[271] Umbau in Schnitt, Ansicht, 2D und Möbeln: Abbruch-Stück und Ausfachung auch im Schnitt und in der Ansicht (Bogenwände eingeschlossen), Projektionslinien und Ansichts-Öffnungen in Umbau-Farbe, 2D-Elemente/Möbel/Bäume mit Status
Schnitt und Ansicht rechnen die Ersatzstücke der Öffnungen aus dem Projekt mit allem (die zugemauerte Öffnung fehlt im gefilterten Projekt); Grundriss auch für Bogenwände. Projektionslinien des Schnitts über Output::edge_ids, Öffnungslinien der Ansicht über restyle_with. Drawing2D.renovation (Möbel/Symbole immer, übrige 2D-Elemente nur mit ausdrücklichem Status), Strichfarbe in drawings::emit; Bäume: Tree.status IST der Umbau-Status (tree_renovation), kein zweites Feld. Schnitt entfernt jetzt auch ausgeblendete Bäume/Körper (without_hidden). Beispiel :umbau mit Möbeln, Bäumen und Ansicht West; Bilder doc/review-271/06-09.
This commit is contained in:
26 files changed
+822
-50
No files matched your search
@@ -5,7 +5,7 @@ import { describe, expect, it } from "vitest";
|
||||
import { applyOps } from "../core/ops";
|
||||
import { documentFor } from "../core/document";
|
||||
import {
|
||||
commonRenovation, idsByRenovationStatus, phaseUsage, renovationCounts, renovationFilterList, renovationFilterShows, renovationForNew, renovationStyleOf, RENOVATION_STATUSES,
|
||||
commonRenovation, idsByRenovationStatus, phaseUsage, renovatableIds, renovationCounts, renovationFilterList, renovationFilterShows, renovationForNew, renovationStyleOf, RENOVATION_STATUSES,
|
||||
setPhasesOps, setRenovationOps,
|
||||
} from "./renovation";
|
||||
import { buildUmbauSampleProject } from "./sampleProjectUmbau";
|
||||
@@ -120,4 +120,31 @@ describe("[271] Umbau", () => {
|
||||
expect(phaseUsage(p, "etappe-1")).toBeGreaterThan(0);
|
||||
expect(phaseUsage(p, "nix")).toBe(0);
|
||||
});
|
||||
|
||||
it("Möbel und Bäume tragen den Umbau-Status (Baum: sein Bestand ist der Status)", () => {
|
||||
const p = buildUmbauSampleProject();
|
||||
// Beispiel: Sofa Bestand, Tisch Abbruch, Sofa neu; Baum zu fällen = Abbruch, neuer Baum = Neu.
|
||||
const dem = idsByRenovationStatus(p, "demolish");
|
||||
expect(dem.drawings).toEqual(["M2"]);
|
||||
expect(dem.trees).toEqual(["B1"]);
|
||||
expect(idsByRenovationStatus(p, "new").drawings).toEqual(["M3"]);
|
||||
expect(idsByRenovationStatus(p, "new").trees).toEqual(["B2"]);
|
||||
expect(idsByRenovationStatus(p, "existing").drawings).toEqual(["M1"]);
|
||||
// Linien und Masse ohne Angabe nehmen nicht teil (sonst wären sie im Umbauplan grau).
|
||||
const withLine = { ...p, drawings2d: [...p.drawings2d, { id: "L0", type: "drawing2d" as const, levelId: "eg", categoryCode: "20", geom: { shape: "line" as const, a: { x: 0, y: 0 }, b: { x: 1, y: 0 } } }] };
|
||||
expect(idsByRenovationStatus(withLine, "existing").drawings).toEqual(["M1"]);
|
||||
// Setzen: Möbel bekommen `renovation`, Bäume ihren `status` (zu fällen = Abbruch).
|
||||
const ops = setRenovationOps(p, ["M1", "B2"], "demolish");
|
||||
expect(ops).toHaveLength(2);
|
||||
const q = applyOps(p, ops);
|
||||
expect(q.drawings2d.find((d) => d.id === "M1")?.renovation?.status).toBe("demolish");
|
||||
expect(q.trees?.find((t) => t.id === "B2")?.status).toBe("remove");
|
||||
expect(commonRenovation(q, ["M1", "B2"]).status).toBe("demolish");
|
||||
expect(commonRenovation(p, ["M1", "B1"]).status).toBe("mixed");
|
||||
// Zurück auf Bestand: das Möbel verliert das Feld, der Baum wird bestehend.
|
||||
const back = applyOps(q, setRenovationOps(q, ["M1", "B2"], "existing"));
|
||||
expect(back.drawings2d.find((d) => d.id === "M1")?.renovation).toBeUndefined();
|
||||
expect(back.trees?.find((t) => t.id === "B2")?.status).toBe("existing");
|
||||
expect(renovatableIds(p, ["M1", "B1", "gibts-nicht"]).sort()).toEqual(["B1", "M1"]);
|
||||
});
|
||||
});
|
||||
+40
-15
@@ -4,7 +4,7 @@
|
||||
import type { CoreOp } from "../core/ops";
|
||||
import { documentFor } from "../core/document";
|
||||
import { patchItems, setField } from "../core/opsBuild";
|
||||
import type { Project, Renovation, RenovationPhase, RenovationShow, RenovationStatus } from "./types";
|
||||
import type { Project, Renovation, RenovationPhase, RenovationShow, RenovationStatus, Tree, TreeStatus } from "./types";
|
||||
|
||||
/** Eingebaute Umbaufilter (Ids; Namen über `t("renovation.filter.<id>")`). */
|
||||
export const BUILTIN_RENOVATION_FILTERS = ["bestand", "abbruch", "neubau", "umbauplan", "endzustand"] as const;
|
||||
@@ -12,10 +12,20 @@ export const BUILTIN_RENOVATION_FILTERS = ["bestand", "abbruch", "neubau", "umba
|
||||
/** Status in der Reihenfolge der Oberfläche. */
|
||||
export const RENOVATION_STATUSES: readonly RenovationStatus[] = ["existing", "demolish", "new"];
|
||||
|
||||
/** Listen mit Umbau-Status (Räume nur Sichtbarkeit/Flächen, keine Farbe). */
|
||||
export const RENOVATION_COLLECTIONS = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms"] as const;
|
||||
/**
|
||||
* Listen mit Umbau-Status (Räume nur Sichtbarkeit/Flächen, keine Farbe). `drawings2d`: Möbel und Symbole der Bibliothek
|
||||
* (ohne Angabe = Bestand) sowie 2D-Elemente mit ausdrücklichem Status (Linienwerk, Masse …; Kern `drawing_takes_part`).
|
||||
*/
|
||||
export const RENOVATION_COLLECTIONS = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "drawings2d"] as const;
|
||||
export type RenovationCollection = (typeof RENOVATION_COLLECTIONS)[number];
|
||||
|
||||
/**
|
||||
* Bäume tragen kein eigenes `renovation`: ihr Bestand (`Tree.status`, [149]) IST der Umbau-Status
|
||||
* (bestehend = Bestand, zu fällen = Abbruch, neu = Neu; Kern `renovation::tree_renovation`).
|
||||
*/
|
||||
const TREE_STATUS_OF: Record<RenovationStatus, TreeStatus> = { existing: "existing", demolish: "remove", new: "new" };
|
||||
export const treeRenovationStatus = (t: Tree): RenovationStatus => (t.status === "remove" ? "demolish" : t.status === "new" ? "new" : "existing");
|
||||
|
||||
/** SIA-400-Vorgabe der Umbau-Farben (gleich wie `renovation::default_style` im Kern). */
|
||||
export const DEFAULT_RENOVATION_STYLES: Record<RenovationStatus, { fill: string; line?: string; dashed: boolean }> = {
|
||||
existing: { fill: "#a6a6a6", dashed: false },
|
||||
@@ -73,6 +83,8 @@ export function setRenovationOps(project: Project, ids: Iterable<string>, status
|
||||
}),
|
||||
);
|
||||
}
|
||||
// Bäume: der Status ist ihr Bestand (Etappen kennen sie nicht).
|
||||
if (status) ops.push(...patchItems(project, "trees", set, (t) => ({ ...t, status: TREE_STATUS_OF[status] })));
|
||||
return ops;
|
||||
}
|
||||
|
||||
@@ -83,6 +95,7 @@ export function renovatableIds(project: Project, ids: Iterable<string>): string[
|
||||
for (const c of RENOVATION_COLLECTIONS) {
|
||||
for (const e of (project[c] ?? []) as { id: string }[]) if (set.has(e.id)) out.push(e.id);
|
||||
}
|
||||
for (const t of project.trees ?? []) if (set.has(t.id)) out.push(t.id);
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -92,21 +105,22 @@ export function commonRenovation(project: Project, ids: Iterable<string>): { sta
|
||||
let status: RenovationStatus | "mixed" | null = null;
|
||||
let phase: string | "mixed" | null = null;
|
||||
let first = true;
|
||||
const add = (s: RenovationStatus, ph: string) => {
|
||||
if (first) {
|
||||
status = s;
|
||||
phase = ph;
|
||||
first = false;
|
||||
} else {
|
||||
if (status !== s) status = "mixed";
|
||||
if (phase !== ph) phase = "mixed";
|
||||
}
|
||||
};
|
||||
for (const c of RENOVATION_COLLECTIONS) {
|
||||
for (const e of (project[c] ?? []) as { id: string; renovation?: Renovation }[]) {
|
||||
if (!set.has(e.id)) continue;
|
||||
const s = renovationStatus(e.renovation);
|
||||
const ph = e.renovation?.phase ?? "";
|
||||
if (first) {
|
||||
status = s;
|
||||
phase = ph;
|
||||
first = false;
|
||||
} else {
|
||||
if (status !== s) status = "mixed";
|
||||
if (phase !== ph) phase = "mixed";
|
||||
}
|
||||
if (set.has(e.id)) add(renovationStatus(e.renovation), e.renovation?.phase ?? "");
|
||||
}
|
||||
}
|
||||
for (const t of project.trees ?? []) if (set.has(t.id)) add(treeRenovationStatus(t), "");
|
||||
return { status, phase };
|
||||
}
|
||||
|
||||
@@ -171,6 +185,12 @@ export function renovationStyleOf(project: Project, status: RenovationStatus): {
|
||||
return { fill: o?.fill ?? d.fill, line: o?.line ?? d.line, dashed: o?.dashed ?? d.dashed };
|
||||
}
|
||||
|
||||
/** Möbel und Symbole (Objekte der Bibliothek, Blöcke): nehmen ohne Angabe als Bestand am Umbaufilter teil. */
|
||||
function isFurnitureShape(d: unknown): boolean {
|
||||
const shape = (d as { geom?: { shape?: string } }).geom?.shape;
|
||||
return shape === "libobj" || shape === "block";
|
||||
}
|
||||
|
||||
/** Auswahl-Art je Liste (`extrudedSolids` heissen in der Auswahl `solids`). */
|
||||
const SELECTION_KEY: Record<RenovationCollection, string> = {
|
||||
walls: "walls",
|
||||
@@ -181,6 +201,7 @@ const SELECTION_KEY: Record<RenovationCollection, string> = {
|
||||
columns: "columns",
|
||||
extrudedSolids: "solids",
|
||||
rooms: "rooms",
|
||||
drawings2d: "drawings",
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -197,8 +218,10 @@ export function idsByRenovationStatus(
|
||||
for (const c of RENOVATION_COLLECTIONS) {
|
||||
const ids: string[] = [];
|
||||
for (const e of (project[c] ?? []) as { id: string; floorId?: string; hostWallId?: string; renovation?: Renovation }[]) {
|
||||
// Zeichnungen ohne ausdrücklichen Status (Linien, Masse …) nehmen nicht teil; Möbel und Symbole gelten als Bestand.
|
||||
if (c === "drawings2d" && !e.renovation && !isFurnitureShape(e)) continue;
|
||||
const wall = c === "openings" && e.hostWallId ? wallOf.get(e.hostWallId) : undefined;
|
||||
const floor = e.floorId ?? wall?.floorId;
|
||||
const floor = e.floorId ?? (e as { levelId?: string }).levelId ?? wall?.floorId;
|
||||
if (opts.floorId && floor && floor !== opts.floorId) continue;
|
||||
const r = e.renovation ?? wall?.renovation;
|
||||
if (renovationStatus(r) !== status) continue;
|
||||
@@ -207,6 +230,8 @@ export function idsByRenovationStatus(
|
||||
}
|
||||
if (ids.length) out[SELECTION_KEY[c]] = ids;
|
||||
}
|
||||
const trees = (project.trees ?? []).filter((t) => treeRenovationStatus(t) === status && (!opts.floorId || t.floorId === opts.floorId) && (opts.phase === undefined || opts.phase === "")).map((t) => t.id);
|
||||
if (trees.length) out.trees = trees;
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,12 @@
|
||||
// und Endzustand ist die Wand dort zu, mit roter Ausfachung im Umbauplan), in die Westwand W4 kommt ein neues Fenster O3
|
||||
// (Öffnung „Neu“ in Bestandswand: im Bestand ist die Wand dort zu, im Umbauplan gelbes Abbruch-Stück).
|
||||
// Etappe 2 (Anbau): ein eingeschossiger Anbau im Norden (Wände, Decke, Raum, Fenster) und eine neue Tür in W3.
|
||||
// Möbel (Objekte der Bibliothek) und Bäume tragen den Umbau-Status ebenfalls: ein Sofa bleibt (Bestand), ein Tisch wird
|
||||
// entfernt (Abbruch, Etappe 1), ein neues Sofa kommt in den Anbau (Etappe 2); ein Baum wird gefällt (Bäume: `status` = Umbau-Status),
|
||||
// ein neuer wird gepflanzt.
|
||||
// Nur Modellfelder, keine Kern-Befehle: das Modul ist ohne geladenen Kern auswertbar.
|
||||
|
||||
import type { Ceiling, DrawingLevel, Opening, Project, Renovation, Room, Wall } from "./types";
|
||||
import type { Ceiling, Drawing2D, DrawingLevel, Opening, Project, Renovation, Room, Tree, Wall } from "./types";
|
||||
import { sampleProject } from "./sampleProject";
|
||||
|
||||
const E1: Renovation = { status: "new", phase: "etappe-1" };
|
||||
@@ -23,6 +26,17 @@ const win = (id: string, hostWallId: string, position: number, width: number, re
|
||||
...(renovation ? { renovation } : {}),
|
||||
});
|
||||
|
||||
/** Objekt der Bibliothek ([253]) auf der Möbel-Klasse; ohne `renovation` = Bestand. */
|
||||
const furniture = (id: string, libId: string, x: number, y: number, renovation?: Renovation, rotation = 0): Drawing2D => ({
|
||||
id, type: "drawing2d", levelId: "eg", categoryCode: "22", geom: { shape: "libobj", libId, at: { x, y }, rotation },
|
||||
...(renovation ? { renovation } : {}),
|
||||
});
|
||||
|
||||
const tree = (id: string, x: number, y: number, status: Tree["status"]): Tree => ({
|
||||
id, type: "tree", floorId: "eg", categoryCode: "13", position: { x, y }, trunkDiameter: 0.3, crownDiameter: 3.2, crownBase: 1.8, height: 6.5,
|
||||
shape: "round", status, foliage: "deciduous",
|
||||
});
|
||||
|
||||
/** Das Umbau-Beispiel (frische Kopie bei jedem Aufruf). */
|
||||
export function buildUmbauSampleProject(): Project {
|
||||
const base = structuredClone(sampleProject);
|
||||
@@ -30,6 +44,8 @@ export function buildUmbauSampleProject(): Project {
|
||||
...base.drawingLevels,
|
||||
// Schnitt durch den Anbau (Nord–Süd, Blick nach Osten): zeigt Bestand, Abbruch W9 nicht, aber Anbau und neue Tür.
|
||||
{ id: "schnitt-b", name: "Schnitt B", kind: "section", visible: true, locked: false, linePoints: [{ x: 1.4, y: -1 }, { x: 1.4, y: 8 }], directionSign: -1 },
|
||||
// Ansicht West (Blick nach Osten): das neue Fenster O3 in der Bestandswand W4 mit seinem Abbruch-Stück, der Anbau dahinter.
|
||||
{ id: "ansicht-west", name: "Ansicht West", kind: "elevation", visible: true, locked: false, linePoints: [{ x: -2, y: 8 }, { x: -2, y: -1 }], directionSign: 1 },
|
||||
];
|
||||
const walls: Wall[] = base.walls.map((w) => (w.id === "W9" ? { ...w, renovation: D1 } : w));
|
||||
walls.push(wall("W10", 0, 4, 0, 7), wall("W11", 0, 7, 3, 7), wall("W12", 3, 7, 3, 4));
|
||||
@@ -57,6 +73,14 @@ export function buildUmbauSampleProject(): Project {
|
||||
renovation: E2,
|
||||
},
|
||||
];
|
||||
// Möbel im Westraum und im Anbau, Bäume östlich des Hauses.
|
||||
const drawings2d: Drawing2D[] = [
|
||||
...base.drawings2d,
|
||||
furniture("M1", "lib:sofa-2", 0.85, 2.0, undefined, Math.PI / 2),
|
||||
furniture("M2", "lib:tisch-80x140", 1.65, 2.0, D1),
|
||||
furniture("M3", "lib:sofa-2", 1.5, 5.6, E2),
|
||||
];
|
||||
const trees: Tree[] = [...(base.trees ?? []), tree("B1", 7.4, 1.2, "remove"), tree("B2", 9.4, 4.6, "new")];
|
||||
return {
|
||||
...base,
|
||||
id: "beispiel-umbau",
|
||||
@@ -66,6 +90,8 @@ export function buildUmbauSampleProject(): Project {
|
||||
openings,
|
||||
ceilings,
|
||||
rooms,
|
||||
drawings2d,
|
||||
trees,
|
||||
renovation: {
|
||||
phases: [
|
||||
{ id: "etappe-1", name: "Etappe 1" },
|
||||
|
||||
@@ -1052,6 +1052,10 @@ export type Drawing2D = {
|
||||
* Verhalten (ohne `hatchId` keine Schraffur).
|
||||
*/
|
||||
hatchSource?: AttributeSource;
|
||||
/**
|
||||
* [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe — auch für Objekte der Bibliothek (Möbel). Fehlt ⇒ Bestand.
|
||||
*/
|
||||
renovation?: Renovation;
|
||||
/**
|
||||
* [272] Variante, zu der das Element gehört (`Project.designOptionSets`). Fehlt ⇒ Hauptmodell (immer sichtbar).
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user