Merge branch 'worktree-agent-a8d7e77ddfaeadb8c' into claude/practical-noether-1hb2s1
This commit is contained in:
29 files changed
+1154
-193
No files matched your search
@@ -13,10 +13,6 @@ export {
|
||||
pointOnCircle,
|
||||
} from "../geometry/bulge";
|
||||
|
||||
export {
|
||||
columnFootprint,
|
||||
} from "../geometry/column";
|
||||
|
||||
export {
|
||||
sampleBezierChain,
|
||||
sampleCatmullRom,
|
||||
|
||||
@@ -57,3 +57,31 @@ describe("Druck-SVG: Strichmuster", () => {
|
||||
expect(seen.every((s) => s[1] === seen[0][1])).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
// [169] Runde Stütze (in der Szene fein nachtesselliert) als Pfad mit Bögen statt Vieleck; gestrichelter
|
||||
// Bogen (Türschwenk) mit Musterphase.
|
||||
describe("Druck-SVG: Kreise und Bögen", () => {
|
||||
it("Kreis-Fläche und -Umriss als <path> mit A, Bogen mit stroke-dashoffset", () => {
|
||||
const ring: [number, number][] = Array.from({ length: 180 }, (_, i) => {
|
||||
const t = (2 * Math.PI * i) / 180;
|
||||
return [1 + 0.15 * Math.cos(t), 1 + 0.15 * Math.sin(t)];
|
||||
});
|
||||
const sc = {
|
||||
fills: [{ pts: ring, color: [0, 0, 0, 1], z: 0 }],
|
||||
outlines: [{ pts: ring, color: [0, 0, 0, 1], widthMm: 0.35, dash: null, z: 1 }],
|
||||
polylines: [],
|
||||
arcs: [{ center: [0, 0], from: [2, 0], to: [0, 2], r: 2, color: [0, 0, 0, 1], widthMm: 0.18, dash: [2, 1] }],
|
||||
lines: [],
|
||||
texts: [],
|
||||
images: [],
|
||||
bounds: { minX: -1, minY: -1, maxX: 3, maxY: 3 },
|
||||
} as unknown as RScene;
|
||||
const svg = sceneToPrintSvg(sc, { scaleDenominator: 50, pageWidthMm: 100, pageHeightMm: 100 }).svg as unknown as FakeEl;
|
||||
const paths = svg.children.filter((c) => c.tag === "path");
|
||||
expect(svg.children.some((c) => c.tag === "polygon")).toBe(false);
|
||||
// Fläche und Umriss (je zwei Halbkreise r = 3 mm bei 1:50) und der Bogen.
|
||||
expect(paths.filter((p) => (p.attrs.get("d") ?? "").includes(" A 3 3 ")).length).toBe(2);
|
||||
const arc = paths.find((p) => p.attrs.has("stroke-dasharray"))!;
|
||||
expect(arc.attrs.get("stroke-dashoffset")).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -228,11 +228,35 @@ function ptsAttrOf(pts: RPoint[], map: Mapper): string {
|
||||
return pts.map((p) => map(p)).map(([x, y]) => `${round(x)},${round(y)}`).join(" ");
|
||||
}
|
||||
|
||||
/**
|
||||
* [169] Zug mit Boegen (runde Stuetze, Bogenwand; in der Szene fein nachtesselliert) als `<path>` mit
|
||||
* `A`-Befehlen statt Vieleck: Kern `plan_arc_path_d` (Bogenerkennung `plan/arc_fit.rs`) auf den
|
||||
* Papier-mm-Punkten. Ohne erkannten Bogen `null` (dann `polygon`/`polyline`).
|
||||
*/
|
||||
function arcPathEl(pts: RPoint[], closed: boolean, map: Mapper): SVGElement | null {
|
||||
if (pts.length < 4) return null;
|
||||
const flat = new Float64Array(pts.length * 2);
|
||||
pts.forEach((p, i) => {
|
||||
const [x, y] = map(p);
|
||||
flat[2 * i] = x;
|
||||
flat[2 * i + 1] = y;
|
||||
});
|
||||
const d = core().plan_arc_path_d(flat, closed, ARC_TOL_MM);
|
||||
if (!d) return null;
|
||||
const el = document.createElementNS(SVG_NS, "path");
|
||||
el.setAttribute("d", d);
|
||||
return el;
|
||||
}
|
||||
|
||||
/** Toleranz der Bogenerkennung auf dem Blatt (mm). */
|
||||
const ARC_TOL_MM = 1e-4;
|
||||
|
||||
/** Gefuelltes Polygon (Wand-Poche, Raeume, Decken, Grundfuellung vor Schraffur). */
|
||||
function appendFill(svg: SVGSVGElement, f: RFill, map: Mapper): void {
|
||||
if (f.pts.length < 3) return;
|
||||
const el = document.createElementNS(SVG_NS, "polygon");
|
||||
el.setAttribute("points", ptsAttrOf(f.pts, map));
|
||||
const arc = arcPathEl(f.pts, true, map);
|
||||
const el = arc ?? document.createElementNS(SVG_NS, "polygon");
|
||||
if (!arc) el.setAttribute("points", ptsAttrOf(f.pts, map));
|
||||
el.setAttribute("fill", rgbCss(f.color));
|
||||
setOpacityAttr(el, "fill-opacity", f.color[3]);
|
||||
el.setAttribute("stroke", "none");
|
||||
@@ -267,8 +291,9 @@ function appendStroke(
|
||||
const effectiveMm = widthScreen ? widthMm * HATCH_DENSITY_MM : widthMm;
|
||||
const strokeMm = quantizePen(effectiveMm);
|
||||
|
||||
const el = document.createElementNS(SVG_NS, closed ? "polygon" : "polyline");
|
||||
el.setAttribute("points", ptsAttrOf(pts, map));
|
||||
const arc = widthScreen ? null : arcPathEl(pts, closed, map);
|
||||
const el = arc ?? document.createElementNS(SVG_NS, closed ? "polygon" : "polyline");
|
||||
if (!arc) el.setAttribute("points", ptsAttrOf(pts, map));
|
||||
el.setAttribute("fill", "none");
|
||||
el.setAttribute("stroke", rgbCss(color));
|
||||
setOpacityAttr(el, "stroke-opacity", color[3]);
|
||||
@@ -343,6 +368,11 @@ function appendArc(svg: SVGSVGElement, a: RArc, map: Mapper, mmPerM: number): vo
|
||||
el.setAttribute("stroke-width", String(quantizePen(a.widthMm)));
|
||||
if (a.dash && a.dash.length) {
|
||||
el.setAttribute("stroke-dasharray", a.dash.map((x) => round(x)).join(" "));
|
||||
// [153]/[169] Musterphase auch auf Boegen (kuerzerer Bogen, wie gezeichnet).
|
||||
let sw = Math.abs(Math.atan2(v2.y, v2.x) - Math.atan2(v1.y, v1.x));
|
||||
if (sw > Math.PI) sw = 2 * Math.PI - sw;
|
||||
const ph = core().line_dash_phase(r * sw, Float64Array.from(a.dash));
|
||||
if (ph > 1e-9) el.setAttribute("stroke-dashoffset", String(round(ph)));
|
||||
}
|
||||
svg.appendChild(el);
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
// Stützen-Geometrie: leitet aus einer Stütze (Column) ihren Grundriss-Querschnitt
|
||||
// (Poché-/Footprint-Polygon) ab. Reine Funktion, keine Modell-Mutation — sowohl
|
||||
// der 2D-Grundriss (generatePlan) als auch die 3D-Extrusion (toWalls3d) und die
|
||||
// Auswahl-/Transform-Vorschau (transform.ts) nutzen dieselbe Kontur.
|
||||
//
|
||||
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import type { Column, Vec2 } from "../model/types";
|
||||
|
||||
/** Tessellierungs-Segmentzahl eines runden Stützenprofils (Grundriss + 3D-Prisma). */
|
||||
export const COLUMN_ROUND_SEGMENTS = 32;
|
||||
|
||||
/**
|
||||
* Grundriss-Querschnitt einer Stütze als geschlossenes Polygon (Modell-Meter,
|
||||
* CCW), um `position` platziert und (bei Rechteck) um `rotation` gedreht. Ein
|
||||
* rundes Profil wird als regelmäßiges {@link COLUMN_ROUND_SEGMENTS}-Eck
|
||||
* tesselliert; der Schlusspunkt wird NICHT dupliziert.
|
||||
*/
|
||||
export function columnFootprint(col: Column): Vec2[] {
|
||||
const { x: cx, y: cy } = col.position;
|
||||
if (col.profile.kind === "round") {
|
||||
const r = col.profile.radius;
|
||||
const pts: Vec2[] = [];
|
||||
for (let i = 0; i < COLUMN_ROUND_SEGMENTS; i++) {
|
||||
const t = (i / COLUMN_ROUND_SEGMENTS) * Math.PI * 2;
|
||||
pts.push({ x: cx + r * Math.cos(t), y: cy + r * Math.sin(t) });
|
||||
}
|
||||
return pts;
|
||||
}
|
||||
// Rechteck: lokale Ecken ±w/2 (X) × ±d/2 (Y), um `rotation` gedreht.
|
||||
const hw = col.profile.width / 2;
|
||||
const hd = col.profile.depth / 2;
|
||||
const rot = col.rotation ?? 0;
|
||||
const cos = Math.cos(rot);
|
||||
const sin = Math.sin(rot);
|
||||
const local: Vec2[] = [
|
||||
{ x: -hw, y: -hd },
|
||||
{ x: +hw, y: -hd },
|
||||
{ x: +hw, y: +hd },
|
||||
{ x: -hw, y: +hd },
|
||||
];
|
||||
return local.map((p) => ({
|
||||
x: cx + p.x * cos - p.y * sin,
|
||||
y: cy + p.x * sin + p.y * cos,
|
||||
}));
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
viewBox -4.2 0 37.045 17.378
|
||||
bytes 192404
|
||||
bytes 193364
|
||||
circle 4
|
||||
g 1
|
||||
line 556
|
||||
polygon 1018
|
||||
polygon 1026
|
||||
polyline 44
|
||||
rect 1
|
||||
svg 1
|
||||
text 4
|
||||
hash ee49aae5cc3ed4a4
|
||||
hash 32b9045a8708e6ad
|
||||
@@ -1,13 +1,13 @@
|
||||
viewBox -41.5 0 95 63.6
|
||||
bytes 79943
|
||||
bytes 69342
|
||||
circle 16
|
||||
g 1
|
||||
line 172
|
||||
path 18
|
||||
polygon 90
|
||||
polyline 124
|
||||
path 30
|
||||
polygon 81
|
||||
polyline 121
|
||||
rect 1
|
||||
svg 1
|
||||
text 116
|
||||
tspan 24
|
||||
hash 9dadf0534a699dd9
|
||||
hash b09770784bf89a35
|
||||
@@ -1,13 +1,13 @@
|
||||
viewBox -41.5 0 95 63.6
|
||||
bytes 131023
|
||||
bytes 117357
|
||||
circle 16
|
||||
g 1
|
||||
line 419
|
||||
path 39
|
||||
polygon 252
|
||||
polyline 145
|
||||
path 59
|
||||
polygon 236
|
||||
polyline 141
|
||||
rect 1
|
||||
svg 1
|
||||
text 121
|
||||
tspan 32
|
||||
hash ff2665a76f5bbb8d
|
||||
hash d3d02bf2fbc8b704
|
||||
@@ -1,12 +1,13 @@
|
||||
viewBox -12.8 0 37.6 33.6
|
||||
bytes 51729
|
||||
bytes 48623
|
||||
circle 14
|
||||
g 1
|
||||
line 142
|
||||
polygon 52
|
||||
polyline 111
|
||||
path 8
|
||||
polygon 45
|
||||
polyline 110
|
||||
rect 1
|
||||
svg 1
|
||||
text 88
|
||||
tspan 19
|
||||
hash 17f9cbe73785a7bd
|
||||
hash 6dd15cc4f269c858
|
||||
@@ -1,13 +1,13 @@
|
||||
viewBox -12.65 0 37.3 33.3
|
||||
bytes 370588
|
||||
bytes 365622
|
||||
circle 14
|
||||
g 1
|
||||
line 3238
|
||||
path 21
|
||||
polygon 213
|
||||
polyline 180
|
||||
path 36
|
||||
polygon 199
|
||||
polyline 179
|
||||
rect 1
|
||||
svg 1
|
||||
text 91
|
||||
tspan 24
|
||||
hash d968a9e0e5adcdd3
|
||||
hash a53d7dc3ed58eded
|
||||
@@ -1,13 +1,13 @@
|
||||
viewBox -12.8 0 37.6 33.6
|
||||
bytes 52830
|
||||
circle 14
|
||||
bytes 42610
|
||||
circle 15
|
||||
g 1
|
||||
line 121
|
||||
path 4
|
||||
polygon 44
|
||||
polyline 83
|
||||
path 14
|
||||
polygon 37
|
||||
polyline 79
|
||||
rect 1
|
||||
svg 1
|
||||
text 73
|
||||
tspan 18
|
||||
hash d87f0eaf1cd610d4
|
||||
hash 9e69d187939143f2
|
||||
@@ -1,13 +1,13 @@
|
||||
viewBox -12.65 0 37.3 33.3
|
||||
bytes 62538
|
||||
circle 14
|
||||
bytes 50135
|
||||
circle 15
|
||||
g 1
|
||||
line 117
|
||||
path 15
|
||||
polygon 89
|
||||
polyline 92
|
||||
path 29
|
||||
polygon 80
|
||||
polyline 86
|
||||
rect 1
|
||||
svg 1
|
||||
text 75
|
||||
tspan 20
|
||||
hash 0a0d09cb775a502b
|
||||
hash 4dbe226dec66455c
|
||||
@@ -8,8 +8,8 @@ meshes[].indices [180]
|
||||
meshes[].indices [192] x3
|
||||
meshes[].indices [348] x6
|
||||
meshes[].indices [36] x1858
|
||||
meshes[].indices [372]
|
||||
meshes[].indices [396]
|
||||
meshes[].indices [564]
|
||||
meshes[].indices [60] x9
|
||||
meshes[].indices [72]
|
||||
meshes[].indices [84] x2
|
||||
@@ -19,12 +19,11 @@ meshes[].positions [1044] x6
|
||||
meshes[].positions [108] x30
|
||||
meshes[].positions [120]
|
||||
meshes[].positions [180] x9
|
||||
meshes[].positions [192]
|
||||
meshes[].positions [216]
|
||||
meshes[].positions [24] x1826
|
||||
meshes[].positions [252] x2
|
||||
meshes[].positions [264]
|
||||
meshes[].positions [288] x6
|
||||
meshes[].positions [288] x7
|
||||
meshes[].positions [306] x3
|
||||
meshes[].positions [324] x6
|
||||
meshes[].positions [4746]
|
||||
@@ -61,4 +60,4 @@ walls[].start [2] x1489
|
||||
walls[].startCut [4] x1164
|
||||
walls[].topDrop [2] x103
|
||||
walls[].topPlane [3] x259
|
||||
hash 0401db08722c5c30
|
||||
hash f77d51f089e28986
|
||||
@@ -1,11 +1,11 @@
|
||||
viewBox 4.457 0 21.343 17.378
|
||||
bytes 34158
|
||||
circle 3
|
||||
bytes 33583
|
||||
circle 4
|
||||
g 1
|
||||
line 33
|
||||
polygon 186
|
||||
polygon 185
|
||||
polyline 16
|
||||
rect 1
|
||||
svg 1
|
||||
text 3
|
||||
hash ab512b19fa3bae7c
|
||||
hash ef5a378a0ea326c1
|
||||
+4
-17
@@ -11,7 +11,6 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { generatePlan } from "./generatePlan";
|
||||
import { projectToModel3d } from "./toWalls3d";
|
||||
import { columnFootprint } from "../geometry/column";
|
||||
import type { Column, Project } from "../model/types";
|
||||
|
||||
/** Minimalprojekt (zwei Geschosse gestapelt) mit einer konfigurierbaren Stütze. */
|
||||
@@ -111,7 +110,7 @@ describe("Stütze — 3D (projectToModel3d / emitColumns)", () => {
|
||||
expect(Math.max(...zs)).toBeCloseTo(3, 6);
|
||||
});
|
||||
|
||||
it("erzeugt ein tesselliertes Kreis-Prisma (64 Ecken)", () => {
|
||||
it("erzeugt ein tesselliertes Kreis-Prisma (96 Ecken)", () => {
|
||||
const round: Column = {
|
||||
...rectColumn,
|
||||
profile: { kind: "round", radius: 0.15 },
|
||||
@@ -119,20 +118,8 @@ describe("Stütze — 3D (projectToModel3d / emitColumns)", () => {
|
||||
const model = projectToModel3d(projectWithColumn(round));
|
||||
const mesh = model.meshes.find((m) => m.kind === "extrusion");
|
||||
if (!mesh) throw new Error("kein Prisma-Mesh");
|
||||
// 32-Eck × (unten + oben) = 64 Vertices.
|
||||
expect(mesh.positions.length).toBe(64 * 3);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Stütze — Footprint-Helfer (columnFootprint)", () => {
|
||||
it("tesselliert ein rundes Profil als 32-Eck um die Position", () => {
|
||||
const round: Column = { ...rectColumn, profile: { kind: "round", radius: 0.15 } };
|
||||
const pts = columnFootprint(round);
|
||||
expect(pts.length).toBe(32);
|
||||
// Alle Punkte liegen im Radius 0.15 um (2,3).
|
||||
for (const p of pts) {
|
||||
const d = Math.hypot(p.x - 2, p.y - 3);
|
||||
expect(d).toBeCloseTo(0.15, 6);
|
||||
}
|
||||
// [169] 48-Eck (Pfeilhöhe ≤ 0.5 mm, Kern `column_round_segments`) × (unten + oben) = 96 Vertices, glatt.
|
||||
expect(mesh.positions.length).toBe(96 * 3);
|
||||
expect(mesh.creaseAngle).toBe(30);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user