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-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 }
glBegin
GLAPI void GLAPIENTRY glBegin(GLenum mode)
mrpt::opengl::CSimpleLine::render_dl
void render_dl() const override
Render.
Definition: CSimpleLine.cpp:47
mrpt::opengl::CSimpleLine::m_z0
float m_z0
Definition: CSimpleLine.h:27
GL_SRC_ALPHA
#define GL_SRC_ALPHA
Definition: glew.h:286
CSimpleLine.h
mrpt::opengl::CSimpleLine::serializeTo
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CSimpleLine.cpp:81
mrpt::opengl::CSimpleLine::Ptr
std::shared_ptr< CSimpleLine > Ptr
Definition: CSimpleLine.h:24
mrpt::opengl::CSimpleLine::m_x0
float m_x0
Definition: CSimpleLine.h:27
GL_BLEND
#define GL_BLEND
Definition: glew.h:432
glColor4ub
GLAPI void GLAPIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
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::CSimpleLine::m_lineWidth
float m_lineWidth
Definition: CSimpleLine.h:29
mrpt::img::TColor::R
uint8_t R
Definition: TColor.h:48
glEnable
GLAPI void GLAPIENTRY glEnable(GLenum cap)
mrpt::opengl::CRenderizable::Ptr
std::shared_ptr< CRenderizable > Ptr
Definition: CRenderizable.h:45
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
uint8_t
unsigned char uint8_t
Definition: rptypes.h:41
glVertex3f
GLAPI void GLAPIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z)
mrpt::opengl::CSimpleLine::m_antiAliasing
bool m_antiAliasing
Definition: CSimpleLine.h:30
mrpt::opengl::CSimpleLine
A line segment.
Definition: CSimpleLine.h:22
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:48
mrpt::opengl::CSimpleLine::m_x1
float m_x1
Definition: CSimpleLine.h:28
mrpt::opengl::CSimpleLine::m_z1
float m_z1
Definition: CSimpleLine.h:28
glEnd
GLAPI void GLAPIENTRY glEnd(void)
mrpt::img::TColor::B
uint8_t B
Definition: TColor.h:48
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::m_color
mrpt::img::TColor m_color
Color components in the range [0,255].
Definition: CRenderizable.h:54
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::CSimpleLine::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: CSimpleLine.cpp:111
mrpt::math::TPoint3D::x
double x
X,Y,Z coordinates.
Definition: lightweight_geom_data.h:385
mrpt::opengl::CSimpleLine::serializeFrom
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
mrpt::img::TColor::A
uint8_t A
Definition: TColor.h:48
IMPLEMENTS_SERIALIZABLE
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
This must be inserted in all CSerializable classes implementation files.
Definition: CSerializable.h:114
GL_LINES
#define GL_LINES
Definition: glew.h:273
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
mrpt::opengl::CSimpleLine::serializeGetVersion
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Definition: CSimpleLine.cpp:80
opengl-precomp.h
mrpt::math::TPoint3D::y
double y
Definition: lightweight_geom_data.h:385
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
min
#define min(a, b)
Definition: rplidar_driver.cpp:42
opengl_internals.h
mrpt::opengl::CSimpleLine::CSimpleLine
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
glPopAttrib
GLAPI void GLAPIENTRY glPopAttrib(void)
mrpt::img::TColor::G
uint8_t G
Definition: TColor.h:48
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:13
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::CSimpleLine::m_y0
float m_y0
Definition: CSimpleLine.h:27
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
glBlendFunc
GLAPI void GLAPIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor)
GL_COLOR_BUFFER_BIT
#define GL_COLOR_BUFFER_BIT
Definition: glew.h:265
mrpt::opengl::CSimpleLine::m_y1
float m_y1
Definition: CSimpleLine.h:28



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