This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@xeokit/xeokit-ifc-to-xkt

0.1.0-alpha.1 • Public • Published

ifc2xkt

This project is using Percy.io for visual regression testing. npm version

An Experimental WASM-Based IFC Importer for xeokit

ifc2xkt is an experimental CLI tool for Node.js that converts geometry from IFC files into xeokit's native XKT geometry format.

The XKT format compresses huge double-precision models into a compact payload that can be rapidly loaded over the Web into a xeokit viewer.

This experimental converter provides a one-step IFC→XKT conversion, using the experimental WASM-based web-ifc library to parse the IFC input, and xeokit-xkt-utils to generate the XKT output.

Schependomlaan

Contents

Acknowledgements

This project builds on previous work that was generously contributed to the community by open source BIM developers:

Usage

Clone the repository and install the converter. Note that we're using git lfs clone so that we get some example IFC files to convert.

git lfs clone https://github.com/xeokit/xeokit-ifc-to-xkt.git
cd xeokit-ifc-to-xkt
npm install

Now you're ready to convert some IFC files.

To convert a file, run ifc2xkt, specifying paths to the source IFC file and the target XKT file.

node ifc2xkt.js -s ./tests/models/ifc/Schependomlaan.ifc -o ./tests/models/xkt/Schependomlaan.xkt

Once you've got your XKT file, you can then view it with xeokit in the browser.

import {Viewer, XKTLoaderPlugin} from "../dist/xeokit-sdk.es.js";

const viewer = new Viewer({
    canvasId: "myCanvas"
});

const xktLoader = new XKTLoaderPlugin(viewer);

const model = xktLoader.load({
    id: "myModel",
    src: "./tests/models/xkt/Schependomlaan.xkt"
});

Compatibility

XKT files generated by ifc2xkt work with xeokit-sdk versions 1.9 and later.

Features

  • Converts IFC 2x3 and 4 to XKT
  • Runs in Node.js
  • Fast conversion using WASM
  • Direct IFC→XKT conversion without intermediate file formats
  • Compact XKT output
  • Double-precision geometry, enabling models to be viewed at their original site placement

Architecture

As mentioned, ifc2xkt is built around two open source libraries:

  • web-ifc - an MIT-licensed library from @tomvandig, which loads an IFC file into an in-memory document model that represents the IFC geometry content.
  • xeokit-xkt-utils - an AGPL3-licensed library from xeolabs that builds an in-memory XKT document model and saves it as an XKT file.

Using these two libraries together, ifc2xkt performs the following steps:

  1. loads an IFC into an in-memory IFC document model,
  2. translates the IFC document model into an XKT document model, then
  3. serializes the XKT document model to an XKT file.

Examples

Example 1: Basic Model

In this first example, we're converting an IFC 2x3 file to XKT. This model is centered at the IFC coordinate origin, and therefore relies on single-precision geometry.

time node ifc2xkt.js -s Schependomlaan.ifc -o Schependomlaan.xkt

Reading IFC file: ifc/Schependomlaan.ifc
Wrote file
Loading: ifc/Schependomlaan.ifc
Read 
Loading 
Tape 44348356
Lines normal 714486
Max express ID 1080892
Loaded 714486 lines in 339 ms!
Array buffer size: 1040.375 kB

Writing XKT file: Schependomlaan.xkt

real    0m3.562s
user    0m4.752s
sys     0m0.241s

Schependomlaan

Example 2: Double Precision Geometry

In this second example, we're converting an IFC 4 model which is placed at [1842022, 10, -5173301], and consequently relies on double-precision geometry coordinates, because the coordinate values will be huge.

This model is of the Marc Antoine apartment building in Lyon, and was provided by BIMData.io.

time node ifc2xkt.js -s MAP.ifc -o MAP.xkt

Reading IFC file: ifc/MAP.ifc
Wrote file
Loading: ifc/MAP.ifc
Read 
Loading 
Tape 23548265
Lines normal 475783
Max express ID 833829
Loaded 475783 lines in 208 ms!
Array buffer size: 1342.054 kB

Writing XKT file: MAP.xkt

real    0m3.685s
user    0m4.889s
sys     0m0.173s

MAP

Benchmarks

The table below shows benchmarks for ifc2xkt 0.0.1-alpha using various IFC2x3 and IFC4 files. Click "View" in the last column to open each benchmark's converted XKT file in a xeokit viewer.

Model IFC Size XKT Size Objects Meshes Conversion Time View
Holter Tower 169.12M 6.26M 121100 89546 46.37s View
Conference Center 71.70M 3.99M 12174 5323 9.5s View
Schependomlaan 49.28M 1.04M 7270 4761 3.5s View
rac_advanced_sample_project 43.22M 6.62M 11122 2870 10.75s View
rme_advanced_sample_project 33.67M 1.74M 12884 3897 11.32s View
MAP (double precision) 29.35M 1.3M 3548 3680 3.6s View
IfcOpenHouse2x3 0.11M 0.01M 80 18 0.28s View
IfcOpenHouse4 0.11M 0.01M 80 18 0.21s View

Issues found in benchmarks

  • Holter Tower has missing objects
  • MAP has misaligned objects
  • Some colors are incorrect

Visual Tests

We're using visual testing on Percy to catch bugs in ifc2xkt.

See the latest test reports here: https://percy.io/73524691/xeokit-ifc-to-xkt

Percy

Further Work

  • Debug the transform precision loss in web-ifc.
  • Support point clouds, line segments
  • Somehow configure rollup.js to build a CJS binary that bundles web-ifc.wasm.

Package Sidebar

Install

npm i @xeokit/xeokit-ifc-to-xkt

Weekly Downloads

1

Version

0.1.0-alpha.1

License

AGPL3

Unpacked Size

48.1 kB

Total Files

4

Last publish

Collaborators

  • xeolabs