pub struct ObjExporter;Expand description
Exports 3MF Model structures to Wavefront OBJ files.
The exporter writes all mesh objects from build items to OBJ format, creating separate groups for each object and applying build item transformations.
Implementations§
Source§impl ObjExporter
impl ObjExporter
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 OBJ text format.
§Arguments
model- The 3MF model to exportwriter- Any type implementingWriteto receive OBJ text data
§Returns
Ok(()) on successful export.
§Errors
Returns Lib3mfError::Io if any write operation fails.
§Format Details
- Groups: Each mesh object creates an OBJ group (
g) with the object’s name or “Object” - Vertex indices: Written as 1-based indices (OBJ convention)
- Transformations: Build item transforms are applied to vertex coordinates
- Materials: Not exported (OBJ output is geometry-only)
- Normals/UVs: Not exported
§Behavior
- Only mesh objects from
model.build.itemsare exported - Non-mesh geometries (Components, BooleanShape, etc.) are skipped
- Vertex indices are offset correctly across multiple objects
- Each object’s vertices and faces are written in sequence
§Examples
use lib3mf_converters::obj::ObjExporter;
use lib3mf_core::model::Model;
use std::fs::File;
let output = File::create("exported.obj")?;
ObjExporter::write(&model, output)?;
println!("Model exported successfully");Auto Trait Implementations§
impl Freeze for ObjExporter
impl RefUnwindSafe for ObjExporter
impl Send for ObjExporter
impl Sync for ObjExporter
impl Unpin for ObjExporter
impl UnwindSafe for ObjExporter
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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