]> OCCT Git - occt-copy.git/commitdiff
0031388: To support kinematics data in STEP format
authordpasukhi <dpasukhi@opencascade.com>
Mon, 22 Jun 2020 10:07:17 +0000 (13:07 +0300)
committerdpasukhi <dpasukhi@opencascade.com>
Mon, 22 Jun 2020 10:19:07 +0000 (13:19 +0300)
 - Add Write Kinematic Pair
 - Add States in XCAF structure

46 files changed:
src/RWStepAP214/RWStepAP214_GeneralModule.cxx
src/RWStepAP214/RWStepAP214_ReadWriteModule.cxx
src/RWStepKinematics/FILES
src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.cxx [new file with mode: 0644]
src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.hxx [new file with mode: 0644]
src/STEPCAFControl/STEPCAFControl_Reader.cxx
src/STEPCAFControl/STEPCAFControl_Writer.cxx
src/STEPCAFControl/STEPCAFControl_Writer.hxx
src/StepAP214/StepAP214_Protocol.cxx
src/StepKinematics/FILES
src/StepKinematics/StepKinematics_MechanismStateRepresentation.cxx [new file with mode: 0644]
src/StepKinematics/StepKinematics_MechanismStateRepresentation.hxx [new file with mode: 0644]
src/XCAFDoc/XCAFDoc.cxx
src/XCAFDoc/XCAFDoc.hxx
src/XCAFDoc/XCAFDoc_KinematicPair.cxx
src/XCAFDoc/XCAFDoc_KinematicPairValue.cxx
src/XCAFDoc/XCAFDoc_KinematicPairValue.hxx
src/XCAFDoc/XCAFDoc_KinematicTool.cxx
src/XCAFDoc/XCAFDoc_KinematicTool.hxx
src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx
src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx
src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.cxx
src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx
src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.cxx
src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx
src/XCAFKinematics/XCAFKinematics_PairObject.hxx
src/XCAFKinematics/XCAFKinematics_PairType.hxx
src/XDEDRAW/XDEDRAW_Kinematics.cxx
tests/gdt/kinematics/A2
tests/gdt/kinematics/A3
tests/gdt/kinematics/A4
tests/gdt/kinematics/A5
tests/gdt/kinematics/A6
tests/gdt/kinematics/A7
tests/gdt/kinematics/A8
tests/gdt/kinematics/A9
tests/gdt/kinematics/B1
tests/gdt/kinematics/B2
tests/gdt/kinematics/B3
tests/gdt/kinematics/B4
tests/gdt/kinematics/B5
tests/gdt/kinematics/B6
tests/gdt/kinematics/B7
tests/gdt/kinematics/B8
tests/gdt/kinematics/B9
tests/gdt/kinematics/C1

index 7895ea8a727ad5f2ff9c00f5eaec9fe3f7541a48..fbdbbaa736650ba2b438a6d9a9c45b95a02fbe2a 100644 (file)
@@ -1442,6 +1442,7 @@ IMPLEMENT_STANDARD_RTTIEXT(RWStepAP214_GeneralModule,StepData_GeneralModule)
 #include <StepKinematics_UniversalPairValue.hxx>
 #include <StepKinematics_UniversalPairWithRange.hxx>
 #include <StepKinematics_ActuatedKinPairAndOrderKinPair.hxx>
+#include <StepKinematics_MechanismStateRepresentation.hxx>
 
 #include <RWStepRepr_RWRepresentationContextReference.hxx>
 #include <RWStepRepr_RWRepresentationReference.hxx>
@@ -1519,6 +1520,7 @@ IMPLEMENT_STANDARD_RTTIEXT(RWStepAP214_GeneralModule,StepData_GeneralModule)
 #include <RWStepKinematics_RWUniversalPairValue.hxx>
 #include <RWStepKinematics_RWUniversalPairWithRange.hxx>
 #include <RWStepKinematics_RWActuatedKinPairAndOrderKinPair.hxx>
+#include <RWStepKinematics_RWMechanismStateRepresentation.hxx>
 
 static Standard_Integer catsh,catdr,catstr,catdsc,cataux;
 
@@ -5878,6 +5880,13 @@ void RWStepAP214_GeneralModule::FillSharedCase(const Standard_Integer CN,
     RWStepKinematics_RWActuatedKinPairAndOrderKinPair tool;
     tool.Share(anent, iter);
   }
+  break;
+  case 801:
+  {
+    DeclareAndCast(StepKinematics_MechanismStateRepresentation, anent, ent);
+    RWStepKinematics_RWMechanismStateRepresentation tool;
+    tool.Share(anent, iter);
+  }
   break;
 
     default : break;
@@ -8132,6 +8141,9 @@ Standard_Boolean RWStepAP214_GeneralModule::NewVoid
    case 800:
      ent = new StepKinematics_ActuatedKinPairAndOrderKinPair;
      break;
+   case 801:
+     ent = new StepKinematics_MechanismStateRepresentation;
+     break;
     
   default: 
     return Standard_False;
@@ -8811,6 +8823,7 @@ Standard_Integer  RWStepAP214_GeneralModule::CategoryNumber
   case 797: return cataux;
   case 798: return cataux;
   case 800: return catsh;
+  case 801: return cataux;
   default : break;
   }
   return 0;
index 4f3f50b395cc11e00cc31711c97006247cbce315..d2bd21e3072152bebf52cbcf1b65a6b1ee9de1e3 100644 (file)
@@ -1486,6 +1486,7 @@ IMPLEMENT_STANDARD_RTTIEXT(RWStepAP214_ReadWriteModule,StepData_ReadWriteModule)
 #include <StepKinematics_UniversalPairWithRange.hxx>
 #include <StepKinematics_KinematicPair.hxx>
 #include <StepKinematics_ActuatedKinPairAndOrderKinPair.hxx>
+#include <StepKinematics_MechanismStateRepresentation.hxx>
 #include <RWStepRepr_RWRepresentationContextReference.hxx>
 #include <RWStepRepr_RWRepresentationReference.hxx>
 #include <RWStepKinematics_RWSuParameters.hxx>
@@ -1562,6 +1563,7 @@ IMPLEMENT_STANDARD_RTTIEXT(RWStepAP214_ReadWriteModule,StepData_ReadWriteModule)
 #include <RWStepKinematics_RWUniversalPairValue.hxx>
 #include <RWStepKinematics_RWUniversalPairWithRange.hxx>
 #include <RWStepKinematics_RWActuatedKinPairAndOrderKinPair.hxx>
+#include <RWStepKinematics_RWMechanismStateRepresentation.hxx>
 
 #include <RWStepVisual_RWSurfaceStyleTransparent.hxx>
 #include <RWStepVisual_RWSurfaceStyleReflectanceAmbient.hxx>
@@ -2290,6 +2292,7 @@ static TCollection_AsciiString Reco_UniversalPair("UNIVERSAL_PAIR");
 static TCollection_AsciiString Reco_UniversalPairValue("UNIVERSAL_PAIR_VALUE");
 static TCollection_AsciiString Reco_UniversalPairWithRange("UNIVERSAL_PAIR_WITH_RANGE");
 static TCollection_AsciiString Reco_KinematicPair("KINEMATIC_PAIR");
+static TCollection_AsciiString Reco_MechanismStateRepresentation("MECHANISM_STATE_REPRESENTATION");
 
 // -- Definition of the libraries --
 
@@ -3029,6 +3032,8 @@ RWStepAP214_ReadWriteModule::RWStepAP214_ReadWriteModule ()
   typenums.Bind(Reco_LinearFlexibleAndPlanarCurvePair, 797);
   typenums.Bind(Reco_LinearFlexibleLinkRepresentation, 798);
   typenums.Bind(Reco_KinematicPair, 799);
+  typenums.Bind(Reco_MechanismStateRepresentation, 801);
+
   
 //    SHORT NAMES
 //    NB : la liste est celle de AP203
@@ -4981,7 +4986,7 @@ const TCollection_AsciiString& RWStepAP214_ReadWriteModule::StepType
   case 797: return Reco_LinearFlexibleAndPlanarCurvePair;
   case 798: return Reco_LinearFlexibleLinkRepresentation;
   case 799: return Reco_KinematicPair;
-
+  case 801: return Reco_MechanismStateRepresentation;
 
   default : return PasReco;
   }
@@ -10453,6 +10458,13 @@ void RWStepAP214_ReadWriteModule::ReadStep(const Standard_Integer CN,
     tool.ReadStep(data, num, ach, anent);
   }
   break;
+  case 801:
+  {
+    DeclareAndCast(StepKinematics_MechanismStateRepresentation, anent, ent);
+    RWStepKinematics_RWMechanismStateRepresentation tool;
+    tool.ReadStep(data, num, ach, anent);
+  }
+  break;
 
   default: 
     ach->AddFail("Type Mismatch when reading - Entity");
@@ -15869,6 +15881,13 @@ void RWStepAP214_ReadWriteModule::WriteStep(const Standard_Integer CN,
     tool.WriteStep(SW, anent);
   }
   break;
+  case 801:
+  {
+    DeclareAndCast(StepKinematics_MechanismStateRepresentation, anent, ent);
+    RWStepKinematics_RWMechanismStateRepresentation tool;
+    tool.WriteStep(SW, anent);
+  }
+  break;
 
   default: 
     return;
index 491b2ccd6c1299ac44d2d1146d7e1ed7bfd42adc..40db30168a620ab0298697691f456406bcf4b3de 100644 (file)
@@ -44,6 +44,8 @@ RWStepKinematics_RWLowOrderKinematicPairWithRange.cxx
 RWStepKinematics_RWLowOrderKinematicPairWithRange.hxx
 RWStepKinematics_RWMechanismRepresentation.cxx
 RWStepKinematics_RWMechanismRepresentation.hxx
+RWStepKinematics_RWMechanismStateRepresentation.cxx
+RWStepKinematics_RWMechanismStateRepresentation.hxx
 RWStepKinematics_RWOrientedJoint.cxx
 RWStepKinematics_RWOrientedJoint.hxx
 RWStepKinematics_RWPairRepresentationRelationship.cxx
diff --git a/src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.cxx b/src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.cxx
new file mode 100644 (file)
index 0000000..fed5c93
--- /dev/null
@@ -0,0 +1,116 @@
+// Created on: 2016-04-26
+// Created by: Irina KRYLOVA
+// Copyright (c) 2016 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <Interface_Check.hxx>
+#include <Interface_EntityIterator.hxx>
+#include <RWStepKinematics_RWMechanismStateRepresentation.hxx>
+#include <StepData_StepReaderData.hxx>
+#include <StepData_StepWriter.hxx>
+#include <StepRepr_HArray1OfRepresentationItem.hxx>
+#include <StepRepr_RepresentationContext.hxx>
+#include <StepRepr_RepresentationItem.hxx>
+#include <StepKinematics_MechanismStateRepresentation.hxx>
+#include <StepKinematics_MechanismRepresentation.hxx>
+
+//=======================================================================
+//function : RWStepKinematics_RWMechanismStateRepresentation
+//purpose  : 
+//=======================================================================
+RWStepKinematics_RWMechanismStateRepresentation::RWStepKinematics_RWMechanismStateRepresentation() {}
+
+//=======================================================================
+//function : ReadStep
+//purpose  : 
+//=======================================================================
+void RWStepKinematics_RWMechanismStateRepresentation::ReadStep
+  (const Handle(StepData_StepReaderData)& data,
+   const Standard_Integer num,
+   Handle(Interface_Check)& ach,
+   const Handle(StepKinematics_MechanismStateRepresentation)& ent) const
+{
+  // Number of Parameter Control
+  if (!data->CheckNbParams(num, 4, ach, "mechanism_state_representation")) return;
+
+  // Inherited field : name
+  Handle(TCollection_HAsciiString) aName;
+  data->ReadString (num, 1, "name" ,ach, aName);
+
+  // Inherited field : items
+  Handle(StepRepr_HArray1OfRepresentationItem) aItems;
+  Handle(StepRepr_RepresentationItem) anEnt;
+  Standard_Integer nsub;
+  if (data->ReadSubList (num, 2, "items", ach, nsub)) {
+    Standard_Integer nb = data->NbParams(nsub);
+    aItems = new StepRepr_HArray1OfRepresentationItem (1, nb);
+    for (Standard_Integer i = 1; i <= nb; i ++) {
+      if (data->ReadEntity (nsub, i, "representation_item", ach,
+        STANDARD_TYPE(StepRepr_RepresentationItem), anEnt))
+        aItems->SetValue(i, anEnt);
+    }
+  }
+
+  // Inherited field : context_of_items
+  Handle(StepRepr_RepresentationContext) aContextOfItems;
+  data->ReadEntity(num, 3,"context_of_items", ach, STANDARD_TYPE(StepRepr_RepresentationContext), aContextOfItems);
+
+  // Inherited field : represented_mechanism
+  Handle(StepKinematics_MechanismRepresentation) aRepresentedMechanism;
+  data->ReadEntity(num, 4, "represented_mechanism", ach, STANDARD_TYPE(StepKinematics_MechanismRepresentation), aRepresentedMechanism);
+
+  // Initialisation of the read entity
+  ent->Init(aName, aItems, aContextOfItems, aRepresentedMechanism);
+}
+
+//=======================================================================
+//function : WriteStep
+//purpose  : 
+//=======================================================================
+void RWStepKinematics_RWMechanismStateRepresentation::WriteStep
+  (StepData_StepWriter& SW,
+   const Handle(StepKinematics_MechanismStateRepresentation)& ent) const
+{
+  // Inherited field : name
+  SW.Send(ent->Name());
+
+  // Inherited field : items
+  SW.OpenSub();
+  for (Standard_Integer i = 1;  i <= ent->NbItems();  i++) {
+    SW.Send(ent->ItemsValue(i));
+  }
+  SW.CloseSub();
+
+  // Inherited field : context_of_items
+  SW.Send(ent->ContextOfItems());
+
+  // Inherited field : represented_mechanism
+  SW.Send(ent->Mechanism());
+
+}
+
+//=======================================================================
+//function : Share
+//purpose  : 
+//=======================================================================
+void RWStepKinematics_RWMechanismStateRepresentation::Share(const Handle(StepKinematics_MechanismStateRepresentation)& ent, Interface_EntityIterator& iter) const
+{
+  Standard_Integer nbElem = ent->NbItems();
+  for (Standard_Integer i = 1; i <= nbElem; i++) {
+    iter.GetOneItem(ent->ItemsValue(i));
+  }
+  iter.GetOneItem(ent->ContextOfItems());
+  iter.GetOneItem(ent->Mechanism());
+}
+
diff --git a/src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.hxx b/src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.hxx
new file mode 100644 (file)
index 0000000..73660d3
--- /dev/null
@@ -0,0 +1,48 @@
+// Created on: 2016-04-26
+// Created on: 2016-04-26
+// Created by: Irina KRYLOVA
+// Copyright (c) 2016 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 _RWStepKinematics_RWMechanismStateRepresentation_HeaderFile
+#define _RWStepKinematics_RWMechanismStateRepresentation_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Handle.hxx>
+
+#include <Standard_Integer.hxx>
+class StepData_StepReaderData;
+class Interface_Check;
+class StepKinematics_MechanismStateRepresentation;
+class StepData_StepWriter;
+class Interface_EntityIterator;
+
+
+//! Read & Write Module for MechanismStateRepresentation
+class RWStepKinematics_RWMechanismStateRepresentation
+{
+public:
+
+  DEFINE_STANDARD_ALLOC
+
+  Standard_EXPORT RWStepKinematics_RWMechanismStateRepresentation();
+  
+  Standard_EXPORT void ReadStep (const Handle(StepData_StepReaderData)& data, const Standard_Integer num, Handle(Interface_Check)& ach, const Handle(StepKinematics_MechanismStateRepresentation)& ent) const;
+  
+  Standard_EXPORT void WriteStep (StepData_StepWriter& SW, const Handle(StepKinematics_MechanismStateRepresentation)& ent) const;
+  
+  Standard_EXPORT void Share (const Handle(StepKinematics_MechanismStateRepresentation)& ent, Interface_EntityIterator& iter) const;
+
+};
+#endif // _RWStepKinematics_RWMechanismStateRepresentation_HeaderFile
index 1e3abf704d4ce4c2e635bd657648336fe5ae1a6b..144c1d8e6d5b1387049d34b91ac9ea4ebda4b7ce 100644 (file)
 #include <XCAFKinematics_LowOrderPairObject.hxx>
 #include <XCAFKinematics_LowOrderPairObjectWithCoupling.hxx>
 #include <XCAFKinematics_HighOrderPairObject.hxx>
-     //sliding_surface_pair_value, a rolling_surface_pair_value, a revolute_pair_value, 
-     //a prismatic_pair_value, a screw_pair_value, a cylindrical_pair_value,
-     //a spherical_pair_value, a sliding_curve_pair_value, a rolling_curve_pair_value,
-     //a gear_pair_value, a rack_and_pinion_pair_value, an universal_pair_value, a planar_pair_value,
-     //an unconstrained_pair_value, a point_on_surface_pair_value, or a point_on_planar_curve_pair_value.
+
 #include <StepKinematics_SlidingSurfacePairValue.hxx>
 #include <StepKinematics_RollingSurfacePairValue.hxx>
 #include <StepKinematics_RevolutePairValue.hxx>
 #include <StepKinematics_LinearFlexibleAndPinionPair.hxx>
 #include <StepKinematics_LinearFlexibleAndPlanarCurvePair.hxx>
 #include <StepKinematics_ActuatedKinPairAndOrderKinPair.hxx>
+#include <StepKinematics_MechanismStateRepresentation.hxx>
 
 
 #include <TColgp_HArray1OfXYZ.hxx>
@@ -423,7 +420,8 @@ STEPCAFControl_Reader::STEPCAFControl_Reader()
   mySHUOMode(Standard_False),
   myGDTMode(Standard_True),
   myMatMode(Standard_True),
-  myViewMode(Standard_True)
+  myViewMode(Standard_True),
+  myKinematicMode(Standard_True)
 {
   STEPCAFControl_Controller::Init();
   mySourceCodePage = (Resource_FormatType )Interface_Static::IVal ("read.stepcaf.codepage");
@@ -4319,37 +4317,77 @@ void collectViewShapes(const Handle(XSControl_WorkSession)& theWS,
 }
 
 //=======================================================================
-//function : linkShapeWithJoint
-//purpose  : collect all labels of representations in given representation
+//function : addLinksWithShapes
+//purpose  : set links of the Kinematic Joint on the OCAF
 //=======================================================================
-void linkShapeWithJoint(const Handle(XSControl_WorkSession)& theWS,
+Standard_Boolean addLinksWithShapes(const Handle(XSControl_WorkSession)& theWS,
   const Handle(TDocStd_Document)& theDoc,
-  const Handle(StepKinematics_KinematicLinkRepresentationAssociation)& theRAssociation,
-  TDF_LabelSequence& theShapes,
+  const Handle(StepKinematics_KinematicLinkRepresentation)& aLinkRepresentation,
+  TDF_Label& theLink,
+  const TDF_Label& aMechanism,
+  TColStd_SequenceOfTransient& aCollOfLinks,
+  TDF_LabelSequence& aSeqOfLinksL,
   const XCAFDoc_DataMapOfShapeLabel& aMap)
 {
   Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
   Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
   const Interface_Graph& aGraph = aTP->Graph();
   Handle(XCAFDoc_ShapeTool) aSTool = XCAFDoc_DocumentTool::ShapeTool(theDoc->Main());
+  Handle(XCAFDoc_KinematicTool) aKTool = XCAFDoc_DocumentTool::KinematicTool(theDoc->Main());
+  TDF_LabelSequence aShapes;
+  Handle(StepKinematics_KinematicLink) aLink = aLinkRepresentation->RepresentedLink();
+  for (Standard_Integer anIndexOfLink = 1; anIndexOfLink <= aCollOfLinks.Length(); ++anIndexOfLink)
+  {
+    if (aCollOfLinks(anIndexOfLink) == aLink)
+    {
+      theLink = aSeqOfLinksL(anIndexOfLink);
+      aCollOfLinks.Append(aLink);
+      aSeqOfLinksL.Append(theLink);
+      return Standard_True;
+    }
+  }
+  Handle(StepKinematics_KinematicLinkRepresentationAssociation) aKLRA1;
+  for (Interface_EntityIterator anIterLinks = aGraph.Sharings(aLinkRepresentation);
+    anIterLinks.More() && aKLRA1.IsNull(); anIterLinks.Next())
+  {
+    if (!anIterLinks.Value()->IsKind(STANDARD_TYPE(StepKinematics_KinematicLinkRepresentationAssociation)))
+      continue;
+    aKLRA1 = Handle(StepKinematics_KinematicLinkRepresentationAssociation)::DownCast(anIterLinks.Value());
+  }
+  if (aKLRA1.IsNull())
+    return Standard_False;
   Handle(StepKinematics_ContextDependentKinematicLinkRepresentation) aCDKLR;
-  Interface_EntityIterator entIt = aGraph.Sharings(theRAssociation);
-  for (entIt.Start(); entIt.More()&aCDKLR.IsNull(); entIt.Next())
+  Interface_EntityIterator entIt = aGraph.Sharings(aKLRA1);
+  for (entIt.Start(); entIt.More() & aCDKLR.IsNull(); entIt.Next())
   {
     aCDKLR = Handle(StepKinematics_ContextDependentKinematicLinkRepresentation)::DownCast(entIt.Value());
   }
-  Handle(StepRepr_NextAssemblyUsageOccurrence) aNAUO
-    Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(aCDKLR->RepresentedProductRelation()->Definition().ProductDefinitionRelationship());
+  Handle(StepRepr_NextAssemblyUsageOccurrence) aNAUO =
+    Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(aCDKLR->RepresentedProductRelation()->Definition().Value());
   TDF_Label aShapeLabel;
   Handle(Transfer_Binder) binder = aTP->Find(aNAUO);
   TopoDS_Shape aShape = TransferBRep::ShapeResult(aTP, binder);
   if (aShape.IsNull())
-    return;
+    return Standard_False;
   if (aMap.IsBound(aShape))
     aShapeLabel = aMap(aShape);
   else
     aSTool->Search(aShape, aShapeLabel, Standard_True, Standard_True, Standard_True);
-  theShapes.Append(aShapeLabel);
+  aShapes.Append(aShapeLabel);
+  if (aShapes.Length() == 0)
+    return Standard_False;
+
+  theLink = aKTool->AddLink(aMechanism, aShapes);
+  if (!aLink->Name()->IsEmpty())
+    TDataStd_Name::Set(theLink, aLink->Name()->String());
+
+  if (theLink.IsNull())
+    return Standard_False;
+
+  aCollOfLinks.Append(aLink);
+  aSeqOfLinksL.Append(theLink);
+
+  return Standard_True;
 }
 
 //=======================================================================
@@ -4388,7 +4426,7 @@ XCAFKinematics_PairType getKinematicType(const Handle(StepKinematics_KinematicPa
   if (aKP->IsKind(STANDARD_TYPE(StepKinematics_GearPair)))
     return XCAFKinematics_PairType_Gear;
   if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPinionPair)))
-    return  XCAFKinematics_LinearFlexibleAndPinionPair;
+    return  XCAFKinematics_PairType_LinearFlexibleAndPinion;
 
   // High order pairs
   if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnSurfacePair)))
@@ -4404,7 +4442,7 @@ XCAFKinematics_PairType getKinematicType(const Handle(StepKinematics_KinematicPa
   if (aKP->IsKind(STANDARD_TYPE(StepKinematics_RollingCurvePair)))
     return  XCAFKinematics_PairType_RollingCurve;
   if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPlanarCurvePair)))
-    return  XCAFKinematics_PairType_LinearFlexibleAndPlanarCurvePair;
+    return  XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve;
   return  XCAFKinematics_PairType_NoType;
 }
 
@@ -4626,6 +4664,11 @@ Handle(XCAFKinematics_PairObject) createXCAFKinematicPairObject(const Handle(Ste
       anLowOrderKinPairWthCouplingObj->SetRadiusFirstLink(aGearPair->RadiusFirstLink());
       anLowOrderKinPairWthCouplingObj->SetRadiusSecondLink(aGearPair->RadiusSecondLink());
     }
+    else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPinionPair)))
+    {
+      Handle(StepKinematics_LinearFlexibleAndPinionPair) aLinearFlexibleAndPinionPair = Handle(StepKinematics_LinearFlexibleAndPinionPair)::DownCast(aKP);
+      anLowOrderKinPairWthCouplingObj->SetPinionRadius(aLinearFlexibleAndPinionPair->PinionRadius());
+    }
   }
   // High order pairs
   else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_HighOrderKinematicPair)))
