Crate stl_io [−] [src]
stl_io
is crate for reading and writing STL (STereoLithography) files.
It can read both, binary and ascii STL in a safe manner.
Writing is limited to binary STL, which is more compact anyway.
Examples
Read STL file:
use std::fs::OpenOptions; let mut file = OpenOptions::new().read(true).open("mesh.stl").unwrap(); let stl = stl_io::read_stl(&mut file).unwrap();
Write STL file:
use std::fs::OpenOptions; let mesh = [stl_io::Triangle { normal: [1.0, 0.0, 0.0], vertices: [[0.0, -1.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 0.5]]}]; let mut file = OpenOptions::new().write(true).create_new(true).open("mesh.stl").unwrap(); stl_io::write_stl(&mut file, mesh.iter()).unwrap();
Structs
AsciiStlReader |
Struct for ascii STL reader. |
BinaryStlReader |
Struct for binary STL reader. |
IndexedMesh |
STL Mesh in indexed form, consisting of a list of Vertices and a list of indexed Triangles. |
IndexedTriangle |
STL Triangle in indexed form, consisting of a normal and three indices to vertices in the vertex list. This format is more compact, since in real world Meshes Triangles usually share vertices with other Triangles. |
Triangle |
STL Triangle, consisting of a normal and three vertices. This is the format Triangles are usually stored in STL files. |
Traits
TriangleIterator |
Iterates over all Triangles in a STL. |
Functions
create_stl_reader |
Attempts to create a TriangleIterator for either ascii or binary STL from std::io::Read. |
read_stl |
Attempts to read either ascci or binary STL from std::io::Read. |
write_stl |
Write to std::io::Write as documented in Wikipedia. |
Type Definitions
Normal |
STL Normal - a vector perpendicular to a Triangle in a 3D Mesh. |
Vertex |
STL vertex - a corner of a Triangle in a 3D Mesh. |