[274] Umbau je Schicht: Sanierung auch für Decken und Dächer, Status je Schicht im IFC

Gleicher Kern-Code wie bei den Wänden (Trait build_up::Layered für Wand-, Decken-
und Dachtyp; type_pair_in, look_core; ceiling_look/roof_look in Resolved::slabs,
Umstellen in swap_build_ups). CeilingType/RoofType mit renovationTarget/Side/Old/New;
Bezugsseite Decke unten/oben, Dach: Dachhaut hebt sich. Schnitt je Schicht, 3D je
Deckenschicht, Grundriss-Linien/Ansicht/Axo in der Farbe der obersten Schicht.
Objekt-Info und Umbau-Panel „Sanierung“ für Decken und Dächer; Abfragen mit kind.
IFC: Dossier_Umbau.SchichtenBestand/SchichtenSanierung. Beispiel :umbau: Decke C1
und Dach RF1 saniert (Schnitt C). Bild doc/review-274/07-decke-dach.png.
This commit is contained in:
Claude committed 2026-11-17 22:14:49 +00:00
1 parent 4b7a85dacd
commit b7eed13942
20 files changed
+955 -180

No files matched your search

+63 -30
View File
@@ -327,7 +327,7 @@ export function phaseUsage(project: Project, phaseId: string): number {
/** Neuer Aufbau einer Wand: keiner, der Sanierungstyp ihres Wandtyps oder ein anderer Wandtyp (Ausnahme). */
export type RenovationBuildUp = { kind: "none" } | { kind: "type" } | { kind: "other"; typeId: string };
/** Neuer Aufbau einer Wand aus ihren Umbau-Angaben. */
/** Neuer Aufbau eines Bauteils (Wand, Decke, Dach) aus seinen Umbau-Angaben. */
export function wallBuildUp(r: Renovation | undefined | null): RenovationBuildUp {
if (r?.newTypeId) return { kind: "other", typeId: r.newTypeId };
return r?.renovated ? { kind: "type" } : { kind: "none" };
@@ -358,22 +358,52 @@ function withBuildUp(r: Renovation | undefined, b: RenovationBuildUp): Renovatio
return plain ? undefined : base;
}
/** Ops: neuer Aufbau für die Wände `ids` (ein Undo-Schritt); Status/Etappe bleiben. */
export function setBuildUpOps(project: Project, ids: Iterable<string>, b: RenovationBuildUp): CoreOp[] {
/** [274] Bauteilart einer Sanierung je Schicht: Wand, Decke oder Dach (je mit eigenem Typ-Katalog). */
export type RenovationHost = "wall" | "ceiling" | "roof";
export const RENOVATION_HOSTS: readonly RenovationHost[] = ["wall", "ceiling", "roof"];
/** Element-Liste, Typ-Liste und Typ-Feld je Bauteilart. */
const HOST = {
wall: { items: "walls", types: "wallTypes", typeKey: "wallTypeId" },
ceiling: { items: "ceilings", types: "ceilingTypes", typeKey: "ceilingTypeId" },
roof: { items: "roofs", types: "roofTypes", typeKey: "roofTypeId" },
} as const;
/** Mehrschichtiger Typ mit Sanierungs-Angaben (Wand-, Decken- oder Dachtyp). */
export type LayeredType = Pick<WallType, "id" | "name" | "layers" | "renovationTarget" | "renovationSide" | "renovationOld" | "renovationNew">;
type HostItem = { id: string; renovation?: Renovation } & Record<string, unknown>;
/** Typen einer Bauteilart (Wandtypen, Deckentypen, Dachtypen). */
export function renovationTypes(project: Project, host: RenovationHost = "wall"): readonly LayeredType[] {
return ((project as unknown as Record<string, unknown>)[HOST[host].types] as LayeredType[] | undefined) ?? [];
}
function hostItems(project: Project, host: RenovationHost): readonly HostItem[] {
return ((project as unknown as Record<string, unknown>)[HOST[host].items] as HostItem[] | undefined) ?? [];
}
/** Typ-Id eines Elements (Wand-, Decken-, Dachtyp; Decke/Dach ohne Typ: `undefined`). */
export function hostTypeId(e: unknown, host: RenovationHost = "wall"): string | undefined {
return ((e as Record<string, unknown>)[HOST[host].typeKey] as string | undefined) || undefined;
}
/** Ops: neuer Aufbau für die Elemente `ids` der Bauteilart `host` (ein Undo-Schritt); Status/Etappe bleiben. */
export function setBuildUpOps(project: Project, ids: Iterable<string>, b: RenovationBuildUp, host: RenovationHost = "wall"): CoreOp[] {
const set = new Set(ids);
return patchItems(project, "walls", set, (w) => {
const fn = (w: HostItem): HostItem => {
const next = withBuildUp(w.renovation, b);
const { renovation: _drop, ...rest } = w;
void _drop;
return next ? { ...rest, renovation: next } : rest;
});
};
return patchItems(project, HOST[host].items, set, fn as never);
}
/** Gemeinsamer Aufbau-Schlüssel ({@link buildUpKey}) der Wände `ids`: `"mixed"` bei verschiedenen, `null` ohne Wände. */
export function commonBuildUp(project: Project, ids: Iterable<string>): string | null {
/** Gemeinsamer Aufbau-Schlüssel ({@link buildUpKey}) der Elemente `ids`: `"mixed"` bei verschiedenen, `null` ohne. */
export function commonBuildUp(project: Project, ids: Iterable<string>, host: RenovationHost = "wall"): string | null {
const set = new Set(ids);
let out: string | null = null;
for (const w of project.walls) {
for (const w of hostItems(project, host)) {
if (!set.has(w.id)) continue;
const k = buildUpKey(wallBuildUp(w.renovation));
if (out === null) out = k;
@@ -382,30 +412,30 @@ export function commonBuildUp(project: Project, ids: Iterable<string>): string |
return out;
}
/** Ops: alle Wände des Bestandstyps `typeId` sanieren (Sanierungstyp des Typs; ein Undo-Schritt). */
export function renovateAllOfTypeOps(project: Project, typeId: string): CoreOp[] {
const ids = project.walls.filter((w) => w.wallTypeId === typeId && renovationStatus(w.renovation) === "existing").map((w) => w.id);
return setBuildUpOps(project, ids, { kind: "type" });
/** Ops: alle Elemente des Bestandstyps `typeId` sanieren (Sanierungstyp des Typs; ein Undo-Schritt). */
export function renovateAllOfTypeOps(project: Project, typeId: string, host: RenovationHost = "wall"): CoreOp[] {
const ids = hostItems(project, host).filter((w) => hostTypeId(w, host) === typeId && renovationStatus(w.renovation) === "existing").map((w) => w.id);
return setBuildUpOps(project, ids, { kind: "type" }, host);
}
/** Nächste freie Wandtyp-Id mit Präfix. */
function freeTypeId(project: Project, base: string): string {
const used = new Set(project.wallTypes.map((t) => t.id));
/** Nächste freie Typ-Id mit Präfix. */
function freeTypeId(project: Project, base: string, host: RenovationHost): string {
const used = new Set(renovationTypes(project, host).map((t) => t.id));
let i = 1;
while (used.has(`${base}-${i}`)) i++;
return `${base}-${i}`;
}
/**
* Ops: „Sanierungstyp anlegen …“ — Kopie des Bestandstyps `typeId` als neuer Wandtyp `name` (zum Anpassen der Schichten)
* Ops: „Sanierungstyp anlegen …“ — Kopie des Bestandstyps `typeId` als neuer Typ `name` (zum Anpassen der Schichten)
* und als Sanierungstyp des Bestandstyps eingetragen. Liefert die Ops und die neue Id.
*/
export function createRenovationTypeOps(project: Project, typeId: string, name: string): { ops: CoreOp[]; id: string } {
const src = project.wallTypes.find((t) => t.id === typeId);
export function createRenovationTypeOps(project: Project, typeId: string, name: string, host: RenovationHost = "wall"): { ops: CoreOp[]; id: string } {
const src = renovationTypes(project, host).find((t) => t.id === typeId);
if (!src) return { ops: [], id: "" };
const id = freeTypeId(project, `${typeId}-saniert`);
const copy: WallType = { id, name, layers: src.layers.map((l) => ({ ...l })) };
return { ops: [...addItems("wallTypes", [copy]), ...setTypePairOps(project, typeId, { target: id, old: null, new: null })], id };
const id = freeTypeId(project, `${typeId}-saniert`, host);
const copy: LayeredType = { id, name, layers: src.layers.map((l) => ({ ...l })) };
return { ops: [...addItems(HOST[host].types, [copy] as never), ...setTypePairOps(project, typeId, { target: id, old: null, new: null }, host)], id };
}
/** Ops: Typ-Paar am Bestandstyp ändern (Sanierungstyp, Bezugsseite, manuelle Zuordnung; `null` entfernt). */
@@ -413,10 +443,11 @@ export function setTypePairOps(
project: Project,
typeId: string,
patch: { target?: string | null; side?: RenovationSide | null; old?: LayerRenovation[] | null; new?: LayerRenovation[] | null },
host: RenovationHost = "wall",
): CoreOp[] {
return patchItem(project, "wallTypes", typeId, (t) => {
const next: WallType = { ...t };
const put = <K extends keyof WallType>(k: K, v: WallType[K] | null | undefined) => {
return patchItem(project, HOST[host].types, typeId, ((t: LayeredType) => {
const next: LayeredType = { ...t };
const put = <K extends keyof LayeredType>(k: K, v: LayeredType[K] | null | undefined) => {
if (v === undefined) return;
if (v === null || (Array.isArray(v) && v.every((x) => x === "auto"))) delete next[k];
else next[k] = v;
@@ -426,7 +457,7 @@ export function setTypePairOps(
put("renovationOld", patch.old);
put("renovationNew", patch.new);
return next;
});
}) as never);
}
/** Schicht eines Typ-Paars (Kern-Abfrage `renovationPair`). */
@@ -444,6 +475,7 @@ export interface RenovationStripPiece {
fill: string;
}
export interface RenovationPair {
kind: RenovationHost;
type: string;
target: string;
side: RenovationSide;
@@ -452,21 +484,22 @@ export interface RenovationPair {
oldStrip: RenovationStripPiece[];
newStrip: RenovationStripPiece[];
result: RenovationStripPiece[];
walls: number;
/** Elemente des Bestandstyps bzw. davon mit diesem Sanierungstyp saniert. */
elements: number;
renovated: number;
}
/** Typ-Paar Bestandstyp → Sanierungstyp (`target` fehlt = eingetragener); `null` ohne gültiges Paar. */
export function renovationPair(project: Project, typeId: string, target?: string): RenovationPair | null {
return documentFor(project).query<RenovationPair | null>("renovationPair", [], JSON.stringify({ type: typeId, target: target ?? "" }));
export function renovationPair(project: Project, typeId: string, target?: string, host: RenovationHost = "wall"): RenovationPair | null {
return documentFor(project).query<RenovationPair | null>("renovationPair", [], JSON.stringify({ type: typeId, target: target ?? "", kind: host }));
}
export interface RenovationPairsInfo {
pairs: { type: string; name: string; target: string; targetName: string | null; walls: number; renovated: number }[];
pairs: { kind: RenovationHost; type: string; name: string; target: string; targetName: string | null; elements: number; renovated: number }[];
renovated: number;
}
/** Alle Typ-Paare mit Zählern (Umbau-Panel „Sanierung“). */
/** Alle Typ-Paare (Wände, Decken, Dächer) mit Zählern (Umbau-Panel „Sanierung“). */
export function renovationPairs(project: Project): RenovationPairsInfo {
return documentFor(project).query<RenovationPairsInfo>("renovationPairs");
}
+36 -2
View File
@@ -78,7 +78,7 @@ describe("[274] Sanierung je Schicht", () => {
// Alles „automatisch“: Feld weg.
const u = applyOps(s, setTypePairOps(s, "aw", { old: ["auto", "auto"] }));
expect(u.wallTypes.find((t) => t.id === "aw")).not.toHaveProperty("renovationOld");
expect(renovationPairs(u).pairs.map((x) => x.type).sort()).toEqual(["aw", "aw-bestand"]);
expect(renovationPairs(u).pairs.filter((x) => x.kind === "wall").map((x) => x.type).sort()).toEqual(["aw", "aw-bestand"]);
});
it("Beispiel Umbau: Typ-Paar der Südwand, Zähler, Grundriss und GF je Filter", () => {
@@ -87,7 +87,8 @@ describe("[274] Sanierung je Schicht", () => {
expect(pr?.old.map((l) => l.fate)).toEqual(["demolish", "demolish", "kept"]);
expect(pr?.new.map((l) => l.fate)).toEqual(["new", "new", "kept"]);
expect(pr?.result.map((q) => q.kind)).toEqual(["new", "new", "newOverDemolish", "newOverDemolish", "kept"]);
expect(renovationPairs(p).renovated).toBe(1);
// Südwand W1, Decke C1, Dach RF1.
expect(renovationPairs(p).renovated).toBe(3);
// Grundriss: Abbruch gelb, Umbauplan mit gelber gestrichelter Kontur über Rot.
const dashedYellow = (prims: ReturnType<typeof plan>) => prims.some((x) => x.kind === "line" && !!x.dash && x.color === "#e8c35a");
expect(dashedYellow(plan(p, "umbauplan"))).toBe(true);
@@ -99,4 +100,37 @@ describe("[274] Sanierung je Schicht", () => {
const gfB = (q: Project) => computeAreaTable(q, "bestand").total.gf;
expect(gfB(p)).toBeCloseTo(gfB(unsaniert), 9);
});
it("Decken und Dächer: Typ-Paare, Ops je Bauteilart, Bezugsseite unten", () => {
const p = buildUmbauSampleProject();
const kinds = renovationPairs(p).pairs.map((x) => `${x.kind}:${x.type}:${x.renovated}/${x.elements}`).sort();
expect(kinds).toEqual(["ceiling:decke-bestand:1/1", "roof:dach-bestand:1/1", "wall:aw-bestand:1/1"]);
// Decke: Rohdecke bleibt (Bezugsseite unten = „inside“), darüber alles neu.
const pc = renovationPair(p, "decke-bestand", undefined, "ceiling");
expect(pc?.kind).toBe("ceiling");
expect(pc?.side).toBe("inside");
expect(pc?.old.map((l) => l.fate)).toEqual(["demolish", "demolish", "demolish", "kept"]);
expect(pc?.new.map((l) => l.fate)).toEqual(["new", "new", "new", "kept"]);
// Dach: Sparren und Verkleidung bleiben, Ziegel ab, Dämmung und Ziegel neu.
const pr = renovationPair(p, "dach-bestand", undefined, "roof");
expect(pr?.old.map((l) => l.fate)).toEqual(["demolish", "kept", "kept"]);
expect(pr?.new.map((l) => l.fate)).toEqual(["new", "new", "kept", "kept"]);
// Bezugsseite oben (gleiche Gesamtdicke: die Rohdecke liegt auch von oben her gleich und bleibt).
const q = applyOps(p, setTypePairOps(p, "decke-bestand", { side: "outside" }, "ceiling"));
expect(q.ceilingTypes?.find((t) => t.id === "decke-bestand")?.renovationSide).toBe("outside");
expect(renovationPair(q, "decke-bestand", undefined, "ceiling")?.side).toBe("outside");
expect(renovationPair(q, "decke-bestand", undefined, "ceiling")?.old.map((l) => l.fate)).toEqual(["demolish", "demolish", "demolish", "kept"]);
// Ops je Art: keiner / wie Typ, gemeinsamer Wert, Sanierungstyp anlegen, alle sanieren.
const none = applyOps(p, setBuildUpOps(p, ["C1"], { kind: "none" }, "ceiling"));
expect(none.ceilings?.find((c) => c.id === "C1")?.renovation).toEqual({ status: "existing", phase: "etappe-1" });
expect(commonBuildUp(p, ["C1"], "ceiling")).toBe("type");
expect(commonBuildUp(p, ["RF1"], "roof")).toBe("type");
expect(commonBuildUp(p, ["W1"], "ceiling")).toBeNull();
const { ops, id } = createRenovationTypeOps(p, "dg-massiv", "Decke saniert", "ceiling");
const r = applyOps(p, ops);
expect(r.ceilingTypes?.find((t) => t.id === "dg-massiv")?.renovationTarget).toBe(id);
const s = applyOps(r, renovateAllOfTypeOps(r, "dg-massiv", "ceiling"));
// C2 (Anbau) ist neu: nicht saniert; sonst trägt keine Decke „dg-massiv“.
expect((s.ceilings ?? []).filter((c) => c.renovation?.renovated).map((c) => c.id)).toEqual(["C1"]);
});
});
+69 -4
View File
@@ -11,9 +11,13 @@
// [274] Sanierung je Schicht: die Südwand W1 ist eine Aussenwand „Beton 20 + Dämmung 10 + Aussenputz“ (Bestandstyp
// „aw-bestand“) mit dem Sanierungstyp „aw-saniert“ (Beton bleibt, Dämmung und Putz werden abgebrochen, neue Dämmung 20 +
// neuer Putz), saniert in Etappe 1: Kern bleibt an seiner Stelle, die Fassade rückt 10 cm nach aussen.
// Ebenso je Schicht saniert (Etappe 1): die Geschossdecke C1 über dem EG (Rohdecke bleibt; Linoleum, Unterlagsboden und
// Trittschall werden abgebrochen, neu Parkett + Unterlagsboden + dickerer Trittschall, gleiche Gesamtdicke) und das Dach
// RF1 (Sparren und Verkleidung bleiben; Ziegel ab, neu 12 cm Aufsparrendämmung + Ziegel: die Dachhaut hebt sich). Schnitt C
// (x = 2) schneidet Wand, Decke und Dach.
// Nur Modellfelder, keine Kern-Befehle: das Modul ist ohne geladenen Kern auswertbar.
import type { Ceiling, Drawing2D, DrawingLevel, Opening, Project, Renovation, Room, Tree, Wall, WallType } from "./types";
import type { Ceiling, CeilingType, Component, Drawing2D, DrawingLevel, Opening, Project, Renovation, Roof, RoofType, Room, Tree, Wall, WallType } from "./types";
import { sampleProject } from "./sampleProject";
const E1: Renovation = { status: "new", phase: "etappe-1" };
@@ -87,10 +91,67 @@ export function buildUmbauSampleProject(): Project {
// Fenster des Anbaus: ohne eigenen Status, folgt der neuen Wand.
win("O5", "W11", 0.9, 1.2),
);
const c1 = (base.ceilings ?? [])[0];
// [274] Decke und Dach je Schicht saniert (Typ-Paare oben → unten bzw. aussen → innen).
const components: Component[] = [
...base.components,
{ id: "linoleum", name: "Linoleum", color: "#9c8f6e", hatchId: "none", joinPriority: 5 },
{ id: "parquet", name: "Parkett", color: "#c49a6c", hatchId: "none", joinPriority: 5 },
{ id: "timber", name: "Sparren (Holz)", color: "#c8a26b", hatchId: "diagonal", joinPriority: 40 },
];
const ceilingTypes: CeilingType[] = [
...(base.ceilingTypes ?? []),
{
id: "decke-bestand",
name: "Geschossdecke Linoleum (Bestand)",
layers: [
{ componentId: "linoleum", thickness: 0.005 },
{ componentId: "screed", thickness: 0.055 },
{ componentId: "insulation", thickness: 0.02 },
{ componentId: "concrete", thickness: 0.2 },
],
renovationTarget: "decke-saniert",
},
{
id: "decke-saniert",
name: "Geschossdecke Parkett (saniert)",
layers: [
{ componentId: "parquet", thickness: 0.01 },
{ componentId: "screed", thickness: 0.04 },
{ componentId: "insulation", thickness: 0.03 },
{ componentId: "concrete", thickness: 0.2 },
],
},
];
const roofTypes: RoofType[] = [
...(base.roofTypes ?? []),
{
id: "dach-bestand",
name: "Steildach Sparren (Bestand)",
layers: [
{ componentId: "roof-tiles", thickness: 0.04 },
{ componentId: "timber", thickness: 0.16 },
{ componentId: "render-int", thickness: 0.0125 },
],
renovationTarget: "dach-saniert",
},
{
id: "dach-saniert",
name: "Steildach Aufsparrendämmung (saniert)",
layers: [
{ componentId: "roof-tiles", thickness: 0.04 },
{ componentId: "insulation", thickness: 0.12 },
{ componentId: "timber", thickness: 0.16 },
{ componentId: "render-int", thickness: 0.0125 },
],
},
];
const R1: Renovation = { status: "existing", phase: "etappe-1", renovated: true };
const roofs: Roof[] = (base.roofs ?? []).map((r) => (r.id === "RF1" ? { ...r, roofTypeId: "dach-bestand", renovation: R1 } : r));
const c1: Ceiling = { ...(base.ceilings ?? [])[0], ceilingTypeId: "decke-bestand", renovation: R1 };
const ceilings: Ceiling[] = [
...(base.ceilings ?? []),
{ ...c1, id: "C2", outline: [{ x: 0, y: 4 }, { x: 3, y: 4 }, { x: 3, y: 7 }, { x: 0, y: 7 }], renovation: E2 },
c1,
...(base.ceilings ?? []).slice(1),
{ ...c1, ceilingTypeId: (base.ceilings ?? [])[0].ceilingTypeId, id: "C2", outline: [{ x: 0, y: 4 }, { x: 3, y: 4 }, { x: 3, y: 7 }, { x: 0, y: 7 }], renovation: E2 },
];
const r1 = (base.rooms ?? [])[0];
const h = 0.1725;
@@ -117,6 +178,10 @@ export function buildUmbauSampleProject(): Project {
name: "Beispiel Umbau",
drawingLevels: levels,
wallTypes,
components,
ceilingTypes,
roofTypes,
roofs,
walls,
openings,
ceilings,
+29 -1
View File
@@ -237,7 +237,23 @@ export type Ceiling = {
* damit Fuge/Schraffur-Auflösung identisch zur Wand bleiben. Eine „einschichtige"
* Decke (SOLID) ist einfach ein Deckentyp mit genau einer Schicht.
*/
export type CeilingType = { id: string; name: string; layers: Array<Layer> };
export type CeilingType = {
id: string;
name: string;
layers: Array<Layer>;
/**
* [274] Sanierungstyp (Deckentyp-Id): neuer Aufbau aller als „saniert“ markierten Decken dieses (Bestands-)Typs.
*/
renovationTarget?: string;
/**
* [274] Bezugsseite der Sanierung (fehlt ⇒ innen); bei Decken: innen = unten (Rohdecke bleibt, die Oberkante verschiebt sich), aussen = oben (Oberkante bleibt).
*/
renovationSide?: RenovationSide;
/** [274] Manuelle Zuordnung je Schicht dieses Bestandstyps (wie `WallType.renovationOld`). */
renovationOld?: Array<LayerRenovation>;
/** [274] Manuelle Zuordnung je Schicht des Sanierungstyps (wie `WallType.renovationNew`). */
renovationNew?: Array<LayerRenovation>;
};
/**
* Ein Stift (ArchiCAD-Stiftsatz-Muster): ein reiner NAME/PLATZHALTER, der
@@ -3688,6 +3704,18 @@ export type RoofType = {
name: string;
/** Aussen (Eindeckung) → innen (Verkleidung), analog `WallType.layers`. */
layers: Array<Layer>;
/**
* [274] Sanierungstyp (Dachtyp-Id): neuer Aufbau aller als „saniert“ markierten Dächer dieses (Bestands-)Typs.
*/
renovationTarget?: string;
/**
* [274] Bezugsseite der Sanierung (fehlt ⇒ innen); innen = Tragwerk/Verkleidung bleibt, die Dachhaut verschiebt sich.
*/
renovationSide?: RenovationSide;
/** [274] Manuelle Zuordnung je Schicht dieses Bestandstyps (wie `WallType.renovationOld`). */
renovationOld?: Array<LayerRenovation>;
/** [274] Manuelle Zuordnung je Schicht des Sanierungstyps (wie `WallType.renovationNew`). */
renovationNew?: Array<LayerRenovation>;
};
/**