@@ -4659,6 +4702,12 @@ Handle(XCAFKinematics_PairObject) createXCAFKinematicPairObject(const Handle(Ste
       aHighOrderPairObject->SetSecondCurve(StepToGeom::MakeCurve(aPlanarCurvePair->Curve2()));
       aHighOrderPairObject->SetOrientation(aPlanarCurvePair->Orientation());
     }
+    else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPlanarCurvePair)))
+    {
+      Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair) aLinearFlexibleAndPlanarCurvePair = Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair)::DownCast(aKP);
+      aHighOrderPairObject->SetFirstCurve(StepToGeom::MakeCurve(aLinearFlexibleAndPlanarCurvePair->PairCurve()));
+      aHighOrderPairObject->SetOrientation(aLinearFlexibleAndPlanarCurvePair->Orientation());
+    }
   }
   if (!anObj.IsNull())
   {
@@ -4676,6 +4725,7 @@ Handle(XCAFKinematics_PairObject) createXCAFKinematicPairObject(const Handle(Ste
       aPlacementSecond = StepToGeom::MakeAxis2Placement(Handle(StepGeom_Axis2Placement3d)::DownCast(aTransformItem2));
     if (!aKP->Joint()->Name()->IsEmpty())
       anObj->SetName(aKP->Joint()->Name()->String());
+
     anObj->SetFirstTransformation(aPlacementFirst->Ax2());
     anObj->SetSecondTransformation(aPlacementSecond->Ax2());
   }
@@ -4686,168 +4736,129 @@ Handle(XCAFKinematics_PairObject) createXCAFKinematicPairObject(const Handle(Ste
 //function : setPairValue
 //purpose  : set pair Value of the kinematic pair on OCAF
 //=======================================================================
- Standard_Boolean setKinematicPairValue(const Handle(XSControl_WorkSession)& theWS,
-   const Handle(TDocStd_Document)& theDoc, const Handle(StepKinematics_KinematicPair)& theKP,
-   TDF_Label& theJoint)
- { 
-   Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
-   Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
-   const Interface_Graph& aGraph = aTP->Graph();
-   Handle(XCAFDoc_KinematicTool) aKTool = XCAFDoc_DocumentTool::KinematicTool(theDoc->Main());
-   Handle(StepKinematics_KinematicPair) aKP=theKP;
-   //find father kinematicPair if pair is complex
-   for (Interface_EntityIterator anIter = aGraph.Sharings(theKP->Joint()); anIter.More(); anIter.Next()) {
-     if (!anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_KinematicPair)) || anIter.Value() == aKP)
-       continue;
-     aKP = Handle(StepKinematics_KinematicPair)::DownCast(anIter.Value());
-   }
-   Interface_EntityIterator anIter = aGraph.Sharings(aKP);
-   for (; anIter.More(); anIter.Next()) {
-     if (!anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_PairValue)))
-       continue;
-     else
-     {
-       Handle(XCAFKinematics_PairValueObject) aValueObject;
-       // Low order pairs
-       if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_RevolutePairValue)))
-       {
-         Handle(StepKinematics_RevolutePairValue) aRevolutePairValue = Handle(StepKinematics_RevolutePairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetRotation(aRevolutePairValue->ActualRotation());
-       }
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_PrismaticPairValue)))
-       {
-         Handle(StepKinematics_PrismaticPairValue) aPrismaticPairValue = Handle(StepKinematics_PrismaticPairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetTranslation(aPrismaticPairValue->ActualTranslation());
-       }
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_CylindricalPairValue)))
-       {
-         Handle(StepKinematics_CylindricalPairValue) aCylindricalPairValue = Handle(StepKinematics_CylindricalPairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetTranslation(aCylindricalPairValue->ActualTranslation());
-         aValueObject->SetRotation(aCylindricalPairValue->ActualRotation());
-       }
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_SphericalPairValue)))
-       {
-         Handle(StepKinematics_SphericalPairValue) aSphericalPairValue = Handle(StepKinematics_SphericalPairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetYPR(aSphericalPairValue->InputOrientation().YprRotation()->Value(1),
-           aSphericalPairValue->InputOrientation().YprRotation()->Value(2), aSphericalPairValue->InputOrientation().YprRotation()->Value(3));
-       }
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_UniversalPairValue)))
-       {
-         Handle(StepKinematics_UniversalPairValue) aUniversalPairValue = Handle(StepKinematics_UniversalPairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetFirstRotation(aUniversalPairValue->FirstRotationAngle());
-         aValueObject->SetSecondRotation(aUniversalPairValue->SecondRotationAngle()); //CHECK
-       }
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_UnconstrainedPairValue)))
-       {
-         Handle(StepKinematics_UnconstrainedPairValue) anUnconstrainedPairValue = Handle(StepKinematics_UnconstrainedPairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetTransformation(StepToGeom::MakeAxis2Placement(anUnconstrainedPairValue->ActualPlacement())->Ax2());
-       }
-       // Low order pairs with motion coupling
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_ScrewPairValue)))
-       {
-         Handle(StepKinematics_ScrewPairValue) aScrewPairValue = Handle(StepKinematics_ScrewPairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetRotation(aScrewPairValue->ActualRotation());
-       }
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_GearPairValue)))
-       {
-         Handle(StepKinematics_GearPairValue) aGearPairValue = Handle(StepKinematics_GearPairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetRotation(aGearPairValue->ActualRotation1());
-       }
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_RackAndPinionPairValue)))
-       {
-         Handle(StepKinematics_RackAndPinionPairValue) aRackAndPinionPairValue = Handle(StepKinematics_RackAndPinionPairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetTranslation(aRackAndPinionPairValue->ActualDisplacement());
-       }
-       // High order pairs
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_SlidingSurfacePairValue)))
-       {
-         Handle(StepKinematics_SlidingSurfacePairValue) aSlidingSurfacePairValue = Handle(StepKinematics_SlidingSurfacePairValue)::DownCast(anIter.Value());
-         aValueObject= new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetFirstPointOnSurface(aSlidingSurfacePairValue->ActualPointOnSurface1()->PointParameterU(), aSlidingSurfacePairValue->ActualPointOnSurface1()->PointParameterV());
-         aValueObject->SetSecondPointOnSurface(aSlidingSurfacePairValue->ActualPointOnSurface2()->PointParameterU(), aSlidingSurfacePairValue->ActualPointOnSurface2()->PointParameterV());
-         aValueObject->SetRotation(aSlidingSurfacePairValue->ActualRotation());
-       }
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_RollingSurfacePairValue)))
-       {
-         Handle(StepKinematics_RollingSurfacePairValue) aRollingSurfacePairValue = Handle(StepKinematics_RollingSurfacePairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetRotation(aRollingSurfacePairValue->ActualRotation());
-         aValueObject->SetFirstPointOnSurface(aRollingSurfacePairValue->ActualPointOnSurface()->PointParameterU(), aRollingSurfacePairValue->ActualPointOnSurface()->PointParameterV());
-       }
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_SlidingCurvePairValue)))
-       {
-         Handle(StepKinematics_SlidingCurvePairValue) aSlidingCurvePairValue = Handle(StepKinematics_SlidingCurvePairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetFirstPointOnCurve(aSlidingCurvePairValue->ActualPointOnCurve1()->PointParameter());
-         aValueObject->SetSecondPointOnCurve(aSlidingCurvePairValue->ActualPointOnCurve2()->PointParameter());
-       }
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_RollingCurvePairValue)))
-       {
-         Handle(StepKinematics_RollingCurvePairValue) aRollingCurvePairValue = Handle(StepKinematics_RollingCurvePairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetPointOnCurve(aRollingCurvePairValue->ActualPointOnCurve1()->PointParameter());
-       }
-
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_PlanarPairValue)))
-       {
-         Handle(StepKinematics_PlanarPairValue) aPlanarPairValue = Handle(StepKinematics_PlanarPairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetRotation(aPlanarPairValue->ActualRotation());
-         aValueObject->SetFirstTranslation(aPlanarPairValue->ActualTranslationX());
-         aValueObject->SetSecondTranslation(aPlanarPairValue->ActualTranslationY());
-       }
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_PointOnSurfacePairValue)))
-       {
-         Handle(StepKinematics_PointOnSurfacePairValue) aPointOnSurfacePairValue = Handle(StepKinematics_PointOnSurfacePairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetPointOnSurface(aPointOnSurfacePairValue->ActualPointOnSurface()->PointParameterU(), 
-           aPointOnSurfacePairValue->ActualPointOnSurface()->PointParameterV());
-         aValueObject->SetYPR(aPointOnSurfacePairValue->InputOrientation().YprRotation()->Value(1),
-           aPointOnSurfacePairValue->InputOrientation().YprRotation()->Value(2), aPointOnSurfacePairValue->InputOrientation().YprRotation()->Value(3));
-       }
-       else if (anIter.Value()->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePairValue)))
-       {
-         Handle(StepKinematics_PointOnPlanarCurvePairValue) aPointOnPlanarCurvePairValue = Handle(StepKinematics_PointOnPlanarCurvePairValue)::DownCast(anIter.Value());
-         aValueObject = new XCAFKinematics_PairValueObject();
-         aValueObject->SetType(getKinematicType(theKP));
-         aValueObject->SetFirstPointOnCurve(aPointOnPlanarCurvePairValue->ActualPointOnCurve()->PointParameter());
-         aValueObject->SetYPR(aPointOnPlanarCurvePairValue->InputOrientation().YprRotation()->Value(1),
-           aPointOnPlanarCurvePairValue->InputOrientation().YprRotation()->Value(2), aPointOnPlanarCurvePairValue->InputOrientation().YprRotation()->Value(3));
-       }
-       if (!aValueObject.IsNull())
-       {
-         Handle(XCAFDoc_KinematicPairValue) aCAFKinematicPairValue = XCAFDoc_KinematicPairValue::Set(theJoint);
-         aCAFKinematicPairValue->SetObject(aValueObject);
-         return Standard_True;
-       }
-       return Standard_False;
-     }
-   }
-   return Standard_False;
+Standard_Boolean setKinematicPairValue(const Handle(XSControl_WorkSession)& theWS,
+                                       const Handle(TDocStd_Document)& theDoc,
+                                       const XCAFKinematics_PairType aType,
+                                       const Handle(StepKinematics_PairValue)& aValue,
+                                       const TDF_Label& aState,
+                                       const TDF_Label& aJoint)
+{
+  Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
+  Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
+  const Interface_Graph& aGraph = aTP->Graph();
+  Handle(XCAFDoc_KinematicTool) aKTool = XCAFDoc_DocumentTool::KinematicTool(theDoc->Main());
+  Handle(XCAFKinematics_PairValueObject) aValueObject;
+  aValueObject = new XCAFKinematics_PairValueObject();
+  aValueObject->SetType(aType);
+
+  TDF_TagSource aTag;
+  TDF_Label aValueL = aTag.NewChild(aState);
+
+  // Low order pairs
+  if (aValue->IsKind(STANDARD_TYPE(StepKinematics_RevolutePairValue)))
+  {
+    Handle(StepKinematics_RevolutePairValue) aRevolutePairValue = Handle(StepKinematics_RevolutePairValue)::DownCast(aValue);
+    aValueObject->SetRotation(aRevolutePairValue->ActualRotation());
+  }
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_PrismaticPairValue)))
+  {
+    Handle(StepKinematics_PrismaticPairValue) aPrismaticPairValue = Handle(StepKinematics_PrismaticPairValue)::DownCast(aValue);
+    aValueObject->SetTranslation(aPrismaticPairValue->ActualTranslation());
+  }
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_CylindricalPairValue)))
+  {
+    Handle(StepKinematics_CylindricalPairValue) aCylindricalPairValue = Handle(StepKinematics_CylindricalPairValue)::DownCast(aValue);
+    aValueObject->SetTranslation(aCylindricalPairValue->ActualTranslation());
+    aValueObject->SetRotation(aCylindricalPairValue->ActualRotation());
+  }
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_SphericalPairValue)))
+  {
+    Handle(StepKinematics_SphericalPairValue) aSphericalPairValue = Handle(StepKinematics_SphericalPairValue)::DownCast(aValue);
+    aValueObject->SetYPR(aSphericalPairValue->InputOrientation().YprRotation()->Value(1),
+      aSphericalPairValue->InputOrientation().YprRotation()->Value(2), aSphericalPairValue->InputOrientation().YprRotation()->Value(3));
+  }
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_UniversalPairValue)))
+  {
+    Handle(StepKinematics_UniversalPairValue) aUniversalPairValue = Handle(StepKinematics_UniversalPairValue)::DownCast(aValue);
+    aValueObject->SetFirstRotation(aUniversalPairValue->FirstRotationAngle());
+    aValueObject->SetSecondRotation(aUniversalPairValue->SecondRotationAngle()); //CHECK
+  }
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_UnconstrainedPairValue)))
+  {
+    Handle(StepKinematics_UnconstrainedPairValue) anUnconstrainedPairValue = Handle(StepKinematics_UnconstrainedPairValue)::DownCast(aValue);
+    aValueObject->SetTransformation(StepToGeom::MakeAxis2Placement(anUnconstrainedPairValue->ActualPlacement())->Ax2());
+  }
+  // Low order pairs with motion coupling
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_ScrewPairValue)))
+  {
+    Handle(StepKinematics_ScrewPairValue) aScrewPairValue = Handle(StepKinematics_ScrewPairValue)::DownCast(aValue);
+    aValueObject->SetRotation(aScrewPairValue->ActualRotation());
+  }
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_GearPairValue)))
+  {
+    Handle(StepKinematics_GearPairValue) aGearPairValue = Handle(StepKinematics_GearPairValue)::DownCast(aValue);
+    aValueObject->SetRotation(aGearPairValue->ActualRotation1());
+  }
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_RackAndPinionPairValue)))
+  {
+    Handle(StepKinematics_RackAndPinionPairValue) aRackAndPinionPairValue = Handle(StepKinematics_RackAndPinionPairValue)::DownCast(aValue);
+    aValueObject->SetTranslation(aRackAndPinionPairValue->ActualDisplacement());
+  }
+  // High order pairs
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_SlidingSurfacePairValue)))
+  {
+    Handle(StepKinematics_SlidingSurfacePairValue) aSlidingSurfacePairValue = Handle(StepKinematics_SlidingSurfacePairValue)::DownCast(aValue);
+    aValueObject->SetFirstPointOnSurface(aSlidingSurfacePairValue->ActualPointOnSurface1()->PointParameterU(), aSlidingSurfacePairValue->ActualPointOnSurface1()->PointParameterV());
+    aValueObject->SetSecondPointOnSurface(aSlidingSurfacePairValue->ActualPointOnSurface2()->PointParameterU(), aSlidingSurfacePairValue->ActualPointOnSurface2()->PointParameterV());
+    aValueObject->SetRotation(aSlidingSurfacePairValue->ActualRotation());
+  }
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_RollingSurfacePairValue)))
+  {
+    Handle(StepKinematics_RollingSurfacePairValue) aRollingSurfacePairValue = Handle(StepKinematics_RollingSurfacePairValue)::DownCast(aValue);
+    aValueObject->SetRotation(aRollingSurfacePairValue->ActualRotation());
+    aValueObject->SetFirstPointOnSurface(aRollingSurfacePairValue->ActualPointOnSurface()->PointParameterU(), aRollingSurfacePairValue->ActualPointOnSurface()->PointParameterV());
+  }
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_SlidingCurvePairValue)))
+  {
+    Handle(StepKinematics_SlidingCurvePairValue) aSlidingCurvePairValue = Handle(StepKinematics_SlidingCurvePairValue)::DownCast(aValue);
+    aValueObject->SetFirstPointOnCurve(aSlidingCurvePairValue->ActualPointOnCurve1()->PointParameter());
+    aValueObject->SetSecondPointOnCurve(aSlidingCurvePairValue->ActualPointOnCurve2()->PointParameter());
+  }
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_RollingCurvePairValue)))
+  {
+    Handle(StepKinematics_RollingCurvePairValue) aRollingCurvePairValue = Handle(StepKinematics_RollingCurvePairValue)::DownCast(aValue);
+    aValueObject->SetPointOnCurve(aRollingCurvePairValue->ActualPointOnCurve1()->PointParameter());
+  }
+
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_PlanarPairValue)))
+  {
+    Handle(StepKinematics_PlanarPairValue) aPlanarPairValue = Handle(StepKinematics_PlanarPairValue)::DownCast(aValue);
+    aValueObject->SetRotation(aPlanarPairValue->ActualRotation());
+    aValueObject->SetFirstTranslation(aPlanarPairValue->ActualTranslationX());
+    aValueObject->SetSecondTranslation(aPlanarPairValue->ActualTranslationY());
+  }
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_PointOnSurfacePairValue)))
+  {
+    Handle(StepKinematics_PointOnSurfacePairValue) aPointOnSurfacePairValue = Handle(StepKinematics_PointOnSurfacePairValue)::DownCast(aValue);
+    aValueObject->SetPointOnSurface(aPointOnSurfacePairValue->ActualPointOnSurface()->PointParameterU(),
+      aPointOnSurfacePairValue->ActualPointOnSurface()->PointParameterV());
+    aValueObject->SetYPR(aPointOnSurfacePairValue->InputOrientation().YprRotation()->Value(1),
+      aPointOnSurfacePairValue->InputOrientation().YprRotation()->Value(2), aPointOnSurfacePairValue->InputOrientation().YprRotation()->Value(3));
+  }
+  else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePairValue)))
+  {
+    Handle(StepKinematics_PointOnPlanarCurvePairValue) aPointOnPlanarCurvePairValue = Handle(StepKinematics_PointOnPlanarCurvePairValue)::DownCast(aValue);
+    aValueObject->SetFirstPointOnCurve(aPointOnPlanarCurvePairValue->ActualPointOnCurve()->PointParameter());
+    aValueObject->SetYPR(aPointOnPlanarCurvePairValue->InputOrientation().YprRotation()->Value(1),
+      aPointOnPlanarCurvePairValue->InputOrientation().YprRotation()->Value(2), aPointOnPlanarCurvePairValue->InputOrientation().YprRotation()->Value(3));
+  }
+  else
+    return Standard_False;
+  Handle(XCAFDoc_KinematicPairValue) aCAFKinematicPairValue = XCAFDoc_KinematicPairValue::Set(aValueL, aJoint);
+  aCAFKinematicPairValue->SetObject(aValueObject);
+  if (!aValue->Name()->IsEmpty())
+    TDataStd_Name::Set(aValueL, aValue->Name()->ToCString());
+  return Standard_True;
 }
 
 //=======================================================================
