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: f64Length unit → metres (1.0 for metre files, 0.001 for millimetre files).
plane_angle_to_radians: f64Plane-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
impl UnitScales
Sourcepub fn geometry_length_scale(&self) -> f64
pub fn geometry_length_scale(&self) -> f64
The geometry scale: 1.0 for a refused unit, a finite placeholder no mesh uses (#7678).
Sourcepub fn length_unit(&self) -> LengthUnit
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.
Sourcepub fn resolve_complete(
decoder: &mut EntityDecoder<'_>,
project_id: u32,
) -> Self
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).
Sourcepub fn resolve(
content: &[u8],
project_id_hint: Option<u32>,
decoder: &mut EntityDecoder<'_>,
) -> Self
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:
project_id_hint(recorded by the scan) — O(1) decode via the index.- No hint? Locate
IFCPROJECTwith 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). - 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
impl Clone for UnitScales
Source§fn clone(&self) -> UnitScales
fn clone(&self) -> UnitScales
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more