0026859: Export of GDT from XCAF to STEP
authorika <ika@opencascade.com>
Tue, 10 Nov 2015 08:58:29 +0000 (11:58 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 4 Dec 2015 10:16:58 +0000 (13:16 +0300)
Export/Import:
Add export of dimensions, geometric tolerances and datums, according to AP242.
Add missing STEP entities.
Corrections.

XCAF:
Add new attributes to Datum object: DatumTargetNumber.
Supplement enum XCAFDimTolObjects_GeomToleranceZoneModif.
Corrections.

Test cases:
gdt export A1
gdt export A2
gdt export A3
gdt export A4
gdt export A5

46 files changed:
src/RWStepAP214/RWStepAP214_GeneralModule.cxx
src/RWStepAP214/RWStepAP214_ReadWriteModule.cxx
src/RWStepDimTol/FILES
src/RWStepDimTol/RWStepDimTol_RWDatumReferenceCompartment.cxx
src/RWStepDimTol/RWStepDimTol_RWDatumReferenceElement.cxx
src/RWStepDimTol/RWStepDimTol_RWGeneralDatumReference.cxx
src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.cxx [new file with mode: 0644]
src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx [new file with mode: 0644]
src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod.cxx
src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.cxx [new file with mode: 0644]
src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.hxx [new file with mode: 0644]
src/STEPCAFControl/STEPCAFControl_Reader.cxx
src/STEPCAFControl/STEPCAFControl_Writer.cxx
src/STEPCAFControl/STEPCAFControl_Writer.hxx
src/STEPConstruct/STEPConstruct_GDTProperty.cxx
src/STEPConstruct/STEPConstruct_GDTProperty.hxx
src/StepAP214/StepAP214_Protocol.cxx
src/StepDimTol/FILES
src/StepDimTol/StepDimTol_GeneralDatumReference.hxx
src/StepDimTol/StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.cxx [new file with mode: 0644]
src/StepDimTol/StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx [new file with mode: 0644]
src/StepDimTol/StepDimTol_GeoTolAndGeoTolWthMaxTol.cxx [new file with mode: 0644]
src/StepDimTol/StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx [new file with mode: 0644]
src/StepDimTol/StepDimTol_SimpleDatumReferenceModifierMember.hxx
src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.cxx
src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.hxx
src/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.cxx
src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceZoneModif.hxx
src/XCAFDoc/XCAFDoc_Datum.cxx
src/XCAFDoc/XCAFDoc_DimTolTool.cxx
src/XCAFDoc/XCAFDoc_DimTolTool.hxx
src/XCAFDoc/XCAFDoc_GeomTolerance.cxx
src/XDEDRAW/XDEDRAW_GDTs.cxx
tests/gdt/export/A1 [new file with mode: 0644]
tests/gdt/export/A2 [new file with mode: 0644]
tests/gdt/export/A3 [new file with mode: 0644]
tests/gdt/export/A4 [new file with mode: 0644]
tests/gdt/export/A5 [new file with mode: 0644]
tests/gdt/export/begin [new file with mode: 0644]
tests/gdt/export/end [new file with mode: 0644]
tests/gdt/grids.list
tests/gdt/import/A1
tests/gdt/import/A2
tests/gdt/import/A3
tests/gdt/import/A4
tests/gdt/import/A5

index 2d99080..bcea4ad 100644 (file)
 #include <RWStepRepr_RWCompShAspAndDatumFeatAndShAsp.hxx>
 #include <RWStepRepr_RWIntegerRepresentationItem.hxx>
 #include <RWStepRepr_RWValueRepresentationItem.hxx>
+#include <RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx>
+#include <RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.hxx>
 
 #include <StepRepr_Apex.hxx>
 #include <StepRepr_CentreOfSymmetry.hxx>
 #include <StepRepr_CompShAspAndDatumFeatAndShAsp.hxx>
 #include <StepRepr_IntegerRepresentationItem.hxx>
 #include <StepRepr_ValueRepresentationItem.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx>
 
 static Standard_Integer catsh,catdr,catstr,catdsc,cataux;
 
@@ -4978,6 +4982,21 @@ void RWStepAP214_GeneralModule::FillSharedCase(const Standard_Integer CN,
       RWStepRepr_RWFeatureForDatumTargetRelationship tool;
       tool.Share(anent,iter);
     }
+    break;
+  case 705:
+    {
+      DeclareAndCast(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol,anent,ent);
+      RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol tool;
+      tool.Share(anent,iter);
+    }
+    break;
+  case 706:
+    {
+      DeclareAndCast(StepDimTol_GeoTolAndGeoTolWthMaxTol,anent,ent);
+      RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol tool;
+      tool.Share(anent,iter);
+    }
+    break;
 
     default : break;
     }
@@ -6928,6 +6947,12 @@ Standard_Boolean RWStepAP214_GeneralModule::NewVoid
   case 702:
     ent = new StepRepr_FeatureForDatumTargetRelationship;
     break;
+  case 705 : 
+    ent = new StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol;
+    break;
+  case 706 : 
+    ent = new StepDimTol_GeoTolAndGeoTolWthMaxTol;
+    break;
 
   default: 
     return Standard_False;
@@ -7508,7 +7533,10 @@ Standard_Integer  RWStepAP214_GeneralModule::CategoryNumber
   case 698:
   case 699:
   case 700:
-  case 701: return catdr;
+  case 701:
+  case 702: return catdr;
+  case 705:
+  case 706: return cataux;
     
   default : break;
   }
index 81d240a..fc56d33 100644 (file)
@@ -1316,6 +1316,8 @@ Handle(atype) result = Handle(atype)::DownCast (start)
 #include <RWStepRepr_RWCompShAspAndDatumFeatAndShAsp.hxx>
 #include <RWStepRepr_RWIntegerRepresentationItem.hxx>
 #include <RWStepRepr_RWValueRepresentationItem.hxx>
+#include <RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx>
+#include <RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.hxx>
 
 #include <StepRepr_Apex.hxx>
 #include <StepRepr_CentreOfSymmetry.hxx>
@@ -1359,6 +1361,8 @@ Handle(atype) result = Handle(atype)::DownCast (start)
 #include <StepRepr_CompShAspAndDatumFeatAndShAsp.hxx>
 #include <StepRepr_IntegerRepresentationItem.hxx>
 #include <StepRepr_ValueRepresentationItem.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx>
 
 
 // -- General Declarations (Recognize, StepType) ---
@@ -1987,6 +1991,7 @@ static TCollection_AsciiString Reco_DatumSystem("DATUM_SYSTEM");
 static TCollection_AsciiString Reco_GeneralDatumReference("GENERAL_DATUM_REFERENCE");
 static TCollection_AsciiString Reco_IntegerRepresentationItem("INTEGER_REPRESENTATION_ITEM");
 static TCollection_AsciiString Reco_ValueRepresentationItem("VALUE_REPRESENTATION_ITEM");
+static TCollection_AsciiString Reco_FeatureForDatumTargetRelationship("FEATURE_FOR_DATUM_TARGET_RELATIONSHIP");
 
 // -- Definition of the libraries --
 
@@ -2630,6 +2635,7 @@ RWStepAP214_ReadWriteModule::RWStepAP214_ReadWriteModule ()
   typenums->SetItem (Reco_GeneralDatumReference, 690);
   typenums->SetItem (Reco_IntegerRepresentationItem, 700);
   typenums->SetItem (Reco_ValueRepresentationItem, 701);
+  typenums->SetItem (Reco_FeatureForDatumTargetRelationship, 702);
 
 //    SHORT NAMES
 //    NB : la liste est celle de AP203
@@ -3362,6 +3368,32 @@ Standard_Integer RWStepAP214_ReadWriteModule::CaseStep
                (types(5).IsEqual(StepType(247)))) {
         return 693;
       }
+      else if (((types(1).IsEqual(StepType(609)) ||
+                 types(1).IsEqual(StepType(611)) ||
+                 types(1).IsEqual(StepType(612)) ||
+                 types(1).IsEqual(StepType(613)) ||
+                 types(1).IsEqual(StepType(614)) ||
+                 types(1).IsEqual(StepType(615))) &&
+                types(2).IsEqual(StepType(625)) &&
+                types(3).IsEqual(StepType(627)) &&
+                types(4).IsEqual(StepType(675)) &&
+                types(5).IsEqual(StepType(676)))
+                ||
+               (types(1).IsEqual(StepType(625)) &&
+                types(2).IsEqual(StepType(627)) &&
+                types(3).IsEqual(StepType(675)) &&
+                types(4).IsEqual(StepType(676)) &&
+                (types(5).IsEqual(StepType(616)) ||
+                 types(5).IsEqual(StepType(617)) ||
+                 types(5).IsEqual(StepType(618)) ||
+                 types(5).IsEqual(StepType(619)) ||
+                 types(5).IsEqual(StepType(620)) ||
+                 types(5).IsEqual(StepType(621)) ||
+                 types(5).IsEqual(StepType(622)) ||
+                 types(5).IsEqual(StepType(623)) ||
+                 types(5).IsEqual(StepType(624))))) {
+        return 705;
+      }
     }
     else if (NbComp == 4) {
       if ((types(1).IsEqual(StepType(161))) &&
@@ -3450,6 +3482,30 @@ Standard_Integer RWStepAP214_ReadWriteModule::CaseStep
                types(4).IsEqual(StepType(258))) {
         return 698;
       }
+      else if (((types(1).IsEqual(StepType(609)) ||
+                 types(1).IsEqual(StepType(611)) ||
+                 types(1).IsEqual(StepType(612)) ||
+                 types(1).IsEqual(StepType(613)) ||
+                 types(1).IsEqual(StepType(614)) ||
+                 types(1).IsEqual(StepType(615))) &&
+                types(2).IsEqual(StepType(625)) &&
+                types(3).IsEqual(StepType(675)) &&
+                types(4).IsEqual(StepType(676)))
+                ||
+               (types(1).IsEqual(StepType(625)) &&
+                types(2).IsEqual(StepType(675)) &&
+                types(3).IsEqual(StepType(676)) &&
+                (types(4).IsEqual(StepType(616)) ||
+                 types(4).IsEqual(StepType(617)) ||
+                 types(4).IsEqual(StepType(618)) ||
+                 types(4).IsEqual(StepType(619)) ||
+                 types(4).IsEqual(StepType(620)) ||
+                 types(4).IsEqual(StepType(621)) ||
+                 types(4).IsEqual(StepType(622)) ||
+                 types(4).IsEqual(StepType(623)) ||
+                 types(4).IsEqual(StepType(624))))) {
+        return 706;
+      }
     }
     else if (NbComp == 3) {
       if ((types(1).IsEqual(StepType(158))) &&
@@ -3740,6 +3796,10 @@ Standard_Boolean RWStepAP214_ReadWriteModule::IsComplex
       return Standard_True;
     case 699:
       return Standard_True;
+    case 705:
+      return Standard_True;
+    case 706:
+      return Standard_True;
     default:
       return Standard_False;
     }
@@ -4383,6 +4443,7 @@ const TCollection_AsciiString& RWStepAP214_ReadWriteModule::StepType
   case 690: return Reco_GeneralDatumReference;
   case 700: return Reco_IntegerRepresentationItem;
   case 701: return Reco_ValueRepresentationItem;
+  case 702: return Reco_FeatureForDatumTargetRelationship;
 
   default : return PasReco;
   }
@@ -4679,6 +4740,19 @@ Standard_Boolean RWStepAP214_ReadWriteModule::ComplexType(const Standard_Integer
       types.Append (StepType(630));
       types.Append (StepType(258));
       break;
+    case 705:
+      types.Append (StepType(625));
+      types.Append (StepType(627));
+      types.Append (StepType(675));
+      types.Append (StepType(676));
+      types.Append (StepType(625));
+      break;
+    case 706:
+      types.Append (StepType(625));
+      types.Append (StepType(675));
+      types.Append (StepType(676));
+      types.Append (StepType(625));
+      break;
     }
   return Standard_True;
 }
@@ -9109,6 +9183,20 @@ void RWStepAP214_ReadWriteModule::ReadStep(const Standard_Integer CN,
       tool.ReadStep (data,num,ach,anent);
     }
     break;
+  case 705:
+    {
+      DeclareAndCast(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol,anent,ent);
+      RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol tool;
+      tool.ReadStep (data,num,ach,anent);
+    }
+    break;
+  case 706:
+    {
+      DeclareAndCast(StepDimTol_GeoTolAndGeoTolWthMaxTol,anent,ent);
+      RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol tool;
+      tool.ReadStep (data,num,ach,anent);
+    }
+    break;
 
   default: 
     ach->AddFail("Type Mismatch when reading - Entity");
@@ -13817,6 +13905,20 @@ void RWStepAP214_ReadWriteModule::WriteStep(const Standard_Integer CN,
       tool.WriteStep (SW,anent);
     }
     break;
+  case 705:
+    {
+      DeclareAndCast(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol,anent,ent);
+      RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol tool;
+      tool.WriteStep (SW,anent);
+    }
+    break;
+  case 706:
+    {
+      DeclareAndCast(StepDimTol_GeoTolAndGeoTolWthMaxTol,anent,ent);
+      RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol tool;
+      tool.WriteStep (SW,anent);
+    }
+    break;
 
   default: 
     return;
index e5d06c5..dee89bc 100644 (file)
@@ -46,12 +46,16 @@ RWStepDimTol_RWGeometricToleranceWithModifiers.cxx
 RWStepDimTol_RWGeometricToleranceWithModifiers.hxx
 RWStepDimTol_RWGeoTolAndGeoTolWthDatRef.cxx
 RWStepDimTol_RWGeoTolAndGeoTolWthDatRef.hxx
+RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.cxx
+RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx
 RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod.cxx
 RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod.hxx
 RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.cxx
 RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx
 RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.cxx
 RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.hxx
+RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.cxx
+RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.hxx
 RWStepDimTol_RWGeoTolAndGeoTolWthMod.cxx
 RWStepDimTol_RWGeoTolAndGeoTolWthMod.hxx
 RWStepDimTol_RWLineProfileTolerance.cxx
index 249aaf0..06ffdd7 100644 (file)
@@ -156,7 +156,7 @@ void RWStepDimTol_RWDatumReferenceCompartment::WriteStep (StepData_StepWriter& S
   else if (aBaseType == 2) {
     Handle(StepDimTol_HArray1OfDatumReferenceElement) anArray = ent->Base().CommonDatumList();
     Standard_Integer i, nb = (anArray.IsNull() ? 0 : anArray->Length());
-    SW.OpenSub();
+    SW.OpenTypedSub("COMMON_DATUM_LIST");
     for (i = 1; i <= nb; i++)  
       SW.Send (anArray->Value(i));
     SW.CloseSub();
@@ -170,12 +170,14 @@ void RWStepDimTol_RWDatumReferenceCompartment::WriteStep (StepData_StepWriter& S
       Standard_Integer aType = aModifier.CaseNum(aModifier.Value());
       switch (aType) {
         case 1: SW.Send(aModifier.DatumReferenceModifierWithValue()); break;
-        case 2: SW.SendEnum(aModifier.SimpleDatumReferenceModifierMember()->EnumText());break;
+        case 2: SW.Send(aModifier.SimpleDatumReferenceModifierMember());break;
       }
     }
     SW.CloseSub();
-  }  
-  
+  }
+  else {
+    SW.SendUndef();
+  }
 }
 
 //=======================================================================
index dc80729..f5656e5 100644 (file)
@@ -158,7 +158,7 @@ void RWStepDimTol_RWDatumReferenceElement::WriteStep (StepData_StepWriter& SW,
   else if (aBaseType == 2) {
     Handle(StepDimTol_HArray1OfDatumReferenceElement) anArray = (ent->Base()).CommonDatumList();
     Standard_Integer i, nb = (anArray.IsNull() ? 0 : anArray->Length());
-    SW.OpenSub();
+    SW.OpenTypedSub("COMMON_DATUM_LIST");
     for (i = 1; i <= nb; i++)  
       SW.Send (anArray->Value(i));
     SW.CloseSub();
@@ -176,8 +176,10 @@ void RWStepDimTol_RWDatumReferenceElement::WriteStep (StepData_StepWriter& SW,
       }
     }
     SW.CloseSub();
-  }  
-  
+  }
+  else {
+    SW.SendUndef();
+  }
 }
 
 //=======================================================================
index 5ff7628..d9ec460 100644 (file)
@@ -156,7 +156,7 @@ void RWStepDimTol_RWGeneralDatumReference::WriteStep (StepData_StepWriter& SW,
   else if (aBaseType == 2) {
     Handle(StepDimTol_HArray1OfDatumReferenceElement) anArray = ent->Base().CommonDatumList();
     Standard_Integer i, nb = (anArray.IsNull() ? 0 : anArray->Length());
-    SW.OpenSub();
+    SW.OpenTypedSub("COMMON_DATUM_LIST");
     for (i = 1; i <= nb; i++)  
       SW.Send (anArray->Value(i));
     SW.CloseSub();
@@ -174,7 +174,10 @@ void RWStepDimTol_RWGeneralDatumReference::WriteStep (StepData_StepWriter& SW,
       }
     }
     SW.CloseSub();
-  }  
+  }
+  else {
+    SW.SendUndef();
+  }
   
 }
 
diff --git a/src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.cxx b/src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.cxx
new file mode 100644 (file)
index 0000000..fdb9557
--- /dev/null
@@ -0,0 +1,253 @@
+// Created on: 2015-11-13
+// Created by: Irina KRYLOVA
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <Interface_Check.hxx>
+#include <Interface_EntityIterator.hxx>
+#include <RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx>
+#include <StepBasic_LengthMeasureWithUnit.hxx>
+#include <StepBasic_MeasureWithUnit.hxx>
+#include <StepData_StepReaderData.hxx>
+#include <StepData_StepWriter.hxx>
+#include <StepDimTol_DatumReference.hxx>
+#include <StepDimTol_GeometricToleranceTarget.hxx>
+#include <StepDimTol_GeometricToleranceType.hxx>
+#include <StepDimTol_GeometricToleranceWithDatumReference.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx>
+#include <StepDimTol_HArray1OfDatumSystemOrReference.hxx>
+#include <StepDimTol_GeometricToleranceWithModifiers.hxx>
+
+//=======================================================================
+//function : RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol
+//purpose  : 
+//=======================================================================
+RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol()
+{
+}
+
+
+//=======================================================================
+//function : ReadStep
+//purpose  : 
+//=======================================================================
+
+void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::ReadStep
+  (const Handle(StepData_StepReaderData)& data,
+   const Standard_Integer num0, Handle(Interface_Check)& ach,
+   const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)& ent) const
+{
+  Standard_Integer num = 0;//num0;
+  data->NamedForComplex("GEOMETRIC_TOLERANCE","GMTTLR",num0,num,ach);
+  if (!data->CheckNbParams(num,4,ach,"geometric_tolerance")) return;
+  // Own fields of GeometricTolerance
+  Handle(TCollection_HAsciiString) aName;
+  data->ReadString (num, 1, "name", ach, aName);
+  Handle(TCollection_HAsciiString) aDescription;
+  data->ReadString (num, 2, "description", ach, aDescription);
+  Handle(StepBasic_MeasureWithUnit) aMagnitude;
+  data->ReadEntity (num, 3, "magnitude", ach, STANDARD_TYPE(StepBasic_MeasureWithUnit), aMagnitude);
+  StepDimTol_GeometricToleranceTarget aTolerancedShapeAspect;
+  data->ReadEntity (num, 4, "toleranced_shape_aspect", ach, aTolerancedShapeAspect);
+
+  data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE","GTWDR",num0,num,ach);
+  // Own fields of GeometricToleranceWithDatumReference
+  Handle(StepDimTol_HArray1OfDatumSystemOrReference) aDatumSystem;
+  Standard_Integer sub5 = 0;
+  if ( data->ReadSubList (num, 1, "datum_system", ach, sub5) ) {
+    Standard_Integer nb0 = data->NbParams(sub5);
+    aDatumSystem = new StepDimTol_HArray1OfDatumSystemOrReference (1, nb0);
+    Standard_Integer num2 = sub5;
+    for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
+      StepDimTol_DatumSystemOrReference anIt0;
+      data->ReadEntity (num2, i0, "datum_system_or_reference", ach, anIt0);
+      aDatumSystem->SetValue(i0, anIt0);
+    }
+  }
+  // Initialize entity
+  Handle(StepDimTol_GeometricToleranceWithDatumReference) aGTWDR =
+    new StepDimTol_GeometricToleranceWithDatumReference;
+  aGTWDR->SetDatumSystem(aDatumSystem);
+  
+  data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_MAXIMUM_TOLERANCE",num0,num,ach);
+  Handle(StepBasic_LengthMeasureWithUnit) aMaxTol;
+  data->ReadEntity (num, 1, "maximum_upper_tolerance", ach, STANDARD_TYPE(StepBasic_LengthMeasureWithUnit), aMaxTol);
+
+  data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_MODIFIERS",num0,num,ach);
+  // Own fields of ModifiedGeometricTolerance
+  Handle(StepDimTol_HArray1OfGeometricToleranceModifier) aModifiers;
+  Standard_Integer sub = 0;
+  if ( data->ReadSubList (num, 1, "modifiers", ach, sub) ) {
+    Standard_Integer nb0 = data->NbParams(sub5);
+    aModifiers = new StepDimTol_HArray1OfGeometricToleranceModifier (1, nb0);
+    Standard_Integer num2 = sub;
+    for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
+      StepDimTol_GeometricToleranceModifier anIt0 = StepDimTol_GTMMaximumMaterialRequirement;
+      if (data->ParamType (num2, i0) == Interface_ParamEnum) {
+        Standard_CString text = data->ParamCValue(num2, i0);
+        if      (strcmp(text, ".ANY_CROSS_SECTION.")==0) anIt0 = StepDimTol_GTMAnyCrossSection;
+        else if (strcmp(text, ".COMMON_ZONE.")==0) anIt0 = StepDimTol_GTMCommonZone;
+        else if (strcmp(text, ".EACH_RADIAL_ELEMENT.")==0) anIt0 = StepDimTol_GTMEachRadialElement;
+        else if (strcmp(text, ".FREE_STATE.")==0) anIt0 = StepDimTol_GTMFreeState;
+        else if (strcmp(text, ".LEAST_MATERIAL_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMLeastMaterialRequirement;
+        else if (strcmp(text, ".LINE_ELEMENT.")==0) anIt0 = StepDimTol_GTMLineElement;
+        else if (strcmp(text, ".MAJOR_DIAMETER.")==0) anIt0 = StepDimTol_GTMMajorDiameter;
+        else if (strcmp(text, ".MAXIMUM_MATERIAL_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMMaximumMaterialRequirement;
+        else if (strcmp(text, ".MINOR_DIAMETER.")==0) anIt0 = StepDimTol_GTMMinorDiameter;
+        else if (strcmp(text, ".NOT_CONVEX.")==0) anIt0 = StepDimTol_GTMNotConvex;
+        else if (strcmp(text, ".PITCH_DIAMETER.")==0) anIt0 = StepDimTol_GTMPitchDiameter;
+        else if (strcmp(text, ".RECIPROCITY_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMReciprocityRequirement;
+        else if (strcmp(text, ".SEPARATE_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMSeparateRequirement;
+        else if (strcmp(text, ".STATISTICAL_TOLERANCE.")==0) anIt0 = StepDimTol_GTMStatisticalTolerance;
+        else if (strcmp(text, ".TANGENT_PLANE.")==0) anIt0 = StepDimTol_GTMTangentPlane;
+        else ach->AddFail("Parameter #5 (modifiers) has not allowed value");
+      }
+      else ach->AddFail("Parameter #5 (modifier) is not set of enumerations");
+      aModifiers->SetValue(i0, anIt0);
+    }
+  }
+  Handle(StepDimTol_GeometricToleranceWithModifiers) aGTWM = new StepDimTol_GeometricToleranceWithModifiers;
+  aGTWM->SetModifiers(aModifiers);
+
+  //Choose type of geometric tolerance
+  TColStd_SequenceOfAsciiString aTypes;
+  data->ComplexType(num0, aTypes);
+  Standard_CString aFirst = aTypes.First().ToCString();
+  Standard_CString aLast = aTypes.Last().ToCString();
+  StepDimTol_GeometricToleranceType aType = StepDimTol_GTTPositionTolerance;
+  if (strcmp(aFirst, "ANGULARITY_TOLERANCE") == 0) aType = StepDimTol_GTTAngularityTolerance;
+  else if (strcmp(aFirst, "CIRCULAR_RUNOUT_TOLERANCE") == 0) aType = StepDimTol_GTTCircularRunoutTolerance;
+  else if (strcmp(aFirst, "COAXIALITY_TOLERANCE") == 0) aType = StepDimTol_GTTCoaxialityTolerance;
+  else if (strcmp(aFirst, "CONCENTRICITY_TOLERANCE") == 0) aType = StepDimTol_GTTConcentricityTolerance;
+  else if (strcmp(aFirst, "CYLINDRICITY_TOLERANCE") == 0) aType = StepDimTol_GTTCylindricityTolerance;
+  else if (strcmp(aFirst, "FLATNESS_TOLERANCE") == 0) aType = StepDimTol_GTTFlatnessTolerance;
+  else if (strcmp(aLast, "LINE_PROFILE_TOLERANCE") == 0) aType = StepDimTol_GTTLineProfileTolerance;
+  else if (strcmp(aLast, "PARALLELISM_TOLERANCE") == 0) aType = StepDimTol_GTTParallelismTolerance;
+  else if (strcmp(aLast, "PERPENDICULARITY_TOLERANCE") == 0) aType = StepDimTol_GTTPerpendicularityTolerance;
+  else if (strcmp(aLast, "POSITION_TOLERANCE") == 0) aType = StepDimTol_GTTPositionTolerance;
+  else if (strcmp(aLast, "ROUNDNESS_TOLERANCE") == 0) aType = StepDimTol_GTTRoundnessTolerance;
+  else if (strcmp(aLast, "STRAIGHTNESS_TOLERANCE") == 0) aType = StepDimTol_GTTStraightnessTolerance;
+  else if (strcmp(aLast, "SURFACE_PROFILE_TOLERANCE") == 0) aType = StepDimTol_GTTSurfaceProfileTolerance;
+  else if (strcmp(aLast, "SYMMETRY_TOLERANCE") == 0) aType = StepDimTol_GTTSymmetryTolerance;
+  else if (strcmp(aLast, "TOTAL_RUNOUT_TOLERANCE") == 0) aType = StepDimTol_GTTTotalRunoutTolerance;
+  else ach->AddFail("The type of geometric tolerance is not supported");
+
+  // Initialize entity
+  ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, aGTWDR, aGTWM, aMaxTol, aType);
+
+}
+
+
+//=======================================================================
+//function : WriteStep
+//purpose  : 
+//=======================================================================
+
+void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::WriteStep
+  (StepData_StepWriter& SW,
+   const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)& ent) const
+{
+  StepDimTol_GeometricToleranceType aType = ent->GetToleranceType();
+  if (aType == StepDimTol_GTTAngularityTolerance)
+    SW.StartEntity("ANGULARITY_TOLERANCE");
+  else if (aType == StepDimTol_GTTCircularRunoutTolerance)
+    SW.StartEntity("CIRCULAR_RUNOUT_TOLERANCE");
+  else if (aType == StepDimTol_GTTCoaxialityTolerance)
+    SW.StartEntity("COAXIALITY_TOLERANCE");
+  else if (aType == StepDimTol_GTTConcentricityTolerance)
+    SW.StartEntity("CONCENTRICITY_TOLERANCE");
+  else if (aType == StepDimTol_GTTCylindricityTolerance)
+    SW.StartEntity("CYLINDRICITY_TOLERANCE");
+  else if (aType == StepDimTol_GTTFlatnessTolerance)
+    SW.StartEntity("FLATNESS_TOLERANCE");
+
+  SW.StartEntity("GEOMETRIC_TOLERANCE");
+  SW.Send(ent->Name());
+  SW.Send(ent->Description());
+  SW.Send(ent->Magnitude());
+  SW.Send(ent->TolerancedShapeAspect().Value());
+  SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_MAXIMUM_TOLERANCE");
+  SW.Send(ent->GetMaxTolerance());
+  SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_DATUM_REFERENCE");
+  SW.OpenSub();
+  for(Standard_Integer i4=1; i4<=ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Length(); i4++) {
+    StepDimTol_DatumSystemOrReference Var0 =
+      ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Value(i4);
+    SW.Send(Var0.Value());
+  }
+  SW.CloseSub();
+
+  SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_MODIFIERS");
+  SW.OpenSub();
+  Handle(StepDimTol_GeometricToleranceWithModifiers) aGTWM = ent->GetGeometricToleranceWithModifiers();
+  for (Standard_Integer i = 1;  i <= aGTWM->NbModifiers();  i++) {
+    switch (aGTWM->ModifierValue(i)) {
+      case StepDimTol_GTMAnyCrossSection: SW.SendEnum (".ANY_CROSS_SECTION."); break;
+      case StepDimTol_GTMCommonZone: SW.SendEnum (".COMMON_ZONE."); break;
+      case StepDimTol_GTMEachRadialElement: SW.SendEnum (".EACH_RADIAL_ELEMENT."); break;
+      case StepDimTol_GTMFreeState: SW.SendEnum (".FREE_STATE."); break;
+      case StepDimTol_GTMLeastMaterialRequirement: SW.SendEnum (".LEAST_MATERIAL_REQUIREMENT."); break;
+      case StepDimTol_GTMLineElement: SW.SendEnum (".LINE_ELEMENT."); break;
+      case StepDimTol_GTMMajorDiameter: SW.SendEnum (".MAJOR_DIAMETER."); break;
+      case StepDimTol_GTMMaximumMaterialRequirement: SW.SendEnum (".MAXIMUM_MATERIAL_REQUIREMENT."); break;
+      case StepDimTol_GTMMinorDiameter: SW.SendEnum (".MINOR_DIAMETER."); break;
+      case StepDimTol_GTMNotConvex: SW.SendEnum (".NOT_CONVEX."); break;
+      case StepDimTol_GTMPitchDiameter: SW.SendEnum (".PITCH_DIAMETER."); break;
+      case StepDimTol_GTMReciprocityRequirement: SW.SendEnum (".RECIPROCITY_REQUIREMENT."); break;
+      case StepDimTol_GTMSeparateRequirement: SW.SendEnum (".SEPARATE_REQUIREMENT."); break;
+      case StepDimTol_GTMStatisticalTolerance: SW.SendEnum (".STATISTICAL_TOLERANCE."); break;
+      case StepDimTol_GTMTangentPlane: SW.SendEnum (".TANGENT_PLANE."); break;
+    }
+  }
+  SW.CloseSub();
+
+  if (aType == StepDimTol_GTTLineProfileTolerance)
+    SW.StartEntity("LINE_PROFILE_TOLERANCE");
+  else if (aType == StepDimTol_GTTParallelismTolerance)
+    SW.StartEntity("PARALLELISM_TOLERANCE");
+  else if (aType == StepDimTol_GTTPerpendicularityTolerance)
+    SW.StartEntity("PERPENDICULARITY_TOLERANCE");
+  else if (aType == StepDimTol_GTTPositionTolerance)
+    SW.StartEntity("POSITION_TOLERANCE");
+  else if (aType == StepDimTol_GTTRoundnessTolerance)
+    SW.StartEntity("ROUNDNESS_TOLERANCE");
+  else if (aType == StepDimTol_GTTStraightnessTolerance)
+    SW.StartEntity("STRAIGHTNESS_TOLERANCE");
+  else if (aType == StepDimTol_GTTSurfaceProfileTolerance)
+    SW.StartEntity("SURFACE_PROFILE_TOLERANCE");
+  else if (aType == StepDimTol_GTTSymmetryTolerance)
+    SW.StartEntity("SYMMETRY_TOLERANCE");
+  else if (aType == StepDimTol_GTTTotalRunoutTolerance)
+    SW.StartEntity("TOTAL_RUNOUT_TOLERANCE");
+}
+
+
+//=======================================================================
+//function : Share
+//purpose  : 
+//=======================================================================
+
+void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::Share
+  (const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)& ent,
+   Interface_EntityIterator& iter) const
+{
+  // Own fields of GeometricTolerance
+  iter.AddItem (ent->Magnitude());
+  iter.AddItem (ent->TolerancedShapeAspect().Value());
+  // Own fields of GeometricToleranceWithDatumReference
+  for (Standard_Integer i3=1; i3<=ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Length(); i3++ ) {
+    StepDimTol_DatumSystemOrReference Var0 = ent->GetGeometricToleranceWithDatumReference()->DatumSystemAP242()->Value(i3);
+    iter.AddItem (Var0.Value());
+  }
+}
diff --git a/src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx b/src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx
new file mode 100644 (file)
index 0000000..228879a
--- /dev/null
@@ -0,0 +1,47 @@
+// Created on: 2015-11-13
+// Created by: Irina KRYLOVA
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol_HeaderFile
+#define _RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Handle.hxx>
+
+#include <Standard_Integer.hxx>
+class StepData_StepReaderData;
+class Interface_Check;
+class StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol;
+class StepData_StepWriter;
+class Interface_EntityIterator;
+
+
+//! Read & Write Module for GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol
+class RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol
+{
+public:
+
+  DEFINE_STANDARD_ALLOC
+
+  
+  Standard_EXPORT RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol();
+  
+  Standard_EXPORT void ReadStep (const Handle(StepData_StepReaderData)& data, const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)& ent) const;
+  
+  Standard_EXPORT void WriteStep (StepData_StepWriter& SW, const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)& ent) const;
+  
+  Standard_EXPORT void Share (const Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)& ent, Interface_EntityIterator& iter) const;
+};
+#endif // _RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol_HeaderFile
index d9ee750..82fd6d2 100644 (file)
@@ -181,6 +181,30 @@ void RWStepDimTol_RWGeoTolAndGeoTolWthDatRefAndGeoTolWthMod::WriteStep
   }
   SW.CloseSub();
 
