VTK  9.3.0
Group.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 #pragma once
4 
5 #include "../Types.h"
6 #include "Geometry.h"
7 
8 #include <VisRTX.h>
9 
10 #include <set>
11 
12 namespace RTW
13 {
14 VTK_ABI_NAMESPACE_BEGIN
15  class Group : public Object
16  {
17  friend class World;
18 
19  public:
21 
22  ~Group() {}
23 
24  void Commit() override {}
25 
26  void SetObject(const std::string& id, Object *object) override
27  {
28  Object::SetObject(id, object);
29  if(object && object->GetDataType() == RTW_DATA)
30  {
31  Data *data = reinterpret_cast<Data *>(object);
32  if(data->GetElementDataType() == RTW_GEOMETRIC_MODEL)
33  {
34  int numElements = data->GetNumElements();
35  Object **elemData = reinterpret_cast<Object **>(data->GetData());
36  while(numElements-- > 0)
37  {
38  Object *elem = *elemData;
39  assert(elem->GetDataType() == RTW_GEOMETRIC_MODEL);
40  geometricModels.insert(reinterpret_cast<GeometricModel *>(elem));
41  elemData++;
42  }
43  }
44  }
45  else if(object && object->GetDataType() == RTW_GEOMETRIC_MODEL)
46  geometricModels.insert(reinterpret_cast<GeometricModel *>(object));
47  }
48 
49  void RemoveParam(const std::string& id) override
50  {
51  Object *obj = GetObject({id});
52  if(obj && obj->GetDataType() == RTW_GEOMETRIC_MODEL)
53  geometricModels.erase(reinterpret_cast<GeometricModel *>(obj));
55  }
56 
57 
58  private:
59  std::set<GeometricModel *> geometricModels;
60 
61  };
62 VTK_ABI_NAMESPACE_END
63 }
@ RTW_GROUP
Definition: Types.h:144
@ RTW_GEOMETRIC_MODEL
Definition: Types.h:142
@ RTW_DATA
Definition: Types.h:138
Definition: Data.h:13
void SetObject(const std::string &id, Object *object) override
Definition: Group.h:26
~Group()
Definition: Group.h:22
Group()
Definition: Group.h:20
void Commit() override
Definition: Group.h:24
void RemoveParam(const std::string &id) override
Definition: Group.h:49
RTWDataType GetDataType() const
Definition: Object.h:309
virtual void SetObject(const std::string &id, Object *object)
Definition: Object.h:81
T * GetObject(const std::vector< std::string > &ids, T *defaultValue=nullptr, bool *found=nullptr) const
Definition: Object.h:101
virtual void RemoveParam(const std::string &id)
Definition: Object.h:233
Definition: Backend.h:8
@ data
Definition: vtkX3D.h:315
@ string
Definition: vtkX3D.h:490