MRPT  2.0.4
CGridPlaneXY.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 
14 
15 using namespace mrpt;
16 using namespace mrpt::opengl;
17 using namespace std;
18 
21 
22 /** Constructor */
24  float xMin, float xMax, float yMin, float yMax, float z, float frequency,
25  float lineWidth, bool antiAliasing)
26  : m_xMin(xMin),
27  m_xMax(xMax),
28  m_yMin(yMin),
29  m_yMax(yMax),
30  m_plane_z(z),
31  m_frequency(frequency)
32 {
33  m_lineWidth = lineWidth;
34  m_antiAliasing = antiAliasing;
35 }
36 
37 void CGridPlaneXY::onUpdateBuffers_Wireframe()
38 {
40 
41  m_vertex_buffer_data.clear();
42  m_color_buffer_data.clear();
43  for (float y = m_yMin; y <= m_yMax; y += m_frequency)
44  {
45  m_vertex_buffer_data.emplace_back(m_xMin, y, m_plane_z);
46  m_vertex_buffer_data.emplace_back(m_xMax, y, m_plane_z);
47  }
48 
49  for (float x = m_xMin; x <= m_xMax; x += m_frequency)
50  {
51  m_vertex_buffer_data.emplace_back(x, m_yMin, m_plane_z);
52  m_vertex_buffer_data.emplace_back(x, m_yMax, m_plane_z);
53  }
54  // The same color to all vertices:
56 }
57 
58 uint8_t CGridPlaneXY::serializeGetVersion() const { return 1; }
60 {
62  out << m_xMin << m_xMax;
63  out << m_yMin << m_yMax << m_plane_z;
64  out << m_frequency;
65  out << m_lineWidth << m_antiAliasing; // v1
66 }
67 
69  mrpt::serialization::CArchive& in, uint8_t version)
70 {
71  switch (version)
72  {
73  case 0:
74  case 1:
75  {
77  in >> m_xMin >> m_xMax;
78  in >> m_yMin >> m_yMax >> m_plane_z;
79  in >> m_frequency;
80  if (version >= 1)
81  in >> m_lineWidth >> m_antiAliasing;
82  else
83  {
84  m_lineWidth = 1.0f;
85  m_antiAliasing = true;
86  }
87  }
88  break;
89  default:
91  };
93 }
94 
97 {
98  bb_min.x = m_xMin;
99  bb_min.y = m_yMin;
100  bb_min.z = 0;
101 
102  bb_max.x = m_xMax;
103  bb_max.y = m_yMax;
104  bb_max.z = 0;
105 
106  // Convert to coordinates of my parent:
109 }
A grid of lines over the XY plane.
Definition: CGridPlaneXY.h:29
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration.
STL namespace.
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...
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference.
Definition: CRenderizable.h:62
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
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
void writeToStreamRender(mrpt::serialization::CArchive &out) const
IMPLEMENTS_SERIALIZABLE(CGridPlaneXY, CRenderizableShaderWireFrame, mrpt::opengl) CGridPlaneXY
Constructor.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
mrpt::img::TColor m_color
Color components in the range [0,255].
Definition: CRenderizable.h:59
std::vector< mrpt::img::TColor > m_color_buffer_data
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
mrpt::vision::TStereoCalibResults out
Renderizable generic renderer for objects using the wireframe shader.
#define ASSERT_ABOVE_(__A, __B)
Definition: exceptions.h:155
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13
const auto bb_max
void readFromStreamRender(mrpt::serialization::CArchive &in)
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::optional_ref< mrpt::math::CMatrixDouble33 > out_jacobian_df_dpoint=std::nullopt, mrpt::optional_ref< mrpt::math::CMatrixDouble36 > out_jacobian_df_dpose=std::nullopt, mrpt::optional_ref< mrpt::math::CMatrixDouble36 > out_jacobian_df_dse3=std::nullopt, 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...
const auto bb_min
CGridPlaneXY(float xMin=-10, float xMax=10, float yMin=-10, float yMax=10, float z=0, float frequency=1, float lineWidth=1.3f, bool antiAliasing=true)
Constructor.



Page generated by Doxygen 1.8.14 for MRPT 2.0.4 Git: 02a75dd25 Thu Jun 4 01:49:55 2020 +0200 at jue jun 4 02:00:12 CEST 2020