[68] [T6] [112] [G5] Baugrube: Griffe, Arbeitsraum, Verbau, Überlagerung; Höhenlinien-Lücke, Raster-Glättung, Luftbild-Farben; Achsen-Beschriftung/Blasenseite, IfcGrid; Gauben-Hinweis
TODO.md nachgeführt (30.10.): Offen-Listen der vier Einträge aktualisiert.
This commit is contained in:
38 files changed
+1074
-78
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import type { Project, Roof } from "../model/types";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { affectedKeys, dormerKey, dormerStatus, newlyAffected } from "./dormerStatus";
|
||||
|
||||
/** Satteldach 10 × 8 m, 45°, First bei y = 4, mit einer Sattelgaube bei y = 1. */
|
||||
function withDormer(frontHeight: number): Project {
|
||||
const roof = {
|
||||
id: "R1",
|
||||
type: "roof",
|
||||
floorId: "F",
|
||||
categoryCode: "35",
|
||||
outline: [{ x: 0, y: 0 }, { x: 10, y: 0 }, { x: 10, y: 8 }, { x: 0, y: 8 }],
|
||||
shape: "sattel",
|
||||
pitchDeg: 45,
|
||||
overhang: 0.5,
|
||||
ridgeAxis: "x",
|
||||
baseElevation: 3,
|
||||
thickness: 0.3,
|
||||
dormers: [{ id: "D1", kind: "sattel", position: { x: 3, y: 1 }, width: 2.4, frontHeight }],
|
||||
} as unknown as Roof;
|
||||
return { ...sampleProject, roofs: [roof] };
|
||||
}
|
||||
|
||||
describe("dormerStatus [G5]", () => {
|
||||
it("meldet nichts ohne Gauben", () => {
|
||||
expect(dormerStatus({ ...sampleProject, roofs: [] })).toEqual([]);
|
||||
});
|
||||
|
||||
it("meldet die am First gekappte Gaube mit tatsächlicher Höhe", () => {
|
||||
const ok = dormerStatus(withDormer(1.6));
|
||||
expect(ok).toHaveLength(1);
|
||||
expect(ok[0]).toMatchObject({ roofId: "R1", dormerId: "D1", clamped: false, invalid: false });
|
||||
const hi = dormerStatus(withDormer(6));
|
||||
expect(hi[0].clamped).toBe(true);
|
||||
expect(hi[0].effectiveHeight).toBeLessThan(6);
|
||||
expect(hi[0].effectiveHeight).toBeGreaterThan(0.3);
|
||||
});
|
||||
|
||||
it("newlyAffected nur beim Übergang auf gekappt", () => {
|
||||
const before = affectedKeys(dormerStatus(withDormer(1.6)));
|
||||
const now = dormerStatus(withDormer(6));
|
||||
expect(newlyAffected(before, now).map(dormerKey)).toEqual(["R1/D1"]);
|
||||
expect(newlyAffected(affectedKeys(now), now)).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,33 @@
|
||||
// Gauben ([G5]): Zustand aus dem Rust-Kern (`dormer.rs::status`). Eine zu hohe Gaube wird am First gekappt
|
||||
// (`clamped`) oder ist nicht herstellbar (`invalid`) — die Hülle zeigt das als Hinweis (Objekt-Info, Toast).
|
||||
|
||||
import type { Project } from "../model/types";
|
||||
import { documentFor } from "../core/document";
|
||||
|
||||
export interface DormerStatus {
|
||||
roofId: string;
|
||||
dormerId: string;
|
||||
/** Über den First hinaus und darum gekappt. */
|
||||
clamped: boolean;
|
||||
/** Nicht herstellbar (zu schmal/niedrig, Punkt nicht in einer geneigten Fläche …). */
|
||||
invalid: boolean;
|
||||
/** Tatsächliche Stirnhöhe (m) nach dem Kappen; 0 bei `invalid`. */
|
||||
effectiveHeight: number;
|
||||
}
|
||||
|
||||
/** Zustand aller Gauben (leer ohne Gauben, ohne Kernaufruf). */
|
||||
export function dormerStatus(project: Project): DormerStatus[] {
|
||||
if (!(project.roofs ?? []).some((r) => (r.dormers ?? []).length > 0)) return [];
|
||||
return documentFor(project).query<DormerStatus[]>("dormerStatus");
|
||||
}
|
||||
|
||||
/** Schlüssel einer Gaube für Mengenvergleiche. */
|
||||
export const dormerKey = (s: Pick<DormerStatus, "roofId" | "dormerId">) => `${s.roofId}/${s.dormerId}`;
|
||||
|
||||
/** Gauben, die jetzt gekappt/ungültig sind, vorher aber nicht (`before` = Schlüssel des vorigen Stands). */
|
||||
export function newlyAffected(before: ReadonlySet<string>, now: readonly DormerStatus[]): DormerStatus[] {
|
||||
return now.filter((s) => (s.clamped || s.invalid) && !before.has(dormerKey(s)));
|
||||
}
|
||||
|
||||
/** Schlüssel der gekappten/ungültigen Gauben. */
|
||||
export const affectedKeys = (now: readonly DormerStatus[]): Set<string> => new Set(now.filter((s) => s.clamped || s.invalid).map(dormerKey));
|
||||
@@ -64,3 +64,41 @@ describe("[T6] Gelände aus Höhenlinien", () => {
|
||||
expect(Math.max(...zs)).toBeGreaterThan(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe("[68] Arbeitsraum, Verbau, Überlagerung", () => {
|
||||
const pit = (id: string, dx: number, extra: object = {}) => ({
|
||||
id,
|
||||
type: "excavation" as const,
|
||||
name: id,
|
||||
outline: [{ x: -5 + dx, y: -5 }, { x: 5 + dx, y: -5 }, { x: 5 + dx, y: 5 }, { x: -5 + dx, y: 5 }],
|
||||
bottom: -3,
|
||||
slope: 45,
|
||||
...extra,
|
||||
});
|
||||
const terrain = project().context![0];
|
||||
const withPits = (...pits: ReturnType<typeof pit>[]): Project => ({ ...project(), context: [terrain, ...pits] });
|
||||
|
||||
it("Arbeitsraum vergrössert Sohle und Abtrag", () => {
|
||||
const [plain] = excavationQuantities(withPits(pit("a", 0)));
|
||||
const [ws] = excavationQuantities(withPits(pit("a", 0, { workingSpace: 1 })));
|
||||
expect(ws.bottomArea).toBeCloseTo(144, 6);
|
||||
expect(ws.cut).toBeGreaterThan(plain.cut * 1.3);
|
||||
});
|
||||
|
||||
it("senkrechter Verbau: Abtrag ≈ Sohle × Tiefe", () => {
|
||||
const [q] = excavationQuantities(withPits(pit("a", 0, { edgeShoring: [true, true, true, true] })));
|
||||
expect(Math.abs(q.cut - 300) / 300).toBeLessThan(0.03);
|
||||
});
|
||||
|
||||
it("überlappende Baugruben: Summe zählt die Überlagerung einmal", () => {
|
||||
const [single] = excavationQuantities(withPits(pit("a", 0)));
|
||||
const same = excavationQuantities(withPits(pit("a", 0), pit("b", 0)));
|
||||
expect(same.map((q) => q.id)).toEqual(["a", "b"]);
|
||||
expect(same[0].cut + same[1].cut).toBeCloseTo(single.cut, 3);
|
||||
expect(same[1].bottomArea).toBeLessThan(1);
|
||||
const shifted = excavationQuantities(withPits(pit("a", 0), pit("b", 6)));
|
||||
const sum = shifted[0].cut + shifted[1].cut;
|
||||
expect(sum).toBeGreaterThan(single.cut);
|
||||
expect(sum).toBeLessThan(2 * single.cut - 10);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user