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(
14            "IFCMATERIALPROFILESET",
15            self.id(),
16            self.entity(),
17            self.slot("Name")?,
18            "Name",
19        )
20    }
21
22    /// `IfcMaterialProfileSet.Description`, if given.
23    pub fn description(self) -> MaterialResult<Option<&'m str>> {
24        optional_text(
25            "IFCMATERIALPROFILESET",
26            self.id(),
27            self.entity(),
28            self.slot("Description")?,
29            "Description",
30        )
31    }
32
33    /// `IfcMaterialProfileSet.MaterialProfiles`, in set order. Required
34    /// and must be non-empty.
35    pub fn profile_ids(self) -> MaterialResult<Vec<EntityId>> {
36        required_refs(
37            "IFCMATERIALPROFILESET",
38            self.id(),
39            self.entity(),
40            self.slot("MaterialProfiles")?,
41            "MaterialProfiles",
42            1,
43        )
44    }
45
46    /// `IfcMaterialProfileSet.CompositeProfile`, if given.
47    pub fn composite_profile_id(self) -> MaterialResult<Option<EntityId>> {
48        optional_ref(
49            "IFCMATERIALPROFILESET",
50            self.id(),
51            self.entity(),
52            self.slot("CompositeProfile")?,
53            "CompositeProfile",
54        )
55    }
56}
57
58impl<'m> MaterialView<'m> {
59    /// Iterates every `IfcMaterialProfileSet` instance in the model.
60    pub fn profile_sets(self) -> impl Iterator<Item = MaterialProfileSet<'m>> + 'm {
61        let release = self.release();
62        self.model()
63            .of_type("IFCMATERIALPROFILESET")
64            .map(move |(id, entity)| MaterialProfileSet::from_known(id, entity, release))
65    }
66}