Files
DOSSIER/src/plan/generatePlan.corner.test.ts
T
Claude ce631273a6 [140] Plandarstellung Teil 5: Schnittflächen 1:100 schwarz, dünne Schichten, Raumstempel im L-Raum
- Schnittflächen ab 1:100 (mittel; grob immer) als schwarze Fläche ohne Fugen/Schraffur, nur Umriss:
  Wände, Stützen, Körper im Grundriss, alle geschnittenen Bauteile im Schnitt (style::solid_cut).
  1:50 und „fein" schraffiert; Feld cutHatch an Ebene/Ansichtsvorlage übersteuert das 1:100.
- Dünne Schichten: gemeinsame Regel in plan/style.rs (unter 0.5 mm Papier, ab 1:50, nicht „fein")
  für Wände im Grundriss, Schnitt-Schichten und dünne Dämmung.
- Raumstempel: Anker = Pol der Unzugänglichkeit (room_area::label_point), Platz aus dem Raumumriss
  (rect_in_ring) statt Bounding-Box, Ausweichen im Raum, Breite aus Inter-Schriftmetrik
  (text_layout::text_width_em, stamp_block_size); neue Räume ohne festen Anker.
- Goldens neu, TODO.md nachgeführt.
2026-11-06 15:39:04 +00:00

145 lines
5.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Unit-Tests für die Wandecken-Gehrung im Grundriss (generatePlan):
* • KEINE 45°-Naht zwischen gleichfarbigen Schichten zweier Wände am Knoten
* (die inneren Gehrungs-Stirnkanten tragen `noStrokeEdges`).
* • KEIN überschießender Umriss-Barb: die Gehrungs-Diagonale ist der Umriss
* nicht mehr gestrichen; die Cut-Ecken sitzen exakt auf den Fläche×Fläche-
* Apexen (sauberer Miter, kein Overshoot).
* • Freie (rechtwinklige) Wandenden bleiben voll umrissen (kein noStrokeEdges).
*/
import { describe, it, expect } from "vitest";
import { generatePlan } from "./generatePlan";
import type { Project, Wall } from "../model/types";
/** Minimalprojekt: zwei Wände, die in (5,0) eine 90°-L-Ecke bilden. */
function cornerProject(): Project {
const wall = (id: string, start: Wall["start"], end: Wall["end"]): Wall => ({
id,
type: "wall",
floorId: "eg",
categoryCode: "20",
start,
end,
wallTypeId: "aw",
height: 2.6,
});
return {
id: "t",
name: "T",
lineStyles: [{ id: "thin", name: "d", weight: 0.13, color: "#111", dash: null }],
hatches: [{ id: "none", name: "Ohne", pattern: "none", scale: 1, angle: 0, color: "#111" }],
components: [
{ id: "a", name: "A", color: "#d8d2c7", hatchId: "none", joinPriority: 10 },
{ id: "b", name: "B", color: "#8c5544", hatchId: "none", joinPriority: 50 },
],
wallTypes: [
{
id: "aw",
name: "AW",
layers: [
{ componentId: "a", thickness: 0.1 },
{ componentId: "b", thickness: 0.245 },
],
},
],
drawingLevels: [
{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0, cutHatch: true },
],
layers: [{ code: "20", name: "Wände", color: "#0a0a0a", lw: 0.5, visible: true, locked: false }],
walls: [
// W1 endet in (5,0); W2 startet in (5,0) → geteilter Knoten (L-Ecke).
wall("W1", { x: 0, y: 0 }, { x: 5, y: 0 }),
wall("W2", { x: 5, y: 0 }, { x: 5, y: 4 }),
],
openings: [],
ceilings: [],
stairs: [],
rooms: [],
drawings2d: [],
context: [],
};
}
const visible = new Set(["20"]);
describe("generatePlan — Wandecken-Gehrung", () => {
it("markiert die Gehrungs-Stirnkante am Knoten als nicht zu stricheln (keine Naht/Barbe)", () => {
const plan = generatePlan(cornerProject(), "eg", visible, undefined, "mittel");
const wallPolys = plan.primitives.filter(
(p): p is Extract<typeof p, { kind: "polygon" }> =>
p.kind === "polygon" && p.wallId != null,
);
expect(wallPolys.length).toBeGreaterThan(0);
// JEDES Wandpolygon (Schichtbänder + Umriss) trägt an genau EINEM Ende die
// Gehrungs-Stirnkante: W1 am Endcut (Kante 1), W2 am Startcut (Kante 3).
const w1 = wallPolys.filter((p) => p.wallId === "W1");
const w2 = wallPolys.filter((p) => p.wallId === "W2");
expect(w1.length).toBeGreaterThan(0);
expect(w2.length).toBeGreaterThan(0);
for (const p of w1) expect(p.noStrokeEdges).toEqual([1]);
for (const p of w2) expect(p.noStrokeEdges).toEqual([3]);
});
it("legt die Umriss-Cut-Ecken exakt auf die Fläche×Fläche-Apexe (sauberer Miter, kein Overshoot)", () => {
const plan = generatePlan(cornerProject(), "eg", visible, undefined, "mittel");
// Der Wand-Umriss ist das letzte Wandpolygon je Wand (fill:"none").
const outlineW1 = plan.primitives.filter(
(p): p is Extract<typeof p, { kind: "polygon" }> =>
p.kind === "polygon" && p.wallId === "W1" && p.fill === "none",
);
expect(outlineW1.length).toBe(1);
const o = outlineW1[0];
// clippedBand-Reihenfolge [A.start, A.end, B.end, B.start]; A.end/B.end sind
// die getrimmten Enden am Knoten. T=0.345, half=0.1725. Aussen-Apex=(5.1725,
// -0.1725), Innen-Apex=(4.8275, 0.1725) — der EXAKTE 90°-Miter ohne Überstand.
const half = 0.345 / 2;
expect(o.pts[1].x).toBeCloseTo(5 + half, 4); // A.end (Aussenfläche)
expect(o.pts[1].y).toBeCloseTo(-half, 4);
expect(o.pts[2].x).toBeCloseTo(5 - half, 4); // B.end (Innenfläche)
expect(o.pts[2].y).toBeCloseTo(half, 4);
});
it("lässt freie (rechtwinklige) Wandenden voll umrissen (kein noStrokeEdges dort)", () => {
// Nur W1 allein → beide Enden frei, kein Knoten.
const proj = cornerProject();
proj.walls = [proj.walls[0]];
const plan = generatePlan(proj, "eg", visible, undefined, "mittel");
const wallPolys = plan.primitives.filter(
(p): p is Extract<typeof p, { kind: "polygon" }> =>
p.kind === "polygon" && p.wallId === "W1",
);
expect(wallPolys.length).toBeGreaterThan(0);
for (const p of wallPolys) expect(p.noStrokeEdges).toEqual([]);
});
});
describe("generatePlan — Schichtfugen als stilisierbare Linien", () => {
const jointLines = (proj: Project) =>
generatePlan(proj, "eg", visible, undefined, "mittel").primitives.filter(
(p): p is Extract<typeof p, { kind: "line" }> =>
p.kind === "line" && p.cls === "layer-joint",
);
it("zieht die innere Fuge als eigene Linie: Farbe/Muster vom LineStyle, Stärke von der Schicht ([110])", () => {
const proj = cornerProject();
proj.walls = [proj.walls[0]]; // nur W1, zwei Schichten → genau eine innere Fuge
proj.wallTypes[0].layers[0].jointLineStyleId = "thin"; // color #111
proj.wallTypes[0].layers[0].jointWeightMm = 0.13;
const joints = jointLines(proj);
expect(joints.length).toBe(1);
// LAYER_DETAIL_FACTOR["mittel"] == 1 → die Fugen-Stärke der Schicht wirkt direkt.
expect(joints[0].weightMm).toBeCloseTo(0.13, 6);
expect(joints[0].color).toBe("#111");
expect(joints[0].dash ?? null).toBeNull();
});
it("fällt ohne Zuweisung auf die feine Fuge (0.09 mm, [140]) in Wandfarbe zurück", () => {
const proj = cornerProject();
proj.walls = [proj.walls[0]];
const joints = jointLines(proj);
expect(joints.length).toBe(1);
expect(joints[0].weightMm).toBeCloseTo(0.09, 6);
});
});