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