From e814fcc0c463f632af093fd5ec3e7a8d7a603c85 Mon Sep 17 00:00:00 2001 From: dpasukhi Date: Fri, 31 Jul 2020 00:59:13 +0300 Subject: [PATCH] 0031388: Data Exchange - support kinematics data in STEP format # add support for multiple reference shapes for kinematic link # fix lost reference joint of kinematic value # fix unsupported adding geom params for linear pair # fix useless check conditions in the XDRAW_Kinematics --- src/STEPCAFControl/STEPCAFControl_Reader.cxx | 67 +-- src/STEPCAFControl/STEPCAFControl_Writer.cxx | 211 +++++----- src/StepToGeom/StepToGeom.cxx | 369 ++++++++--------- src/XCAFDoc/XCAFDoc.cxx | 4 + src/XCAFDoc/XCAFDoc_KinematicPair.cxx | 18 +- src/XCAFDoc/XCAFDoc_KinematicPairValue.cxx | 8 +- src/XCAFDoc/XCAFDoc_KinematicPairValue.hxx | 5 +- src/XCAFDoc/XCAFDoc_KinematicTool.cxx | 54 ++- src/XCAFDoc/XCAFDoc_KinematicTool.hxx | 4 + .../XCAFKinematics_HighOrderPairObject.hxx | 20 +- .../XCAFKinematics_LowOrderPairObject.hxx | 27 +- .../XCAFKinematics_PairValueObject.cxx | 4 +- src/XDEDRAW/XDEDRAW.cxx | 3 + src/XDEDRAW/XDEDRAW_Kinematics.cxx | 383 +++++++++--------- tests/gdt/kinematics/A1 | 3 +- .../gdt/kinematics_export/{A1 => bug31388_1} | 2 +- .../gdt/kinematics_export/{A2 => bug31388_2} | 2 +- tests/gdt/kinematics_export/end | 2 +- 18 files changed, 582 insertions(+), 604 deletions(-) rename tests/gdt/kinematics_export/{A1 => bug31388_1} (94%) rename tests/gdt/kinematics_export/{A2 => bug31388_2} (94%) diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index 3567d4cde2..fa7192968a 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -4318,13 +4318,13 @@ void collectViewShapes(const Handle(XSControl_WorkSession)& theWS, //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) + 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(); @@ -4337,33 +4337,34 @@ Standard_Boolean addLinkWithShapes(const Handle(XSControl_WorkSession)& theWS, return Standard_True; Handle(StepKinematics_KinematicLinkRepresentationAssociation) aKLRA1; for (Interface_EntityIterator anIterLinks = aGraph.Sharings(theLinkRepresentation); - anIterLinks.More() && aKLRA1.IsNull(); anIterLinks.Next()) - { + anIterLinks.More(); anIterLinks.Next()) { aKLRA1 = Handle(StepKinematics_KinematicLinkRepresentationAssociation)::DownCast(anIterLinks.Value()); + if (aKLRA1.IsNull()) + continue; + + Handle(StepKinematics_ContextDependentKinematicLinkRepresentation) aCDKLR; + Interface_EntityIterator entIt = aGraph.Sharings(aKLRA1); + for (entIt.Start(); entIt.More() & aCDKLR.IsNull(); entIt.Next()) + { + aCDKLR = Handle(StepKinematics_ContextDependentKinematicLinkRepresentation)::DownCast(entIt.Value()); + } + if (aCDKLR.IsNull()) + continue; + Handle(StepRepr_PropertyDefinition) aPD = + Handle(StepRepr_PropertyDefinition)::DownCast(aCDKLR->RepresentedProductRelation()); + if (aPD.IsNull()) + continue; + TDF_Label aShapeLabel; + Handle(Transfer_Binder) binder = aTP->Find(aPD->Definition().Value()); + TopoDS_Shape aShape = TransferBRep::ShapeResult(aTP, binder); + if (aShape.IsNull()) + continue; + if (theMap.IsBound(aShape)) + aShapes.Append(theMap(aShape)); + else if (aSTool->Search(aShape, aShapeLabel)) + aShapes.Append(aShapeLabel); } - if (aKLRA1.IsNull()) - return Standard_False; - Handle(StepKinematics_ContextDependentKinematicLinkRepresentation) aCDKLR; - Interface_EntityIterator entIt = aGraph.Sharings(aKLRA1); - for (entIt.Start(); entIt.More() & aCDKLR.IsNull(); entIt.Next()) - { - aCDKLR = Handle(StepKinematics_ContextDependentKinematicLinkRepresentation)::DownCast(entIt.Value()); - } - 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 (theMap.IsBound(aShape)) - aShapeLabel = theMap(aShape); - else - aSTool->Search(aShape, aShapeLabel, Standard_True, Standard_True, Standard_True); - aShapes.Append(aShapeLabel); - if (aShapes.Length() == 0) + if (aShapes.IsEmpty()) return Standard_False; theLink = aKTool->AddLink(theMechanism, aShapes, theIsBase); @@ -4719,7 +4720,7 @@ Handle(XCAFKinematics_PairObject) createXCAFKinematicPairObject(const Handle(Ste } //======================================================================= -//function : setPairValue +//function : setKinematicPairValue //purpose : set pair Value of the kinematic pair in OCAF //======================================================================= Standard_Boolean setKinematicPairValue(const Handle(XSControl_WorkSession)& theWS, diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index 6aa1ee7d8e..87b6f372be 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -2194,44 +2194,33 @@ Standard_Boolean STEPCAFControl_Writer::WriteSHUOs (const Handle(XSControl_WorkS //function : createKinematicLink //purpose : auxilary //======================================================================= -static Standard_Boolean createKinematicLink(const Handle(Transfer_FinderProcess)& FP, +static Standard_Boolean createKinematicLink(const Handle(XSControl_WorkSession)& theWS, const Handle(XCAFDoc_KinematicTool)& theKTool, const Interface_Graph& theGraph, - const TDF_Label& theLabelLink, - Handle(StepKinematics_KinematicLinkRepresentation)& theLinkRepresentation, - Handle(StepKinematics_KinematicLink)& theLink, - Handle(StepShape_ShapeRepresentation)& theShapeRepr, - Handle(StepRepr_PropertyDefinition)& thePDS) + const TDF_Label& theLabelLink, + NCollection_IndexedDataMap& theMapOfLinks, + Handle(StepKinematics_RigidLinkRepresentation)& theBaseLink, + Handle(StepRepr_PropertyDefinition)& theGeneralPD) { - theLink = new StepKinematics_KinematicLink; + const Handle(Interface_InterfaceModel)& Model = theWS->Model(); + const Handle(XSControl_TransferWriter)& TW = theWS->TransferWriter(); + const Handle(Transfer_FinderProcess)& FP = TW->FinderProcess(); + Handle(StepKinematics_KinematicLink) aLink = new StepKinematics_KinematicLink; 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 = theKTool->GetRefShapes(theLabelLink); - if (aShapesStartL.IsEmpty()) return Standard_False; - TopoDS_Shape aTopoShapeStart = XCAFDoc_ShapeTool::GetShape(aShapesStartL.Value(1)); - TopLoc_Location aLocStart; - TColStd_SequenceOfTransient seqRI; - FindEntities(FP, aTopoShapeStart, aLocStart, seqRI); - if (seqRI.Length() <= 0) { - FP->Messenger()->SendInfo() << "Warning: Cannot find RI for " << aTopoShapeStart.TShape()->DynamicType()->Name() << std::endl; - return Standard_False; - } + aLink->Init(aHNameLink); //Choose type of the representation link + Handle(StepKinematics_KinematicLinkRepresentation) aLinkRepr; TDF_LabelSequence aJoints = theKTool->GetJointsOfLink(theLabelLink,Standard_True,Standard_False); Standard_Boolean isLinear = Standard_False; - for (Standard_Integer anIndOfJoint = 1; anIndOfJoint <= aJoints.Length(); ++anIndOfJoint) + for (TDF_LabelSequence::Iterator anItJoint(aJoints); anItJoint.More(); anItJoint.Next()) { Handle(XCAFDoc_KinematicPair) aKPairAttr; - if (!aJoints(anIndOfJoint).FindAttribute(XCAFDoc_KinematicPair::GetID(), aKPairAttr)) + if (!anItJoint.Value().FindAttribute(XCAFDoc_KinematicPair::GetID(), aKPairAttr)) continue; Handle(XCAFKinematics_PairObject) aPairObject = aKPairAttr->GetObject(); if (aPairObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPinion || @@ -2241,28 +2230,74 @@ static Standard_Boolean createKinematicLink(const Handle(Transfer_FinderProcess) return Standard_False; } if (isLinear) - theLinkRepresentation = new StepKinematics_LinearFlexibleLinkRepresentation; + aLinkRepr = new StepKinematics_LinearFlexibleLinkRepresentation; else - theLinkRepresentation = new StepKinematics_RigidLinkRepresentation; + aLinkRepr = new StepKinematics_RigidLinkRepresentation; - // get PDS of Shape - 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()) + Model->AddEntity(aLink); + Model->AddEntity(aLinkRepr); + + // find ref shapes + TDF_LabelSequence aShapesL = theKTool->GetRefShapes(theLabelLink); + if (aShapesL.IsEmpty()) + return Standard_False; + for (TDF_LabelSequence::Iterator anItShapes(aShapesL); anItShapes.More(); anItShapes.Next()) { + TopoDS_Shape aTopoShape = XCAFDoc_ShapeTool::GetShape(anItShapes.Value()); + TopLoc_Location aLoc; + TColStd_SequenceOfTransient seqRI; + FindEntities(FP, aTopoShape, aLoc, seqRI); + if (seqRI.Length() <= 0) { + FP->Messenger()->SendInfo() << "Warning: Cannot find RI for " << aTopoShape.TShape()->DynamicType()->Name() << std::endl; continue; - 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; - thePDS = aSDR->Definition().PropertyDefinition(); - if (!thePDS.IsNull()) - return Standard_True; } + + // get PDS of Shape + Handle(StepShape_ShapeRepresentation) aShapeRepr; + Handle(StepRepr_PropertyDefinition) aPD; + Interface_EntityIterator anItRI = theGraph.Sharings(seqRI.Value(1)); + for (anItRI.Start(); anItRI.More() && aPD.IsNull(); anItRI.Next()) { + aShapeRepr = Handle(StepShape_ShapeRepresentation)::DownCast(anItRI.Value()); + if (aShapeRepr.IsNull()) + continue; + Interface_EntityIterator aSDRIt = theGraph.Sharings(aShapeRepr); + for (aSDRIt.Start(); aSDRIt.More() && aPD.IsNull(); aSDRIt.Next()) { + Handle(StepShape_ShapeDefinitionRepresentation) aSDR = + Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aSDRIt.Value()); + if (aSDR.IsNull()) continue; + aPD = aSDR->Definition().PropertyDefinition(); + } + } + if (aPD.IsNull()) + return Standard_False; + Handle(StepRepr_RepresentationContext) aRepresentationContextOfLink = aShapeRepr->ContextOfItems(); + + Handle(TCollection_HAsciiString) aNameOfLinkRepr = new TCollection_HAsciiString(""); + Handle(StepRepr_HArray1OfRepresentationItem) aPlacementsOfPairs = new StepRepr_HArray1OfRepresentationItem(); + aLinkRepr->Init(aNameOfLinkRepr, aPlacementsOfPairs, aRepresentationContextOfLink, aLink); + theMapOfLinks.Add(theLabelLink, aLinkRepr); + + if (theGeneralPD.IsNull() && !isLinear) + theGeneralPD = aPD; + + Handle(TDataStd_Integer) aBase; + if (theBaseLink.IsNull() && theLabelLink.FindAttribute(TDataStd_Integer::GetID(), aBase)) { + theGeneralPD = aPD; + theBaseLink = Handle(StepKinematics_RigidLinkRepresentation)::DownCast(aLinkRepr); + } + + Handle(StepKinematics_KinematicLinkRepresentationAssociation) aLinkRepresentationAssociation = new StepKinematics_KinematicLinkRepresentationAssociation; + aLinkRepresentationAssociation->Init(aNameOfLinkRepr, aNameOfLinkRepr, aLinkRepr, aShapeRepr); + Handle(StepKinematics_ContextDependentKinematicLinkRepresentation) aCDKLRS = new StepKinematics_ContextDependentKinematicLinkRepresentation; + Handle(StepKinematics_ProductDefinitionRelationshipKinematics) aPDRK = new StepKinematics_ProductDefinitionRelationshipKinematics; + theGeneralPD = aPD; + aPDRK->Init(aNameOfLinkRepr, Standard_False, aLinkRepresentationAssociation->Description(), aPD->Definition()); + aCDKLRS->Init(aLinkRepresentationAssociation, aPDRK); + Model->AddEntity(aLinkRepresentationAssociation); + Model->AddEntity(aPDRK); + Model->AddEntity(aCDKLRS); } - return Standard_False; + return Standard_True; } //======================================================================= @@ -2514,11 +2549,6 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } case(XCAFKinematics_PairType_Planar): { - if (isRanged) - theKinematicPair = new StepKinematics_PlanarPairWithRange; - else - theKinematicPair = new StepKinematics_PlanarPair; - aTZ = Standard_False; aRX = Standard_False; aRY = Standard_False; @@ -2695,7 +2725,7 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } return Standard_True; } - else if (theKinPairObj->IsKind(STANDARD_TYPE(XCAFKinematics_HighOrderPairObject))) //need to fix + else if (theKinPairObj->IsKind(STANDARD_TYPE(XCAFKinematics_HighOrderPairObject))) { Handle(XCAFKinematics_HighOrderPairObject) aHighOrderPairObject = Handle(XCAFKinematics_HighOrderPairObject)::DownCast(theKinPairObj); switch (theKinPairObj->Type()) @@ -2854,6 +2884,10 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje return Standard_False; } +//======================================================================= +//function : createKinematicPairValue +//purpose : +//======================================================================= static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_PairValueObject)& theKinPairValueObj, const Handle(StepKinematics_PairRepresentationRelationship)& thePairReprRelationship, Handle(StepKinematics_PairValue)& thePairValue) @@ -2889,14 +2923,6 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai break; } case(XCAFKinematics_PairType_Universal): - { - thePairValue = new StepKinematics_UniversalPairValue; - Handle(StepKinematics_UniversalPairValue) aUniversalPairValue = - Handle(StepKinematics_UniversalPairValue)::DownCast(thePairValue); - aUniversalPairValue->SetFirstRotationAngle(theKinPairValueObj->GetFirstRotation()); - aUniversalPairValue->SetSecondRotationAngle(theKinPairValueObj->GetSecondRotation()); - break; - } case(XCAFKinematics_PairType_Homokinetic): { thePairValue = new StepKinematics_UniversalPairValue; @@ -2907,15 +2933,6 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai break; } case(XCAFKinematics_PairType_Spherical): - { - thePairValue = new StepKinematics_SphericalPairValue; - Handle(StepKinematics_SphericalPairValue) aSphericalPairValue = - Handle(StepKinematics_SphericalPairValue)::DownCast(thePairValue); - StepKinematics_SpatialRotation InputRotation; - InputRotation.SetValue(theKinPairValueObj->GetAllValues()); - aSphericalPairValue->SetInputOrientation(InputRotation); - break; - } case(XCAFKinematics_PairType_SphericalWithPin): { thePairValue = new StepKinematics_SphericalPairValue; @@ -3122,55 +3139,29 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha return Standard_False; TDF_LabelSequence aMechanismsL; - - aMechanismsL.Clear(); aMechanismsL = aKTool->GetMechanisms(); if (aMechanismsL.Length() <= 0) return Standard_False; - Standard_Integer aMechInd; - for (Standard_Integer aMechInd = 1; aMechInd <= aMechanismsL.Length(); aMechInd++) + for (TDF_LabelSequence::Iterator anItMech(aMechanismsL); anItMech.More(); anItMech.Next()) { // write Links Handle(StepKinematics_RigidLinkRepresentation) aBaseLinkOfMech; Handle(StepRepr_PropertyDefinition) aGeneralDefinition; - TDF_LabelSequence aSeqOfLinskL = aKTool->GetLinks(aMechanismsL.Value(aMechInd)); + TDF_LabelSequence aSeqOfLinskL = aKTool->GetLinks(anItMech.Value()); if (aSeqOfLinskL.Length() <= 0) continue; NCollection_IndexedDataMap aMapOfLinks; - for (Standard_Integer aLinkInd = 1; aLinkInd <= aSeqOfLinskL.Length(); aLinkInd++) + for (TDF_LabelSequence::Iterator anItLink(aSeqOfLinskL); anItLink.More(); anItLink.Next()) { - TDF_Label aLinkL = aSeqOfLinskL.Value(aLinkInd); + TDF_Label aLinkL = anItLink.Value(); Handle(StepKinematics_KinematicLink) aLink; Handle(StepShape_ShapeRepresentation) aRefShapeOfLink; Handle(StepRepr_PropertyDefinition) aPD; Handle(StepKinematics_KinematicLinkRepresentation) aLinkRepresentation; - if (!createKinematicLink(FP, aKTool, aGraph, aLinkL, aLinkRepresentation, aLink, aRefShapeOfLink, aPD)) + if (!createKinematicLink(theWS, aKTool, aGraph, aLinkL, aMapOfLinks, aBaseLinkOfMech, aGeneralDefinition)) continue; - Handle(StepRepr_RepresentationContext) aRepresentationContextOfLink = aRefShapeOfLink->ContextOfItems(); - - Handle(TCollection_HAsciiString) aNameOfLinkRepr = new TCollection_HAsciiString(""); - Handle(StepRepr_HArray1OfRepresentationItem) aPlacementsOfPairs = new StepRepr_HArray1OfRepresentationItem; - aLinkRepresentation->Init(aNameOfLinkRepr, aPlacementsOfPairs, aRepresentationContextOfLink, aLink); - aMapOfLinks.Add(aSeqOfLinskL(aLinkInd), aLinkRepresentation); - - Handle(TDataStd_Integer) aBase; - if (aBaseLinkOfMech.IsNull() && aLinkL.FindAttribute(TDataStd_Integer::GetID(), aBase)) - aBaseLinkOfMech = Handle(StepKinematics_RigidLinkRepresentation)::DownCast(aLinkRepresentation); - - Handle(StepKinematics_KinematicLinkRepresentationAssociation) aLinkRepresentationAssociation = new StepKinematics_KinematicLinkRepresentationAssociation; - aLinkRepresentationAssociation->Init(aNameOfLinkRepr, aNameOfLinkRepr, aLinkRepresentation, aRefShapeOfLink); - Handle(StepKinematics_ContextDependentKinematicLinkRepresentation) aCDKLRS = new StepKinematics_ContextDependentKinematicLinkRepresentation; - Handle(StepKinematics_ProductDefinitionRelationshipKinematics) aPDRK = new StepKinematics_ProductDefinitionRelationshipKinematics; - aGeneralDefinition = aPD; - aPDRK->Init(aNameOfLinkRepr, Standard_False, aLinkRepresentationAssociation->Description(), aPD->Definition()); - aCDKLRS->Init(aLinkRepresentationAssociation, aPDRK); - Model->AddEntity(aLink); - Model->AddEntity(aLinkRepresentation); - Model->AddEntity(aLinkRepresentationAssociation); - Model->AddEntity(aPDRK); - Model->AddEntity(aCDKLRS); } if (aGeneralDefinition.IsNull()) continue; @@ -3183,7 +3174,7 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha continue; // write joints - TDF_LabelSequence aSeqOfJointsL = aKTool->GetJoints(aMechanismsL.Value(aMechInd)); + TDF_LabelSequence aSeqOfJointsL = aKTool->GetJoints(anItMech.Value()); if (aSeqOfJointsL.Length() <= 0) continue; NCollection_IndexedDataMap aMapofJoints; @@ -3193,9 +3184,10 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha Handle(StepKinematics_MechanismRepresentation) aMechanism = new StepKinematics_MechanismRepresentation; StepRepr_RepresentedDefinition aPDK; Handle(StepKinematics_KinematicTopologyStructure) aKTopoStruct = new StepKinematics_KinematicTopologyStructure; - for (Standard_Integer aJointInd = 1; aJointInd <= aSeqOfJointsL.Length(); aJointInd++) + Standard_Integer aJointInd = 1; + for (TDF_LabelSequence::Iterator anItJoint(aSeqOfJointsL); anItJoint.More(); anItJoint.Next()) { - TDF_Label aJointL = aSeqOfJointsL.Value(aJointInd); + TDF_Label aJointL = anItJoint.Value(); Handle(StepKinematics_KinematicJoint) aJoint; Handle(XCAFDoc_KinematicPair) aKPairAttr; Handle(StepKinematics_KinematicPair) aKinematicPair; @@ -3208,7 +3200,7 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha continue; if (!createKinematicPair(aPairObject,aJoint,aKinematicPair, aLinkRepr1, aLinkRepr2)) continue; - aMapofJoints.Add(aSeqOfJointsL(aJointInd), aJoint); + aMapofJoints.Add(anItJoint.Value(), aJoint); Handle(StepKinematics_PairRepresentationRelationship) aPairReprRelationship = new StepKinematics_PairRepresentationRelationship; StepRepr_RepresentationOrRepresentationReference aDataLinkStart; aDataLinkStart.SetValue(aLinkRepr1); @@ -3218,7 +3210,7 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha aPair.SetValue(aKinematicPair); Handle(TCollection_HAsciiString) aDescription; aPairReprRelationship->Init(aKinematicPair->Name(), aKinematicPair->Name(), Standard_False, aDescription, aDataLinkStart, aDataLinkEnd, aPair); - anArrayOfPairs->SetValue(aJointInd, aPairReprRelationship); + anArrayOfPairs->SetValue(aJointInd++, aPairReprRelationship); Model->AddEntity(aJoint); Model->AddWithRefs(aPairReprRelationship); @@ -3231,7 +3223,7 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha StepKinematics_KinematicTopologyRepresentationSelect aTopoSelect; aTopoSelect.SetValue(aKTopoStruct); Handle(TDataStd_Name) aAttrName; - aMechanismsL.Value(aMechInd).FindAttribute(TDataStd_Name::GetID(), aAttrName); + anItMech.Value().FindAttribute(TDataStd_Name::GetID(), aAttrName); Handle(TCollection_HAsciiString) aHNameMechanism = new TCollection_HAsciiString(aAttrName->Get()); aPDK.SetValue(aProductDefKin); aMechanism->Init(aHNameMechanism, anArrayOfPairs, aBaseLinkOfMech->ContextOfItems(), aTopoSelect); @@ -3239,17 +3231,18 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha Model->AddWithRefs(aPropertyMechanismRepr); // (optional) write States - TDF_LabelSequence aSeqOfStates = aKTool->GetStates(aMechanismsL.Value(aMechInd)); - for (Standard_Integer aStateInd = 1; aStateInd <= aSeqOfStates.Length(); ++aStateInd) + TDF_LabelSequence aSeqOfStates = aKTool->GetStates(anItMech.Value()); + for (TDF_LabelSequence::Iterator anItState(aSeqOfStates); anItState.More(); anItState.Next()) { Handle(StepKinematics_MechanismStateRepresentation) aStateRepr = new StepKinematics_MechanismStateRepresentation; - TDF_LabelSequence aSeqOfValues = aKTool->GetValuesOfState(aSeqOfStates(aStateInd)); + TDF_LabelSequence aSeqOfValues = aKTool->GetValuesOfState(anItState.Value()); if (aSeqOfValues.IsEmpty()) continue; Handle(StepRepr_HArray1OfRepresentationItem) aItems = new StepRepr_HArray1OfRepresentationItem(1, aSeqOfValues.Length()); - for (Standard_Integer aValueInd = 1; aValueInd <= aItems->Length(); ++aValueInd) + Standard_Integer aValueInd = 1; + for (TDF_LabelSequence::Iterator anItValue(aSeqOfValues); anItValue.More(); anItValue.Next()) { - TDF_Label aJointL = aKTool->GetJointOfValue(aSeqOfValues(aValueInd)); + TDF_Label aJointL = aKTool->GetJointOfValue(anItValue.Value()); Handle(StepKinematics_KinematicJoint) aJoint; Handle(StepKinematics_PairRepresentationRelationship) aPairReprRelationship; if (!aMapofJoints.FindFromKey(aJointL, aJoint)) @@ -3258,22 +3251,22 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha if (aPairReprRelationship.IsNull()) continue; Handle(XCAFDoc_KinematicPairValue) aKPairValueAttr; - if (!aSeqOfValues(aValueInd).FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aKPairValueAttr)) + if (!anItValue.Value().FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aKPairValueAttr)) continue; Handle(TCollection_HAsciiString) aNameOfValue; Handle(TDataStd_Name) aNameAttr; - if (aSeqOfValues(aValueInd).FindAttribute(TDataStd_Name::GetID(), aNameAttr)) + if (anItValue.Value().FindAttribute(TDataStd_Name::GetID(), aNameAttr)) aNameOfValue = new TCollection_HAsciiString(aNameAttr->Get()); Handle(XCAFKinematics_PairValueObject) aPairValueObject = aKPairValueAttr->GetObject(); Handle(StepKinematics_PairValue) aPairValue; if (!createKinematicPairValue(aPairValueObject, aPairReprRelationship, aPairValue)) continue; aPairValue->SetName(aNameOfValue); - aItems->SetValue(aValueInd, aPairValue); + aItems->SetValue(aValueInd++, aPairValue); } Handle(TCollection_HAsciiString) aNameOfState; Handle(TDataStd_Name) aNameAttr; - if (aSeqOfStates(aStateInd).FindAttribute(TDataStd_Name::GetID(), aNameAttr)) + if (anItState.Value().FindAttribute(TDataStd_Name::GetID(), aNameAttr)) aNameOfState = new TCollection_HAsciiString(aNameAttr->Get()); aStateRepr->Init(aNameOfState, aItems, aMechanism->ContextOfItems(), aMechanism); Model->AddWithRefs(aStateRepr); diff --git a/src/StepToGeom/StepToGeom.cxx b/src/StepToGeom/StepToGeom.cxx index f623e2afbd..b0eba23c0c 100644 --- a/src/StepToGeom/StepToGeom.cxx +++ b/src/StepToGeom/StepToGeom.cxx @@ -142,6 +142,7 @@ #include #include #include +#include #include //============================================================================= @@ -228,7 +229,7 @@ Handle(Geom_Axis2Placement) StepToGeom::MakeAxis2Placement(const Handle(StepKine const gp_Dir Ngp (anAsisX,anAxisY,anAxisZ); const gp_Dir Vxgp(aDirX, aDirY, aDirZ); gp_Ax2 gpAx2 = gp_Ax2(Pgp, Ngp, Vxgp); - return new Geom_Axis2Placement(gpAx2); + return new Geom_Axis2Placement(gpAx2); } //============================================================================= @@ -2081,226 +2082,180 @@ Handle(TColStd_HArray1OfReal) StepToGeom::MakeYprRotation(const StepKinematics_S SR.YprRotation()->Length() == 3) { anYPRRotation = SR.YprRotation(); + return anYPRRotation; } + + if (SR.RotationAboutDirection().IsNull() || + SR.RotationAboutDirection()->DirectionOfAxis()->DirectionRatios()->Length() != 3 || + theCntxt.IsNull()) + return NULL; //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 (Abs(anAngle) < Precision::Angular()) { - 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; + // 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; + anAngle = (!aSiUnit->HasPrefix() ? + 1. : STEPConstruct_UnitContext::ConvertSiPrefix(aSiUnit->Prefix())) * anAngle; + 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 (Abs(dy) < Precision::Confusion() && Abs(dx * dz) < Precision::SquareConfusion()) + { + while (anAngle <= -M_PI) + anAngle = anAngle + 2 * M_PI; + while (anAngle > M_PI) + anAngle = anAngle - 2 * M_PI; + + aYaw = anUcf * anAngle; + if (Abs(anAngle - M_PI) >= Precision::Angular()) + 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 - 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); + anYPRRotation->SetValue(3, aRoll); + else + if (dz > 0.) + anYPRRotation->SetValue(1, aYaw); else - if (dz > 0.) - anYPRRotation->SetValue(1, aYaw); - else - anYPRRotation->SetValue(1, aRoll); - return anYPRRotation; - } + 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.)) + // axis parallel to y-axis - use y-axis as pitch axis + if (Abs(dy) >= Precision::Confusion() && Abs(dx) < Precision::Confusion() && Abs(dz) < Precision::Confusion()) + { + if (aCA >= 0.) { - // |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; + aYaw = 0.0; + aRoll = 0.0; } 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; + aYaw = anUcf * M_PI; + aRoll = aYaw; + } + aPitch = anUcf * ATan2(aSA, Abs(aCA)); + if (dy < 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(Abs(aRotMat[0][2] - 1.)) < Precision::Confusion()) + { + // |aPitch| = PI/2 + if (Abs(aRotMat[0][2] - 1.) < Precision::Confusion()) + 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. || Abs(aYaw) < Precision::Angular()) + 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/XCAFDoc/XCAFDoc.cxx b/src/XCAFDoc/XCAFDoc.cxx index a9b6f2edba..a2a71f64ef 100644 --- a/src/XCAFDoc/XCAFDoc.cxx +++ b/src/XCAFDoc/XCAFDoc.cxx @@ -337,6 +337,10 @@ const Standard_GUID& XCAFDoc::KinematicRefLink2GUID() return ID; } +//======================================================================= +//function : KinematicRefJointGUID +//purpose : +//======================================================================= Standard_EXPORT const Standard_GUID& XCAFDoc::KinematicRefJointGUID() { static const Standard_GUID ID("596B048C-A965-4514-A059-464560BFAE4E"); diff --git a/src/XCAFDoc/XCAFDoc_KinematicPair.cxx b/src/XCAFDoc/XCAFDoc_KinematicPair.cxx index 49da1784c0..8e0cc99972 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicPair.cxx +++ b/src/XCAFDoc/XCAFDoc_KinematicPair.cxx @@ -47,7 +47,6 @@ enum ChildLab ChildLab_SecondTrsf, ChildLab_FirstGeomParam, ChildLab_SecondGeomParam, - ChildLab_Value }; //======================================================================= @@ -118,7 +117,7 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t TDataXtd_Plane::Set(Label().FindChild(ChildLab_FirstTrsf), gp_Pln(theObject->FirstTransformation())); TDataXtd_Plane::Set(Label().FindChild(ChildLab_SecondTrsf), gp_Pln(theObject->SecondTransformation())); - if (!theObject->GetAllLimits().IsNull() && theObject->HasLimits()) { + if (theObject->HasLimits()) { Handle(TDataStd_RealArray) aLimitsAttr; aLimitsAttr = TDataStd_RealArray::Set(Label(), getLimitsID(), 1, theObject->GetAllLimits()->Length()); aLimitsAttr->ChangeArray(theObject->GetAllLimits()); @@ -137,7 +136,7 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t theObject->Type() <= XCAFKinematics_PairType_LinearFlexibleAndPinion) { Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObject = Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(theObject); - if (!anObject->GetAllParams().IsNull() && anObject->GetAllParams()->Upper() > 0) { + if (!anObject->GetAllParams().IsNull() && !anObject->GetAllParams()->IsEmpty()) { Handle(TDataStd_RealArray) aParamsAttr; aParamsAttr = TDataStd_RealArray::Set(Label(), getParamsID(), 1, anObject->GetAllParams()->Upper()); aParamsAttr->ChangeArray(anObject->GetAllParams()); @@ -186,8 +185,8 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t TNaming_Builder aTNBuild(Label().FindChild(ChildLab_FirstGeomParam)); aTNBuild.Generated(anEdge); } - if (anObject->Type() == XCAFKinematics_PairType_SlidingCurve || - anObject->Type() == XCAFKinematics_PairType_RollingCurve) + if (anObject->Type() >= XCAFKinematics_PairType_SlidingCurve && + anObject->Type() <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) { TopoDS_Edge anEdge1, anEdge2; if (!anObject->FirstCurve().IsNull()) { @@ -201,15 +200,6 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t aTNBuild2.Generated(anEdge2); } } - if (anObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) - { - TopoDS_Edge anEdge; - if (!anObject->FirstCurve().IsNull()) { - aBuilder.MakeEdge(anEdge, anObject->FirstCurve(), Precision::Confusion()); - TNaming_Builder aTNBuild1(Label().FindChild(ChildLab_FirstGeomParam)); - aTNBuild1.Generated(anEdge); - } - } } } diff --git a/src/XCAFDoc/XCAFDoc_KinematicPairValue.cxx b/src/XCAFDoc/XCAFDoc_KinematicPairValue.cxx index f5952e33bf..bce52988c1 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicPairValue.cxx +++ b/src/XCAFDoc/XCAFDoc_KinematicPairValue.cxx @@ -61,13 +61,19 @@ Handle(XCAFDoc_KinematicPairValue) XCAFDoc_KinematicPairValue::Set(const TDF_Lab theValue.AddAttribute(anAttr); } + // check for exist old reference Handle(TDataStd_TreeNode) aJointNode, aValueNode; + if (theValue.FindAttribute(XCAFDoc::KinematicRefJointGUID(), aValueNode)) { + if (aValueNode->HasFather() && aValueNode->Father()->Label() == theJoint) + return anAttr; + aValueNode->Remove(); + } + // Add reference to Joint aValueNode = TDataStd_TreeNode::Set(theJoint, XCAFDoc::KinematicRefJointGUID()); aJointNode = TDataStd_TreeNode::Set(theValue, XCAFDoc::KinematicRefJointGUID()); aValueNode->Append(aJointNode); - return anAttr; } diff --git a/src/XCAFDoc/XCAFDoc_KinematicPairValue.hxx b/src/XCAFDoc/XCAFDoc_KinematicPairValue.hxx index 6d8895f36e..78fef40bb8 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicPairValue.hxx +++ b/src/XCAFDoc/XCAFDoc_KinematicPairValue.hxx @@ -35,10 +35,11 @@ class XCAFDoc_KinematicPairValue; DEFINE_STANDARD_HANDLE(XCAFDoc_KinematicPairValue, TDF_Attribute) //! Attribute to store kinematic pair value. -//! This parameter is an additional attribute for kinematic pair attribute +//! This parameter is an additional attribute for kinematic pair attribute, +//! which characterizes the pair for one of the mechanism states. //! It is prohibited to store inconsistent data: //! - to store this attribute without kinematic value attribute -//! - to store attributes with different types +//! - to store this attribute not of the same type as the type of the pair class XCAFDoc_KinematicPairValue : public TDF_Attribute { diff --git a/src/XCAFDoc/XCAFDoc_KinematicTool.cxx b/src/XCAFDoc/XCAFDoc_KinematicTool.cxx index 32f3145557..86b9364f91 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicTool.cxx +++ b/src/XCAFDoc/XCAFDoc_KinematicTool.cxx @@ -231,22 +231,25 @@ Standard_EXPORT Standard_Boolean XCAFDoc_KinematicTool::SetBaseLink(const TDF_La if (!IsMechanism(aMechanism)) return Standard_False; TDF_LabelSequence aLinks = GetLinks(aMechanism); - for (Standard_Integer anInd = 1; anInd <= aLinks.Length(); ++anInd) + for (TDF_LabelSequence::Iterator anIt(aLinks); anIt.More(); anIt.Next()) { Handle(TDataStd_Integer) aBase; - if (aLinks(anInd).FindAttribute(TDataStd_Integer::GetID(), aBase)) + if (anIt.Value().FindAttribute(TDataStd_Integer::GetID(), aBase)) { - aLinks(anInd).ForgetAttribute(aBase); + anIt.Value().ForgetAttribute(aBase); Handle(TDataStd_Name) aLinkName; - if (aLinks(anInd).FindAttribute(TDataStd_Name::GetID(), aLinkName) && !aLinkName->Get().IsDifferent("Base")) + if (anIt.Value().FindAttribute(TDataStd_Name::GetID(), aLinkName) && !aLinkName->Get().IsDifferent("Base")) { TCollection_AsciiString aName = "Link "; - aName.AssignCat(TCollection_AsciiString(aLinks(anInd).Tag())); - TDataStd_Name::Set(aLinks(anInd), aName); + aName.AssignCat(TCollection_AsciiString(anIt.Value().Tag())); + TDataStd_Name::Set(anIt.Value(), aName); } } } - TDataStd_Name::Set(theLink, "Base"); + Handle(TDataStd_Name) aLinkName; + if (!theLink.FindAttribute(TDataStd_Name::GetID(), aLinkName) || + (!aLinkName.IsNull() && !aLinkName->Get().IsDifferent("Link " + theLink.Tag()))) + TDataStd_Name::Set(theLink, "Base"); TDataStd_Integer::Set(theLink, 1); } @@ -371,9 +374,6 @@ Standard_Boolean XCAFDoc_KinematicTool::SetJoint(const TDF_Label& theJoint, aJointNode->Remove(); // fix against bug in TreeNode::Append() aLinkNode->Append(aJointNode); - TCollection_AsciiString aName = "Joint "; - aName.AssignCat(TCollection_AsciiString(theJoint.Tag())); - TDataStd_Name::Set(theJoint, aName); return Standard_True; } @@ -396,12 +396,6 @@ void XCAFDoc_KinematicTool::RemoveJoint(const TDF_Label& theJoint) } -Standard_Boolean XCAFDoc_KinematicTool::IsValue(const TDF_Label& theValue) const -{ - Handle(XCAFDoc_KinematicPairValue) anAttr; - return theValue.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), anAttr); -} - //======================================================================= //function : GetMechanisms //purpose : @@ -532,19 +526,37 @@ TDF_Label XCAFDoc_KinematicTool::AddState(const TDF_Label& theMechanism) return aState; } +//======================================================================= +//function : IsState +//purpose : +//======================================================================= +Standard_Boolean XCAFDoc_KinematicTool::IsState(const TDF_Label& theState) const +{ + return IsMechanism(theState.Father().Father()) && theState.Father().Tag() == 3; +} + //======================================================================= //function : AddValue //purpose : //======================================================================= TDF_Label XCAFDoc_KinematicTool::AddValue(const TDF_Label& theState) { - if(!IsMechanism(theState.Father().Father()) && - theState.Father().Tag() != 3) + if (!IsState(theState)) return TDF_Label(); return theState.NewChild(); } +//======================================================================= +//function : IsValue +//purpose : +//======================================================================= +Standard_Boolean XCAFDoc_KinematicTool::IsValue(const TDF_Label& theValue) const +{ + Handle(XCAFDoc_KinematicPairValue) anAttr; + return theValue.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), anAttr); +} + //======================================================================= //function : RemoveValue //purpose : @@ -573,7 +585,7 @@ TDF_LabelSequence XCAFDoc_KinematicTool::GetStates(const TDF_Label& theMechanism return aStatesArray; TDF_Label aRootOfState = getRootOfStates(theMechanism); - if (!IsMechanism(theMechanism) || aRootOfState.IsNull()) + if (aRootOfState.IsNull()) return aStatesArray; for (TDF_ChildIterator anIt(aRootOfState); anIt.More(); anIt.Next()) { @@ -604,7 +616,7 @@ TDF_Label XCAFDoc_KinematicTool::GetStateOfValue(const TDF_Label& theValue) cons Standard_EXPORT TDF_LabelSequence XCAFDoc_KinematicTool::GetValuesOfState(const TDF_Label& theState) const { TDF_LabelSequence aValueArray; - if (!IsMechanism(theState.Father().Father()) || theState.Father().Tag() != 3) + if (!IsState(theState)) return aValueArray; for (TDF_ChildIterator anIt(theState); anIt.More(); anIt.Next()) { @@ -663,7 +675,7 @@ TDF_LabelSequence XCAFDoc_KinematicTool::GetValuesOfJoint(const TDF_Label& theJo void XCAFDoc_KinematicTool::RemoveState(const TDF_Label& theState) { TDF_Label aMechanism = theState.Father().Father(); - if (!IsMechanism(aMechanism) || theState.Father().Tag() != 3) + if (!IsState(theState)) return; Handle(TDataStd_TreeNode) aNode; TDF_LabelSequence aSeqOfValues = GetValuesOfState(theState); diff --git a/src/XCAFDoc/XCAFDoc_KinematicTool.hxx b/src/XCAFDoc/XCAFDoc_KinematicTool.hxx index 847cc13d0d..596f672cee 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicTool.hxx +++ b/src/XCAFDoc/XCAFDoc_KinematicTool.hxx @@ -153,6 +153,10 @@ public: //! \return created state label Standard_EXPORT TDF_Label AddState(const TDF_Label& theMechanism); + //! Checks is the given label a State + //! \return the result of check + Standard_EXPORT Standard_Boolean IsState(const TDF_Label& theState) const; + //! Adds new empty label for Value. //! \param[in] theState parent state //! \return created value label diff --git a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx index 72346d5e25..a8f56a2ec3 100644 --- a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx +++ b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx @@ -36,7 +36,6 @@ 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 { @@ -66,10 +65,10 @@ public: Handle(TColStd_HArray1OfReal) GetAllLimits() const Standard_OVERRIDE { - Handle(TColStd_HArray1OfReal) aLimitArray; + if (HasLimits()) - aLimitArray = myLimits; - return aLimitArray; + return myLimits; + return NULL; } //! Sets low limit of rotation attribute (only for SlidingSurface and RollingSurface) @@ -160,10 +159,6 @@ public: //! \return curve Standard_EXPORT Handle(Geom_Curve) SecondCurve() const; - //! 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) //! \param[in] aTrimCurve trimmed curve Standard_EXPORT void SetTrimmedCurve(const Handle(Geom_TrimmedCurve)& aTrimCurve); @@ -172,15 +167,12 @@ public: //! \return trimmed curve Standard_EXPORT Handle(Geom_TrimmedCurve) TrimmedCurve() const; - //! \return trimmed curve - //Standard_EXPORT void TrimmedCurve(Standard_Real& theTrim1,Standard_Real& theTrim2) const; - //! Sets surface attribute (only for PointOnSurface) //! \param[in] theSurface surface Standard_EXPORT void SetSurface(const Handle(Geom_Surface)& theSurface); //! Gets surface attribute (only for PointOnSurface) - //! \return curve + //! \return surface Standard_EXPORT Handle(Geom_Surface) Surface() const; //! Sets surface attribute (only for SlidingSurface and RollingSurface) @@ -199,10 +191,6 @@ public: //! \return surface Standard_EXPORT Handle(Geom_Surface) SecondSurface() const; - //! 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) //! \param[in] aTrimSurface trimmered surface Standard_EXPORT void SetTrimmedSurface(const Handle(Geom_RectangularTrimmedSurface)& aTrimSurface); diff --git a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx index 6b60427aaa..ca8a488ae7 100644 --- a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx +++ b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx @@ -24,19 +24,20 @@ class TColStd_HArray1OfReal; DEFINE_STANDARD_HANDLE(XCAFKinematics_LowOrderPairObject, XCAFKinematics_PairObject) //! \class XCAFKinematics_LowOrderPairObject -//! \brief Object for low order kinematic pairs: -//! - XCAFKinematics_PairType_FullyConstrained -//! - XCAFKinematics_PairType_Revolute -//! - XCAFKinematics_PairType_Prismatic -//! - XCAFKinematics_PairType_Cylindrical -//! - XCAFKinematics_PairType_Universal -//! - XCAFKinematics_PairType_Homokinetic -//! - XCAFKinematics_PairType_SphericalWithPin -//! - XCAFKinematics_PairType_Spherical -//! - XCAFKinematics_PairType_Planar -//! - XCAFKinematics_PairType_Unconstrained -//! Not all limits are used for each pair, if less than 3 translation/rotation -//! limits is used values should be specified in alphabetical order. +//! \brief Object for low order kinematic pairs: +//! - XCAFKinematics_PairType_FullyConstrained +//! - XCAFKinematics_PairType_Revolute +//! - XCAFKinematics_PairType_Prismatic +//! - XCAFKinematics_PairType_Cylindrical +//! - XCAFKinematics_PairType_Universal +//! - XCAFKinematics_PairType_Homokinetic +//! - XCAFKinematics_PairType_SphericalWithPin +//! - XCAFKinematics_PairType_Spherical +//! - XCAFKinematics_PairType_Planar +//! - XCAFKinematics_PairType_Unconstrained +//! Not all limits are used for each pair, +//! values should be specified in alphabetical order: + class XCAFKinematics_LowOrderPairObject : public XCAFKinematics_PairObject { diff --git a/src/XCAFKinematics/XCAFKinematics_PairValueObject.cxx b/src/XCAFKinematics/XCAFKinematics_PairValueObject.cxx index 0c6682d31c..972ff53840 100644 --- a/src/XCAFKinematics/XCAFKinematics_PairValueObject.cxx +++ b/src/XCAFKinematics/XCAFKinematics_PairValueObject.cxx @@ -47,8 +47,8 @@ void XCAFKinematics_PairValueObject::SetType(const XCAFKinematics_PairType theTy Standard_Integer aNbParams = 0; switch (myType) { case XCAFKinematics_PairType_Revolute: - aNbParams = 1; - break; + aNbParams = 1; + break; case XCAFKinematics_PairType_Prismatic: aNbParams = 1; break; diff --git a/src/XDEDRAW/XDEDRAW.cxx b/src/XDEDRAW/XDEDRAW.cxx index 84d6b1d197..a93b8a57cf 100644 --- a/src/XDEDRAW/XDEDRAW.cxx +++ b/src/XDEDRAW/XDEDRAW.cxx @@ -1123,6 +1123,9 @@ static Standard_Integer XAttributeValue (Draw_Interpretor& di, Standard_Integer else if (att->ID() == XCAFDoc::KinematicRefLink1GUID() || att->ID() == XCAFDoc::KinematicRefLink2GUID()){ type = "Kinematic Joint to Link"; } + else if (att->ID() == XCAFDoc::KinematicRefJointGUID()) { + type = "Kinematic Value to Joint"; + } else return 0; Handle(XCAFDoc_GraphNode) DETGN = Handle(XCAFDoc_GraphNode)::DownCast(att); diff --git a/src/XDEDRAW/XDEDRAW_Kinematics.cxx b/src/XDEDRAW/XDEDRAW_Kinematics.cxx index 3f39ec92c7..6660099750 100644 --- a/src/XDEDRAW/XDEDRAW_Kinematics.cxx +++ b/src/XDEDRAW/XDEDRAW_Kinematics.cxx @@ -512,11 +512,11 @@ static Standard_Integer getLinksOfJoint(Draw_Interpretor& di, Standard_Integer a if (!getDocument(di, argv[1], aDoc)) return 1; + Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) return 1; - Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aLink1, aLink2; aTool->GetLinksOfJoint(aJoint, aLink1, aLink2); @@ -598,7 +598,7 @@ static Standard_Integer setName(Draw_Interpretor& di, Standard_Integer argc, con Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; TCollection_AsciiString aName; @@ -610,12 +610,15 @@ static Standard_Integer setName(Draw_Interpretor& di, Standard_Integer argc, con } Handle(XCAFDoc_KinematicPair) aPair; - if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { - Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); - anObject->SetName(aName); - aPair->SetObject(anObject); + if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { + di << "Invalid kinematic pair object\n"; + return 1; } + Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); + anObject->SetName(aName); + aPair->SetObject(anObject); + return 0; } @@ -636,15 +639,18 @@ static Standard_Integer getName(Draw_Interpretor& di, Standard_Integer argc, con Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; Handle(XCAFDoc_KinematicPair) aPair; - if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { - Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); - di << anObject->Name(); + if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { + di << "Invalid kinematic pair object\n"; + return 1; } + Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); + di << anObject->Name(); + return 0; } @@ -665,26 +671,29 @@ static Standard_Integer setType(Draw_Interpretor& di, Standard_Integer argc, con Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; Handle(XCAFDoc_KinematicPair) aPair; - if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { - Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); - int aType = Draw::Atoi(argv[3]); - if (aType >= XCAFKinematics_PairType_FullyConstrained && - aType <= XCAFKinematics_PairType_Unconstrained) - anObject = new XCAFKinematics_LowOrderPairObject(); - else if (aType >= XCAFKinematics_PairType_Screw && - aType <= XCAFKinematics_PairType_LinearFlexibleAndPinion) - anObject = new XCAFKinematics_LowOrderPairObjectWithCoupling(); - else if (aType >= XCAFKinematics_PairType_PointOnSurface && - aType <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) - anObject = new XCAFKinematics_HighOrderPairObject(); - anObject->SetType((XCAFKinematics_PairType)aType); - aPair->SetObject(anObject); + if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { + di << "Invalid kinematic pair object\n"; + return 1; } + Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); + int aType = Draw::Atoi(argv[3]); + if (aType >= XCAFKinematics_PairType_FullyConstrained && + aType <= XCAFKinematics_PairType_Unconstrained) + anObject = new XCAFKinematics_LowOrderPairObject(); + else if (aType >= XCAFKinematics_PairType_Screw && + aType <= XCAFKinematics_PairType_LinearFlexibleAndPinion) + anObject = new XCAFKinematics_LowOrderPairObjectWithCoupling(); + else if (aType >= XCAFKinematics_PairType_PointOnSurface && + aType <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) + anObject = new XCAFKinematics_HighOrderPairObject(); + anObject->SetType((XCAFKinematics_PairType)aType); + aPair->SetObject(anObject); + return 0; } @@ -705,15 +714,18 @@ static Standard_Integer getType(Draw_Interpretor& di, Standard_Integer argc, con Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; Handle(XCAFDoc_KinematicPair) aPair; - if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { - Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); - di << anObject->Type(); + if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { + di << "Invalid kinematic pair object\n"; + return 1; } + Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); + di << anObject->Type(); + return 0; } @@ -734,30 +746,34 @@ static Standard_Integer setTrsf(Draw_Interpretor& di, Standard_Integer argc, con Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; Handle(XCAFDoc_KinematicPair) aPair; - if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { - Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); - Standard_Integer aTrsfNb = Draw::Atoi(argv[3]); - Handle(Geom_Plane) aSurface = Handle(Geom_Plane)::DownCast(DrawTrSurf::GetSurface(argv[4])); - if (aSurface.IsNull()) { - di << "Invalid transformation\n"; - return 1; - } - switch (aTrsfNb) { - case 1: anObject->SetFirstTransformation(aSurface->Position()); - break; - case 2: anObject->SetSecondTransformation(aSurface->Position()); - break; - default: - di << "Invalid number of transformation\n"; - return 1; - } - aPair->SetObject(anObject); + if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { + di << "Invalid kinematic pair object\n"; + return 1; } + Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); + Standard_Integer aTrsfNb = Draw::Atoi(argv[3]); + Handle(Geom_Plane) aSurface = Handle(Geom_Plane)::DownCast(DrawTrSurf::GetSurface(argv[4])); + if (aSurface.IsNull()) { + di << "Invalid transformation\n"; + return 1; + } + switch (aTrsfNb) { + case 1: anObject->SetFirstTransformation(aSurface->Position()); + break; + case 2: anObject->SetSecondTransformation(aSurface->Position()); + break; + default: + di << "Invalid number of transformation\n"; + return 1; + } + aPair->SetObject(anObject); + + return 0; } @@ -778,23 +794,26 @@ static Standard_Integer getTrsf(Draw_Interpretor& di, Standard_Integer argc, con Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; Handle(XCAFDoc_KinematicPair) aPair; - if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { - Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); - Standard_Integer aTrsfNb = Draw::Atoi(argv[3]); - Standard_CString aName = argv[4]; - switch (aTrsfNb) { - case 1: DrawTrSurf::Set(aName, new Geom_Plane(anObject->FirstTransformation())); - break; - case 2: DrawTrSurf::Set(aName, new Geom_Plane(anObject->SecondTransformation())); - break; - default: - di << "Invalid number of transformation\n"; - return 1; - } + if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { + di << "Invalid kinematic pair object\n"; + return 1; + } + + Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); + Standard_Integer aTrsfNb = Draw::Atoi(argv[3]); + Standard_CString aName = argv[4]; + switch (aTrsfNb) { + case 1: DrawTrSurf::Set(aName, new Geom_Plane(anObject->FirstTransformation())); + break; + case 2: DrawTrSurf::Set(aName, new Geom_Plane(anObject->SecondTransformation())); + break; + default: + di << "Invalid number of transformation\n"; + return 1; } return 0; @@ -817,21 +836,24 @@ static Standard_Integer setLimits(Draw_Interpretor& di, Standard_Integer argc, c Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; + Handle(XCAFDoc_KinematicPair) aPair; + if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { + di << "Invalid kinematic pair object\n"; + return 1; + } + Handle(TColStd_HArray1OfReal) aLimitArray = new TColStd_HArray1OfReal(1, argc - 3); for (Standard_Integer i = 3; i < argc; i++) { aLimitArray->ChangeValue(i - 2) = Draw::Atof(argv[i]); } - Handle(XCAFDoc_KinematicPair) aPair; - if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { - Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); - anObject->SetAllLimits(aLimitArray); - if (anObject->HasLimits()) - aPair->SetObject(anObject); - } + Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); + anObject->SetAllLimits(aLimitArray); + if (anObject->HasLimits()) + aPair->SetObject(anObject); return 0; } @@ -853,7 +875,7 @@ static Standard_Integer getLimits(Draw_Interpretor& di, Standard_Integer argc, c Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; Handle(XCAFDoc_KinematicPair) aPair; @@ -888,30 +910,33 @@ static Standard_Integer setParameters(Draw_Interpretor& di, Standard_Integer arg Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) + return 1; + + Handle(XCAFDoc_KinematicPair) aPair; + if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { + di << "Invalid kinematic pair object\n"; return 1; + } Handle(TColStd_HArray1OfReal) aParamArray = new TColStd_HArray1OfReal(1, argc - 3); for (Standard_Integer i = 3; i < argc; i++) { aParamArray->ChangeValue(i - 2) = Draw::Atof(argv[i]); } - Handle(XCAFDoc_KinematicPair) aPair; - if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { - Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObject = - Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(aPair->GetObject()); - if (!anObject.IsNull()) { - anObject->SetAllParams(aParamArray); - aPair->SetObject(anObject); - return 0; - } - Handle(XCAFKinematics_LowOrderPairObject) aLowObject = - Handle(XCAFKinematics_LowOrderPairObject)::DownCast(aPair->GetObject()); - if (!aLowObject.IsNull()) { - aLowObject->SetSkewAngle(aParamArray->First()); - aPair->SetObject(aLowObject); - return 0; - } + Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObject = + Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(aPair->GetObject()); + if (!anObject.IsNull()) { + anObject->SetAllParams(aParamArray); + aPair->SetObject(anObject); + return 0; + } + Handle(XCAFKinematics_LowOrderPairObject) aLowObject = + Handle(XCAFKinematics_LowOrderPairObject)::DownCast(aPair->GetObject()); + if (!aLowObject.IsNull()) { + aLowObject->SetSkewAngle(aParamArray->First()); + aPair->SetObject(aLowObject); + return 0; } di << "Wrong type of object\n"; @@ -935,44 +960,45 @@ static Standard_Integer getParameters(Draw_Interpretor& di, Standard_Integer arg Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; Handle(XCAFDoc_KinematicPair) aPair; - if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { - Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObject = - Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(aPair->GetObject()); - if (anObject.IsNull()) { - Handle(XCAFKinematics_LowOrderPairObject) aLowObject = - Handle(XCAFKinematics_LowOrderPairObject)::DownCast(aPair->GetObject()); - if (!aLowObject.IsNull() && - (aLowObject->Type() == XCAFKinematics_PairType_Universal || - aLowObject->Type() == XCAFKinematics_PairType_Homokinetic)) { - di << "Skew Angle = " << aLowObject->SkewAngle(); - return 0; - } - else { - di << "Wrong type of object\n"; - return 1; - } + if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) + return 1; + + Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObject = + Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(aPair->GetObject()); + if (anObject.IsNull()) { + Handle(XCAFKinematics_LowOrderPairObject) aLowObject = + Handle(XCAFKinematics_LowOrderPairObject)::DownCast(aPair->GetObject()); + if (!aLowObject.IsNull() && + (aLowObject->Type() == XCAFKinematics_PairType_Universal || + aLowObject->Type() == XCAFKinematics_PairType_Homokinetic)) { + di << "Skew Angle = " << aLowObject->SkewAngle(); + return 0; } - switch (anObject->Type()) { - case XCAFKinematics_PairType_Screw: - di << "Pitch = " << anObject->Pitch(); - break; - case XCAFKinematics_PairType_RackAndPinion: - case XCAFKinematics_PairType_LinearFlexibleAndPinion: - di << "Pinion Radius = " << anObject->PinionRadius(); - break; - case XCAFKinematics_PairType_Gear: - di << "First Link Radius = " << anObject->RadiusFirstLink() << "\n"; - di << "Second Link Radius = " << anObject->RadiusSecondLink() << "\n"; - di << "Bevel = " << anObject->Bevel() << "\n"; - di << "Helical Angle = " << anObject->HelicalAngle() << "\n"; - di << "Gear Ratio = " << anObject->GearRatio(); - break; + else { + di << "Wrong type of object\n"; + return 1; } } + switch (anObject->Type()) { + case XCAFKinematics_PairType_Screw: + di << "Pitch = " << anObject->Pitch(); + break; + case XCAFKinematics_PairType_RackAndPinion: + case XCAFKinematics_PairType_LinearFlexibleAndPinion: + di << "Pinion Radius = " << anObject->PinionRadius(); + break; + case XCAFKinematics_PairType_Gear: + di << "First Link Radius = " << anObject->RadiusFirstLink() << "\n"; + di << "Second Link Radius = " << anObject->RadiusSecondLink() << "\n"; + di << "Bevel = " << anObject->Bevel() << "\n"; + di << "Helical Angle = " << anObject->HelicalAngle() << "\n"; + di << "Gear Ratio = " << anObject->GearRatio(); + break; + } return 0; } @@ -994,21 +1020,22 @@ static Standard_Integer setOrientation(Draw_Interpretor& di, Standard_Integer ar Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; Handle(XCAFDoc_KinematicPair) aPair; - if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { - Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); - Handle(XCAFKinematics_HighOrderPairObject) aHighObject = - Handle(XCAFKinematics_HighOrderPairObject)::DownCast(anObject); - if (aHighObject.IsNull()) { - di << "Error: Orientation could be applied only for high order kinematic pair\n"; - return 1; - } - aHighObject->SetOrientation(Draw::Atoi(argv[3]) != 0 ); - aPair->SetObject(anObject); + if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) + return 1; + + Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); + Handle(XCAFKinematics_HighOrderPairObject) aHighObject = + Handle(XCAFKinematics_HighOrderPairObject)::DownCast(anObject); + if (aHighObject.IsNull()) { + di << "Error: Orientation could be applied only for high order kinematic pair\n"; + return 1; } + aHighObject->SetOrientation(Draw::Atoi(argv[3]) != 0); + aPair->SetObject(anObject); return 0; } @@ -1030,20 +1057,20 @@ static Standard_Integer getOrientation(Draw_Interpretor& di, Standard_Integer ar Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; Handle(XCAFDoc_KinematicPair) aPair; - if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { - Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); - Handle(XCAFKinematics_HighOrderPairObject) aHighObject = - Handle(XCAFKinematics_HighOrderPairObject)::DownCast(anObject); - if (aHighObject.IsNull()) { - di << "Error: Orientation could be applied only for high order kinematic pair\n"; - return 1; - } - di << aHighObject->Orientation(); + if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) + return 1; + Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); + Handle(XCAFKinematics_HighOrderPairObject) aHighObject = + Handle(XCAFKinematics_HighOrderPairObject)::DownCast(anObject); + if (aHighObject.IsNull()) { + di << "Error: Orientation could be applied only for high order kinematic pair\n"; + return 1; } + di << aHighObject->Orientation(); return 0; } @@ -1065,7 +1092,7 @@ static Standard_Integer setGeomParam(Draw_Interpretor& di, Standard_Integer argc Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; Handle(XCAFDoc_KinematicPair) aPair; if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { @@ -1130,6 +1157,8 @@ static Standard_Integer setGeomParam(Draw_Interpretor& di, Standard_Integer argc } if (anObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve) anObject->SetCurve(aCurve); + else if (anObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) + anObject->SetFirstCurve(aCurve); else { switch (aParamNb) { case 1: anObject->SetFirstCurve(aCurve); @@ -1164,7 +1193,7 @@ static Standard_Integer getGeomParam(Draw_Interpretor& di, Standard_Integer argc return 1; Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[2], aJoint)) return 1; Handle(XCAFDoc_KinematicPair) aPair; if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { @@ -1207,10 +1236,12 @@ static Standard_Integer getGeomParam(Draw_Interpretor& di, Standard_Integer argc // Curve Handle(Geom_Curve) aCurve; if (anObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve) - if (!anObject->HasLimits()) - aCurve = anObject->Curve(); - else - aCurve = anObject->TrimmedCurve(); + if (!anObject->HasLimits()) + aCurve = anObject->Curve(); + else + aCurve = anObject->TrimmedCurve(); + else if(anObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) + aCurve = anObject->FirstCurve(); else { switch (aTrsfNb) { case 1: aCurve = anObject->FirstCurve(); @@ -1268,15 +1299,12 @@ static Standard_Integer removeMechanismState(Draw_Interpretor& di, Standard_Inte return 1; TDF_Label aState; - if (!getLabel(di, aDoc, argv[2], aState) && aState.Father().Tag() != 3) + if (!getLabel(di, aDoc, argv[2], aState)) return 1; Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); - TDF_Label aMechanism = aState.Father().Father(); - if(!aTool->IsMechanism(aMechanism)) - return 1; - aTool->RemoveState(aState); + return 0; } @@ -1296,12 +1324,10 @@ static Standard_Integer addValues(Draw_Interpretor& di, Standard_Integer argc, c return 1; Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aState; - if (!getLabel(di, aDoc, argv[2], aState)) + if (!getLabel(di, aDoc, argv[2], aState) || !aTool->IsState(aState)) return 1; - TDF_Label aMechanism = aState.Father().Father(); + TDF_Label aValue = aTool->AddValue(aState); - TDF_TagSource aTag; - TDF_Label aValue = aTag.NewChild(aState); if (argc == 3) { Handle(XCAFDoc_KinematicPairValue) aPairValue; @@ -1309,7 +1335,7 @@ static Standard_Integer addValues(Draw_Interpretor& di, Standard_Integer argc, c } else { TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[3], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[3], aJoint)) return 1; Handle(XCAFKinematics_PairValueObject) anObject; @@ -1401,9 +1427,8 @@ static Standard_Integer setValues(Draw_Interpretor& di, Standard_Integer argc, c return 1; Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aJoint; - if (!getLabel(di, aDoc, argv[3], aJoint) || !aTool->IsJoint(aJoint)) + if (!getLabel(di, aDoc, argv[3], aJoint)) return 1; - TDF_Label aMechanism = aJoint.Father().Father(); TDF_Label aValue; if (!getLabel(di, aDoc, argv[2], aValue) || !aTool->IsValue(aValue)) return 1; @@ -1418,19 +1443,15 @@ static Standard_Integer setValues(Draw_Interpretor& di, Standard_Integer argc, c } Handle(XCAFKinematics_PairObject) aPairObject = aPair->GetObject(); - if (aValue.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aPairValue)) - { - aPairValue = XCAFDoc_KinematicPairValue::Set(aValue, aJoint); - anObject = aPairValue->GetObject(); - if (anObject->GetAllValues().IsNull()) - anObject->SetType(aPairObject->Type()); + if (!aValue.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aPairValue)) { + di << "Invalid kinematic value object\n"; + return 1; } - else { - anObject = new XCAFKinematics_PairValueObject(); - aPairValue = XCAFDoc_KinematicPairValue::Set(aValue,aJoint); + anObject = aPairValue->GetObject(); + if (anObject->GetAllValues().IsNull() || + anObject->Type() != aPairObject->Type()) anObject->SetType(aPairObject->Type()); - } - + XCAFDoc_KinematicPairValue::Set(aValue, aJoint); try { Standard_Integer anIt = 4; while (anIt < argc) { @@ -1506,10 +1527,9 @@ static Standard_Integer getValues(Draw_Interpretor& di, Standard_Integer argc, c return 1; Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aValue; - if (!getLabel(di, aDoc, argv[2], aValue) || !aTool->IsValue(aValue)) + if (!getLabel(di, aDoc, argv[2], aValue)) return 1; - Handle(XCAFKinematics_PairValueObject) anObject; Handle(XCAFDoc_KinematicPairValue) aPairValue; if (aValue.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aPairValue)) @@ -1584,7 +1604,7 @@ static Standard_Integer removeValues(Draw_Interpretor& di, Standard_Integer argc return 1; Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); TDF_Label aValue; - if (!getLabel(di, aDoc, argv[2], aValue) && !aTool->IsValue(aValue)) + if (!getLabel(di, aDoc, argv[2], aValue)) return 1; aTool->RemoveValue(aValue); @@ -1625,18 +1645,18 @@ static Standard_Integer dump(Draw_Interpretor& di, Standard_Integer argc, const nbLowOrderPairWithMotionCouplingValues = 0, nbLowOrderPairValues = 0; - for (Standard_Integer aMechInd = 1; aMechInd <= aMechanisms.Length(); ++aMechInd) + for (TDF_LabelSequence::Iterator anIt(aMechanisms); anIt.More(); anIt.Next()) { - TDF_Label aMechanism = aMechanisms.Value(aMechInd); + TDF_Label aMechanism = anIt.Value(); 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) + for (TDF_LabelSequence::Iterator anIt(aJoints); anIt.More(); anIt.Next()) { Handle(XCAFDoc_KinematicPair) aKinAttr; - if (!aJoints.Value(aJointInd).FindAttribute(XCAFDoc_KinematicPair::GetID(), aKinAttr)) + if (!anIt.Value().FindAttribute(XCAFDoc_KinematicPair::GetID(), aKinAttr)) continue; Handle(XCAFKinematics_PairObject) anObject = aKinAttr->GetObject(); if (anObject.IsNull()) @@ -1649,7 +1669,7 @@ static Standard_Integer dump(Draw_Interpretor& di, Standard_Integer argc, const nbLowOrderPairsWithRange++; else nbLowOrderPairs++; - nbLowOrderPairValues += aKTool->GetValuesOfJoint(aJoints.Value(aJointInd)).Length(); + nbLowOrderPairValues += aKTool->GetValuesOfJoint(anIt.Value()).Length(); } else if (aKinType >= XCAFKinematics_PairType_Screw && aKinType <= XCAFKinematics_PairType_LinearFlexibleAndPinion) @@ -1658,7 +1678,7 @@ static Standard_Integer dump(Draw_Interpretor& di, Standard_Integer argc, const nbLowOrderPairsWithMotionCouplingAndRange++; else nbLowOrderPairsWithMotionCoupling++; - nbLowOrderPairWithMotionCouplingValues += aKTool->GetValuesOfJoint(aJoints.Value(aJointInd)).Length(); + nbLowOrderPairWithMotionCouplingValues += aKTool->GetValuesOfJoint(anIt.Value()).Length(); } else if (aKinType >= XCAFKinematics_PairType_PointOnSurface && aKinType <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) @@ -1667,7 +1687,7 @@ static Standard_Integer dump(Draw_Interpretor& di, Standard_Integer argc, const nbHigeOrderPairsWithRange++; else nbHigeOrderPairs++; - nbHigeOrderPairValues += aKTool->GetValuesOfJoint(aJoints.Value(aJointInd)).Length(); + nbHigeOrderPairValues += aKTool->GetValuesOfJoint(anIt.Value()).Length(); } } nbStates += aKTool->GetStates(aMechanism).Length(); @@ -1822,6 +1842,7 @@ void XDEDRAW_Kinematics::InitCommands(Draw_Interpretor& di) "\tScrew - Pitch\n" "\tRackAndPinion - PinionRadius\n" "\tGear -FirstLinkRadius SecondLinkRadius Bevel HelicalAngle GearRatio \n" + "\tLinear - SkewAngle \n" __FILE__, setParameters, g); di.Add("XGetPairParams", "XGetPairParams Doc Joint", diff --git a/tests/gdt/kinematics/A1 b/tests/gdt/kinematics/A1 index a9db18cf0f..8d45cdb63c 100644 --- a/tests/gdt/kinematics/A1 +++ b/tests/gdt/kinematics/A1 @@ -2,9 +2,8 @@ # Test scenario for kinematics #============================== - ReadStep D [locate_data_file as1-oc-214.stp] # Load document with shape structure -# ReadStep D C:/Work/files/as1.stp +ReadStep D [locate_data_file as1-oc-214.stp] # Add parent mechanism set mech [XAddMechanism D] diff --git a/tests/gdt/kinematics_export/A1 b/tests/gdt/kinematics_export/bug31388_1 similarity index 94% rename from tests/gdt/kinematics_export/A1 rename to tests/gdt/kinematics_export/bug31388_1 index 7bbf95c9b8..538c342142 100644 --- a/tests/gdt/kinematics_export/A1 +++ b/tests/gdt/kinematics_export/bug31388_1 @@ -1,5 +1,5 @@ # !!!! This file is generated automatically, do not edit manually! See end script -set filename chuck_3_jaw_AP242_v2.stp +set filename bug31388_1.stp set ref_data { diff --git a/tests/gdt/kinematics_export/A2 b/tests/gdt/kinematics_export/bug31388_2 similarity index 94% rename from tests/gdt/kinematics_export/A2 rename to tests/gdt/kinematics_export/bug31388_2 index 7a3daec194..3e8b4a4bc8 100644 --- a/tests/gdt/kinematics_export/A2 +++ b/tests/gdt/kinematics_export/bug31388_2 @@ -1,5 +1,5 @@ # !!!! This file is generated automatically, do not edit manually! See end script -set filename mazak_kinematic_v3.stp +set filename bug31388_2.stp set ref_data { diff --git a/tests/gdt/kinematics_export/end b/tests/gdt/kinematics_export/end index 6d8d5dca7c..31101d3ab2 100644 --- a/tests/gdt/kinematics_export/end +++ b/tests/gdt/kinematics_export/end @@ -99,7 +99,7 @@ if { $mist < 1} { 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 {NbOfRefShapes +: +[(] +([-0-9.+eE]+) +[)]} $xst2 full nbRefShape_Second 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 -- 2.39.5