pub struct SpatialTree { /* private fields */ }Expand description
The containment tree of one model.
Implementations§
Source§impl SpatialTree
impl SpatialTree
Sourcepub fn build(model: &Model) -> Self
pub fn build(model: &Model) -> Self
Build the containment tree of model.
One pass over the aggregation, containment and spatial reference relationships. Cost is linear in the number of relationship entities, not in model size, because relationships are found through the type index.
Containers are classified against the release the file’s
FILE_SCHEMA declares (see release): an entity is
a container when that release declares it an IfcSpatialElement
(IFC2X3: IfcSpatialStructureElement), or it is the IfcProject.
Source§impl SpatialTree
impl SpatialTree
Sourcepub fn release(&self) -> Option<SchemaVersion>
pub fn release(&self) -> Option<SchemaVersion>
The release the containers were classified against: the one the
file’s FILE_SCHEMA names, when it names exactly one bundled release
(IFC2X3, IFC4, IFC4X3).
None when the header names none, several, or another release: an
entity is then a container when any bundled release declares it a
spatial element, as SpatialKind::classify answers.
Sourcepub fn node(&self, id: EntityId) -> Option<&SpatialNode>
pub fn node(&self, id: EntityId) -> Option<&SpatialNode>
The node describing id, if it is a spatial container.
Sourcepub fn roots(&self) -> &[EntityId]
pub fn roots(&self) -> &[EntityId]
Containers with no parent, most-general kind first.
A conformant file yields exactly one root, the IfcProject. More than
one means the file omits an aggregation relationship somewhere.
Sourcepub fn containers(&self) -> impl Iterator<Item = &SpatialNode>
pub fn containers(&self) -> impl Iterator<Item = &SpatialNode>
Every spatial container in the model, ordered by entity id.
Sourcepub fn of_kind(
&self,
kind: SpatialKind,
) -> impl Iterator<Item = &SpatialNode> + '_
pub fn of_kind( &self, kind: SpatialKind, ) -> impl Iterator<Item = &SpatialNode> + '_
Containers of a given kind, ordered by entity id.
Sourcepub fn elements_of(&self, container: EntityId) -> &[EntityId]
pub fn elements_of(&self, container: EntityId) -> &[EntityId]
Elements placed directly in container.
Direct only: an element in a space inside a storey is not returned for
the storey. Use elements_recursive for the
transitive set.
Sourcepub fn elements_recursive(&self, container: EntityId) -> Vec<EntityId>
pub fn elements_recursive(&self, container: EntityId) -> Vec<EntityId>
Every element in container or any container beneath it.
Breadth-first, so a container’s own elements precede those of its children. Bounded by the tree’s depth, which is finite because each node holds at most one parent.
Sourcepub fn ancestors(&self, id: EntityId) -> Vec<EntityId>
pub fn ancestors(&self, id: EntityId) -> Vec<EntityId>
The chain of containers above id, nearest first.
Empty for a root. Terminates even if the file contains a containment cycle, because the walk stops at the first repeated entity.
Sourcepub fn container_of(&self, element: EntityId) -> Option<EntityId>
pub fn container_of(&self, element: EntityId) -> Option<EntityId>
The container holding element, if any relationship places it.
Answers the question a drawing or take-off actually asks: which storey is this wall on? Backed by a map built during assembly, so this is a lookup rather than a scan over every container.
Sourcepub fn dangling(&self) -> &[(EntityId, EntityId)]
pub fn dangling(&self) -> &[(EntityId, EntityId)]
Relationship/target pairs naming an entity the model does not contain.
Sourcepub fn anomalies(&self) -> &[SpatialAnomaly]
pub fn anomalies(&self) -> &[SpatialAnomaly]
Second parents the file states and the tree rejected, in the order relationships were applied.
Empty for a conformant file. Each entry names the relationship whose claim was dropped, so a caller can point at the offending record.
Sourcepub fn orphans(&self) -> &[EntityId]
pub fn orphans(&self) -> &[EntityId]
Containers that no relationship places under a parent, excluding the most-general root.
A conformant file has none: every site is aggregated into the project, every building into a site. Entries here mean the file omits an aggregation relationship, which a viewer would show as a detached branch.
Source§impl SpatialTree
impl SpatialTree
Sourcepub fn referenced_elements(&self, container: EntityId) -> &[EntityId]
pub fn referenced_elements(&self, container: EntityId) -> &[EntityId]
Elements IfcRelReferencedInSpatialStructure references in
container, in file order, each once.
Disjoint in meaning from elements_of: a
referenced element is contained elsewhere (or nowhere). An element
the file both contains and references in one container appears in
both lists, because the file states both.
Sourcepub fn referencing_structures(&self, element: EntityId) -> &[EntityId]
pub fn referencing_structures(&self, element: EntityId) -> &[EntityId]
Containers that reference element, in file order, each once.
Empty for an element that is only contained; its container is
container_of.