From eacbb7c94cce70378b912b632606e5dd58e668a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 29 Mar 2023 16:07:42 +0200 Subject: [PATCH] Change Itag to No_constraints + try-catch --- .../include/CGAL/extrude_skeleton.h | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/Straight_skeleton_extrusion_2/include/CGAL/extrude_skeleton.h b/Straight_skeleton_extrusion_2/include/CGAL/extrude_skeleton.h index 35f132bbf9b..7358064f2d2 100644 --- a/Straight_skeleton_extrusion_2/include/CGAL/extrude_skeleton.h +++ b/Straight_skeleton_extrusion_2/include/CGAL/extrude_skeleton.h @@ -296,7 +296,7 @@ class Extrusion_builder using Vbb = CGAL::Triangulation_vertex_base_2; using Fb = CGAL::Constrained_triangulation_face_base_2; using TDS = CGAL::Triangulation_data_structure_2; - using Itag = CGAL::No_constraint_intersection_requiring_constructions_tag; + using Itag = CGAL::No_constraint_intersection_tag; using CDT = CGAL::Constrained_Delaunay_triangulation_2; using CDT_Vertex_handle = typename CDT::Vertex_handle; using CDT_Face_handle = typename CDT::Face_handle; @@ -341,9 +341,18 @@ public: #endif CDT cdt; - cdt.insert_constraint(p.outer_boundary().begin(), p.outer_boundary().end(), true /*close*/); - for(auto h_it=p.holes_begin(); h_it!=p.holes_end(); ++h_it) - cdt.insert_constraint(h_it->begin(), h_it->end(), true /*close*/); + + try + { + cdt.insert_constraint(p.outer_boundary().begin(), p.outer_boundary().end(), true /*close*/); + for(auto h_it=p.holes_begin(); h_it!=p.holes_end(); ++h_it) + cdt.insert_constraint(h_it->begin(), h_it->end(), true /*close*/); + } + catch(const typename CDT::Intersection_of_constraints_exception& e) + { + std::cerr << "Warning: Failed to triangulate horizontal face" << std::endl; + return; + } std::size_t id = points.size(); // point ID offset (previous faces inserted their points) for(CDT_Vertex_handle vh : cdt.finite_vertex_handles()) @@ -399,7 +408,16 @@ public: const Vector_3 n = CGAL::cross_product(face_points[1] - face_points[0], face_points[2] - face_points[0]); PK traits(n); PCDT pcdt(traits); - pcdt.insert_constraint(face_points.begin(), face_points.end(), true /*close*/); + + try + { + pcdt.insert_constraint(face_points.begin(), face_points.end(), true /*close*/); + } + catch(const typename PCDT::Intersection_of_constraints_exception& e) + { + std::cerr << "Warning: Failed to triangulate skeleton face" << std::endl; + return; + } std::size_t id = points.size(); // point ID offset (previous faces inserted their points); for(PCDT_Vertex_handle vh : pcdt.finite_vertex_handles())