7 releases
Uses new Rust 2024
| new 0.0.7 | Apr 7, 2026 |
|---|---|
| 0.0.6 | Mar 26, 2026 |
#35 in Data formats
145KB
3.5K
SLoC
sc-mesh-formats
A SoulCrafted library to read, write, and manipulate 3D mesh data. Part of the Slicer project.
Supported formats
| Format | Read | Write | Notes |
|---|---|---|---|
STL (.stl) |
✓ | ✓ | Probes the file to pick ASCII or binary. Writes as binary by default. |
STL ASCII (.stla) |
✓ | ✓ | |
STL Binary (.stlb) |
✓ | ✓ | |
| OBJ | ✓ | planned | |
| PLY | planned | — | |
| AMF | planned | — | |
| 3MF | planned | — |
Public API
stl module
use sc_mesh_formats::core::IndexedMesh; // Just for type annotation
use sc_mesh_formats::stl::{
read_stl,
read_stla,
read_stlb,
write_stla,
write_stlb
};
Reading
// Auto-detect ASCII vs. binary from the stream
let mesh: IndexedMesh = read_stl(&mut reader)?;
// Explicit ASCII
let mesh: IndexedMesh = read_stla(&mut reader)?;
// Explicit binary
let mesh: IndexedMesh = read_stlb(&mut reader)?;
All three functions accept any value implementing Read + Seek and return an
IndexedMesh wrapped in anyhow::Result.
Writing
// Write ASCII STL
write_stla(&mesh, &mut writer)?;
// Write binary STL
write_stlb(&mesh, &mut writer)?;
Both functions accept any W: Write.
Credits
- The support for STL file format has been heavily inspired on
stl_io.
License
Apache-2.0 — see LICENSE or the SPDX headers in each source file.
Dependencies
~2.2–4MB
~71K SLoC