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).
This commit is contained in:
Mael Rouxel-Labbé 2023-07-21 09:55:01 +02:00
parent 796baca1c5
commit 3ad1825359
4 changed files with 158 additions and 183 deletions

View File

@ -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<Tr,CornerIndex,CurveIndex>`
\sa \link Mesh_cell_base_3 `CGAL::Mesh_cell_base_3`\endlink
\sa `MeshDomain_3`
\sa `MeshDomainWithFeatures_3`
*/
template <typename Gt,
typename SubdomainIndex,
typename SurfacePatchIndex,
typename Cb>
class Simplicial_mesh_cell_3
typename Cb = Triangulation_cell_base_3<Gt> >
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 <typename TDS2>
struct Rebind_TDS
{
using Cb2 = typename Cb::template Rebind_TDS<TDS2>::Other;
using Other = Simplicial_mesh_cell_base_3<Gt,
SubdomainIndex,
SurfacePatchIndex,
Cb2>;
};
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<const Cb&>(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<Tr,CornerIndex,CurveIndex>`
\sa \link Mesh_cell_base_3 `CGAL::Mesh_cell_base_3`\endlink
\sa `MeshDomain_3`
\sa `MeshDomainWithFeatures_3`
*/
template <typename Gt,
typename SubdomainIndex,
typename SurfacePatchIndex,
typename Cb = Triangulation_cell_base_3<Gt> >
class Simplicial_mesh_cell_base_3
{
public:
template <typename TDS2>
struct Rebind_TDS
{
using Cb2 = typename Cb::template Rebind_TDS<TDS2>::Other;
using Other = Simplicial_mesh_cell_3<Gt,
SubdomainIndex,
SurfacePatchIndex,
Cb2>;
};
};
} // namespace CGAL
#endif // CGAL_SIMPLICIAL_MESH_CELL_BASE_3_H

View File

@ -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<typename Gt,
typename SubdomainIndex,
typename SurfacePatchIndex,
typename CurveIndex,
typename CornerIndex,
typename Vb>
class Simplicial_mesh_vertex_3
typename Vb = CGAL::Triangulation_vertex_base_3<Gt> >
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 <typename TDS2>
struct Rebind_TDS
{
using Vb2 = typename Vb::template Rebind_TDS<TDS2>::Other;
using Other = Simplicial_mesh_vertex_base_3<Gt,
SubdomainIndex,
SurfacePatchIndex,
CurveIndex,
CornerIndex,
Vb2>;
};
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<Cmvb3_base&>(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<const Cmvb3_base&>(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<typename Gt,
typename SubdomainIndex,
typename SurfacePatchIndex,
typename CurveIndex,
typename CornerIndex,
typename Vb = CGAL::Triangulation_vertex_base_3<Gt> >
class Simplicial_mesh_vertex_base_3
{
public:
template <typename TDS2>
struct Rebind_TDS
{
using Vb2 = typename Vb::template Rebind_TDS<TDS2>::Other;
using Other = Simplicial_mesh_vertex_3<Gt,
SubdomainIndex,
SurfacePatchIndex,
CurveIndex,
CornerIndex,
Vb2>;
};
};
} // namespace CGAL
#endif // CGAL_SIMPLICIAL_MESH_VERTEX_BASE_3_H

View File

@ -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<typename Gt,
typename Cb>
class Remeshing_cell_3
typename Cb = CGAL::Simplicial_mesh_cell_base_3<Gt,
int /*Subdomain_index*/,
int /*Surface_patch_index*/> >
class Remeshing_cell_base_3
: public Cb
{
public:
@ -35,6 +53,14 @@ public:
using Geom_traits = Gt;
public:
template <typename TDS2>
struct Rebind_TDS
{
using Cb2 = typename Cb::template Rebind_TDS<TDS2>::Other;
using Other = Remeshing_cell_base_3<Gt, Cb2>;
};
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<typename Gt,
typename Cb = CGAL::Simplicial_mesh_cell_base_3<Gt,
int /*Subdomain_index*/,
int /*Surface_patch_index*/> >
class Remeshing_cell_base_3
{
public:
template <typename TDS2>
struct Rebind_TDS
{
using Cb2 = typename Cb::template Rebind_TDS<TDS2>::Other;
using Other = Remeshing_cell_3<Gt, Cb2>;
};
};
} // namespace Tetrahedral_remeshing
} // namespace CGAL

View File

@ -20,15 +20,6 @@
namespace CGAL {
namespace Tetrahedral_remeshing {
template<typename Gt,
typename Vb>
class Remeshing_vertex_3
: public Vb
{
public:
using Vb::Vb; // constructors
};
/*!
\ingroup PkgTetrahedralRemeshingClasses
@ -51,14 +42,18 @@ template<typename Gt,
int /*Curve_index*/,
int /*Corner_index*/> >
class Remeshing_vertex_base_3
: public Vb
{
public:
template <typename TDS2>
struct Rebind_TDS
{
using Vb2 = typename Vb::template Rebind_TDS<TDS2>::Other;
using Other = Remeshing_vertex_3<Gt, Vb2>;
using Other = Remeshing_vertex_base_3<Gt, Vb2>;
};
public:
using Vb::Vb; // constructors
};
} // namespace Tetrahedral_remeshing