@@ -5066,85 +5077,110 @@ Standard_Boolean STEPCAFControl_Reader::ReadKinematics(const Handle(XSControl_Wo
   for (Standard_Integer i = 1; i <= nb; i++)
   {
     Handle(Standard_Transient) anEnt = aModel->Value(i);
-    if (anEnt->IsKind(STANDARD_TYPE(StepKinematics_KinematicPropertyMechanismRepresentation)))
+    if (!anEnt->IsKind(STANDARD_TYPE(StepKinematics_KinematicPropertyMechanismRepresentation)))
+      continue;
+    Handle(StepKinematics_KinematicPropertyMechanismRepresentation) aKPMR =
+      Handle(StepKinematics_KinematicPropertyMechanismRepresentation)::DownCast(anEnt);
+    Handle(StepKinematics_MechanismRepresentation) aKMR =
+      Handle(StepKinematics_MechanismRepresentation)::DownCast(aKPMR->UsedRepresentation());
+    TDF_Label aMechanism;
+    if (aKMR.IsNull())
+      continue;
+
+    aMechanism = aKTool->AddMechanism();
+
+    //Collecting entity of States and labels of States
+    //States and their labels located at a single index
+    if (!aKMR->Name()->IsEmpty())
+      TDataStd_Name::Set(aMechanism, aKMR->Name()->String());
+    TDF_LabelSequence aStates;
+    Handle(TColStd_HArray1OfTransient) aArrayOfStates;
+
+    Interface_EntityIterator anIterStates = aGraph.TypedSharings(aKMR, STANDARD_TYPE(StepKinematics_MechanismStateRepresentation));
+    const Standard_Integer aCountOfStates = anIterStates.NbEntities();
+    Standard_Boolean hasStates = Standard_False;
+    if (aCountOfStates > 0)
+    {
+      aArrayOfStates = new  TColStd_HArray1OfTransient(1, aCountOfStates);
+      hasStates = Standard_True;
+    }
+    for (Standard_Integer indState = 1; anIterStates.More(); anIterStates.Next(), ++indState)
+    {
+      Handle(StepKinematics_MechanismStateRepresentation) aMechanismState = Handle(StepKinematics_MechanismStateRepresentation)::DownCast(anIterStates.Value());
+      TDF_Label aState = aKTool->AddState(aMechanism);
+      if (!aMechanismState->Name().IsNull() && !aMechanismState->Name()->IsEmpty())
+        TDataStd_Name::Set(aState, aMechanismState->Name()->ToCString());
+      aStates.Append(aState);
+      aArrayOfStates->ChangeValue(indState) = aMechanismState;
+    }
+
+    //Collecting Joints and labels of Joints
+    //Joints and their labels located at a single index
+    TColStd_SequenceOfTransient aCollOfLinks;
+    TDF_LabelSequence aSeqOfLinksL;
+
+    //read base link
+    //base link should be first label
+    //if mechanism hasn't a base link, first link became base
+    if (!aKPMR->Base().IsNull())
+    {
+      TDF_Label aLableOfBaseLink;
+      addLinksWithShapes(theWS, theDoc, aKPMR->Base(), aLableOfBaseLink,aMechanism, aCollOfLinks, aSeqOfLinksL, aShapeLabelMap);
+    }
+
+    for (Standard_Integer aPairIndex = 1; aPairIndex <= aKMR->NbItems(); ++aPairIndex)
     {
-      Handle(StepKinematics_KinematicPropertyMechanismRepresentation) aKPMR =
-        Handle(StepKinematics_KinematicPropertyMechanismRepresentation)::DownCast(anEnt);
-      Handle(StepKinematics_MechanismRepresentation) aKMR =
-        Handle(StepKinematics_MechanismRepresentation)::DownCast(aKPMR->UsedRepresentation());
-      TDF_Label aMechanism;
-      if (aKMR.IsNull())
+      if (!aKMR->ItemsValue(aPairIndex)->IsKind(STANDARD_TYPE(StepKinematics_PairRepresentationRelationship)))
+        continue;
+      Handle(StepKinematics_PairRepresentationRelationship) aPRR =
+        Handle(StepKinematics_PairRepresentationRelationship)::DownCast(aKMR->ItemsValue(aPairIndex));
+      if (aPRR.IsNull()) continue;
+      Handle(StepKinematics_KinematicPair) aKinematicPair
+        = Handle(StepKinematics_KinematicPair)::DownCast(aPRR->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair());
+      if (aKinematicPair.IsNull())
+        continue;
+      //find joint & links
+      Handle(StepKinematics_KinematicJoint) aKinematicJoint = aKinematicPair->Joint();
+      if (aKinematicJoint.IsNull())
+        continue;
+      Handle(StepKinematics_KinematicLinkRepresentation) aLinkRepresentation1 = 
+        Handle(StepKinematics_KinematicLinkRepresentation)::DownCast(aPRR->RepresentationRelationshipWithTransformation()->Rep1());
+      Handle(StepKinematics_KinematicLinkRepresentation) aLinkRepresentation2 =
+        Handle(StepKinematics_KinematicLinkRepresentation)::DownCast(aPRR->RepresentationRelationshipWithTransformation()->Rep2());
+      if (aLinkRepresentation1.IsNull() || aLinkRepresentation2.IsNull())
+        continue;
+      TDF_Label aJoint, aLink1, aLink2;
+      if (!addLinksWithShapes(theWS, theDoc, aLinkRepresentation1, aLink1, aMechanism, aCollOfLinks, aSeqOfLinksL, aShapeLabelMap))
+        continue;
+      if (!addLinksWithShapes(theWS, theDoc, aLinkRepresentation2, aLink2, aMechanism, aCollOfLinks, aSeqOfLinksL, aShapeLabelMap))
+        continue;
+      //Setting info
+      aJoint = aKTool->AddJoint(aMechanism, aLink1, aLink2);
+      Handle(XCAFDoc_KinematicPair) aCAFKinPair = XCAFDoc_KinematicPair::Set(aJoint);
+      Handle(XCAFKinematics_PairObject) aPairObject = createXCAFKinematicPairObject(aKinematicPair);
+      if (aPairObject.IsNull())
         continue;
-      aMechanism = aKTool->AddMechanism();
-      if (!aKMR->Name()->IsEmpty())
-        TDataStd_Name::Set(aMechanism, aKMR->Name()->String());
-      for (Standard_Integer aMechanismIndex = 1 ; aMechanismIndex <=aKMR->NbItems();++aMechanismIndex)
+      setKinematicPairLimits(aPairObject, aKinematicPair);
+      aCAFKinPair->SetObject(aPairObject);
+
+      //Set Values of Joint on the OCAF
+      for (Standard_Integer IndState = 1; hasStates && IndState <= aArrayOfStates->Length(); ++IndState)
       {
-        if (!aKMR->ItemsValue(aMechanismIndex)->IsKind(STANDARD_TYPE(StepKinematics_PairRepresentationRelationship)))
-          continue;
-        Handle(StepKinematics_PairRepresentationRelationship) aPRR =
-          Handle(StepKinematics_PairRepresentationRelationship)::DownCast(aKMR->ItemsValue(aMechanismIndex));
-        if (aPRR.IsNull()) continue;
-        Handle(StepKinematics_KinematicPair) aKinematicPair
-          = Handle(StepKinematics_KinematicPair)::DownCast(aPRR->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair());
-        if (aKinematicPair.IsNull()) 
-          continue;
-        //find joint & links
-        Handle(StepKinematics_KinematicJoint) aKinematicJoint = aKinematicPair->Joint();
-        if (aKinematicJoint.IsNull())
-          continue;
-        Handle(StepKinematics_KinematicLink) aKinematicLinkStart, aKinematicLinkEnd;
-        TDF_Label aJoint, aLinkStart, aLinkEnd;
-        TDF_LabelSequence aShapeArrayStart, aShapeArrayEnd;
-        //lins inizialise
-        aKinematicLinkStart = Handle(StepKinematics_KinematicLink)::DownCast(aKinematicJoint->EdgeStart());
-        aKinematicLinkEnd = Handle(StepKinematics_KinematicLink)::DownCast(aKinematicJoint->EdgeEnd());
-        //for the start
-        Handle(StepKinematics_KinematicLinkRepresentation) aLinkRepresentationStart
-          = Handle(StepKinematics_KinematicLinkRepresentation)::DownCast(aPRR->RepresentationRelationshipWithTransformation()->Rep1());
-        if (aLinkRepresentationStart.IsNull()) continue;
-        Handle(StepKinematics_KinematicLinkRepresentationAssociation) aKLRepresentationAssociationStart;
-        for (Interface_EntityIterator anIterLinks = aGraph.Sharings(aLinkRepresentationStart);
-          anIterLinks.More() && aKLRepresentationAssociationStart.IsNull(); anIterLinks.Next())
+        Handle(StepKinematics_MechanismStateRepresentation) aMechanismState =
+          Handle(StepKinematics_MechanismStateRepresentation)::DownCast(aArrayOfStates->Value(IndState));
+        for (Standard_Integer IndValue = 1; IndValue <= aMechanismState->Items()->Length(); ++IndValue)
         {
-          if (!anIterLinks.Value()->IsKind(STANDARD_TYPE(StepKinematics_KinematicLinkRepresentationAssociation)))
-            continue;
-          aKLRepresentationAssociationStart = Handle(StepKinematics_KinematicLinkRepresentationAssociation)::DownCast(anIterLinks.Value());
-        }
-        if (aKLRepresentationAssociationStart.IsNull()) 
-          continue;
-        linkShapeWithJoint(theWS, theDoc, aKLRepresentationAssociationStart, aShapeArrayStart, aShapeLabelMap);
-        //for the end
-        Handle(StepKinematics_KinematicLinkRepresentation) aLinkRepresentationEnd
-          = Handle(StepKinematics_KinematicLinkRepresentation)::DownCast(aPRR->RepresentationRelationshipWithTransformation()->Rep2());;
-        if (aLinkRepresentationEnd.IsNull()) continue;
-        Handle(StepKinematics_KinematicLinkRepresentationAssociation) aKLRepresentationAssociationEnd;
-        for (Interface_EntityIterator anIterLinks = aGraph.Sharings(aLinkRepresentationEnd);
-          anIterLinks.More() && aKLRepresentationAssociationEnd.IsNull(); anIterLinks.Next())
-        {
-          if (!anIterLinks.Value()->IsKind(STANDARD_TYPE(StepKinematics_KinematicLinkRepresentationAssociation)))
-            continue;
-          aKLRepresentationAssociationEnd = Handle(StepKinematics_KinematicLinkRepresentationAssociation)::DownCast(anIterLinks.Value());
+          Handle(StepKinematics_PairValue) aValue = Handle(StepKinematics_PairValue)::DownCast(aMechanismState->Items()->Value(IndValue));
+          Handle(StepKinematics_KinematicJoint) aRefJoint =
+            Handle(StepKinematics_KinematicJoint)::DownCast(aValue->AppliesToPair()->Joint());
+          if (aRefJoint == aKinematicJoint)
+          {
+            setKinematicPairValue(theWS, theDoc, aPairObject->Type(), aValue, aStates.Value(IndState), aJoint);
+          }
         }
-        if (aKLRepresentationAssociationEnd.IsNull()) continue;
-        linkShapeWithJoint(theWS, theDoc, aKLRepresentationAssociationEnd, aShapeArrayEnd, aShapeLabelMap);
-        //Setting info
-        aLinkStart = aKTool->AddLink(aMechanism, aShapeArrayStart);
-        if (!aKinematicLinkStart->Name()->IsEmpty())
-          TDataStd_Name::Set(aLinkStart, aKinematicLinkStart->Name()->String());
-        aLinkEnd = aKTool->AddLink(aMechanism, aShapeArrayEnd);
-        if (!aKinematicLinkEnd->Name()->IsEmpty())
-          TDataStd_Name::Set(aLinkEnd, aKinematicLinkEnd->Name()->String());
-        aJoint = aKTool->AddJoint(aMechanism, aLinkStart, aLinkEnd);
-        Handle(XCAFDoc_KinematicPair) aCAFKinPair = XCAFDoc_KinematicPair::Set(aJoint);
-        Handle(XCAFKinematics_PairObject) aPairObject = createXCAFKinematicPairObject(aKinematicPair);
-        if (aPairObject.IsNull())
-          continue;
-        setKinematicPairLimits(aPairObject, aKinematicPair);
-        aCAFKinPair->SetObject(aPairObject);
-        setKinematicPairValue(theWS, theDoc, aKinematicPair, aJoint);
       }
     }
+
   }
   return Standard_True;
 }
index 74aeb3971af75b9bde5c91514bba6e5768070416..5de3d3146e420ea4ecd14d9db68ecd99ca23cbc3 100644 (file)
 #include <StepVisual_SurfaceStyleUsage.hxx>
 #include <StepVisual_TessellatedAnnotationOccurrence.hxx>
 #include <StepVisual_TessellatedGeometricSet.hxx>
+//
+//
+//
+#include <StepKinematics_KinematicJoint.hxx>
+#include <StepKinematics_KinematicLink.hxx>
+#include <StepKinematics_PairValue.hxx>
+#include <StepKinematics_KinematicPropertyMechanismRepresentation.hxx>
+#include <StepKinematics_MechanismRepresentation.hxx>
+#include <StepKinematics_PairRepresentationRelationship.hxx>
+#include <StepKinematics_KinematicPair.hxx>
+#include <StepKinematics_KinematicJoint.hxx>
+#include <StepKinematics_PairValue.hxx>
+#include <XCAFDoc_KinematicPairValue.hxx>
+#include <StepKinematics_KinematicLink.hxx>
+#include <XCAFDoc_KinematicTool.hxx>
+#include <XCAFKinematics_PairObject.hxx>
+#include <StepKinematics_KinematicLinkRepresentationAssociation.hxx>
+#include <StepKinematics_ActuatedKinematicPair.hxx>
+#include <StepKinematics_RigidLinkRepresentation.hxx>
+#include <StepKinematics_KinematicTopologyStructure.hxx>
+#include <StepShape_Vertex.hxx>
+#include <XCAFKinematics_PairValueObject.hxx>
+#include <StepKinematics_KinematicLinkRepresentation.hxx>
+#include <StepKinematics_ProductDefinitionKinematics.hxx>
+#include <StepKinematics_SuParameters.hxx>
+#include <NCollection_Vector.hxx>
+#include <StepKinematics_ContextDependentKinematicLinkRepresentation.hxx>
+#include <StepKinematics_KinematicLinkRepresentationAssociation.hxx>
+#include <StepKinematics_ProductDefinitionRelationshipKinematics.hxx>
+
+#include <StepKinematics_CylindricalPair.hxx>
+#include <StepKinematics_CylindricalPairWithRange.hxx>
+#include <StepKinematics_FullyConstrainedPair.hxx>
+#include <StepKinematics_GearPair.hxx>
+#include <StepKinematics_GearPairWithRange.hxx>
+#include <StepKinematics_HomokineticPair.hxx>
+#include <StepKinematics_KinematicTopologyStructure.hxx>
+#include <StepKinematics_LowOrderKinematicPair.hxx>
+#include <StepKinematics_LowOrderKinematicPairWithRange.hxx>
+#include <StepKinematics_PlanarCurvePair.hxx>
+#include <StepKinematics_PlanarCurvePairRange.hxx>
+#include <StepKinematics_PlanarPair.hxx>
+#include <StepKinematics_PlanarPairWithRange.hxx>
+#include <StepKinematics_PointOnPlanarCurvePair.hxx>
+#include <StepKinematics_PointOnPlanarCurvePairWithRange.hxx>
+#include <StepKinematics_PointOnSurfacePair.hxx>
+#include <StepKinematics_PointOnSurfacePairWithRange.hxx>
+#include <StepKinematics_PrismaticPair.hxx>
+#include <StepKinematics_PrismaticPairWithRange.hxx>
+#include <StepKinematics_ProductDefinitionKinematics.hxx>
+#include <StepKinematics_RackAndPinionPair.hxx>
+#include <StepKinematics_RackAndPinionPairWithRange.hxx>
+#include <StepKinematics_RevolutePair.hxx>
+#include <StepKinematics_RevolutePairWithRange.hxx>
+#include <StepKinematics_RollingCurvePair.hxx>
+#include <StepKinematics_RollingSurfacePair.hxx>
+#include <StepKinematics_ScrewPair.hxx>
+#include <StepKinematics_ScrewPairWithRange.hxx>
+#include <StepKinematics_SlidingCurvePair.hxx>
+#include <StepKinematics_SlidingSurfacePair.hxx>
+#include <StepKinematics_SphericalPair.hxx>
+#include <StepKinematics_SphericalPairWithPin.hxx>
+#include <StepKinematics_SphericalPairWithPinAndRange.hxx>
+#include <StepKinematics_SphericalPairWithRange.hxx>
+#include <StepKinematics_SurfacePairWithRange.hxx>
+#include <StepKinematics_UnconstrainedPair.hxx>
+#include <StepKinematics_UnconstrainedPairValue.hxx>
+#include <StepKinematics_UniversalPair.hxx>
+#include <StepKinematics_UniversalPairWithRange.hxx>
+#include <XCAFKinematics_LowOrderPairObject.hxx>
+#include <XCAFKinematics_LowOrderPairObjectWithCoupling.hxx>
+#include <XCAFKinematics_HighOrderPairObject.hxx>
+
+#include <StepKinematics_SlidingSurfacePairValue.hxx>
+#include <StepKinematics_RollingSurfacePairValue.hxx>
+#include <StepKinematics_RevolutePairValue.hxx>
+#include <StepKinematics_PrismaticPairValue.hxx>
+#include <StepKinematics_ScrewPairValue.hxx>
+#include <StepKinematics_CylindricalPairValue.hxx>
+#include <StepKinematics_SphericalPairValue.hxx>
+#include <StepKinematics_SlidingCurvePairValue.hxx>
+#include <StepKinematics_RollingCurvePairValue.hxx>
+#include <StepKinematics_GearPairValue.hxx>
+#include <StepKinematics_RackAndPinionPairValue.hxx>
+#include <StepKinematics_UniversalPairValue.hxx>
+#include <StepKinematics_PlanarPairValue.hxx>
+#include <StepKinematics_UnconstrainedPairValue.hxx>
+#include <StepKinematics_PointOnSurfacePairValue.hxx>
+#include <StepKinematics_PointOnPlanarCurvePairValue.hxx>
+#include <StepKinematics_LinearFlexibleAndPinionPair.hxx>
+#include <StepKinematics_LinearFlexibleAndPlanarCurvePair.hxx>
+#include <StepKinematics_ActuatedKinPairAndOrderKinPair.hxx>
+#include <StepKinematics_MechanismStateRepresentation.hxx>
+
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_HAsciiString.hxx>
 #include <TColStd_HArray1OfReal.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <TopoDS_Shape.hxx>
 #include <TopTools_MapOfShape.hxx>
+#include <GeomToStep_MakeSurface.hxx>
+#include <GeomToStep_MakeCurve.hxx>
+#include <GeomToStep_MakeRectangularTrimmedSurface.hxx>
 #include <TopTools_SequenceOfShape.hxx>
 #include <Transfer_ActorOfFinderProcess.hxx>
 #include <Transfer_Binder.hxx>
 #include <TransferBRep.hxx>
 #include <TransferBRep_ShapeMapper.hxx>
 #include <XCAFDimTolObjects_DatumObject.hxx>
+#include <XCAFKinematics_PairObject.hxx>
+#include <XCAFKinematics_PairValueObject.hxx>
+#include <XCAFKinematics_PairType.hxx>
+#include <XCAFKinematics_HighOrderPairObject.hxx>
+#include <XCAFKinematics_LowOrderPairObject.hxx>
+#include <XCAFKinematics_LowOrderPairObjectWithCoupling.hxx>
+#include <XCAFDoc_KinematicTool.hxx>
+#include <XCAFDoc_KinematicPairValue.hxx>
+#include <XCAFDoc_KinematicPair.hxx>
 #include <XCAFDimTolObjects_DimensionFormVariance.hxx>
 #include <XCAFDimTolObjects_DimensionGrade.hxx>
 #include <XCAFDimTolObjects_DimensionObject.hxx>
@@ -280,7 +386,8 @@ STEPCAFControl_Writer::STEPCAFControl_Writer () :
        myPropsMode( Standard_True ),
        mySHUOMode ( Standard_True ),
        myGDTMode  ( Standard_True ),
-       myMatMode  ( Standard_True )
+       myMatMode  ( Standard_True ),
+       myKPairMode( Standard_True )
 {
   STEPCAFControl_Controller::Init();
   Handle(XSControl_WorkSession) WS = new XSControl_WorkSession;
@@ -301,7 +408,8 @@ STEPCAFControl_Writer::STEPCAFControl_Writer (const Handle(XSControl_WorkSession
   myPropsMode(Standard_True),
   mySHUOMode(Standard_True),
   myGDTMode(Standard_True),
-  myMatMode(Standard_True)
+  myMatMode(Standard_True),
+  myKPairMode(Standard_True)
 {
   STEPCAFControl_Controller::Init();
   Init ( WS, scratch );
@@ -641,6 +749,10 @@ Standard_Boolean STEPCAFControl_Writer::Transfer (STEPControl_Writer &writer,
       }
     }
 
+    // write Kinematic Pair
+    if (GetKinematicsMode())
+      WriteKinematics(writer.WS(), sublabels);
+
     // write Materials
     if(GetMaterialMode())
       WriteMaterials(writer.WS(),sublabels);
@@ -1756,6 +1868,33 @@ static Standard_Boolean getProDefinitionOfNAUO(const Handle(XSControl_WorkSessio
   return Standard_True;
 }
 
+//=======================================================================
+//function : getProDefinitionOfNAUO
+//purpose  : auxilary
+//=======================================================================
+static Standard_Boolean getProDefi(const Handle(XSControl_WorkSession)& WS,
+  const TopoDS_Shape& theShape,
+  Handle(StepRepr_ProductDefinitionShape)& PD)
+{
+  if (theShape.IsNull())
+    return Standard_False;
+  // get CDSR
+  const Handle(XSControl_TransferWriter)& TW = WS->TransferWriter();
+  const Handle(Transfer_FinderProcess)& FP = TW->FinderProcess();
+  Handle(StepShape_ContextDependentShapeRepresentation) CDSR;
+  Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper(FP, theShape);
+  if (!FP->FindTypedTransient(mapper,
+    STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation),
+    CDSR))
+    return Standard_False;
+  // get PDS of NAUO
+  Handle(StepRepr_ProductDefinitionShape) PDS = CDSR->RepresentedProductRelation();
+  if (PDS.IsNull())
+    return Standard_False;
+  PD = PDS;
+  return Standard_True;
+}
+
 
 //=======================================================================
 //function : writeSHUO
@@ -2084,6 +2223,1047 @@ Standard_Boolean STEPCAFControl_Writer::WriteSHUOs (const Handle(XSControl_WorkS
   return Standard_True;
 }
 
+//=======================================================================
+//function : createKinematicLink
+//purpose  : auxilary
+//=======================================================================
+static Standard_Boolean createKinematicLink(const Handle(Transfer_FinderProcess)& FP,
+  const Handle(XCAFDoc_KinematicTool)& aKTool,
+  Handle(StepKinematics_KinematicLink)& theLink,
+  const Interface_Graph& aGraph,
+  const TDF_Label& theLabelLink,
+  Handle(StepShape_ShapeRepresentation)& aShapeRepr,
+  Handle(StepRepr_NextAssemblyUsageOccurrence)& NAUO)
+{
+  theLink = new StepKinematics_KinematicLink;
+
+  Handle(TDataStd_Name) aNameLinkStart;
+  theLabelLink.FindAttribute(TDataStd_Name::GetID(), aNameLinkStart);
+  Handle(TCollection_HAsciiString) aHNameLinkStart = new TCollection_HAsciiString(aNameLinkStart->Get()); 
+  theLink->Init(aHNameLinkStart);
+
+  // find ref shapes
+  TDF_LabelSequence aShapesStartL = aKTool->GetRefShapes(theLabelLink);
+  if (aShapesStartL.IsEmpty()) return Standard_False;
+  TopoDS_Shape aTopoShapeStart = XCAFDoc_ShapeTool::GetShape(aShapesStartL.Value(1));
+  TopLoc_Location aLocStart;
+  TColStd_SequenceOfTransient seqRI;
+  FindEntities(FP, aTopoShapeStart, aLocStart, seqRI);
+  if (seqRI.Length() <= 0) {
+    FP->Messenger()->SendInfo() << "Warning: Cannot find RI for " << aTopoShapeStart.TShape()->DynamicType()->Name() << std::endl;
+    return Standard_False;
+  }
+  Interface_EntityIterator anIter = aGraph.Sharings(seqRI.Value(1));
+  for (anIter.Start(); anIter.More() && aShapeRepr.IsNull(); anIter.Next())
+  {
+    aShapeRepr = Handle(StepShape_ShapeRepresentation)::DownCast(anIter.Value());
+  }
+  Handle(StepShape_ContextDependentShapeRepresentation) CDSR;
+  Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper(FP, aTopoShapeStart);
+  if (!FP->FindTypedTransient(mapper,
+    STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation),
+    CDSR))
+    return Standard_False;
+  // get PDS of NAUO
+  Handle(StepRepr_ProductDefinitionShape) PDS = CDSR->RepresentedProductRelation();
+  if (PDS.IsNull())
+    return Standard_False;
+  // get the NAUO entity
+  Interface_EntityIterator subs = aGraph.Shareds(PDS);
+  for (subs.Start(); subs.More(); subs.Next()) {
+    if (!subs.Value()->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence)))
+      continue;
+    NAUO = Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(subs.Value());
+    break;
+  }
+  if (NAUO.IsNull())
+    return Standard_False;
+  return Standard_True;
+}
+
+//=======================================================================
+//function : createKinematicJoint
+//purpose  : auxilary
+//=======================================================================
+static Standard_Boolean createKinematicJoint(const Handle(Transfer_FinderProcess)& FP,
+  const Handle(XCAFDoc_KinematicTool)& aKTool,
+  const Interface_Graph& aGraph,
+  const TDF_Label& theLabelJoint,
+  const Handle(XCAFKinematics_PairObject)& aKinPairObj,
+  TDF_LabelSequence& aSeqOfLinskL,
+  Handle(StepKinematics_RigidLinkRepresentation)& aRigLinkRepr1,
+  Handle(StepKinematics_RigidLinkRepresentation)& aRigLinkRepr2,
+  Handle(TColStd_HArray1OfTransient)& aArrayOfRigidLinks,
+  Handle(StepKinematics_KinematicJoint)& theJoint)
+{
+  TDF_Label aLinkStartL, aLinkEndL;
+  theJoint = new StepKinematics_KinematicJoint;
+  aKTool->GetLinksOfJoint(theLabelJoint, aLinkStartL, aLinkEndL);
+  Handle(TCollection_HAsciiString) aNameJoint = new TCollection_HAsciiString(aKinPairObj->Name());
+
+  Handle(TDataStd_Name) aNameLinkStart;
+  aLinkStartL.FindAttribute(TDataStd_Name::GetID(), aNameLinkStart);
+
+  Handle(TDataStd_Name) aNameLinkEnd;
+  aLinkEndL.FindAttribute(TDataStd_Name::GetID(), aNameLinkEnd);
+  Handle(StepShape_Vertex) aEdgeStart;
+  Handle(StepShape_Vertex) aEdgeEnd;
+
+  //find represent of link in the containers
+  //link and their label has single index
+  Standard_Integer aLinkInd;
+  for (aLinkInd = 1; (aLinkInd <= aArrayOfRigidLinks->Length()) && (aEdgeStart.IsNull() || aEdgeEnd.IsNull()); ++aLinkInd)
+  {
+    if (aSeqOfLinskL(aLinkInd) == aLinkStartL)
+    {
+      aRigLinkRepr1 = Handle(StepKinematics_RigidLinkRepresentation)::DownCast(aArrayOfRigidLinks->Value(aLinkInd));
+      aEdgeStart = aRigLinkRepr1->RepresentedLink();
+    }
+    else if (aSeqOfLinskL(aLinkInd) == aLinkEndL)
+    {
+      aRigLinkRepr2 = Handle(StepKinematics_RigidLinkRepresentation)::DownCast(aArrayOfRigidLinks->Value(aLinkInd));
+      aEdgeEnd = aRigLinkRepr2->RepresentedLink();
+    }
+  }
+  if (aEdgeEnd.IsNull() || aEdgeStart.IsNull())
+    return Standard_False;
+  theJoint->Init(aNameJoint, aEdgeStart, aEdgeEnd);
+
+
+  return Standard_True;
+}
+
+//=======================================================================
+//function : createKinematicPair
+//purpose  : auxilary
+//=======================================================================
+static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObject)& aKinPairObj,
+  Handle(StepKinematics_KinematicPair)& aKinematicPair,
+  const Handle(StepKinematics_KinematicJoint)& theJoint,
+  const TDF_LabelSequence& aSeqOfLinskL,
+  Handle(StepKinematics_RigidLinkRepresentation)& aRigLinkRepr1,
+  Handle(StepKinematics_RigidLinkRepresentation)& aRigLinkRepr2,
+  const Handle(TColStd_HArray1OfTransient)& aArrayOfRigidLinks)
+{
+  if (aKinPairObj->Type() == XCAFKinematics_PairType_NoType)
+    return Standard_False;
+  Handle(StepRepr_RepresentationItem) theTransformItem1 = GeomToStep_MakeAxis2Placement3d(aKinPairObj->FirstTransformation()).Value();
+  Handle(StepRepr_RepresentationItem) theTransformItem2 = GeomToStep_MakeAxis2Placement3d(aKinPairObj->SecondTransformation()).Value();
+
+  aRigLinkRepr1->Items()->Resize(aRigLinkRepr1->Items()->Lower(), aRigLinkRepr1->Items()->Upper() + 1, Standard_True);
+  aRigLinkRepr1->Items()->ChangeLast() = theTransformItem1;
+
+  aRigLinkRepr2->Items()->Resize(aRigLinkRepr2->Items()->Lower(), aRigLinkRepr2->Items()->Upper() + 1, Standard_True);
+  aRigLinkRepr2->Items()->ChangeLast() = theTransformItem1;
+
+  Standard_Boolean hasDescription = Standard_False;
+  Handle(TCollection_HAsciiString) aPairName = new TCollection_HAsciiString(aKinPairObj->Name());
+  Handle(TCollection_HAsciiString) aDescription;
+  Standard_Boolean HasRange = aKinPairObj->HasLimits();
+  if (aKinPairObj->IsKind(STANDARD_TYPE(XCAFKinematics_LowOrderPairObject)))
+  {
+    Handle(XCAFKinematics_LowOrderPairObject) aLowOrderPairObj = Handle(XCAFKinematics_LowOrderPairObject)::DownCast(aKinPairObj);
+    Standard_Boolean aTX = Standard_True;
+    Standard_Boolean aTY = Standard_True;
+    Standard_Boolean aTZ = Standard_True;
+    Standard_Boolean aRX = Standard_True;
+    Standard_Boolean aRY = Standard_True;
+    Standard_Boolean aRZ = Standard_True;
+    switch (aKinPairObj->Type())
+    {
+    case(XCAFKinematics_PairType_Revolute):
+    {
+      aTX = Standard_False;
+      aTY = Standard_False;
+      aTZ = Standard_False;
+      aRX = Standard_False;
+      aRY = Standard_False;
+      if (HasRange)
+      {
+        aKinematicPair = new StepKinematics_RevolutePairWithRange;
+        Standard_Real aLowerLimitActualRotation = aLowOrderPairObj->MinRotationZ();
+        Standard_Real aUpperLimitActualRotation = aLowOrderPairObj->MaxRotationZ();
+        aRZ = Standard_True;
+        Handle(StepKinematics_RevolutePairWithRange) aRevolutePairWithRange = Handle(StepKinematics_RevolutePairWithRange)::DownCast(aKinematicPair);
+        aRevolutePairWithRange->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, aLowerLimitActualRotation, Standard_True, aUpperLimitActualRotation);
+      }
+      else
+      {
+        aKinematicPair = new StepKinematics_RevolutePair;
+        Handle(StepKinematics_RevolutePair) aRevolutePair = Handle(StepKinematics_RevolutePair)::DownCast(aKinematicPair);
+        aRevolutePair->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ);
+      }
+      break;
+    }
+    case(XCAFKinematics_PairType_Prismatic):
+    {
+      aTY = Standard_False;
+      aTZ = Standard_False;
+      aRX = Standard_False;
+      aRY = Standard_False;
+      aRZ = Standard_False;
+      if (HasRange)
+      {
+        aKinematicPair = new StepKinematics_PrismaticPairWithRange;
+        Handle(StepKinematics_PrismaticPairWithRange) aPrismaticPairWithRange = Handle(StepKinematics_PrismaticPairWithRange)::DownCast(aKinematicPair);
+        Standard_Real aUpperLimitActualTranslation = aLowOrderPairObj->MaxTranslationX();
+        Standard_Real aLowerLimitActualTranslation = aLowOrderPairObj->MinTranslationX();
+        aPrismaticPairWithRange->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, aLowerLimitActualTranslation, Standard_True, aUpperLimitActualTranslation);
+      }
+      else
+      {
+        aKinematicPair = new StepKinematics_PrismaticPair;
+        Handle(StepKinematics_PrismaticPair) aPrismaticPair = Handle(StepKinematics_PrismaticPair)::DownCast(aKinematicPair);
+        aPrismaticPair->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ);
+      }
+      break;
+    }
+    case(XCAFKinematics_PairType_Cylindrical):
+    {
+      aTX = Standard_False;
+      aTY = Standard_False;
+      aRX = Standard_False;
+      aRY = Standard_False;
+      if (HasRange)
+      {
+        aKinematicPair = new StepKinematics_CylindricalPairWithRange;
+        Handle(StepKinematics_CylindricalPairWithRange) aCylindricalPairWithRange = Handle(StepKinematics_CylindricalPairWithRange)::DownCast(aKinematicPair);
+        Standard_Real aUpperLimitActualTranslation = aLowOrderPairObj->MaxTranslationZ();
+        Standard_Real aLowerLimitActualTranslation = aLowOrderPairObj->MinTranslationZ();
+        Standard_Real aLowerLimitActualRotation = aLowOrderPairObj->MinRotationZ();
+        Standard_Real aUpperLimitActualRotation = aLowOrderPairObj->MaxRotationZ();
+        aCylindricalPairWithRange->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, aLowerLimitActualTranslation, Standard_True,
+          aUpperLimitActualTranslation, Standard_True, aLowerLimitActualRotation, Standard_True, aUpperLimitActualRotation);
+      }
+      else
+      {
+        aKinematicPair = new StepKinematics_CylindricalPair;
+        Handle(StepKinematics_CylindricalPair) aCylindricalPair = Handle(StepKinematics_CylindricalPair)::DownCast(aKinematicPair);
+        aCylindricalPair->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ);
+      }
+      break;
+    }
+    case(XCAFKinematics_PairType_Universal):
+    {
+      aTX = Standard_False;
+      aTY = Standard_False;
+      aTZ = Standard_False;
+      aRY = Standard_False;
+      Standard_Real theUniversalPair_InputSkewAngle = aLowOrderPairObj->SkewAngle();
+      if (HasRange)
+      {
+        aKinematicPair = new StepKinematics_UniversalPairWithRange;
+        Handle(StepKinematics_UniversalPairWithRange) anUniversalPairWithRange = Handle(StepKinematics_UniversalPairWithRange)::DownCast(aKinematicPair);
+        Standard_Real aUpperLimitActualTranslationX = aLowOrderPairObj->MaxTranslationX();
+        Standard_Real aLowerLimitActualTranslationX = aLowOrderPairObj->MinTranslationX();
+        Standard_Real aUpperLimitActualTranslationZ = aLowOrderPairObj->MaxTranslationZ();
+        Standard_Real aLowerLimitActualTranslationZ = aLowOrderPairObj->MinTranslationZ();
+        anUniversalPairWithRange->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, theUniversalPair_InputSkewAngle, Standard_True, aLowerLimitActualTranslationX, Standard_True,
+          aUpperLimitActualTranslationX, Standard_True, aLowerLimitActualTranslationZ, Standard_True, aUpperLimitActualTranslationZ);
+      }
+      else
+      {
+        aKinematicPair = new StepKinematics_UniversalPair;
+        Handle(StepKinematics_UniversalPair) anUniversalPair = Handle(StepKinematics_UniversalPair)::DownCast(aKinematicPair);
+        anUniversalPair->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, theUniversalPair_InputSkewAngle);
+      }
+      break;
+    }
+    case(XCAFKinematics_PairType_SphericalWithPin):
+    {
+      aTX = Standard_False;
+      aTY = Standard_False;
+      aTZ = Standard_False;
+      aRX = Standard_False;
+      aRY = Standard_False;
+      if (HasRange)
+      {
+        Standard_Real aUpperLimitYaw = aLowOrderPairObj->MaxRotationZ();
+        Standard_Real aLowerLimitYaw = aLowOrderPairObj->MinRotationZ();
+        Standard_Real aUpperLimitRoll = aLowOrderPairObj->MaxRotationX();
+        Standard_Real aLowerLimitRoll = aLowOrderPairObj->MinRotationX();
+        aKinematicPair = new StepKinematics_SphericalPairWithPinAndRange;
+        Handle(StepKinematics_SphericalPairWithPinAndRange) aSphericalPairWithPinAndRange = Handle(StepKinematics_SphericalPairWithPinAndRange)::DownCast(aKinematicPair);
+        aSphericalPairWithPinAndRange->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, aLowerLimitYaw, Standard_True,
+          aUpperLimitYaw, Standard_True, aLowerLimitRoll, Standard_True, aUpperLimitRoll);
+      }
+      else
+      {
+        aKinematicPair = new StepKinematics_SphericalPairWithPin;
+        Handle(StepKinematics_SphericalPairWithPin) aSphericalPairWithPin = Handle(StepKinematics_SphericalPairWithPin)::DownCast(aKinematicPair);
+        aSphericalPairWithPin->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ);
+      }
+      break;
+    }
+    case(XCAFKinematics_PairType_Spherical):
+    {
+      aTX = Standard_False;
+      aTY = Standard_False;
+      aTZ = Standard_False;
+      if (HasRange)
+      {
+        Standard_Real aUpperLimitYaw = aLowOrderPairObj->MaxRotationZ();
+        Standard_Real aLowerLimitYaw = aLowOrderPairObj->MinRotationZ();
+        Standard_Real aUpperLimitRoll = aLowOrderPairObj->MaxRotationX();
+        Standard_Real aLowerLimitRoll = aLowOrderPairObj->MinRotationX();
+        Standard_Real aUpperLimitPitch = aLowOrderPairObj->MaxRotationY();
+        Standard_Real aLowerLimitPitch= aLowOrderPairObj->MinRotationY();
+        aKinematicPair = new StepKinematics_SphericalPairWithRange;
+        Handle(StepKinematics_SphericalPairWithRange) aSphericalPairWithRange = Handle(StepKinematics_SphericalPairWithRange)::DownCast(aKinematicPair);
+        aSphericalPairWithRange->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, aLowerLimitYaw, Standard_True,
+          aUpperLimitYaw, Standard_True, aLowerLimitRoll, Standard_True, aUpperLimitRoll, Standard_True, aLowerLimitPitch, Standard_True, aUpperLimitPitch);
+      }
+      else
+      {
+        aKinematicPair = new StepKinematics_SphericalPair;
+        Handle(StepKinematics_SphericalPair) aSphericalPair = Handle(StepKinematics_SphericalPair)::DownCast(aKinematicPair);
+        aSphericalPair->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ);
+      }
+      break;
+    }
+    case(XCAFKinematics_PairType_Planar):
+    {
+      if (HasRange)
+        aKinematicPair = new StepKinematics_PlanarPairWithRange;
+      else
+        aKinematicPair = new StepKinematics_PlanarPair;
+
+      aTZ = Standard_False;
+      aRX = Standard_False;
+      aRY = Standard_False;
+      if (HasRange)
+      {
+        aKinematicPair = new StepKinematics_PlanarPairWithRange;
+        Handle(StepKinematics_PlanarPairWithRange) aPlanarPairWithRange = Handle(StepKinematics_PlanarPairWithRange)::DownCast(aKinematicPair);
+        Standard_Real aUpperLimitActualTranslationX = aLowOrderPairObj->MaxTranslationX();
+        Standard_Real aLowerLimitActualTranslationX = aLowOrderPairObj->MinTranslationX();
+        Standard_Real aUpperLimitActualTranslationY = aLowOrderPairObj->MaxTranslationY();
+        Standard_Real aLowerLimitActualTranslationY = aLowOrderPairObj->MinTranslationY();
+        Standard_Real aLowerLimitActualRotation = aLowOrderPairObj->MinRotationZ();
+        Standard_Real aUpperLimitActualRotation = aLowOrderPairObj->MaxRotationZ();
+        aPlanarPairWithRange->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, aLowerLimitActualTranslationX, Standard_True, aUpperLimitActualTranslationX, 
+          Standard_True, aLowerLimitActualTranslationY, Standard_True, aUpperLimitActualTranslationY,
+          Standard_True, aLowerLimitActualRotation, Standard_True, aUpperLimitActualRotation);
+      }
+      else
+      {
+        aKinematicPair = new StepKinematics_PlanarPair;
+        Handle(StepKinematics_PlanarPair) aPlanarPair = Handle(StepKinematics_PlanarPair)::DownCast(aKinematicPair);
+        aPlanarPair->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,
+          aTX, aTY, aTZ, aRX, aRY, aRZ);
+      }
+      break;
+    }
+    case(XCAFKinematics_PairType_Unconstrained):
+    {
+      aKinematicPair = new StepKinematics_LowOrderKinematicPairWithRange;
+
+      Standard_Real aUpperLimitActualTranslationX = aLowOrderPairObj->MaxTranslationX();
+      Standard_Real aLowerLimitActualTranslationX = aLowOrderPairObj->MinTranslationX();
+      Standard_Real aUpperLimitActualTranslationY = aLowOrderPairObj->MaxTranslationY();
+      Standard_Real aLowerLimitActualTranslationY = aLowOrderPairObj->MinTranslationY();
+      Standard_Real aUpperLimitActualTranslationZ = aLowOrderPairObj->MaxTranslationZ();
+      Standard_Real aLowerLimitActualTranslationZ = aLowOrderPairObj->MinTranslationZ();
+      Standard_Real aLowerLimitActualRotationX = aLowOrderPairObj->MinRotationX();
+      Standard_Real aUpperLimitActualRotationX = aLowOrderPairObj->MaxRotationX();
+      Standard_Real aLowerLimitActualRotationY = aLowOrderPairObj->MinRotationY();
+      Standard_Real aUpperLimitActualRotationY = aLowOrderPairObj->MaxRotationY();
+      Standard_Real aLowerLimitActualRotationZ = aLowOrderPairObj->MinRotationZ();
+      Standard_Real aUpperLimitActualRotationZ = aLowOrderPairObj->MaxRotationZ();
+      Handle(StepKinematics_LowOrderKinematicPairWithRange) anUnconstrainedPairWithRange = Handle(StepKinematics_LowOrderKinematicPairWithRange)::DownCast(aKinematicPair);
+      anUnconstrainedPairWithRange->Init(aPairName, aPairName, hasDescription,
+        aDescription, theTransformItem1, theTransformItem2, theJoint,
+        aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, aLowerLimitActualTranslationX, Standard_True, aUpperLimitActualTranslationX,
+        Standard_True, aLowerLimitActualTranslationY, Standard_True, aUpperLimitActualTranslationY,
+        Standard_True, aLowerLimitActualTranslationZ, Standard_True, aUpperLimitActualTranslationZ,
+        Standard_True, aLowerLimitActualRotationX, Standard_True, aUpperLimitActualRotationX,
+        Standard_True, aLowerLimitActualRotationY, Standard_True, aUpperLimitActualRotationY,
+        Standard_True, aLowerLimitActualRotationZ, Standard_True, aUpperLimitActualRotationZ);
+      break;
+    }
+    case(XCAFKinematics_PairType_FullyConstrained):
+    {
+      aKinematicPair = new StepKinematics_FullyConstrainedPair;
+      Handle(StepKinematics_FullyConstrainedPair) aFullyConstrainedPair = Handle(StepKinematics_FullyConstrainedPair)::DownCast(aKinematicPair);
+      aFullyConstrainedPair->Init(aPairName, aPairName, hasDescription,
+        aDescription, theTransformItem1, theTransformItem2, theJoint,
+        aTX, aTY, aTZ, aRX, aRY, aRZ);
+      break;
+    }
+    case(XCAFKinematics_PairType_Homokinetic):
+    {
+      aTX = Standard_False;
+      aTY = Standard_False;
+      aTZ = Standard_False;
+      aRY = Standard_False;
+      Standard_Real InputSkewAngle = aLowOrderPairObj->SkewAngle();
+      aKinematicPair = new StepKinematics_HomokineticPair;
+      Handle(StepKinematics_HomokineticPair) aHomokineticPair = Handle(StepKinematics_HomokineticPair)::DownCast(aKinematicPair);
+      aHomokineticPair->Init(aPairName, aPairName, hasDescription,
+        aDescription, theTransformItem1, theTransformItem2, theJoint,
+        aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, InputSkewAngle);
+      break;
+    }
+    default:
+      return Standard_False;
+      break;
+    }
+    return Standard_True;
+  }
+  else if (aKinPairObj->IsKind(STANDARD_TYPE(XCAFKinematics_LowOrderPairObjectWithCoupling)))
+  {
+  Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) aLowOrderPairObjectWithCoupling = Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(aKinPairObj);
+    switch (aKinPairObj->Type())
+    {
+    case(XCAFKinematics_PairType_Screw):
+    {
+      Standard_Real aPitch = aLowOrderPairObjectWithCoupling->Pitch();
+      if (HasRange)
+      {
+        aKinematicPair = new StepKinematics_ScrewPairWithRange;
+        Handle(StepKinematics_ScrewPairWithRange) aScrewPairWithRange = Handle(StepKinematics_ScrewPairWithRange)::DownCast(aKinematicPair);
+        Standard_Real aLowLimit = aLowOrderPairObjectWithCoupling->LowLimit();
+        Standard_Real aUpperLimit = aLowOrderPairObjectWithCoupling->UpperLimit();
+        aScrewPairWithRange->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,aPitch,
+          Standard_True, aLowLimit, Standard_True, aUpperLimit);
+      }
+      else
+      {
+        aKinematicPair = new StepKinematics_ScrewPair;
+        Handle(StepKinematics_ScrewPair) aScrewPair = Handle(StepKinematics_ScrewPair)::DownCast(aKinematicPair);
+        aScrewPair->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,aPitch);
+      }
+      break;
+    }
+    case(XCAFKinematics_PairType_RackAndPinion):
+    {
+      Standard_Real aPinionRadius = aLowOrderPairObjectWithCoupling->PinionRadius();
+      if (HasRange)
+      {
+        aKinematicPair = new StepKinematics_RackAndPinionPairWithRange;
+        Standard_Real aLowLimit = aLowOrderPairObjectWithCoupling->LowLimit();
+        Standard_Real aUpperLimit = aLowOrderPairObjectWithCoupling->UpperLimit();
+        Handle(StepKinematics_RackAndPinionPairWithRange) aRackAndPinionPairWithRange = Handle(StepKinematics_RackAndPinionPairWithRange)::DownCast(aKinematicPair);
+        aRackAndPinionPairWithRange->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint, aPinionRadius,
+          Standard_True, aLowLimit, Standard_True, aUpperLimit);
+      }
+      else
+      { 
+        aKinematicPair = new StepKinematics_RackAndPinionPair;
+        Handle(StepKinematics_RackAndPinionPair) aRackAndPinionPair = Handle(StepKinematics_RackAndPinionPair)::DownCast(aKinematicPair);
+        aRackAndPinionPair->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint, aPinionRadius);
+      }
+
+      break;
+    }
+    case(XCAFKinematics_PairType_Gear):
+    {
+      Standard_Real aBevel = aLowOrderPairObjectWithCoupling->Bevel();
+      Standard_Real aGearRatio = aLowOrderPairObjectWithCoupling->GearRatio();
+      Standard_Real aHelicalAngle = aLowOrderPairObjectWithCoupling->HelicalAngle();
+      Standard_Real aRadiusFirstLink = aLowOrderPairObjectWithCoupling->RadiusFirstLink();;
+      Standard_Real aRadiusSecondLink = aLowOrderPairObjectWithCoupling->RadiusSecondLink();;
+      if (HasRange)
+      {
+        Standard_Real aLowLimit = aLowOrderPairObjectWithCoupling->LowLimit();
+        Standard_Real aUpperLimit = aLowOrderPairObjectWithCoupling->UpperLimit();
+        aKinematicPair = new StepKinematics_GearPairWithRange;
+        Handle(StepKinematics_GearPairWithRange) aGearPairWithRange = Handle(StepKinematics_GearPairWithRange)::DownCast(aKinematicPair);
+        aGearPairWithRange->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint, aRadiusFirstLink, aRadiusSecondLink, aBevel, aHelicalAngle, aGearRatio,
+          Standard_True, aLowLimit, Standard_True, aUpperLimit);
+      }
+      else
+      {
+        aKinematicPair = new StepKinematics_GearPair;
+        Handle(StepKinematics_GearPair) aGearPair = Handle(StepKinematics_GearPair)::DownCast(aKinematicPair);
+        aGearPair->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,aRadiusFirstLink,aRadiusSecondLink,aBevel,aHelicalAngle, aGearRatio);
+      }
+      break;
+    }
+    case(XCAFKinematics_PairType_LinearFlexibleAndPinion):
+    {
+      Standard_Real aPinionRadius = aLowOrderPairObjectWithCoupling->PinionRadius();
+      aKinematicPair = new StepKinematics_LinearFlexibleAndPinionPair;
+      Handle(StepKinematics_LinearFlexibleAndPinionPair) aLinearFlexibleAndPinionPair = Handle(StepKinematics_LinearFlexibleAndPinionPair)::DownCast(aKinematicPair);
+      aLinearFlexibleAndPinionPair->Init(aPairName, aPairName, hasDescription,
+        aDescription, theTransformItem1, theTransformItem2, theJoint, aPinionRadius);
+      break;
+    }
+    default:
+      return Standard_False;
+      break;
+    }
+    return Standard_True;
+  }
+  else if (aKinPairObj->IsKind(STANDARD_TYPE(XCAFKinematics_HighOrderPairObject))) //need to fix
+  {
+  Handle(XCAFKinematics_HighOrderPairObject) aHighOrderPairObject = Handle(XCAFKinematics_HighOrderPairObject)::DownCast(aKinPairObj);
+    switch (aKinPairObj->Type())
+    {
+    case(XCAFKinematics_PairType_PointOnSurface):
+    {
+      GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface());
+      Handle(StepGeom_Surface) aPairSurface = aMaker.Value();
+      if (HasRange)
+      {
+        return Standard_False;
+        Standard_Real aLowerLimitYaw = aHighOrderPairObject->LowLimitYaw();
+        Standard_Real aUpperLimitYaw = aHighOrderPairObject->UpperLimitYaw();
+        Standard_Real aLowerLimitPitch = aHighOrderPairObject->LowLimitPitch();
+        Standard_Real aUpperLimitPitch = aHighOrderPairObject->UpperLimitPitch();
+        Standard_Real aLowerLimitRoll = aHighOrderPairObject->LowLimitRoll();
+        Standard_Real aUpperLimitRoll = aHighOrderPairObject->UpperLimitRoll();
+        //GeomToStep_MakeRectangularTrimmedSurface aTrimSurface;
+        Handle(StepGeom_RectangularTrimmedSurface) aRangeOnPairSurface; /*= aHighOrderPairObject->Surface();*/
+        aKinematicPair = new StepKinematics_PointOnSurfacePairWithRange;
+        Handle(StepKinematics_PointOnSurfacePairWithRange) aPointOnSurfacePairWithRange = Handle(StepKinematics_PointOnSurfacePairWithRange)::DownCast(aKinematicPair);
+        aPointOnSurfacePairWithRange->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint, aPairSurface,aRangeOnPairSurface, Standard_True, aLowerLimitYaw, Standard_True, aUpperLimitYaw, Standard_True,
+          aLowerLimitPitch, Standard_True, aUpperLimitPitch, Standard_True, aLowerLimitRoll, Standard_True, aUpperLimitRoll);
+      }
+      else
+      {
+        aKinematicPair = new StepKinematics_PointOnSurfacePair;
+        Handle(StepKinematics_PointOnSurfacePair) aPointOnSurface = Handle(StepKinematics_PointOnSurfacePair)::DownCast(aKinematicPair);
+        aPointOnSurface->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint,aPairSurface);
+      }
+      break;
+    }
+    case(XCAFKinematics_PairType_SlidingSurface):
+    {
+      aKinematicPair = new StepKinematics_SlidingSurfacePair;
+      GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface());
+      Handle(StepGeom_Surface) aPairSurfac1 = aMaker.Value();
+      GeomToStep_MakeSurface aMaker2(aHighOrderPairObject->Surface());
+      Handle(StepGeom_Surface) aPairSurface2 = aMaker2.Value();
+      Standard_Boolean anOrientation = aHighOrderPairObject->Orientation();
+      Handle(StepKinematics_SlidingSurfacePair) aSlidingSurfacePair = Handle(StepKinematics_SlidingSurfacePair)::DownCast(aKinematicPair);
+      aSlidingSurfacePair->Init(aPairName, aPairName, hasDescription,
+        aDescription, theTransformItem1, theTransformItem2, theJoint, aPairSurfac1, aPairSurface2, anOrientation);
+      break;
+    }
+    case(XCAFKinematics_PairType_RollingSurface):
+    {
+      aKinematicPair = new StepKinematics_RollingSurfacePair;
+      GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface());
+      Handle(StepGeom_Surface) aPairSurfac1 = aMaker.Value();
+      GeomToStep_MakeSurface aMaker2(aHighOrderPairObject->Surface());
+      Handle(StepGeom_Surface) aPairSurface2 = aMaker2.Value();
+      Standard_Boolean anOrientation = aHighOrderPairObject->Orientation();
+      Handle(StepKinematics_RollingSurfacePair) aRollingSurfacePair = Handle(StepKinematics_RollingSurfacePair)::DownCast(aKinematicPair);
+      aRollingSurfacePair->Init(aPairName, aPairName, hasDescription,
+        aDescription, theTransformItem1, theTransformItem2, theJoint, aPairSurfac1, aPairSurface2, anOrientation);
+      break;
+    }
+    case(XCAFKinematics_PairType_PointOnPlanarCurve):
+    {
+      GeomToStep_MakeCurve aMaker(aHighOrderPairObject->Curve());
+      Handle(StepGeom_Curve) aPairCurve = aMaker.Value();
+      Standard_Boolean anOrientation = aHighOrderPairObject->Orientation();
+      if (HasRange)
+      {
+        return Standard_False;
+        Standard_Real aLowerLimitYaw = aHighOrderPairObject->LowLimitYaw();
+        Standard_Real aUpperLimitYaw = aHighOrderPairObject->UpperLimitYaw();
+        Standard_Real aLowerLimitPitch = aHighOrderPairObject->LowLimitPitch();
+        Standard_Real aUpperLimitPitch = aHighOrderPairObject->UpperLimitPitch();
+        Standard_Real aLowerLimitRoll = aHighOrderPairObject->LowLimitRoll();
+        Standard_Real aUpperLimitRoll = aHighOrderPairObject->UpperLimitRoll();
+        Handle(StepGeom_TrimmedCurve) aRangeOnPairCurve; /*= aHighOrderPairObject->Curve();*/
+        aKinematicPair = new StepKinematics_PointOnPlanarCurvePairWithRange;
+        Handle(StepKinematics_PointOnPlanarCurvePairWithRange) aPointOnPlanarCurvePairWithRange = Handle(StepKinematics_PointOnPlanarCurvePairWithRange)::DownCast(aKinematicPair);
+        aPointOnPlanarCurvePairWithRange->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint, aPairCurve, anOrientation, aRangeOnPairCurve,Standard_True,aLowerLimitYaw, Standard_True,aUpperLimitYaw, Standard_True,
+          aLowerLimitPitch, Standard_True, aUpperLimitPitch, Standard_True,aLowerLimitRoll, Standard_True, aUpperLimitRoll);
+      }
+      else
+      {
+        aKinematicPair = new StepKinematics_PointOnPlanarCurvePair;
+        Handle(StepKinematics_PointOnPlanarCurvePair) aPointOnPlanarCurvePair = Handle(StepKinematics_PointOnPlanarCurvePair)::DownCast(aKinematicPair);
+        aPointOnPlanarCurvePair->Init(aPairName, aPairName, hasDescription,
+          aDescription, theTransformItem1, theTransformItem2, theJoint, aPairCurve, anOrientation);
+      }
+      break;
+    }
+    case(XCAFKinematics_PairType_SlidingCurve): 
+    {
+      GeomToStep_MakeCurve aMaker(aHighOrderPairObject->Curve());
+      Handle(StepGeom_Curve) aPairCurve = aMaker.Value();
+      Standard_Boolean anOrientation = aHighOrderPairObject->Orientation();
+      GeomToStep_MakeCurve aMaker2(aHighOrderPairObject->Curve());
+      Handle(StepGeom_Curve) aPairCurve2 = aMaker2.Value();
+      aKinematicPair = new StepKinematics_SlidingCurvePair;
+      Handle(StepKinematics_SlidingCurvePair) aSlidingCurvePair = Handle(StepKinematics_SlidingCurvePair)::DownCast(aKinematicPair);
+      aSlidingCurvePair->Init(aPairName, aPairName, hasDescription,
+        aDescription, theTransformItem1, theTransformItem2, theJoint, aPairCurve, aPairCurve2, anOrientation);
+      break;
+    }
+    case(XCAFKinematics_PairType_RollingCurve):
+    {
+      GeomToStep_MakeCurve aMaker(aHighOrderPairObject->Curve());
+      Handle(StepGeom_Curve) aPairCurve = aMaker.Value();
+      Standard_Boolean anOrientation = aHighOrderPairObject->Orientation();
+      GeomToStep_MakeCurve aMaker2(aHighOrderPairObject->Curve());
+      Handle(StepGeom_Curve) aPairCurve2 = aMaker2.Value();
+      aKinematicPair = new StepKinematics_RollingCurvePair;
+      Handle(StepKinematics_RollingCurvePair) aRollingCurvePair = Handle(StepKinematics_RollingCurvePair)::DownCast(aKinematicPair);
+      aRollingCurvePair->Init(aPairName, aPairName, hasDescription,
+        aDescription, theTransformItem1, theTransformItem2, theJoint, aPairCurve, aPairCurve2, anOrientation);
+      break;
+    }
+    case(XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve):
+    {
+      aKinematicPair = new StepKinematics_LinearFlexibleAndPlanarCurvePair;
+      GeomToStep_MakeCurve aMaker(aHighOrderPairObject->Curve());
+      Handle(StepGeom_Curve) aPairCurve = aMaker.Value();
+      Standard_Boolean anOrientation = aHighOrderPairObject->Orientation();
+      Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair) aLinearFlexibleAndPlanarCurvePair = Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair)::DownCast(aKinematicPair);
+      aLinearFlexibleAndPlanarCurvePair->Init(aPairName, aPairName, hasDescription,
+        aDescription, theTransformItem1, theTransformItem2, theJoint, aPairCurve, anOrientation);
+      break;
+    }
+    default:
+      return Standard_False;
+      break;
+    }
+    return Standard_True;
+  }
+
+  return Standard_False;
+}
+
+static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_PairValueObject)& aKinPairValueObj,
+  Handle(StepKinematics_PairValue)& aPairValue,
+  const Handle(StepKinematics_PairRepresentationRelationship)& aPairReprRelationship)
+{
+  if (aKinPairValueObj->Type() == XCAFKinematics_PairType_NoType)
+    return Standard_False;
+
+
+  switch (aKinPairValueObj->Type())
+  {
+  case(XCAFKinematics_PairType_Revolute):
+  {
+    aPairValue = new StepKinematics_RevolutePairValue;
+    Handle(StepKinematics_RevolutePairValue) aRevolutePairValue = 
+      Handle(StepKinematics_RevolutePairValue)::DownCast(aPairValue);
+    aRevolutePairValue->SetActualRotation(aKinPairValueObj->GetRotation());
+    break;
+  }
+  case(XCAFKinematics_PairType_Prismatic):
+  {
+    aPairValue = new StepKinematics_PrismaticPairValue;
+    Handle(StepKinematics_PrismaticPairValue) aPrismaticPairValue = 
+      Handle(StepKinematics_PrismaticPairValue)::DownCast(aPairValue);
+    aPrismaticPairValue->SetActualTranslation(aKinPairValueObj->GetTranslation());
+    break;
+  }
+  case(XCAFKinematics_PairType_Cylindrical):
+  {
+    aPairValue = new StepKinematics_CylindricalPairValue;
+    Handle(StepKinematics_CylindricalPairValue) aCylindricalPairValue = 
+      Handle(StepKinematics_CylindricalPairValue)::DownCast(aPairValue);
+    aCylindricalPairValue->SetActualTranslation(aKinPairValueObj->GetTranslation());
+    aCylindricalPairValue->SetActualRotation(aKinPairValueObj->GetRotation());
+    break;
+  }
+  case(XCAFKinematics_PairType_Universal):
+  {
+    aPairValue = new StepKinematics_UniversalPairValue;
+    Handle(StepKinematics_UniversalPairValue) aUniversalPairValue = 
+      Handle(StepKinematics_UniversalPairValue)::DownCast(aPairValue);
+    aUniversalPairValue->SetFirstRotationAngle(aKinPairValueObj->GetFirstRotation());
+    aUniversalPairValue->SetSecondRotationAngle(aKinPairValueObj->GetSecondRotation());
+    break;
+  }
+  case(XCAFKinematics_PairType_Spherical):
+  {
+    aPairValue = new StepKinematics_SphericalPairValue;
+    Handle(StepKinematics_SphericalPairValue) aSphericalPairValue = 
+      Handle(StepKinematics_SphericalPairValue)::DownCast(aPairValue);
+    StepKinematics_SpatialRotation InputRotation;
+    InputRotation.SetValue(aKinPairValueObj->GetAllValues());
+    aSphericalPairValue->SetInputOrientation(InputRotation);
+    break;
+  }
+  case(XCAFKinematics_PairType_Planar):
+  {
+    aPairValue = new StepKinematics_PlanarPairValue;
+    Handle(StepKinematics_PrismaticPairValue) aPrismaticPairValue = 
+      Handle(StepKinematics_PrismaticPairValue)::DownCast(aPairValue);
+    aPrismaticPairValue->SetActualTranslation(aKinPairValueObj->GetTranslation());
+    break;
+  }
+  case(XCAFKinematics_PairType_Unconstrained):
+  {
+    aPairValue = new StepKinematics_UnconstrainedPairValue;
+    Handle(StepKinematics_UnconstrainedPairValue) anUnconstrainedPairValue = 
+      Handle(StepKinematics_UnconstrainedPairValue)::DownCast(aPairValue);
+    GeomToStep_MakeAxis2Placement3d anActualPlacement(aKinPairValueObj->GetTransformation());
+    anUnconstrainedPairValue->SetActualPlacement(anActualPlacement.Value());
+    break;
+  }
+  case(XCAFKinematics_PairType_Screw):
+  {
+    aPairValue = new StepKinematics_ScrewPairValue;
+    Handle(StepKinematics_ScrewPairValue) aScrewPairValue = 
+      Handle(StepKinematics_ScrewPairValue)::DownCast(aPairValue);
+    aScrewPairValue->SetActualRotation(aKinPairValueObj->GetRotation());
+    break;
+  }
+  case(XCAFKinematics_PairType_RackAndPinion):
+  {
+    aPairValue = new StepKinematics_RackAndPinionPairValue;
+    Handle(StepKinematics_RackAndPinionPairValue) aRackAndPinionPairValue = 
+      Handle(StepKinematics_RackAndPinionPairValue)::DownCast(aPairValue);
+    aRackAndPinionPairValue->SetActualDisplacement(aKinPairValueObj->GetTranslation());
+    break;
+  }
+  case(XCAFKinematics_PairType_Gear):
+  {
+    aPairValue = new StepKinematics_GearPairValue;
+    Handle(StepKinematics_GearPairValue) aGearPairValue = 
+      Handle(StepKinematics_GearPairValue)::DownCast(aPairValue);
+    aGearPairValue->SetActualRotation1(aKinPairValueObj->GetRotation());
+    break;
+  }
+  case(XCAFKinematics_PairType_PointOnSurface):
+  {
+    aPairValue = new StepKinematics_PointOnSurfacePairValue;
+    Handle(StepKinematics_PointOnSurfacePairValue) aPointOnSurfacePairValue = 
+      Handle(StepKinematics_PointOnSurfacePairValue)::DownCast(aPairValue);
+    Handle(StepGeom_PointOnSurface) aActualPointOnSurface = new StepGeom_PointOnSurface;
+    Handle(StepKinematics_PointOnSurfacePair) aPointOnSurfacePair = 
+      Handle(StepKinematics_PointOnSurfacePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair());
+    Standard_Real theU;
+    Standard_Real theV;
+    aKinPairValueObj->GetPointOnSurface(theU, theV);
+    aActualPointOnSurface->Init(aPairValue->Name(), aPointOnSurfacePair->PairSurface(), theU, theV);
+    aPointOnSurfacePairValue->SetActualPointOnSurface(aActualPointOnSurface);
+    StepKinematics_SpatialRotation aYRP;
+    Handle(TColStd_HArray1OfReal) anArrayYRP = new TColStd_HArray1OfReal(1,3);
+    Standard_Real aYaw;
+    Standard_Real aPitch;
+    Standard_Real aRoll;
+    aKinPairValueObj->GetYPR(aYaw, aPitch, aRoll);
+    anArrayYRP->SetValue(1, aYaw);
+    anArrayYRP->SetValue(2, aPitch);
+    anArrayYRP->SetValue(3, aRoll);
+    aYRP.SetValue(anArrayYRP);
+    aPointOnSurfacePairValue->SetInputOrientation(aYRP);
+    break;
+  }
+  case(XCAFKinematics_PairType_SlidingSurface):
+  {
+    aPairValue = new StepKinematics_SlidingSurfacePairValue;
+    Handle(StepKinematics_SlidingSurfacePairValue) aSlidingSurfacePairValue =
+      Handle(StepKinematics_SlidingSurfacePairValue)::DownCast(aPairValue);
+    Handle(StepGeom_PointOnSurface) aActualPointOnSurface1 = new StepGeom_PointOnSurface;
+    Handle(StepKinematics_SlidingSurfacePair) SlidingSurfacePair =
+      Handle(StepKinematics_SlidingSurfacePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair());
+    Standard_Real theU1;
+    Standard_Real theV1;
+    aKinPairValueObj->GetFirstPointOnSurface(theU1, theV1);
+    aActualPointOnSurface1->Init(aPairValue->Name(), SlidingSurfacePair->Surface1(), theU1, theV1);
+    aSlidingSurfacePairValue->SetActualPointOnSurface1(aActualPointOnSurface1);
+    Handle(StepGeom_PointOnSurface) aActualPointOnSurface2 = new StepGeom_PointOnSurface;
+    Standard_Real theU2;
+    Standard_Real theV2;
+    aKinPairValueObj->GetSecondPointOnSurface(theU2, theV2);
+    aActualPointOnSurface2->Init(aPairValue->Name(), SlidingSurfacePair->Surface2(), theU2, theV2);
+    aSlidingSurfacePairValue->SetActualPointOnSurface2(aActualPointOnSurface2);
+    break;
+  }
+  case(XCAFKinematics_PairType_RollingSurface):
+  {
+    aPairValue = new StepKinematics_RollingSurfacePairValue;
+    Handle(StepKinematics_RollingSurfacePairValue) aRollingSurfacePairValue =
+      Handle(StepKinematics_RollingSurfacePairValue)::DownCast(aPairValue);
+    aRollingSurfacePairValue->SetActualRotation(aKinPairValueObj->GetRotation());
+    Handle(StepGeom_PointOnSurface) aActualPointOnSurface = new StepGeom_PointOnSurface;
+    Handle(StepKinematics_RollingSurfacePair) aRollingSurfacePair =
+      Handle(StepKinematics_RollingSurfacePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation());
+    Standard_Real theU;
+    Standard_Real theV;
+    aKinPairValueObj->GetPointOnSurface(theU, theV);
+    aActualPointOnSurface->Init(aPairValue->Name(), aRollingSurfacePair->Surface1(), theU, theV);
+    aRollingSurfacePairValue->SetActualPointOnSurface(aActualPointOnSurface);
+    break;
+  }
+  case(XCAFKinematics_PairType_PointOnPlanarCurve):
+  {
+    aPairValue = new StepKinematics_PointOnPlanarCurvePairValue;
+    Handle(StepKinematics_PointOnPlanarCurvePairValue) aPointOnPlanarCurvePairValue =
+      Handle(StepKinematics_PointOnPlanarCurvePairValue)::DownCast(aPairValue);
+    StepKinematics_SpatialRotation aYRP;
+    Handle(TColStd_HArray1OfReal) anArrayYRP = new TColStd_HArray1OfReal(1, 3);
+    Standard_Real aYaw;
+    Standard_Real aPitch;
+    Standard_Real aRoll;
+    aKinPairValueObj->GetYPR(aYaw, aPitch, aRoll);
+    anArrayYRP->SetValue(1, aYaw);
+    anArrayYRP->SetValue(2, aPitch);
+    anArrayYRP->SetValue(3, aRoll);
+    aYRP.SetValue(anArrayYRP);
+    aPointOnPlanarCurvePairValue->SetInputOrientation(aYRP);
+    Handle(StepGeom_PointOnCurve) anActualPointOnCurve = new StepGeom_PointOnCurve;
+    Handle(StepKinematics_PointOnPlanarCurvePair) aPointOnPlanarCurvePair =
+      Handle(StepKinematics_PointOnPlanarCurvePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair());
+    Standard_Real aParametr = aKinPairValueObj->GetPointOnCurve();
+    anActualPointOnCurve->Init(aPointOnPlanarCurvePair->Name(), aPointOnPlanarCurvePair->PairCurve(), aParametr);
+    aPointOnPlanarCurvePairValue->SetActualPointOnCurve(anActualPointOnCurve);
+    break;
+  }
+  case(XCAFKinematics_PairType_SlidingCurve):
+  {
+    aPairValue = new StepKinematics_SlidingCurvePairValue;
+    Handle(StepKinematics_SlidingCurvePairValue) aSlidingCurvePairValue = 
+      Handle(StepKinematics_SlidingCurvePairValue)::DownCast(aPairValue);
+    Handle(StepGeom_PointOnCurve) anActualPointOnCurve1 = new StepGeom_PointOnCurve;
+    Handle(StepKinematics_SlidingCurvePair) aSlidingCurvePair =
+      Handle(StepKinematics_SlidingCurvePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair());
+    Standard_Real aParametr1 = aKinPairValueObj->GetFirstPointOnCurve();
+    anActualPointOnCurve1->Init(aSlidingCurvePair->Name(), aSlidingCurvePair->Curve1(), aParametr1);
+    aSlidingCurvePairValue->SetActualPointOnCurve1(anActualPointOnCurve1);
+    break;
+  }
+  case(XCAFKinematics_PairType_RollingCurve):
+  {
+    aPairValue = new StepKinematics_RollingCurvePairValue;
+    Handle(StepKinematics_RollingCurvePairValue) aRollingCurvePairValue =
+      Handle(StepKinematics_RollingCurvePairValue)::DownCast(aPairValue);
+    Handle(StepGeom_PointOnCurve) anActualPointOnCurve = new StepGeom_PointOnCurve;
+    Handle(StepKinematics_RollingCurvePair) aRollingCurvePair =
+      Handle(StepKinematics_RollingCurvePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation());
+    Standard_Real aParametr = aKinPairValueObj->GetPointOnCurve();
+    anActualPointOnCurve->Init(aRollingCurvePair->Name(), aRollingCurvePair->Curve1(), aParametr);
+    aRollingCurvePairValue->SetActualPointOnCurve1(anActualPointOnCurve);
+    break; 
+  }
+  default:
+    return Standard_False;
+    break;
+  }
+  Handle(StepKinematics_KinematicPair) aAppliesToPair =
+    Handle(StepKinematics_KinematicPair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair());
+  aPairValue->SetAppliesToPair(aAppliesToPair);
+  aPairValue->SetName(aAppliesToPair->Name());
+  return Standard_True;
+}
+
+Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels)
+{
+
+  if (labels.Length() <= 0) return Standard_False;
+
+  // get working data
+  const Handle(Interface_InterfaceModel)& Model = WS->Model();
+  const Handle(XSControl_TransferWriter)& TW = WS->TransferWriter();
+  const Handle(Transfer_FinderProcess)& FP = TW->FinderProcess();
+
+  const Handle(Interface_HGraph) aHGraph = WS->HGraph();
+  if (aHGraph.IsNull())
+    return Standard_False;
+
+  Interface_Graph aGraph = aHGraph->Graph();
+  Handle(XCAFDoc_KinematicTool) aKTool = XCAFDoc_DocumentTool::KinematicTool(labels(1));
+  if (aKTool.IsNull()) 
+    return Standard_False;
+
+  TDF_LabelSequence aMechanismsL;
+
+  aMechanismsL.Clear();
+  aMechanismsL = aKTool->GetMechanisms();
+  if (aMechanismsL.Length() <= 0) return Standard_False;
+
+  Standard_Integer aMechInd;
+  for (aMechInd = 1; aMechInd <= aMechanismsL.Length(); aMechInd++)
+  {
+    //write Links
+    Handle(StepKinematics_KinematicLinkRepresentation) aBaseLinksOfMech;
+    Handle(StepRepr_NextAssemblyUsageOccurrence) aGeneralNAUO;
+
+    //containers storing Links and their labels located at a single index
+    TDF_LabelSequence aSeqOfLinskL = aKTool->GetLinks(aMechanismsL.Value(aMechInd));
+    if (aSeqOfLinskL.Length() <= 0)
+      return Standard_False;
+    Handle(TColStd_HArray1OfTransient) aArrayOfRigidLinks = new TColStd_HArray1OfTransient(1, aSeqOfLinskL.Length());
+
+    for (Standard_Integer aLinkInd = 1; aLinkInd <= aSeqOfLinskL.Length(); aLinkInd++)
+    {
+      TDF_Label aLinkL = aSeqOfLinskL.Value(aLinkInd);
+      Handle(StepKinematics_KinematicLink) aLink;
+      Handle(StepShape_ShapeRepresentation) aRefShapeOfLink;
+      Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO;
+      createKinematicLink(FP, aKTool, aLink, aGraph, aLinkL, aRefShapeOfLink, NAUO);
+      Handle(StepRepr_RepresentationContext) aRepresentationContextOfLink = aRefShapeOfLink->ContextOfItems();
+      Handle(StepKinematics_RigidLinkRepresentation) aLinkRepresentation = new StepKinematics_RigidLinkRepresentation;
+      Handle(TCollection_HAsciiString) aNameOfLinkRepr = new TCollection_HAsciiString("");
+      Handle(StepRepr_HArray1OfRepresentationItem) aPlacementsOfPairs = new StepRepr_HArray1OfRepresentationItem;
+      aLinkRepresentation->Init(aNameOfLinkRepr, aPlacementsOfPairs, aRepresentationContextOfLink, aLink);
+      aArrayOfRigidLinks->SetValue(aLinkInd, aLinkRepresentation);
+      Handle(StepKinematics_KinematicLinkRepresentationAssociation) aLinkRepresentationAssociation = new StepKinematics_KinematicLinkRepresentationAssociation;
+      aLinkRepresentationAssociation->Init(aNameOfLinkRepr, aNameOfLinkRepr, aRefShapeOfLink, aLinkRepresentation);
+      Handle(StepKinematics_ContextDependentKinematicLinkRepresentation) aCDKLRS = new StepKinematics_ContextDependentKinematicLinkRepresentation;
+      Handle(StepKinematics_ProductDefinitionRelationshipKinematics) aPDRK = new StepKinematics_ProductDefinitionRelationshipKinematics;
+      StepRepr_CharacterizedDefinition aDefinition;
+      aDefinition.SetValue(NAUO);
+      aGeneralNAUO = NAUO; //Work, but think out
+      aPDRK->Init(aNameOfLinkRepr, Standard_False, aLinkRepresentationAssociation->Description(), aDefinition);
+      aCDKLRS->Init(aLinkRepresentationAssociation, aPDRK);
+      Model->AddEntity(aLink);
+      Model->AddEntity(aLinkRepresentation);
+      Model->AddEntity(aLinkRepresentationAssociation);
+      Model->AddEntity(aPDRK);
+      Model->AddEntity(aCDKLRS);
+    }
+    aBaseLinksOfMech = Handle(StepKinematics_KinematicLinkRepresentation)::DownCast(aArrayOfRigidLinks->Value(1));
+
+    //write joints
+
+    //containers storing Joints and their labels located at a single index
+    //any joint corresponds a unique pair with the same index
+    TDF_LabelSequence aSeqOfJointsL = aKTool->GetJoints(aMechanismsL.Value(aMechInd));
+    if (aSeqOfJointsL.Length() <= 0) 
+      return Standard_False;
+    Handle(TColStd_HArray1OfTransient) aArrayOfJoints = new TColStd_HArray1OfTransient(1, aSeqOfJointsL.Length());
+    Handle(StepRepr_HArray1OfRepresentationItem) anArrayOfPairs = new StepRepr_HArray1OfRepresentationItem(1, aSeqOfJointsL.Length());
+
+    Handle(StepKinematics_KinematicPropertyMechanismRepresentation) aPropertyMechanismRepr = new StepKinematics_KinematicPropertyMechanismRepresentation;
+    Handle(StepKinematics_MechanismRepresentation) aMechanism = new StepKinematics_MechanismRepresentation;
+    StepRepr_RepresentedDefinition aPDK;
+    Handle(StepKinematics_KinematicTopologyStructure) aKTopoStruct = new StepKinematics_KinematicTopologyStructure;
+    for (Standard_Integer aJointInd = 1; aJointInd <= aSeqOfJointsL.Length(); aJointInd++)
+    {
+      TDF_Label aJointL = aSeqOfJointsL.Value(aJointInd);
+      Handle(StepKinematics_KinematicJoint) aJoint;
+      Handle(XCAFDoc_KinematicPair) aKPairAttr;
+      Handle(StepKinematics_KinematicPair) aKinematicPair;
+      if (!aJointL.FindAttribute(XCAFDoc_KinematicPair::GetID(), aKPairAttr))
+        continue;
+      Handle(XCAFKinematics_PairObject) aPairObject = aKPairAttr->GetObject();
+      Handle(StepKinematics_RigidLinkRepresentation) aRigLinkRepr1;
+      Handle(StepKinematics_RigidLinkRepresentation) aRigLinkRepr2;
+      if (!createKinematicJoint(FP, aKTool, aGraph, aJointL, aPairObject, aSeqOfLinskL, aRigLinkRepr1, aRigLinkRepr2, aArrayOfRigidLinks, aJoint))
+        continue;
+      if (!createKinematicPair(aPairObject, aKinematicPair, aJoint, aSeqOfLinskL, aRigLinkRepr1, aRigLinkRepr2, aArrayOfRigidLinks))
+        continue;
+      aArrayOfJoints->SetValue(aJointInd, aJoint);
+      Handle(StepKinematics_PairRepresentationRelationship) aPairReprRelationship = new StepKinematics_PairRepresentationRelationship;
+      StepRepr_RepresentationOrRepresentationReference aDataLinkStart;
+      aDataLinkStart.SetValue(aRigLinkRepr1);
+      StepRepr_RepresentationOrRepresentationReference aDataLinkEnd;
+      aDataLinkEnd.SetValue(aRigLinkRepr2);
+      StepRepr_Transformation aPair;
+      aPair.SetValue(aKinematicPair);
+      aPairReprRelationship->Init(aKinematicPair->Name(), aKinematicPair->Name(), Standard_False, aKinematicPair->Name(), aDataLinkStart, aDataLinkEnd, aPair);
+      anArrayOfPairs->SetValue(aJointInd, aPairReprRelationship);
+
+      Model->AddEntity(aJoint);
+      Model->AddWithRefs(aPairReprRelationship);
+    }
+
+    //write mechanism
+    Handle(StepKinematics_ProductDefinitionKinematics) aProductDefKin = new StepKinematics_ProductDefinitionKinematics;
+    StepRepr_CharacterizedDefinition aKinDefinition;
+    aKinDefinition.SetValue(aGeneralNAUO->RelatingProductDefinition());
+    aProductDefKin->Init(new TCollection_HAsciiString, Standard_False, new TCollection_HAsciiString, aKinDefinition);
+    aKTopoStruct->Init(new TCollection_HAsciiString, anArrayOfPairs, aBaseLinksOfMech->ContextOfItems());
+    StepKinematics_KinematicTopologyRepresentationSelect aTopoSelect;
+    aTopoSelect.SetValue(aKTopoStruct);
+    Handle(TDataStd_Name) aAttrName;
+    aMechanismsL.Value(aMechInd).FindAttribute(TDataStd_Name::GetID(), aAttrName);
+    Handle(TCollection_HAsciiString) aHNameMechanism = new TCollection_HAsciiString(aAttrName->Get());
+    aPDK.SetValue(aProductDefKin);
+    aMechanism->Init(aHNameMechanism, anArrayOfPairs, aBaseLinksOfMech->ContextOfItems(), aTopoSelect);
+    aPropertyMechanismRepr->Init(aPDK, aMechanism, aBaseLinksOfMech);
+    Model->AddWithRefs(aPropertyMechanismRepr);
+
+    //(optional) write States
+    TDF_LabelSequence aSeqOfStates = aKTool->GetStates(aMechanismsL.Value(aMechInd));
+    for (Standard_Integer aStateInd = 1; aStateInd <= aSeqOfStates.Length(); ++aStateInd)
+    {
+      Handle(StepKinematics_MechanismStateRepresentation) aStateRepr = new StepKinematics_MechanismStateRepresentation;
+      TDF_LabelSequence aSeqOfValues = aKTool->GetValuesOfState(aSeqOfStates(aStateInd));
+      Handle(StepRepr_HArray1OfRepresentationItem) aItems = new StepRepr_HArray1OfRepresentationItem(1, aSeqOfValues.Length());
+      for (Standard_Integer aValueInd = 1; aValueInd <= aItems->Length(); ++aValueInd)
+      {
+        TDF_Label aJointL = aKTool->GetJointOfValue(aSeqOfValues(aValueInd));
+        Handle(StepKinematics_KinematicJoint) aJoint;
+        Handle(StepKinematics_PairRepresentationRelationship) aPairReprRelationship;
+        Standard_Integer anIndOfPair;
+        for (anIndOfPair = 1; anIndOfPair <= aSeqOfJointsL.Length(); ++anIndOfPair)
+        {
+          if (aSeqOfJointsL(anIndOfPair) == aJointL)
+          {
+            aPairReprRelationship = Handle(StepKinematics_PairRepresentationRelationship)::DownCast(anArrayOfPairs->Value(anIndOfPair));
+            aJoint = Handle(StepKinematics_KinematicJoint)::DownCast(aArrayOfJoints->Value(anIndOfPair));
+            break;
+          }
+        }
+        if (aJoint.IsNull() || aPairReprRelationship.IsNull())
+          continue;
+        Handle(XCAFDoc_KinematicPairValue) aKPairValueAttr;
+        if (!aSeqOfValues(aValueInd).FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aKPairValueAttr))
+          continue;
+        Handle(TCollection_HAsciiString) aNameOfValue;
+        Handle(TDataStd_Name) aNameAttr;
+        if (aSeqOfValues(aValueInd).FindAttribute(TDataStd_Name::GetID(), aNameAttr))
+          aNameOfValue = new TCollection_HAsciiString(aNameAttr->Get());
+        if (!aSeqOfValues(aValueInd).FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aKPairValueAttr))
+          continue;
+        Handle(XCAFKinematics_PairValueObject) aPairValueObject = aKPairValueAttr->GetObject();
+        Handle(StepKinematics_PairValue) aPairValue;
+        if (!createKinematicPairValue(aPairValueObject, aPairValue, aPairReprRelationship))
+          continue;
+        aPairValue->SetName(aNameOfValue);
+        aItems->SetValue(aValueInd, aPairValue);
+      }
+      Handle(TCollection_HAsciiString) aNameOfState;
+      Handle(TDataStd_Name) aNameAttr;
+      if (aSeqOfStates(aStateInd).FindAttribute(TDataStd_Name::GetID(), aNameAttr))
+        aNameOfState = new TCollection_HAsciiString(aNameAttr->Get());
+      aStateRepr->Init(aNameOfState, aItems, aMechanism->ContextOfItems(), aMechanism);
+      Model->AddWithRefs(aStateRepr);
+    }
+  }
+
+  return Standard_True;
+}
 
 //=======================================================================
 //function : FindPDSforDGT
