iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointCloud2Data.H
Go to the documentation of this file.
1 //NRT_HEADER_BEGIN
2 /*! @file PointCloud2/PointCloud2Data.H */
3 
4 // ////////////////////////////////////////////////////////////////////////
5 // The iLab Neuromorphic Robotics Toolkit (NRT) //
6 // Copyright 2010 by the University of Southern California (USC) and the //
7 // iLab at USC. //
8 // //
9 // iLab - University of Southern California //
10 // Hedco Neurociences Building, Room HNB-10 //
11 // Los Angeles, Ca 90089-2520 - USA //
12 // //
13 // See http://ilab.usc.edu for information about this project. //
14 // ////////////////////////////////////////////////////////////////////////
15 // This file is part of The iLab Neuromorphic Robotics Toolkit. //
16 // //
17 // The iLab Neuromorphic Robotics Toolkit is free software: you can //
18 // redistribute it and/or modify it under the terms of the GNU General //
19 // Public License as published by the Free Software Foundation, either //
20 // version 3 of the License, or (at your option) any later version. //
21 // //
22 // The iLab Neuromorphic Robotics Toolkit is distributed in the hope //
23 // that it will be useful, but WITHOUT ANY WARRANTY; without even the //
24 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR //
25 // PURPOSE. See the GNU General Public License for more details. //
26 // //
27 // You should have received a copy of the GNU General Public License //
28 // along with The iLab Neuromorphic Robotics Toolkit. If not, see //
29 // <http://www.gnu.org/licenses/>. //
30 // ////////////////////////////////////////////////////////////////////////
31 //
32 // Primary maintainer for this file: Shane Grant <wgrant@usc.edu>
33 //
34 //NRT_HEADER_END
35 
36 #ifdef NRT_HAVE_CLOUD
37 #ifndef NRT_POINTCLOUD2_POINTCLOUD2DATA_H_
38 #define NRT_POINTCLOUD2_POINTCLOUD2DATA_H_
39 
43 
44 namespace nrt
45 {
46  //! A container for holding the data associated with a point cloud point
47  /*! Point cloud points can contain arbitrary data types in addition to
48  their geometric coordinate representation.
49 
50  Accessing geometry is available through the geometry() functionality whereas
51  all other data that may be held is handled through the get() functionality
52  inherited from StreamableGenericBag.
53 
54  @tparam Types The various types that can be represented by this data. Geometry is
55  always included regardless of types specified. Types follow the rules
56  for GenericBag (i.e.: they must be distinct using std::is_same)
57 
58  @ingroup pointcloud */
59  template <class ... Types>
60  class PointCloud2Data : public PointCloud2DataCore, public StreamableGenericBag<Types...>
61  {
62  private:
63  //! Geometry type - this is the same as PointCloud2::Geometry
64  typedef PointSSE<POINTCLOUD2_BASE_TYPE> Geometry;
65  typedef StreamableGenericBag<Types...> BagType;
66 
67  public:
68  //! Default initialized point
69  PointCloud2Data() = default;
70 
71  //! Initialize to some geometric point
72  PointCloud2Data( Geometry const & geo );
73 
74  //! Initialize by specifying geometry and a set of values for the other data
75  /*! This allows you to initialize all of the other (non geometry) types associated
76  with a point by specifying the value that the type will be initialized with.
77  The types do not need to be in the same order as the template parameter types,
78  and need not even match - those that do form an exact match with the actual contents
79  of this point will be initialized */
80  template <class ... InitTypes>
81  PointCloud2Data( Geometry const & geo, InitTypes const & ... initialValues );
82 
83  //! Copy construction
84  template <class ... InitTypes>
85  PointCloud2Data( PointCloud2Data<InitTypes...> const & other );
86 
87  //! Copy construction from a reference point
88  template <bool IsConst, class ... InitTypes>
89  PointCloud2Data( PointCloud2DataRefBase<IsConst, InitTypes...> const & other );
90 
91  //! Move copy construction
92  template <class ... InitTypes>
93  PointCloud2Data( PointCloud2Data<InitTypes...> && other );
94 
95  //! Move copy construction from a reference point
96  template <bool IsConst, class ... InitTypes>
97  PointCloud2Data( PointCloud2DataRefBase<IsConst, InitTypes...> && other );
98 
99  //! Assignment operation
100  template <class ... OtherTypes>
101  PointCloud2Data & operator=( PointCloud2Data<OtherTypes...> const & other );
102 
103  //! Assignment operation from a reference point
104  template <bool IsConst, class ... OtherTypes>
105  PointCloud2Data & operator=( PointCloud2DataRefBase<IsConst, OtherTypes...> const & other );
106 
107  //! Move assignment operation
108  template <class ... OtherTypes>
109  PointCloud2Data & operator=( PointCloud2Data<OtherTypes...> && other );
110 
111  //! Move assignment operation from a reference point
112  template <bool IsConst, class ... OtherTypes>
113  PointCloud2Data & operator=( PointCloud2DataRefBase<IsConst, OtherTypes...> && other );
114 
115  //! Inherit all assignment from streamable bag
116  using BagType::operator=;
117 
118  //! Access the geometry
119  Geometry & geometry();
120 
121  //! Const access to the geometry
122  Geometry const & geometry() const;
123 
124  private:
125  Geometry itsGeometry; //!< The geometry
126  }; // pointcloud2data
127 
128  //! A container for holding references to the data associated with a point cloud point
129  /*! Point cloud points can contain arbitrary data types in addition to
130  their geometric coordinate representation.
131 
132  Accessing geometry is available through the geometry() functionality whereas
133  all other data that may be held is handled through the get() functionality
134  inherited from StreamableGenericBag.
135 
136  Note that any and all data held by a reference point will exist elsewhere, usually
137  inside of an actual point cloud. This data type will most often be encountered
138  when querying a cloud for data.
139 
140  See @ref PointCloud2DataRefBase for implementation and interface details.
141 
142  @tparam Types The various types that can be represented by this data. Geometry is
143  always included regardless of types specified. Types follow the rules
144  for GenericBag (i.e.: they must be distinct using std::is_same on the decayed types)
145 
146  @ingroup pointcloud */
147  template <class ... Types>
148  using PointCloud2DataRef = PointCloud2DataRefBase<false, Types...>;
149 
150  //! A container for holding constant references to the data associated with a point cloud point
151  /*! See @ref PointCloud2DataRef for details. This version only holds constant references
152  @ingroup pointcloud */
153  template <class ... Types>
155 
156  //! Human-readable output to a stream
157  /*! @relates PointCloud2Data */
158  template <class ... Fields>
159  std::ostream & operator<<( std::ostream & out, PointCloud2Data<Fields...> const & data );
160 
161  //! Human-readable input from a stream
162  /*! @relates PointCloud2Data */
163  template <class ... Fields>
164  std::istream & operator>>( std::istream & in, PointCloud2Data<Fields...> & data );
165 
166  //! Human-readable output to a stream
167  /*! @relates PointCloud2DataRef
168  @relates PoitnCloud2ConstDataRef */
169  template <bool IsConst, class ... Fields>
170  std::ostream & operator<<( std::ostream & out, PointCloud2DataRefBase<IsConst, Fields...> const & data );
171 } // namespace nrt
172 
173 // Implementation details
175 
176 #endif // NRT_POINTCLOUD2_PointCloud2Data_H_
177 #endif // NRT_HAVE_CLOUD