Main MRPT website > C++ reference for MRPT 1.9.9
CGridPlaneXZ.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 zMin, float zMax, float y, float frequency,
26  float lineWidth, bool antiAliasing)
27 {
28  return CGridPlaneXZ::Ptr(
29  new CGridPlaneXZ(
30  xMin, xMax, zMin, zMax, y, frequency, lineWidth, antiAliasing));
31 }
32 
33 /** Constructor */
35  float xMin, float xMax, float zMin, float zMax, float y, float frequency,
36  float lineWidth, bool antiAliasing)
37  : m_xMin(xMin),
38  m_xMax(xMax),
39  m_zMin(zMin),
40  m_zMax(zMax),
41  m_plane_y(y),
42  m_frequency(frequency),
43  m_lineWidth(lineWidth),
44  m_antiAliasing(antiAliasing)
45 {
46 }
47 
48 /*---------------------------------------------------------------
49  render
50  ---------------------------------------------------------------*/
52 {
53 #if MRPT_HAS_OPENGL_GLUT
54  ASSERT_(m_frequency >= 0)
55 
56  // Enable antialiasing:
57  if (m_antiAliasing)
58  {
63  }
65 
66  glDisable(GL_LIGHTING); // Disable lights when drawing lines
68 
69  ASSERT_(m_frequency >= 0);
70 
71  for (float z = m_zMin; z <= m_zMax; z += m_frequency)
72  {
75  }
76 
77  for (float x = m_xMin; x <= m_xMax; x += m_frequency)
78  {
81  }
82 
83  glEnd();
85 
86  // End antialiasing:
87  if (m_antiAliasing)
88  {
89  glPopAttrib();
91  }
92 #endif
93 }
94 
95 /*---------------------------------------------------------------
96  Implements the writing to a CStream capability of
97  CSerializable objects
98  ---------------------------------------------------------------*/
99 void CGridPlaneXZ::writeToStream(mrpt::utils::CStream& out, int* version) const
100 {
101  if (version)
102  *version = 1;
103  else
104  {
105  writeToStreamRender(out);
106  out << m_xMin << m_xMax;
107  out << m_zMin << m_zMax << m_plane_y;
108  out << m_frequency;
109  out << m_lineWidth << m_antiAliasing; // v1
110  }
111 }
112 
113 /*---------------------------------------------------------------
114  Implements the reading from a CStream capability of
115  CSerializable objects
116  ---------------------------------------------------------------*/
118 {
119  switch (version)
120  {
121  case 0:
122  case 1:
123  {
125  in >> m_xMin >> m_xMax;
126  in >> m_zMin >> m_zMax >> m_plane_y;
127  in >> m_frequency;
128  if (version >= 1)
130  else
131  {
132  m_lineWidth = 1.0f;
133  m_antiAliasing = true;
134  }
135  }
136  break;
137  default:
139  };
141 }
142 
144  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
145 {
146  bb_min.x = m_xMin;
147  bb_min.y = 0;
148  bb_min.z = m_zMin;
149 
150  bb_max.x = m_xMax;
151  bb_max.y = 0;
152  bb_max.z = m_zMax;
153 
154  // Convert to coordinates of my parent:
155  m_pose.composePoint(bb_min, bb_min);
156  m_pose.composePoint(bb_max, bb_max);
157 }
void writeToStreamRender(utils::CStream &out) const
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
GLdouble GLdouble z
Definition: glext.h:3872
GLAPI void GLAPIENTRY glEnable(GLenum cap)
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
STL namespace.
#define GL_ONE_MINUS_SRC_ALPHA
Definition: glew.h:287
std::shared_ptr< CObject > Ptr
Definition: CObject.h:154
GLAPI void GLAPIENTRY glPopAttrib(void)
#define GL_LIGHTING
Definition: glew.h:385
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
Definition: CRenderizable.h:57
A grid of lines over the XZ plane.
Definition: CGridPlaneXZ.h:32
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
#define GL_COLOR_BUFFER_BIT
Definition: glew.h:265
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
#define GL_LINE_SMOOTH
Definition: glew.h:367
CGridPlaneXZ(float xMin=-10, float xMax=10, float zMin=-10, float zMax=10, float y=0, float frequency=1, float lineWidth=1.3f, bool antiAliasing=true)
Constructor.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
void readFromStreamRender(mrpt::utils::CStream &in)
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...
double x
X,Y,Z coordinates.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
#define GL_BLEND
Definition: glew.h:432
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
#define GL_SRC_ALPHA
Definition: glew.h:286
static void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask)
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
void render_dl() const override
Render.
GLuint in
Definition: glext.h:7274
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
std::shared_ptr< CGridPlaneXZ > Ptr
Definition: CGridPlaneXZ.h:34
#define ASSERT_(f)
GLAPI void GLAPIENTRY glEnd(void)
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...
GLenum GLint GLint y
Definition: glext.h:3538
#define GL_LINES
Definition: glew.h:273
GLenum GLint x
Definition: glext.h:3538
Lightweight 3D point.
GLAPI void GLAPIENTRY glDisable(GLenum cap)
#define GL_LINE_BIT
Definition: glew.h:253



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019