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-2018, 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 
14 
15 #include "opengl_internals.h"
16 
17 using namespace mrpt;
18 using namespace mrpt::opengl;
19 
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 
97 {
99  out << m_xMin << m_xMax;
100  out << m_zMin << m_zMax << m_plane_y;
101  out << m_frequency;
102  out << m_lineWidth << m_antiAliasing; // v1
103 }
104 
107 {
108  switch (version)
109  {
110  case 0:
111  case 1:
112  {
114  in >> m_xMin >> m_xMax;
115  in >> m_zMin >> m_zMax >> m_plane_y;
116  in >> m_frequency;
117  if (version >= 1)
119  else
120  {
121  m_lineWidth = 1.0f;
122  m_antiAliasing = true;
123  }
124  }
125  break;
126  default:
128  };
130 }
131 
133  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
134 {
135  bb_min.x = m_xMin;
136  bb_min.y = 0;
137  bb_min.z = m_zMin;
138 
139  bb_max.x = m_xMax;
140  bb_max.y = 0;
141  bb_max.z = m_zMax;
142 
143  // Convert to coordinates of my parent:
144  m_pose.composePoint(bb_min, bb_min);
145  m_pose.composePoint(bb_max, bb_max);
146 }
glBegin
GLAPI void GLAPIENTRY glBegin(GLenum mode)
mrpt::opengl::CGridPlaneXZ::m_lineWidth
float m_lineWidth
Definition: CGridPlaneXZ.h:41
mrpt::opengl::CGridPlaneXZ::m_frequency
float m_frequency
Definition: CGridPlaneXZ.h:40
GL_SRC_ALPHA
#define GL_SRC_ALPHA
Definition: glew.h:286
GL_BLEND
#define GL_BLEND
Definition: glew.h:432
mrpt::opengl::CGridPlaneXZ::m_xMax
float m_xMax
Definition: CGridPlaneXZ.h:37
GL_LINE_SMOOTH
#define GL_LINE_SMOOTH
Definition: glew.h:367
mrpt::opengl::CRenderizableDisplayList
A renderizable object suitable for rendering with OpenGL's display lists.
Definition: CRenderizableDisplayList.h:39
mrpt::math::TPoint3D::z
double z
Definition: lightweight_geom_data.h:385
glDisable
GLAPI void GLAPIENTRY glDisable(GLenum cap)
mrpt::opengl::CRenderizableDisplayList::notifyChange
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated)
Definition: CRenderizableDisplayList.h:57
mrpt::opengl::CGridPlaneXZ::m_antiAliasing
bool m_antiAliasing
Definition: CGridPlaneXZ.h:42
glEnable
GLAPI void GLAPIENTRY glEnable(GLenum cap)
mrpt::opengl::CGridPlaneXZ::Ptr
std::shared_ptr< CGridPlaneXZ > Ptr
Definition: CGridPlaneXZ.h:34
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::opengl::CGridPlaneXZ::serializeGetVersion
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Definition: CGridPlaneXZ.cpp:95
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
glVertex3f
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
ASSERT_
#define ASSERT_(f)
Defines an assertion mechanism.
Definition: exceptions.h:113
mrpt::opengl::CGridPlaneXZ::serializeTo
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CGridPlaneXZ.cpp:96
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
glEnd
GLAPI void GLAPIENTRY glEnd(void)
mrpt::opengl::CGridPlaneXZ::m_plane_y
float m_plane_y
Definition: CGridPlaneXZ.h:39
GL_LINE_BIT
#define GL_LINE_BIT
Definition: glew.h:253
mrpt::opengl::CRenderizable::m_pose
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
Definition: CRenderizable.h:57
mrpt::opengl::CRenderizable::checkOpenGLError
static void checkOpenGLError()
Checks glGetError and throws an exception if an error situation is found.
Definition: CRenderizable.cpp:301
GL_LIGHTING
#define GL_LIGHTING
Definition: glew.h:385
glLineWidth
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
GL_ONE_MINUS_SRC_ALPHA
#define GL_ONE_MINUS_SRC_ALPHA
Definition: glew.h:287
glPushAttrib
GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask)
mrpt::opengl::CGridPlaneXZ::m_zMax
float m_zMax
Definition: CGridPlaneXZ.h:38
mrpt::math::TPoint3D::x
double x
X,Y,Z coordinates.
Definition: lightweight_geom_data.h:385
mrpt::opengl::CGridPlaneXZ::render_dl
void render_dl() const override
Render.
Definition: CGridPlaneXZ.cpp:51
mrpt::opengl::CGridPlaneXZ::m_zMin
float m_zMin
Definition: CGridPlaneXZ.h:38
IMPLEMENTS_SERIALIZABLE
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
Definition: CSerializable.h:114
mrpt::opengl::CGridPlaneXZ::CGridPlaneXZ
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.
Definition: CGridPlaneXZ.cpp:34
GL_LINES
#define GL_LINES
Definition: glew.h:273
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
opengl-precomp.h
mrpt::math::TPoint3D::y
double y
Definition: lightweight_geom_data.h:385
mrpt::opengl::CGridPlaneXZ
A grid of lines over the XZ plane.
Definition: CGridPlaneXZ.h:32
mrpt::poses::CPose3D::composePoint
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:379
mrpt::opengl::CGridPlaneXZ::getBoundingBox
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...
Definition: CGridPlaneXZ.cpp:132
opengl_internals.h
glPopAttrib
GLAPI void GLAPIENTRY glPopAttrib(void)
z
GLdouble GLdouble z
Definition: glext.h:3872
CGridPlaneXZ.h
in
GLuint in
Definition: glext.h:7274
CArchive.h
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:90
mrpt::opengl::CRenderizable::writeToStreamRender
void writeToStreamRender(mrpt::serialization::CArchive &out) const
Definition: CRenderizable.cpp:110
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
mrpt::opengl::CRenderizableDisplayList::readFromStreamRender
void readFromStreamRender(mrpt::serialization::CArchive &in)
Definition: CRenderizableDisplayList.h:65
y
GLenum GLint GLint y
Definition: glext.h:3538
mrpt::opengl::CGridPlaneXZ::m_xMin
float m_xMin
Definition: CGridPlaneXZ.h:37
x
GLenum GLint x
Definition: glext.h:3538
mrpt::opengl::CGridPlaneXZ::serializeFrom
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: CGridPlaneXZ.cpp:105
glBlendFunc
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
GL_COLOR_BUFFER_BIT
#define GL_COLOR_BUFFER_BIT
Definition: glew.h:265



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST