b311480e |
1 | // Created on: 1997-03-06 |
2 | // Created by: Denis PASCAL |
3 | // Copyright (c) 1997-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | #include <TDataStd_Real.ixx> |
24 | #include <TDF_Reference.hxx> |
25 | #include <TDataStd.hxx> |
26 | |
27 | |
28 | //======================================================================= |
29 | //function : GetID |
30 | //purpose : |
31 | //======================================================================= |
32 | |
33 | const Standard_GUID& TDataStd_Real::GetID() |
34 | { |
35 | static Standard_GUID TDataStd_RealID("2a96b60f-ec8b-11d0-bee7-080009dc3333"); |
36 | return TDataStd_RealID; |
37 | } |
38 | |
39 | |
40 | //======================================================================= |
41 | //function : Set |
42 | //purpose : |
43 | //======================================================================= |
44 | |
45 | Handle(TDataStd_Real) TDataStd_Real::Set (const TDF_Label& L, |
46 | const Standard_Real V) |
47 | { |
48 | Handle(TDataStd_Real) A; |
49 | if (!L.FindAttribute(TDataStd_Real::GetID(), A)) { |
50 | A = new TDataStd_Real (); |
51 | L.AddAttribute(A); |
52 | } |
53 | A->Set (V); |
54 | return A; |
55 | } |
56 | |
57 | |
58 | //======================================================================= |
59 | //function : TDataStd_Real |
60 | //purpose : Empty constructor |
61 | //======================================================================= |
62 | |
63 | TDataStd_Real::TDataStd_Real () |
64 | : myValue (RealFirst()), |
65 | myDimension (TDataStd_SCALAR) |
66 | {} |
67 | |
68 | |
69 | |
70 | //======================================================================= |
71 | //function : IsCaptured |
72 | //purpose : |
73 | //======================================================================= |
74 | |
75 | Standard_Boolean TDataStd_Real::IsCaptured() const |
76 | { |
77 | Handle(TDF_Reference) reference; |
78 | // pour test |
79 | |
80 | if (Label().FindAttribute(TDF_Reference::GetID(),reference)) { |
81 | const TDF_Label& label = reference->Get(); |
82 | return label.IsAttribute (TDataStd_Real::GetID()); |
83 | } |
84 | return Standard_False; |
85 | } |
86 | |
87 | |
88 | //======================================================================= |
89 | //function : Set |
90 | //purpose : |
91 | //======================================================================= |
92 | |
93 | void TDataStd_Real::Set(const Standard_Real v) |
94 | { |
95 | // OCC2932 correction |
96 | if( myValue == v) return; |
97 | |
98 | Backup(); |
99 | myValue = v; |
100 | } |
101 | |
102 | //======================================================================= |
103 | //function : Get |
104 | //purpose : |
105 | //======================================================================= |
106 | |
107 | Standard_Real TDataStd_Real::Get() const { return myValue; } |
108 | |
109 | |
110 | //======================================================================= |
111 | //function : SetDimension |
112 | //purpose : |
113 | //======================================================================= |
114 | |
115 | void TDataStd_Real::SetDimension (const TDataStd_RealEnum DIM) |
116 | { |
117 | // OCC2932 correction |
118 | if(myDimension == DIM) return; |
119 | |
120 | Backup(); |
121 | myDimension = DIM; |
122 | } |
123 | |
124 | |
125 | //======================================================================= |
126 | //function : GetDimension |
127 | //purpose : |
128 | //======================================================================= |
129 | |
130 | TDataStd_RealEnum TDataStd_Real::GetDimension () const |
131 | { |
132 | return myDimension; |
133 | } |
134 | |
135 | |
136 | //======================================================================= |
137 | //function : ID |
138 | //purpose : |
139 | //======================================================================= |
140 | |
141 | const Standard_GUID& TDataStd_Real::ID() const { return GetID(); } |
142 | |
143 | |
144 | //======================================================================= |
145 | //function : NewEmpty |
146 | //purpose : |
147 | //======================================================================= |
148 | |
149 | Handle(TDF_Attribute) TDataStd_Real::NewEmpty () const |
150 | { |
151 | return new TDataStd_Real(); |
152 | } |
153 | |
154 | //======================================================================= |
155 | //function : Restore |
156 | //purpose : |
157 | //======================================================================= |
158 | |
159 | void TDataStd_Real::Restore(const Handle(TDF_Attribute)& With) |
160 | { |
161 | Handle(TDataStd_Real) R = Handle(TDataStd_Real)::DownCast (With); |
162 | myValue = R->Get(); |
163 | myDimension = R->GetDimension(); |
164 | } |
165 | |
166 | |
167 | |
168 | //======================================================================= |
169 | //function : Paste |
170 | //purpose : |
171 | //======================================================================= |
172 | |
173 | void TDataStd_Real::Paste (const Handle(TDF_Attribute)& Into, |
174 | const Handle(TDF_RelocationTable)& RT) const |
175 | { |
176 | Handle(TDataStd_Real) R = Handle(TDataStd_Real)::DownCast (Into); |
177 | R->Set(myValue); |
178 | R->SetDimension(myDimension); |
179 | } |
180 | |
181 | //======================================================================= |
182 | //function : Dump |
183 | //purpose : |
184 | //======================================================================= |
185 | |
186 | Standard_OStream& TDataStd_Real::Dump (Standard_OStream& anOS) const |
187 | { |
188 | anOS << "Real "; |
189 | TDataStd::Print(GetDimension(),anOS); |
190 | return anOS; |
191 | } |
192 | |