[G2][G5][T2] Wand an Dach: exakte ebene Oberkante je Schicht, Gauben über den First abgefangen, IFC-Mengen der Gaube

Wände unter Dächern enden je Schicht exakt an der Dach-Unterkante (Facetten, obere Hülle bei Kehlen
und Gauben), geteilt an First/Grat/Kehle und seitlich über die Dicke, mit ebener Oberkante (topPlane)
in 3D, Schnitt, Ansicht, Exporten und Mengen; Öffnungen unter der Schräge ohne Treppung; Option
„An Dach anschliessen“ je Wand. Ansicht: Verdeckung der Wände durch die Dachscheiben, Stirnflächen
statt Giebeldreiecken. Gauben über den First werden gekappt, Gaubendach endet an der Dachfläche;
IFC-Mengen der Gauben am IfcRoof.
This commit is contained in:
Claude committed 2026-10-30 07:37:48 +00:00
1 parent 63b0823936
commit fd111c81ec
27 files changed
+1533 -159

No files matched your search

+86 -12
View File
@@ -255,6 +255,10 @@ pub struct RWall {
pub base_elevation: f64,
#[serde(skip_serializing_if = "Option::is_none")]
pub top_drop: Option<[f64; 2]>,
/// Ebene Oberkante unter einer Dachfläche ([G2]): `[z am Anfang (Mittellinie), dz/dx, dz/dy]`
/// (Grundriss-Meter). Übersteuert `topDrop`; `height` ist dann der höchste Eckwert über der UK.
#[serde(skip_serializing_if = "Option::is_none")]
pub top_plane: Option<[f64; 3]>,
pub color: Rgb,
pub layers: Vec<()>,
pub wall_id: String,
@@ -525,13 +529,13 @@ fn compute_joins_by_floor(p: &Project) -> Result<HashMap<String, WallCuts>, Stri
Ok(merged)
}
fn floor_context(p: &Project, floor_id: &str) -> FloorContext {
fn floor_context(p: &Project, floor_id: &str, with_ceilings: bool) -> FloorContext {
let ceilings: Vec<CeilingIn> = p
.ceilings
.as_deref()
.unwrap_or(&[])
.iter()
.filter(|c| c.floor_id == floor_id && c.outline.len() >= 3)
.filter(|c| with_ceilings && c.floor_id == floor_id && c.outline.len() >= 3)
.map(|c| {
let (z_bottom, z_top) = p.ceiling_vertical_extent(c);
CeilingIn {
@@ -552,7 +556,14 @@ fn floor_context(p: &Project, floor_id: &str) -> FloorContext {
let eaves_z = p.roof_base_elevation(r);
let geo = crate::roof::roof_geometry(&r.params(), eaves_z);
let total: f64 = p.roof_layers(r).iter().fold(0.0, |s, l| s + l.thickness.max(0.0));
RoofIn { eaves_z, total_thickness: total, eaves: geo.eaves, planes: geo.planes }
let mut ri = RoofIn::new(eaves_z, total, geo.eaves, geo.planes);
// Gauben ([G2]): unter dem Gaubeninneren endet die Wand an der Gaubendach-Unterkante.
for d in r.dormers.as_deref().unwrap_or(&[]) {
if let Some(g) = crate::dormer::geometry(p, r, d) {
ri.facets.extend(g.under_facets());
}
}
ri
})
.collect();
FloorContext::new(ceilings, roofs)
@@ -571,17 +582,13 @@ pub fn emit_walls(p: &Project, layered: bool) -> Result<Vec<RWall>, String> {
let joins = if layered { Some(compute_joins_by_floor(p)?) } else { None };
let maps = wall_material_color_maps(p);
let mut contexts: HashMap<&str, FloorContext> = HashMap::new();
let empty = FloorContext::default();
let mut out = Vec::new();
let by_wall = p.openings_by_wall();
for wall in &p.walls {
let (bands, stacked) = resolve_wall_bands(p, &maps, wall, layered);
let (z_bottom, z_top) = p.wall_vertical_extent(wall);
let ctx = if layered {
contexts.entry(wall.floor_id.as_str()).or_insert_with(|| floor_context(p, &wall.floor_id))
} else {
&empty
};
// Schnitt-Eingabe: nur die Dächer ([G2]); Decken rechnet der Schnitt selbst (Dominanz).
let ctx = contexts.entry(wall.floor_id.as_str()).or_insert_with(|| floor_context(p, &wall.floor_id, layered));
let win = wall_bands::WallIn {
start: kv(wall.start),
end: kv(wall.end),
@@ -599,6 +606,7 @@ pub fn emit_walls(p: &Project, layered: bool) -> Result<Vec<RWall>, String> {
bands: bands.iter().map(|b| BandIn { thickness: b.thickness, priority: b.priority }).collect(),
openings: wall_openings(p, wall, by_wall.get(wall.id.as_str()).map_or(&[][..], |v| v.as_slice()), true),
cuts: if layered { joins.as_ref().and_then(|j| j.get(&wall.id)).cloned().unwrap_or_default() } else { WallCuts::default() },
roof_attach: wall.roof_attach,
reveals: if layered && stacked { wall_reveals(p, wall, by_wall.get(wall.id.as_str()).map_or(&[][..], |v| v.as_slice()), bands.len()) } else { Vec::new() },
};
// Bogenwand ([T2]): Sehnen-Teilwände mit radialen Gehrungen.
@@ -618,8 +626,8 @@ pub fn emit_walls(p: &Project, layered: bool) -> Result<Vec<RWall>, String> {
let Some(b) = bands.get(piece.band) else { continue };
// Schnitt-Eingabe der Bogen-Teilwände: radiale Gehrungen auch ohne Schichtband-Pfad.
if arc.is_some() && !layered {
piece.start_cut = win.cuts.start_cut;
piece.end_cut = win.cuts.end_cut;
piece.start_cut = piece.start_cut.or(win.cuts.start_cut);
piece.end_cut = piece.end_cut.or(win.cuts.end_cut);
}
out.push(RWall {
start: [piece.start.x, piece.start.y],
@@ -628,6 +636,7 @@ pub fn emit_walls(p: &Project, layered: bool) -> Result<Vec<RWall>, String> {
height: piece.z_top - piece.z_bottom,
base_elevation: piece.z_bottom,
top_drop: piece.top_drop,
top_plane: piece.top_plane.map(|c| [c[0] + c[1] * piece.start.x + c[2] * piece.start.y, c[1], c[2]]),
color: b.color,
layers: vec![],
wall_id: wall.id.clone(),
@@ -637,7 +646,10 @@ pub fn emit_walls(p: &Project, layered: bool) -> Result<Vec<RWall>, String> {
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]),
joint: arc.map_or([false; 2], |a| [inner_joint(&a, wall, &keep, piece.start), inner_joint(&a, wall, &keep, piece.end)]),
joint: {
let j = arc.map_or([false; 2], |a| [inner_joint(&a, wall, &keep, piece.start), inner_joint(&a, wall, &keep, piece.end)]);
[j[0] || piece.joint[0], j[1] || piece.joint[1]]
},
});
}
}
@@ -646,6 +658,68 @@ pub fn emit_walls(p: &Project, layered: bool) -> Result<Vec<RWall>, String> {
Ok(out)
}
/// Grundriss-Ecken eines Wandkörpers an seinen Schnittlinien: Anfang +n, Ende +n, Ende −n, Anfang −n
/// (+n = linke Normale). `None` bei entarteter Achse.
pub(crate) fn wall_footprint(w: &RWall) -> Option<[[f64; 2]; 4]> {
let (dx, dy) = (w.end[0] - w.start[0], w.end[1] - w.start[1]);
let l = hypot2(dx, dy);
if !(l > 1e-9) || !(w.thickness > 0.0) {
return None;
}
let (ux, uy) = (dx / l, dy / l);
let (nx, ny) = (-uy, ux);
let h = w.thickness / 2.0;
let at = |p: [f64; 2], o: f64, cut: Option<[f64; 4]>| -> [f64; 2] {
let q = [p[0] + nx * o, p[1] + ny * o];
let Some([cx, cy, ex, ey]) = cut else { return q };
let den = ux * ey - uy * ex;
if den.abs() < 1e-12 {
return q;
}
let t = ((cx - q[0]) * ey - (cy - q[1]) * ex) / den;
if t.is_finite() && t.abs() < l {
[q[0] + ux * t, q[1] + uy * t]
} else {
q
}
};
Some([at(w.start, h, w.start_cut), at(w.end, h, w.end_cut), at(w.end, -h, w.end_cut), at(w.start, -h, w.start_cut)])
}
/// Oberkante eines Wandkörpers an einem Grundriss-Punkt (ebene Oberkante unter einem Dach, [G2]).
pub(crate) fn wall_top_at(w: &RWall, q: [f64; 2]) -> f64 {
let zt = w.base_elevation + w.height;
match w.top_plane {
Some(c) => (c[0] + c[1] * (q[0] - w.start[0]) + c[2] * (q[1] - w.start[1])).clamp(w.base_elevation, zt),
None => zt,
}
}
/// Wandkörper mit ebener Oberkante als geschlossenes Netz (Modell x, y, z), ohne Löcher.
pub(crate) fn wall_piece_mesh(w: &RWall) -> Option<crate::solid_bool::Mesh> {
let fp = wall_footprint(w)?;
let zb = w.base_elevation;
let m = crate::solid_bool::Mesh::prism_between(&fp, &|_, _| zb, &|x, y| wall_top_at(w, [x, y]));
(!m.is_empty()).then_some(m)
}
/// Volumen eines Wandkörpers ohne Löcher: Grundfläche × Höhe im Schwerpunkt (exakt bei ebener Oberkante).
pub(crate) fn wall_piece_volume(w: &RWall) -> f64 {
let Some(q) = wall_footprint(w) else { return 0.0 };
let (mut a, mut cx, mut cy) = (0.0, 0.0, 0.0);
for i in 0..4 {
let (p0, p1) = (q[i], q[(i + 1) % 4]);
let c = p0[0] * p1[1] - p1[0] * p0[1];
a += c;
cx += (p0[0] + p1[0]) * c;
cy += (p0[1] + p1[1]) * c;
}
if a.abs() < 1e-15 {
return 0.0;
}
(a / 2.0).abs() * (wall_top_at(w, [cx / (3.0 * a), cy / (3.0 * a)]) - w.base_elevation)
}
// ── Öffnungs-Einbauteile (Glas, Rahmen, Sprossen, Bank, Kasten) ─────────────
/// Farbe je Bauteil-Klasse (Index = `Part` in `openings3d.rs`).