ifc_material/material/
relationships.rs1use ifc_model::EntityId;
4
5use crate::view::{borrowed_entity, optional_text, required_ref, required_refs, MaterialView};
6use crate::MaterialResult;
7
8borrowed_entity!(
9 MaterialClassificationRelationship,
10 "IFCMATERIALCLASSIFICATIONRELATIONSHIP"
11);
12borrowed_entity!(MaterialList, "IFCMATERIALLIST");
13borrowed_entity!(MaterialRelationship, "IFCMATERIALRELATIONSHIP");
14
15impl MaterialClassificationRelationship<'_> {
16 pub fn classification_ids(self) -> MaterialResult<Vec<EntityId>> {
19 required_refs(
20 "IFCMATERIALCLASSIFICATIONRELATIONSHIP",
21 self.id(),
22 self.entity(),
23 0,
24 "MaterialClassifications",
25 1,
26 )
27 }
28
29 pub fn material_id(self) -> MaterialResult<EntityId> {
31 required_ref(
32 "IFCMATERIALCLASSIFICATIONRELATIONSHIP",
33 self.id(),
34 self.entity(),
35 1,
36 "ClassifiedMaterial",
37 )
38 }
39}
40
41impl MaterialList<'_> {
42 pub fn material_ids(self) -> MaterialResult<Vec<EntityId>> {
45 required_refs(
46 "IFCMATERIALLIST",
47 self.id(),
48 self.entity(),
49 0,
50 "Materials",
51 1,
52 )
53 }
54}
55
56impl<'m> MaterialRelationship<'m> {
57 pub fn name(self) -> MaterialResult<Option<&'m str>> {
59 optional_text(
60 "IFCMATERIALRELATIONSHIP",
61 self.id(),
62 self.entity(),
63 0,
64 "Name",
65 )
66 }
67
68 pub fn description(self) -> MaterialResult<Option<&'m str>> {
70 optional_text(
71 "IFCMATERIALRELATIONSHIP",
72 self.id(),
73 self.entity(),
74 1,
75 "Description",
76 )
77 }
78
79 pub fn relating_material_id(self) -> MaterialResult<EntityId> {
81 required_ref(
82 "IFCMATERIALRELATIONSHIP",
83 self.id(),
84 self.entity(),
85 2,
86 "RelatingMaterial",
87 )
88 }
89
90 pub fn related_material_ids(self) -> MaterialResult<Vec<EntityId>> {
93 required_refs(
94 "IFCMATERIALRELATIONSHIP",
95 self.id(),
96 self.entity(),
97 3,
98 "RelatedMaterials",
99 1,
100 )
101 }
102
103 pub fn expression(self) -> MaterialResult<Option<&'m str>> {
105 optional_text(
106 "IFCMATERIALRELATIONSHIP",
107 self.id(),
108 self.entity(),
109 4,
110 "Expression",
111 )
112 }
113}
114
115impl<'m> MaterialView<'m> {
116 pub fn classification_relationships(
118 self,
119 ) -> impl Iterator<Item = MaterialClassificationRelationship<'m>> + 'm {
120 self.model()
121 .of_type("IFCMATERIALCLASSIFICATIONRELATIONSHIP")
122 .map(|(id, entity)| MaterialClassificationRelationship::from_known(id, entity))
123 }
124
125 pub fn material_lists(self) -> impl Iterator<Item = MaterialList<'m>> + 'm {
127 self.model()
128 .of_type("IFCMATERIALLIST")
129 .map(|(id, entity)| MaterialList::from_known(id, entity))
130 }
131
132 pub fn material_relationships(self) -> impl Iterator<Item = MaterialRelationship<'m>> + 'm {
134 self.model()
135 .of_type("IFCMATERIALRELATIONSHIP")
136 .map(|(id, entity)| MaterialRelationship::from_known(id, entity))
137 }
138}