mirror of https://github.com/CGAL/cgal
Fixed discrete authalic example
This example is now used to illustrate the use of various border parameterizers
This commit is contained in:
parent
656d996e6f
commit
bb9230f4ff
|
|
@ -1,17 +1,21 @@
|
||||||
#include <CGAL/Simple_cartesian.h>
|
#include <CGAL/Simple_cartesian.h>
|
||||||
|
|
||||||
#include <CGAL/Surface_mesh.h>
|
#include <CGAL/Surface_mesh.h>
|
||||||
#include <CGAL/Polygon_mesh_processing/measure.h>
|
#include <CGAL/Polygon_mesh_processing/measure.h>
|
||||||
|
|
||||||
#include <CGAL/parameterize.h>
|
#include <CGAL/Circular_border_parameterizer_3.h>
|
||||||
#include <CGAL/Discrete_authalic_parameterizer_3.h>
|
|
||||||
#include <CGAL/Square_border_parameterizer_3.h>
|
#include <CGAL/Square_border_parameterizer_3.h>
|
||||||
|
|
||||||
|
#include <CGAL/IO/Surface_mesh_parameterization/File_off.h>
|
||||||
|
#include <CGAL/parameterize.h>
|
||||||
|
#include <CGAL/Discrete_authalic_parameterizer_3.h>
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
|
||||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||||
typedef Kernel::Point_2 Point_2;
|
typedef Kernel::Point_2 Point_2;
|
||||||
typedef Kernel::Point_3 Point_3;
|
typedef Kernel::Point_3 Point_3;
|
||||||
|
|
@ -21,43 +25,39 @@ typedef boost::graph_traits<SurfaceMesh>::halfedge_descriptor halfedge_descripto
|
||||||
typedef boost::graph_traits<SurfaceMesh>::vertex_descriptor vertex_descriptor;
|
typedef boost::graph_traits<SurfaceMesh>::vertex_descriptor vertex_descriptor;
|
||||||
typedef boost::graph_traits<SurfaceMesh>::face_descriptor face_descriptor;
|
typedef boost::graph_traits<SurfaceMesh>::face_descriptor face_descriptor;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
SurfaceMesh sm;
|
SurfaceMesh sm;
|
||||||
|
|
||||||
std::ifstream in((argc>1)?argv[1]:"data/blob.off");
|
std::ifstream in((argc>1) ? argv[1] : "data/nefertiti.off");
|
||||||
std::ofstream out((argc>2)?argv[2]:"blob.polylines.txt");
|
|
||||||
|
|
||||||
in >> sm;
|
in >> sm;
|
||||||
|
|
||||||
halfedge_descriptor bhd= CGAL::Polygon_mesh_processing::longest_border(sm).first
|
halfedge_descriptor bhd = CGAL::Polygon_mesh_processing::longest_border(sm).first;
|
||||||
|
|
||||||
// The 2D points of the uv parametrisation will be written into this map
|
// The 2D points of the uv parametrisation will be written into this map
|
||||||
SurfaceMesh::Property_map<vertex_descriptor, Point_2> uvpm;
|
SurfaceMesh::Property_map<vertex_descriptor, Point_2> uvpm;
|
||||||
bool created;
|
bool created;
|
||||||
boost::tie(uvpm, created) = sm.add_property_map<vertex_descriptor, Point_2>("v:uv");
|
boost::tie(uvpm, created) = sm.add_property_map<vertex_descriptor, Point_2>("v:uv");
|
||||||
|
|
||||||
typedef CGAL::Square_border_arc_length_parameterizer_3<SurfaceMesh> Border_parameterizer;
|
// Four different border parameterizers (pick one)
|
||||||
typedef CGAL::Discrete_authalic_parameterizer_3<SurfaceMesh,Border_parameterizer> Parameterizer;
|
typedef CGAL::Circular_border_uniform_parameterizer_3<SurfaceMesh> Border_parameterizer;
|
||||||
|
// typedef CGAL::Circular_border_arc_length_parameterizer_3<SurfaceMesh> Border_parameterizer;
|
||||||
|
// typedef CGAL::Square_border_uniform_parameterizer_3<SurfaceMesh> Border_parameterizer;
|
||||||
|
// typedef CGAL::Square_border_arc_length_parameterizer_3<SurfaceMesh> Border_parameterizer;
|
||||||
|
|
||||||
Parameterizer::Error_code err = CGAL::parameterize(sm, Parameterizer(), bhd, uvpm);
|
// Parameterize onto a square (non-uniformly on the border)
|
||||||
|
typedef CGAL::Discrete_authalic_parameterizer_3<SurfaceMesh, Border_parameterizer>
|
||||||
|
Parameterizer;
|
||||||
|
Parameterizer::Error_code s_err = CGAL::parameterize(sm, Parameterizer(), bhd, uvpm);
|
||||||
|
|
||||||
if(err != Parameterizer::OK){
|
if(s_err != Parameterizer::OK) {
|
||||||
std::cerr << "Error: " << Parameterizer::get_error_message(err) << std::endl;
|
std::cerr << "Error: " << Parameterizer::get_error_message(s_err) << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
out.precision(17);
|
std::ofstream out("result.off");
|
||||||
BOOST_FOREACH(face_descriptor fd, faces(sm)){
|
CGAL::Parameterization::output_uvmap_to_off(sm, bhd, uvpm, out);
|
||||||
halfedge_descriptor hd = halfedge(fd,sm);
|
|
||||||
out << "4 " << uvpm[target(hd,sm)].x() << " " << uvpm[target(hd,sm)].y() << " 0 ";
|
|
||||||
hd = next(hd,sm);
|
|
||||||
BOOST_FOREACH(vertex_descriptor vd, vertices_around_face(hd,sm)){
|
|
||||||
out << uvpm[vd].x() << " " << uvpm[vd].y() << " 0 ";
|
|
||||||
}
|
|
||||||
out << std::endl;
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,8 @@ int main(int argc, char * argv[])
|
||||||
CGAL::parameterize(mesh, Parameterizer(), bhd, uv_pm);
|
CGAL::parameterize(mesh, Parameterizer(), bhd, uv_pm);
|
||||||
}
|
}
|
||||||
|
|
||||||
CGAL::Parameterization::output_uvmap_to_off(mesh, bhd, uv_pm, std::cout);
|
std::ofstream out("result.off");
|
||||||
|
CGAL::Parameterization::output_uvmap_to_off(mesh, bhd, uv_pm, out);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ int main(int argc, char * argv[])
|
||||||
SurfaceMesh sm;
|
SurfaceMesh sm;
|
||||||
in >> sm;
|
in >> sm;
|
||||||
|
|
||||||
// An edge on the border
|
// An halfedge on the border
|
||||||
halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(sm).first;
|
halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(sm).first;
|
||||||
|
|
||||||
// The UV property map that holds the parameterized values
|
// The UV property map that holds the parameterized values
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <CGAL/Fixed_border_parameterizer_3.h>
|
#include <CGAL/Fixed_border_parameterizer_3.h>
|
||||||
#include <CGAL/Circular_border_parameterizer_3.h>
|
#include <CGAL/Circular_border_parameterizer_3.h>
|
||||||
|
#include <CGAL/Fixed_border_parameterizer_3.h>
|
||||||
#include <CGAL/Eigen_solver_traits.h>
|
#include <CGAL/Eigen_solver_traits.h>
|
||||||
|
|
||||||
/// \file Discrete_authalic_parameterizer_3.h
|
/// \file Discrete_authalic_parameterizer_3.h
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue