diff --git a/Installation/CHANGES.md b/Installation/CHANGES.md index 479984002682..01485063f191 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) ----------- diff --git a/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshCellBase_3.h b/SMDS_3/doc/SMDS_3/Concepts/SimplicialMeshCellBase_3.h index 12332226a754..3ae475cbba74 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 24878f48bd4a..3ff3421ef9cb 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/examples/SMDS_3/c3t3_example.cpp b/SMDS_3/examples/SMDS_3/c3t3_example.cpp index 14501c395c1b..5ebb5cc3e358 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/Compact_simplicial_mesh_cell_base_3.h b/SMDS_3/include/CGAL/Compact_simplicial_mesh_cell_base_3.h new file mode 100644 index 000000000000..92272897094d --- /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/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 0a5c70bfa601..f77f1d9c07f3 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 0001e33ed678..8ed8d332f598 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,94 @@ 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> -class 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 - 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_) - { - 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, - 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]; - } +/*! +\ingroup PkgSMDS3Classes - bool has_vertex(Vertex_handle v) const - { - return (V[0] == v) || (V[1] == v) || (V[2]== v) || (V[3]== v); - } +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. - 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; - } +\tparam Gt is the geometric traits class. +It must be a model of the concept `TriangulationTraits_3` - 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; - } +\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. - Cell_handle neighbor(int i) const - { - CGAL_precondition( i >= 0 && i <= 3); - return N[i]; - } +\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. - bool has_neighbor(Cell_handle n) const - { - return (N[0] == n) || (N[1] == n) || (N[2] == n) || (N[3] == n); - } +\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`. - 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; - } +\cgalModels{SimplicialMeshCellBase_3} - 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; - } +\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 Cb +{ +public: + using Vertex_handle = typename Cb::Vertex_handle; + using Cell_handle = typename Cb::Cell_handle; - // SETTING - void set_neighbor(int i, Cell_handle n) - { - CGAL_precondition( i >= 0 && i <= 3); - CGAL_precondition( this != n.operator->() ); - N[i] = n; - } + using Geom_traits = Gt; - void set_neighbors() - { - N[0] = N[1] = N[2] = N[3] = Cell_handle(); - } + // Index Type + using Subdomain_index = SubdomainIndex; + using Surface_patch_index = SurfacePatchIndex; - void set_neighbors(Cell_handle n0, Cell_handle n1, - Cell_handle n2, Cell_handle n3) +public: + template + struct Rebind_TDS { - 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); } + using Cb2 = typename Cb::template Rebind_TDS::Other; + using Other = Simplicial_mesh_cell_base_3; + }; - // TDS internal data access functions. - TDS_data& tds_data() { return _tds_data; } - const TDS_data& tds_data() const { return _tds_data; } +public: + Simplicial_mesh_cell_base_3() + : time_stamp_(std::size_t(-1)) + {} - // 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) + 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_) { - CGAL_precondition( i >= 0 && i <= 3); - V[i] = v; + for(int i=0; i <4; ++i) + surface_index_table_[i] = rhs.surface_index_table_[i]; } - void set_vertices() - { - V[0] = V[1] = V[2] = V[3] = Vertex_handle(); - } + Simplicial_mesh_cell_base_3(Vertex_handle v0, Vertex_handle v1, + Vertex_handle v2, Vertex_handle v3) + : Cb(v0, v1, v2, v3) + { } - 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_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) + { } // Returns the index of the cell of the input complex that contains the cell Subdomain_index subdomain_index() const { return subdomain_index_; } @@ -284,107 +191,60 @@ class Simplicial_mesh_cell_3 /// 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_base_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); - } + { + 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 Simplicial_mesh_cell_3&c) + std::ostream& operator<<(std::ostream& os, + const Simplicial_mesh_cell_base_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)); - } + { + 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 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. -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 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. - -\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 - { - typedef Simplicial_mesh_cell_3 Other; - }; }; -} // end namespace CGAL - +} // 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 d7b8a85263b9..96a2377355c6 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,69 @@ #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 -class Simplicial_mesh_vertex_3 -: public Vb +// 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_base_3 + : public Vb { private : using Cmvb3_base = Vb; @@ -53,11 +100,30 @@ private : using Vertex_handle = typename Vb::Vertex_handle; // Types + using Subdomain_index = SubdomainIndex; + using Surface_patch_index = SurfacePatchIndex; + using Curve_index = CurveIndex; + using Corner_index = CornerIndex; + using Index = Variant_with_no_duplicate_t; - using FT = typename GT::FT; - // Constructor - Simplicial_mesh_vertex_3() + using FT = typename Gt::FT; + +public: + 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) @@ -155,8 +221,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_base_3& v) { is >> static_cast(v); int dimension; @@ -181,7 +247,8 @@ private : 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_base_3& v) { os << static_cast(v); if(IO::is_ascii(os)) { @@ -200,89 +267,8 @@ private : v.index()); return os; } -}; // end class Simplicial_mesh_vertex_3 - - -/*! -\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 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 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 Curve_index 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. - -\tparam Corner_index 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. - -\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`. - -\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 > -struct 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 ; - }; }; - -} // end namespace CGAL - - +} // namespace CGAL #endif // CGAL_SIMPLICIAL_MESH_VERTEX_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 4f3531c5fcb4..e438200b9aaf 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; 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 15f6751141d2..c551716d618e 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,36 +15,63 @@ #include -#include +#include -namespace CGAL -{ -namespace Tetrahedral_remeshing -{ +#include + +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. -template -class Remeshing_cell_3 - : public CGAL::Simplicial_mesh_cell_3 +\cgalModels{RemeshingCellBase_3} + +*/ +template > +class Remeshing_cell_base_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: + template + struct Rebind_TDS + { + using Cb2 = typename Cb::template Rebind_TDS::Other; + using Other = Remeshing_cell_base_3; + }; 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,50 +81,11 @@ class Remeshing_cell_3 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`. -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 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. - -\cgalModels{RemeshingCellBase_3,SimplicialMeshCellBase_3} - -*/ -template -class Remeshing_cell_base_3 -{ -public: - template - struct Rebind_TDS - { - typedef Remeshing_cell_3 Other; - }; -}; - -}//end namespace Tetrahedral_remeshing -}//end namespace CGAL +} // namespace Tetrahedral_remeshing +} // namespace CGAL #endif //CGAL_TET_ADAPTIVE_REMESHING_CELL_BASE_3_H 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 7b2bb34f9cf3..f009ad0471cd 100644 --- a/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h +++ b/Tetrahedral_remeshing/include/CGAL/Tetrahedral_remeshing/Remeshing_triangulation_3.h @@ -45,14 +45,14 @@ 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, - 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 ca2697a81907..7602f7453705 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,43 +17,46 @@ #include -namespace CGAL -{ -namespace Tetrahedral_remeshing -{ +namespace CGAL { +namespace Tetrahedral_remeshing { /*! \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,SimplicialMeshVertexBase_3} */ -template > -using Remeshing_vertex_base_3 - = CGAL::Simplicial_mesh_vertex_base_3; - -}//end namespace Tetrahedral_remeshing - -}//end namespace CGAL +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_base_3; + }; + +public: + using Vb::Vb; // constructors +}; + +} // namespace Tetrahedral_remeshing +} // namespace CGAL #endif //CGAL_TET_ADAPTIVE_REMESHING_VERTEX_BASE_3_H diff --git a/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h b/Tetrahedral_remeshing/include/CGAL/tetrahedral_remeshing.h index edd23bc2967b..f1be0dcf844a 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. */