pub struct StlMesh {
pub triangles: Vec<StlTriangle>,
pub name: String,
}Expand description
An STL mesh consisting of named triangles.
Fields§
§triangles: Vec<StlTriangle>The triangles that make up this mesh.
name: StringThe name of the solid (used in ASCII output).
Implementations§
Source§impl StlMesh
impl StlMesh
Sourcepub fn add_triangle(&mut self, v0: [f32; 3], v1: [f32; 3], v2: [f32; 3])
pub fn add_triangle(&mut self, v0: [f32; 3], v1: [f32; 3], v2: [f32; 3])
Add a triangle defined by three vertices; the normal is computed automatically.
Sourcepub fn to_binary_bytes(&self) -> Vec<u8> ⓘ
pub fn to_binary_bytes(&self) -> Vec<u8> ⓘ
Serialize this mesh to binary STL bytes.
Layout: 80-byte header + 4-byte little-endian triangle count + (12 floats + 2-byte attribute) per triangle = 50 bytes each.
Sourcepub fn from_binary_bytes(data: &[u8]) -> Result<Self, String>
pub fn from_binary_bytes(data: &[u8]) -> Result<Self, String>
Parse a binary STL byte slice into an StlMesh.
Sourcepub fn from_ascii(s: &str) -> Result<Self, String>
pub fn from_ascii(s: &str) -> Result<Self, String>
Parse an ASCII STL string into an StlMesh.
Sourcepub fn surface_area(&self) -> f32
pub fn surface_area(&self) -> f32
Compute the total surface area of this mesh.
Sourcepub fn bounding_box(&self) -> ([f32; 3], [f32; 3])
pub fn bounding_box(&self) -> ([f32; 3], [f32; 3])
Compute the axis-aligned bounding box as (min, max).
Returns ([0.0;3], [0.0;3]) for an empty mesh.
Sourcepub fn is_watertight(&self) -> bool
pub fn is_watertight(&self) -> bool
Return true if every edge is shared by exactly two triangles (watertight).
Auto Trait Implementations§
impl Freeze for StlMesh
impl RefUnwindSafe for StlMesh
impl Send for StlMesh
impl Sync for StlMesh
impl Unpin for StlMesh
impl UnsafeUnpin for StlMesh
impl UnwindSafe for StlMesh
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.