Crate lib3mf_converters

Crate lib3mf_converters 

Source
Expand description

§lib3mf-converters

Format converters for converting between 3MF and other 3D file formats.

§Overview

This crate provides importers and exporters for converting STL and OBJ files to and from the 3MF format. It builds on lib3mf_core to provide bi-directional conversion between these common 3D formats and the full 3MF Model representation.

Supported formats:

  • STL: Binary and ASCII STL formats with auto-detection
  • OBJ: Basic geometry only (vertices and faces, no materials/textures)

§Quick Start

use lib3mf_converters::stl::StlImporter;
use lib3mf_core::validation::ValidationLevel;
use std::fs::File;

// Import an STL file
let file = File::open("model.stl")?;
let model = StlImporter::read(file)?;

// Validate the imported geometry
let report = model.validate(ValidationLevel::Standard);
if report.has_errors() {
    eprintln!("Imported model has validation errors");
}

// Access the mesh data
println!("Imported {} objects", model.resources.iter_objects().count());

§Modules

  • stl: Binary and ASCII STL import and export
  • obj: Wavefront OBJ import and export

§Limitations

  • STL: No color or material attribute support in STL format
  • OBJ: Materials (mtllib/usemtl), texture coordinates (vt), and normals (vn) are ignored during import
  • OBJ: Export does not include materials or textures, only geometry
  • Vertex deduplication in STL import uses bitwise float comparison (exact match required)

§Cross-References

This crate works with types from lib3mf_core, particularly:

Modules§

mtl
Wavefront MTL material library parser.
obj
Wavefront OBJ format import and export.
stl
STL format import and export (binary and ASCII).