diff --git a/TODO.md b/TODO.md index fb208894..30756f69 100644 --- a/TODO.md +++ b/TODO.md @@ -10,7 +10,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* stehen im Archiv („Bewusst nicht übernommen“). - **Grösse** (eine Person mit Agenten): S ≤ 1 Tag · M ≤ 1 Woche · L ≤ 1 Monat · XL > 1 Monat. Steht keine Grösse im Archiv, ist sie hier geschätzt. -- **IDs sind stabil.** Neue ID = nächste freie Zahl nach der höchsten im Archiv und hier (aktuell 258); +- **IDs sind stabil.** Neue ID = nächste freie Zahl nach der höchsten im Archiv und hier (aktuell 259); nie eine ID wiederverwenden oder umnummerieren. Präfix-IDs (`[K]`, `[G]`, `[T]`, `[B]`, `[C]`) bleiben. - **Pro Punkt:** was fehlt · wo im Code · Grösse. Höchstens ein bis drei Sätze je Punkt; Messwerte und Befunde gehören in den Commit. @@ -340,7 +340,12 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC. (`sunStudy.show`), unverändert; Wettbewerb-Schnitt ohne Gelände: Nachbar bleibt (hellgrau) weit neben dem Haus; `levelMarkers.ts`-Doppelspur (braucht eine Kern-Abfrage mit Plan-Puffer als Eingabe); Stempel „Schlafen" DG 80 %. **14.11. (spät):** Klassen-Füllung im Klassen-Dialog editierbar (Farbwähler + „keine", Inline-Editor und macOS-Ebenenfenster; Ziehen = ein Undo-Schritt; Test `categoryFill.test.ts`); nur vitest/tsc, - nicht in der Tauri-App angesehen. · M + nicht in der Tauri-App angesehen. **14.11. (Befund 6, Vorschlag umschaltbar, Entscheid Maintainer offen):** Öffnungen über/unter der + Schnitthöhe in geschlossener Wand (DG-Rundfenster 1.8 m, EG-Bad-Fenster, EG-Rundfenster) bleiben strichpunktiert, der Teil auf der + schwarzen 1:100-Sammelfläche wird weiss (SIA-Praxis), ausserhalb unverändert, Bemassung bleibt. Über die Plan-Primitive (`plan/contrast.rs`: + Linien/Bögen an dunklen Flächen zerlegt, helle Stücke über allen Füllungen) — Bildschirm, Plan-SVG, Druck-SVG/PDF, DXF (Echtfarbe weiss) + bekommen dieselben Stücke; 1:50 (helle Schichten) unverändert. Abschaltbar: Modelldarstellung `walls.contrastOnSolid` (Basis an). + Tests `contrast::tests`, `ueber_schnitt_hell_auf_schwarzer_wand`; Goldens nachgeführt. Geprüft nur Linux/CLI-SVG `--hatch` in Chromium. · M - Fachplaner-Austausch: DXF/DWG je Geschoss/Schnitt/Ansicht ([200]), IFC mit Räumen/Psets ([201]); Rundreise in Archicad/Revit einmal real prüfen ([C9]). - ◐ **[259]** IFC-Export für Fachplaner (Vorprojekt, 14.11.). Alle drei Beispielprojekte mit ifcopenshell 0.9 geprüft: `validate-ifc.py` diff --git a/src-tauri/core/src/model/generated.rs b/src-tauri/core/src/model/generated.rs index 2b10d7ab..860efbc9 100644 --- a/src-tauri/core/src/model/generated.rs +++ b/src-tauri/core/src/model/generated.rs @@ -2429,6 +2429,11 @@ pub struct ModelViewWalls { #[serde(rename = "cutHatch", default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub cut_hatch: Option, + /// [256] Öffnungen über/unter der Schnittebene in geschlossener Wand: der Teil auf schwarzer Schnittfläche hell + /// (weiss) statt dunkel, damit das strichpunktierte Symbol lesbar bleibt (Basis: ja). + #[serde(rename = "contrastOnSolid", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub contrast_on_solid: Option, #[serde(flatten)] #[ts(skip)] pub extra: Extra, diff --git a/src-tauri/core/src/plan/contrast.rs b/src-tauri/core/src/plan/contrast.rs new file mode 100644 index 00000000..12f2ac0b --- /dev/null +++ b/src-tauri/core/src/plan/contrast.rs @@ -0,0 +1,277 @@ +//! [256] Kontrast auf dunkler Füllung: Linien, die auf einer schwarzen Schnittfläche liegen (ab 1:100 die +//! Sammelfläche der Wände, `style::solid_cut`), verschwinden in ihr. Die Plan-Erzeugung zeichnet den Teil +//! einer solchen Linie, der IN der dunklen Fläche liegt, in der Kontrastfarbe (weiss); ausserhalb bleibt +//! sie unverändert. Genutzt für Öffnungs-Symbole über/unter der Schnittebene in einer geschlossenen Wand +//! (Rundfenster, hohes Bad-Fenster: SIA-Praxis, die Öffnung über Schnitt bleibt lesbar). Wirkt auf die +//! Plan-Primitive selbst — Bildschirm, Plan-SVG, Druck-SVG/PDF und DXF bekommen dieselben Stücke. + +use super::prim::Primitive; +use crate::model::Vec2; + +/// Kontrastfarbe auf dunkler Füllung. +pub const CONTRAST_INK: &str = "#ffffff"; + +/// Linien auf dem Rand der Fläche (Wandflucht) bleiben dunkel: Abstand zum Rand mindestens so viel (m). +const EDGE_EPS: f64 = 2e-4; + +/// Relative Helligkeit (0 schwarz … 1 weiss), unter der eine Füllung als dunkel gilt. +const DARK_LUMA: f64 = 0.3; + +/// Dunkle, deckende Füllung (z. B. `HATCH_INK`)? Transparente oder halbtransparente Füllungen nicht. +pub fn is_dark_fill(fill: &str, opacity: Option) -> bool { + if opacity.is_some_and(|o| !(o >= 0.5)) { + return false; + } + let Some([r, g, b, a]) = super::buf::parse_color(fill) else { return false }; + a >= 0.5 && 0.2126 * r + 0.7152 * g + 0.0722 * b < DARK_LUMA +} + +/// Dunkle Flächen mit Hüllrechteck. +pub struct DarkRings { + rings: Vec<(Vec, [f64; 4])>, +} + +impl DarkRings { + /// Flächen aus `prims`, deren Füllung dunkel ist und die `pick` annimmt. + pub fn collect(prims: &[Primitive], pick: impl Fn(&Primitive) -> bool) -> Self { + let mut rings = Vec::new(); + for q in prims { + if let Primitive::Polygon { pts, fill, opacity, .. } = q { + if pts.len() >= 3 && is_dark_fill(fill, *opacity) && pick(q) && pts.iter().all(|p| p.x.is_finite() && p.y.is_finite()) { + let mut bb = [f64::INFINITY, f64::INFINITY, f64::NEG_INFINITY, f64::NEG_INFINITY]; + for p in pts { + bb = [bb[0].min(p.x), bb[1].min(p.y), bb[2].max(p.x), bb[3].max(p.y)]; + } + rings.push((pts.clone(), bb)); + } + } + } + Self { rings } + } + + pub fn is_empty(&self) -> bool { + self.rings.is_empty() + } + + /// Punkt echt in einer dunklen Fläche (nicht auf ihrem Rand). + fn inside(&self, p: Vec2) -> bool { + self.rings.iter().any(|(r, bb)| { + p.x > bb[0] - EDGE_EPS && p.x < bb[2] + EDGE_EPS && p.y > bb[1] - EDGE_EPS && p.y < bb[3] + EDGE_EPS && in_ring(r, p) && edge_dist(r, p) > EDGE_EPS + }) + } + + /// Parameter (0..1), an denen die Strecke a→b einen Flächenrand kreuzt. + fn crossings(&self, a: Vec2, b: Vec2, ts: &mut Vec) { + let (lo_x, hi_x, lo_y, hi_y) = (a.x.min(b.x), a.x.max(b.x), a.y.min(b.y), a.y.max(b.y)); + for (r, bb) in &self.rings { + if hi_x < bb[0] - EDGE_EPS || lo_x > bb[2] + EDGE_EPS || hi_y < bb[1] - EDGE_EPS || lo_y > bb[3] + EDGE_EPS { + continue; + } + let n = r.len(); + for i in 0..n { + let (c, d) = (r[i], r[(i + 1) % n]); + let (dx, dy, ex, ey) = (b.x - a.x, b.y - a.y, d.x - c.x, d.y - c.y); + let den = dx * ey - dy * ex; + if den.abs() < 1e-15 { + continue; + } + let t = ((c.x - a.x) * ey - (c.y - a.y) * ex) / den; + let u = ((c.x - a.x) * dy - (c.y - a.y) * dx) / den; + if t > 0.0 && t < 1.0 && (-1e-9..=1.0 + 1e-9).contains(&u) { + ts.push(t); + } + } + } + } +} + +fn in_ring(r: &[Vec2], p: Vec2) -> bool { + let mut inside = false; + let mut j = r.len() - 1; + for i in 0..r.len() { + let (a, b) = (r[i], r[j]); + if (a.y > p.y) != (b.y > p.y) && p.x < (b.x - a.x) * (p.y - a.y) / (b.y - a.y) + a.x { + inside = !inside; + } + j = i; + } + inside +} + +fn edge_dist(r: &[Vec2], p: Vec2) -> f64 { + let n = r.len(); + let mut best = f64::INFINITY; + for i in 0..n { + let (a, b) = (r[i], r[(i + 1) % n]); + let (dx, dy) = (b.x - a.x, b.y - a.y); + let l2 = dx * dx + dy * dy; + let t = if l2 > 0.0 { (((p.x - a.x) * dx + (p.y - a.y) * dy) / l2).clamp(0.0, 1.0) } else { 0.0 }; + let (qx, qy) = (a.x + dx * t - p.x, a.y + dy * t - p.y); + best = best.min((qx * qx + qy * qy).sqrt()); + } + best +} + +/// Abschnitte `(t0, t1, drinnen)` einer Strecke, benachbarte gleiche zusammengefasst. +fn split_runs(ts: &mut Vec, at: impl Fn(f64) -> bool) -> Vec<(f64, f64, bool)> { + ts.push(0.0); + ts.push(1.0); + ts.sort_by(|a, b| a.total_cmp(b)); + ts.dedup_by(|a, b| (*a - *b).abs() < 1e-9); + let mut runs: Vec<(f64, f64, bool)> = Vec::new(); + for w in ts.windows(2) { + let inside = at((w[0] + w[1]) / 2.0); + match runs.last_mut() { + Some(l) if l.2 == inside => l.1 = w[1], + _ => runs.push((w[0], w[1], inside)), + } + } + runs +} + +fn lerp(a: Vec2, b: Vec2, t: f64) -> Vec2 { + Vec2 { x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t } +} + +/// Linien und Bögen in `prims[from..to]`: der Teil in einer dunklen Fläche wird als eigenes Stück in +/// [`CONTRAST_INK`] ans ENDE von `prims` gehängt (über allen Füllungen), der Rest bleibt an seinem Platz. +/// Flächen und andere Primitive bleiben unverändert. Rückgabe: Zahl der hellen Stücke. +pub fn light_on_dark(prims: &mut Vec, from: usize, to: usize, dark: &DarkRings) -> usize { + if dark.is_empty() || from >= to || to > prims.len() { + return 0; + } + let mut keep: Vec = Vec::with_capacity(to - from); + let mut light: Vec = Vec::new(); + for q in prims.drain(from..to) { + match &q { + Primitive::Line { a, b, .. } if a.x.is_finite() && a.y.is_finite() && b.x.is_finite() && b.y.is_finite() => { + let (a, b) = (*a, *b); + let mut ts = Vec::new(); + dark.crossings(a, b, &mut ts); + let runs = split_runs(&mut ts, |t| dark.inside(lerp(a, b, t))); + if runs.len() == 1 && !runs[0].2 { + keep.push(q); + continue; + } + for (t0, t1, inside) in runs { + let mut s = q.clone(); + if let Primitive::Line { a: sa, b: sb, color, .. } = &mut s { + *sa = lerp(a, b, t0); + *sb = lerp(a, b, t1); + if inside { + *color = Some(CONTRAST_INK.into()); + } + } + if inside { light.push(s) } else { keep.push(s) } + } + } + Primitive::Arc { center, from: af, to: at, r, .. } if r.is_finite() && *r > 0.0 => { + // Bogen gegen den Uhrzeigersinn von `from` nach `to` (wie die SVG-Ausgabe), in Stücken abgetastet. + let (c, r) = (*center, *r); + let a0 = crate::jsnum::atan2(af.y - c.y, af.x - c.x); + let mut sweep = crate::jsnum::atan2(at.y - c.y, at.x - c.x) - a0; + while sweep < 0.0 && sweep.is_finite() { + sweep += std::f64::consts::PI * 2.0; + } + if !sweep.is_finite() || sweep <= 0.0 { + keep.push(q); + continue; + } + let pt = |t: f64| { + let a = a0 + sweep * t; + Vec2 { x: c.x + r * crate::jsnum::cos(a), y: c.y + r * crate::jsnum::sin(a) } + }; + const N: usize = 32; + let mut ts: Vec = (1..N).map(|k| k as f64 / N as f64).collect(); + let runs = split_runs(&mut ts, |t| dark.inside(pt(t))); + if runs.len() == 1 && !runs[0].2 { + keep.push(q); + continue; + } + for (t0, t1, inside) in runs { + let mut s = q.clone(); + if let Primitive::Arc { from: sf, to: st, color, .. } = &mut s { + *sf = if t0 <= 0.0 { *af } else { pt(t0) }; + *st = if t1 >= 1.0 { *at } else { pt(t1) }; + if inside { + *color = Some(CONTRAST_INK.into()); + } + } + if inside { light.push(s) } else { keep.push(s) } + } + } + _ => keep.push(q), + } + } + let n = light.len(); + prims.splice(from..from, keep); + prims.extend(light); + n +} + +#[cfg(test)] +mod tests { + use super::*; + + fn v(x: f64, y: f64) -> Vec2 { + Vec2 { x, y } + } + fn poly(pts: Vec, fill: &str) -> Primitive { + Primitive::Polygon { pts, fill: fill.into(), stroke: "none".into(), stroke_width_mm: 0.0, hatch: Box::new(super::super::style::no_hatch()), greyed: None, opacity: None, no_stroke_edges: None, wall_id: Some("w".into()), drawing_id: None, ceiling_id: None, opening_id: None, stair_id: None, room_id: None, extruded_solid_id: None, context_object_id: None, column_id: None, roof_id: None, section_line_id: None } + } + fn line(a: Vec2, b: Vec2) -> Primitive { + Primitive::Line { a, b, cls: "view-range".into(), weight_mm: 0.18, dash: Some(Some(vec![1.2, 0.25, 0.15, 0.25])), zigzag: None, motif: None, color: Some("#1a1a1a".into()), drawing_id: None, opening_id: None, stair_id: None, greyed: None, opacity: None } + } + + #[test] + fn dunkle_fuellung() { + assert!(is_dark_fill("#0f0f0f", None)); + assert!(!is_dark_fill("#d9d9d9", None)); + assert!(!is_dark_fill("#0f0f0f", Some(0.2))); + assert!(!is_dark_fill("#4a4a4a00", None)); + assert!(!is_dark_fill("none", None)); + } + + #[test] + fn nur_der_teil_in_der_schwarzen_flaeche_wird_hell() { + let wall = poly(vec![v(0.0, 0.0), v(4.0, 0.0), v(4.0, 0.3), v(0.0, 0.3)], "#0f0f0f"); + // Quer durch die Wand und darüber hinaus; dazu eine Linie auf der Wandflucht und eine ausserhalb. + let mut prims = vec![wall, line(v(1.0, -0.5), v(1.0, 0.8)), line(v(0.5, 0.0), v(3.5, 0.0)), line(v(0.0, 2.0), v(4.0, 2.0))]; + let dark = DarkRings::collect(&prims, |_| true); + let n = light_on_dark(&mut prims, 1, 4, &dark); + assert_eq!(n, 1); + let col = |q: &Primitive| match q { + Primitive::Line { color, .. } => color.as_deref().map(str::to_string), + _ => None, + }; + // Das helle Stück liegt zuletzt (über allen Füllungen) und genau in der Wand. + let Primitive::Line { a, b, .. } = prims.last().unwrap() else { panic!() }; + assert_eq!(col(prims.last().unwrap()).as_deref(), Some(CONTRAST_INK)); + assert!((a.y - 0.0).abs() < 1e-9 && (b.y - 0.3).abs() < 1e-9, "{a:?} {b:?}"); + // Aussen bleibt dunkel: zwei Reststücke der Querlinie, Flucht- und Aussenlinie unverändert. + let dark_lines = prims.iter().filter(|q| col(q).as_deref() == Some("#1a1a1a")).count(); + assert_eq!(dark_lines, 4); + assert!(matches!(&prims[0], Primitive::Polygon { .. })); + } + + #[test] + fn helle_flaeche_aendert_nichts() { + let wall = poly(vec![v(0.0, 0.0), v(4.0, 0.0), v(4.0, 0.3), v(0.0, 0.3)], "#ffffff"); + let mut prims = vec![wall, line(v(1.0, -0.5), v(1.0, 0.8))]; + let before = prims.clone(); + let dark = DarkRings::collect(&prims, |_| true); + assert_eq!(light_on_dark(&mut prims, 1, 2, &dark), 0); + assert_eq!(prims, before); + } + + #[test] + fn bogen_in_der_wand_wird_hell() { + let wall = poly(vec![v(-1.0, -0.15), v(1.0, -0.15), v(1.0, 0.15), v(-1.0, 0.15)], "#0f0f0f"); + let arc = Primitive::Arc { center: v(0.0, 0.0), from: v(0.1, 0.0), to: v(-0.1, 0.0), r: 0.1, cls: "view-range".into(), weight_mm: 0.18, dash: None, color: None, opening_id: None, stair_id: None, greyed: None, opacity: None }; + let mut prims = vec![wall, arc]; + let dark = DarkRings::collect(&prims, |_| true); + assert_eq!(light_on_dark(&mut prims, 1, 2, &dark), 1); + assert_eq!(prims.len(), 2); + assert!(matches!(&prims[1], Primitive::Arc { color: Some(c), .. } if c == CONTRAST_INK)); + } +} diff --git a/src-tauri/core/src/plan/mod.rs b/src-tauri/core/src/plan/mod.rs index c50e1f61..ba8fc609 100644 --- a/src-tauri/core/src/plan/mod.rs +++ b/src-tauri/core/src/plan/mod.rs @@ -42,6 +42,7 @@ pub mod trees; pub mod cameras; pub mod mesh_plan; pub mod situation; +pub mod contrast; pub mod arc_fit; pub(crate) mod seams; pub(crate) mod wall_columns; diff --git a/src-tauri/core/src/plan/model_view.rs b/src-tauri/core/src/plan/model_view.rs index 722863be..2ab4eaca 100644 --- a/src-tauri/core/src/plan/model_view.rs +++ b/src-tauri/core/src/plan/model_view.rs @@ -249,6 +249,8 @@ pub struct WallOpts { pub reveals: bool, /// Schnittflächen schraffiert (die Ebene geht vor, s. [`Options::cut_hatch`]). pub cut_hatch_mv: Option, + /// [256] Öffnungs-Symbole über/unter Schnitt auf schwarzer Wand hell (Basis: ja). + pub contrast_on_solid: bool, } /// Decken und Böden. @@ -525,6 +527,7 @@ pub fn resolve(mv: Option<&ModelViewOption>, detail: Detail, scale: f64) -> Opti thin_mm: wl.and_then(|w| w.thin_layer_mm).filter(|t| t.is_finite() && *t >= 0.0).unwrap_or(THIN_LAYER_PAPER_MM), reveals: wl.and_then(|w| w.reveals).unwrap_or(true), cut_hatch_mv: wl.and_then(|w| w.cut_hatch), + contrast_on_solid: wl.and_then(|w| w.contrast_on_solid).unwrap_or(true), }, slab: SlabOpts { layers: layer_mode(sl.and_then(|s| s.layers)), diff --git a/src-tauri/core/src/plan/model_view_tests3.rs b/src-tauri/core/src/plan/model_view_tests3.rs index 36397ac5..d4817f54 100644 --- a/src-tauri/core/src/plan/model_view_tests3.rs +++ b/src-tauri/core/src/plan/model_view_tests3.rs @@ -282,3 +282,45 @@ fn mitgelieferte_stufen_aus_den_standards() { p.drawing_levels.iter_mut().find(|l| l.id == "eg").unwrap().model_view_option_id = Some("std-mv-wettbewerb-200".into()); assert_ne!(heute, buf(&p, 100.0)); } + +/// [256] Oberlicht über der Schnittebene in geschlossener Wand: ab 1:100 (schwarze Sammelfläche) wird der Teil +/// des strichpunktierten Symbols in der Wand weiss, damit es lesbar bleibt; 1:50 (Schichten, hell) und mit +/// `walls.contrastOnSolid: false` bleibt alles dunkel. Die Wandfläche selbst bleibt gleich. +#[test] +fn ueber_schnitt_hell_auf_schwarzer_wand() { + let mut p = sample(); + let o1 = p.openings.as_mut().unwrap().iter_mut().find(|o| o.id == "O1").unwrap(); + (o1.sill_height, o1.height) = (1.5, 0.6); + p.drawing_levels.iter_mut().find(|l| l.id == "eg").unwrap().view_top = Some(2.5); + let codes: Vec = p.walls.iter().map(|w| w.category_code.clone()).chain(p.openings.iter().flatten().map(|o| o.category_code.clone())).collect(); + let run = |p: &Project, scale: f64| -> DomainPrims { + let t = serde_json::json!({"floor": "eg", "show": codes, "scale": scale}).to_string(); + plan_domains(p, &PlanArgs::parse_in(p, 1.0, &t).unwrap()).unwrap() + }; + let light = |d: &DomainPrims| -> Vec<(Vec2, Vec2)> { + d.walls.iter().filter_map(|q| match q { + Primitive::Line { a, b, color: Some(c), cls, .. } if c == crate::plan::contrast::CONTRAST_INK && cls == "view-range" => Some((*a, *b)), + _ => None, + }).collect() + }; + let dark_polys = |d: &DomainPrims| d.walls.iter().filter(|q| matches!(q, Primitive::Polygon { fill, .. } if fill == crate::plan::style::HATCH_INK)).count(); + let d100 = run(&p, 100.0); + let l = light(&d100); + assert!(l.len() >= 2, "helle Stücke des Oberlichts: {l:?}"); + // Alle hellen Stücke liegen in der Wand W1 (Hüllrechteck, Wanddicke grosszügig). + let w1 = p.walls.iter().find(|w| w.id == "W1").unwrap(); + let (x0, x1) = (w1.start.x.min(w1.end.x) - 0.5, w1.start.x.max(w1.end.x) + 0.5); + let (y0, y1) = (w1.start.y.min(w1.end.y) - 0.5, w1.start.y.max(w1.end.y) + 0.5); + assert!(l.iter().all(|(a, b)| [a, b].iter().all(|q| q.x >= x0 && q.x <= x1 && q.y >= y0 && q.y <= y1)), "{l:?}"); + // Die hellen Stücke liegen nach allen schwarzen Flächen (darüber gezeichnet). + let last_dark = d100.walls.iter().rposition(|q| matches!(q, Primitive::Polygon { fill, .. } if fill == crate::plan::style::HATCH_INK)).unwrap(); + let first_light = d100.walls.iter().position(|q| matches!(q, Primitive::Line { color: Some(c), .. } if c == crate::plan::contrast::CONTRAST_INK)).unwrap(); + assert!(first_light > last_dark); + // Abschaltbar; die Wand bleibt dieselbe. + let off = with_mv(p.clone(), serde_json::json!({"baseDetail": "mittel", "walls": {"contrastOnSolid": false}})); + let d_off = run(&off, 100.0); + assert!(light(&d_off).is_empty()); + assert_eq!(dark_polys(&d_off), dark_polys(&d100)); + // 1:50: Schichten mit heller Füllung, nichts wird weiss. + assert!(light(&run(&p, 50.0)).is_empty()); +} diff --git a/src-tauri/core/src/plan/walls.rs b/src-tauri/core/src/plan/walls.rs index 2965be1b..d0d2f6c3 100644 --- a/src-tauri/core/src/plan/walls.rs +++ b/src-tauri/core/src/plan/walls.rs @@ -1074,6 +1074,8 @@ pub fn plan_walls(c: &Ctx, reference_lines: bool, out: &mut Vec, boun } // [198] Ab hier die Wand-Primitive: danach Linien zwischen gleichen Flächen verschiedener Wände streichen. let fuse_from = out.len(); + // [256] Öffnungs-Symbole über/unter Schnitt in geschlossener Wand (Bereiche in `out`), für den Kontrast danach. + let mut closed_syms: Vec<(usize, usize)> = Vec::new(); // Bei doppelten Wand-ids gewinnt in TS (Map) die letzte Verschneidung. let mut cut_by_id: HashMap<&str, &WallCuts> = HashMap::new(); for (e, k) in walls.iter().zip(&cuts) { @@ -1214,12 +1216,21 @@ pub fn plan_walls(c: &Ctx, reference_lines: bool, out: &mut Vec, boun } if let Some(d) = dash { super::view_range::restyle(out, sym_start, d); + closed_syms.push((sym_start, out.len())); } } if let Some(d) = range.restyle_dash(zone) { super::view_range::restyle(out, out_start, d); } } + // [256] Auf schwarzer Sammelfläche (ab 1:100) verschwände das Symbol: der Teil in der Fläche wird hell + // (Modelldarstellung `walls.contrastOnSolid`, Basis an). Hinten anfangen, die Bereiche verschieben sich. + if c.mv().wall.contrast_on_solid && !closed_syms.is_empty() { + let dark = super::contrast::DarkRings::collect(&out[fuse_from..], |q| matches!(q, Primitive::Polygon { wall_id: Some(_), opening_id: None, .. })); + for &(a, b) in closed_syms.iter().rev() { + super::contrast::light_on_dark(out, a, b, &dark); + } + } let tail = out.split_off(fuse_from); let curved: std::collections::HashSet<&str> = p.walls.iter().filter(|w| w.floor_id == c.a.floor && crate::wall_arc::WallArc::of_wall(w).is_some()).map(|w| w.id.as_str()).collect(); out.extend(super::seams::fuse_wall_plan(tail, &|id: &str| curved.contains(id))); diff --git a/src/i18n/de.ts b/src/i18n/de.ts index bb35bc99..78f8a7a6 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -1350,6 +1350,7 @@ export const de = { "resources.modelViews.opt.walls.thinLayerMm": "Dünne Schichten zusammenfassen unter", "resources.modelViews.opt.walls.reveals": "Schichteinzug", "resources.modelViews.opt.walls.cutHatch": "Schnittflächen ab 1:100 schraffiert", + "resources.modelViews.opt.walls.contrastOnSolid": "Öffnungen über/unter Schnitt hell auf schwarzer Wand", "resources.modelViews.opt.slabs.floorFinish": "Bodenbelag", "resources.modelViews.opt.sectionMarks.style": "Markentyp der Schnitte", "resources.modelViews.val.arrow": "Pfeil", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index bc18abd4..e5b2920c 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -1344,6 +1344,7 @@ export const en: Record = { "resources.modelViews.opt.walls.thinLayerMm": "Merge thin layers below", "resources.modelViews.opt.walls.reveals": "Layer reveal", "resources.modelViews.opt.walls.cutHatch": "Hatch cut faces from 1:100", + "resources.modelViews.opt.walls.contrastOnSolid": "Openings above/below cut drawn light on solid walls", "resources.modelViews.opt.slabs.floorFinish": "Floor finish", "resources.modelViews.opt.sectionMarks.style": "Section marker type", "resources.modelViews.val.arrow": "Arrow", diff --git a/src/model/types.generated.ts b/src/model/types.generated.ts index 6409cb08..23292335 100644 --- a/src/model/types.generated.ts +++ b/src/model/types.generated.ts @@ -2462,6 +2462,11 @@ export type ModelViewWalls = { reveals?: boolean; /** Schnittflächen ab 1:100 schraffiert statt schwarz (die Ebene geht vor; Basis: schwarz). */ cutHatch?: boolean; + /** + * [256] Öffnungen über/unter der Schnittebene in geschlossener Wand: der Teil auf schwarzer Schnittfläche hell + * (weiss) statt dunkel, damit das strichpunktierte Symbol lesbar bleibt (Basis: ja). + */ + contrastOnSolid?: boolean; }; /** [173] Fenster in der Modelldarstellung (fehlt ⇒ wie Basis). */ diff --git a/src/state/modelViews.ts b/src/state/modelViews.ts index 3ce6b969..a9821850 100644 --- a/src/state/modelViews.ts +++ b/src/state/modelViews.ts @@ -196,6 +196,7 @@ export const MODEL_VIEW_FIELDS: readonly ModelViewField[] = [ { section: "walls", key: "thinLayerMm", values: [0.25, 0.5, 0.75, 1] }, { section: "walls", key: "reveals", values: "bool" }, { section: "walls", key: "cutHatch", values: "bool" }, + { section: "walls", key: "contrastOnSolid", values: "bool" }, { section: "slabs", key: "floorFinish", values: ["off", "wet", "all"] }, { section: "slabs", key: "layers", values: ["all", "simplified", "core"] }, { section: "slabs", key: "buildUp", values: ["show", "merged"] },