Geometric constraint system
The geometric constraint system is a set of geometric objects mutually related by constraints and dimensions. Types of supported geometric objects and constraints can be found in paragraphs Supported geometry types, Supported constraint types, respectively. The geometric model created in an application is expected to have its own constraint system. From a software engineering viewpoint, this means that each model is associated with the constraint system using the GCM_system descriptor type, and each geometric object and constraint is represented by its unique descriptors of types GCM_geom and GCM_constraint.
Before proceeding to work with geometric constraints, declare a constraint system for the model by calling:
GCM_system GCM_CreateSystem()
The function returns the empty constraint system as the GCM_system descriptor, which is a pointer to internal data structure instance in the geometric solver. All further manipulations with the constraint system will be performed using this descriptor. For example, if you want to declare a point, call the following function for the created constraint system:
GCM_geom GCM_AddPoint(GCM_system gSys, MbCartPoint3D pVal)
The function returns a descriptor of the geometric point that belongs to the geometric constraint system gSys. The pVal parameter defines the start <x,y,z> coordinates of this point.
When you finish work with the geometric model, always call the function that deletes its constraint system:
void GCM_RemoveSystem(GCM_system gSys)
This function completely releases the memory occupied by the constraint system with all object and constraint data. After calling the GCM_RemoveSystem function, the constraint system descriptor becomes invalid, i.e. if you try to use the descriptor then the application might crash.
Function
void GCM_ClearSystem(GCM_system gSys)
clears the constraint system; it deletes objects and constraints only from the memory, but it keeps the constraint system valid for further work.
Also, by calling
bool GCM_ReadSystem(GCM_system gSys, reader & in)
you can save the constraint system to the file stream while, calling
bool GCM_WriteSystem(GCM_system gSys, writer & out)
you can restore the complete system state. The functions for saving and recovering from the stream ensure safe storage of descriptor values of all constraints and objects.
Warning! Read/write functions of the constraint system save only the data on objects and constraints that are loaded onto C3D Solver. All source data on objects and model constraints are stored on the application side. The application developer must take care to ensure the integrity of the data. GCM_ReadSystem, GCM_WriteSystem functions may be useful in the following cases:
Transfer of data from the application developer to the C3D Solver developer for debugging during technical maintenance. See also paragraph Journalling API calls of the GCM solver where journalling GCM calls for debugging and technical maintenance purposes is described;
Converting native formats into a C3D file with a certain data loss;
Temporary saving the constraint system state for various purposes (partial loss of data for such constraints is possible, such as mechanical transmissions and GCM_DEPENDENT dependencies).