resolve_unit_scales

Function resolve_unit_scales 

Source
pub fn resolve_unit_scales(
    content: &[u8],
    project_id_hint: Option<u32>,
    decoder: &mut EntityDecoder<'_>,
) -> UnitScales
Expand description

Resolve BOTH unit 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? Find IFCPROJECT by 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.

This is the only sanctioned place that hunts for IFCPROJECT; per-element decoders are seeded from the result (EntityDecoder::seed_unit_scales) so the historic O(file)-scan-per-decoder stall class stays dead.