1 // Created on: 2015-09-10
2 // Created by: Irina Krylova
3 // Copyright (c) 1999-2015 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
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
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.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <BRep_Tool.hxx>
17 #include <Geom_BSplineCurve.hxx>
18 #include <Geom_Curve.hxx>
19 #include <Geom_Line.hxx>
20 #include <ShapeConstruct_Curve.hxx>
21 #include <STEPCAFControl_GDTProperty.hxx>
22 #include <StepBasic_MeasureValueMember.hxx>
23 #include <StepGeom_CartesianPoint.hxx>
24 #include <StepGeom_Direction.hxx>
25 #include <StepDimTol_CylindricityTolerance.hxx>
26 #include <StepDimTol_FlatnessTolerance.hxx>
27 #include <StepDimTol_LineProfileTolerance.hxx>
28 #include <StepDimTol_PositionTolerance.hxx>
29 #include <StepDimTol_RoundnessTolerance.hxx>
30 #include <StepDimTol_StraightnessTolerance.hxx>
31 #include <StepDimTol_SurfaceProfileTolerance.hxx>
32 #include <StepRepr_DescriptiveRepresentationItem.hxx>
33 #include <StepVisual_CoordinatesList.hxx>
34 #include <StepVisual_TessellatedCurveSet.hxx>
35 #include <TopExp_Explorer.hxx>
36 #include <TopoDS.hxx>
37 #include <TopoDS_Shape.hxx>
38 #include <XCAFDimTolObjects_DatumModifiersSequence.hxx>
39 #include <XCAFDimTolObjects_DatumModifWithValue.hxx>
40
41 //=======================================================================
42 //function : STEPCAFControl_GDTProperty
43 //purpose :
44 //=======================================================================
45
STEPCAFControl_GDTProperty()46 STEPCAFControl_GDTProperty::STEPCAFControl_GDTProperty ()
47 {
48 }
49
50 //=======================================================================
51 //function : getDimModifiers
52 //purpose :
53 //=======================================================================
GetDimModifiers(const Handle (StepRepr_CompoundRepresentationItem)& theCRI,XCAFDimTolObjects_DimensionModifiersSequence & theModifiers)54 void STEPCAFControl_GDTProperty::GetDimModifiers(const Handle(StepRepr_CompoundRepresentationItem)& theCRI,
55 XCAFDimTolObjects_DimensionModifiersSequence& theModifiers)
56 {
57 for (Standard_Integer l = 1; l <= theCRI->ItemElement()->Length(); l++)
58 {
59 Handle(StepRepr_DescriptiveRepresentationItem) aDRI =
60 Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(theCRI->ItemElement()->Value(l));
61 if(aDRI.IsNull()) continue;
62 XCAFDimTolObjects_DimensionModif aModifier = XCAFDimTolObjects_DimensionModif_ControlledRadius;
63 const TCollection_AsciiString aModifStr = aDRI->Description()->String();
64 Standard_Boolean aFound = Standard_False;
65 if(aModifStr.IsEqual("controlled radius"))
66 {
67 aFound = Standard_True;
68 aModifier = XCAFDimTolObjects_DimensionModif_ControlledRadius;
69 }
70 else if(aModifStr.IsEqual("square"))
71 {
72 aFound = Standard_True;
73 aModifier = XCAFDimTolObjects_DimensionModif_Square;
74 }
75 else if(aModifStr.IsEqual("statistical"))
76 {
77 aFound = Standard_True;
78 aModifier = XCAFDimTolObjects_DimensionModif_StatisticalTolerance;
79 }
80 else if(aModifStr.IsEqual("continuous feature"))
81 {
82 aFound = Standard_True;
83 aModifier = XCAFDimTolObjects_DimensionModif_ContinuousFeature;
84 }
85 else if(aModifStr.IsEqual("two point size"))
86 {
87 aFound = Standard_True;
88 aModifier = XCAFDimTolObjects_DimensionModif_TwoPointSize;
89 }
90 else if(aModifStr.IsEqual("local size defined by a sphere"))
91 {
92 aFound = Standard_True;
93 aModifier = XCAFDimTolObjects_DimensionModif_LocalSizeDefinedBySphere;
94 }
95 else if(aModifStr.IsEqual("least squares association criteria"))
96 {
97 aFound = Standard_True;
98 aModifier = XCAFDimTolObjects_DimensionModif_LeastSquaresAssociationCriterion;
99 }
100 else if(aModifStr.IsEqual("maximum inscribed association criteria"))
101 {
102 aFound = Standard_True;
103 aModifier = XCAFDimTolObjects_DimensionModif_MaximumInscribedAssociation;
104 }
105 else if(aModifStr.IsEqual("minimum circumscribed association criteria"))
106 {
107 aFound = Standard_True;
108 aModifier = XCAFDimTolObjects_DimensionModif_MinimumCircumscribedAssociation;
109 }
110 else if(aModifStr.IsEqual("circumference diameter calculated size"))
111 {
112 aFound = Standard_True;
113 aModifier = XCAFDimTolObjects_DimensionModif_CircumferenceDiameter;
114 }
115 else if(aModifStr.IsEqual("area diameter calculated size"))
116 {
117 aFound = Standard_True;
118 aModifier = XCAFDimTolObjects_DimensionModif_AreaDiameter;
119 }
120 else if(aModifStr.IsEqual("volume diameter calculated size"))
121 {
122 aFound = Standard_True;
123 aModifier = XCAFDimTolObjects_DimensionModif_VolumeDiameter;
124 }
125 else if(aModifStr.IsEqual("maximum rank order size"))
126 {
127 aFound = Standard_True;
128 aModifier = XCAFDimTolObjects_DimensionModif_MaximumSize;
129 }
130 else if(aModifStr.IsEqual("minimum rank order size"))
131 {
132 aFound = Standard_True;
133 aModifier = XCAFDimTolObjects_DimensionModif_MinimumSize;
134 }
135 else if(aModifStr.IsEqual("average rank order size"))
136 {
137 aFound = Standard_True;
138 aModifier = XCAFDimTolObjects_DimensionModif_AverageSize;
139 }
140 else if(aModifStr.IsEqual("median rank order size"))
141 {
142 aFound = Standard_True;
143 aModifier = XCAFDimTolObjects_DimensionModif_MedianSize;
144 }
145 else if(aModifStr.IsEqual("mid range rank order size"))
146 {
147 aFound = Standard_True;
148 aModifier = XCAFDimTolObjects_DimensionModif_MidRangeSize;
149 }
150 else if(aModifStr.IsEqual("range rank order size"))
151 {
152 aFound = Standard_True;
153 aModifier = XCAFDimTolObjects_DimensionModif_RangeOfSizes;
154 }
155 else if(aModifStr.IsEqual("any part of the feature"))
156 {
157 aFound = Standard_True;
158 aModifier = XCAFDimTolObjects_DimensionModif_AnyRestrictedPortionOfFeature;
159 }
160 else if(aModifStr.IsEqual("any cross section"))
161 {
162 aFound = Standard_True;
163 aModifier = XCAFDimTolObjects_DimensionModif_AnyCrossSection;
164 }
165 else if(aModifStr.IsEqual("specific fixed cross section"))
166 {
167 aFound = Standard_True;
168 aModifier = XCAFDimTolObjects_DimensionModif_SpecificFixedCrossSection;
169 }
170 else if(aModifStr.IsEqual("common tolerance"))
171 {
172 aFound = Standard_True;
173 aModifier = XCAFDimTolObjects_DimensionModif_CommonTolerance;
174 }
175 else if(aModifStr.IsEqual("free state condition"))
176 {
177 aFound = Standard_True;
178 aModifier = XCAFDimTolObjects_DimensionModif_FreeStateCondition;
179 }
180 if (aFound)
181 theModifiers.Append(aModifier);
182 }
183 }
184
185 //=======================================================================
186 //function : getClassOfTolerance
187 //purpose :
188 //=======================================================================
GetDimClassOfTolerance(const Handle (StepShape_LimitsAndFits)& theLAF,Standard_Boolean & theHolle,XCAFDimTolObjects_DimensionFormVariance & theFV,XCAFDimTolObjects_DimensionGrade & theG)189 void STEPCAFControl_GDTProperty::GetDimClassOfTolerance(const Handle(StepShape_LimitsAndFits)& theLAF,
190 Standard_Boolean& theHolle,
191 XCAFDimTolObjects_DimensionFormVariance& theFV,
192 XCAFDimTolObjects_DimensionGrade& theG)
193 {
194 Handle(TCollection_HAsciiString) aFormV = theLAF->FormVariance();
195 Handle(TCollection_HAsciiString) aGrade = theLAF->Grade();
196 theFV = XCAFDimTolObjects_DimensionFormVariance_None;
197 Standard_Boolean aFound;
198 theHolle = Standard_False;
199 //it is not verified information
200 for(Standard_Integer c = 0; c <= 1 && !aFormV.IsNull(); c++)
201 {
202 aFound = Standard_False;
203 Standard_Boolean aCaseSens = Standard_False;
204 if (c == 1)
205 aCaseSens = Standard_True;
206 Handle(TCollection_HAsciiString) aStr = new TCollection_HAsciiString("a");
207 if(aFormV->IsSameString(aStr, aCaseSens))
208 {
209 aFound = Standard_True;
210 theFV = XCAFDimTolObjects_DimensionFormVariance_A;
211 continue;
212 }
213 aStr = new TCollection_HAsciiString("b");
214 if(aFormV->IsSameString(aStr, aCaseSens))
215 {
216 aFound = Standard_True;
217 theFV = XCAFDimTolObjects_DimensionFormVariance_B;
218 continue;
219 }
220 aStr = new TCollection_HAsciiString("c");
221 if(aFormV->IsSameString(aStr, aCaseSens))
222 {
223 aFound = Standard_True;
224 theFV = XCAFDimTolObjects_DimensionFormVariance_C;
225 continue;
226 }
227 aStr = new TCollection_HAsciiString("cd");
228 if(aFormV->IsSameString(aStr, aCaseSens))
229 {
230 aFound = Standard_True;
231 theFV = XCAFDimTolObjects_DimensionFormVariance_CD;
232 continue;
233 }
234 aStr = new TCollection_HAsciiString("d");
235 if(aFormV->IsSameString(aStr, aCaseSens))
236 {
237 aFound = Standard_True;
238 theFV = XCAFDimTolObjects_DimensionFormVariance_D;
239 continue;
240 }
241 aStr = new TCollection_HAsciiString("e");
242 if(aFormV->IsSameString(aStr, aCaseSens))
243 {
244 aFound = Standard_True;
245 theFV = XCAFDimTolObjects_DimensionFormVariance_E;
246 continue;
247 }
248 aStr = new TCollection_HAsciiString("ef");
249 if(aFormV->IsSameString(aStr, aCaseSens))
250 {
251 aFound = Standard_True;
252 theFV = XCAFDimTolObjects_DimensionFormVariance_EF;
253 continue;
254 }
255 aStr = new TCollection_HAsciiString("f");
256 if(aFormV->IsSameString(aStr, aCaseSens))
257 {
258 aFound = Standard_True;
259 theFV = XCAFDimTolObjects_DimensionFormVariance_F;
260 continue;
261 }
262 aStr = new TCollection_HAsciiString("fg");
263 if(aFormV->IsSameString(aStr, aCaseSens))
264 {
265 aFound = Standard_True;
266 theFV = XCAFDimTolObjects_DimensionFormVariance_FG;
267 continue;
268 }
269 aStr = new TCollection_HAsciiString("g");
270 if(aFormV->IsSameString(aStr, aCaseSens))
271 {
272 aFound = Standard_True;
273 theFV = XCAFDimTolObjects_DimensionFormVariance_G;
274 continue;
275 }
276 aStr = new TCollection_HAsciiString("h");
277 if(aFormV->IsSameString(aStr, aCaseSens))
278 {
279 aFound = Standard_True;
280 theFV = XCAFDimTolObjects_DimensionFormVariance_H;
281 continue;
282 }
283 aStr = new TCollection_HAsciiString("js");
284 if(aFormV->IsSameString(aStr, aCaseSens))
285 {
286 aFound = Standard_True;
287 theFV = XCAFDimTolObjects_DimensionFormVariance_JS;
288 continue;
289 }
290 aStr = new TCollection_HAsciiString("k");
291 if(aFormV->IsSameString(aStr, aCaseSens))
292 {
293 aFound = Standard_True;
294 theFV = XCAFDimTolObjects_DimensionFormVariance_K;
295 continue;
296 }
297 aStr = new TCollection_HAsciiString("m");
298 if(aFormV->IsSameString(aStr, aCaseSens))
299 {
300 aFound = Standard_True;
301 theFV = XCAFDimTolObjects_DimensionFormVariance_M;
302 continue;
303 }
304 aStr = new TCollection_HAsciiString("n");
305 if(aFormV->IsSameString(aStr, aCaseSens))
306 {
307 aFound = Standard_True;
308 theFV = XCAFDimTolObjects_DimensionFormVariance_N;
309 continue;
310 }
311 aStr = new TCollection_HAsciiString("p");
312 if(aFormV->IsSameString(aStr, aCaseSens))
313 {
314 aFound = Standard_True;
315 theFV = XCAFDimTolObjects_DimensionFormVariance_P;
316 continue;
317 }
318 aStr = new TCollection_HAsciiString("r");
319 if(aFormV->IsSameString(aStr, aCaseSens))
320 {
321 aFound = Standard_True;
322 theFV = XCAFDimTolObjects_DimensionFormVariance_R;
323 continue;
324 }
325 aStr = new TCollection_HAsciiString("s");
326 if(aFormV->IsSameString(aStr, aCaseSens))
327 {
328 aFound = Standard_True;
329 theFV = XCAFDimTolObjects_DimensionFormVariance_S;
330 continue;
331 }
332 aStr = new TCollection_HAsciiString("t");
333 if(aFormV->IsSameString(aStr, aCaseSens))
334 {
335 aFound = Standard_True;
336 theFV = XCAFDimTolObjects_DimensionFormVariance_T;
337 continue;
338 }
339 aStr = new TCollection_HAsciiString("u");
340 if(aFormV->IsSameString(aStr, aCaseSens))
341 {
342 aFound = Standard_True;
343 theFV = XCAFDimTolObjects_DimensionFormVariance_U;
344 continue;
345 }
346 aStr = new TCollection_HAsciiString("v");
347 if(aFormV->IsSameString(aStr, aCaseSens))
348 {
349 aFound = Standard_True;
350 theFV = XCAFDimTolObjects_DimensionFormVariance_V;
351 continue;
352 }
353 aStr = new TCollection_HAsciiString("x");
354 if(aFormV->IsSameString(aStr, aCaseSens))
355 {
356 aFound = Standard_True;
357 theFV = XCAFDimTolObjects_DimensionFormVariance_X;
358 continue;
359 }
360 aStr = new TCollection_HAsciiString("y");
361 if(aFormV->IsSameString(aStr, aCaseSens))
362 {
363 aFound = Standard_True;
364 theFV = XCAFDimTolObjects_DimensionFormVariance_Y;
365 continue;
366 }
367 aStr = new TCollection_HAsciiString("b");
368 if(aFormV->IsSameString(aStr, aCaseSens))
369 {
370 aFound = Standard_True;
371 theFV = XCAFDimTolObjects_DimensionFormVariance_B;
372 continue;
373 }
374 aStr = new TCollection_HAsciiString("z");
375 if(aFormV->IsSameString(aStr, aCaseSens))
376 {
377 aFound = Standard_True;
378 theFV = XCAFDimTolObjects_DimensionFormVariance_Z;
379 continue;
380 }
381 aStr = new TCollection_HAsciiString("za");
382 if(aFormV->IsSameString(aStr, aCaseSens))
383 {
384 aFound = Standard_True;
385 theFV = XCAFDimTolObjects_DimensionFormVariance_ZA;
386 continue;
387 }
388 aStr = new TCollection_HAsciiString("zb");
389 if(aFormV->IsSameString(aStr, aCaseSens))
390 {
391 aFound = Standard_True;
392 theFV = XCAFDimTolObjects_DimensionFormVariance_ZB;
393 continue;
394 }
395 aStr = new TCollection_HAsciiString("zc");
396 if(aFormV->IsSameString(aStr, aCaseSens))
397 {
398 aFound = Standard_True;
399 theFV = XCAFDimTolObjects_DimensionFormVariance_ZC;
400 continue;
401 }
402
403 if (c == 1 && !aFound)
404 theHolle = Standard_True;
405 }
406 Handle(TCollection_HAsciiString) aStr = new TCollection_HAsciiString("01");
407 theG = XCAFDimTolObjects_DimensionGrade_IT01;
408 if (!aGrade.IsNull()
409 && !aGrade->String().IsEqual("01")
410 && aGrade->IsIntegerValue())
411 {
412 theG = (XCAFDimTolObjects_DimensionGrade)(aGrade->IntegerValue() + 1);
413 }
414 }
415
416 //=======================================================================
417 //function : getDimType
418 //purpose :
419 //=======================================================================
GetDimType(const Handle (TCollection_HAsciiString)& theName,XCAFDimTolObjects_DimensionType & theType)420 Standard_Boolean STEPCAFControl_GDTProperty::GetDimType(const Handle(TCollection_HAsciiString)& theName,
421 XCAFDimTolObjects_DimensionType& theType)
422 {
423 TCollection_AsciiString aName = theName->String();
424 aName.LowerCase();
425 theType = XCAFDimTolObjects_DimensionType_Location_None;
426 if(aName.IsEqual("curve length"))
427 {
428 theType = XCAFDimTolObjects_DimensionType_Size_CurveLength;
429 }
430 else if(aName.IsEqual("diameter"))
431 {
432 theType = XCAFDimTolObjects_DimensionType_Size_Diameter;
433 }
434 else if(aName.IsEqual("spherical diameter"))
435 {
436 theType = XCAFDimTolObjects_DimensionType_Size_SphericalDiameter;
437 }
438 else if(aName.IsEqual("radius"))
439 {
440 theType = XCAFDimTolObjects_DimensionType_Size_Radius;
441 }
442 else if(aName.IsEqual("spherical radius"))
443 {
444 theType = XCAFDimTolObjects_DimensionType_Size_SphericalRadius;
445 }
446 else if(aName.IsEqual("toroidal minor diameter"))
447 {
448 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalMinorDiameter;
449 }
450 else if(aName.IsEqual("toroidal major diameter"))
451 {
452 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalMajorDiameter;
453 }
454 else if(aName.IsEqual("toroidal minor radius"))
455 {
456 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalMinorRadius;
457 }
458 else if(aName.IsEqual("toroidal major radius"))
459 {
460 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalMajorRadius;
461 }
462 else if(aName.IsEqual("toroidal high major diameter"))
463 {
464 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorDiameter;
465 }
466 else if(aName.IsEqual("toroidal low major diameter"))
467 {
468 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorDiameter;
469 }
470 else if(aName.IsEqual("toroidal high major radius"))
471 {
472 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorRadius;
473 }
474 else if(aName.IsEqual("toroidal low major radius"))
475 {
476 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorRadius;
477 }
478 else if(aName.IsEqual("thickness"))
479 {
480 theType = XCAFDimTolObjects_DimensionType_Size_Thickness;
481 }
482 else if(aName.IsEqual("curved distance"))
483 {
484 theType = XCAFDimTolObjects_DimensionType_Location_CurvedDistance;
485 }
486 else if(aName.IsEqual("linear distance"))
487 {
488 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance;
489 }
490 else if(aName.IsEqual("linear distance centre outer"))
491 {
492 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToOuter;
493 }
494 else if(aName.IsEqual("linear distance centre inner"))
495 {
496 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToInner;
497 }
498 else if(aName.IsEqual("linear distance outer centre"))
499 {
500 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToCenter;
501 }
502 else if(aName.IsEqual("linear distance outer outer"))
503 {
504 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToOuter;
505 }
506 else if(aName.IsEqual("linear distance outer inner"))
507 {
508 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToInner;
509 }
510 else if(aName.IsEqual("linear distance inner centre"))
511 {
512 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToCenter;
513 }
514 else if(aName.IsEqual("linear distance inner outer"))
515 {
516 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToOuter;
517 }
518 else if(aName.IsEqual("linear distance inner inner"))
519 {
520 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToInner;
521 }
522
523 if(theType != XCAFDimTolObjects_DimensionType_Location_None &&
524 theType != XCAFDimTolObjects_DimensionType_CommonLabel)
525 {
526 return Standard_True;
527 }
528 return Standard_False;
529 }
530
531
532 //=======================================================================
533 //function : DatumTargetType
534 //purpose :
535 //=======================================================================
GetDatumTargetType(const Handle (TCollection_HAsciiString)& theDescription,XCAFDimTolObjects_DatumTargetType & theType)536 Standard_Boolean STEPCAFControl_GDTProperty::GetDatumTargetType(const Handle(TCollection_HAsciiString)& theDescription,
537 XCAFDimTolObjects_DatumTargetType& theType)
538 {
539 TCollection_AsciiString aName = theDescription->String();
540 aName.LowerCase();
541 if(aName.IsEqual("area"))
542 {
543 theType = XCAFDimTolObjects_DatumTargetType_Area;
544 return Standard_True;
545 }
546 else if(aName.IsEqual("line"))
547 {
548 theType = XCAFDimTolObjects_DatumTargetType_Line;
549 return Standard_True;
550 }
551 else if(aName.IsEqual("circle"))
552 {
553 theType = XCAFDimTolObjects_DatumTargetType_Circle;
554 return Standard_True;
555 }
556 else if(aName.IsEqual("rectangle"))
557 {
558 theType = XCAFDimTolObjects_DatumTargetType_Rectangle;
559 return Standard_True;
560 }
561 else if(aName.IsEqual("point"))
562 {
563 theType = XCAFDimTolObjects_DatumTargetType_Point;
564 return Standard_True;
565 }
566 return Standard_False;
567 }
568
569 //=======================================================================
570 //function : GetDimQualifierType
571 //purpose :
572 //=======================================================================
GetDimQualifierType(const Handle (TCollection_HAsciiString)& theDescription,XCAFDimTolObjects_DimensionQualifier & theType)573 Standard_Boolean STEPCAFControl_GDTProperty::GetDimQualifierType(const Handle(TCollection_HAsciiString)& theDescription,
574 XCAFDimTolObjects_DimensionQualifier& theType)
575 {
576 TCollection_AsciiString aName = theDescription->String();
577 aName.LowerCase();
578 theType = XCAFDimTolObjects_DimensionQualifier_None;
579 if(aName.IsEqual("maximum"))
580 {
581 theType = XCAFDimTolObjects_DimensionQualifier_Max;
582 }
583 else if(aName.IsEqual("minimum"))
584 {
585 theType = XCAFDimTolObjects_DimensionQualifier_Min;
586 }
587 else if(aName.IsEqual("average"))
588 {
589 theType = XCAFDimTolObjects_DimensionQualifier_Avg;
590 }
591 if(theType != XCAFDimTolObjects_DimensionQualifier_None)
592 {
593 return Standard_True;
594 }
595 return Standard_False;
596 }
597
598 //=======================================================================
599 //function : GetTolValueType
600 //purpose :
601 //=======================================================================
GetTolValueType(const Handle (TCollection_HAsciiString)& theDescription,XCAFDimTolObjects_GeomToleranceTypeValue & theType)602 Standard_Boolean STEPCAFControl_GDTProperty::GetTolValueType(const Handle(TCollection_HAsciiString)& theDescription,
603 XCAFDimTolObjects_GeomToleranceTypeValue& theType)
604 {
605 TCollection_AsciiString aName = theDescription->String();
606 aName.LowerCase();
607 theType = XCAFDimTolObjects_GeomToleranceTypeValue_None;
608 if(aName.IsEqual("cylindrical or circular"))
609 {
610 theType = XCAFDimTolObjects_GeomToleranceTypeValue_Diameter;
611 }
612 else if(aName.IsEqual("spherical"))
613 {
614 theType = XCAFDimTolObjects_GeomToleranceTypeValue_SphericalDiameter;
615 }
616 if(theType != XCAFDimTolObjects_GeomToleranceTypeValue_None)
617 {
618 return Standard_True;
619 }
620 return Standard_False;
621 }
622
623
624 //=======================================================================
625 //function : GetDimTypeName
626 //purpose :
627 //=======================================================================
Handle(TCollection_HAsciiString)628 Handle(TCollection_HAsciiString) STEPCAFControl_GDTProperty::GetDimTypeName(const XCAFDimTolObjects_DimensionType theType)
629 {
630 Handle(TCollection_HAsciiString) aName;
631 switch (theType) {
632 // Dimensional_Location
633 case XCAFDimTolObjects_DimensionType_Location_CurvedDistance:
634 aName = new TCollection_HAsciiString("curved distance");
635 break;
636 case XCAFDimTolObjects_DimensionType_Location_LinearDistance:
637 aName = new TCollection_HAsciiString("linear distance");
638 break;
639 case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToOuter:
640 aName = new TCollection_HAsciiString("linear distance centre outer");
641 break;
642 case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToInner:
643 aName = new TCollection_HAsciiString("linear distance centre inner");
644 break;
645 case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToCenter:
646 aName = new TCollection_HAsciiString("linear distance outer centre");
647 break;
648 case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToOuter:
649 aName = new TCollection_HAsciiString("linear distance outer outer");
650 break;
651 case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToInner:
652 aName = new TCollection_HAsciiString("linear distance outer inner");
653 break;
654 case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToCenter:
655 aName = new TCollection_HAsciiString("linear distance inner centre");
656 break;
657 case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToOuter:
658 aName = new TCollection_HAsciiString("linear distance inner outer");
659 break;
660 case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToInner:
661 aName = new TCollection_HAsciiString("linear distance inner inner");
662 break;
663 //Dimensional_Size
664 case XCAFDimTolObjects_DimensionType_Size_CurveLength:
665 aName = new TCollection_HAsciiString("curve length");
666 break;
667 case XCAFDimTolObjects_DimensionType_Size_Diameter:
668 aName = new TCollection_HAsciiString("diameter");
669 break;
670 case XCAFDimTolObjects_DimensionType_Size_SphericalDiameter:
671 aName = new TCollection_HAsciiString("spherical diameter");
672 break;
673 case XCAFDimTolObjects_DimensionType_Size_Radius:
674 aName = new TCollection_HAsciiString("radius");
675 break;
676 case XCAFDimTolObjects_DimensionType_Size_SphericalRadius:
677 aName = new TCollection_HAsciiString("spherical radius");
678 break;
679 case XCAFDimTolObjects_DimensionType_Size_ToroidalMinorDiameter:
680 aName = new TCollection_HAsciiString("toroidal minor diameter");
681 break;
682 case XCAFDimTolObjects_DimensionType_Size_ToroidalMajorDiameter:
683 aName = new TCollection_HAsciiString("toroidal major diameter");
684 break;
685 case XCAFDimTolObjects_DimensionType_Size_ToroidalMinorRadius:
686 aName = new TCollection_HAsciiString("toroidal minor radius");
687 break;
688 case XCAFDimTolObjects_DimensionType_Size_ToroidalMajorRadius:
689 aName = new TCollection_HAsciiString("toroidal major radius");
690 break;
691 case XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorDiameter:
692 aName = new TCollection_HAsciiString("toroidal high major diameter");
693 break;
694 case XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorDiameter:
695 aName = new TCollection_HAsciiString("toroidal low major diameter");
696 break;
697 case XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorRadius:
698 aName = new TCollection_HAsciiString("toroidal high major radius");
699 break;
700 case XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorRadius:
701 aName = new TCollection_HAsciiString("toroidal low major radius");
702 break;
703 case XCAFDimTolObjects_DimensionType_Size_Thickness:
704 aName = new TCollection_HAsciiString("thickness");
705 break;
706 // Other entities
707 default:
708 aName = new TCollection_HAsciiString();
709 }
710 return aName;
711 }
712
713 //=======================================================================
714 //function : GetDimQualifierName
715 //purpose :
716 //=======================================================================
Handle(TCollection_HAsciiString)717 Handle(TCollection_HAsciiString) STEPCAFControl_GDTProperty::GetDimQualifierName(const XCAFDimTolObjects_DimensionQualifier theQualifier)
718 {
719 Handle(TCollection_HAsciiString) aName;
720 switch (theQualifier) {
721 case XCAFDimTolObjects_DimensionQualifier_Min:
722 aName = new TCollection_HAsciiString("minimum");
723 break;
724 case XCAFDimTolObjects_DimensionQualifier_Avg:
725 aName = new TCollection_HAsciiString("average");
726 break;
727 case XCAFDimTolObjects_DimensionQualifier_Max:
728 aName = new TCollection_HAsciiString("maximum");
729 break;
730 default:
731 aName = new TCollection_HAsciiString();
732 }
733 return aName;
734 }
735
736 //=======================================================================
737 //function : GetDimModifierName
738 //purpose :
739 //=======================================================================
Handle(TCollection_HAsciiString)740 Handle(TCollection_HAsciiString) STEPCAFControl_GDTProperty::GetDimModifierName(const XCAFDimTolObjects_DimensionModif theModifier)
741 {
742 Handle(TCollection_HAsciiString) aName;
743 switch (theModifier) {
744 case XCAFDimTolObjects_DimensionModif_ControlledRadius:
745 aName = new TCollection_HAsciiString("controlled radius");
746 break;
747 case XCAFDimTolObjects_DimensionModif_Square:
748 aName = new TCollection_HAsciiString("square");
749 break;
750 case XCAFDimTolObjects_DimensionModif_StatisticalTolerance:
751 aName = new TCollection_HAsciiString("statistical");
752 break;
753 case XCAFDimTolObjects_DimensionModif_ContinuousFeature:
754 aName = new TCollection_HAsciiString("continuous feature");
755 break;
756 case XCAFDimTolObjects_DimensionModif_TwoPointSize:
757 aName = new TCollection_HAsciiString("two point size");
758 break;
759 case XCAFDimTolObjects_DimensionModif_LocalSizeDefinedBySphere:
760 aName = new TCollection_HAsciiString("local size defined by a sphere");
761 break;
762 case XCAFDimTolObjects_DimensionModif_LeastSquaresAssociationCriterion:
763 aName = new TCollection_HAsciiString("least squares association criteria");
764 break;
765 case XCAFDimTolObjects_DimensionModif_MaximumInscribedAssociation:
766 aName = new TCollection_HAsciiString("maximum inscribed association criteria");
767 break;
768 case XCAFDimTolObjects_DimensionModif_MinimumCircumscribedAssociation:
769 aName = new TCollection_HAsciiString("minimum circumscribed association criteria");
770 break;
771 case XCAFDimTolObjects_DimensionModif_CircumferenceDiameter:
772 aName = new TCollection_HAsciiString("circumference diameter calculated size");
773 break;
774 case XCAFDimTolObjects_DimensionModif_AreaDiameter:
775 aName = new TCollection_HAsciiString("area diameter calculated size");
776 break;
777 case XCAFDimTolObjects_DimensionModif_VolumeDiameter:
778 aName = new TCollection_HAsciiString("volume diameter calculated size");
779 break;
780 case XCAFDimTolObjects_DimensionModif_MaximumSize:
781 aName = new TCollection_HAsciiString("maximum rank order size");
782 break;
783 case XCAFDimTolObjects_DimensionModif_MinimumSize:
784 aName = new TCollection_HAsciiString("minimum rank order size");
785 break;
786 case XCAFDimTolObjects_DimensionModif_AverageSize:
787 aName = new TCollection_HAsciiString("average rank order size");
788 break;
789 case XCAFDimTolObjects_DimensionModif_MedianSize:
790 aName = new TCollection_HAsciiString("median rank order size");
791 break;
792 case XCAFDimTolObjects_DimensionModif_MidRangeSize:
793 aName = new TCollection_HAsciiString("mid range rank order size");
794 break;
795 case XCAFDimTolObjects_DimensionModif_RangeOfSizes:
796 aName = new TCollection_HAsciiString("range rank order size");
797 break;
798 case XCAFDimTolObjects_DimensionModif_AnyRestrictedPortionOfFeature:
799 aName = new TCollection_HAsciiString("any part of the feature");
800 break;
801 case XCAFDimTolObjects_DimensionModif_AnyCrossSection:
802 aName = new TCollection_HAsciiString("any cross section");
803 break;
804 case XCAFDimTolObjects_DimensionModif_SpecificFixedCrossSection:
805 aName = new TCollection_HAsciiString("specific fixed cross section");
806 break;
807 case XCAFDimTolObjects_DimensionModif_CommonTolerance:
808 aName = new TCollection_HAsciiString("common tolerance");
809 break;
810 case XCAFDimTolObjects_DimensionModif_FreeStateCondition:
811 aName = new TCollection_HAsciiString("free state condition");
812 break;
813 default: aName = new TCollection_HAsciiString();
814 }
815 return aName;
816 }
817
818 //=======================================================================
819 //function : GetLimitsAndFits
820 //purpose :
821 //=======================================================================
Handle(StepShape_LimitsAndFits)822 Handle(StepShape_LimitsAndFits) STEPCAFControl_GDTProperty::GetLimitsAndFits(Standard_Boolean theHole,
823 XCAFDimTolObjects_DimensionFormVariance theFormVariance,
824 XCAFDimTolObjects_DimensionGrade theGrade)
825 {
826 Handle(StepShape_LimitsAndFits) aLAF = new StepShape_LimitsAndFits();
827 Handle(TCollection_HAsciiString) aGradeStr, aFormStr, aHoleStr;
828
829 if (theGrade == XCAFDimTolObjects_DimensionGrade_IT01)
830 aGradeStr = new TCollection_HAsciiString("01");
831 else
832 aGradeStr = new TCollection_HAsciiString((Standard_Integer)theGrade + 1);
833
834 switch (theFormVariance) {
835 case XCAFDimTolObjects_DimensionFormVariance_None:
836 aFormStr = new TCollection_HAsciiString("");
837 break;
838 case XCAFDimTolObjects_DimensionFormVariance_A:
839 aFormStr = new TCollection_HAsciiString("A");
840 break;
841 case XCAFDimTolObjects_DimensionFormVariance_B:
842 aFormStr = new TCollection_HAsciiString("B");
843 break;
844 case XCAFDimTolObjects_DimensionFormVariance_C:
845 aFormStr = new TCollection_HAsciiString("C");
846 break;
847 case XCAFDimTolObjects_DimensionFormVariance_CD:
848 aFormStr = new TCollection_HAsciiString("CD");
849 break;
850 case XCAFDimTolObjects_DimensionFormVariance_D:
851 aFormStr = new TCollection_HAsciiString("D");
852 break;
853 case XCAFDimTolObjects_DimensionFormVariance_E:
854 aFormStr = new TCollection_HAsciiString("E");
855 break;
856 case XCAFDimTolObjects_DimensionFormVariance_EF:
857 aFormStr = new TCollection_HAsciiString("EF");
858 break;
859 case XCAFDimTolObjects_DimensionFormVariance_F:
860 aFormStr = new TCollection_HAsciiString("F");
861 break;
862 case XCAFDimTolObjects_DimensionFormVariance_FG:
863 aFormStr = new TCollection_HAsciiString("FG");
864 break;
865 case XCAFDimTolObjects_DimensionFormVariance_G:
866 aFormStr = new TCollection_HAsciiString("G");
867 break;
868 case XCAFDimTolObjects_DimensionFormVariance_H:
869 aFormStr = new TCollection_HAsciiString("H");
870 break;
871 case XCAFDimTolObjects_DimensionFormVariance_JS:
872 aFormStr = new TCollection_HAsciiString("JS");
873 break;
874 case XCAFDimTolObjects_DimensionFormVariance_J:
875 aFormStr = new TCollection_HAsciiString("J");
876 break;
877 case XCAFDimTolObjects_DimensionFormVariance_K:
878 aFormStr = new TCollection_HAsciiString("K");
879 break;
880 case XCAFDimTolObjects_DimensionFormVariance_M:
881 aFormStr = new TCollection_HAsciiString("M");
882 break;
883 case XCAFDimTolObjects_DimensionFormVariance_N:
884 aFormStr = new TCollection_HAsciiString("N");
885 break;
886 case XCAFDimTolObjects_DimensionFormVariance_P:
887 aFormStr = new TCollection_HAsciiString("P");
888 break;
889 case XCAFDimTolObjects_DimensionFormVariance_R:
890 aFormStr = new TCollection_HAsciiString("R");
891 break;
892 case XCAFDimTolObjects_DimensionFormVariance_S:
893 aFormStr = new TCollection_HAsciiString("S");
894 break;
895 case XCAFDimTolObjects_DimensionFormVariance_T:
896 aFormStr = new TCollection_HAsciiString("T");
897 break;
898 case XCAFDimTolObjects_DimensionFormVariance_U:
899 aFormStr = new TCollection_HAsciiString("U");
900 break;
901 case XCAFDimTolObjects_DimensionFormVariance_V:
902 aFormStr = new TCollection_HAsciiString("V");
903 break;
904 case XCAFDimTolObjects_DimensionFormVariance_X:
905 aFormStr = new TCollection_HAsciiString("X");
906 break;
907 case XCAFDimTolObjects_DimensionFormVariance_Y:
908 aFormStr = new TCollection_HAsciiString("Y");
909 break;
910 case XCAFDimTolObjects_DimensionFormVariance_Z:
911 aFormStr = new TCollection_HAsciiString("Z");
912 break;
913 case XCAFDimTolObjects_DimensionFormVariance_ZA:
914 aFormStr = new TCollection_HAsciiString("ZA");
915 break;
916 case XCAFDimTolObjects_DimensionFormVariance_ZB:
917 aFormStr = new TCollection_HAsciiString("ZB");
918 break;
919 case XCAFDimTolObjects_DimensionFormVariance_ZC:
920 aFormStr = new TCollection_HAsciiString("ZC");
921 break;
922 }
923
924 if (theHole) {
925 aHoleStr = new TCollection_HAsciiString("hole");
926 }
927 else {
928 aHoleStr = new TCollection_HAsciiString("shaft");
929 aFormStr->LowerCase();
930 }
931 aLAF->Init(aFormStr, aHoleStr, aGradeStr, new TCollection_HAsciiString);
932 return aLAF;
933 }
934
935 //=======================================================================
936 //function : GetDatumTargetName
937 //purpose :
938 //=======================================================================
Handle(TCollection_HAsciiString)939 Handle(TCollection_HAsciiString) STEPCAFControl_GDTProperty::GetDatumTargetName(const XCAFDimTolObjects_DatumTargetType theDatumType)
940 {
941 Handle(TCollection_HAsciiString) aName;
942 switch (theDatumType) {
943 case XCAFDimTolObjects_DatumTargetType_Point:
944 aName = new TCollection_HAsciiString("point");
945 break;
946 case XCAFDimTolObjects_DatumTargetType_Line:
947 aName = new TCollection_HAsciiString("line");
948 break;
949 case XCAFDimTolObjects_DatumTargetType_Rectangle:
950 aName = new TCollection_HAsciiString("rectangle");
951 break;
952 case XCAFDimTolObjects_DatumTargetType_Circle:
953 aName = new TCollection_HAsciiString("circle");
954 break;
955 case XCAFDimTolObjects_DatumTargetType_Area:
956 aName = new TCollection_HAsciiString("area");
957 break;
958 default: aName = new TCollection_HAsciiString();
959 }
960 return aName;
961 }
962
963 //=======================================================================
964 //function : IsDimensionalSize
965 //purpose :
966 //=======================================================================
IsDimensionalLocation(const XCAFDimTolObjects_DimensionType theType)967 Standard_Boolean STEPCAFControl_GDTProperty::IsDimensionalLocation(const XCAFDimTolObjects_DimensionType theType)
968 {
969 if (theType == XCAFDimTolObjects_DimensionType_Location_None ||
970 theType == XCAFDimTolObjects_DimensionType_Location_CurvedDistance ||
971 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance ||
972 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToOuter ||
973 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToInner ||
974 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToCenter ||
975 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToOuter ||
976 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToInner ||
977 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToCenter ||
978 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToOuter ||
979 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToInner ||
980 theType == XCAFDimTolObjects_DimensionType_Location_Oriented)
981 return Standard_True;
982 return Standard_False;
983 }
984
985 //=======================================================================
986 //function : IsDimensionalSize
987 //purpose :
988 //=======================================================================
IsDimensionalSize(const XCAFDimTolObjects_DimensionType theType)989 Standard_Boolean STEPCAFControl_GDTProperty::IsDimensionalSize(const XCAFDimTolObjects_DimensionType theType)
990 {
991 if (theType == XCAFDimTolObjects_DimensionType_Size_CurveLength ||
992 theType == XCAFDimTolObjects_DimensionType_Size_Diameter ||
993 theType == XCAFDimTolObjects_DimensionType_Size_SphericalDiameter ||
994 theType == XCAFDimTolObjects_DimensionType_Size_Radius ||
995 theType == XCAFDimTolObjects_DimensionType_Size_SphericalRadius ||
996 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalMinorDiameter ||
997 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalMajorDiameter ||
998 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalMinorRadius ||
999 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalMajorRadius ||
1000 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorDiameter ||
1001 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorDiameter ||
1002 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorRadius ||
1003 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorRadius ||
1004 theType == XCAFDimTolObjects_DimensionType_Size_Thickness)
1005 return Standard_True;
1006 return Standard_False;
1007 }
1008
1009 //=======================================================================
1010 //function : GetGeomToleranceType
1011 //purpose :
1012 //=======================================================================
GetGeomToleranceType(const XCAFDimTolObjects_GeomToleranceType theType)1013 StepDimTol_GeometricToleranceType STEPCAFControl_GDTProperty::GetGeomToleranceType(const XCAFDimTolObjects_GeomToleranceType theType)
1014 {
1015 switch (theType) {
1016 case XCAFDimTolObjects_GeomToleranceType_Angularity:
1017 return StepDimTol_GTTAngularityTolerance;
1018 case XCAFDimTolObjects_GeomToleranceType_CircularRunout:
1019 return StepDimTol_GTTCircularRunoutTolerance;
1020 case XCAFDimTolObjects_GeomToleranceType_CircularityOrRoundness:
1021 return StepDimTol_GTTRoundnessTolerance;
1022 case XCAFDimTolObjects_GeomToleranceType_Coaxiality:
1023 return StepDimTol_GTTCoaxialityTolerance;
1024 case XCAFDimTolObjects_GeomToleranceType_Concentricity:
1025 return StepDimTol_GTTConcentricityTolerance;
1026 case XCAFDimTolObjects_GeomToleranceType_Cylindricity:
1027 return StepDimTol_GTTCylindricityTolerance;
1028 case XCAFDimTolObjects_GeomToleranceType_Flatness:
1029 return StepDimTol_GTTFlatnessTolerance;
1030 case XCAFDimTolObjects_GeomToleranceType_Parallelism:
1031 return StepDimTol_GTTParallelismTolerance;
1032 case XCAFDimTolObjects_GeomToleranceType_Perpendicularity:
1033 return StepDimTol_GTTPerpendicularityTolerance;
1034 case XCAFDimTolObjects_GeomToleranceType_Position:
1035 return StepDimTol_GTTPositionTolerance;
1036 case XCAFDimTolObjects_GeomToleranceType_ProfileOfLine:
1037 return StepDimTol_GTTLineProfileTolerance;
1038 case XCAFDimTolObjects_GeomToleranceType_ProfileOfSurface:
1039 return StepDimTol_GTTSurfaceProfileTolerance;
1040 case XCAFDimTolObjects_GeomToleranceType_Straightness:
1041 return StepDimTol_GTTStraightnessTolerance;
1042 case XCAFDimTolObjects_GeomToleranceType_Symmetry:
1043 return StepDimTol_GTTSymmetryTolerance;
1044 case XCAFDimTolObjects_GeomToleranceType_TotalRunout:
1045 return StepDimTol_GTTTotalRunoutTolerance;
1046 default:
1047 return StepDimTol_GTTPositionTolerance;
1048 }
1049 }
1050
1051 //=======================================================================
1052 //function : GetGeomToleranceType
1053 //purpose :
1054 //=======================================================================
GetGeomToleranceType(const StepDimTol_GeometricToleranceType theType)1055 XCAFDimTolObjects_GeomToleranceType STEPCAFControl_GDTProperty::GetGeomToleranceType(const StepDimTol_GeometricToleranceType theType)
1056 {
1057 switch (theType) {
1058 case StepDimTol_GTTAngularityTolerance:
1059 return XCAFDimTolObjects_GeomToleranceType_Angularity;
1060 case StepDimTol_GTTCircularRunoutTolerance:
1061 return XCAFDimTolObjects_GeomToleranceType_CircularRunout;
1062 case StepDimTol_GTTRoundnessTolerance:
1063 return XCAFDimTolObjects_GeomToleranceType_CircularityOrRoundness;
1064 case StepDimTol_GTTCoaxialityTolerance:
1065 return XCAFDimTolObjects_GeomToleranceType_Coaxiality;
1066 case StepDimTol_GTTConcentricityTolerance:
1067 return XCAFDimTolObjects_GeomToleranceType_Concentricity;
1068 case StepDimTol_GTTCylindricityTolerance:
1069 return XCAFDimTolObjects_GeomToleranceType_Cylindricity;
1070 case StepDimTol_GTTFlatnessTolerance:
1071 return XCAFDimTolObjects_GeomToleranceType_Flatness;
1072 case StepDimTol_GTTParallelismTolerance:
1073 return XCAFDimTolObjects_GeomToleranceType_Parallelism;
1074 case StepDimTol_GTTPerpendicularityTolerance:
1075 return XCAFDimTolObjects_GeomToleranceType_Perpendicularity;
1076 case StepDimTol_GTTPositionTolerance:
1077 return XCAFDimTolObjects_GeomToleranceType_Position;
1078 case StepDimTol_GTTLineProfileTolerance:
1079 return XCAFDimTolObjects_GeomToleranceType_ProfileOfLine;
1080 case StepDimTol_GTTSurfaceProfileTolerance:
1081 return XCAFDimTolObjects_GeomToleranceType_ProfileOfSurface;
1082 case StepDimTol_GTTStraightnessTolerance:
1083 return XCAFDimTolObjects_GeomToleranceType_Straightness;
1084 case StepDimTol_GTTSymmetryTolerance:
1085 return XCAFDimTolObjects_GeomToleranceType_Symmetry;
1086 case StepDimTol_GTTTotalRunoutTolerance:
1087 return XCAFDimTolObjects_GeomToleranceType_TotalRunout;
1088 default:
1089 return XCAFDimTolObjects_GeomToleranceType_Position;
1090 }
1091 }
1092
1093 //=======================================================================
1094 //function : GetGeomTolerance
1095 //purpose :
1096 //=======================================================================
Handle(StepDimTol_GeometricTolerance)1097 Handle(StepDimTol_GeometricTolerance) STEPCAFControl_GDTProperty::
1098 GetGeomTolerance(const XCAFDimTolObjects_GeomToleranceType theType)
1099 {
1100 switch (theType) {
1101 case XCAFDimTolObjects_GeomToleranceType_CircularityOrRoundness:
1102 return new StepDimTol_RoundnessTolerance();
1103 case XCAFDimTolObjects_GeomToleranceType_Cylindricity:
1104 return new StepDimTol_CylindricityTolerance();
1105 case XCAFDimTolObjects_GeomToleranceType_Flatness:
1106 return new StepDimTol_FlatnessTolerance();
1107 case XCAFDimTolObjects_GeomToleranceType_Position:
1108 return new StepDimTol_PositionTolerance();
1109 case XCAFDimTolObjects_GeomToleranceType_ProfileOfLine:
1110 return new StepDimTol_LineProfileTolerance();
1111 case XCAFDimTolObjects_GeomToleranceType_ProfileOfSurface:
1112 return new StepDimTol_SurfaceProfileTolerance();
1113 case XCAFDimTolObjects_GeomToleranceType_Straightness:
1114 return new StepDimTol_StraightnessTolerance();
1115 default:
1116 return NULL;
1117 }
1118 }
1119
1120 //=======================================================================
1121 //function : GetGeomToleranceModifier
1122 //purpose :
1123 //=======================================================================
1124 StepDimTol_GeometricToleranceModifier STEPCAFControl_GDTProperty::
GetGeomToleranceModifier(const XCAFDimTolObjects_GeomToleranceModif theModifier)1125 GetGeomToleranceModifier(const XCAFDimTolObjects_GeomToleranceModif theModifier)
1126 {
1127 switch (theModifier) {
1128 case XCAFDimTolObjects_GeomToleranceModif_Any_Cross_Section:
1129 return StepDimTol_GTMAnyCrossSection;
1130 case XCAFDimTolObjects_GeomToleranceModif_Common_Zone:
1131 return StepDimTol_GTMCommonZone;
1132 case XCAFDimTolObjects_GeomToleranceModif_Each_Radial_Element:
1133 return StepDimTol_GTMEachRadialElement;
1134 case XCAFDimTolObjects_GeomToleranceModif_Free_State:
1135 return StepDimTol_GTMFreeState;
1136 case XCAFDimTolObjects_GeomToleranceModif_Least_Material_Requirement:
1137 return StepDimTol_GTMLeastMaterialRequirement;
1138 case XCAFDimTolObjects_GeomToleranceModif_Line_Element:
1139 return StepDimTol_GTMLineElement;
1140 case XCAFDimTolObjects_GeomToleranceModif_Major_Diameter:
1141 return StepDimTol_GTMMajorDiameter;
1142 case XCAFDimTolObjects_GeomToleranceModif_Maximum_Material_Requirement:
1143 return StepDimTol_GTMMaximumMaterialRequirement;
1144 case XCAFDimTolObjects_GeomToleranceModif_Minor_Diameter:
1145 return StepDimTol_GTMMinorDiameter;
1146 case XCAFDimTolObjects_GeomToleranceModif_Not_Convex:
1147 return StepDimTol_GTMNotConvex;
1148 case XCAFDimTolObjects_GeomToleranceModif_Pitch_Diameter:
1149 return StepDimTol_GTMPitchDiameter;
1150 case XCAFDimTolObjects_GeomToleranceModif_Reciprocity_Requirement:
1151 return StepDimTol_GTMReciprocityRequirement;
1152 case XCAFDimTolObjects_GeomToleranceModif_Separate_Requirement:
1153 return StepDimTol_GTMSeparateRequirement;
1154 case XCAFDimTolObjects_GeomToleranceModif_Statistical_Tolerance:
1155 return StepDimTol_GTMStatisticalTolerance;
1156 case XCAFDimTolObjects_GeomToleranceModif_Tangent_Plane:
1157 return StepDimTol_GTMTangentPlane;
1158 default:
1159 return StepDimTol_GTMMaximumMaterialRequirement;
1160 }
1161 }
1162
1163 //=======================================================================
1164 //function : GetDatumRefModifiers
1165 //purpose : Note: this function does not add anything to model
1166 //=======================================================================
Handle(StepDimTol_HArray1OfDatumReferenceModifier)1167 Handle(StepDimTol_HArray1OfDatumReferenceModifier) STEPCAFControl_GDTProperty::
1168 GetDatumRefModifiers(const XCAFDimTolObjects_DatumModifiersSequence theModifiers,
1169 const XCAFDimTolObjects_DatumModifWithValue theModifWithVal,
1170 const Standard_Real theValue,
1171 const StepBasic_Unit theUnit)
1172 {
1173 if ((theModifiers.Length() == 0) && (theModifWithVal == XCAFDimTolObjects_DatumModifWithValue_None))
1174 return NULL;
1175 Standard_Integer aModifNb = theModifiers.Length();
1176 if (theModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None)
1177 aModifNb++;
1178 Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModifiers =
1179 new StepDimTol_HArray1OfDatumReferenceModifier(1, aModifNb);
1180
1181 // Modifier with value
1182 if (theModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None) {
1183 StepDimTol_DatumReferenceModifierType aType;
1184 switch (theModifWithVal) {
1185 case XCAFDimTolObjects_DatumModifWithValue_CircularOrCylindrical:
1186 aType = StepDimTol_CircularOrCylindrical;
1187 break;
1188 case XCAFDimTolObjects_DatumModifWithValue_Distance:
1189 aType = StepDimTol_Distance;
1190 break;
1191 case XCAFDimTolObjects_DatumModifWithValue_Projected:
1192 aType = StepDimTol_Projected;
1193 break;
1194 case XCAFDimTolObjects_DatumModifWithValue_Spherical:
1195 aType = StepDimTol_Spherical;
1196 break;
1197 default:
1198 aType = StepDimTol_Distance;
1199 }
1200 Handle(StepBasic_LengthMeasureWithUnit) aLMWU = new StepBasic_LengthMeasureWithUnit();
1201 Handle(StepBasic_MeasureValueMember) aValueMember = new StepBasic_MeasureValueMember();
1202 aValueMember->SetName("LENGTH_MEASURE");
1203 aValueMember->SetReal(theValue);
1204 aLMWU->Init(aValueMember, theUnit);
1205 Handle(StepDimTol_DatumReferenceModifierWithValue) aModifWithVal = new StepDimTol_DatumReferenceModifierWithValue();
1206 aModifWithVal->Init(aType, aLMWU);
1207 StepDimTol_DatumReferenceModifier aModif;
1208 aModif.SetValue(aModifWithVal);
1209 aModifiers->SetValue(aModifNb, aModif);
1210 }
1211
1212 // Simple modifiers
1213 for (Standard_Integer i = 1; i <= theModifiers.Length(); i++) {
1214 Handle(StepDimTol_SimpleDatumReferenceModifierMember) aSimpleModifMember =
1215 new StepDimTol_SimpleDatumReferenceModifierMember();
1216 switch (theModifiers.Value(i)) {
1217 case XCAFDimTolObjects_DatumSingleModif_AnyCrossSection:
1218 aSimpleModifMember->SetEnumText(0, ".ANY_CROSS_SECTION.");
1219 break;
1220 case XCAFDimTolObjects_DatumSingleModif_Any_LongitudinalSection:
1221 aSimpleModifMember->SetEnumText(0, ".ANY_LONGITUDINAL_SECTION.");
1222 break;
1223 case XCAFDimTolObjects_DatumSingleModif_Basic:
1224 aSimpleModifMember->SetEnumText(0, ".BASIC.");
1225 break;
1226 case XCAFDimTolObjects_DatumSingleModif_ContactingFeature:
1227 aSimpleModifMember->SetEnumText(0, ".CONTACTING_FEATURE.");
1228 break;
1229 case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintU:
1230 aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_U.");
1231 break;
1232 case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintV:
1233 aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_V.");
1234 break;
1235 case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintW:
1236 aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_W.");
1237 break;
1238 case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintX:
1239 aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_X.");
1240 break;
1241 case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintY:
1242 aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_Y.");
1243 break;
1244 case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintZ:
1245 aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_Z.");
1246 break;
1247 case XCAFDimTolObjects_DatumSingleModif_DistanceVariable:
1248 aSimpleModifMember->SetEnumText(0, ".DISTANCE_VARIABLE.");
1249 break;
1250 case XCAFDimTolObjects_DatumSingleModif_FreeState:
1251 aSimpleModifMember->SetEnumText(0, ".FREE_STATE.");
1252 break;
1253 case XCAFDimTolObjects_DatumSingleModif_LeastMaterialRequirement:
1254 aSimpleModifMember->SetEnumText(0, ".LEAST_MATERIAL_REQUIREMENT.");
1255 break;
1256 case XCAFDimTolObjects_DatumSingleModif_Line:
1257 aSimpleModifMember->SetEnumText(0, ".LINE.");
1258 break;
1259 case XCAFDimTolObjects_DatumSingleModif_MajorDiameter:
1260 aSimpleModifMember->SetEnumText(0, ".MAJOR_DIAMETER.");
1261 break;
1262 case XCAFDimTolObjects_DatumSingleModif_MaximumMaterialRequirement:
1263 aSimpleModifMember->SetEnumText(0, ".MAXIMUM_MATERIAL_REQUIREMENT.");
1264 break;
1265 case XCAFDimTolObjects_DatumSingleModif_MinorDiameter:
1266 aSimpleModifMember->SetEnumText(0, ".MINOR_DIAMETER.");
1267 break;
1268 case XCAFDimTolObjects_DatumSingleModif_Orientation:
1269 aSimpleModifMember->SetEnumText(0, ".ORIENTATION.");
1270 break;
1271 case XCAFDimTolObjects_DatumSingleModif_PitchDiameter:
1272 aSimpleModifMember->SetEnumText(0, ".PITCH_DIAMETER.");
1273 break;
1274 case XCAFDimTolObjects_DatumSingleModif_Plane:
1275 aSimpleModifMember->SetEnumText(0, ".PLANE.");
1276 break;
1277 case XCAFDimTolObjects_DatumSingleModif_Point:
1278 aSimpleModifMember->SetEnumText(0, ".POINT.");
1279 break;
1280 case XCAFDimTolObjects_DatumSingleModif_Translation:
1281 aSimpleModifMember->SetEnumText(0, ".TRANSLATION.");
1282 break;
1283 }
1284 StepDimTol_DatumReferenceModifier aModif;
1285 aModif.SetValue(aSimpleModifMember);
1286 aModifiers->SetValue(i, aModif);
1287 }
1288
1289 return aModifiers;
1290 }
1291
1292 //=======================================================================
1293 //function : GetTolValueType
1294 //purpose :
1295 //=======================================================================
Handle(TCollection_HAsciiString)1296 Handle(TCollection_HAsciiString) STEPCAFControl_GDTProperty::GetTolValueType(const XCAFDimTolObjects_GeomToleranceTypeValue& theType)
1297 {
1298 switch (theType) {
1299 case XCAFDimTolObjects_GeomToleranceTypeValue_Diameter:
1300 return new TCollection_HAsciiString("cylindrical or circular");
1301 case XCAFDimTolObjects_GeomToleranceTypeValue_SphericalDiameter:
1302 return new TCollection_HAsciiString("spherical");
1303 default:
1304 return new TCollection_HAsciiString("unknown");
1305 }
1306 }
1307
1308 //=======================================================================
1309 //function : GetTessellation
1310 //purpose :
1311 //=======================================================================
Handle(StepVisual_TessellatedGeometricSet)1312 Handle(StepVisual_TessellatedGeometricSet) STEPCAFControl_GDTProperty::GetTessellation(const TopoDS_Shape theShape)
1313 {
1314 // Build coordinate list and curves
1315 NCollection_Handle<StepVisual_VectorOfHSequenceOfInteger> aCurves = new StepVisual_VectorOfHSequenceOfInteger;
1316 NCollection_Vector<gp_XYZ> aCoords;
1317 Standard_Integer aPntNb = 1;
1318 for (TopExp_Explorer aCurveIt(theShape, TopAbs_EDGE); aCurveIt.More(); aCurveIt.Next()) {
1319 Handle(TColStd_HSequenceOfInteger) aCurve = new TColStd_HSequenceOfInteger;
1320 // Find out type of edge curve
1321 Standard_Real aFirst = 0, aLast = 0;
1322 Handle(Geom_Curve) anEdgeCurve = BRep_Tool::Curve(TopoDS::Edge(aCurveIt.Current()), aFirst, aLast);
1323 if (anEdgeCurve.IsNull())
1324 continue;
1325 // Line
1326 if (anEdgeCurve->IsKind(STANDARD_TYPE(Geom_Line))) {
1327 for (TopExp_Explorer aVertIt(aCurveIt.Current(), TopAbs_VERTEX); aVertIt.More(); aVertIt.Next()) {
1328 aCoords.Append(BRep_Tool::Pnt(TopoDS::Vertex(aVertIt.Current())).XYZ());
1329 aCurve->Append(aPntNb);
1330 aPntNb++;
1331 }
1332 }
1333 // BSpline
1334 else {
1335 ShapeConstruct_Curve aSCC;
1336 Handle(Geom_BSplineCurve) aBSCurve = aSCC.ConvertToBSpline(anEdgeCurve,
1337 aFirst, aLast, Precision::Confusion());
1338 for (Standard_Integer i = 1; i <= aBSCurve->NbPoles(); i++) {
1339 aCoords.Append(aBSCurve->Pole(i).XYZ());
1340 aCurve->Append(aPntNb);
1341 aPntNb++;
1342 }
1343 }
1344 aCurves->Append(aCurve);
1345 }
1346
1347 Handle(TColgp_HArray1OfXYZ) aPoints = new TColgp_HArray1OfXYZ(1, aCoords.Length());
1348 for (Standard_Integer i = 1; i <= aPoints->Length(); i++) {
1349 aPoints->SetValue(i, aCoords.Value(i - 1));
1350 }
1351 // STEP entities
1352 Handle(StepVisual_CoordinatesList) aCoordList = new StepVisual_CoordinatesList();
1353 aCoordList->Init(new TCollection_HAsciiString(), aPoints);
1354 Handle(StepVisual_TessellatedCurveSet) aCurveSet = new StepVisual_TessellatedCurveSet();
1355 aCurveSet->Init(new TCollection_HAsciiString(), aCoordList, aCurves);
1356 NCollection_Handle<StepVisual_Array1OfTessellatedItem> aTessItems = new StepVisual_Array1OfTessellatedItem(1, 1);
1357 aTessItems->SetValue(1, aCurveSet);
1358 Handle(StepVisual_TessellatedGeometricSet) aGeomSet = new StepVisual_TessellatedGeometricSet();
1359 aGeomSet->Init(new TCollection_HAsciiString(), aTessItems);
1360 return aGeomSet;
1361 }
1362