@@ -3398,333 +4578,333 @@ void STEPCAFControl_Writer::WriteGeomTolerance (const Handle(XSControl_WorkSessi
 //function : WriteDGTs
 //purpose  : 
 //=======================================================================
-Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSession) &WS,
-                                                   const TDF_LabelSequence  &labels ) const
-{
+  Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSession) &WS,
+                                                     const TDF_LabelSequence  &labels ) const
+  {
   
-  if ( labels.Length() <=0 ) return Standard_False;
+    if ( labels.Length() <=0 ) return Standard_False;
   
-  // get working data
-  const Handle(Interface_InterfaceModel) &Model = WS->Model();
-  const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter();
-  const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess();
+    // get working data
+    const Handle(Interface_InterfaceModel) &Model = WS->Model();
+    const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter();
+    const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess();
 
-  const Handle(Interface_HGraph) aHGraph = WS->HGraph();
-  if(aHGraph.IsNull())
-    return Standard_False;
+    const Handle(Interface_HGraph) aHGraph = WS->HGraph();
+    if(aHGraph.IsNull())
+      return Standard_False;
 
-  Interface_Graph aGraph = aHGraph->Graph();
-  Handle(XCAFDoc_DimTolTool) DGTTool = XCAFDoc_DocumentTool::DimTolTool( labels(1) );
-  if(DGTTool.IsNull() ) return Standard_False;
-
-  TDF_LabelSequence DGTLabels;
-
-  STEPConstruct_DataMapOfAsciiStringTransient DatumMap;
-
-  // write Datums
-  DGTLabels.Clear();
-  DGTTool->GetDatumLabels(DGTLabels);
-  if(DGTLabels.Length()<=0) return Standard_False;
-  Standard_Integer i;
-  for(i=1; i<=DGTLabels.Length(); i++) {
-    TDF_Label DatumL = DGTLabels.Value(i);
-    TDF_LabelSequence ShapeL;
-    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;
-    TColStd_SequenceOfTransient seqRI;
-    FindEntities( FP, aShape, Loc, seqRI );
-    if ( seqRI.Length() <= 0 ) {
-      FP->Messenger()->SendInfo() << "Warning: Cannot find RI for "<<aShape.TShape()->DynamicType()->Name()<<std::endl;
-      continue;
+    Interface_Graph aGraph = aHGraph->Graph();
+    Handle(XCAFDoc_DimTolTool) DGTTool = XCAFDoc_DocumentTool::DimTolTool( labels(1) );
+    if(DGTTool.IsNull() ) return Standard_False;
+
+    TDF_LabelSequence DGTLabels;
+
+    STEPConstruct_DataMapOfAsciiStringTransient DatumMap;
+
+    // write Datums
+    DGTLabels.Clear();
+    DGTTool->GetDatumLabels(DGTLabels);
+    if(DGTLabels.Length()<=0) return Standard_False;
+    Standard_Integer i;
+    for(i=1; i<=DGTLabels.Length(); i++) {
+      TDF_Label DatumL = DGTLabels.Value(i);
+      TDF_LabelSequence ShapeL;
+      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;
+      TColStd_SequenceOfTransient seqRI;
+      FindEntities( FP, aShape, Loc, seqRI );
+      if ( seqRI.Length() <= 0 ) {
+        FP->Messenger()->SendInfo() << "Warning: Cannot find RI for "<<aShape.TShape()->DynamicType()->Name()<<std::endl;
+        continue;
+      }
+      Handle(StepRepr_ProductDefinitionShape) PDS;
+      Handle(StepRepr_RepresentationContext) RC;
+      Handle(Standard_Transient) ent = seqRI.Value(1);
+      Handle(StepShape_AdvancedFace) AF;
+      Handle(StepShape_EdgeCurve) EC;
+      FindPDSforDGT(aGraph,ent,PDS,RC,AF,EC);
+      if(PDS.IsNull()) continue;
+      //std::cout<<"Model->Number(PDS)="<<Model->Number(PDS)<<std::endl;
+      Handle(XCAFDoc_Datum) DatumAttr;
+      if(!DatumL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) continue;
+      Handle(TCollection_HAsciiString) aName = DatumAttr->GetName();
+      Handle(TCollection_HAsciiString) aDescription = DatumAttr->GetDescription();
+      Handle(TCollection_HAsciiString) anIdentification = DatumAttr->GetIdentification();
+      Handle(StepDimTol_DatumFeature) DF = new StepDimTol_DatumFeature;
+      Handle(StepDimTol_Datum) aDatum = new StepDimTol_Datum;
+      DF->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue);
+      Model->AddWithRefs(DF);
+      aDatum->Init(aName, new TCollection_HAsciiString, PDS, StepData_LFalse, anIdentification);
+      Model->AddWithRefs(aDatum);
+      Handle(StepRepr_ShapeAspectRelationship) SAR = new StepRepr_ShapeAspectRelationship;
+      SAR->SetName(aName);
+      SAR->SetRelatingShapeAspect(DF);
+      SAR->SetRelatedShapeAspect(aDatum);
+      Model->AddWithRefs(SAR);
+      // write chain for DatumFeature
+      StepRepr_CharacterizedDefinition CD;
+      CD.SetValue(DF);
+      Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition;
+      PropD->Init(aName,Standard_True,aDescription,CD);
+      Model->AddWithRefs(PropD);
+      StepRepr_RepresentedDefinition RD;
+      RD.SetValue(PropD);
+      Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation;
+      Handle(StepRepr_HArray1OfRepresentationItem) HARI =
+        new StepRepr_HArray1OfRepresentationItem(1,1);
+      HARI->SetValue(1,AF);
+      SR->Init(aName,HARI,RC);
+      Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation;
+      SDR->Init(RD,SR);
+      Model->AddWithRefs(SDR);
+      // write chain for Datum 
+      StepRepr_CharacterizedDefinition CD1;
+      CD1.SetValue(aDatum);
+      Handle(StepRepr_PropertyDefinition) PropD1 = new StepRepr_PropertyDefinition;
+      PropD1->Init(aName,Standard_True,aDescription,CD1);
+      Model->AddWithRefs(PropD1);
+      StepRepr_RepresentedDefinition RD1;
+      RD1.SetValue(PropD1);
+      Handle(StepShape_ShapeRepresentation) SR1 = new StepShape_ShapeRepresentation;
+      Handle(StepRepr_HArray1OfRepresentationItem) HARI1 =
+        new StepRepr_HArray1OfRepresentationItem(1,1);
+      HARI1->SetValue(1,AF->FaceGeometry());
+      SR1->Init(aName,HARI1,RC);
+      Model->AddWithRefs(SR1);
+      Handle(StepShape_ShapeDefinitionRepresentation) SDR1 = new StepShape_ShapeDefinitionRepresentation;
+      SDR1->Init(RD1,SR1);
+      Model->AddWithRefs(SDR1);
+      // add created Datum into Map
+      TCollection_AsciiString stmp(aName->ToCString());
+      stmp.AssignCat(aDescription->ToCString());
+      stmp.AssignCat(anIdentification->ToCString());
+      DatumMap.Bind(stmp,aDatum);
     }
-    Handle(StepRepr_ProductDefinitionShape) PDS;
-    Handle(StepRepr_RepresentationContext) RC;
-    Handle(Standard_Transient) ent = seqRI.Value(1);
-    Handle(StepShape_AdvancedFace) AF;
-    Handle(StepShape_EdgeCurve) EC;
-    FindPDSforDGT(aGraph,ent,PDS,RC,AF,EC);
-    if(PDS.IsNull()) continue;
-    //std::cout<<"Model->Number(PDS)="<<Model->Number(PDS)<<std::endl;
-    Handle(XCAFDoc_Datum) DatumAttr;
-    if(!DatumL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) continue;
-    Handle(TCollection_HAsciiString) aName = DatumAttr->GetName();
-    Handle(TCollection_HAsciiString) aDescription = DatumAttr->GetDescription();
-    Handle(TCollection_HAsciiString) anIdentification = DatumAttr->GetIdentification();
-    Handle(StepDimTol_DatumFeature) DF = new StepDimTol_DatumFeature;
-    Handle(StepDimTol_Datum) aDatum = new StepDimTol_Datum;
-    DF->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue);
-    Model->AddWithRefs(DF);
-    aDatum->Init(aName, new TCollection_HAsciiString, PDS, StepData_LFalse, anIdentification);
-    Model->AddWithRefs(aDatum);
-    Handle(StepRepr_ShapeAspectRelationship) SAR = new StepRepr_ShapeAspectRelationship;
-    SAR->SetName(aName);
-    SAR->SetRelatingShapeAspect(DF);
-    SAR->SetRelatedShapeAspect(aDatum);
-    Model->AddWithRefs(SAR);
-    // write chain for DatumFeature
-    StepRepr_CharacterizedDefinition CD;
-    CD.SetValue(DF);
-    Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition;
-    PropD->Init(aName,Standard_True,aDescription,CD);
-    Model->AddWithRefs(PropD);
-    StepRepr_RepresentedDefinition RD;
-    RD.SetValue(PropD);
-    Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation;
-    Handle(StepRepr_HArray1OfRepresentationItem) HARI =
-      new StepRepr_HArray1OfRepresentationItem(1,1);
-    HARI->SetValue(1,AF);
-    SR->Init(aName,HARI,RC);
-    Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation;
-    SDR->Init(RD,SR);
-    Model->AddWithRefs(SDR);
-    // write chain for Datum 
-    StepRepr_CharacterizedDefinition CD1;
-    CD1.SetValue(aDatum);
-    Handle(StepRepr_PropertyDefinition) PropD1 = new StepRepr_PropertyDefinition;
-    PropD1->Init(aName,Standard_True,aDescription,CD1);
-    Model->AddWithRefs(PropD1);
-    StepRepr_RepresentedDefinition RD1;
-    RD1.SetValue(PropD1);
-    Handle(StepShape_ShapeRepresentation) SR1 = new StepShape_ShapeRepresentation;
-    Handle(StepRepr_HArray1OfRepresentationItem) HARI1 =
-      new StepRepr_HArray1OfRepresentationItem(1,1);
-    HARI1->SetValue(1,AF->FaceGeometry());
-    SR1->Init(aName,HARI1,RC);
-    Model->AddWithRefs(SR1);
-    Handle(StepShape_ShapeDefinitionRepresentation) SDR1 = new StepShape_ShapeDefinitionRepresentation;
-    SDR1->Init(RD1,SR1);
-    Model->AddWithRefs(SDR1);
-    // add created Datum into Map
-    TCollection_AsciiString stmp(aName->ToCString());
-    stmp.AssignCat(aDescription->ToCString());
-    stmp.AssignCat(anIdentification->ToCString());
-    DatumMap.Bind(stmp,aDatum);
-  }
 
