Skip to main content

ifc_material/profile/
set.rs

1//! Ordered `IfcMaterialProfileSet` composition.
2
3use ifc_model::EntityId;
4
5use crate::view::{borrowed_entity, optional_ref, optional_text, required_refs, MaterialView};
6use crate::MaterialResult;
7
8borrowed_entity!(MaterialProfileSet, "IFCMATERIALPROFILESET");
9
10impl<'m> MaterialProfileSet<'m> {
11    /// `IfcMaterialProfileSet.Name`, if given.
12    pub fn name(self) -> MaterialResult<Option<&'m str>> {
13        optional_text("IFCMATERIALPROFILESET", self.id(), self.entity(), 0, "Name")
14    }
15
16    /// `IfcMaterialProfileSet.Description`, if given.
17    pub fn description(self) -> MaterialResult<Option<&'m str>> {
18        optional_text(
19            "IFCMATERIALPROFILESET",
20            self.id(),
21            self.entity(),
22            1,
23            "Description",
24        )
25    }
26
27    /// `IfcMaterialProfileSet.MaterialProfiles`, in set order. Required
28    /// and must be non-empty.
29    pub fn profile_ids(self) -> MaterialResult<Vec<EntityId>> {
30        required_refs(
31            "IFCMATERIALPROFILESET",
32            self.id(),
33            self.entity(),
34            2,
35            "MaterialProfiles",
36            1,
37        )
38    }
39
40    /// `IfcMaterialProfileSet.CompositeProfile`, if given.
41    pub fn composite_profile_id(self) -> MaterialResult<Option<EntityId>> {
42        optional_ref(
43            "IFCMATERIALPROFILESET",
44            self.id(),
45            self.entity(),
46            3,
47            "CompositeProfile",
48        )
49    }
50}
51
52impl<'m> MaterialView<'m> {
53    /// Iterates every `IfcMaterialProfileSet` instance in the model.
54    pub fn profile_sets(self) -> impl Iterator<Item = MaterialProfileSet<'m>> + 'm {
55        self.model()
56            .of_type("IFCMATERIALPROFILESET")
57            .map(|(id, entity)| MaterialProfileSet::from_known(id, entity))
58    }
59}