[K1][K2] Bögen und Treppen nach Rust: bulge.ts und stair.ts nur noch Fassade über den Kern

Bögen: Tessellation, Drei-Punkt-/Radius-/Tangenten-Bogen, bulgePointAt und ganze
Polylinien (bulge_polyline_points) in kernel2d; TS-Formeln gelöscht, Aufrufer mit
Segmentschleifen nutzen bulgePolylinePoints. Treppen: stair_geometry um Referenz
(links/rechts) ergänzt, stair_outline neu; stairCut/stairBBox/defaultStepCount über
flache Puffer; pointInPolygon/pointHitsStair (ungenutzt) gelöscht.
This commit is contained in:
Claude committed 2026-10-27 21:42:29 +00:00
1 parent d9daed7c47
commit 6c84cd371b
21 files changed
+1395 -734

No files matched your search

+3 -8
View File
@@ -23,7 +23,7 @@
// Bezeichner englisch, Kommentare/UI deutsch (CONVENTIONS.md).
import type { Drawing2D, Drawing2DGeom } from "../../model/types";
import { bulgeArcPoints, hasRealBulge } from "../../core";
import { bulgePolylinePoints, hasRealBulge } from "../../core";
import { extendBulgeSegment, extendSegment, pointSegmentDistance, polylineEdges } from "../../core";
import type {
Command,
@@ -56,13 +56,8 @@ function geomToOpenCurve(g: Drawing2DGeom): Curve | null {
*/
function curveHitEdges(curve: Curve): [Vec2, Vec2][] {
if (!hasRealBulge(curve.bulge)) return polylineEdges(curve.pts, curve.closed);
const n = curve.pts.length;
const edgeCount = curve.closed ? n : n - 1;
const chain: Vec2[] = [curve.pts[0]];
for (let i = 0; i < edgeCount; i++) {
const seg = bulgeArcPoints(curve.pts[i], curve.pts[(i + 1) % n], curve.bulge?.[i]);
chain.push(...seg.slice(1));
}
const chain = bulgePolylinePoints(curve.pts, curve.bulge, curve.closed);
if (curve.closed) chain.push(curve.pts[0]); // Schlusskante mit-tesselliert, Kette endet am Start
return polylineEdges(chain, false);
}
+4 -9
View File
@@ -14,7 +14,7 @@
// Vorzeichen, wenn negativ getippt.
import type { Drawing2D, Drawing2DGeom } from "../../model/types";
import { bulgeArcPoints, hasRealBulge } from "../../core";
import { bulgePolylinePoints, hasRealBulge } from "../../core";
import { uniqueId } from "../../tools/types";
import { leftNormal, normalize, sub } from "../../model/geometry";
import { offsetPolyline, offsetPolylineWithBulge, offsetSegment, pointSegmentDistance, polylineEdges } from "../../core";
@@ -86,20 +86,15 @@ function singleSelectedCurve(project: Project, sel: CommandSelection): Drawing2D
/**
* Kanten für Klick-Trefftests/Vorschau: bei Bogen-Segmenten (bulge) wird die
* Kurve zu Geradenstücken tesselliert (`bulgeArcPoints`), damit Klick-/Seiten-
* Kurve zu Geradenstücken tesselliert (`bulgePolylinePoints`), damit Klick-/Seiten-
* Tests entlang der TATSÄCHLICHEN (runden) Kontur funktionieren statt entlang
* der geraden Sehne. Die eigentliche Offset-Geometrie bleibt exakt (bulge-
* erhaltend, s. `offsetPolylineWithBulge`) — nur diese Hilfsfunktion approximiert.
*/
function curveHitEdges(curve: Curve): [Vec2, Vec2][] {
if (!hasRealBulge(curve.bulge)) return polylineEdges(curve.pts, curve.closed);
const n = curve.pts.length;
const edgeCount = curve.closed ? n : n - 1;
const chain: Vec2[] = [curve.pts[0]];
for (let i = 0; i < edgeCount; i++) {
const seg = bulgeArcPoints(curve.pts[i], curve.pts[(i + 1) % n], curve.bulge?.[i]);
chain.push(...seg.slice(1));
}
const chain = bulgePolylinePoints(curve.pts, curve.bulge, curve.closed);
if (curve.closed) chain.push(curve.pts[0]); // Schlusskante mit-tesselliert, Kette endet am Start
return polylineEdges(chain, false); // Schlusskante (falls closed) ist bereits mit-tesselliert
}
+2 -6
View File
@@ -19,7 +19,7 @@
// Tangenten-Referenz und bleibt gerade.
import type { Drawing2D } from "../../model/types";
import { bulgeArcPoints, bulgeThroughPoint } from "../../core";
import { bulgePolylinePoints, bulgeThroughPoint } from "../../core";
import { segmentHud, uniqueId } from "../../tools/types";
import type {
Command,
@@ -190,11 +190,7 @@ function polyDraft(
: 0;
const allBulges = cursor ? [...bulges, previewBulge] : bulges;
// Bogen-Segmente für die Vorschau ausrollen.
const pts: Vec2[] = all.length ? [all[0]] : [];
for (let i = 0; i < all.length - 1; i++) {
const sub = bulgeArcPoints(all[i], all[i + 1], allBulges[i] ?? 0);
for (let k = 1; k < sub.length; k++) pts.push(sub[k]);
}
const pts = bulgePolylinePoints(all, allBulges, false);
// Ring nur ab 3 Punkten zeigen; darunter bleibt die Vorschau offen.
const showClosed = closed && all.length >= 3;
const preview: DraftShape[] = [{ kind: "poly", pts, closed: showClosed }];
+2 -7
View File
@@ -32,7 +32,7 @@
import type { Drawing2D } from "../../model/types";
import { deltaHud, segmentHud, uniqueId } from "../../tools/types";
import { filletCorner } from "../../core";
import { bulgeArcPoints, bulgeThroughPoint } from "../../core";
import { bulgePolylinePoints, bulgeThroughPoint } from "../../core";
import type {
Command,
CommandContext,
@@ -257,12 +257,7 @@ function roundedRectPts(corners: Vec2[], r: number): { pts: Vec2[]; bulge: numbe
/** Tessellierte Punkte einer gerundeten geschlossenen Kontur — für die Live-Vorschau. */
function tessellateRounded(pts: Vec2[], bulge: number[]): Vec2[] {
const out: Vec2[] = [];
const n = pts.length;
for (let i = 0; i < n; i++) {
out.push(...bulgeArcPoints(pts[i], pts[(i + 1) % n], bulge[i]).slice(0, -1));
}
return out;
return bulgePolylinePoints(pts, bulge, true);
}
// ── Vorschau ─────────────────────────────────────────────────────────────────
+2 -6
View File
@@ -9,7 +9,7 @@
// Aufrufe hinweg (wie `lastSides` bei `polygon.ts`).
import type { Drawing2D } from "../../model/types";
import { bulgeArcPoints } from "../../core";
import { bulgePolylinePoints } from "../../core";
import { revisionCloudPts } from "../../core";
import { segmentHud, uniqueId } from "../../tools/types";
import type {
@@ -53,11 +53,7 @@ function revcloudDraft(points: Vec2[], cursor: Vec2 | null): ToolDraft {
const expanded = revisionCloudPts(all, false, lastArcSize);
const pts: Vec2[] = [];
if (expanded) {
pts.push(expanded.pts[0]);
for (let i = 0; i < expanded.pts.length - 1; i++) {
const sub = bulgeArcPoints(expanded.pts[i], expanded.pts[i + 1], expanded.bulge[i]);
for (let k = 1; k < sub.length; k++) pts.push(sub[k]);
}
pts.push(...bulgePolylinePoints(expanded.pts, expanded.bulge, false));
}
const preview: DraftShape[] = [{ kind: "poly", pts, closed: false }];
const draft: ToolDraft = { preview, vertices: points };
+3 -8
View File
@@ -19,7 +19,7 @@
// Bezeichner englisch, Kommentare/UI deutsch (CONVENTIONS.md).
import type { Drawing2D, Drawing2DGeom } from "../../model/types";
import { bulgeArcPoints, hasRealBulge } from "../../core";
import { bulgePolylinePoints, hasRealBulge } from "../../core";
import { uniqueId } from "../../tools/types";
import { pointSegmentDistance, polylineEdges, trimPolylineWithBulge, vecEqual } from "../../core";
import type {
@@ -78,13 +78,8 @@ export function isTrimmable(d: Drawing2D): boolean {
*/
export function curveHitEdges(curve: Curve): [Vec2, Vec2][] {
if (!hasRealBulge(curve.bulge)) return polylineEdges(curve.pts, curve.closed);
const n = curve.pts.length;
const edgeCount = curve.closed ? n : n - 1;
const chain: Vec2[] = [curve.pts[0]];
for (let i = 0; i < edgeCount; i++) {
const seg = bulgeArcPoints(curve.pts[i], curve.pts[(i + 1) % n], curve.bulge?.[i]);
chain.push(...seg.slice(1));
}
const chain = bulgePolylinePoints(curve.pts, curve.bulge, curve.closed);
if (curve.closed) chain.push(curve.pts[0]); // Schlusskante mit-tesselliert, Kette endet am Start
return polylineEdges(chain, false);
}