-  // write Tolerances and Dimensions
-  DGTLabels.Clear();
-  DGTTool->GetDimTolLabels(DGTLabels);
-  if(DGTLabels.Length()<=0) return Standard_False;
-  for(i=1; i<=DGTLabels.Length(); i++) {
-    TDF_Label DimTolL = DGTLabels.Value(i);
-    TDF_LabelSequence ShapeL;
-    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;
-    TColStd_SequenceOfTransient seqRI;
-    FindEntities( FP, aShape, Loc, seqRI );
-    if ( seqRI.Length() <= 0 ) {
-      FP->Messenger()->SendInfo() << "Warning: Cannot find RI for "<<aShape.TShape()->DynamicType()->Name()<<std::endl;
-      continue;
-    }
-    Handle(StepRepr_ProductDefinitionShape) PDS;
-    Handle(StepRepr_RepresentationContext) RC;
-    Handle(Standard_Transient) ent = seqRI.Value(1);
-    Handle(StepShape_AdvancedFace) AF;
-    Handle(StepShape_EdgeCurve) EC;
-    FindPDSforDGT(aGraph,ent,PDS,RC,AF,EC);
-    if(PDS.IsNull()) continue;
-    //std::cout<<"Model->Number(PDS)="<<Model->Number(PDS)<<std::endl;
-
-    Handle(XCAFDoc_DimTol) DimTolAttr;
-    if(!DimTolL.FindAttribute(XCAFDoc_DimTol::GetID(),DimTolAttr)) continue;
-    Standard_Integer kind = DimTolAttr->GetKind();
-    Handle(TColStd_HArray1OfReal) aVal = DimTolAttr->GetVal();
-    Handle(TCollection_HAsciiString) aName = DimTolAttr->GetName();
-    Handle(TCollection_HAsciiString) aDescription = DimTolAttr->GetDescription();
-
-    // common part of writing D&GT entities
-    StepRepr_CharacterizedDefinition CD;
-    Handle(StepRepr_ShapeAspect) SA = new StepRepr_ShapeAspect;
-    SA->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue);
-    Model->AddWithRefs(SA);
-    CD.SetValue(SA);
-    Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition;
-    PropD->Init(aName,Standard_True,aDescription,CD);
-    Model->AddWithRefs(PropD);
-    StepRepr_RepresentedDefinition RD;
-    RD.SetValue(PropD);
-    Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation;
-    Handle(StepRepr_HArray1OfRepresentationItem) HARI =
-      new StepRepr_HArray1OfRepresentationItem(1,1);
-    if(kind<20) 
-      HARI->SetValue(1,EC);
-    else
-      HARI->SetValue(1,AF);
-    SR->Init(aName,HARI,RC);
-    Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation;
-    SDR->Init(RD,SR);
-    Model->AddWithRefs(SDR);
-    // define aUnit for creation LengthMeasureWithUnit (common for all)
-    StepBasic_Unit aUnit;
-    aUnit = GetUnit(RC);
-
-    // specific part of writing D&GT entities
-    if(kind<20) { //dimension
-      Handle(StepShape_DimensionalSize) DimSize = new StepShape_DimensionalSize;
-      DimSize->Init(SA,aDescription);
-      Model->AddWithRefs(DimSize);
-      if(aVal->Length()>1) {
-        // create MeasureWithUnits
-        Handle(StepBasic_MeasureValueMember) MVM1 = new StepBasic_MeasureValueMember;
-        MVM1->SetName("POSITIVE_LENGTH_MEASURE");
-        MVM1->SetReal(aVal->Value(1));
-        Handle(StepBasic_MeasureWithUnit) MWU1 = new StepBasic_MeasureWithUnit;
-        MWU1->Init(MVM1,aUnit);
-        Handle(StepBasic_MeasureValueMember) MVM2 = new StepBasic_MeasureValueMember;
-        MVM2->SetName("POSITIVE_LENGTH_MEASURE");
-        MVM2->SetReal(aVal->Value(2));
-        Handle(StepBasic_MeasureWithUnit) MWU2 = new StepBasic_MeasureWithUnit;
-        MWU2->Init(MVM2,aUnit);
-        Handle(StepRepr_RepresentationItem) RI1 = new StepRepr_RepresentationItem;
-        RI1->Init(new TCollection_HAsciiString("lower limit"));
-        Handle(StepRepr_RepresentationItem) RI2 = new StepRepr_RepresentationItem;
-        RI2->Init(new TCollection_HAsciiString("upper limit"));
-        Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMU1 =
-          new StepRepr_ReprItemAndLengthMeasureWithUnit;
-        RILMU1->Init(MWU1,RI1);
-        Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMU2 =
-          new StepRepr_ReprItemAndLengthMeasureWithUnit;
-        RILMU2->Init(MWU2,RI2);
-        Model->AddWithRefs(RILMU1);
-        Model->AddWithRefs(RILMU2);
-        //Handle(StepRepr_CompoundItemDefinitionMember) CIDM =
-        //  new StepRepr_CompoundItemDefinitionMember;
-        //Handle(TColStd_HArray1OfTransient) ArrTr = new TColStd_HArray1OfTransient(1,2);
-        //ArrTr->SetValue(1,RILMU1);
-        //ArrTr->SetValue(2,RILMU2);
-        //CIDM->SetArrTransient(ArrTr);
-        //CIDM->SetName("SET_REPRESENTATION_ITEM");
-        //StepRepr_CompoundItemDefinition CID;
-        //CID.SetValue(CIDM);
-        Handle(StepRepr_HArray1OfRepresentationItem) HARIVR =
-          new StepRepr_HArray1OfRepresentationItem(1,2);
-        HARIVR->SetValue(1,RILMU1);
-        HARIVR->SetValue(2,RILMU2);
-        Handle(StepRepr_ValueRange) VR = new StepRepr_ValueRange;
-        //VR->Init(aName,CID);
-        VR->Init(aName,HARIVR);
-        Model->AddEntity(VR);
-        Handle(StepShape_ShapeDimensionRepresentation) SDimR =
-          new StepShape_ShapeDimensionRepresentation;
-        Handle(StepRepr_HArray1OfRepresentationItem) aHARI =
-          new StepRepr_HArray1OfRepresentationItem(1,1);
-        aHARI->SetValue(1,VR);
-        SDimR->Init(aName,aHARI,RC);
-        Model->AddWithRefs(SDimR);
-        Handle(StepShape_DimensionalCharacteristicRepresentation) DimCharR =
-          new StepShape_DimensionalCharacteristicRepresentation;
-        StepShape_DimensionalCharacteristic DimChar;
-        DimChar.SetValue(DimSize);
-        DimCharR->Init(DimChar,SDimR);
-        Model->AddEntity(DimCharR);
+    // write Tolerances and Dimensions
+    DGTLabels.Clear();
+    DGTTool->GetDimTolLabels(DGTLabels);
+    if(DGTLabels.Length()<=0) return Standard_False;
+    for(i=1; i<=DGTLabels.Length(); i++) {
+      TDF_Label DimTolL = DGTLabels.Value(i);
+      TDF_LabelSequence ShapeL;
+      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;
+      TColStd_SequenceOfTransient seqRI;
+      FindEntities( FP, aShape, Loc, seqRI );
+      if ( seqRI.Length() <= 0 ) {
+        FP->Messenger()->SendInfo() << "Warning: Cannot find RI for "<<aShape.TShape()->DynamicType()->Name()<<std::endl;
+        continue;
       }
-    }
-    else if(kind<50) { //tolerance
-      if(kind<35) { // tolerance with datum system
-        TDF_LabelSequence DatumLabels;
-        DGTTool->GetDatumOfTolerLabels(DimTolL,DatumLabels);
-        Standard_Integer NbDR = DatumLabels.Length();
-        Handle(StepDimTol_HArray1OfDatumReference) HADR = new StepDimTol_HArray1OfDatumReference(1,NbDR);
-        for(Standard_Integer j=1; j<=NbDR; j++) {
-          Handle(XCAFDoc_Datum) DatumAttr;
-          TDF_Label DatumL = DatumLabels.Value(j);
-          if(!DatumL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) continue;
-          Handle(TCollection_HAsciiString) aNameD = DatumAttr->GetName();
-          Handle(TCollection_HAsciiString) aDescriptionD = DatumAttr->GetDescription();
-          Handle(TCollection_HAsciiString) anIdentificationD = DatumAttr->GetIdentification();
-          TCollection_AsciiString stmp(aNameD->ToCString());
-          stmp.AssignCat(aDescriptionD->ToCString());
-          stmp.AssignCat(anIdentificationD->ToCString());
-          if(DatumMap.IsBound(stmp)) {
-            Handle(StepDimTol_Datum) aDatum = 
-              Handle(StepDimTol_Datum)::DownCast(DatumMap.Find(stmp));
-            Handle(StepDimTol_DatumReference) DR = new StepDimTol_DatumReference;
-            DR->Init(j,aDatum);
-            Model->AddWithRefs(DR);
-            HADR->SetValue(j,DR);
-          }
-        }
-        // create LengthMeasureWithUnit
-        Handle(StepBasic_MeasureValueMember) MVM = new StepBasic_MeasureValueMember;
-        MVM->SetName("LENGTH_MEASURE");
-        MVM->SetReal(aVal->Value(1));
-        Handle(StepBasic_LengthMeasureWithUnit) LMWU = new StepBasic_LengthMeasureWithUnit;
-        LMWU->Init(MVM,aUnit);
-        // create tolerance by it's type
-        if(kind<24) {
-          Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
-            new StepDimTol_GeometricToleranceWithDatumReference;
-          GTWDR->SetDatumSystem(HADR);
-          Handle(StepDimTol_ModifiedGeometricTolerance) MGT =
-            new StepDimTol_ModifiedGeometricTolerance;
-          if(kind==21) MGT->SetModifier(StepDimTol_MaximumMaterialCondition);
-          else if(kind==22) MGT->SetModifier(StepDimTol_LeastMaterialCondition);
-          else if(kind==23) MGT->SetModifier(StepDimTol_RegardlessOfFeatureSize);
-          Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol) GTComplex =
-            new StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol;
-          GTComplex->Init(aName,aDescription,LMWU,SA,GTWDR,MGT);
-          Model->AddWithRefs(GTComplex);
-        }
-        else if(kind==24) {
-          Handle(StepDimTol_AngularityTolerance) aToler =
-            new StepDimTol_AngularityTolerance;
-          aToler->Init(aName,aDescription,LMWU,SA,HADR);
-          Model->AddWithRefs(aToler);
-        }
-        else if(kind==25) {
-          Handle(StepDimTol_CircularRunoutTolerance) aToler =
-            new StepDimTol_CircularRunoutTolerance;
-          aToler->Init(aName,aDescription,LMWU,SA,HADR);
-          Model->AddWithRefs(aToler);
-        }
-        else if(kind==26) {
-          Handle(StepDimTol_CoaxialityTolerance) aToler =
-            new StepDimTol_CoaxialityTolerance;
-          aToler->Init(aName,aDescription,LMWU,SA,HADR);
-          Model->AddWithRefs(aToler);
-        }
-        else if(kind==27) {
-          Handle(StepDimTol_ConcentricityTolerance) aToler =
-            new StepDimTol_ConcentricityTolerance;
-          aToler->Init(aName,aDescription,LMWU,SA,HADR);
-          Model->AddWithRefs(aToler);
-        }
-        else if(kind==28) {
-          Handle(StepDimTol_ParallelismTolerance) aToler =
-            new StepDimTol_ParallelismTolerance;
-          aToler->Init(aName,aDescription,LMWU,SA,HADR);
-          Model->AddWithRefs(aToler);
-        }
-        else if(kind==29) {
-          Handle(StepDimTol_PerpendicularityTolerance) aToler =
-            new StepDimTol_PerpendicularityTolerance;
-          aToler->Init(aName,aDescription,LMWU,SA,HADR);
-          Model->AddWithRefs(aToler);
-        }
-        else if(kind==30) {
-          Handle(StepDimTol_SymmetryTolerance) aToler =
-            new StepDimTol_SymmetryTolerance;
-          aToler->Init(aName,aDescription,LMWU,SA,HADR);
-          Model->AddWithRefs(aToler);
+      Handle(StepRepr_ProductDefinitionShape) PDS;
+      Handle(StepRepr_RepresentationContext) RC;
+      Handle(Standard_Transient) ent = seqRI.Value(1);
+      Handle(StepShape_AdvancedFace) AF;
+      Handle(StepShape_EdgeCurve) EC;
+      FindPDSforDGT(aGraph,ent,PDS,RC,AF,EC);
+      if(PDS.IsNull()) continue;
+      //std::cout<<"Model->Number(PDS)="<<Model->Number(PDS)<<std::endl;
+
+      Handle(XCAFDoc_DimTol) DimTolAttr;
+      if(!DimTolL.FindAttribute(XCAFDoc_DimTol::GetID(),DimTolAttr)) continue;
+      Standard_Integer kind = DimTolAttr->GetKind();
+      Handle(TColStd_HArray1OfReal) aVal = DimTolAttr->GetVal();
+      Handle(TCollection_HAsciiString) aName = DimTolAttr->GetName();
+      Handle(TCollection_HAsciiString) aDescription = DimTolAttr->GetDescription();
+
+      // common part of writing D&GT entities
+      StepRepr_CharacterizedDefinition CD;
+      Handle(StepRepr_ShapeAspect) SA = new StepRepr_ShapeAspect;
+      SA->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue);
+      Model->AddWithRefs(SA);
+      CD.SetValue(SA);
+      Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition;
+      PropD->Init(aName,Standard_True,aDescription,CD);
+      Model->AddWithRefs(PropD);
+      StepRepr_RepresentedDefinition RD;
+      RD.SetValue(PropD);
+      Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation;
+      Handle(StepRepr_HArray1OfRepresentationItem) HARI =
+        new StepRepr_HArray1OfRepresentationItem(1,1);
+      if(kind<20) 
+        HARI->SetValue(1,EC);
+      else
+        HARI->SetValue(1,AF);
+      SR->Init(aName,HARI,RC);
+      Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation;
+      SDR->Init(RD,SR);
+      Model->AddWithRefs(SDR);
+      // define aUnit for creation LengthMeasureWithUnit (common for all)
+      StepBasic_Unit aUnit;
+      aUnit = GetUnit(RC);
+
+      // specific part of writing D&GT entities
+      if(kind<20) { //dimension
+        Handle(StepShape_DimensionalSize) DimSize = new StepShape_DimensionalSize;
+        DimSize->Init(SA,aDescription);
+        Model->AddWithRefs(DimSize);
+        if(aVal->Length()>1) {
+          // create MeasureWithUnits
+          Handle(StepBasic_MeasureValueMember) MVM1 = new StepBasic_MeasureValueMember;
+          MVM1->SetName("POSITIVE_LENGTH_MEASURE");
+          MVM1->SetReal(aVal->Value(1));
+          Handle(StepBasic_MeasureWithUnit) MWU1 = new StepBasic_MeasureWithUnit;
+          MWU1->Init(MVM1,aUnit);
+          Handle(StepBasic_MeasureValueMember) MVM2 = new StepBasic_MeasureValueMember;
+          MVM2->SetName("POSITIVE_LENGTH_MEASURE");
+          MVM2->SetReal(aVal->Value(2));
+          Handle(StepBasic_MeasureWithUnit) MWU2 = new StepBasic_MeasureWithUnit;
+          MWU2->Init(MVM2,aUnit);
+          Handle(StepRepr_RepresentationItem) RI1 = new StepRepr_RepresentationItem;
+          RI1->Init(new TCollection_HAsciiString("lower limit"));
+          Handle(StepRepr_RepresentationItem) RI2 = new StepRepr_RepresentationItem;
+          RI2->Init(new TCollection_HAsciiString("upper limit"));
+          Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMU1 =
+            new StepRepr_ReprItemAndLengthMeasureWithUnit;
+          RILMU1->Init(MWU1,RI1);
+          Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMU2 =
+            new StepRepr_ReprItemAndLengthMeasureWithUnit;
+          RILMU2->Init(MWU2,RI2);
+          Model->AddWithRefs(RILMU1);
+          Model->AddWithRefs(RILMU2);
+          //Handle(StepRepr_CompoundItemDefinitionMember) CIDM =
+          //  new StepRepr_CompoundItemDefinitionMember;
+          //Handle(TColStd_HArray1OfTransient) ArrTr = new TColStd_HArray1OfTransient(1,2);
+          //ArrTr->SetValue(1,RILMU1);
+          //ArrTr->SetValue(2,RILMU2);
+          //CIDM->SetArrTransient(ArrTr);
+          //CIDM->SetName("SET_REPRESENTATION_ITEM");
+          //StepRepr_CompoundItemDefinition CID;
+          //CID.SetValue(CIDM);
+          Handle(StepRepr_HArray1OfRepresentationItem) HARIVR =
+            new StepRepr_HArray1OfRepresentationItem(1,2);
+          HARIVR->SetValue(1,RILMU1);
+          HARIVR->SetValue(2,RILMU2);
+          Handle(StepRepr_ValueRange) VR = new StepRepr_ValueRange;
+          //VR->Init(aName,CID);
+          VR->Init(aName,HARIVR);
+          Model->AddEntity(VR);
+          Handle(StepShape_ShapeDimensionRepresentation) SDimR =
+            new StepShape_ShapeDimensionRepresentation;
+          Handle(StepRepr_HArray1OfRepresentationItem) aHARI =
+            new StepRepr_HArray1OfRepresentationItem(1,1);
+          aHARI->SetValue(1,VR);
+          SDimR->Init(aName,aHARI,RC);
+          Model->AddWithRefs(SDimR);
+          Handle(StepShape_DimensionalCharacteristicRepresentation) DimCharR =
+            new StepShape_DimensionalCharacteristicRepresentation;
+          StepShape_DimensionalCharacteristic DimChar;
+          DimChar.SetValue(DimSize);
+          DimCharR->Init(DimChar,SDimR);
+          Model->AddEntity(DimCharR);
         }
-        else if(kind==31) {
-          Handle(StepDimTol_TotalRunoutTolerance) aToler =
-            new StepDimTol_TotalRunoutTolerance;
-          aToler->Init(aName,aDescription,LMWU,SA,HADR);
-          Model->AddWithRefs(aToler);
+      }
+      else if(kind<50) { //tolerance
+        if(kind<35) { // tolerance with datum system
+          TDF_LabelSequence DatumLabels;
+          DGTTool->GetDatumOfTolerLabels(DimTolL,DatumLabels);
+          Standard_Integer NbDR = DatumLabels.Length();
+          Handle(StepDimTol_HArray1OfDatumReference) HADR = new StepDimTol_HArray1OfDatumReference(1,NbDR);
+          for(Standard_Integer j=1; j<=NbDR; j++) {
+            Handle(XCAFDoc_Datum) DatumAttr;
+            TDF_Label DatumL = DatumLabels.Value(j);
+            if(!DatumL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) continue;
+            Handle(TCollection_HAsciiString) aNameD = DatumAttr->GetName();
+            Handle(TCollection_HAsciiString) aDescriptionD = DatumAttr->GetDescription();
+            Handle(TCollection_HAsciiString) anIdentificationD = DatumAttr->GetIdentification();
+            TCollection_AsciiString stmp(aNameD->ToCString());
+            stmp.AssignCat(aDescriptionD->ToCString());
+            stmp.AssignCat(anIdentificationD->ToCString());
+            if(DatumMap.IsBound(stmp)) {
+              Handle(StepDimTol_Datum) aDatum = 
+                Handle(StepDimTol_Datum)::DownCast(DatumMap.Find(stmp));
+              Handle(StepDimTol_DatumReference) DR = new StepDimTol_DatumReference;
+              DR->Init(j,aDatum);
+              Model->AddWithRefs(DR);
+              HADR->SetValue(j,DR);
+            }
+          }
+          // create LengthMeasureWithUnit
+          Handle(StepBasic_MeasureValueMember) MVM = new StepBasic_MeasureValueMember;
+          MVM->SetName("LENGTH_MEASURE");
+          MVM->SetReal(aVal->Value(1));
+          Handle(StepBasic_LengthMeasureWithUnit) LMWU = new StepBasic_LengthMeasureWithUnit;
+          LMWU->Init(MVM,aUnit);
+          // create tolerance by it's type
+          if(kind<24) {
+            Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR =
+              new StepDimTol_GeometricToleranceWithDatumReference;
+            GTWDR->SetDatumSystem(HADR);
+            Handle(StepDimTol_ModifiedGeometricTolerance) MGT =
+              new StepDimTol_ModifiedGeometricTolerance;
+            if(kind==21) MGT->SetModifier(StepDimTol_MaximumMaterialCondition);
+            else if(kind==22) MGT->SetModifier(StepDimTol_LeastMaterialCondition);
+            else if(kind==23) MGT->SetModifier(StepDimTol_RegardlessOfFeatureSize);
+            Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol) GTComplex =
+              new StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol;
+            GTComplex->Init(aName,aDescription,LMWU,SA,GTWDR,MGT);
+            Model->AddWithRefs(GTComplex);
+          }
+          else if(kind==24) {
+            Handle(StepDimTol_AngularityTolerance) aToler =
+              new StepDimTol_AngularityTolerance;
+            aToler->Init(aName,aDescription,LMWU,SA,HADR);
+            Model->AddWithRefs(aToler);
+          }
+          else if(kind==25) {
+            Handle(StepDimTol_CircularRunoutTolerance) aToler =
+              new StepDimTol_CircularRunoutTolerance;
+            aToler->Init(aName,aDescription,LMWU,SA,HADR);
+            Model->AddWithRefs(aToler);
+          }
+          else if(kind==26) {
+            Handle(StepDimTol_CoaxialityTolerance) aToler =
+              new StepDimTol_CoaxialityTolerance;
+            aToler->Init(aName,aDescription,LMWU,SA,HADR);
+            Model->AddWithRefs(aToler);
+          }
+          else if(kind==27) {
+            Handle(StepDimTol_ConcentricityTolerance) aToler =
+              new StepDimTol_ConcentricityTolerance;
+            aToler->Init(aName,aDescription,LMWU,SA,HADR);
+            Model->AddWithRefs(aToler);
+          }
+          else if(kind==28) {
+            Handle(StepDimTol_ParallelismTolerance) aToler =
+              new StepDimTol_ParallelismTolerance;
+            aToler->Init(aName,aDescription,LMWU,SA,HADR);
+            Model->AddWithRefs(aToler);
+          }
+          else if(kind==29) {
+            Handle(StepDimTol_PerpendicularityTolerance) aToler =
+              new StepDimTol_PerpendicularityTolerance;
+            aToler->Init(aName,aDescription,LMWU,SA,HADR);
+            Model->AddWithRefs(aToler);
+          }
+          else if(kind==30) {
+            Handle(StepDimTol_SymmetryTolerance) aToler =
+              new StepDimTol_SymmetryTolerance;
+            aToler->Init(aName,aDescription,LMWU,SA,HADR);
+            Model->AddWithRefs(aToler);
+          }
+          else if(kind==31) {
+            Handle(StepDimTol_TotalRunoutTolerance) aToler =
+              new StepDimTol_TotalRunoutTolerance;
+            aToler->Init(aName,aDescription,LMWU,SA,HADR);
+            Model->AddWithRefs(aToler);
+          }
         }
       }
     }
-  }
 
-  return Standard_True;
-}
+    return Standard_True;
+  }
 
 //=======================================================================
 //function : WriteDGTsAP242
