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