From f910d2ee6019b2fe9cd088ccf8fb6cb83715c755 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 15 Nov 2016 18:15:28 +0100 Subject: [PATCH] Misc minor changes --- .../Surface_mesh_parameterization/lscm.cpp | 4 +-- .../parameterization_tests.cpp | 2 +- .../seam_Polyhedron_3.cpp | 2 +- .../ARAP_parameterizer_3.h | 11 +++--- .../LSCM_parameterizer_3.h | 6 ++-- .../MVC_post_processor_3.h | 35 ++++++++++--------- .../internal/Bool_property_map.h | 2 +- .../internal/Containers_filler.h | 6 ++-- .../internal/validity.h | 20 +++++------ 9 files changed, 45 insertions(+), 43 deletions(-) diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp index 24251d90d5e..a137e7fb090 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/lscm.cpp @@ -65,7 +65,7 @@ int main(int argc, char * argv[]) std::istringstream iss(vertices); int p1, p2; bool two_vertices_given = false; - if(iss >> p1 >> p2){ + if(iss >> p1 >> p2) { two_vertices_given = true; } @@ -86,7 +86,7 @@ int main(int argc, char * argv[]) typedef SMP::Two_vertices_parameterizer_3 Border_parameterizer; typedef SMP::LSCM_parameterizer_3 Parameterizer; - if(two_vertices_given){ + if(two_vertices_given) { SM_halfedge_descriptor smhp1 = halfedge(SM_vertex_descriptor(p1), sm); vertex_descriptor vp1 = target(halfedge_descriptor(smhp1), mesh); diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/parameterization_tests.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/parameterization_tests.cpp index 94e5241611c..9aca13e54d2 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/parameterization_tests.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/parameterization_tests.cpp @@ -123,7 +123,7 @@ int main(int argc, char * argv[]) // std::ifstream in((argc>1)?argv[1]:"../data/mushroom_big_hole.off"); // std::ifstream in((argc>1)?argv[1]:"../data/mushroom_hole_1.off"); - if(!in){ + if(!in) { std::cerr << "Problem loading the input data" << std::endl; return 1; } diff --git a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/seam_Polyhedron_3.cpp b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/seam_Polyhedron_3.cpp index a9f50e531b9..21acd72e520 100644 --- a/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/seam_Polyhedron_3.cpp +++ b/Surface_mesh_parameterization/examples/Surface_mesh_parameterization/seam_Polyhedron_3.cpp @@ -45,7 +45,7 @@ int main(int argc, char * argv[]) PolyMesh sm; 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; return 1; } diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/ARAP_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/ARAP_parameterizer_3.h index 54ae7561dd8..1f8a83e9a62 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/ARAP_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/ARAP_parameterizer_3.h @@ -59,15 +59,16 @@ /// \file ARAP_parameterizer_3.h -// @todo Determine the proper name of this file // @todo Handle the case cot = 0 with a local parameterization aligned with the axes // (this produces C2=0 which is problematic to compute a & b) -// @todo Add to the polyhedron demo +// @todo test ARAP + SEAM // @todo Add distortion measures -// @todo is_one_to_one mapping functions in all parameterizers +// @todo non-simple border in MVC_post_processor +// @todo clean OpenNL from LSCM +// @todo Fix PMP::border_halfedges() (add a "!") + +// @todo look up the matlab code -// @todo The two systems A Xu = Bu and A Xv = BV could be merged in one system -// using complex numbers? // @todo Parallelize the local phase? namespace CGAL { diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/LSCM_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/LSCM_parameterizer_3.h index 10b5501db10..02bf42411ae 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/LSCM_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/LSCM_parameterizer_3.h @@ -219,7 +219,7 @@ public: // Fill the matrix for the other vertices solver.begin_system(); - BOOST_FOREACH(face_descriptor fd, ccfaces){ + BOOST_FOREACH(face_descriptor fd, ccfaces) { // Create two lines in the linear system per triangle (one for u, one for v) status = setup_triangle_relations(solver, mesh, fd, vimap); if (status != OK) @@ -238,7 +238,7 @@ public: // Copy X coordinates into the (u,v) pair of each vertex //set_mesh_uv_from_system(mesh, solver, uvmap); - BOOST_FOREACH(vertex_descriptor vd, ccvertices){ + BOOST_FOREACH(vertex_descriptor vd, ccvertices) { int index = get(vimap,vd); NT u = solver.variable(2 * index).value(); NT v = solver.variable(2 * index + 1).value(); @@ -262,7 +262,7 @@ private: VertexIndexMap vimap, VertexParameterizedMap vpmap) const { - BOOST_FOREACH(vertex_descriptor v, ccvertices){ + BOOST_FOREACH(vertex_descriptor v, ccvertices) { // Get vertex index in sparse linear system int index = get(vimap, v); diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/MVC_post_processor_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/MVC_post_processor_3.h index ee89b54ac39..38434911189 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/MVC_post_processor_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/MVC_post_processor_3.h @@ -143,12 +143,12 @@ private: std::ofstream out("constrained_triangulation_exterior.txt"); typename CT::Finite_faces_iterator fit = ct.finite_faces_begin(), fend = ct.finite_faces_end(); - for(; fit!=fend; ++fit){ + for(; fit!=fend; ++fit) { if(fit->info() != -1) // only output exterior (finite) faces continue; out << "4 "; - for(std::size_t i=0; i<4; ++i){ + for(std::size_t i=0; i<4; ++i) { out << fit->vertex(i%3)->point() << " 0 "; } out << '\n'; @@ -165,7 +165,7 @@ private: VertexUVMap uvmap, const VertexIndexMap vimap) const { - BOOST_FOREACH(vertex_descriptor vd, vertices){ + BOOST_FOREACH(vertex_descriptor vd, vertices) { int index = get(vimap, vd); NT u = Xu(index); NT v = Xv(index); @@ -197,8 +197,8 @@ private: { // @fixme unefficient: use sweep line algorithms instead of brute force - BOOST_FOREACH(halfedge_descriptor hd_1, halfedges_around_face(bhd, mesh)){ - BOOST_FOREACH(halfedge_descriptor hd_2, halfedges_around_face(bhd, mesh)){ + BOOST_FOREACH(halfedge_descriptor hd_1, halfedges_around_face(bhd, mesh)) { + BOOST_FOREACH(halfedge_descriptor hd_2, halfedges_around_face(bhd, mesh)) { if(hd_1 == hd_2 || // equality next(hd_1, mesh) == hd_2 || next(hd_2, mesh) == hd_1) // adjacency continue; @@ -206,7 +206,7 @@ private: if(CGAL::do_intersect(Segment_2(get(uvmap, source(hd_1, mesh)), get(uvmap, target(hd_1, mesh))), Segment_2(get(uvmap, source(hd_2, mesh)), - get(uvmap, target(hd_2, mesh))))){ + get(uvmap, target(hd_2, mesh))))) { std::ofstream out("non-simple.txt"); // polygon lines out << "2 " << get(uvmap, source(hd_1, mesh)) << " 0 " << get(uvmap, target(hd_1, mesh)) << " 0" << std::endl; @@ -268,7 +268,7 @@ private: // Since the border is closed and we are interest in triangles that are outside // of the border, we actually only need to insert points on the border - BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_face(bhd, mesh)){ + BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_face(bhd, mesh)) { vertex_descriptor s = source(hd, mesh); Point_2 sp = get(uvmap, s); @@ -278,7 +278,7 @@ private: } // Insert constraints (the border) - BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_face(bhd, mesh)){ + BOOST_FOREACH(halfedge_descriptor hd, halfedges_around_face(bhd, mesh)) { vertex_descriptor s = source(hd, mesh), t = target(hd, mesh); Point_2 sp = get(uvmap, s), tp = get(uvmap, t); @@ -319,7 +319,7 @@ private: continue; bool is_edge_constrained = ct.is_constrained(Edge(fc, index_of_inf_vertex)); - if(!is_edge_constrained){ + if(!is_edge_constrained) { // edge is not constrained so the face is part of the convex hull but // geometrically outside of 'mesh' mirror_face->info() = -1; // outside @@ -373,7 +373,7 @@ private: // For flipped triangles, the connectivity is inversed and thus the angle // computed by the previous function is not the one we need. Instead, // we need the explementary angle. - if(angle > CGAL_PI){ // flipped triangle + if(angle > CGAL_PI) { // flipped triangle angle = 2 * CGAL_PI - angle; } NT weight = std::tan(0.5 * angle); @@ -579,7 +579,7 @@ private: // Loop over the faces of 'mesh' std::cout << "add from mesh" << std::endl; - BOOST_FOREACH(face_descriptor fd, faces){ + BOOST_FOREACH(face_descriptor fd, faces) { fill_linear_system_matrix_mvc_from_mesh_face(mesh, fd, uvmap, vimap, vpmap, A); } @@ -596,10 +596,10 @@ private: const VertexParameterizedMap vpmap, Vector& Bu, Vector& Bv) const { - BOOST_FOREACH(vertex_descriptor vd, vertices){ + BOOST_FOREACH(vertex_descriptor vd, vertices) { int index = get(vimap, vd); Point_2 uv = get(uvmap, vd); - if(!get(vpmap, vd)){ // not yet parameterized + if(!get(vpmap, vd)) { // not yet parameterized Bu[index] = 0.; // might not be needed Bv[index] = 0.; } else { // fixed vertices @@ -618,7 +618,7 @@ private: NT Du, Dv; if(!get_linear_algebra_traits().linear_solver(A, Bu, Xu, Du) || - !get_linear_algebra_traits().linear_solver(A, Bv, Xv, Dv)){ + !get_linear_algebra_traits().linear_solver(A, Bv, Xv, Dv)) { status = ERROR_CANNOT_SOLVE_LINEAR_SYSTEM; } @@ -677,8 +677,8 @@ private: CGAL_postcondition_code ( // make sure that the constrained vertices have not been moved - BOOST_FOREACH(vertex_descriptor vd, vertices){ - if(get(vpmap, vd)){ + BOOST_FOREACH(vertex_descriptor vd, vertices) { + if(get(vpmap, vd)) { int index = get(vimap, vd); CGAL_postcondition(std::abs(Xu[index] - Bu[index] ) < 1e-10); CGAL_postcondition(std::abs(Xv[index] - Bv[index] ) < 1e-10); @@ -708,7 +708,7 @@ public: const bool is_param_border_simple = is_polygon_simple(mesh, bhd, uvmap); // Not sure how to handle non-simple yet @fixme - if(!is_param_border_simple){ + if(!is_param_border_simple) { std::cout << "Border is not simple!" << std::endl; return ERROR_NON_CONVEX_BORDER; } @@ -726,6 +726,7 @@ public: // Run the MVC parameterize_convex_hull_with_MVC(mesh, vertices, faces, ct, uvmap, vimap, vpmap); + std::cout << "End of post processing: Ok" << std::endl; return OK; } diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Bool_property_map.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Bool_property_map.h index 9fff8557eb8..7979f27eb26 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Bool_property_map.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Bool_property_map.h @@ -49,7 +49,7 @@ public: friend void put(const Self& pm, key_type& k, const value_type& v) { - if(v){ + if(v) { pm.m_s->insert(k); } else { pm.m_s->erase(k); diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Containers_filler.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Containers_filler.h index 24cccefc221..d62264fa69a 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Containers_filler.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Containers_filler.h @@ -65,7 +65,7 @@ public: void operator()(face_descriptor fd) { halfedge_descriptor hd = halfedge(fd, mesh); - BOOST_FOREACH(vertex_descriptor vd, vertices_around_face(hd, mesh)){ + BOOST_FOREACH(vertex_descriptor vd, vertices_around_face(hd, mesh)) { vertices.insert(vd); } @@ -87,11 +87,11 @@ struct Index_map_filler void operator()(const face_descriptor& fd) { BOOST_FOREACH(vertex_descriptor vd, - vertices_around_face(halfedge(fd, mesh), mesh)){ + vertices_around_face(halfedge(fd, mesh), mesh)) { typename Map::iterator it; bool new_element; boost::tie(it,new_element) = map->insert(std::make_pair(vd,1)); - if(new_element){ + if(new_element) { it->second = index++; } } diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/validity.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/validity.h index 588e7dd534a..d9edbe901df 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/validity.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/validity.h @@ -91,7 +91,7 @@ bool has_flips(const TriangleMesh& mesh, Vector_3 normal = CGAL::cross_product(v01_3D, v02_3D); // Check that all normals are oriented the same way - if (!is_normal_set){ + if (!is_normal_set) { first_triangle_normal = normal; is_normal_set = true; } else { @@ -140,7 +140,7 @@ public: // check for shared egde if(face(opposite(h, mesh), mesh) == b->info() || face(opposite(prev(h, mesh), mesh), mesh) == b->info() || - face(opposite(next(h, mesh), mesh), mesh) == b->info()){ + face(opposite(next(h, mesh), mesh), mesh) == b->info()) { // shared edge // intersection if the orientations are not identical @@ -149,7 +149,7 @@ public: get(uvmap, source(h, mesh))) != CGAL::orientation(get(uvmap, target(g, mesh)), get(uvmap, target(next(g, mesh), mesh)), - get(uvmap, source(g, mesh)))){ + get(uvmap, source(g, mesh)))) { ++self_intersection_counter; } return; @@ -172,7 +172,7 @@ public: if(target(h, mesh) == target(next(next(g, mesh), mesh), mesh)) hd = next(next(g, mesh), mesh); - if(hd == halfedge_descriptor()){ + if(hd == halfedge_descriptor()) { h = next(h, mesh); if(target(h, mesh) == target(g, mesh)) hd = g; @@ -180,7 +180,7 @@ public: hd = next(g, mesh); if(target(h, mesh) == target(next(next(g, mesh), mesh), mesh)) hd = next(next(g, mesh), mesh); - if(hd == halfedge_descriptor()){ + if(hd == halfedge_descriptor()) { h = next(h, mesh); if(target(h, mesh) == target(g, mesh)) hd = g; @@ -191,7 +191,7 @@ public: } } - if(hd != halfedge_descriptor()){ + if(hd != halfedge_descriptor()) { // shared vertex CGAL_assertion(target(h, mesh) == target(hd, mesh)); @@ -208,9 +208,9 @@ public: Segment_2 s2 = segment_functor(get(uvmap, target(next(hd, mesh), mesh)), get(uvmap, target(next(next(hd, mesh), mesh), mesh))); - if(do_intersect_2_functor(t1, s2)){ + if(do_intersect_2_functor(t1, s2)) { ++self_intersection_counter; - } else if(do_intersect_2_functor(t2, s1)){ + } else if(do_intersect_2_functor(t2, s1)) { ++self_intersection_counter; } return; @@ -223,7 +223,7 @@ public: Triangle_2 t2 = triangle_functor(get(uvmap, target(g, mesh)), get(uvmap, target(next(g, mesh), mesh)), get(uvmap, target(next(next(g, mesh), mesh), mesh))); - if(do_intersect_2_functor(t1, t2)){ + if(do_intersect_2_functor(t1, t2)) { ++self_intersection_counter; } } @@ -262,7 +262,7 @@ bool is_one_to_one_mapping(const TriangleMesh& mesh, // Create the corresponding vector of bounding boxes std::vector boxes; - BOOST_FOREACH(face_descriptor fd, faces){ + BOOST_FOREACH(face_descriptor fd, faces) { halfedge_descriptor hd = halfedge(fd, mesh); vertex_descriptor vd0 = target(hd, mesh); vertex_descriptor vd1 = target(next(hd, mesh), mesh);