0026689: Necessary to improve STEPCAFControl_Reader to read GD&T data from STEP model...
authorink <ink@opencascade.com>
Tue, 15 Sep 2015 11:58:17 +0000 (14:58 +0300)
committerbugmaster <bugmaster@opencascade.com>
Thu, 5 Nov 2015 08:52:35 +0000 (11:52 +0300)
Small corrections
added tests, corrected remarks
corrected remarks
Fix compilation errors.
Update test case (direction can be exist only for Oriented dimension).
fix compilation warning

43 files changed:
src/RWStepAP214/RWStepAP214_GeneralModule.cxx
src/RWStepAP214/RWStepAP214_ReadWriteModule.cxx
src/RWStepRepr/FILES
src/RWStepRepr/RWStepRepr_RWFeatureForDatumTargetRelationship.cxx [new file with mode: 0644]
src/RWStepRepr/RWStepRepr_RWFeatureForDatumTargetRelationship.hxx [new file with mode: 0644]
src/STEPCAFControl/STEPCAFControl_Reader.cxx
src/STEPCAFControl/STEPCAFControl_Writer.cxx
src/STEPConstruct/FILES
src/STEPConstruct/STEPConstruct_GDTProperty.cxx [new file with mode: 0644]
src/STEPConstruct/STEPConstruct_GDTProperty.hxx [new file with mode: 0644]
src/StepAP214/StepAP214_Protocol.cxx
src/StepRepr/FILES
src/StepRepr/StepRepr_FeatureForDatumTargetRelationship.cxx [new file with mode: 0644]
src/StepRepr/StepRepr_FeatureForDatumTargetRelationship.hxx [new file with mode: 0644]
src/StepShape/StepShape_ValueQualifier.cxx
src/StepShape/StepShape_ValueQualifier.hxx
src/XCAFDimTolObjects/FILES
src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.cxx
src/XCAFDimTolObjects/XCAFDimTolObjects_DatumObject.hxx
src/XCAFDimTolObjects/XCAFDimTolObjects_DatumTargetType.hxx [new file with mode: 0644]
src/XCAFDimTolObjects/XCAFDimTolObjects_DimensionObject.cxx
src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceModif.hxx
src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceObject.cxx
src/XCAFDimTolObjects/XCAFDimTolObjects_GeomToleranceObject.hxx
src/XCAFDimTolObjects/XCAFDimTolObjects_Tool.cxx
src/XCAFDoc/XCAFDoc.cxx
src/XCAFDoc/XCAFDoc.hxx
src/XCAFDoc/XCAFDoc_Datum.cxx
src/XCAFDoc/XCAFDoc_DimTolTool.cxx
src/XCAFDoc/XCAFDoc_DimTolTool.hxx
src/XCAFDoc/XCAFDoc_Dimension.cxx
src/XCAFDoc/XCAFDoc_GeomTolerance.cxx
src/XDEDRAW/XDEDRAW.cxx
src/XDEDRAW/XDEDRAW_GDTs.cxx
tests/gdt/dimensions/A6
tests/gdt/grids.list
tests/gdt/import/A1 [new file with mode: 0644]
tests/gdt/import/A2 [new file with mode: 0644]
tests/gdt/import/A3 [new file with mode: 0644]
tests/gdt/import/A4 [new file with mode: 0644]
tests/gdt/import/A5 [new file with mode: 0644]
tests/gdt/import/begin [new file with mode: 0644]
tests/gdt/import/end [new file with mode: 0644]

index 24adce5..2d99080 100644 (file)
 #include <RWStepRepr_RWReprItemAndLengthMeasureWithUnit.hxx>
 #include <RWStepRepr_RWShapeAspect.hxx>
 #include <RWStepRepr_RWShapeAspectRelationship.hxx>
+#include <RWStepRepr_RWFeatureForDatumTargetRelationship.hxx>
 #include <RWStepRepr_RWShapeAspectTransition.hxx>
 #include <RWStepRepr_RWShapeRepresentationRelationshipWithTransformation.hxx>
 #include <RWStepRepr_RWSpecifiedHigherUsageOccurrence.hxx>
 #include <StepRepr_ShapeAspect.hxx>
 #include <StepRepr_ShapeAspectDerivingRelationship.hxx>
 #include <StepRepr_ShapeAspectRelationship.hxx>
+#include <StepRepr_FeatureForDatumTargetRelationship.hxx>
 #include <StepRepr_ShapeAspectTransition.hxx>
 #include <StepRepr_ShapeRepresentationRelationship.hxx>
 #include <StepRepr_ShapeRepresentationRelationshipWithTransformation.hxx>
@@ -4970,6 +4972,12 @@ void RWStepAP214_GeneralModule::FillSharedCase(const Standard_Integer CN,
       tool.Share(anent,iter);
     }
     break;
+  case 702:
+    {
+      DeclareAndCast(StepRepr_FeatureForDatumTargetRelationship,anent,ent);
+      RWStepRepr_RWFeatureForDatumTargetRelationship tool;
+      tool.Share(anent,iter);
+    }
 
     default : break;
     }
@@ -6917,6 +6925,9 @@ Standard_Boolean RWStepAP214_GeneralModule::NewVoid
   case 701:
     ent = new StepRepr_ValueRepresentationItem;
     break;
+  case 702:
+    ent = new StepRepr_FeatureForDatumTargetRelationship;
+    break;
 
   default: 
     return Standard_False;
index 950b94e..81d240a 100644 (file)
@@ -295,6 +295,7 @@ Handle(atype) result = Handle(atype)::DownCast (start)
 #include <StepBasic_SecurityClassificationLevel.hxx>
 #include <StepRepr_ShapeAspect.hxx>
 #include <StepRepr_ShapeAspectRelationship.hxx>
+#include <StepRepr_FeatureForDatumTargetRelationship.hxx>
 #include <StepRepr_ShapeAspectTransition.hxx>
 #include <StepShape_ShapeDefinitionRepresentation.hxx>
 #include <StepShape_ShapeRepresentation.hxx>
@@ -686,6 +687,7 @@ Handle(atype) result = Handle(atype)::DownCast (start)
 #include <RWStepBasic_RWSecurityClassificationLevel.hxx>
 #include <RWStepRepr_RWShapeAspect.hxx>
 #include <RWStepRepr_RWShapeAspectRelationship.hxx>
+#include <RWStepRepr_RWFeatureForDatumTargetRelationship.hxx>
 #include <RWStepRepr_RWShapeAspectTransition.hxx>
 #include <RWStepShape_RWShapeDefinitionRepresentation.hxx>
 #include <RWStepShape_RWShapeRepresentation.hxx>
@@ -9100,6 +9102,13 @@ void RWStepAP214_ReadWriteModule::ReadStep(const Standard_Integer CN,
       tool.ReadStep (data,num,ach,anent);
     }
     break;
+  case 702:
+    {
+      DeclareAndCast(StepRepr_FeatureForDatumTargetRelationship,anent,ent);
+      RWStepRepr_RWFeatureForDatumTargetRelationship tool;
+      tool.ReadStep (data,num,ach,anent);
+    }
+    break;
 
   default: 
     ach->AddFail("Type Mismatch when reading - Entity");
@@ -13801,6 +13810,13 @@ void RWStepAP214_ReadWriteModule::WriteStep(const Standard_Integer CN,
       tool.WriteStep (SW,anent);
     }
     break;
+  case 702:
+    {
+      DeclareAndCast(StepRepr_FeatureForDatumTargetRelationship,anent,ent);
+      RWStepRepr_RWFeatureForDatumTargetRelationship tool;
+      tool.WriteStep (SW,anent);
+    }
+    break;
 
   default: 
     return;
index 8232885..55feba9 100644 (file)
@@ -38,6 +38,8 @@ RWStepRepr_RWDescriptiveRepresentationItem.cxx
 RWStepRepr_RWDescriptiveRepresentationItem.hxx
 RWStepRepr_RWExtension.cxx
 RWStepRepr_RWExtension.hxx
+RWStepRepr_RWFeatureForDatumTargetRelationship.cxx
+RWStepRepr_RWFeatureForDatumTargetRelationship.hxx
 RWStepRepr_RWFunctionallyDefinedTransformation.cxx
 RWStepRepr_RWFunctionallyDefinedTransformation.hxx
 RWStepRepr_RWGeometricAlignment.cxx
diff --git a/src/RWStepRepr/RWStepRepr_RWFeatureForDatumTargetRelationship.cxx b/src/RWStepRepr/RWStepRepr_RWFeatureForDatumTargetRelationship.cxx
new file mode 100644 (file)
index 0000000..abecde9
--- /dev/null
@@ -0,0 +1,112 @@
+// Created on: 2000-04-18
+// Created by: Andrey BETENEV
+// Copyright (c) 2000-2014 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.
+
+// Generator:  ExpToCas (EXPRESS -> CASCADE/XSTEP Translator) V1.0
+
+#include <Interface_Check.hxx>
+#include <Interface_EntityIterator.hxx>
+#include <RWStepRepr_RWFeatureForDatumTargetRelationship.hxx>
+#include <StepData_StepReaderData.hxx>
+#include <StepData_StepWriter.hxx>
+#include <StepRepr_ShapeAspect.hxx>
+#include <StepRepr_FeatureForDatumTargetRelationship.hxx>
+
+//=======================================================================
+//function : RWStepRepr_RWFeatureForDatumTargetRelationship
+//purpose  : 
+//=======================================================================
+RWStepRepr_RWFeatureForDatumTargetRelationship::RWStepRepr_RWFeatureForDatumTargetRelationship ()
+{
+}
+
+//=======================================================================
+//function : ReadStep
+//purpose  : 
+//=======================================================================
+
+void RWStepRepr_RWFeatureForDatumTargetRelationship::ReadStep (const Handle(StepData_StepReaderData)& data,
+                                                     const Standard_Integer num,
+                                                     Handle(Interface_Check)& ach,
+                                                     const Handle(StepRepr_FeatureForDatumTargetRelationship) &ent) const
+{
+  // Check number of parameters
+  if ( ! data->CheckNbParams(num,4,ach,"feature_for_datum_target-relationship") ) return;
+
+  // Own fields of ShapeAspectRelationship
+
+  Handle(TCollection_HAsciiString) aName;
+  data->ReadString (num, 1, "name", ach, aName);
+
+  Handle(TCollection_HAsciiString) aDescription;
+  Standard_Boolean hasDescription = Standard_True;
+  if ( data->IsParamDefined (num,2) ) {
+    data->ReadString (num, 2, "description", ach, aDescription);
+  }
+  else {
+    hasDescription = Standard_False;
+  }
+
+  Handle(StepRepr_ShapeAspect) aRelatingShapeAspect;
+  data->ReadEntity (num, 3, "relating_shape_aspect", ach, STANDARD_TYPE(StepRepr_ShapeAspect), aRelatingShapeAspect);
+
+  Handle(StepRepr_ShapeAspect) aRelatedShapeAspect;
+  data->ReadEntity (num, 4, "related_shape_aspect", ach, STANDARD_TYPE(StepRepr_ShapeAspect), aRelatedShapeAspect);
+
+  // Initialize entity
+  ent->Init(aName,
+            hasDescription,
+            aDescription,
+            aRelatingShapeAspect,
+            aRelatedShapeAspect);
+}
+
+//=======================================================================
+//function : WriteStep
+//purpose  : 
+//=======================================================================
+
+void RWStepRepr_RWFeatureForDatumTargetRelationship::WriteStep (StepData_StepWriter& SW,
+                                                      const Handle(StepRepr_FeatureForDatumTargetRelationship) &ent) const
+{
+
+  // Own fields of ShapeAspectRelationship
+
+  SW.Send (ent->Name());
+
+  if ( ent->HasDescription() ) {
+    SW.Send (ent->Description());
+  }
+  else SW.SendUndef();
+
+  SW.Send (ent->RelatingShapeAspect());
+
+  SW.Send (ent->RelatedShapeAspect());
+}
+
+//=======================================================================
+//function : Share
+//purpose  : 
+//=======================================================================
+
+void RWStepRepr_RWFeatureForDatumTargetRelationship::Share (const Handle(StepRepr_FeatureForDatumTargetRelationship) &ent,
+                                                  Interface_EntityIterator& iter) const
+{
+
+  // Own fields of ShapeAspectRelationship
+
+  iter.AddItem (ent->RelatingShapeAspect());
+
+  iter.AddItem (ent->RelatedShapeAspect());
+}
diff --git a/src/RWStepRepr/RWStepRepr_RWFeatureForDatumTargetRelationship.hxx b/src/RWStepRepr/RWStepRepr_RWFeatureForDatumTargetRelationship.hxx
new file mode 100644 (file)
index 0000000..47eb8f1
--- /dev/null
@@ -0,0 +1,74 @@
+// Created on: 2000-04-18
+// Created by: Andrey BETENEV
+// Copyright (c) 2000-2014 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 _RWStepRepr_RWFeatureForDatumTargetRelationship_HeaderFile
+#define _RWStepRepr_RWFeatureForDatumTargetRelationship_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Handle.hxx>
+
+#include <Standard_Integer.hxx>
+class StepData_StepReaderData;
+class Interface_Check;
+class StepRepr_FeatureForDatumTargetRelationship;
+class StepData_StepWriter;
+class Interface_EntityIterator;
+
+
+//! Read & Write tool for FeatureForDatumTargetRelationship 
+class RWStepRepr_RWFeatureForDatumTargetRelationship 
+{
+public:
+
+  DEFINE_STANDARD_ALLOC
+
+  
+  //! Empty constructor
+  Standard_EXPORT RWStepRepr_RWFeatureForDatumTargetRelationship();
+  
+  //! Reads ShapeAspectRelationship
+  Standard_EXPORT void ReadStep (const Handle(StepData_StepReaderData)& data, const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(StepRepr_FeatureForDatumTargetRelationship)& ent) const;
+  
+  //! Writes ShapeAspectRelationship
+  Standard_EXPORT void WriteStep (StepData_StepWriter& SW, const Handle(StepRepr_FeatureForDatumTargetRelationship)& ent) const;
+  
+  //! Fills data for graph (shared items)
+  Standard_EXPORT void Share (const Handle(StepRepr_FeatureForDatumTargetRelationship)& ent, Interface_EntityIterator& iter) const;
+
+
+
+
+protected:
+
+
+
+
+
+private:
+
+
+
+
+
+};
+
+
+
+
+
+
+
+#endif // _RWStepRepr_RWFeatureForDatumTargetRelationship_HeaderFile
index e25075a..954e948 100644 (file)
 #include <BRep_Builder.hxx>
 #include <Interface_EntityIterator.hxx>
 #include <Interface_InterfaceModel.hxx>
+#include <StepData_StepModel.hxx>
+#include <HeaderSection_FileSchema.hxx>
 #include <Interface_Static.hxx>
 #include <NCollection_DataMap.hxx>
 #include <OSD_Path.hxx>
 #include <Quantity_Color.hxx>
 #include <StepAP214_AppliedExternalIdentificationAssignment.hxx>
 #include <StepBasic_ConversionBasedUnitAndLengthUnit.hxx>
+#include <StepBasic_ConversionBasedUnitAndPlaneAngleUnit.hxx>
 #include <StepBasic_ConversionBasedUnitAndMassUnit.hxx>
 #include <StepBasic_DerivedUnit.hxx>
 #include <StepBasic_DerivedUnitElement.hxx>
@@ -51,6 +54,9 @@
 #include <STEPConstruct_UnitContext.hxx>
 #include <STEPConstruct_ValidationProps.hxx>
 #include <STEPControl_Reader.hxx>
+#include <StepGeom_GeometricRepresentationItem.hxx>
+#include <StepGeom_Axis2Placement3d.hxx>
+#include <StepGeom_Direction.hxx>
 #include <StepDimTol_AngularityTolerance.hxx>
 #include <StepDimTol_CircularRunoutTolerance.hxx>
 #include <StepDimTol_CoaxialityTolerance.hxx>
 #include <StepDimTol_Datum.hxx>
 #include <StepDimTol_DatumFeature.hxx>
 #include <StepDimTol_DatumReference.hxx>
+#include <StepDimTol_DatumReferenceElement.hxx>
+#include <StepDimTol_DatumReferenceCompartment.hxx>
+#include <StepDimTol_DatumSystem.hxx>
 #include <StepDimTol_FlatnessTolerance.hxx>
 #include <StepDimTol_GeometricTolerance.hxx>
 #include <StepDimTol_GeometricToleranceWithDatumReference.hxx>
 #include <StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthDatRef.hxx>
 #include <StepDimTol_HArray1OfDatumReference.hxx>
 #include <StepDimTol_LineProfileTolerance.hxx>
 #include <StepDimTol_ModifiedGeometricTolerance.hxx>
 #include <StepDimTol_ParallelismTolerance.hxx>
 #include <StepDimTol_PerpendicularityTolerance.hxx>
 #include <StepDimTol_PositionTolerance.hxx>
+#include <StepDimTol_ProjectedZoneDefinition.hxx>
 #include <StepDimTol_RoundnessTolerance.hxx>
+#include <StepDimTol_RunoutZoneDefinition.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 <StepDimTol_GeometricToleranceWithModifiers.hxx>
+#include <StepDimTol_HArray1OfGeometricToleranceModifier.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod.hxx>
+#include <StepDimTol_GeoTolAndGeoTolWthMod.hxx>
+#include <StepDimTol_GeometricToleranceWithMaximumTolerance.hxx>
+#include <StepDimTol_PlacedDatumTargetFeature.hxx>
 #include <StepRepr_AssemblyComponentUsage.hxx>
 #include <StepRepr_CharacterizedDefinition.hxx>
+#include <StepRepr_CompoundRepresentationItem.hxx>
 #include <StepRepr_DescriptiveRepresentationItem.hxx>
 #include <StepRepr_HArray1OfRepresentationItem.hxx>
 #include <StepRepr_MeasureRepresentationItem.hxx>
 #include <StepRepr_PropertyDefinitionRepresentation.hxx>
 #include <StepRepr_Representation.hxx>
 #include <StepRepr_RepresentationItem.hxx>
+#include <StepRepr_HArray1OfRepresentationItem.hxx>
 #include <StepRepr_RepresentationRelationship.hxx>
 #include <StepRepr_RepresentedDefinition.hxx>
 #include <StepRepr_ReprItemAndLengthMeasureWithUnit.hxx>
+#include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnit.hxx>
 #include <StepRepr_SequenceOfRepresentationItem.hxx>
 #include <StepRepr_ShapeAspect.hxx>
+#include <StepRepr_CompositeShapeAspect.hxx>
+#include <StepRepr_AllAroundShapeAspect.hxx>
+#include <StepRepr_CompShAspAndDatumFeatAndShAsp.hxx>
 #include <StepRepr_ShapeAspectRelationship.hxx>
 #include <StepRepr_ShapeRepresentationRelationship.hxx>
 #include <StepRepr_SpecifiedHigherUsageOccurrence.hxx>
 #include <StepRepr_ValueRange.hxx>
+#include <StepRepr_FeatureForDatumTargetRelationship.hxx>
 #include <StepShape_AdvancedFace.hxx>
+#include <StepShape_AdvancedBrepShapeRepresentation.hxx>
+#include <StepShape_AngleRelator.hxx>
+#include <StepShape_AngularSize.hxx>
+#include <StepShape_AngularLocation.hxx>
 #include <StepShape_ClosedShell.hxx>
 #include <StepShape_ConnectedFaceSet.hxx>
 #include <StepShape_ContextDependentShapeRepresentation.hxx>
+#include <StepRepr_CompGroupShAspAndCompShAspAndDatumFeatAndShAsp.hxx>
+#include <StepRepr_CompShAspAndDatumFeatAndShAsp.hxx>
 #include <StepShape_DimensionalCharacteristicRepresentation.hxx>
+#include <StepShape_DimensionalSizeWithPath.hxx>
+#include <StepShape_DimensionalLocationWithPath.hxx>
+#include <StepShape_ShapeDimensionRepresentationItem.hxx>
+#include <StepShape_ShapeRepresentationWithParameters.hxx>
+#include <StepShape_HArray1OfShapeDimensionRepresentationItem.hxx>
 #include <StepShape_DimensionalSize.hxx>
+#include <StepShape_DimensionalLocation.hxx>
 #include <StepShape_EdgeCurve.hxx>
 #include <StepShape_EdgeLoop.hxx>
 #include <StepShape_GeometricSet.hxx>
 #include <StepShape_HArray1OfFaceBound.hxx>
 #include <StepShape_HArray1OfOrientedEdge.hxx>
 #include <StepShape_HArray1OfShell.hxx>
+#include <StepShape_LimitsAndFits.hxx>
 #include <StepShape_Loop.hxx>
 #include <StepShape_ManifoldSolidBrep.hxx>
+#include <StepShape_PlusMinusTolerance.hxx>
+#include <StepShape_QualifiedRepresentationItem.hxx>
 #include <StepShape_OpenShell.hxx>
 #include <StepShape_ShapeDefinitionRepresentation.hxx>
 #include <StepShape_ShapeDimensionRepresentation.hxx>
 #include <StepShape_ShapeRepresentation.hxx>
 #include <StepShape_ShellBasedSurfaceModel.hxx>
 #include <StepShape_SolidModel.hxx>
+#include <StepShape_ToleranceMethodDefinition.hxx>
+#include <StepShape_ToleranceValue.hxx>
+#include <StepShape_ValueFormatTypeQualifier.hxx>
 #include <StepShape_Vertex.hxx>
 #include <StepVisual_Invisibility.hxx>
 #include <StepVisual_LayeredItem.hxx>
 #include <StepVisual_PresentationStyleByContext.hxx>
 #include <StepVisual_StyleContextSelect.hxx>
 #include <StepVisual_StyledItem.hxx>
+#include <StepShape_TypeQualifier.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_HAsciiString.hxx>
 #include <TColStd_HArray1OfReal.hxx>
 #include <TDF_Tool.hxx>
 #include <TDocStd_Document.hxx>
 #include <TNaming_NamedShape.hxx>
+#include <TopoDS.hxx>
 #include <TopoDS_Compound.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <TopoDS_Shape.hxx>
 #include <XCAFDoc_ColorTool.hxx>
 #include <XCAFDoc_DataMapOfShapeLabel.hxx>
 #include <XCAFDoc_DimTolTool.hxx>
+#include <XCAFDoc_Dimension.hxx>
+#include <XCAFDoc_Datum.hxx>
+#include <XCAFDoc_GeomTolerance.hxx>
 #include <XCAFDoc_DocumentTool.hxx>
 #include <XCAFDoc_GraphNode.hxx>
 #include <XCAFDoc_LayerTool.hxx>
 #include <XCAFDoc_MaterialTool.hxx>
 #include <XCAFDoc_ShapeTool.hxx>
 #include <XCAFDoc_Volume.hxx>
+#include <XCAFDimTolObjects_DimensionModifiersSequence.hxx>
+#include <XCAFDimTolObjects_GeomToleranceType.hxx>
+#include <XCAFDimTolObjects_DimensionObject.hxx>
+#include <XCAFDimTolObjects_GeomToleranceObject.hxx>
+#include <XCAFDimTolObjects_DatumObject.hxx>
 #include <XSControl_TransferReader.hxx>
 #include <XSControl_WorkSession.hxx>
-
+#include <StepAP242_GeometricItemSpecificUsage.hxx>
+#include <StepGeom_CartesianPoint.hxx>
+#include <STEPConstruct_GDTProperty.hxx>
 // skl 21.08.2003 for reading G&DT
 //#include <StepRepr_CompoundItemDefinition.hxx>
 //#include <StepRepr_CompoundItemDefinitionMember.hxx>
@@ -1567,9 +1624,9 @@ static Standard_Boolean GetLengthConversionFactor(Handle(StepBasic_NamedUnit)& N
       Handle(StepBasic_SiUnit) SU = Handle(StepBasic_SiUnit)::DownCast(NU2);
       if(SU->Name()==StepBasic_sunMetre) {
         if(SU->HasPrefix()) 
-         afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
-       // convert m to mm
-       afact *= 1000.;
+          afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
+        // convert m to mm
+        afact *= 1000.;
       }
     }
   }
@@ -1578,6 +1635,35 @@ static Standard_Boolean GetLengthConversionFactor(Handle(StepBasic_NamedUnit)& N
 
 
 //=======================================================================
+//function : GetAngleConversionFactor
+//purpose  : 
+//=======================================================================
+static Standard_Boolean GetAngleConversionFactor(Handle(StepBasic_NamedUnit)& NU,
+                                                  Standard_Real& afact)
+{
+  afact=1.;
+  if( !NU->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndPlaneAngleUnit)) ) return Standard_False;
+  Handle(StepBasic_ConversionBasedUnitAndPlaneAngleUnit) CBULU =
+    Handle(StepBasic_ConversionBasedUnitAndPlaneAngleUnit)::DownCast(NU);
+  Handle(StepBasic_MeasureWithUnit) MWUCBU = CBULU->ConversionFactor();
+  afact = MWUCBU->ValueComponent();
+  StepBasic_Unit anUnit2 = MWUCBU->UnitComponent();
+  if(anUnit2.CaseNum(anUnit2.Value())==1) {
+    Handle(StepBasic_NamedUnit) NU2 = anUnit2.NamedUnit();
+    if(NU2->IsKind(STANDARD_TYPE(StepBasic_SiUnit))) {
+      Handle(StepBasic_SiUnit) SU = Handle(StepBasic_SiUnit)::DownCast(NU2);
+      if(SU->Name()==StepBasic_sunRadian) {
+        if(SU->HasPrefix()) 
+          afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
+        // convert radian to deg
+        afact *= 180/M_PI;
+      }
+    }
+  }
+  return Standard_True;
+}
+
+//=======================================================================
 //function : GetMassConversionFactor
 //purpose  : 
 //=======================================================================
@@ -1597,7 +1683,7 @@ static Standard_Boolean GetMassConversionFactor(Handle(StepBasic_NamedUnit)& NU,
       Handle(StepBasic_SiUnit) SU = Handle(StepBasic_SiUnit)::DownCast(NU2);
       if(SU->Name()==StepBasic_sunGram) {
         if(SU->HasPrefix())
-         afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
+          afact *= STEPConstruct_UnitContext::ConvertSiPrefix (SU->Prefix());
       }
     }
   }
