pub struct MeasuredTolerance { /* private fields */ }Expand description
A deviation measured between a constructed entity and the geometry that entity was built to reproduce, recorded next to the derived band it was judged against.
§Why this type exists
Everything above this line in this module is derived: a band predicted
from a size (model_scale), a policy field, or a constant, computed
before the geometry exists. Nothing above this line ever looks at what
the construction actually produced. A collocation fit, a polyline
interpolation or a marched section can miss its intended locus by far more
(or, far more often, far less) than the derived band assumed, and today that
number is either thrown away or never taken.
This is the other half, and it is the half OCCT has and we did not:
BRepOffset_SimpleOffset::FillEdgeData sets an edge’s tolerance to the
measured maximum distance between its new 3D curve and its pcurve on the
offset surface, over every adjacent face
(BRepOffset_SimpleOffset.cxx:296-310), and UpdateTolerance
(BRepOffset_MakeOffset.cxx:4196-4302) re-measures and raises after the
whole pipeline has run. See
docs/developer/kernel-plans/occt-offset-algorithms.md §6.
§The direction rule — this may never loosen anything
A MeasuredTolerance is a record of what happened, not a budget to
spend. The measured number may flow into
- a diagnostic,
- a refusal message,
- a comparison against a derived band that tightens an existing gate,
and nowhere else. It must never be max-ed into an acceptance band, a weld
radius or a search radius, because a construction would then certify its own
error: the sloppier the fit, the wider the band that judges it. That is the
self-certification failure per-entity-tolerances.md’s invariant I1 excludes
structurally, and it is why this type deliberately exposes no
f64-producing “band to use” accessor — only Self::deviation (what
happened), Self::band (what was demanded), and the verdict between them.
§Where it lives
Alongside the constructed entity, in the transient result struct the
construction already returns — never as a field on crate::BrepSolid’s
records. BrepSolid is serialized by io/snapshot.rs, which is a
documented durable format; a record field would be a format change with a
reader obligation. Persisting per-entity tolerances is a real and planned
piece of work with its own design
(docs/developer/kernel-plans/per-entity-tolerances.md, slice S3) — this
type is the measurement layer beneath it, and lands with no format churn at
all.
Implementations§
Source§impl MeasuredTolerance
impl MeasuredTolerance
Sourcepub fn new(deviation: f64, band: f64) -> Self
pub fn new(deviation: f64, band: f64) -> Self
Record deviation against the derived band that was in force.
Both arguments are normalised in the FAIL-SAFE direction, so a
measurement that went wrong reads as “worse than the band”, never as
“fine”: a non-finite or negative deviation becomes +inf, and a
non-finite or negative band becomes 0.0. Either way
Self::exceeds_band answers true.
Sourcepub fn exact(band: f64) -> Self
pub fn exact(band: f64) -> Self
A construction with no fit to measure — a closed-form analytic result,
or an affine offset that shifts a control net rigidly. Records 0.0
deviation as a claim, which is why it is a named constructor: reading
MeasuredTolerance::exact(band) at a call site says “this lane has no
approximation error by construction”, where new(0.0, band) would read
as an unmeasured default.
Sourcepub fn within_band(&self) -> bool
pub fn within_band(&self) -> bool
The construction met the band it was judged against.
Sourcepub fn exceeds_band(&self) -> bool
pub fn exceeds_band(&self) -> bool
The construction was WORSE than the derived band assumed — the case worth acting on. A site that gates on this refuses; a site that only reports names both numbers.
Sourcepub fn utilisation(&self) -> f64
pub fn utilisation(&self) -> f64
deviation / band — how much of the derived band the construction
spent. > 1 is Self::exceeds_band; a value orders of magnitude
below 1 says the band is loose here, which is worth knowing and is
exactly what the corpus distribution reports. A zero band answers 0.0
for a zero deviation and +inf otherwise.
Sourcepub fn worse_of(self, other: Self) -> Self
pub fn worse_of(self, other: Self) -> Self
The worse of two records: the larger deviation against the tighter band.
Both halves move in the fail-safe direction, so folding a set of per-coedge or per-edge measurements can only ever make the summary harder to pass, never easier.
Sourcepub fn worst(records: impl IntoIterator<Item = Self>) -> Option<Self>
pub fn worst(records: impl IntoIterator<Item = Self>) -> Option<Self>
Fold a set of measurements into their worst, or None when empty.
Trait Implementations§
Source§impl Clone for MeasuredTolerance
impl Clone for MeasuredTolerance
Source§fn clone(&self) -> MeasuredTolerance
fn clone(&self) -> MeasuredTolerance
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more