htrdr 0.8.1



sth - Star-TetraHedra file format


sth is a binary file format that describes a tetrahedral mesh. Only the geometry data of the mesh are stored; no additional property is attached to the vertices nor to the tetrahedra.

A sth file begins by a header that describes the data layout followed by the geometric data themselves, i.e. the list of 3D vertices and the list of tetrahedra.

The header is made up of 3 signed 64-bit integers. The first integer is a power of two (usually 4096) that defines the <pagesize> in bytes along which the vertices and tetrahedra are aligned. The two remaining integers store the number of vertices and the number of tetrahedra respectively. Note that by aligning the geometric data to <pagesize>, and depending on the system requirements, memory mapping can be used to automatically load/unload those data on demand (see for example the POSIX C function mmap(2)).

Padding bytes follow the file header to ensure alignment of the vertices to <pagesize>. The vertex positions are then listed with 3 double precision floating point numbers per vertex. Once stored, additional padding bytes are added after the mesh vertices to align the upcoming list of tetrahedra to <pagesize>. Each tetrahedron are then listed with 4 signed 64-bit integers per tetrahedra where each integer indexes a position in the list of vertices. We point out that the indexing of the vertices starts at 0 and not at 1. Finally, padding bytes are added to align the overall file size to <pagesize>.


Data are encoded with respect to the little endian bytes ordering, i.e. least significant bytes are stored first.

<sth>         ::= <pagesize> <#vertices> <#tetrahedra>

<pagesize>    ::= INT64
<#vertices>   ::= INT64
<#tetrahedra> ::= INT64
<padding>     ::= [ BYTE ... ]

<positions>   ::= <vertex-pos>
                [ <vertex-pos> ... ]

<indices>     ::= <tetra-ids>
                [ <tetra-ids> ... ]

<vertex-pos>  ::= DOUBLE DOUBLE DOUBLE
<tetra-ids>   ::= INT64 INT64 INT64 INT64