Expand description
An parser for binary and ASCII STL files.
§Example
use std::io::BufReader;
use std::fs::File;
let file = File::open("./fixtures/Root_Vase.stl").unwrap();
let mut root_vase = BufReader::new(&file);
let mesh: nom_stl::Mesh = nom_stl::parse_stl(&mut root_vase).unwrap();
assert_eq!(mesh.triangles().len(), 596_736);
Structs§
- Index
Mesh - A triangle mesh represented as a vector of
IndexTriangle
and a vector ofVertex
. - Index
Triangle - A triangle type which contains a normal vertex and index references
to vertices contained in a separate vertices container.
See
IndexMesh
. - Mesh
- A triangle mesh represented as a vector of
Triangle
. - Triangle
- A triangle type with an included normal vertex and vertices.
Enums§
- Error
- An error is either an IOError (wrapping std::io::Error), or a parse error, indicating that the parser is unable to make progress on an invalid input. This error is derived from the underlying nom_stl error
Functions§
- parse_
stl - Parse a binary or an ASCII stl.
Binary stls ar not supposed to begin with the bytes
solid
, but unfortunately they sometimes do in the real world. For this reason, we use a simple regex heuristic to determine if the stl contains the bytesfacet normal
, which is a byte sequence specifically used in ASCII stls. If the file contains this sequence, we assume ASCII, otherwise binary. While a binary stl can in theory contain this sequence, the odds of this are low. This is a tradeoff to avoid something both more complicated and less performant.