[K3a] Oeffnungssymbole im Grundriss in Rust (opening_geom.rs, plan_openings.rs); windowSymbol Fassade; tote Ports in kernel2d entfernt

This commit is contained in:
karim committed 2026-10-28 00:58:28 +01:00
1 parent 8c112b2bc5
commit c134d32fcc
9 files changed
+964 -1034

No files matched your search

+6 -1
View File
@@ -91,7 +91,12 @@ truck (`trucksolid`) bleibt eigenes WASM-Modul (Panic-Isolation), wird vom Kern
Fugen-Linienstil) bleibt in TS, bis das Modell in Rust liegt [K4]; Zuordnung über den Schichtindex. Bitgleich zur
alten Fassung (60 Zufallspläne × 3 Detailgrade, Öffnungen, Beispielprojekt, Decken mit/ohne Loch); `subtractIntervals`/
`segmentInsideWallBand` aus TS gelöscht. Nicht in der Tauri-App angesehen.
Offen: Öffnungssymbole, Räume, Dächer, Stützen, 2D-Zeichnung, Kontext, Schnittlinien.
✅ Öffnungssymbole (Tür/Fenster): `opening_geom.rs` (Pfosten, Lücke, Türblätter, Fenster-Symbol mit Flügel-/Stulpmarken)
und `plan_openings.rs` (Symbol, Rahmenband, Sturzlinien, Sims, Rollladenkasten); Linien-Overrides lösen in TS auf,
Farben kommen als Slot zurück. `geometry/opening.ts`: `doorSymbol`/`doorLeaves` gelöscht, `windowSymbol` ist Fassade
(Schnitt nutzt sie weiter). Bitgleich zur alten Fassung (80 Zufallsfälle × 3 Detailgrade, alle 13 Linienklassen;
600 Zufalls-Fenstersymbole). Tote halbe Ports in `kernel2d` (door/window_symbol, jambs …) entfernt.
Offen: Räume, Dächer, Stützen, 2D-Zeichnung, Kontext, Schnittlinien.
- ○ **[K3c] Schnitt und Ansicht** (`toSection`, `toElevation`, `meshSection`) im selben Puffer-Format.
- ○ **[K3d] Aufräumen:** TS-Primitive-Erzeugung löschen, SVG/PDF/DXF-Export lesen den Puffer.
Nachteile (bewusst): Übergang mit doppelter Datenhaltung, Format muss TS/Rust gleich bleiben
+2
View File
@@ -35,6 +35,8 @@ pub mod plan_buf;
pub mod gpu_compile;
pub mod plan_stairs;
pub mod plan_walls;
pub mod opening_geom;
pub mod plan_openings;
#[cfg(feature = "web")]
mod web;
+329
View File
@@ -0,0 +1,329 @@
//! Öffnungs-Geometrie im Grundriss ([K3a]): Pfosten, Lücke, Türblätter und das Fenster-Symbol
//! (Rahmen, Glaslinien, Flügel- und Stulpmarken). Port von `src/geometry/opening.ts`; Rechen-
//! reihenfolge und Zahlsemantik wie in TS (`Math.hypot` über `jsmath`, `Math.min/max/round`
//! über `jsnum`, `cos/sin` über `jsnum`), damit die Ausgabe bitgleich bleibt.
use crate::jsmath::hypot2;
use crate::jsnum::{cos, max, min, round, sin};
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct V {
pub x: f64,
pub y: f64,
}
pub fn v(x: f64, y: f64) -> V {
V { x, y }
}
pub fn sub(a: V, b: V) -> V {
v(a.x - b.x, a.y - b.y)
}
pub fn add(a: V, b: V) -> V {
v(a.x + b.x, a.y + b.y)
}
pub fn scale(a: V, s: f64) -> V {
v(a.x * s, a.y * s)
}
pub fn dot(p: V, q: V) -> f64 {
p.x * q.x + p.y * q.y
}
pub fn normalize(a: V) -> V {
let l = hypot2(a.x, a.y);
let l = if l == 0.0 || l.is_nan() { 1.0 } else { l };
v(a.x / l, a.y / l)
}
pub fn left_normal(a: V) -> V {
v(-a.y, a.x)
}
pub fn along(p1: V, p2: V, d: f64) -> V {
add(p1, scale(normalize(sub(p2, p1)), d))
}
const DEG: f64 = std::f64::consts::PI / 180.0;
const DEFAULT_POST_WIDTH: f64 = 0.06;
const DEFAULT_FRAME_DEPTH: f64 = 0.07;
/// Wand für die Öffnungs-Geometrie: Achse, aufgelöste Dicke und Referenzversatz.
#[derive(Clone, Copy, Debug)]
pub struct WallRef {
pub start: V,
pub end: V,
pub total: f64,
pub ref_off: f64,
}
impl WallRef {
pub fn frame(&self) -> (V, V) {
let u = normalize(sub(self.end, self.start));
(u, left_normal(u))
}
}
/// Öffnungs-Intervall entlang der Achse (auf die Achslänge geklemmt) oder `None` (entartet).
pub fn opening_interval(w: &WallRef, position: f64, width: f64) -> Option<(f64, f64)> {
let axis = hypot2(w.end.x - w.start.x, w.end.y - w.start.y);
let from = max(0.0, min(position, axis));
let to = max(from, min(position + width, axis));
if to - from < 1e-4 {
None
} else {
Some((from, to))
}
}
pub fn opening_jambs(w: &WallRef, position: f64, width: f64) -> Option<(V, V)> {
let (from, to) = opening_interval(w, position, width)?;
Some((along(w.start, w.end, from), along(w.start, w.end, to)))
}
/// Lücken-Rechteck über die volle Wanddicke (jambStart+n/2 → jambEnd+n/2 → jambEnd−n/2 → jambStart−n/2).
pub fn opening_gap_quad(w: &WallRef, position: f64, width: f64) -> Option<Vec<V>> {
let (js, je) = opening_jambs(w, position, width)?;
let n = w.frame().1;
let outer = w.ref_off + w.total / 2.0;
let inner = w.ref_off - w.total / 2.0;
Some(vec![add(js, scale(n, outer)), add(je, scale(n, outer)), add(je, scale(n, inner)), add(js, scale(n, inner))])
}
#[derive(Clone, Copy, Debug)]
pub struct DoorLeaf {
pub hinge: V,
pub open_end: V,
pub closed_end: V,
pub radius: f64,
}
fn compute_leaf(hinge: V, closed_dir: V, swing_dir: V, angle: f64, width: f64) -> DoorLeaf {
let open_dir = v(closed_dir.x * cos(angle) + swing_dir.x * sin(angle), closed_dir.y * cos(angle) + swing_dir.y * sin(angle));
DoorLeaf { hinge, open_end: add(hinge, scale(open_dir, width)), closed_end: add(hinge, scale(closed_dir, width)), radius: width }
}
/// Tür-Parameter: `swing_right`, `open_out`, `hinge_end` (false = Start), `swing_angle` in Grad.
#[derive(Clone, Copy, Debug)]
pub struct DoorParams {
pub swing_right: bool,
pub open_out: bool,
pub hinge_end: bool,
pub swing_angle: f64,
}
/// Türblätter (1 oder 2 Flügel); leer bei entarteter Öffnung.
pub fn door_leaves(w: &WallRef, position: f64, width: f64, p: &DoorParams, leaf_count: f64) -> Vec<DoorLeaf> {
let Some((js, je)) = opening_jambs(w, position, width) else { return Vec::new() };
let (u, n) = w.frame();
let wd = hypot2(je.x - js.x, je.y - js.y);
let swing_sign = if p.swing_right { -1.0 } else { 1.0 };
let dir_sign = if p.open_out { -1.0 } else { 1.0 };
let swing_dir = scale(n, swing_sign * dir_sign);
let angle = p.swing_angle * DEG;
if leaf_count >= 2.0 {
let hw = wd / 2.0;
return vec![compute_leaf(js, u, swing_dir, angle, hw), compute_leaf(je, scale(u, -1.0), swing_dir, angle, hw)];
}
let (hinge, closed_dir) = if p.hinge_end { (je, scale(u, -1.0)) } else { (js, u) };
vec![compute_leaf(hinge, closed_dir, swing_dir, angle, wd)]
}
/// Eintrag der Flügeleinteilung.
#[derive(Clone, Copy, Debug)]
pub struct Sash {
pub post: bool,
/// `false` ⇔ `autoWidth === false`.
pub auto_width: bool,
/// feste Breite (nur wenn `!auto_width`), NaN = nicht gesetzt
pub width: f64,
pub post_width: f64,
pub operable: bool,
}
#[derive(Clone, Debug)]
pub struct WindowSpec {
pub sashes: Vec<Sash>,
pub frame_width: f64,
/// NaN = nicht gesetzt
pub frame_depth: f64,
/// NaN = nicht gesetzt
pub inset_from_face: f64,
pub inset_inner: bool,
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum Detail {
Grob,
Mittel,
Fein,
}
#[derive(Default, Clone, Debug)]
pub struct WindowSymbol {
pub frame: Vec<V>,
pub glass_lines: Vec<(V, V)>,
pub mullion_lines: Vec<(V, V)>,
pub sash_frames: Vec<Vec<V>>,
pub meeting_marks: Vec<Vec<V>>,
pub jamb_marks: Vec<Vec<V>>,
}
fn or_zero(x: f64) -> f64 {
if x.is_nan() {
0.0
} else {
x
}
}
fn sash_segments(sashes: &[Sash], total_width: f64) -> Vec<(usize, f64, f64)> {
if sashes.is_empty() {
return Vec::new();
}
let post_w = |s: &Sash| max(0.0, if s.post_width.is_nan() { DEFAULT_POST_WIDTH } else { s.post_width });
let fixed_w = |s: &Sash| max(0.0, or_zero(s.width));
let mut fixed_sum = 0.0;
let mut auto_count = 0.0;
for s in sashes {
if s.post {
fixed_sum += post_w(s);
} else if !s.auto_width {
fixed_sum += fixed_w(s);
} else {
auto_count += 1.0;
}
}
let remaining = max(0.0, total_width - fixed_sum);
let auto_width = if auto_count > 0.0 { remaining / auto_count } else { 0.0 };
let mut segs = Vec::with_capacity(sashes.len());
let mut cursor = 0.0;
for (i, s) in sashes.iter().enumerate() {
let w = if s.post {
post_w(s)
} else if !s.auto_width {
fixed_w(s)
} else {
auto_width
};
segs.push((i, cursor, cursor + w));
cursor += w;
}
segs
}
/// Fenster-Symbol; `spec` nur mit auflösbarem Typ (sonst Alt-Pfad mit `wing_count`, NaN = 1).
pub fn window_symbol(
w: &WallRef,
position: f64,
width: f64,
glass_count: f64,
spec: Option<&WindowSpec>,
wing_count: f64,
detail: Detail,
) -> Option<WindowSymbol> {
let (js, je) = opening_jambs(w, position, width)?;
let n = w.frame().1;
let total = w.total;
let ref_off = w.ref_off;
let outer = ref_off + total / 2.0;
let inner = ref_off - total / 2.0;
if let Some(spec) = spec.filter(|s| !s.sashes.is_empty()) {
let fw = max(0.01, spec.frame_width);
let depth = min(total, if !spec.frame_depth.is_nan() && spec.frame_depth > 1e-9 { spec.frame_depth } else { DEFAULT_FRAME_DEPTH });
let inset = max(0.0, or_zero(spec.inset_from_face));
let half_t = total / 2.0;
let sign = if spec.inset_inner { 1.0 } else { -1.0 };
let mut front_rel = sign * (half_t - inset);
let mut back_rel = front_rel - sign * depth;
front_rel = max(-half_t, min(half_t, front_rel));
back_rel = max(-half_t, min(half_t, back_rel));
let frame_outer_n = ref_off + max(front_rel, back_rel);
let frame_inner_n = ref_off + min(front_rel, back_rel);
let band_depth = frame_outer_n - frame_inner_n;
let g_mid_base = (frame_outer_n + frame_inner_n) / 2.0;
let frame = vec![
add(js, scale(n, frame_outer_n)),
add(je, scale(n, frame_outer_n)),
add(je, scale(n, frame_inner_n)),
add(js, scale(n, frame_inner_n)),
];
let mut sym = WindowSymbol { frame, ..Default::default() };
if detail == Detail::Grob {
sym.glass_lines.push((add(js, scale(n, g_mid_base)), add(je, scale(n, g_mid_base))));
return Some(sym);
}
let fein = detail == Detail::Fein;
let axis_width = hypot2(je.x - js.x, je.y - js.y);
let segs = sash_segments(&spec.sashes, axis_width);
let reveal = if fein { min(band_depth * 0.3, fw * 0.7) } else { 0.0 };
let frame_block = |u_center: f64, half_u: f64| -> Vec<V> {
let a = along(js, je, u_center - half_u);
let b = along(js, je, u_center + half_u);
vec![add(a, scale(n, frame_outer_n)), add(b, scale(n, frame_outer_n)), add(b, scale(n, frame_inner_n)), add(a, scale(n, frame_inner_n))]
};
sym.jamb_marks.push(frame_block(fw / 2.0, fw / 2.0));
sym.jamb_marks.push(frame_block(axis_width - fw / 2.0, fw / 2.0));
for i in 0..segs.len().saturating_sub(1) {
let u_pos = segs[i].2;
if fein {
sym.meeting_marks.push(frame_block(u_pos - fw / 2.0, fw / 2.0));
sym.meeting_marks.push(frame_block(u_pos + fw / 2.0, fw / 2.0));
} else {
sym.meeting_marks.push(frame_block(u_pos, fw / 2.0));
}
}
for &(si, from, to) in &segs {
let s = &spec.sashes[si];
if s.post {
continue;
}
let clear_from = from + fw;
let clear_to = to - fw;
if clear_to - clear_from <= 1e-6 {
continue;
}
if !fein {
continue;
}
let g_outer_n = frame_outer_n - if s.operable { reveal } else { 0.0 };
let g_inner_n = frame_inner_n + if s.operable { reveal } else { 0.0 };
if s.operable {
let s_from = along(js, je, clear_from);
let s_to = along(js, je, clear_to);
sym.sash_frames.push(vec![
add(s_from, scale(n, g_outer_n)),
add(s_to, scale(n, g_outer_n)),
add(s_to, scale(n, g_inner_n)),
add(s_from, scale(n, g_inner_n)),
]);
}
}
return Some(sym);
}
// Alt-Pfad
let frame = vec![add(js, scale(n, outer)), add(je, scale(n, outer)), add(je, scale(n, inner)), add(js, scale(n, inner))];
let mut sym = WindowSymbol { frame, ..Default::default() };
let count = max(1.0, glass_count);
let mut i = 0.0;
while i < count {
let spread = total / 8.0;
let off = ref_off + if count == 1.0 { 0.0 } else { (i - (count - 1.0) / 2.0) * spread * 2.0 };
sym.glass_lines.push((add(js, scale(n, off)), add(je, scale(n, off))));
i += 1.0;
}
let wc = if wing_count.is_nan() { 1.0 } else { wing_count };
let wings = max(1.0, min(4.0, round(wc)));
if wings > 1.0 {
let post_depth = total * 0.6;
let p_outer = ref_off + post_depth / 2.0;
let p_inner = ref_off - post_depth / 2.0;
let mut k = 1.0;
while k < wings {
let t = k / wings;
let on_axis = add(js, scale(sub(je, js), t));
sym.mullion_lines.push((add(on_axis, scale(n, p_outer)), add(on_axis, scale(n, p_inner))));
k += 1.0;
}
}
Some(sym)
}
+446
View File
@@ -0,0 +1,446 @@
//! Öffnungs-Symbol (Tür/Fenster) im Grundriss ([K3a]): Port von `generatePlan/openings.ts`
//! (`addOpeningSymbol`, `addOpeningFrameBand`). Geometrie aus `opening_geom.rs`. Stil löst TS aus dem
//! Modell: Strichstärken kommen als Zahlen herein, Farben als Platz (Slot) heraus (0 = keine,
//! 1 Strichfarbe, 2 Rahmen, 3 Rahmen-Aufsicht, 4 Flügel/Sprossen, 5 Fensterbank-/Sims-Linie).
//!
//! Eingabe (`f64`): `[sx, sy, ex, ey, dicke, refOff, position, breite, art (0 Fenster | 1 Tür),
//! detail (0 grob | 1 mittel | 2 fein),
//! Tür: schwenkRechts, ausen, anschlagEnde, schwenkwinkel (NaN = 90), wandoeffnung, fluegel,
//! sturz (0 keine | 1 aussen | 2 innen | 3 beide),
//! Rahmen: hat, breite, art (0 Zarge | 1 Blockrahmen), einzug, einzugInnen,
//! Fenster: hatTyp, profilbreite, rahmentiefe (NaN), einzug (NaN), einzugInnen, altFluegel (NaN = 1),
//! glasAlt, sims (0 keine | 1 aussen | 2 innen | 3 beide), simsUnter (0|1), kasten (0|1),
//! kastenBreite, kastenHoehe,
//! Stärken: haar, rahmenHaar, rahmenAufsicht, fluegel, sims,
//! nFluegel, (pfosten, auto, breite, pfostenbreite, oeffenbar) × n]`.
//!
//! Ausgabe `[n, Eintrag × n]` in Zeichenreihenfolge:
//! ```text
//! 1 polygon [1, art (0 Pick-Fläche | 1 Rahmen-Aufsicht), weightMm, farbSlot, nPts, x, y …]
//! 2 line [2, cls, weightMm, farbSlot, strich, ax, ay, bx, by]
//! 3 arc [3, weightMm, cx, cy, fromX, fromY, toX, toY, r] (cls door-swing)
//! cls 0 door-leaf · 1 door-frame · 2 door-lintel · 3 opening-frame · 4 window-glass ·
//! 5 window-mullion · 6 window-sash · 7 window-stulp · 8 window-sill · 9 window-frame ·
//! 10 window-shading
//! strich 0 keiner (Schlüssel fehlt) · 1 Sturz [0.18, 0.09] · 2 Überkopf · 3 gepunktet [0.04, 0.08]
//! ```
use crate::jsmath::hypot2;
use crate::jsnum::{max, min, round};
use crate::opening_geom::*;
use crate::flat_read::Reader;
struct Out {
buf: Vec<f64>,
n: usize,
}
const C_LEAF: f64 = 0.0;
const C_DOOR_FRAME: f64 = 1.0;
const C_LINTEL: f64 = 2.0;
const C_OPENING_FRAME: f64 = 3.0;
const C_GLASS: f64 = 4.0;
const C_MULLION: f64 = 5.0;
const C_SASH: f64 = 6.0;
const C_STULP: f64 = 7.0;
const C_SILL: f64 = 8.0;
const C_WINDOW_FRAME: f64 = 9.0;
const C_SHADING: f64 = 10.0;
impl Out {
fn polygon(&mut self, art: f64, weight: f64, color: f64, pts: &[V]) {
self.n += 1;
self.buf.extend([1.0, art, weight, color, pts.len() as f64]);
for p in pts {
self.buf.extend([p.x, p.y]);
}
}
fn line(&mut self, cls: f64, weight: f64, color: f64, dash: f64, a: V, b: V) {
self.n += 1;
self.buf.extend([2.0, cls, weight, color, dash, a.x, a.y, b.x, b.y]);
}
fn arc(&mut self, weight: f64, c: V, from: V, to: V, r: f64) {
self.n += 1;
self.buf.extend([3.0, weight, c.x, c.y, from.x, from.y, to.x, to.y, r]);
}
/// Geschlossener Linienzug aus Eckpunkten (Kante i → i+1, zuletzt → 0).
fn ring(&mut self, cls: f64, weight: f64, color: f64, pts: &[V]) {
for i in 0..pts.len() {
self.line(cls, weight, color, 0.0, pts[i], pts[(i + 1) % pts.len()]);
}
}
}
pub fn plan_opening(buf: &[f64]) -> Vec<f64> {
plan_opening_inner(buf).unwrap_or_default()
}
fn plan_opening_inner(buf: &[f64]) -> Option<Vec<f64>> {
let mut r = Reader::new(buf);
let (sx, sy, ex, ey, total, ref_off) = (r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?);
let (position, width) = (r.num()?, r.num()?);
let is_door = r.num()? != 0.0;
let detail = match r.num()? as i64 {
0 => Detail::Grob,
1 => Detail::Mittel,
_ => Detail::Fein,
};
let door = DoorParams { swing_right: r.num()? != 0.0, open_out: r.num()? != 0.0, hinge_end: r.num()? != 0.0, swing_angle: 0.0 };
let swing_angle = r.num()?;
let door = DoorParams { swing_angle: if swing_angle.is_nan() { 90.0 } else { swing_angle }, ..door };
let wandoeffnung = r.num()? != 0.0;
let leaf_count = r.num()?;
let lintel = r.num()? as i64;
let has_frame = r.num()? != 0.0;
let frame_width = r.num()?;
let frame_block = r.num()? != 0.0;
let frame_inset = r.num()?;
let frame_inset_inner = r.num()? != 0.0;
let has_type = r.num()? != 0.0;
let win_frame_width = r.num()?;
let win_frame_depth = r.num()?;
let win_inset = r.num()?;
let win_inset_inner = r.num()? != 0.0;
let wing_count = r.num()?;
let glass_alt = r.num()?;
let sill_faces = r.num()? as i64;
let sill_under = r.num()? != 0.0;
let shading = r.num()? != 0.0;
let shading_width = r.num()?;
let shading_height = r.num()?;
let (hair, frame_hair, frame_view_w, sash_w, sill_w) = (r.num()?, r.num()?, r.num()?, r.num()?, r.num()?);
let n_sash = r.count()?;
let mut sashes = Vec::with_capacity(n_sash);
for _ in 0..n_sash {
sashes.push(Sash {
post: r.num()? != 0.0,
auto_width: r.num()? != 0.0,
width: r.num()?,
post_width: r.num()?,
operable: r.num()? != 0.0,
});
}
if ![sx, sy, ex, ey, total, ref_off, position, width].iter().all(|x| x.is_finite()) {
return None;
}
let w = WallRef { start: v(sx, sy), end: v(ex, ey), total, ref_off };
let (_, wn) = w.frame();
let mut o = Out { buf: Vec::new(), n: 0 };
if is_door {
let (jamb_start, jamb_end) = opening_jambs(&w, position, width)?;
if let Some(gap) = opening_gap_quad(&w, position, width) {
o.polygon(0.0, 0.0, 0.0, &gap);
}
if !wandoeffnung {
let count = max(1.0, round(if leaf_count.is_nan() { 1.0 } else { leaf_count }));
for leaf in door_leaves(&w, position, width, &door, count) {
o.line(C_LEAF, hair, 0.0, 0.0, leaf.hinge, leaf.open_end);
if detail != Detail::Grob {
o.arc(hair, leaf.hinge, leaf.closed_end, leaf.open_end, leaf.radius);
}
}
}
if detail == Detail::Fein {
let reveal = 0.06;
for jamb in [jamb_start, jamb_end] {
o.line(C_DOOR_FRAME, hair, 0.0, 0.0, add(jamb, scale(wn, reveal)), add(jamb, scale(wn, -reveal)));
}
}
if has_frame {
frame_band(&mut o, &w, position, width, frame_width, frame_block, frame_inset, frame_inset_inner, hair);
}
if lintel != 0 {
let half_d = total / 2.0;
let outer_off = ref_off - half_d;
let inner_off = ref_off + half_d;
let line = |off: f64| (add(jamb_start, scale(wn, off)), add(jamb_end, scale(wn, off)));
if lintel == 1 || lintel == 3 {
let (a, b) = line(outer_off);
o.line(C_LINTEL, hair, 1.0, 1.0, a, b);
}
if lintel == 2 || lintel == 3 {
let (a, b) = line(inner_off);
o.line(C_LINTEL, hair, 1.0, 1.0, a, b);
}
}
return Some(finish(o));
}
// Fenster
let spec = if has_type {
Some(WindowSpec {
sashes,
frame_width: win_frame_width,
frame_depth: win_frame_depth,
inset_from_face: win_inset,
inset_inner: win_inset_inner,
})
} else {
None
};
let sym = window_symbol(&w, position, width, glass_alt, spec.as_ref(), wing_count, detail)?;
if let Some(gap) = opening_gap_quad(&w, position, width) {
o.polygon(0.0, 0.0, 0.0, &gap);
}
if detail == Detail::Grob {
let idx = sym.glass_lines.len() / 2;
if let Some(g) = sym.glass_lines.get(idx).or_else(|| sym.glass_lines.first()) {
o.line(C_GLASS, sash_w, 4.0, 0.0, g.0, g.1);
}
} else {
o.polygon(1.0, frame_view_w, 3.0, &sym.frame);
for (a, b) in &sym.mullion_lines {
o.line(C_MULLION, sash_w, 4.0, 0.0, *a, *b);
}
if detail == Detail::Fein {
for pts in &sym.sash_frames {
o.ring(C_SASH, sash_w, 4.0, pts);
}
}
for mark in &sym.jamb_marks {
o.ring(C_STULP, frame_hair, 2.0, mark);
}
for mark in &sym.meeting_marks {
o.ring(C_STULP, sash_w, 4.0, mark);
}
for (a, b) in &sym.glass_lines {
o.line(C_GLASS, hair, 0.0, 0.0, *a, *b);
}
if detail == Detail::Fein {
if let Some((js, je)) = opening_jambs(&w, position, width) {
let outer_n = min(dot(sub(sym.frame[0], js), wn), dot(sub(sym.frame[2], js), wn));
let (ov, proj) = (0.03, 0.04);
let s0 = along(js, je, -ov);
let s1 = along(je, js, -ov);
let b0 = add(s0, scale(wn, outer_n));
let b1 = add(s1, scale(wn, outer_n));
let b2 = add(s1, scale(wn, outer_n - proj));
let b3 = add(s0, scale(wn, outer_n - proj));
for (a, b) in [(b0, b1), (b1, b2), (b2, b3), (b3, b0)] {
o.line(C_SILL, hair, 1.0, 0.0, a, b);
}
let reveal = 0.06;
for jamb in [js, je] {
o.line(C_WINDOW_FRAME, hair, 1.0, 0.0, add(jamb, scale(wn, reveal)), add(jamb, scale(wn, -reveal)));
}
}
}
}
if detail != Detail::Grob && sill_faces != 0 {
let dash = if sill_under { 2.0 } else { 3.0 };
let pair01_is_outer = dot(sym.frame[0], wn) <= dot(sym.frame[3], wn);
let (outer_pair, inner_pair) = if pair01_is_outer {
((sym.frame[0], sym.frame[1]), (sym.frame[3], sym.frame[2]))
} else {
((sym.frame[3], sym.frame[2]), (sym.frame[0], sym.frame[1]))
};
if sill_faces == 1 || sill_faces == 3 {
o.line(C_SILL, sill_w, 5.0, dash, outer_pair.0, outer_pair.1);
}
if sill_faces == 2 || sill_faces == 3 {
o.line(C_SILL, sill_w, 5.0, dash, inner_pair.0, inner_pair.1);
}
}
if shading {
if let Some((js, je)) = opening_jambs(&w, position, width) {
let (u, nrm) = w.frame();
let outer_face = ref_off - total / 2.0;
let axis_width = hypot2(je.x - js.x, je.y - js.y);
let box_width = if shading_width > 0.0 { shading_width } else { axis_width };
let box_height = max(0.0, shading_height);
let center = add(js, scale(u, axis_width / 2.0));
let half = box_width / 2.0;
let c1 = add(center, scale(u, -half));
let c2 = add(center, scale(u, half));
let p1 = add(c1, scale(nrm, outer_face));
let p2 = add(c2, scale(nrm, outer_face));
let p3 = add(c2, scale(nrm, outer_face + box_height));
let p4 = add(c1, scale(nrm, outer_face + box_height));
for (a, b) in [(p1, p2), (p2, p3), (p3, p4), (p4, p1)] {
o.line(C_SHADING, hair, 1.0, 2.0, a, b);
}
}
}
Some(finish(o))
}
fn finish(o: Out) -> Vec<f64> {
let mut out = Vec::with_capacity(o.buf.len() + 1);
out.push(o.n as f64);
out.extend(o.buf);
out
}
/// Rahmenband einer Tür (Zarge/Blockrahmen) aus dem Typ der Tür.
#[allow(clippy::too_many_arguments)]
fn frame_band(o: &mut Out, w: &WallRef, position: f64, width: f64, frame_width: f64, block: bool, inset_from_face: f64, inset_inner: bool, hair: f64) {
let Some((js, je)) = opening_jambs(w, position, width) else { return };
let n = w.frame().1;
let total = w.total;
let outer_face = w.ref_off - total / 2.0;
let inner_face = w.ref_off + total / 2.0;
let clamped_inset = max(0.0, min(inset_from_face, total));
let near_is_aussen = !inset_inner;
let face_near = if near_is_aussen { outer_face + clamped_inset } else { inner_face - clamped_inset };
let face_far = if near_is_aussen { inner_face } else { outer_face };
let lo = min(face_near, face_far);
let hi = max(face_near, face_far);
let fw = max(0.0, frame_width);
let (band_lo, band_hi, j_start, j_end, weight);
if block {
let depth = min(fw, hi - lo);
band_lo = if near_is_aussen { lo } else { hi - depth };
band_hi = if near_is_aussen { lo + depth } else { hi };
j_start = js;
j_end = je;
weight = hair * 2.2;
} else {
let jamb_span = hypot2(je.x - js.x, je.y - js.y);
let jamb_inset = min(fw, jamb_span / 2.0);
j_start = along(js, je, jamb_inset);
j_end = along(je, js, jamb_inset);
let depth_inset = min(fw, (hi - lo) / 2.0);
band_lo = lo + depth_inset;
band_hi = hi - depth_inset;
weight = hair;
}
let p1 = add(j_start, scale(n, band_lo));
let p2 = add(j_end, scale(n, band_lo));
let p3 = add(j_end, scale(n, band_hi));
let p4 = add(j_start, scale(n, band_hi));
for (a, b) in [(p1, p2), (p2, p3), (p3, p4), (p4, p1)] {
o.line(C_OPENING_FRAME, weight, 1.0, 0.0, a, b);
}
}
// ── Fenster-Symbol als Einzelaufruf (für die Fassade `windowSymbol`, z. B. im Schnitt) ──────────
/// Eingabe `[sx, sy, ex, ey, dicke, refOff, position, breite, glasAnzahl, altFluegel (NaN = 1),
/// detail, hatTyp, profilbreite, rahmentiefe (NaN), einzug (NaN), einzugInnen, nFluegel,
/// (pfosten, auto, breite, pfostenbreite, oeffenbar) × n]`; Ausgabe
/// `[1, Rahmen(4 Punkte), nGlas, 4 Zahlen × n, nPfosten, 4 × n, nFluegelRahmen, (nPts, pts…) × n,
/// nStoss, (nPts, pts…) × n, nLaibung, (nPts, pts…) × n]` oder leer.
pub fn window_symbol_flat(buf: &[f64]) -> Vec<f64> {
(|| {
let mut r = Reader::new(buf);
let (sx, sy, ex, ey, total, ref_off, position, width) =
(r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?, r.num()?);
let glass = r.num()?;
let wings = r.num()?;
let detail = match r.num()? as i64 {
0 => Detail::Grob,
1 => Detail::Mittel,
_ => Detail::Fein,
};
let has_type = r.num()? != 0.0;
let (fw, fd, inset) = (r.num()?, r.num()?, r.num()?);
let inner = r.num()? != 0.0;
let n = r.count()?;
let mut sashes = Vec::with_capacity(n);
for _ in 0..n {
sashes.push(Sash { post: r.num()? != 0.0, auto_width: r.num()? != 0.0, width: r.num()?, post_width: r.num()?, operable: r.num()? != 0.0 });
}
if ![sx, sy, ex, ey, total, ref_off, position, width].iter().all(|x| x.is_finite()) {
return None;
}
let w = WallRef { start: v(sx, sy), end: v(ex, ey), total, ref_off };
let spec = if has_type { Some(WindowSpec { sashes, frame_width: fw, frame_depth: fd, inset_from_face: inset, inset_inner: inner }) } else { None };
let s = window_symbol(&w, position, width, glass, spec.as_ref(), wings, detail)?;
let mut out = vec![1.0];
for p in &s.frame {
out.extend([p.x, p.y]);
}
for list in [&s.glass_lines, &s.mullion_lines] {
out.push(list.len() as f64);
for (a, b) in list.iter() {
out.extend([a.x, a.y, b.x, b.y]);
}
}
for rings in [&s.sash_frames, &s.meeting_marks, &s.jamb_marks] {
out.push(rings.len() as f64);
for pts in rings.iter() {
out.push(pts.len() as f64);
for p in pts {
out.extend([p.x, p.y]);
}
}
}
Some(out)
})()
.unwrap_or_default()
}
#[cfg(test)]
mod tests {
use super::*;
const NAN: f64 = f64::NAN;
/// Wand 0..6 m entlang x, Dicke 0.3, Öffnung ab 1.0 m, 0.9 m breit.
fn input(door: bool, detail: f64, has_type: bool, sashes: &[[f64; 5]]) -> Vec<f64> {
let mut b = vec![0.0, 0.0, 6.0, 0.0, 0.3, 0.0, 1.0, 0.9, door as u8 as f64, detail];
b.extend([0.0, 0.0, 0.0, NAN, 0.0, 1.0, 3.0]); // Tür: links, innen, Start, 90°, normal, 1 Blatt, Sturz beide
b.extend([0.0, 0.06, 0.0, 0.0, 0.0]); // kein Rahmenband
b.extend([has_type as u8 as f64, 0.06, NAN, NAN, 0.0, NAN, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0]); // Fenster
b.extend([0.02, 0.02, 0.02, 0.02, 0.02]); // Strichstärken
b.push(sashes.len() as f64);
for s in sashes {
b.extend(s);
}
b
}
fn tags(buf: &[f64]) -> Vec<f64> {
let (mut i, mut t) = (1, Vec::new());
for _ in 0..buf[0] as usize {
t.push(buf[i]);
i += match buf[i] as i64 {
1 => 5 + 2 * buf[i + 4] as usize,
2 => 9,
_ => 9,
};
}
assert_eq!(i, buf.len());
t
}
#[test]
fn tuer_grob_hat_pick_blatt_und_zwei_sturzlinien() {
let t = tags(&plan_opening(&input(true, 0.0, false, &[])));
assert_eq!(t, vec![1.0, 2.0, 2.0, 2.0]);
}
#[test]
fn tuer_fein_hat_bogen_und_anschlagstriche() {
let t = tags(&plan_opening(&input(true, 2.0, false, &[])));
assert_eq!(t.iter().filter(|x| **x == 3.0).count(), 1);
assert_eq!(t.len(), 1 + 1 + 1 + 2 + 2);
}
#[test]
fn fenster_grob_hat_eine_glaslinie() {
let t = tags(&plan_opening(&input(false, 0.0, false, &[])));
assert_eq!(t, vec![1.0, 2.0]);
}
#[test]
fn entartete_oeffnung_und_unsinn_ergeben_leeres_ergebnis() {
let mut b = input(false, 1.0, false, &[]);
b[7] = 0.0;
assert!(plan_opening(&b).is_empty());
assert!(plan_opening(&[1.0]).is_empty());
let mut c = input(true, 1.0, false, &[]);
c[0] = f64::NAN;
assert!(plan_opening(&c).is_empty());
assert!(window_symbol_flat(&[]).is_empty());
}
#[test]
fn typisiertes_fenster_fein_hat_fluegelrahmen() {
let sashes = [[0.0, 1.0, NAN, NAN, 1.0], [0.0, 1.0, NAN, NAN, 1.0]];
let a = plan_opening(&input(false, 2.0, true, &sashes));
let g = plan_opening(&input(false, 1.0, true, &sashes));
assert!(a[0] > g[0]);
}
}
+1
View File
@@ -27,6 +27,7 @@ mod plan_buf;
mod gpu_compile;
mod plan_stairs;
mod plan_walls;
mod plan_openings;
mod hatch;
use wasm_bindgen::prelude::wasm_bindgen;
+15
View File
@@ -0,0 +1,15 @@
//! Bindungen von Öffnungs-Symbol und Fenster-Symbol (`crate::plan_openings`). Layout s. dort.
use wasm_bindgen::prelude::wasm_bindgen;
/// Tür-/Fenster-Symbol einer Öffnung im Grundriss; Unsinn → leer.
#[wasm_bindgen]
pub fn plan_opening_flat(buf: &[f64]) -> Vec<f64> {
crate::plan_openings::plan_opening(buf)
}
/// Fenster-Symbol (Rahmen, Glas, Flügel, Stulp) einer Öffnung; Unsinn/entartet → leer.
#[wasm_bindgen]
pub fn window_symbol_flat(buf: &[f64]) -> Vec<f64> {
crate::plan_openings::window_symbol_flat(buf)
}
-200
View File
@@ -2266,206 +2266,6 @@ pub fn along(p1: Vec2, p2: Vec2, d: f64) -> Vec2 {
add(p1, scale(normalize(sub(p2, p1)), d))
}
/// Achslaenge einer Wand (Port von `wallAxisLength`; Wand → start/end).
pub fn wall_axis_length(start: Vec2, end: Vec2) -> f64 {
(end.x - start.x).hypot(end.y - start.y)
}
/// Oeffnungs-Intervall entlang der Achse (Port von `openingInterval`).
#[derive(Serialize, Deserialize, Clone, Copy, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Interval {
pub from: f64,
pub to: f64,
}
pub fn opening_interval(start: Vec2, end: Vec2, position: f64, width: f64) -> Option<Interval> {
let axis = wall_axis_length(start, end);
let from = position.min(axis).max(0.0);
let to = (position + width).min(axis).max(from);
if to - from < 1e-4 {
return None; // entartet: Breite <= 0 oder vollstaendig ausserhalb der Achse
}
Some(Interval { from, to })
}
/// Einheits-Laufrichtung (u) und linke Normale (n) der Wandachse (Port von
/// `wallAxisFrame`).
#[derive(Serialize, Deserialize, Clone, Copy, Debug)]
pub struct AxisFrame {
pub u: Vec2,
pub n: Vec2,
}
pub fn wall_axis_frame(start: Vec2, end: Vec2) -> AxisFrame {
let u = normalize(sub(end, start));
AxisFrame { u, n: left_normal(u) }
}
/// Die beiden Pfosten-Punkte einer Oeffnung im Grundriss (Port von `openingJambs`).
#[derive(Serialize, Deserialize, Clone, Copy, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Jambs {
pub jamb_start: Vec2,
pub jamb_end: Vec2,
}
pub fn opening_jambs(start: Vec2, end: Vec2, position: f64, width: f64) -> Option<Jambs> {
let iv = opening_interval(start, end, position, width)?;
Some(Jambs {
jamb_start: along(start, end, iv.from),
jamb_end: along(start, end, iv.to),
})
}
/// Luecken-Rechteck-Ecken ueber die volle Wanddicke (Port von `openingGapQuad`).
/// Reihenfolge: jambStart(+n/2) → jambEnd(+n/2) → jambEnd(−n/2) → jambStart(−n/2).
pub fn opening_gap_quad(
start: Vec2,
end: Vec2,
position: f64,
width: f64,
thickness: f64,
ref_offset: f64,
) -> Option<Vec<Vec2>> {
let jambs = opening_jambs(start, end, position, width)?;
let n = wall_axis_frame(start, end).n;
let outer = ref_offset + thickness / 2.0;
let inner = ref_offset - thickness / 2.0;
Some(vec![
add(jambs.jamb_start, scale(n, outer)),
add(jambs.jamb_end, scale(n, outer)),
add(jambs.jamb_end, scale(n, inner)),
add(jambs.jamb_start, scale(n, inner)),
])
}
/// Mittelpunkt einer Oeffnung im Grundriss (Port von `openingCenter`).
pub fn opening_center(start: Vec2, end: Vec2, position: f64, width: f64) -> Option<Vec2> {
let iv = opening_interval(start, end, position, width)?;
Some(along(start, end, (iv.from + iv.to) / 2.0))
}
/// Aufgeloeste Tuer-Symbol-Geometrie im Grundriss (Port von `DoorSymbol`).
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct DoorSymbol {
pub hinge: Vec2,
pub open_end: Vec2,
pub closed_end: Vec2,
pub radius: f64,
pub jamb_start: Vec2,
pub jamb_end: Vec2,
pub normal: Vec2,
}
/// Port von `doorSymbol`. `swing`/`opening_dir`/`hinge_side` folgen der TS-
/// `??`-Fallback-Semantik (`None` → TS-Default); `swing_angle` `None` → 90°.
pub fn door_symbol(
start: Vec2,
end: Vec2,
position: f64,
width: f64,
swing: Option<&str>,
opening_dir: Option<&str>,
hinge_side: Option<&str>,
swing_angle: Option<f64>,
) -> Option<DoorSymbol> {
let jambs = opening_jambs(start, end, position, width)?;
let frame = wall_axis_frame(start, end);
let (jamb_start, jamb_end) = (jambs.jamb_start, jambs.jamb_end);
// TS berechnet die Breite NEU aus den geklemmten Pfosten (nicht das rohe
// `o.width`) — bewusst repliziert.
let w = (jamb_end.x - jamb_start.x).hypot(jamb_end.y - jamb_start.y);
let swing_sign = if swing.unwrap_or("left") == "left" { 1.0 } else { -1.0 };
let dir_sign = if opening_dir.unwrap_or("in") == "in" { 1.0 } else { -1.0 };
let swing_dir = scale(frame.n, swing_sign * dir_sign);
let hinge_at_start = hinge_side.unwrap_or("start") == "start";
let hinge = if hinge_at_start { jamb_start } else { jamb_end };
let closed_dir = if hinge_at_start { frame.u } else { scale(frame.u, -1.0) };
let angle = swing_angle.unwrap_or(90.0) * DEG;
let open_dir = Vec2 {
x: closed_dir.x * angle.cos() + swing_dir.x * angle.sin(),
y: closed_dir.y * angle.cos() + swing_dir.y * angle.sin(),
};
Some(DoorSymbol {
hinge,
open_end: add(hinge, scale(open_dir, w)),
closed_end: add(hinge, scale(closed_dir, w)),
radius: w,
jamb_start,
jamb_end,
normal: frame.n,
})
}
/// Aufgeloeste Fenster-Linien im Grundriss (Port von `WindowSymbol`).
#[derive(Serialize, Deserialize, Clone, Debug)]
#[serde(rename_all = "camelCase")]
pub struct WindowSymbol {
pub frame: Vec<Vec2>,
pub glass_lines: Vec<(Vec2, Vec2)>,
pub mullion_lines: Vec<(Vec2, Vec2)>,
}
/// Port von `windowSymbol`. `thickness`/`ref_offset` sind bereits aufgeloeste
/// Werte (siehe Modul-Kommentar); `wing_count` `None` → TS-Default `1`.
pub fn window_symbol(
start: Vec2,
end: Vec2,
position: f64,
width: f64,
thickness: f64,
ref_offset: f64,
glass_count: f64,
wing_count: Option<f64>,
) -> Option<WindowSymbol> {
let jambs = opening_jambs(start, end, position, width)?;
let (jamb_start, jamb_end) = (jambs.jamb_start, jambs.jamb_end);
let n = wall_axis_frame(start, end).n;
let outer = ref_offset + thickness / 2.0;
let inner = ref_offset - thickness / 2.0;
let frame_quad = vec![
add(jamb_start, scale(n, outer)),
add(jamb_end, scale(n, outer)),
add(jamb_end, scale(n, inner)),
add(jamb_start, scale(n, inner)),
];
let mut glass_lines: Vec<(Vec2, Vec2)> = Vec::new();
let count = glass_count.max(1.0);
let mut i: i64 = 0;
while (i as f64) < count {
let spread = thickness / 8.0;
let off = if count == 1.0 {
ref_offset
} else {
ref_offset + ((i as f64) - (count - 1.0) / 2.0) * spread * 2.0
};
glass_lines.push((add(jamb_start, scale(n, off)), add(jamb_end, scale(n, off))));
i += 1;
}
let mut mullion_lines: Vec<(Vec2, Vec2)> = Vec::new();
let wings = wing_count.unwrap_or(1.0).round().min(4.0).max(1.0);
if wings > 1.0 {
let post_depth = thickness * 0.6;
let p_outer = ref_offset + post_depth / 2.0;
let p_inner = ref_offset - post_depth / 2.0;
let wings_n = wings as i64;
for k in 1..wings_n {
let t = k as f64 / wings;
let on_axis = add(jamb_start, scale(sub(jamb_end, jamb_start), t));
mullion_lines.push((add(on_axis, scale(n, p_outer)), add(on_axis, scale(n, p_inner))));
}
}
Some(WindowSymbol { frame: frame_quad, glass_lines, mullion_lines })
}
#[cfg(test)]
mod tests {
use super::*;
+41 -334
View File
@@ -1,8 +1,7 @@
// Geometrie-Helfer für Öffnungen (Fenster/Türen) — reine Funktionen, die eine
// `Opening` relativ zu ihrer Wirts-Wand in konkrete Welt-Geometrie auflösen:
// • die Öffnungs-Lücke entlang der Wandachse (from/to in Metern),
// • das Türblatt (Scharnier → offenes/geschlossenes Ende) + Schwenkbogen,
// • die Fenster-Rahmen-/Glaslinien quer über die Lücke,
// • die Fenster-Rahmen-/Glaslinien quer über die Lücke (`windowSymbol`, Fassade über den Rust-Kern),
// • die vertikale Lage (UK/OK der Öffnung, absolut in Metern).
//
// Da JEDE Größe aus der aktuellen Wandachse (`wall.start`/`wall.end`) abgeleitet
@@ -12,12 +11,11 @@
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import type { Opening, Project, SashDef, Vec2, Wall } from "../model/types";
import { core } from "../engine/coreWasm";
import { getWallType, wallTypeThickness } from "../model/types";
import { add, along, leftNormal, normalize, scale, sub } from "../model/geometry";
import { wallReferenceOffset, wallVerticalExtent } from "../model/wall";
const DEG = Math.PI / 180;
/** Achslänge einer Wand (Meter). */
export function wallAxisLength(wall: Wall): number {
return Math.hypot(wall.end.x - wall.start.x, wall.end.y - wall.start.y);
@@ -104,121 +102,6 @@ export function openingCenter(wall: Wall, o: Opening): Vec2 | null {
return along(wall.start, wall.end, (iv.from + iv.to) / 2);
}
// ── Tür-Symbol (Plan) ────────────────────────────────────────────────────────
/** Aufgelöste Tür-Symbol-Geometrie im Grundriss (Weltkoordinaten). */
export interface DoorSymbol {
/** Scharnierpunkt (auf der Achse). */
hinge: Vec2;
/** Ende des Blatts in GEÖFFNETER Stellung. */
openEnd: Vec2;
/** Ende des Blatts in GESCHLOSSENER Stellung (Bogen-Startpunkt). */
closedEnd: Vec2;
/** Radius (= Türbreite) des Schwenkbogens. */
radius: number;
/** Beide Pfosten-Punkte (für Rahmen-/Anschlagstriche). */
jambStart: Vec2;
jambEnd: Vec2;
/** Achs-Normale (für kurze Anschlagstriche quer zur Wand). */
normal: Vec2;
}
/**
* Löst die Tür-Symbolik auf. `swing` wählt die Aufschlagseite (linke/rechte
* Achs-Normale), `openingDir` ("out") spiegelt sie auf die andere Seite,
* `hinge` wählt den Scharnier-Pfosten, `swingAngle` (Grad, Default 90) bestimmt,
* wie weit das Blatt in der offenen Stellung aufsteht.
*/
export function doorSymbol(wall: Wall, o: Opening): DoorSymbol | null {
const jambs = openingJambs(wall, o);
if (!jambs) return null;
const { u, n } = wallAxisFrame(wall);
const { jambStart, jambEnd } = jambs;
const width = Math.hypot(jambEnd.x - jambStart.x, jambEnd.y - jambStart.y);
const swingSign = (o.swing ?? "left") === "left" ? 1 : -1;
const dirSign = (o.openingDir ?? "in") === "in" ? 1 : -1;
const swingDir = scale(n, swingSign * dirSign);
const hinge = (o.hinge ?? "start") === "start" ? jambStart : jambEnd;
// Geschlossene Richtung zeigt vom Scharnier zum GEGENüberliegenden Pfosten.
const closedDir = (o.hinge ?? "start") === "start" ? u : scale(u, -1);
const angle = (o.swingAngle ?? 90) * DEG;
// Offenes Blatt-Ende: um `angle` von der geschlossenen Richtung zur
// Schwenkrichtung gedreht (Interpolation über die Basis closedDir/swingDir).
const openDir = {
x: closedDir.x * Math.cos(angle) + swingDir.x * Math.sin(angle),
y: closedDir.y * Math.cos(angle) + swingDir.y * Math.sin(angle),
};
return {
hinge,
openEnd: add(hinge, scale(openDir, width)),
closedEnd: add(hinge, scale(closedDir, width)),
radius: width,
jambStart,
jambEnd,
normal: n,
};
}
/** Ein einzelnes Türblatt (Grundriss): Scharnier + geschlossenes/offenes Ende + Radius. */
export interface DoorLeaf {
hinge: Vec2;
openEnd: Vec2;
closedEnd: Vec2;
radius: number;
}
/** Blatt-Geometrie aus Scharnier, geschlossener Richtung, Schwenkrichtung, Winkel, Breite. */
function computeLeaf(
hinge: Vec2,
closedDir: Vec2,
swingDir: Vec2,
angle: number,
width: number,
): DoorLeaf {
const openDir = {
x: closedDir.x * Math.cos(angle) + swingDir.x * Math.sin(angle),
y: closedDir.y * Math.cos(angle) + swingDir.y * Math.sin(angle),
};
return {
hinge,
openEnd: add(hinge, scale(openDir, width)),
closedEnd: add(hinge, scale(closedDir, width)),
radius: width,
};
}
/**
* Türblätter im Grundriss (1 oder 2 Flügel). Einflüglig: ein Blatt über die
* volle Breite (Scharnier je `o.hinge`). Zweiflüglig (`leafCount === 2`): zwei
* halbbreite Blätter, an den GEGENüberliegenden Pfosten angeschlagen, beide zur
* selben Seite schwenkend (symmetrische Doppeltür / Stulptür). `doorSymbol`
* bleibt unverändert (einflügelig) für Bestandspfade/Parität; dies ist additiv.
*/
export function doorLeaves(wall: Wall, o: Opening, leafCount: number): DoorLeaf[] {
const jambs = openingJambs(wall, o);
if (!jambs) return [];
const { u, n } = wallAxisFrame(wall);
const { jambStart, jambEnd } = jambs;
const width = Math.hypot(jambEnd.x - jambStart.x, jambEnd.y - jambStart.y);
const swingSign = (o.swing ?? "left") === "left" ? 1 : -1;
const dirSign = (o.openingDir ?? "in") === "in" ? 1 : -1;
const swingDir = scale(n, swingSign * dirSign);
const angle = (o.swingAngle ?? 90) * DEG;
if (leafCount >= 2) {
const hw = width / 2;
return [
computeLeaf(jambStart, u, swingDir, angle, hw),
computeLeaf(jambEnd, scale(u, -1), swingDir, angle, hw),
];
}
const hinge = (o.hinge ?? "start") === "start" ? jambStart : jambEnd;
const closedDir = (o.hinge ?? "start") === "start" ? u : scale(u, -1);
return [computeLeaf(hinge, closedDir, swingDir, angle, width)];
}
// ── Fenster-Symbol (Plan) ────────────────────────────────────────────────────
/** Aufgelöste Fenster-Linien im Grundriss (Weltkoordinaten). */
@@ -288,62 +171,6 @@ export interface WindowRenderSpec {
insetFace?: "aussen" | "innen";
}
/** Ein Segment (Flügel/Pfosten) der Flügeleinteilung, mit aufgelöster Breite. */
interface SashSegment {
sash: SashDef;
/** Abstand vom Laibungsstart in Metern (0 = jambStart). */
from: number;
/** Abstand vom Laibungsstart in Metern. */
to: number;
}
/** Default-Pfostenbreite (Meter), wenn ein `kind:"pfosten"`-Eintrag keine `postWidth` angibt. */
const DEFAULT_POST_WIDTH = 0.06;
/**
* Default-Rahmentiefe (Meter), wenn ein Fenster-/Türtyp keine explizite
* `frameDepth` trägt: reale Fensterrahmen sind ~70–90 mm tief (Holz/PVC/Alu),
* unabhängig von der Wanddicke — NICHT die volle Wanddicke (das liess Fenster
* wie einen massiven Block in der Öffnung wirken statt eines schlanken Rahmens
* mit sichtbarer Laibung/Leibung ringsum, s. Recherche zu VW/ArchiCAD-Fenster-
* konstruktion). Deckt sich mit `toWalls3d.ts::DEFAULT_FRAME_DEPTH` (2D=3D).
*/
const DEFAULT_FRAME_DEPTH = 0.07;
/**
* Löst eine Flügeleinteilung ({@link SashDef}-Liste) zu konkreten Segment-
* Intervallen (Meter, gemessen ab Laibungsstart) über die gegebene
* Gesamtbreite auf: `kind:"pfosten"` und Flügel mit `autoWidth === false`
* erhalten ihre feste Breite (`postWidth` bzw. `width`), die restlichen
* (`autoWidth`, Default) teilen sich die verbleibende Breite gleichmäßig.
* Degeneriert bei GLEICHMÄSSIGEN Flügeln (alle `autoWidth`, keine Pfosten) zur
* bisherigen `wingCount`-Gleichverteilung (Regressionssicherheit).
*/
function sashSegments(sashes: SashDef[], totalWidth: number): SashSegment[] {
if (sashes.length === 0) return [];
let fixedSum = 0;
let autoCount = 0;
for (const s of sashes) {
if (s.kind === "pfosten") fixedSum += Math.max(0, s.postWidth ?? DEFAULT_POST_WIDTH);
else if (s.autoWidth === false) fixedSum += Math.max(0, s.width ?? 0);
else autoCount++;
}
const remaining = Math.max(0, totalWidth - fixedSum);
const autoWidth = autoCount > 0 ? remaining / autoCount : 0;
const segs: SashSegment[] = [];
let cursor = 0;
for (const s of sashes) {
const w =
s.kind === "pfosten"
? Math.max(0, s.postWidth ?? DEFAULT_POST_WIDTH)
: s.autoWidth === false
? Math.max(0, s.width ?? 0)
: autoWidth;
segs.push({ sash: s, from: cursor, to: cursor + w });
cursor += w;
}
return segs;
}
/**
* Löst die Fenster-Symbolik auf: ein Rahmen-Rechteck über die Lücke (volle
* Wanddicke) plus 1–3 Glaslinien (dünne parallele Linien in der Wandmitte,
@@ -355,6 +182,9 @@ function sashSegments(sashes: SashDef[], totalWidth: number): SashSegment[] {
* referenziert/auflösbar), bleibt die Mittelpfosten-Berechnung beim
* BISHERIGEN Verhalten — `o.wingCount` gleichmäßig verteilt, KEINE
* Öffnungsandeutungen — exakt wie vor dieser Erweiterung (Rückwärtskompatibilität).
*
* Die Berechnung läuft im Rust-Kern (`src-tauri/core/src/opening_geom.rs`, [K3a]); diese Funktion
* ist die Fassade mit unveränderter Signatur.
*/
export function windowSymbol(
project: Project,
@@ -364,167 +194,44 @@ export function windowSymbol(
spec?: WindowRenderSpec,
detail: "grob" | "mittel" | "fein" = "fein",
): WindowSymbol | null {
const jambs = openingJambs(wall, o);
if (!jambs) return null;
const { n } = wallAxisFrame(wall);
const total = wallTypeThickness(getWallType(project, wall));
const refOff = wallReferenceOffset(wall, total);
const outer = refOff + total / 2;
const inner = refOff - total / 2;
const { jambStart, jambEnd } = jambs;
// ── Reicher Pfad (typisiertes Fenster mit Flügeltabelle), SIA-Darstellung ─
// Detailstufe = SIA-Massstab (fig. 36/37/38):
// • grob (1:100): NUR Blendrahmen-Band + eine Glaslinie über die ganze
// Öffnung — schematisch (SIA fig. 36).
// • mittel(1:50): Blendrahmen + Flügel-Trennlinien + je Flügel eine Glas-
// linie + kleines Stulp-Quadrat je Stoss (SIA fig. 37). KEINE Flügelrahmen.
// • fein (1:20): zusätzlich verschachtelte Flügelrahmen, Glas als Doppel-
// linie (Isolierverglasung) und je Stoss ZWEI Stulp-Quadrate (SIA fig. 38).
if (spec && spec.sashes.length > 0) {
const fw = Math.max(0.01, spec.frameWidth);
const depth = Math.min(total, spec.frameDepth && spec.frameDepth > 1e-9 ? spec.frameDepth : DEFAULT_FRAME_DEPTH);
const inset = Math.max(0, spec.insetFromFace ?? 0);
const halfT = total / 2;
// "aussen" = die Wandfläche, an der die ERSTE Wandtyp-Schicht (Aussenputz
// etc., "Schichten außen → innen") liegt — das ist die Seite mit dem
// NEGATIVEN Achs-Offset (s. addWallPoche: `off` startet bei `refOff-total/2`
// für die erste Schicht). Bug bis 2026-07-12: hier stand `+1` für "aussen"
// (positiver, NICHT negativer Offset) — der Rahmen landete dadurch bündig
// an der INNEREN statt der äusseren Wandfläche (Nutzer-Report: "im 2D innen
// bündig und im 3D aussen bündig" — das 3D-Pendant nutzt kompensierend eine
// gespiegelte Normale, s. resolveFrameNormalRange/openingAxisBox).
const sign = (spec.insetFace ?? "aussen") === "aussen" ? -1 : 1;
// Rahmen-Vorderkante bündig mit der Bezugsfläche, um `inset` zurück; der
// Körper reicht `depth` zur Wandmitte. Auf die Wanddicke geklemmt (mirror
// von resolveFrameNormalRange im 3D). Alles relativ zur Referenzlinie.
let frontRel = sign * (halfT - inset);
let backRel = frontRel - sign * depth;
frontRel = Math.max(-halfT, Math.min(halfT, frontRel));
backRel = Math.max(-halfT, Math.min(halfT, backRel));
const frameOuterN = refOff + Math.max(frontRel, backRel);
const frameInnerN = refOff + Math.min(frontRel, backRel);
const bandDepth = frameOuterN - frameInnerN;
const gMidBase = (frameOuterN + frameInnerN) / 2;
const frame = [
add(jambStart, scale(n, frameOuterN)),
add(jambEnd, scale(n, frameOuterN)),
add(jambEnd, scale(n, frameInnerN)),
add(jambStart, scale(n, frameInnerN)),
];
const glassLines: [Vec2, Vec2][] = [];
const mullionLines: [Vec2, Vec2][] = [];
const sashFrames: Vec2[][] = [];
const meetingMarks: Vec2[][] = [];
const jambMarks: Vec2[][] = [];
// grob (1:100): nur der Rahmenkasten + EINE Glaslinie über die ganze Öffnung.
if (detail === "grob") {
glassLines.push([add(jambStart, scale(n, gMidBase)), add(jambEnd, scale(n, gMidBase))]);
return { frame, glassLines, mullionLines, sashFrames, sashOpeningLines: [], meetingMarks, jambMarks };
}
const fein = detail === "fein";
const axisWidth = Math.hypot(jambEnd.x - jambStart.x, jambEnd.y - jambStart.y);
const segs = sashSegments(spec.sashes, axisWidth);
// Öffenbarer Flügel sitzt `reveal` tiefer im Blendrahmen (nur „fein").
const reveal = fein ? Math.min(bandDepth * 0.3, fw * 0.7) : 0;
// Profil-Block über die VOLLE Rahmentiefe (aussen bis innen), Breite `2·halfU`
// entlang der Achse, zentriert bei `uCenter` (Achsabstand ab jambStart) — der
// Rahmenquerschnitt, wie er im Grundriss-Schnitt sichtbar ist (Nutzer:
// „Rahmen aussen als zwei Flächen gleichbreit wie das Fenster [tief]").
const frameBlock = (uCenter: number, halfU: number): Vec2[] => {
const a = along(jambStart, jambEnd, uCenter - halfU);
const b = along(jambStart, jambEnd, uCenter + halfU);
return [
add(a, scale(n, frameOuterN)),
add(b, scale(n, frameOuterN)),
add(b, scale(n, frameInnerN)),
add(a, scale(n, frameInnerN)),
];
};
// Laibungs-Pfosten an beiden Enden (Blendrahmen-Querschnitt an der Wand-
// öffnung) — EIN Block je Seite, unabhängig vom Detailgrad. Teil des
// Blendrahmens (jambMarks), NICHT der Flügelstoss-Marken (meetingMarks) —
// separat steuerbar (Nutzer-Feedback).
jambMarks.push(frameBlock(fw / 2, fw / 2), frameBlock(axisWidth - fw / 2, fw / 2));
// Flügel-Trennlinien (Mittelpfosten) an den inneren Segmentgrenzen +
// Stulp-Block: mittel 1, fein 2 (die beiden zusammenstossenden Profile) —
// je über die volle Rahmentiefe. KEINE zusätzliche dünne Trennlinie mehr
// daneben (Nutzer-Feedback: „keine vertikale Trennlinie, sondern ein
// Rechteck") — der Block selbst markiert den Stoss.
for (let i = 0; i < segs.length - 1; i++) {
const uPos = segs[i].to;
if (fein) {
meetingMarks.push(frameBlock(uPos - fw / 2, fw / 2), frameBlock(uPos + fw / 2, fw / 2));
} else {
meetingMarks.push(frameBlock(uPos, fw / 2));
}
}
for (const seg of segs) {
if (seg.sash.kind === "pfosten") continue;
const clearFrom = seg.from + fw;
const clearTo = seg.to - fw;
if (clearTo - clearFrom <= 1e-6) continue;
const operable = !!seg.sash.opening && seg.sash.opening !== "fest";
// „mittel" (SIA fig. 37) zeigt NUR Blendrahmen + Pfosten/Stulp — noch KEINE
// Glaslinie/Flügelrahmen (Nutzer-Vorgabe: „im 1:50 muss man die Fenster-
// linie noch nicht sehen, nur die Vierecke aussen/innen"). Das kommt erst
// bei „fein" (SIA fig. 38) dazu.
if (!fein) continue;
const gOuterN = frameOuterN - (operable ? reveal : 0);
const gInnerN = frameInnerN + (operable ? reveal : 0);
// Verschachtelter Flügelrahmen NUR bei „fein" (SIA fig. 38); „mittel" bleibt
// beim reinen Blendrahmen-Band (SIA fig. 37).
// Keine Glaslinie mehr im Feld (auch nicht bei „fein") — Nutzer-Feedback:
// eine feine Haarlinie mittig im Glasfeld wird nicht gebraucht, unabhängig
// von der Fensterposition. Der Flügelrahmen (nur bei öffenbaren Flügeln)
// bleibt als einzige zusätzliche Kontur bei „fein" bestehen.
if (operable) {
const sFrom = along(jambStart, jambEnd, clearFrom);
const sTo = along(jambStart, jambEnd, clearTo);
sashFrames.push([
add(sFrom, scale(n, gOuterN)),
add(sTo, scale(n, gOuterN)),
add(sTo, scale(n, gInnerN)),
add(sFrom, scale(n, gInnerN)),
]);
}
}
return { frame, glassLines, mullionLines, sashFrames, sashOpeningLines: [], meetingMarks, jambMarks };
}
// ── Alt-Pfad (kein Typ auflösbar) ────────────────────────────────────────
// UNVERÄNDERT (Rust-Parität kernel2d): Rahmen an voller Wanddicke, Glaslinien
// mittig, (wingCount−1) gleichmäßige Mittelpfosten. Keine Flügelrahmen.
const frame = [
add(jambStart, scale(n, outer)),
add(jambEnd, scale(n, outer)),
add(jambEnd, scale(n, inner)),
add(jambStart, scale(n, inner)),
const b: number[] = [
wall.start.x, wall.start.y, wall.end.x, wall.end.y, total, wallReferenceOffset(wall, total),
o.position, o.width, glassCount, o.wingCount ?? Number.NaN,
detail === "grob" ? 0 : detail === "mittel" ? 1 : 2,
spec ? 1 : 0,
spec?.frameWidth ?? 0, spec?.frameDepth ?? Number.NaN, spec?.insetFromFace ?? Number.NaN,
spec?.insetFace === "innen" ? 1 : 0,
spec?.sashes.length ?? 0,
];
const glassLines: [Vec2, Vec2][] = [];
const count = Math.max(1, glassCount);
for (let i = 0; i < count; i++) {
const spread = total / 8;
const off = refOff + (count === 1 ? 0 : (i - (count - 1) / 2) * spread * 2);
glassLines.push([add(jambStart, scale(n, off)), add(jambEnd, scale(n, off))]);
for (const s of spec?.sashes ?? []) {
b.push(s.kind === "pfosten" ? 1 : 0, s.autoWidth === false ? 0 : 1, s.width ?? Number.NaN, s.postWidth ?? Number.NaN,
s.opening && s.opening !== "fest" ? 1 : 0);
}
const mullionLines: [Vec2, Vec2][] = [];
const wings = Math.max(1, Math.min(4, Math.round(o.wingCount ?? 1)));
if (wings > 1) {
const postDepth = total * 0.6;
const pOuter = refOff + postDepth / 2;
const pInner = refOff - postDepth / 2;
for (let i = 1; i < wings; i++) {
const t = i / wings;
const onAxis = add(jambStart, scale(sub(jambEnd, jambStart), t));
mullionLines.push([add(onAxis, scale(n, pOuter)), add(onAxis, scale(n, pInner))]);
const f = core().window_symbol_flat(Float64Array.from(b));
if (f.length === 0) return null;
let i = 1;
const pt = (): Vec2 => ({ x: f[i++], y: f[i++] });
const frame = [pt(), pt(), pt(), pt()];
const segs = (): [Vec2, Vec2][] => {
const n = f[i++];
const out: [Vec2, Vec2][] = [];
for (let k = 0; k < n; k++) out.push([pt(), pt()]);
return out;
};
const rings = (): Vec2[][] => {
const n = f[i++];
const out: Vec2[][] = [];
for (let k = 0; k < n; k++) {
const m = f[i++];
out.push(Array.from({ length: m }, pt));
}
}
return { frame, glassLines, mullionLines, sashFrames: [], sashOpeningLines: [], meetingMarks: [], jambMarks: [] };
return out;
};
const glassLines = segs();
const mullionLines = segs();
const sashFrames = rings();
const meetingMarks = rings();
const jambMarks = rings();
return { frame, glassLines, mullionLines, sashFrames, sashOpeningLines: [], meetingMarks, jambMarks };
}
+124 -499
View File
@@ -1,9 +1,12 @@
// Öffnungs-Domäne des Grundriss-Generators: Tür-/Fenstersymbole je Detailgrad
// (Blatt/Schwenkbogen/Anschlag bzw. Rahmen/Sprossen/Glas), das optionale
// Rahmenband (Zarge/Blockrahmen) samt Schichteinzug aus der Typ-Bibliothek,
// sowie das Legacy-Türsymbol (`Door`, vor der Öffnungs-Typ-Bibliothek).
// Rahmenband (Zarge/Blockrahmen) samt Schichteinzug aus der Typ-Bibliothek.
//
// Die Geometrie entsteht im Rust-Kern (`src-tauri/core/src/plan_openings.rs`, [K3a]); hier bleibt
// die Auflösung aus dem Modell (Typ-Bibliothek, Linien-Overrides) und die Übersetzung in
// `Primitive`-Objekte mit Farbe, Strichstärke und `openingId`. Fällt mit [K3d] weg.
import type { Opening, Project, Vec2, Wall } from "../../model/types";
import type { Opening, Project, Wall } from "../../model/types";
import {
getDoorType,
getWindowType,
@@ -11,16 +14,8 @@ import {
sashesOfWindowType,
wallTypeThickness,
} from "../../model/types";
import {
doorLeaves,
doorSymbol,
openingGapQuad,
openingJambs,
wallAxisFrame,
windowSymbol,
} from "../../geometry/opening";
import { wallReferenceOffset } from "../../model/wall";
import { add, along, dot, scale, sub } from "../../model/geometry";
import { core } from "../../engine/coreWasm";
import {
NO_HATCH,
OVERHEAD_DASH,
@@ -30,6 +25,17 @@ import {
type Primitive,
} from "./shared";
/** Linienklassen in der Reihenfolge der Kern-Kodierung (`plan_openings.rs`). */
const LINE_CLS = [
"door-leaf", "door-frame", "door-lintel", "opening-frame", "window-glass", "window-mullion",
"window-sash", "window-stulp", "window-sill", "window-frame", "window-shading",
] as const;
/** Strichmuster (Kern-Kodierung): 1 Sturz, 2 Überkopf, 3 gepunktet. */
const DASHES: (number[] | undefined)[] = [undefined, [0.18, 0.09], OVERHEAD_DASH, [0.04, 0.08]];
const DETAIL_CODE: Record<DetailLevel, number> = { grob: 0, mittel: 1, fein: 2 };
const LINTEL_CODE = { keine: 0, aussen: 1, innen: 2, beide: 3 } as const;
const SILL_CODE = { aussen: 1, innen: 2, beide: 3 } as const;
/**
* Aufgelöste Rahmen-Parameter (Typ-Bibliothek) einer Tür-/Fenster-Öffnung —
* nur vorhanden, wenn die Öffnung einen Bauteil-Typ referenziert (`typeId`).
@@ -74,133 +80,8 @@ function resolveOpeningFrameSpec(project: Project, o: Opening): OpeningFrameSpec
}
/**
* Rahmenband + Oberlicht-Andeutung einer Tür-/Fenstertyp-Öffnung im
* Grundriss-Schnitt. Nur aufgerufen, wenn `resolveOpeningFrameSpec` einen Typ
* liefert — sonst bleibt die Darstellung exakt wie zuvor (kein neues Primitiv).
*
* • Zarge — schmales Umlauf-Rahmenband, ringsum um `frameWidth`
* von der vollen Öffnung (Pfosten × Wanddicke) nach innen eingezogen.
* • Blockrahmen (Tür) — kräftiges Rechteckprofil, sitzt PROUD an der
* gewählten Fläche (kein Einzug an den Pfosten, nur eine Tiefenscheibe von
* `frameWidth` ab der Nah-Fläche), kräftigere Linie.
* • Schichteinzug — verschiebt die Nah-Fläche des Rahmens um
* `insetFromFace` von der gewählten Wandfläche nach innen; die Gegenfläche
* bleibt unverändert (der Rahmen reicht weiterhin bis dorthin).
* • Oberlicht — Überkopf-Andeutung (gestrichelte Linie quer über die
* Öffnung), nur wenn `transomHeight > 0`.
*/
function addOpeningFrameBand(
out: Primitive[],
project: Project,
wall: Wall,
o: Opening,
spec: OpeningFrameSpec,
greyed: boolean,
): void {
const jambs = openingJambs(wall, o);
if (!jambs) return;
const { n } = wallAxisFrame(wall);
const total = wallTypeThickness(getWallType(project, wall));
const refOff = wallReferenceOffset(wall, total);
// "aussen" = die Fläche der ERSTEN Wandtyp-Schicht (kleinster Achs-Offset,
// s. addWallPoche/`off` startet bei `refOff-total/2`) — mit `n = leftNormal(u)`
// ist das die NEGATIVE Seite. Bug bis 2026-07-12: hier stand `+total/2` für
// "aussen" (positive Seite, tatsächlich "innen") — Türrahmenbänder mit
// insetFace:"aussen" landeten dadurch an der falschen Wandfläche.
const outerFace = refOff - total / 2; // "aussen"-Fläche (−n, erste Schicht)
const innerFace = refOff + total / 2; // "innen"-Fläche (+n, letzte Schicht)
// Schichteinzug: die GEWÄHLTE Fläche rückt um `insetFromFace` nach innen; die
// gegenüberliegende Fläche bleibt unverändert (der Rahmen reicht weiterhin
// bis dorthin) — vgl. DoorType.insetFromFace/WindowType.insetFromFace.
const clampedInset = Math.max(0, Math.min(spec.insetFromFace, total));
const nearIsAussen = spec.insetFace !== "innen";
// "Nach innen" heisst: von der gewählten Fläche RICHTUNG WANDMITTE (refOff) —
// von aussen (negative Seite) aus AUFWÄRTS (+clampedInset), von innen
// (positive Seite) aus ABWÄRTS (−clampedInset).
const faceNear = nearIsAussen ? outerFace + clampedInset : innerFace - clampedInset;
const faceFar = nearIsAussen ? innerFace : outerFace;
const lo = Math.min(faceNear, faceFar);
const hi = Math.max(faceNear, faceFar);
const { jambStart, jambEnd } = jambs;
const color = o.color ?? POCHE_STROKE;
// Rahmen-Rechteck NUR bei Türen zeichnen. Beim Fenster stellt bereits
// `windowSymbol` den Rahmen dar (voller Öffnungsumriss + Glaslinien); ein
// zusätzliches Band ergäbe ein doppeltes, verschachteltes Rechteck — genau
// das wirkte im 2D „nicht korrekt". Die Tür hat dort nur Blatt+Bogen, daher
// ist ihr Rahmenband die einzige Rahmenkontur und bleibt.
if (o.kind === "door") {
const frameWidth = Math.max(0, spec.frameWidth);
const isBlock = spec.frameKind === "blockrahmen";
let bandLo: number;
let bandHi: number;
let jStart: Vec2;
let jEnd: Vec2;
let weightMm: number;
if (isBlock) {
// Blockrahmen: volle Öffnungsbreite (kein Pfosten-Einzug), nur eine
// Tiefenscheibe von frameWidth ab der Nah-Fläche — sitzt proud VOR/auf der
// Laibung, statt schmal darin zu verschwinden (Zargen-Optik). "aussen"
// liegt bei `lo` (s. Kommentar zu outerFace/innerFace oben), die Scheibe
// beginnt dort und wächst RICHTUNG WANDMITTE (Richtung `hi`).
const depth = Math.min(frameWidth, hi - lo);
bandLo = nearIsAussen ? lo : hi - depth;
bandHi = nearIsAussen ? lo + depth : hi;
jStart = jambStart;
jEnd = jambEnd;
weightMm = SYMBOL_HAIRLINE_MM * 2.2;
} else {
// Zarge: ringsum um frameWidth von der vollen Öffnung eingezogenes,
// schmales Rahmenband (Laibungs-Anschlaglinie).
const jambSpan = Math.hypot(jambEnd.x - jambStart.x, jambEnd.y - jambStart.y);
const jambInset = Math.min(frameWidth, jambSpan / 2);
jStart = along(jambStart, jambEnd, jambInset);
jEnd = along(jambEnd, jambStart, jambInset);
const depthInset = Math.min(frameWidth, (hi - lo) / 2);
bandLo = lo + depthInset;
bandHi = hi - depthInset;
weightMm = SYMBOL_HAIRLINE_MM;
}
// Geschlossenes Rechteck aus 4 Kanten (Primitive "line", nicht "polygon" —
// so bleibt das Band per `cls` selektierbar/testbar wie die übrigen Symbole).
const p1 = add(jStart, scale(n, bandLo));
const p2 = add(jEnd, scale(n, bandLo));
const p3 = add(jEnd, scale(n, bandHi));
const p4 = add(jStart, scale(n, bandHi));
const edges: [Vec2, Vec2][] = [
[p1, p2],
[p2, p3],
[p3, p4],
[p4, p1],
];
for (const [a, b] of edges) {
out.push({
kind: "line",
a,
b,
cls: "opening-frame",
weightMm,
color,
greyed,
openingId: o.id,
});
}
}
// Die frühere Oberlicht-Andeutung (gestrichelte Linie quer über die ganze
// Öffnung bei transomHeight>0) ist entfernt (Nutzer-Report: erscheint immer
// auf der Wandachse, unabhängig davon, ob die Schnittebene den Kämpfer
// überhaupt trifft — im horizontalen Grundriss-Schnitt architektonisch nicht
// aussagekräftig, ein Kämpfer ist ein Höhen-, kein Grundriss-Merkmal).
}
/**
* Öffnungs-Symbol (Fenster/Tür) je Detailgrad. Anders als das Legacy-`addDoorSymbol`
* arbeitet diese Funktion über die reinen Geometrie-Helfer (opening.ts) und taggt
* ihre Primitive mit `openingId`, sodass die Öffnung im Plan selektierbar ist.
* Öffnungs-Symbol (Fenster/Tür) je Detailgrad. Arbeitet über den Kern (`plan_openings.rs`) und
* taggt ihre Primitive mit `openingId`, sodass die Öffnung im Plan selektierbar ist.
*
* Tür:
* • grob — gerade Türblatt-Linie (die Lücke kommt aus der ausgesparten Poché).
@@ -208,8 +89,8 @@ function addOpeningFrameBand(
* • fein — + Anschlag-Striche an beiden Pfosten.
* Fenster:
* • grob — eine einzelne Glaslinie über die Lücke.
* • mittel — Rahmen-Rechteck (Umriss) + eine Glaslinie.
* • fein — Rahmen + zwei Glaslinien (Doppelverglasung angedeutet).
* • mittel — Rahmen-Rechteck (Umriss) + Pfosten/Stulp.
* • fein — + Flügelrahmen, Fensterbank, Anschlagkerben.
*/
export function addOpeningSymbol(
out: Primitive[],
@@ -220,374 +101,118 @@ export function addOpeningSymbol(
detail: DetailLevel,
lwMm: number,
): void {
if (o.kind === "door") {
const sym = doorSymbol(wall, o);
if (!sym) return;
// Unsichtbares Pick-Polygon über der Öffnungslücke (Laibung × Wanddicke) —
// damit die Tür wie ein Fenster per Punkt-in-Polygon über die ganze
// Öffnungsfläche selektierbar ist (Türsymbol besteht sonst nur aus dünnem
// Blatt + Bogen, die man exakt treffen müsste). fill/stroke "none" ⇒ zeichnet
// nichts; `pickOpening` (PlanView) testet nur die `pts`.
const gap = openingGapQuad(project, wall, o);
if (gap) {
const total = wallTypeThickness(getWallType(project, wall));
const refOff = wallReferenceOffset(wall, total);
const door = o.kind === "door";
const wt = door ? undefined : getWindowType(project, o);
const frameSpec = door ? resolveOpeningFrameSpec(project, o) : undefined;
const sashes = wt ? sashesOfWindowType(wt) : [];
const strokeColor = o.color ?? POCHE_STROKE;
// Linien-Kategorien einzeln übersteuerbar: Rahmen-Schnitt, Rahmen-Aufsicht, Fenster
// (Flügelrahmen/Sprossen), Sims. `undefined` ⇒ Strichfarbe/Haarlinie.
const frameColor = o.frameLine?.color ?? strokeColor;
const frameWeight = o.frameLine?.weight ?? lwMm;
const frameViewWeight = o.frameViewLine?.weight ?? frameWeight;
const colors = [
"",
strokeColor,
frameColor,
o.frameViewLine?.color ?? frameColor,
o.sashLine?.color ?? strokeColor,
o.sillLineStyle?.color ?? strokeColor,
];
const b: number[] = [
wall.start.x, wall.start.y, wall.end.x, wall.end.y, total, refOff,
o.position, o.width, door ? 1 : 0, DETAIL_CODE[detail],
// Tür
(o.swing ?? "left") !== "left" ? 1 : 0,
(o.openingDir ?? "in") !== "in" ? 1 : 0,
(o.hinge ?? "start") !== "start" ? 1 : 0,
o.swingAngle ?? Number.NaN,
(o.doorType ?? "normal") === "wandoeffnung" ? 1 : 0,
door ? Math.max(1, Math.round(getDoorType(project, o)?.leafCount ?? 1)) : 1,
LINTEL_CODE[o.lintelLines ?? "beide"],
// Rahmenband
frameSpec ? 1 : 0,
frameSpec?.frameWidth ?? 0,
frameSpec?.frameKind === "blockrahmen" ? 1 : 0,
frameSpec?.insetFromFace ?? 0,
frameSpec?.insetFace === "innen" ? 1 : 0,
// Fenster
wt ? 1 : 0,
wt ? wt.frameWidth ?? 0.06 : 0,
wt?.frameDepth ?? Number.NaN,
wt?.insetFromFace ?? Number.NaN,
wt?.insetFace === "innen" ? 1 : 0,
o.wingCount ?? Number.NaN,
detail === "fein" ? 2 : 1,
wt?.sillLine ? SILL_CODE[wt.sillLine.faces] : 0,
wt?.sillLine?.view === "unter" ? 1 : 0,
wt?.shading?.create ? 1 : 0,
wt?.shading?.box.width ?? 0,
wt?.shading?.box.height ?? 0,
// Strichstärken
SYMBOL_HAIRLINE_MM,
o.frameLine?.weight ?? SYMBOL_HAIRLINE_MM,
frameViewWeight,
o.sashLine?.weight ?? SYMBOL_HAIRLINE_MM,
o.sillLineStyle?.weight ?? SYMBOL_HAIRLINE_MM,
sashes.length,
];
for (const s of sashes) {
b.push(s.kind === "pfosten" ? 1 : 0, s.autoWidth === false ? 0 : 1, s.width ?? Number.NaN, s.postWidth ?? Number.NaN,
s.opening && s.opening !== "fest" ? 1 : 0);
}
const f = core().plan_opening_flat(Float64Array.from(b));
if (f.length === 0) return;
const openingId = o.id;
const n = f[0];
let i = 1;
for (let k = 0; k < n; k++) {
if (f[i] === 1) {
const count = f[i + 4];
const pts = new Array<{ x: number; y: number }>(count);
for (let j = 0; j < count; j++) pts[j] = { x: f[i + 5 + 2 * j], y: f[i + 6 + 2 * j] };
const frame = f[i + 1] === 1;
out.push({
kind: "polygon",
pts: gap,
pts,
fill: "none",
stroke: "none",
strokeWidthMm: 0,
stroke: frame ? colors[f[i + 3]] : "none",
strokeWidthMm: f[i + 2],
hatch: NO_HATCH,
greyed,
openingId: o.id,
openingId,
});
}
// Tür-Typ „wandoeffnung": reiner Wanddurchbruch — KEIN Türblatt, KEIN
// Schwenkbogen. Nur die Öffnung/Laibung bleibt (die Wandlücke kommt aus der
// ausgesparten Poché; Sturz-/Anschlaglinien werden weiter unten gezeichnet).
// Entspricht `oeff_tuer_typ == "wandoeffnung"` im Rhino-Plugin.
const isWandoeffnung = (o.doorType ?? "normal") === "wandoeffnung";
if (!isWandoeffnung) {
// Türblätter (1 oder 2 Flügel, je DoorType.leafCount). Zweiflüglig ⇒ zwei
// halbbreite Blätter an gegenüberliegenden Pfosten (symmetrische Doppeltür).
const leafCount = Math.max(1, Math.round(getDoorType(project, o)?.leafCount ?? 1));
for (const leaf of doorLeaves(wall, o, leafCount)) {
out.push({
kind: "line",
a: leaf.hinge,
b: leaf.openEnd,
cls: "door-leaf",
weightMm: SYMBOL_HAIRLINE_MM,
greyed,
openingId: o.id,
});
// mittel + fein: Schwenkbogen von geschlossen → offen je Blatt.
if (detail !== "grob") {
out.push({
kind: "arc",
center: leaf.hinge,
from: leaf.closedEnd,
to: leaf.openEnd,
r: leaf.radius,
cls: "door-swing",
weightMm: SYMBOL_HAIRLINE_MM,
greyed,
openingId: o.id,
});
}
}
}
// fein: Anschlag-Striche an beiden Pfosten (quer zur Wand).
if (detail === "fein") {
const reveal = 0.06;
for (const jamb of [sym.jambStart, sym.jambEnd]) {
out.push({
kind: "line",
a: add(jamb, scale(sym.normal, reveal)),
b: add(jamb, scale(sym.normal, -reveal)),
cls: "door-frame",
weightMm: SYMBOL_HAIRLINE_MM,
greyed,
openingId: o.id,
});
}
}
// Rahmenband (Zarge/Blockrahmen) + Oberlicht-Andeutung — nur wenn die
// Öffnung einen Türtyp referenziert (siehe `resolveOpeningFrameSpec`).
const doorFrameSpec = resolveOpeningFrameSpec(project, o);
if (doorFrameSpec) addOpeningFrameBand(out, project, wall, o, doorFrameSpec, greyed);
// Sturzlinien (SIA, gestrichelt) — Überkopf-Projektion des Sturzes quer über
// die Öffnung an der Wand-Innen-/Aussenkante. Entspricht `_make_tuer_sturz_curves`
// im Rhino-Plugin. Default „beide" wenn nicht explizit gesetzt.
const lintelMode = o.lintelLines ?? "beide";
if (lintelMode !== "keine") {
const jambs = openingJambs(wall, o);
if (jambs) {
const { n } = wallAxisFrame(wall);
const total = wallTypeThickness(getWallType(project, wall));
const refOff = wallReferenceOffset(wall, total);
const halfD = total / 2;
// "aussen" = negative Seite (erste Wandtyp-Schicht), s. Kommentar in
// addOpeningFrameBand — Bug bis 2026-07-12: stand hier vertauscht.
const outerOff = refOff - halfD;
const innerOff = refOff + halfD;
// Strichmuster: gestrichelt (Überkopf-Projektion, SIA-Konvention).
const dash: number[] = [0.18, 0.09];
const strokeColor = o.color ?? POCHE_STROKE;
/** Linie quer über die Öffnung am gegebenen Perp-Offset. */
const lintelLine = (perpOff: number) => ({
a: add(jambs.jambStart, scale(n, perpOff)),
b: add(jambs.jambEnd, scale(n, perpOff)),
});
if (lintelMode === "aussen" || lintelMode === "beide") {
const seg = lintelLine(outerOff);
out.push({
kind: "line" as const,
a: seg.a,
b: seg.b,
cls: "door-lintel",
weightMm: SYMBOL_HAIRLINE_MM,
dash,
color: strokeColor,
greyed,
openingId: o.id,
});
}
if (lintelMode === "innen" || lintelMode === "beide") {
const seg = lintelLine(innerOff);
out.push({
kind: "line" as const,
a: seg.a,
b: seg.b,
cls: "door-lintel",
weightMm: SYMBOL_HAIRLINE_MM,
dash,
color: strokeColor,
greyed,
openingId: o.id,
});
}
}
}
return;
}
// Fenster: Rahmen (mittel/fein) + Glaslinie(n) je Detailgrad + Fenstertyp.
const wt = getWindowType(project, o);
// Flügeltabelle NUR übergeben, wenn ein Fenstertyp auflösbar ist — fehlt er
// (kein `typeId`/unbekannt), bleibt `windowSymbol` beim reinen
// `o.wingCount`-Alt-Verhalten (siehe dortiger Kommentar, Regressionssicherheit).
const spec = wt
? {
sashes: sashesOfWindowType(wt),
frameWidth: wt.frameWidth ?? 0.06,
frameDepth: wt.frameDepth,
insetFromFace: wt.insetFromFace,
insetFace: wt.insetFace,
}
: undefined;
// Glaslinienzahl NUR für den Alt-Pfad (kein `spec`) relevant — der typisierte
// Pfad entscheidet die Anzahl selbst nach SIA-Detailgrad (s. windowSymbol).
const glassCount = detail === "fein" ? 2 : 1;
const sym = windowSymbol(project, wall, o, glassCount, spec, detail);
if (!sym) return;
// Unsichtbares Pick-Polygon über der Öffnungslücke — macht das Fenster über
// die ganze Fläche selektierbar, auch bei „grob" (nur eine Glaslinie, sonst
// schwer zu treffen). Siehe Tür-Zweig oben.
const wgap = openingGapQuad(project, wall, o);
if (wgap) {
out.push({
kind: "polygon",
pts: wgap,
fill: "none",
stroke: "none",
strokeWidthMm: 0,
hatch: NO_HATCH,
greyed,
openingId: o.id,
});
}
// ── SIA-Fensterdarstellung, nach Detailgrad gestaffelt ────────────────────
// grob (1:100): weisse Öffnung + EINE dünne Glaslinie, sonst nichts.
// mittel (1:50): Blendrahmen-Rechteck + Pfosten-Trennlinien + Stulp-Mittel-
// quadrat je Flügel-Junction + Glaslinie(n).
// fein (1:20): zusätzlich Flügelrahmen, Stulp als ZWEI Rechtecke, Fensterbank
// (aussen) und Anschlag-/Laibungskerben — deutlich reicher als mittel.
const strokeColor = o.color ?? POCHE_STROKE;
const { n: wn } = wallAxisFrame(wall);
if (detail === "grob") {
// SIA 1:100 — nur eine dünne Glaslinie mittig über die weisse Öffnung.
// Zählt zur "Fenster"-Kategorie (sashLine) — dieselbe Glaslinie, die bei
// mittel/fein früher sichtbar war (jetzt dort entfernt, s. Fenster-Session).
const g = sym.glassLines[Math.floor(sym.glassLines.length / 2)] ?? sym.glassLines[0];
if (g) {
i += 5 + 2 * count;
} else if (f[i] === 2) {
const slot = f[i + 3];
const dash = DASHES[f[i + 4]];
out.push({
kind: "line",
a: g[0],
b: g[1],
cls: "window-glass",
weightMm: o.sashLine?.weight ?? SYMBOL_HAIRLINE_MM,
color: o.sashLine?.color ?? strokeColor,
a: { x: f[i + 5], y: f[i + 6] },
b: { x: f[i + 7], y: f[i + 8] },
cls: LINE_CLS[f[i + 1]],
weightMm: f[i + 2],
...(dash ? { dash } : {}),
...(slot ? { color: colors[slot] } : {}),
greyed,
openingId: o.id,
openingId,
});
}
} else {
// Linien-Kategorien einzeln übersteuerbar (Nutzer-Wunsch): Rahmen-Schnitt
// (Laibungs-/Stulp-Blöcke, geschnittenes Profil), Rahmen-Aufsicht (die
// durchlaufende Kontur DAZWISCHEN, projiziert statt geschnitten), Fenster
// (Flügelrahmen/Sprossen), Sims (Auf-/Untersicht-Andeutung, s. u.).
// `undefined` ⇒ bisheriges Verhalten (strokeColor/SYMBOL_HAIRLINE_MM);
// `frameViewLine` fällt zusätzlich auf `frameLine` zurück (eine Farbe für
// Schnitt+Aufsicht, bis der Nutzer sie explizit trennt).
const frameColor = o.frameLine?.color ?? strokeColor;
const frameWeight = o.frameLine?.weight ?? lwMm;
const frameHairline = o.frameLine?.weight ?? SYMBOL_HAIRLINE_MM;
const frameViewColor = o.frameViewLine?.color ?? frameColor;
const frameViewWeight = o.frameViewLine?.weight ?? frameWeight;
const sashColor = o.sashLine?.color ?? strokeColor;
const sashWeight = o.sashLine?.weight ?? SYMBOL_HAIRLINE_MM;
// Blendrahmen-Rechteck in Aufsicht (mittel + fein) — die durchlaufende
// Kontur zwischen den geschnittenen Laibungs-/Stulp-Blöcken.
out.push({
kind: "polygon",
pts: sym.frame,
fill: "none",
stroke: frameViewColor,
strokeWidthMm: frameViewWeight,
hatch: NO_HATCH,
greyed,
openingId: o.id,
});
// Pfosten-/Flügel-Trennlinien (Alt-Pfad ohne Typ — zählt als "Fenster").
for (const [a, b] of sym.mullionLines) {
out.push({ kind: "line", a, b, cls: "window-mullion", weightMm: sashWeight, color: sashColor, greyed, openingId: o.id });
}
// fein: Flügelrahmen (Flügelkontur) je öffenbarem Flügel — Schachtelung
// Blendrahmen → Flügelrahmen → Glas (Feindetail, hebt fein klar von mittel ab).
if (detail === "fein") {
for (const pts of sym.sashFrames) {
for (let i = 0; i < pts.length; i++) {
out.push({ kind: "line", a: pts[i], b: pts[(i + 1) % pts.length], cls: "window-sash", weightMm: sashWeight, color: sashColor, greyed, openingId: o.id });
}
}
}
// Laibungs-Blöcke an den Öffnungsenden (Blendrahmen-Querschnitt) — Teil des
// Blendrahmens, zählt zu "Rahmen".
for (const mark of sym.jambMarks) {
for (let i = 0; i < mark.length; i++) {
out.push({ kind: "line", a: mark[i], b: mark[(i + 1) % mark.length], cls: "window-stulp", weightMm: frameHairline, color: frameColor, greyed, openingId: o.id });
}
}
// Stulp-Mittelquadrat je Flügel-Junction (SIA-Signatur): mittel = EIN Quadrat,
// fein = ZWEI anliegende Rechtecke (die beiden Stulp-Stäbe der Flügel) —
// bereits tiefenkorrekt (inset-/insetFace-bewusst) in windowSymbol berechnet.
// Sitzt zwischen den Flügeln, zählt zu "Fenster" (separat vom Blendrahmen
// steuerbar — Nutzer-Feedback).
for (const mark of sym.meetingMarks) {
for (let i = 0; i < mark.length; i++) {
out.push({ kind: "line", a: mark[i], b: mark[(i + 1) % mark.length], cls: "window-stulp", weightMm: sashWeight, color: sashColor, greyed, openingId: o.id });
}
}
// Glaslinien (Anzahl je Detailgrad/Verglasung, s. glassCount).
for (const [a, b] of sym.glassLines) {
out.push({ kind: "line", a, b, cls: "window-glass", weightMm: SYMBOL_HAIRLINE_MM, greyed, openingId: o.id });
}
// Oberlicht-Andeutung (transom, gestrichelt) — mittel/fein.
const windowFrameSpec = resolveOpeningFrameSpec(project, o);
if (windowFrameSpec) addOpeningFrameBand(out, project, wall, o, windowFrameSpec, greyed);
// fein: Fensterbank (aussen) + Anschlag-/Laibungskerben.
if (detail === "fein") {
const jb = openingJambs(wall, o);
if (jb) {
const { jambStart, jambEnd } = jb;
// Tatsächliche Rahmen-Aussenkante (NICHT pauschal die volle Wandfläche —
// ein eingezogener Rahmen, s. {@link WindowType.insetFromFace}, hat seine
// Aussenkante weiter innen). "Aussen" ist der ALGEBRAISCH KLEINERE der
// beiden Tiefen-Werte in sym.frame (s. windowSymbol: frontRel für
// insetFace:"aussen" ist negativ) — welcher der beiden Eckpunkt-Paare das
// ist, hängt von insetFace ab, daher robust über Math.min bestimmt statt
// fest über sym.frame[0].
const outerN = Math.min(
dot(sub(sym.frame[0], jambStart), wn),
dot(sub(sym.frame[2], jambStart), wn),
);
// Fensterbank: schmales Rechteck vor der Aussenfläche, seitlich ~3 cm
// überstehend, ~4 cm auskragend (SIA-Sims-Andeutung im Grundriss).
// Auskragung geht IMMER weiter nach aussen (algebraisch kleiner, s. o.).
const ov = 0.03;
const proj = 0.04;
const s0 = along(jambStart, jambEnd, -ov);
const s1 = along(jambEnd, jambStart, -ov);
const b0 = add(s0, scale(wn, outerN));
const b1 = add(s1, scale(wn, outerN));
const b2 = add(s1, scale(wn, outerN - proj));
const b3 = add(s0, scale(wn, outerN - proj));
for (const [a, b] of [[b0, b1], [b1, b2], [b2, b3], [b3, b0]] as [Vec2, Vec2][]) {
out.push({ kind: "line", a, b, cls: "window-sill", weightMm: SYMBOL_HAIRLINE_MM, color: strokeColor, greyed, openingId: o.id });
}
// Anschlag-Kerben an beiden Pfosten (kurz quer zur Wand).
const reveal = 0.06;
for (const jamb of [jambStart, jambEnd]) {
out.push({ kind: "line", a: add(jamb, scale(wn, reveal)), b: add(jamb, scale(wn, -reveal)), cls: "window-frame", weightMm: SYMBOL_HAIRLINE_MM, color: strokeColor, greyed, openingId: o.id });
}
}
}
}
// Auf-/Untersicht-Andeutung ({@link WindowType.sillLine}): eine Referenzlinie
// an der Rahmen-Aussen-/Innenkante (NICHT der Wandachse — ersetzt die frühere,
// falsch positionierte Brüstungslinie), nur wenn der Typ es explizit wählt.
// "auf" (Aufsicht von oben, dünn gepunktet) vs. "unter" (Untersicht von unten,
// gestrichelt wie die übrigen Überkopf-Projektionen).
if (detail !== "grob" && wt?.sillLine) {
const { faces, view } = wt.sillLine;
const dash = view === "unter" ? OVERHEAD_DASH : [0.04, 0.08];
const sillColor = o.sillLineStyle?.color ?? strokeColor;
const sillWeight = o.sillLineStyle?.weight ?? SYMBOL_HAIRLINE_MM;
// Welches der beiden sym.frame-Eckpunkt-Paare physisch "aussen" ist, hängt
// von insetFace ab (s. windowSymbol) — robust über den Tiefen-Vergleich
// entlang wn bestimmt statt fest über den Index.
const pair01IsOuter = dot(sym.frame[0], wn) <= dot(sym.frame[3], wn);
const outerPair: [Vec2, Vec2] = pair01IsOuter ? [sym.frame[0], sym.frame[1]] : [sym.frame[3], sym.frame[2]];
const innerPair: [Vec2, Vec2] = pair01IsOuter ? [sym.frame[3], sym.frame[2]] : [sym.frame[0], sym.frame[1]];
if (faces === "aussen" || faces === "beide") {
out.push({ kind: "line", a: outerPair[0], b: outerPair[1], cls: "window-sill", weightMm: sillWeight, dash, color: sillColor, greyed, openingId: o.id });
}
if (faces === "innen" || faces === "beide") {
out.push({ kind: "line", a: innerPair[0], b: innerPair[1], cls: "window-sill", weightMm: sillWeight, dash, color: sillColor, greyed, openingId: o.id });
}
}
// Rollladen-/Sonnenschutzkasten (P0-Minimalfassung, reine 2D-Kontur): ein
// gestricheltes Rechteck ÜBER der Öffnung, ausserhalb der Wand-Aussenfläche —
// Breite = `shading.box.width` (0/fehlt ⇒ Öffnungsbreite), die zweite
// Rechteckseite = `shading.box.height`. Die 3D-Tiefe (`box.depth`) bleibt für
// eine spätere 3D-Box reserviert (Fokus hier bewusst 2D, s. Aufgabenstellung).
// Gestrichelt wie die übrigen Überkopf-Projektionen (Sturz/Oberlicht) — der
// Kasten liegt oberhalb der Schnittebene und wird nur angedeutet.
if (wt?.shading?.create) {
const jambs = openingJambs(wall, o);
if (jambs) {
const { u, n: nrm } = wallAxisFrame(wall);
const total = wallTypeThickness(getWallType(project, wall));
const refOff = wallReferenceOffset(wall, total);
// "aussen" = negative Seite (erste Wandtyp-Schicht), s. Kommentar in
// addOpeningFrameBand — Bug bis 2026-07-12: stand hier vertauscht (der
// Rollladenkasten landete an der Innenfläche statt aussen am Sturz).
const outerFace = refOff - total / 2;
const axisWidth = Math.hypot(
jambs.jambEnd.x - jambs.jambStart.x,
jambs.jambEnd.y - jambs.jambStart.y,
);
const boxWidth = wt.shading.box.width > 0 ? wt.shading.box.width : axisWidth;
const boxHeight = Math.max(0, wt.shading.box.height);
const center = add(jambs.jambStart, scale(u, axisWidth / 2));
const half = boxWidth / 2;
const c1 = add(center, scale(u, -half));
const c2 = add(center, scale(u, half));
const p1 = add(c1, scale(nrm, outerFace));
const p2 = add(c2, scale(nrm, outerFace));
const p3 = add(c2, scale(nrm, outerFace + boxHeight));
const p4 = add(c1, scale(nrm, outerFace + boxHeight));
const edges: [Vec2, Vec2][] = [
[p1, p2],
[p2, p3],
[p3, p4],
[p4, p1],
];
for (const [a, b] of edges) {
out.push({
kind: "line",
a,
b,
cls: "window-shading",
weightMm: SYMBOL_HAIRLINE_MM,
dash: OVERHEAD_DASH,
color: o.color ?? POCHE_STROKE,
greyed,
openingId: o.id,
});
}
i += 9;
} else {
out.push({
kind: "arc",
center: { x: f[i + 2], y: f[i + 3] },
from: { x: f[i + 4], y: f[i + 5] },
to: { x: f[i + 6], y: f[i + 7] },
r: f[i + 8],
cls: "door-swing",
weightMm: f[i + 1],
greyed,
openingId,
});
i += 9;
}
}
}