### 2.3.7. Primitive Region Routines

The following routines enable the specification of 2D regions as a group of nodes or faces, or a 3D region as a group of elements. In the case of nodes and faces, only those that define faces of valid imported elements will be imported; others are ignored by CFX.

#### 2.3.7.1. cfxImportBegReg

    int cfxImportBegReg (regname, regtype)
    char *regname;
    int regtype;

Initialize for the specification of a region. If a region is currently being defined, `cfxImportEndReg` will be called.

The name of the region is given by `regname`. If the region name is `NULL`, the name `Unnamed Region 2D` or `Unnamed Region 3D`, with a sequential integer appended, will be used. If a region named `regname` has already been defined, then additional objects will be added to the previous region.

The type of region is given by regtype, which should be one of `cfxImpREG_NODES`, `cfxImpREG_FACES` or `cfxImpREG_ELEMS` depending on whether the region is to be defined by nodes, faces or elements, respectively. It is not currently possible to mix types in a region; doing so will cause the import API to terminate with an error message.

Returns the number of objects (node, faces or elements) currently in the region.

#### 2.3.7.2. cfxImportAddReg

    int cfxImportAddReg (numobjs, objlist)
    int numobjs, *objlist;

Add IDs of objects being defined to the current region.

A region must be currently defined or reactivated by `cfxImportBegReg` or an error will occur, and the API will terminate.

The number of objects to add is given by `numobjs` and the IDs of the objects are supplied in `objlist`.

The objects are interpreted as node IDs, face IDs, or element IDs, depending on the type of the region indicated when `cfxImportBegReg` was called.

On calling `cfxImportDone`, any node IDs , face IDs or element IDs specified in the object list must have been defined by the appropriate routine or they will be removed from the region.

Returns the total number of objects in the current region after the object IDs have been added.

#### 2.3.7.3. cfxImportEndReg

    int cfxImportEndReg ()

End the specification of the current region.

Returns the number of objects (nodes, faces or elements) in the region.

#### 2.3.7.4. cfxImportRegion

    int cfxImportRegion (regname, regtype, numobjs, objlist)
    char *regname;
    int regtype, numobjs, *objlist;

Import a region named `regname` of type `regtype`. The number of objects to add to the region is given by `numobjs`, and the list of object IDs by `objlist`. This routine combines calls to `cfxImportBegReg`, `cfxImportAddReg` and `cfxImportEndReg`.

Returns the total number of objects in the region on termination of the routine.

#### 2.3.7.5. cfxImportRegionList

    char ** cfxImportRegionList ()

Return a NULL terminated list of currently defined region names.

The memory for the array and each character string in the array returned is allocated using `malloc` by the routine, consequently each array member and the array itself should be destroyed when no longer required by calling `free`.

#### 2.3.7.6. cfxImportGetRegion

    int * cfxImportGetRegion (regname)
    char *regname;

Returns a list of objects in the region named `regname`, or `NULL` if the region does not exist. The first entry in the returned list is the region type and the second entry is the number of object IDs.

The memory for the array is allocated using `malloc` by the routine, consequently the array itself should be destroyed when no longer required by calling `free`.

Release 18.2 - © ANSYS, Inc. All rights reserved.