lib3mf_core/model/mod.rs
1//! Core data model for 3MF files.
2//!
3//! This module contains the in-memory representation of a 3MF document, including all geometry,
4//! materials, build instructions, and extension data.
5//!
6//! ## Key Types
7//!
8//! - [`Model`]: The root structure representing an entire 3MF document. Contains resources,
9//! build instructions, metadata, and attachments.
10//! - [`ResourceCollection`]: Central registry for all resources (objects, materials, textures)
11//! using a global ID namespace within the model.
12//! - [`Object`]: A 3MF resource representing geometry or components. Can be a mesh, support,
13//! surface, solid support, boolean shape, or other type.
14//! - [`Mesh`]: Triangle mesh geometry with vertices, triangles, and optional beam lattice data.
15//! - [`Build`]: Collection of [`BuildItem`]s that define which objects to print and where to
16//! position them.
17//! - [`BuildItem`]: An instance of an object in the build volume, with optional transformation.
18//!
19//! ## Material System
20//!
21//! Materials are applied to geometry via property IDs (`pid`):
22//!
23//! - [`BaseMaterial`]: Simple named materials with optional display color
24//! - [`ColorGroup`]: Per-vertex or per-triangle color assignments
25//! - [`Texture2DGroup`]: Image-based materials with UV coordinates
26//! - [`CompositeMaterials`]: Blended combinations of base materials
27//! - [`MultiProperties`]: Multi-channel property assignments
28//!
29//! Materials can be assigned at the object level (default for all triangles) or overridden
30//! per-triangle or per-vertex.
31//!
32//! ## Extension Support
33//!
34//! The model includes first-class support for 3MF extensions:
35//!
36//! - **Beam Lattice**: [`BeamLattice`] and [`BeamSet`] for structural lattices
37//! - **Slice**: [`SliceStack`] for layer-based geometry
38//! - **Volumetric**: [`VolumetricStack`] for voxel data
39//! - **Boolean Operations**: [`BooleanShape`] for CSG operations
40//! - **Displacement**: [`DisplacementMesh`] for texture-driven surface modification
41//! - **Secure Content**: Cryptographic features (see [`secure_content`] module)
42//!
43//! ## Design Philosophy
44//!
45//! The model follows an **immutable-by-default** design:
46//!
47//! - All structures derive `Clone` for easy copying
48//! - Modification happens via explicit operations (e.g., [`MeshRepair`] trait)
49//! - Thread-safe by default (no interior mutability)
50//! - Predictable behavior: functions don't have hidden side effects
51//!
52//! ## Re-exports
53//!
54//! For convenience, all public types are re-exported at the crate root via `pub use model::*`.
55//! You can use `lib3mf_core::Model` instead of `lib3mf_core::model::Model`.
56
57/// Build instructions — `Build` and `BuildItem` types.
58pub mod build;
59/// Root `Model` struct and its `validate` / `compute_stats` methods.
60pub mod core;
61/// XML-DSIG crypto data structures used by the Secure Content Extension.
62pub mod crypto;
63/// Material and texture types (colors, base materials, composites, etc.).
64pub mod materials;
65/// Mesh geometry types (`Mesh`, `Triangle`, `Vertex`, `BeamLattice`, etc.).
66pub mod mesh;
67/// Multi-part `Package` type for Production Extension multi-model files.
68pub mod package;
69/// Mesh repair operations (`MeshRepair` trait and `RepairStats`).
70pub mod repair;
71/// Cross-file component resolver (`PartResolver`, `ResolvedMesh`, `ResolveOptions`).
72pub mod resolver;
73/// `ResourceCollection` — central registry for all model resources.
74pub mod resources;
75/// Secure Content Extension key store types (`KeyStore`, `Consumer`, etc.).
76pub mod secure_content;
77/// Slice Extension types (`SliceStack`, `Slice`, `Polygon`, etc.).
78pub mod slice;
79/// Model statistics types returned by `Model::compute_stats()`.
80pub mod stats;
81/// Internal implementation of `compute_stats()` — not part of the public API surface.
82pub mod stats_impl;
83
84/// Unit of measurement enum and conversion utilities.
85pub mod units;
86/// Volumetric Extension types (`VolumetricStack`, `VolumetricLayer`, etc.).
87pub mod volumetric;
88
89pub use build::*;
90pub use core::*;
91pub use crypto::*;
92pub use materials::*;
93pub use mesh::*;
94pub use package::*;
95pub use repair::*;
96pub use resolver::{ResolveOptions, ResolvedMesh};
97pub use resources::*;
98pub use secure_content::*;
99pub use slice::*;
100pub use stats::*;
101
102pub use units::*;
103pub use volumetric::*;