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,63 +1,63 @@
|
|||
#include <CGAL/Simple_cartesian.h>
|
||||
|
||||
#include <CGAL/Surface_mesh.h>
|
||||
#include <CGAL/Polygon_mesh_processing/measure.h>
|
||||
|
||||
#include <CGAL/parameterize.h>
|
||||
#include <CGAL/Discrete_authalic_parameterizer_3.h>
|
||||
#include <CGAL/Circular_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 <iostream>
|
||||
#include <cstdlib>
|
||||
#include <fstream>
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
typedef Kernel::Point_2 Point_2;
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
typedef CGAL::Surface_mesh<Kernel::Point_3> SurfaceMesh;
|
||||
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
typedef Kernel::Point_2 Point_2;
|
||||
typedef Kernel::Point_3 Point_3;
|
||||
typedef CGAL::Surface_mesh<Kernel::Point_3> SurfaceMesh;
|
||||
|
||||
typedef boost::graph_traits<SurfaceMesh>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef boost::graph_traits<SurfaceMesh>::vertex_descriptor vertex_descriptor;
|
||||
typedef boost::graph_traits<SurfaceMesh>::face_descriptor face_descriptor;
|
||||
|
||||
|
||||
typedef boost::graph_traits<SurfaceMesh>::halfedge_descriptor halfedge_descriptor;
|
||||
typedef boost::graph_traits<SurfaceMesh>::vertex_descriptor vertex_descriptor;
|
||||
typedef boost::graph_traits<SurfaceMesh>::face_descriptor face_descriptor;
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
SurfaceMesh sm;
|
||||
|
||||
std::ifstream in((argc>1)?argv[1]:"data/blob.off");
|
||||
std::ofstream out((argc>2)?argv[2]:"blob.polylines.txt");
|
||||
std::ifstream in((argc>1) ? argv[1] : "data/nefertiti.off");
|
||||
|
||||
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
|
||||
SurfaceMesh::Property_map<vertex_descriptor,Point_2> uvpm;
|
||||
// The 2D points of the uv parametrisation will be written into this map
|
||||
SurfaceMesh::Property_map<vertex_descriptor, Point_2> uvpm;
|
||||
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;
|
||||
typedef CGAL::Discrete_authalic_parameterizer_3<SurfaceMesh,Border_parameterizer> Parameterizer;
|
||||
// Four different border parameterizers (pick one)
|
||||
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){
|
||||
std::cerr << "Error: " << Parameterizer::get_error_message(err) << std::endl;
|
||||
if(s_err != Parameterizer::OK) {
|
||||
std::cerr << "Error: " << Parameterizer::get_error_message(s_err) << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
out.precision(17);
|
||||
BOOST_FOREACH(face_descriptor fd, faces(sm)){
|
||||
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;
|
||||
}
|
||||
std::ofstream out("result.off");
|
||||
CGAL::Parameterization::output_uvmap_to_off(sm, bhd, uvpm, out);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,8 @@ int main(int argc, char * argv[])
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ int main(int argc, char * argv[])
|
|||
SurfaceMesh sm;
|
||||
in >> sm;
|
||||
|
||||
// An edge on the border
|
||||
// An halfedge on the border
|
||||
halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(sm).first;
|
||||
|
||||
// The UV property map that holds the parameterized values
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <CGAL/Fixed_border_parameterizer_3.h>
|
||||
#include <CGAL/Circular_border_parameterizer_3.h>
|
||||
#include <CGAL/Fixed_border_parameterizer_3.h>
|
||||
#include <CGAL/Eigen_solver_traits.h>
|
||||
|
||||
/// \file Discrete_authalic_parameterizer_3.h
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@ parameterize(TriangleMesh& mesh,
|
|||
|
||||
// Compute (u,v) for border vertices
|
||||
// and mark them as "parameterized"
|
||||
status = get_border_parameterizer().parameterize_border(mesh,bhd,uvmap,vpm);
|
||||
status = get_border_parameterizer().parameterize_border(mesh, bhd, uvmap, vpm);
|
||||
|
||||
if (status != Base::OK)
|
||||
return status;
|
||||
|
|
|
|||
Loading…
Reference in New Issue