From 243dcd1822b3a7ef7328c7c2d227341b437f6f20 Mon Sep 17 00:00:00 2001 From: dpasukhi Date: Thu, 9 Jul 2020 14:58:05 +0300 Subject: [PATCH] 0031388: To support kinematics data in STEP format * Add support for testing kinematics_export * Add dump of kinematics (XDEDRAW_Kinematics) * Add tests for kinematics_export * chuck_3_jaw_AP242_v2 (A1) * mazak_kinematic_v3 (A2) * Add tests for kinematics * linear flexible and pinion pair (C2) * linear flexible and planar curve pair (C3) * Rename function arguments or/and class fields * STEPCAFControl_Reader.cxx * addLinkWithShapes * setKinematicPairValue * ReadKinematics * STEPCAFControl_Writer.cxx * createKinematicLink * createKinematicJoint * createKinematicPair * createKinematicPairValue * WriteKinematics * StepKinematics_MechanismStateRepresentation * XCAFKinematics_LowOrderPairObjectWithCoupling * XCAFKinematics_LowOrderPairObject * XCAFKinematics_HighOrderPairObject * XCAFDoc_KinematicTool * Fix useless "linear * pair" XCAFDoc_KinematicPair * Add support of Spatial Rotation * Add MakeYprRotation in StepToGeom --- src/STEPCAFControl/STEPCAFControl_Reader.cxx | 467 +++++++------ src/STEPCAFControl/STEPCAFControl_Writer.cxx | 613 +++++++++--------- ...inematics_MechanismStateRepresentation.cxx | 18 +- ...inematics_MechanismStateRepresentation.hxx | 6 +- src/StepToGeom/StepToGeom.cxx | 242 +++++++ src/StepToGeom/StepToGeom.hxx | 4 + src/XCAFDoc/XCAFDoc_KinematicPair.cxx | 18 +- src/XCAFDoc/XCAFDoc_KinematicTool.cxx | 30 +- src/XCAFDoc/XCAFDoc_KinematicTool.hxx | 30 +- .../XCAFKinematics_HighOrderPairObject.cxx | 33 +- .../XCAFKinematics_HighOrderPairObject.hxx | 14 +- .../XCAFKinematics_LowOrderPairObject.cxx | 8 +- .../XCAFKinematics_LowOrderPairObject.hxx | 26 +- ...ematics_LowOrderPairObjectWithCoupling.cxx | 12 +- ...ematics_LowOrderPairObjectWithCoupling.hxx | 6 +- src/XDEDRAW/XDEDRAW_Kinematics.cxx | 111 +++- tests/gdt/grids.list | 1 + tests/gdt/kinematics/A1 | 4 +- tests/gdt/kinematics/C2 | 49 ++ tests/gdt/kinematics/C3 | 58 ++ tests/gdt/kinematics_export/A1 | 13 + tests/gdt/kinematics_export/A2 | 13 + tests/gdt/kinematics_export/begin | 1 + tests/gdt/kinematics_export/end | 185 ++++++ 24 files changed, 1308 insertions(+), 654 deletions(-) create mode 100644 tests/gdt/kinematics/C2 create mode 100644 tests/gdt/kinematics/C3 create mode 100644 tests/gdt/kinematics_export/A1 create mode 100644 tests/gdt/kinematics_export/A2 create mode 100644 tests/gdt/kinematics_export/begin create mode 100644 tests/gdt/kinematics_export/end diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index fe7a6c2923..f032fe6ae6 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -4317,18 +4317,17 @@ void collectViewShapes(const Handle(XSControl_WorkSession)& theWS, } //======================================================================= -//function : addLinksWithShapes -//purpose : set links of the Kinematic Joint on the OCAF -//======================================================================= -Standard_Boolean addLinksWithShapes(const Handle(XSControl_WorkSession)& theWS, - const Handle(TDocStd_Document)& theDoc, - const Handle(StepKinematics_KinematicLinkRepresentation)& aLinkRepresentation, - TDF_Label& theLink, - const TDF_Label& aMechanism, - TColStd_SequenceOfTransient& aCollOfLinks, - TDF_LabelSequence& aSeqOfLinksL, - const XCAFDoc_DataMapOfShapeLabel& aMap, - const Standard_Boolean& IsBase = Standard_False) +//function : addLinkWithShapes +//purpose : set links of the Kinematic Joint in the OCAF +//======================================================================= +Standard_Boolean addLinkWithShapes(const Handle(XSControl_WorkSession)& theWS, + const Handle(TDocStd_Document)& theDoc, + const Handle(StepKinematics_KinematicLinkRepresentation)& theLinkRepresentation, + const TDF_Label& theMechanism, + const XCAFDoc_DataMapOfShapeLabel& theMap, + TDF_Label& theLink, + NCollection_DataMap& theMapOfLinks, + const Standard_Boolean& theIsBase = Standard_False) { Handle(XSControl_TransferReader) aTR = theWS->TransferReader(); Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess(); @@ -4336,23 +4335,13 @@ Standard_Boolean addLinksWithShapes(const Handle(XSControl_WorkSession)& theWS, 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_KinematicLink) aLink = theLinkRepresentation->RepresentedLink(); + if(theMapOfLinks.Find(theLinkRepresentation, theLink)) + return Standard_True; Handle(StepKinematics_KinematicLinkRepresentationAssociation) aKLRA1; - for (Interface_EntityIterator anIterLinks = aGraph.Sharings(aLinkRepresentation); + for (Interface_EntityIterator anIterLinks = aGraph.Sharings(theLinkRepresentation); 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()) @@ -4365,29 +4354,28 @@ Standard_Boolean addLinksWithShapes(const Handle(XSControl_WorkSession)& theWS, } Handle(StepRepr_PropertyDefinition) aPD = Handle(StepRepr_PropertyDefinition)::DownCast(aCDKLR->RepresentedProductRelation()); + if (aPD.IsNull()) + return Standard_False; TDF_Label aShapeLabel; Handle(Transfer_Binder) binder = aTP->Find(aPD->Definition().Value()); TopoDS_Shape aShape = TransferBRep::ShapeResult(aTP, binder); if (aShape.IsNull()) return Standard_False; - if (aMap.IsBound(aShape)) - aShapeLabel = aMap(aShape); + if (theMap.IsBound(aShape)) + aShapeLabel = theMap(aShape); else aSTool->Search(aShape, aShapeLabel, Standard_True, Standard_True, Standard_True); aShapes.Append(aShapeLabel); if (aShapes.Length() == 0) return Standard_False; - theLink = aKTool->AddLink(aMechanism, aShapes, IsBase); + theLink = aKTool->AddLink(theMechanism, aShapes, theIsBase); if (!aLink->Name()->IsEmpty()) TDataStd_Name::Set(theLink, aLink->Name()->String()); if (theLink.IsNull()) return Standard_False; - - aCollOfLinks.Append(aLink); - aSeqOfLinksL.Append(theLink); - + theMapOfLinks.Bind(theLinkRepresentation, theLink); return Standard_True; } @@ -4395,114 +4383,114 @@ Standard_Boolean addLinksWithShapes(const Handle(XSControl_WorkSession)& theWS, //function : getKinematicType //purpose : get type of the Kinematic Pair //======================================================================= -XCAFKinematics_PairType getKinematicType(const Handle(StepKinematics_KinematicPair)& aKP) +XCAFKinematics_PairType getKinematicType(const Handle(StepKinematics_KinematicPair)& theKP) { // Low order pairs - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_FullyConstrainedPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_FullyConstrainedPair))) return XCAFKinematics_PairType_FullyConstrained; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_RevolutePair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_RevolutePair))) return XCAFKinematics_PairType_Revolute; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PrismaticPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PrismaticPair))) return XCAFKinematics_PairType_Prismatic; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_CylindricalPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_CylindricalPair))) return XCAFKinematics_PairType_Cylindrical; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_UniversalPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_UniversalPair))) return XCAFKinematics_PairType_Universal; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_HomokineticPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_HomokineticPair))) return XCAFKinematics_PairType_Homokinetic; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_SphericalPairWithPin))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_SphericalPairWithPin))) return XCAFKinematics_PairType_SphericalWithPin; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_SphericalPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_SphericalPair))) return XCAFKinematics_PairType_Spherical; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PlanarPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PlanarPair))) return XCAFKinematics_PairType_Planar; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_UnconstrainedPair)) || - aKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPairWithRange))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_UnconstrainedPair)) || + theKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPairWithRange))) return XCAFKinematics_PairType_Unconstrained; // Low order pairs with motion coupling - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_ScrewPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_ScrewPair))) return XCAFKinematics_PairType_Screw; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_RackAndPinionPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_RackAndPinionPair))) return XCAFKinematics_PairType_RackAndPinion; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_GearPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_GearPair))) return XCAFKinematics_PairType_Gear; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPinionPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPinionPair))) return XCAFKinematics_PairType_LinearFlexibleAndPinion; // High order pairs - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnSurfacePair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnSurfacePair))) return XCAFKinematics_PairType_PointOnSurface; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_SlidingSurfacePair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_SlidingSurfacePair))) return XCAFKinematics_PairType_SlidingSurface; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_RollingSurfacePair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_RollingSurfacePair))) return XCAFKinematics_PairType_RollingSurface; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePair))) return XCAFKinematics_PairType_PointOnPlanarCurve; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_SlidingCurvePair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_SlidingCurvePair))) return XCAFKinematics_PairType_SlidingCurve; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_RollingCurvePair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_RollingCurvePair))) return XCAFKinematics_PairType_RollingCurve; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPlanarCurvePair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPlanarCurvePair))) return XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve; return XCAFKinematics_PairType_NoType; } //======================== =============================================== -//function : setKinematicPairLimits -//purpose : set limits of the Kinematic Pair on the OCAF +//function : setKinematicPairLimit +//purpose : set limits of the Kinematic Pair in the OCAF //======================================================================= -Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKinematicPairObj, - const Handle(StepKinematics_KinematicPair)& aKP) +Standard_Boolean setKinematicPairLimit(const Handle(StepKinematics_KinematicPair)& theKP, + Handle(XCAFKinematics_PairObject)& theKinematicPairObj) { - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_FullyConstrainedPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_FullyConstrainedPair))) return Standard_False; // no DOF // Low order pairs - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPair))) { - Handle(XCAFKinematics_LowOrderPairObject) anObj = Handle(XCAFKinematics_LowOrderPairObject)::DownCast(aKinematicPairObj); - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_RevolutePairWithRange))) // one rotation DOF + Handle(XCAFKinematics_LowOrderPairObject) anObj = Handle(XCAFKinematics_LowOrderPairObject)::DownCast(theKinematicPairObj); + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_RevolutePairWithRange))) // one rotation DOF { - Handle(StepKinematics_RevolutePairWithRange) aRevolutePairWithRange = Handle(StepKinematics_RevolutePairWithRange)::DownCast(aKP); + Handle(StepKinematics_RevolutePairWithRange) aRevolutePairWithRange = Handle(StepKinematics_RevolutePairWithRange)::DownCast(theKP); anObj->SetMaxRotationZ(aRevolutePairWithRange->UpperLimitActualRotation()); anObj->SetMinRotationZ(aRevolutePairWithRange->LowerLimitActualRotation()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PrismaticPairWithRange)))// one translation DOF + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PrismaticPairWithRange)))// one translation DOF { - Handle(StepKinematics_PrismaticPairWithRange) aPrismaticPairWithRange = Handle(StepKinematics_PrismaticPairWithRange)::DownCast(aKP); + Handle(StepKinematics_PrismaticPairWithRange) aPrismaticPairWithRange = Handle(StepKinematics_PrismaticPairWithRange)::DownCast(theKP); anObj->SetMaxTranslationX(aPrismaticPairWithRange->UpperLimitActualTranslation()); anObj->SetMinTranslationX(aPrismaticPairWithRange->LowerLimitActualTranslation()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_CylindricalPairWithRange)))//one rotation and one translation DOF + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_CylindricalPairWithRange)))//one rotation and one translation DOF { - Handle(StepKinematics_CylindricalPairWithRange) aCylindricalPairWithRange = Handle(StepKinematics_CylindricalPairWithRange)::DownCast(aKP); + Handle(StepKinematics_CylindricalPairWithRange) aCylindricalPairWithRange = Handle(StepKinematics_CylindricalPairWithRange)::DownCast(theKP); anObj->SetMaxRotationZ(aCylindricalPairWithRange->UpperLimitActualRotation()); anObj->SetMinRotationZ(aCylindricalPairWithRange->LowerLimitActualRotation()); anObj->SetMaxTranslationZ(aCylindricalPairWithRange->UpperLimitActualTranslation()); anObj->SetMinTranslationZ(aCylindricalPairWithRange->LowerLimitActualTranslation()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_UniversalPairWithRange)))// two rotation DOF + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_UniversalPairWithRange)))// two rotation DOF { - Handle(StepKinematics_UniversalPairWithRange) aUniversalPairWithRange = Handle(StepKinematics_UniversalPairWithRange)::DownCast(aKP); + Handle(StepKinematics_UniversalPairWithRange) aUniversalPairWithRange = Handle(StepKinematics_UniversalPairWithRange)::DownCast(theKP); anObj->SetMaxRotationX(aUniversalPairWithRange->UpperLimitFirstRotation()); anObj->SetMinRotationX(aUniversalPairWithRange->LowerLimitFirstRotation()); anObj->SetMaxRotationZ(aUniversalPairWithRange->UpperLimitSecondRotation()); anObj->SetMinRotationZ(aUniversalPairWithRange->LowerLimitSecondRotation()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_SphericalPairWithPinAndRange)))// two rotation DOF + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_SphericalPairWithPinAndRange)))// two rotation DOF { - Handle(StepKinematics_SphericalPairWithPinAndRange) aSphericalPairWithPinAndRange = Handle(StepKinematics_SphericalPairWithPinAndRange)::DownCast(aKP); + Handle(StepKinematics_SphericalPairWithPinAndRange) aSphericalPairWithPinAndRange = Handle(StepKinematics_SphericalPairWithPinAndRange)::DownCast(theKP); //Pitch Yaw Roll (Y Z X) anObj->SetMaxRotationZ(aSphericalPairWithPinAndRange->UpperLimitYaw()); anObj->SetMinRotationZ(aSphericalPairWithPinAndRange->LowerLimitYaw()); anObj->SetMaxRotationX(aSphericalPairWithPinAndRange->UpperLimitRoll()); anObj->SetMinRotationX(aSphericalPairWithPinAndRange->LowerLimitRoll()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_SphericalPairWithRange)))// three rotation DOF + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_SphericalPairWithRange)))// three rotation DOF { //Pitch Yaw Roll (Y Z X) - Handle(StepKinematics_SphericalPairWithRange) aSphericalPairWithRange = Handle(StepKinematics_SphericalPairWithRange)::DownCast(aKP); + Handle(StepKinematics_SphericalPairWithRange) aSphericalPairWithRange = Handle(StepKinematics_SphericalPairWithRange)::DownCast(theKP); anObj->SetMaxRotationZ(aSphericalPairWithRange->UpperLimitYaw()); anObj->SetMinRotationZ(aSphericalPairWithRange->LowerLimitYaw()); anObj->SetMaxRotationX(aSphericalPairWithRange->UpperLimitRoll()); @@ -4510,9 +4498,9 @@ Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKine anObj->SetMaxRotationY(aSphericalPairWithRange->UpperLimitPitch()); anObj->SetMinRotationY(aSphericalPairWithRange->LowerLimitPitch()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PlanarPairWithRange))) // one rotation and two translation DOF + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PlanarPairWithRange))) // one rotation and two translation DOF { - Handle(StepKinematics_PlanarPairWithRange) aPlanarPairWithRange = Handle(StepKinematics_PlanarPairWithRange)::DownCast(aKP); + Handle(StepKinematics_PlanarPairWithRange) aPlanarPairWithRange = Handle(StepKinematics_PlanarPairWithRange)::DownCast(theKP); anObj->SetMaxRotationZ(aPlanarPairWithRange->UpperLimitActualRotation()); anObj->SetMinRotationZ(aPlanarPairWithRange->LowerLimitActualRotation()); anObj->SetMaxTranslationX(aPlanarPairWithRange->UpperLimitActualTranslationX()); @@ -4520,9 +4508,9 @@ Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKine anObj->SetMaxTranslationY(aPlanarPairWithRange->UpperLimitActualTranslationY()); anObj->SetMinTranslationY(aPlanarPairWithRange->LowerLimitActualTranslationY()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPairWithRange))) // three rotation and three translation DOF + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPairWithRange))) // three rotation and three translation DOF { - Handle(StepKinematics_LowOrderKinematicPairWithRange) anUnconstrainedPair = Handle(StepKinematics_LowOrderKinematicPairWithRange)::DownCast(aKP); + Handle(StepKinematics_LowOrderKinematicPairWithRange) anUnconstrainedPair = Handle(StepKinematics_LowOrderKinematicPairWithRange)::DownCast(theKP); anObj->SetMaxRotationX(anUnconstrainedPair->UpperLimitActualRotationX()); anObj->SetMinRotationX(anUnconstrainedPair->LowerLimitActualRotationX()); anObj->SetMaxRotationY(anUnconstrainedPair->UpperLimitActualRotationY()); @@ -4539,36 +4527,36 @@ Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKine return Standard_True; } // Low order pairs with motion coupling - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPairWithMotionCoupling))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPairWithMotionCoupling))) { - Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObj = Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(aKinematicPairObj); - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_ScrewPairWithRange))) + Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObj = Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(theKinematicPairObj); + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_ScrewPairWithRange))) { - Handle(StepKinematics_ScrewPairWithRange) aScrewPairWithRange = Handle(StepKinematics_ScrewPairWithRange)::DownCast(aKP); + Handle(StepKinematics_ScrewPairWithRange) aScrewPairWithRange = Handle(StepKinematics_ScrewPairWithRange)::DownCast(theKP); anObj->SetLowLimit(aScrewPairWithRange->LowerLimitActualRotation()); anObj->SetUpperLimit(aScrewPairWithRange->UpperLimitActualRotation()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_RackAndPinionPairWithRange))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_RackAndPinionPairWithRange))) { - Handle(StepKinematics_RackAndPinionPairWithRange) aRackAndPinionPairWithRange = Handle(StepKinematics_RackAndPinionPairWithRange)::DownCast(aKP); + Handle(StepKinematics_RackAndPinionPairWithRange) aRackAndPinionPairWithRange = Handle(StepKinematics_RackAndPinionPairWithRange)::DownCast(theKP); anObj->SetUpperLimit(aRackAndPinionPairWithRange->UpperLimitRackDisplacement()); anObj->SetLowLimit(aRackAndPinionPairWithRange->LowerLimitRackDisplacement()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_GearPairWithRange))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_GearPairWithRange))) { - Handle(StepKinematics_GearPairWithRange) aGearPairWithRange = Handle(StepKinematics_GearPairWithRange)::DownCast(aKP); + Handle(StepKinematics_GearPairWithRange) aGearPairWithRange = Handle(StepKinematics_GearPairWithRange)::DownCast(theKP); anObj->SetLowLimit(aGearPairWithRange->LowerLimitActualRotation1()); anObj->SetUpperLimit(aGearPairWithRange->UpperLimitActualRotation1()); } return Standard_True; } // High order pairs - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_HighOrderKinematicPair))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_HighOrderKinematicPair))) { - Handle(XCAFKinematics_HighOrderPairObject) anObj = Handle(XCAFKinematics_HighOrderPairObject)::DownCast(aKinematicPairObj);//new XCAFKinematics_HighOrderPairObject; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnSurfacePairWithRange))) + Handle(XCAFKinematics_HighOrderPairObject) anObj = Handle(XCAFKinematics_HighOrderPairObject)::DownCast(theKinematicPairObj);//new XCAFKinematics_HighOrderPairObject; + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnSurfacePairWithRange))) { - Handle(StepKinematics_PointOnSurfacePairWithRange) aPointOnSurfacePairWithRange = Handle(StepKinematics_PointOnSurfacePairWithRange)::DownCast(aKP); + Handle(StepKinematics_PointOnSurfacePairWithRange) aPointOnSurfacePairWithRange = Handle(StepKinematics_PointOnSurfacePairWithRange)::DownCast(theKP); anObj->SetLowLimitYaw(aPointOnSurfacePairWithRange->LowerLimitYaw()); anObj->SetUpperLimitYaw(aPointOnSurfacePairWithRange->UpperLimitYaw()); anObj->SetLowLimitPitch(aPointOnSurfacePairWithRange->LowerLimitPitch()); @@ -4577,9 +4565,9 @@ Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKine anObj->SetUpperLimitRoll(aPointOnSurfacePairWithRange->UpperLimitRoll()); anObj->SetTrimmedSurface(StepToGeom::MakeRectangularTrimmedSurface(aPointOnSurfacePairWithRange->RangeOnPairSurface())); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePairWithRange))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePairWithRange))) { - Handle(StepKinematics_PointOnPlanarCurvePairWithRange) aPointOnPlanarCurvePairWithRange = Handle(StepKinematics_PointOnPlanarCurvePairWithRange)::DownCast(aKP); + Handle(StepKinematics_PointOnPlanarCurvePairWithRange) aPointOnPlanarCurvePairWithRange = Handle(StepKinematics_PointOnPlanarCurvePairWithRange)::DownCast(theKP); anObj->SetLowLimitYaw(aPointOnPlanarCurvePairWithRange->LowerLimitYaw()); anObj->SetUpperLimitYaw(aPointOnPlanarCurvePairWithRange->UpperLimitYaw()); anObj->SetLowLimitPitch(aPointOnPlanarCurvePairWithRange->LowerLimitPitch()); @@ -4588,9 +4576,9 @@ Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKine anObj->SetUpperLimitRoll(aPointOnPlanarCurvePairWithRange->UpperLimitRoll()); anObj->SetTrimmedCurve(StepToGeom::MakeTrimmedCurve(aPointOnPlanarCurvePairWithRange->RangeOnPairCurve())); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PlanarCurvePairRange))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PlanarCurvePairRange))) { - Handle(StepKinematics_PlanarCurvePairRange) aPlanarCurvePairRange = Handle(StepKinematics_PlanarCurvePairRange)::DownCast(aKP); + Handle(StepKinematics_PlanarCurvePairRange) aPlanarCurvePairRange = Handle(StepKinematics_PlanarCurvePairRange)::DownCast(theKP); anObj->SetFirstCurve(StepToGeom::MakeCurve(aPlanarCurvePairRange->RangeOnCurve1())); anObj->SetSecondCurve(StepToGeom::MakeCurve(aPlanarCurvePairRange->RangeOnCurve2())); } @@ -4604,116 +4592,116 @@ Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKine //function : createXCAFKinematicPairObject //purpose : create XCAFKinematicPairObject with main parameters of the Kinematic Pair //======================================================================= -Handle(XCAFKinematics_PairObject) createXCAFKinematicPairObject(const Handle(StepKinematics_KinematicPair)& aKP) +Handle(XCAFKinematics_PairObject) createXCAFKinematicPairObject(const Handle(StepKinematics_KinematicPair)& theKP) { Handle(XCAFKinematics_PairObject) anObj; // Low order pairs - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPair))) { anObj = new XCAFKinematics_LowOrderPairObject; - anObj->SetType(getKinematicType(aKP)); + anObj->SetType(getKinematicType(theKP)); Handle(XCAFKinematics_LowOrderPairObject) anLowOrderKinPairObj = Handle(XCAFKinematics_LowOrderPairObject)::DownCast(anObj); - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_UniversalPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_UniversalPair))) { - Handle(StepKinematics_UniversalPair) anUniversalPair = Handle(StepKinematics_UniversalPair)::DownCast(aKP); + Handle(StepKinematics_UniversalPair) anUniversalPair = Handle(StepKinematics_UniversalPair)::DownCast(theKP); anLowOrderKinPairObj->SetSkewAngle(anUniversalPair->InputSkewAngle()); } } // Low order pairs with motion coupling - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPairWithMotionCoupling))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPairWithMotionCoupling))) { anObj = new XCAFKinematics_LowOrderPairObjectWithCoupling; - anObj->SetType(getKinematicType(aKP)); + anObj->SetType(getKinematicType(theKP)); Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anLowOrderKinPairWthCouplingObj = Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(anObj); - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_ScrewPair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_ScrewPair))) { - Handle(StepKinematics_ScrewPair) aScrewPair = Handle(StepKinematics_ScrewPair)::DownCast(aKP); + Handle(StepKinematics_ScrewPair) aScrewPair = Handle(StepKinematics_ScrewPair)::DownCast(theKP); anLowOrderKinPairWthCouplingObj->SetPitch(aScrewPair->Pitch()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_RackAndPinionPair))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_RackAndPinionPair))) { - Handle(StepKinematics_RackAndPinionPair) aRackAndPinionPair = Handle(StepKinematics_RackAndPinionPair)::DownCast(aKP); + Handle(StepKinematics_RackAndPinionPair) aRackAndPinionPair = Handle(StepKinematics_RackAndPinionPair)::DownCast(theKP); anLowOrderKinPairWthCouplingObj->SetPinionRadius(aRackAndPinionPair->PinionRadius()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_GearPair))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_GearPair))) { - Handle(StepKinematics_GearPair) aGearPair = Handle(StepKinematics_GearPair)::DownCast(aKP); + Handle(StepKinematics_GearPair) aGearPair = Handle(StepKinematics_GearPair)::DownCast(theKP); anLowOrderKinPairWthCouplingObj->SetBevel(aGearPair->Bevel()); anLowOrderKinPairWthCouplingObj->SetGearRatio(aGearPair->GearRatio()); anLowOrderKinPairWthCouplingObj->SetHelicalAngle(aGearPair->HelicalAngle()); anLowOrderKinPairWthCouplingObj->SetRadiusFirstLink(aGearPair->RadiusFirstLink()); anLowOrderKinPairWthCouplingObj->SetRadiusSecondLink(aGearPair->RadiusSecondLink()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPinionPair))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPinionPair))) { - Handle(StepKinematics_LinearFlexibleAndPinionPair) aLinearFlexibleAndPinionPair = Handle(StepKinematics_LinearFlexibleAndPinionPair)::DownCast(aKP); + Handle(StepKinematics_LinearFlexibleAndPinionPair) aLinearFlexibleAndPinionPair = Handle(StepKinematics_LinearFlexibleAndPinionPair)::DownCast(theKP); anLowOrderKinPairWthCouplingObj->SetPinionRadius(aLinearFlexibleAndPinionPair->PinionRadius()); } } // High order pairs - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_HighOrderKinematicPair))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_HighOrderKinematicPair))) { anObj = new XCAFKinematics_HighOrderPairObject; - anObj->SetType(getKinematicType(aKP)); + anObj->SetType(getKinematicType(theKP)); Handle(XCAFKinematics_HighOrderPairObject) aHighOrderPairObject = Handle(XCAFKinematics_HighOrderPairObject)::DownCast(anObj); - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnSurfacePair))) + if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnSurfacePair))) { - Handle(StepKinematics_PointOnSurfacePair) aPointOnSurfacePair = Handle(StepKinematics_PointOnSurfacePair)::DownCast(aKP); + Handle(StepKinematics_PointOnSurfacePair) aPointOnSurfacePair = Handle(StepKinematics_PointOnSurfacePair)::DownCast(theKP); aHighOrderPairObject->SetSurface(StepToGeom::MakeSurface(aPointOnSurfacePair->PairSurface())); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_RollingSurfacePair))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_RollingSurfacePair))) { - Handle(StepKinematics_RollingSurfacePair) aRollingSurfacePair = Handle(StepKinematics_RollingSurfacePair)::DownCast(aKP); + Handle(StepKinematics_RollingSurfacePair) aRollingSurfacePair = Handle(StepKinematics_RollingSurfacePair)::DownCast(theKP); aHighOrderPairObject->SetFirstSurface(StepToGeom::MakeSurface(aRollingSurfacePair->Surface1())); aHighOrderPairObject->SetSecondSurface(StepToGeom::MakeSurface(aRollingSurfacePair->Surface2())); aHighOrderPairObject->SetOrientation(aRollingSurfacePair->Orientation()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_SlidingSurfacePair))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_SlidingSurfacePair))) { - Handle(StepKinematics_SlidingSurfacePair) aSlidingSurfacePair = Handle(StepKinematics_SlidingSurfacePair)::DownCast(aKP); + Handle(StepKinematics_SlidingSurfacePair) aSlidingSurfacePair = Handle(StepKinematics_SlidingSurfacePair)::DownCast(theKP); aHighOrderPairObject->SetFirstSurface(StepToGeom::MakeSurface(aSlidingSurfacePair->Surface1())); aHighOrderPairObject->SetSecondSurface(StepToGeom::MakeSurface(aSlidingSurfacePair->Surface2())); aHighOrderPairObject->SetOrientation(aSlidingSurfacePair->Orientation()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_SlidingCurvePair))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_SlidingCurvePair))) { - Handle(StepKinematics_SlidingCurvePair) aSlidingCurvePair = Handle(StepKinematics_SlidingCurvePair)::DownCast(aKP); + Handle(StepKinematics_SlidingCurvePair) aSlidingCurvePair = Handle(StepKinematics_SlidingCurvePair)::DownCast(theKP); aHighOrderPairObject->SetFirstCurve(StepToGeom::MakeCurve(aSlidingCurvePair->Curve1())); aHighOrderPairObject->SetSecondCurve(StepToGeom::MakeCurve(aSlidingCurvePair->Curve2())); aHighOrderPairObject->SetOrientation(aSlidingCurvePair->Orientation()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_RollingCurvePair))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_RollingCurvePair))) { - Handle(StepKinematics_RollingCurvePair) aRollingCurvePair = Handle(StepKinematics_RollingCurvePair)::DownCast(aKP); + Handle(StepKinematics_RollingCurvePair) aRollingCurvePair = Handle(StepKinematics_RollingCurvePair)::DownCast(theKP); aHighOrderPairObject->SetFirstCurve(StepToGeom::MakeCurve(aRollingCurvePair->Curve1())); aHighOrderPairObject->SetSecondCurve(StepToGeom::MakeCurve(aRollingCurvePair->Curve2())); aHighOrderPairObject->SetOrientation(aRollingCurvePair->Orientation()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePair))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePair))) { - Handle(StepKinematics_PointOnPlanarCurvePair) aPointOnPlanarCurvePair = Handle(StepKinematics_PointOnPlanarCurvePair)::DownCast(aKP); + Handle(StepKinematics_PointOnPlanarCurvePair) aPointOnPlanarCurvePair = Handle(StepKinematics_PointOnPlanarCurvePair)::DownCast(theKP); aHighOrderPairObject->SetOrientation(aPointOnPlanarCurvePair->Orientation()); aHighOrderPairObject->SetCurve(StepToGeom::MakeCurve(aPointOnPlanarCurvePair->PairCurve())); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PlanarCurvePair))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PlanarCurvePair))) { - Handle(StepKinematics_PlanarCurvePair) aPlanarCurvePair = Handle(StepKinematics_PlanarCurvePair)::DownCast(aKP); + Handle(StepKinematics_PlanarCurvePair) aPlanarCurvePair = Handle(StepKinematics_PlanarCurvePair)::DownCast(theKP); aHighOrderPairObject->SetFirstCurve(StepToGeom::MakeCurve(aPlanarCurvePair->Curve1())); aHighOrderPairObject->SetSecondCurve(StepToGeom::MakeCurve(aPlanarCurvePair->Curve2())); aHighOrderPairObject->SetOrientation(aPlanarCurvePair->Orientation()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPlanarCurvePair))) + else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPlanarCurvePair))) { - Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair) aLinearFlexibleAndPlanarCurvePair = Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair)::DownCast(aKP); + Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair) aLinearFlexibleAndPlanarCurvePair = Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair)::DownCast(theKP); aHighOrderPairObject->SetFirstCurve(StepToGeom::MakeCurve(aLinearFlexibleAndPlanarCurvePair->PairCurve())); aHighOrderPairObject->SetOrientation(aLinearFlexibleAndPlanarCurvePair->Orientation()); } } if (!anObj.IsNull()) { - Handle(StepRepr_RepresentationItem) aTransformItem1 = aKP->ItemDefinedTransformation()->TransformItem1(); - Handle(StepRepr_RepresentationItem) aTransformItem2 = aKP->ItemDefinedTransformation()->TransformItem2(); + Handle(StepRepr_RepresentationItem) aTransformItem1 = theKP->ItemDefinedTransformation()->TransformItem1(); + Handle(StepRepr_RepresentationItem) aTransformItem2 = theKP->ItemDefinedTransformation()->TransformItem2(); Handle(Geom_Axis2Placement) aPlacementFirst; Handle(Geom_Axis2Placement) aPlacementSecond; if (aTransformItem1->IsKind(STANDARD_TYPE(StepKinematics_SuParameters))) @@ -4724,8 +4712,8 @@ Handle(XCAFKinematics_PairObject) createXCAFKinematicPairObject(const Handle(Ste aPlacementSecond = StepToGeom::MakeAxis2Placement(Handle(StepKinematics_SuParameters)::DownCast(aTransformItem2)); else aPlacementSecond = StepToGeom::MakeAxis2Placement(Handle(StepGeom_Axis2Placement3d)::DownCast(aTransformItem2)); - if (!aKP->Joint()->Name()->IsEmpty()) - anObj->SetName(aKP->Joint()->Name()->String()); + if (!theKP->Joint()->Name()->IsEmpty()) + anObj->SetName(theKP->Joint()->Name()->String()); anObj->SetFirstTransformation(aPlacementFirst->Ax2()); anObj->SetSecondTransformation(aPlacementSecond->Ax2()); @@ -4735,134 +4723,159 @@ Handle(XCAFKinematics_PairObject) createXCAFKinematicPairObject(const Handle(Ste //======================================================================= //function : setPairValue -//purpose : set pair Value of the kinematic pair on OCAF +//purpose : set pair Value of the kinematic pair in OCAF //======================================================================= 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) + const Handle(StepKinematics_KinematicJoint)& theKinematicJoint, + const Handle(StepKinematics_PairValue)& theValue, + const TDF_Label& theState, + const 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(XCAFKinematics_PairValueObject) aValueObject; - aValueObject = new XCAFKinematics_PairValueObject(); - aValueObject->SetType(aType); + Handle(XCAFKinematics_PairValueObject) aValueObject = new XCAFKinematics_PairValueObject(); - if (aType == 0) + Handle(StepKinematics_KinematicLink) aLink = Handle(StepKinematics_KinematicLink)::DownCast(theKinematicJoint->EdgeStart()); + if (aLink.IsNull()) + return Standard_False; + Handle(StepKinematics_KinematicLinkRepresentation) aLinkRepresentation; + Interface_EntityIterator anIterLinkRepr = aGraph.Sharings(aLink); + for (anIterLinkRepr.Start(); anIterLinkRepr.More() && aLinkRepresentation.IsNull(); anIterLinkRepr.Next()) + aLinkRepresentation = Handle(StepKinematics_KinematicLinkRepresentation)::DownCast(anIterLinkRepr.Value()); + if(aLinkRepresentation.IsNull()) return Standard_False; + Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx) aContext = + Handle(StepGeom_GeomRepContextAndGlobUnitAssCtxAndGlobUncertaintyAssCtx)::DownCast(aLinkRepresentation->ContextOfItems()); + + Handle(XCAFDoc_KinematicPair) aKPairAttr; + if (!theJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aKPairAttr)) + return Standard_False; + XCAFKinematics_PairType aPairType = aKPairAttr->GetObject()->Type(); + if (aPairType == XCAFKinematics_PairType_NoType) + return Standard_False; + aValueObject->SetType(aPairType); TDF_TagSource aTag; - TDF_Label aValueL = aTag.NewChild(aState); + TDF_Label aValueL = aTag.NewChild(theState); // Low order pairs - if (aValue->IsKind(STANDARD_TYPE(StepKinematics_RevolutePairValue))) + if (theValue->IsKind(STANDARD_TYPE(StepKinematics_RevolutePairValue))) { - Handle(StepKinematics_RevolutePairValue) aRevolutePairValue = Handle(StepKinematics_RevolutePairValue)::DownCast(aValue); + Handle(StepKinematics_RevolutePairValue) aRevolutePairValue = Handle(StepKinematics_RevolutePairValue)::DownCast(theValue); aValueObject->SetRotation(aRevolutePairValue->ActualRotation()); } - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_PrismaticPairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_PrismaticPairValue))) { - Handle(StepKinematics_PrismaticPairValue) aPrismaticPairValue = Handle(StepKinematics_PrismaticPairValue)::DownCast(aValue); + Handle(StepKinematics_PrismaticPairValue) aPrismaticPairValue = Handle(StepKinematics_PrismaticPairValue)::DownCast(theValue); aValueObject->SetTranslation(aPrismaticPairValue->ActualTranslation()); } - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_CylindricalPairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_CylindricalPairValue))) { - Handle(StepKinematics_CylindricalPairValue) aCylindricalPairValue = Handle(StepKinematics_CylindricalPairValue)::DownCast(aValue); + Handle(StepKinematics_CylindricalPairValue) aCylindricalPairValue = Handle(StepKinematics_CylindricalPairValue)::DownCast(theValue); aValueObject->SetTranslation(aCylindricalPairValue->ActualTranslation()); aValueObject->SetRotation(aCylindricalPairValue->ActualRotation()); } - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_SphericalPairValue))) + else if (theValue->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)); + Handle(StepKinematics_SphericalPairValue) aSphericalPairValue = Handle(StepKinematics_SphericalPairValue)::DownCast(theValue); + if(aContext.IsNull()) + return Standard_False; + Handle(TColStd_HArray1OfReal) anYprRotation = StepToGeom::MakeYprRotation(aSphericalPairValue->InputOrientation(), aContext->GlobalUnitAssignedContext()); + if (anYprRotation.IsNull()) + return Standard_False; + aValueObject->SetYPR(anYprRotation->Value(1), anYprRotation->Value(2), anYprRotation->Value(3)); } - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_UniversalPairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_UniversalPairValue))) { - Handle(StepKinematics_UniversalPairValue) aUniversalPairValue = Handle(StepKinematics_UniversalPairValue)::DownCast(aValue); + Handle(StepKinematics_UniversalPairValue) aUniversalPairValue = Handle(StepKinematics_UniversalPairValue)::DownCast(theValue); aValueObject->SetFirstRotation(aUniversalPairValue->FirstRotationAngle()); - aValueObject->SetSecondRotation(aUniversalPairValue->SecondRotationAngle()); //CHECK + aValueObject->SetSecondRotation(aUniversalPairValue->SecondRotationAngle()); } - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_UnconstrainedPairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_UnconstrainedPairValue))) { - Handle(StepKinematics_UnconstrainedPairValue) anUnconstrainedPairValue = Handle(StepKinematics_UnconstrainedPairValue)::DownCast(aValue); + Handle(StepKinematics_UnconstrainedPairValue) anUnconstrainedPairValue = Handle(StepKinematics_UnconstrainedPairValue)::DownCast(theValue); aValueObject->SetTransformation(StepToGeom::MakeAxis2Placement(anUnconstrainedPairValue->ActualPlacement())->Ax2()); } // Low order pairs with motion coupling - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_ScrewPairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_ScrewPairValue))) { - Handle(StepKinematics_ScrewPairValue) aScrewPairValue = Handle(StepKinematics_ScrewPairValue)::DownCast(aValue); + Handle(StepKinematics_ScrewPairValue) aScrewPairValue = Handle(StepKinematics_ScrewPairValue)::DownCast(theValue); aValueObject->SetRotation(aScrewPairValue->ActualRotation()); } - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_GearPairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_GearPairValue))) { - Handle(StepKinematics_GearPairValue) aGearPairValue = Handle(StepKinematics_GearPairValue)::DownCast(aValue); + Handle(StepKinematics_GearPairValue) aGearPairValue = Handle(StepKinematics_GearPairValue)::DownCast(theValue); aValueObject->SetRotation(aGearPairValue->ActualRotation1()); } - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_RackAndPinionPairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_RackAndPinionPairValue))) { - Handle(StepKinematics_RackAndPinionPairValue) aRackAndPinionPairValue = Handle(StepKinematics_RackAndPinionPairValue)::DownCast(aValue); + Handle(StepKinematics_RackAndPinionPairValue) aRackAndPinionPairValue = Handle(StepKinematics_RackAndPinionPairValue)::DownCast(theValue); aValueObject->SetTranslation(aRackAndPinionPairValue->ActualDisplacement()); } // High order pairs - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_SlidingSurfacePairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_SlidingSurfacePairValue))) { - Handle(StepKinematics_SlidingSurfacePairValue) aSlidingSurfacePairValue = Handle(StepKinematics_SlidingSurfacePairValue)::DownCast(aValue); + Handle(StepKinematics_SlidingSurfacePairValue) aSlidingSurfacePairValue = Handle(StepKinematics_SlidingSurfacePairValue)::DownCast(theValue); 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))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_RollingSurfacePairValue))) { - Handle(StepKinematics_RollingSurfacePairValue) aRollingSurfacePairValue = Handle(StepKinematics_RollingSurfacePairValue)::DownCast(aValue); + Handle(StepKinematics_RollingSurfacePairValue) aRollingSurfacePairValue = Handle(StepKinematics_RollingSurfacePairValue)::DownCast(theValue); aValueObject->SetRotation(aRollingSurfacePairValue->ActualRotation()); aValueObject->SetFirstPointOnSurface(aRollingSurfacePairValue->ActualPointOnSurface()->PointParameterU(), aRollingSurfacePairValue->ActualPointOnSurface()->PointParameterV()); } - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_SlidingCurvePairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_SlidingCurvePairValue))) { - Handle(StepKinematics_SlidingCurvePairValue) aSlidingCurvePairValue = Handle(StepKinematics_SlidingCurvePairValue)::DownCast(aValue); + Handle(StepKinematics_SlidingCurvePairValue) aSlidingCurvePairValue = Handle(StepKinematics_SlidingCurvePairValue)::DownCast(theValue); aValueObject->SetFirstPointOnCurve(aSlidingCurvePairValue->ActualPointOnCurve1()->PointParameter()); aValueObject->SetSecondPointOnCurve(aSlidingCurvePairValue->ActualPointOnCurve2()->PointParameter()); } - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_RollingCurvePairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_RollingCurvePairValue))) { - Handle(StepKinematics_RollingCurvePairValue) aRollingCurvePairValue = Handle(StepKinematics_RollingCurvePairValue)::DownCast(aValue); + Handle(StepKinematics_RollingCurvePairValue) aRollingCurvePairValue = Handle(StepKinematics_RollingCurvePairValue)::DownCast(theValue); aValueObject->SetPointOnCurve(aRollingCurvePairValue->ActualPointOnCurve1()->PointParameter()); } - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_PlanarPairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_PlanarPairValue))) { - Handle(StepKinematics_PlanarPairValue) aPlanarPairValue = Handle(StepKinematics_PlanarPairValue)::DownCast(aValue); + Handle(StepKinematics_PlanarPairValue) aPlanarPairValue = Handle(StepKinematics_PlanarPairValue)::DownCast(theValue); aValueObject->SetRotation(aPlanarPairValue->ActualRotation()); aValueObject->SetFirstTranslation(aPlanarPairValue->ActualTranslationX()); aValueObject->SetSecondTranslation(aPlanarPairValue->ActualTranslationY()); } - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_PointOnSurfacePairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_PointOnSurfacePairValue))) { - Handle(StepKinematics_PointOnSurfacePairValue) aPointOnSurfacePairValue = Handle(StepKinematics_PointOnSurfacePairValue)::DownCast(aValue); + Handle(StepKinematics_PointOnSurfacePairValue) aPointOnSurfacePairValue = Handle(StepKinematics_PointOnSurfacePairValue)::DownCast(theValue); 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)); + if (aContext.IsNull()) + return Standard_False; + Handle(TColStd_HArray1OfReal) anYprRotation = StepToGeom::MakeYprRotation(aPointOnSurfacePairValue->InputOrientation(), aContext->GlobalUnitAssignedContext()); + if (anYprRotation.IsNull()) + return Standard_False; + aValueObject->SetYPR(anYprRotation->Value(1), anYprRotation->Value(2), anYprRotation->Value(3)); } - else if (aValue->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePairValue))) + else if (theValue->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePairValue))) { - Handle(StepKinematics_PointOnPlanarCurvePairValue) aPointOnPlanarCurvePairValue = Handle(StepKinematics_PointOnPlanarCurvePairValue)::DownCast(aValue); + Handle(StepKinematics_PointOnPlanarCurvePairValue) aPointOnPlanarCurvePairValue = Handle(StepKinematics_PointOnPlanarCurvePairValue)::DownCast(theValue); aValueObject->SetFirstPointOnCurve(aPointOnPlanarCurvePairValue->ActualPointOnCurve()->PointParameter()); - aValueObject->SetYPR(aPointOnPlanarCurvePairValue->InputOrientation().YprRotation()->Value(1), - aPointOnPlanarCurvePairValue->InputOrientation().YprRotation()->Value(2), aPointOnPlanarCurvePairValue->InputOrientation().YprRotation()->Value(3)); + if (aContext.IsNull()) + return Standard_False; + Handle(TColStd_HArray1OfReal) anYprRotation = StepToGeom::MakeYprRotation(aPointOnPlanarCurvePairValue->InputOrientation(), aContext->GlobalUnitAssignedContext()); + if (anYprRotation.IsNull()) + return Standard_False; + aValueObject->SetYPR(anYprRotation->Value(1), anYprRotation->Value(2), anYprRotation->Value(3)); } else return Standard_False; - if (aValueObject->GetAllValues().IsNull()) - return Standard_False; - Handle(XCAFDoc_KinematicPairValue) aCAFKinematicPairValue = XCAFDoc_KinematicPairValue::Set(aValueL, aJoint); + Handle(XCAFDoc_KinematicPairValue) aCAFKinematicPairValue = XCAFDoc_KinematicPairValue::Set(aValueL, theJoint); aCAFKinematicPairValue->SetObject(aValueObject); - if (!aValue->Name()->IsEmpty()) - TDataStd_Name::Set(aValueL, aValue->Name()->ToCString()); + if (!theValue->Name()->IsEmpty()) + TDataStd_Name::Set(aValueL, theValue->Name()->ToCString()); return Standard_True; } @@ -5070,8 +5083,8 @@ Standard_Boolean STEPCAFControl_Reader::ReadViews(const Handle(XSControl_WorkSes //purpose : //======================================================================= Standard_Boolean STEPCAFControl_Reader::ReadKinematics(const Handle(XSControl_WorkSession)& theWS, - Handle(TDocStd_Document)& theDoc, - const XCAFDoc_DataMapOfShapeLabel& aShapeLabelMap) const + Handle(TDocStd_Document)& theDoc, + const XCAFDoc_DataMapOfShapeLabel& theShapeLabelMap) const { const Handle(Interface_InterfaceModel)& aModel = theWS->Model(); const Interface_Graph& aGraph = theWS->Graph(); @@ -5088,51 +5101,26 @@ Standard_Boolean STEPCAFControl_Reader::ReadKinematics(const Handle(XSControl_Wo Handle(StepKinematics_KinematicPropertyMechanismRepresentation)::DownCast(anEnt); Handle(StepKinematics_MechanismRepresentation) aKMR = Handle(StepKinematics_MechanismRepresentation)::DownCast(aKPMR->UsedRepresentation()); - TDF_Label aMechanism; if (aKMR.IsNull()) continue; - + TDF_Label aMechanism; 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; + //Collecting Links and labels of Links + NCollection_DataMap theMapOfLinks; //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, Standard_True); + addLinkWithShapes(theWS, theDoc, aKPMR->Base(), aMechanism, theShapeLabelMap, aLableOfBaseLink, theMapOfLinks, Standard_True); } - + + //read joints with their links + NCollection_DataMap theMapOfJoints; for (Standard_Integer aPairIndex = 1; aPairIndex <= aKMR->NbItems(); ++aPairIndex) { if (!aKMR->ItemsValue(aPairIndex)->IsKind(STANDARD_TYPE(StepKinematics_PairRepresentationRelationship))) @@ -5155,9 +5143,9 @@ Standard_Boolean STEPCAFControl_Reader::ReadKinematics(const Handle(XSControl_Wo if (aLinkRepresentation1.IsNull() || aLinkRepresentation2.IsNull()) continue; TDF_Label aJoint, aLink1, aLink2; - if (!addLinksWithShapes(theWS, theDoc, aLinkRepresentation1, aLink1, aMechanism, aCollOfLinks, aSeqOfLinksL, aShapeLabelMap)) + if (!addLinkWithShapes(theWS, theDoc, aLinkRepresentation1, aMechanism, theShapeLabelMap, aLink1, theMapOfLinks)) continue; - if (!addLinksWithShapes(theWS, theDoc, aLinkRepresentation2, aLink2, aMechanism, aCollOfLinks, aSeqOfLinksL, aShapeLabelMap)) + if (!addLinkWithShapes(theWS, theDoc, aLinkRepresentation2, aMechanism, theShapeLabelMap, aLink2, theMapOfLinks)) continue; //Setting info aJoint = aKTool->AddJoint(aMechanism, aLink1, aLink2); @@ -5165,27 +5153,30 @@ Standard_Boolean STEPCAFControl_Reader::ReadKinematics(const Handle(XSControl_Wo Handle(XCAFKinematics_PairObject) aPairObject = createXCAFKinematicPairObject(aKinematicPair); if (aPairObject.IsNull()) continue; - setKinematicPairLimits(aPairObject, aKinematicPair); + setKinematicPairLimit(aKinematicPair, aPairObject); aCAFKinPair->SetObject(aPairObject); + theMapOfJoints.Bind(aKinematicJoint, aJoint); + } - //Set Values of Joint on the OCAF - for (Standard_Integer IndState = 1; hasStates && IndState <= aArrayOfStates->Length(); ++IndState) + // (optional) + // Set mechanism's states with their values in the OCAF + Interface_EntityIterator anIterStates = aGraph.TypedSharings(aKMR, STANDARD_TYPE(StepKinematics_MechanismStateRepresentation)); + for (anIterStates.Start(); anIterStates.More(); anIterStates.Next()) + { + 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()); + for (Standard_Integer anIndValue = 1; anIndValue <= aMechanismState->Items()->Length(); ++anIndValue) { - Handle(StepKinematics_MechanismStateRepresentation) aMechanismState = - Handle(StepKinematics_MechanismStateRepresentation)::DownCast(aArrayOfStates->Value(IndState)); - for (Standard_Integer IndValue = 1; IndValue <= aMechanismState->Items()->Length(); ++IndValue) - { - 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); - } - } + Handle(StepKinematics_PairValue) aValue = Handle(StepKinematics_PairValue)::DownCast(aMechanismState->Items()->Value(anIndValue)); + Handle(StepKinematics_KinematicJoint) aKinematicJoint = aValue->AppliesToPair()->Joint(); + if (aKinematicJoint.IsNull()) + continue; + TDF_Label aJoint = theMapOfJoints.Find(aKinematicJoint); + setKinematicPairValue(theWS, theDoc, aKinematicJoint, aValue, aState, aJoint); } } - } return Standard_True; } diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index 3a577547c8..e96c2aee63 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -1859,7 +1859,7 @@ static Standard_Boolean getProDefinitionOfNAUO(const Handle(XSControl_WorkSessio } if ( NAUO.IsNull() ) return Standard_False; - // get Relatinf or Related product definition + // get Relating or Related product definition if ( !IsRelating ) PD = NAUO->RelatedProductDefinition(); else @@ -2197,59 +2197,30 @@ Standard_Boolean STEPCAFControl_Writer::WriteSHUOs (const Handle(XSControl_WorkS return Standard_True; } -//======================================================================= -//function : MakeTrimmedCurve -//purpose : auxilary -//======================================================================= -static Handle(StepGeom_TrimmedCurve) MakeTrimmedCurve(const Handle(StepGeom_Curve)& C, - const Handle(Geom_TrimmedCurve) TC, - Standard_Boolean sense) -{ - Handle(StepGeom_HArray1OfTrimmingSelect) aSTS1 = - new StepGeom_HArray1OfTrimmingSelect(1, 2); - StepGeom_TrimmingSelect tSel; - GeomToStep_MakeCartesianPoint aMP1(TC->StartPoint()); - tSel.SetValue(aMP1.Value()); - aSTS1->SetValue(1, tSel); - tSel.SetParameterValue(TC->FirstParameter()); - aSTS1->SetValue(2, tSel); - - Handle(StepGeom_HArray1OfTrimmingSelect) aSTS2 = - new StepGeom_HArray1OfTrimmingSelect(1, 2); - GeomToStep_MakeCartesianPoint aMP2(TC->EndPoint()); - tSel.SetValue(aMP2.Value()); - aSTS2->SetValue(1, tSel); - tSel.SetParameterValue(TC->LastParameter()); - aSTS2->SetValue(2, tSel); - - Handle(TCollection_HAsciiString) empty = - new TCollection_HAsciiString(""); - Handle(StepGeom_TrimmedCurve) pmsTC = new StepGeom_TrimmedCurve; - pmsTC->Init(empty, C, aSTS1, aSTS2, sense, StepGeom_tpParameter); - return pmsTC; -} - //======================================================================= //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_PropertyDefinition)& aPDS) + const Handle(XCAFDoc_KinematicTool)& theKTool, + const Interface_Graph& theGraph, + const TDF_Label& theLabelLink, + Handle(StepKinematics_KinematicLink)& theLink, + Handle(StepShape_ShapeRepresentation)& theShapeRepr, + Handle(StepRepr_PropertyDefinition)& thePDS) { 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); + Handle(TDataStd_Name) aNameLink; + Handle(TCollection_HAsciiString) aHNameLink; + if (theLabelLink.FindAttribute(TDataStd_Name::GetID(), aNameLink)) + aHNameLink = new TCollection_HAsciiString(aNameLink->Get()); + else + aHNameLink = new TCollection_HAsciiString("Link "+ theLabelLink.Tag()); + theLink->Init(aHNameLink); // find ref shapes - TDF_LabelSequence aShapesStartL = aKTool->GetRefShapes(theLabelLink); + TDF_LabelSequence aShapesStartL = theKTool->GetRefShapes(theLabelLink); if (aShapesStartL.IsEmpty()) return Standard_False; TopoDS_Shape aTopoShapeStart = XCAFDoc_ShapeTool::GetShape(aShapesStartL.Value(1)); TopLoc_Location aLocStart; @@ -2261,18 +2232,18 @@ static Standard_Boolean createKinematicLink(const Handle(Transfer_FinderProcess) } // get PDS of Shape - Interface_EntityIterator anIter = aGraph.Sharings(seqRI.Value(1)); - for (anIter.Start(); anIter.More() && aPDS.IsNull(); anIter.Next()) { - aShapeRepr = Handle(StepShape_ShapeRepresentation)::DownCast(anIter.Value()); - if (aShapeRepr.IsNull()) + Interface_EntityIterator anIter = theGraph.Sharings(seqRI.Value(1)); + for (anIter.Start(); anIter.More() && thePDS.IsNull(); anIter.Next()) { + theShapeRepr = Handle(StepShape_ShapeRepresentation)::DownCast(anIter.Value()); + if (theShapeRepr.IsNull()) continue; - Interface_EntityIterator aSDRIt = aGraph.Sharings(aShapeRepr); - for (aSDRIt.Start(); aSDRIt.More() && aPDS.IsNull(); aSDRIt.Next()) { + Interface_EntityIterator aSDRIt = theGraph.Sharings(theShapeRepr); + for (aSDRIt.Start(); aSDRIt.More() && thePDS.IsNull(); aSDRIt.Next()) { Handle(StepShape_ShapeDefinitionRepresentation) aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aSDRIt.Value()); if (aSDR.IsNull()) continue; - aPDS = aSDR->Definition().PropertyDefinition(); - if (!aPDS.IsNull()) + thePDS = aSDR->Definition().PropertyDefinition(); + if (!thePDS.IsNull()) return Standard_True; } } @@ -2284,55 +2255,36 @@ static Standard_Boolean createKinematicLink(const Handle(Transfer_FinderProcess) //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) +static Standard_Boolean createKinematicJoint(const Handle(Transfer_FinderProcess)& theFP, + const Handle(XCAFDoc_KinematicTool)& theKTool, + const Interface_Graph& theGraph, + const TDF_Label& theLabelJoint, + const Handle(XCAFKinematics_PairObject)& theKinPairObj, + const NCollection_DataMap& theMapOfLinks, + Handle(StepKinematics_RigidLinkRepresentation)& theRigLinkRepr1, + Handle(StepKinematics_RigidLinkRepresentation)& theRigLinkRepr2, + 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); + theKTool->GetLinksOfJoint(theLabelJoint, aLinkStartL, aLinkEndL); + Handle(TCollection_HAsciiString) aNameJoint = new TCollection_HAsciiString(theKinPairObj->Name()); - 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)); - if (aRigLinkRepr1.IsNull()) - return Standard_False; - aEdgeStart = aRigLinkRepr1->RepresentedLink(); - } - else if (aSeqOfLinskL(aLinkInd) == aLinkEndL) - { - aRigLinkRepr2 = Handle(StepKinematics_RigidLinkRepresentation)::DownCast(aArrayOfRigidLinks->Value(aLinkInd)); - if (aRigLinkRepr2.IsNull()) - return Standard_False; - aEdgeEnd = aRigLinkRepr2->RepresentedLink(); - } - } - if (aEdgeEnd.IsNull() || aEdgeStart.IsNull()) + if (!theMapOfLinks.Find(aLinkStartL, theRigLinkRepr1)) return Standard_False; - theJoint->Init(aNameJoint, aEdgeStart, aEdgeEnd); + if (!theMapOfLinks.Find(aLinkEndL, theRigLinkRepr2)) + return Standard_False; + + aEdgeStart = theRigLinkRepr1->RepresentedLink(); + aEdgeEnd = theRigLinkRepr2->RepresentedLink(); + if (aEdgeEnd.IsNull() || aEdgeStart.IsNull()) + return Standard_False; + theJoint->Init(aNameJoint, aEdgeStart, aEdgeEnd); return Standard_True; } @@ -2340,39 +2292,37 @@ static Standard_Boolean createKinematicJoint(const Handle(Transfer_FinderProcess //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) +static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObject)& theKinPairObj, + const Handle(StepKinematics_KinematicJoint)& theJoint, + Handle(StepKinematics_KinematicPair)& theKinematicPair, + Handle(StepKinematics_RigidLinkRepresentation)& theRigLinkRepr1, + Handle(StepKinematics_RigidLinkRepresentation)& theRigLinkRepr2) { - if (aKinPairObj->Type() == XCAFKinematics_PairType_NoType) + if (theKinPairObj->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(); + Handle(StepRepr_RepresentationItem) theTransformItem1 = GeomToStep_MakeAxis2Placement3d(theKinPairObj->FirstTransformation()).Value(); + Handle(StepRepr_RepresentationItem) theTransformItem2 = GeomToStep_MakeAxis2Placement3d(theKinPairObj->SecondTransformation()).Value(); - aRigLinkRepr1->Items()->Resize(aRigLinkRepr1->Items()->Lower(), aRigLinkRepr1->Items()->Upper() + 1, Standard_True); - aRigLinkRepr1->Items()->ChangeLast() = theTransformItem1; + theRigLinkRepr1->Items()->Resize(theRigLinkRepr1->Items()->Lower(), theRigLinkRepr1->Items()->Upper() + 1, Standard_True); + theRigLinkRepr1->Items()->ChangeLast() = theTransformItem1; - aRigLinkRepr2->Items()->Resize(aRigLinkRepr2->Items()->Lower(), aRigLinkRepr2->Items()->Upper() + 1, Standard_True); - aRigLinkRepr2->Items()->ChangeLast() = theTransformItem1; + theRigLinkRepr2->Items()->Resize(theRigLinkRepr2->Items()->Lower(), theRigLinkRepr2->Items()->Upper() + 1, Standard_True); + theRigLinkRepr2->Items()->ChangeLast() = theTransformItem2; Standard_Boolean hasDescription = Standard_False; - Handle(TCollection_HAsciiString) aPairName = new TCollection_HAsciiString(aKinPairObj->Name()); + Handle(TCollection_HAsciiString) aPairName = new TCollection_HAsciiString(theKinPairObj->Name()); Handle(TCollection_HAsciiString) aDescription; - Standard_Boolean HasRange = aKinPairObj->HasLimits(); - if (aKinPairObj->IsKind(STANDARD_TYPE(XCAFKinematics_LowOrderPairObject))) + Standard_Boolean aHasRange = theKinPairObj->HasLimits(); + if (theKinPairObj->IsKind(STANDARD_TYPE(XCAFKinematics_LowOrderPairObject))) { - Handle(XCAFKinematics_LowOrderPairObject) aLowOrderPairObj = Handle(XCAFKinematics_LowOrderPairObject)::DownCast(aKinPairObj); + Handle(XCAFKinematics_LowOrderPairObject) aLowOrderPairObj = Handle(XCAFKinematics_LowOrderPairObject)::DownCast(theKinPairObj); 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()) + switch (theKinPairObj->Type()) { case(XCAFKinematics_PairType_Revolute): { @@ -2381,21 +2331,21 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje aTZ = Standard_False; aRX = Standard_False; aRY = Standard_False; - if (HasRange) + if (aHasRange) { - aKinematicPair = new StepKinematics_RevolutePairWithRange; + theKinematicPair = 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); + Handle(StepKinematics_RevolutePairWithRange) aRevolutePairWithRange = Handle(StepKinematics_RevolutePairWithRange)::DownCast(theKinematicPair); 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); + theKinematicPair = new StepKinematics_RevolutePair; + Handle(StepKinematics_RevolutePair) aRevolutePair = Handle(StepKinematics_RevolutePair)::DownCast(theKinematicPair); aRevolutePair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aTX, aTY, aTZ, aRX, aRY, aRZ); @@ -2409,10 +2359,10 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje aRX = Standard_False; aRY = Standard_False; aRZ = Standard_False; - if (HasRange) + if (aHasRange) { - aKinematicPair = new StepKinematics_PrismaticPairWithRange; - Handle(StepKinematics_PrismaticPairWithRange) aPrismaticPairWithRange = Handle(StepKinematics_PrismaticPairWithRange)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_PrismaticPairWithRange; + Handle(StepKinematics_PrismaticPairWithRange) aPrismaticPairWithRange = Handle(StepKinematics_PrismaticPairWithRange)::DownCast(theKinematicPair); Standard_Real aUpperLimitActualTranslation = aLowOrderPairObj->MaxTranslationX(); Standard_Real aLowerLimitActualTranslation = aLowOrderPairObj->MinTranslationX(); aPrismaticPairWithRange->Init(aPairName, aPairName, hasDescription, @@ -2421,8 +2371,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } else { - aKinematicPair = new StepKinematics_PrismaticPair; - Handle(StepKinematics_PrismaticPair) aPrismaticPair = Handle(StepKinematics_PrismaticPair)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_PrismaticPair; + Handle(StepKinematics_PrismaticPair) aPrismaticPair = Handle(StepKinematics_PrismaticPair)::DownCast(theKinematicPair); aPrismaticPair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aTX, aTY, aTZ, aRX, aRY, aRZ); @@ -2435,10 +2385,10 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje aTY = Standard_False; aRX = Standard_False; aRY = Standard_False; - if (HasRange) + if (aHasRange) { - aKinematicPair = new StepKinematics_CylindricalPairWithRange; - Handle(StepKinematics_CylindricalPairWithRange) aCylindricalPairWithRange = Handle(StepKinematics_CylindricalPairWithRange)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_CylindricalPairWithRange; + Handle(StepKinematics_CylindricalPairWithRange) aCylindricalPairWithRange = Handle(StepKinematics_CylindricalPairWithRange)::DownCast(theKinematicPair); Standard_Real aUpperLimitActualTranslation = aLowOrderPairObj->MaxTranslationZ(); Standard_Real aLowerLimitActualTranslation = aLowOrderPairObj->MinTranslationZ(); Standard_Real aLowerLimitActualRotation = aLowOrderPairObj->MinRotationZ(); @@ -2450,8 +2400,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } else { - aKinematicPair = new StepKinematics_CylindricalPair; - Handle(StepKinematics_CylindricalPair) aCylindricalPair = Handle(StepKinematics_CylindricalPair)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_CylindricalPair; + Handle(StepKinematics_CylindricalPair) aCylindricalPair = Handle(StepKinematics_CylindricalPair)::DownCast(theKinematicPair); aCylindricalPair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aTX, aTY, aTZ, aRX, aRY, aRZ); @@ -2465,10 +2415,10 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje aTZ = Standard_False; aRY = Standard_False; Standard_Real theUniversalPair_InputSkewAngle = aLowOrderPairObj->SkewAngle(); - if (HasRange) + if (aHasRange) { - aKinematicPair = new StepKinematics_UniversalPairWithRange; - Handle(StepKinematics_UniversalPairWithRange) anUniversalPairWithRange = Handle(StepKinematics_UniversalPairWithRange)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_UniversalPairWithRange; + Handle(StepKinematics_UniversalPairWithRange) anUniversalPairWithRange = Handle(StepKinematics_UniversalPairWithRange)::DownCast(theKinematicPair); Standard_Real aUpperLimitActualRotationX = aLowOrderPairObj->MaxRotationX(); Standard_Real aLowerLimitActualRotationX = aLowOrderPairObj->MinRotationX(); Standard_Real aUpperLimitActualRotationZ = aLowOrderPairObj->MaxRotationZ(); @@ -2480,8 +2430,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } else { - aKinematicPair = new StepKinematics_UniversalPair; - Handle(StepKinematics_UniversalPair) anUniversalPair = Handle(StepKinematics_UniversalPair)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_UniversalPair; + Handle(StepKinematics_UniversalPair) anUniversalPair = Handle(StepKinematics_UniversalPair)::DownCast(theKinematicPair); anUniversalPair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, theUniversalPair_InputSkewAngle); @@ -2495,14 +2445,14 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje aTZ = Standard_False; aRX = Standard_False; aRY = Standard_False; - if (HasRange) + if (aHasRange) { 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); + theKinematicPair = new StepKinematics_SphericalPairWithPinAndRange; + Handle(StepKinematics_SphericalPairWithPinAndRange) aSphericalPairWithPinAndRange = Handle(StepKinematics_SphericalPairWithPinAndRange)::DownCast(theKinematicPair); aSphericalPairWithPinAndRange->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, aLowerLimitYaw, Standard_True, @@ -2510,8 +2460,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } else { - aKinematicPair = new StepKinematics_SphericalPairWithPin; - Handle(StepKinematics_SphericalPairWithPin) aSphericalPairWithPin = Handle(StepKinematics_SphericalPairWithPin)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_SphericalPairWithPin; + Handle(StepKinematics_SphericalPairWithPin) aSphericalPairWithPin = Handle(StepKinematics_SphericalPairWithPin)::DownCast(theKinematicPair); aSphericalPairWithPin->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aTX, aTY, aTZ, aRX, aRY, aRZ); @@ -2523,7 +2473,7 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje aTX = Standard_False; aTY = Standard_False; aTZ = Standard_False; - if (HasRange) + if (aHasRange) { Standard_Real aUpperLimitYaw = aLowOrderPairObj->MaxRotationZ(); Standard_Real aLowerLimitYaw = aLowOrderPairObj->MinRotationZ(); @@ -2531,8 +2481,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje 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); + theKinematicPair = new StepKinematics_SphericalPairWithRange; + Handle(StepKinematics_SphericalPairWithRange) aSphericalPairWithRange = Handle(StepKinematics_SphericalPairWithRange)::DownCast(theKinematicPair); aSphericalPairWithRange->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, aLowerLimitYaw, Standard_True, @@ -2540,8 +2490,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } else { - aKinematicPair = new StepKinematics_SphericalPair; - Handle(StepKinematics_SphericalPair) aSphericalPair = Handle(StepKinematics_SphericalPair)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_SphericalPair; + Handle(StepKinematics_SphericalPair) aSphericalPair = Handle(StepKinematics_SphericalPair)::DownCast(theKinematicPair); aSphericalPair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aTX, aTY, aTZ, aRX, aRY, aRZ); @@ -2550,18 +2500,18 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } case(XCAFKinematics_PairType_Planar): { - if (HasRange) - aKinematicPair = new StepKinematics_PlanarPairWithRange; + if (aHasRange) + theKinematicPair = new StepKinematics_PlanarPairWithRange; else - aKinematicPair = new StepKinematics_PlanarPair; + theKinematicPair = new StepKinematics_PlanarPair; aTZ = Standard_False; aRX = Standard_False; aRY = Standard_False; - if (HasRange) + if (aHasRange) { - aKinematicPair = new StepKinematics_PlanarPairWithRange; - Handle(StepKinematics_PlanarPairWithRange) aPlanarPairWithRange = Handle(StepKinematics_PlanarPairWithRange)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_PlanarPairWithRange; + Handle(StepKinematics_PlanarPairWithRange) aPlanarPairWithRange = Handle(StepKinematics_PlanarPairWithRange)::DownCast(theKinematicPair); Standard_Real aUpperLimitActualTranslationX = aLowOrderPairObj->MaxTranslationX(); Standard_Real aLowerLimitActualTranslationX = aLowOrderPairObj->MinTranslationX(); Standard_Real aUpperLimitActualTranslationY = aLowOrderPairObj->MaxTranslationY(); @@ -2576,8 +2526,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } else { - aKinematicPair = new StepKinematics_PlanarPair; - Handle(StepKinematics_PlanarPair) aPlanarPair = Handle(StepKinematics_PlanarPair)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_PlanarPair; + Handle(StepKinematics_PlanarPair) aPlanarPair = Handle(StepKinematics_PlanarPair)::DownCast(theKinematicPair); aPlanarPair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aTX, aTY, aTZ, aRX, aRY, aRZ); @@ -2586,7 +2536,7 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } case(XCAFKinematics_PairType_Unconstrained): { - aKinematicPair = new StepKinematics_LowOrderKinematicPairWithRange; + theKinematicPair = new StepKinematics_LowOrderKinematicPairWithRange; Standard_Real aUpperLimitActualTranslationX = aLowOrderPairObj->MaxTranslationX(); Standard_Real aLowerLimitActualTranslationX = aLowOrderPairObj->MinTranslationX(); @@ -2600,7 +2550,7 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje Standard_Real aUpperLimitActualRotationY = aLowOrderPairObj->MaxRotationY(); Standard_Real aLowerLimitActualRotationZ = aLowOrderPairObj->MinRotationZ(); Standard_Real aUpperLimitActualRotationZ = aLowOrderPairObj->MaxRotationZ(); - Handle(StepKinematics_LowOrderKinematicPairWithRange) anUnconstrainedPairWithRange = Handle(StepKinematics_LowOrderKinematicPairWithRange)::DownCast(aKinematicPair); + Handle(StepKinematics_LowOrderKinematicPairWithRange) anUnconstrainedPairWithRange = Handle(StepKinematics_LowOrderKinematicPairWithRange)::DownCast(theKinematicPair); anUnconstrainedPairWithRange->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, aLowerLimitActualRotationX, Standard_True, aUpperLimitActualRotationX, @@ -2613,8 +2563,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } case(XCAFKinematics_PairType_FullyConstrained): { - aKinematicPair = new StepKinematics_FullyConstrainedPair; - Handle(StepKinematics_FullyConstrainedPair) aFullyConstrainedPair = Handle(StepKinematics_FullyConstrainedPair)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_FullyConstrainedPair; + Handle(StepKinematics_FullyConstrainedPair) aFullyConstrainedPair = Handle(StepKinematics_FullyConstrainedPair)::DownCast(theKinematicPair); aFullyConstrainedPair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aTX, aTY, aTZ, aRX, aRY, aRZ); @@ -2627,8 +2577,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje aTZ = Standard_False; aRY = Standard_False; Standard_Real InputSkewAngle = aLowOrderPairObj->SkewAngle(); - aKinematicPair = new StepKinematics_HomokineticPair; - Handle(StepKinematics_HomokineticPair) aHomokineticPair = Handle(StepKinematics_HomokineticPair)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_HomokineticPair; + Handle(StepKinematics_HomokineticPair) aHomokineticPair = Handle(StepKinematics_HomokineticPair)::DownCast(theKinematicPair); aHomokineticPair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, InputSkewAngle); @@ -2640,18 +2590,18 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } return Standard_True; } - else if (aKinPairObj->IsKind(STANDARD_TYPE(XCAFKinematics_LowOrderPairObjectWithCoupling))) + else if (theKinPairObj->IsKind(STANDARD_TYPE(XCAFKinematics_LowOrderPairObjectWithCoupling))) { - Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) aLowOrderPairObjectWithCoupling = Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(aKinPairObj); - switch (aKinPairObj->Type()) + Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) aLowOrderPairObjectWithCoupling = Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(theKinPairObj); + switch (theKinPairObj->Type()) { case(XCAFKinematics_PairType_Screw): { Standard_Real aPitch = aLowOrderPairObjectWithCoupling->Pitch(); - if (HasRange) + if (aHasRange) { - aKinematicPair = new StepKinematics_ScrewPairWithRange; - Handle(StepKinematics_ScrewPairWithRange) aScrewPairWithRange = Handle(StepKinematics_ScrewPairWithRange)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_ScrewPairWithRange; + Handle(StepKinematics_ScrewPairWithRange) aScrewPairWithRange = Handle(StepKinematics_ScrewPairWithRange)::DownCast(theKinematicPair); Standard_Real aLowLimit = aLowOrderPairObjectWithCoupling->LowLimit(); Standard_Real aUpperLimit = aLowOrderPairObjectWithCoupling->UpperLimit(); aScrewPairWithRange->Init(aPairName, aPairName, hasDescription, @@ -2660,8 +2610,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } else { - aKinematicPair = new StepKinematics_ScrewPair; - Handle(StepKinematics_ScrewPair) aScrewPair = Handle(StepKinematics_ScrewPair)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_ScrewPair; + Handle(StepKinematics_ScrewPair) aScrewPair = Handle(StepKinematics_ScrewPair)::DownCast(theKinematicPair); aScrewPair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint,aPitch); } @@ -2670,20 +2620,20 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje case(XCAFKinematics_PairType_RackAndPinion): { Standard_Real aPinionRadius = aLowOrderPairObjectWithCoupling->PinionRadius(); - if (HasRange) + if (aHasRange) { - aKinematicPair = new StepKinematics_RackAndPinionPairWithRange; + theKinematicPair = new StepKinematics_RackAndPinionPairWithRange; Standard_Real aLowLimit = aLowOrderPairObjectWithCoupling->LowLimit(); Standard_Real aUpperLimit = aLowOrderPairObjectWithCoupling->UpperLimit(); - Handle(StepKinematics_RackAndPinionPairWithRange) aRackAndPinionPairWithRange = Handle(StepKinematics_RackAndPinionPairWithRange)::DownCast(aKinematicPair); + Handle(StepKinematics_RackAndPinionPairWithRange) aRackAndPinionPairWithRange = Handle(StepKinematics_RackAndPinionPairWithRange)::DownCast(theKinematicPair); 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); + theKinematicPair = new StepKinematics_RackAndPinionPair; + Handle(StepKinematics_RackAndPinionPair) aRackAndPinionPair = Handle(StepKinematics_RackAndPinionPair)::DownCast(theKinematicPair); aRackAndPinionPair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aPinionRadius); } @@ -2697,20 +2647,20 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje Standard_Real aHelicalAngle = aLowOrderPairObjectWithCoupling->HelicalAngle(); Standard_Real aRadiusFirstLink = aLowOrderPairObjectWithCoupling->RadiusFirstLink();; Standard_Real aRadiusSecondLink = aLowOrderPairObjectWithCoupling->RadiusSecondLink();; - if (HasRange) + if (aHasRange) { Standard_Real aLowLimit = aLowOrderPairObjectWithCoupling->LowLimit(); Standard_Real aUpperLimit = aLowOrderPairObjectWithCoupling->UpperLimit(); - aKinematicPair = new StepKinematics_GearPairWithRange; - Handle(StepKinematics_GearPairWithRange) aGearPairWithRange = Handle(StepKinematics_GearPairWithRange)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_GearPairWithRange; + Handle(StepKinematics_GearPairWithRange) aGearPairWithRange = Handle(StepKinematics_GearPairWithRange)::DownCast(theKinematicPair); 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); + theKinematicPair = new StepKinematics_GearPair; + Handle(StepKinematics_GearPair) aGearPair = Handle(StepKinematics_GearPair)::DownCast(theKinematicPair); aGearPair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint,aRadiusFirstLink,aRadiusSecondLink,aBevel,aHelicalAngle, aGearRatio); } @@ -2719,8 +2669,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje case(XCAFKinematics_PairType_LinearFlexibleAndPinion): { Standard_Real aPinionRadius = aLowOrderPairObjectWithCoupling->PinionRadius(); - aKinematicPair = new StepKinematics_LinearFlexibleAndPinionPair; - Handle(StepKinematics_LinearFlexibleAndPinionPair) aLinearFlexibleAndPinionPair = Handle(StepKinematics_LinearFlexibleAndPinionPair)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_LinearFlexibleAndPinionPair; + Handle(StepKinematics_LinearFlexibleAndPinionPair) aLinearFlexibleAndPinionPair = Handle(StepKinematics_LinearFlexibleAndPinionPair)::DownCast(theKinematicPair); aLinearFlexibleAndPinionPair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aPinionRadius); break; @@ -2731,14 +2681,14 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } return Standard_True; } - else if (aKinPairObj->IsKind(STANDARD_TYPE(XCAFKinematics_HighOrderPairObject))) //need to fix + else if (theKinPairObj->IsKind(STANDARD_TYPE(XCAFKinematics_HighOrderPairObject))) //need to fix { - Handle(XCAFKinematics_HighOrderPairObject) aHighOrderPairObject = Handle(XCAFKinematics_HighOrderPairObject)::DownCast(aKinPairObj); - switch (aKinPairObj->Type()) + Handle(XCAFKinematics_HighOrderPairObject) aHighOrderPairObject = Handle(XCAFKinematics_HighOrderPairObject)::DownCast(theKinPairObj); + switch (theKinPairObj->Type()) { case(XCAFKinematics_PairType_PointOnSurface): { - if (HasRange) + if (aHasRange) { GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface()); Handle(StepGeom_Surface) aPairSurface = aMaker.Value(); @@ -2750,18 +2700,18 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje Standard_Real aUpperLimitRoll = aHighOrderPairObject->UpperLimitRoll(); GeomToStep_MakeRectangularTrimmedSurface aMakerTrimmered(aHighOrderPairObject->TrimmedSurface()); Handle(StepGeom_RectangularTrimmedSurface) aRangeOnPairSurface = aMakerTrimmered.Value(); - aKinematicPair = new StepKinematics_PointOnSurfacePairWithRange; - Handle(StepKinematics_PointOnSurfacePairWithRange) aPointOnSurfacePairWithRange = Handle(StepKinematics_PointOnSurfacePairWithRange)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_PointOnSurfacePairWithRange; + Handle(StepKinematics_PointOnSurfacePairWithRange) aPointOnSurfacePairWithRange = Handle(StepKinematics_PointOnSurfacePairWithRange)::DownCast(theKinematicPair); 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; + theKinematicPair = new StepKinematics_PointOnSurfacePair; GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface()); Handle(StepGeom_Surface) aPairSurface = aMaker.Value(); - Handle(StepKinematics_PointOnSurfacePair) aPointOnSurface = Handle(StepKinematics_PointOnSurfacePair)::DownCast(aKinematicPair); + Handle(StepKinematics_PointOnSurfacePair) aPointOnSurface = Handle(StepKinematics_PointOnSurfacePair)::DownCast(theKinematicPair); aPointOnSurface->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint,aPairSurface); } @@ -2769,26 +2719,26 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } case(XCAFKinematics_PairType_SlidingSurface): { - aKinematicPair = new StepKinematics_SlidingSurfacePair; + theKinematicPair = new StepKinematics_SlidingSurfacePair; GeomToStep_MakeSurface aMaker(aHighOrderPairObject->FirstSurface()); Handle(StepGeom_Surface) aPairSurfac1 = aMaker.Value(); GeomToStep_MakeSurface aMaker2(aHighOrderPairObject->SecondSurface()); Handle(StepGeom_Surface) aPairSurface2 = aMaker2.Value(); Standard_Boolean anOrientation = aHighOrderPairObject->Orientation(); - Handle(StepKinematics_SlidingSurfacePair) aSlidingSurfacePair = Handle(StepKinematics_SlidingSurfacePair)::DownCast(aKinematicPair); + Handle(StepKinematics_SlidingSurfacePair) aSlidingSurfacePair = Handle(StepKinematics_SlidingSurfacePair)::DownCast(theKinematicPair); aSlidingSurfacePair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aPairSurfac1, aPairSurface2, anOrientation); break; } case(XCAFKinematics_PairType_RollingSurface): { - aKinematicPair = new StepKinematics_RollingSurfacePair; + theKinematicPair = new StepKinematics_RollingSurfacePair; GeomToStep_MakeSurface aMaker(aHighOrderPairObject->FirstSurface()); Handle(StepGeom_Surface) aPairSurfac1 = aMaker.Value(); GeomToStep_MakeSurface aMaker2(aHighOrderPairObject->SecondSurface()); Handle(StepGeom_Surface) aPairSurface2 = aMaker2.Value(); Standard_Boolean anOrientation = aHighOrderPairObject->Orientation(); - Handle(StepKinematics_RollingSurfacePair) aRollingSurfacePair = Handle(StepKinematics_RollingSurfacePair)::DownCast(aKinematicPair); + Handle(StepKinematics_RollingSurfacePair) aRollingSurfacePair = Handle(StepKinematics_RollingSurfacePair)::DownCast(theKinematicPair); aRollingSurfacePair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aPairSurfac1, aPairSurface2, anOrientation); break; @@ -2798,7 +2748,7 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje GeomToStep_MakeCurve aMaker(aHighOrderPairObject->Curve()); Handle(StepGeom_Curve) aPairCurve = aMaker.Value(); Standard_Boolean anOrientation = aHighOrderPairObject->Orientation(); - if (HasRange) + if (aHasRange) { Standard_Real aLowerLimitYaw = aHighOrderPairObject->LowLimitYaw(); Standard_Real aUpperLimitYaw = aHighOrderPairObject->UpperLimitYaw(); @@ -2807,17 +2757,37 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje Standard_Real aLowerLimitRoll = aHighOrderPairObject->LowLimitRoll(); Standard_Real aUpperLimitRoll = aHighOrderPairObject->UpperLimitRoll(); Handle(Geom_TrimmedCurve) aRangeOnCurve = aHighOrderPairObject->TrimmedCurve(); - Handle(StepGeom_TrimmedCurve) aRangeOnPairCurve = MakeTrimmedCurve(aPairCurve, aHighOrderPairObject->TrimmedCurve(), Standard_True); - aKinematicPair = new StepKinematics_PointOnPlanarCurvePairWithRange; - Handle(StepKinematics_PointOnPlanarCurvePairWithRange) aPointOnPlanarCurvePairWithRange = Handle(StepKinematics_PointOnPlanarCurvePairWithRange)::DownCast(aKinematicPair); + Handle(StepGeom_HArray1OfTrimmingSelect) aSTS1 = + new StepGeom_HArray1OfTrimmingSelect(1, 2); + StepGeom_TrimmingSelect tSel; + GeomToStep_MakeCartesianPoint aMP1(aRangeOnCurve->StartPoint()); + tSel.SetValue(aMP1.Value()); + aSTS1->SetValue(1, tSel); + tSel.SetParameterValue(aRangeOnCurve->FirstParameter()); + aSTS1->SetValue(2, tSel); + + Handle(StepGeom_HArray1OfTrimmingSelect) aSTS2 = + new StepGeom_HArray1OfTrimmingSelect(1, 2); + GeomToStep_MakeCartesianPoint aMP2(aRangeOnCurve->EndPoint()); + tSel.SetValue(aMP2.Value()); + aSTS2->SetValue(1, tSel); + tSel.SetParameterValue(aRangeOnCurve->LastParameter()); + aSTS2->SetValue(2, tSel); + + Handle(TCollection_HAsciiString) empty = + new TCollection_HAsciiString(""); + Handle(StepGeom_TrimmedCurve) aRangeOnPairCurve = new StepGeom_TrimmedCurve; + aRangeOnPairCurve->Init(empty, aPairCurve, aSTS1, aSTS2, Standard_True, StepGeom_tpParameter); + theKinematicPair = new StepKinematics_PointOnPlanarCurvePairWithRange; + Handle(StepKinematics_PointOnPlanarCurvePairWithRange) aPointOnPlanarCurvePairWithRange = Handle(StepKinematics_PointOnPlanarCurvePairWithRange)::DownCast(theKinematicPair); 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); + theKinematicPair = new StepKinematics_PointOnPlanarCurvePair; + Handle(StepKinematics_PointOnPlanarCurvePair) aPointOnPlanarCurvePair = Handle(StepKinematics_PointOnPlanarCurvePair)::DownCast(theKinematicPair); aPointOnPlanarCurvePair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aPairCurve, anOrientation); } @@ -2830,8 +2800,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje Standard_Boolean anOrientation = aHighOrderPairObject->Orientation(); GeomToStep_MakeCurve aMaker2(aHighOrderPairObject->SecondCurve()); Handle(StepGeom_Curve) aPairCurve2 = aMaker2.Value(); - aKinematicPair = new StepKinematics_SlidingCurvePair; - Handle(StepKinematics_SlidingCurvePair) aSlidingCurvePair = Handle(StepKinematics_SlidingCurvePair)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_SlidingCurvePair; + Handle(StepKinematics_SlidingCurvePair) aSlidingCurvePair = Handle(StepKinematics_SlidingCurvePair)::DownCast(theKinematicPair); aSlidingCurvePair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aPairCurve, aPairCurve2, anOrientation); break; @@ -2843,19 +2813,19 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje Standard_Boolean anOrientation = aHighOrderPairObject->Orientation(); GeomToStep_MakeCurve aMaker2(aHighOrderPairObject->SecondCurve()); Handle(StepGeom_Curve) aPairCurve2 = aMaker2.Value(); - aKinematicPair = new StepKinematics_RollingCurvePair; - Handle(StepKinematics_RollingCurvePair) aRollingCurvePair = Handle(StepKinematics_RollingCurvePair)::DownCast(aKinematicPair); + theKinematicPair = new StepKinematics_RollingCurvePair; + Handle(StepKinematics_RollingCurvePair) aRollingCurvePair = Handle(StepKinematics_RollingCurvePair)::DownCast(theKinematicPair); aRollingCurvePair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aPairCurve, aPairCurve2, anOrientation); break; } case(XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve): { - aKinematicPair = new StepKinematics_LinearFlexibleAndPlanarCurvePair; + theKinematicPair = 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); + Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair) aLinearFlexibleAndPlanarCurvePair = Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair)::DownCast(theKinematicPair); aLinearFlexibleAndPlanarCurvePair->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aPairCurve, anOrientation); break; @@ -2870,133 +2840,132 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje return Standard_False; } -static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_PairValueObject)& aKinPairValueObj, - Handle(StepKinematics_PairValue)& aPairValue, - const Handle(StepKinematics_PairRepresentationRelationship)& aPairReprRelationship) +static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_PairValueObject)& theKinPairValueObj, + const Handle(StepKinematics_PairRepresentationRelationship)& thePairReprRelationship, + Handle(StepKinematics_PairValue)& thePairValue) { - if (aKinPairValueObj->Type() == XCAFKinematics_PairType_NoType) + if (theKinPairValueObj->Type() == XCAFKinematics_PairType_NoType) return Standard_False; - - switch (aKinPairValueObj->Type()) + switch (theKinPairValueObj->Type()) { case(XCAFKinematics_PairType_Revolute): { - aPairValue = new StepKinematics_RevolutePairValue; + thePairValue = new StepKinematics_RevolutePairValue; Handle(StepKinematics_RevolutePairValue) aRevolutePairValue = - Handle(StepKinematics_RevolutePairValue)::DownCast(aPairValue); - aRevolutePairValue->SetActualRotation(aKinPairValueObj->GetRotation()); + Handle(StepKinematics_RevolutePairValue)::DownCast(thePairValue); + aRevolutePairValue->SetActualRotation(theKinPairValueObj->GetRotation()); break; } case(XCAFKinematics_PairType_Prismatic): { - aPairValue = new StepKinematics_PrismaticPairValue; + thePairValue = new StepKinematics_PrismaticPairValue; Handle(StepKinematics_PrismaticPairValue) aPrismaticPairValue = - Handle(StepKinematics_PrismaticPairValue)::DownCast(aPairValue); - aPrismaticPairValue->SetActualTranslation(aKinPairValueObj->GetTranslation()); + Handle(StepKinematics_PrismaticPairValue)::DownCast(thePairValue); + aPrismaticPairValue->SetActualTranslation(theKinPairValueObj->GetTranslation()); break; } case(XCAFKinematics_PairType_Cylindrical): { - aPairValue = new StepKinematics_CylindricalPairValue; + thePairValue = new StepKinematics_CylindricalPairValue; Handle(StepKinematics_CylindricalPairValue) aCylindricalPairValue = - Handle(StepKinematics_CylindricalPairValue)::DownCast(aPairValue); - aCylindricalPairValue->SetActualTranslation(aKinPairValueObj->GetTranslation()); - aCylindricalPairValue->SetActualRotation(aKinPairValueObj->GetRotation()); + Handle(StepKinematics_CylindricalPairValue)::DownCast(thePairValue); + aCylindricalPairValue->SetActualTranslation(theKinPairValueObj->GetTranslation()); + aCylindricalPairValue->SetActualRotation(theKinPairValueObj->GetRotation()); break; } case(XCAFKinematics_PairType_Universal): { - aPairValue = new StepKinematics_UniversalPairValue; + thePairValue = new StepKinematics_UniversalPairValue; Handle(StepKinematics_UniversalPairValue) aUniversalPairValue = - Handle(StepKinematics_UniversalPairValue)::DownCast(aPairValue); - aUniversalPairValue->SetFirstRotationAngle(aKinPairValueObj->GetFirstRotation()); - aUniversalPairValue->SetSecondRotationAngle(aKinPairValueObj->GetSecondRotation()); + Handle(StepKinematics_UniversalPairValue)::DownCast(thePairValue); + aUniversalPairValue->SetFirstRotationAngle(theKinPairValueObj->GetFirstRotation()); + aUniversalPairValue->SetSecondRotationAngle(theKinPairValueObj->GetSecondRotation()); break; } case(XCAFKinematics_PairType_Homokinetic): { - aPairValue = new StepKinematics_UniversalPairValue; + thePairValue = new StepKinematics_UniversalPairValue; Handle(StepKinematics_UniversalPairValue) aUniversalPairValue = - Handle(StepKinematics_UniversalPairValue)::DownCast(aPairValue); - aUniversalPairValue->SetFirstRotationAngle(aKinPairValueObj->GetFirstRotation()); - aUniversalPairValue->SetSecondRotationAngle(aKinPairValueObj->GetSecondRotation()); + Handle(StepKinematics_UniversalPairValue)::DownCast(thePairValue); + aUniversalPairValue->SetFirstRotationAngle(theKinPairValueObj->GetFirstRotation()); + aUniversalPairValue->SetSecondRotationAngle(theKinPairValueObj->GetSecondRotation()); break; } case(XCAFKinematics_PairType_Spherical): { - aPairValue = new StepKinematics_SphericalPairValue; + thePairValue = new StepKinematics_SphericalPairValue; Handle(StepKinematics_SphericalPairValue) aSphericalPairValue = - Handle(StepKinematics_SphericalPairValue)::DownCast(aPairValue); + Handle(StepKinematics_SphericalPairValue)::DownCast(thePairValue); StepKinematics_SpatialRotation InputRotation; - InputRotation.SetValue(aKinPairValueObj->GetAllValues()); + InputRotation.SetValue(theKinPairValueObj->GetAllValues()); aSphericalPairValue->SetInputOrientation(InputRotation); break; } case(XCAFKinematics_PairType_SphericalWithPin): { - aPairValue = new StepKinematics_SphericalPairValue; + thePairValue = new StepKinematics_SphericalPairValue; Handle(StepKinematics_SphericalPairValue) aSphericalPairValue = - Handle(StepKinematics_SphericalPairValue)::DownCast(aPairValue); + Handle(StepKinematics_SphericalPairValue)::DownCast(thePairValue); StepKinematics_SpatialRotation InputRotation; - InputRotation.SetValue(aKinPairValueObj->GetAllValues()); + InputRotation.SetValue(theKinPairValueObj->GetAllValues()); aSphericalPairValue->SetInputOrientation(InputRotation); break; } case(XCAFKinematics_PairType_Planar): { - aPairValue = new StepKinematics_PlanarPairValue; + thePairValue = new StepKinematics_PlanarPairValue; Handle(StepKinematics_PlanarPairValue) aPlanarPairValue = - Handle(StepKinematics_PlanarPairValue)::DownCast(aPairValue); - aPlanarPairValue->SetActualRotation(aKinPairValueObj->GetRotation()); - aPlanarPairValue->SetActualTranslationX(aKinPairValueObj->GetFirstTranslation()); - aPlanarPairValue->SetActualTranslationY(aKinPairValueObj->GetSecondTranslation()); + Handle(StepKinematics_PlanarPairValue)::DownCast(thePairValue); + aPlanarPairValue->SetActualRotation(theKinPairValueObj->GetRotation()); + aPlanarPairValue->SetActualTranslationX(theKinPairValueObj->GetFirstTranslation()); + aPlanarPairValue->SetActualTranslationY(theKinPairValueObj->GetSecondTranslation()); break; } case(XCAFKinematics_PairType_Unconstrained): { - aPairValue = new StepKinematics_UnconstrainedPairValue; + thePairValue = new StepKinematics_UnconstrainedPairValue; Handle(StepKinematics_UnconstrainedPairValue) anUnconstrainedPairValue = - Handle(StepKinematics_UnconstrainedPairValue)::DownCast(aPairValue); - GeomToStep_MakeAxis2Placement3d anActualPlacement(aKinPairValueObj->GetTransformation()); + Handle(StepKinematics_UnconstrainedPairValue)::DownCast(thePairValue); + GeomToStep_MakeAxis2Placement3d anActualPlacement(theKinPairValueObj->GetTransformation()); anUnconstrainedPairValue->SetActualPlacement(anActualPlacement.Value()); break; } case(XCAFKinematics_PairType_Screw): { - aPairValue = new StepKinematics_ScrewPairValue; + thePairValue = new StepKinematics_ScrewPairValue; Handle(StepKinematics_ScrewPairValue) aScrewPairValue = - Handle(StepKinematics_ScrewPairValue)::DownCast(aPairValue); - aScrewPairValue->SetActualRotation(aKinPairValueObj->GetRotation()); + Handle(StepKinematics_ScrewPairValue)::DownCast(thePairValue); + aScrewPairValue->SetActualRotation(theKinPairValueObj->GetRotation()); break; } case(XCAFKinematics_PairType_RackAndPinion): { - aPairValue = new StepKinematics_RackAndPinionPairValue; + thePairValue = new StepKinematics_RackAndPinionPairValue; Handle(StepKinematics_RackAndPinionPairValue) aRackAndPinionPairValue = - Handle(StepKinematics_RackAndPinionPairValue)::DownCast(aPairValue); - aRackAndPinionPairValue->SetActualDisplacement(aKinPairValueObj->GetTranslation()); + Handle(StepKinematics_RackAndPinionPairValue)::DownCast(thePairValue); + aRackAndPinionPairValue->SetActualDisplacement(theKinPairValueObj->GetTranslation()); break; } case(XCAFKinematics_PairType_Gear): { - aPairValue = new StepKinematics_GearPairValue; + thePairValue = new StepKinematics_GearPairValue; Handle(StepKinematics_GearPairValue) aGearPairValue = - Handle(StepKinematics_GearPairValue)::DownCast(aPairValue); - aGearPairValue->SetActualRotation1(aKinPairValueObj->GetRotation()); + Handle(StepKinematics_GearPairValue)::DownCast(thePairValue); + aGearPairValue->SetActualRotation1(theKinPairValueObj->GetRotation()); break; } case(XCAFKinematics_PairType_PointOnSurface): { - aPairValue = new StepKinematics_PointOnSurfacePairValue; + thePairValue = new StepKinematics_PointOnSurfacePairValue; Handle(StepKinematics_PointOnSurfacePairValue) aPointOnSurfacePairValue = - Handle(StepKinematics_PointOnSurfacePairValue)::DownCast(aPairValue); + Handle(StepKinematics_PointOnSurfacePairValue)::DownCast(thePairValue); Handle(StepGeom_PointOnSurface) aActualPointOnSurface = new StepGeom_PointOnSurface; Handle(StepKinematics_PointOnSurfacePair) aPointOnSurfacePair = - Handle(StepKinematics_PointOnSurfacePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); + Handle(StepKinematics_PointOnSurfacePair)::DownCast(thePairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); Standard_Real theU; Standard_Real theV; - aKinPairValueObj->GetPointOnSurface(theU, theV); + theKinPairValueObj->GetPointOnSurface(theU, theV); aActualPointOnSurface->Init(new TCollection_HAsciiString, aPointOnSurfacePair->PairSurface(), theU, theV); aPointOnSurfacePairValue->SetActualPointOnSurface(aActualPointOnSurface); StepKinematics_SpatialRotation aYRP; @@ -3004,7 +2973,7 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai Standard_Real aYaw; Standard_Real aPitch; Standard_Real aRoll; - aKinPairValueObj->GetYPR(aYaw, aPitch, aRoll); + theKinPairValueObj->GetYPR(aYaw, aPitch, aRoll); anArrayYRP->SetValue(1, aYaw); anArrayYRP->SetValue(2, aPitch); anArrayYRP->SetValue(3, aRoll); @@ -3014,53 +2983,53 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai } case(XCAFKinematics_PairType_SlidingSurface): { - aPairValue = new StepKinematics_SlidingSurfacePairValue; + thePairValue = new StepKinematics_SlidingSurfacePairValue; Handle(StepKinematics_SlidingSurfacePairValue) aSlidingSurfacePairValue = - Handle(StepKinematics_SlidingSurfacePairValue)::DownCast(aPairValue); + Handle(StepKinematics_SlidingSurfacePairValue)::DownCast(thePairValue); Handle(StepGeom_PointOnSurface) aActualPointOnSurface1 = new StepGeom_PointOnSurface; Handle(StepKinematics_SlidingSurfacePair) SlidingSurfacePair = - Handle(StepKinematics_SlidingSurfacePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); + Handle(StepKinematics_SlidingSurfacePair)::DownCast(thePairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); Standard_Real theU1; Standard_Real theV1; - aKinPairValueObj->GetFirstPointOnSurface(theU1, theV1); + theKinPairValueObj->GetFirstPointOnSurface(theU1, theV1); aActualPointOnSurface1->Init(new TCollection_HAsciiString, SlidingSurfacePair->Surface1(), theU1, theV1); aSlidingSurfacePairValue->SetActualPointOnSurface1(aActualPointOnSurface1); Handle(StepGeom_PointOnSurface) aActualPointOnSurface2 = new StepGeom_PointOnSurface; Standard_Real theU2; Standard_Real theV2; - aKinPairValueObj->GetSecondPointOnSurface(theU2, theV2); + theKinPairValueObj->GetSecondPointOnSurface(theU2, theV2); aActualPointOnSurface2->Init(new TCollection_HAsciiString, SlidingSurfacePair->Surface2(), theU2, theV2); aSlidingSurfacePairValue->SetActualPointOnSurface2(aActualPointOnSurface2); - aSlidingSurfacePairValue->SetActualRotation(aKinPairValueObj->GetRotation()); + aSlidingSurfacePairValue->SetActualRotation(theKinPairValueObj->GetRotation()); break; } case(XCAFKinematics_PairType_RollingSurface): { - aPairValue = new StepKinematics_RollingSurfacePairValue; + thePairValue = new StepKinematics_RollingSurfacePairValue; Handle(StepKinematics_RollingSurfacePairValue) aRollingSurfacePairValue = - Handle(StepKinematics_RollingSurfacePairValue)::DownCast(aPairValue); - aRollingSurfacePairValue->SetActualRotation(aKinPairValueObj->GetRotation()); + Handle(StepKinematics_RollingSurfacePairValue)::DownCast(thePairValue); + aRollingSurfacePairValue->SetActualRotation(theKinPairValueObj->GetRotation()); Handle(StepGeom_PointOnSurface) aActualPointOnSurface = new StepGeom_PointOnSurface; Handle(StepKinematics_RollingSurfacePair) aRollingSurfacePair = - Handle(StepKinematics_RollingSurfacePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); + Handle(StepKinematics_RollingSurfacePair)::DownCast(thePairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); Standard_Real theU; Standard_Real theV; - aKinPairValueObj->GetPointOnSurface(theU, theV); + theKinPairValueObj->GetPointOnSurface(theU, theV); aActualPointOnSurface->Init(new TCollection_HAsciiString, aRollingSurfacePair->Surface1(), theU, theV); aRollingSurfacePairValue->SetActualPointOnSurface(aActualPointOnSurface); break; } case(XCAFKinematics_PairType_PointOnPlanarCurve): { - aPairValue = new StepKinematics_PointOnPlanarCurvePairValue; + thePairValue = new StepKinematics_PointOnPlanarCurvePairValue; Handle(StepKinematics_PointOnPlanarCurvePairValue) aPointOnPlanarCurvePairValue = - Handle(StepKinematics_PointOnPlanarCurvePairValue)::DownCast(aPairValue); + Handle(StepKinematics_PointOnPlanarCurvePairValue)::DownCast(thePairValue); 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); + theKinPairValueObj->GetYPR(aYaw, aPitch, aRoll); anArrayYRP->SetValue(1, aYaw); anArrayYRP->SetValue(2, aPitch); anArrayYRP->SetValue(3, aRoll); @@ -3068,38 +3037,38 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai 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(); + Handle(StepKinematics_PointOnPlanarCurvePair)::DownCast(thePairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); + Standard_Real aParametr = theKinPairValueObj->GetPointOnCurve(); anActualPointOnCurve->Init(aPointOnPlanarCurvePair->Name(), aPointOnPlanarCurvePair->PairCurve(), aParametr); aPointOnPlanarCurvePairValue->SetActualPointOnCurve(anActualPointOnCurve); break; } case(XCAFKinematics_PairType_SlidingCurve): { - aPairValue = new StepKinematics_SlidingCurvePairValue; + thePairValue = new StepKinematics_SlidingCurvePairValue; Handle(StepKinematics_SlidingCurvePairValue) aSlidingCurvePairValue = - Handle(StepKinematics_SlidingCurvePairValue)::DownCast(aPairValue); + Handle(StepKinematics_SlidingCurvePairValue)::DownCast(thePairValue); Handle(StepGeom_PointOnCurve) anActualPointOnCurve1 = new StepGeom_PointOnCurve; Handle(StepKinematics_SlidingCurvePair) aSlidingCurvePair = - Handle(StepKinematics_SlidingCurvePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); - Standard_Real aParametr1 = aKinPairValueObj->GetFirstPointOnCurve(); + Handle(StepKinematics_SlidingCurvePair)::DownCast(thePairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); + Standard_Real aParametr1 = theKinPairValueObj->GetFirstPointOnCurve(); anActualPointOnCurve1->Init(aSlidingCurvePair->Name(), aSlidingCurvePair->Curve1(), aParametr1); aSlidingCurvePairValue->SetActualPointOnCurve1(anActualPointOnCurve1); Handle(StepGeom_PointOnCurve) anActualPointOnCurve2 = new StepGeom_PointOnCurve; - Standard_Real aParametr2 = aKinPairValueObj->GetSecondPointOnCurve(); + Standard_Real aParametr2 = theKinPairValueObj->GetSecondPointOnCurve(); anActualPointOnCurve2->Init(aSlidingCurvePair->Name(), aSlidingCurvePair->Curve2(), aParametr2); aSlidingCurvePairValue->SetActualPointOnCurve2(anActualPointOnCurve2); break; } case(XCAFKinematics_PairType_RollingCurve): { - aPairValue = new StepKinematics_RollingCurvePairValue; + thePairValue = new StepKinematics_RollingCurvePairValue; Handle(StepKinematics_RollingCurvePairValue) aRollingCurvePairValue = - Handle(StepKinematics_RollingCurvePairValue)::DownCast(aPairValue); + Handle(StepKinematics_RollingCurvePairValue)::DownCast(thePairValue); Handle(StepGeom_PointOnCurve) anActualPointOnCurve = new StepGeom_PointOnCurve; Handle(StepKinematics_RollingCurvePair) aRollingCurvePair = - Handle(StepKinematics_RollingCurvePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); - Standard_Real aParametr = aKinPairValueObj->GetPointOnCurve(); + Handle(StepKinematics_RollingCurvePair)::DownCast(thePairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); + Standard_Real aParametr = theKinPairValueObj->GetPointOnCurve(); anActualPointOnCurve->Init(aRollingCurvePair->Name(), aRollingCurvePair->Curve1(), aParametr); aRollingCurvePairValue->SetActualPointOnCurve1(anActualPointOnCurve); break; @@ -3109,28 +3078,32 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai break; } Handle(StepKinematics_KinematicPair) aAppliesToPair = - Handle(StepKinematics_KinematicPair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); - aPairValue->SetAppliesToPair(aAppliesToPair); - aPairValue->SetName(aAppliesToPair->Name()); + Handle(StepKinematics_KinematicPair)::DownCast(thePairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); + thePairValue->SetAppliesToPair(aAppliesToPair); + thePairValue->SetName(aAppliesToPair->Name()); return Standard_True; } -Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Handle(XSControl_WorkSession)& WS, const TDF_LabelSequence& labels) +//======================================================================= +//function : WriteKinematics +//purpose : +//======================================================================= +Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Handle(XSControl_WorkSession)& theWS, const TDF_LabelSequence& theLabels) { - if (labels.Length() <= 0) return Standard_False; + if (theLabels.Length() <= 0) return Standard_False; // get working data - const Handle(Interface_InterfaceModel)& Model = WS->Model(); - const Handle(XSControl_TransferWriter)& TW = WS->TransferWriter(); + const Handle(Interface_InterfaceModel)& Model = theWS->Model(); + const Handle(XSControl_TransferWriter)& TW = theWS->TransferWriter(); const Handle(Transfer_FinderProcess)& FP = TW->FinderProcess(); - const Handle(Interface_HGraph) aHGraph = WS->HGraph(); + const Handle(Interface_HGraph) aHGraph = theWS->HGraph(); if (aHGraph.IsNull()) return Standard_False; Interface_Graph aGraph = aHGraph->Graph(); - Handle(XCAFDoc_KinematicTool) aKTool = XCAFDoc_DocumentTool::KinematicTool(labels(1)); + Handle(XCAFDoc_KinematicTool) aKTool = XCAFDoc_DocumentTool::KinematicTool(theLabels(1)); if (aKTool.IsNull()) return Standard_False; @@ -3141,17 +3114,16 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha if (aMechanismsL.Length() <= 0) return Standard_False; Standard_Integer aMechInd; - for (aMechInd = 1; aMechInd <= aMechanismsL.Length(); aMechInd++) + for (Standard_Integer aMechInd = 1; aMechInd <= aMechanismsL.Length(); aMechInd++) { - //write Links - Handle(StepKinematics_KinematicLinkRepresentation) aBaseLinksOfMech; + // write Links + Handle(StepKinematics_RigidLinkRepresentation) aBaseLinkOfMech; Handle(StepRepr_PropertyDefinition) aGeneralDefinition; - //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()); + continue; + NCollection_DataMap aMapOfLinks; for (Standard_Integer aLinkInd = 1; aLinkInd <= aSeqOfLinskL.Length(); aLinkInd++) { @@ -3159,24 +3131,24 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha Handle(StepKinematics_KinematicLink) aLink; Handle(StepShape_ShapeRepresentation) aRefShapeOfLink; Handle(StepRepr_PropertyDefinition) aPD; - if (!createKinematicLink(FP, aKTool, aLink, aGraph, aLinkL, aRefShapeOfLink, aPD)) + if (!createKinematicLink(FP, aKTool, aGraph, aLinkL, aLink, aRefShapeOfLink, aPD)) continue; 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); + aMapOfLinks.Bind(aSeqOfLinskL(aLinkInd), aLinkRepresentation); Handle(TDataStd_Integer) aBase; - if (aBaseLinksOfMech.IsNull() && aLinkL.FindAttribute(TDataStd_Integer::GetID(), aBase)) - aBaseLinksOfMech = aLinkRepresentation; + if (aBaseLinkOfMech.IsNull() && aLinkL.FindAttribute(TDataStd_Integer::GetID(), aBase)) + aBaseLinkOfMech = aLinkRepresentation; Handle(StepKinematics_KinematicLinkRepresentationAssociation) aLinkRepresentationAssociation = new StepKinematics_KinematicLinkRepresentationAssociation; - aLinkRepresentationAssociation->Init(aNameOfLinkRepr, aNameOfLinkRepr, aRefShapeOfLink, aLinkRepresentation); + aLinkRepresentationAssociation->Init(aNameOfLinkRepr, aNameOfLinkRepr, aLinkRepresentation, aRefShapeOfLink); Handle(StepKinematics_ContextDependentKinematicLinkRepresentation) aCDKLRS = new StepKinematics_ContextDependentKinematicLinkRepresentation; Handle(StepKinematics_ProductDefinitionRelationshipKinematics) aPDRK = new StepKinematics_ProductDefinitionRelationshipKinematics; - aGeneralDefinition = aPD; //Work, but think out + aGeneralDefinition = aPD; aPDRK->Init(aNameOfLinkRepr, Standard_False, aLinkRepresentationAssociation->Description(), aPD->Definition()); aCDKLRS->Init(aLinkRepresentationAssociation, aPDRK); Model->AddEntity(aLink); @@ -3185,19 +3157,19 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha Model->AddEntity(aPDRK); Model->AddEntity(aCDKLRS); } - if (aBaseLinksOfMech.IsNull()) - aBaseLinksOfMech = Handle(StepKinematics_KinematicLinkRepresentation)::DownCast(aArrayOfRigidLinks->Value(1)); - if (aGeneralDefinition.IsNull()) continue; - //write joints - //containers storing Joints and their labels located at a single index - //any joint corresponds a unique pair with the same index + // if not found base link in OCAF + // first link became base of the mechanism + if (aBaseLinkOfMech.IsNull() && !aMapOfLinks.Find(aSeqOfLinskL(1), aBaseLinkOfMech)) + continue; + + // write joints 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()); + continue; + NCollection_IndexedDataMap aMapofJoints; Handle(StepRepr_HArray1OfRepresentationItem) anArrayOfPairs = new StepRepr_HArray1OfRepresentationItem(1, aSeqOfJointsL.Length()); Handle(StepKinematics_KinematicPropertyMechanismRepresentation) aPropertyMechanismRepr = new StepKinematics_KinematicPropertyMechanismRepresentation; @@ -3215,11 +3187,11 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha 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)) + if (!createKinematicJoint(FP, aKTool, aGraph, aJointL, aPairObject, aMapOfLinks, aRigLinkRepr1, aRigLinkRepr2, aJoint)) continue; - if (!createKinematicPair(aPairObject, aKinematicPair, aJoint, aSeqOfLinskL, aRigLinkRepr1, aRigLinkRepr2, aArrayOfRigidLinks)) + if (!createKinematicPair(aPairObject,aJoint,aKinematicPair, aRigLinkRepr1, aRigLinkRepr2)) continue; - aArrayOfJoints->SetValue(aJointInd, aJoint); + aMapofJoints.Add(aSeqOfJointsL(aJointInd), aJoint); Handle(StepKinematics_PairRepresentationRelationship) aPairReprRelationship = new StepKinematics_PairRepresentationRelationship; StepRepr_RepresentationOrRepresentationReference aDataLinkStart; aDataLinkStart.SetValue(aRigLinkRepr1); @@ -3234,21 +3206,21 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha Model->AddWithRefs(aPairReprRelationship); } - //write mechanism + // write mechanism Handle(StepKinematics_ProductDefinitionKinematics) aProductDefKin = new StepKinematics_ProductDefinitionKinematics; aProductDefKin->Init(new TCollection_HAsciiString, Standard_False, new TCollection_HAsciiString, aGeneralDefinition->Definition()); - aKTopoStruct->Init(new TCollection_HAsciiString, anArrayOfPairs, aBaseLinksOfMech->ContextOfItems()); + aKTopoStruct->Init(new TCollection_HAsciiString, anArrayOfPairs, aBaseLinkOfMech->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); + aMechanism->Init(aHNameMechanism, anArrayOfPairs, aBaseLinkOfMech->ContextOfItems(), aTopoSelect); + aPropertyMechanismRepr->Init(aPDK, aMechanism, aBaseLinkOfMech); Model->AddWithRefs(aPropertyMechanismRepr); - //(optional) write States + // (optional) write States TDF_LabelSequence aSeqOfStates = aKTool->GetStates(aMechanismsL.Value(aMechInd)); for (Standard_Integer aStateInd = 1; aStateInd <= aSeqOfStates.Length(); ++aStateInd) { @@ -3262,17 +3234,10 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha 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()) + if (!aMapofJoints.FindFromKey(aJointL, aJoint)) + continue; + aPairReprRelationship = Handle(StepKinematics_PairRepresentationRelationship)::DownCast(anArrayOfPairs->Value(aMapofJoints.FindIndex(aJointL))); + if (aPairReprRelationship.IsNull()) continue; Handle(XCAFDoc_KinematicPairValue) aKPairValueAttr; if (!aSeqOfValues(aValueInd).FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aKPairValueAttr)) @@ -3285,7 +3250,7 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha continue; Handle(XCAFKinematics_PairValueObject) aPairValueObject = aKPairValueAttr->GetObject(); Handle(StepKinematics_PairValue) aPairValue; - if (!createKinematicPairValue(aPairValueObject, aPairValue, aPairReprRelationship)) + if (!createKinematicPairValue(aPairValueObject, aPairReprRelationship, aPairValue)) continue; aPairValue->SetName(aNameOfValue); aItems->SetValue(aValueInd, aPairValue); diff --git a/src/StepKinematics/StepKinematics_MechanismStateRepresentation.cxx b/src/StepKinematics/StepKinematics_MechanismStateRepresentation.cxx index 333be3f1b3..f34be4621a 100644 --- a/src/StepKinematics/StepKinematics_MechanismStateRepresentation.cxx +++ b/src/StepKinematics/StepKinematics_MechanismStateRepresentation.cxx @@ -22,21 +22,21 @@ IMPLEMENT_STANDARD_RTTIEXT(StepKinematics_MechanismStateRepresentation, StepRepr 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) +void StepKinematics_MechanismStateRepresentation::Init(const Handle(TCollection_HAsciiString)& theName, + const Handle(StepRepr_HArray1OfRepresentationItem)& theItems, + const Handle(StepRepr_RepresentationContext)& theContextOfItems, + const Handle(StepKinematics_MechanismRepresentation) theMechanism) { - StepRepr_Representation::Init(aName, aItems, aContextOfItems); - representedMechanism = aMechanism; + StepRepr_Representation::Init(theName, theItems, theContextOfItems); + myRepresentedMechanism = theMechanism; } -void StepKinematics_MechanismStateRepresentation::SetMechanism(const Handle(StepKinematics_MechanismRepresentation)& aMechanism) +void StepKinematics_MechanismStateRepresentation::SetMechanism(const Handle(StepKinematics_MechanismRepresentation)& theMechanism) { - representedMechanism = aMechanism; + myRepresentedMechanism = theMechanism; } Handle(StepKinematics_MechanismRepresentation) StepKinematics_MechanismStateRepresentation::Mechanism() const { - return representedMechanism; + return myRepresentedMechanism; } \ No newline at end of file diff --git a/src/StepKinematics/StepKinematics_MechanismStateRepresentation.hxx b/src/StepKinematics/StepKinematics_MechanismStateRepresentation.hxx index f72a364b4f..82ee1ca25c 100644 --- a/src/StepKinematics/StepKinematics_MechanismStateRepresentation.hxx +++ b/src/StepKinematics/StepKinematics_MechanismStateRepresentation.hxx @@ -34,14 +34,14 @@ 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 Init(const Handle(TCollection_HAsciiString)& theName, const Handle(StepRepr_HArray1OfRepresentationItem)& theItems, const Handle(StepRepr_RepresentationContext)& theContextOfItems, const Handle(StepKinematics_MechanismRepresentation) theMechanism); - Standard_EXPORT void SetMechanism(const Handle(StepKinematics_MechanismRepresentation)& aMechanism); + Standard_EXPORT void SetMechanism(const Handle(StepKinematics_MechanismRepresentation)& theMechanism); Standard_EXPORT Handle(StepKinematics_MechanismRepresentation) Mechanism() const; private: - Handle(StepKinematics_MechanismRepresentation) representedMechanism; + Handle(StepKinematics_MechanismRepresentation) myRepresentedMechanism; DEFINE_STANDARD_RTTIEXT(StepKinematics_MechanismStateRepresentation,StepRepr_Representation) }; diff --git a/src/StepToGeom/StepToGeom.cxx b/src/StepToGeom/StepToGeom.cxx index e16fc3a903..f623e2afbd 100644 --- a/src/StepToGeom/StepToGeom.cxx +++ b/src/StepToGeom/StepToGeom.cxx @@ -132,10 +132,16 @@ #include #include #include +#include +#include #include #include +#include +#include +#include +#include #include //============================================================================= @@ -2062,3 +2068,239 @@ Handle(Geom2d_VectorWithMagnitude) StepToGeom::MakeVectorWithMagnitude2d (const } return 0; } + +//============================================================================= +// Creation d' un YptRotation de Kinematic a partir d' un SpatialRotation de Step +//============================================================================= + +Handle(TColStd_HArray1OfReal) StepToGeom::MakeYprRotation(const StepKinematics_SpatialRotation& SR, const Handle(StepRepr_GlobalUnitAssignedContext)& theCntxt) +{ + //If rotation is already a ypr_rotation, return it immediately + Handle(TColStd_HArray1OfReal) anYPRRotation; + if (!SR.YprRotation().IsNull() && + SR.YprRotation()->Length() == 3) + { + anYPRRotation = SR.YprRotation(); + } + //rotation is a rotation_about_direction + else if (!SR.RotationAboutDirection().IsNull() && + SR.RotationAboutDirection()->DirectionOfAxis()->DirectionRatios()->Length() == 3 && + !theCntxt.IsNull()) + { + Handle(Geom_Direction) anAxis; + anAxis = new Geom_Direction(SR.RotationAboutDirection()->DirectionOfAxis()->DirectionRatiosValue(1), + SR.RotationAboutDirection()->DirectionOfAxis()->DirectionRatiosValue(2), + SR.RotationAboutDirection()->DirectionOfAxis()->DirectionRatiosValue(3)); + Standard_Real anAngle = SR.RotationAboutDirection()->RotationAngle(); + if (anAngle == 0.) + { + // a zero rotation is converted trivially + anYPRRotation = new TColStd_HArray1OfReal(1, 3); + anYPRRotation->SetValue(1, 0.); + anYPRRotation->SetValue(2, 0.); + anYPRRotation->SetValue(3, 0.); + return anYPRRotation; + } + Standard_Real dx = anAxis->X(); + Standard_Real dy = anAxis->Y(); + Standard_Real dz = anAxis->Z(); + NCollection_Sequence aPaUnits; + for (Standard_Integer anInd = 1; anInd <= theCntxt->Units()->Length(); ++anInd) + { + if (theCntxt->UnitsValue(anInd)->IsKind(STANDARD_TYPE(StepBasic_ConversionBasedUnitAndPlaneAngleUnit))|| + theCntxt->UnitsValue(anInd)->IsKind(STANDARD_TYPE(StepBasic_SiUnitAndPlaneAngleUnit))) + aPaUnits.Append(theCntxt->UnitsValue(anInd)); + } + if (aPaUnits.Length() != 1) + return anYPRRotation; + Handle(StepBasic_NamedUnit) aPau = aPaUnits.Value(1); + while (!aPau.IsNull() && aPau->IsKind((STANDARD_TYPE(StepBasic_ConversionBasedUnitAndPlaneAngleUnit)))) + { + Handle(StepBasic_ConversionBasedUnitAndPlaneAngleUnit) aConverUnit = Handle(StepBasic_ConversionBasedUnitAndPlaneAngleUnit)::DownCast(aPau); + anAngle = anAngle * aConverUnit->ConversionFactor()->ValueComponent(); + aPau = aConverUnit->ConversionFactor()->UnitComponent().NamedUnit(); + } + if(aPau.IsNull()) + return anYPRRotation; + Handle(StepBasic_SiUnitAndPlaneAngleUnit) aSiUnit = Handle(StepBasic_SiUnitAndPlaneAngleUnit)::DownCast(aPau); + if(aSiUnit.IsNull() || aSiUnit->Name() != StepBasic_SiUnitName::StepBasic_sunRadian) + return anYPRRotation; + switch (aSiUnit->Prefix()) + { + case(StepBasic_spExa): + anAngle = 1.E18 * anAngle; + break; + case(StepBasic_spPeta): + anAngle = 1.E15 * anAngle; + break; + case(StepBasic_spTera): + anAngle = 1.E12 * anAngle; + break; + case(StepBasic_spGiga): + anAngle = 1.E9 * anAngle; + break; + case(StepBasic_spMega): + anAngle = 1.E6 * anAngle; + break; + case(StepBasic_spKilo): + anAngle = 1.E3 * anAngle; + break; + case(StepBasic_spHecto): + anAngle = 1.E2 * anAngle; + break; + case(StepBasic_spDeca): + anAngle = 1.E1 * anAngle; + break; + case(StepBasic_spDeci): + anAngle = 1.E-1 * anAngle; + break; + case(StepBasic_spCenti): + anAngle = 1.E-2 * anAngle; + break; + case(StepBasic_spMilli): + anAngle = 1.E-3 * anAngle; + break; + case(StepBasic_spMicro): + anAngle = 1.E-6 * anAngle; + break; + case(StepBasic_spNano): + anAngle = 1.E-9 * anAngle; + break; + case(StepBasic_spPico): + anAngle = 1.E-12 * anAngle; + break; + case(StepBasic_spFemto): + anAngle = 1.E-15 * anAngle; + break; + case(StepBasic_spAtto): + anAngle = 1.E-18 * anAngle; + break; + } + Standard_Real anUcf = SR.RotationAboutDirection()->RotationAngle() / anAngle; + Standard_Real aSA = Sin(anAngle); + Standard_Real aCA = Cos(anAngle); + Standard_Real aYaw = 0, aPitch = 0, aRoll = 0; + // axis parallel either to x-axis or to z-axis? + if (dy == 0. && dx * dz == 0.) + { + while (anAngle <= -M_PI) + anAngle = anAngle + 2 * M_PI; + while (anAngle > M_PI) + anAngle = anAngle - 2 * M_PI; + + aYaw = anUcf * anAngle; + if (anAngle != M_PI) + aRoll = -aYaw; + else + aRoll = aYaw; + anYPRRotation = new TColStd_HArray1OfReal(1, 3); + anYPRRotation->SetValue(1, 0.); + anYPRRotation->SetValue(2, 0.); + anYPRRotation->SetValue(3, 0.); + if (dx != 0.) + if (dx > 0.) + anYPRRotation->SetValue(3, aYaw); + else + anYPRRotation->SetValue(3, aRoll); + else + if (dz > 0.) + anYPRRotation->SetValue(1, aYaw); + else + anYPRRotation->SetValue(1, aRoll); + return anYPRRotation; + } + + // axis parallel to y-axis - use y-axis as pitch axis + if ((dy != 0.0) && (dx == 0.0) && (dz == 0.0)) + { + if (aCA >= 0.0) + { + aYaw = 0.0; + aRoll = 0.0; + } + else + { + aYaw = anUcf * M_PI; + aRoll = aYaw; + } + aPitch = anUcf * ATan2(aSA, Abs(aCA)); + if (dy < 0.0) + aPitch = -aPitch; + anYPRRotation = new TColStd_HArray1OfReal(1, 3); + anYPRRotation->SetValue(1, aYaw); + anYPRRotation->SetValue(2, aPitch); + anYPRRotation->SetValue(3, aRoll); + return anYPRRotation; + } + // axis not parallel to any axis of coordinate system + // compute rotation matrix + Standard_Real aCm1 = 1 - aCA; + + Standard_Real aRotMat[3][3] = { { dx * dx * aCm1 + aCA ,dx * dy * aCm1 - dz * aSA, dx * dz * aCm1 + dy * aSA }, + { dx * dy * aCm1 + dz * aSA,dy * dy * aCm1 + aCA, dy * dz * aCm1 - dx * aSA }, + { dx * dz * aCm1 - dy * aSA, dy * dz * aCm1 + dx * aSA,dz * dz * aCm1 + aCA } }; + + // aRotMat[1][3] equals SIN(pitch_angle) + if (Abs(aRotMat[0][2] == 1.)) + { + // |aPithc| = PI/2 + if (aRotMat[0][2] == 1.) + aPitch = M_PI_2; + else + aPitch = -M_PI_2; + // In this case, only the sum or difference of roll and yaw angles + // is relevant and can be evaluated from the matrix. + // According to IP `rectangular pitch angle' for ypr_rotation, + // the roll angle is set to zero. + aRoll = 0.; + aYaw = ATan2(aRotMat[1][0], aRotMat[1][1]); + // result of ATAN is in the range[-PI / 2, PI / 2]. + // Here all four quadrants are needed. + + if (aRotMat[1][1] < 0.) + if (aYaw <= 0.) + aYaw = aYaw + M_PI; + else + aYaw = aYaw - M_PI; + } + else + { + // COS (pitch_angle) not equal to zero + aYaw = ATan2(-aRotMat[0][1], aRotMat[0][0]); + + if (aRotMat[0][0] < 0.) + { + if (aYaw <= 0.) + aYaw = aYaw + M_PI; + else + aYaw = aYaw - M_PI; + } + Standard_Real aSY = Sin(aYaw); + Standard_Real aCY = Cos(aYaw); + Standard_Real aSR = Sin(aRoll); + Standard_Real aCR = Cos(aRoll); + + if (Abs(aSY) > Abs(aCY) && + Abs(aSY) > Abs(aSR) && + Abs(aSY) > Abs(aCR)) + aCm1 = -aRotMat[0][1] / aSY; + else + if (Abs(aCY) > Abs(aSR) && Abs(aCY) > Abs(aCR)) + aCm1 = aRotMat[0][0] / aCY; + else + if (Abs(aSR) > Abs(aCR)) + aCm1 = -aRotMat[1][2] / aSR; + else + aCm1 = aRotMat[2][2] / aCR; + aPitch = ATan2(aRotMat[0][2], aCm1); + } + aYaw = aYaw * anUcf; + aPitch = aPitch * anUcf; + aRoll = aRoll * anUcf; + anYPRRotation = new TColStd_HArray1OfReal(1, 3); + anYPRRotation->SetValue(1, aYaw); + anYPRRotation->SetValue(2, aPitch); + anYPRRotation->SetValue(3, aRoll); + } + return anYPRRotation; +} diff --git a/src/StepToGeom/StepToGeom.hxx b/src/StepToGeom/StepToGeom.hxx index ac89d1c085..2e79911f8a 100644 --- a/src/StepToGeom/StepToGeom.hxx +++ b/src/StepToGeom/StepToGeom.hxx @@ -101,6 +101,9 @@ class StepGeom_CartesianTransformationOperator3d; class StepGeom_TrimmedCurve; class StepGeom_Vector; class StepKinematics_SuParameters; +class StepKinematics_SpatialRotation; +class StepRepr_GlobalUnitAssignedContext; +class TColStd_HArray1OfReal; //! This class provides static methods to convert STEP geometric entities to OCCT. //! The methods returning handles will return null handle in case of error. @@ -157,6 +160,7 @@ public: Standard_EXPORT static Handle(Geom2d_BSplineCurve) MakeTrimmedCurve2d (const Handle(StepGeom_TrimmedCurve)& SC); Standard_EXPORT static Handle(Geom_VectorWithMagnitude) MakeVectorWithMagnitude (const Handle(StepGeom_Vector)& SV); Standard_EXPORT static Handle(Geom2d_VectorWithMagnitude) MakeVectorWithMagnitude2d (const Handle(StepGeom_Vector)& SV); + Standard_EXPORT static Handle(TColStd_HArray1OfReal) MakeYprRotation(const StepKinematics_SpatialRotation& SR, const Handle(StepRepr_GlobalUnitAssignedContext)& theCntxt); }; #endif // _StepToGeom_HeaderFile diff --git a/src/XCAFDoc/XCAFDoc_KinematicPair.cxx b/src/XCAFDoc/XCAFDoc_KinematicPair.cxx index 60370244ce..a30ace0155 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicPair.cxx +++ b/src/XCAFDoc/XCAFDoc_KinematicPair.cxx @@ -146,7 +146,7 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t // High order pairs if (theObject->Type() >= XCAFKinematics_PairType_PointOnSurface && - theObject->Type() <= XCAFKinematics_PairType_RollingCurve) { + theObject->Type() <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) { Handle(XCAFKinematics_HighOrderPairObject) anObject = Handle(XCAFKinematics_HighOrderPairObject)::DownCast(theObject); TDataStd_Integer::Set(Label(), getParamsID(), (Standard_Integer)anObject->Orientation()); @@ -186,8 +186,8 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t TNaming_Builder aTNBuild(Label().FindChild(ChildLab_FirstGeomParam)); aTNBuild.Generated(anEdge); } - if (theObject->Type() == XCAFKinematics_PairType_SlidingCurve || - theObject->Type() == XCAFKinematics_PairType_RollingCurve) + if (theObject->Type() >= XCAFKinematics_PairType_SlidingCurve && + theObject->Type() <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) { TopoDS_Edge anEdge1, anEdge2; if (!anObject->FirstCurve().IsNull()) { @@ -220,10 +220,10 @@ Handle(XCAFKinematics_PairObject) XCAFDoc_KinematicPair::GetObject() const 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); } @@ -266,7 +266,7 @@ Handle(XCAFKinematics_PairObject) XCAFDoc_KinematicPair::GetObject() const // Low order pairs with motion coupling if (anObject->Type() >= XCAFKinematics_PairType_Screw && - anObject->Type() <= XCAFKinematics_PairType_Gear) { + anObject->Type() <= XCAFKinematics_PairType_LinearFlexibleAndPinion) { Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) aDefObject = Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(anObject); Handle(TDataStd_RealArray) aParamsAttr; @@ -278,7 +278,7 @@ Handle(XCAFKinematics_PairObject) XCAFDoc_KinematicPair::GetObject() const // High order pairs if (anObject->Type() >= XCAFKinematics_PairType_PointOnSurface && - anObject->Type() <= XCAFKinematics_PairType_RollingCurve) { + anObject->Type() <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) { Handle(XCAFKinematics_HighOrderPairObject) aDefObject = Handle(XCAFKinematics_HighOrderPairObject)::DownCast(anObject); Handle(TDataStd_Integer) anOrienAttr; @@ -318,8 +318,8 @@ Handle(XCAFKinematics_PairObject) XCAFDoc_KinematicPair::GetObject() const aDefObject->SetCurve(BRep_Tool::Curve(anEdge, aFirst, aLast)); } } - if (anObject->Type() == XCAFKinematics_PairType_SlidingCurve || - anObject->Type() == XCAFKinematics_PairType_RollingCurve) + if (anObject->Type() >= XCAFKinematics_PairType_SlidingCurve && + anObject->Type() <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) { if (Label().FindChild(ChildLab_FirstGeomParam).FindAttribute(TNaming_NamedShape::GetID(), aNS)) { diff --git a/src/XCAFDoc/XCAFDoc_KinematicTool.cxx b/src/XCAFDoc/XCAFDoc_KinematicTool.cxx index 989d91b2c2..027601696f 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicTool.cxx +++ b/src/XCAFDoc/XCAFDoc_KinematicTool.cxx @@ -128,13 +128,13 @@ void XCAFDoc_KinematicTool::RemoveMechanism(const TDF_Label& theLabel) //purpose : //======================================================================= TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism, - const Standard_Boolean& IsBase) + const Standard_Boolean& isBase) { if (!IsMechanism(theMechanism)) return TDF_Label(); TDF_TagSource aTag; TDF_Label aLink = aTag.NewChild(getRootOfLinks(theMechanism)); - if (IsBase) + if (isBase) { SetBaseLink(aLink); } @@ -153,9 +153,9 @@ TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism, //======================================================================= TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism, const TDF_LabelSequence& theShapes, - const Standard_Boolean& IsBase) + const Standard_Boolean& isBase) { - TDF_Label aNewLink = AddLink(theMechanism, IsBase); + TDF_Label aNewLink = AddLink(theMechanism, isBase); if (aNewLink.IsNull() || theShapes.Length() == 0) return aNewLink; @@ -169,11 +169,11 @@ TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism, //======================================================================= TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism, const TDF_Label& theShape, - const Standard_Boolean& IsBase) + const Standard_Boolean& isBase) { TDF_LabelSequence anAuxSequence; anAuxSequence.Append(theShape); - return AddLink(theMechanism, anAuxSequence, IsBase); + return AddLink(theMechanism, anAuxSequence, isBase); } //======================================================================= @@ -224,7 +224,6 @@ Standard_Boolean XCAFDoc_KinematicTool::SetLink(const TDF_Label& theLink, //======================================================================= Standard_EXPORT Standard_Boolean XCAFDoc_KinematicTool::SetBaseLink(const TDF_Label& theLink) { - TDataStd_Name::Set(theLink, "Base"); TDF_Label aMechanism = theLink.Father().Father(); if (!IsMechanism(aMechanism)) return Standard_False; @@ -244,6 +243,7 @@ Standard_EXPORT Standard_Boolean XCAFDoc_KinematicTool::SetBaseLink(const TDF_La } } } + TDataStd_Name::Set(theLink, "Base"); TDataStd_Integer::Set(theLink, 1); } @@ -549,6 +549,19 @@ TDF_LabelSequence XCAFDoc_KinematicTool::GetStates(const TDF_Label& theMechanism return aStatesArray; } +//======================================================================= +//function : GetStateOfValue +//purpose : +//======================================================================= +TDF_Label XCAFDoc_KinematicTool::GetStateOfValue(const TDF_Label& theValue) const +{ + TDF_Label aState; + if (!IsValue(theValue)) + return aState; + aState = theValue.Father(); + return aState; +} + //======================================================================= //function : GetValuesOfState //purpose : @@ -600,7 +613,8 @@ TDF_LabelSequence XCAFDoc_KinematicTool::GetValuesOfJoint(const TDF_Label& theJo if (theJoint.FindAttribute(XCAFDoc::KinematicRefJointGUID(), aNode)) { aChildNode = aNode->First(); while (!aChildNode.IsNull()) { - aValuesArray.Append(aChildNode->Label()); + if (IsValue(aChildNode->Label())) + aValuesArray.Append(aChildNode->Label()); aChildNode = aChildNode->Next(); } } diff --git a/src/XCAFDoc/XCAFDoc_KinematicTool.hxx b/src/XCAFDoc/XCAFDoc_KinematicTool.hxx index 1719f0d848..b3aa14b69b 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicTool.hxx +++ b/src/XCAFDoc/XCAFDoc_KinematicTool.hxx @@ -63,41 +63,42 @@ public: //! Adds new empty label for link. //! \param[in] theMechanism parent mechanism - //! param[in] IsBase link is base of mechanism + //! \param[in] isBase link is base of mechanism //! \return created link label Standard_EXPORT TDF_Label AddLink(const TDF_Label& theMechanism, - const Standard_Boolean& IsBase = Standard_False); + const Standard_Boolean& isBase = Standard_False); //! Adds new label with link. - //! param[in] theMechanism parent mechanism - //! param[in] theShapes all details of link - //! param[in] IsBase link is base of mechanism + //! \param[in] theMechanism parent mechanism + //! \param[in] theShapes all details of link + //! \param[in] isBase link is base of mechanism //! \return created link label Standard_EXPORT TDF_Label AddLink(const TDF_Label& theMechanism, const TDF_LabelSequence& theShapes, - const Standard_Boolean& IsBase = Standard_False); + const Standard_Boolean& isBase = Standard_False); //! Adds new label with link. //! \param[in] theMechanism parent mechanism //! \param[in] theShape singular detail of link + //! \param[in] isBase link is base of mechanism //! \return created link label Standard_EXPORT TDF_Label AddLink(const TDF_Label& theMechanism, - const TDF_Label& theShapeĆ”, - const Standard_Boolean& IsBase = Standard_False); + const TDF_Label& theShape, + const Standard_Boolean& isBase = Standard_False); //! Checks is the given label a link //! \return the result of check Standard_EXPORT Standard_Boolean IsLink(const TDF_Label& theLink) const; //! Sets shapes references for link - //! param[in] theLink link to set shapes - //! param[in] theShapes all details of link + //! \param[in] theLink link to set shapes + //! \param[in] theShapes all details of link //! \return true in case of success, false otherwise Standard_EXPORT Standard_Boolean SetLink(const TDF_Label& theLink, const TDF_LabelSequence& theShapes); //! Sets shapes references for link - //! param[in] theLink link to set base + //! \param[in] theLink link to set base //! \return true in case of success, false otherwise Standard_EXPORT Standard_Boolean SetBaseLink(const TDF_Label& theLink); @@ -159,9 +160,14 @@ public: // Retrieves all values labels of the given state //! \param[in] theState parent state - //! \return value set + //! \return set of values Standard_EXPORT TDF_LabelSequence GetValuesOfState(const TDF_Label& theState) const; + //! Gets references to state of the given value. + //! \param[in] theValue value to get + //! \return state + Standard_EXPORT TDF_Label GetStateOfValue(const TDF_Label& theValue) const; + //! Gets references to joints of the given value. //! \param[in] theValue value to get //! \return a joint diff --git a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx index 2d1483c357..12f1830fbd 100644 --- a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx +++ b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx @@ -29,7 +29,7 @@ XCAFKinematics_HighOrderPairObject:: XCAFKinematics_HighOrderPairObject() { myLimits = NULL; - isRanged = Standard_False; + myIsRanged = Standard_False; } //======================================================================= @@ -46,7 +46,7 @@ XCAFKinematics_HighOrderPairObject(const Handle(XCAFKinematics_HighOrderPairObje myOrientation = theObj->myOrientation; myLimits = theObj->myLimits; myGeom = theObj->myGeom; - isRanged = theObj->HasLimits(); + myIsRanged = theObj->HasLimits(); } //======================================================================= @@ -87,6 +87,11 @@ void XCAFKinematics_HighOrderPairObject::SetType(const XCAFKinematics_PairType t myGeom = NCollection_Array1(1, 2); break; } + case XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve: { + myLimits = NULL; + myGeom = NCollection_Array1(1, 1); + break; + } } } @@ -112,7 +117,7 @@ void XCAFKinematics_HighOrderPairObject::SetAllLimits(const Handle(TColStd_HArra if (theLimits->Length() == aNbLimits) { myLimits = theLimits; - isRanged = Standard_True; + myIsRanged = Standard_True; } } @@ -122,7 +127,7 @@ void XCAFKinematics_HighOrderPairObject::SetAllLimits(const Handle(TColStd_HArra //======================================================================= Standard_Boolean XCAFKinematics_HighOrderPairObject::HasLimits() const { - return isRanged; + return myIsRanged; } //======================================================================= @@ -134,7 +139,7 @@ void XCAFKinematics_HighOrderPairObject::SetRotationLowLimit(const Standard_Real if (Type() == XCAFKinematics_PairType_SlidingSurface || Type() == XCAFKinematics_PairType_RollingSurface) { myLimits->ChangeValue(1) = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } } @@ -158,7 +163,7 @@ void XCAFKinematics_HighOrderPairObject::SetRotationUpperLimit(const Standard_Re if (Type() == XCAFKinematics_PairType_SlidingSurface || Type() == XCAFKinematics_PairType_RollingSurface) { myLimits->ChangeValue(2) = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } } @@ -182,7 +187,7 @@ void XCAFKinematics_HighOrderPairObject::SetLowLimitYaw(const Standard_Real theL if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface) { myLimits->ChangeValue(1) = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } } @@ -206,7 +211,7 @@ void XCAFKinematics_HighOrderPairObject::SetUpperLimitYaw(const Standard_Real th if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface) { myLimits->ChangeValue(2) = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } } @@ -230,7 +235,7 @@ void XCAFKinematics_HighOrderPairObject::SetLowLimitRoll(const Standard_Real the if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface) { myLimits->ChangeValue(3) = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } } @@ -254,7 +259,7 @@ void XCAFKinematics_HighOrderPairObject::SetUpperLimitRoll(const Standard_Real t if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface) { myLimits->ChangeValue(4) = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } } @@ -278,7 +283,7 @@ void XCAFKinematics_HighOrderPairObject::SetLowLimitPitch(const Standard_Real th if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface) { myLimits->ChangeValue(5) = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } } @@ -302,7 +307,7 @@ void XCAFKinematics_HighOrderPairObject::SetUpperLimitPitch(const Standard_Real if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface) { myLimits->ChangeValue(6) = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } } @@ -352,7 +357,7 @@ Handle(Geom_Curve) XCAFKinematics_HighOrderPairObject::Curve() const //======================================================================= void XCAFKinematics_HighOrderPairObject::SetFirstCurve(const Handle(Geom_Curve)& theCurve) { - if (Type() == XCAFKinematics_PairType_SlidingCurve || Type() == XCAFKinematics_PairType_RollingCurve) + if (Type() >= XCAFKinematics_PairType_SlidingCurve && Type() <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) myGeom.ChangeFirst() = theCurve; } @@ -362,7 +367,7 @@ void XCAFKinematics_HighOrderPairObject::SetFirstCurve(const Handle(Geom_Curve)& //======================================================================= Handle(Geom_Curve) XCAFKinematics_HighOrderPairObject::FirstCurve() const { - if (Type() == XCAFKinematics_PairType_SlidingCurve || Type() == XCAFKinematics_PairType_RollingCurve) + if (Type() >= XCAFKinematics_PairType_SlidingCurve && Type() <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) return Handle(Geom_Curve)::DownCast(myGeom.First()); return NULL; } diff --git a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx index a782f906de..286487e01c 100644 --- a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx +++ b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx @@ -36,6 +36,8 @@ DEFINE_STANDARD_HANDLE(XCAFKinematics_HighOrderPairObject, XCAFKinematics_PairOb //! - XCAFKinematics_PairType_PointOnPlanarCurve //! - XCAFKinematics_PairType_SlidingCurve //! - XCAFKinematics_PairType_RollingCurve +//! - XCAFKinematics_PairType_RollingCurve +//! - XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve class XCAFKinematics_HighOrderPairObject : public XCAFKinematics_PairObject { @@ -158,8 +160,8 @@ public: //! \return curve Standard_EXPORT Handle(Geom_Curve) SecondCurve() const; - ////! Sets curve attribute (only for PointOnCurve) - ////! \param[in] theTrimmedCurve trimmed curve + //! Sets curve attribute (only for PointOnCurve) + //! \param[in] theTrimmedCurve trimmed curve //Standard_EXPORT void SetTrimmedCurve(const Standard_Real& theTrim1, const Standard_Real& theTrim2); //! Sets trimmed curve attribute (only for PointOnCurve) @@ -170,7 +172,7 @@ public: //! \return trimmed curve Standard_EXPORT Handle(Geom_TrimmedCurve) TrimmedCurve() const; - ////! \return trimmed curve + //! \return trimmed curve //Standard_EXPORT void TrimmedCurve(Standard_Real& theTrim1,Standard_Real& theTrim2) const; //! Sets surface attribute (only for PointOnSurface) @@ -197,8 +199,8 @@ public: //! \return surface Standard_EXPORT Handle(Geom_Surface) SecondSurface() const; - ////! Sets surface attribute (only for PointOnSurface) - ////! \param[in] theTrimmedSurface trimmed surface + //! Sets surface attribute (only for PointOnSurface) + //! \param[in] theTrimmedSurface trimmed surface //Standard_EXPORT void SetTrimmedSurface(const Standard_Real& U1, const Standard_Real& U2, const Standard_Real& V1, const Standard_Real& V2); //! Sets trimmed surface attribute (only for PointOnSurface) @@ -216,7 +218,7 @@ private: Standard_Boolean myOrientation; //!< orientation Handle(TColStd_HArray1OfReal) myLimits; //!< array of limits, size depends on type NCollection_Array1 myGeom; //!< curve(s) or surface(s) attributes - Standard_Boolean isRanged; //!< flag "is limits defined" + Standard_Boolean myIsRanged; //!< flag "is limits defined" }; diff --git a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.cxx b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.cxx index 475e9ee926..1e827dbfd1 100644 --- a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.cxx +++ b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.cxx @@ -36,7 +36,7 @@ XCAFKinematics_LowOrderPairObject::XCAFKinematics_LowOrderPairObject() myMaxTranslationY = Precision::Infinite(); myMinTranslationZ = -Precision::Infinite(); myMaxTranslationZ = Precision::Infinite(); - isRanged = Standard_False; + myIsRanged = Standard_False; } //======================================================================= @@ -62,7 +62,7 @@ XCAFKinematics_LowOrderPairObject:: myMaxTranslationY = theObj->myMaxTranslationY; myMinTranslationZ = theObj->myMinTranslationZ; myMaxTranslationZ = theObj->myMaxTranslationZ; - isRanged = theObj->HasLimits(); + myIsRanged = theObj->HasLimits(); } //======================================================================= @@ -96,7 +96,7 @@ Handle(TColStd_HArray1OfReal) XCAFKinematics_LowOrderPairObject::GetAllLimits() //======================================================================= Standard_Boolean XCAFKinematics_LowOrderPairObject::HasLimits() const { - return isRanged; + return myIsRanged; } //======================================================================= @@ -119,5 +119,5 @@ void XCAFKinematics_LowOrderPairObject::SetAllLimits(const Handle(TColStd_HArray myMaxTranslationY = theLimits->Value(10); myMinTranslationZ = theLimits->Value(11); myMaxTranslationZ = theLimits->Value(12); - isRanged = Standard_True; + myIsRanged = Standard_True; } diff --git a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx index 53c961f626..6b60427aaa 100644 --- a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx +++ b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx @@ -52,7 +52,7 @@ public: void SetMinRotationX(const Standard_Real theLimit) { myMinRotationX = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } Standard_Real MinRotationX() const @@ -63,7 +63,7 @@ public: void SetMaxRotationX(const Standard_Real theLimit) { myMaxRotationX = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } Standard_Real MaxRotationX() const @@ -76,7 +76,7 @@ public: void SetMinRotationY(const Standard_Real theLimit) { myMinRotationY = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } Standard_Real MinRotationY() const @@ -87,7 +87,7 @@ public: void SetMaxRotationY(const Standard_Real theLimit) { myMaxRotationY = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } Standard_Real MaxRotationY() const @@ -100,7 +100,7 @@ public: void SetMinRotationZ(const Standard_Real theLimit) { myMinRotationZ = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } Standard_Real MinRotationZ() const @@ -111,7 +111,7 @@ public: void SetMaxRotationZ(const Standard_Real theLimit) { myMaxRotationZ = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } Standard_Real MaxRotationZ() const @@ -124,7 +124,7 @@ public: void SetMinTranslationX(const Standard_Real theLimit) { myMinTranslationX = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } Standard_Real MinTranslationX() const @@ -135,7 +135,7 @@ public: void SetMaxTranslationX(const Standard_Real theLimit) { myMaxTranslationX = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } Standard_Real MaxTranslationX() const @@ -148,7 +148,7 @@ public: void SetMinTranslationY(const Standard_Real theLimit) { myMinTranslationY = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } Standard_Real MinTranslationY() const @@ -159,7 +159,7 @@ public: void SetMaxTranslationY(const Standard_Real theLimit) { myMaxTranslationY = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } Standard_Real MaxTranslationY() const @@ -172,7 +172,7 @@ public: void SetMinTranslationZ(const Standard_Real theLimit) { myMinTranslationZ = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } Standard_Real MinTranslationZ() const @@ -183,7 +183,7 @@ public: void SetMaxTranslationZ(const Standard_Real theLimit) { myMaxTranslationZ = theLimit; - isRanged = Standard_True; + myIsRanged = Standard_True; } Standard_Real MaxTranslationZ() const @@ -229,7 +229,7 @@ private: Standard_Real myMinTranslationZ; //!< minimum value of translation in z-direction Standard_Real myMaxTranslationZ; //!< maximum value of translation in z-direction Standard_Real mySkewAngle; //!< param for universal/homokinetic pair - Standard_Boolean isRanged; //!< flag "is limits defined" + Standard_Boolean myIsRanged; //!< flag "is limits defined" }; diff --git a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.cxx b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.cxx index 149ccf09c6..0a6636e0a9 100644 --- a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.cxx +++ b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.cxx @@ -24,7 +24,7 @@ IMPLEMENT_STANDARD_RTTIEXT(XCAFKinematics_LowOrderPairObjectWithCoupling, XCAFKi XCAFKinematics_LowOrderPairObjectWithCoupling:: XCAFKinematics_LowOrderPairObjectWithCoupling() { - isRanged = Standard_False; + myIsRanged = Standard_False; myLowLimit = -Precision::Infinite(); myUpperLimit = Precision::Infinite(); myParams = NULL; @@ -41,7 +41,7 @@ XCAFKinematics_LowOrderPairObjectWithCoupling:: SetType(theObj->Type()); SetFirstTransformation(theObj->FirstTransformation()); SetSecondTransformation(theObj->SecondTransformation()); - isRanged = theObj->HasLimits(); + myIsRanged = theObj->HasLimits(); myLowLimit = theObj->LowLimit(); myUpperLimit = theObj->UpperLimit(); myParams = theObj->GetAllParams(); @@ -102,7 +102,7 @@ Standard_Real XCAFKinematics_LowOrderPairObjectWithCoupling::Pitch() const //======================================================================= void XCAFKinematics_LowOrderPairObjectWithCoupling::SetPinionRadius(const Standard_Real theRadius) { - if (Type() == XCAFKinematics_PairType_RackAndPinion) + if (Type() == XCAFKinematics_PairType_RackAndPinion || Type() == XCAFKinematics_PairType_LinearFlexibleAndPinion) myParams->ChangeFirst() = theRadius; } @@ -112,7 +112,7 @@ void XCAFKinematics_LowOrderPairObjectWithCoupling::SetPinionRadius(const Standa //======================================================================= Standard_Real XCAFKinematics_LowOrderPairObjectWithCoupling::PinionRadius() const { - if (Type() == XCAFKinematics_PairType_RackAndPinion) + if (Type() == XCAFKinematics_PairType_RackAndPinion || Type() == XCAFKinematics_PairType_LinearFlexibleAndPinion) return myParams->First(); return 0; } @@ -238,7 +238,7 @@ void XCAFKinematics_LowOrderPairObjectWithCoupling::SetAllParams(const Handle(TC //======================================================================= Standard_Boolean XCAFKinematics_LowOrderPairObjectWithCoupling::HasLimits() const { - return isRanged; + return myIsRanged; } //======================================================================= @@ -249,7 +249,7 @@ void XCAFKinematics_LowOrderPairObjectWithCoupling::SetAllLimits(const Handle(TC { if (theLimits->Length() == 2) { - isRanged = Standard_True; + myIsRanged = Standard_True; myLowLimit = theLimits->Value(1); myUpperLimit = theLimits->Value(2); } diff --git a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx index 5877263215..62d4c73a07 100644 --- a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx +++ b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx @@ -41,7 +41,7 @@ public: void SetLowLimit(const Standard_Real theLimit) { - isRanged = Standard_True; + myIsRanged = Standard_True; myLowLimit = theLimit; } @@ -52,7 +52,7 @@ public: void SetUpperLimit(const Standard_Real theLimit) { - isRanged = Standard_True; + myIsRanged = Standard_True; myUpperLimit = theLimit; } @@ -141,7 +141,7 @@ private: Standard_Real myLowLimit; //!< low limit of motion range Standard_Real myUpperLimit; //!< upper limit of motion range Handle(TColStd_HArray1OfReal) myParams; //!< additional parameters of kinematic pair - Standard_Boolean isRanged; //!< flag "is limits defined" + Standard_Boolean myIsRanged; //!< flag "is limits defined" }; diff --git a/src/XDEDRAW/XDEDRAW_Kinematics.cxx b/src/XDEDRAW/XDEDRAW_Kinematics.cxx index fb690a7f3c..18b165a9a2 100644 --- a/src/XDEDRAW/XDEDRAW_Kinematics.cxx +++ b/src/XDEDRAW/XDEDRAW_Kinematics.cxx @@ -175,9 +175,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"); + Standard_Boolean isBase = argc >= 4 && TCollection_AsciiString(argv[3]).IsEqual("-base"); TDF_LabelSequence aShapeArray; - for (Standard_Integer i = (IsBase) ? 4 : 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; @@ -185,7 +185,7 @@ 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, IsBase)); + di << getEntry(aTool->AddLink(aMechanism, aShapeArray, isBase)); return 0; } @@ -961,6 +961,7 @@ static Standard_Integer getParameters(Draw_Interpretor& di, Standard_Integer arg di << "Pitch = " << anObject->Pitch(); break; case XCAFKinematics_PairType_RackAndPinion: + case XCAFKinematics_PairType_LinearFlexibleAndPinion: di << "Pinion Radius = " << anObject->PinionRadius(); break; case XCAFKinematics_PairType_Gear: @@ -1539,6 +1540,106 @@ static Standard_Integer getValues(Draw_Interpretor& di, Standard_Integer argc, c return 0; } +//======================================================================= +//function : dump +//purpose : +//======================================================================= +static Standard_Integer dump(Draw_Interpretor& di, Standard_Integer argc, const char** argv) +{ + if (argc < 2) { + di << "Use: XDumpKinematics Doc\n"; + return 1; + } + Handle(TDocStd_Document) aDoc; + DDocStd::GetDocument(argv[1], aDoc); + if (aDoc.IsNull()) { + di << argv[1] << " is not a document\n"; + return 1; + } + Handle(XCAFDoc_KinematicTool) aKTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); + + TDF_LabelSequence aMechanisms = aKTool->GetMechanisms(); + + di << "\n NbOfMechanisms : ( " << aMechanisms.Length()<<" )"; + Standard_Integer nbLinks = 0, + nbRefShapes = 0, + nbHigeOrderPairs = 0, + nbLowOrderPairsWithMotionCoupling = 0, + nbLowOrderPairs = 0, + nbHigeOrderPairsWithRange = 0, + nbLowOrderPairsWithMotionCouplingAndRange = 0, + nbLowOrderPairsWithRange = 0, + nbStates = 0, + nbHigeOrderPairValues = 0, + nbLowOrderPairWithMotionCouplingValues = 0, + nbLowOrderPairValues = 0; + + for (Standard_Integer aMechInd = 1; aMechInd <= aMechanisms.Length(); ++aMechInd) + { + TDF_Label aMechanism = aMechanisms.Value(aMechInd); + TDF_LabelSequence aLinks = aKTool->GetLinks(aMechanism); + nbLinks += aLinks.Length(); + for (Standard_Integer aLinkInd = 1; aLinkInd <= nbLinks; ++aLinkInd) + nbRefShapes += aKTool->GetRefShapes(aLinks.Value(aLinkInd)).Length(); + TDF_LabelSequence aJoints = aKTool->GetJoints(aMechanism); + for (Standard_Integer aJointInd = 1; aJointInd <= aJoints.Length(); ++aJointInd) + { + Handle(XCAFDoc_KinematicPair) aKinAttr; + if (!aJoints.Value(aJointInd).FindAttribute(XCAFDoc_KinematicPair::GetID(), aKinAttr)) + continue; + Handle(XCAFKinematics_PairObject) anObject = aKinAttr->GetObject(); + if (anObject.IsNull()) + continue; + XCAFKinematics_PairType aKinType = anObject->Type(); + if (aKinType >= XCAFKinematics_PairType_FullyConstrained && + aKinType <= XCAFKinematics_PairType_Unconstrained) + { + if (anObject->HasLimits()) + nbLowOrderPairsWithRange++; + else + nbLowOrderPairs++; + nbLowOrderPairValues += aKTool->GetValuesOfJoint(aJoints.Value(aJointInd)).Length(); + } + else if (aKinType >= XCAFKinematics_PairType_Screw && + aKinType <= XCAFKinematics_PairType_LinearFlexibleAndPinion) + { + if (anObject->HasLimits()) + nbLowOrderPairsWithMotionCouplingAndRange++; + else + nbLowOrderPairsWithMotionCoupling++; + nbLowOrderPairWithMotionCouplingValues += aKTool->GetValuesOfJoint(aJoints.Value(aJointInd)).Length(); + } + else if (aKinType >= XCAFKinematics_PairType_PointOnSurface && + aKinType <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) + { + if (anObject->HasLimits()) + nbHigeOrderPairsWithRange++; + else + nbHigeOrderPairs++; + nbHigeOrderPairValues += aKTool->GetValuesOfJoint(aJoints.Value(aJointInd)).Length(); + } + } + nbStates += aKTool->GetStates(aMechanism).Length(); + } + di << "\n NbOfKinematicLinks : ( " << nbLinks <<" )"; + di << "\n NbOfRefShapes : ( " << nbRefShapes << " )"; + di << "\n KinematicPairsWithoutRange : "; + di << " NbOfLowOrderPairs ( " << nbLowOrderPairs << " )"; + di << " NbOfLowOrderPairsWithMotionCoupling ( " << nbLowOrderPairsWithMotionCoupling << " )"; + di << " NbOfHightOrderPairs ( " << nbHigeOrderPairs << " )"; + di << "\n KinematicPairsWithRange : "; + di << " NbOfLowOrderPairs ( " << nbLowOrderPairsWithRange << " )"; + di << " NbOfLowOrderPairsWithMotionCoupling ( " << nbLowOrderPairsWithMotionCouplingAndRange << " )"; + di << " NbOfHightOrderPairs ( " << nbHigeOrderPairsWithRange << " )"; + di << "\n NbOfStates : ( " << nbStates << " )"; + di << "\n KinematicValues : "; + di << " NbOfLowOrderPairs ( " << nbLowOrderPairValues << " )"; + di << " NbOfLowOrderPairsWithMotionCoupling ( " << nbLowOrderPairWithMotionCouplingValues << " )"; + di << " NbOfHightOrderPairs ( " << nbHigeOrderPairValues << " )"; + return 0; +} + + //======================================================================= //function : InitCommands //purpose : @@ -1638,6 +1739,7 @@ void XDEDRAW_Kinematics::InitCommands(Draw_Interpretor& di) "\t 18 PointOnPlanarCurve\n" "\t 19 SlidingCurve\n" "\t 20 RollingCurve\n" + "\t 21 LinearFlexibleAndPlanarCurve\n" __FILE__, setType, g); di.Add("XGetPairType", "XGetPairType Doc Joint", @@ -1709,4 +1811,7 @@ void XDEDRAW_Kinematics::InitCommands(Draw_Interpretor& di) "\t-ypr - current yaw pitch roll angles - 3 numbers" "\t-trsf - for unconstrained only current location direction xdirection - 9 numbers", __FILE__, getValues, g); + + di.Add("XDumpKinematics", "XDumpKinematics Doc", + __FILE__, dump, g); } diff --git a/tests/gdt/grids.list b/tests/gdt/grids.list index ca36186f16..3bc4c9aed2 100644 --- a/tests/gdt/grids.list +++ b/tests/gdt/grids.list @@ -6,3 +6,4 @@ 006 view 007 notes 008 kinematics +009 kinematics_export diff --git a/tests/gdt/kinematics/A1 b/tests/gdt/kinematics/A1 index fb3257f8eb..a9db18cf0f 100644 --- a/tests/gdt/kinematics/A1 +++ b/tests/gdt/kinematics/A1 @@ -2,9 +2,9 @@ # Test scenario for kinematics #============================== -# ReadStep D [locate_data_file as1-oc-214.stp] + ReadStep D [locate_data_file as1-oc-214.stp] # Load document with shape structure -ReadStep D C:/Work/files/as1.stp +# ReadStep D C:/Work/files/as1.stp # Add parent mechanism set mech [XAddMechanism D] diff --git a/tests/gdt/kinematics/C2 b/tests/gdt/kinematics/C2 new file mode 100644 index 0000000000..4b8b580173 --- /dev/null +++ b/tests/gdt/kinematics/C2 @@ -0,0 +1,49 @@ +# Rolling curve pair + +# Prepare a document +XNewDoc D +box b 1 1 1 +box bb 2 0 0 1 1 1 +XAddShape D b +XAddShape D bb +set mech [XAddMechanism D] +set link1 [XAddLink D $mech 0:1:1:1] +set link2 [XAddLink D $mech 0:1:1:2] +set joint [XAddJoint D $mech $link1 $link2] + +# Start testing +XSetPairName D $joint linear flexible and pinion +set name [XGetPairName D $joint] +if {$name != "linear flexible and pinion"} { + puts "Error: wrong parameter" +} +XSetPairType D $joint 14 +set type [XGetPairType D $joint] +if {$type != "14"} { + puts "Error: wrong parameter" +} + +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 +XSetPairTransformation D $joint 1 p1 +XSetPairTransformation D $joint 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" +} + +XSetPairParams D $joint 3 +set param [XGetPairParams D $joint] +if {$param != "Pinion Radius = 3"} { + puts "Error: wrong parameter" +} + +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/C3 b/tests/gdt/kinematics/C3 new file mode 100644 index 0000000000..327c187f34 --- /dev/null +++ b/tests/gdt/kinematics/C3 @@ -0,0 +1,58 @@ +# Rolling curve pair + +# Prepare a document +XNewDoc D +box b 1 1 1 +box bb 2 0 0 1 1 1 +XAddShape D b +XAddShape D bb +set mech [XAddMechanism D] +set link1 [XAddLink D $mech 0:1:1:1] +set link2 [XAddLink D $mech 0:1:1:2] +set joint [XAddJoint D $mech $link1 $link2] + +# Start testing +XSetPairName D $joint linear flexible and planar curve +set name [XGetPairName D $joint] +if {$name != "linear flexible and planar curve"} { + puts "Error: wrong parameter" +} +XSetPairType D $joint 21 +set type [XGetPairType D $joint] +if {$type != "21"} { + puts "Error: wrong parameter" +} + +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 +XSetPairTransformation D $joint 1 p1 +XSetPairTransformation D $joint 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" +} + +circle cir1 4 4 4 1 +XSetPairGeomParam D $joint 1 cir1 +set dump_in [dump cir1] +XGetPairGeomParam D $joint 1 cir1 +set dump_out [dump cir1] +if {$dump_in != $dump_out} { + puts "Error: wrong parameter" +} + +XSetPairOrientation D $joint 1 +set ori [XGetPairOrientation D $joint] +if {$ori != 1} { + puts "Error: wrong parameter" +} + +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics_export/A1 b/tests/gdt/kinematics_export/A1 new file mode 100644 index 0000000000..7bbf95c9b8 --- /dev/null +++ b/tests/gdt/kinematics_export/A1 @@ -0,0 +1,13 @@ +# !!!! This file is generated automatically, do not edit manually! See end script +set filename chuck_3_jaw_AP242_v2.stp + +set ref_data { + + NbOfMechanisms : ( 1 ) + NbOfKinematicLinks : ( 4 ) + NbOfRefShapes : ( 4 ) + KinematicPairsWithoutRange : NbOfLowOrderPairs ( 0 ) NbOfLowOrderPairsWithMotionCoupling ( 0 ) NbOfHightOrderPairs ( 0 ) + KinematicPairsWithRange : NbOfLowOrderPairs ( 3 ) NbOfLowOrderPairsWithMotionCoupling ( 0 ) NbOfHightOrderPairs ( 0 ) + NbOfStates : ( 2 ) + KinematicValues : NbOfLowOrderPairs ( 6 ) NbOfLowOrderPairsWithMotionCoupling ( 0 ) NbOfHightOrderPairs ( 0 ) +} diff --git a/tests/gdt/kinematics_export/A2 b/tests/gdt/kinematics_export/A2 new file mode 100644 index 0000000000..7a3daec194 --- /dev/null +++ b/tests/gdt/kinematics_export/A2 @@ -0,0 +1,13 @@ +# !!!! This file is generated automatically, do not edit manually! See end script +set filename mazak_kinematic_v3.stp + +set ref_data { + + NbOfMechanisms : ( 1 ) + NbOfKinematicLinks : ( 8 ) + NbOfRefShapes : ( 8 ) + KinematicPairsWithoutRange : NbOfLowOrderPairs ( 2 ) NbOfLowOrderPairsWithMotionCoupling ( 0 ) NbOfHightOrderPairs ( 0 ) + KinematicPairsWithRange : NbOfLowOrderPairs ( 5 ) NbOfLowOrderPairsWithMotionCoupling ( 0 ) NbOfHightOrderPairs ( 0 ) + NbOfStates : ( 10 ) + KinematicValues : NbOfLowOrderPairs ( 15 ) NbOfLowOrderPairsWithMotionCoupling ( 0 ) NbOfHightOrderPairs ( 0 ) +} diff --git a/tests/gdt/kinematics_export/begin b/tests/gdt/kinematics_export/begin new file mode 100644 index 0000000000..e633456cf3 --- /dev/null +++ b/tests/gdt/kinematics_export/begin @@ -0,0 +1 @@ +NewDocument D diff --git a/tests/gdt/kinematics_export/end b/tests/gdt/kinematics_export/end new file mode 100644 index 0000000000..6d8d5dca7c --- /dev/null +++ b/tests/gdt/kinematics_export/end @@ -0,0 +1,185 @@ +# Set flag dump_file to 1 in order to regenerate script files with actual data +# used as reference. In this mode all tests intentionaly report failure. +set dump_file 0 +######################################################################## +set mist 0; +# Kinematic Mechanism +set nbMechanism_First 0; set nbMechanism_Second 0; +# Kinematic Links +set nbLink_First 0; set nbLink_Second 0; +set nbRefShape_First 0; set nbRefShape_Second 0; +# Kinematic Pairs +set nbLowPair_First 0; set nbLowPair_Second 0; +set nbLowPairWthMotCoupl_First 0; set nbLowPairWthMotCoupl_Second 0; +set nbHighPair_First 0; set nbHighPair_Second 0; +set nbLowPairWthRng_First 0; set nbLowPairWthRng_Second 0; +set nbLowPairWthMotCouplAndRng_First 0; set nbLowPairWthMotCouplAndRng_Second 0; +set nbHighPairWthRng_First 0; set nbHighPairWthRange_Second 0; +# Kinematic States +set nbState_First 0; set nbState_Second 0; +# Kinematic Values +set nbLowPairVls_First 0; set nbLowPairVls_Second 0; +set nbLowPairWthMotCouplVls_First 0; set nbLowPairWthMotCouplVls_Second 0; +set nbHighPairVls_First 0; set nbHighPairVls_Second 0; +################################################################### +set ref_Compare 0 +set todo_msg "" +set todo_mask "puts \"TODO CR31388 ALL: " +set end_line "\" \n" +################################################################## + +# Read original file +if { [string length $filename] > 1} { + set path_file [locate_data_file $filename] + if { [catch { ReadStep D_First $path_file } catch_result] } { + set err_msg "Error: First - file was not read - exception " + puts $err_msg + append todo_msg $todo_mask $err_msg $end_line + set mist 1 + } +} else { + set mist 1 +} + +# Get information about kinematics +if { $mist < 1} { + puts "" + set xst [ XDumpKinematics D_First] + + if { [llength $xst] > 0 } { + regexp {NbOfMechanisms +: +[(] +([-0-9.+eE]+) +[)]} $xst full nbMechanism_First + regexp {NbOfKinematicLinks +: +[(] +([-0-9.+eE]+) +[)]} $xst full nbLink_First + regexp {NbOfRefShapes +: +[(] +([-0-9.+eE]+) +[)]} $xst full nbRefShape_First + regexp {KinematicPairsWithoutRange +: +NbOfLowOrderPairs +[(] +([-0-9.+eE]+) +[)] +NbOfLowOrderPairsWithMotionCoupling +[(] +([-0-9.+eE]+) +[)] +NbOfHightOrderPairs +[(] +([-0-9.+eE]+) +[)]} $xst full nbLowPair_First nbLowPairWthMotCoupl_First nbHighPair_First + regexp {KinematicPairsWithRange +: +NbOfLowOrderPairs +[(] +([-0-9.+eE]+) +[)] +NbOfLowOrderPairsWithMotionCoupling +[(] +([-0-9.+eE]+) +[)] +NbOfHightOrderPairs +[(] +([-0-9.+eE]+) +[)]} $xst full nbLowPairWthRng_First nbLowPairWthMotCouplAndRng_First nbHighPairWthRng_First + regexp {NbOfStates +: +[(] +([-0-9.+eE]+) +[)]} $xst full nbState_First + regexp {KinematicValues +: +NbOfLowOrderPairs +[(] +([-0-9.+eE]+) +[)] +NbOfLowOrderPairsWithMotionCoupling +[(] +([-0-9.+eE]+) +[)] +NbOfHightOrderPairs +[(] +([-0-9.+eE]+) +[)]} $xst full nbLowPairVls_First nbLowPairWthMotCouplVls_First nbHighPairVls_First + } else { + puts " Kinematics information was NOT provided" + } +} + +if { $mist != 1 } { + puts "" + set result "" + append result [format $xst] +} + +# Writing file +if { $mist < 1} { + puts " " + puts "-----------------------------WRITING FILE ------------------------------" + if { [catch { WriteStep D_First $imagedir/${casename}_D_First.stp } catch_result] } { + set err_msg "Error: First - file was not written - exception" + puts $err_msg + append todo_msg $todo_mask $err_msg $end_line + set mist 1 + } + if { $mist < 1 } { + if { [catch { ReadStep D_Second $imagedir/${casename}_D_First.stp } catch_result] } { + set err_msg "Error: Second - file was not read - exception" + puts $err_msg + append todo_msg $todo_mask $err_msg $end_line + set mist 1 + } + } +} + +catch {[file delete $imagedir/${casename}_D_First.stp]} +if { [catch { Close D_First } catch_result] } { + set err_msg "Error : cannot close a document D_First - exception" + puts $err_msg +} + +# Get information about kinematics +if { $mist < 1} { + puts "" + set xst2 [ XDumpKinematics D_Second] + + if { [llength $xst2] > 0 } { + regexp {NbOfMechanisms +: +[(] +([-0-9.+eE]+) +[)]} $xst2 full nbMechanism_Second + regexp {NbOfKinematicLinks +: +[(] +([-0-9.+eE]+) +[)]} $xst2 full nbLink_Second + regexp {NbOfRefShapes +: +[(] +([-0-9.+eE]+) +[)]} $xst2 full nbRefShape_Secondt + regexp {KinematicPairsWithoutRange +: +NbOfLowOrderPairs +[(] +([-0-9.+eE]+) +[)] +NbOfLowOrderPairsWithMotionCoupling +[(] +([-0-9.+eE]+) +[)] +NbOfHightOrderPairs +[(] +([-0-9.+eE]+) +[)]} $xst2 full nbLowPair_Second nbLowPairWthMotCoupl_Second nbHighPair_Second + regexp {KinematicPairsWithRange +: +NbOfLowOrderPairs +[(] +([-0-9.+eE]+) +[)] +NbOfLowOrderPairsWithMotionCoupling +[(] +([-0-9.+eE]+) +[)] +NbOfHightOrderPairs +[(] +([-0-9.+eE]+) +[)]} $xst2 full nbLowPairWthRng_Second nbLowPairWthMotCouplAndRng_Second nbHighPairWthRng__Second + regexp {NbOfStates +: +[(] +([-0-9.+eE]+) +[)]} $xst2 full nbState_Second + regexp {KinematicValues +: +NbOfLowOrderPairs +[(] +([-0-9.+eE]+) +[)] +NbOfLowOrderPairsWithMotionCoupling +[(] +([-0-9.+eE]+) +[)] +NbOfHightOrderPairs +[(] +([-0-9.+eE]+) +[)]} $xst2 full nbLowPairVls_Second nbLowPairWthMotCouplVls_Second nbHighPairVls_Second + } else { + puts " Kinematics information was NOT provided" + } + if { [catch { Close D_Second } catch_result] } { + set err_msg "Error : cannot close a document D_Second - exception" + puts $err_msg + } +} + +if { $mist != 1 } { + puts "" + set result2 "" + append result2 [format $xst2] +} +set err_compare_ref "" +# Put reference data to the test script file if option "dump" is set +if { $dump_file == 1 } { + set fd_stream [open $dirname/$groupname/$gridname/$casename w] + puts $fd_stream "# !!!! This file is generated automatically, do not edit manually! See end script" + puts $fd_stream "set filename $filename" + if { $mist != 1 } { + puts $fd_stream "" + puts $fd_stream "set ref_data \{" + puts $fd_stream $result + puts $fd_stream "\}" + } + close $fd_stream +} elseif { $mist != 1 } { + puts "========================== Comparision with reference data ========" + puts "" + # Comparision of reference data with obtained result + set ref_list [split $ref_data \n] + set cur_list [split $result \n] + set cur2_list [split $result2 \n] + set nb_ref [llength $ref_list] + for { set i 0 } { $i < $nb_ref } { incr i } { + set j [expr $i +1] + set refstr [lindex $ref_list $j] + set curstr [lindex $cur_list $i] + set cur2str [lindex $cur2_list $i] + set isOK 1; + + if {[string equal $refstr $curstr] == 0} { + set isOK 0 + } + + if {[string equal $curstr $cur2str] == 0} { + set isOK 0 + } + + if { $isOK == 0} { + incr ref_Compare + append err_compare_ref " Reference data - $refstr\n" + append err_compare_ref " Current data - $curstr\n" + append err_compare_ref " Current data after writing - $cur2str\n" + append err_compare_ref "--------------------------------------------------------------------\n" + } + } +} + +if { $dump_file != 0 } { + puts "Error : Running in regeneration mode, comparision was not performed!" + if { $mist != 1 } { + puts "Generation of test file $groupname/$gridname/$casename successful" + } else { + puts "Generation of reference data failed" + } +} else { + if { $ref_Compare > 0} { + puts "Error : $ref_Compare differences with reference data found :\n$err_compare_ref" + } else { + puts "Comparision of current result with reference data - OK\n" + } +} + +puts "--------------------------------------------------------------------" +puts "" + +puts "TEST COMPLETED" -- 2.39.5