MEPP2 Project
calculate_halfedges_tangent.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 
18 
19 
20 namespace FEVV {
21 namespace Filters {
22 
33 template< typename HalfedgeGraph,
34  typename PointMap,
35  typename HalfedgeUVMap,
36  typename VertexTangentMap >
37 void
38 calculate_halfedges_tangent(const HalfedgeGraph &g,
39  const PointMap &pm,
40  const HalfedgeUVMap &hum, // provided halfedge UVs
41  VertexTangentMap &vtm)
42 {
43  using GeometryTraits = FEVV::Geometry_traits< HalfedgeGraph >;
44  using Vector = typename GeometryTraits::Vector;
45 
46  using GraphTraits = typename boost::graph_traits< HalfedgeGraph >;
47  using face_iterator = typename GraphTraits::face_iterator;
48 
49  using halfedge_descriptor =
50  typename boost::graph_traits< HalfedgeGraph >::halfedge_descriptor;
51 
52  const GeometryTraits gt(g);
53 
54  face_iterator fb, fe;
55  for(boost::tie(fb, fe) = faces(g); fb != fe; ++fb)
56  {
57  halfedge_descriptor half_edge = halfedge(*fb, g);
58 
59  const Vector uv1 = get(hum, half_edge);
60  const Vector uv2 = get(hum, prev(half_edge, g));
61  const Vector uv3 = get(hum, next(half_edge, g));
62 
63  Operators::calculate_face_tangent(*fb, g, pm, uv1, uv2, uv3, vtm);
64  }
65 
67 }
68 
69 } // namespace Filters
70 } // namespace FEVV
FEVV::DataStructures::AIF::next
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor next(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the next halfedge around its face.
Definition: Graph_traits_aif.h:599
Vector
AIFMesh::Vector Vector
Definition: Graph_properties_aif.h:22
FEVV::Filters::normalize_vector_map_vertices
void normalize_vector_map_vertices(const HalfedgeGraph &g, PropertyMap &prop_map)
Normalize each vector of the vertex property map.
Definition: normalize_vector_map.h:55
FEVV::Filters::calculate_halfedges_tangent
void calculate_halfedges_tangent(const HalfedgeGraph &g, const PointMap &pm, const HalfedgeUVMap &hum, VertexTangentMap &vtm)
Calculate the mesh's tangents from its halfedges.
Definition: calculate_halfedges_tangent.hpp:38
FEVV::Geometry_traits< HalfedgeGraph >
calculate_face_tangent.hpp
normalize_vector_map.h
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
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
FEVV::DataStructures::AIF::halfedge
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor halfedge(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::vertex_descriptor v, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns a halfedge with target v.
Definition: Graph_traits_aif.h:296
Geometry_traits.h
FEVV::DataStructures::AIF::AIFVector
Definition: AIFProperties.h:173
FEVV::DataStructures::AIF::prev
boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor prev(typename boost::graph_traits< FEVV::DataStructures::AIF::AIFMesh >::halfedge_descriptor h, const FEVV::DataStructures::AIF::AIFMesh &sm)
Returns the previous halfedge around its face.
Definition: Graph_traits_aif.h:612
FEVV::Operators::calculate_face_tangent
void calculate_face_tangent(typename boost::graph_traits< HalfedgeGraph >::face_descriptor f, const HalfedgeGraph &g, const PointMap &pm, const Vector &uv1, const Vector &uv2, const Vector &uv3, VertexTangentMap &vtm)
Calculate a face tangent, then accumulate its value on every vertices it contains to average them; fi...
Definition: calculate_face_tangent.hpp:41