From 8e77c99653e256b565752629b7e30167acdf8e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 15 Nov 2016 13:46:07 +0100 Subject: [PATCH] Fixed seam meshes not always picking the longest border in a connected component --- .../CGAL/boost/graph/properties_Seam_mesh.h | 17 ++++++++++++----- .../Surface_mesh/Parameterization_plugin.cpp | 2 +- .../discrete_authalic.cpp | 2 +- .../Surface_mesh_parameterization/lscm.cpp | 11 ++++++++--- .../parameterization_tests.cpp | 18 ++++++++++++------ .../seam_Polyhedron_3.cpp | 10 +++++++--- .../simple_parameterization.cpp | 2 +- .../ARAP_parameterizer_3.h | 1 - 8 files changed, 42 insertions(+), 21 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/properties_Seam_mesh.h b/BGL/include/CGAL/boost/graph/properties_Seam_mesh.h index ae88b66c6de..47e15eb236b 100644 --- a/BGL/include/CGAL/boost/graph/properties_Seam_mesh.h +++ b/BGL/include/CGAL/boost/graph/properties_Seam_mesh.h @@ -123,12 +123,19 @@ struct property_map, CGAL::vertex_point_t> namespace CGAL { template - typename boost:: property_map, vertex_point_t>::const_type - get(vertex_point_t, const Seam_mesh& sm) - { - return Seam_mesh_point_map(sm, get(vertex_point, sm.mesh())); - } +typename boost:: property_map, vertex_point_t>::const_type +get(vertex_point_t, const Seam_mesh& sm) +{ + return Seam_mesh_point_map(sm, get(vertex_point, sm.mesh())); +} } // namespace CGAL +namespace boost +{ +template +struct graph_has_property, CGAL::vertex_point_t> + : CGAL::Tag_true {}; +} //boost + #endif // CGAL_PROPERTIES_SEAM_MESH_H diff --git a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Parameterization_plugin.cpp b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Parameterization_plugin.cpp index f6ad42ca7b3..f363d2bb53c 100644 --- a/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Parameterization_plugin.cpp +++ b/Polyhedron/demo/Polyhedron/Plugins/Surface_mesh/Parameterization_plugin.cpp @@ -576,7 +576,7 @@ void Polyhedron_demo_parameterization_plugin::parameterize(const Parameterizatio } halfedge_descriptor bhd(phd); - bhd = opposite(bhd,*sMesh); // a halfedge on the virtual border + bhd = opposite(bhd, *sMesh); // a halfedge on the virtual border bool success = false; switch(method) { diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/discrete_authalic.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/discrete_authalic.cpp index 61874b9e6ed..fbde3a5a8b9 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/discrete_authalic.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/discrete_authalic.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp index b2078be9a5e..24251d90d5e 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp @@ -2,6 +2,7 @@ #include #include + #include #include @@ -10,6 +11,8 @@ #include #include +#include + #include #include #include @@ -68,15 +71,17 @@ int main(int argc, char * argv[]) Mesh mesh(sm, seam_edge_pm, seam_vertex_pm); SM_halfedge_descriptor smhd = mesh.add_seams(filename); - assert(smhd != SM_halfedge_descriptor()); + if(smhd == SM_halfedge_descriptor() ) { + std::cerr << "Warning: No seams in input" << std::endl; + } // The 2D points of the uv parametrisation will be written into this map // Note that this is a halfedge property map, and that uv values // are only stored for the canonical halfedges representing a vertex UV_pmap uv_pm = sm.add_property_map("h:uv").first; - halfedge_descriptor bhd(smhd); - bhd = opposite(bhd, mesh); // a halfedge on the virtual border + // a halfedge on the (possibly virtual) border + halfedge_descriptor bhd = CGAL::Polygon_mesh_processing::longest_border(mesh, CGAL::Polygon_mesh_processing::parameters::all_default()).first; typedef SMP::Two_vertices_parameterizer_3 Border_parameterizer; typedef SMP::LSCM_parameterizer_3 Parameterizer; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/parameterization_tests.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/parameterization_tests.cpp index 102456f7e8a..94e5241611c 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/parameterization_tests.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/parameterization_tests.cpp @@ -307,7 +307,10 @@ int main(int argc, char * argv[]) sm.add_property_map("v:on_seam", false).first; SM_Seam_mesh mesh(sm, seam_edge_pm, seam_vertex_pm); - SM_halfedge_descriptor smhd = mesh.add_seams("../data/lion.selection.txt"); + SM_halfedge_descriptor smhd = mesh.add_seams(selection); + if(smhd == SM_halfedge_descriptor() ) { + std::cerr << "Warning: No seams in input" << std::endl; + } // The 2D points of the uv parametrisation will be written into this map // Note that this is a halfedge property map, and that the uv @@ -315,8 +318,8 @@ int main(int argc, char * argv[]) SM_UV_pmap uv_pm = sm.add_property_map("h:uv").first; - SM_SE_halfedge_descriptor bhd(smhd); - bhd = opposite(bhd, mesh); // a halfedge on the virtual border + // a halfedge on the (possibly virtual) border + SM_SE_halfedge_descriptor bhd = CGAL::Polygon_mesh_processing::longest_border(mesh).first; // Indices typedef boost::unordered_map Indices; @@ -357,7 +360,10 @@ int main(int argc, char * argv[]) PM_seam_vertex_pmap seam_vertex_pm(seam_vertex_hm); PM_Seam_mesh mesh(pm, seam_edge_pm, seam_vertex_pm); - PM_halfedge_descriptor pmhd = mesh.add_seams("../data/lion.selection.txt"); + PM_halfedge_descriptor pmhd = mesh.add_seams(selection); + if(pmhd == PM_halfedge_descriptor() ) { + std::cerr << "Warning: No seams in input" << std::endl; + } // The 2D points of the uv parametrisation will be written into this map // Note that this is a halfedge property map, and that the uv @@ -365,8 +371,8 @@ int main(int argc, char * argv[]) PM_UV_hmap uv_hm; PM_UV_pmap uv_pm(uv_hm); - PM_SE_halfedge_descriptor bhd(pmhd); - bhd = opposite(bhd, mesh); // a halfedge on the virtual border + // a halfedge on the (possibly virtual) border + PM_SE_halfedge_descriptor bhd = CGAL::Polygon_mesh_processing::longest_border(mesh).first; // Indices typedef boost::unordered_map Indices; diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/seam_Polyhedron_3.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/seam_Polyhedron_3.cpp index d8e00b8c1e7..a9f50e531b9 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/seam_Polyhedron_3.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/seam_Polyhedron_3.cpp @@ -2,6 +2,7 @@ #include #include + #include #include @@ -9,6 +10,7 @@ #include #include +#include #include #include @@ -61,7 +63,9 @@ int main(int argc, char * argv[]) const char* filename = (argc>2) ? argv[2] : "data/lion.selection.txt"; SM_halfedge_descriptor smhd = mesh.add_seams(filename); - assert(smhd != SM_halfedge_descriptor()); + if(smhd == SM_halfedge_descriptor() ) { + std::cerr << "Warning: No seams in input" << std::endl; + } // The 2D points of the uv parametrisation will be written into this map // Note that this is a halfedge property map, and that uv values @@ -69,8 +73,8 @@ int main(int argc, char * argv[]) UV_uhm uv_uhm; UV_pmap uv_pm(uv_uhm); - halfedge_descriptor bhd(smhd); - bhd = opposite(bhd, mesh); // a halfedge on the virtual border + // a halfedge on the (possibly virtual) border + halfedge_descriptor bhd = CGAL::Polygon_mesh_processing::longest_border(mesh).first; SMP::parameterize(mesh, bhd, uv_pm); diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/simple_parameterization.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/simple_parameterization.cpp index f91beb36f32..5a96b707cdf 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/simple_parameterization.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/simple_parameterization.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/ARAP_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/ARAP_parameterizer_3.h index 39084de6d8f..33218392d30 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/ARAP_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/ARAP_parameterizer_3.h @@ -36,7 +36,6 @@ #include #include // @tmp used for solving conic equations #include -#include #include #include