Created
August 9, 2024 15:32
-
-
Save sethhall/0a50f824b9d0bca48898b539cf9c18ba to your computer and use it in GitHub Desktop.
Binary STL parser in spicy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module STL; | |
import spicy; | |
%byte-order = spicy::ByteOrder::Little; | |
public type File = unit { | |
header : bytes &size=80; | |
total_facets : uint32; | |
facets : Facet[self.total_facets]; | |
}; | |
type Facet = unit { | |
normal: Point; | |
vertices: Point[3]; | |
pad: skip bytes &size=2; | |
}; | |
type Point = unit { | |
x: real &type=spicy::RealType::IEEE754_Single; | |
y: real &type=spicy::RealType::IEEE754_Single; | |
z: real &type=spicy::RealType::IEEE754_Single; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment