Skip to main content

IfcAPI

Struct IfcAPI 

Source
pub struct IfcAPI { /* private fields */ }
Expand description

Main IFC-Lite API

Implementations§

Source§

impl IfcAPI

Source

pub fn parse_alignment_lines(&self, content: String) -> Float32Array

Parse the file and return every IfcAlignment directrix as a flat Float32Array of 3D line-list vertices [x0,y0,z0, x1,y1,z1, …] in the renderer’s Y-up world space (RTC-subtracted, metres). Consecutive samples form line segments. Feed straight to renderer.uploadAnnotationLines3D(...).

Returns an empty array when the file has no alignments (or none with a resolvable Axis curve), so the caller can clear the overlay cheaply.

Source§

impl IfcAPI

Source

pub fn diagnose_geometry(&self, content: &[u8]) -> JsValue

Run geometry extraction on content and return its typed CSG / opening diagnostics (the GeometryDiagnostics contract) as a JS object, or undefined when nothing diagnostic-worthy happened (no openings, no failures). Takes the raw IFC bytes (Uint8Array) so there is no input-size cap. The produced meshes are dropped; only the diagnostics are returned.

Source§

impl IfcAPI

Source

pub fn export_csv( &self, content: &[u8], mode: String, delimiter: String, include_properties: bool, ) -> Vec<u8>

Export tabular CSV. mode ∈ {"entities", "properties", "quantities", "spatial"}. delimiter defaults to , when empty; include_properties adds flattened Pset_Prop columns to the entities view.

Source

pub fn export_json( &self, content: &[u8], pretty: bool, include_properties: bool, include_quantities: bool, ) -> Vec<u8>

Export structured JSON (array of entity objects with typed property values).

Source

pub fn export_jsonld( &self, content: &[u8], context: String, include_properties: bool, include_quantities: bool, pretty: bool, included: &[u32], ) -> Vec<u8>

Export JSON-LD (@graph of ifc: nodes). Empty context ⇒ buildingSMART IFC4 OWL default. included is an express-id isolation filter mirroring the OBJ/glTF/STEP exporters (empty ⇒ all entities).

Source

pub fn export_ifcx( &self, content: &[u8], only_known_properties: bool, pretty: bool, ) -> Vec<u8>

Export IFC5 / IFCX (the USD-style node graph). only_known_properties keeps only properties with an official IFC5 schema.

Source

pub fn export_usd(&self, content: &[u8]) -> Vec<u8>

Export OpenUSD (.usda ASCII): a real Z-up USD stage — spatial hierarchy of Xform prims, UsdGeomMesh geometry, UsdPreviewSurface materials, IFC metadata as custom attributes. Whole-model (geometry-backed).

Source§

impl IfcAPI

Source

pub fn export_dfjson(&self, content: &[u8], name: String) -> String

Export the IfcSpace volumes in content as a Dragonfly DFJSON string.

Each space becomes an extruded Room2D (floor polygon + floor-to-ceiling height) grouped into stories — the simpler Ladybug Tools target for mostly-vertical-wall models. Loads via dragonfly.model.Model.from_dfjson.

const api = new IfcAPI();
const dfjson = api.exportDfjson(ifcContent, "my_model");
Source§

impl IfcAPI

Source

pub fn export_glb( &self, content: &[u8], include_metadata: bool, hidden: &[u32], isolated: &[u32], hidden_types_csv: String, lit: Option<bool>, emissive: Option<bool>, ) -> Result<Vec<u8>, JsValue>

Export the render geometry in content as a binary GLB (Uint8Array).

