VTK  9.1.0
Group.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../Types.h"
4 #include "Geometry.h"
5 
6 #include <VisRTX.h>
7 
8 #include <set>
9 
10 namespace RTW
11 {
12  class Group : public Object
13  {
14  friend class World;
15 
16  public:
18 
19  ~Group() {}
20 
21  void Commit() override {}
22 
23  void SetObject(const std::string& id, Object *object) override
24  {
25  Object::SetObject(id, object);
26  if(object && object->GetDataType() == RTW_DATA)
27  {
28  Data *data = reinterpret_cast<Data *>(object);
29  if(data->GetElementDataType() == RTW_GEOMETRIC_MODEL)
30  {
31  int numElements = data->GetNumElements();
32  Object **elemData = reinterpret_cast<Object **>(data->GetData());
33  while(numElements-- > 0)
34  {
35  Object *elem = *elemData;
36  assert(elem->GetDataType() == RTW_GEOMETRIC_MODEL);
37  geometricModels.insert(reinterpret_cast<GeometricModel *>(elem));
38  elemData++;
39  }
40  }
41  }
42  else if(object && object->GetDataType() == RTW_GEOMETRIC_MODEL)
43  geometricModels.insert(reinterpret_cast<GeometricModel *>(object));
44  }
45 
46  void RemoveParam(const std::string& id) override
47  {
48  Object *obj = GetObject({id});
49  if(obj && obj->GetDataType() == RTW_GEOMETRIC_MODEL)
50  geometricModels.erase(reinterpret_cast<GeometricModel *>(obj));
52  }
53 
54 
55  private:
56  std::set<GeometricModel *> geometricModels;
57 
58  };
59 }
@ RTW_GROUP
Definition: Types.h:140
@ RTW_GEOMETRIC_MODEL
Definition: Types.h:138
@ RTW_DATA
Definition: Types.h:134
Definition: Data.h:10
void SetObject(const std::string &id, Object *object) override
Definition: Group.h:23
~Group()
Definition: Group.h:19
Group()
Definition: Group.h:17
void Commit() override
Definition: Group.h:21
void RemoveParam(const std::string &id) override
Definition: Group.h:46
RTWDataType GetDataType() const
Definition: Object.h:306
virtual void SetObject(const std::string &id, Object *object)
Definition: Object.h:78
T * GetObject(const std::vector< std::string > &ids, T *defaultValue=nullptr, bool *found=nullptr) const
Definition: Object.h:98
virtual void RemoveParam(const std::string &id)
Definition: Object.h:230
Definition: Backend.h:6
@ data
Definition: vtkX3D.h:321
@ string
Definition: vtkX3D.h:496