Skip to main content

ifc_lite_wasm/api/
symbolic.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5//! 2D symbol extraction for the browser. Thin wrapper over the canonical
6//! extractor in `ifc-lite-processing` so the browser and the HTTP server
7//! produce bit-identical symbol streams (issue #843 follow-up: full
8//! parity, no separate code paths).
9//!
10//! The heavy lifting — Transform2D composition, IfcGrid bubbles,
11//! IfcTrimmedCurve arc handling, IfcAnnotationFillArea with holes,
12//! IfcStyledItem colour resolution, etc. — lives in
13//! `rust/processing/src/symbolic.rs`. This file just converts the
14//! resulting pure-Rust `SymbolicData` into the `wasm_bindgen` types the
15//! JS layer consumes.
16
17use super::IfcAPI;
18use wasm_bindgen::prelude::*;
19
20#[wasm_bindgen]
21impl IfcAPI {
22    /// Parse IFC file and extract symbolic representations (Plan,
23    /// Annotation, FootPrint, Axis). These are 2D curves used for
24    /// architectural drawings instead of sectioning 3D geometry.
25    ///
26    /// Example:
27    /// ```javascript
28    /// const api = new IfcAPI();
29    /// const symbols = api.parseSymbolicRepresentations(ifcData);
30    /// console.log('Found', symbols.totalCount, 'symbolic items');
31    /// for (let i = 0; i < symbols.polylineCount; i++) {
32    ///   const polyline = symbols.getPolyline(i);
33    ///   console.log('Polyline for', polyline.ifcType, ':', polyline.points);
34    /// }
35    /// ```
36    #[wasm_bindgen(js_name = parseSymbolicRepresentations)]
37    pub fn parse_symbolic_representations(
38        &self,
39        content: String,
40    ) -> crate::zero_copy::SymbolicRepresentationCollection {
41        let data = ifc_lite_processing::extract_symbolic_data(&content);
42        crate::zero_copy::SymbolicRepresentationCollection::from_data(data)
43    }
44}