diff --git a/Surface_mesh_parameterization/include/CGAL/ARAP_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/ARAP_parameterizer_3.h index 6b8c65da728..2dbe3c8f22b 100644 --- a/Surface_mesh_parameterization/include/CGAL/ARAP_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/ARAP_parameterizer_3.h @@ -1245,6 +1245,20 @@ private: // Public operations public: + /// Check if the 3D -> 2D mapping is one-to-one. + template + bool is_one_to_one_mapping(const TriangleMesh& mesh, + const VertexUVMap uvmap) const + { + /// Theorem: A one-to-one mapping is guaranteed if all w_ij coefficients + /// are > 0 (for j vertex neighbor of i) and if the surface + /// border is mapped onto a 2D convex polygon. + /// Here, all w_ij coefficients = 1 (for j vertex neighbor of i), thus a + /// valid embedding is guaranteed if the surface border is mapped + /// onto a 2D convex polygon. + return internal::Parameterization::is_one_to_one_mapping(mesh, uvmap); + } + /// Compute a mapping from a triangular 3D surface mesh to a piece of the 2D space. /// The mapping is piecewise linear (linear in each triangle). /// The result is the (u,v) pair image of each vertex of the 3D surface. diff --git a/Surface_mesh_parameterization/include/CGAL/Barycentric_mapping_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Barycentric_mapping_parameterizer_3.h index e8ba50c6597..e745e614e0c 100644 --- a/Surface_mesh_parameterization/include/CGAL/Barycentric_mapping_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Barycentric_mapping_parameterizer_3.h @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -118,6 +119,21 @@ public: // Default copy constructor and operator =() are fine + /// Check if the 3D -> 2D mapping is one-to-one. + template + bool is_one_to_one_mapping(const TriangleMesh& mesh, + const VertexUVMap uvmap) const + { + /// Theorem: A one-to-one mapping is guaranteed if all w_ij coefficients + /// are > 0 (for j vertex neighbor of i) and if the surface + /// border is mapped onto a 2D convex polygon. + /// Here, all w_ij coefficients = 1 (for j vertex neighbor of i), thus a + /// valid embedding is guaranteed if the surface border is mapped + /// onto a 2D convex polygon. + return (Base::get_border_parameterizer().is_border_convex() || + internal::Parameterization::is_one_to_one_mapping(mesh, uvmap)); + } + // Protected operations protected: /// Compute w_ij = (i,j), coefficient of matrix A for j neighbor vertex of i. diff --git a/Surface_mesh_parameterization/include/CGAL/LSCM_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/LSCM_parameterizer_3.h index 8e7a9b5d39e..5929830566d 100644 --- a/Surface_mesh_parameterization/include/CGAL/LSCM_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/LSCM_parameterizer_3.h @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -147,6 +148,14 @@ public: // Default copy constructor and operator =() are fine + /// Check if the 3D -> 2D mapping is one-to-one. + template + bool is_one_to_one_mapping(const TriangleMesh& mesh, + const VertexUVMap uvmap) const + { + return internal::Parameterization::is_one_to_one_mapping(mesh, uvmap); + } + /// Compute a one-to-one mapping from a triangular 3D surface mesh /// to a piece of the 2D space. /// The mapping is piecewise linear (linear in each triangle). diff --git a/Surface_mesh_parameterization/include/CGAL/Mean_value_coordinates_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Mean_value_coordinates_parameterizer_3.h index f9e78fac610..2573a8d2e6f 100644 --- a/Surface_mesh_parameterization/include/CGAL/Mean_value_coordinates_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Mean_value_coordinates_parameterizer_3.h @@ -23,7 +23,7 @@ #include - +#include #include #include @@ -129,6 +129,21 @@ public: // Default copy constructor and operator =() are fine + /// Check if the 3D -> 2D mapping is one-to-one. + template + bool is_one_to_one_mapping(const TriangleMesh& mesh, + const VertexUVMap uvmap) const + { + /// Theorem: A one-to-one mapping is guaranteed if all w_ij coefficients + /// are > 0 (for j vertex neighbor of i) and if the surface + /// border is mapped onto a 2D convex polygon. + /// Here, all w_ij coefficients are positive (for j vertex neighbor of i), thus a + /// valid embedding is guaranteed if the surface border is mapped + /// onto a 2D convex polygon. + return (Base::get_border_parameterizer().is_border_convex() || + internal::Parameterization::is_one_to_one_mapping(mesh, uvmap)); + } + // Protected operations protected: /// Compute w_ij = (i, j) coefficient of matrix A for j neighbor vertex of i.