00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef mrpt_maps_PCL_adapters_H
00029 #define mrpt_maps_PCL_adapters_H
00030
00031 #include <mrpt/config.h>
00032 #include <mrpt/utils/adapters.h>
00033
00034
00035
00036
00037
00038 #include <pcl/point_types.h>
00039 #include <pcl/point_cloud.h>
00040
00041 namespace mrpt
00042 {
00043 namespace utils
00044 {
00045
00046 template <>
00047 class PointCloudAdapter<pcl::PointCloud<pcl::PointXYZ> > : public detail::PointCloudAdapterHelperNoRGB<pcl::PointCloud<pcl::PointXYZ>,float>
00048 {
00049 private:
00050 pcl::PointCloud<pcl::PointXYZ> &m_obj;
00051 public:
00052 typedef float coords_t;
00053 static const int HAS_RGB = 0;
00054 static const int HAS_RGBf = 0;
00055 static const int HAS_RGBu8 = 0;
00056
00057
00058 inline PointCloudAdapter(const pcl::PointCloud<pcl::PointXYZ> &obj) : m_obj(*const_cast<pcl::PointCloud<pcl::PointXYZ>*>(&obj)) { }
00059
00060 inline size_t size() const { return m_obj.points.size(); }
00061
00062 inline void resize(const size_t N) { m_obj.points.resize(N); }
00063
00064
00065 template <typename T>
00066 inline void getPointXYZ(const size_t idx, T &x,T &y, T &z) const {
00067 const pcl::PointXYZ &p=m_obj.points[idx];
00068 x=p.x; y=p.y; z=p.z;
00069 }
00070
00071 inline void setPointXYZ(const size_t idx, const coords_t x,const coords_t y, const coords_t z) {
00072 pcl::PointXYZ &p=m_obj.points[idx];
00073 p.x=x; p.y=y; p.z=z;
00074 }
00075 };
00076
00077
00078
00079 template <>
00080 class PointCloudAdapter<pcl::PointCloud<pcl::PointXYZRGB> >
00081 {
00082 private:
00083 pcl::PointCloud<pcl::PointXYZRGB> &m_obj;
00084 public:
00085 typedef float coords_t;
00086 static const int HAS_RGB = 1;
00087 static const int HAS_RGBf = 0;
00088 static const int HAS_RGBu8 = 1;
00089
00090
00091 inline PointCloudAdapter(const pcl::PointCloud<pcl::PointXYZRGB> &obj) : m_obj(*const_cast<pcl::PointCloud<pcl::PointXYZRGB>*>(&obj)) { }
00092
00093 inline size_t size() const { return m_obj.points.size(); }
00094
00095 inline void resize(const size_t N) { m_obj.points.resize(N); }
00096
00097
00098 template <typename T>
00099 inline void getPointXYZ(const size_t idx, T &x,T &y, T &z) const {
00100 const pcl::PointXYZRGB &p=m_obj.points[idx];
00101 x=p.x; y=p.y; z=p.z;
00102 }
00103
00104 inline void setPointXYZ(const size_t idx, const coords_t x,const coords_t y, const coords_t z) {
00105 pcl::PointXYZRGB &p=m_obj.points[idx];
00106 p.x=x; p.y=y; p.z=z;
00107 p.r=p.g=p.b=255;
00108 }
00109
00110
00111 template <typename T>
00112 inline void getPointXYZ_RGBf(const size_t idx, T &x,T &y, T &z, float &r,float &g,float &b) const {
00113 const pcl::PointXYZRGB &p=m_obj.points[idx];
00114 x=p.x; y=p.y; z=p.z;
00115 r=p.r/255.f; g=p.g/255.f; b=p.b/255.f;
00116 }
00117
00118 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) {
00119 pcl::PointXYZRGB &p=m_obj.points[idx];
00120 p.x=x; p.y=y; p.z=z;
00121 p.r=r*255; p.g=g*255; p.b=b*255;
00122 }
00123
00124
00125 template <typename T>
00126 inline void getPointXYZ_RGBu8(const size_t idx, T &x,T &y, T &z, uint8_t &r,uint8_t &g,uint8_t &b) const {
00127 const pcl::PointXYZRGB &p=m_obj.points[idx];
00128 x=p.x; y=p.y; z=p.z;
00129 r=p.r; g=p.g; b=p.b;
00130 }
00131
00132 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) {
00133 pcl::PointXYZRGB &p=m_obj.points[idx];
00134 p.x=x; p.y=y; p.z=z;
00135 p.r=r; p.g=g; p.b=b;
00136 }
00137
00138
00139 inline void getPointRGBf(const size_t idx, float &r,float &g,float &b) const {
00140 const pcl::PointXYZRGB &p=m_obj.points[idx];
00141 r=p.r/255.f; g=p.g/255.f; b=p.b/255.f;
00142 }
00143
00144 inline void setPointRGBf(const size_t idx, const float r,const float g,const float b) {
00145 pcl::PointXYZRGB &p=m_obj.points[idx];
00146 p.r=r*255; p.g=g*255; p.b=b*255;
00147 }
00148
00149
00150 inline void getPointRGBu8(const size_t idx, uint8_t &r,uint8_t &g,uint8_t &b) const {
00151 const pcl::PointXYZRGB &p=m_obj.points[idx];
00152 r=p.r; g=p.g; b=p.b;
00153 }
00154
00155 inline void setPointRGBu8(const size_t idx,const uint8_t r,const uint8_t g,const uint8_t b) {
00156 pcl::PointXYZRGB &p=m_obj.points[idx];
00157 p.r=r; p.g=g; p.b=b;
00158 }
00159
00160 };
00161
00162 }
00163 }
00164
00165 #endif