point_cloud2_iterator.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2013, Open Source Robotics Foundation
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of Open Source Robotics Foundation nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef SENSOR_MSGS_POINT_CLOUD2_ITERATOR_H
36 #define SENSOR_MSGS_POINT_CLOUD2_ITERATOR_H
37 
38 #include <sensor_msgs/PointCloud2.h>
39 #include <cstdarg>
40 #include <string>
41 #include <vector>
42 
100 namespace sensor_msgs
101 {
106 {
107 public:
112  PointCloud2Modifier(PointCloud2& cloud_msg);
113 
117  size_t size() const;
118 
122  void reserve(size_t size);
123 
127  void resize(size_t size);
128 
132  void clear();
133 
151  void setPointCloud2Fields(int n_fields, ...);
152 
163  void setPointCloud2FieldsByString(int n_fields, ...);
164 protected:
166  PointCloud2& cloud_msg_;
167 };
168 
169 namespace impl
170 {
178 template<typename T, typename TT, typename U, typename C, template <typename> class V>
180 {
181 public:
185 
190  PointCloud2IteratorBase(C &cloud_msg, const std::string &field_name);
191 
196  V<T>& operator =(const V<T>& iter);
197 
203  TT& operator [](size_t i) const;
204 
208  TT& operator *() const;
209 
213  V<T>& operator ++();
214 
219  V<T> operator +(int i);
220 
224  V<T>& operator +=(int i);
225 
229  bool operator !=(const V<T>& iter) const;
230 
234  V<T> end() const;
235 
236 private:
242  int set_field(const sensor_msgs::PointCloud2 &cloud_msg, const std::string &field_name);
243 
249  TT* data_;
254 };
255 }
256 
280 template<typename T>
281 class PointCloud2Iterator : public impl::PointCloud2IteratorBase<T, T, unsigned char, sensor_msgs::PointCloud2, PointCloud2Iterator>
282 {
283 public:
284  PointCloud2Iterator(sensor_msgs::PointCloud2 &cloud_msg, const std::string &field_name) :
285  impl::PointCloud2IteratorBase<T, T, unsigned char, sensor_msgs::PointCloud2, sensor_msgs::PointCloud2Iterator>::PointCloud2IteratorBase(cloud_msg, field_name) {}
286 };
287 
291 template<typename T>
292 class PointCloud2ConstIterator : public impl::PointCloud2IteratorBase<T, const T, const unsigned char, const sensor_msgs::PointCloud2, PointCloud2ConstIterator>
293 {
294 public:
295  PointCloud2ConstIterator(const sensor_msgs::PointCloud2 &cloud_msg, const std::string &field_name) :
296  impl::PointCloud2IteratorBase<T, const T, const unsigned char, const sensor_msgs::PointCloud2, sensor_msgs::PointCloud2ConstIterator>::PointCloud2IteratorBase(cloud_msg, field_name) {}
297 };
298 }
299 
301 
302 #endif// SENSOR_MSGS_POINT_CLOUD2_ITERATOR_H
sensor_msgs::impl::PointCloud2IteratorBase::operator=
V< T > & operator=(const V< T > &iter)
Definition: impl/point_cloud2_iterator.h:262
point_cloud2_iterator.h
sensor_msgs::impl::PointCloud2IteratorBase::operator[]
TT & operator[](size_t i) const
Definition: impl/point_cloud2_iterator.h:282
sensor_msgs::impl::PointCloud2IteratorBase::data_
TT * data_
Definition: point_cloud2_iterator.h:249
sensor_msgs::impl::PointCloud2IteratorBase::end
V< T > end() const
Definition: impl/point_cloud2_iterator.h:346
sensor_msgs::PointCloud2Modifier::reserve
void reserve(size_t size)
Definition: impl/point_cloud2_iterator.h:111
sensor_msgs::PointCloud2Modifier::PointCloud2Modifier
PointCloud2Modifier(PointCloud2 &cloud_msg)
Default constructor.
Definition: impl/point_cloud2_iterator.h:102
sensor_msgs::PointCloud2Modifier::size
size_t size() const
Definition: impl/point_cloud2_iterator.h:106
sensor_msgs::impl::PointCloud2IteratorBase::point_step_
int point_step_
Definition: point_cloud2_iterator.h:245
sensor_msgs::impl::PointCloud2IteratorBase::operator+=
V< T > & operator+=(int i)
Definition: impl/point_cloud2_iterator.h:326
sensor_msgs::impl::PointCloud2IteratorBase::operator!=
bool operator!=(const V< T > &iter) const
Definition: impl/point_cloud2_iterator.h:337
sensor_msgs::PointCloud2Modifier::setPointCloud2Fields
void setPointCloud2Fields(int n_fields,...)
Function setting some fields in a PointCloud and adjusting the internals of the PointCloud2.
Definition: impl/point_cloud2_iterator.h:166
sensor_msgs::PointCloud2Iterator::PointCloud2Iterator
PointCloud2Iterator(sensor_msgs::PointCloud2 &cloud_msg, const std::string &field_name)
Definition: point_cloud2_iterator.h:284
sensor_msgs::PointCloud2ConstIterator
Same as a PointCloud2Iterator but for const data.
Definition: point_cloud2_iterator.h:292
sensor_msgs::impl::PointCloud2IteratorBase::data_end_
TT * data_end_
Definition: point_cloud2_iterator.h:251
sensor_msgs::impl::PointCloud2IteratorBase::is_bigendian_
bool is_bigendian_
Definition: point_cloud2_iterator.h:253
sensor_msgs::PointCloud2Iterator
Class that can iterate over a PointCloud2.
Definition: point_cloud2_iterator.h:281
sensor_msgs::impl::PointCloud2IteratorBase
Definition: point_cloud2_iterator.h:179
sensor_msgs::impl::PointCloud2IteratorBase::PointCloud2IteratorBase
PointCloud2IteratorBase()
Definition: impl/point_cloud2_iterator.h:239
sensor_msgs::impl::PointCloud2IteratorBase::operator*
TT & operator*() const
Definition: impl/point_cloud2_iterator.h:291
sensor_msgs::PointCloud2Modifier::cloud_msg_
PointCloud2 & cloud_msg_
Definition: point_cloud2_iterator.h:166
sensor_msgs::PointCloud2Modifier::resize
void resize(size_t size)
Definition: impl/point_cloud2_iterator.h:116
sensor_msgs::impl::PointCloud2IteratorBase::set_field
int set_field(const sensor_msgs::PointCloud2 &cloud_msg, const std::string &field_name)
Definition: impl/point_cloud2_iterator.h:359
sensor_msgs::PointCloud2Modifier
Enables modifying a sensor_msgs::PointCloud2 like a container.
Definition: point_cloud2_iterator.h:105
sensor_msgs::impl::PointCloud2IteratorBase::operator+
V< T > operator+(int i)
Definition: impl/point_cloud2_iterator.h:312
sensor_msgs::PointCloud2Modifier::clear
void clear()
remove all T's from the original sensor_msgs::PointCloud2
Definition: impl/point_cloud2_iterator.h:134
sensor_msgs::impl::PointCloud2IteratorBase::data_char_
U * data_char_
Definition: point_cloud2_iterator.h:247
sensor_msgs
Tools for manipulating sensor_msgs.
Definition: distortion_models.h:41
sensor_msgs::PointCloud2ConstIterator::PointCloud2ConstIterator
PointCloud2ConstIterator(const sensor_msgs::PointCloud2 &cloud_msg, const std::string &field_name)
Definition: point_cloud2_iterator.h:295
sensor_msgs::PointCloud2Modifier::setPointCloud2FieldsByString
void setPointCloud2FieldsByString(int n_fields,...)
Function setting some fields in a PointCloud and adjusting the internals of the PointCloud2.
Definition: impl/point_cloud2_iterator.h:198
sensor_msgs::impl::PointCloud2IteratorBase::operator++
V< T > & operator++()
Definition: impl/point_cloud2_iterator.h:300


sensor_msgs
Author(s): Tully Foote
autogenerated on Wed Mar 2 2022 00:06:55