From d77bb6c242f1d0ffddf9f1308e26a4c62a80a69c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 19 May 2015 12:51:29 +0200 Subject: [PATCH] make all parametrization methods work --- .../Authalic_parameterization.cpp | 11 +++- .../Barycentric_mapping_parameterizer_3.h | 40 +++----------- .../CGAL/Discrete_authalic_parameterizer_3.h | 6 +-- .../Discrete_conformal_map_parameterizer_3.h | 52 ++++++------------- .../Mean_value_coordinates_parameterizer_3.h | 12 +++-- 5 files changed, 43 insertions(+), 78 deletions(-) diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Authalic_parameterization.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Authalic_parameterization.cpp index 9f3e169c595..b77651df0a7 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Authalic_parameterization.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/Authalic_parameterization.cpp @@ -7,6 +7,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -19,7 +22,7 @@ typedef CGAL::Simple_cartesian Kernel; typedef Kernel::Point_2 Point_2; -#if 0 +#if 1 typedef CGAL::Surface_mesh Polyhedron; #else typedef CGAL::Polyhedron_3 Polyhedron; @@ -102,7 +105,11 @@ int main(int argc, char * argv[]) // (defaults are circular border and Eigen solver) //*************************************** - typedef CGAL::Discrete_authalic_parameterizer_3 + typedef + CGAL::Discrete_authalic_parameterizer_3 + //CGAL::Barycentric_mapping_parameterizer_3 + //CGAL::Discrete_conformal_map_parameterizer_3 + //CGAL::Mean_value_coordinates_parameterizer_3 Parameterizer; Parameterizer::Error_code err = CGAL::parameterize(mesh_adaptor, Parameterizer()); 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 1bc05c3a05c..0b1212662b7 100644 --- a/Surface_mesh_parameterization/include/CGAL/Barycentric_mapping_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Barycentric_mapping_parameterizer_3.h @@ -99,39 +99,11 @@ public: // Private types private: - // Mesh_Adaptor_3 subtypes: - typedef typename Adaptor::NT NT; - typedef typename Adaptor::Point_2 Point_2; - typedef typename Adaptor::Point_3 Point_3; - typedef typename Adaptor::Vector_2 Vector_2; - typedef typename Adaptor::Vector_3 Vector_3; - typedef typename Adaptor::Facet Facet; - typedef typename Adaptor::Facet_handle Facet_handle; - typedef typename Adaptor::Facet_const_handle - Facet_const_handle; - typedef typename Adaptor::Facet_iterator Facet_iterator; - typedef typename Adaptor::Facet_const_iterator - Facet_const_iterator; - typedef typename Adaptor::Vertex Vertex; - typedef typename Adaptor::Vertex_handle Vertex_handle; - typedef typename Adaptor::Vertex_const_handle - Vertex_const_handle; - typedef typename Adaptor::Vertex_iterator Vertex_iterator; - typedef typename Adaptor::Vertex_const_iterator - Vertex_const_iterator; - typedef typename Adaptor::Border_vertex_iterator - Border_vertex_iterator; - typedef typename Adaptor::Border_vertex_const_iterator - Border_vertex_const_iterator; - typedef typename Adaptor::Vertex_around_facet_circulator - Vertex_around_facet_circulator; - typedef typename Adaptor::Vertex_around_facet_const_circulator - Vertex_around_facet_const_circulator; - typedef typename Adaptor::Vertex_around_vertex_circulator - Vertex_around_vertex_circulator; - typedef typename Adaptor::Vertex_around_vertex_const_circulator - Vertex_around_vertex_const_circulator; + typedef typename Adaptor::Polyhedron TriangleMesh; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + typedef CGAL::Vertex_around_target_circulator vertex_around_target_circulator; + typedef typename ParameterizationMesh_3::NT NT; // SparseLinearAlgebraTraits_d subtypes: typedef typename Sparse_LA::Vector Vector; typedef typename Sparse_LA::Matrix Matrix; @@ -154,8 +126,8 @@ public: protected: /// Compute w_ij = (i,j) coefficient of matrix A for j neighbor vertex of i. virtual NT compute_w_ij(const Adaptor& /* mesh */, - Vertex_const_handle /* main_vertex_v_i */, - Vertex_around_vertex_const_circulator /* neighbor_vertex_v_j */ ) + vertex_descriptor /* main_vertex_v_i */, + vertex_around_target_circulator /* neighbor_vertex_v_j */ ) { /// Tutte Barycentric Mapping algorithm is the most simple one: /// w_ij = 1 for j neighbor vertex of i. diff --git a/Surface_mesh_parameterization/include/CGAL/Discrete_authalic_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Discrete_authalic_parameterizer_3.h index c0133d42b01..9a068f10cb6 100644 --- a/Surface_mesh_parameterization/include/CGAL/Discrete_authalic_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Discrete_authalic_parameterizer_3.h @@ -132,10 +132,10 @@ protected: vertex_descriptor main_vertex_v_i, vertex_around_target_circulator neighbor_vertex_v_j) { -typedef typename boost::property_map::const_type PPmap; - typedef typename boost::property_traits::reference Point_3; + typedef typename boost::property_map::const_type PPmap; + typedef typename boost::property_traits::reference Point_3; - PPmap ppmap = get(vertex_point, mesh.get_adapted_mesh()); + PPmap ppmap = get(vertex_point, mesh.get_adapted_mesh()); Point_3 position_v_i = get(ppmap,main_vertex_v_i); Point_3 position_v_j = get(ppmap,*neighbor_vertex_v_j); diff --git a/Surface_mesh_parameterization/include/CGAL/Discrete_conformal_map_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Discrete_conformal_map_parameterizer_3.h index 94a8b6ef4de..dc19a8f93fc 100644 --- a/Surface_mesh_parameterization/include/CGAL/Discrete_conformal_map_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Discrete_conformal_map_parameterizer_3.h @@ -101,39 +101,17 @@ public: // Private types private: + typedef typename Adaptor::Polyhedron TriangleMesh; + typedef typename boost::graph_traits::vertex_descriptor vertex_descriptor; + + typedef CGAL::Vertex_around_target_circulator vertex_around_target_circulator; // Mesh_Adaptor_3 subtypes: typedef typename Adaptor::NT NT; typedef typename Adaptor::Point_2 Point_2; typedef typename Adaptor::Point_3 Point_3; typedef typename Adaptor::Vector_2 Vector_2; typedef typename Adaptor::Vector_3 Vector_3; - typedef typename Adaptor::Facet Facet; - typedef typename Adaptor::Facet_handle Facet_handle; - typedef typename Adaptor::Facet_const_handle - Facet_const_handle; - typedef typename Adaptor::Facet_iterator Facet_iterator; - typedef typename Adaptor::Facet_const_iterator - Facet_const_iterator; - typedef typename Adaptor::Vertex Vertex; - typedef typename Adaptor::Vertex_handle Vertex_handle; - typedef typename Adaptor::Vertex_const_handle - Vertex_const_handle; - typedef typename Adaptor::Vertex_iterator Vertex_iterator; - typedef typename Adaptor::Vertex_const_iterator - Vertex_const_iterator; - typedef typename Adaptor::Border_vertex_iterator - Border_vertex_iterator; - typedef typename Adaptor::Border_vertex_const_iterator - Border_vertex_const_iterator; - typedef typename Adaptor::Vertex_around_facet_circulator - Vertex_around_facet_circulator; - typedef typename Adaptor::Vertex_around_facet_const_circulator - Vertex_around_facet_const_circulator; - typedef typename Adaptor::Vertex_around_vertex_circulator - Vertex_around_vertex_circulator; - typedef typename Adaptor::Vertex_around_vertex_const_circulator - Vertex_around_vertex_const_circulator; - + // SparseLinearAlgebraTraits_d subtypes: typedef typename Sparse_LA::Vector Vector; typedef typename Sparse_LA::Matrix Matrix; @@ -158,24 +136,28 @@ public: protected: /// Compute w_ij = (i,j) coefficient of matrix A for j neighbor vertex of i. virtual NT compute_w_ij(const Adaptor& mesh, - Vertex_const_handle main_vertex_v_i, - Vertex_around_vertex_const_circulator neighbor_vertex_v_j) + vertex_descriptor main_vertex_v_i, + vertex_around_target_circulator neighbor_vertex_v_j) { - Point_3 position_v_i = mesh.get_vertex_position(main_vertex_v_i); - Point_3 position_v_j = mesh.get_vertex_position(neighbor_vertex_v_j); + typedef typename boost::property_map::const_type PPmap; + typedef typename boost::property_traits::reference Point_3; + + PPmap ppmap = get(vertex_point, mesh.get_adapted_mesh()); + Point_3 position_v_i = get(ppmap,main_vertex_v_i); + Point_3 position_v_j = get(ppmap,*neighbor_vertex_v_j); // Compute cotangent of (v_i,v_k,v_j) corner (i.e. cotan of v_k corner) // if v_k is the vertex before v_j when circulating around v_i - Vertex_around_vertex_const_circulator previous_vertex_v_k = neighbor_vertex_v_j; + vertex_around_target_circulator previous_vertex_v_k = neighbor_vertex_v_j; previous_vertex_v_k --; - Point_3 position_v_k = mesh.get_vertex_position(previous_vertex_v_k); + Point_3 position_v_k = get(ppmap,*previous_vertex_v_k); double cotg_beta_ij = cotangent(position_v_i, position_v_k, position_v_j); // Compute cotangent of (v_j,v_l,v_i) corner (i.e. cotan of v_l corner) // if v_l is the vertex after v_j when circulating around v_i - Vertex_around_vertex_const_circulator next_vertex_v_l = neighbor_vertex_v_j; + vertex_around_target_circulator next_vertex_v_l = neighbor_vertex_v_j; next_vertex_v_l ++; - Point_3 position_v_l = mesh.get_vertex_position(next_vertex_v_l); + Point_3 position_v_l = get(ppmap,*next_vertex_v_l); double cotg_alpha_ij = cotangent(position_v_j, position_v_l, position_v_i); double weight = cotg_beta_ij+cotg_alpha_ij; 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 15246488fe5..effbf370a09 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 @@ -139,8 +139,12 @@ protected: vertex_descriptor main_vertex_v_i, vertex_around_target_circulator neighbor_vertex_v_j) { - Point_3 position_v_i = mesh.get_vertex_position(main_vertex_v_i); - Point_3 position_v_j = mesh.get_vertex_position(*neighbor_vertex_v_j); + typedef typename boost::property_map::const_type PPmap; + typedef typename boost::property_traits::reference Point_3; + + PPmap ppmap = get(vertex_point, mesh.get_adapted_mesh()); + Point_3 position_v_i = get(ppmap,main_vertex_v_i); + Point_3 position_v_j = get(ppmap,*neighbor_vertex_v_j); // Compute the norm of v_j -> v_i vector Vector_3 edge = position_v_i - position_v_j; @@ -150,14 +154,14 @@ protected: // if v_k is the vertex before v_j when circulating around v_i vertex_around_target_circulator previous_vertex_v_k = neighbor_vertex_v_j; previous_vertex_v_k --; - Point_3 position_v_k = mesh.get_vertex_position(*previous_vertex_v_k); + Point_3 position_v_k = get(ppmap,*previous_vertex_v_k); double gamma_ij = compute_angle_rad(position_v_j, position_v_i, position_v_k); // Compute angle of (v_l,v_i,v_j) corner (i.e. angle of v_i corner) // if v_l is the vertex after v_j when circulating around v_i vertex_around_target_circulator next_vertex_v_l = neighbor_vertex_v_j; next_vertex_v_l ++; - Point_3 position_v_l = mesh.get_vertex_position(*next_vertex_v_l); + Point_3 position_v_l = get(ppmap,*next_vertex_v_l); double delta_ij = compute_angle_rad(position_v_l, position_v_i, position_v_j); double weight = 0.0;