STL format

Written by Paul Bourke
October 1999


The STL (STereo Lithography) format was developed primarily by Albert Consulting Group and is perhaps the main standard for rapid prototyping systems. The format is specified as both an ASCII (printable character) format as well as a binary format.

ASCII

Sample ascii stl file

The first line is a description line that must start with the word "solid" in lower case, it then normally contains the file name, author, date etc. The last line should be the keyword "endsolid". The lines between the above contain descriptions of 3 vertex facets including their normals, the ordering of the vertices should comply with the right hand rule. As an example consider the following except from a STL file

solid
   :
   :
   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 
   endloop
   endfacet
   :
   :
endsolid

Often the normals need not be provided and they will be generated by the parsing software/system. The main restriction placed upon the facets in STL files is that all adjacent facets must share two common vertices.

Binary

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.


Example using ZCorp Z406