Top3dSTL A simple STL writter for Top3d
Top3dSTL(fout) writes a STL file with name fout using cubic representation and binary file format if xPhys exists in Workspace.
Top3dSTL(fout, xPhys) writes a STL file with name fout using cubic representation and binary file format
Top3dSTL(___, Name, Value) writes a STL file with one or more Name, Value pair argments. Use this option with any of the input argument combinations in the prvious syntaxes.
FORMAT - File is written in 'binary' (default) or 'ascii' format.
TITLE - Header text (max 80 characters) written to the STL file.
MODE - Facets are generated using 'cube' (default) or 'iso'.
CUTOFF - Density cutoff value. default: 0.5
FACECOLOR - Face color. default: 'cyan'
ALPHA - Face alpha value. default: 1.
UNITLENGTH - Vector of element unit length. default: [1 1 1]
PLOT - Logic flag to display structures. default: true
Top3dSTL('MyTop3d.stl') % when xPhys is in Workspace
Top3dSTL('MyTop3d.stl', density, 'Format', 'ascii', 'Mode', 'iso', 'FaceColor', 'm', 'Plot', false)
STL File Format Specifications
The facets define the surface of a 3-dimensional object. As such, each facet is part of the boundary between the interior and the exterior of the object. The orientation of the facets (which way is "out" and which way is "in") is specified redundantly in two ways which should be consistent. First, the direction of the normal is outward. Second, which is most commonly used now-a-day, list the facet vertexes in counter-clockwise order when looking at the object from the outside (right-hand rule).
Each triangle must share two vertices with each of its adjacent triangles. In other words, a vertex of one triangle cannot lie on the side of another.
ASCII STL Format
An ASCII STL file begins with the line
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
vertex v1x v1y v1z
vertex v2x v2y v2z
vertex v3x v3y v3z
v is a floating-point number in sign-mantissa-"e"-sign-exponent format, e.g., "2.648000e-002" (noting that each v must be non-negative).
The file concludes with
Binary STL Format
The binary format uses the IEEE integer and floating point numerical representation.
The syntax for a binary STL file is as follows:
UINT8 – Header
UINT32 – Number of triangles
REAL32 – Normal vector
REAL32 – Vertex 1
REAL32 – Vertex 2
REAL32 – Vertex 3
UINT16 – Attribute byte count