@@ -4329,3 +5509,23 @@ Standard_Boolean STEPCAFControl_Writer::GetMaterialMode() const
 {
   return myMatMode;
 }
+
+//=======================================================================
+//function : SetKinematicsMode
+//purpose  : 
+//=======================================================================
+
+void STEPCAFControl_Writer::SetKinematicsMode(const Standard_Boolean kinematicsmod)
+{
+  myKPairMode = kinematicsmod;
+}
+
+//=======================================================================
+//function : GetKinematicsMode
+//purpose  : 
+//=======================================================================
+
+Standard_Boolean STEPCAFControl_Writer::GetKinematicsMode() const
+{
+  return myKPairMode;
+}
index 67ff328a344e20b4692755c706aff0884af441a3..fd1515922a6c24b4c7d2291ee7c1c036a51cac2f 100644 (file)
@@ -150,6 +150,11 @@ public:
   
   Standard_EXPORT Standard_Boolean GetMaterialMode() const;
 
+  //! Set dimtolmode for indicate write D&GTs or not.
+  Standard_EXPORT void SetKinematicsMode(const Standard_Boolean kinematicsmod);
+
+  Standard_EXPORT Standard_Boolean GetKinematicsMode() const;
+
 
 
 
@@ -198,6 +203,8 @@ protected:
   //! Write SHUO assigned to specified component, to STEP model
   Standard_EXPORT Standard_Boolean WriteSHUOs (const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
 
+  //! Write Kinematic Pairs assigned to specified component, to STEP model
+  Standard_EXPORT Standard_Boolean WriteKinematics(const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels);
   
 
 private:
@@ -230,6 +237,7 @@ private:
   Standard_Boolean myLayerMode;
   Standard_Boolean myPropsMode;
   Standard_Boolean mySHUOMode;
+  Standard_Boolean myKPairMode;
   MoniTool_DataMapOfShapeTransient myMapCompMDGPR;
   Standard_Boolean myGDTMode;
   Standard_Boolean myMatMode;
index 1ec1aade17ada214f00191af3495d072eab985a7..236edc5caa8a1268dc939fc7d75aecaa6146fc3e 100644 (file)
@@ -826,6 +826,7 @@ static Standard_CString schemaAP242DIS = "AP242_MANAGED_MODEL_BASED_3D_ENGINEERI
 #include <StepKinematics_UniversalPairValue.hxx>
 #include <StepKinematics_UniversalPairWithRange.hxx>
 #include <StepKinematics_ActuatedKinPairAndOrderKinPair.hxx>
+#include <StepKinematics_MechanismStateRepresentation.hxx>
 
 #include <StepVisual_SurfaceStyleTransparent.hxx>
 #include <StepVisual_SurfaceStyleReflectanceAmbient.hxx>
@@ -833,7 +834,7 @@ static Standard_CString schemaAP242DIS = "AP242_MANAGED_MODEL_BASED_3D_ENGINEERI
 #include <StepVisual_SurfaceStyleRenderingWithProperties.hxx>
 
 static int THE_StepAP214_Protocol_init = 0;
-static Interface_DataMapOfTransientInteger types(801);
+static Interface_DataMapOfTransientInteger types(803);
 
 //=======================================================================
 //function : StepAP214_Protocol
@@ -1623,6 +1624,7 @@ StepAP214_Protocol::StepAP214_Protocol ()
   types.Bind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPlanarCurvePair), 797);
   types.Bind(STANDARD_TYPE(StepKinematics_LinearFlexibleLinkRepresentation), 798);
   types.Bind(STANDARD_TYPE(StepKinematics_ActuatedKinPairAndOrderKinPair), 800);
+  types.Bind(STANDARD_TYPE(StepKinematics_MechanismStateRepresentation), 801);
 }
 
 
index 1df7719b9f1e1bfad05667be0b381185db3332d0..919fdadc6465b4d69c92ec58dee1f6dd58bce6ab 100644 (file)
@@ -55,6 +55,8 @@ StepKinematics_LowOrderKinematicPairWithRange.cxx
 StepKinematics_LowOrderKinematicPairWithRange.hxx
 StepKinematics_MechanismRepresentation.cxx
 StepKinematics_MechanismRepresentation.hxx
+StepKinematics_MechanismStateRepresentation.cxx
+StepKinematics_MechanismStateRepresentation.hxx
 StepKinematics_OrientedJoint.cxx
 StepKinematics_OrientedJoint.hxx
 StepKinematics_PairRepresentationRelationship.cxx
diff --git a/src/StepKinematics/StepKinematics_MechanismStateRepresentation.cxx b/src/StepKinematics/StepKinematics_MechanismStateRepresentation.cxx
new file mode 100644 (file)
index 0000000..fae011f
--- /dev/null
@@ -0,0 +1,42 @@
+// Created on: 2016-04-26
+// Created by: Irina KRYLOVA
+// Copyright (c) 2016 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <Standard_Type.hxx>
+#include <StepKinematics_MechanismStateRepresentation.hxx>
+#include <StepKinematics_MechanismRepresentation.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(StepKinematics_MechanismStateRepresentation, StepRepr_Representation)
+
+StepKinematics_MechanismStateRepresentation::StepKinematics_MechanismStateRepresentation()  {}
+
+void StepKinematics_MechanismStateRepresentation::Init(const Handle(TCollection_HAsciiString)& aName,
+                                                            const Handle(StepRepr_HArray1OfRepresentationItem)& aItems,
+                                                            const Handle(StepRepr_RepresentationContext)& aContextOfItems,
+                                                            const Handle(StepKinematics_MechanismRepresentation) aMechanism)
+{
+       StepRepr_Representation::Init(aName, aItems, aContextOfItems);
+       representedMechanism = aMechanism;
+}
+
+void StepKinematics_MechanismStateRepresentation::SetMechanism(const Handle(StepKinematics_MechanismRepresentation)& aMechanism)
+{
+  representedMechanism = aMechanism;
+}
+
+Handle(StepKinematics_MechanismRepresentation) StepKinematics_MechanismStateRepresentation::Mechanism() const
+{
+  return representedMechanism;
+}
\ No newline at end of file
diff --git a/src/StepKinematics/StepKinematics_MechanismStateRepresentation.hxx b/src/StepKinematics/StepKinematics_MechanismStateRepresentation.hxx
new file mode 100644 (file)
index 0000000..fed3126
--- /dev/null
@@ -0,0 +1,49 @@
+// Created on: 2016-04-26
+// Created by: Irina KRYLOVA
+// Copyright (c) 2016 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 _StepKinematics_MechanismStateRepresentation_HeaderFile
+#define _StepKinematics_MechanismStateRepresentation_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <StepRepr_Representation.hxx>
+
+class StepKinematics_MechanismRepresentation;
+
+class StepKinematics_MechanismStateRepresentation;
+DEFINE_STANDARD_HANDLE(StepKinematics_MechanismStateRepresentation, StepRepr_Representation)
+
+
+class StepKinematics_MechanismStateRepresentation : public StepRepr_Representation
+{
+public:
+  
+  //! Returns a MechanismStateRepresentation
+  Standard_EXPORT StepKinematics_MechanismStateRepresentation();
+
+  Standard_EXPORT void Init(const Handle(TCollection_HAsciiString)& aName, const Handle(StepRepr_HArray1OfRepresentationItem)& aItems, const Handle(StepRepr_RepresentationContext)& aContextOfItems, const Handle(StepKinematics_MechanismRepresentation) aMechanism);
+
+  Standard_EXPORT void SetMechanism(const Handle(StepKinematics_MechanismRepresentation)& aMechanism);
+
+  Standard_EXPORT Handle(StepKinematics_MechanismRepresentation) Mechanism() const;
+
+private:
+  Handle(StepKinematics_MechanismRepresentation) representedMechanism;
+
+  DEFINE_STANDARD_RTTIEXT(StepKinematics_MechanismStateRepresentation,StepRepr_Representation)
+};
+
+#endif // _StepKinematics_MechanismStateRepresentation_HeaderFile
index bb8fc4d06ddecfd160e29e09504f34d63a7655c6..d7c42c2649368094e0ef00b9a75fab0c0db7cfca 100644 (file)
@@ -337,3 +337,9 @@ const Standard_GUID& XCAFDoc::KinematicRefLink2GUID()
   return ID;
 }
 
+Standard_EXPORT const Standard_GUID& XCAFDoc::KinematicRefJointGUID()
+{
+  static const Standard_GUID ID("6AA96F91-7436-46F9-A955-4B3CCC42692B");
+  return ID;
+}
+
index 9574cbcf703bbe66a8446dd6525c6000397bc0f6..ebbdf69c31921f82bec51705887a63d1d83339ba 100644 (file)
@@ -143,6 +143,9 @@ public:
   //! Return GUIDs for TreeNode representing specified types of Kinematics
   Standard_EXPORT static const Standard_GUID& KinematicRefLink2GUID();
 
+  //! Return GUIDs for TreeNode representing specified types of Kinematics
+  Standard_EXPORT static const Standard_GUID& KinematicRefJointGUID();
+
 };
 
 #endif // _XCAFDoc_HeaderFile
index 13914a775efd4f9c7793d37b40d69b208b394620..5fc0453ceb29abdbac9926d715d6b7115d15f6e2 100644 (file)
@@ -127,7 +127,8 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t
   }
 
   // Common attributes
-  TDataStd_Name::Set(Label(), theObject->Name());
+  if (!theObject->Name().IsEmpty())
+    TDataStd_Name::Set(Label(), theObject->Name());
   TDataStd_Integer::Set(Label(), theObject->Type());
   TDataXtd_Plane::Set(Label().FindChild(ChildLab_FirstTrsf), gp_Pln(theObject->FirstTransformation()));
   TDataXtd_Plane::Set(Label().FindChild(ChildLab_SecondTrsf), gp_Pln(theObject->SecondTransformation()));
index 069115ee18f79454bb8a15934d6a6ec3b66e7a0f..4a6eb94c97bffc8ca7d5303510aff48d98a8ade0 100644 (file)
@@ -21,6 +21,7 @@
 #include <TDataStd_Name.hxx>
 #include <TDataStd_Integer.hxx>
 #include <TDataStd_RealArray.hxx>
+#include <TDataStd_TreeNode.hxx>
 #include <TDF_ChildIterator.hxx>
 #include <XCAFDoc.hxx>
 #include <XCAFDoc_KinematicPair.hxx>
