UnitScales

Struct UnitScales 

Source
pub struct UnitScales {
    pub length_unit_scale: f64,
    pub plane_angle_to_radians: f64,
    pub project_id: Option<u32>,
    pub length_unit_refused: Option<u32>,
}
Expand description

The file’s unit scales, resolved exactly once per parse.

Fields§

§length_unit_scale: f64

Length unit → metres (1.0 for metre files, 0.001 for millimetre files).

§plane_angle_to_radians: f64

Plane-angle unit → radians (1.0 for RADIAN files, π/180 for DEGREE).

§project_id: Option<u32>

The IFCPROJECT express id the scales were resolved from, when found.

§length_unit_refused: Option<u32>

The unusable length-unit factor geometry must refuse (#7678); length_unit_scale is then data-only.

Implementations§

Source§

impl UnitScales

Source

pub fn geometry_length_scale(&self) -> f64

The geometry scale: 1.0 for a refused unit, a finite placeholder no mesh uses (#7678).

Source

pub fn length_unit(&self) -> LengthUnit

The length unit as LengthUnit: the data reader’s value (main’s, an overflowing factor reading as infinity) plus the refusal geometry must follow. Never refuses itself.

Source

pub fn resolve_complete( decoder: &mut EntityDecoder<'_>, project_id: u32, ) -> Self

Resolve BOTH scales against a COMPLETE entity index, with the data path’s policy: an undecodable project or assignment leaves the metre and radian defaults, and an unusable length factor keeps main’s value in length_unit_scale while flagging length_unit_refused (D13: data never refuses, geometry does).

Source

pub fn resolve( content: &[u8], project_id_hint: Option<u32>, decoder: &mut EntityDecoder<'_>, ) -> Self

Resolve BOTH scales once, against the decoder’s (possibly partial) entity index, with the documented fallback ladder:

  1. project_id_hint (recorded by the scan) — O(1) decode via the index.
  2. No hint? Locate IFCPROJECT with the one locator (crate::find_project_id, a SIMD substring search: it is a singleton and many exporters — IfcOpenShell, Revit — emit it near the END of the file, after the scan’s early-meta point).
  3. Resolution chain incomplete on a PARTIAL index (streaming early-meta: the IFCSIUNIT chain may sit past the scan point)? Re-resolve against a freshly built FULL index rather than silently defaulting — a millimetre model resolved as metres renders 1000× oversized.

Per-element decoders are seeded from the result (EntityDecoder::seed_unit_scales) so the historic O(file)-scan-per-decoder stall class stays dead.

Trait Implementations§

Source§

impl Clone for UnitScales

Source§

fn clone(&self) -> UnitScales

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnitScales

Source§

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

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

impl Default for UnitScales

Source§

fn default() -> Self

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

impl PartialEq for UnitScales

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for UnitScales

Source§

impl StructuralPartialEq for UnitScales

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