1pub mod boundary;
16mod index;
17pub(crate) mod link;
18pub(crate) mod slots;
19
20pub use boundary::{
21 BoundaryExposure, BoundaryPhysicality, ConnectionGeometryAnomaly, SpaceBoundary,
22};
23pub use index::RelationshipIndex;
24pub use link::{Relationship, RelationshipKind};
25
26use ifc_model::{EntityId, Model};
27
28#[must_use]
33pub fn all(model: &Model) -> Vec<Relationship> {
34 let mut out = Vec::new();
35 for (slots, kind) in [
36 (slots::AGGREGATES, RelationshipKind::Aggregates),
37 (slots::CONTAINED_IN, RelationshipKind::ContainedIn),
38 (slots::NESTS, RelationshipKind::Nests),
39 (slots::COVERS_ELEMENTS, RelationshipKind::CoversElements),
40 (slots::COVERS_SPACES, RelationshipKind::CoversSpaces),
41 (
42 slots::INTERFERES_ELEMENTS,
43 RelationshipKind::InterferesElements,
44 ),
45 (slots::ASSIGNS_TO_ACTOR, RelationshipKind::AssignsToActor),
46 (
47 slots::ASSIGNS_TO_PROCESS,
48 RelationshipKind::AssignsToProcess,
49 ),
50 (
51 slots::ASSIGNS_TO_PRODUCT,
52 RelationshipKind::AssignsToProduct,
53 ),
54 (
55 slots::ASSIGNS_TO_GROUP_BY_FACTOR,
56 RelationshipKind::AssignsToGroupByFactor,
57 ),
58 (slots::DECLARES, RelationshipKind::Declares),
59 (slots::DEFINES_BY_OBJECT, RelationshipKind::DefinesByObject),
60 (
61 slots::FLOW_CONTROL_ELEMENTS,
62 RelationshipKind::FlowControlElements,
63 ),
64 (
65 slots::SERVICES_BUILDINGS,
66 RelationshipKind::ServicesBuildings,
67 ),
68 (
69 slots::CONNECTS_WITH_ECCENTRICITY,
70 RelationshipKind::ConnectsWithEccentricity,
71 ),
72 ] {
73 for id in model.ids_of_type(slots.type_name) {
74 if let Some(relationship) = link::read(model, *id, slots, kind) {
75 out.push(relationship);
76 }
77 }
78 }
79 for slots in slots::CONNECTS_ELEMENT_TYPES {
83 for id in model.ids_of_type(slots.type_name) {
84 if let Some(relationship) =
85 link::read(model, *id, slots, RelationshipKind::ConnectsElements)
86 {
87 out.push(relationship);
88 }
89 }
90 }
91 out
92}
93
94#[must_use]
98pub fn naming(model: &Model, target: EntityId) -> Vec<Relationship> {
99 all(model)
100 .into_iter()
101 .filter(|relationship| relationship.related.contains(&target))
102 .collect()
103}