VTK  9.1.0
GeometricModel.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
10namespace RTW
11{
12 class GeometricModel : public Object
13 {
14 friend class World;
15
16 public:
18 : Object(RTW_GEOMETRIC_MODEL), geometry(_geometry)
19 {
20 if(geometry)
21 geometry->AddRef();
22 }
23
25 {
26 if(geometry)
27 geometry->Release();
28 }
29
30 void Commit() override
31 {
32 //Forward "material" data to geometry if extant.
33 bool found = false;
34 Material *material = reinterpret_cast<Material *>(GetObject<Material>({"material"}, nullptr, &found));
35 if(found)
36 {
37 if(material->GetDataType() == RTW_DATA)
38 {
39 geometry->SetObject("material", reinterpret_cast<Data *>(material));
40 geometry->Commit();
41 }
42 else
43 {
44 assert(material->GetDataType() == RTW_MATERIAL);
45 geometry->SetMaterial(material);
46 geometry->Commit();
47 }
48 }
49
50 //Forward "color" data to geometry if extant.
51 Data *color = reinterpret_cast<Data *>(GetObject<Data>({"color"}, nullptr, &found));
52 if(found)
53 {
54 assert(color->GetDataType() == RTW_DATA);
55 geometry->SetObject("color", color);
56 geometry->Commit();
57 }
58 }
59
60 private:
61 Geometry *geometry;
62 };
63}
@ RTW_MATERIAL
Definition: Types.h:144
@ RTW_GEOMETRIC_MODEL
Definition: Types.h:138
@ RTW_DATA
Definition: Types.h:134
Definition: Data.h:10
void Commit() override
GeometricModel(Geometry *_geometry)
void SetMaterial(Material *material)
Definition: Geometry.h:366
void Commit() override
Definition: Geometry.h:43
RTWDataType GetDataType() const
Definition: Object.h:306
void Release()
Definition: Object.h:43
virtual void SetObject(const std::string &id, Object *object)
Definition: Object.h:78
void AddRef()
Definition: Object.h:38
Definition: Backend.h:6