MRPT  1.9.9
CGridPlaneXZ.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "opengl-precomp.h" // Precompiled header
11 
14 
15 #include "opengl_internals.h"
16 
17 using namespace mrpt;
18 using namespace mrpt::opengl;
19 
20 using namespace std;
21 
23 
24 /** Constructor */
26  float xMin, float xMax, float zMin, float zMax, float y, float frequency,
27  float lineWidth, bool antiAliasing)
28  : m_xMin(xMin),
29  m_xMax(xMax),
30  m_zMin(zMin),
31  m_zMax(zMax),
32  m_plane_y(y),
33  m_frequency(frequency),
34  m_lineWidth(lineWidth),
35  m_antiAliasing(antiAliasing)
36 {
37 }
38 
39 /*---------------------------------------------------------------
40  render
41  ---------------------------------------------------------------*/
43 {
44 #if MRPT_HAS_OPENGL_GLUT
45  ASSERT_(m_frequency >= 0);
46 
47  // Enable antialiasing:
48  if (m_antiAliasing)
49  {
50  glPushAttrib(GL_COLOR_BUFFER_BIT | GL_LINE_BIT);
51  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
52  glEnable(GL_BLEND);
53  glEnable(GL_LINE_SMOOTH);
54  }
55  glLineWidth(m_lineWidth);
56 
57  glDisable(GL_LIGHTING); // Disable lights when drawing lines
58  glBegin(GL_LINES);
59 
60  ASSERT_(m_frequency >= 0);
61 
62  for (float z = m_zMin; z <= m_zMax; z += m_frequency)
63  {
64  glVertex3f(m_xMin, m_plane_y, z);
65  glVertex3f(m_xMax, m_plane_y, z);
66  }
67 
68  for (float x = m_xMin; x <= m_xMax; x += m_frequency)
69  {
70  glVertex3f(x, m_plane_y, m_zMin);
71  glVertex3f(x, m_plane_y, m_zMax);
72  }
73 
74  glEnd();
75  glEnable(GL_LIGHTING);
76 
77  // End antialiasing:
78  if (m_antiAliasing)
79  {
80  glPopAttrib();
82  }
83 #endif
84 }
85 
86 uint8_t CGridPlaneXZ::serializeGetVersion() const { return 1; }
88 {
89  writeToStreamRender(out);
90  out << m_xMin << m_xMax;
91  out << m_zMin << m_zMax << m_plane_y;
92  out << m_frequency;
93  out << m_lineWidth << m_antiAliasing; // v1
94 }
95 
97  mrpt::serialization::CArchive& in, uint8_t version)
98 {
99  switch (version)
100  {
101  case 0:
102  case 1:
103  {
104  readFromStreamRender(in);
105  in >> m_xMin >> m_xMax;
106  in >> m_zMin >> m_zMax >> m_plane_y;
107  in >> m_frequency;
108  if (version >= 1)
109  in >> m_lineWidth >> m_antiAliasing;
110  else
111  {
112  m_lineWidth = 1.0f;
113  m_antiAliasing = true;
114  }
115  }
116  break;
117  default:
119  };
121 }
122 
125 {
126  bb_min.x = m_xMin;
127  bb_min.y = 0;
128  bb_min.z = m_zMin;
129 
130  bb_max.x = m_xMax;
131  bb_max.y = 0;
132  bb_max.z = m_zMax;
133 
134  // Convert to coordinates of my parent:
135  m_pose.composePoint(bb_min, bb_min);
136  m_pose.composePoint(bb_max, bb_max);
137 }
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
STL namespace.
A grid of lines over the XZ plane.
Definition: CGridPlaneXZ.h:29
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:120
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
mrpt::vision::TStereoCalibResults out
void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
Definition: gl_utils.cpp:155
void render_dl() const override
Render.
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
const auto bb_max
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...
const auto bb_min
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Lightweight 3D point.
Definition: TPoint3D.h:90



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 4a95fd864 Fri Dec 13 00:48:40 2019 +0100 at vie dic 13 01:00:11 CET 2019