Main MRPT website > C++ reference for MRPT 1.5.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 
24 CGridPlaneXYPtr CGridPlaneXY::Create(
25  float xMin,
26  float xMax,
27  float yMin,
28  float yMax,
29  float z,
30  float frequency,
31  float lineWidth,
32  bool antiAliasing)
33 {
34  return CGridPlaneXYPtr( new CGridPlaneXY(xMin,xMax,yMin,yMax, z, frequency,lineWidth,antiAliasing ) );
35 }
36 /** Constructor */
38  float xMin,
39  float xMax,
40  float yMin,
41  float yMax,
42  float z,
43  float frequency,
44  float lineWidth,
45  bool antiAliasing
46  ) :
47  m_xMin(xMin),
48  m_xMax(xMax),
49  m_yMin(yMin),
50  m_yMax(yMax),
51  m_plane_z(z),
52  m_frequency(frequency),
53  m_lineWidth(lineWidth),
54  m_antiAliasing(antiAliasing)
55 {
56 }
57 
58 /*---------------------------------------------------------------
59  render_dl
60  ---------------------------------------------------------------*/
62 {
63 #if MRPT_HAS_OPENGL_GLUT
65 
66  // Enable antialiasing:
67  if (m_antiAliasing)
68  {
73  }
75 
76  glDisable(GL_LIGHTING); // Disable lights when drawing lines
78 
79  for (float y=m_yMin;y<=m_yMax;y+=m_frequency)
80  {
83  }
84 
85  for (float x=m_xMin;x<=m_xMax;x+=m_frequency)
86  {
89  }
90 
91  glEnd();
93 
94  // End antialiasing:
95  if (m_antiAliasing)
96  {
97  glPopAttrib();
99  }
100 #endif
101 }
102 
103 /*---------------------------------------------------------------
104  Implements the writing to a CStream capability of
105  CSerializable objects
106  ---------------------------------------------------------------*/
108 {
109 
110  if (version)
111  *version = 1;
112  else
113  {
114  writeToStreamRender(out);
115  out << m_xMin << m_xMax;
116  out << m_yMin << m_yMax << m_plane_z;
117  out << m_frequency;
118  out << m_lineWidth << m_antiAliasing; // v1
119  }
120 }
121 
122 /*---------------------------------------------------------------
123  Implements the reading from a CStream capability of
124  CSerializable objects
125  ---------------------------------------------------------------*/
127 {
128 
129  switch(version)
130  {
131  case 0:
132  case 1:
133  {
135  in >> m_xMin >> m_xMax;
136  in >> m_yMin >> m_yMax >> m_plane_z;
137  in >> m_frequency;
138  if (version>=1)
140  else
141  {
142  m_lineWidth=1.0f;
143  m_antiAliasing=true;
144  }
145 
146  } break;
147  default:
149 
150  };
152 }
153 
155 {
156  bb_min.x = m_xMin;
157  bb_min.y = m_yMin;
158  bb_min.z = 0;
159 
160  bb_max.x = m_xMax;
161  bb_max.y = m_yMax;
162  bb_max.z = 0;
163 
164  // Convert to coordinates of my parent:
165  m_pose.composePoint(bb_min, bb_min);
166  m_pose.composePoint(bb_max, bb_max);
167 }
void writeToStreamRender(utils::CStream &out) const
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:16
GLdouble GLdouble z
Definition: glext.h:3734
A grid of lines over the XY plane.
Definition: CGridPlaneXY.h:35
virtual void render_dl() const MRPT_OVERRIDE
Render.
GLAPI void GLAPIENTRY glEnable(GLenum cap)
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:283
double z
X,Y,Z coordinates.
GLAPI void GLAPIENTRY glPopAttrib(void)
IMPLEMENTS_SERIALIZABLE(CLogFileRecord_FullEval, CHolonomicLogFileRecord, mrpt::nav) IMPLEMENTS_SERIALIZABLE(CHolonomicFullEval
#define GL_LIGHTING
Definition: glew.h:381
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference. This class automatically holds the cached 3x3 rotation m...
Definition: CRenderizable.h:55
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:261
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::math::CMatrixFixedNumeric< double, 3, 3 > *out_jacobian_df_dpoint=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dpose=NULL, mrpt::math::CMatrixFixedNumeric< double, 3, 6 > *out_jacobian_df_dse3=NULL, 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:439
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
#define GL_LINE_SMOOTH
Definition: glew.h:363
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
void readFromStreamRender(mrpt::utils::CStream &in)
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
int version
Definition: mrpt_jpeglib.h:898
GLAPI void GLAPIENTRY glBegin(GLenum mode)
#define GL_BLEND
Definition: glew.h:428
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
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.
#define GL_SRC_ALPHA
Definition: glew.h:282
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)
GLuint in
Definition: glext.h:6301
The namespace for 3D scene representation and rendering.
#define ASSERT_(f)
GLAPI void GLAPIENTRY glEnd(void)
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
GLenum GLint GLint y
Definition: glext.h:3516
#define GL_LINES
Definition: glew.h:269
void readFromStream(mrpt::utils::CStream &in, int version)
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
GLenum GLint x
Definition: glext.h:3516
Lightweight 3D point.
GLAPI void GLAPIENTRY glDisable(GLenum cap)
#define GL_LINE_BIT
Definition: glew.h:249



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020