From 7ea7a35dba7413890985e90a5c4f95b6679c9d42 Mon Sep 17 00:00:00 2001 From: dpasukhi Date: Wed, 24 Jun 2020 13:22:56 +0300 Subject: [PATCH] 0031388: To support kinematics data in STEP format - Upgrade tests for current kinematic entities - Fix Write/Read Referenced shapes of link - Fix Write/Read pairs without limits(not ranged) - Fix choosing base kinematic link of mechanism - Fix set/get XCAFKinematics_HighOrderPairObject - SlidingSurface, RollingSurface, SlidingCurve, RollingCurve hasn't limits - PointOnPlanarCurve, PointOnSurface has only trimmed geometry, if limited --- ...atics_RWActuatedKinPairAndOrderKinPair.cxx | 6 +- ...atics_RWActuatedKinPairAndOrderKinPair.hxx | 4 +- ...ematics_RWMechanismStateRepresentation.cxx | 6 +- ...ematics_RWMechanismStateRepresentation.hxx | 7 +- ...nematics_RWPointOnPlanarCurvePairValue.cxx | 34 +- ...epKinematics_RWPointOnSurfacePairValue.cxx | 34 +- .../RWStepKinematics_RWSphericalPairValue.cxx | 44 +- src/STEPCAFControl/STEPCAFControl_Reader.cxx | 81 +- src/STEPCAFControl/STEPCAFControl_Writer.cxx | 885 +++++++++--------- src/STEPCAFControl/STEPCAFControl_Writer.hxx | 6 +- ...ematics_ActuatedKinPairAndOrderKinPair.cxx | 7 +- ...ematics_ActuatedKinPairAndOrderKinPair.hxx | 136 +-- ...inematics_MechanismStateRepresentation.cxx | 6 +- ...inematics_MechanismStateRepresentation.hxx | 6 +- src/XCAFDoc/XCAFDoc.cxx | 2 +- src/XCAFDoc/XCAFDoc_KinematicPair.cxx | 35 +- src/XCAFDoc/XCAFDoc_KinematicPairValue.cxx | 6 - src/XCAFDoc/XCAFDoc_KinematicTool.cxx | 201 ++-- src/XCAFDoc/XCAFDoc_KinematicTool.hxx | 43 +- .../XCAFKinematics_HighOrderPairObject.cxx | 113 ++- .../XCAFKinematics_HighOrderPairObject.hxx | 35 +- .../XCAFKinematics_LowOrderPairObject.cxx | 25 +- .../XCAFKinematics_LowOrderPairObject.hxx | 13 + ...ematics_LowOrderPairObjectWithCoupling.cxx | 13 +- ...ematics_LowOrderPairObjectWithCoupling.hxx | 3 + src/XDEDRAW/XDEDRAW_Kinematics.cxx | 57 +- tests/gdt/kinematics/A1 | 10 +- tests/gdt/kinematics/A2 | 29 +- tests/gdt/kinematics/A3 | 10 +- tests/gdt/kinematics/A4 | 10 +- tests/gdt/kinematics/A5 | 10 +- tests/gdt/kinematics/A6 | 12 +- tests/gdt/kinematics/A7 | 6 +- tests/gdt/kinematics/A8 | 10 +- tests/gdt/kinematics/A9 | 2 +- tests/gdt/kinematics/B1 | 2 +- tests/gdt/kinematics/B2 | 4 +- tests/gdt/kinematics/B3 | 4 +- tests/gdt/kinematics/B4 | 6 +- tests/gdt/kinematics/B5 | 18 +- tests/gdt/kinematics/B6 | 12 +- tests/gdt/kinematics/B7 | 12 +- tests/gdt/kinematics/B8 | 5 +- tests/gdt/kinematics/B9 | 6 +- tests/gdt/kinematics/C1 | 6 +- 45 files changed, 1035 insertions(+), 947 deletions(-) diff --git a/src/RWStepKinematics/RWStepKinematics_RWActuatedKinPairAndOrderKinPair.cxx b/src/RWStepKinematics/RWStepKinematics_RWActuatedKinPairAndOrderKinPair.cxx index 47c0fcf70f..12ad93a1cd 100644 --- a/src/RWStepKinematics/RWStepKinematics_RWActuatedKinPairAndOrderKinPair.cxx +++ b/src/RWStepKinematics/RWStepKinematics_RWActuatedKinPairAndOrderKinPair.cxx @@ -1,6 +1,6 @@ -// Created on: 2015-08-10 -// Created by: Irina KRYLOVA -// Copyright (c) 2015 OPEN CASCADE SAS +// Created on: 2020-05-26 +// Created by: PASUKHIN DMITRY +// Copyright (c) 2020 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // diff --git a/src/RWStepKinematics/RWStepKinematics_RWActuatedKinPairAndOrderKinPair.hxx b/src/RWStepKinematics/RWStepKinematics_RWActuatedKinPairAndOrderKinPair.hxx index 562479e21e..aedd840d30 100644 --- a/src/RWStepKinematics/RWStepKinematics_RWActuatedKinPairAndOrderKinPair.hxx +++ b/src/RWStepKinematics/RWStepKinematics_RWActuatedKinPairAndOrderKinPair.hxx @@ -1,5 +1,5 @@ -// Created on: 2015-08-10 -// Created by: Irina KRYLOVA +// Created on: 2020-05-26 +// Created by: PASUKHIN DMITRY // Copyright (c) 2015 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. diff --git a/src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.cxx b/src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.cxx index fed5c93f04..f6fd2a90a6 100644 --- a/src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.cxx +++ b/src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.cxx @@ -1,6 +1,6 @@ -// Created on: 2016-04-26 -// Created by: Irina KRYLOVA -// Copyright (c) 2016 OPEN CASCADE SAS +// Created on: 2020-06-18 +// Created by: PASUKHIN DMITRY +// Copyright (c) 2020 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // diff --git a/src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.hxx b/src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.hxx index 73660d3223..c227966a04 100644 --- a/src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.hxx +++ b/src/RWStepKinematics/RWStepKinematics_RWMechanismStateRepresentation.hxx @@ -1,7 +1,6 @@ -// Created on: 2016-04-26 -// Created on: 2016-04-26 -// Created by: Irina KRYLOVA -// Copyright (c) 2016 OPEN CASCADE SAS +// Created on: 2020-06-18 +// Created by: PASUKHIN DMITRY +// Copyright (c) 2020 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // diff --git a/src/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePairValue.cxx b/src/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePairValue.cxx index a9a8b2fd15..1a3a03ad0f 100644 --- a/src/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePairValue.cxx +++ b/src/RWStepKinematics/RWStepKinematics_RWPointOnPlanarCurvePairValue.cxx @@ -61,7 +61,24 @@ void RWStepKinematics_RWPointOnPlanarCurvePairValue::ReadStep (const Handle(Step data->ReadEntity (num, 3, "actual_point_on_curve", ach, STANDARD_TYPE(StepGeom_PointOnCurve), aActualPointOnCurve); StepKinematics_SpatialRotation aInputOrientation; - data->ReadEntity (num, 4, "input_orientation", ach, aInputOrientation); + if (data->SubListNumber(num, 4, Standard_True)) + { + Handle(TColStd_HArray1OfReal) aItems; + Standard_Integer nsub = 0; + if (data->ReadSubList(num, 4, "items", ach, nsub)) { + Standard_Integer nb = data->NbParams(nsub); + aItems = new TColStd_HArray1OfReal(1, nb); + Standard_Integer num2 = nsub; + for (Standard_Integer i0 = 1; i0 <= nb; i0++) { + Standard_Real anIt0; + data->ReadReal(num2, i0, "real", ach, anIt0); + aItems->SetValue(i0, anIt0); + } + } + aInputOrientation.SetValue(aItems); + } + else + data->ReadEntity(num, 4, "input_orientation", ach, aInputOrientation); // Initialize entity ent->Init(aRepresentationItem_Name, @@ -91,7 +108,17 @@ void RWStepKinematics_RWPointOnPlanarCurvePairValue::WriteStep (StepData_StepWri SW.Send (ent->ActualPointOnCurve()); - SW.Send (ent->InputOrientation().Value()); + if (!ent->InputOrientation().YprRotation().IsNull()) + { + // Inherited field : YPR + SW.OpenSub(); + for (Standard_Integer i = 1; i <= ent->InputOrientation().YprRotation()->Length(); i++) { + SW.Send(ent->InputOrientation().YprRotation()->Value(i)); + } + SW.CloseSub(); + } + else + SW.Send(ent->InputOrientation().Value()); } //======================================================================= @@ -113,5 +140,6 @@ void RWStepKinematics_RWPointOnPlanarCurvePairValue::Share (const Handle(StepKin iter.AddItem (ent->ActualPointOnCurve()); - iter.AddItem (ent->InputOrientation().Value()); + if (!ent->InputOrientation().RotationAboutDirection().IsNull()) + iter.AddItem(ent->InputOrientation().Value()); } diff --git a/src/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePairValue.cxx b/src/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePairValue.cxx index b1ccd248e2..62aac2133a 100644 --- a/src/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePairValue.cxx +++ b/src/RWStepKinematics/RWStepKinematics_RWPointOnSurfacePairValue.cxx @@ -61,7 +61,24 @@ void RWStepKinematics_RWPointOnSurfacePairValue::ReadStep (const Handle(StepData data->ReadEntity (num, 3, "actual_point_on_surface", ach, STANDARD_TYPE(StepGeom_PointOnSurface), aActualPointOnSurface); StepKinematics_SpatialRotation aInputOrientation; - data->ReadEntity (num, 4, "input_orientation", ach, aInputOrientation); + if (data->SubListNumber(num, 4, Standard_True)) + { + Handle(TColStd_HArray1OfReal) aItems; + Standard_Integer nsub = 0; + if (data->ReadSubList(num, 4, "items", ach, nsub)) { + Standard_Integer nb = data->NbParams(nsub); + aItems = new TColStd_HArray1OfReal(1, nb); + Standard_Integer num2 = nsub; + for (Standard_Integer i0 = 1; i0 <= nb; i0++) { + Standard_Real anIt0; + data->ReadReal(num2, i0, "real", ach, anIt0); + aItems->SetValue(i0, anIt0); + } + } + aInputOrientation.SetValue(aItems); + } + else + data->ReadEntity(num, 4, "input_orientation", ach, aInputOrientation); // Initialize entity ent->Init(aRepresentationItem_Name, @@ -91,7 +108,17 @@ void RWStepKinematics_RWPointOnSurfacePairValue::WriteStep (StepData_StepWriter& SW.Send (ent->ActualPointOnSurface()); - SW.Send (ent->InputOrientation().Value()); + if (!ent->InputOrientation().YprRotation().IsNull()) + { + // Inherited field : YPR + SW.OpenSub(); + for (Standard_Integer i = 1; i <= ent->InputOrientation().YprRotation()->Length(); i++) { + SW.Send(ent->InputOrientation().YprRotation()->Value(i)); + } + SW.CloseSub(); + } + else + SW.Send(ent->InputOrientation().Value()); } //======================================================================= @@ -113,5 +140,6 @@ void RWStepKinematics_RWPointOnSurfacePairValue::Share (const Handle(StepKinemat iter.AddItem (ent->ActualPointOnSurface()); - iter.AddItem (ent->InputOrientation().Value()); + if (!ent->InputOrientation().RotationAboutDirection().IsNull()) + iter.AddItem(ent->InputOrientation().Value()); } diff --git a/src/RWStepKinematics/RWStepKinematics_RWSphericalPairValue.cxx b/src/RWStepKinematics/RWStepKinematics_RWSphericalPairValue.cxx index b4399770fc..dd3de9f750 100644 --- a/src/RWStepKinematics/RWStepKinematics_RWSphericalPairValue.cxx +++ b/src/RWStepKinematics/RWStepKinematics_RWSphericalPairValue.cxx @@ -54,10 +54,27 @@ void RWStepKinematics_RWSphericalPairValue::ReadStep (const Handle(StepData_Step Handle(StepKinematics_KinematicPair) aPairValue_AppliesToPair; data->ReadEntity (num, 2, "pair_value.applies_to_pair", ach, STANDARD_TYPE(StepKinematics_KinematicPair), aPairValue_AppliesToPair); - // Own fields of SphericalPairValue + // Own fields of SphericalPairValue StepKinematics_SpatialRotation aInputOrientation; - data->ReadEntity (num, 3, "input_orientation", ach, aInputOrientation); + if (data->SubListNumber(num, 3, Standard_True)) + { + Handle(TColStd_HArray1OfReal) aItems; + Standard_Integer nsub = 0; + if (data->ReadSubList(num, 3, "items", ach, nsub)) { + Standard_Integer nb = data->NbParams(nsub); + aItems = new TColStd_HArray1OfReal(1, nb); + Standard_Integer num2 = nsub; + for (Standard_Integer i0 = 1; i0 <= nb; i0++) { + Standard_Real anIt0; + data->ReadReal(num2, i0, "real", ach, anIt0); + aItems->SetValue(i0, anIt0); + } + } + aInputOrientation.SetValue(aItems); + } + else + data->ReadEntity (num, 3, "input_orientation", ach, aInputOrientation); // Initialize entity ent->Init(aRepresentationItem_Name, @@ -70,21 +87,31 @@ void RWStepKinematics_RWSphericalPairValue::ReadStep (const Handle(StepData_Step //purpose : //======================================================================= -void RWStepKinematics_RWSphericalPairValue::WriteStep (StepData_StepWriter& SW, - const Handle(StepKinematics_SphericalPairValue)& ent) const +void RWStepKinematics_RWSphericalPairValue::WriteStep(StepData_StepWriter& SW, + const Handle(StepKinematics_SphericalPairValue)& ent) const { // Own fields of RepresentationItem - SW.Send (ent->Name()); + SW.Send(ent->Name()); // Own fields of PairValue - SW.Send (ent->AppliesToPair()); + SW.Send(ent->AppliesToPair()); // Own fields of SphericalPairValue - SW.Send (ent->InputOrientation().Value()); + if (!ent->InputOrientation().YprRotation().IsNull()) + { + // Inherited field : YPR + SW.OpenSub(); + for (Standard_Integer i = 1; i <= ent->InputOrientation().YprRotation()->Length(); i++) { + SW.Send(ent->InputOrientation().YprRotation()->Value(i)); + } + SW.CloseSub(); + } + else + SW.Send(ent->InputOrientation().Value()); } //======================================================================= @@ -104,5 +131,6 @@ void RWStepKinematics_RWSphericalPairValue::Share (const Handle(StepKinematics_S // Own fields of SphericalPairValue - iter.AddItem (ent->InputOrientation().Value()); + if (!ent->InputOrientation().RotationAboutDirection().IsNull()) + iter.AddItem(ent->InputOrientation().Value()); } diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index 144c1d8e6d..fe7a6c2923 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -4327,7 +4327,8 @@ Standard_Boolean addLinksWithShapes(const Handle(XSControl_WorkSession)& theWS, const TDF_Label& aMechanism, TColStd_SequenceOfTransient& aCollOfLinks, TDF_LabelSequence& aSeqOfLinksL, - const XCAFDoc_DataMapOfShapeLabel& aMap) + const XCAFDoc_DataMapOfShapeLabel& aMap, + const Standard_Boolean& IsBase = Standard_False) { Handle(XSControl_TransferReader) aTR = theWS->TransferReader(); Handle(Transfer_TransientProcess) aTP = aTR->TransientProcess(); @@ -4362,10 +4363,10 @@ Standard_Boolean addLinksWithShapes(const Handle(XSControl_WorkSession)& theWS, { aCDKLR = Handle(StepKinematics_ContextDependentKinematicLinkRepresentation)::DownCast(entIt.Value()); } - Handle(StepRepr_NextAssemblyUsageOccurrence) aNAUO = - Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(aCDKLR->RepresentedProductRelation()->Definition().Value()); + Handle(StepRepr_PropertyDefinition) aPD = + Handle(StepRepr_PropertyDefinition)::DownCast(aCDKLR->RepresentedProductRelation()); TDF_Label aShapeLabel; - Handle(Transfer_Binder) binder = aTP->Find(aNAUO); + Handle(Transfer_Binder) binder = aTP->Find(aPD->Definition().Value()); TopoDS_Shape aShape = TransferBRep::ShapeResult(aTP, binder); if (aShape.IsNull()) return Standard_False; @@ -4377,7 +4378,7 @@ Standard_Boolean addLinksWithShapes(const Handle(XSControl_WorkSession)& theWS, if (aShapes.Length() == 0) return Standard_False; - theLink = aKTool->AddLink(aMechanism, aShapes); + theLink = aKTool->AddLink(aMechanism, aShapes, IsBase); if (!aLink->Name()->IsEmpty()) TDataStd_Name::Set(theLink, aLink->Name()->String()); @@ -4415,7 +4416,8 @@ XCAFKinematics_PairType getKinematicType(const Handle(StepKinematics_KinematicPa return XCAFKinematics_PairType_Spherical; if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PlanarPair))) return XCAFKinematics_PairType_Planar; - if (aKP->IsKind(STANDARD_TYPE(StepKinematics_UnconstrainedPair))) + if (aKP->IsKind(STANDARD_TYPE(StepKinematics_UnconstrainedPair)) || + aKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPairWithRange))) return XCAFKinematics_PairType_Unconstrained; // Low order pairs with motion coupling @@ -4518,7 +4520,7 @@ Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKine anObj->SetMaxTranslationY(aPlanarPairWithRange->UpperLimitActualTranslationY()); anObj->SetMinTranslationY(aPlanarPairWithRange->LowerLimitActualTranslationY()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_UnconstrainedPair)))// three rotation and three translation DOF + else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPairWithRange))) // three rotation and three translation DOF { Handle(StepKinematics_LowOrderKinematicPairWithRange) anUnconstrainedPair = Handle(StepKinematics_LowOrderKinematicPairWithRange)::DownCast(aKP); anObj->SetMaxRotationX(anUnconstrainedPair->UpperLimitActualRotationX()); @@ -4539,8 +4541,7 @@ Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKine // Low order pairs with motion coupling else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LowOrderKinematicPairWithMotionCoupling))) { - Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObj = Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(aKinematicPairObj);//new XCAFKinematics_LowOrderPairObjectWithCoupling; - anObj->SetType(getKinematicType(aKP)); + Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObj = Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(aKinematicPairObj); if (aKP->IsKind(STANDARD_TYPE(StepKinematics_ScrewPairWithRange))) { Handle(StepKinematics_ScrewPairWithRange) aScrewPairWithRange = Handle(StepKinematics_ScrewPairWithRange)::DownCast(aKP); @@ -4559,18 +4560,12 @@ Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKine anObj->SetLowLimit(aGearPairWithRange->LowerLimitActualRotation1()); anObj->SetUpperLimit(aGearPairWithRange->UpperLimitActualRotation1()); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPinionPair))) - { - Handle(StepKinematics_LinearFlexibleAndPinionPair) aLinearFlexibleAndPinionPair = Handle(StepKinematics_LinearFlexibleAndPinionPair)::DownCast(aKP); - anObj->SetPinionRadius(aLinearFlexibleAndPinionPair->PinionRadius()); - } return Standard_True; } // High order pairs else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_HighOrderKinematicPair))) { Handle(XCAFKinematics_HighOrderPairObject) anObj = Handle(XCAFKinematics_HighOrderPairObject)::DownCast(aKinematicPairObj);//new XCAFKinematics_HighOrderPairObject; - anObj->SetType(getKinematicType(aKP)); if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnSurfacePairWithRange))) { Handle(StepKinematics_PointOnSurfacePairWithRange) aPointOnSurfacePairWithRange = Handle(StepKinematics_PointOnSurfacePairWithRange)::DownCast(aKP); @@ -4580,15 +4575,7 @@ Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKine anObj->SetUpperLimitPitch(aPointOnSurfacePairWithRange->UpperLimitPitch()); anObj->SetLowLimitRoll(aPointOnSurfacePairWithRange->LowerLimitRoll()); anObj->SetUpperLimitRoll(aPointOnSurfacePairWithRange->UpperLimitRoll()); - anObj->SetSurface(StepToGeom::MakeSurface(aPointOnSurfacePairWithRange->RangeOnPairSurface())); - } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_SurfacePairWithRange))) - { - Handle(StepKinematics_SurfacePairWithRange) aSurfacePairWithRange = Handle(StepKinematics_SurfacePairWithRange)::DownCast(aKP); - anObj->SetRotationLowLimit(aSurfacePairWithRange->LowerLimitActualRotation()); - anObj->SetRotationUpperLimit(aSurfacePairWithRange->UpperLimitActualRotation()); - anObj->SetFirstSurface(StepToGeom::MakeSurface(aSurfacePairWithRange->RangeOnSurface1())); - anObj->SetSecondSurface(StepToGeom::MakeSurface(aSurfacePairWithRange->RangeOnSurface2())); + anObj->SetTrimmedSurface(StepToGeom::MakeRectangularTrimmedSurface(aPointOnSurfacePairWithRange->RangeOnPairSurface())); } else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePairWithRange))) { @@ -4599,8 +4586,7 @@ Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKine anObj->SetUpperLimitPitch(aPointOnPlanarCurvePairWithRange->UpperLimitPitch()); anObj->SetLowLimitRoll(aPointOnPlanarCurvePairWithRange->LowerLimitRoll()); anObj->SetUpperLimitRoll(aPointOnPlanarCurvePairWithRange->UpperLimitRoll()); - anObj->SetCurve(StepToGeom::MakeCurve(aPointOnPlanarCurvePairWithRange->RangeOnPairCurve())); - + anObj->SetTrimmedCurve(StepToGeom::MakeTrimmedCurve(aPointOnPlanarCurvePairWithRange->RangeOnPairCurve())); } else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PlanarCurvePairRange))) { @@ -4608,12 +4594,6 @@ Standard_Boolean setKinematicPairLimits(Handle(XCAFKinematics_PairObject)& aKine anObj->SetFirstCurve(StepToGeom::MakeCurve(aPlanarCurvePairRange->RangeOnCurve1())); anObj->SetSecondCurve(StepToGeom::MakeCurve(aPlanarCurvePairRange->RangeOnCurve2())); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_LinearFlexibleAndPlanarCurvePair))) - { - Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair) aLinearFlexibleAndPlanarCurvePair = Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair)::DownCast(aKP); - anObj->SetOrientation(aLinearFlexibleAndPlanarCurvePair->Orientation()); - anObj->SetCurve(StepToGeom::MakeCurve(aLinearFlexibleAndPlanarCurvePair->PairCurve())); - } return Standard_True; } return Standard_False; @@ -4681,12 +4661,33 @@ Handle(XCAFKinematics_PairObject) createXCAFKinematicPairObject(const Handle(Ste Handle(StepKinematics_PointOnSurfacePair) aPointOnSurfacePair = Handle(StepKinematics_PointOnSurfacePair)::DownCast(aKP); aHighOrderPairObject->SetSurface(StepToGeom::MakeSurface(aPointOnSurfacePair->PairSurface())); } - else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_SurfacePair))) + else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_RollingSurfacePair))) + { + Handle(StepKinematics_RollingSurfacePair) aRollingSurfacePair = Handle(StepKinematics_RollingSurfacePair)::DownCast(aKP); + aHighOrderPairObject->SetFirstSurface(StepToGeom::MakeSurface(aRollingSurfacePair->Surface1())); + aHighOrderPairObject->SetSecondSurface(StepToGeom::MakeSurface(aRollingSurfacePair->Surface2())); + aHighOrderPairObject->SetOrientation(aRollingSurfacePair->Orientation()); + } + else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_SlidingSurfacePair))) + { + Handle(StepKinematics_SlidingSurfacePair) aSlidingSurfacePair = Handle(StepKinematics_SlidingSurfacePair)::DownCast(aKP); + aHighOrderPairObject->SetFirstSurface(StepToGeom::MakeSurface(aSlidingSurfacePair->Surface1())); + aHighOrderPairObject->SetSecondSurface(StepToGeom::MakeSurface(aSlidingSurfacePair->Surface2())); + aHighOrderPairObject->SetOrientation(aSlidingSurfacePair->Orientation()); + } + else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_SlidingCurvePair))) + { + Handle(StepKinematics_SlidingCurvePair) aSlidingCurvePair = Handle(StepKinematics_SlidingCurvePair)::DownCast(aKP); + aHighOrderPairObject->SetFirstCurve(StepToGeom::MakeCurve(aSlidingCurvePair->Curve1())); + aHighOrderPairObject->SetSecondCurve(StepToGeom::MakeCurve(aSlidingCurvePair->Curve2())); + aHighOrderPairObject->SetOrientation(aSlidingCurvePair->Orientation()); + } + else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_RollingCurvePair))) { - Handle(StepKinematics_SurfacePair) aSurfacePair = Handle(StepKinematics_SurfacePair)::DownCast(aKP); - aHighOrderPairObject->SetFirstSurface(StepToGeom::MakeSurface(aSurfacePair->Surface1())); - aHighOrderPairObject->SetSecondSurface(StepToGeom::MakeSurface(aSurfacePair->Surface2())); - aHighOrderPairObject->SetOrientation(aSurfacePair->Orientation()); + Handle(StepKinematics_RollingCurvePair) aRollingCurvePair = Handle(StepKinematics_RollingCurvePair)::DownCast(aKP); + aHighOrderPairObject->SetFirstCurve(StepToGeom::MakeCurve(aRollingCurvePair->Curve1())); + aHighOrderPairObject->SetSecondCurve(StepToGeom::MakeCurve(aRollingCurvePair->Curve2())); + aHighOrderPairObject->SetOrientation(aRollingCurvePair->Orientation()); } else if (aKP->IsKind(STANDARD_TYPE(StepKinematics_PointOnPlanarCurvePair))) { @@ -4751,6 +4752,8 @@ Standard_Boolean setKinematicPairValue(const Handle(XSControl_WorkSession)& theW aValueObject = new XCAFKinematics_PairValueObject(); aValueObject->SetType(aType); + if (aType == 0) + return Standard_False; TDF_TagSource aTag; TDF_Label aValueL = aTag.NewChild(aState); @@ -4854,6 +4857,8 @@ Standard_Boolean setKinematicPairValue(const Handle(XSControl_WorkSession)& theW } else return Standard_False; + if (aValueObject->GetAllValues().IsNull()) + return Standard_False; Handle(XCAFDoc_KinematicPairValue) aCAFKinematicPairValue = XCAFDoc_KinematicPairValue::Set(aValueL, aJoint); aCAFKinematicPairValue->SetObject(aValueObject); if (!aValue->Name()->IsEmpty()) @@ -5125,7 +5130,7 @@ Standard_Boolean STEPCAFControl_Reader::ReadKinematics(const Handle(XSControl_Wo if (!aKPMR->Base().IsNull()) { TDF_Label aLableOfBaseLink; - addLinksWithShapes(theWS, theDoc, aKPMR->Base(), aLableOfBaseLink,aMechanism, aCollOfLinks, aSeqOfLinksL, aShapeLabelMap); + addLinksWithShapes(theWS, theDoc, aKPMR->Base(), aLableOfBaseLink, aMechanism, aCollOfLinks, aSeqOfLinksL, aShapeLabelMap, Standard_True); } for (Standard_Integer aPairIndex = 1; aPairIndex <= aKMR->NbItems(); ++aPairIndex) diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.cxx b/src/STEPCAFControl/STEPCAFControl_Writer.cxx index 5de3d3146e..3a577547c8 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.cxx @@ -22,7 +22,9 @@ #include #include +#include #include +#include #include #include #include @@ -182,9 +184,7 @@ #include #include #include -// -// -// + #include #include #include @@ -291,6 +291,7 @@ #include #include #include +#include #include #include #include @@ -387,7 +388,7 @@ STEPCAFControl_Writer::STEPCAFControl_Writer () : mySHUOMode ( Standard_True ), myGDTMode ( Standard_True ), myMatMode ( Standard_True ), - myKPairMode( Standard_True ) + myKinematicMode( Standard_True ) { STEPCAFControl_Controller::Init(); Handle(XSControl_WorkSession) WS = new XSControl_WorkSession; @@ -409,7 +410,7 @@ STEPCAFControl_Writer::STEPCAFControl_Writer (const Handle(XSControl_WorkSession mySHUOMode(Standard_True), myGDTMode(Standard_True), myMatMode(Standard_True), - myKPairMode(Standard_True) + myKinematicMode(Standard_True) { STEPCAFControl_Controller::Init(); Init ( WS, scratch ); @@ -1868,33 +1869,6 @@ static Standard_Boolean getProDefinitionOfNAUO(const Handle(XSControl_WorkSessio return Standard_True; } -//======================================================================= -//function : getProDefinitionOfNAUO -//purpose : auxilary -//======================================================================= -static Standard_Boolean getProDefi(const Handle(XSControl_WorkSession)& WS, - const TopoDS_Shape& theShape, - Handle(StepRepr_ProductDefinitionShape)& PD) -{ - if (theShape.IsNull()) - return Standard_False; - // get CDSR - const Handle(XSControl_TransferWriter)& TW = WS->TransferWriter(); - const Handle(Transfer_FinderProcess)& FP = TW->FinderProcess(); - Handle(StepShape_ContextDependentShapeRepresentation) CDSR; - Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper(FP, theShape); - if (!FP->FindTypedTransient(mapper, - STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation), - CDSR)) - return Standard_False; - // get PDS of NAUO - Handle(StepRepr_ProductDefinitionShape) PDS = CDSR->RepresentedProductRelation(); - if (PDS.IsNull()) - return Standard_False; - PD = PDS; - return Standard_True; -} - //======================================================================= //function : writeSHUO @@ -2223,6 +2197,38 @@ Standard_Boolean STEPCAFControl_Writer::WriteSHUOs (const Handle(XSControl_WorkS return Standard_True; } +//======================================================================= +//function : MakeTrimmedCurve +//purpose : auxilary +//======================================================================= +static Handle(StepGeom_TrimmedCurve) MakeTrimmedCurve(const Handle(StepGeom_Curve)& C, + const Handle(Geom_TrimmedCurve) TC, + Standard_Boolean sense) +{ + Handle(StepGeom_HArray1OfTrimmingSelect) aSTS1 = + new StepGeom_HArray1OfTrimmingSelect(1, 2); + StepGeom_TrimmingSelect tSel; + GeomToStep_MakeCartesianPoint aMP1(TC->StartPoint()); + tSel.SetValue(aMP1.Value()); + aSTS1->SetValue(1, tSel); + tSel.SetParameterValue(TC->FirstParameter()); + aSTS1->SetValue(2, tSel); + + Handle(StepGeom_HArray1OfTrimmingSelect) aSTS2 = + new StepGeom_HArray1OfTrimmingSelect(1, 2); + GeomToStep_MakeCartesianPoint aMP2(TC->EndPoint()); + tSel.SetValue(aMP2.Value()); + aSTS2->SetValue(1, tSel); + tSel.SetParameterValue(TC->LastParameter()); + aSTS2->SetValue(2, tSel); + + Handle(TCollection_HAsciiString) empty = + new TCollection_HAsciiString(""); + Handle(StepGeom_TrimmedCurve) pmsTC = new StepGeom_TrimmedCurve; + pmsTC->Init(empty, C, aSTS1, aSTS2, sense, StepGeom_tpParameter); + return pmsTC; +} + //======================================================================= //function : createKinematicLink //purpose : auxilary @@ -2233,7 +2239,7 @@ static Standard_Boolean createKinematicLink(const Handle(Transfer_FinderProcess) const Interface_Graph& aGraph, const TDF_Label& theLabelLink, Handle(StepShape_ShapeRepresentation)& aShapeRepr, - Handle(StepRepr_NextAssemblyUsageOccurrence)& NAUO) + Handle(StepRepr_PropertyDefinition)& aPDS) { theLink = new StepKinematics_KinematicLink; @@ -2253,32 +2259,25 @@ static Standard_Boolean createKinematicLink(const Handle(Transfer_FinderProcess) FP->Messenger()->SendInfo() << "Warning: Cannot find RI for " << aTopoShapeStart.TShape()->DynamicType()->Name() << std::endl; return Standard_False; } + + // get PDS of Shape Interface_EntityIterator anIter = aGraph.Sharings(seqRI.Value(1)); - for (anIter.Start(); anIter.More() && aShapeRepr.IsNull(); anIter.Next()) - { + for (anIter.Start(); anIter.More() && aPDS.IsNull(); anIter.Next()) { aShapeRepr = Handle(StepShape_ShapeRepresentation)::DownCast(anIter.Value()); - } - Handle(StepShape_ContextDependentShapeRepresentation) CDSR; - Handle(TransferBRep_ShapeMapper) mapper = TransferBRep::ShapeMapper(FP, aTopoShapeStart); - if (!FP->FindTypedTransient(mapper, - STANDARD_TYPE(StepShape_ContextDependentShapeRepresentation), - CDSR)) - return Standard_False; - // get PDS of NAUO - Handle(StepRepr_ProductDefinitionShape) PDS = CDSR->RepresentedProductRelation(); - if (PDS.IsNull()) - return Standard_False; - // get the NAUO entity - Interface_EntityIterator subs = aGraph.Shareds(PDS); - for (subs.Start(); subs.More(); subs.Next()) { - if (!subs.Value()->IsKind(STANDARD_TYPE(StepRepr_NextAssemblyUsageOccurrence))) + if (aShapeRepr.IsNull()) continue; - NAUO = Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(subs.Value()); - break; + Interface_EntityIterator aSDRIt = aGraph.Sharings(aShapeRepr); + for (aSDRIt.Start(); aSDRIt.More() && aPDS.IsNull(); aSDRIt.Next()) { + Handle(StepShape_ShapeDefinitionRepresentation) aSDR = + Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aSDRIt.Value()); + if (aSDR.IsNull()) continue; + aPDS = aSDR->Definition().PropertyDefinition(); + if (!aPDS.IsNull()) + return Standard_True; + } } - if (NAUO.IsNull()) - return Standard_False; - return Standard_True; + + return Standard_False; } //======================================================================= @@ -2317,11 +2316,15 @@ static Standard_Boolean createKinematicJoint(const Handle(Transfer_FinderProcess if (aSeqOfLinskL(aLinkInd) == aLinkStartL) { aRigLinkRepr1 = Handle(StepKinematics_RigidLinkRepresentation)::DownCast(aArrayOfRigidLinks->Value(aLinkInd)); + if (aRigLinkRepr1.IsNull()) + return Standard_False; aEdgeStart = aRigLinkRepr1->RepresentedLink(); } else if (aSeqOfLinskL(aLinkInd) == aLinkEndL) { aRigLinkRepr2 = Handle(StepKinematics_RigidLinkRepresentation)::DownCast(aArrayOfRigidLinks->Value(aLinkInd)); + if (aRigLinkRepr2.IsNull()) + return Standard_False; aEdgeEnd = aRigLinkRepr2->RepresentedLink(); } } @@ -2466,14 +2469,14 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje { aKinematicPair = new StepKinematics_UniversalPairWithRange; Handle(StepKinematics_UniversalPairWithRange) anUniversalPairWithRange = Handle(StepKinematics_UniversalPairWithRange)::DownCast(aKinematicPair); - Standard_Real aUpperLimitActualTranslationX = aLowOrderPairObj->MaxTranslationX(); - Standard_Real aLowerLimitActualTranslationX = aLowOrderPairObj->MinTranslationX(); - Standard_Real aUpperLimitActualTranslationZ = aLowOrderPairObj->MaxTranslationZ(); - Standard_Real aLowerLimitActualTranslationZ = aLowOrderPairObj->MinTranslationZ(); + Standard_Real aUpperLimitActualRotationX = aLowOrderPairObj->MaxRotationX(); + Standard_Real aLowerLimitActualRotationX = aLowOrderPairObj->MinRotationX(); + Standard_Real aUpperLimitActualRotationZ = aLowOrderPairObj->MaxRotationZ(); + Standard_Real aLowerLimitActualRotationZ = aLowOrderPairObj->MinRotationZ(); anUniversalPairWithRange->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, - aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, theUniversalPair_InputSkewAngle, Standard_True, aLowerLimitActualTranslationX, Standard_True, - aUpperLimitActualTranslationX, Standard_True, aLowerLimitActualTranslationZ, Standard_True, aUpperLimitActualTranslationZ); + aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, theUniversalPair_InputSkewAngle, Standard_True, aLowerLimitActualRotationX, Standard_True, + aUpperLimitActualRotationX, Standard_True, aLowerLimitActualRotationZ, Standard_True, aUpperLimitActualRotationZ); } else { @@ -2600,12 +2603,12 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje Handle(StepKinematics_LowOrderKinematicPairWithRange) anUnconstrainedPairWithRange = Handle(StepKinematics_LowOrderKinematicPairWithRange)::DownCast(aKinematicPair); anUnconstrainedPairWithRange->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint, - aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, aLowerLimitActualTranslationX, Standard_True, aUpperLimitActualTranslationX, - Standard_True, aLowerLimitActualTranslationY, Standard_True, aUpperLimitActualTranslationY, - Standard_True, aLowerLimitActualTranslationZ, Standard_True, aUpperLimitActualTranslationZ, - Standard_True, aLowerLimitActualRotationX, Standard_True, aUpperLimitActualRotationX, + aTX, aTY, aTZ, aRX, aRY, aRZ, Standard_True, aLowerLimitActualRotationX, Standard_True, aUpperLimitActualRotationX, Standard_True, aLowerLimitActualRotationY, Standard_True, aUpperLimitActualRotationY, - Standard_True, aLowerLimitActualRotationZ, Standard_True, aUpperLimitActualRotationZ); + Standard_True, aLowerLimitActualRotationZ, Standard_True, aUpperLimitActualRotationZ, + Standard_True, aLowerLimitActualTranslationX, Standard_True, aUpperLimitActualTranslationX, + Standard_True, aLowerLimitActualTranslationY, Standard_True, aUpperLimitActualTranslationY, + Standard_True, aLowerLimitActualTranslationZ, Standard_True, aUpperLimitActualTranslationZ); break; } case(XCAFKinematics_PairType_FullyConstrained): @@ -2735,19 +2738,18 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje { case(XCAFKinematics_PairType_PointOnSurface): { - GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface()); - Handle(StepGeom_Surface) aPairSurface = aMaker.Value(); if (HasRange) { - return Standard_False; + 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 aTrimSurface; - Handle(StepGeom_RectangularTrimmedSurface) aRangeOnPairSurface; /*= aHighOrderPairObject->Surface();*/ + GeomToStep_MakeRectangularTrimmedSurface aMakerTrimmered(aHighOrderPairObject->TrimmedSurface()); + Handle(StepGeom_RectangularTrimmedSurface) aRangeOnPairSurface = aMakerTrimmered.Value(); aKinematicPair = new StepKinematics_PointOnSurfacePairWithRange; Handle(StepKinematics_PointOnSurfacePairWithRange) aPointOnSurfacePairWithRange = Handle(StepKinematics_PointOnSurfacePairWithRange)::DownCast(aKinematicPair); aPointOnSurfacePairWithRange->Init(aPairName, aPairName, hasDescription, @@ -2757,6 +2759,8 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje else { aKinematicPair = new StepKinematics_PointOnSurfacePair; + GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface()); + Handle(StepGeom_Surface) aPairSurface = aMaker.Value(); Handle(StepKinematics_PointOnSurfacePair) aPointOnSurface = Handle(StepKinematics_PointOnSurfacePair)::DownCast(aKinematicPair); aPointOnSurface->Init(aPairName, aPairName, hasDescription, aDescription, theTransformItem1, theTransformItem2, theJoint,aPairSurface); @@ -2766,9 +2770,9 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje case(XCAFKinematics_PairType_SlidingSurface): { aKinematicPair = new StepKinematics_SlidingSurfacePair; - GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface()); + GeomToStep_MakeSurface aMaker(aHighOrderPairObject->FirstSurface()); Handle(StepGeom_Surface) aPairSurfac1 = aMaker.Value(); - GeomToStep_MakeSurface aMaker2(aHighOrderPairObject->Surface()); + GeomToStep_MakeSurface aMaker2(aHighOrderPairObject->SecondSurface()); Handle(StepGeom_Surface) aPairSurface2 = aMaker2.Value(); Standard_Boolean anOrientation = aHighOrderPairObject->Orientation(); Handle(StepKinematics_SlidingSurfacePair) aSlidingSurfacePair = Handle(StepKinematics_SlidingSurfacePair)::DownCast(aKinematicPair); @@ -2779,9 +2783,9 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje case(XCAFKinematics_PairType_RollingSurface): { aKinematicPair = new StepKinematics_RollingSurfacePair; - GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface()); + GeomToStep_MakeSurface aMaker(aHighOrderPairObject->FirstSurface()); Handle(StepGeom_Surface) aPairSurfac1 = aMaker.Value(); - GeomToStep_MakeSurface aMaker2(aHighOrderPairObject->Surface()); + GeomToStep_MakeSurface aMaker2(aHighOrderPairObject->SecondSurface()); Handle(StepGeom_Surface) aPairSurface2 = aMaker2.Value(); Standard_Boolean anOrientation = aHighOrderPairObject->Orientation(); Handle(StepKinematics_RollingSurfacePair) aRollingSurfacePair = Handle(StepKinematics_RollingSurfacePair)::DownCast(aKinematicPair); @@ -2796,14 +2800,14 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje Standard_Boolean anOrientation = aHighOrderPairObject->Orientation(); if (HasRange) { - return Standard_False; Standard_Real aLowerLimitYaw = aHighOrderPairObject->LowLimitYaw(); Standard_Real aUpperLimitYaw = aHighOrderPairObject->UpperLimitYaw(); Standard_Real aLowerLimitPitch = aHighOrderPairObject->LowLimitPitch(); Standard_Real aUpperLimitPitch = aHighOrderPairObject->UpperLimitPitch(); Standard_Real aLowerLimitRoll = aHighOrderPairObject->LowLimitRoll(); - Standard_Real aUpperLimitRoll = aHighOrderPairObject->UpperLimitRoll(); - Handle(StepGeom_TrimmedCurve) aRangeOnPairCurve; /*= aHighOrderPairObject->Curve();*/ + Standard_Real aUpperLimitRoll = aHighOrderPairObject->UpperLimitRoll(); + Handle(Geom_TrimmedCurve) aRangeOnCurve = aHighOrderPairObject->TrimmedCurve(); + Handle(StepGeom_TrimmedCurve) aRangeOnPairCurve = MakeTrimmedCurve(aPairCurve, aHighOrderPairObject->TrimmedCurve(), Standard_True); aKinematicPair = new StepKinematics_PointOnPlanarCurvePairWithRange; Handle(StepKinematics_PointOnPlanarCurvePairWithRange) aPointOnPlanarCurvePairWithRange = Handle(StepKinematics_PointOnPlanarCurvePairWithRange)::DownCast(aKinematicPair); aPointOnPlanarCurvePairWithRange->Init(aPairName, aPairName, hasDescription, @@ -2821,10 +2825,10 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } case(XCAFKinematics_PairType_SlidingCurve): { - GeomToStep_MakeCurve aMaker(aHighOrderPairObject->Curve()); + GeomToStep_MakeCurve aMaker(aHighOrderPairObject->FirstCurve()); Handle(StepGeom_Curve) aPairCurve = aMaker.Value(); Standard_Boolean anOrientation = aHighOrderPairObject->Orientation(); - GeomToStep_MakeCurve aMaker2(aHighOrderPairObject->Curve()); + GeomToStep_MakeCurve aMaker2(aHighOrderPairObject->SecondCurve()); Handle(StepGeom_Curve) aPairCurve2 = aMaker2.Value(); aKinematicPair = new StepKinematics_SlidingCurvePair; Handle(StepKinematics_SlidingCurvePair) aSlidingCurvePair = Handle(StepKinematics_SlidingCurvePair)::DownCast(aKinematicPair); @@ -2834,10 +2838,10 @@ static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObje } case(XCAFKinematics_PairType_RollingCurve): { - GeomToStep_MakeCurve aMaker(aHighOrderPairObject->Curve()); + GeomToStep_MakeCurve aMaker(aHighOrderPairObject->FirstCurve()); Handle(StepGeom_Curve) aPairCurve = aMaker.Value(); Standard_Boolean anOrientation = aHighOrderPairObject->Orientation(); - GeomToStep_MakeCurve aMaker2(aHighOrderPairObject->Curve()); + GeomToStep_MakeCurve aMaker2(aHighOrderPairObject->SecondCurve()); Handle(StepGeom_Curve) aPairCurve2 = aMaker2.Value(); aKinematicPair = new StepKinematics_RollingCurvePair; Handle(StepKinematics_RollingCurvePair) aRollingCurvePair = Handle(StepKinematics_RollingCurvePair)::DownCast(aKinematicPair); @@ -2879,7 +2883,7 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai case(XCAFKinematics_PairType_Revolute): { aPairValue = new StepKinematics_RevolutePairValue; - Handle(StepKinematics_RevolutePairValue) aRevolutePairValue = + Handle(StepKinematics_RevolutePairValue) aRevolutePairValue = Handle(StepKinematics_RevolutePairValue)::DownCast(aPairValue); aRevolutePairValue->SetActualRotation(aKinPairValueObj->GetRotation()); break; @@ -2887,7 +2891,7 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai case(XCAFKinematics_PairType_Prismatic): { aPairValue = new StepKinematics_PrismaticPairValue; - Handle(StepKinematics_PrismaticPairValue) aPrismaticPairValue = + Handle(StepKinematics_PrismaticPairValue) aPrismaticPairValue = Handle(StepKinematics_PrismaticPairValue)::DownCast(aPairValue); aPrismaticPairValue->SetActualTranslation(aKinPairValueObj->GetTranslation()); break; @@ -2895,7 +2899,7 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai case(XCAFKinematics_PairType_Cylindrical): { aPairValue = new StepKinematics_CylindricalPairValue; - Handle(StepKinematics_CylindricalPairValue) aCylindricalPairValue = + Handle(StepKinematics_CylindricalPairValue) aCylindricalPairValue = Handle(StepKinematics_CylindricalPairValue)::DownCast(aPairValue); aCylindricalPairValue->SetActualTranslation(aKinPairValueObj->GetTranslation()); aCylindricalPairValue->SetActualRotation(aKinPairValueObj->GetRotation()); @@ -2904,7 +2908,16 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai case(XCAFKinematics_PairType_Universal): { aPairValue = new StepKinematics_UniversalPairValue; - Handle(StepKinematics_UniversalPairValue) aUniversalPairValue = + Handle(StepKinematics_UniversalPairValue) aUniversalPairValue = + Handle(StepKinematics_UniversalPairValue)::DownCast(aPairValue); + aUniversalPairValue->SetFirstRotationAngle(aKinPairValueObj->GetFirstRotation()); + aUniversalPairValue->SetSecondRotationAngle(aKinPairValueObj->GetSecondRotation()); + break; + } + case(XCAFKinematics_PairType_Homokinetic): + { + aPairValue = new StepKinematics_UniversalPairValue; + Handle(StepKinematics_UniversalPairValue) aUniversalPairValue = Handle(StepKinematics_UniversalPairValue)::DownCast(aPairValue); aUniversalPairValue->SetFirstRotationAngle(aKinPairValueObj->GetFirstRotation()); aUniversalPairValue->SetSecondRotationAngle(aKinPairValueObj->GetSecondRotation()); @@ -2913,7 +2926,17 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai case(XCAFKinematics_PairType_Spherical): { aPairValue = new StepKinematics_SphericalPairValue; - Handle(StepKinematics_SphericalPairValue) aSphericalPairValue = + Handle(StepKinematics_SphericalPairValue) aSphericalPairValue = + Handle(StepKinematics_SphericalPairValue)::DownCast(aPairValue); + StepKinematics_SpatialRotation InputRotation; + InputRotation.SetValue(aKinPairValueObj->GetAllValues()); + aSphericalPairValue->SetInputOrientation(InputRotation); + break; + } + case(XCAFKinematics_PairType_SphericalWithPin): + { + aPairValue = new StepKinematics_SphericalPairValue; + Handle(StepKinematics_SphericalPairValue) aSphericalPairValue = Handle(StepKinematics_SphericalPairValue)::DownCast(aPairValue); StepKinematics_SpatialRotation InputRotation; InputRotation.SetValue(aKinPairValueObj->GetAllValues()); @@ -2923,9 +2946,11 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai case(XCAFKinematics_PairType_Planar): { aPairValue = new StepKinematics_PlanarPairValue; - Handle(StepKinematics_PrismaticPairValue) aPrismaticPairValue = - Handle(StepKinematics_PrismaticPairValue)::DownCast(aPairValue); - aPrismaticPairValue->SetActualTranslation(aKinPairValueObj->GetTranslation()); + Handle(StepKinematics_PlanarPairValue) aPlanarPairValue = + Handle(StepKinematics_PlanarPairValue)::DownCast(aPairValue); + aPlanarPairValue->SetActualRotation(aKinPairValueObj->GetRotation()); + aPlanarPairValue->SetActualTranslationX(aKinPairValueObj->GetFirstTranslation()); + aPlanarPairValue->SetActualTranslationY(aKinPairValueObj->GetSecondTranslation()); break; } case(XCAFKinematics_PairType_Unconstrained): @@ -2972,7 +2997,7 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai Standard_Real theU; Standard_Real theV; aKinPairValueObj->GetPointOnSurface(theU, theV); - aActualPointOnSurface->Init(aPairValue->Name(), aPointOnSurfacePair->PairSurface(), theU, theV); + aActualPointOnSurface->Init(new TCollection_HAsciiString, aPointOnSurfacePair->PairSurface(), theU, theV); aPointOnSurfacePairValue->SetActualPointOnSurface(aActualPointOnSurface); StepKinematics_SpatialRotation aYRP; Handle(TColStd_HArray1OfReal) anArrayYRP = new TColStd_HArray1OfReal(1,3); @@ -2998,14 +3023,15 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai Standard_Real theU1; Standard_Real theV1; aKinPairValueObj->GetFirstPointOnSurface(theU1, theV1); - aActualPointOnSurface1->Init(aPairValue->Name(), SlidingSurfacePair->Surface1(), theU1, theV1); + aActualPointOnSurface1->Init(new TCollection_HAsciiString, SlidingSurfacePair->Surface1(), theU1, theV1); aSlidingSurfacePairValue->SetActualPointOnSurface1(aActualPointOnSurface1); Handle(StepGeom_PointOnSurface) aActualPointOnSurface2 = new StepGeom_PointOnSurface; Standard_Real theU2; Standard_Real theV2; aKinPairValueObj->GetSecondPointOnSurface(theU2, theV2); - aActualPointOnSurface2->Init(aPairValue->Name(), SlidingSurfacePair->Surface2(), theU2, theV2); + aActualPointOnSurface2->Init(new TCollection_HAsciiString, SlidingSurfacePair->Surface2(), theU2, theV2); aSlidingSurfacePairValue->SetActualPointOnSurface2(aActualPointOnSurface2); + aSlidingSurfacePairValue->SetActualRotation(aKinPairValueObj->GetRotation()); break; } case(XCAFKinematics_PairType_RollingSurface): @@ -3016,11 +3042,11 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai aRollingSurfacePairValue->SetActualRotation(aKinPairValueObj->GetRotation()); Handle(StepGeom_PointOnSurface) aActualPointOnSurface = new StepGeom_PointOnSurface; Handle(StepKinematics_RollingSurfacePair) aRollingSurfacePair = - Handle(StepKinematics_RollingSurfacePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()); + Handle(StepKinematics_RollingSurfacePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); Standard_Real theU; Standard_Real theV; aKinPairValueObj->GetPointOnSurface(theU, theV); - aActualPointOnSurface->Init(aPairValue->Name(), aRollingSurfacePair->Surface1(), theU, theV); + aActualPointOnSurface->Init(new TCollection_HAsciiString, aRollingSurfacePair->Surface1(), theU, theV); aRollingSurfacePairValue->SetActualPointOnSurface(aActualPointOnSurface); break; } @@ -3059,6 +3085,10 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai Standard_Real aParametr1 = aKinPairValueObj->GetFirstPointOnCurve(); anActualPointOnCurve1->Init(aSlidingCurvePair->Name(), aSlidingCurvePair->Curve1(), aParametr1); aSlidingCurvePairValue->SetActualPointOnCurve1(anActualPointOnCurve1); + Handle(StepGeom_PointOnCurve) anActualPointOnCurve2 = new StepGeom_PointOnCurve; + Standard_Real aParametr2 = aKinPairValueObj->GetSecondPointOnCurve(); + anActualPointOnCurve2->Init(aSlidingCurvePair->Name(), aSlidingCurvePair->Curve2(), aParametr2); + aSlidingCurvePairValue->SetActualPointOnCurve2(anActualPointOnCurve2); break; } case(XCAFKinematics_PairType_RollingCurve): @@ -3068,7 +3098,7 @@ static Standard_Boolean createKinematicPairValue(const Handle(XCAFKinematics_Pai Handle(StepKinematics_RollingCurvePairValue)::DownCast(aPairValue); Handle(StepGeom_PointOnCurve) anActualPointOnCurve = new StepGeom_PointOnCurve; Handle(StepKinematics_RollingCurvePair) aRollingCurvePair = - Handle(StepKinematics_RollingCurvePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()); + Handle(StepKinematics_RollingCurvePair)::DownCast(aPairReprRelationship->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair()); Standard_Real aParametr = aKinPairValueObj->GetPointOnCurve(); anActualPointOnCurve->Init(aRollingCurvePair->Name(), aRollingCurvePair->Curve1(), aParametr); aRollingCurvePairValue->SetActualPointOnCurve1(anActualPointOnCurve); @@ -3115,7 +3145,7 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha { //write Links Handle(StepKinematics_KinematicLinkRepresentation) aBaseLinksOfMech; - Handle(StepRepr_NextAssemblyUsageOccurrence) aGeneralNAUO; + Handle(StepRepr_PropertyDefinition) aGeneralDefinition; //containers storing Links and their labels located at a single index TDF_LabelSequence aSeqOfLinskL = aKTool->GetLinks(aMechanismsL.Value(aMechInd)); @@ -3128,22 +3158,26 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha TDF_Label aLinkL = aSeqOfLinskL.Value(aLinkInd); Handle(StepKinematics_KinematicLink) aLink; Handle(StepShape_ShapeRepresentation) aRefShapeOfLink; - Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO; - createKinematicLink(FP, aKTool, aLink, aGraph, aLinkL, aRefShapeOfLink, NAUO); + Handle(StepRepr_PropertyDefinition) aPD; + if (!createKinematicLink(FP, aKTool, aLink, aGraph, aLinkL, aRefShapeOfLink, aPD)) + continue; Handle(StepRepr_RepresentationContext) aRepresentationContextOfLink = aRefShapeOfLink->ContextOfItems(); Handle(StepKinematics_RigidLinkRepresentation) aLinkRepresentation = new StepKinematics_RigidLinkRepresentation; Handle(TCollection_HAsciiString) aNameOfLinkRepr = new TCollection_HAsciiString(""); Handle(StepRepr_HArray1OfRepresentationItem) aPlacementsOfPairs = new StepRepr_HArray1OfRepresentationItem; aLinkRepresentation->Init(aNameOfLinkRepr, aPlacementsOfPairs, aRepresentationContextOfLink, aLink); aArrayOfRigidLinks->SetValue(aLinkInd, aLinkRepresentation); + + Handle(TDataStd_Integer) aBase; + if (aBaseLinksOfMech.IsNull() && aLinkL.FindAttribute(TDataStd_Integer::GetID(), aBase)) + aBaseLinksOfMech = aLinkRepresentation; + Handle(StepKinematics_KinematicLinkRepresentationAssociation) aLinkRepresentationAssociation = new StepKinematics_KinematicLinkRepresentationAssociation; aLinkRepresentationAssociation->Init(aNameOfLinkRepr, aNameOfLinkRepr, aRefShapeOfLink, aLinkRepresentation); Handle(StepKinematics_ContextDependentKinematicLinkRepresentation) aCDKLRS = new StepKinematics_ContextDependentKinematicLinkRepresentation; Handle(StepKinematics_ProductDefinitionRelationshipKinematics) aPDRK = new StepKinematics_ProductDefinitionRelationshipKinematics; - StepRepr_CharacterizedDefinition aDefinition; - aDefinition.SetValue(NAUO); - aGeneralNAUO = NAUO; //Work, but think out - aPDRK->Init(aNameOfLinkRepr, Standard_False, aLinkRepresentationAssociation->Description(), aDefinition); + aGeneralDefinition = aPD; //Work, but think out + aPDRK->Init(aNameOfLinkRepr, Standard_False, aLinkRepresentationAssociation->Description(), aPD->Definition()); aCDKLRS->Init(aLinkRepresentationAssociation, aPDRK); Model->AddEntity(aLink); Model->AddEntity(aLinkRepresentation); @@ -3151,8 +3185,11 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha Model->AddEntity(aPDRK); Model->AddEntity(aCDKLRS); } - aBaseLinksOfMech = Handle(StepKinematics_KinematicLinkRepresentation)::DownCast(aArrayOfRigidLinks->Value(1)); + if (aBaseLinksOfMech.IsNull()) + aBaseLinksOfMech = Handle(StepKinematics_KinematicLinkRepresentation)::DownCast(aArrayOfRigidLinks->Value(1)); + if (aGeneralDefinition.IsNull()) + continue; //write joints //containers storing Joints and their labels located at a single index @@ -3199,9 +3236,7 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha //write mechanism Handle(StepKinematics_ProductDefinitionKinematics) aProductDefKin = new StepKinematics_ProductDefinitionKinematics; - StepRepr_CharacterizedDefinition aKinDefinition; - aKinDefinition.SetValue(aGeneralNAUO->RelatingProductDefinition()); - aProductDefKin->Init(new TCollection_HAsciiString, Standard_False, new TCollection_HAsciiString, aKinDefinition); + aProductDefKin->Init(new TCollection_HAsciiString, Standard_False, new TCollection_HAsciiString, aGeneralDefinition->Definition()); aKTopoStruct->Init(new TCollection_HAsciiString, anArrayOfPairs, aBaseLinksOfMech->ContextOfItems()); StepKinematics_KinematicTopologyRepresentationSelect aTopoSelect; aTopoSelect.SetValue(aKTopoStruct); @@ -3219,6 +3254,8 @@ Standard_EXPORT Standard_Boolean STEPCAFControl_Writer::WriteKinematics(const Ha { Handle(StepKinematics_MechanismStateRepresentation) aStateRepr = new StepKinematics_MechanismStateRepresentation; TDF_LabelSequence aSeqOfValues = aKTool->GetValuesOfState(aSeqOfStates(aStateInd)); + if (aSeqOfValues.IsEmpty()) + continue; Handle(StepRepr_HArray1OfRepresentationItem) aItems = new StepRepr_HArray1OfRepresentationItem(1, aSeqOfValues.Length()); for (Standard_Integer aValueInd = 1; aValueInd <= aItems->Length(); ++aValueInd) { @@ -4578,334 +4615,334 @@ void STEPCAFControl_Writer::WriteGeomTolerance (const Handle(XSControl_WorkSessi //function : WriteDGTs //purpose : //======================================================================= - Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSession) &WS, - const TDF_LabelSequence &labels ) const - { +Standard_Boolean STEPCAFControl_Writer::WriteDGTs (const Handle(XSControl_WorkSession) &WS, + const TDF_LabelSequence &labels ) const +{ - if ( labels.Length() <=0 ) return Standard_False; + if ( labels.Length() <=0 ) return Standard_False; - // get working data - const Handle(Interface_InterfaceModel) &Model = WS->Model(); - const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); - const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); + // get working data + const Handle(Interface_InterfaceModel) &Model = WS->Model(); + const Handle(XSControl_TransferWriter) &TW = WS->TransferWriter(); + const Handle(Transfer_FinderProcess) &FP = TW->FinderProcess(); - const Handle(Interface_HGraph) aHGraph = WS->HGraph(); - if(aHGraph.IsNull()) - return Standard_False; + const Handle(Interface_HGraph) aHGraph = WS->HGraph(); + if(aHGraph.IsNull()) + return Standard_False; - Interface_Graph aGraph = aHGraph->Graph(); - Handle(XCAFDoc_DimTolTool) DGTTool = XCAFDoc_DocumentTool::DimTolTool( labels(1) ); - if(DGTTool.IsNull() ) return Standard_False; - - TDF_LabelSequence DGTLabels; - - STEPConstruct_DataMapOfAsciiStringTransient DatumMap; - - // write Datums - DGTLabels.Clear(); - DGTTool->GetDatumLabels(DGTLabels); - if(DGTLabels.Length()<=0) return Standard_False; - Standard_Integer i; - for(i=1; i<=DGTLabels.Length(); i++) { - TDF_Label DatumL = DGTLabels.Value(i); - TDF_LabelSequence ShapeL; - TDF_LabelSequence aNullSeq; - if(!DGTTool->GetRefShapeLabel(DatumL,ShapeL,aNullSeq)) continue; - // find target shape - TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL.Value(1)); - TopLoc_Location Loc; - TColStd_SequenceOfTransient seqRI; - FindEntities( FP, aShape, Loc, seqRI ); - if ( seqRI.Length() <= 0 ) { - FP->Messenger()->SendInfo() << "Warning: Cannot find RI for "<DynamicType()->Name()<Number(PDS)="<Number(PDS)<GetName(); - Handle(TCollection_HAsciiString) aDescription = DatumAttr->GetDescription(); - Handle(TCollection_HAsciiString) anIdentification = DatumAttr->GetIdentification(); - Handle(StepDimTol_DatumFeature) DF = new StepDimTol_DatumFeature; - Handle(StepDimTol_Datum) aDatum = new StepDimTol_Datum; - DF->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue); - Model->AddWithRefs(DF); - aDatum->Init(aName, new TCollection_HAsciiString, PDS, StepData_LFalse, anIdentification); - Model->AddWithRefs(aDatum); - Handle(StepRepr_ShapeAspectRelationship) SAR = new StepRepr_ShapeAspectRelationship; - SAR->SetName(aName); - SAR->SetRelatingShapeAspect(DF); - SAR->SetRelatedShapeAspect(aDatum); - Model->AddWithRefs(SAR); - // write chain for DatumFeature - StepRepr_CharacterizedDefinition CD; - CD.SetValue(DF); - Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition; - PropD->Init(aName,Standard_True,aDescription,CD); - Model->AddWithRefs(PropD); - StepRepr_RepresentedDefinition RD; - RD.SetValue(PropD); - Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation; - Handle(StepRepr_HArray1OfRepresentationItem) HARI = - new StepRepr_HArray1OfRepresentationItem(1,1); - HARI->SetValue(1,AF); - SR->Init(aName,HARI,RC); - Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation; - SDR->Init(RD,SR); - Model->AddWithRefs(SDR); - // write chain for Datum - StepRepr_CharacterizedDefinition CD1; - CD1.SetValue(aDatum); - Handle(StepRepr_PropertyDefinition) PropD1 = new StepRepr_PropertyDefinition; - PropD1->Init(aName,Standard_True,aDescription,CD1); - Model->AddWithRefs(PropD1); - StepRepr_RepresentedDefinition RD1; - RD1.SetValue(PropD1); - Handle(StepShape_ShapeRepresentation) SR1 = new StepShape_ShapeRepresentation; - Handle(StepRepr_HArray1OfRepresentationItem) HARI1 = - new StepRepr_HArray1OfRepresentationItem(1,1); - HARI1->SetValue(1,AF->FaceGeometry()); - SR1->Init(aName,HARI1,RC); - Model->AddWithRefs(SR1); - Handle(StepShape_ShapeDefinitionRepresentation) SDR1 = new StepShape_ShapeDefinitionRepresentation; - SDR1->Init(RD1,SR1); - Model->AddWithRefs(SDR1); - // add created Datum into Map - TCollection_AsciiString stmp(aName->ToCString()); - stmp.AssignCat(aDescription->ToCString()); - stmp.AssignCat(anIdentification->ToCString()); - DatumMap.Bind(stmp,aDatum); + Interface_Graph aGraph = aHGraph->Graph(); + Handle(XCAFDoc_DimTolTool) DGTTool = XCAFDoc_DocumentTool::DimTolTool( labels(1) ); + if(DGTTool.IsNull() ) return Standard_False; + + TDF_LabelSequence DGTLabels; + + STEPConstruct_DataMapOfAsciiStringTransient DatumMap; + + // write Datums + DGTLabels.Clear(); + DGTTool->GetDatumLabels(DGTLabels); + if(DGTLabels.Length()<=0) return Standard_False; + Standard_Integer i; + for(i=1; i<=DGTLabels.Length(); i++) { + TDF_Label DatumL = DGTLabels.Value(i); + TDF_LabelSequence ShapeL; + TDF_LabelSequence aNullSeq; + if(!DGTTool->GetRefShapeLabel(DatumL,ShapeL,aNullSeq)) continue; + // find target shape + TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL.Value(1)); + TopLoc_Location Loc; + TColStd_SequenceOfTransient seqRI; + FindEntities( FP, aShape, Loc, seqRI ); + if ( seqRI.Length() <= 0 ) { + FP->Messenger()->SendInfo() << "Warning: Cannot find RI for "<DynamicType()->Name()<Number(PDS)="<Number(PDS)<GetName(); + Handle(TCollection_HAsciiString) aDescription = DatumAttr->GetDescription(); + Handle(TCollection_HAsciiString) anIdentification = DatumAttr->GetIdentification(); + Handle(StepDimTol_DatumFeature) DF = new StepDimTol_DatumFeature; + Handle(StepDimTol_Datum) aDatum = new StepDimTol_Datum; + DF->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue); + Model->AddWithRefs(DF); + aDatum->Init(aName, new TCollection_HAsciiString, PDS, StepData_LFalse, anIdentification); + Model->AddWithRefs(aDatum); + Handle(StepRepr_ShapeAspectRelationship) SAR = new StepRepr_ShapeAspectRelationship; + SAR->SetName(aName); + SAR->SetRelatingShapeAspect(DF); + SAR->SetRelatedShapeAspect(aDatum); + Model->AddWithRefs(SAR); + // write chain for DatumFeature + StepRepr_CharacterizedDefinition CD; + CD.SetValue(DF); + Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition; + PropD->Init(aName,Standard_True,aDescription,CD); + Model->AddWithRefs(PropD); + StepRepr_RepresentedDefinition RD; + RD.SetValue(PropD); + Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation; + Handle(StepRepr_HArray1OfRepresentationItem) HARI = + new StepRepr_HArray1OfRepresentationItem(1,1); + HARI->SetValue(1,AF); + SR->Init(aName,HARI,RC); + Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation; + SDR->Init(RD,SR); + Model->AddWithRefs(SDR); + // write chain for Datum + StepRepr_CharacterizedDefinition CD1; + CD1.SetValue(aDatum); + Handle(StepRepr_PropertyDefinition) PropD1 = new StepRepr_PropertyDefinition; + PropD1->Init(aName,Standard_True,aDescription,CD1); + Model->AddWithRefs(PropD1); + StepRepr_RepresentedDefinition RD1; + RD1.SetValue(PropD1); + Handle(StepShape_ShapeRepresentation) SR1 = new StepShape_ShapeRepresentation; + Handle(StepRepr_HArray1OfRepresentationItem) HARI1 = + new StepRepr_HArray1OfRepresentationItem(1,1); + HARI1->SetValue(1,AF->FaceGeometry()); + SR1->Init(aName,HARI1,RC); + Model->AddWithRefs(SR1); + Handle(StepShape_ShapeDefinitionRepresentation) SDR1 = new StepShape_ShapeDefinitionRepresentation; + SDR1->Init(RD1,SR1); + Model->AddWithRefs(SDR1); + // add created Datum into Map + TCollection_AsciiString stmp(aName->ToCString()); + stmp.AssignCat(aDescription->ToCString()); + stmp.AssignCat(anIdentification->ToCString()); + DatumMap.Bind(stmp,aDatum); + } - // write Tolerances and Dimensions - DGTLabels.Clear(); - DGTTool->GetDimTolLabels(DGTLabels); - if(DGTLabels.Length()<=0) return Standard_False; - for(i=1; i<=DGTLabels.Length(); i++) { - TDF_Label DimTolL = DGTLabels.Value(i); - TDF_LabelSequence ShapeL; - TDF_LabelSequence aNullSeq; - if(!DGTTool->GetRefShapeLabel(DimTolL,ShapeL,aNullSeq)) continue; - // find target shape - TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL.Value(1)); - TopLoc_Location Loc; - TColStd_SequenceOfTransient seqRI; - FindEntities( FP, aShape, Loc, seqRI ); - if ( seqRI.Length() <= 0 ) { - FP->Messenger()->SendInfo() << "Warning: Cannot find RI for "<DynamicType()->Name()<Number(PDS)="<Number(PDS)<GetKind(); - Handle(TColStd_HArray1OfReal) aVal = DimTolAttr->GetVal(); - Handle(TCollection_HAsciiString) aName = DimTolAttr->GetName(); - Handle(TCollection_HAsciiString) aDescription = DimTolAttr->GetDescription(); - - // common part of writing D> entities - StepRepr_CharacterizedDefinition CD; - Handle(StepRepr_ShapeAspect) SA = new StepRepr_ShapeAspect; - SA->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue); - Model->AddWithRefs(SA); - CD.SetValue(SA); - Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition; - PropD->Init(aName,Standard_True,aDescription,CD); - Model->AddWithRefs(PropD); - StepRepr_RepresentedDefinition RD; - RD.SetValue(PropD); - Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation; - Handle(StepRepr_HArray1OfRepresentationItem) HARI = - new StepRepr_HArray1OfRepresentationItem(1,1); - if(kind<20) - HARI->SetValue(1,EC); - else - HARI->SetValue(1,AF); - SR->Init(aName,HARI,RC); - Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation; - SDR->Init(RD,SR); - Model->AddWithRefs(SDR); - // define aUnit for creation LengthMeasureWithUnit (common for all) - StepBasic_Unit aUnit; - aUnit = GetUnit(RC); - - // specific part of writing D> entities - if(kind<20) { //dimension - Handle(StepShape_DimensionalSize) DimSize = new StepShape_DimensionalSize; - DimSize->Init(SA,aDescription); - Model->AddWithRefs(DimSize); - if(aVal->Length()>1) { - // create MeasureWithUnits - Handle(StepBasic_MeasureValueMember) MVM1 = new StepBasic_MeasureValueMember; - MVM1->SetName("POSITIVE_LENGTH_MEASURE"); - MVM1->SetReal(aVal->Value(1)); - Handle(StepBasic_MeasureWithUnit) MWU1 = new StepBasic_MeasureWithUnit; - MWU1->Init(MVM1,aUnit); - Handle(StepBasic_MeasureValueMember) MVM2 = new StepBasic_MeasureValueMember; - MVM2->SetName("POSITIVE_LENGTH_MEASURE"); - MVM2->SetReal(aVal->Value(2)); - Handle(StepBasic_MeasureWithUnit) MWU2 = new StepBasic_MeasureWithUnit; - MWU2->Init(MVM2,aUnit); - Handle(StepRepr_RepresentationItem) RI1 = new StepRepr_RepresentationItem; - RI1->Init(new TCollection_HAsciiString("lower limit")); - Handle(StepRepr_RepresentationItem) RI2 = new StepRepr_RepresentationItem; - RI2->Init(new TCollection_HAsciiString("upper limit")); - Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMU1 = - new StepRepr_ReprItemAndLengthMeasureWithUnit; - RILMU1->Init(MWU1,RI1); - Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMU2 = - new StepRepr_ReprItemAndLengthMeasureWithUnit; - RILMU2->Init(MWU2,RI2); - Model->AddWithRefs(RILMU1); - Model->AddWithRefs(RILMU2); - //Handle(StepRepr_CompoundItemDefinitionMember) CIDM = - // new StepRepr_CompoundItemDefinitionMember; - //Handle(TColStd_HArray1OfTransient) ArrTr = new TColStd_HArray1OfTransient(1,2); - //ArrTr->SetValue(1,RILMU1); - //ArrTr->SetValue(2,RILMU2); - //CIDM->SetArrTransient(ArrTr); - //CIDM->SetName("SET_REPRESENTATION_ITEM"); - //StepRepr_CompoundItemDefinition CID; - //CID.SetValue(CIDM); - Handle(StepRepr_HArray1OfRepresentationItem) HARIVR = - new StepRepr_HArray1OfRepresentationItem(1,2); - HARIVR->SetValue(1,RILMU1); - HARIVR->SetValue(2,RILMU2); - Handle(StepRepr_ValueRange) VR = new StepRepr_ValueRange; - //VR->Init(aName,CID); - VR->Init(aName,HARIVR); - Model->AddEntity(VR); - Handle(StepShape_ShapeDimensionRepresentation) SDimR = - new StepShape_ShapeDimensionRepresentation; - Handle(StepRepr_HArray1OfRepresentationItem) aHARI = - new StepRepr_HArray1OfRepresentationItem(1,1); - aHARI->SetValue(1,VR); - SDimR->Init(aName,aHARI,RC); - Model->AddWithRefs(SDimR); - Handle(StepShape_DimensionalCharacteristicRepresentation) DimCharR = - new StepShape_DimensionalCharacteristicRepresentation; - StepShape_DimensionalCharacteristic DimChar; - DimChar.SetValue(DimSize); - DimCharR->Init(DimChar,SDimR); - Model->AddEntity(DimCharR); - } + // write Tolerances and Dimensions + DGTLabels.Clear(); + DGTTool->GetDimTolLabels(DGTLabels); + if(DGTLabels.Length()<=0) return Standard_False; + for(i=1; i<=DGTLabels.Length(); i++) { + TDF_Label DimTolL = DGTLabels.Value(i); + TDF_LabelSequence ShapeL; + TDF_LabelSequence aNullSeq; + if(!DGTTool->GetRefShapeLabel(DimTolL,ShapeL,aNullSeq)) continue; + // find target shape + TopoDS_Shape aShape = XCAFDoc_ShapeTool::GetShape(ShapeL.Value(1)); + TopLoc_Location Loc; + TColStd_SequenceOfTransient seqRI; + FindEntities( FP, aShape, Loc, seqRI ); + if ( seqRI.Length() <= 0 ) { + FP->Messenger()->SendInfo() << "Warning: Cannot find RI for "<DynamicType()->Name()<Number(PDS)="<Number(PDS)<GetKind(); + Handle(TColStd_HArray1OfReal) aVal = DimTolAttr->GetVal(); + Handle(TCollection_HAsciiString) aName = DimTolAttr->GetName(); + Handle(TCollection_HAsciiString) aDescription = DimTolAttr->GetDescription(); + + // common part of writing D> entities + StepRepr_CharacterizedDefinition CD; + Handle(StepRepr_ShapeAspect) SA = new StepRepr_ShapeAspect; + SA->Init(aName, new TCollection_HAsciiString, PDS, StepData_LTrue); + Model->AddWithRefs(SA); + CD.SetValue(SA); + Handle(StepRepr_PropertyDefinition) PropD = new StepRepr_PropertyDefinition; + PropD->Init(aName,Standard_True,aDescription,CD); + Model->AddWithRefs(PropD); + StepRepr_RepresentedDefinition RD; + RD.SetValue(PropD); + Handle(StepShape_ShapeRepresentation) SR = new StepShape_ShapeRepresentation; + Handle(StepRepr_HArray1OfRepresentationItem) HARI = + new StepRepr_HArray1OfRepresentationItem(1,1); + if(kind<20) + HARI->SetValue(1,EC); + else + HARI->SetValue(1,AF); + SR->Init(aName,HARI,RC); + Handle(StepShape_ShapeDefinitionRepresentation) SDR = new StepShape_ShapeDefinitionRepresentation; + SDR->Init(RD,SR); + Model->AddWithRefs(SDR); + // define aUnit for creation LengthMeasureWithUnit (common for all) + StepBasic_Unit aUnit; + aUnit = GetUnit(RC); + + // specific part of writing D> entities + if(kind<20) { //dimension + Handle(StepShape_DimensionalSize) DimSize = new StepShape_DimensionalSize; + DimSize->Init(SA,aDescription); + Model->AddWithRefs(DimSize); + if(aVal->Length()>1) { + // create MeasureWithUnits + Handle(StepBasic_MeasureValueMember) MVM1 = new StepBasic_MeasureValueMember; + MVM1->SetName("POSITIVE_LENGTH_MEASURE"); + MVM1->SetReal(aVal->Value(1)); + Handle(StepBasic_MeasureWithUnit) MWU1 = new StepBasic_MeasureWithUnit; + MWU1->Init(MVM1,aUnit); + Handle(StepBasic_MeasureValueMember) MVM2 = new StepBasic_MeasureValueMember; + MVM2->SetName("POSITIVE_LENGTH_MEASURE"); + MVM2->SetReal(aVal->Value(2)); + Handle(StepBasic_MeasureWithUnit) MWU2 = new StepBasic_MeasureWithUnit; + MWU2->Init(MVM2,aUnit); + Handle(StepRepr_RepresentationItem) RI1 = new StepRepr_RepresentationItem; + RI1->Init(new TCollection_HAsciiString("lower limit")); + Handle(StepRepr_RepresentationItem) RI2 = new StepRepr_RepresentationItem; + RI2->Init(new TCollection_HAsciiString("upper limit")); + Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMU1 = + new StepRepr_ReprItemAndLengthMeasureWithUnit; + RILMU1->Init(MWU1,RI1); + Handle(StepRepr_ReprItemAndLengthMeasureWithUnit) RILMU2 = + new StepRepr_ReprItemAndLengthMeasureWithUnit; + RILMU2->Init(MWU2,RI2); + Model->AddWithRefs(RILMU1); + Model->AddWithRefs(RILMU2); + //Handle(StepRepr_CompoundItemDefinitionMember) CIDM = + // new StepRepr_CompoundItemDefinitionMember; + //Handle(TColStd_HArray1OfTransient) ArrTr = new TColStd_HArray1OfTransient(1,2); + //ArrTr->SetValue(1,RILMU1); + //ArrTr->SetValue(2,RILMU2); + //CIDM->SetArrTransient(ArrTr); + //CIDM->SetName("SET_REPRESENTATION_ITEM"); + //StepRepr_CompoundItemDefinition CID; + //CID.SetValue(CIDM); + Handle(StepRepr_HArray1OfRepresentationItem) HARIVR = + new StepRepr_HArray1OfRepresentationItem(1,2); + HARIVR->SetValue(1,RILMU1); + HARIVR->SetValue(2,RILMU2); + Handle(StepRepr_ValueRange) VR = new StepRepr_ValueRange; + //VR->Init(aName,CID); + VR->Init(aName,HARIVR); + Model->AddEntity(VR); + Handle(StepShape_ShapeDimensionRepresentation) SDimR = + new StepShape_ShapeDimensionRepresentation; + Handle(StepRepr_HArray1OfRepresentationItem) aHARI = + new StepRepr_HArray1OfRepresentationItem(1,1); + aHARI->SetValue(1,VR); + SDimR->Init(aName,aHARI,RC); + Model->AddWithRefs(SDimR); + Handle(StepShape_DimensionalCharacteristicRepresentation) DimCharR = + new StepShape_DimensionalCharacteristicRepresentation; + StepShape_DimensionalCharacteristic DimChar; + DimChar.SetValue(DimSize); + DimCharR->Init(DimChar,SDimR); + Model->AddEntity(DimCharR); } - else if(kind<50) { //tolerance - if(kind<35) { // tolerance with datum system - TDF_LabelSequence DatumLabels; - DGTTool->GetDatumOfTolerLabels(DimTolL,DatumLabels); - Standard_Integer NbDR = DatumLabels.Length(); - Handle(StepDimTol_HArray1OfDatumReference) HADR = new StepDimTol_HArray1OfDatumReference(1,NbDR); - for(Standard_Integer j=1; j<=NbDR; j++) { - Handle(XCAFDoc_Datum) DatumAttr; - TDF_Label DatumL = DatumLabels.Value(j); - if(!DatumL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) continue; - Handle(TCollection_HAsciiString) aNameD = DatumAttr->GetName(); - Handle(TCollection_HAsciiString) aDescriptionD = DatumAttr->GetDescription(); - Handle(TCollection_HAsciiString) anIdentificationD = DatumAttr->GetIdentification(); - TCollection_AsciiString stmp(aNameD->ToCString()); - stmp.AssignCat(aDescriptionD->ToCString()); - stmp.AssignCat(anIdentificationD->ToCString()); - if(DatumMap.IsBound(stmp)) { - Handle(StepDimTol_Datum) aDatum = - Handle(StepDimTol_Datum)::DownCast(DatumMap.Find(stmp)); - Handle(StepDimTol_DatumReference) DR = new StepDimTol_DatumReference; - DR->Init(j,aDatum); - Model->AddWithRefs(DR); - HADR->SetValue(j,DR); - } - } - // create LengthMeasureWithUnit - Handle(StepBasic_MeasureValueMember) MVM = new StepBasic_MeasureValueMember; - MVM->SetName("LENGTH_MEASURE"); - MVM->SetReal(aVal->Value(1)); - Handle(StepBasic_LengthMeasureWithUnit) LMWU = new StepBasic_LengthMeasureWithUnit; - LMWU->Init(MVM,aUnit); - // create tolerance by it's type - if(kind<24) { - Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR = - new StepDimTol_GeometricToleranceWithDatumReference; - GTWDR->SetDatumSystem(HADR); - Handle(StepDimTol_ModifiedGeometricTolerance) MGT = - new StepDimTol_ModifiedGeometricTolerance; - if(kind==21) MGT->SetModifier(StepDimTol_MaximumMaterialCondition); - else if(kind==22) MGT->SetModifier(StepDimTol_LeastMaterialCondition); - else if(kind==23) MGT->SetModifier(StepDimTol_RegardlessOfFeatureSize); - Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol) GTComplex = - new StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol; - GTComplex->Init(aName,aDescription,LMWU,SA,GTWDR,MGT); - Model->AddWithRefs(GTComplex); - } - else if(kind==24) { - Handle(StepDimTol_AngularityTolerance) aToler = - new StepDimTol_AngularityTolerance; - aToler->Init(aName,aDescription,LMWU,SA,HADR); - Model->AddWithRefs(aToler); - } - else if(kind==25) { - Handle(StepDimTol_CircularRunoutTolerance) aToler = - new StepDimTol_CircularRunoutTolerance; - aToler->Init(aName,aDescription,LMWU,SA,HADR); - Model->AddWithRefs(aToler); - } - else if(kind==26) { - Handle(StepDimTol_CoaxialityTolerance) aToler = - new StepDimTol_CoaxialityTolerance; - aToler->Init(aName,aDescription,LMWU,SA,HADR); - Model->AddWithRefs(aToler); - } - else if(kind==27) { - Handle(StepDimTol_ConcentricityTolerance) aToler = - new StepDimTol_ConcentricityTolerance; - aToler->Init(aName,aDescription,LMWU,SA,HADR); - Model->AddWithRefs(aToler); - } - else if(kind==28) { - Handle(StepDimTol_ParallelismTolerance) aToler = - new StepDimTol_ParallelismTolerance; - aToler->Init(aName,aDescription,LMWU,SA,HADR); - Model->AddWithRefs(aToler); - } - else if(kind==29) { - Handle(StepDimTol_PerpendicularityTolerance) aToler = - new StepDimTol_PerpendicularityTolerance; - aToler->Init(aName,aDescription,LMWU,SA,HADR); - Model->AddWithRefs(aToler); - } - else if(kind==30) { - Handle(StepDimTol_SymmetryTolerance) aToler = - new StepDimTol_SymmetryTolerance; - aToler->Init(aName,aDescription,LMWU,SA,HADR); - Model->AddWithRefs(aToler); - } - else if(kind==31) { - Handle(StepDimTol_TotalRunoutTolerance) aToler = - new StepDimTol_TotalRunoutTolerance; - aToler->Init(aName,aDescription,LMWU,SA,HADR); - Model->AddWithRefs(aToler); + } + else if(kind<50) { //tolerance + if(kind<35) { // tolerance with datum system + TDF_LabelSequence DatumLabels; + DGTTool->GetDatumOfTolerLabels(DimTolL,DatumLabels); + Standard_Integer NbDR = DatumLabels.Length(); + Handle(StepDimTol_HArray1OfDatumReference) HADR = new StepDimTol_HArray1OfDatumReference(1,NbDR); + for(Standard_Integer j=1; j<=NbDR; j++) { + Handle(XCAFDoc_Datum) DatumAttr; + TDF_Label DatumL = DatumLabels.Value(j); + if(!DatumL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) continue; + Handle(TCollection_HAsciiString) aNameD = DatumAttr->GetName(); + Handle(TCollection_HAsciiString) aDescriptionD = DatumAttr->GetDescription(); + Handle(TCollection_HAsciiString) anIdentificationD = DatumAttr->GetIdentification(); + TCollection_AsciiString stmp(aNameD->ToCString()); + stmp.AssignCat(aDescriptionD->ToCString()); + stmp.AssignCat(anIdentificationD->ToCString()); + if(DatumMap.IsBound(stmp)) { + Handle(StepDimTol_Datum) aDatum = + Handle(StepDimTol_Datum)::DownCast(DatumMap.Find(stmp)); + Handle(StepDimTol_DatumReference) DR = new StepDimTol_DatumReference; + DR->Init(j,aDatum); + Model->AddWithRefs(DR); + HADR->SetValue(j,DR); } } + // create LengthMeasureWithUnit + Handle(StepBasic_MeasureValueMember) MVM = new StepBasic_MeasureValueMember; + MVM->SetName("LENGTH_MEASURE"); + MVM->SetReal(aVal->Value(1)); + Handle(StepBasic_LengthMeasureWithUnit) LMWU = new StepBasic_LengthMeasureWithUnit; + LMWU->Init(MVM,aUnit); + // create tolerance by it's type + if(kind<24) { + Handle(StepDimTol_GeometricToleranceWithDatumReference) GTWDR = + new StepDimTol_GeometricToleranceWithDatumReference; + GTWDR->SetDatumSystem(HADR); + Handle(StepDimTol_ModifiedGeometricTolerance) MGT = + new StepDimTol_ModifiedGeometricTolerance; + if(kind==21) MGT->SetModifier(StepDimTol_MaximumMaterialCondition); + else if(kind==22) MGT->SetModifier(StepDimTol_LeastMaterialCondition); + else if(kind==23) MGT->SetModifier(StepDimTol_RegardlessOfFeatureSize); + Handle(StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol) GTComplex = + new StepDimTol_GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol; + GTComplex->Init(aName,aDescription,LMWU,SA,GTWDR,MGT); + Model->AddWithRefs(GTComplex); + } + else if(kind==24) { + Handle(StepDimTol_AngularityTolerance) aToler = + new StepDimTol_AngularityTolerance; + aToler->Init(aName,aDescription,LMWU,SA,HADR); + Model->AddWithRefs(aToler); + } + else if(kind==25) { + Handle(StepDimTol_CircularRunoutTolerance) aToler = + new StepDimTol_CircularRunoutTolerance; + aToler->Init(aName,aDescription,LMWU,SA,HADR); + Model->AddWithRefs(aToler); + } + else if(kind==26) { + Handle(StepDimTol_CoaxialityTolerance) aToler = + new StepDimTol_CoaxialityTolerance; + aToler->Init(aName,aDescription,LMWU,SA,HADR); + Model->AddWithRefs(aToler); + } + else if(kind==27) { + Handle(StepDimTol_ConcentricityTolerance) aToler = + new StepDimTol_ConcentricityTolerance; + aToler->Init(aName,aDescription,LMWU,SA,HADR); + Model->AddWithRefs(aToler); + } + else if(kind==28) { + Handle(StepDimTol_ParallelismTolerance) aToler = + new StepDimTol_ParallelismTolerance; + aToler->Init(aName,aDescription,LMWU,SA,HADR); + Model->AddWithRefs(aToler); + } + else if(kind==29) { + Handle(StepDimTol_PerpendicularityTolerance) aToler = + new StepDimTol_PerpendicularityTolerance; + aToler->Init(aName,aDescription,LMWU,SA,HADR); + Model->AddWithRefs(aToler); + } + else if(kind==30) { + Handle(StepDimTol_SymmetryTolerance) aToler = + new StepDimTol_SymmetryTolerance; + aToler->Init(aName,aDescription,LMWU,SA,HADR); + Model->AddWithRefs(aToler); + } + else if(kind==31) { + Handle(StepDimTol_TotalRunoutTolerance) aToler = + new StepDimTol_TotalRunoutTolerance; + aToler->Init(aName,aDescription,LMWU,SA,HADR); + Model->AddWithRefs(aToler); + } } } - - return Standard_True; } + return Standard_True; +} + //======================================================================= //function : WriteDGTsAP242 //purpose : @@ -5517,7 +5554,7 @@ Standard_Boolean STEPCAFControl_Writer::GetMaterialMode() const void STEPCAFControl_Writer::SetKinematicsMode(const Standard_Boolean kinematicsmod) { - myKPairMode = kinematicsmod; + myKinematicMode = kinematicsmod; } //======================================================================= @@ -5527,5 +5564,5 @@ void STEPCAFControl_Writer::SetKinematicsMode(const Standard_Boolean kinematicsm Standard_Boolean STEPCAFControl_Writer::GetKinematicsMode() const { - return myKPairMode; + return myKinematicMode; } diff --git a/src/STEPCAFControl/STEPCAFControl_Writer.hxx b/src/STEPCAFControl/STEPCAFControl_Writer.hxx index fd1515922a..371cf0ac03 100644 --- a/src/STEPCAFControl/STEPCAFControl_Writer.hxx +++ b/src/STEPCAFControl/STEPCAFControl_Writer.hxx @@ -150,8 +150,8 @@ public: Standard_EXPORT Standard_Boolean GetMaterialMode() const; - //! Set dimtolmode for indicate write D>s or not. - Standard_EXPORT void SetKinematicsMode(const Standard_Boolean kinematicsmod); + //! Set Kinematic mode for indicate write kinematics or not. + Standard_EXPORT void SetKinematicsMode(const Standard_Boolean kinematicmode); Standard_EXPORT Standard_Boolean GetKinematicsMode() const; @@ -237,7 +237,7 @@ private: Standard_Boolean myLayerMode; Standard_Boolean myPropsMode; Standard_Boolean mySHUOMode; - Standard_Boolean myKPairMode; + Standard_Boolean myKinematicMode; MoniTool_DataMapOfShapeTransient myMapCompMDGPR; Standard_Boolean myGDTMode; Standard_Boolean myMatMode; diff --git a/src/StepKinematics/StepKinematics_ActuatedKinPairAndOrderKinPair.cxx b/src/StepKinematics/StepKinematics_ActuatedKinPairAndOrderKinPair.cxx index ec55f80bb6..a47ecbe14d 100644 --- a/src/StepKinematics/StepKinematics_ActuatedKinPairAndOrderKinPair.cxx +++ b/src/StepKinematics/StepKinematics_ActuatedKinPairAndOrderKinPair.cxx @@ -1,7 +1,6 @@ -// Created on : Sat May 02 12:41:15 2020 -// Created by: Irina KRYLOVA -// Generator: Express (EXPRESS -> CASCADE/XSTEP Translator) V3.0 -// Copyright (c) Open CASCADE 2020 +// Created on: 2020-05-26 +// Created by: PASUKHIN DMITRY +// Copyright (c) 2020 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // diff --git a/src/StepKinematics/StepKinematics_ActuatedKinPairAndOrderKinPair.hxx b/src/StepKinematics/StepKinematics_ActuatedKinPairAndOrderKinPair.hxx index 41addfa989..e9e8b3ec5b 100644 --- a/src/StepKinematics/StepKinematics_ActuatedKinPairAndOrderKinPair.hxx +++ b/src/StepKinematics/StepKinematics_ActuatedKinPairAndOrderKinPair.hxx @@ -1,7 +1,6 @@ -// Created on : Sat May 02 12:41:15 2020 -// Created by: Irina KRYLOVA -// Generator: Express (EXPRESS -> CASCADE/XSTEP Translator) V3.0 -// Copyright (c) Open CASCADE 2020 +// Created on: 2020-05-26 +// Created by: PASUKHIN DMITRY +// Copyright (c) 2020 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // @@ -47,62 +46,6 @@ public : const Handle(StepKinematics_KinematicJoint)& theJoint, const Handle(StepKinematics_ActuatedKinematicPair)& theActuatedKinematicPair, const Handle(StepKinematics_KinematicPair)& theOrderKinematicPair); - ////! Initialize all fields for low order kinematic pair - //Standard_EXPORT void Init(const Handle(TCollection_HAsciiString)& theRepresentationItem_Name, - // const Handle(TCollection_HAsciiString)& theItemDefinedTransformation_Name, - // const Standard_Boolean hasItemDefinedTransformation_Description, - // const Handle(TCollection_HAsciiString)& theItemDefinedTransformation_Description, - // const Handle(StepRepr_RepresentationItem)& theItemDefinedTransformation_TransformItem1, - // const Handle(StepRepr_RepresentationItem)& theItemDefinedTransformation_TransformItem2, - // const Handle(StepKinematics_KinematicJoint)& theKinematicPair_Joint, - // const Standard_Boolean theLowOrderKinematicPair_TX, - // const Standard_Boolean theLowOrderKinematicPair_TY, - // const Standard_Boolean theLowOrderKinematicPair_TZ, - // const Standard_Boolean theLowOrderKinematicPair_RX, - // const Standard_Boolean theLowOrderKinematicPair_RY, - // const Standard_Boolean theLowOrderKinematicPair_RZ, - // const Standard_Boolean hasUniversalPair_InputSkewAngle, - // const Standard_Real theUniversalPair_InputSkewAngle, - // const Standard_Boolean hasLowerLimitFirstRotation, - // const Standard_Real theLowerLimitFirstRotation, - // const Standard_Boolean hasUpperLimitFirstRotation, - // const Standard_Real theUpperLimitFirstRotation, - // const Standard_Boolean hasLowerLimitSecondRotation, - // const Standard_Real theLowerLimitSecondRotation, - // const Standard_Boolean hasUpperLimitSecondRotation, - // const Standard_Real theUpperLimitSecondRotation); - - ////! Initialize all fields for low order kinematic pair with motions coupling - //Standard_EXPORT void Init(const Handle(TCollection_HAsciiString)& theRepresentationItem_Name, - // const Handle(TCollection_HAsciiString)& theItemDefinedTransformation_Name, - // const Standard_Boolean hasItemDefinedTransformation_Description, - // const Handle(TCollection_HAsciiString)& theItemDefinedTransformation_Description, - // const Handle(StepRepr_RepresentationItem)& theItemDefinedTransformation_TransformItem1, - // const Handle(StepRepr_RepresentationItem)& theItemDefinedTransformation_TransformItem2, - // const Handle(StepKinematics_KinematicJoint)& theKinematicPair_Joint, - // const Standard_Real theScrewPair_Pitch, - // const Standard_Real theGearPair_RadiusFirstLink, - // const Standard_Real theGearPair_RadiusSecondLink, - // const Standard_Real theGearPair_Bevel, - // const Standard_Real theGearPair_HelicalAngle, - // const Standard_Real theGearPair_GearRatio, - // const Standard_Boolean hasLowerLimitActualRotation1, - // const Standard_Real theLowerLimitActualRotation1, - // const Standard_Boolean hasUpperLimitActualRotation1, - // const Standard_Real theUpperLimitActualRotation1, - // const Handle(TColStd_HArray1OfReal) theParams); - - ////! Initialize all fields for high order kinematic pair - //Standard_EXPORT void Init(const Handle(TCollection_HAsciiString)& theRepresentationItem_Name, - // const Handle(TCollection_HAsciiString)& theItemDefinedTransformation_Name, - // const Standard_Boolean hasItemDefinedTransformation_Description, - // const Handle(TCollection_HAsciiString)& theItemDefinedTransformation_Description, - // const Handle(StepRepr_RepresentationItem)& theItemDefinedTransformation_TransformItem1, - // const Handle(StepRepr_RepresentationItem)& theItemDefinedTransformation_TransformItem2, - // const Handle(StepKinematics_KinematicJoint)& theKinematicPair_Joint, - // const Standard_Boolean theOrientation, - // const Handle(TColStd_HArray1OfReal) theLimits, - // const NCollection_Array1 theGeom); inline void SetActuatedKinematicPair(const Handle(StepKinematics_ActuatedKinematicPair)& aKP) { myActuatedKinematicPair = aKP; @@ -118,40 +61,6 @@ public : inline Handle(StepKinematics_KinematicPair) GetOrderKinematicPair() const { return myOrderKinematicPair; } - ////! Returns field LowerLimitFirstRotation - //Standard_EXPORT Standard_Real LowerLimitFirstRotation() const; - ////! Sets field LowerLimitFirstRotation - //Standard_EXPORT void SetLowerLimitFirstRotation(const Standard_Real theLowerLimitFirstRotation); - ////! Returns True if optional field LowerLimitFirstRotation is defined - //Standard_EXPORT Standard_Boolean HasLowerLimitFirstRotation() const; - - ////! Returns field UpperLimitFirstRotation - //Standard_EXPORT Standard_Real UpperLimitFirstRotation() const; - ////! Sets field UpperLimitFirstRotation - //Standard_EXPORT void SetUpperLimitFirstRotation(const Standard_Real theUpperLimitFirstRotation); - ////! Returns True if optional field UpperLimitFirstRotation is defined - //Standard_EXPORT Standard_Boolean HasUpperLimitFirstRotation() const; - - ////! Returns field LowerLimitSecondRotation - //Standard_EXPORT Standard_Real LowerLimitSecondRotation() const; - ////! Sets field LowerLimitSecondRotation - //Standard_EXPORT void SetLowerLimitSecondRotation(const Standard_Real theLowerLimitSecondRotation); - ////! Returns True if optional field LowerLimitSecondRotation is defined - //Standard_EXPORT Standard_Boolean HasLowerLimitSecondRotation() const; - - ////! Returns field UpperLimitSecondRotation - //Standard_EXPORT Standard_Real UpperLimitSecondRotation() const; - ////! Sets field UpperLimitSecondRotation - //Standard_EXPORT void SetUpperLimitSecondRotation(const Standard_Real theUpperLimitSecondRotation); - ////! Returns True if optional field UpperLimitSecondRotation is defined - //Standard_EXPORT Standard_Boolean HasUpperLimitSecondRotation() const; - - ////! Returns field InputSkewAngle - //Standard_EXPORT Standard_Real InputSkewAngle() const; - ////! Sets field InputSkewAngle - //Standard_EXPORT void SetInputSkewAngle(const Standard_Real theInputSkewAngle); - ////! Returns True if optional field InputSkewAngle is defined - //Standard_EXPORT Standard_Boolean HasInputSkewAngle() const; DEFINE_STANDARD_RTTIEXT(StepKinematics_ActuatedKinPairAndOrderKinPair, StepKinematics_KinematicPair) @@ -159,44 +68,5 @@ DEFINE_STANDARD_RTTIEXT(StepKinematics_ActuatedKinPairAndOrderKinPair, StepKinem private: Handle(StepKinematics_ActuatedKinematicPair) myActuatedKinematicPair; Handle(StepKinematics_KinematicPair) myOrderKinematicPair; - //Standard_Boolean myTX; - //Standard_Boolean myTY; - //Standard_Boolean myTZ; - //Standard_Boolean myRX; - //Standard_Boolean myRY; - //Standard_Boolean myRZ; - //Standard_Boolean defInputSkewAngle; //!< flag "is InputSkewAngle defined" - //Standard_Real myMinRotationX; //!< minimum value of the yaw angle - //Standard_Real myMaxRotationX; //!< maximum value of the yaw angle - //Standard_Real myMinRotationY; //!< minimum value of the pitch angle - //Standard_Real myMaxRotationY; //!< maximum value of the pitch angle - //Standard_Real myMinRotationZ; //!< minimum value of the roll angle - //Standard_Real myMaxRotationZ; //!< maximum value of the roll angle - //Standard_Real myMinTranslationX; //!< minimum value of translation in x-direction - //Standard_Real myMaxTranslationX; //!< maximum value of translation in x-direction - //Standard_Real myMinTranslationY; //!< minimum value of translation in y-direction - //Standard_Real myMaxTranslationY; //!< maximum value of translation in y-direction - //Standard_Real myMinTranslationZ; //!< minimum value of translation in z-direction - //Standard_Real myMaxTranslationZ; //!< maximum value of translation in z-direction - //Standard_Real myLowerLimitFirstRotation; //!< optional - //Standard_Real myUpperLimitFirstRotation; //!< optional - //Standard_Real myLowerLimitSecondRotation; //!< optional - //Standard_Real myUpperLimitSecondRotation; //!< optional - //Standard_Boolean defLowerLimitFirstRotation; //!< flag "is LowerLimitFirstRotation defined" - //Standard_Boolean defUpperLimitFirstRotation; //!< flag "is UpperLimitFirstRotation defined" - //Standard_Boolean defLowerLimitSecondRotation; //!< flag "is LowerLimitSecondRotation defined" - //Standard_Boolean defUpperLimitSecondRotation; //!< flag "is UpperLimitSecondRotation defined" - //Standard_Real myRadiusFirstLink; - //Standard_Real myRadiusSecondLink; - //Standard_Real myBevel; - //Standard_Real myHelicalAngle; - //Standard_Real myGearRatio; - //Standard_Real mySkewAngle; //!< param for universal/homokinetic pair - //Standard_Real myLowLimit; //!< low limit of motion range - //Standard_Real myUpperLimit; //!< upper limit of motion range - //Handle(TColStd_HArray1OfReal) myParams; //!< additional parameters of kinematic pair - //Standard_Boolean myOrientation; //!< orientation - //Handle(TColStd_HArray1OfReal) myLimits; //!< array of limits, size depends on type - //NCollection_Array1 myGeom; //!< curve(s) or surface(s) attributes }; #endif // StepKinematics_ActuatedKinPairAndOrderKinPair diff --git a/src/StepKinematics/StepKinematics_MechanismStateRepresentation.cxx b/src/StepKinematics/StepKinematics_MechanismStateRepresentation.cxx index fae011f0d6..333be3f1b3 100644 --- a/src/StepKinematics/StepKinematics_MechanismStateRepresentation.cxx +++ b/src/StepKinematics/StepKinematics_MechanismStateRepresentation.cxx @@ -1,6 +1,6 @@ -// Created on: 2016-04-26 -// Created by: Irina KRYLOVA -// Copyright (c) 2016 OPEN CASCADE SAS +// Created on: 2020-06-18 +// Created by: PASUKHIN DMITRY +// Copyright (c) 2020 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // diff --git a/src/StepKinematics/StepKinematics_MechanismStateRepresentation.hxx b/src/StepKinematics/StepKinematics_MechanismStateRepresentation.hxx index fed3126919..f72a364b4f 100644 --- a/src/StepKinematics/StepKinematics_MechanismStateRepresentation.hxx +++ b/src/StepKinematics/StepKinematics_MechanismStateRepresentation.hxx @@ -1,6 +1,6 @@ -// Created on: 2016-04-26 -// Created by: Irina KRYLOVA -// Copyright (c) 2016 OPEN CASCADE SAS +// Created on: 2020-06-18 +// Created by: PASUKHIN DMITRY +// Copyright (c) 2020 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // diff --git a/src/XCAFDoc/XCAFDoc.cxx b/src/XCAFDoc/XCAFDoc.cxx index d7c42c2649..a9b6f2edba 100644 --- a/src/XCAFDoc/XCAFDoc.cxx +++ b/src/XCAFDoc/XCAFDoc.cxx @@ -339,7 +339,7 @@ const Standard_GUID& XCAFDoc::KinematicRefLink2GUID() Standard_EXPORT const Standard_GUID& XCAFDoc::KinematicRefJointGUID() { - static const Standard_GUID ID("6AA96F91-7436-46F9-A955-4B3CCC42692B"); + static const Standard_GUID ID("596B048C-A965-4514-A059-464560BFAE4E"); return ID; } diff --git a/src/XCAFDoc/XCAFDoc_KinematicPair.cxx b/src/XCAFDoc/XCAFDoc_KinematicPair.cxx index 5fc0453ceb..60370244ce 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicPair.cxx +++ b/src/XCAFDoc/XCAFDoc_KinematicPair.cxx @@ -14,10 +14,10 @@ // commercial license or contractual agreement. #include - #include #include #include +#include #include #include #include @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -110,22 +111,6 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t { Backup(); - for (TDF_ChildIterator anIter(Label()); anIter.More(); anIter.Next()) - { - // Check if it needs to clear value label - if (anIter.Value().IsEqual(Label().FindChild(ChildLab_Value))) { - Handle(TDataStd_Integer) aTypeAttr; - if (Label().FindAttribute(TDataStd_Integer::GetID(), aTypeAttr)) - { - int aType = aTypeAttr->Get(); - if (aType != theObject->Type()) - anIter.Value().ForgetAllAttributes(); - } - } - else - anIter.Value().ForgetAllAttributes(); - } - // Common attributes if (!theObject->Name().IsEmpty()) TDataStd_Name::Set(Label(), theObject->Name()); @@ -133,7 +118,7 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t TDataXtd_Plane::Set(Label().FindChild(ChildLab_FirstTrsf), gp_Pln(theObject->FirstTransformation())); TDataXtd_Plane::Set(Label().FindChild(ChildLab_SecondTrsf), gp_Pln(theObject->SecondTransformation())); - if (!theObject->GetAllLimits().IsNull() && theObject->GetAllLimits()->Length() > 0) { + if (!theObject->GetAllLimits().IsNull() && theObject->HasLimits()) { Handle(TDataStd_RealArray) aLimitsAttr; aLimitsAttr = TDataStd_RealArray::Set(Label(), getLimitsID(), 1, theObject->GetAllLimits()->Length()); aLimitsAttr->ChangeArray(theObject->GetAllLimits()); @@ -149,7 +134,7 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t // Low order pairs with motion coupling if (theObject->Type() >= XCAFKinematics_PairType_Screw && - theObject->Type() <= XCAFKinematics_PairType_Gear) { + theObject->Type() <= XCAFKinematics_PairType_LinearFlexibleAndPinion) { Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObject = Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(theObject); if (!anObject->GetAllParams().IsNull() && anObject->GetAllParams()->Upper() > 0) { @@ -166,10 +151,13 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t Handle(XCAFKinematics_HighOrderPairObject)::DownCast(theObject); TDataStd_Integer::Set(Label(), getParamsID(), (Standard_Integer)anObject->Orientation()); BRep_Builder aBuilder; - if (theObject->Type() >= XCAFKinematics_PairType_PointOnSurface && !anObject->Surface().IsNull()) + if (theObject->Type() == XCAFKinematics_PairType_PointOnSurface && !anObject->Surface().IsNull()) { TopoDS_Face aFace; - aBuilder.MakeFace(aFace, anObject->Surface(), Precision::Confusion()); + if (anObject->HasLimits()) + aBuilder.MakeFace(aFace, anObject->TrimmedSurface(), Precision::Confusion()); + else + aBuilder.MakeFace(aFace, anObject->Surface(), Precision::Confusion()); TNaming_Builder aTNBuild(Label().FindChild(ChildLab_FirstGeomParam)); aTNBuild.Generated(aFace); } @@ -191,7 +179,10 @@ void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& t if (theObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve && !anObject->Curve().IsNull()) { TopoDS_Edge anEdge; - aBuilder.MakeEdge(anEdge, anObject->Curve(), Precision::Confusion()); + if (anObject->HasLimits()) + aBuilder.MakeEdge(anEdge, anObject->TrimmedCurve(), Precision::Confusion()); + else + aBuilder.MakeEdge(anEdge, anObject->Curve(), Precision::Confusion()); TNaming_Builder aTNBuild(Label().FindChild(ChildLab_FirstGeomParam)); aTNBuild.Generated(anEdge); } diff --git a/src/XCAFDoc/XCAFDoc_KinematicPairValue.cxx b/src/XCAFDoc/XCAFDoc_KinematicPairValue.cxx index 4a6eb94c97..f5952e33bf 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicPairValue.cxx +++ b/src/XCAFDoc/XCAFDoc_KinematicPairValue.cxx @@ -29,12 +29,6 @@ IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_KinematicPairValue, TDF_Attribute) -// Gor first children are reserved for kinematic pair parameters -enum ValueLab -{ - ValueLab_Values = 3 -}; - //======================================================================= //function : XCAFDoc_KinematicPairValue //purpose : diff --git a/src/XCAFDoc/XCAFDoc_KinematicTool.cxx b/src/XCAFDoc/XCAFDoc_KinematicTool.cxx index b41c5a3e7d..989d91b2c2 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicTool.cxx +++ b/src/XCAFDoc/XCAFDoc_KinematicTool.cxx @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -126,15 +127,23 @@ void XCAFDoc_KinematicTool::RemoveMechanism(const TDF_Label& theLabel) //function : AddLink //purpose : //======================================================================= -TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism) +TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism, + const Standard_Boolean& IsBase) { if (!IsMechanism(theMechanism)) return TDF_Label(); TDF_TagSource aTag; TDF_Label aLink = aTag.NewChild(getRootOfLinks(theMechanism)); - TCollection_AsciiString aName = "Link "; - aName.AssignCat(TCollection_AsciiString(aLink.Tag())); - TDataStd_Name::Set(aLink, aName); + if (IsBase) + { + SetBaseLink(aLink); + } + else + { + TCollection_AsciiString aName = "Link "; + aName.AssignCat(TCollection_AsciiString(aLink.Tag())); + TDataStd_Name::Set(aLink, aName); + } return aLink; } @@ -143,90 +152,10 @@ TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism) //purpose : //======================================================================= TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism, - const TDF_LabelSequence& theShapes) -{ - TDF_Label aNewLink = AddLink(theMechanism); - if (aNewLink.IsNull() || theShapes.Length() == 0) - return aNewLink; - - SetLink(aNewLink, theShapes); - return aNewLink; -} - -TDF_Label XCAFDoc_KinematicTool::AddBaseLink(const TDF_Label& theMechanism) -{ - if (!IsMechanism(theMechanism)) - return TDF_Label(); - TDF_Label aRootOfLink = getRootOfLinks(theMechanism); - if (aRootOfLink.HasChild()) - { - TDF_Label aFirstLink = aRootOfLink.FindChild(1, Standard_False); - TDF_Label aResLink; - Handle(TDataStd_Name) aNameOfFirst; - aFirstLink.FindAttribute(TDataStd_Name::GetID(), aNameOfFirst); - if (!aNameOfFirst.IsNull() && !aNameOfFirst->Get().IsEqual("Base") && !aNameOfFirst->Get().IsEqual("Link 1")) - { - TDF_TagSource aTag; - TDF_Label aResLink = aTag.NewChild(aRootOfLink); - aResLink.AddAttribute(aNameOfFirst); - } - else - aResLink = AddLink(theMechanism); - - TDF_LabelSequence theShapes = GetRefShapes(aFirstLink); - SetLink(aResLink, theShapes); - - Handle(TDataStd_TreeNode) aJointNode, aLinkNode, aNewLinkNode, aNewJointNode; - if (aFirstLink.FindAttribute(XCAFDoc::KinematicRefLink1GUID(), aJointNode)) - { - aJointNode = aJointNode->First(); - while (!aJointNode.IsNull()) - { - TDF_Label aJoint = aJointNode->Label(); - aNewJointNode = TDataStd_TreeNode::Set(aJoint, XCAFDoc::KinematicRefLink1GUID()); - aNewLinkNode = TDataStd_TreeNode::Set(aResLink, XCAFDoc::KinematicRefLink1GUID()); - aNewJointNode->Remove(); // fix against bug in TreeNode::Append() - aNewLinkNode->Append(aNewJointNode); - - aJointNode = aJointNode->Next(); - } - } - if (aFirstLink.FindAttribute(XCAFDoc::KinematicRefLink2GUID(), aJointNode)) - { - aJointNode = aJointNode->First(); - while (!aJointNode.IsNull()) - { - TDF_Label aJoint = aJointNode->Label(); - aNewJointNode = TDataStd_TreeNode::Set(aJoint, XCAFDoc::KinematicRefLink2GUID()); - aNewLinkNode = TDataStd_TreeNode::Set(aResLink, XCAFDoc::KinematicRefLink2GUID()); - aNewJointNode->Remove(); // fix against bug in TreeNode::Append() - aNewLinkNode->Append(aNewJointNode); - - aJointNode = aJointNode->Next(); - } - } - } - TDF_Label aBaseLink = aRootOfLink.FindChild(1); - aBaseLink.ForgetAllAttributes(Standard_False); - TCollection_AsciiString aName = "Base"; - TDataStd_Name::Set(aBaseLink, aName); - return aBaseLink; -} - -TDF_Label XCAFDoc_KinematicTool::AddBaseLink(const TDF_Label& theMechanism, const TDF_Label& theShape) -{ - TDF_LabelSequence anAuxSequence; - anAuxSequence.Append(theShape); - return AddBaseLink(theMechanism, anAuxSequence); -} - -//======================================================================= -//function : AddBaseLink -//purpose : -//======================================================================= -TDF_Label XCAFDoc_KinematicTool::AddBaseLink(const TDF_Label& theMechanism, const TDF_LabelSequence& theShapes) + const TDF_LabelSequence& theShapes, + const Standard_Boolean& IsBase) { - TDF_Label aNewLink = AddBaseLink(theMechanism); + TDF_Label aNewLink = AddLink(theMechanism, IsBase); if (aNewLink.IsNull() || theShapes.Length() == 0) return aNewLink; @@ -239,11 +168,12 @@ TDF_Label XCAFDoc_KinematicTool::AddBaseLink(const TDF_Label& theMechanism, cons //purpose : //======================================================================= TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism, - const TDF_Label& theShape) + const TDF_Label& theShape, + const Standard_Boolean& IsBase) { TDF_LabelSequence anAuxSequence; anAuxSequence.Append(theShape); - return AddLink(theMechanism, anAuxSequence); + return AddLink(theMechanism, anAuxSequence, IsBase); } //======================================================================= @@ -288,6 +218,35 @@ Standard_Boolean XCAFDoc_KinematicTool::SetLink(const TDF_Label& theLink, return Standard_True; } +//======================================================================= +//function : SetBaseLink +//purpose : +//======================================================================= +Standard_EXPORT Standard_Boolean XCAFDoc_KinematicTool::SetBaseLink(const TDF_Label& theLink) +{ + TDataStd_Name::Set(theLink, "Base"); + TDF_Label aMechanism = theLink.Father().Father(); + if (!IsMechanism(aMechanism)) + return Standard_False; + TDF_LabelSequence aLinks = GetLinks(aMechanism); + for (Standard_Integer anInd = 1; anInd <= aLinks.Length(); ++anInd) + { + Handle(TDataStd_Integer) aBase; + if (aLinks(anInd).FindAttribute(TDataStd_Integer::GetID(), aBase)) + { + aLinks(anInd).ForgetAttribute(aBase); + Handle(TDataStd_Name) aLinkName; + if (aLinks(anInd).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); + } + } + } + TDataStd_Integer::Set(theLink, 1); +} + //======================================================================= //function : SetLink //purpose : @@ -434,7 +393,7 @@ void XCAFDoc_KinematicTool::RemoveJoint(const TDF_Label& theJoint) } -Standard_EXPORT Standard_Boolean XCAFDoc_KinematicTool::IsValue(const TDF_Label& theValue) const +Standard_Boolean XCAFDoc_KinematicTool::IsValue(const TDF_Label& theValue) const { Handle(XCAFDoc_KinematicPairValue) anAttr; return theValue.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), anAttr); @@ -549,15 +508,15 @@ TDF_LabelSequence XCAFDoc_KinematicTool::GetJointsOfLink(const TDF_Label& theLin //function : AddState //purpose : //======================================================================= -Standard_EXPORT TDF_Label XCAFDoc_KinematicTool::AddState(const TDF_Label& theMechanism) +TDF_Label XCAFDoc_KinematicTool::AddState(const TDF_Label& theMechanism) { if (!IsMechanism(theMechanism)) return TDF_Label(); - TDF_Label aRootOfState= getRootOfStates(theMechanism); + TDF_Label aRootOfState = getRootOfStates(theMechanism); if (aRootOfState.IsNull()) { - aRootOfState = theMechanism.FindChild(3);; + aRootOfState = theMechanism.FindChild(3); TDataStd_Name::Set(aRootOfState, "States"); } TDF_TagSource aTag; @@ -572,20 +531,28 @@ Standard_EXPORT TDF_Label XCAFDoc_KinematicTool::AddState(const TDF_Label& theMe //function : GetStates //purpose : //======================================================================= -Standard_EXPORT TDF_LabelSequence XCAFDoc_KinematicTool::GetStates(const TDF_Label& theMechanism) const +TDF_LabelSequence XCAFDoc_KinematicTool::GetStates(const TDF_Label& theMechanism) const { - TDF_Label aRootOfState = getRootOfStates(theMechanism); TDF_LabelSequence aStatesArray; + if (!IsMechanism(theMechanism)) + return aStatesArray; + + TDF_Label aRootOfState = getRootOfStates(theMechanism); if (!IsMechanism(theMechanism) || aRootOfState.IsNull()) return aStatesArray; for (TDF_ChildIterator anIt(aRootOfState); anIt.More(); anIt.Next()) { TDF_Label aState = anIt.Value(); - aStatesArray.Append(aState); + if(!GetValuesOfState(aState).IsEmpty()) + aStatesArray.Append(aState); } return aStatesArray; } +//======================================================================= +//function : GetValuesOfState +//purpose : +//======================================================================= Standard_EXPORT TDF_LabelSequence XCAFDoc_KinematicTool::GetValuesOfState(const TDF_Label& theState) const { TDF_LabelSequence aValueArray; @@ -605,7 +572,7 @@ Standard_EXPORT TDF_LabelSequence XCAFDoc_KinematicTool::GetValuesOfState(const //function : GetJointOfValue //purpose : //======================================================================= -Standard_EXPORT TDF_Label XCAFDoc_KinematicTool::GetJointOfValue(const TDF_Label& theValue) const +TDF_Label XCAFDoc_KinematicTool::GetJointOfValue(const TDF_Label& theValue) const { TDF_Label aJoint; if (!IsValue(theValue)) @@ -618,24 +585,46 @@ Standard_EXPORT TDF_Label XCAFDoc_KinematicTool::GetJointOfValue(const TDF_Label return aJoint; } +//======================================================================= +//function : GetValuesOfJoint +//purpose : +//======================================================================= +TDF_LabelSequence XCAFDoc_KinematicTool::GetValuesOfJoint(const TDF_Label& theJoint) const +{ + TDF_LabelSequence aValuesArray; + if (!IsJoint(theJoint)) + return aValuesArray; + + Handle(TDataStd_TreeNode) aNode, aChildNode; + + if (theJoint.FindAttribute(XCAFDoc::KinematicRefJointGUID(), aNode)) { + aChildNode = aNode->First(); + while (!aChildNode.IsNull()) { + aValuesArray.Append(aChildNode->Label()); + aChildNode = aChildNode->Next(); + } + } + return aValuesArray; +} + //======================================================================= //function : RemoveState //purpose : //======================================================================= -Standard_EXPORT void XCAFDoc_KinematicTool::RemoveState(const TDF_Label& theState) +void XCAFDoc_KinematicTool::RemoveState(const TDF_Label& theState) { TDF_Label aMechanism = theState.Father().Father(); if (!IsMechanism(aMechanism) || theState.Father().Tag() != 3) return; - Handle(TDataStd_TreeNode) aNode; - theState.FindAttribute(XCAFDoc::KinematicRefLink1GUID(), aNode); - aNode->Remove(); - + TDF_LabelSequence aSeqOfValues = GetValuesOfState(theState); + for (Standard_Integer anInd = 1; anInd <= aSeqOfValues.Length(); ++anInd) + { + aSeqOfValues(anInd).FindAttribute(XCAFDoc::KinematicRefJointGUID(), aNode); + aNode->Remove(); + aSeqOfValues(anInd).ForgetAllAttributes(); + } theState.ForgetAllAttributes(); - TDF_Label theStates = theState.Father(); - if (!theStates.HasChild()) - theStates.ForgetAllAttributes(); } //======================================================================= @@ -675,7 +664,7 @@ TDF_Label XCAFDoc_KinematicTool::getRootOfJoints(const TDF_Label& theMechanism) //function : getRootOfStates //purpose : //======================================================================= -Standard_EXPORT TDF_Label XCAFDoc_KinematicTool::getRootOfStates(const TDF_Label& theMechanism) const +TDF_Label XCAFDoc_KinematicTool::getRootOfStates(const TDF_Label& theMechanism) const { return theMechanism.FindChild(3, Standard_False); } diff --git a/src/XCAFDoc/XCAFDoc_KinematicTool.hxx b/src/XCAFDoc/XCAFDoc_KinematicTool.hxx index 747a9bbbde..1719f0d848 100644 --- a/src/XCAFDoc/XCAFDoc_KinematicTool.hxx +++ b/src/XCAFDoc/XCAFDoc_KinematicTool.hxx @@ -63,44 +63,27 @@ public: //! Adds new empty label for link. //! \param[in] theMechanism parent mechanism - //! \return created link label - Standard_EXPORT TDF_Label AddLink(const TDF_Label& theMechanism); - - //! Adds new label with link. - //! param[in] theMechanism parent mechanism - //! param[in] theShapes all details of link + //! param[in] IsBase link is base of mechanism //! \return created link label Standard_EXPORT TDF_Label AddLink(const TDF_Label& theMechanism, - const TDF_LabelSequence& theShapes); - - //! Adds new empty label for link. - //! \replace first link into the end, if it exist - //! \param[in] theMechanism parent mechanism - //! \return created link label - Standard_EXPORT TDF_Label AddBaseLink(const TDF_Label& theMechanism); + const Standard_Boolean& IsBase = Standard_False); //! Adds new label with link. - //! \replace first link into the end, if it exist - //! \param[in] theMechanism parent mechanism - //! \param[in] theShape singular detail of link - //! \return created link label - Standard_EXPORT TDF_Label AddBaseLink(const TDF_Label& theMechanism, - const TDF_Label& theShapes); - - //! Adds new label with link. - //! \replace first link into the end, if it exist //! param[in] theMechanism parent mechanism //! param[in] theShapes all details of link + //! param[in] IsBase link is base of mechanism //! \return created link label - Standard_EXPORT TDF_Label AddBaseLink(const TDF_Label& theMechanism, - const TDF_LabelSequence& theShapes); + Standard_EXPORT TDF_Label AddLink(const TDF_Label& theMechanism, + const TDF_LabelSequence& theShapes, + const Standard_Boolean& IsBase = Standard_False); //! Adds new label with link. //! \param[in] theMechanism parent mechanism //! \param[in] theShape singular detail of link //! \return created link label Standard_EXPORT TDF_Label AddLink(const TDF_Label& theMechanism, - const TDF_Label& theShape); + const TDF_Label& theShapeĆ”, + const Standard_Boolean& IsBase = Standard_False); //! Checks is the given label a link //! \return the result of check @@ -113,6 +96,11 @@ public: Standard_EXPORT Standard_Boolean SetLink(const TDF_Label& theLink, const TDF_LabelSequence& theShapes); + //! Sets shapes references for link + //! param[in] theLink link to set base + //! \return true in case of success, false otherwise + Standard_EXPORT Standard_Boolean SetBaseLink(const TDF_Label& theLink); + //! Sets shape reference for link //! \param[in] theLink link to set shape //! \param[in] theShape singular detail of link @@ -179,6 +167,11 @@ public: //! \return a joint Standard_EXPORT TDF_Label GetJointOfValue(const TDF_Label& theValue) const; + //! Gets references to links of the given joint. + //! \param[in] theJoint joint to get + //! \return set of values + Standard_EXPORT TDF_LabelSequence GetValuesOfJoint(const TDF_Label& theJoint) const; + //! Removes the given state //! \param[in] theState state to remove Standard_EXPORT void RemoveState(const TDF_Label& theState); diff --git a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx index 2b080e5e87..2d1483c357 100644 --- a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx +++ b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.cxx @@ -16,6 +16,8 @@ #include #include #include +#include +#include IMPLEMENT_STANDARD_RTTIEXT(XCAFKinematics_HighOrderPairObject, XCAFKinematics_PairObject) @@ -27,6 +29,7 @@ XCAFKinematics_HighOrderPairObject:: XCAFKinematics_HighOrderPairObject() { myLimits = NULL; + isRanged = Standard_False; } //======================================================================= @@ -43,6 +46,7 @@ XCAFKinematics_HighOrderPairObject(const Handle(XCAFKinematics_HighOrderPairObje myOrientation = theObj->myOrientation; myLimits = theObj->myLimits; myGeom = theObj->myGeom; + isRanged = theObj->HasLimits(); } //======================================================================= @@ -59,12 +63,12 @@ void XCAFKinematics_HighOrderPairObject::SetType(const XCAFKinematics_PairType t break; } case XCAFKinematics_PairType_SlidingSurface: { - myLimits = new TColStd_HArray1OfReal(1, 2); + myLimits = NULL; myGeom = NCollection_Array1(1, 2); break; } case XCAFKinematics_PairType_RollingSurface: { - myLimits = new TColStd_HArray1OfReal(1, 2); + myLimits = NULL; myGeom = NCollection_Array1(1, 2); break; } @@ -84,6 +88,7 @@ void XCAFKinematics_HighOrderPairObject::SetType(const XCAFKinematics_PairType t break; } } + } //======================================================================= @@ -98,14 +103,6 @@ void XCAFKinematics_HighOrderPairObject::SetAllLimits(const Handle(TColStd_HArra aNbLimits = 6; break; } - case XCAFKinematics_PairType_SlidingSurface: { - aNbLimits = 2; - break; - } - case XCAFKinematics_PairType_RollingSurface: { - aNbLimits = 2; - break; - } case XCAFKinematics_PairType_PointOnPlanarCurve: { aNbLimits = 6; break; @@ -113,7 +110,10 @@ void XCAFKinematics_HighOrderPairObject::SetAllLimits(const Handle(TColStd_HArra } if (theLimits->Length() == aNbLimits) + { myLimits = theLimits; + isRanged = Standard_True; + } } //======================================================================= @@ -122,10 +122,7 @@ void XCAFKinematics_HighOrderPairObject::SetAllLimits(const Handle(TColStd_HArra //======================================================================= Standard_Boolean XCAFKinematics_HighOrderPairObject::HasLimits() const { - Standard_Boolean IsConstraint = Standard_False; - for (Standard_Integer anInd = 1; anInd < myLimits->Length() && !IsConstraint; ++anInd) - IsConstraint = myLimits->Value(anInd) != NULL; - return IsConstraint; + return isRanged; } //======================================================================= @@ -135,7 +132,10 @@ Standard_Boolean XCAFKinematics_HighOrderPairObject::HasLimits() const void XCAFKinematics_HighOrderPairObject::SetRotationLowLimit(const Standard_Real theLimit) { if (Type() == XCAFKinematics_PairType_SlidingSurface || Type() == XCAFKinematics_PairType_RollingSurface) + { myLimits->ChangeValue(1) = theLimit; + isRanged = Standard_True; + } } //======================================================================= @@ -156,7 +156,10 @@ Standard_Real XCAFKinematics_HighOrderPairObject::RotationLowLimit() void XCAFKinematics_HighOrderPairObject::SetRotationUpperLimit(const Standard_Real theLimit) { if (Type() == XCAFKinematics_PairType_SlidingSurface || Type() == XCAFKinematics_PairType_RollingSurface) + { myLimits->ChangeValue(2) = theLimit; + isRanged = Standard_True; + } } //======================================================================= @@ -177,7 +180,10 @@ Standard_Real XCAFKinematics_HighOrderPairObject::RotationUpperLimit() void XCAFKinematics_HighOrderPairObject::SetLowLimitYaw(const Standard_Real theLimit) { if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface) + { myLimits->ChangeValue(1) = theLimit; + isRanged = Standard_True; + } } //======================================================================= @@ -198,7 +204,10 @@ Standard_Real XCAFKinematics_HighOrderPairObject::LowLimitYaw() void XCAFKinematics_HighOrderPairObject::SetUpperLimitYaw(const Standard_Real theLimit) { if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface) + { myLimits->ChangeValue(2) = theLimit; + isRanged = Standard_True; + } } //======================================================================= @@ -219,7 +228,10 @@ Standard_Real XCAFKinematics_HighOrderPairObject::UpperLimitYaw() void XCAFKinematics_HighOrderPairObject::SetLowLimitRoll(const Standard_Real theLimit) { if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface) + { myLimits->ChangeValue(3) = theLimit; + isRanged = Standard_True; + } } //======================================================================= @@ -240,7 +252,10 @@ Standard_Real XCAFKinematics_HighOrderPairObject::LowLimitRoll() void XCAFKinematics_HighOrderPairObject::SetUpperLimitRoll(const Standard_Real theLimit) { if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface) + { myLimits->ChangeValue(4) = theLimit; + isRanged = Standard_True; + } } //======================================================================= @@ -261,7 +276,10 @@ Standard_Real XCAFKinematics_HighOrderPairObject::UpperLimitRoll() void XCAFKinematics_HighOrderPairObject::SetLowLimitPitch(const Standard_Real theLimit) { if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface) + { myLimits->ChangeValue(5) = theLimit; + isRanged = Standard_True; + } } //======================================================================= @@ -282,7 +300,10 @@ Standard_Real XCAFKinematics_HighOrderPairObject::LowLimitPitch() void XCAFKinematics_HighOrderPairObject::SetUpperLimitPitch(const Standard_Real theLimit) { if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface) + { myLimits->ChangeValue(6) = theLimit; + isRanged = Standard_True; + } } //======================================================================= @@ -312,8 +333,16 @@ void XCAFKinematics_HighOrderPairObject::SetCurve(const Handle(Geom_Curve)& theC //======================================================================= Handle(Geom_Curve) XCAFKinematics_HighOrderPairObject::Curve() const { - if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve) - return Handle(Geom_Curve)::DownCast(myGeom.First()); + 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()); + } return NULL; } @@ -359,6 +388,28 @@ 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 : @@ -376,7 +427,13 @@ void XCAFKinematics_HighOrderPairObject::SetSurface(const Handle(Geom_Surface)& Handle(Geom_Surface) XCAFKinematics_HighOrderPairObject::Surface() const { if (Type() == XCAFKinematics_PairType_PointOnSurface) - return Handle(Geom_Surface)::DownCast(myGeom.First()); + 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 NULL; } @@ -421,3 +478,25 @@ 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 3bbcc9fbac..a782f906de 100644 --- a/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx +++ b/src/XCAFKinematics/XCAFKinematics_HighOrderPairObject.hxx @@ -23,6 +23,8 @@ class Geom_Curve; class Geom_Surface; +class Geom_RectangularTrimmedSurface; +class Geom_TrimmedCurve; DEFINE_STANDARD_HANDLE(XCAFKinematics_HighOrderPairObject, XCAFKinematics_PairObject) @@ -62,7 +64,10 @@ public: Handle(TColStd_HArray1OfReal) GetAllLimits() const Standard_OVERRIDE { - return myLimits; + Handle(TColStd_HArray1OfReal) aLimitArray; + if (HasLimits()) + aLimitArray = myLimits; + return aLimitArray; } //! Sets low limit of rotation attribute (only for SlidingSurface and RollingSurface) @@ -153,6 +158,21 @@ public: //! \return curve Standard_EXPORT Handle(Geom_Curve) SecondCurve() const; + ////! Sets curve attribute (only for PointOnCurve) + ////! \param[in] theTrimmedCurve trimmed curve + //Standard_EXPORT void SetTrimmedCurve(const Standard_Real& theTrim1, const Standard_Real& theTrim2); + + //! Sets trimmed curve attribute (only for PointOnCurve) + //! \param[in] aTrimCurve trimmed curve + Standard_EXPORT void SetTrimmedCurve(const Handle(Geom_TrimmedCurve)& aTrimCurve); + + //! Gets trimmed curve attribute (only for PointOnCurve) + //! \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); @@ -177,6 +197,18 @@ public: //! \return surface Standard_EXPORT Handle(Geom_Surface) SecondSurface() const; + ////! Sets surface attribute (only for PointOnSurface) + ////! \param[in] theTrimmedSurface trimmed surface + //Standard_EXPORT void SetTrimmedSurface(const Standard_Real& U1, const Standard_Real& U2, const Standard_Real& V1, const Standard_Real& V2); + + //! Sets trimmed surface attribute (only for PointOnSurface) + //! \param[in] aTrimSurface trimmered surface + Standard_EXPORT void SetTrimmedSurface(const Handle(Geom_RectangularTrimmedSurface)& aTrimSurface); + + //! 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: @@ -184,6 +216,7 @@ private: Standard_Boolean myOrientation; //!< orientation Handle(TColStd_HArray1OfReal) myLimits; //!< array of limits, size depends on type NCollection_Array1 myGeom; //!< curve(s) or surface(s) attributes + Standard_Boolean isRanged; //!< flag "is limits defined" }; diff --git a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.cxx b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.cxx index c079c0da45..475e9ee926 100644 --- a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.cxx +++ b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.cxx @@ -36,6 +36,7 @@ XCAFKinematics_LowOrderPairObject::XCAFKinematics_LowOrderPairObject() myMaxTranslationY = Precision::Infinite(); myMinTranslationZ = -Precision::Infinite(); myMaxTranslationZ = Precision::Infinite(); + isRanged = Standard_False; } //======================================================================= @@ -61,6 +62,7 @@ XCAFKinematics_LowOrderPairObject:: myMaxTranslationY = theObj->myMaxTranslationY; myMinTranslationZ = theObj->myMinTranslationZ; myMaxTranslationZ = theObj->myMaxTranslationZ; + isRanged = theObj->HasLimits(); } //======================================================================= @@ -68,8 +70,11 @@ XCAFKinematics_LowOrderPairObject:: //purpose : //======================================================================= Handle(TColStd_HArray1OfReal) XCAFKinematics_LowOrderPairObject::GetAllLimits() const -{ - Handle(TColStd_HArray1OfReal) aLimitArray = new TColStd_HArray1OfReal(1, 12); +{ + Handle(TColStd_HArray1OfReal) aLimitArray; + if (!HasLimits()) + return aLimitArray; + aLimitArray = new TColStd_HArray1OfReal(1, 12); aLimitArray->ChangeValue(1) = myMinRotationX; aLimitArray->ChangeValue(2) = myMaxRotationX; aLimitArray->ChangeValue(3) = myMinRotationY; @@ -91,20 +96,7 @@ Handle(TColStd_HArray1OfReal) XCAFKinematics_LowOrderPairObject::GetAllLimits() //======================================================================= Standard_Boolean XCAFKinematics_LowOrderPairObject::HasLimits() const { - return - ( myMinRotationX != -Precision::Infinite() || - myMaxRotationX != Precision::Infinite() || - myMinRotationY != -Precision::Infinite() || - myMaxRotationY != Precision::Infinite() || - myMinRotationZ != -Precision::Infinite() || - myMaxRotationZ != Precision::Infinite() || - myMinTranslationX != -Precision::Infinite() || - myMaxTranslationX != Precision::Infinite() || - myMinTranslationY != -Precision::Infinite() || - myMaxTranslationY != Precision::Infinite() || - myMinTranslationZ != -Precision::Infinite() || - myMaxTranslationZ != Precision::Infinite() - ); + return isRanged; } //======================================================================= @@ -127,4 +119,5 @@ void XCAFKinematics_LowOrderPairObject::SetAllLimits(const Handle(TColStd_HArray myMaxTranslationY = theLimits->Value(10); myMinTranslationZ = theLimits->Value(11); myMaxTranslationZ = theLimits->Value(12); + isRanged = Standard_True; } diff --git a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx index abc9828711..53c961f626 100644 --- a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx +++ b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObject.hxx @@ -52,6 +52,7 @@ public: void SetMinRotationX(const Standard_Real theLimit) { myMinRotationX = theLimit; + isRanged = Standard_True; } Standard_Real MinRotationX() const @@ -62,6 +63,7 @@ public: void SetMaxRotationX(const Standard_Real theLimit) { myMaxRotationX = theLimit; + isRanged = Standard_True; } Standard_Real MaxRotationX() const @@ -74,6 +76,7 @@ public: void SetMinRotationY(const Standard_Real theLimit) { myMinRotationY = theLimit; + isRanged = Standard_True; } Standard_Real MinRotationY() const @@ -84,6 +87,7 @@ public: void SetMaxRotationY(const Standard_Real theLimit) { myMaxRotationY = theLimit; + isRanged = Standard_True; } Standard_Real MaxRotationY() const @@ -96,6 +100,7 @@ public: void SetMinRotationZ(const Standard_Real theLimit) { myMinRotationZ = theLimit; + isRanged = Standard_True; } Standard_Real MinRotationZ() const @@ -106,6 +111,7 @@ public: void SetMaxRotationZ(const Standard_Real theLimit) { myMaxRotationZ = theLimit; + isRanged = Standard_True; } Standard_Real MaxRotationZ() const @@ -118,6 +124,7 @@ public: void SetMinTranslationX(const Standard_Real theLimit) { myMinTranslationX = theLimit; + isRanged = Standard_True; } Standard_Real MinTranslationX() const @@ -128,6 +135,7 @@ public: void SetMaxTranslationX(const Standard_Real theLimit) { myMaxTranslationX = theLimit; + isRanged = Standard_True; } Standard_Real MaxTranslationX() const @@ -140,6 +148,7 @@ public: void SetMinTranslationY(const Standard_Real theLimit) { myMinTranslationY = theLimit; + isRanged = Standard_True; } Standard_Real MinTranslationY() const @@ -150,6 +159,7 @@ public: void SetMaxTranslationY(const Standard_Real theLimit) { myMaxTranslationY = theLimit; + isRanged = Standard_True; } Standard_Real MaxTranslationY() const @@ -162,6 +172,7 @@ public: void SetMinTranslationZ(const Standard_Real theLimit) { myMinTranslationZ = theLimit; + isRanged = Standard_True; } Standard_Real MinTranslationZ() const @@ -172,6 +183,7 @@ public: void SetMaxTranslationZ(const Standard_Real theLimit) { myMaxTranslationZ = theLimit; + isRanged = Standard_True; } Standard_Real MaxTranslationZ() const @@ -217,6 +229,7 @@ private: Standard_Real myMinTranslationZ; //!< minimum value of translation in z-direction Standard_Real myMaxTranslationZ; //!< maximum value of translation in z-direction Standard_Real mySkewAngle; //!< param for universal/homokinetic pair + Standard_Boolean isRanged; //!< flag "is limits defined" }; diff --git a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.cxx b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.cxx index 58a58281a9..149ccf09c6 100644 --- a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.cxx +++ b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.cxx @@ -24,6 +24,7 @@ IMPLEMENT_STANDARD_RTTIEXT(XCAFKinematics_LowOrderPairObjectWithCoupling, XCAFKi XCAFKinematics_LowOrderPairObjectWithCoupling:: XCAFKinematics_LowOrderPairObjectWithCoupling() { + isRanged = Standard_False; myLowLimit = -Precision::Infinite(); myUpperLimit = Precision::Infinite(); myParams = NULL; @@ -40,6 +41,7 @@ XCAFKinematics_LowOrderPairObjectWithCoupling:: SetType(theObj->Type()); SetFirstTransformation(theObj->FirstTransformation()); SetSecondTransformation(theObj->SecondTransformation()); + isRanged = theObj->HasLimits(); myLowLimit = theObj->LowLimit(); myUpperLimit = theObj->UpperLimit(); myParams = theObj->GetAllParams(); @@ -64,7 +66,10 @@ void XCAFKinematics_LowOrderPairObjectWithCoupling::SetType(const XCAFKinematics //======================================================================= Handle(TColStd_HArray1OfReal) XCAFKinematics_LowOrderPairObjectWithCoupling::GetAllLimits() const { - Handle(TColStd_HArray1OfReal) aLimitArray = new TColStd_HArray1OfReal(1, 2); + Handle(TColStd_HArray1OfReal) aLimitArray; + if (!HasLimits()) + return aLimitArray; + aLimitArray = new TColStd_HArray1OfReal(1, 2); aLimitArray->ChangeValue(1) = myLowLimit; aLimitArray->ChangeValue(2) = myUpperLimit; return aLimitArray; @@ -233,10 +238,7 @@ void XCAFKinematics_LowOrderPairObjectWithCoupling::SetAllParams(const Handle(TC //======================================================================= Standard_Boolean XCAFKinematics_LowOrderPairObjectWithCoupling::HasLimits() const { - return - ( myLowLimit != -Precision::Infinite() || - myUpperLimit != Precision::Infinite() - ); + return isRanged; } //======================================================================= @@ -247,6 +249,7 @@ void XCAFKinematics_LowOrderPairObjectWithCoupling::SetAllLimits(const Handle(TC { if (theLimits->Length() == 2) { + isRanged = Standard_True; myLowLimit = theLimits->Value(1); myUpperLimit = theLimits->Value(2); } diff --git a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx index 3234cb65af..5877263215 100644 --- a/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx +++ b/src/XCAFKinematics/XCAFKinematics_LowOrderPairObjectWithCoupling.hxx @@ -41,6 +41,7 @@ public: void SetLowLimit(const Standard_Real theLimit) { + isRanged = Standard_True; myLowLimit = theLimit; } @@ -51,6 +52,7 @@ public: void SetUpperLimit(const Standard_Real theLimit) { + isRanged = Standard_True; myUpperLimit = theLimit; } @@ -139,6 +141,7 @@ private: Standard_Real myLowLimit; //!< low limit of motion range Standard_Real myUpperLimit; //!< upper limit of motion range Handle(TColStd_HArray1OfReal) myParams; //!< additional parameters of kinematic pair + Standard_Boolean isRanged; //!< flag "is limits defined" }; diff --git a/src/XDEDRAW/XDEDRAW_Kinematics.cxx b/src/XDEDRAW/XDEDRAW_Kinematics.cxx index 4f9bb66fb7..fb690a7f3c 100644 --- a/src/XDEDRAW/XDEDRAW_Kinematics.cxx +++ b/src/XDEDRAW/XDEDRAW_Kinematics.cxx @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include #include @@ -162,7 +164,7 @@ static Standard_Integer removeMechanism(Draw_Interpretor& di, Standard_Integer a static Standard_Integer addLink(Draw_Interpretor& di, Standard_Integer argc, const char** argv) { if (argc < 3) { - di << "Use: XAddLink Doc ParentMechanism [-Base] [shapeLabel1 .. shapeLabelN]\n"; + di << "Use: XAddLink Doc ParentMechanism [-base] [shapeLabel1 .. shapeLabelN]\n"; return 1; } @@ -173,7 +175,7 @@ static Standard_Integer addLink(Draw_Interpretor& di, Standard_Integer argc, con TDF_Label aMechanism; if (!getLabel(di, aDoc, argv[2], aMechanism)) return 1; - Standard_Boolean IsBase = argc >= 4 && TCollection_AsciiString(argv[3]).IsEqual("-Base"); + Standard_Boolean IsBase = argc >= 4 && TCollection_AsciiString(argv[3]).IsEqual("-base"); TDF_LabelSequence aShapeArray; for (Standard_Integer i = (IsBase) ? 4 : 3; i < argc; i++) { TDF_Label aLabel; @@ -183,10 +185,7 @@ static Standard_Integer addLink(Draw_Interpretor& di, Standard_Integer argc, con } Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); - if(IsBase) - di << getEntry(aTool->AddBaseLink(aMechanism, aShapeArray)); - else - di << getEntry(aTool->AddLink(aMechanism, aShapeArray)); + di << getEntry(aTool->AddLink(aMechanism, aShapeArray, IsBase)); return 0; } @@ -196,8 +195,8 @@ static Standard_Integer addLink(Draw_Interpretor& di, Standard_Integer argc, con //======================================================================= static Standard_Integer setLink(Draw_Interpretor& di, Standard_Integer argc, const char** argv) { - if (argc < 3) { - di << "Use: XAddLink Doc Link shapeLabel1 .. shapeLabelN\n"; + if (argc < 4) { + di << "Use: XSetLink Doc Link shapeLabel1 .. shapeLabelN\n"; return 1; } @@ -224,6 +223,32 @@ static Standard_Integer setLink(Draw_Interpretor& di, Standard_Integer argc, con return 0; } +//======================================================================= +//function : setBaseLink +//purpose : +//======================================================================= +static Standard_Integer setBaseLink(Draw_Interpretor& di, Standard_Integer argc, const char** argv) +{ + if (argc < 3) { + di << "Use: XSetBaseLink Doc Link\n"; + return 1; + } + + Handle(TDocStd_Document) aDoc; + if (!getDocument(di, argv[1], aDoc)) + return 1; + + TDF_Label aLink; + if (!getLabel(di, aDoc, argv[2], aLink)) + return 1; + + Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main()); + if (!aTool->SetBaseLink(aLink)) + return 1; + + return 0; +} + //======================================================================= //function : isLink //purpose : @@ -804,7 +829,8 @@ static Standard_Integer setLimits(Draw_Interpretor& di, Standard_Integer argc, c if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) { Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject(); anObject->SetAllLimits(aLimitArray); - aPair->SetObject(anObject); + if (anObject->HasLimits()) + aPair->SetObject(anObject); } return 0; @@ -1159,7 +1185,10 @@ static Standard_Integer getGeomParam(Draw_Interpretor& di, Standard_Integer argc // Surface Handle(Geom_Surface) aSurface; if (anObject->Type() == XCAFKinematics_PairType_PointOnSurface) - aSurface = anObject->Surface(); + if (!anObject->HasLimits()) + aSurface = anObject->Surface(); + else + aSurface = anObject->TrimmedSurface(); else { switch (aTrsfNb) { case 1: aSurface = anObject->FirstSurface(); @@ -1177,7 +1206,10 @@ static Standard_Integer getGeomParam(Draw_Interpretor& di, Standard_Integer argc // Curve Handle(Geom_Curve) aCurve; if (anObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve) + if (!anObject->HasLimits()) aCurve = anObject->Curve(); + else + aCurve = anObject->TrimmedCurve(); else { switch (aTrsfNb) { case 1: aCurve = anObject->FirstCurve(); @@ -1532,12 +1564,15 @@ void XDEDRAW_Kinematics::InitCommands(Draw_Interpretor& di) di.Add("XRemoveMechanism", "XRemoveMechanism Doc Label", __FILE__, removeMechanism, g); - di.Add("XAddLink", "XAddLink Doc ParentMechanism [-Base] [shapeLabel1 .. shapeLabelN]", + di.Add("XAddLink", "XAddLink Doc ParentMechanism [-base] [shapeLabel1 .. shapeLabelN]", __FILE__, addLink, g); di.Add("XSetLink", "XSetLink Doc Link shapeLabel1 .. shapeLabelN", __FILE__, setLink, g); + di.Add("XSetBaseLink", "XSetBaseLink Doc Link", + __FILE__, setBaseLink, g); + di.Add("XIsLink", "XIsLink Doc Label", __FILE__, isLink, g); diff --git a/tests/gdt/kinematics/A1 b/tests/gdt/kinematics/A1 index f65a581d78..fb3257f8eb 100644 --- a/tests/gdt/kinematics/A1 +++ b/tests/gdt/kinematics/A1 @@ -52,8 +52,8 @@ set result [XGetPairName D $joint1] if {$result != "Low order"} { puts "Error: wrong kinematic pair data." } -plane p1 0 0 0 1 0 0 -plane p2 0 0 0 0 1 0 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint1 1 p1 set dump_in [dump p1] XGetPairTransformation D $joint1 1 p1 @@ -110,9 +110,8 @@ if {[lindex $params 20] != "5"} { } set joint3 [XAddJoint D $mech $link3 $link2] -XSetPairType D $joint3 15 +XSetPairType D $joint3 16 XSetPairName D $joint3 High order surface -XSetPairLimits D $joint3 30 60 sphere sph 4 4 4 1 set dump_in [dump sph] XSetPairGeomParam D $joint3 1 sph @@ -121,6 +120,7 @@ set dump_out [dump sph] if {$dump_in != $dump_out} { puts "Error: wrong kinematic pair data." } +XSetPairLimits D $joint3 30 60 cylinder cyl 0 0 0 0 1 0 2 trim cyl cyl 0 2 0 2 set dump_in [dump cyl] @@ -133,7 +133,7 @@ if {$dump_in != $dump_out} { } set joint4 [XAddJoint D $mech $link3 0:1:11:1:1:1] -XSetPairType D $joint4 17 +XSetPairType D $joint4 18 XSetPairName D $joint4 High order curve circle cir 0 0 0 3 set dump_in [dump cir] diff --git a/tests/gdt/kinematics/A2 b/tests/gdt/kinematics/A2 index f5434a7f08..11a13ee44b 100644 --- a/tests/gdt/kinematics/A2 +++ b/tests/gdt/kinematics/A2 @@ -8,7 +8,7 @@ XAddShape D b XAddShape D bb set mech [XAddMechanism D] set link1 [XAddLink D $mech 0:1:1:1] -set link2 [XAddLink D $mech 0:1:1:2] +set link2 [XAddLink D $mech -base 0:1:1:2] set joint [XAddJoint D $mech $link1 $link2] # Start testing @@ -23,8 +23,8 @@ if {$type != "2"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 0 1 -plane p2 0 0 0 0 0 1 1 1 0 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -40,9 +40,9 @@ if {$dump_in != $dump_out} { puts "Error: wrong parameter" } -XSetPairLimits D $joint 0 45 0 0 0 0 0 0 0 0 0 0 +XSetPairLimits D $joint 0 0 0 0 0 45 0 0 0 0 0 0 set limits [XGetPairLimits D $joint] -if {$limits != "0 45 0 0 0 0 0 0 0 0 0 0 "} { +if {$limits != "0 0 0 0 0 45 0 0 0 0 0 0 "} { puts "Error: wrong parameter" } @@ -54,22 +54,5 @@ set values [XGetPairValues D $value -rotation] if {$values != "15"} { puts "Error: wrong parameter" } -set link4 [XAddLink D $mech -Base 0:1:1:2] -set link3 [XAddLink D $mech 0:1:1:1] -set joint2 [XAddJoint D $mech $link3 $link4] - -XSetPairTransformation D $joint2 1 p1 -XSetPairTransformation D $joint2 2 p2 -set dump_in [dump p1] -XGetPairTransformation D $joint 1 p1 -set dump_out [dump p1] -if {$dump_in != $dump_out} { - puts "Error: wrong parameter" -} -set dump_in [dump p2] -XGetPairTransformation D $joint 2 p2 -set dump_out [dump p2] -if {$dump_in != $dump_out} { - puts "Error: wrong parameter" -} +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/A3 b/tests/gdt/kinematics/A3 index 767d746e8f..6933c49132 100644 --- a/tests/gdt/kinematics/A3 +++ b/tests/gdt/kinematics/A3 @@ -23,8 +23,8 @@ if {$type != "3"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 0 1 -plane p2 0 1 0 0 0 1 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -40,9 +40,9 @@ if {$dump_in != $dump_out} { puts "Error: wrong parameter" } -XSetPairLimits D $joint 0 0 0 0 0 0 0 0 0 10 0 0 +XSetPairLimits D $joint 0 0 0 0 0 0 0 10 0 0 0 0 set limits [XGetPairLimits D $joint] -if {$limits != "0 0 0 0 0 0 0 0 0 10 0 0 "} { +if {$limits != "0 0 0 0 0 0 0 10 0 0 0 0 "} { puts "Error: wrong parameter" } @@ -55,4 +55,4 @@ if {$values != "3"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/A4 b/tests/gdt/kinematics/A4 index d1e22eccfa..400c53d25a 100644 --- a/tests/gdt/kinematics/A4 +++ b/tests/gdt/kinematics/A4 @@ -23,8 +23,8 @@ if {$type != "4"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 0 1 -plane p2 0 1 0 0 0 1 1 1 0 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -40,9 +40,9 @@ if {$dump_in != $dump_out} { puts "Error: wrong parameter" } -XSetPairLimits D $joint 0 45 0 0 0 0 0 0 0 10 0 0 +XSetPairLimits D $joint 0 0 0 0 0 45 0 0 0 0 0 45 set limits [XGetPairLimits D $joint] -if {$limits != "0 45 0 0 0 0 0 0 0 10 0 0 "} { +if {$limits != "0 0 0 0 0 45 0 0 0 0 0 45 "} { puts "Error: wrong parameter" } @@ -60,5 +60,5 @@ set values [XGetPairValues D $value -rotation] if {$values != "15"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/A5 b/tests/gdt/kinematics/A5 index 27421bdbf1..9bef9571cf 100644 --- a/tests/gdt/kinematics/A5 +++ b/tests/gdt/kinematics/A5 @@ -23,8 +23,8 @@ if {$type != "5"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 0 1 -plane p2 0 0 0 0 1 1 1 1 0 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -40,9 +40,9 @@ if {$dump_in != $dump_out} { puts "Error: wrong parameter" } -XSetPairLimits D $joint 0 45 10 20 0 0 0 0 0 0 0 0 +XSetPairLimits D $joint 0 25 0 0 0 45 0 0 0 0 0 0 set limits [XGetPairLimits D $joint] -if {$limits != "0 45 10 20 0 0 0 0 0 0 0 0 "} { +if {$limits != "0 25 0 0 0 45 0 0 0 0 0 0 "} { puts "Error: wrong parameter" } @@ -65,4 +65,4 @@ if {$values != "15"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/A6 b/tests/gdt/kinematics/A6 index 8021210095..65548c221b 100644 --- a/tests/gdt/kinematics/A6 +++ b/tests/gdt/kinematics/A6 @@ -23,8 +23,8 @@ if {$type != "6"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 0 1 -plane p2 0 0 0 0 1 1 1 1 0 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -40,12 +40,6 @@ if {$dump_in != $dump_out} { puts "Error: wrong parameter" } -XSetPairLimits D $joint 0 45 0 45 0 0 0 0 0 0 0 0 -set limits [XGetPairLimits D $joint] -if {$limits != "0 45 0 45 0 0 0 0 0 0 0 0 "} { - puts "Error: wrong parameter" -} - XSetPairParams D $joint 30 set param [XGetPairParams D $joint] if {$param != "Skew Angle = 30"} { @@ -65,4 +59,4 @@ if {$values != "20"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/A7 b/tests/gdt/kinematics/A7 index f8ff00d14a..d08eb54f29 100644 --- a/tests/gdt/kinematics/A7 +++ b/tests/gdt/kinematics/A7 @@ -23,8 +23,8 @@ if {$type != "7"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 0 1 -plane p2 0 0 0 0 1 1 1 1 0 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -55,4 +55,4 @@ if {$values != "10 0 30"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/A8 b/tests/gdt/kinematics/A8 index ec3e7dbac7..bb4ffdc7bd 100644 --- a/tests/gdt/kinematics/A8 +++ b/tests/gdt/kinematics/A8 @@ -12,9 +12,9 @@ set link2 [XAddLink D $mech 0:1:1:2] set joint [XAddJoint D $mech $link1 $link2] # Start testing -XSetPairName D $joint spherical with pin +XSetPairName D $joint spherical set name [XGetPairName D $joint] -if {$name != "spherical with pin"} { +if {$name != "spherical"} { puts "Error: wrong parameter" } XSetPairType D $joint 8 @@ -23,8 +23,8 @@ if {$type != "8"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 0 1 -plane p2 0 0 0 0 1 1 1 1 0 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -55,4 +55,4 @@ if {$values != "10 20 30"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/A9 b/tests/gdt/kinematics/A9 index 171fe6477b..1c893f8707 100644 --- a/tests/gdt/kinematics/A9 +++ b/tests/gdt/kinematics/A9 @@ -64,4 +64,4 @@ if {$values != "2.1"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/B1 b/tests/gdt/kinematics/B1 index 6a8b2d9860..eac4dec9c0 100644 --- a/tests/gdt/kinematics/B1 +++ b/tests/gdt/kinematics/B1 @@ -56,4 +56,4 @@ if {$values!= "10 10 10\n1 0 0\n0 -1 0"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/B2 b/tests/gdt/kinematics/B2 index 649859020d..44c6fc2e2f 100644 --- a/tests/gdt/kinematics/B2 +++ b/tests/gdt/kinematics/B2 @@ -23,8 +23,8 @@ if {$type != "11"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 0 1 -plane p2 0 0 0 0 0 1 1 1 0 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] diff --git a/tests/gdt/kinematics/B3 b/tests/gdt/kinematics/B3 index 09925c8148..284f305589 100644 --- a/tests/gdt/kinematics/B3 +++ b/tests/gdt/kinematics/B3 @@ -23,8 +23,8 @@ if {$type != "12"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 0 1 -plane p2 0 0 0 0 0 1 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] diff --git a/tests/gdt/kinematics/B4 b/tests/gdt/kinematics/B4 index 047835c044..c5853c1f46 100644 --- a/tests/gdt/kinematics/B4 +++ b/tests/gdt/kinematics/B4 @@ -23,8 +23,8 @@ if {$type != "13"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 0 1 -plane p2 0 0 0 0 0 1 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -61,4 +61,4 @@ if {$values != "24"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/B5 b/tests/gdt/kinematics/B5 index 5d708a5649..f88a42aa21 100644 --- a/tests/gdt/kinematics/B5 +++ b/tests/gdt/kinematics/B5 @@ -23,8 +23,8 @@ if {$type != "15"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 1 0 1 1 0 -plane p2 0 0 0 0 0 1 0 1 -1 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -46,11 +46,13 @@ if {$limits != "10 20 30 40 50 60 "} { puts "Error: wrong parameter" } -sphere sph 4 4 4 1 -XSetPairGeomParam D $joint 1 sph -set dump_in [dump sph] -XGetPairGeomParam D $joint 1 sph -set dump_out [dump sph] +cylinder cy 10 +trimv cy cy 0 50 +trimu cy cy 0 50 +XSetPairGeomParam D $joint 1 cy +set dump_in [dump cy] +XGetPairGeomParam D $joint 1 cy +set dump_out [dump cy] if {$dump_in != $dump_out} { puts "Error: wrong parameter" } @@ -74,4 +76,4 @@ if {$values != "12 13 14"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/B6 b/tests/gdt/kinematics/B6 index 4d8c16c17d..44c213c84e 100644 --- a/tests/gdt/kinematics/B6 +++ b/tests/gdt/kinematics/B6 @@ -23,8 +23,8 @@ if {$type != "16"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 1 0 1 1 0 -plane p2 0 0 0 0 0 1 0 1 -1 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -40,12 +40,6 @@ if {$dump_in != $dump_out} { puts "Error: wrong parameter" } -XSetPairLimits D $joint 10 20 -set limits [XGetPairLimits D $joint] -if {$limits != "10 20 "} { - puts "Error: wrong parameter" -} - sphere sph1 4 4 4 1 plane p2 0 0 0 1 0 0 XSetPairGeomParam D $joint 1 sph1 @@ -86,4 +80,4 @@ if {$values != "30"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/B7 b/tests/gdt/kinematics/B7 index c0c8f364d6..7d019a3ee8 100644 --- a/tests/gdt/kinematics/B7 +++ b/tests/gdt/kinematics/B7 @@ -23,8 +23,8 @@ if {$type != "17"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 1 0 1 1 0 -plane p2 0 0 0 0 0 1 0 1 -1 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -40,12 +40,6 @@ if {$dump_in != $dump_out} { puts "Error: wrong parameter" } -XSetPairLimits D $joint 10 20 -set limits [XGetPairLimits D $joint] -if {$limits != "10 20 "} { - puts "Error: wrong parameter" -} - sphere sph1 4 4 4 1 plane p2 0 0 0 1 0 0 XSetPairGeomParam D $joint 1 sph1 @@ -82,4 +76,4 @@ if {$values != "30"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/B8 b/tests/gdt/kinematics/B8 index 172b1393f4..18704ec670 100644 --- a/tests/gdt/kinematics/B8 +++ b/tests/gdt/kinematics/B8 @@ -23,8 +23,8 @@ if {$type != "18"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 1 0 1 1 0 -plane p2 0 0 0 0 0 1 0 1 -1 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -47,6 +47,7 @@ if {$limits != "10 20 30 40 50 60 "} { } circle cir 4 4 4 1 +trim cir cir 0 pi/2 XSetPairGeomParam D $joint 1 cir set dump_in [dump cir] XGetPairGeomParam D $joint 1 cir diff --git a/tests/gdt/kinematics/B9 b/tests/gdt/kinematics/B9 index cdf6677f5e..cac4981ba8 100644 --- a/tests/gdt/kinematics/B9 +++ b/tests/gdt/kinematics/B9 @@ -23,8 +23,8 @@ if {$type != "19"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 1 0 1 1 0 -plane p2 0 0 0 0 0 1 0 1 -1 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -76,4 +76,4 @@ if {$values != "7"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file diff --git a/tests/gdt/kinematics/C1 b/tests/gdt/kinematics/C1 index d97ab780b8..623375d798 100644 --- a/tests/gdt/kinematics/C1 +++ b/tests/gdt/kinematics/C1 @@ -23,8 +23,8 @@ if {$type != "20"} { puts "Error: wrong parameter" } -plane p1 0 0 0 0 1 0 1 1 0 -plane p2 0 0 0 0 0 1 0 1 -1 +plane p1 10 20 30 -1 0 0 +plane p2 10 0 0 1 0 0 0 1 0 XSetPairTransformation D $joint 1 p1 XSetPairTransformation D $joint 2 p2 set dump_in [dump p1] @@ -72,4 +72,4 @@ if {$values != "1.5"} { puts "Error: wrong parameter" } -Close D +Close D \ No newline at end of file -- 2.39.5