[B4] IFC-Import: Träger, Geländer und Rampen der Rundreise als Bauteile
Rechteckige IfcBeam werden Project.beams (Achse, Breite, Höhe, Oberkante über topOffset), eigene Geländer (Pset Dossier_Railing mit Achse/Höhe/Art, nur wenn der Körper passt) werden Railings, IfcRamp/IfcRampFlight als ebene schräge Platte werden Decken mit slope.ramp. Alles andere bleibt Mesh bzw. Körper. Rundreise-Test für :wettbewerb und :komplex, Dachplatten nicht doppelt.
This commit is contained in:
9 files changed
+512
-22
No files matched your search
+3
-1
@@ -3099,7 +3099,8 @@ export const de = {
|
||||
"ifc.importReport.rooms": "Räume",
|
||||
"ifc.importReport.roofs": "Dächer",
|
||||
"ifc.importReport.stairs": "Treppen",
|
||||
"ifc.importReport.beams": "Träger (als Extrusionskörper)",
|
||||
"ifc.importReport.beams": "Träger (rechteckige als Träger, sonst Extrusionskörper)",
|
||||
"ifc.importReport.railings": "Geländer",
|
||||
"ifc.importReport.floors": "Neue Geschosse",
|
||||
"ifc.importReport.types": "Neue Typen (Wand, Decke, Dach, Tür, Fenster)",
|
||||
"ifc.importReport.meshes": "Übrige Bauteile als Kontext-Mesh",
|
||||
@@ -3115,6 +3116,7 @@ export const de = {
|
||||
"ifc.reason.holes": "Raum mit Loch",
|
||||
"ifc.reason.part": "Teil eines anderen Bauteils",
|
||||
"ifc.reason.roofForm": "Dachform nicht abbildbar (kein Rechteck, ungleiche Neigung, Tonnendach …)",
|
||||
"ifc.reason.rampForm": "Rampe ist keine ebene schräge Platte (mehrere Läufe, gekrümmt, Stufen)",
|
||||
"ifc.reason.stairForm": "keine gleichmässige gerade, L-, U-, Podest- oder Wendeltreppe",
|
||||
"ifc.reason.stairTurn": "Podesttreppe, die Dossier nicht abbildet (mehr als zwei Podeste, Podest nicht an der Ecke, ungleiche Läufe)",
|
||||
"menu.native.importMesh": "3D-Modell importieren …",
|
||||
|
||||
+3
-1
@@ -3047,7 +3047,8 @@ export const en: Record<TranslationKey, string> = {
|
||||
"ifc.importReport.rooms": "Rooms",
|
||||
"ifc.importReport.roofs": "Roofs",
|
||||
"ifc.importReport.stairs": "Stairs",
|
||||
"ifc.importReport.beams": "Beams (as extruded solids)",
|
||||
"ifc.importReport.beams": "Beams (rectangular ones as beams, others as extruded solids)",
|
||||
"ifc.importReport.railings": "Railings",
|
||||
"ifc.importReport.floors": "New floors",
|
||||
"ifc.importReport.types": "New types (wall, slab, roof, door, window)",
|
||||
"ifc.importReport.meshes": "Other elements as context mesh",
|
||||
@@ -3063,6 +3064,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"ifc.reason.holes": "room with a hole",
|
||||
"ifc.reason.part": "part of another element",
|
||||
"ifc.reason.roofForm": "roof shape not mappable (not a rectangle, unequal pitch, barrel roof …)",
|
||||
"ifc.reason.rampForm": "ramp is not a single planar sloped slab (several flights, curved, stepped)",
|
||||
"ifc.reason.stairForm": "not a regular straight, L, U, landing or spiral stair",
|
||||
"ifc.reason.stairTurn": "landing stair Dossier cannot represent (more than two landings, landing not at the corner, unequal flights)",
|
||||
"menu.native.importMesh": "Import 3D model …",
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
// [B4] Rundreise Export → Import für Träger, Geländer, Rampen und Dächer: Fachplaner-Austausch darf Bauteile nicht in Körper
|
||||
// verwandeln. Anzahl je Bauteilart gleich; Träger (Achse, Breite, Höhe), Geländer (Achse, Höhe, Art) und Rampe (Gefälle,
|
||||
// Umriss) stimmen; die Dachplatten kommen nicht zusätzlich zum Dach als Netz.
|
||||
|
||||
import "../engine/fileioWasm.setup";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { exportIfcSpf } from "../export/exportIfc";
|
||||
import { emptyProject } from "../model/sampleProject";
|
||||
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
|
||||
import { buildWettbewerbSampleProject } from "../model/sampleProjectWettbewerb";
|
||||
import type { Project } from "../model/types";
|
||||
import type { IfcElementsSummary } from "./ifcImport";
|
||||
import { importIfcInto } from "./importView.testutil";
|
||||
|
||||
const near = (a: number, b: number, tol = 1e-5) => Math.abs(a - b) <= tol;
|
||||
|
||||
async function roundtrip(src: Project) {
|
||||
const spf = exportIfcSpf(src);
|
||||
const r = await importIfcInto({ ...emptyProject, drawingLevels: src.drawingLevels }, new TextEncoder().encode(spf), { elements: true });
|
||||
return { spf, p: r.project, summary: r.summary as IfcElementsSummary };
|
||||
}
|
||||
const count = (spf: string, cls: string) => (spf.match(new RegExp(`=${cls}\\(`, "g")) ?? []).length;
|
||||
const len = (a: { start: { x: number; y: number }; end: { x: number; y: number } }) => Math.hypot(a.end.x - a.start.x, a.end.y - a.start.y);
|
||||
const mid = (a: { start: { x: number; y: number }; end: { x: number; y: number } }) => [(a.start.x + a.end.x) / 2, (a.start.y + a.end.y) / 2];
|
||||
|
||||
describe("[B4] IFC-Rundreise: Träger, Geländer, Rampen, Dächer", () => {
|
||||
it(":komplex: Träger kommen als Träger zurück, Dächer nicht doppelt", async () => {
|
||||
const src = buildComplexSampleProject();
|
||||
const { spf, p, summary } = await roundtrip(src);
|
||||
expect(src.beams!.length).toBeGreaterThan(0);
|
||||
expect(count(spf, "IFCBEAM")).toBe(src.beams!.length);
|
||||
expect(p.beams?.length).toBe(src.beams!.length);
|
||||
expect(p.extrudedSolids ?? []).toEqual([]);
|
||||
expect(summary.beams).toBe(src.beams!.length);
|
||||
for (const b of src.beams!) {
|
||||
const got = p.beams!.find((g) => g.floorId === b.floorId && near(len(g), len(b)) && near(mid(g)[0], mid(b)[0]) && near(mid(g)[1], mid(b)[1]))!;
|
||||
expect(got, b.id).toBeDefined();
|
||||
expect(near(got.width, b.width) && near(got.height, b.height), JSON.stringify(got)).toBe(true);
|
||||
expect(near(got.topOffset ?? 0, b.topOffset ?? 0, 1e-4), JSON.stringify([got.topOffset, b.topOffset])).toBe(true);
|
||||
}
|
||||
// Dach: Dachplatten (IfcSlab ROOF) kommen nicht zusätzlich zum Dach als Kontext-Netz.
|
||||
const roofSlabs = (spf.match(/=IFCSLAB\([^;]*\.ROOF\.\);/g) ?? []).length;
|
||||
expect(roofSlabs).toBeGreaterThan(0);
|
||||
const gids = (p.context ?? []).map((c) => (c as { ifcGlobalId?: string }).ifcGlobalId).filter(Boolean);
|
||||
expect(new Set(gids).size, "kein Bauteil doppelt als Netz").toBe(gids.length);
|
||||
});
|
||||
|
||||
it(":wettbewerb: Geländer und Rampe kommen als Bauteile zurück", async () => {
|
||||
const src = buildWettbewerbSampleProject();
|
||||
const { spf, p, summary } = await roundtrip(src);
|
||||
expect((spf.match(/IFCPROPERTYSET\([^;]*Dossier_Railing/g) ?? []).length).toBe(src.railings!.length);
|
||||
expect(p.railings?.length).toBe(src.railings!.length);
|
||||
expect(summary.railings).toBe(src.railings!.length);
|
||||
for (const r of src.railings!) {
|
||||
const got = p.railings!.find((g) => g.floorId === r.floorId && g.points.length === r.points.length && g.points.every((q, i) => near(q.x, r.points[i].x) && near(q.y, r.points[i].y)))!;
|
||||
expect(got, r.id).toBeDefined();
|
||||
expect(near(got.height, r.height)).toBe(true);
|
||||
expect(got.kind).toBe(r.kind);
|
||||
expect(got.closed ?? false).toBe(r.closed ?? false);
|
||||
expect(near(got.baseOffset ?? 0, r.baseOffset ?? 0, 1e-4)).toBe(true);
|
||||
}
|
||||
const ramps = (src.ceilings ?? []).filter((c) => c.slope?.ramp);
|
||||
expect(ramps.length).toBeGreaterThan(0);
|
||||
expect(count(spf, "IFCRAMP\\b")).toBe(ramps.length);
|
||||
expect((p.ceilings ?? []).filter((c) => c.slope?.ramp).length).toBe(ramps.length);
|
||||
expect((p.ceilings ?? []).length).toBe((src.ceilings ?? []).length);
|
||||
for (const c of ramps) {
|
||||
const grade = (s: NonNullable<typeof c.slope>) => s.rise / Math.hypot(s.to.x - s.from.x, s.to.y - s.from.y);
|
||||
const got = (p.ceilings ?? []).find((g) => g.slope?.ramp && near(Math.abs(g.slope.rise), Math.abs(c.slope!.rise), 1e-3))!;
|
||||
expect(got, c.id).toBeDefined();
|
||||
expect(Math.abs(grade(got.slope!))).toBeCloseTo(Math.abs(grade(c.slope!)), 3);
|
||||
expect(got.outline.length).toBe(c.outline.length);
|
||||
}
|
||||
});
|
||||
});
|
||||
+3
-1
@@ -123,8 +123,10 @@ export interface IfcElementsSummary {
|
||||
/** Dächer (Flach/Pult/Sattel/Walm, auch mit Neigung je Kante) und Treppen (gerade, L, Wendel) ([B4]). */
|
||||
roofs: number;
|
||||
stairs: number;
|
||||
/** Träger (IfcBeam) als Extrusionskörper ([B4]). */
|
||||
/** Träger (IfcBeam): rechteckige als Träger, sonst Extrusionskörper ([B4]). */
|
||||
beams?: number;
|
||||
/** Geländer des eigenen Exports (Achse im Pset `Dossier_Railing`) ([B4]). */
|
||||
railings?: number;
|
||||
/** Neu angelegte Geschosse. */
|
||||
floors: number;
|
||||
wallTypes: number;
|
||||
|
||||
@@ -79,6 +79,7 @@ const RECOGNIZED: ReadonlyArray<[string, (s: IfcElementsSummary) => number]> = [
|
||||
["ifc.importReport.roofs", (s) => s.roofs ?? 0],
|
||||
["ifc.importReport.stairs", (s) => s.stairs ?? 0],
|
||||
["ifc.importReport.beams", (s) => s.beams ?? 0],
|
||||
["ifc.importReport.railings", (s) => s.railings ?? 0],
|
||||
["ifc.importReport.columns", (s) => s.columns],
|
||||
["ifc.importReport.rooms", (s) => s.rooms],
|
||||
["ifc.importReport.floors", (s) => s.floors],
|
||||
|
||||
Reference in new issue
Block a user