Skip to main content

Crate ifc_spatial

Crate ifc_spatial 

Source
Expand description

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:

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

use ifc_spatial::{SpatialKind, SpatialTree};

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.

Re-exports§

pub use relation::BoundaryExposure;
pub use relation::BoundaryPhysicality;
pub use relation::Relationship;
pub use relation::RelationshipIndex;
pub use relation::RelationshipKind;
pub use relation::SpaceBoundary;
pub use facility::create_facility;
pub use facility::Facility;
pub use facility::FacilityDraft;
pub use facility::FacilityError;
pub use facility::FacilityResult;
pub use authoring::aggregate;
pub use authoring::connect_path_elements;
pub use authoring::contain;
pub use authoring::create_external_spatial_element;
pub use authoring::create_project;
pub use authoring::create_project_library;
pub use authoring::create_space_boundary;
pub use authoring::create_spatial_element;
pub use authoring::BoundaryDraft;
pub use authoring::BoundaryLevel;
pub use authoring::ExternalSpatialDraft;
pub use authoring::ProjectLibraryDraft;
pub use authoring::SpatialAuthoringError;
pub use authoring::SpatialAuthoringResult;
pub use authoring::SpatialDraft;

Modules§

authoring
Transactional authoring of the spatial structure.
facility
Facilities and facility parts: the non-building spatial containers.
relation
Objectified relationship access.

Structs§

SpatialNode
One entity’s place in the containment tree.
SpatialTree
The containment tree of one model.

Enums§

SpatialKind
The spatial role of an entity, as far as containment is concerned.