In addition to being used as a stand alone program, TetGen can be called from another program. The TetGen library provides functions and data structures for calling TetGen. One of the advantages of using the TetGen library is that it can be repeatedly called by other programs without the overhead of reading and writing files. The feature is very useful for applications like adaptive FEM and FVM methods.
This page gives the necessary instructions for using the TetGen library. Users are supposed to be able to use TetGen, i.e., know its command line switches and the input and output file formats.
The header file includes all data types and function declarations of the TetGen library. More specifically, it defines the function "tetrahedralize()" and the data type "tetgenio", which are provided for users to call TetGen with all its functionalities.
The parameter "switches" is a string containing the command line switches for this call. In this string, no initial dash '-' is required. The `Q' (quiet) switch is recommended in the final code.
The parameters "in" and "out", which are two pointers pointing to objects of "tetgenio", describing the input and the output. "in" and "out" may never be null pointers.
The geometry is a bar with two boundary markers defined (picture shown
below, source file bar.poly).
The complete C++ source code is available at here: tetcall.cxx. It can be compiled into an executable program. It does the following steps: