From a994933ccbc957496522775a94aac3a83b19839f Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 30 Jun 2022 11:44:09 +0100 Subject: [PATCH 01/13] Nef_3: Fix conversion to a FaceGraph --- .../include/CGAL/Nef_3/SNC_const_decorator.h | 10 +++++ .../convert_nef_polyhedron_to_polygon_mesh.h | 20 +++++---- Nef_3/test/Nef_3/issue_6423.cpp | 44 +++++++++++++++++++ 3 files changed, 66 insertions(+), 8 deletions(-) create mode 100644 Nef_3/test/Nef_3/issue_6423.cpp diff --git a/Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h b/Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h index a8b0123f3df..910ba280e2f 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h @@ -535,6 +535,16 @@ visit_shell_objects(typename Traits::SFace_handle f, Visitor& V) const } Halffacet_handle f = ec->twin()->facet(); if ( Done[f] ) continue; + Halffacet_handle tf = f->twin(); + if ((f->incident_volume() == tf->incident_volume()) && Done[tf]) { + continue; // for example when we have to do with the unbounded volume and a surface with boundaries + } + Volume_const_iterator unbounded = volumes_begin(); + Volume_const_iterator fit = f->incident_volume(); + Volume_const_iterator tfit = tf->incident_volume(); + if ((fit == unbounded) && (tfit != unbounded)) { + continue; // because we will later report it from the bounded side + } FacetCandidates.push_back(f); Done[f] = true; } } else if (fc.is_svertex() ) { diff --git a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index a5e5e619120..f2a880c8872 100644 --- a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -351,18 +351,22 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, typedef Cartesian_converter Converter; typename Nef_polyhedron::Volume_const_iterator vol_it = nef.volumes_begin(), vol_end = nef.volumes_end(); - if ( Nef_polyhedron::Infi_box::extended_kernel() ) ++vol_it; // skip Infi_box + + if (Nef_polyhedron::Infi_box::extended_kernel()) { + ++vol_it; // skip Infi_box + } + CGAL_assertion ( vol_it != vol_end ); - ++vol_it; // skip unbounded volume Converter to_output; for (;vol_it!=vol_end;++vol_it) - nef_to_pm::collect_polygon_mesh_info(points, - polygons, - nef, - vol_it->shells_begin(), - to_output, - triangulate_all_faces); + for(auto sit = vol_it->shells_begin(); sit != vol_it->shells_end(); ++sit) + nef_to_pm::collect_polygon_mesh_info(points, + polygons, + nef, + sit, + to_output, + triangulate_all_faces); } template diff --git a/Nef_3/test/Nef_3/issue_6423.cpp b/Nef_3/test/Nef_3/issue_6423.cpp new file mode 100644 index 00000000000..0ffad5bf0e1 --- /dev/null +++ b/Nef_3/test/Nef_3/issue_6423.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include +#include + +typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel; +typedef Kernel::Point_3 Point_3; +typedef CGAL::Surface_mesh SurfaceMesh; +typedef CGAL::Nef_polyhedron_3 NefPolyhedron; + + +int main(int argc, char* argv[]) +{ + SurfaceMesh surfaceMesh; + SurfaceMesh::Vertex_index v0 = surfaceMesh.add_vertex(Point_3(-1, 0, 0)); + SurfaceMesh::Vertex_index v1 = surfaceMesh.add_vertex(Point_3(1, 0, 0)); + SurfaceMesh::Vertex_index v2 = surfaceMesh.add_vertex(Point_3(0, 1, 0)); + + SurfaceMesh::Vertex_index v3 = surfaceMesh.add_vertex(Point_3(-1, 0, 1)); + SurfaceMesh::Vertex_index v4 = surfaceMesh.add_vertex(Point_3(1, 0, 1)); + SurfaceMesh::Vertex_index v5 = surfaceMesh.add_vertex(Point_3(0, 1, 1)); + + surfaceMesh.add_face(v0, v1, v2); + surfaceMesh.add_face(v3, v4, v5); + + make_tetrahedron(Point_3(-1, 0, 10), + Point_3(1, 0, 10), + Point_3(0, 1, 10), + Point_3(-1, 0, 11), + surfaceMesh); + + std::cout << "Before conversion, number_of_faces: " << surfaceMesh.number_of_faces() << std::endl; + + NefPolyhedron nefPoly(surfaceMesh); + std::cout << "NefPolyhedron, number_of_faces: " << nefPoly.number_of_facets() << std::endl; + std::cout << nefPoly << std::endl; + SurfaceMesh convertedSurfaceMesh; + CGAL::convert_nef_polyhedron_to_polygon_mesh(nefPoly, convertedSurfaceMesh, true); + std::cout << "After conversion, number_of_faces: " << convertedSurfaceMesh.number_of_faces() << std::endl; + std::cout << convertedSurfaceMesh << std::endl; + return EXIT_SUCCESS; +} From 07b04366a0e01015f0ccf2f9f49a43d4a7331dbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 6 Jul 2022 17:09:55 +0200 Subject: [PATCH 02/13] WIP --- Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h | 6 ------ .../graph/convert_nef_polyhedron_to_polygon_mesh.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h b/Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h index 910ba280e2f..c2c622a181e 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h @@ -539,12 +539,6 @@ visit_shell_objects(typename Traits::SFace_handle f, Visitor& V) const if ((f->incident_volume() == tf->incident_volume()) && Done[tf]) { continue; // for example when we have to do with the unbounded volume and a surface with boundaries } - Volume_const_iterator unbounded = volumes_begin(); - Volume_const_iterator fit = f->incident_volume(); - Volume_const_iterator tfit = tf->incident_volume(); - if ((fit == unbounded) && (tfit != unbounded)) { - continue; // because we will later report it from the bounded side - } FacetCandidates.push_back(f); Done[f] = true; } } else if (fc.is_svertex() ) { diff --git a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index f2a880c8872..bb11c0daace 100644 --- a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -359,14 +359,28 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, CGAL_assertion ( vol_it != vol_end ); Converter to_output; + bool handling_unbounded_volume = true; + + auto shell_is_closed = [](typename Nef_polyhedron::SFace_const_handle sfh) + { + typename Nef_polyhedron::Halffacet_handle f = sfh; + return f->incident_volume()!=f->twin()->incident_volume(); + }; + for (;vol_it!=vol_end;++vol_it) + { for(auto sit = vol_it->shells_begin(); sit != vol_it->shells_end(); ++sit) + { + if ( (handling_unbounded_volume || sit!=vol_it->shells_begin()) && shell_is_closed(sit)) continue; nef_to_pm::collect_polygon_mesh_info(points, polygons, nef, sit, to_output, triangulate_all_faces); + } + handling_unbounded_volume = false; + } } template From 69c4af61a9a3aae06c00e79cada527659439f81f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 7 Jul 2022 09:21:10 +0200 Subject: [PATCH 03/13] fix types, still not valid --- .../CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index bb11c0daace..98fb89d7192 100644 --- a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -361,9 +361,9 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, Converter to_output; bool handling_unbounded_volume = true; - auto shell_is_closed = [](typename Nef_polyhedron::SFace_const_handle sfh) + auto shell_is_closed = [](typename Nef_polyhedron::Shell_entry_const_iterator sfh) { - typename Nef_polyhedron::Halffacet_handle f = sfh; + typename Nef_polyhedron::Halffacet_const_handle f = sfh; return f->incident_volume()!=f->twin()->incident_volume(); }; From 744a9643722d2d8a17685b41b0bf6b29f1ca8e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 7 Jul 2022 09:36:39 +0200 Subject: [PATCH 04/13] fix compilation errors --- .../boost/graph/convert_nef_polyhedron_to_polygon_mesh.h | 8 ++++++-- Nef_3/test/Nef_3/issue_6423.cpp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index 98fb89d7192..c055798f877 100644 --- a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -363,8 +363,12 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, auto shell_is_closed = [](typename Nef_polyhedron::Shell_entry_const_iterator sfh) { - typename Nef_polyhedron::Halffacet_const_handle f = sfh; - return f->incident_volume()!=f->twin()->incident_volume(); + typename Nef_polyhedron::Halffacet_const_handle f; + + if (CGAL::assign(f,*sfh)) + return f->incident_volume()!=f->twin()->incident_volume(); + else + return false; }; for (;vol_it!=vol_end;++vol_it) diff --git a/Nef_3/test/Nef_3/issue_6423.cpp b/Nef_3/test/Nef_3/issue_6423.cpp index 0ffad5bf0e1..5eeb664f23b 100644 --- a/Nef_3/test/Nef_3/issue_6423.cpp +++ b/Nef_3/test/Nef_3/issue_6423.cpp @@ -11,7 +11,7 @@ typedef CGAL::Surface_mesh SurfaceMesh; typedef CGAL::Nef_polyhedron_3 NefPolyhedron; -int main(int argc, char* argv[]) +int main() { SurfaceMesh surfaceMesh; SurfaceMesh::Vertex_index v0 = surfaceMesh.add_vertex(Point_3(-1, 0, 0)); From 31868332680d0219bbe94500ea460f9bdbe1fef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 7 Jul 2022 10:16:18 +0200 Subject: [PATCH 05/13] WIP working with simple soup example --- .../convert_nef_polyhedron_to_polygon_mesh.h | 80 +++++++++++++++++-- 1 file changed, 75 insertions(+), 5 deletions(-) diff --git a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index c055798f877..218e7210866 100644 --- a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -363,12 +363,82 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, auto shell_is_closed = [](typename Nef_polyhedron::Shell_entry_const_iterator sfh) { - typename Nef_polyhedron::Halffacet_const_handle f; + typename Nef_polyhedron::SFace_const_handle sf = sfh; - if (CGAL::assign(f,*sfh)) - return f->incident_volume()!=f->twin()->incident_volume(); - else - return false; + typename Nef_polyhedron::SFace_cycle_const_iterator fc; + for(fc = sf->sface_cycles_begin(); fc != sf->sface_cycles_end(); ++fc) + { + if (fc.is_shalfedge() ) { + typename Nef_polyhedron::SHalfedge_const_handle e(fc); + typename Nef_polyhedron::SHalfedge_around_sface_const_circulator ec(e),ee(e); + CGAL_For_all(ec,ee) + { + typename Nef_polyhedron::SVertex_const_handle vv = ec->twin()->source(); + //~ if ( !SD.is_isolated(vv) && !Done[vv] ) { + //~ V.visit(vv); // report edge + //~ Done[vv] = Done[vv->twin()] = true; + //~ } + typename Nef_polyhedron::Halffacet_const_handle f = ec->twin()->facet(); + return f->incident_volume()!=f->twin()->incident_volume(); + //~ if ( Done[f] ) continue; + //~ Halffacet_handle tf = f->twin(); + //~ } + //~ FacetCandidates.push_back(f); Done[f] = true; + } + } + +#if 0 + else if (fc.is_svertex() ) { + SVertex_handle v(fc); + if ( Done[v] ) continue; + V.visit(v); // report edge + V.visit(v->twin()); + Done[v] = Done[v->twin()] = true; + CGAL_assertion(SD.is_isolated(v)); + SFaceCandidates.push_back(v->twin()->incident_sface()); + Done[v->twin()->incident_sface()]=true; + // note that v is isolated, thus twin(v) is isolated too + // SM_const_decorator SD; + // SFace_const_handle fo; + // fo = v->twin()->incident_sface(); + /* + if(SD.is_isolated(v)) + fo = v->source()->sfaces_begin(); + else + fo = v->twin()->incident_sface(); + */ + } else if (fc.is_shalfloop() ) { + SHalfloop_handle l(fc); + V.visit(l); + Halffacet_handle f = l->twin()->facet(); + if ( Done[f] ) continue; + FacetCandidates.push_back(f); Done[f] = true; + } else CGAL_error_msg("Damn wrong handle."); +#endif + } + + return false; + + //~ typename Nef_polyhedron::SHalfedge_const_handle e(sf); + //~ typename Nef_polyhedron::SHalffacet_const_handle f = e->facet(); + //~ e->facet() + //~ SHalfedge_around_sface_circulator ec(e),ee(e); + //~ CGAL_For_all(ec,ee) { + //~ SVertex_handle vv = ec->twin()->source(); + //~ if ( !SD.is_isolated(vv) && !Done[vv] ) { + //~ V.visit(vv); // report edge + //~ Done[vv] = Done[vv->twin()] = true; + //~ } + //~ Halffacet_handle f = ec->twin()->facet(); + //~ if ( Done[f] ) continue; + + //~ if (CGAL::assign(f,*sfh)) + //~ { + //~ std::cout << "COUCOU\n"; + //~ return f->incident_volume()!=f->twin()->incident_volume(); + //~ } + //~ else + //~ return false; }; for (;vol_it!=vol_end;++vol_it) From 37eb0eaa173499227e109cb1cf46cdb08d0dd273 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 6 Aug 2024 10:33:14 +0200 Subject: [PATCH 06/13] Tentative fix for L3R3 do_intersect --- .../Intersections_3/internal/Line_3_Ray_3_do_intersect.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Intersections_3/include/CGAL/Intersections_3/internal/Line_3_Ray_3_do_intersect.h b/Intersections_3/include/CGAL/Intersections_3/internal/Line_3_Ray_3_do_intersect.h index e6e125107f0..4659dda8c45 100644 --- a/Intersections_3/include/CGAL/Intersections_3/internal/Line_3_Ray_3_do_intersect.h +++ b/Intersections_3/include/CGAL/Intersections_3/internal/Line_3_Ray_3_do_intersect.h @@ -38,11 +38,8 @@ do_intersect(const typename K::Line_3& l, if(p0p1s == COLLINEAR) return true; - CGAL::Orientation stp0 = pred(r.source(), r.second_point(), l.point(0)); - if(stp0 == COLLINEAR) - return Ray_3_has_on_collinear_Point_3(r,l.point(0),k); - - return (p0p1s != stp0); + typename K::Point_3 lst = l.point(0) + (r.point(1) - r.point(0)); + return (pred(l.point(0), l.point(1), r.point(0), lst) != CGAL::POSITIVE); } template From c1e5926e707bebe5e17da489ba2e9f757ddee57a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 6 Aug 2024 10:26:10 +0200 Subject: [PATCH 07/13] Add new Intersection_3 test cases --- .../Intersections_3/test_intersections_Line_3.cpp | 4 ++++ .../Intersections_3/test_intersections_Ray_3.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/Intersections_3/test/Intersections_3/test_intersections_Line_3.cpp b/Intersections_3/test/Intersections_3/test_intersections_Line_3.cpp index 6fe55a40654..936e077e018 100644 --- a/Intersections_3/test/Intersections_3/test_intersections_Line_3.cpp +++ b/Intersections_3/test/Intersections_3/test_intersections_Line_3.cpp @@ -232,6 +232,10 @@ struct Line_3_intersection_tester check_no_intersection(L(p(0,0,0),p(1,0,0)), R(p(3,0,1),p(6,0,1))); check_no_intersection(L(p(0,0,0),p(1,0,0)), R(p(0,2,0),p(0,4,0))); check_no_intersection(L(p(0,0,0),p(1,0,0)), R(p(6,2,0),p(5,4,0))); + check_no_intersection(L(p(0,0,0),p(0,1,0)), R(p(1,-1,0),p(1,0,0))); + check_no_intersection(L(p(0,-10,0),p(0,-9,0)), R(p(1,-1,0),p(2,0,0))); + check_no_intersection(L(p(0,-10,0),p(0,0,0)), R(p(1,-1,0),p(2,0,0))); + check_no_intersection(L(p(0,0,0),p(0,1,0)), R(p(1,-1,0),p(2,0,0))); // Point intersection check_intersection (L(p(0,0,0),p(1,0,0)), R(p(3,0,0),p(6,4,0)), diff --git a/Intersections_3/test/Intersections_3/test_intersections_Ray_3.cpp b/Intersections_3/test/Intersections_3/test_intersections_Ray_3.cpp index e1d603d4a5e..777c514bd49 100644 --- a/Intersections_3/test/Intersections_3/test_intersections_Ray_3.cpp +++ b/Intersections_3/test/Intersections_3/test_intersections_Ray_3.cpp @@ -74,6 +74,14 @@ struct Ray_3_intersection_tester check_no_intersection (R(p(0,0,0), p(1,0,0)), R(p(0,1,0), p(0,2,0))); check_no_intersection (R(p(0,0,0), p(1,0,0)), R(p(-1,0,0), p(-1,-1,0))); + check_no_intersection (R(p(1,-1,0), p(2,0,0)), R(p(2,-1,0), p(3,0,0))); + check_no_intersection (R(p(1,-1,0), p(2,0,0)), R(p(2,-1,0), p(3,-1,0))); + check_no_intersection (R(p(1,-1,0), p(2,0,0)), R(p(2,-1,0), p(3,-2,0))); + check_no_intersection (R(p(0,0,0), p(0,1,0)), R(p(0,-1,0), p(1,-1,0))); + check_no_intersection (R(p(0,0,0), p(0,1,0)), R(p(-1,-3,0),p(2,0,0))); + check_no_intersection (R(p(0,0,0), p(0,1,0)), R(p(-2,-4,0),p(-1,-3,0))); + check_no_intersection (R(p(0,0,0), p(0,1,0)), R(p(1,-1,0), p(2,0,0))); + // Point check_intersection (R(p(0,0,0), p(1,0,0)), R(p(0,0,0), p(-1,0,0)), p(0,0,0)); @@ -88,6 +96,10 @@ struct Ray_3_intersection_tester check_intersection (R(p(0,0,0), p(1,0,0)), R(p(1,-2,0), p(1,-1,0)), p(1,0,0)); + check_intersection (R(p(0,0,0), p(1,0,0)), R(p(1,-2,0), p(1,-1,0)), + p(1,0,0)); + + // Segment check_intersection (R(p(0,0,0), p(1,0,0)), R(p(2,0,0), p(-3,0,0)), S(p(0,0,0), p(2,0,0)), false); From 403ec19f8a07f5e3a1a0e5f0477bbada3429574b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 14 Aug 2024 18:18:26 +0200 Subject: [PATCH 08/13] clean up and move skip test to export header --- .../include/CGAL/Nef_3/SNC_const_decorator.h | 4 - .../convert_nef_polyhedron_to_polygon_mesh.h | 81 ++++--------------- Nef_3/test/Nef_3/issue_6423.cpp | 1 + 3 files changed, 18 insertions(+), 68 deletions(-) diff --git a/Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h b/Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h index c2c622a181e..a8b0123f3df 100644 --- a/Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h +++ b/Nef_3/include/CGAL/Nef_3/SNC_const_decorator.h @@ -535,10 +535,6 @@ visit_shell_objects(typename Traits::SFace_handle f, Visitor& V) const } Halffacet_handle f = ec->twin()->facet(); if ( Done[f] ) continue; - Halffacet_handle tf = f->twin(); - if ((f->incident_volume() == tf->incident_volume()) && Done[tf]) { - continue; // for example when we have to do with the unbounded volume and a surface with boundaries - } FacetCandidates.push_back(f); Done[f] = true; } } else if (fc.is_svertex() ) { diff --git a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index 218e7210866..8b03c755507 100644 --- a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -25,6 +25,7 @@ #include #include #include +#include #include @@ -81,6 +82,7 @@ struct Shell_polygons_visitor Vertex_index_map& vertex_indices; PolygonRange& polygons; bool triangulate_all_faces; + CGAL::Generic_handle_map Done; Shell_polygons_visitor(Vertex_index_map& vertex_indices, PolygonRange& polygons, @@ -88,6 +90,7 @@ struct Shell_polygons_visitor : vertex_indices( vertex_indices ) , polygons(polygons) , triangulate_all_faces(triangulate_all_faces) + , Done(false) {} std::size_t get_cycle_length( typename Nef_polyhedron::Halffacet_cycle_const_iterator hfc) const @@ -103,6 +106,14 @@ struct Shell_polygons_visitor void visit(typename Nef_polyhedron::Halffacet_const_handle opposite_facet) { + typename Nef_polyhedron::Halffacet_const_handle twin_facet = opposite_facet->twin(); + + // skip when we have to do with the unbounded volume and a surface with boundaries + if ((twin_facet->incident_volume() == opposite_facet->incident_volume()) && Done[twin_facet]) + return; + + Done[opposite_facet] = true; + bool is_marked=opposite_facet->incident_volume()->mark(); CGAL_assertion(Nef_polyhedron::Infi_box::is_standard(opposite_facet->plane())); @@ -352,11 +363,9 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, typename Nef_polyhedron::Volume_const_iterator vol_it = nef.volumes_begin(), vol_end = nef.volumes_end(); - if (Nef_polyhedron::Infi_box::extended_kernel()) { - ++vol_it; // skip Infi_box - } + if (Nef_polyhedron::Infi_box::extended_kernel()) ++vol_it; // skip Infi_box - CGAL_assertion ( vol_it != vol_end ); + if ( vol_it == vol_end ) return; Converter to_output; bool handling_unbounded_volume = true; @@ -374,71 +383,15 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, CGAL_For_all(ec,ee) { typename Nef_polyhedron::SVertex_const_handle vv = ec->twin()->source(); - //~ if ( !SD.is_isolated(vv) && !Done[vv] ) { - //~ V.visit(vv); // report edge - //~ Done[vv] = Done[vv->twin()] = true; - //~ } + typename Nef_polyhedron::Halffacet_const_handle f = ec->twin()->facet(); - return f->incident_volume()!=f->twin()->incident_volume(); - //~ if ( Done[f] ) continue; - //~ Halffacet_handle tf = f->twin(); - //~ } - //~ FacetCandidates.push_back(f); Done[f] = true; + if (f->incident_volume()==f->twin()->incident_volume()) + return false; } } - -#if 0 - else if (fc.is_svertex() ) { - SVertex_handle v(fc); - if ( Done[v] ) continue; - V.visit(v); // report edge - V.visit(v->twin()); - Done[v] = Done[v->twin()] = true; - CGAL_assertion(SD.is_isolated(v)); - SFaceCandidates.push_back(v->twin()->incident_sface()); - Done[v->twin()->incident_sface()]=true; - // note that v is isolated, thus twin(v) is isolated too - // SM_const_decorator SD; - // SFace_const_handle fo; - // fo = v->twin()->incident_sface(); - /* - if(SD.is_isolated(v)) - fo = v->source()->sfaces_begin(); - else - fo = v->twin()->incident_sface(); - */ - } else if (fc.is_shalfloop() ) { - SHalfloop_handle l(fc); - V.visit(l); - Halffacet_handle f = l->twin()->facet(); - if ( Done[f] ) continue; - FacetCandidates.push_back(f); Done[f] = true; - } else CGAL_error_msg("Damn wrong handle."); -#endif } - return false; - - //~ typename Nef_polyhedron::SHalfedge_const_handle e(sf); - //~ typename Nef_polyhedron::SHalffacet_const_handle f = e->facet(); - //~ e->facet() - //~ SHalfedge_around_sface_circulator ec(e),ee(e); - //~ CGAL_For_all(ec,ee) { - //~ SVertex_handle vv = ec->twin()->source(); - //~ if ( !SD.is_isolated(vv) && !Done[vv] ) { - //~ V.visit(vv); // report edge - //~ Done[vv] = Done[vv->twin()] = true; - //~ } - //~ Halffacet_handle f = ec->twin()->facet(); - //~ if ( Done[f] ) continue; - - //~ if (CGAL::assign(f,*sfh)) - //~ { - //~ std::cout << "COUCOU\n"; - //~ return f->incident_volume()!=f->twin()->incident_volume(); - //~ } - //~ else - //~ return false; + return true; }; for (;vol_it!=vol_end;++vol_it) diff --git a/Nef_3/test/Nef_3/issue_6423.cpp b/Nef_3/test/Nef_3/issue_6423.cpp index 5eeb664f23b..87e7f7dff61 100644 --- a/Nef_3/test/Nef_3/issue_6423.cpp +++ b/Nef_3/test/Nef_3/issue_6423.cpp @@ -40,5 +40,6 @@ int main() CGAL::convert_nef_polyhedron_to_polygon_mesh(nefPoly, convertedSurfaceMesh, true); std::cout << "After conversion, number_of_faces: " << convertedSurfaceMesh.number_of_faces() << std::endl; std::cout << convertedSurfaceMesh << std::endl; + std::ofstream("out.off") << convertedSurfaceMesh; return EXIT_SUCCESS; } From 30fc15064bc66a8f6bcf4222878139b201272d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 14 Aug 2024 18:22:04 +0200 Subject: [PATCH 09/13] add assertions --- Nef_3/test/Nef_3/issue_6423.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Nef_3/test/Nef_3/issue_6423.cpp b/Nef_3/test/Nef_3/issue_6423.cpp index 87e7f7dff61..441dd0b7939 100644 --- a/Nef_3/test/Nef_3/issue_6423.cpp +++ b/Nef_3/test/Nef_3/issue_6423.cpp @@ -35,11 +35,11 @@ int main() NefPolyhedron nefPoly(surfaceMesh); std::cout << "NefPolyhedron, number_of_faces: " << nefPoly.number_of_facets() << std::endl; - std::cout << nefPoly << std::endl; SurfaceMesh convertedSurfaceMesh; CGAL::convert_nef_polyhedron_to_polygon_mesh(nefPoly, convertedSurfaceMesh, true); std::cout << "After conversion, number_of_faces: " << convertedSurfaceMesh.number_of_faces() << std::endl; - std::cout << convertedSurfaceMesh << std::endl; std::ofstream("out.off") << convertedSurfaceMesh; + assert(vertices(convertedSurfaceMesh).size()==10); + assert(faces(convertedSurfaceMesh).size()==6); return EXIT_SUCCESS; } From d20cef2f911a2e9773e6394708a14e5d3544222d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 19 Aug 2024 09:02:24 +0200 Subject: [PATCH 10/13] remove unused variable --- .../CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h index 8b03c755507..3ecd0e1b805 100644 --- a/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h +++ b/Nef_3/include/CGAL/boost/graph/convert_nef_polyhedron_to_polygon_mesh.h @@ -382,8 +382,6 @@ void convert_nef_polyhedron_to_polygon_soup(const Nef_polyhedron& nef, typename Nef_polyhedron::SHalfedge_around_sface_const_circulator ec(e),ee(e); CGAL_For_all(ec,ee) { - typename Nef_polyhedron::SVertex_const_handle vv = ec->twin()->source(); - typename Nef_polyhedron::Halffacet_const_handle f = ec->twin()->facet(); if (f->incident_volume()==f->twin()->incident_volume()) return false; From ca2907fbfc0cbfcdf093d73774826a0e858a15ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 20 Aug 2024 10:09:23 +0200 Subject: [PATCH 11/13] avoid creating degenerate planes --- .../test/Intersections_3/test_intersections_Ray_3.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Intersections_3/test/Intersections_3/test_intersections_Ray_3.cpp b/Intersections_3/test/Intersections_3/test_intersections_Ray_3.cpp index e1d603d4a5e..6a3dd24bcea 100644 --- a/Intersections_3/test/Intersections_3/test_intersections_Ray_3.cpp +++ b/Intersections_3/test/Intersections_3/test_intersections_Ray_3.cpp @@ -161,6 +161,8 @@ struct Ray_3_intersection_tester for(int i=0; i Date: Fri, 23 Aug 2024 15:49:20 +0200 Subject: [PATCH 12/13] fix SELinux contexts so that the web server can offer the files --- Scripts/developer_scripts/run_doxygen_testsuite | 1 + 1 file changed, 1 insertion(+) diff --git a/Scripts/developer_scripts/run_doxygen_testsuite b/Scripts/developer_scripts/run_doxygen_testsuite index ec3a5855620..271fb9699aa 100755 --- a/Scripts/developer_scripts/run_doxygen_testsuite +++ b/Scripts/developer_scripts/run_doxygen_testsuite @@ -65,6 +65,7 @@ bash -$- ./process_doc.sh /home/cgal-testsuite/bin/doxygen_1_8_13 /home/cgal-tes if head -2 ../../.scm-branch | grep -q cgal/master; then rsync -a --delete "/srv/CGAL/www/Members/Manual_doxygen_test/${CGAL_RELEASE_ID}/output2/" /srv/CGAL/www/doc/master/ fi +restorecon -R /srv/CGAL/www/doc/master/ /srv/CGAL/www/Members/Manual_doxygen_test/${CGAL_RELEASE_ID} rm -rf "${CGAL_DOC_BUILD}" # Then gzip the log file, to save space exec From 7838b95b948fadfb25b4d49ad1ae46b1d04e2362 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 23 Aug 2024 15:55:55 +0200 Subject: [PATCH 13/13] generate review of the code --- .../developer_scripts/run_doxygen_testsuite | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Scripts/developer_scripts/run_doxygen_testsuite b/Scripts/developer_scripts/run_doxygen_testsuite index 271fb9699aa..22d9aab978f 100755 --- a/Scripts/developer_scripts/run_doxygen_testsuite +++ b/Scripts/developer_scripts/run_doxygen_testsuite @@ -6,7 +6,7 @@ cd /home/cgal-testsuite # Rotate log files on one month: the logfile name contains the number of # the day -LOGFILE=$PWD/doxygen_testsuite-`date '+%d'`.log +LOGFILE=$PWD/doxygen_testsuite-$(date '+%d').log exec > "$LOGFILE" @@ -31,8 +31,8 @@ if [ -r "${CGAL_DOC_BUILD}" ]; then rm -rf "${CGAL_DOC_BUILD}" fi -mkdir ${CGAL_DOC_BUILD} -cd ${CGAL_DOC_BUILD} +mkdir "${CGAL_DOC_BUILD}" +cd "${CGAL_DOC_BUILD}" if [ -r "LATEST" ]; then rm -rf LATEST @@ -44,12 +44,12 @@ if [ ! -f "LATEST" ]; then error "COULD NOT DOWNLOAD LATEST!" fi -for i in `cat LATEST` +for i in $(cat LATEST) do CGAL_LOCATION="${CGAL_URL}/${i}"; CGAL_ZIPFILE="${i}"; done -CGAL_RELEASE_ID=`echo $CGAL_ZIPFILE | sed "s/.tar.gz//"` +CGAL_RELEASE_ID=$(echo "$CGAL_ZIPFILE" | sed "s/.tar.gz//") curl ${CURL_OPTS} "${CGAL_LOCATION}" tar xvzf "${CGAL_ZIPFILE}" && rm "${CGAL_ZIPFILE}" @@ -60,12 +60,16 @@ cd "${CGAL_RELEASE_ID}" PATH=/home/cgal-testsuite/local/bin:$PATH export PATH -cd "$PWD/doc/scripts" +cd "${PWD}/doc/scripts" bash -$- ./process_doc.sh /home/cgal-testsuite/bin/doxygen_1_8_13 /home/cgal-testsuite/bin/doxygen_1_9_6 /srv/CGAL/www/Members/Manual_doxygen_test if head -2 ../../.scm-branch | grep -q cgal/master; then rsync -a --delete "/srv/CGAL/www/Members/Manual_doxygen_test/${CGAL_RELEASE_ID}/output2/" /srv/CGAL/www/doc/master/ fi -restorecon -R /srv/CGAL/www/doc/master/ /srv/CGAL/www/Members/Manual_doxygen_test/${CGAL_RELEASE_ID} +if sestatus &>/dev/null && [ -d "/srv/CGAL/www/doc/master/" ] && [ -d "/srv/CGAL/www/Members/Manual_doxygen_test/${CGAL_RELEASE_ID}" ]; then + restorecon -R /srv/CGAL/www/doc/master/ /srv/CGAL/www/Members/Manual_doxygen_test/${CGAL_RELEASE_ID} || error "restorecon command failed" +else + error "SELinux is not enabled or the paths do not exist" +fi rm -rf "${CGAL_DOC_BUILD}" # Then gzip the log file, to save space exec