hidden / isolated are express-id visibility filters; hidden_types_csv is a comma-separated list of IFC type names whose class toggle is off (e.g. "IfcOpeningElement,IfcSpace"). include_metadata attaches counts + per-node expressId. Per-mesh RTC origin rides the node translation (precision-safe). lit emits standard PBR materials that shade from normals; omitted or true ⇒ lit (the default), false ⇒ flat KHR_materials_unlit (the historical look — #1321). Optional at the boundary so older 5-arg callers keep lit-by-default behaviour. emissive self-illuminates each material at its base colour (core glTF emissiveFactor) so renderers without ambient/IBL — Google Earth — don’t render the model near-black (#1427); omitted or false ⇒ off.

Fails CLOSED: when the visible mesh set is empty this throws an Error whose message starts with NO_RENDER_GEOMETRY, instead of returning a structurally valid but empty GLB. #1438 put that guard only in the TS CLI/MCP wrappers; making the boundary itself refuse means SDK/viewer/ direct callers inherit it too (the TS guards stay as defense-in-depth).

Source

pub fn export_glb_from_meshes( &self, positions: &[f32], normals: &[f32], indices: &[u32], vertex_counts: &[u32], index_counts: &[u32], colors: &[f32], origins: &[f64], express_ids: &[u32], include_metadata: bool, lit: Option<bool>, emissive: Option<bool>, ) -> Result<Vec<u8>, JsValue>

Assemble a GLB from already-produced meshes (the viewer’s MeshData, flattened) — no re-meshing. Per mesh i: vertex_counts[i] verts + index_counts[i] indices taken in order from the concatenated positions/normals/indices; colors is RGBA per mesh, origins xyz per mesh, express_ids labels each mesh (indices are per-mesh local). The caller passes exactly the meshes it wants emitted.

Fails CLOSED: if the declared vertex/index counts run past the flattened positions / indices, there are fewer index_counts than meshes, or normals is empty or too short to cover every vertex, this throws an Error whose message starts with MALFORMED_MESH_INPUT — instead of silently emitting a GLB with those meshes dropped. (The viewer always passes fully-backed, normal-covered arrays, so this only fires on a caller bug.)

Source

pub fn export_kmz( &self, glb: &[u8], latitude: f64, longitude: f64, altitude: f64, x_axis_abscissa: Option<f64>, x_axis_ordinate: Option<f64>, name: String, altitude_mode: Option<String>, ) -> Vec<u8>

Package an already-produced GLB + georeference into a KMZ (Uint8Array) for Google Earth: a ZIP of doc.kml (a <Model> placed at latitude/longitude/ altitude) + model.glb. x_axis_abscissa/x_axis_ordinate are the IfcMapConversion grid-north components; pass both as undefined for heading 0.

altitude_mode selects the KML vertical placement: "clampToGround" (the default when omitted) rests the model on the terrain, ignoring altitude; "absolute" places the origin at altitude metres MSL. Google Earth’s terrain already encodes the site elevation, so clamping keeps a wrong/zero/double-counted OrthogonalHeight from floating the model into the sky (#1427); absolute is offered for models whose OrthogonalHeight is a true MSL elevation the user wants honoured.

Source

pub fn export_kmz_from_meshes( &self, positions: &[f32], normals: &[f32], indices: &[u32], vertex_counts: &[u32], index_counts: &[u32], colors: &[f32], origins: &[f64], latitude: f64, longitude: f64, altitude: f64, x_axis_abscissa: Option<f64>, x_axis_ordinate: Option<f64>, name: String, altitude_mode: Option<String>, ) -> Vec<u8>

Build a Google-Earth-ready KMZ (Uint8Array) straight from the viewer’s already-produced meshes — the working path (#1427). The model is embedded as COLLADA (model.dae), the only <Model> format Google Earth loads (a GLB raises “Unsupported element: Model”), with emission-lit double-sided materials placement. Mesh arrays match exportGlbFromMeshes; latitude/longitude/altitude + x_axis_abscissa/x_axis_ordinate (grid-north, undefined ⇒ heading 0) place + orient the model. altitude_mode ("clampToGround" default ⇒ rest on terrain, ignoring altitude; "absolute" ⇒ place at altitude metres MSL) selects the KML vertical placement (#1427).

Source§

impl IfcAPI

Source

pub fn export_hbjson(&self, content: &[u8], name: String) -> Vec<u8>

Export the IfcSpace volumes in content as Honeybee HBJSON UTF-8 bytes.

Returned as UTF-8 bytes (Uint8Array) so output is not capped by the V8 max-string ceiling (~512 MB); decode with TextDecoder when a string is genuinely needed.

Rooms are built analytically from extruded-area profiles (watertight by construction); faces are typed Floor / RoofCeiling / Wall with outward normals. The result loads via honeybee.model.Model.from_hbjson and is ready for Ladybug Tools / Pollination.

const api = new IfcAPI();
const hbjson = api.exportHbjson(ifcContent, "my_model");
Source§

impl IfcAPI

Source

pub fn export_obj( &self, content: &[u8], include_normals: bool, hidden: &[u32], isolated: &[u32], ) -> Vec<u8>

Export the render geometry in content as Wavefront OBJ UTF-8 bytes.

Returned as UTF-8 bytes (Uint8Array) so output is not capped by the V8 max-string ceiling (~512 MB); decode with TextDecoder when a string is genuinely needed.

hidden / isolated are express-id filters mirroring the viewer’s visibility state (empty isolated ⇒ all visible). Instanced type-library shapes are skipped.

const obj = api.exportObj(ifcContent, true, new Uint32Array(), new Uint32Array());
Source§

impl IfcAPI

Source

pub fn export_step( &self, content: &[u8], schema: String, included: &[u32], mutations_json: String, ) -> Vec<u8>

Re-serialize the model in content to STEP/IFC UTF-8 bytes.

Returned as UTF-8 bytes (Uint8Array) so output is not capped by the V8 max-string ceiling (~512 MB); decode with TextDecoder when a string is genuinely needed.

schema is the FILE_SCHEMA label to write (empty ⇒ preserve the source schema). included is an express-id allowlist (empty ⇒ whole model); when set, the forward #-reference closure is added so the subset never dangles a reference. mutations_json carries MutablePropertyView edits (attribute updates + property-set synthesis); empty ⇒ none. See export_step_json for the shape.

Source

pub fn export_merged( &self, concatenated: &[u8], lengths: &[u32], schema: String, ) -> Vec<u8>

Merge several IFC models into one STEP/IFC UTF-8 byte buffer (Uint8Array). concatenated is every model’s bytes laid end-to-end; lengths[i] is the byte length of model i. The first model keeps its ids; later models are id-offset and their project unified to the first.

Source§

impl IfcAPI

Source

pub fn extract_profiles( &self, content: String, model_index: u32, ) -> ProfileCollection

Extract raw profile polygons from all building elements with IfcExtrudedAreaSolid representations.

Returns a [ProfileCollection] whose entries each carry:

  • A 2D polygon (outer + holes) in local profile space (metres)
  • A 4 × 4 column-major transform in WebGL Y-up world space
  • Extrusion direction (world space) and depth (metres)

Use [ProfileProjector] (TypeScript) to convert these into DrawingLine[] for clean projection without tessellation artifacts.

const api = new IfcAPI();
const profiles = api.extractProfiles(ifcContent, 0);
console.log('Profiles:', profiles.length);
for (let i = 0; i < profiles.length; i++) {
  const p = profiles.get(i);
  console.log(p.ifcType, 'depth:', p.extrusionDepth);
}
Source§

impl IfcAPI

Source

pub fn process_geometry_batch( &self, data: &[u8], jobs_flat: &[u32], unit_scale: f64, rtc_x: f64, rtc_y: f64, rtc_z: f64, needs_shift: bool, void_keys: &[u32], void_counts: &[u32], void_values: &[u32], style_ids: &[u32], style_colors: &[u8], plane_angle_to_radians: Option<f64>, material_element_ids: Option<Vec<u32>>, material_color_counts: Option<Vec<u32>>, material_colors_rgba: Option<Vec<u8>>, ) -> MeshCollection

Process geometry for a subset of pre-scanned entities → flat MeshCollection. Takes raw bytes + pre-pass data from buildPrePassOnce. Thin wrapper over IfcAPI::produce_batch; converts each produced mesh to MeshDataJs (the IFC Z-up→WebGL Y-up swap + winding reversal happen there). Output is byte-for-byte what the pre-refactor method produced.

Source

pub fn process_geometry_batch_instanced( &self, data: &[u8], jobs_flat: &[u32], unit_scale: f64, rtc_x: f64, rtc_y: f64, rtc_z: f64, needs_shift: bool, void_keys: &[u32], void_counts: &[u32], void_values: &[u32], style_ids: &[u32], style_colors: &[u8], plane_angle_to_radians: Option<f64>, material_element_ids: Option<Vec<u32>>, material_color_counts: Option<Vec<u32>>, material_colors_rgba: Option<Vec<u8>>, ) -> Vec<u8>

Like IfcAPI::process_geometry_batch but collates the batch’s meshes into a GPU-instancing shard (IFNS wire format) instead of a flat MeshCollection. Repeated geometry collapses to one template + per- occurrence transforms; non-instanceable meshes ride as flat singleton templates so nothing is dropped. The shard stays in the producer-native (IFC Z-up) frame — the renderer composes the constant Z-up→Y-up swap at upload. Each batch shard renders independently: affinity routing already co-locates identical geometry on one worker, so per-batch collation captures ~all the dedup and no cross-batch merge is needed. Returns empty bytes only when the batch produced zero non-empty meshes.

Source

pub fn process_geometry_batch_partitioned( &self, data: &[u8], jobs_flat: &[u32], unit_scale: f64, rtc_x: f64, rtc_y: f64, rtc_z: f64, needs_shift: bool, void_keys: &[u32], void_counts: &[u32], void_values: &[u32], style_ids: &[u32], style_colors: &[u8], plane_angle_to_radians: Option<f64>, material_element_ids: Option<Vec<u32>>, material_color_counts: Option<Vec<u32>>, material_colors_rgba: Option<Vec<u8>>, ) -> PartitionedBatch

Produce a batch ONCE and PARTITION it (the instanced-ONLY path): opaque ordinary occurrences (colour alpha >= 0.99 AND geometry_class == 0) are collated into the instanced shard; everything else (transparent glass, type-product geometry) goes to the flat MeshCollection. Each mesh takes exactly ONE route, so produce_batch runs once (no emit-both 2× meshing) and the renderer draws opaque occurrences via instancing instead of flat. Partition mirrors the renderer gates: INSTANCED_ALPHA_CUTOFF (0.99 = OPAQUE_ALPHA_CUTOFF) for transparency, geometry_class for the Model/Types split.

NOTE: the renderer must be instanced-feature-complete (picking / selection / lens overlays on instanced geometry) before the worker calls this in place of processGeometryBatch — otherwise those features break for the opaque bulk. See the instanced-only follow-ups.

Source§

impl IfcAPI

Source

pub fn set_source_bytes(&self, data: Vec<u8>)

Store the whole IFC source file ONCE per load so the *FromSource batch variants can read it from the wasm heap instead of re-copying it per call.

Mirrors the setEntityIndex lifecycle: called once per worker per load, and REPLACES the previous file wholesale (repeated calls swap the bytes), so a parser/geometry worker reusing one IfcAPI across loads is safe. The bytes must be the exact source the batch jobs’ byte spans index into (the same buffer passed as data to the legacy processGeometryBatch*), or the decoded entities won’t match — the JS worker installs its own session buffer, so this holds by construction.

Taking Vec<u8> (by value) means wasm-bindgen hands us ownership of the single JS→wasm copy directly; we wrap it in Arc with no second copy.

Source

pub fn process_geometry_batch_from_source( &self, jobs_flat: &[u32], unit_scale: f64, rtc_x: f64, rtc_y: f64, rtc_z: f64, needs_shift: bool, void_keys: &[u32], void_counts: &[u32], void_values: &[u32], style_ids: &[u32], style_colors: &[u8], plane_angle_to_radians: Option<f64>, material_element_ids: Option<Vec<u32>>, material_color_counts: Option<Vec<u32>>, material_colors_rgba: Option<Vec<u8>>, ) -> MeshCollection

Like IfcAPI::process_geometry_batch but reads the source bytes held by IfcAPI::set_source_bytes instead of taking data. Byte-for-byte identical output — it delegates to the legacy twin with the held slice.

Source

pub fn process_geometry_batch_partitioned_from_source( &self, jobs_flat: &[u32], unit_scale: f64, rtc_x: f64, rtc_y: f64, rtc_z: f64, needs_shift: bool, void_keys: &[u32], void_counts: &[u32], void_values: &[u32], style_ids: &[u32], style_colors: &[u8], plane_angle_to_radians: Option<f64>, material_element_ids: Option<Vec<u32>>, material_color_counts: Option<Vec<u32>>, material_colors_rgba: Option<Vec<u8>>, ) -> PartitionedBatch

Like IfcAPI::process_geometry_batch_partitioned but reads the source bytes held by IfcAPI::set_source_bytes instead of taking data. Byte-for-byte identical output — it delegates to the legacy twin.

Source§

impl IfcAPI

Source

pub fn build_pre_pass_once(&self, data: &[u8]) -> JsValue

Run the pre-pass ONCE and return serialized results for worker distribution. Takes raw bytes (&u8) to avoid TextDecoder overhead.

Source

pub fn build_pre_pass_streaming( &self, data: &[u8], on_event: &Function, chunk_size: u32, disabled_type_names: Option<Vec<String>>, skip_type_geometry: bool, ) -> Result<JsValue, JsValue>

Streaming pre-pass: emits geometry jobs in chunks via a JS callback instead of waiting for the full file scan to complete.

Single linear walk over the file:

  1. Builds the entity index incrementally from the same scan that collects geometry jobs (a separate index scan would double wall-clock).
  2. As soon as IFCPROJECT has been seen, the unit scale and the first ~50 geometry jobs have been collected, resolves unitScale + rtcOffset and emits a meta callback so the JS host can spin up geometry process workers.
  3. Emits jobs callbacks every chunk_size jobs (or fewer if the meta phase already buffered some).
  4. Emits complete with the total job count at end of scan.

On a 986 MB / 14 M-entity file this drops time-to-first-geometry from ~17 s (full pre-pass + worker spawn + first batch) to ~3 s (first 100 K bytes scanned + meta + first chunk).

The callback receives a single JsValue argument shaped as one of: { type: "meta", unitScale, rtcOffset: [x,y,z], needsShift, buildingRotation? } { type: "jobs", jobs: Uint32Array } // [id, start, end] triples { type: "complete", totalJobs }

Source§

impl IfcAPI

Source

pub fn build_pre_pass_streaming_sharded( &self, data: &[u8], on_event: &Function, chunk_size: u32, disabled_type_names: Option<Vec<String>>, skip_type_geometry: bool, index_ids: &[u32], index_starts: &[u32], index_lengths: &[u32], index_classes: &[u8], ) -> Result<JsValue, JsValue>

Sharded pre-pass variant: same scan/discovery/jobs/columns pipeline as buildPrePassStreaming, but

  1. the entity index is PREBUILT from the host’s stitched shard columns (file order; see scanEntityIndexShard) — the scan skips its inline index build, the meta RTC ladder resolves against the FULL index (no partial-ladder full-rescan detour), and the post-scan entity-index event is skipped (the host already delivered it), and
  2. styles resolution is EXTERNAL: the styled-item spans are resolved as shard slices on the geometry workers (resolveStyledItemsShard); this call stashes the SUPPORT spans + plane-angle scale, and the follow-up finalizePrepassStyles merges + flattens into the exact styles payload the serial path emits. NO styles event is emitted here.
Source

pub fn scan_entity_index_shard( &self, data: &[u8], range_start: u32, range_end: u32, ) -> JsValue

SPIKE (sharded pre-pass): scan the entity index over a single byte range.

Each idle browser geometry worker calls this on its [range_start, range_end) shard; the main thread stitches the returned columns into the full entity index (byte-identical to the single-threaded build_entity_index) by binary-searching each shard for the previous shard’s handoff. Delegates to ifc_lite_processing::scan_shard_classified — a separately-maintained loop over the same EntityScanner primitive as scan_shard (the one the native build_entity_index_parallel fans across cores), plus a per-record class column this sharded path also needs. The two loops’ records/handoff are kept in parity by a dedicated test (rust/processing/tests/issue_2053_shard_scan_parity.rs), not by delegation — edit one without the other and that test catches the drift.

Byte offsets returned are GLOBAL (relative to file start), so shards concatenate without rewriting. Returns a plain object: { ids: Uint32Array, starts: Uint32Array, lengths: Uint32Array, classes: Uint8Array, handoff: number } where classes is the parallel per-record prepass class byte (PREPASS_CLASS_*: named code in the low bits plus the geometry-job / type-candidate flags) the host filters on to rebuild pre-pass span lists, and handoff is the global start of the first entity at/after range_end (the next shard’s first real entity), or -1 at EOF.

Source

pub fn resolve_styled_items_shard( &self, data: &[u8], spans: &[u32], ) -> Result<JsValue, JsValue>

Sharded pre-pass: resolve ONE contiguous (file-ordered) slice of the styled-item span list on this worker, against the entity index installed by setEntityIndex. Returns raw resolved maps as flat columns: { orphanIds, orphanColors (f32 rgba per id), geomIds, geomColors }. The host merges shard results IN SHARD ORDER with first-wins per geometry id, reproducing the serial resolver’s file-order precedence, then hands the merged columns to finalizePrepassStyles. spans is [id, start, len] triples.

Source

pub fn finalize_prepass_styles( &self, data: &[u8], orphan_ids: &[u32], orphan_colors: &[f32], geom_ids: &[u32], geom_colors: &[f32], colour_map_spans: &[u32], material_def_spans: &[u32], rel_material_spans: &[u32], void_spans: &[u32], fills_spans: &[u32], aggregate_spans: &[u32], plane_angle_to_radians: f64, ) -> Result<JsValue, JsValue>

Sharded pre-pass: merge the shard-resolved styled-item columns with the SUPPORT spans (extracted host-side from the shard classes) and run the CANONICAL styles flatten. Returns the exact styles event payload the serial path emits. Runs on any worker with setEntityIndex installed. Span arguments are [id, start, len] triples; plane_angle_to_radians comes from the meta event.

Source§

impl IfcAPI

Source

pub fn parse_grid_lines(&self, content: String) -> Float32Array

Parse the file and return every IfcGridAxis as a flat Float32Array of 3D line-list vertices [x0,y0,z0, x1,y1,z1, …] (one segment per axis) in the renderer’s Y-up world space (RTC-subtracted, metres). Feed straight to a line pipeline (e.g. uploadAnnotationLines3D).

Returns an empty array when the file has no grids, so the caller can clear the overlay cheaply.

Source

pub fn parse_grid_axes(&self, content: String) -> GridAxisCollection

Parse the file and return structured per-axis data (tag + endpoints) in the renderer’s Y-up world space (RTC-subtracted, metres). Use this when you also need the axis tags (to render grid bubbles / labels).

Source§

impl IfcAPI

Source

pub fn scan_entities_fast(&self, content: &str) -> JsValue

Fast entity scanning using SIMD-accelerated Rust scanner Returns array of entity references for data model parsing Much faster than TypeScript byte-by-byte scanning (5-10x speedup)

Source

pub fn scan_entities_fast_bytes(&self, data: &[u8]) -> JsValue

Fast entity scanning from raw bytes (avoids TextDecoder.decode on JS side). Accepts Uint8Array directly — saves ~2-5s for 487MB files by skipping JS string creation and UTF-16→UTF-8 conversion.

Source

pub fn scan_geometry_entities_fast(&self, content: &str) -> JsValue

Fast geometry-only entity scanning Scans only entities that have geometry, skipping 99% of non-geometry entities Returns array of geometry entity references for parallel processing Much faster than scanning all entities (3x speedup for large files)

Source§

impl IfcAPI

Source

pub fn get_pipeline_diagnostics(&self) -> JsValue

Structured pipeline diagnostics accumulated across every processGeometryBatch* call since the last load reset (clearPrePassCache / setEntityIndex), as a JS object with a schemaVersion field — or undefined when no batch has run yet. Includes per-batch summed geometry wall time, mesh/triangle counts, the degenerate-backstop drop count, and the CSG failure aggregates.

Source§

impl IfcAPI

Source

pub fn simplify_meshes( &self, express_ids: &[u32], levels: &[u8], positions: &[f32], normals: &[f32], indices: &[u32], vertex_counts: &[u32], index_counts: &[u32], origins: &[f64], local_to_world: &[f64], local_to_world_present: &[u8], rtc_x: f64, rtc_y: f64, rtc_z: f64, unit_scale: f64, y_up: bool, ) -> Result<SimplifiedMeshes, JsValue>

Simplify already-produced element meshes at per-element demesher levels (1-4 = cavity removal + clustering at 0.5/0.25/0.10/0.03 triangle ratio, 5 = bounding box).

One RECORD per input MeshData entry (an element may span several records — per-material submeshes; pass all of them, grouped or not). Per record i: vertexCounts[i] vertices from positions (and normals when non-empty), indexCounts[i] indices from indices (per-record local), origins[i*3..], localToWorld[i*16..] valid only when localToWorldPresent[i] != 0, level levels[i] (records of one element must agree). Arrays are the boundary Y-up convention when yUp is true (the browser/SDK case).

rtcX/Y/Z = coordinateInfo.originShift (IFC Z-up metres); unitScale = metres per project length unit.

Source§

impl IfcAPI

Source

pub fn parse_symbolic_representations( &self, content: String, ) -> SymbolicRepresentationCollection

Parse IFC file and extract symbolic representations (Plan, Annotation, FootPrint, Axis). These are 2D curves used for architectural drawings instead of sectioning 3D geometry.

Example:

const api = new IfcAPI();
const symbols = api.parseSymbolicRepresentations(ifcData);
console.log('Found', symbols.totalCount, 'symbolic items');
for (let i = 0; i < symbols.polylineCount; i++) {
  const polyline = symbols.getPolyline(i);
  console.log('Polyline for', polyline.ifcType, ':', polyline.points);
}
Source§

impl IfcAPI

Source

pub fn new() -> Self

Create and initialize the IFC API

Source

pub fn is_ready(&self) -> bool

Check if API is initialized

Source

pub fn clear_pre_pass_cache(&self)

Clear the cached entity index (call between loads when reusing the same IfcAPI instance — e.g. the parser worker keeps one IfcAPI alive across multiple parse requests).

Recovers a poisoned cache Mutex instead of panicking; see mod_tests.rs.

Source

pub fn set_entity_index(&self, ids: &[u32], starts: &[u32], lengths: &[u32])

Populate cached_entity_index from pre-extracted column arrays.

Used by the streaming pre-pass to share its already-built entity index across worker realms via SAB-backed Uint32Arrays — every process worker would otherwise re-scan the entire file in processGeometryBatch’s lazy build path (~5 s on a 1 GB IFC), even though the pre-pass worker built the same index minutes earlier.

Builds a compact ColumnarEntityIndex from the three input slices (sorted u32 columns + binary search) instead of a per-worker FxHashMap — ~229 MB vs ~436 MB on a 19.1 M-entity model (#1682). ColumnarEntityIndex::from_columns verifies the id ordering once (O(n)) and only argsorts if the producer did not emit sorted columns.

lengths[i] is the byte length of entity ids[i], so lookup returns (start, start + length) to match the existing (start, end) layout.

Idempotent in the sense that repeated calls REPLACE the cache — supports the parser-worker pattern of reusing one IfcAPI across multiple loads with different files.

Source

pub fn set_referenced_repmaps(&self, ids: &[u32])

Install the pre-computed set of IfcRepresentationMap ids referenced by an IfcMappedItem (issue #957), so the worker’s first type-product batch SKIPS the per-worker Self::get_or_build_referenced_repmaps full-file walk. The streaming pre-pass built the same set once from the IfcMappedItem spans it already scanned (see styling::build_referenced_representation_maps_from_spans) and ships the id list here — bit-identical to what each worker would compute, since a set’s membership is order-invariant and consumers only call .contains.

Installed AFTER setEntityIndex (which clears this cache on content swap), so the injected value survives. When this setter is never called (native path, non-streaming callers), the lazy build path is unchanged.

Source

pub fn set_instantiated_type_ids(&self, ids: &[u32])

Install the pre-computed set of type ids that an IfcRelDefinesByType instantiates (#957 follow-up), so the worker’s first type-product batch skips the per-worker Self::get_or_build_instantiated_type_ids full-file walk. Same injection contract as Self::set_referenced_repmaps.

Source

pub fn set_mapped_instance_plan(&self, source_ids: &[u32])

Install the pre-computed #1623 Phase 3 don’t-bake plan: the flat list of IfcRepresentationMap ids that an IfcMappedItem instantiates >= 2 times. The streaming pre-pass tallies it in the SAME scan that builds the referenced- repmap set (styling::build_mapped_instance_plan_from_spans) and ships the id list here. The batch path arms its router with it (batch-local template mode), so a repeated single-solid mapped source materializes ONCE per batch and the rest ride as instances in the IFNS shard.

Same injection contract as Self::set_referenced_repmaps: installed after setEntityIndex (which clears it on content swap), and a no-op absence leaves the batch path materializing every occurrence (byte-identical). Each id is stored as (2, id) — the batch-local router only needs the eligibility set (count >= 2); the min-id template slot is unused in batch-local mode.

Source

pub fn set_material_layer_index( &self, element_ids: &[u32], axis: &[u32], layer_counts: &[u32], direction_sense: &[f64], offset: &[f64], layer_material_ids: &[u32], layer_thicknesses: &[f64], )

Install the pre-computed ifc_lite_geometry::MaterialLayerIndex (#563) from its flat SoA encoding, so the worker’s first batch skips the per-worker Self::get_or_build_material_layer_index full-file decode scan (the dominant first-batch cost on layered architectural models, which run this on the DEFAULT view). The streaming pre-pass built the index once from the IfcRelAssociatesMaterial spans it already scanned (MaterialLayerIndex::from_spans) and flat-encoded it here; the flat encoding round-trips bit-for-bit (proven in material_layer_index tests), so the injected index equals each worker’s from_content result.

Same injection contract as Self::set_referenced_repmaps: installed after setEntityIndex, and a no-op absence leaves the lazy build intact.

Source

pub fn get_memory(&self) -> JsValue

Get WASM memory for zero-copy access

Source

pub fn version(&self) -> String

Get version string

Source

pub fn set_merge_layers(&self, enabled: bool)

Toggle the “render multilayer walls as a single solid” mode (issue #540).

When enabled is true, every subsequent processGeometryBatch call will suppress geometry emission for IfcBuildingElementPart entities whose IfcRelAggregates parent wall is sliceable (has an IfcMaterialLayerSetUsage) AND has its own Representation. The parent wall keeps its per-layer sub-mesh colouring, so the visual result is the same as the layered render but with one mesh per wall instead of one per layer part — much cheaper for both CPU and GPU.

Default is false. Pass true before calling processGeometryBatch.

Source

pub fn set_rect_param_fast_path(&self, enabled: bool)

Enable or disable the PARAMETRIC rectangular-opening fast path (the placement-frame, ground-truth-exact analytic cut) for processGeometryBatch.

DEFAULT ON (corpus-validated; native defaults ON too, and wasm has no env to read IFC_LITE_RECT_PARAM, so both targets default in LOCKSTEP – the byte-identical native==wasm contract requires both take the same path). This toggle is the wasm-side escape hatch mirroring IFC_LITE_RECT_PARAM=0. The path subtracts rectangular openings as exact parametric boxes in the host’s own placement frame (rotated walls included), deferring any non-clean case to the exact kernel. Pass false before processGeometryBatch to opt out.

Source

pub fn set_compute_geometry_hashes(&self, tolerance: Option<f64>)

Enable or disable per-entity geometry fingerprinting in processGeometryBatch, used by the viewer’s revision-diff feature.

Pass a positive tolerance (metres) to enable — the quantization grid positions snap to (larger tolerates more float noise, smaller catches finer edits; below the f32 precision floor of model-local coordinates, ~1 mm, mostly hashes noise). Finer than ifc_lite_geometry::MIN_GEOM_HASH_TOLERANCE (1e-6 m) is clamped up to it — see that constant’s doc for why (an i128 overflow surface, not a precision win). null/undefined/non-positive disables. Default: off.

Source

pub fn set_tessellation_quality( &self, level: Option<String>, ) -> Result<(), JsValue>

Select the tessellation detail level applied by every subsequent processGeometryBatch call (issue #976, step 4).

level is one of "lowest" | "low" | "medium" | "high" | "highest" (case-insensitive). "medium" is the default and reproduces the engine’s historical hardcoded densities byte-for-byte; lower levels trade curved-surface smoothness for throughput, higher levels reduce faceting on pipes / cylinders / NURBS at a triangle-count cost. Pass null/undefined to reset to the default.

Set BEFORE processing — meshes already emitted are not regenerated. Throws on an unrecognized level so typos fail loudly instead of silently rendering at the wrong density.

Source

pub fn set_skip_small_cuts(&self, on: bool)

Toggle the tier-independent small-cut skip (#1286). When true, processGeometryBatch drops IfcBooleanResult differences whose cutter is tiny relative to its host (steel copes/notches) while keeping the tessellation tier — so curves stay full-density. The viewer enables this for the on-screen load; exports/drawings leave it off so their geometry keeps every cut. Default off ⇒ byte-identical to before.

Set BEFORE processing — meshes already emitted are not regenerated.

Trait Implementations§

Source§

impl Default for IfcAPI

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<IfcAPI> for JsValue

Source§

fn from(value: IfcAPI) -> Self

Converts to this type from the input type.
Source§

impl FromWasmAbi for IfcAPI

Source§

type Abi = WasmPtr<WasmRefCell<IfcAPI>>

The Wasm ABI type that this converts from when coming back out from the ABI boundary.
Source§

unsafe fn from_abi(js: Self::Abi) -> Self

Recover a Self from Self::Abi. Read more
Source§

impl IntoWasmAbi for IfcAPI

Source§

type Abi = WasmPtr<WasmRefCell<IfcAPI>>

The Wasm ABI type that this converts into when crossing the ABI boundary.
Source§

fn into_abi(self) -> Self::Abi

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
Source§

impl LongRefFromWasmAbi for IfcAPI

Source§

type Abi = WasmPtr<WasmRefCell<IfcAPI>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRef<IfcAPI>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl OptionFromWasmAbi for IfcAPI

Source§

fn is_none(abi: &Self::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
Source§

impl OptionIntoWasmAbi for IfcAPI

Source§

fn none() -> Self::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
Source§

impl RefFromWasmAbi for IfcAPI

Source§

type Abi = WasmPtr<WasmRefCell<IfcAPI>>

The Wasm ABI type references to Self are recovered from.
Source§

type Anchor = RcRef<IfcAPI>

The type that holds the reference to Self for the duration of the invocation of the function that has an &Self parameter. This is required to ensure that the lifetimes don’t persist beyond one function call, and so that they remain anonymous.
Source§

unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor

Recover a Self::Anchor from Self::Abi. Read more
Source§

impl RefMutFromWasmAbi for IfcAPI

Source§

type Abi = WasmPtr<WasmRefCell<IfcAPI>>

Same as RefFromWasmAbi::Abi
Source§

type Anchor = RcRefMut<IfcAPI>

Same as RefFromWasmAbi::Anchor
Source§

unsafe fn ref_mut_from_abi(js: Self::Abi) -> Self::Anchor

Same as RefFromWasmAbi::ref_from_abi
Source§

impl SupportsConstructor for IfcAPI

Source§

impl SupportsInstanceProperty for IfcAPI

Source§

impl SupportsStaticProperty for IfcAPI

Source§

impl TryFromJsValue for IfcAPI

Source§

fn try_from_js_value(value: JsValue) -> Result<Self, JsValue>

Performs the conversion.
Source§

fn try_from_js_value_ref(value: &JsValue) -> Option<Self>

Performs the conversion.
Source§

impl VectorFromWasmAbi for IfcAPI

Source§

type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi

Source§

unsafe fn vector_from_abi(js: Self::Abi) -> Box<[IfcAPI]>

Source§

impl VectorIntoWasmAbi for IfcAPI

Source§

type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi

Source§

fn vector_into_abi(vector: Box<[IfcAPI]>) -> Self::Abi

Source§

impl WasmDescribe for IfcAPI

Source§

impl WasmDescribeVector for IfcAPI

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<U> As for U

Source§

fn as_<T>(self) -> T
where T: CastFrom<U>, U: Sized,

Casts self to type T. The semantics of numeric casting with the as operator are followed, so <T as As>::as_::<U> can be used in the same way as T as U for numeric conversions. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ReturnWasmAbi for T
where T: IntoWasmAbi,

Source§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
Source§

fn return_abi(self) -> <T as ReturnWasmAbi>::Abi

Same as IntoWasmAbi::into_abi, except that it may throw and never return in the case of Err.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more