DG Kernel Documentation


Skip Navigation Links.
Skip Navigation LinksHome Page > API Reference > Model > Entities > IConstraint Search Documentation


IConstraint Interface

SetFreedom
GetFreedom
GetConstraint
Enable
IsEnabled

Every object in DInsight models have a constraint property, which can restrict movements of the object in different ways. IConstraint interface enables and disables constraints for  movements of the object it is implemented by. It also gives access to the geometry of the constraint. See remarks for SetFreedom and GetConstraint methods for more details.

IConstraint can be queried from the correspondent ISection interface.

See also Modal View Sample, Interface List.


HRESULT SetFreedom(int nMovementType, int nDims)

Parameters

nMovementType - [in] identifies the movement type. Valid values are: 1 for translation and 4 for rotation. See also remarks.

nDims - [in] New value for degree of freedom. See remarks.

Returns

DISP_E_PARAMNOTOPTIONAL if nMovementType or nDims is not one of the valid values.

S_OK in case of success.

Remarks:

This method will specify for movement  nMovementType ( translation or rotation ) degree of the freedom which will be allowed for movements of the object. 

Translation movements: 

Every object keeps its integer Degree of Freedom for Translations  and Translation Constraint Direction. Vector of Translation Constraint Direction can be accessed with GetConstraint() method of this interface. Meaning of Translation Constraint Direction depends on the current degree of freedom set with SetFreedom method.

Valid options for nDims in this case are: 

0 - no translations are allowed.
1 - translations are allowed only along the current Translation Constraint Direction.
2 - translations are allowed only in directions orthogonal to the Translation Constraint Direction.
3 - all translations are allowed. 
 
All other values are invalid for nDim in case of translations.

Rotation movements:

In addition to above properties every object keeps its Degree of Freedom for Rotations and Rotation Constraint Axis. 

Valid options for nDims in this case are: 

0 - no rotations are allowed.
1 - rotations are allowed only around the current Rotation Constraint Axis. 
2 - all rotations are allowed.

All other values are invalid for nDim in case of rotations.


HRESULT GetFreedom(int nMovementType, int *pnDims)

Parameters

nMovementType - [in] identifies the movement type. Valid values are: 1 for translation and 4 for rotation. See also remarks.

pnDims - [out] pointer  to the integer variable, which will receive the requested degree of freedom.

Return Values

S_OK in case of success.
 
Remarks:
 
Returns current degree of freedom for the requested movement type. See remarks for SetFreedom method.

HRESULT GetConstraint(int nMovementType, IAxis **ppIAxis)

Parameters

nMovementType - [in] identifies the movement type. Valid values are: 1 for translation and 4 for rotation. See also remarks.

IAxis **ppIAxis - [out] pointer to variable, which will receive pointer to IAxis interface implemented by the constraint of the requested type. See remarks. In case of translation only directional component is valid.

Return Values

S_OK in case of success.
Remarks:

This method gives access to geometry of the constraint. The result depends on the movement type and the current degree of freedom set for this type of movement. See also remarks for SetFreedom method.

Translation movements: 

When the current Degree of Freedom for Translations is 0 or 3 return from GetConstraint() is not valid. When the current Degree of Freedom for Translations is 1 or 2, directional component of the returned IAxis interface (Get/SetDirection methods) give access  to  Translation Constraint Direction. Location component of the IAxis is not valid.

Rotation movements:

When the current Degree of Freedom for Translations is 0 or 2 return from GetConstraint() is not valid. When the current Degree of Freedom for Translations is 1, returned IAxis interface is implemented by and hence gives access to Rotation Constraint Axis of the object.

See also IAxis interface

 


HRESULT Enable(bool bEnable)

Parameters

bEnable- [in] New value for the enabled flag.

Return Values

S_OK in case of success.

Remarks:
 
When the constraint is disabled it has no effect on the movements of the object. All constraints are disabled by default, but enabled during the operation which retrieves it from ISection

HRESULT IsEnabled(bool *pbEnabled)

Parameters

pbEnabled - [out] pointer to the Boolean variable, which will receive the current status of the enabled flag.

Return Values

S_OK in case of success.

Remarks:
 
Returns the current status of  of the enabled flag. When the constraint is disabled it has no effect on the movements of the object. All constraints are disabled by default, but enabled during the operation which retrieves it from ISection