STL File Format, Binary/ASCII
Almost all of the AM technology available today uses the stereolithography (STL) file format. The STL format of the 3D CAD model captures all surfaces of the 3D model by stitching triangles of different sizes on its surfaces. The spatial locations of the vertices of each triangle and the vectors that are normal to each triangle, when combined, allow AM’s pre-process programs to determine the spatial locations of the surfaces of the part in the build envelope, and on which side of the surface is the interior of the part.
Although the STL format has been considered a de facto standard, there are inherent limitations to the fact that only geometry information is stored in these files, while all other information that the CAD model may contain is deleted. Information such as the unit, color, material, etc., can play an important role in the functionality of the built-in component being lost during a file translation process. As such, the functionality of the finished parts is limited. The “AMF” format has been developed specifically to address these issues and limitations and is now the standard ASTM/ ISO format.
Beyond geometry information, this file format also includes dimensions, color, material, and additional information. Currently, the prevailing file format used by AM systems and supported by CAD modeling programs is still the STL format. Increasing numbers of CAD program companies, including plenty of major programs, have included support for AMF file formats. Currently, the actual use of the information stored in the AMF file is still limited due to the capabilities of the current AM systems and the state of the art technology. The STL file consists of a number of triangular facets.
Each triangular facet is uniquely defined by a normal vector unit and three vertices or corners. The normal vector unit is a line that is perpendicular to the triangle and has a length equal to 1.0. The length of the unit could be in millimeters or inches and is stored using three numbers corresponding to its vector coordinates. The STL file itself does not hold any dimensions, so the AM machine operator must know whether the dimensions are millimeters, inches, or any other unit. Since each vertex also has three numbers, there are a total of 12 numbers for each triangle. The following file shows a simple ASCII STL file describing the right-angled, triangular pyramid structure as shown in Figure 2.1.
FIGURE 2.1 A right-angled triangular pyramid as defined in the STL sample file.
Note that the file starts with an object name defined as a solid. Triangles can be identified in any order, each as a facet. The facet line also includes the normal vector for the triangle. Note that this normal is calculated from any convenient location on the triangle and may be from one of the vertices or from the center of the triangle. It is defined that the normal is perpendicular to the triangle and the length of the unit. In most systems, the normal is used to define the outer surface of the solid, essentially pointing out the outer surface. The group of three vertices defining the triangle is defined by the terms “outer loop” and “end loop.”
The outside of the triangle is better established by the right-hand rule approach. As we look at the triangle from the outside, the vertices should be in the clockwise order. Using the right hand with the thumb pointed upward, the other fingers curl in the direction of the vertical order, the starting vertex being arbitrary. This method is becoming more popular because it avoids having to make any calculations for an additional number (i.e. facet normal) and thus STL files might not even allow the normal to avoid ambiguity.
Note that the bottom left-hand corner is the same as the origin and that each vertex coming out of the origin is of unit length.
A binary STL file can be described as follows:
- • The 80-byte ASCII header that might be used to describe the component
- • A long integer of 4 bytes that indicates the number of facets in the object
- • A list of facets, each 50 bytes long
The facet record will be described in the following manner:
- • Three floating values of 4 bytes each for the normal vector
- • Three floating values of 4 bytes each for the first vertex
- • Three floating values of 4 bytes each for the second vertex
- • Three floating values of 4 bytes each for the third vertex
- • One unsigned integer of 2 bytes, which should be zero, used for checking