Merge [259]
This commit is contained in:
17 files changed
+934
-116
No files matched your search
+2
-2
@@ -21,7 +21,7 @@
|
||||
// --model-view <Name> wählt eine Modelldarstellung (eigene Stufe oder grob/mittel/fein) [173]
|
||||
// --hide <Code|Name,…> blendet Klassen aus (z. B. --hide "Schatten,Auto-Bemassung") [180]
|
||||
// --snapshot <Name|id> übernimmt Geschoss, Massstab, Vorlage und Sichtbarkeit eines Ausschnitts [207]
|
||||
// dossier-cli <projekt.obp> ifc [--ebkph] [--ebenen] (IFC mit eBKP-H-Hauptgruppen bzw. Modell-Ebenen als Klassifikation)
|
||||
// dossier-cli <projekt.obp> ifc [--ebkph] [--ebenen] [--kontext] (IFC mit eBKP-H-Hauptgruppen bzw. Modell-Ebenen als Klassifikation; --kontext: Gelände/Nachbarn mitgeben)
|
||||
// --schema 4|2x3: IFC4 (Standard) oder IFC2x3 (Coordination View 2.0)
|
||||
// dossier-cli <projekt.obp> dxf [--binary] [--scale 100] [--dim-unit cm] [--layout]|dwg|ifc|step|obj [--no-mtl]|stl|glb|gltf|schedule [--openings|--elements|--rooms] [--format json|csv|svg|pdf]|kennzahlen [--sia416] [--ivhb] [--nachweis] [--format json|csv|svg|pdf] [--agsf m2] [--gruenflaeche m2] [--agf-basis gf|ngf|nf] [--untergeschosse]|raumprogramm [--import tabelle] [--sheet name|nr] [--mode replace|append] [--tolerance %] [--generate] [--format json|csv|svg|pdf] [--save projekt.obp]|sun [--level EG] [--out datei]
|
||||
// glb/gltf = glTF 2.0 (Y-up, Meter, Geschoss als Eltern; --flat ohne Geschoss-Knoten)
|
||||
@@ -1082,7 +1082,7 @@ async function execute(project: Project, file: string, command: string, rest: st
|
||||
case "ifc":
|
||||
await loadFileio();
|
||||
// --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"), schema: ifcSchemaFlag(args) }), `${exportProjectName(project) || "projekt"}.ifc`);
|
||||
out(args, exportIfcSpf(project, { ebkph: args.flags.has("ebkph"), layerCodes: args.flags.has("ebenen"), context: args.flags.has("kontext"), schema: ifcSchemaFlag(args) }), `${exportProjectName(project) || "projekt"}.ifc`);
|
||||
return 0;
|
||||
case "obj":
|
||||
await loadFileio();
|
||||
|
||||
@@ -49,10 +49,13 @@ describe("IFC-Export: Zonen und Geschoss-Kennwerte (SIA 416)", () => {
|
||||
expect(lines(ifc, "IFCCLASSIFICATION")).toHaveLength(0);
|
||||
});
|
||||
|
||||
it("ohne Räume keine Zonen und keine Geschoss-Mengen", () => {
|
||||
it("ohne Räume keine Zonen; Geschoss-Mengen nur aus der Konstruktionsfläche der Wände ([259])", () => {
|
||||
const ifc = exportIfcSpf({ ...sampleProject, rooms: [] });
|
||||
expect(lines(ifc, "IFCZONE")).toHaveLength(0);
|
||||
expect(ifc).not.toContain("Qto_BuildingStoreyBaseQuantities");
|
||||
expect(ifc).toContain("Qto_BuildingStoreyBaseQuantities");
|
||||
expect(ifc).toMatch(/IFCQUANTITYAREA\('NetFloorArea',\$,\$,0\.0,\$\)/);
|
||||
// Ohne Wände und Räume: gar keine Geschoss-Mengen.
|
||||
expect(exportIfcSpf({ ...sampleProject, rooms: [], walls: [], openings: [] })).not.toContain("Qto_BuildingStoreyBaseQuantities");
|
||||
});
|
||||
|
||||
it("GUIDs der Zonen und der übrigen Bauteile bleiben stabil (zweimal exportiert gleich)", () => {
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
// [259] IFC-Export für Fachplaner (Vorprojekt): alle drei Beispielprojekte gegen ifcopenshell — Schema/Express-Regeln/
|
||||
// Geometrie (`scripts/validate-ifc.py`) und die inhaltliche Prüfung `scripts/check-ifc-fachplaner.py` (räumliche
|
||||
// Struktur, jedes Bauteil genau einmal eingeordnet, Georeferenz lokal + IfcMapConversion EPSG:2056, Öffnungen gefüllt
|
||||
// und im Geschoss des Wirts, Räume mit Mengen/SIA-416-Kategorie, Wandschichten, Mengen ±1 % gegen die Geometrie,
|
||||
// Geschoss-GF mit Konstruktionsfläche, Kontext nur mit Option, keine 2D-Objektbibliothek als 3D-Körper).
|
||||
// Ohne Python/ifcopenshell übersprungen (CI installiert es).
|
||||
|
||||
import { describe, expect, it, vi } 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, ifcGuid, type IfcExportOptions } from "./exportIfc";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { buildWettbewerbSampleProject } from "../model/sampleProjectWettbewerb";
|
||||
import type { Drawing2D, Project } from "../model/types";
|
||||
|
||||
const hasIfcOpenShell = spawnSync("python3", ["-c", "import ifcopenshell, ifcopenshell.validate, ifcopenshell.util.shape, _pytest"]).status === 0;
|
||||
|
||||
function writeIfc(name: string, ifc: string): string {
|
||||
const file = join(mkdtempSync(join(tmpdir(), "dossier-ifc-fp-")), `${name}.ifc`);
|
||||
writeFileSync(file, ifc);
|
||||
return file;
|
||||
}
|
||||
|
||||
interface Check {
|
||||
problems: string[];
|
||||
stats: Record<string, unknown> & { counts: Record<string, number>; context: number; far: number; known: string[]; map?: number[]; storeyQto?: Record<string, Record<string, number>> };
|
||||
}
|
||||
|
||||
/** Beide Prüfskripte; liefert die Kennwerte der inhaltlichen Prüfung. */
|
||||
function check(name: string, ifc: string, flags: string[]): Check {
|
||||
const file = writeIfc(name, ifc);
|
||||
const v = spawnSync("python3", ["scripts/validate-ifc.py", file], { encoding: "utf8", timeout: 400_000 });
|
||||
expect(`${v.stdout}\n${v.stderr}`).toContain(" 0 Befunde");
|
||||
const r = spawnSync("python3", ["scripts/check-ifc-fachplaner.py", file, "--json", ...flags], { encoding: "utf8", timeout: 400_000 });
|
||||
expect(r.stdout, r.stderr).not.toBe("");
|
||||
const out = JSON.parse(r.stdout) as Check;
|
||||
expect(out.problems).toEqual([]);
|
||||
expect(r.status).toBe(0);
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Export mit festem Zeitstempel (Vergleich zweier Dateien). */
|
||||
function exportAt(p: Project, options: IfcExportOptions = {}): string {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(new Date("2026-11-14T10:00:00Z"));
|
||||
try {
|
||||
return exportIfcSpf(p, options);
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
}
|
||||
|
||||
describe.skipIf(!hasIfcOpenShell)("[259] IFC für Fachplaner (ifcopenshell)", { timeout: 900_000 }, () => {
|
||||
it("Musterhaus: Struktur, Mengen, Öffnungen", () => {
|
||||
const c = check("musterhaus", exportIfcSpf(sampleProject), []);
|
||||
expect(c.stats.counts.IfcWall).toBe(sampleProject.walls.length);
|
||||
expect(c.stats.context).toBe(0);
|
||||
});
|
||||
|
||||
it("Wettbewerb: georeferenziert (lokal + IfcMapConversion, ±0.00 = 441.30), Geschoss-GF mit Konstruktionsfläche", () => {
|
||||
const p = buildWettbewerbSampleProject();
|
||||
const c = check("wettbewerb", exportIfcSpf(p), ["--geo"]);
|
||||
expect(c.stats.far).toBeLessThan(1000);
|
||||
expect(c.stats.map).toEqual([p.geoAnchor!.lv95.e - p.geoAnchor!.model.x, p.geoAnchor!.lv95.n - p.geoAnchor!.model.y, 441.3]);
|
||||
const eg = c.stats.storeyQto!.Erdgeschoss;
|
||||
expect(eg.GrossFloorArea).toBeGreaterThan(eg.NetFloorArea);
|
||||
expect(c.stats.spaces).toBe(p.rooms!.length);
|
||||
});
|
||||
|
||||
it("Wettbewerb mit Kontext: Nachbargebäude am IfcSite, sonst nichts geändert", () => {
|
||||
const p = buildWettbewerbSampleProject();
|
||||
const c = check("wettbewerb-kontext", exportIfcSpf(p, { context: true }), ["--geo", "--context"]);
|
||||
expect(c.stats.context).toBe(p.context!.filter((o) => o.type === "importedMesh").length);
|
||||
});
|
||||
|
||||
it("komplex: Bogenkanten (Erker) mit Fläche/Volumen = Mengen, Kontext (Gelände + Nachbar) mit Option", () => {
|
||||
const p = buildComplexSampleProject();
|
||||
// Offen ([259]): Anbauwand OG Ost unter dem Pultdach (Netz mit Dach-Oberkante + Fenster) — ifcopenshell scheitert am
|
||||
// Abzug der Öffnung (30.4 statt 7.5 m³); Netz und Mengen stimmen mit dem 3D überein.
|
||||
const known = `--known=${ifcGuid(`${p.id}/wall/og-anbau-o`)}`;
|
||||
const k = check("komplex", exportIfcSpf(p), ["--geo", known]);
|
||||
expect(k.stats.known.length).toBeLessThanOrEqual(1);
|
||||
const c = check("komplex-kontext", exportIfcSpf(p, { context: true }), ["--geo", "--context", known]);
|
||||
expect(c.stats.counts.IfcGeographicElement).toBeGreaterThanOrEqual(1); // Gelände (TERRAIN)
|
||||
expect(c.stats.context).toBe(2); // Gelände + Nachbargebäude; Höhenlinien und Baugrube nicht
|
||||
});
|
||||
});
|
||||
|
||||
describe("[259] 2D-Objektbibliothek im IFC", () => {
|
||||
it("bleibt draussen: die Datei ist mit und ohne Objekte zeichengleich", () => {
|
||||
const objs: Drawing2D[] = [
|
||||
{ id: "wc", type: "drawing2d", levelId: "eg", categoryCode: "23", geom: { shape: "libobj", libId: "lib:wc-wand", at: { x: 1, y: 1 }, rotation: 0 } },
|
||||
{ id: "ti", type: "drawing2d", levelId: "eg", categoryCode: "22", geom: { shape: "libobj", libId: "lib:tisch-80x140", at: { x: 3, y: 2 }, rotation: 0.5, seed: 3 } },
|
||||
];
|
||||
const without = exportAt(sampleProject);
|
||||
const withObjs = exportAt({ ...sampleProject, drawings2d: [...sampleProject.drawings2d, ...objs] });
|
||||
expect(withObjs).toBe(without);
|
||||
expect(withObjs).not.toMatch(/IFCFURNITURE|IFCSANITARYTERMINAL|IFCFURNISHINGELEMENT/);
|
||||
});
|
||||
});
|
||||
@@ -307,10 +307,14 @@ describe("exportIfcSpf — IFC4-Export", () => {
|
||||
// Das Loch-Face-Set hat 48 CoordIndex-Tripel.
|
||||
const triCounts = faceSets.map((l) => (l.match(/\(\d+,\d+,\d+\)/g) ?? []).length);
|
||||
expect(triCounts).toContain(48);
|
||||
// Zugehörige Punktliste hat 144 Punkte (3er-Koordinaten-Tupel).
|
||||
const pointLists = lines.filter((l) => l.includes("=IFCCARTESIANPOINTLIST3D("));
|
||||
const ptCounts = pointLists.map((l) => (l.match(/\([^()]*,[^()]*,[^()]*\)/g) ?? []).length);
|
||||
expect(ptCounts).toContain(144);
|
||||
// [259] Zugehörige Punktliste verschweisst: jede Ecke einmal (vorher 144 = 3 je Dreieck).
|
||||
const hole = faceSets[triCounts.indexOf(48)];
|
||||
const listId = /IFCTRIANGULATEDFACESET\(#(\d+)/.exec(hole)![1];
|
||||
const list = lines.find((l) => l.startsWith(`#${listId}=`))!;
|
||||
const pts = list.match(/\([^()]*,[^()]*,[^()]*\)/g) ?? [];
|
||||
expect(new Set(pts).size).toBe(pts.length);
|
||||
expect(pts.length).toBeLessThan(144);
|
||||
expect(pts.length).toBeGreaterThanOrEqual(16); // Quader-Ecken + Loch-Ecken vorne/hinten
|
||||
// Keine dangling refs (der Kern-Invarianten-Check gilt auch mit Face-Sets).
|
||||
const { defined, referenced } = collectIds(spf);
|
||||
expect([...referenced].filter((id) => !defined.has(id))).toEqual([]);
|
||||
@@ -433,28 +437,26 @@ describe("exportIfcSpf — IFC4-Export", () => {
|
||||
expect(b.filter((g) => a.has(g))).toEqual([]);
|
||||
});
|
||||
|
||||
it("georeferenziert: mit geoAnchor werden die ECHTEN LV95-Koordinaten geschrieben (lokal bearbeitet, weltweit lagerichtig)", () => {
|
||||
// Modell lokal nahe (0,0), aber geoAnchor sagt: Modell (0,0) = LV95
|
||||
// (2600000,1200000). Der Export muss die Profil-/Punkt-Koordinaten auf die
|
||||
// echten Landeskoordinaten (Millionenbereich) verschoben schreiben.
|
||||
it("[259] georeferenziert: Geometrie bleibt lokal, IfcMapConversion trägt den LV95-Versatz und die Höhe von ±0.00", () => {
|
||||
// Modell lokal nahe (0,0), geoAnchor: Modell (2,1) = LV95 (2600002,1200001) ⇒ Ursprung = (2600000,1200000).
|
||||
// Vorher lag die ganze Geometrie in LV95-Millionen (Revit/Archicad warnen, Genauigkeit leidet).
|
||||
const local = fixtureProject();
|
||||
const withoutAnchor = exportIfcSpf(local);
|
||||
// Ohne Bezug: lokale Koordinaten, KEINE Millionenwerte im Text.
|
||||
expect(withoutAnchor).not.toMatch(/26000\d\d\./);
|
||||
expect(withoutAnchor).not.toContain("IFCMAPCONVERSION");
|
||||
|
||||
const geo: Project = {
|
||||
...local,
|
||||
geoAnchor: { lv95: { e: 2600000, n: 1200000 }, model: { x: 0, y: 0 } },
|
||||
geoAnchor: { lv95: { e: 2600002, n: 1200001 }, model: { x: 2, y: 1 } },
|
||||
referenceElevationMasl: 441.3,
|
||||
};
|
||||
const spf = exportIfcSpf(geo);
|
||||
// W1.start (0,0) -> LV95 (2600000,1200000); W2.end (5,4) -> (2600005,1200004).
|
||||
expect(spf).toContain("2600000.");
|
||||
expect(spf).toContain("1200000.");
|
||||
expect(spf).toContain("2600005.");
|
||||
// Koordinatensystem deklariert (IFC4): EPSG:2056 + Identitäts-Abbildung.
|
||||
// Nur der Versatz in Millionen, keine Koordinate.
|
||||
expect(spf.match(/\b2600000\.0\b/g)).toHaveLength(1);
|
||||
expect(spf).not.toMatch(/2600005\./);
|
||||
expect(spf).toContain("IFCPROJECTEDCRS('EPSG:2056'");
|
||||
expect(spf).toContain("IFCMAPCONVERSION(");
|
||||
expect(withoutAnchor).not.toContain("IFCMAPCONVERSION");
|
||||
expect(spf).toMatch(/IFCMAPCONVERSION\(#\d+,#\d+,2600000\.0,1200000\.0,441\.3,1\.0,0\.0,1\.0\);/);
|
||||
expect(spf).toMatch(/IFCSITE\(.*,441\.3,\$,\$\);/);
|
||||
// Struktur bleibt valide (keine dangling refs / Duplikate).
|
||||
const { defined, referenced, duplicates } = collectIds(spf);
|
||||
expect(duplicates).toEqual([]);
|
||||
|
||||
@@ -29,6 +29,11 @@ export interface IfcExportOptions {
|
||||
ebkph?: boolean;
|
||||
/** `categoryCode` (Ebene) des Modells als System „Dossier-Ebenen". */
|
||||
layerCodes?: boolean;
|
||||
/**
|
||||
* [259] Kontext mitgeben: Gelände (IfcGeographicElement TERRAIN) und Netze auf Umgebungsklassen wie Nachbargebäude
|
||||
* (IfcBuildingElementProxy „Kontext"), am IfcSite. Ohne Angabe nicht: Fachplaner wollen meist nur das Gebäude.
|
||||
*/
|
||||
context?: boolean;
|
||||
}
|
||||
|
||||
/** Deterministische 22-stellige IFC-GUID aus einem Namen (Rust, `ifc_export::ifc_guid`). */
|
||||
@@ -67,13 +72,13 @@ export function decodeExportFlat(bytes: Uint8Array): [Float64Array, string] {
|
||||
|
||||
/**
|
||||
* Baut aus einem Projekt einen vollständigen IFC-SPF-String (IFC4, oder IFC2x3 mit `options.schema`). Kein
|
||||
* Datei-IO. Leeres Projekt ⇒ valider Minimal-IFC (Project/Site/Building). Georeferenziert (`geoAnchor`):
|
||||
* Geometrie in LV95. Verlangt das geladene Format-Modul (`await loadFileio()`).
|
||||
* Datei-IO. Leeres Projekt ⇒ valider Minimal-IFC (Project/Site/Building). Georeferenziert (`geoAnchor`): Geometrie
|
||||
* lokal, IfcMapConversion mit dem LV95-Versatz und der Höhe von ±0.00 ([259]). Verlangt das geladene Format-Modul (`await loadFileio()`).
|
||||
*/
|
||||
export function exportIfcSpf(project: Project, options: IfcExportOptions = {}): string {
|
||||
const now = Date.now();
|
||||
const iso = new Date(now).toISOString().replace(/\.\d+Z$/, "");
|
||||
const args = [Math.floor(now / 1000), options.schema === "IFC2X3" ? 1 : 0, options.ebkph ? 1 : 0, options.layerCodes ? 1 : 0];
|
||||
const args = [Math.floor(now / 1000), options.schema === "IFC2X3" ? 1 : 0, options.ebkph ? 1 : 0, options.layerCodes ? 1 : 0, options.context ? 1 : 0];
|
||||
const [buf, strings] = decodeExportFlat(documentFor(project).queryBin("ifcExportData", args, iso));
|
||||
const m = fileio();
|
||||
const text = m.export_ifc_flat(buf, strings);
|
||||
|
||||
@@ -2861,6 +2861,8 @@ export const de = {
|
||||
"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.context": "Kontext mitgeben (Gelände, Nachbargebäude)",
|
||||
"exportSave.ifc.contextHint": "Gelände als IfcGeographicElement, Netze auf Umgebungsklassen (z. B. 12 Gebäude) als IfcBuildingElementProxy «Kontext», am Grundstück statt im Geschoss. Für Fachplaner meist aus lassen: sie brauchen nur das Gebäude.",
|
||||
"exportSave.ifc.zonesNote": "SIA-416-Zonen (HNF, NNF …) und Geschossflächen sind immer enthalten, sobald Räume vorhanden sind.",
|
||||
"exportSave.ifc.schema": "IFC-Schema",
|
||||
"exportSave.ifc.schema4": "IFC4 (Standard)",
|
||||
|
||||
@@ -3172,6 +3172,8 @@ export const en: Record<TranslationKey, string> = {
|
||||
"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.context": "Include context (terrain, neighbouring buildings)",
|
||||
"exportSave.ifc.contextHint": "Terrain as IfcGeographicElement, meshes on context classes (e.g. 12 Buildings) as IfcBuildingElementProxy “Kontext”, placed on the site instead of a storey. Usually leave off for consultants: they only need the building.",
|
||||
"exportSave.ifc.zonesNote": "SIA 416 zones (HNF, NNF …) and floor areas are always included when rooms exist.",
|
||||
"exportSave.ifc.schema": "IFC schema",
|
||||
"exportSave.ifc.schema4": "IFC4 (default)",
|
||||
|
||||
@@ -66,9 +66,10 @@ export function ExportSaveDialog({
|
||||
// IFC-Klassifikation (Schweizer Praxis): beides aus, bis die Nutzerin es wählt.
|
||||
const [ebkph, setEbkph] = useState(false);
|
||||
const [layerCodes, setLayerCodes] = useState(false);
|
||||
const [context, setContext] = useState(false);
|
||||
// IFC-Schema: IFC4 (Standard) oder IFC2x3 für ältere Fachplaner-Programme.
|
||||
const [schema, setSchema] = useState<IfcSchema>("IFC4");
|
||||
const onConfirm = () => onSave(format, filename, format === "ifc" ? { schema, ebkph, layerCodes } : undefined);
|
||||
const onConfirm = () => onSave(format, filename, format === "ifc" ? { schema, ebkph, layerCodes, context } : undefined);
|
||||
|
||||
return (
|
||||
<div className="imp-overlay" onClick={onClose}>
|
||||
@@ -127,6 +128,11 @@ export function ExportSaveDialog({
|
||||
<span>{t("exportSave.ifc.layers")}</span>
|
||||
</label>
|
||||
<div className="imp-note">{t("exportSave.ifc.layersHint")}</div>
|
||||
<label className="imp-check">
|
||||
<input type="checkbox" checked={context} onChange={(e) => setContext(e.target.checked)} />
|
||||
<span>{t("exportSave.ifc.context")}</span>
|
||||
</label>
|
||||
<div className="imp-note">{t("exportSave.ifc.contextHint")}</div>
|
||||
<div className="imp-note">{t("exportSave.ifc.zonesNote")}</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user