pub struct AsciiStlExporter;Expand description
Exports 3MF Model structures to ASCII STL files.
Each mesh object in the model’s build items is written as a separate ASCII STL solid. Face normals are computed from the triangle edges using the cross product.
Implementations§
Source§impl AsciiStlExporter
impl AsciiStlExporter
Sourcepub fn write<W: Write>(model: &Model, writer: W) -> Result<()>
pub fn write<W: Write>(model: &Model, writer: W) -> Result<()>
Writes a 3MF Model to ASCII STL format.
Each mesh object referenced in the model’s build items is written as a separate
solid ... endsolid block. The solid name is taken from the object’s name field,
or left empty if the object has no name.
§Arguments
model- The 3MF model to exportwriter- Any type implementingWriteto receive ASCII STL text
§Returns
Ok(()) on successful export.
§Errors
Returns Lib3mfError::Io if any write operation fails.
§Format Details
- Normals: Computed via cross product of triangle edges (
normalize_or_zero()) - Degenerate triangles: Emit zero normal
(0 0 0), triangle is not skipped - Normal format: Scientific notation with 6 decimal places (
{:.6e}) - Vertex format: Fixed-point with 6 decimal places (
{:.6}) - Transformations: Build item transforms are applied to vertex coordinates
- Solid names: Taken from
object.name, empty string ifNone
§Examples
use lib3mf_converters::stl::AsciiStlExporter;
use lib3mf_core::model::Model;
use std::fs::File;
let output = File::create("exported.stl")?;
AsciiStlExporter::write(&model, output)?;Sourcepub fn write_with_resolver<W: Write, A: ArchiveReader>(
model: &Model,
resolver: PartResolver<'_, A>,
writer: W,
) -> Result<()>
pub fn write_with_resolver<W: Write, A: ArchiveReader>( model: &Model, resolver: PartResolver<'_, A>, writer: W, ) -> Result<()>
Writes a 3MF Model to ASCII STL format with support for multi-part 3MF files.
Resolves component references and external model parts using a PartResolver,
then writes all collected triangles as a single ASCII STL solid.
§Arguments
model- The root 3MF model to exportresolver- APartResolverfor loading external model parts from the 3MF archivewriter- Any type implementingWriteto receive ASCII STL text
§Returns
Ok(()) on successful export.
§Errors
Returns [Lib3mfError::Io] if any write operation fails.
Returns errors from the resolver if external parts cannot be loaded.
Auto Trait Implementations§
impl Freeze for AsciiStlExporter
impl RefUnwindSafe for AsciiStlExporter
impl Send for AsciiStlExporter
impl Sync for AsciiStlExporter
impl Unpin for AsciiStlExporter
impl UnwindSafe for AsciiStlExporter
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more