+  SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_MODIFIERS");
+  SW.OpenSub();
+  Handle(StepDimTol_GeometricToleranceWithModifiers) aGTWM = ent->GetGeometricToleranceWithModifiers();
+  for (Standard_Integer i = 1;  i <= aGTWM->NbModifiers();  i++) {
+    switch (aGTWM->ModifierValue(i)) {
+      case StepDimTol_GTMAnyCrossSection: SW.SendEnum (".ANY_CROSS_SECTION."); break;
+      case StepDimTol_GTMCommonZone: SW.SendEnum (".COMMON_ZONE."); break;
+      case StepDimTol_GTMEachRadialElement: SW.SendEnum (".EACH_RADIAL_ELEMENT."); break;
+      case StepDimTol_GTMFreeState: SW.SendEnum (".FREE_STATE."); break;
+      case StepDimTol_GTMLeastMaterialRequirement: SW.SendEnum (".LEAST_MATERIAL_REQUIREMENT."); break;
+      case StepDimTol_GTMLineElement: SW.SendEnum (".LINE_ELEMENT."); break;
+      case StepDimTol_GTMMajorDiameter: SW.SendEnum (".MAJOR_DIAMETER."); break;
+      case StepDimTol_GTMMaximumMaterialRequirement: SW.SendEnum (".MAXIMUM_MATERIAL_REQUIREMENT."); break;
+      case StepDimTol_GTMMinorDiameter: SW.SendEnum (".MINOR_DIAMETER."); break;
+      case StepDimTol_GTMNotConvex: SW.SendEnum (".NOT_CONVEX."); break;
+      case StepDimTol_GTMPitchDiameter: SW.SendEnum (".PITCH_DIAMETER."); break;
+      case StepDimTol_GTMReciprocityRequirement: SW.SendEnum (".RECIPROCITY_REQUIREMENT."); break;
+      case StepDimTol_GTMSeparateRequirement: SW.SendEnum (".SEPARATE_REQUIREMENT."); break;
+      case StepDimTol_GTMStatisticalTolerance: SW.SendEnum (".STATISTICAL_TOLERANCE."); break;
+      case StepDimTol_GTMTangentPlane: SW.SendEnum (".TANGENT_PLANE."); break;
+    }
+  }
+  SW.CloseSub();
+
   if (aType == StepDimTol_GTTLineProfileTolerance)
     SW.StartEntity("LINE_PROFILE_TOLERANCE");
   else if (aType == StepDimTol_GTTParallelismTolerance)
diff --git a/src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.cxx b/src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.cxx
new file mode 100644 (file)
index 0000000..656730c
--- /dev/null
@@ -0,0 +1,216 @@
+// Created on: 2015-08-10
+// Created by: Irina KRYLOVA
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <Interface_Check.hxx>
+#include <Interface_EntityIterator.hxx>
+#include <RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.hxx>
+#include <StepBasic_LengthMeasureWithUnit.hxx>
+#include <StepBasic_MeasureWithUnit.hxx>
+#include <StepData_StepReaderData.hxx>
+#include <StepData_StepWriter.hxx>
+#include <StepDimTol_GeometricToleranceTarget.hxx>
+#include <StepDimTol_GeometricToleranceType.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx>
+#include <StepDimTol_GeometricToleranceWithModifiers.hxx>
+
+//=======================================================================
+//function : RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol
+//purpose  : 
+//=======================================================================
+RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol()
+{
+}
+
+
+//=======================================================================
+//function : ReadStep
+//purpose  : 
+//=======================================================================
+
+void RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::ReadStep
+  (const Handle(StepData_StepReaderData)& data,
+   const Standard_Integer num0, Handle(Interface_Check)& ach,
+   const Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)& ent) const
+{
+  Standard_Integer num = 0;//num0;
+  data->NamedForComplex("GEOMETRIC_TOLERANCE","GMTTLR",num0,num,ach);
+  if (!data->CheckNbParams(num,4,ach,"geometric_tolerance")) return;
+  // Own fields of GeometricTolerance
+  Handle(TCollection_HAsciiString) aName;
+  data->ReadString (num, 1, "name", ach, aName);
+  Handle(TCollection_HAsciiString) aDescription;
+  data->ReadString (num, 2, "description", ach, aDescription);
+  Handle(StepBasic_MeasureWithUnit) aMagnitude;
+  data->ReadEntity (num, 3, "magnitude", ach, STANDARD_TYPE(StepBasic_MeasureWithUnit), aMagnitude);
+  StepDimTol_GeometricToleranceTarget aTolerancedShapeAspect;
+  data->ReadEntity (num, 4, "toleranced_shape_aspect", ach, aTolerancedShapeAspect);
+  
+  data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_MAXIMUM_TOLERANCE",num0,num,ach);
+  Handle(StepBasic_LengthMeasureWithUnit) aMaxTol;
+  data->ReadEntity (num, 1, "maximum_upper_tolerance", ach, STANDARD_TYPE(StepBasic_LengthMeasureWithUnit), aMaxTol);
+
+  data->NamedForComplex("GEOMETRIC_TOLERANCE_WITH_MODIFIERS",num0,num,ach);
+  // Own fields of ModifiedGeometricTolerance
+  Handle(StepDimTol_HArray1OfGeometricToleranceModifier) aModifiers;
+  Standard_Integer sub = 0;
+  if ( data->ReadSubList (num, 1, "modifiers", ach, sub) ) {
+    Standard_Integer nb0 = data->NbParams(sub);
+    aModifiers = new StepDimTol_HArray1OfGeometricToleranceModifier (1, nb0);
+    Standard_Integer num2 = sub;
+    for ( Standard_Integer i0=1; i0 <= nb0; i0++ ) {
+      StepDimTol_GeometricToleranceModifier anIt0 = StepDimTol_GTMMaximumMaterialRequirement;
+      if (data->ParamType (num2, i0) == Interface_ParamEnum) {
+        Standard_CString text = data->ParamCValue(num2, i0);
+        if      (strcmp(text, ".ANY_CROSS_SECTION.")==0) anIt0 = StepDimTol_GTMAnyCrossSection;
+        else if (strcmp(text, ".COMMON_ZONE.")==0) anIt0 = StepDimTol_GTMCommonZone;
+        else if (strcmp(text, ".EACH_RADIAL_ELEMENT.")==0) anIt0 = StepDimTol_GTMEachRadialElement;
+        else if (strcmp(text, ".FREE_STATE.")==0) anIt0 = StepDimTol_GTMFreeState;
+        else if (strcmp(text, ".LEAST_MATERIAL_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMLeastMaterialRequirement;
+        else if (strcmp(text, ".LINE_ELEMENT.")==0) anIt0 = StepDimTol_GTMLineElement;
+        else if (strcmp(text, ".MAJOR_DIAMETER.")==0) anIt0 = StepDimTol_GTMMajorDiameter;
+        else if (strcmp(text, ".MAXIMUM_MATERIAL_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMMaximumMaterialRequirement;
+        else if (strcmp(text, ".MINOR_DIAMETER.")==0) anIt0 = StepDimTol_GTMMinorDiameter;
+        else if (strcmp(text, ".NOT_CONVEX.")==0) anIt0 = StepDimTol_GTMNotConvex;
+        else if (strcmp(text, ".PITCH_DIAMETER.")==0) anIt0 = StepDimTol_GTMPitchDiameter;
+        else if (strcmp(text, ".RECIPROCITY_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMReciprocityRequirement;
+        else if (strcmp(text, ".SEPARATE_REQUIREMENT.")==0) anIt0 = StepDimTol_GTMSeparateRequirement;
+        else if (strcmp(text, ".STATISTICAL_TOLERANCE.")==0) anIt0 = StepDimTol_GTMStatisticalTolerance;
+        else if (strcmp(text, ".TANGENT_PLANE.")==0) anIt0 = StepDimTol_GTMTangentPlane;
+        else ach->AddFail("Parameter #5 (modifiers) has not allowed value");
+      }
+      else ach->AddFail("Parameter #5 (modifier) is not set of enumerations");
+      aModifiers->SetValue(i0, anIt0);
+    }
+  }
+  Handle(StepDimTol_GeometricToleranceWithModifiers) aGTWM = new StepDimTol_GeometricToleranceWithModifiers;
+  aGTWM->SetModifiers(aModifiers);
+
+  //Choose type of geometric tolerance
+  TColStd_SequenceOfAsciiString aTypes;
+  data->ComplexType(num0, aTypes);
+  Standard_CString aFirst = aTypes.First().ToCString();
+  Standard_CString aLast = aTypes.Last().ToCString();
+  StepDimTol_GeometricToleranceType aType = StepDimTol_GTTPositionTolerance;
+  if (strcmp(aFirst, "ANGULARITY_TOLERANCE") == 0) aType = StepDimTol_GTTAngularityTolerance;
+  else if (strcmp(aFirst, "CIRCULAR_RUNOUT_TOLERANCE") == 0) aType = StepDimTol_GTTCircularRunoutTolerance;
+  else if (strcmp(aFirst, "COAXIALITY_TOLERANCE") == 0) aType = StepDimTol_GTTCoaxialityTolerance;
+  else if (strcmp(aFirst, "CONCENTRICITY_TOLERANCE") == 0) aType = StepDimTol_GTTConcentricityTolerance;
+  else if (strcmp(aFirst, "CYLINDRICITY_TOLERANCE") == 0) aType = StepDimTol_GTTCylindricityTolerance;
+  else if (strcmp(aFirst, "FLATNESS_TOLERANCE") == 0) aType = StepDimTol_GTTFlatnessTolerance;
+  else if (strcmp(aLast, "LINE_PROFILE_TOLERANCE") == 0) aType = StepDimTol_GTTLineProfileTolerance;
+  else if (strcmp(aLast, "PARALLELISM_TOLERANCE") == 0) aType = StepDimTol_GTTParallelismTolerance;
+  else if (strcmp(aLast, "PERPENDICULARITY_TOLERANCE") == 0) aType = StepDimTol_GTTPerpendicularityTolerance;
+  else if (strcmp(aLast, "POSITION_TOLERANCE") == 0) aType = StepDimTol_GTTPositionTolerance;
+  else if (strcmp(aLast, "ROUNDNESS_TOLERANCE") == 0) aType = StepDimTol_GTTRoundnessTolerance;
+  else if (strcmp(aLast, "STRAIGHTNESS_TOLERANCE") == 0) aType = StepDimTol_GTTStraightnessTolerance;
+  else if (strcmp(aLast, "SURFACE_PROFILE_TOLERANCE") == 0) aType = StepDimTol_GTTSurfaceProfileTolerance;
+  else if (strcmp(aLast, "SYMMETRY_TOLERANCE") == 0) aType = StepDimTol_GTTSymmetryTolerance;
+  else if (strcmp(aLast, "TOTAL_RUNOUT_TOLERANCE") == 0) aType = StepDimTol_GTTTotalRunoutTolerance;
+  else ach->AddFail("The type of geometric tolerance is not supported");
+
+  // Initialize entity
+  ent->Init(aName, aDescription, aMagnitude, aTolerancedShapeAspect, aGTWM, aMaxTol, aType);
+
+}
+
+
+//=======================================================================
+//function : WriteStep
+//purpose  : 
+//=======================================================================
+
+void RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::WriteStep
+  (StepData_StepWriter& SW,
+   const Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)& ent) const
+{
+  StepDimTol_GeometricToleranceType aType = ent->GetToleranceType();
+  if (aType == StepDimTol_GTTAngularityTolerance)
+    SW.StartEntity("ANGULARITY_TOLERANCE");
+  else if (aType == StepDimTol_GTTCircularRunoutTolerance)
+    SW.StartEntity("CIRCULAR_RUNOUT_TOLERANCE");
+  else if (aType == StepDimTol_GTTCoaxialityTolerance)
+    SW.StartEntity("COAXIALITY_TOLERANCE");
+  else if (aType == StepDimTol_GTTConcentricityTolerance)
+    SW.StartEntity("CONCENTRICITY_TOLERANCE");
+  else if (aType == StepDimTol_GTTCylindricityTolerance)
+    SW.StartEntity("CYLINDRICITY_TOLERANCE");
+  else if (aType == StepDimTol_GTTFlatnessTolerance)
+    SW.StartEntity("FLATNESS_TOLERANCE");
+
+  SW.StartEntity("GEOMETRIC_TOLERANCE");
+  SW.Send(ent->Name());
+  SW.Send(ent->Description());
+  SW.Send(ent->Magnitude());
+  SW.Send(ent->TolerancedShapeAspect().Value());
+  SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_MAXIMUM_TOLERANCE");
+  SW.Send(ent->GetMaxTolerance());
+  SW.StartEntity("GEOMETRIC_TOLERANCE_WITH_MODIFIERS");
+  SW.OpenSub();
+  Handle(StepDimTol_GeometricToleranceWithModifiers) aGTWM = ent->GetGeometricToleranceWithModifiers();
+  for (Standard_Integer i = 1;  i <= aGTWM->NbModifiers();  i++) {
+    switch (aGTWM->ModifierValue(i)) {
+      case StepDimTol_GTMAnyCrossSection: SW.SendEnum (".ANY_CROSS_SECTION."); break;
+      case StepDimTol_GTMCommonZone: SW.SendEnum (".COMMON_ZONE."); break;
+      case StepDimTol_GTMEachRadialElement: SW.SendEnum (".EACH_RADIAL_ELEMENT."); break;
+      case StepDimTol_GTMFreeState: SW.SendEnum (".FREE_STATE."); break;
+      case StepDimTol_GTMLeastMaterialRequirement: SW.SendEnum (".LEAST_MATERIAL_REQUIREMENT."); break;
+      case StepDimTol_GTMLineElement: SW.SendEnum (".LINE_ELEMENT."); break;
+      case StepDimTol_GTMMajorDiameter: SW.SendEnum (".MAJOR_DIAMETER."); break;
+      case StepDimTol_GTMMaximumMaterialRequirement: SW.SendEnum (".MAXIMUM_MATERIAL_REQUIREMENT."); break;
+      case StepDimTol_GTMMinorDiameter: SW.SendEnum (".MINOR_DIAMETER."); break;
+      case StepDimTol_GTMNotConvex: SW.SendEnum (".NOT_CONVEX."); break;
+      case StepDimTol_GTMPitchDiameter: SW.SendEnum (".PITCH_DIAMETER."); break;
+      case StepDimTol_GTMReciprocityRequirement: SW.SendEnum (".RECIPROCITY_REQUIREMENT."); break;
+      case StepDimTol_GTMSeparateRequirement: SW.SendEnum (".SEPARATE_REQUIREMENT."); break;
+      case StepDimTol_GTMStatisticalTolerance: SW.SendEnum (".STATISTICAL_TOLERANCE."); break;
+      case StepDimTol_GTMTangentPlane: SW.SendEnum (".TANGENT_PLANE."); break;
+    }
+  }
+  SW.CloseSub();
+  if (aType == StepDimTol_GTTLineProfileTolerance)
+    SW.StartEntity("LINE_PROFILE_TOLERANCE");
+  else if (aType == StepDimTol_GTTParallelismTolerance)
+    SW.StartEntity("PARALLELISM_TOLERANCE");
+  else if (aType == StepDimTol_GTTPerpendicularityTolerance)
+    SW.StartEntity("PERPENDICULARITY_TOLERANCE");
+  else if (aType == StepDimTol_GTTPositionTolerance)
+    SW.StartEntity("POSITION_TOLERANCE");
+  else if (aType == StepDimTol_GTTRoundnessTolerance)
+    SW.StartEntity("ROUNDNESS_TOLERANCE");
+  else if (aType == StepDimTol_GTTStraightnessTolerance)
+    SW.StartEntity("STRAIGHTNESS_TOLERANCE");
+  else if (aType == StepDimTol_GTTSurfaceProfileTolerance)
+    SW.StartEntity("SURFACE_PROFILE_TOLERANCE");
+  else if (aType == StepDimTol_GTTSymmetryTolerance)
+    SW.StartEntity("SYMMETRY_TOLERANCE");
+  else if (aType == StepDimTol_GTTTotalRunoutTolerance)
+    SW.StartEntity("TOTAL_RUNOUT_TOLERANCE");
+}
+
+
+//=======================================================================
+//function : Share
+//purpose  : 
+//=======================================================================
+
+void RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol::Share
+  (const Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)& ent,
+   Interface_EntityIterator& iter) const
+{
+  // Own fields of GeometricTolerance
+  iter.AddItem (ent->Magnitude());
+  iter.AddItem (ent->TolerancedShapeAspect().Value());
+}
diff --git a/src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.hxx b/src/RWStepDimTol/RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol.hxx
new file mode 100644 (file)
index 0000000..9826f9e
--- /dev/null
@@ -0,0 +1,47 @@
+// Created on: 2015-11-13
+// Created by: Irina KRYLOVA
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol_HeaderFile
+#define _RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Handle.hxx>
+
+#include <Standard_Integer.hxx>
+class StepData_StepReaderData;
+class Interface_Check;
+class StepDimTol_GeoTolAndGeoTolWthMaxTol;
+class StepData_StepWriter;
+class Interface_EntityIterator;
+
+
+//! Read & Write Module for GeoTolAndGeoTolWthMaxTol
+class RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol
+{
+public:
+
+  DEFINE_STANDARD_ALLOC
+
+  
+  Standard_EXPORT RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol();
+  
+  Standard_EXPORT void ReadStep (const Handle(StepData_StepReaderData)& data, const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)& ent) const;
+  
+  Standard_EXPORT void WriteStep (StepData_StepWriter& SW, const Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)& ent) const;
+  
+  Standard_EXPORT void Share (const Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)& ent, Interface_EntityIterator& iter) const;
+};
+#endif // _RWStepDimTol_RWGeoTolAndGeoTolWthMaxTol_HeaderFile
index 21eb2d2..dd6b9a2 100644 (file)
@@ -73,6 +73,9 @@
 #include <StepDimTol_GeometricToleranceWithDatumReference.hxx>
 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx>
 #include <StepDimTol_GeoTolAndGeoTolWthDatRef.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx>
 #include <StepDimTol_HArray1OfDatumReference.hxx>
 #include <StepDimTol_LineProfileTolerance.hxx>
 #include <StepDimTol_ModifiedGeometricTolerance.hxx>
@@ -1808,17 +1811,17 @@ static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat,
     else if(aSA->IsKind(STANDARD_TYPE(StepDimTol_PlacedDatumTargetFeature)))
     {
       //processing for datum target
-      Interface_EntityIterator anIterDTF = aGraph.Shareds(aSA);
+      Interface_EntityIterator anIterDTF = aGraph.Sharings(aSA);
       for(anIterDTF.Start(); anIterDTF.More(); anIterDTF.Next()) {
         if(anIterDTF.Value()->IsKind(STANDARD_TYPE(StepRepr_FeatureForDatumTargetRelationship)))
         {
-          Interface_EntityIterator anIterFFD = aGraph.Shareds(anIterDTF.Value());
-          for(anIterFFD.Start(); anIterFFD.More(); anIterFFD.Next()) {
-            if(anIterFFD.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect)))
-            {
-              aSA = Handle(StepRepr_ShapeAspect)::DownCast(anIterFFD.Value());
-            }
-          }
+          Handle(StepRepr_FeatureForDatumTargetRelationship) aFFDTR =
+            Handle(StepRepr_FeatureForDatumTargetRelationship)::DownCast(anIterDTF.Value());
+          Handle(StepRepr_ShapeAspect) aTmpSA = aFFDTR->RelatedShapeAspect();
+          Interface_EntityIterator anIterDSWP = aGraph.Sharings(aTmpSA);
+          for(anIterDSWP.Start(); anIterDSWP.More() && aPGISU.IsNull(); anIterDSWP.Next()) {
+            aPGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value());
+    }
         }
       }
     }
@@ -1862,6 +1865,17 @@ static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat,
         aDGTTool->SetDatum(aShL, aDatL);
         aDatObj = aDat->GetObject();
         aDatObj->SetName(theDat->Identification());
+        aDatObj->SetPosition (thePositionCounter);
+        if(!aXCAFModifiers.IsEmpty())
+          aDatObj->SetModifiers(aXCAFModifiers);
+        if (aXCAFModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None) 
+          aDatObj->SetModifierWithValue(aXCAFModifWithVal, aModifValue);
+        aDGTTool->SetDatumToGeomTol(aDatL, theGDTL);
+        Handle(StepDimTol_PlacedDatumTargetFeature) aPDTF = Handle(StepDimTol_PlacedDatumTargetFeature)::DownCast(aSA);
+        if (aPDTF->TargetId()->IsIntegerValue())
+          aDatObj->SetDatumTargetNumber(aPDTF->TargetId()->IntegerValue());
+        else
+          aDatObj->SetDatumTargetNumber(0);
         aDatObj->IsDatumTarget(Standard_True);
         XCAFDimTolObjects_DatumTargetType aType;
         if(STEPConstruct_GDTProperty::GetDatumTargetType(aSA->Description(),aType))
@@ -2958,7 +2972,37 @@ static Standard_Boolean getTolType(const Handle(Standard_Transient)& theEnt,
   if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRef)))
   {
     Handle(StepDimTol_GeoTolAndGeoTolWthDatRef) anE = Handle(StepDimTol_GeoTolAndGeoTolWthDatRef)::DownCast(theEnt);
-    theType = (XCAFDimTolObjects_GeomToleranceType)anE->GetToleranceType();
+    theType = STEPConstruct_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
+  }
+  else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)))
+  {
+    Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol) anE = 
+      Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)::DownCast(theEnt);
+    theType = STEPConstruct_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
+  }
+  else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)))
+  {
+    Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod) anE = 
+      Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)::DownCast(theEnt);
+    theType = STEPConstruct_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
+  }
+  else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMaxTol)))
+  {
+    Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol) anE = 
+      Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)::DownCast(theEnt);
+    theType = STEPConstruct_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
+  }
+  else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMod)))
+  {
+    Handle(StepDimTol_GeoTolAndGeoTolWthMod) anE = 
+      Handle(StepDimTol_GeoTolAndGeoTolWthMod)::DownCast(theEnt);
+    theType = STEPConstruct_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
+  }
+  else if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol)))
+  {
+    Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol) anE = 
+      Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol)::DownCast(theEnt);
+    theType = STEPConstruct_GDTProperty::GetGeomToleranceType(anE->GetToleranceType());
   }
   else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_AngularityTolerance)))
   {
@@ -3084,6 +3128,7 @@ static void setGeomTolObjectToXCAF(const Handle(Standard_Transient)& theEnt,
             if(GetLengthConversionFactor(NU,aFact))
               aVal=aVal*aFact;
             aTolObj->SetValueOfZoneModifier(aVal);
+            aTolObj->SetZoneModifier(XCAFDimTolObjects_GeomToleranceZoneModif_Projected);
           }
         }
         else if (anIt.Value()->IsKind(STANDARD_TYPE(StepDimTol_RunoutZoneDefinition)))
@@ -3100,6 +3145,7 @@ static void setGeomTolObjectToXCAF(const Handle(Standard_Transient)& theEnt,
             Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
             if(GetAngleConversionFactor(NU,aFact)) aVal=aVal*aFact;
             aTolObj->SetValueOfZoneModifier(aVal);
+            aTolObj->SetZoneModifier(XCAFDimTolObjects_GeomToleranceZoneModif_Runout);
           }
         }
       }
@@ -3121,6 +3167,16 @@ static void setGeomTolObjectToXCAF(const Handle(Standard_Transient)& theEnt,
     aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthMod)
                              ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
   }
+  else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMaxTol)))
+  {
+    aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)
+                             ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
+  }
+  else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)))
+  {
+    aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)
+                             ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
+  }
   if(!aModifiers.IsNull())
   {
     for(Standard_Integer i = aModifiers->Lower(); i <= aModifiers->Upper(); i++)
@@ -3133,14 +3189,31 @@ static void setGeomTolObjectToXCAF(const Handle(Standard_Transient)& theEnt,
         aTolObj->AddModifier((XCAFDimTolObjects_GeomToleranceModif)aModifiers->Value(i));
     }
   }
