Skip to main content

lib3mf_core/model/
package.rs

1use crate::model::Model;
2use std::collections::HashMap;
3
4/// Represents a 3MF Package, which can contain multiple model parts.
5#[derive(Debug, Clone, Default)]
6pub struct Package {
7    /// The main model part (usually /3D/3dmodel.model).
8    pub main_model: Model,
9
10    /// Additional model parts keyed by their package path.
11    pub parts: HashMap<String, Model>,
12}
13
14impl Package {
15    /// Creates a new `Package` with the given main model and no additional parts.
16    pub fn new(main_model: Model) -> Self {
17        Self {
18            main_model,
19            parts: HashMap::new(),
20        }
21    }
22
23    /// Adds an additional model part to the package, keyed by its package path.
24    pub fn add_part(&mut self, path: String, model: Model) {
25        self.parts.insert(path, model);
26    }
27}