Merge origin/master

This commit is contained in:
Claude committed 2026-10-30 08:15:43 +00:00
commit 62b2619f79
42 files changed
+2950 -83

No files matched your search

+2
View File
@@ -1650,6 +1650,7 @@ export default function App() {
removeContextObject,
removeContextObjects,
generateTerrain,
patchContextObject,
moveGripOf,
moveElementByOf,
moveEdgeOf,
@@ -3246,6 +3247,7 @@ export default function App() {
removeContextObject,
removeContextObjects,
generateTerrain,
patchContextObject,
commitTransformOn,
setElementColor,
setElementWeight,
+66
View File
@@ -0,0 +1,66 @@
import { describe, expect, it } from "vitest";
import type { Project } from "../model/types";
import { sampleProject } from "../model/sampleProject";
import { excavationQuantities } from "./excavation";
import { generateTerrainFromContours } from "../model/terrain";
/** Flaches Gelände 100 × 100 m auf ±0 und eine Baugrube 10 × 10 m, 3 m tief, 45°. */
function project(): Project {
return {
...sampleProject,
walls: [],
context: [
{
id: "t",
type: "terrainMesh",
name: "Gelände",
positions: [-50, -50, 0, 50, -50, 0, 50, 50, 0, -50, 50, 0],
indices: [0, 1, 2, 0, 2, 3],
},
{
id: "bg",
type: "excavation",
name: "Baugrube",
outline: [
{ x: -5, y: -5 },
{ x: 5, y: -5 },
{ x: 5, y: 5 },
{ x: -5, y: 5 },
],
bottom: -3,
slope: 45,
},
],
};
}
describe("[68] Baugrube", () => {
it("Abtrag wie analytisch (Kegelecken)", () => {
const [q] = excavationQuantities(project());
const exact = 300 + (40 * 9) / 2 + (Math.PI * 27) / 3;
expect(q.id).toBe("bg");
expect(Math.abs(q.cut - exact) / exact).toBeLessThan(0.01);
expect(q.fill).toBeCloseTo(0, 6);
expect(q.bottomArea).toBeCloseTo(100, 6);
});
it("ohne Baugrube leer", () => {
expect(excavationQuantities({ ...sampleProject, context: [] })).toEqual([]);
});
});
describe("[T6] Gelände aus Höhenlinien", () => {
it("glättet ohne Überschwingen und setzt die Äquidistanz", () => {
const ring = (r: number) =>
Array.from({ length: 32 }, (_, i) => ({ x: r * Math.cos((i / 32) * 2 * Math.PI), y: r * Math.sin((i / 32) * 2 * Math.PI) }));
const contours = [0, 1, 2, 3].map((k) => ({ z: k, pts: ring(40 - 10 * k), closed: true }));
const raw = generateTerrainFromContours(contours, { smooth: 0 });
const smooth = generateTerrainFromContours(contours);
expect(smooth.contourInterval).toBe(1);
expect(smooth.indices.length).toBeGreaterThan(raw.indices.length);
const zs = smooth.positions.filter((_, i) => i % 3 === 2);
expect(Math.min(...zs)).toBeGreaterThanOrEqual(-1e-9);
expect(Math.max(...zs)).toBeLessThan(3.5);
expect(Math.max(...zs)).toBeGreaterThan(3);
});
});
+26
View File
@@ -0,0 +1,26 @@
// Erdarbeiten ([68]): Mengen der Baugruben aus dem Rust-Kern (`src-tauri/core/src/excavation.rs`).
// Abtrag/Auftrag je Baugrube gegen das gewachsene Terrain (Integral über ein feines Raster der exakten
// Böschungsfunktion), Hinterfüllung = Abtrag ausserhalb der Gebäude-Grundfläche.
import type { Project } from "../model/types";
import { documentFor } from "../core/document";
export interface ExcavationQuantity {
id: string;
name: string;
/** Sohle (m, Modell ±0.00). */
bottom: number;
/** Sohlenfläche (m²). */
bottomArea: number;
/** Abtrag (m³). */
cut: number;
/** Auftrag/Schüttung (m³). */
fill: number;
/** Hinterfüllung (m³). */
backfill: number;
}
export function excavationQuantities(project: Project): ExcavationQuantity[] {
if (!(project.context ?? []).some((o) => o.type === "excavation")) return [];
return documentFor(project).query<ExcavationQuantity[]>("excavationQuantities");
}
+6
View File
@@ -57,6 +57,12 @@ export interface SiteCheck {
violationArea: number;
maxTop: number | null;
heightExceeded: boolean;
/** [T6] Geländehöhen an der Fassade (gewachsen/gestaltet, Modellbezug); leer ohne Gelände. */
facadeTerrain: { x: number; y: number; natural: number | null; designed: number | null }[];
/** Tiefstes gewachsenes Terrain an der Fassade (massgebendes Terrain, vereinfacht). */
terrainMin: number | null;
/** Gesamthöhe über dem massgebenden Terrain; mit Gelände prüft die Höhe dagegen statt gegen ±0.00. */
heightAboveTerrain: number | null;
}
/** Prüft das Modell gegen `project.siteRules`; `null` ohne (gültiges) Baurecht. Rechnung im Rust-Kern (`site_rules.rs`). */
+4 -1
View File
@@ -84,6 +84,7 @@ import {
addProgramSheet,
defaultSheetLabels,
checkSiteRules,
excavationQuantities,
exportStl,
exportGlb,
exportGltf,
@@ -683,7 +684,9 @@ async function execute(project: Project, file: string, command: string, rest: st
const k = computeKennzahlen(project);
const prog = checkRoomProgram(project);
const baurecht = checkSiteRules(project);
out(args, JSON.stringify({ kennzahlen: k, raumprogramm: prog, baurecht }, null, 2), `${project.name || "projekt"}-kennzahlen.json`);
// [68] Erdarbeiten je Baugrube (Abtrag/Auftrag/Hinterfüllung, m³).
const erdarbeiten = excavationQuantities(project);
out(args, JSON.stringify({ kennzahlen: k, raumprogramm: prog, baurecht, erdarbeiten }, null, 2), `${project.name || "projekt"}-kennzahlen.json`);
return 0;
}
case "raumprogramm": {
+109
View File
@@ -0,0 +1,109 @@
// Baugrube ([68]) — Umriss der Sohle per Klicks; der Kern (`cmd_solid.rs`) legt ein Kontext-Objekt
// `excavation` an (Sohle = Geschoss-Unterkante − 0.30 m, Böschung 45°), das jedes Gelände-Netz unter dem
// Umriss schneidet. Sohle, Böschung und Bermen danach im Panel „Gelände & Kontext".
//
// Schritte:
// 1) „Erster Punkt der Baugrubensohle:" → Punkt
// 2) „Nächster Punkt …" → Punkt … Schliessen per Klick auf den Startpunkt, Option „Schliessen" oder
// Enter (≥ 3 Punkte; bei genau 2 Punkten: Rechteck aus den Ecken).
import type { Command, CommandContext, CommandResult, CommandState, CmdOption, DraftShape, ToolDraft, Vec2 } from "../types";
import { createMutation } from "../createCore";
const EPS = 1e-6;
const CLOSE_HIT = 0.08; // Modell-Meter: Klick nahe Startpunkt schliesst die Kontur
const dist = (a: Vec2, b: Vec2): number => Math.hypot(b.x - a.x, b.y - a.y);
interface HoleIdle extends CommandState {
phase: "start";
}
interface HoleDrawing extends CommandState {
phase: "next";
points: Vec2[];
cursor: Vec2 | null;
}
type HoleState = HoleIdle | HoleDrawing;
const CLOSE: CmdOption = { id: "close", labelKey: "cmd.polyline.close" };
const UNDO: CmdOption = { id: "undo", labelKey: "cmd.polyline.undo" };
/** Vorschau: Kontur (ab 3 Punkten geschlossen) + Gummiband. */
function holeDraft(points: Vec2[], cursor: Vec2 | null): ToolDraft {
const pts = cursor ? [...points, cursor] : points;
const preview: DraftShape[] = [{ kind: "poly", pts, closed: pts.length >= 3 }];
const draft: ToolDraft = { preview, vertices: points };
const last = points[points.length - 1];
if (cursor && last && dist(last, cursor) >= EPS) draft.hud = { at: cursor, text: `${dist(last, cursor).toFixed(2)} m` };
return draft;
}
/**
* Commit (Kern, `cmd_solid.rs`): Baugrube aus dem Umriss (≥ 3 Punkte wie gezeichnet, 2 Punkte als Rechteck);
* entartet → nichts.
*/
const excavationOps = (points: Vec2[], ctx: CommandContext) => createMutation(ctx, { cmd: "excavation", pts: points });
const idle = (): [CommandState, CommandResult] => [{ phase: "start", lastPoint: null } as HoleIdle, { draft: null, done: true }];
const finish = (points: Vec2[], ctx: CommandContext): [CommandState, CommandResult] => [
{ phase: "start", lastPoint: null } as HoleIdle,
{ draft: null, done: true, commit: excavationOps(points, ctx) },
];
export const excavationCommand: Command = {
name: "excavation",
labelKey: "cmd.excavation.label",
floorOnly: true,
prompt: (s) => ((s as HoleState).phase === "next" ? "cmd.excavation.next" : "cmd.excavation.start"),
accepts: (s) => ((s as HoleState).phase === "next" ? ["point", "option"] : ["point"]),
options: (s) => {
const ps = s as HoleState;
if (ps.phase !== "next") return [];
return ps.points.length >= 3 ? [CLOSE, UNDO] : [UNDO];
},
init: (): HoleIdle => ({ phase: "start", lastPoint: null }),
onInput: (state, input, ctx): [CommandState, CommandResult] => {
const s = state as HoleState;
if (input.kind === "option") {
if (s.phase !== "next") return [s, { draft: null }];
if (input.id === "undo") {
const pts = s.points.slice(0, -1);
if (pts.length === 0) return [{ phase: "start", lastPoint: null } as HoleIdle, { draft: null }];
const ns: HoleDrawing = { phase: "next", points: pts, cursor: s.cursor, lastPoint: pts[pts.length - 1] };
return [ns, { draft: holeDraft(pts, s.cursor) }];
}
if (input.id === "close" && s.points.length >= 3) return finish(s.points, ctx);
return [s, { draft: holeDraft(s.points, s.cursor) }];
}
if (input.kind !== "point") return [s, { draft: s.phase === "next" ? holeDraft(s.points, s.cursor) : null }];
const pt = input.point;
if (s.phase !== "next") {
const ns: HoleDrawing = { phase: "next", points: [pt], cursor: pt, lastPoint: pt };
return [ns, { draft: holeDraft([pt], pt) }];
}
// Klick nahe Startpunkt schliesst den Umriss.
if (s.points.length >= 3 && dist(s.points[0], pt) < CLOSE_HIT) return finish(s.points, ctx);
// Null-Strecke ignorieren.
if (dist(s.points[s.points.length - 1], pt) < EPS) return [s, { draft: holeDraft(s.points, s.cursor) }];
const points = [...s.points, pt];
const ns: HoleDrawing = { phase: "next", points, cursor: pt, lastPoint: pt };
return [ns, { draft: holeDraft(points, pt) }];
},
onMove: (state, point): [CommandState, CommandResult] => {
const s = state as HoleState;
if (s.phase !== "next") return [s, { draft: null }];
const ns: HoleDrawing = { ...s, cursor: point };
return [ns, { draft: holeDraft(s.points, point) }];
},
// Enter/Rechtsklick: ≥ 3 Punkte Polygon, 2 Punkte Rechteck.
onConfirm: (state, ctx): [CommandState, CommandResult] => {
const s = state as HoleState;
if (s.phase === "next" && s.points.length >= 2) return finish(s.points, ctx);
return idle();
},
onCancel: (): [CommandState, CommandResult] => idle(),
};
+4
View File
@@ -63,6 +63,7 @@ import { chamferCommand } from "./cmds/chamfer";
import { multilineCommand } from "./cmds/multiline";
import { importCommand } from "./cmds/import";
import { terrainCommand } from "./cmds/terrain";
import { excavationCommand } from "./cmds/excavation";
import { measureCommand } from "./cmds/measure";
import { sectionLineCommand, viewLineCommand } from "./cmds/sectionline";
import { georefCommand } from "./cmds/georef";
@@ -132,6 +133,7 @@ export const COMMANDS: Record<string, Command> = {
multiline: multilineCommand,
import: importCommand,
terrain: terrainCommand,
excavation: excavationCommand,
measure: measureCommand,
sectionline: sectionLineCommand,
viewline: viewLineCommand,
@@ -265,6 +267,8 @@ export const ALIASES: Record<string, string> = {
parallel: "multiline",
imp: "import",
ter: "terrain",
baugrube: "excavation",
aushub: "excavation",
schnittlinie: "sectionline",
ansichtslinie: "viewline",
bezugspunkt: "georef",
+1
View File
@@ -68,6 +68,7 @@ export type QueryName =
| "programLayout"
| "ivhb"
| "siteCheck"
| "excavationQuantities"
| "buildingFootprint"
| "modelTop"
| "shadows"
+1
View File
@@ -44,6 +44,7 @@ export type { AreaReport, AreaReportOptions } from "../export/areaReport";
export { sunPosition, shadowPolygons, shadowOfPrism, projectLatLon } from "../analysis/sun";
export type { SunPosition } from "../analysis/sun";
export { checkSiteRules, allowedArea, multiPolygonArea, buildingFootprint, modelTop } from "../analysis/siteRules";
export { excavationQuantities, type ExcavationQuantity } from "../analysis/excavation";
export type { SiteCheck } from "../analysis/siteRules";
export { sampleProject } from "../model/sampleProject";
export { parseDxf } from "../io/dxfParser";
+4 -4
View File
@@ -53,12 +53,12 @@ describe("Tabellen auf dem Blatt ([111])", () => {
expect(b.prims.filter((x) => x.k === "text" && x.s === tableLabels(p)["openings.col.mark"]).length).toBe(1);
});
it("alle vier Quellen liefern Primitive; Katalog nennt die Spalten", () => {
it("alle Quellen liefern Primitive; Katalog nennt die Spalten", () => {
const cat = tableCatalog(sampleProject);
expect(Object.keys(cat.sources).sort()).toEqual(["areas", "elements", "openings", "rooms"]);
const p = withTables((["openings", "areas", "rooms", "elements"] as const).map((source) => table({ id: source, source })));
expect(Object.keys(cat.sources).sort()).toEqual(["areas", "earthworks", "elements", "openings", "rooms"]);
const p = withTables((["openings", "areas", "rooms", "elements", "earthworks"] as const).map((source) => table({ id: source, source })));
const out = sheetTables(p, "L1");
expect(out.map((o) => o.id)).toEqual(["openings", "areas", "rooms", "elements"]);
expect(out.map((o) => o.id)).toEqual(["openings", "areas", "rooms", "elements", "earthworks"]);
for (const o of out) expect(o.prims.some((x) => x.k === "text")).toBe(true);
});
+1 -1
View File
@@ -38,7 +38,7 @@ interface Catalog {
valueKeys: string[];
}
export const TABLE_SOURCES: readonly LayoutTableSource[] = ["openings", "areas", "rooms", "elements"];
export const TABLE_SOURCES: readonly LayoutTableSource[] = ["openings", "areas", "rooms", "elements", "earthworks"];
export function tableSourceLabel(s: LayoutTableSource): string {
return t(`sheetTable.source.${s}`);
+25
View File
@@ -1616,6 +1616,9 @@ export const de = {
"cmd.ceilingOpening.start": "Erste Ecke der Aussparung (in einer Decke):",
"cmd.ceilingOpening.corner": "Gegenecke:",
"cmd.roofHole.label": "Dachhof",
"cmd.excavation.label": "Baugrube",
"cmd.excavation.start": "Erster Punkt der Baugrubensohle:",
"cmd.excavation.next": "Nächster Punkt (Enter bei 2 Punkten = Rechteck, ab 3 Punkten Polygon):",
"cmd.roofHole.start": "Erster Punkt des Innenhofs (im Dach):",
"cmd.roofHole.next": "Nächster Punkt (Enter bei 2 Punkten = Rechteck, ab 3 Punkten Polygon):",
"cmd.roof.shape.sattel": "Satteldach",
@@ -1980,6 +1983,20 @@ export const de = {
"site.type.mesh": "Mesh",
"site.type.contours": "Konturen",
"site.type.terrain": "Gelände",
"site.type.excavation": "Baugrube",
"site.smooth": "Glätten",
"site.smooth.hint": "Höhenlinien als Bruchkanten, flache Dreiecke behoben, Fläche ohne Überschwingen geglättet",
"site.excavation.draw": "Baugrube zeichnen",
"site.excavation.hint": "Umriss der Sohle zeichnen; Böschungen schneiden das Gelände",
"site.contourInterval": "Äquidistanz [m]",
"site.contourIndexEvery": "Zähllinie jede",
"site.excavation.bottom": "Sohle [m]",
"site.excavation.slope": "Böschung [°]",
"site.excavation.fillSlope": "Schüttung [°]",
"site.excavation.bermWidth": "Berme [m]",
"site.excavation.bermHeight": "Berme alle [m]",
"site.excavation.qty": "Abtrag {cut} m³ · Auftrag {fill} m³ · Hinterfüllung {backfill} m³",
"site.excavation.noTerrain": "Kein Gelände unter der Baugrube",
"site.type.image": "Luftbild",
"site.group.image": "Luftbild",
"site.dwgHint": "DWG? Zuerst mit dem gratis ODA File Converter in DXF umwandeln.",
@@ -2425,6 +2442,7 @@ export const de = {
"siteRules.inside": "Gebäude innerhalb der zulässigen Fläche",
"siteRules.heightOk": "Höhe {top} m ≤ {max} m",
"siteRules.heightOver": "Höhe {top} m über {max} m",
"siteRules.terrainAtFacade": "Massgebendes Terrain an der Fassade: {z} m (Höhe darüber gemessen)",
"siteRules.defaultSetback": "Grenzabstand",
"siteRules.maxHeight": "Gesamthöhe max.",
"siteRules.edges": "Grenzabstand je Kante ({n})",
@@ -2766,6 +2784,7 @@ export const de = {
"sheetTable.source.areas": "Flächentabelle (SIA 416)",
"sheetTable.source.rooms": "Raumprogramm Soll/Ist",
"sheetTable.source.elements": "Bauteile mit U-Wert",
"sheetTable.source.earthworks": "Erdarbeiten (Baugruben)",
"sheetTable.filter": "Zeigen",
"sheetTable.filter.all": "Fenster und Türen",
"sheetTable.filter.window": "Nur Fenster",
@@ -2813,6 +2832,11 @@ export const de = {
"sheetTable.col.diffPct": "Diff. [%]",
"sheetTable.col.buildup": "Aufbau",
"sheetTable.col.area": "Fläche [m²]",
"sheetTable.col.name": "Bezeichnung",
"sheetTable.col.bottom": "Sohle [m]",
"sheetTable.col.cut": "Abtrag [m³]",
"sheetTable.col.fill": "Auftrag [m³]",
"sheetTable.col.backfill": "Hinterfüllung [m³]",
"sheetTable.col.thickness": "Dicke [cm]",
"sheetTable.v.window": "Fenster",
"sheetTable.v.door": "Tür",
@@ -2998,6 +3022,7 @@ export const de = {
"history.cmd.revcloud": "Revisionswolke",
"history.cmd.roof": "Dach zeichnen",
"history.cmd.roofHole": "Dachöffnung",
"history.cmd.excavation": "Baugrube",
"history.cmd.room": "Raum zeichnen",
"history.cmd.roomInside": "Raum aus Umriss",
"history.cmd.scalebar": "Massstabsbalken",
+25
View File
@@ -1605,6 +1605,9 @@ export const en: Record<TranslationKey, string> = {
"cmd.ceilingOpening.start": "First corner of the opening (inside a slab):",
"cmd.ceilingOpening.corner": "Opposite corner:",
"cmd.roofHole.label": "Roof court",
"cmd.excavation.label": "Excavation",
"cmd.excavation.start": "First point of the excavation bottom:",
"cmd.excavation.next": "Next point (Enter with 2 points = rectangle, 3 or more = polygon):",
"cmd.roofHole.start": "First point of the courtyard (inside the roof):",
"cmd.roofHole.next": "Next point (Enter with 2 points = rectangle, 3 or more = polygon):",
"cmd.roof.shape.sattel": "Gable roof",
@@ -1968,6 +1971,20 @@ export const en: Record<TranslationKey, string> = {
"site.type.mesh": "Mesh",
"site.type.contours": "Contours",
"site.type.terrain": "Terrain",
"site.type.excavation": "Excavation",
"site.smooth": "Smooth",
"site.smooth.hint": "Contours as breaklines, flat triangles fixed, surface smoothed without overshoot",
"site.excavation.draw": "Draw excavation",
"site.excavation.hint": "Draw the outline of the pit bottom; slopes cut the terrain",
"site.contourInterval": "Contour interval [m]",
"site.contourIndexEvery": "Index contour every",
"site.excavation.bottom": "Bottom [m]",
"site.excavation.slope": "Slope [°]",
"site.excavation.fillSlope": "Fill slope [°]",
"site.excavation.bermWidth": "Berm [m]",
"site.excavation.bermHeight": "Berm every [m]",
"site.excavation.qty": "Cut {cut} m³ · Fill {fill} m³ · Backfill {backfill} m³",
"site.excavation.noTerrain": "No terrain below the excavation",
"site.type.image": "Aerial",
"site.group.image": "Aerial imagery",
"site.dwgHint": "DWG? Convert it to DXF first with the free ODA File Converter.",
@@ -2375,6 +2392,7 @@ export const en: Record<TranslationKey, string> = {
"siteRules.inside": "Building inside the buildable area",
"siteRules.heightOk": "Height {top} m ≤ {max} m",
"siteRules.heightOver": "Height {top} m exceeds {max} m",
"siteRules.terrainAtFacade": "Reference terrain at the façade: {z} m (height measured from it)",
"siteRules.defaultSetback": "Boundary distance",
"siteRules.maxHeight": "Max. total height",
"siteRules.edges": "Distance per edge ({n})",
@@ -2753,6 +2771,7 @@ export const en: Record<TranslationKey, string> = {
"sheetTable.source.areas": "Area table (SIA 416)",
"sheetTable.source.rooms": "Room program target/actual",
"sheetTable.source.elements": "Elements with U-value",
"sheetTable.source.earthworks": "Earthworks (excavations)",
"sheetTable.filter": "Show",
"sheetTable.filter.all": "Windows and doors",
"sheetTable.filter.window": "Windows only",
@@ -2800,6 +2819,11 @@ export const en: Record<TranslationKey, string> = {
"sheetTable.col.diffPct": "Diff. [%]",
"sheetTable.col.buildup": "Build-up",
"sheetTable.col.area": "Area [m²]",
"sheetTable.col.name": "Name",
"sheetTable.col.bottom": "Bottom [m]",
"sheetTable.col.cut": "Cut [m³]",
"sheetTable.col.fill": "Fill [m³]",
"sheetTable.col.backfill": "Backfill [m³]",
"sheetTable.col.thickness": "Thickness [cm]",
"sheetTable.v.window": "Window",
"sheetTable.v.door": "Door",
@@ -2984,6 +3008,7 @@ export const en: Record<TranslationKey, string> = {
"history.cmd.revcloud": "Revision cloud",
"history.cmd.roof": "Draw roof",
"history.cmd.roofHole": "Roof opening",
"history.cmd.excavation": "Excavation",
"history.cmd.room": "Draw room",
"history.cmd.roomInside": "Room from outline",
"history.cmd.scalebar": "Scale bar",
+25 -6
View File
@@ -19,14 +19,32 @@ let terrainSeq = 0;
export const TERRAIN_LAYER = "Terrain";
/**
* Erzeugt ein TIN aus Konturen (Rust-Kern, `cmd_solid.rs::terrain_from_contours`): alle endlichen
* Stützpunkte der Konturen als Vertices (Z = Kontur-Höhe, nicht endlich → 0), 2D-Delaunay über die
* (x, y)-Projektion (`delaunay.rs`), Dreiecke mit (nahezu) null Fläche verworfen. Offene und
* geschlossene Konturen gleich; unter 3 Punkten ein leeres Mesh.
* Erzeugt ein Gelände aus Konturen (Rust-Kern, `terrain.rs`): Konturen verdichtet und als Bruchkanten
* erzwungen (constrained Delaunay), flache Dreiecke behoben, adaptiv geglättet ohne Überschwingen.
* `contourInterval` = kleinster Höhenabstand der Konturen (Höhenlinien im Grundriss). Unter 3 Punkten
* ein leeres Mesh.
*/
export function generateTerrainFromContours(contours: Contour[]): TerrainMesh {
export function generateTerrainFromContours(contours: Contour[], opts: TerrainOptions = {}): TerrainMesh {
const id = `terrain-${Date.now()}-${terrainSeq++}`;
return JSON.parse(core().terrain_from_contours_json(toMarkedJson(contours), id)) as TerrainMesh;
const json = core().terrain_from_contours_opts_json(
toMarkedJson(contours),
id,
opts.smooth ?? 2,
opts.maxEdge ?? 0,
opts.breaklines === false ? 0 : 1,
);
return JSON.parse(json) as TerrainMesh;
}
/**
* [T6] Optionen der Gelände-Erzeugung (`terrain.rs`): `smooth` = Glättungsstufen 0–4 (0 = reines TIN mit
* Bruchkanten, Standard 2), `maxEdge` = Verdichtung/grösste Kante in m (0 = automatisch), `breaklines` =
* Höhenlinien als Bruchkanten erzwingen (Standard ja).
*/
export interface TerrainOptions {
smooth?: number;
maxEdge?: number;
breaklines?: boolean;
}
/**
@@ -91,5 +109,6 @@ export function terrainMeshFromGrid(grid: TerrainGrid): TerrainMesh {
categoryCode: TERRAIN_CATEGORY.code,
positions,
indices,
contourInterval: 1,
};
}
+31 -2
View File
@@ -453,7 +453,7 @@ export type ContextImage = {
};
/** Kontext-Objekt (Tag `type`). */
export type ContextObject = ImportedMesh | ContourSet | TerrainMesh | ContextImage;
export type ContextObject = ImportedMesh | ContourSet | TerrainMesh | ContextImage | Excavation;
/**
* Eine einzelne Kontur (Höhenlinie / Polylinie) auf konstanter Höhe `z`. `pts`
@@ -1117,6 +1117,28 @@ export type DrawingLevelKind = "floor" | "section" | "elevation" | "drawing";
*/
export type EndMark = "none" | "arrow" | "arrowOpen" | "dot" | "tick" | "square";
/**
* [68] Baugrube / Geländebearbeitung: Sohle als Umriss auf der Höhe `bottom` (m, Modell ±0.00).
* Ausserhalb steigt die Böschung mit `slope` (Grad, Default 45; je Kante `edgeSlopes`, 0 = Default)
* bis zum Gelände (Abtrag); liegt das Gelände tiefer, fällt eine Schüttung mit `fillSlope` (Default
* 33.7 ≈ 2:3) bis zum Gelände (Auftrag). Bermen: alle `bermHeight` m Höhe eine waagrechte Berme der
* Breite `bermWidth`. Schneidet jedes Gelände-Netz, das den Umriss enthält.
*/
export type Excavation = {
type: "excavation";
id: string;
name: string;
layer?: string;
categoryCode?: string;
outline: Array<Vec2>;
bottom: number;
slope?: number;
fillSlope?: number;
edgeSlopes?: Array<number>;
bermWidth?: number;
bermHeight?: number;
};
/** Ein extrudierter Körper: geschlossenes Profil (Modell-Meter) + Höhe. */
export type ExtrudedSolid = {
id: string;
@@ -1627,7 +1649,7 @@ export type LayoutTable = {
};
/** Quelle einer Blatt-Tabelle ([111]). */
export type LayoutTableSource = "openings" | "areas" | "rooms" | "elements";
export type LayoutTableSource = "openings" | "areas" | "rooms" | "elements" | "earthworks";
/**
* Einfache Textfelder des Titelblocks (Master). Alle optional — leere Felder
@@ -2950,6 +2972,13 @@ export type TerrainMesh = {
* statt mit der Grundfarbe. Fehlt es, bleibt das Gelände einfarbig.
*/
vertexColors?: Array<number>;
/**
* [T6] Äquidistanz der Höhenlinien im Grundriss in m (aus dem Netz neu erzeugt, inkl. Baugruben).
* Fehlt der Wert oder ist er ≤ 0, zeigt der Grundriss nur den Rahmen.
*/
contourInterval?: number;
/** [T6] Jede n-te Höhenlinie ist Zähllinie (dicker, beschriftet). Default 5. */
contourIndexEvery?: number;
};
/** Ein zusammenhängender Textabschnitt mit einheitlicher Formatierung. */
+121 -2
View File
@@ -13,7 +13,7 @@
// Bezeichner englisch, UI-Text/Kommentare deutsch (CONVENTIONS.md). Alle sichtbaren
// Texte über t(...).
import { useState } from "react";
import { useMemo, useState } from "react";
import { t } from "../i18n";
import type { TranslationKey } from "../i18n";
import { usePanelHost } from "./host";
@@ -26,6 +26,7 @@ import { openContextImportWindowNative } from "../native/contextImportWindow";
import { SunStudySection } from "./SunStudySection";
import { SiteRulesSection } from "./SiteRulesSection";
import { PointCloudSection } from "./PointCloudSection";
import { excavationQuantities } from "../core";
/** Typ-spezifisches Badge-Label (i18n-Key) je Kontext-Objekt-Art. */
function typeBadgeKey(obj: ContextObject): TranslationKey {
@@ -38,6 +39,8 @@ function typeBadgeKey(obj: ContextObject): TranslationKey {
return "site.type.terrain";
case "image":
return "site.type.image";
case "excavation":
return "site.type.excavation";
}
}
@@ -53,9 +56,42 @@ function layerOf(obj: ContextObject): string {
return t("site.group.contours");
case "image":
return t("site.group.image");
case "excavation":
return t("site.group.terrain");
}
}
/** Zahl-Eingabe für ein Feld eines Kontext-Objekts (leer = Standard, ungültig = keine Änderung). */
function NumField(props: {
label: string;
value: number | undefined;
step: number;
min?: number;
placeholder?: string;
onChange: (v: number | undefined) => void;
}) {
return (
<label className="site-prop">
<span>{props.label}</span>
<input
type="number"
step={props.step}
min={props.min}
placeholder={props.placeholder}
value={props.value ?? ""}
onChange={(e) => {
const raw = e.target.value.trim();
if (raw === "") return props.onChange(undefined);
const v = Number(raw);
if (Number.isFinite(v)) props.onChange(v);
}}
/>
</label>
);
}
const fmt1 = (v: number) => v.toLocaleString("de-CH", { maximumFractionDigits: 1, minimumFractionDigits: 1 });
/** Gruppiert Kontext-Objekte nach Ebene, Reihenfolge des ersten Auftretens. */
function groupByLayer(objects: ContextObject[]): { layer: string; items: ContextObject[] }[] {
const order: string[] = [];
@@ -73,6 +109,15 @@ function groupByLayer(objects: ContextObject[]): { layer: string; items: Context
return order.map((layer) => ({ layer, items: byLayer.get(layer)! }));
}
function ExcavationQty({ q }: { q: { cut: number; fill: number; backfill: number } | undefined }) {
if (!q) return <div className="site-qty">{t("site.excavation.noTerrain")}</div>;
return (
<div className="site-qty">
{t("site.excavation.qty", { cut: fmt1(q.cut), fill: fmt1(q.fill), backfill: fmt1(q.backfill) })}
</div>
);
}
export function SitePanel() {
const host = usePanelHost();
const notify = useStore((s) => s.notify);
@@ -89,9 +134,16 @@ export function SitePanel() {
? selectedSet
: (contourSets[0]?.id ?? "");
// [T6] Glätten beim Erzeugen (Bruchkanten werden immer erzwungen).
const [smooth, setSmooth] = useState(true);
// [68] Mengen der Baugruben (Kern), nur neu, wenn sich das Projekt ändert.
const quantities = useMemo(() => excavationQuantities(host.project), [host.project]);
const patch = (id: string, field: string) => (v: number | undefined) =>
host.onPatchContextObject(id, { [field]: v }, `site-${id}-${field}`);
const onGenerate = () => {
if (!effectiveSet) return;
const id = host.onGenerateTerrain(effectiveSet);
const id = host.onGenerateTerrain(effectiveSet, { smooth: smooth ? 2 : 0 });
if (id === null) {
// Kein sinnvolles TIN — ruhiger Hinweis als Toast (keine harte Fehlerbox;
// window.alert wäre im Tauri-WKWebView ohnehin wirkungslos).
@@ -153,11 +205,22 @@ export function SitePanel() {
{contourSets[0].name}
</span>
)}
<label className="site-check" title={t("site.smooth.hint")}>
<input type="checkbox" checked={smooth} onChange={(e) => setSmooth(e.target.checked)} />
{t("site.smooth")}
</label>
<button type="button" className="site-btn" onClick={onGenerate}>
{t("site.generateTerrain")}
</button>
</div>
)}
{objects.some((o) => o.type === "terrainMesh") && (
<div className="site-actions">
<button type="button" className="site-btn" title={t("site.excavation.hint")} onClick={() => host.onStartExcavation()}>
{t("site.excavation.draw")}
</button>
</div>
)}
<div className="site-sep" />
<SunStudySection />
@@ -213,6 +276,62 @@ export function SitePanel() {
>
×
</button>
{obj.type === "terrainMesh" && (
<div className="site-props">
<NumField
label={t("site.contourInterval")}
value={obj.contourInterval}
step={0.5}
min={0}
placeholder="—"
onChange={patch(obj.id, "contourInterval")}
/>
<NumField
label={t("site.contourIndexEvery")}
value={obj.contourIndexEvery}
step={1}
min={1}
placeholder="5"
onChange={patch(obj.id, "contourIndexEvery")}
/>
</div>
)}
{obj.type === "excavation" && (
<div className="site-props">
<NumField
label={t("site.excavation.bottom")}
value={obj.bottom}
step={0.05}
onChange={(v) => v !== undefined && patch(obj.id, "bottom")(v)}
/>
<NumField label={t("site.excavation.slope")} value={obj.slope} step={5} min={5} placeholder="45" onChange={patch(obj.id, "slope")} />
<NumField
label={t("site.excavation.fillSlope")}
value={obj.fillSlope}
step={5}
min={5}
placeholder="33.7"
onChange={patch(obj.id, "fillSlope")}
/>
<NumField
label={t("site.excavation.bermWidth")}
value={obj.bermWidth}
step={0.25}
min={0}
placeholder="—"
onChange={patch(obj.id, "bermWidth")}
/>
<NumField
label={t("site.excavation.bermHeight")}
value={obj.bermHeight}
step={0.5}
min={0}
placeholder="—"
onChange={patch(obj.id, "bermHeight")}
/>
<ExcavationQty q={quantities.find((x) => x.id === obj.id)} />
</div>
)}
</li>
))}
</ul>
+4 -1
View File
@@ -84,11 +84,14 @@ export function SiteRulesSection() {
{rules.maxHeight !== undefined && check.maxTop !== null && (
<div>
{t(check.heightExceeded ? "siteRules.heightOver" : "siteRules.heightOk", {
top: fmt(check.maxTop, 2),
top: fmt(check.heightAboveTerrain ?? check.maxTop, 2),
max: fmt(rules.maxHeight, 2),
})}
</div>
)}
{check.terrainMin !== null && (
<div>{t("siteRules.terrainAtFacade", { z: fmt(check.terrainMin, 2) })}</div>
)}
</div>
)}
+1 -1
View File
@@ -355,7 +355,7 @@ const TOOLS_2D: ToolId[] = [
"image",
];
const TOOLS_3D: ToolId[] = ["wall", "ceiling", "window", "door", "stair", "room"];
const COMMANDS_3D = ["column", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "sectionline", "viewline", "autodim"];
const COMMANDS_3D = ["column", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "sectionline", "viewline", "autodim", "excavation"];
const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "extend", "fillet", "chamfer", "join", "defblock", "measure"];
type ToolsView = "list" | "icons";
+6 -1
View File
@@ -40,6 +40,7 @@ import type {
WallType,
} from "../model/types";
import type { MeasurementReadout, SnapSettings, ToolId } from "../tools/types";
import type { TerrainOptions } from "../model/terrain";
import type { Selection } from "../state/selectionInfo";
import type { TextStylePreset } from "../text/richText";
import type { ScheduleKind } from "../export/exportSchedule";
@@ -583,7 +584,11 @@ export interface PanelHostValue {
* Erzeugt aus einem ContourSet (per ID) ein Gelände-TIN. Liefert die neue
* TerrainMesh-ID oder null (unbekannte ID / kein sinnvolles TIN).
*/
onGenerateTerrain: (contourSetId: string) => string | null;
onGenerateTerrain: (contourSetId: string, opts?: TerrainOptions) => string | null;
/** [T6]/[68] Ändert Felder eines Kontext-Objekts (Äquidistanz, Baugruben-Sohle …). */
onPatchContextObject: (id: string, patch: Record<string, unknown>, coalesceKey?: string) => void;
/** [68] Startet den Befehl „Baugrube" (Umriss zeichnen). */
onStartExcavation: () => void;
/**
* Setzt/ersetzt den Georeferenzierungs-Bezug (`Project.geoAnchor`) — welcher
* Modell-Punkt welcher realen LV95-Koordinate entspricht. `undefined` löscht
+11 -6
View File
@@ -9,9 +9,9 @@
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import { generateTerrainFromContours } from "../model/terrain";
import { generateTerrainFromContours, type TerrainOptions } from "../model/terrain";
import type { ContextObject, Project } from "../model/types";
import { addItems, fieldOps, removeItems } from "../core/opsBuild";
import { addItems, fieldOps, patchItem, removeItems } from "../core/opsBuild";
import type { CoreOp } from "../core/ops";
import { ensureContextCategories } from "../model/contextCategories";
import type { StoreApi } from "./store";
@@ -32,7 +32,9 @@ export interface SiteSlice {
* weiteres Kontext-Objekt hinzu. Liefert die ID des neuen TerrainMesh, oder
* null, wenn der ContourSet nicht existiert / kein Mesh entsteht.
*/
generateTerrain: (contourSetId: string) => string | null;
generateTerrain: (contourSetId: string, opts?: TerrainOptions) => string | null;
/** [T6]/[68] Ändert Felder eines Kontext-Objekts (Gelände, Baugrube) in einem Schritt; `coalesceKey` für Tippen. */
patchContextObject: (id: string, patch: Record<string, unknown>, coalesceKey?: string) => void;
/** Leert die gesamte Kontext-Schicht. */
clearContext: () => void;
}
@@ -44,7 +46,7 @@ export interface SiteSlice {
*/
type SiteSliceDeps = {
project: Project;
applyChange: (ops: readonly CoreOp[] | ((p: Project) => readonly CoreOp[])) => void;
applyChange: (ops: readonly CoreOp[] | ((p: Project) => readonly CoreOp[]), coalesceKey?: string) => void;
};
export function createSiteSlice(
@@ -81,13 +83,16 @@ export function createSiteSlice(
get().applyChange((p) => removeItems(p, "context", ids));
},
generateTerrain: (contourSetId) => {
patchContextObject: (id, patch, coalesceKey) =>
get().applyChange((p) => patchItem(p, "context", id, (o) => ({ ...o, ...patch }) as ContextObject), coalesceKey),
generateTerrain: (contourSetId, opts) => {
const ctx = get().project.context ?? [];
const set = ctx.find(
(o) => o.id === contourSetId && o.type === "contourSet",
);
if (!set || set.type !== "contourSet") return null;
const terrain = generateTerrainFromContours(set.contours);
const terrain = generateTerrainFromContours(set.contours, opts);
if (terrain.indices.length === 0) return null; // kein sinnvolles TIN
addToContext([terrain]);
return terrain.id;
+4
View File
@@ -169,6 +169,7 @@ export function usePanelHostBase(opts: {
| "removeContextObject"
| "removeContextObjects"
| "generateTerrain"
| "patchContextObject"
| "commitTransformOn"
| "setElementColor"
| "setElementWeight"
@@ -293,6 +294,7 @@ export function usePanelHostBase(opts: {
removeContextObject,
removeContextObjects,
generateTerrain,
patchContextObject,
commitTransformOn,
setElementColor,
setElementWeight,
@@ -1087,6 +1089,8 @@ export function usePanelHostBase(opts: {
onRemoveContextObject: removeContextObject,
onRemoveContextObjects: removeContextObjects,
onGenerateTerrain: generateTerrain,
onPatchContextObject: patchContextObject,
onStartExcavation: () => onRunCommand("excavation"),
onSetGeoAnchor: (anchor) => {
applyChange((p) => setFieldIfChanged(p, "geoAnchor", anchor));
},
+4
View File
@@ -48,6 +48,8 @@ function contextObjectsBounds(objs: ContextObject[]): Vec2[] | null {
} else if (obj.type === "image") {
acc(obj.min.x, obj.min.y);
acc(obj.max.x, obj.max.y);
} else if (obj.type === "excavation") {
for (const p of obj.outline) acc(p.x, p.y);
} else {
// importedMesh / terrainMesh: flaches (x,y,z…)-Array, Stride 3.
const pos = obj.positions;
@@ -351,6 +353,7 @@ export function useProjectActions(
const removeContextObject = useStore((s) => s.removeContextObject);
const removeContextObjects = useStore((s) => s.removeContextObjects);
const generateTerrain = useStore((s) => s.generateTerrain);
const patchContextObject = useStore((s) => s.patchContextObject);
const moveGripOf = useStore((s) => s.moveGripOf);
const moveElementByOf = useStore((s) => s.moveElementByOf);
const moveEdgeOf = useStore((s) => s.moveEdgeOf);
@@ -465,6 +468,7 @@ export function useProjectActions(
removeContextObject,
removeContextObjects,
generateTerrain,
patchContextObject,
moveGripOf,
moveElementByOf,
moveEdgeOf,
+28
View File
@@ -4945,11 +4945,39 @@ body {
}
.site-panel .site-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
padding: 4px 6px;
border-radius: 5px;
}
/* [T6]/[68] Felder von Gelände und Baugrube unter der Zeile. */
.site-panel .site-props {
flex: 1 0 100%;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 4px 8px;
font-size: 11px;
}
.site-panel .site-prop {
display: flex;
align-items: center;
justify-content: space-between;
gap: 4px;
}
.site-panel .site-prop input {
width: 64px;
}
.site-panel .site-qty {
grid-column: 1 / -1;
color: var(--text-dim, inherit);
}
.site-panel .site-check {
display: flex;
align-items: center;
gap: 3px;
font-size: 11px;
}
.site-panel .site-row:hover {
background: var(--accent-dim);
}
+9
View File
@@ -182,6 +182,15 @@ export function CommandIcon({ name }: { name: string }) {
<line x1="8" y1="3" x2="8" y2="9" strokeDasharray="1.5 1.5" />
</svg>
);
case "excavation":
// Baugrube: Geländelinie mit Grube, Böschungen schräg.
return (
<svg {...common}>
<polyline points="1,5 4,5 6.5,11 9.5,11 12,5 15,5" />
<line x1="4.8" y1="6.5" x2="3.6" y2="6.5" />
<line x1="11.2" y1="6.5" x2="12.4" y2="6.5" />
</svg>
);
case "roofhole":
// Dachhof: Dach-Umriss mit ausgespartem Innenhof.
return (