Evaluating the constraint system

The main task of the three-dimensional geometric solver (see Geometric constraint satisfaction problem) is performed by the following function:

GCM_result GCM_Evaluate(GCM_system gSys)    

The function calculates the new state of geometry and distributes error codes to those constraints that cannot be satisfied. The function does not execute any calculation operations if all constraints are satisfied at the time when it is called.

GCM_Evaluate will return the GCM_RESULT_Ok code, if an efficient solution is found for all input constraints. Any other returned value means that the constraint system cannot be entirely satisfied. So, the returned GCM_Evaluate value means either a success or a diagnostic code of one of the unsolved constraints or another code indicating the reason for the failed solution. Diagnostic codes are described in Diagnostic codes of a solution.

After the GCM_Evaluate call, each geometric constraint is assigned a diagnostic status. You can retrieve it using the following call:

GCM_result GCM_EvaluationResult(GCM_system gSys, GCM_constraint cItem)

The call will output one of the following values for each constraint:

  • GCM_RESULT_None means that the constraint status is not defined, i.e. the constraint has not been calculated yet.

  • GCM_RESULT_Satisfied means that the constraint has been solved;

  • GCM_RESULT_Overconstrained means that the constraint is part of a group of conflicting constraints that cannot be all satisfied simultaneously. Generally, you can fix the situation by removing one of the constraints;

  • GCM_RESULT_Not_Satisfied means that the constraint is not satisfied (in the event when the cause of a failed solution cannot be identified);

  • GCM_RESULT_Unsolvable means that the constraint cannot be solved. Possible reasons: conflicting constraints, no required constraints to position objects (for example, in a cam mechanism), poor initial approximation;

  • GCM_RESULT_IncompatibleArguments means that the constraint is not applicable to objects with these geometry types. For example, it is impossible to implement the coincidence of a plane and a cylinder;

See Diagnostic codes of a solution for all GCM_result values.

Calling GCM_Evaluate changes the state of geometric objects. To make it possible for the application to apply the results of calculations, you need to use the GCM_Placement function to request LCS values that position objects. Function

MbPlacement3D GCM_Placement(GCM_system gSys, GCM_geom g)    

returns the position (LCS) of a geometric object g based on the current state of the geometric model. We already mentioned in Reresentation of geometric objects that each geometric object has its own LCS, even if it is a primitive like a point. LCS is convenient, since we can use it to express positions of all types of objects, including not only solid bodies, but also simple objects, such as a point, line, and plane. Also a call GCM_Origin can be used to request a point of the LCS. It is convenient when we deal with non-orientable geometries such as point and sphere.

Another function, if applied to radial objects, such as a circle, sphere, or cylinder, will return the radius value:

double GCM_Radius(GCM_system gSys, GCM_geom g). 

Also, by calling the following functions:

double GCM_RadiusA(GCM_system gSys, GCM_geom g) 
double GCM_RadiusB(GCM_system gSys, GCM_geom g)

you can retrieve the major and the minor radii of a toroid or cone.

The application is capable not only of requesting the current geometry state but also changing it in the event of any modifications on the CAD model side that require synchronization of the geometric solver. For this purpose, the following call is used:

void GCM_SetPlacement(GCM_system gSys, GCM_geom g, const MbPlacement3D & place) 

The call changes the current LCS value of the object.

Source call data:

  • gSys – geometric constraint system;

  • g – geometric object descriptor;

  • place – new position (LCS) within the World Coordinate System.

Note that this function changes the object state without revaluating the constraint system. Using the GCM_Evaluate call, you can change the defined state if there are any constraints that cannot be satisfied.

At any moment, you can request each constraint if it is satisfied or not using the following function:

bool GCM_IsSatisfied(GCM_system gSys, GCM_constraint cItem) 

which will return true, if the cItem constraint is satisfied in the current geometry state. The result of the GCM_IsSatisfied call depends only on the current state of the constraint’s geometric arguments and is not related to its diagnostic status, returned using the GCM_EvaluationResult query.