MRPT  1.9.9
CGridPlaneXY.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 yMin, float yMax, float z, float frequency,
27  float lineWidth, bool antiAliasing)
28  : m_xMin(xMin),
29  m_xMax(xMax),
30  m_yMin(yMin),
31  m_yMax(yMax),
32  m_plane_z(z),
33  m_frequency(frequency),
34  m_lineWidth(lineWidth),
35  m_antiAliasing(antiAliasing)
36 {
37 }
38 
39 /*---------------------------------------------------------------
40  render_dl
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  for (float y = m_yMin; y <= m_yMax; y += m_frequency)
61  {
62  glVertex3f(m_xMin, y, m_plane_z);
63  glVertex3f(m_xMax, y, m_plane_z);
64  }
65 
66  for (float x = m_xMin; x <= m_xMax; x += m_frequency)
67  {
68  glVertex3f(x, m_yMin, m_plane_z);
69  glVertex3f(x, m_yMax, m_plane_z);
70  }
71 
72  glEnd();
73  glEnable(GL_LIGHTING);
74 
75  // End antialiasing:
76  if (m_antiAliasing)
77  {
78  glPopAttrib();
80  }
81 #endif
82 }
83 
84 uint8_t CGridPlaneXY::serializeGetVersion() const { return 1; }
86 {
87  writeToStreamRender(out);
88  out << m_xMin << m_xMax;
89  out << m_yMin << m_yMax << m_plane_z;
90  out << m_frequency;
91  out << m_lineWidth << m_antiAliasing; // v1
92 }
93 
95  mrpt::serialization::CArchive& in, uint8_t version)
96 {
97  switch (version)
98  {
99  case 0:
100  case 1:
101  {
102  readFromStreamRender(in);
103  in >> m_xMin >> m_xMax;
104  in >> m_yMin >> m_yMax >> m_plane_z;
105  in >> m_frequency;
106  if (version >= 1)
107  in >> m_lineWidth >> m_antiAliasing;
108  else
109  {
110  m_lineWidth = 1.0f;
111  m_antiAliasing = true;
112  }
113  }
114  break;
115  default:
117  };
119 }
120 
123 {
124  bb_min.x = m_xMin;
125  bb_min.y = m_yMin;
126  bb_min.z = 0;
127 
128  bb_max.x = m_xMax;
129  bb_max.y = m_yMax;
130  bb_max.z = 0;
131 
132  // Convert to coordinates of my parent:
133  m_pose.composePoint(bb_min, bb_min);
134  m_pose.composePoint(bb_max, bb_max);
135 }
void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
A grid of lines over the XY plane.
Definition: CGridPlaneXY.h:29
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void render_dl() const override
Render.
STL namespace.
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...
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
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
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
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
const auto bb_max
const auto bb_min
Lightweight 3D point.
Definition: TPoint3D.h:90



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7e629e01a Sat Dec 14 00:05:55 2019 +0100 at sáb dic 14 00:15:10 CET 2019