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]);
220 writeToStreamRender(out);
222 out << static_cast<int32_t>(m_colorFromDepth);
223 out << m_xs << m_ys << m_zs;
229 out << m_colorFromDepth_min.R << m_colorFromDepth_min.G
230 << m_colorFromDepth_min.B;
231 out << m_colorFromDepth_max.R << m_colorFromDepth_max.G
232 << m_colorFromDepth_max.B;
235 out << m_pointSmooth;
249 readFromStreamRender(
in);
254 m_colorFromDepth =
Axis(axis);
263 in >> m_xs >> m_ys >> m_zs;
272 in >> m_colorFromDepth_min.R >> m_colorFromDepth_min.G >>
273 m_colorFromDepth_min.B;
274 in >> m_colorFromDepth_max.R >> m_colorFromDepth_max.G >>
275 m_colorFromDepth_max.B;
279 m_colorFromDepth_min =
TColorf(0, 0, 0);
280 m_colorFromDepth_max.R = m_color.R * 255.f;
281 m_colorFromDepth_max.G = m_color.G * 255.f;
282 m_colorFromDepth_max.B = m_color.B * 255.f;
288 m_pointSmooth =
false;
295 markAllPointsAsNew();
306 markAllPointsAsNew();
318 m_minmax_valid =
false;
322 markAllPointsAsNew();
328 size_t i,
const float x,
const float y,
const float z)
337 m_minmax_valid =
false;
341 markAllPointsAsNew();
350 m_colorFromDepth_min = colorMin;
351 m_colorFromDepth_max = colorMax;
357 m_minmax_valid =
false;
358 octree_mark_as_outdated();
378 this->setPoint(idx, pt.
x, pt.
y, pt.
z);
393 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.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
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.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
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
virtual void PLY_import_set_vertex(const size_t idx, const mrpt::math::TPoint3Df &pt, const mrpt::img::TColorf *pt_color=nullptr) override
In a base class, will be called after PLY_import_set_vertex_count() once for each loaded point.
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
void PLY_export_get_vertex(const size_t idx, mrpt::math::TPoint3Df &pt, bool &pt_has_color, mrpt::img::TColorf &pt_color) const override
In a base class, will be called after PLY_export_get_vertex_count() once for each exported point.
void setGradientColors(const mrpt::img::TColorf &colorMin, const mrpt::img::TColorf &colorMax)
Sets the colors used as extremes when colorFromDepth is enabled.
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.
Virtual base class for "archives": classes abstracting I/O streams.
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
#define ASSERT_(f)
Defines an assertion mechanism.
#define ASSERT_BELOW_(__A, __B)
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
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.
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.
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...
A RGB color - floats in the range [0,1].
Lightweight 3D point (float version).
Information about the rendering process being issued.