28 #ifndef CColouredPointsMap_H
29 #define CColouredPointsMap_H
44 class CObservation3DRangeScan;
63 virtual ~CColouredPointsMap();
77 virtual
void reserve(
size_t newLength);
83 virtual
void resize(
size_t newLength);
92 virtual
void setPointFast(
size_t index,
float x,
float y,
float z)
100 virtual void insertPointFast(
float x,
float y,
float z = 0 );
104 virtual void copyFrom(
const CPointsMap &obj);
110 virtual void getPointAllFieldsFast(
const size_t index, std::vector<float> & point_data )
const {
111 point_data.resize(6);
112 point_data[0] = x[index];
113 point_data[1] = y[index];
114 point_data[2] = z[index];
115 point_data[3] = m_color_R[index];
116 point_data[4] = m_color_G[index];
117 point_data[5] = m_color_B[index];
124 virtual void setPointAllFieldsFast(
const size_t index,
const std::vector<float> & point_data ) {
126 x[index] = point_data[0];
127 y[index] = point_data[1];
128 z[index] = point_data[2];
129 m_color_R[index] = point_data[3];
130 m_color_G[index] = point_data[4];
131 m_color_B[index] = point_data[5];
135 virtual void loadFromRangeScan(
136 const CObservation2DRangeScan &rangeScan,
137 const CPose3D *robotPose = NULL );
140 virtual void loadFromRangeScan(
141 const CObservation3DRangeScan &rangeScan,
142 const CPose3D *robotPose = NULL );
147 virtual void addFrom_classSpecific(
const CPointsMap &anotherMap,
const size_t nPreviousPoints);
151 template <
class Derived>
friend struct detail::loadFromRangeImpl;
152 template <
class Derived>
friend struct detail::pointmap_traits;
163 bool save3D_and_colour_to_text_file(
const std::string &file)
const;
168 virtual void setPoint(
size_t index,
float x,
float y,
float z,
float R,
float G,
float B);
172 inline void setPoint(
size_t index,
float x,
float y,
float z) {
174 setPointFast(index,x,y,z);
186 virtual void insertPoint(
float x,
float y,
float z,
float R,
float G,
float B );
189 inline void insertPoint(
const CPoint3D &p ) { insertPoint(p.x(),p.y(),p.z()); }
193 inline void insertPoint(
float x,
float y,
float z) { insertPointFast(x,y,z); mark_as_modified(); }
198 void setPointColor(
size_t index,
float R,
float G,
float B);
201 inline void setPointColor_fast(
size_t index,
float R,
float G,
float B)
203 this->m_color_R[index]=R;
204 this->m_color_G[index]=G;
205 this->m_color_B[index]=B;
210 virtual void getPoint(
size_t index,
float &x,
float &y,
float &z,
float &R,
float &G,
float &B )
const;
213 unsigned long getPoint(
size_t index,
float &x,
float &y,
float &z)
const;
216 void getPointColor(
size_t index,
float &R,
float &G,
float &B )
const;
219 inline void getPointColor_fast(
size_t index,
float &R,
float &G,
float &B )
const
221 R = m_color_R[index];
222 G = m_color_G[index];
223 B = m_color_B[index];
236 bool colourFromObservation(
const CObservationImage &obs,
const CPose3D &robotPose );
243 enum TColouringMethod
245 cmFromHeightRelativeToSensor = 0,
246 cmFromHeightRelativeToSensorJet = 0,
247 cmFromHeightRelativeToSensorGray = 1,
248 cmFromIntensityImage = 2
259 void loadFromConfigFile(
261 const std::string §ion);
265 void dumpToTextStream(
CStream &out)
const;
272 TColourOptions colorScheme;
274 void resetPointsMinDist(
float defValue = 2000.0f );
280 virtual bool savePCDFile(
const std::string &filename,
bool save_as_binary)
const;
287 std::vector<float> m_color_R,m_color_G,m_color_B;
294 virtual void internal_clear();
304 virtual void PLY_import_set_vertex_count(
const size_t N);
312 virtual void PLY_export_get_vertex(
334 static const int HAS_RGB = 1;
335 static const int HAS_RGBf = 1;
336 static const int HAS_RGBu8 = 0;
341 inline size_t size()
const {
return m_obj.size(); }
343 inline void resize(
const size_t N) { m_obj.resize(N); }
346 template <
typename T>
347 inline void getPointXYZ(
const size_t idx, T &x,T &y, T &z)
const {
348 m_obj.getPointFast(idx,x,y,z);
352 m_obj.setPointFast(idx,x,y,z);
356 template <
typename T>
357 inline void getPointXYZ_RGBf(
const size_t idx, T &x,T &y, T &z,
float &r,
float &g,
float &b)
const {
358 m_obj.getPoint(idx,x,y,z,r,g,b);
362 m_obj.setPoint(idx,x,y,z,r,g,b);
366 template <
typename T>
367 inline void getPointXYZ_RGBu8(
const size_t idx, T &x,T &y, T &z, uint8_t &r,uint8_t &g,uint8_t &b)
const {
369 m_obj.getPoint(idx,x,y,z,Rf,Gf,Bf);
370 r=Rf*255; g=Gf*255; b=Bf*255;
374 m_obj.setPoint(idx,x,y,z,r/255.f,g/255.f,b/255.f);
378 inline void getPointRGBf(
const size_t idx,
float &r,
float &g,
float &b)
const { m_obj.getPointColor_fast(idx,r,g,b); }
380 inline void setPointRGBf(
const size_t idx,
const float r,
const float g,
const float b) { m_obj.setPointColor_fast(idx,r,g,b); }
383 inline void getPointRGBu8(
const size_t idx, uint8_t &r,uint8_t &g,uint8_t &b)
const {
385 m_obj.getPointColor_fast(idx,R,G,B);
386 r=R*255; g=G*255; b=B*255;
389 inline void setPointRGBu8(
const size_t idx,
const uint8_t r,
const uint8_t g,
const uint8_t b) {
390 m_obj.setPointColor_fast(idx,r/255.f,g/255.f,b/255.f);