Main MRPT website > C++ reference for MRPT 1.9.9
CSimpleLine.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 #include "opengl_internals.h"
15 
16 using namespace mrpt;
17 using namespace mrpt::opengl;
18 using namespace mrpt::utils;
19 using namespace mrpt::math;
20 using namespace std;
21 
23 
25  float x0, float y0, float z0, float x1, float y1, float z1, float lineWidth)
26 {
27  return CSimpleLine::Ptr(new CSimpleLine(x0, y0, z0, x1, y1, z1, lineWidth));
28 }
29 
31  float x0, float y0, float z0, float x1, float y1, float z1, float lineWidth,
32  bool antiAliasing)
33  : m_x0(x0),
34  m_y0(y0),
35  m_z0(z0),
36  m_x1(x1),
37  m_y1(y1),
38  m_z1(z1),
39  m_lineWidth(lineWidth),
40  m_antiAliasing(antiAliasing)
41 {
42 }
43 
44 /*---------------------------------------------------------------
45  render_dl
46  ---------------------------------------------------------------*/
48 {
49 #if MRPT_HAS_OPENGL_GLUT
50  // Enable antialiasing:
51  if (m_antiAliasing)
52  {
57  }
59 
60  glDisable(GL_LIGHTING); // Disable lights when drawing lines
62 
66 
67  glEnd();
69  glEnable(GL_LIGHTING); // Disable lights when drawing lines
70 
71  // End antialiasing:
72  if (m_antiAliasing)
73  {
74  glPopAttrib();
76  }
77 #endif
78 }
79 
80 /*---------------------------------------------------------------
81  Implements the writing to a CStream capability of
82  CSerializable objects
83  ---------------------------------------------------------------*/
84 void CSimpleLine::writeToStream(mrpt::utils::CStream& out, int* version) const
85 {
86  if (version)
87  *version = 1;
88  else
89  {
91  out << m_x0 << m_y0 << m_z0;
92  out << m_x1 << m_y1 << m_z1 << m_lineWidth;
93  out << m_antiAliasing; // Added in v1
94  }
95 }
96 
97 /*---------------------------------------------------------------
98  Implements the reading from a CStream capability of
99  CSerializable objects
100  ---------------------------------------------------------------*/
102 {
103  switch (version)
104  {
105  case 1:
106  {
108  in >> m_x0 >> m_y0 >> m_z0;
109  in >> m_x1 >> m_y1 >> m_z1 >> m_lineWidth;
110  if (version >= 1)
111  in >> m_antiAliasing;
112  else
113  m_antiAliasing = true;
114  }
115  break;
116  default:
118  };
120 }
121 
123  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
124 {
125  bb_min.x = std::min(m_x0, m_x1);
126  bb_min.y = std::min(m_y0, m_y1);
127  bb_min.z = std::min(m_z0, m_z1);
128 
129  bb_max.x = std::max(m_x0, m_x1);
130  bb_max.y = std::max(m_y0, m_y1);
131  bb_max.z = std::max(m_z0, m_z1);
132 
133  // Convert to coordinates of my parent:
134  m_pose.composePoint(bb_min, bb_min);
135  m_pose.composePoint(bb_max, bb_max);
136 }
void readFromStream(mrpt::utils::CStream &in, int version) override
Introduces a pure virtual method responsible for loading from a CStream This can not be used directly...
void writeToStreamRender(utils::CStream &out) const
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
#define min(a, b)
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:287
std::shared_ptr< CObject > Ptr
Definition: CObject.h:154
GLAPI void GLAPIENTRY glPopAttrib(void)
#define GL_LIGHTING
Definition: glew.h:385
GLAPI void GLAPIENTRY glLineWidth(GLfloat width)
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
Definition: CRenderizable.h:57
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:265
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:41
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
#define GL_LINE_SMOOTH
Definition: glew.h:367
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
void readFromStreamRender(mrpt::utils::CStream &in)
void render_dl() const override
Render.
Definition: CSimpleLine.cpp:47
mrpt::utils::TColor m_color
Color components in the range [0,255].
Definition: CRenderizable.h:54
double x
X,Y,Z coordinates.
GLAPI void GLAPIENTRY glBegin(GLenum mode)
#define GL_BLEND
Definition: glew.h:432
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...
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
#define GL_SRC_ALPHA
Definition: glew.h:286
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.
A line segment.
Definition: CSimpleLine.h:22
GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask)
CSimpleLine(float x0=0, float y0=0, float z0=0, float x1=0, float y1=0, float z1=0, float lineWidth=1, bool antiAliasing=true)
Constructor.
Definition: CSimpleLine.cpp:30
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:453
GLuint in
Definition: glext.h:7274
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
GLAPI void GLAPIENTRY glEnd(void)
#define GL_LINES
Definition: glew.h:273
Lightweight 3D point.
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const override
Introduces a pure virtual method responsible for writing to a CStream.
Definition: CSimpleLine.cpp:84
GLAPI void GLAPIENTRY glDisable(GLenum cap)
std::shared_ptr< CSimpleLine > Ptr
Definition: CSimpleLine.h:24
INT32 z1
Definition: jidctint.cpp:130
#define GL_LINE_BIT
Definition: glew.h:253



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019