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

# Conflicts:
#	TODO.md
#	src/plan/__golden__/komplex-grundriss-eg-50.txt
#	src/plan/__golden__/komplex-grundriss-og-50.txt
#	src/plan/__golden__/komplex-grundriss-ug-50.txt
#	src/plan/__golden__/komplex-schnitt-schnitt-a.txt
This commit is contained in:
Claude committed 2026-11-09 17:57:15 +00:00
commit 488b8095d0
23 files changed
+631 -96

No files matched your search

@@ -119,8 +119,8 @@ pub(super) fn collect_openings(p: &Project, frame: &[f64; 9]) -> Vec<ProjOpening
wt.map_or(0.0, |t| sash_kind(t.kind)),
// Anschlag nur mit Leibung (Einzug > 0 oder mittig), sonst gibt es keine Wandnase.
match (dt, wt) {
(Some(t), _) if t.inset_face == Some(DoorTypeInsetFace::Mitte) || t.inset_from_face.unwrap_or(0.0) > 1e-4 => t.rebate_depth.unwrap_or(0.0),
(_, Some(t)) if t.inset_face == Some(WindowTypeInsetFace::Mitte) || t.inset_from_face.unwrap_or(0.0) > 1e-4 => t.rebate_depth.unwrap_or(0.0),
(Some(t), _) if t.inset_face == Some(DoorTypeInsetFace::Mitte) || t.inset_from_face.or_else(|| crate::opening_detail::default_frame_inset(p, op)).unwrap_or(0.0) > 1e-4 => t.rebate_depth.unwrap_or(0.0),
(_, Some(t)) if t.inset_face == Some(WindowTypeInsetFace::Mitte) || t.inset_from_face.or_else(|| crate::opening_detail::default_frame_inset(p, op)).unwrap_or(0.0) > 1e-4 => t.rebate_depth.unwrap_or(0.0),
_ => 0.0,
},
if (door && dt.and_then(|t| t.inset_face) == Some(DoorTypeInsetFace::Innen)) || (!door && wt.and_then(|t| t.inset_face) == Some(WindowTypeInsetFace::Innen)) { -1.0 } else { 1.0 },
+2 -2
View File
@@ -299,7 +299,7 @@ fn daemm_striche_quer_zur_wand_im_grundriss() {
}
}
// Fenster mit Anschlag: die Wandnasen (Schichtstücke in der Leibung) schraffiert wie ihre Wand, auch in
// der Bogenwand (radial).
// der Bogenwand (radial) — [168] als Teil der Schicht-Fläche (kein eigenes Öffnungs-Stück mehr).
for (what, arc) in [("Fenster in schräger Wand", false), ("Fenster in Bogenwand", true)] {
let mut p = base();
if arc {
@@ -309,7 +309,7 @@ fn daemm_striche_quer_zur_wand_im_grundriss() {
}
add_window(&mut p, "W1", 1.8);
for scale in [50.0, 20.0] {
assert!(plan_case(&p, scale, what) > 0, "{what}: keine Nasen-Stücke");
assert_eq!(plan_case(&p, scale, what), 0, "{what}: Nase als eigenes Stück");
}
}
}
+3 -3
View File
@@ -406,13 +406,13 @@ pub(super) fn split_wall_layers(cp: &Cut, p: &Project, layers: &[Layer], owner:
}
}
let rect_pts = |r: [f64; 4]| vec![[r[0], r[3]], [r[1], r[3]], [r[1], r[2]], [r[0], r[2]]];
if nibs.is_empty() {
if nibs.is_empty() && pieces.is_empty() {
if vt - vb > 1e-6 {
out.push(mk(rect_pts([u_left, u_right, vb, vt])));
}
out.extend(pieces.into_iter().map(|r| mk(rect_pts(r))));
} else {
// Band, Nase(n) und Zusatzstücke der Schicht als EIN Umriss (keine Fuge an der Nase).
// Band, Nase(n) und Zusatzstücke der Schicht als EIN Umriss (keine Fuge an der Nase, [168]
// auch ohne Nase keine am Schichteinzug).
let mut rects = nibs;
if vt - vb > 1e-6 {
rects.push([u_left, u_right, vb, vt]);
+1 -1
View File
@@ -117,7 +117,7 @@ fn window_cut(p: &Project, wall: &Wall, o: &Opening, c: &CrossSection) -> Result
sashes: sashes_of_window_type(t),
frame_width: t.frame_width.unwrap_or(DEFAULT_FRAME_WIDTH),
frame_depth: t.frame_depth.unwrap_or(f64::NAN),
inset_from_face: t.inset_from_face.unwrap_or(f64::NAN),
inset_from_face: t.inset_from_face.or_else(|| crate::opening_detail::default_frame_inset(p, o)).unwrap_or(f64::NAN),
inset_inner: t.inset_face == Some(WindowTypeInsetFace::Innen),
inset_mid: t.inset_face == Some(WindowTypeInsetFace::Mitte),
frame_width_end: f64::NAN,
+21 -3
View File
@@ -6,6 +6,16 @@ fn sample() -> Project {
serde_json::from_str(include_str!("../../../tests/fixtures/sample_project.json")).unwrap()
}
/// Beispiel mit ausdrücklich aussen bündigen Fenstern (ohne die [168]-Vorgabe bei Aussendämmung:
/// Rahmen in der Leibung, Dämmung überdeckt ihn).
fn sample_flush() -> Project {
let mut p = sample();
for t in p.window_types.iter_mut().flatten() {
t.inset_face = Some(WindowTypeInsetFace::Aussen);
}
p
}
fn level(p: &Project, id: &str) -> LevelSpec {
let l = p.drawing_levels.iter().find(|l| l.id == id).unwrap();
LevelSpec::from_json(&serde_json::to_value(l).unwrap())
@@ -446,7 +456,7 @@ fn sturz_baenke_und_storenkasten_im_schnitt() {
/// Bands (ein Umriss, keine Fuge), nicht als eigenes Öffnungs-Stück. Ohne Anschlag bleibt das Loch glatt.
#[test]
fn anschlag_im_schnitt_sturz_nase_und_bruestung() {
let mut p = sample();
let mut p = sample_flush();
let o1 = p.openings.as_deref().unwrap().iter().find(|o| o.id == "O1").unwrap().clone();
let w1 = p.walls.iter().find(|w| w.id == "W1").unwrap().clone();
let (u, n) = axis_frame(&w1);
@@ -514,12 +524,20 @@ fn anschlag_im_schnitt_sturz_nase_und_bruestung() {
}
let without = section_opening_primitives(&p, &l, &Visibility::default()).unwrap().len();
assert_eq!(with, without);
// [168] Ohne Anschlag (keine Nase): der Schichteinzug (Dämmung überdämmt 3 cm) ist trotzdem Teil des
// Schicht-Bands — eine Fläche, kein eigens umrandetes Stück unter dem Sturz.
for o in p.openings.iter_mut().flatten().filter(|o| o.id == "O1") {
o.layer_reveals = Some(reveal(0.03));
}
let (h, s, k) = edges(&p, "insulation");
assert!((h - (zt - 0.03)).abs() < 1e-6 && (s - (zb + 0.03)).abs() < 1e-6, "{h} {s}");
assert_eq!(k, count["insulation"], "Einzug gehört zum Band");
}
/// [G3] Rundbogen-Fenster: an der Schnittstelle reicht die Wand bis an den Bogen, Rahmen/Glas folgen.
#[test]
fn rundbogen_im_schnitt() {
let mut p = sample();
let mut p = sample_flush();
let o1 = p.openings.as_deref().unwrap().iter().find(|o| o.id == "O1").unwrap().clone();
let w1 = p.walls.iter().find(|w| w.id == o1.host_wall_id).unwrap().clone();
let (u, n) = axis_frame(&w1);
@@ -547,7 +565,7 @@ fn rundbogen_im_schnitt() {
/// am Sturz (Sehne zwischen den Laibungen).
#[test]
fn rundbogen_und_einzug_in_bogenwand() {
let mut p = sample();
let mut p = sample_flush();
p.walls.iter_mut().find(|w| w.id == "W1").unwrap().bulge = Some(-0.3);
let o1 = p.openings.as_deref().unwrap().iter().find(|o| o.id == "O1").unwrap().clone();
let w1 = p.walls.iter().find(|w| w.id == "W1").unwrap().clone();
+40 -4
View File
@@ -765,6 +765,9 @@ fn adjusted_segment(o: &mut Out, g: &Seg, thick: &[f64], off0: f64, layer_cuts:
let x_lo = if cutouts.iter().any(|c| c.lo() < s - CUTOUT_EPS) { ends_at(g.sc, s, false) } else { s };
let x_hi = if cutouts.iter().any(|c| c.hi() > e + CUTOUT_EPS) { ends_at(g.ec, e, true) } else { e };
let mut rects: Vec<(f64, f64, f64, f64, usize)> = Vec::new();
// [168] Flächen je Schicht (Band-Stücke, Zusatzstücke, Anschlag-Nasen) — am Ende je Schicht vereinigt.
let mut fills: Vec<(usize, Vec<V>)> = Vec::new();
let mut side_lines: Vec<(usize, V, V)> = Vec::new();
for li in 0..n_layers {
let (mut a, mut b) = (x_lo, x_hi);
for ad in adj.iter().filter(|ad| ad.layer == li) {
@@ -782,7 +785,7 @@ fn adjusted_segment(o: &mut Out, g: &Seg, thick: &[f64], off0: f64, layer_cuts:
for (pa, pb) in subtract_intervals(a, b, &holes) {
let bsc = if pa <= s + CUTOUT_EPS { start_cut } else { None };
let bec = if pb >= e - CUTOUT_EPS { end_cut } else { None };
o.polygon(ART_BAND, li, band_join_edges, &clipped_band(axis_pt(pa), axis_pt(pb), lo, hi, bsc, bec));
fills.push((li, clipped_band(axis_pt(pa), axis_pt(pb), lo, hi, bsc, bec).to_vec()));
rects.push((pa, pb, lo, hi, li));
}
}
@@ -796,10 +799,10 @@ fn adjusted_segment(o: &mut Out, g: &Seg, thick: &[f64], off0: f64, layer_cuts:
line_intersect(pt, u_seg, cut.point, cut.dir).unwrap_or(pt)
};
if let Some(c) = side_start {
o.line(LINE_JOINT_L, li, side_point(g.p1, lo, c), side_point(g.p1, hi, c));
side_lines.push((li, side_point(g.p1, lo, c), side_point(g.p1, hi, c)));
}
if let Some(c) = side_end {
o.line(LINE_JOINT_L, li, side_point(g.p2, lo, c), side_point(g.p2, hi, c));
side_lines.push((li, side_point(g.p2, lo, c), side_point(g.p2, hi, c)));
}
}
for ad in adj {
@@ -809,10 +812,43 @@ fn adjusted_segment(o: &mut Out, g: &Seg, thick: &[f64], off0: f64, layer_cuts:
if x1 - x0 <= CUTOUT_EPS || y1 - y0 <= CUTOUT_EPS {
continue;
}
o.polygon(ART_BAND, ad.layer, &[], &clipped_band(axis_pt(x0), axis_pt(x1), y0, y1, None, None));
fills.push((ad.layer, clipped_band(axis_pt(x0), axis_pt(x1), y0, y1, None, None).to_vec()));
rects.push((x0, x1, y0, y1, ad.layer));
}
}
// [168] Je Schicht EINE Fläche aus Band, Einzug und Nase (i_overlay): Füllung und Schraffur laufen
// durch, wie in der Schicht selbst. Nur Einzelringe; mit Loch (kommt hier nicht vor) die Stücke.
for li in 0..n_layers {
let group: Vec<&Vec<V>> = fills.iter().filter(|f| f.0 == li).map(|f| &f.1).collect();
if group.len() > 1 {
let polys: Vec<crate::flat::Polygon> = group.iter().map(|r| vec![r.iter().map(|p| [p.x, p.y]).collect()]).collect();
let merged = crate::polygon_bool::union(&polys);
if !merged.is_empty() && merged.iter().all(|m| m.len() == 1) {
// i_overlay rechnet auf einem Ganzzahlraster: Ecken auf die Eingabe zurückrasten (die
// Bogenwand biegt nur Kanten mit exakt gleichem Querversatz, `Unroll::is_arc_edge`).
let inp: Vec<V> = group.iter().flat_map(|r| r.iter().copied()).collect();
let snap1 = |x: f64, pick: fn(&V) -> f64| inp.iter().map(pick).filter(|c| (c - x).abs() < 1e-6).min_by(|a, b| (a - x).abs().total_cmp(&(b - x).abs())).unwrap_or(x);
let snap = |q: &[f64; 2]| -> V {
let p = v(q[0], q[1]);
match inp.iter().filter(|r| (r.x - p.x).hypot(r.y - p.y) < 1e-6).min_by(|a, b| (a.x - p.x).hypot(a.y - p.y).total_cmp(&(b.x - p.x).hypot(b.y - p.y))) {
Some(r) => *r,
None => v(snap1(p.x, |r| r.x), snap1(p.y, |r| r.y)),
}
};
for m in &merged {
let pts: Vec<V> = m[0].iter().map(snap).collect();
o.polygon(ART_BAND, li, &[], &pts);
}
continue;
}
}
for r in group {
o.polygon(ART_BAND, li, band_join_edges, r);
}
}
for (li, a, b) in side_lines {
o.line(LINE_JOINT_L, li, a, b);
}
// Raster der Teilflächen.
let mut xs: Vec<f64> = vec![x_lo, x_hi];
let mut ys: Vec<f64> = offs.clone();
+205 -30
View File
@@ -232,9 +232,10 @@ pub fn thin_layer_targets(thick: &[f64], detail: Detail, scale: f64) -> Vec<usiz
.collect()
}
/// Wand-Poché (`addWallPoche`).
/// Wand-Poché (`addWallPoche`). `true`: in Schichten gezeichnet — Schichteinzug und Anschlag-Nasen
/// (`reveals`) sind darin enthalten ([168]); sonst (Ansicht, schwarze Sammelfläche) nicht.
#[allow(clippy::too_many_arguments)]
fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)], cuts: &WallCuts, greyed: bool, wall_lw: f64, category: Option<&LayerCategory>, view_only: bool, reveals: &[f64], bend: Option<&Unroll>) -> Result<(), String> {
fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)], cuts: &WallCuts, greyed: bool, wall_lw: f64, category: Option<&LayerCategory>, view_only: bool, reveals: &[f64], bend: Option<&Unroll>) -> Result<bool, String> {
let p = c.p;
let w = e.w;
let detail = c.a.detail;
@@ -255,8 +256,9 @@ fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)
let f = crate::plan::wall_poche::wall_poche(&encode_wall_poche(w, &thick, total, ref_off, gaps, cuts, solid && !layered_solid, view_only, reveals));
let target = thin_layer_targets(&thick, detail, c.a.scale);
if f.is_empty() {
return Ok(());
return Ok(false);
}
let layered = !view_only && !(solid && !layered_solid);
let ov_of = |li: usize| lov.get(target.get(li).copied().unwrap_or(li));
// Stil einer Schicht mit Override bzw. schwarz (Schicht ohne Override in `layered_solid`).
let apply_ov = |li: usize, (hatch, fill): (HatchRender, String)| -> (HatchRender, String) {
@@ -372,7 +374,7 @@ fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)
}
}
}
Ok(())
Ok(layered)
}
/// [141] Gerichtete Schichtmuster (Dämmschlange, Zickzack, Welle, Holzkreuz) an den Wandenden
@@ -538,7 +540,7 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
1.0,
t.frame_width.unwrap_or(0.06),
b01(t.frame_kind == Some(DoorTypeFrameKind::Blockrahmen)),
t.inset_from_face.unwrap_or(0.0),
t.inset_from_face.or_else(|| crate::opening_detail::default_frame_inset(p, o)).unwrap_or(0.0),
match t.inset_face {
Some(DoorTypeInsetFace::Innen) => 1.0,
Some(DoorTypeInsetFace::Mitte) => 2.0,
@@ -564,7 +566,8 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
None => {
b.push(wt.map_or(0.0, |t| t.frame_width.unwrap_or(0.06)));
b.push(wt.and_then(|t| t.frame_depth).unwrap_or(f64::NAN));
b.push(wt.and_then(|t| t.inset_from_face).unwrap_or(f64::NAN));
// [168] Ohne Lage: Vorgabe bei Aussendämmung (Rahmen in der Leibung der tragenden Schicht).
b.push(wt.and_then(|t| t.inset_from_face).or_else(|| crate::opening_detail::default_frame_inset(p, o)).unwrap_or(f64::NAN));
b.push(match wt.and_then(|t| t.inset_face) {
Some(WindowTypeInsetFace::Innen) => 1.0,
Some(WindowTypeInsetFace::Mitte) => 2.0,
@@ -888,7 +891,7 @@ pub fn plan_walls(c: &Ctx, reference_lines: bool, out: &mut Vec<Primitive>, boun
let cut = cut_by_id.get(w.id.as_str()).copied().unwrap_or(&empty);
let (zb, zt) = p.wall_vertical_extent(w);
let view_only = zt < cut_z || zb > cut_z;
let reveals = crate::opening_detail::plan_reveal_block(p, w, &openings);
let mut reveals = crate::opening_detail::plan_reveal_block(p, w, &openings);
let (unroll, cut_u) = match &arc_wall {
Some((arc, _)) => {
let total = p.wall_thickness(w, 0.2);
@@ -899,14 +902,42 @@ pub fn plan_walls(c: &Ctx, reference_lines: bool, out: &mut Vec<Primitive>, boun
}
None => (None, WallCuts::default()),
};
// [168] Öffnungs-Symbole vorab (auf der Ersatzwand `wv`, noch nicht gebogen): ihre Anschlag-Nasen
// (Schichtstücke an den Leibungen) zeichnet die Poché als Teil ihrer Schicht mit — eine Fläche,
// durchlaufende Schraffur, keine Linie zwischen Schicht und Nase.
let mut syms: Vec<(Vec<Primitive>, Vec<Primitive>, Option<&'static [f64]>)> = Vec::new();
for (o, oz) in &all_openings {
let (o, oz) = (o.as_ref(), *oz);
if !c.vis(&o.category_code, &o.id) || oz == Zone::Hidden {
continue;
}
let ov = c.overrides(Some("opening"), &o.category_code, Some(&opening_label(o)));
let olw = ov.lineweight.unwrap_or_else(|| c.cat(&o.category_code).map_or(LAYER_LINE_MM, |k| k.lw));
let color = ov.color.as_deref().or(o.color.as_deref());
let detail = match o.detail_level {
Some(DetailLevel::Grob) => Detail::Grob,
Some(DetailLevel::Mittel) => Detail::Mittel,
Some(DetailLevel::Fein) => Detail::Fein,
_ => c.a.detail,
};
let wall_line = (e.color.as_deref().unwrap_or(POCHE_STROKE), lw * c.a.detail.outline_factor());
let mut tmp = Vec::new();
opening_symbol(c, &mut tmp, wv, o, color, c.greyed(&o.category_code), detail, olw, wall_line)?;
// Nur Öffnungen mit Wandlücke (sonst schliesst die Wand, die Nase hätte keine Leibung).
let in_gap = openings.iter().any(|g| std::ptr::eq(*g, o));
let noses = if in_gap && !view_only && !cut.covered { take_noses(&mut tmp) } else { Vec::new() };
syms.push((noses, tmp, closed_dash(oz)));
}
append_nose_reveals(&mut reveals, p, wv, &gaps, syms.iter().flat_map(|s| s.0.iter()));
// [95] Taschen der Taschen-Schiebetüren (Hohlraum in der Wand, aus der Schraffur ausgespart).
let pockets = if view_only { WallPockets { o: wv.start, u: v2(1.0, 0.0), n: v2(0.0, 1.0), cuts: vec![] } } else { wall_pockets(p, wv, &openings) };
let mut layered = false;
match &unroll {
Some(u) => {
let mut tmp = Vec::new();
// [141] Ganz in einer Bogenwand gleichen Kreises und Typs: deren Körper zeigt sie mit.
if !cut.covered {
wall_poche(c, &mut tmp, &ev, &gaps, &cut_u, greyed, lw, category, view_only, &reveals, Some(u))?;
layered = wall_poche(c, &mut tmp, &ev, &gaps, &cut_u, greyed, lw, category, view_only, &reveals, Some(u))?;
}
cut_pockets(&mut tmp, 0, &pockets);
if reference_lines {
@@ -918,7 +949,7 @@ pub fn plan_walls(c: &Ctx, reference_lines: bool, out: &mut Vec<Primitive>, boun
let at = out.len();
// [141] Ganz in einer kollinearen Wand gleichen Typs: deren Körper zeigt sie mit.
if !cut.covered {
wall_poche(c, out, e, &gaps, cut, greyed, lw, category, view_only, &reveals, None)?;
layered = wall_poche(c, out, e, &gaps, cut, greyed, lw, category, view_only, &reveals, None)?;
}
cut_pockets(out, at, &pockets);
if reference_lines {
@@ -926,32 +957,19 @@ pub fn plan_walls(c: &Ctx, reference_lines: bool, out: &mut Vec<Primitive>, boun
}
}
}
for (o, oz) in &all_openings {
let (o, oz) = (o.as_ref(), *oz);
if !c.vis(&o.category_code, &o.id) || oz == Zone::Hidden {
continue;
}
for (noses, prims, dash) in syms {
let sym_start = out.len();
let ov = c.overrides(Some("opening"), &o.category_code, Some(&opening_label(o)));
let olw = ov.lineweight.unwrap_or_else(|| c.cat(&o.category_code).map_or(LAYER_LINE_MM, |k| k.lw));
let color = ov.color.as_deref().or(o.color.as_deref());
let detail = match o.detail_level {
Some(DetailLevel::Grob) => Detail::Grob,
Some(DetailLevel::Mittel) => Detail::Mittel,
Some(DetailLevel::Fein) => Detail::Fein,
_ => c.a.detail,
};
let wall_line = (e.color.as_deref().unwrap_or(POCHE_STROKE), lw * c.a.detail.outline_factor());
// Ohne Schicht-Poché (schwarze Sammelfläche) bleiben die Nasen eigene Stücke wie bisher.
let mut all = if layered { Vec::new() } else { noses };
all.extend(prims);
match &unroll {
Some(u) => {
let mut tmp = Vec::new();
opening_symbol(c, &mut tmp, wv, o, color, c.greyed(&o.category_code), detail, olw, wall_line)?;
polar_layer_pieces(u, &mut tmp);
bend_prims(u, tmp, out);
polar_layer_pieces(u, &mut all);
bend_prims(u, all, out);
}
None => opening_symbol(c, out, w, o, color, c.greyed(&o.category_code), detail, olw, wall_line)?,
None => out.extend(all),
}
if let Some(d) = closed_dash(oz) {
if let Some(d) = dash {
super::view_range::restyle(out, sym_start, d);
}
}
@@ -1273,6 +1291,70 @@ fn polar_layer_pieces(u: &Unroll, prims: &mut [Primitive]) {
}
}
/// [168] Anschlag-Nasen (Schichtstücke an einer Öffnung: Fläche mit Wand- UND Öffnungs-id) aus den
/// Symbol-Primitiven nehmen.
fn take_noses(prims: &mut Vec<Primitive>) -> Vec<Primitive> {
let (noses, rest): (Vec<Primitive>, Vec<Primitive>) = std::mem::take(prims).into_iter().partition(|q| matches!(q, Primitive::Polygon { wall_id: Some(_), opening_id: Some(_), .. }));
*prims = rest;
noses
}
/// [168] Anschlag-Nasen als Zusatzstücke an den Schichteinzug-Block der Poché (`plan_reveal_block`)
/// hängen: je Nase und geschnittener Schicht ein Stück `[x0, x1, o0, o1]` an der nächsten Leibung
/// (x ab Rohbaukante in die Öffnung, o quer ab Aussenfläche). So entstehen Umriss und Fugen aus dem
/// Raster der Teilflächen (`wall_poche::adjusted_segment`): Nase und Schicht sind eine Fläche.
fn append_nose_reveals<'a>(reveals: &mut Vec<f64>, p: &Project, w: &Wall, gaps: &[(f64, f64)], noses: impl Iterator<Item = &'a Primitive>) {
let Some(wt) = p.wall_type(w) else { return };
let total = thickness(&wt.layers);
let (dx, dy) = (w.end.x - w.start.x, w.end.y - w.start.y);
let len = dx.hypot(dy);
if !(total > 1e-9) || !(len > 1e-9) {
return;
}
let u = v2(dx / len, dy / len);
let n = v2(-u.y, u.x);
let face = joins::reference_offset(crate::model3d::wall_reference(w), total) - total / 2.0;
let mut bounds = Vec::with_capacity(wt.layers.len());
let mut acc = 0.0;
for l in &wt.layers {
bounds.push((acc, acc + l.thickness));
acc += l.thickness;
}
if reveals.is_empty() {
reveals.push(0.0);
}
for q in noses {
let Primitive::Polygon { pts, .. } = q else { continue };
let (mut x0, mut x1, mut o0, mut o1) = (f64::INFINITY, f64::NEG_INFINITY, f64::INFINITY, f64::NEG_INFINITY);
for pt in pts {
let (rx, ry) = (pt.x - w.start.x, pt.y - w.start.y);
let (x, o) = (rx * u.x + ry * u.y, rx * n.x + ry * n.y - face);
(x0, x1, o0, o1) = (x0.min(x), x1.max(x), o0.min(o), o1.max(o));
}
if !(x1 - x0 > 1e-6 && o1 - o0 > 1e-6) {
continue;
}
let xm = (x0 + x1) / 2.0;
// Nächste Leibung: links (Öffnung beginnt) oder rechts (Öffnung endet).
let Some((jamb, dir)) = gaps
.iter()
.filter(|g| xm > g.0 - 1e-6 && xm < g.1 + 1e-6)
.map(|g| if xm - g.0 <= g.1 - xm { (g.0, 1.0) } else { (g.1, -1.0) })
.next()
else {
continue;
};
let (a, b) = if dir > 0.0 { (x0 - jamb, x1 - jamb) } else { (jamb - x1, jamb - x0) };
for (li, &(l0, l1)) in bounds.iter().enumerate() {
let (s0, s1) = (o0.max(l0), o1.min(l1));
if s1 - s0 > 1e-6 {
reveals.extend([jamb, dir, li as f64, 0.0, 1.0, a.max(0.0), b, s0, s1]);
reveals[0] += 1.0;
}
}
}
}
fn bend_prims(u: &Unroll, prims: Vec<Primitive>, out: &mut Vec<Primitive>) {
for mut p in prims {
match &mut p {
@@ -1602,6 +1684,99 @@ pub(crate) mod tests {
assert!((g - 2.0 * (0.36f64 - 0.04).sqrt() * 0.16).abs() < 0.003, "{g}");
}
/// [168] Aussenwand Putz 2 · EPS 18 · Backstein 17.5 · Putz 1.5 cm entlang +x, Fenster 1.0..2.2 mit
/// Rahmen 18 cm hinter der Aussenfläche, Anschlag 5 cm (Nase aus Putz + EPS vor dem Rahmen) und
/// Schichteinzug „EPS überdämmt 3 cm".
fn reveal_window_project() -> Project {
let mut p = Project::default();
let std_h = crate::standards::hatches().into_iter().find(|h| h["id"] == "std-h-daemmstoffe-sia").expect("Standard-Schraffur");
p.hatches.push(serde_json::from_value(std_h).unwrap());
for (id, h) in [("putz", ""), ("eps", "std-h-daemmstoffe-sia"), ("bs", "")] {
p.components.push(Component { id: id.into(), hatch_id: h.into(), ..Default::default() });
}
let l = |c: &str, t: f64| Layer { component_id: c.into(), thickness: t, ..Default::default() };
p.wall_types.push(WallType { id: "aw".into(), layers: vec![l("putz", 0.02), l("eps", 0.18), l("bs", 0.175), l("putz", 0.015)], ..Default::default() });
p.drawing_levels.push(DrawingLevel { id: "eg".into(), kind: DrawingLevelKind::Floor, floor_height: Some(2.6), ..Default::default() });
p.walls.push(Wall { id: "w".into(), floor_id: "eg".into(), wall_type_id: "aw".into(), category_code: "20".into(), start: Vec2 { x: 0.0, y: 0.0 }, end: Vec2 { x: 4.0, y: 0.0 }, height: 2.6, ..Default::default() });
p.window_types = Some(vec![serde_json::from_value(serde_json::json!({
"id": "f", "name": "F", "kind": "drehkipp", "wingCount": 1, "frameWidth": 0.08, "frameDepth": 0.08,
"insetFromFace": 0.18, "insetFace": "aussen", "rebateDepth": 0.05,
"layerReveals": [{ "layer": 1, "mode": "ueberdaemmt", "amount": 0.03 }],
})).unwrap()]);
p.openings = Some(vec![Opening { id: "o".into(), host_wall_id: "w".into(), kind: ElementKind::Window, type_id: Some("f".into()), category_code: "20".into(), position: 1.0, width: 1.2, height: 1.4, sill_height: 0.9, ..Default::default() }]);
p
}
/// [168] Schichteinzug und Anschlag-Nase gehören zur Schicht: im Grundriss (1:20, Schichten) liegt die
/// EPS-Nase vor dem Rahmen in DERSELBEN Fläche wie das EPS-Band (gleiche Schraffur, durchlaufend),
/// keine Linie (Umriss/Fuge) auf der Grenze Schicht ↔ Einzug (Rohbaukante quer durch das EPS), kein
/// eigens umrandetes Stück an der Öffnung; die Aussenkontur (Stirn der Nase) bleibt Umriss.
#[test]
fn schichteinzug_ein_stueck_mit_der_schicht() {
for bulge in [None, Some(0.05)] {
let mut p = reveal_window_project();
p.walls[0].bulge = bulge;
let t = serde_json::json!({ "floor": "eg", "show": ["20"], "grey": [], "scale": 20.0 }).to_string();
let prims = super::super::domains::plan_domains(&p, &super::super::domains::PlanArgs::parse(1.0, &t).unwrap()).unwrap().walls;
assert!(
!prims.iter().any(|q| matches!(q, Primitive::Polygon { wall_id: Some(_), opening_id: Some(_), .. })),
"{bulge:?}: Nase als eigenes Element"
);
if bulge.is_some() {
continue;
}
// Querlage: Aussenfläche y = −0.195, EPS 0.02..0.20 ⇒ y −0.175..0.005; Rohbaukante x = 1.0 (bzw. 0.4..1.6 je nach Lage).
let (js, je) = crate::opening_geom::opening_interval(
&crate::opening_geom::WallRef { start: crate::opening_geom::v(0.0, 0.0), end: crate::opening_geom::v(4.0, 0.0), total: 0.39, ref_off: 0.0 },
1.0,
1.2,
)
.unwrap();
let eps_y = -0.195 + 0.1;
let polys: Vec<(&Vec<Vec2>, &HatchRender)> = prims
.iter()
.filter_map(|q| match q {
Primitive::Polygon { pts, hatch, wall_id: Some(_), fill, .. } if fill != "none" => Some((pts, hatch)),
_ => None,
})
.collect();
let containing = |x: f64, y: f64| polys.iter().find(|(pts, _)| point_in(pts, x, y)).copied();
for (jamb, into) in [(js, 1.0), (je, -1.0)] {
let nose = containing(jamb + into * 0.025, eps_y).expect("Nase gefüllt");
let band = containing(jamb - into * 0.3, eps_y).expect("EPS-Band");
assert!(nose.1.pattern == HatchPattern::Diagonal && nose.1 == band.1, "Nase in der EPS-Schraffur");
assert!(std::ptr::eq(nose.0, band.0), "Nase und Band als eine Fläche");
// Keine Linie auf der Rohbaukante im EPS.
for q in &prims {
if let Primitive::Line { a, b, cls, .. } = q {
let on = (a.x - jamb).abs() < 1e-6 && (b.x - jamb).abs() < 1e-6 && a.y.max(b.y) > eps_y - 0.05 && a.y.min(b.y) < eps_y + 0.05;
assert!(!on, "Linie {cls} auf der Grenze Schicht/Einzug: {a:?} {b:?}");
}
}
// Stirn der Nase (x = Rohbaukante + 5 cm) ist Umriss.
let face = jamb + into * 0.05;
assert!(
prims.iter().any(|q| matches!(q, Primitive::Line { a, b, cls, .. } if cls == "wall-outline" && (a.x - face).abs() < 1e-6 && (b.x - face).abs() < 1e-6)),
"Stirn der Nase ohne Umriss"
);
}
}
}
fn point_in(pts: &[Vec2], x: f64, y: f64) -> bool {
let n = pts.len();
let mut c = false;
let mut j = n - 1;
for i in 0..n {
let (a, b) = (pts[i], pts[j]);
if (a.y > y) != (b.y > y) && x < (b.x - a.x) * (y - a.y) / (b.y - a.y) + a.x {
c = !c;
}
j = i;
}
c
}
/// [G3][36] Bogen über der Schnitthöhe vorbei (Schräg: links bis 0.5 tief): die Wand bleibt
/// geschlossen, wo der Umriss die Schnittebene nicht erreicht; ganz verfehlt (Rund, Schnitt am
/// Scheitel) ⇒ Wand geschlossen, Symbol „über/unter Schnitt“.