Documentation
¶
Overview ¶
Package stl reads STL files, the binary and the ASCII kind (SPEC §27.9), into a model.Model.
The kind is told by the content, not by the header: a binary file is one whose size is 84 bytes plus 50 for each triangle that its count says, even when its header begins with "solid" (a habit of some writers). Binary files may give a color for each triangle in the two attribute bytes, by the VisCAM and SolidView convention. Equal vertices are welded (exactly, or within a tolerance), and the normals are smooth across edges whose faces differ by less than a crease angle.
Index ¶
Constants ¶
const DefaultCreaseAngle = math.Pi / 6
DefaultCreaseAngle is the angle between the normals of two triangles at a vertex above which the vertex is split in two, so that the edge stays sharp: 30 degrees.
Flutter: no counterpart
const TagSTLInvalid = "STLInvalid"
TagSTLInvalid is the tag of the error of a file that is not a valid STL file: a truncated binary file, a number that is not one or that is not finite, a keyword in the wrong place, a file with no triangle. The metadata has "offset" (the byte, for a binary file) or "line" (for an ASCII file), and "reason".
Flutter: no counterpart
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// Name is the name of the model, its node and its mesh. Load sets the base name of the file when it is empty.
Name string
// Float64 keeps the positions of an ASCII file in float64 when some of them have more digits than a float32 holds. A binary file
// is float32 and is not changed by it.
Float64 bool
// WeldTolerance welds vertices that fall in the same cell of a grid of this size, in the units of the file. Zero welds the
// vertices that are equal bit for bit (and -0 with 0), which is what CAD writers produce.
WeldTolerance float64
// Flat gives every triangle three vertices of its own with the normal of the triangle: nothing is welded and no normal is
// smoothed.
Flat bool
// CreaseAngle is the angle in radians between the normals of two triangles at a vertex above which they do not share the
// vertex. Zero is DefaultCreaseAngle; a negative angle smooths every edge that is shared.
CreaseAngle float64
// Logger gets the notes of the loader (triangles that were dropped); slog.Default() when nil.
Logger *slog.Logger
}
Options are the options of Decode and Load.
Flutter: no counterpart