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