difference() produces invalid (self-intersecting) result for valid polygon-with-hole input
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
- #1491 của @tinko92 — đã đóng, không merge
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 70/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- cpp
- Lĩnh vực
- computer-graphics
Hướng nghiên cứu
Bắt đầu với testing.cpp đính kèm và tái hiện trường hợp này với Boost 1.91.0, tập trung vào bg::difference() khi lỗ của đa giác A chạm vào biên của đa giác B. Sử dụng bg::is_valid() và self-intersection được báo cáo tại (5, 15) để theo dõi kết quả; hoàn tất khi difference() trả về một hình học hợp lệ loại trừ B.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version of Boost
1.91.0
Actual and Expected Behavior
Actual: boost::geometry::difference() on two valid multi_polygon operands (a polygon with a hole, minus another polygon) returns a result that fails boost::geometry::is_valid() — it contains a self-intersection introduced at the point where the hole's ring touches the subtracted polygon's boundary.
I discovered this by seeing that a point, that is in A \ B, is reported as also being within B, which violates the basic definition of set difference.
Expected: boost::geometry::difference() should return a valid geometry (satisfying is_valid()) for valid input operands.
Minimal complete program: attached testing.cpp
#include <boost/geometry.hpp>
#include <cassert>
#include <iostream>
namespace bg = boost::geometry;
using int_point_t = bg::model::point<int64_t, 2, bg::cs::cartesian>;
using int_poly_t = bg::model::polygon<int_point_t>;
using int_multi_poly_t = bg::model::multi_polygon<int_poly_t>;
int main()
{
int_multi_poly_t poly_A;
boost::geometry::read_wkt("MULTIPOLYGON(((0 0,20 0,20 20,0 20,0 0),(5 15,14 14,9 6,5 15)))", poly_A);
int_multi_poly_t poly_B;
boost::geometry::read_wkt("MULTIPOLYGON(((5 15,5 5,15 5,15 15,5 15)))", poly_B);
bg::correct(poly_A);
bg::correct(poly_B);
assert(bg::is_valid(poly_A));
assert(bg::is_valid(poly_B));
int_multi_poly_t result;
boost::geometry::difference(poly_A, poly_B, result);
std::cout << boost::geometry::to_wkt(result) << std::endl;
if (std::string message; !bg::is_valid(result, message))
std::cerr << "Invalid geometry: " << message << std::endl;
}
Output when run:
MULTIPOLYGON(((0 0,0 20,20 20,20 0,0 0),(5 15,9 6,14 14,5 15),(5 15,5 5,15 5,15 15,5 15)))
Invalid geometry: Geometry has invalid self-intersections. A self-intersection point was found at (5, 15); method: t; operations: u/i; segment IDs {source, multi, ring, segment}: {0, 0, 0, 2}/{0, 0, 1, 3}
Pictures of input:
Picture of output:
Steps necessary to reproduce the problem
- Build the attached
testing.cppagainst Boost 1.91.0. - Run it.
- Observe that
bg::is_valid(result, message)reportsfalsewith a self-intersection at the point where polygon A's hole ring touches polygon B's boundary.
Both input polygons (poly_A, poly_B) are individually valid (confirmed via is_valid() before the difference() call in the program), so the invalidity is introduced by difference() itself.
All relevant compiler information
- Compiler: GCC 14 (
g++-14.3.0) - Standard: C++23 (
-std=gnu++23) - OS: Linux
- Ngôn ngữ chính
- C++
- Star
- 519
- Fork
- 241
- Merge trung bình
- 4 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 9
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của boostorg/geometry
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 57/100
boostorg/geometry#1523 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
LLM generated regression case in differenceCó thể đã có người làm @barendgehrels đã nhận 11 ngày trước. Đang mởbug
boostorg/geometry#1511 · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
union_ of two valid polygons sharing an edge returns empty (argument order dependent)Có thể đã có người làm @barendgehrels đã nhận 16 ngày trước. Đang mở
boostorg/geometry#1506 · 1 bình luận · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
boostorg/geometry#1476 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
I cannot get Dissolve to compile in version 1.91Có thể làm lại được @barendgehrels đã nhận 160 ngày trước và không có pull request nào đang mở. Đang mở
boostorg/geometry#1472 · 8 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của boostorg/geometry
Issue tương tự
-
agent:WSL code-review linux pri:medium refactoring
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
-
kind/enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
psi29a/d2decomped#691 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
CachyOS/packageinstaller#144 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
(S1 - Need confirmation)
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
CleverRaven/Cataclysm-DDA#89715 ·
Maintainer thường phản hồi trong vòng 1 ngày