[BCF] BCF 2.1/3.0: .bcfzip lesen/schreiben (Rust), Panel „BCF-Themen", GlobalId-Zuordnung, CLI bcf-info

Rust bcf.rs in fileio (zip + quick-xml, MIT): Themen, Kommentare, Viewpoints mit Kamera,
Auswahl, Sichtbarkeit, Schnittebenen, Snapshot. TS-Fassade io/bcf.ts, Zuordnung io/bcfMatch.ts
(gleiche GlobalId-Ableitung wie der IFC-Export), Dock-Panel und Menüpunkt, dossier-cli bcf-info.
Kamera setzen steht offen (Viewport ohne Setter). Nur im Linux-Container geprüft.

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-28 14:50:26 +00:00
1 parent 02b5be72cf
commit 11e88a4cb1
20 files changed
+2250 -1

No files matched your search

+10
View File
@@ -23,3 +23,13 @@ truck (https://github.com/ricosjp/truck, truck-meshalgo src/tessellation/triangu
csg.js (https://github.com/evanw/csg.js, Datei csg.js), Copyright (c) 2011 Evan Wallace, MIT License
Verfahren (BSP-Bäume, Ebenen-Teilung, clipTo/invert, Vereinigung/Differenz/Schnitt) in Rust neu
geschrieben und angepasst: src-tauri/fileio/src/csg.rs (IFC-Import: Öffnungen, Boolesche Körper).
zip (https://github.com/zip-rs/zip2), MIT, mit flate2 (MIT OR Apache-2.0) und zopfli (Apache-2.0)
Abhängigkeit von src-tauri/fileio (BCF: .bcfzip lesen und schreiben, nur Deflate), unverändert.
quick-xml (https://github.com/tafia/quick-xml), MIT
Abhängigkeit von src-tauri/fileio (BCF: markup.bcf und Viewpoints lesen), unverändert.
BCF-Spezifikation (https://github.com/buildingSMART/BCF-XML, Schemas), buildingSMART, CC BY-ND 4.0
Nur das Dateiformat als Vorlage; eigener Code in src-tauri/fileio/src/bcf.rs. Die Test-Beispiele
stehen nicht im Repo (Test buildingsmart_beispiele liest sie über BCF_TESTCASES aus einem lokalen Klon).
+18
View File
@@ -447,6 +447,24 @@ Ganzes nicht WASM-tauglich (rayon, tempfile, SystemTime) — nur einzelne Module
Export im Worker; nur Linux-Container/vitest, nicht in der Tauri-App geprüft. · L
- Geprüft nur im Linux-Container (vitest + ifcopenshell 0.9: 0 Befunde, Volumen), nicht in
Solibri/BIMcollab und nicht in der Tauri-App.
- ◐ **[BCF] BCF 2.1/3.0 (BIM Collaboration Format).** (28.10.) Koordinations-Themen mit Solibri, BIMcollab,
Revit, ArchiCAD austauschen. Rust `src-tauri/fileio/src/bcf.rs` (+ `bcf_read`/`bcf_write` im pkgFileIo,
JSON an der Grenze, Snapshots Base64): .bcfzip lesen/schreiben (Themen mit Typ/Status/Priorität/Zuständig/
Fällig/Labels, Kommentare, Viewpoints mit Perspektiv-/Orthokamera, Auswahl, Sichtbarkeits-Ausnahmen,
Schnittebenen, Snapshot; 2.1 und 3.0). Crates `zip` (MIT, nur Deflate) und `quick-xml` (MIT), in NOTICE.
TS `io/bcf.ts` (Fassade, reine Hilfen), `io/bcfMatch.ts` (GlobalId ↔ Dossier-id mit derselben Ableitung wie
der IFC-Export: `ifcGuid("<Projekt-id>/<Art>/<id>")`; importierte Meshes über `ifcGlobalId`), Dock-Panel
„BCF-Themen" (`panels/BcfPanel.tsx`, nicht im Standard-Layout, Menü Fenster > BCF-Themen bzw. macOS Fenster > Panels): Datei öffnen,
Themenliste, Klick wählt die Bauteile, Kommentar, Status, Thema aus Auswahl, Speichern. Themen liegen in
der eigenen Datei, kein Feld in `src/model`. CLI `dossier-cli bcf-info <datei.bcfzip>`.
Geprüft: Rust-Rundreise 2.1/3.0, Unsinn → Fehler (inkl. Zufallsbytes, Zip-Bomben-Grenze, XML-Tiefe),
alle 71 buildingSMART-Beispieldateien (Test Cases v2.1/v3.0, lokal; CC BY-ND, deshalb nicht im Repo,
Test `buildingsmart_beispiele` über `BCF_TESTCASES`), vitest Fassade und GlobalId-Zuordnung gegen den
IFC-Export des Demo-Hauses. Nicht geprüft: Austausch mit echter Solibri/BIMcollab-Software, Tauri-App.
Offen: Kamera des Viewpoints setzen und für neue Themen aus dem 3D-Viewport lesen (`Wasm3DViewport` hält
die Orbit-Kamera intern, ohne Setter/Getter; Achsen Z-oben wie IFC, Viewport vermutlich Y-oben);
Snapshot aus dem Viewport; `extensions.xml` (3.0), Farbgruppen/Linien, BimSnippet, Dokument-Referenzen
und verwandte Themen gehen beim Speichern verloren; Panel in den Standard-Dock aufnehmen. · M
- ○ **[B6] Wand unter Dach als Prismen zwischen Ebenen** (für [G2]). `walls.rs:413–472, 592–654`. · M
- ○ **[B7] Dach-Verschneidung und Gauben in 2.5D** (für [G5]). · M · nach [B2]/[B6].
- ○ **[B8] Bogenwände, schneller Weg** (für [T2]). · S/M–L
+77
View File
@@ -44,6 +44,15 @@ version = "1.0.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3"
[[package]]
name = "arbitrary"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d036a3c4ab069c7b410a2ce876bd74808d2d0888a82667669f8e783a898bf1"
dependencies = [
"derive_arbitrary",
]
[[package]]
name = "autocfg"
version = "1.5.1"
@@ -118,6 +127,28 @@ version = "0.8.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
[[package]]
name = "derive_arbitrary"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e567bd82dcff979e4b03460c307b3cdc9e96fde3d73bed1496d2bc75d9dd62a"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.118",
]
[[package]]
name = "displaydoc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"
dependencies = [
"proc-macro2",
"quote",
"syn 3.0.9",
]
[[package]]
name = "dossier-fileio"
version = "0.1.0"
@@ -126,10 +157,12 @@ dependencies = [
"console_error_panic_hook",
"earcutr",
"getrandom",
"quick-xml",
"serde",
"serde_json",
"spade",
"wasm-bindgen",
"zip",
]
[[package]]
@@ -276,6 +309,12 @@ version = "0.2.186"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66"
[[package]]
name = "log"
version = "0.4.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
[[package]]
name = "memchr"
version = "2.8.2"
@@ -374,6 +413,15 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "quick-xml"
version = "0.39.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdcc8dd4e2f670d309a5f0e83fe36dfdc05af317008fea29144da1a2ac858e5e"
dependencies = [
"memchr",
]
[[package]]
name = "quote"
version = "1.0.46"
@@ -624,8 +672,37 @@ version = "0.57.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
[[package]]
name = "zip"
version = "2.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fabe6324e908f85a1c52063ce7aa26b68dcb7eb6dbc83a2d148403c9bc3eba50"
dependencies = [
"arbitrary",
"crc32fast",
"crossbeam-utils",
"displaydoc",
"flate2",
"indexmap",
"memchr",
"thiserror",
"zopfli",
]
[[package]]
name = "zmij"
version = "1.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8848ee67ecc8aedbaf3e4122217aff892639231befc6a1b58d29fff4c2cabaa"
[[package]]
name = "zopfli"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f05cd8797d63865425ff89b5c4a48804f35ba0ce8d125800027ad6017d2b5249"
dependencies = [
"bumpalo",
"crc32fast",
"log",
"simd-adler32",
]
+8
View File
@@ -45,3 +45,11 @@ console_error_panic_hook = { version = "0.1", optional = true }
earcutr = "0.5"
# IFC-Import: eingeschränkte Delaunay-Triangulierung getrimmter Freiformflächen (MIT OR Apache-2.0).
spade = "2.15"
# BCF ([BCF]): .bcfzip (ZIP) lesen/schreiben und markup.bcf/viewpoint.bcfv (XML) lesen.
# zip: MIT, nur Deflate in reinem Rust (flate2/miniz_oxide, zopfli: Apache-2.0); quick-xml: MIT.
zip = { version = "2", default-features = false, features = ["deflate"] }
quick-xml = "0.39"
[dev-dependencies]
serde_json = "1"
File diff suppressed because it is too large. Load diff
+1
View File
@@ -23,6 +23,7 @@ pub mod ifc_import;
pub mod ifc_semantic;
pub mod ifc_export;
pub mod ifc_openings;
pub mod bcf;
pub mod csg;
mod ifc_sweep;
mod ifc_nurbs;
+1
View File
@@ -3440,6 +3440,7 @@ export default function App() {
resourcesOpen={resourcesOpen}
onToggleResources={() => toggleResources()}
onOpenSettings={() => openSettings()}
onOpenBcf={() => setLayout((l) => revealPanel(l, "bcf"))}
/>
)
}
+29 -1
View File
@@ -58,6 +58,8 @@ import {
parseProjectFile,
planToSvgString,
serializeProject,
parseBcf,
bcfInfo,
setWasmBytesProvider,
initCore,
validateProject,
@@ -134,12 +136,38 @@ function out(args: Args, text: string | Uint8Array, defaultName: string): void {
}
}
/** `dossier-cli bcf-info <datei.bcfzip>`: Themen einer BCF-Datei (2.1/3.0) als JSON, ohne Snapshot-Bytes. */
async function runBcfInfo(path: string | undefined): Promise<number> {
if (!path) {
process.stderr.write("Aufruf: dossier-cli bcf-info <datei.bcfzip>\n");
return 2;
}
setWasmBytesProvider(async (name) => {
const rel = WASM_FILES[name];
if (!rel) throw new Error(`unbekanntes WASM-Modul ${name}`);
return readFileSync(join(wasmDir(), rel));
});
let bytes: Uint8Array;
try {
bytes = new Uint8Array(readFileSync(path));
} catch (e) {
fail(`Datei nicht lesbar: ${path} (${e instanceof Error ? e.message : String(e)})`);
}
try {
process.stdout.write(JSON.stringify(bcfInfo(await parseBcf(bytes)), null, 2) + "\n");
} catch (e) {
fail(`BCF: ${e instanceof Error ? e.message : String(e)}`);
}
return 0;
}
export async function run(argv: string[]): Promise<number> {
const args = parseArgs(argv);
const [file, command, ...rest] = args.positional;
if (file === "bcf-info") return runBcfInfo(command);
if (!file || !command) {
process.stderr.write(
"Aufruf: dossier-cli <projekt.obp> <info|validate|migrate|plan|section|elevation|dxf|dwg|ifc|import-ifc|step|obj|stl|schedule|kennzahlen|sun|model3d> [Optionen]\n",
"Aufruf: dossier-cli <projekt.obp> <info|validate|migrate|plan|section|elevation|dxf|dwg|ifc|import-ifc|step|obj|stl|schedule|kennzahlen|sun|model3d> [Optionen]\n dossier-cli bcf-info <datei.bcfzip>\n",
);
return 2;
}
+1
View File
@@ -9,6 +9,7 @@ export { buildPlanDxfBinary } from "../export/exportDxf";
export { loadFileio } from "../engine/fileioWasm";
export { readIfc, ifcToImportedMeshes } from "../io/ifcImport";
export { readIfcElements, ifcElementsToProject } from "../io/ifcElements";
export { parseBcf, writeBcf, bcfInfo } from "../io/bcf";
export { projectGeoOrigin } from "../model/geoRebase";
export { ensureContextCategories } from "../model/contextCategories";
export { projectToWorldCoords } from "../model/geoRebase";
+33
View File
@@ -2245,6 +2245,39 @@ export const de = {
"start.recent": "Zuletzt geöffnet",
"start.recent.remove": "Aus der Liste entfernen",
"start.recentMissing": "Datei nicht gefunden — aus der Liste entfernt.",
"nav.bcf": "BCF-Themen",
"bcf.open": "Öffnen…",
"bcf.new": "Neu",
"bcf.save": "Speichern…",
"bcf.format": "Format",
"bcf.author": "Autor",
"bcf.author.placeholder": "Name oder E-Mail",
"bcf.empty": "Keine BCF-Datei geladen. Eine .bcfzip von Solibri, BIMcollab, Revit oder ArchiCAD öffnen oder ein neues Thema aus der Auswahl anlegen. Die Themen liegen in einer eigenen Datei, nicht im Projekt.",
"bcf.noTopics": "Die Datei enthält keine Themen.",
"bcf.fileInfo": "{name} · BCF {version} · {n} Themen",
"bcf.newFromSelection": "Thema aus Auswahl",
"bcf.newFromSelection.hint": "Legt ein Thema an, das auf die im Modell gewählten Bauteile zeigt (über deren IFC-GlobalId).",
"bcf.needSelection": "Zuerst Bauteile im Modell auswählen.",
"bcf.defaultTitle": "Neues Thema",
"bcf.status": "Status",
"bcf.type": "Typ",
"bcf.priority": "Priorität",
"bcf.assignedTo": "Zuständig",
"bcf.dueDate": "Fällig",
"bcf.labels": "Labels",
"bcf.description": "Beschreibung",
"bcf.comments": "Kommentare",
"bcf.commentPlaceholder": "Kommentar schreiben…",
"bcf.addComment": "Kommentieren",
"bcf.camera": "Kamera",
"bcf.camera.perspective": "perspektivisch, Position {x} / {y} / {z} m, Sichtfeld {fov}°",
"bcf.camera.orthogonal": "orthogonal, Position {x} / {y} / {z} m",
"bcf.components": "{found} von {total} Bauteilen im Modell gefunden und gewählt.",
"bcf.components.none": "Dieses Thema verweist auf keine Bauteile.",
"bcf.selectElements": "Bauteile wählen",
"bcf.openFailed": "BCF-Datei nicht lesbar: {error}",
"bcf.saved": "BCF gespeichert.",
"bcf.saveFailed": "BCF nicht gespeichert: {error}",
} as const;
export type TranslationKey = keyof typeof de;
+33
View File
@@ -2231,4 +2231,37 @@ export const en: Record<TranslationKey, string> = {
"start.recent": "Recently opened",
"start.recent.remove": "Remove from list",
"start.recentMissing": "File not found — removed from the list.",
"nav.bcf": "BCF issues",
"bcf.open": "Open…",
"bcf.new": "New",
"bcf.save": "Save…",
"bcf.format": "Format",
"bcf.author": "Author",
"bcf.author.placeholder": "Name or e-mail",
"bcf.empty": "No BCF file loaded. Open a .bcfzip from Solibri, BIMcollab, Revit or ArchiCAD, or create a new issue from the selection. Issues live in their own file, not in the project.",
"bcf.noTopics": "The file contains no issues.",
"bcf.fileInfo": "{name} · BCF {version} · {n} issues",
"bcf.newFromSelection": "Issue from selection",
"bcf.newFromSelection.hint": "Creates an issue pointing at the elements selected in the model (via their IFC GlobalId).",
"bcf.needSelection": "Select elements in the model first.",
"bcf.defaultTitle": "New issue",
"bcf.status": "Status",
"bcf.type": "Type",
"bcf.priority": "Priority",
"bcf.assignedTo": "Assigned to",
"bcf.dueDate": "Due",
"bcf.labels": "Labels",
"bcf.description": "Description",
"bcf.comments": "Comments",
"bcf.commentPlaceholder": "Write a comment…",
"bcf.addComment": "Comment",
"bcf.camera": "Camera",
"bcf.camera.perspective": "perspective, position {x} / {y} / {z} m, field of view {fov}°",
"bcf.camera.orthogonal": "orthogonal, position {x} / {y} / {z} m",
"bcf.components": "{found} of {total} elements found in the model and selected.",
"bcf.components.none": "This issue does not point at any elements.",
"bcf.selectElements": "Select elements",
"bcf.openFailed": "BCF file not readable: {error}",
"bcf.saved": "BCF saved.",
"bcf.saveFailed": "BCF not saved: {error}",
};
+148
View File
@@ -0,0 +1,148 @@
// BCF-Fassade ([BCF]): Rundreise über Rust, Fehlerfälle, reine Hilfen und die GlobalId-Zuordnung
// zum IFC-Export (gleiche Ableitung → Dossier → IFC → BCF → Dossier trifft).
import "../engine/fileioWasm.setup";
import { describe, expect, it } from "vitest";
import {
addComment,
addTopic,
bcfInfo,
emptyBcf,
newTopic,
newViewpoint,
parseBcf,
setTopicStatus,
writeBcf,
type BcfCamera,
} from "./bcf";
import { buildGuidIndex, emptyBcfSelection, resolveGuids, selectionToGuids, viewpointGuids } from "./bcfMatch";
import { exportIfcSpf, ifcGuid } from "../export/exportIfc";
import { sampleProject } from "../model/sampleProject";
import type { Project } from "../model/types";
const camera: BcfCamera = {
kind: "perspective",
position: [10, -12, 8],
direction: [-0.5, 0.6, -0.4],
up: [0, 0, 1],
fieldOfView: 50,
viewToWorldScale: 0,
aspectRatio: 1.5,
};
function sample() {
const vp = newViewpoint("vp-1", ["0n_zVrPdE0cg_UxWSd1GmA"], camera);
let f = emptyBcf("proj-1", "Haus Müller");
f = addTopic(f, newTopic({ guid: "11111111-2222-3333-4444-555555555555", title: "Wand zu dünn", author: "a@b.ch", now: "2026-10-28T09:00:00Z", description: "Mindestens 30 cm", viewpoints: [vp] }));
f = addComment(f, "11111111-2222-3333-4444-555555555555", { guid: "c-1", date: "2026-10-28T09:10:00Z", author: "c@d.ch", comment: "Einverstanden", viewpointGuid: "vp-1", modifiedDate: "", modifiedAuthor: "" });
return setTopicStatus(f, "11111111-2222-3333-4444-555555555555", "Resolved", "c@d.ch", "2026-10-28T09:20:00Z");
}
describe("BCF-Fassade", () => {
it("Rundreise 2.1 und 3.0 über Rust", async () => {
for (const version of ["2.1", "3.0"] as const) {
const bytes = await writeBcf(sample(), version);
expect(bytes[0]).toBe(0x50); // ZIP
const back = await parseBcf(bytes);
expect(back.version).toBe(version);
expect(back.projectName).toBe("Haus Müller");
const t = back.topics[0];
expect(t.title).toBe("Wand zu dünn");
expect(t.topicStatus).toBe("Resolved");
expect(t.modifiedAuthor).toBe("c@d.ch");
expect(t.comments).toHaveLength(1);
expect(t.comments[0].comment).toBe("Einverstanden");
expect(t.comments[0].viewpointGuid).toBe("vp-1");
expect(t.viewpoints[0].camera).toEqual(camera);
expect(t.viewpoints[0].selection[0].ifcGuid).toBe("0n_zVrPdE0cg_UxWSd1GmA");
}
});
it("Unsinn ergibt einen Fehler, keinen Absturz", async () => {
await expect(parseBcf(new Uint8Array([1, 2, 3]))).rejects.toThrow();
await expect(parseBcf(new Uint8Array())).rejects.toThrow();
await expect(writeBcf(sample(), "9.9" as never)).rejects.toThrow(/Version/);
const bad = { ...sample(), topics: [{ ...sample().topics[0], guid: "../x" }] };
await expect(writeBcf(bad, "2.1")).rejects.toThrow();
});
it("Hilfen ändern den Eingang nicht", () => {
const f = emptyBcf();
const g = addTopic(f, newTopic({ guid: "g", title: "t", author: "a", now: "n" }));
expect(f.topics).toHaveLength(0);
expect(g.topics).toHaveLength(1);
const h = setTopicStatus(g, "g", "Closed", "x", "later");
expect(g.topics[0].topicStatus).toBe("Open");
expect(h.topics[0].topicStatus).toBe("Closed");
});
it("bcfInfo ohne Snapshot-Bytes", async () => {
const info = bcfInfo(await parseBcf(await writeBcf(sample(), "3.0"))) as { topicCount: number; topics: { viewpoints: { selected: string[] }[] }[] };
expect(info.topicCount).toBe(1);
expect(info.topics[0].viewpoints[0].selected).toEqual(["0n_zVrPdE0cg_UxWSd1GmA"]);
expect(JSON.stringify(info)).not.toContain("snapshot\":\"");
});
});
describe("BCF-GlobalId-Zuordnung", () => {
const ifc = exportIfcSpf(sampleProject);
it("jede GlobalId des Index steht im IFC-Export", () => {
const index = buildGuidIndex(sampleProject);
const channels = new Set<string>();
let found = 0;
for (const [guid, target] of index) {
// `opening/…` (IfcOpeningElement) wird in manchen Wänden nicht geschrieben — die Füllung (`fill/…`) schon.
if (ifc.includes(`'${guid}'`)) {
found++;
channels.add(target.channel);
}
}
expect(found).toBeGreaterThan(10);
for (const c of ["wallIds", "ceilingIds", "openingIds"]) expect(channels.has(c)).toBe(true);
});
it("Rundreise Auswahl → GlobalId → Auswahl", () => {
const sel = emptyBcfSelection();
sel.wallIds = sampleProject.walls.slice(0, 2).map((w) => w.id);
sel.ceilingIds = (sampleProject.ceilings ?? []).slice(0, 1).map((c) => c.id);
sel.openingIds = (sampleProject.openings ?? []).slice(0, 1).map((o) => o.id);
const guids = selectionToGuids(sampleProject, sel);
expect(guids).toHaveLength(sel.wallIds.length + sel.ceilingIds.length + sel.openingIds.length);
for (const g of guids) expect(ifc).toContain(`'${g}'`);
const back = resolveGuids(sampleProject, guids);
expect(back.missing).toEqual([]);
expect(back.selection).toEqual(sel);
});
it("Wand-GlobalId entspricht der im Export (Projekt-id/wall/id)", () => {
const w = sampleProject.walls[0];
const g = ifcGuid(`${sampleProject.id}/wall/${w.id}`);
expect(resolveGuids(sampleProject, [g]).selection.wallIds).toEqual([w.id]);
});
it("unbekannte GUIDs werden gemeldet", () => {
const r = resolveGuids(sampleProject, ["0000000000000000000000", ifcGuid(`${sampleProject.id}/wall/${sampleProject.walls[0].id}`)]);
expect(r.missing).toEqual(["0000000000000000000000"]);
expect(r.selection.wallIds).toHaveLength(1);
});
it("importierte Meshes über ifcGlobalId", () => {
const p = {
...sampleProject,
context: [{ id: "m1", type: "importedMesh", name: "x", ifcGlobalId: "2O2Fr$t4X7Zf8NOew3FLOH", positions: [], indices: [] }],
} as unknown as Project;
expect(resolveGuids(p, ["2O2Fr$t4X7Zf8NOew3FLOH"]).selection.contextObjectIds).toEqual(["m1"]);
const sel = emptyBcfSelection();
sel.contextObjectIds = ["m1"];
expect(selectionToGuids(p, sel)).toEqual(["2O2Fr$t4X7Zf8NOew3FLOH"]);
});
it("viewpointGuids: Auswahl, sonst sichtbare Ausnahmen bei defaultVisibility=false", () => {
const vp = newViewpoint("v", ["A", "B", "A"]);
expect(viewpointGuids(vp)).toEqual(["A", "B"]);
const hidden = { ...newViewpoint("v", []), defaultVisibility: false, exceptions: [{ ifcGuid: "C", originatingSystem: "", authoringToolId: "" }] };
expect(viewpointGuids(hidden)).toEqual(["C"]);
expect(viewpointGuids(newViewpoint("v", []))).toEqual([]);
});
});
+224
View File
@@ -0,0 +1,224 @@
// BCF (BIM Collaboration Format) 2.1/3.0: dünne TS-Fassade über das Rust-Modul `bcf.rs`
// (`src-tauri/fileio`, pkgFileIo). Rust liest/schreibt die .bcfzip, an der Grenze steht JSON
// (Text, Kamera, Komponenten-GUIDs; Snapshots als Base64). Die Themen gehören NICHT ins Projekt:
// sie leben in einer eigenen Datei (s. `panels/BcfPanel.tsx`).
//
// Reine Hilfen (`addComment`, `setTopicStatus`, `newTopic` …) ändern nichts am Eingang, sondern
// liefern Kopien; Zeit und Guid kommen vom Aufrufer (Tests deterministisch).
import { loadFileio } from "../engine/fileioWasm";
export type BcfVersion = "2.1" | "3.0";
export type Vec3 = [number, number, number];
export interface BcfComponent {
/** 22-stellige IFC-GlobalId. */
ifcGuid: string;
originatingSystem: string;
authoringToolId: string;
}
export interface BcfCamera {
kind: "perspective" | "orthogonal";
position: Vec3;
direction: Vec3;
up: Vec3;
/** Vertikaler Öffnungswinkel in Grad (perspektivisch). */
fieldOfView: number;
viewToWorldScale: number;
aspectRatio: number;
}
export interface BcfClippingPlane {
location: Vec3;
direction: Vec3;
}
export interface BcfViewpoint {
guid: string;
file: string;
snapshotFile: string;
/** Snapshot (PNG/JPEG) als Base64, leer = keiner. */
snapshot: string;
camera: BcfCamera | null;
selection: BcfComponent[];
/** true = alles sichtbar ausser `exceptions`; false = alles unsichtbar ausser `exceptions`. */
defaultVisibility: boolean;
exceptions: BcfComponent[];
clippingPlanes: BcfClippingPlane[];
}
export interface BcfComment {
guid: string;
date: string;
author: string;
comment: string;
viewpointGuid: string;
modifiedDate: string;
modifiedAuthor: string;
}
export interface BcfHeaderFile {
ifcProject: string;
ifcSpatialStructureElement: string;
isExternal: boolean;
filename: string;
date: string;
reference: string;
}
export interface BcfTopic {
guid: string;
topicType: string;
topicStatus: string;
title: string;
priority: string;
creationDate: string;
creationAuthor: string;
modifiedDate: string;
modifiedAuthor: string;
dueDate: string;
assignedTo: string;
stage: string;
description: string;
labels: string[];
headerFiles: BcfHeaderFile[];
comments: BcfComment[];
viewpoints: BcfViewpoint[];
}
export interface BcfFile {
version: string;
projectId: string;
projectName: string;
topics: BcfTopic[];
}
function message(e: unknown, fallback: string): string {
return typeof e === "string" ? e : e instanceof Error ? e.message : fallback;
}
/** .bcfzip lesen. Wirft bei Unsinn (kein ZIP, kein BCF) mit lesbarer Meldung. */
export async function parseBcf(bytes: Uint8Array): Promise<BcfFile> {
const m = await loadFileio();
try {
return JSON.parse(m.bcf_read(bytes)) as BcfFile;
} catch (e) {
throw new Error(message(e, "BCF nicht lesbar"));
}
}
/** .bcfzip der gewünschten Version erzeugen. */
export async function writeBcf(file: BcfFile, version: BcfVersion = "2.1"): Promise<Uint8Array> {
const m = await loadFileio();
try {
return m.bcf_write(JSON.stringify(file), version);
} catch (e) {
throw new Error(message(e, "BCF nicht schreibbar"));
}
}
/** Übliche Status-Werte (BCF lässt eigene Werte über extensions zu). */
export const BCF_STATUSES = ["Open", "In Progress", "Resolved", "Closed"] as const;
export function emptyBcf(projectId = "", projectName = ""): BcfFile {
return { version: "2.1", projectId, projectName, topics: [] };
}
/** Neues Thema (Guid/Zeit vom Aufrufer). */
export function newTopic(init: {
guid: string;
title: string;
author: string;
now: string;
description?: string;
viewpoints?: BcfViewpoint[];
}): BcfTopic {
return {
guid: init.guid,
topicType: "Issue",
topicStatus: "Open",
title: init.title,
priority: "",
creationDate: init.now,
creationAuthor: init.author,
modifiedDate: "",
modifiedAuthor: "",
dueDate: "",
assignedTo: "",
stage: "",
description: init.description ?? "",
labels: [],
headerFiles: [],
comments: [],
viewpoints: init.viewpoints ?? [],
};
}
/** Viewpoint aus einer Komponenten-Auswahl (Kamera optional). */
export function newViewpoint(guid: string, ifcGuids: string[], camera: BcfCamera | null = null, system = "Dossier"): BcfViewpoint {
return {
guid,
file: "",
snapshotFile: "",
snapshot: "",
camera,
selection: ifcGuids.map((ifcGuid) => ({ ifcGuid, originatingSystem: system, authoringToolId: "" })),
defaultVisibility: true,
exceptions: [],
clippingPlanes: [],
};
}
function mapTopic(file: BcfFile, guid: string, fn: (t: BcfTopic) => BcfTopic): BcfFile {
return { ...file, topics: file.topics.map((t) => (t.guid === guid ? fn(t) : t)) };
}
export function addTopic(file: BcfFile, topic: BcfTopic): BcfFile {
return { ...file, topics: [...file.topics, topic] };
}
export function setTopicStatus(file: BcfFile, guid: string, status: string, author: string, now: string): BcfFile {
return mapTopic(file, guid, (t) => ({ ...t, topicStatus: status, modifiedDate: now, modifiedAuthor: author }));
}
export function addComment(file: BcfFile, guid: string, comment: BcfComment): BcfFile {
return mapTopic(file, guid, (t) => ({
...t,
comments: [...t.comments, comment],
modifiedDate: comment.date,
modifiedAuthor: comment.author,
}));
}
/** Zusammenfassung für `dossier-cli bcf-info`: Themen als JSON-taugliches Objekt, ohne Snapshot-Bytes. */
export function bcfInfo(file: BcfFile): unknown {
return {
version: file.version,
project: { id: file.projectId, name: file.projectName },
topicCount: file.topics.length,
topics: file.topics.map((t) => ({
guid: t.guid,
title: t.title,
type: t.topicType,
status: t.topicStatus,
priority: t.priority,
assignedTo: t.assignedTo,
dueDate: t.dueDate,
creationDate: t.creationDate,
creationAuthor: t.creationAuthor,
description: t.description,
labels: t.labels,
comments: t.comments.map((c) => ({ guid: c.guid, date: c.date, author: c.author, comment: c.comment })),
viewpoints: t.viewpoints.map((v) => ({
guid: v.guid,
camera: v.camera,
selected: v.selection.map((c) => c.ifcGuid),
defaultVisibility: v.defaultVisibility,
exceptions: v.exceptions.map((c) => c.ifcGuid),
clippingPlanes: v.clippingPlanes.length,
hasSnapshot: v.snapshot.length > 0,
})),
})),
};
}
+113
View File
@@ -0,0 +1,113 @@
// BCF ↔ Dossier: IFC-GlobalId eines Komponenten-Verweises ↔ Bauteil-ids des Projekts.
//
// Dieselbe Ableitung wie der IFC-Export (`exportIfc.ts`/`ifc_export.rs`: `ifcGuid("<Projekt-id>/<Art>/<id>")`),
// damit die Rundreise Dossier → IFC → Solibri → BCF → Dossier trifft. Importierte Meshes tragen die
// GlobalId ihres Quell-Bauteils (`ImportedMesh.ifcGlobalId`). Bauteile, die im Export nicht vorkommen
// (2D-Zeichnungen, Gruppen), haben keine GlobalId.
import type { BcfViewpoint } from "./bcf";
import { ifcGuid } from "../export/exportIfc";
import type { Project } from "../model/types";
/** Ids je Auswahlkanal (Namen wie `selected…Ids` im Zustand). */
export interface BcfSelection {
wallIds: string[];
ceilingIds: string[];
openingIds: string[];
stairIds: string[];
roomIds: string[];
extrudedSolidIds: string[];
columnIds: string[];
roofIds: string[];
contextObjectIds: string[];
}
export type BcfChannel = keyof BcfSelection;
export const emptyBcfSelection = (): BcfSelection => ({
wallIds: [],
ceilingIds: [],
openingIds: [],
stairIds: [],
roomIds: [],
extrudedSolidIds: [],
columnIds: [],
roofIds: [],
contextObjectIds: [],
});
export function bcfSelectionSize(s: BcfSelection): number {
return Object.values(s).reduce((n, ids) => n + ids.length, 0);
}
interface Target {
channel: BcfChannel;
id: string;
}
/** GlobalId → Bauteil (alle Bauteile, die der IFC-Export mit dieser GlobalId schreibt). */
export function buildGuidIndex(project: Project): Map<string, Target> {
const index = new Map<string, Target>();
const pid = project.id;
const add = (key: string, channel: BcfChannel, id: string) => index.set(ifcGuid(`${pid}/${key}/${id}`), { channel, id });
for (const w of project.walls ?? []) add("wall", "wallIds", w.id);
for (const c of project.ceilings ?? []) add("slab", "ceilingIds", c.id);
for (const r of project.roofs ?? []) add("roof", "roofIds", r.id);
for (const c of project.columns ?? []) add("column", "columnIds", c.id);
for (const s of project.stairs ?? []) add("stair", "stairIds", s.id);
for (const e of project.extrudedSolids ?? []) add("extrusion", "extrudedSolidIds", e.id);
for (const r of project.rooms ?? []) add("space", "roomIds", r.id);
for (const o of project.openings ?? []) {
// Tür/Fenster (IfcDoor/IfcWindow) und Öffnung (IfcOpeningElement) gehören zur selben Dossier-Öffnung.
add("fill", "openingIds", o.id);
add("opening", "openingIds", o.id);
}
for (const o of project.context ?? []) {
if (o.type === "importedMesh" && o.ifcGlobalId) index.set(o.ifcGlobalId, { channel: "contextObjectIds", id: o.id });
}
return index;
}
/** Komponenten-GUIDs → Auswahl; unbekannte GUIDs landen in `missing`. */
export function resolveGuids(project: Project, guids: string[]): { selection: BcfSelection; missing: string[] } {
const index = buildGuidIndex(project);
const selection = emptyBcfSelection();
const missing: string[] = [];
for (const g of guids) {
const hit = index.get(g);
if (!hit) {
missing.push(g);
continue;
}
if (!selection[hit.channel].includes(hit.id)) selection[hit.channel].push(hit.id);
}
return { selection, missing };
}
/** GUIDs, auf die ein Viewpoint zeigt: gewählte Komponenten, sonst die sichtbaren Ausnahmen bei „alles unsichtbar". */
export function viewpointGuids(vp: BcfViewpoint): string[] {
const picked = vp.selection.map((c) => c.ifcGuid);
if (picked.length > 0) return [...new Set(picked)];
if (!vp.defaultVisibility) return [...new Set(vp.exceptions.map((c) => c.ifcGuid))];
return [];
}
/** Auswahl → IFC-GlobalIds (Umkehrung von {@link resolveGuids}); Elemente ohne GlobalId entfallen. */
export function selectionToGuids(project: Project, sel: BcfSelection): string[] {
const pid = project.id;
const guids: string[] = [];
const g = (key: string, ids: string[]) => ids.forEach((id) => guids.push(ifcGuid(`${pid}/${key}/${id}`)));
g("wall", sel.wallIds);
g("slab", sel.ceilingIds);
g("roof", sel.roofIds);
g("column", sel.columnIds);
g("stair", sel.stairIds);
g("extrusion", sel.extrudedSolidIds);
g("space", sel.roomIds);
g("fill", sel.openingIds);
for (const id of sel.contextObjectIds) {
const o = (project.context ?? []).find((c) => c.id === id);
if (o?.type === "importedMesh" && o.ifcGlobalId) guids.push(o.ifcGlobalId);
}
return guids;
}
+272
View File
@@ -0,0 +1,272 @@
// Dock-Panel „BCF-Themen": Koordinations-Themen im BIM Collaboration Format (2.1/3.0) von Solibri,
// BIMcollab, Revit, ArchiCAD. Datei öffnen, Themenliste mit Status, Klick zeigt Beschreibung,
// Kommentare und Snapshot und wählt die betroffenen Bauteile im Modell aus (Zuordnung über die
// IFC-GlobalId, dieselbe Ableitung wie im IFC-Export: `io/bcfMatch.ts`). Kommentar hinzufügen,
// Status ändern, neues Thema aus der Auswahl, als .bcfzip speichern.
//
// Die Themen gehören nicht zum Projekt (eigene Datei, `bcfSession.ts`). Die Kamera eines Viewpoints
// wird angezeigt, aber noch nicht gesetzt: `Wasm3DViewport` hält seine Orbit-Kamera intern und bietet
// keine Setz-Funktion (s. TODO.md [BCF]).
//
// Bezeichner englisch, UI-Text deutsch/englisch über t().
import { useMemo, useRef } from "react";
import { t } from "../i18n";
import { usePanelHost } from "./host";
import { getState, useStore } from "../state/appStore";
import { saveBinaryFile } from "../native/saveFile";
import {
BCF_STATUSES,
addComment,
addTopic,
emptyBcf,
newTopic,
newViewpoint,
parseBcf,
setTopicStatus,
writeBcf,
type BcfCamera,
type BcfFile,
type BcfTopic,
type BcfVersion,
} from "../io/bcf";
import {
bcfSelectionSize,
emptyBcfSelection,
resolveGuids,
selectionToGuids,
viewpointGuids,
type BcfSelection,
} from "../io/bcfMatch";
import { fileioLoaded, loadFileio } from "../engine/fileioWasm";
import { setBcfSession, useBcfSession } from "./bcfSession";
const AUTHOR_KEY = "dossier.bcf.author";
function readAuthor(): string {
try {
return localStorage.getItem(AUTHOR_KEY) ?? "";
} catch {
return "";
}
}
function writeAuthor(v: string): void {
try {
localStorage.setItem(AUTHOR_KEY, v);
} catch {
/* ohne Speicher: nur für diese Sitzung */
}
}
function uuid(): string {
if (typeof crypto !== "undefined" && "randomUUID" in crypto) return crypto.randomUUID();
const h = (n: number) => Math.floor(Math.random() * 16 ** n).toString(16).padStart(n, "0");
return `${h(8)}-${h(4)}-4${h(3)}-a${h(3)}-${h(12)}`;
}
/** Auswahl des Modells in die Kanäle des Stores übernehmen (ersetzt die bisherige Auswahl). */
function applySelection(sel: BcfSelection): void {
const s = getState();
s.clearSelection();
s.setSelectedWallIds(sel.wallIds);
s.setSelectedCeilingIds(sel.ceilingIds);
s.setSelectedOpeningIds(sel.openingIds);
s.setSelectedStairIds(sel.stairIds);
s.setSelectedRoomIds(sel.roomIds);
s.setSelectedExtrudedSolidIds(sel.extrudedSolidIds);
s.setSelectedColumnIds(sel.columnIds);
s.setSelectedRoofIds(sel.roofIds);
s.setSelectedContextObjectIds(sel.contextObjectIds);
}
function currentSelection(): BcfSelection {
const s = getState();
return {
...emptyBcfSelection(),
wallIds: s.selectedWallIds,
ceilingIds: s.selectedCeilingIds,
openingIds: s.selectedOpeningIds,
stairIds: s.selectedStairIds,
roomIds: s.selectedRoomIds,
extrudedSolidIds: s.selectedExtrudedSolidIds,
columnIds: s.selectedColumnIds,
roofIds: s.selectedRoofIds,
contextObjectIds: s.selectedContextObjectIds,
};
}
const f1 = (n: number) => n.toLocaleString("de-CH", { maximumFractionDigits: 1 });
function cameraText(c: BcfCamera): string {
const p = { x: f1(c.position[0]), y: f1(c.position[1]), z: f1(c.position[2]) };
return c.kind === "orthogonal" ? t("bcf.camera.orthogonal", p) : t("bcf.camera.perspective", { ...p, fov: f1(c.fieldOfView) });
}
export function BcfPanel() {
const host = usePanelHost();
const notify = useStore((s) => s.notify);
const session = useBcfSession();
const inputRef = useRef<HTMLInputElement>(null);
const authorRef = useRef<HTMLInputElement>(null);
const commentRef = useRef<HTMLTextAreaElement>(null);
const { file, selectedGuid } = session;
const topic = file?.topics.find((x) => x.guid === selectedGuid) ?? null;
const author = () => authorRef.current?.value.trim() || "Dossier";
const now = () => new Date().toISOString();
const update = (next: BcfFile) => setBcfSession({ file: next, dirty: true });
const openFile = async (f: File) => {
try {
const parsed = await parseBcf(new Uint8Array(await f.arrayBuffer()));
setBcfSession({ file: parsed, fileName: f.name, dirty: false, selectedGuid: null, version: parsed.version === "3.0" ? "3.0" : "2.1" });
} catch (e) {
notify(t("bcf.openFailed", { error: e instanceof Error ? e.message : String(e) }), "error");
}
};
const selectTopic = (tp: BcfTopic) => {
setBcfSession({ selectedGuid: tp.guid });
const guids = [...new Set(tp.viewpoints.flatMap(viewpointGuids))];
if (guids.length === 0) return;
// GlobalIds brauchen das Format-Modul (Rust-Hash); nach dem Öffnen ist es geladen.
void loadFileio().then(() => {
const { selection } = resolveGuids(host.project, guids);
const found = bcfSelectionSize(selection);
applySelection(selection);
notify(t("bcf.components", { found, total: guids.length }), found > 0 ? "info" : "warning");
});
};
const save = async () => {
if (!file) return;
try {
const bytes = await writeBcf(file, session.version);
const name = session.fileName.replace(/\.(bcf|bcfzip|zip)$/i, "") || host.project.name || "themen";
if (await saveBinaryFile(bytes, `${name}.bcfzip`, "application/zip")) {
setBcfSession({ dirty: false, fileName: `${name}.bcfzip` });
notify(t("bcf.saved"), "info");
}
} catch (e) {
notify(t("bcf.saveFailed", { error: e instanceof Error ? e.message : String(e) }), "error");
}
};
const createFromSelection = async () => {
const sel = currentSelection();
if (bcfSelectionSize(sel) === 0) {
notify(t("bcf.needSelection"), "warning");
return;
}
await loadFileio();
const guids = selectionToGuids(host.project, sel);
const topicGuid = uuid();
const tp = newTopic({
guid: topicGuid,
title: t("bcf.defaultTitle"),
author: author(),
now: now(),
viewpoints: guids.length > 0 ? [newViewpoint(uuid(), guids)] : [],
});
const base = file ?? emptyBcf(host.project.id, host.project.name ?? "");
setBcfSession({ file: addTopic(base, tp), dirty: true, selectedGuid: topicGuid });
};
const submitComment = () => {
const el = commentRef.current;
if (!file || !topic || !el || el.value.trim() === "") return;
update(addComment(file, topic.guid, { guid: uuid(), date: now(), author: author(), comment: el.value.trim(), viewpointGuid: "", modifiedDate: "", modifiedAuthor: "" }));
el.value = "";
};
const retitle = (title: string) => {
if (!file || !topic) return;
update({ ...file, topics: file.topics.map((x) => (x.guid === topic.guid ? { ...x, title, modifiedDate: now(), modifiedAuthor: author() } : x)) });
};
const snapshot = topic?.viewpoints.find((v) => v.snapshot)?.snapshot;
const camera = topic?.viewpoints.find((v) => v.camera)?.camera ?? null;
const topicGuids = topic ? [...new Set(topic.viewpoints.flatMap(viewpointGuids))] : [];
const project = host.project;
const foundCount = useMemo(
() => (topicGuids.length > 0 && fileioLoaded() ? bcfSelectionSize(resolveGuids(project, topicGuids).selection) : 0),
// eslint-disable-next-line react-hooks/exhaustive-deps
[project, topic],
);
return (
<div className="bcf-panel">
<div className="bcf-bar">
<button type="button" className="bcf-btn" onClick={() => inputRef.current?.click()}>{t("bcf.open")}</button>
<button type="button" className="bcf-btn" onClick={() => setBcfSession({ file: emptyBcf(host.project.id, host.project.name ?? ""), fileName: "", dirty: false, selectedGuid: null })}>{t("bcf.new")}</button>
<button type="button" className="bcf-btn" disabled={!file} onClick={() => void save()}>{t("bcf.save")}{session.dirty ? " •" : ""}</button>
<input ref={inputRef} type="file" accept=".bcf,.bcfzip,.zip" hidden onChange={(e) => { const f = e.target.files?.[0]; e.target.value = ""; if (f) void openFile(f); }} />
</div>
<div className="bcf-bar">
<label className="bcf-field">
<span>{t("bcf.author")}</span>
<input ref={authorRef} type="text" defaultValue={readAuthor()} placeholder={t("bcf.author.placeholder")} onChange={(e) => writeAuthor(e.target.value)} />
</label>
<label className="bcf-field bcf-field-narrow">
<span>{t("bcf.format")}</span>
<select value={session.version} onChange={(e) => setBcfSession({ version: e.target.value as BcfVersion })}>
<option value="2.1">BCF 2.1</option>
<option value="3.0">BCF 3.0</option>
</select>
</label>
</div>
<button type="button" className="bcf-btn" title={t("bcf.newFromSelection.hint")} onClick={() => void createFromSelection()}>{t("bcf.newFromSelection")}</button>
{!file && <div className="bcf-empty">{t("bcf.empty")}</div>}
{file && <div className="bcf-info">{t("bcf.fileInfo", { name: session.fileName || "–", version: file.version, n: file.topics.length })}</div>}
{file && file.topics.length === 0 && <div className="bcf-empty">{t("bcf.noTopics")}</div>}
<ul className="bcf-list">
{file?.topics.map((tp) => (
<li key={tp.guid}>
<button type="button" className={`bcf-topic${tp.guid === selectedGuid ? " is-active" : ""}`} onClick={() => selectTopic(tp)}>
<span className={`bcf-status bcf-status-${tp.topicStatus.toLowerCase().replace(/\s+/g, "-")}`}>{tp.topicStatus}</span>
<span className="bcf-topic-title">{tp.title}</span>
{tp.comments.length > 0 && <span className="bcf-count">{tp.comments.length}</span>}
</button>
</li>
))}
</ul>
{file && topic && (
<div className="bcf-detail">
<input className="bcf-title" type="text" value={topic.title} onChange={(e) => retitle(e.target.value)} aria-label={t("bcf.defaultTitle")} />
<div className="bcf-grid">
<label className="bcf-field">
<span>{t("bcf.status")}</span>
<select value={topic.topicStatus} onChange={(e) => update(setTopicStatus(file, topic.guid, e.target.value, author(), now()))}>
{[...new Set<string>([...BCF_STATUSES, topic.topicStatus])].map((s) => <option key={s} value={s}>{s}</option>)}
</select>
</label>
{topic.topicType && <div className="bcf-kv"><span>{t("bcf.type")}</span>{topic.topicType}</div>}
{topic.priority && <div className="bcf-kv"><span>{t("bcf.priority")}</span>{topic.priority}</div>}
{topic.assignedTo && <div className="bcf-kv"><span>{t("bcf.assignedTo")}</span>{topic.assignedTo}</div>}
{topic.dueDate && <div className="bcf-kv"><span>{t("bcf.dueDate")}</span>{topic.dueDate.slice(0, 10)}</div>}
{topic.labels.length > 0 && <div className="bcf-kv"><span>{t("bcf.labels")}</span>{topic.labels.join(", ")}</div>}
</div>
{topic.description && <div className="bcf-desc">{topic.description}</div>}
{snapshot && <img className="bcf-snapshot" alt="" src={`data:image/png;base64,${snapshot}`} />}
{camera && <div className="bcf-info"><b>{t("bcf.camera")}:</b> {cameraText(camera)}</div>}
<div className="bcf-bar">
<div className="bcf-info bcf-grow">{topicGuids.length > 0 ? t("bcf.components", { found: foundCount, total: topicGuids.length }) : t("bcf.components.none")}</div>
{topicGuids.length > 0 && <button type="button" className="bcf-btn" onClick={() => selectTopic(topic)}>{t("bcf.selectElements")}</button>}
</div>
<div className="bcf-sub">{t("bcf.comments")}</div>
{topic.comments.map((c) => (
<div className="bcf-comment" key={c.guid}>
<div className="bcf-comment-head">{c.author} · {c.date.slice(0, 16).replace("T", " ")}</div>
<div>{c.comment}</div>
</div>
))}
<textarea ref={commentRef} className="bcf-input" rows={2} placeholder={t("bcf.commentPlaceholder")} />
<button type="button" className="bcf-btn" onClick={submitComment}>{t("bcf.addComment")}</button>
</div>
)}
</div>
);
}
+10
View File
@@ -97,3 +97,13 @@ export function RoomBalanceTabIcon() {
</svg>
);
}
/** BCF-Themen — Sprechblase mit Haken (Koordinations-Thema). */
export function BcfTabIcon() {
return (
<svg {...common}>
<path d="M2.5 3.5h11v7h-6l-3 2.5v-2.5h-2z" />
<path d="M5.5 7l1.6 1.6L10.5 5.5" />
</svg>
);
}
+33
View File
@@ -0,0 +1,33 @@
// Sitzungszustand des BCF-Panels: die geladene BCF-Datei lebt AUSSERHALB des Projekts (eigene .bcfzip),
// aber über das Umschalten der Panel-Tabs hinweg — daher ein kleiner Modul-Speicher statt React-State.
import { useSyncExternalStore } from "react";
import type { BcfFile, BcfVersion } from "../io/bcf";
export interface BcfSession {
file: BcfFile | null;
fileName: string;
dirty: boolean;
selectedGuid: string | null;
version: BcfVersion;
}
let state: BcfSession = { file: null, fileName: "", dirty: false, selectedGuid: null, version: "2.1" };
const listeners = new Set<() => void>();
export const getBcfSession = (): BcfSession => state;
export function setBcfSession(patch: Partial<BcfSession>): void {
state = { ...state, ...patch };
for (const l of listeners) l();
}
export function useBcfSession(): BcfSession {
return useSyncExternalStore(
(cb) => {
listeners.add(cb);
return () => listeners.delete(cb);
},
getBcfSession,
);
}
+14
View File
@@ -25,6 +25,7 @@ import { RoomBalancePanel } from "./RoomBalancePanel";
import { ElementTreePanel, ElementsTabIcon } from "./ElementTreePanel";
import { ViewSnapshotsPanel, ViewSnapshotsTabIcon } from "./ViewSnapshotsPanel";
import { LayoutsPanel, LayoutsTabIcon } from "./LayoutsPanel";
import { BcfPanel } from "./BcfPanel";
import {
ToolsTabIcon,
AttributesTabIcon,
@@ -33,6 +34,7 @@ import {
LayersTabIcon,
SiteTabIcon,
RoomBalanceTabIcon,
BcfTabIcon,
} from "./PanelIcons";
/** IDs der eingebauten Dock-Panels (auch für defaultLayout/Filter nutzbar). */
@@ -47,6 +49,7 @@ export const BUILTIN_PANEL_IDS = {
elements: "elements",
viewSnapshots: "view-snapshots",
layouts: "layouts",
bcf: "bcf",
} as const;
// Werkzeug-Palette (Symbol + Name je Werkzeug, ArchiCAD/Vectorworks-Stil).
@@ -144,3 +147,14 @@ registerPanel({
hasDisplayMode: false,
render: () => <LayoutsPanel />,
});
// BCF-Themen (buildingSMART BCF 2.1/3.0) — Koordinations-Themen aus Solibri/BIMcollab/Revit/ArchiCAD;
// die Themen liegen in einer eigenen .bcfzip, nicht im Projekt. Nicht im Standard-Layout (kein
// Layout-Versionssprung), erreichbar über „Fenster > Panels".
registerPanel({
id: BUILTIN_PANEL_IDS.bcf,
title: "nav.bcf",
icon: <BcfTabIcon />,
hasDisplayMode: false,
render: () => <BcfPanel />,
});
+179
View File
@@ -8243,3 +8243,182 @@ body {
gap: 6px;
margin-top: 10px;
}
/* ── BCF-Themen (BcfPanel) ───────────────────────────────────────────── */
.bcf-panel {
display: flex;
flex-direction: column;
gap: 6px;
padding: 8px;
overflow-y: auto;
height: 100%;
min-height: 0;
font-size: 12px;
}
.bcf-bar {
display: flex;
align-items: flex-end;
gap: 6px;
}
.bcf-grow {
flex: 1 1 auto;
min-width: 0;
}
.bcf-btn {
flex: 1 1 auto;
padding: 5px 8px;
border-radius: 6px;
border: 1px solid var(--line);
background: var(--panel-2);
color: var(--ink);
cursor: pointer;
font-size: 12px;
text-align: center;
}
.bcf-btn:hover:not(:disabled) {
background: var(--accent-dim);
border-color: var(--accent-border);
}
.bcf-btn:disabled {
opacity: 0.5;
cursor: default;
}
.bcf-field {
display: flex;
flex-direction: column;
gap: 2px;
flex: 1 1 auto;
min-width: 0;
color: var(--ink-2);
font-size: 11px;
}
.bcf-field-narrow {
flex: 0 0 90px;
}
.bcf-field input,
.bcf-field select,
.bcf-title,
.bcf-input {
min-width: 0;
padding: 4px 6px;
border-radius: 6px;
border: 1px solid var(--line);
background: var(--input);
color: var(--ink);
font: inherit;
}
.bcf-title {
font-weight: 600;
}
.bcf-input {
resize: vertical;
}
.bcf-info {
color: var(--ink-2);
font-size: 11px;
}
.bcf-empty {
color: var(--ink-2);
padding: 8px 4px;
line-height: 1.4;
}
.bcf-list {
list-style: none;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
gap: 2px;
}
.bcf-topic {
display: flex;
align-items: center;
gap: 6px;
width: 100%;
padding: 4px 6px;
border: 1px solid transparent;
border-radius: 6px;
background: transparent;
color: var(--ink);
cursor: pointer;
font-size: 12px;
text-align: left;
}
.bcf-topic:hover {
background: var(--accent-dim);
}
.bcf-topic.is-active {
background: var(--active-dim);
border-color: var(--accent-border);
}
.bcf-topic-title {
flex: 1 1 auto;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.bcf-status {
flex: 0 0 auto;
padding: 1px 6px;
border-radius: 8px;
background: var(--panel-2);
border: 1px solid var(--line);
color: var(--ink-2);
font-size: 10px;
text-transform: uppercase;
letter-spacing: 0.03em;
}
.bcf-status-open,
.bcf-status-active {
color: var(--danger);
border-color: var(--danger);
}
.bcf-count {
flex: 0 0 auto;
color: var(--muted);
font-size: 11px;
}
.bcf-detail {
display: flex;
flex-direction: column;
gap: 6px;
padding-top: 6px;
border-top: 1px solid var(--line);
}
.bcf-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 4px 8px;
}
.bcf-kv span {
display: block;
color: var(--ink-2);
font-size: 11px;
}
.bcf-desc {
white-space: pre-wrap;
line-height: 1.4;
}
.bcf-snapshot {
max-width: 100%;
border-radius: 6px;
border: 1px solid var(--line);
}
.bcf-sub {
font-weight: 600;
color: var(--ink-2);
font-size: 11px;
text-transform: uppercase;
letter-spacing: 0.04em;
}
.bcf-comment {
padding: 4px 6px;
border-radius: 6px;
background: var(--panel-2);
white-space: pre-wrap;
}
.bcf-comment-head {
color: var(--ink-2);
font-size: 11px;
}
+4
View File
@@ -41,6 +41,8 @@ export interface AppMenuBarProps {
resourcesOpen: boolean;
onToggleResources: () => void;
onOpenSettings: () => void;
/** BCF-Themen-Panel öffnen (`revealPanel`); ohne diese Funktion entfällt der Menüpunkt. */
onOpenBcf?: () => void;
}
/** Menüleiste (Bearbeiten/Ansicht/Fenster) — sitzt in der TopBar neben der Wortmarke. */
@@ -66,6 +68,7 @@ export function AppMenuBar({
resourcesOpen,
onToggleResources,
onOpenSettings,
onOpenBcf,
}: AppMenuBarProps) {
const fileItems: DropdownItem[] = [
{ label: t("file.new"), onSelect: onNewProject },
@@ -132,6 +135,7 @@ export function AppMenuBar({
active: resourcesOpen,
},
{ divider: true },
...(onOpenBcf ? [{ label: t("nav.bcf"), onSelect: onOpenBcf }] : []),
{ label: t("menu.window.settings"), onSelect: onOpenSettings },
];