Point Cloud Library (PCL)  1.9.1-dev
PCLPointCloud2.h
1 #pragma once
2 
3 #ifdef USE_ROS
4  #error USE_ROS setup requires PCL to compile against ROS message headers, which is now deprecated
5 #endif
6 
7 #include <ostream>
8 #include <vector>
9 
10 #include <boost/predef/other/endian.h>
11 
12 // Include the correct Header path here
13 #include <pcl/PCLHeader.h>
14 #include <pcl/PCLPointField.h>
15 
16 namespace pcl
17 {
18 
20  {
21  PCLPointCloud2 () : height (0), width (0),
22  is_bigendian (false), point_step (0), row_step (0),
23  is_dense (false)
24  {
25 #if BOOST_ENDIAN_BIG_BYTE
26  is_bigendian = true;
27 #elif BOOST_ENDIAN_LITTLE_BYTE
28  is_bigendian = false;
29 #else
30 #error "unable to determine system endianness"
31 #endif
32  }
33 
35 
36  pcl::uint32_t height;
37  pcl::uint32_t width;
38 
39  std::vector< ::pcl::PCLPointField> fields;
40 
41  pcl::uint8_t is_bigendian;
42  pcl::uint32_t point_step;
43  pcl::uint32_t row_step;
44 
45  std::vector<pcl::uint8_t> data;
46 
47  pcl::uint8_t is_dense;
48 
49  public:
50  using Ptr = boost::shared_ptr< ::pcl::PCLPointCloud2>;
51  using ConstPtr = boost::shared_ptr<const ::pcl::PCLPointCloud2>;
52 
53  //////////////////////////////////////////////////////////////////////////
54  /** \brief Inplace concatenate two pcl::PCLPointCloud2
55  *
56  * IFF the layout of all the fields in both the clouds is the same, this command
57  * doesn't remove any fields named "_" (aka marked as skip). For comparison of field
58  * names, "rgb" and "rgba" are considered equivalent
59  * However, if the order and/or number of non-skip fields is different, the skip fields
60  * are dropped and non-skip fields copied selectively.
61  * This function returns an error if
62  * * the total number of non-skip fields is different
63  * * the non-skip field names are named differently (excluding "rbg{a}") in serial order
64  * * the endian-ness of both clouds is different
65  * \param[in,out] cloud1 the first input and output point cloud dataset
66  * \param[in] cloud2 the second input point cloud dataset
67  * \return true if successful, false if failed (e.g., name/number of fields differs)
68  */
69  static bool
70  concatenate (pcl::PCLPointCloud2 &cloud1, const pcl::PCLPointCloud2 &cloud2);
71 
72  /** \brief Concatenate two pcl::PCLPointCloud2
73  * \param[in] cloud1 the first input point cloud dataset
74  * \param[in] cloud2 the second input point cloud dataset
75  * \param[out] cloud_out the resultant output point cloud dataset
76  * \return true if successful, false if failed (e.g., name/number of fields differs)
77  */
78  static bool
79  concatenate (const PCLPointCloud2 &cloud1,
80  const PCLPointCloud2 &cloud2,
81  PCLPointCloud2 &cloud_out)
82  {
83  cloud_out = cloud1;
84  return concatenate(cloud_out, cloud2);
85  }
86 
87  /** \brief Add a point cloud to the current cloud.
88  * \param[in] rhs the cloud to add to the current cloud
89  * \return the new cloud as a concatenation of the current cloud and the new given cloud
90  */
92  operator += (const PCLPointCloud2& rhs);
93 
94  /** \brief Add a point cloud to another cloud.
95  * \param[in] rhs the cloud to add to the current cloud
96  * \return the new cloud as a concatenation of the current cloud and the new given cloud
97  */
98  inline PCLPointCloud2
100  {
101  return (PCLPointCloud2 (*this) += rhs);
102  }
103  }; // struct PCLPointCloud2
104 
105  using PCLPointCloud2Ptr = boost::shared_ptr< ::pcl::PCLPointCloud2>;
106  using PCLPointCloud2ConstPtr = boost::shared_ptr<const ::pcl::PCLPointCloud2>;
107 
108  inline std::ostream& operator<<(std::ostream& s, const ::pcl::PCLPointCloud2 &v)
109  {
110  s << "header: " << std::endl;
111  s << v.header;
112  s << "height: ";
113  s << " " << v.height << std::endl;
114  s << "width: ";
115  s << " " << v.width << std::endl;
116  s << "fields[]" << std::endl;
117  for (size_t i = 0; i < v.fields.size (); ++i)
118  {
119  s << " fields[" << i << "]: ";
120  s << std::endl;
121  s << " " << v.fields[i] << std::endl;
122  }
123  s << "is_bigendian: ";
124  s << " " << v.is_bigendian << std::endl;
125  s << "point_step: ";
126  s << " " << v.point_step << std::endl;
127  s << "row_step: ";
128  s << " " << v.row_step << std::endl;
129  s << "data[]" << std::endl;
130  for (size_t i = 0; i < v.data.size (); ++i)
131  {
132  s << " data[" << i << "]: ";
133  s << " " << v.data[i] << std::endl;
134  }
135  s << "is_dense: ";
136  s << " " << v.is_dense << std::endl;
137 
138  return (s);
139  }
140 
141 } // namespace pcl
pcl::uint8_t is_bigendian
PCLPointCloud2 operator+(const PCLPointCloud2 &rhs)
Add a point cloud to another cloud.
pcl::uint32_t point_step
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
static bool concatenate(pcl::PCLPointCloud2 &cloud1, const pcl::PCLPointCloud2 &cloud2)
Inplace concatenate two pcl::PCLPointCloud2.
::pcl::PCLHeader header
pcl::uint8_t is_dense
PCLPointCloud2 & operator+=(const PCLPointCloud2 &rhs)
Add a point cloud to the current cloud.
std::ostream & operator<<(std::ostream &os, const BivariatePolynomialT< real > &p)
static bool concatenate(const PCLPointCloud2 &cloud1, const PCLPointCloud2 &cloud2, PCLPointCloud2 &cloud_out)
Concatenate two pcl::PCLPointCloud2.
pcl::uint32_t row_step
pcl::uint32_t width
boost::shared_ptr< ::pcl::PCLPointCloud2 > Ptr
boost::shared_ptr< ::pcl::PCLPointCloud2 > PCLPointCloud2Ptr
boost::shared_ptr< const ::pcl::PCLPointCloud2 > PCLPointCloud2ConstPtr
std::vector< ::pcl::PCLPointField > fields
pcl::uint32_t height
boost::shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr
std::vector< pcl::uint8_t > data