MRPT  1.9.9
CSimpleLine.cpp
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 #include "opengl-precomp.h" // Precompiled header
11 
13 #include <mrpt/opengl/opengl_api.h>
15 
16 using namespace mrpt;
17 using namespace mrpt::opengl;
18 using namespace mrpt::math;
19 using namespace std;
20 
22 
24  float x0, float y0, float z0, float x1, float y1, float z1, float lineWidth,
25  bool antiAliasing)
26  : m_x0(x0), m_y0(y0), m_z0(z0), m_x1(x1), m_y1(y1), m_z1(z1)
27 {
28  m_lineWidth = lineWidth;
29  m_antiAliasing = antiAliasing;
30 }
31 
33 {
35  vbd.resize(2);
36 
37  vbd[0] = {m_x0, m_y0, m_z0};
38  vbd[1] = {m_x1, m_y1, m_z1};
39 
40  // The same color to all vertices:
41  m_color_buffer_data.assign(vbd.size(), m_color);
42 }
43 
44 uint8_t CSimpleLine::serializeGetVersion() const { return 1; }
46 {
47  writeToStreamRender(out);
48  out << m_x0 << m_y0 << m_z0;
49  out << m_x1 << m_y1 << m_z1 << m_lineWidth;
50  out << m_antiAliasing; // Added in v1
51 }
52 
54  mrpt::serialization::CArchive& in, uint8_t version)
55 {
56  switch (version)
57  {
58  case 1:
59  {
60  readFromStreamRender(in);
61  in >> m_x0 >> m_y0 >> m_z0;
62  in >> m_x1 >> m_y1 >> m_z1 >> m_lineWidth;
63  if (version >= 1)
64  in >> m_antiAliasing;
65  else
66  m_antiAliasing = true;
67  }
68  break;
69  default:
71  };
73 }
74 
77 {
78  bb_min.x = std::min(m_x0, m_x1);
79  bb_min.y = std::min(m_y0, m_y1);
80  bb_min.z = std::min(m_z0, m_z1);
81 
82  bb_max.x = std::max(m_x0, m_x1);
83  bb_max.y = std::max(m_y0, m_y1);
84  bb_max.z = std::max(m_z0, m_z1);
85 
86  // Convert to coordinates of my parent:
87  m_pose.composePoint(bb_min, bb_min);
88  m_pose.composePoint(bb_max, bb_max);
89 }
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
void onUpdateBuffers_Wireframe() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
Definition: CSimpleLine.cpp:32
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
Definition: CSimpleLine.cpp:45
STL namespace.
std::vector< mrpt::math::TPoint3Df > m_vertex_buffer_data
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
This base provides a set of functions for maths stuff.
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:75
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:54
A line segment.
Definition: CSimpleLine.h:19
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
Definition: CSimpleLine.cpp:53
mrpt::vision::TStereoCalibResults out
Renderizable generic renderer for objects using the wireframe shader.
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
const auto bb_max
const auto bb_min
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
Definition: CSimpleLine.cpp:44



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020