Skip to main content

MeasuredTolerance

Struct MeasuredTolerance 

Source
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. Their model throughout is measure, do not assume: no tolerance in that pipeline is predicted from a size heuristic, each is measured off the geometry that was actually built and then propagated up the entity hierarchy.

§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

Source

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.

Source

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.

Source

pub fn deviation(&self) -> f64

What the construction actually did.

Source

pub fn band(&self) -> f64

What the size-derived policy demanded of it.

Source

pub fn within_band(&self) -> bool

The construction met the band it was judged against.

Source

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.

Source

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.

Source

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.

Source

pub fn worst(records: impl IntoIterator<Item = Self>) -> Option<Self>

Fold a set of measurements into their worst, or None when empty.

Source

pub fn describe(&self) -> String

measured 1.234e-7 against band 4.000e-3 — the shared wording for refusal messages and diagnostics, so every site that reports a measured deviation reports both numbers in the same form.

Trait Implementations§

Source§

impl Clone for MeasuredTolerance

Source§

fn clone(&self) -> MeasuredTolerance

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 Copy for MeasuredTolerance

Source§

impl Debug for MeasuredTolerance

Source§

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

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

impl PartialEq for MeasuredTolerance

Source§

fn eq(&self, other: &MeasuredTolerance) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for MeasuredTolerance

Auto Trait Implementations§

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

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

fn try_from(value: U) -> Result<T, !>

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

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more