58 m_colorFromDepth_min(0, 0, 0),
59 m_colorFromDepth_max(0, 0, 1)
69 #if MRPT_HAS_OPENGL_GLUT 71 ASSERT_(m_xs.size() == m_ys.size());
72 ASSERT_(m_xs.size() == m_zs.size());
74 octree_assure_uptodate();
75 m_last_rendered_count_ongoing = 0;
85 m_minmax_valid =
true;
96 m_max_m_min = m_max - m_min;
97 if (std::abs(m_max_m_min) < 1e-4)
100 m_min = m_max - m_max_m_min * 1.01f;
101 m_max_m_min_inv = 1.0 / m_max_m_min;
104 if (m_color.A != 255)
115 m_col_slop.R = m_colorFromDepth_max.R - m_colorFromDepth_min.R;
116 m_col_slop.G = m_colorFromDepth_max.G - m_colorFromDepth_min.G;
117 m_col_slop.B = m_colorFromDepth_max.B - m_colorFromDepth_min.B;
119 m_col_slop_inv.R = m_col_slop.R != 0 ? 1.0f / m_col_slop.R : 0;
120 m_col_slop_inv.G = m_col_slop.G != 0 ? 1.0f / m_col_slop.G : 0;
121 m_col_slop_inv.B = m_col_slop.B != 0 ? 1.0f / m_col_slop.B : 0;
134 m_color.R, m_color.G, m_color.B,
145 m_last_rendered_count = m_last_rendered_count_ongoing;
153 #if MRPT_HAS_OPENGL_GLUT 154 if (m_colorFromDepth != colNone && m_max_m_min > 0)
156 const float depthCol =
157 (m_colorFromDepth == colX
159 : (m_colorFromDepth == colY ? m_ys[i] : m_zs[i]));
161 float f = (depthCol - m_min) * m_max_m_min_inv;
162 f = std::max(0.0f,
min(1.0f, f));
165 m_colorFromDepth_min.R + f * m_col_slop_inv.R,
166 m_colorFromDepth_min.G + f * m_col_slop_inv.G,
167 m_colorFromDepth_min.B + f * m_col_slop_inv.B,
168 m_color.A * (1.0f / 255.f));
178 const bool all,
const std::vector<size_t>& idxs,
179 const float render_area_sqpixels)
const 181 #if MRPT_HAS_OPENGL_GLUT 183 const size_t N = (all ? m_xs.size() : idxs.size());
185 1.0f, static_cast<float>(
187 render_area_sqpixels))));
189 m_last_rendered_count_ongoing += N / decimation;
193 for (
size_t i = 0; i < N; i++) internal_render_one_point(i);
197 const size_t Np = idxs.size();
198 for (
size_t i = 0; i < Np; i += decimation)
199 internal_render_one_point(idxs[i]);
211 out[
"colorFromDepth"] =
static_cast<int32_t>(m_colorFromDepth);
212 out[
"pointSize"] = m_pointSize;
213 for (
size_t i = 0; i < m_xs.size(); i++)
215 out[
"xs"][i] = m_xs[i];
217 for (
size_t i = 0; i < m_ys.size(); i++)
219 out[
"ys"][i] = m_ys[i];
221 for (
size_t i = 0; i < m_zs.size(); i++)
223 out[
"zs"][i] = m_zs[i];
225 out[
"colorFromDepth_min"][
"R"] = m_colorFromDepth_min.R;
226 out[
"colorFromDepth_min"][
"G"] = m_colorFromDepth_min.G;
227 out[
"colorFromDepth_min"][
"B"] = m_colorFromDepth_min.B;
228 out[
"colorFromDepth_max"][
"R"] = m_colorFromDepth_max.R;
229 out[
"colorFromDepth_max"][
"G"] = m_colorFromDepth_max.G;
230 out[
"colorFromDepth_max"][
"B"] = m_colorFromDepth_max.B;
231 out[
"pointSmooth"] = m_pointSmooth;
246 m_pointSize =
static_cast<float>(
in[
"pointSize"]);
247 for (
size_t i = 0; i < m_xs.size(); i++)
249 m_xs[i] =
static_cast<float>(
in[
"xs"][i]);
251 for (
size_t i = 0; i < m_ys.size(); i++)
253 m_ys[i] =
static_cast<float>(
in[
"ys"][i]);
255 for (
size_t i = 0; i < m_zs.size(); i++)
257 m_zs[i] =
static_cast<float>(
in[
"zs"][i]);
259 m_colorFromDepth_min.R =
260 static_cast<float>(
in[
"colorFromDepth_min"][
"R"]);
261 m_colorFromDepth_min.G =
262 static_cast<float>(
in[
"colorFromDepth_min"][
"G"]);
263 m_colorFromDepth_min.B =
264 static_cast<float>(
in[
"colorFromDepth_min"][
"B"]);
265 m_colorFromDepth_max.R =
266 static_cast<float>(
in[
"colorFromDepth_max"][
"R"]);
267 m_colorFromDepth_max.G =
268 static_cast<float>(
in[
"colorFromDepth_max"][
"G"]);
269 m_colorFromDepth_max.B =
270 static_cast<float>(
in[
"colorFromDepth_max"][
"B"]);
271 m_pointSmooth =
static_cast<bool>(
in[
"pointSmooth"]);
281 writeToStreamRender(out);
283 out << static_cast<int32_t>(m_colorFromDepth);
284 out << m_xs << m_ys << m_zs;
290 out << m_colorFromDepth_min.R << m_colorFromDepth_min.G
291 << m_colorFromDepth_min.B;
292 out << m_colorFromDepth_max.R << m_colorFromDepth_max.G
293 << m_colorFromDepth_max.B;
296 out << m_pointSmooth;
310 readFromStreamRender(
in);
315 m_colorFromDepth = Axis(axis);
324 in >> m_xs >> m_ys >> m_zs;
333 in >> m_colorFromDepth_min.R >> m_colorFromDepth_min.G >>
334 m_colorFromDepth_min.B;
335 in >> m_colorFromDepth_max.R >> m_colorFromDepth_max.G >>
336 m_colorFromDepth_max.B;
340 m_colorFromDepth_min =
TColorf(0, 0, 0);
341 m_colorFromDepth_max.R = m_color.R * 255.f;
342 m_colorFromDepth_max.G = m_color.G * 255.f;
343 m_colorFromDepth_max.B = m_color.B * 255.f;
349 m_pointSmooth =
false;
356 markAllPointsAsNew();
367 markAllPointsAsNew();
379 m_minmax_valid =
false;
383 markAllPointsAsNew();
389 size_t i,
const float x,
const float y,
const float z)
398 m_minmax_valid =
false;
402 markAllPointsAsNew();
411 m_colorFromDepth_min = colorMin;
412 m_colorFromDepth_max = colorMax;
418 m_minmax_valid =
false;
419 octree_mark_as_outdated();
439 this->setPoint(idx, pt.
x, pt.
y, pt.
z);
454 pt_has_color =
false;
void render() const override
Render.
void insertPoint(float x, float y, float z)
Adds a new point to the cloud.
float OCTREE_RENDER_MAX_DENSITY_POINTS_PER_SQPIXEL_value
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
GLAPI void GLAPIENTRY glEnable(GLenum cap)
GLAPI void GLAPIENTRY glPointSize(GLfloat size)
#define ASSERT_BELOW_(__A, __B)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
size_t OCTREE_RENDER_MAX_POINTS_PER_NODE()
Default value = 1e5.
This file implements several operations that operate element-wise on individual or pairs of container...
The base class of 3D objects that can be directly rendered through OpenGL.
#define GL_ONE_MINUS_SRC_ALPHA
enum mrpt::opengl::CPointCloud::Axis colNone
void clear()
Empty the list of points.
void setGradientColors(const mrpt::img::TColorf &colorMin, const mrpt::img::TColorf &colorMax)
Sets the colors used as extremes when colorFromDepth is enabled.
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
Virtual base class for "schematic archives" (JSON, XML,...)
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
#define ASSERT_(f)
Defines an assertion mechanism.
This base provides a set of functions for maths stuff.
Lightweight 3D point (float version).
void OCTREE_RENDER_MAX_DENSITY_POINTS_PER_SQPIXEL(float value)
Default value = 0.01 points/px^2.
Information about the rendering process being issued.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
size_t OCTREE_RENDER_MAX_POINTS_PER_NODE_value
void internal_render_one_point(size_t i) const
void minimum_maximum(const std::vector< T > &V, T &curMin, T &curMax)
Return the maximum and minimum values of a std::vector.
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
#define SCHEMA_DESERIALIZE_DATATYPE_VERSION()
For use inside serializeFrom(CSchemeArchiveBase) methods.
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
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 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...
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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)
Virtual base class for "archives": classes abstracting I/O streams.
void markAllPointsAsNew()
Do needed internal work if all points are new (octree rebuilt,...)
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
A RGB color - floats in the range [0,1].
The namespace for 3D scene representation and rendering.
void getCurrentRenderingInfo(TRenderInfo &ri)
Gather useful information on the render parameters.
size_t PLY_export_get_vertex_count() const override
In a base class, return the number of vertices.
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...
GLAPI void GLAPIENTRY glEnd(void)
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).
GLsizei const GLfloat * value
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
#define SCHEMA_SERIALIZE_DATATYPE_VERSION(ser_version)
For use inside all serializeTo(CSchemeArchiveBase) methods.
GLAPI void GLAPIENTRY glDisable(GLenum cap)
A cloud of points, all with the same color or each depending on its value along a particular coordina...
#define MRPT_UNUSED_PARAM(a)
Determines whether this is an X86 or AMD64 platform.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
int round(const T value)
Returns the closer integer (int) to x.