Skip to content

feat(viewer): Open button reclaims IFC-merge engine + new BCF export module - #676

Open
red1oon wants to merge 2 commits into
mainfrom
lane/open-button-ifc-merge
Open

feat(viewer): Open button reclaims IFC-merge engine + new BCF export module#676
red1oon wants to merge 2 commits into
mainfrom
lane/open-button-ifc-merge

Conversation

@red1oon

@red1oon red1oon commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

Both halves of bim-compiler prompts/OPEN_BUTTON_IFC_BCF_MERGE.md — Open-button item done first, BCF-export item added as a follow-up commit on this same branch/PR since it continues the same backlog entry.

1. Open button reclaims the drop-IFC multi-merge engine

  • Open now accepts native .db AND raw IFC (single or multi — 2+ auto-merge into one building), reusing import_own.js's existing multi-IFC-merge engine verbatim rather than reinventing it.
  • The landing page's #m-import-zone drop-box is retired — flagged by the user as reading like an upload/privacy prompt. Open is now the single, normal-convention entry point for any supported input.
  • import_own.js is loaded a second time, from viewer/viewer.html. Its viewer/-relative asset paths now collapse correctly via _fromViewerHost/_viewerAssetPrefix. openProject() gained opts.sameTab so a merge triggered from Open navigates the CURRENT tab instead of spawning a second one.

2. New BCF 2.1 export module (Viewer had none)

  • Ported, not invented: the zip/XML writer is a verbatim port of Modeller's already-shipped modeller/bcf_export.js; the domain mapping (topic shape, status→BCF-status, severity→BCF-priority) is ported from the real Federation/IfcOpenShell Python BCF generator (~/IfcOpenShell/src/bonsai/bonsai/bim/module/federation/bcf/bcf_generator.py + viewpoint_manager.py) — re-sourced onto the Viewer's own real fields (clash status lifecycle, severity labels, stored camera/snapshot per issue) instead of that module's SQLite schema.
  • One BCF Topic per saved viewer/issues.js Issue — both clashes (TopicType=Clash) and freeform site notes (TopicType=Comment).
  • New "Export BCF" button in the existing Issues panel toolbar, next to Export Excel.

Test plan

  • viewer/tests/poc_open_button_ifc_merge.js — real ARC+MEP reference IFCs through the real Open-button entry point, full round trip. 10/10 PASS.
  • viewer/tests/morpheus_import_live.js — retired to a regression guard confirming the drop-zone removal stuck. 4/4 PASS.
  • viewer/tests/poc_bcf_export.js — seeds real Issue records (one clash w/ real PNG snapshot, one note) into the real IndexedDB, drives the real APP.exportBcf(), then validates the produced .bcfzip with the independent unzip CLI (archive integrity + per-topic XML content), not self-checking. 20/20 PASS. Snapshot separately confirmed a genuinely valid PNG via file.
  • Manual smoke of index.html hub post-removal — catalog cards render normally, 0 console errors.

Generated with Claude Code.

red1oon and others added 2 commits July 6, 2026 07:33
…e landing drop-zone

Open now accepts native .db AND raw IFC (single or multi — 2+ auto-merge into
one building), reusing import_own.js's engine verbatim instead of reinventing
it. The landing page's #m-import-zone drop-box is removed — it read as an
upload/privacy prompt; Open is now the single entry point for any input.

- viewer/scene.js: A.openModelDb widens its picker (.db/.sqlite/.ifc,
  multi-select); A._routeOpenPicks branches by extension into the existing
  native-open path or handleImportFiles (sameTab mode).
- import_own.js: loaded a second time from viewer/viewer.html. Added
  _fromViewerHost/_viewerAssetPrefix so its viewer/-relative asset paths
  (sql.js, web-ifc.wasm, workers) collapse correctly when hosted from inside
  viewer/. openProject() gained opts.sameTab to location.assign in place
  instead of window.open when triggered from the Open button, so a merge
  loads into the current tab rather than spawning a second one.
- viewer/viewer.html: loads import_own.js; hidden status/progress nodes
  (styled as a top overlay, since the reused code toggles their display)
  mirror merge progress into the Viewer's own status line.
- index.html: removes the drop-zone markup/CSS and the now-dead
  wireImportZone().
- viewer/tests/poc_open_button_ifc_merge.js: new live witness, drives the
  real production entry point with real ARC+MEP IFC files end to end
  (merge → same-tab nav → reload → rendered scene), 10/10 PASS.
- viewer/tests/morpheus_import_live.js: retired to a regression guard that
  the drop-zone removal stuck, 4/4 PASS.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…hes + notes)

Viewer had no BCF export at all (unlike Modeller's modeller/bcf_export.js).
Ported rather than invented: the zip/XML engine is a verbatim port of
Modeller's already-shipped BCF 2.1 writer; the domain mapping (topic shape,
status→BCF-status, discipline/severity→BCF-priority) is ported from the real
Federation/IfcOpenShell Python BCF generator (~/IfcOpenShell/src/bonsai/
bonsai/bim/module/federation/bcf/bcf_generator.py + viewpoint_manager.py,
user-cited "old IfcOpenShell/Federation python").

Re-sourced onto the Viewer's own real data instead of that module's SQLite
clash_status schema:
- status   ← A._clashStatuses[A._clashPairKey(...)] (viewer/measure.js's real
  lifecycle: ''/Reviewed/Resolved/Accepted) → Open/Open/Resolved/Closed
- priority ← the issue's own stored `severity` label (Hard clash/Soft clash/
  Clearance violation, viewer/clash_rules.json) → Critical/Major/Minor
- viewpoint← the issue's own real captured camera_pos/camera_target
  (viewer/clash_snag.js already stores these); falls back to the Python
  module's isometric-from-bbox-center math only when none was stored
- snapshot ← the issue's own real stored PNG blob; omitted (not synthesized)
  when an issue has none

One BCF Topic per viewer/issues.js Issue record — clashes (TopicType=Clash)
AND freeform site notes (TopicType=Comment) both export, not just clashes.

- viewer/bcf_export.js: new module, setupBcfExport(A) convention (matches
  every other viewer/ module). Exposes A.exportBcf(opts) + A._bcf (pure
  builders, for unit checks).
- viewer/main.js: wired into the _mods boot list + window.exportIssuesBcf.
- viewer/viewer.html: script tag + "Export BCF" button in the existing
  Issues panel toolbar, next to the existing Export Excel button.
- viewer/locales/en_US.js: ui_export_bcf key (other locales fall back to the
  hardcoded English label per locale_loader.js's existing missing-key
  behavior — no crash, just untranslated).
- viewer/tests/poc_bcf_export.js: new live witness — seeds real Issue
  records (one clash w/ real PNG snapshot, one note) into the real
  IndexedDB, drives the real APP.exportBcf() entry point, then validates
  the produced .bcfzip with the INDEPENDENT `unzip` CLI (archive integrity,
  file contents, per-topic XML fields) rather than self-checking. 20/20 PASS.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@red1oon red1oon changed the title feat(viewer): Open button reclaims drop-IFC multi-merge engine feat(viewer): Open button reclaims IFC-merge engine + new BCF export module Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant