Blender V4.3
Rep.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
13#include <string>
14
15#include "FrsMaterial.h"
16#include "SceneVisitor.h"
17
18#include "../geometry/BBox.h"
19#include "../geometry/Geom.h"
20
22#include "../system/Id.h"
23#include "../system/Precision.h"
24
25using namespace std;
26
27namespace Freestyle {
28
29using namespace Geometry;
30
31class Rep : public BaseObject {
32 public:
33 inline Rep() : BaseObject()
34 {
35 _Id = 0;
36 _FrsMaterial = 0;
37 }
38
39 inline Rep(const Rep &iBrother) : BaseObject()
40 {
41 _Id = iBrother._Id;
42 _Name = iBrother._Name;
43 _LibraryPath = iBrother._LibraryPath;
44 if (0 == iBrother._FrsMaterial) {
45 _FrsMaterial = 0;
46 }
47 else {
48 _FrsMaterial = new FrsMaterial(*(iBrother._FrsMaterial));
49 }
50
51 _BBox = iBrother.bbox();
52 }
53
54 inline void swap(Rep &ioOther)
55 {
56 std::swap(_BBox, ioOther._BBox);
57 std::swap(_Id, ioOther._Id);
58 std::swap(_Name, ioOther._Name);
59 std::swap(_LibraryPath, ioOther._LibraryPath);
60 std::swap(_FrsMaterial, ioOther._FrsMaterial);
61 }
62
63 Rep &operator=(const Rep &iBrother)
64 {
65 if (&iBrother != this) {
66 _Id = iBrother._Id;
67 _Name = iBrother._Name;
68 _LibraryPath = iBrother._LibraryPath;
69 if (0 == iBrother._FrsMaterial) {
70 _FrsMaterial = 0;
71 }
72 else {
73 if (_FrsMaterial == 0) {
74 _FrsMaterial = new FrsMaterial(*iBrother._FrsMaterial);
75 }
76 else {
77 (*_FrsMaterial) = (*(iBrother._FrsMaterial));
78 }
79 _BBox = iBrother.bbox();
80 }
81 }
82 return *this;
83 }
84
85 virtual ~Rep()
86 {
87 if (0 != _FrsMaterial) {
88 delete _FrsMaterial;
89 _FrsMaterial = 0;
90 }
91 }
92
96 virtual void accept(SceneVisitor &v)
97 {
98 if (_FrsMaterial) {
99 v.visitFrsMaterial(*_FrsMaterial);
100 }
101 v.visitRep(*this);
102 }
103
108 virtual void ComputeBBox() = 0;
109
111 virtual const BBox<Vec3f> &bbox() const
112 {
113 return _BBox;
114 }
115
116 inline Id getId() const
117 {
118 return _Id;
119 }
120
121 inline const string &getName() const
122 {
123 return _Name;
124 }
125
126 inline const string &getLibraryPath() const
127 {
128 return _LibraryPath;
129 }
130
131 inline const FrsMaterial *frs_material() const
132 {
133 return _FrsMaterial;
134 }
135
137 virtual void setBBox(const BBox<Vec3f> &iBox)
138 {
139 _BBox = iBox;
140 }
141
142 inline void setId(const Id &id)
143 {
144 _Id = id;
145 }
146
147 inline void setName(const string &name)
148 {
149 _Name = name;
150 }
151
152 inline void setLibraryPath(const string &path)
153 {
154 _LibraryPath = path;
155 }
156
157 inline void setFrsMaterial(const FrsMaterial &iMaterial)
158 {
159 _FrsMaterial = new FrsMaterial(iMaterial);
160 }
161
162 private:
163 BBox<Vec3f> _BBox;
164 Id _Id;
165 string _Name;
166 string _LibraryPath;
167 FrsMaterial *_FrsMaterial;
168};
169
170} /* namespace Freestyle */
A class to hold a bounding box.
Base Class for most shared objects (Node, Rep). Defines the addRef, release system.
Class used to handle materials.
Vectors and Matrices (useful type definitions)
Identification system.
Define the float precision used in the program.
Class to visit (without doing anything) a scene graph structure.
ATTR_WARN_UNUSED_RESULT const BMVert * v
void swap(Rep &ioOther)
Definition Rep.h:54
void setLibraryPath(const string &path)
Definition Rep.h:152
virtual ~Rep()
Definition Rep.h:85
const FrsMaterial * frs_material() const
Definition Rep.h:131
void setId(const Id &id)
Definition Rep.h:142
const string & getLibraryPath() const
Definition Rep.h:126
virtual void accept(SceneVisitor &v)
Definition Rep.h:96
void setFrsMaterial(const FrsMaterial &iMaterial)
Definition Rep.h:157
const string & getName() const
Definition Rep.h:121
virtual void setBBox(const BBox< Vec3f > &iBox)
Definition Rep.h:137
Id getId() const
Definition Rep.h:116
Rep & operator=(const Rep &iBrother)
Definition Rep.h:63
virtual void ComputeBBox()=0
Rep(const Rep &iBrother)
Definition Rep.h:39
virtual const BBox< Vec3f > & bbox() const
Definition Rep.h:111
void setName(const string &name)
Definition Rep.h:147
inherits from class Rep
Definition AppCanvas.cpp:20