59 m_last_rendered_count(0),
60 m_last_rendered_count_ongoing(0),
65 m_minmax_valid(false),
66 m_colorFromDepth_min(0, 0, 0),
67 m_colorFromDepth_max(0, 0, 1)
77 #if MRPT_HAS_OPENGL_GLUT
79 ASSERT_(m_xs.size() == m_ys.size());
80 ASSERT_(m_xs.size() == m_zs.size());
82 octree_assure_uptodate();
83 m_last_rendered_count_ongoing = 0;
93 m_minmax_valid =
true;
104 m_max_m_min = m_max - m_min;
105 if (std::abs(m_max_m_min) < 1e-4)
108 m_min = m_max - m_max_m_min * 1.01f;
109 m_max_m_min_inv = 1.0 / m_max_m_min;
112 if (m_color.A != 255)
123 m_col_slop.R = m_colorFromDepth_max.R - m_colorFromDepth_min.R;
124 m_col_slop.G = m_colorFromDepth_max.G - m_colorFromDepth_min.G;
125 m_col_slop.B = m_colorFromDepth_max.B - m_colorFromDepth_min.B;
127 m_col_slop_inv.R = m_col_slop.R != 0 ? 1.0f / m_col_slop.R : 0;
128 m_col_slop_inv.G = m_col_slop.G != 0 ? 1.0f / m_col_slop.G : 0;
129 m_col_slop_inv.B = m_col_slop.B != 0 ? 1.0f / m_col_slop.B : 0;
142 m_color.R, m_color.G, m_color.B,
153 m_last_rendered_count = m_last_rendered_count_ongoing;
161 #if MRPT_HAS_OPENGL_GLUT
162 if (m_colorFromDepth != colNone && m_max_m_min > 0)
164 const float depthCol =
165 (m_colorFromDepth == colX
167 : (m_colorFromDepth == colY ? m_ys[i] : m_zs[i]));
169 float f = (depthCol - m_min) * m_max_m_min_inv;
170 f = std::max(0.0f,
min(1.0f, f));
173 m_colorFromDepth_min.R + f * m_col_slop_inv.R,
174 m_colorFromDepth_min.G + f * m_col_slop_inv.G,
175 m_colorFromDepth_min.B + f * m_col_slop_inv.B,
176 m_color.A * (1.0f / 255.f));
186 const bool all,
const std::vector<size_t>& idxs,
187 const float render_area_sqpixels)
const
189 #if MRPT_HAS_OPENGL_GLUT
191 const size_t N = (all ? m_xs.size() : idxs.size());
194 1.0f,
static_cast<float>(
196 render_area_sqpixels))));
198 m_last_rendered_count_ongoing += N / decimation;
202 for (
size_t i = 0; i < N; i++) internal_render_one_point(i);
206 const size_t Np = idxs.size();
207 for (
size_t i = 0; i < Np; i += decimation)
208 internal_render_one_point(idxs[i]);
227 writeToStreamRender(out);
229 out << static_cast<int32_t>(m_colorFromDepth);
230 out << m_xs << m_ys << m_zs;
236 out << m_colorFromDepth_min.R << m_colorFromDepth_min.G
237 << m_colorFromDepth_min.B;
238 out << m_colorFromDepth_max.R << m_colorFromDepth_max.G
239 << m_colorFromDepth_max.B;
242 out << m_pointSmooth;
260 readFromStreamRender(
in);
265 m_colorFromDepth =
Axis(axis);
274 in >> m_xs >> m_ys >> m_zs;
283 in >> m_colorFromDepth_min.R >> m_colorFromDepth_min.G >>
284 m_colorFromDepth_min.B;
285 in >> m_colorFromDepth_max.R >> m_colorFromDepth_max.G >>
286 m_colorFromDepth_max.B;
290 m_colorFromDepth_min =
TColorf(0, 0, 0);
291 m_colorFromDepth_max.R = m_color.R * 255.f;
292 m_colorFromDepth_max.G = m_color.G * 255.f;
293 m_colorFromDepth_max.B = m_color.B * 255.f;
299 m_pointSmooth =
false;
306 markAllPointsAsNew();
317 markAllPointsAsNew();
329 m_minmax_valid =
false;
333 markAllPointsAsNew();
339 size_t i,
const float x,
const float y,
const float z)
348 m_minmax_valid =
false;
352 markAllPointsAsNew();
361 m_colorFromDepth_min = colorMin;
362 m_colorFromDepth_max = colorMax;
368 m_minmax_valid =
false;
369 octree_mark_as_outdated();
389 this->setPoint(idx, pt.
x, pt.
y, pt.
z);
404 pt_has_color =
false;
size_t OCTREE_RENDER_MAX_POINTS_PER_NODE_value
float OCTREE_RENDER_MAX_DENSITY_POINTS_PER_SQPIXEL_value
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
A cloud of points, all with the same color or each depending on its value along a particular coordina...
void clear()
Empty the list of points.
void setGradientColors(const mrpt::utils::TColorf &colorMin, const mrpt::utils::TColorf &colorMax)
Sets the colors used as extremes when colorFromDepth is enabled.
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.
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.
size_t PLY_export_get_vertex_count() const override
In a base class, return the number of vertices.
void markAllPointsAsNew()
Do needed internal work if all points are new (octree rebuilt,...)
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 internal_render_one_point(size_t i) const
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
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.
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 setPoint(size_t i, const float x, const float y, const float z)
Write an individual point (checks for "i" in the valid range only in Debug).
void insertPoint(float x, float y, float z)
Adds a new point to the cloud.
void render() const override
Render.
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 glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
GLsizei const GLfloat * value
void OCTREE_RENDER_MAX_DENSITY_POINTS_PER_SQPIXEL(float value)
Default value = 0.01 points/px^2.
size_t OCTREE_RENDER_MAX_POINTS_PER_NODE()
Default value = 1e5.
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.
This base provides a set of functions for maths stuff.
void minimum_maximum(const std::vector< T > &V, T &curMin, T &curMax)
Return the maximum and minimum values of a std::vector.
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.
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...
Lightweight 3D point (float version).
Information about the rendering process being issued.
A RGB color - floats in the range [0,1].