[293] Wand-Oberkante als eine Auswahl (Geschosshöhe/Frei, Bis Decke, Bis Dach, tiefere von beiden): Objekt-Info und Befehl wand

This commit is contained in:
Claude committed 2026-11-19 10:49:42 +00:00
1 parent c7f7f66b33
commit c1b4dcf67a
14 files changed
+184 -71

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
import { describe, expect, it } from "vitest";
import { WALL_TOP_MODES, wallTopFromFields, wallTopPatch, wallTopNext } from "./wallTop";
describe("Wand-Oberkante [293]", () => {
it("Felder und Auswahl sind umkehrbar", () => {
for (const m of WALL_TOP_MODES) {
const p = wallTopPatch(m);
expect(wallTopFromFields(p.roofAttach, p.ceilingAttach)).toBe(m);
}
});
it("Standard (nichts gesetzt) = Geschosshöhe", () => {
expect(wallTopFromFields(undefined, undefined)).toBe("storey");
expect(wallTopPatch("storey")).toEqual({ roofAttach: undefined, ceilingAttach: undefined });
});
it("Decke allein schaltet das Dach ab, tiefere lässt es automatisch", () => {
expect(wallTopPatch("ceiling")).toEqual({ roofAttach: false, ceilingAttach: true });
expect(wallTopPatch("lower")).toEqual({ roofAttach: undefined, ceilingAttach: true });
expect(wallTopPatch("roof")).toEqual({ roofAttach: true, ceilingAttach: undefined });
});
it("reihum", () => {
expect(wallTopNext("storey")).toBe("ceiling");
expect(wallTopNext("lower")).toBe("storey");
});
});
+32
View File
@@ -0,0 +1,32 @@
/**
* [293] Wand-Oberkante als EINE Auswahl über die Felder `Wall.roofAttach` ([G2]) und `Wall.ceilingAttach` ([292]).
* Die Höhe selbst (`height`/`top`) bleibt getrennt (Geschosshöhe bzw. frei, s. Objekt-Info „Höhe“).
* storey — Geschosshöhe/frei: Dächer schneiden automatisch, keine Decke
* roof — bis unters Dach verlängert
* ceiling — bis Unterkante der Decke, Dächer schneiden nicht
* lower — Decke und Dach, je Punkt die tiefere Kante (so rechnet `wall_bands.rs` bei beiden Feldern)
*/
export type WallTopMode = "storey" | "ceiling" | "roof" | "lower";
export const WALL_TOP_MODES: readonly WallTopMode[] = ["storey", "ceiling", "roof", "lower"];
export interface WallTopFields {
roofAttach: boolean | undefined;
ceilingAttach: boolean | undefined;
}
export function wallTopFromFields(roofAttach: boolean | undefined, ceilingAttach: boolean | undefined): WallTopMode {
if (ceilingAttach) return roofAttach === false ? "ceiling" : "lower";
return roofAttach === true ? "roof" : "storey";
}
/** Felder für eine Auswahl; `undefined` entfernt das Feld (Vorgabe). */
export function wallTopPatch(mode: WallTopMode): WallTopFields {
switch (mode) {
case "storey": return { roofAttach: undefined, ceilingAttach: undefined };
case "roof": return { roofAttach: true, ceilingAttach: undefined };
case "ceiling": return { roofAttach: false, ceilingAttach: true };
case "lower": return { roofAttach: undefined, ceilingAttach: true };
}
}
export const wallTopNext = (m: WallTopMode): WallTopMode => WALL_TOP_MODES[(WALL_TOP_MODES.indexOf(m) + 1) % WALL_TOP_MODES.length];