STL (file format)


STL is a file format native to the stereolithography CAD software created by 3D Systems. STL has several backronyms such as "Standard Triangle Language" and "Standard Tessellation Language". This file format is supported by many other software packages; it is widely used for rapid prototyping, 3D printing and computer-aided manufacturing. STL files describe only the surface geometry of a three-dimensional object without any representation of color, texture or other common CAD model attributes. The STL format specifies both ASCII and binary representations. Binary files are more common, since they are more compact.
An STL file describes a raw, unstructured triangulated surface by the unit normal and vertices of the triangles using a three-dimensional Cartesian coordinate system. In the original specification, all STL coordinates were required to be positive numbers, but this restriction is no longer enforced and negative coordinates are commonly encountered in STL files today. STL files contain no scale information, and the units are arbitrary.

ASCII STL

An ASCII STL file begins with the line
solid name
where name is an optional string. The file continues with any number of triangles, each represented as follows:
facet normal ni nj nk
outer loop
vertex v1x v1y v1z
vertex v2x v2y v2z
vertex v3x v3y v3z
endloop
endfacet
where each n or v is a floating-point number in sign-mantissa-"e"-sign-exponent format, e.g., "2.648000e-002". The file concludes with
endsolid name
File:Sphericon.stl|thumb|An example of a sphericon
The structure of the format suggests that other possibilities exist. In practice, however, all facets are simple triangles.
White space may be used anywhere in the file except within numbers or words. The spaces between "facet" and "normal" and between "outer" and "loop" are required.

Binary STL

Because ASCII STL files can become very large, a binary version of STL exists. A binary STL file has an 80-character header. Following the header is a 4-byte little-endian unsigned integer indicating the number of triangular facets in the file. Following that is data describing each triangle in turn. The file simply ends after the last triangle.
Each triangle is described by twelve 32-bit floating-point numbers: three for the normal and then three for the X/Y/Z coordinate of each vertex – just as with the ASCII version of STL. After these follows a 2-byte unsigned integer that is the "attribute byte count" – in the standard format, this should be zero because most software does not understand anything else.
Floating-point numbers are represented as IEEE floating-point numbers and are assumed to be little-endian, although this is not stated in documentation.
UINT8 – Header
UINT32 – Number of triangles

foreach triangle
REAL32 – Normal vector
REAL32 – Vertex 1
REAL32 – Vertex 2
REAL32 – Vertex 3
UINT16 – Attribute byte count
end

Color in binary STL

There are at least two non-standard variations on the binary STL format for adding color information:
The red/green/blue ordering within those two bytes is reversed in these two approaches – so while these formats could easily have been compatible, the reversal of the order of the colors means that they are not – and worse still, a generic STL file reader cannot automatically distinguish between them. There is also no way to have facets be selectively transparent because there is no per-facet alpha value – although in the context of current rapid prototyping machinery, this is not important.

The facet normal

In both ASCII and binary versions of STL, the facet normal should be a unit vector pointing outwards from the solid object. In most software this may be set to, and the software will automatically calculate a normal based on the order of the triangle vertices using the "right-hand rule". Some STL loaders check that the normal in the file agrees with the normal they calculate using the right-hand rule and warn the user when it does not. Other software may ignore the facet normal entirely and use only the right-hand rule. Although it is rare to specify a normal that cannot be calculated using the right-hand rule, in order to be entirely portable, a file should both provide the facet normal and order the vertices appropriately.
A notable exception is SolidWorks, which uses the normal for shading effects.

Use in 3D printing

build objects by solidifying one layer at a time. This requires a series of closed 2D contours that are filled in with solidified material as the layers are fused together. A natural file format for such a machine would be a series of closed polygons corresponding to different Z-values. However, since it is possible to vary the layer thicknesses for a faster though less precise build, it was easier to define the model to be built as a closed polyhedron that can be sliced at the necessary horizontal levels.
The STL file format appears capable of defining a polyhedron with any polygonal facet, but in practice it is only ever used for triangles, which means that much of the syntax of the ASCII protocol is superfluous.
To properly form a 3D volume, the surface represented by any STL files must be closed and connected, where every edge is part of exactly two triangles, and not self-intersecting. Since the STL syntax does not enforce this property, it can be ignored for applications where the closedness does not matter. The closedness only matters insofar as the software that slices the triangles requires it to ensure that the resulting 2D polygons are closed. Sometimes such software can be written to clean up small discrepancies by moving vertices that are close together so that they coincide. The results are not predictable, but it is often sufficient.

Use in other fields

STL file format is simple and easy to output. Consequently, many computer-aided design systems can output the STL file format. Although the output is simple to produce, some connectivity information is discarded.
Many computer-aided manufacturing systems require triangulated models. STL format is not the most memory- and computationally efficient method for transferring this data, but STL is often used to import the triangulated geometry into the CAM system. The format is commonly available, so the CAM system will use it. In order to use the data, the CAM system may have to reconstruct the connectivity.
STL can also be used for interchanging data between CAD/CAM systems and computational environments such as Mathematica.

Representation of curved surfaces

It is not possible to use triangles to perfectly represent curved surfaces. To compensate, users often save enormous STL files to reduce the inaccuracy. Native formats of 3D design software files use mathematical surfaces to preserve detail losslessly in small files.

History

STL was invented by the Albert Consulting Group for 3D Systems in 1987. The format was developed for 3D Systems' first commercial 3D printers. Since its initial release, the format remained relatively unchanged for 22 years. In 2009, an update to the format, dubbed STL 2.0, was proposed.