From 9dcbc58ec94abb0fd85fb0fc7c66ed12edb692cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 31 Jul 2025 11:10:33 +0200 Subject: [PATCH] add a constructor taking a lvalue of an AABB-tree we can construct the tree for a subset of faces and still give the ownership to the class --- .../include/CGAL/Side_of_triangle_mesh.h | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Polygon_mesh_processing/include/CGAL/Side_of_triangle_mesh.h b/Polygon_mesh_processing/include/CGAL/Side_of_triangle_mesh.h index 4c2c98c12bf..7514f945bae 100644 --- a/Polygon_mesh_processing/include/CGAL/Side_of_triangle_mesh.h +++ b/Polygon_mesh_processing/include/CGAL/Side_of_triangle_mesh.h @@ -164,7 +164,7 @@ public: * @param tree a \cgal `AABB_tree` with `AABB_face_graph_triangle_primitive` as `Primitive` type * @param gt an instance of the geometric traits class * - * @pre `CGAL::is_closed(tmesh) && CGAL::is_triangle_mesh(tmesh)` + * @pre `tree` contains a set of triangle faces representing a closed surface mesh */ Side_of_triangle_mesh(const AABB_tree& tree, const GeomTraits& gt = GeomTraits()) @@ -181,6 +181,34 @@ public: box = tree.bbox(); } + /** + * Constructor that takes a pre-built \cgal `AABB_tree` + * of the triangulated surface mesh primitives, and moves it. + * + * @param tree a \cgal `AABB_tree` with `AABB_face_graph_triangle_primitive` as `Primitive` type + * @param gt an instance of the geometric traits class + * + * @pre `tree` contains a set of triangle faces representing a closed surface mesh + */ + Side_of_triangle_mesh(AABB_tree&& tree, + const GeomTraits& gt = GeomTraits()) + : ray_functor(gt.construct_ray_3_object()) + , vector_functor(gt.construct_vector_3_object()) + , tm_ptr(nullptr) + , own_tree(true) +#ifdef CGAL_HAS_THREADS + , atomic_tree_ptr(new AABB_tree(std::forward(tree))) +#else + , tree_ptr(new AABB_tree(std::forward(tree))) +#endif + { +#ifdef CGAL_HAS_THREADS + box = atomic_tree_ptr.load()->bbox(); +#else + box = tree_ptr->bbox(); +#endif + } + /** * Constructor moving an instance of `Side_of_triangle_mesh` to a new memory * location with minimal memory copy.