Merge pull request #3194 from MaelRL/Parameterization-Reduce_verbosity-GF

SMP: clean verbosity
This commit is contained in:
Laurent Rineau 2018-07-04 16:49:45 +02:00
commit 0e8b9b45df
12 changed files with 61 additions and 55 deletions

View File

@ -27,12 +27,12 @@ typedef boost::graph_traits<SurfaceMesh>::face_descriptor face_descriptor;
namespace SMP = CGAL::Surface_mesh_parameterization; namespace SMP = CGAL::Surface_mesh_parameterization;
int main(int argc, char * argv[]) int main(int argc, char** argv)
{ {
std::ifstream in((argc>1) ? argv[1] : "data/three_peaks.off"); std::ifstream in((argc>1) ? argv[1] : "data/three_peaks.off");
if(!in) { if(!in) {
std::cerr << "Problem loading the input data" << std::endl; std::cerr << "Problem loading the input data" << std::endl;
return 1; return EXIT_FAILURE;
} }
SurfaceMesh sm; SurfaceMesh sm;
@ -52,11 +52,11 @@ int main(int argc, char * argv[])
if(err != SMP::OK) { if(err != SMP::OK) {
std::cerr << "Error: " << SMP::get_error_message(err) << std::endl; std::cerr << "Error: " << SMP::get_error_message(err) << std::endl;
return 1; return EXIT_FAILURE;
} }
std::ofstream out("result.off"); std::ofstream out("result.off");
SMP::IO::output_uvmap_to_off(sm, bhd, uv_map, out); SMP::IO::output_uvmap_to_off(sm, bhd, uv_map, out);
return 0; return EXIT_SUCCESS;
} }

View File

@ -37,12 +37,12 @@ typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
namespace SMP = CGAL::Surface_mesh_parameterization; namespace SMP = CGAL::Surface_mesh_parameterization;
int main(int argc, char * argv[]) int main(int argc, char** argv)
{ {
std::ifstream in_mesh((argc>1) ? argv[1] : "data/lion.off"); std::ifstream in_mesh((argc>1) ? argv[1] : "data/lion.off");
if(!in_mesh){ if(!in_mesh){
std::cerr << "Error: problem loading the input data" << std::endl; std::cerr << "Error: problem loading the input data" << std::endl;
return 1; return EXIT_FAILURE;
} }
SurfaceMesh sm; SurfaceMesh sm;
@ -97,6 +97,6 @@ int main(int argc, char * argv[])
std::ofstream out("result.off"); std::ofstream out("result.off");
SMP::IO::output_uvmap_to_off(mesh, bhd, uv_pm, out); SMP::IO::output_uvmap_to_off(mesh, bhd, uv_pm, out);
return 0; return EXIT_SUCCESS;
} }

View File

@ -41,7 +41,7 @@ typedef SurfaceMesh::Property_map<SM_halfedge_descriptor, Point_2> UV_pmap;
namespace SMP = CGAL::Surface_mesh_parameterization; namespace SMP = CGAL::Surface_mesh_parameterization;
int main(int argc, char * argv[]) int main(int argc, char** argv)
{ {
CGAL::Timer task_timer; CGAL::Timer task_timer;
task_timer.start(); task_timer.start();
@ -50,7 +50,7 @@ int main(int argc, char * argv[])
std::ifstream in_mesh(mesh_filename); std::ifstream in_mesh(mesh_filename);
if(!in_mesh) { if(!in_mesh) {
std::cerr << "Error: problem loading the input data" << std::endl; std::cerr << "Error: problem loading the input data" << std::endl;
return 1; return EXIT_FAILURE;
} }
SurfaceMesh sm; // underlying mesh of the seam mesh SurfaceMesh sm; // underlying mesh of the seam mesh
@ -120,4 +120,5 @@ int main(int argc, char * argv[])
parameterizer.parameterize(mesh, bhd, cmap, uvmap, vimap); parameterizer.parameterize(mesh, bhd, cmap, uvmap, vimap);
std::cout << "Finished in " << task_timer.time() << " seconds" << std::endl; std::cout << "Finished in " << task_timer.time() << " seconds" << std::endl;
return EXIT_SUCCESS;
} }

