MEPP2 Project
calculate_face_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 {
35 template< typename HalfedgeGraph,
36  typename PointMap,
37  typename FaceNormalMap,
38  typename GeometryTraits >
39 void
40 calculate_face_normals(const HalfedgeGraph &g,
41  const PointMap &pm,
42  FaceNormalMap fnm,
43  const GeometryTraits &gt)
44 {
45  typedef typename GeometryTraits::Vector Vector;
46 
47  typedef boost::graph_traits< HalfedgeGraph > GraphTraits;
48  typedef typename GraphTraits::face_iterator face_iterator;
49 
50  face_iterator fb, fe;
51  for(boost::tie(fb, fe) = faces(g); fb != fe; ++fb)
52  {
53  Vector vec = FEVV::Operators::
54  calculate_face_normal< HalfedgeGraph, PointMap, GeometryTraits >(
55  *fb, g, pm, gt);
56  put(fnm, *fb, vec);
57  }
58 }
59 
60 
68 template< typename HalfedgeGraph,
69  typename PointMap,
70  typename FaceNormalMap,
71  typename GeometryTraits = FEVV::Geometry_traits< HalfedgeGraph > >
72 void
73 calculate_face_normals(const HalfedgeGraph &g,
74  const PointMap &pm,
75  FaceNormalMap fnm)
76 {
77  GeometryTraits gt(g);
78  return calculate_face_normals< HalfedgeGraph,
79  PointMap,
80  FaceNormalMap,
81  GeometryTraits >(g, pm, fnm, gt);
82 }
83 
84 } // namespace Filters
85 } // namespace FEVV
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
FEVV::DataStructures::AIF::faces
std::pair< typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::face_iterator, typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::face_iterator > faces(const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns an iterator range over all faces of the mesh.
Definition: Graph_traits_aif.h:679
Geometry_traits.h
FEVV::Filters::calculate_face_normals
void calculate_face_normals(const HalfedgeGraph &g, const PointMap &pm, FaceNormalMap fnm, const GeometryTraits &gt)
Calculate "some" normal of all the faces of the considered mesh and populate the argument provided Fa...
Definition: calculate_face_normals.hpp:40
FEVV::DataStructures::AIF::AIFVector
Definition: AIFProperties.h:173
calculate_face_normal.hpp
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