1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! `ifc-spatial` — containment and objectified relationship traversal.
//!
//! # The problem
//!
//! IFC stores no parent pointers. A wall does not name its storey; a separate
//! `IfcRelContainedInSpatialStructure` entity names both ends. Asking "which
//! elements are on this storey" therefore means finding relationship entities
//! and reading the right attribute slot — and the two relationships that build
//! the tree **disagree about which slot is which**:
//!
//! ```text
//! IfcRelAggregates 4 = RelatingObject 5 = RelatedObjects
//! IfcRelContainedInSpatialStructure 4 = RelatedElements 5 = RelatingStructure
//! ```
//!
//! Assuming a uniform layout inverts containment silently: elements become the
//! parents of their storey, and every downstream answer is wrong in a way no
//! type error catches.
//!
//! # Example
//!
//! ```no_run
//! use ifc_spatial::{SpatialKind, SpatialTree};
//! # let model = ifc_model::Model::new();
//!
//! let tree = SpatialTree::build(&model);
//!
//! for storey in tree.of_kind(SpatialKind::Storey) {
//! let elements = tree.elements_of(storey.id);
//! println!("storey {:?} holds {} elements", storey.id, elements.len());
//! }
//! ```
//!
//! # Tolerating real files
//!
//! The canonical hierarchy is project → site → building → storey → element, and
//! real exports deviate: omitted sites, elements hung directly off a building,
//! duplicate storeys, relationships naming entities that are not in the file.
//! The tree records what the file says and reports anomalies through
//! [`SpatialTree::orphans`] and [`SpatialTree::dangling`] rather than asserting
//! the ideal shape or panicking.
//!
//! # Boundaries
//!
//! This crate reads containment. It does not validate it — `ifc-validate` owns
//! WHERE rules and cardinality — and it does not interpret geometry or
//! properties of the elements it groups.
pub use ;
pub use ;
/// The IFC release a tree classifies against (re-exported from `ifc-schema`).
pub use SchemaVersion;
pub use ;
pub use ;