Helios++
Helios software for LiDAR simulations
VHDynSceneAdapter.h
1 #ifdef PCL_BINDING
2 #ifndef _VHDYNSCENEADAPTER_H_
3 
4 #include <scene/dynamic/DynScene.h>
5 #include <visualhelios/adapters/VHStaticObjectAdapter.h>
6 #include <visualhelios/adapters/VHDynObjectAdapter.h>
7 
8 #include <vector>
9 #include <memory>
10 
11 namespace visualhelios{
12 
13 using std::vector;
14 using std::shared_ptr;
15 using std::static_pointer_cast;
16 
29 template <typename ST, typename DT>
31 protected:
32  // *** ATTRIBUTES *** //
33  // ******************** //
43  vector<shared_ptr<DT>> dynObjs;
49  vector<shared_ptr<ST>> staticObjs;
50 
51 public:
52  // *** CONSTRUCTION / DESTRUCTION *** //
53  // ************************************ //
59  virtual ~VHDynSceneAdapter() = default;
60 
61  // *** DYNAMIC BEHAVIOR *** //
62  // ************************** //
69  bool doStep();
70 
71  // *** GETTERs and SETTERs *** //
72  // ***************************** //
81  inline DynScene & getDynScene() {return dynScene;}
86  inline size_t numStaticObjects() const {return staticObjs.size();}
93  inline shared_ptr<ST> getAdaptedStaticObj(size_t const index)
94  {return staticObjs[index];}
102  inline ScenePart & getStaticObj(size_t const index){
103  return static_pointer_cast<VHStaticObjectAdapter>(staticObjs[index])\
104  ->getStaticObj();
105  }
111  inline bool isStaticObjectRenderingNormals(size_t const index) const{
112  return static_pointer_cast<VHStaticObjectAdapter>(staticObjs[index])\
113  ->isRenderingNormals();
114  }
121  size_t const index,
122  bool const renderingNormals
123  ){
124  static_pointer_cast<VHStaticObjectAdapter>(staticObjs[index])\
125  ->setRenderingNormals(renderingNormals);
126  }
131  inline size_t numDynObjects() const {return dynObjs.size();}
138  inline shared_ptr<DT> getAdaptedDynObj(size_t const index){
139  return dynObjs[index];
140  }
148  inline DynObject & getDynObj(size_t const index){
149  return static_pointer_cast<VHDynObjectAdapter>(dynObjs[index])\
150  ->getDynObj();
151  }
160  inline bool isDynObjectUpdated(size_t const index) const
161  {return dynScene.isDynObjectUpdated(index);}
172  inline bool isDynObjectRenderingNormals(size_t const index) const{
173  return static_pointer_cast<VHDynObjectAdapter>(dynObjs[index])\
174  ->isRenderingNormals();
175  }
182  size_t const index,
183  bool const renderingNormals
184  ){
185  static_pointer_cast<VHDynObjectAdapter>(dynObjs[index])\
186  ->setRenderingNormals(renderingNormals);
187  }
188  inline vector<pcl::Vertices> const & getVertices(size_t const index) const{
189  return static_pointer_cast<VHDynObjectAdapter>(dynObjs[index])\
190  ->getVertices();
191  }
196  inline string const & getId(size_t const index) const{
197  return static_pointer_cast<VHDynObjectAdapter>(dynObjs[index])\
198  ->getId();
199  }
200 };
201 
202 
203 #include <visualhelios/adapters/VHDynSceneAdapter.tpp>
204 }
205 #define _VHDYNSCENEADAPTER_H_
206 #endif
207 #endif
Dynamic object base implementation.
Definition: DynObject.h:23
Dynamic scene base implementation.
Definition: DynScene.h:29
bool isDynObjectUpdated(size_t const index) const
Check whether the dynamic object at given index has been updated on last step (true) or not (false)
Definition: DynScene.h:221
Class representing a scene part.
Definition: ScenePart.h:20
Class defining core mechanisms to adapt dynamic scenes to the visual Helios context based on PCL and ...
Definition: VHDynSceneAdapter.h:30
bool isDynObjectUpdated(size_t const index) const
Check if the dynamic object at given index has been updated on last step (true) or not (false)
Definition: VHDynSceneAdapter.h:160
bool isStaticObjectRenderingNormals(size_t const index) const
Check whether the normals of static object at given index must be rendered or not.
Definition: VHDynSceneAdapter.h:111
shared_ptr< ST > getAdaptedStaticObj(size_t const index)
Obtain the adapted static object at given index.
Definition: VHDynSceneAdapter.h:93
bool isDynObjectRenderingNormals(size_t const index) const
Obtain the ordered vertices indices representing the dynamic object at given index.
Definition: VHDynSceneAdapter.h:172
vector< shared_ptr< DT > > dynObjs
Vector of adapted dynamic objects from the adapted dynamic scene.
Definition: VHDynSceneAdapter.h:43
vector< shared_ptr< ST > > staticObjs
Vector of adapted static objects from the adapted dynamic scene.
Definition: VHDynSceneAdapter.h:49
ScenePart & getStaticObj(size_t const index)
Obtain the static object at given index.
Definition: VHDynSceneAdapter.h:102
DynObject & getDynObj(size_t const index)
Obtain the dynamic object at given index.
Definition: VHDynSceneAdapter.h:148
size_t numDynObjects() const
Obtain the number of dynamic objects composing the dynamic scene.
Definition: VHDynSceneAdapter.h:131
string const & getId(size_t const index) const
Obtain the ID of the dynamic object at given index.
Definition: VHDynSceneAdapter.h:196
shared_ptr< DT > getAdaptedDynObj(size_t const index)
Obtain the adapted dynamic object at given index.
Definition: VHDynSceneAdapter.h:138
bool doStep()
Method to adapt dynamic scene computations over time to visual Helios.
DynScene & getDynScene()
Obtain the adapted dynamic scene.
Definition: VHDynSceneAdapter.h:81
DynScene & dynScene
The adapted dynamic scene.
Definition: VHDynSceneAdapter.h:38
size_t numStaticObjects() const
Obtain the number of static objects composing the dynamic scene.
Definition: VHDynSceneAdapter.h:86
void setStaticObjectRenderingNormals(size_t const index, bool const renderingNormals)
Enable or disable normals rendering for the static object at given index.
Definition: VHDynSceneAdapter.h:120
void setDynObjectRenderingNormals(size_t const index, bool const renderingNormals)
Enable or disable normals rendering for the dynamic object at given index.
Definition: VHDynSceneAdapter.h:181
VHDynSceneAdapter(DynScene &dynScene)
Constructor for the visual Helios dynamic scene adapter.