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

This commit is contained in:
Claude committed 2026-11-09 13:20:16 +00:00
commit 66fa208151
8 files changed
+159 -39

No files matched your search

+6 -4
View File
@@ -54,10 +54,12 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
hindurch, Stütze kürzer als Wand, Stütze mit mehreren Höhenabschnitten, Längsschnitt genau in einer Wand
(`split_wall_layers`), Muster bei ungeraden Maschen (Kern `plan/walls.rs`, `joins.rs`). · M
- ◐ **[145]** Texte beim Zoomen synchron. Falls der Mac noch nachläuft: Raumstempel nativ zeichnen (vtext kann nur
einzeilig/linksbündig, eine Schrift, kein Fett). Zudem: Vorschau beim Setzen zeigt den Cursor-Ort statt der
verrückten Lage; `clampInside` steht in TS (Griff) und Rust (Befehl) doppelt. · S
- ◐ **[146]** Linienenden/-ecken. Druck-SVG streicht Polygone rundum (kein `noStrokeEdges`); Nähen in Metal-Chunks nur
innerhalb eines Chunks (Kern `plan/line_ends.rs`, `render2d`). · M
einzeilig/linksbündig, eine Schrift, kein Fett). 9.11.: `clampInside` nur noch im Kern (`grip_clamp_inside`,
Fassade `clampInside` in `src/core`); die Öffnungs-Vorschau beim Setzen zeigt die geklemmte/gerückte Lage
(`placed_gap`, Test `oeffnung_vorschau_zeigt_gerueckte_lage`). Offen: Dach-/Deckenöffnung hat beim Setzen keine
eigene Vorschau; Raumstempel setzt ohne Klemmung (nichts zu zeigen). · S
- ◐ **[146]** Linienenden/-ecken. Druck-SVG achtet seit 9.11. auf `noStrokeEdges` (offene Kantenzüge, Test
`ungestrichene_kante_ohne_strich`); Nähen in Metal-Chunks nur innerhalb eines Chunks (Kern `plan/line_ends.rs`, `render2d`). · M
- ◐ **[150]** Gelände im Grundriss am Gebäude. Raumstempel ausserhalb ihres Raums sind kein Hindernis für
Höhenlinien-Beschriftungen; Beschriftungen an Bündeln fehlen statt versetzt zu werden. · S
- ◐ **[153]** Strichmuster in Papier-mm. Bögen/Kreise ohne Phase (beginnen mit Strich), DXF/DWG ohne Phase je Objekt,
+45 -4
View File
@@ -793,10 +793,26 @@ fn opening_ops(root: &Map<String, Value>, p: &Project, v: &Value, ctx: &Ctx, ids
add_op("openings", vec![obj(f)])
}
/// Lage der Lücke, wie das Setzen sie ergibt ([`opening_ops`]): Breite und Anfang in die Wand geklemmt,
/// bei Überlappung an die nächste freie Stelle gerückt ([145]: die Vorschau zeigt die gesetzte Lage, nicht
/// den Cursor). Ohne Platz bleibt die geklemmte Lage (das Setzen bewirkt dann nichts). `(pos, width)`.
fn placed_gap(root: &Map<String, Value>, v: &Value, len: f64, pos: f64) -> (f64, f64) {
let width = jsnum::max(0.1, jsnum::min(n_of(v, "width"), len));
let pos = jsnum::max(0.0, jsnum::min(pos, jsnum::max(0.0, len - width)));
match crate::opening_slide::place(root, s_of(v, "wall"), len, width, None, pos, &|_| false) {
Some(pl) if pl.clamped => (pl.position, width),
_ => (pos, width),
}
}
/// Öffnungs-Vorschau (Lücken-Balken + Symbol). `pos` fehlt → aus dem Cursor projiziert.
/// `info = [pos, von, ax, ay, bx, by, mx, my]` (Position für den Zustand, HUD/Stützpunkte).
fn opening_preview(v: &Value, cursor: Option<V>, out: &mut Shapes, info: &mut Vec<f64>) {
fn opening_preview(root: &Map<String, Value>, v: &Value, cursor: Option<V>, out: &mut Shapes, info: &mut Vec<f64>) {
let (st, en) = (p_of(v, "start"), p_of(v, "end"));
let wall_len = match arc_of(st, en, opt_n(v, "bulge")) {
Some(a) => a.length(),
None => hypot2(en.0 - st.0, en.1 - st.1),
};
// Bogenwand ([T2]): Lücke und Symbol entlang des Bogens, Position = Bogenlänge.
if let Some(arc) = arc_of(st, en, opt_n(v, "bulge")) {
let len = arc.length();
@@ -805,7 +821,7 @@ fn opening_preview(v: &Value, cursor: Option<V>, out: &mut Shapes, info: &mut Ve
(None, Some(c)) => project_onto_any(st, en, opt_n(v, "bulge"), c).0,
(None, None) => 0.0,
};
let width = n_of(v, "width");
let (pos, width) = placed_gap(root, v, wall_len, pos);
let from = jsnum::max(0.0, jsnum::min(pos, len));
let to = jsnum::max(from, jsnum::min(from + width, len));
let at = |s: f64, n: f64| {
@@ -836,12 +852,12 @@ fn opening_preview(v: &Value, cursor: Option<V>, out: &mut Shapes, info: &mut Ve
(None, Some(c)) => project_onto_wall(st, en, c).0,
(None, None) => 0.0,
};
let (pos, width) = placed_gap(root, v, wall_len, pos);
let ax = (en.0 - st.0, en.1 - st.1);
let l = hypot2(ax.0, ax.1);
let len = if l == 0.0 || l.is_nan() { 1e-9 } else { l };
let u = (ax.0 / len, ax.1 / len);
let n = (-u.1, u.0);
let width = n_of(v, "width");
let from = jsnum::max(0.0, jsnum::min(pos, len));
let to = jsnum::max(from, jsnum::min(from + width, len));
let a = (st.0 + u.0 * from, st.1 + u.1 * from);
@@ -1163,7 +1179,7 @@ pub fn preview_req(root: &Map<String, Value>, project: &Project, req: &Req, pts:
match req.cmd.as_str() {
"wall" => wall_preview(root, v, &ctx, &pts, out),
"stair" => stair_preview(project, v, &ctx, out, &mut p.info),
"opening" => opening_preview(v, pts.first().copied(), out, &mut p.info),
"opening" => opening_preview(root, v, pts.first().copied(), out, &mut p.info),
"roomInside" => p.ok = pts.first().and_then(|at| room_inside(project, ctx.level, *at)).is_some_and(|b| b.len() >= 3),
// Zauberstab ([77]): die gefundene Masche unter dem Cursor.
"wand" => match pts.first().and_then(|at| crate::magic_wand::region_at(project, ctx.level, *at)) {
@@ -1444,5 +1460,30 @@ mod tests {
assert_eq!(p.info[0], 2.0);
assert_eq!(p.shapes.count, 2);
}
/// [145] Die Vorschau zeigt die Lage, die das Setzen ergibt (an die Wand geklemmt, an die nächste freie
/// Stelle gerückt), nicht den Cursor-Ort.
#[test]
fn oeffnung_vorschau_zeigt_gerueckte_lage() {
let r = root(json!({"walls": [{"id": "w", "floorId": "F1", "start": {"x": 0, "y": 0}, "end": {"x": 6, "y": 0}}], "openings": [{"id": "a", "hostWallId": "w", "position": 2, "width": 1}], "windowTypes": [{"id": "FT"}]}));
let t = crate::model::lenient::typed_for_test(&r);
let pos_of = |width: f64, cursor: f64, pos: Value| {
let v = json!({"cmd": "opening", "wall": "w", "start": [0, 0], "end": [6, 0], "kind": "window", "width": width, "pos": pos});
let pv = preview(&r, &t, &v, &[cursor, 0.0]);
let set = ops(&r, &t, &req(json!({"cmd": "opening", "wall": "w", "start": [0, 0], "end": [6, 0], "kind": "window", "pos": pos_or(&pv), "width": width, "height": 1.2, "sill": 0.9}))).unwrap();
(pv.info[0], pv.info[1], items(&set, 0)[0]["position"].as_f64().unwrap())
};
// Cursor über der Nachbaröffnung: rückt neben sie (Steg 5 cm), Setzen an derselben Stelle.
let (p, from, set) = pos_of(1.0, 2.6, Value::Null);
assert_eq!((p, from), (3.05, 3.05));
assert_eq!(set, 3.05);
// Cursor am Wandende: die Lücke behält ihre Breite und rückt in die Wand.
let (p, from, set) = pos_of(1.2, 5.9, Value::Null);
assert_eq!((p, from, set), (4.8, 4.8, 4.8));
}
fn pos_or(p: &Preview) -> f64 {
p.info[0]
}
}
+78 -4
View File
@@ -235,6 +235,28 @@ fn poly_node(pts: &str, fill: &str, stroke: &str, stroke_mm: f64) -> Vec<(&'stat
a
}
/// Polygon mit Füllung und Strich; mit `nse` (nicht gestrichene Kanten, [146]) die Füllung ohne Strich
/// und die sichtbaren Kantenläufe als offene Linienzüge — wie das Plan-SVG (`plan/svg.rs`).
fn poly_stroked(out: &mut Out, attr: &str, pts_mm: &[V2], nse: &[f64], fill: &str, stroke: &str, stroke_mm: f64) {
if nse.is_empty() || stroke_mm <= 0.0 || stroke == "none" {
out.el(1, "polygon", &poly_node(attr, fill, stroke, stroke_mm));
return;
}
out.el(1, "polygon", &poly_node(attr, fill, "none", 0.0));
poly_outline(out, pts_mm, nse, stroke, stroke_mm);
}
/// Nur der Umriss (Füllung oder Schraffur liegt schon darunter).
fn poly_outline(out: &mut Out, pts_mm: &[V2], nse: &[f64], stroke: &str, stroke_mm: f64) {
if nse.is_empty() {
out.el(1, "polygon", &poly_node(&pts_attr(pts_mm), "none", stroke, stroke_mm));
return;
}
for run in crate::plan::scene::visible_edge_runs(pts_mm, nse) {
out.el(1, "polyline", &polyline_attrs(&run, stroke, stroke_mm, None));
}
}
fn line_attrs(a: V2, b: V2, color: &str, stroke_mm: f64, dash: Option<&[f64]>) -> Vec<(&'static str, String)> {
let mut v = vec![
("x1", r3(a.x)),
@@ -398,6 +420,10 @@ fn entry(out: &mut Out, view: &View, i: usize, hatches: &[(i32, Hatch, i32)], m:
let opacity = opacity_of(greyed, obj(4));
let pts_mm: Vec<V2> = pts.iter().map(|p| m.at(p.x, p.y)).collect();
let attr = pts_attr(&pts_mm);
let nse: Vec<f64> = match rec.nse {
Some((o, n)) => view.pool(o, n)?.into_iter().filter(|e| e.is_finite() && *e >= 0.0).collect(),
None => Vec::new(),
};
let sw = f[2];
let stroke_mm = if sw > 0.0 { quantize_pen(sw) } else { 0.0 };
let fill = s(f[0])?;
@@ -418,12 +444,12 @@ fn entry(out: &mut Out, view: &View, i: usize, hatches: &[(i32, Hatch, i32)], m:
}
out.rec(&["I", &attr, &img]);
if stroke_mm > 0.0 {
out.el(1, "polygon", &poly_node(&attr, "none", &stroke, stroke_mm));
poly_outline(out, &pts_mm, &nse, &stroke, stroke_mm);
}
} else if h.pattern == Pattern::None {
out.el(1, "polygon", &poly_node(&attr, &fill, &stroke, stroke_mm));
poly_stroked(out, &attr, &pts_mm, &nse, &fill, &stroke, stroke_mm);
} else if h.pattern == Pattern::Solid {
out.el(1, "polygon", &poly_node(&attr, &hatch_color, &stroke, stroke_mm));
poly_stroked(out, &attr, &pts_mm, &nse, &hatch_color, &stroke, stroke_mm);
} else {
if fill != "none" {
out.el(1, "polygon", &poly_node(&attr, &fill, "none", 0.0));
@@ -455,7 +481,7 @@ fn entry(out: &mut Out, view: &View, i: usize, hatches: &[(i32, Hatch, i32)], m:
}
}
if stroke_mm > 0.0 {
out.el(1, "polygon", &poly_node(&attr, "none", &stroke, stroke_mm));
poly_outline(out, &pts_mm, &nse, &stroke, stroke_mm);
}
}
out.rec(&["g"]);
@@ -809,4 +835,52 @@ mod tests {
assert_eq!(segs.len(), 6);
assert!(segs.iter().all(|(a, b)| (b.x - a.x - 10.0).abs() < 1e-9 || (a.x - b.x - 10.0).abs() < 1e-9));
}
/// [146] Nicht gestrichene Kanten (`noStrokeEdges`) bleiben im Druck-SVG ohne Strich: Füllung ohne
/// Umriss, die übrigen Kanten als offener Linienzug.
#[test]
fn ungestrichene_kante_ohne_strich() {
use crate::model::Vec2;
use crate::plan::buf::{View, Writer};
use crate::plan::prim::Primitive;
let v = |x: f64, y: f64| Vec2 { x, y };
let mut w = Writer::new(false);
let g = w.begin_group();
w.push(&Primitive::Polygon {
pts: vec![v(0.0, 0.0), v(1.0, 0.0), v(1.0, 1.0), v(0.0, 1.0)],
fill: "#fff".into(),
stroke: "#123456".into(),
stroke_width_mm: 0.5,
hatch: crate::plan::style::no_hatch(),
greyed: None,
opacity: None,
no_stroke_edges: Some(vec![3.0]),
wall_id: None,
drawing_id: None,
ceiling_id: None,
opening_id: None,
stair_id: None,
room_id: None,
extruded_solid_id: None,
context_object_id: None,
column_id: None,
roof_id: None,
section_line_id: None,
});
w.end_group(g);
let bytes = w.finish();
let view = View::parse(&bytes).unwrap();
let n = view.len();
let mut parts = vec![Part::new(view, 0, n).unwrap()];
let o = PrintOptions { scale_denominator: 1000.0, page_w: 10.0, page_h: 10.0, bounds: [0.0, 0.0, 1.0, 1.0] };
let ops = print_svg_ops(&mut parts, &o).unwrap();
let recs: Vec<&str> = ops.split('\x1e').collect();
let poly = recs.iter().find(|r| r.contains("\x1fpolygon")).expect("Füllung");
assert!(!poly.contains("#123456"), "Füllung ohne Strich: {poly:?}");
let line = recs.iter().find(|r| r.contains("\x1fpolyline")).expect("Kantenzug");
assert!(line.contains("#123456"), "{line:?}");
// Drei sichtbare Kanten = vier Punkte; die vierte Kante (0,1)→(0,0) fehlt.
let pts = line.split('\x1f').skip_while(|x| *x != "points").nth(1).unwrap();
assert_eq!(pts.split(' ').count(), 4, "{pts}");
}
}
+12
View File
@@ -102,6 +102,18 @@ pub fn grip_opening_slide_sheet(sx: f64, sy: f64, ex: f64, ey: f64, bulge: f64,
gd::opening_slide_sheet((sx, sy), (ex, ey), bulge, (ux, uy), position, width, du).map(|(p, d)| vec![p, d]).unwrap_or_default()
}
/// Punkt im Umriss halten (`opening_slide::clamp_inside`, Dach-/Deckenöffnung): `[x, y]`; Ring als
/// flacher Puffer, kaputte Eingabe (NaN, weniger als 3 Ecken) = Punkt unverändert.
#[wasm_bindgen]
pub fn grip_clamp_inside(x: f64, y: f64, ring: &[f64]) -> Vec<f64> {
let r = pts(ring);
if !x.is_finite() || !y.is_finite() || r.len() < 3 || r.iter().any(|p| !p.0.is_finite() || !p.1.is_finite()) {
return vec![x, y];
}
let q = crate::opening_slide::clamp_inside((x, y), &r);
vec![q.0, q.1]
}
/// Bewegpunkt einer Treppe (Zentrum NaN = keines): `[x, y]`.
#[wasm_bindgen]
#[allow(clippy::too_many_arguments)]
+1 -1
View File
@@ -74,7 +74,7 @@ export { drawingVertices, gripPt, openEdges, polylineEdgeGrips, ringEdges } from
export { verticalExtents } from "../geometry/grips";
export type { VerticalExtent } from "../geometry/grips";
export type { GripRequest } from "../geometry/grips";
export { coincidentGripPoints, excavationGripPoints, gripAxisLock, gripEdgeTarget, gripPolar, gripPolarPoint, openingGripPoint, openingSheetSlide, openingTypedPosition, sheetHeightDrag, stairMoveHandle, stairParamPoints, wallGripPoints } from "../geometry/gripDrag";
export { clampInside, coincidentGripPoints, excavationGripPoints, gripAxisLock, gripEdgeTarget, gripPolar, gripPolarPoint, openingGripPoint, openingSheetSlide, openingTypedPosition, sheetHeightDrag, stairMoveHandle, stairParamPoints, wallGripPoints } from "../geometry/gripDrag";
export type { EdgeDrive, GripLocks, SheetHeightKind } from "../geometry/gripDrag";
export { openingPreviewProject, openingPreviewSvgs } from "../plan/openingPreview";
export type { OpeningPreviewSvgs } from "../plan/openingPreview";
+10
View File
@@ -130,6 +130,16 @@ export function openingSheetSlide(
return f.length ? { position: f[0], du: f[1] } : null;
}
/**
* Punkt im Umriss lassen (Dach-/Deckenöffnung): ausserhalb → nächster Randpunkt, 5 cm nach innen gerückt.
* Gerechnet im Kern (`opening_slide::clamp_inside`), derselbe Wert wie beim Verschieben-Befehl.
*/
export function clampInside(pt: Vec2, ring: readonly Vec2[]): Vec2 {
const flat = new Float64Array(ring.length * 2);
ring.forEach((q, i) => { flat[2 * i] = q.x; flat[2 * i + 1] = q.y; });
return v(core().grip_clamp_inside(pt.x, pt.y, flat));
}
/** Bewegpunkt einer Treppe (Mitte des ersten Laufs, Wendeltreppe im Zentrum). */
export function stairMoveHandle(st: Stair): Vec2 {
const c = st.center;
+6 -2
View File
@@ -1,6 +1,7 @@
// [103] Dachfenster bleiben beim Ziehen auf der Dachfläche (`clampInside`).
// [103]/[145] Dachfenster bleiben beim Ziehen auf der Dachfläche; `clampInside` rechnet der Kern
// (`opening_slide::clamp_inside`), dieselbe Klemmung wie beim Verschieben-Befehl.
import { describe, expect, it } from "vitest";
import { clampInside } from "./surfaceOpening";
import { clampInside } from "../core";
const sq = [{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 3 }, { x: 0, y: 3 }];
@@ -14,4 +15,7 @@ describe("clampInside", () => {
expect(q.x).toBeGreaterThan(3.9);
expect(q.y).toBeCloseTo(1.5, 1);
});
it("zu wenige Ecken: unverändert", () => {
expect(clampInside({ x: 9, y: 9 }, sq.slice(0, 2))).toEqual({ x: 9, y: 9 });
});
});
+1 -24
View File
@@ -4,6 +4,7 @@
import type { Project } from "../model/types";
import { documentFor } from "../core/document";
import { clampInside } from "../geometry/gripDrag";
type V3 = [number, number, number];
type P = { x: number; y: number };
@@ -63,27 +64,3 @@ export function surfaceOpeningGripPatch(
const r = Math.round(v * 1000) / 1000;
return index === 1 ? { width: r } : { height: r };
}
/** Punkt im Umriss lassen: ausserhalb → nächster Randpunkt, 5 cm nach innen gerückt (zum Schwerpunkt der Ecken). */
export function clampInside(pt: P, ring: readonly P[]): P {
let inside = false;
for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
const a = ring[i], b = ring[j];
if (a.y > pt.y !== b.y > pt.y && pt.x < ((b.x - a.x) * (pt.y - a.y)) / (b.y - a.y) + a.x) inside = !inside;
}
if (inside) return { x: pt.x, y: pt.y };
let best = { x: ring[0].x, y: ring[0].y };
let bestD = Infinity;
for (let i = 0; i < ring.length; i++) {
const a = ring[i], b = ring[(i + 1) % ring.length];
const dx = b.x - a.x, dy = b.y - a.y;
const l2 = dx * dx + dy * dy;
const t = l2 > 0 ? Math.max(0, Math.min(1, ((pt.x - a.x) * dx + (pt.y - a.y) * dy) / l2)) : 0;
const q = { x: a.x + dx * t, y: a.y + dy * t };
const dd = (q.x - pt.x) ** 2 + (q.y - pt.y) ** 2;
if (dd < bestD) { bestD = dd; best = q; }
}
const cx = ring.reduce((s, q) => s + q.x, 0) / ring.length, cy = ring.reduce((s, q) => s + q.y, 0) / ring.length;
const l = Math.hypot(cx - best.x, cy - best.y);
return l > 0.05 ? { x: best.x + ((cx - best.x) / l) * 0.05, y: best.y + ((cy - best.y) / l) * 0.05 } : best;
}