9ebaae37 |
1 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
2 | // |
3 | // This file is part of Open CASCADE Technology software library. |
4 | // |
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. |
10 | // |
11 | // Alternatively, this file may be used under the terms of Open CASCADE |
12 | // commercial license or contractual agreement. |
13 | |
14 | #include <XCAFDimTolObjects_DimensionObject.hxx> |
15 | |
16 | #include <Precision.hxx> |
17 | #include <TColgp_HArray1OfPnt.hxx> |
18 | |
19 | |
20 | //======================================================================= |
21 | //function : XCAFDimTolObjects_DimensionObject |
22 | //purpose : |
23 | //======================================================================= |
24 | |
25 | XCAFDimTolObjects_DimensionObject::XCAFDimTolObjects_DimensionObject() |
26 | { |
27 | } |
28 | |
29 | //======================================================================= |
30 | //function : |
31 | //purpose : |
32 | //======================================================================= |
33 | |
34 | XCAFDimTolObjects_DimensionObject::XCAFDimTolObjects_DimensionObject(const Handle(XCAFDimTolObjects_DimensionObject)& theObj) |
35 | { |
36 | myType = theObj->myType; |
37 | myVal = theObj->myVal; |
38 | myQualifier = theObj->myQualifier; |
39 | myIsHole = theObj->myIsHole; |
40 | myFormVariance = theObj->myFormVariance; |
41 | myGrade = theObj->myGrade; |
42 | myL = theObj->myL; |
43 | myR = theObj->myR; |
44 | myModifiers = theObj->myModifiers; |
45 | myPath = theObj->myPath; |
46 | myDir = theObj->myDir; |
47 | myPnts = theObj->myPnts; |
48 | } |
49 | |
50 | //======================================================================= |
51 | //function : SetQualifier |
52 | //purpose : |
53 | //======================================================================= |
54 | void XCAFDimTolObjects_DimensionObject::SetQualifier (const XCAFDimTolObjects_DimensionQualifier theQualifier) |
55 | { |
56 | myQualifier = theQualifier; |
57 | } |
58 | |
59 | //======================================================================= |
60 | //function : GetQualifier |
61 | //purpose : |
62 | //======================================================================= |
63 | XCAFDimTolObjects_DimensionQualifier XCAFDimTolObjects_DimensionObject::GetQualifier() const |
64 | { |
65 | return myQualifier; |
66 | } |
67 | |
68 | //======================================================================= |
69 | //function : HasQualifier |
70 | //purpose : |
71 | //======================================================================= |
72 | Standard_Boolean XCAFDimTolObjects_DimensionObject::HasQualifier() const |
73 | { |
74 | return (myQualifier != XCAFDimTolObjects_DimensionQualifier_None); |
75 | } |
76 | |
77 | //======================================================================= |
78 | //function : SetType |
79 | //purpose : |
80 | //======================================================================= |
81 | void XCAFDimTolObjects_DimensionObject::SetType (const XCAFDimTolObjects_DimensionType theType) |
82 | { |
83 | myType = theType; |
84 | } |
85 | |
86 | //======================================================================= |
87 | //function : GetType |
88 | //purpose : |
89 | //======================================================================= |
90 | XCAFDimTolObjects_DimensionType XCAFDimTolObjects_DimensionObject::GetType() const |
91 | { |
92 | return myType; |
93 | } |
94 | |
95 | //======================================================================= |
96 | //function : GetValue |
97 | //purpose : |
98 | //======================================================================= |
99 | Standard_Real XCAFDimTolObjects_DimensionObject::GetValue () const |
100 | { |
101 | if(!myVal.IsNull() && (myVal->Length() == 1 || myVal->Length() == 3)) |
102 | { |
103 | return myVal->Value(1); |
104 | } |
105 | return 0; |
106 | } |
107 | |
108 | //======================================================================= |
109 | //function : GetValues |
110 | //purpose : |
111 | //======================================================================= |
112 | Handle(TColStd_HArray1OfReal) XCAFDimTolObjects_DimensionObject::GetValues () const |
113 | { |
114 | return myVal; |
115 | } |
116 | |
117 | //======================================================================= |
118 | //function : SetValue |
119 | //purpose : |
120 | //======================================================================= |
121 | void XCAFDimTolObjects_DimensionObject::SetValue (const Standard_Real theValue) |
122 | { |
123 | myVal = new TColStd_HArray1OfReal(1, 1); |
124 | myVal->SetValue(1,theValue); |
125 | } |
126 | |
127 | //======================================================================= |
128 | //function : SetValues |
129 | //purpose : |
130 | //======================================================================= |
131 | void XCAFDimTolObjects_DimensionObject::SetValues (const Handle(TColStd_HArray1OfReal)& theValue) |
132 | { |
133 | myVal = theValue; |
134 | } |
135 | |
136 | //======================================================================= |
137 | //function : IsDimWithRange |
138 | //purpose : |
139 | //======================================================================= |
140 | Standard_Boolean XCAFDimTolObjects_DimensionObject::IsDimWithRange() const |
141 | { |
142 | if (!myVal.IsNull() && myVal->Length() == 2) |
143 | return Standard_True; |
144 | return Standard_False; |
145 | } |
146 | |
147 | //======================================================================= |
148 | //function : SetUpperBound |
149 | //purpose : |
150 | //======================================================================= |
151 | void XCAFDimTolObjects_DimensionObject::SetUpperBound (const Standard_Real theUpperBound) |
152 | { |
153 | if(!myVal.IsNull() && myVal->Length() > 1) |
154 | myVal->SetValue(2, theUpperBound); |
155 | else |
156 | { |
157 | myVal = new TColStd_HArray1OfReal(1, 2); |
158 | myVal->SetValue(1, theUpperBound); |
159 | myVal->SetValue(2, theUpperBound); |
160 | } |
161 | } |
162 | |
163 | //======================================================================= |
164 | //function : SetLowerBound |
165 | //purpose : |
166 | //======================================================================= |
167 | void XCAFDimTolObjects_DimensionObject::SetLowerBound (const Standard_Real theLowerBound) |
168 | { |
169 | if(!myVal.IsNull() && myVal->Length() > 1) |
170 | myVal->SetValue(1, theLowerBound); |
171 | else |
172 | { |
173 | myVal = new TColStd_HArray1OfReal(1, 2); |
174 | myVal->SetValue(2, theLowerBound); |
175 | myVal->SetValue(1, theLowerBound); |
176 | } |
177 | } |
178 | |
179 | //======================================================================= |
180 | //function : GetUpperBound |
181 | //purpose : |
182 | //======================================================================= |
183 | Standard_Real XCAFDimTolObjects_DimensionObject::GetUpperBound () const |
184 | { |
185 | if(!myVal.IsNull() && myVal->Length() == 2) |
186 | { |
187 | return myVal->Value(2); |
188 | } |
189 | return 0; |
190 | } |
191 | |
192 | //======================================================================= |
193 | //function : GetLowerBound |
194 | //purpose : |
195 | //======================================================================= |
196 | Standard_Real XCAFDimTolObjects_DimensionObject::GetLowerBound () const |
197 | { |
198 | if(!myVal.IsNull() && myVal->Length() == 2) |
199 | { |
200 | return myVal->Value(1); |
201 | } |
202 | return 0; |
203 | } |
204 | |
205 | //======================================================================= |
206 | //function : IsDimWithPlusMinusTolerance |
207 | //purpose : |
208 | //======================================================================= |
209 | Standard_Boolean XCAFDimTolObjects_DimensionObject::IsDimWithPlusMinusTolerance() const |
210 | { |
211 | return (!myVal.IsNull() && myVal->Length() == 3); |
212 | } |
213 | |
214 | //======================================================================= |
215 | //function : SetUpperTolValue |
216 | //purpose : |
217 | //======================================================================= |
218 | Standard_Boolean XCAFDimTolObjects_DimensionObject::SetUpperTolValue (const Standard_Real theUperTolValue) |
219 | { |
220 | if(!myVal.IsNull() && myVal->Length() == 3) |
221 | { |
222 | myVal->SetValue(3, theUperTolValue); |
223 | return Standard_True; |
224 | } |
225 | else if(!myVal.IsNull() && myVal->Length() == 1) |
226 | { |
227 | Standard_Real v = myVal->Value(1); |
228 | myVal = new TColStd_HArray1OfReal(1, 3); |
229 | myVal->SetValue(1, v); |
230 | myVal->SetValue(2, theUperTolValue); |
231 | myVal->SetValue(3, theUperTolValue); |
232 | return Standard_True; |
233 | } |
234 | return Standard_False; |
235 | } |
236 | |
237 | //======================================================================= |
238 | //function : SetLowerTolValue |
239 | //purpose : |
240 | //======================================================================= |
241 | Standard_Boolean XCAFDimTolObjects_DimensionObject::SetLowerTolValue (const Standard_Real theLowerTolValue) |
242 | { |
243 | if(!myVal.IsNull() && myVal->Length() == 3) |
244 | { |
245 | myVal->SetValue(2, theLowerTolValue); |
246 | return Standard_True; |
247 | } |
248 | else if(!myVal.IsNull() && myVal->Length() == 1) |
249 | { |
250 | Standard_Real v = myVal->Value(1); |
251 | myVal = new TColStd_HArray1OfReal(1, 3); |
252 | myVal->SetValue(1, v); |
253 | myVal->SetValue(2, theLowerTolValue); |
254 | myVal->SetValue(3, theLowerTolValue); |
255 | return Standard_True; |
256 | } |
257 | return Standard_False; |
258 | } |
259 | |
260 | //======================================================================= |
261 | //function : GetUpperTolValue |
262 | //purpose : |
263 | //======================================================================= |
264 | Standard_Real XCAFDimTolObjects_DimensionObject::GetUpperTolValue () const |
265 | { |
266 | if(!myVal.IsNull() && myVal->Length() == 3) |
267 | { |
268 | return myVal->Value(3); |
269 | } |
270 | return 0; |
271 | } |
272 | |
273 | //======================================================================= |
274 | //function : GetLowerTolValue |
275 | //purpose : |
276 | //======================================================================= |
277 | Standard_Real XCAFDimTolObjects_DimensionObject::GetLowerTolValue () const |
278 | { |
279 | if(!myVal.IsNull() && myVal->Length() == 3) |
280 | { |
281 | return myVal->Value(2); |
282 | } |
283 | return 0; |
284 | } |
285 | |
286 | //======================================================================= |
287 | //function : IsDimWithClassOfTolerance |
288 | //purpose : |
289 | //======================================================================= |
290 | Standard_Boolean XCAFDimTolObjects_DimensionObject::IsDimWithClassOfTolerance() const |
291 | { |
292 | return (myFormVariance != XCAFDimTolObjects_DimensionFormVariance_None); |
293 | } |
294 | |
295 | //======================================================================= |
296 | //function : SetClassOfTolerance |
297 | //purpose : |
298 | //======================================================================= |
299 | void XCAFDimTolObjects_DimensionObject::SetClassOfTolerance (const Standard_Boolean theHole, |
300 | const XCAFDimTolObjects_DimensionFormVariance theFormVariance, |
301 | const XCAFDimTolObjects_DimensionGrade theGrade) |
302 | { |
303 | myIsHole = theHole; |
304 | myFormVariance = theFormVariance; |
305 | myGrade = theGrade; |
306 | } |
307 | |
308 | //======================================================================= |
309 | //function : GetClassOfTolerance |
310 | //purpose : |
311 | //======================================================================= |
312 | Standard_Boolean XCAFDimTolObjects_DimensionObject::GetClassOfTolerance (Standard_Boolean& theHole, |
313 | XCAFDimTolObjects_DimensionFormVariance& theFormVariance, |
314 | XCAFDimTolObjects_DimensionGrade& theGrade) const |
315 | { |
316 | if(myFormVariance != XCAFDimTolObjects_DimensionFormVariance_None) |
317 | { |
318 | theHole = myIsHole; |
319 | theFormVariance = myFormVariance; |
320 | theGrade = myGrade; |
321 | return Standard_True; |
322 | } |
323 | return Standard_False; |
324 | } |
325 | |
326 | //======================================================================= |
327 | //function : SetNbOfDecimalPlaces |
328 | //purpose : |
329 | //======================================================================= |
330 | void XCAFDimTolObjects_DimensionObject::SetNbOfDecimalPlaces (const Standard_Integer theL, const Standard_Integer theR) |
331 | { |
332 | myL = theL; |
333 | myR = theR; |
334 | } |
335 | |
336 | //======================================================================= |
337 | //function : GetNbOfDecimalPlaces |
338 | //purpose : |
339 | //======================================================================= |
340 | void XCAFDimTolObjects_DimensionObject::GetNbOfDecimalPlaces (Standard_Integer& theL, Standard_Integer& theR) const |
341 | { |
342 | theL = myL; |
343 | theR = myR; |
344 | } |
345 | |
346 | //======================================================================= |
347 | //function : GetModifiers |
348 | //purpose : |
349 | //======================================================================= |
350 | XCAFDimTolObjects_DimensionModifiersSequence XCAFDimTolObjects_DimensionObject::GetModifiers () const |
351 | { |
352 | return myModifiers; |
353 | } |
354 | |
355 | //======================================================================= |
356 | //function : SetModifiers |
357 | //purpose : |
358 | //======================================================================= |
359 | void XCAFDimTolObjects_DimensionObject::SetModifiers (const XCAFDimTolObjects_DimensionModifiersSequence& theModifiers) |
360 | { |
361 | myModifiers = theModifiers; |
362 | } |
363 | |
364 | //======================================================================= |
365 | //function : AddModifier |
366 | //purpose : |
367 | //======================================================================= |
368 | void XCAFDimTolObjects_DimensionObject::AddModifier (const XCAFDimTolObjects_DimensionModif theModifier) |
369 | { |
370 | myModifiers.Append(theModifier); |
371 | } |
372 | |
373 | //======================================================================= |
374 | //function : GetPath |
375 | //purpose : |
376 | //======================================================================= |
377 | TopoDS_Edge XCAFDimTolObjects_DimensionObject::GetPath () const |
378 | { |
379 | return myPath; |
380 | } |
381 | |
382 | //======================================================================= |
383 | //function : SetPath |
384 | //purpose : |
385 | //======================================================================= |
386 | void XCAFDimTolObjects_DimensionObject::SetPath (const TopoDS_Edge& thePath) |
387 | { |
388 | if(!thePath.IsNull()) |
389 | { |
390 | myPath = thePath; |
391 | } |
392 | } |
393 | |
394 | //======================================================================= |
395 | //function : GetDirection |
396 | //purpose : |
397 | //======================================================================= |
398 | Standard_Boolean XCAFDimTolObjects_DimensionObject::GetDirection (gp_Dir& theDir) const |
399 | { |
400 | theDir = myDir; |
401 | return Standard_True; |
402 | } |
403 | |
404 | //======================================================================= |
405 | //function : SetDirection |
406 | //purpose : |
407 | //======================================================================= |
408 | Standard_Boolean XCAFDimTolObjects_DimensionObject::SetDirection (const gp_Dir& theDir) |
409 | { |
410 | myDir = theDir; |
411 | return Standard_True; |
412 | } |
413 | |
414 | //======================================================================= |
415 | //function : GetPoints |
416 | //purpose : |
417 | //======================================================================= |
418 | Handle(TColgp_HArray1OfPnt) XCAFDimTolObjects_DimensionObject::GetPoints () const |
419 | { |
420 | return myPnts; |
421 | } |
422 | |
423 | //======================================================================= |
424 | //function : SetPoints |
425 | //purpose : |
426 | //======================================================================= |
427 | void XCAFDimTolObjects_DimensionObject::SetPoints (const Handle(TColgp_HArray1OfPnt)& thePnts) |
428 | { |
429 | myPnts = thePnts; |
430 | } |