Files
FreeCADWasmDev/docs/current/ifcopenshell-native-build-20260916.md
wangdequan 72152ef356 Save verified native IFC import and user validation evidence
Real IFC2X3/IFC4 import tested. Full BIM authoring/export remains out of scope; 349-second building import performance remains to optimize.
2026-09-16 04:27:37 +08:00

4.4 KiB

Real IFC Native Import Build

This work does not replace the existing ifcopenshell declaration module with a fake success path. A separately named IfcOpenShellNative import binding uses the real IfcOpenShell parser, IFC2X3/IFC4 geometry mappings, and the supplied OCCT 7.6.3 static libraries. The complete upstream Python API, BIM authoring/export, IFC4X3 and other schemas are not enabled by this binding.

Reused Work

  • Existing FreeCAD Part document owner, Std_Open file selection/cache, native file-type registry, scene dispatcher and FCStd persistence.
  • Local pthread OCCT, Boost 1.83, Python 3.12 and FreeCAD static libraries.
  • Local IFC building fixture from the supplied Qt/Assimp source tree.
  • Existing manual browser tests, structured results and screenshot folders.

The older Web_FreeCAD_Bitbybit/src/facade/bim.ts implements metadata/proxy roundtrips, not a real IFC geometry backend. It was inspected but not substituted for native parsing. No existing compatible IfcOpenShell binding was located in the indexed local sources. The missing source was obtained from the official repository, not recreated from scratch.

Source and Artifacts

  • Upstream: https://github.com/IfcOpenShell/IfcOpenShell
  • Observed commit: f8da61bf9249126c3ce41e7b995c68ae3ab520d9.
  • Source VERSION: 0.8.6 (downloaded from the v0.8.0 development branch).
  • Download archive SHA-256: c4e1efb7910dede9fabb5003e6599b52528220bf8309c00c196741e7933176fc.
  • Durable local source: freecad-source/build-web/ifcopenshell-native/source.
  • Durable archives: freecad-source/build-web/ifcopenshell-native/build.
  • Compiler/dependency/archive hashes: freecad-source/build-web/ifcopenshell-native/provenance.json.
  • License: LGPL-3.0-or-later; license texts and attribution included in web/public.

The 238 upstream build steps completed successfully in approximately 833 seconds with two compilation jobs. IfcParse is approximately 32 MiB, IfcGeom 6.7 MiB and geometry_kernel_opencascade 3 MiB. Subsequent fixes relink only the existing Part owner. RAM-backed initial source/build remains a temporary optimization; the runtime no longer depends on those RAM paths.

FREECAD_IFC_SOURCE="$PWD/freecad-source/build-web/ifcopenshell-native/source" \
FREECAD_IFC_BUILD="$PWD/freecad-source/build-web/ifcopenshell-native/build" \
node tools/build_ifcopenshell_native.mjs
node tools/run_user_repair_checks.mjs
timeout 120s node tools/test_ifc_native_contract.mjs
FREECAD_MANUAL_IDS=FILE-02 node tools/run_user_manual_tests.mjs

The cached archive-only build directory is sufficient for FreeCAD linking. To rebuild the dependency itself, the script configures that directory afresh; it will compile source objects that are not in the durable cache. The main FreeCAD CMake options are FREECAD_WEB_IFCOPENSHELL_SOURCE and FREECAD_WEB_IFCOPENSHELL_BUILD. No system Python wheel is assumed compatible with this static WebAssembly runtime.

Implementation Boundaries

Import calls the official iterator with the OpenCascade backend and one thread. It preserves native BRep, converts SI metres to FreeCAD millimetres, assigns IFC GlobalId/type/STEP identity, builds spatial groups, maps property definitions including IFC4 definition sets, and embeds the original IFC inside FCStd. Opening/space analytical volumes remain native objects but start hidden.

Invalid geometry is repaired with OCCT ShapeFix and checked again. Conversion errors roll back the newly created document, rather than silently omitting failed geometry. Metadata outside the typed scalar/property-set presentation is retained in the original attached IFC, not claimed to be editable via the full IfcOpenShell API.

The scene avoids duplicate group meshes and uses 2 mm display tessellation for documents with the native IfcSource object. This changes display precision only, not stored BRep. Std_Open passes its prepared scene to the mounted view to avoid duplicate full-building meshing.

Verification Scope

Native building import and FCStd save passed with 147 document objects. A browser reopen test recovered 134 Part features, 12 spatial groups and the source IFC attachment. Official IFC4 property-set fixtures and invalid-file preservation are separately tested. Exact final browser results and timings live in the user-tests-20260915 timestamped runs; consult those records before declaring a release accepted. Large furniture geometry repair still takes minutes and is a performance limitation, not a zero-latency import path.