Crate ifc_lite_cache

Crate ifc_lite_cache 

Source
Expand description

Native writer for the browser-readable .ifclite cache, format v28 (@ifc-lite/cache, packages/cache/src/types.ts FORMAT_VERSION), so a server or function can build the cache a browser then only reads (#9584).

Two entry points with one output: build_cache builds the cache in memory, build_cache_to_path streams it to a file without holding the mesh set, and the two are byte-identical for the same input and options (tests/streamed_matches_in_memory.rs). The ifc-build-cache binary is a thin CLI over the second. Both run the canonical pipeline and add no ingest or geometry of their own: the scalar sections come from ifc_lite_processing::data_model::extract_data_model_with (rooted entities; property and quantity tables off), the geometry from ifc_lite_processing::process. Each section module mirrors its TS serializer field for field and names it.

§Determinism

The output is a pure function of the source bytes and CacheOptions: meshes are chunked in the pipeline’s emit order (pinned by the mesh-determinism contract, independent of thread count), the data model’s tables are ordered, and deflate is miniz_oxide at a fixed level. The stored chunk bytes therefore differ from the TS writer’s (node zlib), which moves directory byteOffset/byteLength and can flip a chunk’s DeflateRaw flag; the inflated payloads are what the two writers share. scripts/cache-native-conformance.mjs checks both properties.

§What the native pipeline does not produce

Each is a value the format and the TS reader accept; none is faked:

  • Properties / Quantities are written empty, as the TS writer does for a STEP-parsed store (packages/cache/README.md).
  • Selection coverage (the v28 EntityIndex trailer, #9947) is written absent: it is computed by the TS parser alone (selection-relationship-index.ts), and porting it would be a second ingest implementation.
  • InstancedShards (IFNS) are never written: native process has no GPU-instancing partition, so every occurrence is a flat mesh.
  • Appearance provenance (v19) is mode 0 on every mesh and the source pool is empty: canonical-item source indices are a browser-batch output.
  • shadingColor (v25) is never present: the native pass reports one colour per mesh and no distinct authored DiffuseColour.
  • Mesh frame. Native process meshes with its own per-mesh origins (zero for most meshes; the browser path stores local-frame origins) and in its own frame tier. Its translation is recorded as wasmRtcOffset; when the IfcSite-local tier also removed the site rotation, which CoordinateInfo cannot express, the writer puts that rotation back into the stored origins, positions and normals (pipeline.rs), so every vertex reads back at MeshFrame::to_world of its pass-frame point. wasmRtcFrame, buildingRotation and boundsRecoveryFallbackCount are left absent (each is producer provenance of the browser path; buildingRotation orients camera presets and is never applied to geometry).
  • Entity rows are the data model’s rooted table and naming rules (an explicit '' Name and the own-Representation flag are re-read from the source, which the data model does not carry: row_facts.rs), not the TS parser’s row selection, so the scalar sections encode the same model the TS writer would be handed for this data, not the bytes a TS parse of the same file produces. scripts/cache-native-conformance.mjs states and checks the row-set difference against a TS parse.

Structs§

CacheOptions
What to write. Default matches the TS writer’s defaults.
CacheStats
What a build produced. Both entry points report the same values for the same input and options.

Enums§

CacheError

Constants§

FORMAT_VERSION
FORMAT_VERSION.

Functions§

build_cache
Build a complete .ifclite cache for source (the IFC STEP bytes), in memory: the pipeline retains every mesh.
build_cache_to_path
Build the same cache straight to output: byte-identical to build_cache for the same input and options, without holding the mesh set. The pipeline runs with retain_meshes off; each chunk is serialized when it closes and appended to a spool file beside output, so only the open chunks and the 44-byte directory entries stay in memory.