9 #ifndef mrpt_maps_PCL_adapters_H 10 #define mrpt_maps_PCL_adapters_H 12 #include <mrpt/config.h> 19 #include <pcl/point_types.h> 20 #include <pcl/point_cloud.h> 31 pcl::PointCloud<pcl::PointXYZ> &
m_obj;
34 static const int HAS_RGB = 0;
35 static const int HAS_RGBf = 0;
36 static const int HAS_RGBu8 = 0;
39 inline PointCloudAdapter(
const pcl::PointCloud<pcl::PointXYZ> &obj) : m_obj(*const_cast<pcl::PointCloud<pcl::PointXYZ>*>(&obj)) { }
41 inline size_t size()
const {
return m_obj.points.size(); }
43 inline void resize(
const size_t N) { m_obj.points.resize(N); }
47 inline void getPointXYZ(
const size_t idx, T &x,T &y, T &z)
const {
48 const pcl::PointXYZ &p=m_obj.points[idx];
52 inline void setPointXYZ(
const size_t idx,
const coords_t x,
const coords_t y,
const coords_t z) {
53 pcl::PointXYZ &p=m_obj.points[idx];
64 pcl::PointCloud<pcl::PointXYZRGB> &
m_obj;
67 static const int HAS_RGB = 1;
68 static const int HAS_RGBf = 0;
69 static const int HAS_RGBu8 = 1;
72 inline PointCloudAdapter(
const pcl::PointCloud<pcl::PointXYZRGB> &obj) : m_obj(*const_cast<pcl::PointCloud<pcl::PointXYZRGB>*>(&obj)) { }
74 inline size_t size()
const {
return m_obj.points.size(); }
76 inline void resize(
const size_t N) { m_obj.points.resize(N); }
80 inline void getPointXYZ(
const size_t idx, T &x,T &y, T &z)
const {
81 const pcl::PointXYZRGB &p=m_obj.points[idx];
85 inline void setPointXYZ(
const size_t idx,
const coords_t x,
const coords_t y,
const coords_t z) {
86 pcl::PointXYZRGB &p=m_obj.points[idx];
93 inline void getPointXYZ_RGBf(
const size_t idx, T &x,T &y, T &z,
float &r,
float &g,
float &b)
const {
94 const pcl::PointXYZRGB &p=m_obj.points[idx];
96 r=p.r/255.f; g=p.g/255.f; b=p.b/255.f;
99 inline void setPointXYZ_RGBf(
const size_t idx,
const coords_t x,
const coords_t y,
const coords_t z,
const float r,
const float g,
const float b) {
100 pcl::PointXYZRGB &p=m_obj.points[idx];
102 p.r=r*255; p.g=g*255; p.b=b*255;
106 template <
typename T>
107 inline void getPointXYZ_RGBu8(
const size_t idx, T &x,T &y, T &z, uint8_t &r,uint8_t &g,uint8_t &b)
const {
108 const pcl::PointXYZRGB &p=m_obj.points[idx];
113 inline void setPointXYZ_RGBu8(
const size_t idx,
const coords_t x,
const coords_t y,
const coords_t z,
const uint8_t r,
const uint8_t g,
const uint8_t b) {
114 pcl::PointXYZRGB &p=m_obj.points[idx];
120 inline void getPointRGBf(
const size_t idx,
float &r,
float &g,
float &b)
const {
121 const pcl::PointXYZRGB &p=m_obj.points[idx];
122 r=p.r/255.f; g=p.g/255.f; b=p.b/255.f;
125 inline void setPointRGBf(
const size_t idx,
const float r,
const float g,
const float b) {
126 pcl::PointXYZRGB &p=m_obj.points[idx];
127 p.r=r*255; p.g=g*255; p.b=b*255;
131 inline void getPointRGBu8(
const size_t idx, uint8_t &r,uint8_t &g,uint8_t &b)
const {
132 const pcl::PointXYZRGB &p=m_obj.points[idx];
136 inline void setPointRGBu8(
const size_t idx,
const uint8_t r,
const uint8_t g,
const uint8_t b) {
137 pcl::PointXYZRGB &p=m_obj.points[idx];
149 pcl::PointCloud<pcl::PointXYZRGBA> &
m_obj;
152 static const int HAS_RGB = 1;
153 static const int HAS_RGBf = 0;
154 static const int HAS_RGBu8 = 1;
157 inline PointCloudAdapter(
const pcl::PointCloud<pcl::PointXYZRGBA> &obj) : m_obj(*const_cast<pcl::PointCloud<pcl::PointXYZRGBA>*>(&obj)) { }
159 inline size_t size()
const {
return m_obj.points.size(); }
161 inline void resize(
const size_t N) { m_obj.points.resize(N); }
164 template <
typename T>
165 inline void getPointXYZ(
const size_t idx, T &x,T &y, T &z)
const {
166 const pcl::PointXYZRGBA &p=m_obj.points[idx];
170 inline void setPointXYZ(
const size_t idx,
const coords_t x,
const coords_t y,
const coords_t z) {
171 pcl::PointXYZRGBA &p=m_obj.points[idx];
177 template <
typename T>
178 inline void getPointXYZ_RGBf(
const size_t idx, T &x,T &y, T &z,
float &r,
float &g,
float &b)
const {
179 const pcl::PointXYZRGBA &p=m_obj.points[idx];
181 r=p.r/255.f; g=p.g/255.f; b=p.b/255.f;
184 inline void setPointXYZ_RGBf(
const size_t idx,
const coords_t x,
const coords_t y,
const coords_t z,
const float r,
const float g,
const float b) {
185 pcl::PointXYZRGBA &p=m_obj.points[idx];
187 p.r=r*255; p.g=g*255; p.b=b*255;
191 template <
typename T>
192 inline void getPointXYZ_RGBu8(
const size_t idx, T &x,T &y, T &z, uint8_t &r,uint8_t &g,uint8_t &b)
const {
193 const pcl::PointXYZRGBA &p=m_obj.points[idx];
198 inline void setPointXYZ_RGBu8(
const size_t idx,
const coords_t x,
const coords_t y,
const coords_t z,
const uint8_t r,
const uint8_t g,
const uint8_t b) {
199 pcl::PointXYZRGBA &p=m_obj.points[idx];
205 inline void getPointRGBf(
const size_t idx,
float &r,
float &g,
float &b)
const {
206 const pcl::PointXYZRGBA &p=m_obj.points[idx];
207 r=p.r/255.f; g=p.g/255.f; b=p.b/255.f;
210 inline void setPointRGBf(
const size_t idx,
const float r,
const float g,
const float b) {
211 pcl::PointXYZRGBA &p=m_obj.points[idx];
212 p.r=r*255; p.g=g*255; p.b=b*255;
216 inline void getPointRGBu8(
const size_t idx, uint8_t &r,uint8_t &g,uint8_t &b)
const {
217 const pcl::PointXYZRGBA &p=m_obj.points[idx];
221 inline void setPointRGBu8(
const size_t idx,
const uint8_t r,
const uint8_t g,
const uint8_t b) {
222 pcl::PointXYZRGBA &p=m_obj.points[idx];
pcl::PointCloud< pcl::PointXYZ > & m_obj
void setPointXYZ_RGBu8(const size_t idx, const coords_t x, const coords_t y, const coords_t z, const uint8_t r, const uint8_t g, const uint8_t b)
Set XYZ_RGBu8 coordinates of i'th point.
void resize(const size_t N)
Set number of points (to uninitialized values)
float coords_t
The type of each point XYZ coordinates.
void getPointRGBf(const size_t idx, float &r, float &g, float &b) const
Get RGBf color of i'th point.
A helper base class for those PointCloudAdapter<> which do not handle RGB data; it declares needed in...
void getPointXYZ(const size_t idx, T &x, T &y, T &z) const
Get XYZ coordinates of i'th point.
void getPointXYZ(const size_t idx, T &x, T &y, T &z) const
Get XYZ coordinates of i'th point.
float coords_t
The type of each point XYZ coordinates.
void setPointXYZ(const size_t idx, const coords_t x, const coords_t y, const coords_t z)
Set XYZ coordinates of i'th point.
void setPointXYZ_RGBu8(const size_t idx, const coords_t x, const coords_t y, const coords_t z, const uint8_t r, const uint8_t g, const uint8_t b)
Set XYZ_RGBu8 coordinates of i'th point.
void resize(const size_t N)
Set number of points (to uninitialized values)
PointCloudAdapter(const pcl::PointCloud< pcl::PointXYZRGB > &obj)
Constructor (accept a const ref for convenience)
size_t size() const
Get number of points.
void getPointRGBu8(const size_t idx, uint8_t &r, uint8_t &g, uint8_t &b) const
Get RGBu8 color of i'th point.
void getPointXYZ_RGBf(const size_t idx, T &x, T &y, T &z, float &r, float &g, float &b) const
Get XYZ_RGBf coordinates of i'th point.
void getPointRGBu8(const size_t idx, uint8_t &r, uint8_t &g, uint8_t &b) const
Get RGBu8 color of i'th point.
PointCloudAdapter(const pcl::PointCloud< pcl::PointXYZ > &obj)
Constructor (accept a const ref for convenience)
void setPointRGBf(const size_t idx, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i'th point.
void setPointXYZ_RGBf(const size_t idx, const coords_t x, const coords_t y, const coords_t z, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i'th point.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void getPointXYZ_RGBu8(const size_t idx, T &x, T &y, T &z, uint8_t &r, uint8_t &g, uint8_t &b) const
Get XYZ_RGBu8 coordinates of i'th point.
size_t size() const
Get number of points.
void resize(const size_t N)
Set number of points (to uninitialized values)
void getPointXYZ_RGBu8(const size_t idx, T &x, T &y, T &z, uint8_t &r, uint8_t &g, uint8_t &b) const
Get XYZ_RGBu8 coordinates of i'th point.
pcl::PointCloud< pcl::PointXYZRGBA > & m_obj
void setPointXYZ_RGBf(const size_t idx, const coords_t x, const coords_t y, const coords_t z, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i'th point.
PointCloudAdapter(const pcl::PointCloud< pcl::PointXYZRGBA > &obj)
Constructor (accept a const ref for convenience)
void setPointXYZ(const size_t idx, const coords_t x, const coords_t y, const coords_t z)
Set XYZ coordinates of i'th point.
size_t size() const
Get number of points.
void setPointRGBu8(const size_t idx, const uint8_t r, const uint8_t g, const uint8_t b)
Set RGBu8 coordinates of i'th point.
void getPointXYZ_RGBf(const size_t idx, T &x, T &y, T &z, float &r, float &g, float &b) const
Get XYZ_RGBf coordinates of i'th point.
An adapter to different kinds of point cloud object.
void setPointXYZ(const size_t idx, const coords_t x, const coords_t y, const coords_t z)
Set XYZ coordinates of i'th point.
void getPointRGBf(const size_t idx, float &r, float &g, float &b) const
Get RGBf color of i'th point.
pcl::PointCloud< pcl::PointXYZRGB > & m_obj
void setPointRGBu8(const size_t idx, const uint8_t r, const uint8_t g, const uint8_t b)
Set RGBu8 coordinates of i'th point.
float coords_t
The type of each point XYZ coordinates.
void setPointRGBf(const size_t idx, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i'th point.
void getPointXYZ(const size_t idx, T &x, T &y, T &z) const
Get XYZ coordinates of i'th point.