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