MEPP2 Project
Graph_traits_pcl_point_cloud.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/graph/properties.hpp>
15 
16 #include <iterator> // for std::distance
17 #include <boost/iterator/counting_iterator.hpp>
18 
19 
21 
22 
23 namespace boost {
24 
25 template<>
26 struct vertex_property_type< FEVV::PCLPointCloud >
27 {
29 };
30 
31 
32 template<>
33 struct graph_traits< FEVV::PCLPointCloud >
34 {
35 private:
37 
38 public:
39  //
40  typedef FEVV::PCLPointCloud::VectorType::size_type index_type;
41  // FEVV::PCLPointCloud::points is a std::vector of FEVV::PCLEnrichedPoint
42  // see https://github.com/PointCloudLibrary/pcl/blob/39732f5a7c8455ed51fd0f6278d8b25322a68dd9/common/include/pcl/point_cloud.h#L426
43  typedef boost::counting_iterator<index_type> index_iterator;
44 
45  // Graph
48 
49  // HalfedgeGraph
51  //TODO-elo-fix halfedge_descriptor needed by SimpleViewer::draw_or_redraw_mesh()
52  // remove when draw_redraw_mesh() is fixed
53 
54  // FaceGraph
56  //TODO-elo-fix face_decriptor needed par SimpleViewer::internal_createMesh()
57  // remove when internal_createMesh() is fixed
58 
59  // VertexListGraph
62 
63  // nulls
64  static vertex_descriptor null_vertex() { return -1; }
65 };
66 
67 template<>
68 struct graph_traits< const FEVV::PCLPointCloud >
69  : public graph_traits< FEVV::PCLPointCloud >
70 { };
71 
72 } // namespace boost
73 
74 
75 namespace pcl {
76 
77 // Essential free functions specialization for PCLPointCloud.
78 
79 // See http://www.boost.org/doc/libs/1_61_0/libs/graph/doc/graph_concepts.html
80 // for BGL concepts description.
81 
82 // See http://doc.cgal.org/latest/BGL/group__PkgBGLConcepts.html
83 // for CGAL-BGL concepts description.
84 
85 // note: Must be in 'pcl' namespace because the real type of
86 // FEVV::PCLPointCloud is pcl::PointCloud<...> and the
87 // functions must be in the same namespace as one of their
88 // parameters.
89 
90 // BGL VertexListGraph
94 inline std::pair< typename boost::graph_traits<
95  FEVV::PCLPointCloud >::vertex_iterator,
96  typename boost::graph_traits<
97  FEVV::PCLPointCloud >::vertex_iterator >
99 {
100  // returns the index range of vertices
101  auto it_beg =
103  auto it_end =
105 
106  return std::pair<
109  it_beg, it_end);
110 }
111 
112 
113 // BGL VertexListGraph
117 inline
120 {
121  return static_cast<
123  std::distance(vertices(m).first, vertices(m).second));
124 }
125 
126 
127 // BGL VertexMutableGraph Concept
132 inline
135 {
136  FEVV::PCLEnrichedPoint new_point;
137  pc.push_back(new_point);
138 
139  // return index of new point
140  return pc.size() - 1;
141 }
142 
143 
144 // CGAL MutableHalfedgeGraph Concept
148 inline
149 void
150 remove_vertex(typename boost::graph_traits<
153 {
154  pc.erase(pc.begin() + v);
155 }
156 
157 
158 } // namespace pcl
boost::graph_traits< FEVV::PCLPointCloud >::vertices_size_type
index_type vertices_size_type
Definition: Graph_traits_pcl_point_cloud.h:61
pcl::num_vertices
boost::graph_traits< FEVV::PCLPointCloud >::vertices_size_type num_vertices(const FEVV::PCLPointCloud &m)
Returns an upper bound of the number of vertices of the mesh.
Definition: Graph_traits_pcl_point_cloud.h:119
pcl
Definition: Graph_properties_pcl_point_cloud.h:83
boost::graph_traits< FEVV::PCLPointCloud >::vertex_descriptor
index_type vertex_descriptor
Definition: Graph_traits_pcl_point_cloud.h:46
boost::graph_traits< FEVV::PCLPointCloud >::index_iterator
boost::counting_iterator< index_type > index_iterator
Definition: Graph_traits_pcl_point_cloud.h:43
FEVV::PCLPointCloud
pcl::PointCloud< PCLEnrichedPoint > PCLPointCloud
Definition: DataStructures_pcl_point_cloud.h:28
boost
Definition: Graph_properties_aif.h:48
boost::graph_traits< FEVV::PCLPointCloud >::null_vertex
static vertex_descriptor null_vertex()
Definition: Graph_traits_pcl_point_cloud.h:64
pcl::vertices
std::pair< typename boost::graph_traits< FEVV::PCLPointCloud >::vertex_iterator, typename boost::graph_traits< FEVV::PCLPointCloud >::vertex_iterator > vertices(const FEVV::PCLPointCloud &pc)
Returns the iterator range of the vertices of the mesh.
Definition: Graph_traits_pcl_point_cloud.h:98
boost::vertex_property_type< FEVV::PCLPointCloud >::type
FEVV::PCLEnrichedPoint type
Definition: Graph_traits_pcl_point_cloud.h:28
pcl::add_vertex
boost::graph_traits< FEVV::PCLPointCloud >::vertex_descriptor add_vertex(FEVV::PCLPointCloud &pc)
Adds a new vertex to the graph without initializing the connectivity.
Definition: Graph_traits_pcl_point_cloud.h:134
boost::graph_traits< FEVV::PCLPointCloud >::Point
FEVV::PCLEnrichedPoint Point
Definition: Graph_traits_pcl_point_cloud.h:36
FEVV
Interfaces for plugins These interfaces will be used for different plugins.
Definition: Assert.h:16
boost::graph_traits< FEVV::PCLPointCloud >::halfedge_descriptor
index_type halfedge_descriptor
Definition: Graph_traits_pcl_point_cloud.h:50
pcl::remove_vertex
void remove_vertex(typename boost::graph_traits< FEVV::PCLPointCloud >::vertex_descriptor v, FEVV::PCLPointCloud &pc)
Removes v from the mesh.
Definition: Graph_traits_pcl_point_cloud.h:150
DataStructures_pcl_point_cloud.h
boost::graph_traits< FEVV::PCLPointCloud >::index_type
FEVV::PCLPointCloud::VectorType::size_type index_type
Definition: Graph_traits_pcl_point_cloud.h:40
boost::graph_traits< FEVV::PCLPointCloud >::vertex_property_type
Point vertex_property_type
Definition: Graph_traits_pcl_point_cloud.h:47
boost::graph_traits< FEVV::PCLPointCloud >::face_descriptor
index_type face_descriptor
Definition: Graph_traits_pcl_point_cloud.h:55
msdm2::vertex_descriptor
boost::graph_traits< MeshT >::vertex_descriptor vertex_descriptor
Definition: msdm2_surfacemesh.h:33
boost::graph_traits< FEVV::PCLPointCloud >::vertex_iterator
index_iterator vertex_iterator
Definition: Graph_traits_pcl_point_cloud.h:60
FEVV::PCLEnrichedPoint
pcl::PointXYZRGBNormal PCLEnrichedPoint
Definition: DataStructures_pcl_point_cloud.h:27