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§
Sourcefn entities_with_geometry(&self) -> Vec<EntityId>
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
Sourcefn has_geometry(&self, id: EntityId) -> bool
fn has_geometry(&self, id: EntityId) -> bool
Sourcefn get_geometry(&self, id: EntityId) -> Option<EntityGeometry>
fn get_geometry(&self, id: EntityId) -> Option<EntityGeometry>
Provided Methods§
Sourcefn batch_geometry(&self, ids: &[EntityId]) -> Vec<(EntityId, EntityGeometry)>
fn batch_geometry(&self, ids: &[EntityId]) -> Vec<(EntityId, EntityGeometry)>
Sourcefn default_color(&self, ifc_type: &IfcType) -> [f32; 4]
fn default_color(&self, ifc_type: &IfcType) -> [f32; 4]
Sourcefn total_triangle_count(&self) -> usize
fn total_triangle_count(&self) -> usize
Get total triangle count for all geometry