MEPP2 Project
scaling.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 
17 
18 namespace FEVV {
19 namespace Filters {
20 
34 template< typename Graph,
35  typename PointMap,
36  typename GeometryTraits = FEVV::Geometry_traits< Graph > >
37 void
39  PointMap &pm,
40  typename GeometryTraits::Scalar scale_x,
41  typename GeometryTraits::Scalar scale_y,
42  typename GeometryTraits::Scalar scale_z,
43  const GeometryTraits &gt)
44 {
45  typedef boost::graph_traits< Graph > GraphTraits;
46  typedef typename GraphTraits::vertex_iterator vertex_iterator;
47  typedef typename boost::property_traits< PointMap >::value_type Point;
48  //typedef typename boost::property_traits< PointMap >::reference Reference;
49 
50  // std::cout << "Asking to scale mesh to " << scaleX << ";" << scaleY << ";"
51  // << scaleZ << std::endl;
52 
53  auto iterator_pair = vertices(g); // vertices() returns a vertex_iterator pair
54  vertex_iterator vi = iterator_pair.first;
55  vertex_iterator vi_end = iterator_pair.second;
56  for(; vi != vi_end; ++vi)
57  {
58  Point p = get(pm, *vi);
59  put(pm,
60  *vi,
61  Point(gt.get_x(p) * scale_x,
62  gt.get_y(p) * scale_y,
63  gt.get_z(p) * scale_z));
64  }
65 }
66 
78 template< typename Graph,
79  typename PointMap,
80  typename GeometryTraits = FEVV::Geometry_traits< Graph > >
81 void
83  PointMap &pm,
84  typename GeometryTraits::Scalar scale_x,
85  typename GeometryTraits::Scalar scale_y,
86  typename GeometryTraits::Scalar scale_z)
87 
88 {
89  GeometryTraits gt(g);
90  calculate_scaling< Graph, PointMap, GeometryTraits >(
91  g, pm, scale_x, scale_y, scale_z, gt);
92 }
93 
94 } // namespace Filters
95 } // 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
FEVV::Geometry_traits< Graph >
Point
AIFMesh::Point Point
Definition: Graph_properties_aif.h:21
FEVV::Filters::calculate_scaling
void calculate_scaling(Graph &g, PointMap &pm, typename GeometryTraits::Scalar scale_x, typename GeometryTraits::Scalar scale_y, typename GeometryTraits::Scalar scale_z, const GeometryTraits &gt)
Scale a mesh.
Definition: scaling.hpp:38
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::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::DataStructures::AIF::AIFPoint
Definition: AIFProperties.h:31