From 37218729f4dca07a8a43fdae713b85db345b57d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 3 Dec 2020 10:23:49 +0100 Subject: [PATCH] add move assignment and move constructor --- .../include/CGAL/Polyhedral_envelope.h | 48 +++++++++++++++---- 1 file changed, 38 insertions(+), 10 deletions(-) diff --git a/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h b/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h index c9a0a5e43f7..b493e0d2b1b 100644 --- a/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h +++ b/Polygon_mesh_processing/include/CGAL/Polyhedral_envelope.h @@ -58,8 +58,6 @@ #include -#define CGAL_ENVELOPE_DEBUG 1 - #include #include @@ -201,20 +199,12 @@ private: typedef std::vector Prism; - std::vector halfspace; // should be renamed to "prisms" - std::vector bounding_boxes; - static const bool OUT_PRISM = 1; static const bool IN_PRISM = 0; static const int CUT_COPLANAR = 4; static const int CUT_EMPTY = -1; static const int CUT_FACE = 3; - - std::vector env_vertices; - std::vector env_faces; - - // For a query object the envelope test uses an AABB tree to find the relevant prisms // property maps for the primitive @@ -233,6 +223,7 @@ private: friend value_type get(const Datum_map& m, key_type k) { + CGAL_assertion( m.boxes_ptr->size()>k ); return (*m.boxes_ptr)[k]; } }; @@ -252,6 +243,7 @@ private: friend value_type get(const Point_map& m, key_type k) { + CGAL_assertion( m.boxes_ptr->size()>k ); return ((*m.boxes_ptr)[k].min)(); } }; @@ -260,6 +252,11 @@ private: typedef AABB_traits Tree_traits; typedef AABB_tree Tree; +// Data members + std::vector halfspace; // should be renamed to "prisms" + std::vector bounding_boxes; + std::vector env_vertices; + std::vector env_faces; Tree tree; @@ -276,6 +273,37 @@ public: Polyhedral_envelope() {} + // Disabled copy constructor & assignment operator + Polyhedral_envelope(const Polyhedral_envelope&) = delete; + Polyhedral_envelope& operator=(const Polyhedral_envelope&) = delete; + + Polyhedral_envelope& operator=(Polyhedral_envelope&& other) noexcept + { + halfspace = std::move(other.halfspace); + bounding_boxes = std::move(other.bounding_boxes); + env_vertices = std::move(other.env_vertices); + env_faces = std::move(other.env_faces); + tree = std::move(other.tree); + oriented_side = std::move(other.oriented_side); + + const_cast(tree.traits()) + .set_shared_data(Datum_map(bounding_boxes), + Point_map(bounding_boxes)); + + return *this; + } + + Polyhedral_envelope(Polyhedral_envelope&& other) + : halfspace(other.halfspace) + , bounding_boxes(other.bounding_boxes) + , env_vertices(other.env_vertices) + , env_faces(other.env_faces) + , tree(other.tree) + , oriented_side(other.oriented_side) + { + *this = std::move(other); + } + /** * Constructor with a triangulated surface mesh. * @tparam TriangleMesh a model of `FaceListGraph`