From: dpasukhi Date: Tue, 11 Aug 2020 14:43:40 +0000 (+0300) Subject: 0031388: Data Exchange - support kinematics data in STEP format X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=e9e75d963e75a3dfcccc236f8c98303a9f29480a;p=occt-copy.git 0031388: Data Exchange - support kinematics data in STEP format - Fix warning --- diff --git a/dox/user_guides/draw_test_harness/draw_test_harness.md b/dox/user_guides/draw_test_harness/draw_test_harness.md index 33e3b2e9cf..2b0225a34d 100644 --- a/dox/user_guides/draw_test_harness/draw_test_harness.md +++ b/dox/user_guides/draw_test_harness/draw_test_harness.md @@ -11169,7 +11169,7 @@ XGetPairValues D 0:11:1:3:1:1 -rotation == 1 ~~~~~ -@subsubsection occt_draw_8_10_37 XRemovePairValues +@subsubsection occt_draw_8_10_38 XRemovePairValues Syntax: ~~~~~ diff --git a/dox/user_guides/xde/xde.md b/dox/user_guides/xde/xde.md index 19e90587a5..3482095b05 100644 --- a/dox/user_guides/xde/xde.md +++ b/dox/user_guides/xde/xde.md @@ -148,7 +148,7 @@ Notes API provides the following functionality: @subsection occt_xde_1_11 Kinematics Kinematic data storage is realized according to ISO 10303-105:2019(E) and STEP Schema AP242 2019 year. -All kinematic data is divided onto mechanisms each mechanism has its graph of links (references to shapes), joints (kinematic pair information) and (optional) states(sets of kinematic values). +All kinematic data is divided onto mechanisms each mechanism has its graph of links (references to shapes), joints (kinematic pair information) and (optional) states (sets of kinematic values). Each joint corresponds to one kinematic pair from the list: * Low order pairs - fully constrained pair (no DOF); @@ -182,7 +182,7 @@ The kinematic pair information consists of The kinematic value consist of * reference to joint; -* paramters; +* parameters. All mentioned data depends on the kinematic pair type. @@ -1102,16 +1102,15 @@ All these methods except for the last one break all links with Document items as @subsection occt_xde_2_11 Kinematics -In XDE Document Kinematics is managed via *XCAFDoc_KinematicTool*. The Kinematic pair entities are described by two attributes -*XCAFDoc_KinematicPair* and *XCAFDoc_KinematicPairValue (optional)*. The second attribute is a dependant attribute, -it cannot be assigned to label without the main attribute or to a label with the main attribute of another kinematic pair type. +In XDE Document Kinematics is managed via *XCAFDoc_KinematicTool*. @subsubsection occt_xde_2_11_1 Creation All kinematic data refers to the mechanism, so, first of all, it needs to *AddMechanism*, this method creates a new mechanism and two empty subfolders for links and joints. The next step is specifying of links (mechanism details) via *AddLink* and *SetLink* commands. -The last step of kinematic graph creation is adding of joints with using *AddJoint* and *SetJoint* commands. +The next step is adding of joints with using *AddJoint* and *SetJoint* commands. +The last step of kinematic graph creationp is specifying of states (optional) via *AddState*, *AddValue* and *SetValue* commands. Here is an example of creating a new mechanism and adding a new joint with two links: ~~~~~ @@ -1147,6 +1146,7 @@ Commands to check that created labels are valid: - *IsLink* : checking for references to shape of the given link; - *IsJoint* : checking for references to end and start link of the given joint; - *IsValue* : checking for conteined assigning data. +- *IsState* : checking for main label of value; To retrieve current graph state use the next methods: - *GetMechanisms* : retrieves all mechanisms labels; diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index fa7192968a..2053eee083 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -4350,8 +4350,7 @@ Standard_Boolean addLinkWithShapes(const Handle(XSControl_WorkSession)& theWS, } if (aCDKLR.IsNull()) continue; - Handle(StepRepr_PropertyDefinition) aPD = - Handle(StepRepr_PropertyDefinition)::DownCast(aCDKLR->RepresentedProductRelation()); + Handle(StepRepr_PropertyDefinition) aPD = aCDKLR->RepresentedProductRelation(); if (aPD.IsNull()) continue; TDF_Label aShapeLabel; @@ -4561,7 +4560,7 @@ Standard_Boolean setKinematicPairLimit(const Handle(StepKinematics_KinematicPair anObj->SetUpperLimitPitch(aPointOnSurfacePairWithRange->UpperLimitPitch()); anObj->SetLowLimitRoll(aPointOnSurfacePairWithRange->LowerLimitRoll()); anObj->SetUpperLimitRoll(aPointOnSurfacePairWithRange->UpperLimitRoll()); - anObj->SetTrimmedSurface(StepToGeom::MakeRectangularTrimmedSurface(aPointOnSurfacePairWithRange->RangeOnPairSurface())); + anObj->SetSurface(StepToGeom::MakeSurface(aPointOnSurfacePairWithRange->RangeOnPairSurface())); } else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePairWithRange))) { @@ -4572,7 +4571,7 @@ Standard_Boolean setKinematicPairLimit(const Handle(StepKinematics_KinematicPair anObj->SetUpperLimitPitch(aPointOnPlanarCurvePairWithRange->UpperLimitPitch()); anObj->SetLowLimitRoll(aPointOnPlanarCurvePairWithRange->LowerLimitRoll()); anObj->SetUpperLimitRoll(aPointOnPlanarCurvePairWithRange->UpperLimitRoll()); - anObj->SetTrimmedCurve(StepToGeom::MakeTrimmedCurve(aPointOnPlanarCurvePairWithRange->RangeOnPairCurve())); + anObj->SetCurve(StepToGeom::MakeCurve(aPointOnPlanarCurvePairWithRange->RangeOnPairCurve())); } else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_PlanarCurvePairRange))) { @@ -4692,7 +4691,7 @@ Handle(XCAFKinematics_PairObject) createXCAFKinematicPairObject(const Handle(Ste else if (theKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPlanarCurvePair))) { Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair) aLinearFlexibleAndPlanarCurvePair = Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair)::DownCast(theKP); - aHighOrderPairObject->SetFirstCurve(StepToGeom::MakeCurve(aLinearFlexibleAndPlanarCurvePair->PairCurve())); + aHighOrderPairObject->SetCurve(StepToGeom::MakeCurve(aLinearFlexibleAndPlanarCurvePair->PairCurve())); aHighOrderPairObject->SetOrientation(aLinearFlexibleAndPlanarCurvePair->Orientation()); } } diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index 87b6f372be..72b9026993 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -22,9 +22,7 @@ #include #include -#include #include -#include #include #include #include @@ -301,7 +299,6 @@ #include #include #include -#include #include #include #include @@ -2304,9 +2301,7 @@ static Standard_Boolean createKinematicLink(const Handle(XSControl_WorkSession)& //function : createKinematicJoint //purpose : auxilary //======================================================================= -static Standard_Boolean createKinematicJoint(const Handle(Transfer_FinderProcess)& theFP, - const Handle(XCAFDoc_KinematicTool)& theKTool, - const Interface_Graph& theGraph, +static Standard_Boolean createKinematicJoint(const Handle(XCAFDoc_KinematicTool)& theKTool, const TDF_Label& theLabelJoint, const Handle(XCAFKinematics_PairObject)& theKinPairObj, const NCollection_IndexedDataMap& theMapOfLinks, @@ -2732,32 +2727,31 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje { case(XCAFKinematics_PairType_PointOnSurface): { - if (isRanged) + GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface()); + Handle(StepGeom_Surface) aPairSurface = aMaker.Value(); + if (isRanged && !aPairSurface.IsNull() && + aPairSurface->IsKind(STANDARD_TYPE(StepGeom_RectangularTrimmedSurface))) { - GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface()); - Handle(StepGeom_Surface) aPairSurface = aMaker.Value(); Standard_Real aLowerLimitYaw = aHighOrderPairObject->LowLimitYaw(); Standard_Real aUpperLimitYaw = aHighOrderPairObject->UpperLimitYaw(); Standard_Real aLowerLimitPitch = aHighOrderPairObject->LowLimitPitch(); Standard_Real aUpperLimitPitch = aHighOrderPairObject->UpperLimitPitch(); Standard_Real aLowerLimitRoll = aHighOrderPairObject->LowLimitRoll(); Standard_Real aUpperLimitRoll = aHighOrderPairObject->UpperLimitRoll(); - GeomToStep_MakeRectangularTrimmedSurface aMakerTrimmered(aHighOrderPairObject->TrimmedSurface()); - Handle(StepGeom_RectangularTrimmedSurface) aRangeOnPairSurface = aMakerTrimmered.Value(); + GeomToStep_MakeSurface aMakerSurface(aHighOrderPairObject->Surface()); + Handle(StepGeom_RectangularTrimmedSurface) aRangeOnPairSurface = Handle(StepGeom_RectangularTrimmedSurface)::DownCast(aMakerSurface.Value()); theKinematicPair = new StepKinematics_PointOnSurfacePairWithRange; Handle(StepKinematics_PointOnSurfacePairWithRange) aPointOnSurfacePairWithRange = Handle(StepKinematics_PointOnSurfacePairWithRange)::DownCast(theKinematicPair); aPointOnSurfacePairWithRange->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, aPairSurface,aRangeOnPairSurface, Standard_True, aLowerLimitYaw, Standard_True, aUpperLimitYaw, Standard_True, aLowerLimitPitch, Standard_True, aUpperLimitPitch, Standard_True, aLowerLimitRoll, Standard_True, aUpperLimitRoll); } - else + else { theKinematicPair = new StepKinematics_PointOnSurfacePair; - GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface()); - Handle(StepGeom_Surface) aPairSurface = aMaker.Value(); Handle(StepKinematics_PointOnSurfacePair) aPointOnSurface = Handle(StepKinematics_PointOnSurfacePair)::DownCast(theKinematicPair); aPointOnSurface->Init(aPairName, aPairName, hasDescription, - aDescription, theTransformItem1, theTransformItem2, theJoint,aPairSurface); + aDescription, theTransformItem1, theTransformItem2, theJoint, aPairSurface); } break; } @@ -2792,41 +2786,21 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje GeomToStep_MakeCurve aMaker(aHighOrderPairObject->Curve()); Handle(StepGeom_Curve) aPairCurve = aMaker.Value(); Standard_Boolean anOrientation = aHighOrderPairObject->Orientation(); - if (isRanged) + if (isRanged && !aPairCurve.IsNull() && + aPairCurve->IsKind(STANDARD_TYPE(StepGeom_TrimmedCurve))) { Standard_Real aLowerLimitYaw = aHighOrderPairObject->LowLimitYaw(); Standard_Real aUpperLimitYaw = aHighOrderPairObject->UpperLimitYaw(); Standard_Real aLowerLimitPitch = aHighOrderPairObject->LowLimitPitch(); Standard_Real aUpperLimitPitch = aHighOrderPairObject->UpperLimitPitch(); Standard_Real aLowerLimitRoll = aHighOrderPairObject->LowLimitRoll(); - Standard_Real aUpperLimitRoll = aHighOrderPairObject->UpperLimitRoll(); - Handle(Geom_TrimmedCurve) aRangeOnCurve = aHighOrderPairObject->TrimmedCurve(); - Handle(StepGeom_HArray1OfTrimmingSelect) aSTS1 = - new StepGeom_HArray1OfTrimmingSelect(1, 2); - StepGeom_TrimmingSelect tSel; - GeomToStep_MakeCartesianPoint aMP1(aRangeOnCurve->StartPoint()); - tSel.SetValue(aMP1.Value()); - aSTS1->SetValue(1, tSel); - tSel.SetParameterValue(aRangeOnCurve->FirstParameter()); - aSTS1->SetValue(2, tSel); - - Handle(StepGeom_HArray1OfTrimmingSelect) aSTS2 = - new StepGeom_HArray1OfTrimmingSelect(1, 2); - GeomToStep_MakeCartesianPoint aMP2(aRangeOnCurve->EndPoint()); - tSel.SetValue(aMP2.Value()); - aSTS2->SetValue(1, tSel); - tSel.SetParameterValue(aRangeOnCurve->LastParameter()); - aSTS2->SetValue(2, tSel); - - Handle(TCollection_HAsciiString) empty = - new TCollection_HAsciiString(""); - Handle(StepGeom_TrimmedCurve) aRangeOnPairCurve = new StepGeom_TrimmedCurve; - aRangeOnPairCurve->Init(empty, aPairCurve, aSTS1, aSTS2, Standard_True, StepGeom_tpParameter); + Standard_Real aUpperLimitRoll = aHighOrderPairObject->UpperLimitRoll(); + Handle(StepGeom_TrimmedCurve) aRangeOnPairCurve = Handle(StepGeom_TrimmedCurve)::DownCast(aPairCurve); theKinematicPair = new StepKinematics_PointOnPlanarCurvePairWithRange; Handle(StepKinematics_PointOnPlanarCurvePairWithRange) aPointOnPlanarCurvePairWithRange = Handle(StepKinematics_PointOnPlanarCurvePairWithRange)::DownCast(theKinematicPair); aPointOnPlanarCurvePairWithRange->Init(aPairName, aPairName, hasDescription, - aDescription, theTransformItem1, theTransformItem2, theJoint, aPairCurve, anOrientation, aRangeOnPairCurve,Standard_True,aLowerLimitYaw, Standard_True,aUpperLimitYaw, Standard_True, - aLowerLimitPitch, Standard_True, aUpperLimitPitch, Standard_True,aLowerLimitRoll, Standard_True, aUpperLimitRoll); + aDescription, theTransformItem1, theTransformItem2, theJoint, aPairCurve, anOrientation, aRangeOnPairCurve, Standard_True, aLowerLimitYaw, Standard_True, aUpperLimitYaw, Standard_True, + aLowerLimitPitch, Standard_True, aUpperLimitPitch, Standard_True, aLowerLimitRoll, Standard_True, aUpperLimitRoll); } else { @@ -2866,7 +2840,7 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje case(XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve): { theKinematicPair = new StepKinematics_LinearFlexibleAndPlanarCurvePair; - GeomToStep_MakeCurve aMaker(aHighOrderPairObject->FirstCurve()); + GeomToStep_MakeCurve aMaker(aHighOrderPairObject->Curve()); Handle(StepGeom_Curve) aPairCurve = aMaker.Value(); Standard_Boolean anOrientation = aHighOrderPairObject->Orientation(); Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair) aLinearFlexibleAndPlanarCurvePair = Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair)::DownCast(theKinematicPair); @@ -3109,7 +3083,7 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai break; } Handle(StepKinematics_KinematicPair) aAppliesToPair = - Handle(StepKinematics_KinematicPair)::DownCast(thePairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); + thePairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair(); thePairValue->SetAppliesToPair(aAppliesToPair); thePairValue->SetName(aAppliesToPair->Name()); return Standard_True; @@ -3126,8 +3100,6 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha // get working data const Handle(Interface_InterfaceModel)& Model = theWS->Model(); - const Handle(XSControl_TransferWriter)& TW = theWS->TransferWriter(); - const Handle(Transfer_FinderProcess)& FP = TW->FinderProcess(); const Handle(Interface_HGraph) aHGraph = theWS->HGraph(); if (aHGraph.IsNull()) @@ -3196,7 +3168,7 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha Handle(XCAFKinematics_PairObject) aPairObject = aKPairAttr->GetObject(); Handle(StepKinematics_KinematicLinkRepresentation) aLinkRepr1; Handle(StepKinematics_KinematicLinkRepresentation) aLinkRepr2; - if (!createKinematicJoint(FP, aKTool, aGraph, aJointL, aPairObject, aMapOfLinks, aLinkRepr1, aLinkRepr2, aJoint)) + if (!createKinematicJoint(aKTool, aJointL, aPairObject, aMapOfLinks, aLinkRepr1, aLinkRepr2, aJoint)) continue; if (!createKinematicPair(aPairObject,aJoint,aKinematicPair, aLinkRepr1, aLinkRepr2)) continue; diff --git a/src/StepRepr/StepRepr_Transformation.cxx b/src/StepRepr/StepRepr_Transformation.cxx index 576bd0e808..cef0c9c643 100644 --- a/src/StepRepr/StepRepr_Transformation.cxx +++ b/src/StepRepr/StepRepr_Transformation.cxx @@ -47,6 +47,6 @@ Handle(StepKinematics_KinematicPair) StepRepr_Transformation::KinematicPair() co Handle(StepKinematics_ActuatedKinPairAndOrderKinPair) aComplexPair = GetCasted(StepKinematics_ActuatedKinPairAndOrderKinPair, Value()); if (aComplexPair.IsNull()) return GetCasted(StepKinematics_KinematicPair, Value()); - return GetCasted(StepKinematics_KinematicPair, aComplexPair->GetOrderKinematicPair()); + return aComplexPair->GetOrderKinematicPair(); } diff --git a/src/StepToGeom/StepToGeom.cxx b/src/StepToGeom/StepToGeom.cxx index b0eba23c0c..c4e0889200 100644 --- a/src/StepToGeom/StepToGeom.cxx +++ b/src/StepToGeom/StepToGeom.cxx @@ -211,7 +211,7 @@ Handle(Geom_Axis2Placement) StepToGeom::MakeAxis2Placement (const Handle(StepGeo } //============================================================================= -// Creation d' un AxisPlacement de Geom2d a partir d' un SuParameters de Step +// Creation of an AxisPlacement from a Kinematic SuParameters for Step //============================================================================= Handle(Geom_Axis2Placement) StepToGeom::MakeAxis2Placement(const Handle(StepKinematics_SuParameters)& SP) @@ -2071,7 +2071,7 @@ Handle(Geom2d_VectorWithMagnitude) StepToGeom::MakeVectorWithMagnitude2d (const } //============================================================================= -// Creation d' un YptRotation de Kinematic a partir d' un SpatialRotation de Step +// Creation of a YptRotation from a Kinematic SpatialRotation for Step //============================================================================= Handle(TColStd_HArray1OfReal) StepToGeom::MakeYprRotation(const StepKinematics_SpatialRotation& SR, const Handle(StepRepr_GlobalUnitAssignedContext)& theCntxt) @@ -2080,10 +2080,7 @@ Handle(TColStd_HArray1OfReal) StepToGeom::MakeYprRotation(const StepKinematics_S Handle(TColStd_HArray1OfReal) anYPRRotation; if (!SR.YprRotation().IsNull() && SR.YprRotation()->Length() == 3) - { - anYPRRotation = SR.YprRotation(); - return anYPRRotation; - } + return SR.YprRotation(); if (SR.RotationAboutDirection().IsNull() || SR.RotationAboutDirection()->DirectionOfAxis()->DirectionRatios()->Length() != 3 || @@ -2152,7 +2149,7 @@ Handle(TColStd_HArray1OfReal) StepToGeom::MakeYprRotation(const StepKinematics_S anYPRRotation->SetValue(1, 0.); anYPRRotation->SetValue(2, 0.); anYPRRotation->SetValue(3, 0.); - if (dx != 0.) + if (Abs(dx) >= Precision::Confusion()) if (dx > 0.) anYPRRotation->SetValue(3, aYaw); else diff --git a/src/XCAFDoc/XCAFDoc_KinematicPair.cxx b/src/XCAFDoc/XCAFDoc_KinematicPair.cxx index 8e0cc99972..ad72c5b528 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicPair.cxx +++ b/src/XCAFDoc/XCAFDoc_KinematicPair.cxx @@ -153,10 +153,7 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t if (theObject->Type() == XCAFKinematics_PairType_PointOnSurface && !anObject->Surface().IsNull()) { TopoDS_Face aFace; - if (anObject->HasLimits()) - aBuilder.MakeFace(aFace, anObject->TrimmedSurface(), Precision::Confusion()); - else - aBuilder.MakeFace(aFace, anObject->Surface(), Precision::Confusion()); + aBuilder.MakeFace(aFace, anObject->Surface(), Precision::Confusion()); TNaming_Builder aTNBuild(Label().FindChild(ChildLab_FirstGeomParam)); aTNBuild.Generated(aFace); } @@ -175,18 +172,16 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t aTNBuild2.Generated(aFace2); } } - if (theObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve && !anObject->Curve().IsNull()) + if ((theObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve || + theObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) && !anObject->Curve().IsNull()) { TopoDS_Edge anEdge; - if (anObject->HasLimits()) - aBuilder.MakeEdge(anEdge, anObject->TrimmedCurve(), Precision::Confusion()); - else - aBuilder.MakeEdge(anEdge, anObject->Curve(), Precision::Confusion()); + aBuilder.MakeEdge(anEdge, anObject->Curve(), Precision::Confusion()); TNaming_Builder aTNBuild(Label().FindChild(ChildLab_FirstGeomParam)); aTNBuild.Generated(anEdge); } - if (anObject->Type() >= XCAFKinematics_PairType_SlidingCurve && - anObject->Type() <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) + if (anObject->Type() == XCAFKinematics_PairType_SlidingCurve || + anObject->Type() == XCAFKinematics_PairType_RollingCurve) { TopoDS_Edge anEdge1, anEdge2; if (!anObject->FirstCurve().IsNull()) { @@ -308,7 +303,8 @@ Handle(XCAFKinematics_PairObject) XCAFDoc_KinematicPair::GetObject() const aDefObject->SetSecondSurface(BRep_Tool::Surface(aFace)); } } - if (anObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve) + if (anObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve || + anObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) { if (Label().FindChild(ChildLab_FirstGeomParam).FindAttribute(TNaming_NamedShape::GetID(), aNS)) { @@ -333,15 +329,6 @@ Handle(XCAFKinematics_PairObject) XCAFDoc_KinematicPair::GetObject() const aDefObject->SetSecondCurve(BRep_Tool::Curve(anEdge, aFirst, aLast)); } } - if (anObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) - { - if (Label().FindChild(ChildLab_FirstGeomParam).FindAttribute(TNaming_NamedShape::GetID(), aNS)) - { - TopoDS_Edge anEdge = TopoDS::Edge(TNaming_Tool::GetShape(aNS)); - Standard_Real aFirst, aLast; - aDefObject->SetFirstCurve(BRep_Tool::Curve(anEdge, aFirst, aLast)); - } - } } return anObject; diff --git a/src/XCAFDoc/XCAFDoc_KinematicPairValue.hxx b/src/XCAFDoc/XCAFDoc_KinematicPairValue.hxx index 78fef40bb8..8bb1324d8a 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicPairValue.hxx +++ b/src/XCAFDoc/XCAFDoc_KinematicPairValue.hxx @@ -38,8 +38,7 @@ DEFINE_STANDARD_HANDLE(XCAFDoc_KinematicPairValue, TDF_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 this attribute not of the same type as the type of the pair +//! - to store this attribute not of the same type as the type of linked the pair class XCAFDoc_KinematicPairValue : public TDF_Attribute { diff --git a/src/XCAFDoc/XCAFDoc_KinematicTool.cxx b/src/XCAFDoc/XCAFDoc_KinematicTool.cxx index 86b9364f91..982f34456a 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicTool.cxx +++ b/src/XCAFDoc/XCAFDoc_KinematicTool.cxx @@ -251,6 +251,8 @@ Standard_EXPORT Standard_Boolean XCAFDoc_KinematicTool::SetBaseLink(const TDF_La (!aLinkName.IsNull() && !aLinkName->Get().IsDifferent("Link " + theLink.Tag()))) TDataStd_Name::Set(theLink, "Base"); TDataStd_Integer::Set(theLink, 1); + + return Standard_True; } //======================================================================= diff --git a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx index 12f1830fbd..ab02eb8019 100644 --- a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx +++ b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx @@ -328,7 +328,7 @@ Standard_Real XCAFKinematics_HighOrderPairObject::UpperLimitPitch() //======================================================================= void XCAFKinematics_HighOrderPairObject::SetCurve(const Handle(Geom_Curve)& theCurve) { - if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve) + if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) myGeom.ChangeFirst() = theCurve; } @@ -338,16 +338,8 @@ void XCAFKinematics_HighOrderPairObject::SetCurve(const Handle(Geom_Curve)& theC //======================================================================= Handle(Geom_Curve) XCAFKinematics_HighOrderPairObject::Curve() const { - if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve && !myGeom.First().IsNull()) - { - if (myGeom.First()->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) - { - Handle(Geom_TrimmedCurve) aTrimCurve = Handle(Geom_TrimmedCurve)::DownCast(myGeom.First()); - return aTrimCurve->BasisCurve(); - } - else - return Handle(Geom_Curve)::DownCast(myGeom.First()); - } + if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) + return Handle(Geom_Curve)::DownCast(myGeom.First()); return NULL; } @@ -357,7 +349,7 @@ Handle(Geom_Curve) XCAFKinematics_HighOrderPairObject::Curve() const //======================================================================= void XCAFKinematics_HighOrderPairObject::SetFirstCurve(const Handle(Geom_Curve)& theCurve) { - if (Type() >= XCAFKinematics_PairType_SlidingCurve && Type() <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) + if (Type() == XCAFKinematics_PairType_SlidingCurve || Type() == XCAFKinematics_PairType_RollingCurve) myGeom.ChangeFirst() = theCurve; } @@ -367,7 +359,7 @@ void XCAFKinematics_HighOrderPairObject::SetFirstCurve(const Handle(Geom_Curve)& //======================================================================= Handle(Geom_Curve) XCAFKinematics_HighOrderPairObject::FirstCurve() const { - if (Type() >= XCAFKinematics_PairType_SlidingCurve && Type() <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) + if (Type() == XCAFKinematics_PairType_SlidingCurve || Type() == XCAFKinematics_PairType_RollingCurve) return Handle(Geom_Curve)::DownCast(myGeom.First()); return NULL; } @@ -393,28 +385,6 @@ Handle(Geom_Curve) XCAFKinematics_HighOrderPairObject::SecondCurve() const return NULL; } -//======================================================================= -//function : SetTrimmedCurve -//purpose : -//======================================================================= -void XCAFKinematics_HighOrderPairObject::SetTrimmedCurve(const Handle(Geom_TrimmedCurve)& aTrimCurve) -{ - if (Type() != XCAFKinematics_PairType_PointOnPlanarCurve && !HasLimits()) - return; - myGeom.ChangeFirst() = aTrimCurve; -} - -//======================================================================= -//function : TrimmedCurve -//purpose : -//======================================================================= -Handle(Geom_TrimmedCurve) XCAFKinematics_HighOrderPairObject::TrimmedCurve() const -{ - if (Type() != XCAFKinematics_PairType_PointOnPlanarCurve) - return NULL; - return Handle(Geom_TrimmedCurve)::DownCast(myGeom.First()); -} - //======================================================================= //function : SetSurface //purpose : @@ -432,13 +402,7 @@ void XCAFKinematics_HighOrderPairObject::SetSurface(const Handle(Geom_Surface)& Handle(Geom_Surface) XCAFKinematics_HighOrderPairObject::Surface() const { if (Type() == XCAFKinematics_PairType_PointOnSurface) - if (!myGeom.First().IsNull() && myGeom.First()->IsKind(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) - { - Handle(Geom_RectangularTrimmedSurface) aTrimSurface = Handle(Geom_RectangularTrimmedSurface)::DownCast(myGeom.First()); - return aTrimSurface->BasisSurface(); - } - else - return Handle(Geom_Surface)::DownCast(myGeom.First()); + return Handle(Geom_Surface)::DownCast(myGeom.First()); return NULL; } @@ -483,25 +447,3 @@ Handle(Geom_Surface) XCAFKinematics_HighOrderPairObject::SecondSurface() const return Handle(Geom_Surface)::DownCast(myGeom.Last()); return NULL; } - -//======================================================================= -//function : SetTrimmedSurface -//purpose : -//======================================================================= -void XCAFKinematics_HighOrderPairObject::SetTrimmedSurface(const Handle(Geom_RectangularTrimmedSurface)& aTrimSurface) -{ - if (Type() != XCAFKinematics_PairType_PointOnSurface && !HasLimits()) - return; - myGeom.ChangeFirst() = aTrimSurface; -} - -//======================================================================= -//function : TrimmedSurface -//purpose : -//======================================================================= -Handle(Geom_RectangularTrimmedSurface) XCAFKinematics_HighOrderPairObject::TrimmedSurface() const -{ - if (Type() != XCAFKinematics_PairType_PointOnSurface) - return NULL; - return Handle(Geom_RectangularTrimmedSurface)::DownCast(myGeom.First()); -} diff --git a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx index a8f56a2ec3..6a636c6f93 100644 --- a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx +++ b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx @@ -135,19 +135,19 @@ public: //! \return limit Standard_EXPORT Standard_Real UpperLimitPitch(); - //! Sets curve attribute (only for PointOnPlanarCurve) + //! Sets curve attribute (only for PointOnPlanarCurve and LinearAndFlexibleCurve) //! \param[in] theCurve curve Standard_EXPORT void SetCurve(const Handle(Geom_Curve)& theCurve); - //! Gets curve attribute (only for PointOnPlanarCurve) + //! Gets curve attribute (only for PointOnPlanarCurve and LinearAndFlexibleCurve) //! \return curve Standard_EXPORT Handle(Geom_Curve) Curve() const; - //! Sets curve attribute (only for SlidingCurve, RollingCurve LinearAndFlexibleCurve) + //! Sets curve attribute (only for SlidingCurve and RollingCurve) //! \param[in] theCurve curve Standard_EXPORT void SetFirstCurve(const Handle(Geom_Curve)& theCurve); - //! Gets curve attribute (only for SlidingCurve, RollingCurve LinearAndFlexibleCurve) + //! Gets curve attribute (only for SlidingCurve and RollingCurve) //! \return curve Standard_EXPORT Handle(Geom_Curve) FirstCurve() const; @@ -159,14 +159,6 @@ public: //! \return curve Standard_EXPORT Handle(Geom_Curve) SecondCurve() const; - //! Sets trimmed curve attribute (only for PointOnCurve) - //! \param[in] aTrimCurve trimmed curve - Standard_EXPORT void SetTrimmedCurve(const Handle(Geom_TrimmedCurve)& aTrimCurve); - - //! Gets trimmed curve attribute (only for PointOnCurve) - //! \return trimmed curve - Standard_EXPORT Handle(Geom_TrimmedCurve) TrimmedCurve() const; - //! Sets surface attribute (only for PointOnSurface) //! \param[in] theSurface surface Standard_EXPORT void SetSurface(const Handle(Geom_Surface)& theSurface); @@ -191,14 +183,6 @@ public: //! \return surface Standard_EXPORT Handle(Geom_Surface) SecondSurface() const; - //! Sets trimmed surface attribute (only for PointOnSurface) - //! \param[in] aTrimSurface trimmered surface - Standard_EXPORT void SetTrimmedSurface(const Handle(Geom_RectangularTrimmedSurface)& aTrimSurface); - - //! Gets trimmed surface attribute (only for PointOnSurface) - //! \return trimmed surface - Standard_EXPORT Handle(Geom_RectangularTrimmedSurface) TrimmedSurface() const; - DEFINE_STANDARD_RTTIEXT(XCAFKinematics_HighOrderPairObject, XCAFKinematics_PairObject) private: diff --git a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx index ca8a488ae7..9d0c72e77f 100644 --- a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx +++ b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx @@ -194,13 +194,13 @@ public: void SetSkewAngle(const Standard_Real theAngle) { - if (Type() == XCAFKinematics_PairType_Universal || XCAFKinematics_PairType_Homokinetic) + if (Type() == XCAFKinematics_PairType_Universal || Type() == XCAFKinematics_PairType_Homokinetic) mySkewAngle = theAngle; } Standard_Real SkewAngle() const { - if (Type() == XCAFKinematics_PairType_Universal || XCAFKinematics_PairType_Homokinetic) + if (Type() == XCAFKinematics_PairType_Universal || Type() == XCAFKinematics_PairType_Homokinetic) return mySkewAngle; else return 0; } diff --git a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx index 62d4c73a07..86bbaf3080 100644 --- a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx +++ b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx @@ -27,6 +27,7 @@ DEFINE_STANDARD_HANDLE(XCAFKinematics_LowOrderPairObjectWithCoupling, XCAFKinema //! - XCAFKinematics_PairType_Screw //! - XCAFKinematics_PairType_RackAndPinion //! - XCAFKinematics_PairType_Gear +//! - XCAFKinematics_PairType_LinearFlexibleAndPinion class XCAFKinematics_LowOrderPairObjectWithCoupling : public XCAFKinematics_PairObject { diff --git a/src/XDEDRAW/XDEDRAW_Kinematics.cxx b/src/XDEDRAW/XDEDRAW_Kinematics.cxx index 6660099750..0b8bd059ee 100644 --- a/src/XDEDRAW/XDEDRAW_Kinematics.cxx +++ b/src/XDEDRAW/XDEDRAW_Kinematics.cxx @@ -1155,10 +1155,9 @@ static Standard_Integer setGeomParam(Draw_Interpretor& di, Standard_Integer argc di << "Invalid geometric argument\n"; return 1; } - if (anObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve) + if (anObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve || + anObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) anObject->SetCurve(aCurve); - else if (anObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) - anObject->SetFirstCurve(aCurve); else { switch (aParamNb) { case 1: anObject->SetFirstCurve(aCurve); @@ -1215,10 +1214,7 @@ static Standard_Integer getGeomParam(Draw_Interpretor& di, Standard_Integer argc // Surface Handle(Geom_Surface) aSurface; if (anObject->Type() == XCAFKinematics_PairType_PointOnSurface) - if (!anObject->HasLimits()) - aSurface = anObject->Surface(); - else - aSurface = anObject->TrimmedSurface(); + aSurface = anObject->Surface(); else { switch (aTrsfNb) { case 1: aSurface = anObject->FirstSurface(); @@ -1235,13 +1231,9 @@ static Standard_Integer getGeomParam(Draw_Interpretor& di, Standard_Integer argc else { // Curve Handle(Geom_Curve) aCurve; - if (anObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve) - if (!anObject->HasLimits()) - aCurve = anObject->Curve(); - else - aCurve = anObject->TrimmedCurve(); - else if(anObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) - aCurve = anObject->FirstCurve(); + if (anObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve || + anObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve) + aCurve = anObject->Curve(); else { switch (aTrsfNb) { case 1: aCurve = anObject->FirstCurve(); @@ -1841,8 +1833,8 @@ void XDEDRAW_Kinematics::InitCommands(Draw_Interpretor& di) di.Add("XSetPairParams", "XSetPairParams Doc Joint Value1 Value2..." "\tScrew - Pitch\n" "\tRackAndPinion - PinionRadius\n" - "\tGear -FirstLinkRadius SecondLinkRadius Bevel HelicalAngle GearRatio \n" - "\tLinear - SkewAngle \n" + "\tGear - FirstLinkRadius SecondLinkRadius Bevel HelicalAngle GearRatio\n" + "\tLinear - PinionRadius\n" __FILE__, setParameters, g); di.Add("XGetPairParams", "XGetPairParams Doc Joint",