Main MRPT website > C++ reference for MRPT 1.5.7
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 
24 CGridPlaneXZPtr CGridPlaneXZ::Create(
25  float xMin,
26  float xMax,
27  float zMin,
28  float zMax,
29  float y,
30  float frequency,
31  float lineWidth,
32  bool antiAliasing
33  )
34 {
35  return CGridPlaneXZPtr( new CGridPlaneXZ( xMin,xMax, zMin, zMax, y, frequency,lineWidth,antiAliasing ) );
36 }
37 
38 /** Constructor */
40  float xMin,
41  float xMax,
42  float zMin,
43  float zMax,
44  float y,
45  float frequency,
46  float lineWidth,
47  bool antiAliasing
48  ) :
49  m_xMin(xMin),m_xMax(xMax),
50  m_zMin(zMin),m_zMax(zMax),
51  m_plane_y(y),
52  m_frequency(frequency),
53  m_lineWidth(lineWidth),
54  m_antiAliasing(antiAliasing)
55 {
56 }
57 
58 
59 /*---------------------------------------------------------------
60  render
61  ---------------------------------------------------------------*/
63 {
64 #if MRPT_HAS_OPENGL_GLUT
66 
67  // Enable antialiasing:
68  if (m_antiAliasing)
69  {
74  }
76 
77  glDisable(GL_LIGHTING); // Disable lights when drawing lines
79 
80  ASSERT_(m_frequency>=0);
81 
82  for (float z=m_zMin;z<=m_zMax;z+=m_frequency)
83  {
86  }
87 
88  for (float x=m_xMin;x<=m_xMax;x+=m_frequency)
89  {
92  }
93 
94  glEnd();
96 
97  // End antialiasing:
98  if (m_antiAliasing)
99  {
100  glPopAttrib();
102  }
103 #endif
104 }
105 
106 /*---------------------------------------------------------------
107  Implements the writing to a CStream capability of
108  CSerializable objects
109  ---------------------------------------------------------------*/
111 {
112 
113  if (version)
114  *version = 1;
115  else
116  {
117  writeToStreamRender(out);
118  out << m_xMin << m_xMax;
119  out << m_zMin << m_zMax << m_plane_y;
120  out << m_frequency;
121  out << m_lineWidth << m_antiAliasing; // v1
122  }
123 }
124 
125 /*---------------------------------------------------------------
126  Implements the reading from a CStream capability of
127  CSerializable objects
128  ---------------------------------------------------------------*/
130 {
131 
132  switch(version)
133  {
134  case 0:
135  case 1:
136  {
138  in >> m_xMin >> m_xMax;
139  in >> m_zMin >> m_zMax >> m_plane_y;
140  in >> m_frequency;
141  if (version>=1)
143  else
144  {
145  m_lineWidth=1.0f;
146  m_antiAliasing=true;
147  }
148  } break;
149  default:
151 
152  };
154 }
155 
157 {
158  bb_min.x = m_xMin;
159  bb_min.y = 0;
160  bb_min.z = m_zMin;
161 
162  bb_max.x = m_xMax;
163  bb_max.y = 0;
164  bb_max.z = m_zMax;
165 
166  // Convert to coordinates of my parent:
167  m_pose.composePoint(bb_min, bb_min);
168  m_pose.composePoint(bb_max, bb_max);
169 }
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
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...
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:283
double z
X,Y,Z coordinates.
GLAPI void GLAPIENTRY glPopAttrib(void)
#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
A grid of lines over the XZ plane.
Definition: CGridPlaneXZ.h:35
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:427
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
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 render_dl() const MRPT_OVERRIDE
Render.
int version
Definition: mrpt_jpeglib.h:898
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
#define GL_BLEND
Definition: glew.h:428
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
#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)
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...
GLuint in
Definition: glext.h:6301
The namespace for 3D scene representation and rendering.
#define ASSERT_(f)
GLAPI void GLAPIENTRY glEnd(void)
GLenum GLint GLint y
Definition: glext.h:3516
#define GL_LINES
Definition: glew.h:269
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.7 Git: 8277875f6 Mon Jun 11 02:47:32 2018 +0200 at lun oct 28 01:50:49 CET 2019