Module prepass

Module prepass 

Source
Expand description

Canonical prepass resolution — the single post-scan step that turns the entity spans a scan collected into the style / material / void context the per-element producer (crate::element) consumes.

Both pipelines run this exact code:

  • the native orchestrator (processor.rs) span-stashes during its scan and resolves here before the rayon loop;
  • the browser prepasses (buildPrePassOnce / buildPrePassStreaming in wasm-bindings) span-stash during their scans and resolve here before serialising the flat wire arrays.

The two scan loops remain per-pipeline (they are mechanical match-arms over type names with pipeline-specific extras: quick-metadata, properties, incremental job emission), but everything SEMANTIC — styled-item precedence, IfcIndexedColourMap fallback, the #407 material chain, void collection and aggregate propagation (#845), and unit-scale resolution — lives here exactly once. The historic #858/#913-class drift was always in this resolution layer, not in the span stashing.

Structs§

PrepassSpans
Entity spans a scan collected for post-scan resolution (no mid-scan decode).
ResolveOptions
Resolution switches (both pipelines share the resolver).
ResolvedPrepass
Everything the post-scan resolution produces.
UnitScales
The file’s unit scales, resolved exactly once per parse.

Functions§

find_ifcproject_id
Find the singleton IFCPROJECT’s express id by SIMD substring search — no full entity scan. Returns None when the file has no project.
finish_from_wire
Decode one [metallic, roughness] wire pair. A non-finite field is unauthored; a pair with neither field authored is no finish at all.
finish_to_wire
One style’s [metallic, roughness] wire pair; f32::NAN marks a field the file did not author. Inverse: finish_from_wire.
flat_material_colors
Flat wire encoding of the element material colour lists (#407/#913 §2.3): (element_ids, counts, rgba8) — counts[i] colours belong to element_ids[i], in order, 4 bytes each.
flat_styles_rgba8
Flat wire encodings of the resolved styles for the browser’s styleIds/styleColors arrays: the rich style index flattened to (ids, rgba8), with IfcIndexedColourMap dominants, flat material colours, and per-element first material colours filling the gaps — the exact layered precedence the browser prepasses have always shipped.
flat_styles_with_finishes
flat_styles_rgba8 plus the parallel styleFinishes wire (#5582): two f32 per style id, [metallic, roughness], in the SAME order as ids, f32::NAN for an unauthored field. The id order is decided once, by the rgba8 flatten; the finishes are a per-id lookup over it into geometry_finishes (crate::prepass_styled::resolve_geometry_finishes over the same styled items). A geometry style always wins its id in that flatten, so only geometry-style entries can carry a finish; the indexed-colour, material and element-colour fallbacks are colour-only and get [NAN, NAN].
flat_voids
Flat wire encoding of the void index: (keys, counts, values) in the shape processGeometryBatch accepts.
material_colors_from_flat
Decode the flat material-colour wire arrays back into the canonical map — the inverse of flat_material_colors, used by processGeometryBatch.
merge_indexed_colours
Fold IfcIndexedColourMap dominant colours into the style index, keyed by target geometry id. or_insert preserves IFCSTYLEDITEM precedence: a geometry that already has a direct style keeps it; the indexed colour only fills the gaps (#913).
resolve_geometry_finishes
IFC-authored metallic/roughness per styled geometry item (#5582), keyed exactly like the colour index resolve_styled_items_into builds: the FIRST styled item (file order) that yields a style claims its geometry id, and the finish comes from that same chosen rendering style, so a mesh never pairs one style’s colour with another’s finish. A claim whose style authors no specular evidence is kept as an empty SpecularMaterial (it encodes to [NAN, NAN]), so a first-wins merge of sharded results cannot take a later item’s finish for it. Orphan (null-item) styled items are skipped, as they colour materials, not geometry. Fed to crate::prepass::flat_styles_with_finishes.
resolve_prepass
THE canonical post-scan resolution (file-order, first-wins precedence).
resolve_prepass_with_style_seeds
resolve_prepass with PRE-RESOLVED styled maps (sharded pre-pass). Seeds MUST install before the material/void loops: the material chain consults orphan_styled_items — injecting after loses material-dependent styles.
resolve_styled_item_spans
Resolve geometry-attached styled-item spans into a style index — the defer-mode replay (fast_first_batch), and the building block resolve_prepass uses internally.
resolve_styled_items_into
The styled-item classification/resolution loop of [resolve_prepass], exposed so the browser’s SHARDED pre-pass can fan slices of the (file- ordered) styled-item span list across workers: each worker resolves its contiguous slice with this exact loop, and the host merges shard results in shard order with first-wins per geometry id — reproducing the serial resolver’s file-order first-wins precedence (collect_geometry_style_info skips ids already present).
resolve_unit_scales
Resolve BOTH unit scales once, against the decoder’s (possibly partial) entity index, with the documented fallback ladder:
style_finishes_for_ids
The styleFinishes wire for an already-ordered id list: finish_of(id)’s finish_to_wire pair per id, in ids order. Shared by the serial flatten and the sharded finalize so both encode identically.

Type Aliases§

Span
One stashed entity span: (express_id, start, end).
StyleSeeds
Pre-resolved styled maps: (orphan id -> rgba, geometry id -> style info).