[K4] Höhen der 3D-Griffe im Kern, tote Geometrie-Helfer gelöscht

Die 3D-Griffe (Griff-Lagen, Arbeitsebene) holen UK/OK von Wänden und Decken
über die Wurzel-Abfrage `verticalExtents` (selection_info.rs, Fassade in
geometry/grips.ts). Gelöscht, weil ohne Aufrufer: lineIntersect, clippedBand,
wallBand, stairVerticalExtent, nextFloorAbove, openingGapQuad, roofBBox,
stairBBox (+ Bindung stair_bbox_flat), outlineBBox, localToLv95, roofEdgeList.
Die vertikalen Ausdehnungen in TS bleiben nur für die Plan-Ableitung.

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-29 10:26:42 +00:00
1 parent 365500516f
commit 0c15c0ede3
21 files changed
+149 -317

No files matched your search

-24
View File
@@ -43,30 +43,6 @@ export function ceilingArea(pts: Vec2[]): number {
return Math.abs(signedArea(pts));
}
/**
* Achsparallele Bounding-Box eines Umrisses (Modell-Meter). Leerer/entarteter
* Umriss → Null-Box.
*/
export function outlineBBox(pts: Vec2[]): {
minX: number;
minY: number;
maxX: number;
maxY: number;
} {
let minX = Infinity,
minY = Infinity,
maxX = -Infinity,
maxY = -Infinity;
for (const p of pts) {
minX = Math.min(minX, p.x);
minY = Math.min(minY, p.y);
maxX = Math.max(maxX, p.x);
maxY = Math.max(maxY, p.y);
}
if (!isFinite(minX)) return { minX: 0, minY: 0, maxX: 0, maxY: 0 };
return { minX, minY, maxX, maxY };
}
/** Schwerpunkt (Zentroid) des Umriss-Polygons (für HUD/Beschriftung). */
export function outlineCentroid(pts: Vec2[]): Vec2 {
const a = signedArea(pts);
+24 -1
View File
@@ -7,7 +7,8 @@
// Bewusst TS: die Rahmen-Ecken einer Textspalte (`textFrameCorners` braucht die Schrift-Metrik der
// Hülle) — der Kern meldet dafür nur „Textspalte".
import type { Drawing2D, Drawing2DGeom, EdgeGrip, Vec2 } from "../model/types";
import type { Ceiling, Drawing2D, Drawing2DGeom, EdgeGrip, Project, Vec2, Wall } from "../model/types";
import { documentFor } from "../core/document";
import { core } from "../engine/coreWasm";
import { toMarkedJson } from "../core/ops";
import { DEFAULT_SCALE_DENOMINATOR } from "../model/dimension";
@@ -103,3 +104,25 @@ export function openEdges(verts: readonly Vec2[], owner: Owner): EdgeGrip[] {
export function polylineEdgeGrips(g: Extract<Drawing2DGeom, { shape: "polyline" }>, owner: Owner): EdgeGrip[] {
return edges(g.pts, !!g.closed, g.bulge ?? [], owner);
}
/** Unter-/Oberkante (absolutes Z, Meter) eines Bauteils. */
export interface VerticalExtent {
zBottom: number;
zTop: number;
}
/**
* UK/OK von Wänden und Decken aus dem Kern (`selection_info.rs::vertical_extents`, Regeln wie
* `wallVerticalExtent`/`ceilingVerticalExtent`): Geschoss-Bindungen und Deckentypen aus `project`, die
* Elemente selbst als ganze Fassung (auch gerade gezogene, noch nicht übernommene — 3D-Griffe).
*/
export function verticalExtents(
project: Project,
walls: readonly Wall[],
ceilings: readonly Ceiling[] = [],
): { walls: VerticalExtent[]; ceilings: VerticalExtent[] } {
if (walls.length === 0 && ceilings.length === 0) return { walls: [], ceilings: [] };
const f = documentFor(project).queryRootMarked<number[]>("verticalExtents", toMarkedJson({ walls, ceilings }));
const at = (i: number): VerticalExtent => ({ zBottom: f[2 * i], zTop: f[2 * i + 1] });
return { walls: walls.map((_, i) => at(i)), ceilings: ceilings.map((_, i) => at(walls.length + i)) };
}
+1 -23
View File
@@ -13,7 +13,7 @@
import type { Opening, Project, SashDef, Vec2, Wall } from "../model/types";
import { core } from "../engine/coreWasm";
import { getWallType, wallTypeThickness } from "../model/types";
import { add, along, leftNormal, normalize, scale, sub } from "../model/geometry";
import { along, leftNormal, normalize, sub } from "../model/geometry";
import { wallReferenceOffset, wallVerticalExtent } from "../model/wall";
/** Achslänge einer Wand (Meter). */
@@ -73,28 +73,6 @@ export function openingJambs(
};
}
/**
* Die Lücken-Rechteck-Ecken (über die volle Wanddicke), z. B. um im Plan die
* Öffnung als Aussparung zu markieren (Auswahl-Highlight). Reihenfolge:
* jambStart(+n/2) → jambEnd(+n/2) → jambEnd(−n/2) → jambStart(−n/2).
*/
export function openingGapQuad(project: Project, wall: Wall, o: Opening): Vec2[] | null {
const jambs = openingJambs(wall, o);
if (!jambs) return null;
const { n } = wallAxisFrame(wall);
const total = wallTypeThickness(getWallType(project, wall));
const refOff = wallReferenceOffset(wall, total);
const outer = refOff + total / 2;
const inner = refOff - total / 2;
const { jambStart, jambEnd } = jambs;
return [
add(jambStart, scale(n, outer)),
add(jambEnd, scale(n, outer)),
add(jambEnd, scale(n, inner)),
add(jambStart, scale(n, inner)),
];
}
/** Mittelpunkt einer Öffnung im Grundriss (Achse) — für HUD/Auswahl-Anker. */
export function openingCenter(wall: Wall, o: Opening): Vec2 | null {
const iv = openingInterval(wall, o);
+8 -7
View File
@@ -1,7 +1,14 @@
import { describe, it, expect } from "vitest";
import { roofGeometry, roofBBox, roofUndersideAt } from "./roof";
import { roofGeometry, roofUndersideAt } from "./roof";
import type { Roof, Vec2 } from "../model/types";
/** Bounding-Box eines Umrisses (Prüfhilfe). */
function roofBBox(outline: Vec2[]): { x0: number; y0: number; x1: number; y1: number } {
const xs = outline.map((p) => p.x);
const ys = outline.map((p) => p.y);
return { x0: Math.min(...xs), y0: Math.min(...ys), x1: Math.max(...xs), y1: Math.max(...ys) };
}
// Rechteck 6×4 (x:0..6, y:0..4), Neigung 45° (tan=1), Traufhöhe 10, kein Überstand.
const RECT: Vec2[] = [
{ x: 0, y: 0 },
@@ -35,12 +42,6 @@ function allZ(g: ReturnType<typeof roofGeometry>): number[] {
return zs;
}
describe("roofBBox", () => {
it("liefert die Bounding-Box", () => {
expect(roofBBox(RECT)).toEqual({ x0: 0, y0: 0, x1: 6, y1: 4 });
});
});
describe("roofGeometry — Formen (6×4, 45°, First entlang X)", () => {
it("flach: eine waagrechte Fläche auf Traufhöhe, kein First", () => {
const g = roofGeometry(roof({ shape: "flach" }), E);
-15
View File
@@ -39,21 +39,6 @@ export interface RoofGeometry {
ridgeHeight: number;
}
/** Bounding-Box eines Umrisses. */
export function roofBBox(outline: Vec2[]): { x0: number; y0: number; x1: number; y1: number } {
let x0 = Infinity;
let y0 = Infinity;
let x1 = -Infinity;
let y1 = -Infinity;
for (const p of outline) {
if (p.x < x0) x0 = p.x;
if (p.y < y0) y0 = p.y;
if (p.x > x1) x1 = p.x;
if (p.y > y1) y1 = p.y;
}
return { x0, y0, x1, y1 };
}
/**
* Traufhöhe (absolutes Z) eines Dachs: `baseElevation`, sonst die OBERKANTE des
* zugehörigen Geschosses (baseElevation + floorHeight) — das Dach sitzt also
+3 -23
View File
@@ -1,7 +1,8 @@
// Kanten und Höfe eines Dachs ([26]): Liste, Änderung der Kantenneigung, Hof hinzufügen/entfernen.
// Kanten und Höfe eines Dachs ([26]): Änderung der Kantenneigung, Hof hinzufügen/entfernen (die
// Kantenliste rechnet der Kern, Test in `state/selectionInfo.test.ts`).
import { describe, expect, it } from "vitest";
import type { Roof, Vec2 } from "../model/types";
import { addRoofHole, removeRoofHole, roofEdgeList, roofHoleWorks, setRoofEdge } from "./roofEdges";
import { addRoofHole, removeRoofHole, roofHoleWorks, setRoofEdge } from "./roofEdges";
const rect = (x: number, y: number, w: number, h: number): Vec2[] => [
{ x, y },
@@ -26,27 +27,6 @@ const roof = (extra: Partial<Roof> = {}): Roof => ({
const court = rect(4, 2, 4, 4);
describe("roofEdgeList", () => {
it("Umrisskanten, dann Hofkanten; Standard ohne Feld", () => {
const list = roofEdgeList(roof({ holes: [court] }));
expect(list).toHaveLength(8);
expect(list.map((e) => e.ring)).toEqual([0, 0, 0, 0, 1, 1, 1, 1]);
expect(list[0]).toMatchObject({ index: 0, spec: { kind: "default" }, length: 12 });
expect(list[5].index).toBe(5);
});
it("liest Giebel, Neigung und negativ = Standard; Sattel: Giebelregel zeigt sich als Vorgabe", () => {
const list = roofEdgeList(roof({ edgePitchDeg: [20, null, -1] }));
expect(list[0].spec).toEqual({ kind: "pitch", deg: 20 });
expect(list[1].spec).toEqual({ kind: "gable" });
expect(list[2].spec).toEqual({ kind: "default" });
expect(list[3].spec).toEqual({ kind: "default" });
const sattel = roofEdgeList(roof({ shape: "sattel" }));
expect(sattel.map((e) => e.defaultGable)).toEqual([false, true, false, true]);
expect(roofEdgeList(roof()).every((e) => !e.defaultGable)).toBe(true);
});
});
describe("setRoofEdge", () => {
it("setzt Neigung/Giebel, füllt mit Standard auf, entfernt das Feld wenn alles Standard", () => {
const a = setRoofEdge(roof(), 2, { kind: "pitch", deg: 25 });
+2 -42
View File
@@ -1,4 +1,4 @@
// Kanten und Höfe eines Dachs ([26]): die Kantenliste fürs Objekt-Info (Neigung je Kante, Giebel),
// Kanten und Höfe eines Dachs ([26]): Typen der Kantenliste (gerechnet im Kern, `selection_info.rs`),
// Änderungen als Teilobjekt (`Partial<Roof>`, für `updateRoof`/`patchItem` — ein Undo-Schritt) und
// die Prüfung, ob ein Hof wirkt. Die Geometrie selbst rechnet der Rust-Kern (`roof.rs`).
//
@@ -31,46 +31,6 @@ export interface RoofEdge {
const MAX_PITCH = 89;
/** Die Vorgabe aus einem Eintrag von `edgePitchDeg`. */
function specOf(v: number | null | undefined): EdgeSpec {
if (v === null) return { kind: "gable" };
if (v === undefined || !Number.isFinite(v) || v < 0) return { kind: "default" };
return { kind: "pitch", deg: v };
}
/** Giebelt der Standard dieser Dachform die Kante a→b (quer zur Firstrichtung)? */
function defaultGableEdge(roof: Roof, a: Vec2, b: Vec2): boolean {
const gabled = roof.shape === "sattel" || (roof.shape === "mansarde" && (roof.mansardType ?? "giebel") === "giebel");
if (!gabled) return false;
const dx = Math.abs(b.x - a.x);
const dy = Math.abs(b.y - a.y);
return roof.ridgeAxis === "y" ? dy < dx : dx < dy;
}
/** Alle Kanten des Dachs (Umriss, dann Höfe) mit ihrer Vorgabe. */
export function roofEdgeList(roof: Roof): RoofEdge[] {
const rings: Vec2[][] = [roof.outline, ...(roof.holes ?? [])];
const out: RoofEdge[] = [];
let index = 0;
rings.forEach((ring, r) => {
ring.forEach((a, edge) => {
const b = ring[(edge + 1) % ring.length];
out.push({
index,
ring: r,
edge,
a,
b,
length: Math.hypot(b.x - a.x, b.y - a.y),
spec: specOf(roof.edgePitchDeg?.[index]),
defaultGable: defaultGableEdge(roof, a, b),
});
index++;
});
});
return out;
}
/** `edgePitchDeg` ohne Standard-Einträge am Ende; alles Standard ⇒ `undefined` (Feld entfällt). */
function normalized(values: (number | null)[]): (number | null)[] | undefined {
const v = values.slice();
@@ -80,7 +40,7 @@ function normalized(values: (number | null)[]): (number | null)[] | undefined {
/** Teilobjekt für `updateRoof`: Kante `index` auf `spec` setzen. */
export function setRoofEdge(roof: Roof, index: number, spec: EdgeSpec): Pick<Roof, "edgePitchDeg"> {
const total = roofEdgeList(roof).length;
const total = roof.outline.length + (roof.holes ?? []).reduce((n, h) => n + h.length, 0);
const values: (number | null)[] = Array.from({ length: total }, (_, i) => {
const v = roof.edgePitchDeg?.[i];
return v === undefined ? -1 : v;
+2 -9
View File
@@ -3,7 +3,7 @@
* Referenz, Schnitt, Rahmen und Unsinn-Eingaben (Rust-Tests decken die Mathematik je Fall ab).
*/
import { describe, it, expect } from "vitest";
import { defaultStepCount, stairBBox, stairCut, stairGeometry, stairOutline } from "./stair";
import { defaultStepCount, stairCut, stairGeometry, stairOutline } from "./stair";
import type { Stair } from "../model/types";
const base: Stair = {
@@ -51,11 +51,10 @@ describe("stairGeometry", () => {
expect(stairGeometry(base, NaN).treads).toEqual([]);
expect(stairGeometry({ ...base, stepCount: 0 }, 2.8).treads).toHaveLength(2);
expect(stairOutline({ ...base, runLength: NaN }, 0)).toEqual({ polygon: null, spiral: null });
expect(stairBBox(stairGeometry(base, NaN))).toEqual({ minX: 0, minY: 0, maxX: 0, maxY: 0 });
});
});
describe("stairCut / stairBBox / defaultStepCount", () => {
describe("stairCut / defaultStepCount", () => {
it("Schnitt teilt die Tritte und legt eine Doppel-Bruchlinie", () => {
const g = stairGeometry(base, 2.8);
const c = stairCut(g, 1.0);
@@ -66,12 +65,6 @@ describe("stairCut / stairBBox / defaultStepCount", () => {
expect(stairCut(stairGeometry(base, NaN), 1)).toEqual({ belowIndices: [], aboveIndices: [], breakLine: null });
});
it("BBox über Tritte", () => {
const b = stairBBox(stairGeometry(base, 2.8));
expect(b.maxX).toBeCloseTo(3, 12);
expect(b.minY).toBeCloseTo(-0.6, 12);
});
it("Vorgabe-Stufenzahl: Steighöhe 0.17, gedeckelt durch die Lauflänge, mind. 2", () => {
expect(defaultStepCount(2.8, 10)).toBe(16);
expect(defaultStepCount(2.8, 3)).toBe(13);
+2 -14
View File
@@ -152,8 +152,8 @@ function encodeGeometry(g: StairGeometry): Float64Array {
/**
* Leitet die vollständige Geometrie einer Treppe ab. `totalRise` MUSS vom
* Aufrufer aufgelöst übergeben werden (Geschosshöhe-Default liegt in
* `stairVerticalExtent`), damit dieses Modul modellfrei bleibt.
* Aufrufer aufgelöst übergeben werden (Geschosshöhe-Default liegt im Kern,
* `stair_vertical_extent` in `model/helpers.rs`), damit dieses Modul modellfrei bleibt.
*/
export function stairGeometry(stair: Stair, totalRise: number): StairGeometry {
return decodeGeometry(core().stair_geometry_flat(encodeStair(stair), totalRise));
@@ -199,18 +199,6 @@ export function stairCut(geo: StairGeometry, cutRise: number): StairCut {
return { belowIndices, aboveIndices, breakLine };
}
/** Achsparallele Bounding-Box aller Tritte (+ Podest) einer Treppengeometrie. */
export function stairBBox(geo: StairGeometry): {
minX: number;
minY: number;
maxX: number;
maxY: number;
} {
const f = core().stair_bbox_flat(encodeGeometry(geo));
if (f.length < 4) return { minX: 0, minY: 0, maxX: 0, maxY: 0 };
return { minX: f[0], minY: f[1], maxX: f[2], maxY: f[3] };
}
/**
* Spiral-Outline: Innenbogen + Aussenbogen + zwei radiale Schliesslinien.
* Die Bögen werden als Kreisbogen-Parameter geliefert (cx/cy/r/a0/a1), die