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-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 #include "opengl_internals.h"
15 
16 using namespace mrpt;
17 using namespace mrpt::opengl;
18 
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 
82 {
84  out << m_x0 << m_y0 << m_z0;
85  out << m_x1 << m_y1 << m_z1 << m_lineWidth;
86  out << m_antiAliasing; // Added in v1
87 }
88 
91 {
92  switch (version)
93  {
94  case 1:
95  {
97  in >> m_x0 >> m_y0 >> m_z0;
98  in >> m_x1 >> m_y1 >> m_z1 >> m_lineWidth;
99  if (version >= 1)
100  in >> m_antiAliasing;
101  else
102  m_antiAliasing = true;
103  }
104  break;
105  default:
107  };
109 }
110 
112  mrpt::math::TPoint3D& bb_min, mrpt::math::TPoint3D& bb_max) const
113 {
114  bb_min.x = std::min(m_x0, m_x1);
115  bb_min.y = std::min(m_y0, m_y1);
116  bb_min.z = std::min(m_z0, m_z1);
117 
118  bb_max.x = std::max(m_x0, m_x1);
119  bb_max.y = std::max(m_y0, m_y1);
120  bb_max.z = std::max(m_z0, m_z1);
121 
122  // Convert to coordinates of my parent:
123  m_pose.composePoint(bb_min, bb_min);
124  m_pose.composePoint(bb_max, bb_max);
125 }
#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.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CSimpleLine.cpp:81
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.
uint8_t B
Definition: TColor.h:46
#define GL_ONE_MINUS_SRC_ALPHA
Definition: glew.h:287
uint8_t G
Definition: TColor.h:46
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:55
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
unsigned char uint8_t
Definition: rptypes.h:41
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:90
#define GL_COLOR_BUFFER_BIT
Definition: glew.h:265
This base provides a set of functions for maths stuff.
void writeToStreamRender(mrpt::serialization::CArchive &out) const
#define GL_LINE_SMOOTH
Definition: glew.h:367
void render_dl() const override
Render.
Definition: CSimpleLine.cpp:47
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)
uint8_t R
Definition: TColor.h:46
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
mrpt::img::TColor m_color
Color components in the range [0,255].
Definition: CRenderizable.h:52
#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.
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:52
A line segment.
Definition: CSimpleLine.h:20
GLAPI void GLAPIENTRY glPushAttrib(GLbitfield mask)
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: CSimpleLine.cpp:89
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:379
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
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Definition: CSimpleLine.cpp:80
Lightweight 3D point.
GLAPI void GLAPIENTRY glDisable(GLenum cap)
std::shared_ptr< CSimpleLine > Ptr
Definition: CSimpleLine.h:22
void readFromStreamRender(mrpt::serialization::CArchive &in)
#define GL_LINE_BIT
Definition: glew.h:253
uint8_t A
Definition: TColor.h:46



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020