pub struct LoweringSession<'a> { /* private fields */ }Expand description
A single recursive lowering pass over one shared graph builder.
Family lowerers take &mut LoweringSession and return NodeId. Only the
public entry point calls LoweringSession::finish.
Implementations§
Source§impl<'a> LoweringSession<'a>
impl<'a> LoweringSession<'a>
Sourcepub fn new(model: &'a Model, units: &'a UnitScale) -> Self
pub fn new(model: &'a Model, units: &'a UnitScale) -> Self
Open a session with the default recursion budget.
Sourcepub fn with_limits(
model: &'a Model,
units: &'a UnitScale,
limits: SessionLimits,
) -> Self
pub fn with_limits( model: &'a Model, units: &'a UnitScale, limits: SessionLimits, ) -> Self
Open a session with an explicit recursion budget.
Sourcepub fn with_face_policy(self, policy: DegenerateFacePolicy) -> Self
pub fn with_face_policy(self, policy: DegenerateFacePolicy) -> Self
Set what lowering does with a collapsed poly-loop face (#46).
Builder-style so the default constructors stay unchanged:
LoweringSession::new(model, units).with_face_policy(policy).
Sourcepub fn face_policy(&self) -> DegenerateFacePolicy
pub fn face_policy(&self) -> DegenerateFacePolicy
The degenerate-face policy in force.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes appended so far.
Exposed so tests can assert that a memoized hit appends nothing.
Sourcepub fn node(&mut self, node: GeometryNode) -> GeometryResult<NodeId>
pub fn node(&mut self, node: GeometryNode) -> GeometryResult<NodeId>
Append one node, attributing any graph fault to the current entity.
Sourcepub fn node_for(
&mut self,
entity: EntityId,
node: GeometryNode,
) -> GeometryResult<NodeId>
pub fn node_for( &mut self, entity: EntityId, node: GeometryNode, ) -> GeometryResult<NodeId>
Append one node, attributing any graph fault to entity.
Sourcepub fn provenance(&self) -> &ProvenanceMap
pub fn provenance(&self) -> &ProvenanceMap
Source attribution accumulated so far.
Sourcepub fn entity(
&self,
referrer: EntityId,
id: EntityId,
) -> GeometryResult<&'a Entity>
pub fn entity( &self, referrer: EntityId, id: EntityId, ) -> GeometryResult<&'a Entity>
Resolve an entity or report the dangling reference against referrer.
Sourcepub fn memoized(
&self,
entity: EntityId,
family: &'static str,
frame: Transform,
) -> Option<NodeId>
pub fn memoized( &self, entity: EntityId, family: &'static str, frame: Transform, ) -> Option<NodeId>
Look up a previously lowered result for entity under frame.
Sourcepub fn memoize(
&mut self,
entity: EntityId,
family: &'static str,
frame: Transform,
node: NodeId,
)
pub fn memoize( &mut self, entity: EntityId, family: &'static str, frame: Transform, node: NodeId, )
Record the lowered result for entity under frame.
Sourcepub fn enter(
&mut self,
entity: EntityId,
kind: &'static str,
) -> GeometryResult<()>
pub fn enter( &mut self, entity: EntityId, kind: &'static str, ) -> GeometryResult<()>
Mark entity as active in the current chain.
Returns GeometryError::CyclicChain if the entity is already active
and GeometryError::ChainTooDeep once the depth budget is exhausted.
Every successful call must be paired with LoweringSession::exit.
Sourcepub fn exit(&mut self, entity: EntityId)
pub fn exit(&mut self, entity: EntityId)
Release entity from the active chain.
Sharing is not recursion: once a subtree is complete the entity must be reachable again from a sibling branch.
Sourcepub fn slots(&self, entity: EntityId) -> GeometryResult<Slots<'a>>
pub fn slots(&self, entity: EntityId) -> GeometryResult<Slots<'a>>
Borrowed attribute view for entity.
Sourcepub fn type_name(&self, entity: EntityId) -> GeometryResult<String>
pub fn type_name(&self, entity: EntityId) -> GeometryResult<String>
Upper-cased IFC type name for entity.
Dispatch compares against canonical upper-case names because STEP files are case-insensitive in practice and exporters disagree.
Sourcepub fn unsupported(
&self,
entity: EntityId,
type_name: &str,
detail: &'static str,
) -> GeometryError
pub fn unsupported( &self, entity: EntityId, type_name: &str, detail: &'static str, ) -> GeometryError
Build a typed Unsupported error naming the offending entity.
Sourcepub fn degenerate(
&self,
entity: EntityId,
type_name: &str,
detail: impl Into<String>,
) -> GeometryError
pub fn degenerate( &self, entity: EntityId, type_name: &str, detail: impl Into<String>, ) -> GeometryError
Build a typed Degenerate error naming the offending entity.
Structurally impossible geometry is distinct from an unimplemented family: the file is understood and the shape does not exist.
Sourcepub fn check_aggregate(
&self,
entity: EntityId,
type_name: &str,
what: &'static str,
requested: u128,
) -> GeometryResult<usize>
pub fn check_aggregate( &self, entity: EntityId, type_name: &str, what: &'static str, requested: u128, ) -> GeometryResult<usize>
Check a file-declared aggregate size against the element budget.
Takes u128 so an overflowing product (triangles * 3) can be
computed in a wider type and reported honestly instead of wrapping to a
small number that passes the check. Returns the size as usize only
once it is known to fit.
Call this before reserving, not after: the point is to refuse the declaration, not to survive the allocation.
Sourcepub fn lower_operand(
&mut self,
entity: EntityId,
frame: Transform,
) -> GeometryResult<NodeId>
pub fn lower_operand( &mut self, entity: EntityId, frame: Transform, ) -> GeometryResult<NodeId>
Lower a nested operand through the total dispatcher.
Kept on the session so recursive families do not each re-import the dispatcher and risk diverging on cycle/limit handling.
Sourcepub fn finish(self, root: NodeId) -> GeometryResult<LoweredGeometry>
pub fn finish(self, root: NodeId) -> GeometryResult<LoweredGeometry>
Freeze the graph with root as its single output root.