Point Cloud Library (PCL)
1.10.0
|
42 #pragma GCC system_header
45 #include <Eigen/StdVector>
46 #include <Eigen/Geometry>
47 #include <pcl/PCLHeader.h>
48 #include <pcl/exceptions.h>
50 #include <pcl/point_traits.h>
52 #include <pcl/make_shared.h>
75 template <
typename Po
intOutT>
86 p2_ (reinterpret_cast<
Pod&>(p2)),
90 template<
typename Key>
inline void
96 *
reinterpret_cast<T*
>(data_ptr) =
static_cast<T
> (p1_[f_idx_++]);
100 const Eigen::VectorXf &p1_;
108 template <
typename Po
intInT>
118 : p1_ (reinterpret_cast<const
Pod&>(p1)), p2_ (p2), f_idx_ (0) { }
121 template<
typename Key>
inline void
127 p2_[f_idx_++] =
static_cast<float> (*
reinterpret_cast<const T*
>(data_ptr));
132 Eigen::VectorXf &p2_;
140 template <
typename Po
intT>
141 [[deprecated(
"use createMapping() instead")]]
142 shared_ptr<pcl::MsgFieldMap>&
179 template <
typename Po
intT>
194 const std::vector<int> &indices) :
195 header (pc.header), points (indices.size ()), width (indices.size ()), height (1), is_dense (pc.is_dense),
196 sensor_origin_ (pc.sensor_origin_), sensor_orientation_ (pc.sensor_orientation_)
199 assert (indices.size () <= pc.
size ());
200 for (std::size_t i = 0; i < indices.size (); i++)
201 points[i] = pc.
points[indices[i]];
210 : points (width_ * height_, value_)
270 at (
int column,
int row)
const
272 if (this->height > 1)
273 return (points.at (row * this->width + column));
284 at (
int column,
int row)
286 if (this->height > 1)
287 return (points.at (row * this->width + column));
298 operator () (std::size_t column, std::size_t row)
const
300 return (points[row * this->width + column]);
309 operator () (std::size_t column, std::size_t row)
311 return (points[row * this->width + column]);
338 inline Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
341 if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit)
342 return (Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(
reinterpret_cast<float*
>(&points[0])+offset, points.size (), dim, Eigen::OuterStride<> (stride)));
344 return (Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(
reinterpret_cast<float*
>(&points[0])+offset, dim, points.size (), Eigen::OuterStride<> (stride)));
362 inline const Eigen::Map<const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
365 if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit)
366 return (Eigen::Map<
const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(
reinterpret_cast<float*
>(
const_cast<PointT*
>(&points[0]))+offset, points.size (), dim, Eigen::OuterStride<> (stride)));
368 return (Eigen::Map<
const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(
reinterpret_cast<float*
>(
const_cast<PointT*
>(&points[0]))+offset, dim, points.size (), Eigen::OuterStride<> (stride)));
376 inline Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
379 return (getMatrixXfMap (
sizeof (
PointT) /
sizeof (
float),
sizeof (
PointT) /
sizeof (
float), 0));
387 inline const Eigen::Map<const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
390 return (getMatrixXfMap (
sizeof (
PointT) /
sizeof (
float),
sizeof (
PointT) /
sizeof (
float), 0));
397 std::vector<PointT, Eigen::aligned_allocator<PointT> >
points;
405 bool is_dense =
true;
408 Eigen::Vector4f sensor_origin_ = Eigen::Vector4f::Zero ();
410 Eigen::Quaternionf sensor_orientation_ = Eigen::Quaternionf::Identity ();
413 using VectorType = std::vector<PointT, Eigen::aligned_allocator<PointT> >;
414 using CloudVectorType = std::vector<PointCloud<PointT>, Eigen::aligned_allocator<PointCloud<PointT> > >;
435 inline std::size_t
size ()
const {
return (points.size ()); }
436 inline void reserve (std::size_t n) { points.reserve (n); }
437 inline bool empty ()
const {
return points.empty (); }
445 if (width * height != n)
453 inline const PointT& operator[] (std::size_t n)
const {
return (points[n]); }
454 inline PointT& operator[] (std::size_t n) {
return (points[n]); }
455 inline const PointT&
at (std::size_t n)
const {
return (points.at (n)); }
456 inline PointT&
at (std::size_t n) {
return (points.at (n)); }
459 inline const PointT&
back ()
const {
return (points.back ()); }
469 points.push_back (pt);
479 template <
class... Args>
inline reference
482 points.emplace_back (std::forward<Args> (args)...);
485 return points.back();
497 iterator it = points.insert (position, pt);
512 points.insert (position, n, pt);
523 template <
class InputIterator>
inline void
526 points.insert (position, first, last);
537 template <
class... Args>
inline iterator
540 iterator it = points.emplace (position, std::forward<Args> (args)...);
554 iterator it = points.erase (position);
569 iterator it = points.erase (first, last);
581 std::swap (header, rhs.
header);
582 this->points.swap (rhs.
points);
583 std::swap (width, rhs.
width);
584 std::swap (height, rhs.
height);
626 template <
typename Po
intT> std::ostream&
629 s <<
"header: " << p.
header << std::endl;
630 s <<
"points[]: " << p.
points.size () << std::endl;
631 s <<
"width: " << p.
width << std::endl;
632 s <<
"height: " << p.
height << std::endl;
633 s <<
"is_dense: " << p.
is_dense << std::endl;
634 s <<
"sensor origin (xyz): [" <<
647 #define PCL_INSTANTIATE_PointCloud(T) template class PCL_EXPORTS pcl::PointCloud<T>;
void swap(PointCloud< PointT > &rhs)
Swap a point cloud with another cloud.
Defines all the PCL and non-PCL macros used.
This file defines compatibility wrappers for low level I/O functions.
Ptr makeShared() const
Copy the cloud to the heap and return a smart pointer Note that deep copy is performed,...
Helper functor structure for copying data between an Eigen type and a PointT.
std::uint32_t height
The point cloud height (if organized as an image-structure).
iterator erase(iterator first, iterator last)
Erase a set of points given by a (first, last) iterator pair.
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
const_iterator end() const
typename traits::POD< PointOutT >::type Pod
void operator()()
Operator.
const PointT & at(std::size_t n) const
void resize(std::size_t n)
Resize the cloud.
typename traits::POD< PointInT >::type Pod
iterator erase(iterator position)
Erase a point in the cloud.
iterator emplace(iterator position, Args &&...args)
Emplace a new point in the cloud, given an iterator.
PointCloud represents the base class in PCL for storing collections of 3D points.
PointT & at(int column, int row)
Obtain the point given by the (column, row) coordinates.
std::vector< pcl::RGB, Eigen::aligned_allocator< pcl::RGB > > VectorType
A point structure representing Euclidean xyz coordinates, and the RGB color.
void operator()()
Operator.
const PointT & at(int column, int row) const
Obtain the point given by the (column, row) coordinates.
bool isOrganized() const
Return whether a dataset is organized (e.g., arranged in a structured grid).
std::vector< PointCloud< pcl::RGB >, Eigen::aligned_allocator< PointCloud< pcl::RGB > > > CloudVectorType
Eigen::Map< Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > getMatrixXfMap()
Return an Eigen MatrixXf (assumes float values) mapped to the PointCloud.
std::ostream & operator<<(std::ostream &os, const BivariatePolynomialT< real > &p)
std::uint32_t width
The point cloud width (if organized as an image-structure).
typename VectorType::difference_type difference_type
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.
shared_ptr< MsgFieldMap > mapping_
const Eigen::Map< const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > getMatrixXfMap() const
Return an Eigen MatrixXf (assumes float values) mapped to the PointCloud.
typename VectorType::size_type size_type
const PointT & back() const
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.
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
A structure representing RGB color information.
void reserve(std::size_t n)
Eigen::Vector4f sensor_origin_
Sensor acquisition pose (origin/translation).
Eigen::Quaternionf sensor_orientation_
Sensor acquisition pose (rotation).
shared_ptr< pcl::MsgFieldMap > & getMapping(pcl::PointCloud< PointT > &p)
NdCopyEigenPointFunctor(const Eigen::VectorXf &p1, PointOutT &p2)
Constructor.
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values in any of their floating point fields).
PointCloud(const PointCloud< PointT > &pc, const std::vector< int > &indices)
Copy constructor from point cloud subset.
pcl::PCLHeader header
The point cloud header.
const_iterator begin() const
Helper functor structure for copying data between an Eigen type and a PointT.
An exception that is thrown when an organized point cloud is needed but not provided.
static bool concatenate(pcl::PointCloud< PointT > &cloud1, const pcl::PointCloud< PointT > &cloud2)
iterator insert(iterator position, const PointT &pt)
Insert a new point in the cloud, given an iterator.
shared_ptr< PointCloud< pcl::RGB > > 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>
reference emplace_back(Args &&...args)
Emplace a new point in the cloud, at the end of the container.
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 & front() const
void insert(iterator position, InputIterator first, InputIterator last)
Insert a new range of points in the cloud, at a certain position.
typename VectorType::const_iterator const_iterator
void clear()
Removes all points in a cloud and sets the width and height to 0.
shared_ptr< const PointCloud< pcl::RGB > > ConstPtr
PointCloud(std::uint32_t width_, std::uint32_t height_, const PointT &value_=PointT())
Allocate constructor from point cloud subset.
static bool concatenate(const pcl::PointCloud< PointT > &cloud1, const pcl::PointCloud< PointT > &cloud2, pcl::PointCloud< PointT > &cloud_out)
std::size_t serialized_offset
std::vector< detail::FieldMapping > MsgFieldMap
typename VectorType::iterator iterator
void push_back(const PointT &pt)
Insert a new point in the cloud, at the end of the container.
NdCopyPointEigenFunctor(const PointInT &p1, Eigen::VectorXf &p2)
Constructor.
std::size_t struct_offset
boost::shared_ptr< T > shared_ptr
Alias for boost::shared_ptr.
PointT & at(std::size_t n)