@@ -31,7 +32,7 @@ IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_KinematicPairValue, TDF_Attribute)
 // Gor first children are reserved for kinematic pair parameters
 enum ValueLab
 {
-  ValueLab_Values = 5
+  ValueLab_Values = 3
 };
 
 //=======================================================================
@@ -57,12 +58,35 @@ const Standard_GUID& XCAFDoc_KinematicPairValue::GetID()
 //function : Set
 //purpose  : 
 //=======================================================================
-Handle(XCAFDoc_KinematicPairValue) XCAFDoc_KinematicPairValue::Set(const TDF_Label& theLabel)
+Handle(XCAFDoc_KinematicPairValue) XCAFDoc_KinematicPairValue::Set(const TDF_Label& theValue,
+                                                                   const TDF_Label& theJoint)
 {
   Handle(XCAFDoc_KinematicPairValue) anAttr;
-  if (!theLabel.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), anAttr)) {
+  if (!theValue.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), anAttr)) {
     anAttr = new XCAFDoc_KinematicPairValue();
-    theLabel.AddAttribute(anAttr);
+    theValue.AddAttribute(anAttr);
+  }
+
+  Handle(TDataStd_TreeNode) aJointNode, aValueNode;
+  // Add reference to Joint
+  aValueNode = TDataStd_TreeNode::Set(theJoint, XCAFDoc::KinematicRefJointGUID());
+  aJointNode = TDataStd_TreeNode::Set(theValue, XCAFDoc::KinematicRefJointGUID());
+
+  aValueNode->Append(aJointNode);
+
+  return anAttr;
+}
+
+//=======================================================================
+//function : Set
+//purpose  : 
+//=======================================================================
+Handle(XCAFDoc_KinematicPairValue) XCAFDoc_KinematicPairValue::Set(const TDF_Label& theValue)
+{
+  Handle(XCAFDoc_KinematicPairValue) anAttr;
+  if (!theValue.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), anAttr)) {
+    anAttr = new XCAFDoc_KinematicPairValue();
+    theValue.AddAttribute(anAttr);
   }
   return anAttr;
 }
@@ -75,29 +99,17 @@ void XCAFDoc_KinematicPairValue::SetObject(const Handle(XCAFKinematics_PairValue
 {
   Backup();
 
-  Label().FindChild(ValueLab_Values).ForgetAllAttributes();
-
-  // Check if kinematic pair and pair value on the given label are consistent
-  Handle(XCAFDoc_KinematicPair) aPairAttr;
-  if (!Label().FindAttribute(XCAFDoc_KinematicPair::GetID(), aPairAttr))
-    return;
-  Handle(TDataStd_Integer) aMainTypeAttr;
-  if (Label().FindAttribute(TDataStd_Integer::GetID(), aMainTypeAttr))
-  {
-    int aType = aMainTypeAttr->Get();
-    if (aType != theObject->Type())
-      return;
-  }
-
   // Check validity of object
   if (theObject->GetAllValues()->Length() == 0)
     return;
+  TCollection_AsciiString aName = "Value ";
+  aName.AssignCat(TCollection_AsciiString(Label().Tag()));
+  TDataStd_Name::Set(Label(), aName);
 
-  TDataStd_Name::Set(Label().FindChild(ValueLab_Values), "Value");
-  TDataStd_Integer::Set(Label().FindChild(ValueLab_Values), theObject->Type());
+  TDataStd_Integer::Set(Label(), theObject->Type());
 
   Handle(TDataStd_RealArray) aValuesAttr;
-  aValuesAttr = TDataStd_RealArray::Set(Label().FindChild(ValueLab_Values), 1, theObject->GetAllValues()->Length());
+  aValuesAttr = TDataStd_RealArray::Set(Label(), 1, theObject->GetAllValues()->Length());
   aValuesAttr->ChangeArray(theObject->GetAllValues());
 }
 
@@ -110,7 +122,7 @@ Handle(XCAFKinematics_PairValueObject) XCAFDoc_KinematicPairValue::GetObject()
   // Type
   Handle(TDataStd_Integer) aTypeAttr;
   Handle(XCAFKinematics_PairValueObject) anObject = new XCAFKinematics_PairValueObject();
-  if (Label().FindChild(ValueLab_Values).FindAttribute(TDataStd_Integer::GetID(), aTypeAttr))
+  if (Label().FindAttribute(TDataStd_Integer::GetID(), aTypeAttr))
   {
     int aType = aTypeAttr->Get();
     anObject->SetType((XCAFKinematics_PairType)aType);
@@ -118,7 +130,7 @@ Handle(XCAFKinematics_PairValueObject) XCAFDoc_KinematicPairValue::GetObject()
 
   // Values
   Handle(TDataStd_RealArray) aValuesAttr;
-  if (Label().FindChild(ValueLab_Values).FindAttribute(TDataStd_RealArray::GetID(), aValuesAttr)) {
+  if (Label().FindAttribute(TDataStd_RealArray::GetID(), aValuesAttr)) {
     Handle(TColStd_HArray1OfReal) aValuesArray = aValuesAttr->Array();
     anObject->SetAllValues(aValuesArray);
   }
index 9acfc24ad1d45000360fa8c042f58dbe7416da75..6d8895f36e5f4acf0c7f223407423d4f316e448f 100644 (file)
@@ -48,7 +48,9 @@ public:
   
   Standard_EXPORT static const Standard_GUID& GetID();
   
-  Standard_EXPORT static Handle(XCAFDoc_KinematicPairValue) Set (const TDF_Label& theLabel);
+  Standard_EXPORT static Handle(XCAFDoc_KinematicPairValue) Set(const TDF_Label& theValue, const TDF_Label& theJoint);
+
+  Standard_EXPORT static Handle(XCAFDoc_KinematicPairValue) Set(const TDF_Label& theValue);
   
   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
   
index e389209f1a02e082f88547a9e4d948eca4846e37..b41c5a3e7d94935ad51b5bf58c18993f89cdf558 100644 (file)
@@ -26,6 +26,7 @@
 #include <XCAFDoc_DocumentTool.hxx>
 #include <XCAFDoc_GraphNode.hxx>
 #include <XCAFDoc_KinematicPair.hxx>
+#include <XCAFDoc_KinematicPairValue.hxx>
 #include <XCAFDoc_ShapeTool.hxx>
 
 IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_KinematicTool, TDF_Attribute)
@@ -101,7 +102,7 @@ Standard_Boolean XCAFDoc_KinematicTool::IsMechanism(const TDF_Label& theLabel) c
   if (!Label().IsEqual(theLabel.Father()))
     return Standard_False;
 
-  return (theLabel.NbChildren() == 2);
+  return (theLabel.NbChildren() == 2 || theLabel.NbChildren() == 3);
 }
 
 //=======================================================================
@@ -129,9 +130,12 @@ TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism)
 {
   if (!IsMechanism(theMechanism))
     return TDF_Label();
-
   TDF_TagSource aTag;
-  return aTag.NewChild(getRootOfLinks(theMechanism));
+  TDF_Label aLink = aTag.NewChild(getRootOfLinks(theMechanism));
+  TCollection_AsciiString aName = "Link ";
+  aName.AssignCat(TCollection_AsciiString(aLink.Tag()));
+  TDataStd_Name::Set(aLink, aName);
+  return aLink;
 }
 
 //=======================================================================
@@ -149,6 +153,87 @@ TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism,
   return aNewLink;
 }
 
+TDF_Label XCAFDoc_KinematicTool::AddBaseLink(const TDF_Label& theMechanism)
+{
+  if (!IsMechanism(theMechanism))
+    return TDF_Label();
+  TDF_Label aRootOfLink = getRootOfLinks(theMechanism);
+  if (aRootOfLink.HasChild())
+  {
+    TDF_Label aFirstLink = aRootOfLink.FindChild(1, Standard_False);
+    TDF_Label aResLink;
+    Handle(TDataStd_Name) aNameOfFirst;
+    aFirstLink.FindAttribute(TDataStd_Name::GetID(), aNameOfFirst);
+    if (!aNameOfFirst.IsNull() && !aNameOfFirst->Get().IsEqual("Base") && !aNameOfFirst->Get().IsEqual("Link 1"))
+    {
+      TDF_TagSource aTag;
+      TDF_Label aResLink = aTag.NewChild(aRootOfLink);
+      aResLink.AddAttribute(aNameOfFirst);
+    }
+    else
+      aResLink = AddLink(theMechanism);
+
+    TDF_LabelSequence theShapes = GetRefShapes(aFirstLink);
+    SetLink(aResLink, theShapes);
+
+    Handle(TDataStd_TreeNode) aJointNode, aLinkNode, aNewLinkNode, aNewJointNode;
+    if (aFirstLink.FindAttribute(XCAFDoc::KinematicRefLink1GUID(), aJointNode))
+    {
+      aJointNode = aJointNode->First();
+      while (!aJointNode.IsNull())
+      {
+        TDF_Label aJoint = aJointNode->Label();
+        aNewJointNode = TDataStd_TreeNode::Set(aJoint, XCAFDoc::KinematicRefLink1GUID()); 
+        aNewLinkNode = TDataStd_TreeNode::Set(aResLink, XCAFDoc::KinematicRefLink1GUID()); 
+        aNewJointNode->Remove(); // fix against bug in TreeNode::Append()
+        aNewLinkNode->Append(aNewJointNode);
+
+        aJointNode = aJointNode->Next();
+      }
+    }
+    if (aFirstLink.FindAttribute(XCAFDoc::KinematicRefLink2GUID(), aJointNode))
+    {
+      aJointNode = aJointNode->First();
+      while (!aJointNode.IsNull())
+      {
+        TDF_Label aJoint = aJointNode->Label();
+        aNewJointNode = TDataStd_TreeNode::Set(aJoint, XCAFDoc::KinematicRefLink2GUID());
+        aNewLinkNode = TDataStd_TreeNode::Set(aResLink, XCAFDoc::KinematicRefLink2GUID());
+        aNewJointNode->Remove(); // fix against bug in TreeNode::Append()
+        aNewLinkNode->Append(aNewJointNode);
+
+        aJointNode = aJointNode->Next();
+      }
+    }
+  }
+  TDF_Label aBaseLink = aRootOfLink.FindChild(1);
+  aBaseLink.ForgetAllAttributes(Standard_False);
+  TCollection_AsciiString aName = "Base";
+  TDataStd_Name::Set(aBaseLink, aName);
+  return aBaseLink;
+}
+
+TDF_Label XCAFDoc_KinematicTool::AddBaseLink(const TDF_Label& theMechanism, const TDF_Label& theShape)
+{
+  TDF_LabelSequence anAuxSequence;
+  anAuxSequence.Append(theShape);
+  return AddBaseLink(theMechanism, anAuxSequence);
+}
+
+//=======================================================================
+//function : AddBaseLink
+//purpose  : 
+//=======================================================================
+TDF_Label XCAFDoc_KinematicTool::AddBaseLink(const TDF_Label& theMechanism, const TDF_LabelSequence& theShapes)
+{
+  TDF_Label aNewLink = AddBaseLink(theMechanism);
+  if (aNewLink.IsNull() || theShapes.Length() == 0)
+    return aNewLink;
+
+  SetLink(aNewLink, theShapes);
+  return aNewLink;
+}
+
 //=======================================================================
 //function : AddLink
 //purpose  : 
@@ -207,12 +292,12 @@ Standard_Boolean XCAFDoc_KinematicTool::SetLink(const TDF_Label& theLink,
 //function : SetLink
 //purpose  : 
 //=======================================================================
-Standard_Boolean XCAFDoc_KinematicTool::SetLink(const TDF_Label& theMechanism,
+Standard_Boolean XCAFDoc_KinematicTool::SetLink(const TDF_Label& theLink,
                                                 const TDF_Label& theShape)
 {
   TDF_LabelSequence anAuxSequence;
   anAuxSequence.Append(theShape);
-  return SetLink(theMechanism, anAuxSequence);
+  return SetLink(theLink, anAuxSequence);
 }
 
 //=======================================================================
@@ -266,6 +351,9 @@ TDF_Label XCAFDoc_KinematicTool::AddJoint(const TDF_Label& theMechanism)
   TDF_TagSource aTag;
   TDF_Label aJoint = aTag.NewChild(getRootOfJoints(theMechanism));
   Handle(XCAFDoc_KinematicPair) aPair = XCAFDoc_KinematicPair::Set(aJoint);
+  TCollection_AsciiString aName = "Joint ";
+  aName.AssignCat(TCollection_AsciiString(aJoint.Tag()));
+  TDataStd_Name::Set(aJoint, aName);
   return aJoint;
 }
 
@@ -307,6 +395,7 @@ Standard_Boolean XCAFDoc_KinematicTool::SetJoint(const TDF_Label& theJoint,
   if (!IsLink(theLink1) || !IsLink(theLink2))
     return Standard_False;
 
+
   Handle(TDataStd_TreeNode) aJointNode, aLinkNode;
   // Add reference to first link
   aJointNode = TDataStd_TreeNode::Set(theJoint, XCAFDoc::KinematicRefLink1GUID());
@@ -319,6 +408,10 @@ Standard_Boolean XCAFDoc_KinematicTool::SetJoint(const TDF_Label& theJoint,
   aLinkNode = TDataStd_TreeNode::Set(theLink2, XCAFDoc::KinematicRefLink2GUID());
   aJointNode->Remove(); // fix against bug in TreeNode::Append()
   aLinkNode->Append(aJointNode);
+
+  TCollection_AsciiString aName = "Joint ";
+  aName.AssignCat(TCollection_AsciiString(theJoint.Tag()));
+  TDataStd_Name::Set(theJoint, aName);
   return Standard_True;
 }
 
@@ -341,6 +434,12 @@ void XCAFDoc_KinematicTool::RemoveJoint(const TDF_Label& theJoint)
 
 }
 
+Standard_EXPORT Standard_Boolean XCAFDoc_KinematicTool::IsValue(const TDF_Label& theValue) const
+{
+  Handle(XCAFDoc_KinematicPairValue) anAttr;
+  return theValue.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), anAttr);
+}
+
 //=======================================================================
 //function : GetMechanisms
 //purpose  : 
@@ -446,6 +545,99 @@ TDF_LabelSequence XCAFDoc_KinematicTool::GetJointsOfLink(const TDF_Label& theLin
   return aJointsArray;
 }
 
+//=======================================================================
+//function : AddState
+//purpose  : 
+//=======================================================================
+Standard_EXPORT TDF_Label XCAFDoc_KinematicTool::AddState(const TDF_Label& theMechanism)
+{
+  if (!IsMechanism(theMechanism))
+    return TDF_Label();
+
+  TDF_Label aRootOfState= getRootOfStates(theMechanism);
+  if (aRootOfState.IsNull())
+  {
+    aRootOfState = theMechanism.FindChild(3);;
+    TDataStd_Name::Set(aRootOfState, "States");
+  }
+  TDF_TagSource aTag;
+  TDF_Label aState = aTag.NewChild(aRootOfState);
+  TCollection_AsciiString aName = "State ";
+  aName.AssignCat(TCollection_AsciiString(aState.Tag()));
+  TDataStd_Name::Set(aState, aName);
+  return aState;
+}
+
+//=======================================================================
+//function : GetStates
+//purpose  : 
+//=======================================================================
+Standard_EXPORT TDF_LabelSequence XCAFDoc_KinematicTool::GetStates(const TDF_Label& theMechanism) const
+{
+  TDF_Label aRootOfState = getRootOfStates(theMechanism);
+  TDF_LabelSequence aStatesArray;
+  if (!IsMechanism(theMechanism) || aRootOfState.IsNull())
+    return aStatesArray;
+
+  for (TDF_ChildIterator anIt(aRootOfState); anIt.More(); anIt.Next()) {
+    TDF_Label aState = anIt.Value();
+    aStatesArray.Append(aState);
+  }
+  return aStatesArray;
+}
+
+Standard_EXPORT TDF_LabelSequence XCAFDoc_KinematicTool::GetValuesOfState(const TDF_Label& theState) const
+{
+  TDF_LabelSequence aValueArray;
+  if (!IsMechanism(theState.Father().Father()) || theState.Father().Tag() != 3)
+    return aValueArray;
+
+  for (TDF_ChildIterator anIt(theState); anIt.More(); anIt.Next()) {
+    TDF_Label aValue = anIt.Value();
+    if (IsValue(aValue))
+      aValueArray.Append(aValue);
+  }
+
+  return aValueArray;
+}
+
+//=======================================================================
+//function : GetJointOfValue
+//purpose  : 
+//=======================================================================
+Standard_EXPORT TDF_Label XCAFDoc_KinematicTool::GetJointOfValue(const TDF_Label& theValue) const
+{
+  TDF_Label aJoint;
+  if (!IsValue(theValue))
+    return aJoint;
+
+  Handle(TDataStd_TreeNode) aNode, aChildNode;
+
+  if (theValue.FindAttribute(XCAFDoc::KinematicRefJointGUID(), aNode))
+    aJoint = aNode->Father()->Label();
+  return aJoint;
+}
+
+//=======================================================================
+//function : RemoveState
+//purpose  : 
+//=======================================================================
+Standard_EXPORT void XCAFDoc_KinematicTool::RemoveState(const TDF_Label& theState)
+{
+  TDF_Label aMechanism = theState.Father().Father();
+  if (!IsMechanism(aMechanism) || theState.Father().Tag() != 3)
+    return;
+
+  Handle(TDataStd_TreeNode) aNode;
+  theState.FindAttribute(XCAFDoc::KinematicRefLink1GUID(), aNode);
+  aNode->Remove();
+
+  theState.ForgetAllAttributes();
+  TDF_Label theStates = theState.Father();
+  if (!theStates.HasChild())
+    theStates.ForgetAllAttributes();
+}
+
 //=======================================================================
 //function : GetRefShapes
 //purpose  : 
@@ -479,6 +671,15 @@ TDF_Label XCAFDoc_KinematicTool::getRootOfJoints(const TDF_Label& theMechanism)
   return theMechanism.FindChild(2, Standard_False);
 }
 
+//=======================================================================
+//function : getRootOfStates
+//purpose  : 
+//=======================================================================
+Standard_EXPORT TDF_Label XCAFDoc_KinematicTool::getRootOfStates(const TDF_Label& theMechanism) const
+{
+  return theMechanism.FindChild(3, Standard_False);
+}
+
 //=======================================================================
 //function : ID
 //purpose  : 
index 383b8657e0c97ca349ae57165e0fb637d2dc1758..747a9bbbde6bb403265f083b91591c48a301fac7 100644 (file)
@@ -73,6 +73,28 @@ public:
   Standard_EXPORT TDF_Label AddLink(const TDF_Label& theMechanism,
                                     const TDF_LabelSequence& theShapes);
 
+  //! Adds new empty label for link.
+  //! \replace first link  into the end, if it exist
+  //! \param[in] theMechanism parent mechanism
+  //! \return created link label
+  Standard_EXPORT TDF_Label AddBaseLink(const TDF_Label& theMechanism);
+
+  //! Adds new label with link.
+  //! \replace first link  into the end, if it exist
+  //! \param[in] theMechanism parent mechanism
+  //! \param[in] theShape singular detail of link
+  //! \return created link label
+  Standard_EXPORT TDF_Label AddBaseLink(const TDF_Label& theMechanism,
+                                        const TDF_Label& theShapes);
+
+  //! Adds new label with link.
+  //! \replace first link  into the end, if it exist
+  //! param[in] theMechanism parent mechanism
+  //! param[in] theShapes all details of link
+  //! \return created link label
+  Standard_EXPORT TDF_Label AddBaseLink(const TDF_Label& theMechanism,
+                                        const TDF_LabelSequence& theShapes);
+
   //! Adds new label with link.
   //! \param[in] theMechanism parent mechanism
   //! \param[in] theShape singular detail of link
@@ -133,6 +155,34 @@ public:
   //! \param[in] thejoint joint to remove
   Standard_EXPORT void RemoveJoint(const TDF_Label& theJoint);
 
+  //! Checks is the given label a Value
+  //! \return the result of check
+  Standard_EXPORT Standard_Boolean IsValue(const TDF_Label& theValue) const;
+
+  //! Adds new empty label for State.
+  //! \param[in] theMechanism parent mechanism
+  //! \return created state label
+  Standard_EXPORT TDF_Label AddState(const TDF_Label& theMechanism);
+
+  // Retrieves all States labels of the given mechanism
+  //! \param[in] theMechanism parent mechanism
+  //! \return state set
+  Standard_EXPORT TDF_LabelSequence GetStates(const TDF_Label& theMechanism) const;
+
+  // Retrieves all values labels of the given state
+  //! \param[in] theState parent state
+  //! \return value set
+  Standard_EXPORT TDF_LabelSequence GetValuesOfState(const TDF_Label& theState) const;
+
+  //! Gets references to joints of the given value.
+  //! \param[in] theValue value to get
+  //! \return a joint
+  Standard_EXPORT TDF_Label GetJointOfValue(const TDF_Label& theValue) const;
+
+  //! Removes the given state
+  //! \param[in] theState state to remove
+  Standard_EXPORT void RemoveState(const TDF_Label& theState);
+  
   //! Retrieves all mechanisms labels
   //! \return mechanisms set
   Standard_EXPORT TDF_LabelSequence GetMechanisms() const;
@@ -182,6 +232,8 @@ public:
   
   Standard_EXPORT TDF_Label getRootOfJoints(const TDF_Label& theMechanism) const;
 
+  Standard_EXPORT TDF_Label getRootOfStates(const TDF_Label& theMechanism) const;
+
   DEFINE_STANDARD_RTTIEXT(XCAFDoc_KinematicTool, TDF_Attribute)
 
 };
