There are a number of file formats for working with meshes. They are useful since they can be used as interchange formats between CAD programs. Some of these are supported by TetGen and some by Mathematica. This section reviews the formats that are supported and shows how you can work with them.
TetGen File Formats
TetGen supports its own formats and also some standard formats. More information on the details of its formats and samples can be found on the TetGen website (http://tetgen.org).
The following table gives a description of TetGen's own formats.
|.node||input/output||a list of nodes|
|.poly||input||a piecewise linear complex|
|.smesh||input/output||a simple piecewise linear complex|
|.ele||input/output||a list of tetrahedra|
|.face||input/output||a list of triangular faces|
|.edge||output||a list of boundary faces|
|.vol||input||a list of maximum volumes|
|.var||input||a list of variant constraints for facets/segments|
|.neigh||output||a list of neighbors|
File formats specific to TetGen.
To demonstrate loading a data file, the application must first be loaded as shown below.
This finds a sample data file in the TetGenLink installation.
To load the data file, you must first create an instance of a TetGen expression to hold the result.
This loads the data file into the instance.
This extracts the points from the instance.
This extracts the vertices from the instance.
Here, the shape is plotted.
Finally, the TetGen instance is deleted.
In addition to TetGen-specific formats, TetGen supports a number of other file formats. Note that STL is also supported by Mathematica's Import command.
|.off||input/output||Geomview's polyhedral file format|
|.ply||input||polyhedral file format|
|.mesh||input/output||Medit's surface mesh file format|
General file formats that can be used by TetGen.
Mathematica File Formats
Mathematica supports a number of formats that are useful for working with meshes.
|STL||.stl||input/output||computer-aided design and manufacturing format|
|3DS||.3ds||input/output||Autodesk format for scene description and 3D modeling|
|DXF||.dxf||input/output||AutoCAD format for 3D geometry|
Formats supported by Mathematica for working with meshes.
These formats are often supported by CAD and other engineering applications, sometimes using them as interchange formats. Also, there are many samples of these files available on websites; one of these is http://www-roc.inria.fr/gamma/download, which has a large collection of files. For example, the gear10 example shown below comes from the "MECHANICAL" section.
To demonstrate loading a data file and working with it in TetGen, you must first load TetGenLink as shown below.
This is a sample 3DS data file. You would need to obtain it from the http://www-roc.inria.fr site described above.
The following loads vertex and polygon data from the file.
The resulting data is set up for multiple objects.
Therefore, you should extract the first for each set.
Now you can plot the mesh as shown below.
If you want to tetrahedralize this mesh, you can do so. First, the coordinates and facets are loaded into a TetGen instance as shown below.
Second, TetGenSetMessages is used to enable messages. Then the tetrahedralization is done. It creates a lot of information, including messages that there are duplicate points in the dataset. This can sometimes create problems.
Now the new coordinates and facets on the surface can be extracted.
Finally, the new data is plotted. You can see that there are more points created in the object.
This last step frees resources from the TetGen instances.