+  Standard_Real aVal = 0;
+  StepBasic_Unit anUnit;
   if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricToleranceWithMaximumTolerance)))
   {
     Handle(StepDimTol_GeometricToleranceWithMaximumTolerance) aMax = Handle(StepDimTol_GeometricToleranceWithMaximumTolerance)::DownCast(aTolEnt);
-    Standard_Real aVal = aMax->MaximumUpperTolerance()->ValueComponent();
-    StepBasic_Unit anUnit = aMax->MaximumUpperTolerance()->UnitComponent();
+    aVal = aMax->MaximumUpperTolerance()->ValueComponent();
+    anUnit = aMax->MaximumUpperTolerance()->UnitComponent();
+  }
+  else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMaxTol)))
+  {
+    Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol) aMax = 
+      Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol)::DownCast(aTolEnt);
+    aVal = aMax->GetMaxTolerance()->ValueComponent();
+    anUnit = aMax->GetMaxTolerance()->UnitComponent();
+  }
+  else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)))
+  {
+    Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol) aMax = 
+      Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol)::DownCast(aTolEnt);
+    aVal = aMax->GetMaxTolerance()->ValueComponent();
+    anUnit = aMax->GetMaxTolerance()->UnitComponent();
+  }
+  if (!anUnit.IsNull() && (anUnit.CaseNum(anUnit.Value()) == 1))
+  {
     Standard_Real aFact=1.;
-    if(anUnit.IsNull()) return;
-    if( !(anUnit.CaseNum(anUnit.Value())==1) ) return;
     Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
     if(GetAngleConversionFactor(NU,aFact)) aVal=aVal*aFact;
     aTolObj->SetMaxValueModifier(aVal);
index f5e8ecd..ea42d09 100644 (file)
@@ -29,6 +29,7 @@
 #include <OSD_Path.hxx>
 #include <Quantity_TypeOfColor.hxx>
 #include <StepAP214_Protocol.hxx>
+#include <StepAP242_GeometricItemSpecificUsage.hxx>
 #include <StepBasic_DerivedUnit.hxx>
 #include <StepBasic_DerivedUnitElement.hxx>
 #include <StepBasic_HArray1OfDerivedUnitElement.hxx>
@@ -40,6 +41,7 @@
 #include <StepBasic_ProductDefinitionRelationship.hxx>
 #include <StepBasic_SiUnitAndLengthUnit.hxx>
 #include <StepBasic_SiUnitAndMassUnit.hxx>
+#include <StepBasic_SiUnitAndPlaneAngleUnit.hxx>
 #include <STEPCAFControl_ActorWrite.hxx>
 #include <STEPCAFControl_Controller.hxx>
 #include <STEPCAFControl_DictionaryOfExternFile.hxx>
@@ -50,6 +52,7 @@
 #include <STEPConstruct_DataMapOfAsciiStringTransient.hxx>
 #include <STEPConstruct_DataMapOfPointTransient.hxx>
 #include <STEPConstruct_ExternRefs.hxx>
+#include <STEPConstruct_GDTProperty.hxx>
 #include <STEPConstruct_Styles.hxx>
 #include <STEPConstruct_ValidationProps.hxx>
 #include <STEPControl_StepModelType.hxx>
 #include <StepDimTol_Datum.hxx>
 #include <StepDimTol_DatumFeature.hxx>
 #include <StepDimTol_DatumReference.hxx>
+#include <StepDimTol_DatumReferenceElement.hxx>
+#include <StepDimTol_DatumSystem.hxx>
+#include <StepDimTol_DatumSystemOrReference.hxx>
+#include <StepDimTol_DatumTarget.hxx>
 #include <StepDimTol_FlatnessTolerance.hxx>
+#include <StepDimTol_GeometricToleranceType.hxx>
 #include <StepDimTol_GeometricToleranceWithDatumReference.hxx>
+#include <StepDimTol_GeometricToleranceWithModifiers.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthDatRef.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod.hxx>
 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthMod.hxx>
 #include <StepDimTol_HArray1OfDatumReference.hxx>
+#include <StepDimTol_HArray1OfDatumReferenceElement.hxx>
+#include <StepDimTol_HArray1OfDatumReferenceModifier.hxx>
+#include <StepDimTol_HArray1OfDatumSystemOrReference.hxx>
 #include <StepDimTol_LineProfileTolerance.hxx>
 #include <StepDimTol_ModifiedGeometricTolerance.hxx>
 #include <StepDimTol_ParallelismTolerance.hxx>
 #include <StepDimTol_PerpendicularityTolerance.hxx>
+#include <StepDimTol_PlacedDatumTargetFeature.hxx>
 #include <StepDimTol_PositionTolerance.hxx>
 #include <StepDimTol_RoundnessTolerance.hxx>
+#include <StepDimTol_RunoutZoneDefinition.hxx>
+#include <StepDimTol_RunoutZoneOrientation.hxx>
 #include <StepDimTol_StraightnessTolerance.hxx>
 #include <StepDimTol_SurfaceProfileTolerance.hxx>
 #include <StepDimTol_SymmetryTolerance.hxx>
+#include <StepDimTol_ToleranceZone.hxx>
+#include <StepDimTol_ToleranceZoneForm.hxx>
 #include <StepDimTol_TotalRunoutTolerance.hxx>
+#include <StepGeom_Axis2Placement3d.hxx>
+#include <StepGeom_CartesianPoint.hxx>
+#include <StepGeom_Direction.hxx>
 #include <StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext.hxx>
 #include <StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx.hxx>
 #include <StepGeom_Surface.hxx>
+#include <StepRepr_CompGroupShAspAndCompShAspAndDatumFeatAndShAsp.hxx>
+#include <StepRepr_CompositeShapeAspect.hxx>
 #include <StepRepr_DescriptiveRepresentationItem.hxx>
+#include <StepRepr_FeatureForDatumTargetRelationship.hxx>
 #include <StepRepr_HArray1OfRepresentationItem.hxx>
 #include <StepRepr_MeasureRepresentationItem.hxx>
 #include <StepRepr_NextAssemblyUsageOccurrence.hxx>
 #include <StepRepr_ProductDefinitionShape.hxx>
 #include <StepRepr_PropertyDefinition.hxx>
+#include <StepRepr_RepresentedDefinition.hxx>
 #include <StepRepr_Representation.hxx>
 #include <StepRepr_RepresentationItem.hxx>
 #include <StepRepr_ReprItemAndLengthMeasureWithUnit.hxx>
+#include <StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI.hxx>
+#include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnit.hxx>
+#include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI.hxx>
 #include <StepRepr_ShapeAspect.hxx>
 #include <StepRepr_ShapeAspectRelationship.hxx>
 #include <StepRepr_SpecifiedHigherUsageOccurrence.hxx>
 #include <StepRepr_ValueRange.hxx>
 #include <StepShape_AdvancedFace.hxx>
+#include <StepShape_AngleRelator.hxx>
+#include <StepShape_AngularLocation.hxx>
+#include <StepShape_AngularSize.hxx>
 #include <StepShape_ConnectedFaceSet.hxx>
 #include <StepShape_ContextDependentShapeRepresentation.hxx>
+#include <StepShape_DimensionalCharacteristic.hxx>
 #include <StepShape_DimensionalCharacteristicRepresentation.hxx>
+#include <StepShape_DimensionalLocation.hxx>
+#include <StepShape_DimensionalLocationWithPath.hxx>
 #include <StepShape_DimensionalSize.hxx>
+#include <StepShape_DimensionalSizeWithPath.hxx>
 #include <StepShape_EdgeCurve.hxx>
 #include <StepShape_EdgeLoop.hxx>
 #include <StepShape_FaceBound.hxx>
+#include <StepShape_LimitsAndFits.hxx>
 #include <StepShape_OrientedEdge.hxx>
+#include <StepShape_PlusMinusTolerance.hxx>
+#include <StepShape_QualifiedRepresentationItem.hxx>
 #include <StepShape_ShapeDefinitionRepresentation.hxx>
 #include <StepShape_ShapeDimensionRepresentation.hxx>
 #include <StepShape_ShapeRepresentation.hxx>
+#include <StepShape_ShapeRepresentationWithParameters.hxx>
+#include <StepShape_ToleranceValue.hxx>
+#include <StepShape_TypeQualifier.hxx>
+#include <StepShape_ValueFormatTypeQualifier.hxx>
 #include <StepVisual_CurveStyle.hxx>
 #include <StepVisual_HArray1OfInvisibleItem.hxx>
 #include <StepVisual_HArray1OfLayeredItem.hxx>
 #include <TColStd_HArray1OfReal.hxx>
 #include <TColStd_HArray1OfTransient.hxx>
 #include <TColStd_HSequenceOfTransient.hxx>
+#include <TColStd_MapOfAsciiString.hxx>
 #include <TColStd_MapOfTransient.hxx>
 #include <TDataStd_Name.hxx>
 #include <TDataStd_TreeNode.hxx>
 #include <Transfer_TransientListBinder.hxx>
 #include <TransferBRep.hxx>
 #include <TransferBRep_ShapeMapper.hxx>
+#include <XCAFDimTolObjects_DatumObject.hxx>
+#include <XCAFDimTolObjects_DimensionFormVariance.hxx>
+#include <XCAFDimTolObjects_DimensionGrade.hxx>
+#include <XCAFDimTolObjects_DimensionObject.hxx>
+#include <XCAFDimTolObjects_DimensionModif.hxx>
+#include <XCAFDimTolObjects_DimensionModifiersSequence.hxx>
+#include <XCAFDimTolObjects_DimensionQualifier.hxx>
+#include <XCAFDimTolObjects_GeomToleranceObject.hxx>
 #include <XCAFDoc.hxx>
 #include <XCAFDoc_Area.hxx>
 #include <XCAFDoc_Centroid.hxx>
 #include <XCAFDoc_ColorTool.hxx>
 #include <XCAFDoc_Datum.hxx>
+#include <XCAFDoc_Dimension.hxx>
 #include <XCAFDoc_DimTol.hxx>
 #include <XCAFDoc_DimTolTool.hxx>
 #include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_GeomTolerance.hxx>
 #include <XCAFDoc_GraphNode.hxx>
 #include <XCAFDoc_LayerTool.hxx>
 #include <XCAFDoc_Material.hxx>
 #include <XSControl_TransferWriter.hxx>
 #include <XSControl_WorkSession.hxx>
 
+enum DimensionalValueNumber {
+  DimensionalValueNumber_Nominal = 1,
+  DimensionalValueNumber_Lower,
+  DimensionalValueNumber_Upper
+};
+
 // added by skl 15.01.2004 for D&GT writing
 //#include <StepRepr_CompoundItemDefinition.hxx>
 //#include <StepRepr_CompoundItemDefinitionMember.hxx>
@@ -2044,18 +2107,997 @@ static Standard_Boolean FindPDSforDGT(const Interface_Graph &aGraph,
   return Standard_True;
 }
 
+//=======================================================================
+//function : GetUnit
+//purpose  : auxiliary
+//=======================================================================
+
+static StepBasic_Unit GetUnit(const Handle(StepRepr_RepresentationContext)& theRC,
+                              const Standard_Boolean isAngle = Standard_False)
+{
+  StepBasic_Unit aUnit;
+  if (isAngle) {
+    Handle(StepBasic_SiUnitAndPlaneAngleUnit) aSiPAU;
+    Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) aCtx =
+      Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(theRC);
+    if(!aCtx.IsNull()) {
+      for(Standard_Integer j = 1; j <= aCtx->NbUnits(); j++) {
+        if(aCtx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit))) {
+          aSiPAU = Handle(StepBasic_SiUnitAndPlaneAngleUnit)::DownCast(aCtx->UnitsValue(j));
+          break;
+        }
+      }
+    }
+    if(aSiPAU.IsNull()) {
+      Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) aCtx1 =
+        Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(theRC);
+      if(!aCtx1.IsNull()) {
+        for(Standard_Integer j = 1; j <= aCtx1->NbUnits(); j++) {
+          if(aCtx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit))) {
+            aSiPAU = Handle(StepBasic_SiUnitAndPlaneAngleUnit)::DownCast(aCtx1->UnitsValue(j));
+            break;
+          }
+        }
+      }
+    }
+    if(aSiPAU.IsNull())
+      aSiPAU = new StepBasic_SiUnitAndPlaneAngleUnit;
+    aUnit.SetValue(aSiPAU);
+  }
+  else {
+    Handle(StepBasic_SiUnitAndLengthUnit) aSiLU;
+    Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext) aCtx =
+      Handle(StepGeom_GeometricRepresentationContextAndGlobalUnitAssignedContext)::DownCast(theRC);
+    if(!aCtx.IsNull()) {
+      for(Standard_Integer j = 1; j <= aCtx->NbUnits(); j++) {
+        if(aCtx->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) {
+          aSiLU = Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(aCtx->UnitsValue(j));
+          break;
+        }
+      }
+    }
+    if(aSiLU.IsNull()) {
+      Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) aCtx1 =
+        Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(theRC);
+      if(!aCtx1.IsNull()) {
+        for(Standard_Integer j = 1; j <= aCtx1->NbUnits(); j++) {
+          if(aCtx1->UnitsValue(j)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndLengthUnit))) {
+            aSiLU = Handle(StepBasic_SiUnitAndLengthUnit)::DownCast(aCtx1->UnitsValue(j));
+            break;
+          }
+        }
+      }
+    }
+    if(aSiLU.IsNull())
+      aSiLU = new StepBasic_SiUnitAndLengthUnit;
+    aUnit.SetValue(aSiLU);
+  }
+  return aUnit;
+}
+
+//=======================================================================
+//function : CreateDimValue
+//purpose  : auxiliary
+//======================================================================
+static Handle(StepRepr_ReprItemAndMeasureWithUnit) CreateDimValue(const Standard_Real theValue,
+                                                                  const StepBasic_Unit theUnit,
+                                                                  const Handle(TCollection_HAsciiString)& theName,
+                                                                  const Standard_CString theMeasureName,
+                                                                  const Standard_Boolean isAngle,
+                                                                  const Standard_Boolean isQualified = Standard_False,
+                                                                  const Handle(StepShape_QualifiedRepresentationItem)& theQRI = NULL)
+{
+  Handle(StepRepr_RepresentationItem) aReprItem = new StepRepr_RepresentationItem();
+  aReprItem->Init(new TCollection_HAsciiString(theName));
+  Handle(StepBasic_MeasureWithUnit) aMWU = new StepBasic_MeasureWithUnit();
+  Handle(StepBasic_MeasureValueMember) aValueMember = new StepBasic_MeasureValueMember();
+  aValueMember->SetName(theMeasureName);
+  aValueMember->SetReal(theValue);
+  aMWU->Init(aValueMember, theUnit);
+  if (isQualified) {
+    if (isAngle) {
+      // Angle & with qualifiers
+      Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI) anItem = 
+        new StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI();
+      anItem->Init(aMWU, aReprItem, theQRI);
+      return anItem;
+    }
+    else {
+      // Length & with qualifiers
+      Handle(StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI) anItem = 
+        new StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI();
+      anItem->Init(aMWU, aReprItem, theQRI);
+      return anItem;
+    }
+  }
+  else {
+    if (isAngle) {
+      // Angle & without qualifiers
+      Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit) anItem = 
+        new StepRepr_ReprItemAndPlaneAngleMeasureWithUnit();
+      anItem->Init(aMWU, aReprItem);
+      return anItem;
+    }
+    else {
+      // Length & without qualifiers
+      Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) anItem = 
+        new StepRepr_ReprItemAndLengthMeasureWithUnit();
+      anItem->Init(aMWU, aReprItem);
+      return anItem;
+    }
+  }
+}
+
+//=======================================================================
+//function : WriteShapeAspect
+//purpose  : auxiliary (write Shape_Aspect entity for given shape)
+//=======================================================================
+
+static Handle(StepRepr_ShapeAspect) WriteShapeAspect (const Handle(XSControl_WorkSession) &WS,
+                                                      const TDF_Label theLabel,
+                                                      const TopoDS_Shape theShape,
+                                                      Handle(StepRepr_RepresentationContext)& theRC,
+                                                      Handle(StepAP242_GeometricItemSpecificUsage)& theGISU)
+{
+  // Get working data
+  Handle(Interface_InterfaceModel) Model = WS->Model();
+  Handle(XSControl_TransferWriter) TW = WS->TransferWriter();
+  Handle(Transfer_FinderProcess) FP = TW->FinderProcess();
+  const Handle(Interface_HGraph) aHGraph = WS->HGraph();
+  if (aHGraph.IsNull())
+    return NULL;
+  Interface_Graph aGraph = aHGraph->Graph();
+
+  TopLoc_Location aLoc;
+  TColStd_SequenceOfTransient aSeqRI;
+  FindEntities( FP, theShape, aLoc, aSeqRI );
+  if ( aSeqRI.Length() <= 0 ) {
+    FP->Messenger() << "Warning: Cannot find RI for "<<theShape.TShape()->DynamicType()->Name()<<endl;
+    return NULL;
+  }
+
+  Handle(StepRepr_ProductDefinitionShape) aPDS;
+  Handle(StepRepr_RepresentationContext) aRC;
+  Handle(Standard_Transient) anEnt = aSeqRI.Value(1);
+  Handle(StepShape_AdvancedFace) anAF;
+  Handle(StepShape_EdgeCurve) anEC;
+  FindPDSforDGT(aGraph, anEnt, aPDS, aRC, anAF, anEC);
+  if(aPDS.IsNull()) 
+    return NULL;
+
+  theRC = aRC;
+  // Shape_Aspect
+  Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString();
+  Handle(TDataStd_Name) aNameAttr;
+  if (theLabel.FindAttribute(TDataStd_Name::GetID(), aNameAttr)) {
+    aName = new TCollection_HAsciiString(TCollection_AsciiString(aNameAttr->Get(), '?'));
+    Standard_Integer aFirstSpace = aName->Search(" ");
+    if (aFirstSpace != -1)
+      aName = aName->SubString(aFirstSpace + 1, aName->Length());
+    else
+      aName = new TCollection_HAsciiString();
+  }
+  Handle(TCollection_HAsciiString) aDescription = new TCollection_HAsciiString();
+  Handle(StepRepr_ShapeAspect) aSA = new StepRepr_ShapeAspect;
+  aSA->Init(aName, aDescription, aPDS, StepData_LTrue);
+
+  // Geometric_Item_Specific_Usage
+  Handle(StepAP242_GeometricItemSpecificUsage) aGISU = new StepAP242_GeometricItemSpecificUsage();
+  StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition;
+  aDefinition.SetValue(aSA);
+  Handle(StepRepr_HArray1OfRepresentationItem) anReprItems = new StepRepr_HArray1OfRepresentationItem(1, 1);
+  Handle(StepRepr_RepresentationItem) anIdentifiedItem = Handle(StepRepr_RepresentationItem)::DownCast(anEnt);
+  anReprItems->SetValue(1, anIdentifiedItem);
+  Interface_EntityIterator subs = aGraph.Sharings(aPDS);
+  Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
+  for (subs.Start(); subs.More() && aSDR.IsNull(); subs.Next()) {
+    Handle(Standard_Transient) anEntity = subs.Value();
+    aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(anEntity);
+  }
+  if (aSDR.IsNull())
+    return NULL;
+
+  // Set entities to model
+  aGISU->Init(aName, aDescription, aDefinition, aSDR->UsedRepresentation(), anReprItems);
+  Model->AddWithRefs(aSA);
+  Model->AddWithRefs(aGISU);
+  theGISU = aGISU;
+  return aSA;
+}
+
+//=======================================================================
+//function : WriteDatumAP242
+//purpose  : auxiliary (write Datum entity for given shape or write all 
+//           necessary entities and link them to already written datum 
+//           in case of multiple features association)
+//=======================================================================
+static Handle(StepDimTol_Datum) WriteDatumAP242(const Handle(XSControl_WorkSession) &WS,
+                                                const TDF_Label theShapeL,
+                                                const TDF_Label theDatumL,
+                                                const Standard_Boolean isFirstDTarget,
+                                                const Handle(StepDimTol_Datum) theWrittenDatum)
+{
+  // Get working data
+  Handle(Interface_InterfaceModel) Model = WS->Model();
+  Handle(XSControl_TransferWriter) TW = WS->TransferWriter();
+  Handle(Transfer_FinderProcess) FP = TW->FinderProcess();
+  const Handle(Interface_HGraph) aHGraph = WS->HGraph();
+  if (aHGraph.IsNull())
+    return NULL;
+  Interface_Graph aGraph = aHGraph->Graph();
+
+  Handle(StepRepr_ShapeAspect) aSA;
+  Handle(StepAP242_GeometricItemSpecificUsage) aGISU;
+  // Link with datum feature
+  Handle(StepRepr_ProductDefinitionShape) aPDS;
+  Handle(StepRepr_RepresentationContext) aRC;
+  Handle(Standard_Transient) anEnt;
+  Handle(StepShape_AdvancedFace) anAF;
+  Handle(StepShape_EdgeCurve) anEC;
+  TopoDS_Shape aShape;
+  TopLoc_Location aLoc;
+  TColStd_SequenceOfTransient aSeqRI;
+
+  aShape = XCAFDoc_ShapeTool::GetShape(theShapeL);
+  FindEntities( FP, aShape, aLoc, aSeqRI );
+  if ( aSeqRI.Length() <= 0 ) {
+    FP->Messenger() << "Warning: Cannot find RI for "<<aShape.TShape()->DynamicType()->Name()<<endl;
+    return NULL;
+  }
+  anEnt = aSeqRI.Value(1);
+  FindPDSforDGT(aGraph, anEnt, aPDS, aRC, anAF, anEC);
+  if (aPDS.IsNull()) 
+    return NULL;
+
+  aSA = WriteShapeAspect(WS, theDatumL, aShape, aRC, aGISU);
+  if (aSA.IsNull())
+    return NULL;
+  Standard_Integer aSANum = Model->Number(aSA);
+  Standard_Integer aGISUNum = Model->Number(aGISU);
+  // Find if datum has datum targets and get common datum attributes
+  Handle(XCAFDoc_Datum) aDatumAttr;
+  if (!theDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr)) 
+    return NULL;
+  Handle(XCAFDimTolObjects_DatumObject) anObject = aDatumAttr->GetObject();
+  if (anObject.IsNull())
+    return NULL;
+  Standard_Boolean isSimpleDatum = !anObject->IsDatumTarget();
+  Handle(TCollection_HAsciiString) anIdentifier = anObject->GetName();
+  Handle(TCollection_HAsciiString) aTargetId = (anObject->GetDatumTargetNumber() == 0 ? 
+    new TCollection_HAsciiString() : new TCollection_HAsciiString(anObject->GetDatumTargetNumber()));
+
+  // If datum type is area, but there is no area in object, write as simple datum
+  if (anObject->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Area &&
+    anObject->GetDatumTarget().IsNull())
+    isSimpleDatum = Standard_True;
+
+  // Simple datum
+  if (isSimpleDatum) {
+    Handle(StepDimTol_DatumFeature) aDF = new StepDimTol_DatumFeature();
+    aDF->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aSA->OfShape(), aSA->ProductDefinitional());
+    Model->ReplaceEntity(aSANum, aDF);
+    aSA = aDF;
+    StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition;
+    aDefinition.SetValue(aDF);
+    aGISU->SetDefinition(aDefinition);
+    Model->ReplaceEntity(aGISUNum, aGISU);
+  }
+  // Datum with datum targets
+  else {
+    XCAFDimTolObjects_DatumTargetType aDatumType = anObject->GetDatumTargetType();
+    Handle(StepDimTol_DatumTarget) aDatumTarget;
+    // Note: the given way to write such datum type may be incorrect (too little information)
+    if (aDatumType == XCAFDimTolObjects_DatumTargetType_Area) {
+      TopoDS_Shape aDTShape = anObject->GetDatumTarget();
+      Handle(StepAP242_GeometricItemSpecificUsage) anAreaGISU;
+      Handle(StepRepr_ShapeAspect) anAreaSA = WriteShapeAspect(WS, theDatumL, aDTShape, aRC, anAreaGISU);
+      aSANum = Model->Number(anAreaSA);
+      aGISUNum = Model->Number(anAreaGISU);
+      Handle(StepDimTol_DatumTarget) aDT = new StepDimTol_DatumTarget();
+      aDT->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString("area"), anAreaSA->OfShape(),
+        anAreaSA->ProductDefinitional(), aTargetId);
+      Model->ReplaceEntity(aSANum, aDT);
+      StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition;
+      aDefinition.SetValue(aDT);
+      anAreaGISU->SetDefinition(aDefinition);
+      Model->ReplaceEntity(aGISUNum, anAreaGISU);
+  }
+    else {
+      Handle(StepDimTol_PlacedDatumTargetFeature) aPDTF = new StepDimTol_PlacedDatumTargetFeature();
+      aPDTF->Init(new TCollection_HAsciiString(), STEPConstruct_GDTProperty::GetDatumTargetName(aDatumType),
+        aPDS, StepData_LTrue, aTargetId);
+      Model->AddWithRefs(aPDTF);
+      aDatumTarget = aPDTF;
+      // Datum targets
+      Handle(StepRepr_PropertyDefinition) aPD = new StepRepr_PropertyDefinition();
+      StepRepr_CharacterizedDefinition aCDefinition;
+      aCDefinition.SetValue(aPDTF);
+      aPD->Init(new TCollection_HAsciiString(), Standard_False, NULL, aCDefinition);
+      Handle(StepShape_ShapeRepresentationWithParameters) aSRWP = new StepShape_ShapeRepresentationWithParameters();
+      // Common for all datum targets
+      StepBasic_Unit aUnit = GetUnit(aRC);
+      gp_Ax2 aDTAxis = anObject->GetDatumTargetAxis();
+      Handle(StepGeom_Axis2Placement3d) anA2P3D = 
+        STEPConstruct_GDTProperty::GetAxis2Placement3D(aDTAxis);
+      Handle(StepRepr_HArray1OfRepresentationItem) anItems;
+      // Process each datum target type
+      if (aDatumType == XCAFDimTolObjects_DatumTargetType_Point) {
+        anItems = new StepRepr_HArray1OfRepresentationItem(1, 1);
+      }
+      else  {
+        Handle(TCollection_HAsciiString) aTargetValueName;
+        if (aDatumType == XCAFDimTolObjects_DatumTargetType_Line) {
+          anItems = new StepRepr_HArray1OfRepresentationItem(1, 2);
+          aTargetValueName = new TCollection_HAsciiString("target length");
+        }
+        else if (aDatumType == XCAFDimTolObjects_DatumTargetType_Rectangle) {
+          anItems = new StepRepr_HArray1OfRepresentationItem(1, 3);
+          aTargetValueName = new TCollection_HAsciiString("target length");
+          // Additional value
+          Handle(StepRepr_ReprItemAndMeasureWithUnit) aTargetValue = CreateDimValue(anObject->GetDatumTargetWidth(),
+            aUnit, new TCollection_HAsciiString("target width"), "POSITIVE_LENGTH_MEASURE", Standard_False);
+          anItems->SetValue(2, aTargetValue);
+          Model->AddWithRefs(aTargetValue);
+        }
+        else if (aDatumType == XCAFDimTolObjects_DatumTargetType_Circle) {
+          anItems = new StepRepr_HArray1OfRepresentationItem(1, 2);
+          aTargetValueName = new TCollection_HAsciiString("target diameter");
+        }
+        // Value
+        Handle(StepRepr_ReprItemAndMeasureWithUnit) aTargetValue= CreateDimValue(anObject->GetDatumTargetLength(),
+          aUnit, aTargetValueName, "POSITIVE_LENGTH_MEASURE", Standard_False);
+        anItems->SetValue(1, aTargetValue);
+        Model->AddWithRefs(aTargetValue);
+      }
+      anItems->SetValue(anItems->Length(), anA2P3D);
+      aSRWP->Init(new TCollection_HAsciiString(), anItems, aRC);
+  
+      // Create and write auxiliary entities
+      Handle (StepShape_ShapeDefinitionRepresentation) aSDR = new StepShape_ShapeDefinitionRepresentation();
+      StepRepr_RepresentedDefinition aRDefinition;
+      aRDefinition.SetValue(aPD);
+      aSDR->Init(aRDefinition, aSRWP);
+      Model->AddWithRefs(aPD);
+      Model->AddWithRefs(aSRWP);
+      Model->AddWithRefs(aSDR);
+    }
+    // Link datum target to datum feature
+    Handle(StepRepr_FeatureForDatumTargetRelationship) aFFDTR = new StepRepr_FeatureForDatumTargetRelationship();
+    aFFDTR->Init(new TCollection_HAsciiString(), Standard_False, NULL, aDatumTarget, aSA);
+    Model->AddWithRefs(aFFDTR);
+    aSA = aDatumTarget;
+  }
+
+  // Datum
+  Handle(StepDimTol_Datum) aDatum = theWrittenDatum;
+  if (isFirstDTarget) {
+    aDatum = new StepDimTol_Datum();
+    aDatum->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aPDS, StepData_LTrue, anIdentifier);
+    Model->AddWithRefs(aDatum);
+  }
+
+  // Shape_Aspect_Relationship
+  Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship();
+  aSAR->Init(new TCollection_HAsciiString(), Standard_False, NULL, aSA, aDatum);
+  Model->AddWithRefs(aSAR);
+
+  // Auxiliary entities
+  // Property_Definition
+  Handle(StepRepr_PropertyDefinition) aPD = new StepRepr_PropertyDefinition();
+  Handle(TCollection_HAsciiString) aPDName = new TCollection_HAsciiString("Datum Feature Symbol ");
+  aPDName = aPDName->Cat(anIdentifier)->Cat(aTargetId);
+  StepRepr_CharacterizedDefinition aCD;
+  aCD.SetValue(aSA);
+  aPD->Init(aPDName, Standard_False, NULL, aCD);
+  Model->AddWithRefs(aPD);
+  // Shape_Representation
+  Handle(StepShape_ShapeRepresentation) aShapeRepr = new StepShape_ShapeRepresentation();
+  aShapeRepr->Init(aPDName, aGISU->IdentifiedItem(), aRC);
+  Model->AddWithRefs(aShapeRepr);
+  // Shape_Definition_Representation
+  Handle (StepShape_ShapeDefinitionRepresentation) aSDR = new StepShape_ShapeDefinitionRepresentation();
+  StepRepr_RepresentedDefinition aRDefinition;
+  aRDefinition.SetValue(aPD);
+  aSDR->Init(aRDefinition, aShapeRepr);
+  Model->AddWithRefs(aSDR);
+
+  return aDatum;
+}
+
+//=======================================================================
+//function : WriteDimValues
+//purpose  : auxiliary (write all data for given dimension: values, 
+//           qualifiers, modifiers, orientation and tolerance class)
+//======================================================================
+static void WriteDimValues(const Handle(XSControl_WorkSession) &WS,
+                           const Handle(XCAFDimTolObjects_DimensionObject) theObject,
+                           const Handle(StepRepr_RepresentationContext) theRC,
+                           const StepShape_DimensionalCharacteristic theDimension)
+{
+  // Get working data
+  Handle(Interface_InterfaceModel) aModel = WS->Model();
+  XCAFDimTolObjects_DimensionModifiersSequence aModifiers = theObject->GetModifiers();
+  Handle(Standard_Transient) aDim = theDimension.Value();
+  Standard_Boolean isAngle = aDim->IsKind(STANDARD_TYPE(StepShape_AngularLocation)) ||
+                             aDim->IsKind(STANDARD_TYPE(StepShape_AngularSize));
+
+  // Unit
+  StepBasic_Unit aUnit = GetUnit(theRC, isAngle);
+  Standard_CString aMeasureName;
+  if (isAngle)
+    aMeasureName = "POSITIVE_PLANE_ANGLE_MEASURE";
+  else
+    aMeasureName = "POSITIVE_LENGTH_MEASURE";
+
+  // Values
+  Handle(StepRepr_HArray1OfRepresentationItem) aValues;
+  Standard_Integer aNbValItems = 1, aNbAddItems = 0;
+  if (theObject->IsDimWithRange())
+    aNbValItems += 2;
+  if (aModifiers.Length() > 0)
+    aNbAddItems++;
+  if (theObject->GetType() == XCAFDimTolObjects_DimensionType_Location_Oriented)
+    aNbAddItems++;
+  aValues = new StepRepr_HArray1OfRepresentationItem(1, aNbValItems + aNbAddItems);
+
+  // Nominal value
+  Standard_Real aNominal = theObject->GetValue();
+  Standard_Integer aLeftNbDigits, aRightNbDigits;
+  theObject->GetNbOfDecimalPlaces(aLeftNbDigits, aRightNbDigits);
+  Standard_Integer aNbQualifiers = 0;
+  if (theObject->HasQualifier() && !isAngle)
+    aNbQualifiers++;
+  if (aLeftNbDigits > 0 || aRightNbDigits > 0)
+    aNbQualifiers++;
+  // With qualifiers
+  if (aNbQualifiers > 0) {
+    Handle(StepShape_QualifiedRepresentationItem) aQRI = new StepShape_QualifiedRepresentationItem();
+    Handle(StepShape_HArray1OfValueQualifier) aQualifiers = new StepShape_HArray1OfValueQualifier(1, aNbQualifiers);
+    // Type qualifier
+    if (theObject->HasQualifier() && !isAngle) {
+      StepShape_ValueQualifier anItem;
+      Handle(StepShape_TypeQualifier) aType = new StepShape_TypeQualifier();
+      XCAFDimTolObjects_DimensionQualifier aQualifier = theObject->GetQualifier();
+      aType->Init(STEPConstruct_GDTProperty::GetDimQualifierName(aQualifier));
+      aModel->AddWithRefs(aType);
+      anItem.SetValue(aType);
+      aQualifiers->SetValue(1, anItem);
+    }
+    // Number of decimal places
+    if (aLeftNbDigits > 0 || aRightNbDigits > 0) {
+      StepShape_ValueQualifier anItem;
+      Handle(StepShape_ValueFormatTypeQualifier) aType = new StepShape_ValueFormatTypeQualifier();
+      Handle(TCollection_HAsciiString) aFormatType = new TCollection_HAsciiString("NR2 ");
+      aFormatType->AssignCat(new TCollection_HAsciiString(aLeftNbDigits));
+      aFormatType->AssignCat(new TCollection_HAsciiString("."));
+      aFormatType->AssignCat(new TCollection_HAsciiString(aRightNbDigits));
+      aType->Init(aFormatType);
+      aModel->AddWithRefs(aType);
+      anItem.SetValue(aType);
+      aQualifiers->SetValue(aNbQualifiers, anItem);
+    }
+    // Set qualifiers
+    aQRI->SetQualifiers(aQualifiers);
+    Handle(StepRepr_ReprItemAndMeasureWithUnit) anItem = CreateDimValue(aNominal, aUnit,
+      new TCollection_HAsciiString("nominal value"), aMeasureName, isAngle, Standard_True, aQRI);
+    aValues->SetValue(DimensionalValueNumber_Nominal, anItem);
+  }
+  // Without qualifiers
+  else {
+    Handle(StepRepr_ReprItemAndMeasureWithUnit) anItem = CreateDimValue(aNominal, aUnit,
+      new TCollection_HAsciiString("nominal value"), aMeasureName, isAngle);
+    aValues->SetValue(DimensionalValueNumber_Nominal, anItem);
+  }
+  // Ranges
+  if (theObject->IsDimWithRange()) {
+    Handle(StepRepr_ReprItemAndMeasureWithUnit) aLowerItem = CreateDimValue(theObject->GetLowerBound(), aUnit,
+      new TCollection_HAsciiString("lower limit"), aMeasureName, isAngle);
+    Handle(StepRepr_ReprItemAndMeasureWithUnit) anUpperItem = CreateDimValue(theObject->GetUpperBound(), aUnit,
+      new TCollection_HAsciiString("upper limit"), aMeasureName, isAngle);
+    aValues->SetValue(DimensionalValueNumber_Lower, aLowerItem);
+    aValues->SetValue(DimensionalValueNumber_Upper, anUpperItem);
+  }
+
+  // Modifiers
+  if (aModifiers.Length() > 0) {
+    Handle(StepRepr_CompoundRepresentationItem) aCompoundRI = new StepRepr_CompoundRepresentationItem();
+    Handle (StepRepr_HArray1OfRepresentationItem) aModifItems = 
+      new StepRepr_HArray1OfRepresentationItem(1, aModifiers.Length());
+    for (Standard_Integer i = 1; i <= aModifiers.Length(); i++) {
+      XCAFDimTolObjects_DimensionModif aModif = aModifiers.Value(i);
+      Handle(StepRepr_DescriptiveRepresentationItem) aModifItem = 
+        new StepRepr_DescriptiveRepresentationItem();
+      aModifItem->Init(new TCollection_HAsciiString(), STEPConstruct_GDTProperty::GetDimModifierName(aModif));
+      aModel->AddWithRefs(aModifItem);
+      aModifItems->SetValue(i, aModifItem);
+    }
+    aCompoundRI->Init(new TCollection_HAsciiString(), aModifItems);
+    aValues->SetValue(aNbValItems + 1, aCompoundRI);
+  }
+
+  // Orientation
+  if (theObject->GetType() == XCAFDimTolObjects_DimensionType_Location_Oriented) {
+    Handle(StepGeom_Axis2Placement3d) anOrientation = new StepGeom_Axis2Placement3d();
+    gp_Dir aDir;
+    theObject->GetDirection(aDir);
+    Handle(StepGeom_CartesianPoint) aLoc = new StepGeom_CartesianPoint();
+    aLoc->Init(new TCollection_HAsciiString());
+    Handle(StepGeom_Direction) anAxis = new StepGeom_Direction();
+    Handle(TColStd_HArray1OfReal) aCoords = new TColStd_HArray1OfReal(1, 3);
+    aCoords->SetValue(1, aDir.X());
+    aCoords->SetValue(2, aDir.Y());
+    aCoords->SetValue(3, aDir.Z());
+    anAxis->Init(new TCollection_HAsciiString(), aCoords);
+    anOrientation->Init(new TCollection_HAsciiString("orientation"), aLoc, Standard_True, anAxis, Standard_False, NULL);
+    aValues->SetValue(aValues->Length(), anOrientation);
+  }
+
+  for (Standard_Integer i = 1; i <= aValues->Length(); i++)
+    aModel->AddWithRefs(aValues->Value(i));
+
+  // Create resulting Shape_Dimension_Representation
+  Handle(StepShape_ShapeDimensionRepresentation) aSDR = new StepShape_ShapeDimensionRepresentation();
+  aSDR->Init(new TCollection_HAsciiString(), aValues, theRC);
+  aModel->AddWithRefs(aSDR);
+  Handle(StepShape_DimensionalCharacteristicRepresentation) aDCR = new StepShape_DimensionalCharacteristicRepresentation();
+  aDCR->Init(theDimension, aSDR);
+  aModel->AddWithRefs(aDCR);
+
+  // Plus_Minus_Tolerance
+  if (theObject->IsDimWithPlusMinusTolerance()) {
+    Handle(TCollection_HAsciiString) aDummyName = new TCollection_HAsciiString(aMeasureName);
+    aDummyName = aDummyName->SubString(9, aDummyName->Length()); //delete "POSITIVE_"
+    aMeasureName = aDummyName->ToCString();
+    Standard_Real aLowerTolValue = -theObject->GetLowerTolValue(),
+                  anUpperTolValue = theObject->GetUpperTolValue();
+    // Upper
+    Handle(StepBasic_MeasureWithUnit) anUpperMWU = new StepBasic_MeasureWithUnit();
+    Handle(StepBasic_MeasureValueMember) anUpperValue = new StepBasic_MeasureValueMember();
+    anUpperValue->SetName(aMeasureName);
+    anUpperValue->SetReal(anUpperTolValue);
+    anUpperMWU->Init(anUpperValue, aUnit);
+    aModel->AddWithRefs(anUpperMWU);
+    // Lower
+    Handle(StepBasic_MeasureWithUnit) aLowerMWU = new StepBasic_MeasureWithUnit();
+    Handle(StepBasic_MeasureValueMember) aLowerValue = new StepBasic_MeasureValueMember();
+    aLowerValue->SetName(aMeasureName);
+    aLowerValue->SetReal(aLowerTolValue);
+    aLowerMWU->Init(aLowerValue, aUnit);
+    aModel->AddWithRefs(aLowerMWU);
+    // Tolerance
+    Handle(StepShape_ToleranceValue) aTolValue = new StepShape_ToleranceValue();
+    aTolValue->Init(aLowerMWU, anUpperMWU);
+    aModel->AddWithRefs(aTolValue);
+    StepShape_ToleranceMethodDefinition aMethod;
+    aMethod.SetValue(aTolValue);
+    Handle(StepShape_PlusMinusTolerance) aPlusMinusTol = new StepShape_PlusMinusTolerance();
+    aPlusMinusTol->Init(aMethod, theDimension);
+    aModel->AddWithRefs(aPlusMinusTol);
+  }
+  // Tolerance class
+  if (theObject->IsDimWithClassOfTolerance()) {
+    Standard_Boolean isHole;
+    XCAFDimTolObjects_DimensionFormVariance aFormVariance;
+    XCAFDimTolObjects_DimensionGrade aGrade;
+    if (!theObject->GetClassOfTolerance(isHole, aFormVariance, aGrade))
+      return;
+    Handle(StepShape_LimitsAndFits) aLAF = STEPConstruct_GDTProperty::GetLimitsAndFits(isHole, aFormVariance, aGrade);
+    aModel->AddWithRefs(aLAF);
+    StepShape_ToleranceMethodDefinition aMethod;
+    aMethod.SetValue(aLAF);
+    Handle(StepShape_PlusMinusTolerance) aPlusMinusTol = new StepShape_PlusMinusTolerance();
+    aPlusMinusTol->Init(aMethod, theDimension);
+    aModel->AddWithRefs(aPlusMinusTol);
+  }
+}
+
+//=======================================================================
+//function : WriteDatumSystem
+//purpose  : auxiliary (write Write datum system for given
+//           geometric_tolerance)
+//======================================================================
+static Handle(StepDimTol_HArray1OfDatumSystemOrReference) WriteDatumSystem(const Handle(XSControl_WorkSession) &WS,
+                                                                           const TDF_Label theGeomTolL,
+                                                                           const TDF_LabelSequence theDatumSeq,
+                                                                           const STEPConstruct_DataMapOfAsciiStringTransient theDatumMap,
+                                                                           const Handle(StepRepr_RepresentationContext)& theRC)
+{
+  // Get working data
+  Handle(Interface_InterfaceModel) Model = WS->Model();
+  const Handle(Interface_HGraph) aHGraph = WS->HGraph();
+  if (aHGraph.IsNull())
+    return NULL;
+  Interface_Graph aGraph = aHGraph->Graph();
+  Handle(XCAFDoc_GeomTolerance) aGTAttr;
+  if (!theGeomTolL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGTAttr)) 
+    return NULL;
+  Handle(XCAFDimTolObjects_GeomToleranceObject) anObject = aGTAttr->GetObject();
+  if (anObject.IsNull())
+    return NULL;
+
+  // Unit
+  StepBasic_Unit aUnit = GetUnit(theRC);
+
+  XCAFDimTolObjects_DatumObjectSequence aDatums;
+  Standard_Integer aMaxDatumNum = 0;
+  for (Standard_Integer i = 1; i <= theDatumSeq.Length(); i++) {
+    Handle(XCAFDoc_Datum) aDatumAttr;
+    if (!theDatumSeq.Value(i).FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr)) 
+      continue;
+    Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatumAttr->GetObject();
+    if (aDatumObj.IsNull())
+      continue;
+    aDatums.Append(aDatumObj);
+    aMaxDatumNum = Max(aMaxDatumNum, aDatumObj->GetPosition());
+  }
+
+  Handle(StepDimTol_HArray1OfDatumReferenceCompartment) aConstituents =
+    new StepDimTol_HArray1OfDatumReferenceCompartment(1, aMaxDatumNum);
+  // Auxiliary datum to initialize attributes in Datum_System
+  Handle(StepDimTol_Datum) aFirstDatum;
+  Standard_Integer aConstituentsNum = 0;
+  for (Standard_Integer i = 1; i <= aMaxDatumNum; i++) {
+    // Collect datums with i-th position
+    XCAFDimTolObjects_DatumObjectSequence aDatumSeqPos;
+    for (Standard_Integer j = 1; j <= aDatums.Length(); j++)
+      if (aDatums.Value(j)->GetPosition() == i)
+        aDatumSeqPos.Append(aDatums.Value(j));
+    if (aDatumSeqPos.Length() < 1)
+      continue;
+
+    aConstituentsNum++;
+    // Initialize Datum_Reference_Compartment
+    StepDimTol_DatumOrCommonDatum aDatumRef;
+    Handle(StepDimTol_DatumReferenceCompartment) aCompartment =
+      new StepDimTol_DatumReferenceCompartment();
+    Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModifiers;
+    if (aDatumSeqPos.Length() == 1) {
+      // Datum entity
+      theDatumMap.Find(aDatumSeqPos.Value(1)->GetName()->String(), aFirstDatum);
+      aDatumRef.SetValue(aFirstDatum);
+      // Modifiers
+      XCAFDimTolObjects_DatumModifiersSequence aSimpleModifiers = aDatumSeqPos.Value(1)->GetModifiers();
+      XCAFDimTolObjects_DatumModifWithValue aModifWithVal;
+      Standard_Real aValue = 0;
+      aDatumSeqPos.Value(1)->GetModifierWithValue(aModifWithVal, aValue);
+      aModifiers = STEPConstruct_GDTProperty::GetDatumRefModifiers(aSimpleModifiers, aModifWithVal, aValue, aUnit);
+      // Add Datum_Reference_Modifier_With_Value
+      if (!aModifiers.IsNull()) {
+        Handle(StepDimTol_DatumReferenceModifierWithValue) aDRMWV = 
+          aModifiers->Value(aModifiers->Length()).DatumReferenceModifierWithValue();
+        if (!aDRMWV.IsNull()) {
+          Model->AddWithRefs(aDRMWV);
+        }
+      }
+    }
+    else {
+      Handle(StepDimTol_HArray1OfDatumReferenceElement) aCommonDatumList = new StepDimTol_HArray1OfDatumReferenceElement(1, aDatumSeqPos.Length());
+      for (Standard_Integer j = 1; j <= aDatumSeqPos.Length(); j++) {
+        // Datum entity
+        Handle(StepDimTol_Datum) aDatum;
+        theDatumMap.Find(aDatumSeqPos.Value(j)->GetName()->String(), aDatum);
+        StepDimTol_DatumOrCommonDatum anElemDatumRef;
+        anElemDatumRef.SetValue(aDatum);
+        if (aFirstDatum.IsNull())
+          aFirstDatum = aDatum;
+        // Modifiers
+        XCAFDimTolObjects_DatumModifiersSequence aSimpleModifiers = aDatumSeqPos.Value(j)->GetModifiers();
+        XCAFDimTolObjects_DatumModifWithValue aModifWithVal;
+        Standard_Real aValue = 0;
+        aDatumSeqPos.Value(j)->GetModifierWithValue(aModifWithVal, aValue);
+        Handle(StepDimTol_HArray1OfDatumReferenceModifier) anElemModifiers =
+          STEPConstruct_GDTProperty::GetDatumRefModifiers(aSimpleModifiers, aModifWithVal, aValue, aUnit);
+        // Add Datum_Reference_Modifier_With_Value
+        if (!anElemModifiers.IsNull()) {
+          Handle(StepDimTol_DatumReferenceModifierWithValue) aDRMWV = 
+            anElemModifiers->Value(aModifiers->Length()).DatumReferenceModifierWithValue();
+          if (!aDRMWV.IsNull()) {
+            Model->AddWithRefs(aDRMWV);
+          }
+        }
+        // Datum_Reference_Element
+        Handle(StepDimTol_DatumReferenceElement) anElement = new StepDimTol_DatumReferenceElement();
+        anElement->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aDatum->OfShape(),
+          aDatum->ProductDefinitional(), anElemDatumRef, !anElemModifiers.IsNull(), anElemModifiers);
+        Model->AddWithRefs(anElement);
+        aCommonDatumList->SetValue(j, anElement);
+      }
+      aDatumRef.SetValue(aCommonDatumList);
+    }
+    aCompartment->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aFirstDatum->OfShape(),
+      aFirstDatum->ProductDefinitional(), aDatumRef, !aModifiers.IsNull(), aModifiers);
+    Model->AddWithRefs(aCompartment);
+    aConstituents->SetValue(aConstituentsNum, aCompartment);
+  }
+  // Remove null elements from aConstituents
+  Standard_Integer aNbConstituents = 0;
+  for (Standard_Integer i = 1; i <= aConstituents->Length(); i++)
+    if (!aConstituents->Value(i).IsNull())
+      aNbConstituents++;
+  Handle(StepDimTol_HArray1OfDatumReferenceCompartment) aResConstituents =
+    new StepDimTol_HArray1OfDatumReferenceCompartment(1, aNbConstituents);
+  Standard_Integer aConstituentsIt = 0;
+  for (Standard_Integer i = 1; i <= aConstituents->Length(); i++)
+    if (!aConstituents->Value(i).IsNull()) {
+      aConstituentsIt++;
+      aResConstituents->SetValue(aConstituentsIt, aConstituents->Value(i));
+    }
+
+  Handle(StepDimTol_HArray1OfDatumSystemOrReference) aDatumSystem;
+  Handle(StepDimTol_DatumSystem) aDS = new StepDimTol_DatumSystem();
+  aDS->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(), aFirstDatum->OfShape(),
+    aFirstDatum->ProductDefinitional(), aResConstituents);
+  Model->AddWithRefs(aDS);
+  StepDimTol_DatumSystemOrReference anArrayValue;
+  anArrayValue.SetValue(aDS);
+  aDatumSystem = new StepDimTol_HArray1OfDatumSystemOrReference(1, 1);
+  aDatumSystem->SetValue(1, anArrayValue);
+
+  // Axis
+  if (anObject->HasAxis()) {
+    Handle(StepGeom_Axis2Placement3d) anAxis =
+      STEPConstruct_GDTProperty::GetAxis2Placement3D(anObject->GetAxis());
+    Handle(StepAP242_GeometricItemSpecificUsage) aGISU = new StepAP242_GeometricItemSpecificUsage();
+    StepAP242_ItemIdentifiedRepresentationUsageDefinition aDefinition;
+    aDefinition.SetValue(aDS);
+    Handle(StepRepr_HArray1OfRepresentationItem) anReprItems = new StepRepr_HArray1OfRepresentationItem(1, 1);
+    Handle(StepRepr_RepresentationItem) anIdentifiedItem = Handle(StepRepr_RepresentationItem)::DownCast(anAxis);
+    anReprItems->SetValue(1, anIdentifiedItem);
+    Interface_EntityIterator subs = aGraph.Sharings(aFirstDatum->OfShape());
+    Handle(StepShape_ShapeDefinitionRepresentation) aSDR;
+    for (subs.Start(); subs.More() && aSDR.IsNull(); subs.Next()) {
+      Handle(Standard_Transient) anEntity = subs.Value();
+      aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(anEntity);
+    }
+    if (aSDR.IsNull())
+      return aDatumSystem;
+    
+    aGISU->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(),
+      aDefinition, aSDR->UsedRepresentation(), anReprItems);
+    Model->AddWithRefs(anAxis);
+    Model->AddWithRefs(aGISU);
+  }
+
+  return aDatumSystem;
+}
+
+//=======================================================================
+//function : WriteToleranceZone
+//purpose  : auxiliary (write tolerace zones)
+//=======================================================================
+static void WriteToleranceZone (const Handle(XSControl_WorkSession) &WS,
+                                const Handle(XCAFDimTolObjects_GeomToleranceObject)& theObject,
+                                const Handle(StepDimTol_GeometricTolerance)& theEntity,
+                                const Handle(StepRepr_RepresentationContext)& theRC)
+{
+  // Get working data
+  Handle(Interface_InterfaceModel) Model = WS->Model();
+  if (theEntity.IsNull() || theObject.IsNull())
+    return;
+
+  // Return if there is no tolerance zones
+  if (theObject->GetTypeOfValue() == XCAFDimTolObjects_GeomToleranceTypeValue_None &&
+      theObject->GetZoneModifier() != XCAFDimTolObjects_GeomToleranceZoneModif_Runout)
+    return;
+
+  // Create Tolerance_Zone
+  Handle(StepDimTol_ToleranceZoneForm) aForm = new StepDimTol_ToleranceZoneForm();
+  Model->AddWithRefs(aForm);
+  aForm->Init(STEPConstruct_GDTProperty::GetTolValueType(theObject->GetTypeOfValue()));
+  Handle(StepDimTol_HArray1OfToleranceZoneTarget) aZoneTargetArray = new StepDimTol_HArray1OfToleranceZoneTarget(1, 1);
+  StepDimTol_ToleranceZoneTarget aTarget;
+  aTarget.SetValue(theEntity);
+  aZoneTargetArray->SetValue(1, aTarget);
+  Handle(StepDimTol_ToleranceZone) aZone = new StepDimTol_ToleranceZone();
+  aZone->Init(new TCollection_HAsciiString(), new TCollection_HAsciiString(),
+    theEntity->TolerancedShapeAspect().ShapeAspect()->OfShape(), StepData_LFalse,
+    aZoneTargetArray, aForm);
+  Model->AddWithRefs(aZone);
+
+  // Runout_Tolerance_Zone
+  Handle(StepBasic_PlaneAngleMeasureWithUnit) aPAMWU = new StepBasic_PlaneAngleMeasureWithUnit();
+  Handle(StepBasic_MeasureValueMember) aValueMember = new StepBasic_MeasureValueMember();
+  aValueMember->SetName("PLANE_ANGLE_MEASURE");
+  aValueMember->SetReal(theObject->GetValueOfZoneModifier());
+  aPAMWU->Init(aValueMember, GetUnit(theRC, Standard_True));
+  Handle(StepDimTol_RunoutZoneOrientation) anOrientation = new StepDimTol_RunoutZoneOrientation();
+  anOrientation->Init(aPAMWU);
+  Handle(StepDimTol_RunoutZoneDefinition) aDefinition = new StepDimTol_RunoutZoneDefinition();
+  aDefinition->Init(aZone, NULL, anOrientation);
+  Model->AddWithRefs(aDefinition);
+  Model->AddWithRefs(anOrientation);
+  Model->AddWithRefs(aPAMWU);
+}
+
+//=======================================================================
+//function : WriteGeomTolerance
+//purpose  : auxiliary (write Geometric_Tolerance entity for given shapes,
+//           label and datum system)
+//======================================================================
+static void WriteGeomTolerance (const Handle(XSControl_WorkSession) &WS,
+                                const TDF_LabelSequence theShapeSeqL,
+                                const TDF_Label theGeomTolL,
+                                const Handle(StepDimTol_HArray1OfDatumSystemOrReference)& theDatumSystem,
+                                const Handle(StepRepr_RepresentationContext)& theRC)
+{
+  // Get working data
+  Handle(Interface_InterfaceModel) Model = WS->Model();
+  Handle(XCAFDoc_GeomTolerance) aGTAttr;
+  if (!theGeomTolL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGTAttr)) 
+    return;
+  Handle(XCAFDimTolObjects_GeomToleranceObject) anObject = aGTAttr->GetObject();
+  if (anObject.IsNull())
+    return;
+
+  // Value
+  Handle(StepBasic_LengthMeasureWithUnit) aLMWU = new StepBasic_LengthMeasureWithUnit();
+  StepBasic_Unit aUnit = GetUnit(theRC);
+  Handle(StepBasic_MeasureValueMember) aValueMember = new StepBasic_MeasureValueMember();
+  aValueMember->SetName("LENGTH_MEASURE");
+  aValueMember->SetReal(anObject->GetValue());
+  aLMWU->Init(aValueMember, aUnit);
+  Model->AddWithRefs(aLMWU);
+
+  // Geometric_Tolerance target
+  Handle(StepRepr_ShapeAspect) aMainSA;
+  Handle(StepRepr_RepresentationContext) dummyRC;
+  Handle(StepAP242_GeometricItemSpecificUsage) dummyGISU;
+  if (theShapeSeqL.Length() == 1) {
+    TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(theShapeSeqL.Value(1));
+    aMainSA = WriteShapeAspect(WS, theGeomTolL, aShape, dummyRC, dummyGISU);
+    Model->AddWithRefs(aMainSA);
+  }
+  else {
+    Handle(StepRepr_CompositeShapeAspect) aCSA;
+    for (Standard_Integer i = 1; i <= theShapeSeqL.Length(); i++) {
+      TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(theShapeSeqL.Value(i));
+      Handle(StepRepr_ShapeAspect) aSA = WriteShapeAspect(WS, theGeomTolL, aShape, dummyRC, dummyGISU);
+      if (aSA.IsNull())
+        continue;
+      if (aCSA.IsNull()) {
+        aCSA = new StepRepr_CompositeShapeAspect();
+        aCSA->Init(aSA->Name(), aSA->Description(), aSA->OfShape(), aSA->ProductDefinitional());
+        Model->AddWithRefs(aCSA);
+      }
+      Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship();
+      aSAR->Init(new TCollection_HAsciiString(), Standard_False, NULL, aCSA, aSA);
+      Model->AddWithRefs(aSAR);
+    }
+    aMainSA = aCSA;
+  }
+  StepDimTol_GeometricToleranceTarget aGTTarget;
+  aGTTarget.SetValue(aMainSA);
+
+  Standard_Boolean isWithModif = Standard_False,
+                   isWithDatRef = Standard_False,
+                   isWithMaxTol = Standard_False;
+  // Modifiers
+  // Simple modifiers
+  XCAFDimTolObjects_GeomToleranceModifiersSequence aModifiers = anObject->GetModifiers();
+  Handle(StepDimTol_HArray1OfGeometricToleranceModifier) aModifArray;
+  Handle(StepBasic_LengthMeasureWithUnit) aMaxLMWU;
+  Standard_Integer aModifNb = aModifiers.Length();
+  if (anObject->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None)
+      aModifNb++;
+  for (Standard_Integer i = 1; i < aModifiers.Length(); i++)
+    if (aModifiers.Value(i) == XCAFDimTolObjects_GeomToleranceModif_All_Around ||
+        aModifiers.Value(i) == XCAFDimTolObjects_GeomToleranceModif_All_Over)
+        aModifNb--;
+  if (aModifNb > 0) {
+    isWithModif = Standard_True;
+    aModifArray = new StepDimTol_HArray1OfGeometricToleranceModifier(1, aModifNb);
+    Standard_Integer k = 1;
+    for (Standard_Integer i = 1; i <= aModifiers.Length(); i++) {
+      if (aModifiers.Value(i) == XCAFDimTolObjects_GeomToleranceModif_All_Around ||
+        aModifiers.Value(i) == XCAFDimTolObjects_GeomToleranceModif_All_Over)
+        continue;
+      StepDimTol_GeometricToleranceModifier aModif = 
+        STEPConstruct_GDTProperty::GetGeomToleranceModifier(aModifiers.Value(i));
+      aModifArray->SetValue(k, aModif);
+      k++;
+    }
+    if (anObject->GetMaterialRequirementModifier() == XCAFDimTolObjects_GeomToleranceMatReqModif_L) {
+      aModifArray->SetValue(aModifNb, StepDimTol_GTMLeastMaterialRequirement);
+    }
+    else if (anObject->GetMaterialRequirementModifier() == XCAFDimTolObjects_GeomToleranceMatReqModif_M) {
+      aModifArray->SetValue(aModifNb, StepDimTol_GTMMaximumMaterialRequirement);
+    }
+    // Modifier with value
+    if (anObject->GetMaxValueModifier() != 0) {
+      isWithMaxTol = Standard_True;
+      aMaxLMWU = new StepBasic_LengthMeasureWithUnit();
+      Handle(StepBasic_MeasureValueMember) aValueMember = new StepBasic_MeasureValueMember();
+      aValueMember->SetName("LENGTH_MEASURE");
+      aValueMember->SetReal(anObject->GetMaxValueModifier());
+      aMaxLMWU->Init(aValueMember, aUnit);
+      Model->AddWithRefs(aMaxLMWU);
+    }
+  }
+
+  // Datum Reference
+  isWithDatRef = !theDatumSystem.IsNull();
+
+  // Collect all attributes
+  Handle(TCollection_HAsciiString) aName = new TCollection_HAsciiString(),
+                                  aDescription = new TCollection_HAsciiString();
+  Handle(StepDimTol_GeometricToleranceWithDatumReference) aGTWDR = 
+    new StepDimTol_GeometricToleranceWithDatumReference();
+  aGTWDR->SetDatumSystem(theDatumSystem);
+  Handle(StepDimTol_GeometricToleranceWithModifiers) aGTWM = 
+    new StepDimTol_GeometricToleranceWithModifiers();
+  aGTWM->SetModifiers(aModifArray);
+  StepDimTol_GeometricToleranceType aType = 
+    STEPConstruct_GDTProperty::GetGeomToleranceType(anObject->GetType());
+
+  // Init and write necessary subtype of Geometric_Tolerance entity
+  Handle(StepDimTol_GeometricTolerance) aGeomTol;
+  if (isWithModif) {
+    if (isWithMaxTol) {
+      if (isWithDatRef) {
+        // Geometric_Tolerance & Geometric_Tolerance_With_Datum_Reference & 
+        //Geometric_Tolerance_With_Maximum_Tolerance & Geometric_Tolerance_With_Modifiers
+        Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol) aResult =
+          new StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol();
+        aResult->Init(aName, aDescription, aLMWU, aGTTarget, aGTWDR, aGTWM, aMaxLMWU, aType);
+        aGeomTol = aResult;
+      }
+      else {
+        // Geometric_Tolerance & Geometric_Tolerance_With_Maximum_Tolerance & Geometric_Tolerance_With_Modifiers
+        Handle(StepDimTol_GeoTolAndGeoTolWthMaxTol) aResult =
+          new StepDimTol_GeoTolAndGeoTolWthMaxTol();
+        aResult->Init(aName, aDescription, aLMWU, aGTTarget, aGTWM, aMaxLMWU, aType);
+        aGeomTol = aResult;
+      }
+    }
+    else {
+      if (isWithDatRef) {
+        // Geometric_Tolerance & Geometric_Tolerance_With_Datum_Reference & Geometric_Tolerance_With_Modifiers
+        Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod) aResult =
+          new StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod();
+        aResult->Init(aName, aDescription, aLMWU, aGTTarget, aGTWDR, aGTWM, aType);
+        aGeomTol = aResult;
+      }
+      else {
+        // Geometric_Tolerance & Geometric_Tolerance_With_Modifiers
+        Handle(StepDimTol_GeoTolAndGeoTolWthMod) aResult =
+          new StepDimTol_GeoTolAndGeoTolWthMod();
+        aResult->Init(aName, aDescription, aLMWU, aGTTarget, aGTWM, aType);
+        aGeomTol = aResult;
+      }
+    }
+  }
+  else {
+    if (isWithDatRef) {
+      // Geometric_Tolerance & Geometric_Tolerance_With_Datum_Reference
+      Handle(StepDimTol_GeoTolAndGeoTolWthDatRef) aResult =
+          new StepDimTol_GeoTolAndGeoTolWthDatRef();
+        aResult->Init(aName, aDescription, aLMWU, aGTTarget, aGTWDR, aType);
+        aGeomTol = aResult;
+    }
+    else {
+      // Geometric_Tolerance
+      Handle(StepDimTol_GeometricTolerance) aResult = 
+        STEPConstruct_GDTProperty::GetGeomTolerance(anObject->GetType());
+      if (!aResult.IsNull()) {
+        aResult->Init(aName, aDescription, aLMWU, aGTTarget);
+        aGeomTol = aResult;
+      }
+    }
+  }
+  Model->AddWithRefs(aGeomTol);
+  WriteToleranceZone(WS, anObject, aGeomTol, theRC);
+}
 
 //=======================================================================
 //function : WriteDGTs
 //purpose  : 
 //=======================================================================
