## Adding and deleting geometric restrictions You can use the following call to add the majority of geometric or dimension constraints: ```cpp GCM_constraint GCM_AddConstraint(GCM_system gSys, const GCM_g_record & cRec) ``` It requires completion of the **cRec** data structure that stores the data on the **cRec.type** type and the argument array of the **cRec.args** constraint. The function returns a descriptor of a new constraint registered in the **gSys** system. As an example, let us add a constraint right now -- coincidence of point and plane: ```cpp GCM_system gSys = GCM_CreateSystem(); GCM_c_record cRec; // The record of point and plane coincidence. cRec.type = GCM_COINCIDENT; /* Some point and plane as arguments of the coincidence. */ cRec.args[0] = GCM_AddPoint(gSys, MbCartPoint3D::origin); cRec.args[1] = GCM_AddGeom(gSys, GCM_Plane(MbCartPoint3D(0,0,1), MbVector3D::zAxis)); cRec.args[2] = GCM_NO_ALIGNMENT; // The alignment option does't matter in point-plane case. /* Add coincidence to the system. */ GCM_constraint cItem = GCM_AddConstraint(gSys, cRec); /* Finalize the constraint system. */ GCM_RemoveConstraint(gSys, cItem); GCM_RemoveSystem(gSys); ``` There is a certain sequence of completing **args** arguments in the GCM_c\_record structure for each constraint type. In the above example, we have demonstrated that the first two elements cRec.args\[0\] and cRec.args\[1\] of the GCM_COINCIDENT constraint are descriptors of the Coincidence constraint, while the third element cRec.args\[2\] defines the alignment option. **GCM_c\_record**. The table below contains the template for completing the GCM_c\_record structure which is sent to the **GCM_AddConstraint** method for various constraint types. Table 1 - Data argument types for various constraints (GCM_c\_record completion) | **Constraint type** | type | | | | | |:---------------------------|:----------------|:----------|:------------------------|:---------------|:--------------| | type | args\[0\] | args\[1\] | args\[2\] | args\[3\] | args\[4\] | | GCM_COINCIDENT | GCM_geom | GCM_geom | GCM_alignment | | | | GCM_CONCENTRIC | GCM_geom | GCM_geom | GCM_alignment | | | | GCM_PARALLEL | GCM_geom | GCM_geom | GCM_alignment | | | | GCM_PERPENDICULAR | GCM_geom | GCM_geom | GCM_alignment | | | | GCM_TANGENT | GCM_geom | GCM_geom | GCM_alignment | GCM_tan_choice | | | GCM_SYMMETRIC | GCM_geom | GCM_geom | CM_geom | GCM_alignment | | | GCM_DISTANCE | GCM_geom | GCM_geom | double | GCM_alignment | | | GCM_ANGLE (планарный угол) | GCM_geom | GCM_geom | GCM_geom (ось вращения) | double | GCM_alignment | | GCM_ANGLE (3D угол) | GCM_geom | GCM_geom | GCM_NULL (без оси) | double | GCM_alignment | | GCM_RADIUS | GCM_geom | GCM_geom | | | | GCM_alignment is an option value considered in [GCM_alignment option](./GCM_alignment_option.md). GCM_tan_choice values will be described in sections dedicated to the tangency constraint (GCM_TANGENT). Table 32.10.1. lists only interpretation rules for data types accepted by the GCM_c\_arg element type in GCM_c\_record::args array for a certain constraint type. Therefore, the GCM_c\_record data structure is a unified method for setting a range of constraints using only one method -- **GCM_AddConstraint**. However, there are alternative ways to add constraints for convenient development in GCM API that do not require completing the GCM_c\_record. You can use the following function to add any **binary** constraints that bind a pair of geometric objects: ```cpp GCM_constraint GCM_AddBinConstraint(GCM_system gSys, GCM_c_type cType , GCM_geom g1 , GCM_geom g2 , GCM_alignment aVal , GCM_tan_choice tVar) ``` Input parameters of the function: - **gSys** -- descriptor of the constraint system; - **cType** -- type value from the following list: GCM_COINCIDENT, GCM_PARALLEL, GCM_PERPENDICULAR, GCM_TANGENT, GCM_CONCENTRIC; - **g1**, **g2** -- a pair of geometric object descriptors, binary constraint arguments; - **aVal** -- alignment option making it possible to select mutual orientation for objects (see [GCM_alignment option](./GCM_alignment_option.md)); - **tVar** -- tangency selection option for selecting a method for executing constraints of the GCM_TANGENT type. The result of the call is the binary constraint descriptor binding **g1** and **g2** objects with the selected alignment/tangency parameters **aVal**, **tVar**. The dimension constraint of the GCM_DISTANCE type that defines the distance between objects is created using the following call: ```cpp GCM_constraint GCM_AddDistance(GCM_system gSys, GCM_geom g1, GCM_geom g2, double dVal, GCM_alignment aVal) ``` The call uses input data **g1**, **g2**, **aVal** -- the same as for the **GCM_AddBinConstraint** function; numeric value **dVal** -- sets the dimension value. The same algorithm is used for calls that define the angular dimension, mirror symmetry, and radial dimension: **GCM_AddAngle**, **GCM_AddSymmeric**,**GCM_FixRadius**. They also do not require completing the GCM_c\_record transit structure.