Improved the initial parameterization of ARAP

and gave bool_pmap its own header
This commit is contained in:
Mael Rouxel-Labbé 2016-11-15 14:27:42 +01:00
parent 8e77c99653
commit 20bcc9233c
3 changed files with 88 additions and 42 deletions

View File

@ -21,6 +21,7 @@
#ifndef CGAL_SURFACE_MESH_PARAMETERIZATION_ARAP_PARAMETERIZER_3_H
#define CGAL_SURFACE_MESH_PARAMETERIZATION_ARAP_PARAMETERIZER_3_H
#include <CGAL/Surface_mesh_parameterization/internal/Bool_property_map.h>
#include <CGAL/Surface_mesh_parameterization/internal/Containers_filler.h>
#include <CGAL/Surface_mesh_parameterization/internal/kernel_traits.h>
#include <CGAL/Surface_mesh_parameterization/internal/validity.h>
@ -277,10 +278,12 @@ private:
}
/// Initialize the UV values with a first parameterization of the input.
template <typename VertexUVMap>
template <typename VertexUVMap,
typename VertexIndexMap>
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<vertex_descriptor> vs;
internal::Bool_property_map<boost::unordered_set<vertex_descriptor> > 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<TriangleMesh> 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<TriangleMesh, Border_param> 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;

View File

@ -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 <CGAL/boost/graph/properties.h>
#include <CGAL/Kernel_traits.h>
namespace CGAL {
namespace Surface_mesh_parameterization {
namespace internal {
template <typename Set>
class Bool_property_map
{
typedef Set S;
typedef Bool_property_map<S> 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

View File

@ -23,6 +23,8 @@
#include <CGAL/license/Surface_mesh_parameterization.h>
#include <CGAL/Surface_mesh_parameterization/internal/Bool_property_map.h>
#include <CGAL/Surface_mesh_parameterization/Error_code.h>
#include <CGAL/Surface_mesh_parameterization/Mean_value_coordinates_parameterizer_3.h>
@ -39,43 +41,6 @@ namespace CGAL {
namespace Surface_mesh_parameterization {
namespace internal {
template <typename Set>
class Bool_property_map
{
typedef Set S;
typedef Bool_property_map<S> 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