View File

@ -37,12 +37,12 @@ typedef boost::graph_traits<Mesh>::face_descriptor face_descriptor;
namespace SMP = CGAL::Surface_mesh_parameterization; namespace SMP = CGAL::Surface_mesh_parameterization;
int main(int argc, char * argv[]) int main(int argc, char** argv)
{ {
std::ifstream in_mesh((argc>1)?argv[1]:"data/lion.off"); std::ifstream in_mesh((argc>1)?argv[1]:"data/lion.off");
if(!in_mesh) { if(!in_mesh) {
std::cerr << "Error: problem loading the input data" << std::endl; std::cerr << "Error: problem loading the input data" << std::endl;
return 1; return EXIT_FAILURE;
} }
PolyMesh sm; PolyMesh sm;
@ -77,6 +77,6 @@ int main(int argc, char * argv[])
std::ofstream out("result.off"); std::ofstream out("result.off");
SMP::IO::output_uvmap_to_off(mesh, bhd, uv_pm, out); SMP::IO::output_uvmap_to_off(mesh, bhd, uv_pm, out);
return 0; return EXIT_SUCCESS;
} }

View File

@ -21,12 +21,12 @@ typedef boost::graph_traits<SurfaceMesh>::face_descriptor face_descriptor;
namespace SMP = CGAL::Surface_mesh_parameterization; namespace SMP = CGAL::Surface_mesh_parameterization;
int main(int argc, char * argv[]) int main(int argc, char** argv)
{ {
std::ifstream in((argc>1) ? argv[1] : "data/nefertiti.off"); std::ifstream in((argc>1) ? argv[1] : "data/nefertiti.off");
if(!in) { if(!in) {
std::cerr << "Problem loading the input data" << std::endl; std::cerr << "Problem loading the input data" << std::endl;
return 1; return EXIT_FAILURE;
} }
SurfaceMesh sm; SurfaceMesh sm;
@ -44,5 +44,5 @@ int main(int argc, char * argv[])
std::ofstream out("result.off"); std::ofstream out("result.off");
SMP::IO::output_uvmap_to_off(sm, bhd, uv_map, out); SMP::IO::output_uvmap_to_off(sm, bhd, uv_map, out);
return 0; return EXIT_SUCCESS;
} }

View File

