[B4] IFC-Import: Tür-Anschlag/Aufschlag aus OperationType, Fensterteilung aus PartitioningType
- ifc_semantic.rs: Ausführung vom Bauteil oder Typ (IFC4 IfcDoorType/IfcWindowType, IFC2x3 Style), Scharnier am Wandanfang/-ende und Aufschlagseite aus der Tür-Platzierung (IFC-Konvention wie Export) - ifcElements.ts: hinge/swing an der Tür, Tür-/Fenstertyp nach Art, Blatt- bzw. Flügelzahl - Rundreise mit unserem Export: 8 Kombinationen räumlich gleich Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
4 files changed
+185
-6
No files matched your search
@@ -79,6 +79,42 @@ describe("IFC-Import als Bauteile: Rundreise Demo-Haus", () => {
|
||||
expect(text).toContain('"walls":9');
|
||||
});
|
||||
|
||||
it("Tür-Anschlag/Aufschlag und Fensterteilung aus OperationType/PartitioningType (Rundreise)", async () => {
|
||||
// Lage im Raum vergleichen (die Wand kann umgekehrt ankommen): Scharnierpunkt und Aufschlagrichtung.
|
||||
const physical = (o: Opening, w: Wall) => {
|
||||
const l = Math.hypot(w.end.x - w.start.x, w.end.y - w.start.y);
|
||||
const u = { x: (w.end.x - w.start.x) / l, y: (w.end.y - w.start.y) / l };
|
||||
const along = (o.hinge ?? "start") === "start" ? o.position : o.position + o.width;
|
||||
const s = ((o.swing ?? "left") === "left" ? 1 : -1) * ((o.openingDir ?? "in") === "in" ? 1 : -1);
|
||||
return { hinge: { x: w.start.x + u.x * along, y: w.start.y + u.y * along }, swing: { x: -u.y * s, y: u.x * s } };
|
||||
};
|
||||
for (const hinge of ["start", "end"] as const)
|
||||
for (const swing of ["left", "right"] as const)
|
||||
for (const openingDir of ["in", "out"] as const) {
|
||||
const src: Project = {
|
||||
...sampleProject,
|
||||
openings: (sampleProject.openings ?? []).map((o) =>
|
||||
o.id === "D1" ? { ...o, hinge, swing, openingDir } : o.id === "O2" ? { ...o, wingCount: 2 } : o,
|
||||
),
|
||||
};
|
||||
const { project: p } = await importInto(emptyProject, src);
|
||||
const d1 = src.openings!.find((o) => o.id === "D1")!;
|
||||
const w1 = src.walls.find((w) => w.id === d1.hostWallId)!;
|
||||
const got = (p.openings ?? []).find((o) => o.kind === "door")!;
|
||||
const gw = p.walls.find((w) => w.id === got.hostWallId)!;
|
||||
const want = physical(d1, w1);
|
||||
const have = physical(got, gw);
|
||||
const tag = `${hinge}/${swing}/${openingDir}`;
|
||||
expect(near(have.hinge, want.hinge), tag).toBe(true);
|
||||
expect(near(have.swing, want.swing), tag).toBe(true);
|
||||
expect(got.typeId, tag).toBe("door-standard");
|
||||
// Fenster O2 mit zwei Flügeln: Typ mit zwei Flügeln (oder eigene Flügelzahl).
|
||||
const o2 = (p.openings ?? []).find((o) => o.kind === "window" && Math.abs(o.width - 1.4) < 1e-6)!;
|
||||
const wt = (p.windowTypes ?? []).find((t) => t.id === o2.typeId);
|
||||
expect(o2.wingCount ?? wt?.wingCount, tag).toBe(2);
|
||||
}
|
||||
});
|
||||
|
||||
it("in ein Projekt ohne Geschosse/Typen: legt Geschosse, Wand-/Deckentypen und Materialien an", async () => {
|
||||
const bare: Project = {
|
||||
...emptyProject,
|
||||
|
||||
+42
-3
@@ -77,6 +77,12 @@ export interface IfcOpeningData extends IfcInfo {
|
||||
width: number;
|
||||
sill: number;
|
||||
height: number;
|
||||
/** Ausführung: IfcDoorTypeOperationEnum bzw. IfcWindowTypePartitioningEnum (Bauteil, sonst Typ). */
|
||||
operation: string | null;
|
||||
/** Tür: Aufschlag links (+1) / rechts (−1) der Wandachse, 0 = unbekannt (Rust `ifc_semantic`). */
|
||||
swing: number;
|
||||
/** Tür: Scharnier am Wandanfang (+1) / -ende (−1), 0 = unbekannt. */
|
||||
hinge: number;
|
||||
}
|
||||
export interface IfcSlabData extends IfcInfo {
|
||||
outline: Vec2[];
|
||||
@@ -117,6 +123,7 @@ interface RawElement extends IfcInfo {
|
||||
n: number;
|
||||
host?: number;
|
||||
openingKind?: "door" | "window" | "hole";
|
||||
operation?: string | null;
|
||||
profile?: "rect" | "round";
|
||||
longName?: string | null;
|
||||
sia?: string | null;
|
||||
@@ -170,8 +177,19 @@ export function decodeIfcElements(flat: IfcFlat): IfcElementsData | null {
|
||||
break;
|
||||
case "opening": {
|
||||
const host = wallIndex.get(e.host ?? -1);
|
||||
if (host !== undefined && v.length === 4) {
|
||||
out.openings.push({ ...info, host, kind: e.openingKind ?? "hole", position: v[0], width: v[1], sill: v[2], height: v[3] });
|
||||
if (host !== undefined && v.length === 6) {
|
||||
out.openings.push({
|
||||
...info,
|
||||
host,
|
||||
kind: e.openingKind ?? "hole",
|
||||
position: v[0],
|
||||
width: v[1],
|
||||
sill: v[2],
|
||||
height: v[3],
|
||||
operation: e.operation ?? null,
|
||||
swing: Math.sign(v[4]),
|
||||
hinge: Math.sign(v[5]),
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -422,7 +440,26 @@ export function ifcElementsToProject(
|
||||
const host = walls[o.host];
|
||||
if (!host) continue;
|
||||
const kind = o.kind === "window" ? "window" : "door";
|
||||
const typeId = o.kind === "door" ? project.doorTypes?.[0]?.id : o.kind === "window" ? project.windowTypes?.[0]?.id : undefined;
|
||||
const op = o.operation ?? "";
|
||||
// Tür: Typ nach Art (Dreh/Schiebe) und Blattzahl aus der Ausführung, sonst der erste Typ.
|
||||
const sliding = op.includes("SLIDING");
|
||||
const leaves = op.startsWith("DOUBLE_DOOR") ? 2 : 1;
|
||||
const doorType =
|
||||
(op ? project.doorTypes?.find((t) => t.kind === (sliding ? "schiebe" : "dreh") && t.leafCount === leaves) : undefined) ??
|
||||
project.doorTypes?.[0];
|
||||
// Fenster: Flügelzahl aus der Teilung (nur senkrechte Standardfälle); Typ mit dieser Flügelzahl, sonst
|
||||
// der erste Typ mit eigener Flügelzahl an der Öffnung.
|
||||
const wings = ({ SINGLE_PANEL: 1, DOUBLE_PANEL_VERTICAL: 2, TRIPLE_PANEL_VERTICAL: 3 } as Record<string, number>)[op];
|
||||
const windowType = (wings ? project.windowTypes?.find((t) => t.wingCount === wings) : undefined) ?? project.windowTypes?.[0];
|
||||
const typeId = o.kind === "door" ? doorType?.id : o.kind === "window" ? windowType?.id : undefined;
|
||||
const doorExtra =
|
||||
o.kind === "door"
|
||||
? {
|
||||
...(o.hinge !== 0 ? { hinge: o.hinge > 0 ? ("start" as const) : ("end" as const) } : {}),
|
||||
...(o.swing !== 0 ? { swing: o.swing > 0 ? ("left" as const) : ("right" as const) } : {}),
|
||||
}
|
||||
: {};
|
||||
const windowExtra = o.kind === "window" && wings && (windowType?.wingCount ?? 1) !== wings ? { wingCount: wings } : {};
|
||||
openings.push({
|
||||
id: newId("opening"),
|
||||
type: "opening",
|
||||
@@ -435,6 +472,8 @@ export function ifcElementsToProject(
|
||||
sillHeight: round(o.sill, 1e-6),
|
||||
...(o.kind === "hole" ? { doorType: "wandoeffnung" as const } : {}),
|
||||
...(typeId ? { typeId } : {}),
|
||||
...doorExtra,
|
||||
...windowExtra,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user