diff --git a/TODO.md b/TODO.md index 92c93f04..8807593d 100644 --- a/TODO.md +++ b/TODO.md @@ -320,9 +320,13 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* Kontext-Netze nicht in der Projektion. · XL - ◐ **[G6]** Allgemeine Polygon-Dominanz im Schnitt. 3D-Live-Schnitt (`render3d/section_boolean.rs`) rechnet nur Rechtecke, Ring mit Loch bleibt unbeschnitten; dort fehlt auch der Schraffur-Deckel von Abzugskörpern (aus [G8]). · M -- ◐ **[G1]** Ebenenschnitt beliebiger Körper (`plan/meshSection.ts`, `plan/domains.rs`). Poché für B-Rep-Körper im Grundriss - (kein Netz im Kern), Eckenradius/Fase in der Poché, `ExtrudedSolid` ohne Material-Feld (keine SIA-Schraffur), - Abzugskörper beliebiger Form im Grundriss, Untersicht von Wendel-/Podesttreppen. · L +- ◐ **[G1]** Ebenenschnitt beliebiger Körper (`plan/mesh_plan.rs::plan_bodies`, `plan/extras.rs`). 11.11.: Grundriss aller + freien Körper über das Kern-Netz (`solid_mesh.rs`): Poché = Ebenenschnitt auf Schnitthöhe (B-Rep, Eckenradius/Fase, + Löcher, Verjüngung), darunter Aufsicht, darüber Überkopf; `ExtrudedSolid.componentId` (Objekt-Info „Bauteil") + gibt Füllung/SIA-Schraffur in Grundriss und Schnitt; Abzugskörper beliebiger Form sparen Wände/Stützen (Ebenenschnitt) + und Decken (Grundriss im Plattenband, Manifold + i_overlay) aus; Kreis-Körper ohne `points` bauen. Offen: Untersicht + von Wendel-/Podesttreppen; Abzugskörper-Symbol bleibt das Profil-Rechteck mit Kreuz; Körper verdecken keine + importierten Netze (getrennte Sichtbarkeitsrechnung); nicht in der Tauri-App geprüft. · M - ◐ **[G2]** Wand an Dach. Ansicht bleibt Painter + Verdeckungstest (→ [G4]); fast achsparallele Grenzen im Band nur genähert; Fenster, das ins Dach ragt, verliert seinen Sturz; Dachgeometrie im 3D-Live-Schnitt unverändert (`wall_bands.rs`). · M @@ -338,8 +342,8 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* rechnet der Kern selbst (`solid_mesh.rs`, Tessellierung der B-Rep-Beschreibung, Booleans über Manifold; Entscheid in `doc/ARCHITEKTUR.md`): Ansicht (Flächen mit Körper-Id, Verdeckung, Klasse), Blatt-Viewports (Schnitt + Ansicht, Fang) und CLI zeigen freie Körper; `computeSection` baut keine truck-Netze mehr. Offen: 3D nimmt weiter truck (könnte die Kern-Netze - nehmen); Kreis-Körper mit leeren `points` (Brunnen im Musterhaus komplex) baut weder truck noch der Kern; 3D-Ausschnitt im - Viewport; nicht in der Tauri-App geprüft. · S + nehmen); Kreis-Körper mit leeren `points` (Brunnen im Musterhaus komplex) baut der Kern seit [G1] (truck/3D nicht geprüft); + 3D-Ausschnitt im Viewport; nicht in der Tauri-App geprüft. · S - ◐ **[36]** View Range (`plan/view_range.rs`). Dach/Decke über/unter Schnitt verfeinern, Raum/Fenster eigenständig, Tiefe nur ganzes Bauteil (kein Clip an der Ebene). 11.11.: Öffnung ganz unter der Schnittebene schliesst die Wand auch ohne eigenen Bereich (Symbol gepunktet, `walls.rs`). · M @@ -625,7 +629,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* Auf dem Mac (Tauri/Metal) noch nicht angesehen oder geprüft; bisher nur Linux-Container, CLI-SVG, Chromium oder Unit-Tests: [116] (atomares Speichern), [117] (CSP unter `tauri://`), [118], [122], [123], [126], [110], [101], -[102], [131], [133], [136], [140], [145], [146], [153], [64], [T2], [T4], [34], [108], [65], [169], [113], [181]. Je Punkt ansehen, dann hier und +[102], [131], [133], [136], [140], [145], [146], [153], [64], [T2], [T4], [34], [108], [65], [169], [113], [181], [G1]. Je Punkt ansehen, dann hier und im jeweiligen Eintrag streichen. · M (gesamt) --- diff --git a/doc/ARCHITEKTUR.md b/doc/ARCHITEKTUR.md index c4ee8a88..e8e1a0e2 100644 --- a/doc/ARCHITEKTUR.md +++ b/doc/ARCHITEKTUR.md @@ -151,6 +151,10 @@ bekommt): alle Arten der Beschreibung sind einfache Extrusionen, Lofts, Rotation Flächen als Facetten (5 mm Sehnenabweichung); Booleans und Löcher über Manifold. Verworfen: die TS-Netze als Dokument-Cache in den Kern zu reichen (asynchron, fehlt in CLI und PDF, zweite Wahrheit). truck bleibt für das 3D-Bild (exakte Rundungen), STEP, Kennwerte und Kollision; das 3D könnte später ebenfalls die Kern-Netze nehmen. +Seit [G1] zeichnet auch der Grundriss alle freien Körper aus diesen Netzen (wie importierte Netze, `plan/mesh_plan.rs`: +waagrechter Ebenenschnitt als Poché, Aufsicht/Überkopf über `hlr`), und Abzugskörper beliebiger Form sparen im +Grundriss über Ebenenschnitt bzw. Grundriss im Plattenband aus (`plan/extras.rs::subtract_voids`, Manifold-Band + +i_overlay-Vereinigung). Senkrechte Prismen-Abzugskörper bleiben beim Profil-Weg. --- @@ -243,7 +247,7 @@ Beispiel: Die Plan-Ansicht zeigt das Erdgeschoss im Massstab 1:100. | Wände mit Öffnungen | `plan_walls()` in `plan/walls.rs` | Wandknoten `joins.rs`, Poché `plan/wall_poche.rs`, Symbole `plan/openings.rs` und `opening_geom.rs`, Wand an Stütze `plan/wall_columns.rs` | | Treppen | `plan_stairs()` in `plan/stairs.rs` | Symbol `plan/stair_symbol.rs`, Geometrie `stair.rs` und `kernel2d` | | Stützen, Bäume | `columns()`, `plan_trees()` | `plan/trees.rs`, `tree.rs` | - | Körper (Extrusionen) | `solids()` in `domains.rs` | Umriss auf Schnitthöhe | + | Körper (Extrusionen) | `solids()` in `domains.rs` | Kern-Netz (`solid_mesh.rs`) über `plan/mesh_plan.rs::plan_bodies()`: Ebenenschnitt (Poché, Bauteil-Schraffur aus `componentId`), Aufsicht, Überkopf ([G1]) | | 2D-Zeichnungen | `plan_drawings()` in `plan/drawings.rs` | Linien, Bögen, Bemassung, Texte, Blöcke | | Schnittführungen | `plan_section_lines()` in `plan/context.rs` | Symbol aus `plan/misc.rs` | | Kontext, Gelände | `plan_context_with()` in `plan/context.rs` | Höhenlinien `terrain.rs`, Netze `plan/mesh_plan.rs` | diff --git a/src-tauri/core/src/cmd_solid.rs b/src-tauri/core/src/cmd_solid.rs index 6172ca58..12e47580 100644 --- a/src-tauri/core/src/cmd_solid.rs +++ b/src-tauri/core/src/cmd_solid.rs @@ -43,11 +43,12 @@ pub fn extruded_solid_spec(solid: &Value, floor_z: f64) -> Option { return Some(obj(vec![("kind", s("translate")), ("v", json!([js_num(dx), js_num(dy), js_num(base_z)])), ("solid", spec)])); } let height = num_of(field(solid, "height")); - if points.len() < 3 || height <= 0.0 { - return None; - } let taper = jsnum::min(1.0, jsnum::max(0.0, num_or(field(solid, "taper"), 0.0))); let circle = field(solid, "circle").filter(|c| truthy(Some(c))); + // [G1] Kreis-Körper brauchen keine Profil-Punkte (Brunnen im Musterhaus komplex: `points` leer). + if height <= 0.0 || (points.len() < 3 && circle.is_none()) { + return None; + } if let Some(c) = circle { if taper < 1e-6 || taper >= 1.0 - 1e-6 { let ctr = xy(field(c, "center").unwrap_or(&Value::Null)); @@ -62,6 +63,9 @@ pub fn extruded_solid_spec(solid: &Value, floor_z: f64) -> Option { ])); } } + if points.len() < 3 { + return None; + } let pts: Vec = points.iter().map(xy).collect(); let flat = |ps: &[V]| Value::Array(ps.iter().flat_map(|p| [js_num(p.0), js_num(p.1)]).collect()); if taper < 1e-6 { diff --git a/src-tauri/core/src/model/generated.rs b/src-tauri/core/src/model/generated.rs index 1034099b..5554b95a 100644 --- a/src-tauri/core/src/model/generated.rs +++ b/src-tauri/core/src/model/generated.rs @@ -4589,6 +4589,11 @@ pub struct ExtrudedSolid { #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional, inline)] pub brep: Option, + /// [G1] Bauteil (Component Manager) des Körpers: Füllung und SIA-Schraffur der Schnittfläche im + /// Grundriss und im Schnitt. Fehlt = neutrale Körper-Füllung mit Rückfall-Schraffur. + #[serde(rename = "componentId", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub component_id: Option, #[serde(flatten)] #[ts(skip)] pub extra: Extra, diff --git a/src-tauri/core/src/plan/README.md b/src-tauri/core/src/plan/README.md index 70e8934f..db5e2455 100644 --- a/src-tauri/core/src/plan/README.md +++ b/src-tauri/core/src/plan/README.md @@ -21,7 +21,7 @@ Herkunft, kein Wegweiser. | `stairs.rs`, `stair_symbol.rs` | Treppen: Filter und Stil; Symbol (Tritte, Lauflinie, Pfeil, Bruchlinie) | | `drawings.rs` | freie 2D-Zeichnungen (Linie bis Bild, Bemassung, Blöcke), Zeichnungs-Stücke, kompakte Linien-Unterlage | | `context.rs` | Kontext (Höhenlinien, Fussabdrücke importierter Gebäude, Gelände) und Schnittführungs-Symbole | -| `mesh_plan.rs` | importierte Netze im Grundriss: geschnitten, darunter, darüber | +| `mesh_plan.rs` | importierte Netze und ([G1]) freie Körper über ihr Kern-Netz im Grundriss: geschnitten, darunter, darüber | | `ceiling_plan.rs` | Deckenspiegel als eigene Ebenen-Art | | `floor_finish.rs` | Bodenbelag-Muster nach Massstab | | `model_view.rs` | Modelldarstellung ([173]): Optionen je Bauteilart über dem Detailgrad, Rangfolge Element > Typ > Stufe > Basis | diff --git a/src-tauri/core/src/plan/domains.rs b/src-tauri/core/src/plan/domains.rs index 15ddeb4c..ac7cadcd 100644 --- a/src-tauri/core/src/plan/domains.rs +++ b/src-tauri/core/src/plan/domains.rs @@ -1207,6 +1207,12 @@ fn stamp_obstacles_with(d: &DomainPrims, drawn: super::stamp_place::Obstacles) - for q in d.stairs.iter().chain(&d.columns) { o.add_prim(q); } + // [G1] Körper: Schnittfläche und Aufsicht (nicht die Überkopf-Linien) — der Stempel steht daneben. + for q in &d.solids { + if matches!(q, Primitive::Polygon { fill, .. } if fill != "none") || matches!(q, Primitive::Line { dash: None, .. }) { + o.add_prim(q); + } + } for q in &d.walls { if matches!(q, Primitive::Arc { opening_id: Some(_), .. }) { o.add_prim(q); @@ -1553,50 +1559,66 @@ pub(super) fn columns(c: &Ctx, out: &mut Vec) { // ── Extrusionen ───────────────────────────────────────────────────────────── fn solids(c: &Ctx, out: &mut Vec) { + // [180] Körper und Abzugskörper liegen wie jedes Bauteil auf ihrer Klasse (die Aussparung wirkt unabhängig davon). + let on: Vec<&ExtrudedSolid> = c.p.extruded_solids.as_deref().unwrap_or(&[]).iter().filter(|s| s.level_id == c.a.floor && c.vis(&s.category_code, &s.id)).collect(); + // [G1] Körper über ihr Kern-Netz (Ebenenschnitt, Aufsicht, Überkopf); ohne baubares Netz über das Profil. + let bodies: Vec<&ExtrudedSolid> = on.iter().copied().filter(|s| s.operation.as_deref() != Some("subtract")).collect(); + let mut meshed = Vec::new(); + let rest = super::mesh_plan::plan_bodies(c, &bodies, &mut meshed); + for s in on.iter().copied().filter(|s| s.operation.as_deref() == Some("subtract") || rest.iter().any(|r| std::ptr::eq(*r, *s))) { + solid_by_profile(c, s, out); + } + out.extend(meshed); +} + +/// Körper ohne Netz (Kreis-Körper ohne Profil …) und Abzugskörper: Umriss des Profils, geschnitten mit der +/// Profil-Poché ([`body_cut_ring`]). +fn solid_by_profile(c: &Ctx, s: &ExtrudedSolid, out: &mut Vec) { let range = super::view_range::ViewRange::of(c.p, &c.a.floor); let base = c.p.floor(&c.a.floor).and_then(|f| f.base_elevation).unwrap_or(0.0); - // [180] Körper und Abzugskörper liegen wie jedes Bauteil auf ihrer Klasse (die Aussparung wirkt unabhängig davon). - for s in c.p.extruded_solids.as_deref().unwrap_or(&[]).iter().filter(|s| s.level_id == c.a.floor && c.vis(&s.category_code, &s.id)) { - let greyed = c.greyed(&s.category_code).then_some(true); - let subtract = s.operation.as_deref() == Some("subtract"); - let zb = base + s.base_offset.unwrap_or(0.0); - let zone = if subtract { super::view_range::Zone::Cut } else { range.classify(zb, zb + s.height) }; - if zone == super::view_range::Zone::Hidden { - continue; + let greyed = c.greyed(&s.category_code).then_some(true); + let subtract = s.operation.as_deref() == Some("subtract"); + let zb = base + s.base_offset.unwrap_or(0.0); + let zone = if subtract { super::view_range::Zone::Cut } else { range.classify(zb, zb + s.height) }; + if zone == super::view_range::Zone::Hidden { + return; + } + let out_start = out.len(); + if subtract { + out.push(polygon(s.points.clone(), "none", "none", 0.0, no_hatch(), greyed, None, Pick::Solid(&s.id))); + let n = s.points.len(); + let seg = |a: Vec2, b: Vec2, dash: Option>| line(a, b, "void", SYMBOL_HAIRLINE_MM, Some(dash), EXTRUSION_STROKE, greyed); + for i in 0..n { + out.push(seg(s.points[i], s.points[(i + 1) % n], Some(vec![2.0, 1.0]))); } - let out_start = out.len(); - if s.operation.as_deref() == Some("subtract") { - out.push(polygon(s.points.clone(), "none", "none", 0.0, no_hatch(), greyed, None, Pick::Solid(&s.id))); - let n = s.points.len(); - let seg = |a: Vec2, b: Vec2, dash: Option>| line(a, b, "void", SYMBOL_HAIRLINE_MM, Some(dash), EXTRUSION_STROKE, greyed); - for i in 0..n { - out.push(seg(s.points[i], s.points[(i + 1) % n], Some(vec![2.0, 1.0]))); - } - if n == 4 { - out.push(seg(s.points[0], s.points[2], None)); - out.push(seg(s.points[1], s.points[3], None)); - } - } else { - out.push(polygon(s.points.clone(), "none", EXTRUSION_STROKE, SYMBOL_HAIRLINE_MM, no_hatch(), greyed, None, Pick::Solid(&s.id))); - // [G1] Schnittfläche auf Schnitthöhe (Poché); der Umriss darunter bleibt als Projektion. - if zone == super::view_range::Zone::Cut { - if let Some(ring) = body_cut_ring(s, zb, range.cut) { - let (fill, hatch) = if c.solid_cut() { (HATCH_INK, no_hatch()) } else { (super::section::BODY_FILL, super::section::section_hatch()) }; - out.push(polygon(ring, fill, POCHE_STROKE, WALL_FALLBACK_MM, hatch, greyed, None, Pick::Solid(&s.id))); - } + if n == 4 { + out.push(seg(s.points[0], s.points[2], None)); + out.push(seg(s.points[1], s.points[3], None)); + } + } else { + out.push(polygon(s.points.clone(), "none", EXTRUSION_STROKE, SYMBOL_HAIRLINE_MM, no_hatch(), greyed, None, Pick::Solid(&s.id))); + // [G1] Schnittfläche auf Schnitthöhe (Poché); der Umriss darunter bleibt als Projektion. + if zone == super::view_range::Zone::Cut { + if let Some(ring) = body_cut_ring(s, zb, range.cut) { + let (fill, hatch) = if c.solid_cut() { + (HATCH_INK.to_string(), no_hatch()) + } else { + super::style::body_component_style(c.p, s).unwrap_or_else(|| (super::section::BODY_FILL.to_string(), super::section::section_hatch())) + }; + out.push(polygon(ring, &fill, POCHE_STROKE, WALL_FALLBACK_MM, hatch, greyed, None, Pick::Solid(&s.id))); } } - // [152] Über der Schnitthöhe immer als Überkopf-Linie (Träger, Pfetten), auch ohne eigenen Ansichtsbereich. - let dash = if zone == super::view_range::Zone::Above { Some(&super::view_range::ABOVE_DASH[..]) } else { range.restyle_dash(zone) }; - if let Some(d) = dash { - super::view_range::restyle(out, out_start, d); - } + } + // [152] Über der Schnitthöhe immer als Überkopf-Linie (Träger, Pfetten), auch ohne eigenen Ansichtsbereich. + let dash = if zone == super::view_range::Zone::Above { Some(&super::view_range::ABOVE_DASH[..]) } else { range.restyle_dash(zone) }; + if let Some(d) = dash { + super::view_range::restyle(out, out_start, d); } } /// [G1] Schnittfläche eines Körpers (Profil-Extrusion, auch verjüngt) auf der Höhe `cut` (UK `zb`): /// das Profil, linear zum Ecken-Schwerpunkt gestaucht wie die truck-Verjüngung (`extruded_solid_spec`). -/// `None` für B-Rep-Körper (kein Netz im Kern), Abzugskörper, entartete Profile und ausserhalb. +/// Rückfall ohne Kern-Netz; `None` für B-Rep-Körper, Abzugskörper, entartete Profile und ausserhalb. fn body_cut_ring(s: &ExtrudedSolid, zb: f64, cut: f64) -> Option> { let n = s.points.len(); if s.brep.is_some() || s.operation.as_deref() == Some("subtract") || n < 3 || !(s.height > 0.0) || !(cut > zb && cut < zb + s.height) { @@ -2627,11 +2649,12 @@ mod tests { assert!(!w0.contains("view-range")); let r = plan_domains(&p, &args("eg", 1.0, &["20", "30", "60"])).unwrap(); let dashed: Vec<&str> = r.solids.iter().filter_map(|q| match q { - Primitive::Line { cls, dash: Some(Some(d)), .. } if cls == "view-range" && d[..] == super::super::view_range::ABOVE_DASH[..] => Some("x"), + Primitive::Line { cls, dash: Some(Some(d)), .. } if cls == "solid-view" && d[..] == super::super::view_range::ABOVE_DASH[..] => Some("x"), _ => None, }).collect(); assert_eq!(dashed.len(), 4, "{s0}"); - assert!(r.solids.iter().any(|q| matches!(q, Primitive::Polygon { stroke, extruded_solid_id: Some(id), .. } if id == "unten" && stroke != "none")), "Sockel als Aufsicht"); + // [G1] Sockel als Aufsicht (Kern-Netz, durchgezogen; wo er unter der geschnittenen Wand liegt, verdeckt). + assert!(r.solids.iter().any(|q| matches!(q, Primitive::Line { cls, dash: None, .. } if cls == "solid-view")), "Sockel als Aufsicht"); // Oberkante 1.2 m: Schrank (ab 1.4) fällt weg. p.drawing_levels.iter_mut().find(|l| l.id == "eg").unwrap().view_top = Some(1.2); let (_, s1) = walls(&p); @@ -2639,7 +2662,7 @@ mod tests { // Oberkante 2.0 m: Schrank bleibt, gestrichelt „über Schnitt“. p.drawing_levels.iter_mut().find(|l| l.id == "eg").unwrap().view_top = Some(2.0); let (_, s2) = walls(&p); - assert!(s2.contains("\"oben\"") && s2.contains("view-range"), "{s2}"); + assert!(s2.contains("\"oben\"") && s2.contains("[6.0,1.5,0.0,1.5]"), "{s2}"); // Unterkante 0.6 m ohne Tiefe: Sockel (bis 0.5) entfällt; mit Tiefe gepunktet. let l = p.drawing_levels.iter_mut().find(|l| l.id == "eg").unwrap(); l.view_bottom = Some(0.6); @@ -3399,13 +3422,15 @@ mod tests { _ => None, }) .collect(); + let mut poche = poche; + poche.sort_by(|a, b| a.0.cmp(b.0)); let ids: Vec<&str> = poche.iter().map(|q| q.0).collect(); assert_eq!(ids, vec!["block", "pyr"], "{ids:?}"); let area = |pts: &[Vec2]| (pts.iter().enumerate().fold(0.0, |a, (i, q)| { let n = pts[(i + 1) % pts.len()]; a + q.x * n.y - n.x * q.y }) / 2.0).abs(); - assert!((area(&poche[0].1) - 4.0).abs() < 1e-9); + assert!((area(&poche[0].1) - 4.0).abs() < 1e-6); // Pyramide (Spitze bei 2 m): auf Schnitthöhe um (1 − t) gestaucht. let k = 1.0 - (cut - base) / 2.0; - assert!((area(&poche[1].1) - 4.0 * k * k).abs() < 1e-9, "{}", area(&poche[1].1)); + assert!((area(&poche[1].1) - 4.0 * k * k).abs() < 1e-6, "{}", area(&poche[1].1)); assert!(poche.iter().all(|q| q.2 == WALL_FALLBACK_MM)); // Darunter bleibt der Umriss (Projektion) aller vier. let s = serde_json::to_string(&r.solids).unwrap(); @@ -3413,4 +3438,64 @@ mod tests { assert!(s.contains(&format!("\"{id}\"")), "{id}"); } } + + /// [G1] Poché über das Kern-Netz (`solid_mesh`): Eckenradius und Fase, B-Rep mit Loch (Schlüsselloch), + /// Bauteil-Schraffur (`componentId`); ganz unter der Schnitthöhe nur Aufsicht ohne Poché. + #[test] + fn koerper_poche_aus_netz_radius_fase_loch_bauteil() { + let mut p = sample(); + p.drawing_levels.iter_mut().find(|l| l.id == "eg").unwrap().cut_hatch = Some(true); + let comp = p.components.iter().find(|k| p.hatch(&k.hatch_id).is_some_and(|h| h.pattern != HatchPattern::None && h.pattern != HatchPattern::Diagonal && h.pattern != HatchPattern::Solid)).expect("Bauteil mit Schraffur").clone(); + let sq = |x0: f64| vec![Vec2 { x: x0, y: 0.0 }, Vec2 { x: x0 + 2.0, y: 0.0 }, Vec2 { x: x0 + 2.0, y: 2.0 }, Vec2 { x: x0, y: 2.0 }]; + let mk = |id: &str, x0: f64, f: &dyn Fn(&mut ExtrudedSolid)| { + let mut s = ExtrudedSolid { id: id.into(), level_id: "eg".into(), category_code: "20".into(), points: sq(x0), height: 2.0, ..Default::default() }; + f(&mut s); + s + }; + let ring = serde_json::json!({"origin": {"x": 26.0, "y": 0.0}, "spec": {"kind": "extrude", "points": [26, 0, 28, 0, 28, 2, 26, 2], "holes": [[26.5, 0.5, 27.5, 0.5, 27.5, 1.5, 26.5, 1.5]], "height": 2, "z0": 0}}); + p.extruded_solids = Some(vec![ + mk("rund", 20.0, &|s| s.corner_radius = Some(0.5)), + mk("fase", 23.0, &|s| s.chamfer = Some(0.5)), + mk("ring", 26.0, &|s| s.brep = Some(serde_json::from_value(ring.clone()).unwrap())), + mk("mat", 29.0, &|s| s.component_id = Some(comp.id.clone())), + mk("tief", 32.0, &|s| s.height = 0.4), + ]); + let r = plan_domains(&p, &args("eg", 1.0, &["20", "30", "60"])).unwrap(); + let area = |pts: &[Vec2]| (pts.iter().enumerate().fold(0.0, |a, (i, q)| { let n = pts[(i + 1) % pts.len()]; a + q.x * n.y - n.x * q.y }) / 2.0).abs(); + let poche = |id: &str| -> Vec<(f64, String, HatchPattern, bool)> { + r.solids + .iter() + .filter_map(|q| match q { + Primitive::Polygon { pts, fill, hatch, no_stroke_edges, extruded_solid_id: Some(i), .. } if i == id && fill != "none" => Some((area(pts), fill.clone(), hatch.pattern, no_stroke_edges.as_ref().is_some_and(|v| !v.is_empty()))), + _ => None, + }) + .collect() + }; + let pi = std::f64::consts::PI; + let rund = poche("rund"); + assert_eq!(rund.len(), 1); + assert!((rund[0].0 - (4.0 - (4.0 - pi) * 0.25)).abs() < 0.01, "Eckenradius {}", rund[0].0); + let fase = poche("fase"); + assert!((fase[0].0 - 3.5).abs() < 1e-6, "Fase {}", fase[0].0); + let ring = poche("ring"); + assert_eq!(ring.len(), 1, "B-Rep geschnitten"); + assert!((ring[0].0 - 3.0).abs() < 1e-6 && ring[0].3, "Loch als Schlüsselloch: {ring:?}"); + let mat = poche("mat"); + let h = p.hatch(&comp.hatch_id).unwrap(); + assert_eq!(mat[0].2, h.pattern, "Bauteil-Schraffur"); + assert_eq!(mat[0].1, comp.background.clone().unwrap_or_else(|| poche_fill(h.pattern).to_string())); + assert_eq!(rund[0].2, HatchPattern::Diagonal, "ohne Bauteil Rückfall-Schraffur"); + assert!(poche("tief").is_empty(), "unter der Schnitthöhe keine Poché"); + // Aufsicht des niedrigen Körpers: Umriss als durchgezogene Ansichtslinien (Länge 8). + let len: f64 = r.solids.iter().filter_map(|q| match q { + Primitive::Line { a, b, cls, dash: None, .. } if cls == "solid-view" && a.x >= 32.0 - 1e-9 && b.x >= 32.0 - 1e-9 => Some(crate::jsmath::hypot2(b.x - a.x, b.y - a.y)), + _ => None, + }).sum(); + assert!((len - 8.0).abs() < 1e-6, "Aufsicht {len}"); + // Ab 1:100 schwarz (auch mit Bauteil). + p.drawing_levels.iter_mut().find(|l| l.id == "eg").unwrap().cut_hatch = None; + let t = serde_json::json!({ "floor": "eg", "show": ["20", "30", "60"], "grey": [], "scale": 100 }).to_string(); + let r = plan_domains(&p, &PlanArgs::parse(1.0, &t).unwrap()).unwrap(); + assert!(r.solids.iter().any(|q| matches!(q, Primitive::Polygon { fill, extruded_solid_id: Some(i), .. } if i == "mat" && fill == HATCH_INK))); + } } diff --git a/src-tauri/core/src/plan/extras.rs b/src-tauri/core/src/plan/extras.rs index bf3729ee..62d4d340 100644 --- a/src-tauri/core/src/plan/extras.rs +++ b/src-tauri/core/src/plan/extras.rs @@ -256,6 +256,97 @@ fn encode_rings(rings: &[&[Vec2]]) -> Vec { b } +/// Schneider-Polygon (erster Ring aussen, weitere Löcher). +type CutPoly = Vec>; + +/// [G1] Abzugskörper beliebiger Form (kein senkrechtes Prisma, s. [`void_prisms`]): Kern-Netz +/// (`solid_mesh::body_mesh`) und Höhenbereich. +pub(crate) struct VoidMesh { + pub(crate) mesh: std::rc::Rc>, + pub(crate) z0: f64, + pub(crate) z1: f64, +} + +pub(crate) fn void_meshes(p: &Project) -> Vec { + let mut out = Vec::new(); + for s in p.extruded_solids.as_deref().unwrap_or(&[]) { + let prism = s.brep.is_none() && s.taper.unwrap_or(0.0) < 1e-6 && s.points.len() >= 3 && s.height > 0.0; + if s.operation.as_deref() != Some("subtract") || prism { + continue; + } + let Some(mesh) = crate::solid_mesh::body_mesh(p, s) else { continue }; + let Some((lo, hi)) = mesh.as_ref().as_ref().and_then(|m| m.bounds()) else { continue }; + out.push(VoidMesh { mesh: mesh.clone(), z0: lo[2], z1: hi[2] }); + } + out +} + +/// Ringliste flach (`encode_rings`), solange kein Schneider Löcher hat (sonst `None`: Polygon-Weg). +fn flat_rings(polys: &[CutPoly]) -> Option> { + if polys.iter().any(|p| p.len() != 1) { + return None; + } + let mut b = vec![polys.len() as f64]; + for r in polys.iter().map(|p| &p[0]) { + b.push(r.len() as f64); + for q in r { + b.extend([q[0], q[1]]); + } + } + Some(b) +} + +/// [G1] Waagrechter Ebenenschnitt eines Netzes auf Höhe `z` als Polygone mit Löchern. +fn mesh_level_polys(mesh: &Option, z: f64) -> Vec { + let Some(m) = mesh else { return Vec::new() }; + let idx: Vec = m.indices.iter().map(|&i| i as f64).collect(); + let f = crate::mesh_section::cut(&m.positions, &idx, &[1.0, z]); + let Some(&n) = f.first() else { return Vec::new() }; + let mut rings = Vec::new(); + let mut i = 1; + for _ in 0..n as usize { + let k = f[i] as usize; + i += 1; + rings.push((0..k).map(|j| [f[i + 2 * j], f[i + 2 * j + 1]]).collect::>()); + i += 2 * k; + } + super::section::rings_to_polygons(&rings) +} + +/// [G1] Grundriss eines Netzes im Höhenbereich `z0..z1`: der Körper wird auf das Band beschnitten +/// (Manifold), dann die nach oben weisenden Dreiecke projiziert und vereinigt (i_overlay). +fn mesh_footprint(mesh: &Option, z0: f64, z1: f64) -> Vec { + use crate::solid_bool::{Mesh, Solid}; + let Some(m) = mesh else { return Vec::new() }; + let Some((lo, hi)) = m.bounds() else { return Vec::new() }; + let clipped; + let m = if z0 <= lo[2] + EPS && z1 >= hi[2] - EPS { + m + } else { + let (a, b) = (z0.max(lo[2] - 1.0), z1.min(hi[2] + 1.0)); + if !(b > a + EPS) { + return Vec::new(); + } + let r = [[lo[0] - 1.0, lo[1] - 1.0], [hi[0] + 1.0, lo[1] - 1.0], [hi[0] + 1.0, hi[1] + 1.0], [lo[0] - 1.0, hi[1] + 1.0]]; + let Some(c) = Solid::new(m).ok().and_then(|s| Solid::new(&Mesh::prism(&r, a, b)).ok().and_then(|band| s.intersection(&band).ok())) else { return Vec::new() }; + clipped = c.to_mesh(); + &clipped + }; + let p = |i: u32| { + let j = 3 * i as usize; + [m.positions[j], m.positions[j + 1]] + }; + let mut tris: Vec = Vec::new(); + for t in m.indices.chunks_exact(3) { + let (a, b, c) = (p(t[0]), p(t[1]), p(t[2])); + let cross = (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); + if cross > 1e-12 { + tris.push(vec![vec![a, b, c]]); + } + } + crate::polygon_bool::union(&tris) +} + /// Linien-Klassen der Wand-Poché, die ein Abzugskörper auf Schnitthöhe unterbricht. const WALL_LINE_CLS: [&str; 3] = ["wall-outline", "layer-joint", "layer-joint-l"]; @@ -265,15 +356,28 @@ const WALL_LINE_CLS: [&str; 3] = ["wall-outline", "layer-joint", "layer-joint-l" /// Abzugskörper unverändert. Gleiche Rechnung wie der frühere Weg über die flachen Bindungen. pub fn subtract_voids(prims: Vec, p: &Project, cut_z: f64) -> Vec { let voids = void_prisms(p); - if voids.is_empty() { + let shaped = void_meshes(p); + if voids.is_empty() && shaped.is_empty() { return prims; } // Maps wie in TS: bei doppelter id gewinnt der letzte Eintrag. let ceilings: HashMap<&str, &Ceiling> = p.ceilings.as_deref().unwrap_or(&[]).iter().map(|c| (c.id.as_str(), c)).collect(); let columns: HashMap<&str, &Column> = p.columns.as_deref().unwrap_or(&[]).iter().map(|c| (c.id.as_str(), c)).collect(); - let cutters_for = |z0: f64, z1: f64| -> Vec<&[Vec2]> { voids.iter().filter(|v| v.z0 < z1 - EPS && v.z1 > z0 + EPS).map(|v| v.pts.as_slice()).collect() }; - let wall_cutters = cutters_for(cut_z - 1e-4, cut_z + 1e-4); - let wall_flat = encode_rings(&wall_cutters); + let ring_of = |pts: &[Vec2]| -> Vec<[f64; 2]> { pts.iter().map(|q| [q.x, q.y]).collect() }; + // [G1] Abzugskörper beliebiger Form: Grundriss des Körpers im Höhenbereich des Bauteils. + let cutters_for = |z0: f64, z1: f64| -> Vec { + let mut c: Vec = voids.iter().filter(|v| v.z0 < z1 - EPS && v.z1 > z0 + EPS).map(|v| vec![ring_of(&v.pts)]).collect(); + for v in shaped.iter().filter(|v| v.z0 < z1 - EPS && v.z1 > z0 + EPS) { + c.extend(mesh_footprint(&v.mesh, z0, z1)); + } + c + }; + // Wände: Prismen wie bisher über ihr Profil, Körper beliebiger Form über ihren Ebenenschnitt auf Schnitthöhe. + let mut wall_cutters: Vec = voids.iter().filter(|v| v.z0 < cut_z + 1e-4 - EPS && v.z1 > cut_z - 1e-4 + EPS).map(|v| vec![ring_of(&v.pts)]).collect(); + for v in shaped.iter().filter(|v| v.z0 < cut_z && v.z1 > cut_z) { + wall_cutters.extend(mesh_level_polys(&v.mesh, cut_z)); + } + let wall_flat = flat_rings(&wall_cutters); // [159] Nichts zu tun (z. B. Kontext mit zehntausenden Höhenlinien): die Liste unverändert, ohne Umkopieren. let nonempty = |s: &Option| s.as_deref().is_some_and(|s| !s.is_empty()); let touched = |q: &Primitive| match q { @@ -288,9 +392,15 @@ pub fn subtract_voids(prims: Vec, p: &Project, cut_z: f64) -> Vec = (0..n).map(|k| (f[1 + 2 * k], f[2 + 2 * k])).collect(); + let parts: Vec<(f64, f64)> = match &wall_flat { + Some(flat) => { + let f = crate::voids::segment_outside_flat(&[a.x, a.y, b.x, b.y], flat); + let n = f.first().copied().unwrap_or(0.0) as usize; + (0..n).map(|k| (f[1 + 2 * k], f[2 + 2 * k])).collect() + } + None if [a.x, a.y, b.x, b.y].iter().all(|v| v.is_finite()) => crate::voids::segment_outside_polys([a.x, a.y], [b.x, b.y], &wall_cutters), + None => Vec::new(), + }; if parts.len() == 1 && parts[0].0 == 0.0 && parts[0].1 == 1.0 { out.push(pr); } else { @@ -319,7 +429,7 @@ pub fn subtract_voids(prims: Vec, p: &Project, cut_z: f64) -> Vec> = if wall_id.is_some() { + let cutters: Option> = if wall_id.is_some() { Some(wall_cutters.clone()) } else if let Some(id) = &ceiling_id { ceilings.get(id.as_str()).map(|c| { @@ -349,15 +459,33 @@ pub fn subtract_voids(prims: Vec, p: &Project, cut_z: f64) -> Vec = ns.iter().filter(|v| v.is_finite() && **v >= 0.0).map(|v| *v as usize).collect(); + match crate::voids::subtract_polys(&ring_of(pts), &cutters, &ns) { + None => out.push(pr), + Some(pieces) => { + for pc in pieces { + let mut q = pr.clone(); + if let Primitive::Polygon { pts, no_stroke_edges, .. } = &mut q { + *pts = pc.pts.iter().map(|q| Vec2 { x: q[0], y: q[1] }).collect(); + *no_stroke_edges = (!pc.no_stroke.is_empty()).then(|| pc.no_stroke.iter().map(|&i| i as f64).collect()); + } + out.push(q); + } + } + } + continue; + }; + let ring = encode_rings(&[pts]); let mut nsf = vec![ns.len() as f64]; nsf.extend_from_slice(ns); - let f = crate::voids::subtract_rings_flat(&ring[1..], &encode_rings(&cutters), &nsf); + let f = crate::voids::subtract_rings_flat(&ring[1..], &cutters_flat, &nsf); if f.is_empty() || f[0] < 0.0 { out.push(pr); continue; @@ -824,6 +952,74 @@ mod tests { assert!(after.len() > before.len(), "{} → {}", before.len(), after.len()); } + /// [G1] Abzugskörper beliebiger Form im Grundriss: Zylinder (B-Rep) spart Wand-Poché und Wandlinie über + /// seinen Ebenenschnitt auf Schnitthöhe aus; ein Ring-Körper (Loch) lässt den Kern der Wand stehen; eine + /// Kugel an der Decke spart deren Grundriss im Plattenband aus. + #[test] + fn abzugskoerper_beliebiger_form_im_grundriss() { + let v2 = |x: f64, y: f64| Vec2 { x, y }; + let poly = |pts: Vec, wall: bool| { + let mut q = flat_polygon(pts, "#000", 1.0); + if let Primitive::Polygon { wall_id, ceiling_id, .. } = &mut q { + if wall { + *wall_id = Some("w".into()); + } else { + *ceiling_id = Some("d".into()); + } + } + q + }; + let wall = poly(vec![v2(0.0, -0.1), v2(4.0, -0.1), v2(4.0, 0.1), v2(0.0, 0.1)], true); + let outline = super::super::domains::line(v2(0.0, 0.1), v2(4.0, 0.1), "wall-outline", 0.35, None, "#000", None); + let deck = poly(vec![v2(0.0, -2.0), v2(4.0, -2.0), v2(4.0, 2.0), v2(0.0, 2.0)], false); + let project = |spec: serde_json::Value| -> Project { + serde_json::from_value(serde_json::json!({ + "drawingLevels": [{"id": "eg", "name": "EG", "kind": "floor", "baseElevation": 0, "floorHeight": 3, "cutHeight": 1, "visible": true}], + "ceilings": [{"id": "d", "type": "ceiling", "floorId": "eg", "categoryCode": "30", "outline": [{"x": 0, "y": -2}, {"x": 4, "y": -2}, {"x": 4, "y": 2}, {"x": 0, "y": 2}]}], + "extrudedSolids": [{"id": "v", "type": "extrudedSolid", "levelId": "eg", "categoryCode": "20", "operation": "subtract", "height": 2, + "points": [{"x": 0, "y": 0}, {"x": 1, "y": 0}, {"x": 1, "y": 1}], "brep": {"origin": {"x": 0, "y": 0}, "spec": spec}}] + })) + .unwrap() + }; + let area = |prims: &[Primitive], wall: bool| -> f64 { + prims.iter().filter_map(|q| match q { + Primitive::Polygon { pts, wall_id, .. } if wall_id.is_some() == wall => { + let n = pts.len(); + Some(((0..n).map(|k| pts[k].x * pts[(k + 1) % n].y - pts[(k + 1) % n].x * pts[k].y).sum::() / 2.0).abs()) + } + _ => None, + }).sum() + }; + let line_len = |prims: &[Primitive]| -> (usize, f64) { + let l: Vec = prims.iter().filter_map(|q| match q { Primitive::Line { a, b, .. } => Some(b.x - a.x), _ => None }).collect(); + (l.len(), l.iter().sum()) + }; + // Zylinder r = 0.3 um (2, 0): Kreis ∩ Wandstreifen (|y| ≤ 0.1) fehlt. + let p = project(serde_json::json!({"kind": "cylinder", "cx": 2, "cy": 0, "z0": 0, "r": 0.3, "height": 2})); + let out = subtract_voids(vec![wall.clone(), outline.clone()], &p, 1.0); + let n = 2000; + let lens: f64 = (0..n).map(|k| { let y = -0.1 + 0.2 * (k as f64 + 0.5) / n as f64; 2.0 * (0.09 - y * y).sqrt() * 0.2 / n as f64 }).sum(); + assert!((area(&out, true) - (0.8 - lens)).abs() < 2e-3, "{} ≠ {}", area(&out, true), 0.8 - lens); + let (k, len) = line_len(&out); + assert_eq!(k, 2, "Wandlinie unterbrochen"); + assert!((len - (4.0 - 2.0 * 0.08f64.sqrt())).abs() < 5e-3, "{len}"); + // Ring-Körper 1.6 × 1.6 mit Loch 0.6 × 0.6: der Wandkern im Loch bleibt. + let p = project(serde_json::json!({"kind": "extrude", "points": [1.2, -0.8, 2.8, -0.8, 2.8, 0.8, 1.2, 0.8], "holes": [[1.7, -0.3, 2.3, -0.3, 2.3, 0.3, 1.7, 0.3]], "height": 2, "z0": 0})); + let out = subtract_voids(vec![wall.clone(), outline.clone()], &p, 1.0); + assert!((area(&out, true) - 0.2 * 3.0).abs() < 1e-6, "{}", area(&out, true)); + assert_eq!(out.iter().filter(|q| matches!(q, Primitive::Polygon { .. })).count(), 3); + let (k, len) = line_len(&out); + assert_eq!(k, 3); + assert!((len - 3.0).abs() < 1e-6, "{len}"); + // Kugel r = 0.5 um (2, 0, 3) an der Decke (Platte am Geschoss-Oberrand): Kreis aus der Decke; die + // Wand (Schnitthöhe 1) bleibt. + let p = project(serde_json::json!({"kind": "sphere", "center": [2, 0, 3], "r": 0.5})); + let out = subtract_voids(vec![wall, outline, deck], &p, 1.0); + let pi = std::f64::consts::PI; + assert!((area(&out, false) - (16.0 - pi * 0.25)).abs() < 0.01, "{}", area(&out, false)); + assert!((area(&out, true) - 0.8).abs() < 1e-9); + } + #[test] fn erdgeschoss_naechst_null() { let p = sample(); diff --git a/src-tauri/core/src/plan/mesh_plan.rs b/src-tauri/core/src/plan/mesh_plan.rs index 9734832d..a6588f8e 100644 --- a/src-tauri/core/src/plan/mesh_plan.rs +++ b/src-tauri/core/src/plan/mesh_plan.rs @@ -172,35 +172,103 @@ fn component_occluders(c: &Ctx, range: &ViewRange, out: &mut Vec { + m: MeshRef<'a>, + zone: Zone, + ov: Option, + greyed: bool, + /// Freier Körper: Pick über `extrudedSolidId`, Poché aus seinem Bauteil. + solid: Option<&'a ExtrudedSolid>, +} + /// Importierte Netze des Geschosses in `out`; `false`, wenn die Ebene kein Geschoss ist (dann zeichnet /// `context.rs` den Fussabdruck wie bisher). pub fn plan_meshes(c: &Ctx, out: &mut Vec) -> bool { let Some(l) = c.p.floor(&c.a.floor).filter(|l| l.kind == DrawingLevelKind::Floor) else { return false }; let range = ViewRange::of(c.p, &c.a.floor); let band = floor_band(c.p, l, &range); - let cut = range.cut; - let meshes: Vec<(MeshRef, Zone)> = mesh_view::meshes(c.p) + let items: Vec = mesh_view::meshes(c.p) .into_iter() .filter(|m| c.shown(&m.mesh.category_code) && !c.rule_hidden(&m.mesh.id)) .filter_map(|m| { - let z = zone_of(&range, band, m.info.bbox[2], m.info.bbox[5])?; - Some((m, z)) + let zone = zone_of(&range, band, m.info.bbox[2], m.info.bbox[5])?; + let (ov, greyed) = (mesh_ov(c, m.mesh), c.greyed(&m.mesh.category_code)); + Some(Item { m, zone, ov, greyed, solid: None }) }) .collect(); - if meshes.is_empty() { + if items.is_empty() { return true; } + draw_items(c, &range, &items, out); + // Pick-Flächen (Hüllbox) zuletzt: Klick wählt das Netz. + for it in &items { + let b = &it.m.info.bbox; + let pts = vec![Vec2 { x: b[0], y: b[1] }, Vec2 { x: b[3], y: b[1] }, Vec2 { x: b[3], y: b[4] }, Vec2 { x: b[0], y: b[4] }]; + out.push(super::context::pick_band(pts, Some(&it.m.mesh.id), None)); + } + true +} + +/// [G1] Freie Körper des Geschosses über ihr Kern-Netz (`solid_mesh::body_mesh`), wie importierte Netze: +/// geschnitten ⇒ Ebenenschnitt als Poché (mit Eckenradius/Fase, Löchern, Verjüngung, B-Rep-Grundkörpern; +/// Füllung/SIA-Schraffur aus `componentId`, ab 1:100 schwarz) und der Teil darunter als Aufsicht; ganz +/// darunter Aufsicht, darüber Überkopf-Linien (gestrichelt). Liefert die Körper ohne baubares Netz zurück +/// (der Aufrufer zeichnet sie wie bisher über ihr Profil). +pub fn plan_bodies<'a>(c: &Ctx, solids: &[&'a ExtrudedSolid], out: &mut Vec) -> Vec<&'a ExtrudedSolid> { + let range = ViewRange::of(c.p, &c.a.floor); + let mut rest = Vec::new(); + let mut owned: Vec<(&ExtrudedSolid, ImportedMesh)> = Vec::new(); + for s in solids { + match crate::solid_mesh::body_mesh(c.p, s).and_then(|m| (*m).clone()) { + Some(m) => { + let indices = m.indices.iter().map(|&i| i as f64).collect(); + owned.push((s, ImportedMesh { id: s.id.clone(), name: s.id.clone(), category_code: s.category_code.clone(), positions: m.positions, indices, ..Default::default() })); + } + None => rest.push(*s), + } + } + let mut items: Vec = Vec::new(); + for (k, (s, im)) in owned.iter().enumerate() { + let Some(info) = mesh_view::info(im) else { + rest.push(*s); + continue; + }; + let zone = range.classify(info.bbox[2], info.bbox[5]); + if zone == Zone::Hidden { + continue; + } + items.push(Item { m: MeshRef { index: k, mesh: im, info }, zone, ov: None, greyed: c.greyed(&s.category_code), solid: Some(s) }); + } + // Pick-Fläche (Grundriss-Profil, sonst Hüllbox) zuerst, darüber Linien und Poché. + for it in &items { + let Some(s) = it.solid else { continue }; + let pts = if s.points.len() >= 3 { + s.points.clone() + } else { + let b = &it.m.info.bbox; + vec![Vec2 { x: b[0], y: b[1] }, Vec2 { x: b[3], y: b[1] }, Vec2 { x: b[3], y: b[4] }, Vec2 { x: b[0], y: b[4] }] + }; + out.push(super::domains::polygon(pts, "none", "none", 0.0, no_hatch(), Some(it.greyed), None, super::domains::Pick::Solid(&s.id))); + } + if !items.is_empty() { + draw_items(c, &range, &items, out); + } + rest +} + +/// Schnittflächen, Aufsicht und Überkopf-Linien einer Netz-Gruppe (gegenseitig und durch die Bauteile verdeckt). +fn draw_items(c: &Ctx, range: &ViewRange, items: &[Item], out: &mut Vec) { + let cut = range.cut; let (solid_fill, solid_hatch) = if c.solid_cut() { (HATCH_INK.to_string(), no_hatch()) } else { (super::section::BODY_FILL.to_string(), super::section::section_hatch()) }; - let ovs: Vec> = meshes.iter().map(|(m, _)| mesh_ov(c, m.mesh)).collect(); - let greyed = |m: &MeshRef| c.greyed(&m.mesh.category_code); // Schnittflächen (und Verdecker der Aufsicht in Tiefe 0). let mut below: Vec = Vec::new(); let mut cut_prims: Vec = Vec::new(); - for (k, (m, z)) in meshes.iter().enumerate() { - if *z != Zone::Cut { - continue; - } - let ov = ovs[k].as_ref(); + for it in items.iter().filter(|it| it.zone == Zone::Cut) { + let (m, ov) = (&it.m, it.ov.as_ref()); + // [G1] Körper mit Bauteil: dessen Füllung und Schraffur (ausser schwarz ab 1:100). + let comp = it.solid.filter(|_| !c.solid_cut()).and_then(|s| super::style::body_component_style(c.p, s)); let (rings, open) = mesh_view::cut(m, &[1.0, cut]); for poly in super::section::rings_to_polygons(&rings) { let mut f = crate::hlr::Face::new(poly[0].iter().map(|q| [q[0], q[1], 0.0]).collect(), [0.0, 0.0, -1.0], u32::MAX); @@ -217,21 +285,26 @@ pub fn plan_meshes(c: &Ctx, out: &mut Vec) -> bool { if pts.len() < 3 { continue; } - let fill = ov.and_then(|o| o.fill.clone()).unwrap_or_else(|| solid_fill.clone()); - let hatch = ov.and_then(|o| o.hatch.clone()).map_or_else(|| solid_hatch.clone(), |h| h.unwrap_or_else(no_hatch)); + let (fill, hatch) = match &comp { + Some((f, h)) => (f.clone(), h.clone()), + None => (ov.and_then(|o| o.fill.clone()).unwrap_or_else(|| solid_fill.clone()), ov.and_then(|o| o.hatch.clone()).map_or_else(|| solid_hatch.clone(), |h| h.unwrap_or_else(no_hatch))), + }; let mut q = super::section::polygon(pts.iter().map(|q| Vec2 { x: q[0], y: q[1] }).collect(), &fill, POCHE_STROKE, WALL_FALLBACK_MM, hatch); - if let Primitive::Polygon { context_object_id, no_stroke_edges, greyed: g, .. } = &mut q { - *context_object_id = Some(m.mesh.id.clone()); + if let Primitive::Polygon { context_object_id, extruded_solid_id, no_stroke_edges, greyed: g, .. } = &mut q { + match it.solid { + Some(s) => *extruded_solid_id = Some(s.id.clone()), + None => *context_object_id = Some(m.mesh.id.clone()), + } *no_stroke_edges = nse; - *g = Some(greyed(m)); + *g = Some(it.greyed); } cut_prims.push(q); } for l in open { for w in l.windows(2) { - let mut q = view_line(w[0], w[1], None, greyed(m), ov); + let mut q = view_line(w[0], w[1], None, it.greyed, ov); if let Primitive::Line { cls, weight_mm, .. } = &mut q { - *cls = "mesh-cut".into(); + *cls = if it.solid.is_some() { "solid-cut" } else { "mesh-cut" }.into(); if ov.and_then(|o| o.weight).is_none() { *weight_mm = WALL_FALLBACK_MM; } @@ -241,13 +314,13 @@ pub fn plan_meshes(c: &Ctx, out: &mut Vec) -> bool { } } // Bauteile verdecken die Aufsicht: geschnitten in Tiefe 0 (Poché), darunter in Höhe ihrer Oberkante. - component_occluders(c, &range, &mut below); + component_occluders(c, range, &mut below); // Aufsicht von oben (Tiefe = Schnitthöhe − z, nur unter der Schnittebene) und Überkopf von unten. let mut above: Vec = Vec::new(); - for (k, (m, z)) in meshes.iter().enumerate() { - match z { - Zone::Above => mesh_view::hlr_faces(m, &|q| [q[0], q[1], q[2] - cut], k as u32, k as u32 + 1, false, &mut above), - _ => mesh_view::hlr_faces(m, &|q| [q[0], q[1], cut - q[2]], k as u32, k as u32 + 1, true, &mut below), + for (k, it) in items.iter().enumerate() { + match it.zone { + Zone::Above => mesh_view::hlr_faces(&it.m, &|q| [q[0], q[1], q[2] - cut], k as u32, k as u32 + 1, false, &mut above), + _ => mesh_view::hlr_faces(&it.m, &|q| [q[0], q[1], cut - q[2]], k as u32, k as u32 + 1, true, &mut below), } } let opts = crate::hlr::Opts { tol: 1e-4, depth_eps: 1e-4, hidden: false, ..crate::hlr::Opts::default() }; @@ -257,27 +330,24 @@ pub fn plan_meshes(c: &Ctx, out: &mut Vec) -> bool { continue; } for s in crate::hlr::hidden_lines(faces, &opts) { - let Some((m, z)) = meshes.get(s.owner as usize) else { continue }; + let Some(it) = items.get(s.owner as usize) else { continue }; if s.hidden { continue; } - let dash: Option<&[f64]> = match z { + let dash: Option<&[f64]> = match it.zone { Zone::Above => Some(&ABOVE_DASH), Zone::Under => Some(&UNDER_DASH), _ => None, }; - lines.push(view_line(s.a, s.b, dash, greyed(m), ovs[s.owner as usize].as_ref())); + let mut q = view_line(s.a, s.b, dash, it.greyed, it.ov.as_ref()); + if let (Primitive::Line { cls, .. }, Some(_)) = (&mut q, it.solid) { + *cls = "solid-view".into(); + } + lines.push(q); } } out.extend(lines); out.extend(cut_prims); - // Pick-Flächen (Hüllbox) zuletzt: Klick wählt das Netz. - for (m, _) in &meshes { - let b = &m.info.bbox; - let pts = vec![Vec2 { x: b[0], y: b[1] }, Vec2 { x: b[3], y: b[1] }, Vec2 { x: b[3], y: b[4] }, Vec2 { x: b[0], y: b[4] }]; - out.push(super::context::pick_band(pts, Some(&m.mesh.id), None)); - } - true } #[cfg(test)] diff --git a/src-tauri/core/src/plan/section/meshes.rs b/src-tauri/core/src/plan/section/meshes.rs index 026e7766..cd0b9407 100644 --- a/src-tauri/core/src/plan/section/meshes.rs +++ b/src-tauri/core/src/plan/section/meshes.rs @@ -55,6 +55,8 @@ pub(crate) fn keyhole(poly: &[Vec<[f64; 2]>]) -> (Vec<[f64; 2]>, Vec) { pub(super) fn append_body_sections(cuts: &mut Vec, p: &Project, bodies: &[&BodyMesh], base: (f64, f64), u: (f64, f64)) { let solids = p.extruded_solids.as_deref().unwrap_or(&[]); for b in bodies { + // [G1] Bauteil des Körpers: Füllung und SIA-Schraffur wie im Grundriss. + let style = solids.get(b.index).and_then(|s| crate::plan::style::body_component_style(p, s).map(|st| (st, s.component_id.clone()))); let (rings, _) = cut_mesh(&b.positions, &b.indices, base, u); for poly in rings_to_polygons(&rings) { let (pts, nse) = if poly.len() > 1 { @@ -66,6 +68,11 @@ pub(super) fn append_body_sections(cuts: &mut Vec, p: &Project, bodies: &[& }; let mut c = Cut::new(Kind::Body, b.index, pts); c.fill = Some(BODY_FILL.into()); + if let Some(((fill, hatch), comp)) = &style { + c.fill = Some(fill.clone()); + c.hatch = Some(hatch.clone()); + c.component_id = comp.clone(); + } c.nse = nse; c.source_id = solids.get(b.index).map(|s| s.id.clone()); // [180] Klasse des Körpers (Sichtbarkeit, Darstellungsmodus). diff --git a/src-tauri/core/src/plan/section/tests.rs b/src-tauri/core/src/plan/section/tests.rs index b345b5f8..a5a16619 100644 --- a/src-tauri/core/src/plan/section/tests.rs +++ b/src-tauri/core/src/plan/section/tests.rs @@ -113,6 +113,28 @@ fn abzugskoerper_beliebiger_form_im_schnitt() { assert!(!out.visible.iter().chain(&out.hidden).any(|e| apex(e.a) || apex(e.b))); } +/// [G1] Freier Körper mit Bauteil (`componentId`): seine Schnittfläche trägt Füllung und Schraffur des +/// Bauteils (SIA), ohne Bauteil die neutrale Körper-Füllung. +#[test] +fn koerper_mit_bauteil_im_schnitt() { + let mut p = sample(); + let comp = p.components.iter().find(|k| p.hatch(&k.hatch_id).is_some_and(|h| h.pattern != HatchPattern::None && h.pattern != HatchPattern::Solid)).unwrap().clone(); + let sq = vec![Vec2 { x: 20.0, y: 0.0 }, Vec2 { x: 22.0, y: 0.0 }, Vec2 { x: 22.0, y: 2.0 }, Vec2 { x: 20.0, y: 2.0 }]; + p.extruded_solids = Some(vec![ExtrudedSolid { id: "k".into(), level_id: "eg".into(), category_code: "20".into(), points: sq, height: 1.0, ..Default::default() }]); + let l = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: 19.0, y: 1.0 }, Vec2 { x: 23.0, y: 1.0 }]), ..Default::default() }; + let body = |p: &Project| { + let out = compute_section(p, &l, &crate::solid_mesh::body_meshes(p)).unwrap().unwrap(); + out.cuts.into_iter().find(|c| c.kind == Kind::Body).expect("Körper geschnitten") + }; + let c = body(&p); + assert_eq!(c.fill.as_deref(), Some(BODY_FILL)); + assert!(c.hatch.is_none() && c.component_id.is_none()); + p.extruded_solids.as_mut().unwrap()[0].component_id = Some(comp.id.clone()); + let c = body(&p); + assert_eq!(c.hatch.as_ref().map(|h| h.pattern), p.hatch(&comp.hatch_id).map(|h| h.pattern)); + assert_eq!(c.component_id.as_deref(), Some(comp.id.as_str())); +} + /// [157] Wangentreppe hinter der Schnittebene (von vorn gesehen): neben den Tritten die Wangen (Ansichtskante /// aussen an der Treppe, bis zur Austrittshöhe) und der Handlauf beidseitig — vorher schwebten die Tritte /// als „graue Streifen“ ohne Wange und Geländer. diff --git a/src-tauri/core/src/plan/style.rs b/src-tauri/core/src/plan/style.rs index 6073ec82..99430887 100644 --- a/src-tauri/core/src/plan/style.rs +++ b/src-tauri/core/src/plan/style.rs @@ -130,6 +130,16 @@ pub fn poche_fill(p: HatchPattern) -> &'static str { } } +/// [G1] Füllung und Schraffur der Schnittfläche eines freien Körpers aus seinem Bauteil (`componentId`): +/// Bauteil-Schraffur (SIA) mit Vorder-/Hintergrund des Bauteils, Füllung wie die Stützen-Poché. +/// `None` ohne (auflösbares) Bauteil — dann die neutrale Körper-Füllung mit Rückfall-Schraffur. +pub fn body_component_style(p: &Project, s: &ExtrudedSolid) -> Option<(String, HatchRender)> { + let k = s.component_id.as_deref().filter(|id| !id.is_empty()).and_then(|id| p.component(id))?; + let h = resolve_hatch(p, &k.hatch_id, None, k.foreground.as_deref(), None)?; + let fill = k.background.as_deref().unwrap_or(poche_fill(h.pattern)).to_string(); + Some((fill, h)) +} + /// [141] Drehung einer wandbezogenen Schraffur. Kreuzschraffur und Diagonale unter 45° zur Achse sehen /// um 90° gedreht gleichwertig aus (45° zur Achse bleibt 45° zur Achse); sie drehen nur um den Rest der /// Wandrichtung modulo 90° mit — so laufen sie an rechtwinkligen Ecken, T- und Kreuzstössen (und zwischen diff --git a/src-tauri/core/src/selection_info.rs b/src-tauri/core/src/selection_info.rs index fd8a6070..1d4341a5 100644 --- a/src-tauri/core/src/selection_info.rs +++ b/src-tauri/core/src/selection_info.rs @@ -1031,6 +1031,8 @@ fn solid_selection(root: &Map, s: &Value) -> J { .v("subtract", Value::Bool(subtract)) .v("canSubtract", Value::Bool(brep.is_none() && taper < 1e-6)) .n("baseOffset", num_or(field(s, "baseOffset"), 0.0)) + // [G1] Bauteil der Schnittfläche (leer = neutrale Körper-Füllung). + .s("componentId", str_of(field(s, "componentId")).unwrap_or("")) .raw("floorId", s, "levelId") .o("floorName", floor_name(floor, field(s, "levelId"))) .done(); diff --git a/src-tauri/core/src/solid_mesh.rs b/src-tauri/core/src/solid_mesh.rs index 4717da3b..62ebd7e0 100644 --- a/src-tauri/core/src/solid_mesh.rs +++ b/src-tauri/core/src/solid_mesh.rs @@ -553,4 +553,22 @@ mod tests { let zs: Vec = b[0].positions.chunks_exact(3).map(|q| q[2]).collect(); assert!(zs.iter().all(|z| (*z - 3.0).abs() < 1e-9 || (*z - 5.0).abs() < 1e-9), "{zs:?}"); } + + /// [G1] Kreis-Körper ohne Profil-Punkte (Brunnen im Musterhaus komplex) bekommen ein Netz (Zylinder). + #[test] + fn kreis_koerper_ohne_punkte() { + let p: Project = serde_json::from_value(json!({ + "drawingLevels": [{"id": "ug", "name": "UG", "kind": "floor", "baseElevation": -3, "visible": true}], + "extrudedSolids": [{"id": "b", "type": "extrudedSolid", "levelId": "ug", "categoryCode": "20", "points": [], "circle": {"center": {"x": 4.5, "y": -6.5}, "r": 0.7}, "height": 0.6, "baseOffset": -0.1}] + })) + .unwrap(); + let b = body_meshes(&p); + assert_eq!(b.len(), 1); + let m = Mesh { positions: b[0].positions.clone(), indices: b[0].indices.iter().map(|&i| i as u32).collect() }; + let v = m.volume(); + let exact = std::f64::consts::PI * 0.49 * 0.6; + assert!((v - exact).abs() < 0.02 * exact, "{v}"); + let (lo, hi) = m.bounds().unwrap(); + assert!((lo[2] + 3.1).abs() < 1e-9 && (hi[2] + 2.5).abs() < 1e-9); + } } diff --git a/src-tauri/core/src/voids.rs b/src-tauri/core/src/voids.rs index 27fb260a..c843cfe0 100644 --- a/src-tauri/core/src/voids.rs +++ b/src-tauri/core/src/voids.rs @@ -108,11 +108,18 @@ pub struct Piece { /// `None` = keine Überschneidung (Original unverändert lassen). pub fn subtract_rings(pts: &[Pair], cutters: &[Vec], no_stroke: &[usize]) -> Option> { - if pts.len() < 3 || cutters.is_empty() { + let clips: Vec>> = cutters.iter().map(|c| vec![c.clone()]).collect(); + subtract_polys(pts, &clips, no_stroke) +} + +/// Wie [`subtract_rings`], Schneider als Polygone mit Löchern (erster Ring aussen; [G1] Ebenenschnitt bzw. +/// Grundriss eines Abzugskörpers beliebiger Form). Unendliche Koordinaten ⇒ `None`. +pub fn subtract_polys(pts: &[Pair], cutters: &[Vec>], no_stroke: &[usize]) -> Option> { + if pts.len() < 3 || cutters.is_empty() || !finite(&[pts.to_vec()]) || cutters.iter().any(|c| !finite(c)) { return None; } let subject = vec![pts.to_vec()]; - let clips: Vec>> = cutters.iter().filter(|c| c.len() >= 3).map(|c| vec![c.clone()]).collect(); + let clips: Vec>> = cutters.iter().filter(|c| c.first().is_some_and(|r| r.len() >= 3)).cloned().collect(); if clips.is_empty() { return None; } @@ -187,10 +194,16 @@ fn point_in_ring(x: f64, y: f64, r: &[Pair]) -> bool { /// Teile der Strecke a→b ausserhalb aller Ringe, als Parameter-Intervalle. pub fn segment_outside(a: Pair, b: Pair, cutters: &[Vec]) -> Vec<(f64, f64)> { + let polys: Vec>> = cutters.iter().map(|c| vec![c.clone()]).collect(); + segment_outside_polys(a, b, &polys) +} + +/// Wie [`segment_outside`], Schneider als Polygone mit Löchern ([G1]): innen = in ungerade vielen Ringen. +pub fn segment_outside_polys(a: Pair, b: Pair, cutters: &[Vec>]) -> Vec<(f64, f64)> { let mut ts = vec![0.0, 1.0]; let dx = b[0] - a[0]; let dy = b[1] - a[1]; - for r in cutters { + for r in cutters.iter().flatten() { for i in 0..r.len() { let p = r[i]; let q = r[(i + 1) % r.len()]; @@ -217,7 +230,7 @@ pub fn segment_outside(a: Pair, b: Pair, cutters: &[Vec]) -> Vec<(f64, f64 let tm = (t0 + t1) / 2.0; let mx = a[0] + dx * tm; let my = a[1] + dy * tm; - if cutters.iter().any(|r| point_in_ring(mx, my, r)) { + if cutters.iter().any(|poly| poly.iter().filter(|r| point_in_ring(mx, my, r)).count() % 2 == 1) { continue; } match out.last_mut() { diff --git a/src/i18n/de.ts b/src/i18n/de.ts index a19cf5ae..4d0604e5 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -964,6 +964,9 @@ export const de = { "objinfo.extrudedSolid.taper": "Verjüngung", "objinfo.extrudedSolid.cornerRadius": "Eckenradius", "objinfo.extrudedSolid.chamfer": "Fase", + "objinfo.extrudedSolid.component": "Bauteil", + "objinfo.extrudedSolid.component.none": "– neutral –", + "objinfo.extrudedSolid.componentHint": "Material der Schnittfläche (Füllung und Schraffur in Grundriss und Schnitt)", "objinfo.extrudedSolid.brep": "B-Rep-Körper", "objinfo.extrudedSolid.baseOffset": "Abstand über Geschoss-UK", "objinfo.extrudedSolid.subtract": "Abzugskörper", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 2ac7bc97..df9a3429 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -960,6 +960,9 @@ export const en: Record = { "objinfo.extrudedSolid.taper": "Taper", "objinfo.extrudedSolid.cornerRadius": "Corner radius", "objinfo.extrudedSolid.chamfer": "Chamfer", + "objinfo.extrudedSolid.component": "Component", + "objinfo.extrudedSolid.component.none": "– neutral –", + "objinfo.extrudedSolid.componentHint": "Material of the cut face (fill and hatch in plan and section)", "objinfo.extrudedSolid.brep": "B-rep solid", "objinfo.extrudedSolid.baseOffset": "Offset above storey base", "objinfo.extrudedSolid.subtract": "Subtraction body", diff --git a/src/model/types.generated.ts b/src/model/types.generated.ts index 432dbd24..04e293fd 100644 --- a/src/model/types.generated.ts +++ b/src/model/types.generated.ts @@ -1341,6 +1341,11 @@ export type ExtrudedSolid = { * Grundriss-Fläche (Auswahl/2D-Umriss), `height` die Körperhöhe. */ brep?: { spec: Record; origin: Vec2; label?: string }; + /** + * [G1] Bauteil (Component Manager) des Körpers: Füllung und SIA-Schraffur der Schnittfläche im + * Grundriss und im Schnitt. Fehlt = neutrale Körper-Füllung mit Rückfall-Schraffur. + */ + componentId?: string; }; /** diff --git a/src/panels/host.ts b/src/panels/host.ts index a1523d80..69e163ca 100644 --- a/src/panels/host.ts +++ b/src/panels/host.ts @@ -585,6 +585,8 @@ export interface PanelHostValue { onSetExtrudedSolidSubtract: (subtract: boolean) => void; /** Abstand der Körper-UK über der Geschoss-UK (Meter). */ onSetExtrudedSolidBaseOffset: (offset: number) => void; + /** [G1] Bauteil des Körpers (Schnittfläche); "" löst die Zuweisung. */ + onSetExtrudedSolidComponent: (componentId: string) => void; // ── Stützen-Attribute (Tragwerk; nur die selektierte Stütze) ──────────── /** Wechselt das Profil (Rechteck/Kreis); leitet ein sinnvolles Mass ab. */ diff --git a/src/panels/objectInfo/SolidSections.tsx b/src/panels/objectInfo/SolidSections.tsx index 03fb6fa6..34469652 100644 --- a/src/panels/objectInfo/SolidSections.tsx +++ b/src/panels/objectInfo/SolidSections.tsx @@ -7,6 +7,7 @@ import { solidProps } from "../../engine/truckSolid"; import { t } from "../../i18n"; import type { ExtrudedSolidInfo, ColumnInfo } from "../../state/selectionInfo"; import { usePanelHost } from "../host"; +import { useStore } from "../../state/appStore"; import { Dropdown } from "../../ui/Dropdown"; import { DimensionField } from "./fields"; @@ -60,6 +61,7 @@ export function ExtrudedSolidSection({ solid: ExtrudedSolidInfo; host: ReturnType; }) { + const components = useStore((st) => st.project.components); return ( <>
@@ -100,6 +102,23 @@ export function ExtrudedSolidSection({ />
+ {/* [G1] Bauteil: Füllung und SIA-Schraffur der Schnittfläche in Grundriss und Schnitt. */} + {!solid.subtract && ( +
+ {t("objinfo.extrudedSolid.component")} + host.onSetExtrudedSolidComponent(v)} + options={[ + { value: "", label: t("objinfo.extrudedSolid.component.none") }, + ...components.map((c) => ({ value: c.id, label: c.name })), + ]} + title={t("objinfo.extrudedSolid.componentHint")} + width={130} + /> +
+ )} + {/* Abzugskörper: zieht sich von Wänden/Decken/Stützen ab (Grundriss, Schnitt, 3D, STEP). */} {solid.canSubtract && (
diff --git a/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt b/src/plan/__golden__/komplex-ansicht-ansicht-sued.txt index 0c39e33b..c8c5b741 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 232642 +bytes 234402 circle 4 g 1 line 553 path 2 -polygon 1326 +polygon 1341 polyline 50 rect 1 svg 1 text 4 -hash d8d8603c14110f10 +hash c283cb05e9570e10 diff --git a/src/plan/__golden__/komplex-grundriss-ug-100.txt b/src/plan/__golden__/komplex-grundriss-ug-100.txt index e04a0ff5..874b7b7e 100644 --- a/src/plan/__golden__/komplex-grundriss-ug-100.txt +++ b/src/plan/__golden__/komplex-grundriss-ug-100.txt @@ -1,13 +1,13 @@ viewBox -13.693 0 38.86 33.813 -bytes 38699 -circle 15 +bytes 42016 +circle 16 g 1 -line 94 +line 98 path 23 -polygon 43 -polyline 64 +polygon 45 +polyline 80 rect 1 svg 1 text 71 tspan 15 -hash 266ecd86022ba7cb +hash 914de604bff9969a diff --git a/src/plan/__golden__/komplex-grundriss-ug-50.txt b/src/plan/__golden__/komplex-grundriss-ug-50.txt index 6a153a60..f00c4b06 100644 --- a/src/plan/__golden__/komplex-grundriss-ug-50.txt +++ b/src/plan/__golden__/komplex-grundriss-ug-50.txt @@ -1,13 +1,13 @@ viewBox -13.693 0 38.527 33.406 -bytes 44623 -circle 15 +bytes 47974 +circle 16 g 1 -line 90 +line 94 path 38 -polygon 78 -polyline 71 +polygon 80 +polyline 87 rect 1 svg 1 text 71 tspan 15 -hash cd8d6d1ec759f128 +hash a4878f4a1e60006c diff --git a/src/state/panelHost/elementAttributesHost.ts b/src/state/panelHost/elementAttributesHost.ts index 8924c63d..2e25165f 100644 --- a/src/state/panelHost/elementAttributesHost.ts +++ b/src/state/panelHost/elementAttributesHost.ts @@ -276,6 +276,11 @@ export function buildElementAttributesHost(c: FlatHostOpts) { const id = selection.id; applyChange((p) => patchItem(p, "extrudedSolids", id, { baseOffset: Math.abs(offset) > 1e-9 ? offset : undefined })); }, + onSetExtrudedSolidComponent: (componentId) => { + if (selection?.kind !== "extrudedSolid") return; + const id = selection.id; + applyChange((p) => patchItem(p, "extrudedSolids", id, { componentId: componentId || undefined })); + }, // ── Stützen-Attribute (Tragwerk; nur bei selektierter Stütze) ────────── onSetColumnProfileKind: (kind) => { if (selection?.kind !== "column") return; diff --git a/src/state/selectionInfo.test.ts b/src/state/selectionInfo.test.ts index bf0eb2a0..ca96f8ee 100644 --- a/src/state/selectionInfo.test.ts +++ b/src/state/selectionInfo.test.ts @@ -59,7 +59,7 @@ describe("deriveSelection (Kern)", () => { expect(sel.extrudedSolid!.area).toBeCloseTo(3, 12); expect(sel.extrudedSolid!.spec).toMatchObject({ kind: "extrude", height: 2 }); expect(Object.keys(sel.extrudedSolid!)).toEqual([ - "height", "taper", "cornerRadius", "chamfer", "area", "spec", "subtract", "canSubtract", "baseOffset", "floorId", "floorName", + "height", "taper", "cornerRadius", "chamfer", "area", "spec", "subtract", "canSubtract", "baseOffset", "componentId", "floorId", "floorName", ]); }); diff --git a/src/state/selectionInfo.ts b/src/state/selectionInfo.ts index 0db5ac0b..35d40ede 100644 --- a/src/state/selectionInfo.ts +++ b/src/state/selectionInfo.ts @@ -361,6 +361,8 @@ export interface ExtrudedSolidInfo { canSubtract: boolean; /** Abstand der UK über der Geschoss-UK (m). */ baseOffset: number; + /** [G1] Bauteil der Schnittfläche (Füllung/SIA-Schraffur in Grundriss und Schnitt); "" = keins. */ + componentId: string; /** B-Rep-Beschreibung (Weltkoordinaten) für Kennwerte — `null`, wenn truck keine hat. */ spec: SolidSpec | null; /** Geschoss, dessen `baseElevation` die UK des Körpers bestimmt. */