@ -97,7 +97,7 @@ bool read_vertices(const PolyMesh& mesh,
return true; return true;
} }
int main(int argc, char * argv[]) int main(int argc, char** argv)
{ {
std::ifstream in((argc>1) ? argv[1] : "data/nefertiti.off"); std::ifstream in((argc>1) ? argv[1] : "data/nefertiti.off");
if(!in){ if(!in){
@ -118,7 +118,7 @@ int main(int argc, char * argv[])
Vd_array vda; Vd_array vda;
if(!read_vertices(sm, filename, vda)) { if(!read_vertices(sm, filename, vda)) {
std::cerr << "Error: problem loading the square corners" << std::endl; std::cerr << "Error: problem loading the square corners" << std::endl;
return 1; return EXIT_FAILURE;
} }
typedef SMP::Square_border_uniform_parameterizer_3<PolyMesh> Border_parameterizer; typedef SMP::Square_border_uniform_parameterizer_3<PolyMesh> Border_parameterizer;
@ -138,5 +138,5 @@ int main(int argc, char * argv[])
std::ofstream out("result.off"); std::ofstream out("result.off");
SMP::IO::output_uvmap_to_off(sm, bhd, uv_map, out); SMP::IO::output_uvmap_to_off(sm, bhd, uv_map, out);
return 0; return EXIT_SUCCESS;
} }

View File

@ -1327,8 +1327,11 @@ public:
NT energy_this = compute_current_energy(mesh, faces, ctmap, lp, lpmap, NT energy_this = compute_current_energy(mesh, faces, ctmap, lp, lpmap,
ltmap, uvmap); ltmap, uvmap);
NT energy_last; NT energy_last;
#ifdef CGAL_PARAMETERIZATION_ARAP_VERBOSE
std::cout << "Initial energy: " << energy_this << std::endl; std::cout << "Initial energy: " << energy_this << std::endl;
std::cout << m_iterations << " max iterations" << std::endl; std::cout << m_iterations << " max iterations" << std::endl;
#endif
// main loop // main loop
for(unsigned int ite=1; ite<=m_iterations; ++ite) for(unsigned int ite=1; ite<=m_iterations; ++ite)
@ -1342,7 +1345,9 @@ public:
energy_last = energy_this; energy_last = energy_this;
energy_this = compute_current_energy(mesh, faces, ctmap, lp, lpmap, energy_this = compute_current_energy(mesh, faces, ctmap, lp, lpmap,
ltmap, uvmap); ltmap, uvmap);
#ifdef CGAL_PARAMETERIZATION_ARAP_VERBOSE
std::cout << "Energy at iteration " << ite << " : " << energy_this << std::endl; std::cout << "Energy at iteration " << ite << " : " << energy_this << std::endl;
#endif
CGAL_warning(energy_this >= 0); CGAL_warning(energy_this >= 0);
if(status != OK) if(status != OK)
@ -1353,9 +1358,11 @@ public:
{ // also no need compute energy if this iteration is the last iteration { // also no need compute energy if this iteration is the last iteration
double energy_diff = std::abs((energy_last - energy_this) / energy_this); double energy_diff = std::abs((energy_last - energy_this) / energy_this);
if(energy_diff < m_tolerance) { if(energy_diff < m_tolerance) {
#ifdef CGAL_PARAMETERIZATION_ARAP_VERBOSE
std::cout << "Minimization process ended after: " std::cout << "Minimization process ended after: "
<< ite + 1 << " iterations. " << ite + 1 << " iterations. "
<< "Energy diff: " << energy_diff << std::endl; << "Energy diff: " << energy_diff << std::endl;
#endif
break; break;
} }
} }

View File

@ -744,7 +744,6 @@ public:
// Run the MVC // Run the MVC
parameterize_convex_hull_with_MVC(mesh, vertices, faces, ct, uvmap, vimap, vpmap); parameterize_convex_hull_with_MVC(mesh, vertices, faces, ct, uvmap, vimap, vpmap);
std::cout << "End of post processing" << std::endl;
return OK; return OK;
} }

View File

