MVSim
Lightweight simulator for 2.5D vehicles and robots
CollisionShapeCache.h
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014-2026 Jose Luis Blanco Claraco |
5  | Copyright (C) 2017 Borys Tymchenko (Odessa Polytechnic University) |
6  | Distributed under 3-clause BSD License |
7  | See COPYING |
8  +-------------------------------------------------------------------------+ */
9 
10 #include <mrpt/opengl/CRenderizable.h>
11 #include <mvsim/Shape2p5.h>
12 
13 #include <map>
14 #include <optional>
15 #include <string>
16 
17 namespace mvsim
18 {
21 {
22  public:
23  static CollisionShapeCache& Instance();
24 
27  mrpt::opengl::CRenderizable& obj, float zMin, float zMax,
28  const mrpt::poses::CPose3D& modelPose, const float modelScale,
29  const std::optional<std::string>& modelFile = std::nullopt);
30 
31  void clear() { cache.clear(); }
32 
33  private:
34  CollisionShapeCache() = default;
35  ~CollisionShapeCache() = default;
36 
37  struct Entry
38  {
39  Shape2p5 shape;
40  };
41 
42  std::map<std::string, Entry> cache;
43 
47  std::optional<Shape2p5> processSimpleGeometries(
48  const mrpt::opengl::CRenderizable& obj, float zMin, float zMax,
49  const mrpt::poses::CPose3D& modelPose, const float modelScale);
50 
51  Shape2p5 processGenericGeometry(
52  mrpt::opengl::CRenderizable& obj, float zMin, float zMax,
53  const mrpt::poses::CPose3D& modelPose, const float modelScale);
54 
55  Shape2p5 processCylinderLike(
56  const size_t actualEdgeCount, double actualRadius, float zMin, float zMax,
57  const mrpt::poses::CPose3D& modelPose, const float modelScale);
58 };
59 
60 } // namespace mvsim
Definition: CollisionShapeCache.h:21
Shape2p5 get(mrpt::opengl::CRenderizable &obj, float zMin, float zMax, const mrpt::poses::CPose3D &modelPose, const float modelScale, const std::optional< std::string > &modelFile=std::nullopt)
Definition: Shape2p5.h:31