@@ -1668,234 +1754,1439 @@ static Standard_Boolean ReadDatums(const Handle(XCAFDoc_ShapeTool) &STool,
 
 
 //=======================================================================
-//function : ReadGDTs
+//function : setDatumToXCAF
 //purpose  : 
 //=======================================================================
-
-Standard_Boolean STEPCAFControl_Reader::ReadGDTs(const Handle(XSControl_WorkSession) &WS,
-                                                 Handle(TDocStd_Document)& Doc) const
+static Standard_Boolean setDatumToXCAF(const Handle(StepDimTol_Datum)& theDat,
+                                        const TDF_Label theGDTL,
+                                        const Standard_Integer thePositionCounter,
+                                        const XCAFDimTolObjects_DatumModifiersSequence& aXCAFModifiers,
+                                        const XCAFDimTolObjects_DatumModifWithValue aXCAFModifWithVal,
+                                        const Standard_Real aModifValue,
+                                        const Handle(TDocStd_Document)& theDoc,
+                                        const Handle(XSControl_WorkSession)& theWS)
 {
-  Handle(Interface_InterfaceModel) Model = WS->Model();
-  Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool( Doc->Main() );
-  Handle(XSControl_TransferReader) TR = WS->TransferReader();
-  Handle(Transfer_TransientProcess) TP = TR->TransientProcess();
-  Handle(XCAFDoc_DimTolTool) DGTTool = XCAFDoc_DocumentTool::DimTolTool( Doc->Main() );
-  if ( DGTTool.IsNull() ) return Standard_False;
-  
-  Standard_Integer nb = Model->NbEntities();
-  const Interface_Graph& graph = TP->Graph();
-  for(Standard_Integer i=1; i<=nb; i++) {
-    Handle(Standard_Transient) ent = Model->Value(i);
-    if(ent->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))) {
-      Handle(StepRepr_ShapeAspect) SA = Handle(StepRepr_ShapeAspect)::DownCast(ent);
-      // find RepresentationItem for current ShapeAspect
-      Handle(StepRepr_RepresentationItem) RI;
-      Handle(StepRepr_PropertyDefinition) PropD;
-      Interface_EntityIterator subs3 = graph.Sharings(SA);
-      for(subs3.Start(); subs3.More() && PropD.IsNull(); subs3.Next()) {
-        PropD = Handle(StepRepr_PropertyDefinition)::DownCast(subs3.Value());
+  Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
+  Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
+  Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
+  Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
+  const Interface_Graph& aGraph = aTP->Graph();
+  Handle(XCAFDoc_Datum) aDat;
+  TDF_Label aShL;
+  Standard_Boolean aRefShapeIsFound = Standard_False;
+  Standard_Boolean aFirstStep = Standard_True;
+  Interface_EntityIterator anIterD = aGraph.Sharings(theDat);
+  for(anIterD.Start(); anIterD.More(); anIterD.Next()) {
+    Handle(StepRepr_ShapeAspectRelationship) aSAR = 
+      Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIterD.Value());
+    if(aSAR.IsNull()) continue;
+
+    Handle(StepRepr_ShapeAspect) aSA = aSAR->RelatingShapeAspect();
+    if (aSA.IsNull()) continue;
+    Handle(StepAP242_GeometricItemSpecificUsage) aPGISU;
+    if(aSA->IsKind(STANDARD_TYPE(StepRepr_CompShAspAndDatumFeatAndShAsp)))
+    {
+      //processing for complex entity
+      Interface_EntityIterator anIterC = aGraph.Sharings(aSA);
+      for(anIterC.Start(); anIterC.More(); anIterC.Next()) {
+        Handle(StepRepr_ShapeAspectRelationship) SAR = 
+          Handle(StepRepr_ShapeAspectRelationship)::DownCast(anIterC.Value());
+        if(SAR.IsNull()) continue;
+        Handle(StepRepr_ShapeAspect) aS = 
+          Handle(StepRepr_ShapeAspect)::DownCast(SAR->RelatedShapeAspect());
+        if(aS.IsNull()) continue;
+        Interface_EntityIterator anIterSA = aGraph.Sharings(aS);
+        for(anIterSA.Start(); anIterSA.More() && aPGISU.IsNull(); anIterSA.Next()) {
+          aPGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterSA.Value());
+        }
+        if(!aPGISU.IsNull()){
+          aSA = aS;
+          break;
+        }
       }
-      if(PropD.IsNull()) continue;
-      Interface_EntityIterator subs4 = graph.Sharings(PropD);
-      for(subs4.Start(); subs4.More(); subs4.Next()) {
-        Handle(StepShape_ShapeDefinitionRepresentation) SDR = 
-          Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs4.Value());
-        if(!SDR.IsNull()) {
-          Handle(StepRepr_Representation) Repr = SDR->UsedRepresentation();
-          if( !Repr.IsNull() && Repr->NbItems()>0 ) {
-            RI = Repr->ItemsValue(1);
+    }
+    else if(aSA->IsKind(STANDARD_TYPE(StepDimTol_PlacedDatumTargetFeature)))
+    {
+      //processing for datum target
+      Interface_EntityIterator anIterDTF = aGraph.Shareds(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());
+            }
           }
         }
       }
-      if(RI.IsNull()) continue;
-      // read DGT entities:
-      subs3 = graph.Sharings(SA);
-      for(subs3.Start(); subs3.More(); subs3.Next()) {
-        if(subs3.Value()->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) {
-          // read dimensions
-          Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(RI);
-          if(EC.IsNull()) continue;
-          Handle(TCollection_HAsciiString) aName;
-          Handle(StepShape_DimensionalSize) DimSize = 
-            Handle(StepShape_DimensionalSize)::DownCast(subs3.Value());
-          Standard_Real dim1=-1.,dim2=-1.;
-          subs4 = graph.Sharings(DimSize);
-          for(subs4.Start(); subs4.More(); subs4.Next()) {
-            Handle(StepShape_DimensionalCharacteristicRepresentation) DimCharR = 
-              Handle(StepShape_DimensionalCharacteristicRepresentation)::DownCast(subs4.Value());
-            if(!DimCharR.IsNull()) {
-              Handle(StepShape_ShapeDimensionRepresentation) SDimR = DimCharR->Representation();
-              if(!SDimR.IsNull() && SDimR->NbItems()>0) {
-                Handle(StepRepr_RepresentationItem) aRI = SDimR->ItemsValue(1);
-                Handle(StepRepr_ValueRange) VR = Handle(StepRepr_ValueRange)::DownCast(aRI);
-                if(!VR.IsNull()) {
-                  aName = VR->Name();
-                  //StepRepr_CompoundItemDefinition CID = VR->ItemElement();
-                  //if(CID.IsNull()) continue;
-                  //Handle(StepRepr_CompoundItemDefinitionMember) CIDM = 
-                  //  Handle(StepRepr_CompoundItemDefinitionMember)::DownCast(CID.Value());
-                  //if(CIDM.IsNull()) continue;
-                  //if(CIDM->ArrTransient().IsNull()) continue;
-                  //Handle(StepRepr_HArray1OfRepresentationItem) HARI;
-                  //if(CID.CaseMem(CIDM)==1)
-                  //  HARI = CID.ListRepresentationItem();
-                  //if(CID.CaseMem(CIDM)==2)
-                  //  HARI = CID.SetRepresentationItem();
-                  Handle(StepRepr_HArray1OfRepresentationItem) HARI = VR->ItemElement();
-                  if(HARI.IsNull()) continue;
-                  if(HARI->Length()>0) {
-                    Handle(StepRepr_RepresentationItem) RI1 =
-                      Handle(StepRepr_RepresentationItem)::DownCast(HARI->Value(1));
-                    if(RI1.IsNull()) continue;
-                    if(RI1->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
-                      Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMWU =
-                        Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(RI1);
-                      dim1 = RILMWU->GetMeasureWithUnit()->ValueComponent();
-                      StepBasic_Unit anUnit = RILMWU->GetMeasureWithUnit()->UnitComponent();
-                      Standard_Real afact=1.;
-                      if(anUnit.IsNull()) continue;
-                      if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
-                      Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
-                      if(GetLengthConversionFactor(NU,afact)) dim1=dim1*afact;
+    }
+    if (aSA.IsNull()) continue;
+    Interface_EntityIterator anIterDSWP = aGraph.Sharings(aSA);
+    for(anIterDSWP.Start(); anIterDSWP.More() && aPGISU.IsNull(); anIterDSWP.Next()) {
+      aPGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value());
+    }
+    if(aPGISU.IsNull()) continue;
+    // get representation item
+    Handle(StepRepr_RepresentationItem) aRI;
+    for(Standard_Integer i = 1 ; i <= aPGISU->NbIdentifiedItem() && aRI.IsNull(); i++)
+    {
+      aRI = Handle(StepRepr_RepresentationItem)::DownCast(aPGISU->IdentifiedItemValue(i));
+    }
+    if(aRI.IsNull()) continue;
+    Standard_Integer index = aTP->MapIndex(aRI);
+    TopoDS_Shape aSh;
+    if(index >0) {
+      Handle(Transfer_Binder) binder = aTP->MapItem(index);
+      aSh = TransferBRep::ShapeResult(binder);
+    }
+    if(aSh.IsNull()) continue; 
+    if( !aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True) ) continue;
+    Handle(TDataStd_TreeNode) aNode;
+    if(aFirstStep && aShL.FindAttribute(XCAFDoc::DatumRefGUID(),aNode) && aNode->HasFirst() &&
+       aNode->First()->Label().FindAttribute(XCAFDoc_Datum::GetID(),aDat))
+    {
+      //if datums already attached, not need add datum target
+      aRefShapeIsFound = Standard_True;
+    }
+    aFirstStep = Standard_False;
+    Handle(XCAFDimTolObjects_DatumObject) aDatObj;
+    if(aSA->IsKind(STANDARD_TYPE(StepDimTol_PlacedDatumTargetFeature)))
+    {
+      if(!aRefShapeIsFound)
+      {
+        //if datum targers not yet added
+        TDF_Label aDatL = aDGTTool->AddDatum();
+        aDat = XCAFDoc_Datum::Set(aDatL);
+        aDGTTool->SetDatum(aShL, aDatL);
+        aDatObj = aDat->GetObject();
+        aDatObj->SetName(theDat->Identification());
+        aDatObj->IsDatumTarget(Standard_True);
+        XCAFDimTolObjects_DatumTargetType aType;
+        if(STEPConstruct_GDTProperty::GetDatumTargetType(aSA->Description(),aType))
+        {
+          aDatObj->SetDatumTargetType(aType);
+          if(aType == XCAFDimTolObjects_DatumTargetType_Area)
+          {
+            Interface_EntityIterator anIterDTF = aGraph.Shareds(aSA);
+            for(anIterDTF.Start(); anIterDTF.More(); anIterDTF.Next()) {
+              if(anIterDTF.Value()->IsKind(STANDARD_TYPE(StepAP242_GeometricItemSpecificUsage)))
+              {
+                Handle(StepAP242_GeometricItemSpecificUsage) aGISU
+                  = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value());
+                Handle(StepRepr_RepresentationItem) aRI;
+                if(aPGISU->NbIdentifiedItem() > 0) {
+                  aRI = Handle(StepRepr_RepresentationItem)::DownCast(aPGISU->IdentifiedItemValue(1));
+                }
+                if(aRI.IsNull()) continue;
+                Standard_Integer index = aTP->MapIndex(aRI);
+                TopoDS_Shape aSh;
+                if(index >0) {
+                  Handle(Transfer_Binder) binder = aTP->MapItem(index);
+                  aSh = TransferBRep::ShapeResult(binder);
+                  aDatObj->SetDatumTarget(aSh);
+                }
+              }
+            }
+          }
+          else
+          {
+            Interface_EntityIterator anIterDTF = aGraph.Shareds(aSA);
+            for(anIterDTF.Start(); anIterDTF.More(); anIterDTF.Next()) {
+              if(anIterDTF.Value()->IsKind(STANDARD_TYPE(StepRepr_PropertyDefinition)))
+              {
+                Interface_EntityIterator anIterPD = aGraph.Shareds(anIterDTF.Value());
+                for(anIterPD.Start(); anIterPD.More(); anIterPD.Next()) {
+                  if(anIterPD.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation)))
+                  {
+                    Interface_EntityIterator anIterSDR = aGraph.Sharings(anIterPD.Value());
+                    for(anIterSDR.Start(); anIterSDR.More(); anIterSDR.Next()) {
+                      if(anIterSDR.Value()->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentationWithParameters)))
+                      {
+                        Handle(StepShape_ShapeRepresentationWithParameters) aSRWP
+                          = Handle(StepShape_ShapeRepresentationWithParameters)::DownCast(anIterSDR.Value());
+                        for(Standard_Integer r = aSRWP->Items()->Lower(); r <= aSRWP->Items()->Upper(); r++)
+                        {
+                          if(aSRWP->ItemsValue(r)->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
+                          {
+                            Handle(StepGeom_Axis2Placement3d) anAx
+                              = Handle(StepGeom_Axis2Placement3d)::DownCast(aSRWP->ItemsValue(r));
+                            Handle(TColStd_HArray1OfReal) aDirArr = anAx->Axis()->DirectionRatios();
+                            Handle(TColStd_HArray1OfReal) aDirRArr = anAx->RefDirection()->DirectionRatios();
+                            Handle(TColStd_HArray1OfReal) aLocArr = anAx->Location()->Coordinates();
+                            gp_Dir aDir;
+                            gp_Dir aDirR;
+                            gp_Pnt aPnt;
+                            if(!aDirArr.IsNull() && aDirArr->Length() > 2 &&
+                              !aDirRArr.IsNull() && aDirRArr->Length() > 2 && 
+                              !aLocArr.IsNull() && aLocArr->Length() > 2)
+                            {
+                              aDir.SetCoord(aDirArr->Lower(), aDirArr->Lower()+1, aDirArr->Lower()+2);
+                              aDirR.SetCoord(aDirRArr->Lower(), aDirRArr->Lower()+1, aDirRArr->Lower()+2);
+                              aPnt.SetCoord(aLocArr->Lower(), aLocArr->Lower()+1, aLocArr->Lower()+2);
+                              gp_Ax2 anA(aPnt, aDir, aDirR);
+                              aDatObj->SetDatumTargetAxis(anA);
+                            }
+                          }
+                          else if(aSRWP->ItemsValue(r)->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit)))
+                          {
+                            Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) aM =
+                              Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(aSRWP->ItemsValue(r)); 
+                            Standard_Real aVal = aM->GetMeasureWithUnit()->ValueComponent();
+                            StepBasic_Unit anUnit = aM->GetMeasureWithUnit()->UnitComponent();
+                            Standard_Real aFact=1.;
+                            if(anUnit.IsNull()) continue;
+                            if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
+                            Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
+                            if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
+                            if(aM->Name()->String().IsEqual("target length") ||
+                              aM->Name()->String().IsEqual("target diameter"))
+                              aDatObj->SetDatumTargetLength(aVal);
+                            else
+                              aDatObj->SetDatumTargetWidth(aVal);
+                          }
+                        }
+                      }
                     }
                   }
-                  if(HARI->Length()>1) {
-                    Handle(StepRepr_RepresentationItem) RI2 =
-                      Handle(StepRepr_RepresentationItem)::DownCast(HARI->Value(2));
-                    if(RI2.IsNull()) continue;
-                    if(RI2->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
-                      Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMWU =
-                        Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(RI2);
-                      dim2 = RILMWU->GetMeasureWithUnit()->ValueComponent();
-                      StepBasic_Unit anUnit = RILMWU->GetMeasureWithUnit()->UnitComponent();
-                      Standard_Real afact=1.;
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+    else
+    {
+      //processing for darum feature
+      TDF_Label aDatL = aDGTTool->AddDatum();
+      aDat = XCAFDoc_Datum::Set(aDatL);
+      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);
+    }
+    if(!aDatObj.IsNull())
+      aDat->SetObject(aDatObj);
+  }
+  return !aDat.IsNull();
+}
+
+
+//=======================================================================
+//function : ReadDatums
+//purpose  : auxilary
+//=======================================================================
+static Standard_Boolean readDatumsAP242(const Handle(Standard_Transient)& theEnt,
+                                        const TDF_Label theGDTL,
+                                        const Handle(TDocStd_Document)& theDoc,
+                                        const Handle(XSControl_WorkSession)& theWS)
+{
+  Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
+  Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
+  Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
+  Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
+  const Interface_Graph& aGraph = aTP->Graph();
+
+  Interface_EntityIterator anIter = aGraph.Shareds(theEnt);
+  for(anIter.Start(); anIter.More(); anIter.Next()) {
+    Handle(Standard_Transient) anAtr = anIter.Value();
+    if(anAtr->IsKind(STANDARD_TYPE(StepDimTol_DatumSystem)))
+    {
+      Standard_Integer aPositionCounter = 0;//position on frame 
+      Handle(StepDimTol_DatumSystem) aDS = Handle(StepDimTol_DatumSystem)::DownCast(anAtr);
+      Interface_EntityIterator anIterDS = aGraph.Sharings(aDS);
+      for(anIterDS.Start(); anIterDS.More(); anIterDS.Next()) {
+        Handle(Standard_Transient) anAtrDS = anIterDS.Value();
+        if(anAtrDS->IsKind(STANDARD_TYPE(StepAP242_GeometricItemSpecificUsage)))
+        {
+          //get axis
+          Handle(StepAP242_GeometricItemSpecificUsage)aAxGISUI
+            = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anAtrDS);
+          if (aAxGISUI->IdentifiedItemValue(1)->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
+          {
+            Handle(StepGeom_Axis2Placement3d) anAx
+              = Handle(StepGeom_Axis2Placement3d)::DownCast(aAxGISUI->IdentifiedItemValue(1));
+            Handle(XCAFDoc_GeomTolerance) aTol;
+            if(theGDTL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aTol))
+            {
+              Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aTol->GetObject();
+              Handle(TColStd_HArray1OfReal) aDirArr = anAx->Axis()->DirectionRatios();
+              Handle(TColStd_HArray1OfReal) aDirRArr = anAx->RefDirection()->DirectionRatios();
+              Handle(TColStd_HArray1OfReal) aLocArr = anAx->Location()->Coordinates();
+              gp_Dir aDir;
+              gp_Dir aDirR;
+              gp_Pnt aPnt;
+              if(!aDirArr.IsNull() && aDirArr->Length() > 2 &&
+                !aDirRArr.IsNull() && aDirRArr->Length() > 2 && 
+                !aLocArr.IsNull() && aLocArr->Length() > 2)
+              {
+                aDir.SetCoord(aDirArr->Lower(), aDirArr->Lower()+1, aDirArr->Lower()+2);
+                aDirR.SetCoord(aDirRArr->Lower(), aDirRArr->Lower()+1, aDirRArr->Lower()+2);
+                aPnt.SetCoord(aLocArr->Lower(), aLocArr->Lower()+1, aLocArr->Lower()+2);
+                gp_Ax2 anA(aPnt, aDir, aDirR);
+                anObj->SetAxis(anA);
+                aTol->SetObject(anObj);
+              }
+            }
+          }
+        }
+      }
+      if (aDS->NbConstituents() > 0)
+      {
+        //get datum feature and datum target from datum system
+        Handle(StepDimTol_HArray1OfDatumReferenceCompartment) aDRCA = aDS->Constituents();
+        if(!aDRCA.IsNull())
+        {
+          for(Standard_Integer i = aDRCA->Lower(); i <= aDRCA->Upper(); i++)
+          {
+            Handle(StepDimTol_DatumReferenceCompartment) aDRC
+              = Handle(StepDimTol_DatumReferenceCompartment)::DownCast(aDRCA->Value(i));
+            //gete modifiers
+            Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModif = aDRC->Modifiers();
+            XCAFDimTolObjects_DatumModifiersSequence aXCAFModifiers;
+            XCAFDimTolObjects_DatumModifWithValue aXCAFModifWithVal = XCAFDimTolObjects_DatumModifWithValue_None;
+            Standard_Real aModifValue = 0;
+            if(!aModif.IsNull())
+            {
+              for(Standard_Integer m = aModif->Lower(); m <= aModif->Upper(); m++)
+              {
+                if(aModif->Value(m).CaseNumber() == 2)
+                  aXCAFModifiers.Append(
+                  (XCAFDimTolObjects_DatumSingleModif)aModif->Value(m).
+                  SimpleDatumReferenceModifierMember()->Value());
+                else if (aModif->Value(m).CaseNumber() == 1)
+                {
+                  aXCAFModifWithVal = (XCAFDimTolObjects_DatumModifWithValue)(aModif->Value(m).DatumReferenceModifierWithValue()->ModifierType() + 1);
+                  Standard_Real aVal = aModif->Value(m).DatumReferenceModifierWithValue()->ModifierValue()->ValueComponent();
+                  StepBasic_Unit anUnit = aModif->Value(m).DatumReferenceModifierWithValue()->ModifierValue()->UnitComponent();
+                  Standard_Real aFact=1.;
+                  if(anUnit.IsNull()) continue;
+                  if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
+                  Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
+                  if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
+                  aModifValue = aVal;
+                }
+              }
+            }
+            aPositionCounter++;
+            Interface_EntityIterator anIterDRC = aGraph.Shareds(aDRC);
+            for(anIterDRC.Start(); anIterDRC.More(); anIterDRC.Next()) {
+              
+              if(anIterDRC.Value()->IsKind(STANDARD_TYPE(StepDimTol_Datum)))
+              {
+                Handle(StepDimTol_Datum) aD = Handle(StepDimTol_Datum)::DownCast(anIterDRC.Value());
+                setDatumToXCAF(aD, theGDTL, aPositionCounter, aXCAFModifiers, aXCAFModifWithVal, aModifValue,theDoc, theWS);
+              }
+              else if(anIterDRC.Value()->IsKind(STANDARD_TYPE(StepDimTol_DatumReferenceElement)))
+              {
+                Handle(StepDimTol_DatumReferenceElement) aDRE 
+                  = Handle(StepDimTol_DatumReferenceElement)::DownCast(anIterDRC.Value());
+                //get modifiers from group of datums
+                Handle(StepDimTol_HArray1OfDatumReferenceModifier) aModifE = aDRE->Modifiers();
+                if(!aModifE.IsNull())
+                {
+                  for(Standard_Integer k = aModifE->Lower(); k <= aModifE->Upper(); k++)
+                  {
+                    if(aModifE->Value(k).CaseNumber() == 1)
+                      aXCAFModifiers.Append(
+                      (XCAFDimTolObjects_DatumSingleModif)aModifE->Value(k).
+                      SimpleDatumReferenceModifierMember()->Value());
+                    else if (aModifE->Value(k).CaseNumber() == 2)
+                    {
+                      aXCAFModifWithVal = (XCAFDimTolObjects_DatumModifWithValue)(aModifE->Value(k).DatumReferenceModifierWithValue()->ModifierType() + 1);
+                      Standard_Real aVal = aModifE->Value(k).DatumReferenceModifierWithValue()->ModifierValue()->ValueComponent();
+                      StepBasic_Unit anUnit = aModifE->Value(k).DatumReferenceModifierWithValue()->ModifierValue()->UnitComponent();
+                      Standard_Real aFact=1.;
                       if(anUnit.IsNull()) continue;
                       if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
                       Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
-                      if(GetLengthConversionFactor(NU,afact)) dim2 = dim2*afact;
+                      if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
+                      aModifValue = aVal;
                     }
                   }
                 }
+                Interface_EntityIterator anIterDRE = aGraph.Shareds(aDRE);
+                for(anIterDRE.Start(); anIterDRE.More(); anIterDRE.Next()) {
+                  if(anIterDRE.Value()->IsKind(STANDARD_TYPE(StepDimTol_Datum)))
+                  {
+                    Handle(StepDimTol_Datum) aD = Handle(StepDimTol_Datum)::DownCast(anIterDRE.Value());
+                    setDatumToXCAF(aD, theGDTL, aPositionCounter, aXCAFModifiers, aXCAFModifWithVal, aModifValue,theDoc, theWS);
+                  }
+                }
               }
             }
           }
-          if(dim1<0) continue;
-          if(dim2<0) dim2=dim1;
-          //cout<<"DimensionalSize: dim1="<<dim1<<"  dim2="<<dim2<<endl;
-          // now we know edge_curve and value range therefore
-          // we can create corresponding D&GT labels
-          Standard_Integer index = TP->MapIndex(EC);
-          TopoDS_Shape aSh;
-          if(index >0) {
-            Handle(Transfer_Binder) binder = TP->MapItem(index);
-            aSh = TransferBRep::ShapeResult(binder);
+        }
+      }
+    }
+  }
+  return Standard_True;
+}
+
+//=======================================================================
+//function : craeteGeomTolObjectInXCAF
+//purpose  : 
+//=======================================================================
+static TDF_Label createGDTObjectInXCAF(const Handle(Standard_Transient)& theEnt,
+                                               const Handle(TDocStd_Document)& theDoc,
+                                               const Handle(XSControl_WorkSession)& theWS)
+{
+  TDF_Label aGDTL;
+  if(!theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)) &&
+     !theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)) && 
+     !theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance)))
+  {
+    return aGDTL;
+  }
+
+  Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
+  Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
+  Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
+  Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
+  const Interface_Graph& aGraph = aTP->Graph();
+  Standard_Boolean isAllAround = Standard_False;
+  Standard_Boolean isAllOver = Standard_False;
+  
+  // find RepresentationItem for current Ent
+  NCollection_Sequence<Handle(Standard_Transient)> aSeqRI1, aSeqRI2;
+
+  Interface_EntityIterator anIter = aGraph.Shareds(theEnt);
+  for(anIter.Start(); anIter.More(); anIter.Next()) {
+    Handle(Standard_Transient) anAtr = anIter.Value();
+    NCollection_Sequence<Handle(StepRepr_ShapeAspect)> aSAs;
+    if(anAtr->IsKind(STANDARD_TYPE(StepRepr_ProductDefinitionShape)))
+    {
+      //if associating tolerances with part (All-Over)
+      Interface_EntityIterator anIterSDR = aGraph.Sharings(anAtr);
+      for(anIterSDR.Start(); anIterSDR.More(); anIterSDR.Next()) 
+      {
+        Handle(Standard_Transient) anAtrSDR = anIterSDR.Value();
+        if(anAtrSDR->IsKind(STANDARD_TYPE(StepShape_ShapeDefinitionRepresentation)))
+        {
+          isAllOver = Standard_True;
+          Interface_EntityIterator anIterABSR = aGraph.Shareds(anAtrSDR);
+          for(anIterABSR.Start(); anIterABSR.More(); anIterABSR.Next()) 
+          {
+            Handle(Standard_Transient) anAtrABSR = anIterABSR.Value();
+            if(anAtrABSR->IsKind(STANDARD_TYPE(StepShape_AdvancedBrepShapeRepresentation)))
+            {
+              aSeqRI1.Append(anAtrABSR);
+            }
           }
-          if(aSh.IsNull()) continue; 
-          TDF_Label shL;
-          if( !STool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
-          Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(1,2);
-          arr->SetValue(1,dim1);
-          arr->SetValue(2,dim2);
-          DGTTool->SetDimTol(shL,1,arr,aName,DimSize->Name());
         }
-        // read tolerances and datums
-        else if(subs3.Value()->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
-          Handle(StepDimTol_GeometricTolerance) GT =
-            Handle(StepDimTol_GeometricTolerance)::DownCast(subs3.Value());
-          // read common data for tolerance
-          //Standard_Real dim = GT->Magnitude()->ValueComponent();
-          Handle (StepBasic_MeasureWithUnit) dim3 = GT->Magnitude();
-          if(dim3.IsNull()) continue;
-          Standard_Real dim = dim3->ValueComponent();
-          StepBasic_Unit anUnit = GT->Magnitude()->UnitComponent();
-          Standard_Real afact=1.;
-          if(anUnit.IsNull()) continue;
-          if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
-          Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
-          if(GetLengthConversionFactor(NU,afact)) dim = dim*afact;
-          //cout<<"GeometricTolerance: Magnitude = "<<dim<<endl;
-          Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(1,1);
-          arr->SetValue(1,dim);
-          Handle(TCollection_HAsciiString) aName = GT->Name();
-          Handle(TCollection_HAsciiString) aDescription = GT->Description();
-          Handle(StepShape_AdvancedFace) AF = Handle(StepShape_AdvancedFace)::DownCast(RI);
-          if(AF.IsNull()) continue;
-          Standard_Integer index = TP->MapIndex(AF);
-          TopoDS_Shape aSh;
-          if(index >0) {
-            Handle(Transfer_Binder) binder = TP->MapItem(index);
-            aSh = TransferBRep::ShapeResult(binder);
+      }
+    }
+    else if(anAtr->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)) || 
+      anAtr->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)))
+    {
+      //if tolerance attached to dimension
+      Interface_EntityIterator anIterDim = aGraph.Shareds(anAtr);
+      for(anIterDim.Start(); anIterDim.More(); anIterDim.Next()) 
+      {
+        Handle(Standard_Transient) anAtrDim = anIterDim.Value();
+        if(anAtrDim->IsKind(STANDARD_TYPE(StepRepr_CompositeShapeAspect)) || 
+          anAtrDim->IsKind(STANDARD_TYPE(StepRepr_CompShAspAndDatumFeatAndShAsp)))
+        {
+          Interface_EntityIterator anIterCSA = aGraph.Sharings(anAtrDim);
+          for(anIterCSA.Start(); anIterCSA.More(); anIterCSA.Next()) {
+            if (anIterCSA.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))){
+              Interface_EntityIterator anIterSAR = aGraph.Shareds(anIterCSA.Value());
+              for(anIterSAR.Start(); anIterSAR.More(); anIterSAR.Next()) {
+                if (anIterSAR.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))){
+                  aSAs.Append(Handle(StepRepr_ShapeAspect)::DownCast(anIterSAR.Value()));
+                }
+              }
+            }
           }
