ifc_lite_geometry/router/voids/
representation.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4//! Conservative, geometry-free routing for documented Reference openings.
5use crate::GeometryRouter;
6use ifc_lite_core::{EntityDecoder, IfcType};
7
8impl GeometryRouter {
9    /// Whether an opening must retain the canonical cutter path. Only a proven
10    /// Reference-only opening (optionally with BoundingBox) returns false.
11    /// Unknown, malformed, empty and over-budget representation data returns true
12    /// so ordinary cutter/error handling remains authoritative (#4440).
13    pub fn opening_requires_subtraction(&self, id:u32, decoder:&mut EntityDecoder<'_>)->bool {
14        let reference_only=(|| {
15            let opening=decoder.decode_by_id(id).ok()?;
16            if !opening.ifc_type.is_subtype_of(IfcType::IfcOpeningElement) {return None;}
17            let pds=decoder.decode_by_id(opening.get_ref(6)?).ok()?;
18            if pds.ifc_type!=IfcType::IfcProductDefinitionShape {return None;}
19            let representations=pds.get_list(2)?;
20            if representations.is_empty() || representations.len()>64 {return None;}
21            let mut reference=false;
22            for value in representations {
23                let representation=decoder.decode_by_id(value.as_entity_ref()?).ok()?;
24                if representation.ifc_type!=IfcType::IfcShapeRepresentation {return None;}
25                match crate::router::effective_element_rep_type(&opening,&representation) {
26                    Some("Reference")=>reference=true,
27                    Some("BoundingBox")=>{},
28                    _=>return None,
29                }
30            }
31            Some(reference)
32        })();
33        reference_only!=Some(true)
34    }
35}