From e431c4e481e11fb4b933010d759f7d4373c8f220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Tue, 14 Feb 2023 14:16:22 +0100 Subject: [PATCH 1/2] early exit if the mesh is empty --- .../include/CGAL/Polygon_mesh_processing/orientation.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h index f5b5f9392a75..01e5cdd5268a 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -1364,6 +1364,9 @@ void orient_to_bound_a_volume(TriangleMesh& tm, typedef typename GetGeomTraits::type GT; typedef typename GetInitializedFaceIndexMap::type FaceIndexMap; + std::size_t nbf = num_faces(tm); + if (nbf == 0) return; + CGAL_precondition(is_closed(tm)); CGAL_precondition(is_triangle_mesh(tm)); @@ -1377,7 +1380,7 @@ void orient_to_bound_a_volume(TriangleMesh& tm, GT gt = choose_parameter(get_parameter(np, internal_np::geom_traits)); FaceIndexMap fid_map = CGAL::get_initialized_face_index_map(tm, np); - std::vector face_cc(num_faces(tm), std::size_t(-1)); + std::vector face_cc(nbf, std::size_t(-1)); std::vector nesting_levels; std::vector is_cc_outward_oriented; Constant_property_map vidmap(0); // dummy map not used From 0c37af1be9b2fce2c1f4fa09d86565b7068b288b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 16 Feb 2023 14:36:58 +0100 Subject: [PATCH 2/2] num_faces is not tight --- .../include/CGAL/Polygon_mesh_processing/orientation.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h index 01e5cdd5268a..b54f44995696 100644 --- a/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h +++ b/Polygon_mesh_processing/include/CGAL/Polygon_mesh_processing/orientation.h @@ -1364,8 +1364,7 @@ void orient_to_bound_a_volume(TriangleMesh& tm, typedef typename GetGeomTraits::type GT; typedef typename GetInitializedFaceIndexMap::type FaceIndexMap; - std::size_t nbf = num_faces(tm); - if (nbf == 0) return; + if (is_empty(tm)) return; CGAL_precondition(is_closed(tm)); CGAL_precondition(is_triangle_mesh(tm)); @@ -1380,7 +1379,7 @@ void orient_to_bound_a_volume(TriangleMesh& tm, GT gt = choose_parameter(get_parameter(np, internal_np::geom_traits)); FaceIndexMap fid_map = CGAL::get_initialized_face_index_map(tm, np); - std::vector face_cc(nbf, std::size_t(-1)); + std::vector face_cc(num_faces(tm), std::size_t(-1)); std::vector nesting_levels; std::vector is_cc_outward_oriented; Constant_property_map vidmap(0); // dummy map not used