From b0ca5f27890ed3b78806b34858b8b15781fa928b Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Sat, 15 Mar 2025 12:04:27 +0200 Subject: [PATCH 1/3] Fixed do_intersect() of curves (provided by Edkirito). --- .../CGAL/Arrangement_2/Arrangement_on_surface_2_global.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_global.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_global.h index 5bc8054c525..1436405e4d8 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_global.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_2/Arrangement_on_surface_2_global.h @@ -1568,7 +1568,7 @@ template bool do_intersect(Arrangement_on_surface_2& arr, - const typename GeometryTraits_2::X_monotone_curve_2& c, + const typename GeometryTraits_2::Curve_2& c, const PointLocation& pl, std::is_same::type) { typedef GeometryTraits_2 Gt2; @@ -1607,7 +1607,7 @@ do_intersect(Arrangement_on_surface_2& arr, // Check whether the isolated point lies inside a face (otherwise, // it coincides with a vertex or an edge). auto obj = pl.locate(*iso_p); - if (std::get_if(&x_obj) != nullptr) return true; + if (std::get_if(&obj) != nullptr) return true; } // If we reached here, the curve does not intersect the arrangement. From 30e5d27ffc929d2d3dbb1501f438311b0e28077f Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Sat, 15 Mar 2025 12:09:10 +0200 Subject: [PATCH 2/3] Added comment of a fix in the 2D Arrangement on Surface package --- Installation/CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index bdae9dd56fb..010aa9958b7 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -22,6 +22,7 @@ - Introduces two traits decorators, namely `Arr_tracing_traits_2` and `Arr_counting_traits_2`, which can be used to extract debugging and informative metadata about the traits in use while a program is being executed. - Fixed the Landmark point-location strategy so that it can be applied to arrangements on a sphere. +- Fixed do_intersect() of a 2D Arrangement and a curve. ### [3D Mesh Generation](https://doc.cgal.org/6.1/Manual/packages.html#PkgMesh3) From f1b82b9dcc514072ad39b5a0dce14fad09932a44 Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Mon, 17 Mar 2025 10:10:17 +0200 Subject: [PATCH 3/3] Enhanced to test intersection with (non x-monotone) curves --- .../test_do_intersect.cpp | 62 ++++++++++--------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_do_intersect.cpp b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_do_intersect.cpp index e1287e2761a..c5436ee7b89 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_do_intersect.cpp +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/test_do_intersect.cpp @@ -8,47 +8,49 @@ #include #include -typedef CGAL::Quotient Number_type; -typedef CGAL::Simple_cartesian Kernel; -typedef CGAL::Arr_segment_traits_2 Traits_2; -typedef Traits_2::Point_2 Point_2; -typedef Traits_2::X_monotone_curve_2 Segment_2; -typedef CGAL::Arrangement_2 Arrangement_2; -typedef Arrangement_2::Halfedge_handle Halfedge_handle; +using Number_type = CGAL::Quotient; +using Kernel = CGAL::Simple_cartesian; +using Traits_2 = CGAL::Arr_segment_traits_2; +using Point_2 = Traits_2::Point_2; +using Segment_2 = Traits_2::X_monotone_curve_2; +using Arrangement_2 = CGAL::Arrangement_2; +using Halfedge_handle = Arrangement_2::Halfedge_handle; -#define N_SEGMENTS 3 +int main () { + Arrangement_2 arr; + using Tt = Arrangement_2::Topology_traits; + Tt::Default_point_location_strategy def_pl(arr); -int main () -{ - Arrangement_2 arr; - Segment_2 segs[N_SEGMENTS]; - bool expected_intersect[N_SEGMENTS]; - int k; + Segment_2 segs[] = { + Segment_2(Point_2(-2, -2), Point_2(-1, -1)), + Segment_2(Point_2(-1, 1), Point_2(0, 1)), + Segment_2(Point_2(-1, 0), Point_2(0, 0)) + }; - segs[0] = Segment_2 (Point_2 (-2, -2), Point_2 (-1, -1)); - segs[1] = Segment_2 (Point_2 (-1, 1), Point_2 (0, 1)); - segs[2] = Segment_2 (Point_2 (-1, 0), Point_2 (0, 0)); - - expected_intersect[0] = false; - expected_intersect[1] = true; - expected_intersect[2] = true; + bool expected_intersect[] = {false, true, true}; insert(arr, Segment_2(Point_2(0, 0), Point_2(2, 0))); insert(arr, Segment_2(Point_2(2, 0), Point_2(2, 2))); insert(arr, Segment_2(Point_2(2, 2), Point_2(0, 2))); insert(arr, Segment_2(Point_2(0, 2), Point_2(0, 0))); - for (k = 0; k < N_SEGMENTS; k++) - { - bool do_inter = do_intersect(arr, segs[k]); + size_t k = 0; + for (const auto& seg : segs) { + bool do_inter_0 = do_intersect(arr, seg); + bool do_inter_1 = do_intersect(arr, seg, def_pl, std::true_type()); + bool do_inter_2 = do_intersect(arr, seg, def_pl, std::false_type()); - std::cout << "Segment: " << segs[k]; - std::cout << " Expected: " << expected_intersect[k]; - std::cout << " Actual: " << do_inter << std::endl; + std::cout << "Segment: " << segs[k] << std::endl; + std::cout << " Expected: " << expected_intersect[k] << std::endl; + std::cout << " Actual auto: " << do_inter_0 << std::endl; + std::cout << " Actual x-monotone curve: " << do_inter_1 << std::endl; + std::cout << " Actual curve: " << do_inter_2 << std::endl; - if (expected_intersect[k] != do_inter) - return (1); + if (expected_intersect[k] != do_inter_0) return -1; + if (expected_intersect[k] != do_inter_1) return -1; + if (expected_intersect[k] != do_inter_2) return -1; + ++k; } - return (0); + return 0; }