Skip to main content

GeometrySource

Trait GeometrySource 

Source
pub trait GeometrySource: Send + Sync {
    // Required methods
    fn entities_with_geometry(&self) -> Vec<EntityId>;
    fn has_geometry(&self, id: EntityId) -> bool;
    fn get_geometry(&self, id: EntityId) -> Option<EntityGeometry>;

    // Provided methods
    fn batch_geometry(
        &self,
        ids: &[EntityId],
    ) -> Vec<(EntityId, EntityGeometry)> { ... }
    fn default_color(&self, ifc_type: &IfcType) -> [f32; 4] { ... }
    fn total_triangle_count(&self) -> usize { ... }
}
Expand description

Geometry source for rendering

Provides access to processed geometry data ready for GPU rendering. Implementations handle geometry processing, caching, and color assignment.

§Example

use bimifc_model::{GeometrySource, EntityId};

fn render_model(geometry: &dyn GeometrySource) {
    // Get all entities with geometry
    let entities = geometry.entities_with_geometry();
    println!("Rendering {} entities", entities.len());

    // Process each entity
    for id in entities {
        if let Some(geom) = geometry.get_geometry(id) {
            println!("Entity {:?}: {} triangles", id, geom.triangle_count());
            // Submit to GPU...
        }
    }

    // Or batch process for efficiency
    let all_geom = geometry.batch_geometry(&entities);
    for (id, geom) in all_geom {
        // Submit to GPU...
    }
}

Required Methods§

Source

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

Get all entity IDs that have processable geometry

§Returns

A vector of entity IDs that have geometry representations

Source

fn has_geometry(&self, id: EntityId) -> bool

Check if an entity has processable geometry

§Arguments
  • id - The entity ID to check
§Returns

true if the entity has geometry that can be processed

Source

fn get_geometry(&self, id: EntityId) -> Option<EntityGeometry>

Get processed geometry for a single entity

§Arguments
  • id - The entity ID to get geometry for
§Returns

The processed geometry if available

Provided Methods§

Source

fn batch_geometry(&self, ids: &[EntityId]) -> Vec<(EntityId, EntityGeometry)>

Batch process geometry for multiple entities

This is more efficient than calling get_geometry repeatedly as it can leverage caching and parallel processing.

§Arguments
  • ids - The entity IDs to process
§Returns

A vector of (entity_id, geometry) pairs

Source

fn default_color(&self, ifc_type: &IfcType) -> [f32; 4]

Get default color for an entity type

Returns a color based on the IFC type for consistent visualization.

§Arguments
  • ifc_type - The IFC type
§Returns

RGBA color array [r, g, b, a]

Source

fn total_triangle_count(&self) -> usize

Get total triangle count for all geometry

Implementors§