Skip to main content

SpatialQuery

Trait SpatialQuery 

Source
pub trait SpatialQuery: Send + Sync {
    // Required methods
    fn spatial_tree(&self) -> Option<&SpatialNode>;
    fn storeys(&self) -> Vec<StoreyInfo>;
    fn elements_in_storey(&self, storey_id: EntityId) -> Vec<EntityId>;
    fn containing_storey(&self, element_id: EntityId) -> Option<EntityId>;
    fn search(&self, query: &str) -> Vec<EntityId>;
    fn elements_by_type(&self, ifc_type: &IfcType) -> Vec<EntityId>;

    // Provided methods
    fn all_elements(&self) -> Vec<EntityId> { ... }
    fn element_count(&self) -> usize { ... }
}
Expand description

Spatial query interface

Provides access to the spatial structure hierarchy and search capabilities.

§Example

use bimifc_model::{SpatialQuery, EntityId};

fn explore_building(spatial: &dyn SpatialQuery) {
    // Get spatial tree
    if let Some(tree) = spatial.spatial_tree() {
        println!("Project: {}", tree.name);
        for child in &tree.children {
            println!("  {}: {}", child.node_type.display_name(), child.name);
        }
    }

    // List storeys
    for storey in spatial.storeys() {
        println!("Storey {} at elevation {}m ({} elements)",
            storey.name, storey.elevation, storey.element_count);
    }

    // Search for walls
    let wall_ids = spatial.search("wall");
    println!("Found {} walls", wall_ids.len());
}

Required Methods§

Source

fn spatial_tree(&self) -> Option<&SpatialNode>

Get the spatial hierarchy tree

Returns the root of the spatial structure tree (typically IfcProject). The tree contains all spatial structure elements and their contained elements.

§Returns

The root spatial node, or None if no spatial structure exists

Source

fn storeys(&self) -> Vec<StoreyInfo>

Get all building storeys

Returns information about all storeys in the model, sorted by elevation.

§Returns

A vector of storey information

Source

fn elements_in_storey(&self, storey_id: EntityId) -> Vec<EntityId>

Get elements contained in a storey

§Arguments
  • storey_id - The storey entity ID
§Returns

A vector of element IDs contained in the storey

Source

fn containing_storey(&self, element_id: EntityId) -> Option<EntityId>

Get the containing storey for an element

§Arguments
  • element_id - The element entity ID
§Returns

The storey ID if the element is contained in a storey

Source

fn search(&self, query: &str) -> Vec<EntityId>

Search entities by name or type

Performs a case-insensitive search across entity names and types.

§Arguments
  • query - The search query string
§Returns

A vector of matching entity IDs

Source

fn elements_by_type(&self, ifc_type: &IfcType) -> Vec<EntityId>

Get elements of a specific type

§Arguments
  • ifc_type - The IFC type to filter by
§Returns

A vector of entity IDs of the specified type

Provided Methods§

Source

fn all_elements(&self) -> Vec<EntityId>

Get all building elements (walls, slabs, etc.)

§Returns

A vector of all building element IDs

Source

fn element_count(&self) -> usize

Get element count

Implementors§