Skip to main content

SpatialTree

Struct SpatialTree 

Source
pub struct SpatialTree { /* private fields */ }
Expand description

The containment tree of one model.

Implementations§

Source§

impl SpatialTree

Source

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

Source

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.

Source

pub fn node(&self, id: EntityId) -> Option<&SpatialNode>

The node describing id, if it is a spatial container.

Source

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.

Source

pub fn containers(&self) -> impl Iterator<Item = &SpatialNode>

Every spatial container in the model, ordered by entity id.

Source

pub fn of_kind( &self, kind: SpatialKind, ) -> impl Iterator<Item = &SpatialNode> + '_

Containers of a given kind, ordered by entity id.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn dangling(&self) -> &[(EntityId, EntityId)]

Relationship/target pairs naming an entity the model does not contain.

Source

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.

Source

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

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for SpatialTree

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SpatialTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SpatialTree

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.