Main MRPT website > C++ reference for MRPT 1.9.9
CGridPlaneXY.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "opengl-precomp.h" // Precompiled header
11 
13 #include <mrpt/utils/CStream.h>
14 
15 #include "opengl_internals.h"
16 
17 using namespace mrpt;
18 using namespace mrpt::opengl;
19 using namespace mrpt::utils;
20 using namespace std;
21 
23 
25  float xMin, float xMax, float yMin, float yMax, float z, float frequency,
26  float lineWidth, bool antiAliasing)
27 {
28  return CGridPlaneXY::Ptr(
29  new CGridPlaneXY(
30  xMin, xMax, yMin, yMax, z, frequency, lineWidth, antiAliasing));
31 }
32 /** Constructor */
34  float xMin, float xMax, float yMin, float yMax, float z, float frequency,
35  float lineWidth, bool antiAliasing)
36  : m_xMin(xMin),
37  m_xMax(xMax),
38  m_yMin(yMin),
39  m_yMax(yMax),
40  m_plane_z(z),
41  m_frequency(frequency),
42  m_lineWidth(lineWidth),
43  m_antiAliasing(antiAliasing)
44 {
45 }
46 
47 /*---------------------------------------------------------------
48  render_dl
49  ---------------------------------------------------------------*/
51 {
52 #if MRPT_HAS_OPENGL_GLUT
53  ASSERT_(m_frequency >= 0)
54 
55  // Enable antialiasing:
56  if (m_antiAliasing)
57  {
62  }
64 
65  glDisable(GL_LIGHTING); // Disable lights when drawing lines
67 
68  for (float y = m_yMin; y <= m_yMax; y += m_frequency)
69  {
72  }
73 
74  for (float x = m_xMin; x <= m_xMax; x += m_frequency)
75  {
78  }
79 
80  glEnd();
82 
83  // End antialiasing:
84  if (m_antiAliasing)
85  {
86  glPopAttrib();
88  }
89 #endif
90 }
91 
92 /*---------------------------------------------------------------
93  Implements the writing to a CStream capability of
94  CSerializable objects
95  ---------------------------------------------------------------*/
96 void CGridPlaneXY::writeToStream(mrpt::utils::CStream& out, int* version) const
97 {
98  if (version)
99  *version = 1;
100  else
101  {
102  writeToStreamRender(out);
103  out << m_xMin << m_xMax;
104  out << m_yMin << m_yMax << m_plane_z;
105  out << m_frequency;
106  out << m_lineWidth << m_antiAliasing; // v1
107  }
108 }
109 
110 /*---------------------------------------------------------------
111  Implements the reading from a CStream capability of
112  CSerializable objects
113  ---------------------------------------------------------------*/
115 {
116  switch (version)
117  {
118  case 0:
119  case 1:
120  {
122  in >> m_xMin >> m_xMax;
123  in >> m_yMin >> m_yMax >> m_plane_z;
124  in >> m_frequency;
125  if (version >= 1)
127  else
128  {
129  m_lineWidth = 1.0f;
130  m_antiAliasing = true;
131  }
132  }
133  break;
134  default:
136  };
138 }
139 
141  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
142 {
143  bb_min.x = m_xMin;
144  bb_min.y = m_yMin;
145  bb_min.z = 0;
146 
147  bb_max.x = m_xMax;
148  bb_max.y = m_yMax;
149  bb_max.z = 0;
150 
151  // Convert to coordinates of my parent:
152  m_pose.composePoint(bb_min, bb_min);
153  m_pose.composePoint(bb_max, bb_max);
154 }
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
A grid of lines over the XY plane.
Definition: CGridPlaneXY.h:33
virtual void render_dl() const override
Render.
CGridPlaneXY(float xMin=-10, float xMax=10, float yMin=-10, float yMax=10, float z=0, float frequency=1, float lineWidth=1.3f, bool antiAliasing=true)
Constructor
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
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 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...
std::shared_ptr< CGridPlaneXY > Ptr
Definition: CGridPlaneXY.h:34
A renderizable object suitable for rendering with OpenGL's display lists.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
void readFromStreamRender(mrpt::utils::CStream &in)
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
Definition: CRenderizable.h:57
void writeToStreamRender(utils::CStream &out) const
static void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=nullptr, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=nullptr, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing with G and L being 3D points and P this 6D pose...
Definition: CPose3D.cpp:453
std::shared_ptr< CObject > Ptr
Definition: CObject.h:154
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:42
GLAPI void GLAPIENTRY glEnable(GLenum cap)
#define GL_SRC_ALPHA
Definition: glew.h:286
#define GL_LINES
Definition: glew.h:273
#define GL_LINE_BIT
Definition: glew.h:253
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
#define GL_COLOR_BUFFER_BIT
Definition: glew.h:265
GLAPI void GLAPIENTRY glBegin(GLenum mode)
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
#define GL_BLEND
Definition: glew.h:432
#define GL_ONE_MINUS_SRC_ALPHA
Definition: glew.h:287
GLAPI void GLAPIENTRY glEnd(void)
GLAPI void GLAPIENTRY glPopAttrib(void)
GLAPI void GLAPIENTRY glDisable(GLenum cap)
GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask)
#define GL_LINE_SMOOTH
Definition: glew.h:367
#define GL_LIGHTING
Definition: glew.h:385
GLenum GLint GLint y
Definition: glext.h:3538
GLuint in
Definition: glext.h:7274
GLenum GLint x
Definition: glext.h:3538
GLdouble GLdouble z
Definition: glext.h:3872
#define ASSERT_(f)
Definition: mrpt_macros.h:309
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: mrpt_macros.h:181
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:16
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.
Lightweight 3D point.
double x
X,Y,Z coordinates.



Page generated by Doxygen 1.9.1 for MRPT 1.9.9 Git: 63ea9d1f1 Thu Nov 23 00:06:53 2017 +0100 at mar 26 may 2026 12:19:29 CEST