XShapeVolume a 0
~~~~~
+@subsection occt_draw_8_10 XDE kinematics commands
+
+@subsubsection occt_draw_8_10_1 XAddMechanism
+
+Syntax:
+~~~~~
+XAddMechanism <document>
+~~~~~
+
+Adds a new empty kinematic mechanism.
+
+**Example:**
+~~~~~
+XAddMechanism D
+== 0:11:1
+~~~~~
+
+@subsubsection occt_draw_8_10_2 XIsMechanism
+
+Syntax:
+~~~~~
+XIsMechanism <document> <label>
+~~~~~
+
+Returns 1 if the Label is a kinematic mechanism, else returns 0.
+
+**Example:**
+~~~~~
+XIsMechanism D 0:11:1
+== 1
+~~~~~
+
+@subsubsection occt_draw_8_10_3 XRemoveMechanism
+
+Syntax:
+~~~~~
+XRemoveMechanism <document> <label>
+~~~~~
+
+Removes a kinematic mechanism from a document (by it’s label).
+
+**Example:**
+~~~~~
+XRemoveMechanism D 0:11:1
+~~~~~
+
+@subsubsection occt_draw_8_10_4 XAddLink
+
+Syntax:
+~~~~~
+XAddLink <document> <parentMechanism> [-base] [shapeLabel1] ... [shapeLabelN]
+~~~~~
+
+Adds a kinematic link to a given mechanism. By default, a new link is added as empty and a non-base, otherwise it is necessary to pass label(s) of shape as the last parameters and -base as the third parameter.
+
+**Example:**
+~~~~~
+# add full (with shape) link to the mechanism
+XAddLink D 0:11:1 0:1:1:1
+# add empty base link to the mechanism
+XAddLink D 0:11:1 -base
+== 0:11:1:1:2
+~~~~~
+
+@subsubsection occt_draw_8_10_5 XSetLink
+
+Syntax:
+~~~~~
+XSetLink <document> <linkLabel> <shapeLabel1> [shapeLabel2] ... [shapeLabelN]
+~~~~~
+
+Sets a reference between a shape (set of shapes) and a kinematic link.
+
+**Example:**
+~~~~~
+XSetLink D 0:11:1:1:2 0:1:1:2
+~~~~~
+
+@subsubsection occt_draw_8_10_6 XSetBaseLink
+
+Syntax:
+~~~~~
+XSetBaseLink <document> <linkLabel>
+~~~~~
+
+Sets a kinematic link as a base of the mechanism.
+
+**Example:**
+~~~~~
+XSetBaseLink D 0:11:1:1:2
+~~~~~
+
+@subsubsection occt_draw_8_10_7 XIsLink
+
+Syntax:
+~~~~~
+XIsLink <document> <linkLabel>
+~~~~~
+
+Returns 1 if the label is a kinematic link, else returns 0.
+
+**Example:**
+~~~~~
+XIsLink D 0:11:1:1:1
+== 1
+~~~~~
+
+@subsubsection occt_draw_8_10_8 XRemoveLink
+
+Syntax:
+~~~~~
+XRemoveLink <doxument> <label>
+~~~~~
+
+Removes a kinematic link and referenced by it kinematic joints from a document (by it’s label).
+
+**Example:**
+~~~~~
+XRemoveLink D 0:11:1:1:1
+~~~~~
+
+@subsubsection occt_draw_8_10_9 XAddJoint
+
+Syntax:
+~~~~~
+XAddJoint <document> <parentMechanism> [linkLabel1 linkLabel2]
+~~~~~
+
+Adds a kinematic joint to a given mechanism. By default, a new joint is added as empty, otherwise it is necessary to pass couple (start and end) of the kinematic links as the last parameters.
+
+**Example:**
+~~~~~
+# add full (with links) joint to the mechanism
+XAddJoint D 0:11:1 0:11:1:1:1 0:11:1:1:2
+== 0:11:1:2:1
+# add empty joint to the mechanism
+XAddJoint D 0:11:1
+== 0:11:1:2:2
+~~~~~
+
+@subsubsection occt_draw_8_10_10 XSetJoint
+
+Syntax:
+~~~~~
+XSetJoint <document> <jointLabel> <linkLabel1> <linkLabel2>
+~~~~~
+
+Sets a reference between a kinematic joint and couple (start and end) of the kinematic links
+
+**Example:**
+~~~~~
+XSetJoint D 0:11:1:2:1 0:11:1:1:1 0:11:1:1:2
+~~~~~
+
+@subsubsection occt_draw_8_10_11 XIsJoint
+
+Syntax:
+~~~~~
+XIsJoint <document> <jointLabel>
+~~~~~
+
+Returns 1 if the label is a kinematic joint, else returns 0.
+
+**Example:**
+~~~~~
+XIsJoint D 0:11:1:2:1
+== 1
+~~~~~
+
+@subsubsection occt_draw_8_10_12 XRemoveJoint
+
+Syntax:
+~~~~~
+XRemoveJoint <document> <jointLabel>
+~~~~~
+
+Removes a kinematic joint from a document (by it’s label).
+
+**Example:**
+~~~~~
+XRemoveJoint D 0:11:1:2:1
+~~~~~
+
+@subsubsection occt_draw_8_10_13 XGetMechanisms
+
+Syntax:
+~~~~~
+XGetMechanisms <document>
+~~~~~
+
+Prints all kinematic mechanisms in an XCAF document.
+
+**Example:**
+~~~~~
+XGetMechanisms D
+== 0:11:1 0:11:2
+~~~~~
+
+@subsubsection occt_draw_8_10_14 XGetLinks
+
+Syntax:
+~~~~~
+XGetLinks <document> <parentMechanism>
+~~~~~
+
+Prints all kinematic links of the given mechanism in an XCAF document.
+
+**Example:**
+~~~~~
+XGetLinks D 0:11:1
+== 0:11:1:1:1 0:11:1:1:2
+~~~~~
+
+@subsubsection occt_draw_8_10_15 XGetJoints
+
+Syntax:
+~~~~~
+XGetJoints <document> <parentMechanism>
+~~~~~
+
+Prints all kinematic joints of the given mechanism in an XCAF document.
+
+**Example:**
+~~~~~
+XGetJoints 0:11:1
+== 0:11:1:2:1 0:11:1:2:2
+~~~~~
+
+@subsubsection occt_draw_8_10_16 XGetLinksOfJoint
+
+Syntax:
+~~~~~
+XGetLinksOfJoint <document> <jointLabel>
+~~~~~
+
+Prints start and end kinematic links of the given joint in an XCAF document.
+
+**Example:**
+~~~~~
+XGetLinksOfJoint D 0:11:1:2:1
+== 0:11:1:1:1 0:11:1:1:2
+~~~~~
+
+@subsubsection occt_draw_8_10_17 XGetJointsOfLink
+
+Syntax:
+~~~~~
+XGetJointsOfLink <document> <linkLabel>
+~~~~~
+
+Prints all kinematic links that reference a kinematic joint in an XCAF document.
+
+**Example:**
+~~~~~
+XGetJointsOfLink D 0:11:1:1:1
+== 0:11:1:2:1
+~~~~~
+
+@subsubsection occt_draw_8_10_18 XGetRefShapes
+
+Syntax:
+~~~~~
+XGetRefShapes <document> <linkLabel>
+~~~~~
+
+Prints all shape that reference a kinematic link in an XCAF document.
+
+**Example:**
+~~~~~
+XGetRefShapes D 0:11:1:1:1
+== 0:1:1:1
+~~~~~
+
+@subsubsection occt_draw_8_10_19 XSetPairName
+
+Syntax:
+~~~~~
+XSetPairName <document> <jointLabel> <name>
+~~~~~
+
+Sets the name of the kinematic pair.
+
+**Example:**
+~~~~~
+XSetPairName D 0:11:1:2:1 revolute
+~~~~~
+
+@subsubsection occt_draw_8_10_20 XGetPairName
+
+Syntax:
+~~~~~
+XGetPairName <document> <jointLabel>
+~~~~~
+
+Prints the name of the kinematic pair.
+
+**Example:**
+~~~~~
+XGetPairName D 0:11:1:2:1
+== revolute
+~~~~~
+
+@subsubsection occt_draw_8_10_21 XSetPairType
+
+Syntax:
+~~~~~
+XSetPairType <document> <jointLabel> <type {0|1|...|21}>
+~~~~~
+
+Sets a type of the kinematic pair.
+
+<i>\<Type\></i> may be:
+* 0 type is absent
+* 1 FullyConstrained
+* 2 Revolute
+* 3 Prismatic
+* 4 Cylindrical
+* 5 Universal
+* 6 Homokinetic
+* 7 SphericalWithPin
+* 8 Spherical
+* 9 Planar
+* 10 Unconstrained
+* 11 Screw
+* 12 RackAndPinion
+* 13 Gear
+* 14 LinearFlexibleAndPinion
+* 15 PointOnSurface
+* 16 SlidingSurface
+* 17 RollingSurface
+* 18 PointOnPlanarCurve
+* 19 SlidingCurve
+* 20 RollingCurve
+* 21 LinearFlexibleAndPlanarCurve
+
+**Example:**
+~~~~~
+XSetPairType D 0:11:1:2:1 2
+~~~~~
+
+@subsubsection occt_draw_8_10_22 XGetPairType
+
+Syntax:
+~~~~~
+XGetPairType <document> <jointLabel>
+~~~~~
+
+Prints a type of the kinematic pair.
+
+**Example:**
+~~~~~
+XGetPairType D 0:11:1:2:1
+== 2
+~~~~~
+
+@subsubsection occt_draw_8_10_23 XSetPairTransformation
+
+Syntax:
+~~~~~
+XSetPairTransformation <document> <jointLabel> <transform_nb {1|2}> <plane>
+~~~~~
+
+Sets a placement describes a relative position and orientation of a frame with respect to another frame.
+
+**Example:**
+~~~~~
+plane p1 10 20 30 -1 0 0
+XSetPairTransformation D 0:11:1:2:1 1 p1
+~~~~~
+
+@subsubsection occt_draw_8_10_24 XGetPairTransformation
+
+Syntax:
+~~~~~
+XGetPairTransformation <document> <jointLabel> <transform_nb {1|2}> <planeName>
+~~~~~
+
+Creates a new variable names <i>\<planeName\></i> with a copy of the content of an first or second pair transformation.
+
+**Example:**
+~~~~~
+XGetPairTransformation D 0:11:1:2:1 1 p1
+~~~~~
+
+@subsubsection occt_draw_8_10_25 XSetPairOrientation
+
+Syntax:
+~~~~~
+XSetPairOrientation <document> <jointLabel> <orientation {0|1}>
+~~~~~
+
+Sets orientation, directions correspond to the type of the kinematic pair.
+
+**Example:**
+~~~~~
+XSetPairOrientation D 0:11:1:2:1 1
+~~~~~
+
+@subsubsection occt_draw_8_10_26 XGetPairOrientation
+
+Syntax:
+~~~~~
+XGetPairOrientation <document> <jointLabel>
+~~~~~
+
+Prints orientation of the kinematic pair.
+
+**Example:**
+~~~~~
+XGetPairOrientation D 0:11:1:2:1
+== 1
+~~~~~
+
+@subsubsection occt_draw_8_10_27 XSetPairLimits
+
+Syntax:
+~~~~~
+XSetPairLimits <document> <jointLabel> <value1> ... <valueN>
+~~~~~
+
+Sets the limits of the kinematic pair according to the type
+
+<i>\<type - nb_of_values\></i>:
+* low order pair - 12 values
+* low order pair with motion coupling - 2 values
+* high order pair - 2 or 6 values.
+
+**Example:**
+~~~~~
+# sets limits for the low order pair with motion coupling
+XSetPairLimits D 0:11:1:2:1 15 30
+~~~~~
+
+@subsubsection occt_draw_8_10_28 XGetPairLimits
+
+Syntax:
+~~~~~
+XGetPairLimits <document> <jointLabel>
+~~~~~
+
+Prints all limits of the kinematic pair.
+
+**Example:**
+~~~~~
+# gets limits for the low order pair with motion coupling
+XGetPairLimits D 0:11:1:2:1
+== 15 30
+~~~~~
+
+@subsubsection occt_draw_8_10_29 XSetPairParams
+
+Syntax:
+~~~~~
+XSetPairParams <document> <jointLabel> <value1> ... <valueN>
+~~~~~
+
+Sets the params of the low order pair with motion coupling according to the type.
+
+<i>\<Type - nb_of_values\></i>:
+* screw - 1 values
+ * pitch
+* rackAndPinion - 1 values
+ * pinionRadius
+* gear - 5
+ * firstLinkRadius
+ * secondLinkRadius
+ * bevel
+ * helicalAngle
+ * gearRatio
+
+**Example:**
+~~~~~
+XSetPairParams D 0:11:1:2:1 15
+~~~~~
+
+@subsubsection occt_draw_8_10_30 XGetPairParams
+
+Syntax:
+~~~~~
+XGetPairParams <document> <jointLabel>
+~~~~~
+
+Prints all params of the kinematic pair.
+
+**Example:**
+~~~~~
+XGetPairParams D 0:11:1:2:1
+== 15
+~~~~~
+
+@subsubsection occt_draw_8_10_31 XSetPairGeomParam
+
+Syntax:
+~~~~~
+XSetPairGeomParam <document> <jointLabel> <number_of_the_parameter {1|2}> {<surface>|<face>|<curve>|<edge>}
+~~~~~
+
+Sets the parametrs of the high order pair according to the type.
+
+The following syntax is used:
+* <i>\<limited\></i>
+ * point on surface
+ * trimmed surface | trimmed face
+ * point on curve
+ * trimmed curve | trimmed edge
+* <i>\<not limited\></i>
+ * point on surface
+ * surface | face
+ * point on curve
+ * curve | edge
+ * sliding surface
+ * surface | face
+ * surface | face
+ * rolling surface
+ * surface | face
+ * surface | face
+ * sliding curve
+ * curve | edge
+ * curve | edge
+ * rolling curve
+ * curve | edge
+ * curve | edge
+ * linear flexible and planar curve
+ * curve | edge
+
+**Example:**
+~~~~~
+circle cir 4 4 4 1
+XSetPairGeomParam D 0:11:1:2:1 1 cir
+~~~~~
+
+@subsubsection occt_draw_8_10_32 XGetPairGeomParam
+
+Syntax:
+~~~~~
+XGetPairGeomParam <document> <jointLabel> <number_of_the_parameter {1|2}> <name>
+~~~~~
+
+Creates a new variable names <i>\<name\></i> with a copy of the content of an first or second geom parametrs of pair.
+
+**Example:**
+~~~~~
+XGetPairGeomParam D 0:11:1:2:1 1 face
+~~~~~
+
+@subsubsection occt_draw_8_10_33 XAddMechanismState
+
+Syntax:
+~~~~~
+XAddMechanismState <document> <parentMechanism>
+~~~~~
+
+Adds a new empty kinematic mechanism state.
+
+**Example:**
+~~~~~
+XAddMechanismState D 0:11:1
+== 0:11:1:3:1
+~~~~~
+
+@subsubsection occt_draw_8_10_34 XRemoveMechanismState
+
+Syntax:
+~~~~~
+XRemoveMechanismState <document> <stateLabel>
+~~~~~
+
+Removes a kinematic mechanism state with all kinematic values from a document (by it’s label).
+
+**Example:**
+~~~~~
+XRemoveMechanismState D 0:11:1:3:1
+~~~~~
+
+@subsubsection occt_draw_8_10_35 XAddPairValues
+
+Syntax:
+~~~~~
+XAddPairValues <document> <stateLabel> [jointLabel] [-key1 values1] ... [-keyN valuesN]
+~~~~~
+
+Adds a kinematic value to a given state. By default, a new value is added as empty , otherwise it is necessary to pass label of reference joint as the third parameters and set of { -key value } according type, conteined in the joint.
+
+The following syntax of {-key value} is used:
+* -[first_/second_]rotation - current rotation - 1 number
+* -[first_/second_]translation - current translation - 1 number
+* -[first_/second_]point_on_surface - current (u,v) - 2 numbers
+* -[first_/second_]point_on_curve - current (t) - 1 number
+* -ypr - current yaw pitch roll angles - 3 numbers
+* -trsf - for unconstrained only current location direction xdirection - 9 numbers
+
+**Example:**
+~~~~~
+XAddPairValues D 0:11:1:3:1
+== 0:11:1:3:1:1
+~~~~~
+
+@subsubsection occt_draw_8_10_36 XSetPairValues
+
+Syntax:
+~~~~~
+XSetPairValues <document> <valueLabel> <jointLabel> <-key1 values1> ... <-keyN valuesN>
+~~~~~
+
+Sets a reference between a kinematic value and kinematic joint and sets parametr(s) of the kinematic value.
+
+The following syntax of {-key value} is used:
+* -[first_/second_]rotation - current rotation - 1 number
+* -[first_/second_]translation - current translation - 1 number
+* -[first_/second_]point_on_surface - current (u,v) - 2 numbers
+* -[first_/second_]point_on_curve - current (t) - 1 number
+* -ypr - current yaw pitch roll angles - 3 numbers
+* -trsf - for unconstrained only current location direction xdirection - 9 numbers
+
+**Example:**
+~~~~~
+XSetPairValues D 0:11:1:3:1:1 0:11:1:2:1 -first_point_on_surface 1.5 -second_point_on_curve 7
+~~~~~
+
+@subsubsection occt_draw_8_10_37 XGetPairValues
+
+Syntax:
+~~~~~
+XGetPairValues <document> <valueLabel> <-key>
+~~~~~
+
+Prints parameter of the kinematic value according kinematic type.
+
+The following syntax of <i>\<-key\></i> is used:
+* -[first_/second_]rotation - current rotation
+* -[first_/second_]translation - current translation
+* -[first_/second_]point_on_surface - current (u,v)
+* -[first_/second_]point_on_curve - current (t)
+* -ypr - current yaw pitch roll angles
+* -trsf - for unconstrained only current location direction xdirection
+
+**Example:**
+~~~~~
+XGetPairValues D 0:11:1:3:1:1 -rotation
+== 1
+~~~~~
+
+@subsubsection occt_draw_8_10_37 XRemovePairValues
+
+Syntax:
+~~~~~
+XRemovePairValues <document> <valueLabel>
+~~~~~
+
+Removes a kinematic value from a document (by it’s label).
+
+**Example:**
+~~~~~
+XRemovePairValues D 0:11:1:3:1:1
+~~~~~
+
+
+
@section occt_draw_9 Shape Healing commands
@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).
+All kinematic data is divided onto mechanisms each mechanism has its graph of links (references to shapes), joints (kinematic pair information) and (optional) states(sets of kinematic values).
Each joint corresponds to one kinematic pair from the list:
* Low order pairs
- fully constrained pair (no DOF);
- screw pair;
- rack and pinion pair;
- gear pair;
+ - linear flexible and pinion 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.
+ - rolling curve pair;
+ - linear flexible and planar curve pair.
The kinematic pair information consists of
* parameters;
* limits (optional);
* current position (optional).
+The kinematic value consist of
+* reference to joint;
+* paramters;
+
All mentioned data depends on the kinematic pair type.
@section occt_xde_2 Working with XDE
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.
+Here is an example of creating a new mechanism and adding a new joint with two links:
+~~~~~
+Handle(XCAFDoc_KinematicTool) myKTool = ...
+TDF_Label aMechaism = myKTool->AddMechanism();
+TDF_Label aStartShape = ...
+TDF_Label aLink1 = myKTool->AddLink(aMechaism, aStartShape); // start link of joint
+TDF_Label aEndShape = ...
+TDF_Label aLink2 = myKTool->AddLink(aMechaism, aEndShape); // end link of joint
+TDF_Label aJoint = myKTool->AddJoint(aMechaism, aLink1, aLink2).
+~~~~~
+
+(Optional) the state label contains pair values to each kinematic joint within the kinematic mechanism.
+You can create new state with the empty kinematic value of joint, use:
+~~~~~
+Handle(XCAFDoc_KinematicTool) myKTool = ...
+TDF_Label aMechaism = myKTool->AddMechanism();
+TDF_Label aJoint = ...
+TDF_Label aState = myKTool->AddState(aMechanism);
+TDF_Label aValue = myKTool->AddValue(aState).
+~~~~~
+
+**Note** Any mechanism has a base link. By default, the end link of the first joint is the base of the mechanism.
+You can specify any link as basic, use:
+~~~~~
+TDF_Label aLink2 = myKTool->AddLink(aMechaism, aEndShape, Standard_True); // if base link exist, old base loses specification.
+~~~~~
+
@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)*.
+Commands to check that created labels are valid:
+- *IsMechanism* : checking for main labels of links and joints;
+- *IsLink* : checking for references to shape of the given link;
+- *IsJoint* : checking for references to end and start link of the given joint;
+- *IsValue* : checking for conteined assigning data.
+
+To retrieve current graph state use the next methods:
+- *GetMechanisms* : retrieves all mechanisms labels;
+- *GetStates* : retrieves all state labels of the given mechanism;
+- *GetValuesOfState* : retrieves all references to values labels of the given state;
+- *GetStateOfValue* : retrieves the state label of the given value;
+- *GetLinks* : retrieves all links labels of the given mechanism;
+- *GetJoints* : retrieves all joint labels of the given mechanism;
+- *GetLinksOfJoint* : retrieves two references to links labels of the given joint;
+- *GetJointOfLink* : retrieves all references to joint labels of the given link;
+- *GetValuesOfJoint* : retrieves all references to value labels of the given joint;
+- *GetJointOfValue* : retrieves the joint label of the given value;
+- *GetRefShapes* : retrieves all references to shape labels of the given **link**.
@subsubsection occt_xde_2_11_3 Editing
-To change links's referred shapes use *SetLink*.
-To change joint's referred links use *SetJoint*.
+To change links's referred shapes use:
+~~~~~
+Handle(XCAFDoc_KinematicTool) myKTool = ...
+TDF_Label aLink = ...
+TDF_Label aShape = ... // or TDF_LabelSequence aShape
+aKTool->*SetLink*(aLink, aShape).
+~~~~~
+
+To change joint's referred links use:
+~~~~~
+Handle(XCAFDoc_KinematicTool) myKTool = ...
+aKTool->*SetJoint*(aJointLabel, aLink1Label, aLink2Label).
+~~~~~
@subsubsection occt_xde_2_11_4 Deleting
-All kinematic data can be removed by *RemoveLink*, *RemoveJoint* and *RemoveMechanism* commands.
+All kinematic data can be removed use the next methods:
+- *RemoveLink* : removes the given link and all joints reference to it;
+- *RemoveJoint* : removes the given joint;
+- *RemoveMechanism* : removes the given mechanism with all its childrens;
+- *RemoveState* : removes the given state with all its values;
+- *RemoveValue* : removes the given value.
@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.
-
+Set pair data:
~~~~~
// Create an object according to necessary type (LowOrder/LowOrderWithCoupling/HighOrder)
XCAFKinematics_PairObject anObject = new XCAFKinematics_PairObject();
aPair->SetObject(anObject);
~~~~~
-Get data.
+(Optional) set kinematic value data:
+~~~~~
+// Create an object according to necessary type (RevolutePair, PrismaticPair, ...)
+Handle(StepKinematics_PairValue) aValueObject = new StepKinematics_PairValue;
+// Fill parameters according type
+...
+// Add attribute
+Handle(XCAFDoc_KinematicPairValue) aXCAFValue = XCAFDoc_KinematicPairValue::Set(aValueLabel, aJointLabel);
+aXCAFValue->SetObject(aValueObject);
+~~~~~
+
+Get pair data:
~~~~~
// Get attribute from the label
Handle(XCAFDoc_KinematicPair) aPair;
}
~~~~~
+(Optional) get kinematic value data:
+~~~~~
+// Get attribute from the label
+Handle(XCAFDoc_KinematicPairValue) aPairValue;
+if (aValueLabel.FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aPairValue)) {
+ Handle(XCAFKinematics_PairValueObject) aPairValueObject = aPairValue->GetObject();
+}
+~~~~~
+
@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.
return Standard_True;
case 719:
return Standard_True;
- case 796:
- return Standard_True;
default:
return Standard_False;
}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <RWStepKinematics_RWActuatedKinematicPair.hxx>
#include <Interface_Check.hxx>
#include <Interface_EntityIterator.hxx>
#include <RWStepKinematics_RWActuatedKinPairAndOrderKinPair.hxx>
-#include <StepBasic_MeasureWithUnit.hxx>
#include <StepData_StepReaderData.hxx>
#include <StepData_StepWriter.hxx>
#include <StepKinematics_ActuatedKinPairAndOrderKinPair.hxx>
#include <StepKinematics_UnconstrainedPairValue.hxx>
#include <StepKinematics_UniversalPair.hxx>
#include <StepKinematics_UniversalPairWithRange.hxx>
-#include <RWStepKinematics_RWPrismaticPairWithRange.hxx>
//=======================================================================
//function : RWStepDimTol_RWGeoTolAndGeoTolWthMod
#include <StepRepr_PropertyDefinitionRepresentation.hxx>
#include <StepRepr_Representation.hxx>
#include <StepRepr_RepresentationItem.hxx>
-#include <StepRepr_Transformation.hxx>
#include <StepRepr_HArray1OfRepresentationItem.hxx>
#include <StepRepr_RepresentationMap.hxx>
#include <StepRepr_RepresentationRelationship.hxx>
#include <StepRepr_ReprItemAndLengthMeasureWithUnitAndQRI.hxx>
#include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnit.hxx>
#include <StepRepr_ReprItemAndPlaneAngleMeasureWithUnitAndQRI.hxx>
-#include <StepRepr_ShapeRepresentationRelationshipWithTransformation.hxx>
#include <StepRepr_SequenceOfRepresentationItem.hxx>
#include <StepRepr_ShapeAspect.hxx>
#include <StepRepr_ShapeAspectDerivingRelationship.hxx>
#include <StepVisual_TessellatedItem.hxx>
#include <StepVisual_TessellatedGeometricSet.hxx>
#include <StepVisual_TessellatedCurveSet.hxx>
+#include <StepVisual_CoordinatesList.hxx>
+// Start Added for kinematics implementation
#include <StepKinematics_KinematicJoint.hxx>
#include <StepKinematics_KinematicLink.hxx>
#include <StepKinematics_PairValue.hxx>
#include <StepKinematics_KinematicLinkRepresentationAssociation.hxx>
#include <StepKinematics_ActuatedKinematicPair.hxx>
#include <StepKinematics_RigidLinkRepresentation.hxx>
-#include <StepKinematics_KinematicTopologyStructure.hxx>
-#include <StepShape_Vertex.hxx>
#include <XCAFKinematics_PairValueObject.hxx>
#include <StepKinematics_KinematicLinkRepresentation.hxx>
#include <StepKinematics_ProductDefinitionKinematics.hxx>
#include <StepKinematics_SuParameters.hxx>
-#include <NCollection_Vector.hxx>
#include <StepKinematics_ContextDependentKinematicLinkRepresentation.hxx>
#include <StepKinematics_KinematicLinkRepresentationAssociation.hxx>
#include <StepKinematics_ProductDefinitionRelationshipKinematics.hxx>
-//
#include <StepKinematics_CylindricalPair.hxx>
#include <StepKinematics_CylindricalPairWithRange.hxx>
#include <StepKinematics_FullyConstrainedPair.hxx>
#include <XCAFKinematics_LowOrderPairObject.hxx>
#include <XCAFKinematics_LowOrderPairObjectWithCoupling.hxx>
#include <XCAFKinematics_HighOrderPairObject.hxx>
-
#include <StepKinematics_SlidingSurfacePairValue.hxx>
#include <StepKinematics_RollingSurfacePairValue.hxx>
#include <StepKinematics_RevolutePairValue.hxx>
#include <StepKinematics_LinearFlexibleAndPlanarCurvePair.hxx>
#include <StepKinematics_ActuatedKinPairAndOrderKinPair.hxx>
#include <StepKinematics_MechanismStateRepresentation.hxx>
+// End Added for kinematics implementation
-
+#include <NCollection_Vector.hxx>
#include <TColgp_HArray1OfXYZ.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepTools.hxx>
if (aShapes.Length() == 0)
return Standard_False;
- theLink = aKTool->AddLink(theMechanism, aShapes, theIsBase);
+ theLink = aKTool->AddLink(theMechanism, aShapes, theIsBase);
+ if (theLink.IsNull())
+ return Standard_False;
if (!aLink->Name()->IsEmpty())
TDataStd_Name::Set(theLink, aLink->Name()->String());
- if (theLink.IsNull())
- return Standard_False;
theMapOfLinks.Bind(theLinkRepresentation, theLink);
return Standard_True;
}
if (aPairType == XCAFKinematics_PairType_NoType)
return Standard_False;
aValueObject->SetType(aPairType);
- TDF_TagSource aTag;
- TDF_Label aValueL = aTag.NewChild(theState);
+ TDF_Label aValueL = aKTool->AddValue(theState);
+ if (aValueL.IsNull())
+ return Standard_False;
// Low order pairs
if (theValue->IsKind(STANDARD_TYPE(StepKinematics_RevolutePairValue)))
TDataStd_Name::Set(aMechanism, aKMR->Name()->String());
//Collecting Links and labels of Links
- NCollection_DataMap<Handle(StepKinematics_KinematicLinkRepresentation), TDF_Label> theMapOfLinks;
+ NCollection_DataMap<Handle(StepKinematics_KinematicLinkRepresentation), TDF_Label> aMapOfLinks;
//read base link
if (!aKPMR->Base().IsNull())
{
TDF_Label aLableOfBaseLink;
- addLinkWithShapes(theWS, theDoc, aKPMR->Base(), aMechanism, theShapeLabelMap, aLableOfBaseLink, theMapOfLinks, Standard_True);
+ addLinkWithShapes(theWS, theDoc, aKPMR->Base(), aMechanism, theShapeLabelMap, aLableOfBaseLink, aMapOfLinks, Standard_True);
}
//read joints with their links
- NCollection_DataMap<Handle(StepKinematics_KinematicJoint), TDF_Label> theMapOfJoints;
+ NCollection_DataMap<Handle(StepKinematics_KinematicJoint), TDF_Label> aMapOfJoints;
for (Standard_Integer aPairIndex = 1; aPairIndex <= aKMR->NbItems(); ++aPairIndex)
{
if (!aKMR->ItemsValue(aPairIndex)->IsKind(STANDARD_TYPE(StepKinematics_PairRepresentationRelationship)))
Handle(StepKinematics_PairRepresentationRelationship) aPRR =
Handle(StepKinematics_PairRepresentationRelationship)::DownCast(aKMR->ItemsValue(aPairIndex));
if (aPRR.IsNull()) continue;
- Handle(StepKinematics_KinematicPair) aKinematicPair
- = Handle(StepKinematics_KinematicPair)::DownCast(aPRR->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair());
+ Handle(StepKinematics_KinematicPair) aKinematicPair = aPRR->RepresentationRelationshipWithTransformation()->TransformationOperator().KinematicPair();
if (aKinematicPair.IsNull())
continue;
//find joint & links
if (aLinkRepresentation1.IsNull() || aLinkRepresentation2.IsNull())
continue;
TDF_Label aJoint, aLink1, aLink2;
- if (!addLinkWithShapes(theWS, theDoc, aLinkRepresentation1, aMechanism, theShapeLabelMap, aLink1, theMapOfLinks))
+ if (!addLinkWithShapes(theWS, theDoc, aLinkRepresentation1, aMechanism, theShapeLabelMap, aLink1, aMapOfLinks))
continue;
- if (!addLinkWithShapes(theWS, theDoc, aLinkRepresentation2, aMechanism, theShapeLabelMap, aLink2, theMapOfLinks))
+ if (!addLinkWithShapes(theWS, theDoc, aLinkRepresentation2, aMechanism, theShapeLabelMap, aLink2, aMapOfLinks))
continue;
//Setting info
aJoint = aKTool->AddJoint(aMechanism, aLink1, aLink2);
continue;
setKinematicPairLimit(aKinematicPair, aPairObject);
aCAFKinPair->SetObject(aPairObject);
- theMapOfJoints.Bind(aKinematicJoint, aJoint);
+ aMapOfJoints.Bind(aKinematicJoint, aJoint);
}
// (optional)
Handle(StepKinematics_KinematicJoint) aKinematicJoint = aValue->AppliesToPair()->Joint();
if (aKinematicJoint.IsNull())
continue;
- TDF_Label aJoint = theMapOfJoints.Find(aKinematicJoint);
+ TDF_Label aJoint = aMapOfJoints.Find(aKinematicJoint);
setKinematicPairValue(theWS, theDoc, aKinematicJoint, aValue, aState, aJoint);
}
}
#include <StepVisual_SurfaceStyleUsage.hxx>
#include <StepVisual_TessellatedAnnotationOccurrence.hxx>
#include <StepVisual_TessellatedGeometricSet.hxx>
-
+// Start Added for kinematics implementation
#include <StepKinematics_KinematicJoint.hxx>
#include <StepKinematics_KinematicLink.hxx>
+#include <StepKinematics_LinearFlexibleLinkRepresentation.hxx>
#include <StepKinematics_PairValue.hxx>
#include <StepKinematics_KinematicPropertyMechanismRepresentation.hxx>
#include <StepKinematics_MechanismRepresentation.hxx>
#include <StepKinematics_KinematicPair.hxx>
#include <StepKinematics_KinematicJoint.hxx>
#include <StepKinematics_PairValue.hxx>
-#include <XCAFDoc_KinematicPairValue.hxx>
#include <StepKinematics_KinematicLink.hxx>
-#include <XCAFDoc_KinematicTool.hxx>
-#include <XCAFKinematics_PairObject.hxx>
#include <StepKinematics_KinematicLinkRepresentationAssociation.hxx>
#include <StepKinematics_ActuatedKinematicPair.hxx>
#include <StepKinematics_RigidLinkRepresentation.hxx>
#include <StepKinematics_KinematicTopologyStructure.hxx>
#include <StepShape_Vertex.hxx>
-#include <XCAFKinematics_PairValueObject.hxx>
#include <StepKinematics_KinematicLinkRepresentation.hxx>
#include <StepKinematics_ProductDefinitionKinematics.hxx>
-#include <StepKinematics_SuParameters.hxx>
-#include <NCollection_Vector.hxx>
#include <StepKinematics_ContextDependentKinematicLinkRepresentation.hxx>
#include <StepKinematics_KinematicLinkRepresentationAssociation.hxx>
#include <StepKinematics_ProductDefinitionRelationshipKinematics.hxx>
-
#include <StepKinematics_CylindricalPair.hxx>
#include <StepKinematics_CylindricalPairWithRange.hxx>
#include <StepKinematics_FullyConstrainedPair.hxx>
#include <StepKinematics_UnconstrainedPairValue.hxx>
#include <StepKinematics_UniversalPair.hxx>
#include <StepKinematics_UniversalPairWithRange.hxx>
-#include <XCAFKinematics_LowOrderPairObject.hxx>
-#include <XCAFKinematics_LowOrderPairObjectWithCoupling.hxx>
-#include <XCAFKinematics_HighOrderPairObject.hxx>
-
#include <StepKinematics_SlidingSurfacePairValue.hxx>
#include <StepKinematics_RollingSurfacePairValue.hxx>
#include <StepKinematics_RevolutePairValue.hxx>
#include <StepKinematics_ActuatedKinPairAndOrderKinPair.hxx>
#include <StepKinematics_MechanismStateRepresentation.hxx>
+#include <XCAFKinematics_LowOrderPairObjectWithCoupling.hxx>
+#include <XCAFKinematics_HighOrderPairObject.hxx>
+#include <XCAFKinematics_LowOrderPairObject.hxx>
+#include <XCAFKinematics_PairValueObject.hxx>
+#include <XCAFKinematics_PairObject.hxx>
+#include <XCAFKinematics_PairObject.hxx>
+#include <XCAFKinematics_PairType.hxx>
+#include <XCAFDoc_KinematicPairValue.hxx>
+#include <XCAFDoc_KinematicTool.hxx>
+#include <XCAFDoc_KinematicPair.hxx>
+// End Added for kinematics implementation
+
#include <TCollection_AsciiString.hxx>
#include <TCollection_HAsciiString.hxx>
#include <TColStd_HArray1OfReal.hxx>
#include <TransferBRep.hxx>
#include <TransferBRep_ShapeMapper.hxx>
#include <XCAFDimTolObjects_DatumObject.hxx>
-#include <XCAFKinematics_PairObject.hxx>
-#include <XCAFKinematics_PairValueObject.hxx>
-#include <XCAFKinematics_PairType.hxx>
-#include <XCAFKinematics_HighOrderPairObject.hxx>
-#include <XCAFKinematics_LowOrderPairObject.hxx>
-#include <XCAFKinematics_LowOrderPairObjectWithCoupling.hxx>
-#include <XCAFDoc_KinematicTool.hxx>
-#include <XCAFDoc_KinematicPairValue.hxx>
-#include <XCAFDoc_KinematicPair.hxx>
#include <XCAFDimTolObjects_DimensionFormVariance.hxx>
#include <XCAFDimTolObjects_DimensionGrade.hxx>
#include <XCAFDimTolObjects_DimensionObject.hxx>
const Handle(XCAFDoc_KinematicTool)& theKTool,
const Interface_Graph& theGraph,
const TDF_Label& theLabelLink,
+ Handle(StepKinematics_KinematicLinkRepresentation)& theLinkRepresentation,
Handle(StepKinematics_KinematicLink)& theLink,
Handle(StepShape_ShapeRepresentation)& theShapeRepr,
Handle(StepRepr_PropertyDefinition)& thePDS)
return Standard_False;
}
+ //Choose type of the representation link
+ TDF_LabelSequence aJoints = theKTool->GetJointsOfLink(theLabelLink,Standard_True,Standard_False);
+ Standard_Boolean isLinear = Standard_False;
+ for (Standard_Integer anIndOfJoint = 1; anIndOfJoint <= aJoints.Length(); ++anIndOfJoint)
+ {
+ Handle(XCAFDoc_KinematicPair) aKPairAttr;
+ if (!aJoints(anIndOfJoint).FindAttribute(XCAFDoc_KinematicPair::GetID(), aKPairAttr))
+ continue;
+ Handle(XCAFKinematics_PairObject) aPairObject = aKPairAttr->GetObject();
+ if (aPairObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPinion ||
+ aPairObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve)
+ isLinear = Standard_True;
+ else if(isLinear)
+ return Standard_False;
+ }
+ if (isLinear)
+ theLinkRepresentation = new StepKinematics_LinearFlexibleLinkRepresentation;
+ else
+ theLinkRepresentation = new StepKinematics_RigidLinkRepresentation;
+
// get PDS of Shape
Interface_EntityIterator anIter = theGraph.Sharings(seqRI.Value(1));
for (anIter.Start(); anIter.More() && thePDS.IsNull(); anIter.Next()) {
const Interface_Graph& theGraph,
const TDF_Label& theLabelJoint,
const Handle(XCAFKinematics_PairObject)& theKinPairObj,
- const NCollection_DataMap<TDF_Label, Handle(StepKinematics_RigidLinkRepresentation), TDF_LabelMapHasher>& theMapOfLinks,
- Handle(StepKinematics_RigidLinkRepresentation)& theRigLinkRepr1,
- Handle(StepKinematics_RigidLinkRepresentation)& theRigLinkRepr2,
+ const NCollection_IndexedDataMap<TDF_Label, Handle(StepKinematics_KinematicLinkRepresentation), TDF_LabelMapHasher>& theMapOfLinks,
+ Handle(StepKinematics_KinematicLinkRepresentation)& theLinkRepr1,
+ Handle(StepKinematics_KinematicLinkRepresentation)& theLinkRepr2,
Handle(StepKinematics_KinematicJoint)& theJoint)
{
TDF_Label aLinkStartL, aLinkEndL;
theKTool->GetLinksOfJoint(theLabelJoint, aLinkStartL, aLinkEndL);
Handle(TCollection_HAsciiString) aNameJoint = new TCollection_HAsciiString(theKinPairObj->Name());
- Handle(StepShape_Vertex) aEdgeStart;
- Handle(StepShape_Vertex) aEdgeEnd;
+ Handle(StepShape_Vertex) anEdgeStart;
+ Handle(StepShape_Vertex) anEdgeEnd;
- if (!theMapOfLinks.Find(aLinkStartL, theRigLinkRepr1))
+ if (!theMapOfLinks.FindFromKey(aLinkStartL, theLinkRepr1))
return Standard_False;
- if (!theMapOfLinks.Find(aLinkEndL, theRigLinkRepr2))
+ if (!theMapOfLinks.FindFromKey(aLinkEndL, theLinkRepr2))
return Standard_False;
- aEdgeStart = theRigLinkRepr1->RepresentedLink();
- aEdgeEnd = theRigLinkRepr2->RepresentedLink();
+ anEdgeStart = theLinkRepr1->RepresentedLink();
+ anEdgeEnd = theLinkRepr2->RepresentedLink();
- if (aEdgeEnd.IsNull() || aEdgeStart.IsNull())
+ if (anEdgeEnd.IsNull() || anEdgeStart.IsNull())
return Standard_False;
- theJoint->Init(aNameJoint, aEdgeStart, aEdgeEnd);
+ theJoint->Init(aNameJoint, anEdgeStart, anEdgeEnd);
return Standard_True;
}
static Standard_Boolean createKinematicPair(const Handle(XCAFKinematics_PairObject)& theKinPairObj,
const Handle(StepKinematics_KinematicJoint)& theJoint,
Handle(StepKinematics_KinematicPair)& theKinematicPair,
- Handle(StepKinematics_RigidLinkRepresentation)& theRigLinkRepr1,
- Handle(StepKinematics_RigidLinkRepresentation)& theRigLinkRepr2)
+ Handle(StepKinematics_KinematicLinkRepresentation)& theLinkRepr1,
+ Handle(StepKinematics_KinematicLinkRepresentation)& theLinkRepr2)
{
if (theKinPairObj->Type() == XCAFKinematics_PairType_NoType)
return Standard_False;
Handle(StepRepr_RepresentationItem) theTransformItem1 = GeomToStep_MakeAxis2Placement3d(theKinPairObj->FirstTransformation()).Value();
Handle(StepRepr_RepresentationItem) theTransformItem2 = GeomToStep_MakeAxis2Placement3d(theKinPairObj->SecondTransformation()).Value();
- theRigLinkRepr1->Items()->Resize(theRigLinkRepr1->Items()->Lower(), theRigLinkRepr1->Items()->Upper() + 1, Standard_True);
- theRigLinkRepr1->Items()->ChangeLast() = theTransformItem1;
+ theLinkRepr1->Items()->Resize(theLinkRepr1->Items()->Lower(), theLinkRepr1->Items()->Upper() + 1, Standard_True);
+ theLinkRepr1->Items()->ChangeLast() = theTransformItem1;
- theRigLinkRepr2->Items()->Resize(theRigLinkRepr2->Items()->Lower(), theRigLinkRepr2->Items()->Upper() + 1, Standard_True);
- theRigLinkRepr2->Items()->ChangeLast() = theTransformItem2;
+ theLinkRepr2->Items()->Resize(theLinkRepr2->Items()->Lower(), theLinkRepr2->Items()->Upper() + 1, Standard_True);
+ theLinkRepr2->Items()->ChangeLast() = theTransformItem2;
Standard_Boolean hasDescription = Standard_False;
Handle(TCollection_HAsciiString) aPairName = new TCollection_HAsciiString(theKinPairObj->Name());
Handle(TCollection_HAsciiString) aDescription;
- Standard_Boolean aHasRange = theKinPairObj->HasLimits();
+ Standard_Boolean isRanged = theKinPairObj->HasLimits();
if (theKinPairObj->IsKind(STANDARD_TYPE(XCAFKinematics_LowOrderPairObject)))
{
Handle(XCAFKinematics_LowOrderPairObject) aLowOrderPairObj = Handle(XCAFKinematics_LowOrderPairObject)::DownCast(theKinPairObj);
aTZ = Standard_False;
aRX = Standard_False;
aRY = Standard_False;
- if (aHasRange)
+ if (isRanged)
{
theKinematicPair = new StepKinematics_RevolutePairWithRange;
Standard_Real aLowerLimitActualRotation = aLowOrderPairObj->MinRotationZ();
aRX = Standard_False;
aRY = Standard_False;
aRZ = Standard_False;
- if (aHasRange)
+ if (isRanged)
{
theKinematicPair = new StepKinematics_PrismaticPairWithRange;
Handle(StepKinematics_PrismaticPairWithRange) aPrismaticPairWithRange = Handle(StepKinematics_PrismaticPairWithRange)::DownCast(theKinematicPair);
aTY = Standard_False;
aRX = Standard_False;
aRY = Standard_False;
- if (aHasRange)
+ if (isRanged)
{
theKinematicPair = new StepKinematics_CylindricalPairWithRange;
Handle(StepKinematics_CylindricalPairWithRange) aCylindricalPairWithRange = Handle(StepKinematics_CylindricalPairWithRange)::DownCast(theKinematicPair);
aTZ = Standard_False;
aRY = Standard_False;
Standard_Real theUniversalPair_InputSkewAngle = aLowOrderPairObj->SkewAngle();
- if (aHasRange)
+ if (isRanged)
{
theKinematicPair = new StepKinematics_UniversalPairWithRange;
Handle(StepKinematics_UniversalPairWithRange) anUniversalPairWithRange = Handle(StepKinematics_UniversalPairWithRange)::DownCast(theKinematicPair);
aTZ = Standard_False;
aRX = Standard_False;
aRY = Standard_False;
- if (aHasRange)
+ if (isRanged)
{
Standard_Real aUpperLimitYaw = aLowOrderPairObj->MaxRotationZ();
Standard_Real aLowerLimitYaw = aLowOrderPairObj->MinRotationZ();
aTX = Standard_False;
aTY = Standard_False;
aTZ = Standard_False;
- if (aHasRange)
+ if (isRanged)
{
Standard_Real aUpperLimitYaw = aLowOrderPairObj->MaxRotationZ();
Standard_Real aLowerLimitYaw = aLowOrderPairObj->MinRotationZ();
}
case(XCAFKinematics_PairType_Planar):
{
- if (aHasRange)
+ if (isRanged)
theKinematicPair = new StepKinematics_PlanarPairWithRange;
else
theKinematicPair = new StepKinematics_PlanarPair;
aTZ = Standard_False;
aRX = Standard_False;
aRY = Standard_False;
- if (aHasRange)
+ if (isRanged)
{
theKinematicPair = new StepKinematics_PlanarPairWithRange;
Handle(StepKinematics_PlanarPairWithRange) aPlanarPairWithRange = Handle(StepKinematics_PlanarPairWithRange)::DownCast(theKinematicPair);
case(XCAFKinematics_PairType_Screw):
{
Standard_Real aPitch = aLowOrderPairObjectWithCoupling->Pitch();
- if (aHasRange)
+ if (isRanged)
{
theKinematicPair = new StepKinematics_ScrewPairWithRange;
Handle(StepKinematics_ScrewPairWithRange) aScrewPairWithRange = Handle(StepKinematics_ScrewPairWithRange)::DownCast(theKinematicPair);
case(XCAFKinematics_PairType_RackAndPinion):
{
Standard_Real aPinionRadius = aLowOrderPairObjectWithCoupling->PinionRadius();
- if (aHasRange)
+ if (isRanged)
{
theKinematicPair = new StepKinematics_RackAndPinionPairWithRange;
Standard_Real aLowLimit = aLowOrderPairObjectWithCoupling->LowLimit();
Standard_Real aHelicalAngle = aLowOrderPairObjectWithCoupling->HelicalAngle();
Standard_Real aRadiusFirstLink = aLowOrderPairObjectWithCoupling->RadiusFirstLink();;
Standard_Real aRadiusSecondLink = aLowOrderPairObjectWithCoupling->RadiusSecondLink();;
- if (aHasRange)
+ if (isRanged)
{
Standard_Real aLowLimit = aLowOrderPairObjectWithCoupling->LowLimit();
Standard_Real aUpperLimit = aLowOrderPairObjectWithCoupling->UpperLimit();
{
case(XCAFKinematics_PairType_PointOnSurface):
{
- if (aHasRange)
+ if (isRanged)
{
GeomToStep_MakeSurface aMaker(aHighOrderPairObject->Surface());
Handle(StepGeom_Surface) aPairSurface = aMaker.Value();
GeomToStep_MakeCurve aMaker(aHighOrderPairObject->Curve());
Handle(StepGeom_Curve) aPairCurve = aMaker.Value();
Standard_Boolean anOrientation = aHighOrderPairObject->Orientation();
- if (aHasRange)
+ if (isRanged)
{
Standard_Real aLowerLimitYaw = aHighOrderPairObject->LowLimitYaw();
Standard_Real aUpperLimitYaw = aHighOrderPairObject->UpperLimitYaw();
case(XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve):
{
theKinematicPair = new StepKinematics_LinearFlexibleAndPlanarCurvePair;
- GeomToStep_MakeCurve aMaker(aHighOrderPairObject->Curve());
+ GeomToStep_MakeCurve aMaker(aHighOrderPairObject->FirstCurve());
Handle(StepGeom_Curve) aPairCurve = aMaker.Value();
Standard_Boolean anOrientation = aHighOrderPairObject->Orientation();
Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair) aLinearFlexibleAndPlanarCurvePair = Handle(StepKinematics_LinearFlexibleAndPlanarCurvePair)::DownCast(theKinematicPair);
TDF_LabelSequence aSeqOfLinskL = aKTool->GetLinks(aMechanismsL.Value(aMechInd));
if (aSeqOfLinskL.Length() <= 0)
continue;
- NCollection_DataMap<TDF_Label, Handle(StepKinematics_RigidLinkRepresentation), TDF_LabelMapHasher> aMapOfLinks;
+ NCollection_IndexedDataMap<TDF_Label, Handle(StepKinematics_KinematicLinkRepresentation), TDF_LabelMapHasher> aMapOfLinks;
for (Standard_Integer aLinkInd = 1; aLinkInd <= aSeqOfLinskL.Length(); aLinkInd++)
{
TDF_Label aLinkL = aSeqOfLinskL.Value(aLinkInd);
Handle(StepKinematics_KinematicLink) aLink;
Handle(StepShape_ShapeRepresentation) aRefShapeOfLink;
- Handle(StepRepr_PropertyDefinition) aPD;
- if (!createKinematicLink(FP, aKTool, aGraph, aLinkL, aLink, aRefShapeOfLink, aPD))
+ Handle(StepRepr_PropertyDefinition) aPD;
+ Handle(StepKinematics_KinematicLinkRepresentation) aLinkRepresentation;
+ if (!createKinematicLink(FP, aKTool, aGraph, aLinkL, aLinkRepresentation, aLink, aRefShapeOfLink, aPD))
continue;
Handle(StepRepr_RepresentationContext) aRepresentationContextOfLink = aRefShapeOfLink->ContextOfItems();
- Handle(StepKinematics_RigidLinkRepresentation) aLinkRepresentation = new StepKinematics_RigidLinkRepresentation;
+
Handle(TCollection_HAsciiString) aNameOfLinkRepr = new TCollection_HAsciiString("");
Handle(StepRepr_HArray1OfRepresentationItem) aPlacementsOfPairs = new StepRepr_HArray1OfRepresentationItem;
aLinkRepresentation->Init(aNameOfLinkRepr, aPlacementsOfPairs, aRepresentationContextOfLink, aLink);
- aMapOfLinks.Bind(aSeqOfLinskL(aLinkInd), aLinkRepresentation);
+ aMapOfLinks.Add(aSeqOfLinskL(aLinkInd), aLinkRepresentation);
Handle(TDataStd_Integer) aBase;
if (aBaseLinkOfMech.IsNull() && aLinkL.FindAttribute(TDataStd_Integer::GetID(), aBase))
- aBaseLinkOfMech = aLinkRepresentation;
+ aBaseLinkOfMech = Handle(StepKinematics_RigidLinkRepresentation)::DownCast(aLinkRepresentation);
Handle(StepKinematics_KinematicLinkRepresentationAssociation) aLinkRepresentationAssociation = new StepKinematics_KinematicLinkRepresentationAssociation;
aLinkRepresentationAssociation->Init(aNameOfLinkRepr, aNameOfLinkRepr, aLinkRepresentation, aRefShapeOfLink);
continue;
// if not found base link in OCAF
- // first link became base of the mechanism
- if (aBaseLinkOfMech.IsNull() && !aMapOfLinks.Find(aSeqOfLinskL(1), aBaseLinkOfMech))
+ // first rigid link became base of the mechanism
+ for (Standard_Integer anIndOfLink = 1; anIndOfLink <= aMapOfLinks.Size() && aBaseLinkOfMech.IsNull(); ++anIndOfLink)
+ aBaseLinkOfMech = Handle(StepKinematics_RigidLinkRepresentation)::DownCast(aMapOfLinks.FindFromIndex(anIndOfLink));
+ if (aBaseLinkOfMech.IsNull())
continue;
// write joints
if (!aJointL.FindAttribute(XCAFDoc_KinematicPair::GetID(), aKPairAttr))
continue;
Handle(XCAFKinematics_PairObject) aPairObject = aKPairAttr->GetObject();
- Handle(StepKinematics_RigidLinkRepresentation) aRigLinkRepr1;
- Handle(StepKinematics_RigidLinkRepresentation) aRigLinkRepr2;
- if (!createKinematicJoint(FP, aKTool, aGraph, aJointL, aPairObject, aMapOfLinks, aRigLinkRepr1, aRigLinkRepr2, aJoint))
+ Handle(StepKinematics_KinematicLinkRepresentation) aLinkRepr1;
+ Handle(StepKinematics_KinematicLinkRepresentation) aLinkRepr2;
+ if (!createKinematicJoint(FP, aKTool, aGraph, aJointL, aPairObject, aMapOfLinks, aLinkRepr1, aLinkRepr2, aJoint))
continue;
- if (!createKinematicPair(aPairObject,aJoint,aKinematicPair, aRigLinkRepr1, aRigLinkRepr2))
+ if (!createKinematicPair(aPairObject,aJoint,aKinematicPair, aLinkRepr1, aLinkRepr2))
continue;
aMapofJoints.Add(aSeqOfJointsL(aJointInd), aJoint);
Handle(StepKinematics_PairRepresentationRelationship) aPairReprRelationship = new StepKinematics_PairRepresentationRelationship;
StepRepr_RepresentationOrRepresentationReference aDataLinkStart;
- aDataLinkStart.SetValue(aRigLinkRepr1);
+ aDataLinkStart.SetValue(aLinkRepr1);
StepRepr_RepresentationOrRepresentationReference aDataLinkEnd;
- aDataLinkEnd.SetValue(aRigLinkRepr2);
+ aDataLinkEnd.SetValue(aLinkRepr2);
StepRepr_Transformation aPair;
aPair.SetValue(aKinematicPair);
- aPairReprRelationship->Init(aKinematicPair->Name(), aKinematicPair->Name(), Standard_False, aKinematicPair->Name(), aDataLinkStart, aDataLinkEnd, aPair);
+ Handle(TCollection_HAsciiString) aDescription;
+ aPairReprRelationship->Init(aKinematicPair->Name(), aKinematicPair->Name(), Standard_False, aDescription, aDataLinkStart, aDataLinkEnd, aPair);
anArrayOfPairs->SetValue(aJointInd, aPairReprRelationship);
Model->AddEntity(aJoint);
Handle(TDataStd_Name) aNameAttr;
if (aSeqOfValues(aValueInd).FindAttribute(TDataStd_Name::GetID(), aNameAttr))
aNameOfValue = new TCollection_HAsciiString(aNameAttr->Get());
- if (!aSeqOfValues(aValueInd).FindAttribute(XCAFDoc_KinematicPairValue::GetID(), aKPairValueAttr))
- continue;
Handle(XCAFKinematics_PairValueObject) aPairValueObject = aKPairValueAttr->GetObject();
Handle(StepKinematics_PairValue) aPairValue;
if (!createKinematicPairValue(aPairValueObject, aPairReprRelationship, aPairValue))
Standard_EXPORT Standard_Boolean GetKinematicsMode() const;
-
-
protected:
//! Mehod to writing sequence of root assemblies or part of the file specified by use by one label
Standard_EXPORT Standard_Boolean Transfer (const TDF_LabelSequence& L, const STEPControl_StepModelType mode = STEPControl_AsIs, const Standard_CString multi = 0);
CD65A782-448C-4935-8499-2210D970C175: Kinematics attributes
35FF1462-E684-465F-B0B9-5CAD14B5018F
6AA96F91-7436-46F9-A955-4B3CCC42592B
+596B048C-A965-4514-A059-464560BFAE4E
89FB0996-A8B8-4085-87A9-63AB5D56D8C1
8A9E9B60-7CA1-45F1-882A-42390D4DB894
6BE4AAD0-36BE-4D17-B65C-0B2062E04D92
TNaming_Builder aTNBuild(Label().FindChild(ChildLab_FirstGeomParam));
aTNBuild.Generated(anEdge);
}
- if (theObject->Type() >= XCAFKinematics_PairType_SlidingCurve &&
- theObject->Type() <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve)
+ if (anObject->Type() == XCAFKinematics_PairType_SlidingCurve ||
+ anObject->Type() == XCAFKinematics_PairType_RollingCurve)
{
TopoDS_Edge anEdge1, anEdge2;
if (!anObject->FirstCurve().IsNull()) {
aTNBuild2.Generated(anEdge2);
}
}
+ if (anObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve)
+ {
+ TopoDS_Edge anEdge;
+ if (!anObject->FirstCurve().IsNull()) {
+ aBuilder.MakeEdge(anEdge, anObject->FirstCurve(), Precision::Confusion());
+ TNaming_Builder aTNBuild1(Label().FindChild(ChildLab_FirstGeomParam));
+ aTNBuild1.Generated(anEdge);
+ }
+ }
}
}
aDefObject->SetCurve(BRep_Tool::Curve(anEdge, aFirst, aLast));
}
}
- if (anObject->Type() >= XCAFKinematics_PairType_SlidingCurve &&
- anObject->Type() <= XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve)
+ if (anObject->Type() == XCAFKinematics_PairType_SlidingCurve ||
+ anObject->Type() == XCAFKinematics_PairType_RollingCurve)
{
if (Label().FindChild(ChildLab_FirstGeomParam).FindAttribute(TNaming_NamedShape::GetID(), aNS))
{
aDefObject->SetSecondCurve(BRep_Tool::Curve(anEdge, aFirst, aLast));
}
}
+ if (anObject->Type() == XCAFKinematics_PairType_LinearFlexibleAndPlanarCurve)
+ {
+ if (Label().FindChild(ChildLab_FirstGeomParam).FindAttribute(TNaming_NamedShape::GetID(), aNS))
+ {
+ TopoDS_Edge anEdge = TopoDS::Edge(TNaming_Tool::GetShape(aNS));
+ Standard_Real aFirst, aLast;
+ aDefObject->SetFirstCurve(BRep_Tool::Curve(anEdge, aFirst, aLast));
+ }
+ }
}
return anObject;
RemoveLink(aLinkIt.Value());
for (TDF_ChildIterator aJointIt(getRootOfJoints(theLabel)); aJointIt.More(); aJointIt.Next())
RemoveJoint(aJointIt.Value());
+ if (!getRootOfStates(theLabel).IsNull())
+ for (TDF_ChildIterator aStateIt(getRootOfStates(theLabel)); aStateIt.More(); aStateIt.Next())
+ RemoveState(aStateIt.Value());
theLabel.ForgetAllAttributes();
}
//function : GetJointsOfLink
//purpose :
//=======================================================================
-TDF_LabelSequence XCAFDoc_KinematicTool::GetJointsOfLink(const TDF_Label& theLink) const
+TDF_LabelSequence XCAFDoc_KinematicTool::GetJointsOfLink(const TDF_Label& theLink,
+ const Standard_Boolean& toFirst,
+ const Standard_Boolean& toSecond) const
{
TDF_LabelSequence aJointsArray;
if (!IsLink(theLink))
Handle(TDataStd_TreeNode) aNode, aChildNode;
- if (theLink.FindAttribute(XCAFDoc::KinematicRefLink1GUID(), aNode)) {
+ if (toFirst && theLink.FindAttribute(XCAFDoc::KinematicRefLink1GUID(), aNode)) {
aChildNode = aNode->First();
while (!aChildNode.IsNull()) {
aJointsArray.Append(aChildNode->Label());
}
}
- if (theLink.FindAttribute(XCAFDoc::KinematicRefLink2GUID(), aNode)) {
+ if (toSecond && theLink.FindAttribute(XCAFDoc::KinematicRefLink2GUID(), aNode)) {
aChildNode = aNode->First();
while (!aChildNode.IsNull()) {
aJointsArray.Append(aChildNode->Label());
return aState;
}
+//=======================================================================
+//function : AddValue
+//purpose :
+//=======================================================================
+TDF_Label XCAFDoc_KinematicTool::AddValue(const TDF_Label& theState)
+{
+ if(!IsMechanism(theState.Father().Father()) &&
+ theState.Father().Tag() != 3)
+ return TDF_Label();
+
+ return theState.NewChild();
+}
+
+//=======================================================================
+//function : RemoveValue
+//purpose :
+//=======================================================================
+void XCAFDoc_KinematicTool::RemoveValue(const TDF_Label& theValue)
+{
+ if (!IsValue(theValue))
+ return;
+
+ Handle(TDataStd_TreeNode) aNode;
+ theValue.FindAttribute(XCAFDoc::KinematicRefJointGUID(), aNode);
+ aNode->Remove();
+
+
+ theValue.ForgetAllAttributes();
+}
+
//=======================================================================
//function : GetStates
//purpose :
Handle(TDataStd_TreeNode) aNode;
TDF_LabelSequence aSeqOfValues = GetValuesOfState(theState);
for (Standard_Integer anInd = 1; anInd <= aSeqOfValues.Length(); ++anInd)
- {
- aSeqOfValues(anInd).FindAttribute(XCAFDoc::KinematicRefJointGUID(), aNode);
- aNode->Remove();
- aSeqOfValues(anInd).ForgetAllAttributes();
- }
+ RemoveValue(aSeqOfValues.Value(anInd));
theState.ForgetAllAttributes();
}
//! \return created state label
Standard_EXPORT TDF_Label AddState(const TDF_Label& theMechanism);
+ //! Adds new empty label for Value.
+ //! \param[in] theState parent state
+ //! \return created value label
+ Standard_EXPORT TDF_Label AddValue(const TDF_Label& theState);
+
+ //! Removes the given value
+ //! \param[in] theValue value to remove
+ Standard_EXPORT void RemoveValue(const TDF_Label& theValue);
+
// Retrieves all States labels of the given mechanism
//! \param[in] theMechanism parent mechanism
//! \return state set
//! Gets references to joints of the given link.
//! \param[in] theLink link to get
+ //! \param[in] toFirst take a reference first link of joint
+ //! \param[in] toSecond take a reference second link of joint
//! \return set of joints
- Standard_EXPORT TDF_LabelSequence GetJointsOfLink(const TDF_Label& theLink) const;
+ Standard_EXPORT TDF_LabelSequence GetJointsOfLink(const TDF_Label& theLink,
+ const Standard_Boolean& toFirst = Standard_True,
+ const Standard_Boolean& toSecond = Standard_True) const;
//! Gets reference shapes of the given link.
//! \param[in] theLink link to get
//! \return curve
Standard_EXPORT Handle(Geom_Curve) Curve() const;
- //! Sets curve attribute (only for SlidingCurve and RollingCurve)
+ //! Sets curve attribute (only for SlidingCurve, RollingCurve LinearAndFlexibleCurve)
//! \param[in] theCurve curve
Standard_EXPORT void SetFirstCurve(const Handle(Geom_Curve)& theCurve);
- //! Gets curve attribute (only for SlidingCurve and RollingCurve)
+ //! Gets curve attribute (only for SlidingCurve, RollingCurve LinearAndFlexibleCurve)
//! \return curve
Standard_EXPORT Handle(Geom_Curve) FirstCurve() const;
static Standard_Integer addLink(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc < 3) {
- di << "Use: XAddLink Doc ParentMechanism [-base] [shapeLabel1 .. shapeLabelN]\n";
+ di << "Use: XAddLink Doc ParentMechanism [-base] [shapeLabel1 ... shapeLabelN]\n";
return 1;
}
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";
+ di << "Use: XSetPairType Doc Joint Type[1, 21]\n";
return 1;
}
return 0;
}
+//=======================================================================
+//function : removeMechanismState
+//purpose :
+//=======================================================================
+static Standard_Integer removeMechanismState(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XRemoveMechanismState Doc State\n";
+ return 1;
+ }
+
+ Handle(TDocStd_Document) aDoc;
+ if (!getDocument(di, argv[1], aDoc))
+ return 1;
+
+ TDF_Label aState;
+ if (!getLabel(di, aDoc, argv[2], aState) && aState.Father().Tag() != 3)
+ return 1;
+
+ Handle(XCAFDoc_KinematicTool) aTool = XCAFDoc_DocumentTool::KinematicTool(aDoc->Main());
+ TDF_Label aMechanism = aState.Father().Father();
+ if(!aTool->IsMechanism(aMechanism))
+ return 1;
+
+ aTool->RemoveState(aState);
+ return 0;
+}
+
//=======================================================================
//function : addValues
//purpose :
return 0;
}
+//=======================================================================
+//function : removeValues
+//purpose :
+//=======================================================================
+static Standard_Integer removeValues(Draw_Interpretor& di, Standard_Integer argc, const char** argv)
+{
+ if (argc < 3) {
+ di << "Use: XRemovePairValues Doc Value\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 aValue;
+ if (!getLabel(di, aDoc, argv[2], aValue) && !aTool->IsValue(aValue))
+ return 1;
+
+ aTool->RemoveValue(aValue);
+ return 0;
+}
+
//=======================================================================
//function : dump
//purpose :
di.Add("XRemoveMechanism", "XRemoveMechanism Doc Label",
__FILE__, removeMechanism, g);
- di.Add("XAddLink", "XAddLink Doc ParentMechanism [-base] [shapeLabel1 .. shapeLabelN]",
+ di.Add("XAddLink", "XAddLink Doc ParentMechanism [-base] [shapeLabel1 ... shapeLabelN]",
__FILE__, addLink, g);
di.Add("XSetLink", "XSetLink Doc Link shapeLabel1 .. shapeLabelN",
di.Add("XGetPairName", "XGetPairName Doc Joint",
__FILE__, getName, g);
- di.Add("XSetPairType", "XSetPairType Doc Joint Type[0..19]"
+ di.Add("XSetPairType", "XSetPairType Doc Joint Type[0..21]"
"Values:\n"
"\t 0 type is absent\n"
"\t 1 FullyConstrained\n"
di.Add("XAddMechanismState", "XAddMechanismState Doc Mechanism",
__FILE__, addMechanismState, g);
+ di.Add("XRemoveMechanismState", "XRemoveMechanismState Doc State",
+ __FILE__, removeMechanismState, g);
+
di.Add("XAddPairValues", "XAddPairValues Doc State [Joint -Key1 Values1 -KeyN ValuesN]"
"\t-[first_/second_]rotation - current rotation - 1 number"
"\t-[first_/second_]translation - current translation - 1 number"
"\t-trsf - for unconstrained only current location direction xdirection - 9 numbers",
__FILE__, getValues, g);
+ di.Add("XRemovePairValues", "XRemovePairValues Doc Value",
+ __FILE__, removeValues, g);
+
di.Add("XDumpKinematics", "XDumpKinematics Doc",
__FILE__, dump, g);
}
else if (att->ID() == XCAFDoc::KinematicRefLink1GUID() || att->ID() == XCAFDoc::KinematicRefLink2GUID()){
type = "Kinematic Joint to Link";
}
+ else if (att->ID() == XCAFDoc::KinematicRefJointGUID()) {
+ type = "Kinematic Value to Joint";
+ }
else
return TCollection_AsciiString();