From 20bcc9233cd2360c4881d284435f7f2c6335a36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 15 Nov 2016 14:27:42 +0100 Subject: [PATCH] Improved the initial parameterization of ARAP and gave bool_pmap its own header --- .../ARAP_parameterizer_3.h | 19 +++-- .../internal/Bool_property_map.h | 72 +++++++++++++++++++ .../parameterize.h | 39 +--------- 3 files changed, 88 insertions(+), 42 deletions(-) create mode 100644 Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Bool_property_map.h 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 33218392d30..54ae7561dd8 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 @@ -21,6 +21,7 @@ #ifndef CGAL_SURFACE_MESH_PARAMETERIZATION_ARAP_PARAMETERIZER_3_H #define CGAL_SURFACE_MESH_PARAMETERIZATION_ARAP_PARAMETERIZER_3_H +#include #include #include #include @@ -277,10 +278,12 @@ private: } /// Initialize the UV values with a first parameterization of the input. - template + template Error_code compute_initial_uv_map(TriangleMesh& mesh, halfedge_descriptor bhd, - VertexUVMap uvmap) const + VertexUVMap uvmap, + VertexIndexMap vimap) const { Error_code status; @@ -291,14 +294,20 @@ private: return status; } + // temporary vpmap since we do not need it in the future + boost::unordered_set vs; + internal::Bool_property_map > vpmap(vs); + // According to the paper, MVC is better for single border and LSCM is better // when there are multiple borders if(number_of_borders == 1) { typedef Mean_value_coordinates_parameterizer_3 MVC_parameterizer; - status = CGAL::Surface_mesh_parameterization::parameterize(mesh, MVC_parameterizer(), bhd, uvmap); + MVC_parameterizer mvc_parameterizer; + status = mvc_parameterizer.parameterize(mesh, bhd, uvmap, vimap, vpmap); } else { typedef LSCM_parameterizer_3 LSCM_parameterizer; - status = CGAL::Surface_mesh_parameterization::parameterize(mesh, LSCM_parameterizer(), bhd, uvmap); + LSCM_parameterizer lscm_parameterizer; + status = lscm_parameterizer.parameterize(mesh, bhd, uvmap, vimap, vpmap); } std::cout << "Computed initial parameterization" << std::endl; @@ -1290,7 +1299,7 @@ public: Lt_map ltmap(lt_hm); // will be filled in 'compute_optimal_Lt_matrices()' // Compute the initial parameterization of the mesh - status = compute_initial_uv_map(mesh, bhd, uvmap); + status = compute_initial_uv_map(mesh, bhd, uvmap, vimap); output_uvmap("ARAP_initial_param.off", mesh, vertices, faces, uvmap, vimap); if(status != OK) return status; 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 new file mode 100644 index 00000000000..9fff8557eb8 --- /dev/null +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/internal/Bool_property_map.h @@ -0,0 +1,72 @@ +// Copyright (c) 2016 GeometryFactory (France). +// All rights reserved. +// +// This file is part of CGAL (www.cgal.org). +// You can redistribute it and/or modify it under the terms of the GNU +// General Public License as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// Licensees holding a valid commercial license may use this file in +// accordance with the commercial license agreement provided with the software. +// +// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +// +// $URL$ +// $Id$ +// +// +// Author(s) : + +#ifndef CGAL_SURFACE_MESH_PARAMETERIZATION_INTERNAL_BOOL_PROPERTY_MAP_H +#define CGAL_SURFACE_MESH_PARAMETERIZATION_INTERNAL_BOOL_PROPERTY_MAP_H + +#include +#include + +namespace CGAL { + +namespace Surface_mesh_parameterization { + +namespace internal { + +template +class Bool_property_map +{ + typedef Set S; + typedef Bool_property_map Self; + +public: + typedef typename Set::key_type key_type; + typedef bool value_type; + typedef bool reference; + typedef boost::read_write_property_map_tag category; + + friend value_type get(const Self& pm, const key_type& k) + { + return pm.m_s->find(k) != pm.m_s->end(); + } + + friend void put(const Self& pm, key_type& k, const value_type& v) + { + if(v){ + pm.m_s->insert(k); + } else { + pm.m_s->erase(k); + } + } + + Bool_property_map() : m_s(0) { } + Bool_property_map(S& s) : m_s(&s) { } + +private: + S* m_s; +}; + +} // namespace internal + +} // namespace Surface_mesh_parameterization + +} // namespace CGAL + +#endif // CGAL_SURFACE_MESH_PARAMETERIZATION_INTERNAL_BOOL_PROPERTY_MAP_H diff --git a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/parameterize.h b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/parameterize.h index c15f3f166ea..d9b58a4d0df 100644 --- a/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/parameterize.h +++ b/Surface_mesh_parameterization/include/CGAL/Surface_mesh_parameterization/parameterize.h @@ -23,6 +23,8 @@ #include +#include + #include #include @@ -39,43 +41,6 @@ namespace CGAL { namespace Surface_mesh_parameterization { -namespace internal { - -template -class Bool_property_map -{ - typedef Set S; - typedef Bool_property_map Self; - -public: - typedef typename Set::key_type key_type; - typedef bool value_type; - typedef bool reference; - typedef boost::read_write_property_map_tag category; - - friend value_type get(const Self& pm, const key_type& k) - { - return pm.m_s->find(k) != pm.m_s->end(); - } - - friend void put(const Self& pm, key_type& k, const value_type& v) - { - if(v){ - pm.m_s->insert(k); - } else { - pm.m_s->erase(k); - } - } - - Bool_property_map() : m_s(0) { } - Bool_property_map(S& s) : m_s(&s) { } - -private: - S* m_s; -}; - -} // namespace internal - /// \ingroup PkgSurfaceParameterizationMainFunction /// /// Compute a one-to-one mapping from a 3D triangle surface `mesh` to a