-
 Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSession) &WS,
                                                    const TDF_LabelSequence  &labels ) const
 {
   
   if ( labels.Length() <=0 ) return Standard_False;
-
+  
   // get working data
   Handle(Interface_InterfaceModel) Model = WS->Model();
   Handle(XSControl_TransferWriter) TW = WS->TransferWriter();
@@ -2070,9 +3112,16 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSe
   if(DGTTool.IsNull() ) return Standard_False;
 
   TDF_LabelSequence DGTLabels;
+
+  // Check for number of Application Protocol
+  DGTTool->GetDimTolLabels(DGTLabels);
+  if (DGTLabels.Length() == 0)
+    return WriteDGTsAP242(WS, labels);
+
   STEPConstruct_DataMapOfAsciiStringTransient DatumMap;
 
   // write Datums
+  DGTLabels.Clear();
   DGTTool->GetDatumLabels(DGTLabels);
   if(DGTLabels.Length()<=0) return Standard_False;
   Standard_Integer i;
@@ -2402,6 +3451,217 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSe
   return Standard_True;
 }
 
+//=======================================================================
+//function : WriteDGTsAP242
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean STEPCAFControl_Writer::WriteDGTsAP242 (const Handle(XSControl_WorkSession) &WS,
+                                                        const TDF_LabelSequence  &labels ) const
+{
+  // Get working data
+  Handle(Interface_InterfaceModel) aModel = WS->Model();
+  Handle(XSControl_TransferWriter) TW = WS->TransferWriter();
+  Handle(Transfer_FinderProcess) FP = TW->FinderProcess();
+
+  const Handle(Interface_HGraph) aHGraph = WS->HGraph();
+  if(aHGraph.IsNull())
+    return Standard_False;
+
+  Interface_Graph aGraph = aHGraph->Graph();
+  Handle(XCAFDoc_DimTolTool) DGTTool = XCAFDoc_DocumentTool::DimTolTool(labels(1));
+  if(DGTTool.IsNull())
+    return Standard_False;
+
+  TDF_LabelSequence aDGTLabels;
+  STEPConstruct_DataMapOfAsciiStringTransient aDatumMap;
+  Handle(StepRepr_RepresentationContext) aRC;
+
+  //------------- //
+  // write Datums //
+  //--------------//
+  DGTTool->GetDatumLabels(aDGTLabels);
+  // Find all shapes with datums
+  TColStd_MapOfAsciiString aNameIdMap;
+  for(Standard_Integer i = 1; i <= aDGTLabels.Length(); i++) {
+    TDF_Label aDatumL = aDGTLabels.Value(i);
+    TDF_LabelSequence aShapeL;
+    TDF_LabelSequence aNullSeq;
+    if(!DGTTool->GetRefShapeLabel(aDatumL, aShapeL, aNullSeq))
+      continue;
+    Handle(XCAFDoc_Datum) aDatumAttr;
+    aDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr);
+    Handle(XCAFDimTolObjects_DatumObject) anObject = aDatumAttr->GetObject();
+    TCollection_AsciiString aDatumName = anObject->GetName()->String();
+    TCollection_AsciiString aDatumTargetId = TCollection_AsciiString(anObject->GetDatumTargetNumber());
+    if (!aNameIdMap.Add(aDatumName.Cat(aDatumTargetId)))
+      continue;
+    Handle(StepDimTol_Datum) aWrittenDatum;
+    Standard_Boolean isFirstDT = !aDatumMap.Find(aDatumName, aWrittenDatum);
+    Handle(StepDimTol_Datum) aDatum = WriteDatumAP242(WS, aShapeL.First(), aDatumL, isFirstDT, aWrittenDatum);
+    // Add created Datum into Map
+    aDatumMap.Bind(aDatumName, aDatum);
+  }
+
+  //----------------- //
+  // write Dimensions //
+  //------------------//
+  aDGTLabels.Clear();
+  DGTTool->GetDimensionLabels(aDGTLabels);
+  for (Standard_Integer i = 1; i <= aDGTLabels.Length(); i++) {
+    TDF_Label aDimensionL = aDGTLabels.Value(i);
+    TDF_LabelSequence aFirstShapeL, aSecondShapeL;
+    if (!DGTTool->GetRefShapeLabel(aDimensionL, aFirstShapeL, aSecondShapeL))
+      continue;
+    Handle(XCAFDoc_Dimension) aDimAttr;
+    if (!aDimensionL.FindAttribute(XCAFDoc_Dimension::GetID(),aDimAttr)) 
+      continue;
+    Handle(XCAFDimTolObjects_DimensionObject) anObject = aDimAttr->GetObject();
+    if (anObject.IsNull())
+      continue;
+
+    // Write links with shapes
+    Handle(StepRepr_RepresentationContext) dummyRC;
+    Handle(StepAP242_GeometricItemSpecificUsage) dummyGISU;
+    Handle(StepRepr_ShapeAspect) aFirstSA, aSecondSA;
+    if (aFirstShapeL.Length() == 1) {
+      TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aFirstShapeL.Value(1));
+      aFirstSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU);
+      if (aRC.IsNull() && !dummyRC.IsNull())
+        aRC = dummyRC;
+    }
+    else if (aFirstShapeL.Length() > 1) {
+      Handle(StepRepr_CompositeShapeAspect) aCSA;
+      for (Standard_Integer shIt = 1; shIt <= aFirstShapeL.Length(); shIt++) {
+        TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aFirstShapeL.Value(shIt));
+        Handle(StepRepr_ShapeAspect) aSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU);
+        if (aCSA.IsNull() && !aSA.IsNull())
+          aCSA = new StepRepr_CompositeShapeAspect();
+          aCSA->Init(aSA->Name(), aSA->Description(), aSA->OfShape(), aSA->ProductDefinitional());
+          aModel->AddWithRefs(aCSA);
+        if (!aSA.IsNull()) {
+          Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship();
+          aSAR->Init(new TCollection_HAsciiString(), Standard_False, new TCollection_HAsciiString(), aCSA, aSA);
+          aModel->AddWithRefs(aSAR);
+        }
+        if (aRC.IsNull() && !dummyRC.IsNull())
+          aRC = dummyRC;
+      }
+      aFirstSA = aCSA;
+    }
+    if (aSecondShapeL.Length() == 1) {
+      TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aSecondShapeL.Value(1));
+      aSecondSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU);
+      if (aRC.IsNull() && !dummyRC.IsNull())
+        aRC = dummyRC;
+    }
+    else if (aSecondShapeL.Length() > 1) {
+      Handle(StepRepr_CompositeShapeAspect) aCSA;
+      for (Standard_Integer shIt = 1; shIt <= aSecondShapeL.Length(); shIt++) {
+        TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(aSecondShapeL.Value(shIt));
+        Handle(StepRepr_ShapeAspect) aSA = WriteShapeAspect(WS, aDimensionL, aShape, dummyRC, dummyGISU);
+        if (aCSA.IsNull() && !aSA.IsNull())
+          aCSA = new StepRepr_CompositeShapeAspect();
+          aCSA->Init(aSA->Name(), aSA->Description(), aSA->OfShape(), aSA->ProductDefinitional());
+        if (!aSA.IsNull()) {
+          Handle(StepRepr_ShapeAspectRelationship) aSAR = new StepRepr_ShapeAspectRelationship();
+          aSAR->Init(new TCollection_HAsciiString(), Standard_False, new TCollection_HAsciiString(), aCSA, aSA);
+          aModel->AddWithRefs(aSAR);
+        }
+        if (aRC.IsNull() && !dummyRC.IsNull())
+          aRC = dummyRC;
+      }
+      aSecondSA = aCSA;
+    }
+
+    // Write dimensions
+    StepShape_DimensionalCharacteristic aDimension;
+    XCAFDimTolObjects_DimensionType aDimType = anObject->GetType();
+    if (STEPConstruct_GDTProperty::IsDimensionalLocation(aDimType)) {
+      // Dimensional_Location
+      Handle(StepShape_DimensionalLocation) aDim = new StepShape_DimensionalLocation();
+      aDim->Init(STEPConstruct_GDTProperty::GetDimTypeName(aDimType), Standard_False, NULL, aFirstSA, aSecondSA);
+      aDimension.SetValue(aDim);
+    }
+    else if (aDimType == XCAFDimTolObjects_DimensionType_Location_Angular) {
+      // Angular_Location
+      Handle(StepShape_AngularLocation) aDim = new StepShape_AngularLocation();
+      StepShape_AngleRelator aRelator = StepShape_Equal;
+      if (anObject->HasQualifier()) {
+        XCAFDimTolObjects_DimensionQualifier aQualifier = anObject->GetQualifier();
+        switch (aQualifier) {
+          case XCAFDimTolObjects_DimensionQualifier_Min: aRelator = StepShape_Small;
+            break;
+          case XCAFDimTolObjects_DimensionQualifier_Max: aRelator = StepShape_Large;
+            break;
+          default: aRelator = StepShape_Equal;
+        }
+      }
+      aDim->Init(new TCollection_HAsciiString(), Standard_False, NULL, aFirstSA, aSecondSA, aRelator);
+      aDimension.SetValue(aDim);
+    }
+    else if (aDimType == XCAFDimTolObjects_DimensionType_Location_WithPath) {
+      // Dimensional_Location_With_Path
+      Handle(StepShape_DimensionalLocationWithPath) aDim = new StepShape_DimensionalLocationWithPath();
+      Handle(StepRepr_ShapeAspect) aPathSA = WriteShapeAspect(WS, aDimensionL, anObject->GetPath(), dummyRC, dummyGISU);
+      aDim->Init(new TCollection_HAsciiString(), Standard_False, NULL, aFirstSA, aSecondSA, aPathSA);
+      aDimension.SetValue(aDim);
+    }
+    else if (STEPConstruct_GDTProperty::IsDimensionalSize(aDimType)) {
+      // Dimensional_Size
+      Handle(StepShape_DimensionalSize) aDim = new StepShape_DimensionalSize();
+      aDim->Init(aFirstSA, STEPConstruct_GDTProperty::GetDimTypeName(aDimType));
+      aDimension.SetValue(aDim);
+    }
+    else if (aDimType == XCAFDimTolObjects_DimensionType_Size_Angular) {
+      // Angular_Size
+      Handle(StepShape_AngularSize) aDim = new StepShape_AngularSize();
+      StepShape_AngleRelator aRelator = StepShape_Equal;
+      if (anObject->HasQualifier()) {
+        XCAFDimTolObjects_DimensionQualifier aQualifier = anObject->GetQualifier();
+        switch (aQualifier) {
+          case XCAFDimTolObjects_DimensionQualifier_Min: aRelator = StepShape_Small;
+            break;
+          case XCAFDimTolObjects_DimensionQualifier_Max: aRelator = StepShape_Large;
+            break;
+          default: aRelator = StepShape_Equal;
+        }
+      }
+      aDim->Init(aFirstSA, new TCollection_HAsciiString(), aRelator);
+      aDimension.SetValue(aDim);
+    }
+    else if (aDimType == XCAFDimTolObjects_DimensionType_Size_WithPath) {
+      // Dimensional_Size_With_Path
+      Handle(StepShape_DimensionalSizeWithPath) aDim = new StepShape_DimensionalSizeWithPath();
+      Handle(StepRepr_ShapeAspect) aPathSA = WriteShapeAspect(WS, aDimensionL, anObject->GetPath(), dummyRC, dummyGISU);
+      aDim->Init(aFirstSA, new TCollection_HAsciiString(), aPathSA);
+      aDimension.SetValue(aDim);
+    }
+
+    // Write values
+    WriteDimValues(WS, anObject, aRC, aDimension);
+  }
+
+  //----------------------------//
+  // write Geometric Tolerances //
+  //----------------------------//
+  aDGTLabels.Clear();
+  DGTTool->GetGeomToleranceLabels(aDGTLabels);
+  for (Standard_Integer i = 1; i <= aDGTLabels.Length(); i++) {
+    TDF_Label aGeomTolL = aDGTLabels.Value(i);
+    TDF_LabelSequence aFirstShapeL, aNullSeqL;
+    if (!DGTTool->GetRefShapeLabel(aGeomTolL, aFirstShapeL, aNullSeqL))
+      continue;
+    TDF_LabelSequence aDatumSeq;
+    DGTTool->GetDatumWithObjectOfTolerLabels(aGeomTolL, aDatumSeq);
+    Handle(StepDimTol_HArray1OfDatumSystemOrReference) aDatumSystem;
+    if (aDatumSeq.Length() > 0)
+      aDatumSystem = WriteDatumSystem(WS, aGeomTolL, aDatumSeq, aDatumMap, aRC);
+    WriteGeomTolerance(WS, aFirstShapeL, aGeomTolL, aDatumSystem, aRC);
+  }
+
+  return Standard_True;
+}
 
 //=======================================================================
 //function : FindPDSforRI
