Files
DOSSIER/src/model/standards.test.ts
T
Claude 7a980d32d3 [166] Dämm-Striche (EPS/XPS) quer zur Wand in allen Ausgaben
Ursache: Die Ausgaben lasen den Schraffur-Winkel von Geraden-/Kreuzscharen um 90° verschieden.
Szene (Bildschirm render2d, PDF-Export sceneToPrintSvg) und SVG-Kachel: Winkel 0 = Musterlinie
senkrecht; CLI-SVG (plan/svg.rs), Druck-SVG der Layout-Blätter (plan/print_svg.rs, hatch_lines)
und DXF-HATCH: Winkel 0 = Linie waagrecht. Darum pendelte der Standard „Dämmstoffe (SIA-Linien)"
zwischen 0° und 90° (5.11. auf 90° nach dem CLI-Bild: dort quer, auf dem Bildschirm/PDF längs).
Zusätzlich ignorierten CLI-/Druck-SVG die polare Schraffur der Bogenwand (Striche im Sehnenwinkel),
und die Anschlag-Nasen an Öffnungen einer Bogenwand standen im Winkel der abgewickelten Ersatzwand.

Fix:
- plan/svg.rs, plan/print_svg.rs: alle Vektor-Schraffuren über hatch::build_hatch_runs (wie Szene);
  eigene Linienschar hatch_lines/fill_parallel/is_generated entfernt.
- plan/dxf.rs: Scharwinkel = 90° − Schraffur-Winkel (Lesart der Szene), in [0°, 180°).
- standards.rs: std-h-daemmstoffe-sia wieder 0° relativ zur Wand (= quer).
- project_format.rs: beim Laden 90° dieser Standard-Schraffur auf 0° zurückgestellt (Dateien 5.–9.11.).
- plan/walls.rs: Schichtstücke an Öffnungen einer Bogenwand polar schraffiert (polar_layer_pieces).

Test: plan/hatch_dir_tests.rs prüft die tatsächlich gezeichneten Linien der Dämmschicht in Szene,
CLI-SVG und Druck-SVG (1:50 und 1:20): gerade Wand in 9 Drehlagen, Bogen (4), Ecken 90/135/60° gedreht,
Y, T, Y mit Bogenast, kollinear, Wand an/durch Stütze (auch rund, schräg), Fenster mit Anschlag in
schräger Wand und Bogenwand — Winkel zur lokalen Wandachse 90° ± 1°; Schnitt mit Wand, Decke und
geneigtem Dach (quer zur Schicht). Vorher: Szene längs (0°), Bogen-Nasen 54°.
Goldens: komplex-model3d (Hash, Schraffur-Winkel im 3D-Modell); DXF-Test Kreuzschar [90, 0].

Geprüft: cargo test Kern, tsc, vitest; Musterhaus komplex EG/OG 1:50/1:20 und Schnitt A-A 1:50
als Szene und CLI-SVG vorher/nachher angesehen (Linux/Chromium), weiche Dämmung/Zickzack angesehen.
Nicht geprüft: Tauri-App/Mac, render3d-Live-Schnitt.
2026-11-09 15:53:53 +00:00

