MEPP2 Project
calculate_vertices_one_ring_barycenter.hpp
Go to the documentation of this file.
1 // Copyright (c) 2012-2019 University of Lyon and CNRS (France).
2 // All rights reserved.
3 //
4 // This file is part of MEPP2; you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as
6 // published by the Free Software Foundation; either version 3 of
7 // the License, or (at your option) any later version.
8 //
9 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
10 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 #pragma once
12 
13 #include <boost/graph/graph_traits.hpp>
14 #include <boost/graph/properties.hpp>
15 
18 
19 namespace FEVV {
20 namespace Filters {
21 
42 template< typename FaceGraph,
43  typename PointMap,
44  typename CentroidMap,
45  typename GeometryTraits = FEVV::Geometry_traits< FaceGraph > >
46 void
48  const FaceGraph &g,
49  const PointMap &pm, // const map (follows CGAL usage)
50  CentroidMap barycenters_pm, // modifiable map (follows CGAL usage)
51  const typename GeometryTraits::Scalar smoothing_factor,
52  const GeometryTraits &gt)
53 {
54  typedef boost::graph_traits< FaceGraph > GraphTraits;
55 
56  typedef typename GraphTraits::vertex_iterator vertex_iterator;
57  //typedef typename GraphTraits::vertex_descriptor vertex_descriptor;
58  //typedef typename boost::property_traits< PointMap >::value_type Point;
59  //typedef typename boost::property_traits< PointMap >::reference Reference;
60 
61  // this code works only for Polyhedron_3, Surface Mesh, OpenMesh and AIF
62  auto iterator_pair = vertices(g); // vertices() returns a vertex_iterator pair
63 
64  // VertexMap barycenters_pm(get(boost::vertex_index, g));
65  vertex_iterator vi = iterator_pair.first;
66  vertex_iterator vi_end = iterator_pair.second;
67  for(; vi != vi_end; ++vi)
68  {
69  barycenters_pm[*vi] =
71  PointMap,
72  GeometryTraits >(
73  *vi, g, pm, smoothing_factor, gt);
74  }
75 }
76 
77 template< typename FaceGraph,
78  typename PointMap,
79  typename CentroidMap,
80  typename GeometryTraits = FEVV::Geometry_traits< FaceGraph > >
81 void
83  const FaceGraph &g,
84  const PointMap &pm, // const map (follows CGAL usage)
85  CentroidMap barycenters_pm, // modifiable map (follows CGAL usage)
86  const typename GeometryTraits::Scalar smoothing_factor = 0.1)
87 
88 {
89  GeometryTraits gt(g);
91  PointMap,
92  CentroidMap,
93  GeometryTraits >(
94  g, pm, barycenters_pm, smoothing_factor, gt);
95 }
96 
97 } // namespace Filters
98 } // namespace FEVV
FEVV::DataStructures::AIF::vertices
std::pair< typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_iterator, typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_iterator > vertices(const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the iterator range of the vertices of the mesh.
Definition: Graph_traits_aif.h:172
vertex_one_ring_barycenter.hpp
FEVV::Geometry_traits
Refer to Geometry_traits_documentation_dummy for further documentation on provided types and algorith...
Definition: Geometry_traits.h:162
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
Geometry_traits.h
FEVV::Operators::vertex_one_ring_barycenter
boost::property_traits< PointMap >::value_type vertex_one_ring_barycenter(typename boost::graph_traits< FaceGraph >::vertex_descriptor v, const FaceGraph &g, const PointMap &pm, const typename GeometryTraits::Scalar smoothing_factor, const GeometryTraits &gt)
Barycenter of the vertex' one ring of vertex positions.
Definition: vertex_one_ring_barycenter.hpp:47
FEVV::Filters::calculate_vertices_one_ring_barycenter
void calculate_vertices_one_ring_barycenter(const FaceGraph &g, const PointMap &pm, CentroidMap barycenters_pm, const typename GeometryTraits::Scalar smoothing_factor, const GeometryTraits &gt)
Compute barycenters for all vertices and store them in barycenters_pm.
Definition: calculate_vertices_one_ring_barycenter.hpp:47