Point Cloud Library (PCL)
1.11.1-dev
|
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>
77 using Pod =
typename traits::POD<PointOutT>::type;
85 p2_ (reinterpret_cast<
Pod&>(p2)),
89 template<
typename Key>
inline void
93 using T =
typename pcl::traits::datatype<PointOutT, Key>::type;
94 std::uint8_t* data_ptr =
reinterpret_cast<std::uint8_t*
>(&p2_) + pcl::traits::offset<PointOutT, Key>::value;
95 *
reinterpret_cast<T*
>(data_ptr) =
static_cast<T
> (p1_[f_idx_++]);
99 const Eigen::VectorXf &p1_;
107 template <
typename Po
intInT>
110 using Pod =
typename traits::POD<PointInT>::type;
117 : p1_ (reinterpret_cast<const
Pod&>(p1)), p2_ (p2), f_idx_ (0) { }
120 template<
typename Key>
inline void
124 using T =
typename pcl::traits::datatype<PointInT, Key>::type;
125 const std::uint8_t* data_ptr =
reinterpret_cast<const std::uint8_t*
>(&p1_) + pcl::traits::offset<PointInT, Key>::value;
126 p2_[f_idx_++] =
static_cast<float> (*
reinterpret_cast<const T*
>(data_ptr));
131 Eigen::VectorXf &p2_;
170 template <
typename Po
intT>
186 header (pc.header), points (indices.size ()), width (indices.size ()), height (1), is_dense (pc.is_dense),
187 sensor_origin_ (pc.sensor_origin_), sensor_orientation_ (pc.sensor_orientation_)
190 assert (indices.size () <= pc.
size ());
191 for (std::size_t i = 0; i < indices.size (); i++)
192 points[i] = pc[indices[i]];
201 : points (width_ * height_, value_)
261 at (
int column,
int row)
const
263 if (this->height > 1)
264 return (points.at (row * this->width + column));
275 at (
int column,
int row)
277 if (this->height > 1)
278 return (points.at (row * this->width + column));
289 operator () (std::size_t column, std::size_t row)
const
291 return (points[row * this->width + column]);
300 operator () (std::size_t column, std::size_t row)
302 return (points[row * this->width + column]);
328 inline Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
331 if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit)
332 return (Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(
reinterpret_cast<float*
>(&points[0])+offset, size (), dim, Eigen::OuterStride<> (stride)));
334 return (Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(
reinterpret_cast<float*
>(&points[0])+offset, dim, size (), Eigen::OuterStride<> (stride)));
351 inline const Eigen::Map<const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
354 if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit)
355 return (Eigen::Map<
const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(
reinterpret_cast<float*
>(
const_cast<PointT*
>(&points[0]))+offset, size (), dim, Eigen::OuterStride<> (stride)));
357 return (Eigen::Map<
const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(
reinterpret_cast<float*
>(
const_cast<PointT*
>(&points[0]))+offset, dim, size (), Eigen::OuterStride<> (stride)));
366 inline Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
369 return (getMatrixXfMap (
sizeof (
PointT) /
sizeof (
float),
sizeof (
PointT) /
sizeof (
float), 0));
378 inline const Eigen::Map<const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
381 return (getMatrixXfMap (
sizeof (
PointT) /
sizeof (
float),
sizeof (
PointT) /
sizeof (
float), 0));
388 std::vector<PointT, Eigen::aligned_allocator<PointT> >
points;
391 std::uint32_t width = 0;
393 std::uint32_t height = 0;
396 bool is_dense =
true;
399 Eigen::Vector4f sensor_origin_ = Eigen::Vector4f::Zero ();
401 Eigen::Quaternionf sensor_orientation_ = Eigen::Quaternionf::Identity ();
404 using VectorType = std::vector<PointT, Eigen::aligned_allocator<PointT> >;
405 using CloudVectorType = std::vector<PointCloud<PointT>, Eigen::aligned_allocator<PointCloud<PointT> > >;
406 using Ptr = shared_ptr<PointCloud<PointT> >;
407 using ConstPtr = shared_ptr<const PointCloud<PointT> >;
436 inline std::size_t
size ()
const {
return points.size (); }
438 inline void reserve (std::size_t n) { points.reserve (n); }
439 inline bool empty ()
const {
return points.empty (); }
441 const PointT*
data() const noexcept {
return points.data(); }
457 points.resize(count);
458 if (width * height != count) {
459 width =
static_cast<std::uint32_t
>(count);
479 points.resize(count, value);
480 if (width * height != count) {
487 inline const PointT& operator[] (std::size_t n)
const {
return (points[n]); }
488 inline PointT& operator[] (std::size_t n) {
return (points[n]); }
489 inline const PointT&
at (std::size_t n)
const {
return (points.at (n)); }
490 inline PointT&
at (std::size_t n) {
return (points.at (n)); }
493 inline const PointT&
back ()
const {
return (points.back ()); }
504 points.assign(count, value);
505 width =
static_cast<std::uint32_t
>(size());
516 template <
class InputIt>
520 points.assign(std::move(first), std::move(last));
521 width =
static_cast<std::uint32_t
>(size());
531 assign(std::initializer_list<PointT> ilist)
533 points.assign(std::move(ilist));
534 width =
static_cast<std::uint32_t
>(size());
545 points.push_back (pt);
555 template <
class... Args>
inline reference
558 points.emplace_back (std::forward<Args> (args)...);
561 return points.back();
573 iterator it = points.insert (position, pt);
588 points.insert (position, n, pt);
599 template <
class InputIterator>
inline void
602 points.insert (position, first, last);
613 template <
class... Args>
inline iterator
616 iterator it = points.emplace (position, std::forward<Args> (args)...);
630 iterator it = points.erase (position);
645 iterator it = points.erase (first, last);
657 std::swap (header, rhs.
header);
658 this->points.swap (rhs.
points);
659 std::swap (width, rhs.
width);
660 std::swap (height, rhs.
height);
687 template <
typename Po
intT> std::ostream&
690 s <<
"header: " << p.
header << std::endl;
691 s <<
"points[]: " << p.
size () << std::endl;
692 s <<
"width: " << p.
width << std::endl;
693 s <<
"height: " << p.
height << std::endl;
694 s <<
"is_dense: " << p.
is_dense << std::endl;
695 s <<
"sensor origin (xyz): [" <<
708 #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).
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)
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.
const_reverse_iterator rend() const noexcept
const Eigen::Map< const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > getMatrixXfMap() const
typename VectorType::size_type size_type
const_iterator end() const noexcept
const PointT & back() const
Eigen::Map< Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> > getMatrixXfMap()
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).
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
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.
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)