Point Cloud Library (PCL)
1.11.1
|
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&
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): [" <<
748 #define PCL_INSTANTIATE_PointCloud(T) template class PCL_EXPORTS pcl::PointCloud<T>;
void swap(PointCloud< PointT > &rhs)
Swap a point cloud with another cloud.
typename VectorType::const_reverse_iterator const_reverse_iterator
Defines all the PCL and non-PCL macros used.
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.
void assign(std::initializer_list< PointT > ilist)
Replaces the points with the elements from the initializer list ilist
std::uint32_t height
The point cloud height (if organized as an image-structure).
void resize(index_t count, const PointT &value)
Resizes the container to contain count elements.
iterator erase(iterator first, iterator last)
Erase a set of points given by a (first, last) iterator pair.
const_iterator cbegin() const noexcept
std::vector< PointT, Eigen::aligned_allocator< PointT > > points
The point data.
reverse_iterator rbegin() noexcept
Defines basic non-point types used by PCL.
typename traits::POD< PointOutT >::type Pod
void operator()()
Operator.
iterator begin() noexcept
const PointT & at(std::size_t n) const
const_iterator cend() const noexcept
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.
detail::int_type_t< detail::index_type_size, detail::index_type_signed > index_t
Type used for an index in PCL.
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).
const Eigen::Map< const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > getMatrixXfMap() const
std::vector< PointCloud< pcl::RGB >, Eigen::aligned_allocator< PointCloud< pcl::RGB > > > CloudVectorType
const PointT * data() const noexcept
std::ostream & operator<<(std::ostream &os, const BivariatePolynomialT< real > &p)
#define PCL_DEPRECATED(Major, Minor, Message)
macro for compatibility across compilers and help remove old deprecated items for the Major....
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_
This is motivated by ROS integration.
const_reverse_iterator rend() const noexcept
typename VectorType::size_type size_type
const_iterator end() const noexcept
const PointT & back() const
reverse_iterator rend() 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.
const_reverse_iterator crend() const noexcept
#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)
PointCloud(const PointCloud< PointT > &pc)=default
Copy constructor.
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).
void resize(std::size_t count)
Resizes the container to contain count elements.
typename VectorType::reverse_iterator reverse_iterator
pcl::PCLHeader header
The point cloud header.
Helper functor structure for copying data between an Eigen type and a PointT.
IndicesAllocator<> Indices
Type used for indices in PCL.
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)
const_iterator begin() const noexcept
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.
void assign(index_t count, const PointT &value)
Replaces the points with count copies of value
const_reverse_iterator rbegin() const noexcept
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 assign(InputIt first, InputIt last)
Replaces the points with copies of those in the range [first, last)
void clear()
Removes all points in a cloud and sets the width and height to 0.
PointCloud(const PointCloud< PointT > &pc, const Indices &indices)
Copy constructor from point cloud subset.
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)
index_t max_size() const noexcept
std::size_t serialized_offset
Eigen::Map< Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > getMatrixXfMap()
std::vector< detail::FieldMapping > MsgFieldMap
PointCloud()=default
Default constructor.
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.
const_reverse_iterator crbegin() const noexcept
Defines functions, macros and traits for allocating and using memory.
std::size_t struct_offset
PointT & at(std::size_t n)