MEPP2 Project
calculate_vertex_normals.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>
17 
18 namespace FEVV {
19 namespace Filters {
20 
35 template< typename HalfedgeGraph,
36  typename PointMap,
37  typename FaceNormalMap,
38  typename VertexNormalMap,
39  typename GeometryTraits >
40 void
41 calculate_vertex_normals(const HalfedgeGraph &g,
42  const PointMap &pm,
43  const FaceNormalMap &fnm,
44  VertexNormalMap vnm,
45  const GeometryTraits &gt)
46 {
47  typedef typename GeometryTraits::Vector Vector;
48 
49  typedef boost::graph_traits< HalfedgeGraph > GraphTraits;
50  typedef typename GraphTraits::vertex_iterator vertex_iterator;
51 
52  vertex_iterator vb, ve;
53  for(boost::tie(vb, ve) = vertices(g); vb != ve; ++vb)
54  {
56  PointMap,
57  FaceNormalMap,
58  GeometryTraits >(
59  *vb, g, pm, fnm, gt);
60  put(vnm, *vb, vec);
61  }
62 }
63 
78 template< typename HalfedgeGraph,
79  typename PointMap,
80  typename FaceNormalMap,
81  typename VertexNormalMap,
82  typename GeometryTraits = FEVV::Geometry_traits< HalfedgeGraph > >
83 void
84 calculate_vertex_normals(const HalfedgeGraph &g,
85  const PointMap &pm,
86  const FaceNormalMap &fnm,
87  VertexNormalMap vnm)
88 {
89  GeometryTraits gt(g);
90  calculate_vertex_normals< HalfedgeGraph,
91  PointMap,
92  FaceNormalMap,
93  VertexNormalMap,
94  GeometryTraits >(g, pm, fnm, vnm, 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
Vector
AIFMesh::Vector Vector
Definition: Graph_properties_aif.h:22
FEVV::Geometry_traits< HalfedgeGraph >
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
Geometry_traits.h
FEVV::DataStructures::AIF::AIFVector
Definition: AIFProperties.h:173
FEVV::Filters::calculate_vertex_normals
void calculate_vertex_normals(const HalfedgeGraph &g, const PointMap &pm, const FaceNormalMap &fnm, VertexNormalMap vnm, const GeometryTraits &gt)
Compute the respectice vertex normal for all the vertices of the considered mesh and populate the arg...
Definition: calculate_vertex_normals.hpp:41
FEVV::put
void put(FEVV::PCLPointCloudPointMap &pm, FEVV::PCLPointCloudPointMap::key_type key, const FEVV::PCLPointCloudPointMap::value_type &value)
Specialization of put(point_map, key, value) for PCLPointCloud.
Definition: Graph_properties_pcl_point_cloud.h:126
FEVV::Operators::calculate_vertex_normal
GeometryTraits::Vector calculate_vertex_normal(typename boost::graph_traits< HalfedgeGraph >::vertex_descriptor v, const HalfedgeGraph &g, const PointMap &pm, const GeometryTraits &gt)
Computes the unit normal at considered vertex v as the average of the normals of incident faces.
Definition: calculate_vertex_normal.hpp:43
calculate_vertex_normal.hpp