@ -110,10 +110,12 @@ Error_code read_cones(const TriangleMesh& tm, std::ifstream& in, VertexIndexMap
while(in >> cone_index) while(in >> cone_index)
cones.push_back(cone_index); cones.push_back(cone_index);
#ifdef CGAL_PARAMETERIZATION_ORBIFOLD_CONE_VERBOSE
std::cout << "Input cones: "; std::cout << "Input cones: ";
for(std::size_t i=0; i<cones.size(); ++i) for(std::size_t i=0; i<cones.size(); ++i)
std::cout << cones[i] << " "; std::cout << cones[i] << " ";
std::cout << std::endl; std::cout << std::endl;
#endif
if(cones.size() < 3 || cones.size() > 4) { if(cones.size() < 3 || cones.size() > 4) {
std::cerr << "Error: Not enough or too many input cones" << std::endl; std::cerr << "Error: Not enough or too many input cones" << std::endl;

View File

@ -35,7 +35,7 @@ namespace Surface_mesh_parameterization {
namespace internal { namespace internal {
// -> -> // -> ->
// Return cotangent of (P,Q,R) corner (i.e. cotan of QP, QR angle). // Returns the cotangent of the corner (P,Q,R) (i.e. the cotan of the angle (QP, QR) ).
template<typename K> template<typename K>
typename K::FT cotangent(const typename K::Point_3& P, typename K::FT cotangent(const typename K::Point_3& P,
const typename K::Point_3& Q, const typename K::Point_3& Q,
@ -46,18 +46,17 @@ typename K::FT cotangent(const typename K::Point_3& P,
Vector_3 u = P - Q; Vector_3 u = P - Q;
Vector_3 v = R - Q; Vector_3 v = R - Q;
// (u . v) / ((u x v).len)
NT dot = (u * v); NT dot = (u * v);
Vector_3 cross_vector = CGAL::cross_product(u, v); Vector_3 cross_vector = CGAL::cross_product(u, v);
NT cross_norm = CGAL::sqrt(cross_vector * cross_vector); NT cross_norm = CGAL::sqrt(cross_vector * cross_vector);
if(cross_norm != 0.0) if(cross_norm != NT(0))
return (dot / cross_norm); return (dot / cross_norm);
else else
return 0.0; // undefined return 0; // undefined
} }
// -> -> // -> ->
// Return tangent of (P,Q,R) corner (i.e. tangent of QP, QR angle). // Returns the tangent of the corner (P,Q,R) (i.e. the tangent of angle (QP, QR) ).
template<typename K> template<typename K>
typename K::FT tangent(const typename K::Point_3& P, typename K::FT tangent(const typename K::Point_3& P,
const typename K::Point_3& Q, const typename K::Point_3& Q,
@ -68,17 +67,16 @@ typename K::FT tangent(const typename K::Point_3& P,
Vector_3 u = P - Q; Vector_3 u = P - Q;
Vector_3 v = R - Q; Vector_3 v = R - Q;
// (u . v) / ((u x v).len)
NT dot = (u * v); NT dot = (u * v);
Vector_3 cross_vector = CGAL::cross_product(u, v); Vector_3 cross_vector = CGAL::cross_product(u, v);
NT cross_norm = CGAL::sqrt(cross_vector * cross_vector); NT cross_norm = CGAL::sqrt(cross_vector * cross_vector);
if(dot != 0.0) if(dot != NT(0))
return (cross_norm / dot); return (cross_norm / dot);
else else
return 0.0; // undefined return 0; // undefined
} }
// Fix sine to be within [-1;1]. // Fixes the sine to be within [-1;1].
template<typename K> template<typename K>
typename K::FT fix_sine(typename K::FT sine) typename K::FT fix_sine(typename K::FT sine)
{ {
@ -91,7 +89,7 @@ typename K::FT fix_sine(typename K::FT sine)
} }
// -> -> // -> ->
// Return angle (in radians) of of (P,Q,R) corner (i.e. QP, QR angle). // Returns the angle (in radians) of the corner (P,Q,R) (i.e. the angle (QP, QR) ).
template<typename K> template<typename K>
typename K::FT compute_angle_rad(const typename K::Point_3& P, typename K::FT compute_angle_rad(const typename K::Point_3& P,
const typename K::Point_3& Q, const typename K::Point_3& Q,
@ -103,10 +101,9 @@ typename K::FT compute_angle_rad(const typename K::Point_3& P,
Vector_3 u = P - Q; Vector_3 u = P - Q;
Vector_3 v = R - Q; Vector_3 v = R - Q;
// check
NT product = CGAL::sqrt(u * u) * CGAL::sqrt(v * v); NT product = CGAL::sqrt(u * u) * CGAL::sqrt(v * v);
if(product == 0) if(product == NT(0))
return 0.0; return 0;
// cosine // cosine
NT dot = (u * v); NT dot = (u * v);
@ -116,7 +113,7 @@ typename K::FT compute_angle_rad(const typename K::Point_3& P,
Vector_3 w = CGAL::cross_product(u, v); Vector_3 w = CGAL::cross_product(u, v);
NT abs_sine = CGAL::sqrt(w * w) / product; NT abs_sine = CGAL::sqrt(w * w) / product;
if(cosine >= 0) if(cosine >= NT(0))
return std::asin(fix_sine<K>(abs_sine)); return std::asin(fix_sine<K>(abs_sine));
else else
return CGAL_PI - std::asin(fix_sine<K>(abs_sine)); return CGAL_PI - std::asin(fix_sine<K>(abs_sine));

View File

@ -130,7 +130,7 @@ void compute_shortest_paths_between_two_cones(const TriangleMesh& mesh,
EdgeOutputIterator oi) EdgeOutputIterator oi)
{ {
if(source == target) { if(source == target) {
std::cout << "Warning: the source and target are identical in 'shortest_path' " << std::endl; std::cerr << "Warning: the source and target are identical in 'shortest_path' " << std::endl;
return; return;
} }
@ -150,7 +150,7 @@ void compute_shortest_paths_between_two_cones(const TriangleMesh& mesh,
try { try {
boost::dijkstra_shortest_paths(mesh, source, boost::predecessor_map(pred_pmap).visitor(vis)); boost::dijkstra_shortest_paths(mesh, source, boost::predecessor_map(pred_pmap).visitor(vis));
} catch (const std::exception& e) { } catch (const std::exception& e) {
std::cout << e.what() << std::endl; std::cerr << e.what() << std::endl;
} }
// Draw the path from target to source and collect the edges along the way // Draw the path from target to source and collect the edges along the way

View File

@ -92,7 +92,7 @@ int main(int, char**)
in >> pm; in >> pm;
if(!in || num_vertices(pm) == 0) { if(!in || num_vertices(pm) == 0) {
std::cerr << "Problem loading the input data" << std::endl; std::cerr << "Problem loading the input data" << std::endl;
return 1; return EXIT_FAILURE;
} }
PM_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(pm).first; PM_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(pm).first;
@ -108,7 +108,7 @@ int main(int, char**)
if(status != SMP::OK) { if(status != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return 1; return EXIT_FAILURE;
} }
else { else {
std::cout << "Parameterized with MVC (POLY)!" << std::endl; std::cout << "Parameterized with MVC (POLY)!" << std::endl;
@ -129,7 +129,7 @@ int main(int, char**)
in >> pm; in >> pm;
if(!in || num_vertices(pm) == 0) { if(!in || num_vertices(pm) == 0) {
std::cerr << "Problem loading the input data" << std::endl; std::cerr << "Problem loading the input data" << std::endl;
return 1; return EXIT_FAILURE;
} }
PM_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(pm).first; PM_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(pm).first;
@ -162,7 +162,7 @@ int main(int, char**)
if(status != SMP::OK) { if(status != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return 1; return EXIT_FAILURE;
} }
else { else {
std::cout << "Parameterized with ARAP (POLY)!" << std::endl; std::cout << "Parameterized with ARAP (POLY)!" << std::endl;
@ -183,7 +183,7 @@ int main(int, char**)
in >> sm; in >> sm;
if(!in || num_vertices(sm) == 0) { if(!in || num_vertices(sm) == 0) {
std::cerr << "Problem loading the input data" << std::endl; std::cerr << "Problem loading the input data" << std::endl;
return 1; return EXIT_FAILURE;
} }
SM_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(sm).first; SM_halfedge_descriptor hd = CGAL::Polygon_mesh_processing::longest_border(sm).first;
@ -214,7 +214,7 @@ int main(int, char**)
if(status != SMP::OK) { if(status != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return 1; return EXIT_FAILURE;
} }
else { else {
std::cout << "Parameterized with Barycentric (SM)!" << std::endl; std::cout << "Parameterized with Barycentric (SM)!" << std::endl;
@ -235,7 +235,7 @@ int main(int, char**)
in >> sm; in >> sm;
if(!in || num_vertices(sm) == 0) { if(!in || num_vertices(sm) == 0) {
std::cerr << "Problem loading the input data" << std::endl; std::cerr << "Problem loading the input data" << std::endl;
return 1; return EXIT_FAILURE;
} }
// halfedge on the longest border // halfedge on the longest border
@ -269,7 +269,7 @@ int main(int, char**)
SMP::Error_code status = parameterizer.parameterize(sm, hd, uv_pm, vipm, vpm); SMP::Error_code status = parameterizer.parameterize(sm, hd, uv_pm, vipm, vpm);
if(status != SMP::OK) { if(status != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return 1; return EXIT_FAILURE;
} }
else { else {
std::cout << "Parameterized with ARAP (SM)!" << std::endl; std::cout << "Parameterized with ARAP (SM)!" << std::endl;
@ -286,7 +286,7 @@ int main(int, char**)
in >> pm; in >> pm;
if(!in || num_vertices(pm) == 0) { if(!in || num_vertices(pm) == 0) {
std::cerr << "Problem loading the input data" << std::endl; std::cerr << "Problem loading the input data" << std::endl;
return 1; return EXIT_FAILURE;
} }
const char* selection = "data/fandisk.dcm.selection.txt"; const char* selection = "data/fandisk.dcm.selection.txt";
@ -330,7 +330,7 @@ int main(int, char**)
if(status != SMP::OK) { if(status != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return 1; return EXIT_FAILURE;
} }
else { else {
std::cout << "Parameterized with DCM (SEAM POLY)!" << std::endl; std::cout << "Parameterized with DCM (SEAM POLY)!" << std::endl;
@ -351,7 +351,7 @@ int main(int, char**)
in >> sm; in >> sm;
if(!in || num_vertices(sm) == 0) { if(!in || num_vertices(sm) == 0) {
std::cerr << "Problem loading the input data" << std::endl; std::cerr << "Problem loading the input data" << std::endl;
return 1; return EXIT_FAILURE;
} }
const char* selection = "data/bear.dac.selection.txt"; const char* selection = "data/bear.dac.selection.txt";
@ -395,7 +395,7 @@ int main(int, char**)
SMP::Error_code status = parameterizer.parameterize(mesh, hd, uv_pm, vipm, vpm); SMP::Error_code status = parameterizer.parameterize(mesh, hd, uv_pm, vipm, vpm);
if(status != SMP::OK) { if(status != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return 1; return EXIT_FAILURE;
} }
else { else {
std::cout << "Parameterized with DAC (SEAM SM)!" << std::endl; std::cout << "Parameterized with DAC (SEAM SM)!" << std::endl;
@ -413,7 +413,7 @@ int main(int, char**)
in >> sm; in >> sm;
if(!in || num_vertices(sm) == 0) { if(!in || num_vertices(sm) == 0) {
std::cerr << "Problem loading the input data" << std::endl; std::cerr << "Problem loading the input data" << std::endl;
return 1; return EXIT_FAILURE;
} }
const char* cone_filename = "data/fandisk.orbifold.selection.txt"; const char* cone_filename = "data/fandisk.orbifold.selection.txt";
@ -471,7 +471,7 @@ int main(int, char**)
SMP::Error_code status = parameterizer.parameterize(mesh, hd, cmap, uvmap, vimap); SMP::Error_code status = parameterizer.parameterize(mesh, hd, cmap, uvmap, vimap);
if(status != SMP::OK) { if(status != SMP::OK) {
std::cout << "Encountered a problem: " << status << std::endl; std::cout << "Encountered a problem: " << status << std::endl;
return 1; return EXIT_FAILURE;
} }
else { else {
std::cout << "Parameterized with Orbifold (SEAM SM)!" << std::endl; std::cout << "Parameterized with Orbifold (SEAM SM)!" << std::endl;
@ -481,5 +481,5 @@ int main(int, char**)
std::cout << "Done!" << std::endl; std::cout << "Done!" << std::endl;
return 0; return EXIT_SUCCESS;
} }