Skip to main content

ifc_lite_wasm/api/
export_dfjson.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//! WASM API: export_dfjson — IFC → Dragonfly DFJSON (energy model) string.
6
7use super::IfcAPI;
8use wasm_bindgen::prelude::*;
9
10#[wasm_bindgen]
11impl IfcAPI {
12    /// Export the `IfcSpace` volumes in `content` as a Dragonfly **DFJSON** string.
13    ///
14    /// Each space becomes an extruded `Room2D` (floor polygon + floor-to-ceiling height)
15    /// grouped into stories — the simpler Ladybug Tools target for mostly-vertical-wall
16    /// models. Loads via `dragonfly.model.Model.from_dfjson`.
17    ///
18    /// ```javascript
19    /// const api = new IfcAPI();
20    /// const dfjson = api.exportDfjson(ifcContent, "my_model");
21    /// ```
22    #[wasm_bindgen(js_name = exportDfjson)]
23    pub fn export_dfjson(&self, content: &[u8], name: String) -> String {
24        let opts = ifc_lite_export::DfjsonOptions { name, tolerance: 0.01 };
25        ifc_lite_export::export_dfjson(content, &opts)
26    }
27}