//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<Handle(StepKinematics_KinematicLinkRepresentation), TDF_Label>& 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<Handle(StepKinematics_KinematicLinkRepresentation), TDF_Label>& theMapOfLinks,
+ const Standard_Boolean& theIsBase = Standard_False)
{
Handle(XSControl_TransferReader) aTR = theWS->TransferReader();
Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess();
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);
}
//=======================================================================
-//function : setPairValue
+//function : setKinematicPairValue
//purpose : set pair Value of the kinematic pair in OCAF
//=======================================================================
Standard_Boolean setKinematicPairValue(const Handle(XSControl_WorkSession)& theWS,
//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<TDF_Label, Handle(StepKinematics_KinematicLinkRepresentation), TDF_LabelMapHasher>& 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 ||
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;
}
//=======================================================================
}
case(XCAFKinematics_PairType_Planar):
{
- if (isRanged)
- theKinematicPair = new StepKinematics_PlanarPairWithRange;
- else
- theKinematicPair = new StepKinematics_PlanarPair;
-
aTZ = Standard_False;
aRX = Standard_False;
aRY = Standard_False;
}
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())
return Standard_False;
}
+//=======================================================================
+//function : createKinematicPairValue
+//purpose :
+//=======================================================================
static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_PairValueObject)& theKinPairValueObj,
const Handle(StepKinematics_PairRepresentationRelationship)& thePairReprRelationship,
Handle(StepKinematics_PairValue)& thePairValue)
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;
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;
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<TDF_Label, Handle(StepKinematics_KinematicLinkRepresentation), TDF_LabelMapHasher> 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;
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<TDF_Label, Handle(StepKinematics_KinematicJoint), TDF_LabelMapHasher> aMapofJoints;
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;
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);
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);
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);
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))
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);
#include <StepBasic_ConversionBasedUnitAndPlaneAngleUnit.hxx>
#include <StepBasic_SiUnitAndPlaneAngleUnit.hxx>
#include <StepRepr_GlobalUnitAssignedContext.hxx>
+#include <STEPConstruct_UnitContext.hxx>
#include <UnitsMethods.hxx>
//=============================================================================
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);
}
//=============================================================================
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<Handle(StepBasic_NamedUnit)> 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<Handle(StepBasic_NamedUnit)> 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;
}
return ID;
}
+//=======================================================================
+//function : KinematicRefJointGUID
+//purpose :
+//=======================================================================
Standard_EXPORT const Standard_GUID& XCAFDoc::KinematicRefJointGUID()
{
static const Standard_GUID ID("596B048C-A965-4514-A059-464560BFAE4E");
ChildLab_SecondTrsf,
ChildLab_FirstGeomParam,
ChildLab_SecondGeomParam,
- ChildLab_Value
};
//=======================================================================
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());
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());
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()) {
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);
- }
- }
}
}
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;
}
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
{
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);
}
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;
}
}
-Standard_Boolean XCAFDoc_KinematicTool::IsValue(const TDF_Label& theValue) const
-{
- Handle(XCAFDoc_KinematicPairValue) anAttr;
- return theValue.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), anAttr);
-}
-
//=======================================================================
//function : GetMechanisms
//purpose :
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 :
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()) {
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()) {
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);
//! \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
//! - XCAFKinematics_PairType_PointOnPlanarCurve
//! - XCAFKinematics_PairType_SlidingCurve
//! - XCAFKinematics_PairType_RollingCurve
-//! - XCAFKinematics_PairType_RollingCurve
//! - XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve
class XCAFKinematics_HighOrderPairObject : public XCAFKinematics_PairObject
{
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)
//! \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);
//! \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)
//! \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);
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 <F, F, F, F, F, F>
+//! - XCAFKinematics_PairType_Revolute <F, F, T, F, F, F>
+//! - XCAFKinematics_PairType_Prismatic <F, F, F, T, F, F>
+//! - XCAFKinematics_PairType_Cylindrical <F, F, T, F, F, T>
+//! - XCAFKinematics_PairType_Universal <T, F, T, F, F, F>
+//! - XCAFKinematics_PairType_Homokinetic <T, F, T, F, F, F>
+//! - XCAFKinematics_PairType_SphericalWithPin <F, T, T, F, F, F>
+//! - XCAFKinematics_PairType_Spherical <T, T, T, F, F, F>
+//! - XCAFKinematics_PairType_Planar <T, F, F, T, T, F>
+//! - XCAFKinematics_PairType_Unconstrained <T, T, T, T, T, T>
+//! Not all limits are used for each pair,
+//! values should be specified in alphabetical order: <rX, rY, rZ, tX, tY, tZ>
+
class XCAFKinematics_LowOrderPairObject : public XCAFKinematics_PairObject
{
Standard_Integer aNbParams = 0;
switch (myType) {
case XCAFKinematics_PairType_Revolute:
- aNbParams = 1;
- break;
+ aNbParams = 1;
+ break;
case XCAFKinematics_PairType_Prismatic:
aNbParams = 1;
break;
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);
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);
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
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;
}
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;
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";
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;
}
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;
}
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;
}
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)) {
}
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);
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)) {
// 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();
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;
}
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;
}
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;
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;
}
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) {
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))
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);
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())
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)
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)
nbHigeOrderPairsWithRange++;
else
nbHigeOrderPairs++;
- nbHigeOrderPairValues += aKTool->GetValuesOfJoint(aJoints.Value(aJointInd)).Length();
+ nbHigeOrderPairValues += aKTool->GetValuesOfJoint(anIt.Value()).Length();
}
}
nbStates += aKTool->GetStates(aMechanism).Length();
"\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",
# 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]
+++ /dev/null
-# !!!! 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 )
-}
+++ /dev/null
-# !!!! 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 )
-}
--- /dev/null
+# !!!! This file is generated automatically, do not edit manually! See end script
+set filename bug31388_1.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 )
+}
--- /dev/null
+# !!!! This file is generated automatically, do not edit manually! See end script
+set filename bug31388_2.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 )
+}
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