[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
+13
@@ -20,6 +20,7 @@ import { addLegend, patchLegend, removeLegend } from "./analysis/legend";
|
||||
import { lengthFromDisplay, unitsForLevel } from "./tools/displayUnits";
|
||||
import { NON_LENGTH_FIELDS } from "./commands/parseInput";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
import { useDormerNotice } from "./state/useDormerNotice";
|
||||
import {
|
||||
collectVisibleCodes,
|
||||
flattenCategories,
|
||||
@@ -366,6 +367,7 @@ export default function App() {
|
||||
const applyChange = useStore((s) => s.applyChange);
|
||||
const groupChanges = useStore((s) => s.groupChanges);
|
||||
const notify = useStore((s) => s.notify);
|
||||
useDormerNotice(project, notify);
|
||||
const undo = useStore((s) => s.undo);
|
||||
const redo = useStore((s) => s.redo);
|
||||
const canUndo = useStore((s) => s.canUndo);
|
||||
@@ -1188,6 +1190,12 @@ export default function App() {
|
||||
() => (project.ceilings ?? []).find((c) => c.id === selectedCeilingId) ?? null,
|
||||
[project.ceilings, selectedCeilingId],
|
||||
);
|
||||
// [68] Genau eine gewählte Baugrube (Griffe für Umriss und Sohle).
|
||||
const selectedExcavation = useMemo(() => {
|
||||
if (selectedContextObjectIds.length !== 1) return null;
|
||||
const o = (project.context ?? []).find((c) => c.id === selectedContextObjectIds[0]);
|
||||
return o && o.type === "excavation" ? o : null;
|
||||
}, [project.context, selectedContextObjectIds]);
|
||||
const selectedRoom = useMemo(
|
||||
() => (project.rooms ?? []).find((r) => r.id === selectedRoomId) ?? null,
|
||||
[project.rooms, selectedRoomId],
|
||||
@@ -1670,6 +1678,8 @@ export default function App() {
|
||||
setWallThickness,
|
||||
updateOpening,
|
||||
moveCeilingGrip,
|
||||
moveExcavationGrip,
|
||||
moveExcavationEdge,
|
||||
moveCeilingBy,
|
||||
moveCeilingEdge,
|
||||
updateCeiling,
|
||||
@@ -1757,6 +1767,7 @@ export default function App() {
|
||||
project,
|
||||
selectedDrawing,
|
||||
selectedCeiling,
|
||||
selectedExcavation,
|
||||
selectedRoom,
|
||||
selectedOpeningId,
|
||||
selectedStairId,
|
||||
@@ -1781,6 +1792,8 @@ export default function App() {
|
||||
moveStairBy,
|
||||
moveRoomGrip,
|
||||
moveCeilingGrip,
|
||||
moveExcavationGrip,
|
||||
moveExcavationEdge,
|
||||
moveGripOf,
|
||||
moveRoomEdge,
|
||||
moveCeilingEdge,
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
@@ -69,6 +69,7 @@ export type QueryName =
|
||||
| "ivhb"
|
||||
| "siteCheck"
|
||||
| "excavationQuantities"
|
||||
| "dormerStatus"
|
||||
| "buildingFootprint"
|
||||
| "modelTop"
|
||||
| "shadows"
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
// [112] Achsraster → IfcGrid im IFC-Export (IFC4 und IFC2x3), Prüfung mit ifcopenshell, wenn installiert.
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdtempSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import "../engine/fileioWasm.setup";
|
||||
import { exportIfcSpf } from "./exportIfc";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import type { Drawing2D, Project } from "../model/types";
|
||||
|
||||
const hasIfcOpenShell = spawnSync("python3", ["-c", "import ifcopenshell, ifcopenshell.validate, _pytest"]).status === 0;
|
||||
|
||||
function gridProject(radial = false): Project {
|
||||
const floor = sampleProject.drawingLevels.find((l) => l.kind === "floor")!;
|
||||
const grid = {
|
||||
id: "grid-1",
|
||||
type: "drawing2d",
|
||||
levelId: floor.id,
|
||||
categoryCode: sampleProject.layers[0]?.code ?? "00",
|
||||
geom: radial
|
||||
? { shape: "grid", origin: { x: 0, y: 0 }, angle: 0, radial: true, a: [{ label: "1", pos: 0 }, { label: "2", pos: 90 }], b: [{ label: "A", pos: 3 }, { label: "B", pos: 6 }] }
|
||||
: {
|
||||
shape: "grid",
|
||||
origin: { x: 1, y: 2 },
|
||||
angle: 0,
|
||||
a: [{ label: "1", pos: 0 }, { label: "2", pos: 5 }, { label: "3", pos: 9 }],
|
||||
b: [{ label: "A", pos: 0 }, { label: "B", pos: 4 }],
|
||||
},
|
||||
} as unknown as Drawing2D;
|
||||
return { ...sampleProject, drawings2d: [...sampleProject.drawings2d, grid] };
|
||||
}
|
||||
|
||||
describe("IfcGrid im Export [112]", () => {
|
||||
it("IFC4: IfcGrid mit U-/V-Achsen und Beschriftung", () => {
|
||||
const ifc = exportIfcSpf(gridProject());
|
||||
expect(ifc).toMatch(/^#\d+=IFCGRID\(/m);
|
||||
const tags = [...ifc.matchAll(/^#\d+=IFCGRIDAXIS\('([^']*)'/gm)].map((m) => m[1]);
|
||||
expect(tags).toEqual(["1", "2", "3", "A", "B"]);
|
||||
// UAxes = 3, VAxes = 2.
|
||||
const g = ifc.match(/^#\d+=IFCGRID\(.*,\((#\d+(?:,#\d+)*)\),\((#\d+(?:,#\d+)*)\),\$\);$/m)!;
|
||||
expect(g[1].split(",")).toHaveLength(3);
|
||||
expect(g[2].split(",")).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("ohne Raster kein IfcGrid; IFC2x3 ebenfalls", () => {
|
||||
expect(exportIfcSpf(sampleProject)).not.toContain("IFCGRID(");
|
||||
expect(exportIfcSpf(gridProject(), { schema: "IFC2X3" })).toMatch(/^#\d+=IFCGRID\(/m);
|
||||
});
|
||||
|
||||
it.skipIf(!hasIfcOpenShell)("ifcopenshell: gültig, Achsen lesbar (rechtwinklig und radial)", () => {
|
||||
for (const [name, p] of [["ortho", gridProject()], ["radial", gridProject(true)]] as const) {
|
||||
const dir = mkdtempSync(join(tmpdir(), "dossier-ifc-grid-"));
|
||||
const file = join(dir, `${name}.ifc`);
|
||||
writeFileSync(file, exportIfcSpf(p));
|
||||
const r = spawnSync("python3", ["scripts/validate-ifc.py", file], { encoding: "utf8", timeout: 120_000 });
|
||||
expect(r.status, `${r.stdout}\n${r.stderr}`).toBe(0);
|
||||
const read = spawnSync(
|
||||
"python3",
|
||||
["-c", "import sys, ifcopenshell\nm = ifcopenshell.open(sys.argv[1])\ng = m.by_type('IfcGrid')[0]\nprint(len(g.UAxes), len(g.VAxes), ','.join(a.AxisTag for a in g.UAxes + g.VAxes))", file],
|
||||
{ encoding: "utf8" },
|
||||
);
|
||||
expect(read.status, read.stderr).toBe(0);
|
||||
expect(read.stdout.trim()).toBe(name === "ortho" ? "3 2 1,2,3,A,B" : "2 2 1,2,A,B");
|
||||
}
|
||||
}, 240_000);
|
||||
});
|
||||
@@ -26,6 +26,8 @@ export type GripRequest =
|
||||
| { op: "ceilingGrip" | "roomGrip" | "roofGrip"; id: string; index: number; pt: P }
|
||||
| { op: "ceilingBy" | "roofBy" | "stairBy" | "roomBy" | "roomStamp"; id: string; delta: P }
|
||||
| { op: "ceilingEdge" | "roomEdge"; id: string; a: number; b: number; delta: P }
|
||||
| { op: "excavationGrip"; id: string; index: number; pt: P }
|
||||
| { op: "excavationEdge"; id: string; a: number; b: number; delta: P }
|
||||
| { op: "insertPoint"; id: string; seg: number; pt: P }
|
||||
| { op: "deletePoint"; id: string; index: number }
|
||||
| { op: "vertexType"; id: string; index: number; vertexType: "corner" | "arc" | "spline" }
|
||||
|
||||
@@ -395,6 +395,12 @@ export const de = {
|
||||
"attr.grid.bubbleMm": "Blase Ø (mm)",
|
||||
"attr.grid.levels": "Sichtbar in",
|
||||
"attr.grid.show3d": "Im 3D-Modell zeigen",
|
||||
"attr.grid.axis": "Achse bei {pos} m",
|
||||
"attr.grid.ray": "Strahl bei {pos}°",
|
||||
"attr.grid.ring": "Ring bei {pos} m",
|
||||
"attr.grid.axisLabel": "Beschriftung der Achse",
|
||||
"attr.grid.axisBubble": "Blasenseite dieser Achse",
|
||||
"attr.grid.axisBubble.grid": "Wie Raster",
|
||||
"attr.grid.levels.all": "Allen Geschossen",
|
||||
"attr.grid.levels.here": "Nur diesem Geschoss",
|
||||
"attr.dim.gap": "Abstand Hilfslinie (mm)",
|
||||
@@ -508,6 +514,10 @@ export const de = {
|
||||
"objinfo.dormer.kind.flach": "Flachdachgaube",
|
||||
"objinfo.dormer.kind.walm": "Walmgaube",
|
||||
"objinfo.dormer.remove": "Gaube entfernen",
|
||||
"objinfo.dormer.clamped": "Am First gekappt: Stirnhöhe nur {height} m (Gaube würde über den First ragen).",
|
||||
"objinfo.dormer.invalid": "Nicht herstellbar: Breite, Höhe oder Lage prüfen.",
|
||||
"dormer.clamped.toast": "Gaube am First gekappt: Stirnhöhe {height} m.",
|
||||
"dormer.invalid.toast": "Gaube nicht herstellbar: Lage oder Masse prüfen.",
|
||||
"objinfo.dormer.width": "Breite (aussen)",
|
||||
"objinfo.dormer.frontHeight": "Stirnhöhe",
|
||||
"objinfo.dormer.pitch": "Neigung Gaubendach",
|
||||
@@ -2034,6 +2044,10 @@ export const de = {
|
||||
"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.excavation.workingSpace": "Arbeitsraum [m]",
|
||||
"site.excavation.shoring": "Verbau (senkrecht), Kante",
|
||||
"site.excavation.shoringHint": "Gewählte Kanten: senkrechte Wand (Spundwand) statt Böschung",
|
||||
"site.earthDepth": "Erdreich-Band im Schnitt [m]",
|
||||
"site.type.image": "Luftbild",
|
||||
"site.group.image": "Luftbild",
|
||||
"site.dwgHint": "DWG? Zuerst mit dem gratis ODA File Converter in DXF umwandeln.",
|
||||
@@ -2657,6 +2671,10 @@ export const de = {
|
||||
"ctxImport.terrain.resolution": "Auflösung",
|
||||
"ctxImport.terrain.res2": "2 m (schnell)",
|
||||
"ctxImport.terrain.res05": "0.5 m (fein, grössere Kacheln)",
|
||||
"ctxImport.terrain.smooth": "Glättung des Höhenrasters",
|
||||
"ctxImport.terrain.smooth0": "Rohdaten",
|
||||
"ctxImport.terrain.smooth1": "Glätten (leicht)",
|
||||
"ctxImport.terrain.smooth3": "Glätten (stark)",
|
||||
"ctxImport.src.osmBuildings": "OSM-Gebäude",
|
||||
"ctxImport.src.osmRoads": "OSM-Strassen",
|
||||
"ctxImport.src.osmWater": "OSM-Wasser",
|
||||
|
||||
@@ -393,6 +393,12 @@ export const en: Record<TranslationKey, string> = {
|
||||
"attr.grid.bubbleMm": "Bubble Ø (mm)",
|
||||
"attr.grid.levels": "Visible on",
|
||||
"attr.grid.show3d": "Show in 3D model",
|
||||
"attr.grid.axis": "Axis at {pos} m",
|
||||
"attr.grid.ray": "Ray at {pos}°",
|
||||
"attr.grid.ring": "Ring at {pos} m",
|
||||
"attr.grid.axisLabel": "Axis label",
|
||||
"attr.grid.axisBubble": "Bubble side of this axis",
|
||||
"attr.grid.axisBubble.grid": "As grid",
|
||||
"attr.grid.levels.all": "All levels",
|
||||
"attr.grid.levels.here": "This level only",
|
||||
"attr.dim.gap": "Extension gap (mm)",
|
||||
@@ -506,6 +512,10 @@ export const en: Record<TranslationKey, string> = {
|
||||
"objinfo.dormer.kind.flach": "Flat-roof dormer",
|
||||
"objinfo.dormer.kind.walm": "Hipped dormer",
|
||||
"objinfo.dormer.remove": "Remove dormer",
|
||||
"objinfo.dormer.clamped": "Clamped at the ridge: front height only {height} m (the dormer would reach beyond the ridge).",
|
||||
"objinfo.dormer.invalid": "Cannot be built: check width, height or position.",
|
||||
"dormer.clamped.toast": "Dormer clamped at the ridge: front height {height} m.",
|
||||
"dormer.invalid.toast": "Dormer cannot be built: check position or size.",
|
||||
"objinfo.dormer.width": "Width (outside)",
|
||||
"objinfo.dormer.frontHeight": "Front height",
|
||||
"objinfo.dormer.pitch": "Dormer roof pitch",
|
||||
@@ -2020,6 +2030,10 @@ export const en: Record<TranslationKey, string> = {
|
||||
"site.excavation.fillSlope": "Fill slope [°]",
|
||||
"site.excavation.bermWidth": "Berm [m]",
|
||||
"site.excavation.bermHeight": "Berm every [m]",
|
||||
"site.excavation.workingSpace": "Working space [m]",
|
||||
"site.excavation.shoring": "Shoring (vertical), edge",
|
||||
"site.excavation.shoringHint": "Selected edges: vertical wall (sheet piling) instead of a slope",
|
||||
"site.earthDepth": "Earth band in section [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",
|
||||
@@ -2644,6 +2658,10 @@ export const en: Record<TranslationKey, string> = {
|
||||
"ctxImport.terrain.resolution": "Resolution",
|
||||
"ctxImport.terrain.res2": "2 m (fast)",
|
||||
"ctxImport.terrain.res05": "0.5 m (fine, larger tiles)",
|
||||
"ctxImport.terrain.smooth": "Height grid smoothing",
|
||||
"ctxImport.terrain.smooth0": "Raw data",
|
||||
"ctxImport.terrain.smooth1": "Smooth (light)",
|
||||
"ctxImport.terrain.smooth3": "Smooth (strong)",
|
||||
"ctxImport.src.osmBuildings": "OSM buildings",
|
||||
"ctxImport.src.osmRoads": "OSM roads",
|
||||
"ctxImport.src.osmWater": "OSM water",
|
||||
|
||||
@@ -60,6 +60,21 @@ export interface TerrainGrid {
|
||||
name?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* [T6] Glättet ein Höhenraster (Rust-Kern `terrain.rs::smooth_grid`): `passes` Durchgänge eines
|
||||
* Binomialfilters je Achse (0 = unverändert). Zellen ohne Messwert (`null`) bleiben leer.
|
||||
*/
|
||||
export function smoothTerrainGrid(grid: TerrainGrid, passes: number): TerrainGrid {
|
||||
if (!(passes > 0) || grid.xs.length === 0 || grid.ys.length === 0) return grid;
|
||||
const nx = grid.xs.length;
|
||||
const ny = grid.ys.length;
|
||||
const flat = new Float64Array(nx * ny);
|
||||
for (let j = 0; j < ny; j++) for (let i = 0; i < nx; i++) flat[j * nx + i] = grid.z[j]?.[i] ?? Number.NaN;
|
||||
const out = core().terrain_smooth_grid(flat, nx, ny, passes);
|
||||
const z = grid.ys.map((_, j) => grid.xs.map((__, i) => (Number.isFinite(out[j * nx + i]) ? out[j * nx + i] : null)));
|
||||
return { ...grid, z };
|
||||
}
|
||||
|
||||
/**
|
||||
* Baut ein Terrain-Mesh aus einem regulären Höhenraster (Quad-Gitter → zwei
|
||||
* Dreiecke je Zelle). Fehlende Zellen (`null`) werden ausgelassen; eine Zelle
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
// (swisstopo-DTM-Profilraster → terrainMeshFromGrid).
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { terrainMeshFromGrid } from "./terrain";
|
||||
import { smoothTerrainGrid, terrainMeshFromGrid } from "./terrain";
|
||||
import type { TerrainGrid } from "./terrain";
|
||||
|
||||
describe("terrainMeshFromGrid", () => {
|
||||
@@ -54,3 +54,18 @@ describe("terrainMeshFromGrid", () => {
|
||||
expect(zs.sort((a, b) => a - b)).toEqual([5, 7, 9, 11]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("[T6] Höhenraster glätten", () => {
|
||||
it("baut Spitzen ab, lässt Lücken und Ebenen", () => {
|
||||
const xs = [0, 1, 2, 3, 4];
|
||||
const flat = Array.from({ length: 5 }, () => Array<number | null>(5).fill(2));
|
||||
expect(smoothTerrainGrid({ xs, ys: xs, z: flat }, 3).z.flat().every((v) => Math.abs((v as number) - 2) < 1e-12)).toBe(true);
|
||||
const z = Array.from({ length: 5 }, () => Array<number | null>(5).fill(0));
|
||||
z[2][2] = 8;
|
||||
z[0][0] = null;
|
||||
const g = smoothTerrainGrid({ xs, ys: xs, z }, 1);
|
||||
expect((g.z[2][2] as number) < 8 && (g.z[2][2] as number) > 1).toBe(true);
|
||||
expect(g.z[0][0]).toBeNull();
|
||||
expect(smoothTerrainGrid({ xs, ys: xs, z }, 0)).toEqual({ xs, ys: xs, z });
|
||||
});
|
||||
});
|
||||
@@ -1176,6 +1176,15 @@ export type Excavation = {
|
||||
edgeSlopes?: Array<number>;
|
||||
bermWidth?: number;
|
||||
bermHeight?: number;
|
||||
/**
|
||||
* [68] Arbeitsraum in m: der Umriss gilt als Gebäude-Grundfläche, die Sohle liegt um dieses Mass
|
||||
* weiter aussen (Gehrung an den Ecken). Fehlt = 0 (Umriss = Sohle).
|
||||
*/
|
||||
workingSpace?: number;
|
||||
/**
|
||||
* [68] Senkrechter Verbau (Spundwand) je Kante (wie `edgeSlopes`): keine Böschung, Wand steht senkrecht.
|
||||
*/
|
||||
edgeShoring?: Array<boolean>;
|
||||
};
|
||||
|
||||
/** Ein extrudierter Körper: geschlossenes Profil (Modell-Meter) + Höhe. */
|
||||
@@ -1280,7 +1289,15 @@ export type FrameDetail = {
|
||||
};
|
||||
|
||||
/** Eine Achse des Achsrasters: Beschriftung und Lage (Abstand bzw. Winkel/Radius, s. `Grid`). */
|
||||
export type GridAxis = { label: string; pos: number };
|
||||
export type GridAxis = {
|
||||
label: string;
|
||||
pos: number;
|
||||
/** Blasenseite nur dieser Achse (überschreibt `Grid.bubbles`); fehlt = wie das Raster. */
|
||||
bubble?: GridBubbles;
|
||||
};
|
||||
|
||||
/** Welche Achsenden eine Blase tragen. */
|
||||
export type GridBubbles = "start" | "end" | "both";
|
||||
|
||||
/**
|
||||
* Raster-Regel: generiert Wände entlang gleichmäßiger X-/Y-Achsen.
|
||||
@@ -3025,6 +3042,8 @@ export type TerrainMesh = {
|
||||
contourInterval?: number;
|
||||
/** [T6] Jede n-te Höhenlinie ist Zähllinie (dicker, beschriftet). Default 5. */
|
||||
contourIndexEvery?: number;
|
||||
/** [T6] Tiefe des Erdreich-Bands im Schnitt unter dem Gelände in m (Default 1.5). */
|
||||
earthDepth?: number;
|
||||
};
|
||||
|
||||
/** Ein zusammenhängender Textabschnitt mit einheitlicher Formatierung. */
|
||||
|
||||
@@ -502,6 +502,7 @@ export function AttributesPanel() {
|
||||
Standard zurück. Die Masszahl selbst wird direkt im Plan am
|
||||
eigenen Griff verschoben (rastet nahe der Standardlage ein). */}
|
||||
{drawing?.geom.shape === "grid" && (() => {
|
||||
const fmtAxis = (v: number) => (Math.round(v * 100) / 100).toString();
|
||||
const geom = drawing.geom as Extract<typeof drawing.geom, { shape: "grid" }>;
|
||||
const here = geom.levels?.includes(drawing.levelId) && geom.levels.length === 1;
|
||||
return (
|
||||
@@ -529,6 +530,42 @@ export function AttributesPanel() {
|
||||
<span className="attr-val">
|
||||
<input type="checkbox" checked={geom.show3d === true} onChange={(e) => host.onSetGridProps(drawing.id, { show3d: e.target.checked })} />
|
||||
</span>
|
||||
{(["a", "b"] as const).map((list) =>
|
||||
geom[list].map((ax, i) => (
|
||||
<Fragment key={`${list}${i}`}>
|
||||
<span className="attr-key">{t(geom.radial ? (list === "a" ? "attr.grid.ray" : "attr.grid.ring") : "attr.grid.axis", { pos: fmtAxis(ax.pos) })}</span>
|
||||
<span className="attr-val" data-testid="grid-axis-row">
|
||||
<input
|
||||
className="attr-num"
|
||||
style={{ width: 56 }}
|
||||
type="text"
|
||||
aria-label={t("attr.grid.axisLabel")}
|
||||
value={ax.label}
|
||||
onChange={(e) => host.onSetGridProps(drawing.id, { [list]: geom[list].map((x, k) => (k === i ? { ...x, label: e.target.value } : x)) })}
|
||||
/>
|
||||
<select
|
||||
aria-label={t("attr.grid.axisBubble")}
|
||||
value={ax.bubble ?? ""}
|
||||
onChange={(e) => {
|
||||
const v = e.target.value as "" | "start" | "end" | "both";
|
||||
host.onSetGridProps(drawing.id, {
|
||||
[list]: geom[list].map((x, k) => {
|
||||
if (k !== i) return x;
|
||||
const { bubble: _old, ...rest } = x;
|
||||
return v ? { ...rest, bubble: v } : rest;
|
||||
}),
|
||||
});
|
||||
}}
|
||||
>
|
||||
<option value="">{t("attr.grid.axisBubble.grid")}</option>
|
||||
<option value="both">{t("attr.grid.bubbles.both")}</option>
|
||||
<option value="start">{t("attr.grid.bubbles.start")}</option>
|
||||
<option value="end">{t("attr.grid.bubbles.end")}</option>
|
||||
</select>
|
||||
</span>
|
||||
</Fragment>
|
||||
)),
|
||||
)}
|
||||
<span className="attr-key">{t("attr.grid.levels")}</span>
|
||||
<span className="attr-val">
|
||||
<select value={here ? "here" : "all"} onChange={(e) => host.onSetGridProps(drawing.id, { levels: e.target.value === "here" ? [drawing.levelId] : undefined })}>
|
||||
|
||||
@@ -18,7 +18,8 @@ import { UValueRow } from "./UValueRow";
|
||||
import { lengthFromDisplay, lengthToDisplay, unitsForLevel, xToDisplay, yFromDisplay, yToDisplay } from "../tools/displayUnits";
|
||||
import { solidProps } from "../engine/truckSolid";
|
||||
import type { SolidProps, SolidSpec } from "../engine/truckSolid";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { dormerStatus } from "../analysis/dormerStatus";
|
||||
// Anzeige-Fallbacks für die Öffnungs-Linien-Übersteuerung (LineStyleRow) —
|
||||
// dieselben Werte wie POCHE_STROKE/SYMBOL_HAIRLINE_MM im Grundriss (Kern: plan/style.rs)
|
||||
// (reine UI-Default-Anzeige, kein Re-Export nötig).
|
||||
@@ -967,6 +968,7 @@ function rectOutline(x0: number, y0: number, w: number, d: number) {
|
||||
/** Gauben ([G5]) des Dachs: Art, Masse, Neigung, Aufbau je Gaube; Hinzufügen über den Befehl „Gaube". */
|
||||
function DormersSection({ roof, host }: { roof: RoofInfo; host: ReturnType<typeof usePanelHost> }) {
|
||||
const dormers = roof.dormers ?? [];
|
||||
const status = useMemo(() => dormerStatus(host.project), [host.project]);
|
||||
const patch = (i: number, p: Partial<Dormer>) =>
|
||||
host.onSetRoofPatch({ dormers: dormers.map((d, k) => (k === i ? { ...d, ...p } : d)) }, `dormer-${i}`);
|
||||
const num = (labelKey: TranslationKey, value: number, step: number, apply: (v: number) => void) => (
|
||||
@@ -991,6 +993,15 @@ function DormersSection({ roof, host }: { roof: RoofInfo; host: ReturnType<typeo
|
||||
<div className="objinfo-section-label">{t("objinfo.dormer.section")}</div>
|
||||
{dormers.map((d, i) => (
|
||||
<div key={d.id} data-testid="objinfo-dormer">
|
||||
{(() => {
|
||||
const st = status.find((s) => s.dormerId === d.id);
|
||||
if (!st || !(st.clamped || st.invalid)) return null;
|
||||
return (
|
||||
<div className="objinfo-warn" role="alert" data-testid="objinfo-dormer-warning">
|
||||
{st.invalid ? t("objinfo.dormer.invalid") : t("objinfo.dormer.clamped", { height: st.effectiveHeight.toFixed(2) })}
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.dormer.kind")}</span>
|
||||
<Dropdown
|
||||
|
||||
@@ -319,6 +319,14 @@ export function SitePanel() {
|
||||
placeholder="5"
|
||||
onChange={patch(obj.id, "contourIndexEvery")}
|
||||
/>
|
||||
<NumField
|
||||
label={t("site.earthDepth")}
|
||||
value={obj.earthDepth}
|
||||
step={0.5}
|
||||
min={0.1}
|
||||
placeholder="1.5"
|
||||
onChange={patch(obj.id, "earthDepth")}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{obj.type === "excavation" && (
|
||||
@@ -354,6 +362,33 @@ export function SitePanel() {
|
||||
placeholder="—"
|
||||
onChange={patch(obj.id, "bermHeight")}
|
||||
/>
|
||||
<NumField
|
||||
label={t("site.excavation.workingSpace")}
|
||||
value={obj.workingSpace}
|
||||
step={0.1}
|
||||
min={0}
|
||||
placeholder="0"
|
||||
onChange={patch(obj.id, "workingSpace")}
|
||||
/>
|
||||
<div className="site-prop" title={t("site.excavation.shoringHint")}>
|
||||
<span>{t("site.excavation.shoring")}</span>
|
||||
<span>
|
||||
{obj.outline.map((_, i) => (
|
||||
<label key={i} style={{ marginRight: 6 }}>
|
||||
<input
|
||||
type="checkbox"
|
||||
data-testid={`excavation-shoring-${i}`}
|
||||
checked={obj.edgeShoring?.[i] === true}
|
||||
onChange={(e) => {
|
||||
const next = obj.outline.map((__, k) => (k === i ? e.target.checked : obj.edgeShoring?.[k] === true));
|
||||
host.onPatchContextObject(obj.id, { edgeShoring: next.some(Boolean) ? next : undefined }, `site-${obj.id}-edgeShoring`);
|
||||
}}
|
||||
/>
|
||||
{i + 1}
|
||||
</label>
|
||||
))}
|
||||
</span>
|
||||
</div>
|
||||
<ExcavationQty q={quantities.find((x) => x.id === obj.id)} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
+10
-1
@@ -300,7 +300,16 @@ export interface PanelHostValue {
|
||||
/** Achsraster ([112]): Blasenseite, Überstand (m), Blasen-Ø (Papier-mm), Geschosse (leer = alle). */
|
||||
onSetGridProps: (
|
||||
drawingId: string,
|
||||
patch: { bubbles?: "start" | "end" | "both"; extend?: number; bubbleMm?: number; levels?: string[] | undefined; show3d?: boolean },
|
||||
patch: {
|
||||
bubbles?: "start" | "end" | "both";
|
||||
extend?: number;
|
||||
bubbleMm?: number;
|
||||
levels?: string[] | undefined;
|
||||
show3d?: boolean;
|
||||
/** Achsen (Beschriftung, Lage, Blasenseite je Achse): ganze Liste ersetzen. */
|
||||
a?: import("../model/types").GridAxis[];
|
||||
b?: import("../model/types").GridAxis[];
|
||||
},
|
||||
) => void;
|
||||
onSetDimensionStyle: (
|
||||
drawingId: string,
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// [68] Baugrube: Griffe für Umriss-Ecken, Kanten und Sohlenhöhe (Kern `grips.rs`, Griff-Lage `excavationGripPoints`).
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { documentFor } from "../core/document";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import type { Excavation, Project } from "../model/types";
|
||||
import { excavationGripPoints } from "./useGripEditing";
|
||||
|
||||
const pit: Excavation = {
|
||||
id: "bg",
|
||||
type: "excavation",
|
||||
name: "Baugrube",
|
||||
outline: [{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 4 }, { x: 0, y: 4 }],
|
||||
bottom: -2,
|
||||
};
|
||||
const project = (): Project => ({ ...sampleProject, context: [pit] });
|
||||
|
||||
function commit(base: Project, req: object): Excavation {
|
||||
const r = documentFor(base).commitGrip(base, req, undefined, 1);
|
||||
if ("problems" in r) throw new Error(r.problems.join(";"));
|
||||
return r.project.context!.find((c) => c.id === "bg") as Excavation;
|
||||
}
|
||||
|
||||
describe("Baugrube: Griffe", () => {
|
||||
it("Griff-Punkte: Ecken plus Sohlen-Griff (Schwerpunkt, y + Sohle)", () => {
|
||||
const pts = excavationGripPoints(pit);
|
||||
expect(pts).toHaveLength(5);
|
||||
expect(pts[4]).toEqual({ x: 2, y: 0 });
|
||||
});
|
||||
|
||||
it("Ecke, Kante und Sohle ziehen", () => {
|
||||
const p = project();
|
||||
expect(commit(p, { op: "excavationGrip", id: "bg", index: 2, pt: [5, 6] }).outline[2]).toEqual({ x: 5, y: 6 });
|
||||
const edge = commit(p, { op: "excavationEdge", id: "bg", a: 0, b: 1, delta: [0, -1] });
|
||||
expect([edge.outline[0].y, edge.outline[1].y]).toEqual([-1, -1]);
|
||||
// Sohlen-Griff liegt bei (2, 2 + bottom); auf y = −1 ziehen → bottom = −3.
|
||||
expect(commit(p, { op: "excavationGrip", id: "bg", index: 4, pt: [2, -1] }).bottom).toBe(-3);
|
||||
});
|
||||
});
|
||||
@@ -371,6 +371,9 @@ export interface ProjectSlice {
|
||||
// ── Decken-Editieren ──────────────────────────────────────────────────────
|
||||
/** Verschiebt EINEN Umriss-Vertex (per Index) einer Decke. */
|
||||
moveCeilingGrip: (ceilingId: string, index: number, pt: Vec2) => void;
|
||||
/** [68] Baugrube: Umriss-Ecke ziehen (Index = Ecke; Index = Eckenzahl: Sohlenhöhe). */
|
||||
moveExcavationGrip: (id: string, index: number, pt: Vec2) => void;
|
||||
moveExcavationEdge: (id: string, aIndex: number, bIndex: number, delta: Vec2) => void;
|
||||
/** Verschiebt eine Decke (ganzer Umriss) um `delta`. */
|
||||
moveCeilingBy: (ceilingId: string, delta: Vec2) => void;
|
||||
/** Verschiebt eine Umriss-KANTE (beide Vertices) einer Decke um `delta`. */
|
||||
@@ -1178,6 +1181,11 @@ export function createProjectSlice(
|
||||
moveCeilingGrip: (ceilingId, index, pt) =>
|
||||
applyGrip({ op: "ceilingGrip", id: ceilingId, index, pt: gripPt(pt) }, `moveCeilingGrip:${ceilingId}:${index}`),
|
||||
|
||||
moveExcavationGrip: (id, index, pt) => applyGrip({ op: "excavationGrip", id, index, pt: gripPt(pt) }, `moveExcavationGrip:${id}:${index}`),
|
||||
|
||||
moveExcavationEdge: (id, aIndex, bIndex, delta) =>
|
||||
applyGrip({ op: "excavationEdge", id, a: aIndex, b: bIndex, delta: gripPt(delta) }, `moveExcavationEdge:${id}:${aIndex}:${bIndex}`),
|
||||
|
||||
moveCeilingBy: (ceilingId, delta) =>
|
||||
applyGrip({ op: "ceilingBy", id: ceilingId, delta: gripPt(delta) }, `moveCeilingBy:${ceilingId}`),
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// Hinweis (Toast), sobald eine Gaube durch Anlegen oder Ändern am First gekappt wird ([G5]). Beim Öffnen
|
||||
// eines Projekts nur merken, nicht melden (der Befund steht in der Objekt-Info des Dachs).
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import type { Project } from "../model/types";
|
||||
import { affectedKeys, dormerStatus, newlyAffected } from "../analysis/dormerStatus";
|
||||
import type { DormerStatus } from "../analysis/dormerStatus";
|
||||
import { t } from "../i18n";
|
||||
|
||||
export function useDormerNotice(project: Project, notify: (msg: string, kind?: "info" | "warning" | "error") => void) {
|
||||
const seen = useRef<{ id: string; keys: Set<string> } | null>(null);
|
||||
useEffect(() => {
|
||||
let status: DormerStatus[];
|
||||
try {
|
||||
status = dormerStatus(project);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
const prev = seen.current;
|
||||
seen.current = { id: project.id, keys: affectedKeys(status) };
|
||||
if (!prev || prev.id !== project.id) return;
|
||||
for (const s of newlyAffected(prev.keys, status)) {
|
||||
notify(s.invalid ? t("dormer.invalid.toast") : t("dormer.clamped.toast", { height: s.effectiveHeight.toFixed(2) }), "warning");
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [project.roofs, project.id, notify]);
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
import { useRef, useState, type RefObject } from "react";
|
||||
import { add, dot, leftNormal, normalize, scale, sub, wallCorners } from "../model/geometry";
|
||||
import type { Ceiling, Drawing2D, EdgeGrip, Project, Room, Stair, Vec2 } from "../model/types";
|
||||
import type { Ceiling, Drawing2D, EdgeGrip, Excavation, Project, Room, Stair, Vec2 } from "../model/types";
|
||||
import { wallTypeThickness } from "../model/types";
|
||||
import { bulgeArcPoints, drawingVertices, surfaceOpeningGripPatch, surfaceOpeningGrips, surfaceOpeningInfo, wallArcBand } from "../core";
|
||||
import { gripDrawingIdsFor } from "./gripLimits";
|
||||
@@ -35,10 +35,20 @@ function arcApex(a: Vec2, b: Vec2, bulge: number): Vec2 {
|
||||
return add(scale(add(a, b), 0.5), scale(normalize(leftNormal(sub(b, a))), h * bulge));
|
||||
}
|
||||
|
||||
/** Griff-Punkte einer Baugrube: Umriss-Ecken, dann der Sohlen-Griff (Schwerpunkt, y + Sohlenhöhe; Kern `grips.rs`). */
|
||||
export function excavationGripPoints(e: Excavation): Vec2[] {
|
||||
const n = Math.max(1, e.outline.length);
|
||||
const cx = e.outline.reduce((a, q) => a + q.x, 0) / n;
|
||||
const cy = e.outline.reduce((a, q) => a + q.y, 0) / n;
|
||||
return [...e.outline, { x: cx, y: cy + e.bottom }];
|
||||
}
|
||||
|
||||
export function useGripEditing(opts: {
|
||||
project: Project;
|
||||
selectedDrawing: Drawing2D | null;
|
||||
selectedCeiling: Ceiling | null;
|
||||
/** [68] Einzeln gewählte Baugrube (Umriss-Ecken, Kanten, Sohlenhöhe als Griffe). */
|
||||
selectedExcavation?: Excavation | null;
|
||||
selectedRoom: Room | null;
|
||||
selectedOpeningId: string | null;
|
||||
selectedStairId: string | null;
|
||||
@@ -79,6 +89,8 @@ export function useGripEditing(opts: {
|
||||
moveStairBy: (id: string, delta: Vec2) => void;
|
||||
moveRoomGrip: (id: string, index: number, pt: Vec2) => void;
|
||||
moveCeilingGrip: (id: string, index: number, pt: Vec2) => void;
|
||||
moveExcavationGrip: (id: string, index: number, pt: Vec2) => void;
|
||||
moveExcavationEdge: (id: string, aIndex: number, bIndex: number, delta: Vec2) => void;
|
||||
moveGripOf: (
|
||||
drawingId: string | null,
|
||||
wallId: string | null,
|
||||
@@ -108,6 +120,7 @@ export function useGripEditing(opts: {
|
||||
project,
|
||||
selectedDrawing,
|
||||
selectedCeiling,
|
||||
selectedExcavation = null,
|
||||
selectedRoom,
|
||||
selectedOpeningId,
|
||||
selectedStairId,
|
||||
@@ -132,6 +145,8 @@ export function useGripEditing(opts: {
|
||||
moveStairBy,
|
||||
moveRoomGrip,
|
||||
moveCeilingGrip,
|
||||
moveExcavationGrip,
|
||||
moveExcavationEdge,
|
||||
moveGripOf,
|
||||
moveRoomEdge,
|
||||
moveCeilingEdge,
|
||||
@@ -275,6 +290,12 @@ export function useGripEditing(opts: {
|
||||
gripOwnerRange.push([0, 0]);
|
||||
return [stairMoveHandle(st)];
|
||||
}
|
||||
// [68] Baugrube: Umriss-Ecken + Sohlen-Griff (Lage: Schwerpunkt, y um die Sohlenhöhe versetzt).
|
||||
if (modelEditable && selectedExcavation && !selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
|
||||
const pts = excavationGripPoints(selectedExcavation);
|
||||
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
|
||||
return pts;
|
||||
}
|
||||
// Decke: die Umriss-Vertices als Griffe (nur bei genau einer gewählten Decke,
|
||||
// solange kein 2D-Element/Wand mitgewählt ist — kein Multi-Select für Decken).
|
||||
if (modelEditable && selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
|
||||
@@ -386,6 +407,9 @@ export function useGripEditing(opts: {
|
||||
// Verschieben EINER Kante einer komplexen Polylinie, §Task B).
|
||||
const edgeGrips: EdgeGrip[] = (() => {
|
||||
// ringEdges/openEdges/polylineEdgeGrips: Kern (`geometry/grips.ts`, `grips.rs`).
|
||||
if (modelEditable && selectedExcavation && !selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
|
||||
return ringEdges(selectedExcavation.outline, {});
|
||||
}
|
||||
// Decke: geschlossener Ring aus dem Umriss (Auswahl exklusiv, wie bei grips).
|
||||
if (modelEditable && selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
|
||||
return ringEdges(selectedCeiling.outline, {});
|
||||
@@ -525,7 +549,7 @@ export function useGripEditing(opts: {
|
||||
// Dasselbe für das Verschieben eines ganzen 2D-Elements (Gesamt-Delta) und für
|
||||
// Kanten-Griffe von Polylinien (Ziel-Delta): bis zum Loslassen nur Vorschau.
|
||||
const pendingWallGripRef = useRef<{ wallId: string; localIndex: number; flat: number; pt: Vec2 } | null>(null);
|
||||
const pendingAreaGripRef = useRef<{ kind: "room" | "ceiling"; id: string; index: number; flat: number; pt: Vec2 } | null>(null);
|
||||
const pendingAreaGripRef = useRef<{ kind: "room" | "ceiling" | "excavation"; id: string; index: number; flat: number; pt: Vec2 } | null>(null);
|
||||
const pendingAreaMoveRef = useRef<{ kind: "ceiling" | "room" | "stair"; id: string; total: Vec2 } | null>(null);
|
||||
const pendingWallMoveRef = useRef<{ wallId: string; total: Vec2 } | null>(null);
|
||||
/** Aufgeschobene Öffnungs-Verschiebung im Schnitt/in der Ansicht (neue `position`). */
|
||||
@@ -634,7 +658,9 @@ export function useGripEditing(opts: {
|
||||
if (!owner?.drawingId && !owner?.wallId) {
|
||||
// Raum/Decke (exklusiv) — kein Owner, `localIndex` fehlt dann auch, also
|
||||
// ist der flache `index` selbst der Ring-Index.
|
||||
const pts = selectedCeiling
|
||||
const pts = selectedExcavation && !selectedCeiling
|
||||
? selectedExcavation.outline
|
||||
: selectedCeiling
|
||||
? selectedCeiling.outline
|
||||
: selectedRoom
|
||||
? selectedRoom.boundary
|
||||
@@ -907,6 +933,12 @@ export function useGripEditing(opts: {
|
||||
if (st) moveStairBy(st.id, sub(pt, stairMoveHandle(st)));
|
||||
return;
|
||||
}
|
||||
// [68] Baugrube: Sohlen-Griff sofort (Höhe), Ecken als Vorschau bis zum Setzen.
|
||||
if (selectedExcavation && !selectedCeilingId && !selectedRoomId) {
|
||||
if (index >= selectedExcavation.outline.length) moveExcavationGrip(selectedExcavation.id, index, pt);
|
||||
else pendingAreaGripRef.current = { kind: "excavation", id: selectedExcavation.id, index, flat: index, pt };
|
||||
return;
|
||||
}
|
||||
// Raum/Decke: Eckpunkt-Zug nur als Vorschau, Projekt erst beim Setzen.
|
||||
if (selectedRoomId || selectedCeilingId) {
|
||||
pendingAreaGripRef.current = selectedRoomId
|
||||
@@ -950,6 +982,8 @@ export function useGripEditing(opts: {
|
||||
const ring =
|
||||
pa.kind === "room"
|
||||
? (project.rooms ?? []).find((r) => r.id === pa.id)?.boundary
|
||||
: pa.kind === "excavation"
|
||||
? selectedExcavation?.outline
|
||||
: (project.ceilings ?? []).find((c) => c.id === pa.id)?.outline;
|
||||
if (!ring) return [];
|
||||
return [{ kind: "poly", pts: ring.map((q, i) => (i === pa.index ? pa.pt : q)), closed: true }];
|
||||
@@ -994,6 +1028,7 @@ export function useGripEditing(opts: {
|
||||
pendingAreaGripRef.current = null;
|
||||
if (pa) {
|
||||
if (pa.kind === "room") moveRoomGrip(pa.id, pa.index, pa.pt);
|
||||
else if (pa.kind === "excavation") moveExcavationGrip(pa.id, pa.index, pa.pt);
|
||||
else moveCeilingGrip(pa.id, pa.index, pa.pt);
|
||||
}
|
||||
const pw = pendingWallGripRef.current;
|
||||
@@ -1073,7 +1108,8 @@ export function useGripEditing(opts: {
|
||||
applyEdge(pend.edge, pend.delta);
|
||||
};
|
||||
const applyEdge = (edge: EdgeGrip, delta: Vec2) => {
|
||||
if (selectedRoomId) moveRoomEdge(selectedRoomId, edge.aIndex, edge.bIndex, delta);
|
||||
if (selectedExcavation && !selectedRoomId && !selectedCeilingId) moveExcavationEdge(selectedExcavation.id, edge.aIndex, edge.bIndex, delta);
|
||||
else if (selectedRoomId) moveRoomEdge(selectedRoomId, edge.aIndex, edge.bIndex, delta);
|
||||
else if (selectedCeilingId) moveCeilingEdge(selectedCeilingId, edge.aIndex, edge.bIndex, delta);
|
||||
else moveEdgeOf(edge.owner?.drawingId ?? selectedDrawingId, edge.owner?.wallId ?? selectedWallId, edge.aIndex, edge.bIndex, delta);
|
||||
};
|
||||
|
||||
@@ -372,6 +372,8 @@ export function useProjectActions(
|
||||
const setWallThickness = useStore((s) => s.setWallThickness);
|
||||
const updateOpening = useStore((s) => s.updateOpening);
|
||||
const moveCeilingGrip = useStore((s) => s.moveCeilingGrip);
|
||||
const moveExcavationGrip = useStore((s) => s.moveExcavationGrip);
|
||||
const moveExcavationEdge = useStore((s) => s.moveExcavationEdge);
|
||||
const moveCeilingBy = useStore((s) => s.moveCeilingBy);
|
||||
const moveCeilingEdge = useStore((s) => s.moveCeilingEdge);
|
||||
const updateCeiling = useStore((s) => s.updateCeiling);
|
||||
@@ -487,6 +489,8 @@ export function useProjectActions(
|
||||
setWallThickness,
|
||||
updateOpening,
|
||||
moveCeilingGrip,
|
||||
moveExcavationGrip,
|
||||
moveExcavationEdge,
|
||||
moveCeilingBy,
|
||||
moveCeilingEdge,
|
||||
updateCeiling,
|
||||
|
||||
@@ -22,7 +22,7 @@ import { fetchOsm } from "../io/osm";
|
||||
import type { OsmSelection } from "../io/osm";
|
||||
import { featuresToContextObjects } from "../io/geoContext";
|
||||
import type { GeoFeature } from "../io/geoContext";
|
||||
import { terrainMeshFromGrid } from "../model/terrain";
|
||||
import { smoothTerrainGrid, terrainMeshFromGrid } from "../model/terrain";
|
||||
import { makeOrigin } from "../io/lv95";
|
||||
import type { GeoOrigin, LV95 } from "../io/lv95";
|
||||
import type { ContextObject, TerrainMesh } from "../model/types";
|
||||
@@ -125,6 +125,8 @@ export function ContextImportDialog({
|
||||
const [sources, setSources] = useState<Sources>(DEFAULT_SOURCES);
|
||||
// 2 m = Default (schneller/kleinere Kacheln); 0.5 m für Detailarbeit.
|
||||
const [terrainResolution, setTerrainResolution] = useState<TerrainResolution>("2");
|
||||
// [T6] Glättung des swissALTI3D-Rasters vor dem Vernetzen: Durchgänge des Binomialfilters (0 = aus).
|
||||
const [terrainSmooth, setTerrainSmooth] = useState(0);
|
||||
|
||||
const [searching, setSearching] = useState(false);
|
||||
const [importing, setImporting] = useState(false);
|
||||
@@ -277,7 +279,7 @@ export function ContextImportDialog({
|
||||
// Gelände-Höhenraster (echtes swissALTI3D-XYZ, native Auflösung) → Terrain-Mesh.
|
||||
let terrain: TerrainMesh | null = null;
|
||||
if (terrainResult?.grid) {
|
||||
const mesh = terrainMeshFromGrid(terrainResult.grid);
|
||||
const mesh = terrainMeshFromGrid(smoothTerrainGrid(terrainResult.grid, terrainSmooth));
|
||||
if (mesh.positions.length >= 9) terrain = mesh;
|
||||
}
|
||||
|
||||
@@ -553,6 +555,18 @@ export function ContextImportDialog({
|
||||
<option value="2">{t("ctxImport.terrain.res2")}</option>
|
||||
<option value="0.5">{t("ctxImport.terrain.res05")}</option>
|
||||
</select>
|
||||
<select
|
||||
className="cim-input"
|
||||
value={terrainSmooth}
|
||||
disabled={!sources.swissTerrain}
|
||||
onChange={(e) => setTerrainSmooth(Number(e.target.value))}
|
||||
aria-label={t("ctxImport.terrain.smooth")}
|
||||
title={t("ctxImport.terrain.smooth")}
|
||||
>
|
||||
<option value="0">{t("ctxImport.terrain.smooth0")}</option>
|
||||
<option value="1">{t("ctxImport.terrain.smooth1")}</option>
|
||||
<option value="3">{t("ctxImport.terrain.smooth3")}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="cim-check">
|
||||
<input
|
||||
|
||||
Reference in new issue
Block a user