b311480e |
1 | // Created on: 2000-09-08 |
2 | // Created by: data exchange team |
973c2be1 |
3 | // Copyright (c) 2000-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
7 | // This library is free software; you can redistribute it and/or modify it under |
8 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
9 | // by the Free Software Foundation, with special exception defined in the file |
10 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
11 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
42cf5bc1 |
16 | |
17 | #include <Standard_GUID.hxx> |
18 | #include <Standard_Type.hxx> |
19 | #include <TDF_Attribute.hxx> |
20 | #include <TDF_Label.hxx> |
21 | #include <TDF_RelocationTable.hxx> |
22 | #include <XCAFDoc_Volume.hxx> |
7fd59977 |
23 | |
92efcf78 |
24 | IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_Volume,TDF_Attribute) |
25 | |
7fd59977 |
26 | //======================================================================= |
27 | //function : Constructor |
28 | //purpose : |
29 | //======================================================================= |
7fd59977 |
30 | XCAFDoc_Volume::XCAFDoc_Volume() |
31 | { |
32 | } |
33 | |
34 | //======================================================================= |
35 | //function : GetID |
36 | //purpose : |
37 | //======================================================================= |
38 | |
39 | const Standard_GUID& XCAFDoc_Volume::GetID() |
40 | { |
41 | static Standard_GUID VolumeID ("efd212f1-6dfd-11d4-b9c8-0060b0ee281b"); |
42 | return VolumeID; |
43 | } |
44 | |
45 | //======================================================================= |
46 | //function : ID |
47 | //purpose : |
48 | //======================================================================= |
49 | |
50 | const Standard_GUID& XCAFDoc_Volume::ID() const |
51 | { |
52 | return GetID(); |
53 | } |
54 | |
55 | //======================================================================= |
56 | //function : Set |
57 | //purpose : |
58 | //======================================================================= |
59 | |
60 | Handle(XCAFDoc_Volume) XCAFDoc_Volume::Set (const TDF_Label& L,const Standard_Real V) |
61 | { |
62 | Handle(XCAFDoc_Volume) A; |
63 | if (!L.FindAttribute(XCAFDoc_Volume::GetID(), A)) { |
64 | A = new XCAFDoc_Volume; |
65 | L.AddAttribute(A); |
66 | } |
67 | A->Set(V); |
68 | return A; |
69 | } |
70 | |
71 | //======================================================================= |
72 | //function : Set |
73 | //purpose : |
74 | //======================================================================= |
75 | |
76 | void XCAFDoc_Volume::Set (const Standard_Real V) |
77 | { |
78 | Backup(); |
79 | myValue = V; |
80 | } |
81 | |
82 | //======================================================================= |
83 | //function : Get |
84 | //purpose : |
85 | //======================================================================= |
86 | |
87 | Standard_Real XCAFDoc_Volume::Get() const { return myValue; } |
88 | |
89 | //======================================================================= |
90 | //function : Get |
91 | //purpose : |
92 | //======================================================================= |
93 | |
94 | Standard_Boolean XCAFDoc_Volume::Get(const TDF_Label& label,Standard_Real& vol) |
95 | { |
96 | Handle(XCAFDoc_Volume) aVolume; |
97 | if (!label.FindAttribute(XCAFDoc_Volume::GetID(), aVolume)) |
98 | return Standard_False; |
99 | |
100 | vol = aVolume->Get(); |
101 | return Standard_True; |
102 | } |
103 | |
104 | //======================================================================= |
105 | //function : NewEmpty |
106 | //purpose : |
107 | //======================================================================= |
108 | |
109 | Handle(TDF_Attribute) XCAFDoc_Volume::NewEmpty () const |
110 | { |
111 | return new XCAFDoc_Volume(); |
112 | } |
113 | |
114 | //======================================================================= |
115 | //function : Restore |
116 | //purpose : |
117 | //======================================================================= |
118 | |
119 | void XCAFDoc_Volume::Restore(const Handle(TDF_Attribute)& With) |
120 | { |
121 | Handle(XCAFDoc_Volume) R = Handle(XCAFDoc_Volume)::DownCast (With); |
122 | myValue = R->Get(); |
123 | } |
124 | |
125 | |
126 | //======================================================================= |
127 | //function : Paste |
128 | //purpose : |
129 | //======================================================================= |
130 | |
131 | void XCAFDoc_Volume::Paste (const Handle(TDF_Attribute)& Into, |
132 | const Handle(TDF_RelocationTable)& /* RT */) const |
133 | { |
134 | Handle(XCAFDoc_Volume) R = Handle(XCAFDoc_Volume)::DownCast (Into); |
135 | R->Set(myValue); |
136 | } |
137 | |
138 | //======================================================================= |
139 | //function : Dump |
140 | //purpose : |
141 | //======================================================================= |
142 | |
143 | Standard_OStream& XCAFDoc_Volume::Dump (Standard_OStream& anOS) const |
144 | { |
145 | anOS << "Volume "; |
146 | anOS << Get(); |
147 | return anOS; |
148 | } |