stl
A library to read, write, and transform Stereolithography (.stl) files in Go. It is used in the command line STL manipulation tool stltool.
Features
- Read and write STL files in either binary or ASCII form
- Check correctness of STL files
- Measure models
- Various linear model transformations
- Scale
- Rotate
- Translate (Move)
- Fit into box
- Apply generic 4x4 transformation matrix
Applications
- Save 3D models as STL
- Import STL models
- Repair and manipulation of STL models
- General pre-processing before processing STL models in a 3D printing slicer
- Writing a slicer in Go (I hope someone does this one day)
Installation
Using go's builtin installation mechanism:
go get github.com/hschendel/stl
Usage Example
solid, errRead := stl.ReadFile(inputFilename)
if errRead != nil {
// handle
}
solid.Scale(25.4) // Convert from Inches to mm
errWrite := solid.WriteFile(outputFilename)
Stream Processing STL Files
You can implement the stl.Writer
interface to directly write into your own data structures.
This way you can use the stl.CopyFile
and stl.CopyAll
functions.
var ownData ownDataStructure // implements stl.Writer
err := stl.CopyFile("somefile.stl", &ownData)
Further Reading
The package godoc documentation should be helpful. Or just start a local godoc server using this command:
godoc -http=:6060
Then open http://localhost:6060/pkg/github.com/hschendel/stl/ in your browser.
License
The stl package is licensed under the MIT license. See LICENSE file.