make all parametrization methods work

This commit is contained in:
Andreas Fabri 2015-05-19 12:51:29 +02:00 committed by Mael Rouxel-Labbé
parent f664cb4268
commit d77bb6c242
5 changed files with 43 additions and 78 deletions

View File

@ -7,6 +7,9 @@
#include <CGAL/Parameterization_polyhedron_adaptor_3.h> #include <CGAL/Parameterization_polyhedron_adaptor_3.h>
#include <CGAL/parameterize.h> #include <CGAL/parameterize.h>
#include <CGAL/Discrete_authalic_parameterizer_3.h> #include <CGAL/Discrete_authalic_parameterizer_3.h>
#include <CGAL/Barycentric_mapping_parameterizer_3.h>
#include <CGAL/Discrete_conformal_map_parameterizer_3.h>
#include <CGAL/Mean_value_coordinates_parameterizer_3.h>
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
#include <iostream> #include <iostream>
#include <cstdlib> #include <cstdlib>
@ -19,7 +22,7 @@
typedef CGAL::Simple_cartesian<double> Kernel; typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_2 Point_2; typedef Kernel::Point_2 Point_2;
#if 0 #if 1
typedef CGAL::Surface_mesh<Kernel::Point_3> Polyhedron; typedef CGAL::Surface_mesh<Kernel::Point_3> Polyhedron;
#else #else
typedef CGAL::Polyhedron_3<Kernel> Polyhedron; typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
@ -102,7 +105,11 @@ int main(int argc, char * argv[])
// (defaults are circular border and Eigen solver) // (defaults are circular border and Eigen solver)
//*************************************** //***************************************
typedef CGAL::Discrete_authalic_parameterizer_3<Parameterization_polyhedron_adaptor> typedef
CGAL::Discrete_authalic_parameterizer_3<Parameterization_polyhedron_adaptor>
//CGAL::Barycentric_mapping_parameterizer_3<Parameterization_polyhedron_adaptor>
//CGAL::Discrete_conformal_map_parameterizer_3<Parameterization_polyhedron_adaptor>
//CGAL::Mean_value_coordinates_parameterizer_3<Parameterization_polyhedron_adaptor>
Parameterizer; Parameterizer;
Parameterizer::Error_code err = CGAL::parameterize(mesh_adaptor, Parameterizer()); Parameterizer::Error_code err = CGAL::parameterize(mesh_adaptor, Parameterizer());

View File

