Merge [B5][B4][70] IFC: eBKP-H-Hauptgruppen bzw. Modell-Ebenen als Klassifikation (Option), SIA-416-Zonen, Geschoss-GF/NGF; Import liest Klassifikation und Zonen
Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
15 files changed
+945
-16
No files matched your search
+2
-2
@@ -4036,8 +4036,8 @@ export default function App() {
|
||||
<ExportSaveDialog
|
||||
initialFormat={exportSaveFormat}
|
||||
baseName={projectFileName()}
|
||||
onSave={(fmt, filename) => {
|
||||
runExport(fmt, filename);
|
||||
onSave={(fmt, filename, ifcOptions) => {
|
||||
runExport(fmt, filename, ifcOptions);
|
||||
setExportSaveFormat(null);
|
||||
}}
|
||||
onClose={() => setExportSaveFormat(null)}
|
||||
|
||||
+3
-1
@@ -9,6 +9,7 @@
|
||||
// json = render2d-Szene (planToRenderScene)
|
||||
// dossier-cli <projekt.obp> section <Name> [--out schnitt.svg] (braucht render3d-WASM)
|
||||
// dossier-cli <projekt.obp> elevation <Name> [--out ansicht.svg]
|
||||
// dossier-cli <projekt.obp> ifc [--ebkph] [--ebenen] (IFC mit eBKP-H-Hauptgruppen bzw. Modell-Ebenen als Klassifikation)
|
||||
// dossier-cli <projekt.obp> dxf [--binary] [--scale 100] [--dim-unit cm] [--layout]|dwg|ifc|step|obj|stl|glb|gltf|schedule|kennzahlen|sun [--level EG] [--out datei]
|
||||
// glb/gltf = glTF 2.0 (Y-up, Meter, Geschoss als Eltern; --flat ohne Geschoss-Knoten)
|
||||
// dossier-cli convert <eingabe> <ausgabe> [--cmd "befehl"]… Format nach Endung: dxf/dwg/ifc/obp → obp-Import,
|
||||
@@ -588,7 +589,8 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
}
|
||||
case "ifc":
|
||||
await loadFileio();
|
||||
out(args, exportIfcSpf(project), `${project.name || "projekt"}.ifc`);
|
||||
// --ebkph: eBKP-H-Hauptgruppen je Bauteilart; --ebenen: Ebene (categoryCode) des Modells als Klassifikation.
|
||||
out(args, exportIfcSpf(project, { ebkph: args.flags.has("ebkph"), layerCodes: args.flags.has("ebenen") }), `${project.name || "projekt"}.ifc`);
|
||||
return 0;
|
||||
case "obj":
|
||||
await loadFileio();
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
// IFC für die Schweizer Praxis ([B5], 28.10.): Klassifikation (eBKP-H-Hauptgruppen, Ebene des Modells),
|
||||
// SIA-416-Zonen und Geschoss-Kennwerte; Rundreise Export → Import und Prüfung mit ifcopenshell.
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import "../engine/fileioWasm.setup";
|
||||
import { exportIfcSpf } from "./exportIfc";
|
||||
import { EBKPH_GROUPS, ebkphGroup, layerClassification } from "./ifcClassification";
|
||||
import { readIfcElements } from "../io/ifcElements";
|
||||
import { classificationSuffix, ifcToImportedMeshes, readIfc } from "../io/ifcImport";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import type { Project, Room } from "../model/types";
|
||||
|
||||
const hasIfcOpenShell = spawnSync("python3", ["-c", "import ifcopenshell, ifcopenshell.util.classification, ifcopenshell.validate, _pytest"]).status === 0;
|
||||
|
||||
const lines = (ifc: string, ty: string): string[] => ifc.split("\n").filter((l) => new RegExp(`^#\\d+=${ty}\\(`).test(l));
|
||||
|
||||
/** Demo-Haus mit Räumen in mehreren SIA-Kategorien (zwei im EG, einer im OG). */
|
||||
function houseWithRooms(): Project {
|
||||
const base = sampleProject.rooms![0];
|
||||
const at = (id: string, floorId: string, siaCategory: Room["siaCategory"], dx: number): Room => ({
|
||||
...base,
|
||||
id,
|
||||
floorId,
|
||||
siaCategory,
|
||||
name: id,
|
||||
boundary: base.boundary.map((p) => ({ x: p.x + dx, y: p.y })),
|
||||
});
|
||||
return {
|
||||
...sampleProject,
|
||||
rooms: [base, at("R2", "eg", "HNF", 6), at("R3", "eg", "VF", 12), at("R4", "og", "NNF", 0)],
|
||||
};
|
||||
}
|
||||
|
||||
describe("eBKP-H-Standardzuordnung", () => {
|
||||
it("nur gesicherte Hauptgruppen, Tür und Raum bleiben unklassifiziert", () => {
|
||||
expect(Object.keys(EBKPH_GROUPS)).toEqual(["C", "E", "F"]);
|
||||
expect(ebkphGroup("wall")).toEqual({ code: "C", name: "Konstruktion Gebäude" });
|
||||
expect(ebkphGroup("slab")?.code).toBe("C");
|
||||
expect(ebkphGroup("column")?.code).toBe("C");
|
||||
expect(ebkphGroup("stair")?.code).toBe("C");
|
||||
expect(ebkphGroup("roof")).toEqual({ code: "F", name: "Bedachung Gebäude" });
|
||||
expect(ebkphGroup("window")).toEqual({ code: "E", name: "Äussere Wandbekleidung Gebäude" });
|
||||
expect(ebkphGroup("door")).toBeNull();
|
||||
expect(ebkphGroup("space")).toBeNull();
|
||||
});
|
||||
|
||||
it("Ebene: Name aus dem Ebenenbaum, unbekannter Code bleibt Code, ohne Code nichts", () => {
|
||||
expect(layerClassification(sampleProject, "20")?.code).toBe("20");
|
||||
expect(layerClassification(sampleProject, "25")?.name).toBe("Stützen"); // Unterkategorie
|
||||
expect(layerClassification(sampleProject, "777")).toEqual({ code: "777", name: "777" });
|
||||
expect(layerClassification(sampleProject, undefined)).toBeNull();
|
||||
expect(layerClassification(sampleProject, " ")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("IFC-Export: Zonen und Geschoss-Kennwerte (SIA 416)", () => {
|
||||
it("je Kategorie eine IfcZone mit ihren Räumen, Kategorie und Fläche als Eigenschaft", () => {
|
||||
const ifc = exportIfcSpf(houseWithRooms());
|
||||
// HNF (R1, R2), VF (R3), NNF (R4) → 3 Zonen; 4 Räume in 3 Zuordnungen.
|
||||
const zones = lines(ifc, "IFCZONE");
|
||||
expect(zones).toHaveLength(3);
|
||||
expect(zones.map((l) => l.match(/,'(HNF|NNF|VF)',\$,\$,/)?.[1]).sort()).toEqual(["HNF", "NNF", "VF"]);
|
||||
expect(lines(ifc, "IFCRELASSIGNSTOGROUP")).toHaveLength(3);
|
||||
expect(ifc).toContain("'CH_Zone'");
|
||||
expect(ifc).toContain("'CH_Qto_SIA416'");
|
||||
// Ohne Option keine Klassifikation.
|
||||
expect(lines(ifc, "IFCCLASSIFICATION")).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("ohne Räume keine Zonen und keine Geschoss-Mengen", () => {
|
||||
const ifc = exportIfcSpf({ ...sampleProject, rooms: [] });
|
||||
expect(lines(ifc, "IFCZONE")).toHaveLength(0);
|
||||
expect(ifc).not.toContain("Qto_BuildingStoreyBaseQuantities");
|
||||
});
|
||||
|
||||
it("GUIDs der Zonen und der übrigen Bauteile bleiben stabil (zweimal exportiert gleich)", () => {
|
||||
const a = exportIfcSpf(houseWithRooms());
|
||||
const b = exportIfcSpf(houseWithRooms());
|
||||
const guids = (t: string) => [...t.matchAll(/=IFC[A-Z]+\('([0-9A-Za-z_$]{22})'/g)].map((m) => m[1]);
|
||||
// Zeitstempel im Kopf/OwnerHistory ändern sich nicht innerhalb derselben Sekunde zuverlässig → nur GUIDs.
|
||||
expect(guids(a)).toEqual(guids(b));
|
||||
expect(new Set(guids(a)).size).toBe(guids(a).length);
|
||||
});
|
||||
});
|
||||
|
||||
describe("IFC-Export: Klassifikation", () => {
|
||||
it("eBKP-H: ein System, je Hauptgruppe eine Referenz und eine Beziehung; Türen und Räume ohne", () => {
|
||||
const ifc = exportIfcSpf(houseWithRooms(), { ebkph: true });
|
||||
const sys = lines(ifc, "IFCCLASSIFICATION");
|
||||
expect(sys).toHaveLength(1);
|
||||
expect(sys[0]).toContain("'SN 506 511:2020'");
|
||||
expect(sys[0]).toContain("'eBKP-H'");
|
||||
const refs = lines(ifc, "IFCCLASSIFICATIONREFERENCE");
|
||||
// C (Wand, Decke, Treppe), F (Dach), E (Fenster) — Stützen hat das Demo-Haus nicht.
|
||||
expect(refs.map((l) => l.match(/^#\d+=IFCCLASSIFICATIONREFERENCE\(\$,'(\w)'/)![1]).sort()).toEqual(["C", "E", "F"]);
|
||||
expect(lines(ifc, "IFCRELASSOCIATESCLASSIFICATION")).toHaveLength(3);
|
||||
});
|
||||
|
||||
it("Ebene des Modells als eigenes System, beide Systeme zusammen möglich", () => {
|
||||
const ifc = exportIfcSpf(houseWithRooms(), { layerCodes: true, ebkph: true });
|
||||
expect(lines(ifc, "IFCCLASSIFICATION")).toHaveLength(2);
|
||||
expect(ifc).toContain("'Dossier-Ebenen'");
|
||||
const codes = lines(ifc, "IFCCLASSIFICATIONREFERENCE").map((l) => l.match(/^#\d+=IFCCLASSIFICATIONREFERENCE\(\$,'(\w+)'/)![1]);
|
||||
// Wände 20, Decke 30, Dach 31, Treppe 40, Türen/Fenster 21, Räume 60 + eBKP-H C, E, F.
|
||||
for (const c of ["20", "21", "30", "31", "40", "60", "C", "E", "F"]) expect(codes, c).toContain(c);
|
||||
});
|
||||
|
||||
it("ohne Bauteile (leeres Projekt) kein leeres System", () => {
|
||||
const ifc = exportIfcSpf({ ...sampleProject, walls: [], openings: [], ceilings: [], roofs: [], stairs: [], rooms: [], columns: [], extrudedSolids: [] }, { ebkph: true, layerCodes: true });
|
||||
expect(lines(ifc, "IFCCLASSIFICATION")).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Rundreise Export → Import", () => {
|
||||
it("Klassifikation kommt an Bauteilen und am Mesh-Rest wieder an", async () => {
|
||||
const ifc = exportIfcSpf(houseWithRooms(), { ebkph: true, layerCodes: true });
|
||||
const bytes = new TextEncoder().encode(ifc);
|
||||
const { products, elements } = await readIfcElements(bytes);
|
||||
const wall = elements.walls[0];
|
||||
expect(wall.classifications?.map((c) => `${c.system}:${c.code}`).sort()).toEqual(["Dossier-Ebenen:20", "eBKP-H:C"]);
|
||||
expect(wall.classifications?.find((c) => c.system === "eBKP-H")?.name).toBe("Konstruktion Gebäude");
|
||||
const window = elements.openings.find((o) => o.kind === "window")!;
|
||||
expect(window.classifications?.map((c) => `${c.system}:${c.code}`).sort()).toEqual(["Dossier-Ebenen:21", "eBKP-H:E"]);
|
||||
const door = elements.openings.find((o) => o.kind === "door")!;
|
||||
expect(door.classifications?.map((c) => c.system)).toEqual(["Dossier-Ebenen"]);
|
||||
// Dach bleibt Mesh, trägt aber seine Klassifikation.
|
||||
const roof = products.find((p) => p.ifcClass === "IfcRoof")!;
|
||||
expect(roof.classifications?.map((c) => c.code).sort()).toEqual(["31", "F"]);
|
||||
// Räume: Kategorie bleibt (auch über die Zone).
|
||||
expect(elements.spaces.map((s) => s.sia).sort()).toEqual(["HNF", "HNF", "NNF", "VF"]);
|
||||
});
|
||||
|
||||
it("Mesh-Import: Klassifikation im Namen des Kontext-Objekts", async () => {
|
||||
const ifc = exportIfcSpf(sampleProject, { ebkph: true });
|
||||
const { products } = await readIfc(new TextEncoder().encode(ifc));
|
||||
expect(products.find((p) => p.ifcClass === "IfcRoof")?.classifications?.[0]).toMatchObject({ system: "eBKP-H", code: "F" });
|
||||
const roof = ifcToImportedMeshes(products, "haus.ifc", { group: "product" }).find((m) => m.layer === "IfcRoof")!;
|
||||
expect(roof.name).toMatch(/ \[eBKP-H F\]$/);
|
||||
expect(classificationSuffix(undefined)).toBe("");
|
||||
expect(classificationSuffix([{ system: "", code: "214", name: null }])).toBe(" [214]");
|
||||
});
|
||||
});
|
||||
|
||||
describe.skipIf(!hasIfcOpenShell)("ifcopenshell", () => {
|
||||
const PY = `
|
||||
import json, sys
|
||||
import ifcopenshell, ifcopenshell.util.classification as uc, ifcopenshell.util.element as ue
|
||||
m = ifcopenshell.open(sys.argv[1])
|
||||
out = {"classes": {}, "zones": {}, "storeys": {}}
|
||||
for e in m.by_type("IfcProduct"):
|
||||
refs = uc.get_references(e)
|
||||
if refs:
|
||||
out["classes"].setdefault(e.is_a(), []).extend(sorted(f"{uc.get_classification(r).Name}:{r.Identification}" for r in refs))
|
||||
for z in m.by_type("IfcZone"):
|
||||
members = [a.is_a() for rel in z.IsGroupedBy for a in rel.RelatedObjects]
|
||||
psets = ue.get_psets(z)
|
||||
out["zones"][z.Name] = {"members": members, "sia": psets["CH_Zone"]["SIA416"], "area": psets["CH_Qto_SIA416"]["NetFloorArea"]}
|
||||
for s in m.by_type("IfcBuildingStorey"):
|
||||
out["storeys"][s.Name] = ue.get_psets(s, qtos_only=True)
|
||||
print(json.dumps(out))
|
||||
`;
|
||||
const run = (name: string, ifc: string) => {
|
||||
const dir = mkdtempSync(join(tmpdir(), "dossier-ifc-cls-"));
|
||||
const file = join(dir, `${name}.ifc`);
|
||||
writeFileSync(file, ifc);
|
||||
const r = spawnSync("python3", ["-c", PY, file], { encoding: "utf8", timeout: 120_000 });
|
||||
expect(r.status, r.stderr).toBe(0);
|
||||
const v = spawnSync("python3", ["scripts/validate-ifc.py", file], { encoding: "utf8", timeout: 180_000 });
|
||||
return { read: JSON.parse(r.stdout), valid: { status: v.status, out: `${v.stdout}${v.stderr}` } };
|
||||
};
|
||||
|
||||
it("liest Klassifikation, Zonen und Geschoss-Mengen; 0 Befunde", () => {
|
||||
const { read, valid } = run("klassifiziert", exportIfcSpf(houseWithRooms(), { ebkph: true, layerCodes: true }));
|
||||
expect(valid.out).toMatch(/ 0 Befunde/);
|
||||
expect(valid.status).toBe(0);
|
||||
expect(read.classes.IfcWall).toContain("eBKP-H:C");
|
||||
expect(read.classes.IfcWall).toContain("Dossier-Ebenen:20");
|
||||
expect(read.classes.IfcRoof).toContain("eBKP-H:F");
|
||||
expect(read.classes.IfcWindow).toContain("eBKP-H:E");
|
||||
expect(read.classes.IfcDoor).not.toContain("eBKP-H:E");
|
||||
expect(Object.keys(read.zones).sort()).toEqual(["HNF", "NNF", "VF"]);
|
||||
expect(read.zones.HNF.members).toEqual(["IfcSpace", "IfcSpace"]);
|
||||
expect(read.zones.HNF.sia).toBe("HNF");
|
||||
// Zwei gleich grosse Räume: doppelte Nettofläche des Einzelraums.
|
||||
expect(read.zones.HNF.area).toBeCloseTo(read.zones.VF.area * 2, 6);
|
||||
const eg = read.storeys["Erdgeschoss"] ?? Object.values(read.storeys)[0];
|
||||
expect(eg.Qto_BuildingStoreyBaseQuantities.GrossFloorArea).toBeGreaterThan(0);
|
||||
expect(eg.CH_Qto_SIA416.GF).toBeCloseTo(eg.Qto_BuildingStoreyBaseQuantities.GrossFloorArea, 9);
|
||||
}, 300_000);
|
||||
|
||||
it("Standardexport (ohne Option) mit Zonen: 0 Befunde", () => {
|
||||
const { valid } = run("standard", exportIfcSpf(houseWithRooms()));
|
||||
expect(valid.out).toMatch(/ 0 Befunde/);
|
||||
expect(valid.status).toBe(0);
|
||||
}, 300_000);
|
||||
});
|
||||
+119
-1
@@ -66,6 +66,18 @@
|
||||
// IsExternal beim Dach und bei SIA-416-AGF-Räumen, Glasanteil der Glastür). Kein U-Wert,
|
||||
// keine Tragfunktion: dafür hat das Modell keine Felder.
|
||||
//
|
||||
// Schweizer Praxis ([B5], 28.10.):
|
||||
// • Zonen: je vorkommender SIA-416-Kategorie (HNF, NNF, VF, FF, KGF, AGF) eine IfcZone mit
|
||||
// IfcRelAssignsToGroup der IfcSpaces, Eigenschaft `CH_Zone.SIA416` und Summe der Nettoflächen
|
||||
// (`CH_Qto_SIA416.NetFloorArea`). Immer dabei, sobald Räume da sind.
|
||||
// • Geschoss-Kennwerte: je Geschoss mit Räumen `Qto_BuildingStoreyBaseQuantities` (GrossFloorArea = GF,
|
||||
// NetFloorArea = NGF nach SIA 416) und `CH_Qto_SIA416` mit allen Blatt-/Summenflächen (HNF … GF).
|
||||
// • Klassifikation (Option, `ifcClassification.ts`): eBKP-H-Hauptgruppen je Bauteilart und/oder die
|
||||
// Ebene des Modells als System „Dossier-Ebenen" — IfcClassification + IfcClassificationReference +
|
||||
// IfcRelAssociatesClassification.
|
||||
// • Achsraster: nicht exportiert — das Modell führt keine Raster-Ressource (nur die Regel „grid" der
|
||||
// parametrischen Wände mit festem Abstand).
|
||||
//
|
||||
// GUIDs ([B5]/[10]): deterministisch aus `<Projekt-id>/<Art>/<id>[/<Zusatz>]` über einen
|
||||
// 128-Bit-Hash + Standard-IFC-GUID-Kompression (Zeichensatz 0-9,A-Z,a-z,_,$) — zweimal
|
||||
// exportieren gibt dieselben GlobalIds, BIM-Koordination (Solibri, BIMcollab) erkennt die
|
||||
@@ -108,6 +120,18 @@ import {
|
||||
type Qty,
|
||||
} from "./ifcQuantities";
|
||||
import { roofBaseElevation, roofGeometry } from "../geometry/roof";
|
||||
import { SIA_CATEGORIES, balance, siaLabel, type SiaCategory } from "../geometry/roomArea";
|
||||
import {
|
||||
EBKPH_SYSTEM,
|
||||
LAYER_SYSTEM,
|
||||
ebkphGroup,
|
||||
layerClassification,
|
||||
type ClassificationSystem,
|
||||
type ClassifiedKind,
|
||||
type IfcExportOptions,
|
||||
} from "./ifcClassification";
|
||||
|
||||
export type { IfcExportOptions } from "./ifcClassification";
|
||||
|
||||
/** Deterministische 22-stellige IFC-GUID aus einem Namen (Rust, `ifc_export.rs::ifc_guid`). */
|
||||
export function ifcGuid(name: string): string {
|
||||
@@ -133,6 +157,9 @@ const REC_END_SPACES = 8;
|
||||
const REC_ROOF = 9;
|
||||
const REC_COLUMN = 10;
|
||||
const REC_END_COLUMNS = 11;
|
||||
const REC_CLASSIFICATION = 12;
|
||||
const REC_ZONE = 13;
|
||||
const REC_ATTACH = 14;
|
||||
|
||||
/** Typart in der flachen Kodierung (0 Wand, 1 Decke, 2 Dach). */
|
||||
type TypeKind = 0 | 1 | 2;
|
||||
@@ -402,6 +429,26 @@ class FlatIfc {
|
||||
this.nums.push(REC_END_COLUMNS);
|
||||
}
|
||||
|
||||
/** Zone (IfcZone) mit den Räumen `spaceIds`; `key` ergibt die dauerhafte GUID. */
|
||||
zone(key: string, name: string, longName: string, spaceIds: readonly string[], psets: PsetIn[]): void {
|
||||
this.nums.push(REC_ZONE, this.str(key), this.str(name), this.str(longName), spaceIds.length);
|
||||
for (const id of spaceIds) this.nums.push(this.str(id));
|
||||
this.psets(psets);
|
||||
}
|
||||
|
||||
/** Psets/Mengen an ein geschriebenes Bauteil (Schlüssel wie für seine GUID, z. B. `storey/<id>`). */
|
||||
attach(key: string, psets: PsetIn[]): void {
|
||||
this.nums.push(REC_ATTACH, this.str(key));
|
||||
this.psets(psets);
|
||||
}
|
||||
|
||||
/** Ein Klassifikationssystem mit Zuordnungen (Bauteil-Schlüssel → Code, Name der Referenz). */
|
||||
classification(system: ClassificationSystem, refs: readonly { key: string; code: string; name: string }[]): void {
|
||||
if (refs.length === 0) return;
|
||||
this.nums.push(REC_CLASSIFICATION, this.str(system.name), this.str(system.source), this.str(system.edition), refs.length);
|
||||
for (const r of refs) this.nums.push(this.str(r.key), this.str(r.code), this.str(r.name));
|
||||
}
|
||||
|
||||
/** Argumente für die Rust-Bindung: `[Zahlenpuffer, Zeichenketten durch \0 getrennt]`. */
|
||||
args(): [Float64Array, string] {
|
||||
return [new Float64Array(this.nums), this.strings.join("\0")];
|
||||
@@ -569,7 +616,7 @@ function qto(name: string, quantities: readonly Qty[]): PsetIn[] {
|
||||
* File). Kein Datei-IO. Leeres Projekt ⇒ valider Minimal-IFC (Project/Site/Building, kein Crash).
|
||||
* Verlangt das geladene Format-Modul (`await loadFileio()`).
|
||||
*/
|
||||
export function exportIfcSpf(projectIn: Project): string {
|
||||
export function exportIfcSpf(projectIn: Project, options: IfcExportOptions = {}): string {
|
||||
// Georeferenziert exportieren: ist ein Standort-Bezug gesetzt (geoAnchor),
|
||||
// wird die gesamte Geometrie auf die ECHTEN LV95-Weltkoordinaten verschoben,
|
||||
// damit die IFC-Datei in anderer Software lagerichtig sitzt — auch wenn das
|
||||
@@ -603,6 +650,13 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
storeys: floors.map((f, i) => ({ id: f.id, name: f.name, base: storeyBase[i] })),
|
||||
});
|
||||
|
||||
// Klassifikation: je Bauteil, das geschrieben wird, Schlüssel (wie für die GUID), Art und Ebene sammeln;
|
||||
// Rust überspringt Schlüssel ohne geschriebenes Bauteil (degenerierte Wand, Öffnung ohne Körper …).
|
||||
const classified: { key: string; kind: ClassifiedKind; categoryCode: string | undefined }[] = [];
|
||||
const classify = (key: string, kind: ClassifiedKind, categoryCode: string | undefined): void => {
|
||||
classified.push({ key, kind, categoryCode });
|
||||
};
|
||||
|
||||
const componentName = (componentId: string): string =>
|
||||
project.components.find((c) => c.id === componentId)?.name ?? componentId;
|
||||
const typeRef = (
|
||||
@@ -687,6 +741,7 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
if (bands.length === 0) continue; // degenerierte Wand / keine Geometrie
|
||||
const cutouts = cutoutsOf(wall);
|
||||
cutoutsByWallId.set(wall.id, cutouts);
|
||||
classify(`wall/${wall.id}`, "wall", wall.categoryCode);
|
||||
if (!bandsMatchOpenings(wall, bands, cutouts)) {
|
||||
meshWalls.push({ wall, bands: bandsByWallId.get(wall.id)! });
|
||||
continue;
|
||||
@@ -761,6 +816,7 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
if (ceiling.outline.length < 3) continue;
|
||||
const { zBottom, zTop } = ceilingVerticalExtent(project, ceiling);
|
||||
const structure = structureOf(ceiling.floorId);
|
||||
classify(`slab/${ceiling.id}`, "slab", ceiling.categoryCode);
|
||||
let name: string = ceiling.id;
|
||||
let ty: TypeRefIn | null = null;
|
||||
const psets: PsetIn[] = [];
|
||||
@@ -792,6 +848,7 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
const depth = c.zTop - c.zBottom;
|
||||
if (!(depth > 1e-6)) continue;
|
||||
const isDoor = opening.kind === "door";
|
||||
classify(`fill/${opening.id}`, isDoor ? "door" : "window", opening.categoryCode);
|
||||
const props: PropIn[] = [];
|
||||
let psetName: string;
|
||||
if (isDoor) {
|
||||
@@ -829,6 +886,7 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
if (footprint.length < 3) continue;
|
||||
const { zBottom, zTop } = stairVerticalExtent(project, stair);
|
||||
const structure = structureOf(stair.floorId);
|
||||
classify(`stair/${stair.id}`, "stair", stair.categoryCode);
|
||||
const predefined = stair.shape === "straight" ? "STRAIGHT_RUN_STAIR" : stair.shape === "spiral" ? "SPIRAL_STAIR" : "QUARTER_TURN_STAIR";
|
||||
flat.stair(structure, stair.id, predefined, footprint, zBottom - baseOf(structure), zTop - zBottom, stairParts(project, stair, baseOf(structure)));
|
||||
}
|
||||
@@ -848,6 +906,7 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
// Geschoss AGGREGIERT (IfcRelAggregates), nicht enthalten. Dazu Basismengen
|
||||
// (Qto_SpaceBaseQuantities), die SIA-416-Kategorie als Eigenschaft und Pset_SpaceCommon
|
||||
// (AGF = Aussengeschossfläche ⇒ aussen, alles andere innen).
|
||||
const roomAreas: { id: string; floorId: string; category: SiaCategory; area: number }[] = [];
|
||||
for (const room of project.rooms ?? []) {
|
||||
if (room.boundary.length < 3) continue;
|
||||
const structure = structureOf(room.floorId);
|
||||
@@ -855,6 +914,8 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
const height = floor?.floorHeight && floor.floorHeight > 0 ? floor.floorHeight : 2.5;
|
||||
const external = room.siaCategory === "AGF";
|
||||
const area = evaluateRoom(room.boundary, room.siaCategory);
|
||||
roomAreas.push({ id: room.id, floorId: room.floorId, category: room.siaCategory, area: area.netArea });
|
||||
classify(`space/${room.id}`, "space", room.categoryCode);
|
||||
const common: PropIn[] = [];
|
||||
if (room.stamp?.number) common.push(identifier("Reference", room.stamp.number));
|
||||
common.push({ name: "IsExternal", bool: external });
|
||||
@@ -874,6 +935,41 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
}
|
||||
flat.endSpaces();
|
||||
|
||||
// SIA 416 ([70], [B5]): je vorkommender Kategorie eine IfcZone mit den Räumen. Kategorie als Eigenschaft
|
||||
// (`CH_Zone.SIA416`, die der Import wieder liest), Summe der Nettoflächen als Menge.
|
||||
for (const cat of SIA_CATEGORIES) {
|
||||
const members = roomAreas.filter((r) => r.category === cat);
|
||||
if (members.length === 0) continue;
|
||||
const net = members.reduce((a, r) => a + r.area, 0);
|
||||
flat.zone(
|
||||
`sia416/${cat}`,
|
||||
cat,
|
||||
siaLabel(cat),
|
||||
members.map((r) => r.id),
|
||||
[
|
||||
{ name: "CH_Zone", props: [identifier("SIA416", cat)] },
|
||||
{ name: "CH_Qto_SIA416", props: [{ name: "NetFloorArea", area: Math.max(0, net) }] },
|
||||
],
|
||||
);
|
||||
}
|
||||
// Geschoss-Kennwerte: GF/NGF als Basismenge des IfcBuildingStorey, alle SIA-416-Flächen als CH_Qto_SIA416.
|
||||
for (const floor of floors) {
|
||||
const rooms = roomAreas.filter((r) => r.floorId === floor.id);
|
||||
if (rooms.length === 0) continue;
|
||||
const bal = balance(rooms.map((r) => ({ category: r.category, area: r.area })));
|
||||
const keys = ["HNF", "NNF", "NF", "VF", "FF", "NGF", "KGF", "AGF", "GF"] as const;
|
||||
flat.attach(`storey/${floor.id}`, [
|
||||
{
|
||||
name: "Qto_BuildingStoreyBaseQuantities",
|
||||
props: [
|
||||
{ name: "GrossFloorArea", area: Math.max(0, bal.byKey.GF) },
|
||||
{ name: "NetFloorArea", area: Math.max(0, bal.byKey.NGF) },
|
||||
],
|
||||
},
|
||||
{ name: "CH_Qto_SIA416", props: keys.map((k): PropIn => ({ name: k, area: Math.max(0, bal.byKey[k]) })) },
|
||||
]);
|
||||
}
|
||||
|
||||
// ── Dächer → IfcRoof ───────────────────────────────────────────────────
|
||||
// Dieselben geschlossenen Schicht-Meshes wie das 3D (`emitRoofs`: Dachflächen je Schicht,
|
||||
// an First/Grat gehrt), zu EINEM Face-Set je Dach vereint. Modell-Koordinaten sind bereits
|
||||
@@ -881,6 +977,7 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
// positiv ist — nur dann ist das Face-Set als geschlossen markiert.
|
||||
for (const roof of project.roofs ?? []) {
|
||||
const structure = structureOf(roof.floorId);
|
||||
classify(`roof/${roof.id}`, "roof", roof.categoryCode);
|
||||
const positions: number[] = [];
|
||||
const indices: number[] = [];
|
||||
for (const mesh of emitRoofs({ ...project, roofs: [roof] })) {
|
||||
@@ -928,6 +1025,7 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
const { zBottom, zTop } = columnVerticalExtent(project, col);
|
||||
if (!(zTop > zBottom)) continue;
|
||||
const structure = structureOf(col.floorId);
|
||||
classify(`column/${col.id}`, "column", col.categoryCode);
|
||||
const label = columnLabel(col);
|
||||
flat.column({
|
||||
structure,
|
||||
@@ -942,6 +1040,26 @@ export function exportIfcSpf(projectIn: Project): string {
|
||||
}
|
||||
flat.endColumns();
|
||||
|
||||
// ── Klassifikation (Optionen), am Ende: alle Bauteile sind geschrieben ──────────────
|
||||
if (options.ebkph) {
|
||||
flat.classification(
|
||||
EBKPH_SYSTEM,
|
||||
classified.flatMap((c) => {
|
||||
const g = ebkphGroup(c.kind);
|
||||
return g ? [{ key: c.key, code: g.code, name: g.name }] : [];
|
||||
}),
|
||||
);
|
||||
}
|
||||
if (options.layerCodes) {
|
||||
flat.classification(
|
||||
LAYER_SYSTEM,
|
||||
classified.flatMap((c) => {
|
||||
const l = layerClassification(project, c.categoryCode);
|
||||
return l ? [{ key: c.key, code: l.code, name: l.name }] : [];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const m = fileio();
|
||||
const [buf, strings] = flat.args();
|
||||
const text = m.export_ifc_flat(buf, strings);
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
// Klassifikation im IFC-Export ([B5], 28.10.): welche Klassifikationssysteme das Modell hergibt und die
|
||||
// Standard-Zuordnung nach eBKP-H. Reine Tabellen/Funktionen, kein IFC-Schreiben (das macht Rust über
|
||||
// den Datensatz CLASSIFICATION, `ifc_export.rs`).
|
||||
//
|
||||
// Was das Modell führt: KEINEN eBKP-H-/BKP-Code. `categoryCode` an Bauteilen ist die Grafik-Ebene
|
||||
// („20" Wände, „30" Decken …, `LayerCategory`), kein Kostenschlüssel. Daher zwei getrennte Wege:
|
||||
// • `layerCodes` — die Ebene des Modells als eigenes System „Dossier-Ebenen" (Code = `categoryCode`,
|
||||
// Name = Ebenenname). Stammt aus dem Modell, behauptet keinen Standard.
|
||||
// • `ebkph` — Standardzuordnung je Bauteilart auf eBKP-H-HAUPTGRUPPEN (siehe `EBKPH_GROUPS`).
|
||||
//
|
||||
// Quelle eBKP-H: CRB, „eBKP-H Elementbasierter Baukostenplan Hochbau", SN 506 511 (Ausgabe 2020).
|
||||
// Gesichert sind nur die Hauptgruppen-Buchstaben und ihre Namen (A Grundstück, B Vorbereitung,
|
||||
// C Konstruktion Gebäude, D Technik Gebäude, E Äussere Wandbekleidung Gebäude, F Bedachung Gebäude,
|
||||
// G Ausbau Gebäude, H Nutzungsspezifische Anlagen Gebäude, I Umgebung Gebäude, J Ausstattung,
|
||||
// V Planungsleistungen, W Nebenkosten, Y Reserve, Z Mehrwertsteuer). Keine Untergruppen (C01 …):
|
||||
// die hängen von Konstruktionsart und Lage ab, die das Modell nicht trägt.
|
||||
//
|
||||
// Die Zuordnung ist deshalb bewusst grob und ein VORSCHLAG für die Kostenplanung, kein Ersatz für
|
||||
// die Einordnung durch die Kostenplanerin:
|
||||
// Wand → C (Wandkonstruktion; Aussen-/Innenbekleidung E/G und nichttragende Innenwände
|
||||
// unterscheidet das Modell nicht — dafür fehlt ein Feld am Wandtyp)
|
||||
// Decke → C (Deckenkonstruktion; Bodenbeläge/Unterdecken wären G)
|
||||
// Stütze → C
|
||||
// Treppe → C (Treppenkonstruktion; Belag/Geländer wären G)
|
||||
// Dach → F (Dachaufbau mit Eindeckung/Abdichtung; die reine Tragkonstruktion wäre C)
|
||||
// Fenster → E (Fenster der Gebäudehülle)
|
||||
// Tür → keine (Aussentür E, Innentür G — nicht unterscheidbar, daher nicht geraten)
|
||||
// Raum → keine (Räume sind Flächen, kein Bauteil; sie haben die SIA-416-Zonen)
|
||||
|
||||
import type { LayerCategory, Project } from "../model/types";
|
||||
|
||||
/** Optionen der Klassifikation im IFC-Export. */
|
||||
export interface IfcExportOptions {
|
||||
/** eBKP-H-Hauptgruppen je Bauteilart (Standardzuordnung, s. Dateikopf). */
|
||||
ebkph?: boolean;
|
||||
/** `categoryCode` (Ebene) des Modells als System „Dossier-Ebenen". */
|
||||
layerCodes?: boolean;
|
||||
}
|
||||
|
||||
/** Bauteilarten, die klassifiziert werden können. */
|
||||
export type ClassifiedKind = "wall" | "slab" | "roof" | "column" | "stair" | "window" | "door" | "space";
|
||||
|
||||
/** Ein Klassifikationssystem für IfcClassification. */
|
||||
export interface ClassificationSystem {
|
||||
name: string;
|
||||
source: string;
|
||||
/** Ausgabe; leer = keine Angabe. */
|
||||
edition: string;
|
||||
}
|
||||
|
||||
export const EBKPH_SYSTEM: ClassificationSystem = {
|
||||
name: "eBKP-H",
|
||||
source: "CRB Schweizerische Zentralstelle für Baurationalisierung",
|
||||
edition: "SN 506 511:2020",
|
||||
};
|
||||
|
||||
export const LAYER_SYSTEM: ClassificationSystem = {
|
||||
name: "Dossier-Ebenen",
|
||||
source: "Dossier",
|
||||
edition: "",
|
||||
};
|
||||
|
||||
/** Gesicherte eBKP-H-Hauptgruppen (nur die hier verwendeten). */
|
||||
export const EBKPH_GROUPS = {
|
||||
C: "Konstruktion Gebäude",
|
||||
E: "Äussere Wandbekleidung Gebäude",
|
||||
F: "Bedachung Gebäude",
|
||||
} as const;
|
||||
|
||||
const EBKPH_BY_KIND: Partial<Record<ClassifiedKind, keyof typeof EBKPH_GROUPS>> = {
|
||||
wall: "C",
|
||||
slab: "C",
|
||||
column: "C",
|
||||
stair: "C",
|
||||
roof: "F",
|
||||
window: "E",
|
||||
};
|
||||
|
||||
/** eBKP-H-Hauptgruppe zur Bauteilart, oder `null` (Tür, Raum: nicht eindeutig). */
|
||||
export function ebkphGroup(kind: ClassifiedKind): { code: string; name: string } | null {
|
||||
const code = EBKPH_BY_KIND[kind];
|
||||
return code ? { code, name: EBKPH_GROUPS[code] } : null;
|
||||
}
|
||||
|
||||
function findLayer(list: readonly LayerCategory[], code: string): LayerCategory | undefined {
|
||||
for (const c of list) {
|
||||
if (c.code === code) return c;
|
||||
const sub = c.children ? findLayer(c.children, code) : undefined;
|
||||
if (sub) return sub;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/** Ebene (Code + Name) eines Bauteils; ohne Code `null`, ohne bekannte Ebene der Code als Name. */
|
||||
export function layerClassification(project: Project, categoryCode: string | undefined): { code: string; name: string } | null {
|
||||
const code = categoryCode?.trim();
|
||||
if (!code) return null;
|
||||
return { code, name: findLayer(project.layers, code)?.name ?? code };
|
||||
}
|
||||
@@ -1783,6 +1783,11 @@ export const de = {
|
||||
"exportSave.format": "Format",
|
||||
"exportSave.filename": "Dateiname",
|
||||
"exportSave.locationNote": "Wird in den Standard-Download-Ordner gespeichert.",
|
||||
"exportSave.ifc.ebkph": "eBKP-H-Klassifikation hinzufügen",
|
||||
"exportSave.ifc.ebkphHint": "Hauptgruppe je Bauteilart: Wand, Decke, Stütze, Treppe = C, Dach = F, Fenster = E; Türen bleiben ohne. Vorschlag für die Kostenplanung (CRB, eBKP-H, SN 506 511) — Aussen-/Innenwände und Untergruppen unterscheidet das Modell nicht.",
|
||||
"exportSave.ifc.layers": "Ebene (Kategorie-Code) des Modells als Klassifikation",
|
||||
"exportSave.ifc.layersHint": "System «Dossier-Ebenen»: Code und Name der Grafik-Ebene jedes Bauteils (kein Baukostenplan).",
|
||||
"exportSave.ifc.zonesNote": "SIA-416-Zonen (HNF, NNF …) und Geschossflächen sind immer enthalten, sobald Räume vorhanden sind.",
|
||||
"exportSave.fmt.csv": "Bauteilliste (CSV)",
|
||||
"exportSave.fmt.ifc": "IFC (BIM)",
|
||||
"exportSave.fmt.obj": "OBJ (3D-Mesh)",
|
||||
@@ -1851,6 +1856,7 @@ export const de = {
|
||||
"ifc.import.truncated": "abgebrochen: zu viele Dreiecke",
|
||||
"ifc.import.elements": "{schema} importiert: {walls} Wände, {openings} Türen/Fenster, {ceilings} Decken, {columns} Stützen, {rooms} Räume, {floors} neue Geschosse; {meshes} Bauteile als Kontext-Meshes",
|
||||
"ifc.import.kept": "{n} Wände/Decken/Stützen/Räume nicht sicher abbildbar, als Mesh übernommen",
|
||||
"ifc.import.classified": "{n} Bauteile mit Klassifikation (eBKP-H …); bei Kontext-Meshes im Namen vermerkt",
|
||||
"ifc.importDialog.title": "IFC importieren",
|
||||
"ifc.importDialog.asMesh": "Als Kontext-Meshes (Standard)",
|
||||
"ifc.importDialog.asMeshHint": "Jedes Bauteil als nicht bearbeitbares Mesh der Kontext-Schicht, wie in der Datei.",
|
||||
|
||||
@@ -1810,6 +1810,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"ifc.import.truncated": "aborted: too many triangles",
|
||||
"ifc.import.elements": "{schema} imported: {walls} walls, {openings} doors/windows, {ceilings} slabs, {columns} columns, {rooms} rooms, {floors} new storeys; {meshes} elements as context meshes",
|
||||
"ifc.import.kept": "{n} walls/slabs/columns/rooms not safely mappable, kept as mesh",
|
||||
"ifc.import.classified": "{n} elements with a classification (eBKP-H …); noted in the name of context meshes",
|
||||
"ifc.importDialog.title": "Import IFC",
|
||||
"ifc.importDialog.asMesh": "As context meshes (default)",
|
||||
"ifc.importDialog.asMeshHint": "Every element as a non-editable mesh on the context layer, as in the file.",
|
||||
@@ -1944,6 +1945,11 @@ export const en: Record<TranslationKey, string> = {
|
||||
"exportSave.format": "Format",
|
||||
"exportSave.filename": "File name",
|
||||
"exportSave.locationNote": "Saved to the default downloads folder.",
|
||||
"exportSave.ifc.ebkph": "Add eBKP-H classification",
|
||||
"exportSave.ifc.ebkphHint": "Main group per element type: wall, slab, column, stair = C, roof = F, window = E; doors stay unclassified. A suggestion for cost planning (CRB, eBKP-H, SN 506 511) — the model does not tell exterior from interior walls or know sub-groups.",
|
||||
"exportSave.ifc.layers": "Model layer (category code) as classification",
|
||||
"exportSave.ifc.layersHint": "System “Dossier-Ebenen”: code and name of each element's graphic layer (not a cost plan).",
|
||||
"exportSave.ifc.zonesNote": "SIA 416 zones (HNF, NNF …) and storey areas are always included when rooms exist.",
|
||||
"exportSave.fmt.csv": "Component schedule (CSV)",
|
||||
"exportSave.fmt.ifc": "IFC (BIM)",
|
||||
"exportSave.fmt.obj": "OBJ (3D mesh)",
|
||||
|
||||
+17
-2
@@ -31,6 +31,7 @@ import {
|
||||
ifcColorHex,
|
||||
ifcToImportedMeshes,
|
||||
readIfcFlat,
|
||||
type IfcClassificationRef,
|
||||
type IfcFlat,
|
||||
type IfcImportReport,
|
||||
type IfcProduct,
|
||||
@@ -54,6 +55,8 @@ interface IfcInfo {
|
||||
color: [number, number, number, number] | null;
|
||||
typeName: string | null;
|
||||
layers: IfcMatLayer[];
|
||||
/** Klassifikationen des Bauteils bzw. seines Typs (eBKP-H, BKP …); fehlt in älteren Rohdaten. */
|
||||
classifications?: IfcClassificationRef[];
|
||||
}
|
||||
|
||||
export interface IfcStoreyData {
|
||||
@@ -153,6 +156,7 @@ export function decodeIfcElements(flat: IfcFlat): IfcElementsData | null {
|
||||
color: e.color,
|
||||
typeName: e.typeName,
|
||||
layers: e.layers ?? [],
|
||||
...(e.classifications?.length ? { classifications: e.classifications } : {}),
|
||||
};
|
||||
const rings = (start: number, count: number): { rings: Vec2[][]; ok: boolean } => {
|
||||
const res: Vec2[][] = [];
|
||||
@@ -249,6 +253,12 @@ export interface IfcElementsSummary {
|
||||
components: number;
|
||||
/** Bauteile als Kontext-Mesh. */
|
||||
meshes: number;
|
||||
/**
|
||||
* Übernommene Bauteile und Meshes mit Klassifikation (eBKP-H …). Das Modell hat an Wand/Decke/Stütze/
|
||||
* Raum kein Klassifikationsfeld: nur die Namen der Kontext-Meshes tragen sie (`[eBKP-H C]`), sonst wird
|
||||
* sie gezählt und gemeldet.
|
||||
*/
|
||||
classified: number;
|
||||
/** Davon Kandidaten, die nicht sicher abbildbar waren. */
|
||||
kept: number;
|
||||
}
|
||||
@@ -290,7 +300,7 @@ export function ifcElementsToProject(
|
||||
const stamp = Date.now().toString(36);
|
||||
const newId = (kind: string) => `ifc-${kind}-${stamp}-${counter++}`;
|
||||
const summary: IfcElementsSummary = {
|
||||
walls: 0, openings: 0, ceilings: 0, columns: 0, rooms: 0, floors: 0, wallTypes: 0, ceilingTypes: 0, components: 0, meshes: 0,
|
||||
walls: 0, openings: 0, ceilings: 0, columns: 0, rooms: 0, floors: 0, wallTypes: 0, ceilingTypes: 0, components: 0, meshes: 0, classified: 0,
|
||||
kept: Object.values(elements.kept).reduce((s, n) => s + n, 0),
|
||||
};
|
||||
|
||||
@@ -544,6 +554,10 @@ export function ifcElementsToProject(
|
||||
summary.columns = columns.length;
|
||||
summary.rooms = rooms.length;
|
||||
summary.meshes = meshes.length;
|
||||
const withClass = (l: readonly IfcInfo[]) => l.filter((e) => e.classifications?.length).length;
|
||||
summary.classified =
|
||||
withClass(elements.walls) + withClass(elements.openings.filter((o) => o.kind !== "hole")) + withClass(elements.slabs) + withClass(elements.columns) + withClass(elements.spaces) +
|
||||
products.filter((p) => p.classifications?.length).length;
|
||||
|
||||
const next: Project = {
|
||||
...project,
|
||||
@@ -570,7 +584,7 @@ export function ifcElementsToProject(
|
||||
export function formatIfcElementsSummary(
|
||||
s: IfcElementsSummary,
|
||||
r: IfcImportReport,
|
||||
tr: (key: "ifc.import.elements" | "ifc.import.kept", vars?: Record<string, string | number>) => string,
|
||||
tr: (key: "ifc.import.elements" | "ifc.import.kept" | "ifc.import.classified", vars?: Record<string, string | number>) => string,
|
||||
): string {
|
||||
const parts = [
|
||||
tr("ifc.import.elements", {
|
||||
@@ -585,5 +599,6 @@ export function formatIfcElementsSummary(
|
||||
}),
|
||||
];
|
||||
if (s.kept) parts.push(tr("ifc.import.kept", { n: s.kept }));
|
||||
if (s.classified) parts.push(tr("ifc.import.classified", { n: s.classified }));
|
||||
return parts.join(" · ");
|
||||
}
|
||||
+24
-1
@@ -21,6 +21,14 @@ import { GENERIC_IMPORT_CATEGORY } from "../model/contextCategories";
|
||||
import type { ImportedMesh } from "../model/types";
|
||||
import { rgbToHex } from "../model/color";
|
||||
|
||||
/** Klassifikation eines Bauteils (IfcClassificationReference), z. B. eBKP-H `C`. */
|
||||
export interface IfcClassificationRef {
|
||||
/** Name des Systems (IfcClassification), z. B. `eBKP-H`; leer, wenn die Datei keines nennt. */
|
||||
system: string;
|
||||
code: string;
|
||||
name: string | null;
|
||||
}
|
||||
|
||||
/** Ein gelesenes IFC-Bauteil. */
|
||||
export interface IfcProduct {
|
||||
globalId: string;
|
||||
@@ -30,6 +38,8 @@ export interface IfcProduct {
|
||||
storey: string | null;
|
||||
/** RGBA 0..1 aus IfcStyledItem/Material, falls vorhanden. */
|
||||
color: [number, number, number, number] | null;
|
||||
/** Klassifikationen (eBKP-H, BKP …); fehlt bei Quellen ohne. */
|
||||
classifications?: IfcClassificationRef[];
|
||||
/** x,y,z in Metern (Z = Höhe). */
|
||||
positions: Float64Array;
|
||||
indices: Uint32Array;
|
||||
@@ -60,6 +70,7 @@ interface RawProduct {
|
||||
name: string | null;
|
||||
storey: string | null;
|
||||
color: [number, number, number, number] | null;
|
||||
classifications?: IfcClassificationRef[];
|
||||
positionCount: number;
|
||||
indexCount: number;
|
||||
}
|
||||
@@ -143,6 +154,7 @@ export function decodeIfc(flat: IfcFlat): { products: IfcProduct[]; report: IfcI
|
||||
name: p.name,
|
||||
storey: p.storey,
|
||||
color: p.color,
|
||||
...(p.classifications?.length ? { classifications: p.classifications } : {}),
|
||||
positions: flat.positions.subarray(po, po + p.positionCount),
|
||||
indices: flat.indices.subarray(io, io + p.indexCount),
|
||||
});
|
||||
@@ -212,6 +224,17 @@ export function geoShift(
|
||||
return nearOrigin ? [-origin.e, -origin.n] : [0, 0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Klassifikation als Namenszusatz des Kontext-Objekts (` [eBKP-H C]`): das Modell hat für Kontext-Meshes
|
||||
* kein eigenes Klassifikationsfeld, der Name ist das einzige freie Feld (im Kontext-Panel sichtbar).
|
||||
* Nur die erste Klassifikation; ohne leer.
|
||||
*/
|
||||
export function classificationSuffix(list: readonly IfcClassificationRef[] | undefined): string {
|
||||
const c = list?.[0];
|
||||
if (!c) return "";
|
||||
return ` [${[c.system, c.code].filter(Boolean).join(" ")}]`;
|
||||
}
|
||||
|
||||
/** Bauteile → Kontext-Meshes (Kategorie „Situation" wie STEP; `layer` = IFC-Klasse). */
|
||||
export function ifcToImportedMeshes(products: IfcProduct[], fileName: string, opts: IfcToMeshesOptions = {}): ImportedMesh[] {
|
||||
const base = fileName.replace(/\.[^.]+$/, "") || "IFC";
|
||||
@@ -239,7 +262,7 @@ export function ifcToImportedMeshes(products: IfcProduct[], fileName: string, op
|
||||
return {
|
||||
id: `imported-ifc-${stamp}-${counter++}`,
|
||||
type: "importedMesh" as const,
|
||||
name: [p.storey, p.name || p.ifcClass].filter(Boolean).join(": "),
|
||||
name: [p.storey, p.name || p.ifcClass].filter(Boolean).join(": ") + classificationSuffix(p.classifications),
|
||||
layer: p.ifcClass,
|
||||
categoryCode: GENERIC_IMPORT_CATEGORY.code,
|
||||
...(color ? { color } : {}),
|
||||
|
||||
@@ -24,7 +24,7 @@ import { isPdfFile, pdfPageToImport, readPdfVectorPage } from "../io/pdfVector";
|
||||
import { planDashLineStyles } from "../io/pdfLineStyles";
|
||||
import type { PdfVectorPage } from "../io/pdfVector";
|
||||
import { exportScheduleCsv } from "../export/exportSchedule";
|
||||
import { exportIfcSpf } from "../export/exportIfc";
|
||||
import { exportIfcSpf, type IfcExportOptions } from "../export/exportIfc";
|
||||
import { loadFileio } from "../engine/fileioWasm";
|
||||
import { exportProjectStep } from "../export/exportStep";
|
||||
import { exportGlb, exportObj, exportStl } from "../export/exportMesh";
|
||||
@@ -587,7 +587,7 @@ export function useProjectFileActions(
|
||||
// Führt den gewählten Direkt-Export (CSV/IFC/OBJ/STL) mit dem im Dialog
|
||||
// gewählten Dateinamen aus. Erzeugung aus dem jeweiligen reinen Kern, Download
|
||||
// über den robusten Helfer.
|
||||
const runExport = (format: ExportSaveFormat, filename: string) => {
|
||||
const runExport = (format: ExportSaveFormat, filename: string, ifcOptions?: IfcExportOptions) => {
|
||||
switch (format) {
|
||||
case "csv":
|
||||
downloadTextFile("" + exportScheduleCsv(project), filename, "text/csv;charset=utf-8;");
|
||||
@@ -595,7 +595,7 @@ export function useProjectFileActions(
|
||||
case "ifc":
|
||||
// IFC schreibt Rust (Format-Modul pkgFileIo, wird beim ersten Export nachgeladen).
|
||||
void loadFileio()
|
||||
.then(() => downloadTextFile(exportIfcSpf(project), filename))
|
||||
.then(() => downloadTextFile(exportIfcSpf(project, ifcOptions), filename))
|
||||
.catch((e) => notify(`${t("ifc.export.failed")}: ${e instanceof Error ? e.message : String(e)}`, "error"));
|
||||
break;
|
||||
case "obj":
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { t } from "../i18n";
|
||||
import { Dropdown } from "./Dropdown";
|
||||
import type { IfcExportOptions } from "../export/ifcClassification";
|
||||
|
||||
/** Direkt-herunterladbare Exportformate (mit Datei-Endung). */
|
||||
export type ExportSaveFormat = "csv" | "ifc" | "obj" | "stl" | "glb" | "step";
|
||||
@@ -29,7 +30,8 @@ export interface ExportSaveDialogProps {
|
||||
initialFormat: ExportSaveFormat;
|
||||
/** Basis-Dateiname OHNE Endung (i. d. R. Projektname). */
|
||||
baseName: string;
|
||||
onSave: (format: ExportSaveFormat, filename: string) => void;
|
||||
/** `ifc`: Klassifikations-Optionen (nur bei Format IFC gesetzt). */
|
||||
onSave: (format: ExportSaveFormat, filename: string, ifc?: IfcExportOptions) => void;
|
||||
onClose: () => void;
|
||||
}
|
||||
|
||||
@@ -59,7 +61,10 @@ export function ExportSaveDialog({
|
||||
const [name, setName] = useState(baseName);
|
||||
|
||||
const filename = withExt(name, EXPORT_FORMAT_EXT[format]);
|
||||
const onConfirm = () => onSave(format, filename);
|
||||
// IFC-Klassifikation (Schweizer Praxis): beides aus, bis die Nutzerin es wählt.
|
||||
const [ebkph, setEbkph] = useState(false);
|
||||
const [layerCodes, setLayerCodes] = useState(false);
|
||||
const onConfirm = () => onSave(format, filename, format === "ifc" ? { ebkph, layerCodes } : undefined);
|
||||
|
||||
return (
|
||||
<div className="imp-overlay" onClick={onClose}>
|
||||
@@ -95,6 +100,22 @@ export function ExportSaveDialog({
|
||||
/>
|
||||
</section>
|
||||
|
||||
{format === "ifc" && (
|
||||
<section className="imp-section">
|
||||
<label className="imp-check">
|
||||
<input type="checkbox" checked={ebkph} onChange={(e) => setEbkph(e.target.checked)} />
|
||||
<span>{t("exportSave.ifc.ebkph")}</span>
|
||||
</label>
|
||||
<div className="imp-note">{t("exportSave.ifc.ebkphHint")}</div>
|
||||
<label className="imp-check">
|
||||
<input type="checkbox" checked={layerCodes} onChange={(e) => setLayerCodes(e.target.checked)} />
|
||||
<span>{t("exportSave.ifc.layers")}</span>
|
||||
</label>
|
||||
<div className="imp-note">{t("exportSave.ifc.layersHint")}</div>
|
||||
<div className="imp-note">{t("exportSave.ifc.zonesNote")}</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section className="imp-section">
|
||||
<div className="imp-section-title">{t("exportSave.filename")}</div>
|
||||
<input
|
||||
|
||||
Reference in new issue
Block a user