[113][T2] Wände bearbeiten: Verrunden mit Radius an Bogenwänden, Fasen, gegenläufiges Verketten, 2D-Kurven an Wänden

- Verrunden mit Radius jetzt auch Bogen–Gerade und Bogen–Bogen (Kern `cmd_wall_edit.rs`: Mittelpunkt aus
  den Schnitten der um ±r versetzten Träger, Berührpunkte in den behaltenen Bereichen, nächst der Ecke;
  Bogenwand tangential dazwischen). Gerade–Gerade unverändert über `kernel2d::fillet_corner`.
- Fasen zweier Wände (`chamferWalls`, Befehl „Fasen": erster Klick auf eine Wand statt einer Ecke → zweite
  Wand, Zahl = Distanz): Enden im Abstand vor dem Achsschnittpunkt (Bogenlänge bei Bogenwänden), gerade
  Wand dazwischen; 0 = L-Ecke.
- Verketten gegenläufiger Wände (gerade kollinear, Bogen auf demselben Kreis mit umgekehrtem Drehsinn): die
  erste behält Laufrichtung/Schichtseite, Öffnungen der gekehrten behalten die Weltlage, Türen kehren
  Aufschlag und Scharnier; Bemassungs-Bezüge folgen.
- 2D-Kurven stutzen/verlängern an Wänden (Achse bzw. Option „Fläche", gerade und Bogen; beim Verlängern
  gewinnt die nähere Grenze, Bogen-Enden bleiben auf ihrem Kreis).
- Wand-Schritt „Zweite Wand" (Verrunden/Fasen) ohne Bezugspunkt: getippte Zahl ist Radius/Distanz statt
  Distanz-Lock eines Punkts (war vorher auch beim Verrunden falsch).

Tests: Rust (Verrunden Bogen/Gerade und Bogen/Bogen inkl. Tangente und Öffnung, Fasen gerade/Bogen,
gegenläufiges Verketten mit Tür und Bemassung, 2D-Trim/Extend an Wänden inkl. Bogenwand und
Polylinien-Bogen), vitest (`wallEdit.test.ts`), e2e (`wallEditFillet.spec.ts`: Bogenwand verrunden, Fasen,
je ein Undo-Schritt). Geprüft im Linux-Container (cargo test Kern, tsc, vitest, Chromium-e2e), nicht in der
Tauri-App.
This commit is contained in:
Claude committed 2026-11-10 09:21:12 +00:00
1 parent 977cbee260
commit 0052edfdac
11 files changed
+758 -83

No files matched your search

