MEPP2 Project
compute_mesh_bounding_box.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>
16 
17 namespace FEVV {
18 namespace Filters {
34 template< typename PropertyGraph,
35  typename PointMap,
36  typename GeometryTraits = FEVV::Geometry_traits< PropertyGraph > >
37 void
39  const PropertyGraph &g,
40  const PointMap &pm,
41  typename boost::property_traits< PointMap >::value_type &min_aabb,
42  typename boost::property_traits< PointMap >::value_type &max_aabb,
43  const GeometryTraits &gt)
44 {
45  typedef typename boost::property_traits< PointMap >::value_type Point;
46 
47  //typedef boost::graph_traits< PropertyGraph > GraphTraits;
48  auto iterator_pair = vertices(g); // vertices() returns a vertex_iterator pair
49  auto vi = iterator_pair.first;
50  auto vi_end = iterator_pair.second;
51  if(vi != vi_end)
52  {
53  Point p = get(pm, *vi);
54  min_aabb = Point(gt.get_x(p), gt.get_y(p), gt.get_z(p));
55  max_aabb = Point(gt.get_x(p), gt.get_y(p), gt.get_z(p));
56  ++vi;
57  for(; vi != vi_end; ++vi)
58  {
59  Point p = get(pm, *vi);
60  min_aabb = Point(std::min(gt.get_x(p), gt.get_x(min_aabb)),
61  std::min(gt.get_y(p), gt.get_y(min_aabb)),
62  std::min(gt.get_z(p), gt.get_z(min_aabb)));
63 
64  max_aabb = Point(std::max(gt.get_x(p), gt.get_x(max_aabb)),
65  std::max(gt.get_y(p), gt.get_y(max_aabb)),
66  std::max(gt.get_z(p), gt.get_z(max_aabb)));
67  }
68  }
69 }
70 
71 } // namespace Filters
72 } // 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
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
FEVV::Filters::compute_mesh_bounding_box
void compute_mesh_bounding_box(const PropertyGraph &g, const PointMap &pm, typename boost::property_traits< PointMap >::value_type &min_aabb, typename boost::property_traits< PointMap >::value_type &max_aabb, const GeometryTraits &gt)
Compute the mesh Axis-Aligned Bounding-Box (AABB).
Definition: compute_mesh_bounding_box.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::DataStructures::AIF::AIFPoint
Definition: AIFProperties.h:31