# Introduction

TetGen is a quality tetrahedral mesh generator and a three-dimensional Delaunay triangulator. It is used by *Mathematica* for various operations, such as interpolation in three-dimensional convex domains.

*TetGenLink* is a *Mathematica* application that makes the functions of TetGen available to *Mathematica. *This is done with Wolfram *LibraryLink*, which allows TetGen to be used in a high-speed and low-memory fashion. *TetGenLink* is used automatically by other *Mathematica* functions. However, it can also be used directly, which gives a flexible and innovative way to use the functionality of TetGen.

To use the application it must first be loaded.

In[7]:= |

Now you can create an instance of a TetGen object.

In[8]:= |

Out[8]= |

This sets up points and facets to use.

In[9]:= |

In the following, the points and facets are plotted as a three-dimensional outline.

In[11]:= |

Out[11]= |

Here, the points and facets are set in the instance.

In[12]:= |

The following creates a new TetGen instance that contains the result of meshing the first.

In[14]:= |

Out[14]= |

This gets the points and faces for the generated mesh.

In[15]:= |

The generated mesh can be plotted, as shown below.

In[17]:= |

Out[17]= |

If you plot just the wire frame, you can see that this just includes the exterior of the mesh.

In[19]:= |

Out[19]= |

If you want to get all the triangularization of the interior, you can do this with TetGenGetElements.

In[20]:= |

The wire frame plot is more complicated since it contains the interior.

In[22]:= |

Out[22]= |

When you have finished with the meshes, you can release them as shown in the following.

In[23]:= |

## Loading a Dataset

TetGen can read and write several formats of mesh data. This is useful since it lets you work with meshes created in other applications and also save meshes created by TetGen to use elsewhere.

*TetGenLink* contains a number of sample data files that are useful for demonstrations.

To use the application it must first be loaded.

In[25]:= |

This sets up the location of some data files in the *TetGenLink* installation.

In[26]:= |

This creates a TetGen instance and then loads point and facet information from the data into it.

In[27]:= |

Next, you create a tetrahedron mesh.

In[35]:= |

Out[35]= |

Here, the points and faces are extracted from the TetGen instance.

In[36]:= |

Finally, a plot is made of the points and faces.

In[39]:= |

Out[39]= |

You can then work with the TetGen mesh to carry out refinement or some other computation. Here, the instances are removed to free the resources.

In[40]:= |

## TetGen Details

TetGen is created by Hang Si, Research Group: "Numerical Mathematics and Scientific Computing", Weierstrass Institute for Applied Analysis and Stochastics (WIAS), Berlin. More information can be found at http://tetgen.org.