973c2be1 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
2 | // |
973c2be1 |
3 | // This file is part of Open CASCADE Technology software library. |
b311480e |
4 | // |
d5f74e42 |
5 | // This library is free software; you can redistribute it and/or modify it under |
6 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
7 | // by the Free Software Foundation, with special exception defined in the file |
8 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
9 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
10 | // |
973c2be1 |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
b311480e |
13 | |
7fd59977 |
14 | |
42cf5bc1 |
15 | #include <Standard_GUID.hxx> |
16 | #include <Standard_Type.hxx> |
17 | #include <TCollection_HAsciiString.hxx> |
18 | #include <TDF_Attribute.hxx> |
19 | #include <TDF_Label.hxx> |
7fd59977 |
20 | #include <TDF_RelocationTable.hxx> |
42cf5bc1 |
21 | #include <XCAFDoc_Material.hxx> |
7fd59977 |
22 | |
92efcf78 |
23 | IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_Material,TDF_Attribute) |
24 | |
7fd59977 |
25 | //======================================================================= |
26 | //function : XCAFDoc_Material |
27 | //purpose : |
28 | //======================================================================= |
7fd59977 |
29 | XCAFDoc_Material::XCAFDoc_Material() |
30 | { |
31 | } |
32 | |
33 | |
34 | //======================================================================= |
35 | //function : GetID |
36 | //purpose : |
37 | //======================================================================= |
38 | |
39 | const Standard_GUID& XCAFDoc_Material::GetID() |
40 | { |
41 | static Standard_GUID MatID ("efd212f8-6dfd-11d4-b9c8-0060b0ee281b"); |
42 | return MatID; |
43 | } |
44 | |
45 | |
46 | //======================================================================= |
47 | //function : Set |
48 | //purpose : |
49 | //======================================================================= |
50 | |
51 | Handle(XCAFDoc_Material) XCAFDoc_Material::Set(const TDF_Label& label, |
52 | const Handle(TCollection_HAsciiString)& aName, |
53 | const Handle(TCollection_HAsciiString)& aDescription, |
54 | const Standard_Real aDensity, |
55 | const Handle(TCollection_HAsciiString)& aDensName, |
56 | const Handle(TCollection_HAsciiString)& aDensValType) |
57 | { |
58 | Handle(XCAFDoc_Material) A; |
59 | if (!label.FindAttribute(XCAFDoc_Material::GetID(), A)) { |
60 | A = new XCAFDoc_Material(); |
61 | label.AddAttribute(A); |
62 | } |
63 | A->Set(aName,aDescription,aDensity,aDensName,aDensValType); |
64 | return A; |
65 | } |
66 | |
67 | |
68 | //======================================================================= |
69 | //function : Set |
70 | //purpose : |
71 | //======================================================================= |
72 | |
73 | void XCAFDoc_Material::Set(const Handle(TCollection_HAsciiString)& aName, |
74 | const Handle(TCollection_HAsciiString)& aDescription, |
75 | const Standard_Real aDensity, |
76 | const Handle(TCollection_HAsciiString)& aDensName, |
77 | const Handle(TCollection_HAsciiString)& aDensValType) |
78 | { |
79 | myName = aName; |
80 | myDescription = aDescription; |
81 | myDensity = aDensity; |
82 | myDensName = aDensName; |
83 | myDensValType = aDensValType; |
84 | } |
85 | |
86 | |
87 | //======================================================================= |
88 | //function : GetName |
89 | //purpose : |
90 | //======================================================================= |
91 | |
92 | Handle(TCollection_HAsciiString) XCAFDoc_Material::GetName() const |
93 | { |
94 | return myName; |
95 | } |
96 | |
97 | |
98 | //======================================================================= |
99 | //function : GetDescription |
100 | //purpose : |
101 | //======================================================================= |
102 | |
103 | Handle(TCollection_HAsciiString) XCAFDoc_Material::GetDescription() const |
104 | { |
105 | return myDescription; |
106 | } |
107 | |
108 | |
109 | //======================================================================= |
110 | //function : GetDensity |
111 | //purpose : |
112 | //======================================================================= |
113 | |
114 | Standard_Real XCAFDoc_Material::GetDensity() const |
115 | { |
116 | return myDensity; |
117 | } |
118 | |
119 | |
120 | //======================================================================= |
121 | //function : GetDensName |
122 | //purpose : |
123 | //======================================================================= |
124 | |
125 | Handle(TCollection_HAsciiString) XCAFDoc_Material::GetDensName() const |
126 | { |
127 | return myDensName; |
128 | } |
129 | |
130 | |
131 | //======================================================================= |
132 | //function : GetDensValType |
133 | //purpose : |
134 | //======================================================================= |
135 | |
136 | Handle(TCollection_HAsciiString) XCAFDoc_Material::GetDensValType() const |
137 | { |
138 | return myDensValType; |
139 | } |
140 | |
141 | |
142 | //======================================================================= |
143 | //function : ID |
144 | //purpose : |
145 | //======================================================================= |
146 | |
147 | const Standard_GUID& XCAFDoc_Material::ID() const |
148 | { |
149 | return GetID(); |
150 | } |
151 | |
152 | |
153 | //======================================================================= |
154 | //function : Restore |
155 | //purpose : |
156 | //======================================================================= |
157 | |
158 | void XCAFDoc_Material::Restore(const Handle(TDF_Attribute)& With) |
159 | { |
160 | myName = Handle(XCAFDoc_Material)::DownCast(With)->GetName(); |
161 | myDensity = Handle(XCAFDoc_Material)::DownCast(With)->GetDensity(); |
162 | myDescription = Handle(XCAFDoc_Material)::DownCast(With)->GetDescription(); |
163 | myDensName = Handle(XCAFDoc_Material)::DownCast(With)->GetDensName(); |
164 | myDensValType = Handle(XCAFDoc_Material)::DownCast(With)->GetDensValType(); |
165 | } |
166 | |
167 | |
168 | //======================================================================= |
169 | //function : NewEmpty |
170 | //purpose : |
171 | //======================================================================= |
172 | |
173 | Handle(TDF_Attribute) XCAFDoc_Material::NewEmpty() const |
174 | { |
175 | return new XCAFDoc_Material(); |
176 | } |
177 | |
178 | |
179 | //======================================================================= |
180 | //function : Paste |
181 | //purpose : |
182 | //======================================================================= |
183 | |
184 | void XCAFDoc_Material::Paste(const Handle(TDF_Attribute)& Into, |
185 | const Handle(TDF_RelocationTable)& /*RT*/) const |
186 | { |
187 | Handle(XCAFDoc_Material)::DownCast(Into)->Set(myName,myDescription,myDensity, |
188 | myDensName,myDensValType); |
189 | } |
190 | |