0.1.0-alpha.1 • Published 3 years ago

@xeokit/xeokit-ifc-to-xkt v0.1.0-alpha.1

Weekly downloads
-
License
AGPL3
Repository
github
Last release
3 years ago

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.

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.