File Formats

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 the Wolfram Language. 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.

extension

mode

description

.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.

In[1]:=

This finds a sample data file in the TetGenLink installation.

In[2]:=

Out[2]=

To load the data file, you must first create an instance of a TetGen expression to hold the result.

In[3]:=

Out[3]=

This loads the data file into the instance.

In[4]:=

This extracts the points from the instance.

In[5]:=

Out[5]=

This extracts the vertices from the instance.

In[6]:=

Out[6]=

Here, the shape is plotted.

In[7]:=

Out[7]=

Finally, the TetGen instance is deleted.

In[8]:=

In addition to TetGen-specific formats, TetGen supports a number of other file formats. Note that STL is also supported by the Wolfram Language's Import command.

extension

mode

description

.off

input/output

Geomview's polyhedral file format

.ply

input

polyhedral file format

.stl

input

stereolithography format

.mesh

input/output

Medit's surface mesh file format

General file formats that can be used by TetGen.

Wolfram Language File Formats

The Wolfram Language supports a number of formats that are useful for working with meshes.

name

extension

mode

description

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 the Wolfram Language 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.

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.

In[10]:=

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.

In[13]:=

Now the new coordinates and facets on the surface can be extracted.

In[16]:=

Finally, the new data is plotted. You can see that there are more points created in the object.