[41][61][62][70] Kennzahlen (GF/aGF je Geschoss, GV aus Koerpern, AZ/UEZ mit Parzelle) und Raumprogramm-Pruefung; Menue, CLI kennzahlen; Tests
This commit is contained in:
1 parent
460509424e
commit
b2a1d58191
10 files changed
+259
-4
No files matched your search
+16
-1
@@ -34,7 +34,7 @@ import type {
|
||||
} from "./model/types";
|
||||
import { activePenSet, resolvePenColor, resolvePenWeight } from "./model/penSets";
|
||||
import { PenColorField } from "./ui/PenColorField";
|
||||
import { generatePlan } from "./core";
|
||||
import { generatePlan, computeKennzahlen, checkRoomProgram } from "./core";
|
||||
import type { CategoryDisplayResolver } from "./core";
|
||||
import { sectionPlaneFromLevel, sectionUAxisModel } from "./core";
|
||||
import { roofBaseElevation, roofGeometry } from "./core";
|
||||
@@ -2409,6 +2409,21 @@ export default function App() {
|
||||
})
|
||||
.catch((err) => notify(`${t("clash.failed")}: ${err instanceof Error ? err.message : String(err)}`, "error"));
|
||||
},
|
||||
onKennzahlen: () => {
|
||||
const k = computeKennzahlen(project);
|
||||
const prog = checkRoomProgram(project);
|
||||
const f = (n: number, d = 1) => n.toFixed(d);
|
||||
const lines = [
|
||||
t("kennzahlen.summary", { gf: f(k.gf), agf: f(k.agf), gv: f(k.gv) }),
|
||||
k.az !== null && k.uez !== null ? t("kennzahlen.ziffern", { az: f(k.az, 2), uez: f(k.uez, 2) }) : t("kennzahlen.noParcel"),
|
||||
];
|
||||
if (prog.rows.length > 0) {
|
||||
const bad = prog.rows.filter((r) => r.status !== "ok");
|
||||
lines.push(t("kennzahlen.program", { ok: prog.rows.length - bad.length, n: prog.rows.length }));
|
||||
for (const r of bad.slice(0, 4)) lines.push(t("kennzahlen.programIssue", { name: r.name, status: r.status }));
|
||||
}
|
||||
notify(lines.join(" — "), "info");
|
||||
},
|
||||
onUndo: undo,
|
||||
onRedo: redo,
|
||||
onDeleteSelection: deleteSelection,
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import type { Project } from "../model/types";
|
||||
import { computeKennzahlen, checkRoomProgram, solidVolume } from "./kennzahlen";
|
||||
|
||||
const sq = (x: number, y: number, s: number) => [
|
||||
{ x, y }, { x: x + s, y }, { x: x + s, y: y + s }, { x, y: y + s },
|
||||
];
|
||||
|
||||
describe("solidVolume", () => {
|
||||
it("Prisma, Kegelstumpf (taper) und Kreis", () => {
|
||||
const base = { id: "s", type: "extrudedSolid" as const, levelId: "eg", points: sq(0, 0, 2), height: 3 };
|
||||
expect(solidVolume(base)).toBeCloseTo(12, 9);
|
||||
expect(solidVolume({ ...base, taper: 1 })).toBeCloseTo(4, 9); // Pyramide = A·h/3
|
||||
const r = { ...base, circle: { center: { x: 0, y: 0 }, r: 1 } };
|
||||
expect(solidVolume(r)).toBeCloseTo(Math.PI * 3, 9);
|
||||
});
|
||||
});
|
||||
|
||||
describe("computeKennzahlen", () => {
|
||||
const rooms = (p: Project) => p.rooms ?? [];
|
||||
it("GF/aGF je Geschoss aus Räumen und Summe", () => {
|
||||
const k = computeKennzahlen(sampleProject);
|
||||
const total = rooms(sampleProject).reduce((s, r) => s + Math.abs(areaOf(r.boundary)), 0);
|
||||
expect(k.gf).toBeCloseTo(total, 6);
|
||||
expect(k.levels.reduce((s, l) => s + l.gf, 0)).toBeCloseTo(k.gf, 6);
|
||||
});
|
||||
it("Ziffern nur mit Parzellenfläche", () => {
|
||||
expect(computeKennzahlen(sampleProject).az).toBeNull();
|
||||
const k = computeKennzahlen({ ...sampleProject, parcelArea: 1000 });
|
||||
expect(k.az).toBeCloseTo(k.agf / 1000, 9);
|
||||
});
|
||||
it("Gebäudevolumen aus freien Körpern, Abzugskörper zählen negativ nicht mit", () => {
|
||||
const p: Project = {
|
||||
...sampleProject,
|
||||
extrudedSolids: [
|
||||
{ id: "a", type: "extrudedSolid", levelId: sampleProject.drawingLevels[0].id, points: sq(0, 0, 10), height: 3 } as never,
|
||||
{ id: "b", type: "extrudedSolid", levelId: sampleProject.drawingLevels[0].id, points: sq(0, 0, 1), height: 3, operation: "subtract" } as never,
|
||||
],
|
||||
};
|
||||
const k = computeKennzahlen(p);
|
||||
expect(k.gv).toBeCloseTo(300 - 3, 6);
|
||||
});
|
||||
});
|
||||
|
||||
function areaOf(pts: { x: number; y: number }[]) {
|
||||
let a = 0;
|
||||
for (let i = 0; i < pts.length; i++) { const q = pts[(i + 1) % pts.length]; a += pts[i].x * q.y - q.x * pts[i].y; }
|
||||
return a / 2;
|
||||
}
|
||||
|
||||
describe("checkRoomProgram", () => {
|
||||
it("meldet fehlend, zu klein, zu gross und überzählig", () => {
|
||||
const p: Project = {
|
||||
...sampleProject,
|
||||
rooms: [
|
||||
{ ...(sampleProject.rooms ?? [])[0], id: "r1", name: "Wohnen", boundary: sq(0, 0, 5) },
|
||||
{ ...(sampleProject.rooms ?? [])[0], id: "r2", name: "Bad", boundary: sq(10, 0, 2) },
|
||||
{ ...(sampleProject.rooms ?? [])[0], id: "r3", name: "Keller", boundary: sq(20, 0, 2) },
|
||||
],
|
||||
roomProgram: [
|
||||
{ name: "Wohnen", area: 30 },
|
||||
{ name: "Bad", area: 4 },
|
||||
{ name: "Büro", area: 12 },
|
||||
],
|
||||
};
|
||||
const r = checkRoomProgram(p);
|
||||
const by = Object.fromEntries(r.rows.map((x) => [x.name, x]));
|
||||
expect(by.Wohnen.status).toBe("zu klein"); // 25 < 30
|
||||
expect(by.Bad.status).toBe("ok");
|
||||
expect(by["Büro"].status).toBe("fehlt");
|
||||
expect(r.extra.map((e) => e.name)).toEqual(["Keller"]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,123 @@
|
||||
// Kennzahlen und Raumprogramm-Prüfung (Wettbewerbswerkzeug, [41]/[61]/[62]/[70]).
|
||||
//
|
||||
// • Flächen je Geschoss aus den Räumen (SIA 416: GF, NGF/aGF), Summe über das Gebäude.
|
||||
// • Gebäudevolumen (GV) aus den freien Körpern (Massenmodell); Abzugskörper zählen nicht mit,
|
||||
// ihr Volumen wird abgezogen.
|
||||
// • Ausnützungs-/Überbauungsziffer nur mit `project.parcelArea`.
|
||||
// • Raumprogramm (`project.roomProgram`, Soll) gegen die gezeichneten Räume.
|
||||
// Alles rein und ohne Wasm — exakt für Prismen/Kegelstümpfe/Kreise, Näherung sonst (Fasen/Rundungen).
|
||||
|
||||
import type { ExtrudedSolid, Project } from "../model/types";
|
||||
import { balance, polygonArea } from "../geometry/roomArea";
|
||||
import type { SiaCategory } from "../geometry/roomArea";
|
||||
|
||||
export interface LevelKennzahlen {
|
||||
levelId: string;
|
||||
name: string;
|
||||
/** Geschossfläche (SIA 416 GF) aus den Räumen. */
|
||||
gf: number;
|
||||
/** Anrechenbare Fläche ≈ Nettogeschossfläche NGF (NF + VF + FF). */
|
||||
agf: number;
|
||||
rooms: number;
|
||||
}
|
||||
|
||||
export interface Kennzahlen {
|
||||
levels: LevelKennzahlen[];
|
||||
gf: number;
|
||||
agf: number;
|
||||
/** Gebäudevolumen aus den freien Körpern (m³), Abzugskörper abgezogen. */
|
||||
gv: number;
|
||||
/** Bebaute Fläche ≈ GF des untersten Geschosses (m²). */
|
||||
footprint: number;
|
||||
/** Ausnützungsziffer aGF / Parzelle; `null` ohne Parzellenfläche. */
|
||||
az: number | null;
|
||||
/** Überbauungsziffer bebaute Fläche / Parzelle; `null` ohne Parzellenfläche. */
|
||||
uez: number | null;
|
||||
}
|
||||
|
||||
/** Volumen eines Extrusionskörpers (m³): Prisma, Kegel(stumpf) über `taper`, Kreis. */
|
||||
export function solidVolume(s: ExtrudedSolid): number {
|
||||
const area = s.circle ? Math.PI * s.circle.r * s.circle.r : polygonArea(s.points);
|
||||
const t = Math.min(1, Math.max(0, s.taper ?? 0));
|
||||
const k = 1 - t; // Massstab der Deckfläche
|
||||
return (area * s.height * (1 + k + k * k)) / 3;
|
||||
}
|
||||
|
||||
const finite = (n: number): number => (Number.isFinite(n) ? n : 0);
|
||||
|
||||
export function computeKennzahlen(project: Project): Kennzahlen {
|
||||
const floors = project.drawingLevels
|
||||
.filter((l) => l.kind === "floor")
|
||||
.slice()
|
||||
.sort((a, b) => (a.baseElevation ?? 0) - (b.baseElevation ?? 0));
|
||||
const rooms = project.rooms ?? [];
|
||||
const levels: LevelKennzahlen[] = floors.map((l) => {
|
||||
const mine = rooms.filter((r) => r.floorId === l.id);
|
||||
const b = balance(mine.map((r) => ({ category: r.siaCategory as SiaCategory, area: finite(polygonArea(r.boundary)) })));
|
||||
return { levelId: l.id, name: l.name, gf: b.byKey.GF, agf: b.byKey.NGF, rooms: mine.length };
|
||||
});
|
||||
const gf = levels.reduce((s, l) => s + l.gf, 0);
|
||||
const agf = levels.reduce((s, l) => s + l.agf, 0);
|
||||
let gv = 0;
|
||||
for (const s of project.extrudedSolids ?? []) {
|
||||
const v = finite(solidVolume(s));
|
||||
gv += s.operation === "subtract" ? -v : v;
|
||||
}
|
||||
const footprint = levels.find((l) => l.gf > 0)?.gf ?? 0;
|
||||
const parcel = project.parcelArea && project.parcelArea > 0 ? project.parcelArea : null;
|
||||
return {
|
||||
levels,
|
||||
gf,
|
||||
agf,
|
||||
gv: Math.max(0, gv),
|
||||
footprint,
|
||||
az: parcel ? agf / parcel : null,
|
||||
uez: parcel ? footprint / parcel : null,
|
||||
};
|
||||
}
|
||||
|
||||
export type ProgramStatus = "ok" | "zu klein" | "zu gross" | "fehlt" | "zu wenige" | "zu viele";
|
||||
|
||||
export interface ProgramRowResult {
|
||||
name: string;
|
||||
targetArea: number;
|
||||
targetCount: number;
|
||||
/** Gefundene Räume (Anzahl, Gesamtfläche). */
|
||||
count: number;
|
||||
area: number;
|
||||
status: ProgramStatus;
|
||||
}
|
||||
|
||||
export interface ProgramCheck {
|
||||
rows: ProgramRowResult[];
|
||||
/** Räume im Modell, die keiner Programmzeile zugeordnet sind. */
|
||||
extra: Array<{ id: string; name: string; area: number }>;
|
||||
}
|
||||
|
||||
/** Toleranz der Flächenprüfung (relativ zur Soll-Fläche). */
|
||||
const AREA_TOL = 0.1;
|
||||
|
||||
const norm = (s: string) => s.trim().toLowerCase();
|
||||
|
||||
/** Prüft das Raumprogramm: Räume werden über den Namen (Präfix, ohne Gross-/Kleinschreibung) zugeordnet. */
|
||||
export function checkRoomProgram(project: Project): ProgramCheck {
|
||||
const rooms = (project.rooms ?? []).map((r) => ({ id: r.id, name: r.name, cat: r.siaCategory, area: finite(polygonArea(r.boundary)) }));
|
||||
const used = new Set<string>();
|
||||
const rows: ProgramRowResult[] = (project.roomProgram ?? []).map((row) => {
|
||||
const n = norm(row.name);
|
||||
const hits = rooms.filter((r) => !used.has(r.id) && norm(r.name).startsWith(n) && (!row.siaCategory || r.cat === row.siaCategory));
|
||||
hits.forEach((h) => used.add(h.id));
|
||||
const targetCount = Math.max(1, row.count ?? 1);
|
||||
const area = hits.reduce((s, h) => s + h.area, 0);
|
||||
const target = row.area * targetCount;
|
||||
let status: ProgramStatus;
|
||||
if (hits.length === 0) status = "fehlt";
|
||||
else if (hits.length < targetCount) status = "zu wenige";
|
||||
else if (hits.length > targetCount) status = "zu viele";
|
||||
else if (area < target * (1 - AREA_TOL)) status = "zu klein";
|
||||
else if (area > target * (1 + AREA_TOL)) status = "zu gross";
|
||||
else status = "ok";
|
||||
return { name: row.name, targetArea: row.area, targetCount, count: hits.length, area, status };
|
||||
});
|
||||
return { rows, extra: rooms.filter((r) => !used.has(r.id)).map((r) => ({ id: r.id, name: r.name, area: r.area })) };
|
||||
}
|
||||
+10
-2
@@ -8,7 +8,7 @@
|
||||
// dossier-cli <projekt.obp> plan [--level EG] [--scale 100] [--out eg.svg]
|
||||
// dossier-cli <projekt.obp> section <Name> [--out schnitt.svg] (braucht render3d-WASM)
|
||||
// dossier-cli <projekt.obp> elevation <Name> [--out ansicht.svg]
|
||||
// dossier-cli <projekt.obp> dxf|ifc|step|obj|stl|schedule [--level EG] [--out datei]
|
||||
// dossier-cli <projekt.obp> dxf|ifc|step|obj|stl|schedule|kennzahlen [--level EG] [--out datei]
|
||||
// dossier-cli <projekt.obp> model3d [--out modell.json] 3D-Modell fürs Headless-Rendern (render_png)
|
||||
// dossier-cli <projekt.obp> mcp MCP-Server (stdio): project_info, query, render_svg, apply_ops, validate
|
||||
// dossier-cli <projekt.obp> bench [--runs 10] Zeitprofil der Ableitungen (ms je Aufruf)
|
||||
@@ -25,6 +25,8 @@ import {
|
||||
exportObj,
|
||||
exportProjectStep,
|
||||
exportScheduleCsv,
|
||||
computeKennzahlen,
|
||||
checkRoomProgram,
|
||||
exportStl,
|
||||
generateElevationPlan,
|
||||
diffToOps,
|
||||
@@ -111,7 +113,7 @@ export async function run(argv: string[]): Promise<number> {
|
||||
const [file, command, ...rest] = args.positional;
|
||||
if (!file || !command) {
|
||||
process.stderr.write(
|
||||
"Aufruf: dossier-cli <projekt.obp> <info|validate|migrate|plan|section|elevation|dxf|ifc|step|obj|stl|schedule> [Optionen]\n",
|
||||
"Aufruf: dossier-cli <projekt.obp> <info|validate|migrate|plan|section|elevation|dxf|ifc|step|obj|stl|schedule|kennzahlen> [Optionen]\n",
|
||||
);
|
||||
return 2;
|
||||
}
|
||||
@@ -199,6 +201,12 @@ export async function run(argv: string[]): Promise<number> {
|
||||
case "stl":
|
||||
out(args, exportStl(project), `${project.name || "projekt"}.stl`);
|
||||
return 0;
|
||||
case "kennzahlen": {
|
||||
const k = computeKennzahlen(project);
|
||||
const prog = checkRoomProgram(project);
|
||||
out(args, JSON.stringify({ kennzahlen: k, raumprogramm: prog }, null, 2), `${project.name || "projekt"}-kennzahlen.json`);
|
||||
return 0;
|
||||
}
|
||||
case "schedule":
|
||||
out(args, exportScheduleCsv(project), `${project.name || "projekt"}-liste.csv`);
|
||||
return 0;
|
||||
|
||||
@@ -12,3 +12,5 @@ export { setWasmBytesProvider } from "../engine/wasmSource";
|
||||
export { applyOps, diffToOps, validateProject, validateOps } from "./ops";
|
||||
export type { CoreOp } from "./ops";
|
||||
export type { Project, DrawingLevel } from "../model/types";
|
||||
export { computeKennzahlen, checkRoomProgram, solidVolume } from "../analysis/kennzahlen";
|
||||
export type { Kennzahlen, ProgramCheck } from "../analysis/kennzahlen";
|
||||
@@ -1766,6 +1766,12 @@ export const de = {
|
||||
"startup.previousCrashed": "Dossier wurde beim letzten Mal nicht sauber beendet. Ungesicherte Arbeit wird beim Öffnen zur Wiederherstellung angeboten.",
|
||||
"project.open.failed": "Projekt konnte nicht geöffnet werden.",
|
||||
"menu.native.clashCheck": "Kollisionsprüfung …",
|
||||
"menu.native.kennzahlen": "Kennzahlen und Raumprogramm …",
|
||||
"kennzahlen.summary": "GF {gf} m² · aGF {agf} m² · GV {gv} m³",
|
||||
"kennzahlen.ziffern": "AZ {az} · ÜZ {uez}",
|
||||
"kennzahlen.noParcel": "Parzellenfläche nicht gesetzt (keine AZ/ÜZ)",
|
||||
"kennzahlen.program": "Raumprogramm: {ok} von {n} erfüllt",
|
||||
"kennzahlen.programIssue": "{name}: {status}",
|
||||
"clash.none": "Keine Kollisionen gefunden.",
|
||||
"clash.found": "Kollisionen gefunden",
|
||||
"clash.failed": "Kollisionsprüfung fehlgeschlagen",
|
||||
|
||||
@@ -1727,6 +1727,12 @@ export const en: Record<TranslationKey, string> = {
|
||||
"startup.previousCrashed": "Dossier did not shut down cleanly last time. Unsaved work is offered for recovery when you open it.",
|
||||
"project.open.failed": "Project could not be opened.",
|
||||
"menu.native.clashCheck": "Clash detection …",
|
||||
"menu.native.kennzahlen": "Key figures and room programme …",
|
||||
"kennzahlen.summary": "GFA {gf} m² · usable {agf} m² · volume {gv} m³",
|
||||
"kennzahlen.ziffern": "FAR {az} · site coverage {uez}",
|
||||
"kennzahlen.noParcel": "Site area not set (no FAR/coverage)",
|
||||
"kennzahlen.program": "Room programme: {ok} of {n} met",
|
||||
"kennzahlen.programIssue": "{name}: {status}",
|
||||
"clash.none": "No clashes found.",
|
||||
"clash.found": "Clashes found",
|
||||
"clash.failed": "Clash detection failed",
|
||||
|
||||
@@ -69,7 +69,7 @@ const KNOWN_KEYS = new Set<string>([
|
||||
"walls", "ceilings", "roofs", "openings", "stairs", "rooms", "drawings2d", "context",
|
||||
"extrudedSolids", "columns", "groups", "parametricWalls", "overrideRules", "viewSnapshots",
|
||||
"viewSnapshotFolders", "layouts", "masterLayouts", "layoutFolders", "referenceElevationMasl",
|
||||
"geoAnchor",
|
||||
"geoAnchor", "roomProgram", "parcelArea",
|
||||
]);
|
||||
|
||||
export type ParseProjectResult =
|
||||
|
||||
@@ -934,6 +934,18 @@ export type DrawingLevelKind = "floor" | "section" | "elevation" | "drawing";
|
||||
* Geschoss nutzt floorHeight/cutHeight/baseElevation; Schnitt/Ansicht nutzen
|
||||
* linePoints/directionSign; "drawing" nutzt keines dieser Felder.
|
||||
*/
|
||||
/** Eine Zeile des Raumprogramms (Soll): wird gegen die gezeichneten Räume geprüft (`analysis/kennzahlen.ts`). */
|
||||
export interface RoomProgramRow {
|
||||
/** Raumname wie im Modell (Vergleich ohne Gross-/Kleinschreibung, Präfix „Wohnen" trifft „Wohnen 2"). */
|
||||
name: string;
|
||||
/** SIA-416-Kategorie des Soll-Raums (optional, schärft die Zuordnung). */
|
||||
siaCategory?: SiaCategory;
|
||||
/** Soll-Fläche je Raum in m². */
|
||||
area: number;
|
||||
/** Soll-Anzahl (Default 1). */
|
||||
count?: number;
|
||||
}
|
||||
|
||||
export interface DrawingLevel {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -2889,6 +2901,10 @@ export interface Project {
|
||||
builtinPaletteBanks?: BuiltinPaletteBanks;
|
||||
/** Oberste Schnitte: Geschosse + Schnitte/Ansichten. */
|
||||
drawingLevels: DrawingLevel[];
|
||||
/** Raumprogramm (Soll) für die Prüfung gegen das Modell. */
|
||||
roomProgram?: RoomProgramRow[];
|
||||
/** Parzellenfläche (m²) für Ausnützungs- und Überbauungsziffer. */
|
||||
parcelArea?: number;
|
||||
/** Grafik-Kategorie-Baum (geschossübergreifend). */
|
||||
layers: LayerCategory[];
|
||||
walls: Wall[];
|
||||
|
||||
@@ -35,6 +35,7 @@ export interface NativeAppMenuHandlers {
|
||||
onExportStep: () => void;
|
||||
onImportStep: () => void;
|
||||
onClashCheck: () => void;
|
||||
onKennzahlen: () => void;
|
||||
|
||||
onUndo: () => void;
|
||||
onRedo: () => void;
|
||||
@@ -252,6 +253,10 @@ export function useNativeAppMenu(
|
||||
text: t("menu.native.clashCheck"),
|
||||
action: () => handlersRef.current.onClashCheck(),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.native.kennzahlen"),
|
||||
action: () => handlersRef.current.onKennzahlen(),
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user