Files
DOSSIER/doc/wip/190-bogenwaende-wip.patch
T

552 lines
30 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
diff --git a/src-tauri/core/src/cmd_wall_edit.rs b/src-tauri/core/src/cmd_wall_edit.rs
index e01158e..ee65ae7 100644
--- a/src-tauri/core/src/cmd_wall_edit.rs
+++ b/src-tauri/core/src/cmd_wall_edit.rs
@@ -1039,58 +1039,113 @@ fn spot(ax: &Axis, x: P, tol: f64) -> Option<Spot> {
}
}
+/// Tangentiale Berührung (Gerade/Kreis, Kreis/Kreis) gilt bis zu diesem Abstand als Treffer (Meter).
+const TANGENT_TOL: f64 = 1e-6;
+
+/// Achsschnittpunkte zweier Wände für das Verbinden ([190]): Gerade × Gerade (nicht fast parallel),
+/// Gerade × Kreis, Kreis × Kreis; tangentiale Berührung ergibt den Berührpunkt (auch knapp daneben,
+/// [`TANGENT_TOL`]). Bögen auf demselben Kreis treffen sich nicht (das ist Verketten).
+fn connect_hits(a: &Axis, b: &Axis) -> Vec<P> {
+ let tangent_line = |c: P, r: f64, l: &Axis| -> Option<P> {
+ let t = (c.x - l.a.x) * l.u.x + (c.y - l.a.y) * l.u.y;
+ let f = P::new(l.a.x + l.u.x * t, l.a.y + l.u.y * t);
+ ((dist(f, c) - r).abs() <= TANGENT_TOL).then_some(f)
+ };
+ let pts = match (&a.arc, &b.arc) {
+ (None, None) => {
+ if cross(a.u, b.u).abs() < 0.02 {
+ return vec![];
+ }
+ kernel2d::line_intersect(a.a, a.u, b.a, b.u).into_iter().collect()
+ }
+ (None, Some(w)) | (Some(w), None) => {
+ let l = if a.arc.is_none() { a } else { b };
+ match tangent_line(w.center, w.r, l) {
+ Some(f) => vec![f],
+ None => circle_line(w.center, w.r, &Line { point: l.a, dir: l.u }),
+ }
+ }
+ (Some(v), Some(w)) => {
+ let d = dist(v.center, w.center);
+ if d < EPS_GEO && (v.r - w.r).abs() < EPS_GEO {
+ return vec![];
+ }
+ let touch = d > 1e-12 && ((d - (v.r + w.r)).abs() <= TANGENT_TOL || (d - (v.r - w.r).abs()).abs() <= TANGENT_TOL);
+ if touch {
+ // Berührpunkt auf der Mittellinie, auf dem ersten Kreis, nächst am zweiten.
+ let u = P::new((w.center.x - v.center.x) / d, (w.center.y - v.center.y) / d);
+ let c = [1.0, -1.0].map(|s| P::new(v.center.x + u.x * v.r * s, v.center.y + u.y * v.r * s));
+ let best = if (dist(c[0], w.center) - w.r).abs() <= (dist(c[1], w.center) - w.r).abs() { c[0] } else { c[1] };
+ vec![best]
+ } else {
+ circle_circle(v.center, v.r, w.center, w.r)
+ }
+ }
+ };
+ pts.into_iter().filter(|p| fin(*p)).collect()
+}
+
/// T-Stoss ([190]): Punkt, an dem die Achse des Abzweigs (`ab`, Ende `at_end`) auf die dem Abzweig
-/// zugewandte Fläche der Durchgangswand `wt` trifft. Dort endet der Abzweig; `joins.rs`
-/// (`apply_mid_span_tee`) schneidet ihn an dieser Fläche, es bleibt kein Überstand im Durchgang.
-fn tee_face_point(pr: &Project, ab: &Axis, at_end: bool, wt: &Wall, at: &Axis) -> Option<P> {
+/// zugewandte Fläche der Durchgangswand `wt` trifft (nächst dem Achsschnittpunkt `x`; Geraden und
+/// Bögen). Dort endet der Abzweig; `joins.rs` (`apply_mid_span_tee`) schneidet ihn an dieser Fläche, es
+/// bleibt kein Überstand im Durchgang.
+fn tee_face_point(pr: &Project, ab: &Axis, at_end: bool, wt: &Wall, at: &Axis, x: P) -> Option<P> {
let far = if at_end { ab.a } else { ab.b };
let (lo, hi) = faces(pr, wt);
let face = if at.local(far).1 >= 0.0 { hi } else { lo };
- kernel2d::line_intersect(ab.a, ab.u, at.point(0.0, face), at.u).filter(|x| fin(*x))
+ let hits = carrier_cross(&carrier(ab, 0.0)?, &carrier(at, face)?);
+ hits.into_iter().filter(|p| fin(*p)).min_by(|p, q| dist(*p, x).total_cmp(&dist(*q, x)))
+}
+
+/// Bestes Verbinden eines Wandpaars: (Kosten, Bewegungen) über alle Achsschnittpunkte.
+fn connect_pair(pr: &Project, sel: &[(&Wall, Axis)], i: usize, j: usize) -> Option<(f64, Vec<Move>)> {
+ let ((wi, ai), (wj, aj)) = (&sel[i], &sel[j]);
+ let thick = |w: &Wall| {
+ let (lo, hi) = faces(pr, w);
+ (hi - lo).abs()
+ };
+ let tol = 0.5_f64.max(2.0 * thick(wi).max(thick(wj)));
+ let mut best: Option<(f64, Vec<Move>)> = None;
+ for x in connect_hits(ai, aj) {
+ let cand = match (spot(ai, x, tol), spot(aj, x, tol)) {
+ (Some(Spot::End(da, ea)), Some(Spot::End(db, eb))) => (da + db, vec![Move { i, at_end: ea, x }, Move { i: j, at_end: eb, x }]),
+ (Some(Spot::End(da, ea)), Some(Spot::Inner)) => (da, vec![Move { i, at_end: ea, x: tee_face_point(pr, ai, ea, wj, aj, x).unwrap_or(x) }]),
+ (Some(Spot::Inner), Some(Spot::End(db, eb))) => (db, vec![Move { i: j, at_end: eb, x: tee_face_point(pr, aj, eb, wi, ai, x).unwrap_or(x) }]),
+ _ => continue,
+ };
+ if best.as_ref().map_or(true, |b| cand.0 < b.0) {
+ best = Some(cand);
+ }
+ }
+ best
}
-/// Verbinden von Ecken ([190], Archicad-Art): gewählte gerade Wände eines Geschosses, deren Achsen sich
-/// nicht sauber treffen, werden bis zum Achsschnittpunkt verlängert bzw. gekürzt. Zwei Enden nahe am
-/// Schnittpunkt ergeben eine L-Ecke (beide rücken), ein Ende nahe am Schnittpunkt, der im Innern der
-/// anderen Wand liegt, einen T-Stoss (nur das Ende rückt, an die zugewandte Fläche der Durchgangswand). Toleranz je Paar: grösser von 0.5 m und der
-/// doppelten Wanddicke. Jedes Ende rückt höchstens einmal (nahe Paare zuerst). Die Gehrung bzw. der
-/// Anschluss folgt aus den Enden (`joins.rs`); Öffnungen und Bemassung führt [`commit`] nach (wie
-/// Trim/Extend — Öffnungen bleiben im Plan stehen). Wände in `skip` (schon kollinear verkettet) und
-/// Bogenwände bleiben aussen vor. Parallele Wände (auch versetzte) werden nicht angefasst.
+/// Verbinden von Ecken ([190], Archicad-Art): gewählte Wände eines Geschosses (gerade und Bogenwände),
+/// deren Achsen sich nicht sauber treffen, werden bis zum Achsschnittpunkt verlängert bzw. gekürzt. Zwei
+/// Enden nahe am Schnittpunkt ergeben eine L-Ecke (beide rücken), ein Ende nahe am Schnittpunkt, der im
+/// Innern der anderen Wand liegt, einen T-Stoss (nur das Ende rückt, an die zugewandte Fläche der
+/// Durchgangswand). Bei Bögen ist der Schnittpunkt ein Kreis–Gerade- bzw. Kreis–Kreis-Schnitt (die Lösung
+/// nächst den Enden; tangentiale Berührung zählt); Bogenwände behalten Mittelpunkt und Radius, nur ihr
+/// Winkelbereich ändert sich ([`Axis::piece`]). Toleranz je Paar: grösser von 0.5 m und der doppelten
+/// Wanddicke, gemessen entlang der Achse (Bogenlänge). Jedes Ende rückt höchstens einmal (nahe Paare
+/// zuerst). Die Gehrung bzw. der Anschluss folgt aus den Enden (`joins.rs`, Bögen mit Versatzkreisen);
+/// Öffnungen und Bemassung führt [`commit`] nach (wie Trim/Extend — Öffnungen bleiben im Plan stehen).
+/// Wände in `skip` (schon kollinear verkettet) bleiben aussen vor. Parallele gerade Wände (auch
+/// versetzte) werden nicht angefasst.
pub fn connect_ops(root: &Map<String, Value>, pr: &Project, ids_sel: &[String], skip: &[String]) -> Vec<Op> {
let sel: Vec<(&Wall, Axis)> = walls(pr)
.iter()
.filter(|w| editable(w) && ids_sel.contains(&w.id) && !skip.contains(&w.id))
- .filter_map(|w| Axis::of(w).filter(|a| a.arc.is_none()).map(|a| (w, a)))
+ .filter_map(|w| Axis::of(w).map(|a| (w, a)))
.collect();
// Kandidaten: (Kosten, Bewegungen)
let mut cands: Vec<(f64, Vec<Move>)> = Vec::new();
for i in 0..sel.len() {
for j in i + 1..sel.len() {
- let ((wi, ai), (wj, aj)) = (&sel[i], &sel[j]);
- if wi.floor_id != wj.floor_id {
- continue;
- }
- let den = cross(ai.u, aj.u);
- if den.abs() < 0.02 {
- continue;
- }
- let t = cross(P::new(aj.a.x - ai.a.x, aj.a.y - ai.a.y), aj.u) / den;
- let x = P::new(ai.a.x + ai.u.x * t, ai.a.y + ai.u.y * t);
- if !fin(x) {
+ if sel[i].0.floor_id != sel[j].0.floor_id {
continue;
}
- let thick = |w: &Wall| {
- let (lo, hi) = faces(pr, w);
- (hi - lo).abs()
- };
- let tol = 0.5_f64.max(2.0 * thick(wi).max(thick(wj)));
- match (spot(ai, x, tol), spot(aj, x, tol)) {
- (Some(Spot::End(da, ea)), Some(Spot::End(db, eb))) => cands.push((da + db, vec![Move { i, at_end: ea, x }, Move { i: j, at_end: eb, x }])),
- (Some(Spot::End(da, ea)), Some(Spot::Inner)) => cands.push((da, vec![Move { i, at_end: ea, x: tee_face_point(pr, ai, ea, wj, aj).unwrap_or(x) }])),
- (Some(Spot::Inner), Some(Spot::End(db, eb))) => cands.push((db, vec![Move { i: j, at_end: eb, x: tee_face_point(pr, aj, eb, wi, ai).unwrap_or(x) }])),
- _ => {}
- }
+ cands.extend(connect_pair(pr, &sel, i, j));
}
}
cands.sort_by(|a, b| a.0.total_cmp(&b.0));
@@ -1100,7 +1155,7 @@ pub fn connect_ops(root: &Map<String, Value>, pr: &Project, ids_sel: &[String],
if moves.iter().any(|m| used.contains(&(m.i, m.at_end))) {
continue;
}
- // Keine Wand darf dabei (fast) verschwinden.
+ // Keine Wand darf dabei (fast) verschwinden, kein Bogen zum Vollkreis werden.
let next: Vec<(usize, (f64, f64))> = moves
.iter()
.map(|m| {
@@ -1108,7 +1163,7 @@ pub fn connect_ops(root: &Map<String, Value>, pr: &Project, ids_sel: &[String],
(m.i, if m.at_end { (span[m.i].0, s) } else { (s, span[m.i].1) })
})
.collect();
- if next.iter().any(|(_, (a, b))| !(b - a >= 0.05)) {
+ if next.iter().any(|(i, (a, b))| !(b - a >= 0.05) || sel[*i].1.piece(*a, *b).is_none()) {
continue;
}
for (m, (i, sp)) in moves.iter().zip(next) {
@@ -1136,35 +1191,30 @@ pub fn join_hint(pr: &Project, ids_sel: &[String]) -> Option<String> {
if sel.len() < 2 {
return None;
}
- let free: Vec<&Wall> = sel.iter().copied().filter(|w| editable(w)).collect();
+ let free: Vec<(&Wall, Axis)> = sel.iter().copied().filter(|w| editable(w)).filter_map(|w| Axis::of(w).map(|a| (w, a))).collect();
if free.len() < 2 {
return Some("cmd.join.locked".into());
}
- let straight: Vec<(&Wall, Axis)> = free.iter().filter_map(|w| Axis::of(w).filter(|a| a.arc.is_none()).map(|a| (*w, a))).collect();
- if straight.len() < 2 {
- return Some("cmd.join.arc".into());
- }
- let (mut same_floor, mut parallel, mut met, mut crossing) = (false, false, false, false);
+ let (mut same_floor, mut parallel, mut met, mut crossing, mut arc_apart) = (false, false, false, false, false);
let mut far: Option<(f64, f64)> = None;
- for i in 0..straight.len() {
- for j in i + 1..straight.len() {
- let ((wi, ai), (wj, aj)) = (&straight[i], &straight[j]);
+ for i in 0..free.len() {
+ for j in i + 1..free.len() {
+ let ((wi, ai), (wj, aj)) = (&free[i], &free[j]);
if wi.floor_id != wj.floor_id {
continue;
}
same_floor = true;
- let den = cross(ai.u, aj.u);
- if den.abs() < 0.02 {
- parallel = true;
- continue;
- }
- let t = cross(P::new(aj.a.x - ai.a.x, aj.a.y - ai.a.y), aj.u) / den;
- let x = P::new(ai.a.x + ai.u.x * t, ai.a.y + ai.u.y * t);
- if !fin(x) {
+ let hits = connect_hits(ai, aj);
+ if hits.is_empty() {
+ if ai.arc.is_none() && aj.arc.is_none() {
+ parallel = true;
+ } else {
+ arc_apart = true;
+ }
continue;
}
// Abstand des Schnittpunkts zur Wand: 0 im Innern, sonst zum nächsten Ende.
- let gap = |a: &Axis| {
+ let gap = |a: &Axis, x: P| {
let s = a.local(x).0;
if s > 0.0 && s < a.len {
(0.0, true)
@@ -1172,12 +1222,14 @@ pub fn join_hint(pr: &Project, ids_sel: &[String]) -> Option<String> {
(s.abs().min((s - a.len).abs()), false)
}
};
- let ((gi, ini), (gj, inj)) = (gap(ai), gap(aj));
let thick = |w: &Wall| {
let (lo, hi) = faces(pr, w);
(hi - lo).abs()
};
let tol = 0.5_f64.max(2.0 * thick(wi).max(thick(wj)));
+ // Der Schnittpunkt nächst an beiden Wänden zählt (Bögen: bis zu zwei Lösungen).
+ let worst = |g: &((f64, bool), (f64, bool))| g.0 .0.max(g.1 .0);
+ let Some(((gi, ini), (gj, inj))) = hits.iter().map(|x| (gap(ai, *x), gap(aj, *x))).min_by(|p, q| worst(p).total_cmp(&worst(q))) else { continue };
if ini && inj {
crossing = true;
} else if gi.max(gj) < 1e-6 {
@@ -1202,6 +1254,9 @@ pub fn join_hint(pr: &Project, ids_sel: &[String]) -> Option<String> {
if crossing {
return Some("cmd.join.cross".into());
}
+ if arc_apart {
+ return Some("cmd.join.arc".into());
+ }
parallel.then(|| "cmd.join.parallel".into())
}
@@ -1712,10 +1767,188 @@ mod tests {
assert_eq!(hint(vec![wall("a", (0.0, 0.0), (6.0, 0.0), None), wall("b", (6.0, 0.0), (6.0, 4.0), None)]).as_deref(), Some("cmd.join.met"));
// Kreuzung.
assert_eq!(hint(vec![wall("a", (0.0, 0.0), (6.0, 0.0), None), wall("b", (3.0, -2.0), (3.0, 2.0), None)]).as_deref(), Some("cmd.join.cross"));
- // Bogenwand.
- assert_eq!(hint(vec![wall("a", (0.0, 0.0), (6.0, 0.0), Some(0.5)), wall("b", (6.0, 0.0), (6.0, 4.0), None)]).as_deref(), Some("cmd.join.arc"));
+ // Bogenwand, die sich schon trifft; Bogen, der die Gerade auch verlängert nicht trifft.
+ assert_eq!(hint(vec![wall("a", (0.0, 0.0), (6.0, 0.0), Some(0.5)), wall("b", (6.0, 0.0), (6.0, 4.0), None)]).as_deref(), Some("cmd.join.met"));
+ assert_eq!(hint(vec![wall("a", (0.0, 0.0), (6.0, 0.0), Some(0.2)), wall("b", (0.0, 9.0), (6.0, 9.0), None)]).as_deref(), Some("cmd.join.arc"));
// Eine Wand allein: kein besonderer Grund.
let r = project(vec![wall("a", (0.0, 0.0), (6.0, 0.0), None)], vec![], vec![]);
assert_eq!(join_hint(&typed(&r), &["a".to_string()]), None);
}
+
+ // ── [190] Bogenwände verbinden ──────────────────────────────────────────
+
+ /// Bogenwand auf dem Kreis (Mitte `c`, Radius `r`) von Winkel `a0` nach `a1` (Grad; `a1 > a0` =
+ /// Gegenuhrzeigersinn, Modell-Bulge dann negativ).
+ fn arc_wall(id: &str, c: (f64, f64), r: f64, a0: f64, a1: f64) -> Value {
+ let (p0, p1) = (a0.to_radians(), a1.to_radians());
+ let pt = |a: f64| (c.0 + r * a.cos(), c.1 + r * a.sin());
+ wall(id, pt(p0), pt(p1), Some(-((p1 - p0) / 4.0).tan()))
+ }
+ fn arc_of_wall(r: &Map<String, Value>, id: &str) -> WallArc {
+ Axis::of(find_wall(&typed(r), id).unwrap()).unwrap().arc.expect("Bogenwand")
+ }
+ /// Mittelpunkt und Radius der Bogenwand bleiben erhalten.
+ fn assert_circle(r: &Map<String, Value>, id: &str, c: (f64, f64), rad: f64) {
+ let a = arc_of_wall(r, id);
+ assert!(close((a.center.x, a.center.y), c), "{id}: Mitte {:?}", a.center);
+ assert!((a.r - rad).abs() < 1e-6, "{id}: Radius {}", a.r);
+ }
+ fn connect(r: &Map<String, Value>, sel: &[&str]) -> Map<String, Value> {
+ let ids: Vec<String> = sel.iter().map(|s| s.to_string()).collect();
+ let ops = connect_ops(r, &typed(r), &ids, &[]);
+ assert!(!ops.is_empty(), "Verbinden ohne Wirkung");
+ apply(r, ops)
+ }
+ fn at(r: &Map<String, Value>, id: &str, key: &str) -> (f64, f64) {
+ xy_of(&w_of(r, id)[key])
+ }
+ /// Wand-Joins der Wände (Dicke 0.2, Mitte) aus dem Ergebnis.
+ fn joins_of(r: &Map<String, Value>, ids: &[&str]) -> Vec<crate::joins::WallCuts> {
+ use crate::joins::{compute_joins, JoinLayer, JoinWall, Reference};
+ let jw: Vec<JoinWall> = ids
+ .iter()
+ .map(|id| {
+ let w = w_of(r, id);
+ let (s, e) = (xy_of(&w["start"]), xy_of(&w["end"]));
+ JoinWall {
+ start: P::new(s.0, s.1),
+ end: P::new(e.0, e.1),
+ reference: Reference::Center,
+ layers: Some(vec![JoinLayer { thickness: 0.2, component: Some(0), priority: 1.0 }]),
+ bulge: w["bulge"].as_f64(),
+ }
+ })
+ .collect();
+ compute_joins(&jw).unwrap()
+ }
+
+ #[test]
+ fn verbinden_bogen_gerade_ecke() {
+ // Bogen r = 5 um (0,0) von 0° bis 85° (5° = 0.44 m vor der Ecke), Gerade x = 0 ab y = 5.3.
+ let r = project(vec![arc_wall("a", (0.0, 0.0), 5.0, 0.0, 85.0), wall("b", (0.0, 5.3), (0.0, 9.0), None)], vec![], vec![]);
+ let n = connect(&r, &["a", "b"]);
+ assert!(close(at(&n, "a", "end"), (0.0, 5.0)), "{:?}", at(&n, "a", "end"));
+ assert!(close(at(&n, "b", "start"), (0.0, 5.0)));
+ assert!(close(at(&n, "a", "start"), (5.0, 0.0)));
+ assert!(close(at(&n, "b", "end"), (0.0, 9.0)));
+ assert_circle(&n, "a", (0.0, 0.0), 5.0);
+ // Gehrung: beide Enden geschnitten, die Schnittlinie verbindet die Flächen-Ecken (Kreis r ± 0.1
+ // mit x = ± 0.1) — keine Lücke, keine Überlappung.
+ let cuts = joins_of(&n, &["a", "b"]);
+ let (ca, cb) = (cuts[0].end_cut.expect("Gehrung am Bogen"), cuts[1].start_cut.expect("Gehrung an der Geraden"));
+ for c in [ca.point, kernel2d::add(ca.point, ca.dir)] {
+ assert!((c.x.abs() - 0.1).abs() < 1e-9, "{c:?}");
+ assert!(((c.x.hypot(c.y) - 5.0).abs() - 0.1).abs() < 1e-9, "{c:?}");
+ }
+ assert!(close((cb.point.x, cb.point.y), (ca.point.x, ca.point.y)));
+ // Überstand: Bogen 5° über die Ecke hinaus, Gerade beginnt 0.2 innerhalb → beide gekürzt.
+ let r = project(vec![arc_wall("a", (0.0, 0.0), 5.0, 0.0, 95.0), wall("b", (0.0, 4.8), (0.0, 9.0), None)], vec![], vec![]);
+ let n = connect(&r, &["a", "b"]);
+ assert!(close(at(&n, "a", "end"), (0.0, 5.0)));
+ assert!(close(at(&n, "b", "start"), (0.0, 5.0)));
+ assert_circle(&n, "a", (0.0, 0.0), 5.0);
+ }
+
+ #[test]
+ fn verbinden_bogen_bogen_ecke() {
+ // Kreise um (0,0) und (−5,5), beide r = 5: Schnitt (0,5) (nahe den Enden) und (−5,0) (weit weg).
+ let r = project(vec![arc_wall("a", (0.0, 0.0), 5.0, 0.0, 85.0), arc_wall("b", (-5.0, 5.0), 5.0, 5.0, 80.0)], vec![], vec![]);
+ let n = connect(&r, &["a", "b"]);
+ assert!(close(at(&n, "a", "end"), (0.0, 5.0)));
+ assert!(close(at(&n, "b", "start"), (0.0, 5.0)));
+ assert_circle(&n, "a", (0.0, 0.0), 5.0);
+ assert_circle(&n, "b", (-5.0, 5.0), 5.0);
+ let cuts = joins_of(&n, &["a", "b"]);
+ assert!(cuts[0].end_cut.is_some() && cuts[1].start_cut.is_some());
+ // Gegenrichtung des zweiten Bogens (Uhrzeigersinn, endet an der Ecke).
+ let r = project(vec![arc_wall("a", (0.0, 0.0), 5.0, 0.0, 85.0), arc_wall("b", (-5.0, 5.0), 5.0, 80.0, 5.0)], vec![], vec![]);
+ let n = connect(&r, &["a", "b"]);
+ assert!(close(at(&n, "a", "end"), (0.0, 5.0)));
+ assert!(close(at(&n, "b", "end"), (0.0, 5.0)));
+ assert_circle(&n, "b", (-5.0, 5.0), 5.0);
+ assert!(w_of(&n, "b")["bulge"].as_f64().unwrap() > 0.0, "Drehsinn bleibt");
+ }
+
+ #[test]
+ fn verbinden_gegenrichtungen_bogen_gerade() {
+ // Wie die Bogen–Gerade-Ecke, beide Wände gekehrt: der Bogen beginnt, die Gerade endet an der Ecke.
+ let r = project(vec![arc_wall("a", (0.0, 0.0), 5.0, 85.0, 0.0), wall("b", (0.0, 9.0), (0.0, 5.3), None)], vec![], vec![]);
+ let n = connect(&r, &["b", "a"]);
+ assert!(close(at(&n, "a", "start"), (0.0, 5.0)));
+ assert!(close(at(&n, "a", "end"), (5.0, 0.0)));
+ assert!(close(at(&n, "b", "end"), (0.0, 5.0)));
+ assert_circle(&n, "a", (0.0, 0.0), 5.0);
+ assert!(w_of(&n, "a")["bulge"].as_f64().unwrap() > 0.0);
+ let cuts = joins_of(&n, &["a", "b"]);
+ assert!(cuts[0].start_cut.is_some() && cuts[1].end_cut.is_some());
+ }
+
+ #[test]
+ fn verbinden_t_stoss_gerade_an_bogen() {
+ // Halbkreis r = 5 als Durchgang; radiale Gerade von innen endet 0.4 vor der Achse → an der
+ // Innenfläche r = 4.9; der Bogen bleibt unverändert.
+ let r = project(vec![arc_wall("a", (0.0, 0.0), 5.0, 0.0, 180.0), wall("b", (0.0, 1.0), (0.0, 4.6), None)], vec![], vec![]);
+ let n = connect(&r, &["a", "b"]);
+ assert!(close(at(&n, "b", "end"), (0.0, 4.9)), "{:?}", at(&n, "b", "end"));
+ assert!(close(at(&n, "a", "start"), (5.0, 0.0)) && close(at(&n, "a", "end"), (-5.0, 0.0)));
+ let cuts = joins_of(&n, &["a", "b"]);
+ assert!(cuts[1].end_cut.is_some(), "T-Anschluss am Bogen");
+ assert!(cuts[0].start_cut.is_none() && cuts[0].end_cut.is_none());
+ // Von aussen, mit Überstand durch den Bogen: an der Aussenfläche r = 5.1.
+ let r = project(vec![arc_wall("a", (0.0, 0.0), 5.0, 0.0, 180.0), wall("b", (0.0, 8.0), (0.0, 4.95), None)], vec![], vec![]);
+ let n = connect(&r, &["a", "b"]);
+ assert!(close(at(&n, "b", "end"), (0.0, 5.1)), "{:?}", at(&n, "b", "end"));
+ }
+
+ #[test]
+ fn verbinden_t_stoss_bogen_an_gerade() {
+ // Gerade Durchgangswand x = 0 (y 2…10); der Bogen (r = 5 um (0,0), 0°…85°) endet an ihrer
+ // zugewandten Fläche x = 0.1, auf seinem Kreis.
+ let r = project(vec![wall("a", (0.0, 2.0), (0.0, 10.0), None), arc_wall("b", (0.0, 0.0), 5.0, 0.0, 85.0)], vec![], vec![]);
+ let n = connect(&r, &["a", "b"]);
+ let e = at(&n, "b", "end");
+ assert!(close(e, (0.1, (25.0_f64 - 0.01).sqrt())), "{e:?}");
+ assert_circle(&n, "b", (0.0, 0.0), 5.0);
+ assert!(close(at(&n, "a", "start"), (0.0, 2.0)) && close(at(&n, "a", "end"), (0.0, 10.0)));
+ let cuts = joins_of(&n, &["a", "b"]);
+ let c = cuts[1].end_cut.expect("T-Anschluss des Bogens");
+ assert!((c.point.x - 0.1).abs() < 1e-9 && c.dir.x.abs() < 1e-9, "Schnitt an der Fläche: {c:?}");
+ assert!(cuts[0].start_cut.is_none() && cuts[0].end_cut.is_none());
+ }
+
+ #[test]
+ fn verbinden_flacher_bogen_wie_gerade() {
+ // Bulge 1e-4 (Pfeilhöhe 0.3 mm auf 5.7 m): verhält sich wie die gerade L-Ecke, bleibt aber Bogen.
+ let r = project(vec![wall("a", (0.0, 0.0), (5.7, 0.0), Some(1e-4)), wall("b", (6.0, 0.3), (6.0, 4.4), None)], vec![], vec![]);
+ let before = arc_of_wall(&r, "a");
+ let n = connect(&r, &["a", "b"]);
+ let (ea, sb) = (at(&n, "a", "end"), at(&n, "b", "start"));
+ assert!((ea.0 - 6.0).abs() < 1e-6 && ea.1.abs() < 1e-3, "{ea:?}");
+ assert!(close(ea, sb));
+ assert!(close(at(&n, "a", "start"), (0.0, 0.0)));
+ let after = arc_of_wall(&n, "a");
+ assert!((after.r - before.r).abs() < 1e-6 * before.r, "Radius {} → {}", before.r, after.r);
+ assert!(close((after.center.x, after.center.y), (before.center.x, before.center.y)) || (after.center.x - before.center.x).hypot(after.center.y - before.center.y) < 1e-6 * before.r);
+ assert!(w_of(&n, "a")["bulge"].as_f64().unwrap() > 0.0);
+ }
+
+ #[test]
+ fn verbinden_tangentialstoss() {
+ // Gerade y = 5 berührt den Kreis r = 5 in (0,5); Bogen endet 5° davor, Gerade beginnt 0.3 daneben.
+ let r = project(vec![arc_wall("a", (0.0, 0.0), 5.0, 0.0, 85.0), wall("b", (-0.3, 5.0), (-4.0, 5.0), None)], vec![], vec![]);
+ let n = connect(&r, &["a", "b"]);
+ assert!(close(at(&n, "a", "end"), (0.0, 5.0)), "{:?}", at(&n, "a", "end"));
+ assert!(close(at(&n, "b", "start"), (0.0, 5.0)));
+ assert_circle(&n, "a", (0.0, 0.0), 5.0);
+ // Radiale Stossfuge (tangentialer Übergang).
+ let cuts = joins_of(&n, &["a", "b"]);
+ let c = cuts[0].end_cut.expect("Stoss am Bogenende");
+ assert!(c.dir.x.abs() < 1e-6, "radial: {c:?}");
+ // Kreis–Kreis tangential (S-Kurve): Kreise um (0,0) und (0,10) berühren sich in (0,5).
+ let r = project(vec![arc_wall("a", (0.0, 0.0), 5.0, 0.0, 85.0), arc_wall("b", (0.0, 10.0), 5.0, 265.0, 200.0)], vec![], vec![]);
+ let n = connect(&r, &["a", "b"]);
+ assert!(close(at(&n, "a", "end"), (0.0, 5.0)));
+ assert!(close(at(&n, "b", "start"), (0.0, 5.0)), "{:?}", at(&n, "b", "start"));
+ assert_circle(&n, "b", (0.0, 10.0), 5.0);
+ }
}
diff --git a/src/commands/cmds/join.arcWalls.test.ts b/src/commands/cmds/join.arcWalls.test.ts
new file mode 100644
index 0000000..b891ac2
--- /dev/null
+++ b/src/commands/cmds/join.arcWalls.test.ts
@@ -0,0 +1,82 @@
+/**
+ * [190] Verbinden (Cmd/Ctrl+J, Befehl „join") mit Bogenwänden: Kern `cmd_wall_edit.rs::connect_ops`.
+ * Enden rücken auf den Kreis–Gerade- bzw. Kreis–Kreis-Schnitt, die Bogenwand behält Mittelpunkt und Radius.
+ */
+import { describe, it, expect } from "vitest";
+import type { Project, Wall } from "../../model/types";
+import { documentFor } from "../../core/document";
+import { applyOps } from "../../core/ops";
+import { sampleProject } from "../../model/sampleProject";
+
+/** Bogenwand auf dem Kreis (Mitte c, Radius r) von a0 nach a1 (Grad, a1 > a0 = Gegenuhrzeigersinn). */
+function arcWall(id: string, c: { x: number; y: number }, r: number, a0: number, a1: number): Wall {
+ const rad = (d: number) => (d * Math.PI) / 180;
+ const pt = (a: number) => ({ x: c.x + r * Math.cos(rad(a)), y: c.y + r * Math.sin(rad(a)) });
+ return { ...line(id, pt(a0), pt(a1)), bulge: -Math.tan(rad(a1 - a0) / 4) };
+}
+
+function line(id: string, a: { x: number; y: number }, b: { x: number; y: number }): Wall {
+ return { id, type: "wall", floorId: "eg", categoryCode: "20", start: a, end: b, wallTypeId: "aw", height: 2.6 };
+}
+
+function join(walls: Wall[]): Wall[] {
+ const p = { ...sampleProject, walls, openings: [], rooms: [], drawings2d: [] } as Project;
+ const ops = documentFor(p).cmdOps({ cmd: "join", ids: walls.map((w) => w.id), stamp: "t" });
+ return applyOps(p, ops).walls;
+}
+
+/** Mittelpunkt und Radius aus Sehne und Modell-Bulge (positiv = Scheitel links der Sehne). */
+function circleOf(w: Wall): { x: number; y: number; r: number } {
+ const b = w.bulge ?? 0;
+ const dx = w.end.x - w.start.x;
+ const dy = w.end.y - w.start.y;
+ const c = Math.hypot(dx, dy);
+ const r = (c * (1 + b * b)) / (4 * Math.abs(b));
+ const sagitta = (Math.abs(b) * c) / 2;
+ // Scheitel auf der Seite sign(b) der linken Normalen; Mitte um (Pfeilhöhe − r) von der Sehnenmitte.
+ const k = Math.sign(b) * (sagitta - r);
+ return { x: (w.start.x + w.end.x) / 2 + (-dy / c) * k, y: (w.start.y + w.end.y) / 2 + (dx / c) * k, r };
+}
+
+describe("[190] Cmd+J verbindet Bogenwände", () => {
+ it("Bogen–Gerade-Ecke: beide Enden auf dem Achsschnittpunkt, Kreis bleibt", () => {
+ const walls = join([arcWall("a", { x: 0, y: 0 }, 5, 0, 85), line("b", { x: 0, y: 5.3 }, { x: 0, y: 9 })]);
+ const a = walls.find((w) => w.id === "a")!;
+ const b = walls.find((w) => w.id === "b")!;
+ expect(a.end.x).toBeCloseTo(0, 6);
+ expect(a.end.y).toBeCloseTo(5, 6);
+ expect(b.start.x).toBeCloseTo(0, 6);
+ expect(b.start.y).toBeCloseTo(5, 6);
+ expect(a.bulge).toBeLessThan(0);
+ const c = circleOf(a);
+ expect(c.r).toBeCloseTo(5, 6);
+ expect(Math.hypot(c.x, c.y)).toBeCloseTo(0, 6);
+ });
+
+ it("Bogen–Bogen-Ecke: Kreis–Kreis-Schnitt nahe den Enden", () => {
+ const walls = join([arcWall("a", { x: 0, y: 0 }, 5, 0, 85), arcWall("b", { x: -5, y: 5 }, 5, 5, 80)]);
+ const a = walls.find((w) => w.id === "a")!;
+ const b = walls.find((w) => w.id === "b")!;
+ expect(a.end.x).toBeCloseTo(0, 6);
+ expect(a.end.y).toBeCloseTo(5, 6);
+ expect(b.start.x).toBeCloseTo(0, 6);
+ expect(b.start.y).toBeCloseTo(5, 6);
+ const cb = circleOf(b);
+ expect(cb.r).toBeCloseTo(5, 6);
+ expect(cb.x).toBeCloseTo(-5, 6);
+ expect(cb.y).toBeCloseTo(5, 6);
+ });
+
+ it("Gerade an Bogen (T-Stoss): die Gerade endet an der zugewandten Bogenfläche, der Bogen bleibt", () => {
+ const arc = arcWall("a", { x: 0, y: 0 }, 5, 0, 180);
+ const walls = join([arc, line("b", { x: 0, y: 1 }, { x: 0, y: 4.6 })]);
+ const a = walls.find((w) => w.id === "a")!;
+ const b = walls.find((w) => w.id === "b")!;
+ // Wandtyp „aw" des Beispielprojekts, Referenz Mitte: Innenfläche bei r = 5 − Dicke/2.
+ expect(b.end.x).toBeCloseTo(0, 6);
+ expect(b.end.y).toBeGreaterThan(4.6);
+ expect(b.end.y).toBeLessThan(5);
+ expect(a.start).toEqual(arc.start);
+ expect(a.end).toEqual(arc.end);
+ });
+});
diff --git a/src/i18n/de.ts b/src/i18n/de.ts
index e1fedd0..995b907 100644
--- a/src/i18n/de.ts
+++ b/src/i18n/de.ts
@@ -2510,7 +2510,7 @@ export const de = {
"cmd.join.met": "Nichts zu verbinden: die Wände treffen sich bereits.",
"cmd.join.cross": "Nichts zu verbinden: die Wände kreuzen sich.",
"cmd.join.parallel": "Nichts zu verbinden: die Wände sind parallel.",
- "cmd.join.arc": "Nichts zu verbinden: Bogenwände werden nicht an Ecken verbunden.",
+ "cmd.join.arc": "Nichts zu verbinden: Bogen und Wand treffen sich auch verlängert nicht.",
"cmd.join.locked": "Nichts zu verbinden: die Wände sind gesperrt.",
"cmd.join.floors": "Nichts zu verbinden: die Wände liegen auf verschiedenen Geschossen.",
"edit.cutSegment.label": "Segment löschen",
diff --git a/src/i18n/en.ts b/src/i18n/en.ts
index 80d6204..3ad8724 100644
--- a/src/i18n/en.ts
+++ b/src/i18n/en.ts
@@ -2498,7 +2498,7 @@ export const en: Record<TranslationKey, string> = {
"cmd.join.met": "Nothing to join: the walls already meet.",
"cmd.join.cross": "Nothing to join: the walls cross each other.",
"cmd.join.parallel": "Nothing to join: the walls are parallel.",
- "cmd.join.arc": "Nothing to join: curved walls are not joined at corners.",
+ "cmd.join.arc": "Nothing to join: the curved wall and the other wall do not meet, even when extended.",
"cmd.join.locked": "Nothing to join: the walls are locked.",
"cmd.join.floors": "Nothing to join: the walls are on different floors.",
"edit.cutSegment.label": "Delete segment",