Implement XCAF structures to store kinematic data.
Add DRAW commands to process kinematic data.
Add test cases.
Update documentation.
* Removes note(s) from an annotated assembly item; orphan note(s) might be deleted optionally (items without linked notes will be deleted automatically);
* Deletes note(s) and removes them from annotated items;
* Gets / deletes orphan notes.
+
+@subsection occt_xde_1_11 Kinematics
+
+Kinematic data storage is realized according to ISO 10303-105:2019(E) and STEP Schema AP242 2019 year.
+All kinematic data is divided onto mechanisms each mechanism has its graph of links (references to shapes) and joints (kinematic pair information).
+Each joint corresponds to one kinematic pair from the list:
+* Low order pairs
+ - fully constrained pair (no DOF);
+ - revolute pair (one rotation DOF);
+ - prismatic pair (one translation DOF);
+ - cylindrical pair (one rotation and one translation DOF);
+ - universal pair (two rotation DOF);
+ - homokinetic pair (two rotation DOF);
+ - spherical pair with pin (two rotation DOF);
+ - spherical pair (three rotation DOF);
+ - planar pair (one rotation and two translation DOF);
+ - unconstrained pair (3 rotation and 3 translation DOF);
+* Low order pairs with motion coupling
+ - screw pair;
+ - rack and pinion pair;
+ - gear pair;
+* High order pairs
+ - point on surface pair;
+ - sliding surface pair;
+ - rolling surface pair;
+ - point on planar curve pair;
+ - sliding curve pair;
+ - rolling curve pair.
+
+The kinematic pair information consists of
+* parameters;
+* limits (optional);
+* current position (optional).
+
+All mentioned data depends on the kinematic pair type.
@section occt_xde_2 Working with XDE
- *DeleteOrphanNotes* : deletes notes not bound to Document items.
All these methods except for the last one break all links with Document items as well.
+
+@subsection occt_xde_2_11 Kinematics
+
+In XDE Document Kinematics is managed via *XCAFDoc_KinematicTool*. The Kinematic pair entities are described by two attributes
+*XCAFDoc_KinematicPair* and *XCAFDoc_KinematicPairValue (optional)*. The second attribute is a dependant attribute,
+it cannot be assigned to label without the main attribute or to a label with the main attribute of another kinematic pair type.
-@subsection occt_xde_2_11 Reading and Writing STEP or IGES
+@subsubsection occt_xde_2_11_1 Creation
+
+All kinematic data refers to the mechanism, so, first of all, it needs to *AddMechanism*,
+this method creates a new mechanism and two empty subfolders for links and joints.
+The next step is specifying of links (mechanism details) via *AddLink* and *SetLink* commands.
+The last step of kinematic graph creation is adding of joints with using *AddJoint* and *SetJoint* commands.
+
+@subsubsection occt_xde_2_11_2 Checking
+
+Commands *IsMechanism*, *IsLink* and *IsJoint* helps to check that created labels are valid.
+To retrieve current graph state use the next methods: *GetMechanisms*, *GetLinks*, *GetJoints* *GetLinksOfJoint*, *GetJointOfLink*, *GetRefShapes (for link)*.
+
+@subsubsection occt_xde_2_11_3 Editing
+
+To change links's referred shapes use *SetLink*.
+To change joint's referred links use *SetJoint*.
+
+@subsubsection occt_xde_2_11_4 Deleting
+
+All kinematic data can be removed by *RemoveLink*, *RemoveJoint* and *RemoveMechanism* commands.
+
+@subsubsection occt_xde_2_11_5 Assigning data
+
+Each kinematic pair type has its set of parameters and so should be processed separately. The code below is a common example.
+
+Set data.
+
+~~~~~
+// Create an object according to necessary type (LowOrder/LowOrderWithCoupling/HighOrder)
+XCAFKinematics_PairObject anObject = new XCAFKinematics_PairObject();
+// Fill type, parameters if existed and limits if needed
+anObject->SetType(XCAFKinematics_PairType_Screw);
+...
+// Add attribute
+Handle(XCAFDoc_KinematicPair) aPair = XCAFDoc_KinematicPair::Set(aJointLabel);
+aPair->SetObject(anObject);
+~~~~~
+
+Get data.
+~~~~~
+// Get attribute from the label
+Handle(XCAFDoc_KinematicPair) aPair;
+if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject();
+ TCollection_AsciiString aName = anObject->Name();
+}
+~~~~~
+
+@subsection occt_xde_2_12 Reading and Writing STEP or IGES
Note that saving and restoring the document itself are standard OCAF operations. As the various previously described definitions enter into this frame, they will not be explained any further.
The same can be said for Viewing: presentations can be defined from Shapes and Colors.
The packages to manage this are *IGESCAFControl* for IGES, and *STEPCAFControl* for STEP.
-@subsubsection occt_xde_2_11_1 Reading a STEP file
+@subsubsection occt_xde_2_12_1 Reading a STEP file
To read a STEP file by itself, use:
~~~~~
~~~~~
In addition, the reader provides methods that are applicable to document transfers and for directly querying of the data produced.
-@subsubsection occt_xde_2_11_2 Writing a STEP file
+@subsubsection occt_xde_2_12_2 Writing a STEP file
To write a STEP file by itself, use:
~~~~~
IFSelect_ReturnStatus stat = writer.Write(file-name);
~~~~~
-@subsubsection occt_xde_2_11_3 Reading an IGES File
+@subsubsection occt_xde_2_12_3 Reading an IGES File
Use the same procedure as for a STEP file but with IGESCAFControl instead of STEPCAFControl.
-@subsubsection occt_xde_2_11_4 Writing an IGES File
+@subsubsection occt_xde_2_12_4 Writing an IGES File
Use the same procedure as for a STEP file but with IGESCAFControl instead of STEPCAFControl.
-@subsection occt_xde_2_12 Using an XDE Document
+@subsection occt_xde_2_13 Using an XDE Document
There are several ways of exploiting XDE data from an application, you can:
1. Get the data relevant for the application by mapping XDE/Appli, then discard the XDE data once it has been used.
2. Create a reference from the Application Document to the XDE Document, to have its data available as external data.
3. Embed XDE data inside the Application Document (see the following section for details).
4. Directly exploit XDE data such as when using file checkers.
-@subsubsection occt_xde_2_12_1 XDE Data inside an Application Document
+@subsubsection occt_xde_2_13_1 XDE Data inside an Application Document
To have XCAF data elsewhere than under label 0.1, you use the DocLabel of XDE. The method DocLabel from XCAFDoc_DocumentTool determines the relevant Label for XCAF. However, note that the default is 0.1.
In addition, as XDE data is defined and managed in a modular way, you can consider exclusively Assembly Structure, only Colors, and so on.
#include <BinMXCAFDoc_DimTolToolDriver.hxx>
#include <BinMXCAFDoc_DocumentToolDriver.hxx>
#include <BinMXCAFDoc_GraphNodeDriver.hxx>
+#include <BinMXCAFDoc_KinematicPairDriver.hxx>
+#include <BinMXCAFDoc_KinematicPairValueDriver.hxx>
+#include <BinMXCAFDoc_KinematicToolDriver.hxx>
#include <BinMXCAFDoc_LayerToolDriver.hxx>
#include <BinMXCAFDoc_LocationDriver.hxx>
#include <BinMXCAFDoc_MaterialDriver.hxx>
theDriverTable->AddDriver( new BinMXCAFDoc_NoteBinDataDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NoteCommentDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_ViewDriver (theMsgDrv));
+ theDriverTable->AddDriver( new BinMXCAFDoc_KinematicPairDriver(theMsgDrv));
+ theDriverTable->AddDriver( new BinMXCAFDoc_KinematicPairValueDriver(theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_ColorToolDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_DocumentToolDriver(theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_VisMaterialToolDriver(theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_NotesToolDriver (theMsgDrv));
theDriverTable->AddDriver( new BinMXCAFDoc_ViewToolDriver (theMsgDrv));
+ theDriverTable->AddDriver( new BinMXCAFDoc_KinematicToolDriver(theMsgDrv));
}
class BinMXCAFDoc_MaterialToolDriver;
class BinMXCAFDoc_ViewDriver;
class BinMXCAFDoc_ViewToolDriver;
+class BinMXCAFDoc_KinematicToolDriver;
+class BinMXCAFDoc_KinematicPairDriver;
+class BinMXCAFDoc_KinematicPairValueDriver;
friend class BinMXCAFDoc_MaterialToolDriver;
friend class BinMXCAFDoc_ViewDriver;
friend class BinMXCAFDoc_ViewToolDriver;
+friend class BinMXCAFDoc_KinematicToolDriver;
+friend class BinMXCAFDoc_KinematicPairDriver;
+friend class BinMXCAFDoc_KinematicPairValueDriver;
};
--- /dev/null
+// Created on: 2020-03-18
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <BinMXCAFDoc_KinematicPairDriver.hxx>
+#include <BinObjMgt_Persistent.hxx>
+#include <Message_Messenger.hxx>
+#include <Standard_Type.hxx>
+#include <TDF_Attribute.hxx>
+#include <XCAFDoc_KinematicPair.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_KinematicPairDriver, BinMDF_ADriver)
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+BinMXCAFDoc_KinematicPairDriver::BinMXCAFDoc_KinematicPairDriver (const Handle(Message_Messenger)& theMsgDriver)
+: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_KinematicPair)->Name())
+{
+}
+
+//=======================================================================
+//function : NewEmpty
+//purpose :
+//=======================================================================
+Handle(TDF_Attribute) BinMXCAFDoc_KinematicPairDriver::NewEmpty() const
+{
+ return new XCAFDoc_KinematicPair();
+}
+
+//=======================================================================
+//function : Paste
+//purpose :
+//=======================================================================
+Standard_Boolean BinMXCAFDoc_KinematicPairDriver::Paste (const BinObjMgt_Persistent& /*theSource*/,
+ const Handle(TDF_Attribute)& /*theTarget*/,
+ BinObjMgt_RRelocationTable& /*theRelocTable*/) const
+{
+ return Standard_True;
+}
+
+//=======================================================================
+//function : Paste
+//purpose :
+//=======================================================================
+void BinMXCAFDoc_KinematicPairDriver::Paste (const Handle(TDF_Attribute)& /*theSource*/,
+ BinObjMgt_Persistent& /*theTarget*/,
+ BinObjMgt_SRelocationTable& /*theRelocTable*/) const
+{
+}
--- /dev/null
+// Created on: 2020-03-18
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _BinMXCAFDoc_KinematicPairDriver_HeaderFile
+#define _BinMXCAFDoc_KinematicPairDriver_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <BinMDF_ADriver.hxx>
+#include <Standard_Boolean.hxx>
+#include <BinObjMgt_RRelocationTable.hxx>
+#include <BinObjMgt_SRelocationTable.hxx>
+
+class Message_Messenger;
+class TDF_Attribute;
+class BinObjMgt_Persistent;
+
+class BinMXCAFDoc_KinematicPairDriver;
+DEFINE_STANDARD_HANDLE(BinMXCAFDoc_KinematicPairDriver, BinMDF_ADriver)
+
+class BinMXCAFDoc_KinematicPairDriver : public BinMDF_ADriver
+{
+
+public:
+
+
+ Standard_EXPORT BinMXCAFDoc_KinematicPairDriver (const Handle(Message_Messenger)& theMsgDriver);
+
+ Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
+ const Handle(TDF_Attribute)& theTarget,
+ BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource,
+ BinObjMgt_Persistent& theTarget,
+ BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
+
+ DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_KinematicPairDriver, BinMDF_ADriver)
+
+};
+
+#endif // _BinMXCAFDoc_KinematicPairDriver_HeaderFile
--- /dev/null
+// Created on: 2020-03-30
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <BinMXCAFDoc_KinematicPairValueDriver.hxx>
+#include <BinObjMgt_Persistent.hxx>
+#include <Message_Messenger.hxx>
+#include <Standard_Type.hxx>
+#include <TDF_Attribute.hxx>
+#include <XCAFDoc_KinematicPairValue.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_KinematicPairValueDriver, BinMDF_ADriver)
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
+BinMXCAFDoc_KinematicPairValueDriver::
+BinMXCAFDoc_KinematicPairValueDriver (const Handle(Message_Messenger)& theMsgDriver)
+: BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_KinematicPairValue)->Name())
+{
+}
+
+//=======================================================================
+//function : NewEmpty
+//purpose :
+//=======================================================================
+Handle(TDF_Attribute) BinMXCAFDoc_KinematicPairValueDriver::NewEmpty() const
+{
+ return new XCAFDoc_KinematicPairValue();
+}
+
+//=======================================================================
+//function : Paste
+//purpose :
+//=======================================================================
+Standard_Boolean BinMXCAFDoc_KinematicPairValueDriver::Paste (const BinObjMgt_Persistent& /*theSource*/,
+ const Handle(TDF_Attribute)& /*theTarget*/,
+ BinObjMgt_RRelocationTable& /*theRelocTable*/) const
+{
+ return Standard_True;
+}
+
+//=======================================================================
+//function : Paste
+//purpose :
+//=======================================================================
+void BinMXCAFDoc_KinematicPairValueDriver::Paste (const Handle(TDF_Attribute)& /*theSource*/,
+ BinObjMgt_Persistent& /*theTarget*/,
+ BinObjMgt_SRelocationTable& /*theRelocTable*/) const
+{
+}
--- /dev/null
+// Created on: 2020-03-30
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _BinMXCAFDoc_KinematicPairValueDriver_HeaderFile
+#define _BinMXCAFDoc_KinematicPairValueDriver_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <BinMDF_ADriver.hxx>
+#include <Standard_Boolean.hxx>
+#include <BinObjMgt_RRelocationTable.hxx>
+#include <BinObjMgt_SRelocationTable.hxx>
+
+class Message_Messenger;
+class TDF_Attribute;
+class BinObjMgt_Persistent;
+
+class BinMXCAFDoc_KinematicPairValueDriver;
+DEFINE_STANDARD_HANDLE(BinMXCAFDoc_KinematicPairValueDriver, BinMDF_ADriver)
+
+class BinMXCAFDoc_KinematicPairValueDriver : public BinMDF_ADriver
+{
+
+public:
+
+
+ Standard_EXPORT BinMXCAFDoc_KinematicPairValueDriver (const Handle(Message_Messenger)& theMsgDriver);
+
+ Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual Standard_Boolean Paste (const BinObjMgt_Persistent& theSource,
+ const Handle(TDF_Attribute)& theTarget,
+ BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource,
+ BinObjMgt_Persistent& theTarget,
+ BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
+
+ DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_KinematicPairValueDriver, BinMDF_ADriver)
+
+};
+
+#endif // _BinMXCAFDoc_KinematicPairValueDriver_HeaderFile
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <BinMXCAFDoc_KinematicToolDriver.hxx>
+#include <BinObjMgt_Persistent.hxx>
+#include <Message_Messenger.hxx>
+#include <Standard_Type.hxx>
+#include <TDF_Attribute.hxx>
+#include <XCAFDoc_KinematicTool.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(BinMXCAFDoc_KinematicToolDriver, BinMDF_ADriver)
+
+//=======================================================================
+//function : BinMXCAFDoc_KinematicToolDriver
+//purpose :
+//=======================================================================
+BinMXCAFDoc_KinematicToolDriver::BinMXCAFDoc_KinematicToolDriver
+ (const Handle(Message_Messenger)& theMsgDriver)
+ : BinMDF_ADriver(theMsgDriver, STANDARD_TYPE(XCAFDoc_KinematicTool)->Name())
+{
+}
+
+//=======================================================================
+//function : NewEmpty
+//purpose :
+//=======================================================================
+Handle(TDF_Attribute) BinMXCAFDoc_KinematicToolDriver::NewEmpty() const
+{
+ return new XCAFDoc_KinematicTool();
+}
+
+//=======================================================================
+//function : Paste
+//purpose :
+//=======================================================================
+Standard_Boolean BinMXCAFDoc_KinematicToolDriver::Paste
+ (const BinObjMgt_Persistent& /*theSource*/,
+ const Handle(TDF_Attribute)& /*theTarget*/,
+ BinObjMgt_RRelocationTable& /*theRelocTable*/) const
+{
+ return Standard_True;
+}
+
+//=======================================================================
+//function : Paste
+//purpose :
+//=======================================================================
+void BinMXCAFDoc_KinematicToolDriver::Paste
+ (const Handle(TDF_Attribute)& /*theSource*/,
+ BinObjMgt_Persistent& /*theTarget*/,
+ BinObjMgt_SRelocationTable& /*theRelocTable*/) const {
+}
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _BinMXCAFDoc_KinematicToolDriver_HeaderFile
+#define _BinMXCAFDoc_KinematicToolDriver_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <BinMDF_ADriver.hxx>
+#include <Standard_Boolean.hxx>
+#include <BinObjMgt_RRelocationTable.hxx>
+#include <BinObjMgt_SRelocationTable.hxx>
+class Message_Messenger;
+class TDF_Attribute;
+class BinObjMgt_Persistent;
+
+
+class BinMXCAFDoc_KinematicToolDriver;
+DEFINE_STANDARD_HANDLE(BinMXCAFDoc_KinematicToolDriver, BinMDF_ADriver)
+
+
+class BinMXCAFDoc_KinematicToolDriver : public BinMDF_ADriver
+{
+
+public:
+
+
+ Standard_EXPORT BinMXCAFDoc_KinematicToolDriver(const Handle(Message_Messenger)& theMsgDriver);
+
+ Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual Standard_Boolean Paste (const BinObjMgt_Persistent& theSource, const Handle(TDF_Attribute)& theTarget, BinObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource, BinObjMgt_Persistent& theTarget, BinObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
+
+ DEFINE_STANDARD_RTTIEXT(BinMXCAFDoc_KinematicToolDriver, BinMDF_ADriver)
+
+};
+#endif // _BinMXCAFDoc_KinematicToolDriver_HeaderFile
BinMXCAFDoc_GeomToleranceDriver.hxx
BinMXCAFDoc_GraphNodeDriver.cxx
BinMXCAFDoc_GraphNodeDriver.hxx
+BinMXCAFDoc_KinematicPairDriver.cxx
+BinMXCAFDoc_KinematicPairDriver.hxx
+BinMXCAFDoc_KinematicPairValueDriver.cxx
+BinMXCAFDoc_KinematicPairValueDriver.hxx
+BinMXCAFDoc_KinematicToolDriver.cxx
+BinMXCAFDoc_KinematicToolDriver.hxx
BinMXCAFDoc_LayerToolDriver.cxx
BinMXCAFDoc_LayerToolDriver.hxx
BinMXCAFDoc_LocationDriver.cxx
XCAFDoc
XCAFPrs
XCAFView
+XCAFKinematics
XCAFDoc_GraphNode.cxx
XCAFDoc_GraphNode.hxx
XCAFDoc_GraphNodeSequence.hxx
+XCAFDoc_KinematicPair.cxx
+XCAFDoc_KinematicPair.hxx
+XCAFDoc_KinematicPairValue.cxx
+XCAFDoc_KinematicPairValue.hxx
+XCAFDoc_KinematicTool.cxx
+XCAFDoc_KinematicTool.hxx
XCAFDoc_LayerTool.cxx
XCAFDoc_LayerTool.hxx
XCAFDoc_Location.cxx
efd212f5-6dfd-11d4-b9c8-0060b0ee281b: GraphNode attribute
efd212f6-6dfd-11d4-b9c8-0060b0ee281b
efd212f7-6dfd-11d4-b9c8-0060b0ee281b
+
+CD65A782-448C-4935-8499-2210D970C175: Kinematics attributes
+35FF1462-E684-465F-B0B9-5CAD14B5018F
+6AA96F91-7436-46F9-A955-4B3CCC42592B
+89FB0996-A8B8-4085-87A9-63AB5D56D8C1
+8A9E9B60-7CA1-45F1-882A-42390D4DB894
+6BE4AAD0-36BE-4D17-B65C-0B2062E04D92
+4F451E46-0AC9-4270-90E4-D96605CDE635
static const Standard_GUID ID("efd213eb-6dfd-11d4-b9c8-0060b0ee281b");
return ID;
}
+
+//=======================================================================
+//function : KinematicRefShapeGUID
+//purpose :
+//=======================================================================
+
+const Standard_GUID& XCAFDoc::KinematicRefShapeGUID()
+{
+ static const Standard_GUID ID("CD65A782-448C-4935-8499-2210D970C175");
+ return ID;
+}
+
+//=======================================================================
+//function : KinematicRefLink1GUID
+//purpose :
+//=======================================================================
+
+const Standard_GUID& XCAFDoc::KinematicRefLink1GUID()
+{
+ static const Standard_GUID ID("35FF1462-E684-465F-B0B9-5CAD14B5018F");
+ return ID;
+}
+
+//=======================================================================
+//function : KinematicRefLink2GUID
+//purpose :
+//=======================================================================
+
+const Standard_GUID& XCAFDoc::KinematicRefLink2GUID()
+{
+ static const Standard_GUID ID("6AA96F91-7436-46F9-A955-4B3CCC42592B");
+ return ID;
+}
+
class XCAFDoc_GraphNode;
class XCAFDoc_Editor;
class XCAFDoc_ViewTool;
+class XCAFDoc_KinematicTool;
//! Definition of general structure of DECAF document
//! Returns GUID for UAttribute identifying lock flag
Standard_EXPORT static const Standard_GUID& LockGUID();
+ //! Return GUIDs for GraphNode representing specified types of Kinematics
+ Standard_EXPORT static const Standard_GUID& KinematicRefShapeGUID();
+
+ //! Return GUIDs for TreeNode representing specified types of Kinematics
+ Standard_EXPORT static const Standard_GUID& KinematicRefLink1GUID();
+
+ //! Return GUIDs for TreeNode representing specified types of Kinematics
+ Standard_EXPORT static const Standard_GUID& KinematicRefLink2GUID();
+
};
#endif // _XCAFDoc_HeaderFile
#include <XCAFDoc_ColorTool.hxx>
#include <XCAFDoc_ClippingPlaneTool.hxx>
#include <XCAFDoc_DimTolTool.hxx>
+#include <XCAFDoc_KinematicTool.hxx>
#include <XCAFDoc_LayerTool.hxx>
#include <XCAFDoc_MaterialTool.hxx>
#include <XCAFDoc_NotesTool.hxx>
XCAFDoc_NotesTool::Set(NotesLabel(L));
XCAFDoc_ViewTool::Set(ViewsLabel(L));
XCAFDoc_ClippingPlaneTool::Set(ClippingPlanesLabel(L));
+ XCAFDoc_KinematicTool::Set(KinematicsLabel(L));
}
return A;
}
return aLabel;
}
+//=======================================================================
+//function : KinematicsLabel
+//purpose :
+//=======================================================================
+
+TDF_Label XCAFDoc_DocumentTool::KinematicsLabel(const TDF_Label& acces)
+{
+ TDF_Label L = DocLabel(acces).FindChild(11, Standard_True);
+ TDataStd_Name::Set(L, "Kinematics");
+ return L;
+}
+
//=======================================================================
//function : ShapeTool
//purpose :
return XCAFDoc_NotesTool::Set(NotesLabel(acces));
}
+//=======================================================================
+//function : KinematicTool
+//purpose :
+//=======================================================================
+
+Handle(XCAFDoc_KinematicTool) XCAFDoc_DocumentTool::KinematicTool(const TDF_Label& acces)
+{
+ return XCAFDoc_KinematicTool::Set(KinematicsLabel(acces));
+}
+
//=======================================================================
//function : ID
//purpose :
class XCAFDoc_NotesTool;
class XCAFDoc_ViewTool;
class XCAFDoc_VisMaterialTool;
+class XCAFDoc_KinematicTool;
class TDF_Attribute;
class TDF_RelocationTable;
//! Returns sub-label of DocLabel() with tag 10.
Standard_EXPORT static TDF_Label VisMaterialLabel (const TDF_Label& theLabel);
+ //! Returns sub-label of DocLabel() with tag 11.
+ Standard_EXPORT static TDF_Label KinematicsLabel (const TDF_Label& acces);
+
//! Creates (if it does not exist) ShapeTool attribute on ShapesLabel().
Standard_EXPORT static Handle(XCAFDoc_ShapeTool) ShapeTool (const TDF_Label& acces);
//! Creates (if it does not exist) NotesTool attribute on NotesLabel().
Standard_EXPORT static Handle(XCAFDoc_NotesTool) NotesTool(const TDF_Label& acces);
+ //! Creates (if it does not exist) KinematicTool attribute on KinematicsLabel().
+ Standard_EXPORT static Handle(XCAFDoc_KinematicTool) KinematicTool(const TDF_Label& acces);
+
public:
Standard_EXPORT XCAFDoc_DocumentTool();
--- /dev/null
+// Created on: 2020-03-17
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <XCAFDoc_KinematicPair.hxx>
+
+#include <BRep_Builder.hxx>
+#include <gp_Pln.hxx>
+#include <Standard_Dump.hxx>
+#include <Standard_GUID.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+#include <TDataStd_AsciiString.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_Real.hxx>
+#include <TDataStd_RealArray.hxx>
+#include <TDataXtd_Geometry.hxx>
+#include <TDataXtd_Plane.hxx>
+#include <TDF_ChildIterator.hxx>
+#include <TNaming_Builder.hxx>
+#include <TNaming_Tool.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <XCAFDoc.hxx>
+#include <XCAFKinematics_HighOrderPairObject.hxx>
+#include <XCAFKinematics_LowOrderPairObject.hxx>
+#include <XCAFKinematics_LowOrderPairObjectWithCoupling.hxx>
+#include <XCAFKinematics_PairObject.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_KinematicPair, TDF_Attribute)
+
+enum ChildLab
+{
+ ChildLab_FirstTrsf = 1,
+ ChildLab_SecondTrsf,
+ ChildLab_FirstGeomParam,
+ ChildLab_SecondGeomParam,
+ ChildLab_Value
+};
+
+//=======================================================================
+//function : XCAFDoc_KinematicPair
+//purpose :
+//=======================================================================
+XCAFDoc_KinematicPair::XCAFDoc_KinematicPair()
+{
+}
+
+
+//=======================================================================
+//function : GetID
+//purpose :
+//=======================================================================
+const Standard_GUID& XCAFDoc_KinematicPair::GetID()
+{
+ static Standard_GUID PairID ("89FB0996-A8B8-4085-87A9-63AB5D56D8C1");
+ return PairID;
+}
+
+//=======================================================================
+//function : getLimitsID
+//purpose :
+//=======================================================================
+const Standard_GUID& XCAFDoc_KinematicPair::getLimitsID()
+{
+ static Standard_GUID KinematicLimitsID("8A9E9B60-7CA1-45F1-882A-42390D4DB894");
+ return KinematicLimitsID;
+}
+
+//=======================================================================
+//function : getParamsID
+//purpose :
+//=======================================================================
+const Standard_GUID& XCAFDoc_KinematicPair::getParamsID()
+{
+ static Standard_GUID KinematicParamsID("6BE4AAD0-36BE-4D17-B65C-0B2062E04D92");
+ return KinematicParamsID;
+}
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+Handle(XCAFDoc_KinematicPair) XCAFDoc_KinematicPair::Set(const TDF_Label& theLabel)
+{
+ Handle(XCAFDoc_KinematicPair) anAttr;
+ if (!theLabel.FindAttribute(XCAFDoc_KinematicPair::GetID(), anAttr)) {
+ anAttr = new XCAFDoc_KinematicPair();
+ theLabel.AddAttribute(anAttr);
+ }
+ return anAttr;
+}
+
+//=======================================================================
+//function : SetObject
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicPair::SetObject(const Handle(XCAFKinematics_PairObject)& theObject)
+{
+ 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
+ TDataStd_Name::Set(Label(), theObject->Name());
+ TDataStd_Integer::Set(Label(), theObject->Type());
+ 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) {
+ Handle(TDataStd_RealArray) aLimitsAttr;
+ aLimitsAttr = TDataStd_RealArray::Set(Label(), getLimitsID(), 1, theObject->GetAllLimits()->Length());
+ aLimitsAttr->ChangeArray(theObject->GetAllLimits());
+ }
+
+ // Low order pairs
+ if (theObject->Type() == XCAFKinematics_PairType_Universal ||
+ theObject->Type() == XCAFKinematics_PairType_Homokinetic) {
+ Handle(XCAFKinematics_LowOrderPairObject) anObject =
+ Handle(XCAFKinematics_LowOrderPairObject)::DownCast(theObject);
+ TDataStd_Real::Set(Label(), getParamsID(), anObject->SkewAngle());
+ }
+
+ // Low order pairs with motion coupling
+ if (theObject->Type() >= XCAFKinematics_PairType_Screw &&
+ theObject->Type() <= XCAFKinematics_PairType_Gear) {
+ Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObject =
+ Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(theObject);
+ if (!anObject->GetAllParams().IsNull() && anObject->GetAllParams()->Upper() > 0) {
+ Handle(TDataStd_RealArray) aParamsAttr;
+ aParamsAttr = TDataStd_RealArray::Set(Label(), getParamsID(), 1, anObject->GetAllParams()->Upper());
+ aParamsAttr->ChangeArray(anObject->GetAllParams());
+ }
+ }
+
+ // High order pairs
+ if (theObject->Type() >= XCAFKinematics_PairType_PointOnSurface &&
+ theObject->Type() <= XCAFKinematics_PairType_RollingCurve) {
+ Handle(XCAFKinematics_HighOrderPairObject) anObject =
+ 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())
+ {
+ TopoDS_Face aFace;
+ aBuilder.MakeFace(aFace, anObject->Surface(), Precision::Confusion());
+ TNaming_Builder aTNBuild(Label().FindChild(ChildLab_FirstGeomParam));
+ aTNBuild.Generated(aFace);
+ }
+ if (theObject->Type() == XCAFKinematics_PairType_SlidingSurface ||
+ theObject->Type() == XCAFKinematics_PairType_RollingSurface)
+ {
+ TopoDS_Face aFace1, aFace2;
+ if (!anObject->FirstSurface().IsNull()) {
+ aBuilder.MakeFace(aFace1, anObject->FirstSurface(), Precision::Confusion());
+ TNaming_Builder aTNBuild1(Label().FindChild(ChildLab_FirstGeomParam));
+ aTNBuild1.Generated(aFace1);
+ }
+ if (!anObject->SecondSurface().IsNull()) {
+ aBuilder.MakeFace(aFace2, anObject->SecondSurface(), Precision::Confusion());
+ TNaming_Builder aTNBuild2(Label().FindChild(ChildLab_SecondGeomParam));
+ aTNBuild2.Generated(aFace2);
+ }
+ }
+ if (theObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve && !anObject->Curve().IsNull())
+ {
+ TopoDS_Edge anEdge;
+ aBuilder.MakeEdge(anEdge, anObject->Curve(), Precision::Confusion());
+ TNaming_Builder aTNBuild(Label().FindChild(ChildLab_FirstGeomParam));
+ aTNBuild.Generated(anEdge);
+ }
+ if (theObject->Type() == XCAFKinematics_PairType_SlidingCurve ||
+ theObject->Type() == XCAFKinematics_PairType_RollingCurve)
+ {
+ TopoDS_Edge anEdge1, anEdge2;
+ if (!anObject->FirstCurve().IsNull()) {
+ aBuilder.MakeEdge(anEdge1, anObject->FirstCurve(), Precision::Confusion());
+ TNaming_Builder aTNBuild1(Label().FindChild(ChildLab_FirstGeomParam));
+ aTNBuild1.Generated(anEdge1);
+ }
+ if (!anObject->SecondCurve().IsNull()) {
+ aBuilder.MakeEdge(anEdge2, anObject->SecondCurve(), Precision::Confusion());
+ TNaming_Builder aTNBuild2(Label().FindChild(ChildLab_SecondGeomParam));
+ aTNBuild2.Generated(anEdge2);
+ }
+ }
+ }
+}
+
+//=======================================================================
+//function : GetObject
+//purpose :
+//=======================================================================
+Handle(XCAFKinematics_PairObject) XCAFDoc_KinematicPair::GetObject() const
+{
+ // Type
+ Handle(TDataStd_Integer) aTypeAttr;
+ Handle(XCAFKinematics_PairObject) anObject = new XCAFKinematics_PairObject();
+ if (Label().FindAttribute(TDataStd_Integer::GetID(), aTypeAttr))
+ {
+ int aType = aTypeAttr->Get();
+ if (aType >= XCAFKinematics_PairType_FullyConstrained &&
+ aType <= XCAFKinematics_PairType_Unconstrained)
+ anObject = new XCAFKinematics_LowOrderPairObject();
+ else if (aType >= XCAFKinematics_PairType_Screw &&
+ aType <= XCAFKinematics_PairType_Gear)
+ anObject = new XCAFKinematics_LowOrderPairObjectWithCoupling();
+ else if (aType >= XCAFKinematics_PairType_PointOnSurface &&
+ aType <= XCAFKinematics_PairType_RollingCurve)
+ anObject = new XCAFKinematics_HighOrderPairObject();
+ anObject->SetType((XCAFKinematics_PairType)aType);
+ }
+
+ // Name
+ Handle(TDataStd_Name) aNameAttr;
+ if (Label().FindAttribute(TDataStd_Name::GetID(), aNameAttr))
+ anObject->SetName(aNameAttr->Get());
+
+ //Transformations
+ Handle(TDataXtd_Plane) aTrsfAttr;
+ if (Label().FindChild(ChildLab_FirstTrsf).FindAttribute(TDataXtd_Plane::GetID(), aTrsfAttr)) {
+ gp_Pln aPlane;
+ TDataXtd_Geometry::Plane(aTrsfAttr->Label(), aPlane);
+ anObject->SetFirstTransformation(aPlane.Position());
+ }
+ if (Label().FindChild(ChildLab_SecondTrsf).FindAttribute(TDataXtd_Plane::GetID(), aTrsfAttr)) {
+ gp_Pln aPlane;
+ TDataXtd_Geometry::Plane(aTrsfAttr->Label(), aPlane);
+ anObject->SetSecondTransformation(aPlane.Position());
+ }
+
+ // Limits
+ Handle(TDataStd_RealArray) aLimitsAttr;
+ if (Label().FindAttribute(getLimitsID(), aLimitsAttr)) {
+ Handle(TColStd_HArray1OfReal) aLimitsArray = aLimitsAttr->Array();
+ anObject->SetAllLimits(aLimitsArray);
+ }
+
+ // Low order pairs
+ if (anObject->Type() == XCAFKinematics_PairType_Universal ||
+ anObject->Type() == XCAFKinematics_PairType_Homokinetic) {
+ Handle(XCAFKinematics_LowOrderPairObject) aDefObject =
+ Handle(XCAFKinematics_LowOrderPairObject)::DownCast(anObject);
+ Handle(TDataStd_Real) aParamAttr;
+ if (Label().FindAttribute(getParamsID(), aParamAttr)) {
+ aDefObject->SetSkewAngle(aParamAttr->Get());
+ }
+ }
+
+ // Low order pairs with motion coupling
+ if (anObject->Type() >= XCAFKinematics_PairType_Screw &&
+ anObject->Type() <= XCAFKinematics_PairType_Gear) {
+ Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) aDefObject =
+ Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(anObject);
+ Handle(TDataStd_RealArray) aParamsAttr;
+ if (Label().FindAttribute(getParamsID(), aParamsAttr)) {
+ Handle(TColStd_HArray1OfReal) aParamsArray = aParamsAttr->Array();
+ aDefObject->SetAllParams(aParamsAttr->Array());
+ }
+ }
+
+ // High order pairs
+ if (anObject->Type() >= XCAFKinematics_PairType_PointOnSurface &&
+ anObject->Type() <= XCAFKinematics_PairType_RollingCurve) {
+ Handle(XCAFKinematics_HighOrderPairObject) aDefObject =
+ Handle(XCAFKinematics_HighOrderPairObject)::DownCast(anObject);
+ Handle(TDataStd_Integer) anOrienAttr;
+ if (Label().FindAttribute(getParamsID(), anOrienAttr)) {
+ aDefObject->SetOrientation(anOrienAttr->Get() != 0);
+ }
+
+ Handle(TNaming_NamedShape) aNS;
+ if (anObject->Type() == XCAFKinematics_PairType_PointOnSurface)
+ {
+ if (Label().FindChild(ChildLab_FirstGeomParam).FindAttribute(TNaming_NamedShape::GetID(), aNS))
+ {
+ TopoDS_Face aFace = TopoDS::Face(TNaming_Tool::GetShape(aNS));
+ aDefObject->SetSurface(BRep_Tool::Surface(aFace));
+ }
+ }
+ if (anObject->Type() == XCAFKinematics_PairType_SlidingSurface ||
+ anObject->Type() == XCAFKinematics_PairType_RollingSurface)
+ {
+ if (Label().FindChild(ChildLab_FirstGeomParam).FindAttribute(TNaming_NamedShape::GetID(), aNS))
+ {
+ TopoDS_Face aFace = TopoDS::Face(TNaming_Tool::GetShape(aNS));
+ aDefObject->SetFirstSurface(BRep_Tool::Surface(aFace));
+ }
+ if (Label().FindChild(ChildLab_SecondGeomParam).FindAttribute(TNaming_NamedShape::GetID(), aNS))
+ {
+ TopoDS_Face aFace = TopoDS::Face(TNaming_Tool::GetShape(aNS));
+ aDefObject->SetSecondSurface(BRep_Tool::Surface(aFace));
+ }
+ }
+ if (anObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve)
+ {
+ if (Label().FindChild(ChildLab_FirstGeomParam).FindAttribute(TNaming_NamedShape::GetID(), aNS))
+ {
+ TopoDS_Edge anEdge = TopoDS::Edge(TNaming_Tool::GetShape(aNS));
+ Standard_Real aFirst, aLast;
+ aDefObject->SetCurve(BRep_Tool::Curve(anEdge, aFirst, aLast));
+ }
+ }
+ if (anObject->Type() == XCAFKinematics_PairType_SlidingCurve ||
+ anObject->Type() == XCAFKinematics_PairType_RollingCurve)
+ {
+ if (Label().FindChild(ChildLab_FirstGeomParam).FindAttribute(TNaming_NamedShape::GetID(), aNS))
+ {
+ TopoDS_Edge anEdge = TopoDS::Edge(TNaming_Tool::GetShape(aNS));
+ Standard_Real aFirst, aLast;
+ aDefObject->SetFirstCurve(BRep_Tool::Curve(anEdge, aFirst, aLast));
+ }
+ if (Label().FindChild(ChildLab_SecondGeomParam).FindAttribute(TNaming_NamedShape::GetID(), aNS))
+ {
+ TopoDS_Edge anEdge = TopoDS::Edge(TNaming_Tool::GetShape(aNS));
+ Standard_Real aFirst, aLast;
+ aDefObject->SetSecondCurve(BRep_Tool::Curve(anEdge, aFirst, aLast));
+ }
+ }
+ }
+
+ return anObject;
+}
+
+//=======================================================================
+//function : ID
+//purpose :
+//=======================================================================
+const Standard_GUID& XCAFDoc_KinematicPair::ID() const
+{
+ return GetID();
+}
+
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicPair::Restore(const Handle(TDF_Attribute)& /*With*/)
+{
+}
+
+
+//=======================================================================
+//function : NewEmpty
+//purpose :
+//=======================================================================
+Handle(TDF_Attribute) XCAFDoc_KinematicPair::NewEmpty() const
+{
+ return new XCAFDoc_KinematicPair();
+}
+
+
+//=======================================================================
+//function : Paste
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicPair::Paste(const Handle(TDF_Attribute)& /*Into*/,
+ const Handle(TDF_RelocationTable)& /*RT*/) const
+{
+}
+
+//=======================================================================
+//function : DumpJson
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicPair::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
+{
+ OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+
+ OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
+}
--- /dev/null
+// Created on: 2020-03-17
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _XCAFDoc_KinematicPair_HeaderFile
+#define _XCAFDoc_KinematicPair_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <TDF_Attribute.hxx>
+class Standard_GUID;
+class TDF_Label;
+class TDF_Attribute;
+class TDF_RelocationTable;
+class XCAFKinematics_PairObject;
+
+// resolve name collisions with WinAPI headers
+#ifdef GetObject
+ #undef GetObject
+#endif
+
+class XCAFDoc_KinematicPair;
+DEFINE_STANDARD_HANDLE(XCAFDoc_KinematicPair, TDF_Attribute)
+
+//! Attribute to store kinematic pair
+class XCAFDoc_KinematicPair : public TDF_Attribute
+{
+
+public:
+
+ Standard_EXPORT XCAFDoc_KinematicPair();
+
+ Standard_EXPORT static const Standard_GUID& GetID();
+
+ Standard_EXPORT static Handle(XCAFDoc_KinematicPair) Set (const TDF_Label& theLabel);
+
+ Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
+
+ Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
+
+ Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+
+ Standard_EXPORT void Paste(const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
+
+ //! Updates parent's label and its sub-labels with data taken from thePairObject.
+ //! Old data associated with the label will be lost.
+ Standard_EXPORT void SetObject(const Handle(XCAFKinematics_PairObject)& thePairObject);
+
+ //! Returns kinematic pair object data taken from the parent's label and its sub-labels.
+ Standard_EXPORT Handle(XCAFKinematics_PairObject) GetObject() const;
+
+ //! Dumps the content of me into the stream
+ Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
+private:
+
+ Standard_EXPORT static const Standard_GUID& getLimitsID();
+
+ Standard_EXPORT static const Standard_GUID& getParamsID();
+
+ DEFINE_STANDARD_RTTIEXT(XCAFDoc_KinematicPair, TDF_Attribute)
+
+};
+
+#endif
--- /dev/null
+// Created on: 2020-03-30
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <XCAFDoc_KinematicPairValue.hxx>
+
+#include <Standard_Dump.hxx>
+#include <Standard_GUID.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_RealArray.hxx>
+#include <TDF_ChildIterator.hxx>
+#include <XCAFDoc.hxx>
+#include <XCAFDoc_KinematicPair.hxx>
+#include <XCAFKinematics_PairValueObject.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_KinematicPairValue, TDF_Attribute)
+
+// Gor first children are reserved for kinematic pair parameters
+enum ValueLab
+{
+ ValueLab_Values = 5
+};
+
+//=======================================================================
+//function : XCAFDoc_KinematicPairValue
+//purpose :
+//=======================================================================
+XCAFDoc_KinematicPairValue::XCAFDoc_KinematicPairValue()
+{
+}
+
+
+//=======================================================================
+//function : GetID
+//purpose :
+//=======================================================================
+const Standard_GUID& XCAFDoc_KinematicPairValue::GetID()
+{
+ static Standard_GUID PairValueID ("4F451E46-0AC9-4270-90E4-D96605CDE635");
+ return PairValueID;
+}
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+Handle(XCAFDoc_KinematicPairValue) XCAFDoc_KinematicPairValue::Set(const TDF_Label& theLabel)
+{
+ Handle(XCAFDoc_KinematicPairValue) anAttr;
+ if (!theLabel.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), anAttr)) {
+ anAttr = new XCAFDoc_KinematicPairValue();
+ theLabel.AddAttribute(anAttr);
+ }
+ return anAttr;
+}
+
+//=======================================================================
+//function : SetObject
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicPairValue::SetObject(const Handle(XCAFKinematics_PairValueObject)& theObject)
+{
+ Backup();
+
+ Label().FindChild(ValueLab_Values).ForgetAllAttributes();
+
+ // Check if kinematic pair and pair value on the given label are consistent
+ Handle(XCAFDoc_KinematicPair) aPairAttr;
+ if (!Label().FindAttribute(XCAFDoc_KinematicPair::GetID(), aPairAttr))
+ return;
+ Handle(TDataStd_Integer) aMainTypeAttr;
+ if (Label().FindAttribute(TDataStd_Integer::GetID(), aMainTypeAttr))
+ {
+ int aType = aMainTypeAttr->Get();
+ if (aType != theObject->Type())
+ return;
+ }
+
+ // Check validity of object
+ if (theObject->GetAllValues()->Length() == 0)
+ return;
+
+ TDataStd_Name::Set(Label().FindChild(ValueLab_Values), "Value");
+ TDataStd_Integer::Set(Label().FindChild(ValueLab_Values), theObject->Type());
+
+ Handle(TDataStd_RealArray) aValuesAttr;
+ aValuesAttr = TDataStd_RealArray::Set(Label().FindChild(ValueLab_Values), 1, theObject->GetAllValues()->Length());
+ aValuesAttr->ChangeArray(theObject->GetAllValues());
+}
+
+//=======================================================================
+//function : GetObject
+//purpose :
+//=======================================================================
+Handle(XCAFKinematics_PairValueObject) XCAFDoc_KinematicPairValue::GetObject() const
+{
+ // Type
+ Handle(TDataStd_Integer) aTypeAttr;
+ Handle(XCAFKinematics_PairValueObject) anObject = new XCAFKinematics_PairValueObject();
+ if (Label().FindChild(ValueLab_Values).FindAttribute(TDataStd_Integer::GetID(), aTypeAttr))
+ {
+ int aType = aTypeAttr->Get();
+ anObject->SetType((XCAFKinematics_PairType)aType);
+ }
+
+ // Values
+ Handle(TDataStd_RealArray) aValuesAttr;
+ if (Label().FindChild(ValueLab_Values).FindAttribute(TDataStd_RealArray::GetID(), aValuesAttr)) {
+ Handle(TColStd_HArray1OfReal) aValuesArray = aValuesAttr->Array();
+ anObject->SetAllValues(aValuesArray);
+ }
+
+ return anObject;
+}
+
+//=======================================================================
+//function : ID
+//purpose :
+//=======================================================================
+const Standard_GUID& XCAFDoc_KinematicPairValue::ID() const
+{
+ return GetID();
+}
+
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicPairValue::Restore(const Handle(TDF_Attribute)& /*With*/)
+{
+}
+
+
+//=======================================================================
+//function : NewEmpty
+//purpose :
+//=======================================================================
+Handle(TDF_Attribute) XCAFDoc_KinematicPairValue::NewEmpty() const
+{
+ return new XCAFDoc_KinematicPairValue();
+}
+
+
+//=======================================================================
+//function : Paste
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicPairValue::Paste(const Handle(TDF_Attribute)& /*Into*/,
+ const Handle(TDF_RelocationTable)& /*RT*/) const
+{
+}
+
+//=======================================================================
+//function : DumpJson
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicPairValue::DumpJson(Standard_OStream& theOStream, Standard_Integer theDepth) const
+{
+ OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+
+ OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
+}
--- /dev/null
+// Created on: 2020-03-30
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _XCAFDoc_KinematicPairValue_HeaderFile
+#define _XCAFDoc_KinematicPairValue_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <TDF_Attribute.hxx>
+class Standard_GUID;
+class TDF_Label;
+class TDF_Attribute;
+class TDF_RelocationTable;
+class XCAFKinematics_PairValueObject;
+
+// resolve name collisions with WinAPI headers
+#ifdef GetObject
+ #undef GetObject
+#endif
+
+class XCAFDoc_KinematicPairValue;
+DEFINE_STANDARD_HANDLE(XCAFDoc_KinematicPairValue, TDF_Attribute)
+
+//! Attribute to store kinematic pair value.
+//! This parameter is an additional attribute for kinematic pair attribute
+//! It is prohibited to store inconsistent data:
+//! - to store this attribute without kinematic value attribute
+//! - to store attributes with different types
+class XCAFDoc_KinematicPairValue : public TDF_Attribute
+{
+
+public:
+
+ Standard_EXPORT XCAFDoc_KinematicPairValue();
+
+ Standard_EXPORT static const Standard_GUID& GetID();
+
+ Standard_EXPORT static Handle(XCAFDoc_KinematicPairValue) Set (const TDF_Label& theLabel);
+
+ Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
+
+ Standard_EXPORT void Restore (const Handle(TDF_Attribute)& With) Standard_OVERRIDE;
+
+ Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+
+ Standard_EXPORT void Paste(const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
+
+ //! Updates parent's label and its sub-labels with data taken from thePairValueObject.
+ //! Old data associated with the label will be lost.
+ Standard_EXPORT void SetObject(const Handle(XCAFKinematics_PairValueObject)& thePairValueObject);
+
+ //! Returns kinematic pair value object data taken from the parent's label and its sub-labels.
+ Standard_EXPORT Handle(XCAFKinematics_PairValueObject) GetObject() const;
+
+ //! Dumps the content of me into the stream
+ Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
+private:
+
+ DEFINE_STANDARD_RTTIEXT(XCAFDoc_KinematicPairValue, TDF_Attribute)
+
+};
+
+#endif
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <XCAFDoc_KinematicTool.hxx>
+
+#include <Standard_GUID.hxx>
+#include <Standard_Type.hxx>
+#include <TDataStd_Name.hxx>
+#include <TDataStd_TreeNode.hxx>
+#include <TDF_Attribute.hxx>
+#include <TDF_ChildIDIterator.hxx>
+#include <TDF_Label.hxx>
+#include <XCAFDoc.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_GraphNode.hxx>
+#include <XCAFDoc_KinematicPair.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XCAFDoc_KinematicTool, TDF_Attribute)
+
+//=======================================================================
+//function : XCAFDoc_KinematicTool
+//purpose :
+//=======================================================================
+XCAFDoc_KinematicTool::XCAFDoc_KinematicTool()
+{
+}
+
+
+//=======================================================================
+//function : Set
+//purpose :
+//=======================================================================
+Handle(XCAFDoc_KinematicTool) XCAFDoc_KinematicTool::Set(const TDF_Label& theLabel)
+{
+ Handle(XCAFDoc_KinematicTool) anAttr;
+ if (!theLabel.FindAttribute(XCAFDoc_KinematicTool::GetID(), anAttr)) {
+ anAttr = new XCAFDoc_KinematicTool();
+ theLabel.AddAttribute(anAttr);
+ }
+ return anAttr;
+}
+
+
+//=======================================================================
+//function : GetID
+//purpose :
+//=======================================================================
+const Standard_GUID& XCAFDoc_KinematicTool::GetID()
+{
+ static Standard_GUID KinematicToolID("322D8F8D-8E93-4F6A-A98B-CCC2EBBCC34D");
+ return KinematicToolID;
+}
+
+
+//=======================================================================
+//function : BaseLabel
+//purpose :
+//=======================================================================
+TDF_Label XCAFDoc_KinematicTool::BaseLabel() const
+{
+ return Label();
+}
+
+//=======================================================================
+//function : AddMechanism
+//purpose :
+//=======================================================================
+TDF_Label XCAFDoc_KinematicTool::AddMechanism()
+{
+ TDF_TagSource aTag;
+ TDF_Label aMechanismL = aTag.NewChild(Label());
+ TCollection_AsciiString aName = "Mechanism ";
+ aName.AssignCat(TCollection_AsciiString(Label().NbChildren()));
+ TDataStd_Name::Set(aMechanismL, aName);
+ TDF_Label aRootOfLinks = aMechanismL.FindChild(1);
+ TDataStd_Name::Set(aRootOfLinks, "Links");
+ TDF_Label aRootOfJoints = aMechanismL.FindChild(2);
+ TDataStd_Name::Set(aRootOfJoints, "Joints");
+ return aMechanismL;
+}
+
+//=======================================================================
+//function : IsMechanism
+//purpose :
+//=======================================================================
+Standard_Boolean XCAFDoc_KinematicTool::IsMechanism(const TDF_Label& theLabel) const
+{
+ if (!Label().IsEqual(theLabel.Father()))
+ return Standard_False;
+
+ return (theLabel.NbChildren() == 2);
+}
+
+//=======================================================================
+//function : RemoveMechanism
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicTool::RemoveMechanism(const TDF_Label& theLabel)
+{
+ if (!IsMechanism(theLabel))
+ return;
+
+ for (TDF_ChildIterator aLinkIt(getRootOfLinks(theLabel)); aLinkIt.More(); aLinkIt.Next())
+ RemoveLink(aLinkIt.Value());
+ for (TDF_ChildIterator aJointIt(getRootOfJoints(theLabel)); aJointIt.More(); aJointIt.Next())
+ RemoveJoint(aJointIt.Value());
+
+ theLabel.ForgetAllAttributes();
+}
+
+//=======================================================================
+//function : AddLink
+//purpose :
+//=======================================================================
+TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism)
+{
+ if (!IsMechanism(theMechanism))
+ return TDF_Label();
+
+ TDF_TagSource aTag;
+ return aTag.NewChild(getRootOfLinks(theMechanism));
+}
+
+//=======================================================================
+//function : AddLink
+//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;
+}
+
+//=======================================================================
+//function : AddLink
+//purpose :
+//=======================================================================
+TDF_Label XCAFDoc_KinematicTool::AddLink(const TDF_Label& theMechanism,
+ const TDF_Label& theShape)
+{
+ TDF_LabelSequence anAuxSequence;
+ anAuxSequence.Append(theShape);
+ return AddLink(theMechanism, anAuxSequence);
+}
+
+//=======================================================================
+//function : SetLink
+//purpose :
+//=======================================================================
+Standard_Boolean XCAFDoc_KinematicTool::SetLink(const TDF_Label& theLink,
+ const TDF_LabelSequence& theShapes)
+{
+ if (theShapes.Length() == 0)
+ return Standard_False;
+
+ Handle(XCAFDoc_GraphNode) aLinkGNode;
+ Handle(XCAFDoc_GraphNode) aShapesGNode;
+
+ // Clear link from old references to shapes
+ if (theLink.FindAttribute(XCAFDoc::KinematicRefShapeGUID(), aLinkGNode)) {
+ while (aLinkGNode->NbFathers() > 0) {
+ aShapesGNode = aLinkGNode->GetFather(1);
+ aShapesGNode->UnSetChild(aLinkGNode);
+ if (aShapesGNode->NbChildren() == 0)
+ aShapesGNode->ForgetAttribute(XCAFDoc::KinematicRefShapeGUID());
+ }
+ theLink.ForgetAttribute(XCAFDoc::KinematicRefShapeGUID());
+ }
+
+ // Create new references
+ aLinkGNode = new XCAFDoc_GraphNode;
+ aLinkGNode = XCAFDoc_GraphNode::Set(theLink);
+ aLinkGNode->SetGraphID(XCAFDoc::KinematicRefShapeGUID());
+
+ for (Standard_Integer i = theShapes.Lower(); i <= theShapes.Upper(); i++) {
+ if (!theShapes.Value(i).FindAttribute(XCAFDoc::KinematicRefShapeGUID(), aShapesGNode)) {
+ aShapesGNode = new XCAFDoc_GraphNode;
+ aShapesGNode = XCAFDoc_GraphNode::Set(theShapes.Value(i));
+ aShapesGNode->SetGraphID(XCAFDoc::KinematicRefShapeGUID());
+ }
+ aShapesGNode->SetChild(aLinkGNode);
+ aLinkGNode->SetFather(aShapesGNode);
+ }
+
+ return Standard_True;
+}
+
+//=======================================================================
+//function : SetLink
+//purpose :
+//=======================================================================
+Standard_Boolean XCAFDoc_KinematicTool::SetLink(const TDF_Label& theMechanism,
+ const TDF_Label& theShape)
+{
+ TDF_LabelSequence anAuxSequence;
+ anAuxSequence.Append(theShape);
+ return SetLink(theMechanism, anAuxSequence);
+}
+
+//=======================================================================
+//function : IsLink
+//purpose :
+//=======================================================================
+Standard_Boolean XCAFDoc_KinematicTool::IsLink(const TDF_Label& theLink) const
+{
+ Handle(XCAFDoc_GraphNode) aLinkGNode;
+ return theLink.FindAttribute(XCAFDoc::KinematicRefShapeGUID(), aLinkGNode);
+}
+
+//=======================================================================
+//function : RemoveLink
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicTool::RemoveLink(const TDF_Label& theLink)
+{
+ if (!IsLink(theLink))
+ return;
+
+ Handle(XCAFDoc_GraphNode) aLinkGNode;
+ Handle(XCAFDoc_GraphNode) aShapesGNode;
+
+ // Remove all referenced joints
+ TDF_LabelSequence aRefJoints = GetJointsOfLink(theLink);
+ for (TDF_LabelSequence::Iterator anIt(aRefJoints); anIt.More(); anIt.Next())
+ RemoveJoint(anIt.Value());
+
+ // Clear link from old references to shapes
+ if (theLink.FindAttribute(XCAFDoc::KinematicRefShapeGUID(), aLinkGNode)) {
+ while (aLinkGNode->NbFathers() > 0) {
+ aShapesGNode = aLinkGNode->GetFather(1);
+ aShapesGNode->UnSetChild(aLinkGNode);
+ if (aShapesGNode->NbChildren() == 0)
+ aShapesGNode->ForgetAttribute(XCAFDoc::KinematicRefShapeGUID());
+ }
+ }
+ theLink.ForgetAllAttributes();
+}
+
+//=======================================================================
+//function : AddJoint
+//purpose :
+//=======================================================================
+TDF_Label XCAFDoc_KinematicTool::AddJoint(const TDF_Label& theMechanism)
+{
+ if (!IsMechanism(theMechanism))
+ return TDF_Label();
+
+ TDF_TagSource aTag;
+ TDF_Label aJoint = aTag.NewChild(getRootOfJoints(theMechanism));
+ Handle(XCAFDoc_KinematicPair) aPair = XCAFDoc_KinematicPair::Set(aJoint);
+ return aJoint;
+}
+
+//=======================================================================
+//function : AddJoint
+//purpose :
+//=======================================================================
+TDF_Label XCAFDoc_KinematicTool::AddJoint(const TDF_Label& theMechanism,
+ const TDF_Label& theLink1,
+ const TDF_Label& theLink2)
+{
+ TDF_Label aNewJoint = AddJoint(theMechanism);
+ if (aNewJoint.IsNull())
+ return TDF_Label();
+
+ SetJoint(aNewJoint, theLink1, theLink2);
+ return aNewJoint;
+}
+
+//=======================================================================
+//function : IsJoint
+//purpose :
+//=======================================================================
+Standard_Boolean XCAFDoc_KinematicTool::IsJoint(const TDF_Label& theJoint) const
+{
+ Handle(TDataStd_TreeNode) anAuxAttr;
+ return (theJoint.FindAttribute(XCAFDoc::KinematicRefLink1GUID(), anAuxAttr) &&
+ theJoint.FindAttribute(XCAFDoc::KinematicRefLink2GUID(), anAuxAttr));
+}
+
+//=======================================================================
+//function : SetJoint
+//purpose :
+//=======================================================================
+Standard_Boolean XCAFDoc_KinematicTool::SetJoint(const TDF_Label& theJoint,
+ const TDF_Label& theLink1,
+ const TDF_Label& theLink2)
+{
+ if (!IsLink(theLink1) || !IsLink(theLink2))
+ return Standard_False;
+
+ Handle(TDataStd_TreeNode) aJointNode, aLinkNode;
+ // Add reference to first link
+ aJointNode = TDataStd_TreeNode::Set(theJoint, XCAFDoc::KinematicRefLink1GUID());
+ aLinkNode = TDataStd_TreeNode::Set(theLink1, XCAFDoc::KinematicRefLink1GUID());
+ aJointNode->Remove(); // fix against bug in TreeNode::Append()
+ aLinkNode->Append(aJointNode);
+
+ // Add reference to second link
+ aJointNode = TDataStd_TreeNode::Set(theJoint, XCAFDoc::KinematicRefLink2GUID());
+ aLinkNode = TDataStd_TreeNode::Set(theLink2, XCAFDoc::KinematicRefLink2GUID());
+ aJointNode->Remove(); // fix against bug in TreeNode::Append()
+ aLinkNode->Append(aJointNode);
+ return Standard_True;
+}
+
+//=======================================================================
+//function : RemoveJoint
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicTool::RemoveJoint(const TDF_Label& theJoint)
+{
+ if (!IsJoint(theJoint))
+ return;
+
+ Handle(TDataStd_TreeNode) aNode;
+ theJoint.FindAttribute(XCAFDoc::KinematicRefLink1GUID(), aNode);
+ aNode->Remove();
+ theJoint.FindAttribute(XCAFDoc::KinematicRefLink2GUID(), aNode);
+ aNode->Remove();
+
+ theJoint.ForgetAllAttributes();
+
+}
+
+//=======================================================================
+//function : GetMechanisms
+//purpose :
+//=======================================================================
+TDF_LabelSequence XCAFDoc_KinematicTool::GetMechanisms() const
+{
+ TDF_LabelSequence aMechArray;
+ for (TDF_ChildIterator anIt(Label()); anIt.More(); anIt.Next()) {
+ TDF_Label aMechanism = anIt.Value();
+ if (IsMechanism(aMechanism))
+ aMechArray.Append(aMechanism);
+ }
+
+ return aMechArray;
+}
+
+//=======================================================================
+//function : GetLinks
+//purpose :
+//=======================================================================
+TDF_LabelSequence XCAFDoc_KinematicTool::GetLinks(const TDF_Label& theMechanism) const
+{
+ TDF_LabelSequence aLinkArray;
+ if (!IsMechanism(theMechanism))
+ return aLinkArray;
+
+ for (TDF_ChildIterator anIt(getRootOfLinks(theMechanism)); anIt.More(); anIt.Next()) {
+ TDF_Label aLink = anIt.Value();
+ if (IsLink(aLink))
+ aLinkArray.Append(aLink);
+ }
+
+ return aLinkArray;
+}
+
+//=======================================================================
+//function : GetJoints
+//purpose :
+//=======================================================================
+TDF_LabelSequence XCAFDoc_KinematicTool::GetJoints(const TDF_Label& theMechanism) const
+{
+ TDF_LabelSequence aJointArray;
+ if (!IsMechanism(theMechanism))
+ return aJointArray;
+
+ for (TDF_ChildIterator anIt(getRootOfJoints(theMechanism)); anIt.More(); anIt.Next()) {
+ TDF_Label aJoint = anIt.Value();
+ if (IsJoint(aJoint))
+ aJointArray.Append(aJoint);
+ }
+
+ return aJointArray;
+}
+
+//=======================================================================
+//function : GetLinksOfJoint
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicTool::GetLinksOfJoint(const TDF_Label& theJoint,
+ TDF_Label& theLink1,
+ TDF_Label& theLink2) const
+{
+ if (!IsJoint(theJoint))
+ return;
+
+ Handle(TDataStd_TreeNode) aNode;
+
+ if (theJoint.FindAttribute(XCAFDoc::KinematicRefLink1GUID(), aNode))
+ theLink1 = aNode->Father()->Label();
+
+ if (theJoint.FindAttribute(XCAFDoc::KinematicRefLink2GUID(), aNode))
+ theLink2 = aNode->Father()->Label();
+}
+
+//=======================================================================
+//function : GetJointsOfLink
+//purpose :
+//=======================================================================
+TDF_LabelSequence XCAFDoc_KinematicTool::GetJointsOfLink(const TDF_Label& theLink) const
+{
+ TDF_LabelSequence aJointsArray;
+ if (!IsLink(theLink))
+ return aJointsArray;
+
+ Handle(TDataStd_TreeNode) aNode, aChildNode;
+
+ if (theLink.FindAttribute(XCAFDoc::KinematicRefLink1GUID(), aNode)) {
+ aChildNode = aNode->First();
+ while (!aChildNode.IsNull()) {
+ aJointsArray.Append(aChildNode->Label());
+ aChildNode = aChildNode->Next();
+ }
+ }
+
+ if (theLink.FindAttribute(XCAFDoc::KinematicRefLink2GUID(), aNode)) {
+ aChildNode = aNode->First();
+ while (!aChildNode.IsNull()) {
+ aJointsArray.Append(aChildNode->Label());
+ aChildNode = aChildNode->Next();
+ }
+ }
+
+ return aJointsArray;
+}
+
+//=======================================================================
+//function : GetRefShapes
+//purpose :
+//=======================================================================
+TDF_LabelSequence XCAFDoc_KinematicTool::GetRefShapes(const TDF_Label& theLink) const
+{
+ Handle(XCAFDoc_GraphNode) aGNode;
+ TDF_LabelSequence aShapeArray;
+ if (theLink.FindAttribute(XCAFDoc::KinematicRefShapeGUID(), aGNode) && aGNode->NbFathers() > 0) {
+ for(Standard_Integer i = 1; i <= aGNode->NbFathers(); i++)
+ aShapeArray.Append(aGNode->GetFather(i)->Label());
+ }
+ return aShapeArray;
+}
+
+//=======================================================================
+//function : getRootOfLinks
+//purpose :
+//=======================================================================
+TDF_Label XCAFDoc_KinematicTool::getRootOfLinks(const TDF_Label& theMechanism) const
+{
+ return theMechanism.FindChild(1, Standard_False);
+}
+
+//=======================================================================
+//function : getRootOfJoints
+//purpose :
+//=======================================================================
+TDF_Label XCAFDoc_KinematicTool::getRootOfJoints(const TDF_Label& theMechanism) const
+{
+ return theMechanism.FindChild(2, Standard_False);
+}
+
+//=======================================================================
+//function : ID
+//purpose :
+//=======================================================================
+const Standard_GUID& XCAFDoc_KinematicTool::ID() const
+{
+ return GetID();
+}
+
+
+//=======================================================================
+//function : Restore
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicTool::Restore(const Handle(TDF_Attribute)& /*with*/)
+{
+}
+
+
+//=======================================================================
+//function : NewEmpty
+//purpose :
+//=======================================================================
+Handle(TDF_Attribute) XCAFDoc_KinematicTool::NewEmpty() const
+{
+ return new XCAFDoc_KinematicTool;
+}
+
+
+//=======================================================================
+//function : Paste
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicTool::Paste(const Handle(TDF_Attribute)& /*into*/,
+ const Handle(TDF_RelocationTable)& /*RT*/) const
+{
+}
+
+//=======================================================================
+//function : DumpJson
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicTool::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
+{
+ OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
+
+ OCCT_DUMP_BASE_CLASS (theOStream, theDepth, TDF_Attribute)
+}
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2016 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _XCAFDoc_KinematicTool_HeaderFile
+#define _XCAFDoc_KinematicTool_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <TDF_Attribute.hxx>
+#include <Standard_Boolean.hxx>
+#include <TDF_LabelSequence.hxx>
+#include <Standard_Integer.hxx>
+
+class XCAFDoc_ShapeTool;
+class TDF_Label;
+class Standard_GUID;
+class TDF_Attribute;
+
+
+class XCAFDoc_KinematicTool;
+DEFINE_STANDARD_HANDLE(XCAFDoc_KinematicTool, TDF_Attribute)
+
+//! Provides tools to store and retrieve Kinematics in and from TDocStd_Document.
+//! Kinematics data storage consists of several mechanisms,
+//! each mechanish has its ows sets of links and joints.
+class XCAFDoc_KinematicTool : public TDF_Attribute
+{
+
+public:
+
+
+ Standard_EXPORT XCAFDoc_KinematicTool();
+
+ //! Creates (if not exist) KinematicTool
+ Standard_EXPORT static Handle(XCAFDoc_KinematicTool) Set(const TDF_Label& theLabel);
+
+ Standard_EXPORT static const Standard_GUID& GetID();
+
+ //! Returns the label under which Kinematics is stored
+ Standard_EXPORT TDF_Label BaseLabel() const;
+
+ //! Creates new mechanism - a child under BaseLabel
+ Standard_EXPORT TDF_Label AddMechanism();
+
+ //! Checks is the given label a mechanism
+ Standard_EXPORT Standard_Boolean IsMechanism(const TDF_Label& theLabel) const;
+
+ //! Removes given mechanism with all underlying information
+ Standard_EXPORT void RemoveMechanism(const TDF_Label& theLabel);
+
+ //! 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
+ //! \return created link label
+ Standard_EXPORT TDF_Label AddLink(const TDF_Label& theMechanism,
+ const TDF_LabelSequence& theShapes);
+
+ //! 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);
+
+ //! Checks is the given label a link
+ //! \return the result of check
+ Standard_EXPORT Standard_Boolean IsLink(const TDF_Label& theLink) const;
+
+ //! Sets shapes references for link
+ //! param[in] theLink link to set shapes
+ //! param[in] theShapes all details of link
+ //! \return true in case of success, false otherwise
+ Standard_EXPORT Standard_Boolean SetLink(const TDF_Label& theLink,
+ const TDF_LabelSequence& theShapes);
+
+ //! Sets shape reference for link
+ //! \param[in] theLink link to set shape
+ //! \param[in] theShape singular detail of link
+ //! \return true in case of success, false otherwise
+ Standard_EXPORT Standard_Boolean SetLink(const TDF_Label& theLink,
+ const TDF_Label& theShape);
+
+ //! Removes the given link
+ //! \param[in] theLink link to remove
+ Standard_EXPORT void RemoveLink(const TDF_Label& theLink);
+
+ //! Adds new empty label for joint.
+ //! \param[in] theMechanism parent mechanism
+ //! \return created joint label
+ Standard_EXPORT TDF_Label AddJoint(const TDF_Label& theMechanism);
+
+ //! Adds new label with joint.
+ //! \param[in] theMechanism parent mechanism
+ //! \param[in] theLink1 first link
+ //! \param[in] theLink2 second link
+ //! \return created joint label
+ Standard_EXPORT TDF_Label AddJoint(const TDF_Label& theMechanism,
+ const TDF_Label& theLink1,
+ const TDF_Label& theLink2);
+
+ //! Checks is the given label a joint
+ //! \return the result of check
+ Standard_EXPORT Standard_Boolean IsJoint(const TDF_Label& theJoint) const;
+
+ //! Sets references to links to joint.
+ //! \param[in] theJoint joint to set
+ //! \param[in] theLink1 first link of joint
+ //! \param[in] theLink2 second link of joint
+ //! \return true in case of success, false otherwise
+ Standard_EXPORT Standard_Boolean SetJoint(const TDF_Label& theJoint,
+ const TDF_Label& theLink1,
+ const TDF_Label& theLink2);
+
+ //! Removes the given joint
+ //! \param[in] thejoint joint to remove
+ Standard_EXPORT void RemoveJoint(const TDF_Label& theJoint);
+
+ //! Retrieves all mechanisms labels
+ //! \return mechanisms set
+ Standard_EXPORT TDF_LabelSequence GetMechanisms() const;
+
+ //! Retrieves all links labels of the given mechanism
+ //! \param[in] theMechanism parent mechanism
+ //! \return links set
+ Standard_EXPORT TDF_LabelSequence GetLinks(const TDF_Label& theMechanism) const;
+
+ // Retrieves all joints labels of the given mechanism
+ //! \param[in] theMechanism parent mechanism
+ //! \return joints set
+ Standard_EXPORT TDF_LabelSequence GetJoints(const TDF_Label& theMechanism) const;
+
+ //! Gets references to links of the given joint.
+ //! \param[in] theJoint joint to get
+ //! \param[out] theLink1 first link of joint
+ //! \param[out] theLink2 second link of joint
+ Standard_EXPORT void GetLinksOfJoint(const TDF_Label& theJoint,
+ TDF_Label& theLink1,
+ TDF_Label& theLink2) const;
+
+ //! Gets references to joints of the given link.
+ //! \param[in] theLink link to get
+ //! \return set of joints
+ Standard_EXPORT TDF_LabelSequence GetJointsOfLink(const TDF_Label& theLink) const;
+
+ //! Gets reference shapes of the given link.
+ //! \param[in] theLink link to get
+ //! \return set of shapes
+ Standard_EXPORT TDF_LabelSequence GetRefShapes(const TDF_Label& theLink) const;
+
+ Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
+
+ Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
+
+ Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+
+ Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
+
+ //! Dumps the content of me into the stream
+ Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
+
+ private:
+
+ Standard_EXPORT TDF_Label getRootOfLinks(const TDF_Label& theMechanism) const;
+
+ Standard_EXPORT TDF_Label getRootOfJoints(const TDF_Label& theMechanism) const;
+
+ DEFINE_STANDARD_RTTIEXT(XCAFDoc_KinematicTool, TDF_Attribute)
+
+};
+#endif // _XCAFDoc_KinematicTool_HeaderFile
--- /dev/null
+XCAFKinematics_HighOrderPairObject.cxx
+XCAFKinematics_HighOrderPairObject.hxx
+XCAFKinematics_LowOrderPairObject.cxx
+XCAFKinematics_LowOrderPairObject.hxx
+XCAFKinematics_LowOrderPairObjectWithCoupling.cxx
+XCAFKinematics_LowOrderPairObjectWithCoupling.hxx
+XCAFKinematics_PairObject.cxx
+XCAFKinematics_PairObject.hxx
+XCAFKinematics_PairType.hxx
+XCAFKinematics_PairValueObject.cxx
+XCAFKinematics_PairValueObject.hxx
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <XCAFKinematics_HighOrderPairObject.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XCAFKinematics_HighOrderPairObject, XCAFKinematics_PairObject)
+
+//=======================================================================
+//function : XCAFKinematics_HighOrderPairObject
+//purpose :
+//=======================================================================
+XCAFKinematics_HighOrderPairObject::
+XCAFKinematics_HighOrderPairObject()
+{
+ myLimits = NULL;
+}
+
+//=======================================================================
+//function : XCAFKinematics_HighOrderPairObject
+//purpose :
+//=======================================================================
+XCAFKinematics_HighOrderPairObject::
+XCAFKinematics_HighOrderPairObject(const Handle(XCAFKinematics_HighOrderPairObject)& theObj)
+{
+ SetName(theObj->Name());
+ SetType(theObj->Type());
+ SetFirstTransformation(theObj->FirstTransformation());
+ SetSecondTransformation(theObj->SecondTransformation());
+ myOrientation = theObj->myOrientation;
+ myLimits = theObj->myLimits;
+ myGeom = theObj->myGeom;
+}
+
+//=======================================================================
+//function : SetType
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetType(const XCAFKinematics_PairType theType)
+{
+ XCAFKinematics_PairObject::SetType(theType);
+ switch (theType) {
+ case XCAFKinematics_PairType_PointOnSurface: {
+ myLimits = new TColStd_HArray1OfReal(1, 6);
+ myGeom = NCollection_Array1<Handle(Geom_Geometry)>(1, 1);
+ break;
+ }
+ case XCAFKinematics_PairType_SlidingSurface: {
+ myLimits = new TColStd_HArray1OfReal(1, 2);
+ myGeom = NCollection_Array1<Handle(Geom_Geometry)>(1, 2);
+ break;
+ }
+ case XCAFKinematics_PairType_RollingSurface: {
+ myLimits = new TColStd_HArray1OfReal(1, 2);
+ myGeom = NCollection_Array1<Handle(Geom_Geometry)>(1, 2);
+ break;
+ }
+ case XCAFKinematics_PairType_PointOnPlanarCurve: {
+ myLimits = new TColStd_HArray1OfReal(1, 6);
+ myGeom = NCollection_Array1<Handle(Geom_Geometry)>(1, 1);
+ break;
+ }
+ case XCAFKinematics_PairType_SlidingCurve: {
+ myLimits = NULL;
+ myGeom = NCollection_Array1<Handle(Geom_Geometry)>(1, 2);
+ break;
+ }
+ case XCAFKinematics_PairType_RollingCurve: {
+ myLimits = NULL;
+ myGeom = NCollection_Array1<Handle(Geom_Geometry)>(1, 2);
+ break;
+ }
+ }
+}
+
+//=======================================================================
+//function : SetAllLimits
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetAllLimits(const Handle(TColStd_HArray1OfReal)& theLimits)
+{
+ Standard_Integer aNbLimits = 0;
+ switch (Type()) {
+ case XCAFKinematics_PairType_PointOnSurface: {
+ aNbLimits = 6;
+ break;
+ }
+ case XCAFKinematics_PairType_SlidingSurface: {
+ aNbLimits = 2;
+ break;
+ }
+ case XCAFKinematics_PairType_RollingSurface: {
+ aNbLimits = 2;
+ break;
+ }
+ case XCAFKinematics_PairType_PointOnPlanarCurve: {
+ aNbLimits = 6;
+ break;
+ }
+ }
+
+ if (theLimits->Length() == aNbLimits)
+ myLimits = theLimits;
+}
+
+//=======================================================================
+//function : SetRotationLowLimit
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetRotationLowLimit(const Standard_Real theLimit)
+{
+ if (Type() == XCAFKinematics_PairType_SlidingSurface || Type() == XCAFKinematics_PairType_RollingSurface)
+ myLimits->ChangeValue(1) = theLimit;
+}
+
+//=======================================================================
+//function : RotationLowLimit
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_HighOrderPairObject::RotationLowLimit()
+{
+ if (Type() == XCAFKinematics_PairType_SlidingSurface || Type() == XCAFKinematics_PairType_RollingSurface)
+ return myLimits->Value(1);
+ return 0;
+}
+
+//=======================================================================
+//function : SetRotationUpperLimit
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetRotationUpperLimit(const Standard_Real theLimit)
+{
+ if (Type() == XCAFKinematics_PairType_SlidingSurface || Type() == XCAFKinematics_PairType_RollingSurface)
+ myLimits->ChangeValue(2) = theLimit;
+}
+
+//=======================================================================
+//function : RotationUpperLimit
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_HighOrderPairObject::RotationUpperLimit()
+{
+ if (Type() == XCAFKinematics_PairType_SlidingSurface || Type() == XCAFKinematics_PairType_RollingSurface)
+ return myLimits->Value(2);
+ return 0;
+}
+
+//=======================================================================
+//function : SetLowLimitYaw
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetLowLimitYaw(const Standard_Real theLimit)
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface)
+ myLimits->ChangeValue(1) = theLimit;
+}
+
+//=======================================================================
+//function : LowLimitYaw
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_HighOrderPairObject::LowLimitYaw()
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface)
+ return myLimits->Value(1);
+ return 0;
+}
+
+//=======================================================================
+//function : SetUpperLimitYaw
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetUpperLimitYaw(const Standard_Real theLimit)
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface)
+ myLimits->ChangeValue(2) = theLimit;
+}
+
+//=======================================================================
+//function : UpperLimitYaw
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_HighOrderPairObject::UpperLimitYaw()
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface)
+ return myLimits->Value(2);
+ return 0;
+}
+
+//=======================================================================
+//function : SetLowLimitRoll
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetLowLimitRoll(const Standard_Real theLimit)
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface)
+ myLimits->ChangeValue(3) = theLimit;
+}
+
+//=======================================================================
+//function : LowLimitRoll
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_HighOrderPairObject::LowLimitRoll()
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface)
+ return myLimits->Value(3);
+ return 0;
+}
+
+//=======================================================================
+//function : SetUpperLimitRoll
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetUpperLimitRoll(const Standard_Real theLimit)
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface)
+ myLimits->ChangeValue(4) = theLimit;
+}
+
+//=======================================================================
+//function : UpperLimitRoll
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_HighOrderPairObject::UpperLimitRoll()
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface)
+ return myLimits->Value(4);
+ return 0;
+}
+
+//=======================================================================
+//function : SetLowLimitPitch
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetLowLimitPitch(const Standard_Real theLimit)
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface)
+ myLimits->ChangeValue(5) = theLimit;
+}
+
+//=======================================================================
+//function : LowLimitPitch
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_HighOrderPairObject::LowLimitPitch()
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface)
+ return myLimits->Value(5);
+ return 0;
+}
+
+//=======================================================================
+//function : SetUpperLimitPitch
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetUpperLimitPitch(const Standard_Real theLimit)
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface)
+ myLimits->ChangeValue(6) = theLimit;
+}
+
+//=======================================================================
+//function : UpperLimitPitch
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_HighOrderPairObject::UpperLimitPitch()
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve || Type() == XCAFKinematics_PairType_PointOnSurface)
+ return myLimits->Value(6);
+ return 0;
+}
+
+//=======================================================================
+//function : SetCurve
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetCurve(const Handle(Geom_Curve)& theCurve)
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve)
+ myGeom.ChangeFirst() = theCurve;
+}
+
+//=======================================================================
+//function : Curve
+//purpose :
+//=======================================================================
+Handle(Geom_Curve) XCAFKinematics_HighOrderPairObject::Curve() const
+{
+ if (Type() == XCAFKinematics_PairType_PointOnPlanarCurve)
+ return Handle(Geom_Curve)::DownCast(myGeom.First());
+ return NULL;
+}
+
+//=======================================================================
+//function : SetFirstCurve
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetFirstCurve(const Handle(Geom_Curve)& theCurve)
+{
+ if (Type() == XCAFKinematics_PairType_SlidingCurve || Type() == XCAFKinematics_PairType_RollingCurve)
+ myGeom.ChangeFirst() = theCurve;
+}
+
+//=======================================================================
+//function : FirstCurve
+//purpose :
+//=======================================================================
+Handle(Geom_Curve) XCAFKinematics_HighOrderPairObject::FirstCurve() const
+{
+ if (Type() == XCAFKinematics_PairType_SlidingCurve || Type() == XCAFKinematics_PairType_RollingCurve)
+ return Handle(Geom_Curve)::DownCast(myGeom.First());
+ return NULL;
+}
+
+//=======================================================================
+//function : SetSecondCurve
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetSecondCurve(const Handle(Geom_Curve)& theCurve)
+{
+ if (Type() == XCAFKinematics_PairType_SlidingCurve || Type() == XCAFKinematics_PairType_RollingCurve)
+ myGeom.ChangeLast() = theCurve;
+}
+
+//=======================================================================
+//function : SecondCurve
+//purpose :
+//=======================================================================
+Handle(Geom_Curve) XCAFKinematics_HighOrderPairObject::SecondCurve() const
+{
+ if (Type() == XCAFKinematics_PairType_SlidingCurve || Type() == XCAFKinematics_PairType_RollingCurve)
+ return Handle(Geom_Curve)::DownCast(myGeom.Last());
+ return NULL;
+}
+
+//=======================================================================
+//function : SetSurface
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetSurface(const Handle(Geom_Surface)& theSurface)
+{
+ if (Type() == XCAFKinematics_PairType_PointOnSurface)
+ myGeom.ChangeFirst() = theSurface;
+}
+
+//=======================================================================
+//function : Surface
+//purpose :
+//=======================================================================
+Handle(Geom_Surface) XCAFKinematics_HighOrderPairObject::Surface() const
+{
+ if (Type() == XCAFKinematics_PairType_PointOnSurface)
+ return Handle(Geom_Surface)::DownCast(myGeom.First());
+ return NULL;
+}
+
+//=======================================================================
+//function : SetFirstSurface
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetFirstSurface(const Handle(Geom_Surface)& theSurface)
+{
+ if (Type() == XCAFKinematics_PairType_SlidingSurface || Type() == XCAFKinematics_PairType_RollingSurface)
+ myGeom.ChangeFirst() = theSurface;
+}
+
+//=======================================================================
+//function : FirstSurface
+//purpose :
+//=======================================================================
+Handle(Geom_Surface) XCAFKinematics_HighOrderPairObject::FirstSurface() const
+{
+ if (Type() == XCAFKinematics_PairType_SlidingSurface || Type() == XCAFKinematics_PairType_RollingSurface)
+ return Handle(Geom_Surface)::DownCast(myGeom.First());
+ return NULL;
+}
+
+//=======================================================================
+//function : SetSecondSurface
+//purpose :
+//=======================================================================
+void XCAFKinematics_HighOrderPairObject::SetSecondSurface(const Handle(Geom_Surface)& theSurface)
+{
+ if (Type() == XCAFKinematics_PairType_SlidingSurface || Type() == XCAFKinematics_PairType_RollingSurface)
+ myGeom.ChangeLast() = theSurface;
+}
+
+//=======================================================================
+//function : SecondSurface
+//purpose :
+//=======================================================================
+Handle(Geom_Surface) XCAFKinematics_HighOrderPairObject::SecondSurface() const
+{
+ if (Type() == XCAFKinematics_PairType_SlidingSurface || Type() == XCAFKinematics_PairType_RollingSurface)
+ return Handle(Geom_Surface)::DownCast(myGeom.Last());
+ return NULL;
+}
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#ifndef _XCAFKinematics_HighOrderPairObject_HeaderFile
+#define _XCAFKinematics_HighOrderPairObject_HeaderFile
+
+#include <Geom_Geometry.hxx>
+#include <XCAFKinematics_PairObject.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+
+class Geom_Curve;
+class Geom_Surface;
+
+DEFINE_STANDARD_HANDLE(XCAFKinematics_HighOrderPairObject, XCAFKinematics_PairObject)
+
+//! \class XCAFKinematics_HighOrderPairObject
+//! \brief Object for high order kinematic pairs:
+//! - XCAFKinematics_PairType_PointOnSurface
+//! - XCAFKinematics_PairType_SlidingSurface
+//! - XCAFKinematics_PairType_RollingSurface
+//! - XCAFKinematics_PairType_PointOnPlanarCurve
+//! - XCAFKinematics_PairType_SlidingCurve
+//! - XCAFKinematics_PairType_RollingCurve
+class XCAFKinematics_HighOrderPairObject : public XCAFKinematics_PairObject
+{
+
+public:
+
+ Standard_EXPORT XCAFKinematics_HighOrderPairObject();
+
+ Standard_EXPORT XCAFKinematics_HighOrderPairObject
+ (const Handle(XCAFKinematics_HighOrderPairObject)& theObj);
+
+ Standard_EXPORT void SetType(const XCAFKinematics_PairType theType) Standard_OVERRIDE;
+
+ void SetOrientation(const Standard_Boolean theOrientation)
+ {
+ myOrientation = theOrientation;
+ }
+
+ Standard_Boolean Orientation() const
+ {
+ return myOrientation;
+ }
+
+ Standard_EXPORT void SetAllLimits(const Handle(TColStd_HArray1OfReal)& theLimits) Standard_OVERRIDE;
+
+ Handle(TColStd_HArray1OfReal) GetAllLimits() const Standard_OVERRIDE
+ {
+ return myLimits;
+ }
+
+ //! Sets low limit of rotation attribute (only for SlidingSurface and RollingSurface)
+ //! \param[in] theLimit limit to set
+ Standard_EXPORT void SetRotationLowLimit(const Standard_Real theLimit);
+
+ //! Gets low rotation limit (only for SlidingSurface and RollingSurface)
+ //! \return limit
+ Standard_EXPORT Standard_Real RotationLowLimit();
+
+ //! Sets upper limit of rotation attribute (only for SlidingSurface and RollingSurface)
+ //! \param[in] theLimit limit to set
+ Standard_EXPORT void SetRotationUpperLimit(const Standard_Real theLimit);
+
+ //! Gets upper rotation limit (only for SlidingSurface and RollingSurface)
+ //! \return limit
+ Standard_EXPORT Standard_Real RotationUpperLimit();
+
+ //! Sets low limit of yaw angle (only for PointOnPlanarCurve and PointOnSurface)
+ //! \param[in] theLimit limit to set
+ Standard_EXPORT void SetLowLimitYaw(const Standard_Real theLimit);
+
+ //! Gets low limit of yaw angle (only for PointOnPlanarCurve and PointOnSurface)
+ //! \return limit
+ Standard_EXPORT Standard_Real LowLimitYaw();
+
+ //! Sets upper limit of yaw angle (only for PointOnPlanarCurve and PointOnSurface)
+ //! \param[in] theLimit limit to set
+ Standard_EXPORT void SetUpperLimitYaw(const Standard_Real theLimit);
+
+ //! Gets upper limit of yaw angle (only for PointOnPlanarCurve and PointOnSurface)
+ //! \return limit
+ Standard_EXPORT Standard_Real UpperLimitYaw();
+
+ //! Sets low limit of roll angle (only for PointOnPlanarCurve and PointOnSurface)
+ //! \param[in] theLimit limit to set
+ Standard_EXPORT void SetLowLimitRoll(const Standard_Real theLimit);
+
+ //! Gets low limit of roll angle (only for PointOnPlanarCurve and PointOnSurface)
+ //! \return limit
+ Standard_EXPORT Standard_Real LowLimitRoll();
+
+ //! Sets upper limit of roll angle (only for PointOnPlanarCurve and PointOnSurface)
+ //! \param[in] theLimit limit to set
+ Standard_EXPORT void SetUpperLimitRoll(const Standard_Real theLimit);
+
+ //! Gets upper limit of roll angle (only for PointOnPlanarCurve and PointOnSurface)
+ //! \return limit
+ Standard_EXPORT Standard_Real UpperLimitRoll();
+
+ //! Sets low limit of pitch angle (only for PointOnPlanarCurve and PointOnSurface)
+ //! \param[in] theLimit limit to set
+ Standard_EXPORT void SetLowLimitPitch(const Standard_Real theLimit);
+
+ //! Gets low limit of pitch angle (only for PointOnPlanarCurve and PointOnSurface)
+ //! \return limit
+ Standard_EXPORT Standard_Real LowLimitPitch();
+
+ //! Sets upper limit of pitch angle (only for PointOnPlanarCurve and PointOnSurface)
+ //! \param[in] theLimit limit to set
+ Standard_EXPORT void SetUpperLimitPitch(const Standard_Real theLimit);
+
+ //! Gets upper limit of pitch angle (only for PointOnPlanarCurve and PointOnSurface)
+ //! \return limit
+ Standard_EXPORT Standard_Real UpperLimitPitch();
+
+ //! Sets curve attribute (only for PointOnPlanarCurve)
+ //! \param[in] theCurve curve
+ Standard_EXPORT void SetCurve(const Handle(Geom_Curve)& theCurve);
+
+ //! Gets curve attribute (only for PointOnPlanarCurve)
+ //! \return curve
+ Standard_EXPORT Handle(Geom_Curve) Curve() const;
+
+ //! Sets curve attribute (only for SlidingCurve and RollingCurve)
+ //! \param[in] theCurve curve
+ Standard_EXPORT void SetFirstCurve(const Handle(Geom_Curve)& theCurve);
+
+ //! Gets curve attribute (only for SlidingCurve and RollingCurve)
+ //! \return curve
+ Standard_EXPORT Handle(Geom_Curve) FirstCurve() const;
+
+ //! Sets curve attribute (only for SlidingCurve and RollingCurve)
+ //! \param[in] theCurve curve
+ Standard_EXPORT void SetSecondCurve(const Handle(Geom_Curve)& theCurve);
+
+ //! Gets curve attribute (only for SlidingCurve and RollingCurve)
+ //! \return curve
+ Standard_EXPORT Handle(Geom_Curve) SecondCurve() const;
+
+ //! Sets surface attribute (only for PointOnSurface)
+ //! \param[in] theSurface surface
+ Standard_EXPORT void SetSurface(const Handle(Geom_Surface)& theSurface);
+
+ //! Gets surface attribute (only for PointOnSurface)
+ //! \return curve
+ Standard_EXPORT Handle(Geom_Surface) Surface() const;
+
+ //! Sets surface attribute (only for SlidingSurface and RollingSurface)
+ //! \param[in] theSurface surface
+ Standard_EXPORT void SetFirstSurface(const Handle(Geom_Surface)& theSurface);
+
+ //! Gets surface attribute (only for SlidingSurface and RollingSurface)
+ //! \return surface
+ Standard_EXPORT Handle(Geom_Surface) FirstSurface() const;
+
+ //! Sets surface attribute (only for SlidingSurface and RollingSurface)
+ //! \param[in] theSurface surface
+ Standard_EXPORT void SetSecondSurface(const Handle(Geom_Surface)& theSurface);
+
+ //! Gets surface attribute (only for SlidingSurface and RollingSurface)
+ //! \return surface
+ Standard_EXPORT Handle(Geom_Surface) SecondSurface() const;
+
+ DEFINE_STANDARD_RTTIEXT(XCAFKinematics_HighOrderPairObject, XCAFKinematics_PairObject)
+
+private:
+
+ Standard_Boolean myOrientation; //!< orientation
+ Handle(TColStd_HArray1OfReal) myLimits; //!< array of limits, size depends on type
+ NCollection_Array1<Handle(Geom_Geometry)> myGeom; //!< curve(s) or surface(s) attributes
+
+};
+
+#endif // _XCAFKinematics_HighOrderPairObject_HeaderFile
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <XCAFKinematics_LowOrderPairObject.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XCAFKinematics_LowOrderPairObject, XCAFKinematics_PairObject)
+
+//=======================================================================
+//function : XCAFKinematics_LowOrderPairObject
+//purpose :
+//=======================================================================
+XCAFKinematics_LowOrderPairObject::XCAFKinematics_LowOrderPairObject()
+{
+ 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();
+}
+
+//=======================================================================
+//function : XCAFKinematics_LowOrderPairObject
+//purpose :
+//=======================================================================
+XCAFKinematics_LowOrderPairObject::
+ XCAFKinematics_LowOrderPairObject(const Handle(XCAFKinematics_LowOrderPairObject)& theObj)
+{
+ SetName(theObj->Name());
+ SetType(theObj->Type());
+ SetFirstTransformation(theObj->FirstTransformation());
+ SetSecondTransformation(theObj->SecondTransformation());
+ myMinRotationX = theObj->myMinRotationX;
+ myMaxRotationX = theObj->myMaxRotationX;
+ myMinRotationY = theObj->myMinRotationY;
+ myMaxRotationY = theObj->myMaxRotationY;
+ myMinRotationZ = theObj->myMinRotationZ;
+ myMaxRotationZ = theObj->myMaxRotationZ;
+ myMinTranslationX = theObj->myMinTranslationX;
+ myMaxTranslationX = theObj->myMaxTranslationX;
+ myMinTranslationY = theObj->myMinTranslationY;
+ myMaxTranslationY = theObj->myMaxTranslationY;
+ myMinTranslationZ = theObj->myMinTranslationZ;
+ myMaxTranslationZ = theObj->myMaxTranslationZ;
+}
+
+//=======================================================================
+//function : GetAllLimits
+//purpose :
+//=======================================================================
+Handle(TColStd_HArray1OfReal) XCAFKinematics_LowOrderPairObject::GetAllLimits() const
+{
+ Handle(TColStd_HArray1OfReal) aLimitArray = new TColStd_HArray1OfReal(1, 12);
+ aLimitArray->ChangeValue(1) = myMinRotationX;
+ aLimitArray->ChangeValue(2) = myMaxRotationX;
+ aLimitArray->ChangeValue(3) = myMinRotationY;
+ aLimitArray->ChangeValue(4) = myMaxRotationY;
+ aLimitArray->ChangeValue(5) = myMinRotationZ;
+ aLimitArray->ChangeValue(6) = myMaxRotationZ;
+ aLimitArray->ChangeValue(7) = myMinTranslationX;
+ aLimitArray->ChangeValue(8) = myMaxTranslationX;
+ aLimitArray->ChangeValue(9) = myMinTranslationY;
+ aLimitArray->ChangeValue(10) = myMaxTranslationY;
+ aLimitArray->ChangeValue(11) = myMinTranslationZ;
+ aLimitArray->ChangeValue(12) = myMaxTranslationZ;
+ return aLimitArray;
+}
+
+//=======================================================================
+//function : GetAllLimits
+//purpose :
+//=======================================================================
+void XCAFKinematics_LowOrderPairObject::SetAllLimits(const Handle(TColStd_HArray1OfReal)& theLimits)
+{
+ if (theLimits->Length() != 12)
+ return;
+ myMinRotationX = theLimits->Value(1);
+ myMaxRotationX = theLimits->Value(2);
+ myMinRotationY = theLimits->Value(3);
+ myMaxRotationY = theLimits->Value(4);
+ myMinRotationZ = theLimits->Value(5);
+ myMaxRotationZ = theLimits->Value(6);
+ myMinTranslationX = theLimits->Value(7);
+ myMaxTranslationX = theLimits->Value(8);
+ myMinTranslationY = theLimits->Value(9);
+ myMaxTranslationY = theLimits->Value(10);
+ myMinTranslationZ = theLimits->Value(11);
+ myMaxTranslationZ = theLimits->Value(12);
+}
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#ifndef _XCAFKinematics_LowOrderPairObject_HeaderFile
+#define _XCAFKinematics_LowOrderPairObject_HeaderFile
+
+#include <XCAFKinematics_PairObject.hxx>
+
+class TColStd_HArray1OfReal;
+
+DEFINE_STANDARD_HANDLE(XCAFKinematics_LowOrderPairObject, XCAFKinematics_PairObject)
+
+//! \class XCAFKinematics_LowOrderPairObject
+//! \brief Object for low order kinematic pairs:
+//! - XCAFKinematics_PairType_FullyConstrained
+//! - XCAFKinematics_PairType_Revolute
+//! - XCAFKinematics_PairType_Prismatic
+//! - XCAFKinematics_PairType_Cylindrical
+//! - XCAFKinematics_PairType_Universal
+//! - XCAFKinematics_PairType_Homokinetic
+//! - XCAFKinematics_PairType_SphericalWithPin
+//! - XCAFKinematics_PairType_Spherical
+//! - XCAFKinematics_PairType_Planar
+//! - XCAFKinematics_PairType_Unconstrained
+//! Not all limits are used for each pair, if less than 3 translation/rotation
+//! limits is used values should be specified in alphabetical order.
+class XCAFKinematics_LowOrderPairObject : public XCAFKinematics_PairObject
+{
+
+public:
+
+ Standard_EXPORT XCAFKinematics_LowOrderPairObject();
+
+ Standard_EXPORT XCAFKinematics_LowOrderPairObject
+ (const Handle(XCAFKinematics_LowOrderPairObject)& theObj);
+
+ // X rotation limits
+
+ void SetMinRotationX(const Standard_Real theLimit)
+ {
+ myMinRotationX = theLimit;
+ }
+
+ Standard_Real MinRotationX() const
+ {
+ return myMinRotationX;
+ }
+
+ void SetMaxRotationX(const Standard_Real theLimit)
+ {
+ myMaxRotationX = theLimit;
+ }
+
+ Standard_Real MaxRotationX() const
+ {
+ return myMaxRotationX;
+ }
+
+ // Y rotation limits
+
+ void SetMinRotationY(const Standard_Real theLimit)
+ {
+ myMinRotationY = theLimit;
+ }
+
+ Standard_Real MinRotationY() const
+ {
+ return myMinRotationY;
+ }
+
+ void SetMaxRotationY(const Standard_Real theLimit)
+ {
+ myMaxRotationY = theLimit;
+ }
+
+ Standard_Real MaxRotationY() const
+ {
+ return myMaxRotationY;
+ }
+
+ // Z rotation limits
+
+ void SetMinRotationZ(const Standard_Real theLimit)
+ {
+ myMinRotationZ = theLimit;
+ }
+
+ Standard_Real MinRotationZ() const
+ {
+ return myMinRotationZ;
+ }
+
+ void SetMaxRotationZ(const Standard_Real theLimit)
+ {
+ myMaxRotationZ = theLimit;
+ }
+
+ Standard_Real MaxRotationZ() const
+ {
+ return myMaxRotationZ;
+ }
+
+ // X translation limits
+
+ void SetMinTranslationX(const Standard_Real theLimit)
+ {
+ myMinTranslationX = theLimit;
+ }
+
+ Standard_Real MinTranslationX() const
+ {
+ return myMinTranslationX;
+ }
+
+ void SetMaxTranslationX(const Standard_Real theLimit)
+ {
+ myMaxTranslationX = theLimit;
+ }
+
+ Standard_Real MaxTranslationX() const
+ {
+ return myMaxTranslationX;
+ }
+
+ // Y translation limits
+
+ void SetMinTranslationY(const Standard_Real theLimit)
+ {
+ myMinTranslationY = theLimit;
+ }
+
+ Standard_Real MinTranslationY() const
+ {
+ return myMinTranslationY;
+ }
+
+ void SetMaxTranslationY(const Standard_Real theLimit)
+ {
+ myMaxTranslationY = theLimit;
+ }
+
+ Standard_Real MaxTranslationY() const
+ {
+ return myMaxTranslationY;
+ }
+
+ // Z translation limits
+
+ void SetMinTranslationZ(const Standard_Real theLimit)
+ {
+ myMinTranslationZ = theLimit;
+ }
+
+ Standard_Real MinTranslationZ() const
+ {
+ return myMinTranslationZ;
+ }
+
+ void SetMaxTranslationZ(const Standard_Real theLimit)
+ {
+ myMaxTranslationZ = theLimit;
+ }
+
+ Standard_Real MaxTranslationZ() const
+ {
+ return myMaxTranslationZ;
+ }
+
+ void SetSkewAngle(const Standard_Real theAngle)
+ {
+ if (Type() == XCAFKinematics_PairType_Universal || XCAFKinematics_PairType_Homokinetic)
+ mySkewAngle = theAngle;
+ }
+
+ Standard_Real SkewAngle() const
+ {
+ if (Type() == XCAFKinematics_PairType_Universal || XCAFKinematics_PairType_Homokinetic)
+ return mySkewAngle;
+ else return 0;
+ }
+
+ //! Creates array with all limits
+ //! \return created array
+ Standard_EXPORT Handle(TColStd_HArray1OfReal) GetAllLimits() const Standard_OVERRIDE;
+
+ Standard_EXPORT void SetAllLimits(const Handle(TColStd_HArray1OfReal)& theLimits) Standard_OVERRIDE;
+
+ DEFINE_STANDARD_RTTIEXT(XCAFKinematics_LowOrderPairObject, XCAFKinematics_PairObject)
+
+private:
+
+ 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 mySkewAngle; //!< param for universal/homokinetic pair
+
+};
+
+#endif // _XCAFKinematics_LowOrderPairObject_HeaderFile
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <XCAFKinematics_LowOrderPairObjectWithCoupling.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XCAFKinematics_LowOrderPairObjectWithCoupling, XCAFKinematics_PairObject)
+
+//=======================================================================
+//function : XCAFKinematics_LowOrderPairObjectWithCoupling
+//purpose :
+//=======================================================================
+XCAFKinematics_LowOrderPairObjectWithCoupling::
+ XCAFKinematics_LowOrderPairObjectWithCoupling()
+{
+ myLowLimit = -Precision::Infinite();
+ myUpperLimit = Precision::Infinite();
+ myParams = NULL;
+}
+
+//=======================================================================
+//function : XCAFKinematics_LowOrderPairObjectWithCoupling
+//purpose :
+//=======================================================================
+XCAFKinematics_LowOrderPairObjectWithCoupling::
+ XCAFKinematics_LowOrderPairObjectWithCoupling(const Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)& theObj)
+{
+ SetName(theObj->Name());
+ SetType(theObj->Type());
+ SetFirstTransformation(theObj->FirstTransformation());
+ SetSecondTransformation(theObj->SecondTransformation());
+ myLowLimit = theObj->LowLimit();
+ myUpperLimit = theObj->UpperLimit();
+ myParams = theObj->GetAllParams();
+}
+
+//=======================================================================
+//function : SetType
+//purpose :
+//=======================================================================
+void XCAFKinematics_LowOrderPairObjectWithCoupling::SetType(const XCAFKinematics_PairType theType)
+{
+ XCAFKinematics_PairObject::SetType(theType);
+ if (theType == XCAFKinematics_PairType_Gear)
+ myParams = new TColStd_HArray1OfReal(1, 5);
+ else
+ myParams = new TColStd_HArray1OfReal(1, 1);
+}
+
+//=======================================================================
+//function : GetAllLimits
+//purpose :
+//=======================================================================
+Handle(TColStd_HArray1OfReal) XCAFKinematics_LowOrderPairObjectWithCoupling::GetAllLimits() const
+{
+ Handle(TColStd_HArray1OfReal) aLimitArray = new TColStd_HArray1OfReal(1, 2);
+ aLimitArray->ChangeValue(1) = myLowLimit;
+ aLimitArray->ChangeValue(2) = myUpperLimit;
+ return aLimitArray;
+}
+
+//=======================================================================
+//function : SetPitch
+//purpose :
+//=======================================================================
+void XCAFKinematics_LowOrderPairObjectWithCoupling::SetPitch(const Standard_Real thePitch)
+{
+ if (Type() == XCAFKinematics_PairType_Screw)
+ myParams->ChangeFirst() = thePitch;
+}
+
+//=======================================================================
+//function : Pitch
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_LowOrderPairObjectWithCoupling::Pitch() const
+{
+ if (Type() == XCAFKinematics_PairType_Screw)
+ return myParams->First();
+ return 0;
+}
+
+//=======================================================================
+//function : SetPinionRadius
+//purpose :
+//=======================================================================
+void XCAFKinematics_LowOrderPairObjectWithCoupling::SetPinionRadius(const Standard_Real theRadius)
+{
+ if (Type() == XCAFKinematics_PairType_RackAndPinion)
+ myParams->ChangeFirst() = theRadius;
+}
+
+//=======================================================================
+//function : PinionRadius
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_LowOrderPairObjectWithCoupling::PinionRadius() const
+{
+ if (Type() == XCAFKinematics_PairType_RackAndPinion)
+ return myParams->First();
+ return 0;
+}
+
+//=======================================================================
+//function : SetRadiusFirstLink
+//purpose :
+//=======================================================================
+void XCAFKinematics_LowOrderPairObjectWithCoupling::SetRadiusFirstLink(const Standard_Real theRadius)
+{
+ if (Type() == XCAFKinematics_PairType_Gear)
+ myParams->ChangeFirst() = theRadius;
+}
+
+//=======================================================================
+//function : RadiusFirstLink
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_LowOrderPairObjectWithCoupling::RadiusFirstLink() const
+{
+ if (Type() == XCAFKinematics_PairType_Gear)
+ return myParams->First();
+ return 0;
+}
+
+//=======================================================================
+//function : SetRadiusSecondLink
+//purpose :
+//=======================================================================
+void XCAFKinematics_LowOrderPairObjectWithCoupling::SetRadiusSecondLink(const Standard_Real theRadius)
+{
+ if (Type() == XCAFKinematics_PairType_Gear)
+ myParams->ChangeValue(2) = theRadius;
+}
+
+//=======================================================================
+//function : RadiusSecondLink
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_LowOrderPairObjectWithCoupling::RadiusSecondLink() const
+{
+ if (Type() == XCAFKinematics_PairType_Gear)
+ return myParams->Value(2);
+ return 0;
+}
+
+//=======================================================================
+//function : SetBevel
+//purpose :
+//=======================================================================
+void XCAFKinematics_LowOrderPairObjectWithCoupling::SetBevel(const Standard_Real theBevel)
+{
+ if (Type() == XCAFKinematics_PairType_Gear)
+ myParams->ChangeValue(3) = theBevel;
+}
+
+//=======================================================================
+//function : Bevel
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_LowOrderPairObjectWithCoupling::Bevel() const
+{
+ if (Type() == XCAFKinematics_PairType_Gear)
+ return myParams->Value(3);
+ return 0;
+}
+
+//=======================================================================
+//function : SetHelicalAngle
+//purpose :
+//=======================================================================
+void XCAFKinematics_LowOrderPairObjectWithCoupling::SetHelicalAngle(const Standard_Real theAngle)
+{
+ if (Type() == XCAFKinematics_PairType_Gear)
+ myParams->ChangeValue(4) = theAngle;
+}
+
+//=======================================================================
+//function : HelicalAngle
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_LowOrderPairObjectWithCoupling::HelicalAngle() const
+{
+ if (Type() == XCAFKinematics_PairType_Gear)
+ return myParams->Value(4);
+ return 0;
+}
+
+//=======================================================================
+//function : SetGearRatio
+//purpose :
+//=======================================================================
+void XCAFKinematics_LowOrderPairObjectWithCoupling::SetGearRatio(const Standard_Real theGearRatio)
+{
+ if (Type() == XCAFKinematics_PairType_Gear)
+ myParams->ChangeValue(5) = theGearRatio;
+}
+
+//=======================================================================
+//function : GearRatio
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_LowOrderPairObjectWithCoupling::GearRatio() const
+{
+ if (Type() == XCAFKinematics_PairType_Gear)
+ return myParams->Value(5);
+ return 0;
+}
+
+//=======================================================================
+//function : SetAllParams
+//purpose :
+//=======================================================================
+void XCAFKinematics_LowOrderPairObjectWithCoupling::SetAllParams(const Handle(TColStd_HArray1OfReal)& theParams)
+{
+ if (theParams->Length() == myParams->Length())
+ myParams = theParams;
+}
+
+//=======================================================================
+//function : SetAllLimits
+//purpose :
+//=======================================================================
+void XCAFKinematics_LowOrderPairObjectWithCoupling::SetAllLimits(const Handle(TColStd_HArray1OfReal)& theLimits)
+{
+ if (theLimits->Length() == 2)
+ {
+ myLowLimit = theLimits->Value(1);
+ myUpperLimit = theLimits->Value(2);
+ }
+}
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#ifndef _XCAFKinematics_LowOrderPairObjectWithCoupling_HeaderFile
+#define _XCAFKinematics_LowOrderPairObjectWithCoupling_HeaderFile
+
+#include <XCAFKinematics_PairObject.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+
+DEFINE_STANDARD_HANDLE(XCAFKinematics_LowOrderPairObjectWithCoupling, XCAFKinematics_PairObject)
+
+//! \class XCAFKinematics_LowOrderPairObjectWithCoupling
+//! \brief Object for low order kinematic pairs with motion coupling:
+//! - XCAFKinematics_PairType_Screw
+//! - XCAFKinematics_PairType_RackAndPinion
+//! - XCAFKinematics_PairType_Gear
+class XCAFKinematics_LowOrderPairObjectWithCoupling : public XCAFKinematics_PairObject
+{
+
+public:
+
+ Standard_EXPORT XCAFKinematics_LowOrderPairObjectWithCoupling();
+
+ Standard_EXPORT XCAFKinematics_LowOrderPairObjectWithCoupling
+ (const Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)& theObj);
+
+ Standard_EXPORT void SetType(const XCAFKinematics_PairType theType) Standard_OVERRIDE;
+
+ void SetLowLimit(const Standard_Real theLimit)
+ {
+ myLowLimit = theLimit;
+ }
+
+ Standard_Real LowLimit() const
+ {
+ return myLowLimit;
+ }
+
+ void SetUpperLimit(const Standard_Real theLimit)
+ {
+ myUpperLimit = theLimit;
+ }
+
+ Standard_Real UpperLimit() const
+ {
+ return myUpperLimit;
+ }
+
+ //! Creates array with all limits
+ //! \return created array
+ Standard_EXPORT Handle(TColStd_HArray1OfReal) GetAllLimits() const Standard_OVERRIDE;
+
+ //! Sets pitch parameter (only for Screw)
+ //! \param[in] thePitch parameter value
+ Standard_EXPORT void SetPitch(const Standard_Real thePitch);
+
+ //! Gets pitch parameter (only for Screw)
+ //! \return parameter value
+ Standard_EXPORT Standard_Real Pitch() const;
+
+ //! Sets pinion radius parameter (only for RackAndPinion)
+ //! \param[in] theRadius parameter value
+ Standard_EXPORT void SetPinionRadius(const Standard_Real theRadius);
+
+ //! Gets pinion radius parameter (only for RackAndPinion)
+ //! \return parameter value
+ Standard_EXPORT Standard_Real PinionRadius() const;
+
+ //! Sets first link radius parameter (only for Gear)
+ //! \param[in] theRadius parameter value
+ Standard_EXPORT void SetRadiusFirstLink(const Standard_Real theRadius);
+
+ //! Gets first link radius parameter (only for Gear)
+ //! \return parameter value
+ Standard_EXPORT Standard_Real RadiusFirstLink() const;
+
+ //! Sets second link radius parameter (only for Gear)
+ //! \param[in] theRadius parameter value
+ Standard_EXPORT void SetRadiusSecondLink(const Standard_Real theRadius);
+
+ //! Gets second link radius parameter (only for Gear)
+ //! \return parameter value
+ Standard_EXPORT Standard_Real RadiusSecondLink() const;
+
+ //! Sets bevel parameter (only for Gear)
+ //! \param[in] theBevel parameter value
+ Standard_EXPORT void SetBevel(const Standard_Real theBevel);
+
+ //! Gets bevel parameter (only for Gear)
+ //! \return parameter value
+ Standard_EXPORT Standard_Real Bevel() const;
+
+ //! Sets helical angle parameter (only for Gear)
+ //! \param[in] theAngle parameter value
+ Standard_EXPORT void SetHelicalAngle(const Standard_Real theAngle);
+
+ //! Gets helical angle parameter (only for Gear)
+ //! \return parameter value
+ Standard_EXPORT Standard_Real HelicalAngle() const;
+
+ //! Sets gear ratio parameter (only for Gear)
+ //! \param[in] theGearRatio parameter value
+ Standard_EXPORT void SetGearRatio(const Standard_Real theGearRatio);
+
+ //! Gets gear ratio parameter (only for Gear)
+ //! \return parameter value
+ Standard_EXPORT Standard_Real GearRatio() const;
+
+ //! Sets all parameters as an array
+ //! \param[in] theParams array of parameters
+ Standard_EXPORT void SetAllParams(const Handle(TColStd_HArray1OfReal)& theParams);
+
+ Standard_EXPORT Handle(TColStd_HArray1OfReal) GetAllParams() const
+ {
+ return myParams;
+ }
+
+ Standard_EXPORT void SetAllLimits(const Handle(TColStd_HArray1OfReal)& theLimits) Standard_OVERRIDE;
+
+ DEFINE_STANDARD_RTTIEXT(XCAFKinematics_LowOrderPairObjectWithCoupling, XCAFKinematics_PairObject)
+
+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
+
+};
+
+#endif // _XCAFKinematics_LowOrderPairObjectWithCoupling_HeaderFile
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <XCAFKinematics_PairObject.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XCAFKinematics_PairObject, Standard_Transient)
+
+//=======================================================================
+//function : XCAFKinematics_PairObject
+//purpose :
+//=======================================================================
+XCAFKinematics_PairObject::XCAFKinematics_PairObject()
+{
+}
+
+//=======================================================================
+//function : XCAFKinematics_PairObject
+//purpose :
+//=======================================================================
+XCAFKinematics_PairObject::XCAFKinematics_PairObject(const Handle(XCAFKinematics_PairObject)& theObj)
+{
+ myName = theObj->myName;
+ myType = theObj->myType;
+ myTrsf1 = theObj-> myTrsf1;
+ myTrsf2 = theObj-> myTrsf2;
+}
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#ifndef _XCAFKinematics_PairObject_HeaderFile
+#define _XCAFKinematics_PairObject_HeaderFile
+
+#include <gp_Ax3.hxx>
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+#include <XCAFKinematics_PairType.hxx>
+
+DEFINE_STANDARD_HANDLE(XCAFKinematics_PairObject, Standard_Transient)
+
+//! \class XCAFKinematics_PairObject
+//! \brief Main parent object for kinematic pairs
+class XCAFKinematics_PairObject : public Standard_Transient
+{
+
+public:
+
+ Standard_EXPORT XCAFKinematics_PairObject();
+
+ Standard_EXPORT XCAFKinematics_PairObject(const Handle(XCAFKinematics_PairObject)& theObj);
+
+ void SetName(const TCollection_AsciiString& theName)
+ {
+ myName = theName;
+ }
+
+ TCollection_AsciiString Name() const
+ {
+ return myName;
+ }
+
+ void virtual SetType(const XCAFKinematics_PairType theType)
+ {
+ myType = theType;
+ }
+
+ XCAFKinematics_PairType Type() const
+ {
+ return myType;
+ }
+
+ void SetFirstTransformation(const gp_Ax3& theTrsf)
+ {
+ myTrsf1 = theTrsf;
+ }
+
+ gp_Ax3 FirstTransformation() const
+ {
+ return myTrsf1;
+ }
+
+ void SetSecondTransformation(const gp_Ax3& theTrsf)
+ {
+ myTrsf2 = theTrsf;
+ }
+
+ gp_Ax3 SecondTransformation() const
+ {
+ return myTrsf2;
+ }
+
+ Standard_EXPORT virtual void SetAllLimits(const Handle(TColStd_HArray1OfReal)& /*theLimits*/) {};
+
+ Standard_EXPORT virtual Handle(TColStd_HArray1OfReal) GetAllLimits() const
+ {
+ return new TColStd_HArray1OfReal();
+ }
+
+ DEFINE_STANDARD_RTTIEXT(XCAFKinematics_PairObject, Standard_Transient)
+
+private:
+
+ TCollection_AsciiString myName; //!< name of kinematic pair
+ XCAFKinematics_PairType myType; //!< type of kinematic pair
+ gp_Ax3 myTrsf1; //!< first transformation element
+ gp_Ax3 myTrsf2; //!< second transformation element
+};
+
+#endif // _XCAFKinematics_PairObject_HeaderFile
--- /dev/null
+// Created on: 2020-03-16
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#ifndef _XCAFKinematics_PairType_HeaderFile
+#define _XCAFKinematics_PairType_HeaderFile
+
+//! Defines types of kinemtic pairs
+enum XCAFKinematics_PairType
+{
+ // Auxiliary type
+ XCAFKinematics_PairType_NoType,
+
+ // Low order pairs
+ XCAFKinematics_PairType_FullyConstrained, // no DOF
+ XCAFKinematics_PairType_Revolute, // one rotation DOF
+ XCAFKinematics_PairType_Prismatic, // one translation DOF
+ XCAFKinematics_PairType_Cylindrical, // one rotation and one translation DOF
+ XCAFKinematics_PairType_Universal, // two rotation DOF
+ XCAFKinematics_PairType_Homokinetic, // two uniform rotation DOF
+ XCAFKinematics_PairType_SphericalWithPin, // two rotation DOF
+ XCAFKinematics_PairType_Spherical, // three rotation DOF
+ XCAFKinematics_PairType_Planar, // one rotation and two translation DOF
+ XCAFKinematics_PairType_Unconstrained, // three rotation and three translation DOF
+
+ // Low order pairs with motion coupling
+ XCAFKinematics_PairType_Screw,
+ XCAFKinematics_PairType_RackAndPinion,
+ XCAFKinematics_PairType_Gear,
+
+ // High order pairs
+ XCAFKinematics_PairType_PointOnSurface,
+ XCAFKinematics_PairType_SlidingSurface,
+ XCAFKinematics_PairType_RollingSurface,
+ XCAFKinematics_PairType_PointOnPlanarCurve,
+ XCAFKinematics_PairType_SlidingCurve,
+ XCAFKinematics_PairType_RollingCurve
+};
+
+#endif // _XCAFKinematics_PairType_HeaderFile
--- /dev/null
+// Created on: 2020-03-27
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <gp_Ax2.hxx>
+#include <XCAFKinematics_PairValueObject.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XCAFKinematics_PairValueObject, Standard_Transient)
+
+//=======================================================================
+//function : XCAFKinematics_PairValueObject
+//purpose :
+//=======================================================================
+XCAFKinematics_PairValueObject::XCAFKinematics_PairValueObject()
+{
+ myValues = NULL;
+}
+
+//=======================================================================
+//function : XCAFKinematics_PairValueObject
+//purpose :
+//=======================================================================
+XCAFKinematics_PairValueObject::XCAFKinematics_PairValueObject(const Handle(XCAFKinematics_PairValueObject)& theObj)
+{
+ myType = theObj->myType;
+ myValues = theObj->myValues;
+}
+
+//=======================================================================
+//function : SetType
+//purpose :
+//=======================================================================
+void XCAFKinematics_PairValueObject::SetType(const XCAFKinematics_PairType theType)
+{
+ myType = theType;
+ Standard_Integer aNbParams = 0;
+ switch (myType) {
+ case XCAFKinematics_PairType_Revolute:
+ aNbParams = 1;
+ break;
+ case XCAFKinematics_PairType_Prismatic:
+ aNbParams = 1;
+ break;
+ case XCAFKinematics_PairType_Cylindrical:
+ aNbParams = 2;
+ break;
+ case XCAFKinematics_PairType_Universal:
+ case XCAFKinematics_PairType_Homokinetic:
+ aNbParams = 2;
+ break;
+ case XCAFKinematics_PairType_SphericalWithPin:
+ case XCAFKinematics_PairType_Spherical:
+ aNbParams = 3;
+ break;
+ case XCAFKinematics_PairType_Planar:
+ aNbParams = 3;
+ break;
+ case XCAFKinematics_PairType_Unconstrained:
+ aNbParams = 9;
+ break;
+ case XCAFKinematics_PairType_Screw:
+ aNbParams = 1;
+ break;
+ case XCAFKinematics_PairType_RackAndPinion:
+ aNbParams = 1;
+ break;
+ case XCAFKinematics_PairType_Gear:
+ aNbParams = 1;
+ break;
+ case XCAFKinematics_PairType_PointOnSurface:
+ aNbParams = 5;
+ break;
+ case XCAFKinematics_PairType_SlidingSurface:
+ aNbParams = 5;
+ break;
+ case XCAFKinematics_PairType_RollingSurface:
+ aNbParams = 3;
+ break;
+ case XCAFKinematics_PairType_PointOnPlanarCurve:
+ aNbParams = 4;
+ break;
+ case XCAFKinematics_PairType_SlidingCurve:
+ aNbParams = 2;
+ break;
+ case XCAFKinematics_PairType_RollingCurve:
+ aNbParams = 1;
+ break;
+ }
+
+ if (aNbParams == 0)
+ myValues = NULL;
+ else
+ myValues = new TColStd_HArray1OfReal(1, aNbParams);
+}
+
+//=======================================================================
+//function : SetFirstRotaion
+//purpose :
+//=======================================================================
+void XCAFKinematics_PairValueObject::SetFirstRotation(const Standard_Real theRotation)
+{
+ switch (myType) {
+ case XCAFKinematics_PairType_Revolute:
+ myValues->ChangeValue(1) = theRotation;
+ break;
+ case XCAFKinematics_PairType_Cylindrical:
+ myValues->ChangeValue(1) = theRotation;
+ break;
+ case XCAFKinematics_PairType_Universal:
+ case XCAFKinematics_PairType_Homokinetic:
+ myValues->ChangeValue(1) = theRotation;
+ break;
+ case XCAFKinematics_PairType_Planar:
+ myValues->ChangeValue(1) = theRotation;
+ break;
+ case XCAFKinematics_PairType_Screw:
+ myValues->ChangeValue(1) = theRotation;
+ break;
+ case XCAFKinematics_PairType_Gear:
+ myValues->ChangeValue(1) = theRotation;
+ break;
+ case XCAFKinematics_PairType_SlidingSurface:
+ myValues->ChangeValue(1) = theRotation;
+ break;
+ case XCAFKinematics_PairType_RollingSurface:
+ myValues->ChangeValue(1) = theRotation;
+ break;
+ }
+}
+
+//=======================================================================
+//function : GetFirstRotaion
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_PairValueObject::GetFirstRotation() const
+{
+ switch (myType) {
+ case XCAFKinematics_PairType_Revolute:
+ return myValues->Value(1);
+ case XCAFKinematics_PairType_Cylindrical:
+ return myValues->Value(1);
+ case XCAFKinematics_PairType_Universal:
+ case XCAFKinematics_PairType_Homokinetic:
+ return myValues->Value(1);
+ case XCAFKinematics_PairType_Planar:
+ return myValues->Value(1);
+ case XCAFKinematics_PairType_Screw:
+ return myValues->Value(1);
+ case XCAFKinematics_PairType_Gear:
+ return myValues->Value(1);
+ case XCAFKinematics_PairType_SlidingSurface:
+ return myValues->Value(1);
+ case XCAFKinematics_PairType_RollingSurface:
+ return myValues->Value(1);
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : SetSecondRotaion
+//purpose :
+//=======================================================================
+void XCAFKinematics_PairValueObject::SetSecondRotation(const Standard_Real theRotation)
+{
+ switch (myType) {
+ case XCAFKinematics_PairType_Universal:
+ case XCAFKinematics_PairType_Homokinetic:
+ myValues->ChangeValue(2) = theRotation;
+ break;
+ }
+}
+
+//=======================================================================
+//function : GetSecondRotaion
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_PairValueObject::GetSecondRotation() const
+{
+ switch (myType) {
+ case XCAFKinematics_PairType_Universal:
+ case XCAFKinematics_PairType_Homokinetic:
+ return myValues->Value(2);
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : SetFirstTranslation
+//purpose :
+//=======================================================================
+void XCAFKinematics_PairValueObject::SetFirstTranslation(const Standard_Real theTranslation)
+{
+ switch (myType) {
+ case XCAFKinematics_PairType_Prismatic:
+ myValues->ChangeValue(1) = theTranslation;
+ break;
+ case XCAFKinematics_PairType_Cylindrical:
+ myValues->ChangeValue(2) = theTranslation;
+ break;
+ case XCAFKinematics_PairType_Planar:
+ myValues->ChangeValue(2) = theTranslation;
+ break;
+ case XCAFKinematics_PairType_RackAndPinion:
+ myValues->ChangeValue(1) = theTranslation;
+ break;
+ }
+}
+
+//=======================================================================
+//function : GetFirstTranslation
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_PairValueObject::GetFirstTranslation() const
+{
+ switch (myType) {
+ case XCAFKinematics_PairType_Prismatic:
+ return myValues->Value(1);
+ case XCAFKinematics_PairType_Cylindrical:
+ return myValues->Value(2);
+ case XCAFKinematics_PairType_Planar:
+ return myValues->Value(2);
+ case XCAFKinematics_PairType_RackAndPinion:
+ return myValues->Value(1);
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : SetSecondTranslation
+//purpose :
+//=======================================================================
+void XCAFKinematics_PairValueObject::SetSecondTranslation(const Standard_Real theTranslation)
+{
+ if (myType == XCAFKinematics_PairType_Planar)
+ myValues->ChangeValue(3) = theTranslation;
+}
+
+//=======================================================================
+//function : GetSecondTranslation
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_PairValueObject::GetSecondTranslation() const
+{
+ if (myType == XCAFKinematics_PairType_Planar)
+ return myValues->Value(3);
+ return 0;
+}
+
+//=======================================================================
+//function : SetFirstPointOnSurface
+//purpose :
+//=======================================================================
+void XCAFKinematics_PairValueObject::SetFirstPointOnSurface(const Standard_Real theU,
+ const Standard_Real theV)
+{
+ switch (myType) {
+ case XCAFKinematics_PairType_PointOnSurface:
+ myValues->ChangeValue(1) = theU;
+ myValues->ChangeValue(2) = theV;
+ break;
+ case XCAFKinematics_PairType_SlidingSurface:
+ myValues->ChangeValue(2) = theU;
+ myValues->ChangeValue(3) = theV;
+ break;
+ case XCAFKinematics_PairType_RollingSurface:
+ myValues->ChangeValue(2) = theU;
+ myValues->ChangeValue(3) = theV;
+ break;
+ }
+}
+
+//=======================================================================
+//function : GetFirstPointOnSurface
+//purpose :
+//=======================================================================
+Standard_Boolean XCAFKinematics_PairValueObject::GetFirstPointOnSurface(Standard_Real& theU,
+ Standard_Real& theV) const
+{
+ switch (myType) {
+ case XCAFKinematics_PairType_PointOnSurface:
+ theU = myValues->Value(1);
+ theV = myValues->Value(2);
+ return Standard_True;
+ case XCAFKinematics_PairType_SlidingSurface:
+ theU = myValues->Value(2);
+ theV = myValues->Value(3);
+ return Standard_True;
+ case XCAFKinematics_PairType_RollingSurface:
+ theU = myValues->Value(2);
+ theV = myValues->Value(3);
+ return Standard_True;
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : SetSecondPointOnSurface
+//purpose :
+//=======================================================================
+void XCAFKinematics_PairValueObject::SetSecondPointOnSurface(const Standard_Real theU,
+ const Standard_Real theV)
+{
+ if (myType != XCAFKinematics_PairType_SlidingSurface)
+ return;
+ myValues->ChangeValue(4) = theU;
+ myValues->ChangeValue(5) = theV;
+}
+
+//=======================================================================
+//function : GetSecondPointOnSurface
+//purpose :
+//=======================================================================
+Standard_Boolean XCAFKinematics_PairValueObject::GetSecondPointOnSurface(Standard_Real& theU,
+ Standard_Real& theV) const
+{
+ if (myType != XCAFKinematics_PairType_SlidingSurface)
+ return Standard_False;
+ theU = myValues->Value(4);
+ theV = myValues->Value(5);
+ return Standard_True;
+}
+
+//=======================================================================
+//function : SetFirstPointOnCurve
+//purpose :
+//=======================================================================
+void XCAFKinematics_PairValueObject::SetFirstPointOnCurve(const Standard_Real theT)
+{
+ switch (myType) {
+ case XCAFKinematics_PairType_PointOnPlanarCurve:
+ myValues->ChangeValue(1) = theT;
+ break;
+ case XCAFKinematics_PairType_SlidingCurve:
+ myValues->ChangeValue(1) = theT;
+ break;
+ case XCAFKinematics_PairType_RollingCurve:
+ myValues->ChangeValue(1) = theT;
+ break;
+ }
+}
+
+//=======================================================================
+//function : GetFirstPointOnCurve
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_PairValueObject::GetFirstPointOnCurve() const
+{
+ switch (myType) {
+ case XCAFKinematics_PairType_PointOnPlanarCurve:
+ return myValues->Value(1);
+ case XCAFKinematics_PairType_SlidingCurve:
+ return myValues->Value(1);
+ case XCAFKinematics_PairType_RollingCurve:
+ return myValues->Value(1);
+ }
+ return 0;
+}
+
+//=======================================================================
+//function : SetSecondPointOnCurve
+//purpose :
+//=======================================================================
+void XCAFKinematics_PairValueObject::SetSecondPointOnCurve(const Standard_Real theT)
+{
+ if (myType == XCAFKinematics_PairType_SlidingCurve)
+ myValues->ChangeValue(2) = theT;
+}
+
+//=======================================================================
+//function : GetSecondPointOnCurve
+//purpose :
+//=======================================================================
+Standard_Real XCAFKinematics_PairValueObject::GetSecondPointOnCurve() const
+{
+ if (myType == XCAFKinematics_PairType_SlidingCurve)
+ return myValues->Value(2);
+ return 0;
+}
+
+//=======================================================================
+//function : SetYPR
+//purpose :
+//=======================================================================
+void XCAFKinematics_PairValueObject::SetYPR(const Standard_Real theYaw,
+ const Standard_Real thePitch,
+ const Standard_Real theRoll)
+{
+ switch (myType) {
+ case XCAFKinematics_PairType_SphericalWithPin:
+ case XCAFKinematics_PairType_Spherical:
+ myValues->ChangeValue(1) = theYaw;
+ myValues->ChangeValue(2) = thePitch;
+ myValues->ChangeValue(3) = theRoll;
+ break;
+ case XCAFKinematics_PairType_PointOnSurface:
+ myValues->ChangeValue(3) = theYaw;
+ myValues->ChangeValue(4) = thePitch;
+ myValues->ChangeValue(5) = theRoll;
+ break;
+ case XCAFKinematics_PairType_PointOnPlanarCurve:
+ myValues->ChangeValue(2) = theYaw;
+ myValues->ChangeValue(3) = thePitch;
+ myValues->ChangeValue(4) = theRoll;
+ break;
+ }
+}
+
+//=======================================================================
+//function : GetYPR
+//purpose :
+//=======================================================================
+Standard_Boolean XCAFKinematics_PairValueObject::GetYPR(Standard_Real& theYaw,
+ Standard_Real& thePitch,
+ Standard_Real& theRoll) const
+{
+ switch (myType) {
+ case XCAFKinematics_PairType_SphericalWithPin:
+ case XCAFKinematics_PairType_Spherical:
+ theYaw = myValues->Value(1);
+ thePitch = myValues->Value(2);
+ theRoll = myValues->Value(3);
+ return Standard_True;
+ case XCAFKinematics_PairType_PointOnSurface:
+ theYaw = myValues->Value(3);
+ thePitch = myValues->Value(4);
+ theRoll = myValues->Value(5);
+ return Standard_True;
+ case XCAFKinematics_PairType_PointOnPlanarCurve:
+ theYaw = myValues->Value(2);
+ thePitch = myValues->Value(3);
+ theRoll = myValues->Value(4);
+ return Standard_True;
+ }
+ return Standard_False;
+}
+
+//=======================================================================
+//function : SetTransformation
+//purpose :
+//=======================================================================
+void XCAFKinematics_PairValueObject::SetTransformation(const gp_Ax2& theTrsf)
+{
+ if (myType != XCAFKinematics_PairType_Unconstrained)
+ return;
+
+ myValues->ChangeValue(1) = theTrsf.Location().X();
+ myValues->ChangeValue(2) = theTrsf.Location().Y();
+ myValues->ChangeValue(3) = theTrsf.Location().Z();
+ myValues->ChangeValue(4) = theTrsf.Direction().X();
+ myValues->ChangeValue(5) = theTrsf.Direction().Y();
+ myValues->ChangeValue(6) = theTrsf.Direction().Z();
+ myValues->ChangeValue(7) = theTrsf.XDirection().X();
+ myValues->ChangeValue(8) = theTrsf.XDirection().Y();
+ myValues->ChangeValue(9) = theTrsf.XDirection().Z();
+}
+
+//=======================================================================
+//function : GetTransformation
+//purpose :
+//=======================================================================
+gp_Ax2 XCAFKinematics_PairValueObject::GetTransformation()
+{
+ if (myType != XCAFKinematics_PairType_Unconstrained)
+ return gp_Ax2();
+
+ gp_Pnt aLoc(myValues->Value(1), myValues->Value(2), myValues->Value(3));
+ gp_Dir aDir(myValues->Value(4), myValues->Value(5), myValues->Value(6));
+ gp_Dir aXDir(myValues->Value(7), myValues->Value(8), myValues->Value(9));
+ gp_Ax2 aResult = gp_Ax2(aLoc, aDir, aXDir);
+ return aResult;
+}
--- /dev/null
+// Created on: 2020-03-27
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#ifndef _XCAFKinematics_PairValueObject_HeaderFile
+#define _XCAFKinematics_PairValueObject_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+#include <TColStd_HArray1OfReal.hxx>
+#include <XCAFKinematics_PairType.hxx>
+
+DEFINE_STANDARD_HANDLE(XCAFKinematics_PairValueObject, Standard_Transient)
+
+class gp_Ax2;
+
+//! \class XCAFKinematics_PairValueObject
+//! \brief Object to store and process current position
+//! of kinematic pair.
+//! NoType - no values,
+//!
+//! FullyConstrained - no values,
+//! Revolute - angle,
+//! Prismatic - length,
+//! Cylindrical - angle + length,
+//! Universal - angle + angle,
+//! Homokinetic - angle + angle,
+//! SphericalWithPin - ypr,
+//! Spherical - ypr,
+//! Planar - angle + length + length,
+//! Unconstrained - ax2,
+//!
+//! Screw - angle,
+//! RackAndPinion - length,
+//! Gear - angle,
+//!
+//! PointOnSurface pnt on surface + ypr,
+//! SlidingSurface - angle + pnt on surface + pnt on surface,
+//! RollingSurface - angle + pnt on surface,
+//! PointOnPlanarCurve pnt on curve + ypr,
+//! SlidingCurve - pnt on curve + pnt on curve,
+//! RollingCurve - pnt on curve
+//!
+//! ypr - three angles: yaw, pitch, roll
+//! point on surface - (u,v)
+//! point on curve - (t)
+//! ax2 - consists of location and two directions
+class XCAFKinematics_PairValueObject : public Standard_Transient
+{
+
+public:
+
+ Standard_EXPORT XCAFKinematics_PairValueObject();
+
+ Standard_EXPORT XCAFKinematics_PairValueObject(const Handle(XCAFKinematics_PairValueObject)& theObj);
+
+ Standard_EXPORT void SetType(const XCAFKinematics_PairType theType);
+
+ XCAFKinematics_PairType Type() const
+ {
+ return myType;
+ }
+
+ void SetAllValues(const Handle(TColStd_HArray1OfReal)& theValues)
+ {
+ if (myValues->Length() == theValues->Length())
+ myValues = theValues;
+ };
+
+ Handle(TColStd_HArray1OfReal) GetAllValues() const
+ {
+ return myValues;
+ }
+
+ // Rotations
+
+ void SetRotation(const Standard_Real theRotation)
+ {
+ SetFirstRotation(theRotation);
+ }
+
+ Standard_Real GetRotation() const
+ {
+ return GetFirstRotation();
+ }
+
+ Standard_EXPORT void SetFirstRotation(const Standard_Real theRotation);
+
+ Standard_EXPORT Standard_Real GetFirstRotation() const;
+
+ Standard_EXPORT void SetSecondRotation(const Standard_Real theRotation);
+
+ Standard_EXPORT Standard_Real GetSecondRotation() const;
+
+ // Translations
+
+ void SetTranslation(const Standard_Real theTranslation)
+ {
+ SetFirstTranslation(theTranslation);
+ }
+
+ Standard_Real GetTranslation() const
+ {
+ return GetFirstTranslation();
+ }
+
+ Standard_EXPORT void SetFirstTranslation(const Standard_Real theTranslation);
+
+ Standard_EXPORT Standard_Real GetFirstTranslation() const;
+
+ Standard_EXPORT void SetSecondTranslation(const Standard_Real theTranslation);
+
+ Standard_EXPORT Standard_Real GetSecondTranslation() const;
+
+ // Points on surface
+
+ void SetPointOnSurface(const Standard_Real theU,
+ const Standard_Real theV)
+ {
+ SetFirstPointOnSurface(theU, theV);
+ }
+
+ Standard_Boolean GetPointOnSurface(Standard_Real& theU,
+ Standard_Real& theV) const
+ {
+ return GetFirstPointOnSurface(theU, theV);
+ }
+
+ Standard_EXPORT void SetFirstPointOnSurface(const Standard_Real theU,
+ const Standard_Real theV);
+
+ Standard_EXPORT Standard_Boolean GetFirstPointOnSurface(Standard_Real& theU,
+ Standard_Real& theV) const;
+
+ Standard_EXPORT void SetSecondPointOnSurface(const Standard_Real theU,
+ const Standard_Real theV);
+
+ Standard_EXPORT Standard_Boolean GetSecondPointOnSurface(Standard_Real& theU,
+ Standard_Real& theV) const;
+
+ // Points on curve
+
+ void SetPointOnCurve(const Standard_Real theT)
+ {
+ SetFirstPointOnCurve(theT);
+ }
+
+ Standard_Real GetPointOnCurve() const
+ {
+ return GetFirstPointOnCurve();
+ }
+
+ Standard_EXPORT void SetFirstPointOnCurve(const Standard_Real theT);
+
+ Standard_EXPORT Standard_Real GetFirstPointOnCurve() const;
+
+ Standard_EXPORT void SetSecondPointOnCurve(const Standard_Real theT);
+
+ Standard_EXPORT Standard_Real GetSecondPointOnCurve() const;
+
+ // YPR
+
+ Standard_EXPORT void SetYPR(const Standard_Real theYaw,
+ const Standard_Real thePitch,
+ const Standard_Real theRoll);
+
+ Standard_EXPORT Standard_Boolean GetYPR(Standard_Real& theYaw,
+ Standard_Real& thePitch,
+ Standard_Real& theRoll) const;
+
+ // Transformation
+
+ Standard_EXPORT void SetTransformation(const gp_Ax2& theTrsf);
+
+ Standard_EXPORT gp_Ax2 GetTransformation();
+
+ DEFINE_STANDARD_RTTIEXT(XCAFKinematics_PairValueObject, Standard_Transient)
+
+private:
+
+ XCAFKinematics_PairType myType; //!< type of kinematic pair
+ Handle(TColStd_HArray1OfReal) myValues; //!< all values in a line
+};
+
+#endif // _XCAFKinematics_PairValueObject_HeaderFile
XDEDRAW_Views.hxx
XDEDRAW_Notes.cxx
XDEDRAW_Notes.hxx
+XDEDRAW_Kinematics.cxx
+XDEDRAW_Kinematics.hxx
#include <XDEDRAW_GDTs.hxx>
#include <XDEDRAW_Views.hxx>
#include <XDEDRAW_Notes.hxx>
+#include <XDEDRAW_Kinematics.hxx>
#include <XSDRAW.hxx>
#include <XSDRAWIGES.hxx>
#include <XSDRAWSTEP.hxx>
else if (att->ID() == XCAFDoc::ViewRefPlaneGUID()) {
type = "View Clipping Plane Link";
}
+ else if (att->ID() == XCAFDoc::KinematicRefShapeGUID()){
+ type = "Kinematic Link to Shape";
+ }
+ else if (att->ID() == XCAFDoc::KinematicRefLink1GUID() || att->ID() == XCAFDoc::KinematicRefLink2GUID()){
+ type = "Kinematic Joint to Link";
+ }
else return 0;
Handle(XCAFDoc_GraphNode) DETGN = Handle(XCAFDoc_GraphNode)::DownCast(att);
XDEDRAW_GDTs::InitCommands ( di );
XDEDRAW_Views::InitCommands(di);
XDEDRAW_Notes::InitCommands(di);
+ XDEDRAW_Kinematics::InitCommands(di);
XDEDRAW_Common::InitCommands ( di );//moved from EXE
}
class XDEDRAW_Props;
class XDEDRAW_Common;
class XDEDRAW_Views;
+class XDEDRAW_Kinematics;
//! Provides DRAW commands for work with DECAF data structures
--- /dev/null
+// Created on: 2020-03-19
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#include <XDEDRAW_Kinematics.hxx>
+
+#include <BRep_Tool.hxx>
+#include <DBRep.hxx>
+#include <DDocStd.hxx>
+#include <Draw.hxx>
+#include <DrawTrSurf.hxx>
+#include <Geom_Plane.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TDF_Tool.hxx>
+#include <TDF_Label.hxx>
+#include <TDF_LabelSequence.hxx>
+#include <TDocStd_Document.hxx>
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <XCAFDoc_DocumentTool.hxx>
+#include <XCAFDoc_KinematicPair.hxx>
+#include <XCAFDoc_KinematicPairValue.hxx>
+#include <XCAFDoc_KinematicTool.hxx>
+#include <XCAFDoc_ShapeTool.hxx>
+#include <XCAFKinematics_HighOrderPairObject.hxx>
+#include <XCAFKinematics_LowOrderPairObject.hxx>
+#include <XCAFKinematics_LowOrderPairObjectWithCoupling.hxx>
+#include <XCAFKinematics_PairObject.hxx>
+#include <XCAFKinematics_PairValueObject.hxx>
+
+//=======================================================================
+//function : getDocument
+//purpose : auxiliary method
+//=======================================================================
+static Standard_Boolean getDocument(Draw_Interpretor& di,
+ const char* theDocName,
+ Handle(TDocStd_Document)& theDoc)
+{
+ DDocStd::GetDocument(theDocName, theDoc);
+ if (theDoc.IsNull()) {
+ di << theDocName << " is not a document\n";
+ return Standard_False;
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : getEntry
+//purpose : auxiliary method
+//=======================================================================
+static TCollection_AsciiString getEntry(const TDF_Label& theLabel)
+{
+ TCollection_AsciiString entry;
+ TDF_Tool::Entry(theLabel, entry);
+ return entry;
+}
+
+//=======================================================================
+//function : getLabel
+//purpose : auxiliary method
+//=======================================================================
+static Standard_Boolean getLabel(Draw_Interpretor& di,
+ const Handle(TDocStd_Document)& theDoc,
+ const char* theEntry,
+ TDF_Label& theLabel)
+{
+ TDF_Tool::Label(theDoc->GetData(), theEntry, theLabel);
+ if (theLabel.IsNull()) {
+ di << "Invalid label " << theEntry << "\n";
+ return Standard_False;
+ }
+ return Standard_True;
+}
+
+//=======================================================================
+//function : addMechanism
+//purpose :
+//=======================================================================
+static Standard_Integer addMechanism(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 2) {
+ di << "Use: XAddMechanism Doc\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ di << getEntry(aTool->AddMechanism());
+
+ return 0;
+}
+
+//=======================================================================
+//function : isMechanism
+//purpose :
+//=======================================================================
+static Standard_Integer isMechanism(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XIsMechanism Doc Label\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aLabel;
+ if (!getLabel(di, aDoc, argv[2], aLabel))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ di << aTool->IsMechanism(aLabel);
+
+ return 0;
+}
+
+//=======================================================================
+//function : removeMechanism
+//purpose :
+//=======================================================================
+static Standard_Integer removeMechanism(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XRemoveMechanism Doc Label\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aLabel;
+ if (!getLabel(di, aDoc, argv[2], aLabel))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ aTool->RemoveMechanism(aLabel);
+
+ return 0;
+}
+
+//=======================================================================
+//function : addLink
+//purpose :
+//=======================================================================
+static Standard_Integer addLink(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XAddLink Doc ParentMechanism [shapeLabel1 .. shapeLabelN]\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aMechanism;
+ if (!getLabel(di, aDoc, argv[2], aMechanism))
+ return 1;
+
+ TDF_LabelSequence aShapeArray;
+ for (Standard_Integer i = 3; i < argc; i++) {
+ TDF_Label aLabel;
+ if (!getLabel(di, aDoc, argv[i], aLabel))
+ continue;
+ aShapeArray.Append(aLabel);
+ }
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ di << getEntry(aTool->AddLink(aMechanism, aShapeArray));
+
+ return 0;
+}
+
+//=======================================================================
+//function : setLink
+//purpose :
+//=======================================================================
+static Standard_Integer setLink(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XAddLink Doc Link shapeLabel1 .. shapeLabelN\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;
+
+ TDF_LabelSequence aShapeArray;
+ for (Standard_Integer i = 3; i < argc; i++) {
+ TDF_Label aLabel;
+ if (!getLabel(di, aDoc, argv[i], aLabel))
+ continue;
+ aShapeArray.Append(aLabel);
+ }
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ if (!aTool->SetLink(aLink, aShapeArray))
+ return 1;
+
+ return 0;
+}
+
+//=======================================================================
+//function : isLink
+//purpose :
+//=======================================================================
+static Standard_Integer isLink(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XIsLink Doc Label\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aLabel;
+ if (!getLabel(di, aDoc, argv[2], aLabel))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ di << aTool->IsLink(aLabel);
+
+ return 0;
+}
+
+//=======================================================================
+//function : removeLink
+//purpose :
+//=======================================================================
+static Standard_Integer removeLink(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XRemoveLink Doc Label\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aLabel;
+ if (!getLabel(di, aDoc, argv[2], aLabel))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ aTool->RemoveLink(aLabel);
+
+ return 0;
+}
+
+//=======================================================================
+//function : addJoint
+//purpose :
+//=======================================================================
+static Standard_Integer addJoint(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XAddJoint Doc Mechanism [Link1 Link2]\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aMechanism;
+ if (!getLabel(di, aDoc, argv[2], aMechanism))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+
+ if (argc == 3) {
+ di << getEntry(aTool->AddJoint(aMechanism));
+ return 0;
+ }
+ else if (argc == 5) {
+ TDF_Label aLink1, aLink2;
+ if (!getLabel(di, aDoc, argv[3], aLink1))
+ return 1;
+ if (!getLabel(di, aDoc, argv[4], aLink2))
+ return 1;
+ di << getEntry(aTool->AddJoint(aMechanism, aLink1, aLink2));
+ return 0;
+ }
+
+ return 1;
+}
+
+//=======================================================================
+//function : isJoint
+//purpose :
+//=======================================================================
+static Standard_Integer isJoint(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XIsJoint Doc Label\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aLabel;
+ if (!getLabel(di, aDoc, argv[2], aLabel))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ di << aTool->IsJoint(aLabel);
+ return 0;
+}
+
+//=======================================================================
+//function : setJoint
+//purpose :
+//=======================================================================
+static Standard_Integer setJoint(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 5) {
+ di << "Use: XSetJoint Doc Joint Link1 Link2\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint))
+ return 1;
+ TDF_Label aLink1, aLink2;
+ if (!getLabel(di, aDoc, argv[3], aLink1))
+ return 1;
+ if (!getLabel(di, aDoc, argv[4], aLink2))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ if (!aTool->SetJoint(aJoint, aLink1, aLink2))
+ return 1;
+
+ return 0;
+}
+
+//=======================================================================
+//function : removeJoint
+//purpose :
+//=======================================================================
+static Standard_Integer removeJoint(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XRemoveJoint Doc Label\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aLabel;
+ if (!getLabel(di, aDoc, argv[2], aLabel))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ aTool->RemoveJoint(aLabel);
+
+ return 0;
+}
+
+//=======================================================================
+//function : getMechanisms
+//purpose :
+//=======================================================================
+static Standard_Integer getMechanisms(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 2) {
+ di << "Use: XGetMechanisms Doc\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_LabelSequence aMechanismArray = aTool->GetMechanisms();
+ for (TDF_LabelSequence::Iterator anIter(aMechanismArray); anIter.More(); anIter.Next()) {
+ di << getEntry(anIter.Value()) << " ";
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : getLinks
+//purpose :
+//=======================================================================
+static Standard_Integer getLinks(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XGetLinks Doc Mechanism\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aMechanism;
+ if (!getLabel(di, aDoc, argv[2], aMechanism))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_LabelSequence aLinksArray = aTool->GetLinks(aMechanism);
+ for (TDF_LabelSequence::Iterator anIter(aLinksArray); anIter.More(); anIter.Next()) {
+ di << getEntry(anIter.Value()) << " ";
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : getJoints
+//purpose :
+//=======================================================================
+static Standard_Integer getJoints(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XGetJoints Doc Mechanism\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aMechanism;
+ if (!getLabel(di, aDoc, argv[2], aMechanism))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_LabelSequence aJointsArray = aTool->GetJoints(aMechanism);
+ for (TDF_LabelSequence::Iterator anIter(aJointsArray); anIter.More(); anIter.Next()) {
+ di << getEntry(anIter.Value()) << " ";
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : getLinksOfJoint
+//purpose :
+//=======================================================================
+static Standard_Integer getLinksOfJoint(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XGetLinksOfJoint Doc Joint\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aLink1, aLink2;
+ aTool->GetLinksOfJoint(aJoint, aLink1, aLink2);
+
+ di << getEntry(aLink1) << " " << getEntry(aLink2);
+
+ return 0;
+}
+
+//=======================================================================
+//function : getJointsOfLink
+//purpose :
+//=======================================================================
+static Standard_Integer getJointsOfLink(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XGetJointsOfLink 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());
+ TDF_LabelSequence aJointsArray = aTool->GetJointsOfLink(aLink);
+ for (TDF_LabelSequence::Iterator anIter(aJointsArray); anIter.More(); anIter.Next()) {
+ di << getEntry(anIter.Value()) << " ";
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : getRefShapes
+//purpose :
+//=======================================================================
+static Standard_Integer getRefShapes(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XGetRefShapes 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());
+ TDF_LabelSequence aShapesArray = aTool->GetRefShapes(aLink);
+ for (TDF_LabelSequence::Iterator anIter(aShapesArray); anIter.More(); anIter.Next()) {
+ di << getEntry(anIter.Value()) << " ";
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : setName
+//purpose :
+//=======================================================================
+static Standard_Integer setName(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 4) {
+ di << "Use: XSetPairName Doc Joint Name\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ TCollection_AsciiString aName;
+ for (Standard_Integer i = 3; i < argc; i++) {
+ aName.AssignCat(argv[i]);
+ aName.AssignCat(" ");
+ if (i == argc - 1)
+ aName.Remove(aName.Length(), 1);
+ }
+
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject();
+ anObject->SetName(aName);
+ aPair->SetObject(anObject);
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : getName
+//purpose :
+//=======================================================================
+static Standard_Integer getName(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XGetPairName Doc Joint\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject();
+ di << anObject->Name();
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : setType
+//purpose :
+//=======================================================================
+static Standard_Integer setType(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 4) {
+ di << "Use: XSetPairType Doc Joint Type[1, 19]\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject();
+ int aType = Draw::Atoi(argv[3]);
+ if (aType >= XCAFKinematics_PairType_FullyConstrained &&
+ aType <= XCAFKinematics_PairType_Unconstrained)
+ anObject = new XCAFKinematics_LowOrderPairObject();
+ else if (aType >= XCAFKinematics_PairType_Screw &&
+ aType <= XCAFKinematics_PairType_Gear)
+ anObject = new XCAFKinematics_LowOrderPairObjectWithCoupling();
+ else if (aType >= XCAFKinematics_PairType_PointOnSurface &&
+ aType <= XCAFKinematics_PairType_RollingCurve)
+ anObject = new XCAFKinematics_HighOrderPairObject();
+ anObject->SetType((XCAFKinematics_PairType)aType);
+ aPair->SetObject(anObject);
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : getType
+//purpose :
+//=======================================================================
+static Standard_Integer getType(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XGetPairType Doc Joint\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject();
+ di << anObject->Type();
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : setTrsf
+//purpose :
+//=======================================================================
+static Standard_Integer setTrsf(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 5) {
+ di << "Use: XSetPairTransformation Doc Joint TrsfNumber[1/2] Plane\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject();
+ Standard_Integer aTrsfNb = Draw::Atoi(argv[3]);
+ Handle(Geom_Plane) aSurface = Handle(Geom_Plane)::DownCast(DrawTrSurf::GetSurface(argv[4]));
+ if (aSurface.IsNull()) {
+ di << "Invalid transformation\n";
+ return 1;
+ }
+ switch (aTrsfNb) {
+ case 1: anObject->SetFirstTransformation(aSurface->Position());
+ break;
+ case 2: anObject->SetSecondTransformation(aSurface->Position());
+ break;
+ default:
+ di << "Invalid number of transformation\n";
+ return 1;
+ }
+ aPair->SetObject(anObject);
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : getTrsf
+//purpose :
+//=======================================================================
+static Standard_Integer getTrsf(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 5) {
+ di << "Use: XGetPairTransformation Doc Joint TrsfNumber[1/2] PlaneName\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject();
+ Standard_Integer aTrsfNb = Draw::Atoi(argv[3]);
+ Standard_CString aName = argv[4];
+ switch (aTrsfNb) {
+ case 1: DrawTrSurf::Set(aName, new Geom_Plane(anObject->FirstTransformation()));
+ break;
+ case 2: DrawTrSurf::Set(aName, new Geom_Plane(anObject->SecondTransformation()));
+ break;
+ default:
+ di << "Invalid number of transformation\n";
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : setLimits
+//purpose :
+//=======================================================================
+static Standard_Integer setLimits(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 5) {
+ di << "Use: XSetPairLimits Doc Joint Value1 Value2...\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(TColStd_HArray1OfReal) aLimitArray = new TColStd_HArray1OfReal(1, argc - 3);
+ for (Standard_Integer i = 3; i < argc; i++) {
+ aLimitArray->ChangeValue(i - 2) = Draw::Atof(argv[i]);
+ }
+
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject();
+ anObject->SetAllLimits(aLimitArray);
+ aPair->SetObject(anObject);
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : getLimits
+//purpose :
+//=======================================================================
+static Standard_Integer getLimits(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XGetPairLimits Doc Joint\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ di << "Invalid Pair object\n";
+ return 1;
+ }
+
+ Handle(TColStd_HArray1OfReal) aLimitArray;
+ Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject();
+ aLimitArray = anObject->GetAllLimits();
+ for (Standard_Integer i = 1; i <= aLimitArray->Length(); i++)
+ di << aLimitArray->Value(i) << " ";
+
+ return 0;
+}
+
+//=======================================================================
+//function : setParameters
+//purpose :
+//=======================================================================
+static Standard_Integer setParameters(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 4) {
+ di << "Use: XSetPairParams Doc Joint Value1 Value2...\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(TColStd_HArray1OfReal) aParamArray = new TColStd_HArray1OfReal(1, argc - 3);
+ for (Standard_Integer i = 3; i < argc; i++) {
+ aParamArray->ChangeValue(i - 2) = Draw::Atof(argv[i]);
+ }
+
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObject =
+ Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(aPair->GetObject());
+ if (!anObject.IsNull()) {
+ anObject->SetAllParams(aParamArray);
+ aPair->SetObject(anObject);
+ return 0;
+ }
+ Handle(XCAFKinematics_LowOrderPairObject) aLowObject =
+ Handle(XCAFKinematics_LowOrderPairObject)::DownCast(aPair->GetObject());
+ if (!aLowObject.IsNull()) {
+ aLowObject->SetSkewAngle(aParamArray->First());
+ aPair->SetObject(aLowObject);
+ return 0;
+ }
+ }
+
+ di << "Wrong type of object\n";
+ return 1;
+}
+
+//=======================================================================
+//function : getParameters
+//purpose :
+//=======================================================================
+static Standard_Integer getParameters(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XGetPairParams Doc Joint\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ Handle(XCAFKinematics_LowOrderPairObjectWithCoupling) anObject =
+ Handle(XCAFKinematics_LowOrderPairObjectWithCoupling)::DownCast(aPair->GetObject());
+ if (anObject.IsNull()) {
+ Handle(XCAFKinematics_LowOrderPairObject) aLowObject =
+ Handle(XCAFKinematics_LowOrderPairObject)::DownCast(aPair->GetObject());
+ if (!aLowObject.IsNull() &&
+ (aLowObject->Type() == XCAFKinematics_PairType_Universal ||
+ aLowObject->Type() == XCAFKinematics_PairType_Homokinetic)) {
+ di << "Skew Angle = " << aLowObject->SkewAngle();
+ return 0;
+ }
+ else {
+ di << "Wrong type of object\n";
+ return 1;
+ }
+ }
+ switch (anObject->Type()) {
+ case XCAFKinematics_PairType_Screw:
+ di << "Pitch = " << anObject->Pitch();
+ break;
+ case XCAFKinematics_PairType_RackAndPinion:
+ di << "Pinion Radius = " << anObject->PinionRadius();
+ break;
+ case XCAFKinematics_PairType_Gear:
+ di << "First Link Radius = " << anObject->RadiusFirstLink() << "\n";
+ di << "Second Link Radius = " << anObject->RadiusSecondLink() << "\n";
+ di << "Bevel = " << anObject->Bevel() << "\n";
+ di << "Helical Angle = " << anObject->HelicalAngle() << "\n";
+ di << "Gear Ratio = " << anObject->GearRatio();
+ break;
+ }
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : setOrientation
+//purpose :
+//=======================================================================
+static Standard_Integer setOrientation(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 4) {
+ di << "Use: XSetPairOrientation Doc Joint Orientation[0/1]\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject();
+ Handle(XCAFKinematics_HighOrderPairObject) aHighObject =
+ Handle(XCAFKinematics_HighOrderPairObject)::DownCast(anObject);
+ if (aHighObject.IsNull()) {
+ di << "Error: Orientation could be applied only for high order kinematic pair\n";
+ return 1;
+ }
+ aHighObject->SetOrientation(Draw::Atoi(argv[3]) != 0 );
+ aPair->SetObject(anObject);
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : getOrientation
+//purpose :
+//=======================================================================
+static Standard_Integer getOrientation(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XGetPairOrientation Doc Joint\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ Handle(XCAFKinematics_PairObject) anObject = aPair->GetObject();
+ Handle(XCAFKinematics_HighOrderPairObject) aHighObject =
+ Handle(XCAFKinematics_HighOrderPairObject)::DownCast(anObject);
+ if (aHighObject.IsNull()) {
+ di << "Error: Orientation could be applied only for high order kinematic pair\n";
+ return 1;
+ }
+ di << aHighObject->Orientation();
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : setGeomParam
+//purpose :
+//=======================================================================
+static Standard_Integer setGeomParam(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 5) {
+ di << "Use: XSetPairGeomParam Doc Joint Number[1/2] Surface/Face/Curve/Edge\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ di << "Invalid kinematic pair object\n";
+ return 1;
+ }
+ Handle(XCAFKinematics_HighOrderPairObject) anObject =
+ Handle(XCAFKinematics_HighOrderPairObject)::DownCast(aPair->GetObject());
+ if (anObject.IsNull()) {
+ di << "Wrong type of kinematic pair\n";
+ return 1;
+ }
+
+ Standard_Integer aParamNb = Draw::Atoi(argv[3]);
+
+ if (anObject->Type() >= XCAFKinematics_PairType_PointOnSurface &&
+ anObject->Type() <= XCAFKinematics_PairType_RollingSurface)
+ {
+ // Surface
+ Handle(Geom_Surface) aSurface = DrawTrSurf::GetSurface(argv[4]);
+ if (aSurface.IsNull()) {
+ // Try to retrieve as a face
+ TopoDS_Face aFace = TopoDS::Face(DBRep::Get(argv[4], TopAbs_FACE));
+ if (!aFace.IsNull()) {
+ TopLoc_Location aLoc;
+ aSurface = BRep_Tool::Surface(aFace, aLoc);
+ }
+ }
+ if (aSurface.IsNull()) {
+ di << "Invalid geometric argument\n";
+ return 1;
+ }
+ if (anObject->Type() == XCAFKinematics_PairType_PointOnSurface)
+ anObject->SetSurface(aSurface);
+ else {
+ switch (aParamNb) {
+ case 1: anObject->SetFirstSurface(aSurface);
+ break;
+ case 2: anObject->SetSecondSurface(aSurface);
+ break;
+ default:
+ di << "Invalid number of geometric argument\n";
+ return 1;
+ }
+ }
+ }
+ else {
+ // Curve
+ Handle(Geom_Curve) aCurve = DrawTrSurf::GetCurve(argv[4]);
+ if (aCurve.IsNull()) {
+ // Try to retrieve as an adge
+ TopoDS_Edge anEdge = TopoDS::Edge(DBRep::Get(argv[4], TopAbs_EDGE));
+ if (!anEdge.IsNull()) {
+ TopLoc_Location aLoc;
+ Standard_Real aFirst, aLast;
+ aCurve = BRep_Tool::Curve(anEdge, aLoc, aFirst, aLast);
+ }
+ }
+ if (aCurve.IsNull()) {
+ di << "Invalid geometric argument\n";
+ return 1;
+ }
+ if (anObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve)
+ anObject->SetCurve(aCurve);
+ else {
+ switch (aParamNb) {
+ case 1: anObject->SetFirstCurve(aCurve);
+ break;
+ case 2: anObject->SetSecondCurve(aCurve);
+ break;
+ default:
+ di << "Invalid number of geometric argument\n";
+ return 1;
+ }
+ }
+ }
+
+ aPair->SetObject(anObject);
+
+ return 0;
+}
+
+//=======================================================================
+//function : getGeomParam
+//purpose :
+//=======================================================================
+static Standard_Integer getGeomParam(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 5) {
+ di << "Use: XGetPairGeomParam Doc Joint Number[1/2] Name\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ di << "Invalid kinematic pair object\n";
+ return 1;
+ }
+ Handle(XCAFKinematics_HighOrderPairObject) anObject =
+ Handle(XCAFKinematics_HighOrderPairObject)::DownCast(aPair->GetObject());
+ if (anObject.IsNull()) {
+ di << "Wrong type of kinematic pair\n";
+ return 1;
+ }
+
+ Standard_Integer aTrsfNb = Draw::Atoi(argv[3]);
+
+ if (anObject->Type() >= XCAFKinematics_PairType_PointOnSurface &&
+ anObject->Type() <= XCAFKinematics_PairType_RollingSurface)
+ {
+ // Surface
+ Handle(Geom_Surface) aSurface;
+ if (anObject->Type() == XCAFKinematics_PairType_PointOnSurface)
+ aSurface = anObject->Surface();
+ else {
+ switch (aTrsfNb) {
+ case 1: aSurface = anObject->FirstSurface();
+ break;
+ case 2: aSurface = anObject->SecondSurface();
+ break;
+ default:
+ di << "Invalid number of geometric argument\n";
+ return 1;
+ }
+ }
+ DrawTrSurf::Set(argv[4], aSurface);
+ }
+ else {
+ // Curve
+ Handle(Geom_Curve) aCurve;
+ if (anObject->Type() == XCAFKinematics_PairType_PointOnPlanarCurve)
+ aCurve = anObject->Curve();
+ else {
+ switch (aTrsfNb) {
+ case 1: aCurve = anObject->FirstCurve();
+ break;
+ case 2: aCurve = anObject->SecondCurve();
+ break;
+ default:
+ di << "Invalid number of geometric argument\n";
+ return 1;
+ }
+ }
+ DrawTrSurf::Set(argv[4], aCurve);
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : setValues
+//purpose :
+//=======================================================================
+static Standard_Integer setValues(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 5) {
+ di << "Use: XSetPairValues Doc Joint -Key1 Values1... -KeyN ValuesN\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(XCAFKinematics_PairValueObject) anObject;
+ Handle(XCAFDoc_KinematicPairValue) aPairValue;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aPairValue))
+ anObject = aPairValue->GetObject();
+ else {
+ Handle(XCAFDoc_KinematicPair) aPair;
+ if (!aJoint.FindAttribute(XCAFDoc_KinematicPair::GetID(), aPair)) {
+ di << "Invalid kinematic pair object\n";
+ return 1;
+ }
+ Handle(XCAFKinematics_PairObject) aPairObject = aPair->GetObject();
+ anObject = new XCAFKinematics_PairValueObject();
+ anObject->SetType(aPairObject->Type());
+ aPairValue = XCAFDoc_KinematicPairValue::Set(aJoint);
+ }
+
+ try {
+ Standard_Integer anIt = 3;
+ while (anIt < argc) {
+ TCollection_AsciiString aKey = argv[anIt];
+ if (aKey.IsEqual("-rotation"))
+ anObject->SetRotation(Atof(argv[++anIt]));
+ else if (aKey.IsEqual("-first_rotation"))
+ anObject->SetFirstRotation(Atof(argv[++anIt]));
+ else if (aKey.IsEqual("-second_rotation"))
+ anObject->SetSecondRotation(Atof(argv[++anIt]));
+ else if (aKey.IsEqual("-translation"))
+ anObject->SetTranslation(Atof(argv[++anIt]));
+ else if (aKey.IsEqual("-first_translation"))
+ anObject->SetFirstTranslation(Atof(argv[++anIt]));
+ else if (aKey.IsEqual("-second_translation"))
+ anObject->SetSecondTranslation(Atof(argv[++anIt]));
+ else if (aKey.IsEqual("-point_on_surface")) {
+ anObject->SetPointOnSurface(Atof(argv[anIt + 1]), Atof(argv[anIt + 2]));
+ anIt += 2;
+ }
+ else if (aKey.IsEqual("-first_point_on_surface")) {
+ anObject->SetFirstPointOnSurface(Atof(argv[anIt + 1]), Atof(argv[anIt + 2]));
+ anIt += 2;
+ }
+ else if (aKey.IsEqual("-second_point_on_surface")) {
+ anObject->SetSecondPointOnSurface(Atof(argv[anIt + 1]), Atof(argv[anIt + 2]));
+ anIt += 2;
+ }
+ else if (aKey.IsEqual("-point_on_curve"))
+ anObject->SetPointOnCurve(Atof(argv[++anIt]));
+ else if (aKey.IsEqual("-first_point_on_curve"))
+ anObject->SetFirstPointOnCurve(Atof(argv[++anIt]));
+ else if (aKey.IsEqual("-second_point_on_curve"))
+ anObject->SetSecondPointOnCurve(Atof(argv[++anIt]));
+ else if (aKey.IsEqual("-ypr")) {
+ anObject->SetYPR(Atof(argv[anIt + 1]), Atof(argv[anIt + 2]), Atof(argv[anIt + 3]));
+ anIt += 3;
+ }
+ else if (aKey.IsEqual("-trsf")) {
+ gp_Pnt aLoc(Atof(argv[anIt + 1]), Atof(argv[anIt + 2]), Atof(argv[anIt + 3]));
+ gp_Dir aDir(Atof(argv[anIt + 4]), Atof(argv[anIt + 5]), Atof(argv[anIt + 6]));
+ gp_Dir aXDir(Atof(argv[anIt + 7]), Atof(argv[anIt + 8]), Atof(argv[anIt + 9]));
+ anIt += 9;
+ gp_Ax2 aResult = gp_Ax2(aLoc, aDir, aXDir);
+ anObject->SetTransformation(aResult);
+ }
+ anIt++;
+ }
+ }
+ catch (...) {
+ di << "Invalid number of parameters";
+ return 1;
+ }
+
+ aPairValue->SetObject(anObject);
+
+ return 0;
+}
+
+//=======================================================================
+//function : getValues
+//purpose :
+//=======================================================================
+static Standard_Integer getValues(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 4) {
+ di << "Use: XGetPairValues Doc Joint -Key\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aJoint;
+ if (!getLabel(di, aDoc, argv[2], aJoint) || !aTool->IsJoint(aJoint))
+ return 1;
+
+ Handle(XCAFKinematics_PairValueObject) anObject;
+ Handle(XCAFDoc_KinematicPairValue) aPairValue;
+ if (aJoint.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aPairValue))
+ anObject = aPairValue->GetObject();
+ if (anObject.IsNull()) {
+ di << "Invalid value object";
+ return 1;
+ }
+
+ TCollection_AsciiString aKey = argv[3];
+ if (aKey.IsEqual("-rotation"))
+ di << anObject->GetRotation();
+ else if (aKey.IsEqual("-first_rotation"))
+ di << anObject->GetFirstRotation();
+ else if (aKey.IsEqual("-second_rotation"))
+ di << anObject->GetSecondRotation();
+ else if (aKey.IsEqual("-translation"))
+ di << anObject->GetTranslation();
+ else if (aKey.IsEqual("-first_translation"))
+ di << anObject->GetFirstTranslation();
+ else if (aKey.IsEqual("-second_translation"))
+ di << anObject->GetSecondTranslation();
+ else if (aKey.IsEqual("-point_on_surface")) {
+ Standard_Real anU, aV;
+ if (anObject->GetPointOnSurface(anU, aV))
+ di << anU << " " << aV;
+ }
+ else if (aKey.IsEqual("-first_point_on_surface")) {
+ Standard_Real anU, aV;
+ if (anObject->GetFirstPointOnSurface(anU, aV))
+ di << anU << " " << aV;
+ }
+ else if (aKey.IsEqual("-second_point_on_surface")) {
+ Standard_Real anU, aV;
+ if (anObject->GetSecondPointOnSurface(anU, aV))
+ di << anU << " " << aV;
+ }
+ else if (aKey.IsEqual("-point_on_curve"))
+ di << anObject->GetPointOnCurve();
+ else if (aKey.IsEqual("-first_point_on_curve"))
+ di << anObject->GetFirstPointOnCurve();
+ else if (aKey.IsEqual("-second_point_on_curve"))
+ di << anObject->GetSecondPointOnCurve();
+ else if (aKey.IsEqual("-ypr")) {
+ Standard_Real anYaw, aPitch, aRoll;
+ if (anObject->GetYPR(anYaw, aPitch, aRoll))
+ di << anYaw << " " << aPitch << " " << aRoll;
+ }
+ else if (aKey.IsEqual("-trsf")) {
+ gp_Ax2 aResult = anObject->GetTransformation();
+ di << aResult.Location().X() << " " << aResult.Location().Y() << " " << aResult.Location().Z() << "\n";
+ di << aResult.Direction().X() << " " << aResult.Direction().Y() << " " << aResult.Direction().Z() << "\n";
+ di << aResult.XDirection().X() << " " << aResult.XDirection().Y() << " " << aResult.XDirection().Z();
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : InitCommands
+//purpose :
+//=======================================================================
+
+void XDEDRAW_Kinematics::InitCommands(Draw_Interpretor& di)
+{
+ static Standard_Boolean initactor = Standard_False;
+ if (initactor)
+ {
+ return;
+ }
+ initactor = Standard_True;
+
+ Standard_CString g = "XDE Kinematics commands";
+
+ di.Add("XAddMechanism", "XAddMechanism Doc",
+ __FILE__, addMechanism, g);
+
+ di.Add("XIsMechanism", "XIsMechanism Doc Label",
+ __FILE__, isMechanism, g);
+
+ di.Add("XRemoveMechanism", "XRemoveMechanism Doc Label",
+ __FILE__, removeMechanism, g);
+
+ di.Add("XAddLink", "XAddLink Doc ParentMechanism [shapeLabel1 .. shapeLabelN]",
+ __FILE__, addLink, g);
+
+ di.Add("XSetLink", "XSetLink Doc Link shapeLabel1 .. shapeLabelN",
+ __FILE__, setLink, g);
+
+ di.Add("XIsLink", "XIsLink Doc Label",
+ __FILE__, isLink, g);
+
+ di.Add("XRemoveLink", "XRemoveLink Doc Label",
+ __FILE__, removeLink, g);
+
+ di.Add("XAddJoint", "XAddJoint Doc Mechanism [Link1 Link2]",
+ __FILE__, addJoint, g);
+
+ di.Add("XSetJoint", "XSetJoint Doc Joint Link1 Link2",
+ __FILE__, setJoint, g);
+
+ di.Add("XIsJoint", "XIsJoint Doc Label",
+ __FILE__, isJoint, g);
+
+ di.Add("XRemoveJoint", "XRemoveJoint Doc Label",
+ __FILE__, removeJoint, g);
+
+ di.Add("XGetMechanisms", "XGetMechanisms Doc",
+ __FILE__, getMechanisms, g);
+
+ di.Add("XGetLinks", "XGetLinks Doc Mechanism",
+ __FILE__, getLinks, g);
+
+ di.Add("XGetJoints", "XGetJoints Doc Mechanism",
+ __FILE__, getJoints, g);
+
+ di.Add("XGetLinksOfJoint", "XGetLinksOfJoint Doc Joint",
+ __FILE__, getLinksOfJoint, g);
+
+ di.Add("XGetJointsOfLink", "XGetJointsOfLink Doc Link",
+ __FILE__, getJointsOfLink, g);
+
+ di.Add("XGetRefShapes", "XGetRefShapes Doc Link",
+ __FILE__, getRefShapes, g);
+
+ di.Add("XSetPairName", "XSetPairName Doc Joint Name",
+ __FILE__, setName, g);
+
+ di.Add("XGetPairName", "XGetPairName Doc Joint",
+ __FILE__, getName, g);
+
+ di.Add("XSetPairType", "XSetPairType Doc Joint Type[0..19]"
+ "Values:\n"
+ "\t 0 type is absent\n"
+ "\t 1 FullyConstrained\n"
+ "\t 2 Revolute\n"
+ "\t 3 Prismatic\n"
+ "\t 4 Cylindrical\n"
+ "\t 5 Universal\n"
+ "\t 6 Homokinetic\n"
+ "\t 7 SphericalWithPin\n"
+ "\t 8 Spherical\n"
+ "\t 9 Planar\n"
+ "\t 10 Unconstrained\n"
+ "\t 11 Screw\n"
+ "\t 12 RackAndPinion\n"
+ "\t 13 Gear\n"
+ "\t 14 PointOnSurface\n"
+ "\t 15 SlidingSurface\n"
+ "\t 16 RollingSurface\n"
+ "\t 17 PointOnPlanarCurve\n"
+ "\t 18 SlidingCurve\n"
+ "\t 19 RollingCurve\n"
+ __FILE__, setType, g);
+
+ di.Add("XGetPairType", "XGetPairType Doc Joint",
+ __FILE__, getType, g);
+
+ di.Add("XSetPairTransformation", "XSetPairTransformation Doc Joint TrsfNb[1/2] Plane",
+ __FILE__, setTrsf, g);
+
+ di.Add("XGetPairTransformation", "XGetPairTransformation Doc Joint TrsfNb[1/2] PlaneName",
+ __FILE__, getTrsf, g);
+
+ di.Add("XSetPairOrientation", "XSetPairOrientation Doc Joint Orientation[0/1]",
+ __FILE__, setOrientation, g);
+
+ di.Add("XGetPairOrientation", "XGetPairOrientation Doc Joint",
+ __FILE__, getOrientation, g);
+
+ di.Add("XSetPairLimits", "XSetPairLimits Doc Joint Value1 Value2..."
+ "Values:\n"
+ "\t Low order pair - 12 values \n"
+ "\t Low order pair with motion coupling - 2 values \n"
+ "\t High order pair - 2 or 6 values\n"
+ __FILE__, setLimits, g);
+
+ di.Add("XGetPairLimits", "XGetPairLimits Doc Joint",
+ __FILE__, getLimits, g);
+
+ di.Add("XSetPairParams", "XSetPairParams Doc Joint Value1 Value2..."
+ "\tScrew - Pitch\n"
+ "\tRackAndPinion - PinionRadius\n"
+ "\tGear -FirstLinkRadius SecondLinkRadius Bevel HelicalAngle GearRatio \n"
+ __FILE__, setParameters, g);
+
+ di.Add("XGetPairParams", "XGetPairParams Doc Joint",
+ __FILE__, getParameters, g);
+
+ di.Add("XSetPairGeomParam", "XSetPairGeomParam Doc Joint Number[1/2] Surface/Face/Curve/Edge",
+ __FILE__, setGeomParam, g);
+
+ di.Add("XGetPairGeomParam", "XGetPairGeomParam Doc Joint Number[1/2] Name",
+ __FILE__, getGeomParam, g);
+
+ di.Add("XSetPairValues", "XSetPairValues Doc Joint -Key1 Values1 -KeyN ValuesN"
+ "\t-[first_/second_]rotation - current rotation - 1 number"
+ "\t-[first_/second_]translation - current translation - 1 number"
+ "\t-[first_/second_]point_on_surface - current (u,v) - 2 numbers"
+ "\t-[first_/second_]point_on_curve - current (t) - 1 number"
+ "\t-ypr - current yaw pitch roll angles - 3 numbers"
+ "\t-trsf - for unconstrained only current location direction xdirection - 9 numbers",
+ __FILE__, setValues, g);
+
+ di.Add("XGetPairValues", "XGetPairValues Doc Joint -Key"
+ "\t-[first_/second_]rotation - current rotation - 1 number"
+ "\t-[first_/second_]translation - current translation - 1 number"
+ "\t-[first_/second_]point_on_surface - current (u,v) - 2 numbers"
+ "\t-[first_/second_]point_on_curve - current (t) - 1 number"
+ "\t-ypr - current yaw pitch roll angles - 3 numbers"
+ "\t-trsf - for unconstrained only current location direction xdirection - 9 numbers",
+ __FILE__, getValues, g);
+}
--- /dev/null
+// Created on: 2020-03-19
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _XDEDRAW_Kinematics_HeaderFile
+#define _XDEDRAW_Kinematics_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_DefineAlloc.hxx>
+#include <Standard_Handle.hxx>
+
+#include <Draw_Interpretor.hxx>
+
+
+//! Contains commands to work with GDTs
+class XDEDRAW_Kinematics
+{
+public:
+
+ DEFINE_STANDARD_ALLOC
+
+ Standard_EXPORT static void InitCommands (Draw_Interpretor& theCommands);
+};
+
+#endif // _XDEDRAW_Kinematics_HeaderFile
XmlMXCAFDoc_DocumentToolDriver.hxx
XmlMXCAFDoc_GraphNodeDriver.cxx
XmlMXCAFDoc_GraphNodeDriver.hxx
+XmlMXCAFDoc_KinematicToolDriver.cxx
+XmlMXCAFDoc_KinematicToolDriver.hxx
XmlMXCAFDoc_LayerToolDriver.cxx
XmlMXCAFDoc_LayerToolDriver.hxx
XmlMXCAFDoc_LocationDriver.cxx
#include <XmlMXCAFDoc_DimTolToolDriver.hxx>
#include <XmlMXCAFDoc_DocumentToolDriver.hxx>
#include <XmlMXCAFDoc_GraphNodeDriver.hxx>
+#include <XmlMXCAFDoc_KinematicToolDriver.hxx>
#include <XmlMXCAFDoc_LayerToolDriver.hxx>
#include <XmlMXCAFDoc_LocationDriver.hxx>
#include <XmlMXCAFDoc_MaterialDriver.hxx>
aDriverTable -> AddDriver (new XmlMXCAFDoc_NotesToolDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_ViewToolDriver (anMsgDrv));
aDriverTable -> AddDriver (new XmlMXCAFDoc_ClippingPlaneToolDriver(anMsgDrv));
+ aDriverTable -> AddDriver (new XmlMXCAFDoc_KinematicToolDriver(anMsgDrv));
}
class XmlMXCAFDoc_DimTolToolDriver;
class XmlMXCAFDoc_MaterialToolDriver;
class XmlMXCAFDoc_ViewToolDriver;
+class XmlMXCAFDoc_KinematicToolDriver;
//! Storage and Retrieval drivers for modelling attributes.
friend class XmlMXCAFDoc_DimTolToolDriver;
friend class XmlMXCAFDoc_MaterialToolDriver;
friend class XmlMXCAFDoc_ViewToolDriver;
+friend class XmlMXCAFDoc_KinematicToolDriver;
};
--- /dev/null
+// Created on: 2020-03-18
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+
+#include <Message_Messenger.hxx>
+#include <Standard_Type.hxx>
+#include <TDF_Attribute.hxx>
+#include <XCAFDoc_KinematicTool.hxx>
+#include <XmlMXCAFDoc_KinematicToolDriver.hxx>
+#include <XmlObjMgt_Persistent.hxx>
+
+IMPLEMENT_STANDARD_RTTIEXT(XmlMXCAFDoc_KinematicToolDriver, XmlMDF_ADriver)
+
+//=======================================================================
+//function : XmlMXCAFDoc_KinematicToolDriver
+//purpose :
+//=======================================================================
+XmlMXCAFDoc_KinematicToolDriver::XmlMXCAFDoc_KinematicToolDriver
+ (const Handle(Message_Messenger)& theMsgDriver)
+: XmlMDF_ADriver (theMsgDriver, "xcaf", "KinematicTool")
+{
+}
+
+//=======================================================================
+//function : NewEmpty
+//purpose :
+//=======================================================================
+Handle(TDF_Attribute) XmlMXCAFDoc_KinematicToolDriver::NewEmpty() const
+{
+ return new XCAFDoc_KinematicTool();
+}
+
+//=======================================================================
+//function : Paste
+//purpose :
+//=======================================================================
+Standard_Boolean XmlMXCAFDoc_KinematicToolDriver::Paste(const XmlObjMgt_Persistent&,
+ const Handle(TDF_Attribute)&,
+ XmlObjMgt_RRelocationTable&) const
+{
+ return Standard_True;
+}
+
+//=======================================================================
+//function : Paste
+//purpose :
+//=======================================================================
+void XmlMXCAFDoc_KinematicToolDriver::Paste(const Handle(TDF_Attribute)&,
+ XmlObjMgt_Persistent&,
+ XmlObjMgt_SRelocationTable&) const
+{
+}
--- /dev/null
+// Created on: 2020-03-18
+// Created by: Irina KRYLOVA
+// Copyright (c) 2020 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _XmlMXCAFDoc_KinematicToolDriver_HeaderFile
+#define _XmlMXCAFDoc_KinematicToolDriver_HeaderFile
+
+#include <Standard.hxx>
+#include <Standard_Type.hxx>
+
+#include <XmlMDF_ADriver.hxx>
+#include <Standard_Boolean.hxx>
+#include <XmlObjMgt_RRelocationTable.hxx>
+#include <XmlObjMgt_SRelocationTable.hxx>
+class Message_Messenger;
+class TDF_Attribute;
+class XmlObjMgt_Persistent;
+
+
+class XmlMXCAFDoc_KinematicToolDriver;
+DEFINE_STANDARD_HANDLE(XmlMXCAFDoc_KinematicToolDriver, XmlMDF_ADriver)
+
+//! Attribute Driver.
+class XmlMXCAFDoc_KinematicToolDriver : public XmlMDF_ADriver
+{
+
+public:
+
+
+ Standard_EXPORT XmlMXCAFDoc_KinematicToolDriver(const Handle(Message_Messenger)& theMsgDriver);
+
+ Standard_EXPORT virtual Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual Standard_Boolean Paste (const XmlObjMgt_Persistent& theSource, const Handle(TDF_Attribute)& theTarget, XmlObjMgt_RRelocationTable& theRelocTable) const Standard_OVERRIDE;
+
+ Standard_EXPORT virtual void Paste (const Handle(TDF_Attribute)& theSource, XmlObjMgt_Persistent& theTarget, XmlObjMgt_SRelocationTable& theRelocTable) const Standard_OVERRIDE;
+
+ DEFINE_STANDARD_RTTIEXT(XmlMXCAFDoc_KinematicToolDriver, XmlMDF_ADriver)
+};
+
+#endif // _XmlMXCAFDoc_KinematicToolDriver_HeaderFile
005 presentation
006 view
007 notes
+008 kinematics
--- /dev/null
+#==============================
+# Test scenario for kinematics
+#==============================
+
+# ReadStep D [locate_data_file as1-oc-214.stp]
+# Load document with shape structure
+ReadStep D C:/Work/files/as1.stp
+# Add parent mechanism
+set mech [XAddMechanism D]
+
+# Add several Links
+set link1 [XAddLink D $mech 0:1:1:2:3]
+set ref_shapes1 [XGetRefShapes D $link1]
+if {$ref_shapes1 != "0:1:1:2:3 "} {
+ puts "Error: wrong kinematic graph structure."
+}
+set link2 [XAddLink D 0:1:11:1]
+XSetLink D $link2 0:1:1:2:1 0:1:1:2:2
+set ref_shapes2 [XGetRefShapes D $link2]
+if {$ref_shapes2 != "0:1:1:2:1 0:1:1:2:2 "} {
+ puts "Error: wrong kinematic graph structure."
+}
+set link3 [XAddLink D $mech 0:1:1:3]
+set result [XIsLink D $link3]
+if {$result == 0} {
+ puts "Error: wrong kinematic graph structure."
+}
+set link4 [XAddLink D $mech 0:1:1:7]
+XRemoveLink D $link4
+set result [XIsLink D $link4]
+if {$result == 1} {
+ puts "Error: wrong kinematic graph structure."
+}
+
+# Add several Joints
+set joint1 [XAddJoint D $mech $link1 $link2]
+set result [XIsJoint D $joint1]
+if {$result == 0} {
+ puts "Error: wrong kinematic graph structure."
+}
+set ref_links1 [XGetLinksOfJoint D $joint1]
+if {$ref_links1 != "0:1:11:1:1:1 0:1:11:1:1:2"} {
+ puts "Error: wrong kinematic graph structure."
+}
+XSetPairType D $joint1 3
+set result [XGetPairType D $joint1]
+if {$result != 3} {
+ puts "Error: wrong kinematic pair data."
+}
+XSetPairName D $joint1 Low order
+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
+XSetPairTransformation D $joint1 1 p1
+set dump_in [dump p1]
+XGetPairTransformation D $joint1 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong kinematic pair data."
+}
+XSetPairTransformation D $joint1 2 p2
+set dump_in [dump p2]
+XGetPairTransformation D $joint1 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong kinematic pair data."
+}
+XSetPairLimits D $joint1 0 0 0 0 0 0 0 100 0 0 0 0
+set limits [XGetPairLimits D $joint1]
+if {$limits != "0 0 0 0 0 0 0 100 0 0 0 0 "} {
+ puts "Error: wrong kinematic pair data."
+}
+
+set joint2 [XAddJoint D 0:1:11:1]
+XSetJoint D $joint2 $link1 $link3
+set ref_links2 [XGetLinksOfJoint D $joint2]
+if {$ref_links2 != "0:1:11:1:1:1 0:1:11:1:1:3"} {
+ puts "Error: wrong kinematic graph structure."
+}
+set ref_joints [XGetJointsOfLink D 0:1:11:1:1:1]
+if {$ref_joints != "0:1:11:1:2:1 0:1:11:1:2:2 "} {
+ puts "Error: wrong kinematic graph structure."
+}
+XSetPairType D $joint2 13
+XSetPairName D $joint2 Low order with motion coupling
+XSetPairLimits D $joint2 0 60
+set limits [XGetPairLimits D $joint2]
+if {$limits != "0 60 "} {
+ puts "Error: wrong kinematic pair data."
+}
+XSetPairParams D $joint2 1 2 3 4 5
+set params [XGetPairParams D $joint2]
+if {[lindex $params 4] != "1"} {
+ puts "Error: wrong kinematic pair data."
+}
+if {[lindex $params 9] != "2"} {
+ puts "Error: wrong kinematic pair data."
+}
+if {[lindex $params 12] != "3"} {
+ puts "Error: wrong kinematic pair data."
+}
+if {[lindex $params 16] != "4"} {
+ puts "Error: wrong kinematic pair data."
+}
+if {[lindex $params 20] != "5"} {
+ puts "Error: wrong kinematic pair data."
+}
+
+set joint3 [XAddJoint D $mech $link3 $link2]
+XSetPairType D $joint3 15
+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
+XGetPairGeomParam D $joint3 1 sph
+set dump_out [dump sph]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong kinematic pair data."
+}
+cylinder cyl 0 0 0 0 1 0 2
+trim cyl cyl 0 2 0 2
+set dump_in [dump cyl]
+mkface fcyl cyl
+XSetPairGeomParam D $joint3 2 fcyl
+XGetPairGeomParam D $joint3 2 cyl
+set dump_out [dump cyl]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong kinematic pair data."
+}
+
+set joint4 [XAddJoint D $mech $link3 0:1:11:1:1:1]
+XSetPairType D $joint4 17
+XSetPairName D $joint4 High order curve
+circle cir 0 0 0 3
+set dump_in [dump cir]
+XSetPairGeomParam D $joint4 1 cir
+XGetPairGeomParam D $joint4 1 cir
+set dump_out [dump cir]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong kinematic pair data."
+}
+mkedge ecir cir
+XSetPairGeomParam D $joint4 1 ecir
+XGetPairGeomParam D $joint4 1 cir
+set dump_out [dump cir]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong kinematic pair data."
+}
+
+Close D
--- /dev/null
+# Revolute pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint revolute
+set name [XGetPairName D $joint]
+if {$name != "revolute"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 2
+set type [XGetPairType D $joint]
+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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 0 45 0 0 0 0 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 "} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -rotation 15
+set values [XGetPairValues D $joint -rotation]
+if {$values != "15"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Revolute pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint prismatic
+set name [XGetPairName D $joint]
+if {$name != "prismatic"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 3
+set type [XGetPairType D $joint]
+if {$type != "3"} {
+ puts "Error: wrong parameter"
+}
+
+plane p1 0 0 0 0 0 1
+plane p2 0 1 0 0 0 1
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 0 0 0 0 0 0 0 0 0 10 0 0
+set limits [XGetPairLimits D $joint]
+if {$limits != "0 0 0 0 0 0 0 0 0 10 0 0 "} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -translation 3
+set values [XGetPairValues D $joint -translation]
+if {$values != "3"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Cylindrical pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint cylindrical
+set name [XGetPairName D $joint]
+if {$name != "cylindrical"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 4
+set type [XGetPairType D $joint]
+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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 0 45 0 0 0 0 0 0 0 10 0 0
+set limits [XGetPairLimits D $joint]
+if {$limits != "0 45 0 0 0 0 0 0 0 10 0 0 "} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -rotation 15 -translation 3
+set values [XGetPairValues D $joint -translation]
+if {$values != "3"} {
+ puts "Error: wrong parameter"
+}
+set values [XGetPairValues D $joint -rotation]
+if {$values != "15"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Universal pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint universal
+set name [XGetPairName D $joint]
+if {$name != "universal"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 5
+set type [XGetPairType D $joint]
+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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 0 45 10 20 0 0 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 "} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairParams D $joint 30
+set param [XGetPairParams D $joint]
+if {$param != "Skew Angle = 30"} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -first_rotation 20 -second_rotation 15
+set values [XGetPairValues D $joint -first_rotation]
+if {$values != "20"} {
+ puts "Error: wrong parameter"
+}
+set values [XGetPairValues D $joint -second_rotation]
+if {$values != "15"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Homokinetic pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint homokinetic
+set name [XGetPairName D $joint]
+if {$name != "homokinetic"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 6
+set type [XGetPairType D $joint]
+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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+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"} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -rotation 20 -second_rotation 20
+set values [XGetPairValues D $joint -rotation]
+if {$values != "20"} {
+ puts "Error: wrong parameter"
+}
+set values [XGetPairValues D $joint -second_rotation]
+if {$values != "20"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Spherical with pin pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint spherical with pin
+set name [XGetPairName D $joint]
+if {$name != "spherical with pin"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 7
+set type [XGetPairType D $joint]
+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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 0 45 0 0 30 60 0 0 0 0 0 0
+set limits [XGetPairLimits D $joint]
+if {$limits != "0 45 0 0 30 60 0 0 0 0 0 0 "} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -ypr 10 0 30
+set values [XGetPairValues D $joint -ypr]
+if {$values != "10 0 30"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Spherical pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint spherical with pin
+set name [XGetPairName D $joint]
+if {$name != "spherical with pin"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 8
+set type [XGetPairType D $joint]
+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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 0 45 0 30 30 60 0 0 0 0 0 0
+set limits [XGetPairLimits D $joint]
+if {$limits != "0 45 0 30 30 60 0 0 0 0 0 0 "} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -ypr 10 20 30
+set values [XGetPairValues D $joint -ypr]
+if {$values != "10 20 30"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Planar pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint planar
+set name [XGetPairName D $joint]
+if {$name != "planar"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 9
+set type [XGetPairType D $joint]
+if {$type != "9"} {
+ puts "Error: wrong parameter"
+}
+
+plane p1 0 0 3 0 0 1
+plane p2 0 0 0 0 1 1 1 1 0
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 0 45 0 0 0 0 10 20 2 3 0 0
+set limits [XGetPairLimits D $joint]
+if {$limits != "0 45 0 0 0 0 10 20 2 3 0 0 "} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -rotation 20 -first_translation 14
+XSetPairValues D $joint -second_translation 2.1
+set values [XGetPairValues D $joint -rotation]
+if {$values != "20"} {
+ puts "Error: wrong parameter"
+}
+set values [XGetPairValues D $joint -first_translation]
+if {$values != "14"} {
+ puts "Error: wrong parameter"
+}
+set values [XGetPairValues D $joint -second_translation]
+if {$values != "2.1"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Unconstrained pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint unconstrained
+set name [XGetPairName D $joint]
+if {$name != "unconstrained"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 10
+set type [XGetPairType D $joint]
+if {$type != "10"} {
+ puts "Error: wrong parameter"
+}
+
+plane p1 0 0 3 0 0 1
+plane p2 4 0 0 0 1 1 1 1 0
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 1 2 3 4 5 6 7 8 9 10 11 12
+set limits [XGetPairLimits D $joint]
+if {$limits != "1 2 3 4 5 6 7 8 9 10 11 12 "} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -trsf 10 10 10 1 0 0 0 -1 0
+set values [XGetPairValues D $joint -trsf]
+if {$values!= "10 10 10\n1 0 0\n0 -1 0"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Screw pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint screw
+set name [XGetPairName D $joint]
+if {$name != "screw"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 11
+set type [XGetPairType D $joint]
+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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 0 30
+set limits [XGetPairLimits D $joint]
+if {$limits != "0 30 "} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairParams D $joint 14
+set param [XGetPairParams D $joint]
+if {$param != "Pitch = 14"} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -rotation 20
+set values [XGetPairValues D $joint -rotation]
+if {$values != "20"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Rack and pinion pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint rack and pinion
+set name [XGetPairName D $joint]
+if {$name != "rack and pinion"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 12
+set type [XGetPairType D $joint]
+if {$type != "12"} {
+ puts "Error: wrong parameter"
+}
+
+plane p1 0 0 0 0 0 1
+plane p2 0 0 0 0 0 1
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 10 20
+set limits [XGetPairLimits D $joint]
+if {$limits != "10 20 "} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairParams D $joint 3
+set param [XGetPairParams D $joint]
+if {$param != "Pinion Radius = 3"} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -translation 12
+set values [XGetPairValues D $joint -translation]
+if {$values != "12"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Gear pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint gear
+set name [XGetPairName D $joint]
+if {$name != "gear"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 13
+set type [XGetPairType D $joint]
+if {$type != "13"} {
+ puts "Error: wrong parameter"
+}
+
+plane p1 0 0 0 0 0 1
+plane p2 0 0 0 0 0 1
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 15 30
+set limits [XGetPairLimits D $joint]
+if {$limits != "15 30 "} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairParams D $joint 1 2 3 4 5
+set param [XGetPairParams D $joint]
+if {$param != "First Link Radius = 1\nSecond Link Radius = 2\nBevel = 3\nHelical Angle = 4\nGear Ratio = 5"} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -rotation 24
+set values [XGetPairValues D $joint -rotation]
+if {$values != "24"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Point on surface pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint point on surface
+set name [XGetPairName D $joint]
+if {$name != "point on surface"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 14
+set type [XGetPairType D $joint]
+if {$type != "14"} {
+ 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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 10 20 30 40 50 60
+set limits [XGetPairLimits D $joint]
+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]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairOrientation D $joint 1
+set ori [XGetPairOrientation D $joint]
+if {$ori != 1} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -point_on_surface 1 2 -ypr 12 13 14
+set values [XGetPairValues D $joint -point_on_surface]
+if {$values != "1 2"} {
+ puts "Error: wrong parameter"
+}
+set values [XGetPairValues D $joint -ypr]
+if {$values != "12 13 14"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Sliding surface pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint sliding surface
+set name [XGetPairName D $joint]
+if {$name != "sliding surface"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 15
+set type [XGetPairType D $joint]
+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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+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
+set dump_in [dump sph1]
+XGetPairGeomParam D $joint 1 sph1
+set dump_out [dump sph1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+XSetPairGeomParam D $joint 2 p2
+set dump_in [dump p2]
+XGetPairGeomParam D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairOrientation D $joint 0
+set ori [XGetPairOrientation D $joint]
+if {$ori != 0} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -point_on_surface 1 2 -second_point_on_surface 2 1 -rotation 30
+set values [XGetPairValues D $joint -first_point_on_surface]
+if {$values != "1 2"} {
+ puts "Error: wrong parameter"
+}
+set values [XGetPairValues D $joint -second_point_on_surface]
+if {$values != "2 1"} {
+ puts "Error: wrong parameter"
+}
+set values [XGetPairValues D $joint -rotation]
+if {$values != "30"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Rolling surface pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint rolling surface
+set name [XGetPairName D $joint]
+if {$name != "rolling surface"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 16
+set type [XGetPairType D $joint]
+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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+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
+set dump_in [dump sph1]
+XGetPairGeomParam D $joint 1 sph1
+set dump_out [dump sph1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+XSetPairGeomParam D $joint 2 p2
+set dump_in [dump p2]
+XGetPairGeomParam D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairOrientation D $joint 1
+set ori [XGetPairOrientation D $joint]
+if {$ori != 1} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -point_on_surface 2 1 -rotation 30
+set values [XGetPairValues D $joint -point_on_surface]
+if {$values != "2 1"} {
+ puts "Error: wrong parameter"
+}
+set values [XGetPairValues D $joint -rotation]
+if {$values != "30"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# point on planar curve pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint point on planar curve
+set name [XGetPairName D $joint]
+if {$name != "point on planar curve"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 17
+set type [XGetPairType D $joint]
+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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairLimits D $joint 10 20 30 40 50 60
+set limits [XGetPairLimits D $joint]
+if {$limits != "10 20 30 40 50 60 "} {
+ puts "Error: wrong parameter"
+}
+
+circle cir 4 4 4 1
+XSetPairGeomParam D $joint 1 cir
+set dump_in [dump cir]
+XGetPairGeomParam D $joint 1 cir
+set dump_out [dump cir]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairOrientation D $joint 1
+set ori [XGetPairOrientation D $joint]
+if {$ori != 1} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -point_on_curve 1.5 -ypr 12 13 14
+set values [XGetPairValues D $joint -point_on_curve]
+if {$values != "1.5"} {
+ puts "Error: wrong parameter"
+}
+set values [XGetPairValues D $joint -ypr]
+if {$values != "12 13 14"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# sliding curve pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint sliding curve
+set name [XGetPairName D $joint]
+if {$name != "sliding curve"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 18
+set type [XGetPairType D $joint]
+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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+circle cir1 4 4 4 1
+line l2 0 0 0 1 1 1
+XSetPairGeomParam D $joint 1 cir1
+set dump_in [dump cir1]
+XGetPairGeomParam D $joint 1 cir1
+set dump_out [dump cir1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+XSetPairGeomParam D $joint 2 l2
+set dump_in [dump l2]
+XGetPairGeomParam D $joint 2 l2
+set dump_out [dump l2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairOrientation D $joint 0
+set ori [XGetPairOrientation D $joint]
+if {$ori != 0} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -point_on_curve 1.5 -second_point_on_curve 7
+set values [XGetPairValues D $joint -first_point_on_curve]
+if {$values != "1.5"} {
+ puts "Error: wrong parameter"
+}
+set values [XGetPairValues D $joint -second_point_on_curve]
+if {$values != "7"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+# Rolling curve pair
+
+# Prepare a document
+XNewDoc D
+box b 1 1 1
+box bb 2 0 0 1 1 1
+XAddShape D b
+XAddShape D bb
+set mech [XAddMechanism D]
+set link1 [XAddLink D $mech 0:1:1:1]
+set link2 [XAddLink D $mech 0:1:1:2]
+set joint [XAddJoint D $mech $link1 $link2]
+
+# Start testing
+XSetPairName D $joint rolling curve
+set name [XGetPairName D $joint]
+if {$name != "rolling curve"} {
+ puts "Error: wrong parameter"
+}
+XSetPairType D $joint 19
+set type [XGetPairType D $joint]
+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
+XSetPairTransformation D $joint 1 p1
+XSetPairTransformation D $joint 2 p2
+set dump_in [dump p1]
+XGetPairTransformation D $joint 1 p1
+set dump_out [dump p1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+set dump_in [dump p2]
+XGetPairTransformation D $joint 2 p2
+set dump_out [dump p2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+circle cir1 4 4 4 1
+line l2 0 0 0 1 1 1
+XSetPairGeomParam D $joint 1 cir1
+set dump_in [dump cir1]
+XGetPairGeomParam D $joint 1 cir1
+set dump_out [dump cir1]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+XSetPairGeomParam D $joint 2 l2
+set dump_in [dump l2]
+XGetPairGeomParam D $joint 2 l2
+set dump_out [dump l2]
+if {$dump_in != $dump_out} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairOrientation D $joint 1
+set ori [XGetPairOrientation D $joint]
+if {$ori != 1} {
+ puts "Error: wrong parameter"
+}
+
+XSetPairValues D $joint -point_on_curve 1.5
+set values [XGetPairValues D $joint -first_point_on_curve]
+if {$values != "1.5"} {
+ puts "Error: wrong parameter"
+}
+
+Close D
--- /dev/null
+puts "TEST COMPLETED"
else if ( att->ID() == XCAFDoc::GeomToleranceRefGUID() ){
type = "GeomTolerance Link";
}
+ else if (att->ID() == XCAFDoc::KinematicRefShapeGUID()){
+ type = "Kinematic Link to Shape";
+ }
+ else if (att->ID() == XCAFDoc::KinematicRefLink1GUID() || att->ID() == XCAFDoc::KinematicRefLink2GUID()){
+ type = "Kinematic Joint to Link";
+ }
else
return TCollection_AsciiString();