Crate ifc_lite_export

Crate ifc_lite_export 

Source
Expand description

Domain-format exporters for ifc-lite.

Phase 1: HBJSON (Honeybee energy-model) room export — the analytic, watertight IFC→Ladybug bridge. Apertures/doors/shades and a glTF migration follow.

This is the Rust source of truth; CLI / SDK / wasm become thin callers (mirroring how geometry already flows through ifc-lite-wasm).

Modules§

csv_cell
The single CSV cell escaper for this crate — RFC 4180 quoting plus the CWE-1236 formula-injection guard, pinned to the TypeScript half by tests/csv_cell_parity.rs. THE CSV cell escaper for this repository’s Rust.
rooted_type
Schema-driven IfcRoot rootedness check, extracted as a standalone unit.
source_header
Read the ISO 10303-21 HEADER section of a source file into the structured form the writer needs to round-trip header fidelity.

Structs§

AttrMutation
A single root-attribute edit: replace the top-level attribute at index of entity express_id with value (already STEP-serialized, e.g. 'New Name' or $). This is the wasm-bridge form of a MutablePropertyView UPDATE_ATTRIBUTE mutation.
AuthoredQuantity
An IFC-authored physical simple quantity, with its two source entity IDs.
AuthoredQuantityAnalysis
Observations keyed by product STEP ID. product_count counts IFC product entities, not represented solids or physical parts.
AuthoredRebarAttribute
One explicitly authored EXPRESS attribute, keyed by its exact name.
CopyOnWriteMutation
Replace one attribute of a record that other records share, by copying the record and repointing a single referrer at the copy.
CsvOptions
Options for CSV export.
DecodedEntity
Decoded IFC entity. attributes is behind an Arc so cloning a DecodedEntity (the decoder clones on every cache insert AND every cache hit) is a refcount bump, not a deep clone of the attribute tree. Attributes are never mutated after construction, so sharing is sound and byte-identical.
DerivedQuantity
A source parameter or nominal measurement, never a final cut-product takeoff.
DfjsonOptions
Options for DFJSON (Dragonfly) export.
DfjsonStats
Coverage stats for a DFJSON export.
EntityRow
One exportable entity row.
ExportModel
The full extracted model.
GeorefMutations
StepExportOptions.georefMutations: partial ProjectedCRS / MapConversion edits. Each member is kept as its JSON value so an explicit null stays distinguishable from an absent key, which the TypeScript exporter tests with !== undefined.
GlbSizeProjection
Projected size of the single-GLB export for a model, computed from pass 1 only (no output allocation) — issue #1516. A caller uses it to pick single GLB vs multi-buffer glTF (export_gltf_streaming) WITHOUT the historical “attempt the GLB, catch the 4 GiB panic, re-run as multi-buffer” dance.
GltfBuffer
One finished external buffer of a multi-buffer glTF export.
GltfOptions
Options for glTF/GLB export.
GltfStats
Coverage stats for a GLB export.
HbjsonOptions
Options for HBJSON export.
HbjsonStats
Coverage stats for an HBJSON export.
Ifc5Options
Options for IFC5/IFCX export.
JsonLdOptions
Options for JSON-LD export.
JsonOptions
Options for JSON export.
KmzOptions
Options for KMZ export.
LandXmlTerrainExport
The LandXML document plus what it contains.
LandXmlTerrainOptions
How the document is written. #[non_exhaustive]: build it with LandXmlTerrainOptions::new and set the fields you need, so a later option is not a breaking change.
LandXmlTerrainRefusal
The selection is not an authored triangulated terrain, or its georeferencing (map conversion, CRS, units) is missing or ambiguous. The reason names the product or attribute, so a caller can show it verbatim.
LandXmlTerrainSurface
One written <Surface>, for the caller to report.
LogExportStats
What a mutation-log export reports beyond StepStats.
LogMutation
One Mutation record. Values are kept as JSON because that is what they are on the wire: PropertyValue is string | number | boolean | null | PropertyValue[], and a positional value may carry the { real } / { typed } write markers.
LogNewEntity
NewEntity: an entity the session created, as getNewEntities() returns it. attributes is the positional STEP argument list in the IfcAttributeValue shape ("#42" for a reference, ".AREA." for an enum, "$" for unset, { "real": 5 } for a forced REAL).
MapConversionEntityPatch
A complete replacement or newly allocated STEP entity. IDs let the host exporter settle its existing modification ledger without counting edits twice.
MapConversionNormalizationPlan
Atomic plan applied to the already mutation-resolved export pass. Warnings mean no geometry/context patches were produced; upload must refuse them.
MergedModel
A single input model for export_merged_models.
MergedOptions
Options for merged export.
MergedStats
Coverage stats for a merged export.
Model
The top-level Honeybee model.
ModelOptions
What the export should resolve beyond the attributes it always reads.
MutationLog
What exportMutations() returns, plus the two members above.
ObjOptions
Options for OBJ export.
ObjStats
Coverage stats for an OBJ export.
Placement
A product’s placement, composed from its IfcLocalPlacement chain.
ProductQuantities
One actual product occurrence; no row here represents a type product.
ProductQuantityAnalysis
Authored observations and nominal source estimates for one IFC product.
PropMutation
A property create/update: attach (or overwrite) prop_name in pset_name on express_id with value — the STEP-serialized nominal value, e.g. IFCLABEL('2HR') or IFCREAL(42.). The wasm-bridge form of a MutablePropertyView CREATE/UPDATE_PROPERTY. Synthesizes fresh IfcPropertySingleValue / IfcPropertySet / IfcRelDefinesByProperties entities appended to DATA (new psets; merge-into-existing is a follow-on).
PropValue
A single property value (IfcPropertySingleValue and friends).
PropertySet
A named property set (IfcPropertySet).
QuantityAnalysis
Product and unique geometric source counts are different, especially for maps.
QuantityConflict
Same named authored occurrence and type quantity disagree in value or unit.
QuantitySet
A named quantity set (IfcElementQuantity).
QuantitySourceOccurrence
One use of a source solid by a product. Repeated map uses remain separate.
QuantityUnit
Resolved IFC unit, including an explicit quantity override when supplied.
QuantityValue
A single physical quantity (IfcQuantityLength/Area/Volume/…).
RebarFabricationCheck
One requested comparison, including the source identity and absent-value reason.
RebarFabricationPolicy
Caller-selected SI comparisons. None means the check was not requested.
RebarFabricationPolicyError
RebarFabricationReport
A geometric precheck only. Even all passing checks do not establish a physical bar count, material, process, cutting length, or code compliance.
RebarPreflightComparison
One measured comparison. Segment index is absent for the whole directrix.
RebarPreflightError
Invalid caller-supplied fabrication threshold.
RebarPreflightLimits
Project-specific limits in SI metres. No default fabrication code is implied.
RebarPreflightReport
Source geometry assessment. A skipped sweep has unavailable comparisons.
RebarSchedule
Occurrence-keyed schedule inputs. physical_bar_count is deliberately absent: IFC permits one entity to represent multiple manufactured bars.
RebarScheduleRow
One IFC IfcReinforcingBar entity, including bars without analytic geometry.
RebarSweep
One represented swept-disk source. This is not a physical bar count.
Relationships
Relationships resolved from one pass over the file.
StepCounters
StepStats’ counters, carried over for a caller that reads them.
StepOptions
Options for STEP export.
StepStats
Coverage stats for a STEP export.
UnitScales
The file’s unit scales, resolved exactly once per parse.
UsdOptions
Options for USD (USDA) export.

