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  {
22 
23  std::uint32_t height = 0;
24  std::uint32_t width = 0;
25 
26  std::vector<::pcl::PCLPointField> fields;
27 
28  static_assert(BOOST_ENDIAN_BIG_BYTE || BOOST_ENDIAN_LITTLE_BYTE, "unable to determine system endianness");
29  std::uint8_t is_bigendian = BOOST_ENDIAN_BIG_BYTE;
30  std::uint32_t point_step = 0;
31  std::uint32_t row_step = 0;
32 
33  std::vector<std::uint8_t> data;
34 
35  std::uint8_t is_dense = 0;
36 
37  public:
38  using Ptr = boost::shared_ptr< ::pcl::PCLPointCloud2>;
39  using ConstPtr = boost::shared_ptr<const ::pcl::PCLPointCloud2>;
40 
41  //////////////////////////////////////////////////////////////////////////
42  /** \brief Inplace concatenate two pcl::PCLPointCloud2
43  *
44  * IFF the layout of all the fields in both the clouds is the same, this command
45  * doesn't remove any fields named "_" (aka marked as skip). For comparison of field
46  * names, "rgb" and "rgba" are considered equivalent
47  * However, if the order and/or number of non-skip fields is different, the skip fields
48  * are dropped and non-skip fields copied selectively.
49  * This function returns an error if
50  * * the total number of non-skip fields is different
51  * * the non-skip field names are named differently (excluding "rbg{a}") in serial order
52  * * the endian-ness of both clouds is different
53  * \param[in,out] cloud1 the first input and output point cloud dataset
54  * \param[in] cloud2 the second input point cloud dataset
55  * \return true if successful, false if failed (e.g., name/number of fields differs)
56  */
57  static bool
58  concatenate (pcl::PCLPointCloud2 &cloud1, const pcl::PCLPointCloud2 &cloud2);
59 
60  /** \brief Concatenate two pcl::PCLPointCloud2
61  * \param[in] cloud1 the first input point cloud dataset
62  * \param[in] cloud2 the second input point cloud dataset
63  * \param[out] cloud_out the resultant output point cloud dataset
64  * \return true if successful, false if failed (e.g., name/number of fields differs)
65  */
66  static bool
67  concatenate (const PCLPointCloud2 &cloud1,
68  const PCLPointCloud2 &cloud2,
69  PCLPointCloud2 &cloud_out)
70  {
71  cloud_out = cloud1;
72  return concatenate(cloud_out, cloud2);
73  }
74 
75  /** \brief Add a point cloud to the current cloud.
76  * \param[in] rhs the cloud to add to the current cloud
77  * \return the new cloud as a concatenation of the current cloud and the new given cloud
78  */
80  operator += (const PCLPointCloud2& rhs);
81 
82  /** \brief Add a point cloud to another cloud.
83  * \param[in] rhs the cloud to add to the current cloud
84  * \return the new cloud as a concatenation of the current cloud and the new given cloud
85  */
86  inline PCLPointCloud2
87  operator + (const PCLPointCloud2& rhs)
88  {
89  return (PCLPointCloud2 (*this) += rhs);
90  }
91  }; // struct PCLPointCloud2
92 
95 
96  inline std::ostream& operator<<(std::ostream& s, const ::pcl::PCLPointCloud2 &v)
97  {
98  s << "header: " << std::endl;
99  s << v.header;
100  s << "height: ";
101  s << " " << v.height << std::endl;
102  s << "width: ";
103  s << " " << v.width << std::endl;
104  s << "fields[]" << std::endl;
105  for (std::size_t i = 0; i < v.fields.size (); ++i)
106  {
107  s << " fields[" << i << "]: ";
108  s << std::endl;
109  s << " " << v.fields[i] << std::endl;
110  }
111  s << "is_bigendian: ";
112  s << " " << v.is_bigendian << std::endl;
113  s << "point_step: ";
114  s << " " << v.point_step << std::endl;
115  s << "row_step: ";
116  s << " " << v.row_step << std::endl;
117  s << "data[]" << std::endl;
118  for (std::size_t i = 0; i < v.data.size (); ++i)
119  {
120  s << " data[" << i << "]: ";
121  s << " " << v.data[i] << std::endl;
122  }
123  s << "is_dense: ";
124  s << " " << v.is_dense << std::endl;
125 
126  return (s);
127  }
128 
129 } // namespace pcl
std::vector<::pcl::PCLPointField > fields
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
::pcl::PCLHeader header
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.
PCLPointCloud2::ConstPtr PCLPointCloud2ConstPtr
boost::shared_ptr< ::pcl::PCLPointCloud2 > Ptr
PCL_EXPORTS bool concatenate(const pcl::PointCloud< PointT > &cloud1, const pcl::PointCloud< PointT > &cloud2, pcl::PointCloud< PointT > &cloud_out)
Concatenate two pcl::PointCloud<PointT>
Definition: io.h:281
std::vector< std::uint8_t > data
PCLPointCloud2::Ptr PCLPointCloud2Ptr
boost::shared_ptr< const ::pcl::PCLPointCloud2 > ConstPtr
#define PCL_EXPORTS
Definition: pcl_macros.h:241