33 const auto cols = Z.cols();
34 const auto rows = Z.rows();
36 if ((m_colorFromZ) || (m_isImage)) updateColorsMatrix();
38 ASSERT_((cols > 0) && (rows > 0));
39 ASSERT_((xMax > xMin) && (yMax > yMin));
40 X.setSize(rows, cols);
41 Y.setSize(rows, cols);
42 const float sCellX = (xMax - xMin) / (rows - 1);
43 const float sCellY = (yMax - yMin) / (cols - 1);
45 for (
int iX = 0; iX < rows; iX++)
46 for (
int iY = 0; iY < cols; iY++)
48 X(iX, iY) = xMin + iX * sCellX;
49 Y(iX, iY) = yMin + iY * sCellY;
52 pointsUpToDate =
true;
60 #if MRPT_HAS_OPENGL_GLUT 62 if (!pointsUpToDate) updatePoints();
84 for (
unsigned int i = 0; i < X.rows(); i++)
85 for (
unsigned int j = 0; j < X.cols(); j++)
87 if (m_isImage && m_textureImage.isColor())
88 glColor4f(C_r(i, j), C_g(i, j), C_b(i, j), m_color.A / 255.f);
91 glColor4f(C(i, j), C(i, j), C(i, j), m_color.A / 255.f);
93 else if (m_colorFromZ)
102 m_color.R / 255.f, m_color.G / 255.f, m_color.B / 255.f,
126 m_textureImage =
img;
129 Z.setSize(
img.getHeight(),
img.getWidth());
133 m_modified_Image =
true;
134 m_enableTransparency =
false;
135 m_colorFromZ =
false;
137 pointsUpToDate =
false;
150 (
img.getWidth() ==
static_cast<size_t>(in_Z.cols())) &&
151 (
img.getHeight() ==
static_cast<size_t>(in_Z.rows())));
156 m_textureImage =
img;
159 m_modified_Image =
true;
160 m_enableTransparency =
false;
161 m_colorFromZ =
false;
163 pointsUpToDate =
false;
173 writeToStreamRender(out);
175 out << m_textureImage;
177 out << xMin << xMax << yMin << yMax;
179 out << m_enableTransparency;
183 out << m_pointSmooth;
193 readFromStreamRender(
in);
195 in >> m_textureImage;
204 in >> m_enableTransparency;
215 pointsUpToDate =
false;
226 if ((!m_modified_Z) && (!m_modified_Image))
return;
232 const int cols = m_textureImage.getWidth();
233 const int rows = m_textureImage.getHeight();
235 if ((cols != Z.cols()) || (rows != Z.rows()))
237 printf(
"\nTexture Image and Z sizes have to be equal");
239 else if (m_textureImage.isColor())
241 C_r.setSize(rows, cols);
242 C_g.setSize(rows, cols);
243 C_b.setSize(rows, cols);
244 m_textureImage.getAsRGBMatrices(C_r, C_g, C_b);
248 C.setSize(rows, cols);
249 m_textureImage.getAsMatrix(C);
254 const size_t cols = Z.cols();
255 const size_t rows = Z.rows();
257 C.setSize(rows, cols);
262 C.normalize(0.01f, 0.99f);
265 m_modified_Image =
false;
266 m_modified_Z =
false;
267 pointsUpToDate =
false;
274 pointsUpToDate =
false;
287 bb_min.
z = Z.minCoeff();
291 bb_max.
z = Z.maxCoeff();
294 m_pose.composePoint(bb_min, bb_min);
295 m_pose.composePoint(bb_max, bb_max);
void updateColorsMatrix() const
Called internally to assure C is updated.
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.
TColormap
Different colormaps for use in mrpt::img::colormap()
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 IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
A planar (XY) grid where each cell has an associated height and, optionally, a texture map...
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
void render_dl() const override
Render.
#define GL_ONE_MINUS_SRC_ALPHA
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
A renderizable object suitable for rendering with OpenGL's display lists.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
#define ASSERT_(f)
Defines an assertion mechanism.
void assignImageAndZ(const mrpt::img::CImage &img, const mrpt::math::CMatrixTemplateNumeric< float > &in_Z)
Assigns a texture image and Z simultaneously, and disable transparency.
This base provides a set of functions for maths stuff.
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
void setZ(const mrpt::math::CMatrixTemplateNumeric< float > &in_Z)
This method sets the matrix of heights for each position (cell) in the mesh grid. ...
double x
X,Y,Z coordinates.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
The namespace for 3D scene representation and rendering.
GLAPI void GLAPIENTRY glEnd(void)
A matrix of dynamic size.
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
GLAPI void GLAPIENTRY glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
void assignImage(const mrpt::img::CImage &img)
Assigns a texture image, and disable transparency.
A class for storing images as grayscale or RGB bitmaps.