1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
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>
20 #include <TDF_RelocationTable.hxx>
21 #include <XCAFDoc_Material.hxx>
23 IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_Material,TDF_Attribute)
25 //=======================================================================
26 //function : XCAFDoc_Material
28 //=======================================================================
29 XCAFDoc_Material::XCAFDoc_Material()
34 //=======================================================================
37 //=======================================================================
39 const Standard_GUID& XCAFDoc_Material::GetID()
41 static Standard_GUID MatID ("efd212f8-6dfd-11d4-b9c8-0060b0ee281b");
46 //=======================================================================
49 //=======================================================================
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)
58 Handle(XCAFDoc_Material) A;
59 if (!label.FindAttribute(XCAFDoc_Material::GetID(), A)) {
60 A = new XCAFDoc_Material();
61 label.AddAttribute(A);
63 A->Set(aName,aDescription,aDensity,aDensName,aDensValType);
68 //=======================================================================
71 //=======================================================================
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)
80 myDescription = aDescription;
82 myDensName = aDensName;
83 myDensValType = aDensValType;
87 //=======================================================================
90 //=======================================================================
92 Handle(TCollection_HAsciiString) XCAFDoc_Material::GetName() const
98 //=======================================================================
99 //function : GetDescription
101 //=======================================================================
103 Handle(TCollection_HAsciiString) XCAFDoc_Material::GetDescription() const
105 return myDescription;
109 //=======================================================================
110 //function : GetDensity
112 //=======================================================================
114 Standard_Real XCAFDoc_Material::GetDensity() const
120 //=======================================================================
121 //function : GetDensName
123 //=======================================================================
125 Handle(TCollection_HAsciiString) XCAFDoc_Material::GetDensName() const
131 //=======================================================================
132 //function : GetDensValType
134 //=======================================================================
136 Handle(TCollection_HAsciiString) XCAFDoc_Material::GetDensValType() const
138 return myDensValType;
142 //=======================================================================
145 //=======================================================================
147 const Standard_GUID& XCAFDoc_Material::ID() const
153 //=======================================================================
156 //=======================================================================
158 void XCAFDoc_Material::Restore(const Handle(TDF_Attribute)& With)
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();
168 //=======================================================================
169 //function : NewEmpty
171 //=======================================================================
173 Handle(TDF_Attribute) XCAFDoc_Material::NewEmpty() const
175 return new XCAFDoc_Material();
179 //=======================================================================
182 //=======================================================================
184 void XCAFDoc_Material::Paste(const Handle(TDF_Attribute)& Into,
185 const Handle(TDF_RelocationTable)& /*RT*/) const
187 Handle(XCAFDoc_Material)::DownCast(Into)->Set(myName,myDescription,myDensity,
188 myDensName,myDensValType);