Blender  V2.93
Rep.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
17 #pragma once
18 
25 #include <string>
26 
27 #include "FrsMaterial.h"
28 #include "SceneVisitor.h"
29 
30 #include "../geometry/BBox.h"
31 #include "../geometry/Geom.h"
32 
33 #include "../system/BaseObject.h"
34 #include "../system/Id.h"
35 #include "../system/Precision.h"
36 
37 using namespace std;
38 
39 namespace Freestyle {
40 
41 using namespace Geometry;
42 
43 class Rep : public BaseObject {
44  public:
45  inline Rep() : BaseObject()
46  {
47  _Id = 0;
48  _FrsMaterial = 0;
49  }
50 
51  inline Rep(const Rep &iBrother) : BaseObject()
52  {
53  _Id = iBrother._Id;
54  _Name = iBrother._Name;
55  _LibraryPath = iBrother._LibraryPath;
56  if (0 == iBrother._FrsMaterial) {
57  _FrsMaterial = 0;
58  }
59  else {
60  _FrsMaterial = new FrsMaterial(*(iBrother._FrsMaterial));
61  }
62 
63  _BBox = iBrother.bbox();
64  }
65 
66  inline void swap(Rep &ioOther)
67  {
68  std::swap(_BBox, ioOther._BBox);
69  std::swap(_Id, ioOther._Id);
70  std::swap(_Name, ioOther._Name);
71  std::swap(_LibraryPath, ioOther._LibraryPath);
72  std::swap(_FrsMaterial, ioOther._FrsMaterial);
73  }
74 
75  Rep &operator=(const Rep &iBrother)
76  {
77  if (&iBrother != this) {
78  _Id = iBrother._Id;
79  _Name = iBrother._Name;
80  _LibraryPath = iBrother._LibraryPath;
81  if (0 == iBrother._FrsMaterial) {
82  _FrsMaterial = 0;
83  }
84  else {
85  if (_FrsMaterial == 0) {
86  _FrsMaterial = new FrsMaterial(*iBrother._FrsMaterial);
87  }
88  else {
89  (*_FrsMaterial) = (*(iBrother._FrsMaterial));
90  }
91  _BBox = iBrother.bbox();
92  }
93  }
94  return *this;
95  }
96 
97  virtual ~Rep()
98  {
99  if (0 != _FrsMaterial) {
100  delete _FrsMaterial;
101  _FrsMaterial = 0;
102  }
103  }
104 
108  virtual void accept(SceneVisitor &v)
109  {
110  if (_FrsMaterial) {
111  v.visitFrsMaterial(*_FrsMaterial);
112  }
113  v.visitRep(*this);
114  }
115 
120  virtual void ComputeBBox() = 0;
121 
123  virtual const BBox<Vec3f> &bbox() const
124  {
125  return _BBox;
126  }
127 
128  inline Id getId() const
129  {
130  return _Id;
131  }
132 
133  inline const string &getName() const
134  {
135  return _Name;
136  }
137 
138  inline const string &getLibraryPath() const
139  {
140  return _LibraryPath;
141  }
142 
143  inline const FrsMaterial *frs_material() const
144  {
145  return _FrsMaterial;
146  }
147 
149  virtual void setBBox(const BBox<Vec3f> &iBox)
150  {
151  _BBox = iBox;
152  }
153 
154  inline void setId(const Id &id)
155  {
156  _Id = id;
157  }
158 
159  inline void setName(const string &name)
160  {
161  _Name = name;
162  }
163 
164  inline void setLibraryPath(const string &path)
165  {
166  _LibraryPath = path;
167  }
168 
169  inline void setFrsMaterial(const FrsMaterial &iMaterial)
170  {
171  _FrsMaterial = new FrsMaterial(iMaterial);
172  }
173 
174  private:
175  BBox<Vec3f> _BBox;
176  Id _Id;
177  string _Name;
178  string _LibraryPath;
179  FrsMaterial *_FrsMaterial;
180 };
181 
182 } /* namespace Freestyle */
void swap(T &a, T &b)
Definition: Common.h:33
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:66
void setLibraryPath(const string &path)
Definition: Rep.h:164
virtual ~Rep()
Definition: Rep.h:97
void setId(const Id &id)
Definition: Rep.h:154
virtual const BBox< Vec3f > & bbox() const
Definition: Rep.h:123
virtual void accept(SceneVisitor &v)
Definition: Rep.h:108
void setFrsMaterial(const FrsMaterial &iMaterial)
Definition: Rep.h:169
virtual void setBBox(const BBox< Vec3f > &iBox)
Definition: Rep.h:149
Id getId() const
Definition: Rep.h:128
const string & getLibraryPath() const
Definition: Rep.h:138
virtual void ComputeBBox()=0
Rep(const Rep &iBrother)
Definition: Rep.h:51
const string & getName() const
Definition: Rep.h:133
const FrsMaterial * frs_material() const
Definition: Rep.h:143
void setName(const string &name)
Definition: Rep.h:159
Rep & operator=(const Rep &iBrother)
Definition: Rep.h:75
inherits from class Rep
Definition: AppCanvas.cpp:32