[105][106] Merge: Fenster/Türen tief einstellbar (Rahmen je Seite, Flügel, Profile, Zargenarten, Schichteinzug je Schicht/Seite, Vorschau) – IDs 103/104→105/106

Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
Claude committed 2026-10-30 01:06:15 +00:00
commit 2eab3b73af
26 files changed
+3099 -85

No files matched your search

+171 -19
View File
@@ -545,7 +545,7 @@ fn wall_layers_reversed_in_u(w: &Wall, u: (f64, f64)) -> bool {
}
/// `splitWallLayers`: stehende Teil-Rechtecke je Schicht quer zur Dicke (u).
fn split_wall_layers(cp: &Cut, p: &Project, layers: &[Layer], owner: &Wall, u_world: (f64, f64)) -> Result<Vec<Cut>, String> {
fn split_wall_layers(cp: &Cut, p: &Project, layers: &[Layer], owner: &Wall, u_world: (f64, f64), plane: &Plane) -> Result<Vec<Cut>, String> {
let total = sum_thickness(layers);
let [u_min, u_max, v_min, v_max] = bbox(&cp.pts);
let u_span = u_max - u_min;
@@ -553,28 +553,93 @@ fn split_wall_layers(cp: &Cut, p: &Project, layers: &[Layer], owner: &Wall, u_wo
return Ok(vec![cp.clone()]);
}
let scale = u_span / total;
let ordered: Vec<&Layer> = if wall_layers_reversed_in_u(owner, u_world) { layers.iter().rev().collect() } else { layers.iter().collect() };
let reversed = wall_layers_reversed_in_u(owner, u_world);
let ordered: Vec<&Layer> = if reversed { layers.iter().rev().collect() } else { layers.iter().collect() };
let category = p.layer_category(&owner.category_code);
let mut out = Vec::with_capacity(layers.len());
// [106] Schichteinzug am Sturz (Stück liegt über der Öffnung) bzw. an der Brüstung (darunter).
let (top, bottom) = section_reveal(p, owner, plane, v_min, v_max);
let n = layers.len();
let mut acc = 0.0;
for layer in ordered {
for (k, layer) in ordered.into_iter().enumerate() {
let li = if reversed { n - 1 - k } else { k };
let comp = p.component_or_fallback(&layer.component_id);
let (fill, hatch) = layer_style(p, comp, owner.hatch_id.as_deref(), owner.hatch_source, owner.foreground.as_deref(), owner.foreground_source, owner.background.as_deref(), owner.background_source, category, SECTION_WALL_AXIS_ANGLE_DEG)?;
let u_left = u_min + acc * scale;
acc += layer.thickness;
let u_right = u_min + acc * scale;
let mut c = Cut::new(cp.kind, cp.index, vec![[u_left, v_max], [u_right, v_max], [u_right, v_min], [u_left, v_min]]);
c.fill = Some(fill);
c.hatch = Some(hatch);
c.join_priority = Some(comp.join_priority);
c.component_id = Some(comp.id.clone());
c.source_id = cp.source_id.clone();
c.category = cp.category.clone();
out.push(c);
let mk = |pts: Vec<[f64; 2]>| {
let mut c = Cut::new(cp.kind, cp.index, pts);
c.fill = Some(fill.clone());
c.hatch = Some(hatch.clone());
c.join_priority = Some(comp.join_priority);
c.component_id = Some(comp.id.clone());
c.source_id = cp.source_id.clone();
c.category = cp.category.clone();
c
};
let shift = |s: &Option<(f64, Vec<crate::opening_detail::LayerAdjust>)>| s.as_ref().and_then(|(_, v)| v.iter().find(|a| a.layer == li)).map_or(0.0, |a| a.shift);
let (vb, vt) = (v_min + shift(&top), v_max - shift(&bottom));
if vt - vb > 1e-6 {
out.push(mk(vec![[u_left, vt], [u_right, vt], [u_right, vb], [u_left, vb]]));
}
// Zusatzstücke dieser Schicht in der Öffnung.
let u_of = |o: f64| if reversed { u_max - o * scale } else { u_min + o * scale };
for (side, below) in [(&top, true), (&bottom, false)] {
let Some((z, adj)) = side else { continue };
for a in adj.iter().filter(|a| a.layer == li) {
for pc in &a.pieces {
let (z0, z1) = if below { (z - pc[1], z - pc[0]) } else { (z + pc[0], z + pc[1]) };
let (ua, ub) = (min(u_of(pc[2]), u_of(pc[3])), max(u_of(pc[2]), u_of(pc[3])));
out.push(mk(vec![[ua, z1], [ub, z1], [ub, z0], [ua, z0]]));
}
}
}
}
Ok(out)
}
/// Schichteinzug der Öffnung, deren Sturz (unten an `v_min`) bzw. Brüstung (oben an `v_max`) dieses
/// Wandstück ist und die die Schnittebene quert: `(Öffnungs-OK bzw. -UK, Anschlüsse)`.
#[allow(clippy::type_complexity)]
fn section_reveal(p: &Project, wall: &Wall, plane: &Plane, v_min: f64, v_max: f64) -> (Option<(f64, Vec<crate::opening_detail::LayerAdjust>)>, Option<(f64, Vec<crate::opening_detail::LayerAdjust>)>) {
let (mut top, mut bottom) = (None, None);
let u_raw = plane.u_model();
let l = hypot2(u_raw.0, u_raw.1);
if !(l > 1e-12) {
return (None, None);
}
let u = (u_raw.0 / l, u_raw.1 / l);
let (a, n) = axis_frame(wall);
let un = u.0 * n.0 + u.1 * n.1;
if un.abs() < MIN_CROSS {
return (None, None);
}
let p0 = plane.base();
let rel = (p0.0 - wall.start.x, p0.1 - wall.start.y);
let n0 = rel.0 * n.0 + rel.1 * n.1;
let a0 = rel.0 * a.0 + rel.1 * a.1;
let ua = u.0 * a.0 + u.1 * a.1;
let along = a0 + ((0.0 - n0) / un) * ua;
let (zb, zt) = p.wall_vertical_extent(wall);
for o in p.openings_of_wall(&wall.id) {
let Some(r) = crate::opening_detail::opening_reveal(p, wall, o) else { continue };
if along < r.from + 1e-4 || along > r.to - 1e-4 {
continue;
}
let o_bottom = zb + o.sill_height.max(0.0);
let o_top = zt.min(o_bottom + o.height);
let [_, _, t, b] = r.sides;
if (v_min - o_top).abs() < 1e-3 {
top = Some((o_top, t));
}
if (v_max - o_bottom).abs() < 1e-3 {
bottom = Some((o_bottom, b));
}
}
(top, bottom)
}
/// `attachCutStyles`: Stil, Herkunft, Schicht-Bänder, Terminierung, Dominanz.
fn attach_cut_styles(cuts: Vec<Cut>, p: &Project, plane: &Plane, walls: &[Option<&Wall>], slabs: &[SlabOwner]) -> Result<Vec<Cut>, String> {
if cuts.is_empty() {
@@ -598,7 +663,7 @@ fn attach_cut_styles(cuts: Vec<Cut>, p: &Project, plane: &Plane, walls: &[Option
if let Some(o) = owner {
let wt = p.wall_type_or_fallback(o);
if wt.layers.len() > 1 {
bands.extend(split_wall_layers(&cp, p, &wt.layers, o, u_world)?);
bands.extend(split_wall_layers(&cp, p, &wt.layers, o, u_world, plane)?);
continue;
}
}
@@ -1480,6 +1545,19 @@ fn window_cut(p: &Project, wall: &Wall, o: &Opening, c: &CrossSection) -> Result
inset_from_face: t.inset_from_face.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,
});
// [105] Rahmen-Detail: Lage/Tiefe übersteuert, Breite oben/unten, Anschlussprofile.
let det = crate::opening_detail::frame_of(p, o).filter(|f| f.detailed);
let spec = spec.map(|s| match &det {
Some(f) => crate::opening_geom::WindowSpec {
frame_depth: f.depth,
inset_from_face: f.inset,
inset_inner: f.face == crate::opening_detail::Face::Innen,
inset_mid: f.face == crate::opening_detail::Face::Mitte,
..s
},
None => s,
});
let finite = [wall.start.x, wall.start.y, wall.end.x, wall.end.y, total, ref_off, o.position, o.width].iter().all(|x| x.is_finite());
let sym = if finite {
@@ -1514,12 +1592,22 @@ fn window_cut(p: &Project, wall: &Wall, o: &Opening, c: &CrossSection) -> Result
let u1 = c.u_at(f_max);
let h = c.z_top - c.z_bottom;
let fwv = min(fw, h / 3.0);
let (sp, sh) = det.as_ref().map_or((0.0, 0.0), |f| (min(f.sill_profile, h / 4.0), min(f.shading_profile, h / 4.0)));
let (fwb, fwt) = det.as_ref().map_or((fwv, fwv), |f| (min(max(0.02, f.sides.bottom), h / 3.0), min(max(0.02, f.sides.top), h / 3.0)));
let (zb0, zt0) = (c.z_bottom + sp, c.z_top - sh);
let mut out = vec![opening_poly(rect(c.u_at(c.face_min), c.u_at(c.face_max), c.z_bottom, c.z_top), false, &o.id)];
out.push(opening_poly(rect(u0, u1, c.z_bottom, c.z_bottom + fwv), true, &o.id));
out.push(opening_poly(rect(u0, u1, c.z_top - fwv, c.z_top), true, &o.id));
out.push(opening_poly(rect(u0, u1, zb0, zb0 + fwb), true, &o.id));
out.push(opening_poly(rect(u0, u1, zt0 - fwt, zt0), true, &o.id));
// Fensterbank- und Storen-Anschlussprofil.
if sp > 1e-4 {
out.push(opening_poly(rect(u0, u1, c.z_bottom, zb0), true, &o.id));
}
if sh > 1e-4 {
out.push(opening_poly(rect(u0, u1, zt0, c.z_top), true, &o.id));
}
for s in glass {
let u = c.u_at(s);
let mut l = line(v2(u, c.z_bottom + fwv), v2(u, c.z_top - fwv), "section-window-glass", GLASS_MM, OPENING_INK);
let mut l = line(v2(u, zb0 + fwb), v2(u, zt0 - fwt), "section-window-glass", GLASS_MM, OPENING_INK);
if let Primitive::Line { opening_id, .. } = &mut l {
*opening_id = Some(o.id.clone());
}
@@ -1589,6 +1677,11 @@ fn door_cut(p: &Project, o: &Opening, c: &CrossSection) -> Vec<Primitive> {
lintel_cut(&mut out, o, c, p.door_type(o).and_then(|t| t.lintel_height), 0.0);
}
let kind = p.door_type(o).map(|t| t.kind);
// [105] Zargen-Arten: Sturz-Profil der Zarge und Blatt im Falz.
if let Some(df) = crate::opening_detail::door_frame_of(p, o).filter(|_| matches!(kind, Some(DoorTypeKind::Dreh | DoorTypeKind::Pendel | DoorTypeKind::Unknown))) {
door_frame_cut(&mut out, o, c, &df);
return out;
}
if o.door_type == Some(OpeningDoorType::Wandoeffnung) || kind == Some(DoorTypeKind::Wandoeffnung) {
return out;
}
@@ -1621,6 +1714,64 @@ fn door_cut(p: &Project, o: &Opening, c: &CrossSection) -> Vec<Primitive> {
out
}
/// Türzarge im Schnitt ([105]): Profil am Sturz (gleiches Profil wie im Grundriss, `x` nach unten)
/// und Türblatt im Falz der Aufschlagseite.
fn door_frame_cut(out: &mut Vec<Primitive>, o: &Opening, c: &CrossSection, df: &crate::opening_detail::DoorFrame) {
use crate::opening_detail as od;
let total = c.face_max - c.face_min;
let innen = od::aufschlag_innen(o);
let s_of = |d: f64| c.face_min + if innen { total - d } else { d };
let profile = od::door_frame_profile(df, total, innen);
let clear = od::profile_clear_x(&profile);
for (_, poly) in &profile {
let pts: Vec<Vec2> = poly.iter().map(|q| v2(c.u_at(s_of(q[1])), c.z_top - q[0])).collect();
let mut pr = if df.steel { polygon(pts, OPENING_INK, OPENING_INK, FRAME_MM, no_hatch_base()) } else { polygon(pts, "#ffffff", OPENING_INK, FRAME_MM, no_hatch_base()) };
if let Primitive::Polygon { opening_id, .. } = &mut pr {
*opening_id = Some(o.id.clone());
}
out.push(pr);
}
let (d0, d1) = od::leaf_band(df, total, innen);
let top = c.z_top - max(clear - df.falz_width, 0.0);
out.push(opening_poly(rect(c.u_at(s_of(d0)), c.u_at(s_of(d1)), c.z_bottom + 0.01, top), true, &o.id));
}
/// Anschlag im Schnitt ([105]/[94]): Wandnase oben (Sturz) und unten (Brüstung) über die Zone
/// zwischen gewählter Fläche und Rahmen, je Wandschicht in deren Schnitt-Darstellung.
fn rebate_cut(p: &Project, wall: &Wall, o: &Opening, c: &CrossSection) -> Result<Vec<Primitive>, String> {
let mut out = Vec::new();
let Some(f) = crate::opening_detail::frame_of(p, o) else { return Ok(out) };
let wt = p.wall_type_or_fallback(wall);
let total = sum_thickness(&wt.layers);
let Some((z0, z1)) = f.rebate_zone(total) else { return Ok(out) };
let h = c.z_top - c.z_bottom;
let category = p.layer_category(&wall.category_code);
for (rd, top) in [(f.rebate.top, true), (if o.kind == ElementKind::Door { 0.0 } else { f.rebate.bottom }, false)] {
let rd = min(rd, h / 3.0);
if !(rd > 1e-4) {
continue;
}
let (v0, v1) = if top { (c.z_top - rd, c.z_top) } else { (c.z_bottom, c.z_bottom + rd) };
let mut l0 = 0.0;
for layer in &wt.layers {
let l1 = l0 + layer.thickness;
let (a, b) = (z0.max(l0), z1.min(l1));
l0 = l1;
if b - a <= 1e-6 {
continue;
}
let comp = p.component_or_fallback(&layer.component_id);
let (fill, hatch) = layer_style(p, comp, wall.hatch_id.as_deref(), wall.hatch_source, wall.foreground.as_deref(), wall.foreground_source, wall.background.as_deref(), wall.background_source, category, SECTION_WALL_AXIS_ANGLE_DEG)?;
let mut pr = polygon(rect(c.u_at(c.face_min + a), c.u_at(c.face_min + b), v0, v1), &fill, OPENING_INK, FRAME_MM, hatch);
if let Primitive::Polygon { opening_id, .. } = &mut pr {
*opening_id = Some(o.id.clone());
}
out.push(pr);
}
}
Ok(out)
}
/// `sectionOpeningPrimitives`.
pub fn section_opening_primitives(p: &Project, level: &LevelSpec, vis: &Visibility) -> Result<Vec<Primitive>, String> {
let Some(plane) = level.plane() else { return Ok(Vec::new()) };
@@ -1656,7 +1807,8 @@ pub fn section_opening_primitives(p: &Project, level: &LevelSpec, vis: &Visibili
continue;
}
let Some(c) = cross_section(p, wall, o, p0, u)? else { continue };
let prims = if o.kind == ElementKind::Window { window_cut(p, wall, o, &c)? } else { door_cut(p, o, &c) };
let mut prims = if o.kind == ElementKind::Window { window_cut(p, wall, o, &c)? } else { door_cut(p, o, &c) };
prims.extend(rebate_cut(p, wall, o, &c)?);
let greyed = vis.greyed(&o.category_code);
for pr in prims {
out.push(if greyed { pr.with_greyed(true) } else { pr });
@@ -2198,8 +2350,8 @@ mod ts_faelle {
let w2 = p.walls.iter().find(|w| w.id == "W2").unwrap().clone();
let w4 = p.walls.iter().find(|w| w.id == "W4").unwrap().clone();
let u = (1.0, 0.0);
let b2 = split_wall_layers(&cp, &p, &layers, &w2, u).unwrap();
let b4 = split_wall_layers(&cp, &p, &layers, &w4, u).unwrap();
let b2 = split_wall_layers(&cp, &p, &layers, &w2, u, &Plane { point: [0.0; 3], normal: [1.0, 0.0, 0.0] }).unwrap();
let b4 = split_wall_layers(&cp, &p, &layers, &w4, u, &Plane { point: [0.0; 3], normal: [1.0, 0.0, 0.0] }).unwrap();
// W4 (Aussenseite −x): layers[0] an uMin; W2 gespiegelt: layers[0] an uMax.
assert_eq!(b4[0].component_id.as_deref(), Some(layers[0].component_id.as_str()));
assert!(close(bbox(&b4[0].pts)[0], 0.0));
@@ -2207,7 +2359,7 @@ mod ts_faelle {
// Override der Wand gilt für jede Schicht
p.walls[1].background = Some("#123456".into());
let w = p.walls[1].clone();
let bands = split_wall_layers(&cp, &p, &layers, &w, u).unwrap();
let bands = split_wall_layers(&cp, &p, &layers, &w, u, &Plane { point: [0.0; 3], normal: [1.0, 0.0, 0.0] }).unwrap();
assert!(bands.iter().all(|b| b.fill.as_deref() == Some("#123456")));
}
}
+140 -16
View File
@@ -97,7 +97,7 @@ fn line_buf(out: &mut Vec<f64>, l: Option<&joins::Line>) {
/// Eingabe von `plan_walls::wall_poche` (wie `encodeWallPoche` in TS).
#[allow(clippy::too_many_arguments)]
fn encode_wall_poche(w: &Wall, layers: &[f64], total: f64, ref_off: f64, gaps: &[(f64, f64)], cuts: &WallCuts, grob: bool, view_only: bool) -> Vec<f64> {
fn encode_wall_poche(w: &Wall, layers: &[f64], total: f64, ref_off: f64, gaps: &[(f64, f64)], cuts: &WallCuts, grob: bool, view_only: bool, reveals: &[f64]) -> Vec<f64> {
let mut b = vec![w.start.x, w.start.y, w.end.x, w.end.y, total, ref_off, if grob { 1.0 } else { 0.0 }, if view_only { 1.0 } else { 0.0 }];
b.push(layers.len() as f64);
b.extend_from_slice(layers);
@@ -124,6 +124,10 @@ fn encode_wall_poche(w: &Wall, layers: &[f64], total: f64, ref_off: f64, gaps: &
for g in gaps {
b.extend([g.0, g.1]);
}
// [106] Schichteinzug an den Leibungen.
if reveals.first().is_some_and(|n| *n > 0.0) {
b.extend_from_slice(reveals);
}
b
}
@@ -163,7 +167,7 @@ fn v2(x: f64, y: f64) -> Vec2 {
/// Wand-Poché (`addWallPoche`).
#[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) -> 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]) -> Result<(), String> {
let p = c.p;
let w = e.w;
let detail = c.a.detail;
@@ -175,7 +179,7 @@ fn wall_poche(c: &Ctx, out: &mut Vec<Primitive>, e: &EffWall, gaps: &[(f64, f64)
let outline_mm = wall_lw * detail.outline_factor();
let layer_mm = LAYER_LINE_MM * detail.layer_factor();
let thick: Vec<f64> = wt.layers.iter().map(|l| l.thickness).collect();
let f = crate::plan_walls::wall_poche(&encode_wall_poche(w, &thick, total, ref_off, gaps, cuts, detail == Detail::Grob, view_only));
let f = crate::plan_walls::wall_poche(&encode_wall_poche(w, &thick, total, ref_off, gaps, cuts, detail == Detail::Grob, view_only, reveals));
if f.is_empty() {
return Ok(());
}
@@ -305,7 +309,13 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
Detail::Mittel => 1.0,
Detail::Fein => 2.0,
};
let mut b: Vec<f64> = vec![w.start.x, w.start.y, w.end.x, w.end.y, total, ref_off, o.position, o.width, b01(door), detail_code];
// [105] Rahmen-Detail und Türzarge (eigene Zeichnung in `opening_detail_plan`).
let det = crate::opening_detail::frame_of(p, o).filter(|f| f.detailed);
let dframe = crate::opening_detail::door_frame_of(p, o);
// Verbreiterungsprofile: das Fenster-Element sitzt um sie eingerückt in der Rohbauöffnung.
let (ext_l, ext_r) = det.as_ref().filter(|_| !door).map_or((0.0, 0.0), |f| (f.ext.left, f.ext.right));
let (o_pos, o_wid) = if ext_l + ext_r > 1e-6 && o.width - ext_l - ext_r > 0.05 { (o.position + ext_l, o.width - ext_l - ext_r) } else { (o.position, o.width) };
let mut b: Vec<f64> = vec![w.start.x, w.start.y, w.end.x, w.end.y, total, ref_off, o_pos, o_wid, b01(door), detail_code];
// Tür
b.push(b01(o.swing.is_some_and(|s| s != SwingSide::Left)));
b.push(b01(o.opening_dir.is_some_and(|s| s != OpeningOpeningDir::In)));
@@ -320,8 +330,8 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
OpeningLintelLines::Beide => 3.0,
OpeningLintelLines::Unknown => f64::NAN,
});
// Rahmenband (Tür mit Typ)
match dt {
// Rahmenband (Tür mit Typ; Zargen-Arten [105] zeichnet `opening_detail_plan`)
match dt.filter(|_| dframe.is_none()) {
Some(t) => b.extend([
1.0,
t.frame_width.unwrap_or(0.06),
@@ -337,14 +347,29 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
}
// Fenster
b.push(b01(wt.is_some()));
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));
b.push(match wt.and_then(|t| t.inset_face) {
Some(WindowTypeInsetFace::Innen) => 1.0,
Some(WindowTypeInsetFace::Mitte) => 2.0,
_ => 0.0,
});
match det.as_ref().filter(|_| wt.is_some()) {
// [105]: Rahmen je Seite (links hier, rechts im Anhang), Tiefe/Lage übersteuert.
Some(f) => b.extend([
f.sides.left,
f.depth,
f.inset,
match f.face {
crate::opening_detail::Face::Innen => 1.0,
crate::opening_detail::Face::Mitte => 2.0,
crate::opening_detail::Face::Aussen => 0.0,
},
]),
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));
b.push(match wt.and_then(|t| t.inset_face) {
Some(WindowTypeInsetFace::Innen) => 1.0,
Some(WindowTypeInsetFace::Mitte) => 2.0,
_ => 0.0,
});
}
}
b.push(o.wing_count.unwrap_or(f64::NAN));
b.push(if detail == Detail::Fein { 2.0 } else { 1.0 });
let sill = wt.and_then(|t| t.sill_line.as_ref());
@@ -366,7 +391,13 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
b.push(o.sash_line.as_ref().and_then(|l| l.weight).unwrap_or(SYMBOL_HAIRLINE_MM));
b.push(o.sill_line_style.as_ref().and_then(|l| l.weight).unwrap_or(SYMBOL_HAIRLINE_MM));
// Details ([94]): Anschlag, Fensterbank, Storenkasten.
b.push(if door { dt.and_then(|t| t.rebate_depth) } else { wt.and_then(|t| t.rebate_depth) }.unwrap_or(0.0));
// Anschlag: je Seite verschieden ⇒ zeichnet `opening_detail_plan`.
let rebate_sides = det.as_ref().map(|f| f.rebate).filter(|r| (r.left - r.right).abs() > 1e-9 || dframe.is_some());
b.push(match (&det, rebate_sides) {
(_, Some(_)) => 0.0,
(Some(f), None) => f.rebate.left,
(None, None) => if door { dt.and_then(|t| t.rebate_depth) } else { wt.and_then(|t| t.rebate_depth) }.unwrap_or(0.0),
});
b.push(match wt.and_then(|t| t.sill_board) {
Some(WindowTypeSillBoard::Keine) => 1.0,
Some(WindowTypeSillBoard::Innen) => 2.0,
@@ -397,6 +428,10 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
b01(s.opening.is_some_and(|k| k != OpeningKind::Fest)),
]);
}
// [105] Anhang: Rahmenbreite rechts (Fenster).
if let Some(f) = det.as_ref().filter(|f| wt.is_some() && (f.sides.right - f.sides.left).abs() > 1e-9) {
b.push(f.sides.right);
}
let f = crate::plan_openings::plan_opening(&b);
if f.is_empty() {
return Ok(());
@@ -462,6 +497,94 @@ fn opening_symbol(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, colo
i += 9;
}
}
let ctx = DetailCtx { stroke: frame_color, weight: frame_weight, greyed, detail, wall_line };
opening_detail_plan(c, out, w, o, &ctx, rebate_sides, (ext_l, ext_r), dframe.as_ref())
}
/// Stil der Detail-Zeichnung einer Öffnung.
struct DetailCtx<'a> {
stroke: &'a str,
weight: f64,
greyed: bool,
detail: Detail,
wall_line: (&'a str, f64),
}
/// Grundriss-Detail einer Öffnung ([105]): Anschlag je Seite (Wandnase in der Schicht-Schraffur),
/// Verbreiterungsprofile neben dem Fensterrahmen und die Türzarge nach Art (Profil je Leibung,
/// Stahl im feinen Detail gefüllt).
#[allow(clippy::too_many_arguments)]
fn opening_detail_plan(c: &Ctx, out: &mut Vec<Primitive>, w: &Wall, o: &Opening, s: &DetailCtx, rebate: Option<crate::opening_detail::Sides>, ext: (f64, f64), dframe: Option<&crate::opening_detail::DoorFrame>) -> Result<(), String> {
use crate::opening_detail as od;
let p = c.p;
if rebate.is_none() && ext.0 + ext.1 <= 1e-6 && dframe.is_none() {
return Ok(());
}
let wtype = wall_type(p, w)?;
let total = thickness(&wtype.layers);
let ref_off = joins::reference_offset(crate::model3d::wall_reference(w), total);
let wr = crate::opening_geom::WallRef { start: crate::opening_geom::v(w.start.x, w.start.y), end: crate::opening_geom::v(w.end.x, w.end.y), total, ref_off };
let Some((js, je)) = crate::opening_geom::opening_jambs(&wr, o.position, o.width) else { return Ok(()) };
let (u, n) = wr.frame();
let face = ref_off - total / 2.0;
let width = ((je.x - js.x).powi(2) + (je.y - js.y).powi(2)).sqrt();
// Punkt: Leibung (0 links, 1 rechts), x in die Öffnung, o quer ab Aussenfläche.
let pt = |side: usize, x: f64, off: f64| {
let (base, dir) = if side == 0 { (js, 1.0) } else { (je, -1.0) };
v2(base.x + u.x * x * dir + n.x * (face + off), base.y + u.y * x * dir + n.y * (face + off))
};
let id = Some(o.id.as_str());
let frame = od::frame_of(p, o);
// Anschlag je Seite.
if let (Some(r), Some(f)) = (rebate, frame.as_ref()) {
if let Some((z0, z1)) = f.rebate_zone(total) {
let category = c.cat(&w.category_code);
let angle = atan2(w.end.y - w.start.y, w.end.x - w.start.x) * 180.0 / std::f64::consts::PI;
for (side, rd) in [(0usize, r.left), (1, r.right)] {
let rd = rd.min(width / 2.0 - 0.01);
if !(rd > 1e-4) {
continue;
}
let mut l0 = 0.0;
for (li, layer) in wtype.layers.iter().enumerate() {
let l1 = l0 + layer.thickness;
let (a, b) = (z0.max(l0), z1.min(l1));
l0 = l1;
if b - a <= 1e-6 {
continue;
}
let (hatch, fill) = layer_style(p, w, wtype, li, category, angle)?;
out.push(wall_polygon(vec![pt(side, 0.0, a), pt(side, rd, a), pt(side, rd, b), pt(side, 0.0, b)], &fill, s.wall_line.0, s.wall_line.1, hatch, s.greyed, None, Some(&w.id), id));
}
}
}
}
// Verbreiterungsprofile (Fenster) in der Rahmenlage.
if let Some(f) = frame.as_ref().filter(|_| ext.0 + ext.1 > 1e-6 && s.detail != Detail::Grob) {
let (lo, hi) = f.range(total);
for (side, e) in [(0usize, ext.0), (1, ext.1)] {
if e > 1e-6 {
let pts = vec![pt(side, 0.0, lo), pt(side, e, lo), pt(side, e, hi), pt(side, 0.0, hi)];
out.push(wall_polygon(pts, "none", s.stroke, s.weight, no_hatch(), s.greyed, None, None, id));
}
}
}
// Türzarge.
if let Some(df) = dframe {
let innen = od::aufschlag_innen(o);
let off_of = |d: f64| if innen { total - d } else { d };
let fein = s.detail == Detail::Fein;
for (part, poly) in od::door_frame_profile(df, total, innen) {
if s.detail == Detail::Grob && part == od::FramePart::Casing {
continue;
}
let fill = if fein && df.steel { s.stroke } else { "none" };
for side in [0usize, 1] {
let pts: Vec<Vec2> = poly.iter().map(|q| pt(side, q[0], off_of(q[1]))).collect();
out.push(wall_polygon(pts, fill, s.stroke, s.weight, no_hatch(), s.greyed, None, None, id));
}
}
}
Ok(())
}
@@ -507,7 +630,8 @@ 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;
wall_poche(c, out, e, &gaps, cut, greyed, lw, category, view_only)?;
let reveals = crate::opening_detail::plan_reveal_block(p, w, &openings);
wall_poche(c, out, e, &gaps, cut, greyed, lw, category, view_only, &reveals)?;
if reference_lines {
out.push(mk_line(w.start, w.end, "wall-axis", 0.13, Some(Some(vec![0.18, 0.06, 0.04, 0.06])), None, greyed, None));
}