-          if(aSh.IsNull()) continue; 
-          TDF_Label shL;
-          if( !STool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
-          // read specific data for tolerance
-          if(GT->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol))) {
-            Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol) GTComplex =
-              Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)::DownCast(subs3.Value());
-            Standard_Integer kind=20;
-            Handle(StepDimTol_ModifiedGeometricTolerance) MGT = 
-              GTComplex->GetModifiedGeometricTolerance();
-            if(!MGT.IsNull()) {
-              kind = kind + MGT->Modifier()+1;
+        }
+        else if(anAtrDim->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect)))
+        {
+          aSAs.Append( Handle(StepRepr_ShapeAspect)::DownCast(anAtrDim));
+        }
+      }
+    }
+    else if(anAtr->IsKind(STANDARD_TYPE(StepRepr_CompositeShapeAspect)) || 
+      anAtr->IsKind(STANDARD_TYPE(StepRepr_CompShAspAndDatumFeatAndShAsp)))
+    {
+      //processing for composite entity
+      Handle(Standard_Transient) anAtrTmp = anAtr;
+      if(anAtr->IsKind(STANDARD_TYPE(StepRepr_AllAroundShapeAspect)))
+      {
+        // if applyed AllAround Modifier
+        isAllAround = Standard_True;
+        Interface_EntityIterator anIterAASA = aGraph.Sharings(anAtrTmp);
+        for(anIterAASA.Start(); anIterAASA.More(); anIterAASA.Next()) {
+          if (anIterAASA.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))){
+            Interface_EntityIterator anIterSAR = aGraph.Shareds(anIterAASA.Value());
+            for(anIterSAR.Start(); anIterSAR.More(); anIterSAR.Next()) {
+              if ((anIterSAR.Value()->IsKind(STANDARD_TYPE(StepRepr_CompositeShapeAspect)) || 
+                anIterSAR.Value()->IsKind(STANDARD_TYPE(StepRepr_CompShAspAndDatumFeatAndShAsp))) &&
+                anAtrTmp != anIterSAR.Value()){
+                  anAtrTmp = anIterSAR.Value();
+                  break;
+              }
             }
-            TDF_Label TolerL = DGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
-            // translate datums connected with this tolerance
-            Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
-              GTComplex->GetGeometricToleranceWithDatumReference();
-            if(!GTWDR.IsNull()) {
-              ReadDatums(STool,DGTTool,graph,TP,TolerL,GTWDR);
+          }
+        }
+      }
+      Interface_EntityIterator anIterCSA = aGraph.Sharings(anAtrTmp);
+      for(anIterCSA.Start(); anIterCSA.More(); anIterCSA.Next()) {
+        if (anIterCSA.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspectRelationship))){
+          Interface_EntityIterator anIterSAR = aGraph.Shareds(anIterCSA.Value());
+          for(anIterSAR.Start(); anIterSAR.More(); anIterSAR.Next()) {
+            if (anIterSAR.Value()->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect))){
+              aSAs.Append(Handle(StepRepr_ShapeAspect)::DownCast(anIterSAR.Value()));
             }
           }
-          else if(GT->IsKind(STANDARD_TYPE(StepDimTol_GeometricToleranceWithDatumReference))) {
-            Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
-              Handle(StepDimTol_GeometricToleranceWithDatumReference)::DownCast(subs3.Value());
-            if(GTWDR.IsNull()) continue;
-            Standard_Integer kind = 0;
-            if     (GTWDR->IsKind(STANDARD_TYPE(StepDimTol_AngularityTolerance)))       kind = 24;
-            else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_CircularRunoutTolerance)))   kind = 25;
-            else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_CoaxialityTolerance)))       kind = 26;
-            else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_ConcentricityTolerance)))    kind = 27;
-            else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_ParallelismTolerance)))      kind = 28;
-            else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_PerpendicularityTolerance))) kind = 29;
-            else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_SymmetryTolerance)))         kind = 30;
-            else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_TotalRunoutTolerance)))      kind = 31;
-            //cout<<"GTWDR: kind="<<kind<<endl;
-            TDF_Label TolerL = DGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
-            ReadDatums(STool,DGTTool,graph,TP,TolerL,GTWDR);
+        }
+      }
+    }
+    else if(anAtr->IsKind(STANDARD_TYPE(StepRepr_ShapeAspect)))
+    {
+      //default
+      aSAs.Append( Handle(StepRepr_ShapeAspect)::DownCast(anAtr));
+    }
+    if(!aSAs.IsEmpty())
+    {
+      //get representation items
+      NCollection_Sequence<Handle(Standard_Transient)> aSeqRI;
+      for(Standard_Integer i = aSAs.Lower(); i <= aSAs.Upper(); i++)
+      {
+        Interface_EntityIterator anIterSA = aGraph.Sharings(aSAs.Value(i));
+        Handle(StepAP242_GeometricItemSpecificUsage) aGISU;
+        Handle(StepRepr_PropertyDefinition) PropD;
+        for(anIterSA.Start(); anIterSA.More() && aGISU.IsNull() && PropD.IsNull(); anIterSA.Next()) {
+          aGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterSA.Value());
+          PropD = Handle(StepRepr_PropertyDefinition)::DownCast(anIterSA.Value());
+        }
+        if(!PropD.IsNull())//for old version
+        {
+          Handle(StepRepr_RepresentationItem) RI;
+          Interface_EntityIterator subs4 = aGraph.Sharings(PropD);
+          for(subs4.Start(); subs4.More(); subs4.Next()) {
+            Handle(StepShape_ShapeDefinitionRepresentation) SDR = 
+              Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs4.Value());
+            if(!SDR.IsNull()) {
+              Handle(StepRepr_Representation) Repr = SDR->UsedRepresentation();
+              if( !Repr.IsNull() && Repr->NbItems()>0 ) {
+                RI = Repr->ItemsValue(1);
+              }
+            }
           }
-          else if(GT->IsKind(STANDARD_TYPE(StepDimTol_ModifiedGeometricTolerance))) {
-            Handle(StepDimTol_ModifiedGeometricTolerance) MGT =
-              Handle(StepDimTol_ModifiedGeometricTolerance)::DownCast(subs3.Value());
-            Standard_Integer kind = 35 + MGT->Modifier();
-            DGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
+          if(RI.IsNull()) continue;
+
+          if(theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize))) {
+            // read dimensions
+            Handle(StepShape_EdgeCurve) EC = Handle(StepShape_EdgeCurve)::DownCast(RI);
+            if(EC.IsNull()) continue;
+            Handle(TCollection_HAsciiString) aName;
+            Handle(StepShape_DimensionalSize) DimSize = 
+              Handle(StepShape_DimensionalSize)::DownCast(theEnt);
+            Standard_Real dim1=-1.,dim2=-1.;
+            subs4 = aGraph.Sharings(DimSize);
+            for(subs4.Start(); subs4.More(); subs4.Next()) {
+              Handle(StepShape_DimensionalCharacteristicRepresentation) DimCharR = 
+                Handle(StepShape_DimensionalCharacteristicRepresentation)::DownCast(subs4.Value());
+              if(!DimCharR.IsNull()) {
+                Handle(StepShape_ShapeDimensionRepresentation) SDimR = DimCharR->Representation();
+                if(!SDimR.IsNull() && SDimR->NbItems()>0) {
+                  Handle(StepRepr_RepresentationItem) aRI = SDimR->ItemsValue(1);
+                  Handle(StepRepr_ValueRange) VR = Handle(StepRepr_ValueRange)::DownCast(aRI);
+                  if(!VR.IsNull()) {
+                    aName = VR->Name();
+                    //StepRepr_CompoundItemDefinition CID = VR->ItemElement();
+                    //if(CID.IsNull()) continue;
+                    //Handle(StepRepr_CompoundItemDefinitionMember) CIDM = 
+                    //  Handle(StepRepr_CompoundItemDefinitionMember)::DownCast(CID.Value());
+                    //if(CIDM.IsNull()) continue;
+                    //if(CIDM->ArrTransient().IsNull()) continue;
+                    //Handle(StepRepr_HArray1OfRepresentationItem) HARI;
+                    //if(CID.CaseMem(CIDM)==1)
+                    //  HARI = CID.ListRepresentationItem();
+                    //if(CID.CaseMem(CIDM)==2)
+                    //  HARI = CID.SetRepresentationItem();
+                    Handle(StepRepr_HArray1OfRepresentationItem) HARI = VR->ItemElement();
+                    if(HARI.IsNull()) continue;
+                    if(HARI->Length()>0) {
+                      Handle(StepRepr_RepresentationItem) RI1 =
+                        Handle(StepRepr_RepresentationItem)::DownCast(HARI->Value(1));
+                      if(RI1.IsNull()) continue;
+                      if(RI1->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
+                        Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMWU =
+                          Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(RI1);
+                        dim1 = RILMWU->GetMeasureWithUnit()->ValueComponent();
+                        StepBasic_Unit anUnit = RILMWU->GetMeasureWithUnit()->UnitComponent();
+                        Standard_Real afact=1.;
+                        if(anUnit.IsNull()) continue;
+                        if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
+                        Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
+                        if(GetLengthConversionFactor(NU,afact)) dim1=dim1*afact;
+                      }
+                    }
+                    if(HARI->Length()>1) {
+                      Handle(StepRepr_RepresentationItem) RI2 =
+                        Handle(StepRepr_RepresentationItem)::DownCast(HARI->Value(2));
+                      if(RI2.IsNull()) continue;
+                      if(RI2->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
+                        Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMWU =
+                          Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(RI2);
+                        dim2 = RILMWU->GetMeasureWithUnit()->ValueComponent();
+                        StepBasic_Unit anUnit = RILMWU->GetMeasureWithUnit()->UnitComponent();
+                        Standard_Real afact=1.;
+                        if(anUnit.IsNull()) continue;
+                        if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
+                        Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
+                        if(GetLengthConversionFactor(NU,afact)) dim2 = dim2*afact;
+                      }
+                    }
+                  }
+                }
+              }
+            }
+            if(dim1<0) continue;
+            if(dim2<0) dim2=dim1;
+            //cout<<"DimensionalSize: dim1="<<dim1<<"  dim2="<<dim2<<endl;
+            // now we know edge_curve and value range therefore
+            // we can create corresponding D&GT labels
+            Standard_Integer index = aTP->MapIndex(EC);
+            TopoDS_Shape aSh;
+            if(index >0) {
+              Handle(Transfer_Binder) binder = aTP->MapItem(index);
+              aSh = TransferBRep::ShapeResult(binder);
+            }
+            if(aSh.IsNull()) continue; 
+            TDF_Label shL;
+            if( !aSTool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
+            Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(1,2);
+            arr->SetValue(1,dim1);
+            arr->SetValue(2,dim2);
+            aDGTTool->SetDimTol(shL,1,arr,aName,DimSize->Name());
           }
-          else if(GT->IsKind(STANDARD_TYPE(StepDimTol_CylindricityTolerance))) {
-            DGTTool->SetDimTol(shL,38,arr,aName,aDescription);
+          // read tolerances and datums
+          else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
+            Handle(StepDimTol_GeometricTolerance) GT =
+              Handle(StepDimTol_GeometricTolerance)::DownCast(theEnt);
+            // read common data for tolerance
+            //Standard_Real dim = GT->Magnitude()->ValueComponent();
+            Handle (StepBasic_MeasureWithUnit) dim3 = GT->Magnitude();
+            if(dim3.IsNull()) continue;
+            Standard_Real dim = dim3->ValueComponent();
+            StepBasic_Unit anUnit = GT->Magnitude()->UnitComponent();
+            Standard_Real afact=1.;
+            if(anUnit.IsNull()) continue;
+            if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
+            Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
+            if(GetLengthConversionFactor(NU,afact)) dim = dim*afact;
+            //cout<<"GeometricTolerance: Magnitude = "<<dim<<endl;
+            Handle(TColStd_HArray1OfReal) arr = new TColStd_HArray1OfReal(1,1);
+            arr->SetValue(1,dim);
+            Handle(TCollection_HAsciiString) aName = GT->Name();
+            Handle(TCollection_HAsciiString) aDescription = GT->Description();
+            Handle(StepShape_AdvancedFace) AF = Handle(StepShape_AdvancedFace)::DownCast(RI);
+            if(AF.IsNull()) continue;
+            Standard_Integer index = aTP->MapIndex(AF);
+            TopoDS_Shape aSh;
+            if(index >0) {
+              Handle(Transfer_Binder) binder = aTP->MapItem(index);
+              aSh = TransferBRep::ShapeResult(binder);
+            }
+            if(aSh.IsNull()) continue; 
+            TDF_Label shL;
+            if( !aSTool->Search(aSh, shL, Standard_True, Standard_True, Standard_True) ) continue;
+            // read specific data for tolerance
+            if(GT->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol))) {
+              Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol) GTComplex =
+                Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)::DownCast(theEnt);
+              Standard_Integer kind=20;
+              Handle(StepDimTol_ModifiedGeometricTolerance) MGT = 
+                GTComplex->GetModifiedGeometricTolerance();
+              if(!MGT.IsNull()) {
+                kind = kind + MGT->Modifier()+1;
+              }
+              TDF_Label TolerL = aDGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
+              // translate datums connected with this tolerance
+              Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
+                GTComplex->GetGeometricToleranceWithDatumReference();
+              if(!GTWDR.IsNull()) {
+                ReadDatums(aSTool,aDGTTool,aGraph,aTP,TolerL,GTWDR);
+              }
+            }
+            else if(GT->IsKind(STANDARD_TYPE(StepDimTol_GeometricToleranceWithDatumReference))) {
+              Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
+                Handle(StepDimTol_GeometricToleranceWithDatumReference)::DownCast(theEnt);
+              if(GTWDR.IsNull()) continue;
+              Standard_Integer kind = 0;
+              if     (GTWDR->IsKind(STANDARD_TYPE(StepDimTol_AngularityTolerance)))       kind = 24;
+              else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_CircularRunoutTolerance)))   kind = 25;
+              else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_CoaxialityTolerance)))       kind = 26;
+              else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_ConcentricityTolerance)))    kind = 27;
+              else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_ParallelismTolerance)))      kind = 28;
+              else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_PerpendicularityTolerance))) kind = 29;
+              else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_SymmetryTolerance)))         kind = 30;
+              else if(GTWDR->IsKind(STANDARD_TYPE(StepDimTol_TotalRunoutTolerance)))      kind = 31;
+              //cout<<"GTWDR: kind="<<kind<<endl;
+              TDF_Label TolerL = aDGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
+              ReadDatums(aSTool,aDGTTool,aGraph,aTP,TolerL,GTWDR);
+            }
+            else if(GT->IsKind(STANDARD_TYPE(StepDimTol_ModifiedGeometricTolerance))) {
+              Handle(StepDimTol_ModifiedGeometricTolerance) MGT =
+                Handle(StepDimTol_ModifiedGeometricTolerance)::DownCast(theEnt);
+              Standard_Integer kind = 35 + MGT->Modifier();
+              aDGTTool->SetDimTol(shL,kind,arr,aName,aDescription);
+            }
+            else if(GT->IsKind(STANDARD_TYPE(StepDimTol_CylindricityTolerance))) {
+              aDGTTool->SetDimTol(shL,38,arr,aName,aDescription);
+            }
+            else if(GT->IsKind(STANDARD_TYPE(StepDimTol_FlatnessTolerance))) {
+              aDGTTool->SetDimTol(shL,39,arr,aName,aDescription);
+            }
+            else if(GT->IsKind(STANDARD_TYPE(StepDimTol_LineProfileTolerance))) {
+              aDGTTool->SetDimTol(shL,40,arr,aName,aDescription);
+            }
+            else if(GT->IsKind(STANDARD_TYPE(StepDimTol_PositionTolerance))) {
+              aDGTTool->SetDimTol(shL,41,arr,aName,aDescription);
+            }
+            else if(GT->IsKind(STANDARD_TYPE(StepDimTol_RoundnessTolerance))) {
+              aDGTTool->SetDimTol(shL,42,arr,aName,aDescription);
+            }
+            else if(GT->IsKind(STANDARD_TYPE(StepDimTol_StraightnessTolerance))) {
+              aDGTTool->SetDimTol(shL,43,arr,aName,aDescription);
+            }
+            else if(GT->IsKind(STANDARD_TYPE(StepDimTol_SurfaceProfileTolerance))) {
+              aDGTTool->SetDimTol(shL,44,arr,aName,aDescription);
+            }
           }
-          else if(GT->IsKind(STANDARD_TYPE(StepDimTol_FlatnessTolerance))) {
-            DGTTool->SetDimTol(shL,39,arr,aName,aDescription);
+        }
+        else
+        {
+          if(aGISU.IsNull()) continue;
+          if(aGISU->NbIdentifiedItem() > 0) {
+            aSeqRI.Append(aGISU->IdentifiedItemValue(1));
           }
-          else if(GT->IsKind(STANDARD_TYPE(StepDimTol_LineProfileTolerance))) {
-            DGTTool->SetDimTol(shL,40,arr,aName,aDescription);
+        }
+      }
+      if(!aSeqRI.IsEmpty())
+      {
+        if(aSeqRI1.IsEmpty())
+          aSeqRI1 = aSeqRI;
+        else 
+          aSeqRI2 = aSeqRI;
+      }
+    }
+  }
+  if(aSeqRI1.IsEmpty()) return aGDTL;
+
+  TDF_LabelSequence aShLS1, aShLS2;
+
+  for(Standard_Integer i = aSeqRI1.Lower(); i <= aSeqRI1.Upper() ;i++)
+  {
+    Standard_Integer anIndex = aTP->MapIndex(aSeqRI1.Value(i));
+    TopoDS_Shape aSh;
+    if(anIndex >0) {
+      Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
+      aSh = TransferBRep::ShapeResult(aBinder);
+    }
+    if(!aSh.IsNull())
+    {
+      TDF_Label aShL;
+      aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
+      aShLS1.Append(aShL);
+    }
+  }
+  if (!aSeqRI2.IsEmpty())
+  {
+    //for dimensional location
+    for(Standard_Integer i = aSeqRI2.Lower(); i <= aSeqRI2.Upper() ;i++)
+    {
+      Standard_Integer anIndex = aTP->MapIndex(aSeqRI2.Value(i));
+      TopoDS_Shape aSh;
+      if(anIndex >0) {
+        Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
+        aSh = TransferBRep::ShapeResult(aBinder);
+      }
+      if(!aSh.IsNull())
+      {
+        TDF_Label aShL;
+        aSTool->Search(aSh, aShL, Standard_True, Standard_True, Standard_True);
+        aShLS2.Append(aShL);
+      }
+    }
+  }
+
+  if(!aShLS1.IsEmpty())
+  {
+    // add to XCAF
+    if(!theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance)))
+    {
+      aGDTL = aDGTTool->AddDimension();
+      Handle(XCAFDoc_Dimension) aDim = XCAFDoc_Dimension::Set(aGDTL);
+      TCollection_AsciiString aStr("DGT:Dimensional_");
+      if(theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)))
+      {
+        aStr.AssignCat("Size");
+      }
+      else if(theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)))
+      {
+        aStr.AssignCat("Location");
+      }
+      TDataStd_Name::Set(aGDTL, aStr);
+
+      if(!aShLS2.IsEmpty())
+      {
+        aDGTTool->SetDimension(aShLS1, aShLS2, aGDTL);
+      }
+      else
+      {
+        TDF_LabelSequence aEmptySeq;
+        aDGTTool->SetDimension(aShLS1, aEmptySeq, aGDTL);
+      }
+    }
+    else
+    {
+      aGDTL = aDGTTool->AddGeomTolerance();
+      Handle(XCAFDoc_GeomTolerance) aGTol = XCAFDoc_GeomTolerance::Set(aGDTL);
+      TCollection_AsciiString aStr("DGT:GeomTolerance");
+      TDataStd_Name::Set(aGDTL, aStr);
+      aDGTTool->SetGeomTolerance(aShLS1, aGDTL);
+      Handle(XCAFDimTolObjects_GeomToleranceObject) anObj = aGTol->GetObject();
+      if(isAllAround)
+        anObj->AddModifier(XCAFDimTolObjects_GeomToleranceModif_All_Around);
+      else if(isAllOver)
+        anObj->AddModifier(XCAFDimTolObjects_GeomToleranceModif_All_Over);
+      aGTol->SetObject(anObj);
+    }
+    readDatumsAP242(theEnt, aGDTL, theDoc, theWS);
+  }
+  return aGDTL;
+}
+
+//=======================================================================
+//function : setDimObjectToXCAF
+//purpose  : 
+//=======================================================================
+static void setDimObjectToXCAF(const Handle(Standard_Transient)& theEnt,
+                                           const TDF_Label& aDimL,
+                                           const Handle(TDocStd_Document)& theDoc,
+                                           const Handle(XSControl_WorkSession)& theWS)
+{
+  Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
+  Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
+  Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
+  Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
+  const Interface_Graph& aGraph = aTP->Graph();
+  Handle(XCAFDimTolObjects_DimensionObject) aDimObj;
+  if(!theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)) &&
+    !theEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation))) 
+    return;
+
+  Handle(StepShape_DimensionalSize) aDimSize = 
+    Handle(StepShape_DimensionalSize)::DownCast(theEnt);
+  Handle(StepShape_DimensionalLocation) aDimLocation = 
+    Handle(StepShape_DimensionalLocation)::DownCast(theEnt);
+
+  Standard_Real aDim1=-1.,aDim2=-1.,aDim3=-1.;
+  Handle(StepShape_TypeQualifier) aTQ;
+  Handle(StepShape_ValueFormatTypeQualifier) aVFTQ;
+  Handle(StepShape_ToleranceValue) aTV;
+  Handle(StepShape_LimitsAndFits) aLAF;
+  Handle(StepRepr_CompoundRepresentationItem) aCRI;
+  Handle(StepGeom_Axis2Placement3d) anAP;
+
+  Interface_EntityIterator anIterDim;
+  if(!aDimSize.IsNull())
+  {
+    anIterDim = aGraph.Sharings(aDimSize);
+  }
+  else
+  {
+    anIterDim = aGraph.Sharings(aDimLocation);
+  }
+  for(anIterDim.Start(); anIterDim.More(); anIterDim.Next()) {
+    Handle(StepShape_DimensionalCharacteristicRepresentation) aDCR = 
+      Handle(StepShape_DimensionalCharacteristicRepresentation)::DownCast(anIterDim.Value());
+    Handle(StepShape_PlusMinusTolerance) aPMT = 
+      Handle(StepShape_PlusMinusTolerance)::DownCast(anIterDim.Value());
+    if(!aDCR.IsNull()) {
+      Handle(StepShape_ShapeDimensionRepresentation) aSDR = aDCR->Representation();
+      if(!aSDR.IsNull()) {
+        Handle(StepRepr_HArray1OfRepresentationItem) aHARI = aSDR->Items();
+
+        if(!aHARI.IsNull())
+        {
+          for(Standard_Integer nr = aHARI->Lower(); nr <= aHARI->Upper(); nr++)
+          {
+            Handle(StepRepr_RepresentationItem) aDRI =
+              Handle(StepRepr_RepresentationItem)::DownCast(aHARI->Value(nr));
+            if(aDRI.IsNull()) continue;
+
+            if(aDRI->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndLengthMeasureWithUnit))) {
+              //get values
+              Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) aRILMWU =
+                Handle(StepRepr_ReprItemAndLengthMeasureWithUnit)::DownCast(aDRI);
+              Standard_Real aVal = aRILMWU->GetMeasureWithUnit()->ValueComponent();
+              StepBasic_Unit anUnit = aRILMWU->GetMeasureWithUnit()->UnitComponent();
+              Standard_Real aFact=1.;
+              if(anUnit.IsNull()) continue;
+              if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
+              Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
+              if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
+              if(aDim2 > 0)
+              {
+                if(aDim1 > aDim2)
+                {
+                  Standard_Real aTmp = aDim1;
+                  aDim1 = aDim2;
+                  aDim2 = aTmp;
+                }
+                if(aVal < aDim1)
+                  aDim1 = aVal;
+                else if(aVal > aDim2)
+                  aDim2 = aVal;
+              }
+              else if(aDim1 > 0)
+              {
+                if (aVal > aDim1)
+                  aDim2 = aVal;
+                else
+                {
+                  aDim2 = aDim1;
+                  aDim1 = aVal;
+                }
+              }
+              else
+                aDim1 = aVal;
+            }
+            else if(aDRI->IsKind(STANDARD_TYPE(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit))) {
+              //get values
+              Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit) aRIPAMWU =
+                Handle(StepRepr_ReprItemAndPlaneAngleMeasureWithUnit)::DownCast(aDRI);
+              Standard_Real aVal = aRIPAMWU->GetMeasureWithUnit()->ValueComponent();
+              StepBasic_Unit anUnit = aRIPAMWU->GetMeasureWithUnit()->UnitComponent();
+              Standard_Real aFact=1.;
+              if(anUnit.IsNull()) continue;
+              if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
+              Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
+              if(GetAngleConversionFactor(NU,aFact)) aVal=aVal*aFact;
+              if(aDim2 > 0)
+              {
+                if(aDim1 > aDim2)
+                {
+                  Standard_Real aTmp = aDim1;
+                  aDim1 = aDim2;
+                  aDim2 = aTmp;
+                }
+                if(aVal < aDim1)
+                  aDim1 = aVal;
+                else if(aVal > aDim2)
+                  aDim2 = aVal;
+              }
+              else if(aDim1 > 0)
+              {
+                if (aVal > aDim1)
+                  aDim2 = aVal;
+                else
+                {
+                  aDim2 = aDim1;
+                  aDim1 = aVal;
+                }
+              }
+              else
+                aDim1 = aVal;
+            }
+            else if(aDRI->IsKind(STANDARD_TYPE(StepShape_QualifiedRepresentationItem))) {
+              //get qualifier
+              Handle(StepShape_QualifiedRepresentationItem) aQRI =
+                Handle(StepShape_QualifiedRepresentationItem)::DownCast(aDRI);
+              for(Standard_Integer l = 1; l <= aQRI->NbQualifiers(); l++)
+              {
+                aTQ = aQRI->Qualifiers()->Value(l).TypeQualifier();
+                aVFTQ = aQRI->Qualifiers()->Value(l).ValueFormatTypeQualifier();
+              }
+            }
+            else if(aDRI->IsKind(STANDARD_TYPE(StepRepr_CompoundRepresentationItem))) {
+              aCRI = Handle(StepRepr_CompoundRepresentationItem)::DownCast(aDRI);
+            }
+            else if(aDRI->IsKind(STANDARD_TYPE(StepGeom_Axis2Placement3d)))
+            {
+              anAP = Handle(StepGeom_Axis2Placement3d)::DownCast(aDRI);
+            }
           }
