core/src/plan/extras.rs rechnet Schattenstudie und Baurecht (unterste
Gruppe, Verstösse zuoberst), zieht Abzugskörper von Wand-/Stützen-/
Decken-Poché ab, setzt Schwarz-Weiss und Strichstärken nach Massstab
beim Schreiben (Writer::post, auch drawingLines) und das Ausmass samt
Kontext. planDomains liefert 12 Gruppen; generatePlan reicht nur noch
Sichtbarkeit und Optionen weiter, der Plan bleibt immer lazy aus
Kern-Puffern. Gelöscht: generatePlan/{sunShadow,siteRules}.ts,
lineWeightScale.ts, subtractVoidsInPlan/segmentOutside (samt Bindung),
toMono, computeBounds, realignRuns.
Gleichheit: temporärer Test (gelöscht) 481 000 Primitive Feld für Feld
gegen die alte TS-Fassung (Beispiel alle Ebenen, bigSample, 120
Zufallsprojekte mit Schatten/Baurecht/Abzugskörpern/Mono/Massstab,
Kataster); CLI byte-gleich zum Stand vor beiden Schritten (96 Ausgaben).
generatePlan unverändert mit Studie/Baurecht/40 Abzugskörpern 237 ->
2,3 ms. geomTransform bleibt in TS (Begründung in TODO.md). Nicht in der
Tauri-App angesehen.
Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
43 lines
2.2 KiB
TypeScript
43 lines
2.2 KiB
TypeScript
/**
|
|
* `generatePlan` — Schattenstudie (`Project.sunStudy`): Boden-Schatten als halbtransparente
|
|
* Flächen ZUUNTERST im Grundriss des Geschosses nächst ±0.00, sonst nirgends.
|
|
*/
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
import { generatePlan } from "./generatePlan";
|
|
import { sampleProject } from "../model/sampleProject";
|
|
import { flattenCategories } from "../model/types";
|
|
import type { Project } from "../model/types";
|
|
|
|
const ALL = new Set(flattenCategories(sampleProject.layers).map((c) => c.code));
|
|
/** Füllfarbe der Schattenflächen (`core/src/plan/extras.rs::SUN_SHADOW_FILL`). */
|
|
const SUN_SHADOW_FILL = "#3a4a66";
|
|
|
|
const withStudy = (when: string, show = true): Project => ({ ...sampleProject, sunStudy: { when, show } });
|
|
const shadows = (p: Project, floorId: string) =>
|
|
generatePlan(p, floorId, ALL).primitives.filter((q) => q.kind === "polygon" && q.fill === SUN_SHADOW_FILL);
|
|
|
|
describe("Schattenstudie im Grundriss", () => {
|
|
it("Wintermittag: Schatten im EG, zuunterst gezeichnet", () => {
|
|
const p = withStudy("2026-12-21T11:00:00Z");
|
|
expect(shadows(p, "eg").length).toBeGreaterThan(0);
|
|
const first = generatePlan(p, "eg", ALL).primitives[0];
|
|
expect(first.kind === "polygon" && first.fill === SUN_SHADOW_FILL).toBe(true);
|
|
});
|
|
it("nicht im OG, nicht ausgeschaltet, nicht nachts, nicht ohne Studie", () => {
|
|
expect(shadows(withStudy("2026-12-21T11:00:00Z"), "og")).toEqual([]);
|
|
expect(shadows(withStudy("2026-12-21T11:00:00Z", false), "eg")).toEqual([]);
|
|
expect(shadows(withStudy("2026-12-21T22:00:00Z"), "eg")).toEqual([]);
|
|
expect(shadows(sampleProject, "eg")).toEqual([]);
|
|
});
|
|
it("ungültiges Datum → kein Schatten, kein Absturz", () => {
|
|
expect(shadows(withStudy("kein Datum"), "eg")).toEqual([]);
|
|
});
|
|
it("Planbegrenzung schliesst den ganzen Schatten ein (Druck/Einpassen)", () => {
|
|
const plan = generatePlan(withStudy("2026-12-21T11:00:00Z"), "eg", ALL);
|
|
const ys = shadows(withStudy("2026-12-21T11:00:00Z"), "eg").flatMap((q) => (q.kind === "polygon" ? q.pts.map((p) => p.y) : []));
|
|
expect(plan.bounds.maxY).toBeGreaterThanOrEqual(Math.max(...ys) - 1e-9);
|
|
expect(plan.bounds.maxY).toBeGreaterThan(generatePlan(sampleProject, "eg", ALL).bounds.maxY);
|
|
});
|
|
});
|