[G3][100] Formöffnungen (Rundbogen, Segment-/Spitzbogen, rund, schräg, Giebel) und Dachfenster/Deckenöffnungen

[G3] Opening.shape + shapeRise (Rust-Modell, Typen generiert). Kern opening_shape.rs: konvexer Umriss
im Öffnungsrechteck; Wand behält das Rechteck-Loch, Füllkörper (Streifen-Quader) schliessen den Rest.
Schnitt: Wandband bis an den Umriss, Rahmen/Glas auf lichter Höhe, kein Sturz/Storenkasten bei Formen.
Ansicht: Rahmen als Umriss, Glas eingerückt, Wandrest in Wandfarbe. 3D: Rahmen-Ring, Glas/Türblatt entlang
des Umrisses. IFC: neuer Datensatz OPENING_SOLID (Profil-Extrusion quer durch die Wand, Füllung als Netz).
Dialog „Fenster bearbeiten": Form + Stich.

[100] Öffnungen mit Wirt Dach/Decke: hostRoofId/hostCeilingId, hostPoint, hostAngle. Dachfenster schneiden
alle Dachschichten (3D dicht, Live-Schnitt, Schnitt), Rahmen/Glas/Eindeckrahmen, Grundriss gestrichelt,
Ansicht, IFC (IfcOpeningElement im IfcRoof/IfcSlab + IfcWindow). Deckenöffnungen als Aussparung.
Befehl „Dachfenster" (roofwindow). Beide Teile teilen opening_shape.rs und den IFC-Datensatz, daher ein Commit.
This commit is contained in:
Claude committed 2026-10-29 23:58:52 +00:00
1 parent a385997282
commit 38d5f9505a
21 files changed
+1805 -65

No files matched your search

