Merge branch 'worktree-agent-a6b600eecf6bd85ef' into claude/practical-noether-1hb2s1

# Conflicts:
#	src-tauri/core/src/plan/context.rs
#	src/plan/__golden__/komplex-ansicht-ansicht-sued.txt
This commit is contained in:
Claude committed 2026-11-11 05:37:26 +00:00
commit 2213a674d4
53 files changed
+680 -81

No files matched your search

@@ -1,12 +1,12 @@
viewBox -4.2 0 37.045 17.378
bytes 197406
bytes 194324
circle 4
g 1
line 436
line 546
path 2
polygon 1053
polyline 156
polygon 1045
polyline 44
rect 1
svg 1
text 4
hash 1b43e968eef4f52b
hash 9ddddce6f17fcd6d
@@ -1,11 +1,11 @@
viewBox 4.457 0 21.343 17.378
bytes 28680
bytes 28250
circle 4
g 1
line 39
line 37
polygon 141
polyline 16
polyline 14
rect 1
svg 1
text 3
hash d2dde45c8a663cfa
hash 9cdb25c298a73bb1
+96
View File
@@ -0,0 +1,96 @@
// [180] Alles Sichtbare liegt auf einer Klasse (Vorgabe Maintainer): Grundriss (alle Geschosse), Schnitte und
// Ansichten beider Musterhäuser sind leer, wenn alle Klassen ausgeblendet sind; jede Klasse der abgeleiteten
// Darstellung (Schatten, Auto-Bemassung, Höhenkoten, Schnittmarken) nimmt genau ihre Primitive mit.
// Kern-Gegenstück mit dem Fixture-Projekt: `src-tauri/core/src/plan/derived_class_tests.rs`.
import { describe, expect, it } from "vitest";
import { computeSection, generateElevationPlan, generatePlan, generateSectionPlan, levelMarksEnabled } from "../core";
import { sampleProject, emptyProject } from "../model/sampleProject";
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
import { withStandards } from "../model/standards";
import { flattenCategories } from "../model/layers";
import { AUTO_DIM_CATEGORY, DERIVED_CATEGORY_CODES, LEVEL_MARK_CATEGORY, SECTION_MARK_CATEGORY, SHADOW_CATEGORY } from "../model/derivedCategories";
import type { Primitive } from "./generatePlan";
import type { Project } from "../model/types";
const SHOW_ALL = () => ({ render: true, greyed: false, locked: false });
const allCodes = (p: Project) => new Set(flattenCategories(p.layers).map((c) => c.code));
const without = (s: Set<string>, code: string) => new Set([...s].filter((c) => c !== code));
const projects: [string, () => Project][] = [
["muster", () => sampleProject],
["komplex", buildComplexSampleProject],
];
const floorPlan = (p: Project, floor: string, codes: Set<string>): readonly Primitive[] =>
generatePlan(p, floor, codes, SHOW_ALL, "mittel", false, false, true, 100).primitives;
const elevation = (p: Project, id: string, codes: Set<string>): readonly Primitive[] =>
generateElevationPlan(p, p.drawingLevels.find((l) => l.id === id)!, { scaleDenominator: 100, visibleCodes: codes, categoryDisplay: SHOW_ALL })?.primitives ?? [];
const describeLeft = (prims: readonly Primitive[]) =>
prims.slice(0, 5).map((q) => JSON.stringify(q).slice(0, 160));
describe("[180] Klassen der abgeleiteten Darstellung", () => {
it('„Standards laden“ legt sie an (Codes wie im Kern)', () => {
const codes = allCodes(withStandards({ ...emptyProject, layers: [] }));
for (const c of DERIVED_CATEGORY_CODES) expect(codes.has(c), c).toBe(true);
// Die Musterprojekte haben sie schon.
for (const c of DERIVED_CATEGORY_CODES) expect(allCodes(sampleProject).has(c), c).toBe(true);
});
for (const [name, make] of projects) {
describe(name, () => {
const p = make();
const all = allCodes(p);
for (const lvl of p.drawingLevels.filter((l) => l.kind === "floor")) {
it(`Grundriss ${lvl.id}: ohne Klassen leer`, () => {
expect(floorPlan(p, lvl.id, all).length).toBeGreaterThan(0);
const rest = floorPlan(p, lvl.id, new Set());
expect(rest.length, describeLeft(rest).join("\n")).toBe(0);
});
}
for (const lvl of p.drawingLevels.filter((l) => l.kind === "section")) {
it(`Schnitt ${lvl.id}: ohne Klassen leer`, async () => {
const out = (await computeSection(p, lvl))!;
const plan = (codes: Set<string>) => generateSectionPlan(out, false, { visibleCodes: codes, categoryDisplay: SHOW_ALL, openings: true, scaleDenominator: 100 }).primitives;
expect(plan(all).length).toBeGreaterThan(0);
const rest = plan(new Set());
expect(rest.length, describeLeft(rest).join("\n")).toBe(0);
expect(levelMarksEnabled({ ...lvl, levelMarks: true }, p, (c) => all.has(c))).toBe(true);
expect(levelMarksEnabled({ ...lvl, levelMarks: true }, p, (c) => c !== LEVEL_MARK_CATEGORY)).toBe(false);
}, 30_000);
}
for (const lvl of p.drawingLevels.filter((l) => l.kind === "elevation")) {
it(`Ansicht ${lvl.id}: ohne Klassen leer, Schlagschatten auf „Schatten“`, () => {
const shaded = { ...p, drawingLevels: p.drawingLevels.map((l) => (l.id === lvl.id ? { ...l, shadows: true } : l)) };
const full = elevation(shaded, lvl.id, all);
expect(full.length).toBeGreaterThan(0);
const rest = elevation(shaded, lvl.id, new Set());
expect(rest.length, describeLeft(rest).join("\n")).toBe(0);
const shadows = (v: readonly Primitive[]) => v.filter((q) => q.kind === "polygon" && q.contextObjectId === "@viewShadows").length;
expect(shadows(full)).toBeGreaterThan(0);
expect(shadows(elevation(shaded, lvl.id, without(all, SHADOW_CATEGORY)))).toBe(0);
});
}
});
}
it("komplex EG: Schatten, Auto-Bemassung und Schnittmarken einzeln aus", () => {
const p = buildComplexSampleProject();
const all = allCodes(p);
const full = floorPlan(p, "eg", all);
const count = (v: readonly Primitive[], hit: (q: Primitive) => boolean) => v.filter(hit).length;
const sun = (q: Primitive) => q.kind === "polygon" && q.contextObjectId === "@sunStudy";
const autodim = (q: Primitive) => "drawingId" in q && typeof q.drawingId === "string" && q.drawingId.startsWith("autodim-");
const marks = (q: Primitive) => q.kind === "polygon" && !!q.sectionLineId;
for (const [code, hit] of [[SHADOW_CATEGORY, sun], [AUTO_DIM_CATEGORY, autodim], [SECTION_MARK_CATEGORY, marks]] as const) {
const n = count(full, hit);
expect(n, code).toBeGreaterThan(0);
const off = floorPlan(p, "eg", without(all, code));
expect(count(off, hit), code).toBe(0);
}
// Die Aussenbemassung trägt ihre Klasse (je Kette änderbar).
expect(p.drawings2d.filter((d) => d.id.startsWith("autodim-")).every((d) => d.categoryCode === AUTO_DIM_CATEGORY)).toBe(true);
});
});
+1 -1
View File
@@ -3,7 +3,7 @@ import type { ExtrudedSolid } from "../model/types";
import { extrudedSolidSpec, needsBrepPath } from "./extrudedSolidSpec";
const sq = [{ x: 0, y: 0 }, { x: 2, y: 0 }, { x: 2, y: 2 }, { x: 0, y: 2 }];
const base: ExtrudedSolid = { id: "e1", type: "extrudedSolid", levelId: "eg", points: sq, height: 3 };
const base: ExtrudedSolid = { id: "e1", type: "extrudedSolid", categoryCode: "20", levelId: "eg", points: sq, height: 3 };
describe("extrudedSolidSpec", () => {
it("Prisma ohne Besonderheiten bleibt auf dem alten Pfad", () => {
+11 -8
View File
@@ -4,7 +4,7 @@
* (cls "section-line"), Endmarken + ein unsichtbares Pick-Band (Polygon mit
* `sectionLineId`). Ebenen OHNE Linie erzeugen nichts.
*
* Sichtbarkeit läuft über die feste Kategorie "90" (Referenzen) — NICHT über
* Sichtbarkeit läuft über die Standard-Klasse "91" (Schnittmarken, [180]; früher "90" Referenzen) — NICHT über
* das eigene `visible`-Flag der Schnitt-/Ansichtsebene (Nutzer-Feedback: "das
* sollten Elemente sein, die sich auf einer Ebene befinden und nur damit
* ein-/ausgeblendet werden"). Das Flag ist daher für dieses Symbol wirkungslos.
@@ -15,7 +15,7 @@ import { generatePlan } from "./generatePlan";
import type { CategoryDisplayResolver } from "./generatePlan";
import type { DrawingLevel, Project } from "../model/types";
const visible = new Set(["20", "35", "90"]);
const visible = new Set(["20", "35", "90", "91"]);
function baseProject(levels: DrawingLevel[]): Project {
return {
@@ -26,7 +26,10 @@ function baseProject(levels: DrawingLevel[]): Project {
components: [],
wallTypes: [],
drawingLevels: levels,
layers: [{ code: "20", name: "Wände", color: "#333", lw: 0.18, visible: true, locked: false }],
layers: [
{ code: "20", name: "Wände", color: "#333", lw: 0.18, visible: true, locked: false },
{ code: "91", name: "Schnittmarken", color: "#1a1a1a", lw: 0.18, visible: true, locked: false },
],
walls: [],
openings: [],
ceilings: [],
@@ -106,7 +109,7 @@ describe("generatePlan — Schnittführungs-Symbol", () => {
expect(prims.some((pr) => pr.kind === "line" && pr.cls === "section-line")).toBe(false);
});
it("zeichnet TROTZDEM, auch wenn die Schnittebene selbst visible=false trägt (nur Kategorie '90' zählt)", () => {
it("zeichnet TROTZDEM, auch wenn die Schnittebene selbst visible=false trägt (nur die Klasse '91' zählt)", () => {
const p = baseProject([
floor,
{
@@ -123,7 +126,7 @@ describe("generatePlan — Schnittführungs-Symbol", () => {
expect(prims.some((pr) => pr.kind === "polygon" && pr.sectionLineId === "s-hidden")).toBe(true);
});
it("zeichnet NICHTS, wenn Kategorie '90' NICHT sichtbar ist (visibleCodes ohne '90')", () => {
it("zeichnet NICHTS, wenn die Klasse '91' NICHT sichtbar ist (visibleCodes ohne '91')", () => {
const p = baseProject([
floor,
{
@@ -136,11 +139,11 @@ describe("generatePlan — Schnittführungs-Symbol", () => {
directionSign: 1,
},
]);
const prims = generatePlan(p, "eg", new Set(["20", "35"])).primitives;
const prims = generatePlan(p, "eg", new Set(["20", "35", "90"])).primitives;
expect(prims.some((pr) => pr.kind === "polygon" && pr.sectionLineId === "s-cat")).toBe(false);
});
it("dimmt (greyed), wenn categoryDisplay('90') greyed liefert", () => {
it("dimmt (greyed), wenn categoryDisplay('91') greyed liefert", () => {
const p = baseProject([
floor,
{
@@ -154,7 +157,7 @@ describe("generatePlan — Schnittführungs-Symbol", () => {
},
]);
const categoryDisplay: CategoryDisplayResolver = (code) =>
code === "90" ? { render: true, greyed: true, locked: false } : { render: true, greyed: false, locked: false };
code === "91" ? { render: true, greyed: true, locked: false } : { render: true, greyed: false, locked: false };
const prims = generatePlan(p, "eg", visible, categoryDisplay).primitives;
const line = prims.find((pr) => pr.kind === "line" && pr.cls === "section-line") as
| { greyed?: boolean }
+11 -3
View File
@@ -3,20 +3,28 @@
// Gebäudes (First/OK Dach), links neben der Zeichnung mit einer kurzen
// Bezugslinie zur Geometrie. Symbol = dieselbe SIA-400-Kote wie das 2D-Element
// `kote`; gerechnet im Kern (`plan/drawings.rs::level_markers`, Abfrage `levelMarkers`).
// Abschaltbar je Ebene (`DrawingLevel.levelMarks`) oder über die Modelldarstellung ([173]).
// Abschaltbar je Ebene (`DrawingLevel.levelMarks`), über die Modelldarstellung ([173]) oder die Klasse
// „Höhenkoten" ([180]).
import type { DrawingLevel, Project } from "../model/types";
import type { Primitive } from "./generatePlan";
import { documentFor } from "../core/document";
import { decodePlanBuf } from "./planBuf";
import { derivedVisible, LEVEL_MARK_CATEGORY } from "../model/derivedCategories";
/**
* Ob eine Ebene automatische Koten trägt: Ebene > [173] Modelldarstellung der Ebene (`dimensions.levelMarks`,
* Rangfolge wie Kern `model_view::Options::level_marks`) > an.
*/
export function levelMarksEnabled(level: DrawingLevel, project?: Pick<Project, "modelViewOptions">): boolean {
export function levelMarksEnabled(
level: DrawingLevel,
project?: Pick<Project, "modelViewOptions"> & Partial<Pick<Project, "layers">>,
shown?: (code: string) => boolean,
): boolean {
const mv = level.modelViewOptionId ? project?.modelViewOptions?.find((m) => m.id === level.modelViewOptionId) : undefined;
return level.levelMarks ?? mv?.dimensions?.levelMarks ?? true;
const on = level.levelMarks ?? mv?.dimensions?.levelMarks ?? true;
// [180] Die Koten liegen auf der Klasse „Höhenkoten": ausgeblendet ⇒ ohne (`shown`: sichtbar und gezeichnet).
return on && (!shown || !project?.layers || derivedVisible(project.layers, LEVEL_MARK_CATEGORY, shown));
}
/**
+2 -2
View File
@@ -50,7 +50,7 @@ describe("Schnitt: Gelände und freie Körper", () => {
// Kugel mitten auf der Schnittebene: Position aus der Schnittlinie des Beispiels
const [px, , pz] = (await import("./toSection")).sectionPlaneFromLevel(section)!.point;
const sphere: ExtrudedSolid = {
id: "ball", type: "extrudedSolid", levelId: floor.id, height: 2,
id: "ball", type: "extrudedSolid", categoryCode: "20", levelId: floor.id, height: 2,
points: [{ x: px - 1, y: pz - 1 }, { x: px + 1, y: pz - 1 }, { x: px + 1, y: pz + 1 }, { x: px - 1, y: pz + 1 }],
brep: { spec: { kind: "sphere", center: [px, pz, 1], r: 1 }, origin: { x: px - 1, y: pz - 1 } },
};
@@ -67,7 +67,7 @@ describe("Schnitt: Gelände und freie Körper", () => {
const cy = (a.y + b.y) / 2;
const r = 2;
const ball: ExtrudedSolid = {
id: "void-ball", type: "extrudedSolid", levelId: floor.id, height: 2 * r, operation: "subtract",
id: "void-ball", type: "extrudedSolid", categoryCode: "20", levelId: floor.id, height: 2 * r, operation: "subtract",
points: [{ x: cx - r, y: cy - r }, { x: cx + r, y: cy - r }, { x: cx + r, y: cy + r }, { x: cx - r, y: cy + r }],
brep: { spec: { kind: "sphere", center: [cx, cy, 1], r }, origin: { x: cx - r, y: cy - r } },
};
+2 -2
View File
@@ -20,8 +20,8 @@ const base: Project = {
{ id: "k1", type: "column", floorId: "eg", categoryCode: "25", position: { x: 20, y: 3 }, profile: { kind: "rect", width: 0.4, depth: 0.4 }, rotation: 0, height: 2.5 },
],
extrudedSolids: [
{ id: "s1", type: "extrudedSolid", levelId: "og", points: [{ x: 30, y: 2 }, { x: 32, y: 2 }, { x: 32, y: 5 }, { x: 30, y: 5 }], height: 1.5, baseOffset: 0.5 },
{ id: "v1", type: "extrudedSolid", levelId: "eg", points: [{ x: 40, y: 0 }, { x: 41, y: 0 }, { x: 41, y: 1 }], height: 1, operation: "subtract" },
{ id: "s1", type: "extrudedSolid", categoryCode: "20", levelId: "og", points: [{ x: 30, y: 2 }, { x: 32, y: 2 }, { x: 32, y: 5 }, { x: 30, y: 5 }], height: 1.5, baseOffset: 0.5 },
{ id: "v1", type: "extrudedSolid", categoryCode: "20", levelId: "eg", points: [{ x: 40, y: 0 }, { x: 41, y: 0 }, { x: 41, y: 1 }], height: 1, operation: "subtract" },
],
} as Project;
+1 -1
View File
@@ -103,7 +103,7 @@ async function levelPlan(
}
if (!raw || raw.primitives.length === 0) return EMPTY;
const own = generatePlan(project, level.id, visibleCodes, undefined, detail, false, mono, false, scaleDenominator, forPrint, false, overrideRuleIds);
const marks = levelMarksEnabled(level, project) ? levelMarkerPrimitives(project, raw.bounds, raw.primitives) : [];
const marks = levelMarksEnabled(level, project, (c) => visibleCodes.has(c)) ? levelMarkerPrimitives(project, raw.bounds, raw.primitives) : [];
const b = { ...raw.bounds };
const grow = (x: number, y: number) => {
b.minX = Math.min(b.minX, x);
+1 -1
View File
@@ -9,7 +9,7 @@ const sq = (x0: number, y0: number, x1: number, y1: number): Pair[] => [[x0, y0]
const area = (r: Pair[]) => Math.abs(r.reduce((s, p, i) => s + p[0] * r[(i + 1) % r.length][1] - r[(i + 1) % r.length][0] * p[1], 0) / 2);
function withVoid(p: Project, v: Partial<ExtrudedSolid>): Project {
const solid: ExtrudedSolid = { id: "void1", type: "extrudedSolid", levelId: p.walls[0].floorId, operation: "subtract", height: 2, points: [], ...v };
const solid: ExtrudedSolid = { id: "void1", type: "extrudedSolid", categoryCode: "20", levelId: p.walls[0].floorId, operation: "subtract", height: 2, points: [], ...v };
return { ...p, extrudedSolids: [...(p.extrudedSolids ?? []), solid] };
}