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
impl Model
pub fn new() -> Self
pub fn get(&self, id: &GlobalId) -> Option<&ElementRecord>
pub fn contains(&self, id: &GlobalId) -> bool
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> impl Iterator<Item = &ElementRecord>
pub fn revision(&self) -> u64
pub fn history(&self) -> &[Revision]
pub fn can_undo(&self) -> bool
pub fn can_redo(&self) -> bool
Sourcepub fn by_class<'a>(
&'a self,
class: &'a IfcClass,
) -> impl Iterator<Item = &'a ElementRecord>
pub fn by_class<'a>( &'a self, class: &'a IfcClass, ) -> impl Iterator<Item = &'a ElementRecord>
Elements of a class, in stable order.
Sourcepub fn contained_in<'a>(
&'a self,
container: &'a GlobalId,
) -> impl Iterator<Item = &'a ElementRecord>
pub fn contained_in<'a>( &'a self, container: &'a GlobalId, ) -> impl Iterator<Item = &'a ElementRecord>
Elements contained in a spatial structure element.
Sourcepub fn voids(&self) -> impl Iterator<Item = (&GlobalId, &GlobalId)>
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.
Sourcepub fn fills(&self) -> impl Iterator<Item = (&GlobalId, &GlobalId)>
pub fn fills(&self) -> impl Iterator<Item = (&GlobalId, &GlobalId)>
Every (opening, filler) pair, in stable order. See Model::voids.
Sourcepub fn openings_of<'a>(
&'a self,
host: &'a GlobalId,
) -> impl Iterator<Item = &'a GlobalId>
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.
Sourcepub fn fills_of<'a>(
&'a self,
opening: &'a GlobalId,
) -> impl Iterator<Item = &'a GlobalId>
pub fn fills_of<'a>( &'a self, opening: &'a GlobalId, ) -> impl Iterator<Item = &'a GlobalId>
Elements filling an opening (IfcRelFillsElement).
Sourcepub fn host_of(&self, opening: &GlobalId) -> Option<&GlobalId>
pub fn host_of(&self, opening: &GlobalId) -> Option<&GlobalId>
The host an opening cuts, if any.
Sourcepub fn bounds(&self) -> BoundingBox
pub fn bounds(&self) -> BoundingBox
World bounds of everything with evaluated geometry.
Sourcepub fn spatial_index(&self) -> SpatialIndex
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).
Sourcepub fn set_bounds(&mut self, id: &GlobalId, bounds: Option<BoundingBox>) -> bool
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).
Sourcepub fn apply(
&mut self,
command: ModelCommand,
) -> Result<CommandOutcome, CommandError>
pub fn apply( &mut self, command: ModelCommand, ) -> Result<CommandOutcome, CommandError>
Apply a command, recording it for undo.
Sourcepub fn apply_all(
&mut self,
commands: impl IntoIterator<Item = ModelCommand>,
) -> Result<Vec<CommandOutcome>, CommandError>
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.