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
This commit is contained in:
Sébastien Loriot 2025-07-31 11:10:33 +02:00
parent 8464fae660
commit 9dcbc58ec9
1 changed files with 29 additions and 1 deletions

View File

@ -164,7 +164,7 @@ public:
* @param tree a \cgal `AABB_tree` with `AABB_face_graph_triangle_primitive` as `Primitive` type * @param tree a \cgal `AABB_tree` with `AABB_face_graph_triangle_primitive` as `Primitive` type
* @param gt an instance of the geometric traits class * @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, Side_of_triangle_mesh(const AABB_tree& tree,
const GeomTraits& gt = GeomTraits()) const GeomTraits& gt = GeomTraits())
@ -181,6 +181,34 @@ public:
box = tree.bbox(); 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<AABB_tree>(tree)))
#else
, tree_ptr(new AABB_tree(std::forward<AABB_tree>(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 * Constructor moving an instance of `Side_of_triangle_mesh` to a new memory
* location with minimal memory copy. * location with minimal memory copy.