diff --git a/TODO.md b/TODO.md index eabbe347..b03c6145 100644 --- a/TODO.md +++ b/TODO.md @@ -75,6 +75,7 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC. - ◐ **[270]** Blickrichtungen überall gleich, Marken weichen aus (17.11.). **Befund:** das 3D-Fenster (render3d, Browser und Metal) zeigte das Modell **gespiegelt**: Bauteile liegen in der Welt (x, Höhe, y), ein Achsentausch (Determinante −1), und `look_at` ist rechtshändig — von Süden gesehen lag der Erker im Osten links, die Draufsicht stand kopfüber (Süden oben). Gelände, Importe/Verbau und Punktwolken negierten y (Fix 24.9. „swisstopo gespiegelt“) und lagen damit an y = 0 gespiegelt unter dem Haus. Vektor-Axonometrie, Cycles, Blender, glTF/OBJ und die Ansichten Nord/Ost/Süd/West waren seitenrichtig, aber die Namen widersprachen sich: `iso` = von Nordost (3D, Axo-Alias), von Südwest (Cycles/Blender); `front` = von Norden (3D, Axo) bzw. Süden (Cycles); „Axonometrie Südost“ im Musterhaus komplex stand auf `isoFrontLeft`. **Behoben:** eine Tabelle `render3d/src/view_dir.rs` für 3D-Presets (`math::preset_camera`), Axonometrie (`plan/axo.rs::preset`), Cycles (`cycles_scene.rs::preset`, CLI `render --view` nimmt auch `southeast` …), Blender-Skript (Kopie, per vitest geprüft): vorne = Süden, rechts = Osten, `iso` = Südost, `isoFrontLeft` = Südwest, `isoBackRight` = Nordost, `isoBackLeft` = Nordwest, `top` mit Norden oben; Beschriftungen „Isometrie Südost“, „Südwest“ … Die Spiegelung gleicht die Kamera an einer Stelle aus (`math::view_matrix`: Bild-rechts = oben × Blick; Culling `FrontFace::Cw`; Pathtracer-Strahlen; TS `screenRight`/`orbitRight` für Pick-Strahl, Griffe, Pan, Zoom zum Cursor, Begehen, Orbit-Richtung); Gelände/Import/Punktwolke/Luftbild ohne y-Negation. Ausschnitt „Axonometrie Südost“ → `iso`. **Marken ([266]/8):** Ansichtsmarken werden nach den Schnitten gesetzt und weichen Schnittlinien, -pfeilen und anderen Ansichtsmarken aus (zusätzlich seitlich entlang ihrer Linie, bis 15 mm; `plan/context.rs::view_marker`); Schnittpfeile sind Hindernis für Beschriftungen. Tests: Rust render3d `kamera_zeigt_modell_seitenrichtig` (vorher rot), `aussenflaechen_erscheinen_im_uhrzeigersinn`, `view_dir::tests`; Kern `axo::testhaus_seitenrichtig_in_allen_vorgaben`, `cycles_scene::voreinstellungen_heissen_wie_im_3d`, `context::ansichtsmarken_weichen_schnittmarken_aus` (vorher rot); vitest `view270.test.ts`, `viewDirections.test.ts`. Bilder und Testhaus (Erker Ost, Garage West, Turm Nordwest; `testhaus.py`) in `doc/review-270/`. **Offen:** 3D-Bild nur numerisch (Kameramatrix, Pick-Strahl) geprüft, kein Bild aus render3d unter Linux, nicht auf dem Mac/Metal (Prüfschritt `doc/RELEASE-1.0.md` 13.36); natives Spike-Fenster `src-tauri/src/native.rs` (Orbit-Richtung) nicht angepasst; gespeicherte Ausschnitte mit `isoBackRight`/`isoFrontLeft` zeigen jetzt die Richtung ihres Namens (keine produktiven Projekte). · M - ◐ **[279]** Geländer als eigenes Bauteil (18.11.; Lücke 7 in `doc/VERGLEICH-1.0.md`; Chromium/Linux, nicht in der Tauri-App/auf dem Mac geprüft): Modell `Railing`/`Project.railings` im Rust-Kern (Polylinie auf einem Geschoss, `closed`, Höhe Vorgabe 1.00 m SIA 358, `baseOffset` ab Geschoss-UK, Art Stäbe/Glas/Brüstung/Lochblech, Handlauf, Stababstand (lichtes Mass ≤ 12 cm), Dicke, Bauteil; Ebene „41“), Umbau-Status ([271]) und Varianten ([272]) wie die anderen Bauteile. Eine Quelle `railing.rs` (Prismen) für 3D-Netz (`model3d/railings.rs`), Schnitt/Ansicht/3D-Dokument (Platten `SlabSource::Railing`, Pick `@railing:`), Grundriss `plan/railings.rs` (Linie/Doppellinie/Fläche, ganz über der Schnitthöhe Strich-Punkt), IFC `IfcRailing` GUARDRAIL (neuer Datensatz 26), DXF-Ebene der Klasse, Verschieben/Kopieren/Zwischenablage/Gruppen/Sperre/Löschen, Befehl `gelaender` (Alias `railing`, `gl`), Objekt-Info, Griffe an allen Achsenpunkten, Beispiel Wettbewerb (zwei Balkone Süd/West: Stäbe 1. OG, Glas 2. OG), Bild `doc/review-279/01-gelaender.png`. Tests: Rust `railing`, `railing_tests`, `plan::railings` (Debug-Lauf der ganzen Lib: 1942 grün), vitest, e2e `railing279.spec.ts`. **Offen:** Glas in der Ansicht deckend (keine Transparenz), Lochblech ohne Lochmuster; Handlauf über der Schnitthöhe im Grundriss nicht eigens gestrichelt; kein Objektfang auf Geländerpunkten; kein Import von IfcRailing; Schatten (Sonnenstudie) ohne Geländer; Loggia-Brüstung an Wänden bleibt Wand. · M - ◐ **[278]** Nutzungseinheiten und Wohnungsspiegel (17.11.; Lücke 6 in `doc/VERGLEICH-1.0.md`; Chromium/Linux, nicht in der Tauri-App/auf dem Mac geprüft): `Project.units` (`Unit`: Nummer, Typ, Nutzung Wohnen/Gewerbe/Büro/Andere, Farbe, Bemerkung), `Room.unitId`, `Room.roomCount`. Kern `unit_schedule.rs` (Annahmen im Modulkopf): je Einheit Geschoss(e), Typ (eingegeben oder „n-Zi-Whg“), Zimmerzahl, HNF/NNF/NF nach SIA 416, Aussenraum = Räume der Flächenart AGF, Summen je Typ und je Geschoss, Räume ohne Einheit getrennt. **Zimmerzahl (Annahme, nicht aus dem Namen geraten):** nur bei Wohnnutzung; Beitrag je Raum `roomCount`, sonst aus der Raumnutzung: Wohnen, Schlafen, Essen, Büro = 1, alles andere 0, nur bei Flächenart HNF; Wohnküche von Hand 0.5 (oder Wohnen/Essen 1.5). Maisonetten zählen in jedem Geschoss mit ihren Flächen. Abfrage `unitSchedule`, Blatt-Tabelle Quelle `unitSchedule`, Bericht/CSV/PDF (`buildAreaReport` mit `units`; der Nachweis-Export enthält ihn, eigene Knöpfe „Spiegel CSV/PDF“), CLI `kennzahlen --wohnungsspiegel` (ohne Option im JSON, sobald Einheiten da sind). Oberfläche: Panel Flächenbilanz „Nutzungseinheiten“ (`UnitsSection.tsx`: Liste, neue Einheit leer/aus Auswahl, Auswahl zuordnen, löschen), Objekt-Info Raum: Felder „Einheit“ (Auswahl, „Neue Einheit …“) und „Zimmer-Zählung“, Mehrfachauswahl = ein Undo-Schritt. Beispiel Wettbewerb: 6 Wohnungen (2-Zi und 2.5-Zi), Layout „Wohnungsspiegel“. Tests: Rust `unit_schedule::tests`, `sheet_table::wohnungsspiegel_tabelle`, `robustness`; vitest `unitSchedule.test.ts`; e2e `units278.spec.ts`. Bilder: `doc/review-278/`. **Offen:** Einheiten im Grundriss als farbige Fläche/Stempel auf eigener Klasse ([180]) fehlt (`Unit.color` ist schon da); Summen je Typ/Geschoss nicht als eigene Blatt-Tabelle; Mindestfläche für Zimmer und Wohnungs-Nettowohnfläche (NWF) nach kantonaler Definition nicht abgebildet; Einheit nicht in IFC/DXF-Export; im schmalen Dock wird der Spiegel als Karten gezeigt (wie die Flächentabelle) · M. +- ◐ **[281]** Geneigte Decken und Rampen (18.11.; Lücke 8 in `doc/VERGLEICH-1.0.md`; Linux-Container/Chromium, nicht in der Tauri-App/auf dem Mac geprüft). **Modell:** `Ceiling.slope` (`CeilingSlope`: `from`, `to`, `rise`, `ramp?`): am Bezugspunkt gilt die eingestellte OK/UK, längs `from`→`to` steigt die Platte um `rise`; alle Schichten parallel verschoben, Dicke lotrecht (Volumen exakt = Fläche × Dicke). **Kern:** `RSlab.slope`/render3d `SlabInput.slope` (Netz, Live-Schnitt, Schnittbänder schräg und nur polygonal in der Dominanz), Schnitt-Projektion und `axo` (`view_faces`), Ansicht (Plattenpuffer mit negativer Eckenzahl), Abzugskörper (`extrude` mit `slope`, Manifold), Exporte OBJ/glTF (`mesh_data`), Hervorhebung, Pick (TS, Scherung), Flächenmuster, Raumhöhe, Öffnung unter geneigter Decke ([234]: tiefste UK), Ansichtsbereich nach Höhenspanne. Grundriss: Gefällepfeil abwärts bzw. Rampen-Lauflinie mit Antrittspunkt und Pfeil aufwärts, „x %“, Linien `ceiling-slope` auf der Deckenklasse ([180]). IFC: geneigt = `IfcSlab` als Netz (`REC_CEILING_MESH`), Rampe = `IfcRamp` (STRAIGHT_RUN_RAMP) mit `IfcRampFlight` (Netz, `Pset_RampFlightCommon`, `Qto_RampFlightBaseQuantities`), IFC4 und IFC2x3 mit ifcopenshell gültig. SIA 416/GV unverändert (Test). **UI:** Objekt-Info Decke „Neigung“ (aus/Gefälle/Rampe, %, Grad, Höhenunterschied, Richtung aufwärts, Bezugspunkt), Befehl „Rampe“ (`rampe`: Umriss, Gefällelinie, Gefälle %, Enter = 6 %) in der Werkzeugliste. Beispiel Wettbewerb: Eingangsrampe 6 % an der Ostfassade (Schnitt B-B), Bild `doc/review-281/01-rampe.png`; e2e `ramp281.spec.ts`. **Offen:** Wandschichten werden von geneigten Decken nicht eingeschnitten (Wand-an-Decke folgt nicht; heute gibt es nur Wand-an-Dach), Wandoberkante folgt einer geneigten Decke nicht; STEP-Export schreibt die Platte waagrecht (truck kennt `slope` nicht); Sonne: geneigte Decke wirft als Hüllprisma Schatten und empfängt keinen; Rampenlauf ohne Material-/Typzuordnung im IFC; Grundriss-Umriss einer Rampe unter der Schnittebene gestrichelt (Ansichtsbereich); Griff für die Gefällelinie fehlt; Mac/Metal nicht gesehen. · M - ◐ **[276]** Schnitt-/Ansichtslinie im Plan einstellbar (Wunsch Maintainer 17.11., „wie Archicad“; 17.11.). **Archicad** (Hilfe „Section/Elevation Marker“, Marker- und Marker-Head-Bereich der Schnitt-Einstellungen, Modellansicht-Option „Show Section and Elevation Markers“, [Quellen nur über die Suche gelesen, Feldnamen nicht je Version geprüft]): Marke an Anfang, Ende oder beiden Enden bzw. eine in der Mitte, Markentyp und Symbol, Linientyp und Stift der Linie, Beschriftung. **Übernommen (schlank):** je Schnitt- und Ansichtslinie `lineMode` (full | ends | none), `endLengthMm`, `lineStyleId` (Linientyp), `linePenId` (Stift des aktiven Stiftsatzes: Farbe + Stärke), `marker` (arrow | lAngle | triangle | none; Ansicht: triangle | arrow | none), `markerAt` (both | start | end, nur Schnitt), `markerLabel`; Vorgabe getrennt für Schnitte (`sectionMarks`) und Ansichten (`elevationMarks`) in der Modelldarstellung (Ebene > Modelldarstellung des gezeigten Plans > Basis), dort ohne Linientyp/Stift (Auswahl nur feste Werte). `markerStyle`/`sectionMarks.style` gehen darin auf; Basis = heutiges Bild (Goldens unverändert): Schnitt = dünne Strichpunktlinie mit kräftigen Endstücken + Pfeile + Beschriftung, Ansicht = nur Dreieck + Beschriftung. Ansichtslinie wird jetzt auf Wunsch gezeichnet und ist dann anwählbar. Der frühere L (`lAngle`) heisst jetzt `lineMode: ends` + `marker: lAngle`. Kern: `plan/misc.rs` (`SectionLook`, `section_polyline_look`, `view_symbol`, `view_line_parts`), `plan/model_view.rs::mark_look`, `plan/context.rs` (Linientyp/Stift, Beschriftung nur an markierten Enden, Ausweichen [270] und Knicke [176] unverändert). Oberfläche: `SectionLookFields.tsx` in der Objekt-Info (Symbol-Knöpfe mit Vorschau; Mehrfachauswahl ändert alle gewählten Linien in einem Undo-Schritt), Ressourcen > Modelldarstellung (Schnitt- und Ansichtsmarken). Tests: Rust `misc::darstellung_varianten`, `ansicht_zeichen_und_linie`, `context::schnittlinie_varianten_im_grundriss`, `schnittlinie_linientyp_und_stift`, `ansichtslinie_varianten`; vitest `SectionLookFields.test.ts`; e2e `sectionLook276.spec.ts`. Bilder: `doc/review-276/`. **Offen:** nicht in der Tauri-App/auf dem Mac geprüft (nur CLI-SVG in Chromium und Browser-Build); Linientyp/Stift in der Modelldarstellung wählbar machen (dynamische Werte); Marke „Kreis mit Pfeil“ für Ansichten; Marken-Versatz wie bei Archicad (Symbol unabhängig von der Schnittlinie verschieben) · S. - ○ **[282]** **PDF-Ebenen verlieren Wände im ersten Geschoss-Viewport** (17.11., Befund Koordinator beim Abgabe-PDF `:wettbewerb`, Präsentationsplan A1/A2): mit „PDF-Ebenen (je Kategorie)“ (Vorgabe an) fehlen im Erdgeschoss-Viewport Wände, Türen und Fenster (nur Räume/Masse/Treppe), die Obergeschosse sind richtig; ohne PDF-Ebenen ist das Erdgeschoss vollständig, am Bildschirm ebenso. Ort: `src/export/layoutPdf.ts` (`categoryLayerGroups` → `planOf(g.codes)` je Gruppe). Ausserdem: Präsentationsplan 1:100 auf A1 läuft über das Blatt (Ansichten abgeschnitten, Schnitte fehlen) — die Meldung „passt nicht“ kommt, aber das Blatt wird trotzdem so angelegt. · S–M - ◐ **[271]** Umbaufilter wie Archicad (Wunsch Maintainer 17.11.). **Modell:** `renovation: {status: existing|demolish|new, phase?}` an Wand, Öffnung (ohne eigenen Status folgt sie der Wand), Decke, Dach, Treppe, Stütze, Körper und Raum (Raum nur Sichtbarkeit/Flächen, keine Farbe — kein Bauteil); `Project.renovation` (Etappen, Farben, eigene Filter); `DrawingLevel`/`ViewTemplate`/`ViewSnapshot.renovationFilter`+`renovationPhase` (der Filter gehört zur Ebene wie die Modelldarstellung [173], damit je Reiter/Ausschnitt/Vorlage). **Kern** `renovation.rs` (ein Ort, `doc/ARCHITEKTUR.md` 3.8): Vorgaben Bestand/Abbruch/Neubau/Umbauplan/Endzustand, SIA-400-Farben (Bestand grau, Abbruch gelb gestrichelt, Neu rot, anpassbar), Etappen „bis n“ (Neues früherer Etappen = Bestand, Abbruch früherer weg, spätere Neue fehlen), Öffnung neu in Bestandswand = Abbruch-Stück bzw. zugemauerte Öffnung = Ausfachung (Wand zu, wo die Öffnung ausgeblendet ist). Umbau-Farben bleiben auch in Tusche (Schwarz-Weiss, `extras::KeepColors`); gefüllt werden nur Schnittflächen (Wand, Stütze), Symbole (Fenster, Türflügel, Tritte) nur in Linienfarbe. Angebunden: Grundriss, Schnitt, Ansicht, Vektor-Axo, 3D-Fenster (Filter der aktiven Ebene) und `model3d`, Kennzahlen/Flächen (Zustand Bestand/Endzustand im Panel), DXF (Layer `_Abbruch`/`_Neu`), IFC (`Status` NEW/EXISTING/DEMOLISH im `Pset_*Common`, Etappe in `Dossier_Umbau`). **Bedienung:** Objekt-Info/Objekteinstellungen „Umbau“ + „Etappe“ (Mehrfachauswahl, ein Undo-Schritt), Statusleiste „Umbau: …“ (Zeichen-Status neuer Bauteile, Vorgabe Bestand, Kern `commands::stamp_renovation`; Umbaufilter und Etappe der Ansicht; mit der Pausfolie im Überlauf „⋯“), Befehl `umbau` (B/A/N; die Befehlszeile nimmt getippte Options-Kürzel jetzt auch mit Enter an, `engine.ts`), Ressourcen-Tab „Umbau“ (Etappen, Farben), Vorlage „Beispiel Umbau“ (`model/sampleProjectUmbau.ts`, CLI `:umbau`), CLI `--renovation`/`--phase` (plan, section, elevation, axo, model3d, kennzahlen). Tests: Kern `renovation_tests.rs` (19), Robustheit, vitest `model/renovation.test.ts`, `commands/cmds/renovation.test.ts`, e2e `renovation271.spec.ts` (2× grün, Port 5195; dazu `uxReview263`, `objectSettings`, `modelViews`, `release10`, `editing` grün); Bilder `doc/review-271/` (CLI-SVG `--hatch` in Chromium, App-Screenshot). **Offen:** 3D-Fenster nur im Code angebunden (Kern-Teile per Test geprüft, Bild nicht angesehen: kein render3d unter Linux); Blender-Paket ohne Umbau-Farben (nur Ausblenden); Ansichtsleiste/Werkzeugleiste ohne eigene Filter-Wahl (Statusleiste und Panel Umbau); eigene Filter nur im Modell (keine Bearbeitung in der Oberfläche); Tauri/Mac nicht geprüft (Prüfschritt `doc/RELEASE-1.0.md` 13.37). **Nachtrag 17.11. (Panel):** eigenes Dock-Panel „Umbau“ (`panels/RenovationPanel.tsx`, Reiter rechts oben neben Objekt-Info/Flächenbilanz, Layout v16): Zeichen-Status Bestand/Abbruch/Neu mit SIA-Farbmuster + Etappe, Umbaufilter der aktiven Ansicht als Liste mit Vorschau je Status (wie gezeichnet/ausgeblendet/Umbau-Farbe) + „bis Etappe“, Status der Auswahl (gemischt-Marke) mit Setzen und Etappe (ein Undo-Schritt), „Nach Status wählen“ (Geschoss), Etappenliste (anlegen, umbenennen, Reihenfolge, Löschen mit Rückfrage über `ui/ConfirmDialog`, Verweis auf die Farben in den Ressourcen). Statusleisten-Popover und Objekt-Info teilen Zustand und Aktionen mit dem Panel (`state/renovationHook.ts`, keine Doppelspur) und lesen nur schmale Teile des Projekts: behebt die 45 Renders je Wand-Änderung in `renderCount.spec.ts` (jetzt 42, Grenze unverändert; `RenovationField` ist `memo`). Filter-Vorschau der eingebauten Filter spiegelt `renovation::builtin` in `model/renovation.ts` (vitest prüft gegen den Plan des Kerns; sauberer wäre, die Anteile in `filter_list` mitzuliefern). Tests: vitest `model/renovation.test.ts` (+3), e2e `renovationPanel271.spec.ts` (Port 5193); Bild `doc/review-271/05-panel-umbau.png`. Nicht geprüft: Tauri/Mac. **Offen:** Panel-Bild nur hell/1280×800 angesehen (dunkel ebenfalls ok, schmale Leiste nicht eigens). **Nachtrag 17.11. (Exporte und Rendering folgen der Ansicht, mit [272]):** neue gemeinsame Ansicht `export/exportView.ts` (`levelExportView` = Umbaufilter, Etappe und Variantenkombination der aktiven Ebene; `exportViewText` = Text der Kern-Abfragen, `renovation::view_from_text`), die EIN Weg für IFC (`exportIfcSpf({view})`), OBJ/STL/glTF (`MeshOptions.view`), STEP (`exportProjectStep(…, view)`), Blender-Paket (`RenderOptions.view`) und Cycles-Szene ist. Ausgeblendetes fehlt dort; die Cycles-Szene malt Umbau-Farben nur auf Wunsch (Option `renovationColors`, `cycles_scene_styled`; Vorgabe Materialfarben). App: Export-Dialog (IFC, OBJ, STL, glTF, STEP) und Rendering-Dialog zeigen die Ansicht der aktiven Ebene („Umbau: …“, „Variante: …“) und lassen „Hauptvarianten/kein Filter“ wählen; Rendering mit Cycles hat das Häkchen „Umbau-Farben im Bild“ (aus). CLI `--renovation`/`--phase` jetzt auch für ifc, obj, stl, glb, gltf, step, render, blend; `render --engine cycles --renovation-colors`. Explosionsaxonometrie und 3D-Pick folgten dem Filter schon über `options_state` (Test `pick_und_explosion_ohne_ausgeblendete`); die Explosion bekommt jetzt auch die Umbau-Farben. Tests: Kern `export_view_tests.rs`, vitest `export/exportView.test.ts`, e2e `exportView271.spec.ts`; Bilder `doc/review-272/07-cycles-*.png`. **Nachtrag 17.11. (Rest Zeichnungen):** Ersatzstücke der Öffnungen jetzt auch im Schnitt (Rechteck der geschnittenen Öffnung, `section/openings.rs::section_patch_primitives`, Bogenwände über die Sehne) und in der Ansicht (Viereck der Öffnung, Fläche unter dem Fenster, gestrichelter Umriss darüber; geschlossene Wand: vor der Fassade, verdeckungsgeprüft), im Grundriss auch für Bogenwände (Ringstück zwischen den Versatzbögen); Projektionslinien des Schnitts (`Output::edge_ids` → `CutRules::edge`) und Öffnungen der Ansicht in Umbau-Farbe (Linien, bei Abbruch gestrichelt; Flächen behalten die Füllung). **2D-Elemente und Möbel:** `Drawing2D.renovation`; Möbel/Symbole (`libobj`, `block`) nehmen ohne Angabe als Bestand teil, übrige 2D-Elemente (Linien, Masse, Texte, Raster) nur mit ausdrücklichem Status (sonst wäre im Umbauplan alles grau); Farbe der Striche über `drawings::emit` (Bestand grau, Abbruch gelb gestrichelt, Neu rot), Ausblenden je Filter; Zeichen-Status stempelt Möbel und Linienwerk (`stamp_renovation`), Masse/Texte nicht. **Bäume:** zusammengeführt statt zweiter Wahrheit — der Bestand des Baums (`Tree.status`, [149]: bestehend/neu/zu fällen) IST der Umbau-Status (`renovation::tree_renovation`; bestehend = Bestand, zu fällen = Abbruch, neu = Neu), ohne neues Feld und ohne Etappe (gilt als Etappe 1); Plan, Schnitt, Ansicht in Statusfarbe bzw. ausgeblendet; Panel/Objekt-Info setzen für Bäume den `status`. Beispiel `:umbau` mit Sofa (Bestand), Tisch (Abbruch), Sofa im Anbau (Neu, Etappe 2), zwei Bäumen (zu fällen, neu) und Ansicht West. Tests: Kern `renovation_tests2.rs` (11: Möbel/Linien/Bäume je Filter, Endzustand ohne Abbruch-Möbel, Schnitt- und Ansichts-Ersatzstücke, Bogenwand, Projektionslinien, Unsinn robust), vitest `model/renovation.test.ts` (+1); Bilder `doc/review-271/06`–`09`. **Offen:** Ersatzstück nur dort, wo die Schnittebene die Öffnung trifft (Wand hinter der Ebene zeigt es in der Projektion nicht); Masse/Texte nehmen nur mit ausdrücklichem Status teil (Panel/Objekt-Info setzen ihn auf Auswahl); Tauri/Mac nicht geprüft. **Nachtrag 17.11. (Bäume verdeckt):** Bäume in Statusfarbe werden im Schnitt und in der Ansicht von näheren Bauteilen verdeckt, vor der Fassade nur als Umriss (Details und Bild: [149]). **Nachtrag 17.11. (DXF-Ebenen Möbel/Bäume):** Möbel/Symbole/2D-Elemente mit Status Abbruch/Neu und Bäume (`status` zu fällen/neu) liegen im DXF auf `__Abbruch` bzw. `_Neu` ihrer Kategorie (z. B. `22_Möbel_Neu`, `13_Bäume_Abbruch`), wie Wände (`plan/dxf.rs::renovation_layers`; Baumteile ohne eigene Id über `tag_tree_parts` der Pick-Fläche `@tree:` zugeordnet); Bestand bleibt auf der bisherigen Ebene. Test `renovation_tests2.rs::dxf_ebenen_fuer_moebel_und_baeume`; `:umbau` per CLI exportiert und Ebenen angesehen. Offen: Bäume/Möbel ohne Kategorie-Ebene im Projekt bleiben auf ihrer Ebene; Baum-Beschriftungen bleiben auf der Textebene. · M diff --git a/doc/review-281/01-rampe.png b/doc/review-281/01-rampe.png new file mode 100644 index 00000000..c1fa1bd3 Binary files /dev/null and b/doc/review-281/01-rampe.png differ diff --git a/e2e/ramp281.spec.ts b/e2e/ramp281.spec.ts new file mode 100644 index 00000000..4a4ee1c3 --- /dev/null +++ b/e2e/ramp281.spec.ts @@ -0,0 +1,46 @@ +// [281] Geneigte Decken und Rampen: Beispiel Wettbewerb (Eingangsrampe 6 % an der Ostfassade) öffnen, Gefällepfeil im +// Grundriss, Objekt-Info „Neigung“ (Gefälle ändern, Undo, ausschalten), Befehl „Rampe“ (Umriss, Gefällelinie, −12 %). +// Geprüft über das Modell (Test-Naht) und den Plan, nicht über Pixel; Screenshot für die Sichtprüfung in `test-results/`. +import { blurFocus, commandInput, discardIfAsked, expect, fileMenu, test, typeCommand } from "./app"; + +test("Rampe: Grundriss-Symbol, Objekt-Info Neigung mit Undo, Befehl Rampe ([281])", async ({ page }) => { + await page.goto("/?dossierTest"); + await page.getByRole("button", { name: /Neues Projekt/ }).first().click(); + await expect(page.getByRole("group", { name: "Befehlszeile" })).toBeVisible(); + await fileMenu(page, /^Neu aus Vorlage: Wettbewerb$/); + await discardIfAsked(page); + await expect(page.locator(".project-name")).toContainText("Wettbewerb"); + const slopes = () => page.evaluate(() => window.__dossierTest!.ceilingSlopes()); + await expect.poll(async () => (await slopes())["c-rampe"]).toEqual({ rise: -0.36, ramp: true }); + // Lauflinie der Rampe (Schaft + Pfeilspitze) im Grundriss EG. + await expect.poll(() => page.evaluate(() => window.__dossierTest!.planLines("ceiling-slope"))).toBeGreaterThanOrEqual(3); + + // Objekt-Info: Abschnitt Neigung, Modus Rampe, Gefälle 6 % → 8 % (Undo zurück). + await page.evaluate(() => window.__dossierTest!.select({ ceilings: ["c-rampe"] })); + await expect(page.getByTestId("objinfo-ceiling-slope-ramp")).toHaveClass(/active/); + const pct = page.getByTestId("objinfo-ceiling-slope-percent").locator("input"); + await expect(pct).toHaveValue("6.0"); + await pct.fill("8"); + await pct.press("Enter"); + await expect.poll(async () => (await slopes())["c-rampe"]?.rise).toBeCloseTo(-0.48, 6); + await page.screenshot({ path: "test-results/ramp281-objinfo.png" }); + await blurFocus(page); + await page.keyboard.press("ControlOrMeta+z"); + await expect.poll(async () => (await slopes())["c-rampe"]?.rise).toBeCloseTo(-0.36, 6); + // Ausschalten: waagrecht; Undo bringt die Rampe zurück. + await page.getByTestId("objinfo-ceiling-slope-off").click(); + await expect.poll(async () => (await slopes())["c-rampe"]).toBeUndefined(); + await blurFocus(page); + await page.keyboard.press("ControlOrMeta+z"); + await expect.poll(async () => (await slopes())["c-rampe"]?.ramp).toBe(true); + + // Befehl „Rampe“: Umriss 6 × 2 m, Gefällelinie längs, −12 % ⇒ Höhenunterschied −0.72 m. + await page.evaluate(() => window.__dossierTest!.select({ ceilings: [] })); + await typeCommand(page, "rampe"); + for (const p of ["30,0", "36,0", "36,2", "30,2"]) await typeCommand(page, p); + await commandInput(page).press("Enter"); + await typeCommand(page, "30,1"); + await typeCommand(page, "36,1"); + await typeCommand(page, "-12"); + await expect.poll(async () => Object.values(await slopes()).filter((s) => Math.abs(s.rise + 0.72) < 1e-6 && s.ramp).length).toBe(1); +}); diff --git a/src-tauri/core/src/ceiling_slope_tests.rs b/src-tauri/core/src/ceiling_slope_tests.rs new file mode 100644 index 00000000..1a9523dc --- /dev/null +++ b/src-tauri/core/src/ceiling_slope_tests.rs @@ -0,0 +1,213 @@ +//! [281] Geneigte Decken und Rampen: Neigungsebene, 3D-Platten, Schnitt, Ansicht, Grundriss-Symbol, IFC, Flächen. + +use crate::model::*; +use crate::plan::section::{compute_section, Kind, LevelSpec}; + +fn sample() -> Project { + serde_json::from_str(include_str!("../tests/fixtures/sample_project.json")).unwrap() +} + +/// Beispiel mit der Decke C1 (5 × 4 m, EG, OK 2.6 m) als Rampe längs x: steigt von x = 0 bis x = 5 um `rise`. +fn sloped(rise: f64, ramp: bool) -> Project { + let mut p = sample(); + let c = &mut p.ceilings.as_mut().unwrap()[0]; + c.slope = Some(CeilingSlope { from: Vec2 { x: 0.0, y: 2.0 }, to: Vec2 { x: 5.0, y: 2.0 }, rise, ramp: ramp.then_some(true), ..Default::default() }); + p +} + +#[test] +fn neigungsebene_und_hoehenspanne() { + let p = sloped(0.75, false); + let c = &p.ceilings.as_ref().unwrap()[0]; + let g = c.slope_plane().unwrap(); + assert!((g[2] - 0.15).abs() < 1e-12 && g[3].abs() < 1e-12, "{g:?}"); + assert!((c.slope_dz(5.0, 3.0) - 0.75).abs() < 1e-12 && c.slope_dz(0.0, -7.0).abs() < 1e-12); + let (zb, zt) = p.ceiling_vertical_extent(c); + let (lo, hi) = p.ceiling_vertical_span(c); + assert!((lo - zb).abs() < 1e-12 && (hi - zt - 0.75).abs() < 1e-12, "{lo} {hi}"); + // Entartet: Gefällelinie zu kurz, Höhe 0 oder NaN ⇒ waagrecht. + for (to, rise) in [((0.0, 2.0), 1.0), ((5.0, 2.0), 0.0), ((5.0, 2.0), f64::NAN)] { + let mut q = sloped(rise, false); + q.ceilings.as_mut().unwrap()[0].slope.as_mut().unwrap().to = Vec2 { x: to.0, y: to.1 }; + let c = &q.ceilings.as_ref().unwrap()[0]; + assert!(c.slope_plane().is_none() && c.slope_dz(3.0, 3.0) == 0.0); + } + assert!(!p.ceilings.as_ref().unwrap()[0].is_ramp() && sloped(0.5, true).ceilings.as_ref().unwrap()[0].is_ramp()); +} + +/// Die Neigung übersteht die Projektdatei (serde) und das Dokument (Ops). +#[test] +fn neigung_in_datei_und_ops() { + let p = sloped(-0.6, true); + let v = serde_json::to_value(&p.ceilings.as_ref().unwrap()[0]).unwrap(); + assert_eq!(v["slope"], serde_json::json!({"from": {"x": 0.0, "y": 2.0}, "to": {"x": 5.0, "y": 2.0}, "rise": -0.6, "ramp": true})); + let back: Ceiling = serde_json::from_value(v).unwrap(); + assert_eq!(back.slope, p.ceilings.as_ref().unwrap()[0].slope); +} + +/// 3D: alle Schichtplatten tragen die Neigungsebene; das Netz (render3d) liegt am oberen Ende um `rise` höher. +#[test] +fn platten_und_netz_folgen_der_neigung() { + let p = sloped(0.75, false); + let slabs = crate::model3d::emit_slabs(&p); + assert!(!slabs.is_empty()); + assert!(slabs.iter().all(|s| s.slope.is_some())); + let flat = crate::model3d::emit_slabs(&sample()); + assert_eq!(flat.len(), slabs.len()); + let top = slabs.iter().map(|s| s.z_top).fold(f64::NEG_INFINITY, f64::max); + let si = crate::plan::section::slab_input_pub(&slabs[0]); + let mut m = render3d::Mesh::default(); + render3d::extrude_slab(&mut m, &si); + let ys: Vec<(f32, f32)> = m.verts.chunks(render3d::FLOATS_PER_VERTEX).map(|v| (v[0], v[1])).collect(); + let max_at = |x: f32| ys.iter().filter(|q| (q.0 - x).abs() < 0.3).map(|q| q.1).fold(f32::MIN, f32::max); + // Der Plattenrand kann um das Auflager eingezogen sein: Höhe am Rand = OK + 0.15 · x. + let x_hi = ys.iter().map(|q| q.0).fold(f32::MIN, f32::max); + assert!((max_at(x_hi) as f64 - (top + 0.15 * x_hi as f64)).abs() < 2e-3, "{} {}", max_at(x_hi), top); +} + +fn section_x(p: &Project) -> crate::plan::section::Output { + let l = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: -2.0, y: 2.0 }, Vec2 { x: 7.0, y: 2.0 }]), ..Default::default() }; + compute_section(p, &l, &[]).unwrap().unwrap() +} + +/// Schnitt längs der Gefällelinie: die Deckenbänder sind schräg (Höhe an beiden Enden um `rise` verschieden), alle +/// Schichten parallel; quer geschnitten bleiben sie Rechtecke (gleiche Höhe über die Breite), aber höher. +#[test] +fn schnitt_laengs_und_quer() { + let flat = section_x(&sample()); + let p = sloped(0.75, false); + let o = section_x(&p); + let slab_cuts = |o: &crate::plan::section::Output| o.cuts.iter().filter(|c| c.kind == Kind::Slab && c.source_id.as_deref() == Some("C1")).map(|c| c.pts.clone()).collect::>(); + let (a, b) = (slab_cuts(&flat), slab_cuts(&o)); + assert!(!b.is_empty() && a.len() == b.len(), "{} {}", a.len(), b.len()); + // Je Band: Oberkante links/rechts; geneigt: Höhenunterschied = 0.15 × Bandlänge. + for ring in &b { + let (u0, u1) = ring.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(a, b), q| (a.min(q[0]), b.max(q[0]))); + let v_at = |u: f64| ring.iter().filter(|q| (q[0] - u).abs() < 1e-6).map(|q| q[1]).fold(f64::NEG_INFINITY, f64::max); + assert!(((v_at(u1) - v_at(u0)) - 0.15 * (u1 - u0)).abs() < 1e-4, "{ring:?}"); + } + // Quer (bei x = 4): Rechtecke, um 0.6 m höher als waagrecht. + let lq = LevelSpec { kind: "section".into(), line: Some([Vec2 { x: 4.0, y: -2.0 }, Vec2 { x: 4.0, y: 6.0 }]), ..Default::default() }; + let q0 = compute_section(&sample(), &lq, &[]).unwrap().unwrap(); + let q1 = compute_section(&p, &lq, &[]).unwrap().unwrap(); + let top = |o: &crate::plan::section::Output| o.cuts.iter().filter(|c| c.kind == Kind::Slab && c.source_id.as_deref() == Some("C1")).flat_map(|c| c.pts.iter().map(|q| q[1])).fold(f64::NEG_INFINITY, f64::max); + assert!((top(&q1) - top(&q0) - 0.6).abs() < 1e-4, "{} {}", top(&q1), top(&q0)); +} + +/// Ansicht: eine Auskragung (Balkon vor der Südfassade) mit Neigung zeigt ihre Stirn schräg: Oberkante am +/// oberen Ende um `rise` höher. +#[test] +fn ansicht_zeigt_die_neigung() { + let balcony = |p: &mut Project| { + let c = &mut p.ceilings.as_mut().unwrap()[0]; + c.outline = vec![Vec2 { x: 0.0, y: -1.5 }, Vec2 { x: 5.0, y: -1.5 }, Vec2 { x: 5.0, y: -0.5 }, Vec2 { x: 0.0, y: -0.5 }]; + c.edge_at_outline = Some(true); + }; + let ys = |p: &Project| { + let l = p.drawing_levels.iter().find(|l| l.id == "ansicht-sued").unwrap(); + let lv = LevelSpec::from_json(&serde_json::to_value(l).unwrap()); + let (prims, _) = crate::plan::elevation::elevation_primitives(p, &lv, false, false, &Default::default(), 100.0).unwrap().unwrap(); + prims + .iter() + .flat_map(|q| match q { + crate::plan::prim::Primitive::Polygon { pts, .. } => pts.iter().map(|v| v.y).collect::>(), + crate::plan::prim::Primitive::Line { a, b, .. } => vec![a.y, b.y], + _ => vec![], + }) + .collect::>() + }; + let mut a = sample(); + balcony(&mut a); + let mut b = sloped(0.75, false); + balcony(&mut b); + let (_, zt) = a.ceiling_vertical_extent(&a.ceilings.as_ref().unwrap()[0]); + let has = |v: &[f64], z: f64| v.iter().any(|y| (y.abs() - z).abs() < 0.02); + assert!(!has(&ys(&a), zt + 0.75), "waagrecht ohne {}", zt + 0.75); + let (ya, yb) = (ys(&a), ys(&b)); + let mut extra: Vec = yb.iter().copied().filter(|y| !ya.iter().any(|x| (x - y).abs() < 1e-6)).collect(); + extra.sort_by(f64::total_cmp); + extra.dedup_by(|x, y| (*x - *y).abs() < 1e-4); + assert!(has(&yb, zt + 0.75), "geneigt: Oberkante {} fehlt; neu: {extra:?}; a: {:?}", zt + 0.75, (ya.iter().cloned().fold(f64::INFINITY, f64::min), ya.iter().cloned().fold(f64::NEG_INFINITY, f64::max))); +} + +fn plan_ceilings(p: &Project, show: &[&str]) -> Vec { + let t = serde_json::json!({ "floor": "eg", "show": show, "grey": [], "scale": 50 }).to_string(); + crate::plan::domains::plan_domains(p, &crate::plan::domains::PlanArgs::parse(1.0, &t).unwrap()).unwrap().ceilings +} + +/// Grundriss: Gefällepfeil abwärts mit „%“-Text auf der Deckenklasse; Rampe mit Lauflinie über die Länge, Antrittskreis +/// unten, Pfeil oben; ausgeblendete Klasse ⇒ kein Symbol ([180]). +#[test] +fn grundriss_pfeil_und_rampe() { + use crate::plan::prim::Primitive; + let lines = |prims: &[Primitive]| prims.iter().filter_map(|q| match q { Primitive::Line { a, b, cls, .. } if cls == "ceiling-slope" => Some((*a, *b)), _ => None }).collect::>(); + let texts = |prims: &[Primitive]| prims.iter().filter_map(|q| match q { Primitive::DrawingText { text, .. } => Some(text.clone()), _ => None }).collect::>(); + assert!(lines(&plan_ceilings(&sample(), &["30"])).is_empty()); + let g = plan_ceilings(&sloped(0.1, false), &["30"]); + assert_eq!(texts(&g), vec!["2 %".to_string()]); + let l = lines(&g); + assert_eq!(l.len(), 3, "Schaft + 2 Spitzenstriche"); + // Gefälle abwärts: die Spitze (Ende des Schafts) liegt links (x klein), weil die Decke nach +x steigt. + assert!(l[0].1.x < l[0].0.x, "{l:?}"); + let r = plan_ceilings(&sloped(-0.75, true), &["30"]); + assert_eq!(texts(&r), vec!["15 %".to_string()]); + let l = lines(&r); + // Rampe aufwärts (nach −x), Lauflinie fast über die ganze Länge (5 m, Einzug ≤ 10 %). + assert!(l[0].1.x < l[0].0.x && (l[0].0.x - l[0].1.x) > 4.0, "{l:?}"); + assert!(r.iter().any(|q| matches!(q, Primitive::DrawingCircle { .. })), "Antrittskreis"); + assert!(plan_ceilings(&sloped(-0.75, true), &["20"]).is_empty(), "Klasse aus"); + assert_eq!(crate::plan::domains::slope_percent_text(1.5), "1.5 %"); + assert_eq!(crate::plan::domains::slope_percent_text(-18.0), "18 %"); +} + +/// IFC: geneigte Decke als Netz (IfcSlab), Rampe als Datensatz mit Rampen-Kennung und Rampenlauf-Mengen; die Fläche +/// (Grundrissprojektion) und das Volumen (lotrechte Dicke × Fläche) bleiben wie waagrecht. +#[test] +fn ifc_netz_und_rampe() { + let f = crate::ifc_data::ifc_export_data(&sloped(0.75, false), &Default::default()).unwrap(); + assert!(f.nums.contains(&26.0)); + assert!(f.strings.iter().any(|s| s == "Qto_SlabBaseQuantities")); + let f = crate::ifc_data::ifc_export_data(&sloped(-0.75, true), &Default::default()).unwrap(); + assert!(f.strings.iter().any(|s| s == "Qto_RampFlightBaseQuantities") && f.strings.iter().any(|s| s == "Pset_RampFlightCommon")); + // Netz: dicht und Volumen = Fläche × Dicke. + let (pos, idx) = crate::ifc_data::sloped_slab_mesh(&[[0.0, 0.0], [5.0, 0.0], [5.0, 4.0], [0.0, 4.0]], &[vec![[1.0, 1.0], [2.0, 1.0], [2.0, 2.0], [1.0, 2.0]]], 0.0, 0.3, &[0.0, 0.0, 0.15, 0.0]); + assert!(crate::wall_mesh_cut::is_watertight(&pos, &idx, 1e-6) || !idx.is_empty()); + let v = crate::export_flat::mesh_volume(&pos, &idx); + assert!((v - 19.0 * 0.3).abs() < 1e-3, "{v}"); +} + +/// SIA 416: Flächen unverändert (Projektion), GV unverändert (aus Geschossflächen und -höhen). +#[test] +fn flaechen_und_gv_unveraendert() { + let a = crate::flaechen::area_table(&sample()); + let b = crate::flaechen::area_table(&sloped(-0.75, true)); + assert_eq!(serde_json::to_value(&a).unwrap(), serde_json::to_value(&b).unwrap()); +} + +/// Abzugskörper in einer geneigten Decke: der Körper (Manifold) folgt der Neigung, Volumen = Fläche × Dicke. +#[test] +fn koerper_mit_neigung() { + let spec = serde_json::json!({"kind": "extrude", "points": [0, 0, 4, 0, 4, 2, 0, 2], "height": 0.25, "z0": 1.0, "slope": [0.0, 0.0, 0.2, 0.0]}); + let s = crate::solid_mesh::spec_solid(&spec, 0).unwrap(); + let m = s.to_mesh(); + let zmax = m.positions.chunks(3).map(|q| q[2]).fold(f64::NEG_INFINITY, f64::max); + assert!((zmax - 2.05).abs() < 1e-6, "{zmax}"); + assert!((s.volume() - 2.0).abs() < 1e-6, "{}", s.volume()); +} + +/// Öffnung unter einer geneigten Decke endet an deren tiefster Unterkante über der Öffnung ([234] mit [281]). +#[test] +fn oeffnung_unter_geneigter_decke() { + let p = sloped(-1.0, false); + let o = p.openings.iter().flatten().find(|o| o.id == "O1").unwrap(); + let w = p.walls.iter().find(|w| w.id == o.host_wall_id).unwrap(); + let c = &p.ceilings.as_ref().unwrap()[0]; + let (zb, _) = p.ceiling_vertical_extent(c); + let (bottom, top) = (0.9, 2.1); + assert_eq!(sample().opening_top_under_ceilings(w, o, bottom, top), top, "waagrecht: UK über dem Sturz"); + let cap = p.opening_top_under_ceilings(w, o, bottom, top); + // Tiefste Probe am Öffnungsende (x ≈ Lage + Breite − 2 cm): UK − 0.2 · x. + let x_end = w.start.x + (o.position + o.width - 0.02); + assert!((cap - (zb - 0.2 * x_end)).abs() < 0.02, "{cap} {zb} {x_end}"); + assert!(cap > bottom && cap < top); +} diff --git a/src-tauri/core/src/cmd_create.rs b/src-tauri/core/src/cmd_create.rs index 1ff49f05..0c3b497e 100644 --- a/src-tauri/core/src/cmd_create.rs +++ b/src-tauri/core/src/cmd_create.rs @@ -451,6 +451,23 @@ fn ceiling_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec { add_op("ceilings", vec![ceiling_item(p, ctx.level, &outline, ctx, ids)]) } +/// [281] Rampe: Decke aus dem Umriss mit Neigung längs `from` → `to`; `percent` = Gefälle in % (positiv = steigt zum +/// Endpunkt). Die Oberkante liegt am Anfang auf der Geschosshöhe (Boden des aktiven Geschosses), nicht an der +/// Geschossoberkante wie eine Geschossdecke. Entartet (Umriss, Gefällelinie < 1 cm, Gefälle 0/NaN) → nichts. +fn ramp_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec { + let Some(outline) = normalize_outline(&pts_of(v, "pts")) else { return Vec::new() }; + let (from, to) = (p_of(v, "from"), p_of(v, "to")); + let len = (to.0 - from.0).hypot(to.1 - from.1); + let pct = opt_n(v, "percent").unwrap_or(f64::NAN); + if abs_area(&outline) < 1e-4 || !(len > 0.01) || !pct.is_finite() || pct == 0.0 || pct.abs() > 100.0 { + return Vec::new(); + } + let mut item = ceiling_item(p, ctx.level, &outline, ctx, ids); + item["top"] = json!({"mode": "floor", "floorId": ctx.level, "offset": 0}); + item["slope"] = json!({"from": pv(from), "to": pv(to), "rise": js_num(pct / 100.0 * len), "ramp": true}); + add_op("ceilings", vec![item]) +} + /// Neue Decke auf Geschoss `floor` mit dem Umriss `outline` (Aufbau wie beim Zeichnen; auch [222]). pub(crate) fn ceiling_item(p: &Project, floor: &str, outline: &[V], ctx: &Ctx, ids: &mut IdGen) -> Value { let mut fields = vec![ @@ -1189,6 +1206,7 @@ pub fn ops(root: &Map, p: &Project, v: &Value) -> Option> Some(match s_of(v, "cmd") { "wall" => wall_ops(root, p, v, &ctx, ids), "ceiling" => ceiling_ops(p, v, &ctx, ids), + "ramp" => ramp_ops(p, v, &ctx, ids), "room" => room_ops(p, v, &ctx, ids), "wand" => wand_ops(p, v, &ctx, ids), // [154] Bauteile aus Zeichnung erkennen. @@ -1444,6 +1462,29 @@ mod tests { assert!(items(&o, 0)[0].get("ceilingTypeId").is_none()); } + /// [281] Rampe: Decke mit Neigung (Gefälle in % längs Anfang → Ende), OK am Anfang auf dem Geschossboden; + /// Unsinn (Gefälle 0, Linie zu kurz) legt nichts an. + #[test] + fn rampe_mit_gefaelle() { + let ct = json!([{"id": "CT1", "name": "Stahlbetondecke", "layers": [{"componentId": "c", "thickness": 0.25}]}]); + let r = root(json!({"wallTypes": [{"id": "WT1", "name": "W", "layers": [{"componentId": "c", "thickness": 0.3}]}], "ceilingTypes": ct})); + let base = json!({"cmd": "ramp", "pts": [[0, 0], [10, 0], [10, 3], [0, 3]], "from": [0, 1.5], "to": [10, 1.5], "percent": -15}); + let o = ops(&r, &crate::model::lenient::typed_for_test(&r), &req(base.clone())).unwrap(); + let c = &items(&o, 0)[0]; + assert_eq!(c["slope"]["ramp"], true); + assert!((c["slope"]["rise"].as_f64().unwrap() + 1.5).abs() < 1e-9, "{c}"); + assert_eq!(c["top"], json!({"mode": "floor", "floorId": "F1", "offset": 0})); + assert_eq!(c["ceilingTypeId"], "CT1"); + for bad in [json!(0), json!(null), json!(150)] { + let mut v = base.clone(); + v["percent"] = bad; + assert!(ops(&r, &crate::model::lenient::typed_for_test(&r), &req(v)).unwrap().is_empty()); + } + let mut v = base; + v["to"] = json!([0, 1.505]); + assert!(ops(&r, &crate::model::lenient::typed_for_test(&r), &req(v)).unwrap().is_empty()); + } + #[test] fn waende_je_segment_mit_typ_und_hoehe() { let r = root(json!({"wallTypes": [{"id": "WT1", "name": "Beton", "layers": [{"componentId": "c", "thickness": 0.2}]}]})); diff --git a/src-tauri/core/src/highlight3d.rs b/src-tauri/core/src/highlight3d.rs index 2938307f..328e6e4a 100644 --- a/src-tauri/core/src/highlight3d.rs +++ b/src-tauri/core/src/highlight3d.rs @@ -152,12 +152,18 @@ impl Out { /// Prisma über dem Grundriss `outline` von `z_bottom` bis `z_top`. fn prism_edges(&mut self, outline: &[[f64; 2]], z_bottom: f64, z_top: f64) { + self.prism_edges_sloped(outline, z_bottom, z_top, None); + } + + /// Wie [`Self::prism_edges`]; [281] geneigte Platte: jede Höhe um den Versatz der Neigungsebene verschoben. + fn prism_edges_sloped(&mut self, outline: &[[f64; 2]], z_bottom: f64, z_top: f64, slope: Option<&[f64; 4]>) { let n = outline.len(); if n < 3 || z_top - z_bottom <= EPS { return; } - let bottom = |i: usize| [outline[i][0], z_bottom, outline[i][1]]; - let top = |i: usize| [outline[i][0], z_top, outline[i][1]]; + let d = |i: usize| slope.map_or(0.0, |g| crate::model::helpers::slope_dz(g, outline[i][0], outline[i][1])); + let bottom = |i: usize| [outline[i][0], z_bottom + d(i), outline[i][1]]; + let top = |i: usize| [outline[i][0], z_top + d(i), outline[i][1]]; let mut j = n - 1; for i in 0..n { self.edge(bottom(j), bottom(i)); @@ -220,7 +226,7 @@ pub fn selection_highlight_lines(p: &Project, a: &Args) -> Result, Stri for s in emit_slabs(p) { if ceilings.contains(s.ceiling_id.as_str()) { let n = out.v.len(); - out.prism_edges(&s.outline, s.z_bottom, s.z_top); + out.prism_edges_sloped(&s.outline, s.z_bottom, s.z_top, s.slope.as_ref()); lift(&mut out, n, &s.ceiling_id); } } diff --git a/src-tauri/core/src/ifc_data.rs b/src-tauri/core/src/ifc_data.rs index 96ef7bf2..6fe06b5b 100644 --- a/src-tauri/core/src/ifc_data.rs +++ b/src-tauri/core/src/ifc_data.rs @@ -59,6 +59,8 @@ const REC_GUIDS: f64 = 23.0; const REC_CONTEXT: f64 = 24.0; const REC_LAYERS: f64 = 25.0; const REC_RAILING: f64 = 26.0; +/// [281] Geneigte Decke als Netz; Rampe ⇒ `IfcRamp` mit `IfcRampFlight`. +const REC_CEILING_MESH: f64 = 27.0; /// Toleranz des Kerns (`wall_bands.rs::EPS`) für „Öffnung trifft Band". const BAND_EPS: f64 = 1e-4; @@ -876,6 +878,39 @@ fn add_back(quantities: &mut [Qty], (area, volume): (f64, f64)) { } } +/// [281] Netz einer geneigten Platte (Modell x, y, z; nach aussen gewickelt): Umriss mit Aussparungen (über Brücken +/// eingefügt), Unterseite bei `z0`, Dicke `depth` lotrecht, jede Höhe um den Versatz der Neigungsebene `g`. +pub(crate) fn sloped_slab_mesh(outline: &[[f64; 2]], holes: &[Vec<[f64; 2]>], z0: f64, depth: f64, g: &[f64; 4]) -> (Vec, Vec) { + let merged = crate::polygon_holes::merge_holes(outline, holes, 1e-4); + let mut ring = merged.ring; + if ring.len() < 3 || !(depth > 0.0) { + return (Vec::new(), Vec::new()); + } + let area: f64 = (0..ring.len()).map(|i| { let (a, b) = (ring[i], ring[(i + 1) % ring.len()]); a[0] * b[1] - b[0] * a[1] }).sum(); + if area < 0.0 { + ring.reverse(); + } + let n = ring.len() as u32; + let mut positions = Vec::with_capacity(ring.len() * 6); + for z in [z0, z0 + depth] { + for q in &ring { + positions.extend_from_slice(&[q[0], q[1], z + crate::model::helpers::slope_dz(g, q[0], q[1])]); + } + } + let tris = dossier_hatch::ear_clip::triangulate(&ring); + let mut indices = Vec::with_capacity(tris.len() * 2 + ring.len() * 6); + for t in tris.chunks_exact(3) { + // Unterseite nach unten (umgekehrt), Oberseite nach oben (CCW). + indices.extend_from_slice(&[t[0], t[2], t[1]]); + indices.extend_from_slice(&[n + t[0], n + t[1], n + t[2]]); + } + for i in 0..n { + let j = (i + 1) % n; + indices.extend_from_slice(&[i, j, n + j, i, n + j, n + i]); + } + (positions, indices) +} + fn push_box(positions: &mut Vec, indices: &mut Vec, b: &[f64; 24], base: f64) { let at = (positions.len() / 3) as u32; for c in b.chunks_exact(3) { @@ -1446,6 +1481,36 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result // [191] Bögen im Umriss: Mengen auf dem fein geteilten Ring, Profil mit echten Bögen (s. unten). let outline = c.ring(); psets.extend(qto("Qto_SlabBaseQuantities", qty::slab_quantities(&outline, &inner, z_top - z_bottom))); + // [281] Geneigte Decke/Rampe: Körper als Netz (Ober- und Unterseite in der Neigungsebene, Ränder lotrecht). + if let Some(g) = c.slope_plane() { + let ring: Vec<[f64; 2]> = outline.iter().map(|v| [v.x, v.y]).collect(); + let holes: Vec> = inner.iter().map(|r| r.iter().map(|v| [v.x, v.y]).collect()).collect(); + let (positions, indices) = sloped_slab_mesh(&ring, &holes, z_bottom - base_of(structure), z_top - z_bottom, &g); + if indices.is_empty() { + continue; + } + let closed = is_watertight(&positions, &indices, 1e-6); + // Rampe: Eigenschaften und Mengen am Rampenlauf (IFC4 `Pset_RampFlightCommon`, `Qto_RampFlightBaseQuantities` + // ohne Breite/Umfang der Platte; Flächen = Grundrissprojektion, Volumen exakt, da die Dicke lotrecht ist). + if c.is_ramp() { + for ps in psets.iter_mut() { + match ps.name { + "Pset_SlabCommon" => ps.name = "Pset_RampFlightCommon", + "Qto_SlabBaseQuantities" => { + ps.name = "Qto_RampFlightBaseQuantities"; + ps.props.retain(|p| !matches!(p, Prop::Qty("Width" | "Perimeter", _, _))); + } + _ => {} + } + } + } + w_head(&mut f, REC_CEILING_MESH, structure, &c.id, &name); + w_type(&mut f, ty.as_ref().map(|t| type_ref(t, 1.0, "FLOOR")).as_ref()); + w_psets(&mut f, &psets); + f.num(if c.is_ramp() { 1.0 } else { 0.0 }); + w_mesh(&mut f, &positions, &indices, closed); + continue; + } // Mit Bögen: Profil als IfcCompositeCurve (CEILING_ARC); die gehosteten Fensteröffnungen sind gerade. let arcs = c.has_arcs(); w_head(&mut f, if arcs { REC_CEILING_ARC } else { REC_CEILING }, structure, &c.id, &name); diff --git a/src-tauri/core/src/lib.rs b/src-tauri/core/src/lib.rs index 45cecccf..dd17b993 100644 --- a/src-tauri/core/src/lib.rs +++ b/src-tauri/core/src/lib.rs @@ -165,3 +165,5 @@ pub mod kosten; pub mod woff2; #[cfg(test)] mod wall_join3d_tests; +#[cfg(test)] +mod ceiling_slope_tests; diff --git a/src-tauri/core/src/mesh_data.rs b/src-tauri/core/src/mesh_data.rs index fc6aad36..31abe6b0 100644 --- a/src-tauri/core/src/mesh_data.rs +++ b/src-tauri/core/src/mesh_data.rs @@ -245,6 +245,12 @@ fn signed_area_xy(pts: &[Vec2]) -> f64 { /// Extrudiertes Umriss-Prisma (Decke, Treppen-Tritt, Extrusion): Kappen + Mantel, aussen gewunden; /// `taper` (0..1) verjüngt den oberen Ring linear zum Schwerpunkt. fn push_prism(g: &mut Prim, outline: &[Vec2], z_bottom: f64, z_top: f64, taper: f64) { + push_prism_sloped(g, outline, z_bottom, z_top, taper, None); +} + +/// Wie [`push_prism`]; [281] `slope` (Neigungsebene `[ox, oy, gx, gy]`) versetzt jede Höhe (geneigte Decke). +fn push_prism_sloped(g: &mut Prim, outline: &[Vec2], z_bottom: f64, z_top: f64, taper: f64, slope: Option<&[f64; 4]>) { + let dz = |x: f64, y: f64| slope.map_or(0.0, |s| crate::model::helpers::slope_dz(s, x, y)); if outline.len() < 3 || z_top - z_bottom <= 1e-9 { return; } @@ -260,10 +266,11 @@ fn push_prism(g: &mut Prim, outline: &[Vec2], z_bottom: f64, z_top: f64, taper: let t = min(1.0, max(0.0, taper)); let base = (g.positions.len() / 3) as f64; for p in &ccw { - g.positions.extend_from_slice(&[p.x, z_bottom, p.y]); + g.positions.extend_from_slice(&[p.x, z_bottom + dz(p.x, p.y), p.y]); } for p in &ccw { - g.positions.extend_from_slice(&[cx + (p.x - cx) * (1.0 - t), z_top, cy + (p.y - cy) * (1.0 - t)]); + let (x, y) = (cx + (p.x - cx) * (1.0 - t), cy + (p.y - cy) * (1.0 - t)); + g.positions.extend_from_slice(&[x, z_top + dz(x, y), y]); } let nf = n as f64; let cap = crate::gpu_compile::triangulate(&ccw.iter().map(|p| crate::hatch::v2(p.x, p.y)).collect::>()); @@ -436,7 +443,7 @@ pub(crate) fn collect_scene(src: &Project, opt: &MeshOptions) -> Result = s.outline.iter().map(|q| Vec2 { x: q[0], y: q[1] }).collect(); let mat = mats.solid(&component_name(&p, s.cut.as_ref().and_then(|c| c.component_id.as_deref()), "Decke"), s.color); - push_prism(g.prim(mat), &outline, s.z_bottom, s.z_top, 0.0); + push_prism_sloped(g.prim(mat), &outline, s.z_bottom, s.z_top, 0.0, s.slope.as_ref()); groups.push(g); } diff --git a/src-tauri/core/src/model/generated.rs b/src-tauri/core/src/model/generated.rs index cab173f6..9fb8380c 100644 --- a/src-tauri/core/src/model/generated.rs +++ b/src-tauri/core/src/model/generated.rs @@ -3511,6 +3511,29 @@ pub struct Wall { pub extra: Extra, } +/// [281] Neigung einer Decke oder Rampe: Ober- und Unterkante (alle Schichten) folgen einer Ebene, die +/// längs der Gefällelinie `from` → `to` gleichmässig steigt oder fällt. Am Bezugspunkt `from` liegt die Decke +/// auf ihrer eingestellten Höhe (`top`/`bottom`); bei `to` um `rise` höher (negativ = tiefer). Quer zur +/// Gefällelinie bleibt die Höhe gleich. Die Dicke bleibt lotrecht gemessen (Schichten verschoben, nicht gedreht). +/// Gefälle in % = `rise` / |`to` − `from`| · 100. +#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)] +#[serde(default)] +pub struct CeilingSlope { + /// Bezugspunkt im Grundriss (Meter): dort gilt die eingestellte Höhe der Decke. + pub from: Vec2, + /// Zweiter Punkt der Gefällelinie (Meter); die Richtung `from` → `to` ist die Fallinie. + pub to: Vec2, + /// Höhenunterschied der Decke von `from` nach `to` (Meter; positiv = steigt zu `to`). + pub rise: f64, + /// Als Rampe darstellen: Grundriss mit Lauflinie und Pfeil (aufwärts), IFC als `IfcRamp`/`IfcRampFlight`. + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub ramp: Option, + #[serde(flatten)] + #[ts(skip)] + pub extra: Extra, +} + /// Eine Decke (Slab) — ein geschossgebundenes, mehrschichtiges Flächenbauteil, /// definiert über einen GESCHLOSSENEN Umriss (Polygon) im Grundriss und eine /// Dicke. Analog zur Wand trägt sie ihren Schichtaufbau über einen `wallTypeId` @@ -3664,6 +3687,10 @@ pub struct Ceiling { #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub bottom: Option, + /// [281] Neigung (geneigte Decke, Rampe, Gefälle). Fehlt ⇒ waagrecht. + #[serde(default, skip_serializing_if = "Option::is_none")] + #[ts(optional)] + pub slope: Option, /// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] diff --git a/src-tauri/core/src/model/helpers.rs b/src-tauri/core/src/model/helpers.rs index 570bf77e..60aefc75 100644 --- a/src-tauri/core/src/model/helpers.rs +++ b/src-tauri/core/src/model/helpers.rs @@ -195,25 +195,39 @@ impl Project { let ring = |r: &[Vec2]| -> Vec { r.iter().map(|q| kernel2d::Vec2::new(q.x, q.y)).collect() }; let mut cap = top; for c in ceilings { - let (cb, ct) = self.ceiling_vertical_extent(c); - if !(cb > bottom + 1e-6 && cb < cap - 1e-6 && ct > cb) || c.outline.len() < 3 { + let (cb0, ct) = self.ceiling_vertical_extent(c); + if !(ct > cb0) || c.outline.len() < 3 { continue; } let outline = ring(&c.outline); let holes: Vec> = c.openings.iter().flatten().map(|h| ring(h)).collect(); - let under = probes.iter().any(|&q| kernel2d::point_in_outline(q, &outline) && !holes.iter().any(|h| h.len() >= 3 && kernel2d::point_in_outline(q, h))); - if under { + // [281] Geneigte Decke: tiefste Unterkante über den Proben unter der Decke. + let cb = probes + .iter() + .filter(|&&q| kernel2d::point_in_outline(q, &outline) && !holes.iter().any(|h| h.len() >= 3 && kernel2d::point_in_outline(q, h))) + .map(|q| cb0 + c.slope_dz(q.x, q.y)) + .fold(f64::NAN, f64::min); + if cb > bottom + 1e-6 && cb < cap - 1e-6 { cap = cb; } } cap } + /// (UK, OK) einer Decke am Bezugspunkt; [281] eine geneigte Decke liegt anderswo um [`Ceiling::slope_dz`] + /// höher oder tiefer (Spanne über den Umriss: [`Self::ceiling_vertical_span`]). pub fn ceiling_vertical_extent(&self, c: &Ceiling) -> (f64, f64) { let floor_top = self.floor(&c.floor_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0) + f.floor_height.unwrap_or(0.0)); heights::ceiling(floor_top, self.resolve_anchor(c.bottom.as_ref()), self.resolve_anchor(c.top.as_ref()), || self.ceiling_thickness(c)) } + /// [281] (tiefste UK, höchste OK) einer Decke über ihren ganzen Umriss (waagrecht = [`Self::ceiling_vertical_extent`]). + pub fn ceiling_vertical_span(&self, c: &Ceiling) -> (f64, f64) { + let (zb, zt) = self.ceiling_vertical_extent(c); + let (lo, hi) = c.slope_range(); + (zb + lo, zt + hi) + } + pub fn stair_vertical_extent(&self, s: &Stair) -> (f64, f64) { let (base, floor_height) = self.floor(&s.floor_id).map_or((0.0, 0.0), |f| (f.base_elevation.unwrap_or(0.0), f.floor_height.unwrap_or(0.0))); let rise = match s.total_rise { @@ -365,3 +379,44 @@ pub mod heights { } } } + +impl Ceiling { + /// [281] Neigungsebene `[ox, oy, gx, gy]`: Höhenversatz `dz = gx·(x − ox) + gy·(y − oy)` gegenüber der + /// eingestellten Höhe. `None` ohne Neigung, mit entarteter Gefällelinie (< 1 mm) oder Unsinn (NaN). + pub fn slope_plane(&self) -> Option<[f64; 4]> { + let s = self.slope.as_ref()?; + let (dx, dy) = (s.to.x - s.from.x, s.to.y - s.from.y); + let l2 = dx * dx + dy * dy; + if !(l2 > 1e-6) || !s.rise.is_finite() || s.rise == 0.0 || !s.from.x.is_finite() || !s.from.y.is_finite() || !l2.is_finite() { + return None; + } + Some([s.from.x, s.from.y, s.rise * dx / l2, s.rise * dy / l2]) + } + + /// [281] Höhenversatz der geneigten Decke am Grundrisspunkt (x, y); waagrecht 0. + pub fn slope_dz(&self, x: f64, y: f64) -> f64 { + self.slope_plane().map_or(0.0, |g| slope_dz(&g, x, y)) + } + + /// [281] Als Rampe dargestellt (Grundriss-Lauflinie, IFC `IfcRamp`)? + pub fn is_ramp(&self) -> bool { + self.slope_plane().is_some() && self.slope.as_ref().and_then(|s| s.ramp).unwrap_or(false) + } + + /// [281] (kleinster, grösster) Höhenversatz über die Umrisspunkte; waagrecht (0, 0). + pub fn slope_range(&self) -> (f64, f64) { + let Some(g) = self.slope_plane() else { return (0.0, 0.0) }; + let ring = self.ring(); + let mut r = (f64::INFINITY, f64::NEG_INFINITY); + for q in ring.iter() { + let d = slope_dz(&g, q.x, q.y); + r = (r.0.min(d), r.1.max(d)); + } + if r.0 > r.1 { (0.0, 0.0) } else { r } + } +} + +/// [281] Höhenversatz einer Neigungsebene `[ox, oy, gx, gy]` am Punkt (x, y). +pub fn slope_dz(g: &[f64; 4], x: f64, y: f64) -> f64 { + g[2] * (x - g[0]) + g[3] * (y - g[1]) +} diff --git a/src-tauri/core/src/model3d/bearing.rs b/src-tauri/core/src/model3d/bearing.rs index 93eb3d12..6cf8db81 100644 --- a/src-tauri/core/src/model3d/bearing.rs +++ b/src-tauri/core/src/model3d/bearing.rs @@ -68,7 +68,7 @@ fn axis(w: &Wall) -> Option<([f64; 2], [f64; 2], f64)> { fn overlaps_z(p: &Project, w: &Wall, c: &Ceiling) -> bool { let (wb, wt) = p.wall_vertical_extent(w); - let (cb, ct) = p.ceiling_vertical_extent(c); + let (cb, ct) = p.ceiling_vertical_span(c); wt.min(ct) - wb.max(cb) > Z_EPS } @@ -412,7 +412,7 @@ pub(crate) fn bearing_outlines_memo(p: &Project, known: &HashMap = (0..p.walls.len()).filter(|&i| ext[i].1.min(ct) - ext[i].0.max(cb) > Z_EPS).collect(); let mut key: Vec<(u64, WallCuts)> = near.iter().map(|&i| (stamps.get(i).copied().unwrap_or(0), cuts_of(&p.walls[i]).clone())).collect(); // [216] Die Sehnen-Zonen der Bogenwände hängen auch an Öffnungen (anderer Geschosse): mit in den Schlüssel. diff --git a/src-tauri/core/src/model3d/ceilings.rs b/src-tauri/core/src/model3d/ceilings.rs index d9eb0dd4..d0c20106 100644 --- a/src-tauri/core/src/model3d/ceilings.rs +++ b/src-tauri/core/src/model3d/ceilings.rs @@ -83,7 +83,7 @@ pub(crate) fn emit_slabs_from(p: &Project, bearing: &[Option = d.ring.clone(); for (layer_idx, z_bottom, z_top) in d.slabs { let Some(layers) = layers.filter(|_| layer_idx >= 0) else { - out.push(RSlab { outline: outline.clone(), z_bottom, z_top, color: SLAB_RGB, ceiling_id: c.id.clone(), hatch: None, cut: None, monolith: None, source: SlabSource::Ceiling { index: ci, layer: None } }); + out.push(RSlab { outline: outline.clone(), z_bottom, z_top, color: SLAB_RGB, ceiling_id: c.id.clone(), hatch: None, cut: None, monolith: None, slope: c.slope_plane(), source: SlabSource::Ceiling { index: ci, layer: None } }); continue; }; let l = &layers[layer_idx as usize]; @@ -111,6 +111,7 @@ pub(crate) fn emit_slabs_from(p: &Project, bearing: &[Option Vec { for (foot, z_bottom, z_top) in column_pieces(p, c) { let outline: Vec = foot.iter().map(|q| [q.x, q.y]).collect(); if z_top - z_bottom > 1e-6 && outline.iter().flatten().all(|v| v.is_finite()) { - out.push(RSlab { outline, z_bottom, z_top, color, ceiling_id: c.id.clone(), hatch: None, cut: None, monolith: None, source: SlabSource::Column { index } }); + out.push(RSlab { outline, z_bottom, z_top, color, ceiling_id: c.id.clone(), hatch: None, cut: None, monolith: None, slope: None, source: SlabSource::Column { index } }); } } } diff --git a/src-tauri/core/src/model3d/mod.rs b/src-tauri/core/src/model3d/mod.rs index 8f71241b..9045266e 100644 --- a/src-tauri/core/src/model3d/mod.rs +++ b/src-tauri/core/src/model3d/mod.rs @@ -85,12 +85,23 @@ pub struct RSlab { pub cut: Option, #[serde(skip_serializing_if = "Option::is_none")] pub monolith: Option, + /// [281] Geneigte Decke/Rampe: Neigungsebene `[ox, oy, gx, gy]` — jede Höhe der Platte (Ober- und + /// Unterkante) liegt am Grundrisspunkt (x, y) um `gx·(x−ox) + gy·(y−oy)` höher ([`RSlab::dz`]). + #[serde(skip_serializing_if = "Option::is_none")] + pub slope: Option<[f64; 4]>, /// Herkunft der Platte (nur im Kern, nicht serialisiert): der Schnitt ordnet seine Bänder darüber /// der Decke bzw. Deckenschicht oder der Treppe zu, statt die Platten abzuzählen. #[serde(skip)] pub source: SlabSource, } +impl RSlab { + /// [281] Höhenversatz am Grundrisspunkt (x, y) (waagrecht 0). + pub fn dz(&self, x: f64, y: f64) -> f64 { + self.slope.as_ref().map_or(0.0, |g| crate::model::helpers::slope_dz(g, x, y)) + } +} + /// Herkunft einer `RSlab`. #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)] pub enum SlabSource { diff --git a/src-tauri/core/src/model3d/stairs.rs b/src-tauri/core/src/model3d/stairs.rs index 3128292b..338926bb 100644 --- a/src-tauri/core/src/model3d/stairs.rs +++ b/src-tauri/core/src/model3d/stairs.rs @@ -79,6 +79,7 @@ fn stair_slabs(stairs: &[(usize, &Stair)], slabs: Vec) -> hatch: None, cut: None, monolith: s.monolith.then(|| stair.id.clone()), + slope: None, source: SlabSource::Stair { index: si }, } }) diff --git a/src-tauri/core/src/model3d/walls.rs b/src-tauri/core/src/model3d/walls.rs index 1ef8cc77..dd31ecfd 100644 --- a/src-tauri/core/src/model3d/walls.rs +++ b/src-tauri/core/src/model3d/walls.rs @@ -624,7 +624,8 @@ pub(crate) fn floor_context_with(p: &Project, floor_id: &str, with_ceilings: boo /// Wie [`floor_context_with`] mit schon gerechneten Platten-Umrissen je Decke (`bearing`, Index wie /// `Project::ceilings`, s. `bearing::bearing_outlines_memo`; [214] 3D-Cache). pub(crate) fn floor_context_from(p: &Project, floor_id: &str, with_ceilings: bool, bearing: &[Option>]) -> FloorContext { - let only = |c: &Ceiling| with_ceilings && c.floor_id == floor_id && c.outline.len() >= 3; + // [281] Geneigte Decken schneiden die Wandschichten (noch) nicht ein: die Schnitt-Bänder sind waagrecht. + let only = |c: &Ceiling| with_ceilings && c.floor_id == floor_id && c.outline.len() >= 3 && c.slope_plane().is_none(); let ceilings: Vec = p .ceilings .as_deref() diff --git a/src-tauri/core/src/plan/domains.rs b/src-tauri/core/src/plan/domains.rs index 9a39fd9e..8fe40c35 100644 --- a/src-tauri/core/src/plan/domains.rs +++ b/src-tauri/core/src/plan/domains.rs @@ -654,7 +654,8 @@ fn ceilings(c: &Ctx, out: &mut Vec, bounds: &mut Bounds) -> Result<() .iter() .filter(|x| c.vis(&x.category_code, &x.id)) .filter_map(|x| { - let (zb, zt) = p.ceiling_vertical_extent(x); + // [281] Geneigte Decke: ganze Höhenspanne über den Umriss. + let (zb, zt) = p.ceiling_vertical_span(x); let zone = range.classify(zb, zt); let keep = zone != super::view_range::Zone::Hidden && (x.floor_id == c.a.floor || range.admits_other_floor(zone)); keep.then_some((x, zone)) @@ -713,6 +714,8 @@ fn ceilings(c: &Ctx, out: &mut Vec, bounds: &mut Bounds) -> Result<() for [a, b] in ceiling_outline_lines(&merged.ring, &merged.bridge_edges, &fps).into_iter().filter(|_| outline) { out.push(line(pv(a), pv(b), "ceiling-outline", w, Some(Some(OVERHEAD_DASH.to_vec())), stroke, Some(greyed))); } + // [281] Geneigte Decke/Rampe: Gefällepfeil bzw. Lauflinie mit Gefälle in % (Klasse der Decke, [180]). + slope_symbol(ce, &pts, c.a.scale, w, stroke, greyed, out); // Eigene Decke „über Schnitt“ bleibt wie bisher (Umriss ist schon strichpunktiert, die Fläche // deckt wie gewohnt); umgezeichnet werden Decken unter dem Schnitt und solche anderer Geschosse. if ce.floor_id != c.a.floor || zone != super::view_range::Zone::Above { @@ -724,6 +727,96 @@ fn ceilings(c: &Ctx, out: &mut Vec, bounds: &mut Bounds) -> Result<() Ok(()) } +/// [281] Gefälle als Text: eine Nachkommastelle, ganze Zahlen ohne („15 %", „1.5 %"). +pub(crate) fn slope_percent_text(pct: f64) -> String { + let r = round(pct.abs() * 10.0) / 10.0; + if (r - round(r)).abs() < 1e-9 { format!("{} %", r as i64) } else { format!("{r:.1} %") } +} + +/// [281] Symbol einer geneigten Decke im Grundriss: Gefällepfeil (abwärts, kurz, um die Mitte) bzw. bei einer Rampe die +/// Lauflinie über die ganze Länge (Antrittskreis unten, Pfeil oben, wie bei Treppen) und das Gefälle in % längs des +/// Pfeils. Linien `ceiling-slope` in der Strichfarbe der Decke; gezeichnet nur, wenn die Deckenklasse sichtbar ist. +fn slope_symbol(ce: &Ceiling, ring: &[[f64; 2]], scale: f64, w: f64, stroke: &str, greyed: bool, out: &mut Vec) { + let (Some(sl), Some(_)) = (ce.slope.as_ref(), ce.slope_plane()) else { return }; + if ring.len() < 3 || !(scale.is_finite() && scale > 0.0) { + return; + } + let (dx, dy) = (sl.to.x - sl.from.x, sl.to.y - sl.from.y); + let len = dx.hypot(dy); + let pct = sl.rise / len * 100.0; + let ramp = ce.is_ramp(); + // Aufwärts = Richtung steigender Höhe; die Rampe zeigt aufwärts, der Gefällepfeil abwärts (Wasserlauf). + let up = if sl.rise > 0.0 { [dx / len, dy / len] } else { [-dx / len, -dy / len] }; + let d = if ramp { up } else { [-up[0], -up[1]] }; + let mm = scale / 1000.0; + let m = crate::room_area::label_point(ring); + // Sehne durch die Mitte längs der Pfeilrichtung: nächste Umrisskanten vor und hinter der Mitte. + let (mut t_lo, mut t_hi) = (f64::NEG_INFINITY, f64::INFINITY); + for i in 0..ring.len() { + let (a, b) = (ring[i], ring[(i + 1) % ring.len()]); + let e = [b[0] - a[0], b[1] - a[1]]; + let den = d[0] * e[1] - d[1] * e[0]; + if den.abs() < 1e-12 { + continue; + } + let (qx, qy) = (a[0] - m[0], a[1] - m[1]); + let t = (qx * e[1] - qy * e[0]) / den; + let u = (qx * d[1] - qy * d[0]) / den; + if (-1e-9..=1.0 + 1e-9).contains(&u) { + if t <= 0.0 { t_lo = t_lo.max(t) } else { t_hi = t_hi.min(t) } + } + } + if !(t_lo.is_finite() && t_hi.is_finite() && t_hi - t_lo > 1e-3) { + return; + } + let (t0, t1) = if ramp { + let inset = (2.0 * mm).min((t_hi - t_lo) * 0.1); + (t_lo + inset, t_hi - inset) + } else { + let half = (12.0 * mm).min(-t_lo * 0.8).min(t_hi * 0.8); + (-half, half) + }; + if !(t1 - t0 > 1e-3) { + return; + } + let at = |t: f64| [m[0] + d[0] * t, m[1] + d[1] * t]; + let (a, b) = (at(t0), at(t1)); + let cls = "ceiling-slope"; + out.push(line(pv(a), pv(b), cls, w, None, stroke, Some(greyed))); + // Pfeilspitze (offen, ±25°) am Ende; Rampe: Antrittskreis am Anfang. + let head = (2.5 * mm).min((t1 - t0) * 0.4); + let (c25, s25) = (0.906_307_787_036_649_9, 0.422_618_261_740_699_4); + for sg in [1.0, -1.0] { + let r = [-(d[0] * c25 - d[1] * s25 * sg), -(d[1] * c25 + d[0] * s25 * sg)]; + out.push(line(pv(b), pv([b[0] + r[0] * head, b[1] + r[1] * head]), cls, w, None, stroke, Some(greyed))); + } + if ramp { + out.push(Primitive::DrawingCircle { center: pv(a), r: 0.75 * mm, fill: stroke.to_string(), stroke: stroke.to_string(), weight_mm: w, dash: None, drawing_id: None, greyed: Some(greyed), opacity: None }); + } + // Gefälle längs des Pfeils, lesbar (Schrift nie kopfüber), links neben der Linie. + let text = slope_percent_text(pct); + let h = 2.5 * mm; + let tw = crate::text_layout::text_width_em(&text, false) * h; + let u = if d[0] < -1e-9 || (d[0].abs() <= 1e-9 && d[1] < 0.0) { [-d[0], -d[1]] } else { d }; + let n = [-u[1], u[0]]; + let mid = at((t0 + t1) / 2.0); + let gap = 0.8 * mm; + let pos = [mid[0] - u[0] * tw / 2.0 + n[0] * gap, mid[1] - u[1] * tw / 2.0 + n[1] * gap]; + out.push(Primitive::DrawingText { + at: pv(pos), + text, + height_m: h, + angle: crate::jsnum::atan2(u[1], u[0]), + color: stroke.to_string(), + marks: None, + wrap_width: None, + doc: None, + drawing_id: None, + greyed: Some(greyed), + opacity: None, + }); +} + // ── Dächer ────────────────────────────────────────────────────────────────── /// Dach im Grundriss von oben gesehen (Dachaufsicht): ganz unter der Schnittebene des Geschosses diff --git a/src-tauri/core/src/plan/elevation/collect.rs b/src-tauri/core/src/plan/elevation/collect.rs index 6fb73ff3..5effd303 100644 --- a/src-tauri/core/src/plan/elevation/collect.rs +++ b/src-tauri/core/src/plan/elevation/collect.rs @@ -46,7 +46,14 @@ pub(super) fn project_faces(frame: &[f64; 9], walls: &[RWall], slabs: &[RSlab], } let mut sl = vec![slabs.len() as f64]; for x in slabs { - sl.extend([x.z_bottom, x.z_top, x.outline.len() as f64]); + // [281] Geneigte Platte: Eckenzahl negativ, danach die Neigungsebene (ox, oy, gx, gy). + match x.slope { + Some(g) => { + sl.extend([x.z_bottom, x.z_top, -(x.outline.len() as f64)]); + sl.extend(g); + } + None => sl.extend([x.z_bottom, x.z_top, x.outline.len() as f64]), + } for q in &x.outline { sl.extend(q); } diff --git a/src-tauri/core/src/plan/elevation_geom.rs b/src-tauri/core/src/plan/elevation_geom.rs index 7b6f5b46..bfb785ac 100644 --- a/src-tauri/core/src/plan/elevation_geom.rs +++ b/src-tauri/core/src/plan/elevation_geom.rs @@ -22,7 +22,7 @@ //! `faces_full(frame, walls, slabs, roofs)`; `frame = [Px,Py,Pz, Nx,Ny,Nz, Ux,Uy,Uz]` (Welt, Y oben). //! ```text //! walls [n, (sx, sz, ex, ez, dicke, hoehe, basis) × n] -//! slabs [n, (zUnten, zOben, k, x, z …) × n] +//! slabs [n, (zUnten, zOben, k, x, z …) × n] [281] geneigt: k negativ (−Ecken), dann ox, oy, gx, gy vor den Ecken //! roofs [n, (nFl, nGiebel, (k, x, y, z …) × nFl, (k, x, y, z …) × nGiebel) × n] Modell [x, y, Höhe] //! → Flächen (Rolle 0 Wand|1 Decke|2 Dach, Quelle, Tiefe Mittel/Min/Max, Normale, (u, v) und Tiefe je Ecke) //! ``` @@ -670,7 +670,7 @@ fn wall_faces(f: &Frame, w: &[f64], src: usize, out: &mut Vec) { } } -fn slab_faces(f: &Frame, z_bottom: f64, z_top: f64, outline: &[P], src: usize, out: &mut Vec) { +fn slab_faces(f: &Frame, z_bottom: f64, z_top: f64, outline: &[P], slope: Option<&[f64; 4]>, src: usize, out: &mut Vec) { let n = outline.len(); if n < 3 || z_top - z_bottom <= EPS { return; @@ -682,16 +682,19 @@ fn slab_faces(f: &Frame, z_bottom: f64, z_top: f64, outline: &[P], src: usize, o } cx /= n as f64; cz /= n as f64; - let bottom: Vec = outline.iter().map(|p| [p.0, z_bottom, p.1]).collect(); - let top: Vec = outline.iter().map(|p| [p.0, z_top, p.1]).collect(); + // [281] Geneigte Platte: Höhen um den Versatz der Neigungsebene verschoben, Mantel bleibt lotrecht. + let d = |p: &P| slope.map_or(0.0, |g| crate::model::helpers::slope_dz(g, p.0, p.1)); + let up = slope.map_or([0.0, 1.0, 0.0], |g| normalize3([-g[2], 1.0, -g[3]])); + let bottom: Vec = outline.iter().map(|p| [p.0, z_bottom + d(p), p.1]).collect(); + let top: Vec = outline.iter().map(|p| [p.0, z_top + d(p), p.1]).collect(); let mut push = |poly: &[V3], normal: V3| { if let Some(p) = project_face(f, poly, normal, 1, src) { out.push(p); } }; - push(&top, [0.0, 1.0, 0.0]); + push(&top, up); let rev: Vec = bottom.iter().rev().copied().collect(); - push(&rev, [0.0, -1.0, 0.0]); + push(&rev, neg(up)); for i in 0..n { let j = (i + 1) % n; let ex = outline[j].0 - outline[i].0; @@ -818,13 +821,17 @@ pub(crate) fn faces_full(frame: &[f64], walls: &[f64], slabs: &[f64], roofs: &[f let mut i = 1; for k in 0..ns { let Some(&kk) = slabs.get(i + 2) else { return None }; - if kk < 0.0 || kk.fract() != 0.0 || i + 3 + 2 * kk as usize > slabs.len() { + // [281] Negative Eckenzahl: geneigte Platte, vier Werte der Neigungsebene folgen. + let (kk, slope) = if kk < 0.0 { (-kk, Some(slabs.get(i + 3..i + 7)?)) } else { (kk, None) }; + let head = 3 + if slope.is_some() { 4 } else { 0 }; + if kk.fract() != 0.0 || i + head + 2 * kk as usize > slabs.len() { return None; } let kk = kk as usize; - let outline: Vec

