ifc_lite_geometry/representation/
structural.rs1use ifc_lite_core::{slot, DecodedEntity, EntityDecoder, IfcType};
8
9#[inline]
12pub fn product_shape_id(element: &DecodedEntity) -> Option<u32> {
13 element.get_ref(slot::IfcProduct::REPRESENTATION.index())
14}
15
16#[inline]
20pub fn rep_item_ids(rep: &DecodedEntity) -> impl Iterator<Item = u32> + '_ {
21 rep.get_list(slot::IfcRepresentation::ITEMS.index())
22 .into_iter()
23 .flatten()
24 .filter_map(|value| value.as_entity_ref())
25}
26
27#[inline]
31pub fn pds_representation_ids(pds: &DecodedEntity) -> impl Iterator<Item = u32> {
32 pds.get_refs(slot::IfcProductDefinitionShape::REPRESENTATIONS.index())
33 .unwrap_or_default()
34 .into_iter()
35}
36
37#[inline]
43pub fn mapped_item_representation_id(item: &DecodedEntity, decoder: &mut EntityDecoder<'_>) -> Option<u32> {
44 let source_id = item.get_ref(slot::IfcMappedItem::MAPPING_SOURCE.index())?;
45 let source = decoder.decode_by_id(source_id).ok()?;
46 source.get_ref(slot::IfcRepresentationMap::MAPPED_REPRESENTATION.index())
47}
48
49pub(crate) fn reference_only_opening(id: u32, decoder: &mut EntityDecoder<'_>) -> Option<bool> {
54 let opening = decoder.decode_by_id(id).ok()?;
55 if !opening.ifc_type.is_subtype_of(IfcType::IfcOpeningElement) {
56 return None;
57 }
58 let pds = decoder.decode_by_id(product_shape_id(&opening)?).ok()?;
59 if pds.ifc_type != IfcType::IfcProductDefinitionShape {
60 return None;
61 }
62 let representations = pds.get_list(slot::IfcProductDefinitionShape::REPRESENTATIONS.index())?;
63 if representations.is_empty() || representations.len() > 64 {
64 return None;
65 }
66 let mut reference = false;
67 for value in representations {
68 let representation = decoder.decode_by_id(value.as_entity_ref()?).ok()?;
69 if representation.ifc_type != IfcType::IfcShapeRepresentation {
70 return None;
71 }
72 match super::effective_element_rep_type(&opening, &representation) {
73 Some("Reference") => reference = true,
74 Some("BoundingBox") => {}
75 _ => return None,
76 }
77 }
78 Some(reference)
79}
80
81#[cfg(test)]
82#[path = "structural_tests.rs"]
83mod tests;