@ -99,39 +99,11 @@ public:
// Private types // Private types
private: private:
// Mesh_Adaptor_3 subtypes: typedef typename Adaptor::Polyhedron TriangleMesh;
typedef typename Adaptor::NT NT; typedef typename boost::graph_traits<TriangleMesh>::vertex_descriptor vertex_descriptor;
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 CGAL::Vertex_around_target_circulator<TriangleMesh> vertex_around_target_circulator;
typedef typename ParameterizationMesh_3::NT NT;
// SparseLinearAlgebraTraits_d subtypes: // SparseLinearAlgebraTraits_d subtypes:
typedef typename Sparse_LA::Vector Vector; typedef typename Sparse_LA::Vector Vector;
typedef typename Sparse_LA::Matrix Matrix; typedef typename Sparse_LA::Matrix Matrix;
@ -154,8 +126,8 @@ public:
protected: protected:
/// Compute w_ij = (i,j) coefficient of matrix A for j neighbor vertex of i. /// Compute w_ij = (i,j) coefficient of matrix A for j neighbor vertex of i.
virtual NT compute_w_ij(const Adaptor& /* mesh */, virtual NT compute_w_ij(const Adaptor& /* mesh */,
Vertex_const_handle /* main_vertex_v_i */, vertex_descriptor /* main_vertex_v_i */,
Vertex_around_vertex_const_circulator /* neighbor_vertex_v_j */ ) vertex_around_target_circulator /* neighbor_vertex_v_j */ )
{ {
/// Tutte Barycentric Mapping algorithm is the most simple one: /// Tutte Barycentric Mapping algorithm is the most simple one:
/// w_ij = 1 for j neighbor vertex of i. /// w_ij = 1 for j neighbor vertex of i.

View File

@ -132,10 +132,10 @@ protected:
vertex_descriptor main_vertex_v_i, vertex_descriptor main_vertex_v_i,
vertex_around_target_circulator neighbor_vertex_v_j) vertex_around_target_circulator neighbor_vertex_v_j)
{ {
typedef typename boost::property_map<typename Adaptor::Polyhedron, boost::vertex_point_t>::const_type PPmap; typedef typename boost::property_map<typename Adaptor::Polyhedron, boost::vertex_point_t>::const_type PPmap;
typedef typename boost::property_traits<PPmap>::reference Point_3; typedef typename boost::property_traits<PPmap>::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_i = get(ppmap,main_vertex_v_i);
Point_3 position_v_j = get(ppmap,*neighbor_vertex_v_j); Point_3 position_v_j = get(ppmap,*neighbor_vertex_v_j);

View File

@ -101,38 +101,16 @@ public:
// Private types // Private types
private: private:
typedef typename Adaptor::Polyhedron TriangleMesh;
typedef typename boost::graph_traits<TriangleMesh>::vertex_descriptor vertex_descriptor;
typedef CGAL::Vertex_around_target_circulator<TriangleMesh> vertex_around_target_circulator;
// Mesh_Adaptor_3 subtypes: // Mesh_Adaptor_3 subtypes:
typedef typename Adaptor::NT NT; typedef typename Adaptor::NT NT;
typedef typename Adaptor::Point_2 Point_2; typedef typename Adaptor::Point_2 Point_2;
typedef typename Adaptor::Point_3 Point_3; typedef typename Adaptor::Point_3 Point_3;
typedef typename Adaptor::Vector_2 Vector_2; typedef typename Adaptor::Vector_2 Vector_2;
typedef typename Adaptor::Vector_3 Vector_3; 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: // SparseLinearAlgebraTraits_d subtypes:
typedef typename Sparse_LA::Vector Vector; typedef typename Sparse_LA::Vector Vector;
@ -158,24 +136,28 @@ public:
protected: protected:
/// Compute w_ij = (i,j) coefficient of matrix A for j neighbor vertex of i. /// Compute w_ij = (i,j) coefficient of matrix A for j neighbor vertex of i.
virtual NT compute_w_ij(const Adaptor& mesh, virtual NT compute_w_ij(const Adaptor& mesh,
Vertex_const_handle main_vertex_v_i, vertex_descriptor main_vertex_v_i,
Vertex_around_vertex_const_circulator neighbor_vertex_v_j) vertex_around_target_circulator neighbor_vertex_v_j)
{ {
Point_3 position_v_i = mesh.get_vertex_position(main_vertex_v_i); typedef typename boost::property_map<typename Adaptor::Polyhedron, boost::vertex_point_t>::const_type PPmap;
Point_3 position_v_j = mesh.get_vertex_position(neighbor_vertex_v_j); typedef typename boost::property_traits<PPmap>::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) // 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 // 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 --; 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); 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) // 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 // 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 ++; 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 cotg_alpha_ij = cotangent(position_v_j, position_v_l, position_v_i);
double weight = cotg_beta_ij+cotg_alpha_ij; double weight = cotg_beta_ij+cotg_alpha_ij;

View File

@ -139,8 +139,12 @@ protected:
vertex_descriptor main_vertex_v_i, vertex_descriptor main_vertex_v_i,
vertex_around_target_circulator neighbor_vertex_v_j) vertex_around_target_circulator neighbor_vertex_v_j)
{ {
Point_3 position_v_i = mesh.get_vertex_position(main_vertex_v_i); typedef typename boost::property_map<typename Adaptor::Polyhedron, boost::vertex_point_t>::const_type PPmap;
Point_3 position_v_j = mesh.get_vertex_position(*neighbor_vertex_v_j); typedef typename boost::property_traits<PPmap>::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 // Compute the norm of v_j -> v_i vector
Vector_3 edge = position_v_i - position_v_j; 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 // 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; vertex_around_target_circulator previous_vertex_v_k = neighbor_vertex_v_j;
previous_vertex_v_k --; 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); 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) // 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 // 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; vertex_around_target_circulator next_vertex_v_l = neighbor_vertex_v_j;
next_vertex_v_l ++; 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 delta_ij = compute_angle_rad(position_v_l, position_v_i, position_v_j);
double weight = 0.0; double weight = 0.0;