42 #pragma GCC system_header 45 #include <Eigen/StdVector> 46 #include <Eigen/Geometry> 47 #include <pcl/PCLHeader.h> 48 #include <pcl/exceptions.h> 51 #include <pcl/type_traits.h> 75 template <
typename Po
intOutT>
78 using Pod =
typename traits::POD<PointOutT>::type;
86 p2_ (reinterpret_cast<
Pod&>(p2)),
90 template<
typename Key>
inline void 94 using T =
typename pcl::traits::datatype<PointOutT, Key>::type;
96 *
reinterpret_cast<T*
>(data_ptr) = static_cast<T> (p1_[f_idx_++]);
100 const Eigen::VectorXf &p1_;
108 template <
typename Po
intInT>
111 using Pod =
typename traits::POD<PointInT>::type;
118 : p1_ (reinterpret_cast<const
Pod&>(p1)), p2_ (p2), f_idx_ (0) { }
121 template<
typename Key>
inline void 125 using T =
typename pcl::traits::datatype<PointInT, Key>::type;
126 const std::uint8_t* data_ptr =
reinterpret_cast<const std::uint8_t*
>(&p1_) + pcl::traits::offset<PointInT, Key>::value;
127 p2_[f_idx_++] =
static_cast<float> (*
reinterpret_cast<const T*
>(data_ptr));
132 Eigen::VectorXf &p2_;
140 template <
typename Po
intT>
179 template <typename
PointT>
194 #pragma warning(push) 195 #pragma warning(disable: 4068) 197 #pragma clang diagnostic push 198 #pragma clang diagnostic ignored "-Wdeprecated-declarations" 200 #pragma clang diagnostic pop 209 header (pc.header), points (indices.size ()), width (indices.size ()), height (1), is_dense (pc.is_dense),
210 sensor_origin_ (pc.sensor_origin_), sensor_orientation_ (pc.sensor_orientation_)
213 assert (indices.size () <= pc.
size ());
214 for (std::size_t i = 0; i < indices.size (); i++)
215 points[i] = pc[indices[i]];
224 : points (width_ * height_, value_)
284 at (
int column,
int row)
const 286 if (this->height > 1)
287 return (points.at (row * this->width + column));
298 at (
int column,
int row)
300 if (this->height > 1)
301 return (points.at (row * this->width + column));
312 operator () (std::size_t column, std::size_t row)
const 314 return (points[row * this->width + column]);
323 operator () (std::size_t column, std::size_t row)
325 return (points[row * this->width + column]);
351 inline Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
354 if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit)
355 return (Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(reinterpret_cast<float*>(&points[0])+offset, size (), dim, Eigen::OuterStride<> (stride)));
357 return (Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(reinterpret_cast<float*>(&points[0])+offset, dim, size (), Eigen::OuterStride<> (stride)));
374 inline const Eigen::Map<const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
377 if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit)
378 return (Eigen::Map<
const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(reinterpret_cast<float*>(const_cast<PointT*>(&points[0]))+offset, size (), dim, Eigen::OuterStride<> (stride)));
380 return (Eigen::Map<
const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(reinterpret_cast<float*>(const_cast<PointT*>(&points[0]))+offset, dim, size (), Eigen::OuterStride<> (stride)));
389 inline Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
392 return (getMatrixXfMap (
sizeof (
PointT) /
sizeof (
float),
sizeof (
PointT) /
sizeof (
float), 0));
401 inline const Eigen::Map<const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
404 return (getMatrixXfMap (
sizeof (
PointT) /
sizeof (
float),
sizeof (
PointT) /
sizeof (
float), 0));
411 std::vector<PointT, Eigen::aligned_allocator<PointT> >
points;
419 bool is_dense =
true;
422 Eigen::Vector4f sensor_origin_ = Eigen::Vector4f::Zero ();
424 Eigen::Quaternionf sensor_orientation_ = Eigen::Quaternionf::Identity ();
427 using VectorType = std::vector<PointT, Eigen::aligned_allocator<PointT> >;
428 using CloudVectorType = std::vector<PointCloud<PointT>, Eigen::aligned_allocator<PointCloud<PointT> > >;
429 using Ptr = shared_ptr<PointCloud<PointT> >;
430 using ConstPtr = shared_ptr<const PointCloud<PointT> >;
459 inline std::size_t
size ()
const {
return points.size (); }
461 inline void reserve (std::size_t n) { points.reserve (n); }
462 inline bool empty ()
const {
return points.empty (); }
464 const PointT*
data() const noexcept {
return points.data(); }
480 points.resize(count);
481 if (width * height != count) {
502 points.resize(count, value);
503 if (width * height != count) {
510 inline const PointT& operator[] (std::size_t n)
const {
return (points[n]); }
511 inline PointT& operator[] (std::size_t n) {
return (points[n]); }
512 inline const PointT&
at (std::size_t n)
const {
return (points.at (n)); }
513 inline PointT&
at (std::size_t n) {
return (points.at (n)); }
516 inline const PointT&
back ()
const {
return (points.back ()); }
527 points.assign(count, value);
539 template <
class InputIt>
543 points.assign(std::move(first), std::move(last));
554 assign(std::initializer_list<PointT> ilist)
556 points.assign(std::move(ilist));
568 points.push_back (pt);
578 template <
class... Args>
inline reference
581 points.emplace_back (std::forward<Args> (args)...);
584 return points.back();
596 iterator it = points.insert (position, pt);
611 points.insert (position, n, pt);
622 template <
class InputIterator>
inline void 625 points.insert (position, first, last);
636 template <
class... Args>
inline iterator
639 iterator it = points.emplace (position, std::forward<Args> (args)...);
653 iterator it = points.erase (position);
668 iterator it = points.erase (first, last);
680 std::swap (header, rhs.
header);
681 this->points.swap (rhs.
points);
682 std::swap (width, rhs.
width);
683 std::swap (height, rhs.
height);
720 template <
typename Po
intT> shared_ptr<pcl::MsgFieldMap>&
727 template <
typename Po
intT> std::ostream&
728 operator << (std::ostream& s, const pcl::PointCloud<PointT> &p)
730 s <<
"header: " << p.header << std::endl;
731 s <<
"points[]: " << p.size () << std::endl;
732 s <<
"width: " << p.width << std::endl;
733 s <<
"height: " << p.height << std::endl;
734 s <<
"is_dense: " << p.is_dense << std::endl;
735 s <<
"sensor origin (xyz): [" <<
736 p.sensor_origin_.x () <<
", " <<
737 p.sensor_origin_.y () <<
", " <<
738 p.sensor_origin_.z () <<
"] / orientation (xyzw): [" <<
739 p.sensor_orientation_.x () <<
", " <<
740 p.sensor_orientation_.y () <<
", " <<
741 p.sensor_orientation_.z () <<
", " <<
742 p.sensor_orientation_.w () <<
"]" <<
748 #define PCL_INSTANTIATE_PointCloud(T) template class PCL_EXPORTS pcl::PointCloud<T>; PointCloud(const PointCloud< PointT > &pc, const Indices &indices)
Copy constructor from point cloud subset.
Helper functor structure for copying data between an Eigen type and a PointT.
iterator erase(iterator position)
Erase a point in the cloud.
std::size_t struct_offset
typename VectorType::const_reverse_iterator const_reverse_iterator
NdCopyPointEigenFunctor(const PointInT &p1, Eigen::VectorXf &p2)
Constructor.
std::vector< detail::FieldMapping > MsgFieldMap
Defines basic non-point types used by PCL.
shared_ptr< PointCloud< pcl::RGB > > Ptr
Defines functions, macros and traits for allocating and using memory.
reference emplace_back(Args &&...args)
Emplace a new point in the cloud, at the end of the container.
PointT & at(int column, int row)
Obtain the point given by the (column, row) coordinates.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
Helper functor structure for copying data between an Eigen type and a PointT.
typename VectorType::const_iterator const_iterator
PointT & at(std::size_t n)
NdCopyEigenPointFunctor(const Eigen::VectorXf &p1, PointOutT &p2)
Constructor.
iterator begin() noexcept
index_t max_size() const noexcept
const Eigen::Map< const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > getMatrixXfMap(int dim, int stride, int offset) const
Return an Eigen MatrixXf (assumes float values) mapped to the specified dimensions of the PointCloud...
reverse_iterator rbegin() noexcept
iterator emplace(iterator position, Args &&...args)
Emplace a new point in the cloud, given an iterator.
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
void push_back(const PointT &pt)
Insert a new point in the cloud, at the end of the container.
reverse_iterator rend() noexcept
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
std::vector< pcl::RGB, Eigen::aligned_allocator< pcl::RGB > > VectorType
const PointT & at(int column, int row) const
Obtain the point given by the (column, row) coordinates.
std::size_t serialized_offset
bool isOrganized() const
Return whether a dataset is organized (e.g., arranged in a structured grid).
std::uint32_t width
The point cloud width (if organized as an image-structure).
Eigen::Vector4f sensor_origin_
Sensor acquisition pose (origin/translation).
void resize(index_t count, const PointT &value)
Resizes the container to contain count elements.
A structure representing RGB color information.
void assign(std::initializer_list< PointT > ilist)
Replaces the points with the elements from the initializer list ilist
Eigen::Map< Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > getMatrixXfMap()
static bool concatenate(const pcl::PointCloud< PointT > &cloud1, const pcl::PointCloud< PointT > &cloud2, pcl::PointCloud< PointT > &cloud_out)
shared_ptr< MsgFieldMap > mapping_
This is motivated by ROS integration.
void assign(index_t count, const PointT &value)
Replaces the points with count copies of value
void swap(PointCloud< PointT > &rhs)
Swap a point cloud with another cloud.
const PointT & front() const
const_reverse_iterator rbegin() const noexcept
std::vector< PointCloud< pcl::RGB >, Eigen::aligned_allocator< PointCloud< pcl::RGB > > > CloudVectorType
const_reverse_iterator crend() const noexcept
shared_ptr< pcl::MsgFieldMap > & getMapping(pcl::PointCloud< PointT > &p)
Eigen::Quaternionf sensor_orientation_
Sensor acquisition pose (rotation).
void clear()
Removes all points in a cloud and sets the width and height to 0.
PCL_EXPORTS bool concatenate(const pcl::PointCloud< PointT > &cloud1, const pcl::PointCloud< PointT > &cloud2, pcl::PointCloud< PointT > &cloud_out)
Concatenate two pcl::PointCloud<PointT>
Eigen::Map< Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > getMatrixXfMap(int dim, int stride, int offset)
Return an Eigen MatrixXf (assumes float values) mapped to the specified dimensions of the PointCloud...
void operator()()
Operator.
iterator erase(iterator first, iterator last)
Erase a set of points given by a (first, last) iterator pair.
void resize(std::size_t count)
Resizes the container to contain count elements.
std::uint32_t height
The point cloud height (if organized as an image-structure).
IndicesAllocator<> Indices
Type used for indices in PCL.
const_iterator cbegin() const noexcept
PointCloud(std::uint32_t width_, std::uint32_t height_, const PointT &value_=PointT())
Allocate constructor from point cloud subset.
PointCloud represents the base class in PCL for storing collections of 3D points. ...
pcl::PCLHeader header
The point cloud header.
static bool concatenate(pcl::PointCloud< PointT > &cloud1, const pcl::PointCloud< PointT > &cloud2)
typename VectorType::iterator iterator
const Eigen::Map< const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > getMatrixXfMap() const
typename traits::POD< PointOutT >::type Pod
An exception that is thrown when an organized point cloud is needed but not provided.
void insert(iterator position, InputIterator first, InputIterator last)
Insert a new range of points in the cloud, at a certain position.
void insert(iterator position, std::size_t n, const PointT &pt)
Insert a new point in the cloud N times, given an iterator.
const PointT & back() const
typename VectorType::difference_type difference_type
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values in any of their floating point fields)...
void reserve(std::size_t n)
const_reverse_iterator crbegin() const noexcept
const_iterator end() const noexcept
shared_ptr< const PointCloud< pcl::RGB > > ConstPtr
Ptr makeShared() const
Copy the cloud to the heap and return a smart pointer Note that deep copy is performed, so avoid using this function on non-empty clouds.
#define PCL_DEPRECATED(Major, Minor, Message)
macro for compatibility across compilers and help remove old deprecated items for the Major...
const_iterator begin() const noexcept
A point structure representing Euclidean xyz coordinates, and the RGB color.
void operator()()
Operator.
typename VectorType::size_type size_type
iterator insert(iterator position, const PointT &pt)
Insert a new point in the cloud, given an iterator.
void assign(InputIt first, InputIt last)
Replaces the points with copies of those in the range [first, last)
const PointT * data() const noexcept
const_reverse_iterator rend() const noexcept
const_iterator cend() const noexcept
Defines all the PCL and non-PCL macros used.
typename traits::POD< PointInT >::type Pod
typename VectorType::reverse_iterator reverse_iterator
const PointT & at(std::size_t n) const