index eaeb089638d8d477bec09d71fa05f77f3029b656..2b080e5e8724df2f70b7af13a30973a477a68367 100644 (file)
@@ -116,6 +116,18 @@ void XCAFKinematics_HighOrderPairObject::SetAllLimits(const Handle(TColStd_HArra
     myLimits = theLimits;
 }
 
+//=======================================================================
+//function : SetAllLimits
+//purpose  : 
+//=======================================================================
+Standard_Boolean XCAFKinematics_HighOrderPairObject::HasLimits() const
+{
+  Standard_Boolean IsConstraint = Standard_False;
+  for (Standard_Integer anInd = 1; anInd < myLimits->Length() && !IsConstraint; ++anInd)
+    IsConstraint = myLimits->Value(anInd) != NULL;
+  return IsConstraint;
+}
+
 //=======================================================================
 //function : SetRotationLowLimit
 //purpose  : 
index 94cf853e4bbeb9bb2c01e37dfa4101828fdb545b..3bbcc9fbaca33f77b392f08e38745bcb761b8a8a 100644 (file)
@@ -58,6 +58,8 @@ public:
 
   Standard_EXPORT void SetAllLimits(const Handle(TColStd_HArray1OfReal)& theLimits) Standard_OVERRIDE;
 
+  Standard_EXPORT Standard_Boolean HasLimits() const Standard_OVERRIDE;
+
   Handle(TColStd_HArray1OfReal) GetAllLimits() const Standard_OVERRIDE
   {
     return myLimits;
index 423261a6999d5da5680759b12dfb9b511fa63bfd..c079c0da4587bc58f0b3a0f672f8994e18d7490d 100644 (file)
@@ -85,6 +85,28 @@ Handle(TColStd_HArray1OfReal) XCAFKinematics_LowOrderPairObject::GetAllLimits()
   return aLimitArray;
 }
 
+//=======================================================================
+//function : HasLimits
+//purpose  : 
+//=======================================================================
+Standard_Boolean XCAFKinematics_LowOrderPairObject::HasLimits() const
+{
+  return 
+  (  myMinRotationX != -Precision::Infinite() ||
+      myMaxRotationX != Precision::Infinite() ||
+     myMinRotationY != -Precision::Infinite() ||
+      myMaxRotationY != Precision::Infinite() ||
+     myMinRotationZ != -Precision::Infinite() ||
+      myMaxRotationZ != Precision::Infinite() ||
+  myMinTranslationX != -Precision::Infinite() ||
+   myMaxTranslationX != Precision::Infinite() ||
+  myMinTranslationY != -Precision::Infinite() ||
+   myMaxTranslationY != Precision::Infinite() ||
+  myMinTranslationZ != -Precision::Infinite() ||
+   myMaxTranslationZ != Precision::Infinite()
+  );
+}
+
 //=======================================================================
 //function : GetAllLimits
 //purpose  : 
index e80b0ca83beed7f6041db0aaf8953e1f01e7fb45..abc982871196c3436746815195a94f7c42eaa7a5 100644 (file)
@@ -196,6 +196,8 @@ public:
   //! \return created array
   Standard_EXPORT Handle(TColStd_HArray1OfReal) GetAllLimits() const Standard_OVERRIDE;
 
+  Standard_EXPORT virtual Standard_Boolean HasLimits() const Standard_OVERRIDE;
+
   Standard_EXPORT void SetAllLimits(const Handle(TColStd_HArray1OfReal)& theLimits) Standard_OVERRIDE;
 
   DEFINE_STANDARD_RTTIEXT(XCAFKinematics_LowOrderPairObject, XCAFKinematics_PairObject)
index 637d6c9cf9485d2194992d0c2b98aa57b55b3fe3..58a58281a9cc4bdb04efc0f69899aba437893aad 100644 (file)
@@ -227,6 +227,18 @@ void XCAFKinematics_LowOrderPairObjectWithCoupling::SetAllParams(const Handle(TC
     myParams = theParams;
 }
 
+//=======================================================================
+//function : HasLimits
+//purpose  : 
+//=======================================================================
+Standard_Boolean XCAFKinematics_LowOrderPairObjectWithCoupling::HasLimits() const
+{
+  return
+    (  myLowLimit != -Precision::Infinite() ||
+      myUpperLimit != Precision::Infinite()
+    );
+}
+
 //=======================================================================
 //function : SetAllLimits
 //purpose  : 
index f8a863fba68c3932621e51f7301a1b3d5d2e156c..3234cb65af81d55927fcf7ac93feea85e2eb4f9d 100644 (file)
@@ -128,6 +128,8 @@ public:
     return myParams;
   }
 
+  Standard_EXPORT Standard_Boolean HasLimits() const Standard_OVERRIDE;
+
   Standard_EXPORT void SetAllLimits(const Handle(TColStd_HArray1OfReal)& theLimits) Standard_OVERRIDE;
 
   DEFINE_STANDARD_RTTIEXT(XCAFKinematics_LowOrderPairObjectWithCoupling, XCAFKinematics_PairObject)
index ba9d38f3ae52a5cf894b945a28096ca12b588f76..9d828ba89e328139da96b32628f451066e94ba8d 100644 (file)
@@ -79,6 +79,11 @@ public:
 
   Standard_EXPORT virtual void SetAllLimits(const Handle(TColStd_HArray1OfReal)& /*theLimits*/) {};
 
+  Standard_EXPORT virtual Standard_Boolean HasLimits() const 
+  {
+    return Standard_False;
+  };
+
   Standard_EXPORT virtual Handle(TColStd_HArray1OfReal) GetAllLimits() const
   {
     return new TColStd_HArray1OfReal();
index a69c00e4bcd966d45ead124d203f17c665cc22da..33dd6b5bf760c5b8a0755ce9005837cabc8cb0cf 100644 (file)
@@ -39,7 +39,7 @@ enum XCAFKinematics_PairType
   XCAFKinematics_PairType_Screw,
   XCAFKinematics_PairType_RackAndPinion,
   XCAFKinematics_PairType_Gear,
-  XCAFKinematics_LinearFlexibleAndPinionPair,
+  XCAFKinematics_PairType_LinearFlexibleAndPinion,
 
   // High order pairs
   XCAFKinematics_PairType_PointOnSurface,
@@ -48,7 +48,7 @@ enum XCAFKinematics_PairType
   XCAFKinematics_PairType_PointOnPlanarCurve,
   XCAFKinematics_PairType_SlidingCurve,
   XCAFKinematics_PairType_RollingCurve,
-  XCAFKinematics_PairType_LinearFlexibleAndPlanarCurvePair
+  XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve
 };
 
 #endif // _XCAFKinematics_PairType_HeaderFile
index 9a8c1357f4a91bce6533e164194b4fd0ff9fd880..4f9bb66fb74f011f0801f0a6177dc9e41b4b869c 100644 (file)
@@ -162,7 +162,7 @@ static Standard_Integer removeMechanism(Draw_Interpretor& di, Standard_Integer a
 static Standard_Integer addLink(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
 {
   if (argc < 3) {
-    di << "Use: XAddLink Doc ParentMechanism [shapeLabel1 .. shapeLabelN]\n";
+    di << "Use: XAddLink Doc ParentMechanism [-Base] [shapeLabel1 .. shapeLabelN]\n";
     return 1;
   }
 
@@ -173,9 +173,9 @@ static Standard_Integer addLink(Draw_Interpretor& di, Standard_Integer argc, con
   TDF_Label aMechanism;
   if (!getLabel(di, aDoc, argv[2], aMechanism))
     return 1;
-
+  Standard_Boolean IsBase = argc >= 4 && TCollection_AsciiString(argv[3]).IsEqual("-Base");
   TDF_LabelSequence aShapeArray;
-  for (Standard_Integer i = 3; i < argc; i++) {
+  for (Standard_Integer i = (IsBase) ? 4 : 3; i < argc; i++) {
     TDF_Label aLabel;
     if (!getLabel(di, aDoc, argv[i], aLabel))
       continue;
@@ -183,8 +183,10 @@ static Standard_Integer addLink(Draw_Interpretor& di, Standard_Integer argc, con
   }
 
   Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
-  di << getEntry(aTool->AddLink(aMechanism, aShapeArray));
-
+  if(IsBase)
+    di << getEntry(aTool->AddBaseLink(aMechanism, aShapeArray));
+  else 
+    di << getEntry(aTool->AddLink(aMechanism, aShapeArray));
   return 0;
 }
 
@@ -649,10 +651,10 @@ static Standard_Integer setType(Draw_Interpretor& di, Standard_Integer argc, con
         aType <= XCAFKinematics_PairType_Unconstrained)
       anObject = new XCAFKinematics_LowOrderPairObject();
     else if (aType >= XCAFKinematics_PairType_Screw &&
-             aType <= XCAFKinematics_PairType_Gear)
+             aType <= XCAFKinematics_PairType_LinearFlexibleAndPinion)
       anObject = new XCAFKinematics_LowOrderPairObjectWithCoupling();
     else if (aType >= XCAFKinematics_PairType_PointOnSurface &&
-             aType <= XCAFKinematics_PairType_RollingCurve)
+             aType <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve)
       anObject = new XCAFKinematics_HighOrderPairObject();
     anObject->SetType((XCAFKinematics_PairType)aType);
     aPair->SetObject(anObject);
@@ -1194,29 +1196,63 @@ static Standard_Integer getGeomParam(Draw_Interpretor& di, Standard_Integer argc
 }
 
 //=======================================================================
-//function : setValues
+//function : addMechanismState
 //purpose  : 
 //=======================================================================
-static Standard_Integer setValues(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+static Standard_Integer addMechanismState(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
 {
-  if (argc < 5) {
-    di << "Use: XSetPairValues Doc Joint -Key1 Values1... -KeyN ValuesN\n";
+  if (argc < 3) {
+    di << "Use: XAddMechanismState Doc ParentMechanism\n";
     return 1;
   }
 
   Handle(TDocStd_Document) aDoc;
   if (!getDocument(di, argv[1], aDoc))
     return 1;
+
+  TDF_Label aMechanism;
+  if (!getLabel(di, aDoc, argv[2], aMechanism))
+    return 1;
+
   Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
-  TDF_Label aJoint;
-  if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+  di << getEntry(aTool->AddState(aMechanism));
+  return 0;
+}
+
+//=======================================================================
+//function : addValues
+//purpose  : 
+//=======================================================================
+static Standard_Integer addValues(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+  if (argc < 3) {
+    di << "Use: XAddPairValues Doc State [Joint -Key1 Values1... -KeyN ValuesN]\n";
     return 1;
+  }
 
-  Handle(XCAFKinematics_PairValueObject) anObject;
-  Handle(XCAFDoc_KinematicPairValue) aPairValue;
-  if (aJoint.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aPairValue))
-    anObject = aPairValue->GetObject();
+  Handle(TDocStd_Document) aDoc;
+  if (!getDocument(di, argv[1], aDoc))
+    return 1;
+  Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+  TDF_Label aState;
+  if (!getLabel(di, aDoc, argv[2], aState))
+    return 1;
+  TDF_Label aMechanism = aState.Father().Father();
+
+  TDF_TagSource aTag;
+  TDF_Label aValue = aTag.NewChild(aState);
+  if (argc == 3)
+  {
+    Handle(XCAFDoc_KinematicPairValue) aPairValue;
+    XCAFDoc_KinematicPairValue::Set(aValue);
+  }
   else {
+    TDF_Label aJoint;
+    if (!getLabel(di, aDoc, argv[3], aJoint) || !aTool->IsJoint(aJoint))
+      return 1;
+
+    Handle(XCAFKinematics_PairValueObject) anObject;
+    Handle(XCAFDoc_KinematicPairValue) aPairValue;
     Handle(XCAFDoc_KinematicPair) aPair;
     if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
       di << "Invalid kinematic pair object\n";
@@ -1225,11 +1261,117 @@ static Standard_Integer setValues(Draw_Interpretor& di, Standard_Integer argc, c
     Handle(XCAFKinematics_PairObject) aPairObject = aPair->GetObject();
     anObject = new XCAFKinematics_PairValueObject();
     anObject->SetType(aPairObject->Type());
-    aPairValue = XCAFDoc_KinematicPairValue::Set(aJoint);
+    aPairValue = XCAFDoc_KinematicPairValue::Set(aValue, aJoint);
+
+    try {
+      Standard_Integer anIt = 4;
+      while (anIt < argc) {
+        TCollection_AsciiString aKey = argv[anIt];
+        if (aKey.IsEqual("-rotation"))
+          anObject->SetRotation(Atof(argv[++anIt]));
+        else if (aKey.IsEqual("-first_rotation"))
+          anObject->SetFirstRotation(Atof(argv[++anIt]));
+        else if (aKey.IsEqual("-second_rotation"))
+          anObject->SetSecondRotation(Atof(argv[++anIt]));
+        else if (aKey.IsEqual("-translation"))
+          anObject->SetTranslation(Atof(argv[++anIt]));
+        else if (aKey.IsEqual("-first_translation"))
+          anObject->SetFirstTranslation(Atof(argv[++anIt]));
+        else if (aKey.IsEqual("-second_translation"))
+          anObject->SetSecondTranslation(Atof(argv[++anIt]));
+        else if (aKey.IsEqual("-point_on_surface")) {
+          anObject->SetPointOnSurface(Atof(argv[anIt + 1]), Atof(argv[anIt + 2]));
+          anIt += 2;
+        }
+        else if (aKey.IsEqual("-first_point_on_surface")) {
+          anObject->SetFirstPointOnSurface(Atof(argv[anIt + 1]), Atof(argv[anIt + 2]));
+          anIt += 2;
+        }
+        else if (aKey.IsEqual("-second_point_on_surface")) {
+          anObject->SetSecondPointOnSurface(Atof(argv[anIt + 1]), Atof(argv[anIt + 2]));
+          anIt += 2;
+        }
+        else if (aKey.IsEqual("-point_on_curve"))
+          anObject->SetPointOnCurve(Atof(argv[++anIt]));
+        else if (aKey.IsEqual("-first_point_on_curve"))
+          anObject->SetFirstPointOnCurve(Atof(argv[++anIt]));
+        else if (aKey.IsEqual("-second_point_on_curve"))
+          anObject->SetSecondPointOnCurve(Atof(argv[++anIt]));
+        else if (aKey.IsEqual("-ypr")) {
+          anObject->SetYPR(Atof(argv[anIt + 1]), Atof(argv[anIt + 2]), Atof(argv[anIt + 3]));
+          anIt += 3;
+        }
+        else if (aKey.IsEqual("-trsf")) {
+          gp_Pnt aLoc(Atof(argv[anIt + 1]), Atof(argv[anIt + 2]), Atof(argv[anIt + 3]));
+          gp_Dir aDir(Atof(argv[anIt + 4]), Atof(argv[anIt + 5]), Atof(argv[anIt + 6]));
+          gp_Dir aXDir(Atof(argv[anIt + 7]), Atof(argv[anIt + 8]), Atof(argv[anIt + 9]));
+          anIt += 9;
+          gp_Ax2 aResult = gp_Ax2(aLoc, aDir, aXDir);
+          anObject->SetTransformation(aResult);
+        }
+        anIt++;
+      }
+    }
+    catch (...) {
+      di << "Invalid number of parameters";
+      return 1;
+    }
+
+    aPairValue->SetObject(anObject);
+  }
+
+  di << getEntry(aValue);
+  return 0;
+}
+
+//=======================================================================
+//function : setValues
+//purpose  : 
+//=======================================================================
+static Standard_Integer setValues(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+  if (argc < 6) {
+    di << "Use: XSetPairValues Doc Value Joint -Key1 Values1... -KeyN ValuesN\n";
+    return 1;
+  }
+
+  Handle(TDocStd_Document) aDoc;
+  if (!getDocument(di, argv[1], aDoc))
+    return 1;
+  Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+  TDF_Label aJoint;
+  if (!getLabel(di, aDoc, argv[3], aJoint) || !aTool->IsJoint(aJoint))
+    return 1;
+  TDF_Label aMechanism = aJoint.Father().Father();
+  TDF_Label aValue;
+  if (!getLabel(di, aDoc, argv[2], aValue) || !aTool->IsValue(aValue))
+    return 1;
+
+  Handle(XCAFKinematics_PairValueObject) anObject;
+  Handle(XCAFDoc_KinematicPairValue) aPairValue;
+  Handle(XCAFDoc_KinematicPair) aPair;
+
+  if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+    di << "Invalid kinematic pair object\n";
+    return 1;
+  }
+  Handle(XCAFKinematics_PairObject) aPairObject = aPair->GetObject();
+
+  if (aValue.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aPairValue))
+  {
+    aPairValue = XCAFDoc_KinematicPairValue::Set(aValue, aJoint);
+    anObject = aPairValue->GetObject();
+    if (anObject->GetAllValues().IsNull())
+      anObject->SetType(aPairObject->Type());
+  }
+  else {
+    anObject = new XCAFKinematics_PairValueObject();
+    aPairValue = XCAFDoc_KinematicPairValue::Set(aValue,aJoint);
+    anObject->SetType(aPairObject->Type());
   }
 
   try {
-    Standard_Integer anIt = 3;
+    Standard_Integer anIt = 4;
     while (anIt < argc) {
       TCollection_AsciiString aKey = argv[anIt];
       if (aKey.IsEqual("-rotation"))
@@ -1294,7 +1436,7 @@ static Standard_Integer setValues(Draw_Interpretor& di, Standard_Integer argc, c
 static Standard_Integer getValues(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
 {
   if (argc < 4) {
-    di << "Use: XGetPairValues Doc Joint -Key\n";
+    di << "Use: XGetPairValues Doc Value -Key\n";
     return 1;
   }
 
@@ -1302,13 +1444,14 @@ static Standard_Integer getValues(Draw_Interpretor& di, Standard_Integer argc, c
   if (!getDocument(di, argv[1], aDoc))
     return 1;
   Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
-  TDF_Label aJoint;
-  if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+  TDF_Label aValue;
+  if (!getLabel(di, aDoc, argv[2], aValue) || !aTool->IsValue(aValue))
     return 1;
 
+
   Handle(XCAFKinematics_PairValueObject) anObject;
   Handle(XCAFDoc_KinematicPairValue) aPairValue;
-  if (aJoint.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aPairValue))
+  if (aValue.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aPairValue))
     anObject = aPairValue->GetObject();
   if (anObject.IsNull()) {
     di << "Invalid value object";
@@ -1389,7 +1532,7 @@ void XDEDRAW_Kinematics::InitCommands(Draw_Interpretor& di)
   di.Add("XRemoveMechanism", "XRemoveMechanism Doc Label",
     __FILE__, removeMechanism, g);
 
-  di.Add("XAddLink", "XAddLink Doc ParentMechanism [shapeLabel1 .. shapeLabelN]",
+  di.Add("XAddLink", "XAddLink Doc ParentMechanism [-Base] [shapeLabel1 .. shapeLabelN]",
     __FILE__, addLink, g);
 
   di.Add("XSetLink", "XSetLink Doc Link shapeLabel1 .. shapeLabelN",
@@ -1453,12 +1596,13 @@ void XDEDRAW_Kinematics::InitCommands(Draw_Interpretor& di)
     "\t 11 Screw\n"
     "\t 12 RackAndPinion\n"
     "\t 13 Gear\n"
-    "\t 14 PointOnSurface\n"
-    "\t 15 SlidingSurface\n"
-    "\t 16 RollingSurface\n"
-    "\t 17 PointOnPlanarCurve\n"
-    "\t 18 SlidingCurve\n"
-    "\t 19 RollingCurve\n"
+    "\t 14 LinearFlexibleAndPinion\n"
+    "\t 15 PointOnSurface\n"
+    "\t 16 SlidingSurface\n"
+    "\t 17 RollingSurface\n"
+    "\t 18 PointOnPlanarCurve\n"
+    "\t 19 SlidingCurve\n"
+    "\t 20 RollingCurve\n"
     __FILE__, setType, g);
 
   di.Add("XGetPairType", "XGetPairType Doc Joint",
@@ -1501,7 +1645,19 @@ void XDEDRAW_Kinematics::InitCommands(Draw_Interpretor& di)
   di.Add("XGetPairGeomParam", "XGetPairGeomParam Doc Joint Number[1/2] Name",
     __FILE__, getGeomParam, g);
 
-  di.Add("XSetPairValues", "XSetPairValues Doc Joint -Key1 Values1 -KeyN ValuesN"
+  di.Add("XAddMechanismState", "XAddMechanismState Doc Mechanism",
+    __FILE__, addMechanismState, g);
+
+  di.Add("XAddPairValues", "XAddPairValues Doc State [Joint -Key1 Values1 -KeyN ValuesN]"
+    "\t-[first_/second_]rotation - current rotation - 1 number"
+    "\t-[first_/second_]translation - current translation - 1 number"
+    "\t-[first_/second_]point_on_surface - current (u,v) - 2 numbers"
+    "\t-[first_/second_]point_on_curve - current (t) - 1 number"
+    "\t-ypr - current yaw pitch roll angles - 3 numbers"
+    "\t-trsf - for unconstrained only current location direction xdirection - 9 numbers",
+    __FILE__, addValues, g);
+
+  di.Add("XSetPairValues", "XSetPairValues Doc Value Joint -Key1 Values1 -KeyN ValuesN"
     "\t-[first_/second_]rotation - current rotation - 1 number"
     "\t-[first_/second_]translation - current translation - 1 number"
     "\t-[first_/second_]point_on_surface - current (u,v) - 2 numbers"
@@ -1510,7 +1666,7 @@ void XDEDRAW_Kinematics::InitCommands(Draw_Interpretor& di)
     "\t-trsf - for unconstrained only current location direction xdirection - 9 numbers",
     __FILE__, setValues, g);
 
-  di.Add("XGetPairValues", "XGetPairValues Doc Joint -Key"
+  di.Add("XGetPairValues", "XGetPairValues Doc Value -Key"
     "\t-[first_/second_]rotation - current rotation - 1 number"
     "\t-[first_/second_]translation - current translation - 1 number"
     "\t-[first_/second_]point_on_surface - current (u,v) - 2 numbers"
index 2112707c07227ab8ab154b72e0b2a0536de65544..f5434a7f08f609177ce64772dfd050feb6a1bfd4 100644 (file)
@@ -46,10 +46,30 @@ if {$limits != "0 45 0 0 0 0 0 0 0 0 0 0 "} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -rotation 15
-set values [XGetPairValues D $joint -rotation]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -rotation 15
+set values [XGetPairValues D $value -rotation]
 if {$values != "15"} {
   puts "Error: wrong parameter"
 }
+set link4 [XAddLink D $mech -Base 0:1:1:2]
+set link3 [XAddLink D $mech 0:1:1:1]
+set joint2 [XAddJoint D $mech $link3 $link4]
+
+XSetPairTransformation D $joint2 1 p1
+XSetPairTransformation D $joint2 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+  puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+  puts "Error: wrong parameter"
+}
 
-Close D
index 1629b81a6caf302ccc67b4e9a5e3fa80087b74a1..767d746e8fce156e2cc0e8ffb1b7e55705fe6b07 100644 (file)
@@ -46,8 +46,11 @@ if {$limits != "0 0 0 0 0 0 0 0 0 10 0 0 "} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -translation 3
-set values [XGetPairValues D $joint -translation]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D  $value  $joint -translation 3
+set values [XGetPairValues D $value -translation]
 if {$values != "3"} {
   puts "Error: wrong parameter"
 }
index 3ea9e3c18028608b9de17d0b1c433753d2151a7c..d1e22eccfa182e5f3d6f2e939c6e7102d66e1279 100644 (file)
@@ -46,14 +46,19 @@ if {$limits != "0 45 0 0 0 0 0 0 0 10 0 0 "} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -rotation 15 -translation 3
-set values [XGetPairValues D $joint -translation]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value  $joint -rotation 15 -translation 3
+
+set values [XGetPairValues D $value -translation]
 if {$values != "3"} {
   puts "Error: wrong parameter"
 }
-set values [XGetPairValues D $joint -rotation]
+
+set values [XGetPairValues D $value -rotation]
 if {$values != "15"} {
   puts "Error: wrong parameter"
 }
-
 Close D
+
index f0d975433e6c5fe5ec99136d734aeb40cf23f57e..27421bdbf1d3f6316a346d373ce258f61daf5eaa 100644 (file)
@@ -52,12 +52,15 @@ if {$param != "Skew Angle = 30"} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -first_rotation 20 -second_rotation 15
-set values [XGetPairValues D $joint -first_rotation]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -first_rotation 20 -second_rotation 15
+set values [XGetPairValues D $value -first_rotation]
 if {$values != "20"} {
   puts "Error: wrong parameter"
 }
-set values [XGetPairValues D $joint -second_rotation]
+set values [XGetPairValues D $value -second_rotation]
 if {$values != "15"} {
   puts "Error: wrong parameter"
 }
index 9f1fd294048bcd4f09590d5ee0f40a47a44f0809..802121009501edbad1f903e54c5a40bb3d5f9591 100644 (file)
@@ -52,12 +52,15 @@ if {$param != "Skew Angle = 30"} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -rotation 20 -second_rotation 20
-set values [XGetPairValues D $joint -rotation]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -rotation 20 -second_rotation 20
+set values [XGetPairValues D $value -rotation]
 if {$values != "20"} {
   puts "Error: wrong parameter"
 }
-set values [XGetPairValues D $joint -second_rotation]
+set values [XGetPairValues D $value -second_rotation]
 if {$values != "20"} {
   puts "Error: wrong parameter"
 }
index 255390056d35dccf3d20f06ecd3f5574e4aae759..f8ff00d14a8149c6e010c04401b21a289966e331 100644 (file)
@@ -46,8 +46,11 @@ if {$limits != "0 45 0 0 30 60 0 0 0 0 0 0 "} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -ypr 10 0 30
-set values [XGetPairValues D $joint -ypr]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value  $joint -ypr 10 0 30
+set values [XGetPairValues D $value  -ypr]
 if {$values != "10 0 30"} {
   puts "Error: wrong parameter"
 }
index 8d4a4b7cb691635615ff87426eb19e979c3d9548..ec3e7dbac7db907f908ec312a62631e0fe47ab31 100644 (file)
@@ -46,8 +46,11 @@ if {$limits != "0 45 0 30 30 60 0 0 0 0 0 0 "} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -ypr 10 20 30
-set values [XGetPairValues D $joint -ypr]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -ypr 10 20 30
+set values [XGetPairValues D $value -ypr]
 if {$values != "10 20 30"} {
   puts "Error: wrong parameter"
 }
index fc6995bb1f5a32b44348e9449c72b0190d8e0a39..171fe6477b49f770352523dacd90ccc584d8e1e0 100644 (file)
@@ -46,17 +46,20 @@ if {$limits != "0 45 0 0 0 0 10 20 2 3 0 0 "} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -rotation 20 -first_translation 14
-XSetPairValues D $joint -second_translation 2.1
-set values [XGetPairValues D $joint -rotation]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -rotation 20 -first_translation 14
+XSetPairValues D $value $joint -second_translation 2.1
+set values [XGetPairValues D $value -rotation]
 if {$values != "20"} {
   puts "Error: wrong parameter"
 }
-set values [XGetPairValues D $joint -first_translation]
+set values [XGetPairValues D $value -first_translation]
 if {$values != "14"} {
   puts "Error: wrong parameter"
 }
-set values [XGetPairValues D $joint -second_translation]
+set values [XGetPairValues D $value -second_translation]
 if {$values != "2.1"} {
   puts "Error: wrong parameter"
 }
index 9c8e6e206ddae9029cc25979f20e9103f138996b..6a8b2d98603547ecf85645de7c2fb34d2c830792 100644 (file)
@@ -46,8 +46,12 @@ if {$limits != "1 2 3 4 5 6 7 8 9 10 11 12 "} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -trsf 10 10 10 1 0 0 0 -1 0
-set values [XGetPairValues D $joint -trsf]
+
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -trsf 10 10 10 1 0 0 0 -1 0
+set values [XGetPairValues D $value -trsf]
 if {$values!= "10 10 10\n1 0 0\n0 -1 0"} {
   puts "Error: wrong parameter"
 }
index f5e0c3399dc7b89488d10c95d1289041144c0550..649859020d6b1dcc8df6b9ff78f0773018c2534b 100644 (file)
@@ -52,8 +52,11 @@ if {$param != "Pitch = 14"} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -rotation 20
-set values [XGetPairValues D $joint -rotation]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -rotation 20
+set values [XGetPairValues D $value -rotation]
 if {$values != "20"} {
   puts "Error: wrong parameter"
 }
index 1ed5bd9e0578d28e85542e348a42cf0fbdef4ab8..09925c8148655bad71117eddce67d89d3a823c22 100644 (file)
@@ -52,8 +52,11 @@ if {$param != "Pinion Radius = 3"} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -translation 12
-set values [XGetPairValues D $joint -translation]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -translation 12
+set values [XGetPairValues D $value -translation]
 if {$values != "12"} {
   puts "Error: wrong parameter"
 }
index 853e6a8daa5f04823b8e001b354b8a77404c61ec..047835c04417275ce04919bc560bd64a51697e7f 100644 (file)
@@ -52,8 +52,11 @@ if {$param != "First Link Radius = 1\nSecond Link Radius = 2\nBevel = 3\nHelical
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -rotation 24
-set values [XGetPairValues D $joint -rotation]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -rotation 24
+set values [XGetPairValues D $value -rotation]
 if {$values != "24"} {
   puts "Error: wrong parameter"
 }
index 7a19808d3c7adfbb497d47edc350caab56737a98..5d708a5649e1bc69bc409d3c56c8f1d07ec0d82d 100644 (file)
@@ -17,9 +17,9 @@ set name [XGetPairName D $joint]
 if {$name != "point on surface"} {
   puts "Error: wrong parameter"
 }
-XSetPairType D $joint 14
+XSetPairType D $joint 15
 set type [XGetPairType D $joint]
-if {$type != "14"} {
+if {$type != "15"} {
   puts "Error: wrong parameter"
 }
 
@@ -61,12 +61,15 @@ if {$ori != 1} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -point_on_surface 1 2 -ypr 12 13 14
-set values [XGetPairValues D $joint -point_on_surface]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -point_on_surface 1 2 -ypr 12 13 14
+set values [XGetPairValues D $value -point_on_surface]
 if {$values != "1 2"} {
   puts "Error: wrong parameter"
 }
-set values [XGetPairValues D $joint -ypr]
+set values [XGetPairValues D $value -ypr]
 if {$values != "12 13 14"} {
   puts "Error: wrong parameter"
 }
index 0b9026b90c2d2bdfe56b242a9bb04ddad3d4d86e..4d8c16c17d86e3c98d38508c97f900f9ca170ef1 100644 (file)
@@ -17,9 +17,9 @@ set name [XGetPairName D $joint]
 if {$name != "sliding surface"} {
   puts "Error: wrong parameter"
 }
-XSetPairType D $joint 15
+XSetPairType D $joint 16
 set type [XGetPairType D $joint]
-if {$type != "15"} {
+if {$type != "16"} {
   puts "Error: wrong parameter"
 }
 
@@ -69,16 +69,19 @@ if {$ori != 0} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -point_on_surface 1 2 -second_point_on_surface 2 1 -rotation 30
-set values [XGetPairValues D $joint -first_point_on_surface]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -point_on_surface 1 2 -second_point_on_surface 2 1 -rotation 30
+set values [XGetPairValues D $value -first_point_on_surface]
 if {$values != "1 2"} {
   puts "Error: wrong parameter"
 }
-set values [XGetPairValues D $joint -second_point_on_surface]
+set values [XGetPairValues D $value -second_point_on_surface]
 if {$values != "2 1"} {
   puts "Error: wrong parameter"
 }
-set values [XGetPairValues D $joint -rotation]
+set values [XGetPairValues D $value -rotation]
 if {$values != "30"} {
   puts "Error: wrong parameter"
 }
index 0022275939cf1706afd4b6902d00e3e3c35ba34c..c0c8f364d6e5f437f92e538cf0def12103dcf4df 100644 (file)
@@ -17,9 +17,9 @@ set name [XGetPairName D $joint]
 if {$name != "rolling surface"} {
   puts "Error: wrong parameter"
 }
-XSetPairType D $joint 16
+XSetPairType D $joint 17
 set type [XGetPairType D $joint]
-if {$type != "16"} {
+if {$type != "17"} {
   puts "Error: wrong parameter"
 }
 
@@ -69,12 +69,15 @@ if {$ori != 1} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -point_on_surface 2 1 -rotation 30
-set values [XGetPairValues D $joint -point_on_surface]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -point_on_surface 2 1 -rotation 30
+set values [XGetPairValues D $value -point_on_surface]
 if {$values != "2 1"} {
   puts "Error: wrong parameter"
 }
-set values [XGetPairValues D $joint -rotation]
+set values [XGetPairValues D $value -rotation]
 if {$values != "30"} {
   puts "Error: wrong parameter"
 }
index 960815361f016bceec90175726e89d93181c3513..172b1393f4f6de2608d04d190f6a0ab79a29ff35 100644 (file)
@@ -17,9 +17,9 @@ set name [XGetPairName D $joint]
 if {$name != "point on planar curve"} {
   puts "Error: wrong parameter"
 }
-XSetPairType D $joint 17
+XSetPairType D $joint 18
 set type [XGetPairType D $joint]
-if {$type != "17"} {
+if {$type != "18"} {
   puts "Error: wrong parameter"
 }
 
@@ -61,12 +61,15 @@ if {$ori != 1} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -point_on_curve 1.5 -ypr 12 13 14
-set values [XGetPairValues D $joint -point_on_curve]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -point_on_curve 1.5 -ypr 12 13 14
+set values [XGetPairValues D $value -point_on_curve]
 if {$values != "1.5"} {
   puts "Error: wrong parameter"
 }
-set values [XGetPairValues D $joint -ypr]
+set values [XGetPairValues D $value -ypr]
 if {$values != "12 13 14"} {
   puts "Error: wrong parameter"
 }
index 10ac90c4f9857381eaeceb1e2eaf88d63841d495..cdf6677f5e0ef3c7c2b3a124cec21ce2f667a005 100644 (file)
@@ -17,9 +17,9 @@ set name [XGetPairName D $joint]
 if {$name != "sliding curve"} {
   puts "Error: wrong parameter"
 }
-XSetPairType D $joint 18
+XSetPairType D $joint 19
 set type [XGetPairType D $joint]
-if {$type != "18"} {
+if {$type != "19"} {
   puts "Error: wrong parameter"
 }
 
@@ -63,12 +63,15 @@ if {$ori != 0} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -point_on_curve 1.5 -second_point_on_curve 7
-set values [XGetPairValues D $joint -first_point_on_curve]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -point_on_curve 1.5 -second_point_on_curve 7
+set values [XGetPairValues D $value -first_point_on_curve]
 if {$values != "1.5"} {
   puts "Error: wrong parameter"
 }
-set values [XGetPairValues D $joint -second_point_on_curve]
+set values [XGetPairValues D $value -second_point_on_curve]
 if {$values != "7"} {
   puts "Error: wrong parameter"
 }
index c82ba19747235fc820bc8737c0ae3a84c379cb25..d97ab780b873cc3bd263a2a1920f4e05dc42dc1e 100644 (file)
@@ -17,9 +17,9 @@ set name [XGetPairName D $joint]
 if {$name != "rolling curve"} {
   puts "Error: wrong parameter"
 }
-XSetPairType D $joint 19
+XSetPairType D $joint 20
 set type [XGetPairType D $joint]
-if {$type != "19"} {
+if {$type != "20"} {
   puts "Error: wrong parameter"
 }
 
@@ -63,8 +63,11 @@ if {$ori != 1} {
   puts "Error: wrong parameter"
 }
 
-XSetPairValues D $joint -point_on_curve 1.5
-set values [XGetPairValues D $joint -first_point_on_curve]
+set state [XAddMechanismState D $mech]
+set value [XAddPairValues D $state]
+
+XSetPairValues D $value $joint -point_on_curve 1.5
+set values [XGetPairValues D $value -first_point_on_curve]
 if {$values != "1.5"} {
   puts "Error: wrong parameter"
 }