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