-          else if(GT->IsKind(STANDARD_TYPE(StepDimTol_PositionTolerance))) {
-            DGTTool->SetDimTol(shL,41,arr,aName,aDescription);
+        }
+      }
+    }
+    else if (!aPMT.IsNull())
+    {
+      StepShape_ToleranceMethodDefinition aTMD = aPMT->Range();
+      if(aPMT.IsNull()) continue;
+      if(aTMD.CaseNumber() == 1)
+        //! 1 -> ToleranceValue from StepShape
+        //! 2 -> LimitsAndFits from StepShape
+      {
+        //plus minus tolerance 
+        aTV = aTMD.ToleranceValue();
+        if (aTV.IsNull()) continue;
+
+        Standard_Real aVal = aTV->UpperBound()->ValueComponent();
+        StepBasic_Unit anUnit = aTV->UpperBound()->UnitComponent();
+        Standard_Real aFact=1.;
+        if(anUnit.IsNull()) continue;
+        if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
+        Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
+        if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
+        aDim3 = aVal;
+
+        aVal = aTV->LowerBound()->ValueComponent();
+        anUnit = aTV->LowerBound()->UnitComponent();
+        aFact=1.;
+        if(anUnit.IsNull()) continue;
+        if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
+        NU = anUnit.NamedUnit();
+        if(GetLengthConversionFactor(NU,aFact)) aVal=aVal*aFact;
+        aDim2 = Abs(aVal);
+      }
+      else
+      {
+        // calss of tolerance
+        aLAF = aTMD.LimitsAndFits();
+      }
+    }
+  }
+
+  if(aDim1<0) return;
+
+  aDimObj = new XCAFDimTolObjects_DimensionObject();
+  if(aDim2 < 0)
+    aDimObj->SetValue(aDim1);
+  else if (aDim3 < 0)
+  {
+    Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1,2);
+    anArr->SetValue(1,aDim1);
+    anArr->SetValue(2,aDim2);
+    aDimObj->SetValues(anArr);
+  }
+  else
+  {
+    Handle(TColStd_HArray1OfReal) anArr = new TColStd_HArray1OfReal(1,3);
+    anArr->SetValue(1,aDim1);
+    anArr->SetValue(2,aDim2);
+    anArr->SetValue(3,aDim3);
+    aDimObj->SetValues(anArr);
+  }
+  if(!aTQ.IsNull()) 
+  {
+    XCAFDimTolObjects_DimensionQualifier aQ;
+    if (STEPConstruct_GDTProperty::GetDimQualifierType(aTQ->Name(), aQ))
+    {
+        aDimObj->SetQualifier(aQ);
+    }
+  }
+
+  if (!aVFTQ.IsNull())
+  {
+    //A typical value would be ‘NR2 2.2’
+    TCollection_HAsciiString aFormat = aVFTQ->FormatType();
+    Standard_Integer i = aFormat.Location(1,' ',1,aFormat.Length());
+    aFormat.SubString(i+1,i+1)->IntegerValue();
+    aDimObj->SetNbOfDecimalPlaces(aFormat.SubString(i+1,i+1)->IntegerValue(),
+      aFormat.SubString(i+3,i+3)->IntegerValue());
+  }
+
+  if (!aLAF.IsNull())
+  { 
+    //get class of tolerance
+    Standard_Boolean aHolle = Standard_False;
+    XCAFDimTolObjects_DimensionFormVariance aFV = XCAFDimTolObjects_DimensionFormVariance_None;
+    XCAFDimTolObjects_DimensionGrade aG = XCAFDimTolObjects_DimensionGrade_IT01;
+    STEPConstruct_GDTProperty::GetDimClassOfTolerance(aLAF, aHolle, aFV, aG);
+    aDimObj->SetClassOfTolerance(aHolle, aFV, aG);
+  }
+
+  if (!aCRI.IsNull() && aCRI->ItemElement()->Length() > 0)
+  {
+    //get modifiers
+    XCAFDimTolObjects_DimensionModifiersSequence aModifiers;
+    STEPConstruct_GDTProperty::GetDimModifiers(aCRI, aModifiers);
+    if(aModifiers.Length() > 0)
+      aDimObj->SetModifiers(aModifiers);
+  }
+
+  Handle(TCollection_HAsciiString) aName;
+  if(!aDimSize.IsNull())
+  {
+    aName = aDimSize->Name();
+  }
+  else
+  {
+    aName = aDimLocation->Name();
+  }
+  XCAFDimTolObjects_DimensionType aType = XCAFDimTolObjects_DimensionType_Location_None;
+  if (!STEPConstruct_GDTProperty::GetDimType(aName, aType))
+  {
+    if(!aDimSize.IsNull())
+    {
+      Handle(StepShape_AngularSize) anAngSize= 
+        Handle(StepShape_AngularSize)::DownCast(aDimSize);
+      if(!anAngSize.IsNull())
+      {
+        //get qualifier for angular value
+        aType = XCAFDimTolObjects_DimensionType_Size_Angular;
+        if(anAngSize->AngleSelection() == StepShape_Equal)
+          aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Avg);
+        else if (anAngSize->AngleSelection() == StepShape_Large)
+          aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Max);
+        else if (anAngSize->AngleSelection() == StepShape_Small)
+          aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Min);
+      }
+    }
+    else
+    {
+      Handle(StepShape_AngularLocation) anAngLoc= 
+        Handle(StepShape_AngularLocation)::DownCast(aDimLocation);
+      if(!anAngLoc.IsNull())
+      {
+        //get qualifier for angular value
+        aType = XCAFDimTolObjects_DimensionType_Location_Angular;
+        if(anAngLoc->AngleSelection() == StepShape_Equal)
+          aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Avg);
+        else if (anAngLoc->AngleSelection() == StepShape_Large)
+          aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Max);
+        else if (anAngLoc->AngleSelection() == StepShape_Small)
+          aDimObj->SetQualifier(XCAFDimTolObjects_DimensionQualifier_Min);
+      }
+    }
+    if(aType == XCAFDimTolObjects_DimensionType_Location_None)
+    {
+      Handle(StepRepr_ShapeAspect) aPSA;
+      if(!aDimSize.IsNull())
+      {
+        Handle(StepShape_DimensionalSizeWithPath) aDimSizeWithPath= 
+          Handle(StepShape_DimensionalSizeWithPath)::DownCast(aDimSize);
+        if (!aDimSizeWithPath.IsNull())
+        {
+          aType = XCAFDimTolObjects_DimensionType_Size_WithPath;
+          aPSA = aDimSizeWithPath->Path();
+        }
+      }
+      else
+      {
+        Handle(StepShape_DimensionalLocationWithPath) aDimLocWithPath= 
+          Handle(StepShape_DimensionalLocationWithPath)::DownCast(aDimLocation);
+        if (!aDimLocWithPath.IsNull())
+        {
+          aType = XCAFDimTolObjects_DimensionType_Location_WithPath;
+          aPSA = aDimLocWithPath->Path();
+        }
+      }
+
+      if(!aPSA.IsNull())
+      {
+        //for DimensionalLocationWithPath
+        Handle(StepGeom_GeometricRepresentationItem) aGRI;
+        Handle(StepAP242_GeometricItemSpecificUsage) aPGISU;
+        Interface_EntityIterator anIterDSWP = aGraph.Sharings(aPSA);
+        for(anIterDSWP.Start(); anIterDSWP.More() && aPGISU.IsNull(); anIterDSWP.Next()) {
+          aPGISU = Handle(StepAP242_GeometricItemSpecificUsage)::DownCast(anIterDSWP.Value());
+        }
+        if(aPGISU.IsNull()) return;
+        if(aPGISU->NbIdentifiedItem() > 0) {
+          aGRI = Handle(StepGeom_GeometricRepresentationItem)::DownCast(aPGISU->IdentifiedItemValue(1));
+        }
+        if(aGRI.IsNull()) return;
+        Handle(StepRepr_RepresentationItem) aPRI;
+        Interface_EntityIterator anIterGRI = aGraph.Sharings(aGRI);
+        for(anIterGRI.Start(); anIterGRI.More() && aPGISU.IsNull(); anIterGRI.Next()) {
+          aPRI = Handle(StepRepr_RepresentationItem)::DownCast(anIterGRI.Value());
+        }
+        Standard_Integer anIndex = aTP->MapIndex(aPRI);
+        TopoDS_Edge aSh;
+        if(anIndex >0) {
+          Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex);
+          aSh = TopoDS::Edge(TransferBRep::ShapeResult(aBinder));
+        }
+        if(aSh.IsNull()) return; 
+        aDimObj->SetPath(aSh);
+      }
+      else if(!anAP.IsNull())
+      {
+        if(anAP->Name()->String().IsEqual("orientation") && !anAP->Axis().IsNull())
+        {
+          //for Oriented Dimensional Location
+          Handle(TColStd_HArray1OfReal) aDirArr = anAP->RefDirection()->DirectionRatios();
+          gp_Dir aDir;
+          if(!aDirArr.IsNull() && aDirArr->Length() > 2)
+          {
+            aDir.SetCoord(aDirArr->Lower(), aDirArr->Lower()+1, aDirArr->Lower()+2);
+            aDimObj->SetDirection(aDir);
           }
-          else if(GT->IsKind(STANDARD_TYPE(StepDimTol_RoundnessTolerance))) {
-            DGTTool->SetDimTol(shL,42,arr,aName,aDescription);
+          else if(aDirArr->Length() > 1)
+          {
+            aDir.SetCoord(aDirArr->Lower(), aDirArr->Lower()+1, 0);
+            aDimObj->SetDirection(aDir);
           }
-          else if(GT->IsKind(STANDARD_TYPE(StepDimTol_StraightnessTolerance))) {
-            DGTTool->SetDimTol(shL,43,arr,aName,aDescription);
+        }
+      }
+    }
+  }
+  aDimObj->SetType(aType);
+
+  if(!aDimObj.IsNull())
+  {
+    Handle(XCAFDoc_Dimension) aDim;
+    if(aDimL.FindAttribute(XCAFDoc_Dimension::GetID(),aDim))
+    {
+      aDim->SetObject(aDimObj);
+    }
+  }
+}
+
+//=======================================================================
+//function : getTolType
+//purpose  : 
+//=======================================================================
+static Standard_Boolean getTolType(const Handle(Standard_Transient)& theEnt,
+                       XCAFDimTolObjects_GeomToleranceType& theType)
+{
+  if(!theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) 
+    return Standard_False;
+  theType = XCAFDimTolObjects_GeomToleranceType_None;
+  if (theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRef)))
+  {
+    Handle(StepDimTol_GeoTolAndGeoTolWthDatRef) anE = Handle(StepDimTol_GeoTolAndGeoTolWthDatRef)::DownCast(theEnt);
+    theType = (XCAFDimTolObjects_GeomToleranceType)anE->GetToleranceType();
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_AngularityTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_Angularity;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_CircularRunoutTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_CircularRunout;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_RoundnessTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_CircularityOrRoundness;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_CoaxialityTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_Coaxiality;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_ConcentricityTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_Concentricity;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_CylindricityTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_Cylindricity;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_FlatnessTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_Flatness;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_ParallelismTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_Parallelism;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_PerpendicularityTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_Perpendicularity;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_PositionTolerance)) || 
+     theEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_Position;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_LineProfileTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_ProfileOfLine;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_SurfaceProfileTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_ProfileOfSurface;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_StraightnessTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_Straightness;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_SymmetryTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_Symmetry;
+  }
+  else if(theEnt->IsKind(STANDARD_TYPE(StepDimTol_TotalRunoutTolerance)))
+  {
+    theType = XCAFDimTolObjects_GeomToleranceType_TotalRunout;
+  }
+  return Standard_True;
+}
+//=======================================================================
+//function : setGeomTolObjectToXCAF
+//purpose  : 
+//=======================================================================
+static void setGeomTolObjectToXCAF(const Handle(Standard_Transient)& theEnt,
+                                           const TDF_Label& theTolL,
+                                           const Handle(TDocStd_Document)& theDoc,
+                                           const Handle(XSControl_WorkSession)& theWS)
+{
+  Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
+  Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
+  Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
+  Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
+  const Interface_Graph& aGraph = aTP->Graph();
+  Handle(XCAFDoc_GeomTolerance) aGTol;
+  if(!theTolL.FindAttribute(XCAFDoc_GeomTolerance::GetID(), aGTol))
+  {
+    return;
+  }
+  Handle(XCAFDimTolObjects_GeomToleranceObject) aTolObj = aGTol->GetObject();
+  Handle(StepDimTol_GeometricTolerance) aTolEnt = Handle(StepDimTol_GeometricTolerance)::DownCast(theEnt);
+
+  XCAFDimTolObjects_GeomToleranceType aType = XCAFDimTolObjects_GeomToleranceType_None;
+  getTolType(theEnt, aType);
+  aTolObj->SetType(aType);
+  if(!aTolEnt->Magnitude().IsNull()){
+    //get value
+    Standard_Real aVal = aTolEnt->Magnitude()->ValueComponent();
+    StepBasic_Unit anUnit = aTolEnt->Magnitude()->UnitComponent();
+    Standard_Real aFact=1.;
+    if(anUnit.IsNull()) return;
+    if( !(anUnit.CaseNum(anUnit.Value())==1) ) return;
+    Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
+    if(GetLengthConversionFactor(NU,aFact))
+      aVal=aVal*aFact;
+    aTolObj->SetValue(aVal);
+  }
+  //get modifiers
+  XCAFDimTolObjects_GeomToleranceTypeValue aTypeV = XCAFDimTolObjects_GeomToleranceTypeValue_None;
+  Interface_EntityIterator anIter = aGraph.Sharings(aTolEnt);
+  for(anIter.Start(); anIter.More(); anIter.Next()) {
+    if(anIter.Value()->IsKind(STANDARD_TYPE(StepDimTol_ToleranceZone))){
+      Handle(StepDimTol_ToleranceZoneForm) aForm 
+                            = Handle(StepDimTol_ToleranceZone)::DownCast(anIter.Value())->Form();
+      STEPConstruct_GDTProperty::GetTolValueType(aForm->Name(), aTypeV);
+      Interface_EntityIterator anIt = aGraph.Sharings(anIter.Value());
+      for(anIt.Start(); anIt.More(); anIt.Next()) {
+        if(anIt.Value()->IsKind(STANDARD_TYPE(StepDimTol_ProjectedZoneDefinition))){
+          Handle(StepDimTol_ProjectedZoneDefinition) aPZone
+                              = Handle(StepDimTol_ProjectedZoneDefinition)::DownCast(anIt.Value());
+          if(!aPZone->ProjectionLength().IsNull())
+          {
+            Standard_Real aVal = aPZone->ProjectionLength()->ValueComponent();
+            StepBasic_Unit anUnit = aPZone->ProjectionLength()->UnitComponent();
+            Standard_Real aFact=1.;
+            if(anUnit.IsNull()) return;
+            if( !(anUnit.CaseNum(anUnit.Value())==1) ) return;
+            Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
+            if(GetLengthConversionFactor(NU,aFact))
+              aVal=aVal*aFact;
+            aTolObj->SetValueOfZoneModifier(aVal);
           }
-          else if(GT->IsKind(STANDARD_TYPE(StepDimTol_SurfaceProfileTolerance))) {
-            DGTTool->SetDimTol(shL,44,arr,aName,aDescription);
+        }
+        else if (anIt.Value()->IsKind(STANDARD_TYPE(StepDimTol_RunoutZoneDefinition)))
+        {
+          Handle(StepDimTol_RunoutZoneDefinition) aRZone
+                                = Handle(StepDimTol_RunoutZoneDefinition)::DownCast(anIt.Value());
+          if(!aRZone->Orientation().IsNull())
+          {
+            Standard_Real aVal = aRZone->Orientation()->Angle()->ValueComponent();
+            StepBasic_Unit anUnit = aRZone->Orientation()->Angle()->UnitComponent();
+            Standard_Real aFact=1.;
+            if(anUnit.IsNull()) continue;
+            if( !(anUnit.CaseNum(anUnit.Value())==1) ) continue;
+            Handle(StepBasic_NamedUnit) NU = anUnit.NamedUnit();
+            if(GetAngleConversionFactor(NU,aFact)) aVal=aVal*aFact;
+            aTolObj->SetValueOfZoneModifier(aVal);
           }
         }
       }
+      aTolObj->SetTypeOfValue(aTypeV);
     }
   }
+  Handle(StepDimTol_HArray1OfGeometricToleranceModifier) aModifiers;
+  if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricToleranceWithModifiers)))
+  {
+    aModifiers = Handle(StepDimTol_GeometricToleranceWithModifiers)::DownCast(aTolEnt)->Modifiers();
+  }
+  else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)))
+  {
+    aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndGeoTolWthMod)
+                            ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
+  }
+  else if (aTolEnt->IsKind(STANDARD_TYPE(StepDimTol_GeoTolAndGeoTolWthMod)))
+  {
+    aModifiers = Handle(StepDimTol_GeoTolAndGeoTolWthMod)
+                             ::DownCast(aTolEnt)->GetGeometricToleranceWithModifiers()->Modifiers();
+  }
+  if(!aModifiers.IsNull())
+  {
+    for(Standard_Integer i = aModifiers->Lower(); i <= aModifiers->Upper(); i++)
+    {
+      if(aModifiers->Value(i) == StepDimTol_GTMLeastMaterialRequirement)
+        aTolObj->SetMaterialRequirementModifier(XCAFDimTolObjects_GeomToleranceMatReqModif_L);
+      else if (aModifiers->Value(i) == StepDimTol_GTMMaximumMaterialRequirement)
+        aTolObj->SetMaterialRequirementModifier(XCAFDimTolObjects_GeomToleranceMatReqModif_M);
+      else
+        aTolObj->AddModifier((XCAFDimTolObjects_GeomToleranceModif)aModifiers->Value(i));
+    }
+  }
+  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();
+    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);
+  }
+
+  aGTol->SetObject(aTolObj);
+}
 
+//=======================================================================
+//function : ReadGDTs
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean STEPCAFControl_Reader::ReadGDTs(const Handle(XSControl_WorkSession)& theWS,
+                                                 Handle(TDocStd_Document)& theDoc) const
+{
+  Handle(Interface_InterfaceModel) aModel = theWS->Model();
+  Handle(StepData_StepModel) aSM = Handle(StepData_StepModel)::DownCast(aModel);
+  Interface_EntityIterator anI = aSM->Header();
+  Handle(HeaderSection_FileSchema) aH;
+  for(anI.Start(); anI.More() && aH.IsNull();anI.Next())
+    aH = Handle(HeaderSection_FileSchema)::DownCast(anI.Value());
+  Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool( theDoc->Main() );
+  Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
+  Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
+  Handle(XCAFDoc_DimTolTool) aDGTTool = XCAFDoc_DocumentTool::DimTolTool( theDoc->Main() );
+  if ( aDGTTool.IsNull() ) return Standard_False;
+
+  Standard_Integer nb = aModel->NbEntities();
+  for(Standard_Integer i=1; i<=nb; i++) {
+    Handle(Standard_Transient) anEnt = aModel->Value(i);
+    if(anEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalSize)) || 
+       anEnt->IsKind(STANDARD_TYPE(StepShape_DimensionalLocation)) ||
+       anEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))) {
+      TDF_Label aGDTL = createGDTObjectInXCAF(anEnt,theDoc,theWS);
+      if(!aGDTL.IsNull()){
+        if(anEnt->IsKind(STANDARD_TYPE(StepDimTol_GeometricTolerance))){
+          setGeomTolObjectToXCAF(anEnt, aGDTL,theDoc,theWS);
+        }
+        else {
+          setDimObjectToXCAF(anEnt, aGDTL,theDoc,theWS);
+        }
+      }
+    }
+  }
   return Standard_True;
 }
 
index 538998c..f5e8ecd 100644 (file)
@@ -2079,7 +2079,8 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSe
   for(i=1; i<=DGTLabels.Length(); i++) {
     TDF_Label DatumL = DGTLabels.Value(i);
     TDF_LabelSequence ShapeL;
-    if(!DGTTool->GetRefShapeLabel(DatumL,ShapeL)) continue;
+    TDF_LabelSequence aNullSeq;
+    if(!DGTTool->GetRefShapeLabel(DatumL,ShapeL,aNullSeq)) continue;
     // find target shape
     TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL.Value(1));
     TopLoc_Location Loc;
@@ -2160,7 +2161,8 @@ Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSe
   for(i=1; i<=DGTLabels.Length(); i++) {
     TDF_Label DimTolL = DGTLabels.Value(i);
     TDF_LabelSequence ShapeL;
-    if(!DGTTool->GetRefShapeLabel(DimTolL,ShapeL)) continue;
+    TDF_LabelSequence aNullSeq;
+    if(!DGTTool->GetRefShapeLabel(DimTolL,ShapeL,aNullSeq)) continue;
     // find target shape
     TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL.Value(1));
     TopLoc_Location Loc;
index 95b83dc..1ef37dd 100755 (executable)
@@ -12,6 +12,8 @@ STEPConstruct_DataMapOfAsciiStringTransient.hxx
 STEPConstruct_DataMapOfPointTransient.hxx
 STEPConstruct_ExternRefs.cxx
 STEPConstruct_ExternRefs.hxx
+STEPConstruct_GDTProperty.cxx
+STEPConstruct_GDTProperty.hxx
 STEPConstruct_Part.cxx
 STEPConstruct_Part.hxx
 STEPConstruct_PointHasher.cxx
