From e11bbab4f64f5601d94e3f18bffa9dd9fbc9b291 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 19 Jul 2023 22:32:52 +0200 Subject: [PATCH 01/10] De-compactify Simplicial_mesh_cell_base_3 Give it a cell base instead of re-implementing everything. --- SMDS_3/examples/SMDS_3/c3t3_example.cpp | 2 +- .../CGAL/Simplicial_mesh_cell_base_3.h | 234 ++++-------------- SMDS_3/test/SMDS_3/test_simplicial_cb_vb.cpp | 2 +- 3 files changed, 52 insertions(+), 186 deletions(-) diff --git a/SMDS_3/examples/SMDS_3/c3t3_example.cpp b/SMDS_3/examples/SMDS_3/c3t3_example.cpp index 14501c395c1..5ebb5cc3e35 100644 --- a/SMDS_3/examples/SMDS_3/c3t3_example.cpp +++ b/SMDS_3/examples/SMDS_3/c3t3_example.cpp @@ -21,7 +21,7 @@ using Surface_patch_index = unsigned char; using Curve_index = char; using Corner_index = short; -using Cb = CGAL::Simplicial_mesh_cell_base_3; +using Cb = CGAL::Simplicial_mesh_cell_base_3; using Vb = CGAL::Simplicial_mesh_vertex_base_3; diff --git a/SMDS_3/include/CGAL/Simplicial_mesh_cell_base_3.h b/SMDS_3/include/CGAL/Simplicial_mesh_cell_base_3.h index ee49f572236..b1a16d1b8f0 100644 --- a/SMDS_3/include/CGAL/Simplicial_mesh_cell_base_3.h +++ b/SMDS_3/include/CGAL/Simplicial_mesh_cell_base_3.h @@ -32,187 +32,48 @@ namespace CGAL { -// Class Simplicial_mesh_cell_3 -// Cell base class used for tetrahedral remeshing -// Adds information to Cb about the cell of the input complex containing it -template< class Subdomain_index_, - class Surface_patch_index_, - class TDS> +template class Simplicial_mesh_cell_3 + : public Cb { public: - using Triangulation_data_structure = TDS; - using Vertex_handle = typename TDS::Vertex_handle; - using Cell_handle = typename TDS::Cell_handle; - using Vertex = typename TDS::Vertex; - using Cell = typename TDS::Cell; - using TDS_data = typename TDS::Cell_data; + using Vertex_handle = typename Cb::Vertex_handle; + using Cell_handle = typename Cb::Cell_handle; + + using Geom_traits = Gt; // Index Type - using Subdomain_index = Subdomain_index_; - using Surface_patch_index = Surface_patch_index_; + using Subdomain_index = SubdomainIndex; + using Surface_patch_index = SurfacePatchIndex; public: - // Constructors Simplicial_mesh_cell_3() : time_stamp_(std::size_t(-1)) {} Simplicial_mesh_cell_3(const Simplicial_mesh_cell_3& rhs) - : N(rhs.N) - , V(rhs.V) - , time_stamp_(rhs.time_stamp_) - , subdomain_index_(rhs.subdomain_index_) + : Cb(static_cast(rhs)), + time_stamp_(rhs.time_stamp_), + subdomain_index_(rhs.subdomain_index_) { - for(int i=0; i <4; i++){ + for(int i=0; i <4; ++i) surface_index_table_[i] = rhs.surface_index_table_[i]; - } } - Simplicial_mesh_cell_3(Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3) - : V(CGAL::make_array(v0, v1, v2, v3)) - { - } + Simplicial_mesh_cell_3(Vertex_handle v0, Vertex_handle v1, + Vertex_handle v2, Vertex_handle v3) + : Cb(v0, v1, v2, v3) + { } - Simplicial_mesh_cell_3(Vertex_handle v0, - Vertex_handle v1, - Vertex_handle v2, - Vertex_handle v3, - Cell_handle n0, - Cell_handle n1, - Cell_handle n2, - Cell_handle n3) - : N(CGAL::make_array(n0, n1, n2, n3)) - , V(CGAL::make_array(v0, v1, v2, v3)) - { - } - - // ACCESS FUNCTIONS - Vertex_handle vertex(int i) const - { - CGAL_precondition( i >= 0 && i <= 3 ); - return V[i]; - } - - bool has_vertex(Vertex_handle v) const - { - return (V[0] == v) || (V[1] == v) || (V[2]== v) || (V[3]== v); - } - - bool has_vertex(Vertex_handle v, int & i) const - { - if (v == V[0]) { i = 0; return true; } - if (v == V[1]) { i = 1; return true; } - if (v == V[2]) { i = 2; return true; } - if (v == V[3]) { i = 3; return true; } - return false; - } - - int index(Vertex_handle v) const - { - if (v == V[0]) { return 0; } - if (v == V[1]) { return 1; } - if (v == V[2]) { return 2; } - CGAL_assertion( v == V[3] ); - return 3; - } - - Cell_handle neighbor(int i) const - { - CGAL_precondition( i >= 0 && i <= 3); - return N[i]; - } - - bool has_neighbor(Cell_handle n) const - { - return (N[0] == n) || (N[1] == n) || (N[2] == n) || (N[3] == n); - } - - bool has_neighbor(Cell_handle n, int & i) const - { - if(n == N[0]){ i = 0; return true; } - if(n == N[1]){ i = 1; return true; } - if(n == N[2]){ i = 2; return true; } - if(n == N[3]){ i = 3; return true; } - return false; - } - - int index(Cell_handle n) const - { - if (n == N[0]) return 0; - if (n == N[1]) return 1; - if (n == N[2]) return 2; - CGAL_assertion( n == N[3] ); - return 3; - } - - // SETTING - void set_neighbor(int i, Cell_handle n) - { - CGAL_precondition( i >= 0 && i <= 3); - CGAL_precondition( this != n.operator->() ); - N[i] = n; - } - - void set_neighbors() - { - N[0] = N[1] = N[2] = N[3] = Cell_handle(); - } - - void set_neighbors(Cell_handle n0, Cell_handle n1, - Cell_handle n2, Cell_handle n3) - { - CGAL_precondition( this != n0.operator->() ); - CGAL_precondition( this != n1.operator->() ); - CGAL_precondition( this != n2.operator->() ); - CGAL_precondition( this != n3.operator->() ); - N[0] = n0; - N[1] = n1; - N[2] = n2; - N[3] = n3; - } - - // CHECKING - - // the following trivial is_valid allows - // the user of derived cell base classes - // to add their own purpose checking - bool is_valid(bool = false, int = 0) const - { return true; } - - // For use by Compact_container. - void * for_compact_container() const { return N[0].for_compact_container(); } - void for_compact_container(void *p) { N[0].for_compact_container(p); } - - // TDS internal data access functions. - TDS_data& tds_data() { return _tds_data; } - const TDS_data& tds_data() const { return _tds_data; } - - // We must override the functions that modify the vertices. - // And if the point inside a vertex is modified, we fail, - // but there's not much we can do for this now. - void set_vertex(int i, Vertex_handle v) - { - CGAL_precondition( i >= 0 && i <= 3); - V[i] = v; - } - - void set_vertices() - { - V[0] = V[1] = V[2] = V[3] = Vertex_handle(); - } - - void set_vertices(Vertex_handle v0, Vertex_handle v1, - Vertex_handle v2, Vertex_handle v3) - { - V[0] = v0; - V[1] = v1; - V[2] = v2; - V[3] = v3; - } + Simplicial_mesh_cell_3(Vertex_handle v0, Vertex_handle v1, + Vertex_handle v2, Vertex_handle v3, + Cell_handle n0, Cell_handle n1, + Cell_handle n2, Cell_handle n3) + : Cb(v0, v1, v2, v3, n0, n1, n2, n3) + { } // Returns the index of the cell of the input complex that contains the cell Subdomain_index subdomain_index() const { return subdomain_index_; } @@ -284,25 +145,22 @@ private: /// Stores surface_index for each facet of the cell std::array surface_index_table_ = {}; - std::array N; - std::array V; - std::size_t time_stamp_; // The index of the cell of the input complex that contains me Subdomain_index subdomain_index_ = {}; - TDS_data _tds_data; - public: - friend std::istream& operator>>(std::istream &is, Simplicial_mesh_cell_3 &c) + friend std::istream& operator>>(std::istream& is, + Simplicial_mesh_cell_3& c) { Subdomain_index index; if(IO::is_ascii(is)) is >> index; else read(is, index); + if(is) { c.set_subdomain_index(index); for(int i = 0; i < 4; ++i) @@ -321,7 +179,8 @@ public: } friend - std::ostream& operator<<(std::ostream &os, const Simplicial_mesh_cell_3&c) + std::ostream& operator<<(std::ostream& os, + const Simplicial_mesh_cell_3& c) { if(IO::is_ascii(os)) os << c.subdomain_index(); @@ -348,20 +207,24 @@ It is designed to serve as cell base class for.3D simplicial mesh data structure It stores and gives access to data about the complex the cell belongs to, such as the subdomain it belongs to or surface it takes part to. -\tparam Subdomain_index Type of indices for subdomains of the discretized geometric domain. +\tparam Gt is the geometric traits class. +It must be a model of the concept `TriangulationTraits_3` + +\tparam SubdomainIndex Type of indices for subdomains of the discretized geometric domain. Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` and `EqualityComparable`. The default constructed value must match the label of the exterior of the domain (which contains at least the unbounded component). - It must match the `Subdomain_index` of the model - of the `MeshDomain_3` concept when used for mesh generation. +It must match `MeshDomain_3::Subdomain_index` when used for mesh generation. -\tparam Surface_patch_index Type of indices for surface patches (boundaries and interfaces) +\tparam SurfacePatchIndex Type of indices for surface patches (boundaries and interfaces) of the discretized geometric domain. Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` and `EqualityComparable`. The default constructed value must be the index value assigned to a non surface facet. - It must match the `Surface_patch_index` of the model - of the `MeshDomain_3` concept when used for mesh generation. +It must match `MeshDomain_3::Surface_patch_index` when used for mesh generation. + +\tparam Cb is the cell base class from which `Simplicial_mesh_cell_base_3` derives. +It must be a model of the concept `TriangulationCellBase_3`. \cgalModels `SimplicialMeshCellBase_3` @@ -370,21 +233,24 @@ assigned to a non surface facet. \sa `MeshDomain_3` \sa `MeshDomainWithFeatures_3` */ -template +template > class Simplicial_mesh_cell_base_3 { public: template struct Rebind_TDS { - typedef Simplicial_mesh_cell_3 Other; + using Cb2 = typename Cb::template Rebind_TDS::Other; + using Other = Simplicial_mesh_cell_3; }; }; -} // end namespace CGAL - +} // namespace CGAL #endif // CGAL_SIMPLICIAL_MESH_CELL_BASE_3_H diff --git a/SMDS_3/test/SMDS_3/test_simplicial_cb_vb.cpp b/SMDS_3/test/SMDS_3/test_simplicial_cb_vb.cpp index 4f3531c5fcb..e438200b9aa 100644 --- a/SMDS_3/test/SMDS_3/test_simplicial_cb_vb.cpp +++ b/SMDS_3/test/SMDS_3/test_simplicial_cb_vb.cpp @@ -19,7 +19,7 @@ using Surface_patch_index = std::pair; using Curve_index = char; using Corner_index = short; -using Cb = CGAL::Simplicial_mesh_cell_base_3; +using Cb = CGAL::Simplicial_mesh_cell_base_3; using Vb = CGAL::Simplicial_mesh_vertex_base_3; From 4e824edf32556207c27fbb6f67f7ce11c3d64ad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 19 Jul 2023 22:35:56 +0200 Subject: [PATCH 02/10] Improve doc of Simplicial_vertex_base_3 --- .../CGAL/Simplicial_mesh_vertex_base_3.h | 100 ++++++++---------- 1 file changed, 47 insertions(+), 53 deletions(-) diff --git a/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h b/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h index 3f1a9c92d42..3fbea174853 100644 --- a/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h +++ b/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h @@ -29,22 +29,20 @@ #include #include + #include namespace CGAL { -//Class Simplicial_mesh_vertex_3 -//Adds information to Vb about the localization of the vertex in regards -//to the 3D input complex. -//\cgalModels `SimplicialMeshVertexBase_3` -template +// Adds information to Vb about the localization of the vertex in regards to the 3D input complex. +template class Simplicial_mesh_vertex_3 -: public Vb + : public Vb { private : using Cmvb3_base = Vb; @@ -53,10 +51,16 @@ public: using Vertex_handle = typename Vb::Vertex_handle; // Types - using Index = boost::variant; - using FT = typename GT::FT; + using Subdomain_index = SubdomainIndex; + using Surface_patch_index = SurfacePatchIndex; + using Curve_index = CurveIndex; + using Corner_index = CornerIndex; - // Constructor + using Index = boost::variant; + + using FT = typename Gt::FT; + +public: Simplicial_mesh_vertex_3() : Vb() , number_of_incident_facets_(0) @@ -215,39 +219,34 @@ index of the subcomplex it belongs to. \tparam Gt is the geometric traits class. It must be a model of the concept `TriangulationTraits_3` -\tparam Subdomain_index Type of indices for subdomains of the discretized geometric domain. +\tparam SubdomainIndex Type of indices for subdomains of the discretized geometric domain. Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` and `EqualityComparable`. The default constructed value must match the label of the exterior of the domain (which contains at least the unbounded component). - It must match the `Subdomain_index` of the model - of the `MeshDomain_3` concept when used for mesh generation. +It must match `MeshDomain_3::Subdomain_index` when used for mesh generation. -\tparam Surface_patch_index Type of indices for surface patches (boundaries and interfaces) +\tparam SurfacePatchIndex Type of indices for surface patches (boundaries and interfaces) of the discretized geometric domain. Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` and `EqualityComparable`. The default constructed value must be the index value assigned to a non surface facet. - It must match the `Surface_patch_index` of the model - of the `MeshDomain_3` concept when used for mesh generation. +It must match `MeshDomain_3::Surface_patch_index` when used for mesh generation. -\tparam Curve_index Type of indices for curves (i.e. \f$ 1\f$-dimensional features) +\tparam CurveIndex Type of indices for curves (i.e. \f$ 1\f$-dimensional features) of the discretized geometric domain. Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` and `LessThanComparable`. The default constructed value must be the value for an edge which does not approximate a 1-dimensional feature of the geometric domain. - It must match the `Curve_index` types of the model - of the `MeshDomainWithFeatures_3` concept when used for mesh generation. +It must match `MeshDomainWithFeatures_3::Curve_index` when used for mesh generation. -\tparam Corner_index Type of indices for corners (i.e.\f$ 0\f$--dimensional features) +\tparam CornerIndex Type of indices for corners (i.e.\f$ 0\f$--dimensional features) of the discretized geometric domain. It must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` and `LessThanComparable`. - It must match the `Corner_index` of the model - of the `MeshDomainWithFeatures_3` concept when used for mesh generation. +It must match `MeshDomainWithFeatures_3::Corner_index` when used for mesh generation. -\tparam Vb is the vertex base class. It has to be a model -of the concept `TriangulationVertexBase_3` and defaults to -`Triangulation_vertex_base_3`. +\tparam Vb is the vertex base class from which `Simplicial_mesh_vertex_base_3` derives. +It must be a model of the concept `TriangulationVertexBase_3`. \cgalModels `SimplicialMeshVertexBase_3` @@ -256,33 +255,28 @@ of the concept `TriangulationVertexBase_3` and defaults to \sa `MeshDomain_3` \sa `MeshDomainWithFeatures_3` */ -template > -struct Simplicial_mesh_vertex_base_3 +template > +class Simplicial_mesh_vertex_base_3 { - using Triangulation_data_structure = internal::Dummy_tds_3; - using Vertex_handle = typename Triangulation_data_structure::Vertex_handle; - using Cell_handle = typename Triangulation_data_structure::Cell_handle; - - template < class TDS3 > - struct Rebind_TDS { - using Vb3 = typename Vb::template Rebind_TDS::Other; - using Other = Simplicial_mesh_vertex_3 ; +public: + template + struct Rebind_TDS + { + using Vb2 = typename Vb::template Rebind_TDS::Other; + using Other = Simplicial_mesh_vertex_3; }; }; - -} // end namespace CGAL - - +} // namespace CGAL #endif // CGAL_SIMPLICIAL_MESH_VERTEX_BASE_3_H From 50fa1ee4def7a418f578c041095f9446aa2bbe2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 19 Jul 2023 22:36:39 +0200 Subject: [PATCH 03/10] Various fixes for Remeshing_cell_base_3: - Restore its correct API (as in CGAL 5.5): two templates, a traits, and a cell base. - It is not a model of SimplicialMeshCellBase_3, but of RemeshingCellBase_3 - It should not hardcode an inheritance to Simplicial_cell_base_3, but take it as a template paramter's default value. - Use FT instead of hardcoding 'double' --- .../Remeshing_cell_base_3.h | 72 +++++++++---------- 1 file changed, 32 insertions(+), 40 deletions(-) diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h index d8237882726..30de338cdf7 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h @@ -17,34 +17,35 @@ #include -namespace CGAL -{ -namespace Tetrahedral_remeshing -{ +#include -template +namespace CGAL { +namespace Tetrahedral_remeshing { + +template class Remeshing_cell_3 - : public CGAL::Simplicial_mesh_cell_3 + : public Cb { -private: - using Base = CGAL::Simplicial_mesh_cell_3; +public: + using FT = typename Gt::FT; + + using Vertex_handle = typename Cb::Vertex_handle; + using Cell_handle = typename Cb::Cell_handle; + + using Geom_traits = Gt; public: - using Base::Base; + using Cb::Cb; // constructors - void set_sliver_value(double value) +public: + void set_sliver_value(const FT value) { sliver_cache_validity_ = true; sliver_value_ = value; } - double sliver_value() const + FT sliver_value() const { CGAL_assertion(is_cache_valid()); return sliver_value_; @@ -54,51 +55,42 @@ public: void reset_cache_validity() const { sliver_cache_validity_ = false; } private: - double sliver_value_ = 0.; + FT sliver_value_ = 0.; mutable bool sliver_cache_validity_ = false; }; /*! \ingroup PkgTetrahedralRemeshingClasses -The class `Remeshing_cell_base_3` is a model of the concept `SimplicialMeshCellBase_3`. +The class `Remeshing_cell_base_3` is a model of the concept `RemeshingCellBase_3`. It is designed to serve as cell base class for the 3D triangulation used in the tetrahedral remeshing process. -\tparam Subdomain_index Type of indices for subdomains of the discretized geometric domain. -Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` -and `EqualityComparable`. The default constructed value must match the label -of the exterior of the domain (which contains at least the unbounded component). - It must match the `Subdomain_index` of the model - of the `MeshDomain_3` concept when used for mesh generation. +\tparam Gt is the geometric traits class. +It has to be a model of the concept `RemeshingTriangulationTraits_3`. -\tparam Surface_patch_index Type of indices for surface patches (boundaries and interfaces) -of the discretized geometric domain. -Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` -and `EqualityComparable`. The default constructed value must be the index value -assigned to a non surface facet. - It must match the `Surface_patch_index` of the model - of the `MeshDomain_3` concept when used for mesh generation. +\tparam Cb is a cell base class from which `Remeshing_cell_base_3` derives. +It must be a model of the `SimplicialMeshCellBase_3` concept. \cgalModels `RemeshingCellBase_3` -\cgalModels `SimplicialMeshCellBase_3` */ -template +template > class Remeshing_cell_base_3 { public: template struct Rebind_TDS { - typedef Remeshing_cell_3 Other; + using Cb2 = typename Cb::template Rebind_TDS::Other; + using Other = Remeshing_cell_3; }; }; -}//end namespace Tetrahedral_remeshing -}//end namespace CGAL +} // namespace Tetrahedral_remeshing +} // namespace CGAL #endif //CGAL_TET_ADAPTIVE_REMESHING_CELL_BASE_3_H From c0d0c0d01f691b9e77ba22a1b08b89e6cddcbd6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 19 Jul 2023 22:39:17 +0200 Subject: [PATCH 04/10] Fix API of Remeshing_vertex_base_3: It needs only to document a traits and a vertex base, not expose index types as these are relevant to the Simplicial_vertex_base_3 class, which is not the systematic base. It is a model of RemeshingVertexBase_3, not MeshVertexBase_3 The base needs to be a model of SimplicialVertexBase_3, not TriangulationCellBase_3 Use the proper Rebind mechanism like the other vertex/cell classes --- .../Remeshing_triangulation_3.h | 2 +- .../Remeshing_vertex_base_3.h | 55 +++++++++++-------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h index 7b2bb34f9cf..3abdc9f034d 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h @@ -52,7 +52,7 @@ and `Parallel_if_available_tag`. template, - typename Cb = Remeshing_cell_base_3<> + typename Cb = Remeshing_cell_base_3 > class Remeshing_triangulation_3 : public CGAL::Triangulation_3 > diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_vertex_base_3.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_vertex_base_3.h index b828ffb08d1..faab3950f9a 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_vertex_base_3.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_vertex_base_3.h @@ -17,44 +17,51 @@ #include -namespace CGAL -{ -namespace Tetrahedral_remeshing +namespace CGAL { +namespace Tetrahedral_remeshing { + +template +class Remeshing_vertex_3 + : public Vb { +public: + using Vb::Vb; // constructors +}; /*! \ingroup PkgTetrahedralRemeshingClasses -The class `Remeshing_vertex_base_3` is a model of the concept `MeshVertexBase_3`. +The class `Remeshing_vertex_base_3` is a model of the concept `RemeshingVertexBase_3`. It is designed to serve as vertex base class for the 3D triangulation used in the tetrahedral remeshing process. \tparam Gt is the geometric traits class. -It has to be a model of the concept `RemeshingTriangulationTraits_3`. +It must be a model of the concept `RemeshingTriangulationTraits_3`. \tparam Vb is a vertex base class from which `Remeshing_vertex_base_3` derives. -It must be a model of the `TriangulationVertexBase_3` concept. -It has the default value `Triangulation_vertex_base_3`. +It must be a model of the concept `SimplicialMeshVertexBase_3`. \cgalModels `RemeshingVertexBase_3` -\cgalModels `SimplicialMeshVertexBase_3` */ -template > -using Remeshing_vertex_base_3 - = CGAL::Simplicial_mesh_vertex_base_3; +template > +class Remeshing_vertex_base_3 +{ +public: + template + struct Rebind_TDS + { + using Vb2 = typename Vb::template Rebind_TDS::Other; + using Other = Remeshing_vertex_3; + }; +}; -}//end namespace Tetrahedral_remeshing - -}//end namespace CGAL +} // namespace Tetrahedral_remeshing +} // namespace CGAL #endif //CGAL_TET_ADAPTIVE_REMESHING_VERTEX_BASE_3_H From ce9fa95e2b60349875704976aad5456646d633d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 19 Jul 2023 22:42:45 +0200 Subject: [PATCH 05/10] Fixes for the doc of tetrahedral remeshing --- .../include/CGAL/tetrahedral_remeshing.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h index edd23bc2967..f1be0dcf844 100644 --- a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h +++ b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h @@ -61,7 +61,7 @@ namespace CGAL * subdomains throughout the remeshing process. * * Subdomains are defined by indices that -* are stored in the cells of the input triangulation, following the `MeshCellBase_3` +* are stored in the cells of the input triangulation, following the `SimplicialMeshCellBase_3` * concept (refined by `RemeshingCellBase_3`). * The surfacic interfaces between subdomains are formed by facets whose two incident cells * have different subdomain indices. @@ -302,14 +302,14 @@ void tetrahedral_isotropic_remeshing( * @tparam Tr is the underlying triangulation for `Mesh_complex_3_in_triangulation_3`. * It can be instantiated with any 3D regular triangulation of CGAL provided * that its vertex and cell base classes are models of the concepts -* `MeshVertexBase_3` (refined by `RemeshingCellBase_3`) -* and `MeshCellBase_3` (refined by `RemeshingVertexBase_3`), respectively. +* `SimplicialMeshCellBase_3` (refined by `RemeshingCellBase_3`) +* and `SimplicialMeshVertexBase_3` (refined by `RemeshingVertexBase_3`), respectively. * @tparam CornerIndex is the type of the indices for feature corners. * If `c3t3` has been generated using `CGAL::make_mesh_3()`, it must match -* the `Corner_index` type of the model of the `MeshDomainWithFeatures_3` concept used for mesh generation. +* `MeshDomainWithFeatures_3::Corner_index`. * @tparam CurveIndex is the type of the indices for feature curves. * If `c3t3` has been generated using `CGAL::make_mesh_3()`, it must match -* the `Curve_index` type of the model of the `MeshDomainWithFeatures_3` concept used for mesh generation. +* `MeshDomainWithFeatures_3::Curve_index`. * * @param c3t3 the complex containing the triangulation to be remeshed. */ From 796baca1c59a5d87b413855aec9d30c9214c23e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Wed, 19 Jul 2023 22:43:14 +0200 Subject: [PATCH 06/10] Misc minor cleaning --- .../Concepts/SimplicialMeshCellBase_3.h | 14 +++---- .../Concepts/SimplicialMeshVertexBase_3.h | 2 +- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 2 +- .../CGAL/Simplicial_mesh_cell_base_3.h | 39 ++++++++++--------- .../CGAL/Simplicial_mesh_vertex_base_3.h | 10 ++--- .../Remeshing_triangulation_3.h | 4 +- 6 files changed, 35 insertions(+), 36 deletions(-) diff --git a/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshCellBase_3.h b/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshCellBase_3.h index ff424c1281d..6748b8d4ebc 100644 --- a/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshCellBase_3.h +++ b/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshCellBase_3.h @@ -4,14 +4,12 @@ The concept `SimplicialMeshCellBase_3` describes the requirements for the `TriangulationDataStructure_3::Cell` type of the triangulation -used in the 3D simplicial mesh data structure. The type `SimplicialMeshCellBase_3` -refines the concept `TriangulationCellBase_3` -and must be copy constructible. -The concept `SimplicialMeshCellBase_3` -includes a way to store and retrieve -if a given cell of the triangulation is inside a subdomain or not, -and which subdomain it belongs to -in case of a multi-domain. +used in a 3D simplicial mesh data structure. + +The type `SimplicialMeshCellBase_3` refines the concept `TriangulationCellBase_3` +and must be copy constructible. The concept `SimplicialMeshCellBase_3` includes a way to store and +retrieve if a given cell of the triangulation is inside a subdomain or not, and which subdomain it +belongs to in case of a multi-domain. Moreover, this concept adds four markers per cell to mark the facets of the triangulation that are surface facets. diff --git a/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h b/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h index ad034bbb982..aaba99a5160 100644 --- a/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h +++ b/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshVertexBase_3.h @@ -4,7 +4,7 @@ The concept `SimplicialMeshVertexBase_3` describes the requirements for the `Vertex` type of the triangulation -used in the 3D simplicial mesh data structure. The type `SimplicialMeshVertexBase_3` +used in a 3D simplicial mesh data structure. The type `SimplicialMeshVertexBase_3` refines the concept `TriangulationVertexBase_3`. It provides additional members to store and retrieve information about the location of the vertex with respect diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 643de3ff7da..3ce0ab4e55f 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -151,7 +151,7 @@ namespace CGAL { vertex and cell base class are models of the concepts `SimplicialMeshVertexBase_3` and `SimplicialMeshCellBase_3`, respectively. - \tparam CornerIndex Type of indices for corners (i.e.\f$ 0\f$--dimensional features) + \tparam CornerIndex Type of indices for corners (i.e.\f$ 0\f$--dimensional features) of the discretized geometric domain. It must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` and `LessThanComparable`. diff --git a/SMDS_3/include/CGAL/Simplicial_mesh_cell_base_3.h b/SMDS_3/include/CGAL/Simplicial_mesh_cell_base_3.h index b1a16d1b8f0..ad535d2e402 100644 --- a/SMDS_3/include/CGAL/Simplicial_mesh_cell_base_3.h +++ b/SMDS_3/include/CGAL/Simplicial_mesh_cell_base_3.h @@ -164,16 +164,16 @@ public: if(is) { c.set_subdomain_index(index); for(int i = 0; i < 4; ++i) - { - Surface_patch_index i2; - if(IO::is_ascii(is)) - is >> IO::iformat(i2); - else - { - read(is, i2); - } - c.set_surface_patch_index(i, i2); - } + { + Surface_patch_index i2; + if(IO::is_ascii(is)) + is >> IO::iformat(i2); + else + { + read(is, i2); + } + c.set_surface_patch_index(i, i2); + } } return is; } @@ -186,24 +186,25 @@ public: os << c.subdomain_index(); else write(os, c.subdomain_index()); + for(int i = 0; i < 4; ++i) - { - if(IO::is_ascii(os)) - os << ' ' << IO::oformat(c.surface_patch_index(i)); - else - write(os, c.surface_patch_index(i)); - } + { + if(IO::is_ascii(os)) + os << ' ' << IO::oformat(c.surface_patch_index(i)); + else + write(os, c.surface_patch_index(i)); + } + return os; } - -}; // end class Simplicial_mesh_cell_3 +}; /*! \ingroup PkgSMDS3Classes The class `Simplicial_mesh_cell_base_3` is a model of the concept `SimplicialMeshCellBase_3`. -It is designed to serve as cell base class for.3D simplicial mesh data structures. +It is designed to serve as cell base class for 3D simplicial mesh data structures. It stores and gives access to data about the complex the cell belongs to, such as the subdomain it belongs to or surface it takes part to. diff --git a/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h b/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h index 3fbea174853..a25cf6f4329 100644 --- a/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h +++ b/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h @@ -159,8 +159,8 @@ private: std::size_t time_stamp_; public: - - friend std::istream& operator>>(std::istream &is, Simplicial_mesh_vertex_3& v) + friend std::istream& operator>>(std::istream& is, + Simplicial_mesh_vertex_3& v) { is >> static_cast(v); int dimension; @@ -185,7 +185,8 @@ public: return is; } - friend std::ostream& operator<<(std::ostream &os, const Simplicial_mesh_vertex_3& v) + friend std::ostream& operator<<(std::ostream& os, + const Simplicial_mesh_vertex_3& v) { os << static_cast(v); if(IO::is_ascii(os)) { @@ -204,8 +205,7 @@ public: v.index()); return os; } -}; // end class Simplicial_mesh_vertex_3 - +}; /*! \ingroup PkgSMDS3Classes diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h index 3abdc9f034d..f009ad0471c 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h @@ -45,9 +45,9 @@ triangulation data structure. Possible values are `Sequential_tag` (the default), `Parallel_tag`, and `Parallel_if_available_tag`. -\tparam Vb is a model of `RemeshingVertexBase_3`. It has the default value ` Remeshing_vertex_base_3`. -\tparam Cb is a model of `RemeshingCellBase_3`. It has the default value ` Remeshing_cell_base_3`. +\tparam Vb must be a model of `RemeshingVertexBase_3`. +\tparam Cb must be model of `RemeshingCellBase_3`. */ template Date: Fri, 21 Jul 2023 09:55:01 +0200 Subject: [PATCH 07/10] Fix not being able to Rebind multiple time SMDS_3 / Tet Remesh Vb/Cb If you have the following construct: class V : public Vb; class V_base { struct Rebind --> V; } then you cannot rebind twice. More vicious, if Vb can rebind twice multiple times (e.g. it's a T3 Vb), then it'll silently drop V in the stack, and rebind only up to the rebound Vb! Rebinding multiple times happens for example in Triangulation_hierarchy_3 (Delaunay_triangulation_3 with Fast_locate). --- .../CGAL/Simplicial_mesh_cell_base_3.h | 123 +++++++-------- .../CGAL/Simplicial_mesh_vertex_base_3.h | 142 +++++++++--------- .../Remeshing_cell_base_3.h | 61 ++++---- .../Remeshing_vertex_base_3.h | 15 +- 4 files changed, 158 insertions(+), 183 deletions(-) diff --git a/SMDS_3/include/CGAL/Simplicial_mesh_cell_base_3.h b/SMDS_3/include/CGAL/Simplicial_mesh_cell_base_3.h index ad535d2e402..3c882ad9b52 100644 --- a/SMDS_3/include/CGAL/Simplicial_mesh_cell_base_3.h +++ b/SMDS_3/include/CGAL/Simplicial_mesh_cell_base_3.h @@ -32,11 +32,46 @@ namespace CGAL { +/*! +\ingroup PkgSMDS3Classes + +The class `Simplicial_mesh_cell_base_3` +is a model of the concept `SimplicialMeshCellBase_3`. +It is designed to serve as cell base class for 3D simplicial mesh data structures. +It stores and gives access to data about the complex the cell belongs to, such as the +subdomain it belongs to or surface it takes part to. + +\tparam Gt is the geometric traits class. +It must be a model of the concept `TriangulationTraits_3` + +\tparam SubdomainIndex Type of indices for subdomains of the discretized geometric domain. +Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` +and `EqualityComparable`. The default constructed value must match the label +of the exterior of the domain (which contains at least the unbounded component). +It must match `MeshDomain_3::Subdomain_index` when used for mesh generation. + +\tparam SurfacePatchIndex Type of indices for surface patches (boundaries and interfaces) +of the discretized geometric domain. +Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` +and `EqualityComparable`. The default constructed value must be the index value +assigned to a non surface facet. +It must match `MeshDomain_3::Surface_patch_index` when used for mesh generation. + +\tparam Cb is the cell base class from which `Simplicial_mesh_cell_base_3` derives. +It must be a model of the concept `TriangulationCellBase_3`. + +\cgalModels `SimplicialMeshCellBase_3` + +\sa `CGAL::Mesh_complex_3_in_triangulation_3` +\sa \link Mesh_cell_base_3 `CGAL::Mesh_cell_base_3`\endlink +\sa `MeshDomain_3` +\sa `MeshDomainWithFeatures_3` +*/ template -class Simplicial_mesh_cell_3 + typename Cb = Triangulation_cell_base_3 > +class Simplicial_mesh_cell_base_3 : public Cb { public: @@ -50,11 +85,22 @@ public: using Surface_patch_index = SurfacePatchIndex; public: - Simplicial_mesh_cell_3() + template + struct Rebind_TDS + { + using Cb2 = typename Cb::template Rebind_TDS::Other; + using Other = Simplicial_mesh_cell_base_3; + }; + +public: + Simplicial_mesh_cell_base_3() : time_stamp_(std::size_t(-1)) {} - Simplicial_mesh_cell_3(const Simplicial_mesh_cell_3& rhs) + Simplicial_mesh_cell_base_3(const Simplicial_mesh_cell_base_3& rhs) : Cb(static_cast(rhs)), time_stamp_(rhs.time_stamp_), subdomain_index_(rhs.subdomain_index_) @@ -63,15 +109,15 @@ public: surface_index_table_[i] = rhs.surface_index_table_[i]; } - Simplicial_mesh_cell_3(Vertex_handle v0, Vertex_handle v1, - Vertex_handle v2, Vertex_handle v3) + Simplicial_mesh_cell_base_3(Vertex_handle v0, Vertex_handle v1, + Vertex_handle v2, Vertex_handle v3) : Cb(v0, v1, v2, v3) { } - Simplicial_mesh_cell_3(Vertex_handle v0, Vertex_handle v1, - Vertex_handle v2, Vertex_handle v3, - Cell_handle n0, Cell_handle n1, - Cell_handle n2, Cell_handle n3) + Simplicial_mesh_cell_base_3(Vertex_handle v0, Vertex_handle v1, + Vertex_handle v2, Vertex_handle v3, + Cell_handle n0, Cell_handle n1, + Cell_handle n2, Cell_handle n3) : Cb(v0, v1, v2, v3, n0, n1, n2, n3) { } @@ -153,7 +199,7 @@ private: public: friend std::istream& operator>>(std::istream& is, - Simplicial_mesh_cell_3& c) + Simplicial_mesh_cell_base_3& c) { Subdomain_index index; if(IO::is_ascii(is)) @@ -180,7 +226,7 @@ public: friend std::ostream& operator<<(std::ostream& os, - const Simplicial_mesh_cell_3& c) + const Simplicial_mesh_cell_base_3& c) { if(IO::is_ascii(os)) os << c.subdomain_index(); @@ -199,59 +245,6 @@ public: } }; -/*! -\ingroup PkgSMDS3Classes - -The class `Simplicial_mesh_cell_base_3` -is a model of the concept `SimplicialMeshCellBase_3`. -It is designed to serve as cell base class for 3D simplicial mesh data structures. -It stores and gives access to data about the complex the cell belongs to, such as the -subdomain it belongs to or surface it takes part to. - -\tparam Gt is the geometric traits class. -It must be a model of the concept `TriangulationTraits_3` - -\tparam SubdomainIndex Type of indices for subdomains of the discretized geometric domain. -Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` -and `EqualityComparable`. The default constructed value must match the label -of the exterior of the domain (which contains at least the unbounded component). -It must match `MeshDomain_3::Subdomain_index` when used for mesh generation. - -\tparam SurfacePatchIndex Type of indices for surface patches (boundaries and interfaces) -of the discretized geometric domain. -Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` -and `EqualityComparable`. The default constructed value must be the index value -assigned to a non surface facet. -It must match `MeshDomain_3::Surface_patch_index` when used for mesh generation. - -\tparam Cb is the cell base class from which `Simplicial_mesh_cell_base_3` derives. -It must be a model of the concept `TriangulationCellBase_3`. - -\cgalModels `SimplicialMeshCellBase_3` - -\sa `CGAL::Mesh_complex_3_in_triangulation_3` -\sa \link Mesh_cell_base_3 `CGAL::Mesh_cell_base_3`\endlink -\sa `MeshDomain_3` -\sa `MeshDomainWithFeatures_3` -*/ -template > -class Simplicial_mesh_cell_base_3 -{ -public: - template - struct Rebind_TDS - { - using Cb2 = typename Cb::template Rebind_TDS::Other; - using Other = Simplicial_mesh_cell_3; - }; -}; - } // namespace CGAL #endif // CGAL_SIMPLICIAL_MESH_CELL_BASE_3_H diff --git a/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h b/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h index a25cf6f4329..1b47ea8de4f 100644 --- a/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h +++ b/SMDS_3/include/CGAL/Simplicial_mesh_vertex_base_3.h @@ -35,13 +35,62 @@ namespace CGAL { // Adds information to Vb about the localization of the vertex in regards to the 3D input complex. + +/*! +\ingroup PkgSMDS3Classes + +The class `Simplicial_mesh_vertex_base_3` is a model of the concept +`SimplicialMeshVertexBase_3`. +It is designed to serve as vertex base class for 3D simplicial mesh data structures. +It stores and gives access to data about the complex the vertex belongs to, such as the +index of the subcomplex it belongs to. + +\tparam Gt is the geometric traits class. +It must be a model of the concept `TriangulationTraits_3` + +\tparam SubdomainIndex Type of indices for subdomains of the discretized geometric domain. +Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` +and `EqualityComparable`. The default constructed value must match the label +of the exterior of the domain (which contains at least the unbounded component). +It must match `MeshDomain_3::Subdomain_index` when used for mesh generation. + +\tparam SurfacePatchIndex Type of indices for surface patches (boundaries and interfaces) +of the discretized geometric domain. +Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` +and `EqualityComparable`. The default constructed value must be the index value +assigned to a non surface facet. +It must match `MeshDomain_3::Surface_patch_index` when used for mesh generation. + +\tparam CurveIndex Type of indices for curves (i.e. \f$ 1\f$-dimensional features) +of the discretized geometric domain. +Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` and +`LessThanComparable`. The default constructed value must be the value for an edge which +does not approximate a 1-dimensional feature of the geometric domain. +It must match `MeshDomainWithFeatures_3::Curve_index` when used for mesh generation. + +\tparam CornerIndex Type of indices for corners (i.e.\f$ 0\f$--dimensional features) +of the discretized geometric domain. +It must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` and +`LessThanComparable`. +It must match `MeshDomainWithFeatures_3::Corner_index` when used for mesh generation. + +\tparam Vb is the vertex base class from which `Simplicial_mesh_vertex_base_3` derives. +It must be a model of the concept `TriangulationVertexBase_3`. + +\cgalModels `SimplicialMeshVertexBase_3` + +\sa `CGAL::Mesh_complex_3_in_triangulation_3` +\sa \link Mesh_vertex_base_3 `CGAL::Mesh_vertex_base_3`\endlink +\sa `MeshDomain_3` +\sa `MeshDomainWithFeatures_3` +*/ template -class Simplicial_mesh_vertex_3 + typename Vb = CGAL::Triangulation_vertex_base_3 > +class Simplicial_mesh_vertex_base_3 : public Vb { private : @@ -61,7 +110,20 @@ public: using FT = typename Gt::FT; public: - Simplicial_mesh_vertex_3() + template + struct Rebind_TDS + { + using Vb2 = typename Vb::template Rebind_TDS::Other; + using Other = Simplicial_mesh_vertex_base_3; + }; + +public: + Simplicial_mesh_vertex_base_3() : Vb() , number_of_incident_facets_(0) , number_of_components_(0) @@ -160,7 +222,7 @@ private: public: friend std::istream& operator>>(std::istream& is, - Simplicial_mesh_vertex_3& v) + Simplicial_mesh_vertex_base_3& v) { is >> static_cast(v); int dimension; @@ -186,7 +248,7 @@ public: } friend std::ostream& operator<<(std::ostream& os, - const Simplicial_mesh_vertex_3& v) + const Simplicial_mesh_vertex_base_3& v) { os << static_cast(v); if(IO::is_ascii(os)) { @@ -207,76 +269,6 @@ public: } }; -/*! -\ingroup PkgSMDS3Classes - -The class `Simplicial_mesh_vertex_base_3` is a model of the concept -`SimplicialMeshVertexBase_3`. -It is designed to serve as vertex base class for 3D simplicial mesh data structures. -It stores and gives access to data about the complex the vertex belongs to, such as the -index of the subcomplex it belongs to. - -\tparam Gt is the geometric traits class. -It must be a model of the concept `TriangulationTraits_3` - -\tparam SubdomainIndex Type of indices for subdomains of the discretized geometric domain. -Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` -and `EqualityComparable`. The default constructed value must match the label -of the exterior of the domain (which contains at least the unbounded component). -It must match `MeshDomain_3::Subdomain_index` when used for mesh generation. - -\tparam SurfacePatchIndex Type of indices for surface patches (boundaries and interfaces) -of the discretized geometric domain. -Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` -and `EqualityComparable`. The default constructed value must be the index value -assigned to a non surface facet. -It must match `MeshDomain_3::Surface_patch_index` when used for mesh generation. - -\tparam CurveIndex Type of indices for curves (i.e. \f$ 1\f$-dimensional features) -of the discretized geometric domain. -Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` and -`LessThanComparable`. The default constructed value must be the value for an edge which -does not approximate a 1-dimensional feature of the geometric domain. -It must match `MeshDomainWithFeatures_3::Curve_index` when used for mesh generation. - -\tparam CornerIndex Type of indices for corners (i.e.\f$ 0\f$--dimensional features) -of the discretized geometric domain. -It must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` and -`LessThanComparable`. -It must match `MeshDomainWithFeatures_3::Corner_index` when used for mesh generation. - -\tparam Vb is the vertex base class from which `Simplicial_mesh_vertex_base_3` derives. -It must be a model of the concept `TriangulationVertexBase_3`. - -\cgalModels `SimplicialMeshVertexBase_3` - -\sa `CGAL::Mesh_complex_3_in_triangulation_3` -\sa \link Mesh_vertex_base_3 `CGAL::Mesh_vertex_base_3`\endlink -\sa `MeshDomain_3` -\sa `MeshDomainWithFeatures_3` -*/ -template > -class Simplicial_mesh_vertex_base_3 -{ -public: - template - struct Rebind_TDS - { - using Vb2 = typename Vb::template Rebind_TDS::Other; - using Other = Simplicial_mesh_vertex_3; - }; -}; - } // namespace CGAL #endif // CGAL_SIMPLICIAL_MESH_VERTEX_BASE_3_H diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h index 30de338cdf7..162cfa27f21 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h @@ -22,9 +22,27 @@ namespace CGAL { namespace Tetrahedral_remeshing { +/*! +\ingroup PkgTetrahedralRemeshingClasses + +The class `Remeshing_cell_base_3` is a model of the concept `RemeshingCellBase_3`. +It is designed to serve as cell base class for the 3D triangulation +used in the tetrahedral remeshing process. + +\tparam Gt is the geometric traits class. +It has to be a model of the concept `RemeshingTriangulationTraits_3`. + +\tparam Cb is a cell base class from which `Remeshing_cell_base_3` derives. +It must be a model of the `SimplicialMeshCellBase_3` concept. + +\cgalModels `RemeshingCellBase_3` + +*/ template -class Remeshing_cell_3 + typename Cb = CGAL::Simplicial_mesh_cell_base_3 > +class Remeshing_cell_base_3 : public Cb { public: @@ -35,6 +53,14 @@ public: using Geom_traits = Gt; +public: + template + struct Rebind_TDS + { + using Cb2 = typename Cb::template Rebind_TDS::Other; + using Other = Remeshing_cell_base_3; + }; + public: using Cb::Cb; // constructors @@ -59,37 +85,6 @@ private: mutable bool sliver_cache_validity_ = false; }; -/*! -\ingroup PkgTetrahedralRemeshingClasses - -The class `Remeshing_cell_base_3` is a model of the concept `RemeshingCellBase_3`. -It is designed to serve as cell base class for the 3D triangulation -used in the tetrahedral remeshing process. - -\tparam Gt is the geometric traits class. -It has to be a model of the concept `RemeshingTriangulationTraits_3`. - -\tparam Cb is a cell base class from which `Remeshing_cell_base_3` derives. -It must be a model of the `SimplicialMeshCellBase_3` concept. - -\cgalModels `RemeshingCellBase_3` - -*/ -template > -class Remeshing_cell_base_3 -{ -public: - template - struct Rebind_TDS - { - using Cb2 = typename Cb::template Rebind_TDS::Other; - using Other = Remeshing_cell_3; - }; -}; - } // namespace Tetrahedral_remeshing } // namespace CGAL diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_vertex_base_3.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_vertex_base_3.h index faab3950f9a..34e5fb0855c 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_vertex_base_3.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_vertex_base_3.h @@ -20,15 +20,6 @@ namespace CGAL { namespace Tetrahedral_remeshing { -template -class Remeshing_vertex_3 - : public Vb -{ -public: - using Vb::Vb; // constructors -}; - /*! \ingroup PkgTetrahedralRemeshingClasses @@ -51,14 +42,18 @@ template > class Remeshing_vertex_base_3 + : public Vb { public: template struct Rebind_TDS { using Vb2 = typename Vb::template Rebind_TDS::Other; - using Other = Remeshing_vertex_3; + using Other = Remeshing_vertex_base_3; }; + +public: + using Vb::Vb; // constructors }; } // namespace Tetrahedral_remeshing From a935682a8219925122e4ca3a32be7704ea40dcc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Mon, 24 Jul 2023 10:53:27 +0200 Subject: [PATCH 08/10] (Re-)introduce Compact_simplicial_mesh_cell_base_3 Formerly known as Simplicial_mesh_cell_base_3, this cell base is more efficient in memory, but cannot inherit a base. --- .../Compact_simplicial_mesh_cell_base_3.h | 391 ++++++++++++++++++ .../Remeshing_cell_base_3.h | 4 +- 2 files changed, 393 insertions(+), 2 deletions(-) create mode 100644 SMDS_3/include/CGAL/Compact_simplicial_mesh_cell_base_3.h diff --git a/SMDS_3/include/CGAL/Compact_simplicial_mesh_cell_base_3.h b/SMDS_3/include/CGAL/Compact_simplicial_mesh_cell_base_3.h new file mode 100644 index 00000000000..d9c31c72597 --- /dev/null +++ b/SMDS_3/include/CGAL/Compact_simplicial_mesh_cell_base_3.h @@ -0,0 +1,391 @@ +// Copyright (c) 2006-2007 INRIA Sophia-Antipolis (France). +// Copyright (c) 2008,2011 GeometryFactory Sarl (France) +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Laurent Rineau, Stephane Tayeb, Andreas Fabri, Jane Tournois + +#ifndef CGAL_COMPACT_SIMPLICIAL_MESH_CELL_BASE_3_H +#define CGAL_COMPACT_SIMPLICIAL_MESH_CELL_BASE_3_H + +#include + +#include +#include +#include +#include +#include +#include + +#include + +namespace CGAL { + +// Adds information to Cb about the cell of the input complex containing it +template +class Compact_simplicial_mesh_cell_3 +{ +public: + using Triangulation_data_structure = TDS; + + using Vertex_handle = typename TDS::Vertex_handle; + using Cell_handle = typename TDS::Cell_handle; + using Vertex = typename TDS::Vertex; + using Cell = typename TDS::Cell; + using TDS_data = typename TDS::Cell_data; + + // Index Type + using Subdomain_index = Subdomain_index_; + using Surface_patch_index = Surface_patch_index_; + +public: + // Constructors + Compact_simplicial_mesh_cell_3() + : time_stamp_(std::size_t(-1)) + {} + + Compact_simplicial_mesh_cell_3(const Compact_simplicial_mesh_cell_3& rhs) + : N(rhs.N) + , V(rhs.V) + , time_stamp_(rhs.time_stamp_) + , subdomain_index_(rhs.subdomain_index_) + { + for(int i=0; i <4; i++){ + surface_index_table_[i] = rhs.surface_index_table_[i]; + } + } + + Compact_simplicial_mesh_cell_3(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Vertex_handle v3) + : V(CGAL::make_array(v0, v1, v2, v3)) + { + } + + Compact_simplicial_mesh_cell_3(Vertex_handle v0, + Vertex_handle v1, + Vertex_handle v2, + Vertex_handle v3, + Cell_handle n0, + Cell_handle n1, + Cell_handle n2, + Cell_handle n3) + : N(CGAL::make_array(n0, n1, n2, n3)) + , V(CGAL::make_array(v0, v1, v2, v3)) + { + } + + // ACCESS FUNCTIONS + Vertex_handle vertex(int i) const + { + CGAL_precondition( i >= 0 && i <= 3 ); + return V[i]; + } + + bool has_vertex(Vertex_handle v) const + { + return (V[0] == v) || (V[1] == v) || (V[2]== v) || (V[3]== v); + } + + bool has_vertex(Vertex_handle v, int & i) const + { + if (v == V[0]) { i = 0; return true; } + if (v == V[1]) { i = 1; return true; } + if (v == V[2]) { i = 2; return true; } + if (v == V[3]) { i = 3; return true; } + return false; + } + + int index(Vertex_handle v) const + { + if (v == V[0]) { return 0; } + if (v == V[1]) { return 1; } + if (v == V[2]) { return 2; } + CGAL_assertion( v == V[3] ); + return 3; + } + + Cell_handle neighbor(int i) const + { + CGAL_precondition( i >= 0 && i <= 3); + return N[i]; + } + + bool has_neighbor(Cell_handle n) const + { + return (N[0] == n) || (N[1] == n) || (N[2] == n) || (N[3] == n); + } + + bool has_neighbor(Cell_handle n, int & i) const + { + if(n == N[0]){ i = 0; return true; } + if(n == N[1]){ i = 1; return true; } + if(n == N[2]){ i = 2; return true; } + if(n == N[3]){ i = 3; return true; } + return false; + } + + int index(Cell_handle n) const + { + if (n == N[0]) return 0; + if (n == N[1]) return 1; + if (n == N[2]) return 2; + CGAL_assertion( n == N[3] ); + return 3; + } + + // SETTING + void set_neighbor(int i, Cell_handle n) + { + CGAL_precondition( i >= 0 && i <= 3); + CGAL_precondition( this != n.operator->() ); + N[i] = n; + } + + void set_neighbors() + { + N[0] = N[1] = N[2] = N[3] = Cell_handle(); + } + + void set_neighbors(Cell_handle n0, Cell_handle n1, + Cell_handle n2, Cell_handle n3) + { + CGAL_precondition( this != n0.operator->() ); + CGAL_precondition( this != n1.operator->() ); + CGAL_precondition( this != n2.operator->() ); + CGAL_precondition( this != n3.operator->() ); + N[0] = n0; + N[1] = n1; + N[2] = n2; + N[3] = n3; + } + + // CHECKING + + // the following trivial is_valid allows + // the user of derived cell base classes + // to add their own purpose checking + bool is_valid(bool = false, int = 0) const + { return true; } + + // For use by Compact_container. + void * for_compact_container() const { return N[0].for_compact_container(); } + void for_compact_container(void *p) { N[0].for_compact_container(p); } + + // TDS internal data access functions. + TDS_data& tds_data() { return _tds_data; } + const TDS_data& tds_data() const { return _tds_data; } + + // We must override the functions that modify the vertices. + // And if the point inside a vertex is modified, we fail, + // but there's not much we can do for this now. + void set_vertex(int i, Vertex_handle v) + { + CGAL_precondition( i >= 0 && i <= 3); + V[i] = v; + } + + void set_vertices() + { + V[0] = V[1] = V[2] = V[3] = Vertex_handle(); + } + + void set_vertices(Vertex_handle v0, Vertex_handle v1, + Vertex_handle v2, Vertex_handle v3) + { + V[0] = v0; + V[1] = v1; + V[2] = v2; + V[3] = v3; + } + + // Returns the index of the cell of the input complex that contains the cell + Subdomain_index subdomain_index() const { return subdomain_index_; } + + // Sets the index of the cell of the input complex that contains the cell + void set_subdomain_index(const Subdomain_index& index) + { subdomain_index_ = index; } + + /// Set surface index of \c facet to \c index + void set_surface_patch_index(const int facet, const Surface_patch_index& index) + { + CGAL_precondition(facet>=0 && facet<4); + surface_index_table_[facet] = index; + } + + /// Returns surface index of facet \c facet + Surface_patch_index surface_patch_index(const int facet) const + { + CGAL_precondition(facet>=0 && facet<4); + return surface_index_table_[facet]; + } + + /// Returns true if facet lies on a surface patch + bool is_facet_on_surface(const int facet) const + { + CGAL_precondition(facet>=0 && facet<4); + return ( !( Surface_patch_index() == surface_index_table_[facet] )); + } + + // ----------------------------------- + // Backward Compatibility + // ----------------------------------- +#ifndef CGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX + typedef Surface_patch_index Surface_index; + + void set_surface_index(const int facet, const Surface_index& index) + { set_surface_patch_index(facet,index); } + + /// Returns surface index of facet \c facet + Surface_index surface_index(const int facet) const + { return surface_patch_index(facet); } +#endif // CGAL_MESH_3_NO_DEPRECATED_SURFACE_INDEX + // ----------------------------------- + // End backward Compatibility + // ----------------------------------- + + static + std::string io_signature() + { + return + Get_io_signature()() + + "+(" + Get_io_signature()() + ")[4]"; + } + + /// For the determinism of Compact_container iterators + ///@{ + typedef Tag_true Has_timestamp; + + std::size_t time_stamp() const { + return time_stamp_; + } + void set_time_stamp(const std::size_t& ts) { + time_stamp_ = ts; + } + ///@} + +private: + /// Stores surface_index for each facet of the cell + std::array surface_index_table_ = {}; + + std::array N; + std::array V; + + std::size_t time_stamp_; + + // The index of the cell of the input complex that contains me + Subdomain_index subdomain_index_ = {}; + + TDS_data _tds_data; + +public: + friend std::istream& operator>>(std::istream &is, Compact_simplicial_mesh_cell_3 &c) + { + Subdomain_index index; + if(IO::is_ascii(is)) + is >> index; + else + read(is, index); + + if(is) + { + c.set_subdomain_index(index); + for(int i = 0; i < 4; ++i) + { + Surface_patch_index i2; + if(IO::is_ascii(is)) + is >> IO::iformat(i2); + else + read(is, i2); + + c.set_surface_patch_index(i, i2); + } + } + + return is; + } + + friend + std::ostream& operator<<(std::ostream &os, const Compact_simplicial_mesh_cell_3&c) + { + if(IO::is_ascii(os)) + os << c.subdomain_index(); + else + write(os, c.subdomain_index()); + + for(int i = 0; i < 4; ++i) + { + if(IO::is_ascii(os)) + os << ' ' << IO::oformat(c.surface_patch_index(i)); + else + write(os, c.surface_patch_index(i)); + } + + return os; + } +}; + +/*! +\ingroup PkgSMDS3Classes + +The class `Compact_simplicial_mesh_cell_base_3` +is a model of the concept `SimplicialMeshCellBase_3`. +It is designed to serve as cell base class for.3D simplicial mesh data structures. +It stores and gives access to data about the complex the cell belongs to, such as the +subdomain it belongs to or surface it takes part to. +It is more compact in memory than `CGAL::Simplicial_mesh_cell_base_3`. + +\tparam SubdomainIndex Type of indices for subdomains of the discretized geometric domain. +Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` +and `EqualityComparable`. The default constructed value must match the label +of the exterior of the domain (which contains at least the unbounded component). +It must match `MeshDomain_3::Subdomain_index` when used for mesh generation. + +\tparam SurfacePatchIndex Type of indices for surface patches (boundaries and interfaces) +of the discretized geometric domain. +Must be a model of `CopyConstructible`, `Assignable`, `DefaultConstructible` +and `EqualityComparable`. The default constructed value must be the index value +assigned to a non surface facet. +It must match `MeshDomain_3::Surface_patch_index` when used for mesh generation. + +\cgalModels `SimplicialMeshCellBase_3` + +\sa `CGAL::Mesh_complex_3_in_triangulation_3` +\sa \link Mesh_cell_base_3 `CGAL::Mesh_cell_base_3`\endlink +\sa `MeshDomain_3` +\sa `MeshDomainWithFeatures_3` +*/ +template +class Compact_simplicial_mesh_cell_base_3 +{ +public: +#ifdef DOXYGEN_RUNNING + typedef unspecified_type Triangulation_data_structure; +#else + typedef internal::Dummy_tds_3 Triangulation_data_structure; +#endif + typedef Triangulation_data_structure::Vertex_handle Vertex_handle; + typedef Triangulation_data_structure::Cell_handle Cell_handle; + +public: + template + struct Rebind_TDS + { + typedef Compact_simplicial_mesh_cell_3 Other; + }; +}; + +} // namespace CGAL + +#endif // CGAL_COMPACT_SIMPLICIAL_MESH_CELL_BASE_3_H diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h index 162cfa27f21..94bcd7ab5f1 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h @@ -15,7 +15,7 @@ #include -#include +#include #include @@ -39,7 +39,7 @@ It must be a model of the `SimplicialMeshCellBase_3` concept. */ template > class Remeshing_cell_base_3 From 3ef293b5bd21e31567fcef8557e266091503f284 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 8 Sep 2023 11:41:14 +0200 Subject: [PATCH 09/10] Update to new cgalModels --- .../include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h index 94bcd7ab5f1..c551716d618 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_cell_base_3.h @@ -35,7 +35,7 @@ It has to be a model of the concept `RemeshingTriangulationTraits_3`. \tparam Cb is a cell base class from which `Remeshing_cell_base_3` derives. It must be a model of the `SimplicialMeshCellBase_3` concept. -\cgalModels `RemeshingCellBase_3` +\cgalModels{RemeshingCellBase_3} */ template Date: Wed, 13 Sep 2023 15:20:11 +0200 Subject: [PATCH 10/10] Add breaking changes --- Installation/CHANGES.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 47998400268..01485063f19 100644 --- a/Installation/CHANGES.md +++ b/Installation/CHANGES.md @@ -35,6 +35,18 @@ Release date: October 2023 - Removed the class templates `Gray_image_mesh_domain_3`, `Implicit_mesh_domain_3`, and `Labeled_image_mesh_domain_3` which are deprecated since CGAL-4.13. +### [Tetrahedral Remeshing](https://doc.cgal.org/6.0/Manual/packages.html#PkgTetrahedralRemeshing) +- **Breaking change**: The template parameters of + `CGAL::Tetrahedral_remeshing::Remeshing_cell_base_3` + have been modified, reverting changes introduced in CGAL 5.6. +- **Breaking change**: The vertex base of + `CGAL::Tetrahedral_remeshing::Remeshing_vertex_base_3` + must now be a model of the concept ` SimplicialMeshVertexBase_3` (and not only `TriangulationVertexBase_3`). + +### [3D Simplicial Mesh Data Structure](https://doc.cgal.org/6.0/Manual/packages.html#PkgSMDS3) +- **Breaking change**: The template parameters of + `CGAL::Simplicial_mesh_cell_base_3` + have been modified to enable passing a geometric traits and a custom cell base class. [Release 5.6](https://github.com/CGAL/cgal/releases/tag/v5.6) -----------