Test the global API of Surface_Mesh_Parameterization

This commit is contained in:
Mael Rouxel-Labbé 2020-07-07 15:20:11 +02:00
parent f168d3911e
commit 9c7a75f36f
1 changed files with 44 additions and 47 deletions

View File

@ -10,6 +10,7 @@
#include <CGAL/surface_mesh_parameterization.h> #include <CGAL/surface_mesh_parameterization.h>
#include <CGAL/Polygon_mesh_processing/measure.h> #include <CGAL/Polygon_mesh_processing/measure.h>
#include <CGAL/Polygon_mesh_processing/connected_components.h>
#include <boost/functional/hash.hpp> #include <boost/functional/hash.hpp>
@ -17,6 +18,7 @@
#include <fstream> #include <fstream>
namespace SMP = CGAL::Surface_mesh_parameterization; namespace SMP = CGAL::Surface_mesh_parameterization;
namespace PMP = CGAL::Polygon_mesh_processing;
typedef CGAL::Simple_cartesian<double> Kernel; typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2; typedef Kernel::Point_2 Point_2;
@ -94,7 +96,7 @@ int main(int, char**)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
PM_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(pm).first; PM_halfedge_descriptor hd = PMP::longest_border(pm).first;
CGAL::Unique_hash_map<PM_vertex_descriptor, Point_2, CGAL::Unique_hash_map<PM_vertex_descriptor, Point_2,
boost::hash<PM_vertex_descriptor> > uvhm; boost::hash<PM_vertex_descriptor> > uvhm;
@ -113,7 +115,7 @@ int main(int, char**)
std::cout << "Parameterized with MVC (POLY)!" << std::endl; std::cout << "Parameterized with MVC (POLY)!" << std::endl;
} }
} }
#endif #endif // MVC_POLYHEDRON_MESH
// *************************************************************************** // ***************************************************************************
// ARAP WITH POLYHEDRON_MESH // ARAP WITH POLYHEDRON_MESH
@ -131,7 +133,7 @@ int main(int, char**)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
PM_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(pm).first; PM_halfedge_descriptor hd = PMP::longest_border(pm).first;
// UV map // UV map
CGAL::Unique_hash_map<PM_vertex_descriptor, Point_2, CGAL::Unique_hash_map<PM_vertex_descriptor, Point_2,
@ -143,9 +145,7 @@ int main(int, char**)
// Indices map // Indices map
typedef boost::unordered_map<PM_vertex_descriptor, int> Indices; typedef boost::unordered_map<PM_vertex_descriptor, int> Indices;
Indices indices; Indices indices;
CGAL::Polygon_mesh_processing::connected_component( PMP::connected_component(face(opposite(hd, pm), pm), pm,
face(opposite(hd, pm), pm),
pm,
boost::make_function_output_iterator( boost::make_function_output_iterator(
SMP::internal::Index_map_filler<PMesh, Indices>(pm, indices))); SMP::internal::Index_map_filler<PMesh, Indices>(pm, indices)));
@ -158,8 +158,8 @@ int main(int, char**)
// Parameterizer // Parameterizer
SMP::ARAP_parameterizer_3<PMesh> parameterizer; SMP::ARAP_parameterizer_3<PMesh> parameterizer;
SMP::Error_code status = parameterizer.parameterize(pm, hd, uvpm, vipm, vpm); SMP::Error_code status = parameterizer.parameterize(pm, hd, uvpm, vipm, vpm);
SMP::Error_code status_bis = SMP::parameterize(pm, parameterizer, hd, uvpm);
if(status != SMP::OK) { if(status != SMP::OK || status_bis != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -167,7 +167,7 @@ int main(int, char**)
std::cout << "Parameterized with ARAP (POLY)!" << std::endl; std::cout << "Parameterized with ARAP (POLY)!" << std::endl;
} }
} }
#endif #endif // ARAP_POLYHEDRON_MESH
// *************************************************************************** // ***************************************************************************
// Barycentric mapping // Barycentric mapping
@ -185,7 +185,7 @@ int main(int, char**)
return EXIT_FAILURE; return EXIT_FAILURE;
} }
SM_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(sm).first; SM_halfedge_descriptor hd = PMP::longest_border(sm).first;
assert(hd != SM_halfedge_descriptor()); assert(hd != SM_halfedge_descriptor());
// UV map // UV map
@ -195,9 +195,7 @@ int main(int, char**)
// Indices map // Indices map
typedef boost::unordered_map<SM_vertex_descriptor, int> Indices; typedef boost::unordered_map<SM_vertex_descriptor, int> Indices;
Indices indices; Indices indices;
CGAL::Polygon_mesh_processing::connected_component( PMP::connected_component(face(opposite(hd, sm), sm), sm,
face(opposite(hd, sm), sm),
sm,
boost::make_function_output_iterator( boost::make_function_output_iterator(
SMP::internal::Index_map_filler<SMesh, Indices>(sm, indices))); SMP::internal::Index_map_filler<SMesh, Indices>(sm, indices)));
boost::associative_property_map<Indices> vipm(indices); boost::associative_property_map<Indices> vipm(indices);
@ -210,8 +208,9 @@ int main(int, char**)
SMP::Barycentric_mapping_parameterizer_3<SMesh> parameterizer; SMP::Barycentric_mapping_parameterizer_3<SMesh> parameterizer;
SMP::Error_code status = parameterizer.parameterize(sm, hd, uvpm, vipm, vpm); SMP::Error_code status = parameterizer.parameterize(sm, hd, uvpm, vipm, vpm);
SMP::Error_code status_bis = SMP::parameterize(sm, parameterizer, hd, uvpm);
if(status != SMP::OK) { if(status != SMP::OK || status_bis != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -219,7 +218,7 @@ int main(int, char**)
std::cout << "Parameterized with Barycentric (SM)!" << std::endl; std::cout << "Parameterized with Barycentric (SM)!" << std::endl;
} }
} }
#endif #endif // BARY_SURF_MESH
// *************************************************************************** // ***************************************************************************
// ARAP WITH SURF_MESH // ARAP WITH SURF_MESH
@ -238,8 +237,7 @@ int main(int, char**)
} }
// halfedge on the longest border // halfedge on the longest border
SM_halfedge_descriptor hd = SM_halfedge_descriptor hd = PMP::longest_border(sm).first;
CGAL::Polygon_mesh_processing::longest_border(sm).first;
CGAL::Unique_hash_map<SM_vertex_descriptor, Point_2, CGAL::Unique_hash_map<SM_vertex_descriptor, Point_2,
boost::hash<SM_vertex_descriptor> > uvhm; boost::hash<SM_vertex_descriptor> > uvhm;
@ -251,9 +249,7 @@ int main(int, char**)
// Indices map // Indices map
typedef boost::unordered_map<SM_vertex_descriptor, int> Indices; typedef boost::unordered_map<SM_vertex_descriptor, int> Indices;
Indices indices; Indices indices;
CGAL::Polygon_mesh_processing::connected_component( PMP::connected_component(face(opposite(hd, sm), sm), sm,
face(opposite(hd, sm), sm),
sm,
boost::make_function_output_iterator( boost::make_function_output_iterator(
SMP::internal::Index_map_filler<SMesh, Indices>(sm, indices))); SMP::internal::Index_map_filler<SMesh, Indices>(sm, indices)));
boost::associative_property_map<Indices> vipm(indices); boost::associative_property_map<Indices> vipm(indices);
@ -266,7 +262,9 @@ int main(int, char**)
SMP::ARAP_parameterizer_3<SMesh> parameterizer; SMP::ARAP_parameterizer_3<SMesh> parameterizer;
SMP::Error_code status = parameterizer.parameterize(sm, hd, uv_pm, vipm, vpm); SMP::Error_code status = parameterizer.parameterize(sm, hd, uv_pm, vipm, vpm);
if(status != SMP::OK) { SMP::Error_code status_bis = SMP::parameterize(sm, parameterizer, hd, uv_pm);
if(status != SMP::OK || status_bis != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -274,7 +272,7 @@ int main(int, char**)
std::cout << "Parameterized with ARAP (SM)!" << std::endl; std::cout << "Parameterized with ARAP (SM)!" << std::endl;
} }
} }
#endif #endif // ARAP_SURF_MESH
#ifdef DCM_PM_SEAM_MESH #ifdef DCM_PM_SEAM_MESH
{ {
@ -307,14 +305,12 @@ int main(int, char**)
PM_UV_pmap uv_pm(uv_hm); PM_UV_pmap uv_pm(uv_hm);
// a halfedge on the (possibly virtual) border // a halfedge on the (possibly virtual) border
PM_SE_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(mesh).first; PM_SE_halfedge_descriptor hd = PMP::longest_border(mesh).first;
// Indices // Indices
typedef boost::unordered_map<PM_SE_vertex_descriptor, int> Indices; typedef boost::unordered_map<PM_SE_vertex_descriptor, int> Indices;
Indices indices; Indices indices;
CGAL::Polygon_mesh_processing::connected_component( PMP::connected_component(face(opposite(hd, mesh), mesh), mesh,
face(opposite(hd, mesh), mesh),
mesh,
boost::make_function_output_iterator( boost::make_function_output_iterator(
SMP::internal::Index_map_filler<PM_Seam_mesh, Indices>(mesh, indices))); SMP::internal::Index_map_filler<PM_Seam_mesh, Indices>(mesh, indices)));
boost::associative_property_map<Indices> vipm(indices); boost::associative_property_map<Indices> vipm(indices);
@ -326,8 +322,9 @@ int main(int, char**)
SMP::Discrete_conformal_map_parameterizer_3<PM_Seam_mesh> parameterizer; SMP::Discrete_conformal_map_parameterizer_3<PM_Seam_mesh> parameterizer;
SMP::Error_code status = parameterizer.parameterize(mesh, hd, uv_pm, vipm, vpm); SMP::Error_code status = parameterizer.parameterize(mesh, hd, uv_pm, vipm, vpm);
SMP::Error_code status_bis = SMP::parameterize(mesh, parameterizer, hd, uv_pm);
if(status != SMP::OK) { if(status != SMP::OK || status_bis != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -335,7 +332,7 @@ int main(int, char**)
std::cout << "Parameterized with DCM (SEAM POLY)!" << std::endl; std::cout << "Parameterized with DCM (SEAM POLY)!" << std::endl;
} }
} }
#endif #endif // DCM_PM_SEAM_MESH
// *************************************************************************** // ***************************************************************************
// DAC WITH SEAM_MESH (SM) // DAC WITH SEAM_MESH (SM)
@ -373,14 +370,12 @@ int main(int, char**)
Point_2>("h:uv").first; Point_2>("h:uv").first;
// a halfedge on the (possibly virtual) border // a halfedge on the (possibly virtual) border
SM_SE_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(mesh).first; SM_SE_halfedge_descriptor hd = PMP::longest_border(mesh).first;
// Indices // Indices
typedef boost::unordered_map<SM_SE_vertex_descriptor, int> Indices; typedef boost::unordered_map<SM_SE_vertex_descriptor, int> Indices;
Indices indices; Indices indices;
CGAL::Polygon_mesh_processing::connected_component( PMP::connected_component(face(opposite(hd, mesh), mesh), mesh,
face(opposite(hd, mesh), mesh),
mesh,
boost::make_function_output_iterator( boost::make_function_output_iterator(
SMP::internal::Index_map_filler<SM_Seam_mesh, Indices>(mesh, indices))); SMP::internal::Index_map_filler<SM_Seam_mesh, Indices>(mesh, indices)));
boost::associative_property_map<Indices> vipm(indices); boost::associative_property_map<Indices> vipm(indices);
@ -392,7 +387,9 @@ int main(int, char**)
SMP::Discrete_authalic_parameterizer_3<SM_Seam_mesh> parameterizer; SMP::Discrete_authalic_parameterizer_3<SM_Seam_mesh> parameterizer;
SMP::Error_code status = parameterizer.parameterize(mesh, hd, uv_pm, vipm, vpm); SMP::Error_code status = parameterizer.parameterize(mesh, hd, uv_pm, vipm, vpm);
if(status != SMP::OK) { SMP::Error_code status_bis = SMP::parameterize(mesh, parameterizer, hd, uv_pm);
if(status != SMP::OK || status_bis != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -400,7 +397,7 @@ int main(int, char**)
std::cout << "Parameterized with DAC (SEAM SM)!" << std::endl; std::cout << "Parameterized with DAC (SEAM SM)!" << std::endl;
} }
} }
#endif #endif // DAC_SM_SEAM_MESH
#ifdef ORBIFOLD_SM_MESH #ifdef ORBIFOLD_SM_MESH
{ {
@ -464,10 +461,10 @@ int main(int, char**)
// a halfedge on the (possibly virtual) border // a halfedge on the (possibly virtual) border
// only used in output (will also be used to handle multiple connected components in the future) // only used in output (will also be used to handle multiple connected components in the future)
SM_SE_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(mesh, SM_SE_halfedge_descriptor hd = PMP::longest_border(mesh, PMP::parameters::all_default()).first;
CGAL::Polygon_mesh_processing::parameters::all_default()).first;
SMP::Error_code status = parameterizer.parameterize(mesh, hd, cmap, uvmap, vimap); SMP::Error_code status = parameterizer.parameterize(mesh, hd, cmap, uvmap, vimap);
if(status != SMP::OK) { if(status != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return EXIT_FAILURE; return EXIT_FAILURE;
@ -476,7 +473,7 @@ int main(int, char**)
std::cout << "Parameterized with Orbifold (SEAM SM)!" << std::endl; std::cout << "Parameterized with Orbifold (SEAM SM)!" << std::endl;
} }
} }
#endif #endif // ORBIFOLD_SM_MESH
std::cout << "Done!" << std::endl; std::cout << "Done!" << std::endl;