STL (file format)
Encyclopedia
STL is a file format
File format
A file format is a particular way that information is encoded for storage in a computer file.Since a disk drive, or indeed any computer storage, can store only bits, the computer must have some way of converting information to 0s and 1s and vice-versa. There are different kinds of formats for...

 native to the stereolithography
Stereolithography
Stereolithography is an additive manufacturing technology for producing models, prototypes, patterns, and in some cases, production parts.-Technology description:...

 CAD
Computer-aided design
Computer-aided design , also known as computer-aided design and drafting , is the use of computer technology for the process of design and design-documentation. Computer Aided Drafting describes the process of drafting with a computer...

 software created by 3D Systems
3D Systems
3D Systems, headquartered in Rock Hill, South Carolina, is a maker of rapid prototyping machines, notable for developing stereolithography and the STL file format.- History :...

. This file format is supported by many other software packages; it is widely used for rapid prototyping
Rapid prototyping
Rapid prototyping is the automatic construction of physical objects using additive manufacturing technology. The first techniques for rapid prototyping became available in the late 1980s and were used to produce models and prototype parts. Today, they are used for a much wider range of applications...

 and computer-aided manufacturing
Computer-aided manufacturing
Computer-aided manufacturing is the use of computer software to control machine tools and related machinery in the manufacturing of workpieces. This is not the only definition for CAM, but it is the most common; CAM may also refer to the use of a computer to assist in all operations of a...

. 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
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

 and binary
Binary file
A binary file is a computer file which may contain any type of data, encoded in binary form for computer storage and processing purposes; for example, computer document files containing formatted text...

 representations. Binary files are more common, since they are more compact. In 2011, ASTM
ASTM International
ASTM International, known until 2001 as the American Society for Testing and Materials , is an international standards organization that develops and publishes voluntary consensus technical standards for a wide range of materials, products, systems, and services...

 replaced the STL format with the Additive Manufacturing File Format
Additive Manufacturing File Format
Additive Manufacturing File Format is an open standard for describing objects for additive manufacturing processes such as 3D printing. The official ASTM F2915standard is an XML-based format designed to allow any computer-aided design software to describe the shape and composition of any 3D object...

 (AMF), which has native support for color, multiple materials, and constellations.

An STL file describes a raw unstructured triangulated surface by the unit normal
Surface normal
A surface normal, or simply normal, to a flat surface is a vector that is perpendicular to that surface. A normal to a non-flat surface at a point P on the surface is a vector perpendicular to the tangent plane to that surface at P. The word "normal" is also used as an adjective: a line normal to a...

 and vertices (ordered by the right-hand rule
Right-hand rule
In mathematics and physics, the right-hand rule is a common mnemonic for understanding notation conventions for vectors in 3 dimensions. It was invented for use in electromagnetism by British physicist John Ambrose Fleming in the late 19th century....

) of the triangles using a three-dimensional Cartesian coordinate system
Cartesian coordinate system
A Cartesian coordinate system specifies each point uniquely in a plane by a pair of numerical coordinates, which are the signed distances from the point to two fixed perpendicular directed lines, measured in the same unit of length...

.

ASCII STL

An ASCII STL file begins with the line:

solid name

where name is an optional string (though if name is omitted there must still be a space after solid). 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
Mantissa
* The mantissa is the significand in a common logarithm or floating-point number.* Metaphorically, it is the part of the self that eludes conscious awareness or self-understanding.* An addition of little importance.Mantissa may also refer to:...

 'e'-sign-exponent format. The file concludes with:

endsolid name

The structure of the format suggests that other possibilities exist (e.g., facets with more than one 'loop', or loops with more than three vertices) but in practice, all facets are simple triangles.

White space (spaces, tabs, newlines) 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 (which is generally ignored – but which should never begin with 'solid' because that will lead most software to assume that this is an ASCII STL file). Following the header is a 4 byte 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 the twelve floats there is a two byte unsigned 'short' 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 the endianness
Endianness
In computing, the term endian or endianness refers to the ordering of individually addressable sub-components within the representation of a larger data item as stored in external memory . Each sub-component in the representation has a unique degree of significance, like the place value of digits...

 is assumed to be little endian although this is not stated in documentation.

UINT8[80] – Header
UINT32 – Number of triangles


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

Colour in binary STL

There are at least two variations on the binary STL format for adding colour information:
  • The VisCAM and SolidView software packages use the two 'attribute byte count' bytes at the end of every triangle to store a 15 bit RGB colour:
    • bit 0 to 4 are the intensity level for blue (0 to 31)
    • bits 5 to 9 are the intensity level for green (0 to 31)
    • bits 10 to 14 are the intensity level for red (0 to 31)
      • bit 15 is 1 if the colour is valid
      • bit 15 is 0 if the colour is not valid (as with normal STL files)

  • The Materialise Magics software does things a little differently. It uses the 80 byte header at the top of the file to represent the overall colour of the entire part. If colour is used, then somewhere in the header should be the ASCII
    ASCII
    The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

     string "COLOR=" followed by four bytes representing red, green, blue and alpha channel (transparency) in the range 0–255. This is the colour of the entire object unless overridden at each facet. Magics also recognizes a material description; a more detailed surface characteristic. Just after "COLOR=RGBA" specification should be another ASCII string ",MATERIAL=" followed by three colours (3 × 4 bytes): first is a colour of diffuse reflection
    Diffuse reflection
    Diffuse reflection is the reflection of light from a surface such that an incident ray is reflected at many angles rather than at just one angle as in the case of specular reflection...

    , second is a colour of specular highlight
    Specular highlight
    A specular highlight is the bright spot of light that appears on shiny objects when illuminated . Specular highlights are important in 3D computer graphics, as they provide a strong visual cue for the shape of an object and its location with respect to light sources in the scene.-Microfacets:The...

    , and third is an ambient light. Material settings are preferred over colour. The per-facet colour is represented in the two 'attribute byte count' bytes as follows:
    • bit 0 to 4 are the intensity level for red (0 to 31)
    • bits 5 to 9 are the intensity level for green (0 to 31)
    • bits 10 to 14 are the intensity level for blue (0 to 31)
      • bit 15 is 0 if this facet has its own unique colour
      • bit 15 is 1 if the per-object colour is to be used


