29 #ifndef opengl_CPointCloudColoured_H
30 #define opengl_CPointCloudColoured_H
76 inline TPointColour(
float _x,
float _y,
float _z,
float _R,
float _G,
float _B ) : x(_x),y(_y),z(_z),R(_R),G(_G),B(_B) { }
86 inline iterator
begin() {
return m_points.begin(); }
87 inline const_iterator
begin()
const {
return m_points.begin(); }
88 inline iterator
end() {
return m_points.end(); }
89 inline const_iterator
end()
const {
return m_points.end(); }
101 m_pointSmooth(false),
102 m_last_rendered_count(0),
103 m_last_rendered_count_ongoing(0)
109 void markAllPointsAsNew();
117 void push_back(
float x,
float y,
float z,
float R,
float G,
float B);
120 inline void resize(
size_t N) { m_points.resize(N); markAllPointsAsNew(); }
123 inline void reserve(
size_t N) { m_points.reserve(N); }
150 void setPoint(
size_t i,
const TPointColour &p );
155 markAllPointsAsNew();
159 inline void setPoint_fast(
const size_t i,
const float x,
const float y,
const float z ) {
162 markAllPointsAsNew();
166 inline void setPointColor_fast(
size_t index,
float R,
float G,
float B)
173 inline void getPointColor_fast(
size_t index,
float &R,
float &G,
float &B )
const
175 R = m_points[index].R;
176 G = m_points[index].G;
177 B = m_points[index].B;
180 inline size_t size()
const {
return m_points.size(); }
182 inline void clear() { m_points.clear(); markAllPointsAsNew(); }
185 template <
class POINTSMAP>
186 void loadFromPointsMap(
const POINTSMAP *themap);
212 void render_subset(
const bool all,
const std::vector<size_t>& idxs,
const float render_area_sqpixels )
const;
218 virtual void PLY_import_set_vertex_count(
const size_t N);
231 virtual size_t PLY_export_get_vertex_count()
const;
239 virtual void PLY_export_get_vertex(
257 using namespace mrpt::opengl;
273 static const int HAS_RGB = 1;
274 static const int HAS_RGBf = 1;
275 static const int HAS_RGBu8 = 0;
280 inline size_t size()
const {
return m_obj.size(); }
282 inline void resize(
const size_t N) { m_obj.resize(N); }
285 template <
typename T>
286 inline void getPointXYZ(
const size_t idx, T &x,T &y, T &z)
const {
294 m_obj.setPoint_fast(idx, x,y,z);
298 template <
typename T>
299 inline void getPointXYZ_RGBf(
const size_t idx, T &x,T &y, T &z,
float &r,
float &g,
float &b)
const {
301 x=pc.
x; y=pc.
y; z=pc.
z;
302 r=pc.
R; g=pc.
G; b=pc.
B;
310 template <
typename T>
311 inline void getPointXYZ_RGBu8(
const size_t idx, T &x,T &y, T &z, uint8_t &r,uint8_t &g,uint8_t &b)
const {
313 x=pc.
x; y=pc.
y; z=pc.
z;
314 r=pc.
R*255; g=pc.
G*255; b=pc.
B*255;
322 inline void getPointRGBf(
const size_t idx,
float &r,
float &g,
float &b)
const { m_obj.getPointColor_fast(idx,r,g,b); }
324 inline void setPointRGBf(
const size_t idx,
const float r,
const float g,
const float b) { m_obj.setPointColor_fast(idx,r,g,b); }
327 inline void getPointRGBu8(
const size_t idx, uint8_t &r,uint8_t &g,uint8_t &b)
const {
329 m_obj.getPointColor_fast(idx,R,G,B);
330 r=R*255; g=G*255; b=B*255;
333 inline void setPointRGBu8(
const size_t idx,
const uint8_t r,
const uint8_t g,
const uint8_t b) {
334 m_obj.setPointColor_fast(idx,r/255.f,g/255.f,b/255.f);
344 template <
class POINTSMAP>
347 mrpt::utils::PointCloudAdapter<CPointCloudColoured> pc_dst(*
this);
348 const mrpt::utils::PointCloudAdapter<POINTSMAP> pc_src(*themap);
349 const size_t N=pc_src.size();
351 for (
size_t i=0;i<N;i++)
354 pc_src.getPointXYZ_RGBf(i,x,y,z,r,g,b);
355 pc_dst.setPointXYZ_RGBf(i,x,y,z,r,g,b);