+30 -1
View File
@@ -278,7 +278,7 @@ fn ceilings(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) -> Result<()
continue;
}
let pts: Vec<[f64; 2]> = ce.outline.iter().map(|v| [v.x, v.y]).collect();
let holes: Vec<Vec<[f64; 2]>> = ce.openings.as_deref().unwrap_or(&[]).iter().map(|h| h.iter().map(|v| [v.x, v.y]).collect()).collect();
let holes: Vec<Vec<[f64; 2]>> = crate::opening_shape::ceiling_hole_rings(p, ce).iter().map(|h| h.iter().map(|v| [v.x, v.y]).collect()).collect();
let merged = crate::polygon_holes::merge_holes(&pts, &holes, 1e-4);
let layers = ceiling_layers(p, ce)?;
let comp = match layers.first() {
@@ -351,6 +351,35 @@ fn roofs(c: &Ctx, out: &mut Vec<Primitive>, bounds: &mut Bounds) {
for l in &geo.breaks {
out.push(line(pv(l[0]), pv(l[1]), "roof-break", ROOF_BREAK_MM, Some(Some(ROOF_BREAK_DASH.to_vec())), stroke, greyed));
}
roof_windows(c, out, roof);
}
}
/// Dachfenster ([100]) im Grundriss des Dach-Geschosses: Rahmen-Umriss und Glas als Projektion der
/// Dachfläche, gestrichelt (über der Schnitthöhe); Pick über die Öffnungs-id.
fn roof_windows(c: &Ctx, out: &mut Vec<Primitive>, roof: &Roof) {
let p = c.p;
let Some(ri) = p.roofs.as_deref().and_then(|r| r.iter().position(|x| x.id == roof.id)) else { return };
for (o, f) in crate::opening_shape::roof_openings(p, ri) {
if !c.shown(&o.category_code) {
continue;
}
let greyed = Some(c.greyed(&o.category_code));
let category = c.cat(&o.category_code);
let stroke = o.color.as_deref().or(category.map(|k| k.color.as_str())).unwrap_or(POCHE_STROKE);
let fw = crate::opening_shape::surface_frame_width(p, o);
for (inset, cls, w) in [(0.0, "roof-window-frame", ROOF_EAVES_MM), (fw, "roof-window-glass", ROOF_BREAK_MM)] {
let (hw, hh) = (o.width / 2.0 - inset, o.height / 2.0 - inset);
let r = [f.at(-hw, -hh, 0.0), f.at(hw, -hh, 0.0), f.at(hw, hh, 0.0), f.at(-hw, hh, 0.0)];
for k in 0..4 {
let (a, b) = (r[k], r[(k + 1) % 4]);
let mut l = line(Vec2 { x: a[0], y: a[1] }, Vec2 { x: b[0], y: b[1] }, cls, w, Some(Some(OVERHEAD_DASH.to_vec())), stroke, greyed);
if let Primitive::Line { opening_id, .. } = &mut l {
*opening_id = Some(o.id.clone());
}
out.push(l);
}
}
}
}
+101 -3
View File
@@ -221,6 +221,16 @@ struct ProjOpening {
sill: Vec<[Pt; 4]>,
symbol: Vec<(Pt, Pt)>,
id: String,
/// Formöffnung ([G3]): Rahmen-Umriss und Glas entlang des Umrisses statt der Rechtecke.
shape: Option<(Vec<Pt>, Vec<Pt>, Vec<Vec<Pt>>, String)>,
}
/// Umriss einer Formöffnung in Anteilen (0…1) und das um die Rahmenbreite eingerückte Glas.
type ShapeNorm = (Vec<[f64; 2]>, Vec<[f64; 2]>, Vec<[[f64; 2]; 4]>, String);
fn map_quad(q: &[Pt; 4], s: f64, t: f64) -> Pt {
let lerp = |a: Pt, b: Pt, k: f64| -> Pt { [a[0] + (b[0] - a[0]) * k, a[1] + (b[1] - a[1]) * k] };
lerp(lerp(q[0], q[1], s), lerp(q[3], q[2], s), t)
}
fn sash_kind(k: OpeningKind) -> f64 {
@@ -237,6 +247,7 @@ fn sash_kind(k: OpeningKind) -> f64 {
fn collect_openings(p: &Project, frame: &[f64; 9]) -> Vec<ProjOpening> {
let mut b = vec![0.0];
let mut ids: Vec<&str> = Vec::new();
let mut shapes: Vec<Option<ShapeNorm>> = Vec::new();
let by_wall = p.openings_by_wall();
for wall in &p.walls {
let thickness = p.wall_type(wall).map_or(0.2, |t| t.layers.iter().fold(0.0, |s, l| s + l.thickness));
@@ -332,6 +343,13 @@ fn collect_openings(p: &Project, frame: &[f64; 9]) -> Vec<ProjOpening> {
]);
}
ids.push(&op.id);
shapes.push(crate::opening_shape::opening_outline(op, to - from, ot - ob).map(|poly| {
let (w, h) = (to - from, ot - ob);
let fw = if door { dt.and_then(|t| t.frame_width) } else { wt.and_then(|t| t.frame_width) }.unwrap_or(0.06).min(w.min(h) / 3.0);
let norm = |q: &[f64; 2]| [q[0] / w, q[1] / h];
let fills = crate::opening_shape::fill_quads(&poly, w, h).iter().map(|q| q.map(|c| norm(&c))).collect();
(poly.iter().map(norm).collect(), crate::opening_shape::inset(&poly, fw).iter().map(norm).collect(), fills, wall.id.clone())
}));
b[0] += 1.0;
}
}
@@ -376,11 +394,57 @@ fn collect_openings(p: &Project, frame: &[f64; 9]) -> Vec<ProjOpening> {
let sash_rects = quads(&mut i);
let sill = quads(&mut i);
let symbol = lines(&mut i);
out.push(ProjOpening { pts, depth, glass, door_leaf, divisions, sash_rects, sill, symbol, id: ids[k].to_string() });
let m = |q: &[f64; 2]| map_quad(&pts, q[0], q[1]);
let shape = shapes[k].as_ref().map(|(o, g, fl, wid)| (o.iter().map(m).collect(), g.iter().map(m).collect(), fl.iter().map(|q| q.iter().map(m).collect()).collect(), wid.clone()));
if shape.is_some() {
// Formöffnung ([G3]): ohne Flügel-/Sprossenteilung, Türblatt und Symbole (Rechteck-Raster).
let round = p.openings.as_deref().unwrap_or(&[]).iter().any(|o| o.id == ids[k] && !crate::opening_shape::has_flat_bottom(o));
out.push(ProjOpening { pts, depth, glass: Vec::new(), door_leaf: Vec::new(), divisions: Vec::new(), sash_rects: Vec::new(), sill: if round { Vec::new() } else { sill }, symbol: Vec::new(), id: ids[k].to_string(), shape });
continue;
}
out.push(ProjOpening { pts, depth, glass, door_leaf, divisions, sash_rects, sill, symbol, id: ids[k].to_string(), shape });
}
surface_openings(p, frame, &mut out);
out
}
/// Dach-/Deckenfenster ([100]) in der Ansicht: Rahmen-Rechteck in der Dachfläche (6 cm über der
/// Eindeckung) und Glas, nur wenn die Fläche zum Betrachter zeigt.
fn surface_openings(p: &Project, frame: &[f64; 9], out: &mut Vec<ProjOpening>) {
let (fp, fnrm, fu) = ([frame[0], frame[1], frame[2]], [frame[3], frame[4], frame[5]], [frame[6], frame[7], frame[8]]);
let proj = |q: [f64; 3]| -> (Pt, f64) {
// Modell (x, y, z) → Ansichtswelt (x, Höhe, y).
let w = [q[0] - fp[0], q[2] - fp[1], q[1] - fp[2]];
([w[0] * fu[0] + w[1] * fu[1] + w[2] * fu[2], q[2]], w[0] * fnrm[0] + w[1] * fnrm[1] + w[2] * fnrm[2])
};
for o in p.openings.as_deref().unwrap_or(&[]) {
let Some(f) = crate::opening_shape::host_frame(p, o) else { continue };
if f.plane.is_none() || fnrm[0] * f.n[0] + fnrm[1] * f.n[2] + fnrm[2] * f.n[1] >= -1e-4 {
continue;
}
let (w, h) = (o.width, o.height);
let fw = crate::opening_shape::surface_frame_width(p, o);
let quad = |inset: f64| -> ([Pt; 4], f64) {
let c = [f.at(-w / 2.0 + inset, -h / 2.0 + inset, -0.06), f.at(w / 2.0 - inset, -h / 2.0 + inset, -0.06), f.at(w / 2.0 - inset, h / 2.0 - inset, -0.06), f.at(-w / 2.0 + inset, h / 2.0 - inset, -0.06)];
let pr = c.map(proj);
([pr[0].0, pr[1].0, pr[2].0, pr[3].0], (pr[0].1 + pr[1].1 + pr[2].1 + pr[3].1) / 4.0)
};
let (pts, own) = quad(0.0);
if own <= 1e-6 {
continue;
}
// Painter: knapp vor der eigenen Dachfläche (deren Tiefe = Mittel ihrer Ecken wie `project_face`).
let plane_depth = p.roofs.as_deref().and_then(|r| r.get(f.host)).and_then(|roof| {
let g = crate::roof::roof_geometry(&roof.params(), p.roof_base_elevation(roof));
let pl = g.planes.get(f.plane?)?.clone();
Some(pl.iter().map(|q| proj(*q).1).sum::<f64>() / pl.len() as f64)
});
let depth = plane_depth.map_or(own, |d| d.min(own));
let glass = if o.kind == ElementKind::Window { vec![quad(fw).0] } else { Vec::new() };
out.push(ProjOpening { pts, depth, glass, door_leaf: Vec::new(), divisions: Vec::new(), sash_rects: Vec::new(), sill: Vec::new(), symbol: Vec::new(), id: o.id.clone(), shape: None });
}
}
fn encode_shadow_faces(faces: &[&Face]) -> Vec<f64> {
let mut b = vec![faces.len() as f64];
for f in faces {
@@ -675,11 +739,24 @@ pub fn elevation_primitives(p: &Project, level: &LevelSpec, shadows: bool, mono:
};
let d = op.depth - EPS * 100.0;
let id = Some(op.id.as_str());
// Formöffnung: das Rechteck-Loch der Wand ausserhalb des Umrisses in Wandfarbe schliessen.
if let Some((_, _, fills, wid)) = &op.shape {
let wall_fill = faces.iter().find(|f| f.role == Role::Wall && f.id == *wid).map_or("#ffffff".to_string(), |f| fill_for(f.fill));
for q in fills {
let pts = to_vec(q);
items.push(Item { depth: d + EPS * 10.0, seq, rank: None, prim: polygon(pts, &wall_fill, "none", 0.0, no_hatch()) });
seq += 1;
}
}
let mut push = |prim: Primitive| {
items.push(Item { depth: d, seq, rank: None, prim });
seq += 1;
};
push(poly_prim(to_vec(&op.pts), if mono { "#ffffff" } else { FRAME_FILL_COLOR }, EDGE_INK, FRAME_MM, id));
let frame_pts = op.shape.as_ref().map_or(&op.pts[..], |(o, _, _, _)| &o[..]);
push(poly_prim(to_vec(frame_pts), if mono { "#ffffff" } else { FRAME_FILL_COLOR }, EDGE_INK, FRAME_MM, id));
if let Some((_, g, _, _)) = &op.shape {
push(poly_prim(to_vec(g), if mono { GLASS_FILL_MONO } else { GLASS_FILL_COLOR }, EDGE_INK, EDGE_MM, id));
}
for r in &op.sill {
push(poly_prim(to_vec(r), if mono { "#ffffff" } else { SILL_FILL_COLOR }, EDGE_INK, EDGE_MM, id));
}
@@ -692,7 +769,7 @@ pub fn elevation_primitives(p: &Project, level: &LevelSpec, shadows: bool, mono:
for r in &op.door_leaf {
push(poly_prim(to_vec(r), if mono { "#ffffff" } else { DOOR_LEAF_FILL_COLOR }, EDGE_INK, EDGE_MM, id));
}
if shadows {
if shadows && op.shape.is_none() {
let q = &op.pts;
let lerp = |a: Pt, b: Pt, t: f64| -> Pt { [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t] };
let quad_at = |fa: f64, fz: f64| lerp(lerp(q[0], q[1], fa), lerp(q[3], q[2], fa), fz);
@@ -782,4 +859,25 @@ mod tests {
// Painter: die Bodenlinie zuletzt
assert!(matches!(prims.last(), Some(Primitive::Line { cls, .. }) if cls == "elevation-ground"));
}
/// [G3] Formöffnung: Rahmen als Umriss (viele Ecken), Glas eingerückt; [100] Dachfenster auf der
/// Südfläche sichtbar.
#[test]
fn formoeffnung_und_dachfenster_in_der_ansicht() {
let mut p = sample();
for o in p.openings.iter_mut().flatten().filter(|o| o.id == "O1") {
o.shape = Some(OpeningShape::Rund);
}
p.openings.as_mut().unwrap().push(Opening { id: "DF".into(), kind: ElementKind::Window, category_code: "21".into(), width: 0.78, height: 1.18, host_roof_id: Some("RF1".into()), host_point: Some(Vec2 { x: 2.5, y: 1.0 }), ..Default::default() });
let l = p.drawing_levels.iter().find(|l| l.id == "ansicht-sued").unwrap();
let level = LevelSpec::from_json(&serde_json::to_value(l).unwrap());
let (prims, _) = elevation_primitives(&p, &level, false, false, &Visibility::default()).unwrap().unwrap();
let polys = |id: &str| -> Vec<usize> { prims.iter().filter_map(|pr| if let Primitive::Polygon { pts, opening_id: Some(o), .. } = pr { (o == id).then_some(pts.len()) } else { None }).collect() };
let o1 = polys("O1");
assert!(o1.len() == 2 && o1.iter().all(|n| *n >= 40), "Rahmen + Glas als Ellipse: {o1:?}");
assert_eq!(polys("DF"), vec![4, 4], "Dachfenster: Rahmen + Glas");
let first_df = prims.iter().position(|pr| matches!(pr, Primitive::Polygon { opening_id: Some(o), .. } if o == "DF")).unwrap();
let last_roof = prims.iter().rposition(|pr| matches!(pr, Primitive::Polygon { roof_id: Some(_), .. })).unwrap();
assert!(first_df > last_roof, "Dachfenster vor der Dachfläche gezeichnet");
}
}
+137 -11
View File
@@ -737,6 +737,49 @@ fn subtract_dominant_bands(bands: Vec<Cut>) -> Vec<Cut> {
// ── Dächer ────────────────────────────────────────────────────────────────────
/// `appendRoofSections`: Schnittspur der Dachflächen, je Schicht ein Band.
/// Formöffnungen ([G3]): Die Wand hat im Modell das Rechteck-Loch; an der Schnittstelle reicht die
/// Wand bis an den Umriss. Die geschnittenen Wandbänder über bzw. unter der Öffnung werden bis zur
/// lichten Höhe des Umrisses an dieser Stelle verlängert.
fn shaped_wall_cuts(cuts: &mut [Cut], p: &Project, walls_r: &[RWall], base: (f64, f64), u: (f64, f64)) {
let ul = hypot2(u.0, u.1);
if !(ul > 1e-12) {
return;
}
let u = (u.0 / ul, u.1 / ul);
for o in p.openings.as_deref().unwrap_or(&[]).iter().filter(|o| crate::opening_shape::is_shaped(o)) {
let Some(wall) = p.walls.iter().find(|w| w.id == o.host_wall_id) else { continue };
let Some((from, to)) = opening_interval(wall, o) else { continue };
let (a, _) = axis_frame(wall);
let den = a.0 * u.1 - a.1 * u.0;
if den.abs() < MIN_CROSS {
continue;
}
let (rx, ry) = (base.0 - wall.start.x, base.1 - wall.start.y);
let along = (rx * u.1 - ry * u.0) / den;
if along <= from + 1e-4 || along >= to - 1e-4 {
continue;
}
let (zb, zt) = opening_extent(p, wall, o);
let Some(poly) = crate::opening_shape::opening_outline(o, to - from, zt - zb) else { continue };
let Some((lo, hi)) = crate::opening_shape::v_range(&poly, along - from) else { continue };
let (new_bottom, new_top) = (zb + lo, zb + hi);
const TOL: f64 = 2e-3;
for c in cuts.iter_mut().filter(|c| c.kind == Kind::Wall && walls_r.get(c.index).is_some_and(|w| w.wall_id == wall.id)) {
let (y_lo, y_hi) = c.pts.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(l, h), q| (l.min(q[1]), h.max(q[1])));
let (from_y, to_y) = if (y_lo - zt).abs() < TOL && new_top < zt - 1e-6 {
(zt, new_top)
} else if (y_hi - zb).abs() < TOL && new_bottom > zb + 1e-6 {
(zb, new_bottom)
} else {
continue;
};
for q in c.pts.iter_mut().filter(|q| (q[1] - from_y).abs() < TOL) {
q[1] = to_y;
}
}
}
}
fn append_roof_sections(cuts: &mut Vec<Cut>, p: &Project, plane: &Plane) {
let roofs = p.roofs.as_deref().unwrap_or(&[]);
if roofs.is_empty() {
@@ -760,6 +803,11 @@ fn append_roof_sections(cuts: &mut Vec<Cut>, p: &Project, plane: &Plane) {
}
}
let sg = crate::plan_section::roof_segments(bx, by, ux, uy, &pl);
// Dachfenster ([100]): Lochkörper in der Schnittebene, aus jeder Schicht ausgeschnitten.
let holes: Vec<Vec<[f64; 2]>> = crate::opening_shape::roof_openings(p, index)
.iter()
.filter_map(|(o, f)| crate::opening_shape::box_section(&crate::opening_shape::surface_hole_box(o, f), (bx, by), (ux, uy)))
.collect();
let n = sg.first().copied().unwrap_or(0.0) as usize;
for k in 0..n {
let o = 1 + 5 * k;
@@ -774,14 +822,19 @@ fn append_roof_sections(cuts: &mut Vec<Cut>, p: &Project, plane: &Plane) {
let top0 = z0 - prefix;
let top1 = z1 - prefix;
prefix += vt;
let mut c = Cut::new(Kind::Roof, index, vec![[t_lo, top0], [t_hi, top1], [t_hi, top1 - vt], [t_lo, top0 - vt]]);
if !layer.component_id.is_empty() {
if let Some(h) = p.component(&layer.component_id).and_then(|comp| resolve_hatch(p, &comp.hatch_id, None, None, None)) {
c.fill = Some(poche_fill(h.pattern).to_string());
c.hatch = Some(h);
}
let mut pieces = vec![vec![[t_lo, top0], [t_hi, top1], [t_hi, top1 - vt], [t_lo, top0 - vt]]];
for h in &holes {
pieces = pieces.iter().flat_map(|pc| crate::opening_shape::subtract_convex(pc, h)).collect();
}
let hatch = if layer.component_id.is_empty() { None } else { p.component(&layer.component_id).and_then(|comp| resolve_hatch(p, &comp.hatch_id, None, None, None)) };
for pts in pieces {
let mut c = Cut::new(Kind::Roof, index, pts);
if let Some(h) = &hatch {
c.fill = Some(poche_fill(h.pattern).to_string());
c.hatch = Some(h.clone());
}
cuts.push(c);
}
cuts.push(c);
}
}
}
@@ -1146,6 +1199,7 @@ pub fn compute_section(p: &Project, level: &LevelSpec, bodies: &[BodyMesh]) -> R
let visible: Vec<Edge> = raw.visible_edges.iter().filter(not_cut).map(&mut edge).collect();
let hidden: Vec<Edge> = raw.hidden_edges.iter().filter(not_cut).map(&mut edge).collect();
shaped_wall_cuts(&mut cuts, p, &walls_r, plane.base(), plane.u_model());
append_roof_sections(&mut cuts, p, &plane);
let walls = wall_owners(p, &walls_r);
let slabs = slab_owners(p, &slabs_r);
@@ -1376,7 +1430,12 @@ fn cross_section(p: &Project, wall: &Wall, o: &Opening, p0: (f64, f64), u: (f64,
if along < from + 1e-4 || along > to - 1e-4 {
return Ok(None);
}
let (z_bottom, z_top) = opening_extent(p, wall, o);
let (mut z_bottom, mut z_top) = opening_extent(p, wall, o);
// Formöffnung ([G3]): lichte Höhe an der Schnittstelle aus dem Umriss.
if let Some(poly) = crate::opening_shape::opening_outline(o, to - from, z_top - z_bottom) {
let Some((lo, hi)) = crate::opening_shape::v_range(&poly, along - from) else { return Ok(None) };
(z_bottom, z_top) = (z_bottom + lo, z_bottom + hi);
}
if z_top - z_bottom < 1e-3 {
return Ok(None);
}
@@ -1467,9 +1526,13 @@ fn window_cut(p: &Project, wall: &Wall, o: &Opening, c: &CrossSection) -> Result
out.push(l);
}
if let Some(t) = wt {
let shading = t.shading.as_ref().filter(|s| s.create);
// Formöffnung ([G3]): kein Sturz-Querschnitt, kein Storenkasten (Bogen/Schräge statt Sturz).
let shaped = crate::opening_shape::is_shaped(o);
let shading = t.shading.as_ref().filter(|s| s.create && !shaped);
let sturz_box = shading.filter(|s| s.mount == Some(WindowShadingMount::Sturz)).map_or(0.0, |s| max(0.0, s.r#box.depth));
lintel_cut(&mut out, o, c, t.lintel_height, sturz_box);
if !shaped {
lintel_cut(&mut out, o, c, t.lintel_height, sturz_box);
}
// Fensterbänke nur bei ausdrücklicher Wahl (bisherige Schnitte bleiben gleich).
let zb = c.z_bottom;
if matches!(t.sill_board, Some(WindowTypeSillBoard::Aussen | WindowTypeSillBoard::Beide)) {
@@ -1522,7 +1585,9 @@ fn lintel_cut(out: &mut Vec<Primitive>, o: &Opening, c: &CrossSection, height: O
fn door_cut(p: &Project, o: &Opening, c: &CrossSection) -> Vec<Primitive> {
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)];
lintel_cut(&mut out, o, c, p.door_type(o).and_then(|t| t.lintel_height), 0.0);
if !crate::opening_shape::is_shaped(o) {
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);
if o.door_type == Some(OpeningDoorType::Wandoeffnung) || kind == Some(DoorTypeKind::Wandoeffnung) {
return out;
@@ -1576,6 +1641,16 @@ pub fn section_opening_primitives(p: &Project, level: &LevelSpec, vis: &Visibili
if !vis.visible(&o.category_code) || !vis.render(&o.category_code) {
continue;
}
// Dach-/Deckenfenster ([100]): Schnitt durch Rahmen, Glas und Eindeckrahmen.
if let Some(f) = crate::opening_shape::host_frame(p, o) {
let greyed = vis.greyed(&o.category_code);
for (part, corners) in crate::opening_shape::surface_window_boxes(p, o, &f) {
let Some(pts) = crate::opening_shape::box_section(&corners, p0, u) else { continue };
let pr = opening_poly(pts.iter().map(|q| v2(q[0], q[1])).collect(), part != 0, &o.id);
out.push(if greyed { pr.with_greyed(true) } else { pr });
}
continue;
}
let Some(wall) = walls_by_id.get(o.host_wall_id.as_str()).copied() else { continue };
if !vis.visible(&wall.category_code) {
continue;
@@ -1752,6 +1827,57 @@ mod tests {
assert!(json.contains(LINTEL_FILL) && json.contains(SHADING_PACK_FILL), "{json}");
}
/// [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 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);
// Viertel der Breite: Bogen 0,5 m Radius, Kämpfer 0,7 m über der Brüstung.
let m = o1.position + o1.width / 4.0;
let c = (w1.start.x + u.0 * m, w1.start.y + u.1 * m);
let l = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: c.0 - n.0 * 3.0, y: c.1 - n.1 * 3.0 }, Vec2 { x: c.0 + n.0 * 3.0, y: c.1 + n.1 * 3.0 }]), ..Default::default() };
let (zb, zt) = opening_extent(&p, &w1, &o1);
let top_of = |p: &Project| -> f64 {
let out = compute_section(p, &l, &[]).unwrap().unwrap();
out.cuts.iter().filter(|c| c.kind == Kind::Wall && c.source_id.as_deref() == Some("W1")).flat_map(|c| c.pts.iter().map(|q| q[1])).filter(|y| *y > zb + 0.1).fold(f64::INFINITY, f64::min)
};
assert!((top_of(&p) - zt).abs() < 1e-3, "Rechteck: Sturz bei {zt}");
for o in p.openings.iter_mut().flatten().filter(|o| o.id == "O1") {
o.shape = Some(OpeningShape::Rundbogen);
}
let want = zb + 0.7 + (0.25f64 - 0.0625).sqrt();
assert!((top_of(&p) - want).abs() < 5e-3, "{} vs {want}", top_of(&p));
let prims = section_opening_primitives(&p, &l, &Visibility::default()).unwrap();
let ys: Vec<f64> = prims.iter().filter_map(|pr| if let Primitive::Polygon { pts, opening_id: Some(id), .. } = pr { (id == "O1").then(|| pts.iter().map(|q| q.y).fold(f64::NEG_INFINITY, f64::max)) } else { None }).collect();
assert!(!ys.is_empty() && ys.iter().all(|y| *y < want + 5e-3), "kein Sturz/Kasten über dem Bogen: {ys:?}");
}
/// [100] Dachfenster: Lücke in allen Dachschichten, Rahmen/Glas geschnitten.
#[test]
fn dachfenster_im_schnitt() {
let mut p = sample();
let l = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: 2.5, y: -2.0 }, Vec2 { x: 2.5, y: 6.0 }]), ..Default::default() };
let roof_cuts = |p: &Project| compute_section(p, &l, &[]).unwrap().unwrap().cuts.iter().filter(|c| c.kind == Kind::Roof).count();
let before = roof_cuts(&p);
assert!(before > 0);
p.openings.as_mut().unwrap().push(Opening {
id: "DF".into(),
kind: ElementKind::Window,
category_code: "21".into(),
width: 0.78,
height: 1.18,
host_roof_id: Some("RF1".into()),
host_point: Some(Vec2 { x: 2.5, y: 1.0 }),
..Default::default()
});
assert!(roof_cuts(&p) > before, "Schichten links und rechts des Fensters");
let prims = section_opening_primitives(&p, &l, &Visibility::default()).unwrap();
let df: Vec<_> = prims.iter().filter(|pr| matches!(pr, Primitive::Polygon { opening_id: Some(id), .. } if id == "DF")).collect();
assert!(df.len() >= 4, "Rahmen beidseits, Glas, Eindeckrahmen: {}", df.len());
}
#[test]
fn beschnittene_baender_behalten_ihre_ebene() {
// Von der Dominanz beschnittene Wand-/Deckenstücke tragen ihre Kategorie weiter: Ebene aus → weg.