The red/green/blue ordering within those two bytes is reversed in these two approaches – so whilst these formats could easily have been compatible the reversal of the order of the colours 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 (0,0,0) and the software will automatically calculate a normal based on the order of the triangle vertices using the 'right-hand rule'. Some STL loaders (e.g. the STL plugin for Art of Illusion
Art of Illusion
Art of Illusion is a software package used for 3D modeling, texturing, ray tracing, and otherwise rendering computer generated imagery stills or animations ....

) check that the normal in the file agrees with the normal they calculate using the right-hand rule and warn you 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
SolidWorks
SolidWorks is a 3D mechanical CAD program that runs on Microsoft Windows and is being developed by Dassault Systèmes SolidWorks Corp., a subsidiary of Dassault Systèmes, S. A. . SolidWorks is currently used by over 1.3 million engineers and designers at more than 130,000 companies worldwide...

 which uses the normal for shading effects.

History of use

Stereolithography machines are basically 3D printers that can build any volume shape as a series of slices. Ultimately these machines require a series of closed 2D contours that are filled in with solidified material as the layers are fused together.

The natural file format for such a machine would be a series of closed polygons corresponding to different Z-values. However, since it's possible to vary the layer thicknesses for a faster though less precise build, it seemed easier to define the model to be built as a closed polyhedron
Polyhedron
In elementary geometry a polyhedron is a geometric solid in three dimensions with flat faces and straight edges...

 that could 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's only ever used for triangles, which means that much of the syntax of the ASCII protocol is superfluous.

STL files are supposed to be closed and connected like a combinatorial surface, where every edge is part of exactly two triangles, and not self-intersecting. Since the syntax does not enforce this property, it can be ignored for applications where the closedness doesn't matter.

The closedness only matters insofar as the software which 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 endpoints of edges that are close together so that they coincide. The results are not predictable, but it is often sufficient to get the job done.

Use in other fields

Many computer-aided design
Computer-aided design
Computer-aided design , also known as computer-aided design and drafting , is the use of computer technology for the process of design and design-documentation. Computer Aided Drafting describes the process of drafting with a computer...

 systems are able to output the STL file format among their other formats because it's quick and easy to implement, if you ignore the connection criteria of the triangles. Many computer-aided manufacturing
Computer-aided manufacturing
Computer-aided manufacturing is the use of computer software to control machine tools and related machinery in the manufacturing of workpieces. This is not the only definition for CAM, but it is the most common; CAM may also refer to the use of a computer to assist in all operations of a...

 systems require triangulated models as the basis of their calculation.

Since an STL file output, of a sorts, is almost always available from the CAD system, it's often used as a quick method for importing the necessary triangulated geometry into the CAM system.

It can also be used for interchanging data between CAD/CAM systems and computational environments such as Mathematica
Mathematica
Mathematica is a computational software program used in scientific, engineering, and mathematical fields and other areas of technical computing...

.

Once it works, there is very little motivation to change, even though it is far from the most memory and computationally efficient method for transferring this data. Many integrated CAD and CAM systems transfer their geometric data using this accidental file format, because it's impossible to go wrong.

There are many other file formats capable of encoding triangles available, such as VRML
VRML
VRML is a standard file format for representing 3-dimensional interactive vector graphics, designed particularly with the World Wide Web in mind...

, DXF, but they have the disadvantage that it's possible to put things other than triangles into it, and thus produce something ambiguous or unusable.

See also

  • PLY (file format)
    PLY (file format)
    PLY is a computer file format known as the Polygon File Format or the Stanford Triangle Format.The format was principally designed to store three dimensional data from 3D scanners. It supports a relatively simple description of a single object as a list of nominally flat polygons...

    , an alternative file format offering more flexibility than most stereolithography
    Stereolithography
    Stereolithography is an additive manufacturing technology for producing models, prototypes, patterns, and in some cases, production parts.-Technology description:...

     applications.
  • Wavefront .obj file, a 3D geometry definition file format with .obj file extension
  • MeshLab
    MeshLab
    MeshLab, is a free 3D mesh processing software program; MeshLab, started in late 2005, is an open-source general-purpose system aimed to help the processing of the typical not-so-small unstructured 3D models that arise in the pipeline of processing of the data coming from 3D scanning...

    , a free
    Free software
    Free software, software libre or libre software is software that can be used, studied, and modified without restriction, and which can be copied and redistributed in modified or unmodified form either without restriction, or with restrictions that only ensure that further recipients can also do...

     and open source cross-platform application for visualizing, processing and converting three-dimensional meshes to or from the STL file format.
  • Mathematica
    Mathematica
    Mathematica is a computational software program used in scientific, engineering, and mathematical fields and other areas of technical computing...

    , a technical computing system that can work with PLY files.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK