[108] Merge: schräge Wandanschlüsse (T/L/X) sauber im Grundriss und 3D, SVG-Export ohne ausgeblendete Fugen

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-30 02:28:28 +00:00
commit 9813d19e00
19 files changed
+964 -83

No files matched your search

+14
View File
@@ -1595,6 +1595,20 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]).
CLI-Grundriss/-Schnitt einer Aussenwand Putz/Dämmung/Backstein/Putz mit vier Varianten angesehen. Offen: Schnitt quer
durch eine Leibung (Ebene parallel zur Wand) ohne Rücksprung; Mengen (Leibungsflächen je Schicht) nicht in der Fenster-
liste; keine Rundbogen-/Dachfenster-Leibungen; nicht in der Tauri-App geprüft.
- ◐ **[108] Schräge Wandanschlüsse exakt (T/L/X, ein- und mehrschichtig).** (30.10., Maintainer-Bug: schräger
T-Stoss) Die Nah-Putz-Aussparung der Durchgangswand (`joins::SpanCutout`) ist jetzt ein Parallelogramm
(`from/to` auf der Fläche, `from_b/to_b` auf der Rückgrat-Fläche) aus den echten Kern-Kanten des Abzweigs
— vorher Breite `Kern · sin θ` statt `/ sin θ` und versetzt (Lücke falsch, Schraffur ragte hinein, Fugen-
Linie quer durch die Lücke). Am Knoten-T bekommen beide Durchgangs-Hälften die Aussparung und eine nicht
gezeichnete Stossfuge; Kern ohne Nah-Putz (gleiches Bauteil) gibt eine flache Aussparung → Lücke in der
Flächenlinie. Grundriss (`plan_walls.rs`): Bänder/Fugen/Flächenlinie enden an den schrägen Lochseiten,
Fugen neben dem durchlaufenden Kern bis zur Rückgrat-Fläche. 3D (`wall_bands.rs`): Körper tragen
Schnittlinien (`Piece`/`RWall.startCut/endCut`), render3d verschneidet die Kanten damit statt
rechtwinklig an der Band-Mitte (Dreieck-Lücke weg); OBJ/STL/GLB (`mesh_data.rs`) und Live-Schnitt ebenso.
SVG-Export des Grundrisses beachtet jetzt `noStrokeEdges` (vorher Stossfugen/Gehrungen gestrichen).
Tests: Winkel 15°–165° ein-/mehrschichtig (Joins, Grundriss-Primitive, 3D-Rasterprüfung lückenlos/ohne
Doppelung für T, Knoten-T, L, X). Geprüft: cargo/vitest, CLI-Grundriss-SVG angesehen (Linux). Offen: 3D nur
per Rust-Test (kein Metal-Render), IFC/truck-Körper noch rechtwinklig, nicht in der Tauri-App geprüft. · S
## Priorität 4 — später
+2
View File
@@ -255,6 +255,8 @@ mod tests {
hatch: None,
material_index: None,
cut: None,
start_cut: None,
end_cut: None,
}
}
+137 -21
View File
@@ -70,13 +70,27 @@ pub struct LayerCuts {
pub end_side: Vec<Option<Line>>,
}
/// Aussparung der Nah-Putz-Zone einer Durchgangswand (`SpanCutout` in TS).
/// Aussparung der Nah-Putz-Zone einer Durchgangswand: ein Parallelogramm im Achsmass der Wand.
/// `from`/`to` gelten auf der Fläche (`off_a`), `from_b`/`to_b` auf der Rückgrat-Nahfläche
/// (`off_b`); bei schrägem Abzweig sind die Seiten schräg (Kanten des Abzweig-Kerns), bei
/// rechtwinkligem gilt `from_b = from`, `to_b = to`.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct SpanCutout {
pub from: f64,
pub to: f64,
pub off_a: f64,
pub off_b: f64,
pub from_b: f64,
pub to_b: f64,
}
impl SpanCutout {
/// Achsmass der beiden schrägen Seiten im Querversatz `off` (linear zwischen `off_a`/`off_b`).
pub fn at(&self, off: f64) -> (f64, f64) {
let d = self.off_b - self.off_a;
let t = if d.abs() < 1e-12 { 0.0 } else { (off - self.off_a) / d };
(self.from + (self.from_b - self.from) * t, self.to + (self.to_b - self.to) * t)
}
}
/// Schnittlinien einer Wand (`WallCuts` in TS).
@@ -363,13 +377,20 @@ fn apply_t_junction(walls: &[JoinWall], ends: &[WallEnd], result: &mut [WallCuts
let face_cut = Line { point: face_point, dir: u_t };
set_cut(result, branch_end, face_cut);
apply_layer_cuts(walls, result, branch_end, ti, face_cut, j, u_t, sign)
// Die Durchgangs-Hälften stossen rechtwinklig aneinander; als Schnitt markiert, damit die
// Stossfuge nicht als Umriss gezeichnet wird (eine durchlaufende Wand).
let joint = Line { point: j, dir: n_t };
set_cut(result, ends[t0], joint);
set_cut(result, ends[t1], joint);
apply_layer_cuts(walls, result, branch_end, ti, Some(ends[t1].wall), face_cut, j, u_t, sign)
}
/// Materialbewusste Pro-Schicht-Erweiterung eines T-Stoss-Cuts: Abzweig-Schichten gleichen
/// Materials wie das Rückgrat der Durchgangswand (oder prioritärer) laufen bis zur
/// Rückgrat-Nahfläche durch; angrenzende getrimmte Schichten bekommen eine seitliche Linie; die
/// Durchgangswand bekommt eine Nah-Putz-Aussparung über die Kernbreite. Setzt `layer_cuts` nur,
/// Durchgangswand (am Knoten-T beide Hälften, `other_half`) bekommt eine Nah-Putz-Aussparung über
/// die Kernbreite — exakt dort, wo die Kern-Kanten des (auch schrägen) Abzweigs die Fläche und die
/// Rückgrat-Nahfläche kreuzen. Setzt `layer_cuts` nur,
/// wenn mindestens eine Schicht verschmilzt.
#[allow(clippy::too_many_arguments)]
fn apply_layer_cuts(
@@ -377,6 +398,7 @@ fn apply_layer_cuts(
result: &mut [WallCuts],
branch_end: WallEnd,
ti: usize,
other_half: Option<usize>,
face_cut: Line,
axis_point: Vec2,
through_dir: Vec2,
@@ -450,8 +472,9 @@ fn apply_layer_cuts(
side_arr[i] = if adj_merged && !merges_with_near { Some(side_line) } else { None };
}
// Durchgangswand-Aussparung über die Kernbreite des Abzweigs (nur bei Nah-Putz).
if near_plaster > 1e-9 {
// Durchgangswand-Aussparung über die Kernbreite des Abzweigs. Ohne Nah-Putz (Kern trifft direkt
// auf die Fläche) ist sie flach (`off_a = off_b`): nur die Flächenlinie bekommt dort eine Lücke.
{
let total_branch = branch_layers.iter().fold(0.0, |s, l| s + l.thickness);
let ref_off_branch = reference_offset(walls[bi].reference, total_branch);
let mut b_off = ref_off_branch - total_branch / 2.0;
@@ -470,14 +493,33 @@ fn apply_layer_cuts(
b_off += th;
}
if core_hi > core_lo {
let n_branch = left_normal(dir_of(&walls[bi]));
let proj = dot(n_branch, through_dir);
let axis_at = dot(sub(axis_point, walls[ti].start), through_dir);
let e1 = axis_at + core_lo * proj;
let e2 = axis_at + core_hi * proj;
let off_a = off_t + sign * (t_t / 2.0);
let off_b = off_t + sign * (t_t / 2.0 - near_plaster);
result[ti].span_cutouts.push(SpanCutout { from: e1.min(e2), to: e1.max(e2), off_a, off_b });
let bw = &walls[bi];
let n_branch = left_normal(dir_of(bw));
let u_branch = dir_of(bw);
let edge_lo = add(bw.start, scale(n_branch, core_lo));
let edge_hi = add(bw.start, scale(n_branch, core_hi));
let face_pt = face_cut.point;
for wi in std::iter::once(ti).chain(other_half) {
let w = &walls[wi];
let u_w = dir_of(w);
let n_w = left_normal(u_w);
// Flächen im Rahmen der Wand `wi` (die andere Hälfte kann gegenläufig sein).
let off_a = dot(sub(face_pt, w.start), n_w);
let off_b = dot(sub(merge_point, w.start), n_w);
let along = |edge: Vec2, off: f64| -> Option<f64> {
let hit = line_intersect(edge, u_branch, add(w.start, scale(n_w, off)), u_w)?;
Some(dot(sub(hit, w.start), u_w))
};
let (Some(a_lo), Some(a_hi), Some(b_lo), Some(b_hi)) = (along(edge_lo, off_a), along(edge_hi, off_a), along(edge_lo, off_b), along(edge_hi, off_b)) else {
continue;
};
let s = if a_lo <= a_hi {
SpanCutout { from: a_lo, to: a_hi, off_a, off_b, from_b: b_lo, to_b: b_hi }
} else {
SpanCutout { from: a_hi, to: a_lo, off_a, off_b, from_b: b_hi, to_b: b_lo }
};
result[wi].span_cutouts.push(s);
}
}
}
Ok(())
@@ -544,7 +586,7 @@ fn apply_mid_span_tee(walls: &[JoinWall], free: WallEnd, result: &mut [WallCuts]
set_cut(result, free, face_cut);
let axis_point = add(w.start, scale(u_w, dist_along));
apply_layer_cuts(walls, result, free, wi, face_cut, axis_point, u_w, sign)
apply_layer_cuts(walls, result, free, wi, None, face_cut, axis_point, u_w, sign)
}
// ── Flache Kodierung ─────────────────────────────────────────────────────────
@@ -552,7 +594,7 @@ fn apply_mid_span_tee(walls: &[JoinWall], free: WallEnd, result: &mut [WallCuts]
// Wände: [n, (sx, sy, ex, ey, refKind, refValue, typeOk, nLayers, (dicke, bauteil, prio)…)…]
// refKind: 0 Mitte, 1 links, 2 rechts, 3 freier Versatz (refValue); bauteil < 0 = unbekannt.
// Cuts einer Wand: [start(5), end(5), nLC, (start, end, startSide, endSide je nLC × 5),
// nSpan, (from, to, offA, offB)…]; Linie = (gesetzt 0/1, px, py, dx, dy).
// nSpan, (from, to, offA, offB, fromB, toB)…]; Linie = (gesetzt 0/1, px, py, dx, dy).
/// Liest die Wände; `None` bei kaputten/unendlichen Daten.
pub fn decode_walls(buf: &[f64]) -> Option<Vec<JoinWall>> {
@@ -614,7 +656,7 @@ pub fn encode_cuts(out: &mut Vec<f64>, c: &WallCuts) {
}
out.push(c.span_cutouts.len() as f64);
for s in &c.span_cutouts {
out.extend([s.from, s.to, s.off_a, s.off_b]);
out.extend([s.from, s.to, s.off_a, s.off_b, s.from_b, s.to_b]);
}
}
@@ -652,8 +694,8 @@ pub fn decode_cuts(r: &mut crate::flat_read::Reader) -> Option<WallCuts> {
let m = r.count()?;
let mut span_cutouts = Vec::with_capacity(m.min(1 << 10));
for _ in 0..m {
let s = SpanCutout { from: r.num()?, to: r.num()?, off_a: r.num()?, off_b: r.num()? };
if ![s.from, s.to, s.off_a, s.off_b].iter().all(|v| v.is_finite()) {
let s = SpanCutout { from: r.num()?, to: r.num()?, off_a: r.num()?, off_b: r.num()?, from_b: r.num()?, to_b: r.num()? };
if ![s.from, s.to, s.off_a, s.off_b, s.from_b, s.to_b].iter().all(|v| v.is_finite()) {
return None;
}
span_cutouts.push(s);
@@ -725,8 +767,9 @@ mod tests {
fn t_knoten_schneidet_nur_abzweig() {
let w = vec![mono((0.0, 0.0), (3.0, 0.0), 0.3), mono((3.0, 0.0), (6.0, 0.0), 0.3), mono((3.0, 0.0), (3.0, 4.0), 0.2)];
let c = compute_joins(&w).unwrap();
assert_eq!(c[0].end_cut, None);
assert_eq!(c[1].start_cut, None);
// Durchgang: rechtwinklige Stossfuge der beiden Hälften (nicht gezeichnet).
assert!(close(c[0].end_cut.unwrap().dir.x, 0.0) && close(c[1].start_cut.unwrap().point.x, 3.0));
assert_eq!(c[0].start_cut, None);
let cut = c[2].start_cut.unwrap();
assert!(close(cut.point.y, 0.15) && close(cut.dir.y, 0.0));
}
@@ -744,7 +787,10 @@ mod tests {
assert!(close(c[1].start_cut.unwrap().point.y, 0.15));
assert!(close(c[2].end_cut.unwrap().point.y, -0.15));
assert!(close(c[3].start_cut.unwrap().point.y, 0.15));
assert_eq!(c[0], WallCuts::default());
// Gleiches Bauteil ohne Nah-Putz: flache Aussparungen (nur Lücke in der Flächenlinie), je Anschluss eine.
assert!(c[0].start_cut.is_none() && c[0].end_cut.is_none() && c[0].layer_cuts.is_none());
assert_eq!(c[0].span_cutouts.len(), 3);
assert!(c[0].span_cutouts.iter().all(|s| s.off_a == s.off_b && close(s.to - s.from, 0.2) && s.from_b == s.from));
}
#[test]
@@ -805,6 +851,76 @@ mod tests {
assert!(c[2].start_cut.is_some());
}
/// Aussenwand-Aufbau wie im Beispielhaus: Aussenputz | Dämmung | Backstein (Rückgrat) | Innenputz.
fn aw() -> Vec<JoinLayer> {
vec![layer(0.02, 0, 10.0), layer(0.16, 1, 20.0), layer(0.15, 2, 50.0), layer(0.015, 3, 10.0)]
}
/// Wo die Kante (Versatz `o` quer zur Abzweig-Achse durch `b0` mit Winkel `th`) die Gerade
/// y = f der waagrechten Durchgangswand trifft (x-Koordinate) — unabhängige Referenz.
fn x_on_face(b0: Vec2, th: f64, o: f64, f: f64) -> f64 {
let (s, c) = th.sin_cos();
let t = (f - b0.y - o * c) / s;
b0.x - o * s + t * c
}
#[test]
fn schraeger_t_stoss_schneidet_an_der_flaeche_15_bis_165_grad() {
for deg in (15..=165).step_by(15) {
let th = (deg as f64).to_radians();
let b0 = Vec2::new(5.0, 0.0);
let b1 = Vec2::new(5.0 + 3.0 * th.cos(), 3.0 * th.sin());
for (lay, total) in [(vec![layer(0.25, 0, 10.0)], 0.25), (aw(), 0.345)] {
// Mittelspannen-T und Knoten-T (Durchgang aus zwei Hälften).
let mid = vec![wall((0.0, 0.0), (10.0, 0.0), lay.clone()), wall((b0.x, b0.y), (b1.x, b1.y), lay.clone())];
let node = vec![wall((0.0, 0.0), (5.0, 0.0), lay.clone()), wall((5.0, 0.0), (10.0, 0.0), lay.clone()), wall((b0.x, b0.y), (b1.x, b1.y), lay.clone())];
for w in [mid, node] {
let bi = w.len() - 1;
let c = compute_joins(&w).unwrap();
let cut = c[bi].start_cut.unwrap();
// Schnitt liegt auf der zugewandten Fläche y = total/2, parallel zur Durchgangswand.
assert!(close(cut.dir.y, 0.0) && close(cut.point.y, total / 2.0), "{deg}° {cut:?}");
}
}
}
}
#[test]
fn schraege_nahputz_aussparung_folgt_dem_abzweig_15_bis_165_grad() {
let total = 0.345;
let (off_a, off_b) = (total / 2.0, total / 2.0 - 0.015);
// Rückgrat-Kante des Abzweigs (Backstein) quer zur Achse.
let (core_lo, core_hi) = (-total / 2.0 + 0.18, -total / 2.0 + 0.33);
for deg in (15..=165).step_by(15) {
let th = (deg as f64).to_radians();
let b0 = Vec2::new(5.0, 0.0);
let b1 = Vec2::new(5.0 + 3.0 * th.cos(), 3.0 * th.sin());
let mid = vec![wall((0.0, 0.0), (10.0, 0.0), aw()), wall((b0.x, b0.y), (b1.x, b1.y), aw())];
let node = vec![wall((0.0, 0.0), (5.0, 0.0), aw()), wall((5.0, 0.0), (10.0, 0.0), aw()), wall((b0.x, b0.y), (b1.x, b1.y), aw())];
for w in [mid, node] {
let c = compute_joins(&w).unwrap();
let through: Vec<usize> = (0..w.len() - 1).collect();
// Aussparung je Durchgangs-Hälfte, in deren Achsmass (Start x = 0 bzw. 5).
let mut hits = 0;
for &ti in &through {
let x0 = w[ti].start.x;
for s in &c[ti].span_cutouts {
hits += 1;
assert!(close(s.off_a, off_a) && close(s.off_b, off_b), "{deg}° {s:?}");
let xa = [x_on_face(b0, th, core_lo, off_a), x_on_face(b0, th, core_hi, off_a)];
let xb = [x_on_face(b0, th, core_lo, off_b), x_on_face(b0, th, core_hi, off_b)];
let (lo, hi) = if xa[0] < xa[1] { (0, 1) } else { (1, 0) };
assert!(close(s.from + x0, xa[lo]) && close(s.to + x0, xa[hi]), "{deg}° {s:?} {xa:?}");
assert!(close(s.from_b + x0, xb[lo]) && close(s.to_b + x0, xb[hi]), "{deg}° {s:?} {xb:?}");
// Breite = Kernbreite / sin θ (nicht · sin θ).
assert!(close(s.to - s.from, 0.15 / th.sin()), "{deg}°");
}
}
assert_eq!(hits, through.len(), "{deg}°: jede Durchgangs-Hälfte bekommt die Aussparung");
}
}
}
#[test]
fn hypot_wie_js() {
assert_eq!(js_hypot(3.0, 4.0), 5.0);
+59
View File
@@ -147,10 +147,26 @@ fn push_wall_box(g: &mut Prim, w: &RWall) {
let cz = (sy + ey) / 2.0;
let cy = w.base_elevation + w.height / 2.0;
let base = (g.positions.len() / 3) as f64;
// Kanten ±Dicke/2 an den Schnittlinien (Gehrung, T-Stoss, schräge Aussparung) enden lassen.
let clip = |px: f64, pz: f64, cut: Option<[f64; 4]>| -> (f64, f64) {
let Some([qx, qz, dx2, dz2]) = cut else { return (px, pz) };
let denom = ax * dz2 - az * dx2;
if denom.abs() < 1e-9 {
return (px, pz);
}
let t = ((qx - px) * dz2 - (qz - pz) * dx2) / denom;
(px + ax * t, pz + az * t)
};
for i in 0..8 {
let sl = if i & 1 != 0 { 1.0 } else { -1.0 };
let sh = if i & 2 != 0 { 1.0 } else { -1.0 };
let st = if i & 4 != 0 { 1.0 } else { -1.0 };
let cut = if sl > 0.0 { w.end_cut } else { w.start_cut };
if cut.is_some() {
let (px, pz) = clip(cx + sl * half_len * ax + st * half_thick * nx, cz + sl * half_len * az + st * half_thick * nz, cut);
g.positions.extend_from_slice(&[px, cy + sh * half_height, pz]);
continue;
}
g.positions.extend_from_slice(&[cx + sl * half_len * ax + st * half_thick * nx, cy + sh * half_height, cz + sl * half_len * az + st * half_thick * nz]);
}
for [a, b, c, d] in BOX_QUADS {
@@ -159,6 +175,47 @@ fn push_wall_box(g: &mut Prim, w: &RWall) {
}
}
/// Ecken an Wandanfang/-ende (Welt x, Höhe, y) längs der Achse auf die Schnittlinien schieben
/// (`RWall::start_cut`/`end_cut`); die Mantelflächen bleiben eben, weil sich nur Endpunkte längs
/// der Achse verschieben.
fn shift_cut_ends(pos: &mut [f64], w: &RWall) {
if w.start_cut.is_none() && w.end_cut.is_none() {
return;
}
let [sx, sy] = w.start;
let (dx, dy) = (w.end[0] - sx, w.end[1] - sy);
let len = hypot2(dx, dy);
if len < 1e-9 {
return;
}
let (ax, ay) = (dx / len, dy / len);
// Achsmass, an dem die Längslinie (Querversatz `t`) die Schnittlinie trifft.
let at = |c: [f64; 4], t: f64| -> Option<f64> {
let (px, py) = (sx - ay * t, sy + ax * t);
let denom = ax * c[3] - ay * c[2];
if denom.abs() < 1e-9 {
return None;
}
Some(((c[0] - px) * c[3] - (c[1] - py) * c[2]) / denom)
};
for v in pos.chunks_exact_mut(3) {
let (rx, ry) = (v[0] - sx, v[2] - sy);
let a = rx * ax + ry * ay;
let t = -rx * ay + ry * ax;
let target = if a.abs() < 1e-6 {
w.start_cut.and_then(|c| at(c, t))
} else if (a - len).abs() < 1e-6 {
w.end_cut.and_then(|c| at(c, t))
} else {
None
};
if let Some(na) = target {
v[0] += ax * (na - a);
v[2] += ay * (na - a);
}
}
}
/// Signierte Fläche eines Modell-XY-Umrisses (Shoelace); ≥ 0 = CCW.
fn signed_area_xy(pts: &[Vec2]) -> f64 {
let mut a = 0.0;
@@ -306,6 +363,8 @@ pub fn mesh_export_data(src: &Project, opt: &MeshOptions) -> Result<Flat, String
height: w.height,
holes: w.holes.as_deref().unwrap_or(&[]).iter().map(|h| [h.from, h.to, h.z_bottom, h.z_top]).collect(),
});
let mut cut = cut;
shift_cut_ends(&mut cut, w);
let base = (prim.positions.len() / 3) as f64;
prim.positions.extend_from_slice(&cut);
prim.indices.extend((0..cut.len() / 3).map(|i| base + i as f64));
+9
View File
@@ -266,6 +266,13 @@ pub struct RWall {
pub material_index: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cut: Option<RCutMeta>,
/// Schnittlinie `[px, py, dx, dy]` (Grundriss) am Anfang/Ende: Gehrung, T-Stoss-Fläche oder schräge
/// Aussparungs-Seite; die Kanten ±Dicke/2 enden auf ihr ([108]). Fehlt: rechtwinklig bzw. die
/// Gehrung, die render3d aus den Nachbar-Enden ableitet.
#[serde(skip_serializing_if = "Option::is_none")]
pub start_cut: Option<[f64; 4]>,
#[serde(skip_serializing_if = "Option::is_none")]
pub end_cut: Option<[f64; 4]>,
}
/// Textur-Karten-URLs der Bauteile in der Reihenfolge des ersten Auftretens: Wandtypen, dann
@@ -589,6 +596,8 @@ pub fn emit_walls(p: &Project, layered: bool) -> Result<Vec<RWall>, String> {
hatch: b.hatch.clone().map(|h| with_top_angle(h, dx, dy)),
material_index: b.material_index,
cut: band_cut_meta(b),
start_cut: piece.start_cut.map(|l| [l.point.x, l.point.y, l.dir.x, l.dir.y]),
end_cut: piece.end_cut.map(|l| [l.point.x, l.point.y, l.dir.x, l.dir.y]),
});
}
}
+6
View File
@@ -328,9 +328,15 @@ fn wall_input(w: &RWall) -> render3d::WallInput {
material_index: None,
hatch: None,
cut: None,
start_cut: w.start_cut.map(f32s4),
end_cut: w.end_cut.map(f32s4),
}
}
fn f32s4(v: [f64; 4]) -> [f32; 4] {
[json_f32(v[0]), json_f32(v[1]), json_f32(v[2]), json_f32(v[3])]
}
fn slab_input(s: &RSlab) -> render3d::SlabInput {
render3d::SlabInput {
outline: s.outline.iter().map(|q| f32s2(*q)).collect(),
+1 -1
View File
@@ -118,7 +118,7 @@ fn encode_wall_poche(w: &Wall, layers: &[f64], total: f64, ref_off: f64, gaps: &
}
b.push(cuts.span_cutouts.len() as f64);
for c in &cuts.span_cutouts {
b.extend([c.from, c.to, c.off_a, c.off_b]);
b.extend([c.from, c.to, c.off_a, c.off_b, c.from_b, c.to_b]);
}
b.push(gaps.len() as f64);
for g in gaps {
+29
View File
@@ -116,6 +116,35 @@ pub fn plan_svg(parts: &mut [Part], o: &SvgOptions) -> Option<String> {
let pl = pts.iter().map(|q| format!("{},{}", xs(q.x), ys(q.y))).collect::<Vec<_>>().join(" ");
let fill = esc(part.str(f[0]).unwrap_or(""));
let stroke = esc(part.str(f[1]).unwrap_or(""));
// Nicht gestrichene Kanten (Stossfugen, Lücken an Anschlüssen): Fläche ohne Strich,
// die übrigen Kanten als offener Pfad — wie der GPU-Pfad (`stroke_polygon_outline`).
let nse: Vec<usize> = match rec.nse {
Some((o, len)) => part.view.pool(o, len)?.iter().filter(|e| e.is_finite() && **e >= 0.0).map(|e| *e as usize).collect(),
None => Vec::new(),
};
if !nse.is_empty() && stroke != "none" && !stroke.is_empty() {
let k = pts.len();
let mut d = String::new();
for e in 0..k {
if nse.contains(&e) {
continue;
}
if e == 0 || nse.contains(&(e - 1)) {
d.push_str(&format!("M{},{}", xs(pts[e].x), ys(pts[e].y)));
}
let q = pts[(e + 1) % k];
d.push_str(&format!(" L{},{}", xs(q.x), ys(q.y)));
}
out.push(format!("<polygon points=\"{pl}\" fill=\"{fill}\" stroke=\"none\"{}/>", op(greyed, opacity(4))));
if !d.is_empty() {
out.push(format!(
"<path d=\"{d}\" fill=\"none\" stroke=\"{stroke}\" stroke-width=\"{}\" stroke-linejoin=\"round\"{}/>",
num(f[2] * mm_to_m),
op(greyed, opacity(4))
));
}
continue;
}
out.push(format!(
"<polygon points=\"{pl}\" fill=\"{fill}\" stroke=\"{stroke}\" stroke-width=\"{}\" stroke-linejoin=\"round\"{}/>",
num(f[2] * mm_to_m),
+330 -41
View File
@@ -219,12 +219,130 @@ struct LayerCuts {
end_side: Vec<Option<Line>>,
}
/// Nah-Putz-Aussparung (Parallelogramm, s. `joins::SpanCutout`): `from`/`to` auf `off_a`,
/// `from_b`/`to_b` auf `off_b`.
#[derive(Clone, Copy)]
struct Cutout {
from: f64,
to: f64,
off_a: f64,
off_b: f64,
from_b: f64,
to_b: f64,
}
impl Cutout {
fn lo(&self) -> f64 {
min(min(self.from, self.to), min(self.from_b, self.to_b))
}
fn hi(&self) -> f64 {
max(max(self.from, self.to), max(self.from_b, self.to_b))
}
}
/// Loch im Achsmass (auf der Mittellinie eines Bands) samt den schrägen Seitenlinien (Welt) und
/// deren Achsmass-Spanne `(min, max)` über die Banddicke.
#[derive(Clone, Copy)]
struct Hole {
a: f64,
b: f64,
la: Line,
lb: Line,
la_rng: (f64, f64),
lb_rng: (f64, f64),
}
/// Wandrahmen für die Löcher: Start, Achsrichtung, Links-Normale.
#[derive(Clone, Copy)]
struct Frame {
o: V,
u: V,
n: V,
}
impl Frame {
/// Achsmass, an dem die Gerade `l` die Längslinie im Querversatz `off` trifft.
fn pos(&self, l: &Line, off: f64) -> Option<f64> {
let hit = line_intersect(add(self.o, scale(self.n, off)), self.u, l.point, l.dir)?;
Some(dot(sub(hit, self.o), self.u))
}
}
/// Löcher der Aussparungen im Band `[lo, hi]` (bei Linien `lo = hi`).
fn holes_at(cs: &[&Cutout], lo: f64, hi: f64, f: Frame) -> Vec<Hole> {
let pt = |d: f64, o: f64| add(add(f.o, scale(f.u, d)), scale(f.n, o));
let at = |c: &Cutout, off: f64| {
let d = c.off_b - c.off_a;
let t = if d.abs() < 1e-12 { 0.0 } else { (off - c.off_a) / d };
(c.from + (c.from_b - c.from) * t, c.to + (c.to_b - c.to) * t)
};
cs.iter()
.map(|c| {
let side = |p: f64, q: f64| {
let (a, b) = (pt(p, c.off_a), pt(q, c.off_b));
let dir = sub(b, a);
// Entartet (off_a = off_b): senkrecht zur Achse.
Line { point: a, dir: if hypot2(dir.x, dir.y) < 1e-12 { f.n } else { dir } }
};
let (x0, x1) = at(c, (lo + hi) / 2.0);
let ((p0, q0), (p1, q1)) = (at(c, lo), at(c, hi));
let (rp, rq) = ((min(p0, p1), max(p0, p1)), (min(q0, q1), max(q0, q1)));
let (l0, l1) = (side(c.from, c.from_b), side(c.to, c.to_b));
if x0 <= x1 {
Hole { a: x0, b: x1, la: l0, lb: l1, la_rng: rp, lb_rng: rq }
} else {
Hole { a: x1, b: x0, la: l1, lb: l0, la_rng: rq, lb_rng: rp }
}
})
.collect()
}
/// Wie [`subtract_intervals`], aber jedes Teilstück trägt die Schnittlinien an seinen Enden: am
/// Segmentende `s`/`e` `s_cut`/`e_cut`, an einem Loch dessen schräge Seite. Ragt eine schräge
/// Lochseite über ein rechtwinkliges Segmentende ins Band (Knoten-T: Loch auf der Nachbarhälfte),
/// endet das Band an ihr; Teilstücke, deren Enden sich über die Banddicke `[lo, hi]` kreuzen,
/// entfallen (die Nachbarhälfte deckt sie). Gleiche Regeln wie `wall_bands::subtract_spans_cut`.
#[allow(clippy::too_many_arguments)]
fn subtract_holes(s: f64, e: f64, holes: &[Hole], s_cut: Option<Line>, e_cut: Option<Line>, f: Frame, lo: f64, hi: f64) -> Vec<(f64, f64, Option<Line>, Option<Line>)> {
let (mut s, mut e, mut s_cut, mut e_cut) = (s, e, s_cut, e_cut);
{
if let Some(h) = holes.iter().filter(|h| h.a >= e - CUTOUT_EPS && h.la_rng.0 < e - CUTOUT_EPS).min_by(|p, q| p.a.total_cmp(&q.a)) {
e = h.a;
e_cut = Some(h.la);
}
}
{
if let Some(h) = holes.iter().filter(|h| h.b <= s + CUTOUT_EPS && h.lb_rng.1 > s + CUTOUT_EPS).max_by(|p, q| p.b.total_cmp(&q.b)) {
s = h.b;
s_cut = Some(h.lb);
}
}
let mut clipped: Vec<Hole> = holes.iter().map(|h| Hole { a: max(s, h.a), b: min(e, h.b), ..*h }).filter(|h| h.b > h.a + CUTOUT_EPS).collect();
clipped.sort_by(|p, q| p.a.partial_cmp(&q.a).unwrap_or(std::cmp::Ordering::Equal));
let mut parts = Vec::new();
let (mut cursor, mut cursor_line) = (s, s_cut);
for h in clipped {
if h.a > cursor + CUTOUT_EPS {
parts.push((cursor, h.a, cursor_line, Some(h.la)));
}
if h.b > cursor {
cursor = h.b;
cursor_line = Some(h.lb);
}
}
if cursor < e - CUTOUT_EPS {
parts.push((cursor, e, cursor_line, e_cut));
}
if !holes.is_empty() {
parts.retain(|&(a, b, sc, ec)| {
[lo, hi].iter().all(|&off| {
let ps = sc.and_then(|l| f.pos(&l, off)).unwrap_or(a);
let pe = ec.and_then(|l| f.pos(&l, off)).unwrap_or(b);
pe > ps + CUTOUT_EPS
})
});
}
parts
}
fn read_line(r: &mut Reader) -> Option<Option<Line>> {
@@ -305,7 +423,7 @@ fn wall_poche_inner(buf: &[f64]) -> Option<Vec<f64>> {
let n_cut = r.count()?;
let mut span_cutouts = Vec::with_capacity(n_cut);
for _ in 0..n_cut {
span_cutouts.push(Cutout { from: r.num()?, to: r.num()?, off_a: r.num()?, off_b: r.num()? });
span_cutouts.push(Cutout { from: r.num()?, to: r.num()?, off_a: r.num()?, off_b: r.num()?, from_b: r.num()?, to_b: r.num()? });
}
let n_gap = r.count()?;
let mut gaps = Vec::with_capacity(n_gap);
@@ -363,15 +481,14 @@ fn wall_poche_inner(buf: &[f64]) -> Option<Vec<f64>> {
}
let band_join_edges = join_edges(sc, ec);
let seg_cutouts: Vec<Cutout> = span_cutouts
.iter()
.filter(|c| min(c.from, c.to) < e - CUTOUT_EPS && max(c.from, c.to) > s + CUTOUT_EPS)
.copied()
.collect();
let seg_cutouts: Vec<&Cutout> = span_cutouts.iter().filter(|c| c.lo() < e - CUTOUT_EPS && c.hi() > s + CUTOUT_EPS).collect();
let u_w = normalize(sub(wend, wstart));
let fr = Frame { o: wstart, u: u_w, n: left_normal(u_w) };
let seg_adj: Vec<&Adj> = adj.iter().filter(|a| (a.dir > 0.0 && (a.jamb - e).abs() < 1e-6) || (a.dir < 0.0 && (a.jamb - s).abs() < 1e-6)).collect();
if !seg_adj.is_empty() {
let seg = Seg { s, e, p1, p2, wstart, wend, axis_len, sc, ec };
adjusted_segment(&mut o, &seg, &thick, ref_off - total / 2.0, &layer_cuts, &seg_cutouts, &seg_adj, &band_join_edges);
let seg_cut_vals: Vec<Cutout> = seg_cutouts.iter().map(|c| **c).collect();
adjusted_segment(&mut o, &seg, &thick, ref_off - total / 2.0, &layer_cuts, &seg_cut_vals, &seg_adj, &band_join_edges);
continue;
}
let axis_pt = |d: f64| if d == s { p1 } else if d == e { p2 } else { along(wstart, wend, d) };
@@ -395,17 +512,13 @@ fn wall_poche_inner(buf: &[f64]) -> Option<Vec<f64>> {
};
let band_lo = off;
let band_hi = off + thick[li];
let mut band_holes: Vec<(f64, f64)> = Vec::new();
for c in &seg_cutouts {
let c_lo = min(c.off_a, c.off_b);
let c_hi = max(c.off_a, c.off_b);
if band_lo < c_hi - CUTOUT_EPS && band_hi > c_lo + CUTOUT_EPS {
band_holes.push((c.from, c.to));
}
}
for (a, b) in subtract_intervals(s, e, &band_holes) {
let bsc = if a <= s + CUTOUT_EPS { layer_start_cut } else { None };
let bec = if b >= e - CUTOUT_EPS { layer_end_cut } else { None };
let band_cs: Vec<&Cutout> = seg_cutouts
.iter()
.filter(|c| band_lo < max(c.off_a, c.off_b) - CUTOUT_EPS && band_hi > min(c.off_a, c.off_b) + CUTOUT_EPS)
.copied()
.collect();
let band_holes = holes_at(&band_cs, band_lo, band_hi, fr);
for (a, b, bsc, bec) in subtract_holes(s, e, &band_holes, layer_start_cut, layer_end_cut, fr, band_lo, band_hi) {
o.polygon(ART_BAND, li, &band_join_edges, &clipped_band(axis_pt(a), axis_pt(b), off, off + thick[li], bsc, bec));
}
let side_start = if s <= 1e-6 { layer_cuts.as_ref().and_then(|lc| lc.start_side[li]) } else { None };
@@ -426,17 +539,36 @@ fn wall_poche_inner(buf: &[f64]) -> Option<Vec<f64>> {
}
off += thick[li];
if li + 1 < n_layers {
let mut fuge_holes: Vec<(f64, f64)> = Vec::new();
for c in &seg_cutouts {
let c_lo = min(c.off_a, c.off_b);
let c_hi = max(c.off_a, c.off_b);
if off >= c_lo - CUTOUT_EPS && off <= c_hi + CUTOUT_EPS {
fuge_holes.push((c.from, c.to));
let fuge_cs: Vec<&Cutout> = seg_cutouts
.iter()
.filter(|c| off >= min(c.off_a, c.off_b) - CUTOUT_EPS && off <= max(c.off_a, c.off_b) + CUTOUT_EPS)
.copied()
.collect();
// Fuge neben einer durchlaufenden (verschmolzenen) Schicht: sie trennt diese bis zu
// ihrem Ende von der Nah-Schicht der Durchgangswand — also bis zum weiter reichenden
// der beiden Schicht-Schnitte statt nur bis zur Fläche.
let reach = |own: Option<Line>, pair: [Option<Line>; 2], start: bool| -> Option<Line> {
let pos = |l: &Option<Line>| l.as_ref().and_then(|l| fr.pos(l, off));
let mut best = own;
for l in pair.into_iter().flatten() {
let further = match (pos(&Some(l)), pos(&best)) {
(Some(p), Some(q)) => (start && p < q - CUTOUT_EPS) || (!start && p > q + CUTOUT_EPS),
_ => false,
};
if further {
best = Some(l);
}
}
}
for (a, b) in subtract_intervals(s, e, &fuge_holes) {
let jsc = if a <= s + CUTOUT_EPS { sc } else { None };
let jec = if b >= e - CUTOUT_EPS { ec } else { None };
best
};
let (fsc, fec) = match &layer_cuts {
Some(lc) => (
if s <= 1e-6 { reach(sc, [lc.start[li], lc.start[li + 1]], true) } else { sc },
if e >= axis_len - 1e-6 { reach(ec, [lc.end[li], lc.end[li + 1]], false) } else { ec },
),
None => (sc, ec),
};
for (a, b, jsc, jec) in subtract_holes(s, e, &holes_at(&fuge_cs, off, off, fr), fsc, fec, fr, off, off) {
let jq = clipped_band(axis_pt(a), axis_pt(b), off, off, jsc, jec);
o.line(LINE_JOINT, li, jq[0], jq[1]);
}
@@ -445,15 +577,10 @@ fn wall_poche_inner(buf: &[f64]) -> Option<Vec<f64>> {
let off_lo = ref_off - total / 2.0;
let off_hi = ref_off + total / 2.0;
let mut holes_hi: Vec<(f64, f64)> = Vec::new();
let mut holes_lo: Vec<(f64, f64)> = Vec::new();
for c in &seg_cutouts {
if (c.off_a - off_hi).abs() < 1e-6 {
holes_hi.push((c.from, c.to));
} else if (c.off_a - off_lo).abs() < 1e-6 {
holes_lo.push((c.from, c.to));
}
}
let cs_hi: Vec<&Cutout> = seg_cutouts.iter().filter(|c| (c.off_a - off_hi).abs() < 1e-6).copied().collect();
let cs_lo: Vec<&Cutout> = seg_cutouts.iter().filter(|c| (c.off_a - off_hi).abs() >= 1e-6 && (c.off_a - off_lo).abs() < 1e-6).copied().collect();
let holes_hi = holes_at(&cs_hi, off_hi, off_hi, fr);
let holes_lo = holes_at(&cs_lo, off_lo, off_lo, fr);
let mut outline_no_stroke = band_join_edges.clone();
if !holes_hi.is_empty() {
outline_no_stroke.push(2.0);
@@ -462,10 +589,8 @@ fn wall_poche_inner(buf: &[f64]) -> Option<Vec<f64>> {
outline_no_stroke.push(0.0);
}
o.polygon(ART_OUTLINE, 0, &outline_no_stroke, &clipped_band(p1, p2, off_lo, off_hi, sc, ec));
let mut near_edge = |edge_off: f64, holes: &[(f64, f64)]| {
for (a, b) in subtract_intervals(s, e, holes) {
let nsc = if a <= s + CUTOUT_EPS { sc } else { None };
let nec = if b >= e - CUTOUT_EPS { ec } else { None };
let mut near_edge = |edge_off: f64, holes: &[Hole]| {
for (a, b, nsc, nec) in subtract_holes(s, e, holes, sc, ec, fr, edge_off, edge_off) {
let jq = clipped_band(axis_pt(a), axis_pt(b), edge_off, edge_off, nsc, nec);
o.line(LINE_OUTLINE, 0, jq[0], jq[1]);
}
@@ -703,6 +828,170 @@ mod tests {
n
}
// ── Schräger T-Stoss mit materialbewusster Verschneidung ──────────────────
enum Prim {
Poly(f64, usize, Vec<V>),
Line(f64, V, V),
}
fn parse(out: &[f64]) -> Vec<Prim> {
let (mut i, mut v) = (1, Vec::new());
for _ in 0..out[0] as usize {
if out[i] == 1.0 {
let q = i + 4 + out[i + 3] as usize;
v.push(Prim::Poly(out[i + 1], out[i + 2] as usize, (0..4).map(|j| super::v(out[q + 2 * j], out[q + 2 * j + 1])).collect()));
i = q + 8;
} else {
v.push(Prim::Line(out[i + 1], super::v(out[i + 3], out[i + 4]), super::v(out[i + 5], out[i + 6])));
i += 7;
}
}
v
}
/// Eingabe wie `encode_wall_poche` (Referenz Mitte) aus Wand und Cuts der Verschneidung.
fn poche_of(w: &crate::joins::JoinWall, c: &crate::joins::WallCuts) -> Vec<f64> {
let th: Vec<f64> = w.layers.as_ref().unwrap().iter().map(|l| l.thickness).collect();
let total: f64 = th.iter().sum();
let mut b = vec![w.start.x, w.start.y, w.end.x, w.end.y, total, 0.0, 0.0, 0.0, th.len() as f64];
b.extend(&th);
let line = |b: &mut Vec<f64>, l: Option<crate::joins::Line>| match l {
Some(l) => b.extend([1.0, l.point.x, l.point.y, l.dir.x, l.dir.y]),
None => b.extend(NO_LINE),
};
line(&mut b, c.start_cut);
line(&mut b, c.end_cut);
match &c.layer_cuts {
Some(lc) => {
b.push(1.0);
for i in 0..th.len() {
line(&mut b, lc.start[i]);
line(&mut b, lc.end[i]);
line(&mut b, lc.start_side[i]);
line(&mut b, lc.end_side[i]);
}
}
None => b.push(0.0),
}
b.push(c.span_cutouts.len() as f64);
for k in &c.span_cutouts {
b.extend([k.from, k.to, k.off_a, k.off_b, k.from_b, k.to_b]);
}
b.push(0.0);
b
}
fn inside(poly: &[V], p: V) -> bool {
// Konvexes Viereck: Punkt strikt innen (1e-7), beliebiger Umlaufsinn.
let mut sgn = 0.0;
for i in 0..poly.len() {
let c = cross(sub(poly[(i + 1) % poly.len()], poly[i]), sub(p, poly[i]));
if c.abs() < 1e-7 {
return false;
}
if sgn == 0.0 {
sgn = c.signum();
} else if c.signum() != sgn {
return false;
}
}
true
}
#[test]
fn schraeger_t_stoss_grundriss_exakt_15_bis_165_grad() {
use crate::joins::{compute_joins, JoinLayer, JoinWall, Reference};
let lay = || vec![JoinLayer { thickness: 0.02, component: Some(0), priority: 10.0 }, JoinLayer { thickness: 0.16, component: Some(1), priority: 20.0 }, JoinLayer { thickness: 0.15, component: Some(2), priority: 50.0 }, JoinLayer { thickness: 0.015, component: Some(3), priority: 10.0 }];
let jw = |s: (f64, f64), e: (f64, f64)| JoinWall { start: kernel2d::Vec2::new(s.0, s.1), end: kernel2d::Vec2::new(e.0, e.1), reference: Reference::Center, layers: Some(lay()) };
let face = 0.345 / 2.0;
let merge = face - 0.015;
for deg in (15..=165).step_by(15) {
let th = (deg as f64).to_radians();
let b1 = (5.0 + 3.0 * th.cos(), 3.0 * th.sin());
// Mittelspannen-T und Knoten-T (Durchgang aus zwei Hälften).
for walls in [vec![jw((0.0, 0.0), (10.0, 0.0)), jw((5.0, 0.0), b1)], vec![jw((0.0, 0.0), (5.0, 0.0)), jw((5.0, 0.0), (10.0, 0.0)), jw((5.0, 0.0), b1)]] {
let deg = format!("{deg}° ({} Wände)", walls.len());
let bi = walls.len() - 1;
let cuts = compute_joins(&walls).unwrap();
let thr: Vec<Prim> = (0..bi).flat_map(|i| parse(&wall_poche(&poche_of(&walls[i], &cuts[i])))).collect();
let br = parse(&wall_poche(&poche_of(&walls[bi], &cuts[bi])));
// Wahre Kreuzung der Kern-Kanten (Backstein, quer 0.0075 … 0.1575) mit Fläche und Rückgrat.
let x_at = |o: f64, f: f64| {
let t = (f - o * th.cos()) / th.sin();
5.0 - o * th.sin() + t * th.cos()
};
let (xa0, xa1) = (x_at(0.0075, face).min(x_at(0.1575, face)), x_at(0.0075, face).max(x_at(0.1575, face)));
let (xb0, xb1) = (x_at(0.0075, merge).min(x_at(0.1575, merge)), x_at(0.0075, merge).max(x_at(0.1575, merge)));
// (1) Flächenlinie der Durchgangswand: Lücke genau über der Kern-Kreuzung.
let face_lines: Vec<(f64, f64)> = thr
.iter()
.filter_map(|p| match p {
Prim::Line(a, p, q) if *a == LINE_OUTLINE && (p.y - face).abs() < 1e-9 => Some((p.x.min(q.x), p.x.max(q.x))),
_ => None,
})
.collect();
let on_face = |x: f64| face_lines.iter().any(|&(a, b)| a <= x && x <= b);
assert!(face_lines.iter().any(|l| (l.1 - xa0).abs() < 1e-9) && face_lines.iter().any(|l| (l.0 - xa1).abs() < 1e-9), "{deg} {face_lines:?} {xa0} {xa1}");
assert!(on_face(xa0 - 1e-4) && on_face(xa1 + 1e-4) && !on_face((xa0 + xa1) / 2.0), "{deg} {face_lines:?}");
// (2) Umriss des Abzweigs endet genau auf der Fläche.
let outline = br.iter().find_map(|p| match p {
Prim::Poly(a, _, pts) if *a == ART_OUTLINE => Some(pts.clone()),
_ => None,
});
let o = outline.unwrap();
assert!((o[0].y - face).abs() < 1e-9 && (o[3].y - face).abs() < 1e-9, "{deg}° {:?}", o);
// (3) Kern-Band des Abzweigs endet auf der Rückgrat-Fläche, genau an den Lochseiten.
let core = br.iter().find_map(|p| match p {
Prim::Poly(a, 2, pts) if *a == ART_BAND => Some(pts.clone()),
_ => None,
});
let c = core.unwrap();
let mut ends = [c[0].x, c[3].x];
ends.sort_by(|a, b| a.partial_cmp(b).unwrap());
assert!((c[0].y - merge).abs() < 1e-9 && (c[3].y - merge).abs() < 1e-9, "{deg}°");
assert!((ends[0] - xb0).abs() < 1e-9 && (ends[1] - xb1).abs() < 1e-9, "{deg}° {ends:?} {xb0} {xb1}");
// Fugen beidseits des Kerns laufen bis zur Rückgrat-Fläche (Kern gegen Nah-Putz), die
// übrige bleibt an der Fläche.
let joints: Vec<f64> = br
.iter()
.filter_map(|p| match p {
Prim::Line(a, p, q) if *a == LINE_JOINT => Some(p.y.min(q.y)),
_ => None,
})
.collect();
assert_eq!(joints.len(), 3, "{deg}");
assert!((joints[0] - face).abs() < 1e-9 && (joints[1] - merge).abs() < 1e-9 && (joints[2] - merge).abs() < 1e-9, "{deg} {joints:?}");
// (4) Keine Schraffur der Durchgangswand im Kern des Abzweigs, keine Linie quer durch die Lücke.
// Mitte des Lochs und nahe seiner beiden schrägen Seiten (auf halber Putzdicke).
let (l, r) = ((xa0 + xb0) / 2.0, (xa1 + xb1) / 2.0);
let probes = [super::v((l + r) / 2.0, (face + merge) / 2.0), super::v(l * 0.97 + r * 0.03, (face + merge) / 2.0), super::v(l * 0.03 + r * 0.97, (face + merge) / 2.0)];
for p in thr.iter() {
if let Prim::Poly(a, _, pts) = p {
if *a == ART_BAND {
for q in &probes {
assert!(!inside(pts, *q), "{deg}° Band der Durchgangswand deckt {q:?}");
}
}
}
if let Prim::Line(_, p, q) = p {
for y in [face, merge] {
if (p.y - y).abs() < 1e-9 && (q.y - y).abs() < 1e-9 {
let (g0, g1) = if y == face { (xa0, xa1) } else { (xb0, xb1) };
let m = (g0 + g1) / 2.0;
assert!(!(p.x.min(q.x) < m && p.x.max(q.x) > m), "{deg}° Linie quer durch die Lücke bei y={y}");
}
}
}
}
}
}
}
#[test]
fn intervalle_abziehen() {
assert_eq!(subtract_intervals(0.0, 5.0, &[]), vec![(0.0, 5.0)]);
+259 -10
View File
@@ -144,6 +144,11 @@ pub struct Piece {
pub z_top: f64,
pub top_drop: Option<[f64; 2]>,
pub holes: Vec<[f64; 4]>,
/// Schnittlinie (Welt) am Körper-Anfang/-Ende: Gehrung, T-Stoss-Fläche oder schräge Seite einer
/// Nah-Putz-Aussparung. Die Band-Kanten (±Dicke/2) enden auf ihr statt rechtwinklig; der Körper
/// beginnt/endet dort, wo die Band-Mittellinie sie trifft. `None`: rechtwinklig.
pub start_cut: Option<Line>,
pub end_cut: Option<Line>,
/// Eigene Dicke (Schichteinzug-Stück, [106]); `None` = Banddicke.
pub thickness: Option<f64>,
}
@@ -326,6 +331,83 @@ fn subtract_spans(lo: f64, hi: f64, holes: &[[f64; 2]]) -> Vec<[f64; 2]> {
parts
}
/// Loch einer Nah-Putz-Aussparung in einem Band: Achsmass `[a, b]` auf der Band-Mittellinie, die
/// schrägen Seiten (Welt) und deren Achsmass-Spanne `(min, max)` über die Banddicke.
#[derive(Clone, Copy, Debug)]
struct BandHole {
a: f64,
b: f64,
la: Line,
lb: Line,
la_rng: (f64, f64),
lb_rng: (f64, f64),
}
/// Wie [`subtract_spans`], jedes Teilstück mit den Schnittlinien an seinen Enden: am Rand `lo`/`hi`
/// `lo_cut`/`hi_cut`, an einem Loch dessen (schräge) Seite. Ragt die schräge Seite eines Lochs
/// jenseits eines rechtwinkligen Wandendes ins Band (Knoten-T: das Loch liegt auf der Nachbarhälfte),
/// endet das Band an dieser Seite statt am Wandende; ein Teilstück, dessen Enden sich über die
/// Banddicke kreuzen (`valid` = falsch), entfällt — die Nachbarhälfte deckt es.
fn subtract_spans_cut(
lo: f64,
hi: f64,
holes: &[BandHole],
lo_cut: Option<Line>,
hi_cut: Option<Line>,
valid: impl Fn(f64, f64, Option<Line>, Option<Line>) -> bool,
) -> Vec<([f64; 2], Option<Line>, Option<Line>)> {
let (mut lo, mut hi, mut lo_cut, mut hi_cut) = (lo, hi, lo_cut, hi_cut);
{
if let Some(h) = holes.iter().filter(|h| h.a >= hi - EPS && h.la_rng.0 < hi - EPS).min_by(|p, q| p.a.total_cmp(&q.a)) {
hi = h.a;
hi_cut = Some(h.la);
}
}
{
if let Some(h) = holes.iter().filter(|h| h.b <= lo + EPS && h.lb_rng.1 > lo + EPS).max_by(|p, q| p.b.total_cmp(&q.b)) {
lo = h.b;
lo_cut = Some(h.lb);
}
}
let mut clipped: Vec<BandHole> = holes.iter().map(|h| BandHole { a: lo.max(h.a), b: hi.min(h.b), ..*h }).filter(|h| h.b > h.a + EPS).collect();
clipped.sort_by(|p, q| p.a.partial_cmp(&q.a).unwrap_or(std::cmp::Ordering::Equal));
let mut parts = Vec::new();
let (mut cursor, mut cursor_cut) = (lo, lo_cut);
for h in clipped {
if h.a > cursor + EPS {
parts.push(([cursor, h.a], cursor_cut, Some(h.la)));
}
if h.b > cursor {
cursor = h.b;
cursor_cut = Some(h.lb);
}
}
if cursor < hi - EPS {
parts.push(([cursor, hi], cursor_cut, hi_cut));
}
parts.retain(|&([a, b], sc, ec)| valid(a, b, sc, ec));
parts
}
/// Loch einer Nah-Putz-Aussparung im Band `[band_lo, band_hi]` (Mittellinie `off`).
fn cutout_hole(w: &WallIn, u: Vec2, n: Vec2, c: &crate::joins::SpanCutout, off: f64, band_lo: f64, band_hi: f64) -> BandHole {
let pt = |d: f64, o: f64| add(add(w.start, scale(u, d)), scale(n, o));
let side = |p: f64, q: f64| {
let (a, b) = (pt(p, c.off_a), pt(q, c.off_b));
let dir = sub(b, a);
Line { point: a, dir: if js_hypot(dir.x, dir.y) < 1e-12 { n } else { dir } }
};
let (x0, x1) = c.at(off);
let ((p0, q0), (p1, q1)) = (c.at(band_lo), c.at(band_hi));
let (rp, rq) = ((p0.min(p1), p0.max(p1)), (q0.min(q1), q0.max(q1)));
let (l0, l1) = (side(c.from, c.from_b), side(c.to, c.to_b));
if x0 <= x1 {
BandHole { a: x0, b: x1, la: l0, lb: l1, la_rng: rp, lb_rng: rq }
} else {
BandHole { a: x1, b: x0, la: l1, lb: l0, la_rng: rq, lb_rng: rp }
}
}
/// Decken-z-Cutter auf `[lo, hi]` je Terminierung: ausstanzen (beide), unter der Decke enden,
/// über der Decke beginnen.
fn terminate_or_subtract(lo: f64, hi: f64, cutters: &[[f64; 2]], term: Termination) -> Vec<[f64; 2]> {
@@ -390,6 +472,8 @@ impl Emitter<'_> {
z_top: zt,
top_drop: (drop[0] > EPS || drop[1] > EPS).then_some(drop),
holes,
start_cut: None,
end_cut: None,
thickness: None,
});
}
@@ -575,13 +659,25 @@ pub fn wall_bands(w: &WallIn, ctx: &FloorContext) -> Vec<Piece> {
// (2) Nah-Putz-Aussparungen, die dieses Band quer treffen.
let band_lo = off - b.thickness / 2.0;
let band_hi = off + b.thickness / 2.0;
let axis_holes: Vec<[f64; 2]> = cuts
let axis_holes: Vec<BandHole> = cuts
.span_cutouts
.iter()
.filter(|c| band_lo < c.off_a.max(c.off_b) - EPS && band_hi > c.off_a.min(c.off_b) + EPS)
.map(|c| [c.from, c.to])
.map(|c| cutout_hole(w, u, n, c, off, band_lo, band_hi))
.collect();
let axis_pieces = subtract_spans(from0, to0, &axis_holes);
// Teilstück gültig, wenn es an beiden Band-Kanten eine positive Länge hat.
let valid = |a: f64, b: f64, sc: Option<Line>, ec: Option<Line>| {
[band_lo, band_hi].iter().all(|&e| {
let ps = sc.and_then(|l| band_cut_distance(w, u, n, e, &l)).unwrap_or(a);
let pe = ec.and_then(|l| band_cut_distance(w, u, n, e, &l)).unwrap_or(b);
pe > ps + EPS
})
};
let axis_pieces = if axis_holes.is_empty() {
vec![([from0, to0], s_cut, e_cut)]
} else {
subtract_spans_cut(from0, to0, &axis_holes, s_cut, e_cut, valid)
};
// (3) Decken-Subtraktion je Band dort, wo der Decken-Umriss die Band-Mittellinie deckt.
let mut band_z_cuts: Vec<[f64; 4]> = Vec::new(); // from, to, zBottom, zTop
@@ -598,11 +694,11 @@ pub fn wall_bands(w: &WallIn, ctx: &FloorContext) -> Vec<Piece> {
let innermost = li == n_bands - 1;
let recess = b.thickness;
let mut emit_piece = |a: f64, bb: f64, zb: f64, zt_start: f64, zt_end: f64| {
emit_band_piece(&mut em, li, off, &cutouts, innermost, recess, a, bb, zb, zt_start, zt_end);
};
for [a, bb] in axis_pieces {
for ([a, bb], cut_a, cut_b) in axis_pieces {
let n0 = em.out.len();
let mut emit_piece = |a: f64, bb: f64, zb: f64, zt_start: f64, zt_end: f64| {
emit_band_piece(&mut em, li, off, &cutouts, innermost, recess, a, bb, zb, zt_start, zt_end);
};
let local: Vec<[f64; 4]> = band_z_cuts
.iter()
.map(|c| [a.max(c[0]), bb.min(c[1]), c[2], c[3]])
@@ -610,6 +706,7 @@ pub fn wall_bands(w: &WallIn, ctx: &FloorContext) -> Vec<Piece> {
.collect();
if local.is_empty() {
clip_to_roofs(w, ctx, u, n, off, a, bb, z_bottom, z_top, &mut emit_piece);
set_piece_cuts(&mut em.out[n0..], w, u, a, bb, cut_a, cut_b);
continue;
}
let mut xs = vec![a, bb];
@@ -630,12 +727,26 @@ pub fn wall_bands(w: &WallIn, ctx: &FloorContext) -> Vec<Piece> {
clip_to_roofs(w, ctx, u, n, off, xa, xb, zb, zt, &mut emit_piece);
}
}
set_piece_cuts(&mut em.out[n0..], w, u, a, bb, cut_a, cut_b);
}
}
reveal_pieces(&mut em, &offsets);
em.out
}
/// Schnittlinien an die Körper eines Achsenstücks `[a, bb]` hängen: nur Körper, die tatsächlich bei
/// `a` beginnen bzw. bei `bb` enden (Decken-/Dach-Teilungen dazwischen bleiben rechtwinklig).
fn set_piece_cuts(pieces: &mut [Piece], w: &WallIn, u: Vec2, a: f64, bb: f64, cut_a: Option<Line>, cut_b: Option<Line>) {
for p in pieces {
if (dot(sub(p.start, w.start), u) - a).abs() < EPS {
p.start_cut = cut_a;
}
if (dot(sub(p.end, w.start), u) - bb).abs() < EPS {
p.end_cut = cut_b;
}
}
}
/// Zusatzstücke des Schichteinzugs ([106]) als eigene Körper der Schicht: Leibungen über die
/// Öffnungshöhe (ohne die Ecken der Sturz-/Brüstungsstücke derselben Schicht), Sturz/Brüstung
/// über die ganze Öffnungsbreite.
@@ -704,7 +815,7 @@ fn emit_band_piece(em: &mut Emitter, li: usize, off: f64, cutouts: &[OpeningIn],
#[cfg(test)]
mod tests {
use super::*;
use crate::joins::{compute_joins, JoinLayer, JoinWall, SpanCutout};
use crate::joins::{compute_joins, JoinLayer, JoinWall, Line, SpanCutout};
fn base(start: (f64, f64), end: (f64, f64), bands: Vec<BandIn>) -> WallIn {
WallIn {
@@ -765,10 +876,148 @@ mod tests {
assert!(close(p[0].start.x, 0.0));
}
// ── Lückenlose Verschneidung (schräge T-, L-, X-Stösse) ──────────────────
/// Vorzeichenbehafteter Abstand zum Rand eines konvexen Vierecks (innen positiv).
fn quad_margin(q: &[Vec2; 4], p: Vec2) -> f64 {
let area: f64 = (0..4).map(|i| kernel2d::cross(q[i], q[(i + 1) % 4])).sum();
let s = area.signum();
(0..4)
.map(|i| {
let (a, b) = (q[i], q[(i + 1) % 4]);
let d = sub(b, a);
s * kernel2d::cross(d, sub(p, a)) / js_hypot(d.x, d.y)
})
.fold(f64::INFINITY, f64::min)
}
/// Grundriss eines Körpers: Band-Kanten ±Dicke/2, an den Schnittlinien verschnitten (wie
/// `extrude_layer_segment` in render3d).
fn footprint(w: &WallIn, p: &Piece) -> [Vec2; 4] {
let u = sub(w.end, w.start);
let u = scale(u, 1.0 / js_hypot(u.x, u.y));
let n = left_normal(u);
let h = w.bands[p.band].thickness / 2.0;
let clip = |base: Vec2, c: Option<Line>| c.and_then(|c| line_intersect(base, u, c.point, c.dir)).unwrap_or(base);
[clip(add(p.start, scale(n, h)), p.start_cut), clip(add(p.end, scale(n, h)), p.end_cut), clip(add(p.end, scale(n, -h)), p.end_cut), clip(add(p.start, scale(n, -h)), p.start_cut)]
}
/// Prüft im Kasten `bb` auf einem Raster: jeder Punkt der Soll-Fläche (Vereinigung `region`) ist
/// von genau einem Körper gedeckt (keine Lücke, keine Doppelung), kein Körper ragt hinaus.
fn assert_watertight(label: &str, walls: &[WallIn], region: &[[Vec2; 4]], bb: [f64; 4]) {
let fps: Vec<[Vec2; 4]> = walls.iter().flat_map(|w| bands_of(w).into_iter().map(move |p| footprint(w, &p))).collect();
let tol = 1e-6;
let steps = 150;
for i in 0..=steps {
for j in 0..=steps {
let p = Vec2::new(bb[0] + (bb[2] - bb[0]) * i as f64 / steps as f64 + 1.3e-5, bb[1] + (bb[3] - bb[1]) * j as f64 / steps as f64 + 0.7e-5);
let m = region.iter().map(|q| quad_margin(q, p)).fold(f64::NEG_INFINITY, f64::max);
let ms: Vec<f64> = fps.iter().map(|q| quad_margin(q, p)).collect();
let covered = ms.iter().filter(|&&x| x > tol).count();
let touched = ms.iter().filter(|&&x| x > -tol).count();
if m > tol {
assert!(touched >= 1, "{label}: Lücke bei {p:?}");
assert!(covered <= 1, "{label}: Doppelung bei {p:?}");
} else if m < -tol {
assert_eq!(covered, 0, "{label}: Körper ragt hinaus bei {p:?}");
}
}
}
}
fn layered(lay: &[JoinLayer]) -> Vec<BandIn> {
lay.iter().map(|l| band(l.thickness, l.priority)).collect()
}
fn walls_with_cuts(jw: &[JoinWall]) -> Vec<WallIn> {
let cuts = compute_joins(jw).unwrap();
jw.iter()
.zip(cuts)
.map(|(j, c)| {
let mut w = base((j.start.x, j.start.y), (j.end.x, j.end.y), layered(j.layers.as_ref().unwrap()));
w.cuts = c;
w
})
.collect()
}
fn strip(a: Vec2, b: Vec2, h: f64) -> [Vec2; 4] {
let u = sub(b, a);
let n = scale(left_normal(u), h / js_hypot(u.x, u.y));
[add(a, n), add(b, n), sub(b, n), sub(a, n)]
}
fn lay_sets() -> Vec<(&'static str, Vec<JoinLayer>)> {
let l = |t: f64, c: u32, p: f64| JoinLayer { thickness: t, component: Some(c), priority: p };
vec![
("einschichtig", vec![l(0.25, 0, 100.0)]),
("aussenwand", vec![l(0.02, 0, 10.0), l(0.16, 1, 20.0), l(0.15, 2, 50.0), l(0.015, 3, 10.0)]),
("innenwand", vec![l(0.015, 3, 10.0), l(0.12, 2, 50.0), l(0.015, 3, 10.0)]),
]
}
#[test]
fn schraeger_t_stoss_3d_lueckenlos_15_bis_165_grad() {
for (name, lay) in lay_sets() {
let h: f64 = lay.iter().map(|l| l.thickness).sum::<f64>() / 2.0;
for deg in (15..=165).step_by(15) {
let th = (deg as f64).to_radians();
let b0 = Vec2::new(5.0, 0.0);
let b1 = Vec2::new(5.0 + 3.0 * th.cos(), 3.0 * th.sin());
let jw = |s: Vec2, e: Vec2| JoinWall { start: s, end: e, reference: Reference::Center, layers: Some(lay.clone()) };
// Soll: Durchgangswand + Abzweig ab ihrer Fläche (y = h) bis zum freien Ende.
let ub = scale(sub(b1, b0), 1.0 / 3.0);
let nb = left_normal(ub);
let at_face = |o: f64| {
let e = add(b0, scale(nb, o));
line_intersect(e, ub, Vec2::new(0.0, h), Vec2::new(1.0, 0.0)).unwrap()
};
let branch = [at_face(h), add(b1, scale(nb, h)), add(b1, scale(nb, -h)), at_face(-h)];
let region = [strip(Vec2::new(0.0, 0.0), Vec2::new(10.0, 0.0), h), branch];
let bb = [2.0, -0.4, 8.0, 1.2];
let mid = vec![jw(Vec2::new(0.0, 0.0), Vec2::new(10.0, 0.0)), jw(b0, b1)];
assert_watertight(&format!("{name} T {deg}°"), &walls_with_cuts(&mid), &region, bb);
let node = vec![jw(Vec2::new(0.0, 0.0), b0), jw(b0, Vec2::new(10.0, 0.0)), jw(b0, b1)];
assert_watertight(&format!("{name} Knoten-T {deg}°"), &walls_with_cuts(&node), &region, bb);
}
}
}
#[test]
fn schraege_l_ecke_und_kreuzung_3d_lueckenlos() {
for (name, lay) in lay_sets() {
let h: f64 = lay.iter().map(|l| l.thickness).sum::<f64>() / 2.0;
let jw = |s: Vec2, e: Vec2| JoinWall { start: s, end: e, reference: Reference::Center, layers: Some(lay.clone()) };
for deg in [30.0f64, 60.0, 120.0, 150.0] {
// L: A (0,0)→(4,0), dann B mit Richtungswinkel `deg`.
let th = deg.to_radians();
let (a0, j) = (Vec2::new(0.0, 0.0), Vec2::new(4.0, 0.0));
let b1 = add(j, Vec2::new(3.0 * th.cos(), 3.0 * th.sin()));
let (ua, ub) = (Vec2::new(1.0, 0.0), scale(sub(b1, j), 1.0 / 3.0));
let (na, nb) = (left_normal(ua), left_normal(ub));
let apex = |o: f64| line_intersect(add(a0, scale(na, o)), ua, add(j, scale(nb, o)), ub).unwrap();
let (pl, pr) = (apex(h), apex(-h));
let ra = [add(a0, scale(na, h)), pl, pr, add(a0, scale(na, -h))];
let rb = [pl, add(b1, scale(nb, h)), add(b1, scale(nb, -h)), pr];
let walls = walls_with_cuts(&[jw(a0, j), jw(j, b1)]);
assert_watertight(&format!("{name} L {deg}°"), &walls, &[ra, rb], [2.5, -1.5, 5.5, 1.5]);
}
for deg in [30.0f64, 45.0, 135.0] {
// X: Durchgangswand und zwei Hälften einer schrägen Wand, Knoten auf der Achse.
let th = deg.to_radians();
let c = Vec2::new(5.0, 0.0);
let d = Vec2::new(2.0 * th.cos(), 2.0 * th.sin());
let walls = walls_with_cuts(&[jw(Vec2::new(0.0, 0.0), Vec2::new(10.0, 0.0)), jw(sub(c, d), c), jw(c, add(c, d))]);
let region = [strip(Vec2::new(0.0, 0.0), Vec2::new(10.0, 0.0), h), strip(sub(c, d), add(c, d), h)];
assert_watertight(&format!("{name} X {deg}°"), &walls, &region, [3.0, -1.0, 7.0, 1.0]);
}
}
}
#[test]
fn t_stoss_aussparung_bricht_band_auf() {
let mut w = base((0.0, 0.0), (6.0, 0.0), vec![band(0.02, 10.0), band(0.15, 50.0), band(0.015, 10.0)]);
w.cuts.span_cutouts.push(SpanCutout { from: 2.0, to: 2.15, off_a: 0.0925, off_b: 0.0775 });
w.cuts.span_cutouts.push(SpanCutout { from: 2.0, to: 2.15, off_a: 0.0925, off_b: 0.0775, from_b: 2.0, to_b: 2.15 });
let p = bands_of(&w);
// Aussenputz und Kern durchgehend, Innenputz (Band 2) in zwei Stücken.
assert_eq!(p.iter().filter(|q| q.band == 2).count(), 2);
@@ -37,6 +37,8 @@ fn l_wall_scene() -> (Vec<WallInput>, Vec<SlabInput>) {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
},
WallInput {
top_drop: [0.0, 0.0],
@@ -52,6 +54,8 @@ fn l_wall_scene() -> (Vec<WallInput>, Vec<SlabInput>) {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
},
// "Spaeh"-Wand: kurzer Stummel HINTER Schenkel A (groesseres Modell-X,
// also groessere Tiefe von der Betrachter-Ebene aus), genau im
@@ -72,6 +76,8 @@ fn l_wall_scene() -> (Vec<WallInput>, Vec<SlabInput>) {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
},
];
let slabs = vec![SlabInput {
+2
View File
@@ -43,6 +43,8 @@ fn demo_walls() -> Vec<WallInput> {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
// Raum 6 x 4 m.
vec![
+40
View File
@@ -85,6 +85,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
}
}
@@ -191,6 +193,28 @@ mod tests {
assert!((max_idx as usize) < mesh.vertex_count());
}
#[test]
fn explizite_schnittlinie_schraegt_das_wandende() {
// Schräger T-Stoss ([108]): der Anfang endet auf der Linie y = x (45°), nicht rechtwinklig.
let w = WallInput { start: [0.5, 0.0], end: [4.0, 0.0], start_cut: Some([0.0, 0.0, 1.0, 1.0]), ..wall_x(4.0, 0.2, 2.5) };
let mesh = build_walls_mesh(&[w.clone()]);
let mut on_line = 0;
for i in 0..mesh.vertex_count() {
let (p, _) = vert(&mesh, i);
assert!(p[0] >= -0.1 - 1e-5, "kein Punkt vor der Schnittlinie: {p:?}");
if p[0] < 0.2 {
assert!((p[0] - p[2]).abs() < 1e-5, "Anfangs-Ecke liegt auf y = x: {p:?}");
on_line += 1;
}
}
assert!(on_line > 0);
// Das geschnittene Ende ist angeschlossen: keine Schraffur-Kappe dort (nur am freien Ende).
let hatched = WallInput { hatch: Some(Hatch { pattern: 3, angle: 45.0, scale: 1.0, line_weight: 0.13, top_angle: None }), ..w };
let caps = build_free_wall_end_caps(&[hatched]);
let caps_free = build_free_wall_end_caps(&[WallInput { start_cut: None, ..wall_x_hatched(4.0, 0.2, 2.5) }]);
assert!(caps.len() < caps_free.len(), "angeschlossenes Ende ohne Kappe");
}
/// `wall_x` mit gesetzter Bauteil-Schraffur (Voraussetzung fuer die Kappen).
fn wall_x_hatched(len: f32, thickness: f32, height: f32) -> WallInput {
WallInput {
@@ -293,6 +317,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
},
]);
assert_eq!(mesh.vertex_count(), 2 * VERTS_PER_BOX);
@@ -376,6 +402,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
let mut mesh = Mesh::default();
extrude_wall(&mut mesh, &w);
@@ -402,6 +430,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
let mesh = build_walls_mesh(&[w]);
assert_eq!(mesh.vertex_count(), 0);
@@ -620,6 +650,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
let b = WallInput {
top_drop: [0.0, 0.0],
@@ -635,6 +667,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
let mesh = build_walls_mesh(&[a, b]);
assert_eq!(mesh.vertex_count(), 2 * VERTS_PER_BOX, "weiterhin zwei Quader");
@@ -699,6 +733,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
let walls = vec![
mk([0.0, 0.0], [3.0, 0.0]),
@@ -732,6 +768,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
let walls = vec![
mk([0.0, 0.0], [3.0, 0.0], 0.0),
@@ -825,6 +863,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
let mut b = a.clone();
b.end = [0.0, 3.0];
+20
View File
@@ -842,6 +842,17 @@ fn compute_wall_miters(walls: &[WallInput]) -> Vec<WallMiters> {
apply_cut(&mut out, b, cut);
}
}
// Explizite Schnittlinien aus dem Kern (Gehrung, T-Stoss-Fläche, schräge Aussparungs-Seite)
// übersteuern die abgeleitete Gehrung — sie kennen auch Stösse ohne gemeinsamen Endpunkt.
let line = |c: [f32; 4]| MiterLine { point: [c[0], c[1]], dir: [c[2], c[3]] };
for (i, w) in walls.iter().enumerate() {
if let Some(c) = w.start_cut {
out[i].start = Some(line(c));
}
if let Some(c) = w.end_cut {
out[i].end = Some(line(c));
}
}
out
}
@@ -894,6 +905,15 @@ fn compute_free_wall_ends(walls: &[WallInput]) -> Vec<(bool, bool)> {
}
}
}
// Explizite Schnittlinie (Kern-Verschneidung): das Ende ist angeschlossen, nicht frei.
for (i, w) in walls.iter().enumerate() {
if w.start_cut.is_some() {
out[i].0 = false;
}
if w.end_cut.is_some() {
out[i].1 = false;
}
}
out
}
+12
View File
@@ -1239,6 +1239,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
},
WallInput {
top_drop: [0.0, 0.0],
@@ -1254,6 +1256,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
},
];
let slabs = vec![SlabInput {
@@ -1330,6 +1334,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
// Vorderwand bei y=0, Rueckwand bei y=6, Schnitt bei y=2 Blick nach +y.
let walls = vec![mk([0.0, 0.0], [8.0, 0.0]), mk([0.0, 6.0], [8.0, 6.0])];
@@ -1554,6 +1560,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
}
}
@@ -1644,6 +1652,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
// Blick von y = -2 nach +Y: beide Waende (y=0 bzw. y=1) liegen dahinter.
let plane = SectionPlane::looking_plus_y(-2.0);
@@ -1763,6 +1773,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
// Pultdach-Flaeche wie in roof_cut.rs-Tests: First entlang Welt-Z,
// steigt von X=0 (Traufe) zu X=4 (First) an.
+10
View File
@@ -308,6 +308,8 @@ mod tests {
top_angle: None,
}),
cut: None,
start_cut: None,
end_cut: None,
};
let plane = SectionPlane::looking_plus_x(1.5);
let verts = build_cut_caps(&plane, &[wall], &[], &[]);
@@ -349,6 +351,8 @@ mod tests {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
let plane = SectionPlane::looking_plus_x(1.5);
let verts = build_cut_caps(&plane, &[wall], &[], &[]);
@@ -388,6 +392,8 @@ mod tests {
line_color: None,
line_weight: None,
}),
start_cut: None,
end_cut: None,
};
// Decken-Slab, deren Umriss die Wand an der Schnittstelle (x=1.5) ueberdeckt,
// z in [2.0, 2.4]; Prio 100 (Beton laeuft durch, schneidet die Wand).
@@ -463,6 +469,8 @@ mod tests {
line_color: None,
line_weight: None,
}),
start_cut: None,
end_cut: None,
};
// Estrich-Slab (Prio 30, Muster 3 crosshatch), z in [1.0,1.06], deckt die
// Wand in u ab (Umriss ueber y in [-1,1]).
@@ -546,6 +554,8 @@ mod tests {
line_color: Some(color),
line_weight: Some(2.0),
}),
start_cut: None,
end_cut: None,
};
let plane = SectionPlane::looking_plus_x(1.5);
let verts = build_cut_cap_lines(&plane, &[wall.clone()], &[], &[]);
+8
View File
@@ -190,6 +190,14 @@ pub struct WallInput {
/// Subtraktion, Default-Schnittkante).
#[serde(default)]
pub cut: Option<CutBandMeta>,
/// Explizite Schnittlinie `[px, py, dx, dy]` (Modell-Meter, Grundriss) am Wandanfang/-ende
/// (Gehrung, T-Stoss-Fläche, schräge Aussparungs-Seite aus dem Kern): die Kanten ±Dicke/2
/// enden auf ihr. Übersteuert die aus Nachbar-Enden abgeleitete Gehrung; das Ende gilt dann
/// nicht als frei.
#[serde(default, rename = "startCut")]
pub start_cut: Option<[f32; 4]>,
#[serde(default, rename = "endCut")]
pub end_cut: Option<[f32; 4]>,
}
/// Ein rechteckiges Loch (Fenster/Tuer) in EINEM Wandkoerper. Siehe
+2
View File
@@ -350,6 +350,8 @@ fn demo_walls() -> Vec<WallInput> {
material_index: None,
hatch: None,
cut: None,
start_cut: None,
end_cut: None,
};
vec![
mk([0.0, 0.0], [6.0, 0.0]),
+18 -10
View File
@@ -13,7 +13,8 @@
<polygon points="0.0075,4.665 0.8,4.665 0.8,4.515 0.1575,4.515" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<line x1="0.1575" y1="4.515" x2="0.8" y2="4.515" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="0.1575,4.515 0.8,4.515 0.8,4.5 0.1725,4.5" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<polygon points="-0.1725,4.845 0.8,4.845 0.8,4.5 0.1725,4.5" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="-0.1725,4.845 0.8,4.845 0.8,4.5 0.1725,4.5" fill="none" stroke="none"/>
<path d="M-0.1725,4.845 L0.8,4.845 L0.8,4.5 L0.1725,4.5" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="1.7,4.845 3,4.845 3,4.825 1.7,4.825" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<line x1="1.7" y1="4.825" x2="3" y2="4.825" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="1.7,4.825 3,4.825 3,4.665 1.7,4.665" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
@@ -23,7 +24,8 @@
<line x1="2.46" y1="4.515" x2="3" y2="4.515" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="1.7,4.515 2.34,4.515 2.34,4.5 1.7,4.5" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<polygon points="2.46,4.515 3,4.515 3,4.5 2.46,4.5" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<polygon points="1.7,4.845 3,4.845 3,4.5 1.7,4.5" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="1.7,4.845 3,4.845 3,4.5 1.7,4.5" fill="none" stroke="none"/>
<path d="M1.7,4.845 L3,4.845 L3,4.5M1.7,4.5 L1.7,4.845" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<line x1="1.7" y1="4.5" x2="2.34" y2="4.5" stroke="#1a1a1a" stroke-width="0.035"/>
<line x1="2.46" y1="4.5" x2="3" y2="4.5" stroke="#1a1a1a" stroke-width="0.035"/>
<polygon points="4,4.845 5.1725,4.845 5.1525,4.825 4,4.825" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
@@ -33,7 +35,8 @@
<polygon points="4,4.665 4.9925,4.665 4.8425,4.515 4,4.515" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<line x1="4" y1="4.515" x2="4.8425" y2="4.515" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="4,4.515 4.8425,4.515 4.8275,4.5 4,4.5" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<polygon points="4,4.845 5.1725,4.845 4.8275,4.5 4,4.5" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="4,4.845 5.1725,4.845 4.8275,4.5 4,4.5" fill="none" stroke="none"/>
<path d="M4,4.845 L5.1725,4.845M4.8275,4.5 L4,4.5 L4,4.845" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="5.1725,4.845 5.1725,0.5 5.1525,0.52 5.1525,4.825" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<line x1="5.1525" y1="4.825" x2="5.1525" y2="0.52" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="5.1525,4.825 5.1525,0.52 4.9925,0.68 4.9925,4.665" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
@@ -41,7 +44,8 @@
<polygon points="4.9925,4.665 4.9925,0.68 4.8425,0.83 4.8425,4.515" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<line x1="4.8425" y1="4.515" x2="4.8425" y2="0.83" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="4.8425,4.515 4.8425,0.83 4.8275,0.845 4.8275,4.5" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<polygon points="5.1725,4.845 5.1725,0.5 4.8275,0.845 4.8275,4.5" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="5.1725,4.845 5.1725,0.5 4.8275,0.845 4.8275,4.5" fill="none" stroke="none"/>
<path d="M5.1725,4.845 L5.1725,0.5M4.8275,0.845 L4.8275,4.5" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="5.1725,0.5 4.4,0.5 4.4,0.52 5.1525,0.52" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<line x1="5.1525" y1="0.52" x2="4.4" y2="0.52" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="5.1525,0.52 4.4,0.52 4.4,0.68 4.9925,0.68" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
@@ -49,7 +53,8 @@
<polygon points="4.9925,0.68 4.4,0.68 4.4,0.83 4.8425,0.83" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<line x1="4.8425" y1="0.83" x2="4.4" y2="0.83" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="4.8425,0.83 4.4,0.83 4.4,0.845 4.8275,0.845" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<polygon points="5.1725,0.5 4.4,0.5 4.4,0.845 4.8275,0.845" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="5.1725,0.5 4.4,0.5 4.4,0.845 4.8275,0.845" fill="none" stroke="none"/>
<path d="M5.1725,0.5 L4.4,0.5 L4.4,0.845 L4.8275,0.845" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="3,0.5 -0.1725,0.5 -0.1525,0.52 3,0.52" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<line x1="3" y1="0.52" x2="-0.1525" y2="0.52" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="3,0.52 -0.1525,0.52 0.0075,0.68 3,0.68" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
@@ -59,7 +64,8 @@
<line x1="2.34" y1="0.83" x2="0.1575" y2="0.83" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="3,0.83 2.46,0.83 2.46,0.845 3,0.845" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<polygon points="2.34,0.83 0.1575,0.83 0.1725,0.845 2.34,0.845" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<polygon points="3,0.5 -0.1725,0.5 0.1725,0.845 3,0.845" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="3,0.5 -0.1725,0.5 0.1725,0.845 3,0.845" fill="none" stroke="none"/>
<path d="M3,0.5 L-0.1725,0.5M3,0.845 L3,0.5" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<line x1="3" y1="0.845" x2="2.46" y2="0.845" stroke="#1a1a1a" stroke-width="0.035"/>
<line x1="2.34" y1="0.845" x2="0.1725" y2="0.845" stroke="#1a1a1a" stroke-width="0.035"/>
<polygon points="-0.1725,0.5 -0.1725,4.845 -0.1525,4.825 -0.1525,0.52" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
@@ -69,13 +75,15 @@
<polygon points="0.0075,0.68 0.0075,4.665 0.1575,4.515 0.1575,0.83" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<line x1="0.1575" y1="0.83" x2="0.1575" y2="4.515" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="0.1575,0.83 0.1575,4.515 0.1725,4.5 0.1725,0.845" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<polygon points="-0.1725,0.5 -0.1725,4.845 0.1725,4.5 0.1725,0.845" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="-0.1725,0.5 -0.1725,4.845 0.1725,4.5 0.1725,0.845" fill="none" stroke="none"/>
<path d="M-0.1725,0.5 L-0.1725,4.845M0.1725,4.5 L0.1725,0.845" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="2.475,4.5 2.475,0.845 2.46,0.845 2.46,4.5" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<line x1="2.46" y1="4.5" x2="2.46" y2="0.845" stroke="#1a1a1a" stroke-width="0.002"/>
<line x1="2.46" y1="4.515" x2="2.46" y2="0.83" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="2.46,4.515 2.46,0.83 2.34,0.83 2.34,4.515" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<line x1="2.34" y1="4.5" x2="2.34" y2="0.845" stroke="#1a1a1a" stroke-width="0.002"/>
<line x1="2.34" y1="4.515" x2="2.34" y2="0.83" stroke="#1a1a1a" stroke-width="0.002"/>
<polygon points="2.34,4.5 2.34,0.845 2.325,0.845 2.325,4.5" fill="#f0f0f0" stroke="none" stroke-width="0" stroke-linejoin="round"/>
<polygon points="2.475,4.5 2.475,0.845 2.325,0.845 2.325,4.5" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="2.475,4.5 2.475,0.845 2.325,0.845 2.325,4.5" fill="none" stroke="none"/>
<path d="M2.475,4.5 L2.475,0.845M2.325,0.845 L2.325,4.5" fill="none" stroke="#1a1a1a" stroke-width="0.035" stroke-linejoin="round"/>
<polygon points="3.2,4.2725 3.2,4.05917 4.2,4.05917 4.2,4.2725" fill="none" stroke="#1a1a1a" stroke-width="0.0245" stroke-linejoin="round"/>
<line x1="3.2" y1="4.05917" x2="4.2" y2="4.05917" stroke="#1a1a1a" stroke-width="0.035"/>
<polygon points="3.2,4.05917 3.2,3.84583 4.2,3.84583 4.2,4.05917" fill="none" stroke="#1a1a1a" stroke-width="0.0245" stroke-linejoin="round"/>

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 16 KiB