10#ifndef opengl_CPointCloudColoured_H
11#define opengl_CPointCloudColoured_H
45 public
mrpt::utils::PLY_Importer,
46 public
mrpt::utils::PLY_Exporter
54 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) { }
80 m_last_rendered_count(0),
81 m_last_rendered_count_ongoing(0)
94 this->octree_getBoundingBox(bb_min, bb_max);
101 void push_back(
float x,
float y,
float z,
float R,
float G,
float B);
104 inline void resize(
size_t N) { m_points.resize(N); markAllPointsAsNew(); }
107 inline void reserve(
size_t N) { m_points.reserve(N); }
139 markAllPointsAsNew();
143 inline void setPoint_fast(
const size_t i,
const float x,
const float y,
const float z ) {
146 markAllPointsAsNew();
159 R = m_points[index].R;
160 G = m_points[index].G;
161 B = m_points[index].B;
164 inline size_t size()
const {
return m_points.size(); }
166 inline void clear() { m_points.clear(); markAllPointsAsNew(); }
169 template <
class POINTSMAP>
170 void loadFromPointsMap(
const POINTSMAP *themap);
197 void render_subset(const
bool all, const
std::vector<
size_t>& idxs, const
float render_area_sqpixels ) const;
244 static const int HAS_RGB = 1;
245 static const int HAS_RGBf = 1;
246 static const int HAS_RGBu8 = 0;
251 inline size_t size()
const {
return m_obj.
size(); }
256 template <
typename T>
257 inline void getPointXYZ(
const size_t idx, T &x,T &y, T &z)
const {
269 template <
typename T>
270 inline void getPointXYZ_RGBf(
const size_t idx, T &x,T &y, T &z,
float &r,
float &g,
float &b)
const {
272 x=pc.
x; y=pc.
y; z=pc.
z;
273 r=pc.
R; g=pc.
G; b=pc.
B;
281 template <
typename T>
284 x=pc.
x; y=pc.
y; z=pc.
z;
285 r=pc.
R*255; g=pc.
G*255; b=pc.
B*255;
301 r=R*255; g=G*255; b=B*255;
313 template <
class POINTSMAP>
314 void CPointCloudColoured::loadFromPointsMap(
const POINTSMAP *themap)
318 const size_t N=pc_src.size();
320 for (
size_t i=0;i<N;i++)
323 pc_src.getPointXYZ_RGBf(i,x,y,z,r,g,b);
324 pc_dst.setPointXYZ_RGBf(i,x,y,z,r,g,b);
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
#define MRPT_DECLARE_TTYPENAME_NAMESPACE(_TYPE, __NS)
Template class that implements the data structure and algorithms for Octree-based efficient rendering...
A cloud of points, each one with an individual colour (R,G,B).
void clear()
Erase all the points.
CPointCloudColoured()
Constructor.
std::vector< TPointColour > TListPointColour
TListPointColour::const_iterator const_iterator
void getPointColor_fast(size_t index, float &R, float &G, float &B) const
Like getPointColor but without checking for out-of-index erors.
mrpt::math::TPoint3Df getPointf(size_t i) const
Read access to each individual point (checks for "i" in the valid range only in Debug).
TListPointColour m_points
size_t getActuallyRendered() const
Get the number of elements actually rendered in the last render event.
float getPointSize() const
float m_pointSize
By default is 1.0.
void setPoint_fast(const size_t i, const TPointColour &p)
Like setPoint() but does not check for index out of bounds.
volatile size_t m_last_rendered_count
void render() const MRPT_OVERRIDE
Render.
void disablePointSmooth()
void reserve(size_t N)
Like STL std::vector's reserve.
virtual ~CPointCloudColoured()
Private, virtual destructor: only can be deleted from smart pointers.
void recolorizeByCoordinate(const float coord_min, const float coord_max, const int coord_index=2, const mrpt::utils::TColormap color_map=mrpt::utils::cmJET)
Regenerates the color of each point according the one coordinate (coord_index:0,1,...
bool m_pointSmooth
Default: false.
void enablePointSmooth(bool enable=true)
void markAllPointsAsNew()
Do needed internal work if all points are new (octree rebuilt,...)
virtual void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
const TPointColour & getPoint(size_t i) const
Read access to each individual point (checks for "i" in the valid range only in Debug).
void resize(size_t N)
Set the number of points, with undefined contents.
void setPoint_fast(const size_t i, const float x, const float y, const float z)
Like setPoint() but does not check for index out of bounds.
size_t size() const
Return the number of points.
bool isPointSmoothEnabled() const
void push_back(float x, float y, float z, float R, float G, float B)
Inserts a new point into the point cloud.
virtual void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::utils::TColorf *pt_color=NULL) MRPT_OVERRIDE
In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point.
void PLY_export_get_vertex(const size_t idx, mrpt::math::TPoint3Df &pt, bool &pt_has_color, mrpt::utils::TColorf &pt_color) const MRPT_OVERRIDE
In a base class, will be called after PLY_export_get_vertex_count() once for each exported point.
void setPointColor_fast(size_t index, float R, float G, float B)
Like setPointColor but without checking for out-of-index erors.
size_t PLY_export_get_vertex_count() const MRPT_OVERRIDE
In a base class, return the number of vertices.
void setPoint(size_t i, const TPointColour &p)
Write an individual point (checks for "i" in the valid range only in Debug).
TListPointColour::iterator iterator
void setPointSize(float pointSize)
const_iterator begin() const
const_iterator end() const
The base class of 3D objects that can be directly rendered through OpenGL.
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_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.
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 setPointRGBf(const size_t idx, const float r, const float g, const float b)
Set XYZ_RGBf coordinates of i'th point.
size_t size() const
Get number of points.
PointCloudAdapter(const mrpt::opengl::CPointCloudColoured &obj)
Constructor (accept a const ref for convenience)
void getPointXYZ(const size_t idx, T &x, T &y, T &z) const
Get XYZ 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.
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.
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 setPointRGBu8(const size_t idx, const uint8_t r, const uint8_t g, const uint8_t b)
Set RGBu8 coordinates of i'th point.
mrpt::opengl::CPointCloudColoured & 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.
An adapter to different kinds of point cloud object.
TColormap
Different colormaps.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
#define ASSERT_BELOW_(__A, __B)
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
The namespace for 3D scene representation and rendering.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Lightweight 3D point (float version).
TPointColour(float _x, float _y, float _z, float _R, float _G, float _B)
A RGB color - floats in the range [0,1].