MEPP2 Project
minmax_map.h
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/foreach.hpp>
15 #include <limits>
16 
17 namespace FEVV {
18 namespace Filters {
19 
31 template< typename Descriptor,
32  typename PropertyMap,
33  typename MapType = typename PropertyMap::value_type >
34 void
35 compute_min_max_descriptor(const Descriptor &d,
36  const PropertyMap &prop_map,
37  MapType &min_metric,
38  MapType &max_metric)
39 {
40  MapType l_metric = get(prop_map, d);
41  if(min_metric > l_metric)
42  min_metric = l_metric;
43  if(max_metric < l_metric)
44  max_metric = l_metric;
45 }
46 
47 
58 template< typename HalfedgeGraph,
59  typename PropertyMap,
60  typename MapType = typename PropertyMap::value_type >
61 void
62 compute_min_max_faces(const HalfedgeGraph &g,
63  const PropertyMap &prop_map,
64  MapType &min_metric,
65  MapType &max_metric)
66 {
67  typedef typename boost::graph_traits< HalfedgeGraph >::face_descriptor
68  Face_Descriptor;
69  min_metric = (std::numeric_limits< MapType >::max)();
70  max_metric = (std::numeric_limits< MapType >::min)();
71  BOOST_FOREACH(Face_Descriptor f, faces(g))
72  {
73  compute_min_max_descriptor(f, prop_map, min_metric, max_metric);
74  }
75 }
76 
77 
88 template< typename HalfedgeGraph,
89  typename PropertyMap,
90  typename MapType = typename PropertyMap::value_type >
91 void
92 compute_min_max_vertices(const HalfedgeGraph &g,
93  const PropertyMap &prop_map,
94  MapType &min_metric,
95  MapType &max_metric)
96 {
99 
100  min_metric = (std::numeric_limits< MapType >::max)();
101  max_metric = (std::numeric_limits< MapType >::min)();
102  BOOST_FOREACH(Vertex_Descriptor v, vertices(g))
103  {
104  compute_min_max_descriptor(v, prop_map, min_metric, max_metric);
105  }
106 }
107 
108 
119 template< typename HalfedgeGraph,
120  typename PropertyMap,
121  typename MapType = typename PropertyMap::value_type >
122 void
123 compute_min_max_halfedges(const HalfedgeGraph &g,
124  const PropertyMap &prop_map,
125  MapType &min_metric,
126  MapType &max_metric)
127 {
128  typedef typename boost::graph_traits< HalfedgeGraph >::halfedge_descriptor
129  Halfedge_Descriptor;
130  min_metric = (std::numeric_limits< MapType >::max)();
131  max_metric = (std::numeric_limits< MapType >::min)();
132 
133  BOOST_FOREACH(Halfedge_Descriptor h, halfedges(g))
134  {
135  compute_min_max_descriptor(h, prop_map, min_metric, max_metric);
136  }
137 }
138 } // namespace Filters
139 } // 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::Filters::compute_min_max_vertices
void compute_min_max_vertices(const HalfedgeGraph &g, const PropertyMap &prop_map, MapType &min_metric, MapType &max_metric)
Compute min and max value of a numerical property map for the vertices of a mesh.
Definition: minmax_map.h:92
FEVV::Filters::compute_min_max_halfedges
void compute_min_max_halfedges(const HalfedgeGraph &g, const PropertyMap &prop_map, MapType &min_metric, MapType &max_metric)
Compute min and max value of a numerical property map for the halfedges of a mesh.
Definition: minmax_map.h:123
FEVV::Vertex_Descriptor
MeshSurface::Vertex_index Vertex_Descriptor
Definition: cmdm.h:44
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
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33
FEVV::Filters::compute_min_max_descriptor
void compute_min_max_descriptor(const Descriptor &d, const PropertyMap &prop_map, MapType &min_metric, MapType &max_metric)
Generic call to compute min max from a Descriptor Get the value of the property map for the given des...
Definition: minmax_map.h:35
FEVV::Filters::compute_min_max_faces
void compute_min_max_faces(const HalfedgeGraph &g, const PropertyMap &prop_map, MapType &min_metric, MapType &max_metric)
Compute min and max value of a numerical property map for the faces of a mesh.
Definition: minmax_map.h:62