120 lines
6.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.
import { describe, expect, it } from "vitest";
import { emptyProject, sampleProject } from "./sampleProject";
import { componentLayerFunctions, hiddenElementIds, LAYER_FUNCTIONS, standardsChangeKey, standardsMergeCounts, standardsMergeOps, standardsUpdateOps, standardsUpdatePlan, withStandards } from "./standards";
import { applyOps } from "../core/ops";
describe("Standard-Bibliothek ([100]–[102])", () => {
it("bringt Baustoffe, Linientypen und Aufbauten in ein neues Projekt", () => {
const p = withStandards({ ...emptyProject, components: [], hatches: [], lineStyles: [], wallTypes: [], ceilingTypes: [], roofTypes: [] });
const stb = p.components.find((c) => c.name === "Stahlbeton")!;
expect(stb.lambda).toBe(2.3);
expect(stb.fireClass).toBe("RF1");
expect(p.hatches.some((h) => h.id === stb.hatchId)).toBe(true);
expect(p.components.find((c) => c.name === "Backstein")!.surfacePattern?.kind).toBe("runningBond");
expect(p.lineStyles.find((l) => l.name === "Strichpunktlinie (Achse)")!.dash).toEqual([12, 1.5, 0, 1.5]);
expect(p.wallTypes.map((t) => t.name)).toContain("Holzständerwand hinterlüftet");
expect(p.ceilingTypes?.length).toBe(1);
expect(p.roofTypes?.length).toBe(1);
expect(standardsMergeOps(p)).toEqual([]);
});
it("verdoppelt im bestehenden Projekt nichts und nutzt gleichnamige Einträge", () => {
const p = withStandards(sampleProject);
const names = p.components.map((c) => c.name.toLowerCase());
expect(names.filter((n) => n === "backstein").length).toBe(1);
// Beispiel-Bauteil „Backstein" (id brick) bleibt und wird vom Standard-Aufbau benutzt
const iw = p.wallTypes.find((t) => t.id === "std-wt-iw-backstein")!;
expect(iw.layers[1].componentId).toBe("brick");
expect(p.components.length).toBeGreaterThan(sampleProject.components.length);
expect(standardsMergeOps(p)).toEqual([]);
});
it("zählt, was „Standards laden“ hinzufügt (Rückmeldung)", () => {
const empty = { ...emptyProject, components: [], hatches: [], lineStyles: [], wallTypes: [], ceilingTypes: [], roofTypes: [] };
const c = standardsMergeCounts(standardsMergeOps(empty));
expect(c.components).toBe(35);
expect(c.lineStyles).toBeGreaterThan(5);
expect(c.wallTypes + c.ceilingTypes + c.roofTypes).toBe(5);
expect(c.overrideRules).toBe(2);
expect(standardsMergeCounts(standardsMergeOps(withStandards(empty)))).toEqual({ lineStyles: 0, hatches: 0, components: 0, wallTypes: 0, ceilingTypes: 0, roofTypes: 0, viewTemplates: 0, blockDefs: 0, overrideRules: 0 });
});
it("Sinnbilder nach SIA 400 Fig. 34: Putz leer, Dämmung quer, Beton gekreuzt", () => {
const p = withStandards({ ...emptyProject, components: [], hatches: [], lineStyles: [], wallTypes: [], ceilingTypes: [], roofTypes: [] });
const hatchOf = (name: string) => p.hatches.find((h) => h.id === p.components.find((c) => c.name === name)!.hatchId)!;
expect(hatchOf("Innenputz").pattern).toBe("none");
expect(hatchOf("Aussenputz").pattern).toBe("none");
expect(hatchOf("Beton").pattern).toBe("crosshatch");
expect(hatchOf("EPS").pattern).toBe("diagonal");
// [166] Winkel 0 relativ zur Wand = Striche quer zur Wandachse (90° wäre längs).
expect(hatchOf("EPS").angle).toBe(0);
expect(hatchOf("Holzwerkstoff (OSB/Spanplatte)").pattern).toBe("woodBased");
expect(hatchOf("Keramikplatten").pattern).toBe("crosshatch");
expect(hatchOf("Faserzementplatten").pattern).toBe("diagonal");
});
it("„Standards aktualisieren“: alte Definitionen auf heutigen Stand, Auswahl, ein Op-Satz", () => {
const full = withStandards({ ...emptyProject, components: [], hatches: [], lineStyles: [], wallTypes: [], ceilingTypes: [], roofTypes: [] });
expect(standardsUpdatePlan(full).changes).toEqual([]);
// Stand 31.10. früh: SIA-Parallelen unter dem früheren Namen „SIA Dämmstoffe“, Putz-Schraffur fehlt, Kalksandstein umbenannt
const old = {
...full,
hatches: full.hatches
.filter((h) => h.id !== "std-h-putz")
.map((h) =>
h.id === "std-h-daemmung-weich"
? { ...h, name: "SIA Dämmstoffe", pattern: "diagonal" as const }
: h.id === "std-h-kalksandstein"
? { ...h, name: "Mein KS", pattern: "crosshatch" as const }
: h,
),
components: full.components.map((c) => (c.id === "std-c-innenputz" ? { ...c, hatchId: "std-h-ohne" } : c)),
};
const plan = standardsUpdatePlan(old);
expect(plan.added).toBe(1);
expect(plan.changes.map((c) => c.id).sort()).toEqual(["std-c-innenputz", "std-h-daemmung-weich", "std-h-kalksandstein"]);
expect(plan.changes.find((c) => c.id === "std-h-kalksandstein")!.renamed).toBe(true);
expect(plan.changes.find((c) => c.id === "std-h-daemmung-weich")!.renamed).toBe(false);
const selected = plan.changes.filter((c) => !c.renamed).map(standardsChangeKey);
const after = applyOps(old, standardsUpdateOps(old, selected));
const dae = after.hatches.find((h) => h.id === "std-h-daemmung-weich")!;
expect([dae.name, dae.pattern]).toEqual(["SIA Dämmung weich", "insulation"]);
expect(after.hatches.find((h) => h.id === "std-h-kalksandstein")!.pattern).toBe("crosshatch");
expect(after.components.find((c) => c.id === "std-c-innenputz")!.hatchId).toBe("std-h-putz");
expect(standardsUpdatePlan(after).changes.map((c) => c.id)).toEqual(["std-h-kalksandstein"]);
});
});
describe("[33] Schichtfunktion aus dem Baustoff", () => {
it("Vorgabe je Bauteil wie im Kern (Estrich, Beton, Trittschall)", () => {
const p = withStandards({ ...emptyProject, components: [], hatches: [], lineStyles: [], wallTypes: [], ceilingTypes: [], roofTypes: [] });
const f = componentLayerFunctions(p);
expect([f["std-c-zementestrich"], f["std-c-stahlbeton"], f["std-c-trittschall"], f["std-c-innenputz"]]).toEqual(["screed", "structure", "insulation", "plaster"]);
expect(Object.keys(f).length).toBe(p.components.length);
for (const v of Object.values(f)) expect(v === null || LAYER_FUNCTIONS.includes(v)).toBe(true);
});
});
describe("[33] hiddenElementIds", () => {
it("liefert die per Regel ausgeblendeten Wände samt ihren Öffnungen, nur in der genannten Darstellung", () => {
expect(hiddenElementIds(sampleProject, 100).size).toBe(0);
const p = {
...sampleProject,
overrideRules: [
{
id: "h",
name: "Wände aus",
enabled: true,
condition: { type: "element_kind" as const, operator: "equals" as const, value: "wall" },
conditions: [{ type: "view_kind" as const, operator: "equals" as const, value: "plan" }],
actions: { hide: true },
},
],
} as typeof sampleProject;
const ids = hiddenElementIds(p, 100);
for (const w of p.walls) expect(ids.has(w.id)).toBe(true);
for (const o of p.openings ?? []) expect(ids.has(o.id)).toBe(true);
expect(hiddenElementIds(p, 100, "section").size).toBe(0);
});
});