40 #ifndef PCL_POINT_CLOUD_H_
41 #define PCL_POINT_CLOUD_H_
52 #include <boost/shared_ptr.hpp>
54 #include <boost/mpl/size.hpp>
70 typedef std::vector<detail::FieldMapping>
MsgFieldMap;
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_;
103 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
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_;
135 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
140 template <
typename Po
intT> boost::shared_ptr<pcl::MsgFieldMap>&
177 template <
typename Po
intT>
218 const std::vector<int> &indices) :
224 assert (indices.size () <= pc.
size ());
225 for (
size_t i = 0; i < indices.size (); i++)
236 ,
points (width_ * height_, value_)
260 size_t nr_points =
points.size ();
262 for (
size_t i = nr_points; i <
points.size (); ++i)
292 at (
int column,
int row)
const
295 return (
points.at (row * this->width + column));
306 at (
int column,
int row)
309 return (
points.at (row * this->width + column));
363 inline Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
366 if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit)
367 return (Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(reinterpret_cast<float*>(&
points[0])+offset,
points.size (), dim, Eigen::OuterStride<> (stride)));
369 return (Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(reinterpret_cast<float*>(&
points[0])+offset, dim,
points.size (), Eigen::OuterStride<> (stride)));
387 inline const Eigen::Map<const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
390 if (Eigen::MatrixXf::Flags & Eigen::RowMajorBit)
391 return (Eigen::Map<
const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(reinterpret_cast<float*>(&
points[0])+offset,
points.size (), dim, Eigen::OuterStride<> (stride)));
393 return (Eigen::Map<
const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >(reinterpret_cast<float*>(&
points[0])+offset, dim,
points.size (), Eigen::OuterStride<> (stride)));
402 inline Eigen::Map<Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
413 inline const Eigen::Map<const Eigen::MatrixXf, Eigen::Aligned, Eigen::OuterStride<> >
423 std::vector<PointT, Eigen::aligned_allocator<PointT> >
points;
439 typedef std::vector<PointT, Eigen::aligned_allocator<PointT> >
VectorType;
440 typedef std::vector<PointCloud<PointT>, Eigen::aligned_allocator<PointCloud<PointT> > >
CloudVectorType;
441 typedef boost::shared_ptr<PointCloud<PointT> >
Ptr;
442 typedef boost::shared_ptr<const PointCloud<PointT> >
ConstPtr;
465 width =
static_cast<uint32_t
> (n);
516 points.insert (position, n, pt);
527 template <
class InputIterator>
inline void
530 points.insert (position, first, last);
597 boost::shared_ptr<MsgFieldMap> mapping_;
602 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
646 template <
typename Po
intT>
648 properties (),
points (Eigen::MatrixXf (0, 0)), channels (),
658 pcl::for_each_type <FieldList> (CopyFieldsChannelProperties <PointT> (channels));
661 points.resize (pc.
points.size (), boost::mpl::size<FieldList>::value);
663 for (
size_t cp = 0; cp < pc.
points.size (); ++cp)
679 template <
typename Po
intT>
681 properties (),
points (Eigen::MatrixXf (0, 0)), channels (),
692 pcl::for_each_type <FieldList> (CopyFieldsChannelProperties <PointT> (channels));
695 points.resize (pc.
points.size (), boost::mpl::size<FieldList>::value);
697 for (
size_t cp = 0; cp < pc.
points.size (); ++cp)
706 const std::vector<int> &indices) :
707 properties (pc.properties),
709 channels (pc.channels),
713 assert (static_cast<int>(indices.size ()) <= pc.
points.rows ());
714 for (
size_t i = 0; i < indices.size (); i++)
723 inline PointCloud (uint32_t _width, uint32_t _height, uint32_t _dim)
725 ,
points (Eigen::MatrixXf (_width * _height, _dim))
738 ,
points (Eigen::MatrixXf (_num_points, _dim))
740 ,
width (_num_points)
756 if (rhs.properties.acquisition_time > properties.acquisition_time)
757 properties.acquisition_time = rhs.properties.acquisition_time;
759 properties.sensor_origin = Eigen::Vector4f::Zero ();
760 properties.sensor_orientation = Eigen::Quaternionf::Identity ();
762 int nr_points =
static_cast<int>(
points.rows ());
764 for (
int i = nr_points; i <
points.rows (); ++i)
767 channels = rhs.channels;
794 inline Eigen::Map<Eigen::VectorXf>
795 at (
int column,
int row)
798 return (Eigen::VectorXf::Map (&
points (row *
width + column, 0),
points.cols ()));
809 inline Eigen::Map<Eigen::VectorXf>
812 return (Eigen::VectorXf::Map (&
points (row *
width + column, 0),
points.cols ()));
830 return (
points.rows () == 0);
840 std::map<std::string, pcl::ChannelProperties>
channels;
850 typedef boost::shared_ptr<PointCloud<Eigen::MatrixXf> >
Ptr;
851 typedef boost::shared_ptr<const PointCloud<Eigen::MatrixXf> >
ConstPtr;
894 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
899 template <
typename Po
intOutT,
typename Po
intInT>
910 p2_ (reinterpret_cast<Pod&>(p2)),
914 template<
typename Key>
inline void
920 *
reinterpret_cast<T*
>(data_ptr) = p1_[f_idx_++];
928 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
933 template <
typename Po
intInT,
typename Po
intOutT>
934 struct NdCopyPointEigenFunctor
936 typedef typename traits::POD<PointInT>::type Pod;
942 NdCopyPointEigenFunctor (
const PointInT &p1, PointOutT p2)
943 : p1_ (reinterpret_cast<const Pod&>(p1)), p2_ (p2), f_idx_ (0) { }
946 template<
typename Key>
inline void
952 p2_[f_idx_++] = *
reinterpret_cast<const T*
>(data_ptr);
960 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
965 template <
typename T>
966 struct CopyFieldsChannelProperties
971 CopyFieldsChannelProperties (std::map<std::string, pcl::ChannelProperties> &channels)
972 : channels_ (channels) {}
975 template<
typename U>
inline void
980 channels_[name].name = name;
983 channels_[name].datatype = datatype;
985 channels_[name].count = count;
991 channels_[name].size = count;
998 channels_[name].size = count * 2;
1006 channels_[name].size = count * 4;
1012 channels_[name].size = count * 8;
1019 std::map<std::string, pcl::ChannelProperties> &channels_;
1026 template <
typename Po
intT> boost::shared_ptr<pcl::MsgFieldMap>&
1029 return (p.mapping_);
1033 template <
typename Po
intT> std::ostream&
1034 operator << (std::ostream& s, const pcl::PointCloud<PointT> &p)
1036 s <<
"points[]: " << p.points.size () << std::endl;
1037 s <<
"width: " << p.width << std::endl;
1038 s <<
"height: " << p.height << std::endl;
1039 s <<
"is_dense: " << p.is_dense << std::endl;
1044 #endif //#ifndef PCL_POINT_CLOUD_H_