Merge branch 'worktree-agent-ac2733317425a5805' into claude/practical-noether-1hb2s1

This commit is contained in:
Claude committed 2026-11-12 04:50:53 +00:00
commit 1174191708
14 files changed
+347 -17

No files matched your search

+22
View File
@@ -46,6 +46,11 @@ describe("Höhenlinien: Punkte per Griff", () => {
expect(ins.contours[0].pts).toHaveLength(4);
expect(ins.contours[0].pts[2]).toEqual({ x: 3, y: 1 });
});
it("Punkt löschen und Aufräumen laufen über ringDelete/ringTidy", () => {
const p = project();
expect(commit<ContourSet>(p, { op: "ringDelete", kind: "contours", id: "hl", index: 1 }, "hl").contours[0].pts).toHaveLength(2);
expect(commit<ContourSet>(p, { op: "ringTidy", kind: "contours", id: "hl", index: 1, tol: 0.01 }, "hl").contours[0].pts).toHaveLength(2);
});
});
describe("Kontext verschieben (Maus-Ziehen im Plan)", () => {
@@ -58,3 +63,20 @@ describe("Kontext verschieben (Maus-Ziehen im Plan)", () => {
expect(contextAnchor(p, "nix")).toBeNull();
});
});
describe("Gelände-Netz: Punkte und Zuschnitt [193]", () => {
const mesh = {
id: "tm", type: "terrainMesh", categoryCode: "02", name: "Gelände",
positions: [0, 0, 1, 2, 0, 2, 2, 2, 3, 0, 2, 4], indices: [0, 1, 2, 0, 2, 3],
} as unknown as ContextObject;
const proj = (): Project => ({ ...sampleProject, context: [mesh] });
it("Netzpunkt per Griff verschieben, Höhe setzen, auf Polygon zuschneiden", () => {
const p = proj();
const m = commit<ContextObject & { positions: number[] }>(p, { op: "meshGrip", id: "tm", index: 1, pt: [5, 6] }, "tm");
expect(m.positions.slice(3, 6)).toEqual([5, 6, 2]);
const z = documentFor(p).cmdOps({ cmd: "meshPointZ", id: "tm", index: 2, z: 9 });
expect(JSON.stringify(z)).toContain("9");
const crop = documentFor(p).cmdOps({ cmd: "meshCrop", id: "tm", poly: [-1, -1, 1, -1, 1, 3, -1, 3] });
expect(JSON.stringify(crop)).toContain('"indices":[0,1,2]');
});
});
+4 -1
View File
@@ -402,6 +402,8 @@ export interface ProjectSlice {
insertRingVertex: (kind: RingKind, id: string, seg: number, pt: Vec2, coalesceKey?: string) => void;
/** [26] Ecke löschen (mind. 3 bleiben); ein Undo-Schritt. */
deleteRingVertex: (kind: RingKind, id: string, index: number) => void;
/** [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;
/** [26] Nach dem Ziehen: Ecke auf Nachbar bzw. Gerade zwischen den Nachbarn entfällt. */
@@ -1309,8 +1311,9 @@ export function createProjectSlice(
},
insertRingVertex: (kind, id, seg, pt, coalesceKey) =>
applyGrip(kind === "contours" ? { op: "contourInsert", id, seg, pt: gripPt(pt) } : kind === "polyline" ? { op: "insertPoint", id, seg, pt: gripPt(pt) } : { op: "ringInsert", kind, id, seg, pt: gripPt(pt) }, coalesceKey),
moveMeshPoint: (id, index, pt) => applyGrip({ op: "meshGrip", id, index, pt: gripPt(pt) }),
deleteRingVertex: (kind, id, index) =>
kind === "contours" ? undefined : applyGrip(kind === "polyline" ? { op: "deletePoint", id, index } : { op: "ringDelete", kind, id, index }),
applyGrip(kind === "polyline" ? { op: "deletePoint", id, index } : { op: "ringDelete", kind, id, index }),
setRingArc: (kind, id, seg, pt, coalesceKey) => applyGrip({ op: "ringArc", kind, id, seg, pt: gripPt(pt) }, coalesceKey ?? `ringArc:${kind}:${id}:${seg}`),
tidyRingVertex: (kind, id, index, coalesceKey, tol) =>
applyGrip({ op: "ringTidy", kind, id, index, ...(tol != null ? { tol } : {}) }, coalesceKey),
+15
View File
@@ -38,6 +38,10 @@ export interface SiteSlice {
offsetContextHeight: (id: string, dz: number) => void;
/** [193] Höhe der Höhenlinie `index` eines Höhenlinien-Satzes setzen (Kern `cmd_context.rs`); `coalesceKey` für Tippen. */
setContourHeight: (id: string, index: number, z: number, coalesceKey?: string) => void;
/** [193] Höhe eines Netzpunkts (Vertex-Nummer ab 0) setzen. */
setMeshPointHeight: (id: string, index: number, z: number, coalesceKey?: string) => void;
/** [193] Netz auf ein Polygon (Modell-Meter) zuschneiden; false = nichts geändert. */
cropMesh: (id: string, poly: Vec2[]) => boolean;
/** [193] Kontext-Elemente um `delta` verschieben (Maus-Ziehen im Plan; Kern `cmd_transform.rs`), ein Undo-Schritt. */
moveContextBy: (ids: string[], delta: Vec2) => void;
/** [T6]/[68] Ändert Felder eines Kontext-Objekts (Gelände, Baugrube) in einem Schritt; `coalesceKey` für Tippen. */
@@ -111,6 +115,17 @@ export function createSiteSlice(
if (ops.length) get().applyChange(ops, coalesceKey);
},
setMeshPointHeight: (id, index, z, coalesceKey) => {
const ops = documentFor(get().project).cmdOps({ cmd: "meshPointZ", id, index, z });
if (ops.length) get().applyChange(ops, coalesceKey);
},
cropMesh: (id, poly) => {
const ops = documentFor(get().project).cmdOps({ cmd: "meshCrop", id, poly: poly.flatMap((q) => [q.x, q.y]) });
if (ops.length) get().applyChange(ops);
return ops.length > 0;
},
moveContextBy: (ids, delta) => {
if (ids.length === 0 || (delta.x === 0 && delta.y === 0)) return;
const ops = transformOps(get().project, { wallIds: [], drawingId: null, contextIds: ids }, "move", [{ x: 0, y: 0 }, delta], "move", 1);
+30 -2
View File
@@ -195,6 +195,13 @@ export function useGripEditing(opts: {
return o && o.type === "contourSet" ? o : null;
})()
: null;
// [193] Einzeln gewähltes Gelände-/Netz-Element: Netzpunkte als Griffe (Kern `grips.rs::mesh_grip`).
const selectedMesh = selectedContourSetId
? (() => {
const o = (project.context ?? []).find((c) => c.id === selectedContourSetId);
return o && (o.type === "terrainMesh" || o.type === "importedMesh") ? o : null;
})()
: null;
const selectedTreeId = single(selection, "trees");
const selectedTree = selectedTreeId ? (project.trees ?? []).find((x) => x.id === selectedTreeId) : undefined;
// [176] Schnitt-/Ansichtslinie im Grundriss: Griffe an Anfang, Knickpunkten (`bendPoints`) und Ende.
@@ -541,6 +548,19 @@ export function useGripEditing(opts: {
}
return pts;
}
// [193] Gelände-Netz: jeder Netzpunkt ein Griff (xy; die Höhe steht in der Objekt-Info). Grosse Netze (swissALTI3D
// mit tausenden Punkten) bekommen keine Griffe — dort hilft Zuschneiden auf das Grundstück.
if (selectedMesh && !selectedCeiling && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0) {
const n = Math.floor(selectedMesh.positions.length / 3);
if (n > MAX_CONTOUR_GRIPS) return [];
const pts: Vec2[] = [];
for (let i = 0; i < n; i++) {
pts.push({ x: selectedMesh.positions[3 * i], y: selectedMesh.positions[3 * i + 1] });
gripOwners.push({ localIndex: i });
gripOwnerRange.push([0, n - 1]);
}
return pts;
}
// [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);
@@ -822,7 +842,7 @@ export function useGripEditing(opts: {
/** [193] Aufgeschobenes Ziehen von Gelände-/Umgebungs-Elementen: ungefangenes und gefangenes Gesamt-Delta. */
const pendingContextMoveRef = useRef<{ ids: string[]; raw: Vec2; total: Vec2; anchor: Vec2 | null } | null>(null);
/** [193] Zug an einem Höhenlinien-Punkt (bzw. einer Einfüge-Raute: `insertSeg`): Vorschau bis zum Setzen, dann EIN Undo-Schritt. */
const pendingContourRef = useRef<{ id: string; index: number; pt: Vec2; insertSeg?: number } | null>(null);
const pendingContourRef = useRef<{ id: string; index: number; pt: Vec2; insertSeg?: number; mesh?: boolean } | null>(null);
/** Aufgeschobene Öffnungs-Verschiebung im Schnitt/in der Ansicht (neue `position`). */
const pendingOpeningMoveRef = useRef<{ id: string; position: number } | null>(null);
/** Aufgeschobene Höhen-Änderung im Schnitt (Kante `kind` auf die Höhe `y`, Kern `sheetHeight`). */
@@ -1149,6 +1169,10 @@ export function useGripEditing(opts: {
// auf die Wand/2D-Aktionen. So teilen Plan- UND 3D-Griffe denselben Pfad.
const applyGrip = (index: number, pt: Vec2, arcLength?: number) => {
// [193] Höhenlinien-Punkt bzw. Einfüge-Raute: nur Vorschau, das Projekt ändert sich beim Setzen (ein Undo-Schritt).
if (selectedMesh) {
pendingContourRef.current = { id: selectedMesh.id, index, pt, mesh: true };
return;
}
if (selectedContourSet) {
const ins = gripOwners[index];
pendingContourRef.current = ins?.insertSeg != null
@@ -1285,6 +1309,7 @@ export function useGripEditing(opts: {
/** Vorschau-Form des ausstehenden Eckpunkt-Zugs (leer, wenn keiner läuft). */
const gripPreviewShapes = (): DraftShape[] => {
const pc = pendingContourRef.current;
if (pc?.mesh) return [];
if (pc && selectedContourSet?.id === pc.id) {
// Die betroffene Höhenlinie mit dem gezogenen (bzw. eingefügten) Punkt als Linienzug.
let off = 0;
@@ -1360,9 +1385,12 @@ export function useGripEditing(opts: {
if (ph) sheetHeightGrip(ph.kind, ph.id, ph.y, ph.free, ph.from, ph.index);
const pc = pendingContourRef.current;
pendingContourRef.current = null;
if (pc) {
if (pc?.mesh) storeState().moveMeshPoint(pc.id, pc.index, pc.pt);
else if (pc) {
if (pc.insertSeg != null) storeState().insertRingVertex("contours", pc.id, pc.insertSeg, pc.pt);
else storeState().moveRingVertex("contours", pc.id, pc.index, pc.pt);
// [193] Punkt, der auf einem Nachbarn bzw. auf der Geraden zwischen den Nachbarn landet, entfällt (derselbe Undo-Schritt).
storeState().tidyRingVertex("contours", pc.id, pc.index, undefined, ringTidyTol());
}
const pa = pendingAreaGripRef.current;
pendingAreaGripRef.current = null;