21 releases

0.8.3 Nov 17, 2024
0.7.0 Dec 4, 2022
0.6.0 Jan 4, 2021
0.5.2 Oct 19, 2020
0.3.3 Jul 5, 2017

#84 in Data formats

Download history 2710/week @ 2024-08-25 3304/week @ 2024-09-01 2340/week @ 2024-09-08 2916/week @ 2024-09-15 2889/week @ 2024-09-22 1840/week @ 2024-09-29 2140/week @ 2024-10-06 2394/week @ 2024-10-13 2569/week @ 2024-10-20 2207/week @ 2024-10-27 2883/week @ 2024-11-03 2620/week @ 2024-11-10 2932/week @ 2024-11-17 2786/week @ 2024-11-24 2891/week @ 2024-12-01 2272/week @ 2024-12-08

11,035 downloads per month
Used in 20 crates (17 directly)

MIT license

32KB
657 lines

stl_io

test workflow build workflow Cargo License: MIT Downloads

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();

For more information, check out the Documentation.

License

Licensed under the MIT license.

Dependencies

~165KB