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

#81 in Data formats

Download history 2221/week @ 2024-10-30 2961/week @ 2024-11-06 3225/week @ 2024-11-13 2573/week @ 2024-11-20 2837/week @ 2024-11-27 2531/week @ 2024-12-04 2549/week @ 2024-12-11 1342/week @ 2024-12-18 827/week @ 2024-12-25 1778/week @ 2025-01-01 2419/week @ 2025-01-08 2435/week @ 2025-01-15 3049/week @ 2025-01-22 3027/week @ 2025-01-29 3962/week @ 2025-02-05 2608/week @ 2025-02-12

12,955 downloads per month
Used in 21 crates (20 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