From f7a57a6c41a289e4905c29761304b8b38dbaf946 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Fri, 17 Jan 2025 10:16:08 +0000 Subject: [PATCH 1/4] Add smaller failing issue --- Nef_3/test/Nef_3/issue8644bis.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Nef_3/test/Nef_3/issue8644bis.cpp diff --git a/Nef_3/test/Nef_3/issue8644bis.cpp b/Nef_3/test/Nef_3/issue8644bis.cpp new file mode 100644 index 00000000000..f419094bfc6 --- /dev/null +++ b/Nef_3/test/Nef_3/issue8644bis.cpp @@ -0,0 +1,18 @@ +#include +#include +#include + +using Kernel = CGAL::Extended_cartesian; +using Nef = CGAL::Nef_polyhedron_3; + +int main(int argc, char ** argv) +{ + Nef hspace_1(Nef::Plane_3(1.0, 0.0, 0.0, 0.0), Nef::INCLUDED); + Nef hspace_2(Nef::Plane_3(1.0, 0.0, 0.0, 1.0), Nef::INCLUDED); + Nef hspace_3(Nef::Plane_3(0.0, 0.0, 1.0, 1.0), Nef::INCLUDED); + + Nef intersection_1 = hspace_1*hspace_2; // Line 14. Works fine. + Nef intersection_2 = hspace_2*hspace_3; // Line 15. Assertion failure. + + return 0; +} From f20af1a946ca9255963b965e54178b66f302df93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 30 Jan 2025 18:17:12 +0100 Subject: [PATCH 2/4] fix the value used creating the infimax box used for pairing halfedges without the abs the intersection line of x=-1 and z=-1 would be on the box leading to invalid behavior (and degenerate halfedges) --- Nef_3/include/CGAL/Nef_3/Infimaximal_box.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/Infimaximal_box.h b/Nef_3/include/CGAL/Nef_3/Infimaximal_box.h index b1eb8d6b9ee..463b5f85f60 100644 --- a/Nef_3/include/CGAL/Nef_3/Infimaximal_box.h +++ b/Nef_3/include/CGAL/Nef_3/Infimaximal_box.h @@ -402,9 +402,9 @@ class Infimaximal_box { typename SNC_structure::Vertex_const_iterator v; CGAL_forall_vertices(v, snc) { Point_3 p(v->point()); - if(p.hx()[0] > eval) eval = p.hx()[0]; - if(p.hy()[0] > eval) eval = p.hy()[0]; - if(p.hz()[0] > eval) eval = p.hz()[0]; + if(abs(p.hx()[0]) > eval) eval = abs(p.hx()[0]); + if(abs(p.hy()[0]) > eval) eval = abs(p.hy()[0]); + if(abs(p.hz()[0]) > eval) eval = abs(p.hz()[0]); } eval *= 4; if(eval == 0) return 1; From ca17f813b6102230ec6c4c73d4740e2a86349153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 30 Jan 2025 18:24:06 +0100 Subject: [PATCH 3/4] fix debug --- .../CGAL/Nef_2/Segment_overlay_traits.h | 1 + Nef_3/include/CGAL/Nef_3/K3_tree.h | 2 +- .../CGAL/Nef_3/SNC_external_structure.h | 22 ++++++++++++------- Nef_3/include/CGAL/Nef_3/SNC_intersection.h | 4 ++-- Nef_3/include/CGAL/Nef_3/SNC_point_locator.h | 4 ++-- Nef_3/test/Nef_3/issue8644bis.cpp | 8 +++---- 6 files changed, 24 insertions(+), 17 deletions(-) diff --git a/Nef_2/include/CGAL/Nef_2/Segment_overlay_traits.h b/Nef_2/include/CGAL/Nef_2/Segment_overlay_traits.h index 1eecd047efd..639b4781d6e 100644 --- a/Nef_2/include/CGAL/Nef_2/Segment_overlay_traits.h +++ b/Nef_2/include/CGAL/Nef_2/Segment_overlay_traits.h @@ -627,6 +627,7 @@ public: out << "SweepStatus:\n"; typename SweepStatus::iterator sit3; for( sit3 = YS.begin(); *sit3 != &sh; ++sit3 ) { + if (*sit3==&sl) continue; int b = orientation(sit3, p_sweep); if(*sit3 == &sl) out << " 1"; else if(*sit3 == &sh) out <<"-1"; diff --git a/Nef_3/include/CGAL/Nef_3/K3_tree.h b/Nef_3/include/CGAL/Nef_3/K3_tree.h index 3bec191d7c2..15392c5d5b9 100644 --- a/Nef_3/include/CGAL/Nef_3/K3_tree.h +++ b/Nef_3/include/CGAL/Nef_3/K3_tree.h @@ -517,7 +517,7 @@ Node_handle build_kdtree(Vertex_list& V, Halfedge_list& E, Halffacet_list& F, int coord = depth%3; Point_3 point_on_plane = find_median_point(V, coord); - CGAL_NEF_TRACEN("build_kdtree: plane: "<second.sort(Halfedge_key_lt()); - CGAL_NEF_TRACEN("search opposite "<first); + CGAL_NEF_TRACEN("search opposite (M4) "<first); typename Halfedge_list::iterator itl; CGAL_forall_iterators(itl,it->second) { Halfedge_handle e1 = itl->e; @@ -482,7 +482,7 @@ public: Halfedge_handle e2 = itl->e; CGAL_NEF_TRACEN(" " << e1->source()->point() << " -> " << e2->source()->point()); - CGAL_NEF_TRACEN(e1->vector()<<" -> "<<-e2->vector()); + CGAL_NEF_TRACEN(" " << e1->vector()<<" -> "<<-e2->vector()); make_twins(e1,e2); CGAL_assertion(e1->mark()==e2->mark()); @@ -493,7 +493,7 @@ public: CGAL_forall_iterators(it,M3) { // progress++; it->second.sort(Halfedge_key_lt()); - CGAL_NEF_TRACEN("search opposite "<first); + CGAL_NEF_TRACEN("search opposite (M3) "<first); typename Halfedge_list::iterator itl; CGAL_forall_iterators(itl,it->second) { Halfedge_handle e1 = itl->e; @@ -502,7 +502,7 @@ public: Halfedge_handle e2 = itl->e; CGAL_NEF_TRACEN(" " << e1->source()->point() << " -> " << e2->source()->point()); - CGAL_NEF_TRACEN(e1->vector()<<" -> "<<-e2->vector()); + CGAL_NEF_TRACEN(" " << e1->vector()<<" -> "<<-e2->vector()); make_twins(e1,e2); CGAL_assertion(e1->mark()==e2->mark()); @@ -513,7 +513,7 @@ public: CGAL_forall_iterators(it,M2) { // progress++; it->second.sort(Halfedge_key_lt()); - CGAL_NEF_TRACEN("search opposite "<first); + CGAL_NEF_TRACEN("search opposite (M2) "<first); typename Halfedge_list::iterator itl; CGAL_forall_iterators(itl,it->second) { Halfedge_handle e1 = itl->e; @@ -522,7 +522,7 @@ public: Halfedge_handle e2 = itl->e; CGAL_NEF_TRACEN(" " << e1->source()->point() << " -> " << e2->source()->point()); - CGAL_NEF_TRACEN(e1->vector()<<" -> "<<-e2->vector()); + CGAL_NEF_TRACEN(" " << e1->vector()<<" -> "<<-e2->vector()); make_twins(e1,e2); CGAL_assertion(e1->mark()==e2->mark()); @@ -533,7 +533,7 @@ public: CGAL_forall_iterators(it,M) { // progress++; it->second.sort(Halfedge_key_lt()); - CGAL_NEF_TRACEN("search opposite "<first); + CGAL_NEF_TRACEN("search opposite (M) "<first); typename Halfedge_list::iterator itl; CGAL_forall_iterators(itl,it->second) { Halfedge_handle e1 = itl->e; @@ -542,7 +542,7 @@ public: Halfedge_handle e2 = itl->e; CGAL_NEF_TRACEN(" " << e1->source()->point() << " -> " << e2->source()->point()); - CGAL_NEF_TRACEN(e1->vector()<<" -> "<< -e2->vector()); + CGAL_NEF_TRACEN(" " << e1->vector()<<" -> "<< -e2->vector()); CGAL_assertion(e1->source()->point() != e2->source()->point()); CGAL_assertion(e1->mark()==e2->mark()); make_twins(e1,e2); @@ -585,10 +585,16 @@ public: break; } else #endif + CGAL_assertion_code(bool found = false;) CGAL_For_all(cet,cete) if ( cet->circle() == ce->circle().opposite() && cet->source()->twin() == ce->source() ) + { + CGAL_assertion_code(found = true;) break; + } + + CGAL_assertion(found); #ifdef CGAL_USE_TRACE if( cet->circle() != ce->circle().opposite() ) diff --git a/Nef_3/include/CGAL/Nef_3/SNC_intersection.h b/Nef_3/include/CGAL/Nef_3/SNC_intersection.h index a3a26fb3041..be8345069e2 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_intersection.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_intersection.h @@ -139,7 +139,7 @@ class SNC_intersection { if( !CGAL::assign( p, o)) return false; CGAL_NEF_TRACEN( "-> intersection point: " << p ); - CGAL_NEF_TRACEN( "-> point in facet interior? "< point in facet interior? "< intersection point: " << p ); - CGAL_NEF_TRACEN( "-> point in facet interior? "< point in facet interior? "<source()->point() << "->" << e->twin()->source()->point()); if (SNC_intersection::does_contain_internally(e->source()->point(), e->twin()->source()->point(), p)) { - _CGAL_NEF_TRACEN("found on edge "<< ss); +// _CGAL_NEF_TRACEN("found on edge "<< ss); return make_object(e); } if((e->source() != v) && (e->twin()->source() != v) && @@ -557,7 +557,7 @@ private: if(SNC_intersection::does_intersect_internally( s, *f, q) ) { q = normalized(q); call_back( e0, *f, q); - _CGAL_NEF_TRACEN("edge intersects facet on plane "<plane()<<" on "<plane()<<" on "<; using Nef = CGAL::Nef_polyhedron_3; -int main(int argc, char ** argv) +int main() { Nef hspace_1(Nef::Plane_3(1.0, 0.0, 0.0, 0.0), Nef::INCLUDED); Nef hspace_2(Nef::Plane_3(1.0, 0.0, 0.0, 1.0), Nef::INCLUDED); Nef hspace_3(Nef::Plane_3(0.0, 0.0, 1.0, 1.0), Nef::INCLUDED); - Nef intersection_1 = hspace_1*hspace_2; // Line 14. Works fine. - Nef intersection_2 = hspace_2*hspace_3; // Line 15. Assertion failure. - + Nef intersection_1 = hspace_1*hspace_2; + Nef intersection_2 = hspace_2*hspace_3; + return 0; } From 3abe02075b92dcc03354a21315c8ab5da25e29cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Sat, 1 Feb 2025 23:11:25 +0100 Subject: [PATCH 4/4] GMP is not always available --- Nef_3/test/Nef_3/issue8644bis.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Nef_3/test/Nef_3/issue8644bis.cpp b/Nef_3/test/Nef_3/issue8644bis.cpp index 6968f704c4e..1424419e6cf 100644 --- a/Nef_3/test/Nef_3/issue8644bis.cpp +++ b/Nef_3/test/Nef_3/issue8644bis.cpp @@ -1,8 +1,8 @@ #include -#include +#include #include -using Kernel = CGAL::Extended_cartesian; +using Kernel = CGAL::Extended_cartesian; using Nef = CGAL::Nef_polyhedron_3; int main()