From adb03e8ee9da22e7ea9221ab59963bb7ba5898e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Fri, 9 Dec 2016 11:53:13 +0100 Subject: [PATCH] Moved orbifold type-related functions to the corresponding helper file --- .../Orbital_Tutte_parameterizer_3.h | 89 ++----------------- .../internal/orbital_cone_helper.h | 70 +++++++++++++++ 2 files changed, 75 insertions(+), 84 deletions(-) diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Orbital_Tutte_parameterizer_3.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Orbital_Tutte_parameterizer_3.h index 8554d1a9827..130dc644667 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Orbital_Tutte_parameterizer_3.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/Orbital_Tutte_parameterizer_3.h @@ -68,36 +68,12 @@ namespace CGAL { namespace Surface_mesh_parameterization { -enum Orbifold_type -{ - Square = 0, - Diamond, - Triangle, - Parallelogram -}; - enum Weight_type { Cotangent = 0, Mean_value }; -const char* get_orbifold_type(int orb_type) -{ - // Messages corresponding to Error_code list above. Must be kept in sync! - static const char* type[Parallelogram+1] = { - "Square", - "Diamond", - "Triangle", - "Parallelogram" - }; - - if(orb_type > Parallelogram || orb_type < 0) - return "Unknown orbifold type"; - else - return type[orb_type]; -} - template < typename TriangleMesh, @@ -175,65 +151,7 @@ private: return OK; } - // Orbifold type functions - std::vector get_cones_parameterized_coordinates() const - { - std::vector tcoords; - if(orb_type == Square) { - tcoords.push_back(Point_2(-1, -1)); - tcoords.push_back(Point_2(1, 1)); - } else if(orb_type == Parallelogram) { - tcoords.push_back(Point_2(0, -0.5)); - tcoords.push_back(Point_2(-1, -0.5)); - tcoords.push_back(Point_2(0, 0.5)); - } else { // if(orb_type == Diamond || orb_type == Triangle) - tcoords.push_back(Point_2(-1, 1)); - tcoords.push_back(Point_2(-1, -1)); - } - return tcoords; - } - - /// Angles are minus as we go around the seam border in a counterclockwise manner - std::vector get_angles_at_cones() const - { - std::vector angs; - if(orb_type == Square) { - angs.push_back(4.); - angs.push_back(4.); - } else if(orb_type == Diamond) { - angs.push_back(3.); - angs.push_back(3.); - } else if(orb_type == Triangle) { - angs.push_back(6.); - angs.push_back(2.); - } else { // if(orb_type == Parallelogram) - angs.push_back(2); - angs.push_back(1); - angs.push_back(2); - } - return angs; - } - // Linear system - template - void find_start_cone(const ConeMap& cmap, - VertexIndexMap vimap, - vertex_descriptor& cone, - int& cone_index) const - { - typename ConeMap::const_iterator cmit = cmap.begin(), cend = cmap.end(); - for(; cmit!=cend; ++cmit) { - if(cmit->second != First_unique_cone) - continue; - - cone = cmit->first; - cone_index = get(vimap, cone); - - return; - } - } - /// Compute the number of linear constraints in the system. int number_of_linear_constraints(const TriangleMesh& mesh) const { @@ -360,10 +278,13 @@ private: Matrix& A, Vector& B) const { // positions of the cones in the plane - const std::vector& tcoords = get_cones_parameterized_coordinates(); + typedef std::vector Point_container; + const Point_container& tcoords = + get_cones_parameterized_coordinates(orb_type); // angles at the cones - const std::vector& angs = get_angles_at_cones(); + typedef std::vector Angle_container; + const Angle_container& angs = get_angles_at_cones(orb_type); // the index of the line in A that we are filling next int current_line_id_in_A = 0.; diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/orbital_cone_helper.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/orbital_cone_helper.h index 921e6d1d341..ad3062087b1 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/orbital_cone_helper.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/orbital_cone_helper.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -47,6 +48,75 @@ enum Cone_type Duplicated_cone }; +enum Orbifold_type +{ + Square = 0, + Diamond, + Triangle, + Parallelogram +}; + +const char* get_orbifold_type(int orb_type) +{ + // Messages corresponding to Error_code list above. Must be kept in sync! + static const char* type[Parallelogram+1] = { + "Square", + "Diamond", + "Triangle", + "Parallelogram" + }; + + if(orb_type > Parallelogram || orb_type < 0) + return "Unknown orbifold type"; + else + return type[orb_type]; +} + +// Orbifold type functions +template +Point_container get_cones_parameterized_coordinates(const Orbifold_type orb_type) +{ + typedef typename Point_container::value_type Point; + + Point_container tcoords; + if(orb_type == Square) { + tcoords.push_back(Point(-1, -1)); + tcoords.push_back(Point(1, 1)); + } else if(orb_type == Parallelogram) { + tcoords.push_back(Point(0, -0.5)); + tcoords.push_back(Point(-1, -0.5)); + tcoords.push_back(Point(0, 0.5)); + } else { // if(orb_type == Diamond || orb_type == Triangle) + tcoords.push_back(Point(-1, 1)); + tcoords.push_back(Point(-1, -1)); + } + + return tcoords; +} + +/// Angles are minus as we go around the seam border in a counterclockwise manner +template +NT_container get_angles_at_cones(const Orbifold_type orb_type) +{ + NT_container angs; + if(orb_type == Square) { + angs.push_back(4.); + angs.push_back(4.); + } else if(orb_type == Diamond) { + angs.push_back(3.); + angs.push_back(3.); + } else if(orb_type == Triangle) { + angs.push_back(6.); + angs.push_back(2.); + } else { // if(orb_type == Parallelogram) + angs.push_back(2); + angs.push_back(1); + angs.push_back(2); + } + + return angs; +} + namespace internal { /// Read the cones from the input file.