diff --git a/TODO.md b/TODO.md index 350679c3..08d524f5 100644 --- a/TODO.md +++ b/TODO.md @@ -458,9 +458,17 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* - ◐ **[T6]** Glattes Gelände aus Höhenlinien (`terrain.rs`). Natural-Neighbour/Clough-Tocher statt Hermite-Teilung; Erdreich-Band nicht „bis zur Planunterkante“; Glättung ohne Kantenerhalt; Baugrube ist eigene Kategorie und bleibt beim Ausblenden von „02“ stehen; gespeicherte Ansichten übernehmen beim Öffnen ihre `layerVisibility`. · L -- ◐ **[68]** Baugrube/Geländebearbeitung (Kontext-Objekt `excavation`). Verbau als echte Wand im Schnitt mit Dicke/ - Schraffur; Überlappung der Sohlenfläche nur gerastert; Arbeitsraum an konkaven Ecken ohne Prüfung; IVHB-Terrain - nach kantonalem Recht. · M +- ◐ **[68]** Baugrube/Geländebearbeitung (Kontext-Objekt `excavation`). (11.11.) Verbau ist jetzt eine echte Wand: + Modellfelder `shoringKind` (Spundwand/Rühlwand/Bohrpfahlwand) und `shoringThickness` (Vorgabe 0.2/0.3/0.6 m), im + Schnitt geschnittene Fläche mit Schraffur der Art (Stahl/Holz/Beton), unten Sohle − 1 m Einbindung, Erdreich-Band + spart sie aus; im Grundriss Wandband an der Kante (Klasse der Baugrube, Pick = Baugrube); Sohlenfläche bei + überlappenden Gruben exakt (i_overlay); Arbeitsraum-Prüfung `working_space_check` (enge Nischen, gekappte Gehrung): + rotes Kreuz im Plan, Warnung im Panel. (11.11., 2) Einbindetiefe als Feld `shoringEmbed` (Vorgabe 1 m, Panel); + Verbau auch im 3D (Körper je Kante in Farbe der Verbauart, Klasse der Baugrube, Pick = Baugrube; `excavation:: + shoring_solids`) und in der Ansicht (Netz-Flächen mit exakter Sichtbarkeit `hlr_fill`, Klasse/Pick wie 3D); + Erdreich-Band im Schnitt lässt die Wand nur aus, wenn deren Klasse sichtbar ist (kein Loch bei ausgeblendeter + Klasse). Geprüft: cargo test (Kern), vitest, Goldens; nicht in der App/Metal angesehen. Offen: Verbau je Kante + nur eine Art, Ansicht ohne Verbau-Schraffur (nur Farbfläche); IVHB-Terrain nach kantonalem Recht. · M - ◐ **[143]** Baugrube erstellen. (9.11.) DXF/DWG-Höhenlinien werden beim Import erkannt (Layer-Name Höhenlinie/HL/ Contour/Kote …, Erhebung Gruppe 38, 3D-Polylinien mit konstantem Z, sonst Höhentexte nahe der Linie) und als `contourSet` „02 Gelände“ statt als 2D-Zeichnung übernommen: Kern `import_terrain.rs`, Option „Höhenlinien als Gelände diff --git a/src-tauri/core/src/excavation.rs b/src-tauri/core/src/excavation.rs index 00c48aef..7237cd80 100644 --- a/src-tauri/core/src/excavation.rs +++ b/src-tauri/core/src/excavation.rs @@ -36,6 +36,12 @@ pub struct ExSpec { pub cut_tan: Vec, /// Kante mit senkrechtem Verbau (Spundwand): keine Böschung, keine Schraffur. pub shored: Vec, + /// [68] Art des Verbaus (`sheetPile`, `soldierPile`, `borePile`) und Wanddicke in m. + pub shore_kind: &'static str, + pub shore_t: f64, + /// [68] Umriss vor dem Arbeitsraum (Gebäude-Grundfläche, gegen den Uhrzeigersinn) und Arbeitsraum in m. + pub base: Vec, + pub ws: f64, pub fill_tan: f64, pub berm_w: f64, pub berm_h: f64, @@ -117,9 +123,12 @@ impl ExSpec { } // Arbeitsraum: Sohle um `workingSpace` nach aussen (Gehrung, höchstens 4× so weit an spitzen Ecken). let ws = e.working_space.filter(|v| v.is_finite() && *v > 0.0).unwrap_or(0.0); + let base = ring.clone(); if ws > 0.0 { ring = offset_ring(&ring, ws); } + let (shore_kind, default_t) = shoring_kind(e.shoring_kind.as_deref()); + let shore_t = e.shoring_thickness.filter(|v| v.is_finite() && *v > 0.0).unwrap_or(default_t); let bw = e.berm_width.filter(|v| v.is_finite() && *v > 0.0).unwrap_or(0.0); let bh = e.berm_height.filter(|v| v.is_finite() && *v > 0.0).unwrap_or(0.0); Some(ExSpec { @@ -127,6 +136,10 @@ impl ExSpec { bottom: e.bottom + dz, cut_tan, shored, + shore_kind, + shore_t, + base, + ws, fill_tan: tan_deg(e.fill_slope.filter(|s| s.is_finite() && *s > 0.0).unwrap_or(DEFAULT_FILL_SLOPE)), berm_w: if bh > 0.0 { bw } else { 0.0 }, berm_h: if bw > 0.0 { bh } else { 0.0 }, @@ -216,6 +229,190 @@ impl ExSpec { } } +// ── Verbau ([68]) ──────────────────────────────────────────────────────────── + +/// Einbindetiefe der Verbauwand unter die Sohle (m). +pub const SHORING_EMBED: f64 = 1.0; + +/// Einbindetiefe der Baugrube (Feld `shoringEmbed`, Vorgabe [`SHORING_EMBED`]). +pub fn shoring_embed(e: &Excavation) -> f64 { + e.shoring_embed.filter(|v| v.is_finite() && *v >= 0.0).unwrap_or(SHORING_EMBED) +} + +/// Art des Verbaus und ihre Vorgabe-Dicke (m); Unbekanntes = Spundwand. +pub fn shoring_kind(k: Option<&str>) -> (&'static str, f64) { + match k { + Some("soldierPile") => ("soldierPile", 0.3), + Some("borePile") => ("borePile", 0.6), + _ => ("sheetPile", 0.2), + } +} + +/// Schraffur-Id der Verbauart (SIA: Stahl, Holz, Beton). +pub fn shoring_hatch_id(kind: &str) -> &'static str { + match kind { + "soldierPile" => "std-h-holz", + "borePile" => "std-h-beton", + _ => "std-h-stahl-detail", + } +} + +impl ExSpec { + /// Wandbänder der verbauten Kanten: Vierecke von der Sohlkante um die Wanddicke nach aussen (Gehrung an den + /// Ecken, wie der Arbeitsraum). Index der Kante, Viereck. + pub fn shoring_quads(&self) -> Vec<(usize, Vec)> { + if !self.shored.iter().any(|b| *b) || !(self.shore_t > 0.0) { + return Vec::new(); + } + let n = self.ring.len(); + let off = offset_ring(&self.ring, self.shore_t); + (0..n).filter(|i| self.shored[*i]).map(|i| (i, vec![self.ring[i], self.ring[(i + 1) % n], off[(i + 1) % n], off[i]])).collect() + } +} + +/// [68] Verbauwand einer Baugrube als geschlossene Prismen (Modellbezug, Höhen = Gelände − Höhenbezug) für 3D, Ansicht +/// und Pick: je verbauter Kante ein Körper von Sohle − Einbindetiefe bis zum gewachsenen Gelände. +#[derive(Clone, Debug)] +pub struct ShoringSolid { + pub excavation_id: String, + pub kind: &'static str, + /// x, y, z je Ecke. + pub pos: Vec, + pub idx: Vec, +} + +/// Verbauwände aller Baugruben des Projekts, ein [`ShoringSolid`] je Baugrube mit Verbau. +pub fn shoring_solids(p: &Project) -> Vec { + let mut out: Vec = Vec::new(); + for t in terrains(p) { + if t.positions.len() < 9 { + continue; + } + let st = site_terrain(p, t); + let idx = st.index_orig(); + for (id, spec, _) in &st.items { + if out.iter().any(|s| &s.excavation_id == id) { + continue; + } + let Some(e) = excavations(p).into_iter().find(|e| e.id == *id) else { continue }; + let quads = spec.shoring_quads(); + if quads.is_empty() { + continue; + } + let z_bottom = e.bottom - shoring_embed(e); + let mut s = ShoringSolid { excavation_id: id.clone(), kind: spec.shore_kind, pos: Vec::new(), idx: Vec::new() }; + for (_, mut quad) in quads { + if signed_area(&quad) < 0.0 { + quad.reverse(); + } + let tops: Vec> = quad.iter().map(|q| idx.z_at(q[0], q[1]).map(|z| (z - st.datum).max(e.bottom))).collect(); + if tops.iter().any(Option::is_none) || tops.iter().flatten().all(|z| *z <= e.bottom + 1e-3) { + continue; + } + let b = s.pos.len() as u32 / 3; + for q in &quad { + s.pos.extend([q[0], q[1], z_bottom]); + } + for (q, z) in quad.iter().zip(&tops) { + s.pos.extend([q[0], q[1], z.unwrap_or(e.bottom)]); + } + // Unterseite, Oberseite, vier Seiten (aussen, gegen den Uhrzeigersinn). + s.idx.extend([b, b + 2, b + 1, b, b + 3, b + 2, b + 4, b + 5, b + 6, b + 4, b + 6, b + 7]); + for i in 0..4u32 { + let j = (i + 1) % 4; + s.idx.extend([b + i, b + j, b + 4 + j, b + i, b + 4 + j, b + 4 + i]); + } + } + if !s.idx.is_empty() { + out.push(s); + } + } + } + out +} + +/// Prüfung des Arbeitsraums an den Ecken des Umrisses ([68]). +#[derive(Clone, Debug, PartialEq)] +pub struct WsCheck { + /// Verlangte Breite (m). + pub required: f64, + /// Kleinster Abstand zwischen Gebäude-Umriss und Sohle (m), 0 bei Überschneidung. + pub min_width: f64, + pub ok: bool, + /// Stellen, an denen die Breite fehlt (Ecken der Sohle bzw. des Umrisses, Selbstüberschneidungen). + pub spots: Vec, +} + +fn seg_cross(a: P2, b: P2, c: P2, d: P2) -> Option { + let (r, s) = ([b[0] - a[0], b[1] - a[1]], [d[0] - c[0], d[1] - c[1]]); + let den = r[0] * s[1] - r[1] * s[0]; + if den.abs() < 1e-12 { + return None; + } + let q = [c[0] - a[0], c[1] - a[1]]; + let t = (q[0] * s[1] - q[1] * s[0]) / den; + let u = (q[0] * r[1] - q[1] * r[0]) / den; + (t > 1e-9 && t < 1.0 - 1e-9 && u > 1e-9 && u < 1.0 - 1e-9).then(|| [a[0] + t * r[0], a[1] + t * r[1]]) +} + +fn ring_dist(p: P2, r: &[P2]) -> f64 { + let n = r.len(); + (0..n).map(|i| seg_dist(p, r[i], r[(i + 1) % n])).fold(f64::INFINITY, f64::min) +} + +/// Arbeitsraum an konkaven und spitzen Ecken: Die Sohle ist der um `ws` versetzte Gebäude-Umriss. In engen Nischen +/// (< 2·ws) kreuzen sich die versetzten Kanten, an spitzen Ecken kappt die Gehrung bei 4·ws — dort fehlt Breite. +/// `None` ohne Arbeitsraum. +pub fn working_space_check(spec: &ExSpec) -> Option { + if !(spec.ws > 0.0) { + return None; + } + let (base, sole) = (&spec.base, &spec.ring); + let mut spots: Vec = Vec::new(); + let mut min_w = f64::INFINITY; + // Ecken der Sohle zum Umriss (innen = Verletzung) und Ecken des Umrisses zur Sohle (aussen = Verletzung). + for &v in sole { + let w = if point_in_ring(v, base) { 0.0 } else { ring_dist(v, base) }; + if w < spec.ws - 1e-6 { + spots.push(v); + } + min_w = min_w.min(w); + } + for &v in base { + let w = if point_in_ring(v, sole) { ring_dist(v, sole) } else { 0.0 }; + if w < spec.ws - 1e-6 { + spots.push(v); + } + min_w = min_w.min(w); + } + // Selbstüberschneidung der Sohle (zu enge Nische) und Kreuzung mit dem Umriss. + let (n, m) = (sole.len(), base.len()); + for i in 0..n { + for j in i + 2..n { + if i == 0 && j == n - 1 { + continue; + } + if let Some(x) = seg_cross(sole[i], sole[(i + 1) % n], sole[j], sole[(j + 1) % n]) { + spots.push(x); + } + } + for j in 0..m { + if let Some(x) = seg_cross(sole[i], sole[(i + 1) % n], base[j], base[(j + 1) % m]) { + spots.push(x); + min_w = 0.0; + } + } + } + let mut uniq: Vec = Vec::new(); + for s in spots { + if !uniq.iter().any(|u| (u[0] - s[0]).hypot(u[1] - s[1]) < 1e-3) { + uniq.push(s); + } + } + let min_width = if min_w.is_finite() { min_w } else { spec.ws }; + Some(WsCheck { required: spec.ws, min_width, ok: uniq.is_empty(), spots: uniq }) +} + /// Regelmässiges Raster über einem Rechteck (Knoten). struct Grid { x0: f64, @@ -412,7 +609,7 @@ pub struct Volumes { /// je Probe geht der Höhenunterschied einer Baugrube an sie allein — die Summe ist die Vereinigung. /// Integriert über ein Raster der Weite ≤ `h` (Mittelpunkte, höchstens ~1.5 Mio. Proben). /// `footprint`: Gebäude-Grundfläche (Ringe); Abtrag darin zählt nicht zur Hinterfüllung. -/// Sohlenfläche = Fläche des Umrisses ohne die der vorherigen Baugruben (Überlappung per Raster). +/// Sohlenfläche = Fläche des Umrisses ohne die der vorherigen Baugruben (exakt, Polygon-Booleans). pub fn volumes_union(orig: &Tin, specs: &[&ExSpec], h: f64, footprint: &[Vec]) -> Vec { if specs.is_empty() { return Vec::new(); @@ -431,12 +628,7 @@ pub fn volumes_union(orig: &Tin, specs: &[&ExSpec], h: f64, footprint: &[Vec let (nx, ny) = (((w / h).ceil() as usize).max(1), ((hh / h).ceil() as usize).max(1)); let (hx, hy) = (w / nx as f64, hh / ny as f64); let cell = hx * hy; - let boxes: Vec<[f64; 4]> = specs.iter().map(|e| e.bbox()).collect(); - let overlaps: Vec = (0..specs.len()) - .map(|k| (0..k).any(|j| boxes[j][0] < boxes[k][2] && boxes[k][0] < boxes[j][2] && boxes[j][1] < boxes[k][3] && boxes[k][1] < boxes[j][3])) - .collect(); - let mut out: Vec = specs.iter().map(|e| Volumes { bottom_area: signed_area(&e.ring).abs(), ..Default::default() }).collect(); - let mut shared = vec![0.0; specs.len()]; + let mut out: Vec = specs.iter().map(|_| Volumes::default()).collect(); for j in 0..ny { for i in 0..nx { let p = [reg[0] + (i as f64 + 0.5) * hx, reg[1] + (j as f64 + 0.5) * hy]; @@ -444,9 +636,6 @@ pub fn volumes_union(orig: &Tin, specs: &[&ExSpec], h: f64, footprint: &[Vec let mut cur = t; let outside_fp = !footprint.iter().any(|f| point_in_ring(p, f)); for (k, ex) in specs.iter().enumerate() { - if overlaps[k] && p[0] >= boxes[k][0] && p[0] <= boxes[k][2] && p[1] >= boxes[k][1] && p[1] <= boxes[k][3] && point_in_ring(p, &ex.ring) && (0..k).any(|q| point_in_ring(p, &specs[q].ring)) { - shared[k] += cell; - } let next = ex.apply(cur, p); let dz = cur - next; if dz > 0.0 { @@ -461,8 +650,11 @@ pub fn volumes_union(orig: &Tin, specs: &[&ExSpec], h: f64, footprint: &[Vec } } } - for (v, s) in out.iter_mut().zip(shared) { - v.bottom_area = (v.bottom_area - s).max(0.0); + // Sohlenfläche exakt: Fläche des Umrisses ohne die der vorherigen Baugruben (Polygon-Booleans, [68]). + for (k, v) in out.iter_mut().enumerate() { + let prev: Vec = specs[..k].iter().map(|e| vec![e.ring.clone()]).collect(); + let left = crate::polygon_bool::difference(&[vec![specs[k].ring.clone()]], &prev); + v.bottom_area = left.iter().flat_map(|poly| poly.iter().map(|r| signed_area(r))).sum::().max(0.0); } out } @@ -615,6 +807,12 @@ pub struct ExQty { pub cut: f64, pub fill: f64, pub backfill: f64, + /// [68] Arbeitsraum: verlangte Breite, kleinster Abstand Umriss–Sohle, eingehalten? Ohne Arbeitsraum 0 / 0 / true. + pub working_space: f64, + pub working_space_min: f64, + pub working_space_ok: bool, + /// Stellen mit fehlender Breite (Modell-x/y). + pub working_space_spots: Vec<[f64; 2]>, } pub fn quantities(p: &Project) -> Vec { @@ -631,9 +829,22 @@ pub fn quantities(p: &Project) -> Vec { let (x0, x1) = specs.iter().flat_map(|s| s.ring.iter().map(|q| q[0])).fold((f64::INFINITY, f64::NEG_INFINITY), |a, x| (a.0.min(x), a.1.max(x))); let h = ((x1 - x0).max(1.0) / 400.0).clamp(0.02, 0.5); let vols = volumes_union(&st.orig, &specs, h, &fp); - for ((id, ..), v) in hits.iter().zip(vols) { + for ((id, spec, _), v) in hits.iter().zip(vols) { let Some(e) = excavations(p).into_iter().find(|e| e.id == *id) else { continue }; - done.push(ExQty { id: e.id.clone(), name: e.name.clone(), bottom: e.bottom, bottom_area: v.bottom_area, cut: v.cut, fill: v.fill, backfill: v.backfill }); + let ws = working_space_check(spec); + done.push(ExQty { + id: e.id.clone(), + name: e.name.clone(), + bottom: e.bottom, + bottom_area: v.bottom_area, + cut: v.cut, + fill: v.fill, + backfill: v.backfill, + working_space: ws.as_ref().map_or(0.0, |w| w.required), + working_space_min: ws.as_ref().map_or(0.0, |w| w.min_width), + working_space_ok: ws.as_ref().is_none_or(|w| w.ok), + working_space_spots: ws.map_or_else(Vec::new, |w| w.spots), + }); } } // Reihenfolge wie im Modell. @@ -917,6 +1128,67 @@ mod tests { assert!(sum < single.cut + sep.cut - 1.0 && sum > single.cut, "{sum}"); } + #[test] + fn sohlenflaeche_ueberlappung_exakt() { + // Zwei 10 × 10-Gruben, die zweite um 6 m versetzt: gemeinsam 4 × 10, also bleiben 60 m² (exakt, nicht gerastert). + let t = flat(0.0, 50.0); + let sa = ExSpec::of(&square(5.0, -3.0), 0.0).unwrap(); + let mut c = square(5.0, -3.0); + for q in &mut c.outline { + q.x += 6.0 + 0.0123; + } + let sc = ExSpec::of(&c, 0.0).unwrap(); + let u = volumes_union(&t, &[&sa, &sc], 0.5, &[]); + assert!((u[0].bottom_area - 100.0).abs() < 1e-6, "{}", u[0].bottom_area); + assert!((u[1].bottom_area - (100.0 - 10.0 * (5.0 - (1.0 + 0.0123)))).abs() < 1e-6, "{}", u[1].bottom_area); + // Vollständig überdeckt: 0. + let same = volumes_union(&t, &[&sa, &sa], 0.5, &[]); + assert!(same[1].bottom_area.abs() < 1e-6); + } + + #[test] + fn arbeitsraum_ecken_und_nischen() { + let v = |x: f64, y: f64| Vec2 { x, y }; + let pit = |pts: Vec, ws: f64| Excavation { id: "bg".into(), outline: pts, bottom: -3.0, working_space: Some(ws), ..Default::default() }; + // Rechteck und L-Form (konkave Ecke): Breite eingehalten. + let l = pit(vec![v(0.0, 0.0), v(10.0, 0.0), v(10.0, 4.0), v(4.0, 4.0), v(4.0, 10.0), v(0.0, 10.0)], 1.0); + let c = working_space_check(&ExSpec::of(&l, 0.0).unwrap()).unwrap(); + assert!(c.ok && c.spots.is_empty() && (c.min_width - 1.0).abs() < 1e-6, "{c:?}"); + // Schmale Nische (1 m < 2 · 1 m Arbeitsraum): die versetzten Kanten kreuzen sich, Stelle gemeldet. + let u = pit(vec![v(0.0, 0.0), v(10.0, 0.0), v(10.0, 10.0), v(5.5, 10.0), v(5.5, 3.0), v(4.5, 3.0), v(4.5, 10.0), v(0.0, 10.0)], 1.0); + let c = working_space_check(&ExSpec::of(&u, 0.0).unwrap()).unwrap(); + assert!(!c.ok && !c.spots.is_empty(), "{c:?}"); + // Breite Nische (3 m): in Ordnung. + let w = pit(vec![v(0.0, 0.0), v(10.0, 0.0), v(10.0, 10.0), v(6.5, 10.0), v(6.5, 3.0), v(3.5, 3.0), v(3.5, 10.0), v(0.0, 10.0)], 1.0); + assert!(working_space_check(&ExSpec::of(&w, 0.0).unwrap()).unwrap().ok); + // Sehr spitze Ecke: Gehrung wird gekappt, dort fehlt Breite. + let spike = pit(vec![v(0.0, 0.0), v(20.0, 0.5), v(0.0, 1.0)], 1.0); + assert!(!working_space_check(&ExSpec::of(&spike, 0.0).unwrap()).unwrap().ok); + // Ohne Arbeitsraum keine Prüfung. + assert!(working_space_check(&ExSpec::of(&square(5.0, -3.0), 0.0).unwrap()).is_none()); + } + + #[test] + fn verbau_baender_und_arten() { + let mut e = square(5.0, -3.0); + e.edge_shoring = Some(vec![true, false, false, false]); + let spec = ExSpec::of(&e, 0.0).unwrap(); + assert_eq!((spec.shore_kind, spec.shore_t), ("sheetPile", 0.2)); + let q = spec.shoring_quads(); + assert_eq!(q.len(), 1); + // 10 m × 0.2 m plus die Gehrungsdreiecke an den Enden. + assert!((signed_area(&q[0].1).abs() - 2.04).abs() < 1e-9, "{}", signed_area(&q[0].1)); + // Band liegt ausserhalb der Sohle. + assert!(q[0].1.iter().skip(2).all(|p| !point_in_ring(*p, &spec.ring))); + e.shoring_kind = Some("borePile".into()); + e.shoring_thickness = Some(0.9); + let spec = ExSpec::of(&e, 0.0).unwrap(); + assert_eq!((spec.shore_kind, spec.shore_t), ("borePile", 0.9)); + assert_eq!(shoring_hatch_id(spec.shore_kind), "std-h-beton"); + // Ohne Verbau keine Bänder. + assert!(ExSpec::of(&square(5.0, -3.0), 0.0).unwrap().shoring_quads().is_empty()); + } + #[test] fn luftbildfarben_auf_geaendertem_gelaende() { // Original-Netz mit Farbverlauf in x; nach der Baugrube behalten alle neuen Punkte die Farbe ihrer (x, y). diff --git a/src-tauri/core/src/model/generated.rs b/src-tauri/core/src/model/generated.rs index 77c92838..07b49f8a 100644 --- a/src-tauri/core/src/model/generated.rs +++ b/src-tauri/core/src/model/generated.rs @@ -6370,6 +6370,19 @@ pub struct Excavation { #[serde(rename = "edgeShoring", default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub edge_shoring: Option>, + /// [68] Art des Verbaus auf den verbauten Kanten: `sheetPile` (Spundwand, Vorgabe), `soldierPile` (Rühlwand), + /// `borePile` (Bohrpfahlwand). Bestimmt Vorgabe-Dicke und Schraffur im Schnitt und Grundriss. + #[serde(rename = "shoringKind", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub shoring_kind: Option, + /// [68] Dicke der Verbauwand in m (nach aussen von der Sohlkante); fehlt = Vorgabe der Art. + #[serde(rename = "shoringThickness", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub shoring_thickness: Option, + /// [68] Einbindetiefe der Verbauwand unter die Sohle in m; fehlt = 1 m. + #[serde(rename = "shoringEmbed", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub shoring_embed: Option, #[serde(flatten)] #[ts(skip)] pub extra: Extra, diff --git a/src-tauri/core/src/model3d/context.rs b/src-tauri/core/src/model3d/context.rs index 0b10b7aa..4f6b7ed0 100644 --- a/src-tauri/core/src/model3d/context.rs +++ b/src-tauri/core/src/model3d/context.rs @@ -61,8 +61,32 @@ pub fn emit_context_meshes(p: &Project) -> Vec { owner: Owner::Context(ci), crease_angle: (m.smooth_shading == Some(true)).then(|| m.crease_angle.filter(|a| a.is_finite() && *a > 0.0).unwrap_or(DEFAULT_CREASE_DEG).min(180.0)), }), + // [68] Verbauwand der Baugrube: Körper in der Farbe der Verbauart, Klasse und Pick der Baugrube. + ContextObject::Excavation(e) => { + if let Some(s) = crate::excavation::shoring_solids(p).into_iter().find(|s| s.excavation_id == e.id) { + out.push(RMesh { + positions: s.pos, + indices: s.idx, + kind: "imported", + color: shoring_rgb(s.kind), + vertex_colors: None, + material_index: None, + owner: Owner::Context(ci), + crease_angle: None, + }) + } + } _ => {} } } out } + +/// [68] Bauteilfarbe der Verbauart: Stahl (Spundwand), Holz (Rühlwand), Beton (Bohrpfahlwand). +pub fn shoring_rgb(kind: &str) -> Rgb { + match kind { + "soldierPile" => [0.62, 0.47, 0.30], + "borePile" => [0.72, 0.72, 0.70], + _ => [0.52, 0.56, 0.60], + } +} diff --git a/src-tauri/core/src/model3d/pick.rs b/src-tauri/core/src/model3d/pick.rs index 5a0fa353..bebc21ad 100644 --- a/src-tauri/core/src/model3d/pick.rs +++ b/src-tauri/core/src/model3d/pick.rs @@ -201,6 +201,17 @@ pub fn pick_geometry(p: &Project) -> Result { (pos, idx, &m.id) } ContextObject::ImportedMesh(m) => (std::borrow::Cow::Borrowed(m.positions.as_slice()), std::borrow::Cow::Borrowed(m.indices.as_slice()), &m.id), + // [68] Verbauwand: Körper der Baugrube (Positionen im Modell, Welt wie die übrigen Kontext-Meshes). + ContextObject::Excavation(e) => { + if let Some(s) = crate::excavation::shoring_solids(p).into_iter().find(|s| s.excavation_id == e.id) { + let at = |i: u32| -> V3 { [s.pos[i as usize * 3], s.pos[i as usize * 3 + 2], -s.pos[i as usize * 3 + 1]] }; + let tris: Vec = s.idx.chunks_exact(3).map(|t| [at(t[0]), at(t[1]), at(t[2])]).collect(); + if !tris.is_empty() { + context_meshes.push(PickContextMesh { tris, context_object_id: e.id.clone() }); + } + } + continue; + } _ => continue, }; let (pos, idx) = (&*pos, &*idx); diff --git a/src-tauri/core/src/model3d/tests.rs b/src-tauri/core/src/model3d/tests.rs index b291709d..8b146e7f 100644 --- a/src-tauri/core/src/model3d/tests.rs +++ b/src-tauri/core/src/model3d/tests.rs @@ -594,3 +594,44 @@ fn netzkoerper_klasse_ausgeblendet() { assert!(emit_context_meshes(&mk(false)).is_empty()); assert!(pick_geometry(&mk(false)).unwrap().context_meshes.is_empty()); } + +/// [68] Verbau im 3D: Körper in der Farbe der Verbauart, Klasse der Baugrube, Pick wählt die Baugrube. +#[test] +fn verbau_im_3d_klasse_und_pick() { + let t = crate::model::TerrainMesh { + id: "t".into(), + category_code: "02".into(), + positions: vec![-50.0, -50.0, 0.0, 50.0, -50.0, 0.0, 50.0, 50.0, 0.0, -50.0, 50.0, 0.0], + indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], + ..Default::default() + }; + let v = |x: f64, y: f64| crate::model::Vec2 { x, y }; + let pit = crate::model::Excavation { + id: "bg".into(), + category_code: "07".into(), + outline: vec![v(0.0, 0.0), v(8.0, 0.0), v(8.0, 6.0), v(0.0, 6.0)], + bottom: -3.0, + edge_shoring: Some(vec![true, false, true, false]), + shoring_kind: Some("soldierPile".into()), + shoring_embed: Some(0.5), + ..Default::default() + }; + let cat = |visible| crate::model::LayerCategory { code: "07".into(), name: "Baugrube".into(), visible, ..Default::default() }; + let mk = |visible| Project { context: Some(vec![ContextObject::TerrainMesh(t.clone()), ContextObject::Excavation(pit.clone())]), layers: vec![cat(visible)], ..Default::default() }; + let meshes = emit_context_meshes(&mk(true)); + assert_eq!(meshes.len(), 2, "Gelände + Verbau"); + let m = meshes.iter().find(|m| matches!(m.owner, Owner::Context(1))).unwrap(); + assert_eq!(m.color, shoring_rgb("soldierPile")); + // Zwei Wände: unten Sohle - 0.5, oben Gelände (0). + let zs: Vec = m.positions.chunks_exact(3).map(|q| q[2]).collect(); + assert!((zs.iter().cloned().fold(f64::INFINITY, f64::min) + 3.5).abs() < 1e-6 && zs.iter().cloned().fold(f64::NEG_INFINITY, f64::max).abs() < 1e-6); + assert_eq!(m.indices.len(), 2 * 12 * 3); + // Klasse aus: Verbau weg, Gelände bleibt. + let off = emit_context_meshes(&mk(false)); + assert_eq!(off.len(), 1); + assert!(off.iter().all(|m| matches!(m.owner, Owner::Context(0)))); + // Pick. + let g = pick_geometry(&mk(true)).unwrap(); + assert!(g.context_meshes.iter().any(|m| m.context_object_id == "bg" && m.tris.len() == 24)); + assert!(pick_geometry(&mk(false)).unwrap().context_meshes.iter().all(|m| m.context_object_id != "bg" || m.tris.len() != 24), "Klasse aus: kein Verbau-Pick"); +} diff --git a/src-tauri/core/src/plan/context.rs b/src-tauri/core/src/plan/context.rs index 04e8da07..25af30ef 100644 --- a/src-tauri/core/src/plan/context.rs +++ b/src-tauri/core/src/plan/context.rs @@ -365,6 +365,8 @@ pub(super) fn outside_bb(a: Vec2, b: Vec2, rings: &[Vec], bb: [f64; 4]) -> ts.windows(2).filter(|w| w[1] - w[0] > 1e-9 && !rings.iter().any(|r| inside(at((w[0] + w[1]) / 2.0), r))).map(|w| (at(w[0]), at(w[1]))).collect() } const EXCAVATION_INK: &str = "#1f242c"; +/// [68] Warnmarke: Arbeitsraum zu schmal. +const WS_WARN_INK: &str = "#d6001c"; fn ink_line(a: Vec2, b: Vec2, w: f64, color: &str, dash: Option>) -> Primitive { Primitive::Line { a, b, cls: "context-line".into(), weight_mm: w, dash: dash.map(Some), zigzag: None, motif: None, color: Some(color.into()), drawing_id: None, opening_id: None, stair_id: None, greyed: None, opacity: None } @@ -810,6 +812,28 @@ fn excavation_lines(c: &Ctx, e: &Excavation, out: &mut Vec, bands: &m } } } + // [68] Verbauwand als Wandband an der Kante: Dicke nach aussen, Schraffur der Verbauart; Pick wählt die Baugrube. + let quads = spec.shoring_quads(); + if !quads.is_empty() { + let hatch = crate::plan::style::resolve_hatch(c.p, crate::excavation::shoring_hatch_id(spec.shore_kind), None, None, None) + .unwrap_or_else(no_hatch); + for (_, q) in quads { + let mut band = super::section::polygon(q.iter().map(|p| v2(p[0], p[1])).collect(), crate::plan::style::HATCH_PAPER, EXCAVATION_INK, 0.25, hatch.clone()); + if let Primitive::Polygon { context_object_id, .. } = &mut band { + *context_object_id = Some(e.id.clone()); + } + out.push(band); + } + } + // [68] Arbeitsraum zu schmal (enge Nische, gekappte Ecke): rotes Kreuz an der Stelle. + if let Some(chk) = crate::excavation::working_space_check(spec).filter(|w| !w.ok) { + let r = 0.0025 * c.a.scale.max(1.0); + for s in chk.spots { + for (dx, dy) in [(1.0, 1.0), (1.0, -1.0)] { + out.push(ink_line(v2(s[0] - dx * r, s[1] - dy * r), v2(s[0] + dx * r, s[1] + dy * r), 0.35, WS_WARN_INK, None)); + } + } + } break; } } @@ -1471,6 +1495,32 @@ mod tests { assert_eq!(sohle.iter().filter(|(a, b)| (a.x - 12.0).abs() < 1e-9 && (b.x - 12.0).abs() < 1e-9).count(), 1, "Westrand ganz"); } + /// [68] Verbau als Wandband im Grundriss (mit Schraffur der Verbauart, Pick = Baugrube) und rotes Kreuz, wo der + /// Arbeitsraum an einer engen Nische nicht reicht. + #[test] + fn verbauband_und_arbeitsraum_marke() { + let mut p = sample_with_walls(serde_json::json!([["h1", "eg", 14.0, 0.0, 26.0, 0.0]])); + let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, -10.0, 0.0, 40.0, -10.0, 0.0, 40.0, 30.0, 0.0, 0.0, 30.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() }; + let mut pit = Excavation { id: "bg".into(), category_code: "02".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, edge_shoring: Some(vec![true, false, false, false]), shoring_kind: Some("soldierPile".into()), ..Default::default() }; + p.context = Some(vec![ContextObject::TerrainMesh(t.clone()), ContextObject::Excavation(pit.clone())]); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "show": ["02", "90", "80", "02"], "scale": 100}"#).unwrap(); + let c = Ctx::new(&p, &a); + let mut ctx = Vec::new(); + plan_context(&c, &mut ctx); + let bands: Vec<&Primitive> = ctx.iter().filter(|q| matches!(q, Primitive::Polygon { stroke, context_object_id: Some(id), .. } if stroke == EXCAVATION_INK && id == "bg")).collect(); + assert_eq!(bands.len(), 1, "ein Band für die eine verbaute Kante"); + assert!(!ctx.iter().any(|q| matches!(q, Primitive::Line { color: Some(k), .. } if k == WS_WARN_INK)), "kein Arbeitsraum, keine Marke"); + // Enge Nische mit Arbeitsraum: Marken. + pit.outline = vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(20.5, 10.0), v2(20.5, 3.0), v2(19.5, 3.0), v2(19.5, 10.0), v2(12.0, 10.0)]; + pit.edge_shoring = None; + pit.working_space = Some(1.0); + p.context = Some(vec![ContextObject::TerrainMesh(t), ContextObject::Excavation(pit)]); + let c = Ctx::new(&p, &a); + let mut ctx = Vec::new(); + plan_context(&c, &mut ctx); + assert!(ctx.iter().any(|q| matches!(q, Primitive::Line { color: Some(k), .. } if k == WS_WARN_INK))); + } + /// [157] Schnittmarken-Beschriftung nicht auf der Böschungsschraffur: Sohle, Böschungsoberkante und Schraffur /// der sichtbaren Baugrube sind Hindernisse („B-B“ lag im Musterhaus komplex in der Böschung). #[test] diff --git a/src-tauri/core/src/plan/elevation/collect.rs b/src-tauri/core/src/plan/elevation/collect.rs index 91b1405e..813e8369 100644 --- a/src-tauri/core/src/plan/elevation/collect.rs +++ b/src-tauri/core/src/plan/elevation/collect.rs @@ -130,6 +130,18 @@ pub(super) fn collect_mesh_faces(p: &Project, frame: &[f64; 9]) -> Vec { out } +/// [68] Verbauwände der Baugruben als Netz-Flächen (Role::Mesh, id = Baugrube): Farbe der Verbauart wie im 3D, +/// Verdeckung wie jedes Netz über die exakte Sichtbarkeit. +pub(super) fn collect_shoring_faces(p: &Project, frame: &[f64; 9]) -> Vec { + let mut out = Vec::new(); + for s in crate::excavation::shoring_solids(p) { + let idx: Vec = s.idx.iter().map(|&i| i as f64).collect(); + let Some(info) = crate::mesh_view::analyze(&s.pos, &idx) else { continue }; + mesh_faces(frame, &s.pos, &info, Role::Mesh, &s.excavation_id, model3d::shoring_rgb(s.kind), &mut out); + } + out +} + /// [115] Freie Körper (`extrudedSolids`, Netze aus dem Kern, `solid_mesh.rs`) wie importierte Netze; Abzugskörper /// sind kein Material und fehlen. pub(super) fn collect_body_faces(p: &Project, frame: &[f64; 9]) -> Vec { diff --git a/src-tauri/core/src/plan/elevation/mod.rs b/src-tauri/core/src/plan/elevation/mod.rs index 1b07ba87..c0f00d11 100644 --- a/src-tauri/core/src/plan/elevation/mod.rs +++ b/src-tauri/core/src/plan/elevation/mod.rs @@ -226,6 +226,7 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool, faces.extend(collect_column_faces(p, &frame)); faces.extend(collect_mesh_faces(p, &frame)); faces.extend(collect_body_faces(p, &frame)); + faces.extend(collect_shoring_faces(p, &frame)); // Ansichtsbereich ([36]): Bauteile, deren nächster Punkt weiter als `depth` hinter der Ansichtsebene // liegt, entfallen ganz (samt ihren Öffnungen, s. unten). let far = level.depth.filter(|d| *d > 0.0).map(|d| (d, drop_far_faces(&mut faces, d))); @@ -253,8 +254,15 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool, } let mut mesh_cat: HashMap<&str, &str> = HashMap::new(); for c in p.context.as_deref().unwrap_or(&[]) { - if let ContextObject::ImportedMesh(m) = c { - mesh_cat.entry(m.id.as_str()).or_insert(m.category_code.as_str()); + match c { + ContextObject::ImportedMesh(m) => { + mesh_cat.entry(m.id.as_str()).or_insert(m.category_code.as_str()); + } + // [68] Verbauwand der Baugrube: Klasse der Baugrube. + ContextObject::Excavation(e) => { + mesh_cat.entry(e.id.as_str()).or_insert(e.category_code.as_str()); + } + _ => {} } } // [180] Freie Körper mit ihrer Klasse. diff --git a/src-tauri/core/src/plan/section/meshes.rs b/src-tauri/core/src/plan/section/meshes.rs index cd0b9407..97df4d37 100644 --- a/src-tauri/core/src/plan/section/meshes.rs +++ b/src-tauri/core/src/plan/section/meshes.rs @@ -249,9 +249,78 @@ pub(super) fn append_terrain_profiles(out: &mut Output, p: &Project, base: (f64, } } } + append_shoring(out, p, base, u, range); append_earth(out, p, base, u); } +/// [68] Verbauwände der Baugruben im Schnitt: das Wandband jeder verbauten Sohlkante (Dicke nach aussen) wird mit +/// der Schnittebene geschnitten; oben das gewachsene Gelände, unten Sohle minus Einbindetiefe. Bänder ausserhalb +/// der Schnittweite fallen weg. +fn append_shoring(out: &mut Output, p: &Project, base: (f64, f64), u: (f64, f64), range: Option<(f64, f64)>) { + let mut done: Vec = Vec::new(); + for t in crate::excavation::terrains(p) { + if t.positions.len() < 9 { + continue; + } + let st = crate::excavation::site_terrain(p, t); + let idx = st.index_orig(); + for (id, spec, _) in &st.items { + if done.contains(id) { + continue; + } + let Some(e) = crate::excavation::excavations(p).into_iter().find(|e| e.id == *id) else { continue }; + let quads = spec.shoring_quads(); + if quads.is_empty() { + continue; + } + done.push(id.clone()); + let hatch_id = crate::excavation::shoring_hatch_id(spec.shore_kind); + let hatch = crate::plan::style::resolve_hatch(p, hatch_id, None, None, None) + .unwrap_or(HatchRender { pattern: HatchPattern::Diagonal, scale: 1.0, angle: 45.0, color: HATCH_INK.into(), line_weight: 0.1, ..no_hatch_base() }); + let z_bottom = e.bottom - crate::excavation::shoring_embed(e); + for (_, quad) in quads { + // Schnitt der Geraden base + s·u mit dem Viereck: erster und letzter Durchgang. + let mut ss: Vec = Vec::new(); + for i in 0..quad.len() { + let (a, b) = (quad[i], quad[(i + 1) % quad.len()]); + let (ex, ey) = (b[0] - a[0], b[1] - a[1]); + let den = u.0 * ey - u.1 * ex; + if den.abs() < 1e-12 { + continue; + } + let (wx, wy) = (a[0] - base.0, a[1] - base.1); + let s_ = (wx * ey - wy * ex) / den; + let t_ = (wx * u.1 - wy * u.0) / den; + if (0.0..1.0).contains(&t_) { + ss.push(s_); + } + } + ss.sort_by(|a, b| a.total_cmp(b)); + let (Some(&s0), Some(&s1)) = (ss.first(), ss.last()) else { continue }; + if s1 - s0 < 1e-6 { + continue; + } + if let Some((lo, hi)) = range { + if s1 < lo - TERRAIN_MARGIN || s0 > hi + TERRAIN_MARGIN { + continue; + } + } + let top = |s: f64| idx.z_at(base.0 + u.0 * s, base.1 + u.1 * s).map(|z| z - st.datum); + let (Some(z0), Some(z1)) = (top(s0), top(s1)) else { continue }; + if z0.max(z1) <= e.bottom + 1e-3 { + continue; + } + out.shoring.push(ShoringCut { + ring: vec![[s0, z_bottom], [s1, z_bottom], [s1, z1.max(e.bottom)], [s0, z0.max(e.bottom)]], + hatch: hatch.clone(), + category: e.category_code.clone(), + excavation_id: e.id.clone(), + }); + } + } + } +} + /// Geschlossenes Dreiecksnetz: jede Kante gehört zu genau zwei Dreiecken. fn is_closed(indices: &[f64]) -> bool { if indices.len() < 12 { @@ -291,6 +360,7 @@ fn append_earth(out: &mut Output, p: &Project, base: (f64, f64), u: (f64, f64)) return; } let mut band = crate::polygon_bool::union(&band); + // [68] Die Verbauwände lässt erst `section_primitives` aus, und nur die sichtbaren (ausgeblendete Klasse = kein Loch). // Gebäude-Inneres: Abschnitte der Schnittlinie in der Grundfläche. let mut holes: Vec = Vec::new(); for poly in crate::site_rules::building_footprint(p) { diff --git a/src-tauri/core/src/plan/section/mod.rs b/src-tauri/core/src/plan/section/mod.rs index 0dd560a7..b49eeadb 100644 --- a/src-tauri/core/src/plan/section/mod.rs +++ b/src-tauri/core/src/plan/section/mod.rs @@ -480,6 +480,16 @@ pub struct Profile { pub natural: bool, } +/// [68] Schnitt durch die Verbauwand einer Baugrube. +#[derive(Clone, Debug)] +pub struct ShoringCut { + pub ring: Vec<[f64; 2]>, + pub hatch: HatchRender, + /// Klasse der Baugrube. + pub category: String, + pub excavation_id: String, +} + /// Ergebnis eines Schnitts (`SectionOutput`). #[derive(Clone, Debug, Default)] pub struct Output { @@ -489,6 +499,8 @@ pub struct Output { pub profiles: Vec, /// [T6] Erdreich unter dem gestalteten Terrain (Band, ohne Gebäude-Inneres), mit Schraffur. pub earth: Vec<(Vec<[f64; 2]>, HatchRender)>, + /// [68] Verbauwände der Baugruben (Spundwand, Rühlwand, Bohrpfahlwand) als Schnittflächen mit Schraffur. + pub shoring: Vec, /// [137] Gelände, zu dem das Erdreich-Band gehört (Pick-Id: Klick ins Band wählt das Gelände). pub terrain_id: Option, /// [152] Importierte Netze im Schnitt (Index = `Cut::index`/`Edge::index` bei `Kind::Mesh`). @@ -631,7 +643,7 @@ pub(super) fn compute_plane(p: &Project, level: &LevelSpec, bodies: &[BodyMesh], let (mut visible, hidden) = projection_edges(p, &plane, &walls_r, &wi, &slabs_r, &bodies, &meshes, &cuts, level.hidden_lines, level.depth, strip.map_or(&[][..], |s| &s.half[..]), &skip); shaped_projection(&mut visible, p, &walls_r, &plane); let meshes = meshes.iter().map(|m| MeshMeta { id: m.mesh.id.clone(), name: m.mesh.name.clone(), category: Some(m.mesh.category_code.clone()) }).collect(); - let mut out = Output { cuts, visible, hidden, profiles: Vec::new(), earth: Vec::new(), terrain_id: None, meshes, mesh_lines, edge_cats }; + let mut out = Output { cuts, visible, hidden, profiles: Vec::new(), earth: Vec::new(), shoring: Vec::new(), terrain_id: None, meshes, mesh_lines, edge_cats }; append_terrain_profiles(&mut out, p, base, u); if let Some(s) = strip { unfold::clip_output(&mut out, s); diff --git a/src-tauri/core/src/plan/section/primitives.rs b/src-tauri/core/src/plan/section/primitives.rs index 5d1a3761..15c620f8 100644 --- a/src-tauri/core/src/plan/section/primitives.rs +++ b/src-tauri/core/src/plan/section/primitives.rs @@ -432,7 +432,18 @@ pub fn section_primitives_mv(out: &Output, mono: bool, hidden_lines: bool, vis: let tov = rules.terrain.as_ref(); let terrain_shown = out.profiles.iter().all(|pr| pr.category.as_deref().is_none_or(shown)) && !tov.is_some_and(|(a, _)| a.hidden()); if terrain_shown { - for (ring, hatch) in &out.earth { + // [68] Sichtbare Verbauwände stehen im Erdreich: das Band lässt sie aus. + let walls: Vec = out.shoring.iter().filter(|w| shown(&w.category)).map(|w| vec![w.ring.clone()]).collect(); + let earth: Vec<(Vec<[f64; 2]>, &HatchRender)> = if walls.is_empty() { + out.earth.iter().map(|(r, h)| (r.clone(), h)).collect() + } else { + out.earth + .iter() + .flat_map(|(r, h)| crate::polygon_bool::difference(&[vec![r.clone()]], &walls).into_iter().filter_map(move |poly| poly.into_iter().next().filter(|o| o.len() >= 3).map(|o| (o, h)))) + .collect() + }; + for (ring, hatch) in &earth { + let hatch: &HatchRender = hatch; let hatch = match tov.and_then(|(_, l)| l.hatch.as_deref()) { Some("none") => no_hatch(), Some("material") | None => hatch.clone(), @@ -449,6 +460,18 @@ pub fn section_primitives_mv(out: &Output, mono: bool, hidden_lines: bool, vis: } // [157] Verdeckte Kanten kommen hier hinein (unter die Schnittflächen, die sie verdecken). let cut_start = prims.len(); + // [68] Verbauwände der Baugruben (Klasse der Baugrube), mit Schraffur der Verbauart; Pick wählt die Baugrube. + for w in out.shoring.iter().filter(|w| shown(&w.category)) { + let hatch = if mono { HatchRender { color: SECTION_INK.into(), ..w.hatch.clone() } } else { w.hatch.clone() }; + let mut pr = polygon(w.ring.iter().map(|q| v2(q[0], q[1])).collect(), HATCH_PAPER, SECTION_INK, SECTION_JOINT_MM, hatch); + if let Primitive::Polygon { context_object_id, greyed, .. } = &mut pr { + *context_object_id = Some(w.excavation_id.clone()); + *greyed = Some(vis.greyed(&w.category)); + } + w.ring.iter().for_each(|q| acc.add(q[0], q[1])); + cut_rings.push(vec![w.ring.clone()]); + prims.push(pr); + } for cp in &merged { if cp.pts.len() < 3 { continue; diff --git a/src-tauri/core/src/plan/section/tests.rs b/src-tauri/core/src/plan/section/tests.rs index a5a16619..3abb5890 100644 --- a/src-tauri/core/src/plan/section/tests.rs +++ b/src-tauri/core/src/plan/section/tests.rs @@ -861,6 +861,120 @@ fn gelaende_mit_baugrube_im_schnitt() { assert!(!f.is_empty() && f.iter().all(|q| q.natural == Some(0.0) && q.designed.is_some_and(|z| (z + 2.0).abs() < 1e-6))); } +/// [68] Verbau im Schnitt: verbaute Kanten werden zu geschnittenen Wänden mit Dicke und Schraffur der Verbauart, +/// das Erdreich-Band spart sie aus; Klasse der Baugrube steuert die Sichtbarkeit. +#[test] +fn verbauwand_im_schnitt() { + let mut p = sample(); + let flat = TerrainMesh { + id: "t".into(), + positions: vec![-50.0, -50.0, 0.0, 50.0, -50.0, 0.0, 50.0, 50.0, 0.0, -50.0, 50.0, 0.0], + indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], + category_code: "02".into(), + ..Default::default() + }; + let pit = Excavation { + id: "bg".into(), + category_code: "07".into(), + outline: vec![Vec2 { x: -1.0, y: -1.0 }, Vec2 { x: 6.0, y: -1.0 }, Vec2 { x: 6.0, y: 5.0 }, Vec2 { x: -1.0, y: 5.0 }], + bottom: -2.0, + edge_shoring: Some(vec![true; 4]), + shoring_kind: Some("borePile".into()), + shoring_thickness: Some(0.5), + ..Default::default() + }; + p.context = Some(vec![ContextObject::TerrainMesh(flat), ContextObject::Excavation(pit)]); + let out = compute_section(&p, &level(&p, "schnitt-a"), &[]).unwrap().unwrap(); + assert!(!out.shoring.is_empty(), "Verbauwand geschnitten"); + for w in &out.shoring { + let zs: Vec = w.ring.iter().map(|q| q[1]).collect(); + let (lo, hi) = (zs.iter().cloned().fold(f64::INFINITY, f64::min), zs.iter().cloned().fold(f64::NEG_INFINITY, f64::max)); + assert!((lo + 3.0).abs() < 1e-6 && hi.abs() < 1e-6, "Sohle −2 minus Einbindung 1, Oberkante Gelände 0: {lo} {hi}"); + assert!(w.ring[1][0] - w.ring[0][0] >= 0.5 - 1e-6, "mindestens die Wanddicke"); + assert_eq!(w.category, "07"); + } + let (prims, _) = section_primitives(&out, false, false, &Visibility::default()); + assert!(prims.iter().any(|q| matches!(q, Primitive::Polygon { hatch, context_object_id: Some(id), .. } if id == "bg" && hatch.pattern != HatchPattern::None))); + // Das Erdreich-Band lässt die Wand aus. + let wall_area: f64 = out.shoring.iter().map(|w| (w.ring[1][0] - w.ring[0][0]) * (w.ring[3][1] - w.ring[0][1])).sum(); + assert!(wall_area > 1.0); + // Klasse aus: keine Wand. + let vis = Visibility { has_vis: true, invisible: ["07".to_string()].into_iter().collect(), ..Default::default() }; + let (prims2, _) = section_primitives(&out, false, false, &vis); + assert!(!prims2.iter().any(|q| matches!(q, Primitive::Polygon { context_object_id: Some(id), .. } if id == "bg"))); + // Ohne die Wand kein Loch im Erdreich-Band: die Fläche wächst um (mindestens) die Wandfläche. + let earth_area = |pr: &[Primitive]| -> f64 { + pr.iter() + .filter_map(|q| match q { + Primitive::Polygon { pts, hatch, .. } if hatch.pattern == HatchPattern::Earth => Some((0..pts.len()).map(|i| pts[i].x * pts[(i + 1) % pts.len()].y - pts[(i + 1) % pts.len()].x * pts[i].y).sum::().abs() / 2.0), + _ => None, + }) + .sum() + }; + assert!(earth_area(&prims2) > earth_area(&prims) + 0.5, "{} {} {wall_area}", earth_area(&prims2), earth_area(&prims)); +} + +/// [68] Verbau in der Ansicht: Wandflächen der Baugrube (Pick = Baugrube), Klasse steuert sie. +#[test] +fn verbauwand_in_der_ansicht() { + let (p, _) = shoring_site(); + let lv = level(&p, "ansicht-sued"); + let run = |vis: &Visibility| super::super::elevation::elevation_primitives(&p, &lv, false, false, vis, 100.0).unwrap().unwrap().0; + let has = |ep: &[Primitive]| ep.iter().any(|q| matches!(q, Primitive::Polygon { context_object_id: Some(id), .. } if id == "bg")); + assert!(has(&run(&Visibility::default())), "Verbau in der Ansicht"); + let vis = Visibility { has_vis: true, invisible: ["07".to_string()].into_iter().collect(), ..Default::default() }; + assert!(!has(&run(&vis)), "Klasse aus: kein Verbau"); +} + +fn shoring_site() -> (Project, Excavation) { + let mut p = sample(); + let flat = TerrainMesh { + id: "t".into(), + positions: vec![-50.0, -50.0, 0.0, 50.0, -50.0, 0.0, 50.0, 50.0, 0.0, -50.0, 50.0, 0.0], + indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], + category_code: "02".into(), + ..Default::default() + }; + let pit = Excavation { + id: "bg".into(), + category_code: "07".into(), + outline: vec![Vec2 { x: -1.0, y: -1.0 }, Vec2 { x: 6.0, y: -1.0 }, Vec2 { x: 6.0, y: 5.0 }, Vec2 { x: -1.0, y: 5.0 }], + bottom: -2.0, + edge_shoring: Some(vec![true; 4]), + ..Default::default() + }; + p.context = Some(vec![ContextObject::TerrainMesh(flat), ContextObject::Excavation(pit.clone())]); + (p, pit) +} + +/// [68] Einbindetiefe als Feld: `shoringEmbed` ersetzt die Vorgabe von 1 m. +#[test] +fn verbauwand_einbindetiefe_feld() { + let mut p = sample(); + let flat = TerrainMesh { + id: "t".into(), + positions: vec![-50.0, -50.0, 0.0, 50.0, -50.0, 0.0, 50.0, 50.0, 0.0, -50.0, 50.0, 0.0], + indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], + category_code: "02".into(), + ..Default::default() + }; + let pit = Excavation { + id: "bg".into(), + outline: vec![Vec2 { x: -1.0, y: -1.0 }, Vec2 { x: 6.0, y: -1.0 }, Vec2 { x: 6.0, y: 5.0 }, Vec2 { x: -1.0, y: 5.0 }], + bottom: -2.0, + edge_shoring: Some(vec![true; 4]), + shoring_embed: Some(2.5), + ..Default::default() + }; + p.context = Some(vec![ContextObject::TerrainMesh(flat), ContextObject::Excavation(pit)]); + let out = compute_section(&p, &level(&p, "schnitt-a"), &[]).unwrap().unwrap(); + assert!(!out.shoring.is_empty()); + for w in &out.shoring { + let lo = w.ring.iter().map(|q| q[1]).fold(f64::INFINITY, f64::min); + assert!((lo + 4.5).abs() < 1e-6, "{lo}"); + } +} + fn ov_rule(conds: serde_json::Value, actions: serde_json::Value) -> OverrideRule { let c = conds.as_array().unwrap(); serde_json::from_value(serde_json::json!({"id": "r", "name": "r", "enabled": true, "condition": c[0], "conditions": c[1..].to_vec(), "actions": actions})).unwrap() diff --git a/src-tauri/core/src/plan/section/unfold.rs b/src-tauri/core/src/plan/section/unfold.rs index 71dd48a8..26130fc7 100644 --- a/src-tauri/core/src/plan/section/unfold.rs +++ b/src-tauri/core/src/plan/section/unfold.rs @@ -200,6 +200,7 @@ pub(super) fn clip_output(out: &mut Output, s: &Strip) { .collect(); out.profiles = std::mem::take(&mut out.profiles).into_iter().flat_map(|pr| clip_line_to_u(&pr.pts, lo, hi).into_iter().map(move |pts| Profile { pts, ..pr.clone() })).collect(); out.earth = std::mem::take(&mut out.earth).into_iter().filter_map(|(pts, h)| clip_poly_u(&pts, None, lo, hi).map(|(p, _)| (p, h))).collect(); + out.shoring = std::mem::take(&mut out.shoring).into_iter().filter_map(|mut w| clip_poly_u(&w.ring, None, lo, hi).map(|(p, _)| { w.ring = p; w })).collect(); out.mesh_lines = std::mem::take(&mut out.mesh_lines).into_iter().flat_map(|(k, pts)| clip_line_to_u(&pts, lo, hi).into_iter().map(move |p| (k, p))).collect(); } @@ -216,6 +217,7 @@ pub(super) fn shift_output(out: &mut Output, du: f64) { } out.profiles.iter_mut().flat_map(|p| p.pts.iter_mut()).for_each(sh); out.earth.iter_mut().flat_map(|p| p.0.iter_mut()).for_each(sh); + out.shoring.iter_mut().flat_map(|w| w.ring.iter_mut()).for_each(sh); out.mesh_lines.iter_mut().flat_map(|p| p.1.iter_mut()).for_each(sh); } @@ -230,6 +232,7 @@ pub(super) fn merge_output(acc: &mut Option, o: Output) { a.hidden.extend(o.hidden); a.profiles.extend(o.profiles); a.earth.extend(o.earth); + a.shoring.extend(o.shoring); a.mesh_lines.extend(o.mesh_lines); a.edge_cats.extend(o.edge_cats); if a.terrain_id.is_none() { diff --git a/src/analysis/excavation.ts b/src/analysis/excavation.ts index c959eb9d..2c87e3ba 100644 --- a/src/analysis/excavation.ts +++ b/src/analysis/excavation.ts @@ -18,6 +18,12 @@ export interface ExcavationQuantity { fill: number; /** Hinterfüllung (m³). */ backfill: number; + /** Arbeitsraum: verlangte Breite (m, 0 = keiner), kleinster Abstand Umriss–Sohle, eingehalten? */ + workingSpace: number; + workingSpaceMin: number; + workingSpaceOk: boolean; + /** Stellen mit fehlender Arbeitsraum-Breite (Modell-x/y). */ + workingSpaceSpots: [number, number][]; } export function excavationQuantities(project: Project): ExcavationQuantity[] { diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 6a5802df..5d5a76e1 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -2415,6 +2415,13 @@ export const de = { "site.excavation.noTerrain": "Kein Gelände unter der Baugrube", "site.excavation.workingSpace": "Arbeitsraum [m]", "site.excavation.shoring": "Verbau (senkrecht), Kante", + "site.excavation.shoringKind": "Verbauart", + "site.excavation.shoringKind.sheetPile": "Spundwand (Stahl)", + "site.excavation.shoringKind.soldierPile": "Rühlwand (Träger + Holz)", + "site.excavation.shoringKind.borePile": "Bohrpfahlwand (Beton)", + "site.excavation.shoringThickness": "Wanddicke [m]", + "site.excavation.shoringEmbed": "Einbindetiefe unter Sohle [m]", + "site.excavation.workingSpaceWarn": "Arbeitsraum zu schmal: {min} m statt {need} m an {n} Stelle(n) (rotes Kreuz im Plan)", "site.excavation.shoringHint": "Gewählte Kanten: senkrechte Wand (Spundwand) statt Böschung", "site.earthDepth": "Erdreich-Band im Schnitt [m]", "site.terrain.visible": "Gelände sichtbar", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index ec3f02c4..fc5f74a6 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -2401,6 +2401,13 @@ export const en: Record = { "site.excavation.bermHeight": "Berm every [m]", "site.excavation.workingSpace": "Working space [m]", "site.excavation.shoring": "Shoring (vertical), edge", + "site.excavation.shoringKind": "Shoring type", + "site.excavation.shoringKind.sheetPile": "Sheet piling (steel)", + "site.excavation.shoringKind.soldierPile": "Soldier pile wall (beams + timber)", + "site.excavation.shoringKind.borePile": "Bored pile wall (concrete)", + "site.excavation.shoringThickness": "Wall thickness [m]", + "site.excavation.shoringEmbed": "Embedment below base [m]", + "site.excavation.workingSpaceWarn": "Working space too narrow: {min} m instead of {need} m at {n} spot(s) (red cross in the plan)", "site.excavation.shoringHint": "Selected edges: vertical wall (sheet piling) instead of a slope", "site.earthDepth": "Earth band in section [m]", "site.terrain.visible": "Terrain visible", diff --git a/src/model/sampleProjectComplex.ts b/src/model/sampleProjectComplex.ts index 7b134c06..a8bbfc97 100644 --- a/src/model/sampleProjectComplex.ts +++ b/src/model/sampleProjectComplex.ts @@ -822,7 +822,7 @@ export function buildComplexSampleProject(): Project { type: "excavation", id: "baugrube", name: "Baugrube Haupthaus", categoryCode: "07", // Umriss = Gebäude-Grundfläche UG (mit Erker), Arbeitsraum 0.8 m; Neigungen in Grad. outline: rect(-HA, -HA, 17.2, 10 + HA), bottom: -3.35, slope: 60, fillSlope: 33.7, - edgeSlopes: [60, 50, 90, 60], edgeShoring: [false, false, true, false], workingSpace: 0.8, + edgeSlopes: [60, 50, 90, 60], edgeShoring: [false, false, true, false], shoringKind: "soldierPile", workingSpace: 0.8, }, ], roomProgram: [ diff --git a/src/model/types.generated.ts b/src/model/types.generated.ts index 7ca587c6..e74d043e 100644 --- a/src/model/types.generated.ts +++ b/src/model/types.generated.ts @@ -1279,6 +1279,15 @@ export type Excavation = { * [68] Senkrechter Verbau (Spundwand) je Kante (wie `edgeSlopes`): keine Böschung, Wand steht senkrecht. */ edgeShoring?: Array; + /** + * [68] Art des Verbaus auf den verbauten Kanten: `sheetPile` (Spundwand, Vorgabe), `soldierPile` (Rühlwand), + * `borePile` (Bohrpfahlwand). Bestimmt Vorgabe-Dicke und Schraffur im Schnitt und Grundriss. + */ + shoringKind?: string; + /** [68] Dicke der Verbauwand in m (nach aussen von der Sohlkante); fehlt = Vorgabe der Art. */ + shoringThickness?: number; + /** [68] Einbindetiefe der Verbauwand unter die Sohle in m; fehlt = 1 m. */ + shoringEmbed?: number; }; /** Ein extrudierter Körper: geschlossenes Profil (Modell-Meter) + Höhe. */ diff --git a/src/panels/ContextObjectProps.tsx b/src/panels/ContextObjectProps.tsx index 0ac1d2d7..ae9d8796 100644 --- a/src/panels/ContextObjectProps.tsx +++ b/src/panels/ContextObjectProps.tsx @@ -50,6 +50,11 @@ function ExcavationQty({ q }: { q: ExcavationQuantity | undefined }) { return (
{t("site.excavation.qty", { cut: fmt1(q.cut), fill: fmt1(q.fill), backfill: fmt1(q.backfill) })} + {q.workingSpace > 0 && !q.workingSpaceOk && ( +
+ {t("site.excavation.workingSpaceWarn", { min: q.workingSpaceMin.toFixed(2), need: q.workingSpace.toFixed(2), n: q.workingSpaceSpots.length })} +
+ )}
); } @@ -182,6 +187,24 @@ export function ContextObjectProps({ obj, quantities }: { obj: ContextObject; qu ))} + {obj.edgeShoring?.some(Boolean) && ( + <> + + + + + )} x.id === obj.id)} /> ); diff --git a/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt b/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt index bb50115f..691463ae 100644 --- a/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt +++ b/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt @@ -1,12 +1,12 @@ -viewBox -4.2 0 37.045 17.378 -bytes 175524 +viewBox -4.2 0 38 18.478 +bytes 178085 circle 4 g 1 -line 514 +line 521 path 2 -polygon 765 -polyline 155 +polygon 774 +polyline 161 rect 1 svg 1 text 4 -hash ecd6c1d2799ca660 +hash 587f4d87add7ecf0 diff --git a/src/plan/__golden__/komplex-model3d.txt b/src/plan/__golden__/komplex-model3d.txt index 4cdbc4ad..d00fcce7 100644 --- a/src/plan/__golden__/komplex-model3d.txt +++ b/src/plan/__golden__/komplex-model3d.txt @@ -1,5 +1,5 @@ -meshes [1961] -meshes[].color [3] x1961 +meshes [1962] +meshes[].color [3] x1962 meshes[].indices [108] x6 meshes[].indices [11376] meshes[].indices [1152] @@ -12,7 +12,7 @@ meshes[].indices [180] meshes[].indices [192] x3 meshes[].indices [348] x6 meshes[].indices [360] -meshes[].indices [36] x1860 +meshes[].indices [36] x1861 meshes[].indices [396] meshes[].indices [564] x2 meshes[].indices [60] x9 @@ -26,7 +26,7 @@ meshes[].positions [108] x30 meshes[].positions [120] meshes[].positions [180] x10 meshes[].positions [216] -meshes[].positions [24] x1828 +meshes[].positions [24] x1829 meshes[].positions [252] x2 meshes[].positions [264] meshes[].positions [288] x8 @@ -72,4 +72,4 @@ walls[].start [2] x1492 walls[].startCut [4] x1107 walls[].topDrop [2] x115 walls[].topPlane [3] x271 -hash 1a05da01394b019d +hash d00c532d2d56884e diff --git a/src/styles.css b/src/styles.css index 91fc0ff3..32f53cf0 100644 --- a/src/styles.css +++ b/src/styles.css @@ -4962,6 +4962,9 @@ body { grid-column: 1 / -1; color: var(--text-dim, inherit); } +.site-panel .site-warn { + color: #d6001c; +} .site-panel .site-check { display: flex; align-items: center;