Merge [191] Baugrube mit Bögen

This commit is contained in:
Claude committed 2026-11-12 06:19:13 +00:00
commit cd76a2475c
23 files changed
+678 -105

No files matched your search

+1
View File
@@ -74,6 +74,7 @@ export { arcApex, drawingVertices, gripPt, openEdges, polylineEdgeGrips, ringEdg
export { verticalExtents } from "../geometry/grips";
export type { VerticalExtent } from "../geometry/grips";
export type { GripRequest, RingKind } from "../geometry/grips";
export { edgeArcToggle, type ArcRingKind } from "../geometry/grips";
export { clampInside, coincidentGripPoints, excavationGripPoints, gripArcWallRadius, gripArcWallResize, gripArcWallTarget, gripAxisLock, gripEdgeTarget, gripPolar, gripPolarPoint, openingGripPoint, openingSheetSlide, openingTypedPosition, contourMarks, sheetHeightDrag, snapSheetHeight, stairMoveHandle, stairParamPoints, wallGripPoints } from "../geometry/gripDrag";
export type { EdgeDrive, GripLocks, SheetHeightKind } from "../geometry/gripDrag";
export { openingPreviewProject, openingPreviewSvgs } from "../plan/openingPreview";
+15 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { drawingVertices, openEdges, polylineEdgeGrips, ringEdges } from "./grips";
import { drawingVertices, edgeArcToggle, openEdges, polylineEdgeGrips, ringEdges } from "./grips";
import { documentFor } from "../core/document";
import type { Drawing2D, Project } from "../model/types";
@@ -151,3 +151,17 @@ describe("polylineEdgeGrips", () => {
expect(e.map((g) => [g.aIndex, g.bIndex, g.free])).toEqual([[0, 1, true], [2, 3, true]]);
});
});
describe("[191] Kante gerade ↔ Bogen", () => {
const sq = [{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 4 }, { x: 0, y: 4 }];
it("gerade → Segmentbogen nach aussen (Pfeilhöhe Sehne/4), unabhängig vom Umlaufsinn", () => {
expect(edgeArcToggle(sq, undefined, 1)).toEqual({ pt: { x: 5, y: 2 }, toArc: true });
// Im Uhrzeigersinn ist Kante 0 die Nordkante (0,4) → (4,4): aussen liegt darüber.
expect(edgeArcToggle([...sq].reverse(), [0, 0, 0, 0], 0)).toEqual({ pt: { x: 2, y: 5 }, toArc: true });
});
it("Bogen → Sehnenmitte (gerade), Unsinn → null", () => {
expect(edgeArcToggle(sq, [0, -1, 0, 0], 1)).toEqual({ pt: { x: 4, y: 2 }, toArc: false });
expect(edgeArcToggle(sq, undefined, 4)).toBeNull();
expect(edgeArcToggle(sq.slice(0, 2), undefined, 0)).toBeNull();
});
});
+21 -2
View File
@@ -20,6 +20,8 @@ type P = [number, number];
/** Elemente mit Umriss-Ring, an denen sich Ecken einfügen/löschen lassen (geschlossene Polylinie eingeschlossen). */
export type RingKind = "roof" | "ceiling" | "room" | "excavation" | "polyline" | "contours";
/** [191] Umriss-Ringe mit Bögen je Kante (Scheitel-Griff `ringArc`). */
export type ArcRingKind = "roof" | "ceiling" | "room" | "excavation";
/** Eine Griff-Änderung für den Kern (`grips.rs::run`); Zahlen dürfen NaN/±∞ sein (Marken). */
export type GripRequest =
@@ -50,8 +52,8 @@ export type GripRequest =
| { op: "ringInsert"; kind: RingKind; id: string; seg: number; pt: P }
| { op: "ringDelete"; kind: RingKind; id: string; index: number }
| { op: "ringTidy"; kind: RingKind; id: string; index: number; tol?: number }
// [191] Bogen-Scheitel einer Umriss-Kante (Decke, Raum, Dach samt Höfen; `seg` wie bei `ringInsert`).
| { op: "ringArc"; kind: "roof" | "ceiling" | "room"; id: string; seg: number; pt: P }
// [191] Bogen-Scheitel einer Umriss-Kante (Decke, Raum, Dach samt Höfen, Baugrube; `seg` wie bei `ringInsert`).
| { op: "ringArc"; kind: ArcRingKind; id: string; seg: number; pt: P }
// [151] Parameter-Griff einer Podesttreppe (Kern `grip_drag::stair_param_drag`).
| { op: "stairParam"; id: string; index: number; pt: P }
| { op: "excavationEdge"; id: string; a: number; b: number; delta: P }
@@ -135,6 +137,23 @@ export function arcApex(a: Vec2, b: Vec2, bulge: number | undefined): Vec2 {
return { x: (a.x + b.x) / 2 - (b.y - a.y) * k, y: (a.y + b.y) / 2 + (b.x - a.x) * k };
}
/**
* [191] „Kante gerade ↔ Bogen" (Kontextmenü an einer Umriss-Kante): Ziel-Scheitel für `ringArc` an Kante `i` des
* geschlossenen Rings. Gerade Kante → Segmentbogen nach aussen (Pfeilhöhe = Sehne/4, Bulge ±0.5); Bogenkante →
* Sehnenmitte (gerade). `null` bei kaputtem Index oder Ring.
*/
export function edgeArcToggle(pts: readonly Vec2[], bulge: readonly number[] | undefined, i: number): { pt: Vec2; toArc: boolean } | null {
const n = pts.length;
if (n < 3 || !Number.isInteger(i) || i < 0 || i >= n) return null;
const [a, b] = [pts[i], pts[(i + 1) % n]];
const cur = bulge?.[i];
if (cur && Number.isFinite(cur) && Math.abs(cur) > 1e-9) return { pt: arcApex(a, b, 0), toArc: false };
let area = 0;
for (let k = 0; k < n; k++) area += pts[k].x * pts[(k + 1) % n].y - pts[(k + 1) % n].x * pts[k].y;
// Gegen den Uhrzeigersinn liegt aussen rechts der Kante (Bulge negativ = Scheitel rechts).
return { pt: arcApex(a, b, area >= 0 ? -0.5 : 0.5), toArc: true };
}
/**
* Offene Kette (Linie/offene Polylinie) → ein Griff je Segment, OHNE Schlusskante. `normal` dient nur
* der Darstellung (linke Normale der Kante); die Bewegung ist frei (`free: true`).
+2
View File
@@ -1088,6 +1088,8 @@ export const de = {
"site.meshPointHeight.title": "Höhe des Netzpunkts",
"site.meshPointHeight.label": "Höhe von Netzpunkt {n} (m)",
"site.meshPointDelete": "Punkt löschen",
"ctx.edgeToArc": "Kante als Bogen",
"ctx.edgeStraight": "Kante gerade",
"ctx.vertexType.corner": "Eckpunkt",
"ctx.vertexType.arc": "Bogenpunkt",
"ctx.vertexType.spline": "Splinepunkt",
+2
View File
@@ -1083,6 +1083,8 @@ export const en: Record<TranslationKey, string> = {
"site.meshPointHeight.title": "Mesh point height",
"site.meshPointHeight.label": "Height of mesh point {n} (m)",
"site.meshPointDelete": "Delete point",
"ctx.edgeToArc": "Make edge an arc",
"ctx.edgeStraight": "Straighten edge",
"ctx.vertexType.corner": "Corner point",
"ctx.vertexType.arc": "Arc point",
"ctx.vertexType.spline": "Spline point",
+8 -6
View File
@@ -5,7 +5,7 @@
// die Anzeige-Werte zur Auswahl rechnet `selectionMenuState`.
import type { RefObject } from "react";
import { useStore } from "../state/appStore";
import { getState, useStore } from "../state/appStore";
import { ContextMenu } from "../ui/ContextMenu";
import type { Vec2 } from "../model/types";
import type { PlanViewHandle } from "../views/plan/PlanView";
@@ -164,15 +164,16 @@ export function AppContextMenu(props: {
if (total !== 1) return null;
const roof = selection.roofs.length === 1 ? (project.roofs ?? []).find((x) => x.id === selection.roofs[0]) : undefined;
if (roof && !roof.locked) {
return { kind: "roof" as const, id: roof.id, rings: [roof.outline, ...(roof.holes ?? [])].reduce<{ pts: Vec2[]; off: number }[]>(
(acc, pts) => [...acc, { pts, off: acc.reduce((n, r) => n + r.pts.length, 0) }], []) };
const bulges = [roof.outlineBulge, ...(roof.holes ?? []).map((_, k) => roof.holesBulge?.[k])];
return { kind: "roof" as const, id: roof.id, rings: [roof.outline, ...(roof.holes ?? [])].reduce<{ pts: Vec2[]; off: number; bulge?: number[] }[]>(
(acc, pts, k) => [...acc, { pts, off: acc.reduce((n, r) => n + r.pts.length, 0), bulge: bulges[k] }], []) };
}
const ceiling = selection.ceilings.length === 1 ? (project.ceilings ?? []).find((x) => x.id === selection.ceilings[0]) : undefined;
if (ceiling && !ceiling.locked) return { kind: "ceiling" as const, id: ceiling.id, rings: [{ pts: ceiling.outline, off: 0 }] };
if (ceiling && !ceiling.locked) return { kind: "ceiling" as const, id: ceiling.id, rings: [{ pts: ceiling.outline, off: 0, bulge: ceiling.outlineBulge }] };
const room = selection.rooms.length === 1 ? (project.rooms ?? []).find((x) => x.id === selection.rooms[0]) : undefined;
if (room && !room.locked) return { kind: "room" as const, id: room.id, rings: [{ pts: room.boundary, off: 0 }] };
if (room && !room.locked) return { kind: "room" as const, id: room.id, rings: [{ pts: room.boundary, off: 0, bulge: room.boundaryBulge }] };
const ctx = selection.contextObjects.length === 1 ? (project.context ?? []).find((x) => x.id === selection.contextObjects[0]) : undefined;
if (ctx && ctx.type === "excavation") return { kind: "excavation" as const, id: ctx.id, rings: [{ pts: ctx.outline, off: 0 }] };
if (ctx && ctx.type === "excavation") return { kind: "excavation" as const, id: ctx.id, rings: [{ pts: ctx.outline, off: 0, bulge: ctx.outlineBulge }] };
// [193] Höhenlinien-Satz: je Linie ein Ring (flacher Index über alle Linien); offene Linien haben kein Schlusssegment.
if (ctx && ctx.type === "contourSet") {
return { kind: "contours" as const, id: ctx.id, rings: ctx.contours.reduce<{ pts: Vec2[]; off: number; closed: boolean }[]>(
@@ -188,6 +189,7 @@ export function AppContextMenu(props: {
})(),
askMeshPointHeight: (id, index) => setMeshHeightPrompt({ id, index }),
deleteMeshPoint: (id, index) => { deleteMeshPoint(id, index); },
setRingArc: (kind, id, seg, pt) => getState().setRingArc(kind, id, seg, pt),
insertPolylinePoint: insertDrawingPoint,
deletePolylinePoint: deleteDrawingPoint,
setPolylineVertexType,
+15 -3
View File
@@ -8,7 +8,7 @@
// Kommentare deutsch (CONVENTIONS.md).
import { t } from "../i18n";
import { canSetVertexType, vertexTypeOf, type PolylineVertexType, type RingKind } from "../core";
import { canSetVertexType, edgeArcToggle, vertexTypeOf, type ArcRingKind, type PolylineVertexType, type RingKind } from "../core";
import { meshTolerance, nearestMeshVertex, nearestPolylineTarget, toleranceFor } from "../core";
import type { LayerCategory, Project, Vec2 } from "../model/types";
import { flattenCategories } from "../model/types";
@@ -90,8 +90,10 @@ export interface MenuActions {
selectedSectionLine?: { id: string; pts: Vec2[] } | null;
insertSectionBend?: (id: string, seg: number, pt: Vec2) => void;
/** [26] Einzeln gewähltes Element mit Umriss (Dach samt Höfen, Decke, Raum, Baugrube): Ringe mit Start-Index im flachen Ecken-Index. */
selectedRing?: { kind: RingKind; id: string; rings: { pts: Vec2[]; off: number; closed?: boolean }[] } | null;
selectedRing?: { kind: RingKind; id: string; rings: { pts: Vec2[]; off: number; closed?: boolean; bulge?: number[] }[] } | null;
insertRingVertex?: (kind: RingKind, id: string, seg: number, pt: Vec2) => void;
/** [191] Bogen-Scheitel einer Umriss-Kante setzen („Kante gerade ↔ Bogen"). */
setRingArc?: (kind: ArcRingKind, id: string, seg: number, pt: Vec2) => void;
deleteRingVertex?: (kind: RingKind, id: string, index: number) => void;
/** [193] Einzeln gewähltes Gelände-/Netz-Element: Rechtsklick auf einen Netzpunkt → „Höhe setzen …" / „Netzpunkt löschen". */
selectedMesh?: { id: string; positions: number[] } | null;
@@ -368,7 +370,7 @@ function planMenuItems(
// [26] Umriss-Element: Ecke am Klick einfügen bzw. die getroffene Ecke löschen (mindestens drei bleiben).
const ring = a.selectedRing;
if (ring) {
for (const { pts, off, closed = true } of ring.rings) {
for (const { pts, off, closed = true, bulge } of ring.rings) {
const geom = { pts, closed };
const hit = nearestPolylineTarget(geom, model, toleranceFor(geom));
if (!hit) continue;
@@ -379,6 +381,16 @@ function planMenuItems(
onClick: () => a.insertRingVertex?.(ring.kind, ring.id, off + hit.segIndex, hit.at),
});
}
// [191] Kante gerade ↔ Bogen (Decke, Raum, Dach, Baugrube); die Pfeilhöhe danach am Scheitel-Griff.
const arcKind = ring.kind === "polyline" || ring.kind === "contours" ? null : ring.kind;
const toggle = hit.kind === "segment" && closed && arcKind ? edgeArcToggle(pts, bulge, hit.segIndex) : null;
if (toggle && arcKind && a.setRingArc && hit.kind === "segment") {
pointItems.push({
label: t(toggle.toArc ? "ctx.edgeToArc" : "ctx.edgeStraight"),
icon: <MenuIcon name={toggle.toArc ? "line_curve" : "horizontal_rule"} />,
onClick: () => a.setRingArc?.(arcKind, ring.id, off + hit.segIndex, toggle.pt),
});
}
if (hit.kind === "vertex" && a.deleteRingVertex) {
const enabled = pts.length > (closed ? 3 : 2);
pointItems.push({
+4 -3
View File
@@ -838,9 +838,10 @@ export function buildComplexSampleProject(): Project {
{
// Baugrube: Böschung 60° (Ost 50°), Nordkante (Hang) mit Rühlwand gesichert, Sohle unter der Bodenplatte.
type: "excavation", id: "baugrube", name: "Baugrube Haupthaus", categoryCode: "07",
// Umriss = Gebäude-Grundfläche UG (mit Erker), Arbeitsraum 0.8 m; Neigungen in Grad.
outline: rect(-HA, -HA, 17.2, 10 + HA), bottom: -3.35, slope: 60, fillSlope: 33.7,
edgeSlopes: [60, 50, 90, 60], edgeShoring: [false, false, true, false], shoringKind: "soldierPile", workingSpace: 0.8,
// Umriss = Gebäude-Grundfläche UG mit dem runden Erker als Bogenkante ([191]), Arbeitsraum 0.8 m; Neigungen in
// Grad je Kante (Süd, Ost bis Erker, Erker, Ost ab Erker, Nord, West).
...slabOutline(true, false), bottom: -3.35, slope: 60, fillSlope: 33.7,
edgeSlopes: [60, 50, 50, 50, 90, 60], edgeShoring: [false, false, false, false, true, false], shoringKind: "soldierPile", workingSpace: 0.8,
},
],
roomProgram: [
+7
View File
@@ -1272,6 +1272,13 @@ export type Excavation = {
*/
categoryCode: string;
outline: Array<Vec2>;
/**
* [191] Bögen im Umriss: je Kante (Punkt i → i+1) ein Bulge wie bei `Ceiling.outlineBulge`
* (`tan(Öffnungswinkel/4)`, positiv = Scheitel links; fehlt/0 = Gerade). Die Ableitungen (Böschung,
* Arbeitsraum, Verbau, Schnitt, 3D, Plan) rechnen auf dem fein geteilten Umriss; `edgeSlopes`/`edgeShoring`
* gelten je Kante dieses Felds (eine Bogenkante = ein Eintrag).
*/
outlineBulge?: Array<number>;
bottom: number;
slope?: number;
fillSlope?: number;
@@ -1,12 +1,12 @@
viewBox -4.2 0 38 18.478
bytes 204304
viewBox -4.2 0 37.045 18.478
bytes 203924
circle 4
g 1
line 505
line 508
path 3
polygon 984
polyline 165
polygon 982
polyline 163
rect 1
svg 1
text 4
hash 18f02b98280397fd
hash e090b62ec94561d5
+3 -3
View File
@@ -5,7 +5,7 @@ meshes[].indices [1152]
meshes[].indices [1248] x3
meshes[].indices [12960]
meshes[].indices [144] x55
meshes[].indices [156642]
meshes[].indices [154014]
meshes[].indices [1584]
meshes[].indices [1716]
meshes[].indices [180]
@@ -39,7 +39,7 @@ meshes[].positions [4746]
meshes[].positions [576]
meshes[].positions [7050]
meshes[].positions [72] x2
meshes[].positions [78837]
meshes[].positions [77523]
meshes[].positions [78] x55
meshes[].positions [798]
meshes[].positions [864]
@@ -73,4 +73,4 @@ walls[].start [2] x1273
walls[].startCut [4] x873
walls[].topDrop [2] x115
walls[].topPlane [3] x271
hash b2c8483fd14d95a1
hash 64bd95cef041f4aa
+1 -1
View File
@@ -405,7 +405,7 @@ export interface ProjectSlice {
/** [193] Netzpunkt eines Geländes/Netzes im Grundriss verschieben (Höhe bleibt). */
moveMeshPoint: (id: string, index: number, pt: Vec2) => void;
/** [191] Bogen-Scheitel der Kante `seg` (Dach: flacher Index) ziehen: setzt den Bulge über die Pfeilhöhe. */
setRingArc: (kind: "roof" | "ceiling" | "room", id: string, seg: number, pt: Vec2, coalesceKey?: string) => void;
setRingArc: (kind: "roof" | "ceiling" | "room" | "excavation", id: string, seg: number, pt: Vec2, coalesceKey?: string) => void;
/** [26] Nach dem Ziehen: Ecke auf Nachbar bzw. Gerade zwischen den Nachbarn entfällt. */
tidyRingVertex: (kind: RingKind, id: string, index: number, coalesceKey?: string, tol?: number) => void;
moveExcavationEdge: (id: string, aIndex: number, bIndex: number, delta: Vec2) => void;
+6 -3
View File
@@ -572,7 +572,10 @@ export function useGripEditing(opts: {
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]); });
pushInsertGrips(pts, [{ pts: selectedExcavation.outline, off: 0 }], { kind: "excavation", id: selectedExcavation.id });
// [191] Bogenkanten: Einfüge-Raute auf dem Bogen, Scheitel-Griff wie bei Decken.
const rings = [{ pts: selectedExcavation.outline, off: 0, bulge: selectedExcavation.outlineBulge }];
pushInsertGrips(pts, rings, { kind: "excavation", id: selectedExcavation.id });
pushArcGrips(pts, rings, { kind: "excavation", id: selectedExcavation.id });
return pts;
}
// Decke: die Umriss-Vertices als Griffe (nur bei genau einer gewählten Decke,
@@ -722,7 +725,7 @@ export function useGripEditing(opts: {
);
}
if (modelEditable && selectedExcavation && !selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
return ringEdges(selectedExcavation.outline, {});
return ringEdges(selectedExcavation.outline, {}, selectedExcavation.outlineBulge ?? []);
}
// Decke: geschlossener Ring aus dem Umriss (Auswahl exklusiv, wie bei grips).
if (modelEditable && selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
@@ -1196,7 +1199,7 @@ export function useGripEditing(opts: {
}
const ins = gripOwners[index];
// [191] Scheitel-Griff einer Bogenkante: Bulge live, ein Undo-Schritt je Zug.
if (modelEditable && ins?.arcSeg != null && ins.ring && ins.ring.kind !== "excavation" && ins.ring.kind !== "polyline" && ins.ring.kind !== "contours") {
if (modelEditable && ins?.arcSeg != null && ins.ring && ins.ring.kind !== "polyline" && ins.ring.kind !== "contours") {
storeState().setRingArc(ins.ring.kind, ins.ring.id, ins.arcSeg, pt);
return;
}