0027372: Import/Export dimension text position
[occt.git] / src / STEPCAFControl / STEPCAFControl_GDTProperty.cxx
CommitLineData
727b5ad9 1// Created on: 2015-09-10
2// Created by: Irina Krylova
3// Copyright (c) 1999-2015 OPEN CASCADE SAS
1c9d3225 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
b0cef606 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>
727b5ad9 21#include <STEPCAFControl_GDTProperty.hxx>
6595eee7 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>
1c9d3225 32#include <StepRepr_DescriptiveRepresentationItem.hxx>
b0cef606 33#include <StepVisual_CoordinatesList.hxx>
34#include <StepVisual_TessellatedCurveSet.hxx>
35#include <TopExp_Explorer.hxx>
36#include <TopoDS.hxx>
37#include <TopoDS_Shape.hxx>
6595eee7 38#include <XCAFDimTolObjects_DatumModifiersSequence.hxx>
39#include <XCAFDimTolObjects_DatumModifWithValue.hxx>
40
1c9d3225 41//=======================================================================
727b5ad9 42//function : STEPCAFControl_GDTProperty
1c9d3225 43//purpose :
44//=======================================================================
45
727b5ad9 46STEPCAFControl_GDTProperty::STEPCAFControl_GDTProperty ()
1c9d3225 47{
48}
49
50//=======================================================================
51//function : getDimModifiers
52//purpose :
53//=======================================================================
727b5ad9 54void STEPCAFControl_GDTProperty::GetDimModifiers(const Handle(StepRepr_CompoundRepresentationItem)& theCRI,
1c9d3225 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//=======================================================================
727b5ad9 189void STEPCAFControl_GDTProperty::GetDimClassOfTolerance(const Handle(StepShape_LimitsAndFits)& theLAF,
04e93070 190 Standard_Boolean& theHolle,
191 XCAFDimTolObjects_DimensionFormVariance& theFV,
192 XCAFDimTolObjects_DimensionGrade& theG)
1c9d3225 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; 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 if(aGrade->IsSameString(aStr))
408 {
409 theG = XCAFDimTolObjects_DimensionGrade_IT01;
410 }
411 else
412 {
413 theG = (XCAFDimTolObjects_DimensionGrade)(aGrade->IntegerValue()+1);
414 }
415}
416
417//=======================================================================
418//function : getDimType
419//purpose :
420//=======================================================================
727b5ad9 421Standard_Boolean STEPCAFControl_GDTProperty::GetDimType(const Handle(TCollection_HAsciiString)& theName,
1c9d3225 422 XCAFDimTolObjects_DimensionType& theType)
423{
424 TCollection_AsciiString aName = theName->String();
425 aName.LowerCase();
426 theType = XCAFDimTolObjects_DimensionType_Location_None;
427 if(aName.IsEqual("curve length"))
428 {
429 theType = XCAFDimTolObjects_DimensionType_Size_CurveLength;
430 }
431 else if(aName.IsEqual("diameter"))
432 {
433 theType = XCAFDimTolObjects_DimensionType_Size_Diameter;
434 }
435 else if(aName.IsEqual("spherical diameter"))
436 {
437 theType = XCAFDimTolObjects_DimensionType_Size_SphericalDiameter;
438 }
439 else if(aName.IsEqual("radius"))
440 {
441 theType = XCAFDimTolObjects_DimensionType_Size_Radius;
442 }
443 else if(aName.IsEqual("spherical radius"))
444 {
445 theType = XCAFDimTolObjects_DimensionType_Size_SphericalRadius;
446 }
447 else if(aName.IsEqual("toroidal minor diameter"))
448 {
449 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalMinorDiameter;
450 }
451 else if(aName.IsEqual("toroidal major diameter"))
452 {
453 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalMajorDiameter;
454 }
455 else if(aName.IsEqual("toroidal minor radius"))
456 {
457 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalMinorRadius;
458 }
459 else if(aName.IsEqual("toroidal major radius"))
460 {
461 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalMajorRadius;
462 }
463 else if(aName.IsEqual("toroidal high major diameter"))
464 {
465 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorDiameter;
466 }
467 else if(aName.IsEqual("toroidal low major diameter"))
468 {
469 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorDiameter;
470 }
471 else if(aName.IsEqual("toroidal high major radius"))
472 {
473 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorRadius;
474 }
475 else if(aName.IsEqual("toroidal low major radius"))
476 {
477 theType = XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorRadius;
478 }
479 else if(aName.IsEqual("thickness"))
480 {
481 theType = XCAFDimTolObjects_DimensionType_Size_Thickness;
482 }
483 else if(aName.IsEqual("curved distance"))
484 {
485 theType = XCAFDimTolObjects_DimensionType_Location_CurvedDistance;
486 }
487 else if(aName.IsEqual("linear distance"))
488 {
489 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance;
490 }
491 else if(aName.IsEqual("linear distance centre outer"))
492 {
493 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToOuter;
494 }
495 else if(aName.IsEqual("linear distance centre inner"))
496 {
497 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToInner;
498 }
499 else if(aName.IsEqual("linear distance outer centre"))
500 {
501 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToCenter;
502 }
503 else if(aName.IsEqual("linear distance outer outer"))
504 {
505 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToOuter;
506 }
507 else if(aName.IsEqual("linear distance outer inner"))
508 {
509 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToInner;
510 }
511 else if(aName.IsEqual("linear distance inner centre"))
512 {
513 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToCenter;
514 }
515 else if(aName.IsEqual("linear distance inner outer"))
516 {
517 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToOuter;
518 }
519 else if(aName.IsEqual("linear distance inner inner"))
520 {
521 theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToInner;
522 }
523
524 if(theType != XCAFDimTolObjects_DimensionType_Location_None)
525 {
526 return Standard_True;
527 }
528 return Standard_False;
529}
530
531
532//=======================================================================
533//function : DatumTargetType
534//purpose :
535//=======================================================================
727b5ad9 536Standard_Boolean STEPCAFControl_GDTProperty::GetDatumTargetType(const Handle(TCollection_HAsciiString)& theDescription,
1c9d3225 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//=======================================================================
727b5ad9 573Standard_Boolean STEPCAFControl_GDTProperty::GetDimQualifierType(const Handle(TCollection_HAsciiString)& theDescription,
1c9d3225 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//=======================================================================
727b5ad9 602Standard_Boolean STEPCAFControl_GDTProperty::GetTolValueType(const Handle(TCollection_HAsciiString)& theDescription,
1c9d3225 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;
04e93070 621}
6595eee7 622
623
624//=======================================================================
625//function : GetDimTypeName
626//purpose :
627//=======================================================================
727b5ad9 628Handle(TCollection_HAsciiString) STEPCAFControl_GDTProperty::GetDimTypeName(const XCAFDimTolObjects_DimensionType theType)
6595eee7 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//=======================================================================
727b5ad9 717Handle(TCollection_HAsciiString) STEPCAFControl_GDTProperty::GetDimQualifierName(const XCAFDimTolObjects_DimensionQualifier theQualifier)
6595eee7 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//=======================================================================
727b5ad9 740Handle(TCollection_HAsciiString) STEPCAFControl_GDTProperty::GetDimModifierName(const XCAFDimTolObjects_DimensionModif theModifier)
6595eee7 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//=======================================================================
727b5ad9 822Handle(StepShape_LimitsAndFits) STEPCAFControl_GDTProperty::GetLimitsAndFits(Standard_Boolean theHole,
6595eee7 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//=======================================================================
727b5ad9 939Handle(TCollection_HAsciiString) STEPCAFControl_GDTProperty::GetDatumTargetName(const XCAFDimTolObjects_DatumTargetType theDatumType)
6595eee7 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 : GetAxis2Placement3D
965//purpose :
966//=======================================================================
727b5ad9 967Handle(StepGeom_Axis2Placement3d) STEPCAFControl_GDTProperty::GetAxis2Placement3D(const gp_Ax2& theAxis)
6595eee7 968{
969 Handle(StepGeom_Axis2Placement3d) anA2P3D = new StepGeom_Axis2Placement3d();
970 Handle(StepGeom_CartesianPoint) aPoint = new StepGeom_CartesianPoint();
971 Handle(TColStd_HArray1OfReal) aCoords = new TColStd_HArray1OfReal(1, 3);
972 for (Standard_Integer i = 1; i <= 3; i++)
973 aCoords->SetValue(i, theAxis.Location().Coord(i));
974 aPoint->Init(new TCollection_HAsciiString(), aCoords);
975 Handle(StepGeom_Direction) anAxis, aRefDirection;
976 Handle(TColStd_HArray1OfReal) anAxisCoords = new TColStd_HArray1OfReal(1, 3);
977 for (Standard_Integer i = 1; i <= 3; i++)
f0bf70e8 978 anAxisCoords->SetValue(i, theAxis.XDirection().Coord(i));
6595eee7 979 anAxis = new StepGeom_Direction();
980 anAxis->Init(new TCollection_HAsciiString(), anAxisCoords);
981 Handle(TColStd_HArray1OfReal) aDirCoords = new TColStd_HArray1OfReal(1, 3);
982 for (Standard_Integer i = 1; i <= 3; i++)
f0bf70e8 983 aDirCoords->SetValue(i, theAxis.YDirection().Coord(i));
6595eee7 984 aRefDirection = new StepGeom_Direction();
985 aRefDirection->Init(new TCollection_HAsciiString(), aDirCoords);
b0cef606 986 anA2P3D->Init(new TCollection_HAsciiString(), aPoint, Standard_True, anAxis, Standard_True, aRefDirection);
6595eee7 987 return anA2P3D;
988}
989
990//=======================================================================
991//function : IsDimensionalSize
992//purpose :
993//=======================================================================
727b5ad9 994Standard_Boolean STEPCAFControl_GDTProperty::IsDimensionalLocation(const XCAFDimTolObjects_DimensionType theType)
6595eee7 995{
996 if (theType == XCAFDimTolObjects_DimensionType_Location_None ||
997 theType == XCAFDimTolObjects_DimensionType_Location_CurvedDistance ||
998 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance ||
999 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToOuter ||
1000 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToInner ||
1001 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToCenter ||
1002 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToOuter ||
1003 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToInner ||
1004 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToCenter ||
1005 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToOuter ||
1006 theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToInner ||
1007 theType == XCAFDimTolObjects_DimensionType_Location_Oriented)
1008 return Standard_True;
1009 return Standard_False;
1010}
1011
1012//=======================================================================
1013//function : IsDimensionalSize
1014//purpose :
1015//=======================================================================
727b5ad9 1016Standard_Boolean STEPCAFControl_GDTProperty::IsDimensionalSize(const XCAFDimTolObjects_DimensionType theType)
6595eee7 1017{
1018 if (theType == XCAFDimTolObjects_DimensionType_Size_CurveLength ||
1019 theType == XCAFDimTolObjects_DimensionType_Size_Diameter ||
1020 theType == XCAFDimTolObjects_DimensionType_Size_SphericalDiameter ||
1021 theType == XCAFDimTolObjects_DimensionType_Size_Radius ||
1022 theType == XCAFDimTolObjects_DimensionType_Size_SphericalRadius ||
1023 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalMinorDiameter ||
1024 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalMajorDiameter ||
1025 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalMinorRadius ||
1026 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalMajorRadius ||
1027 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorDiameter ||
1028 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorDiameter ||
1029 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorRadius ||
1030 theType == XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorRadius ||
1031 theType == XCAFDimTolObjects_DimensionType_Size_Thickness)
1032 return Standard_True;
1033 return Standard_False;
1034}
1035
1036//=======================================================================
1037//function : GetGeomToleranceType
1038//purpose :
1039//=======================================================================
727b5ad9 1040StepDimTol_GeometricToleranceType STEPCAFControl_GDTProperty::GetGeomToleranceType(const XCAFDimTolObjects_GeomToleranceType theType)
6595eee7 1041{
1042 switch (theType) {
1043 case XCAFDimTolObjects_GeomToleranceType_Angularity:
1044 return StepDimTol_GTTAngularityTolerance;
1045 case XCAFDimTolObjects_GeomToleranceType_CircularRunout:
1046 return StepDimTol_GTTCircularRunoutTolerance;
1047 case XCAFDimTolObjects_GeomToleranceType_CircularityOrRoundness:
1048 return StepDimTol_GTTRoundnessTolerance;
1049 case XCAFDimTolObjects_GeomToleranceType_Coaxiality:
1050 return StepDimTol_GTTCoaxialityTolerance;
1051 case XCAFDimTolObjects_GeomToleranceType_Concentricity:
1052 return StepDimTol_GTTConcentricityTolerance;
1053 case XCAFDimTolObjects_GeomToleranceType_Cylindricity:
1054 return StepDimTol_GTTCylindricityTolerance;
1055 case XCAFDimTolObjects_GeomToleranceType_Flatness:
1056 return StepDimTol_GTTFlatnessTolerance;
1057 case XCAFDimTolObjects_GeomToleranceType_Parallelism:
1058 return StepDimTol_GTTParallelismTolerance;
1059 case XCAFDimTolObjects_GeomToleranceType_Perpendicularity:
1060 return StepDimTol_GTTPerpendicularityTolerance;
1061 case XCAFDimTolObjects_GeomToleranceType_Position:
1062 return StepDimTol_GTTPositionTolerance;
1063 case XCAFDimTolObjects_GeomToleranceType_ProfileOfLine:
1064 return StepDimTol_GTTLineProfileTolerance;
1065 case XCAFDimTolObjects_GeomToleranceType_ProfileOfSurface:
1066 return StepDimTol_GTTSurfaceProfileTolerance;
1067 case XCAFDimTolObjects_GeomToleranceType_Straightness:
1068 return StepDimTol_GTTStraightnessTolerance;
1069 case XCAFDimTolObjects_GeomToleranceType_Symmetry:
1070 return StepDimTol_GTTSymmetryTolerance;
1071 case XCAFDimTolObjects_GeomToleranceType_TotalRunout:
1072 return StepDimTol_GTTTotalRunoutTolerance;
1073 default:
1074 return StepDimTol_GTTPositionTolerance;
1075 }
1076}
1077
1078//=======================================================================
1079//function : GetGeomToleranceType
1080//purpose :
1081//=======================================================================
727b5ad9 1082XCAFDimTolObjects_GeomToleranceType STEPCAFControl_GDTProperty::GetGeomToleranceType(const StepDimTol_GeometricToleranceType theType)
6595eee7 1083{
1084 switch (theType) {
1085 case StepDimTol_GTTAngularityTolerance:
1086 return XCAFDimTolObjects_GeomToleranceType_Angularity;
1087 case StepDimTol_GTTCircularRunoutTolerance:
1088 return XCAFDimTolObjects_GeomToleranceType_CircularRunout;
1089 case StepDimTol_GTTRoundnessTolerance:
1090 return XCAFDimTolObjects_GeomToleranceType_CircularityOrRoundness;
1091 case StepDimTol_GTTCoaxialityTolerance:
1092 return XCAFDimTolObjects_GeomToleranceType_Coaxiality;
1093 case StepDimTol_GTTConcentricityTolerance:
1094 return XCAFDimTolObjects_GeomToleranceType_Concentricity;
1095 case StepDimTol_GTTCylindricityTolerance:
1096 return XCAFDimTolObjects_GeomToleranceType_Cylindricity;
1097 case StepDimTol_GTTFlatnessTolerance:
1098 return XCAFDimTolObjects_GeomToleranceType_Flatness;
1099 case StepDimTol_GTTParallelismTolerance:
1100 return XCAFDimTolObjects_GeomToleranceType_Parallelism;
1101 case StepDimTol_GTTPerpendicularityTolerance:
1102 return XCAFDimTolObjects_GeomToleranceType_Perpendicularity;
1103 case StepDimTol_GTTPositionTolerance:
1104 return XCAFDimTolObjects_GeomToleranceType_Position;
1105 case StepDimTol_GTTLineProfileTolerance:
1106 return XCAFDimTolObjects_GeomToleranceType_ProfileOfLine;
1107 case StepDimTol_GTTSurfaceProfileTolerance:
1108 return XCAFDimTolObjects_GeomToleranceType_ProfileOfSurface;
1109 case StepDimTol_GTTStraightnessTolerance:
1110 return XCAFDimTolObjects_GeomToleranceType_Straightness;
1111 case StepDimTol_GTTSymmetryTolerance:
1112 return XCAFDimTolObjects_GeomToleranceType_Symmetry;
1113 case StepDimTol_GTTTotalRunoutTolerance:
1114 return XCAFDimTolObjects_GeomToleranceType_TotalRunout;
1115 default:
1116 return XCAFDimTolObjects_GeomToleranceType_Position;
1117 }
1118}
1119
1120//=======================================================================
1121//function : GetGeomTolerance
1122//purpose :
1123//=======================================================================
727b5ad9 1124Handle(StepDimTol_GeometricTolerance) STEPCAFControl_GDTProperty::
6595eee7 1125 GetGeomTolerance(const XCAFDimTolObjects_GeomToleranceType theType)
1126{
1127 switch (theType) {
1128 case XCAFDimTolObjects_GeomToleranceType_CircularityOrRoundness:
1129 return new StepDimTol_RoundnessTolerance();
1130 case XCAFDimTolObjects_GeomToleranceType_Cylindricity:
1131 return new StepDimTol_CylindricityTolerance();
1132 case XCAFDimTolObjects_GeomToleranceType_Flatness:
1133 return new StepDimTol_FlatnessTolerance();
1134 case XCAFDimTolObjects_GeomToleranceType_Position:
1135 return new StepDimTol_PositionTolerance();
1136 case XCAFDimTolObjects_GeomToleranceType_ProfileOfLine:
1137 return new StepDimTol_LineProfileTolerance();
1138 case XCAFDimTolObjects_GeomToleranceType_ProfileOfSurface:
1139 return new StepDimTol_SurfaceProfileTolerance();
1140 case XCAFDimTolObjects_GeomToleranceType_Straightness:
1141 return new StepDimTol_StraightnessTolerance();
1142 default:
1143 return NULL;
1144 }
1145}
1146
1147//=======================================================================
1148//function : GetGeomToleranceModifier
1149//purpose :
1150//=======================================================================
727b5ad9 1151StepDimTol_GeometricToleranceModifier STEPCAFControl_GDTProperty::
6595eee7 1152 GetGeomToleranceModifier(const XCAFDimTolObjects_GeomToleranceModif theModifier)
1153{
1154 switch (theModifier) {
1155 case XCAFDimTolObjects_GeomToleranceModif_Any_Cross_Section:
1156 return StepDimTol_GTMAnyCrossSection;
1157 case XCAFDimTolObjects_GeomToleranceModif_Common_Zone:
1158 return StepDimTol_GTMCommonZone;
1159 case XCAFDimTolObjects_GeomToleranceModif_Each_Radial_Element:
1160 return StepDimTol_GTMEachRadialElement;
1161 case XCAFDimTolObjects_GeomToleranceModif_Free_State:
1162 return StepDimTol_GTMFreeState;
1163 case XCAFDimTolObjects_GeomToleranceModif_Least_Material_Requirement:
1164 return StepDimTol_GTMLeastMaterialRequirement;
1165 case XCAFDimTolObjects_GeomToleranceModif_Line_Element:
1166 return StepDimTol_GTMLineElement;
1167 case XCAFDimTolObjects_GeomToleranceModif_Major_Diameter:
1168 return StepDimTol_GTMMajorDiameter;
1169 case XCAFDimTolObjects_GeomToleranceModif_Maximum_Material_Requirement:
1170 return StepDimTol_GTMMaximumMaterialRequirement;
1171 case XCAFDimTolObjects_GeomToleranceModif_Minor_Diameter:
1172 return StepDimTol_GTMMinorDiameter;
1173 case XCAFDimTolObjects_GeomToleranceModif_Not_Convex:
1174 return StepDimTol_GTMNotConvex;
1175 case XCAFDimTolObjects_GeomToleranceModif_Pitch_Diameter:
1176 return StepDimTol_GTMPitchDiameter;
1177 case XCAFDimTolObjects_GeomToleranceModif_Reciprocity_Requirement:
1178 return StepDimTol_GTMReciprocityRequirement;
1179 case XCAFDimTolObjects_GeomToleranceModif_Separate_Requirement:
1180 return StepDimTol_GTMSeparateRequirement;
1181 case XCAFDimTolObjects_GeomToleranceModif_Statistical_Tolerance:
1182 return StepDimTol_GTMStatisticalTolerance;
1183 case XCAFDimTolObjects_GeomToleranceModif_Tangent_Plane:
1184 return StepDimTol_GTMTangentPlane;
1185 default:
1186 return StepDimTol_GTMMaximumMaterialRequirement;
1187 }
1188}
1189
1190//=======================================================================
1191//function : GetDatumRefModifiers
1192//purpose : Note: this function does not add anything to model
1193//=======================================================================
727b5ad9 1194Handle(StepDimTol_HArray1OfDatumReferenceModifier) STEPCAFControl_GDTProperty::
6595eee7 1195 GetDatumRefModifiers(const XCAFDimTolObjects_DatumModifiersSequence theModifiers,
1196 const XCAFDimTolObjects_DatumModifWithValue theModifWithVal,
1197 const Standard_Real theValue,
1198 const StepBasic_Unit theUnit)
1199{
1200 if ((theModifiers.Length() == 0) && (theModifWithVal == XCAFDimTolObjects_DatumModifWithValue_None))
1201 return NULL;
1202 Standard_Integer aModifNb = theModifiers.Length();
1203 if (theModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None)
1204 aModifNb++;
1205 Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModifiers =
1206 new StepDimTol_HArray1OfDatumReferenceModifier(1, aModifNb);
1207
1208 // Modifier with value
1209 if (theModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None) {
1210 StepDimTol_DatumReferenceModifierType aType;
1211 switch (theModifWithVal) {
1212 case XCAFDimTolObjects_DatumModifWithValue_CircularOrCylindrical:
1213 aType = StepDimTol_CircularOrCylindrical;
1214 break;
1215 case XCAFDimTolObjects_DatumModifWithValue_Distance:
1216 aType = StepDimTol_Distance;
1217 break;
1218 case XCAFDimTolObjects_DatumModifWithValue_Projected:
1219 aType = StepDimTol_Projected;
1220 break;
1221 case XCAFDimTolObjects_DatumModifWithValue_Spherical:
1222 aType = StepDimTol_Spherical;
1223 break;
1224 default:
1225 aType = StepDimTol_Distance;
1226 }
1227 Handle(StepBasic_LengthMeasureWithUnit) aLMWU = new StepBasic_LengthMeasureWithUnit();
1228 Handle(StepBasic_MeasureValueMember) aValueMember = new StepBasic_MeasureValueMember();
1229 aValueMember->SetName("LENGTH_MEASURE");
1230 aValueMember->SetReal(theValue);
1231 aLMWU->Init(aValueMember, theUnit);
1232 Handle(StepDimTol_DatumReferenceModifierWithValue) aModifWithVal = new StepDimTol_DatumReferenceModifierWithValue();
1233 aModifWithVal->Init(aType, aLMWU);
1234 StepDimTol_DatumReferenceModifier aModif;
1235 aModif.SetValue(aModifWithVal);
1236 aModifiers->SetValue(aModifNb, aModif);
1237 }
1238
1239 // Simple modifiers
1240 for (Standard_Integer i = 1; i <= theModifiers.Length(); i++) {
1241 Handle(StepDimTol_SimpleDatumReferenceModifierMember) aSimpleModifMember =
1242 new StepDimTol_SimpleDatumReferenceModifierMember();
1243 switch (theModifiers.Value(i)) {
1244 case XCAFDimTolObjects_DatumSingleModif_AnyCrossSection:
1245 aSimpleModifMember->SetEnumText(0, ".ANY_CROSS_SECTION.");
1246 break;
1247 case XCAFDimTolObjects_DatumSingleModif_Any_LongitudinalSection:
1248 aSimpleModifMember->SetEnumText(0, ".ANY_LONGITUDINAL_SECTION.");
1249 break;
1250 case XCAFDimTolObjects_DatumSingleModif_Basic:
1251 aSimpleModifMember->SetEnumText(0, ".BASIC.");
1252 break;
1253 case XCAFDimTolObjects_DatumSingleModif_ContactingFeature:
1254 aSimpleModifMember->SetEnumText(0, ".CONTACTING_FEATURE.");
1255 break;
1256 case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintU:
1257 aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_U.");
1258 break;
1259 case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintV:
1260 aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_V.");
1261 break;
1262 case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintW:
1263 aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_W.");
1264 break;
1265 case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintX:
1266 aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_X.");
1267 break;
1268 case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintY:
1269 aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_Y.");
1270 break;
1271 case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintZ:
1272 aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_Z.");
1273 break;
1274 case XCAFDimTolObjects_DatumSingleModif_DistanceVariable:
1275 aSimpleModifMember->SetEnumText(0, ".DISTANCE_VARIABLE.");
1276 break;
1277 case XCAFDimTolObjects_DatumSingleModif_FreeState:
1278 aSimpleModifMember->SetEnumText(0, ".FREE_STATE.");
1279 break;
1280 case XCAFDimTolObjects_DatumSingleModif_LeastMaterialRequirement:
1281 aSimpleModifMember->SetEnumText(0, ".LEAST_MATERIAL_REQUIREMENT.");
1282 break;
1283 case XCAFDimTolObjects_DatumSingleModif_Line:
1284 aSimpleModifMember->SetEnumText(0, ".LINE.");
1285 break;
1286 case XCAFDimTolObjects_DatumSingleModif_MajorDiameter:
1287 aSimpleModifMember->SetEnumText(0, ".MAJOR_DIAMETER.");
1288 break;
1289 case XCAFDimTolObjects_DatumSingleModif_MaximumMaterialRequirement:
1290 aSimpleModifMember->SetEnumText(0, ".MAXIMUM_MATERIAL_REQUIREMENT.");
1291 break;
1292 case XCAFDimTolObjects_DatumSingleModif_MinorDiameter:
1293 aSimpleModifMember->SetEnumText(0, ".MINOR_DIAMETER.");
1294 break;
1295 case XCAFDimTolObjects_DatumSingleModif_Orientation:
1296 aSimpleModifMember->SetEnumText(0, ".ORIENTATION.");
1297 break;
1298 case XCAFDimTolObjects_DatumSingleModif_PitchDiameter:
1299 aSimpleModifMember->SetEnumText(0, ".PITCH_DIAMETER.");
1300 break;
1301 case XCAFDimTolObjects_DatumSingleModif_Plane:
1302 aSimpleModifMember->SetEnumText(0, ".PLANE.");
1303 break;
1304 case XCAFDimTolObjects_DatumSingleModif_Point:
1305 aSimpleModifMember->SetEnumText(0, ".POINT.");
1306 break;
1307 case XCAFDimTolObjects_DatumSingleModif_Translation:
1308 aSimpleModifMember->SetEnumText(0, ".TRANSLATION.");
1309 break;
1310 }
1311 StepDimTol_DatumReferenceModifier aModif;
1312 aModif.SetValue(aSimpleModifMember);
1313 aModifiers->SetValue(i, aModif);
1314 }
1315
1316 return aModifiers;
1317}
1318
1319//=======================================================================
1320//function : GetTolValueType
1321//purpose :
1322//=======================================================================
727b5ad9 1323Handle(TCollection_HAsciiString) STEPCAFControl_GDTProperty::GetTolValueType(const XCAFDimTolObjects_GeomToleranceTypeValue& theType)
6595eee7 1324{
1325 switch (theType) {
1326 case XCAFDimTolObjects_GeomToleranceTypeValue_Diameter:
1327 return new TCollection_HAsciiString("cylindrical or circular");
1328 case XCAFDimTolObjects_GeomToleranceTypeValue_SphericalDiameter:
1329 return new TCollection_HAsciiString("spherical");
1330 default:
1331 return new TCollection_HAsciiString("unknown");
1332 }
1333}
b0cef606 1334
1335//=======================================================================
1336//function : GetTessellation
1337//purpose :
1338//=======================================================================
1339Handle(StepVisual_TessellatedGeometricSet) STEPCAFControl_GDTProperty::GetTessellation(const TopoDS_Shape theShape)
1340{
1341 // Build coordinate list and curves
1342 NCollection_Handle<StepVisual_VectorOfHSequenceOfInteger> aCurves = new StepVisual_VectorOfHSequenceOfInteger;
1343 NCollection_Vector<gp_XYZ> aCoords;
1344 Standard_Integer aPntNb = 1;
1345 for (TopExp_Explorer aCurveIt(theShape, TopAbs_EDGE); aCurveIt.More(); aCurveIt.Next()) {
1346 Handle(TColStd_HSequenceOfInteger) aCurve = new TColStd_HSequenceOfInteger;
1347 // Find out type of edge curve
1348 Standard_Real aFirst = 0, aLast = 0;
1349 Handle(Geom_Curve) anEdgeCurve = BRep_Tool::Curve(TopoDS::Edge(aCurveIt.Current()), aFirst, aLast);
1350 if (anEdgeCurve.IsNull())
1351 continue;
1352 // Line
1353 if (anEdgeCurve->IsKind(STANDARD_TYPE(Geom_Line))) {
1354 for (TopExp_Explorer aVertIt(aCurveIt.Current(), TopAbs_VERTEX); aVertIt.More(); aVertIt.Next()) {
1355 aCoords.Append(BRep_Tool::Pnt(TopoDS::Vertex(aVertIt.Current())).XYZ());
1356 aCurve->Append(aPntNb);
1357 aPntNb++;
1358 }
1359 }
1360 // BSpline
1361 else {
1362 ShapeConstruct_Curve aSCC;
1363 Handle(Geom_BSplineCurve) aBSCurve = aSCC.ConvertToBSpline(anEdgeCurve,
1364 aFirst, aLast, Precision::Confusion());
1365 for (Standard_Integer i = 1; i <= aBSCurve->NbPoles(); i++) {
1366 aCoords.Append(aBSCurve->Pole(i).XYZ());
1367 aCurve->Append(aPntNb);
1368 aPntNb++;
1369 }
1370 }
1371 aCurves->Append(aCurve);
1372 }
1373
1374 Handle(TColgp_HArray1OfXYZ) aPoints = new TColgp_HArray1OfXYZ(1, aCoords.Length());
1375 for (Standard_Integer i = 1; i <= aPoints->Length(); i++) {
1376 aPoints->SetValue(i, aCoords.Value(i - 1));
1377 }
1378 // STEP entities
1379 Handle(StepVisual_CoordinatesList) aCoordList = new StepVisual_CoordinatesList();
1380 aCoordList->Init(new TCollection_HAsciiString(), aPoints);
1381 Handle(StepVisual_TessellatedCurveSet) aCurveSet = new StepVisual_TessellatedCurveSet();
1382 aCurveSet->Init(new TCollection_HAsciiString(), aCoordList, aCurves);
1383 NCollection_Handle<StepVisual_Array1OfTessellatedItem> aTessItems = new StepVisual_Array1OfTessellatedItem(1, 1);
1384 aTessItems->SetValue(1, aCurveSet);
1385 Handle(StepVisual_TessellatedGeometricSet) aGeomSet = new StepVisual_TessellatedGeometricSet();
1386 aGeomSet->Init(new TCollection_HAsciiString(), aTessItems);
1387 return aGeomSet;
1388}