Next: Extraction of Boundary Representation Up: Top Previous: Introduction

STL File Format

An STL file is a triangular representation of a 3D surface geometry. The surface is tessellated logically into a set of oriented triangles (facets). Each facet is described by the unit outward normal and three points listed in counterclockwise order representing the vertices of the triangle. While the aspect ratio and orientation of individual facets is governed by the surface curvature, the size of the facets is driven by the tolerance controlling the quality of the surface representation in terms of the distance of the facets from the surface. The choice of the tolerance is strongly dependent on the target application of the produced STL file. In industrial processing, where stereolithography machines perform a computer controlled layer by layer laser curing of a photo-sensitive resin, the tolerance may be in order of 0.1 mm to make the produced 3D part precise with highly worked out details. However much larger values are typically used in pre-production STL prototypes, for example for visualization purposes.

The native STL format has to fulfill the following specifications: (i) The normal and each vertex of every facet are specified by three coordinates each, so there is a total of 12 numbers stored for each facet. (ii) Each facet is part of the boundary between the interior and the exterior of the object. The orientation of the facets (which way is ``out'' and which way is ``in'') is specified redundantly in two ways which must be consistent. First, the direction of the normal is outward. Second, the vertices are listed in counterclockwise order when looking at the object from the outside (right-hand rule). (iii) Each triangle must share two vertices with each of its adjacent triangles. This is known as vertex-to-vertex rule. (iv) The object represented must be located in the all-positive octant (all vertex coordinates must be positive).

However, for non-native STL applications, the STL format can be generalized. The normal, if not specified (three zeros might be used instead), can be easily computed from the coordinates of the vertices using the right-hand rule. Moreover, the vertices can be located in any octant. And finally, the facet can even be on the interface between two objects (or two parts of the same object). This makes the generalized STL format suitable for modelling of 3D non-manifolds objects.

The STL standard includes two data formats - ASCII and binary. While the ASCII form is more descriptive, the binary form is far more common due to the very large resulting size of the CAD data when saved in the ASCII format. The first line in the ASCII format is a description line that must start with the word ``solid'' in lower case, followed eventually by additional information as the file name, author, date etc. The last line should be the keyword ``endsolid''. The lines in between contain descriptions of individual facets as

   facet normal 0.0 0.0 1.0 
   outer loop 
      vertex  1.0  1.0  0.0 
      vertex -1.0  1.0  0.0 
      vertex  0.0 -1.0  0.0 
Binary STL files consist of a 80 byte header line that can be interpreted as a comment string. The following 4 bytes interpreted as a long integer give the total number of facets. What follows is a normal and 3 vertices for each facet, each coordinate represented as a 4 byte floating point number (12 bytes in all). There is a 2 byte spacer between each facet. The result is that each facet is represented by 50 bytes, 12 for the normal, 36 for the 3 vertices, and 2 for the spacer.

Next: Extraction of Boundary Representation Up: Top Previous: Introduction

Daniel Rypl