diff --git a/src/STEPConstruct/STEPConstruct_GDTProperty.cxx b/src/STEPConstruct/STEPConstruct_GDTProperty.cxx
new file mode 100644 (file)
index 0000000..c777b29
--- /dev/null
@@ -0,0 +1,600 @@
+// Created on: 1999-09-09
+// Created by: Andrey BETENEV
+// Copyright (c) 1999-1999 Matra Datavision
+// Copyright (c) 1999-2014 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 <STEPConstruct_GDTProperty.hxx>
+#include <StepRepr_DescriptiveRepresentationItem.hxx>
+   
+//=======================================================================
+//function : STEPConstruct_GDTProperty
+//purpose  : 
+//=======================================================================
+
+STEPConstruct_GDTProperty::STEPConstruct_GDTProperty ()
+{
+}
+
+//=======================================================================
+//function : getDimModifiers
+//purpose  : 
+//=======================================================================
+void STEPConstruct_GDTProperty::GetDimModifiers(const Handle(StepRepr_CompoundRepresentationItem)& theCRI,
+                            XCAFDimTolObjects_DimensionModifiersSequence& theModifiers)
+{
+  for (Standard_Integer l = 1; l <= theCRI->ItemElement()->Length(); l++)
+  {
+    Handle(StepRepr_DescriptiveRepresentationItem) aDRI =
+      Handle(StepRepr_DescriptiveRepresentationItem)::DownCast(theCRI->ItemElement()->Value(l));
+    if(aDRI.IsNull()) continue;
+    XCAFDimTolObjects_DimensionModif aModifier = XCAFDimTolObjects_DimensionModif_ControlledRadius;
+    const TCollection_AsciiString aModifStr = aDRI->Description()->String();
+    Standard_Boolean aFound = Standard_False;
+    if(aModifStr.IsEqual("controlled radius"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_ControlledRadius;
+    }
+    else if(aModifStr.IsEqual("square"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_Square;
+    }
+    else if(aModifStr.IsEqual("statistical"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_StatisticalTolerance;
+    }
+    else if(aModifStr.IsEqual("continuous feature"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_ContinuousFeature;
+    }
+    else if(aModifStr.IsEqual("two point size"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_TwoPointSize;
+    }
+    else if(aModifStr.IsEqual("local size defined by a sphere"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_LocalSizeDefinedBySphere;
+    }
+    else if(aModifStr.IsEqual("least squares association criteria"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_LeastSquaresAssociationCriterion;
+    }
+    else if(aModifStr.IsEqual("maximum inscribed association criteria"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_MaximumInscribedAssociation;
+    }
+    else if(aModifStr.IsEqual("minimum circumscribed association criteria"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_MinimumCircumscribedAssociation;
+    }
+    else if(aModifStr.IsEqual("circumference diameter calculated size"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_CircumferenceDiameter;
+    }
+    else if(aModifStr.IsEqual("area diameter calculated size"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_AreaDiameter;
+    }
+    else if(aModifStr.IsEqual("volume diameter calculated size"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_VolumeDiameter;
+    }
+    else if(aModifStr.IsEqual("maximum rank order size"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_MaximumSize;
+    }
+    else if(aModifStr.IsEqual("minimum rank order size"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_MinimumSize;
+    }
+    else if(aModifStr.IsEqual("average rank order size"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_AverageSize;
+    }
+    else if(aModifStr.IsEqual("median rank order size"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_MedianSize;
+    }
+    else if(aModifStr.IsEqual("mid range rank order size"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_MidRangeSize;
+    }
+    else if(aModifStr.IsEqual("range rank order size"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_RangeOfSizes;
+    }
+    else if(aModifStr.IsEqual("any part of the feature"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_AnyRestrictedPortionOfFeature;
+    }
+    else if(aModifStr.IsEqual("any cross section"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_AnyCrossSection;
+    }
+    else if(aModifStr.IsEqual("specific fixed cross section"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_SpecificFixedCrossSection;
+    }           
+    else if(aModifStr.IsEqual("common tolerance"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_CommonTolerance;
+    }             
+    else if(aModifStr.IsEqual("free state condition"))
+    {
+      aFound = Standard_True;
+      aModifier = XCAFDimTolObjects_DimensionModif_FreeStateCondition;
+    }
+    if (aFound)
+      theModifiers.Append(aModifier);
+  }
+}
+
+//=======================================================================
+//function : getClassOfTolerance
+//purpose  : 
+//=======================================================================
+void STEPConstruct_GDTProperty::GetDimClassOfTolerance(const Handle(StepShape_LimitsAndFits)& theLAF,
+                                   Standard_Boolean theHolle,
+                                   XCAFDimTolObjects_DimensionFormVariance theFV,
+                                   XCAFDimTolObjects_DimensionGrade theG)
+{
+  Handle(TCollection_HAsciiString) aFormV = theLAF->FormVariance();
+  Handle(TCollection_HAsciiString) aGrade = theLAF->Grade();
+  theFV = XCAFDimTolObjects_DimensionFormVariance_None;
+  Standard_Boolean aFound;
+  theHolle = Standard_False;
+  //it is not verified information
+  for(Standard_Integer c = 0; c <= 1; c++)
+  {
+    aFound = Standard_False;
+    Standard_Boolean aCaseSens = Standard_False;
+    if (c == 1)
+      aCaseSens = Standard_True;
+    Handle(TCollection_HAsciiString) aStr = new TCollection_HAsciiString("a");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_A;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("b");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_B;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("c");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_C;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("cd");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_CD;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("d");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_D;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("e");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_E;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("ef");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_EF;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("f");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_F;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("fg");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_FG;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("g");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_G;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("h");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_H;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("js");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_JS;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("k");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_K;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("m");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_M;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("n");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_N;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("p");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_P;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("r");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_R;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("s");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_S;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("t");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_T;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("u");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_U;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("v");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_V;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("x");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_X;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("y");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_Y;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("b");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_B;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("z");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_Z;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("za");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_ZA;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("zb");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_ZB;
+      continue;
+    }
+    aStr = new TCollection_HAsciiString("zc");
+    if(aFormV->IsSameString(aStr, aCaseSens))
+    {
+      aFound = Standard_True;
+      theFV = XCAFDimTolObjects_DimensionFormVariance_ZC;
+      continue;
+    }
+
+    if (c == 1 && !aFound)
+      theHolle = Standard_True;
+  }
+  Handle(TCollection_HAsciiString) aStr = new TCollection_HAsciiString("01");
+  if(aGrade->IsSameString(aStr))
+  {
+    theG = XCAFDimTolObjects_DimensionGrade_IT01;
+  }
+  else
+  {
+    theG = (XCAFDimTolObjects_DimensionGrade)(aGrade->IntegerValue()+1);
+  }
+}
+
+//=======================================================================
+//function : getDimType
+//purpose  : 
+//=======================================================================
+Standard_Boolean STEPConstruct_GDTProperty::GetDimType(const Handle(TCollection_HAsciiString)& theName,
+                       XCAFDimTolObjects_DimensionType& theType)
+{
+    TCollection_AsciiString aName = theName->String();
+    aName.LowerCase();
+    theType = XCAFDimTolObjects_DimensionType_Location_None;
+    if(aName.IsEqual("curve length"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_CurveLength;
+    }
+    else if(aName.IsEqual("diameter"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_Diameter;
+    }
+    else if(aName.IsEqual("spherical diameter"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_SphericalDiameter;
+    }
+    else if(aName.IsEqual("radius"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_Radius;
+    }
+    else if(aName.IsEqual("spherical radius"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_SphericalRadius;
+    }
+    else if(aName.IsEqual("toroidal minor diameter"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_ToroidalMinorDiameter;
+    }
+    else if(aName.IsEqual("toroidal major diameter"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_ToroidalMajorDiameter;
+    }
+    else if(aName.IsEqual("toroidal minor radius"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_ToroidalMinorRadius;
+    }
+    else if(aName.IsEqual("toroidal major radius"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_ToroidalMajorRadius;
+    }
+    else if(aName.IsEqual("toroidal high major diameter"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorDiameter;
+    }
+    else if(aName.IsEqual("toroidal low major diameter"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorDiameter;
+    }
+    else if(aName.IsEqual("toroidal high major radius"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_ToroidalHighMajorRadius;
+    }
+    else if(aName.IsEqual("toroidal low major radius"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_ToroidalLowMajorRadius;
+    }
+    else if(aName.IsEqual("thickness"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Size_Thickness;
+    }
+    else if(aName.IsEqual("curved distance"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Location_CurvedDistance;
+    }
+    else if(aName.IsEqual("linear distance"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance;
+    }
+    else if(aName.IsEqual("linear distance centre outer"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToOuter;
+    }
+    else if(aName.IsEqual("linear distance centre inner"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromCenterToInner;
+    }
+    else if(aName.IsEqual("linear distance outer centre"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToCenter;
+    }
+    else if(aName.IsEqual("linear distance outer outer"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToOuter;
+    }
+    else if(aName.IsEqual("linear distance outer inner"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromOuterToInner;
+    }
+    else if(aName.IsEqual("linear distance inner centre"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToCenter;
+    }
+    else if(aName.IsEqual("linear distance inner outer"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToOuter;
+    }
+    else if(aName.IsEqual("linear distance inner inner"))
+    {
+      theType = XCAFDimTolObjects_DimensionType_Location_LinearDistance_FromInnerToInner;
+    }
+
+    if(theType != XCAFDimTolObjects_DimensionType_Location_None)
+    {
+      return Standard_True;
+    }
+    return Standard_False;
+}
+
+
+//=======================================================================
+//function : DatumTargetType
+//purpose  : 
+//=======================================================================
+Standard_Boolean STEPConstruct_GDTProperty::GetDatumTargetType(const Handle(TCollection_HAsciiString)& theDescription,
+                       XCAFDimTolObjects_DatumTargetType& theType)
+{
+    TCollection_AsciiString aName = theDescription->String();
+    aName.LowerCase();
+    if(aName.IsEqual("area"))
+    {
+      theType = XCAFDimTolObjects_DatumTargetType_Area;
+      return Standard_True;
+    }
+    else if(aName.IsEqual("line"))
+    {
+      theType = XCAFDimTolObjects_DatumTargetType_Line;
+      return Standard_True;
+    }
+    else if(aName.IsEqual("circle"))
+    {
+      theType = XCAFDimTolObjects_DatumTargetType_Circle;
+      return Standard_True;
+    }
+    else if(aName.IsEqual("rectangle"))
+    {
+      theType = XCAFDimTolObjects_DatumTargetType_Rectangle;
+      return Standard_True;
+    }
+    else if(aName.IsEqual("point"))
+    {
+      theType = XCAFDimTolObjects_DatumTargetType_Point;
+      return Standard_True;
+    }
+    return Standard_False;
+}
+
+//=======================================================================
+//function : GetDimQualifierType
+//purpose  : 
+//=======================================================================
+Standard_Boolean STEPConstruct_GDTProperty::GetDimQualifierType(const Handle(TCollection_HAsciiString)& theDescription,
+                       XCAFDimTolObjects_DimensionQualifier& theType)
+{
+    TCollection_AsciiString aName = theDescription->String();
+    aName.LowerCase();
+    theType = XCAFDimTolObjects_DimensionQualifier_None;
+    if(aName.IsEqual("maximum"))
+    {
+      theType = XCAFDimTolObjects_DimensionQualifier_Max;
+    }
+    else if(aName.IsEqual("minimum"))
+    {
+      theType = XCAFDimTolObjects_DimensionQualifier_Min;
+    }
+    else if(aName.IsEqual("average"))
+    {
+      theType = XCAFDimTolObjects_DimensionQualifier_Avg;
+    }
+    if(theType != XCAFDimTolObjects_DimensionQualifier_None)
+    {
+      return Standard_True;
+    }
+    return Standard_False;
+}
+
+//=======================================================================
+//function : GetTolValueType
+//purpose  : 
+//=======================================================================
+Standard_Boolean STEPConstruct_GDTProperty::GetTolValueType(const Handle(TCollection_HAsciiString)& theDescription,
+                       XCAFDimTolObjects_GeomToleranceTypeValue& theType)
+{
+    TCollection_AsciiString aName = theDescription->String();
+    aName.LowerCase();
+    theType = XCAFDimTolObjects_GeomToleranceTypeValue_None;
+    if(aName.IsEqual("cylindrical or circular"))
+    {
+      theType = XCAFDimTolObjects_GeomToleranceTypeValue_Diameter;
+    }
+    else if(aName.IsEqual("spherical"))
+    {
+      theType = XCAFDimTolObjects_GeomToleranceTypeValue_SphericalDiameter;
+    }
+    if(theType != XCAFDimTolObjects_GeomToleranceTypeValue_None)
+    {
+      return Standard_True;
+    }
+    return Standard_False;
+}
\ No newline at end of file
diff --git a/src/STEPConstruct/STEPConstruct_GDTProperty.hxx b/src/STEPConstruct/STEPConstruct_GDTProperty.hxx
new file mode 100644 (file)
index 0000000..cd995eb
--- /dev/null
@@ -0,0 +1,68 @@
+// Created on: 1999-09-08
+// Created by: Andrey BETENEV
+// Copyright (c) 1999 Matra Datavision
+// Copyright (c) 1999-2014 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 _STEPConstruct_GDTProperty_HeaderFile
+#define _STEPConstruct_GDTProperty_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Handle.hxx>
+
+#include <STEPConstruct_Tool.hxx>
+#include <Standard_Boolean.hxx>
+#include <Standard_CString.hxx>
+#include <StepRepr_CompoundRepresentationItem.hxx>
+#include <XCAFDimTolObjects_DimensionModifiersSequence.hxx>
+#include <StepShape_LimitsAndFits.hxx>
+#include <XCAFDimTolObjects_DimensionFormVariance.hxx>
+#include <XCAFDimTolObjects_DimensionGrade.hxx>
+#include <XCAFDimTolObjects_DimensionType.hxx>
+#include <XCAFDimTolObjects_DatumTargetType.hxx>
+#include <XCAFDimTolObjects_DimensionQualifier.hxx>
+#include <XCAFDimTolObjects_GeomToleranceTypeValue.hxx>
+
+//! This class provides tools for access (read)
+//! the GDT properties.
+class STEPConstruct_GDTProperty
+{
+public:
+
+  DEFINE_STANDARD_ALLOC
+
+  Standard_EXPORT STEPConstruct_GDTProperty();
+  Standard_EXPORT static void GetDimModifiers(const Handle(StepRepr_CompoundRepresentationItem)& theCRI,
+                                              XCAFDimTolObjects_DimensionModifiersSequence& theModifiers);
+
+  Standard_EXPORT static void GetDimClassOfTolerance(const Handle(StepShape_LimitsAndFits)& theLAF,
+                                                     Standard_Boolean theHolle,
+                                                     XCAFDimTolObjects_DimensionFormVariance theFV,
+                                                     XCAFDimTolObjects_DimensionGrade theG);
+
+  Standard_EXPORT static Standard_Boolean GetDimType(const Handle(TCollection_HAsciiString)& theName,
+                                                     XCAFDimTolObjects_DimensionType& theType);
+
+  Standard_EXPORT static Standard_Boolean GetDatumTargetType(const Handle(TCollection_HAsciiString)& theDescription,
+                                                     XCAFDimTolObjects_DatumTargetType& theType);
+
+  Standard_EXPORT static Standard_Boolean GetDimQualifierType(const Handle(TCollection_HAsciiString)& theDescription,
+                                                     XCAFDimTolObjects_DimensionQualifier& theType);
+
+  Standard_EXPORT static Standard_Boolean GetTolValueType(const Handle(TCollection_HAsciiString)& theDescription,
+                                                     XCAFDimTolObjects_GeomToleranceTypeValue& theType);
+
+};
+
+#endif // _STEPConstruct_GDTProperty_HeaderFile
index 8542b3a..bf9c60a 100644 (file)
@@ -288,6 +288,7 @@ static Standard_CString schemaAP203    = "CONFIG_CONTROL_DESIGN";
 #include <StepBasic_SecurityClassificationLevel.hxx>
 #include <StepRepr_ShapeAspect.hxx>
 #include <StepRepr_ShapeAspectRelationship.hxx>
+#include <StepRepr_FeatureForDatumTargetRelationship.hxx>
 #include <StepRepr_ShapeAspectTransition.hxx>
 #include <StepShape_ShapeDefinitionRepresentation.hxx>
 #include <StepShape_ShapeRepresentation.hxx>
@@ -1411,6 +1412,7 @@ StepAP214_Protocol::StepAP214_Protocol ()
   types.Bind (STANDARD_TYPE(StepRepr_CompShAspAndDatumFeatAndShAsp), 699);
   types.Bind (STANDARD_TYPE(StepRepr_IntegerRepresentationItem), 700);
   types.Bind (STANDARD_TYPE(StepRepr_ValueRepresentationItem), 701);
+  types.Bind (STANDARD_TYPE(StepRepr_FeatureForDatumTargetRelationship), 702);
 }
 
 //=======================================================================
index ecbd76d..7eced5d 100644 (file)
@@ -48,6 +48,8 @@ StepRepr_Extension.cxx
 StepRepr_Extension.hxx
 StepRepr_ExternallyDefinedRepresentation.cxx
 StepRepr_ExternallyDefinedRepresentation.hxx
+StepRepr_FeatureForDatumTargetRelationship.cxx
+StepRepr_FeatureForDatumTargetRelationship.hxx
 StepRepr_FunctionallyDefinedTransformation.cxx
 StepRepr_FunctionallyDefinedTransformation.hxx
 StepRepr_GeometricAlignment.cxx
diff --git a/src/StepRepr/StepRepr_FeatureForDatumTargetRelationship.cxx b/src/StepRepr/StepRepr_FeatureForDatumTargetRelationship.cxx
new file mode 100644 (file)
index 0000000..4e2bb8a
--- /dev/null
@@ -0,0 +1,29 @@
+// Created on: 2000-04-18
+// Created by: Andrey BETENEV
+// Copyright (c) 2000-2014 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.
+
+// Generator:  ExpToCas (EXPRESS -> CASCADE/XSTEP Translator) V1.0
+
+#include <Standard_Type.hxx>
+#include <StepRepr_ShapeAspect.hxx>
+#include <StepRepr_FeatureForDatumTargetRelationship.hxx>
+
+//=======================================================================
+//function : StepRepr_FeatureForDatumtargetRelationship
+//purpose  : 
+//=======================================================================
+
+StepRepr_FeatureForDatumTargetRelationship::StepRepr_FeatureForDatumTargetRelationship ()
+{
+}
\ No newline at end of file
diff --git a/src/StepRepr/StepRepr_FeatureForDatumTargetRelationship.hxx b/src/StepRepr/StepRepr_FeatureForDatumTargetRelationship.hxx
new file mode 100644 (file)
index 0000000..887e6ac
--- /dev/null
@@ -0,0 +1,59 @@
+// Created on: 2000-04-18
+// Created by: Andrey BETENEV
+// Copyright (c) 2000-2014 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 _StepRepr_FeatureForDatumtargetRelationship_HeaderFile
+#define _StepRepr_FeatureForDatumtargetRelationship_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <StepRepr_ShapeAspectRelationship.hxx>
+
+
+class StepRepr_FeatureForDatumTargetRelationship;
+DEFINE_STANDARD_HANDLE(StepRepr_FeatureForDatumTargetRelationship, StepRepr_ShapeAspectRelationship)
+
+//! Representation of STEP entity DimensionalLocation
+class StepRepr_FeatureForDatumTargetRelationship : public StepRepr_ShapeAspectRelationship
+{
+
+public:
+
+  
+  //! Empty constructor
+  Standard_EXPORT StepRepr_FeatureForDatumTargetRelationship();
+
+
+  DEFINE_STANDARD_RTTI(StepRepr_FeatureForDatumTargetRelationship,StepRepr_ShapeAspectRelationship)
+
+protected:
+
+
+
+
+private:
+
+
+
+
+};
+
+
+
+
+
+
+
+#endif // _StepRepr_FeatureForDatumtargetRelationship_HeaderFile
index 24b0063..2fd6441 100644 (file)
@@ -15,6 +15,7 @@
 #include <Standard_Transient.hxx>
 #include <StepShape_PrecisionQualifier.hxx>
 #include <StepShape_TypeQualifier.hxx>
+#include <StepShape_ValueFormatTypeQualifier.hxx>
 #include <StepShape_ValueQualifier.hxx>
 
 StepShape_ValueQualifier::StepShape_ValueQualifier  ()    {  }
@@ -33,3 +34,6 @@ Handle(StepShape_PrecisionQualifier)  StepShape_ValueQualifier::PrecisionQualifi
 
 Handle(StepShape_TypeQualifier)  StepShape_ValueQualifier::TypeQualifier () const
 {  return Handle(StepShape_TypeQualifier)::DownCast(Value());  }
+
+Handle(StepShape_ValueFormatTypeQualifier)  StepShape_ValueQualifier::ValueFormatTypeQualifier () const
+{  return Handle(StepShape_ValueFormatTypeQualifier)::DownCast(Value());  }
\ No newline at end of file
index 0397497..f9f833c 100644 (file)
@@ -25,6 +25,7 @@
 class Standard_Transient;
 class StepShape_PrecisionQualifier;
 class StepShape_TypeQualifier;
+class StepShape_ValueFormatTypeQualifier;
 
 
 //! Added for Dimensional Tolerances
@@ -49,6 +50,9 @@ public:
   //! Returns Value as TypeQualifier
   Standard_EXPORT Handle(StepShape_TypeQualifier) TypeQualifier() const;
 
+  //! Returns Value as ValueFormatTypeQualifier
+  Standard_EXPORT Handle(StepShape_ValueFormatTypeQualifier) ValueFormatTypeQualifier() const;
+
 
 
 
index 5b2e941..0344eb2 100644 (file)
@@ -9,6 +9,7 @@ XCAFDimTolObjects_Tool.cxx
 XCAFDimTolObjects_Tool.hxx
 XCAFDimTolObjects_DatumModifWithValue.hxx
 XCAFDimTolObjects_DatumSingleModif.hxx
+XCAFDimTolObjects_DatumTargetType.hxx
 XCAFDimTolObjects_DimensionModif.hxx
 XCAFDimTolObjects_DimensionFormVariance.hxx
 XCAFDimTolObjects_DimensionGrade.hxx
index 9770a57..02195ce 100644 (file)
@@ -21,6 +21,7 @@
 
 XCAFDimTolObjects_DatumObject::XCAFDimTolObjects_DatumObject()
 {
+  myIsDTarget = Standard_False;
 }
 
 //=======================================================================
@@ -35,6 +36,9 @@ XCAFDimTolObjects_DatumObject::XCAFDimTolObjects_DatumObject(const Handle(XCAFDi
   myModifierWithValue = theObj->myModifierWithValue;
   myValueOfModifier = theObj->myValueOfModifier;
   myDatumTarget = theObj->myDatumTarget;
+  myIsDTarget = theObj->myIsDTarget;
+  myAxis = theObj->myAxis;
+  myDTargetType = theObj->myDTargetType;
 }
 
 //=======================================================================
@@ -132,11 +136,122 @@ void XCAFDimTolObjects_DatumObject::SetDatumTarget (const TopoDS_Shape& theShape
 }
   
 //=======================================================================
+//function : GetPosition
+//purpose  : 
+//=======================================================================
+
+Standard_Integer XCAFDimTolObjects_DatumObject::GetPosition() const
+{
+  return myPosition;
+}
+
+//=======================================================================
+//function : SetName
+//purpose  : 
+//=======================================================================
+
+void XCAFDimTolObjects_DatumObject::SetPosition(const Standard_Integer thePosition)
+{
+  myPosition = thePosition;
+}
+
+//=======================================================================
+//function : IsDatumTarget
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean XCAFDimTolObjects_DatumObject::IsDatumTarget() const
+{
+  return myIsDTarget;
+}
+
+//=======================================================================
 //function : IsDatumTarget
 //purpose  : 
 //=======================================================================
 
-Standard_Boolean XCAFDimTolObjects_DatumObject::IsDatumTarget()  const
+void XCAFDimTolObjects_DatumObject::IsDatumTarget(const Standard_Boolean theIsDT)
+{
+  myIsDTarget = theIsDT;
+}
+
+//=======================================================================
+//function : GetDatumTargetType
+//purpose  : 
+//=======================================================================
+
+XCAFDimTolObjects_DatumTargetType XCAFDimTolObjects_DatumObject::GetDatumTargetType() const
 {
-  return !myDatumTarget.IsNull();
+  return myDTargetType;
 }
+
+//=======================================================================
+//function : SetDatumTargetType
+//purpose  : 
+//=======================================================================
+
+void XCAFDimTolObjects_DatumObject::SetDatumTargetType(const XCAFDimTolObjects_DatumTargetType theType)
+{
+  myDTargetType = theType;
+}
+
+//=======================================================================
+//function : GetDatumTargetAxis
+//purpose  : 
+//=======================================================================
+
+gp_Ax2 XCAFDimTolObjects_DatumObject::GetDatumTargetAxis() const
+{
+  return myAxis;
+}
+
+//=======================================================================
+//function : SetDatumTargetAxis
+//purpose  : 
+//=======================================================================
+
+void XCAFDimTolObjects_DatumObject::SetDatumTargetAxis(const gp_Ax2& theAxis)
+{
+  myAxis = theAxis;
+}
+
+//=======================================================================
+//function : GetDatumTargetLength
+//purpose  : 
+//=======================================================================
+
+Standard_Real XCAFDimTolObjects_DatumObject::GetDatumTargetLength() const
+{
+  return myLength;
+}
+
+//=======================================================================
+//function : SetDatumTargetLength
+//purpose  : 
+//=======================================================================
+
+void XCAFDimTolObjects_DatumObject::SetDatumTargetLength(const Standard_Real theLength)
+{
+  myLength = theLength;
+}
+
+
+//=======================================================================
+//function : GetDatumTargetWidth
+//purpose  : 
+//=======================================================================
+
+Standard_Real XCAFDimTolObjects_DatumObject::GetDatumTargetWidth() const
+{
+  return myWidth;
+}
+
+//=======================================================================
+//function : SetDatumTargetWidth
+//purpose  : 
+//=======================================================================
+
+void XCAFDimTolObjects_DatumObject::SetDatumTargetWidth(const Standard_Real theWidth)
+{
+  myWidth = theWidth;
+}
\ No newline at end of file
index 80d1f3f..a18d8b3 100644 (file)
@@ -21,6 +21,7 @@
 #include <Standard_Type.hxx>
 
 #include <XCAFDimTolObjects_DatumObjectSequence.hxx>
+#include <XCAFDimTolObjects_DatumTargetType.hxx>
 #include <TCollection_HAsciiString.hxx>
 #include <XCAFDimTolObjects_DatumModifiersSequence.hxx>
 #include <XCAFDimTolObjects_DatumModifWithValue.hxx>
@@ -29,6 +30,7 @@
 #include <Standard_Transient.hxx>
 #include <XCAFDimTolObjects_DatumSingleModif.hxx>
 #include <Standard_Boolean.hxx>
+#include <gp_Ax2.hxx>
 
 class XCAFDimTolObjects_DatumObject;
 DEFINE_STANDARD_HANDLE(XCAFDimTolObjects_DatumObject, Standard_Transient)
@@ -60,9 +62,31 @@ public:
   Standard_EXPORT TopoDS_Shape GetDatumTarget() const;
   
   Standard_EXPORT void SetDatumTarget (const TopoDS_Shape& theShape);
+
+  Standard_EXPORT Standard_Integer GetPosition () const;
+  
+  Standard_EXPORT void SetPosition (const Standard_Integer thePosition);
   
   Standard_EXPORT Standard_Boolean IsDatumTarget() const;
 
+  Standard_EXPORT void IsDatumTarget(const Standard_Boolean theIsDT);
+
+  Standard_EXPORT XCAFDimTolObjects_DatumTargetType GetDatumTargetType() const;
+
+  Standard_EXPORT void SetDatumTargetType (const XCAFDimTolObjects_DatumTargetType theType);
+
+  Standard_EXPORT gp_Ax2 GetDatumTargetAxis() const;
+
+  Standard_EXPORT void SetDatumTargetAxis (const gp_Ax2& theAxis);
+
+  Standard_EXPORT Standard_Real GetDatumTargetLength() const;
+
+  Standard_EXPORT void SetDatumTargetLength (const Standard_Real theLength);
+
+  Standard_EXPORT Standard_Real GetDatumTargetWidth() const;
+
+  Standard_EXPORT void SetDatumTargetWidth (const Standard_Real theWidth);
+
 
   DEFINE_STANDARD_RTTI(XCAFDimTolObjects_DatumObject,Standard_Transient)
 
@@ -73,6 +97,13 @@ private:
   XCAFDimTolObjects_DatumModifWithValue myModifierWithValue;
   Standard_Real myValueOfModifier;
   TopoDS_Shape myDatumTarget;
+  Standard_Integer myPosition;
+  Standard_Boolean myIsDTarget;
+  XCAFDimTolObjects_DatumTargetType myDTargetType;
+  gp_Ax2 myAxis;
+  Standard_Real myLength;
+  Standard_Real myWidth;
+  
 
 };
 
diff --git a/src/XCAFDimTolObjects/XCAFDimTolObjects_DatumTargetType.hxx b/src/XCAFDimTolObjects/XCAFDimTolObjects_DatumTargetType.hxx
new file mode 100644 (file)
index 0000000..4a8543b
--- /dev/null
@@ -0,0 +1,30 @@
+// Created on: 2015-08-06
+// Created by: Ilya Novikov
+// Copyright (c) 2004-2014 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 _XCAFDimTolObjects_DatumTargetType_HeaderFile
+#define _XCAFDimTolObjects_DatumTargetType_HeaderFile
+
+//! Defines types of dimension
+enum XCAFDimTolObjects_DatumTargetType
+{
+XCAFDimTolObjects_DatumTargetType_Point,
+XCAFDimTolObjects_DatumTargetType_Line,
+XCAFDimTolObjects_DatumTargetType_Rectangle,
+XCAFDimTolObjects_DatumTargetType_Circle,
+XCAFDimTolObjects_DatumTargetType_Area
+};
+
+#endif // _XCAFDimTolObjects_DatumTargetType_HeaderFile
index dc63687..c0811b5 100644 (file)
@@ -313,10 +313,10 @@ Standard_Boolean XCAFDimTolObjects_DimensionObject::GetClassOfTolerance (Standar
   XCAFDimTolObjects_DimensionFormVariance& theFormVariance,
   XCAFDimTolObjects_DimensionGrade& theGrade)  const
 {
+  theFormVariance = myFormVariance;
   if(myFormVariance != XCAFDimTolObjects_DimensionFormVariance_None)
   {
     theHole = myIsHole;
-    theFormVariance = myFormVariance;
     theGrade = myGrade;
     return Standard_True;
   }
index 77985bc..ea9cec2 100644 (file)
@@ -33,7 +33,9 @@ XCAFDimTolObjects_GeomToleranceModif_Pitch_Diameter,
 XCAFDimTolObjects_GeomToleranceModif_Reciprocity_Requirement,
 XCAFDimTolObjects_GeomToleranceModif_Separate_Requirement,
 XCAFDimTolObjects_GeomToleranceModif_Statistical_Tolerance,
-XCAFDimTolObjects_GeomToleranceModif_Tangent_Plane
+XCAFDimTolObjects_GeomToleranceModif_Tangent_Plane,
+XCAFDimTolObjects_GeomToleranceModif_All_Around,
+XCAFDimTolObjects_GeomToleranceModif_All_Over,
 };
 
 #endif // _XCAFDimTolObjects_GeomToleranceModif_HeaderFile
index 8cbda95..dd14dfc 100644 (file)
@@ -20,6 +20,7 @@
 
 XCAFDimTolObjects_GeomToleranceObject::XCAFDimTolObjects_GeomToleranceObject()
 {
+  myHasAxis = Standard_False;
 }
 
 //=======================================================================
@@ -37,6 +38,8 @@ XCAFDimTolObjects_GeomToleranceObject::XCAFDimTolObjects_GeomToleranceObject(con
   myValueOfZoneModif = theObj->myValueOfZoneModif;
   myModifiers = theObj->myModifiers;
   myMaxValueModif = theObj->myMaxValueModif;
+  myAxis = theObj->GetAxis();
+  myHasAxis = Standard_False;
 }
 
 //=======================================================================
@@ -208,3 +211,34 @@ Standard_Real XCAFDimTolObjects_GeomToleranceObject::GetMaxValueModifier()  cons
 {
   return myMaxValueModif;
 }
+
+//=======================================================================
+//function :
+//purpose  : 
+//=======================================================================
+
+void XCAFDimTolObjects_GeomToleranceObject::SetAxis (const gp_Ax2 theAxis) 
+{
+  myAxis = theAxis;
+  myHasAxis = Standard_True;
+}
+
+//=======================================================================
+//function :
+//purpose  : 
+//=======================================================================
+
+gp_Ax2 XCAFDimTolObjects_GeomToleranceObject::GetAxis()  const
+{
+  return myAxis;
+}
+
+//=======================================================================
+//function :
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean XCAFDimTolObjects_GeomToleranceObject::HasAxis () const 
+{
+  return myHasAxis;
+}
\ No newline at end of file
index c55ab6c..d53ae52 100644 (file)
@@ -29,6 +29,7 @@
 #include <XCAFDimTolObjects_GeomToleranceModifiersSequence.hxx>
 #include <Standard_Transient.hxx>
 #include <XCAFDimTolObjects_GeomToleranceModif.hxx>
+#include <gp_Ax2.hxx>
 
 class XCAFDimTolObjects_GeomToleranceObject;
 DEFINE_STANDARD_HANDLE(XCAFDimTolObjects_GeomToleranceObject, Standard_Transient)
@@ -77,6 +78,12 @@ public:
   
   Standard_EXPORT Standard_Real GetMaxValueModifier() const;
 
+  Standard_EXPORT void SetAxis (const gp_Ax2 theAxis);
+  
+  Standard_EXPORT gp_Ax2 GetAxis() const;
+   
+  Standard_EXPORT Standard_Boolean HasAxis () const;
+
   DEFINE_STANDARD_RTTI(XCAFDimTolObjects_GeomToleranceObject,Standard_Transient)
 
 private: 
@@ -89,8 +96,8 @@ private:
   Standard_Real myValueOfZoneModif;
   XCAFDimTolObjects_GeomToleranceModifiersSequence myModifiers;
   Standard_Real myMaxValueModif;
-
-
+  gp_Ax2 myAxis;
+  Standard_Boolean myHasAxis;
 };
 
 
index 4969413..b70ef39 100644 (file)
@@ -173,11 +173,11 @@ Standard_Boolean XCAFDimTolObjects_Tool::GetRefDatum(const TopoDS_Shape& theShap
   myDimTolTool->ShapeTool()->Search(theShape, aShapeL);
   if(!aShapeL.IsNull())
   {
-    TDF_Label aDatumL;
+    TDF_LabelSequence aDatumL;
     if(myDimTolTool->GetRefDatumLabel(aShapeL, aDatumL))
     {
       Handle(XCAFDoc_Datum) aDatum;
-      if( aDatumL.FindAttribute(XCAFDoc_Datum::GetID(),aDatum)){
+      if( aDatumL.First().FindAttribute(XCAFDoc_Datum::GetID(),aDatum)){
         theDatumObject = aDatum->GetObject();
         return Standard_True;
       }
index ab339a5..99b5f95 100644 (file)
@@ -94,13 +94,24 @@ Standard_GUID XCAFDoc::DimTolRefGUID()
 //purpose  : 
 //=======================================================================
 
-Standard_GUID XCAFDoc::DimensionRefGUID()
+Standard_GUID XCAFDoc::DimensionRefFirstGUID()
 {
   static Standard_GUID ID("efd212e3-6dfd-11d4-b9c8-0060b0ee281b");
   return ID;
 }
 
 //=======================================================================
+//function : DimensionRefGUID
+//purpose  : 
+//=======================================================================
+
+Standard_GUID XCAFDoc::DimensionRefSecondGUID()
+{
+  static Standard_GUID ID("efd212e0-6dfd-11d4-b9c8-0060b0ee281b");
+  return ID;
+}
+
+//=======================================================================
 //function : GeomToleranceRefGUID
 //purpose  : 
 //=======================================================================
index 703e70c..9b44ad7 100644 (file)
@@ -78,7 +78,10 @@ public:
   Standard_EXPORT static Standard_GUID DimTolRefGUID();
 
   //! Return GUIDs for TreeNode representing specified types of Dimension
-  Standard_EXPORT static   Standard_GUID DimensionRefGUID() ;
+  Standard_EXPORT static   Standard_GUID DimensionRefFirstGUID() ;
+
+  //! Return GUIDs for TreeNode representing specified types of Dimension
+  Standard_EXPORT static   Standard_GUID DimensionRefSecondGUID() ;
 
   //! Return GUIDs for TreeNode representing specified types of GeomTolerance
   Standard_EXPORT static   Standard_GUID GeomToleranceRefGUID() ;
index b326f36..3e7a07a 100644 (file)
 #include <TCollection_HAsciiString.hxx>
 #include <TDF_Attribute.hxx>
 #include <TDF_Label.hxx>
+#include <TDF_ChildIterator.hxx>
 #include <TDF_RelocationTable.hxx>
 #include <XCAFDoc_Datum.hxx>
 #include <TDataStd_AsciiString.hxx>
 #include <TDataStd_IntegerArray.hxx>
+#include <TDataStd_RealArray.hxx>
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_Real.hxx>
 #include <TNaming_NamedShape.hxx>
@@ -34,7 +36,14 @@ enum ChildLab
   ChildLab_Name = 1,
   ChildLab_Modifiers,
   ChildLab_ModifierWithValue,
-  ChildLab_DatumTarget
+  ChildLab_IsDTarget,
+  ChildLab_DTargetType,
+  ChildLab_AxisLoc,
+  ChildLab_AxisN,
+  ChildLab_AxisRef,
+  ChildLab_DTargetLength,
+  ChildLab_DTargetWidth,
+  ChildLab_DatumTarget,
 };
 
 //=======================================================================
@@ -152,7 +161,12 @@ Handle(TCollection_HAsciiString) XCAFDoc_Datum::GetIdentification() const
 void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theObject)
 {
   Backup();
-  if (!theObject->GetName().IsNull())
+  TDF_ChildIterator anIter(Label());
+  for(;anIter.More(); anIter.Next())
+  {
+    anIter.Value().ForgetAllAttributes();
+  }
+  if (!theObject->GetName().IsNull() && !theObject->GetName()->IsEmpty())
   {
     Handle(TDataStd_AsciiString) anAttName;
     if(!Label().FindChild(ChildLab_Name).FindAttribute(TDataStd_AsciiString::GetID(), anAttName))
@@ -162,16 +176,8 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb
     }
     anAttName->Set(theObject->GetName()->String());
   }
-  else
-  {
-    Label().FindChild(ChildLab_Name).ForgetAllAttributes();
-  }
 
-  if(theObject->GetModifiers().Length() == 0)
-  {
-    Label().FindChild(ChildLab_Modifiers).ForgetAllAttributes();
-  }
-  else
+  if(theObject->GetModifiers().Length() > 0)
   {
     Handle(TDataStd_IntegerArray) aModifiers;
     if(!Label().FindChild(ChildLab_Modifiers).FindAttribute(TDataStd_IntegerArray::GetID(), aModifiers))
@@ -205,19 +211,60 @@ void XCAFDoc_Datum::SetObject(const Handle(XCAFDimTolObjects_DatumObject)& theOb
     aModifierWithValueM->Set(aM);
     aModifierWithValueV->Set(aV);
   }
-  else
-  {
-    Label().FindChild(ChildLab_ModifierWithValue).ForgetAllAttributes();
-  }
 
-  if(!theObject->GetDatumTarget().IsNull())
-  {
-    TNaming_Builder tnBuild(Label().FindChild(ChildLab_DatumTarget));
-    tnBuild.Generated(theObject->GetDatumTarget());
-  }
-  else
+  Handle(TDataStd_Integer) aIsTarget = new TDataStd_Integer();
+  aIsTarget->Set(theObject->IsDatumTarget());
+  Label().FindChild(ChildLab_IsDTarget).AddAttribute(aIsTarget);
+
+  if(theObject->IsDatumTarget())
   {
-    Label().FindChild(ChildLab_DatumTarget).ForgetAllAttributes();
+    Handle(TDataStd_Integer) aType = new TDataStd_Integer();
+    aType->Set(theObject->GetDatumTargetType());
+    Label().FindChild(ChildLab_DTargetType).AddAttribute(aType);
+
+    if(theObject->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Area)
+    {
+      if(!theObject->GetDatumTarget().IsNull())
+      {
+        TNaming_Builder tnBuild(Label().FindChild(ChildLab_DatumTarget));
+        tnBuild.Generated(theObject->GetDatumTarget());
+      }
+    }
+    else
+    {
+      Handle(TDataStd_RealArray) aLoc = new TDataStd_RealArray();
+      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());
+
+      aR->SetValue(aR->Upper(),anAx.Direction().X());
+      aR->SetValue(aR->Upper(),anAx.Direction().X());
+      aR->SetValue(aR->Upper(),anAx.Direction().X());
+
+      Label().FindChild(ChildLab_AxisLoc).AddAttribute(aLoc);
+      Label().FindChild(ChildLab_AxisN).AddAttribute(aN);
+      Label().FindChild(ChildLab_AxisRef).AddAttribute(aR);
+
+      if(theObject->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Point)
+      {
+        Handle(TDataStd_Real) aLen = new TDataStd_Real();
+        aLen->Set(theObject->GetDatumTargetLength());
+        Label().FindChild(ChildLab_DTargetLength).AddAttribute(aLen);
+        if(theObject->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Rectangle)
+        {
+          Handle(TDataStd_Real) aWidth = new TDataStd_Real();
+          aWidth->Set(theObject->GetDatumTargetWidth());
+          Label().FindChild(ChildLab_DTargetWidth).AddAttribute(aWidth);
+        }
+      }
+    }
   }
 }
 
@@ -257,10 +304,64 @@ Handle(XCAFDimTolObjects_DatumObject) XCAFDoc_Datum::GetObject() const
     }
   }
 
-  Handle(TNaming_NamedShape) aDatumTarget;
-  if(Label().FindChild(ChildLab_DatumTarget).FindAttribute(TNaming_NamedShape::GetID(), aDatumTarget))
+  Handle(TDataStd_Integer) aIsDTarget;
+  if(Label().FindChild(ChildLab_IsDTarget).FindAttribute(TDataStd_Integer::GetID(), aIsDTarget))
+  {
+    anObj->IsDatumTarget((aIsDTarget->Get() != 0));
+  }
+  else
+  {
+    return anObj;
+  }
+
+  if (aIsDTarget->Get() != 0)
   {
-    anObj->SetDatumTarget(aDatumTarget->Get());
+    Handle(TDataStd_Integer) aDTargetType;
+    if(Label().FindChild(ChildLab_DTargetType).FindAttribute(TDataStd_Integer::GetID(), aDTargetType))
+    {
+      anObj->SetDatumTargetType((XCAFDimTolObjects_DatumTargetType)aDTargetType->Get());
+      if(anObj->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Area)
+      {
+        Handle(TNaming_NamedShape) aDatumTarget;
+        if(Label().FindChild(ChildLab_DatumTarget).FindAttribute(TNaming_NamedShape::GetID(), aDatumTarget))
+        {
+          anObj->SetDatumTarget(aDatumTarget->Get());
+        }
+      }
+      else
+      {
+        Handle(TDataStd_RealArray) aLoc;
+        Handle(TDataStd_RealArray) aN;
+        Handle(TDataStd_RealArray) aR;
+        if(Label().FindChild(ChildLab_AxisLoc).FindAttribute(TDataStd_RealArray::GetID(), aLoc) && aLoc->Length() == 3 &&
+          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_Ax2 anAx(aL, aD, aDR);
+          anObj->SetDatumTargetAxis(anAx);
+        }
+
+        if(anObj->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Point)
+        {
+          Handle(TDataStd_Real) aLen;
+          if(Label().FindChild(ChildLab_DTargetLength).FindAttribute(TDataStd_Integer::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))
+            {
+              anObj->SetDatumTargetWidth(aWidth->Get());
+            }
+          }
+        }
+      }
+    }
   }
 
   return anObj;
index de71831..09d8813 100644 (file)
@@ -314,43 +314,79 @@ void XCAFDoc_DimTolTool::SetDimension(const TDF_Label& theFirstL,
                                    const TDF_Label& theSecondL,
                                    const TDF_Label& theDimTolL) const
 {
+  TDF_LabelSequence aFirstLS, aSecondLS;
+  if(!theFirstL.IsNull())
+    aFirstLS.Append(theFirstL);
+  if(!theSecondL.IsNull())
+    aSecondLS.Append(theSecondL);
+  SetDimension(aFirstLS, aSecondLS, theDimTolL);
+}
+
+//=======================================================================
+//function : SetDimension
+//purpose  : 
+//=======================================================================
+
+void XCAFDoc_DimTolTool::SetDimension(const TDF_LabelSequence& theFirstL,
+                                   const TDF_LabelSequence& theSecondL,
+                                   const TDF_Label& theDimTolL) const
+{
+  if(!IsDimension(theDimTolL) || theFirstL.Length() == 0)
+  {
+    return;
+  }
+
   Handle(XCAFDoc_GraphNode) aChGNode;
   Handle(XCAFDoc_GraphNode) aFGNode;
   Handle(XCAFDoc_GraphNode) aSecondFGNode;
 
-  //Handle(XCAFDoc_GraphNode) ChGNode, FGNode;
-  if ( theDimTolL.FindAttribute (XCAFDoc::DimensionRefGUID(), aChGNode) ) {
+  if ( theDimTolL.FindAttribute (XCAFDoc::DimensionRefFirstGUID(), aChGNode) ) {
     while (aChGNode->NbFathers() > 0) {
       aFGNode = aChGNode->GetFather(1);
       aFGNode->UnSetChild(aChGNode);
+      if(aFGNode->NbChildren() == 0)
+        aFGNode->ForgetAttribute( XCAFDoc::DimensionRefFirstGUID() );
     }
-    theDimTolL.ForgetAttribute ( XCAFDoc::DimTolRefGUID() );
+    theDimTolL.ForgetAttribute ( XCAFDoc::DimensionRefFirstGUID() );
   }
-
-  if(!IsDimension(theDimTolL))
-  {
-    return;
+  if ( theDimTolL.FindAttribute (XCAFDoc::DimensionRefSecondGUID(), aChGNode) ) {
+    while (aChGNode->NbFathers() > 0) {
+      aFGNode = aChGNode->GetFather(1);
+      aFGNode->UnSetChild(aChGNode);
+      if(aFGNode->NbChildren() == 0)
+        aFGNode->ForgetAttribute( XCAFDoc::DimensionRefSecondGUID() );
+    }
+    theDimTolL.ForgetAttribute ( XCAFDoc::DimensionRefSecondGUID() );
   }
 
-  if (!theDimTolL.FindAttribute(XCAFDoc::DimensionRefGUID(), aChGNode) ) {
+  if (!theDimTolL.FindAttribute(XCAFDoc::DimensionRefFirstGUID(), aChGNode)) {
     aChGNode = new XCAFDoc_GraphNode;
     aChGNode = XCAFDoc_GraphNode::Set(theDimTolL);
+    aChGNode->SetGraphID(XCAFDoc::DimensionRefFirstGUID());
   }
-  if (!theFirstL.FindAttribute(XCAFDoc::DimensionRefGUID(), aFGNode) ) {
-    aFGNode = new XCAFDoc_GraphNode;
-    aFGNode = XCAFDoc_GraphNode::Set(theFirstL);
+  for(Standard_Integer i = theFirstL.Lower(); i <= theFirstL.Upper(); i++)
+  {
+    if (!theFirstL.Value(i).FindAttribute(XCAFDoc::DimensionRefFirstGUID(), aFGNode) ) {
+      aFGNode = new XCAFDoc_GraphNode;
+      aFGNode = XCAFDoc_GraphNode::Set(theFirstL.Value(i));
+    }
+    aFGNode->SetGraphID(XCAFDoc::DimensionRefFirstGUID());
+    aFGNode->SetChild(aChGNode);
+    aChGNode->SetFather(aFGNode);
   }
-  aFGNode->SetGraphID(XCAFDoc::DimensionRefGUID());
-  aChGNode->SetGraphID(XCAFDoc::DimensionRefGUID());
-  aFGNode->SetChild(aChGNode);
-  aChGNode->SetFather(aFGNode);
 
-  if (!theSecondL.IsNull()){
-    if(!theSecondL.FindAttribute(XCAFDoc::DimensionRefGUID(), aSecondFGNode) ) {
+  if (!theDimTolL.FindAttribute(XCAFDoc::DimensionRefSecondGUID(), aChGNode) && theSecondL.Length() > 0) {
+    aChGNode = new XCAFDoc_GraphNode;
+    aChGNode = XCAFDoc_GraphNode::Set(theDimTolL);
+    aChGNode->SetGraphID(XCAFDoc::DimensionRefSecondGUID());
+  }
+  for(Standard_Integer i = theSecondL.Lower(); i <= theSecondL.Upper(); i++)
+  {
+    if(!theSecondL.Value(i).FindAttribute(XCAFDoc::DimensionRefSecondGUID(), aSecondFGNode) ) {
       aSecondFGNode = new XCAFDoc_GraphNode;
-      aSecondFGNode = XCAFDoc_GraphNode::Set(theSecondL);
+      aSecondFGNode = XCAFDoc_GraphNode::Set(theSecondL.Value(i));
     }
-    aSecondFGNode->SetGraphID(XCAFDoc::DimensionRefGUID());
+    aSecondFGNode->SetGraphID(XCAFDoc::DimensionRefSecondGUID());
     aSecondFGNode->SetChild(aChGNode);
     aChGNode->SetFather(aSecondFGNode);
   }
@@ -364,12 +400,60 @@ void XCAFDoc_DimTolTool::SetDimension(const TDF_Label& theFirstL,
 void XCAFDoc_DimTolTool::SetGeomTolerance(const TDF_Label& theL,
                                    const TDF_Label& theDimTolL) const
 {
-  // set reference
-  Handle(TDataStd_TreeNode) refNode, mainNode;
-  refNode = TDataStd_TreeNode::Set ( theDimTolL, XCAFDoc::GeomToleranceRefGUID() );
-  mainNode  = TDataStd_TreeNode::Set ( theL,       XCAFDoc::GeomToleranceRefGUID() );
-  refNode->Remove(); // abv: fix against bug in TreeNode::Append()
-  mainNode->Append(refNode);
+  TDF_LabelSequence aSeq;
+  aSeq.Append(theL);
+  SetGeomTolerance(aSeq, theDimTolL);
+}
+
+//=======================================================================
+//function : SetGeomTolerance
+//purpose  : 
+//=======================================================================
+
+void XCAFDoc_DimTolTool::SetGeomTolerance(const TDF_LabelSequence& theL,
+                                   const TDF_Label& theDimTolL) const
+{
+  //  // set reference
+  //  Handle(TDataStd_TreeNode) refNode, mainNode;
+  //  refNode = TDataStd_TreeNode::Set ( theDimTolL, XCAFDoc::GeomToleranceRefGUID() );
+  //  mainNode  = TDataStd_TreeNode::Set ( theL,       XCAFDoc::GeomToleranceRefGUID() );
+  //  refNode->Remove(); // abv: fix against bug in TreeNode::Append()
+  //  mainNode->Append(refNode);
+  
+  if(!IsGeomTolerance(theDimTolL) ||  theL.Length() == 0)
+  {
+    return;
+  }
+
+  Handle(XCAFDoc_GraphNode) aChGNode;
+  Handle(XCAFDoc_GraphNode) aFGNode;
+
+  //Handle(XCAFDoc_GraphNode) ChGNode, FGNode;
+  if ( theDimTolL.FindAttribute (XCAFDoc::GeomToleranceRefGUID(), aChGNode) ) {
+    while (aChGNode->NbFathers() > 0) {
+      aFGNode = aChGNode->GetFather(1);
+      aFGNode->UnSetChild(aChGNode);
+      if(aFGNode->NbChildren() == 0)
+        aFGNode->ForgetAttribute( XCAFDoc::GeomToleranceRefGUID() );
+    }
+    theDimTolL.ForgetAttribute ( XCAFDoc::GeomToleranceRefGUID() );
+  }
+
+  if (!theDimTolL.FindAttribute(XCAFDoc::GeomToleranceRefGUID(), aChGNode)) {
+    aChGNode = new XCAFDoc_GraphNode;
+    aChGNode = XCAFDoc_GraphNode::Set(theDimTolL);
+    aChGNode->SetGraphID(XCAFDoc::GeomToleranceRefGUID());
+  }
+  for(Standard_Integer i = theL.Lower(); i <= theL.Upper(); i++)
+  {
+    if (!theL.Value(i).FindAttribute(XCAFDoc::GeomToleranceRefGUID(), aFGNode) ) {
+      aFGNode = new XCAFDoc_GraphNode;
+      aFGNode = XCAFDoc_GraphNode::Set(theL.Value(i));
+    }
+    aFGNode->SetGraphID(XCAFDoc::GeomToleranceRefGUID());
+    aFGNode->SetChild(aChGNode);
+    aChGNode->SetFather(aFGNode);
+  }
 }
 
 //=======================================================================
@@ -412,26 +496,43 @@ TDF_Label XCAFDoc_DimTolTool::SetDimTol(const TDF_Label& L,
 //=======================================================================
 
 Standard_Boolean XCAFDoc_DimTolTool::GetRefShapeLabel(const TDF_Label& theL,
-                                                      TDF_LabelSequence& theShapeL) const
+                                                      TDF_LabelSequence& theShapeLFirst,
+                                                      TDF_LabelSequence& theShapeLSecond) const
 {
-  theShapeL.Clear();
+  theShapeLFirst.Clear();
+  theShapeLSecond.Clear();
   Handle(TDataStd_TreeNode) aNode;
   if( !theL.FindAttribute(XCAFDoc::DimTolRefGUID(),aNode) || !aNode->HasFather() ) {
     if( !theL.FindAttribute(XCAFDoc::DatumRefGUID(),aNode) || !aNode->HasFather() ) {
-      if( !theL.FindAttribute(XCAFDoc::GeomToleranceRefGUID(),aNode) || !aNode->HasFather() ) {
-        Handle(XCAFDoc_GraphNode) aGNode;
-        if( theL.FindAttribute(XCAFDoc::DimensionRefGUID(),aGNode) && aGNode->NbFathers() > 0 ) {
+      Handle(XCAFDoc_GraphNode) aGNode;
+      if( theL.FindAttribute(XCAFDoc::GeomToleranceRefGUID(),aGNode) && aGNode->NbFathers() > 0 ) {
+        for(Standard_Integer i = 1; i <= aGNode->NbFathers(); i++)
+        {
+          theShapeLFirst.Append(aGNode->GetFather(i)->Label());
+        }
+        return Standard_True;
+      }
+      else if( theL.FindAttribute(XCAFDoc::DimensionRefFirstGUID(),aGNode) && aGNode->NbFathers() > 0 ) {
+        for(Standard_Integer i = 1; i <= aGNode->NbFathers(); i++)
+        {
+          theShapeLFirst.Append(aGNode->GetFather(i)->Label());
+        }
+        if( theL.FindAttribute(XCAFDoc::DimensionRefSecondGUID(),aGNode) && aGNode->NbFathers() > 0 ) {
           for(Standard_Integer i = 1; i <= aGNode->NbFathers(); i++)
           {
-            theShapeL.Append(aGNode->GetFather(i)->Label());
+            theShapeLSecond.Append(aGNode->GetFather(i)->Label());
           }
-          return Standard_True;
         }
+        return Standard_True;
+      }
+      else
+      {
         return Standard_False;
       }
     }
   }
-  theShapeL.Append(aNode->Father()->Label());
+
+  theShapeLFirst.Append(aNode->Father()->Label());
   return Standard_True;
 }
 
@@ -444,14 +545,22 @@ Standard_Boolean XCAFDoc_DimTolTool::GetRefDimensionLabels(const TDF_Label& theS
                                                      TDF_LabelSequence& theDimTols) const
 {
   Handle(XCAFDoc_GraphNode) aGNode;
-  if( theShapeL.FindAttribute(XCAFDoc::DimensionRefGUID(),aGNode) && aGNode->NbChildren() > 0 ) {
+  Standard_Boolean aResult = Standard_False;
+  if( theShapeL.FindAttribute(XCAFDoc::DimensionRefFirstGUID(),aGNode) && aGNode->NbChildren() > 0 ) {
     for(Standard_Integer i = 1; i <= aGNode->NbChildren(); i++)
     {
       theDimTols.Append(aGNode->GetChild(i)->Label());
     }
-    return Standard_True;
+    aResult = Standard_True;
   }
-  return Standard_False;
+  if( theShapeL.FindAttribute(XCAFDoc::DimensionRefSecondGUID(),aGNode) && aGNode->NbChildren() > 0 ) {
+    for(Standard_Integer i = 1; i <= aGNode->NbChildren(); i++)
+    {
+      theDimTols.Append(aGNode->GetChild(i)->Label());
+    }
+    aResult = Standard_True;
+  }
+  return aResult;
 }
 
 //=======================================================================
@@ -462,16 +571,14 @@ Standard_Boolean XCAFDoc_DimTolTool::GetRefDimensionLabels(const TDF_Label& theS
 Standard_Boolean XCAFDoc_DimTolTool::GetRefGeomToleranceLabels(const TDF_Label& theShapeL,
                                                      TDF_LabelSequence& theDimTols) const
 {
-  Handle(TDataStd_TreeNode) aNode;
-  if( !theShapeL.FindAttribute(XCAFDoc::GeomToleranceRefGUID(),aNode) ||
-       !aNode->HasFirst() ) {
+  Handle(XCAFDoc_GraphNode) aGNode;
+  if( !theShapeL.FindAttribute(XCAFDoc::GeomToleranceRefGUID(),aGNode) ||
+    aGNode->NbChildren() == 0 ) {
     return Standard_False;
   }
-  Handle(TDataStd_TreeNode) aLast = aNode->First();
-  theDimTols.Append(aLast->Label());
-  while(aLast->HasNext()) {
-    aLast = aLast->Next();
-    theDimTols.Append(aLast->Label());
+  for(Standard_Integer i = 1; i <= aGNode->NbChildren(); i++)
+  {
+    theDimTols.Append(aGNode->GetChild(i)->Label());
   }
   return Standard_True;
 }
@@ -482,15 +589,20 @@ Standard_Boolean XCAFDoc_DimTolTool::GetRefGeomToleranceLabels(const TDF_Label&
 //=======================================================================
 
 Standard_Boolean XCAFDoc_DimTolTool::GetRefDatumLabel(const TDF_Label& theShapeL,
-                                                     TDF_Label& theDatum) const
+                                                     TDF_LabelSequence& theDatum) const
 {
   Handle(TDataStd_TreeNode) aNode;
   if( !theShapeL.FindAttribute(XCAFDoc::DatumRefGUID(),aNode) ||
        !aNode->HasFirst() ) {
     return Standard_False;
   }
-  Handle(TDataStd_TreeNode) aLast = aNode->First();
-  theDatum = aLast->Label();
+  Handle(TDataStd_TreeNode) aFirst = aNode->First();
+  theDatum.Append(aFirst->Label());
+  for(Standard_Integer i = 1; i < aNode->NbChildren(); i++)
+  {
+    aFirst = aFirst->Next();
+    theDatum.Append(aFirst->Label());
+  }
   return Standard_True;
 }
 
index 29abd82..53a75f0 100644 (file)
@@ -69,6 +69,9 @@ public:
   Standard_EXPORT void GetDimensionLabels (TDF_LabelSequence& theLabels) const;
   
   //! Sets a link with GUID
+  Standard_EXPORT void SetDimension (const TDF_LabelSequence& theFirstLS, const TDF_LabelSequence& theSecondLS, const TDF_Label& theDimTolL) const;
+
+  //! Sets a link with GUID
   Standard_EXPORT void SetDimension (const TDF_Label& theFirstL, const TDF_Label& theSecondL, const TDF_Label& theDimTolL) const;
   
   //! Sets a link with GUID
@@ -90,6 +93,9 @@ public:
   
   //! Sets a link with GUID
   Standard_EXPORT void SetGeomTolerance (const TDF_Label& theL, const TDF_Label& theDimTolL) const;
+
+  //! Sets a link with GUID
+  Standard_EXPORT void SetGeomTolerance (const TDF_LabelSequence& theL, const TDF_Label& theDimTolL) const;
   
   //! Returns all GeomTolerance labels defined for label ShapeL
   Standard_EXPORT Standard_Boolean GetRefGeomToleranceLabels (const TDF_Label& theShapeL, TDF_LabelSequence& theDimTols) const;
@@ -126,7 +132,7 @@ public:
   
   //! Returns ShapeL defined for label DimTolL
   //! Returns False if the DimTolL is not in DGTtable
-  Standard_EXPORT Standard_Boolean GetRefShapeLabel (const TDF_Label& DimTolL, TDF_LabelSequence& ShapeL) const;
+  Standard_EXPORT Standard_Boolean GetRefShapeLabel (const TDF_Label& DimTolL, TDF_LabelSequence& ShapeLFirst, TDF_LabelSequence& ShapeLSecond) const;
   
   //! Returns all DimTol labels defined for label ShapeL
   Standard_EXPORT Standard_Boolean GetRefDGTLabels (const TDF_Label& ShapeL, TDF_LabelSequence& DimTols) const;
@@ -175,7 +181,7 @@ public:
   Standard_EXPORT   Standard_Boolean GetTolerOfDatumLabels (const TDF_Label& theDatumL, TDF_LabelSequence& theTols)  const;
 
   //! Returns Datum label defined for label ShapeL
-  Standard_EXPORT   Standard_Boolean GetRefDatumLabel (const TDF_Label& theShapeL, TDF_Label& theDatum)  const;
+  Standard_EXPORT   Standard_Boolean GetRefDatumLabel (const TDF_Label& theShapeL, TDF_LabelSequence& theDatum)  const;
   
   Standard_EXPORT const Standard_GUID& ID() const;
   
index bd5268d..d9a7222 100644 (file)
@@ -14,6 +14,7 @@
 #include <XCAFDoc_Dimension.hxx>
 
 #include <TDF_RelocationTable.hxx>
+#include <TDF_ChildIterator.hxx>
 #include <XCAFDoc.hxx>
 #include <TDataStd_TreeNode.hxx>
 #include <Precision.hxx>
@@ -86,78 +87,59 @@ void XCAFDoc_Dimension::SetObject (const Handle(XCAFDimTolObjects_DimensionObjec
 {
   Backup();
 
-  Handle(TDataStd_Integer) aType;
-  if(!Label().FindChild(ChildLab_Type).FindAttribute(TDataStd_Integer::GetID(), aType))
+  //Label().ForForgetAllAttributes();
+  TDF_ChildIterator anIter(Label());
+  for(;anIter.More(); anIter.Next())
   {
-    aType = new TDataStd_Integer();
-    Label().FindChild(ChildLab_Type).AddAttribute(aType);
+    anIter.Value().ForgetAllAttributes();
   }
+  Handle(TDataStd_Integer) aType = new TDataStd_Integer();
+  Label().FindChild(ChildLab_Type).AddAttribute(aType);
   aType->Set(theObject->GetType());
 
-  if(theObject->GetValues().IsNull())
-  {
-    Label().FindChild(ChildLab_Value).ForgetAllAttributes();
-  }
-  else
+  if(!theObject->GetValues().IsNull())
   {
-    Handle(TDataStd_RealArray) aVal;
-    if(!Label().FindChild(ChildLab_Value).FindAttribute(TDataStd_RealArray::GetID(), aVal))
-    {
-      aVal = new TDataStd_RealArray();
-      Label().FindChild(ChildLab_Value).AddAttribute(aVal);
-    }
+    Handle(TDataStd_RealArray) aVal = new TDataStd_RealArray();
+    Label().FindChild(ChildLab_Value).AddAttribute(aVal);
     aVal->ChangeArray(theObject->GetValues());
   }
 
-  Handle(TDataStd_Integer) aQualifier;
-  if(!Label().FindChild(ChildLab_Qualifier).FindAttribute(TDataStd_Integer::GetID(), aQualifier))
-  {
-    aQualifier = new TDataStd_Integer();
-    Label().FindChild(ChildLab_Qualifier).AddAttribute(aQualifier);
-  }
+  Handle(TDataStd_Integer) aQualifier = new TDataStd_Integer();
+  Label().FindChild(ChildLab_Qualifier).AddAttribute(aQualifier);
   aQualifier->Set(theObject->GetQualifier());
  
   Standard_Boolean aH;
   XCAFDimTolObjects_DimensionFormVariance aF;
   XCAFDimTolObjects_DimensionGrade aG;
   theObject->GetClassOfTolerance(aH,aF,aG);
-  Handle(TDataStd_IntegerArray) aClass;
-  if(!Label().FindChild(ChildLab_Class).FindAttribute(TDataStd_IntegerArray::GetID(), aClass))
+  Handle(TColStd_HArray1OfInteger) anArrI;
+  if(aF != XCAFDimTolObjects_DimensionFormVariance_None)
   {
-    aClass = new TDataStd_IntegerArray();
+    Handle(TDataStd_IntegerArray) aClass = new TDataStd_IntegerArray();
     Label().FindChild(ChildLab_Class).AddAttribute(aClass);
+    anArrI = new TColStd_HArray1OfInteger(1,3);
+    anArrI->SetValue(1,aH);
+    anArrI->SetValue(2,aF);
+    anArrI->SetValue(3,aG);
+    aClass->ChangeArray(anArrI);
   }
-  Handle(TColStd_HArray1OfInteger) anArrI = new TColStd_HArray1OfInteger(1,3);
-  anArrI->SetValue(1,aH);
-  anArrI->SetValue(2,aF);
-  anArrI->SetValue(3,aG);
-  aClass->ChangeArray(anArrI);
 
   Standard_Integer aL, aR;
   theObject->GetNbOfDecimalPlaces(aL, aR);
-  Handle(TDataStd_IntegerArray) aDec;
-  if(!Label().FindChild(ChildLab_Dec).FindAttribute(TDataStd_IntegerArray::GetID(), aDec))
+  if (aL > 0 || aR > 0)
   {
-    aDec = new TDataStd_IntegerArray();
+    Handle(TDataStd_IntegerArray) aDec = new TDataStd_IntegerArray();
     Label().FindChild(ChildLab_Dec).AddAttribute(aDec);
+    anArrI = new TColStd_HArray1OfInteger(1,2);
+    anArrI->SetValue(1,aL);
+    anArrI->SetValue(2,aR);
+    aDec->ChangeArray(anArrI);
   }
-  anArrI = new TColStd_HArray1OfInteger(1,2);
-  anArrI->SetValue(1,aL);
-  anArrI->SetValue(2,aR);
-  aDec->ChangeArray(anArrI);
-  if(theObject->GetModifiers().Length() == 0)
-  {
-    Label().FindChild(ChildLab_Modifiers).ForgetAllAttributes();
-  }
-  else
+
+  if(theObject->GetModifiers().Length() > 0)
   {
-    Handle(TDataStd_IntegerArray) aModifiers;
-    if(!Label().FindChild(ChildLab_Modifiers).FindAttribute(TDataStd_IntegerArray::GetID(), aModifiers))
-    {
-      aModifiers = new TDataStd_IntegerArray();
-      Label().FindChild(ChildLab_Modifiers).AddAttribute(aModifiers);
-    }
+    Handle(TDataStd_IntegerArray) aModifiers = new TDataStd_IntegerArray();
+    Label().FindChild(ChildLab_Modifiers).AddAttribute(aModifiers);
     anArrI = new TColStd_HArray1OfInteger(1,theObject->GetModifiers().Length());
     for(Standard_Integer i = 1; i <= theObject->GetModifiers().Length(); i++)
       anArrI->SetValue(i,theObject->GetModifiers().Value(i));
@@ -166,44 +148,37 @@ void XCAFDoc_Dimension::SetObject (const Handle(XCAFDimTolObjects_DimensionObjec
 
   if(!theObject->GetPath().IsNull())
   {
-  TNaming_Builder tnBuild(Label().FindChild(ChildLab_Path));
-  tnBuild.Generated(theObject->GetPath());
-  }
-  else
-  {
-    Label().FindChild(ChildLab_Path).ForgetAllAttributes();
+    TNaming_Builder tnBuild(Label().FindChild(ChildLab_Path));
+    tnBuild.Generated(theObject->GetPath());
   }
 
-  Handle(TDataStd_RealArray) aDir;
-  if(!Label().FindChild(ChildLab_Dir).FindAttribute(TDataStd_RealArray::GetID(), aDir))
+  Handle(TColStd_HArray1OfReal) anArrR;
+  if(theObject->GetType() == XCAFDimTolObjects_DimensionType_Location_Oriented)
   {
-    aDir = new TDataStd_RealArray();
+    gp_Dir aD;
+    theObject->GetDirection(aD);
+    Handle(TDataStd_RealArray) aDir = new TDataStd_RealArray();
     Label().FindChild(ChildLab_Dir).AddAttribute(aDir);
+    anArrR = new TColStd_HArray1OfReal(1,3);
+    anArrR->SetValue(1,aD.X());
+    anArrR->SetValue(2,aD.Y());
+    anArrR->SetValue(3,aD.Z());
+    aDir->ChangeArray(anArrR);
   }
-  gp_Dir aD;
-  theObject->GetDirection(aD);
-  Handle(TColStd_HArray1OfReal) anArrR = new TColStd_HArray1OfReal(1,3);
-  anArrR->SetValue(1,aD.X());
-  anArrR->SetValue(2,aD.Y());
-  anArrR->SetValue(3,aD.Z());
-  aDir->ChangeArray(anArrR);
 
-  Handle(TDataStd_RealArray) aPnts;
-  if(!Label().FindChild(ChildLab_Pnts).FindAttribute(TDataStd_RealArray::GetID(), aPnts))
-  {
-    aPnts = new TDataStd_RealArray();
-    Label().FindChild(ChildLab_Pnts).AddAttribute(aPnts);
-  }
   Handle(TColgp_HArray1OfPnt) aP = theObject->GetPoints();
   if(!aP.IsNull() && aP->Length() > 0)
   {
     anArrR = new TColStd_HArray1OfReal(1,6);
+    Handle(TDataStd_RealArray) aPnts;
     anArrR->SetValue(1,aP->Value(1).X());
     anArrR->SetValue(2,aP->Value(1).Y());
     anArrR->SetValue(3,aP->Value(1).Z());
     anArrR->SetValue(4,aP->Value(2).X());
     anArrR->SetValue(5,aP->Value(2).Y());
     anArrR->SetValue(6,aP->Value(2).Z());
+    aPnts = new TDataStd_RealArray();
+    Label().FindChild(ChildLab_Pnts).AddAttribute(aPnts);
     aPnts->ChangeArray(anArrR);
   }
 }
index 1d9b4fe..99a423d 100644 (file)
 #include <XCAFDoc_GeomTolerance.hxx>
 
 #include <TDF_RelocationTable.hxx>
+#include <TDF_ChildIterator.hxx>
 #include <XCAFDoc.hxx>
 #include <TDataStd_TreeNode.hxx>
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_IntegerArray.hxx>
+#include <TDataStd_RealArray.hxx>
 #include <TDataStd_Real.hxx>
 #include <XCAFDimTolObjects_GeomToleranceObject.hxx>
 
@@ -30,7 +32,10 @@ enum ChildLab
   ChildLab_ZoneModif,
   ChildLab_ValueOfZoneModif,
   ChildLab_Modifiers,
-  ChildLab_aMaxValueModif
+  ChildLab_aMaxValueModif,
+  ChildLab_AxisLoc,
+  ChildLab_AxisN,
+  ChildLab_AxisRef
 };
 
 //=======================================================================
@@ -80,80 +85,90 @@ void XCAFDoc_GeomTolerance::SetObject (const Handle(XCAFDimTolObjects_GeomTolera
 {
   Backup();
 
-  Handle(TDataStd_Integer) aType;
-  if(!Label().FindChild(ChildLab_Type).FindAttribute(TDataStd_Integer::GetID(), aType))
+  //Label().ForForgetAllAttributes();
+  TDF_ChildIterator anIter(Label());
+  for(;anIter.More(); anIter.Next())
   {
-    aType = new TDataStd_Integer();
-    Label().FindChild(ChildLab_Type).AddAttribute(aType);
+    anIter.Value().ForgetAllAttributes();
   }
+
+  Handle(TDataStd_Integer) aType = new TDataStd_Integer();
   aType->Set(theObject->GetType());
+  Label().FindChild(ChildLab_Type).AddAttribute(aType);
 
-  Handle(TDataStd_Integer) aTypeOfValue;
-  if(!Label().FindChild(ChildLab_TypeOfValue).FindAttribute(TDataStd_Integer::GetID(), aTypeOfValue))
+  if(theObject->GetTypeOfValue() != XCAFDimTolObjects_GeomToleranceTypeValue_None)
   {
-    aTypeOfValue = new TDataStd_Integer();
+    Handle(TDataStd_Integer) aTypeOfValue = new TDataStd_Integer();
+    aTypeOfValue->Set(theObject->GetTypeOfValue());
     Label().FindChild(ChildLab_TypeOfValue).AddAttribute(aTypeOfValue);
   }
-  aTypeOfValue->Set(theObject->GetTypeOfValue());
 
-  Handle(TDataStd_Real) aValue;
-  if(!Label().FindChild(ChildLab_Value).FindAttribute(TDataStd_Real::GetID(), aValue))
-  {
-    aValue = new TDataStd_Real();
-    Label().FindChild(ChildLab_Value).AddAttribute(aValue);
-  }
+  Handle(TDataStd_Real) aValue = new TDataStd_Real();
   aValue->Set(theObject->GetValue());
+  Label().FindChild(ChildLab_Value).AddAttribute(aValue);
 
   Handle(TDataStd_Integer) aMatReqModif;
-  if(!Label().FindChild(ChildLab_MatReqModif).FindAttribute(TDataStd_Integer::GetID(), aMatReqModif))
+  if(theObject->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None)
   {
+    Label().FindChild(ChildLab_MatReqModif).FindAttribute(TDataStd_Integer::GetID(), aMatReqModif);
     aMatReqModif = new TDataStd_Integer();
     Label().FindChild(ChildLab_MatReqModif).AddAttribute(aMatReqModif);
+    aMatReqModif->Set(theObject->GetMaterialRequirementModifier());
   }
-  aMatReqModif->Set(theObject->GetMaterialRequirementModifier());
 
-  Handle(TDataStd_Integer) aZoneModif;
-  if(!Label().FindChild(ChildLab_ZoneModif).FindAttribute(TDataStd_Integer::GetID(), aZoneModif))
+  if(theObject->GetZoneModifier() != XCAFDimTolObjects_GeomToleranceZoneModif_None)
   {
-    aZoneModif = new TDataStd_Integer();
+    Handle(TDataStd_Integer) aZoneModif = new TDataStd_Integer();
+    aZoneModif->Set(theObject->GetZoneModifier());
     Label().FindChild(ChildLab_ZoneModif).AddAttribute(aZoneModif);
   }
-  aZoneModif->Set(theObject->GetZoneModifier());
-
-  Handle(TDataStd_Real) aValueOfZoneModif;
-  if(!Label().FindChild(ChildLab_ValueOfZoneModif).FindAttribute(TDataStd_Real::GetID(), aValueOfZoneModif))
+  
+  if(theObject->GetValueOfZoneModifier() > 0)
   {
-    aValueOfZoneModif = new TDataStd_Real();
+    Handle(TDataStd_Real) aValueOfZoneModif = new TDataStd_Real();
+    aValueOfZoneModif->Set(theObject->GetValueOfZoneModifier());
     Label().FindChild(ChildLab_ValueOfZoneModif).AddAttribute(aValueOfZoneModif);
   }
-  aValueOfZoneModif->Set(theObject->GetValueOfZoneModifier());
 
-  if(theObject->GetModifiers().Length() == 0)
+  if(theObject->GetModifiers().Length() > 0)
   {
-    Label().FindChild(ChildLab_Modifiers).ForgetAllAttributes();
-  }
-  else
-  {
-    Handle(TDataStd_IntegerArray) aModifiers;
-    if(!Label().FindChild(ChildLab_Modifiers).FindAttribute(TDataStd_IntegerArray::GetID(), aModifiers)
-      || theObject->GetModifiers().Length() == 0)
-    {
-      aModifiers = new TDataStd_IntegerArray();
-      Label().FindChild(ChildLab_Modifiers).AddAttribute(aModifiers);
-    }
+    Handle(TDataStd_IntegerArray) aModifiers = new TDataStd_IntegerArray();
     Handle(TColStd_HArray1OfInteger) anArr = new TColStd_HArray1OfInteger(1,theObject->GetModifiers().Length());
     for(Standard_Integer i = 1; i <= theObject->GetModifiers().Length(); i++)
       anArr->SetValue(i,theObject->GetModifiers().Value(i));
     aModifiers->ChangeArray(anArr);
+    Label().FindChild(ChildLab_Modifiers).AddAttribute(aModifiers);
   }
 
-  Handle(TDataStd_Real) aMaxValueModif;
-  if(!Label().FindChild(ChildLab_aMaxValueModif).FindAttribute(TDataStd_Real::GetID(), aMaxValueModif))
+  if(theObject->GetMaxValueModifier() > 0)
   {
-    aMaxValueModif = new TDataStd_Real();
+    Handle(TDataStd_Real) aMaxValueModif = new TDataStd_Real();
+    aMaxValueModif->Set(theObject->GetMaxValueModifier());
     Label().FindChild(ChildLab_aMaxValueModif).AddAttribute(aMaxValueModif);
   }
-  aMaxValueModif->Set(theObject->GetMaxValueModifier());
+
+  if(theObject->HasAxis())
+  {
+    Handle(TDataStd_RealArray) aLoc = new TDataStd_RealArray();
+    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());
+
+    aR->SetValue(aR->Upper(),anAx.Direction().X());
+    aR->SetValue(aR->Upper(),anAx.Direction().X());
+    aR->SetValue(aR->Upper(),anAx.Direction().X());
+
+    Label().FindChild(ChildLab_AxisLoc).AddAttribute(aLoc);
+    Label().FindChild(ChildLab_AxisN).AddAttribute(aN);
+    Label().FindChild(ChildLab_AxisRef).AddAttribute(aR);
+  }
 }
 
 //=======================================================================
@@ -216,7 +231,20 @@ Handle(XCAFDimTolObjects_GeomToleranceObject) XCAFDoc_GeomTolerance::GetObject()
   {
     anObj->SetMaxValueModifier(aMaxValueModif->Get());
   }
-
+  
+  Handle(TDataStd_RealArray) aLoc;
+  Handle(TDataStd_RealArray) aN;
+  Handle(TDataStd_RealArray) aR;
+  if(Label().FindChild(ChildLab_AxisLoc).FindAttribute(TDataStd_RealArray::GetID(), aLoc) && aLoc->Length() == 3 &&
+    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_Ax2 anAx(aL, aD, aDR);
+    anObj->SetAxis(anAx);
+  }
   return anObj;
 }
 
index 092fc1b..46d8ed7 100644 (file)
@@ -595,7 +595,6 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer
     else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorSurf) ) type = "Surface Color Link";
     else if ( att->ID() == XCAFDoc::ColorRefGUID(XCAFDoc_ColorCurv) ) type = "Curve Color Link";
     else if ( att->ID() == XCAFDoc::DimTolRefGUID() ) type = "DGT Link";
-    else if ( att->ID() == XCAFDoc::GeomToleranceRefGUID() ) type = "GeomTolerance Link";
     else if ( att->ID() == XCAFDoc::DatumRefGUID() ) type = "Datum Link";
     else if ( att->ID() == XCAFDoc::MaterialRefGUID() ) type = "Material Link";
     Handle(TDataStd_TreeNode) TN = Handle(TDataStd_TreeNode)::DownCast(att);
@@ -763,8 +762,14 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer
     else if ( att->ID() == XCAFDoc::DatumTolRefGUID() ) {
       type = "DatumToler Link";
     }
-    else if ( att->ID() == XCAFDoc::DimensionRefGUID() ) {
-      type = "Dimension Link";
+    else if ( att->ID() == XCAFDoc::DimensionRefFirstGUID() ) {
+      type = "Dimension Link First";
+    }
+    else if ( att->ID() == XCAFDoc::DimensionRefSecondGUID() ) {
+      type = "Dimension Link Second";
+    }
+    else if ( att->ID() == XCAFDoc::GeomToleranceRefGUID() ){
+      type = "GeomTolerance Link";
     }
     else return 0;
 
index 4f7c455..2c13b0b 100644 (file)
@@ -123,7 +123,7 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
         {
           TCollection_AsciiString Entry;
           TDF_Tool::Entry(aLabels.Value(i), Entry);
-          di << "\n " << Entry;
+          di << "\n " << Entry << " Shape" << "."<< i;
           flag = Standard_False;
         }
         TCollection_AsciiString Entry;
@@ -131,7 +131,54 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
         di << "\n \t " << Entry;
         flag = Standard_False;
 
-        di << " Dimension";
+        di << " Dimension" << "."<< i << "."<< j;
+        if (argc > 3)
+        {
+          di <<" (";
+          di << " T " << aDimTolObj->GetType();
+          if(aDimTolObj->IsDimWithRange())
+          {
+            di << ", LB " << aDimTolObj->GetLowerBound();
+            di << ", UB " << aDimTolObj->GetUpperBound();
+          }
+          else
+          {
+            di << ", V " << aDimTolObj->GetValue();
+            if (aDimTolObj->IsDimWithPlusMinusTolerance())
+            {
+              di << ", VL " << aDimTolObj->GetLowerTolValue();
+              di << ", VU " << aDimTolObj->GetUpperTolValue();
+            }
+            else if (aDimTolObj->IsDimWithClassOfTolerance())
+            {
+              Standard_Boolean isH;
+              XCAFDimTolObjects_DimensionFormVariance aFV;
+              XCAFDimTolObjects_DimensionGrade aG;
+              aDimTolObj->GetClassOfTolerance(isH, aFV, aG);
+              di << ", H " << (Standard_Integer)isH<< " F " << aFV << " G " << aG;
+            }
+          }
+          if (aDimTolObj->HasQualifier())
+            di << ", Q " << aDimTolObj->GetQualifier();
+          if (aDimTolObj->GetType() == XCAFDimTolObjects_DimensionType_Location_Oriented)
+          {
+            gp_Dir aD;
+            aDimTolObj->GetDirection(aD);
+            di << ", D (" << aD.X() << ", " << aD.Y() << ", " << aD.Z() << ")";
+          }
+          XCAFDimTolObjects_DimensionModifiersSequence aModif = 
+            aDimTolObj->GetModifiers();
+          if (!aModif.IsEmpty())
+          {
+            di << ",";
+            for (Standard_Integer k = aModif.Lower(); k <= aModif.Upper(); k++)
+            {
+              di << " M " << aModif.Value(k);
+            }
+          }
+          di << ", P " << (Standard_Integer)!aDimTolObj->GetPath().IsNull();
+          di << " )";
+        }
       }
     }
     aGDTs.Clear();
@@ -146,7 +193,7 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
         {
           TCollection_AsciiString Entry;
           TDF_Tool::Entry(aLabels.Value(i), Entry);
-          di << "\n " << Entry;
+          di << "\n " << Entry << " Shape" << "."<< i;
           flag = Standard_False;
         }
         TCollection_AsciiString Entry;
@@ -154,7 +201,50 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
         di << "\n \t " << Entry;
         flag = Standard_False;
 
-        di << " GeomTolerance";
+        di << " GeomTolerance" << "."<< i << "."<< j;
+        if (argc > 3)
+        {
+          di <<" (";
+          di << " T " << aDimTolObj->GetType();
+          di << " TV " << aDimTolObj->GetTypeOfValue();
+          di << ", V " << aDimTolObj->GetValue();
+
+          if (aDimTolObj->HasAxis())
+          {
+            gp_Ax2 anAx = aDimTolObj->GetAxis();
+            di << ", A ( L (" << anAx.Location().X() << anAx.Location().Y() << anAx.Location().Z()
+              << "), XD (" << anAx.XDirection().X() << anAx.XDirection().Y() << anAx.XDirection().Z()
+              << "), RD (" << anAx.YDirection().X() << anAx.YDirection().Y() << anAx.YDirection().Z() << "))";
+          }
+          XCAFDimTolObjects_GeomToleranceModifiersSequence aModif = 
+            aDimTolObj->GetModifiers();
+          if (!aModif.IsEmpty())
+          {
+            di << ",";
+            for (Standard_Integer k = aModif.Lower(); k <= aModif.Upper(); k++)
+            {
+              di << " M " << aModif.Value(k);
+            }
+          }
+          if (aDimTolObj->GetMaterialRequirementModifier() != XCAFDimTolObjects_GeomToleranceMatReqModif_None)
+          {
+            di << ", MR " << aDimTolObj->GetMaterialRequirementModifier();
+          }
+          if (aDimTolObj->GetMaxValueModifier() > 0)
+          {
+            di << "MaxV " << aDimTolObj->GetMaxValueModifier();
+          }
+          if ( aDimTolObj->GetZoneModifier() != XCAFDimTolObjects_GeomToleranceZoneModif_None)
+          {
+            di << ", ZM " << aDimTolObj->GetZoneModifier();
+            if (aDimTolObj->GetValueOfZoneModifier() > 0)
+            {
+              di << " ZMV " <<aDimTolObj->GetValueOfZoneModifier();
+            }
+          }
+
+          di << " )";
+        }
         Handle(XCAFDoc_GraphNode) aNode;
         if(aGDTs.Value(j).FindAttribute(XCAFDoc::DatumTolRefGUID(), aNode) && aNode->NbChildren() > 0)
         {
@@ -163,37 +253,150 @@ static Standard_Integer DumpDGTs (Draw_Interpretor& di, Standard_Integer argc, c
             Handle(XCAFDoc_Datum) aDatum;
             if(aNode->GetChild(k)->Label().FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
             {
+              Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatum->GetObject();
               TCollection_AsciiString anEntry;
               TDF_Tool::Entry(aNode->GetChild(k)->Label(), anEntry);
               di << "\n \t \t " << anEntry;
-              di << " Datum";
+              di << " Datum" << "."<< i << "."<< j << "."<< k;
+              if (argc > 3)
+              {
+                di <<" (";
+                XCAFDimTolObjects_DatumModifiersSequence aModif = 
+                  aDatumObj->GetModifiers();
+                if (!aModif.IsEmpty())
+                {
+                  di << ",";
+                  for (Standard_Integer k = aModif.Lower(); k <= aModif.Upper(); k++)
+                  {
+                    di << " M " << aModif.Value(k);
+                  }
+                }
+                XCAFDimTolObjects_DatumModifWithValue aM;
+                Standard_Real aV;
+                aDatumObj->GetModifierWithValue(aM, aV);
+                if (aM != XCAFDimTolObjects_DatumModifWithValue_None)
+                {
+                  di << ", MV" << aM << " " << aV; 
+                }
+                di << " )";
+              }
             }
           }
         }
       }
     }
-    TDF_Label aDatumL;
+    TDF_LabelSequence aDatumL;
     if (aDimTolTool->GetRefDatumLabel(aLabels.Value(i), aDatumL))
     {
-      Handle(XCAFDoc_Datum) aDatum;
-      if(aDatumL.FindAttribute(XCAFDoc_Datum::GetID(), aDatum))
+      for(Standard_Integer j = aDatumL.Lower(); j <= aDatumL.Upper(); j++)
       {
-        if(flag)
+        Handle(XCAFDoc_Datum) aDatum;
+        if(aDatumL.Value(j).FindAttribute(XCAFDoc_Datum::GetID(), aDatum) && 
+           aDatum->GetObject()->IsDatumTarget())
         {
+          Handle(XCAFDimTolObjects_DatumObject) aDatumObj = aDatum->GetObject();
+          if(flag)
+          {
+            TCollection_AsciiString Entry;
+            TDF_Tool::Entry(aLabels.Value(i), Entry);
+            di << "\n " << Entry << " Shape" << "."<< i;
+            flag = Standard_False;
+          }
           TCollection_AsciiString Entry;
-          TDF_Tool::Entry(aLabels.Value(i), Entry);
-          di << "\n " << Entry;
+          TDF_Tool::Entry(aDatumL.First(), Entry);
+          di << "\n \t " << Entry;
           flag = Standard_False;
+
+          di << " Datum target" << "."<< i << "."<< j;
+          if (argc > 3)
+          {
+            di <<" (";
+            di << " T " << aDatumObj->GetDatumTargetType();
+            if (aDatumObj->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Area)
+            {
+              gp_Ax2 anAx = aDatumObj->GetDatumTargetAxis();
+               di << ", A ( L (" << anAx.Location().X() << anAx.Location().Y() << anAx.Location().Z()
+                << "), XD (" << anAx.XDirection().X() << anAx.XDirection().Y() << anAx.XDirection().Z()
+                << "), RD (" << anAx.YDirection().X() << anAx.YDirection().Y() << anAx.YDirection().Z() << "))";
+              if (aDatumObj->GetDatumTargetType() != XCAFDimTolObjects_DatumTargetType_Point)
+              {
+                di << ", L " << aDatumObj->GetDatumTargetLength() ;
+                if (aDatumObj->GetDatumTargetType() == XCAFDimTolObjects_DatumTargetType_Rectangle)
+                {
+                  di << ", W " << aDatumObj->GetDatumTargetWidth() ;
+                }
+              }
+            }
+            di << " )";
+          }
         }
-        TCollection_AsciiString Entry;
-        TDF_Tool::Entry(aDatumL, Entry);
-        di << "\n \t " << Entry;
-        flag = Standard_False;
+      }
+    }
+  }
+  return 0;
+}
+
+static Standard_Integer DumpNbDGTs (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+  if (argc < 2) {
+    di<<"Use: "<<"XDumpNbDGTs Doc";
+    return 1;
+  }
+  Handle(TDocStd_Document) Doc;
+  DDocStd::GetDocument(argv[1], Doc);
+  if ( Doc.IsNull() ) { di << argv[1] << " is not a document" << "\n"; return 1; }
+  Handle(XCAFDoc_DimTolTool) aDimTolTool= XCAFDoc_DocumentTool::DimTolTool(Doc->Main());
+  Handle(XCAFDoc_ShapeTool) aShapeTool= XCAFDoc_DocumentTool::ShapeTool(Doc->Main());
+
+  TDF_LabelSequence aLabels;
+  aShapeTool->GetShapes(aLabels);
+  for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
+  {
+    aShapeTool->GetSubShapes(aLabels.Value(i), aLabels);
+  }
 
-        di << " Datum";
+  TDF_LabelSequence aGDTs;
+  aDimTolTool->GetDimensionLabels(aGDTs);
+  di << "\n NbOfDimensions          : " << aGDTs.Length();
+
+  aGDTs.Clear();
+  aDimTolTool->GetGeomToleranceLabels(aGDTs);
+  di << "\n NbOfTolerances          : " << aGDTs.Length();
+
+  Standard_Integer aCounter = 0;
+  Standard_Integer aCounter1 = 0;
+   Standard_Integer aCounter2 = 0;
+
+  for ( Standard_Integer i=1; i <= aLabels.Length(); i++ )
+  {
+    Standard_Boolean isDatum = Standard_False;
+    TDF_LabelSequence aDatL;
+    if(aDimTolTool->GetRefDatumLabel(aLabels.Value(i), aDatL))
+    {
+      for(Standard_Integer j = aDatL.Lower(); j <= aDatL.Upper(); j++)
+      {
+        Handle(XCAFDoc_Datum) aDat;
+        if(aDatL.Value(j).FindAttribute(XCAFDoc_Datum::GetID(), aDat))
+        {
+          if(aDat->GetObject()->IsDatumTarget())
+          {
+            aCounter1++;
+          }
+          else
+          {
+            aCounter2++;
+            isDatum = Standard_True;
+          }
+        }
       }
+      if(isDatum)
+        aCounter++;
     }
   }
+  di << "\n NbOfDatumFeature        : " << aCounter;
+  di << "\n NbOfAttachedDatum       : " << aCounter2;
+  di << "\n NbOfDatumTarget         : " << aCounter1;
+
   return 0;
 }
 
@@ -378,25 +581,16 @@ static Standard_Integer getDatum (Draw_Interpretor& di, Standard_Integer argc, c
     return 1;
   }
 
-  TDF_Label aD;
+  TDF_LabelSequence aD;
   if(!aDimTolTool->GetRefDatumLabel(aLabel, aD))
   {
-    TDF_LabelSequence aDS;
-    if(aDimTolTool->GetDatumOfTolerLabels(aLabel, aDS))
-    {
-      for(Standard_Integer i = 1; i<=aDS.Length();i++)
-      {
-        if(i>1) di<<", ";
-        TCollection_AsciiString Entry;
-        TDF_Tool::Entry(aDS.Value(i), Entry);
-        di<<Entry;
-      }
-    }
+    aDimTolTool->GetDatumOfTolerLabels(aLabel, aD);
   }
-  else
+  for(Standard_Integer i = aD.Lower(); i <= aD.Upper(); i++)
   {
+    if(i>1) di<<", ";
     TCollection_AsciiString Entry;
-    TDF_Tool::Entry(aD, Entry);
+    TDF_Tool::Entry(aD.Value(i), Entry);
     di<<Entry;
   }
   return 0;
@@ -1890,6 +2084,9 @@ void XDEDRAW_GDTs::InitCommands(Draw_Interpretor& di)
   di.Add ("XDumpDGTs","XDumpDGTs Doc shape/label/all ",
     __FILE__, DumpDGTs, g);
 
+  di.Add ("XDumpNbDGTs","XDumpDGTs Doc",
+    __FILE__, DumpNbDGTs, g);
+
   di.Add ("XAddDimension","XAddDimension Doc shape/label [shape/label]",
     __FILE__, addDim, g);
 
index 2c8bb11..35f972c 100644 (file)
@@ -11,12 +11,12 @@ XAddShape D b
 XAddShape D b1
 XAddDimension D b_1_1  b1_1_1
 #0:1:4:1
-XSetDimensionType D  0:1:4:1 2
+XSetDimensionType D  0:1:4:1 12
 XSetDimensionValue D  0:1:4:1 6
 XSetDimensionPlusMinusTol D  0:1:4:1 -0.001 0.002
 XSetDimensionDir D  0:1:4:1 1 1 0
 
 set c_value "6"
-set c_type "Location_LinearDistance"
+set c_type "Location_Oriented"
 set c_plusminus "lower -0.001 upper 0.002"
 set c_dir "0.70710678118654757;0.70710678118654757;0"
index 9f8a778..e3e3a2f 100644 (file)
@@ -1,2 +1,3 @@
 001 dimensions
-002 tolerances
\ No newline at end of file
+002 tolerances
+003 import
\ No newline at end of file
diff --git a/tests/gdt/import/A1 b/tests/gdt/import/A1
new file mode 100644 (file)
index 0000000..1064239
--- /dev/null
@@ -0,0 +1,97 @@
+# !!!! 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
+ NbOfTolerances          : 6
+ NbOfDatumFeature        : 3
+ NbOfAttachedDatum       : 11
+ NbOfDatumTarget         : 0
+
+ 0:1:1:1:1 Shape.2
+        0:1:4:1 GeomTolerance.2.1 ( T 7 TV 0, V 0.20000000000000001 )
+ 0:1:1:1:2 Shape.3
+        0:1:4:2 GeomTolerance.3.1 ( T 9 TV 0, V 1.5 )
+                0:1:4:3 Datum.3.1.1 ( )
+ 0:1:1:1:3 Shape.4
+        0:1:4:4 GeomTolerance.4.1 ( T 12 TV 0, V 0.5, M 15 )
+                0:1:4:5 Datum.4.1.1 ( )
+ 0:1:1:1:4 Shape.5
+        0:1:4:4 GeomTolerance.5.1 ( T 12 TV 0, V 0.5, M 15 )
+                0:1:4:5 Datum.5.1.1 ( )
+ 0:1:1:1:5 Shape.6
+        0:1:4:4 GeomTolerance.6.1 ( T 12 TV 0, V 0.5, M 15 )
+                0:1:4:5 Datum.6.1.1 ( )
+ 0:1:1:1:6 Shape.7
+        0:1:4:4 GeomTolerance.7.1 ( T 12 TV 0, V 0.5, M 15 )
+                0:1:4:5 Datum.7.1.1 ( )
+ 0:1:1:1:7 Shape.8
+        0:1:4:4 GeomTolerance.8.1 ( T 12 TV 0, V 0.5, M 15 )
+                0:1:4:5 Datum.8.1.1 ( )
+ 0:1:1:1:8 Shape.9
+        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: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:7 Datum.11.1.1 ( )
+                0:1:4:8 Datum.11.1.2 ( )
+                0:1:4:9 Datum.11.1.3 ( )
+ 0:1:1:1:11 Shape.12
+        0:1:4:18 Dimension.12.1 ( T 15, V 35, VL 0.20000000000000001, VU 0, P 0 )
+ 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: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:11 Datum.15.1.1 ( )
+                0:1:4:12 Datum.15.1.2 ( )
+                0:1:4:13 Datum.15.1.3 ( )
+ 0:1:1:1:15 Shape.16
+        0:1:4:14 GeomTolerance.16.1 ( T 12 TV 0, V 1.25 )
+                0:1:4:15 Datum.16.1.1 ( )
+                0:1:4:16 Datum.16.1.2 ( )
+                0:1:4:17 Datum.16.1.3 ( )
+ 0:1:1:1:16 Shape.17
+        0:1:4:14 GeomTolerance.17.1 ( T 12 TV 0, V 1.25 )
+                0:1:4:15 Datum.17.1.1 ( )
+                0:1:4:16 Datum.17.1.2 ( )
+                0:1:4:17 Datum.17.1.3 ( )
+ 0:1:1:1:17 Shape.18
+        0:1:4:18 Dimension.18.1 ( T 15, V 35, VL 0.20000000000000001, VU 0, P 0 )
+ 0:1:1:1:18 Shape.19
+        0:1:4:19 Dimension.19.1 ( T 15, V 35, VL 0, VU 0.20000000000000001, P 0 )
+ 0:1:1:1:19 Shape.20
+        0:1:4:20 Dimension.20.1 ( T 15, V 20, VL 0.10000000000000001, VU 0.050000000000000003, P 0 )
+ 0:1:1:1:20 Shape.21
+        0:1:4:20 Dimension.21.1 ( T 15, V 20, VL 0.10000000000000001, VU 0.050000000000000003, P 0 )
+ 0:1:1:1:21 Shape.22
+        0:1:4:21 Dimension.22.1 ( T 15, V 20, VL 0.050000000000000003, VU 0.10000000000000001, P 0 )
+ 0:1:1:1:22 Shape.23
+        0:1:4:21 Dimension.23.1 ( T 15, V 20, VL 0.050000000000000003, VU 0.10000000000000001, P 0 )
+ 0:1:1:1:23 Shape.24
+        0:1:4:22 Dimension.24.1 ( T 11, V 59.999999999851163, VL 0.5, VU 0.5, Q 3, P 0 )
+ 0:1:1:1:24 Shape.25
+        0:1:4:22 Dimension.25.1 ( T 11, V 59.999999999851163, VL 0.5, VU 0.5, Q 3, P 0 )
+ 0:1:1:1:25 Shape.26
+        0:1:4:23 Dimension.26.1 ( T 15, LB 34.799999999999997, UB 35.200000000000003, P 0 )
+ 0:1:1:1:26 Shape.27
+        0:1:4:23 Dimension.27.1 ( T 15, LB 34.799999999999997, UB 35.200000000000003, P 0 )
+ 0:1:1:1:27 Shape.28
+        0:1:4:24 Dimension.28.1 ( T 15, LB 34.799999999999997, UB 35.200000000000003, P 0 )
+ 0:1:1:1:28 Shape.29
+        0:1:4:24 Dimension.29.1 ( T 15, LB 34.799999999999997, UB 35.200000000000003, P 0 )
+ 0:1:1:1:29 Shape.30
+        0:1:4:25 Dimension.30.1 ( T 15, V 25, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
+ 0:1:1:1:30 Shape.31
+        0:1:4:25 Dimension.31.1 ( T 15, V 25, VL 0.14999999999999999, VU 0.14999999999999999, P 0 )
+}
diff --git a/tests/gdt/import/A2 b/tests/gdt/import/A2
new file mode 100644 (file)
index 0000000..828921c
--- /dev/null
@@ -0,0 +1,185 @@
+# !!!! 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
+ NbOfTolerances          : 22
+ NbOfDatumFeature        : 5
+ NbOfAttachedDatum       : 24
+ 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: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: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: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: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: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: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: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: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: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: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 )
+ 0:1:1:2:185 Shape.188
+        0:1:4:45 GeomTolerance.188.1 ( T 12 TV 0, V 0.5 )
+                0:1:4:46 Datum.188.1.1 ( )
+                0:1:4:47 Datum.188.1.2 (, M 15 )
+                0:1:4:48 Datum.188.1.3 ( )
+ 0:1:1:2:192 Shape.195
+        0:1:4:41 GeomTolerance.195.1 ( T 12 TV 0, V 0.5 )
+                0:1:4:42 Datum.195.1.1 ( )
+                0:1:4:43 Datum.195.1.2 ( )
+                0:1:4:44 Datum.195.1.3 ( )
+ 0:1:1:2:195 Shape.198
+        0:1:4:22 GeomTolerance.198.1 ( T 12 TV 0, V 0.10000000000000001 )
+ 0:1:1:2:205 Shape.208
+        0:1:4:53 GeomTolerance.208.1 ( T 12 TV 0, V 0.5 )
+                0:1:4:54 Datum.208.1.1 ( )
+                0:1:4:55 Datum.208.1.2 ( )
+                0:1:4:56 Datum.208.1.3 (, M 15 )
+ 0:1:1:2:208 Shape.211
+        0:1:4:22 GeomTolerance.211.1 ( T 12 TV 0, V 0.10000000000000001 )
+ 0:1:1:2:219 Shape.222
+        0:1:4:22 GeomTolerance.222.1 ( T 12 TV 0, V 0.10000000000000001 )
+ 0:1:1:2:220 Shape.223
+        0:1:4:49 GeomTolerance.223.1 ( T 12 TV 0, V 0.5 )
+                0:1:4:50 Datum.223.1.1 ( )
+                0:1:4:51 Datum.223.1.2 (, M 15 )
+                0:1:4:52 Datum.223.1.3 (, M 15 )
+ 0:1:1:2:311 Shape.314
+        0:1:4:23 GeomTolerance.314.1 ( T 12 TV 0, V 0.80000000000000004 )
+                0:1:4:24 Datum.314.1.1 (, M 12 )
+                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: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: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: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: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 )
+ 0:1:1:2:396 Shape.399
+        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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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: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:1:2:679 Shape.682
+        0:1:4:27 GeomTolerance.682.1 ( T 8 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: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: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: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:1:3:1 Shape.687
+        0:1:4:1 GeomTolerance.687.1 ( T 6 TV 0, V 0.25 )
+}
diff --git a/tests/gdt/import/A3 b/tests/gdt/import/A3
new file mode 100644 (file)
index 0000000..325c4c6
--- /dev/null
@@ -0,0 +1,169 @@
+# !!!! 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
+ NbOfTolerances          : 13
+ NbOfDatumFeature        : 5
+ NbOfAttachedDatum       : 26
+ NbOfDatumTarget         : 0
+
+ 0:1:1:2:2 Shape.5
+        0:1:4:1 GeomTolerance.5.1 ( T 12 TV 0, V 0.254 )
+ 0:1:1:2:7 Shape.10
+        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: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: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: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: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 )
+ 0:1:1:2:28 Shape.31
+        0:1:4:6 Dimension.31.1 ( T 2, V 20.827999999999996, VL 64.515999999999991, VU 64.515999999999991, P 0 )
+        0:1:4:2 GeomTolerance.31.1 ( T 12 TV 0, V 0.76200000000000001 )
+                0:1:4:3 Datum.31.1.1 ( )
+                0:1:4:4 Datum.31.1.2 ( )
+                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: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:16 Datum.43.1.1 ( )
+                0:1:4:17 Datum.43.1.2 ( )
+                0:1:4:18 Datum.43.1.3 ( )
+ 0:1:1:2:48 Shape.51
+        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: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: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: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: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: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: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: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: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: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: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: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:32 Datum.61.1.1 ( )
+                0:1:4:33 Datum.61.1.2 ( )
+                0:1:4:34 Datum.61.1.3 ( )
+ 0:1:1:2:123 Shape.126
+        0:1:4:43 GeomTolerance.126.1 ( T 12 TV 0, V 1.524 )
+                0:1:4:44 Datum.126.1.1 ( )
+                0:1:4:45 Datum.126.1.2 ( )
+                0:1:4:46 Datum.126.1.3 ( )
+        0:1:4:47 GeomTolerance.126.2 ( T 7 TV 0, V 0.127 )
+        0:1:4:48 GeomTolerance.126.3 ( T 1 TV 0, V 1.016 )
+                0:1:4:49 Datum.126.3.1 ( )
+ 0:1:1:2:129 Shape.132
+        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: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: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: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: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: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:12 Datum.159.1.1 ( )
+                0:1:4:13 Datum.159.1.2 ( )
+ 0:1:1:2:157 Shape.160
+        0:1:4:24 Dimension.160.1 ( T 2, V 38.099999999999994, P 0 )
+ 0:1:1:2:158 Shape.161
+        0:1:4:30 Dimension.161.1 ( T 2, V 19.049999999999997, P 0 )
+}
diff --git a/tests/gdt/import/A4 b/tests/gdt/import/A4
new file mode 100644 (file)
index 0000000..144b1a4
--- /dev/null
@@ -0,0 +1,179 @@
+# !!!! 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
+ NbOfTolerances          : 4
+ NbOfDatumFeature        : 6
+ NbOfAttachedDatum       : 10
+ 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: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:2 Datum.5.1.1 ( )
+                0:1:4:3 Datum.5.1.2 ( )
+                0:1:4:4 Datum.5.1.3 ( )
+ 0:1:1:2:6 Shape.9
+        0:1:4:5 GeomTolerance.9.1 ( T 12 TV 0, V 2 )
+                0:1:4:6 Datum.9.1.1 ( )
+                0:1:4:7 Datum.9.1.2 ( )
+                0:1:4:8 Datum.9.1.3 ( )
+        0:1:4:9 GeomTolerance.9.2 ( T 12 TV 0, V 0.20000000000000001 )
+                0:1:4:10 Datum.9.2.1 ( )
+ 0:1:1:2:7 Shape.10
+        0:1:4:5 GeomTolerance.10.1 ( T 12 TV 0, V 2 )
+                0:1:4:6 Datum.10.1.1 ( )
+                0:1:4:7 Datum.10.1.2 ( )
+                0:1:4:8 Datum.10.1.3 ( )
+        0:1:4:9 GeomTolerance.10.2 ( T 12 TV 0, V 0.20000000000000001 )
+                0:1:4:10 Datum.10.2.1 ( )
+ 0:1:1:2:11 Shape.14
+        0:1:4:11 GeomTolerance.14.1 ( T 12 TV 0, V 0.5 )
+                0:1:4:12 Datum.14.1.1 ( )
+                0:1:4:13 Datum.14.1.2 ( )
+                0:1:4:14 Datum.14.1.3 ( )
+ 0:1:1:2:12 Shape.15
+        0:1:4:15 Dimension.15.1 ( T 15, V 10, P 0 )
+ 0:1:1:2:13 Shape.16
+        0:1:4:15 Dimension.16.1 ( T 15, V 10, P 0 )
+ 0:1:1:2:14 Shape.17
+        0:1:4:16 Dimension.17.1 ( T 2, V 20, VL 0.20000000000000001, VU 0.20000000000000001, P 0 )
+ 0:1:1:2:15 Shape.18
+        0:1:4:17 Dimension.18.1 ( T 14, V 25, VL 0.25, VU 0.25, P 0 )
+        0:1:4:16 Dimension.18.2 ( T 2, V 20, VL 0.20000000000000001, VU 0.20000000000000001, P 0 )
+ 0:1:1:2:16 Shape.19
+        0:1:4:18 Dimension.19.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:17 Shape.20
+        0:1:4:18 Dimension.20.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:18 Shape.21
+        0:1:4:18 Dimension.21.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:19 Shape.22
+        0:1:4:18 Dimension.22.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:20 Shape.23
+        0:1:4:18 Dimension.23.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:21 Shape.24
+        0:1:4:18 Dimension.24.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:22 Shape.25
+        0:1:4:18 Dimension.25.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:23 Shape.26
+        0:1:4:18 Dimension.26.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:24 Shape.27
+        0:1:4:18 Dimension.27.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:25 Shape.28
+        0:1:4:18 Dimension.28.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:26 Shape.29
+        0:1:4:18 Dimension.29.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:27 Shape.30
+        0:1:4:18 Dimension.30.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:28 Shape.31
+        0:1:4:18 Dimension.31.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:29 Shape.32
+        0:1:4:18 Dimension.32.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:30 Shape.33
+        0:1:4:18 Dimension.33.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:31 Shape.34
+        0:1:4:18 Dimension.34.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:32 Shape.35
+        0:1:4:18 Dimension.35.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:33 Shape.36
+        0:1:4:18 Dimension.36.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:34 Shape.37
+        0:1:4:18 Dimension.37.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:35 Shape.38
+        0:1:4:18 Dimension.38.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:36 Shape.39
+        0:1:4:18 Dimension.39.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:37 Shape.40
+        0:1:4:18 Dimension.40.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:38 Shape.41
+        0:1:4:18 Dimension.41.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:39 Shape.42
+        0:1:4:18 Dimension.42.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:40 Shape.43
+        0:1:4:18 Dimension.43.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:41 Shape.44
+        0:1:4:18 Dimension.44.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:42 Shape.45
+        0:1:4:18 Dimension.45.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:43 Shape.46
+        0:1:4:18 Dimension.46.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:44 Shape.47
+        0:1:4:18 Dimension.47.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:45 Shape.48
+        0:1:4:18 Dimension.48.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:46 Shape.49
+        0:1:4:18 Dimension.49.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:47 Shape.50
+        0:1:4:18 Dimension.50.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:48 Shape.51
+        0:1:4:18 Dimension.51.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:49 Shape.52
+        0:1:4:18 Dimension.52.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:50 Shape.53
+        0:1:4:18 Dimension.53.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:51 Shape.54
+        0:1:4:18 Dimension.54.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:52 Shape.55
+        0:1:4:18 Dimension.55.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:53 Shape.56
+        0:1:4:18 Dimension.56.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:54 Shape.57
+        0:1:4:18 Dimension.57.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:55 Shape.58
+        0:1:4:18 Dimension.58.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:56 Shape.59
+        0:1:4:18 Dimension.59.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:57 Shape.60
+        0:1:4:18 Dimension.60.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:58 Shape.61
+        0:1:4:18 Dimension.61.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:59 Shape.62
+        0:1:4:18 Dimension.62.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:60 Shape.63
+        0:1:4:18 Dimension.63.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:61 Shape.64
+        0:1:4:18 Dimension.64.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:62 Shape.65
+        0:1:4:18 Dimension.65.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:63 Shape.66
+        0:1:4:18 Dimension.66.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:64 Shape.67
+        0:1:4:18 Dimension.67.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:65 Shape.68
+        0:1:4:18 Dimension.68.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:66 Shape.69
+        0:1:4:18 Dimension.69.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:67 Shape.70
+        0:1:4:18 Dimension.70.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:68 Shape.71
+        0:1:4:18 Dimension.71.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:69 Shape.72
+        0:1:4:18 Dimension.72.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:70 Shape.73
+        0:1:4:18 Dimension.73.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:71 Shape.74
+        0:1:4:18 Dimension.74.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:72 Shape.75
+        0:1:4:18 Dimension.75.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:73 Shape.76
+        0:1:4:18 Dimension.76.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:74 Shape.77
+        0:1:4:18 Dimension.77.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:75 Shape.78
+        0:1:4:18 Dimension.78.1 ( T 15, V 20, VL 0.29999999999999999, VU 0.29999999999999999, P 0 )
+ 0:1:1:2:76 Shape.79
+        0:1:4:19 Dimension.79.1 ( T 11, V 89.999999999776747, VL 1, VU 1, Q 3, P 0 )
+ 0:1:1:2:77 Shape.80
+        0:1:4:19 Dimension.80.1 ( T 11, V 89.999999999776747, VL 1, VU 1, Q 3, P 0 )
+ 0:1:1:3:1 Shape.81
+        0:1:4:11 GeomTolerance.81.1 ( T 12 TV 0, V 0.5 )
+                0:1:4:12 Datum.81.1.1 ( )
+                0:1:4:13 Datum.81.1.2 ( )
+                0:1:4:14 Datum.81.1.3 ( )
+}
diff --git a/tests/gdt/import/A5 b/tests/gdt/import/A5
new file mode 100644 (file)
index 0000000..0fd09c9
--- /dev/null
@@ -0,0 +1,63 @@
+# !!!! 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
+ NbOfTolerances          : 10
+ NbOfDatumFeature        : 2
+ NbOfAttachedDatum       : 9
+ NbOfDatumTarget         : 2
+
+ 0:1:1:2:2 Shape.5
+        0:1:4:10 Dimension.5.1 ( T 2, V 127, VL 64.515999999999991, VU 64.515999999999991, P 0 )
+ 0:1:1:2:8 Shape.11
+        0:1:4:10 Dimension.11.1 ( T 2, V 127, VL 64.515999999999991, VU 64.515999999999991, P 0 )
+ 0:1:1:2:9 Shape.12
+        0:1:4:1 GeomTolerance.12.1 ( T 13 TV 0, V 0.127 )
+ 0:1:1:2:66 Shape.69
+        0:1:4:11 GeomTolerance.69.1 ( T 3 TV 0, V 0.050799999999999998 )
+ 0:1:1:2:67 Shape.70
+        0:1:4:11 GeomTolerance.70.1 ( T 3 TV 0, V 0.050799999999999998 )
+ 0:1:1:2:68 Shape.71
+        0:1:4:2 GeomTolerance.71.1 ( T 2 TV 0, V 0.88900000000000001 )
+                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: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: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: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: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 ( )
+                0:1:4:16 Datum.128.1.2 ( )
+ 0:1:1:2:141 Shape.144
+        0:1:4:17 GeomTolerance.144.1 ( T 2 TV 0, V 0.63500000000000001 )
+                0:1:4:18 Datum.144.1.1 ( )
+                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: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: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 ( )
+ 0:1:1:2:200 Shape.203
+        0:1:4:5 GeomTolerance.203.1 ( T 2 TV 0, V 0.050799999999999998 )
+                0:1:4:6 Datum.203.1.1 ( )
+ 0:1:1:2:206 Shape.209
+        0:1:4:9 Dimension.209.1 ( T 2, V 254, VL 64.515999999999991, VU 64.515999999999991, P 0 )
+ 0:1:1:2:207 Shape.210
+        0:1:4:9 Dimension.210.1 ( T 2, V 254, VL 64.515999999999991, VU 64.515999999999991, P 0 )
+ 0:1:1:3:1 Shape.211
+        0:1:4:1 GeomTolerance.211.1 ( T 13 TV 0, V 0.127 )
+}
diff --git a/tests/gdt/import/begin b/tests/gdt/import/begin
new file mode 100644 (file)
index 0000000..e633456
--- /dev/null
@@ -0,0 +1 @@
+NewDocument D
diff --git a/tests/gdt/import/end b/tests/gdt/import/end
new file mode 100644 (file)
index 0000000..1a6ea1c
--- /dev/null
@@ -0,0 +1,124 @@
+# 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;
+set nbTol 0;
+set nbDim 0;
+set nbDat 0;
+set nbDatT 0;
+set nbAttDat 0;
+###################################################################
+set ref_Compare 0
+set todo_msg ""
+set todo_mask "puts \"TODO CR23096 ALL: "
+set Mandriva_todo_mask "puts \"TODO CR23096 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 ] 
+
+    if { [llength $xst] > 0 } {
+       regexp {NbOfDimensions +: +([-0-9.+eE]+)} $xst full nbDim
+       regexp {NbOfTolerances +: +([-0-9.+eE]+)} $xst full nbTol
+       regexp {NbOfDatumFeature +: +([-0-9.+eE]+)} $xst full nbDat
+       regexp {NbOfAttachedDatum +: +([-0-9.+eE]+)} $xst full nbAttDat
+       regexp {NbOfDatumTarget +: +([-0-9.+eE]+)} $xst full nbDatT
+    } else {
+       puts " GDT information was NOT provided"
+    }
+    set xstruct [ XDumpDGTs D_First all 1] 
+}
+
+if { $mist != 1 } {  
+  puts "" 
+  set result ""
+  append result [format $xst]
+  append result [format "\n"]
+  append result [format $xstruct]
+}
+
+set err_compare_ref ""
+
+if { [catch { Close D_First } catch_result] } {
+    set err_msg "Error : cannot close a document D_First - exception"  
+    puts $err_msg
+}
+
+
+# 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 nb_ref [llength $ref_list]
+    set nb_cur [llength $cur_list]
+    for { set i 0 } { $i < $nb_cur } { incr i } {
+        set j [expr $i +1]
+       set refstr [lindex $ref_list $j]
+       set curstr [lindex $cur_list $i]
+        set isOK 1; 
+
+        if {[string equal $refstr $curstr] == 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 "--------------------------------------------------------------------\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"