MEPP2 Project
vertex_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 #include <vector>
16 
19 
20 
21 namespace FEVV {
22 namespace Operators {
23 
43 template< typename FaceGraph,
44  typename PointMap,
45  typename GeometryTraits = FEVV::Geometry_traits< FaceGraph > >
46 typename boost::property_traits< PointMap >::value_type
49  const FaceGraph &g,
50  const PointMap &pm,
51  const typename GeometryTraits::Scalar smoothing_factor,
52  const GeometryTraits &gt)
53 {
54  typedef typename boost::property_traits< PointMap >::value_type
55  Point; // this Point type cannot be const because the center Point must be
56  // modifiable
57  //typedef typename boost::property_traits< PointMap >::reference Reference;
58 
60  qv;
61  Operators::extract_1_ring_not_including_v< FaceGraph, GeometryTraits >(v, g, qv);
62 
63  Point center(0, 0, 0);
64  unsigned int cpt = 0;
65  typename std::vector< typename boost::graph_traits<
66  const FaceGraph >::vertex_descriptor >::const_iterator it(qv.begin()),
67  ite(qv.end());
68  for(; it != ite; ++it, ++cpt)
69  {
70  Point tmp = get(pm, *it); // works for all mesh structures
71  center = Point(gt.get_x(tmp) + gt.get_x(center),
72  gt.get_y(tmp) + gt.get_y(center),
73  gt.get_z(tmp) + gt.get_z(center));
74  }
75  if(cpt > 0)
76  {
77  return gt.add_pv(get(pm, v),
78  gt.scalar_mult(gt.sub_p(Point(gt.get_x(center) / cpt,
79  gt.get_y(center) / cpt,
80  gt.get_z(center) / cpt),
81  get(pm, v)),
82  smoothing_factor));
83  }
84  else
85  return get(pm, v);
86 }
87 
88 } // namespace Operators
89 } // namespace FEVV
FEVV::Geometry_traits
Refer to Geometry_traits_documentation_dummy for further documentation on provided types and algorith...
Definition: Geometry_traits.h:162
Point
AIFMesh::Point Point
Definition: Graph_properties_aif.h:21
k_ring.hpp
FEVV::get
FEVV::PCLPointCloudPointMap::value_type get(const FEVV::PCLPointCloudPointMap &pm, FEVV::PCLPointCloudPointMap::key_type key)
Specialization of get(point_map, key) for PCLPointCloud.
Definition: Graph_properties_pcl_point_cloud.h:117
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
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33
FEVV::DataStructures::AIF::AIFPoint
Definition: AIFProperties.h:31