[222] Volumenstudie → Bauteile: Körper in Aussenwände je Geschoss, Decken und Flachdach umwandeln

Neuer Befehl solidtoparts (koerperinbauteile): gewählter Körper oder Klick; ein Undo-Schritt.
Kern cmd_massing.rs: bestehende Geschosse nutzen, fehlende obenauf anlegen; Wände mit
Aussenfläche auf der Körperkante (Referenz left), Decken/Dach wie beim Zeichnen
(ceiling_item/roof_item aus cmd_create.rs), Körper entfällt. Nicht abgedeckte Körper
(verjüngt, Kugel/Kegel, verrundet, Abzugskörper, selbstschneidend, UK zwischen Geschossen)
werden mit Meldung abgelehnt. Tests: Rust, vitest, e2e [222] statt fixme.
This commit is contained in:
Claude committed 2026-11-13 09:41:52 +00:00
1 parent af556d3e28
commit 27f7df8098
15 files changed
+817 -27

No files matched your search

+1 -1
View File
@@ -29,7 +29,7 @@ Ribbon-Befehle sie erreichen: `src/state/useToolInput.ts`.
| Gruppe | Module |
|---|---|
| Bauteile | `wall.ts`, `opening.ts`, `ceiling.ts`, `ceilingOpening.ts`, `roof.ts`, `roofHole.ts`, `roofWindow.ts`, `dormer.ts`, `stair.ts`, `column.ts`, `room.ts`, `grid.ts`, `tree.ts`, `terrain.ts`, `excavation.ts` |
| Körper | `solid.ts`, `solidbool.ts`, `voidbox.ts`, `extrude.ts`, `revolve.ts`, `loft.ts` |
| Körper | `solid.ts`, `solidbool.ts`, `solidToParts.ts` (Körper → Bauteile, [222]), `voidbox.ts`, `extrude.ts`, `revolve.ts`, `loft.ts` |
| 2D zeichnen | `line.ts`, `xline.ts`, `ray.ts`, `polyline.ts`, `polygon.ts`, `rect.ts`, `circle.ts`, `arc.ts`, `ellipse.ts`, `bezier.ts`, `spline.ts`, `multiline.ts`, `revcloud.ts`, `wipeout.ts`, `block.ts`, `defblock.ts` |
| Beschriften | `text.ts`, `textbox.ts`, `textpath.ts`, `leader.ts`, `dimension.ts`, `dimround.ts`, `dimdetach.ts`, `autodim.ts`, `kote.ts`, `detailref.ts`, `pointmarker.ts`, `scalebar.ts`, `sectionline.ts` |
| Bearbeiten | `transform.ts` (Bewegen, Drehen, Spiegeln), `copy.ts`, `scale.ts`, `array.ts`, `align.ts`, `offset.ts`, `trim.ts`, `extend.ts`, `fillet.ts`, `chamfer.ts`, `cornerHit.ts`, `break.ts`, `split.ts`, `join.ts`, `explode.ts` |
+108
View File
@@ -0,0 +1,108 @@
/**
* [222] „Körper in Bauteile umwandeln": gewählter Körper → Aussenwände je Geschoss, Decken, Flachdach (ein Commit),
* fehlende Geschosse obenauf; Unsinn (verjüngt, UK zwischen Geschossen) mit Meldung abgelehnt; ohne Auswahl Klick.
*/
import { describe, it, expect } from "vitest";
import { solidToPartsCommand } from "./solidToParts";
import { resolveCommand } from "../registry";
import type { CommandContext, Project } from "../types";
import type { ExtrudedSolid } from "../../model/types";
/** L-förmiger Körper (konkav) 10 × 8 m, Höhe `h`, auf dem EG. */
const solid = (h: number, extra: Partial<ExtrudedSolid> = {}): ExtrudedSolid => ({
id: "K",
type: "extrudedSolid",
levelId: "eg",
categoryCode: "90",
points: [{ x: 0, y: 0 }, { x: 10, y: 0 }, { x: 10, y: 4 }, { x: 4, y: 4 }, { x: 4, y: 8 }, { x: 0, y: 8 }],
height: h,
...extra,
});
function project(s: ExtrudedSolid): Project {
return {
id: "t",
name: "T",
lineStyles: [],
hatches: [],
components: [{ id: "c", name: "Beton", color: "#999999" }] as Project["components"],
wallTypes: [{ id: "aw", name: "Aussenwand", layers: [{ componentId: "c", thickness: 0.3 }] }],
ceilingTypes: [{ id: "ct", name: "Decke", layers: [{ componentId: "c", thickness: 0.25 }] }],
drawingLevels: [{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 3, cutHeight: 1.0, baseElevation: 0 }],
layers: [
{ code: "20", name: "Wände", color: "#000000", lw: 0.5, visible: true, locked: false },
{ code: "90", name: "Körper", color: "#000000", lw: 0.25, visible: true, locked: false },
],
walls: [],
openings: [],
ceilings: [],
stairs: [],
rooms: [],
drawings2d: [],
context: [],
extrudedSolids: [s],
} as Project;
}
const ctxOf = (p: Project, solidId: string | null): CommandContext =>
({
project: p,
level: p.drawingLevels[0],
defaultCategoryCode: "90",
activeLineStyleId: "solid",
activeWallTypeId: "aw",
lastPoint: null,
selection: { wallIds: [], drawingId: null, drawingIds: [], extrudedSolidId: solidId },
}) as CommandContext;
describe("solidToPartsCommand", () => {
it("Name und Kürzel", () => {
expect(resolveCommand("solidtoparts")?.name).toBe("solidtoparts");
expect(resolveCommand("koerperinbauteile")?.name).toBe("solidtoparts");
});
it("gewählter Körper 9 m: drei Geschosse (zwei neu), 6 Wände je Geschoss, 2 Decken, Flachdach, Körper weg", () => {
const p = project(solid(9));
const r = solidToPartsCommand.autoRun!(ctxOf(p, "K"));
expect(r.done).toBe(true);
expect(r.notice).toMatchObject({ key: "cmd.solidtoparts.done", params: { stories: 3, newFloors: 2, walls: 18, ceilings: 2 } });
const next = r.commit!(p);
expect(next.extrudedSolids ?? []).toHaveLength(0);
const floors = next.drawingLevels.filter((l) => l.kind === "floor");
expect(floors.map((f) => [f.name, f.baseElevation, f.floorHeight])).toEqual([
["EG", 0, 3],
["Geschoss 2", 3, 3],
["Geschoss 3", 6, 3],
]);
expect(next.walls).toHaveLength(18);
expect(next.walls.every((w) => w.wallTypeId === "aw" && w.height === 3 && w.referenceLine === "left" && w.isExternal)).toBe(true);
expect(next.walls.filter((w) => w.floorId === "eg")).toHaveLength(6);
expect((next.ceilings ?? []).map((c) => c.ceilingTypeId)).toEqual(["ct", "ct"]);
expect(next.roofs).toHaveLength(1);
expect(next.roofs![0]).toMatchObject({ shape: "flach", overhang: 0, floorId: floors[2].id });
});
it("lehnt verjüngte Körper und Körper zwischen Geschossen mit Meldung ab (kein Commit)", () => {
const tapered = solidToPartsCommand.autoRun!(ctxOf(project(solid(6, { taper: 0.4 })), "K"));
expect(tapered).toMatchObject({ done: true, notice: { key: "cmd.solidtoparts.reject.tapered", kind: "warning" } });
expect(tapered.commit).toBeUndefined();
const floating = solidToPartsCommand.autoRun!(ctxOf(project(solid(6, { baseOffset: 1.3 })), "K"));
expect(floating.notice?.key).toBe("cmd.solidtoparts.reject.base");
expect(floating.commit).toBeUndefined();
});
it("ohne Auswahl: Klick in den Körper wandelt um, Klick daneben meldet", () => {
const p = project(solid(3));
const ctx = ctxOf(p, null);
expect(solidToPartsCommand.autoRun!(ctx).done).toBeFalsy();
const [, miss] = solidToPartsCommand.onInput(solidToPartsCommand.init(), { kind: "point", point: { x: 8, y: 7 } }, ctx);
expect(miss.commit).toBeUndefined();
expect(miss.notice?.key).toBe("cmd.solidtoparts.noSolid");
const [, hit] = solidToPartsCommand.onInput(solidToPartsCommand.init(), { kind: "point", point: { x: 1, y: 1 } }, ctx);
const next = hit.commit!(p);
expect(next.walls).toHaveLength(6);
expect(next.ceilings).toHaveLength(0);
expect(next.roofs).toHaveLength(1);
});
});
+67
View File
@@ -0,0 +1,67 @@
// [222] Volumenstudie → Bauteile: ein gewählter Körper (Massenmodell) wird zu Aussenwänden je Geschoss, Decken
// und Flachdach; fehlende Geschosse legt der Kern obenauf an, der Körper entfällt. Ein Undo-Schritt.
// Ist ein Körper gewählt, läuft der Befehl sofort; sonst „Körper wählen“ (Klick in seine Grundfläche).
// Rechnung und Prüfung im Kern (`cmd_massing.rs`); was er nicht abdeckt (geneigt, Kugel/Kegel/Torus, verrundet, Abzugskörper,
// selbstschneidend, UK zwischen Geschossen), lehnt der Befehl mit einer Meldung ab.
import type { Command, CommandContext, CommandResult, CommandState } from "../types";
import { createMutation, createQuery, xy } from "../createCore";
import { t, type TranslationKey } from "../../i18n";
/** Ergebnis der Prüfung im Kern (`cmd_massing::check`). */
export interface SolidToPartsCheck {
ok: boolean;
reason: string | null;
stories?: number;
newFloors?: number;
walls?: number;
ceilings?: number;
}
/** Namensmuster neuer Geschosse („Geschoss {n}“, der Kern setzt die Nummer ein). */
const floorName = (): string => t("default.floorName");
export function checkSolidToParts(ctx: CommandContext, id: string): SolidToPartsCheck {
return createQuery<SolidToPartsCheck>(ctx.project, { q: "solidToParts", id, floorName: floorName() });
}
/** Umwandeln (Commit + Meldung) oder ablehnen (nur Meldung). */
function convert(ctx: CommandContext, id: string): CommandResult {
const c = checkSolidToParts(ctx, id);
if (!c.ok) {
return { draft: null, done: true, notice: { key: `cmd.solidtoparts.reject.${c.reason ?? "none"}` as TranslationKey, kind: "warning" } };
}
return {
draft: null,
done: true,
commit: createMutation(ctx, { cmd: "solidToParts", id, floorName: floorName() }),
notice: { key: "cmd.solidtoparts.done", params: { stories: c.stories ?? 0, newFloors: c.newFloors ?? 0, walls: c.walls ?? 0, ceilings: c.ceilings ?? 0 }, kind: "info" },
};
}
const idle = (): CommandState => ({ phase: "pick", lastPoint: null });
export const solidToPartsCommand: Command = {
name: "solidtoparts",
labelKey: "cmd.solidtoparts.label",
floorOnly: true,
prompt: () => "cmd.solidtoparts.pick",
accepts: () => ["point"],
options: () => [],
init: idle,
autoRun: (ctx): CommandResult => {
const id = ctx.selection.extrudedSolidId;
return id ? convert(ctx, id) : { draft: null };
},
onInput: (state, input, ctx): [CommandState, CommandResult] => {
if (input.kind !== "point") return [state, { draft: null }];
const hit = createQuery<{ hit: string | null }>(ctx.project, { q: "pickSolid", level: ctx.level.id, pt: xy(input.point) }).hit;
if (!hit) return [state, { draft: null, notice: { key: "cmd.solidtoparts.noSolid", kind: "info" } }];
return [idle(), convert(ctx, hit)];
},
onMove: (state): [CommandState, CommandResult] => [state, { draft: null }],
onConfirm: (): [CommandState, CommandResult] => [idle(), { draft: null, done: true }],
onCancel: (): [CommandState, CommandResult] => [idle(), { draft: null, done: true }],
};
+4
View File
@@ -17,6 +17,7 @@ import { circlesToTreesCommand, treeCommand } from "./cmds/tree";
import { roofCommand } from "./cmds/roof";
import { solidCommand } from "./cmds/solid";
import { solidBoolCommand } from "./cmds/solidbool";
import { solidToPartsCommand } from "./cmds/solidToParts";
import { voidBoxCommand } from "./cmds/voidbox";
import { ceilingOpeningCommand } from "./cmds/ceilingOpening";
import { roofWindowCommand } from "./cmds/roofWindow";
@@ -93,6 +94,7 @@ export const COMMANDS: Record<string, Command> = {
roof: roofCommand,
solid: solidCommand,
solidbool: solidBoolCommand,
solidtoparts: solidToPartsCommand,
voidbox: voidBoxCommand,
ceilingopening: ceilingOpeningCommand,
roofwindow: roofWindowCommand,
@@ -186,6 +188,8 @@ export const ALIASES: Record<string, string> = {
stütze: "column",
baum: "tree",
kreiseinbaeume: "circlestotrees",
koerperinbauteile: "solidtoparts",
volumenzubauteilen: "solidtoparts",
dach: "roof",
koerper: "solid",
durchbruch: "voidbox",
+13
View File
@@ -1974,6 +1974,19 @@ export const de = {
"cmd.solidbool.op.union": "Vereinigung",
"cmd.solidbool.op.difference": "Differenz",
"cmd.solidbool.op.intersection": "Durchschnitt",
"cmd.solidtoparts.label": "Körper in Bauteile umwandeln",
"cmd.solidtoparts.pick": "Körper wählen (Massenmodell):",
"cmd.solidtoparts.noSolid": "Hier liegt kein Körper.",
"cmd.solidtoparts.done": "{stories} Geschosse ({newFloors} neu): {walls} Aussenwände, {ceilings} Decken und Flachdach erzeugt.",
"cmd.solidtoparts.reject.none": "Kein Körper gewählt.",
"cmd.solidtoparts.reject.tapered": "Nur senkrechte Körper: verjüngte oder geneigte Körper lassen sich nicht umwandeln.",
"cmd.solidtoparts.reject.brep": "Nur Körper aus Grundriss × Höhe (auch Quader, Zylinder): Kugel, Kegel, Torus, Rotations- und verschnittene Körper lassen sich nicht umwandeln.",
"cmd.solidtoparts.reject.rounded": "Körper mit verrundeten oder gefasten Ecken lassen sich nicht umwandeln.",
"cmd.solidtoparts.reject.subtract": "Abzugskörper lassen sich nicht in Bauteile umwandeln.",
"cmd.solidtoparts.reject.outline": "Der Grundriss des Körpers ist selbstschneidend oder flächenlos.",
"cmd.solidtoparts.reject.height": "Der Körper ist zu niedrig (unter 0.5 m) oder zu hoch für Geschosse.",
"cmd.solidtoparts.reject.base": "Die Unterkante des Körpers liegt nicht auf einem Geschoss (OK fertig Boden).",
"cmd.solidtoparts.reject.floors": "Die Geschosse über dem Körper sind nicht lückenlos gestapelt.",
"cmd.void.label": "Durchbruch",
"cmd.void.corner": "Erste Ecke des Durchbruchs:",
"cmd.void.corner2": "Gegenecke:",
+13
View File
@@ -1963,6 +1963,19 @@ export const en: Record<TranslationKey, string> = {
"cmd.solidbool.op.union": "Union",
"cmd.solidbool.op.difference": "Difference",
"cmd.solidbool.op.intersection": "Intersection",
"cmd.solidtoparts.label": "Convert solid to building parts",
"cmd.solidtoparts.pick": "Select solid (massing model):",
"cmd.solidtoparts.noSolid": "No solid here.",
"cmd.solidtoparts.done": "{stories} floors ({newFloors} new): created {walls} exterior walls, {ceilings} slabs and a flat roof.",
"cmd.solidtoparts.reject.none": "No solid selected.",
"cmd.solidtoparts.reject.tapered": "Vertical solids only: tapered or sloped solids cannot be converted.",
"cmd.solidtoparts.reject.brep": "Only footprint × height solids (including boxes and cylinders): spheres, cones, tori, revolved and boolean solids cannot be converted.",
"cmd.solidtoparts.reject.rounded": "Solids with rounded or chamfered corners cannot be converted.",
"cmd.solidtoparts.reject.subtract": "Subtraction solids cannot be converted to building parts.",
"cmd.solidtoparts.reject.outline": "The solid's footprint is self-intersecting or has no area.",
"cmd.solidtoparts.reject.height": "The solid is too low (under 0.5 m) or too tall for floors.",
"cmd.solidtoparts.reject.base": "The bottom of the solid does not sit on a floor (finished floor level).",
"cmd.solidtoparts.reject.floors": "The floors above the solid are not stacked without gaps.",
"cmd.void.label": "Penetration",
"cmd.void.corner": "First corner of the penetration:",
"cmd.void.corner2": "Opposite corner:",
+1 -1
View File
@@ -379,7 +379,7 @@ const TOOLS_2D: ToolId[] = [
"image",
];
const TOOLS_3D: ToolId[] = ["wall", "ceiling", "window", "door", "stair", "room"];
const COMMANDS_3D = ["column", "tree", "circlestotrees", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "sectionline", "viewline", "autodim", "excavation"];
const COMMANDS_3D = ["column", "tree", "circlestotrees", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "solidtoparts", "sectionline", "viewline", "autodim", "excavation"];
const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "split", "extend", "fillet", "chamfer", "join", "defblock", "measure", "erkennen"];
type ToolsView = "list" | "icons";
+8
View File
@@ -308,6 +308,14 @@ export const CommandIcon = memo(function CommandIcon({ name }: { name: string })
<circle cx="10" cy="9.5" r="3.6" />
</svg>
);
case "solidtoparts":
// [222] Körper → Bauteile: Quader mit Geschosslinien und Dachplatte.
return (
<svg {...common}>
<rect x="3.5" y="4.5" width="9" height="9" />
<path d="M2.5 3.5 H13.5 M3.5 7.5 H12.5 M3.5 10.5 H12.5" />
</svg>
);
case "solid":
// Körper: Kugel mit Äquator (B-Rep-Grundkörper).
return (