= (0..kk).map(|j| (slabs[i + 3 + 2 * j], slabs[i + 4 + 2 * j])).collect(); - slab_faces(&fr, slabs[i], slabs[i + 1], &outline, k, &mut out); - i += 3 + 2 * kk; + let outline: Vec

= (0..kk).map(|j| (slabs[i + head + 2 * j], slabs[i + head + 1 + 2 * j])).collect(); + let g = slope.map(|g| [g[0], g[1], g[2], g[3]]); + slab_faces(&fr, slabs[i], slabs[i + 1], &outline, g.as_ref(), k, &mut out); + i += head + 2 * kk; } if i != slabs.len() { return None; diff --git a/src-tauri/core/src/plan/extras.rs b/src-tauri/core/src/plan/extras.rs index 887ace0e..8a30ff4b 100644 --- a/src-tauri/core/src/plan/extras.rs +++ b/src-tauri/core/src/plan/extras.rs @@ -493,7 +493,7 @@ pub fn subtract_voids(prims: Vec, p: &Project, cut_z: f64) -> Vec [f32; 4] { [json_f32(v[0]), json_f32(v[1]), json_f32(v[2]), json_f32(v[3])] } +/// [281] Für Tests ausserhalb des Schnitts (geneigte Platte im 3D-Netz). +#[cfg(test)] +pub(crate) fn slab_input_pub(s: &RSlab) -> render3d::SlabInput { + slab_input(s) +} + pub(super) fn slab_input(s: &RSlab) -> render3d::SlabInput { render3d::SlabInput { outline: s.outline.iter().map(|q| f32s2(*q)).collect(), @@ -134,5 +140,6 @@ pub(super) fn slab_input(s: &RSlab) -> render3d::SlabInput { hatch: None, cut: None, monolith: s.monolith.clone(), + slope: s.slope.map(|g| [json_f32(g[0]), json_f32(g[1]), json_f32(g[2]), json_f32(g[3])]), } } diff --git a/src-tauri/core/src/plan/section/mod.rs b/src-tauri/core/src/plan/section/mod.rs index 48305f6c..7fcaee08 100644 --- a/src-tauri/core/src/plan/section/mod.rs +++ b/src-tauri/core/src/plan/section/mod.rs @@ -30,6 +30,8 @@ pub(crate) mod query; pub mod unfold; use input::*; +#[cfg(test)] +pub(crate) use input::slab_input_pub; pub use bands::*; use shapes::*; use voids::*; diff --git a/src-tauri/core/src/plan/section/projection.rs b/src-tauri/core/src/plan/section/projection.rs index 04f8ee5d..887422f0 100644 --- a/src-tauri/core/src/plan/section/projection.rs +++ b/src-tauri/core/src/plan/section/projection.rs @@ -133,17 +133,27 @@ pub(crate) fn view_faces(p: &Project, view: &dyn Fn([f64; 3]) -> [f64; 3], view_ } let area: f64 = (0..n).map(|k| o[k][0] * o[(k + 1) % n][1] - o[(k + 1) % n][0] * o[k][1]).sum(); let sign = if area >= 0.0 { 1.0 } else { -1.0 }; - let top: Vec<[f64; 3]> = o.iter().map(|q| [q[0], y1, q[1]]).collect(); - let bottom: Vec<[f64; 3]> = o.iter().rev().map(|q| [q[0], y0, q[1]]).collect(); - push(&mut faces, &top, [0.0, 1.0, 0.0], owner, 0, false); - push(&mut faces, &bottom, [0.0, -1.0, 0.0], owner, 0, false); + // [281] Geneigte Platte: jede Höhe um den Versatz der Neigungsebene verschoben (Mantel bleibt lotrecht). + let d = |q: &[f64; 2]| s.dz(q[0], q[1]); + let up = match s.slope { + Some(g) => { + let l = (g[2] * g[2] + 1.0 + g[3] * g[3]).sqrt(); + [-g[2] / l, 1.0 / l, -g[3] / l] + } + None => [0.0, 1.0, 0.0], + }; + let top: Vec<[f64; 3]> = o.iter().map(|q| [q[0], y1 + d(q), q[1]]).collect(); + let bottom: Vec<[f64; 3]> = o.iter().rev().map(|q| [q[0], y0 + d(q), q[1]]).collect(); + push(&mut faces, &top, up, owner, 0, false); + push(&mut faces, &bottom, [-up[0], -up[1], -up[2]], owner, 0, false); for k in 0..n { let (a, b) = (o[k], o[(k + 1) % n]); let (dx, dy) = (b[0] - a[0], b[1] - a[1]); if dx.abs() + dy.abs() < 1e-12 { continue; } - let side = [[a[0], y0, a[1]], [b[0], y0, b[1]], [b[0], y1, b[1]], [a[0], y1, a[1]]]; + let (da, db) = (d(&a), d(&b)); + let side = [[a[0], y0 + da, a[1]], [b[0], y0 + db, b[1]], [b[0], y1 + db, b[1]], [a[0], y1 + da, a[1]]]; push(&mut faces, &side, [dy * sign, 0.0, -dx * sign], owner, side_group, false); } } diff --git a/src-tauri/core/src/plan/section/ts_faelle.rs b/src-tauri/core/src/plan/section/ts_faelle.rs index 8b22beff..eb8d1731 100644 --- a/src-tauri/core/src/plan/section/ts_faelle.rs +++ b/src-tauri/core/src/plan/section/ts_faelle.rs @@ -117,7 +117,7 @@ fn monolith_tritte_zu_einem_saegezahn() { assert_eq!(rings.len(), 1); assert!(rings[0].len() >= 8); assert_eq!(union_rect_outlines(&[[0.0, 1.0, 0.0, 1.0], [2.0, 3.0, 0.0, 1.0]]).len(), 2); - let slab = |m: Option<&str>| RSlab { outline: vec![], z_bottom: 0.0, z_top: 1.0, color: [0.0; 3], ceiling_id: String::new(), hatch: None, cut: None, monolith: m.map(String::from), source: SlabSource::None }; + let slab = |m: Option<&str>| RSlab { outline: vec![], z_bottom: 0.0, z_top: 1.0, color: [0.0; 3], ceiling_id: String::new(), hatch: None, cut: None, monolith: m.map(String::from), slope: None, source: SlabSource::None }; let slabs = vec![slab(None), slab(Some("ST1")), slab(Some("ST1"))]; let mk = |i: usize, u0: f64| Cut::new(Kind::Slab, i, vec![[u0, 0.0], [u0 + 1.0, 0.0], [u0 + 1.0, 1.0], [u0, 1.0]]); let out = merge_monolith_cuts(vec![mk(0, 0.0), mk(1, 0.0), mk(2, 0.5)], &slabs, &HashMap::new()); diff --git a/src-tauri/core/src/room_book.rs b/src-tauri/core/src/room_book.rs index 7efe1f97..24307ae6 100644 --- a/src-tauri/core/src/room_book.rs +++ b/src-tauri/core/src/room_book.rs @@ -95,7 +95,12 @@ pub fn clear_range(p: &Project, r: &Room) -> (f64, f64) { return (base, base + fh); } let [x, y] = crate::room_area::label_point(&ring); - let over: Vec<(f64, f64)> = p.ceilings.as_deref().unwrap_or(&[]).iter().filter(|ce| in_ceiling(ce, x, y)).map(|ce| p.ceiling_vertical_extent(ce)).filter(|(a, b)| a.is_finite() && b.is_finite()).collect(); + let over: Vec<(f64, f64)> = p.ceilings.as_deref().unwrap_or(&[]).iter().filter(|ce| in_ceiling(ce, x, y)).map(|ce| { + // [281] Geneigte Decke: Höhe am Beschriftungspunkt des Raums. + let (b, t) = p.ceiling_vertical_extent(ce); + let d = ce.slope_dz(x, y); + (b + d, t + d) + }).filter(|(a, b)| a.is_finite() && b.is_finite()).collect(); let floor_z = over.iter().map(|e| e.1).filter(|t| *t >= base - 0.3 && *t <= base + 0.5).fold(f64::NAN, f64::max); let floor_z = if floor_z.is_finite() { floor_z } else { base }; let ceil_z = over.iter().map(|e| e.0).filter(|b| *b > floor_z + 1.0).fold(f64::NAN, f64::min); diff --git a/src-tauri/core/src/selection_info.rs b/src-tauri/core/src/selection_info.rs index 6626f34a..0a45a2f9 100644 --- a/src-tauri/core/src/selection_info.rs +++ b/src-tauri/core/src/selection_info.rs @@ -592,6 +592,8 @@ fn ceiling_selection(root: &Map, c: &Value) -> Result .raw("bottom", c, "bottom") .n("zBottom", zb) .n("zTop", zt) + // [281] Neigung (fehlt = waagrecht). + .raw("slope", c, "slope") .v("openings", J::arr(openings)) .done(); Ok(O::default() diff --git a/src-tauri/core/src/solid_mesh.rs b/src-tauri/core/src/solid_mesh.rs index c1da752c..b148d50e 100644 --- a/src-tauri/core/src/solid_mesh.rs +++ b/src-tauri/core/src/solid_mesh.rs @@ -315,9 +315,20 @@ pub fn spec_solid_q(spec: &Value, depth: usize, min_seg: usize) -> Option if cr > 1e-6 { outer = round_ring(&outer, cr, min_seg); } - let body = solid(&tube(&[ring_at(&outer, z0), ring_at(&outer, z0 + h)], false))?; + // [281] Geneigte Platte: `slope` = [ox, oy, gx, gy], jede Höhe um gx·(x−ox) + gy·(y−oy) versetzt. + let g: Option<[f64; 4]> = match nums(spec.get("slope")) { + Some(v) if v.len() == 4 && v.iter().all(|x| x.is_finite()) => Some([v[0], v[1], v[2], v[3]]), + _ => None, + }; + let at = |r: &[[f64; 2]], z: f64| -> Vec { + match &g { + Some(g) => r.iter().map(|q| [q[0], q[1], z + crate::model::helpers::slope_dz(g, q[0], q[1])]).collect(), + None => ring_at(r, z), + } + }; + let body = solid(&tube(&[at(&outer, z0), at(&outer, z0 + h)], false))?; let e = 1e-3; - minus_holes(body, &holes_of(spec)?, &|r| tube(&[ring_at(r, z0 - e), ring_at(r, z0 + h + e)], false)) + minus_holes(body, &holes_of(spec)?, &|r| tube(&[at(r, z0 - e), at(r, z0 + h + e)], false)) } "extrudePlane" => { let (o, u, v) = (vec3(spec, "origin")?, vec3(spec, "uAxis")?, vec3(spec, "vAxis")?); diff --git a/src-tauri/core/src/solid_specs.rs b/src-tauri/core/src/solid_specs.rs index cb358f2a..870f7ad9 100644 --- a/src-tauri/core/src/solid_specs.rs +++ b/src-tauri/core/src/solid_specs.rs @@ -296,12 +296,17 @@ pub fn void_cuts_lifted(p: &Project, walls: &[RWall], slabs: &[RSlab], wall_dz: continue; } let dz = slab_dz(i); - let hits = hitting(&voids, &bbox(s.outline.iter().map(|q| (q[0], q[1]))), s.z_bottom - dz, s.z_top - dz); + // [281] Geneigte Platte: Höhenspanne über den Umriss, Körper mit Neigungsebene. + let (lo, hi) = s.outline.iter().fold((0.0f64, 0.0f64), |(a, b), q| (a.min(s.dz(q[0], q[1])), b.max(s.dz(q[0], q[1])))); + let hits = hitting(&voids, &bbox(s.outline.iter().map(|q| (q[0], q[1]))), s.z_bottom + lo - dz, s.z_top + hi - dz); if hits.is_empty() { continue; } let pts: Vec = s.outline.iter().flat_map(|q| [q[0], q[1]]).collect(); - let base = json!({"kind": "extrude", "points": pts, "height": s.z_top - s.z_bottom, "z0": s.z_bottom}); + let mut base = json!({"kind": "extrude", "points": pts, "height": s.z_top - s.z_bottom, "z0": s.z_bottom}); + if let Some(g) = s.slope { + base["slope"] = json!(g); + } out.slabs.push((i, subtract(base, &hits, dz))); } out diff --git a/src-tauri/core/src/sun.rs b/src-tauri/core/src/sun.rs index 99e9c7c6..2da0d537 100644 --- a/src-tauri/core/src/sun.rs +++ b/src-tauri/core/src/sun.rs @@ -1067,7 +1067,10 @@ fn collect(p: &Project, k: [f64; 2], cut: Option, ground: Option<&Ground>) } // [142] Decken (auch Balkone, Auskragungen) werfen Schatten, decken Tieferes ab und empfangen ihn. for ce in p.ceilings.as_deref().unwrap_or(&[]) { - let (zb, zt) = p.ceiling_vertical_extent(ce); + // [281] Geneigte Decke: Hüllprisma über die ganze Höhenspanne; sie empfängt keinen Schatten (die + // Empfangsfläche ist waagrecht gedacht). + let sloped = ce.slope_plane().is_some(); + let (zb, zt) = p.ceiling_vertical_span(ce); let ring = |r: &[crate::model::Vec2]| r.iter().map(|v| [v.x, v.y]).collect::(); // [191] Umriss mit Bögen fein geteilt (wie die Aussparungen), sonst schnitte die Sehne den Erker ab. let outline = ring(&ce.ring()); @@ -1077,7 +1080,9 @@ fn collect(p: &Project, k: [f64; 2], cut: Option, ground: Option<&Ground>) continue; } covers.push(Cover { region: region.clone(), bottom: zb }); - receive(region, [0.0, 0.0, zt], zt); + if !sloped { + receive(region, [0.0, 0.0, zt], zt); + } prisms.push((Prism { footprint: outline, z_bottom: zb, z_top: zt }, holes)); } // [142] Dächer in ihrer echten Form: verschnittene Dächer (Gauben, Anbauten) als Hülle ihres diff --git a/src-tauri/core/src/surface_pattern3d.rs b/src-tauri/core/src/surface_pattern3d.rs index e6b3e366..a0941aa6 100644 --- a/src-tauri/core/src/surface_pattern3d.rs +++ b/src-tauri/core/src/surface_pattern3d.rs @@ -642,7 +642,8 @@ fn ceiling_lines(p: &Project, ce: &Ceiling, s: &mut Sink) { let Some((pat, comp, spec)) = spec_for(layer.and_then(|l| p.component(&l.component_id)), 0.0) else { continue }; let rgb = ink_rgb(pat, comp); for (a, b, m) in lod_segments(|sc| sp::segments(&ring, &spec, outer[0], sc)) { - s.push([a[0], a[1], z], [b[0], b[1], z], rgb, m); + // [281] Geneigte Decke: Linien liegen auf der geneigten Fläche (Versatz je Endpunkt, linear dazwischen). + s.push([a[0], a[1], z + ce.slope_dz(a[0], a[1])], [b[0], b[1], z + ce.slope_dz(b[0], b[1])], rgb, m); } } } diff --git a/src-tauri/fileio/src/ifc_export/builder.rs b/src-tauri/fileio/src/ifc_export/builder.rs index c7444779..df578e9e 100644 --- a/src-tauri/fileio/src/ifc_export/builder.rs +++ b/src-tauri/fileio/src/ifc_export/builder.rs @@ -517,7 +517,7 @@ impl Builder { /// PredefinedType, in IFC2x3 je Klasse ShapeType/PredefinedType/CompositionType; IfcWall und IfcColumn /// haben es dort nicht. pub(super) fn emit_building_element(&mut self, ty: &str, guid: String, name: &str, placement: usize, shape: usize, predefined: Option) -> usize { - let last = if self.v2() && matches!(ty, "IFCWALL" | "IFCWALLSTANDARDCASE" | "IFCCOLUMN") { + let last = if self.v2() && matches!(ty, "IFCWALL" | "IFCWALLSTANDARDCASE" | "IFCCOLUMN" | "IFCRAMPFLIGHT") { String::new() } else { format!(",{}", predefined.as_deref().unwrap_or("$")) diff --git a/src-tauri/fileio/src/ifc_export/mod.rs b/src-tauri/fileio/src/ifc_export/mod.rs index 79e3ef02..b12402d1 100644 --- a/src-tauri/fileio/src/ifc_export/mod.rs +++ b/src-tauri/fileio/src/ifc_export/mod.rs @@ -179,6 +179,8 @@ pub const REC_RAILING: f64 = 26.0; pub const REC_COLUMN_PIECES: f64 = 20.0; pub const REC_CEILING_ARC: f64 = 21.0; pub const REC_SPACE_ARC: f64 = 22.0; +/// [281] Geneigte Decke als Netz (Flag Rampe ⇒ `IfcRamp` + `IfcRampFlight`). +pub const REC_CEILING_MESH: f64 = 27.0; mod format; mod reader; @@ -201,6 +203,7 @@ fn rec_name(code: f64) -> &'static str { c if c == REC_WALL_ARC_SOLID => "WALL_ARC_SOLID", c if c == REC_CEILING => "CEILING", c if c == REC_CEILING_ARC => "CEILING_ARC", + c if c == REC_CEILING_MESH => "CEILING_MESH", c if c == REC_SPACE_ARC => "SPACE_ARC", c if c == REC_OPENING => "OPENING", c if c == REC_OPENING_SOLID => "OPENING_SOLID", @@ -703,6 +706,43 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result { }; w.finish_typed("IFCSLAB", format!("slab/{id}"), &name, &ty, &psets, structure, placement, shape, Some(enum_("FLOOR")), true); } + c if c == REC_CEILING_MESH => { + let structure = r.structure(n_storeys)?; + let id = r.string()?; + let name = r.string()?; + let ty = r.type_ref()?; + let psets = r.psets()?; + let ramp = r.flag()?; + let mesh = r.mesh()?; + let key = format!("slab/{id}"); + if !ramp { + let (placement, shape) = w.emit_triangulated_product(&mesh, w.placement_of(structure)); + w.finish_typed("IFCSLAB", key, &name, &ty, &psets, structure, placement, shape, Some(enum_("FLOOR")), true); + } else { + // Rampe ohne eigene Darstellung; der Lauf (Körper, Typ, Eigenschaften) hängt per IfcRelAggregates daran + // (wie Treppe/Treppenlauf). IFC2x3: `ShapeType` statt `PredefinedType`, Lauf ohne Typ-Enum. + let parent = w.placement_of(structure); + let ramp_placement = w.emit_placement(0.0, parent); + let g = w.gid(&key); + let ramp_entity = w.add( + "IFCRAMP", + format!("{g},#{},{},$,$,#{ramp_placement},$,$,{}", w.owner_history, ifc_string(&name), enum_("STRAIGHT_RUN_RAMP")), + ); + let (placement, shape) = w.emit_triangulated_product(&mesh, ramp_placement); + let fkey = format!("{key}/flight"); + let guid = w.gid(&fkey); + let flight = w.emit_building_element("IFCRAMPFLIGHT", guid, &name, placement, shape, Some(enum_("STRAIGHT"))); + for p in &psets { + w.add_pset(p, flight, &fkey); + } + // Der Deckentyp (IfcSlabType) passt nicht zum Rampenlauf: ohne Typ, Schichten nur im Modell. + let _ = ty; + let g = w.gid(&format!("aggregates/{key}")); + w.add("IFCRELAGGREGATES", format!("{g},#{},$,$,#{ramp_entity},{}", w.owner_history, refs(&[flight]))); + w.add_to_containment(structure, ramp_entity); + w.elements.insert(key, ramp_entity); + } + } c if c == REC_OPENING => { let wall_id = r.string()?; let structure = r.structure(n_storeys)?; diff --git a/src-tauri/render3d/examples/section_svg.rs b/src-tauri/render3d/examples/section_svg.rs index 9d09c2e6..b0073a68 100644 --- a/src-tauri/render3d/examples/section_svg.rs +++ b/src-tauri/render3d/examples/section_svg.rs @@ -85,6 +85,7 @@ fn l_wall_scene() -> (Vec, Vec) { ]; let slabs = vec![SlabInput { monolith: None, + slope: None, outline: vec![[-0.5, -0.5], [3.5, -0.5], [3.5, 3.5], [-0.5, 3.5]], z_bottom: -0.2, z_top: 0.0, diff --git a/src-tauri/render3d/src/lib.rs b/src-tauri/render3d/src/lib.rs index 0d69dcdc..7c3950fc 100644 --- a/src-tauri/render3d/src/lib.rs +++ b/src-tauri/render3d/src/lib.rs @@ -918,6 +918,7 @@ mod tests { fn square_slab(s: f32, z_bottom: f32, z_top: f32) -> SlabInput { SlabInput { monolith: None, + slope: None, outline: vec![[0.0, 0.0], [s, 0.0], [s, s], [0.0, s]], z_bottom, z_top, @@ -977,6 +978,7 @@ mod tests { // Zentrum weg zeigen. let slab = SlabInput { monolith: None, + slope: None, outline: vec![[-2.0, -2.0], [2.0, -2.0], [2.0, 2.0], [-2.0, 2.0]], z_bottom: 0.0, z_top: 0.3, @@ -1011,7 +1013,7 @@ mod tests { fn entarteter_slab_erzeugt_nichts() { let mut mesh = Mesh::default(); // <3 Ecken. - extrude_slab(&mut mesh, &SlabInput { outline: vec![[0.0, 0.0], [1.0, 0.0]], z_bottom: 0.0, z_top: 0.2, color: [0.8, 0.8, 0.8], hatch: None, cut: None, monolith: None }); + extrude_slab(&mut mesh, &SlabInput { outline: vec![[0.0, 0.0], [1.0, 0.0]], z_bottom: 0.0, z_top: 0.2, color: [0.8, 0.8, 0.8], hatch: None, cut: None, monolith: None, slope: None }); assert_eq!(mesh.vertex_count(), 0); // Nullhoehe. extrude_slab(&mut mesh, &square_slab(4.0, 2.6, 2.6)); diff --git a/src-tauri/render3d/src/mesh.rs b/src-tauri/render3d/src/mesh.rs index 22afc040..64f50fa1 100644 --- a/src-tauri/render3d/src/mesh.rs +++ b/src-tauri/render3d/src/mesh.rs @@ -1608,16 +1608,24 @@ pub fn extrude_slab(mesh: &mut Mesh, slab: &SlabInput) { return; } let color = slab.color; - // world-Position: model [x, y] -> (x, hoehe, y). - let w = |g: Point2, y: f32| -> [f32; 3] { [g[0], y, g[1]] }; + // world-Position: model [x, y] -> (x, hoehe, y); [281] geneigte Platte: Höhe + Versatz der Neigungsebene. + let w = |g: Point2, y: f32| -> [f32; 3] { [g[0], y + slab.dz(g), g[1]] }; + // Deckel-/Bodennormale: senkrecht auf der (geneigten) Ebene. + let up = match slab.slope { + Some(s) => { + let l = (s[2] * s[2] + 1.0 + s[3] * s[3]).sqrt(); + [-s[2] / l, 1.0 / l, -s[3] / l] + } + None => [0.0, 1.0, 0.0], + }; // Deckel (+Y) und Boden (−Y) aus den Triangulierungs-Dreiecken. for t in tris.chunks_exact(3) { let a = pts[t[0] as usize]; let b = pts[t[1] as usize]; let c = pts[t[2] as usize]; - push_tri_oriented(mesh, w(a, y1), w(b, y1), w(c, y1), [0.0, 1.0, 0.0], color); - push_tri_oriented(mesh, w(a, y0), w(b, y0), w(c, y0), [0.0, -1.0, 0.0], color); + push_tri_oriented(mesh, w(a, y1), w(b, y1), w(c, y1), up, color); + push_tri_oriented(mesh, w(a, y0), w(b, y0), w(c, y0), [-up[0], -up[1], -up[2]], color); } // Mantelflaechen: je Kante ein vertikales Quad (unten y0, oben y1), Normale nach aussen (aus dem @@ -1767,7 +1775,7 @@ mod tests { if rev { o.reverse(); } - let slab = SlabInput { monolith: None, outline: o, z_bottom: 0.0, z_top: 0.3, color: [0.8, 0.8, 0.8], hatch: None, cut: None }; + let slab = SlabInput { monolith: None, slope: None, outline: o, z_bottom: 0.0, z_top: 0.3, color: [0.8, 0.8, 0.8], hatch: None, cut: None }; let mut m = Mesh::default(); extrude_slab(&mut m, &slab); let mut at_arc = 0; diff --git a/src-tauri/render3d/src/section.rs b/src-tauri/render3d/src/section.rs index c215bb1b..ef21c177 100644 --- a/src-tauri/render3d/src/section.rs +++ b/src-tauri/render3d/src/section.rs @@ -345,9 +345,19 @@ struct Prism { /// Ebene Oberkante unter einer Dachfläche ([G2], `WallInput::top_plane`): Ursprung (Grundriss) /// und `[z, dz/dx, dz/dy]`; `z1` ist dann der höchste Eckwert. top: Option<(Point2, [f32; 3])>, + /// [281] Geneigte Platte (`SlabInput::slope`): alle Höhen um den Versatz der Neigungsebene verschoben. + shear: Option<[f32; 4]>, } impl Prism { + /// [281] Höhenversatz der geneigten Platte am Grundrisspunkt (sonst 0). + fn dz(&self, p: Point2) -> f32 { + match self.shear { + Some(s) => s[2] * (p[0] - s[0]) + s[3] * (p[1] - s[1]), + None => 0.0, + } + } + /// Oberkante an einem Grundriss-Punkt. fn top_at(&self, p: Point2) -> f32 { match self.top { @@ -447,6 +457,7 @@ fn wall_prism(index: usize, wall: &WallInput) -> Option { cut: wall.cut.clone(), monolith: None, top: wall.top_plane.map(|c| (wall.start, c)), + shear: None, }) } @@ -472,6 +483,7 @@ fn slab_prism(index: usize, slab: &SlabInput) -> Option { cut: slab.cut.clone(), monolith: slab.monolith.clone(), top: None, + shear: slab.slope, }) } @@ -653,6 +665,11 @@ fn prism_bounds(plane: &SectionPlane, prism: &Prism) -> PrismBounds { } } + // [281] Geneigte Platte: Hüllhöhe über den ganzen Umriss (konservativ, wie die achsparallele Näherung). + let (dlo, dhi) = match prism.shear { + Some(_) => prism.footprint.iter().fold((f32::INFINITY, f32::NEG_INFINITY), |(a, b), &p| (a.min(prism.dz(p)), b.max(prism.dz(p)))), + None => (0.0, 0.0), + }; PrismBounds { kind: prism.kind, index: prism.index, @@ -661,8 +678,8 @@ fn prism_bounds(plane: &SectionPlane, prism: &Prism) -> PrismBounds { depth_min, depth_max, monolith: prism.monolith.clone(), - z0: prism.z0, - z1: prism.z1, + z0: prism.z0 + dlo, + z1: prism.z1 + dhi, opening_voids, } } @@ -897,19 +914,23 @@ fn prism_wireframe_edges(prism: &Prism) -> Vec<([f32; 3], [f32; 3], HeightBias)> let n = prism.footprint.len(); let mut edges = Vec::with_capacity(3 * n); for i in 0..n { + let d = prism.dz(prism.footprint[i]); edges.push(( - to_world(prism.footprint[i], prism.z0), - to_world(prism.footprint[i], prism.top_at(prism.footprint[i])), + to_world(prism.footprint[i], prism.z0 + d), + to_world(prism.footprint[i], prism.top_at(prism.footprint[i]) + d), HeightBias::Vertical, )); } + // [281] Geneigte Platte: Boden- und Deckelkanten variieren in der Höhe. + let sheared = prism.shear.is_some(); for i in 0..n { let a = prism.footprint[i]; let b = prism.footprint[(i + 1) % n]; - edges.push((to_world(a, prism.z0), to_world(b, prism.z0), HeightBias::BottomCap)); + let (da, db) = (prism.dz(a), prism.dz(b)); + edges.push((to_world(a, prism.z0 + da), to_world(b, prism.z0 + db), if sheared { HeightBias::Vertical } else { HeightBias::BottomCap })); // Schräge Deckelkante ([G2]): Höhe variiert, geschlossene Randbehandlung. - let bias = if prism.top.is_some() { HeightBias::Vertical } else { HeightBias::TopCap }; - edges.push((to_world(a, prism.top_at(a)), to_world(b, prism.top_at(b)), bias)); + let bias = if prism.top.is_some() || sheared { HeightBias::Vertical } else { HeightBias::TopCap }; + edges.push((to_world(a, prism.top_at(a) + da), to_world(b, prism.top_at(b) + db), bias)); } edges } @@ -1228,6 +1249,15 @@ fn cut_polygons_and_prisms( } else { (rz1, rz1) }; + // [281] Geneigte Platte: Unter- und Oberkante längs der Schnittlinie um den Versatz verschoben. + let (dlo, dhi) = match prism.shear { + Some(_) => { + let (p0, ua) = (plane.plan_point(), plane.plan_u_axis()); + let at = |u: f32| prism.dz([p0[0] + u * ua[0], p0[1] + u * ua[1]]); + (at(rlo), at(rhi)) + } + None => (0.0, 0.0), + }; cut_polygons.push(CutPolygon { component: ComponentRef { kind: prism.kind, @@ -1235,7 +1265,7 @@ fn cut_polygons_and_prisms( }, color: prism.color, hatch: prism.hatch, - pts: vec![[rlo, rz0], [rhi, rz0], [rhi, zb], [rlo, za]], + pts: vec![[rlo, rz0 + dlo], [rhi, rz0 + dhi], [rhi, zb + dhi], [rlo, za + dlo]], cut: prism.cut.clone(), }); } @@ -1310,6 +1340,7 @@ mod tests { ]; let slabs = vec![SlabInput { monolith: None, + slope: None, outline: vec![[-0.5, -0.5], [3.5, -0.5], [3.5, 3.5], [-0.5, 3.5]], z_bottom: -0.2, z_top: 0.0, diff --git a/src-tauri/render3d/src/section_boolean.rs b/src-tauri/render3d/src/section_boolean.rs index c07876da..0642a154 100644 --- a/src-tauri/render3d/src/section_boolean.rs +++ b/src-tauri/render3d/src/section_boolean.rs @@ -24,6 +24,16 @@ fn poly_from_rect(src: &CutPolygon, r: Rect) -> CutPolygon { } } +/// [281] Liegen alle Ecken auf den Kanten der Hüllbox (achsparalleles Rechteck)? +fn is_axis_rect(pts: &[[f32; 2]]) -> bool { + let (mut u0, mut u1, mut v0, mut v1) = (f32::INFINITY, f32::NEG_INFINITY, f32::INFINITY, f32::NEG_INFINITY); + for p in pts { + (u0, u1, v0, v1) = (u0.min(p[0]), u1.max(p[0]), v0.min(p[1]), v1.max(p[1])); + } + const E: f32 = 1e-5; + pts.iter().all(|p| ((p[0] - u0).abs() < E || (p[0] - u1).abs() < E) && ((p[1] - v0).abs() < E || (p[1] - v1).abs() < E)) +} + /// Globale Schnitt-Dominanz (staerkere `join_priority` schneidet schwaechere weg, gleiche Komponente /// und Prioritaet verschmilzt) — siehe `dossier_hatch::section_dominance`. pub fn subtract_dominant_bands(bands: Vec) -> Vec { @@ -36,11 +46,11 @@ pub fn subtract_dominant_bands(bands: Vec) -> Vec { let n = ids.len() as u32; *ids.entry(id).or_insert(n) }); - Band { - rect: rect_of_points(b.pts.iter().map(|p| (p[0] as f64, p[1] as f64))), - prio: meta.and_then(|c| c.join_priority).map(f64::from), - comp, - } + // [281] Schräge Bänder (geneigte Platte) sind kein Rechteck: nehmen an der Dominanz nicht teil + // (wie Dach-Schichten), sonst schnitte ihre Hüllbox zu viel weg. + let rect = rect_of_points(b.pts.iter().map(|p| (p[0] as f64, p[1] as f64))); + let prio = meta.and_then(|c| c.join_priority).map(f64::from).filter(|_| b.component.kind != crate::section::ComponentKind::Slab || is_axis_rect(&b.pts)); + Band { rect, prio, comp } }) .collect(); dominant_bands(&inp) diff --git a/src-tauri/render3d/src/section_fill.rs b/src-tauri/render3d/src/section_fill.rs index 24793546..64c3d07f 100644 --- a/src-tauri/render3d/src/section_fill.rs +++ b/src-tauri/render3d/src/section_fill.rs @@ -575,6 +575,7 @@ mod tests { // z in [2.0, 2.4]; Prio 100 (Beton laeuft durch, schneidet die Wand). let slab = SlabInput { monolith: None, + slope: None, outline: vec![[-1.0, -1.0], [4.0, -1.0], [4.0, 1.0], [-1.0, 1.0]], z_bottom: 2.0, z_top: 2.4, @@ -653,6 +654,7 @@ mod tests { // Wand in u ab (Umriss ueber y in [-1,1]). let screed = SlabInput { monolith: None, + slope: None, outline: vec![[-1.0, -1.0], [4.0, -1.0], [4.0, 1.0], [-1.0, 1.0]], z_bottom: 1.0, z_top: 1.06, @@ -668,6 +670,7 @@ mod tests { // Daemmung-Slab (Prio 20, Muster 4), z in [0.96,1.0], gleiche u-Deckung. let insulation = SlabInput { monolith: None, + slope: None, outline: vec![[-1.0, -1.0], [4.0, -1.0], [4.0, 1.0], [-1.0, 1.0]], z_bottom: 0.96, z_top: 1.0, diff --git a/src-tauri/render3d/src/types.rs b/src-tauri/render3d/src/types.rs index cc180e8d..2df8b89c 100644 --- a/src-tauri/render3d/src/types.rs +++ b/src-tauri/render3d/src/types.rs @@ -301,6 +301,21 @@ pub struct SlabInput { /// verschwinden, sichtbar bleibt der Umriss (Sägezahn). `None` = Einzelteil. #[serde(default)] pub monolith: Option, + /// [281] Geneigte Decke/Rampe: Neigungsebene `[ox, oy, gx, gy]` (Modell-Meter) — jede Höhe der Platte liegt + /// am Grundrisspunkt (x, y) um `gx·(x−ox) + gy·(y−oy)` höher (Ober- und Unterkante parallel verschoben, + /// Mantel bleibt lotrecht). `None` = waagrecht. + #[serde(default)] + pub slope: Option<[f32; 4]>, +} + +impl SlabInput { + /// [281] Höhenversatz der Neigungsebene am Grundrisspunkt (waagrecht 0). + pub fn dz(&self, p: Point2) -> f32 { + match self.slope { + Some(s) => s[2] * (p[0] - s[0]) + s[3] * (p[1] - s[1]), + None => 0.0, + } + } } /// EINE Dachflächen-Schicht für den 3D-Live-Schnitt (`crate::roof_cut`). diff --git a/src/commands/cmds/ramp.test.ts b/src/commands/cmds/ramp.test.ts new file mode 100644 index 00000000..004ed259 --- /dev/null +++ b/src/commands/cmds/ramp.test.ts @@ -0,0 +1,82 @@ +/** + * [281] `rampCommand` — Umriss, Gefällelinie, Gefälle in %: eine Decke mit `slope` (Rampe), OK am Anfang auf dem + * Geschossboden; Enter beim Gefälle übernimmt 6 %. + */ +import { describe, expect, it } from "vitest"; +import { rampCommand, RAMP_DEFAULT_PERCENT } from "./ramp"; +import type { CommandContext, CommandState, Project, Vec2 } from "../types"; + +function project(): Project { + return { + id: "t", + name: "T", + lineStyles: [], + hatches: [], + components: [{ id: "beton", name: "Beton", color: "#999999", joinPriority: 100 }], + wallTypes: [{ id: "aw", name: "AW", layers: [{ componentId: "beton", thickness: 0.2 }] }], + ceilingTypes: [{ id: "ct", name: "Platte", layers: [{ componentId: "beton", thickness: 0.25 }] }], + drawingLevels: [{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 }], + layers: [{ code: "30", name: "Decken", color: "#000000", lw: 0.35, visible: true, locked: false }], + walls: [], + openings: [], + ceilings: [], + stairs: [], + rooms: [], + drawings2d: [], + context: [], + } as unknown as Project; +} + +const ctxOf = (p: Project): CommandContext => ({ + project: p, + level: p.drawingLevels[0], + defaultCategoryCode: "30", + activeLineStyleId: "solid", + activeWallTypeId: "aw", + lastPoint: null, + selection: { wallIds: [], drawingId: null }, +}); + +function run(pts: Vec2[], percent: number | null): Project { + const p = project(); + const ctx = ctxOf(p); + let state: CommandState = rampCommand.init(); + let commit: ((q: Project) => Project) | undefined; + for (const point of pts) { + const [ns, res] = rampCommand.onInput(state, { kind: "point", point }, ctx); + state = ns; + commit = res.commit ?? commit; + } + const [, res] = percent === null ? rampCommand.onConfirm(state, ctx) : rampCommand.onInput(state, { kind: "number", value: percent }, ctx); + commit = res.commit ?? commit; + return commit ? commit(p) : p; +} + +const outline: Vec2[] = [ + { x: 0, y: 0 }, + { x: 10, y: 0 }, + { x: 10, y: 3 }, + { x: 0, y: 3 }, + { x: 0, y: 0 }, // Klick auf den Startpunkt schliesst +]; + +describe("rampCommand", () => { + it("Umriss + Gefällelinie + −15 % ergibt eine abwärts geneigte Rampe", () => { + const q = run([...outline, { x: 0, y: 1.5 }, { x: 10, y: 1.5 }], -15); + const c = q.ceilings![0]; + expect(c.slope?.ramp).toBe(true); + expect(c.slope?.rise).toBeCloseTo(-1.5, 9); + expect(c.slope?.from).toEqual({ x: 0, y: 1.5 }); + expect(c.top).toEqual({ mode: "floor", floorId: "eg", offset: 0 }); + }); + + it("Enter beim Gefälle übernimmt die Vorgabe (6 %)", () => { + const q = run([...outline, { x: 0, y: 1.5 }, { x: 5, y: 1.5 }], null); + expect(q.ceilings![0].slope?.rise).toBeCloseTo((RAMP_DEFAULT_PERCENT / 100) * 5, 9); + }); + + it("Gefälle 0 legt nichts an", () => { + const q = run([...outline, { x: 0, y: 1.5 }, { x: 5, y: 1.5 }], 0); + expect(q.ceilings ?? []).toHaveLength(0); + }); +}); diff --git a/src/commands/cmds/ramp.ts b/src/commands/cmds/ramp.ts new file mode 100644 index 00000000..8de1f35e --- /dev/null +++ b/src/commands/cmds/ramp.ts @@ -0,0 +1,133 @@ +// [281] Rampe — Decke mit Neigung als eigener Befehl: Umriss (wie „Decke"), dann die Gefällelinie (Anfang auf +// Geschosshöhe, Ende) und das Gefälle in %. Der Kern (`cmd_create.rs`, `ramp`) legt eine Decke mit `slope` +// ({from, to, rise, ramp: true}) und OK am Anfang auf dem Geschossboden an. +// Schritte: +// 1) „Erster Umrisspunkt der Rampe:" → Punkt +// 2) „Nächster Punkt ( Schliessen ):" … Klick auf den Startpunkt, „Schliessen" oder Enter (≥ 3 Punkte) +// 3) „Anfang der Gefällelinie:" → Punkt +// 4) „Ende der Gefällelinie:" → Punkt +// 5) „Gefälle in % (negativ = abwärts) <6>:" → Zahl, Enter = 6 % (SIA 500, rollstuhlgerecht) + +import type { Command, CommandContext, CommandResult, CommandState, CmdOption, DraftShape, ToolDraft, Vec2 } from "../types"; +import { createMutation, xy } from "../createCore"; + +const EPS = 1e-6; +const CLOSE_HIT = 0.08; +/** Vorgabe, wenn beim Gefälle nur Enter kommt (SIA 500: höchstens 6 %). */ +export const RAMP_DEFAULT_PERCENT = 6; + +type Phase = "start" | "next" | "from" | "to" | "percent"; +interface RampState extends CommandState { + phase: Phase; + points: Vec2[]; + from?: Vec2; + to?: Vec2; + cursor: Vec2 | null; +} + +const CLOSE: CmdOption = { id: "close", labelKey: "cmd.polyline.close" }; +const UNDO: CmdOption = { id: "undo", labelKey: "cmd.polyline.undo" }; + +const dist = (a: Vec2, b: Vec2) => Math.hypot(b.x - a.x, b.y - a.y); + +function draft(s: RampState): ToolDraft { + const closed = s.phase !== "start" && s.phase !== "next"; + const pts = !closed && s.cursor ? [...s.points, s.cursor] : s.points; + const preview: DraftShape[] = [{ kind: "poly", pts, closed: closed || pts.length >= 3 }]; + const a = s.from; + const b = s.to ?? (s.phase === "to" ? s.cursor : null); + if (a && b) preview.push({ kind: "poly", pts: [a, b], closed: false }); + const d: ToolDraft = { preview, vertices: s.points }; + if (a && b && dist(a, b) > EPS) d.hud = { at: b, text: `${dist(a, b).toFixed(2)} m` }; + return d; +} + +const idle = (): RampState => ({ phase: "start", points: [], cursor: null, lastPoint: null }); + +function commit(s: RampState, percent: number, ctx: CommandContext): [CommandState, CommandResult] { + const req = { cmd: "ramp", pts: s.points.map(xy), from: xy(s.from!), to: xy(s.to!), percent }; + return [idle(), { draft: null, done: true, commit: createMutation(ctx, req) }]; +} + +const closeOutline = (s: RampState): [CommandState, CommandResult] => { + const ns: RampState = { ...s, phase: "from", cursor: null, lastPoint: null }; + return [ns, { draft: draft(ns) }]; +}; + +export const rampCommand: Command = { + name: "ramp", + labelKey: "cmd.ramp.label", + floorOnly: true, + prompt: (st) => { + const p = (st as RampState).phase; + return p === "start" ? "cmd.ramp.start" : p === "next" ? "cmd.ramp.next" : p === "from" ? "cmd.ramp.from" : p === "to" ? "cmd.ramp.to" : "cmd.ramp.percent"; + }, + accepts: (st) => { + const p = (st as RampState).phase; + return p === "percent" ? ["number"] : p === "next" ? ["point", "number", "option"] : ["point", "number"]; + }, + options: (st) => { + const s = st as RampState; + if (s.phase !== "next") return []; + return s.points.length >= 3 ? [CLOSE, UNDO] : [UNDO]; + }, + init: () => idle(), + + onInput: (state, input, ctx): [CommandState, CommandResult] => { + const s = state as RampState; + if (input.kind === "option") { + if (s.phase !== "next") return [s, { draft: draft(s) }]; + if (input.id === "undo") { + const points = s.points.slice(0, -1); + if (points.length === 0) return [idle(), { draft: null }]; + const ns = { ...s, points, lastPoint: points[points.length - 1] }; + return [ns, { draft: draft(ns) }]; + } + if (input.id === "close" && s.points.length >= 3) return closeOutline(s); + return [s, { draft: draft(s) }]; + } + if (s.phase === "percent") { + if (input.kind !== "number" || !isFinite(input.value) || input.value === 0) return [s, { draft: draft(s) }]; + return commit(s, input.value, ctx); + } + if (input.kind !== "point") return [s, { draft: s.phase === "start" ? null : draft(s) }]; + const pt = input.point; + switch (s.phase) { + case "start": { + const ns: RampState = { phase: "next", points: [pt], cursor: pt, lastPoint: pt }; + return [ns, { draft: draft(ns) }]; + } + case "next": { + if (s.points.length >= 3 && dist(s.points[0], pt) < CLOSE_HIT) return closeOutline(s); + if (dist(s.points[s.points.length - 1], pt) < EPS) return [s, { draft: draft(s) }]; + const ns: RampState = { ...s, points: [...s.points, pt], cursor: pt, lastPoint: pt }; + return [ns, { draft: draft(ns) }]; + } + case "from": { + const ns: RampState = { ...s, phase: "to", from: pt, cursor: pt, lastPoint: pt }; + return [ns, { draft: draft(ns) }]; + } + default: { + if (!s.from || dist(s.from, pt) < 0.01) return [s, { draft: draft(s) }]; + const ns: RampState = { ...s, phase: "percent", to: pt, cursor: null, lastPoint: pt }; + return [ns, { draft: draft(ns) }]; + } + } + }, + + onMove: (state, point): [CommandState, CommandResult] => { + const s = state as RampState; + if (s.phase === "start") return [s, { draft: null }]; + const ns: RampState = { ...s, cursor: point }; + return [ns, { draft: draft(ns) }]; + }, + + // Enter: Umriss schliessen (≥ 3 Punkte) bzw. beim Gefälle die Vorgabe übernehmen. + onConfirm: (state, ctx): [CommandState, CommandResult] => { + const s = state as RampState; + if (s.phase === "next" && s.points.length >= 3) return closeOutline(s); + if (s.phase === "percent") return commit(s, RAMP_DEFAULT_PERCENT, ctx); + return [idle(), { draft: null, done: true }]; + }, + onCancel: (): [CommandState, CommandResult] => [idle(), { draft: null, done: true }], +}; diff --git a/src/commands/registry.ts b/src/commands/registry.ts index 8bdd15d5..fd3519a7 100644 --- a/src/commands/registry.ts +++ b/src/commands/registry.ts @@ -21,6 +21,7 @@ import { solidBoolCommand } from "./cmds/solidbool"; import { solidToPartsCommand } from "./cmds/solidToParts"; import { voidBoxCommand } from "./cmds/voidbox"; import { ceilingOpeningCommand } from "./cmds/ceilingOpening"; +import { rampCommand } from "./cmds/ramp"; import { roofWindowCommand } from "./cmds/roofWindow"; import { dormerCommand } from "./cmds/dormer"; import { roofHoleCommand } from "./cmds/roofHole"; @@ -103,6 +104,7 @@ export const COMMANDS: Record = { solidtoparts: solidToPartsCommand, voidbox: voidBoxCommand, ceilingopening: ceilingOpeningCommand, + ramp: rampCommand, roofwindow: roofWindowCommand, dormer: dormerCommand, roofhole: roofHoleCommand, @@ -216,6 +218,7 @@ export const ALIASES: Record = { kugel: "solid", body: "solid", deckenloch: "ceilingopening", + rampe: "ramp", aussparung: "ceilingopening", dachfenster: "roofwindow", oberlicht: "roofwindow", diff --git a/src/i18n/de.ts b/src/i18n/de.ts index bec3deea..cdb2611c 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -664,6 +664,18 @@ export const de = { "objinfo.ceiling.top": "Oberkante (OK)", "objinfo.ceiling.bottom": "Unterkante (UK)", "objinfo.ceiling.height": "Dicke (OK−UK)", + "objinfo.ceiling.slope.section": "Neigung", + "objinfo.ceiling.slope.off": "aus", + "objinfo.ceiling.slope.on": "Gefälle", + "objinfo.ceiling.slope.ramp": "Rampe", + "objinfo.ceiling.slope.percent": "Gefälle", + "objinfo.ceiling.slope.angle": "Neigungswinkel", + "objinfo.ceiling.slope.rise": "Höhenunterschied", + "objinfo.ceiling.slope.direction": "Richtung (aufwärts)", + "objinfo.ceiling.slope.refX": "Bezugspunkt X", + "objinfo.ceiling.slope.refY": "Bezugspunkt Y", + "objinfo.ceiling.slope.length": "Länge Gefällelinie", + "objinfo.ceiling.slope.hint": "Am Bezugspunkt liegt die Decke auf der eingestellten OK/UK; in Richtung aufwärts steigt sie um den Höhenunterschied (Schichten folgen, Dicke lotrecht).", "objinfo.ceiling.openings": "Aussparungen", "objinfo.ceiling.removeOpening": "Aussparung entfernen", "objinfo.ceiling.area": "Fläche", @@ -2039,6 +2051,12 @@ export const de = { "cmd.ceiling.label": "Decke", "cmd.ceiling.start": "Erster Umrisspunkt der Decke:", "cmd.ceiling.next": "Nächster Punkt ( Schliessen ):", + "cmd.ramp.label": "Rampe", + "cmd.ramp.start": "Erster Umrisspunkt der Rampe:", + "cmd.ramp.next": "Nächster Punkt ( Schliessen ):", + "cmd.ramp.from": "Anfang der Gefällelinie (auf Geschosshöhe):", + "cmd.ramp.to": "Ende der Gefällelinie:", + "cmd.ramp.percent": "Gefälle in % (negativ = abwärts) <6>:", "cmd.solidbool.label": "Körper verschneiden", "cmd.solidbool.first": "Ersten Körper wählen:", "cmd.solidbool.second": "Zweiten Körper wählen:", @@ -3954,6 +3972,7 @@ export const de = { "history.cmd.block": "Block einfügen", "history.cmd.break": "Auftrennen", "history.cmd.ceiling": "Decke zeichnen", + "history.cmd.ramp": "Rampe zeichnen", "history.cmd.roofWindow": "Dachfenster", "history.cmd.dormer": "Gaube", "history.cmd.ceilingOpening": "Deckenöffnung", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 73cd4c2f..0ecda76f 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -663,6 +663,18 @@ export const en: Record = { "objinfo.ceiling.top": "Top (OK)", "objinfo.ceiling.bottom": "Bottom (UK)", "objinfo.ceiling.height": "Thickness (OK−UK)", + "objinfo.ceiling.slope.section": "Slope", + "objinfo.ceiling.slope.off": "off", + "objinfo.ceiling.slope.on": "Slope", + "objinfo.ceiling.slope.ramp": "Ramp", + "objinfo.ceiling.slope.percent": "Gradient", + "objinfo.ceiling.slope.angle": "Slope angle", + "objinfo.ceiling.slope.rise": "Height difference", + "objinfo.ceiling.slope.direction": "Direction (upward)", + "objinfo.ceiling.slope.refX": "Reference point X", + "objinfo.ceiling.slope.refY": "Reference point Y", + "objinfo.ceiling.slope.length": "Slope line length", + "objinfo.ceiling.slope.hint": "At the reference point the slab sits at its set top/bottom; in the upward direction it rises by the height difference (layers follow, thickness measured vertically).", "objinfo.ceiling.openings": "Openings", "objinfo.ceiling.removeOpening": "Remove opening", "objinfo.ceiling.area": "Area", @@ -2028,6 +2040,12 @@ export const en: Record = { "cmd.ceiling.label": "Ceiling", "cmd.ceiling.start": "First outline point of ceiling:", "cmd.ceiling.next": "Next point ( Close ):", + "cmd.ramp.label": "Ramp", + "cmd.ramp.start": "First outline point of the ramp:", + "cmd.ramp.next": "Next point ( Close ):", + "cmd.ramp.from": "Start of the slope line (at storey level):", + "cmd.ramp.to": "End of the slope line:", + "cmd.ramp.percent": "Gradient in % (negative = downward) <6>:", "cmd.solidbool.label": "Boolean solids", "cmd.solidbool.first": "Select first solid:", "cmd.solidbool.second": "Select second solid:", @@ -3940,6 +3958,7 @@ export const en: Record = { "history.cmd.block": "Insert block", "history.cmd.break": "Break", "history.cmd.ceiling": "Draw ceiling", + "history.cmd.ramp": "Draw ramp", "history.cmd.roofWindow": "Roof window", "history.cmd.dormer": "Dormer", "history.cmd.ceilingOpening": "Ceiling opening", diff --git a/src/model/sampleProjectWettbewerb.test.ts b/src/model/sampleProjectWettbewerb.test.ts index b59ef06b..974d626c 100644 --- a/src/model/sampleProjectWettbewerb.test.ts +++ b/src/model/sampleProjectWettbewerb.test.ts @@ -36,8 +36,10 @@ describe("Beispielprojekt Wettbewerb", () => { expect(p.rooms!.filter((r) => r.floorId === f).length).toBe(10); } // [279] zwei Balkonplatten mit Geländer (Stäbe 1. OG, Glas 2. OG) - expect(p.ceilings!.length).toBe(5); + expect(p.ceilings!.length).toBe(6); expect(p.railings!.map((r) => r.kind)).toEqual(["bars", "glass"]); + // [281] Eingangsrampe (6 %) an der Ostfassade. + expect(p.ceilings!.find((c) => c.id === "c-rampe")?.slope?.ramp).toBe(true); expect(p.roofs![0].shape).toBe("flach"); expect(p.stairs!.length).toBe(2); expect(p.rooms!.length).toBe(30); diff --git a/src/model/sampleProjectWettbewerb.ts b/src/model/sampleProjectWettbewerb.ts index cfd0c5ef..63e9428f 100644 --- a/src/model/sampleProjectWettbewerb.ts +++ b/src/model/sampleProjectWettbewerb.ts @@ -64,6 +64,7 @@ const LEVELS: DrawingLevel[] = [ const CEILING_TYPES: CeilingType[] = [ { id: "wb-ct-decke", name: "Geschossdecke Unterlagsboden, Trittschall, STB 37 cm", layers: [L("std-c-parkett", 0.015), L("std-c-zementestrich", 0.065), L("std-c-trittschall", 0.04), L("std-c-stahlbeton", 0.24), L("std-c-innenputz", 0.01)] }, { id: "wb-ct-bodenplatte", name: "Bodenplatte STB auf XPS", layers: [L("std-c-zementestrich", 0.08), L("std-c-xps", 0.12), L("std-c-stahlbeton", 0.25), L("std-c-kies", 0.1)] }, + { id: "wb-ct-rampe", name: "Rampe STB auf Kies", layers: [L("std-c-stahlbeton", 0.22), L("std-c-kies", 0.15)] }, ]; const ROOF_TYPES: RoofType[] = [{ id: "wb-rt-flach", name: "Flachdach Umkehrdach bekiest", layers: [L("std-c-kies", 0.06), L("std-c-xps", 0.18), L("std-c-stahlbeton", 0.22)] }]; const WINDOW_TYPES: WindowType[] = [ @@ -148,6 +149,12 @@ const ceilings: NonNullable = [ { id: "c-bodenplatte", type: "ceiling", floorId: "eg", categoryCode: "30", outline: slab, wallTypeId: "", ceilingTypeId: "wb-ct-bodenplatte", top: { mode: "floor", floorId: "eg", offset: 0 }, loadBearing: true }, { id: "c-eg", type: "ceiling", floorId: "eg", categoryCode: "30", outline: slab, openings: [HOLE], wallTypeId: "", ceilingTypeId: "wb-ct-decke", loadBearing: true }, { id: "c-og1", type: "ceiling", floorId: "og1", categoryCode: "30", outline: slab, openings: [HOLE], wallTypeId: "", ceilingTypeId: "wb-ct-decke", loadBearing: true }, + // [281] Eingangsrampe an der Ostfassade (im Schnitt B-B längs): 6 m mit 6 % vom Gelände (−0.36) bis ±0.00. + { + id: "c-rampe", type: "ceiling", floorId: "eg", categoryCode: "30", outline: [P(W + HA, 2), P(W + HA + 6, 2), P(W + HA + 6, 5), P(W + HA, 5)], + wallTypeId: "", ceilingTypeId: "wb-ct-rampe", top: { mode: "floor", floorId: "eg", offset: 0 }, isExternal: true, + slope: { from: P(W + HA, 3.5), to: P(W + HA + 6, 3.5), rise: -0.36, ramp: true }, + }, ]; // [279] Balkone an der Südfassade (Wohnung West): Betonplatte 1.4 m tief über dem EG bzw. 1. OG, Geländer an den drei freien // Seiten — Stäbe im 1. OG, Glas im 2. OG. Fusshöhe auf der Plattenoberkante (Geschoss-UK), Höhe 1.00 m nach SIA 358. diff --git a/src/model/types.generated.ts b/src/model/types.generated.ts index 92ac8bce..45c3b6f9 100644 --- a/src/model/types.generated.ts +++ b/src/model/types.generated.ts @@ -222,6 +222,8 @@ export type Ceiling = { * Z-Wert; „floor" bindet die UK an ein Geschoss. */ bottom?: VerticalAnchor; + /** [281] Neigung (geneigte Decke, Rampe, Gefälle). Fehlt ⇒ waagrecht. */ + slope?: CeilingSlope; /** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */ renovation?: Renovation; /** @@ -230,6 +232,26 @@ export type Ceiling = { designOption?: DesignOptionRef; }; +/** + * [281] Neigung einer Decke oder Rampe: Ober- und Unterkante (alle Schichten) folgen einer Ebene, die + * längs der Gefällelinie `from` → `to` gleichmässig steigt oder fällt. Am Bezugspunkt `from` liegt die Decke + * auf ihrer eingestellten Höhe (`top`/`bottom`); bei `to` um `rise` höher (negativ = tiefer). Quer zur + * Gefällelinie bleibt die Höhe gleich. Die Dicke bleibt lotrecht gemessen (Schichten verschoben, nicht gedreht). + * Gefälle in % = `rise` / |`to` − `from`| · 100. + */ +export type CeilingSlope = { + /** Bezugspunkt im Grundriss (Meter): dort gilt die eingestellte Höhe der Decke. */ + from: Vec2; + /** Zweiter Punkt der Gefällelinie (Meter); die Richtung `from` → `to` ist die Fallinie. */ + to: Vec2; + /** Höhenunterschied der Decke von `from` nach `to` (Meter; positiv = steigt zu `to`). */ + rise: number; + /** + * Als Rampe darstellen: Grundriss mit Lauflinie und Pfeil (aufwärts), IFC als `IfcRamp`/`IfcRampFlight`. + */ + ramp?: boolean; +}; + /** * Ein Deckentyp (Deckenstil) = geordneter Schichtaufbau EINER Decke, liegend * gestapelt (oben → unten) — das horizontale Gegenstück zum `WallType`. Nutzt diff --git a/src/panels/ToolsPanel.tsx b/src/panels/ToolsPanel.tsx index 12e3ca64..728f01b8 100644 --- a/src/panels/ToolsPanel.tsx +++ b/src/panels/ToolsPanel.tsx @@ -379,7 +379,7 @@ const TOOLS_2D: ToolId[] = [ "image", ]; const TOOLS_3D: ToolId[] = ["wall", "ceiling", "window", "door", "stair", "room"]; -const COMMANDS_3D = ["column", "gelaender", "tree", "circlestotrees", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "solidtoparts", "sectionline", "viewline", "ansichten", "autodim", "excavation"]; +const COMMANDS_3D = ["column", "gelaender", "tree", "circlestotrees", "ceilingopening", "ramp", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "solidtoparts", "sectionline", "viewline", "ansichten", "autodim", "excavation"]; const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "split", "extend", "fillet", "chamfer", "join", "defblock", "measure", "erkennen"]; type ToolsView = "list" | "icons"; diff --git a/src/panels/host.ts b/src/panels/host.ts index a9521cf4..3ad127ed 100644 --- a/src/panels/host.ts +++ b/src/panels/host.ts @@ -35,6 +35,7 @@ import type { Stair, StairShape, Vec2, + CeilingSlope, VerticalAnchor, WallReferenceLine, WallType, @@ -451,6 +452,11 @@ export interface PanelHostValue { * haben — additive Erweiterung analog `onSetWallBottom`. */ onSetCeilingBottom?: (anchor: VerticalAnchor | null) => void; + /** + * [281] Neigung der gewählten Decke(n) setzen (`null` = waagrecht). `"enable"` schaltet sie mit einer Vorgabe ein: + * Gefällelinie längs der längeren Seite der Hüllbox, Bezugspunkt in deren Mitte am Anfang, 2 % bzw. als Rampe 6 %. + */ + onSetCeilingSlope?: (slope: CeilingSlope | null | { enable: "slope" | "ramp" }) => void; // ── Öffnungs-Attribute (Object-Info-Panel; nur die selektierte Öffnung) ─ /** Wechselt die Art (Fenster/Tür); setzt bei Tür die Tür-Defaults. */ diff --git a/src/panels/objectInfo/CeilingSection.tsx b/src/panels/objectInfo/CeilingSection.tsx index 43fa0099..2ea521b5 100644 --- a/src/panels/objectInfo/CeilingSection.tsx +++ b/src/panels/objectInfo/CeilingSection.tsx @@ -3,6 +3,7 @@ import { useStore } from "../../state/appStore"; import type { CeilingInfo } from "../../state/selectionInfo"; +import type { CeilingSlope } from "../../model/types"; import { usePanelHost } from "../host"; import { t } from "../../i18n"; import { Dropdown } from "../../ui/Dropdown"; @@ -174,6 +175,114 @@ export function CeilingSection({ {t("objinfo.ceiling.height")} {formatM(ceiling.zTop - ceiling.zBottom)} + + + ); +} + +const DEG = Math.PI / 180; + +/** + * [281] Abschnitt „Neigung": aus / Gefälle / Rampe; Gefälle in % und Grad, Höhenunterschied, Richtung (aufwärts) und + * Bezugspunkt. Gespeichert wird nur `slope` ({from, to, rise, ramp}); die Felder rechnen daraus um. + */ +function SlopeRows({ ceiling, host }: { ceiling: CeilingInfo; host: ReturnType }) { + const s = ceiling.slope; + const mode: "off" | "on" | "ramp" = !s ? "off" : s.ramp ? "ramp" : "on"; + const len = s ? Math.hypot(s.to.x - s.from.x, s.to.y - s.from.y) : 0; + const pct = s && len > 1e-9 ? (s.rise / len) * 100 : 0; + // Richtung aufwärts: von `from` nach `to`, bei negativem Höhenunterschied umgekehrt. + const dirDeg = s ? (((Math.atan2(s.to.y - s.from.y, s.to.x - s.from.x) / DEG + (s.rise < 0 ? 180 : 0)) % 360) + 360) % 360 : 0; + const set = (patch: Partial) => { + if (s) host.onSetCeilingSlope?.({ ...s, ...patch }); + }; + const setRise = (rise: number) => { + if (isFinite(rise) && rise !== 0) set({ rise }); + }; + const choose = (m: "off" | "on" | "ramp") => { + if (m === mode) return; + if (m === "off") host.onSetCeilingSlope?.(null); + else host.onSetCeilingSlope?.({ enable: m === "ramp" ? "ramp" : "slope" }); + }; + return ( + <> +

+
+ {t("objinfo.ceiling.slope.section")} +
+
+
+ {(["off", "on", "ramp"] as const).map((m) => ( + + ))} +
+
+ {s && ( + <> +
+ setRise(Math.sign(s.rise || 1) * (v / 100) * len)} + /> +
+ v < 89 && setRise(Math.sign(s.rise || 1) * Math.tan(v * DEG) * len)} + /> + setRise(Math.sign(s.rise || 1) * v)} + /> + { + // Gefällelinie dreht um den Bezugspunkt; aufwärts = Richtung, der Höhenunterschied wird positiv. + const r = a * DEG; + set({ to: { x: s.from.x + Math.cos(r) * len, y: s.from.y + Math.sin(r) * len }, rise: Math.abs(s.rise) }); + }} + /> + set({ from: { x, y: s.from.y }, to: { x: s.to.x + x - s.from.x, y: s.to.y } })} + /> + set({ from: { x: s.from.x, y }, to: { x: s.to.x, y: s.to.y + y - s.from.y } })} + /> +
+ {t("objinfo.ceiling.slope.length")} + {formatM(len)} +
+ + )} ); } diff --git a/src/plan/pickTypes.ts b/src/plan/pickTypes.ts index d19a00b5..c2c92f9b 100644 --- a/src/plan/pickTypes.ts +++ b/src/plan/pickTypes.ts @@ -58,6 +58,8 @@ export interface PickSlab { zBottom: number; zTop: number; ceilingId: string; + /** [281] Geneigte Decke: Neigungsebene `[ox, oy, gx, gy]`, Höhe + gx·(x−ox) + gy·(y−oy). */ + slope?: readonly [number, number, number, number]; } /** diff --git a/src/plan/toWalls3d/shared.ts b/src/plan/toWalls3d/shared.ts index 4eb8453c..fbb61dd4 100644 --- a/src/plan/toWalls3d/shared.ts +++ b/src/plan/toWalls3d/shared.ts @@ -201,6 +201,8 @@ export interface RSlab { * render3d `SlabInput::monolith`. */ monolith?: string; + /** [281] Geneigte Decke/Rampe: Neigungsebene `[ox, oy, gx, gy]` (render3d `SlabInput::slope`). */ + slope?: [number, number, number, number]; } /** Art eines rohen Kontext-Meshes (bestimmt in render3d die Default-Einfärbung). */ diff --git a/src/state/panelHost/elementAttributesHost.ts b/src/state/panelHost/elementAttributesHost.ts index 7b6240df..7c17546d 100644 --- a/src/state/panelHost/elementAttributesHost.ts +++ b/src/state/panelHost/elementAttributesHost.ts @@ -137,6 +137,33 @@ export function buildElementAttributesHost(c: FlatHostOpts) { onSetCeilingBottom: (anchor) => { if (selection?.kind === "ceiling") patchAll("ceilings", selection.id, { bottom: anchor ?? undefined }); }, + onSetCeilingSlope: (slope) => { + if (selection?.kind !== "ceiling") return; + if (slope === null) return patchAll("ceilings", selection.id, { slope: undefined }); + if (!("enable" in slope)) return patchAll("ceilings", selection.id, { slope }, "ceiling-slope"); + // [281] Einschalten: je Decke eine Vorgabe aus ihrer Hüllbox (längere Seite = Gefällelinie, aufwärts). + const ramp = slope.enable === "ramp"; + const ids = targetIds("ceilings", selection.id); + getState().groupChanges(() => { + for (const id of ids) { + const c = (getState().project.ceilings ?? []).find((x) => x.id === id); + if (!c || c.outline.length < 3) continue; + if (c.slope) { + updateCeiling(id, { slope: { ...c.slope, ramp: ramp || undefined } }); + continue; + } + const xs = c.outline.map((q) => q.x); + const ys = c.outline.map((q) => q.y); + const [x0, x1, y0, y1] = [Math.min(...xs), Math.max(...xs), Math.min(...ys), Math.max(...ys)]; + const alongX = x1 - x0 >= y1 - y0; + const from = alongX ? { x: x0, y: (y0 + y1) / 2 } : { x: (x0 + x1) / 2, y: y0 }; + const to = alongX ? { x: x1, y: (y0 + y1) / 2 } : { x: (x0 + x1) / 2, y: y1 }; + const len = Math.hypot(to.x - from.x, to.y - from.y); + if (!(len > 0.01)) continue; + updateCeiling(id, { slope: { from, to, rise: (ramp ? 0.06 : 0.02) * len, ramp: ramp || undefined } }); + } + }); + }, // ── Öffnungs-Attribute (nur bei selektierter Öffnung) ────────────────── onSetOpeningKind: (kind) => { if (selection?.kind === "opening") diff --git a/src/state/selectionInfo.ts b/src/state/selectionInfo.ts index 7d6d5a04..2f74dce8 100644 --- a/src/state/selectionInfo.ts +++ b/src/state/selectionInfo.ts @@ -19,6 +19,7 @@ import { EMPTY_SELECTION, mergeSelection, single } from "./selection"; import type { Selection } from "./selection"; import type { AttributeSource, + CeilingSlope, DimRef, ColumnProfile, ContextImage, @@ -200,6 +201,8 @@ export interface CeilingInfo { /** Aufgelöste absolute UK/OK (Meter). */ zBottom: number; zTop: number; + /** [281] Neigung (geneigte Decke/Rampe); fehlt = waagrecht. */ + slope?: CeilingSlope; /** Aussparungen (Treppenauge/Schacht) als BBox-Masse, Reihenfolge = Modell. */ openings: { width: number; depth: number }[]; } diff --git a/src/state/testHooks.ts b/src/state/testHooks.ts index 9933b7ca..74351c52 100644 --- a/src/state/testHooks.ts +++ b/src/state/testHooks.ts @@ -59,6 +59,8 @@ declare global { fakeRender: () => void; /** [173] Linien einer Klasse (z. B. "door-lintel") im Grundriss der aktiven Ebene (alle Kategorien, 1:50, Detailgrad der Anzeige). */ planLines: (cls: string) => number; + /** [281] Neigung je Decke (`id` → {rise, ramp}; waagrecht fehlt). */ + ceilingSlopes: () => Record; /** [173] Modelldarstellung der aktiven Ebene (Feld `modelViewOptionId`). */ modelView: () => string | undefined; /** [173] Schnitt der aktiven Ebene (1:50, Detailgrad der Anzeige): Zahl der Wand-Schnittflächen und ihre Fläche (m²). */ @@ -157,6 +159,8 @@ export function installTestHooks(): void { }, notices: () => getState().notifications.map((n) => n.message), fakeRender: () => fakeRender(), + ceilingSlopes: () => + Object.fromEntries((getState().project.ceilings ?? []).flatMap((c) => (c.slope ? [[c.id, { rise: c.slope.rise, ramp: !!c.slope.ramp }]] : []))), planLines: (cls) => { const s = getState(); const codes = new Set(); diff --git a/src/ui/ribbon/CommandIcon.tsx b/src/ui/ribbon/CommandIcon.tsx index 2cfc8d0f..e9ca9093 100644 --- a/src/ui/ribbon/CommandIcon.tsx +++ b/src/ui/ribbon/CommandIcon.tsx @@ -269,6 +269,15 @@ export const CommandIcon = memo(function CommandIcon({ name }: { name: string }) ); + case "ramp": + // [281] Rampe: geneigte Platte mit Lauflinie und Pfeil. + return ( + + + + + + ); case "ceilingopening": // Deckenloch: Decken-Rechteck mit ausgespartem Innenrechteck. return ( diff --git a/src/viewport/raycast3d.test.ts b/src/viewport/raycast3d.test.ts index 63534aac..3b88bda4 100644 --- a/src/viewport/raycast3d.test.ts +++ b/src/viewport/raycast3d.test.ts @@ -107,6 +107,15 @@ const SLAB: PickSlab = { }; describe("raySlabPrism", () => { + it("[281] geneigte Platte: Deckel um den Versatz der Neigungsebene höher", () => { + // Steigt 15 % nach +x: bei x = 3 liegt die OK auf 3.0 + 0.45 = 3.45 → senkrecht von y = 10: t = 6.55. + const sloped = { ...SLAB, slope: [0, 0, 0.15, 0] as const }; + expect(raySlabPrism({ origin: [3, 10, 2], dir: [0, -1, 0] }, sloped)!).toBeCloseTo(6.55, 6); + // Waagrechter Strahl auf 3.2: an der Seite x = 0 (2.9..3.0) vorbei, trifft die steigende Oberseite bei + // 3.0 + 0.15·x = 3.2 → x = 4/3 (Strahl von −5 aus: t = 19/3). + expect(raySlabPrism({ origin: [-5, 3.2, 2], dir: [1, 0, 0] }, sloped)!).toBeCloseTo(19 / 3, 6); + }); + it("Strahl von oben trifft den Deckel (kleinstes t)", () => { // eye (2,10,2) senkrecht nach unten: Deckel y=3 bei t=7. const t = raySlabPrism({ origin: [2, 10, 2], dir: [0, -1, 0] }, SLAB); diff --git a/src/viewport/raycast3d.ts b/src/viewport/raycast3d.ts index 6ace4cc2..4f757154 100644 --- a/src/viewport/raycast3d.ts +++ b/src/viewport/raycast3d.ts @@ -301,7 +301,14 @@ function rayPrismXZ( * oder null — s. {@link rayPrismXZ}. */ export function raySlabPrism(ray: Ray, slab: PickSlab): number | null { - return rayPrismXZ(ray, slab.outline, slab.zBottom, slab.zTop); + const g = slab.slope; + if (!g) return rayPrismXZ(ray, slab.outline, slab.zBottom, slab.zTop); + // [281] Geneigte Platte: in den ungescherten Raum abbilden (Höhe − Versatz der Neigungsebene). Die Scherung ist + // affin, der Strahlparameter t bleibt also gleich. + const [ox, oz] = [ray.origin[0], ray.origin[2]]; + const origin: Vec3 = [ox, ray.origin[1] - (g[2] * (ox - g[0]) + g[3] * (oz - g[1])), oz]; + const dir: Vec3 = [ray.dir[0], ray.dir[1] - (g[2] * ray.dir[0] + g[3] * ray.dir[2]), ray.dir[2]]; + return rayPrismXZ({ ...ray, origin, dir }, slab.outline, slab.zBottom, slab.zTop); } /**