34 #if MRPT_HAS_OPENGL_GLUT
35 octree_assure_uptodate();
36 m_last_rendered_count_ongoing = 0;
69 m_last_rendered_count = m_last_rendered_count_ongoing;
77 const bool all,
const std::vector<size_t>& idxs,
78 const float render_area_sqpixels)
const
80 #if MRPT_HAS_OPENGL_GLUT
81 const size_t N = all ? m_points.size() : idxs.size();
84 1.0f,
static_cast<float>(
87 render_area_sqpixels))));
89 m_last_rendered_count_ongoing += N / decimation;
91 m_last_rendered_count_ongoing +=
92 (all ? m_points.size() : idxs.size()) / decimation;
96 for (
size_t i = 0; i < N; i += decimation)
105 for (
size_t i = 0; i < N; i += decimation)
130 writeToStreamRender(out);
133 out << m_pointSmooth;
148 readFromStreamRender(
in);
149 in >> m_points >> m_pointSize;
154 m_pointSmooth =
false;
159 readFromStreamRender(
in);
165 for (
uint32_t i = 0; i < n; i++) in >> m_points[i];
173 markAllPointsAsNew();
179 in >> o.
x >> o.
y >> o.
z >> o.
R >> o.
G >> o.
B;
186 out << o.
x << o.
y << o.
z << o.
R << o.
G << o.
B;
201 markAllPointsAsNew();
206 float x,
float y,
float z,
float R,
float G,
float B)
212 markAllPointsAsNew();
238 pt.
x, pt.
y, pt.
z, pt_color->
R, pt_color->
G, pt_color->
B));
267 const float coord_min,
const float coord_max,
const int coord_index,
273 const float coord_range = coord_max - coord_min;
274 const float coord_range_1 = coord_range != 0.0f ? 1.0f / coord_range : 1.0f;
275 for (
size_t i = 0; i < m_points.size(); i++)
281 coord = m_points[i].x;
284 coord = m_points[i].y;
287 coord = m_points[i].z;
290 const float col_idx =
291 std::max(0.0f,
std::min(1.0f, (
coord - coord_min) * coord_range_1));
294 this->setPointColor_fast(i,
r,
g,
b);
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
A cloud of points, each one with an individual colour (R,G,B).
void markAllPointsAsNew()
Do needed internal work if all points are new (octree rebuilt,...)
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,...
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
void PLY_export_get_vertex(const size_t idx, mrpt::math::TPoint3Df &pt, bool &pt_has_color, mrpt::utils::TColorf &pt_color) const override
In a base class, will be called after PLY_export_get_vertex_count() once for each exported point.
size_t PLY_export_get_vertex_count() const override
In a base class, return the number of vertices.
void render_subset(const bool all, const std::vector< size_t > &idxs, const float render_area_sqpixels) const
Render a subset of points (required by octree renderer)
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
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_count(const size_t N) override
In a base class, reserve memory to prepare subsequent calls to PLY_import_set_vertex.
virtual void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::utils::TColorf *pt_color=nullptr) override
In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point.
void setPoint(size_t i, const TPointColour &p)
Write an individual point (checks for "i" in the valid range only in Debug).
The base class of 3D objects that can be directly rendered through OpenGL.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glPointSize(GLfloat size)
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
#define GL_ONE_MINUS_SRC_ALPHA
GLAPI void GLAPIENTRY glEnd(void)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
GLdouble GLdouble GLdouble r
TColormap
Different colormaps for use in mrpt::utils::colormap()
void colormap(const TColormap &color_map, const float color_index, float &r, float &g, float &b)
Transform a float number in the range [0,1] into RGB components.
void OCTREE_RENDER_MAX_DENSITY_POINTS_PER_SQPIXEL(float value)
Default value = 0.01 points/px^2.
int round(const T value)
Returns the closer integer (int) to x.
#define ASSERT_BELOW_(__A, __B)
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
#define MRPT_UNUSED_PARAM(a)
Can be used to avoid "not used parameters" warnings from the compiler.
#define ASSERT_ABOVEEQ_(__A, __B)
Global variables to change the run-time behaviour of some MRPT classes within mrpt-base.
This base provides a set of functions for maths stuff.
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
void getCurrentRenderingInfo(TRenderInfo &ri)
Gather useful information on the render parameters.
The namespace for 3D scene representation and rendering.
mrpt::utils::CStream & operator<<(mrpt::utils::CStream &out, const mrpt::opengl::CLight &o)
mrpt::utils::CStream & operator>>(mrpt::utils::CStream &in, mrpt::opengl::CLight &o)
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values,...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
This file implements several operations that operate element-wise on individual or pairs of container...
unsigned __int32 uint32_t
Lightweight 3D point (float version).
Information about the rendering process being issued.
A RGB color - floats in the range [0,1].