Main MRPT website > C++ reference for MRPT 1.5.6
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 
24 CSimpleLinePtr CSimpleLine::Create(
25  float x0,float y0, float z0,
26  float x1,float y1, float z1, float lineWidth )
27 {
28  return CSimpleLinePtr(new CSimpleLine(x0,y0,z0,x1,y1,z1,lineWidth));
29 }
30 
32  float x0,float y0, float z0,
33  float x1,float y1, float z1, float lineWidth,
34  bool antiAliasing) :
35  m_x0(x0),m_y0(y0),m_z0(z0),
36  m_x1(x1),m_y1(y1),m_z1(z1),
37  m_lineWidth(lineWidth),
38  m_antiAliasing(antiAliasing)
39 {
40 }
41 
42 /*---------------------------------------------------------------
43  render_dl
44  ---------------------------------------------------------------*/
46 {
47 #if MRPT_HAS_OPENGL_GLUT
48  // Enable antialiasing:
49  if (m_antiAliasing)
50  {
55  }
57 
58  glDisable(GL_LIGHTING); // Disable lights when drawing lines
59  glBegin( GL_LINES );
60 
62  glVertex3f( m_x0, m_y0, m_z0 );
63  glVertex3f( m_x1, m_y1, m_z1 );
64 
65  glEnd();
67  glEnable(GL_LIGHTING); // Disable lights when drawing lines
68 
69  // End antialiasing:
70  if (m_antiAliasing)
71  {
72  glPopAttrib();
74  }
75 #endif
76 }
77 
78 /*---------------------------------------------------------------
79  Implements the writing to a CStream capability of
80  CSerializable objects
81  ---------------------------------------------------------------*/
83 {
84 
85  if (version)
86  *version = 1;
87  else
88  {
90  out << m_x0 << m_y0 << m_z0;
91  out << m_x1 << m_y1 << m_z1 << m_lineWidth;
92  out << m_antiAliasing; // Added in v1
93  }
94 }
95 
96 /*---------------------------------------------------------------
97  Implements the reading from a CStream capability of
98  CSerializable objects
99  ---------------------------------------------------------------*/
101 {
102  switch(version)
103  {
104  case 1:
105  {
107  in >> m_x0 >> m_y0 >> m_z0;
108  in >> m_x1 >> m_y1 >> m_z1 >> m_lineWidth;
109  if (version>=1)
110  in >> m_antiAliasing;
111  else m_antiAliasing=true;
112  } break;
113  default:
115 
116  };
118 }
119 
121 {
122  bb_min.x = std::min(m_x0, m_x1);
123  bb_min.y = std::min(m_y0, m_y1);
124  bb_min.z = std::min(m_z0, m_z1);
125 
126  bb_max.x = std::max(m_x0, m_x1);
127  bb_max.y = std::max(m_y0, m_y1);
128  bb_max.z = std::max(m_z0, m_z1);
129 
130  // Convert to coordinates of my parent:
131  m_pose.composePoint(bb_min, bb_min);
132  m_pose.composePoint(bb_max, bb_max);
133 }
void render_dl() const MRPT_OVERRIDE
Render.
Definition: CSimpleLine.cpp:45
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
#define min(a, b)
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.
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...
#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
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
This base provides a set of functions for maths stuff.
Definition: CArrayNumeric.h:19
#define GL_LINE_SMOOTH
Definition: glew.h:363
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
void readFromStreamRender(mrpt::utils::CStream &in)
mrpt::utils::TColor m_color
Color components in the range [0,255].
Definition: CRenderizable.h:54
int version
Definition: mrpt_jpeglib.h:898
GLAPI void GLAPIENTRY glBegin(GLenum mode)
#define GL_BLEND
Definition: glew.h:428
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
void writeToStream(mrpt::utils::CStream &out, int *getVersion) const
Introduces a pure virtual method responsible for writing to a CStream.
Definition: CSimpleLine.cpp:82
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
#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.
A line segment.
Definition: CSimpleLine.h:27
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:31
GLuint in
Definition: glext.h:6301
The namespace for 3D scene representation and rendering.
GLAPI void GLAPIENTRY glEnd(void)
#define GL_LINES
Definition: glew.h:269
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.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019