Enums§

AltitudeMode
KML <altitudeMode> — how Google Earth interprets the model’s altitude.
AttributeValue
IFC entity attribute value
AuthoredRebarValue
Authored IFC value. Measures retain the file value and an SI conversion.
ContainerMergeStrategy
Strategy for matching a later model’s IfcSite / IfcBuilding onto the first.
CsvMode
Which CSV view to emit.
ExportError
A failure the caller must handle; completion of a try_export_* function implies a non-empty artifact.
IfcType
IFC Entity Types
LandXmlLinearUnit
The length unit the document is written in (#7618). Coordinates are computed in metres and converted once, at write time.
MutationKind
Mutation['type'].
RebarFabricationCheckStatus
RebarScheduleFabricationError
RebarSchedulePreflightError
Failure to validate caller thresholds or existing sweep-check tolerances.
RebarSource
Where a schema-declared value was authored. An occurrence wins a conflict.
StoreyMergeStrategy
Strategy for matching a later model’s IfcBuildingStorey onto the first.
TessellationQuality
Detail level for geometry tessellation, selectable by consumers.
UnitReconciliation
How to reconcile models whose length unit differs from the first model’s.

Functions§

analyze_authored_quantities
Read authored quantities without meshing. ids restricts emitted product rows; an empty set emits none. Relationship fan-out and quantity lists have explicit work budgets and report refusal rather than truncating silently.
analyze_quantities
Join three canonical opt-in analytic views with exact authored observations. ids selects actual product occurrences; an empty set returns no rows. Source measurements are nominal and intentionally never summed into a product material quantity, cutting length, or physical-part count.
build_entity_index
Build an entity index from content.
build_export_model
Build the export model from raw IFC/STEP bytes.
build_export_model_with_options
build_export_model with options. Same memory caveat: this collects.
build_rebar_schedule
Build an occurrence-aware schedule without tessellating. The optional ID set filters IfcReinforcingBar occurrence IDs; an empty set returns no rows. Geometric findings concern source paths, not bending-code compliance.
build_rebar_schedule_with_fabrication_precheck
Compare only the caller’s requested SI constraints against represented source geometry. The outcome is always precheck_only.
build_rebar_schedule_with_preflight
Build a schedule with caller-supplied geometric fabrication comparisons. Results do not certify a cutting length or code compliance.
deterministic_global_id
Deterministic 22-char GlobalId from an arbitrary seed. A faithful port of @ifc-lite/parser’s deterministicGlobalId (four independent 32-bit rolling hashes cross-mixed into a 128-bit state, stamped MSB-first as 2 + 21*6 bits) so a merged file re-stamped natively carries the same ids the JS path would.
entity_count
Count the entities in a STEP/IFC byte buffer in O(scan) time and O(1) memory — no entity index, no per-type map.
escape_step_string
The STEP string-literal escaper; escape’s docs say why it is public. Escape a STEP string literal body: double the apostrophe and reverse solidus, and encode any character outside the basic graphic range as its \X2\/\X4\ control directive — never a raw byte — since ISO 10303-21 6.3.3.4 restricts a literal’s plain-text bytes to 32-126. buildingSMART’s IFC string-encoding guidance states the same for IFC2X3/IFC4/IFC4X3: a character outside decimal 32-126 “has to be encoded” (e.g. ‘Ä’ as \X2\00C4\X0\). A reader that treats the file’s bytes as ISO-8859-1 — the byte encoding the base standard and most real consumers assume — turns a raw UTF-8 multi-byte sequence into mojibake or a broken parse; this exact writer shape is a reported, reproduced defect in real IFC tooling (IfcOpenShell#699/#1016; files rejected by Solibri).
export_csv
Export the requested CSV view from raw IFC bytes.
export_dfjson
Export the IfcSpace volumes in content (raw IFC/STEP bytes) as a Dragonfly DFJSON string. Each space becomes an extruded Room2D (floor polygon + heights) grouped into stories — the simpler Ladybug target for mostly-vertical-wall models.
export_dfjson_with_stats
Like export_dfjson but also returns coverage stats.
export_glb_from_meshes
Assemble a GLB from already-produced meshes (the viewer’s MeshData — no re-meshing). Per mesh i: vertex_counts[i] vertices + index_counts[i] indices, taken in order from the concatenated positions/normals/indices; colors is RGBA per mesh, origins is xyz per mesh, express_ids labels each mesh. Indices are per-mesh LOCAL. Callers pass exactly the meshes they want emitted (visibility filtering is theirs).
export_gltf_streaming
Export a model as a multi-buffer glTF: the .gltf JSON (returned) plus one or more external .bin buffers, each kept under chunk_cap bytes (well below the 4 GiB glTF limit), so a model of ANY size loads as one logical model. Each finished buffer is handed to sink and dropped, so peak memory is ~one chunk, not the whole model — this is the path for models too large for a single GLB (try_export_glb* stays the smaller-model path). Compose with GltfOptions.quantize to shrink first.
export_gltf_streaming_with_index
Like export_gltf_streaming but reuses a pre-built entity index instead of scanning content again on EACH of its two passes. A caller that already built the index — e.g. to share with the attribute pass (crate::stream_export_model_with_index) — passes it here to remove the redundant SIMD scans on the large models this path targets (#1516). index MUST come from build_entity_index over the same content; output is byte-identical to export_gltf_streaming.
export_hbjson
Export the IfcSpace volumes in content (raw IFC/STEP bytes) as an HBJSON string.
export_hbjson_with_stats
Like export_hbjson but also returns coverage stats (so callers can report how many spaces were skipped instead of silently truncating).
export_ifc5
Export the model in content as an IFCX (IFC5) document string.
export_json
Export the model as a JSON array string.
export_jsonld
Export the model as a JSON-LD document string.
export_jsonld_with_filter
Export JSON-LD with an explicit null-vs-empty isolation filter.
export_merged
Merge models (raw IFC byte slices) into one STEP/IFC string. Convenience wrapper over export_merged_models that exports each model in full.
export_merged_models
Merge several parsed models into one STEP/IFC string, honoring per-model visibility, spatial-merge strategies, and unit reconciliation.
export_merged_models_with_logs
export_merged_models with a mutation log per model (logs[i] for models[i]; None, a missing entry or an empty log leaves the model as it is). Errs, writing nothing, when a model’s log cannot be applied (see export_step_with_log).
export_merged_with_stats
Like export_merged but also returns coverage stats.
export_obj
Export the render geometry in content (raw IFC/STEP bytes) as a Wavefront OBJ string.
export_obj_with_stats
Like export_obj but also returns coverage stats.
export_step
Export the parsed model in content as a STEP/IFC string.
export_step_json
Export STEP from raw bytes + a JSON mutation payload (the wasm bridge form of a MutablePropertyView diff).
export_step_to_writer
export_step_with_stats, writing as it goes instead of returning the file. The two cannot drift: that one is this one writing into a Vec.
export_step_with_log
Export content with the edits in log applied, as a string.
export_step_with_log_to_writer
export_step_with_log, writing as it goes. The source is read, never copied: memory beyond the record index grows with the EDITS (the lines they change, the records they generate), not with the file.
export_step_with_stats
Like export_step but also returns coverage stats.
export_usd
Export the model in content (raw IFC/STEP bytes) as a .usda (ASCII USD) string.
ifc_angle_to_kml_heading
Convert the IFC angle-to-grid-north (counter-clockwise from map east, via the IfcMapConversion X-axis abscissa/ordinate) into a KML <Model><Orientation><heading>, a clockwise rotation of a model whose local X-axis starts pointing east. Returns 0 when either component is absent. KML heading is not a compass bearing: at heading = 0 the X-axis already points east (KML’s baseline), and rotating clockwise by heading moves it to true bearing 90 + heading, so reaching bearing B takes B - 90 (mod 360).
leading_rooted_global_id
The leading GlobalId of a raw STEP entity line, classified by TYPE (not just the 22-char shape): reads the type from the line and applies the rooted-entity rule, so a non-rooted entity leading with a 22-char charset Name (e.g. an IfcColourRgb) is not counted as a rooted GlobalId. For callers that only have raw text — the merge harness and duplicate-GlobalId diagnostics — and want the same classification the merge itself uses.
padded_type_universe
Every (from, to, SOURCE TYPE) this module pads, for the cross-language parity gate to re-derive its required-coverage set from rather than trust a count floor (rust/export/tests/schema_upconvert_parity.rs).
plan_map_conversion_normalization
Plan a standards-valid, uniform 3D IfcMapConversion compatibility export. Default STEP export never calls this. For project unit u metres, physical similarity s = MapScale/u, and native map affine A = [Rs,T/u], emit P_new = APS^-1 and representation scale S=s. Therefore P_newS=A*P, while logical placement origins also represent the same physical map point. The neutral remaining conversion is offsets 0, axes identity, Scale=u.
project_glb_size
Project the single-GLB size for content from pass 1 only — the world AABB + per-mesh byte sizes the bounded assembler already computes — WITHOUT meshing twice or allocating the output (#1516). Lets a caller pick single GLB vs multi-buffer glTF up front. Meshes the model once (the price of an exact size).
project_glb_size_with_index
Shared-index project_glb_size (see try_export_glb_streaming_bounded_with_index).
relationships
Resolve the relationships in content.
stream_export_model
Stream one EntityRow per IfcProduct occurrence, in file order, invoking f for each row and then dropping it.
stream_export_model_with_index
Like stream_export_model but reuses a pre-built entity index. A caller also running the geometry pass (crate::try_export_glb_with_stats_with_index) over the same bytes builds the index once with [build_entity_index] and shares it across both, skipping the duplicate scan. entity_index MUST be built from the same content; output is identical to stream_export_model. Returns the model’s UnitScales, so a caller consuming attribute values can interpret them without a second pass over the file: the scales are resolved from the decoder this function already builds.
stream_export_model_with_options
stream_export_model_with_index, plus the decoded entity behind each row and whatever ModelOptions asked to resolve.
try_export_collada_from_meshes
Build a Google-Earth-compatible COLLADA 1.4.1 .dae from already-produced (Y-up) meshes, flattened into parallel arrays exactly like export_glb_from_meshes. Per mesh i: vertex_counts[i] vertices + index_counts[i] indices taken in order from the concatenated positions/normals/indices; colors is RGBA per mesh, origins xyz per mesh (world = origin + position). Returns the .dae bytes (UTF-8 XML).
try_export_glb
Export the render geometry in content as a binary GLB.
try_export_glb_from_meshes
Fail-closed export_glb_from_meshes: validates the per-mesh vertex_counts / index_counts (and normals) against the flattened buffers, and the index VALUES against the vertex counts, BEFORE assembling. Returns ExportError::MalformedMeshInput when a declared vertex/index count runs past the end of positions / indices, an index_counts entry is missing, normals is empty or too short to cover every emitted vertex, or an index names a vertex its own mesh does not have — instead of silently dropping the un-backed meshes (which the infallible variant does — a valid GLB missing part of the model, reported as success) or copying the out-of-range index straight into the BIN chunk. Prefer this at any boundary where the counts and buffers come from separate sources (the wasm FFI).
try_export_glb_streaming_bounded
Bounded-memory single-GLB export: two passes over the deterministic mesh stream (retain_emitted_meshes: false, peak input = one batch).
try_export_glb_streaming_bounded_with_index
Like try_export_glb_streaming_bounded but reuses a pre-built entity index instead of scanning content again on EACH of the two passes — for a caller that already built it (e.g. to share with crate::stream_export_model_with_index), removing the redundant SIMD scans on the large models this path targets (#1516). index MUST come from build_entity_index over the same content; output is byte-identical.
try_export_glb_with_stats
Like try_export_glb but also returns coverage stats. Meshes the model from bytes.
try_export_glb_with_stats_with_index
Like try_export_glb_with_stats but reuses a pre-built entity index — for a caller that also runs the attribute pass (crate::stream_export_model_with_index) over the same bytes, build_entity_index once and share it across both. index MUST be built from the same content; output is byte-identical to try_export_glb_with_stats below the streaming threshold. NOTE: this path always uses the in-memory assembler (the bounded two-pass path rebuilds its own index per pass and cannot reuse this one); a native caller that needs bounded memory on a large model should call try_export_glb_streaming_bounded_with_index directly.
try_export_kmz_collada_from_meshes
Build a Google-Earth-ready KMZ (doc.kml + model.dae) directly from the viewer’s already-produced (Y-up) meshes, the working path (#1427). The model is embedded as COLLADA (the only <Model> format Google Earth loads), with emission-lit, double-sided materials and clampToGround placement. Mesh arrays match crate::try_export_collada_from_meshes / export_glb_from_meshes.
try_export_landxml_terrain
Export the selected terrain products of content (IFC STEP bytes) as one LandXML 1.2 document, one <Surface> per product in selection order.

Type Aliases§

EntityIndex
Pre-built entity index type