MEPP2 Project
vertex_one_ring_geometric_laplacian.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  typedef typename GeometryTraits::Scalar Scalar;
59 
61  qv;
62  Operators::extract_1_ring_not_including_v< FaceGraph, GeometryTraits >(v, g, qv);
63 
64  Point geom_laplacian(0, 0, 0);
65  Scalar sum = 0;
66  Point center = get(pm, v); // works for all mesh structures
67  unsigned int cpt = 0;
68  typename std::vector< typename boost::graph_traits<
69  const FaceGraph >::vertex_descriptor >::const_iterator it(qv.begin()),
70  ite(qv.end());
71  for(; it != ite; ++it, ++cpt)
72  {
73  Point tmp = get(pm, *it); // works for all mesh structures
74  Scalar len = gt.length(center, tmp);
76  {
77  sum += 1./len ;
78  geom_laplacian = Point(gt.get_x(tmp)/len + gt.get_x(geom_laplacian),
79  gt.get_y(tmp)/len + gt.get_y(geom_laplacian),
80  gt.get_z(tmp)/len + gt.get_z(geom_laplacian));
81  }
82  }
83  if(cpt > 0)
84  {
85  return gt.add_pv(center,
86  gt.scalar_mult(gt.sub_p(Point(gt.get_x(geom_laplacian) / sum,
87  gt.get_y(geom_laplacian) / sum,
88  gt.get_z(geom_laplacian) / sum),
89  center),
90  smoothing_factor));
91  }
92  else
93  return get(pm, v);
94 }
95 
96 } // namespace Operators
97 } // 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_geometric_laplacian
boost::property_traits< PointMap >::value_type vertex_one_ring_geometric_laplacian(typename boost::graph_traits< FaceGraph >::vertex_descriptor v, const FaceGraph &g, const PointMap &pm, const typename GeometryTraits::Scalar smoothing_factor, const GeometryTraits &gt)
Geometric Laplacian of the vertex' one ring of vertex positions.
Definition: vertex_one_ring_geometric_laplacian.hpp:47
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33
FEVV::Filters::fabs
double fabs(const v_Curv< HalfedgeGraph > &input)
Definition: curvature.hpp:54
epsilon
const float epsilon
Definition: core.h:51
FEVV::DataStructures::AIF::AIFPoint
Definition: AIFProperties.h:31