ifc_resource/inventory/items.rs
1//! `IfcRelAssignsToGroup` membership for `IfcInventory`.
2
3use ifc_model::EntityId;
4
5use crate::error::ResourceResult;
6use crate::view::ResourceView;
7
8impl<'m, 's> ResourceView<'m, 's> {
9 /// Members of an `IfcInventory` group, authored order, via
10 /// `IfcRelAssignsToGroup.RelatingGroup`.
11 ///
12 /// `IfcGroup.IsGroupedBy` is `SET [0:?]`: an inventory may be named by
13 /// several assignment relations. Members from every authored relation
14 /// are concatenated in relation-then-list order; duplicates across
15 /// relations are preserved verbatim rather than deduplicated, since the
16 /// schema does not require assignment relations to be disjoint.
17 pub fn inventory_items(&self, inventory: EntityId) -> ResourceResult<Vec<EntityId>> {
18 self.inventory(inventory)?;
19 let mut items = Vec::new();
20 for relation in self.ids_of_ancestor("IfcRelAssignsToGroup") {
21 let record = self.record(relation, "IfcRelAssignsToGroup")?;
22 let relating_group = record.required_ref("RelatingGroup", "IfcGroup")?;
23 if relating_group != inventory {
24 continue;
25 }
26 items.extend(record.refs("RelatedObjects", "IfcObjectDefinition", 1, false, false)?);
27 }
28 Ok(items)
29 }
30}