Skip to main content

MaterialIndex

Struct MaterialIndex 

Source
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>

Source

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.

Source

pub fn view(&self) -> MaterialView<'m>

The view this index answers for.

Source

pub fn assignments_for( &self, object: EntityId, ) -> MaterialResult<Vec<MaterialAssignment<'m>>>

Source

pub fn assigned_material( &self, object: EntityId, ) -> MaterialResult<Option<ResolvedAssignment<'m>>>

Trait Implementations§

Source§

impl<'m> Clone for MaterialIndex<'m>

Source§

fn clone(&self) -> MaterialIndex<'m>

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 MaterialIndex<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'m> !RefUnwindSafe for MaterialIndex<'m>

§

impl<'m> !UnwindSafe for MaterialIndex<'m>

§

impl<'m> Freeze for MaterialIndex<'m>

§

impl<'m> Send for MaterialIndex<'m>

§

impl<'m> Sync for MaterialIndex<'m>

§

impl<'m> Unpin for MaterialIndex<'m>

§

impl<'m> UnsafeUnpin for MaterialIndex<'m>

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
§

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

§

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.

§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.