Skip to main content

Model

Struct Model 

Source
pub struct Model { /* private fields */ }
Expand description

The semantic model.

BTreeMap/BTreeSet throughout, not hash containers: iteration order must be stable so that export from a given revision is reproducible (docs/ifc-semantics.md §7.2).

Implementations§

Source§

impl Model

Source

pub fn new() -> Self

Source

pub fn get(&self, id: &GlobalId) -> Option<&ElementRecord>

Source

pub fn contains(&self, id: &GlobalId) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn iter(&self) -> impl Iterator<Item = &ElementRecord>

Source

pub fn revision(&self) -> u64

Source

pub fn history(&self) -> &[Revision]

Source

pub fn can_undo(&self) -> bool

Source

pub fn can_redo(&self) -> bool

Source

pub fn by_class<'a>( &'a self, class: &'a IfcClass, ) -> impl Iterator<Item = &'a ElementRecord>

Elements of a class, in stable order.

Source

pub fn contained_in<'a>( &'a self, container: &'a GlobalId, ) -> impl Iterator<Item = &'a ElementRecord>

Elements contained in a spatial structure element.

Source

pub fn voids(&self) -> impl Iterator<Item = (&GlobalId, &GlobalId)>

Every (host, opening) pair, in stable order.

Prefer this over calling Model::openings_of in a loop: that is a scan per call, so walking every element with it is quadratic. Exporting a 20k-wall model took 5.9 s that way and 0.9 s this way.

Source

pub fn fills(&self) -> impl Iterator<Item = (&GlobalId, &GlobalId)>

Every (opening, filler) pair, in stable order. See Model::voids.

Source

pub fn openings_of<'a>( &'a self, host: &'a GlobalId, ) -> impl Iterator<Item = &'a GlobalId>

Openings cutting a host (IfcRelVoidsElement).

O(number of voids in the model) — it scans. Fine for answering a question about one element, wrong inside a loop over all of them; use Model::voids there. If this ever shows up in a profile for single-element queries, the fix is a secondary index keyed by host, not a change at the call site.

Source

pub fn fills_of<'a>( &'a self, opening: &'a GlobalId, ) -> impl Iterator<Item = &'a GlobalId>

Elements filling an opening (IfcRelFillsElement).

Source

pub fn host_of(&self, opening: &GlobalId) -> Option<&GlobalId>

The host an opening cuts, if any.

Source

pub fn bounds(&self) -> BoundingBox

World bounds of everything with evaluated geometry.

Source

pub fn spatial_index(&self) -> SpatialIndex

Build a spatial index over elements that have bounds.

Rebuilt rather than maintained incrementally: bulk loading an R-tree is fast, and a stale index is a far worse failure than a rebuild (docs/ifc-semantics.md §4.2).

Source

pub fn set_bounds(&mut self, id: &GlobalId, bounds: Option<BoundingBox>) -> bool

Attach evaluated geometry bounds. Not a command — bounds are a derived cache, and caches do not belong in the audit trail (docs/ifc-semantics.md ADR-001).

Source

pub fn apply( &mut self, command: ModelCommand, ) -> Result<CommandOutcome, CommandError>

Apply a command, recording it for undo.

Source

pub fn apply_all( &mut self, commands: impl IntoIterator<Item = ModelCommand>, ) -> Result<Vec<CommandOutcome>, CommandError>

Apply a batch, stopping at the first failure.

Note this is not transactional — earlier commands stay applied. Callers wanting all-or-nothing should undo back to the starting revision.

Source

pub fn undo(&mut self) -> Result<CommandOutcome, CommandError>

Source

pub fn redo(&mut self) -> Result<CommandOutcome, CommandError>

Trait Implementations§

Source§

impl Clone for Model

Source§

fn clone(&self) -> Model

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 Model

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Model

Source§

fn default() -> Model

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Model

§

impl RefUnwindSafe for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

§

impl UnwindSafe for Model

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

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.