pub struct MaterialIndex<'m> { /* private fields */ }Expand description
The material of many objects, resolved in one pass over the model.
MaterialView::assigned_material decodes the whole RelatedObjects of
every relationship naming the object on each call, so resolving every
product of a model whose relationships share long lists costs the square
of the list length. MaterialIndex::new reads the
IfcRelAssociatesMaterial and IfcRelDefinesByType records once and
checks each one’s RelatedObjects once; a lookup then costs the
relationships that name the object.
Every answer, refusals included, equals the view’s: both run one shared
code path, and a relationship whose RelatedObjects is malformed refuses
every object it names, exactly as the view does. The index borrows the
model, so it cannot go stale: the model cannot change while it lives.
When something built the model’s reverse index the index reads through
it; otherwise it builds its own over those two record types only. It
never leaves an index on the model.
let index = MaterialIndex::new(MaterialView::new(model));
for &p in products {
index.assigned_material(p)?;
}Implementations§
Source§impl<'m> MaterialIndex<'m>
impl<'m> MaterialIndex<'m>
Sourcepub fn new(view: MaterialView<'m>) -> Self
pub fn new(view: MaterialView<'m>) -> Self
Indexes the material and typing relationships of view’s model.
Infallible: a malformed relationship is recorded and refuses the objects it names at lookup, as the view would.
Sourcepub fn view(&self) -> MaterialView<'m>
pub fn view(&self) -> MaterialView<'m>
The view this index answers for.
Sourcepub fn assignments_for(
&self,
object: EntityId,
) -> MaterialResult<Vec<MaterialAssignment<'m>>>
pub fn assignments_for( &self, object: EntityId, ) -> MaterialResult<Vec<MaterialAssignment<'m>>>
Sourcepub fn assigned_material(
&self,
object: EntityId,
) -> MaterialResult<Option<ResolvedAssignment<'m>>>
pub fn assigned_material( &self, object: EntityId, ) -> MaterialResult<Option<ResolvedAssignment<'m>>>
MaterialView::assigned_material, answered from the index.
§Errors
Trait Implementations§
Source§impl<'m> Clone for MaterialIndex<'m>
impl<'m> Clone for MaterialIndex<'m>
Source§fn clone(&self) -> MaterialIndex<'m>
fn clone(&self) -> MaterialIndex<'m>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more