ifc_lite_export/rhino/
options.rs

1// SPDX-License-Identifier: MPL-2.0
2//! What a Rhino scene export can be asked for. The defaults are the decisions
3//! recorded in `docs/architecture/rhino-3dm-export.md` ("Decisions").
4
5use serde::Deserialize;
6
7/// Output length unit. `Source` reads the IFC project length unit.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Deserialize)]
9#[serde(rename_all = "kebab-case")]
10pub enum RhinoUnits {
11    /// The project length unit when it is a Rhino unit, else metres with a warning.
12    #[default]
13    Source,
14    Meters,
15    Millimeters,
16    Centimeters,
17    Feet,
18    Inches,
19}
20
21/// Which frame vertices are written in.
22#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Deserialize)]
23#[serde(rename_all = "kebab-case")]
24pub enum RhinoCoordinates {
25    /// The pipeline's mesh frame: IFC world for a model near the origin, the
26    /// shifted frame for a rebased one (the shift goes to `IFC::WorldFromModel`).
27    #[default]
28    Local,
29    /// IFC world coordinates (survey grid).
30    World,
31}
32
33/// How objects are sorted onto layers.
34#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Deserialize)]
35#[serde(rename_all = "kebab-case")]
36pub enum RhinoLayerScheme {
37    /// Project / site / building / storey layers, one class sublayer per IFC class.
38    #[default]
39    SpatialClass,
40    /// One layer per IFC class under the project root.
41    Class,
42    /// One layer per `IfcPresentationLayerAssignment` name under the project root.
43    Presentation,
44}
45
46/// How much IFC data goes into each object's user text.
47#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Deserialize)]
48#[serde(rename_all = "kebab-case")]
49pub enum RhinoProperties {
50    /// Attributes plus every property and quantity, type sets inherited.
51    #[default]
52    All,
53    /// `IFC::*` attribute keys only.
54    Attributes,
55    /// `IFC::GlobalId`, `IFC::Class` and `IFC::ExpressId` only.
56    None,
57}
58
59/// Options for [`build_rhino_scene`](super::build_rhino_scene). The `.3dm`
60/// archive version is an adapter option and is not here.
61#[derive(Debug, Clone, PartialEq, Deserialize)]
62#[serde(default, rename_all = "camelCase", deny_unknown_fields)]
63pub struct RhinoSceneOptions {
64    pub units: RhinoUnits,
65    pub coordinates: RhinoCoordinates,
66    pub layer_scheme: RhinoLayerScheme,
67    /// Repeated mapped geometry becomes block definitions and instances.
68    pub instancing: bool,
69    pub properties: RhinoProperties,
70    /// Emit `IfcSpace` objects (on a hidden layer).
71    pub include_spaces: bool,
72    /// Write the pipeline's vertex normals.
73    pub normals: bool,
74    /// Material-layer wall slicing.
75    pub layer_slicing: bool,
76    /// Exclude these express ids (hidden in the viewer).
77    pub hidden: Vec<u32>,
78    /// Restrict to these express ids. `None` is no filter; `Some(empty)` is an
79    /// active filter that matches nothing (as `GltfOptions::isolated`).
80    pub isolated: Option<Vec<u32>>,
81    /// Exclude objects of these IFC classes.
82    pub hidden_types: Vec<String>,
83}
84
85impl Default for RhinoSceneOptions {
86    fn default() -> Self {
87        Self {
88            units: RhinoUnits::Source,
89            coordinates: RhinoCoordinates::Local,
90            layer_scheme: RhinoLayerScheme::SpatialClass,
91            instancing: true,
92            properties: RhinoProperties::All,
93            include_spaces: true,
94            normals: true,
95            layer_slicing: false,
96            hidden: Vec::new(),
97            isolated: None,
98            hidden_types: Vec::new(),
99        }
100    }
101}