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>
74 template <
typename Po
intOutT>
85 p2_ (reinterpret_cast<
Pod&>(p2)),
89 template<
typename Key>
inline void
95 *
reinterpret_cast<T*
>(data_ptr) =
static_cast<T
> (p1_[f_idx_++]);
99 const Eigen::VectorXf &p1_;
107 template <
typename Po
intInT>
117 : p1_ (reinterpret_cast<const
Pod&>(p1)), p2_ (p2), f_idx_ (0) { }
120 template<
typename Key>
inline void
126 p2_[f_idx_++] =
static_cast<float> (*
reinterpret_cast<const T*
>(data_ptr));
131 Eigen::VectorXf &p2_;
139 template <
typename Po
intT>
178 template <typename
PointT>
193 #pragma warning(push)
194 #pragma warning(disable: 4068)
196 #pragma clang diagnostic push
197 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
199 #pragma clang diagnostic pop
207 const std::vector<int> &indices) :
208 header (pc.header), points (indices.size ()), width (indices.size ()), height (1), is_dense (pc.is_dense),
209 sensor_origin_ (pc.sensor_origin_), sensor_orientation_ (pc.sensor_orientation_)
212 assert (indices.size () <= pc.
size ());
213 for (std::size_t i = 0; i < indices.size (); i++)
214 points[i] = pc.
points[indices[i]];
223 : points (width_ * height_, value_)
283 at (
int column,
int row)
const
285 if (this->height > 1)
286 return (points.at (row * this->width + column));
297 at (
int column,
int row)
299 if (this->height > 1)
300 return (points.at (row * this->width + column));
311 operator () (std::size_t column, std::size_t row)
const
313 return (points[row * this->width + column]);
322 operator () (std::size_t column, std::size_t row)
324 return (points[row * this->width + column]);
350 inline Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
353 if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit)
354 return (Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(
reinterpret_cast<float*
>(&points[0])+offset, points.size (), dim, Eigen::OuterStride<> (stride)));
356 return (Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(
reinterpret_cast<float*
>(&points[0])+offset, dim, points.size (), Eigen::OuterStride<> (stride)));
373 inline const Eigen::Map<const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
376 if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit)
377 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)));
379 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)));
388 inline Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
391 return (getMatrixXfMap (
sizeof (
PointT) /
sizeof (
float),
sizeof (
PointT) /
sizeof (
float), 0));
400 inline const Eigen::Map<const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
403 return (getMatrixXfMap (
sizeof (
PointT) /
sizeof (
float),
sizeof (
PointT) /
sizeof (
float), 0));
410 std::vector<PointT, Eigen::aligned_allocator<PointT> >
points;
418 bool is_dense =
true;
421 Eigen::Vector4f sensor_origin_ = Eigen::Vector4f::Zero ();
423 Eigen::Quaternionf sensor_orientation_ = Eigen::Quaternionf::Identity ();
426 using VectorType = std::vector<PointT, Eigen::aligned_allocator<PointT> >;
427 using CloudVectorType = std::vector<PointCloud<PointT>, Eigen::aligned_allocator<PointCloud<PointT> > >;
428 using Ptr = shared_ptr<PointCloud<PointT> >;
429 using ConstPtr = shared_ptr<const PointCloud<PointT> >;
448 inline std::size_t
size ()
const {
return (points.size ()); }
449 inline void reserve (std::size_t n) { points.reserve (n); }
450 inline bool empty ()
const {
return points.empty (); }
458 if (width * height != n)
466 inline const PointT& operator[] (std::size_t n)
const {
return (points[n]); }
467 inline PointT& operator[] (std::size_t n) {
return (points[n]); }
468 inline const PointT&
at (std::size_t n)
const {
return (points.at (n)); }
469 inline PointT&
at (std::size_t n) {
return (points.at (n)); }
472 inline const PointT&
back ()
const {
return (points.back ()); }
482 points.push_back (pt);
492 template <
class... Args>
inline reference
495 points.emplace_back (std::forward<Args> (args)...);
498 return points.back();
510 iterator it = points.insert (position, pt);
525 points.insert (position, n, pt);
536 template <
class InputIterator>
inline void
539 points.insert (position, first, last);
550 template <
class... Args>
inline iterator
553 iterator it = points.emplace (position, std::forward<Args> (args)...);
567 iterator it = points.erase (position);
582 iterator it = points.erase (first, last);
594 std::swap (header, rhs.
header);
595 this->points.swap (rhs.
points);
596 std::swap (width, rhs.
width);
597 std::swap (height, rhs.
height);
634 template <
typename Po
intT> shared_ptr<pcl::MsgFieldMap>&
641 template <
typename Po
intT> std::ostream&
644 s <<
"header: " << p.
header << std::endl;
645 s <<
"points[]: " << p.
points.size () << std::endl;
646 s <<
"width: " << p.
width << std::endl;
647 s <<
"height: " << p.
height << std::endl;
648 s <<
"is_dense: " << p.
is_dense << std::endl;
649 s <<
"sensor origin (xyz): [" <<
662 #define PCL_INSTANTIATE_PointCloud(T) template class PCL_EXPORTS pcl::PointCloud<T>;
PointCloud represents the base class in PCL for storing collections of 3D points.
typename VectorType::size_type size_type
iterator erase(iterator position)
Erase a point in the cloud.
shared_ptr< MsgFieldMap > mapping_
This is motivated by ROS integration.
void push_back(const PointT &pt)
Insert a new point in the cloud, at the end of the container.
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.
const PointT & at(int column, int row) const
Obtain the point given by the (column, row) coordinates.
void insert(iterator position, std::size_t n, const PointT &pt)
Insert a new point in the cloud N times, given an iterator.
iterator erase(iterator first, iterator last)
Erase a set of points given by a (first, last) iterator pair.
PointCloud(const PointCloud< PointT > &pc, const std::vector< int > &indices)
Copy constructor from point cloud subset.
PointCloud(const PointCloud< PointT > &pc)=default
Copy constructor.
Eigen::Map< Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > getMatrixXfMap()
PointCloud(std::uint32_t width_, std::uint32_t height_, const PointT &value_=PointT())
Allocate constructor from point cloud subset.
PointT & at(std::size_t n)
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values in any of their floating point fields).
void insert(iterator position, InputIterator first, InputIterator last)
Insert a new range of points in the cloud, at a certain position.
const PointT & at(std::size_t n) const
const PointT & front() const
typename VectorType::iterator iterator
Eigen::Quaternionf sensor_orientation_
Sensor acquisition pose (rotation).
const PointT & back() const
const_iterator begin() const
std::uint32_t width
The point cloud width (if organized as an image-structure).
reference emplace_back(Args &&...args)
Emplace a new point in the cloud, at the end of the container.
iterator insert(iterator position, const PointT &pt)
Insert a new point in the cloud, given an iterator.
PointCloud()=default
Default constructor.
pcl::PCLHeader header
The point cloud header.
std::vector< PointCloud< PointT >, Eigen::aligned_allocator< PointCloud< PointT > > > CloudVectorType
iterator emplace(iterator position, Args &&...args)
Emplace a new point in the cloud, given an iterator.
static bool concatenate(const pcl::PointCloud< PointT > &cloud1, const pcl::PointCloud< PointT > &cloud2, pcl::PointCloud< PointT > &cloud_out)
typename VectorType::const_iterator const_iterator
bool isOrganized() const
Return whether a dataset is organized (e.g., arranged in a structured grid).
std::uint32_t height
The point cloud height (if organized as an image-structure).
PointT & at(int column, int row)
Obtain the point given by the (column, row) coordinates.
void clear()
Removes all points in a cloud and sets the width and height to 0.
Eigen::Vector4f sensor_origin_
Sensor acquisition pose (origin/translation).
void reserve(std::size_t n)
std::vector< PointT, Eigen::aligned_allocator< PointT > > VectorType
void swap(PointCloud< PointT > &rhs)
Swap a point cloud with another cloud.
shared_ptr< PointCloud< PointT > > Ptr
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.
typename VectorType::difference_type difference_type
const Eigen::Map< const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > getMatrixXfMap() const
const_iterator end() const
static bool concatenate(pcl::PointCloud< PointT > &cloud1, const pcl::PointCloud< PointT > &cloud2)
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
void resize(std::size_t n)
Resize the cloud.
shared_ptr< const PointCloud< PointT > > ConstPtr
Ptr makeShared() const
Copy the cloud to the heap and return a smart pointer Note that deep copy is performed,...
An exception that is thrown when an organized point cloud is needed but not provided.
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
PCL_EXPORTS bool concatenate(const pcl::PointCloud< PointT > &cloud1, const pcl::PointCloud< PointT > &cloud2, pcl::PointCloud< PointT > &cloud_out)
Concatenate two pcl::PointCloud<PointT>
Defines functions, macros and traits for allocating and using memory.
shared_ptr< pcl::MsgFieldMap > & getMapping(pcl::PointCloud< PointT > &p)
std::ostream & operator<<(std::ostream &os, const BivariatePolynomialT< real > &p)
std::vector< detail::FieldMapping > MsgFieldMap
Defines all the PCL and non-PCL macros used.
#define PCL_DEPRECATED(Major, Minor, Message)
macro for compatibility across compilers and help remove old deprecated items for the Major....
Helper functor structure for copying data between an Eigen type and a PointT.
NdCopyEigenPointFunctor(const Eigen::VectorXf &p1, PointOutT &p2)
Constructor.
typename traits::POD< PointOutT >::type Pod
void operator()()
Operator.
Helper functor structure for copying data between an Eigen type and a PointT.
typename traits::POD< PointInT >::type Pod
void operator()()
Operator.
NdCopyPointEigenFunctor(const PointInT &p1, Eigen::VectorXf &p2)
Constructor.
A point structure representing Euclidean xyz coordinates, and the RGB color.
std::size_t struct_offset
std::size_t serialized_offset