diff --git a/Constrained_triangulation_3/include/CGAL/Constrained_triangulation_3/internal/cdt_debug_io.h b/Constrained_triangulation_3/include/CGAL/Constrained_triangulation_3/internal/cdt_debug_io.h index cbbe84405880..96b15e548efe 100644 --- a/Constrained_triangulation_3/include/CGAL/Constrained_triangulation_3/internal/cdt_debug_io.h +++ b/Constrained_triangulation_3/include/CGAL/Constrained_triangulation_3/internal/cdt_debug_io.h @@ -135,19 +135,27 @@ namespace CGAL { // check if the polygon soup is pure triangles, and create a triangulated copy otherwise bool is_pure_triangles = std::all_of(faces.begin(), faces.end(), [](const Face &f) { return f.size() == 3; }); - // create a non-deleting pointer to `faces` (with a null deleter) - using Deleter_function = void(Faces*); - using Deleter = Deleter_function*; - using Ptr = std::unique_ptr; - Ptr triangle_faces_ptr{&faces, +[](Faces *) {}}; - if (!is_pure_triangles) - { - triangle_faces_ptr = Ptr(new Faces(faces), +[](Faces* vector){ delete vector; }); // copy `faces` - PMP::triangulate_polygons(points, *triangle_faces_ptr, np); + { // Now, call does_triangle_soup_self_intersect. + // ... but that function requires a triangulated soup (triangle soup) + // So, if needed, create a copy of the range of faces, and triangulate it on the fly. + + // create a non-deleting pointer to `faces` (with a null deleter) + using Deleter_function = void(Faces*); + using Deleter = Deleter_function*; // function pointer type + using Ptr = std::unique_ptr; + auto null_deleter = +[](Faces *) {}; + Ptr triangle_faces_ptr{&faces, null_deleter}; + if (!is_pure_triangles) + { + auto faces_copy_ptr = new Faces(faces); // copy `faces` + auto delete_function_ptr = +[](Faces* vector){ delete vector; }; + triangle_faces_ptr = Ptr(faces_copy_ptr, delete_function_ptr); + PMP::triangulate_polygons(points, *triangle_faces_ptr, np); + } + + result.polygon_soup_self_intersects = PMP::does_triangle_soup_self_intersect(points, *triangle_faces_ptr, np); } - result.polygon_soup_self_intersects = PMP::does_triangle_soup_self_intersect(points, *triangle_faces_ptr, np); - if (!PMP::orient_polygon_soup(points, faces)) { result.polygon_mesh_is_manifold = false;