The insertion of each node is performed in cavityext in the following way:

- determine the cavity for the new node
- start from the base element
- add elements one by one through adjacency; only element whose circumcircle enclose the new node are taken into account
- check for nodes within the cavity; if any, remove the element to which they belong from the cavity
- restore the unperturbed coordinates of the new node
- connect the new node with each of the faces bordering the cavity and
check the quality of the ensueing element. If
- the volume is not extremely small AND
- at least one height (a tetrahedral element has 4 heights) which is very small compared to the desired element size at the new node's position AND
- the face bordering the cavity is external,

then the cavity element bordering this face is removed, provided it is not the base element.

- revert to the perturbed coordinates of the new node
- check that the cavity is convex in the sense that each cavity face is visible from the new node, else the element bordering the face is removed from the cavity
- restore the unperturbed coordinates

- remove the cavity elements
- create new elements connecting the new node with each of the cavity faces provided the resulting volume is not extremely small. If it is, no element is created and the sign of the face is inverted thus marking the zero volume elements
- if any element has a very small volume or at least one very small height the original mesh of the cavity is restored
- since elements have been deleted and created the base element numbers of the nodes still te be inserted may not be correct any more: perform a check on these nodes and correct the base element numbers if necessary.
- label the newly generated faces and edges as external or not. Sub-edges of the edge on which the new node was inserted inherit the label from field iexternaledg
- for negative cavity faces:
- loop over all their edges and check whether they are still needed (i.e. still belong to another face)
- remove the face