Skip to main content

ifc_structural/authoring/
builders.rs

1//! Constructors and builder setters for the drafts of the parent module,
2//! kept apart so the writer stays under the 800-line limit.
3
4#[allow(clippy::wildcard_imports)]
5use super::*;
6
7impl AnalysisModelDraft {
8    /// Starts a draft from its required fields; every other field is unset.
9    #[must_use]
10    pub fn new(global_id: impl Into<String>, predefined_type: AnalysisModelType) -> Self {
11        Self {
12            global_id: global_id.into(),
13            owner_history: None,
14            name: None,
15            description: None,
16            object_type: None,
17            predefined_type,
18            orientation_of_2d_plane: None,
19            loaded_by: Vec::new(),
20            result_groups: Vec::new(),
21            shared_placement: None,
22        }
23    }
24
25    /// Sets `owner_history`: `OwnerHistory`, validated against the
26    /// model/transaction if present.
27    #[must_use]
28    pub fn owner_history(mut self, value: EntityId) -> Self {
29        self.owner_history = Some(value);
30        self
31    }
32
33    /// Sets `name`: `Name`.
34    #[must_use]
35    pub fn name(mut self, value: impl Into<String>) -> Self {
36        self.name = Some(value.into());
37        self
38    }
39
40    /// Sets `description`: `Description`.
41    #[must_use]
42    pub fn description(mut self, value: impl Into<String>) -> Self {
43        self.description = Some(value.into());
44        self
45    }
46
47    /// Sets `object_type`: `ObjectType`; required non-blank when
48    /// `predefined_type` is `UserDefined`.
49    #[must_use]
50    pub fn object_type(mut self, value: impl Into<String>) -> Self {
51        self.object_type = Some(value.into());
52        self
53    }
54
55    /// Sets `orientation_of_2d_plane`: `OrientationOf2DPlane`, an
56    /// `IfcAxis2Placement3D` reference.
57    #[must_use]
58    pub fn orientation_of_2d_plane(mut self, value: EntityId) -> Self {
59        self.orientation_of_2d_plane = Some(value);
60        self
61    }
62
63    /// Sets `loaded_by`: `LoadedBy`, `IfcStructuralLoadGroup` references;
64    /// members must be unique.
65    #[must_use]
66    pub fn loaded_by(mut self, value: Vec<EntityId>) -> Self {
67        self.loaded_by = value;
68        self
69    }
70
71    /// Sets `result_groups`: `HasResults`, `IfcStructuralResultGroup`
72    /// references; members must be unique.
73    #[must_use]
74    pub fn result_groups(mut self, value: Vec<EntityId>) -> Self {
75        self.result_groups = value;
76        self
77    }
78
79    /// Sets `shared_placement`: `SharedPlacement`; only staged when the target
80    /// schema declares the attribute.
81    #[must_use]
82    pub fn shared_placement(mut self, value: EntityId) -> Self {
83        self.shared_placement = Some(value);
84        self
85    }
86}