MRPT  2.0.4
CSetOfTexturedTriangles.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 #include <mrpt/opengl/opengl_api.h>
16 
17 using namespace std;
18 using namespace mrpt;
19 using namespace mrpt::opengl;
20 using namespace mrpt::math;
21 
23 
24 void CSetOfTexturedTriangles::onUpdateBuffers_TexturedTriangles()
25 {
26  // Nothing else to do: all data is already in m_triangles in my base class.
27 }
28 
29 uint8_t CSetOfTexturedTriangles::serializeGetVersion() const { return 2; }
30 void CSetOfTexturedTriangles::serializeTo(
32 {
33  uint32_t n;
34 
35  writeToStreamRender(out);
36  writeToStreamTexturedObject(out);
37 
38  n = (uint32_t)m_triangles.size();
39 
40  out << n;
41 
42  for (uint32_t i = 0; i < n; i++) m_triangles[i].writeTo(out);
43 }
44 
45 void CSetOfTexturedTriangles::serializeFrom(
46  mrpt::serialization::CArchive& in, uint8_t version)
47 {
48  switch (version)
49  {
50  case 0:
51  case 1:
52  case 2:
53  {
54  readFromStreamRender(in);
55  if (version >= 2)
56  {
57  readFromStreamTexturedObject(in);
58  }
59  else
60  { // Old version.
61  THROW_EXCEPTION("deserializing old version not supported.");
62  }
63 
64  uint32_t n;
65  in >> n;
66  m_triangles.resize(n);
67 
68  for (uint32_t i = 0; i < n; i++) m_triangles[i].readFrom(in);
69  }
70  break;
71  default:
73  };
74  CRenderizable::notifyChange();
75 }
76 
78  [[maybe_unused]] const mrpt::poses::CPose3D& o,
79  [[maybe_unused]] double& dist) const
80 {
81  throw std::runtime_error(
82  "TODO: TraceRay not implemented in CSetOfTexturedTriangles");
83 }
84 
85 void CSetOfTexturedTriangles::getBoundingBox(
87 {
89  std::numeric_limits<double>::max(), std::numeric_limits<double>::max(),
90  std::numeric_limits<double>::max());
92  -std::numeric_limits<double>::max(),
93  -std::numeric_limits<double>::max(),
94  -std::numeric_limits<double>::max());
95 
96  for (const auto& t : m_triangles)
97  {
98  for (size_t i = 0; i < 3; i++)
99  {
100  keep_min(bb_min.x, t.x(i));
101  keep_max(bb_max.x, t.x(i));
102 
103  keep_min(bb_min.y, t.y(i));
104  keep_max(bb_max.y, t.y(i));
105 
106  keep_min(bb_min.z, t.z(i));
107  keep_max(bb_max.z, t.z(i));
108  }
109  }
110 
111  // Convert to coordinates of my parent:
112  m_pose.composePoint(bb_min, bb_min);
113  m_pose.composePoint(bb_max, bb_max);
114 }
CSetOfTexturedTriangles.h
opengl_api.h
mrpt::math::TPoint3D
TPoint3D_< double > TPoint3D
Lightweight 3D point.
Definition: TPoint3D.h:268
mrpt::math::TPoint3D_< double >
mrpt::opengl::CRenderizable
The base class of 3D objects that can be directly rendered through OpenGL.
Definition: CRenderizable.h:48
out
mrpt::vision::TStereoCalibResults out
Definition: chessboard_stereo_camera_calib_unittest.cpp:25
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: BaseAppDataSource.h:15
THROW_EXCEPTION
#define THROW_EXCEPTION(msg)
Definition: exceptions.h:67
mrpt::math::traceRay
bool traceRay(const std::vector< TPolygonWithPlane > &vec, const mrpt::math::TPose3D &pose, double &dist)
Fast ray tracing method using polygons' properties.
Definition: geometry.cpp:2484
mrpt::serialization::CArchive
Virtual base class for "archives": classes abstracting I/O streams.
Definition: CArchive.h:54
bb_max
const auto bb_max
Definition: CPose3DPDFGrid_unittest.cpp:25
bb_min
const auto bb_min
Definition: CPose3DPDFGrid_unittest.cpp:23
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:85
mrpt::keep_max
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value.
Definition: core/include/mrpt/core/bits_math.h:152
mrpt::keep_min
void keep_min(T &var, const K test_val)
If the second argument is below the first one, set the first argument to this lower value.
Definition: core/include/mrpt/core/bits_math.h:145
IMPLEMENTS_SERIALIZABLE
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
Definition: CSerializable.h:166
opengl-precomp.h
mrpt::math
This base provides a set of functions for maths stuff.
Definition: math/include/mrpt/math/bits_math.h:11
mrpt::opengl::CSetOfTexturedTriangles
A set of textured triangles.
Definition: CSetOfTexturedTriangles.h:21
CArchive.h
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
Definition: exceptions.h:97
mrpt::opengl
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:13



Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Fri Jul 17 08:43:33 UTC 2020