#stl #mesh #ascii #3d

stl_io

STL input and output for reading and writing STL (STereoLithography) files

23 releases

0.8.5 Feb 26, 2025
0.8.3 Nov 17, 2024
0.7.0 Dec 4, 2022
0.6.0 Jan 4, 2021
0.3.3 Jul 5, 2017

#19 in Data formats

Download history 2844/week @ 2024-12-02 2446/week @ 2024-12-09 1906/week @ 2024-12-16 809/week @ 2024-12-23 1190/week @ 2024-12-30 2634/week @ 2025-01-06 2358/week @ 2025-01-13 2649/week @ 2025-01-20 3137/week @ 2025-01-27 3965/week @ 2025-02-03 3138/week @ 2025-02-10 3151/week @ 2025-02-17 4040/week @ 2025-02-24 3190/week @ 2025-03-03 4037/week @ 2025-03-10 4365/week @ 2025-03-17

15,897 downloads per month
Used in 22 crates (20 directly)

MIT license

33KB
676 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

~170KB