diff --git a/TODO.md b/TODO.md index d4321428..5953e6db 100644 --- a/TODO.md +++ b/TODO.md @@ -10,7 +10,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* stehen im Archiv („Bewusst nicht übernommen“). - **Grösse** (eine Person mit Agenten): S ≤ 1 Tag · M ≤ 1 Woche · L ≤ 1 Monat · XL > 1 Monat. Steht keine Grösse im Archiv, ist sie hier geschätzt. -- **IDs sind stabil.** Neue ID = nächste freie Zahl nach der höchsten im Archiv und hier (aktuell 290); +- **IDs sind stabil.** Neue ID = nächste freie Zahl nach der höchsten im Archiv und hier (aktuell 292); nie eine ID wiederverwenden oder umnummerieren. Präfix-IDs (`[K]`, `[G]`, `[T]`, `[B]`, `[C]`) bleiben. - **Pro Punkt:** was fehlt · wo im Code · Grösse. Höchstens ein bis drei Sätze je Punkt; Messwerte und Befunde gehören in den Commit. @@ -64,7 +64,8 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC. - ◐ **[270]** Blickrichtungen überall gleich (3D-Spiegelung behoben, Marken weichen aus; 17.11.). Offen: 3D-Bild nur numerisch (Kameramatrix, Pick-Strahl) geprüft, kein Bild aus render3d unter Linux, nicht auf dem Mac/Metal (`doc/RELEASE-1.0.md` 13.36); natives Spike-Fenster `src-tauri/src/native.rs` (Orbit-Richtung) nicht angepasst. · M - ◐ **[279]** Geländer als eigenes Bauteil (18.11.; Lücke 7 `doc/VERGLEICH-1.0.md`; Linux/Chromium, nicht auf dem Mac geprüft): Modell, Grundriss, Schnitt/Ansicht/3D, IFC, DXF, Befehl `gelaender` umgesetzt (`railing.rs`, `plan/railings.rs`). Nachgeführt 18.11.: Glas in Ansicht und 3D-Dokument durchscheinend (helle Füllung wie Fensterglas, Deckkraft 0.4, verdeckt nichts; Schnitt unverändert), Objektfang auf Achse (und Längskanten dicker Brüstungen), Schatten der Sonnenstudie (Prismen aus `railing::pieces`, ab 400 Teilen ohne Stäbe/Pfosten). Lochblech mit Lochmuster in Ansicht und 3D-Dokument (Punktschraffur `Dots` der Schraffur-Bibliothek auf der Tafel, `railings::perforation_hatch`; Schnitt und Grundriss unverändert); Handlauf über der Schnitthöhe bei geschnittenem Fuss im Grundriss als zwei gestrichelte Linien im Abstand der Handlaufbreite neben der Achse (`railing-handrail`, Strichmuster wie die Treppen-Handläufe über dem Schnitt; 18.11., Prüfbild `doc/review-279/03-lochblech.png`, Chromium/Linux). Offen: kein IfcRailing-Import; Loggia-Brüstung an Wänden bleibt Wand. · M - ◐ **[278]** Nutzungseinheiten und Wohnungsspiegel (17.11.; Lücke 6; nicht auf dem Mac geprüft): `unit_schedule.rs`, Panel Flächenbilanz „Nutzungseinheiten“, CLI `--wohnungsspiegel` umgesetzt. Offen: Einheiten im Grundriss als farbige Fläche/Stempel auf eigener Klasse ([180]; `Unit.color` ist da); Summen je Typ/Geschoss nicht als eigene Blatt-Tabelle; Mindestfläche Zimmer und NWF nach kantonaler Definition fehlen; Einheit nicht in IFC/DXF; Spiegel im schmalen Dock als Karten. · M -- ◐ **[281]** Geneigte Decken und Rampen (18.11.; Lücke 8; nicht auf dem Mac geprüft): `Ceiling.slope`, Befehl `rampe`, Schnitt/Ansicht/3D/IFC (`IfcRamp`) umgesetzt. Offen: Wandschichten werden von geneigten Decken nicht eingeschnitten, Wandoberkante folgt der Decke nicht; STEP-Export schreibt die Platte waagrecht (truck kennt `slope` nicht); Sonne: geneigte Decke wirft Hüllprisma-Schatten, empfängt keinen; Rampenlauf ohne Material-/Typzuordnung im IFC; Rampen-Umriss unter Schnittebene gestrichelt. Gefällelinie 18.11. mit zwei Griffen (Anfang/Ende, Kern-Op `ceilingSlopeGrip`, Gefälle in % bleibt, ein Undo-Schritt je Zug; e2e `ramp281.spec.ts`; nicht in der Tauri-App geprüft). · M +- ◐ **[281]** Geneigte Decken und Rampen (18.11.; Lücke 8; nicht auf dem Mac geprüft): `Ceiling.slope`, Befehl `rampe`, Schnitt/Ansicht/3D/IFC (`IfcRamp`) umgesetzt. Offen: Wandschichten werden von geneigten Decken nicht eingeschnitten (Wandoberkante: [292]); STEP-Export schreibt die Platte waagrecht (truck kennt `slope` nicht); Sonne: geneigte Decke wirft Hüllprisma-Schatten, empfängt keinen; Rampenlauf ohne Material-/Typzuordnung im IFC; Rampen-Umriss unter Schnittebene gestrichelt. Gefällelinie 18.11. mit zwei Griffen (Anfang/Ende, Kern-Op `ceilingSlopeGrip`, Gefälle in % bleibt, ein Undo-Schritt je Zug; e2e `ramp281.spec.ts`; nicht in der Tauri-App geprüft). · M +- ◐ **[292]** Wand „OK bis Decke“ (19.11.; nach 1.0; Rest von [281]): `Wall.ceilingAttach` (Rust-Modell + `types.generated.ts`; fehlt = aus). Die Wand endet an der Unterkante der Decken ihres Geschosses — waagrecht auf Decken-UK, bei geneigter Decke mit schräger Oberkante (`ceiling_undersides` in `model3d/walls.rs` baut Unterkanten-Facetten samt Aussparungen, `wall_bands.rs` nutzt dieselbe Facetten-Logik wie „Wand an Dach“ [G2]: je Punkt gilt die tiefste Decken-UK bzw. die niedrigere von Dach und Decke, Stücke über der UK entfallen, im Deckenloch und ausserhalb der Decke bleibt die Krone, ohne Decke die Geschosshöhe; Platte bis Aussenkante der tragenden Schicht [178]). Wirkt über `emit_walls` auf 3D, Schnitt, Ansicht und IFC (Bänder, Mengen). UI: Objekt-Info Wand „Oberkante: Geschosshöhe / Bis Decke“, Befehl `wand` Option „OK bis Decke“ (Taste D/C, Vorgabe aus — keine eindeutige Regel für Innenwände). Rust-Tests `wand_ok_bis_decke_*` (waagrecht, Rückfall, geneigt, Deckenloch). Offen: Wand-Quelle `top` „an Dach“ und „frei“ bleiben die bisherigen Felder (`top`/`roofAttach`), keine gemeinsame Auswahl; Plan-Ansichtshöhe skalarer Werte (z. B. Kennzahl Wandhöhe) nutzt weiter die Krone; nicht in der Tauri-App geprüft. · S - ◐ **[280]** Träger/Unterzug als eigenes Bauteil (17.11.; Lücke 9; nicht auf dem Mac geprüft): `Project.beams`, Befehl `traeger`, IFC `IfcBeam`, Griffe umgesetzt (`Beam::as_column`, läuft durch Stützen-Code). Offen: `Group` ohne `beamIds` (Träger laufen über `columnIds`; Transformation bewegt nur EIN gewähltes Element des Kanals, in betretener Gruppe gezeichneter Träger wird nicht Mitglied, ungeprüft); keine Stütze-Träger-Verschneidung/Anschlussdetails; Profile nur als Text (kein Katalog, keine Gewichte); nur rechteckig und waagrecht; Deckenspiegel mit Unterzügen fehlt; Fassadenträger über mehrere Geschosse nur via `topOffset`; IFC-Import liest `IfcBeam` weiter als Körper ([B4]/[B5]); Attribute-Panel (Strich, Schraffur, Poché) für Träger nicht verdrahtet. · M - ◐ **[276]** Schnitt-/Ansichtslinie im Plan einstellbar wie Archicad (17.11.): `lineMode`, Linientyp, Stift, Marker je Linie, Vorgabe in der Modelldarstellung (`plan/misc.rs`, `plan/context.rs`, `SectionLookFields.tsx`). Offen: nicht auf dem Mac geprüft; Linientyp/Stift in der Modelldarstellung wählbar machen; Marke „Kreis mit Pfeil“ für Ansichten; Marken-Versatz unabhängig von der Linie. · S - ◐ **[284]** Review der Stränge seit `9f32c71f` ([271]–[283], [B5], [256], [266]) auf echte Fehler vor der Beta (18.11.). Behoben: Träger fehlten im Varianten-Filter (`design_options.rs`) und in `without_elements` (Umbau/Variante in 3D, Schnitt, Kennzahlen, IFC); Gefällelinie der geneigten Decke wanderte beim Verschieben/Drehen/Kopieren und beim Projekt-Verschieben nicht mit; Export „nur Auswahl“ nahm alle Geländer/Bäume mit; Zeichnen in betretener Gruppe nahm Träger/Geländer/Bäume nicht auf; Fang-Cache ohne `beams`; Cmd+A ohne Geländer; Geschoss löschen liess Dächer, Stützen, Träger, Geländer verwaist; Robustheits-Test für die neuen Bauteile mit Randwerten (kein Panic gefunden). Danach (18.11.): Geschoss löschen nimmt auch 2D-Elemente, Körper, Bäume und Kameras des Geschosses mit (`projectSlice.ts::deleteLevel`, vitest); Geländer in Darstellungs-Regeln (`overrides.rs`, Bauteilart „railing“), „Klasse der Auswahl“ (`layers.rs`) und Mass-Assoziation (`dim_assoc.rs`: Ecken/Kanten der Achse); Robustheits-Fixture `wettbewerb.json` neu aus `dossier-cli :wettbewerb migrate` (mit Geländern, Rampe, Einheiten). Die übrigen Fixtures enthalten diese Bauteile in ihren Beispielprojekten nicht. Erledigt, keine Offenpunkte mehr. Nicht in der Tauri-App geprüft; TS-Seite nur vitest/tsc (WASM nicht neu gebaut). diff --git a/doc/review-292/wand-an-decke.png b/doc/review-292/wand-an-decke.png new file mode 100644 index 00000000..c4bed619 Binary files /dev/null and b/doc/review-292/wand-an-decke.png differ diff --git a/src-tauri/core/src/cmd_create.rs b/src-tauri/core/src/cmd_create.rs index 6bebee42..e85de523 100644 --- a/src-tauri/core/src/cmd_create.rs +++ b/src-tauri/core/src/cmd_create.rs @@ -406,6 +406,10 @@ fn wall_ops(root: &Map, p: &Project, v: &Value, ctx: &Ctx, ids: & if let Some(e) = external { f.push(("isExternal", Value::Bool(e))); } + // [292] OK bis Decke (Option des Befehls, Vorgabe aus). + if matches!(v.get("ceilingAttach"), Some(Value::Bool(true))) { + f.push(("ceilingAttach", Value::Bool(true))); + } walls.push(obj(f)); } if walls.is_empty() { diff --git a/src-tauri/core/src/model/generated.rs b/src-tauri/core/src/model/generated.rs index f18e3445..0fa82b0a 100644 --- a/src-tauri/core/src/model/generated.rs +++ b/src-tauri/core/src/model/generated.rs @@ -3499,6 +3499,12 @@ pub struct Wall { #[serde(rename = "roofAttach", default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub roof_attach: Option, + /// OK bis Decke ([292]): `true` = die Wand endet an der Unterkante der Decke ihres Geschosses (waagrecht: Decken-UK; + /// geneigt: schräge Oberkante; im Deckenloch/ausserhalb der Decke bleibt die Krone); `undefined`/`false` = Wandkrone + /// (Geschosshöhe bzw. `top`). + #[serde(rename = "ceilingAttach", default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub ceiling_attach: Option, /// Ansichtsschraffur ([100]): Drehung (Grad) des Oberflächenmusters dieses Elements gegenüber der /// Ausrichtung am Element (Default 0). #[serde(rename = "surfacePatternAngle", default, skip_serializing_if = "Option::is_none")] diff --git a/src-tauri/core/src/model3d/tests.rs b/src-tauri/core/src/model3d/tests.rs index 27c85802..a35853fc 100644 --- a/src-tauri/core/src/model3d/tests.rs +++ b/src-tauri/core/src/model3d/tests.rs @@ -1209,3 +1209,64 @@ fn entourage_pick_im_3d() { assert!((top - (base + 1.75)).abs() < 1e-9, "{top}"); assert!(mine[0].tris.iter().flatten().all(|q| (q[0] - 4.0).abs() < 1.0 && (q[2] + 3.0).abs() < 1.0)); } + +/// [292] Wand W2 (x = 5, y 0…4) mit `ceilingAttach` unter einer Decke, die weit über die Wand reicht; `slope`: Gefälle +/// der Decke (`rise` über die Länge 4 in +y, `None` = waagrecht), `hole`: Aussparung im Deckenumriss. +fn wall_under_ceiling(attach: bool, with_ceiling: bool, slope: Option, hole: Option<[f64; 4]>) -> (Project, Vec, f64, f64) { + let mut p = sample(); + p.walls.retain(|w| w.id == "W2"); + p.openings = Some(vec![]); + p.walls[0].ceiling_attach = attach.then_some(true); + let mut c = p.ceilings.as_ref().unwrap()[0].clone(); + c.outline = [(0.0, -1.0), (8.0, -1.0), (8.0, 5.0), (0.0, 5.0)].iter().map(|&(x, y)| Vec2 { x, y }).collect(); + c.slope = slope.map(|r| CeilingSlope { from: Vec2 { x: 5.0, y: 0.0 }, to: Vec2 { x: 5.0, y: 4.0 }, rise: r, ramp: None, extra: Default::default() }); + c.openings = hole.map(|h| vec![[(h[0], h[1]), (h[2], h[1]), (h[2], h[3]), (h[0], h[3])].iter().map(|&(x, y)| Vec2 { x, y }).collect()]); + p.ceilings = Some(if with_ceiling { vec![c] } else { vec![] }); + let uk = p.ceilings.as_ref().and_then(|cs| cs.first()).map_or(0.0, |c| p.ceiling_vertical_extent(c).0); + let (_, crown) = p.wall_vertical_extent(&p.walls[0]); + let mut out = emit_walls(&p, false).unwrap(); + out.extend(emit_walls(&p, true).unwrap()); + (p, out, uk, crown) +} + +/// Höchste Oberkante aller Stücke an einer Stelle der Achse (x = 5, y). +fn top_at_y(ws: &[RWall], y: f64) -> f64 { + ws.iter() + .filter(|w| (w.start[1].min(w.end[1]) - 1e-6..=w.start[1].max(w.end[1]) + 1e-6).contains(&y)) + .map(|w| wall_top_at(w, [5.0, y])) + .fold(f64::NEG_INFINITY, f64::max) +} + +/// [292] Unter einer waagrechten Decke endet die Wand an der Decken-UK; ohne Option bleibt die Krone; ohne Decke +/// Rückfall auf die Geschosshöhe. +#[test] +fn wand_ok_bis_decke_waagrecht_und_rueckfall() { + let (_, ws, uk, crown) = wall_under_ceiling(true, true, None, None); + assert!(uk < crown - 0.05, "UK {uk} unter Krone {crown}"); + for y in [0.5, 2.0, 3.5] { + assert!((top_at_y(&ws, y) - uk).abs() < 1e-6, "y {y}: {} soll {uk}", top_at_y(&ws, y)); + } + let (_, ws, _, crown) = wall_under_ceiling(false, true, None, None); + assert!((top_at_y(&ws, 2.0) - crown).abs() < 1e-6, "ohne Option: Krone"); + let (_, ws, _, crown) = wall_under_ceiling(true, false, None, None); + assert!((top_at_y(&ws, 2.0) - crown).abs() < 1e-6, "ohne Decke: Geschosshöhe"); +} + +/// [292] Unter einer geneigten Decke folgt die Oberkante der Neigung (Gefälle −0.5 m auf 4 m). +#[test] +fn wand_ok_bis_decke_geneigt_folgt_der_neigung() { + let (_, ws, uk, _) = wall_under_ceiling(true, true, Some(-0.5), None); + for y in [0.5, 2.0, 3.5] { + let soll = uk - 0.5 * y / 4.0; + assert!((top_at_y(&ws, y) - soll).abs() < 1e-3, "y {y}: {} soll {soll}", top_at_y(&ws, y)); + } + assert!(ws.iter().any(|w| w.top_plane.is_some()), "schräge Oberkante"); +} + +/// [292] Deckenloch (y 1…3): dort bleibt die Krone, daneben endet die Wand an der UK. +#[test] +fn wand_ok_bis_decke_mit_deckenloch() { + let (_, ws, uk, crown) = wall_under_ceiling(true, true, None, Some([4.0, 1.0, 6.0, 3.0])); + assert!((top_at_y(&ws, 0.5) - uk).abs() < 1e-6 && (top_at_y(&ws, 3.5) - uk).abs() < 1e-6); + assert!((top_at_y(&ws, 2.0) - crown).abs() < 1e-6, "im Loch: Krone, {}", top_at_y(&ws, 2.0)); +} diff --git a/src-tauri/core/src/model3d/walls.rs b/src-tauri/core/src/model3d/walls.rs index 44fdd769..9f32a03e 100644 --- a/src-tauri/core/src/model3d/walls.rs +++ b/src-tauri/core/src/model3d/walls.rs @@ -616,9 +616,11 @@ pub(crate) fn floor_context(p: &Project, floor_id: &str, with_ceilings: bool) -> /// Wie [`floor_context`]; `joins`: schon gerechnete Schnittlinien je Wand-id (für den Deckenrand [178]). pub(crate) fn floor_context_with(p: &Project, floor_id: &str, with_ceilings: bool, joins: Option<&HashMap>) -> FloorContext { - let only = |c: &Ceiling| with_ceilings && c.floor_id == floor_id && c.outline.len() >= 3; + // [292] Wände mit `ceilingAttach` brauchen die Platten-Umrisse auch ohne Decken im Kontext (Schnitt). + let needs = with_ceilings || p.walls.iter().any(|w| w.floor_id == floor_id && w.ceiling_attach == Some(true)); + let only = |c: &Ceiling| needs && c.floor_id == floor_id && c.outline.len() >= 3; // [178] Platte bis Aussenkante Kern: die Aussenschicht-Bänder der Aussenwand liegen ausserhalb und laufen durch. - let bearing = if with_ceilings { super::bearing::bearing_outlines(p, only, joins) } else { Vec::new() }; + let bearing = if needs { super::bearing::bearing_outlines(p, only, joins) } else { Vec::new() }; floor_context_from(p, floor_id, with_ceilings, &bearing) } @@ -664,7 +666,40 @@ pub(crate) fn floor_context_from(p: &Project, floor_id: &str, with_ceilings: boo ri }) .collect(); - FloorContext::new(ceilings, roofs) + FloorContext::new(ceilings, roofs).with_ceiling_undersides(ceiling_undersides(p, floor_id, bearing)) +} + +/// [292] Unterkanten der Decken des Geschosses für Wände mit `ceilingAttach` (waagrecht und geneigt, auch ohne +/// `with_ceilings`: der Schnitt rechnet die Decken selbst). Nur gebaut, wenn eine Wand des Geschosses sie braucht. +/// Umriss = Platte bis Aussenkante der tragenden Schicht ([178], wie die Schnitt-Decken), Löcher = Aussparungen. +fn ceiling_undersides(p: &Project, floor_id: &str, bearing: &[Option>]) -> Vec { + if !p.walls.iter().any(|w| w.floor_id == floor_id && w.ceiling_attach == Some(true)) { + return Vec::new(); + } + let mut out = Vec::new(); + for (ci, c) in p.ceilings.as_deref().unwrap_or(&[]).iter().enumerate() { + if c.floor_id != floor_id || c.outline.len() < 3 { + continue; + } + let (zb, _) = p.ceiling_vertical_extent(c); + // z = zb + gx (x − ox) + gy (y − oy) + let plane = match c.slope_plane() { + Some(g) => [zb - g[2] * g[0] - g[3] * g[1], g[2], g[3]], + None => [zb, 0.0, 0.0], + }; + let rings: Vec> = match bearing.get(ci).cloned().flatten() { + Some(polys) => polys.iter().map(|poly| poly[0].iter().map(|q| [q[0], q[1]]).collect()).collect(), + None => vec![c.ring().iter().map(|v| [v.x, v.y]).collect()], + }; + let holes: Vec> = c.openings.iter().flatten().filter(|h| h.len() >= 3).map(|h| h.iter().map(|v| [v.x, v.y]).collect()).collect(); + for ring in rings { + if let Some(mut f) = crate::wall_bands::RoofFacet::new(ring, plane) { + f.holes = holes.clone(); + out.push(f); + } + } + } + out } /// Liegt der Achspunkt `p` eines Bogen-Teilkörpers an einer inneren Stossfuge (nicht an Anfang, Ende @@ -748,6 +783,7 @@ fn wall_pieces_with(p: &Project, maps: &[String], wall: &Wall, ctx: &FloorContex openings: wall_openings(p, wall, openings, true), cuts, roof_attach: wall.roof_attach, + ceiling_attach: wall.ceiling_attach == Some(true), reveals: if layered && stacked { wall_reveals(p, wall, openings, bands.len()) } else { Vec::new() }, keep_holes: plain, // [216] Sehnen-Zonen (über deckungsgleiche Bogenwände der Geschosse vereinigt, `arc_zones`): Wand und Loch liegen diff --git a/src-tauri/core/src/selection_info.rs b/src-tauri/core/src/selection_info.rs index 050c7632..1a353b15 100644 --- a/src-tauri/core/src/selection_info.rs +++ b/src-tauri/core/src/selection_info.rs @@ -507,6 +507,8 @@ fn wall_selection(root: &Map, w: &Value) -> Result { .v("sliceTermination", nn(field(w, "sliceTermination")).cloned().unwrap_or_else(|| "both".into())) // An Dach anschliessen ([G2]): fehlt = automatisch. .v("roofAttach", Value::String(match field(w, "roofAttach").and_then(|v| v.as_bool()) { Some(true) => "on", Some(false) => "off", None => "auto" }.into())) + // OK bis Decke ([292]): fehlt = aus. + .v("ceilingAttach", Value::Bool(field(w, "ceilingAttach").and_then(Value::as_bool).unwrap_or(false))) .raw("wallTypeId", w, "wallTypeId") // Aussenbauteil / tragend ([97]/[98]: Listen, IFC-Pset). .v("isExternal", Value::Bool(field(w, "isExternal").and_then(Value::as_bool).unwrap_or(false))) diff --git a/src-tauri/core/src/wall_bands.rs b/src-tauri/core/src/wall_bands.rs index c85eaf36..657648ed 100644 --- a/src-tauri/core/src/wall_bands.rs +++ b/src-tauri/core/src/wall_bands.rs @@ -91,6 +91,8 @@ impl RoofIn { pub struct RoofFacet { pub ring: Vec<[f64; 2]>, pub plane: [f64; 3], + /// Aussparungen (Deckenlöcher, [292]); leer bei Dachflächen. + pub holes: Vec>, bounds: [f64; 4], } @@ -101,7 +103,7 @@ impl RoofFacet { return None; } let b = outline_bounds(ring.iter().map(|q| (q[0], q[1]))); - Some(RoofFacet { ring, plane, bounds: [b.min_x, b.min_y, b.max_x, b.max_y] }) + Some(RoofFacet { ring, plane, holes: Vec::new(), bounds: [b.min_x, b.min_y, b.max_x, b.max_y] }) } pub(crate) fn z(&self, x: f64, y: f64) -> f64 { self.plane[0] + self.plane[1] * x + self.plane[2] * y @@ -111,17 +113,7 @@ impl RoofFacet { if x < b[0] || x > b[2] || y < b[1] || y > b[3] { return false; } - let mut inside = false; - let n = self.ring.len(); - let mut j = n - 1; - for i in 0..n { - let (a, c) = (self.ring[i], self.ring[j]); - if (a[1] > y) != (c[1] > y) && x < (c[0] - a[0]) * (y - a[1]) / (c[1] - a[1]) + a[0] { - inside = !inside; - } - j = i; - } - inside + ring_has(&self.ring, x, y) && !self.holes.iter().any(|h| ring_has(h, x, y)) } /// Höchster Wert über den Ecken. fn z_max(&self) -> f64 { @@ -129,6 +121,24 @@ impl RoofFacet { } } +/// Punkt im Ring (gerade-ungerade-Regel). +fn ring_has(ring: &[[f64; 2]], x: f64, y: f64) -> bool { + let mut inside = false; + let n = ring.len(); + if n < 3 { + return false; + } + let mut j = n - 1; + for i in 0..n { + let (a, c) = (ring[i], ring[j]); + if (a[1] > y) != (c[1] > y) && x < (c[0] - a[0]) * (y - a[1]) / (c[1] - a[1]) + a[0] { + inside = !inside; + } + j = i; + } + inside +} + /// Unterkanten-Facetten der Dachflächen: Oberfläche um `total` senkrecht zur Fläche gesenkt (wie die /// 3D-Schichten); senkrechte Flächen entfallen. pub fn plane_facets(planes: &[Vec<[f64; 3]>], total: f64) -> Vec { @@ -190,6 +200,9 @@ pub struct WallIn { /// Dach-Unterkante, wo ihre Krone darüber liegt), `Some(true)` = zusätzlich bis unter das Dach /// verlängert, `Some(false)` = Dächer schneiden die Wand nicht. pub roof_attach: Option, + /// OK bis Decke ([292], `Wall.ceilingAttach`): die Wand endet an der Unterkante der Decken ihres Geschosses + /// (`FloorContext::under`), auch geneigt. + pub ceiling_attach: bool, /// [231] Unter einer Dachfläche die Löcher im Stück behalten, statt es in Pfeiler/Brüstung/Sturz mit je /// eigener Oberkante zu teilen — für den Wandkörper per Boolean (`model3d/wall_body.rs`), der die Löcher /// selbst ausschneidet. Sonst `false`. @@ -207,9 +220,23 @@ pub struct WallIn { pub struct FloorContext { ceilings: Vec<(CeilingIn, Bounds)>, roofs: Vec<(RoofIn, Bounds)>, + /// Unterkanten der Decken ([292]) — nur für Wände mit `ceiling_attach`; gilt die tiefste. + under: Vec<(RoofFacet, Bounds)>, } impl FloorContext { + /// Decken-Unterkanten ([292]) ergänzen (`RoofFacet::plane` = UK, `holes` = Aussparungen). + pub fn with_ceiling_undersides(mut self, facets: Vec) -> Self { + self.under = facets + .into_iter() + .map(|f| { + let b = Bounds { min_x: f.bounds[0], min_y: f.bounds[1], max_x: f.bounds[2], max_y: f.bounds[3] }; + (f, b) + }) + .collect(); + self + } + /// Die Decken (Eingabe) — der 3D-Cache ([58]) vergleicht sie: der Deckenrand [178] hängt von den Wänden ab. pub fn ceiling_inputs(&self) -> Vec { self.ceilings.iter().map(|c| c.0.clone()).collect() @@ -219,6 +246,8 @@ impl FloorContext { pub fn same_input(&self, o: &FloorContext) -> bool { self.ceilings.len() == o.ceilings.len() && self.roofs.len() == o.roofs.len() + && self.under.len() == o.under.len() + && self.under.iter().zip(&o.under).all(|(a, b)| a.0 == b.0) && self.ceilings.iter().zip(&o.ceilings).all(|(a, b)| a.0 == b.0) && self.roofs.iter().zip(&o.roofs).all(|(a, b)| a.0 == b.0) } @@ -239,6 +268,7 @@ impl FloorContext { (r, b) }) .collect(), + under: Vec::new(), } } } @@ -621,7 +651,11 @@ enum Fac { } struct Tops<'a> { + /// Dachfacetten (je Punkt gilt die höchste), danach ab `n_roof` die Decken-UK (tiefste, [292]). facets: Vec<&'a RoofFacet>, + n_roof: usize, + /// Fuss der ganzen Wand (nicht des Stücks): Decken darunter zählen nicht. + foot: f64, zb: f64, zt_free: f64, zt_cap: f64, @@ -630,7 +664,7 @@ struct Tops<'a> { impl Tops<'_> { fn at(&self, p: Vec2) -> Fac { let mut best: Option<(f64, usize)> = None; - for (k, f) in self.facets.iter().enumerate() { + for (k, f) in self.facets.iter().enumerate().take(self.n_roof) { if f.contains(p.x, p.y) { let z = f.z(p.x, p.y); if best.is_none_or(|b| z > b.0) { @@ -638,6 +672,21 @@ impl Tops<'_> { } } } + // Decke darüber: tiefste Unterkante über dem Wandfuss (Stücke darüber entfallen); eine Decke unter dem Fuss zählt nicht. + let mut under: Option<(f64, usize)> = None; + for (k, f) in self.facets.iter().enumerate().skip(self.n_roof) { + if f.contains(p.x, p.y) { + let z = f.z(p.x, p.y); + if z > self.foot + 1e-9 && under.is_none_or(|b| z < b.0) { + under = Some((z, k)); + } + } + } + if let Some(u) = under { + if best.is_none_or(|b| u.0 < b.0) { + best = Some(u); + } + } match best { None => Fac::Free, Some((z, _)) if z >= self.zt_cap - 1e-9 => { @@ -678,23 +727,32 @@ struct TopPiece { /// Dächer, die eine Wand im Höhenbereich `[zb, zt]` betreffen; `None` = keine (unverändert). fn roof_tops_ctx<'a>(w: &WallIn, ctx: &'a FloorContext, zb: f64, zt: f64) -> Option> { - if w.roof_attach == Some(false) || ctx.roofs.is_empty() { + let roofs_on = w.roof_attach != Some(false) && !ctx.roofs.is_empty(); + let under_on = w.ceiling_attach && !ctx.under.is_empty(); + if !roofs_on && !under_on { return None; } let wb = wall_bounds(w, w.thickness_safe.max(0.0) + 0.01); - let facets: Vec<&RoofFacet> = ctx - .roofs - .iter() - .filter(|(r, rb)| r.eaves_z + 50.0 >= zb && bounds_overlap(wb, *rb)) - .flat_map(|(r, _)| r.facets.iter()) - .filter(|f| bounds_overlap(wb, Bounds { min_x: f.bounds[0], min_y: f.bounds[1], max_x: f.bounds[2], max_y: f.bounds[3] })) - .collect(); + let mut facets: Vec<&RoofFacet> = if roofs_on { + ctx.roofs + .iter() + .filter(|(r, rb)| r.eaves_z + 50.0 >= zb && bounds_overlap(wb, *rb)) + .flat_map(|(r, _)| r.facets.iter()) + .filter(|f| bounds_overlap(wb, Bounds { min_x: f.bounds[0], min_y: f.bounds[1], max_x: f.bounds[2], max_y: f.bounds[3] })) + .collect() + } else { + Vec::new() + }; + let n_roof = facets.len(); + if under_on { + facets.extend(ctx.under.iter().filter(|(_, b)| bounds_overlap(wb, *b)).map(|(f, _)| f)); + } if facets.is_empty() { return None; } // Verlängern nur, wo der Höhenbereich bis zur Wandkrone reicht (nicht unter einer Decke). - let zt_cap = if w.roof_attach == Some(true) && (zt - w.z_top).abs() < EPS { facets.iter().map(|f| f.z_max()).fold(zt, f64::max) } else { zt }; - Some(Tops { facets, zb, zt_free: zt, zt_cap }) + let zt_cap = if w.roof_attach == Some(true) && (zt - w.z_top).abs() < EPS { facets[..n_roof].iter().map(|f| f.z_max()).fold(zt, f64::max) } else { zt }; + Some(Tops { facets, n_roof, foot: w.z_bottom, zb, zt_free: zt, zt_cap }) } /// Ecken der Grundfläche eines Bandstücks (aussen +n, innen −n) an den Schnittlinien. @@ -808,6 +866,7 @@ fn strip_tops(w: &WallIn, t: &Tops, u: Vec2, n: Vec2, off: f64, th: f64, a: f64, Fac::Floor => continue, Fac::Free => (None, t.zt_free), Fac::Cap => (None, t.zt_cap), + Fac::Roof(k) if k >= t.n_roof && t.coef(f)[1] == 0.0 && t.coef(f)[2] == 0.0 => (None, t.coef(f)[0].clamp_safe(t.zb, t.zt_cap)), Fac::Roof(_) => { let c = t.coef(f); let zmax = strip_corners(w, u, n, off, th, s0, s1, c0, c1).iter().map(|q| c[0] + c[1] * q.x + c[2] * q.y).fold(f64::NEG_INFINITY, f64::max); @@ -1249,6 +1308,7 @@ mod tests { cuts: WallCuts::default(), reveals: vec![], roof_attach: None, + ceiling_attach: false, keep_holes: false, chord_zones: vec![], } diff --git a/src/commands/cmds/wall.ts b/src/commands/cmds/wall.ts index 17ba96ea..58224b7d 100644 --- a/src/commands/cmds/wall.ts +++ b/src/commands/cmds/wall.ts @@ -81,8 +81,10 @@ interface ArcMode { typeName: string | null; /** [285] Aussenbauteil (IFC `IsExternal`): „auto“ = nach dem Wandtyp („Aussenwand“ ⇒ aussen), „yes“/„no“ ausdrücklich. */ ext: "auto" | "yes" | "no"; + /** [292] OK bis Decke: neue Wände enden an der Unterkante der Decke ihres Geschosses (Vorgabe aus). */ + ceil: boolean; } -const NO_MODE: ArcMode = { arc: false, tangent: false, typeId: null, typeName: null, ext: "auto" }; +const NO_MODE: ArcMode = { arc: false, tangent: false, typeId: null, typeName: null, ext: "auto", ceil: false }; const EXT_NEXT = { auto: "yes", yes: "no", no: "auto" } as const; /** Kontext mit dem gewählten Wandtyp des Befehls (Option „Wandtyp“); ein inzwischen gelöschter Typ fällt auf den aktiven zurück. */ @@ -118,6 +120,7 @@ const arcOption = (on: boolean): CmdOption => ({ id: "arc", labelKey: "cmd.polyl const tangentOption = (on: boolean): CmdOption => ({ id: "tangent", labelKey: "cmd.polyline.tangentOpt", value: on ? "on" : "off" }); const typeOption = (s: ArcMode): CmdOption => ({ id: "wtype", labelKey: "cmd.wall.typeOpt", value: s.typeName ?? t("cmd.wall.typeActive"), key: "W" }); const extOption = (s: ArcMode): CmdOption => ({ id: "ext", labelKey: "cmd.wall.extOpt", value: t(`cmd.wall.ext.${s.ext}`), key: t("cmd.wall.extKey") }); +const ceilOption = (s: ArcMode): CmdOption => ({ id: "ceil", labelKey: "cmd.wall.ceilOpt", value: t(s.ceil ? "cmd.wall.ext.yes" : "cmd.wall.ext.no"), key: t("cmd.wall.ceilKey") }); /** * Bänder der schon gesetzten Segmente: sie ändern sich je Mausschritt nicht und werden nur neu gerechnet, @@ -167,13 +170,13 @@ function wallDraft( * Commit: je Achssegment eine Wand des aktiven Typs (Höhe aus dem Geschoss); eine gelockte Dicke * (einschichtig) wählt/erzeugt den passenden Wandtyp — beides im Kern (`cmd_create.rs`). */ -const appendWalls = (pts: Vec2[], ctx: CommandContext, thick: number | null, segs: Seg[] = [], ext: ArcMode["ext"] = "auto") => { +const appendWalls = (pts: Vec2[], ctx: CommandContext, thick: number | null, segs: Seg[] = [], ext: ArcMode["ext"] = "auto", ceil = false) => { const external = ext === "auto" ? null : ext === "yes"; return createMutation( ctx, segs.some((g) => g !== 0) - ? { cmd: "wall", pts: pts.map(xy), thick, segs, external } - : { cmd: "wall", pts: pts.map(xy), thick, external }, + ? { cmd: "wall", pts: pts.map(xy), thick, segs, external, ceilingAttach: ceil } + : { cmd: "wall", pts: pts.map(xy), thick, external, ceilingAttach: ceil }, ); }; @@ -186,7 +189,7 @@ const idle = ( { draft: null, done: true }, ]; -const modeOf = (s: ArcMode): ArcMode => ({ arc: s.arc, tangent: s.tangent, typeId: s.typeId, typeName: s.typeName, ext: s.ext }); +const modeOf = (s: ArcMode): ArcMode => ({ arc: s.arc, tangent: s.tangent, typeId: s.typeId, typeName: s.typeName, ext: s.ext, ceil: s.ceil }); const draftOf = (ctx: CommandContext, s: WallDrawing): ToolDraft => wallDraft(ctx, s.points, s.cursor, s.thickOverride, s); export const wallCommand: Command = { @@ -202,7 +205,7 @@ export const wallCommand: Command = { accepts: () => ["point", "number", "option"], options: (s) => { const ps = s as WallCmdState; - const arc = [arcOption(!!ps.arc), ...(ps.arc ? [tangentOption(!!ps.tangent)] : []), typeOption(ps), extOption(ps)]; + const arc = [arcOption(!!ps.arc), ...(ps.arc ? [tangentOption(!!ps.tangent)] : []), typeOption(ps), extOption(ps), ceilOption(ps)]; return ps.phase === "next" ? [...arc, UNDO] : arc; }, init: (): WallIdle => ({ phase: "start", lastPoint: null, thickOverride: null, single: false, ...NO_MODE }), @@ -212,9 +215,10 @@ export const wallCommand: Command = { const to = s.thickOverride; // [285] Wandtyp wählen (reihum durch die Typen des Projekts) bzw. Aussenbauteil umschalten. - if (input.kind === "option" && (input.id === "wtype" || input.id === "ext")) { + if (input.kind === "option" && (input.id === "wtype" || input.id === "ext" || input.id === "ceil")) { let flip: Partial; if (input.id === "ext") flip = { ext: EXT_NEXT[s.ext] }; + else if (input.id === "ceil") flip = { ceil: !s.ceil }; else { const list = ctx0.project.wallTypes; if (list.length === 0) return [s, { draft: null }]; @@ -297,7 +301,7 @@ export const wallCommand: Command = { if (s.points.length >= 3 && segLen(s.points[0], pt) < EPS) { return [ { phase: "start", lastPoint: null, thickOverride: to, single, ...modeOf(s) } as WallIdle, - { draft: null, done: true, commit: appendWalls([...s.points, s.points[0]], ctx, to, [...s.segs, seg], s.ext) }, + { draft: null, done: true, commit: appendWalls([...s.points, s.points[0]], ctx, to, [...s.segs, seg], s.ext, s.ceil) }, ]; } const ns: WallDrawing = { @@ -330,7 +334,7 @@ export const wallCommand: Command = { const to = s.thickOverride; return [ { phase: "start", lastPoint: null, thickOverride: to, single: s.single, ...modeOf(s) } as WallIdle, - { draft: null, done: true, commit: appendWalls(pts, ctx, to, s.segs, s.ext) }, + { draft: null, done: true, commit: appendWalls(pts, ctx, to, s.segs, s.ext, s.ceil) }, ]; } return idle(s.thickOverride, s.single, modeOf(s)); diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 0e345df4..5dda5976 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -653,6 +653,10 @@ export const de = { "objinfo.wall.roofAttach.auto": "Automatisch", "objinfo.wall.roofAttach.on": "Ja, bis unters Dach", "objinfo.wall.roofAttach.off": "Nein", + "objinfo.wall.ceilingAttach": "Oberkante", + "objinfo.wall.ceilingAttach.off": "Geschosshöhe", + "objinfo.wall.ceilingAttach.on": "Bis Decke", + "objinfo.wall.ceilingAttach.tip": "Geschosshöhe: Die Wand endet an ihrer Oberkante (Geschoss bzw. frei gesetzt). Bis Decke: Sie endet an der Unterkante der Decke ihres Geschosses, auch bei geneigter Decke; im Deckenloch bleibt die Krone.", "objinfo.wall.roofAttach.tip": "Automatisch: Die Wand endet je Schicht an der Dach-Unterkante, wo ihre Krone darüber liegt. Ja: zusätzlich bis unter das Dach verlängert. Nein: Dächer schneiden die Wand nicht.", "objinfo.wall.sliceTermination.both": "Aus", "objinfo.wall.sliceTermination.below": "Unten", @@ -2076,6 +2080,8 @@ export const de = { "cmd.wall.typeActive": "aktiv", "cmd.wall.extOpt": "Aussenbauteil", "cmd.wall.extKey": "A", + "cmd.wall.ceilOpt": "OK bis Decke", + "cmd.wall.ceilKey": "D", "cmd.wall.ext.auto": "nach Typ", "cmd.wall.ext.yes": "ja", "cmd.wall.ext.no": "nein", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index dc2594a9..1c546269 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -651,6 +651,10 @@ export const en: Record = { "objinfo.wall.roofAttach.auto": "Automatic", "objinfo.wall.roofAttach.on": "Yes, up to the roof", "objinfo.wall.roofAttach.off": "No", + "objinfo.wall.ceilingAttach": "Top", + "objinfo.wall.ceilingAttach.off": "Storey height", + "objinfo.wall.ceilingAttach.on": "Up to ceiling", + "objinfo.wall.ceilingAttach.tip": "Storey height: the wall ends at its top (storey or freely set). Up to ceiling: it ends at the underside of its storey's ceiling, also for a sloped ceiling; the crown stays in a ceiling opening.", "objinfo.wall.roofAttach.tip": "Automatic: each wall layer ends at the roof underside where its top lies above it. Yes: also extended up to the roof. No: roofs do not cut the wall.", "objinfo.wall.sliceTermination.both": "Off", "objinfo.wall.sliceTermination.below": "Below", @@ -2065,6 +2069,8 @@ export const en: Record = { "cmd.wall.typeActive": "active", "cmd.wall.extOpt": "External", "cmd.wall.extKey": "E", + "cmd.wall.ceilOpt": "Top to ceiling", + "cmd.wall.ceilKey": "C", "cmd.wall.ext.auto": "by type", "cmd.wall.ext.yes": "yes", "cmd.wall.ext.no": "no", diff --git a/src/model/types.generated.ts b/src/model/types.generated.ts index a101a4a1..a935b99a 100644 --- a/src/model/types.generated.ts +++ b/src/model/types.generated.ts @@ -5044,6 +5044,12 @@ export type Wall = { * unter das Dach verlängert, `false` = Dächer schneiden die Wand nicht. */ roofAttach?: boolean; + /** + * OK bis Decke ([292]): `true` = die Wand endet an der Unterkante der Decke ihres Geschosses (waagrecht: Decken-UK; + * geneigt: schräge Oberkante; im Deckenloch/ausserhalb der Decke bleibt die Krone); `undefined`/`false` = Wandkrone + * (Geschosshöhe bzw. `top`). + */ + ceilingAttach?: boolean; /** * Ansichtsschraffur ([100]): Drehung (Grad) des Oberflächenmusters dieses Elements gegenüber der * Ausrichtung am Element (Default 0). diff --git a/src/panels/host.ts b/src/panels/host.ts index 6c6bd54f..45afda9a 100644 --- a/src/panels/host.ts +++ b/src/panels/host.ts @@ -422,6 +422,7 @@ export interface PanelHostValue { onSetWallSliceTermination: (termination: SliceTermination) => void; /** An Dach anschliessen ([G2]): "auto" = Default (Wand endet an der Dach-Unterkante). */ onSetWallRoofAttach: (attach: "auto" | "on" | "off") => void; + onSetWallCeilingAttach: (attach: boolean) => void; /** Aussenbauteil/tragend der gewählten Wand bzw. Decke ([97]/[98]); `false` = Feld weg. */ onSetBuildingFlags: (flags: { isExternal?: boolean; loadBearing?: boolean }) => void; /** [178] Deckenrand der gewählten Decke: `true` = bis an den Umriss, `false` = Auflager bis Kern (Standard). */ diff --git a/src/panels/objectInfo/WallSection.tsx b/src/panels/objectInfo/WallSection.tsx index 25f74e4d..ba9ddb02 100644 --- a/src/panels/objectInfo/WallSection.tsx +++ b/src/panels/objectInfo/WallSection.tsx @@ -115,6 +115,20 @@ export function WallSection({ width={120} /> + {/* OK bis Decke ([292]): Oberkante an der Unterkante der Decke des Geschosses, auch geneigt. */} +
+ {t("objinfo.wall.ceilingAttach")} + host.onSetWallCeilingAttach(v === "on")} + options={[ + { value: "off", label: t("objinfo.wall.ceilingAttach.off") }, + { value: "on", label: t("objinfo.wall.ceilingAttach.on") }, + ]} + title={t("objinfo.wall.ceilingAttach.tip")} + width={120} + /> +
{/* Aufbau-Typ-Segment. */} diff --git a/src/state/panelHost/elementAttributesHost.ts b/src/state/panelHost/elementAttributesHost.ts index 59e2ef23..69153eac 100644 --- a/src/state/panelHost/elementAttributesHost.ts +++ b/src/state/panelHost/elementAttributesHost.ts @@ -93,6 +93,9 @@ export function buildElementAttributesHost(c: FlatHostOpts) { // "auto" ist der Default ⇒ als undefined speichern. patchAll("walls", selection.id, { roofAttach: attach === "auto" ? undefined : attach === "on" }); }, + onSetWallCeilingAttach: (attach) => { + if (selection?.kind === "wall") patchAll("walls", selection.id, { ceilingAttach: attach ? true : undefined }); + }, onSetBuildingFlags: (flags) => { const patch: { isExternal?: boolean; loadBearing?: boolean } = {}; if (flags.isExternal !== undefined) patch.isExternal = flags.isExternal || undefined; diff --git a/src/state/selectionInfo.ts b/src/state/selectionInfo.ts index ba096665..e562a5c2 100644 --- a/src/state/selectionInfo.ts +++ b/src/state/selectionInfo.ts @@ -133,6 +133,8 @@ export interface WallInfo { sliceTermination: SliceTermination; /** An Dach anschliessen ([G2]): "auto" (Default), "on" (bis unter das Dach verlängern), "off". */ roofAttach: "auto" | "on" | "off"; + /** OK bis Decke ([292]): Wand endet an der Decken-Unterkante ihres Geschosses (auch geneigt). */ + ceilingAttach: boolean; /** Aussenbauteil / tragend ([97]/[98]). */ isExternal: boolean; loadBearing: boolean;