diff --git a/src-tauri/core/src/opening_geom.rs b/src-tauri/core/src/opening_geom.rs index 6e467783..da9a113f 100644 --- a/src-tauri/core/src/opening_geom.rs +++ b/src-tauri/core/src/opening_geom.rs @@ -272,6 +272,10 @@ fn sash_segments(sashes: &[Sash], total_width: f64) -> Vec<(usize, f64, f64)> { segs } +/// [258] Obergrenze für Flügelzahlen aus dem Modell (`wingCount`): ein Wert wie 1e300 darf keine Schleife über +/// Milliarden Flügel auslösen (Speicher-Abbruch im WASM). +pub const MAX_WINGS: f64 = 64.0; + /// Fenster-Symbol; `spec` nur mit auflösbarem Typ (sonst Alt-Pfad mit `wing_count`, NaN = 1). pub fn window_symbol( w: &WallRef, diff --git a/src-tauri/core/src/plan/elevation/openings.rs b/src-tauri/core/src/plan/elevation/openings.rs index b8609b49..d42d651e 100644 --- a/src-tauri/core/src/plan/elevation/openings.rs +++ b/src-tauri/core/src/plan/elevation/openings.rs @@ -195,7 +195,7 @@ pub(super) fn collect_openings(p: &Project, frame: &[f64; 9], win: &crate::plan: } None => { let wc = if t.wing_count == 0.0 || t.wing_count.is_nan() { 1.0 } else { t.wing_count }; - let n = max(1.0, round(wc)) as usize; + let n = max(1.0, round(wc).min(crate::opening_geom::MAX_WINGS)) as usize; for i in 0..n { // [105] Pfostenbreite gesetzt: Pfosten zwischen den Flügeln. if i > 0 && mullion.is_finite() && mullion > 1e-4 { diff --git a/src-tauri/core/src/plan/section/openings.rs b/src-tauri/core/src/plan/section/openings.rs index d59bf4f3..44735e8b 100644 --- a/src-tauri/core/src/plan/section/openings.rs +++ b/src-tauri/core/src/plan/section/openings.rs @@ -98,7 +98,7 @@ pub(crate) fn sashes_of_window_type(wt: &WindowType) -> Vec Vec { return s.clone(); } let wc = if wt.wing_count == 0.0 || wt.wing_count.is_nan() { 1.0 } else { wt.wing_count }; - let n = crate::jsnum::max(1.0, round(wc)) as usize; + let n = crate::jsnum::max(1.0, round(wc).min(crate::opening_geom::MAX_WINGS)) as usize; let opening = if wt.kind == OpeningKind::Fest { OpeningKind::Fest } else { wt.kind }; (0..n).map(|i| SashDef { kind: SashDefKind::Fluegel, auto_width: Some(true), opening: Some(opening), hinge_side: Some(if i % 2 == 0 { SashDefHingeSide::Left } else { SashDefHingeSide::Right }), ..Default::default() }).collect() }