index 250bf21..4223f2a 100644 (file)
@@ -38,7 +38,6 @@ class STEPCAFControl_ExternFile;
 class STEPControl_Writer;
 class TopoDS_Shape;
 
-
 //! Provides a tool to write DECAF document to the
 //! STEP file. Besides transfer of shapes (including
 //! assemblies) provided by STEPControl, supports also
@@ -175,6 +174,9 @@ protected:
   //! Write D&GTs assigned to specified labels, to STEP model
   Standard_EXPORT Standard_Boolean WriteDGTs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
   
+   //! Write D&GTs assigned to specified labels, to STEP model, according AP242
+  Standard_EXPORT Standard_Boolean WriteDGTsAP242 (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
+
   //! Write materials assigned to specified labels, to STEP model
   Standard_EXPORT Standard_Boolean WriteMaterials (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) const;
   
index 59cdd34..13f8576 100644 (file)
 // commercial license or contractual agreement.
 
 #include <STEPConstruct_GDTProperty.hxx>
+#include <StepBasic_MeasureValueMember.hxx>
+#include <StepGeom_CartesianPoint.hxx>
+#include <StepGeom_Direction.hxx>
+#include <StepDimTol_CylindricityTolerance.hxx>
+#include <StepDimTol_FlatnessTolerance.hxx>
+#include <StepDimTol_LineProfileTolerance.hxx>
+#include <StepDimTol_PositionTolerance.hxx>
+#include <StepDimTol_RoundnessTolerance.hxx>
+#include <StepDimTol_StraightnessTolerance.hxx>
+#include <StepDimTol_SurfaceProfileTolerance.hxx>
 #include <StepRepr_DescriptiveRepresentationItem.hxx>
-   
+#include <XCAFDimTolObjects_DatumModifiersSequence.hxx>
+#include <XCAFDimTolObjects_DatumModifWithValue.hxx>
+
 //=======================================================================
 //function : STEPConstruct_GDTProperty
 //purpose  : 
@@ -598,3 +610,715 @@ Standard_Boolean STEPConstruct_GDTProperty::GetTolValueType(const Handle(TCollec
     }
     return Standard_False;
 }
+
+
+//=======================================================================
+//function : GetDimTypeName
+//purpose  : 
+//=======================================================================
+Handle(TCollection_HAsciiString) STEPConstruct_GDTProperty::GetDimTypeName(const XCAFDimTolObjects_DimensionType theType)
+{
+  Handle(TCollection_HAsciiString) aName;
+        switch (theType) {
+        // Dimensional_Location
+        case XCAFDimTolObjects_DimensionType_Location_CurvedDistance:
+          aName = new TCollection_HAsciiString("curved distance");
+          break;
+        case XCAFDimTolObjects_DimensionType_Location_LinearDistance:
+          aName = new TCollection_HAsciiString("linear distance");
+          break;
+        case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToOuter:
+          aName = new TCollection_HAsciiString("linear distance centre outer");
+          break;
+        case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToInner:
+          aName = new TCollection_HAsciiString("linear distance centre inner");
+          break;
+        case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToCenter:
+          aName = new TCollection_HAsciiString("linear distance outer centre");
+          break;
+        case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToOuter:
+          aName = new TCollection_HAsciiString("linear distance outer outer");
+          break;
+        case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToInner:
+          aName = new TCollection_HAsciiString("linear distance outer inner");
+          break;
+        case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToCenter:
+          aName = new TCollection_HAsciiString("linear distance inner centre");
+          break;
+        case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToOuter:
+          aName = new TCollection_HAsciiString("linear distance inner outer");
+          break;
+        case XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToInner:
+          aName = new TCollection_HAsciiString("linear distance inner inner");
+          break;
+        //Dimensional_Size
+        case XCAFDimTolObjects_DimensionType_Size_CurveLength:
+          aName = new TCollection_HAsciiString("curve length");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_Diameter:
+          aName = new TCollection_HAsciiString("diameter");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_SphericalDiameter:
+          aName = new TCollection_HAsciiString("spherical diameter");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_Radius:
+          aName = new TCollection_HAsciiString("radius");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_SphericalRadius:
+          aName = new TCollection_HAsciiString("spherical radius");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_ToroidalMinorDiameter:
+          aName = new TCollection_HAsciiString("toroidal minor diameter");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_ToroidalMajorDiameter:
+          aName = new TCollection_HAsciiString("toroidal major diameter");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_ToroidalMinorRadius:
+          aName = new TCollection_HAsciiString("toroidal minor radius");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_ToroidalMajorRadius:
+          aName = new TCollection_HAsciiString("toroidal major radius");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorDiameter:
+          aName = new TCollection_HAsciiString("toroidal high major diameter");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorDiameter:
+          aName = new TCollection_HAsciiString("toroidal low major diameter");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorRadius:
+          aName = new TCollection_HAsciiString("toroidal high major radius");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorRadius:
+          aName = new TCollection_HAsciiString("toroidal low major radius");
+          break;
+        case XCAFDimTolObjects_DimensionType_Size_Thickness:
+          aName = new TCollection_HAsciiString("thickness");
+          break;
+        // Other entities
+        default:
+          aName = new TCollection_HAsciiString();
+      }
+  return aName;
+}
+
+//=======================================================================
+//function : GetDimQualifierName
+//purpose  : 
+//=======================================================================
+Handle(TCollection_HAsciiString) STEPConstruct_GDTProperty::GetDimQualifierName(const XCAFDimTolObjects_DimensionQualifier theQualifier)
+{
+  Handle(TCollection_HAsciiString) aName;
+  switch (theQualifier) {
+    case XCAFDimTolObjects_DimensionQualifier_Min:
+      aName = new TCollection_HAsciiString("minimum");
+      break;
+    case XCAFDimTolObjects_DimensionQualifier_Avg:
+      aName = new TCollection_HAsciiString("average");
+      break;
+    case XCAFDimTolObjects_DimensionQualifier_Max:
+      aName = new TCollection_HAsciiString("maximum");
+      break;
+    default:
+      aName = new TCollection_HAsciiString();
+  }
+  return aName;
+}
+
+//=======================================================================
+//function : GetDimModifierName
+//purpose  : 
+//=======================================================================
+Handle(TCollection_HAsciiString) STEPConstruct_GDTProperty::GetDimModifierName(const XCAFDimTolObjects_DimensionModif theModifier)
+{
+  Handle(TCollection_HAsciiString) aName;
+  switch (theModifier) {
+    case XCAFDimTolObjects_DimensionModif_ControlledRadius:
+      aName = new TCollection_HAsciiString("controlled radius");
+      break;
+    case XCAFDimTolObjects_DimensionModif_Square:
+      aName = new TCollection_HAsciiString("square");
+      break;
+    case XCAFDimTolObjects_DimensionModif_StatisticalTolerance:
+      aName = new TCollection_HAsciiString("statistical");
+      break;
+    case XCAFDimTolObjects_DimensionModif_ContinuousFeature:
+      aName = new TCollection_HAsciiString("continuous feature");
+      break;
+    case XCAFDimTolObjects_DimensionModif_TwoPointSize:
+      aName = new TCollection_HAsciiString("two point size");
+      break;
+    case XCAFDimTolObjects_DimensionModif_LocalSizeDefinedBySphere:
+      aName = new TCollection_HAsciiString("local size defined by a sphere");
+      break;
+    case XCAFDimTolObjects_DimensionModif_LeastSquaresAssociationCriterion:
+      aName = new TCollection_HAsciiString("least squares association criteria");
+      break;
+    case XCAFDimTolObjects_DimensionModif_MaximumInscribedAssociation:
+      aName = new TCollection_HAsciiString("maximum inscribed association criteria");
+      break;
+    case XCAFDimTolObjects_DimensionModif_MinimumCircumscribedAssociation:
+      aName = new TCollection_HAsciiString("minimum circumscribed association criteria");
+      break;
+    case XCAFDimTolObjects_DimensionModif_CircumferenceDiameter:
+      aName = new TCollection_HAsciiString("circumference diameter calculated size");
+      break;
+    case XCAFDimTolObjects_DimensionModif_AreaDiameter:
+      aName = new TCollection_HAsciiString("area diameter calculated size");
+      break;
+    case XCAFDimTolObjects_DimensionModif_VolumeDiameter:
+      aName = new TCollection_HAsciiString("volume diameter calculated size");
+      break;
+    case XCAFDimTolObjects_DimensionModif_MaximumSize:
+      aName = new TCollection_HAsciiString("maximum rank order size");
+      break;
+    case XCAFDimTolObjects_DimensionModif_MinimumSize:
+      aName = new TCollection_HAsciiString("minimum rank order size");
+      break;
+    case XCAFDimTolObjects_DimensionModif_AverageSize:
+      aName = new TCollection_HAsciiString("average rank order size");
+      break;
+    case XCAFDimTolObjects_DimensionModif_MedianSize:
+      aName = new TCollection_HAsciiString("median rank order size");
+      break;
+    case XCAFDimTolObjects_DimensionModif_MidRangeSize:
+      aName = new TCollection_HAsciiString("mid range rank order size");
+      break;
+    case XCAFDimTolObjects_DimensionModif_RangeOfSizes:
+      aName = new TCollection_HAsciiString("range rank order size");
+      break;
+    case XCAFDimTolObjects_DimensionModif_AnyRestrictedPortionOfFeature:
+      aName = new TCollection_HAsciiString("any part of the feature");
+      break;
+    case XCAFDimTolObjects_DimensionModif_AnyCrossSection:
+      aName = new TCollection_HAsciiString("any cross section");
+      break;
+    case XCAFDimTolObjects_DimensionModif_SpecificFixedCrossSection:
+      aName = new TCollection_HAsciiString("specific fixed cross section");
+      break;
+    case XCAFDimTolObjects_DimensionModif_CommonTolerance:
+      aName = new TCollection_HAsciiString("common tolerance");
+      break;
+    case XCAFDimTolObjects_DimensionModif_FreeStateCondition:
+      aName = new TCollection_HAsciiString("free state condition");
+      break;
+    default: aName = new TCollection_HAsciiString();
+  }
+  return aName;
+}
+
+//=======================================================================
+//function : GetLimitsAndFits
+//purpose  : 
+//=======================================================================
+Handle(StepShape_LimitsAndFits) STEPConstruct_GDTProperty::GetLimitsAndFits(Standard_Boolean theHole,
+                       XCAFDimTolObjects_DimensionFormVariance theFormVariance,
+                       XCAFDimTolObjects_DimensionGrade theGrade)
+{
+  Handle(StepShape_LimitsAndFits) aLAF = new StepShape_LimitsAndFits();
+  Handle(TCollection_HAsciiString) aGradeStr, aFormStr, aHoleStr;
+  
+  if (theGrade == XCAFDimTolObjects_DimensionGrade_IT01)
+      aGradeStr = new TCollection_HAsciiString("01");
+    else
+      aGradeStr = new TCollection_HAsciiString((Standard_Integer)theGrade + 1);
+  
+  switch (theFormVariance) {
+    case XCAFDimTolObjects_DimensionFormVariance_None:
+      aFormStr = new TCollection_HAsciiString("");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_A:
+      aFormStr = new TCollection_HAsciiString("A");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_B:
+      aFormStr = new TCollection_HAsciiString("B");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_C:
+      aFormStr = new TCollection_HAsciiString("C");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_CD:
+      aFormStr = new TCollection_HAsciiString("CD");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_D:
+      aFormStr = new TCollection_HAsciiString("D");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_E:
+      aFormStr = new TCollection_HAsciiString("E");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_EF:
+      aFormStr = new TCollection_HAsciiString("EF");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_F:
+      aFormStr = new TCollection_HAsciiString("F");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_FG:
+      aFormStr = new TCollection_HAsciiString("FG");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_G:
+      aFormStr = new TCollection_HAsciiString("G");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_H:
+      aFormStr = new TCollection_HAsciiString("H");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_JS:
+      aFormStr = new TCollection_HAsciiString("JS");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_J:
+      aFormStr = new TCollection_HAsciiString("J");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_K:
+      aFormStr = new TCollection_HAsciiString("K");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_M:
+      aFormStr = new TCollection_HAsciiString("M");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_N:
+      aFormStr = new TCollection_HAsciiString("N");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_P:
+      aFormStr = new TCollection_HAsciiString("P");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_R:
+      aFormStr = new TCollection_HAsciiString("R");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_S:
+      aFormStr = new TCollection_HAsciiString("S");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_T:
+      aFormStr = new TCollection_HAsciiString("T");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_U:
+      aFormStr = new TCollection_HAsciiString("U");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_V:
+      aFormStr = new TCollection_HAsciiString("V");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_X:
+      aFormStr = new TCollection_HAsciiString("X");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_Y:
+      aFormStr = new TCollection_HAsciiString("Y");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_Z:
+      aFormStr = new TCollection_HAsciiString("Z");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_ZA:
+      aFormStr = new TCollection_HAsciiString("ZA");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_ZB:
+      aFormStr = new TCollection_HAsciiString("ZB");
+      break;
+    case XCAFDimTolObjects_DimensionFormVariance_ZC:
+      aFormStr = new TCollection_HAsciiString("ZC");
+      break;
+  }
+
+  if (theHole) {
+    aHoleStr = new TCollection_HAsciiString("hole");
+  }
+  else {
+    aHoleStr = new TCollection_HAsciiString("shaft");
+    aFormStr->LowerCase();
+  }
+  aLAF->Init(aFormStr, aHoleStr, aGradeStr, new TCollection_HAsciiString);
+  return aLAF;
+}
+
+//=======================================================================
+//function : GetDatumTargetName
+//purpose  : 
+//=======================================================================
+Handle(TCollection_HAsciiString) STEPConstruct_GDTProperty::GetDatumTargetName(const XCAFDimTolObjects_DatumTargetType theDatumType)
+{
+  Handle(TCollection_HAsciiString) aName;
+  switch (theDatumType) {
+    case XCAFDimTolObjects_DatumTargetType_Point:
+      aName = new TCollection_HAsciiString("point");
+      break;
+    case XCAFDimTolObjects_DatumTargetType_Line:
+      aName = new TCollection_HAsciiString("line");
+      break;
+    case XCAFDimTolObjects_DatumTargetType_Rectangle:
+      aName = new TCollection_HAsciiString("rectangle");
+      break;
+    case XCAFDimTolObjects_DatumTargetType_Circle:
+      aName = new TCollection_HAsciiString("circle");
+      break;
+    case XCAFDimTolObjects_DatumTargetType_Area:
+      aName = new TCollection_HAsciiString("area");
+      break;
+    default: aName = new TCollection_HAsciiString();
+  }
+  return aName;
+}
+
+//=======================================================================
+//function : GetAxis2Placement3D
+//purpose  : 
+//=======================================================================
+Handle(StepGeom_Axis2Placement3d) STEPConstruct_GDTProperty::GetAxis2Placement3D(const gp_Ax2 theAxis)
+{
+  Handle(StepGeom_Axis2Placement3d) anA2P3D = new StepGeom_Axis2Placement3d();
+  Handle(StepGeom_CartesianPoint) aPoint = new StepGeom_CartesianPoint();
+  Handle(TColStd_HArray1OfReal) aCoords = new TColStd_HArray1OfReal(1, 3);
+  for (Standard_Integer i = 1; i <= 3; i++)
+    aCoords->SetValue(i, theAxis.Location().Coord(i));
+  aPoint->Init(new TCollection_HAsciiString(), aCoords);
+  Handle(StepGeom_Direction) anAxis, aRefDirection;
+  Handle(TColStd_HArray1OfReal) anAxisCoords = new TColStd_HArray1OfReal(1, 3);
+  for (Standard_Integer i = 1; i <= 3; i++)
+    anAxisCoords->SetValue(i, theAxis.Direction().Coord(i));
+  anAxis = new StepGeom_Direction();
+  anAxis->Init(new TCollection_HAsciiString(), anAxisCoords);
+  Handle(TColStd_HArray1OfReal) aDirCoords = new TColStd_HArray1OfReal(1, 3);
+  for (Standard_Integer i = 1; i <= 3; i++)
+    aDirCoords->SetValue(i, theAxis.XDirection().Coord(i));
+  aRefDirection = new StepGeom_Direction();
+  aRefDirection->Init(new TCollection_HAsciiString(), aDirCoords);
+  anA2P3D->Init(new TCollection_HAsciiString("orientation"), aPoint, Standard_True, anAxis, Standard_True, aRefDirection);
+  return anA2P3D;
+}
+
+//=======================================================================
+//function : IsDimensionalSize
+//purpose  : 
+//=======================================================================
+Standard_Boolean STEPConstruct_GDTProperty::IsDimensionalLocation(const XCAFDimTolObjects_DimensionType theType)
+{
+  if (theType == XCAFDimTolObjects_DimensionType_Location_None ||
+      theType == XCAFDimTolObjects_DimensionType_Location_CurvedDistance  ||
+      theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance ||
+      theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToOuter ||
+      theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToInner ||
+      theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToCenter ||
+      theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToOuter ||
+      theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToInner ||
+      theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToCenter ||
+      theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToOuter ||
+      theType == XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToInner ||
+      theType == XCAFDimTolObjects_DimensionType_Location_Oriented)
+    return Standard_True;
+  return Standard_False;
+}
+
+//=======================================================================
+//function : IsDimensionalSize
+//purpose  : 
+//=======================================================================
+Standard_Boolean STEPConstruct_GDTProperty::IsDimensionalSize(const XCAFDimTolObjects_DimensionType theType)
+{
+  if (theType == XCAFDimTolObjects_DimensionType_Size_CurveLength ||
+      theType == XCAFDimTolObjects_DimensionType_Size_Diameter ||
+      theType == XCAFDimTolObjects_DimensionType_Size_SphericalDiameter ||
+      theType == XCAFDimTolObjects_DimensionType_Size_Radius ||
+      theType == XCAFDimTolObjects_DimensionType_Size_SphericalRadius ||
+      theType == XCAFDimTolObjects_DimensionType_Size_ToroidalMinorDiameter ||
+      theType == XCAFDimTolObjects_DimensionType_Size_ToroidalMajorDiameter ||
+      theType == XCAFDimTolObjects_DimensionType_Size_ToroidalMinorRadius ||
+      theType == XCAFDimTolObjects_DimensionType_Size_ToroidalMajorRadius ||
+      theType == XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorDiameter ||
+      theType == XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorDiameter ||
+      theType == XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorRadius ||
+      theType == XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorRadius ||
+      theType == XCAFDimTolObjects_DimensionType_Size_Thickness)
+    return Standard_True;
+  return Standard_False;
+}
+
+//=======================================================================
+//function : GetGeomToleranceType
+//purpose  : 
+//=======================================================================
+StepDimTol_GeometricToleranceType STEPConstruct_GDTProperty::GetGeomToleranceType(const XCAFDimTolObjects_GeomToleranceType theType)
+{
+  switch (theType) {
+    case XCAFDimTolObjects_GeomToleranceType_Angularity:
+      return StepDimTol_GTTAngularityTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_CircularRunout:
+      return StepDimTol_GTTCircularRunoutTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_CircularityOrRoundness:
+      return StepDimTol_GTTRoundnessTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_Coaxiality:
+      return StepDimTol_GTTCoaxialityTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_Concentricity:
+      return StepDimTol_GTTConcentricityTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_Cylindricity:
+      return StepDimTol_GTTCylindricityTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_Flatness:
+      return StepDimTol_GTTFlatnessTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_Parallelism:
+      return StepDimTol_GTTParallelismTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_Perpendicularity:
+      return StepDimTol_GTTPerpendicularityTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_Position:
+      return StepDimTol_GTTPositionTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_ProfileOfLine:
+      return StepDimTol_GTTLineProfileTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_ProfileOfSurface:
+      return StepDimTol_GTTSurfaceProfileTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_Straightness:
+      return StepDimTol_GTTStraightnessTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_Symmetry:
+      return StepDimTol_GTTSymmetryTolerance;
+    case XCAFDimTolObjects_GeomToleranceType_TotalRunout:
+      return StepDimTol_GTTTotalRunoutTolerance;
+    default:
+      return StepDimTol_GTTPositionTolerance;
+  }
+}
+
+//=======================================================================
+//function : GetGeomToleranceType
+//purpose  : 
+//=======================================================================
+XCAFDimTolObjects_GeomToleranceType STEPConstruct_GDTProperty::GetGeomToleranceType(const StepDimTol_GeometricToleranceType theType)
+{
+  switch (theType) {
+    case StepDimTol_GTTAngularityTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_Angularity;
+    case StepDimTol_GTTCircularRunoutTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_CircularRunout;
+    case StepDimTol_GTTRoundnessTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_CircularityOrRoundness;
+    case StepDimTol_GTTCoaxialityTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_Coaxiality;
+    case StepDimTol_GTTConcentricityTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_Concentricity;
+    case StepDimTol_GTTCylindricityTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_Cylindricity;
+    case StepDimTol_GTTFlatnessTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_Flatness;
+    case StepDimTol_GTTParallelismTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_Parallelism;
+    case StepDimTol_GTTPerpendicularityTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_Perpendicularity;
+    case StepDimTol_GTTPositionTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_Position;
+    case StepDimTol_GTTLineProfileTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_ProfileOfLine;
+    case StepDimTol_GTTSurfaceProfileTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_ProfileOfSurface;
+    case StepDimTol_GTTStraightnessTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_Straightness;
+    case StepDimTol_GTTSymmetryTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_Symmetry;
+    case StepDimTol_GTTTotalRunoutTolerance:
+      return XCAFDimTolObjects_GeomToleranceType_TotalRunout;
+    default:
+      return XCAFDimTolObjects_GeomToleranceType_Position;
+  }
+}
+
+//=======================================================================
+//function : GetGeomTolerance
+//purpose  : 
+//=======================================================================
+Handle(StepDimTol_GeometricTolerance) STEPConstruct_GDTProperty::
+  GetGeomTolerance(const XCAFDimTolObjects_GeomToleranceType theType)
+{
+  switch (theType) {
+    case XCAFDimTolObjects_GeomToleranceType_CircularityOrRoundness:
+      return new StepDimTol_RoundnessTolerance();
+    case XCAFDimTolObjects_GeomToleranceType_Cylindricity:
+      return new StepDimTol_CylindricityTolerance();
+    case XCAFDimTolObjects_GeomToleranceType_Flatness:
+      return new StepDimTol_FlatnessTolerance();
+    case XCAFDimTolObjects_GeomToleranceType_Position:
+      return new StepDimTol_PositionTolerance();
+    case XCAFDimTolObjects_GeomToleranceType_ProfileOfLine:
+      return new StepDimTol_LineProfileTolerance();
+    case XCAFDimTolObjects_GeomToleranceType_ProfileOfSurface:
+      return new StepDimTol_SurfaceProfileTolerance();
+    case XCAFDimTolObjects_GeomToleranceType_Straightness:
+      return new StepDimTol_StraightnessTolerance();
+    default:
+      return NULL;
+  }
+}
+
+//=======================================================================
+//function : GetGeomToleranceModifier
+//purpose  : 
+//=======================================================================
+StepDimTol_GeometricToleranceModifier STEPConstruct_GDTProperty::
+  GetGeomToleranceModifier(const XCAFDimTolObjects_GeomToleranceModif theModifier)
+{
+  switch (theModifier) {
+    case XCAFDimTolObjects_GeomToleranceModif_Any_Cross_Section:
+      return StepDimTol_GTMAnyCrossSection;
+    case XCAFDimTolObjects_GeomToleranceModif_Common_Zone:
+      return StepDimTol_GTMCommonZone;
+    case XCAFDimTolObjects_GeomToleranceModif_Each_Radial_Element:
+      return StepDimTol_GTMEachRadialElement;
+    case XCAFDimTolObjects_GeomToleranceModif_Free_State:
+      return StepDimTol_GTMFreeState;
+    case XCAFDimTolObjects_GeomToleranceModif_Least_Material_Requirement:
+      return StepDimTol_GTMLeastMaterialRequirement;
+    case XCAFDimTolObjects_GeomToleranceModif_Line_Element:
+      return StepDimTol_GTMLineElement;
+    case XCAFDimTolObjects_GeomToleranceModif_Major_Diameter:
+      return StepDimTol_GTMMajorDiameter;
+    case XCAFDimTolObjects_GeomToleranceModif_Maximum_Material_Requirement:
+      return StepDimTol_GTMMaximumMaterialRequirement;
+    case XCAFDimTolObjects_GeomToleranceModif_Minor_Diameter:
+      return StepDimTol_GTMMinorDiameter;
+    case XCAFDimTolObjects_GeomToleranceModif_Not_Convex:
+      return StepDimTol_GTMNotConvex;
+    case XCAFDimTolObjects_GeomToleranceModif_Pitch_Diameter:
+      return StepDimTol_GTMPitchDiameter;
+    case XCAFDimTolObjects_GeomToleranceModif_Reciprocity_Requirement:
+      return StepDimTol_GTMReciprocityRequirement;
+    case XCAFDimTolObjects_GeomToleranceModif_Separate_Requirement:
+      return StepDimTol_GTMSeparateRequirement;
+    case XCAFDimTolObjects_GeomToleranceModif_Statistical_Tolerance:
+      return StepDimTol_GTMStatisticalTolerance;
+    case XCAFDimTolObjects_GeomToleranceModif_Tangent_Plane:
+      return StepDimTol_GTMTangentPlane;
+    default:
+      return StepDimTol_GTMMaximumMaterialRequirement;
+  }
+}
+
+//=======================================================================
+//function : GetDatumRefModifiers
+//purpose  : Note: this function does not add anything to model
+//=======================================================================
+Handle(StepDimTol_HArray1OfDatumReferenceModifier) STEPConstruct_GDTProperty::
+  GetDatumRefModifiers(const XCAFDimTolObjects_DatumModifiersSequence theModifiers,
+                       const XCAFDimTolObjects_DatumModifWithValue theModifWithVal,
+                       const Standard_Real theValue,
+                       const StepBasic_Unit theUnit)
+{
+  if ((theModifiers.Length() == 0) && (theModifWithVal == XCAFDimTolObjects_DatumModifWithValue_None))
+    return NULL;
+  Standard_Integer aModifNb = theModifiers.Length();
+  if (theModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None)
+    aModifNb++;
+  Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModifiers =
+    new StepDimTol_HArray1OfDatumReferenceModifier(1, aModifNb);
+
+  // Modifier with value
+  if (theModifWithVal != XCAFDimTolObjects_DatumModifWithValue_None) {
+    StepDimTol_DatumReferenceModifierType aType;
+    switch (theModifWithVal) {
+      case XCAFDimTolObjects_DatumModifWithValue_CircularOrCylindrical:
+        aType = StepDimTol_CircularOrCylindrical;
+        break;
+      case XCAFDimTolObjects_DatumModifWithValue_Distance:
+        aType = StepDimTol_Distance;
+        break;
+      case XCAFDimTolObjects_DatumModifWithValue_Projected:
+        aType = StepDimTol_Projected;
+        break;
+      case XCAFDimTolObjects_DatumModifWithValue_Spherical:
+        aType = StepDimTol_Spherical;
+        break;
+      default:
+        aType = StepDimTol_Distance;
+    }
+    Handle(StepBasic_LengthMeasureWithUnit) aLMWU = new StepBasic_LengthMeasureWithUnit();
+    Handle(StepBasic_MeasureValueMember) aValueMember = new StepBasic_MeasureValueMember();
+    aValueMember->SetName("LENGTH_MEASURE");
+    aValueMember->SetReal(theValue);
+    aLMWU->Init(aValueMember, theUnit);
+    Handle(StepDimTol_DatumReferenceModifierWithValue) aModifWithVal = new StepDimTol_DatumReferenceModifierWithValue();
+    aModifWithVal->Init(aType, aLMWU);
+    StepDimTol_DatumReferenceModifier aModif;
+    aModif.SetValue(aModifWithVal);
+    aModifiers->SetValue(aModifNb, aModif);
+  }
+
+  // Simple modifiers
+  for (Standard_Integer i = 1; i <= theModifiers.Length(); i++) {
+    Handle(StepDimTol_SimpleDatumReferenceModifierMember) aSimpleModifMember = 
+      new StepDimTol_SimpleDatumReferenceModifierMember();
+    switch (theModifiers.Value(i)) {
+      case XCAFDimTolObjects_DatumSingleModif_AnyCrossSection:
+        aSimpleModifMember->SetEnumText(0, ".ANY_CROSS_SECTION.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_Any_LongitudinalSection:
+        aSimpleModifMember->SetEnumText(0, ".ANY_LONGITUDINAL_SECTION.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_Basic:
+        aSimpleModifMember->SetEnumText(0, ".BASIC.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_ContactingFeature:
+        aSimpleModifMember->SetEnumText(0, ".CONTACTING_FEATURE.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintU:
+        aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_U.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintV:
+        aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_V.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintW:
+        aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_W.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintX:
+        aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_X.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintY:
+        aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_Y.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_DegreeOfFreedomConstraintZ:
+        aSimpleModifMember->SetEnumText(0, ".DEGREE_OF_FREEDOM_CONSTRAINT_Z.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_DistanceVariable:
+        aSimpleModifMember->SetEnumText(0, ".DISTANCE_VARIABLE.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_FreeState:
+        aSimpleModifMember->SetEnumText(0, ".FREE_STATE.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_LeastMaterialRequirement:
+        aSimpleModifMember->SetEnumText(0, ".LEAST_MATERIAL_REQUIREMENT.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_Line:
+        aSimpleModifMember->SetEnumText(0, ".LINE.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_MajorDiameter:
+        aSimpleModifMember->SetEnumText(0, ".MAJOR_DIAMETER.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_MaximumMaterialRequirement:
+        aSimpleModifMember->SetEnumText(0, ".MAXIMUM_MATERIAL_REQUIREMENT.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_MinorDiameter:
+        aSimpleModifMember->SetEnumText(0, ".MINOR_DIAMETER.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_Orientation:
+        aSimpleModifMember->SetEnumText(0, ".ORIENTATION.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_PitchDiameter:
+        aSimpleModifMember->SetEnumText(0, ".PITCH_DIAMETER.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_Plane:
+        aSimpleModifMember->SetEnumText(0, ".PLANE.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_Point:
+        aSimpleModifMember->SetEnumText(0, ".POINT.");
+        break;
+      case XCAFDimTolObjects_DatumSingleModif_Translation:
+        aSimpleModifMember->SetEnumText(0, ".TRANSLATION.");
+        break;
+    }
+    StepDimTol_DatumReferenceModifier aModif;
+    aModif.SetValue(aSimpleModifMember);
+    aModifiers->SetValue(i, aModif);
+  }
+
+  return aModifiers;
+}
+
+//=======================================================================
+//function : GetTolValueType
+//purpose  : 
+//=======================================================================
+Handle(TCollection_HAsciiString) STEPConstruct_GDTProperty::GetTolValueType(const XCAFDimTolObjects_GeomToleranceTypeValue& theType)
+{
+  switch (theType) {
+    case XCAFDimTolObjects_GeomToleranceTypeValue_Diameter:
+      return new TCollection_HAsciiString("cylindrical or circular");
+    case XCAFDimTolObjects_GeomToleranceTypeValue_SphericalDiameter:
+      return new TCollection_HAsciiString("spherical");
+    default:
+      return new TCollection_HAsciiString("unknown");
+  }
+}
index 19204e2..76b0741 100644 (file)
 #include <Standard_DefineAlloc.hxx>
 #include <Standard_Handle.hxx>
 
+#include <gp_Ax2.hxx>
 #include <STEPConstruct_Tool.hxx>
 #include <Standard_Boolean.hxx>
 #include <Standard_CString.hxx>
+#include <StepBasic_Unit.hxx>
+#include <StepDimTol_GeometricTolerance.hxx>
+#include <StepDimTol_GeometricToleranceModifier.hxx>
+#include <StepDimTol_GeometricToleranceType.hxx>
+#include <StepDimTol_HArray1OfDatumReferenceModifier.hxx>
+#include <StepGeom_Axis2Placement3d.hxx>
 #include <StepRepr_CompoundRepresentationItem.hxx>
 #include <XCAFDimTolObjects_DimensionModifiersSequence.hxx>
 #include <StepShape_LimitsAndFits.hxx>
+#include <XCAFDimTolObjects_DatumModifiersSequence.hxx>
+#include <XCAFDimTolObjects_DatumModifWithValue.hxx>
 #include <XCAFDimTolObjects_DimensionFormVariance.hxx>
 #include <XCAFDimTolObjects_DimensionGrade.hxx>
 #include <XCAFDimTolObjects_DimensionType.hxx>
 #include <XCAFDimTolObjects_DatumTargetType.hxx>
 #include <XCAFDimTolObjects_DimensionQualifier.hxx>
+#include <XCAFDimTolObjects_GeomToleranceModif.hxx>
+#include <XCAFDimTolObjects_GeomToleranceType.hxx>
 #include <XCAFDimTolObjects_GeomToleranceTypeValue.hxx>
 
 //! This class provides tools for access (read)
@@ -63,6 +74,39 @@ public:
   Standard_EXPORT static Standard_Boolean GetTolValueType(const Handle(TCollection_HAsciiString)& theDescription,
                                                      XCAFDimTolObjects_GeomToleranceTypeValue& theType);
 
+  Standard_EXPORT static Handle(TCollection_HAsciiString) GetTolValueType(const XCAFDimTolObjects_GeomToleranceTypeValue& theType);
+
+  Standard_EXPORT static Handle(TCollection_HAsciiString) GetDimTypeName(const XCAFDimTolObjects_DimensionType theType);
+
+  Standard_EXPORT static Handle(TCollection_HAsciiString) GetDimQualifierName(const XCAFDimTolObjects_DimensionQualifier theQualifier);
+
+  Standard_EXPORT static Handle(TCollection_HAsciiString) GetDimModifierName(const XCAFDimTolObjects_DimensionModif theModifier);
+
+  Standard_EXPORT static Handle(StepShape_LimitsAndFits) GetLimitsAndFits(Standard_Boolean theHole,
+                                                     XCAFDimTolObjects_DimensionFormVariance theFormVariance,
+                                                     XCAFDimTolObjects_DimensionGrade theGrade);
+
+  Standard_EXPORT static Handle(TCollection_HAsciiString) GetDatumTargetName(const XCAFDimTolObjects_DatumTargetType theDatumType);
+
+  Standard_EXPORT static Handle(StepGeom_Axis2Placement3d) GetAxis2Placement3D(const gp_Ax2 theAxis);
+
+  Standard_EXPORT static Standard_Boolean IsDimensionalLocation(const XCAFDimTolObjects_DimensionType theType);
+
+  Standard_EXPORT static Standard_Boolean IsDimensionalSize(const XCAFDimTolObjects_DimensionType theType);
+
+  Standard_EXPORT static StepDimTol_GeometricToleranceType GetGeomToleranceType(const XCAFDimTolObjects_GeomToleranceType theType);
+
+  Standard_EXPORT static XCAFDimTolObjects_GeomToleranceType GetGeomToleranceType(const StepDimTol_GeometricToleranceType theType);
+
+  Standard_EXPORT static Handle(StepDimTol_GeometricTolerance) GetGeomTolerance(const XCAFDimTolObjects_GeomToleranceType theType);
+
+  Standard_EXPORT static StepDimTol_GeometricToleranceModifier GetGeomToleranceModifier(const XCAFDimTolObjects_GeomToleranceModif theModifier);
+
+  Standard_EXPORT static Handle(StepDimTol_HArray1OfDatumReferenceModifier) GetDatumRefModifiers(const XCAFDimTolObjects_DatumModifiersSequence theModifiers,
+                                                                                                 const XCAFDimTolObjects_DatumModifWithValue theModifWithVal,
+                                                                                                 const Standard_Real theValue,
+                                                                                                 const StepBasic_Unit theUnit);
+
 };
 
 #endif // _STEPConstruct_GDTProperty_HeaderFile
index bf9c60a..f2d6ea8 100644 (file)
@@ -723,6 +723,8 @@ static Standard_CString schemaAP203    = "CONFIG_CONTROL_DESIGN";
 #include <StepRepr_CompShAspAndDatumFeatAndShAsp.hxx>
 #include <StepRepr_IntegerRepresentationItem.hxx>
 #include <StepRepr_ValueRepresentationItem.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx>
 
 
 static int init = 0;
@@ -1413,6 +1415,8 @@ StepAP214_Protocol::StepAP214_Protocol ()
   types.Bind (STANDARD_TYPE(StepRepr_IntegerRepresentationItem), 700);
   types.Bind (STANDARD_TYPE(StepRepr_ValueRepresentationItem), 701);
   types.Bind (STANDARD_TYPE(StepRepr_FeatureForDatumTargetRelationship), 702);
+  types.Bind (STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol), 705);
+  types.Bind (STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMaxTol), 706);
 }
 
 //=======================================================================
index 589d202..ce9c88a 100644 (file)
@@ -65,12 +65,16 @@ StepDimTol_GeometricToleranceWithModifiers.cxx
 StepDimTol_GeometricToleranceWithModifiers.hxx
 StepDimTol_GeoTolAndGeoTolWthDatRef.cxx
 StepDimTol_GeoTolAndGeoTolWthDatRef.hxx
+StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.cxx
+StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx
 StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod.cxx
 StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod.hxx
 StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.cxx
 StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx
 StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.cxx
 StepDimTol_GeoTolAndGeoTolWthDatRefAndUneqDisGeoTol.hxx
+StepDimTol_GeoTolAndGeoTolWthMaxTol.cxx
+StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx
 StepDimTol_GeoTolAndGeoTolWthMod.cxx
 StepDimTol_GeoTolAndGeoTolWthMod.hxx
 StepDimTol_HArray1OfDatumReference.hxx
index e90fee2..297a8cb 100644 (file)
@@ -59,7 +59,7 @@ public:
   //! Indicates is field Modifiers exist
   inline Standard_Boolean HasModifiers() const
   {
-    return myModifiers.IsNull();
+    return !(myModifiers.IsNull() || myModifiers->Length() == 0);
   }
   
   //! Returns field Modifiers
diff --git a/src/StepDimTol/StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.cxx b/src/StepDimTol/StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.cxx
new file mode 100644 (file)
index 0000000..32fbb61
--- /dev/null
@@ -0,0 +1,74 @@
+// Created on: 2015-08-06
+// Created by: Irina KRYLOVA
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <Standard_Type.hxx>
+#include <StepBasic_LengthMeasureWithUnit.hxx>
+#include <StepBasic_MeasureWithUnit.hxx>
+#include <StepDimTol_GeometricToleranceTarget.hxx>
+#include <StepDimTol_GeometricToleranceWithDatumReference.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx>
+#include <StepDimTol_GeometricToleranceWithModifiers.hxx>
+#include <StepRepr_ShapeAspect.hxx>
+#include <TCollection_HAsciiString.hxx>
+
+//=======================================================================
+//function : StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol
+//purpose  : 
+//=======================================================================
+StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol()
+{
+}
+
+
+//=======================================================================
+//function : Init
+//purpose  : 
+//=======================================================================
+
+void StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::Init
+  (const Handle(TCollection_HAsciiString)& theName,
+   const Handle(TCollection_HAsciiString)& theDescription,
+   const Handle(StepBasic_MeasureWithUnit)& theMagnitude,
+   const Handle(StepRepr_ShapeAspect)& theTolerancedShapeAspect,
+   const Handle(StepDimTol_GeometricToleranceWithDatumReference)& theGTWDR,
+   const Handle(StepDimTol_GeometricToleranceWithModifiers)& theGTWM,
+   const Handle(StepBasic_LengthMeasureWithUnit)& theMaxTol,
+   const StepDimTol_GeometricToleranceType theType)
+{
+  StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod::
+    Init(theName, theDescription, theMagnitude, theTolerancedShapeAspect, theGTWDR, theGTWM, theType);
+  myMaxTol = theMaxTol;
+}
+
+//=======================================================================
+//function : Init
+//purpose  : 
+//=======================================================================
+
+void StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol::Init
+  (const Handle(TCollection_HAsciiString)& theName,
+   const Handle(TCollection_HAsciiString)& theDescription,
+   const Handle(StepBasic_MeasureWithUnit)& theMagnitude,
+   const StepDimTol_GeometricToleranceTarget& theTolerancedShapeAspect,
+   const Handle(StepDimTol_GeometricToleranceWithDatumReference)& theGTWDR,
+   const Handle(StepDimTol_GeometricToleranceWithModifiers)& theGTWM,
+   const Handle(StepBasic_LengthMeasureWithUnit)& theMaxTol,
+   const StepDimTol_GeometricToleranceType theType)
+{
+  StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod::
+    Init(theName, theDescription, theMagnitude, theTolerancedShapeAspect, theGTWDR, theGTWM, theType);
+  myMaxTol = theMaxTol;
+}
diff --git a/src/StepDimTol/StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx b/src/StepDimTol/StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol.hxx
new file mode 100644 (file)
index 0000000..4ac710a
--- /dev/null
@@ -0,0 +1,76 @@
+// Created on: 2015-11-13
+// Created by: Irina KRYLOVA
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol_HeaderFile
+#define _StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod.hxx>
+#include <StepDimTol_GeometricToleranceType.hxx>
+class StepDimTol_GeometricToleranceTarget;
+class StepDimTol_GeometricToleranceWithDatumReference;
+class StepDimTol_GeometricToleranceWithModifiers;
+class TCollection_HAsciiString;
+class StepBasic_LengthMeasureWithUnit;
+class StepBasic_MeasureWithUnit;
+class StepRepr_ShapeAspect;
+
+
+class StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol;
+DEFINE_STANDARD_HANDLE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod, StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)
+
+class StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol : public StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod
+{
+
+public:
+
+  
+  Standard_EXPORT StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMaxTol();
+  
+  Standard_EXPORT void Init (const Handle(TCollection_HAsciiString)& theName, 
+                             const Handle(TCollection_HAsciiString)& theDescription, 
+                             const Handle(StepBasic_MeasureWithUnit)& theMagnitude, 
+                             const Handle(StepRepr_ShapeAspect)& theTolerancedShapeAspect, 
+                             const Handle(StepDimTol_GeometricToleranceWithDatumReference)& theGTWDR, 
+                             const Handle(StepDimTol_GeometricToleranceWithModifiers)& theGTWM,
+                             const Handle(StepBasic_LengthMeasureWithUnit)& theMaxTol,
+                             const StepDimTol_GeometricToleranceType theType);
+
+  Standard_EXPORT void Init (const Handle(TCollection_HAsciiString)& aName, 
+                             const Handle(TCollection_HAsciiString)& aDescription, 
+                             const Handle(StepBasic_MeasureWithUnit)& aMagnitude, 
+                             const StepDimTol_GeometricToleranceTarget& aTolerancedShapeAspect, 
+                             const Handle(StepDimTol_GeometricToleranceWithDatumReference)& aGTWDR, 
+                             const Handle(StepDimTol_GeometricToleranceWithModifiers)& aGTWM,
+                             const Handle(StepBasic_LengthMeasureWithUnit)& theMaxTol,
+                             const StepDimTol_GeometricToleranceType theType);
+
+  inline void SetMaxTolerance(Handle(StepBasic_LengthMeasureWithUnit)& theMaxTol) {
+     myMaxTol = theMaxTol;
+  }
+  
+  inline Handle(StepBasic_LengthMeasureWithUnit) GetMaxTolerance() {
+    return myMaxTol;
+  }
+
+  DEFINE_STANDARD_RTTI(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod,StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)
+
+private:
+
+  Handle(StepBasic_LengthMeasureWithUnit) myMaxTol;
+};
+#endif // _StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod_HeaderFile
diff --git a/src/StepDimTol/StepDimTol_GeoTolAndGeoTolWthMaxTol.cxx b/src/StepDimTol/StepDimTol_GeoTolAndGeoTolWthMaxTol.cxx
new file mode 100644 (file)
index 0000000..3fdb63c
--- /dev/null
@@ -0,0 +1,69 @@
+// Created on: 2015-11-13
+// Created by: Irina KRYLOVA
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <Standard_Type.hxx>
+#include <StepBasic_LengthMeasureWithUnit.hxx>
+#include <StepBasic_MeasureWithUnit.hxx>
+#include <StepDimTol_GeometricToleranceTarget.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx>
+#include <StepDimTol_GeometricToleranceWithModifiers.hxx>
+#include <StepRepr_ShapeAspect.hxx>
+#include <TCollection_HAsciiString.hxx>
+
+//=======================================================================
+//function : StepDimTol_GeoTolAndGeoTolWthMaxTol
+//purpose  : 
+//=======================================================================
+StepDimTol_GeoTolAndGeoTolWthMaxTol::StepDimTol_GeoTolAndGeoTolWthMaxTol()
+{
+}
+
+
+//=======================================================================
+//function : Init
+//purpose  : 
+//=======================================================================
+
+void StepDimTol_GeoTolAndGeoTolWthMaxTol::Init
+  (const Handle(TCollection_HAsciiString)& theName,
+   const Handle(TCollection_HAsciiString)& theDescription,
+   const Handle(StepBasic_MeasureWithUnit)& theMagnitude,
+   const Handle(StepRepr_ShapeAspect)& theTolerancedShapeAspect,
+   const Handle(StepDimTol_GeometricToleranceWithModifiers)& theGTWM,
+   const Handle(StepBasic_LengthMeasureWithUnit)& theMaxTol,
+   const StepDimTol_GeometricToleranceType theType)
+{
+  StepDimTol_GeoTolAndGeoTolWthMod::Init(theName, theDescription, theMagnitude, theTolerancedShapeAspect, theGTWM, theType);
+  myMaxTol = theMaxTol;
+}
+
+//=======================================================================
+//function : Init
+//purpose  : 
+//=======================================================================
+
+void StepDimTol_GeoTolAndGeoTolWthMaxTol::Init
+  (const Handle(TCollection_HAsciiString)& theName,
+   const Handle(TCollection_HAsciiString)& theDescription,
+   const Handle(StepBasic_MeasureWithUnit)& theMagnitude,
+   const StepDimTol_GeometricToleranceTarget& theTolerancedShapeAspect,
+   const Handle(StepDimTol_GeometricToleranceWithModifiers)& theGTWM,
+   const Handle(StepBasic_LengthMeasureWithUnit)& theMaxTol,
+   const StepDimTol_GeometricToleranceType theType)
+{
+  StepDimTol_GeoTolAndGeoTolWthMod::Init(theName, theDescription, theMagnitude, theTolerancedShapeAspect, theGTWM, theType);
+  myMaxTol = theMaxTol;
+}
diff --git a/src/StepDimTol/StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx b/src/StepDimTol/StepDimTol_GeoTolAndGeoTolWthMaxTol.hxx
new file mode 100644 (file)
index 0000000..328386b
--- /dev/null
@@ -0,0 +1,73 @@
+// Created on: 2015-11-13
+// Created by: Irina KRYLOVA
+// Copyright (c) 2015 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _StepDimTol_GeoTolAndGeoTolWthMaxTol_HeaderFile
+#define _StepDimTol_GeoTolAndGeoTolWthMaxTol_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <StepDimTol_GeoTolAndGeoTolWthMod.hxx>
+#include <StepDimTol_GeometricToleranceType.hxx>
+class StepDimTol_GeometricToleranceTarget;
+class StepDimTol_GeometricToleranceWithModifiers;
+class TCollection_HAsciiString;
+class StepBasic_LengthMeasureWithUnit;
+class StepBasic_MeasureWithUnit;
+class StepRepr_ShapeAspect;
+
+
+class StepDimTol_GeoTolAndGeoTolWthMaxTol;
+DEFINE_STANDARD_HANDLE(StepDimTol_GeoTolAndGeoTolWthMaxTol, StepDimTol_GeoTolAndGeoTolWthMod)
+
+class StepDimTol_GeoTolAndGeoTolWthMaxTol : public StepDimTol_GeoTolAndGeoTolWthMod
+{
+
+public:
+
+  
+  Standard_EXPORT StepDimTol_GeoTolAndGeoTolWthMaxTol();
+  
+  Standard_EXPORT void Init (const Handle(TCollection_HAsciiString)& theName, 
+                             const Handle(TCollection_HAsciiString)& theDescription, 
+                             const Handle(StepBasic_MeasureWithUnit)& theMagnitude, 
+                             const Handle(StepRepr_ShapeAspect)& theTolerancedShapeAspect, 
+                             const Handle(StepDimTol_GeometricToleranceWithModifiers)& theGTWM,
+                             const Handle(StepBasic_LengthMeasureWithUnit)& theMaxTol,
+                             const StepDimTol_GeometricToleranceType theType);
+
+  Standard_EXPORT void Init (const Handle(TCollection_HAsciiString)& aName, 
+                             const Handle(TCollection_HAsciiString)& aDescription, 
+                             const Handle(StepBasic_MeasureWithUnit)& aMagnitude, 
+                             const StepDimTol_GeometricToleranceTarget& aTolerancedShapeAspect, 
+                             const Handle(StepDimTol_GeometricToleranceWithModifiers)& aGTWM,
+                             const Handle(StepBasic_LengthMeasureWithUnit)& theMaxTol,
+                             const StepDimTol_GeometricToleranceType theType);
+                             
+  inline void SetMaxTolerance(Handle(StepBasic_LengthMeasureWithUnit)& theMaxTol) {
+    myMaxTol = theMaxTol;
+  }
+  
+  inline Handle(StepBasic_LengthMeasureWithUnit) GetMaxTolerance() {
+    return myMaxTol;
+  }
+
+  DEFINE_STANDARD_RTTI(StepDimTol_GeoTolAndGeoTolWthMod,StepDimTol_GeoTolAndGeoTolWthMod)
+
+private:
+
+  Handle(StepBasic_LengthMeasureWithUnit) myMaxTol;
+};
+#endif // _StepDimTol_GeoTolAndGeoTolWthMaxTol_HeaderFile
index 94a9d21..40a69c5 100644 (file)
@@ -44,6 +44,9 @@ public:
 
   virtual Standard_Boolean SetName(const Standard_CString /*theName*/) Standard_OVERRIDE
     {  return Standard_True;  }
+
+  inline Standard_Integer Kind() const
+    {return 4;}
   
   Standard_EXPORT virtual   Standard_CString EnumText()  const Standard_OVERRIDE;
   
index 02195ce..c90b104 100644 (file)
@@ -254,4 +254,24 @@ Standard_Real XCAFDimTolObjects_DatumObject::GetDatumTargetWidth() const
 void XCAFDimTolObjects_DatumObject::SetDatumTargetWidth(const Standard_Real theWidth)
 {
   myWidth = theWidth;
-}
\ No newline at end of file
+}
+
+//=======================================================================
+//function : GetDatumTargetNumber
+//purpose  : 
+//=======================================================================
+
+Standard_Integer XCAFDimTolObjects_DatumObject::GetDatumTargetNumber() const
+{
+  return myDatumTargetNumber;
+}
+
+//=======================================================================
+//function : SetDatumTargetNumber
+//purpose  : 
+//=======================================================================
+
+void XCAFDimTolObjects_DatumObject::SetDatumTargetNumber(const Standard_Integer theNumber)
+{
+  myDatumTargetNumber = theNumber;
+}
index a18d8b3..a8cb14b 100644 (file)
@@ -87,6 +87,10 @@ public:
 
   Standard_EXPORT void SetDatumTargetWidth (const Standard_Real theWidth);
 
+  Standard_EXPORT Standard_Integer GetDatumTargetNumber() const;
+
+  Standard_EXPORT void SetDatumTargetNumber (const Standard_Integer theNumber);
+
 
   DEFINE_STANDARD_RTTI(XCAFDimTolObjects_DatumObject,Standard_Transient)
 
@@ -103,7 +107,7 @@ private:
   gp_Ax2 myAxis;
   Standard_Real myLength;
   Standard_Real myWidth;
-  
+  Standard_Integer myDatumTargetNumber;
 
 };
 
index c0811b5..2693fe5 100644 (file)
@@ -98,10 +98,17 @@ XCAFDimTolObjects_DimensionType XCAFDimTolObjects_DimensionObject::GetType()  co
 //=======================================================================
 Standard_Real XCAFDimTolObjects_DimensionObject::GetValue ()  const
 {
-  if(!myVal.IsNull() && (myVal->Length() == 1 || myVal->Length() == 3))
-  {
+  if (myVal.IsNull())
+    return 0;
+
+  // Simple value or value with Plus_Minus_Tolerance
+  if (myVal->Length() == 1 || myVal->Length() == 3) {
     return myVal->Value(1);
   }
+  // Range
+  if (myVal->Length() == 2) {
+    return (myVal->Value(1) + myVal->Value(2)) / 2;
+  }
   return 0;
 }
 
index eee412a..4d6cf98 100644 (file)
@@ -20,7 +20,8 @@
 enum XCAFDimTolObjects_GeomToleranceZoneModif
 {
 XCAFDimTolObjects_GeomToleranceZoneModif_None,
-XCAFDimTolObjects_GeomToleranceZoneModif_P,
+XCAFDimTolObjects_GeomToleranceZoneModif_Projected,
+XCAFDimTolObjects_GeomToleranceZoneModif_Runout,
 XCAFDimTolObjects_GeomToleranceZoneModif_NonUniform
 };
 
index 3e7a07a..be63f23 100644 (file)
@@ -34,6 +34,7 @@
 enum ChildLab
 {
   ChildLab_Name = 1,
+  ChildLab_Position,
   ChildLab_Modifiers,
   ChildLab_ModifierWithValue,
   ChildLab_IsDTarget,
@@ -43,6 +44,7 @@ enum ChildLab
   ChildLab_AxisRef,
   ChildLab_DTargetLength,
   ChildLab_DTargetWidth,
+  ChildLab_DTargetNumber,
   ChildLab_DatumTarget,
 };
 
@@ -177,6 +179,10 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb
     anAttName->Set(theObject->GetName()->String());
   }
 
+  Handle(TDataStd_Integer) aPosition = new TDataStd_Integer();
+  aPosition->Set(theObject->GetPosition());
+  Label().FindChild(ChildLab_Position).AddAttribute(aPosition);
+
   if(theObject->GetModifiers().Length() > 0)
   {
     Handle(TDataStd_IntegerArray) aModifiers;
@@ -236,17 +242,21 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb
       Handle(TDataStd_RealArray) aN = new TDataStd_RealArray();
       Handle(TDataStd_RealArray) aR = new TDataStd_RealArray();
       gp_Ax2 anAx = theObject->GetDatumTargetAxis();
-      aLoc->SetValue(aLoc->Upper(),anAx.Location().X());
-      aLoc->SetValue(aLoc->Upper()+1,anAx.Location().Y());
-      aLoc->SetValue(aLoc->Upper()+2,anAx.Location().Z());
 
-      aN->SetValue(aN->Upper(),anAx.Axis().Direction().X());
-      aN->SetValue(aN->Upper(),anAx.Axis().Direction().X());
-      aN->SetValue(aN->Upper(),anAx.Axis().Direction().X());
+      Handle(TColStd_HArray1OfReal) aLocArr = new TColStd_HArray1OfReal(1, 3);
+      for (Standard_Integer i = 1; i <= 3; i++)
+        aLocArr->SetValue(i, anAx.Location().Coord(i));
+      aLoc->ChangeArray(aLocArr);
+
+      Handle(TColStd_HArray1OfReal) aNArr = new TColStd_HArray1OfReal(1, 3);
+      for (Standard_Integer i = 1; i <= 3; i++)
+        aNArr->SetValue(i, anAx.Direction().Coord(i));
+      aN->ChangeArray(aNArr);
 
-      aR->SetValue(aR->Upper(),anAx.Direction().X());
-      aR->SetValue(aR->Upper(),anAx.Direction().X());
-      aR->SetValue(aR->Upper(),anAx.Direction().X());
+      Handle(TColStd_HArray1OfReal) aRArr = new TColStd_HArray1OfReal(1, 3);
+      for (Standard_Integer i = 1; i <= 3; i++)
+        aRArr->SetValue(i, anAx.XDirection().Coord(i));
+      aR->ChangeArray(aRArr);
 
       Label().FindChild(ChildLab_AxisLoc).AddAttribute(aLoc);
       Label().FindChild(ChildLab_AxisN).AddAttribute(aN);
@@ -265,6 +275,9 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb
         }
       }
     }
+    Handle(TDataStd_Integer) aNum = new TDataStd_Integer();
+    aNum->Set(theObject->GetDatumTargetNumber());
+    Label().FindChild(ChildLab_DTargetNumber).AddAttribute(aNum);
   }
 }
 
@@ -304,6 +317,12 @@ Handle(XCAFDimTolObjects_DatumObject) XCAFDoc_Datum::GetObject() const
     }
   }
 
+  Handle(TDataStd_Integer) aPosition;
+  if(Label().FindChild(ChildLab_Position).FindAttribute(TDataStd_Integer::GetID(), aPosition))
+  {
+    anObj->SetPosition(aPosition->Get());
+  }
+
   Handle(TDataStd_Integer) aIsDTarget;
   if(Label().FindChild(ChildLab_IsDTarget).FindAttribute(TDataStd_Integer::GetID(), aIsDTarget))
   {
@@ -337,9 +356,9 @@ Handle(XCAFDimTolObjects_DatumObject) XCAFDoc_Datum::GetObject() const
           Label().FindChild(ChildLab_AxisN).FindAttribute(TDataStd_RealArray::GetID(), aN) && aN->Length() == 3 &&
           Label().FindChild(ChildLab_AxisRef).FindAttribute(TDataStd_RealArray::GetID(), aR) && aR->Length() == 3 )
         {
-          gp_Pnt aL(aLoc->Value(aLoc->Upper()), aLoc->Value(aLoc->Upper()+1), aLoc->Value(aLoc->Upper()+2));
-          gp_Dir aD(aN->Value(aN->Upper()), aN->Value(aN->Upper()+1), aN->Value(aN->Upper()+2));
-          gp_Dir aDR(aR->Value(aR->Upper()), aR->Value(aR->Upper()+1), aR->Value(aR->Upper()+2));
+          gp_Pnt aL(aLoc->Value(aLoc->Lower()), aLoc->Value(aLoc->Lower()+1), aLoc->Value(aLoc->Lower()+2));
+          gp_Dir aD(aN->Value(aN->Lower()), aN->Value(aN->Lower()+1), aN->Value(aN->Lower()+2));
+          gp_Dir aDR(aR->Value(aR->Lower()), aR->Value(aR->Lower()+1), aR->Value(aR->Lower()+2));
           gp_Ax2 anAx(aL, aD, aDR);
           anObj->SetDatumTargetAxis(anAx);
         }
@@ -347,14 +366,14 @@ Handle(XCAFDimTolObjects_DatumObject) XCAFDoc_Datum::GetObject() const
         if(anObj->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Point)
         {
           Handle(TDataStd_Real) aLen;
-          if(Label().FindChild(ChildLab_DTargetLength).FindAttribute(TDataStd_Integer::GetID(), aLen))
+          if(Label().FindChild(ChildLab_DTargetLength).FindAttribute(TDataStd_Real::GetID(), aLen))
           {
             anObj->SetDatumTargetLength(aLen->Get());
           }
           if(anObj->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Rectangle)
           {
             Handle(TDataStd_Real) aWidth;
-            if(Label().FindChild(ChildLab_DTargetWidth).FindAttribute(TDataStd_Integer::GetID(), aWidth))
+            if(Label().FindChild(ChildLab_DTargetWidth).FindAttribute(TDataStd_Real::GetID(), aWidth))
             {
               anObj->SetDatumTargetWidth(aWidth->Get());
             }
@@ -362,6 +381,15 @@ Handle(XCAFDimTolObjects_DatumObject) XCAFDoc_Datum::GetObject() const
         }
       }
     }
+    Handle(TDataStd_Integer) aNum;
+    if(Label().FindChild(ChildLab_DTargetNumber).FindAttribute(TDataStd_Integer::GetID(), aNum))
+    {
+      anObj->SetDatumTargetNumber(aNum->Get());
+    }
+    else 
+    {
+      anObj->SetDatumTargetNumber(0);
+    }
   }
 
   return anObj;
index 09d8813..c488fdd 100644 (file)
 #include <Standard_GUID.hxx>
 #include <Standard_Type.hxx>
 #include <TCollection_HAsciiString.hxx>
+#include <TColStd_MapOfAsciiString.hxx>
 #include <TDataStd_Name.hxx>
 #include <TDataStd_TreeNode.hxx>
 #include <TDF_Attribute.hxx>
 #include <TDF_ChildIDIterator.hxx>
 #include <TDF_Label.hxx>
 #include <TDF_RelocationTable.hxx>
+#include <XCAFDimTolObjects_DatumObject.hxx>
 #include <XCAFDoc.hxx>
 #include <XCAFDoc_Dimension.hxx>
 #include <XCAFDoc_GeomTolerance.hxx>
@@ -823,6 +825,7 @@ Standard_Boolean XCAFDoc_DimTolTool::GetDatumOfTolerLabels(const TDF_Label& theD
   Handle(XCAFDoc_GraphNode) aNode;
   if( !theDimTolL.FindAttribute(XCAFDoc::DatumTolRefGUID(),aNode) )
     return Standard_False;
+
   for(Standard_Integer i=1; i<=aNode->NbChildren(); i++) {
     Handle(XCAFDoc_GraphNode) aDatumNode = aNode->GetChild(i);
     theDatums.Append(aDatumNode->Label());
@@ -831,6 +834,38 @@ Standard_Boolean XCAFDoc_DimTolTool::GetDatumOfTolerLabels(const TDF_Label& theD
 }
 
 //=======================================================================
+//function : GetDatumWthObjectsTolerLabels
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean XCAFDoc_DimTolTool::GetDatumWithObjectOfTolerLabels(const TDF_Label& theDimTolL,
+                                                                     TDF_LabelSequence& theDatums) const
+{
+  Handle(XCAFDoc_GraphNode) aNode;
+  if( !theDimTolL.FindAttribute(XCAFDoc::DatumTolRefGUID(),aNode) )
+    return Standard_False;
+
+  TColStd_MapOfAsciiString aDatumNameMap;
+  for(Standard_Integer i=1; i<=aNode->NbChildren(); i++) {
+    Handle(XCAFDoc_GraphNode) aDatumNode = aNode->GetChild(i);
+    TDF_Label aDatumL = aDatumNode->Label();
+    Handle(XCAFDoc_Datum) aDatumAttr;
+    if (!aDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatumAttr)) 
+      continue;
+    Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatumAttr->GetObject();
+    if (aDatumObj.IsNull())
+      continue;
+    Handle(TCollection_HAsciiString) aName = aDatumObj->GetName();
+    if (!aDatumNameMap.Add(aName->String())) {
+      // the datum has already been appended to sequence, due to one of its datum targets
+      continue;
+    }
+    theDatums.Append(aDatumNode->Label());
+  }
+  return Standard_True;
+}
+
+//=======================================================================
 //function : GetTolerDatumLabels
 //purpose  : 
 //=======================================================================
index f7e91d8..986776f 100644 (file)
@@ -177,6 +177,9 @@ public:
   //! Returns all Datum labels defined for label DimTolL
   Standard_EXPORT Standard_Boolean GetDatumOfTolerLabels (const TDF_Label& DimTolL, TDF_LabelSequence& Datums) const;
 
+  //! Returns all Datum labels with XCAFDimTolObjects_DatumObject defined for label DimTolL
+  Standard_EXPORT Standard_Boolean GetDatumWithObjectOfTolerLabels (const TDF_Label& DimTolL, TDF_LabelSequence& Datums) const;
+
   //! Returns all GeomToleranses labels defined for label DatumL
   Standard_EXPORT   Standard_Boolean GetTolerOfDatumLabels (const TDF_Label& theDatumL, TDF_LabelSequence& theTols)  const;
 
index 99a423d..502ba35 100644 (file)
@@ -153,17 +153,21 @@ void XCAFDoc_GeomTolerance::SetObject (const Handle(XCAFDimTolObjects_GeomTolera
     Handle(TDataStd_RealArray) aN = new TDataStd_RealArray();
     Handle(TDataStd_RealArray) aR = new TDataStd_RealArray();
     gp_Ax2 anAx = theObject->GetAxis();
-    aLoc->SetValue(aLoc->Upper(),anAx.Location().X());
-    aLoc->SetValue(aLoc->Upper()+1,anAx.Location().Y());
-    aLoc->SetValue(aLoc->Upper()+2,anAx.Location().Z());
 
-    aN->SetValue(aN->Upper(),anAx.Axis().Direction().X());
-    aN->SetValue(aN->Upper(),anAx.Axis().Direction().X());
-    aN->SetValue(aN->Upper(),anAx.Axis().Direction().X());
+    Handle(TColStd_HArray1OfReal) aLocArr = new TColStd_HArray1OfReal(1, 3);
+    for (Standard_Integer i = 1; i <= 3; i++)
+      aLocArr->SetValue(i, anAx.Location().Coord(i));
+    aLoc->ChangeArray(aLocArr);
 
-    aR->SetValue(aR->Upper(),anAx.Direction().X());
-    aR->SetValue(aR->Upper(),anAx.Direction().X());
-    aR->SetValue(aR->Upper(),anAx.Direction().X());
+    Handle(TColStd_HArray1OfReal) aNArr = new TColStd_HArray1OfReal(1, 3);
+    for (Standard_Integer i = 1; i <= 3; i++)
+      aNArr->SetValue(i, anAx.Direction().Coord(i));
+    aN->ChangeArray(aNArr);
+
+    Handle(TColStd_HArray1OfReal) aRArr = new TColStd_HArray1OfReal(1, 3);
+    for (Standard_Integer i = 1; i <= 3; i++)
+      aRArr->SetValue(i, anAx.XDirection().Coord(i));
+    aR->ChangeArray(aRArr);
 
     Label().FindChild(ChildLab_AxisLoc).AddAttribute(aLoc);
     Label().FindChild(ChildLab_AxisN).AddAttribute(aN);
@@ -239,9 +243,9 @@ Handle(XCAFDimTolObjects_GeomToleranceObject) XCAFDoc_GeomTolerance::GetObject()
     Label().FindChild(ChildLab_AxisN).FindAttribute(TDataStd_RealArray::GetID(), aN) && aN->Length() == 3 &&
     Label().FindChild(ChildLab_AxisRef).FindAttribute(TDataStd_RealArray::GetID(), aR) && aR->Length() == 3 )
   {
-    gp_Pnt aL(aLoc->Value(aLoc->Upper()), aLoc->Value(aLoc->Upper()+1), aLoc->Value(aLoc->Upper()+2));
-    gp_Dir aD(aN->Value(aN->Upper()), aN->Value(aN->Upper()+1), aN->Value(aN->Upper()+2));
-    gp_Dir aDR(aR->Value(aR->Upper()), aR->Value(aR->Upper()+1), aR->Value(aR->Upper()+2));
+    gp_Pnt aL(aLoc->Value(aLoc->Lower()), aLoc->Value(aLoc->Lower()+1), aLoc->Value(aLoc->Lower()+2));
+    gp_Dir aD(aN->Value(aN->Lower()), aN->Value(aN->Lower()+1), aN->Value(aN->Lower()+2));
+    gp_Dir aDR(aR->Value(aR->Lower()), aR->Value(aR->Lower()+1), aR->Value(aR->Lower()+2));
     gp_Ax2 anAx(aL, aD, aDR);
     anObj->SetAxis(anAx);
   }
index d663273..65b4599 100644 (file)
@@ -19,6 +19,8 @@
 #include <DBRep.hxx>
 #include <DDocStd.hxx>
 
+#include <STEPConstruct_GDTProperty.hxx>
+
 #include <TDF_Tool.hxx>
 #include <TDF_Label.hxx>
 #include <TDF_LabelSequence.hxx>
@@ -342,6 +344,13 @@ static Standard_Integer DumpNbDGTs (Draw_Interpretor& di, Standard_Integer argc,
     di<<"Use: XDumpNbDGTs Doc";
     return 1;
   }
+
+  Standard_Boolean isFull = Standard_False;
+  if (argc == 3) {
+    char aChar = argv[2][0];
+    if (aChar == 'f')
+      isFull = Standard_True;
+  }
   Handle(TDocStd_Document) Doc;
   DDocStd::GetDocument(argv[1], Doc);
   if ( Doc.IsNull() ) { di << argv[1] << " is not a document\n"; return 1; }
@@ -358,10 +367,79 @@ static Standard_Integer DumpNbDGTs (Draw_Interpretor& di, Standard_Integer argc,
   TDF_LabelSequence aGDTs;
   aDimTolTool->GetDimensionLabels(aGDTs);
   di << "\n NbOfDimensions          : " << aGDTs.Length();
+  if (isFull) {
+    Standard_Integer nbSize = 0,
+                     nbLocation = 0,
+                     nbAngular = 0,
+                     nbWithPath = 0;
+    for (Standard_Integer i = 1; i <= aGDTs.Length(); i++) {
+      Handle(XCAFDoc_Dimension) aDimAttr;
+      if (!aGDTs.Value(i).FindAttribute(XCAFDoc_Dimension::GetID(),aDimAttr)) 
+        continue;
+      Handle(XCAFDimTolObjects_DimensionObject) anObject = aDimAttr->GetObject();
+      if (anObject.IsNull())
+        continue;
+      XCAFDimTolObjects_DimensionType aDimType = anObject->GetType();
+      if (STEPConstruct_GDTProperty::IsDimensionalLocation(aDimType)) {
+        nbLocation++;
+      }
+      else if (aDimType == XCAFDimTolObjects_DimensionType_Location_Angular) {
+        nbAngular++;
+        nbLocation++;
+      }
+      else if (aDimType == XCAFDimTolObjects_DimensionType_Location_WithPath) {
+        nbLocation++;
+        nbWithPath++;
+      }
+      else if (STEPConstruct_GDTProperty::IsDimensionalSize(aDimType)) {
+        nbSize++;
+      }
+      else if (aDimType == XCAFDimTolObjects_DimensionType_Size_Angular) {
+        nbSize++;
+        nbAngular++;
+      }
+      else if (aDimType == XCAFDimTolObjects_DimensionType_Size_WithPath) {
+        nbSize++;
+        nbWithPath++;
+      }
+    }
+    di << "\n  NbOfDimensionalSize    : " << nbSize;
+    di << "\n  NbOfDimensionalLocation: " << nbLocation;
+    di << "\n  NbOfAngular            : " << nbAngular;
+    di << "\n  NbOfWithPath           : " << nbWithPath;
+  }
 
   aGDTs.Clear();
   aDimTolTool->GetGeomToleranceLabels(aGDTs);
   di << "\n NbOfTolerances          : " << aGDTs.Length();
+  if (isFull) {
+    Standard_Integer nbWithModif = 0,
+                     nbWithMaxTol = 0,
+                     nbWithDatumRef = 0;
+    for (Standard_Integer i = 1; i <= aGDTs.Length(); i++) {
+      Handle(XCAFDoc_GeomTolerance) aGTAttr;
+      if (!aGDTs.Value(i).FindAttribute(XCAFDoc_GeomTolerance::GetID(),aGTAttr)) 
+        continue;
+      Handle(XCAFDimTolObjects_GeomToleranceObject) anObject = aGTAttr->GetObject();
+      if (anObject.IsNull())
+        continue;
+      if (anObject->GetModifiers().Length() > 0 ||
+          anObject->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None) {
+        nbWithModif++;
+      }
+      if (anObject->GetMaxValueModifier() != 0) {
+        nbWithMaxTol++;
+      }
+      TDF_LabelSequence aDatumSeq;
+      aDimTolTool->GetDatumWithObjectOfTolerLabels(aGDTs.Value(i), aDatumSeq);
+      if (aDatumSeq.Length() > 0) {
+        nbWithDatumRef++;
+      }
+    }
+    di << "\n  NbOfGTWithModifiers    : " << nbWithModif;
+    di << "\n  NbOfGTWithMaxTolerance : " << nbWithMaxTol;
+    di << "\n  NbOfGTWithDatums       : " << nbWithDatumRef;
+  }
 
   Standard_Integer aCounter = 0;
   Standard_Integer aCounter1 = 0;
@@ -2084,7 +2162,7 @@ void XDEDRAW_GDTs::InitCommands(Draw_Interpretor& di)
   di.Add ("XDumpDGTs","XDumpDGTs Doc shape/label/all ",
     __FILE__, DumpDGTs, g);
 
-  di.Add ("XDumpNbDGTs","XDumpDGTs Doc",
+  di.Add ("XDumpNbDGTs","XDumpNbDGTs Doc [f (full dumping)]",
     __FILE__, DumpNbDGTs, g);
 
   di.Add ("XAddDimension","XAddDimension Doc shape/label [shape/label]",
diff --git a/tests/gdt/export/A1 b/tests/gdt/export/A1
new file mode 100644 (file)
index 0000000..4a682bc
--- /dev/null
@@ -0,0 +1,18 @@
+# !!!! This file is generated automatically, do not edit manually! See end script
+set filename bug26689_nist_ctc_01_asme1_ap242.stp
+
+set ref_data {
+
+ NbOfDimensions          : 8
+  NbOfDimensionalSize    : 7
+  NbOfDimensionalLocation: 1
+  NbOfAngular            : 1
+  NbOfWithPath           : 0
+ NbOfTolerances          : 6
+  NbOfGTWithModifiers    : 1
+  NbOfGTWithMaxTolerance : 0
+  NbOfGTWithDatums       : 5
+ NbOfDatumFeature        : 3
+ NbOfAttachedDatum       : 11
+ NbOfDatumTarget         : 0
+}
diff --git a/tests/gdt/export/A2 b/tests/gdt/export/A2
new file mode 100644 (file)
index 0000000..558a629
--- /dev/null
@@ -0,0 +1,18 @@
+# !!!! This file is generated automatically, do not edit manually! See end script
+set filename bug26689_nist_ctc_02_asme1_ap242-2.stp
+
+set ref_data {
+
+ NbOfDimensions          : 7
+  NbOfDimensionalSize    : 7
+  NbOfDimensionalLocation: 0
+  NbOfAngular            : 0
+  NbOfWithPath           : 0
+ NbOfTolerances          : 22
+  NbOfGTWithModifiers    : 4
+  NbOfGTWithMaxTolerance : 0
+  NbOfGTWithDatums       : 13
+ NbOfDatumFeature        : 5
+ NbOfAttachedDatum       : 24
+ NbOfDatumTarget         : 9
+}
diff --git a/tests/gdt/export/A3 b/tests/gdt/export/A3
new file mode 100644 (file)
index 0000000..15ab2be
--- /dev/null
@@ -0,0 +1,18 @@
+# !!!! This file is generated automatically, do not edit manually! See end script
+set filename bug26689_nist_ctc_03_asme1_ap242.stp
+
+set ref_data {
+
+ NbOfDimensions          : 10
+  NbOfDimensionalSize    : 7
+  NbOfDimensionalLocation: 3
+  NbOfAngular            : 0
+  NbOfWithPath           : 0
+ NbOfTolerances          : 13
+  NbOfGTWithModifiers    : 2
+  NbOfGTWithMaxTolerance : 0
+  NbOfGTWithDatums       : 11
+ NbOfDatumFeature        : 5
+ NbOfAttachedDatum       : 26
+ NbOfDatumTarget         : 0
+}
diff --git a/tests/gdt/export/A4 b/tests/gdt/export/A4
new file mode 100644 (file)
index 0000000..ba9cee6
--- /dev/null
@@ -0,0 +1,18 @@
+# !!!! This file is generated automatically, do not edit manually! See end script
+set filename bug26689_nist_ctc_04_asme1_ap242.stp
+
+set ref_data {
+
+ NbOfDimensions          : 5
+  NbOfDimensionalSize    : 3
+  NbOfDimensionalLocation: 2
+  NbOfAngular            : 1
+  NbOfWithPath           : 0
+ NbOfTolerances          : 4
+  NbOfGTWithModifiers    : 0
+  NbOfGTWithMaxTolerance : 0
+  NbOfGTWithDatums       : 4
+ NbOfDatumFeature        : 6
+ NbOfAttachedDatum       : 10
+ NbOfDatumTarget         : 0
+}
diff --git a/tests/gdt/export/A5 b/tests/gdt/export/A5
new file mode 100644 (file)
index 0000000..6ab3b4a
--- /dev/null
@@ -0,0 +1,18 @@
+# !!!! This file is generated automatically, do not edit manually! See end script
+set filename bug26689_nist_ctc_05_asme1_ap242-1.stp
+
+set ref_data {
+
+ NbOfDimensions          : 2
+  NbOfDimensionalSize    : 0
+  NbOfDimensionalLocation: 2
+  NbOfAngular            : 0
+  NbOfWithPath           : 0
+ NbOfTolerances          : 10
+  NbOfGTWithModifiers    : 0
+  NbOfGTWithMaxTolerance : 0
+  NbOfGTWithDatums       : 8
+ NbOfDatumFeature        : 2
+ NbOfAttachedDatum       : 9
+ NbOfDatumTarget         : 2
+}
diff --git a/tests/gdt/export/begin b/tests/gdt/export/begin
new file mode 100644 (file)
index 0000000..e633456
--- /dev/null
@@ -0,0 +1 @@
+NewDocument D
diff --git a/tests/gdt/export/end b/tests/gdt/export/end
new file mode 100644 (file)
index 0000000..3e27bb3
--- /dev/null
@@ -0,0 +1,193 @@
+# Set flag dump_file to 1 in order to regenerate script files with actual data
+# used as reference. In this mode all tests intentionaly report failure. 
+set dump_file 0
+########################################################################
+set mist 0;
+# Dimensions
+set nbDim_First 0; set nbDim_Second 0;
+set nbDimSize_First 0; set nbDimSize_Second 0;
+set nbDimLoc_First 0; set nbDimLoc_Second 0;
+set nbAng_First 0; set nbAng_Second 0;
+set nbDimWthPath_First 0; set nbDimWthPath_Second 0;
+# Tolerances
+set nbTol_First 0; set nbTol_Second 0;
+set nbTolWthMod_First 0; set nbTolWthMod_Second 0;
+set nbTolWthMax_First 0; set nbTolWthMax_Second 0;
+set nbTolWthDat_First 0; set nbTolWthDat_Second 0;
+# Datums
+set nbDat_First 0;
+set nbDatT_First 0;
+set nbAttDat_First 0;
+###################################################################
+set ref_Compare 0
+set todo_msg ""
+set todo_mask "puts \"TODO CR26859 ALL: "
+set end_line "\" \n"
+##################################################################
+
+# Read original file
+if { [string length $filename] > 1} {
+  set path_file [locate_data_file $filename]
+  if { [catch { ReadStep D_First $path_file } catch_result] } {
+    set err_msg "Error: First - file was not read - exception "
+    puts $err_msg
+    append todo_msg $todo_mask $err_msg $end_line
+    set mist 1
+  }
+} else {
+  set mist 1
+}
+
+# Get information about translation
+if { $mist < 1} {           
+  puts ""
+  set xst [ XDumpNbDGTs D_First f] 
+
+  if { [llength $xst] > 0 } {
+    regexp {NbOfDimensions +: +([-0-9.+eE]+)} $xst full nbDim_First
+    regexp {NbOfDimensionalSize +: +([-0-9.+eE]+)} $xst full nbDimSize_First
+    regexp {NbOfDimensionalLocation +: +([-0-9.+eE]+)} $xst full nbDimLoc_First
+    regexp {NbOfAngular +: +([-0-9.+eE]+)} $xst full nbAng_First
+    regexp {NbOfWithPath +: +([-0-9.+eE]+)} $xst full nbWthPath_First
+    regexp {NbOfTolerances +: +([-0-9.+eE]+)} $xst full nbTol_First
+    regexp {NbOfGTWithModifiers +: +([-0-9.+eE]+)} $xst full nbTolWthMod_First
+    regexp {NbOfGTWithMaxTolerance +: +([-0-9.+eE]+)} $xst full nbTolWthMax_First
+    regexp {NbOfGTWithDatums +: +([-0-9.+eE]+)} $xst full nbTolWthDat_First
+    regexp {NbOfDatumFeature +: +([-0-9.+eE]+)} $xst full nbDat_First
+    regexp {NbOfAttachedDatum +: +([-0-9.+eE]+)} $xst full nbAttDat_First
+    regexp {NbOfDatumTarget +: +([-0-9.+eE]+)} $xst full nbDatT_First
+  } else {
+      puts " GDT information was NOT provided"
+    }
+}
+
+if { $mist != 1 } {  
+  puts "" 
+  set result ""
+  append result [format $xst]
+}
+
+# Writing file
+if { $mist < 1} {
+  puts " "
+  puts "-----------------------------WRITING FILE ------------------------------"
+  if { [catch { WriteStep D_First $imagedir/${casename}_D_First.stp } catch_result] } {
+    set err_msg "Error: First - file was not written - exception"
+    puts $err_msg
+    append todo_msg $todo_mask $err_msg $end_line
+    set mist 1
+  }
+  if { $mist < 1 } {
+    if { [catch { ReadStep D_Second $imagedir/${casename}_D_First.stp } catch_result] } {
+      set err_msg "Error: Second - file was not read - exception"
+      puts $err_msg
+      append todo_msg $todo_mask $err_msg $end_line
+      set mist 1
+    }
+  }
+}
+
+catch {[file delete $imagedir/${casename}_D_First.stp]}
+if { [catch { Close D_First } catch_result] } {
+  set err_msg "Error : cannot close a document D_First - exception"
+  puts $err_msg
+}
+
+# Get information about translation
+if { $mist < 1} {           
+  puts ""
+  set xst2 [ XDumpNbDGTs D_Second f] 
+
+  if { [llength $xst2] > 0 } {
+    regexp {NbOfDimensions +: +([-0-9.+eE]+)} $xst2 full nbDim_Second
+    regexp {NbOfDimensionalSize +: +([-0-9.+eE]+)} $xst2 full nbDimSize_Second
+    regexp {NbOfDimensionalLocation +: +([-0-9.+eE]+)} $xst2 full nbDimLoc_Second
+    regexp {NbOfAngular +: +([-0-9.+eE]+)} $xst2 full nbAng_Second
+    regexp {NbOfWithPath +: +([-0-9.+eE]+)} $xst2 full nbWthPath_Second
+    regexp {NbOfTolerances +: +([-0-9.+eE]+)} $xst2 full nbTol_Second
+    regexp {NbOfGTWithModifiers +: +([-0-9.+eE]+)} $xst2 full nbTolWthMod_Second
+    regexp {NbOfGTWithMaxTolerance +: +([-0-9.+eE]+)} $xst2 full nbTolWthMax_Second
+    regexp {NbOfGTWithDatums +: +([-0-9.+eE]+)} $xst2 full nbTolWthDat_Second
+    regexp {NbOfDatumFeature +: +([-0-9.+eE]+)} $xst2 full nbDat_Second
+    regexp {NbOfAttachedDatum +: +([-0-9.+eE]+)} $xst2 full nbAttDat_Second
+    regexp {NbOfDatumTarget +: +([-0-9.+eE]+)} $xst2 full nbDatT_Second
+  } else {
+      puts " GDT information was NOT provided"
+    }
+  if { [catch { Close D_Second } catch_result] } {
+    set err_msg "Error : cannot close a document D_Second - exception"
+    puts $err_msg
+  }
+}
+
+if { $mist != 1 } {  
+  puts "" 
+  set result2 ""
+  append result2 [format $xst2]
+}
+
+set err_compare_ref ""
+# Put reference data to the test script file if option "dump" is set
+if { $dump_file == 1 } { 
+  set fd_stream  [open $dirname/$groupname/$gridname/$casename w] 
+  puts $fd_stream "# !!!! This file is generated automatically, do not edit manually! See end script"
+  puts $fd_stream "set filename $filename"
+  if { $mist != 1 } {
+    puts $fd_stream "" 
+    puts $fd_stream "set ref_data \{"
+    puts $fd_stream $result
+    puts $fd_stream "\}"
+  }
+  close $fd_stream 
+} elseif { $mist != 1 } {
+  puts "========================== Comparision with reference data ========"
+  puts ""
+  # Comparision of reference data with obtained result
+  set ref_list [split $ref_data \n]
+  set cur_list [split $result \n]
+  set cur2_list [split $result2 \n]
+  set nb_ref [llength $ref_list]
+  for { set i 0 } { $i < $nb_ref } { incr i } {
+    set j [expr $i +1]
+    set refstr [lindex $ref_list $j]
+    set curstr [lindex $cur_list $i]
+    set cur2str [lindex $cur2_list $i]
+    set isOK 1; 
+
+    if {[string equal $refstr $curstr] == 0} {
+      set isOK 0 
+    }
+    
+    if {[string equal $curstr $cur2str] == 0} {
+      set isOK 0 
+    } 
+
+    if { $isOK == 0}  {
+      incr ref_Compare
+      append err_compare_ref " Reference data             - $refstr\n"
+      append err_compare_ref " Current data               - $curstr\n"
+      append err_compare_ref " Current data after writing - $curstr\n"
+      append err_compare_ref "--------------------------------------------------------------------\n"
+    }
+  }
+}
+
+if { $dump_file != 0 } {
+    puts "Error : Running in regeneration mode, comparision was not performed!"
+    if { $mist != 1 } {
+        puts "Generation of test file $groupname/$gridname/$casename successful"
+    } else {
+        puts "Generation of reference data failed"
+    }
+} else {
+    if { $ref_Compare > 0} {
+        puts "Error : $ref_Compare differences with reference data found :\n$err_compare_ref"
+    } else {
+        puts "Comparision of current result with reference data - OK\n"
+    }    
+}
+
+puts "--------------------------------------------------------------------"
+puts ""
+
+puts "TEST COMPLETED"
index e3e3a2f..b8a7c11 100644 (file)
@@ -1,3 +1,4 @@
 001 dimensions
 002 tolerances
-003 import
\ No newline at end of file
+003 import
+004 export
index 1064239..690803c 100644 (file)
@@ -33,12 +33,12 @@ set ref_data {
         0:1:4:4 GeomTolerance.9.1 ( T 12 TV 0, V 0.5, M 15 )
                 0:1:4:5 Datum.9.1.1 ( )
  0:1:1:1:9 Shape.10
-        0:1:4:6 GeomTolerance.10.1 ( T 9 TV 0, V 0.75 )
+        0:1:4:6 GeomTolerance.10.1 ( T 10 TV 0, V 0.75 )
                 0:1:4:7 Datum.10.1.1 ( )
                 0:1:4:8 Datum.10.1.2 ( )
                 0:1:4:9 Datum.10.1.3 ( )
  0:1:1:1:10 Shape.11
-        0:1:4:6 GeomTolerance.11.1 ( T 9 TV 0, V 0.75 )
+        0:1:4:6 GeomTolerance.11.1 ( T 10 TV 0, V 0.75 )
                 0:1:4:7 Datum.11.1.1 ( )
                 0:1:4:8 Datum.11.1.2 ( )
                 0:1:4:9 Datum.11.1.3 ( )
@@ -47,12 +47,12 @@ set ref_data {
  0:1:1:1:12 Shape.13
         0:1:4:19 Dimension.13.1 ( T 15, V 35, VL 0, VU 0.20000000000000001, P 0 )
  0:1:1:1:13 Shape.14
-        0:1:4:10 GeomTolerance.14.1 ( T 9 TV 0, V 0.75 )
+        0:1:4:10 GeomTolerance.14.1 ( T 10 TV 0, V 0.75 )
                 0:1:4:11 Datum.14.1.1 ( )
                 0:1:4:12 Datum.14.1.2 ( )
                 0:1:4:13 Datum.14.1.3 ( )
  0:1:1:1:14 Shape.15
-        0:1:4:10 GeomTolerance.15.1 ( T 9 TV 0, V 0.75 )
+        0:1:4:10 GeomTolerance.15.1 ( T 10 TV 0, V 0.75 )
                 0:1:4:11 Datum.15.1.1 ( )
                 0:1:4:12 Datum.15.1.2 ( )
                 0:1:4:13 Datum.15.1.3 ( )
index 828921c..d28c908 100644 (file)
@@ -10,45 +10,53 @@ set ref_data {
  NbOfDatumTarget         : 9
 
  0:1:1:2:1 Shape.4
-        0:1:4:1 GeomTolerance.4.1 ( T 6 TV 0, V 0.25 )
-        0:1:4:9 Datum target.4.1 ( T 3, A ( L (000), XD (100), RD (010)), L 0 )
+        0:1:4:1 GeomTolerance.4.1 ( T 11 TV 0, V 0.25 )
+                0:1:4:2 Datum.4.1.1 ( )
+                0:1:4:3 Datum.4.1.2 ( )
+                0:1:4:4 Datum.4.1.3 ( )
+                0:1:4:5 Datum.4.1.4 ( )
+                0:1:4:6 Datum.4.1.5 ( )
+                0:1:4:7 Datum.4.1.6 ( )
+                0:1:4:8 Datum.4.1.7 ( )
+                0:1:4:9 Datum.4.1.8 ( )
+        0:1:4:9 Datum target.4.1 ( T 3, A ( L (000), XD (10-0), RD (-010)), L 0 )
  0:1:1:2:4 Shape.7
         0:1:4:21 GeomTolerance.7.1 ( T 7 TV 0, V 0.050000000000000003 )
  0:1:1:2:44 Shape.47
-        0:1:4:2 Datum target.47.1 ( T 3, A ( L (000), XD (100), RD (010)), L 0 )
-        0:1:4:2 Datum target.47.2 ( T 3, A ( L (000), XD (100), RD (010)), L 0 )
-        0:1:4:2 Datum target.47.3 ( T 3, A ( L (000), XD (100), RD (010)), L 0 )
+        0:1:4:2 Datum target.47.1 ( T 3, A ( L (000), XD (10-0), RD (-010)), L 0 )
+        0:1:4:2 Datum target.47.2 ( T 3, A ( L (000), XD (10-0), RD (-010)), L 0 )
+        0:1:4:2 Datum target.47.3 ( T 3, A ( L (000), XD (10-0), RD (-010)), L 0 )
  0:1:1:2:45 Shape.48
-        0:1:4:6 Datum target.48.1 ( T 3, A ( L (000), XD (100), RD (010)), L 0 )
+        0:1:4:6 Datum target.48.1 ( T 3, A ( L (000), XD (10-0), RD (-010)), L 0 )
  0:1:1:2:53 Shape.56
-        0:1:4:5 Datum target.56.1 ( T 3, A ( L (000), XD (100), RD (010)), L 0 )
+        0:1:4:5 Datum target.56.1 ( T 3, A ( L (000), XD (10-0), RD (-010)), L 0 )
  0:1:1:2:60 Shape.63
         0:1:4:16 GeomTolerance.63.1 ( T 12 TV 0, V 2.5 )
  0:1:1:2:62 Shape.65
-        0:1:4:8 Datum target.65.1 ( T 3, A ( L (000), XD (100), RD (010)), L 0 )
+        0:1:4:8 Datum target.65.1 ( T 3, A ( L (000), XD (10-0), RD (-010)), L 0 )
  0:1:1:2:71 Shape.74
-        0:1:4:7 Datum target.74.1 ( T 3, A ( L (000), XD (100), RD (010)), L 0 )
+        0:1:4:7 Datum target.74.1 ( T 3, A ( L (000), XD (10-0), RD (-010)), L 0 )
  0:1:1:2:75 Shape.78
         0:1:4:57 GeomTolerance.78.1 ( T 12 TV 0, V 0.80000000000000004 )
                 0:1:4:58 Datum.78.1.1 (, M 12 )
                 0:1:4:59 Datum.78.1.2 ( )
  0:1:1:2:94 Shape.97
         0:1:4:29 Dimension.97.1 ( T 15, V 12, VL 0.050000000000000003, VU 0.050000000000000003, P 0 )
-        0:1:4:30 GeomTolerance.97.1 ( T 9 TV 1, V 0.050000000000000003 )
+        0:1:4:30 GeomTolerance.97.1 ( T 10 TV 1, V 0.050000000000000003 )
                 0:1:4:31 Datum.97.1.1 ( )
                 0:1:4:32 Datum.97.1.2 ( )
  0:1:1:2:95 Shape.98
         0:1:4:29 Dimension.98.1 ( T 15, V 12, VL 0.050000000000000003, VU 0.050000000000000003, P 0 )
-        0:1:4:30 GeomTolerance.98.1 ( T 9 TV 1, V 0.050000000000000003 )
+        0:1:4:30 GeomTolerance.98.1 ( T 10 TV 1, V 0.050000000000000003 )
                 0:1:4:31 Datum.98.1.1 ( )
                 0:1:4:32 Datum.98.1.2 ( )
  0:1:1:2:96 Shape.99
         0:1:4:26 Dimension.99.1 ( T 15, V 12, VL 0.050000000000000003, VU 0.050000000000000003, P 0 )
-        0:1:4:27 GeomTolerance.99.1 ( T 8 TV 1, V 0.050000000000000003 )
+        0:1:4:27 GeomTolerance.99.1 ( T 9 TV 1, V 0.050000000000000003 )
                 0:1:4:28 Datum.99.1.1 ( )
  0:1:1:2:97 Shape.100
         0:1:4:26 Dimension.100.1 ( T 15, V 12, VL 0.050000000000000003, VU 0.050000000000000003, P 0 )
-        0:1:4:27 GeomTolerance.100.1 ( T 8 TV 1, V 0.050000000000000003 )
+        0:1:4:27 GeomTolerance.100.1 ( T 9 TV 1, V 0.050000000000000003 )
                 0:1:4:28 Datum.100.1.1 ( )
  0:1:1:2:184 Shape.187
         0:1:4:22 GeomTolerance.187.1 ( T 12 TV 0, V 0.10000000000000001 )
@@ -84,21 +92,21 @@ set ref_data {
                 0:1:4:25 Datum.314.1.2 (, M 12 )
  0:1:1:2:331 Shape.334
         0:1:4:33 Dimension.334.1 ( T 15, V 22, VL 0.10000000000000001, VU 0.10000000000000001, P 0 )
-        0:1:4:34 GeomTolerance.334.1 ( T 0 TV 1, V 0.10000000000000001, MR 2 )
+        0:1:4:34 GeomTolerance.334.1 ( T 9 TV 1, V 0.10000000000000001, MR 2 )
  0:1:1:2:332 Shape.335
         0:1:4:33 Dimension.335.1 ( T 15, V 22, VL 0.10000000000000001, VU 0.10000000000000001, P 0 )
-        0:1:4:34 GeomTolerance.335.1 ( T 0 TV 1, V 0.10000000000000001, MR 2 )
+        0:1:4:34 GeomTolerance.335.1 ( T 9 TV 1, V 0.10000000000000001, MR 2 )
  0:1:1:2:357 Shape.360
         0:1:4:35 GeomTolerance.360.1 ( T 12 TV 0, V 0.80000000000000004 )
                 0:1:4:36 Datum.360.1.1 ( )
                 0:1:4:37 Datum.360.1.2 ( )
  0:1:1:2:363 Shape.366
         0:1:4:60 Dimension.366.1 ( T 15, V 22, VL 0.10000000000000001, VU 0.10000000000000001, P 0 )
-        0:1:4:61 GeomTolerance.366.1 ( T 0 TV 1, V 0.14999999999999999, MR 2 )
+        0:1:4:61 GeomTolerance.366.1 ( T 10 TV 1, V 0.14999999999999999, MR 2 )
                 0:1:4:62 Datum.366.1.1 ( )
  0:1:1:2:364 Shape.367
         0:1:4:60 Dimension.367.1 ( T 15, V 22, VL 0.10000000000000001, VU 0.10000000000000001, P 0 )
-        0:1:4:61 GeomTolerance.367.1 ( T 0 TV 1, V 0.14999999999999999, MR 2 )
+        0:1:4:61 GeomTolerance.367.1 ( T 10 TV 1, V 0.14999999999999999, MR 2 )
                 0:1:4:62 Datum.367.1.1 ( )
  0:1:1:2:375 Shape.378
         0:1:4:14 GeomTolerance.378.1 ( T 12 TV 0, V 2.5 )
@@ -106,80 +114,90 @@ set ref_data {
         0:1:4:15 GeomTolerance.399.1 ( T 12 TV 0, V 0.75 )
  0:1:1:2:431 Shape.434
         0:1:4:10 Dimension.434.1 ( T 15, V 52, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:11 GeomTolerance.434.1 ( T 0 TV 1, V 1, MR 2 )
+        0:1:4:11 GeomTolerance.434.1 ( T 10 TV 1, V 1, MR 2 )
  0:1:1:2:432 Shape.435
         0:1:4:10 Dimension.435.1 ( T 15, V 52, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:11 GeomTolerance.435.1 ( T 0 TV 1, V 1, MR 2 )
+        0:1:4:11 GeomTolerance.435.1 ( T 10 TV 1, V 1, MR 2 )
  0:1:1:2:435 Shape.438
         0:1:4:10 Dimension.438.1 ( T 15, V 52, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:11 GeomTolerance.438.1 ( T 0 TV 1, V 1, MR 2 )
+        0:1:4:11 GeomTolerance.438.1 ( T 10 TV 1, V 1, MR 2 )
  0:1:1:2:436 Shape.439
         0:1:4:10 Dimension.439.1 ( T 15, V 52, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:11 GeomTolerance.439.1 ( T 0 TV 1, V 1, MR 2 )
+        0:1:4:11 GeomTolerance.439.1 ( T 10 TV 1, V 1, MR 2 )
  0:1:1:2:437 Shape.440
         0:1:4:38 GeomTolerance.440.1 ( T 12 TV 0, V 0.80000000000000004 )
                 0:1:4:39 Datum.440.1.1 ( )
                 0:1:4:40 Datum.440.1.2 (, M 12 )
  0:1:1:2:494 Shape.497
         0:1:4:12 Dimension.497.1 ( T 15, V 100, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:13 GeomTolerance.497.1 ( T 0 TV 1, V 1.5, MR 1 )
+        0:1:4:13 GeomTolerance.497.1 ( T 10 TV 1, V 1.5, MR 1 )
  0:1:1:2:495 Shape.498
         0:1:4:12 Dimension.498.1 ( T 15, V 100, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:13 GeomTolerance.498.1 ( T 0 TV 1, V 1.5, MR 1 )
+        0:1:4:13 GeomTolerance.498.1 ( T 10 TV 1, V 1.5, MR 1 )
  0:1:1:2:518 Shape.521
         0:1:4:12 Dimension.521.1 ( T 15, V 100, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:13 GeomTolerance.521.1 ( T 0 TV 1, V 1.5, MR 1 )
+        0:1:4:13 GeomTolerance.521.1 ( T 10 TV 1, V 1.5, MR 1 )
  0:1:1:2:519 Shape.522
         0:1:4:12 Dimension.522.1 ( T 15, V 100, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:13 GeomTolerance.522.1 ( T 0 TV 1, V 1.5, MR 1 )
+        0:1:4:13 GeomTolerance.522.1 ( T 10 TV 1, V 1.5, MR 1 )
  0:1:1:2:540 Shape.543
         0:1:4:17 GeomTolerance.543.1 ( T 12 TV 0, V 2.5 )
  0:1:1:2:612 Shape.615
-        0:1:4:20 Datum target.615.1 ( T 3, A ( L (000), XD (100), RD (010)), L 0 )
+        0:1:4:20 Datum target.615.1 ( T 3, A ( L (000), XD (10-0), RD (-010)), L 0 )
  0:1:1:2:645 Shape.648
         0:1:4:18 Dimension.648.1 ( T 15, V 40, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:19 GeomTolerance.648.1 ( T 8 TV 1, V 0.25 )
+        0:1:4:19 GeomTolerance.648.1 ( T 9 TV 1, V 0.25 )
+                0:1:4:20 Datum.648.1.1 ( )
  0:1:1:2:646 Shape.649
         0:1:4:18 Dimension.649.1 ( T 15, V 40, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:19 GeomTolerance.649.1 ( T 8 TV 1, V 0.25 )
+        0:1:4:19 GeomTolerance.649.1 ( T 9 TV 1, V 0.25 )
+                0:1:4:20 Datum.649.1.1 ( )
  0:1:1:2:672 Shape.675
         0:1:4:10 Dimension.675.1 ( T 15, V 52, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:11 GeomTolerance.675.1 ( T 0 TV 1, V 1, MR 2 )
+        0:1:4:11 GeomTolerance.675.1 ( T 10 TV 1, V 1, MR 2 )
  0:1:1:2:673 Shape.676
         0:1:4:10 Dimension.676.1 ( T 15, V 52, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:11 GeomTolerance.676.1 ( T 0 TV 1, V 1, MR 2 )
+        0:1:4:11 GeomTolerance.676.1 ( T 10 TV 1, V 1, MR 2 )
  0:1:1:2:674 Shape.677
         0:1:4:10 Dimension.677.1 ( T 15, V 52, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:11 GeomTolerance.677.1 ( T 0 TV 1, V 1, MR 2 )
+        0:1:4:11 GeomTolerance.677.1 ( T 10 TV 1, V 1, MR 2 )
  0:1:1:2:675 Shape.678
         0:1:4:10 Dimension.678.1 ( T 15, V 52, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:11 GeomTolerance.678.1 ( T 0 TV 1, V 1, MR 2 )
+        0:1:4:11 GeomTolerance.678.1 ( T 10 TV 1, V 1, MR 2 )
  0:1:1:2:676 Shape.679
         0:1:4:12 Dimension.679.1 ( T 15, V 100, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:13 GeomTolerance.679.1 ( T 0 TV 1, V 1.5, MR 1 )
+        0:1:4:13 GeomTolerance.679.1 ( T 10 TV 1, V 1.5, MR 1 )
  0:1:1:2:677 Shape.680
         0:1:4:12 Dimension.680.1 ( T 15, V 100, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
-        0:1:4:13 GeomTolerance.680.1 ( T 0 TV 1, V 1.5, MR 1 )
+        0:1:4:13 GeomTolerance.680.1 ( T 10 TV 1, V 1.5, MR 1 )
  0:1:1:2:678 Shape.681
         0:1:4:33 Dimension.681.1 ( T 15, V 22, VL 0.10000000000000001, VU 0.10000000000000001, P 0 )
-        0:1:4:34 GeomTolerance.681.1 ( T 0 TV 1, V 0.10000000000000001, MR 2 )
+        0:1:4:34 GeomTolerance.681.1 ( T 9 TV 1, V 0.10000000000000001, MR 2 )
  0:1:1:2:679 Shape.682
-        0:1:4:27 GeomTolerance.682.1 ( T 8 TV 1, V 0.050000000000000003 )
+        0:1:4:27 GeomTolerance.682.1 ( T 9 TV 1, V 0.050000000000000003 )
                 0:1:4:28 Datum.682.1.1 ( )
  0:1:1:2:680 Shape.683
-        0:1:4:27 GeomTolerance.683.1 ( T 8 TV 1, V 0.050000000000000003 )
+        0:1:4:27 GeomTolerance.683.1 ( T 9 TV 1, V 0.050000000000000003 )
                 0:1:4:28 Datum.683.1.1 ( )
  0:1:1:2:681 Shape.684
-        0:1:4:30 GeomTolerance.684.1 ( T 9 TV 1, V 0.050000000000000003 )
+        0:1:4:30 GeomTolerance.684.1 ( T 10 TV 1, V 0.050000000000000003 )
                 0:1:4:31 Datum.684.1.1 ( )
                 0:1:4:32 Datum.684.1.2 ( )
  0:1:1:2:682 Shape.685
-        0:1:4:30 GeomTolerance.685.1 ( T 9 TV 1, V 0.050000000000000003 )
+        0:1:4:30 GeomTolerance.685.1 ( T 10 TV 1, V 0.050000000000000003 )
                 0:1:4:31 Datum.685.1.1 ( )
                 0:1:4:32 Datum.685.1.2 ( )
  0:1:1:2:683 Shape.686
         0:1:4:33 Dimension.686.1 ( T 15, V 22, VL 0.10000000000000001, VU 0.10000000000000001, P 0 )
-        0:1:4:34 GeomTolerance.686.1 ( T 0 TV 1, V 0.10000000000000001, MR 2 )
+        0:1:4:34 GeomTolerance.686.1 ( T 9 TV 1, V 0.10000000000000001, MR 2 )
  0:1:1:3:1 Shape.687
-        0:1:4:1 GeomTolerance.687.1 ( T 6 TV 0, V 0.25 )
+        0:1:4:1 GeomTolerance.687.1 ( T 11 TV 0, V 0.25 )
+                0:1:4:2 Datum.687.1.1 ( )
+                0:1:4:3 Datum.687.1.2 ( )
+                0:1:4:4 Datum.687.1.3 ( )
+                0:1:4:5 Datum.687.1.4 ( )
+                0:1:4:6 Datum.687.1.5 ( )
+                0:1:4:7 Datum.687.1.6 ( )
+                0:1:4:8 Datum.687.1.7 ( )
+                0:1:4:9 Datum.687.1.8 ( )
 }
index 325c4c6..76ee936 100644 (file)
@@ -15,25 +15,25 @@ set ref_data {
         0:1:4:6 Dimension.10.1 ( T 2, V 20.827999999999996, VL 64.515999999999991, VU 64.515999999999991, P 0 )
  0:1:1:2:19 Shape.22
         0:1:4:39 Dimension.22.1 ( T 15, V 11.1252, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:35 GeomTolerance.22.1 ( T 0 TV 1, V 1.27, MR 1 )
+        0:1:4:35 GeomTolerance.22.1 ( T 10 TV 1, V 1.27, MR 1 )
                 0:1:4:36 Datum.22.1.1 ( )
                 0:1:4:37 Datum.22.1.2 (, M 15 )
                 0:1:4:38 Datum.22.1.3 (, M 15 )
  0:1:1:2:20 Shape.23
         0:1:4:39 Dimension.23.1 ( T 15, V 11.1252, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:35 GeomTolerance.23.1 ( T 0 TV 1, V 1.27, MR 1 )
+        0:1:4:35 GeomTolerance.23.1 ( T 10 TV 1, V 1.27, MR 1 )
                 0:1:4:36 Datum.23.1.1 ( )
                 0:1:4:37 Datum.23.1.2 (, M 15 )
                 0:1:4:38 Datum.23.1.3 (, M 15 )
  0:1:1:2:21 Shape.24
         0:1:4:39 Dimension.24.1 ( T 15, V 11.1252, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:35 GeomTolerance.24.1 ( T 0 TV 1, V 1.27, MR 1 )
+        0:1:4:35 GeomTolerance.24.1 ( T 10 TV 1, V 1.27, MR 1 )
                 0:1:4:36 Datum.24.1.1 ( )
                 0:1:4:37 Datum.24.1.2 (, M 15 )
                 0:1:4:38 Datum.24.1.3 (, M 15 )
  0:1:1:2:22 Shape.25
         0:1:4:39 Dimension.25.1 ( T 15, V 11.1252, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:35 GeomTolerance.25.1 ( T 0 TV 1, V 1.27, MR 1 )
+        0:1:4:35 GeomTolerance.25.1 ( T 10 TV 1, V 1.27, MR 1 )
                 0:1:4:36 Datum.25.1.1 ( )
                 0:1:4:37 Datum.25.1.2 (, M 15 )
                 0:1:4:38 Datum.25.1.3 (, M 15 )
@@ -45,13 +45,13 @@ set ref_data {
                 0:1:4:5 Datum.31.1.3 ( )
  0:1:1:2:39 Shape.42
         0:1:4:14 Dimension.42.1 ( T 15, V 50.799999999999997, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:15 GeomTolerance.42.1 ( T 9 TV 1, V 1.524 )
+        0:1:4:15 GeomTolerance.42.1 ( T 10 TV 1, V 1.524 )
                 0:1:4:16 Datum.42.1.1 ( )
                 0:1:4:17 Datum.42.1.2 ( )
                 0:1:4:18 Datum.42.1.3 ( )
  0:1:1:2:40 Shape.43
         0:1:4:14 Dimension.43.1 ( T 15, V 50.799999999999997, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:15 GeomTolerance.43.1 ( T 9 TV 1, V 1.524 )
+        0:1:4:15 GeomTolerance.43.1 ( T 10 TV 1, V 1.524 )
                 0:1:4:16 Datum.43.1.1 ( )
                 0:1:4:17 Datum.43.1.2 ( )
                 0:1:4:18 Datum.43.1.3 ( )
@@ -59,70 +59,70 @@ set ref_data {
         0:1:4:30 Dimension.51.1 ( T 2, V 19.049999999999997, P 0 )
  0:1:1:2:49 Shape.52
         0:1:4:19 Dimension.52.1 ( T 15, V 38.099999999999994, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:20 GeomTolerance.52.1 ( T 9 TV 1, V 2.032 )
+        0:1:4:20 GeomTolerance.52.1 ( T 10 TV 1, V 2.032 )
                 0:1:4:21 Datum.52.1.1 ( )
                 0:1:4:22 Datum.52.1.2 ( )
                 0:1:4:23 Datum.52.1.3 ( )
-        0:1:4:25 GeomTolerance.52.2 ( T 9 TV 0, V 0.76200000000000001 )
+        0:1:4:25 GeomTolerance.52.2 ( T 10 TV 0, V 0.76200000000000001 )
                 0:1:4:26 Datum.52.2.1 ( )
                 0:1:4:27 Datum.52.2.2 ( )
                 0:1:4:28 Datum.52.2.3 ( )
  0:1:1:2:50 Shape.53
         0:1:4:19 Dimension.53.1 ( T 15, V 38.099999999999994, VL 64.515999999999991, VU 64.515999999999991, P 0 )
         0:1:4:24 Dimension.53.2 ( T 2, V 38.099999999999994, P 0 )
-        0:1:4:20 GeomTolerance.53.1 ( T 9 TV 1, V 2.032 )
+        0:1:4:20 GeomTolerance.53.1 ( T 10 TV 1, V 2.032 )
                 0:1:4:21 Datum.53.1.1 ( )
                 0:1:4:22 Datum.53.1.2 ( )
                 0:1:4:23 Datum.53.1.3 ( )
-        0:1:4:25 GeomTolerance.53.2 ( T 9 TV 0, V 0.76200000000000001 )
+        0:1:4:25 GeomTolerance.53.2 ( T 10 TV 0, V 0.76200000000000001 )
                 0:1:4:26 Datum.53.2.1 ( )
                 0:1:4:27 Datum.53.2.2 ( )
                 0:1:4:28 Datum.53.2.3 ( )
  0:1:1:2:51 Shape.54
         0:1:4:29 Dimension.54.1 ( T 15, V 15.875, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:31 GeomTolerance.54.1 ( T 0 TV 1, V 1.27, MR 1 )
+        0:1:4:31 GeomTolerance.54.1 ( T 10 TV 1, V 1.27, MR 1 )
                 0:1:4:32 Datum.54.1.1 ( )
                 0:1:4:33 Datum.54.1.2 ( )
                 0:1:4:34 Datum.54.1.3 ( )
  0:1:1:2:52 Shape.55
         0:1:4:29 Dimension.55.1 ( T 15, V 15.875, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:31 GeomTolerance.55.1 ( T 0 TV 1, V 1.27, MR 1 )
+        0:1:4:31 GeomTolerance.55.1 ( T 10 TV 1, V 1.27, MR 1 )
                 0:1:4:32 Datum.55.1.1 ( )
                 0:1:4:33 Datum.55.1.2 ( )
                 0:1:4:34 Datum.55.1.3 ( )
  0:1:1:2:53 Shape.56
         0:1:4:29 Dimension.56.1 ( T 15, V 15.875, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:31 GeomTolerance.56.1 ( T 0 TV 1, V 1.27, MR 1 )
+        0:1:4:31 GeomTolerance.56.1 ( T 10 TV 1, V 1.27, MR 1 )
                 0:1:4:32 Datum.56.1.1 ( )
                 0:1:4:33 Datum.56.1.2 ( )
                 0:1:4:34 Datum.56.1.3 ( )
  0:1:1:2:54 Shape.57
         0:1:4:29 Dimension.57.1 ( T 15, V 15.875, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:31 GeomTolerance.57.1 ( T 0 TV 1, V 1.27, MR 1 )
+        0:1:4:31 GeomTolerance.57.1 ( T 10 TV 1, V 1.27, MR 1 )
                 0:1:4:32 Datum.57.1.1 ( )
                 0:1:4:33 Datum.57.1.2 ( )
                 0:1:4:34 Datum.57.1.3 ( )
  0:1:1:2:55 Shape.58
         0:1:4:29 Dimension.58.1 ( T 15, V 15.875, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:31 GeomTolerance.58.1 ( T 0 TV 1, V 1.27, MR 1 )
+        0:1:4:31 GeomTolerance.58.1 ( T 10 TV 1, V 1.27, MR 1 )
                 0:1:4:32 Datum.58.1.1 ( )
                 0:1:4:33 Datum.58.1.2 ( )
                 0:1:4:34 Datum.58.1.3 ( )
  0:1:1:2:56 Shape.59
         0:1:4:29 Dimension.59.1 ( T 15, V 15.875, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:31 GeomTolerance.59.1 ( T 0 TV 1, V 1.27, MR 1 )
+        0:1:4:31 GeomTolerance.59.1 ( T 10 TV 1, V 1.27, MR 1 )
                 0:1:4:32 Datum.59.1.1 ( )
                 0:1:4:33 Datum.59.1.2 ( )
                 0:1:4:34 Datum.59.1.3 ( )
  0:1:1:2:57 Shape.60
         0:1:4:29 Dimension.60.1 ( T 15, V 15.875, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:31 GeomTolerance.60.1 ( T 0 TV 1, V 1.27, MR 1 )
+        0:1:4:31 GeomTolerance.60.1 ( T 10 TV 1, V 1.27, MR 1 )
                 0:1:4:32 Datum.60.1.1 ( )
                 0:1:4:33 Datum.60.1.2 ( )
                 0:1:4:34 Datum.60.1.3 ( )
  0:1:1:2:58 Shape.61
         0:1:4:29 Dimension.61.1 ( T 15, V 15.875, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:31 GeomTolerance.61.1 ( T 0 TV 1, V 1.27, MR 1 )
+        0:1:4:31 GeomTolerance.61.1 ( T 10 TV 1, V 1.27, MR 1 )
                 0:1:4:32 Datum.61.1.1 ( )
                 0:1:4:33 Datum.61.1.2 ( )
                 0:1:4:34 Datum.61.1.3 ( )
@@ -138,28 +138,28 @@ set ref_data {
         0:1:4:1 GeomTolerance.132.1 ( T 12 TV 0, V 0.254 )
  0:1:1:2:134 Shape.137
         0:1:4:40 Dimension.137.1 ( T 15, V 27.050999999999998, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:41 GeomTolerance.137.1 ( T 8 TV 1, V 0.254 )
+        0:1:4:41 GeomTolerance.137.1 ( T 9 TV 1, V 0.254 )
                 0:1:4:42 Datum.137.1.1 ( )
  0:1:1:2:135 Shape.138
         0:1:4:40 Dimension.138.1 ( T 15, V 27.050999999999998, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:41 GeomTolerance.138.1 ( T 8 TV 1, V 0.254 )
+        0:1:4:41 GeomTolerance.138.1 ( T 9 TV 1, V 0.254 )
                 0:1:4:42 Datum.138.1.1 ( )
  0:1:1:2:153 Shape.156
         0:1:4:7 Dimension.156.1 ( T 15, V 11.1252, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:9 GeomTolerance.156.1 ( T 8 TV 1, V 0.254 )
+        0:1:4:9 GeomTolerance.156.1 ( T 9 TV 1, V 0.254 )
                 0:1:4:10 Datum.156.1.1 ( )
  0:1:1:2:154 Shape.157
         0:1:4:7 Dimension.157.1 ( T 15, V 11.1252, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:9 GeomTolerance.157.1 ( T 8 TV 1, V 0.254 )
+        0:1:4:9 GeomTolerance.157.1 ( T 9 TV 1, V 0.254 )
                 0:1:4:10 Datum.157.1.1 ( )
  0:1:1:2:155 Shape.158
         0:1:4:8 Dimension.158.1 ( T 15, V 11.1252, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:11 GeomTolerance.158.1 ( T 9 TV 1, V 0.50800000000000001 )
+        0:1:4:11 GeomTolerance.158.1 ( T 10 TV 1, V 0.50800000000000001 )
                 0:1:4:12 Datum.158.1.1 ( )
                 0:1:4:13 Datum.158.1.2 ( )
  0:1:1:2:156 Shape.159
         0:1:4:8 Dimension.159.1 ( T 15, V 11.1252, VL 64.515999999999991, VU 64.515999999999991, P 0 )
-        0:1:4:11 GeomTolerance.159.1 ( T 9 TV 1, V 0.50800000000000001 )
+        0:1:4:11 GeomTolerance.159.1 ( T 10 TV 1, V 0.50800000000000001 )
                 0:1:4:12 Datum.159.1.1 ( )
                 0:1:4:13 Datum.159.1.2 ( )
  0:1:1:2:157 Shape.160
index 144b1a4..3e99492 100644 (file)
@@ -10,12 +10,12 @@ set ref_data {
  NbOfDatumTarget         : 0
 
  0:1:1:2:1 Shape.4
-        0:1:4:1 GeomTolerance.4.1 ( T 9 TV 1, V 0.34999999999999998 )
+        0:1:4:1 GeomTolerance.4.1 ( T 10 TV 1, V 0.34999999999999998 )
                 0:1:4:2 Datum.4.1.1 ( )
                 0:1:4:3 Datum.4.1.2 ( )
                 0:1:4:4 Datum.4.1.3 ( )
  0:1:1:2:2 Shape.5
-        0:1:4:1 GeomTolerance.5.1 ( T 9 TV 1, V 0.34999999999999998 )
+        0:1:4:1 GeomTolerance.5.1 ( T 10 TV 1, V 0.34999999999999998 )
                 0:1:4:2 Datum.5.1.1 ( )
                 0:1:4:3 Datum.5.1.2 ( )
                 0:1:4:4 Datum.5.1.3 ( )
index 0fd09c9..4902c19 100644 (file)
@@ -24,15 +24,15 @@ set ref_data {
                 0:1:4:3 Datum.71.1.1 ( )
                 0:1:4:4 Datum.71.1.2 ( )
  0:1:1:2:88 Shape.91
-        0:1:4:12 GeomTolerance.91.1 ( T 2 TV 1, V 0.76200000000000001 )
+        0:1:4:12 GeomTolerance.91.1 ( T 4 TV 1, V 0.76200000000000001 )
                 0:1:4:13 Datum.91.1.1 ( )
  0:1:1:2:89 Shape.92
-        0:1:4:12 GeomTolerance.92.1 ( T 2 TV 1, V 0.76200000000000001 )
+        0:1:4:12 GeomTolerance.92.1 ( T 4 TV 1, V 0.76200000000000001 )
                 0:1:4:13 Datum.92.1.1 ( )
  0:1:1:2:118 Shape.121
-        0:1:4:23 Datum target.121.1 ( T 3, A ( L (000), XD (100), RD (010)), L 0 )
+        0:1:4:23 Datum target.121.1 ( T 3, A ( L (000), XD (10-0), RD (-010)), L 0 )
  0:1:1:2:123 Shape.126
-        0:1:4:21 Datum target.126.1 ( T 3, A ( L (000), XD (100), RD (010)), L 0 )
+        0:1:4:21 Datum target.126.1 ( T 3, A ( L (000), XD (10-0), RD (-010)), L 0 )
  0:1:1:2:125 Shape.128
         0:1:4:14 GeomTolerance.128.1 ( T 2 TV 0, V 0.63500000000000001 )
                 0:1:4:15 Datum.128.1.1 ( )
@@ -43,11 +43,13 @@ set ref_data {
                 0:1:4:19 Datum.144.1.2 ( )
  0:1:1:2:152 Shape.155
         0:1:4:22 GeomTolerance.155.1 ( T 9 TV 0, V 0.254 )
+                0:1:4:23 Datum.155.1.1 ( )
  0:1:1:2:153 Shape.156
         0:1:4:7 GeomTolerance.156.1 ( T 2 TV 0, V 0.38100000000000001 )
                 0:1:4:8 Datum.156.1.1 ( )
  0:1:1:2:154 Shape.157
         0:1:4:20 GeomTolerance.157.1 ( T 9 TV 0, V 0.254 )
+                0:1:4:21 Datum.157.1.1 ( )
  0:1:1:2:199 Shape.202
         0:1:4:5 GeomTolerance.202.1 ( T 2 TV 0, V 0.050799999999999998 )
                 0:1:4:6 Datum.202.1.1 ( )