+45 -5
View File
@@ -7,6 +7,10 @@
//
// Anders als Fillet braucht Chamfer KEINE Bogen-Tessellierung — die Fasung
// ist von Natur aus gerade, also ein exaktes (nicht approximiertes) Ergebnis.
// Wände ([113]): trifft der erste Klick keine Ecke, aber eine Wand, folgt „Zweite Wand" (Zahl =
// Distanz, Vorgabe 0 = L-Ecke am Achsschnittpunkt): beide Wände enden im Abstand vor dem Schnittpunkt
// (bei Bogenwänden als Bogenlänge), eine gerade Wand (Kopie der ersten) verbindet die Enden. Rechnung
// im Kern (`cmd_wall_edit.rs`, `chamfer`).
import { cmdMutation } from "../../core";
import type {
@@ -21,6 +25,7 @@ import type {
} from "../types";
import { cornerPreview, pickCorner } from "./cornerHit";
import type { CornerHit } from "./cornerHit";
import { cmdQuery, decodeShapes, pair } from "../../tools/coreCmd";
const DEFAULT_DISTANCE = 0.1; // m — Startwert, bis der Nutzer per Maus/Tab einen eigenen setzt
const EPS = 1e-6;
@@ -47,7 +52,21 @@ interface ChamferDistance extends CommandState {
interface ChamferDone extends CommandState {
phase: "done";
}
type ChamferState = ChamferPick | ChamferDistance | ChamferDone;
/** Wände: erste Wand getroffen (statt einer Polylinien-Ecke), jetzt die zweite wählen. */
interface ChamferWall2 extends CommandState {
phase: "wall2";
wall: string;
p1: Vec2;
}
type ChamferState = ChamferPick | ChamferDistance | ChamferDone | ChamferWall2;
/** Fasen-Distanz an Wänden (0 = scharfe L-Ecke), bleibt über Aufrufe. */
let wallDistance = 0;
function wallDraft(ctx: CommandContext, s: ChamferWall2, point: Vec2): ToolDraft {
const r = cmdQuery<{ hit: boolean; shapes: number[] }>(ctx.project, { q: "chamferWalls", level: ctx.level.id, id: s.wall, p1: pair(s.p1), pt: pair(point), d: wallDistance });
return { preview: decodeShapes(r.shapes), vertices: [s.p1], hud: { at: point, text: `D: ${wallDistance.toFixed(3)}m${r.hit ? "" : " ✗"}` } };
}
const finish = (): [CommandState, CommandResult] => [
{ phase: "done", lastPoint: null } as ChamferDone,
@@ -57,9 +76,11 @@ const finish = (): [CommandState, CommandResult] => [
export const chamferCommand: Command = {
name: "chamfer",
labelKey: "cmd.chamfer.label",
prompt: (s) =>
(s as ChamferState).phase === "distance" ? "cmd.chamfer.distance" : "cmd.chamfer.pick",
accepts: (s) => ((s as ChamferState).phase === "distance" ? ["point", "number"] : ["point"]),
prompt: (s) => {
const ph = (s as ChamferState).phase;
return ph === "distance" ? "cmd.chamfer.distance" : ph === "wall2" ? "cmd.chamfer.wall2" : "cmd.chamfer.pick";
},
accepts: (s) => ((s as ChamferState).phase === "distance" || (s as ChamferState).phase === "wall2" ? ["point", "number"] : ["point"]),
options: () => [],
fields: (s) => ((s as ChamferState).phase === "distance" ? DISTANCE_FIELDS : []),
@@ -71,7 +92,12 @@ export const chamferCommand: Command = {
if (s.phase === "pick") {
if (input.kind !== "point") return [s, { draft: null }];
const { hit, preview } = pickCorner(ctx.project, ctx.level.id, input.point, "chamfer", DEFAULT_DISTANCE);
if (!hit) return [s, { draft: null }]; // daneben geklickt → aktiv bleiben
if (!hit) {
const wall = cmdQuery<{ hit: string | null }>(ctx.project, { q: "pickWall", level: ctx.level.id, pt: pair(input.point) }).hit;
if (!wall) return [s, { draft: null }]; // daneben geklickt → aktiv bleiben
const w2: ChamferWall2 = { phase: "wall2", wall, p1: input.point, lastPoint: null };
return [w2, { draft: { preview: [], vertices: [input.point] } }];
}
const next: ChamferDistance = {
phase: "distance",
hit,
@@ -80,6 +106,19 @@ export const chamferCommand: Command = {
};
return [next, { draft: chamferDraft(hit, preview, next.distance, input.point) }];
}
if (s.phase === "wall2") {
if (input.kind === "number") {
wallDistance = Math.max(0, input.value);
return [s, { draft: null }];
}
if (input.kind !== "point") return [s, { draft: null }];
const id2 = cmdQuery<{ hit: string | null }>(ctx.project, { q: "pickWall", level: ctx.level.id, pt: pair(input.point) }).hit;
if (!id2 || id2 === s.wall) return [s, { draft: null }];
return [
{ phase: "done", lastPoint: null } as ChamferDone,
{ draft: null, done: true, commit: cmdMutation({ cmd: "chamferWalls", id: s.wall, p1: pair(s.p1), id2, p2: pair(input.point), d: wallDistance }) },
];
}
// phase === "distance"
let d = s.distance;
if (input.kind === "number") d = Math.max(0, input.value);
@@ -98,6 +137,7 @@ export const chamferCommand: Command = {
if (!hit) return [s, { draft: null }];
return [s, { draft: chamferDraft(hit, preview, DEFAULT_DISTANCE, point) }];
}
if (s.phase === "wall2") return [s, { draft: wallDraft(ctx, s, point) }];
if (s.phase !== "distance") return [s, { draft: null }];
const d = Math.max(0, dist(s.hit.corner, point));
const ns: ChamferDistance = { ...s, distance: d };
+2 -1
View File
@@ -11,7 +11,8 @@
// • Wiederholend, bis Esc/Enter.
//
// Wände ([113], gerade und Bogen) verlängert der Kern bis zur nächsten Wandachse/-fläche, 2D-Kurve
// oder Rasterachse (Bogenwände auf demselben Kreis).
// oder Rasterachse (Bogenwände auf demselben Kreis). 2D-Kurven reichen umgekehrt auch bis an Wände
// (Achse bzw. Option „Fläche"; die nähere Grenze gewinnt).
//
// Geschlossene Formen (rect, geschlossene polyline) und reine Punktformen
// (circle/arc/text) sind nicht extend-fähig — ein geschlossener Ring hat kein
+4 -3
View File
@@ -6,7 +6,8 @@
// wird gewählt; ein einzelnes `line`-Element hat keine eigene Ecke)
// 2) „Radius:" → Punkt (Abstand von der Ecke) ODER getippte Zahl → commit
// Wände ([113]): trifft der erste Klick keine Ecke, aber eine Wand, folgt „Zweite Wand“ (Zahl =
// Radius, Vorgabe 0 = L-Ecke am Achsschnittpunkt; Radius nur bei geraden Wänden → Bogenwand).
// Radius, Vorgabe 0 = L-Ecke am Achsschnittpunkt; mit Radius → Bogenwand tangential dazwischen, auch an
// Bogenwänden).
//
// Die Verrundung wird als ECHTES Bogen-Segment gespeichert (`bulge`, s.
// `geometry/bulge.ts`), nicht mehr tesselliert — editierbar wie jeder andere
@@ -58,7 +59,7 @@ interface FilletDone extends CommandState {
}
/**
* Wände ([113]): erste Wand getroffen (statt einer Polylinien-Ecke), jetzt die zweite wählen. Beide
* werden bis zum Achsschnittpunkt gestutzt/verlängert (L-Ecke); mit Radius > 0 (nur gerade Wände)
* werden bis zum Achsschnittpunkt gestutzt/verlängert (L-Ecke); mit Radius > 0 (gerade und Bogenwände)
* schliesst eine Bogenwand tangential an.
*/
interface FilletWall2 extends CommandState {
@@ -103,7 +104,7 @@ export const filletCommand: Command = {
if (!hit) {
const wall = cmdQuery<{ hit: string | null }>(ctx.project, { q: "pickWall", level: ctx.level.id, pt: pair(input.point) }).hit;
if (!wall) return [s, { draft: null }]; // daneben geklickt → aktiv bleiben
const w2: FilletWall2 = { phase: "wall2", wall, p1: input.point, lastPoint: input.point };
const w2: FilletWall2 = { phase: "wall2", wall, p1: input.point, lastPoint: null };
return [w2, { draft: { preview: [], vertices: [input.point] } }];
}
const next: FilletRadius = { phase: "radius", hit, radius: DEFAULT_RADIUS, lastPoint: input.point };
+2 -1
View File
@@ -14,7 +14,8 @@
// Vorschau rechnet der Kern (`src-tauri/core/src/cmd_edit.rs`, [K4] S3); hier nur
// der Zustandsautomat. Wände (gerade und Bogen, [113]) gehen genauso: Klick auf den wegzuschneidenden
// Teil; Schneider sind die anderen Wände (Achse/Fläche), 2D-Kurven und Achsraster. Sowohl Ziel-Kurve
// als auch Schneider dürfen Bogen-Segmente (bulge) tragen.
// als auch Schneider dürfen Bogen-Segmente (bulge) tragen. 2D-Kurven werden auch an Wänden gestutzt
// (Achse bzw. Option „Fläche", gerade und Bogenwände).
//
// Bezeichner englisch, Kommentare/UI deutsch (CONVENTIONS.md).
+51 -1
View File
@@ -12,6 +12,7 @@ import { breakCommand } from "./break";
import { filletCommand } from "./fillet";
import { joinCommand } from "./join";
import { offsetCommand } from "./offset";
import { chamferCommand } from "./chamfer";
const level = sampleProject.drawingLevels.find((l) => l.kind === "floor")!;
const wt = sampleProject.wallTypes[0].id;
@@ -28,7 +29,9 @@ const wall = (id: string, a: [number, number], b: [number, number], bulge?: numb
});
const opening = (id: string, host: string, position: number): Opening =>
({ id, type: "opening", hostWallId: host, categoryCode: "21", kind: "window", position, width: 1, height: 1.2, sillHeight: 0.9 }) as Opening;
const proj = (walls: Wall[], openings: Opening[] = []): Project => ({ ...sampleProject, walls, openings, drawings2d: [], rooms: [], ceilings: [], stairs: [] });
const proj = (walls: Wall[], openings: Opening[] = [], drawings2d: Project["drawings2d"] = []): Project => ({ ...sampleProject, walls, openings, drawings2d, rooms: [], ceilings: [], stairs: [] });
const line2d = (id: string, a: [number, number], b: [number, number]) =>
({ id, type: "drawing2d", levelId: level.id, categoryCode: "20", geom: { shape: "line", a: { x: a[0], y: a[1] }, b: { x: b[0], y: b[1] } } }) as Project["drawings2d"][number];
function run(cmd: Command, p: Project, inputs: CmdInput[], wallIds: string[] = []): Project {
const ctx: CommandContext = {
@@ -120,4 +123,51 @@ describe("Wand-Editierbefehle ([113])", () => {
expect(o.walls).toHaveLength(2);
expect(Math.abs(o.walls[1].start.y)).toBeCloseTo(2, 9);
});
it("Verrunden mit Radius an einer Bogenwand: tangentiale Bogenwand, Öffnung bleibt", () => {
// Halbkreis R 5 um (0,0) oben herum, Gerade x = 3 nach oben; Schnitt (3,4).
const p = proj([wall("a", [-5, 0], [5, 0], 1), wall("b", [3, -2], [3, 8])], [opening("o", "a", 1)]);
const out = run(filletCommand, p, [pt(-4, 3), { kind: "number", value: 1 }, pt(3, 7)]);
run(filletCommand, p, [pt(-4, 3), { kind: "number", value: 0 }]);
expect(out.walls).toHaveLength(3);
const cy = Math.sqrt(32);
expect(byId(out, "a").end.x).toBeCloseTo(10 / 6, 9);
expect(byId(out, "a").end.y).toBeCloseTo((5 * cy) / 6, 9);
expect(byId(out, "b").start).toMatchObject({ x: 3 });
expect(byId(out, "b").start.y).toBeCloseTo(cy, 9);
const f = out.walls.find((w) => w.id !== "a" && w.id !== "b")!;
expect(f.bulge).toBeTruthy();
expect(out.openings![0]).toMatchObject({ hostWallId: "a", position: 1 });
});
it("Fasen zweier Wände: gerade Wand zwischen den Enden, Distanz getippt", () => {
const p = proj([wall("a", [0, 0], [4, 0]), wall("b", [6, 5], [6, -2])]);
const out = run(chamferCommand, p, [pt(2, 0), { kind: "number", value: 1 }, pt(6, 3)]);
run(chamferCommand, p, [pt(2, 0), { kind: "number", value: 0 }]);
expect(byId(out, "a").end).toEqual({ x: 5, y: 0 });
expect(byId(out, "b").end).toEqual({ x: 6, y: 1 });
const f = out.walls.find((w) => w.id !== "a" && w.id !== "b")!;
expect(f.start).toEqual({ x: 5, y: 0 });
expect(f.end).toEqual({ x: 6, y: 1 });
expect(f.bulge).toBeUndefined();
expect(f.wallTypeId).toBe(wt);
});
it("Verketten gegenläufiger Wände: Tür behält Weltlage, Aufschlag und Scharnier gekehrt", () => {
const door = { ...opening("d", "b", 1), kind: "door", swing: "left", hinge: "start" } as Opening;
const p = proj([wall("a", [0, 0], [4, 0]), wall("b", [10, 0], [4, 0])], [door]);
const j = run(joinCommand, p, [], ["a", "b"]);
expect(j.walls).toHaveLength(1);
expect(j.walls[0].end).toEqual({ x: 10, y: 0 });
expect(j.openings![0]).toMatchObject({ hostWallId: "a", position: 8, swing: "right", hinge: "end" });
});
it("2D-Linien an Wänden stutzen und verlängern", () => {
const p = proj([wall("a", [-5, 0], [5, 0])], [], [line2d("l", [2, -3], [2, 3])]);
const t = run(trimCommand, p, [pt(2, 2)]);
expect(t.walls).toHaveLength(1);
expect(t.drawings2d).toHaveLength(1);
expect((t.drawings2d[0].geom as { b: { x: number; y: number } }).b).toEqual({ x: 2, y: 0 });
const e = run(extendCommand, proj([wall("a", [-5, 0], [5, 0])], [], [line2d("l", [2, -3], [2, -1])]), [pt(2, -1.1)]);
expect((e.drawings2d[0].geom as { b: { x: number; y: number } }).b).toEqual({ x: 2, y: 0 });
});
});
+1
View File
@@ -2137,6 +2137,7 @@ export const de = {
"cmd.chamfer.label": "Fasen",
"cmd.chamfer.pick": "Ecke wählen:",
"cmd.chamfer.distance": "Distanz:",
"cmd.chamfer.wall2": "Zweite Wand wählen (Zahl = Distanz):",
// Multiline: Basislinie + N-1 parallele Kopien in einer Geste (baut auf Offset auf).
"cmd.multiline.label": "Parallellinien",
"cmd.multiline.start": "Startpunkt:",
+1
View File
@@ -2125,6 +2125,7 @@ export const en: Record<TranslationKey, string> = {
"cmd.chamfer.label": "Chamfer",
"cmd.chamfer.pick": "Select corner:",
"cmd.chamfer.distance": "Distance:",
"cmd.chamfer.wall2": "Select second wall (number = distance):",
// Multiline: base line + N-1 parallel copies in one gesture (builds on Offset).
"cmd.multiline.label": "Parallel lines",
"cmd.multiline.start": "Start point:",