Read or Load STL files

The STL file format exists in two primary variants: ASCII and binary. Both formats can represent a 3D object as a collection of triangles, each defined by a unit normal vector and three vertices. Additional details and historical background on the STL specification can be found at: https://en.wikipedia.org/wiki/STL_(file_format).

An STL file reader can generate waves for both the the triangles and their unit normals. The STL format does not store scale information or surface properties.  The reader simply loads the triangle and normals as triplet waves. If the data is intended for display in Gizmo, there is no need to retain the normal waves, since Gizmo computes normals dynamically. The normals read from the file are used only to verify that all triangles follow a consistent winding rule; after this validation, the corresponding normal data can be discarded.

Displaying the triangle data in Gizmo is straightforward. For example:

AppendToGizmo Surface=root:twoSolidAscii_stl:mesh_0, name=surface0
ModifyGizmo ModifyObject=surface0, objectType=surface, property={srcMode, 1}
ModifyGizmo ModifyObject=surface0, objectType=surface, property={surfaceCTab, Rainbow}

The triangle waves can also be used directly with operations such as BoundingBall and ConvexHull.

Attached are a minimal example ASCII STL file containing two box objects, along with an Igor experiment demonstrating the loading procedure and example Gizmo visualizations.

For questions or comments, please contact support@wavemetrics.com.

 

A.G.

Sample STL file. (475 bytes) Demo containing loading code. (66.99 KB)