[279] Geländer als eigenes Bauteil: Modell, Grundriss, Schnitt, Ansicht, 3D, 3D-Dokument, IFC IfcRailing, DXF-Ebene, Umbau und Varianten, Befehl gelaender, Objekt-Info, Griffe, Beispiel Wettbewerb

This commit is contained in:
Claude committed 2026-11-18 00:13:02 +00:00
1 parent 89c2d0c9a8
commit 6f766ef149
103 files changed
+2289 -73

No files matched your search

+2 -1
View File
@@ -10,7 +10,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `*
stehen im Archiv („Bewusst nicht übernommen“).
- **Grösse** (eine Person mit Agenten): S ≤ 1 Tag · M ≤ 1 Woche · L ≤ 1 Monat · XL > 1 Monat.
Steht keine Grösse im Archiv, ist sie hier geschätzt.
- **IDs sind stabil.** Neue ID = nächste freie Zahl nach der höchsten im Archiv und hier (aktuell 278);
- **IDs sind stabil.** Neue ID = nächste freie Zahl nach der höchsten im Archiv und hier (aktuell 279);
nie eine ID wiederverwenden oder umnummerieren. Präfix-IDs (`[K]`, `[G]`, `[T]`, `[B]`, `[C]`) bleiben.
- **Pro Punkt:** was fehlt · wo im Code · Grösse. Höchstens ein bis drei Sätze je Punkt;
Messwerte und Befunde gehören in den Commit.
@@ -73,6 +73,7 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC.
Geprüft und in Ordnung: Anonymität (Plakat-PDF Titel „FALKE 7“, Producer leer, Datum 2000, Schriften eingebettet, `pdftotext` ohne Projekt-/Büronamen; Kennzahlen-PDF nach „anonym“ ebenso; DXF/IFC ohne Projektnamen), Ansichten/Schnitt stimmig zum Grundriss (Fensterlagen nachgemessen), Kennzahlen-Tabelle Plakat = Flächenbilanz, ÜZ 127.71/900, Kosten 2’844 CHF/m² GF plausibel (mit Befund 1), IFC mit Georeferenz LV95 (IfcMapConversion). **Nicht geprüft:** Tauri-App/Mac (Metal, 3D-Bild, Schatten, Rendering), Mausbedienung (alles über Befehlszeile und Test-Naht), Druck des A1-Plakats, DXF/IFC in Fremdsoftware. · M (Reste)
- ◐ **[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:<id>`), 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.
- ◐ **[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.
- ◐ **[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 `<Klasse>_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äkchenLine truncated
+1
View File
@@ -254,6 +254,7 @@ Beispiel: Die Plan-Ansicht zeigt das Erdgeschoss im Massstab 1:100.
| Wände mit Öffnungen | `plan_walls()` in `plan/walls.rs` | Wandknoten `joins.rs`, Poché `plan/wall_poche.rs`, Symbole `plan/openings.rs` und `opening_geom.rs`, Wand an Stütze `plan/wall_columns.rs` |
| Treppen | `plan_stairs()` in `plan/stairs.rs` | Symbol `plan/stair_symbol.rs`, Geometrie `stair.rs` und `kernel2d` |
| Stützen, Bäume | `columns()`, `plan_trees()` | `plan/trees.rs`, `tree.rs` |
| Geländer [279] | `plan_railings()` | `plan/railings.rs`, `railing.rs` |
| Körper (Extrusionen) | `solids()` in `domains.rs` | Kern-Netz (`solid_mesh.rs`) über `plan/mesh_plan.rs::plan_bodies()`: Ebenenschnitt (Poché, Bauteil-Schraffur aus `componentId`), Aufsicht, Überkopf ([G1]) |
| 2D-Zeichnungen | `plan_drawings()` in `plan/drawings.rs` | Linien, Bögen, Bemassung, Texte, Blöcke |
| Schnittführungen | `plan_section_lines()` in `plan/context.rs` | Symbol aus `plan/misc.rs` |
+2 -2
View File
@@ -30,7 +30,7 @@ Legende Dossier: **ja** vorhanden · **teils** teilweise · **fehlt**.
| Austausch DXF/IFC | DXF/DWG, IFC (sehr ausgereift), BCF, Teamwork-Hotlinks | DXF/DWG, IFC, BCF (nicht geprüft) | **teils**: DXF/DWG, IFC Import/Export, BCF, STEP/OBJ/glTF; IFC/DXF in keinem Fremdprogramm geöffnet ([259], [C9]); Dächer als Netz im IFC |
| Wände/Decken/Dächer | alle, Schichtaufbau, Profile | alle | **ja**: mehrschichtig, Bogen, Gehrung/T-Stoss, Dach beliebiger Umriss; **fehlt**: geneigte Decke/Rampe als Element |
| Treppen | parametrisch, Geländer | parametrisch | **ja**: gerade, L, U, Wendel, Deckenloch automatisch |
| Geländer, Balken, Vorhangfassade | eigene Werkzeuge | eigene Werkzeuge | **fehlt**: kein eigenständiges Geländer, Träger/Unterzug, Vorhangfassade (Modell hat nur Treppen-Geländer/Absturzsicherung am Deckenloch, Stützen) |
| Geländer, Balken, Vorhangfassade | eigene Werkzeuge | eigene Werkzeuge | **teils**: Geländer als eigenes Bauteil (Stäbe, Glas, Brüstung, Lochblech; [279]); **fehlt**: Träger/Unterzug, Vorhangfassade |
| Öffnungen | Fenster/Türen parametrisch | dito | **ja**: Typen, Detailstufen, Formöffnungen, Dachfenster, Gauben |
| Bemassung/Text/Schraffur | ja | ja | **ja**: assoziativ, Aussenbemassung automatisch, Koten, Textfelder, SIA-Schraffuren |
| Ebenen/Klassen, Stifte | Ebenen, Stiftsätze, Überschreibungen | Klassen, Layer | **ja**: Klassen, Stiftsätze, Objektstile mit Regeln ([180], [33]) |
@@ -59,7 +59,7 @@ Grösse: S ≤ 1 Tag · M ≤ 1 Woche · L ≤ 1 Monat. IDs aus `TODO.md`; **neu
| # | Lücke | Wo / ID | Grösse |
|---|---|---|---|
| 6 | **Wohnungsspiegel / Nutzungseinheiten**: Räume lassen sich keiner Wohnung zuordnen; kein Spiegel (Zimmerzahl, NWF je Wohnung) — im Mehrfamilienhaus-WBW üblich. **erledigt 17.11. ([278], Rest: Grundriss-Darstellung der Einheiten)** | `unit_schedule.rs`, `UnitsSection` | M |
| 7 | **Geländer als eigenes Bauteil** (Balkon/Loggia/Absturzsicherung in Plan, Schnitt, Ansicht, 3D); heute nur Wand-/2D-Behelf. **neu** | Modell `Stair.railProfile`/`stairs3d::RailSpec` als Ausgangspunkt, `cmds/` | M |
| 7 | **Geländer als eigenes Bauteil** (Balkon/Loggia/Absturzsicherung in Plan, Schnitt, Ansicht, 3D). **erledigt 17.11. ([279], Rest: Loggia-Brüstung an Wänden, Fangpunkte, Import IfcRailing)** | `railing.rs`, `plan/railings.rs`, `cmds/railing.ts` | M |
| 8 | **Geneigte Decke / Rampe** (Tiefgarage, Terrassen mit Gefälle): `Ceiling` hat nur Ober-/Unterkante, keine Neigung; Behelf Pultdach/Körper. **neu** | `Ceiling`, `ceiling_item` (`cmd_create.rs`), `plan/section` | M |
| 9 | **Träger/Unterzug/Fassadenträger**: kein Element (Behelf Körper/Wand), Deckenspiegel mit Unterzügen fehlt. **neu**, [100] nennt die Lücke | `columns` als Muster | M |
| 10 | **3D-Entourage** (Möbel, Menschen, Autos 3D) für Bilder: Bibliothek nur 2D; Behelf glTF/OBJ-Import | [253] („3D nach 1.0“), `furniture_lib.rs` | L |
Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

+58
View File
@@ -0,0 +1,58 @@
// [279] Geländer als eigenes Bauteil: im Musterhaus mit dem Befehl „gelaender" zwei Punkte setzen (Befehlszeile),
// im Plan anklicken (Pick-Fläche aus dem Kern), in der Objekt-Info Art und Höhe ändern, rückgängig machen, löschen.
import type { Page } from "@playwright/test";
import { blurFocus, commandInput, expect, finishCommand, openSample, openTab, startNewProject, test, typeCommand } from "./app";
async function clickModel(page: Page, x: number, y: number): Promise<void> {
const p = await page.locator("svg.plan-svg").first().evaluate(
(el, [x, y]) => {
const [vx, vy, vw, vh] = el.getAttribute("viewBox")!.split(/\s+/).map(Number);
const ox = Number(el.getAttribute("data-origin-x") ?? 0);
const oy = Number(el.getAttribute("data-origin-y") ?? 0);
const r = el.getBoundingClientRect();
const s = Math.min(r.width / vw, r.height / vh);
return { x: r.left + (r.width - vw * s) / 2 + (x * 90 - ox - vx) * s, y: r.top + (r.height - vh * s) / 2 + (-y * 90 - oy - vy) * s };
},
[x, y],
);
await page.mouse.click(p.x, p.y);
}
test("Geländer zeichnen, wählen, Höhe und Art ändern, Undo, Löschen", async ({ page }) => {
test.setTimeout(90_000);
await startNewProject(page);
await openSample(page);
await openTab(page, "Objekt-Info");
await commandInput(page).focus();
await typeCommand(page, "gelaender");
await expect(page.locator(".cmdline-prompt")).toHaveText("Erster Punkt des Geländers (Zahl = Höhe in m):");
await typeCommand(page, "3,5");
await typeCommand(page, "7,5");
await finishCommand(page);
await blurFocus(page);
const objInfo = page.locator(".objinfo-panel").first();
const field = (name: string) =>
objInfo.locator("label.objinfo-field").filter({ has: page.locator(".objinfo-flabel", { hasText: new RegExp(`^${name}$`) }) }).locator("input");
const height = field("Höhe");
await expect(async () => {
await page.keyboard.press("Escape");
// Auf die Mitte der Achse klicken (Pick-Fläche um die Achse, mindestens 4 mm Papier breit).
await clickModel(page, 5, 5);
await expect(height).toBeVisible({ timeout: 1000 });
}).toPass({ timeout: 30_000 });
await expect(objInfo).toContainText("Geländer");
await expect(height).toHaveValue("1.000");
// Länge aus dem Kern: 4.00 m.
await expect(page.getByTestId("railing-length")).toHaveText("4.00 m");
await height.fill("1.1");
await height.press("Enter");
await expect(height).toHaveValue("1.100");
await blurFocus(page);
await page.keyboard.press("ControlOrMeta+z");
await expect(height).toHaveValue("1.000");
// Löschen mit Entf: die Auswahl (und das Geländer) ist weg.
await page.keyboard.press("Delete");
await expect(height).toBeHidden();
});
+1
View File
@@ -59,6 +59,7 @@ Neues Modul: `<modul>.rs` und `mod` in `lib.rs`, Bindungen in `web/<modul>.rs` u
| `wall_arc.rs` | Bogenwände |
| `ring_arc.rs` | Bögen in Umriss-Ringen (Decke, Dach, Raum): feine Teilung, exakte Fläche, Bögen aus Wandkreisen ([191]) |
| `roof.rs`, `roof_skeleton.rs`, `skeleton.rs`, `roof_assembly.rs`, `roof_parapet.rs`, `dormer.rs` | Dächer (Straight Skeleton), Dach an Dach, Attika (Flachdach-Brüstung), Gauben |
| `railing.rs` | [279] Geländer als eigenes Bauteil: Prismen (Pfosten, Stäbe, Tafel, Handlauf) aus einer Quelle für 3D, Schnitt, Ansicht, 3D-Dokument, IFC; Tests in `railing_tests.rs` |
| `stair.rs`, `stair_rail.rs`, `stair_guard.rs` | Treppen-Geometrie, Handlauf, Absturzsicherung am Deckenloch (Grundriss, 3D, IFC) |
| `opening_geom.rs`, `opening_shape.rs`, `opening_detail.rs`, `opening_presets.rs`, `opening_preview.rs`, `opening_slide.rs` | Öffnungen: Symbol, Formen, Rahmen, Vorlagen, Vorschau, Verschieben in der Wand |
| `room_area.rs`, `room_boundary.rs` | Raumflächen nach SIA 416; Raum-Erkennung aus Wänden |
+43
View File
@@ -999,6 +999,48 @@ fn tree_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
add_op("trees", vec![obj(f)])
}
/// [279] Geländer über die Punkte `pts` (Polylinie, mindestens zwei verschiedene) auf dem aktiven Geschoss: Ebene „41"
/// (Geländer), falls vorhanden, sonst die aktive. Art, Höhe (Vorgabe 1.00 m), Fusshöhe, Handlauf, Stababstand, Stabquerschnitt,
/// Dicke und Bauteil aus den Werkzeug-Vorgaben; fehlende oder unsinnige Werte bleiben weg (Vorgaben aus `railing.rs`).
/// `closed` mit mindestens drei Punkten schliesst den Zug.
fn railing_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
let mut pts: Vec<V> = pts_of(v, "pts").into_iter().filter(|q| q.0.is_finite() && q.1.is_finite()).collect();
pts.dedup_by(|a, b| (a.0 - b.0).abs() < 1e-6 && (a.1 - b.1).abs() < 1e-6);
if pts.len() < 2 {
return Vec::new();
}
let pos = |k: &str| opt_n(v, k).filter(|x| *x > 0.0 && x.is_finite());
let kind = ["bars", "glass", "solid", "perforated"].into_iter().find(|a| *a == s_of(v, "kind")).unwrap_or("bars");
let mut f = vec![
("id", s(&ids.next("railing"))),
("type", s("railing")),
("floorId", s(ctx.level)),
("categoryCode", category_or(p, crate::railing::CATEGORY, ctx)),
("points", pvs(&pts)),
("height", js_num(pos("height").unwrap_or(crate::railing::DEFAULT_HEIGHT))),
("kind", s(kind)),
];
if v.get("closed").and_then(Value::as_bool) == Some(true) && pts.len() >= 3 {
f.push(("closed", Value::Bool(true)));
}
if let Some(b) = opt_n(v, "baseOffset").filter(|x| x.is_finite() && *x != 0.0) {
f.push(("baseOffset", js_num(b)));
}
if let Some(h) = v.get("handrail").and_then(Value::as_bool) {
f.push(("handrail", Value::Bool(h)));
}
for k in ["barSpacing", "barSize", "thickness", "handrailSize"] {
if let Some(x) = pos(k) {
f.push((k, js_num(x)));
}
}
let comp = s_of(v, "componentId");
if kind == "solid" && !comp.is_empty() {
f.push(("componentId", s(comp)));
}
add_op("railings", vec![obj(f)])
}
/// [149] „Kreise in Bäume umwandeln": die gewählten Kreise (`ids`), sonst alle Kreise der Baum-Ebene auf der
/// aktiven Ebene, werden Baum-Objekte (Kronendurchmesser = Kreisdurchmesser, Höhe = `sunStudy.treeHeight`
/// bzw. Vorgabe, Ebene und Geschoss des Kreises); die Kreise entfallen. Ein Undo-Schritt.
@@ -1156,6 +1198,7 @@ pub fn ops(root: &Map<String, Value>, p: &Project, v: &Value) -> Option<Vec<Op>>
"roof" => roof_ops(p, v, &ctx, ids),
"column" => column_ops(v, &ctx, ids),
"tree" => tree_ops(p, v, &ctx, ids),
"railing" => railing_ops(p, v, &ctx, ids),
"circlesToTrees" => circles_to_trees_ops(root, p, v, &ctx, ids),
"extrude" => extrude_ops(root, v, &ctx, ids),
// [222] Volumenstudie → Bauteile.
+2 -1
View File
@@ -20,7 +20,7 @@ use std::collections::HashMap;
/// Listen der Zwischenablage: (Schlüssel in `clip`, Projekt-Liste, id-Präfix, Geschoss-Feld).
/// Reihenfolge = Reihenfolge der ids und der Ops (Wände vor Öffnungen).
const LISTS: [(&str, &str, &str, &str); 11] = [
const LISTS: [(&str, &str, &str, &str); 12] = [
("walls", "walls", "W", "floorId"),
("drawings", "drawings2d", "dr2d", "levelId"),
("ceilings", "ceilings", "C", "floorId"),
@@ -31,6 +31,7 @@ const LISTS: [(&str, &str, &str, &str); 11] = [
("extrudedSolids", "extrudedSolids", "extrude", "levelId"),
("columns", "columns", "column", "floorId"),
("trees", "trees", "tree", "floorId"),
("railings", "railings", "railing", "floorId"),
("cameras", "cameras", "camera", "floorId"),
];
+18 -2
View File
@@ -307,6 +307,11 @@ fn mv_tree(t: &Value, xf: &Xf) -> Value {
with(t, "position", pt(n.0, n.1))
}
/// [279] Geländer: alle Punkte der Achse werden abgebildet (Höhe, Dicke und Teilung bleiben).
fn mv_railing(r: &Value, xf: &Xf) -> Value {
with(r, "points", xf.pts(field(r, "points")))
}
/// [213] Kamera: Standpunkt und Ziel werden abgebildet (Drehen dreht beide um den Drehpunkt, Spiegeln spiegelt
/// beide); Augenhöhe, Zielhöhe, Bildwinkel und Sichthöhe bleiben (Skalieren: Abstand Standpunkt–Ziel skaliert mit).
fn mv_camera(c: &Value, xf: &Xf) -> Value {
@@ -722,6 +727,8 @@ pub struct Sel {
pub opening_ids: Option<Vec<String>>,
/// [149] Gewählte Bäume.
pub tree_ids: Option<Vec<String>>,
/// [279] Gewählte Geländer (alle Punkte der Achse werden transformiert).
pub railing_ids: Option<Vec<String>>,
/// [213] Gewählte Kameras (Standpunkt und Ziel werden transformiert).
pub camera_ids: Option<Vec<String>>,
/// [193] Gewählte Gelände-/Umgebungs-Elemente (`Project.context`).
@@ -781,6 +788,7 @@ enum Kind {
Stair,
Room,
Tree,
Railing,
Camera,
Context,
}
@@ -818,6 +826,7 @@ fn gather<'a>(root: &'a Map<String, Value>, sel: &Sel, op: &str, ignore_lock: bo
each("stairs", Ids::opt(&sel.stair_ids), Kind::Stair);
each("rooms", Ids::opt(&sel.room_ids), Kind::Room);
each("trees", Ids::opt(&sel.tree_ids), Kind::Tree);
each("railings", Ids::opt(&sel.railing_ids), Kind::Railing);
each("cameras", Ids::opt(&sel.camera_ids), Kind::Camera);
each("context", Ids::opt(&sel.context_ids), Kind::Context);
out
@@ -1005,6 +1014,10 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
if !trees.is_empty() {
patch("trees", &|t| trees.has(t) && !locked(t), &|t| mv_tree(t, &xf));
}
let railings = Ids::opt(&sel.railing_ids);
if !railings.is_empty() {
patch("railings", &|t| railings.has(t) && !locked(t), &|t| mv_railing(t, &xf));
}
let cams = Ids::opt(&sel.camera_ids);
if !cams.is_empty() {
patch("cameras", &|c| cams.has(c) && !locked(c), &|c| mv_camera(c, &xf));
@@ -1029,7 +1042,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
// Kopien (Kopie/Reihe/Verteilen bzw. gespiegelte Kopie).
let mut ids = IdGen::new(&req.stamp);
let mut new: [Vec<Value>; 11] = Default::default();
let mut new: [Vec<Value>; 12] = Default::default();
let mut new_openings = Vec::new();
// [213] Namen der vorhandenen Kameras (Kopien heissen „… Kopie“, nummeriert bei Kollision).
let mut cam_names: std::collections::HashSet<String> = list(root, "cameras").iter().filter_map(|c| field(c, "name").and_then(Value::as_str).map(String::from)).collect();
@@ -1047,6 +1060,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
Kind::Stair => "ST",
Kind::Room => "RM",
Kind::Tree => "tree",
Kind::Railing => "railing",
Kind::Camera => "camera",
Kind::Context => "ctx",
})
@@ -1074,6 +1088,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
Kind::Stair => (6, mv_stair(e, &xf, k_at(t))),
Kind::Room => (7, mv_room(e, &xf)),
Kind::Tree => (8, mv_tree(e, &xf)),
Kind::Railing => (11, mv_railing(e, &xf)),
Kind::Camera => (10, mv_camera(e, &xf)),
Kind::Context => (9, mv_context(e, &xf)),
};
@@ -1102,7 +1117,7 @@ pub fn transform_result(root: &Map<String, Value>, p: &Project, req: &TransformR
}
}
}
let keys = ["walls", "drawings2d", "extrudedSolids", "columns", "ceilings", "roofs", "stairs", "rooms", "trees", "context", "cameras"];
let keys = ["walls", "drawings2d", "extrudedSolids", "columns", "ceilings", "roofs", "stairs", "rooms", "trees", "context", "cameras", "railings"];
for (key, items) in keys.iter().zip(new) {
ops.extend(add(key, items));
}
@@ -1418,6 +1433,7 @@ fn item_preview(p: &Project, kind: Kind, e: &Value, xf: &Xf, out: &mut Pending)
let ring: Vec<(f64, f64)> = crate::tree::circle([c.0, c.1], d / 2.0, 24).into_iter().map(|q| (q[0], q[1])).collect();
s.poly(&ring);
}
Kind::Railing => s.poly_open(&mapped(&pts_of(field(e, "points")), xf)),
Kind::Camera => {
// [213] Gehäuse am neuen Standpunkt und die Blicklinie zum neuen Ziel.
let (px, py) = pt("position");
+1 -1
View File
@@ -53,7 +53,7 @@ pub fn ops(root: &Map<String, Value>, p: &Project, text: &str) -> Result<Vec<Op>
}
/// Listen, deren neue Elemente den Zeichen-Status bekommen ([271]).
const RENOVATION_COLLECTIONS: [&str; 8] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms"];
const RENOVATION_COLLECTIONS: [&str; 9] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "railings"];
/// [271] Neue Bauteile der Ops (`add` in [`RENOVATION_COLLECTIONS`]) erhalten `renovation` (ein Objekt mit gültigem
/// `status`), sofern sie keines tragen; sonst unverändert.
+5 -3
View File
@@ -13,7 +13,7 @@ use serde_json::{json, Map, Value};
use std::collections::{BTreeMap, HashSet};
/// Listen, deren Elemente eine Variante tragen können (Wurzel-Schlüssel).
pub const COLLECTIONS: [&str; 9] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "drawings2d"];
pub const COLLECTIONS: [&str; 10] = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "drawings2d", "railings"];
/// Höchstens so viele Kombinationen im Vergleich (Kreuzprodukt der Sätze).
pub const MAX_COMPARE: usize = 24;
@@ -54,6 +54,7 @@ pub fn active(p: &Project) -> bool {
|| p.roofs.iter().flatten().any(|x| known(x.design_option.as_ref()))
|| p.stairs.iter().flatten().any(|x| known(x.design_option.as_ref()))
|| p.columns.iter().flatten().any(|x| known(x.design_option.as_ref()))
|| p.railings.iter().flatten().any(|x| known(x.design_option.as_ref()))
|| p.extruded_solids.iter().flatten().any(|x| known(x.design_option.as_ref()))
|| p.rooms.iter().flatten().any(|x| known(x.design_option.as_ref()))
|| p.drawings2d.iter().any(|x| known(x.design_option.as_ref()))
@@ -180,7 +181,7 @@ impl Combination {
}
)*};
}
each!(ceilings, roofs, stairs, columns, extruded_solids, rooms);
each!(ceilings, roofs, stairs, columns, extruded_solids, rooms, railings);
for d in &p.drawings2d {
if !self.shows(d.design_option.as_ref()) {
out.insert(d.id.clone());
@@ -268,7 +269,7 @@ impl Edit {
}
)*};
}
each!(ceilings, roofs, stairs, columns, extruded_solids, rooms);
each!(ceilings, roofs, stairs, columns, extruded_solids, rooms, railings);
out
}
@@ -743,6 +744,7 @@ pub fn info(p: &Project) -> Value {
p.roofs.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
p.stairs.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
p.columns.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
p.railings.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
p.extruded_solids.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
p.rooms.iter().flatten().for_each(|x| add(x.design_option.as_ref()));
p.drawings2d.iter().for_each(|x| add(x.design_option.as_ref()));
+11
View File
@@ -51,6 +51,9 @@ impl<'a> Explode<'a> {
for t in p.trees.as_deref().unwrap_or(&[]) {
floor_of.insert(&t.id, &t.floor_id);
}
for t in p.railings.as_deref().unwrap_or(&[]) {
floor_of.insert(&t.id, &t.floor_id);
}
// [137] Freie Körper (Pick, Hervorhebung) folgen ihrem Geschoss.
for s in p.extruded_solids.as_deref().unwrap_or(&[]) {
floor_of.insert(&s.id, &s.level_id);
@@ -167,6 +170,7 @@ pub fn parts_filtered(p: &Project, layered: bool, detail: f64, for_section: bool
let pick = |fid: &str| ex.in_group(fid, g);
q.columns = p.columns.as_ref().map(|v| v.iter().filter(|c| pick(&c.floor_id)).cloned().collect());
q.trees = p.trees.as_ref().map(|v| v.iter().filter(|t| pick(&t.floor_id)).cloned().collect());
q.railings = p.railings.as_ref().map(|v| v.iter().filter(|t| pick(&t.floor_id)).cloned().collect());
q.stairs = p.stairs.as_ref().map(|v| v.iter().filter(|s| pick(&s.floor_id)).cloned().collect());
q.roofs = p.roofs.as_ref().map(|v| v.iter().filter(|r| pick(&r.floor_id)).cloned().collect());
q.openings = p.openings.as_ref().map(|v| v.iter().filter(|o| filter.keep_opening(o) && pick(ex.floor_of.get(o.id.as_str()).copied().unwrap_or(""))).cloned().collect());
@@ -177,6 +181,7 @@ pub fn parts_filtered(p: &Project, layered: bool, detail: f64, for_section: bool
};
out.column_meshes.extend(shifted(kept(&q, model3d::emit_columns(&q)), dz, shift_mesh));
out.column_meshes.extend(shifted(kept(&q, model3d::emit_trees(&q)), dz, shift_mesh));
out.column_meshes.extend(shifted(kept(&q, model3d::emit_railings(&q)), dz, shift_mesh));
out.stair_meshes.extend(shifted(kept(&q, model3d::emit_stair_meshes(&q)), dz, shift_mesh));
// Handläufe folgen der Treppe, die Absturzsicherung der Decke mit dem Loch (Geschoss `g`, [155]).
out.stair_railings.extend(shifted(kept(&q, model3d::emit_stair_handrails(&q)), dz, shift_mesh));
@@ -283,6 +288,12 @@ pub fn pick_geometry(p: &Project, gap: f64) -> Result<PickGeometry, String> {
v[1] += dz;
}
}
for t in &mut g.railings {
let dz = ex.of(&t.railing_id);
for v in t.tris.iter_mut().flatten() {
v[1] += dz;
}
}
for o in &mut g.opening_meshes {
let dz = ex.of(&o.opening_id);
for v in o.tris.iter_mut().flatten() {
+3
View File
@@ -118,6 +118,9 @@ pub fn translate_project(p: &Project, dx: f64, dy: f64) -> Project {
for t in out.trees.iter_mut().flatten() {
t.position = shift(t.position, dx, dy);
}
for r in out.railings.iter_mut().flatten() {
shift_all(&mut r.points, dx, dy);
}
for c in out.cameras.iter_mut().flatten() {
c.position = shift(c.position, dx, dy);
c.target = shift(c.target, dx, dy);
+2 -1
View File
@@ -9,7 +9,7 @@
use serde_json::{json, Map, Value};
/// Projekt-Listen, die verschoben werden (jedes Element hat eine `id`), in Op-Reihenfolge.
pub const TRANSLATED_LISTS: [&str; 12] = ["walls", "ceilings", "roofs", "stairs", "rooms", "columns", "extrudedSolids", "drawings2d", "context", "drawingLevels", "trees", "cameras"];
pub const TRANSLATED_LISTS: [&str; 13] = ["walls", "ceilings", "roofs", "stairs", "rooms", "columns", "extrudedSolids", "drawings2d", "context", "drawingLevels", "trees", "cameras", "railings"];
fn shift(p: &Value, dx: f64, dy: f64) -> Value {
let c = |k: &str| p.get(k).and_then(Value::as_f64).unwrap_or(f64::NAN);
@@ -164,6 +164,7 @@ fn shift_element(key: &str, e: &Value, dx: f64, dy: f64) -> (Value, bool) {
}
"columns" => shift_pts_fields(&mut m, &["position"], dx, dy, &[]),
"trees" => shift_pts_fields(&mut m, &["position"], dx, dy, &[]),
"railings" => shift_pts_fields(&mut m, &[], dx, dy, &["points"]),
"cameras" => shift_pts_fields(&mut m, &["position", "target"], dx, dy, &[]),
"extrudedSolids" => {
shift_pts_fields(&mut m, &[], dx, dy, &["points"]);
+6 -1
View File
@@ -23,10 +23,12 @@ pub struct Membership {
pub tree_ids: Vec<String>,
/// [213] Kameras.
pub camera_ids: Vec<String>,
/// [279] Geländer.
pub railing_ids: Vec<String>,
}
/// Elementart (`MemberKind` in TS: `"wallIds"` …).
pub const KINDS: [&str; 10] = ["wallIds", "drawingIds", "ceilingIds", "roomIds", "stairIds", "columnIds", "roofIds", "openingIds", "treeIds", "cameraIds"];
pub const KINDS: [&str; 11] = ["wallIds", "drawingIds", "ceilingIds", "roomIds", "stairIds", "columnIds", "roofIds", "openingIds", "treeIds", "cameraIds", "railingIds"];
impl Membership {
pub fn list(&self, kind: &str) -> Option<&Vec<String>> {
@@ -41,6 +43,7 @@ impl Membership {
"openingIds" => &self.opening_ids,
"treeIds" => &self.tree_ids,
"cameraIds" => &self.camera_ids,
"railingIds" => &self.railing_ids,
_ => return None,
})
}
@@ -57,6 +60,7 @@ impl Membership {
"openingIds" => &mut self.opening_ids,
"treeIds" => &mut self.tree_ids,
"cameraIds" => &mut self.camera_ids,
"railingIds" => &mut self.railing_ids,
_ => return None,
})
}
@@ -73,6 +77,7 @@ impl Membership {
opening_ids: g.opening_ids.clone(),
tree_ids: g.tree_ids.clone().unwrap_or_default(),
camera_ids: g.camera_ids.clone().unwrap_or_default(),
railing_ids: g.railing_ids.clone().unwrap_or_default(),
}
}
+18
View File
@@ -31,6 +31,9 @@ pub struct Args {
pub solids: Vec<String>,
/// [149] Bäume (Umriss-Prisma Kronendurchmesser × Fuss bis Spitze).
pub trees: Vec<String>,
/// [279] Geländer (Umriss-Prisma über der Achse, Fuss bis Oberkante).
#[serde(default)]
pub railings: Vec<String>,
pub rgb: [f64; 3],
/// Explosionsabstand ([65], `explode3d.rs`; fehlt/0 = aus): Linien folgen dem auseinandergezogenen Modell.
#[serde(default)]
@@ -274,6 +277,21 @@ pub fn selection_highlight_lines(p: &Project, a: &Args) -> Result<Vec<f32>, Stri
}
}
}
let railings = set(&a.railings);
if !railings.is_empty() {
for r in p.railings.as_deref().unwrap_or(&[]) {
let (Some(s), Some(ax)) = (crate::railing::spec(p, r), crate::railing::axis(r)) else { continue };
if railings.contains(r.id.as_str()) {
let n = out.v.len();
// Umriss der Achse mit Handlaufbreite, Fuss bis Oberkante.
let (quads, _, _) = crate::railing::strips(&ax, s.rail_w().max(s.thickness) / 2.0);
for q in quads {
out.prism_edges(&q, s.z0, s.top());
}
lift(&mut out, n, &r.id);
}
}
}
for s in p.extruded_solids.as_deref().unwrap_or(&[]) {
if solids.contains(s.id.as_str()) {
let n = out.v.len();
+48 -1
View File
@@ -58,6 +58,7 @@ const REC_SPACE_ARC: f64 = 22.0;
const REC_GUIDS: f64 = 23.0;
const REC_CONTEXT: f64 = 24.0;
const REC_LAYERS: f64 = 25.0;
const REC_RAILING: f64 = 26.0;
/// Toleranz des Kerns (`wall_bands.rs::EPS`) für „Öffnung trifft Band".
const BAND_EPS: f64 = 1e-4;
@@ -978,6 +979,8 @@ enum Kind {
Slab,
Roof,
Column,
/// [279] Geländer.
Railing,
Stair,
Window,
Door,
@@ -989,7 +992,7 @@ enum Kind {
/// eBKP-H-Hauptgruppe zur Bauteilart, oder `None` (Tür, Raum: nicht eindeutig).
fn ebkph_group(k: Kind) -> Option<(&'static str, &'static str)> {
match k {
Kind::Wall | Kind::Slab | Kind::Column | Kind::Stair => Some(("C", "Konstruktion Gebäude")),
Kind::Wall | Kind::Slab | Kind::Column | Kind::Railing | Kind::Stair => Some(("C", "Konstruktion Gebäude")),
Kind::Roof => Some(("F", "Bedachung Gebäude")),
Kind::Window => Some(("E", "Äussere Wandbekleidung Gebäude")),
Kind::Door | Kind::Space | Kind::Context => None,
@@ -1874,6 +1877,50 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
w_mesh(&mut f, &positions, &indices, false);
}
// ── [279] Geländer → IfcRailing (GUARDRAIL; HANDRAIL, wenn nur der Handlauf bleibt), Netz aus den Prismen ──
for r in p.railings.as_deref().unwrap_or(&[]) {
let (Some(s), Some(ax)) = (crate::railing::spec(&p, r), crate::railing::axis(r)) else { continue };
let pieces = crate::railing::pieces(&p, r);
let (mut positions, mut indices) = (Vec::new(), Vec::new());
for q in &pieces {
let (pp, ii) = crate::columns3d::prism(&q.outline, q.z0, q.z1);
let at = (positions.len() / 3) as u32;
positions.extend(pp);
indices.extend(ii.into_iter().map(|k| k + at));
}
if indices.is_empty() {
continue;
}
let structure = structure_of(&r.floor_id);
let base = base_of(structure);
for z in positions.iter_mut().skip(2).step_by(3) {
*z -= base;
}
classified.push((format!("railing/{}", r.id), Kind::Railing, r.category_code.clone()));
let kind = match s.kind {
RailingKind::Glass => "glass",
RailingKind::Solid => "solid",
RailingKind::Perforated => "perforated",
_ => "bars",
};
let label = crate::railing::label(r);
let mut psets = vec![Pset { name: "Pset_RailingCommon", props: vec![ident("Reference", &label)] }];
renovation_props(&p, &mut psets, "Pset_RailingCommon", r.renovation.as_ref());
psets.push(Pset { name: "Dossier_Railing", props: vec![ident("Kind", kind), ident("Handrail", if s.handrail { "yes" } else { "no" })] });
let len = crate::railing::length(&ax);
let q = vec![
Qty { name: "Length", kind: QtyKind::Length, value: len },
Qty { name: "Height", kind: QtyKind::Length, value: s.height },
Qty { name: "NetSideArea", kind: QtyKind::Area, value: len * s.height },
];
psets.extend(qto("Dossier_Qto_Railing", q));
let (id, name) = (f.str(&r.id), f.str(&label));
let predefined = f.str("GUARDRAIL");
f.nums(&[REC_RAILING, structure, id, name, predefined]);
w_psets(&mut f, &psets);
w_mesh(&mut f, &positions, &indices, false);
}
// ── [259] Kontext (Option): Gelände und Nachbarn am IfcSite, Höhen absolut (Modell-z, ±0.00 = 0) ──
if opt.context {
for c in p.context.iter().flatten() {
+1
View File
@@ -22,6 +22,7 @@ pub mod roof_parapet;
pub mod flat_read;
pub mod sun;
pub mod tree;
pub mod railing;
pub mod camera;
pub mod site_rules;
pub mod site_proof;
+9
View File
@@ -488,6 +488,15 @@ pub(crate) fn collect_scene(src: &Project, opt: &MeshOptions) -> Result<SceneDat
groups.push(g);
}
p.trees = trees;
// [279] Geländer: je Geländer eine Gruppe.
let railings = p.railings.take();
for r in railings.as_deref().unwrap_or(&[]) {
let mut g = Group::new(format!("Gelaender_{}", sanitize_name(&r.id)), "railing", &r.id, level_of(Some(&r.floor_id)));
p.railings = Some(vec![r.clone()]);
add_meshes(&mut g, &mut mats, &model3d::emit_railings(&p), "Gelaender");
groups.push(g);
}
p.railings = railings;
let stairs = p.stairs.take();
for st in stairs.as_deref().unwrap_or(&[]) {
let mut g = Group::new(format!("Treppe_{}", sanitize_name(&st.id)), "stair", &st.id, level_of(Some(&st.floor_id)));
+115
View File
@@ -5560,6 +5560,107 @@ pub struct Tree {
pub extra: Extra,
}
/// Art der Füllung eines Geländers ([279]): Stäbe (Rundstahl/Flachstahl, lotrecht), Glas (Ganzglas-Brüstung),
/// massive Brüstung (Mauer/Beton) oder Lochblech.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
pub enum RailingKind {
/// Stäbe mit Pfosten, Handlauf und Fussschiene.
#[default]
#[serde(rename = "bars")]
Bars,
/// Glasscheibe (durchsichtig) mit Handlauf.
#[serde(rename = "glass")]
Glass,
/// Massive Brüstung (Wand-ähnlich, mit Bauteil-Füllung im Schnitt).
#[serde(rename = "solid")]
Solid,
/// Lochblech (Blechtafel).
#[serde(rename = "perforated")]
Perforated,
#[serde(other)]
#[ts(skip)]
Unknown,
}
/// Ein Geländer ([279]) — eigenes Bauteil für Balkon, Galerie, Treppenauge und Terrasse (Absturzsicherung,
/// Vorgabe 1.00 m nach SIA 358): Polylinie `points` auf einem Geschoss, Höhe, Art der Füllung, Handlauf. Grundriss
/// (Linie bzw. Doppellinie je Art), Schnitt/Ansicht (Stäbe, Glasfläche, Brüstung), 3D, IFC (`IfcRailing`).
/// Fusshöhe = Geschoss-UK + `baseOffset` (z. B. auf einer Balkonplatte).
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
#[serde(default)]
pub struct Railing {
pub id: String,
#[ts(type = "\"railing\"")]
pub r#type: String,
/// Zugehörige Zeichnungsebene (Geschoss).
#[serde(rename = "floorId")]
pub floor_id: String,
/// Grafik-Kategorie (Ebene), Vorgabe "55" (Geländer).
#[serde(rename = "categoryCode")]
pub category_code: String,
/// IFC-GlobalId des Quell-Bauteils (IFC-Import/Rundreise).
#[serde(rename = "ifcGlobalId", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub ifc_global_id: Option<String>,
/// Objekt-Sperre, analog `Wall.locked`.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub locked: Option<bool>,
/// Achse des Geländers (Polylinie im Grundriss, Meter, mindestens 2 Punkte).
pub points: Vec<Vec2>,
/// Geschlossener Zug (Treppenauge, Galerie ringsum); fehlt = offen.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub closed: Option<bool>,
/// Höhe über dem Fuss bis Oberkante Handlauf bzw. Füllung (m, Vorgabe 1.00 nach SIA 358).
pub height: f64,
/// Fusshöhe relativ zur Geschoss-UK (m, Vorgabe 0), z. B. 0.18 auf einer Balkonplatte.
#[serde(rename = "baseOffset", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub base_offset: Option<f64>,
/// Art der Füllung.
pub kind: RailingKind,
/// Stäbe: Achsabstand der Stäbe (m, Vorgabe 0.12; lichtes Mass bleibt unter 12 cm).
#[serde(rename = "barSpacing", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub bar_spacing: Option<f64>,
/// Stäbe: Querschnitt (Kantenlänge bzw. Durchmesser, m, Vorgabe 0.014).
#[serde(rename = "barSize", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub bar_size: Option<f64>,
/// Dicke der Füllung (m): Glas (Vorgabe 0.02), Brüstung (Vorgabe 0.15), Lochblech (Vorgabe 0.004); bei Stäben ohne Wirkung.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub thickness: Option<f64>,
/// Handlauf auf der Oberkante; fehlt = bei Stäben und Glas ja, sonst nein.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub handrail: Option<bool>,
/// Handlauf: Durchmesser (m, Vorgabe 0.04).
#[serde(rename = "handrailSize", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub handrail_size: Option<f64>,
/// Optionales Bauteil (Component) für Füllung/Farbe, v. a. der massiven Brüstung.
#[serde(rename = "componentId", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub component_id: Option<String>,
/// Optionale Übersteuerung der Strichfarbe; sonst gilt die Kategorie-Farbe.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub color: Option<String>,
/// [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub renovation: Option<Renovation>,
/// [272] Variante, zu der das Element gehört. Fehlt ⇒ Hauptmodell (immer sichtbar).
#[serde(rename = "designOption", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub design_option: Option<DesignOptionRef>,
#[serde(flatten)]
#[ts(skip)]
pub extra: Extra,
}
/// Projektion einer Kamera ([213]): Perspektive, Axonometrie (Parallelprojektion mit schrägem Blick, z. B.
/// Isometrie) oder Parallelprojektion (frei ausgerichtet). Axonometrie und Parallel zeichnen im 3D orthografisch.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
@@ -5660,6 +5761,10 @@ pub struct Group {
#[serde(rename = "cameraIds", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub camera_ids: Option<Vec<String>>,
/// [279] Geländer (fehlt in älteren Dateien).
#[serde(rename = "railingIds", default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub railing_ids: Option<Vec<String>>,
/// Verschachtelte Gruppen (diese Gruppe enthält andere Gruppen als Ganzes).
#[serde(rename = "groupIds")]
pub group_ids: Vec<String>,
@@ -7002,6 +7107,10 @@ pub struct Project {
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub trees: Option<Vec<Tree>>,
/// Geländer ([279]) — eigenes Bauteil (Balkon, Galerie, Treppenauge), siehe {@link Railing}. Optional.
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional)]
pub railings: Option<Vec<Railing>>,
/// Kameras ([213]) — gespeicherte Standpunkte für 3D-Ansicht und Rendering, siehe {@link Camera}. Optional
/// (Default: leer behandeln).
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -7902,6 +8011,12 @@ impl Project {
None => Default::default(),
};
}
"railings" => {
self.railings = match v {
Some(v) => <Option<Vec<Railing>>>::deserialize(v).map_err(|e| e.to_string())?,
None => Default::default(),
};
}
"cameras" => {
self.cameras = match v {
Some(v) => <Option<Vec<Camera>>>::deserialize(v).map_err(|e| e.to_string())?,
+1
View File
@@ -37,6 +37,7 @@ impl Project {
"extrudedSolids" => put_opt(&mut self.extruded_solids, i, v),
"columns" => put_opt(&mut self.columns, i, v),
"trees" => put_opt(&mut self.trees, i, v),
"railings" => put_opt(&mut self.railings, i, v),
"cameras" => put_opt(&mut self.cameras, i, v),
"groups" => put_opt(&mut self.groups, i, v),
"layouts" => put_opt(&mut self.layouts, i, v),
+9
View File
@@ -32,6 +32,8 @@ pub enum Owner {
Roof(usize),
Column(usize),
Tree(usize),
/// [279] Index in `Project::railings`.
Railing(usize),
Stair(usize),
Context(usize),
/// [115] Index in `Project::extruded_solids`.
@@ -49,6 +51,7 @@ impl Owner {
Owner::Roof(i) => at(&p.roofs, i).map(|e| e.id.as_str()),
Owner::Column(i) => at(&p.columns, i).map(|e| e.id.as_str()),
Owner::Tree(i) => at(&p.trees, i).map(|e| e.id.as_str()),
Owner::Railing(i) => at(&p.railings, i).map(|e| e.id.as_str()),
Owner::Stair(i) => at(&p.stairs, i).map(|e| e.id.as_str()),
Owner::Context(i) => at(&p.context, i).map(|e| e.id()),
Owner::Solid(i) => at(&p.extruded_solids, i).map(|e| e.id.as_str()),
@@ -157,6 +160,9 @@ impl ClassFilter {
for t in p.trees.as_deref().unwrap_or(&[]) {
add(&t.category_code, &t.id, &t.floor_id);
}
for t in p.railings.as_deref().unwrap_or(&[]) {
add(&t.category_code, &t.id, &t.floor_id);
}
for s in p.extruded_solids.as_deref().unwrap_or(&[]) {
add(&s.category_code, &s.id, "");
}
@@ -187,6 +193,7 @@ impl ClassFilter {
.chain(p.stairs.iter().flatten().map(|s| &s.id))
.chain(p.columns.iter().flatten().map(|c| &c.id))
.chain(p.trees.iter().flatten().map(|t| &t.id))
.chain(p.railings.iter().flatten().map(|t| &t.id))
.chain(p.extruded_solids.iter().flatten().map(|s| &s.id))
.chain(p.drawings2d.iter().map(|d| &d.id))
.chain(p.openings.iter().flatten().map(|o| &o.id));
@@ -306,6 +313,7 @@ impl ClassFilter {
g.stair_meshes.retain(|s| k(&s.stair_id));
g.drawing_meshes.retain(|d| k(&d.drawing_id));
g.trees.retain(|t| k(&t.tree_id));
g.railings.retain(|t| k(&t.railing_id));
}
}
@@ -321,6 +329,7 @@ pub fn parts_filtered(p: &Project, layered: bool, detail: f64, for_section: bool
column_meshes: {
let mut m = emit_columns(p);
m.extend(emit_trees(p));
m.extend(emit_railings(p));
m
},
opening_meshes: emit_opening_meshes_with(p, detail, &|o| f.keep_opening(o)),
+4
View File
@@ -24,6 +24,7 @@ use crate::jsnum::round;
mod ceilings;
pub(crate) mod bearing;
mod columns;
mod railings;
mod walls;
mod wall_body;
mod openings;
@@ -39,6 +40,7 @@ mod arc_zone_tests;
pub use ceilings::*;
pub use columns::*;
pub use railings::*;
pub use walls::*;
pub use openings::*;
pub use stairs::*;
@@ -100,6 +102,8 @@ pub enum SlabSource {
Stair { index: usize },
/// [141] Index in `Project::columns` (Stützen-Prisma, je Höhenabschnitt von [`column_pieces`]).
Column { index: usize },
/// [279] Index in `Project::railings` (Prisma je Teil, `railing::pieces`).
Railing { index: usize, fill: bool },
}
/// Ein rohes Dreiecks-Mesh (`RMesh`).
+11
View File
@@ -48,6 +48,14 @@ pub struct PickColumn {
pub column_id: String,
}
/// [279] Geländer für den 3D-Pick.
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PickRailing {
pub tris: Vec<Tri>,
pub railing_id: String,
}
/// [149] Baum für den 3D-Pick.
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
@@ -115,6 +123,8 @@ pub struct PickGeometry {
pub drawing_meshes: Vec<PickDrawingMesh>,
/// [149] Bäume (Stamm + Krone).
pub trees: Vec<PickTree>,
/// [279] Geländer.
pub railings: Vec<PickRailing>,
}
/// Öffnungen als Quader (Laibung zu Laibung, Wanddicke, Brüstung bis Sturz) für Pick und Hervorhebung.
@@ -275,6 +285,7 @@ pub fn pick_geometry(p: &Project) -> Result<PickGeometry, String> {
stair_meshes: pick_stair_railings(p),
drawing_meshes: pick_drawing_meshes(p, &HashMap::new()),
trees: pick_trees(p),
railings: pick_railings(p),
})
}
+66
View File
@@ -0,0 +1,66 @@
//! [279] Geländer im 3D: Netze (`emit_railings`, im 3D bei den Stützen eingereiht), Platten für Schnitt, Ansicht und
//! 3D-Dokument (`railing_slabs`, Herkunft `SlabSource::Railing`) und die Pick-Geometrie. Die Körper liefert
//! `crate::railing::pieces` (lotrechte Prismen), eine Quelle für alle Ableitungen.
use super::*;
use crate::railing::{self, Part, Piece};
/// Prismen der Teile `pieces` als ein Netz (Modell x, y, z).
fn merge<'a>(pieces: impl Iterator<Item = &'a Piece>) -> Option<(Vec<f64>, Vec<u32>)> {
let (mut positions, mut indices) = (Vec::new(), Vec::new());
for q in pieces {
if q.outline.len() < 3 || !(q.z1 - q.z0 > 1e-6) || !q.outline.iter().all(|v| v[0].is_finite() && v[1].is_finite()) {
continue;
}
let (pp, ii) = crate::columns3d::prism(&q.outline, q.z0, q.z1);
let base = (positions.len() / 3) as u32;
positions.extend(pp);
indices.extend(ii.into_iter().map(|i| i + base));
}
(!indices.is_empty()).then_some((positions, indices))
}
/// Geländer als Netze: je Geländer die Tafel (Glas, Lochblech, Brüstung) und das Gestänge (Pfosten, Stäbe, Schienen,
/// Handlauf) als eigene Netze mit eigener Farbe.
pub fn emit_railings(p: &Project) -> Vec<RMesh> {
let mut out = Vec::new();
for (ri, r) in p.railings.as_deref().unwrap_or(&[]).iter().enumerate() {
let pcs = railing::pieces(p, r);
for fill in [true, false] {
let Some((positions, indices)) = merge(pcs.iter().filter(|q| (q.part == Part::Fill) == fill)) else { continue };
let color = railing::color(p, r, if fill { Part::Fill } else { Part::Rail });
out.push(RMesh { crease_angle: None, positions, indices, kind: "extrusion", color, vertex_colors: None, material_index: None, owner: Owner::Railing(ri) });
}
}
out
}
/// Geländer als lotrechte Prismen-Platten (Schnitt, Ansicht, 3D-Dokument), Herkunft `SlabSource::Railing`.
pub fn railing_slabs(p: &Project) -> Vec<RSlab> {
let mut out = Vec::new();
for (index, r) in p.railings.as_deref().unwrap_or(&[]).iter().enumerate() {
for q in railing::pieces(p, r) {
if q.z1 - q.z0 > 1e-6 && q.outline.len() >= 3 {
let color = railing::color(p, r, q.part);
let fill = q.part == Part::Fill;
out.push(RSlab { outline: q.outline, z_bottom: q.z0, z_top: q.z1, color, ceiling_id: r.id.clone(), hatch: None, cut: None, monolith: None, source: SlabSource::Railing { index, fill } });
}
}
}
out
}
/// Geländer als Welt-Dreiecke für den 3D-Pick (wie [`emit_railings`]).
pub fn pick_railings(p: &Project) -> Vec<PickRailing> {
let mut out = Vec::new();
for r in p.railings.as_deref().unwrap_or(&[]) {
let pcs = railing::pieces(p, r);
if let Some((pos, idx)) = merge(pcs.iter()) {
let tris = extrusion_tris(&pos, &idx);
if !tris.is_empty() {
out.push(PickRailing { tris, railing_id: r.id.clone() });
}
}
}
out
}
+1 -1
View File
@@ -417,7 +417,7 @@ impl Model3dCache {
slabs,
context_meshes: model3d::emit_context_meshes(p),
solid_meshes: model3d::emit_solids(p),
column_meshes: { let mut m = model3d::emit_columns(p); m.extend(model3d::emit_trees(p)); m },
column_meshes: { let mut m = model3d::emit_columns(p); m.extend(model3d::emit_trees(p)); m.extend(model3d::emit_railings(p)); m },
opening_meshes: Vec::new(),
stair_meshes: model3d::emit_stair_meshes(p),
stair_railings: model3d::emit_stair_railings(p),
+1
View File
@@ -26,6 +26,7 @@ Herkunft, kein Wegweiser.
| `ceiling_plan.rs` | Deckenspiegel als eigene Ebenen-Art |
| `floor_finish.rs` | Bodenbelag-Muster nach Massstab |
| `model_view.rs` | Modelldarstellung ([173]): Optionen je Bauteilart über dem Detailgrad, Rangfolge Element > Typ > Stufe > Basis |
| `railings.rs` | [279] Geländer im Grundriss (Linie/Doppellinie/Fläche je Art, über Schnitt gestrichelt, Pick `@railing:<id>`); Schnitt/Ansicht/Axo über die Platten `model3d::railing_slabs` |
| `trees.rs` | Bäume in Grundriss, Schnitt und Ansicht; im Schnitt von näheren Bauteilen verdeckt (`occlude_in_section`, Verdecker `section::Output::occluders`), in der Ansicht Krone ohne Füllung vor der Fassade |
| `cameras.rs` | [213] Kameras im Grundriss: Gehäuse, Sichtkegel, Ziel, Name, Pick-Bänder (Klasse „Kameras“) |
| `stamp_place.rs` | Hindernisse für die Lage der Raumstempel |
+1
View File
@@ -676,6 +676,7 @@ pub fn axo_primitives(p: &Project, a: &AxoArgs, mono: bool) -> Result<Option<(Ve
Kind::Mesh => *context_object_id = id,
Kind::Slab if r.stair => *stair_id = id,
Kind::Slab if r.column => *column_id = id,
Kind::Slab if r.railing => *context_object_id = id.map(|i| crate::plan::railings::pick_id(&i)),
Kind::Slab => *ceiling_id = id,
}
}
+1
View File
@@ -31,6 +31,7 @@ pub const NOT_FOR_DRAWINGS: &[&str] = &[
"units",
"columns",
"trees",
"railings",
"cameras",
"extrudedSolids",
// [157] `context` lesen die Zeichnungen: die Aussenbemassung rückt hinter die sichtbare Baugrube.
+2
View File
@@ -2012,6 +2012,8 @@ fn domains_before(c: &Ctx, out: &mut DomainPrims, bounds: &mut Bounds) -> Result
super::wall_columns::hide_column_views(&mut out.columns, &filled(&out.walls, false));
// [149] Bäume (Planzeichen) mit den Stützen in einer Gruppe.
super::trees::plan_trees(c, &mut out.columns);
// [279] Geländer mit den Stützen in einer Gruppe.
super::railings::plan_railings(c, &mut out.columns);
solids(c, &mut out.solids);
// [271] Umbaufilter: Decken, Dächer, Treppen, Stützen und Körper in ihrer Umbau-Farbe (Wände: `plan_walls`).
if c.renovation().is_some() {
+35 -1
View File
@@ -787,6 +787,8 @@ struct Ids {
opening: Option<String>,
/// [271] Baum (Kronenumriss, Stamm): Id aus der Pick-Fläche `@tree:<id>`, den übrigen Teilen nachgetragen.
tree: Option<String>,
/// [279] Geländer (Pick-Fläche `@railing:<id>`, die übrigen Teile nachgetragen).
railing: Option<String>,
}
struct Entry {
@@ -820,7 +822,10 @@ fn read_entry(part: &mut Part, i: usize, hatches: &[(i32, Hatch, i32)], text: Op
6 => ids.room = Some(s),
7 => ids.solid = Some(s),
9 => ids.column = Some(s),
8 => ids.tree = s.strip_prefix(crate::tree::TREE_PICK_PREFIX).map(str::to_string),
8 => {
ids.tree = s.strip_prefix(crate::tree::TREE_PICK_PREFIX).map(str::to_string);
ids.railing = s.strip_prefix(crate::railing::PICK_PREFIX).map(str::to_string);
}
_ => {}
}
}
@@ -1508,6 +1513,10 @@ fn renovation_layers(cx: &mut Ctx, cats: &[&LayerCategory]) -> HashMap<String, S
for c in p.columns.iter().flatten() {
items.push((&c.id, &c.category_code, crate::renovation::status_of(c.renovation.as_ref())));
}
// [279] Geländer.
for c in p.railings.iter().flatten() {
items.push((&c.id, &c.category_code, crate::renovation::status_of(c.renovation.as_ref())));
}
for o in p.openings.iter().flatten() {
items.push((&o.id, &o.category_code, crate::renovation::status_of(crate::renovation::opening_renovation(p, o))));
}
@@ -1532,6 +1541,7 @@ fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code:
let code_by_wall: HashMap<&str, &str> = project.walls.iter().map(|w| (w.id.as_str(), w.category_code.as_str())).collect();
let code_by_drawing: HashMap<&str, &str> = project.drawings2d.iter().map(|d| (d.id.as_str(), d.category_code.as_str())).collect();
let code_by_column: HashMap<&str, &str> = project.columns.iter().flatten().map(|c| (c.id.as_str(), c.category_code.as_str())).collect();
let code_by_railing: HashMap<&str, &str> = project.railings.iter().flatten().map(|c| (c.id.as_str(), c.category_code.as_str())).collect();
let code_by_room: HashMap<&str, &str> = project.rooms.iter().flatten().map(|r| (r.id.as_str(), r.category_code.as_str())).collect();
let layer_of_code = |m: &HashMap<&str, &str>, id: &str| -> Option<String> { layer_by_code.get(m.get(id).copied().unwrap_or("")).cloned() };
let drawing_layer = |id: Option<&String>, fallback: &str| -> String {
@@ -1546,6 +1556,10 @@ fn emit_entries(cx: &mut Ctx, main: &mut Buf, entries: &[Entry], layer_by_code:
if let Some(l) = e.ids.tree.as_ref().and_then(|id| ren_layer.get(id)) {
return l.clone();
}
// [279] Teile eines Geländers: Status-Ebene bzw. Ebene der Klasse des Geländers.
if let Some(r) = &e.ids.railing {
return ren_layer.get(r).cloned().or_else(|| layer_of_code(&code_by_railing, r)).unwrap_or_else(|| LAYER_DEFAULT.to_string());
}
match e.tag {
T_POLYGON => {
if let Some(l) = e.ids.wall.as_ref().or(e.ids.column.as_ref()).and_then(|id| ren_layer.get(id)) {
@@ -1755,6 +1769,25 @@ fn tag_tree_parts(entries: &mut [Entry]) {
}
}
/// [279] Geländer-Symbol (`plan/railings.rs`): Pick-Flächen `@railing:<id>` (je Teilstrecke eine), dann gefüllte Flächen
/// (Brüstung, Pfosten) ohne Id und Linien (`railing-*`) — sie bekommen die Id des Geländers.
fn tag_railing_parts(entries: &mut [Entry]) {
let mut cur: Option<String> = None;
for e in entries.iter_mut() {
if e.ids.railing.is_some() {
cur = e.ids.railing.clone();
continue;
}
let part = matches!(&e.prim, Prim::Line { cls, .. } if cls.starts_with("railing-"));
let bare = e.ids.wall.is_none() && e.ids.drawing.is_none() && e.ids.column.is_none() && e.ids.solid.is_none() && e.ids.room.is_none() && e.ids.opening.is_none() && e.ids.tree.is_none();
if cur.is_some() && (part || bare && e.tag == T_POLYGON) {
e.ids.railing = cur.clone();
} else {
cur = None;
}
}
}
/// Primitive der Abschnitte in Plan-Reihenfolge lesen (Texte gesetzt beim Massstab `scale`).
fn read_entries(parts: &mut [Part], scale: f64, font: &str) -> Option<Vec<Entry>> {
let mut entries: Vec<Entry> = Vec::new();
@@ -1766,6 +1799,7 @@ fn read_entries(parts: &mut [Part], scale: f64, font: &str) -> Option<Vec<Entry>
}
}
tag_tree_parts(&mut entries);
tag_railing_parts(&mut entries);
Some(entries)
}
+11 -1
View File
@@ -70,7 +70,7 @@ pub(super) fn project_faces(frame: &[f64; 9], walls: &[RWall], slabs: &[RSlab],
};
let (id, fill) = match role {
Role::Wall => (walls[f.src].wall_id.clone(), walls[f.src].color),
Role::Slab | Role::Column | Role::Mesh | Role::Body => (slabs[f.src].ceiling_id.clone(), slabs[f.src].color),
Role::Slab | Role::Column | Role::Railing | Role::Mesh | Role::Body => (slabs[f.src].ceiling_id.clone(), slabs[f.src].color),
Role::Roof => (roofs[f.src].id.clone(), roofs[f.src].fill),
};
let pts = f.pts.iter().map(|q| [q.0, q.1]).collect();
@@ -118,6 +118,16 @@ pub(super) fn collect_column_faces(p: &Project, frame: &[f64; 9]) -> Vec<Face> {
faces
}
/// [279] Geländer als lotrechte Prismen (Pfosten, Stäbe, Tafel, Handlauf wie im 3D, `model3d::railing_slabs`).
pub(super) fn collect_railing_faces(p: &Project, frame: &[f64; 9]) -> Vec<Face> {
let slabs = model3d::railing_slabs(p);
let mut faces = project_faces(frame, &[], &slabs, &[]);
for f in &mut faces {
f.role = Role::Railing;
}
faces
}
/// [152] Importierte Netze als Dreiecksflächen vor der Ansichtsebene (Hüllbox vorgefiltert): geschlossene
/// Netze nur die zugewandten Dreiecke, offene beidseitig (Normale zum Betrachter). Farbe aus dem Import,
/// sonst Kontext-Grau wie im 3D.
@@ -10,6 +10,8 @@ pub(super) enum Role {
Roof,
/// Stütze ([132]): Prisma aus dem Querschnitt, Flächen wie eine Platte.
Column,
/// [279] Geländer: Prismen (Pfosten, Stäbe, Tafeln, Handlauf), id = Geländer-id.
Railing,
/// [152] Importiertes Netz (`ImportedMesh`): Dreiecke, id = Netz-id.
Mesh,
/// [115] Freier Körper (`ExtrudedSolid`, Netz aus `solid_mesh.rs`): wie ein Netz, id = Körper-id.
@@ -156,6 +158,7 @@ pub(super) fn face_overrides(p: &Project, faces: &mut [Face], v: RuleView) {
surf_ov(p, v, "roof", &r.category_code, None, &layers, Some(0))
}),
Role::Column => p.columns.as_deref().unwrap_or(&[]).iter().find(|c| c.id == id).and_then(|c| surf_ov(p, v, "column", &c.category_code, Some(&super::super::domains::column_label(c)), &[], None)),
Role::Railing => p.railings.as_deref().unwrap_or(&[]).iter().find(|r| r.id == id).and_then(|r| surf_ov(p, v, "railing", &r.category_code, Some(&crate::railing::label(r)), &[], None)),
Role::Mesh => p.context.as_deref().unwrap_or(&[]).iter().find_map(|c| match c {
ContextObject::ImportedMesh(m) if m.id == id => Some(m),
_ => None,
@@ -124,7 +124,7 @@ pub(super) fn curved_slab_facets(faces: &[Face]) -> Vec<bool> {
pub(super) fn paint_rank(r: Role) -> f64 {
match r {
Role::Slab => 0.0,
Role::Wall | Role::Column | Role::Mesh | Role::Body => 1.0,
Role::Wall | Role::Column | Role::Railing | Role::Mesh | Role::Body => 1.0,
Role::Roof => 2.0,
}
}
+4
View File
@@ -237,6 +237,7 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m
cull_under_roofs(p, &frame, &walls, &mut faces, &|c| vis.visible(c) && vis.render(c));
faces.extend(collect_roof_faces(p, &frame, &walls)?);
faces.extend(collect_column_faces(p, &frame));
faces.extend(collect_railing_faces(p, &frame));
faces.extend(collect_mesh_faces(p, &frame));
faces.extend(collect_body_faces(p, &frame));
faces.extend(collect_shoring_faces(p, &frame));
@@ -261,6 +262,7 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m
for r in p.roofs.as_deref().unwrap_or(&[]) {
roof_cat.entry(r.id.as_str()).or_insert(r.category_code.as_str());
}
let rail_cat: HashMap<&str, &str> = p.railings.as_deref().unwrap_or(&[]).iter().map(|r| (r.id.as_str(), r.category_code.as_str())).collect();
let mut col_cat: HashMap<&str, &str> = HashMap::new();
for c in p.columns.as_deref().unwrap_or(&[]) {
col_cat.entry(c.id.as_str()).or_insert(c.category_code.as_str());
@@ -292,6 +294,7 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m
Role::Slab => ceil_cat.get(f.id.as_str()).copied(),
Role::Roof => roof_cat.get(f.id.as_str()).copied(),
Role::Column => col_cat.get(f.id.as_str()).copied(),
Role::Railing => rail_cat.get(f.id.as_str()).copied(),
Role::Mesh => mesh_cat.get(f.id.as_str()).copied(),
Role::Body => body_cat.get(f.id.as_str()).copied(),
}
@@ -505,6 +508,7 @@ pub fn elevation_primitives_ren(p: &Project, level: &LevelSpec, shadows: bool, m
Role::Slab => *ceiling_id = Some(f.id.clone()),
Role::Roof => *roof_id = Some(f.id.clone()),
Role::Column => *column_id = Some(f.id.clone()),
Role::Railing => *context_object_id = Some(super::railings::pick_id(&f.id)),
Role::Mesh => *context_object_id = Some(f.id.clone()),
Role::Body => *extruded_solid_id = Some(f.id.clone()),
}
+1
View File
@@ -40,6 +40,7 @@ pub mod stamp_place;
pub mod floor_finish;
pub mod model_view;
pub mod trees;
pub mod railings;
pub mod cameras;
pub mod mesh_plan;
pub mod situation;
+247
View File
@@ -0,0 +1,247 @@
//! [279] Geländer im Grundriss (`Project.railings`). Geometrie aus `crate::railing`, die Zonen zur Schnitthöhe wie bei
//! den Stützen (`view_range`): geschnitten oder darunter ausgezogen, darüber gestrichelt (Strich-Punkt, SIA 400),
//! darunter sichtbar gepunktet.
//!
//! Zeichen je Art (Strichstärke der Klasse, Farbe der Klasse bzw. des Geländers):
//! - **Stäbe:** eine Linie in der Achse (Handlauf über den Stäben) und kleine gefüllte Pfosten (bis 1:200).
//! - **Glas:** Doppellinie im Abstand der Glasdicke (mindestens 0.7 mm Papier, damit die Linien nicht ineinanderlaufen),
//! an offenen Enden geschlossen.
//! - **Lochblech:** wie Glas, dazu eine gestrichelte Mittellinie.
//! - **Brüstung (massiv):** geschnittene Fläche mit Bauteil-Schraffur (Poché wie die Stützen), Umriss ohne Gehrungsfugen.
//!
//! Pick: unsichtbare Fläche um die Achse (mindestens 4 mm Papier breit) mit `contextObjectId = "@railing:<id>"`.
use super::domains::Ctx;
use super::prim::Primitive;
use super::style::*;
use super::view_range::{ViewRange, Zone};
use crate::model::*;
use crate::railing::{self, PICK_PREFIX};
fn v(q: [f64; 2]) -> Vec2 {
Vec2 { x: q[0], y: q[1] }
}
/// Pick-Id eines Geländers (Feld `contextObjectId`).
pub fn pick_id(id: &str) -> String {
format!("{PICK_PREFIX}{id}")
}
/// Ist `q` ein Planzeichen eines Geländers (Linien, Pick-Fläche)?
pub fn is_symbol_part(q: &Primitive) -> bool {
match q {
Primitive::Line { cls, .. } => cls.starts_with("railing-"),
Primitive::Polygon { context_object_id: Some(id), .. } => id.starts_with(PICK_PREFIX),
_ => false,
}
}
/// Linie mit Strichstärke und Farbe.
fn seg(a: [f64; 2], b: [f64; 2], cls: &str, w: f64, color: &str, dash: Option<&[f64]>, greyed: Option<bool>) -> Primitive {
super::trees::line(v(a), v(b), cls, w, color, dash, greyed)
}
/// Streckenzug als Linien.
fn polyline(out: &mut Vec<Primitive>, pts: &[[f64; 2]], cls: &str, w: f64, color: &str, dash: Option<&[f64]>, greyed: Option<bool>) {
for s in pts.windows(2) {
out.push(seg(s[0], s[1], cls, w, color, dash, greyed));
}
}
/// Planzeichen aller Geländer dieses Geschosses (sichtbare Klasse, im Ansichtsbereich).
pub(super) fn plan_railings(c: &Ctx, out: &mut Vec<Primitive>) {
let p = c.p;
let Some(list) = p.railings.as_deref() else { return };
if list.iter().all(|r| r.floor_id != c.a.floor) {
return;
}
let range = ViewRange::of(p, &c.a.floor);
for r in list.iter().filter(|r| r.floor_id == c.a.floor && c.vis(&r.category_code, &r.id)) {
let (Some(s), Some(ax)) = (railing::spec(p, r), railing::axis(r)) else { continue };
let zone = range.classify(s.z0, s.top());
if zone == Zone::Hidden {
continue;
}
let from = out.len();
let greyed = Some(c.greyed(&r.category_code));
let category = c.cat(&r.category_code);
let ov = c.overrides(Some("railing"), &r.category_code, Some(&railing::label(r)));
let lw = ov.lineweight.unwrap_or_else(|| category.map_or(WALL_FALLBACK_MM, |k| k.lw));
let color = ov.color.as_deref().or(r.color.as_deref());
let stroke = color.or(category.map(|k| k.color.as_str())).unwrap_or(MONO_INK).to_string();
let mm = (c.a.scale / 1000.0).max(1e-6);
let closed = crate::stair_rail::is_closed(&ax);
// Pick: unsichtbare Fläche, mindestens 4 mm Papier breit.
let pick_half = (s.thickness.max(s.rail_w()) / 2.0).max(2.0 * mm);
for q in railing::strips(&ax, pick_half).0 {
out.push(super::trees::poly(q.iter().map(|&q| v(q)).collect(), "none", "none", 0.0, Some(pick_id(&r.id)), greyed));
}
match s.kind {
RailingKind::Solid => {
let (quads, l, rt) = railing::strips(&ax, s.thickness / 2.0);
let (mut fill, mut hatch) = (color.or(category.map(|k| k.color.as_str())).unwrap_or(HATCH_PAPER).to_string(), no_hatch());
if zone != Zone::Cut {
fill = "none".into();
} else if let Some(k) = r.component_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| p.component(id)) {
if let Some(h) = resolve_hatch(p, resolve_hatch_id(None, None, category, Some(&k.hatch_id)).unwrap_or(&k.hatch_id), None, resolve_foreground(k, None, category, None), None) {
fill = resolve_background(k, None, category, None).unwrap_or(if h.pattern == HatchPattern::Solid { HATCH_INK } else { HATCH_PAPER }).to_string();
hatch = h;
}
} else {
fill = HATCH_PAPER.to_string();
}
if zone == Zone::Cut && c.solid_cut() && category.is_some() {
fill = HATCH_INK.to_string();
hatch = no_hatch();
}
for q in quads {
let mut f = super::trees::poly(q.iter().map(|&q| v(q)).collect(), &fill, "none", 0.0, None, greyed);
if let Primitive::Polygon { hatch: h, .. } = &mut f {
**h = hatch.clone();
}
out.push(f);
}
polyline(out, &l, "railing-solid", lw, &stroke, None, greyed);
polyline(out, &rt, "railing-solid", lw, &stroke, None, greyed);
if !closed {
out.push(seg(l[0], rt[0], "railing-solid", lw, &stroke, None, greyed));
out.push(seg(l[l.len() - 1], rt[rt.len() - 1], "railing-solid", lw, &stroke, None, greyed));
}
}
RailingKind::Glass | RailingKind::Perforated => {
// Mindestabstand der Doppellinie: 0.7 mm Papier.
let half = (s.thickness / 2.0).max(0.35 * mm);
let (_, l, rt) = railing::strips(&ax, half);
polyline(out, &l, "railing-glass", lw, &stroke, None, greyed);
polyline(out, &rt, "railing-glass", lw, &stroke, None, greyed);
if !closed {
out.push(seg(l[0], rt[0], "railing-glass", lw, &stroke, None, greyed));
out.push(seg(l[l.len() - 1], rt[rt.len() - 1], "railing-glass", lw, &stroke, None, greyed));
}
if s.kind == RailingKind::Perforated {
polyline(out, &ax, "railing-perforated", lw * 0.6, &stroke, Some(&super::line_pattern::HIDDEN), greyed);
}
}
_ => {
polyline(out, &ax, "railing-bars", lw, &stroke, None, greyed);
// Pfosten als kleine gefüllte Quadrate; bei kleinen Massstäben nicht mehr lesbar.
if c.a.scale <= 200.0 {
for (pt, d) in railing::stations(&ax, &s).0 {
let (n, h) = ([-d[1], d[0]], 0.015);
let q = |a: f64, b: f64| v([pt[0] + d[0] * a + n[0] * b, pt[1] + d[1] * a + n[1] * b]);
out.push(super::trees::poly(vec![q(-h, -h), q(h, -h), q(h, h), q(-h, h)], &stroke, &stroke, 0.0, None, greyed));
}
}
}
}
// Ganz über der Schnitthöhe: Strich-Punkt wie die übrigen Bauteile darüber (auch ohne eigenen Ansichtsbereich, wie die
// Stufen und Handläufe der Treppen); unter der Schnitthöhe gepunktet nur mit eigenem Bereich.
let dash = if zone == Zone::Above { Some(&super::view_range::ABOVE_DASH[..]) } else { range.restyle_dash(zone) };
if let Some(d) = dash {
super::view_range::restyle(out, from, d);
}
// [271] Umbaufilter: das Geländer in der Farbe seines Status (Bestand grau, Abbruch gelb gestrichelt, Neu rot).
if let Some(st) = c.renovation().and_then(|rn| rn.styled.get(&r.id)) {
crate::renovation::restyle_linework(out, from, st, true);
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::plan::domains::{plan_domains, PlanArgs};
fn project(rail: serde_json::Value) -> Project {
serde_json::from_value(serde_json::json!({
"id": "p", "name": "t", "lineStyles": [], "hatches": [], "components": [{"id": "beton", "name": "Beton", "color": "#b0b0b0", "hatchId": "h", "joinPriority": 5}], "wallTypes": [],
"layers": [{"code": "41", "name": "Geländer", "color": "#102030", "lw": 0.25, "visible": true, "locked": false}],
"drawingLevels": [{"id": "eg", "name": "EG", "kind": "floor", "visible": true, "locked": false, "baseElevation": 0.0, "floorHeight": 2.6, "cutHeight": 1.0}],
"walls": [], "openings": [], "drawings2d": [], "railings": [rail]
}))
.unwrap()
}
fn plan(p: &Project, scale: f64) -> Vec<Primitive> {
plan_codes(p, scale, &["41"])
}
fn plan_codes(p: &Project, scale: f64, codes: &[&str]) -> Vec<Primitive> {
let text = serde_json::json!({"floor": "eg", "show": codes, "scale": scale, "global": true}).to_string();
let a = PlanArgs::parse(scale, &text).unwrap();
plan_domains(p, &a).unwrap().columns
}
fn rail(kind: &str, extra: serde_json::Value) -> serde_json::Value {
let mut r = serde_json::json!({"id": "g1", "type": "railing", "floorId": "eg", "categoryCode": "41", "points": [{"x": 0, "y": 0}, {"x": 4, "y": 0}], "height": 1.0, "kind": kind});
if let (Some(o), Some(e)) = (r.as_object_mut(), extra.as_object()) {
o.extend(e.clone());
}
r
}
fn lines(prims: &[Primitive], cls: &str) -> Vec<(Vec2, Vec2)> {
prims.iter().filter_map(|q| match q {
Primitive::Line { a, b, cls: c, .. } if c == cls => Some((*a, *b)),
_ => None,
}).collect()
}
#[test]
fn staebe_eine_linie_und_pfosten() {
let p = project(rail("bars", serde_json::json!({})));
let prims = plan(&p, 50.0);
let l = lines(&prims, "railing-bars");
assert_eq!(l.len(), 1);
assert!((l[0].0.x - 0.0).abs() < 1e-9 && (l[0].1.x - 4.0).abs() < 1e-9 && l[0].0.y == 0.0);
// Pick-Fläche mit der Id.
assert!(prims.iter().any(|q| matches!(q, Primitive::Polygon { context_object_id: Some(id), .. } if id == "@railing:g1")));
// Pfosten: 5 (4 Felder à 1 m), gefüllt.
let posts = prims.iter().filter(|q| matches!(q, Primitive::Polygon { fill, stroke_width_mm, context_object_id: None, .. } if fill != "none" && *stroke_width_mm == 0.0)).count();
assert_eq!(posts, 5);
// Ab 1:500 keine Pfosten mehr.
let big = plan(&p, 500.0);
assert_eq!(big.iter().filter(|q| matches!(q, Primitive::Polygon { fill, context_object_id: None, .. } if fill != "none")).count(), 0);
}
#[test]
fn glas_doppellinie_mit_mindestabstand() {
let p = project(rail("glass", serde_json::json!({"thickness": 0.02})));
let prims = plan(&p, 100.0);
let l = lines(&prims, "railing-glass");
// Zwei Längslinien und zwei Stirnlinien.
assert_eq!(l.len(), 4);
let long: Vec<_> = l.iter().filter(|(a, b)| (a.x - b.x).abs() > 1.0).collect();
assert_eq!(long.len(), 2);
// Abstand = 2 × max(0.01, 0.35 mm × 100/1000 = 0.035) = 0.07.
assert!(((long[0].0.y - long[1].0.y).abs() - 0.07).abs() < 1e-9, "{long:?}");
}
#[test]
fn brustung_flaeche_und_ueber_schnitt_gestrichelt() {
let p = project(rail("solid", serde_json::json!({"thickness": 0.15})));
let prims = plan(&p, 50.0);
// Geschnitten (Höhe 0 bis 1.0, Schnitt bei 1.0): gefüllte Fläche und ausgezogener Umriss.
assert!(prims.iter().any(|q| matches!(q, Primitive::Polygon { fill, context_object_id: None, .. } if fill != "none")));
let ls = lines(&prims, "railing-solid");
assert_eq!(ls.len(), 4);
assert!(prims.iter().filter_map(|q| match q { Primitive::Line { cls, dash, .. } if cls == "railing-solid" => Some(dash), _ => None }).all(|d| d.is_none()));
// Fuss über der Schnitthöhe (Geschoss-Offset 1.2): ganz darüber, gestrichelt, ohne Füllung.
let p = project(rail("solid", serde_json::json!({"thickness": 0.15, "baseOffset": 1.2})));
let prims = plan(&p, 50.0);
assert!(!prims.iter().any(|q| matches!(q, Primitive::Polygon { fill, context_object_id: None, .. } if fill != "none")));
assert!(prims.iter().filter_map(|q| match q { Primitive::Line { cls, dash, .. } if cls == "railing-solid" => Some(dash), _ => None }).all(|d| d.as_ref().is_some_and(|d| d.is_some())));
}
#[test]
fn klasse_aus_blendet_aus_und_unsinn_kein_absturz() {
let p = project(rail("glass", serde_json::json!({})));
assert!(plan_codes(&p, 50.0, &[]).iter().all(|q| !is_symbol_part(q)));
for bad in [serde_json::json!({"points": [{"x": 1, "y": 1}]}), serde_json::json!({"height": 0}), serde_json::json!({"points": [{"x": 0, "y": 0}, {"x": 1e300, "y": 1e300}]})] {
let p = project(rail("bars", bad));
let _ = plan(&p, 50.0);
}
}
}
+34
View File
@@ -126,6 +126,8 @@ pub enum SlabOwner<'a> {
Ceiling(&'a Ceiling, Option<usize>),
Stair(&'a Stair),
Column(&'a Column),
/// [279] Geländer; `true` = Tafel (Glas, Lochblech, Brüstung), sonst Gestänge.
Railing(&'a Railing, bool),
}
/// Je emittierter Platte (Deckenschicht, Treppentritt, Podest) ihre Herkunft (`RSlab::source`).
@@ -138,6 +140,7 @@ pub fn slab_owners<'a>(p: &'a Project, slabs: &[RSlab]) -> Vec<SlabOwner<'a>> {
SlabSource::Ceiling { index, layer } => ceilings.get(index).map_or(SlabOwner::None, |c| SlabOwner::Ceiling(c, layer)),
SlabSource::Stair { index } => stairs.get(index).map_or(SlabOwner::None, SlabOwner::Stair),
SlabSource::Column { index } => p.columns.as_deref().and_then(|c| c.get(index)).map_or(SlabOwner::None, SlabOwner::Column),
SlabSource::Railing { index, fill } => p.railings.as_deref().and_then(|c| c.get(index)).map_or(SlabOwner::None, |r| SlabOwner::Railing(r, fill)),
SlabSource::None => SlabOwner::None,
})
.collect()
@@ -700,6 +703,37 @@ pub(super) fn attach_cut_styles(cuts: Vec<Cut>, p: &Project, plane: &Plane, wall
}
cp.join_priority = Some(comp.map_or(f64::MAX, |k| k.join_priority));
}
// [279] Geländer: Tafel nach Art (Brüstung wie eine Stütze mit Bauteil, Glas hell), Gestänge schwarz.
SlabOwner::Railing(r, fill) => {
cp.source_id = Some(r.id.clone());
cp.railing_id = Some(r.id.clone());
cp.category = Some(r.category_code.clone());
match (fill, r.kind) {
(true, RailingKind::Solid) => {
let comp = r.component_id.as_deref().filter(|s| !s.is_empty()).and_then(|id| p.component(id));
if let Some(k) = comp {
let category = p.layer_category(&r.category_code);
let hid = resolve_hatch_id(None, None, category, Some(&k.hatch_id)).unwrap_or(&k.hatch_id);
if let Some(h) = resolve_hatch(p, hid, None, resolve_foreground(k, None, category, None), None) {
cp.fill = Some(poche_fill(h.pattern).to_string());
cp.hatch = Some(h);
}
cp.component_id = Some(k.id.clone());
} else {
cp.fill = Some(HATCH_PAPER.to_string());
cp.hatch = Some(no_hatch());
}
}
(true, RailingKind::Glass) => {
cp.fill = Some("#cfe3ee".to_string());
cp.hatch = Some(no_hatch());
}
_ => {
cp.fill = Some(HATCH_INK.to_string());
cp.hatch = Some(no_hatch());
}
}
}
SlabOwner::None => {}
}
bands.push(cp);
+11 -1
View File
@@ -247,6 +247,8 @@ pub struct Cut {
pub source_id: Option<String>,
pub category: Option<String>,
pub stair_id: Option<String>,
/// [279] Geländer, zu dem das Band gehört (Pick `@railing:<id>`).
pub railing_id: Option<String>,
/// [33] Index der Schicht im Aufbau des Bauteils (Wand-, Decken-, Dachtyp), wo bekannt.
pub layer_index: Option<usize>,
/// [33] Override der Schicht (nur beim Zeichnen gesetzt, [`cut_overrides`]).
@@ -255,7 +257,7 @@ pub struct Cut {
impl Cut {
fn new(kind: Kind, index: usize, pts: Vec<[f64; 2]>) -> Cut {
Cut { kind, index, pts, nse: None, fill: None, hatch: None, join_priority: None, component_id: None, source_id: None, category: None, stair_id: None, layer_index: None, ov: None }
Cut { kind, index, pts, nse: None, fill: None, hatch: None, join_priority: None, component_id: None, source_id: None, category: None, stair_id: None, railing_id: None, layer_index: None, ov: None }
}
}
@@ -439,6 +441,10 @@ pub fn without_elements(p: &Project, ids: &HashSet<String>) -> Project {
if let Some(v) = &mut q.columns {
v.retain(|x| !ids.contains(&x.id));
}
// [279] Geländer.
if let Some(v) = &mut q.railings {
v.retain(|x| !ids.contains(&x.id));
}
if let Some(v) = &mut q.rooms {
v.retain(|x| !ids.contains(&x.id));
}
@@ -602,6 +608,7 @@ pub(crate) fn edge_categories(p: &Project, walls: &[Option<&Wall>], slabs: &[ban
bands::SlabOwner::Ceiling(c, _) => &c.category_code,
bands::SlabOwner::Stair(st) => &st.category_code,
bands::SlabOwner::Column(c) => &c.category_code,
bands::SlabOwner::Railing(c, _) => &c.category_code,
bands::SlabOwner::None => continue,
};
m.insert((Kind::Slab, i), code.clone());
@@ -628,6 +635,7 @@ pub(crate) fn edge_ids(p: &Project, walls: &[Option<&Wall>], slabs: &[bands::Sla
bands::SlabOwner::Ceiling(c, _) => &c.id,
bands::SlabOwner::Stair(st) => &st.id,
bands::SlabOwner::Column(c) => &c.id,
bands::SlabOwner::Railing(c, _) => &c.id,
bands::SlabOwner::None => continue,
};
m.insert((Kind::Slab, i), id.clone());
@@ -682,6 +690,8 @@ pub(super) fn compute_plane(p: &Project, level: &LevelSpec, bodies: &[BodyMesh],
slabs_r.extend(model3d::emit_stairs(p, true));
// [141] Stützen: geschnitten mit Bauteil-Stil (Rang gegen die Wände wie im Grundriss) und in der Projektion.
slabs_r.extend(model3d::column_slabs(p));
// [279] Geländer: geschnitten und in der Projektion.
slabs_r.extend(model3d::railing_slabs(p));
let wi: Vec<render3d::WallInput> = walls_r.iter().map(wall_input).collect();
let si: Vec<render3d::SlabInput> = slabs_r.iter().map(slab_input).collect();
// Die Ebene ging als Zahl-Argument (wasm-bindgen, `Math.fround`) hinein, nicht über JSON.
@@ -556,7 +556,11 @@ pub fn section_primitives_mv(out: &Output, mono: bool, hidden_lines: bool, vis:
// [152] Importiertes Netz: Pick über die Kontext-Id.
*context_object_id = if cp.kind == Kind::Mesh { src.clone() } else { None };
*wall_id = if cp.kind == Kind::Wall { src.clone() } else { None };
*ceiling_id = if cp.kind == Kind::Slab && cp.stair_id.is_none() { src.clone() } else { None };
*ceiling_id = if cp.kind == Kind::Slab && cp.stair_id.is_none() && cp.railing_id.is_none() { src.clone() } else { None };
// [279] Geländer: Pick über die Kontext-Id `@railing:<id>`.
if let Some(r) = &cp.railing_id {
*context_object_id = Some(crate::plan::railings::pick_id(r));
}
*roof_id = if cp.kind == Kind::Roof { src.clone() } else { None };
*stair_id = cp.stair_id.clone();
*extruded_solid_id = if cp.kind == Kind::Body { src } else { None };
+14 -10
View File
@@ -315,6 +315,8 @@ pub(crate) struct OwnerRef {
/// Treppe (Stufen, Wangen, Geländer) bzw. Stütze statt Decke, wenn `kind` = `Slab`.
pub stair: bool,
pub column: bool,
/// [279] Geländer (Pick `@railing:<id>`).
pub railing: bool,
}
/// [266] Alle Flächen des Modells für eine beliebige Ansicht (Vektor-Axonometrie, `plan/axo.rs`): dieselben Körper wie
@@ -325,6 +327,7 @@ pub(crate) fn model_view_faces(p: &Project, vis: &Visibility, view: &dyn Fn([f64
let mut slabs_r = model3d::emit_slabs(p);
slabs_r.extend(model3d::emit_stairs(p, true));
slabs_r.extend(model3d::column_slabs(p));
slabs_r.extend(model3d::railing_slabs(p));
let wi: Vec<render3d::WallInput> = walls_r.iter().map(wall_input).collect();
let walls = wall_owners(p, &walls_r);
let slabs = slab_owners(p, &slabs_r);
@@ -342,19 +345,20 @@ pub(crate) fn model_view_faces(p: &Project, vis: &Visibility, view: &dyn Fn([f64
.owners
.iter()
.map(|&(kind, i)| {
let (id, stair, column) = match kind {
Kind::Wall => (walls_r.get(i).map(|w| w.wall_id.clone()), false, false),
let (id, stair, column, railing) = match kind {
Kind::Wall => (walls_r.get(i).map(|w| w.wall_id.clone()), false, false, false),
Kind::Slab => match slabs.get(i) {
Some(SlabOwner::Ceiling(c, _)) => (Some(c.id.clone()), false, false),
Some(SlabOwner::Stair(s)) => (Some(s.id.clone()), true, false),
Some(SlabOwner::Column(c)) => (Some(c.id.clone()), false, true),
_ => (None, false, false),
Some(SlabOwner::Ceiling(c, _)) => (Some(c.id.clone()), false, false, false),
Some(SlabOwner::Stair(s)) => (Some(s.id.clone()), true, false, false),
Some(SlabOwner::Column(c)) => (Some(c.id.clone()), false, true, false),
Some(SlabOwner::Railing(r, _)) => (Some(r.id.clone()), false, false, true),
_ => (None, false, false, false),
},
Kind::Roof => (roofs.get(i).map(|r| r.id.clone()), false, false),
Kind::Body => (solids.get(i).map(|s| s.id.clone()), false, false),
Kind::Mesh => (mrefs.get(i).map(|m| m.mesh.id.clone()), false, false),
Kind::Roof => (roofs.get(i).map(|r| r.id.clone()), false, false, false),
Kind::Body => (solids.get(i).map(|s| s.id.clone()), false, false, false),
Kind::Mesh => (mrefs.get(i).map(|m| m.mesh.id.clone()), false, false, false),
};
OwnerRef { kind, id, stair, column }
OwnerRef { kind, id, stair, column, railing }
})
.collect();
Ok((vf, refs))
+2 -1
View File
@@ -15,7 +15,7 @@ const REQUIRED_ARRAYS: [&str; 3] = ["walls", "layers", "drawingLevels"];
const DEFAULT_ARRAYS: [&str; 5] = ["lineStyles", "hatches", "components", "wallTypes", "drawings2d"];
/// Bekannte Felder von `Project` (für die Meldung unbekannter Felder).
const KNOWN_KEYS: [&str; 63] = [
const KNOWN_KEYS: [&str; 64] = [
"formatVersion", "id", "name", "lineStyles", "textStyles", "hatches", "components", "wallTypes",
"ceilingTypes", "roofTypes", "blockDefs", "doorTypes", "windowTypes", "stairTypes", "pens",
"penSets", "activePenSetId", "customPalettes", "builtinPaletteBanks", "drawingLevels", "layers",
@@ -30,6 +30,7 @@ const KNOWN_KEYS: [&str; 63] = [
"designOptionSets",
"designOptionCombinations",
"units",
"railings",
];
/// Ergebnis des Einlesens.
+8 -2
View File
@@ -96,6 +96,11 @@ pub fn dangling_refs(p: &Project) -> Vec<String> {
miss(&mut out, "Stütze", &c.id, "Bauteil", c.component_id.as_deref().unwrap_or(""), &components);
miss(&mut out, "Stütze", &c.id, "Schraffur", c.hatch_id.as_deref().unwrap_or(""), &hatches);
}
// [279] Geländer.
for r in p.railings.as_deref().unwrap_or(&[]) {
miss(&mut out, "Geländer", &r.id, "Geschoss", &r.floor_id, &levels);
miss(&mut out, "Geländer", &r.id, "Bauteil", r.component_id.as_deref().unwrap_or(""), &components);
}
for r in p.rooms.as_deref().unwrap_or(&[]) {
miss(&mut out, "Raum", &r.id, "Geschoss", &r.floor_id, &levels);
}
@@ -167,7 +172,7 @@ pub fn dangling_refs(p: &Project) -> Vec<String> {
// Gruppen: Mitglieder und Zyklen.
let groups = p.groups.as_deref().unwrap_or(&[]);
let group_ids = ids(groups, |g| g.id.as_str());
let members: [(&str, HashSet<&str>); 9] = [
let members: [(&str, HashSet<&str>); 10] = [
("Zeichnung", ids(&p.drawings2d, |d| d.id.as_str())),
("Decke", ids(p.ceilings.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
("Raum", ids(p.rooms.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
@@ -177,13 +182,14 @@ pub fn dangling_refs(p: &Project) -> Vec<String> {
("Öffnung", ids(p.openings.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
("Baum", ids(p.trees.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
("Kamera", ids(p.cameras.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
("Geländer", ids(p.railings.as_deref().unwrap_or(&[]), |x| x.id.as_str())),
];
for g in groups {
for w in &g.wall_ids {
miss(&mut out, "Gruppe", &g.id, "Wand", w, &walls);
}
let none = Vec::new();
let lists = [&g.drawing_ids, &g.ceiling_ids, &g.room_ids, &g.stair_ids, &g.column_ids, &g.roof_ids, &g.opening_ids, g.tree_ids.as_ref().unwrap_or(&none), g.camera_ids.as_ref().unwrap_or(&none)];
let lists = [&g.drawing_ids, &g.ceiling_ids, &g.room_ids, &g.stair_ids, &g.column_ids, &g.roof_ids, &g.opening_ids, g.tree_ids.as_ref().unwrap_or(&none), g.camera_ids.as_ref().unwrap_or(&none), g.railing_ids.as_ref().unwrap_or(&none)];
for (list, (kind, known)) in lists.into_iter().zip(&members) {
for id in list {
miss(&mut out, "Gruppe", &g.id, kind, id, known);
+2
View File
@@ -158,6 +158,8 @@ pub fn run(p: &Project, name: &str, args: &[f64], text: &str) -> Result<String,
("materialMaps", _) => json(&model3d::wall_material_color_maps(p)),
("slabs", _) => json(&model3d::emit_slabs(p)),
("columnMeshes", _) => json(&model3d::emit_columns(p)),
// [279] Kennzahlen eines Geländers (Objekt-Info): Länge, Fuss- und Oberkante, Stäbe, Pfosten; Text = Id.
("railingInfo", _) => json(&crate::railing::info(p, text.trim())),
("walls", 1) => json(&model3d::emit_walls(p, args[0] != 0.0)?),
("openingMeshes", 1) => json(&model3d::emit_opening_meshes(p, args[0])),
("stairSlabs", 1) => json(&model3d::emit_stairs(p, args[0] != 0.0)),
+416
View File
@@ -0,0 +1,416 @@
//! [279] Geländer als eigenes Bauteil (`Project.railings`): Absturzsicherung für Balkon, Galerie, Treppenauge und
//! Terrasse. **Eine Quelle** für die Körper: [`pieces`] zerlegt ein Geländer in lotrechte Prismen
//! `(Querschnitt, z_unten, z_oben, Teil)` wie `model3d::column_pieces` bei den Stützen. Daraus entstehen das 3D-Netz
//! (`model3d/railings.rs`), die Platten für Schnitt, Ansicht und 3D-Dokument (`model3d::railing_slabs`), die
//! IFC-Mengen (`ifc_data.rs`) und die Netze der Auswahl. Der Grundriss (`plan/railings.rs`) zeichnet die Achse und
//! die Streifen ([`strips`]) selbst. Teile, Masse und Obergrenzen:
//!
//! - **Achse:** Polylinie `points` (offen; mit `closed` oder letzter = erster Punkt geschlossen), Gehrungen an den
//! Ecken über [`crate::stair_rail::offset_polyline`] — dieselbe Hilfe wie die Treppen-Handläufe und die
//! Absturzsicherung am Deckenloch ([`crate::stair_guard`], [`crate::stairs3d::guard_mesh`]).
//! - **Stäbe:** Pfosten an den Ecken und höchstens [`POST_GAP`] auseinander, Stäbe im Achsabstand `barSpacing`
//! (lichtes Mass höchstens [`MAX_CLEAR_GAP`] = 12 cm nach SIA 358: der Abstand wird bei Bedarf verkleinert),
//! Fussschiene und Handlauf bzw. Obergurt.
//! - **Glas, Lochblech, massive Brüstung:** durchgehende Tafel der Dicke `thickness` (mit Gehrung); Handlauf obenauf.
//! - **Höhe:** Fuss = Geschoss-UK + `baseOffset`, Oberkante = Fuss + `height` (Vorgabe [`DEFAULT_HEIGHT`] = 1.00 m).
use crate::model::*;
use crate::stair_rail::{is_closed, offset_polyline, P};
/// Vorgabehöhe (m) nach SIA 358 (Absturzsicherung bis 12 m Fallhöhe: 1.00 m).
pub const DEFAULT_HEIGHT: f64 = 1.0;
/// Kategorie (Ebene) neuer Geländer.
pub const CATEGORY: &str = "41";
/// Pick-Id im Grundriss/Schnitt (`contextObjectId = "@railing:<id>"`), wie bei den Bäumen.
pub const PICK_PREFIX: &str = "@railing:";
/// Pfostenabstand (m) und höchstes lichtes Mass zwischen Stäben (m, SIA 358).
pub const POST_GAP: f64 = 1.2;
pub const MAX_CLEAR_GAP: f64 = 0.12;
/// Obergrenzen gegen Eingabefehler (ein Geländer von 100 km Länge): Pfosten und Stäbe je Geländer.
const MAX_POSTS: f64 = 5_000.0;
const MAX_BARS: f64 = 20_000.0;
/// Pfosten: Kantenlänge (m); Fussschiene: Breite, Höhe und Lage über dem Fuss (m); Obergurt ohne Handlauf (m).
const POST_SIZE: f64 = 0.03;
const FOOT_W: f64 = 0.03;
const FOOT_Z: (f64, f64) = (0.05, 0.08);
const TOP_BAR: (f64, f64) = (0.04, 0.03);
/// Teil eines Geländers (für Farbe, Schnittfüllung und Menge).
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Part {
Post,
Bar,
/// Handlauf bzw. Obergurt.
Rail,
/// Fussschiene.
Foot,
/// Tafel: Glas, Lochblech oder massive Brüstung.
Fill,
}
/// Ein lotrechtes Prisma des Geländers.
#[derive(Clone, Debug)]
pub struct Piece {
/// Querschnitt im Grundriss (Gegenuhrzeigersinn).
pub outline: Vec<P>,
pub z0: f64,
pub z1: f64,
pub part: Part,
}
/// Aufgelöste Masse eines Geländers (Vorgaben eingesetzt, Unsinn begrenzt).
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Spec {
pub kind: RailingKind,
pub height: f64,
/// Absolute Höhe des Fusses.
pub z0: f64,
pub thickness: f64,
/// Achsabstand der Stäbe (nach der 12-cm-Regel begrenzt).
pub bar_spacing: f64,
pub bar_size: f64,
pub handrail: bool,
pub handrail_size: f64,
}
impl Spec {
/// Oberkante (absolut).
pub fn top(&self) -> f64 {
self.z0 + self.height
}
/// Höhe des Handlaufs bzw. Obergurts (die Füllung endet darunter).
pub fn rail_h(&self) -> f64 {
if self.handrail {
self.handrail_size
} else if self.kind == RailingKind::Bars {
TOP_BAR.1
} else {
0.0
}
}
/// Breite des Handlaufs bzw. Obergurts.
pub fn rail_w(&self) -> f64 {
if self.handrail {
self.handrail_size
} else {
TOP_BAR.0
}
}
/// Hat das Geländer einen Handlauf als eigenes Teil (Stäbe immer: Handlauf oder Obergurt)?
pub fn has_rail(&self) -> bool {
self.handrail || self.kind == RailingKind::Bars
}
}
/// Vorgabe der Dicke je Art.
pub fn default_thickness(kind: RailingKind) -> f64 {
match kind {
RailingKind::Glass => 0.02,
RailingKind::Solid => 0.15,
RailingKind::Perforated => 0.004,
_ => 0.02,
}
}
/// Handlauf vorhanden? Fehlt die Angabe: bei Stäben und Glas ja, sonst nein.
pub fn has_handrail(r: &Railing) -> bool {
r.handrail.unwrap_or(matches!(r.kind, RailingKind::Bars | RailingKind::Glass))
}
/// Fusshöhe (absolut): Geschoss-UK + `baseOffset`.
pub fn base_z(p: &Project, r: &Railing) -> f64 {
p.floor(&r.floor_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0)) + r.base_offset.filter(|v| v.is_finite()).unwrap_or(0.0)
}
/// Aufgelöste Masse; `None` bei Unsinn (nicht endliche Höhe, Höhe ≤ 0, weniger als 2 Punkte).
pub fn spec(p: &Project, r: &Railing) -> Option<Spec> {
let height = r.height;
if !(height.is_finite() && height > 0.0) || height > 20.0 || axis(r).is_none() {
return None;
}
let z0 = base_z(p, r);
if !z0.is_finite() {
return None;
}
let dim = |v: Option<f64>, d: f64, lo: f64, hi: f64| v.filter(|v| v.is_finite() && *v > 0.0).map_or(d, |v| v.clamp(lo, hi));
let bar_size = dim(r.bar_size, 0.014, 0.004, 0.1);
// Lichtes Mass ≤ 12 cm: Achsabstand höchstens 12 cm plus Stabbreite.
let bar_spacing = dim(r.bar_spacing, 0.12, 0.03, 1.0).min(MAX_CLEAR_GAP + bar_size);
Some(Spec {
kind: if r.kind == RailingKind::Unknown { RailingKind::Bars } else { r.kind },
height,
z0,
thickness: dim(r.thickness, default_thickness(r.kind), 0.002, 1.0),
bar_spacing,
bar_size,
handrail: has_handrail(r),
handrail_size: dim(r.handrail_size, 0.04, 0.02, 0.15).min(height / 2.0),
})
}
/// Achse als Zug: aufeinanderfolgende gleiche Punkte entfallen, ein geschlossener Zug endet auf seinem Anfang;
/// `None` bei weniger als zwei verschiedenen Punkten oder nicht endlichen Koordinaten.
pub fn axis(r: &Railing) -> Option<Vec<P>> {
let mut pts: Vec<P> = Vec::with_capacity(r.points.len() + 1);
for q in &r.points {
if !q.x.is_finite() || !q.y.is_finite() {
return None;
}
let q = [q.x, q.y];
if pts.last().is_none_or(|l| (l[0] - q[0]).abs() > 1e-6 || (l[1] - q[1]).abs() > 1e-6) {
pts.push(q);
}
}
if pts.len() < 2 {
return None;
}
// Ein Punkt am Ende gleich dem Anfang schliesst den Zug (mit mindestens drei Ecken).
if r.closed == Some(true) && pts.len() >= 3 && !is_closed(&pts) {
pts.push(pts[0]);
}
Some(pts)
}
/// Länge der Achse (m).
pub fn length(axis: &[P]) -> f64 {
axis.windows(2).map(|w| crate::jsmath::hypot2(w[1][0] - w[0][0], w[1][1] - w[0][1])).sum()
}
/// Streifen der Breite `2·half` um die Achse mit Gehrung: ein Viereck je Teilstrecke (gemeinsame Gehrungskanten,
/// Gegenuhrzeigersinn), dazu die Ränder links und rechts der Laufrichtung.
pub fn strips(axis: &[P], half: f64) -> (Vec<Vec<P>>, Vec<P>, Vec<P>) {
let (l, r) = (offset_polyline(axis, half), offset_polyline(axis, -half));
let quads = (0..axis.len().saturating_sub(1))
.map(|i| vec![r[i], r[i + 1], l[i + 1], l[i]])
.filter(|q| area(q).abs() > 1e-10 && q.iter().all(|v| v[0].is_finite() && v[1].is_finite()))
.collect();
(quads, l, r)
}
fn area(q: &[P]) -> f64 {
let n = q.len();
(0..n).map(|i| q[i][0] * q[(i + 1) % n][1] - q[(i + 1) % n][0] * q[i][1]).sum::<f64>() / 2.0
}
/// Quadrat der Kantenlänge `s` um `c`, in Richtung `d` (Einheit) gedreht (Gegenuhrzeigersinn).
fn square(c: P, d: P, s: f64) -> Vec<P> {
let (h, n) = (s / 2.0, [-d[1], d[0]]);
let at = |a: f64, b: f64| [c[0] + d[0] * a + n[0] * b, c[1] + d[1] * a + n[1] * b];
vec![at(-h, -h), at(h, -h), at(h, h), at(-h, h)]
}
/// Pfosten- und Stabstellen längs der Achse: `(Lage, Richtung)`. Pfosten an jedem Eck und höchstens [`POST_GAP`]
/// auseinander, Stäbe gleichmässig dazwischen, nicht nahe an einem Pfosten.
pub fn stations(axis: &[P], spec: &Spec) -> (Vec<(P, P)>, Vec<(P, P)>) {
let total = length(axis);
let (mut posts, mut bars) = (Vec::new(), Vec::new());
if !total.is_finite() || total / POST_GAP > MAX_POSTS {
return (posts, bars);
}
let with_bars = total / spec.bar_spacing.max(1e-3) <= MAX_BARS;
let closed = is_closed(axis);
let nseg = axis.len() - 1;
for (i, w) in axis.windows(2).enumerate() {
let len = crate::jsmath::hypot2(w[1][0] - w[0][0], w[1][1] - w[0][1]);
if len < 1e-9 {
continue;
}
let d = [(w[1][0] - w[0][0]) / len, (w[1][1] - w[0][1]) / len];
let at = |t: f64| [w[0][0] + (w[1][0] - w[0][0]) * t, w[0][1] + (w[1][1] - w[0][1]) * t];
let n_post = (len / POST_GAP).ceil().max(1.0) as usize;
// Letzter Eckpfosten nur am offenen Ende (geschlossen: der Anfang steht schon).
for k in 0..n_post + usize::from(i + 1 == nseg && !closed) {
posts.push((at(k as f64 / n_post as f64), d));
}
if with_bars {
let n_bar = (len / spec.bar_spacing).round().max(1.0) as usize;
let gap = len / n_post as f64;
for k in 1..n_bar {
let t = k as f64 / n_bar as f64;
let f = (t * n_post as f64).fract();
if f.min(1.0 - f) * gap > POST_SIZE / 2.0 + spec.bar_size / 2.0 + 0.01 {
bars.push((at(t), d));
}
}
}
}
(posts, bars)
}
/// Prismen des Geländers; leer bei Unsinn.
pub fn pieces(p: &Project, r: &Railing) -> Vec<Piece> {
let (Some(s), Some(ax)) = (spec(p, r), axis(r)) else { return Vec::new() };
let mut out = Vec::new();
let top = s.top();
let under = top - s.rail_h();
let strip_pieces = |half: f64, z0: f64, z1: f64, part: Part, out: &mut Vec<Piece>| {
if z1 - z0 > 1e-6 {
out.extend(strips(&ax, half).0.into_iter().map(|outline| Piece { outline, z0, z1, part }));
}
};
match s.kind {
RailingKind::Bars | RailingKind::Unknown => {
let (posts, bars) = stations(&ax, &s);
for (c, d) in &posts {
out.push(Piece { outline: square(*c, *d, POST_SIZE), z0: s.z0, z1: under, part: Part::Post });
}
for (c, d) in &bars {
out.push(Piece { outline: square(*c, *d, s.bar_size), z0: s.z0 + FOOT_Z.1, z1: under, part: Part::Bar });
}
strip_pieces(FOOT_W / 2.0, s.z0 + FOOT_Z.0, s.z0 + FOOT_Z.1, Part::Foot, &mut out);
}
_ => strip_pieces(s.thickness / 2.0, s.z0, under, Part::Fill, &mut out),
}
if s.has_rail() {
strip_pieces(s.rail_w() / 2.0, under, top, Part::Rail, &mut out);
}
out
}
/// Anzahl Stäbe und Pfosten (Kennzahl der Objekt-Info).
pub fn counts(p: &Project, r: &Railing) -> (usize, usize) {
let (Some(s), Some(ax)) = (spec(p, r), axis(r)) else { return (0, 0) };
if s.kind != RailingKind::Bars {
return (0, 0);
}
let (posts, bars) = stations(&ax, &s);
(bars.len(), posts.len())
}
/// Kennzahlen für die Objekt-Info: Länge der Achse, absolute Fuss- und Oberkante, Stäbe, Pfosten, Fläche der Ansicht (m²);
/// `None` für ein unbekanntes oder unsinniges Geländer.
pub fn info(p: &Project, id: &str) -> Option<serde_json::Value> {
let r = p.railings.as_deref()?.iter().find(|r| r.id == id)?;
let (s, ax) = (spec(p, r)?, axis(r)?);
let len = length(&ax);
let (bars, posts) = counts(p, r);
Some(serde_json::json!({"length": len, "baseZ": s.z0, "topZ": s.top(), "height": s.height, "bars": bars, "posts": posts, "area": len * s.height, "closed": is_closed(&ax)}))
}
/// Anzeigename für Regeln und Listen (`railing_label`): Art und Länge.
pub fn label(r: &Railing) -> String {
let kind = match r.kind {
RailingKind::Glass => "Glasgeländer",
RailingKind::Solid => "Brüstung",
RailingKind::Perforated => "Lochblechgeländer",
_ => "Stabgeländer",
};
let len = axis(r).map_or(0.0, |a| length(&a));
format!("{kind} {} m", crate::js_fmt::js_number((len * 100.0).round() / 100.0))
}
/// Farbe eines Teils im 3D und in der Ansicht (Bauteil-Farbe der massiven Brüstung, sonst nach Art).
pub fn color(p: &Project, r: &Railing, part: Part) -> [f64; 3] {
let hex = |h: &str, d: [f64; 3]| crate::style::hex_to_rgb(h, d);
match (r.kind, part) {
(RailingKind::Glass, Part::Fill) => hex("#b7d3e0", [0.72, 0.83, 0.88]),
(RailingKind::Perforated, Part::Fill) => hex("#9aa3ab", [0.6, 0.64, 0.67]),
(RailingKind::Solid, Part::Fill) => {
let d = [0.72, 0.71, 0.68];
r.component_id.as_deref().and_then(|id| p.component(id)).map_or(d, |k| hex(&k.color, d))
}
_ => hex("#74797f", [0.45, 0.47, 0.5]),
}
}
#[cfg(test)]
mod tests {
use super::*;
fn rail(kind: RailingKind, pts: &[(f64, f64)]) -> Railing {
Railing { id: "g".into(), r#type: "railing".into(), floor_id: "eg".into(), category_code: CATEGORY.into(), points: pts.iter().map(|&(x, y)| Vec2 { x, y }).collect(), height: 1.0, kind, ..Default::default() }
}
fn proj() -> Project {
let mut p = Project::default();
p.drawing_levels.push(DrawingLevel { id: "eg".into(), kind: DrawingLevelKind::Floor, base_elevation: Some(3.0), ..Default::default() });
p
}
#[test]
fn spec_vorgaben_und_unsinn() {
let p = proj();
let s = spec(&p, &rail(RailingKind::Bars, &[(0.0, 0.0), (3.0, 0.0)])).unwrap();
assert_eq!((s.height, s.z0, s.top()), (1.0, 3.0, 4.0));
assert!(s.handrail && s.has_rail());
// Lichtes Mass höchstens 12 cm: Achsabstand ≤ 0.12 + Stabbreite.
let mut g = rail(RailingKind::Bars, &[(0.0, 0.0), (3.0, 0.0)]);
g.bar_spacing = Some(0.5);
let s = spec(&p, &g).unwrap();
assert!(s.bar_spacing - s.bar_size <= MAX_CLEAR_GAP + 1e-12);
// Basis relativ zum Geschoss.
g.base_offset = Some(0.18);
assert!((spec(&p, &g).unwrap().z0 - 3.18).abs() < 1e-12);
// Unsinn.
for bad in [rail(RailingKind::Bars, &[(0.0, 0.0)]), rail(RailingKind::Bars, &[(1.0, 1.0), (1.0, 1.0)]), rail(RailingKind::Bars, &[(0.0, 0.0), (f64::NAN, 1.0)]), Railing { height: 0.0, ..rail(RailingKind::Glass, &[(0.0, 0.0), (1.0, 0.0)]) }, Railing { height: f64::INFINITY, ..rail(RailingKind::Glass, &[(0.0, 0.0), (1.0, 0.0)]) }] {
assert!(spec(&p, &bad).is_none() && pieces(&p, &bad).is_empty());
}
// Handlauf: Vorgabe je Art, ausdrückliche Angabe gewinnt.
assert!(!has_handrail(&rail(RailingKind::Solid, &[(0.0, 0.0), (1.0, 0.0)])));
assert!(has_handrail(&Railing { handrail: Some(true), ..rail(RailingKind::Solid, &[(0.0, 0.0), (1.0, 0.0)]) }));
assert!(!has_handrail(&Railing { handrail: Some(false), ..rail(RailingKind::Bars, &[(0.0, 0.0), (1.0, 0.0)]) }));
}
#[test]
fn staebe_pfosten_und_masse() {
let p = proj();
let r = rail(RailingKind::Bars, &[(0.0, 0.0), (3.0, 0.0)]);
let pcs = pieces(&p, &r);
let n = |part| pcs.iter().filter(|q| q.part == part).count();
// 3 m: 3 Felder à 1 m → 4 Pfosten, 1 Fussschiene, 1 Handlauf.
assert_eq!((n(Part::Post), n(Part::Foot), n(Part::Rail)), (4, 1, 1));
// Stäbe: gleichmässig, lichtes Mass ≤ 12 cm (Achsabstand ≈ 0.12: ≥ 24 Stäbe).
assert!(n(Part::Bar) >= 24, "{}", n(Part::Bar));
assert_eq!(counts(&p, &r), (n(Part::Bar), 4));
// Oberkante = Fuss + Höhe; alle Teile im Höhenbereich.
let z1 = pcs.iter().map(|q| q.z1).fold(f64::MIN, f64::max);
let z0 = pcs.iter().map(|q| q.z0).fold(f64::MAX, f64::min);
assert!((z1 - 4.0).abs() < 1e-12 && (z0 - 3.0).abs() < 1e-12);
// Querschnitte im Gegenuhrzeigersinn.
assert!(pcs.iter().all(|q| area(&q.outline) > 0.0));
// Der Abstand zweier Stäbe ist (lichtes Mass) höchstens 12 cm.
let mut xs: Vec<f64> = pcs.iter().filter(|q| q.part == Part::Bar).map(|q| q.outline.iter().map(|v| v[0]).sum::<f64>() / 4.0).collect();
xs.sort_by(f64::total_cmp);
assert!(xs.windows(2).all(|w| w[1] - w[0] - 0.014 <= 0.1201), "{xs:?}");
}
#[test]
fn tafel_mit_gehrung_und_geschlossen() {
let p = proj();
let r = rail(RailingKind::Glass, &[(0.0, 0.0), (2.0, 0.0), (2.0, 2.0)]);
let pcs = pieces(&p, &r);
// Zwei Tafel-Streifen (je Teilstrecke) und ein Handlauf-Streifen je Teilstrecke.
assert_eq!(pcs.iter().filter(|q| q.part == Part::Fill).count(), 2);
assert_eq!(pcs.iter().filter(|q| q.part == Part::Rail).count(), 2);
// Gehrung: die beiden Streifen teilen die Gehrungskante, die Summe der Flächen = Länge × Dicke ohne Überlappung.
let a: f64 = pcs.iter().filter(|q| q.part == Part::Fill).map(|q| area(&q.outline)).sum();
assert!((a - 4.0 * 0.02).abs() < 1e-3, "{a}");
// Glas bis unter den Handlauf.
let fill = pcs.iter().find(|q| q.part == Part::Fill).unwrap();
assert!((fill.z1 - (4.0 - 0.04)).abs() < 1e-12);
// Geschlossen: ein Zug mit Anfang = Ende, vier Streifen.
let mut sq = rail(RailingKind::Solid, &[(0.0, 0.0), (2.0, 0.0), (2.0, 2.0), (0.0, 2.0)]);
sq.closed = Some(true);
assert_eq!(pieces(&p, &sq).iter().filter(|q| q.part == Part::Fill).count(), 4);
// Brüstung ohne Handlauf: Tafel bis zur Oberkante.
let top = pieces(&p, &sq).iter().map(|q| q.z1).fold(f64::MIN, f64::max);
assert!((top - 4.0).abs() < 1e-12);
}
#[test]
fn riesig_gibt_keine_millionen_stuecke() {
let p = proj();
let r = rail(RailingKind::Bars, &[(0.0, 0.0), (1.0e6, 0.0)]);
assert!(pieces(&p, &r).len() < 10);
let r = rail(RailingKind::Bars, &[(0.0, 0.0), (3000.0, 0.0)]);
let n = pieces(&p, &r).len();
assert!(n > 2000 && n < 30_000, "{n}");
}
}
#[cfg(test)]
#[path = "railing_tests.rs"]
mod view_tests;
+220
View File
@@ -0,0 +1,220 @@
//! [279] Geländer in allen Ableitungen: 3D-Netze und Platten, Schnitt, Ansicht, 3D-Dokument, IFC, Umbaufilter, Varianten,
//! Befehl „railing", Verschieben, Gruppen und Verweise.
use crate::model::*;
use crate::plan::domains::{plan_domains, PlanArgs};
use crate::plan::prim::Primitive;
use serde_json::{json, Value};
/// Projekt mit einem Geländer `g` (offen, 4 m entlang x bei y = 0, Höhe 1 m) auf dem EG (Sockel 3.0 m), dazu Schnitt und Ansicht.
fn project(kind: &str, extra: Value) -> Project {
let mut r = json!({"id": "g", "type": "railing", "floorId": "eg", "categoryCode": "41", "points": [{"x": 0, "y": 0}, {"x": 4, "y": 0}], "height": 1.0, "kind": kind});
for (k, v) in extra.as_object().unwrap() {
r[k] = v.clone();
}
serde_json::from_value(json!({
"id": "p", "name": "P", "lineStyles": [], "hatches": [], "components": [{"id": "c", "name": "Beton", "color": "#b0b0b0", "hatchId": ""}], "wallTypes": [],
"layers": [{"code": "41", "name": "Geländer", "color": "#102030", "lw": 0.25, "visible": true, "locked": false}],
"drawingLevels": [
{"id": "eg", "name": "EG", "kind": "floor", "visible": true, "locked": false, "floorHeight": 3.0, "cutHeight": 1.0, "baseElevation": 3.0},
{"id": "ans", "name": "Ansicht Süd", "kind": "elevation", "visible": true, "locked": false, "linePoints": [{"x": -5, "y": -5}, {"x": 10, "y": -5}], "directionSign": 1},
{"id": "sc", "name": "Schnitt", "kind": "section", "visible": true, "locked": false, "linePoints": [{"x": 1.5, "y": -5}, {"x": 1.5, "y": 5}], "directionSign": 1}
],
"walls": [], "openings": [], "drawings2d": [], "railings": [r]
}))
.unwrap()
}
fn level(p: &Project, id: &str) -> crate::plan::section::LevelSpec {
let l = p.drawing_levels.iter().find(|l| l.id == id).unwrap();
crate::plan::section::LevelSpec::from_json(&serde_json::to_value(l).unwrap())
}
fn hide41() -> crate::plan::section::Visibility {
crate::plan::section::Visibility { has_vis: true, invisible: ["41".to_string()].into_iter().collect(), ..Default::default() }
}
fn picks(prims: &[Primitive]) -> usize {
prims.iter().filter(|q| matches!(q, Primitive::Polygon { context_object_id: Some(id), .. } if id == "@railing:g")).count()
}
fn plan(p: &Project, extra: Value) -> Vec<Primitive> {
let mut t = json!({"floor": "eg", "show": ["41"], "scale": 50, "global": true});
for (k, x) in extra.as_object().unwrap() {
t[k] = x.clone();
}
plan_domains(p, &PlanArgs::parse_in(p, 1.0, &t.to_string()).unwrap()).unwrap().columns
}
#[test]
fn netze_platten_und_pick() {
// Stäbe: nur das Gestänge; Glas: Tafel und Gestänge (Handlauf).
let bars = project("bars", json!({}));
let m = crate::model3d::emit_railings(&bars);
assert_eq!(m.len(), 1);
assert!(matches!(m[0].owner, crate::model3d::Owner::Railing(0)));
// Höhen im Netz: Fuss 3.0, Oberkante 4.0.
let zs: Vec<f64> = m[0].positions.chunks_exact(3).map(|c| c[2]).collect();
assert!((zs.iter().cloned().fold(f64::MAX, f64::min) - 3.0).abs() < 1e-9 && (zs.iter().cloned().fold(f64::MIN, f64::max) - 4.0).abs() < 1e-9);
let glass = project("glass", json!({}));
assert_eq!(crate::model3d::emit_railings(&glass).len(), 2);
let slabs = crate::model3d::railing_slabs(&glass);
assert!(!slabs.is_empty() && slabs.iter().all(|s| s.ceiling_id == "g" && matches!(s.source, crate::model3d::SlabSource::Railing { index: 0, .. })));
// Pick-Geometrie: ein Eintrag mit Dreiecken.
let pk = crate::model3d::pick_railings(&glass);
assert_eq!(pk.len(), 1);
assert!(!pk[0].tris.is_empty() && pk[0].railing_id == "g");
// Das 3D-Modell trägt das Geländer bei den Stützen; ausgeblendete Klasse „41" entfernt es.
let parts = crate::model3d::parts(&glass, true, 1.0, false).unwrap();
assert!(parts.column_meshes.iter().any(|m| matches!(m.owner, crate::model3d::Owner::Railing(_))));
let f = crate::model3d::ClassFilter::from_text(&glass, r#"{"hide":["41"]}"#);
let hidden = crate::model3d::parts_filtered(&glass, true, 1.0, false, &f).unwrap();
assert!(!hidden.column_meshes.iter().any(|m| matches!(m.owner, crate::model3d::Owner::Railing(_))));
}
#[test]
fn schnitt_durch_gelaender() {
let p = project("bars", json!({}));
let out = crate::plan::section::compute_section(&p, &level(&p, "sc"), &[]).unwrap().unwrap();
// Geschnitten: Handlauf und Fussschiene (Gestänge) mit Herkunft und Klasse; schwarz gefüllt.
let cuts: Vec<_> = out.cuts.iter().filter(|c| c.railing_id.as_deref() == Some("g")).collect();
assert!(cuts.len() >= 2, "{} Bänder", out.cuts.len());
assert!(cuts.iter().all(|c| c.category.as_deref() == Some("41") && c.source_id.as_deref() == Some("g")));
// In der Projektion stehen die Pfosten/Stäbe als Kanten (Schnitt an x = 1.5: Stäbe dahinter bei x > 1.5).
assert!(!out.visible.is_empty());
// Ausgeblendete Klasse: nichts mehr.
let vis = hide41();
let o2 = crate::plan::section::compute_section_vis(&p, &level(&p, "sc"), &[], &vis).unwrap().unwrap();
assert!(!o2.cuts.iter().any(|c| c.railing_id.is_some()));
// Glas: eine dünne Tafel (2 cm) wird quer geschnitten.
let g = project("glass", json!({}));
let og = crate::plan::section::compute_section(&g, &level(&g, "sc"), &[]).unwrap().unwrap();
let panel = og.cuts.iter().find(|c| c.railing_id.is_some() && c.fill.as_deref() == Some("#cfe3ee")).expect("Glasband");
let xs: Vec<f64> = panel.pts.iter().map(|q| q[0]).collect();
assert!((xs.iter().cloned().fold(f64::MIN, f64::max) - xs.iter().cloned().fold(f64::MAX, f64::min) - 0.02).abs() < 1e-3, "{xs:?}");
}
#[test]
fn ansicht_zeigt_gelaender_anwaehlbar() {
for kind in ["bars", "glass", "solid", "perforated"] {
let p = project(kind, json!({}));
let (prims, _) = crate::plan::elevation::elevation_primitives(&p, &level(&p, "ans"), false, false, &crate::plan::section::Visibility::default(), 50.0).unwrap().unwrap();
assert!(picks(&prims) > 0, "{kind}: keine anwählbare Fläche in der Ansicht");
}
// Brüstung: ein gefüllter Streifen über 4 m Länge (x) und 1 m Höhe.
let p = project("solid", json!({"thickness": 0.2}));
let (prims, _) = crate::plan::elevation::elevation_primitives(&p, &level(&p, "ans"), false, false, &crate::plan::section::Visibility::default(), 50.0).unwrap().unwrap();
let w: f64 = prims
.iter()
.filter_map(|q| match q {
Primitive::Polygon { pts, context_object_id: Some(id), .. } if id == "@railing:g" => Some(pts.iter().map(|v| v.x).fold(f64::MIN, f64::max) - pts.iter().map(|v| v.x).fold(f64::MAX, f64::min)),
_ => None,
})
.fold(0.0, f64::max);
assert!((w - 4.0).abs() < 1e-6, "{w}");
// Ausgeblendete Klasse: keine Fläche.
let vis = hide41();
let hidden = crate::plan::elevation::elevation_primitives(&p, &level(&p, "ans"), false, false, &vis, 50.0).unwrap().map(|r| r.0).unwrap_or_default();
assert_eq!(picks(&hidden), 0);
}
#[test]
fn dokument_3d_axo() {
let p = project("glass", json!({}));
let a = crate::plan::axo::AxoArgs::parse(&p, &json!({"view": "southeast", "scale": 100})).unwrap();
let (prims, _) = crate::plan::axo::axo_primitives(&p, &a, false).unwrap().expect("Bild");
assert!(picks(&prims) > 0, "Fläche mit Pick-Id fehlt");
assert!(prims.iter().any(|q| matches!(q, Primitive::Line { cls, .. } if cls == "axo-edge" || cls == "axo-outline")));
}
#[test]
fn ifc_datensatz_ifcrailing() {
let p = project("bars", json!({}));
let f = crate::ifc_data::ifc_export_data(&p, &Default::default()).unwrap();
let strings: Vec<String> = f.strings.iter().cloned().collect();
assert!(strings.iter().any(|s| s == "g") && strings.iter().any(|s| s == "GUARDRAIL") && strings.iter().any(|s| s == "Dossier_Qto_Railing"), "{strings:?}");
assert!(f.nums.contains(&26.0), "Datensatz RAILING");
// Unsinn: kein Datensatz.
let bad = project("bars", json!({"height": 0}));
let f = crate::ifc_data::ifc_export_data(&bad, &Default::default()).unwrap();
assert!(!f.nums.contains(&26.0));
}
#[test]
fn umbau_und_varianten_blenden_aus() {
let mut p = project("glass", json!({"renovation": {"status": "demolish"}}));
// Neubauplan: Abbruch weg; Bestandsplan: Abbruch steht (gestrichelt in Umbau-Farbe im Abbruchplan).
assert_eq!(picks(&plan(&p, json!({"renovation": "neubau"}))), 0);
assert!(picks(&plan(&p, json!({"renovation": "bestand"}))) > 0);
let ab = plan(&p, json!({"renovation": "abbruch"}));
assert!(ab.iter().any(|q| matches!(q, Primitive::Line { cls, dash: Some(Some(_)), .. } if cls == "railing-glass")), "Abbruch gestrichelt");
// 3D und Schnitt folgen dem Filter über das Projekt ohne Ausgeblendetes.
let q = crate::renovation::project_in_state(&p, Some("neubau"), None);
assert!(q.railings.as_deref().unwrap_or(&[]).is_empty());
// Varianten: ein Geländer in Variante B fehlt in A.
p.renovation = None;
p.railings.as_mut().unwrap()[0].renovation = None;
p.railings.as_mut().unwrap()[0].design_option = Some(DesignOptionRef { set: "s".into(), option: "b".into(), ..Default::default() });
p.design_option_sets = Some(vec![serde_json::from_value(json!({"id": "s", "name": "Brüstung", "options": [{"id": "a", "name": "A"}, {"id": "b", "name": "B"}], "primary": "a"})).unwrap()]);
assert_eq!(picks(&plan(&p, json!({}))), 0);
assert!(picks(&plan(&p, json!({"designOptions": "Brüstung=B"}))) > 0);
assert!(crate::design_options::active(&p));
}
#[test]
fn befehl_railing_baut_ops() {
let p = project("bars", json!({}));
let root: serde_json::Map<String, Value> = serde_json::from_value(serde_json::to_value(&p).unwrap()).unwrap();
let req = |v: Value| {
let mut base = json!({"cmd": "railing", "ctx": {"level": "eg", "floorHeight": 3.0, "cat": "20", "wallType": "t"}, "stamp": "s"});
for (k, x) in v.as_object().unwrap() {
base[k] = x.clone();
}
base
};
let add = |ops: Vec<crate::ops::Op>| -> (String, Value) {
match ops.into_iter().next() {
Some(crate::ops::Op::Add { collection, items, .. }) => (collection, items[0].clone()),
other => panic!("erwartet Add, war {other:?}"),
}
};
let (coll, it) = add(crate::cmd_create::ops(&root, &p, &req(json!({"pts": [[0, 0], [2, 0], [2, 2]], "kind": "glass", "height": 1.1, "closed": true, "handrail": false}))).unwrap());
assert_eq!((coll.as_str(), it["type"].as_str(), it["floorId"].as_str(), it["categoryCode"].as_str(), it["kind"].as_str()), ("railings", Some("railing"), Some("eg"), Some("41"), Some("glass")));
assert_eq!((it["height"].as_f64(), it["closed"].as_bool(), it["handrail"].as_bool(), it["points"].as_array().map(|a| a.len())), (Some(1.1), Some(true), Some(false), Some(3)));
// Vorgaben bei Unsinn; ein einzelner Punkt oder doppelte Punkte ergeben nichts.
let (_, it) = add(crate::cmd_create::ops(&root, &p, &req(json!({"pts": [[0, 0], [2, 0]], "kind": "foo", "height": -3}))).unwrap());
assert_eq!((it["kind"].as_str(), it["height"].as_f64()), (Some("bars"), Some(1.0)));
assert!(crate::cmd_create::ops(&root, &p, &req(json!({"pts": [[0, 0], [0, 0]]}))).unwrap().is_empty());
}
#[test]
fn verschieben_und_gruppen() {
let p = project("bars", json!({}));
let root: serde_json::Map<String, Value> = serde_json::from_value(serde_json::to_value(&p).unwrap()).unwrap();
let req: crate::cmd_transform::TransformReq = serde_json::from_value(json!({"sel": {"wallIds": [], "railingIds": ["g"]}, "op": "move", "pts": [[0, 0], [3, 1]], "mode": "move", "count": 1, "stamp": "s"})).unwrap();
let ops = crate::cmd_transform::transform_ops(&root, &p, &req);
let Some(crate::ops::Op::Replace { collection, entity }) = ops.first() else { panic!("erwartet Replace: {ops:?}") };
assert_eq!(collection, "railings");
let pts = entity["points"].as_array().unwrap();
assert_eq!((pts[0]["x"].as_f64(), pts[0]["y"].as_f64(), pts[1]["x"].as_f64()), (Some(3.0), Some(1.0), Some(7.0)));
// Gruppen: die Mitgliedschaft kennt Geländer; Verweisprüfung bemerkt ein fehlendes Mitglied.
let mut q = p.clone();
q.groups = Some(vec![Group { id: "gr".into(), railing_ids: Some(vec!["g".into(), "weg".into()]), ..Default::default() }]);
assert_eq!(crate::groups::transitive_membership(&q, "gr").railing_ids, ["g", "weg"]);
assert!(crate::project_refs::dangling_refs(&q).iter().any(|m| m.contains("weg")));
}
#[test]
fn projektdatei_und_georef() {
// Das Feld ist bekannt: kein Hinweis „unbekanntes Feld".
let p = project("bars", json!({}));
let text = serde_json::to_string(&p).unwrap();
let parsed = crate::project_format::parse_project_file(&text, 0.0);
match parsed {
crate::project_format::Parsed::Ok { warnings, project, .. } => {
assert!(!warnings.iter().any(|w| w.contains("railings")), "{warnings:?}");
assert!(project.contains_key("railings"));
}
crate::project_format::Parsed::Err(e) => panic!("{e}"),
}
}
+4
View File
@@ -471,6 +471,10 @@ impl View {
for x in p.columns.iter().flatten() {
put(&x.id, self.treat(x.renovation.as_ref()), out);
}
// [279] Geländer.
for x in p.railings.iter().flatten() {
put(&x.id, self.treat(x.renovation.as_ref()), out);
}
for x in p.extruded_solids.iter().flatten() {
put(&x.id, self.treat(x.renovation.as_ref()), out);
}
+22
View File
@@ -114,6 +114,8 @@
// TREE = 19 ([149] Baum), structure, id, name, PSETS, MESH (Stamm + Krone, Welt rel. Geschoss-UK)
// IFC4: IfcGeographicElement (ObjectType „Baum", PredefinedType USERDEFINED); IFC2x3 (kennt die
// Klasse nicht): IfcBuildingElementProxy mit ObjectType „Baum". GlobalId aus `tree/<id>`.
// RAILING = 26 ([279] Geländer), structure, id, name, predefined (GUARDRAIL | HANDRAIL | BALUSTRADE), PSETS, MESH (Prismen,
// Welt rel. Geschoss-UK): IfcRailing mit PredefinedType (IFC4 und IFC2x3). GlobalId aus `railing/<id>`.
// CONTEXT = 24 ([259] Kontext, nur mit Option), kind (0 Netz auf Umgebungsklasse, 1 Gelände), id, name, class
// (Klasse als Text, leer = keine), MESH (Modell-Koordinaten, z absolut). Am IfcSite eingegliedert (nicht
// im Geschoss); Gelände: IfcGeographicElement TERRAIN, sonst IfcBuildingElementProxy (ObjectType „Kontext",
@@ -173,6 +175,7 @@ pub const REC_GUIDS: f64 = 23.0;
pub const REC_TREE: f64 = 19.0;
pub const REC_CONTEXT: f64 = 24.0;
pub const REC_LAYERS: f64 = 25.0;
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;
@@ -209,6 +212,7 @@ fn rec_name(code: f64) -> &'static str {
c if c == REC_TREE => "TREE",
c if c == REC_CONTEXT => "CONTEXT",
c if c == REC_LAYERS => "LAYERS",
c if c == REC_RAILING => "RAILING",
c if c == REC_COLUMN_PIECES => "COLUMN_PIECES",
_ => "?",
}
@@ -1071,6 +1075,24 @@ pub fn build_ifc(flat: &[f64], strings: &str) -> Result<String, String> {
w.add_pset(p, entity, &key);
}
}
c if c == REC_RAILING => {
let structure = r.structure(n_storeys)?;
let id = r.string()?;
let name = r.string()?;
let predefined = r.string()?;
let psets = r.psets()?;
let mesh = r.mesh()?;
let (placement, shape) = w.emit_triangulated_product(&mesh, w.placement_of(structure));
let key = format!("railing/{id}");
let g = w.gid(&key);
let kind = if ["GUARDRAIL", "HANDRAIL", "BALUSTRADE"].contains(&predefined.as_str()) { predefined } else { "NOTDEFINED".to_string() };
let entity = w.add("IFCRAILING", format!("{g},#{},{},$,$,#{placement},#{shape},$,{}", w.owner_history, ifc_string(&name), enum_(&kind)));
w.add_to_containment(structure, entity);
w.elements.insert(key.clone(), entity);
for p in &psets {
w.add_pset(p, entity, &key);
}
}
c if c == REC_CONTEXT => {
// [259] Kontext am IfcSite: Gelände als IfcGeographicElement TERRAIN, Nachbarn als Proxy (IFC2x3: beide Proxy).
let terrain = r.idx()? == 1;
+27
View File
@@ -0,0 +1,27 @@
// Geländer ([279]): Kennzahlen aus dem Rust-Kern (`railing.rs::info`) für die Objekt-Info — Länge der Achse, absolute
// Fuss- und Oberkante, Zahl der Stäbe und Pfosten, Ansichtsfläche. Die Teilung rechnet der Kern (eine Quelle für
// 3D, Schnitt, Ansicht, IFC).
import type { Project } from "../model/types";
import { documentFor } from "../core/document";
export interface RailingInfo {
/** Länge der Achse (m). */
length: number;
/** Absolute Fuss- und Oberkante (m). */
baseZ: number;
topZ: number;
height: number;
/** Stäbe und Pfosten (nur Art „Stäbe"). */
bars: number;
posts: number;
/** Ansichtsfläche Länge × Höhe (m²). */
area: number;
closed: boolean;
}
/** Kennzahlen eines Geländers; `null` bei unbekannter Id oder unsinnigen Massen. */
export function railingInfo(project: Project, id: string): RailingInfo | null {
if (!(project.railings ?? []).some((r) => r.id === id)) return null;
return documentFor(project).query<RailingInfo | null>("railingInfo", [], id);
}
+1 -1
View File
@@ -28,7 +28,7 @@ Ribbon-Befehle sie erreichen: `src/state/useToolInput.ts`.
| Gruppe | Module |
|---|---|
| Bauteile | `wall.ts`, `opening.ts`, `ceiling.ts`, `ceilingOpening.ts`, `roof.ts`, `roofHole.ts`, `roofWindow.ts`, `dormer.ts`, `stair.ts`, `column.ts`, `room.ts`, `grid.ts`, `tree.ts`, `terrain.ts`, `excavation.ts` |
| Bauteile | `wall.ts`, `opening.ts`, `ceiling.ts`, `ceilingOpening.ts`, `roof.ts`, `roofHole.ts`, `roofWindow.ts`, `dormer.ts`, `stair.ts`, `column.ts`, `room.ts`, `grid.ts`, `tree.ts`, `railing.ts`, `terrain.ts`, `excavation.ts` |
| Körper | `solid.ts`, `solidbool.ts`, `solidToParts.ts` (Körper → Bauteile, [222]), `voidbox.ts`, `extrude.ts`, `revolve.ts`, `loft.ts` |
| 2D zeichnen | `line.ts`, `xline.ts`, `ray.ts`, `polyline.ts`, `polygon.ts`, `rect.ts`, `circle.ts`, `arc.ts`, `ellipse.ts`, `bezier.ts`, `spline.ts`, `multiline.ts`, `revcloud.ts`, `wipeout.ts`, `block.ts`, `defblock.ts`, `libobj.ts` (Objekt aus der Bibliothek setzen, [253]) |
| Beschriften | `text.ts`, `textbox.ts`, `textpath.ts`, `leader.ts`, `dimension.ts`, `dimround.ts`, `dimdetach.ts`, `autodim.ts`, `kote.ts`, `detailref.ts`, `pointmarker.ts`, `scalebar.ts`, `sectionline.ts` |
+100
View File
@@ -0,0 +1,100 @@
/**
* [279] Befehl „gelaender": Polylinie auf dem aktiven Geschoss, Enter beendet (offen), „Schliessen" und Klick auf den
* Startpunkt schliessen den Zug; Zahl = Höhe, Option = Art; die Ops baut der Kern (Ebene 41, Vorgaben).
*/
import { describe, it, expect, beforeEach } from "vitest";
import { railingCommand, railingDefaults } from "./railing";
import type { CommandContext, Project } from "../types";
function project(): Project {
return {
id: "t",
name: "T",
lineStyles: [],
hatches: [],
components: [],
wallTypes: [],
drawingLevels: [{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 }],
layers: [
{ code: "41", name: "Geländer", color: "#0a0a0a", lw: 0.18, visible: true, locked: false },
{ code: "20", name: "Zeichnung", color: "#0a0a0a", lw: 0.5, visible: true, locked: false },
],
walls: [],
openings: [],
ceilings: [],
stairs: [],
rooms: [],
drawings2d: [],
context: [],
};
}
function makeCtx(p: Project): CommandContext {
return { project: p, level: p.drawingLevels[0], defaultCategoryCode: "20", activeLineStyleId: "solid", activeWallTypeId: "aw", lastPoint: null, selection: { wallIds: [], drawingId: null } };
}
describe("railingCommand (gelaender)", () => {
beforeEach(() => {
Object.assign(railingDefaults, { kind: "bars", height: 1.0 });
});
it("Punkte, Enter: offenes Geländer auf Ebene 41 mit Vorgaben (Höhe 1.00 m, Stäbe)", () => {
const p = project();
const ctx = makeCtx(p);
let st = railingCommand.init();
[st] = railingCommand.onInput(st, { kind: "point", point: { x: 0, y: 0 } }, ctx);
[st] = railingCommand.onInput(st, { kind: "point", point: { x: 3, y: 0 } }, ctx);
[st] = railingCommand.onInput(st, { kind: "point", point: { x: 3, y: 2 } }, ctx);
// Vorschau: Zug samt Gummiband.
const [, mv] = railingCommand.onMove!(st, { x: 5, y: 2 }, null, ctx);
expect(mv.draft?.preview?.length).toBeGreaterThan(0);
const [, r] = railingCommand.onConfirm!(st, ctx);
expect(r.done).toBe(true);
const next = r.commit!(p);
expect(next.railings?.length).toBe(1);
expect(next.railings![0]).toMatchObject({
type: "railing",
floorId: "eg",
categoryCode: "41",
kind: "bars",
height: 1,
points: [{ x: 0, y: 0 }, { x: 3, y: 0 }, { x: 3, y: 2 }],
});
expect(next.railings![0].closed).toBeUndefined();
});
it("Zahl = Höhe, Option wechselt die Art; Schliessen ab drei Punkten, Klick auf den Start schliesst auch", () => {
const p = project();
const ctx = makeCtx(p);
let st = railingCommand.init();
[st] = railingCommand.onInput(st, { kind: "number", value: 1.1 }, ctx);
[st] = railingCommand.onInput(st, { kind: "option", id: "kind" }, ctx);
expect(railingDefaults).toMatchObject({ kind: "glass", height: 1.1 });
for (const q of [{ x: 0, y: 0 }, { x: 2, y: 0 }, { x: 2, y: 2 }]) [st] = railingCommand.onInput(st, { kind: "point", point: q }, ctx);
expect(railingCommand.options(st).map((o) => o.id)).toContain("close");
const [, r] = railingCommand.onInput(st, { kind: "option", id: "close" }, ctx);
expect(r.done).toBe(true);
expect(r.commit!(p).railings![0]).toMatchObject({ kind: "glass", height: 1.1, closed: true });
// Klick nahe am Startpunkt schliesst ebenfalls.
const [, r2] = railingCommand.onInput(st, { kind: "point", point: { x: 0.02, y: 0.01 } }, ctx);
expect(r2.commit!(p).railings![0].closed).toBe(true);
// Unsinn: Höhe 0 oder riesig wird nicht übernommen; ein einzelner Punkt gibt kein Geländer.
[st] = railingCommand.onInput(railingCommand.init(), { kind: "number", value: 0 }, ctx);
[st] = railingCommand.onInput(st, { kind: "number", value: 99 }, ctx);
expect(railingDefaults.height).toBe(1.1);
[st] = railingCommand.onInput(st, { kind: "point", point: { x: 1, y: 1 } }, ctx);
expect(railingCommand.onConfirm!(st, ctx)[1].commit).toBeUndefined();
});
it("Zurück nimmt den letzten Punkt weg; ein Klick auf denselben Punkt zählt nicht", () => {
const ctx = makeCtx(project());
let st = railingCommand.init();
[st] = railingCommand.onInput(st, { kind: "point", point: { x: 0, y: 0 } }, ctx);
[st] = railingCommand.onInput(st, { kind: "point", point: { x: 1, y: 0 } }, ctx);
[st] = railingCommand.onInput(st, { kind: "point", point: { x: 1, y: 0 } }, ctx);
[st] = railingCommand.onInput(st, { kind: "option", id: "undo" }, ctx);
const [, r] = railingCommand.onConfirm!(st, ctx);
expect(r.commit).toBeUndefined();
});
});
+178
View File
@@ -0,0 +1,178 @@
// [279] Geländer als Engine-Befehl (`gelaender`): Polylinie auf dem aktiven Geschoss (Balkon, Galerie, Treppenauge,
// Terrasse), Ablauf wie die Polylinie/Decke:
// 1) „Erster Punkt des Geländers:" → Punkt
// 2) „Nächster Punkt ( Schliessen Zurück Art ):" → Punkt … Enter beendet (offen, ≥ 2 Punkte), „Schliessen" (C) oder
// ein Klick auf den Startpunkt schliesst den Zug (≥ 3 Punkte, Treppenauge/Galerie ringsum).
// Eine getippte Zahl setzt die Höhe (Vorgabe 1.00 m, SIA 358); sie bleibt über Aufrufe. Optionen (Klick wechselt): Art
// Stäbe/Glas/Brüstung/Lochblech. Fusshöhe, Handlauf, Stababstand, Dicke danach in der Objekt-Info.
//
// Die Ops baut der Kern (`cmd_create.rs`, Befehl „railing"): Ebene „41" (Geländer), falls vorhanden, sonst die aktive.
//
// Bezeichner englisch, sichtbarer Text via t().
import type { Command, CommandContext, CommandField, CommandResult, CommandState, CmdOption, DraftShape, ToolDraft, Vec2 } from "../types";
import type { RailingKind } from "../../model/types";
import { createMutation, xy } from "../createCore";
import { t, type TranslationKey } from "../../i18n";
const EPS = 1e-6;
const DEG = Math.PI / 180;
/** Klick so nah am Startpunkt (Modell-Meter) schliesst den Zug. */
const CLOSE_HIT = 0.08;
const KINDS: RailingKind[] = ["bars", "glass", "solid", "perforated"];
/** Vorgaben des Werkzeugs (modulweit, leben über Befehls-Instanzen hinweg). */
export const railingDefaults: { kind: RailingKind; height: number } = { kind: "bars", height: 1.0 };
const next = <T>(list: readonly T[], v: T): T => list[(list.indexOf(v) + 1) % list.length];
const segLen = (a: Vec2, b: Vec2): number => Math.hypot(b.x - a.x, b.y - a.y);
const segAngleDeg = (a: Vec2, b: Vec2): number => (Math.atan2(b.y - a.y, b.x - a.x) * 180) / Math.PI;
/** Tab-Felder je weiteren Punkt: Länge + Winkel relativ zum letzten Punkt. */
const FIELDS: CommandField[] = [
{ id: "length", labelKey: "cmd.field.length" },
{ id: "angle", labelKey: "cmd.field.angle" },
];
/** Nächster Punkt aus gelockten Feldern (length/angle) + Cursor, relativ zu `last`. */
function nextFromFields(last: Vec2, locks: Record<string, number>, cursor: Vec2 | null): Vec2 {
const ref = cursor ?? last;
const length = "length" in locks ? locks.length : segLen(last, ref);
const ang = ("angle" in locks ? locks.angle : segAngleDeg(last, ref)) * DEG;
return { x: last.x + Math.cos(ang) * length, y: last.y + Math.sin(ang) * length };
}
/** Anfrage an den Kern (Werkzeug-Vorgaben). */
export const railingReq = (pts: Vec2[], closed: boolean) => ({
cmd: "railing",
kind: railingDefaults.kind,
height: railingDefaults.height,
closed,
pts: pts.map(xy),
});
const appendRailing = (pts: Vec2[], closed: boolean, ctx: CommandContext) => createMutation(ctx, railingReq(pts, closed));
interface RailIdle extends CommandState {
phase: "start";
}
interface RailDrawing extends CommandState {
phase: "next";
points: Vec2[];
cursor: Vec2 | null;
}
type RailState = RailIdle | RailDrawing;
const CLOSE: CmdOption = { id: "close", labelKey: "cmd.polyline.close" };
const UNDO: CmdOption = { id: "undo", labelKey: "cmd.polyline.undo" };
const idle = (): [CommandState, CommandResult] => [{ phase: "start", lastPoint: null } as RailIdle, { draft: null, done: true }];
/** Vorschau: Zug samt Gummiband, bei geschlossenem Zug der Ring; HUD mit Länge, Winkel und Höhe. */
function railingDraft(points: Vec2[], cursor: Vec2 | null, closed = false): ToolDraft {
const pts = cursor ? [...points, cursor] : points;
const preview: DraftShape[] = [{ kind: "poly", pts, closed }];
const draft: ToolDraft = { preview, vertices: points };
const last = points[points.length - 1];
if (cursor && last && segLen(last, cursor) >= EPS) {
draft.hud = {
at: cursor,
text: `${segLen(last, cursor).toFixed(2)} m · ${((segAngleDeg(last, cursor) + 360) % 360).toFixed(0)}° · h ${railingDefaults.height.toFixed(2)} m`,
};
}
return draft;
}
export const railingCommand: Command = {
name: "gelaender",
labelKey: "cmd.gelaender.label",
// Geländer stehen auf Geschossen — wie die Wand nur dort aktiv.
floorOnly: true,
prompt: (s) => ((s as RailState).phase === "next" ? "cmd.gelaender.next" : "cmd.gelaender.start"),
accepts: (s) => ((s as RailState).phase === "next" ? ["point", "number", "option"] : ["point", "number", "option"]),
options: (s): CmdOption[] => {
const ps = s as RailState;
const kind: CmdOption = { id: "kind", labelKey: "cmd.gelaender.kind", value: t(`objinfo.railing.kind.${railingDefaults.kind}` as TranslationKey) };
if (ps.phase !== "next") return [kind];
return ps.points.length >= 3 ? [CLOSE, UNDO, kind] : [UNDO, kind];
},
init: (): RailIdle => ({ phase: "start", lastPoint: null }),
onInput: (state, input, ctx): [CommandState, CommandResult] => {
const s = state as RailState;
const draft = (closed = false) => (s.phase === "next" ? railingDraft(s.points, s.cursor, closed) : null);
if (input.kind === "number") {
const v = Math.abs(input.value);
if (v >= 0.1 && v <= 5 && Number.isFinite(v)) railingDefaults.height = v;
return [s, { draft: draft() }];
}
if (input.kind === "option") {
if (input.id === "kind") {
railingDefaults.kind = next(KINDS, railingDefaults.kind);
return [s, { draft: draft() }];
}
if (s.phase !== "next") return [s, { draft: null }];
if (input.id === "undo") {
const pts = s.points.slice(0, -1);
if (pts.length === 0) return [{ phase: "start", lastPoint: null } as RailIdle, { draft: null }];
const ns: RailDrawing = { phase: "next", points: pts, cursor: s.cursor, lastPoint: pts[pts.length - 1] };
return [ns, { draft: railingDraft(pts, s.cursor) }];
}
// Schliessen: Treppenauge/Galerie ringsum (≥ 3 Punkte).
if (input.id === "close" && s.points.length >= 3) {
return [{ phase: "start", lastPoint: null } as RailIdle, { draft: null, done: true, commit: appendRailing(s.points, true, ctx) }];
}
return [s, { draft: draft() }];
}
if (input.kind !== "point") return [s, { draft: draft() }];
const pt = input.point;
if (s.phase !== "next") {
const ns: RailDrawing = { phase: "next", points: [pt], cursor: pt, lastPoint: pt };
return [ns, { draft: railingDraft([pt], pt) }];
}
// Klick nahe Startpunkt → Zug schliessen und committen.
if (s.points.length >= 3 && segLen(s.points[0], pt) < CLOSE_HIT) {
return [{ phase: "start", lastPoint: null } as RailIdle, { draft: null, done: true, commit: appendRailing(s.points, true, ctx) }];
}
// Null-Strecke (Klick auf denselben Punkt) ignorieren.
if (segLen(s.points[s.points.length - 1], pt) < EPS) return [s, { draft: draft() }];
const points = [...s.points, pt];
const ns: RailDrawing = { phase: "next", points, cursor: pt, lastPoint: pt };
return [ns, { draft: railingDraft(points, pt) }];
},
onMove: (state, point): [CommandState, CommandResult] => {
const s = state as RailState;
if (s.phase !== "next") return [s, { draft: null }];
const ns: RailDrawing = { ...s, cursor: point };
return [ns, { draft: railingDraft(s.points, point) }];
},
// Enter/Rechtsklick: offenen Zug committen (≥ 2 Punkte).
onConfirm: (state, ctx): [CommandState, CommandResult] => {
const s = state as RailState;
if (s.phase === "next" && s.points.length >= 2) {
return [{ phase: "start", lastPoint: null } as RailIdle, { draft: null, done: true, commit: appendRailing(s.points, false, ctx) }];
}
return idle();
},
onCancel: (): [CommandState, CommandResult] => idle(),
fields: (state) => ((state as RailState).phase === "next" ? FIELDS : []),
pointFromFields: (state, locks, cursor) => {
const s = state as RailState;
if (s.phase !== "next" || s.points.length === 0) return null;
return nextFromFields(s.points[s.points.length - 1], locks, cursor);
},
fieldValues: (state, _locks, cursor): Record<string, number> => {
const s = state as RailState;
if (s.phase !== "next" || s.points.length === 0 || !cursor) return {};
const last = s.points[s.points.length - 1];
return { length: segLen(last, cursor), angle: ((segAngleDeg(last, cursor) % 360) + 360) % 360 };
},
};
+5
View File
@@ -14,6 +14,7 @@ import { openingCommand, fensterCommand, tuerCommand } from "./cmds/opening";
import { stairCommand } from "./cmds/stair";
import { columnCommand } from "./cmds/column";
import { circlesToTreesCommand, treeCommand } from "./cmds/tree";
import { railingCommand } from "./cmds/railing";
import { roofCommand } from "./cmds/roof";
import { solidCommand } from "./cmds/solid";
import { solidBoolCommand } from "./cmds/solidbool";
@@ -94,6 +95,7 @@ export const COMMANDS: Record<string, Command> = {
stair: stairCommand,
column: columnCommand,
tree: treeCommand,
gelaender: railingCommand,
circlestotrees: circlesToTreesCommand,
roof: roofCommand,
solid: solidCommand,
@@ -196,6 +198,9 @@ export const ALIASES: Record<string, string> = {
stuetze: "column",
stütze: "column",
baum: "tree",
geländer: "gelaender",
railing: "gelaender",
gl: "gelaender",
kreiseinbaeume: "circlestotrees",
koerperinbauteile: "solidtoparts",
volumenzubauteilen: "solidtoparts",
+2
View File
@@ -88,6 +88,8 @@ export interface CommandSelection {
openingIds?: string[];
/** [149] Gewählte Bäume (Verschieben/Kopieren/Spiegeln/Drehen: Stammmitte). */
treeIds?: string[];
/** [279] Gewählte Geländer (Verschieben/Kopieren/Spiegeln/Drehen: alle Punkte der Achse). */
railingIds?: string[];
/** [213] Gewählte Kameras (Verschieben/Kopieren/Drehen/Spiegeln: Standpunkt und Ziel). */
cameraIds?: string[];
/** [193] Gewählte Gelände-/Umgebungs-Elemente (`Project.context`: Gelände, Höhenlinien, Baugrube, Netze, Bilder). */
+1
View File
@@ -206,6 +206,7 @@ export type QueryName =
| "materialMaps"
| "slabs"
| "columnMeshes"
| "railingInfo"
| "walls"
| "openingMeshes"
| "stairSlabs"
+1
View File
@@ -161,6 +161,7 @@ export {
type PickContextMesh,
type PickColumnMesh,
type PickTreeMesh,
type PickRailingMesh,
type PickSolidMesh,
type PickOpeningMesh,
type PickStairMesh,
+13 -1
View File
@@ -30,6 +30,7 @@ import type {
Room,
Stair,
Tree,
Railing,
Wall,
} from "../model/types";
import { uniqueStamp } from "../tools/types";
@@ -51,6 +52,8 @@ export interface ElementSelectionIds {
treeIds?: string[];
/** [213] Kameras. */
cameraIds?: string[];
/** [279] Geländer. */
railingIds?: string[];
}
/** Tiefe Kopie der gewählten Elemente über alle Bauteil-Arten hinweg. */
@@ -68,6 +71,8 @@ export interface ElementClipboard {
trees?: Tree[];
/** [213] Kameras (optional: ältere Zwischenablagen haben sie nicht). */
cameras?: Camera[];
/** [279] Geländer (optional). */
railings?: Railing[];
}
const EMPTY_CLIPBOARD: ElementClipboard = {
@@ -95,7 +100,8 @@ export function isClipboardEmpty(c: ElementClipboard): boolean {
c.extrudedSolids.length === 0 &&
c.columns.length === 0 &&
(c.trees?.length ?? 0) === 0 &&
(c.cameras?.length ?? 0) === 0
(c.cameras?.length ?? 0) === 0 &&
(c.railings?.length ?? 0) === 0
);
}
@@ -136,6 +142,8 @@ export function collectElementClipboard(
const columns = (project.columns ?? []).filter((c) => columnIds.has(c.id));
const treeIds = new Set(sel.treeIds ?? []);
const trees = (project.trees ?? []).filter((t) => treeIds.has(t.id));
const railingIds = new Set(sel.railingIds ?? []);
const railings = (project.railings ?? []).filter((r) => railingIds.has(r.id));
const cameraIds = new Set(sel.cameraIds ?? []);
const cameras = (project.cameras ?? []).filter((c) => cameraIds.has(c.id));
@@ -151,6 +159,7 @@ export function collectElementClipboard(
columns: columns.map((c) => structuredClone(c)),
trees: trees.map((t) => structuredClone(t)),
cameras: cameras.map((c) => structuredClone(c)),
railings: railings.map((r) => structuredClone(r)),
};
return isClipboardEmpty(clip) ? null : clip;
}
@@ -168,6 +177,7 @@ export interface PastedIds {
columnIds: string[];
treeIds: string[];
cameraIds: string[];
railingIds: string[];
}
/** Projekt-Liste → Feld in {@link PastedIds}. */
@@ -183,6 +193,7 @@ const PASTED_KEY: Record<string, keyof PastedIds> = {
columns: "columnIds",
trees: "treeIds",
cameras: "cameraIds",
railings: "railingIds",
};
/**
@@ -214,6 +225,7 @@ export function addedIds(ops: readonly CoreOp[]): PastedIds {
columnIds: [],
treeIds: [],
cameraIds: [],
railingIds: [],
};
for (const op of ops) {
const key = op.kind === "add" ? PASTED_KEY[op.collection] : undefined;
+32
View File
@@ -1552,6 +1552,7 @@ export const de = {
"resources.overrides.val.view_kind.elevation": "Ansicht",
"resources.overrides.val.element_kind.stair": "Treppe",
"resources.overrides.val.element_kind.column": "Stütze",
"resources.overrides.val.element_kind.railing": "Geländer",
"resources.overrides.val.element_kind.opening": "Fenster / Tür",
"resources.overrides.val.element_kind.room": "Raum",
"resources.overrides.val.element_kind.shadow": "Schatten",
@@ -2162,6 +2163,35 @@ export const de = {
"cmd.tree.status": "Bestand",
"cmd.tree.foliage": "Laub/Nadel",
"cmd.circlestotrees.label": "Kreise in Bäume umwandeln",
"cmd.gelaender.label": "Geländer",
"cmd.gelaender.start": "Erster Punkt des Geländers (Zahl = Höhe in m):",
"cmd.gelaender.next": "Nächster Punkt (Enter beendet, Zahl = Höhe):",
"cmd.gelaender.kind": "Art",
"objinfo.kind.railing": "Geländer",
"objinfo.railing.many": "{n} Geländer",
"objinfo.railing.section": "Geländer",
"objinfo.railing.kind": "Art",
"objinfo.railing.kind.bars": "Stäbe",
"objinfo.railing.kind.glass": "Glas",
"objinfo.railing.kind.solid": "Brüstung (massiv)",
"objinfo.railing.kind.perforated": "Lochblech",
"objinfo.railing.height": "Höhe",
"objinfo.railing.heightHint": "Vorgabe 1.00 m nach SIA 358 (Absturzhöhe bis 12 m)",
"objinfo.railing.baseOffset": "Fusshöhe über Geschoss",
"objinfo.railing.baseOffsetHint": "z. B. 0.18 m auf einer Balkonplatte",
"objinfo.railing.handrail": "Handlauf",
"objinfo.railing.handrailSize": "Handlauf-Ø",
"objinfo.railing.barSpacing": "Stababstand (Achse)",
"objinfo.railing.barSize": "Stabquerschnitt",
"objinfo.railing.thickness": "Dicke",
"objinfo.railing.component": "Bauteil",
"objinfo.railing.componentNone": "ohne",
"objinfo.railing.closed": "Geschlossen (ringsum)",
"objinfo.railing.length": "Länge",
"objinfo.railing.counts": "Stäbe / Pfosten",
"objinfo.railing.points": "Punkte",
"objinfo.railing.locked": "Gesperrt — Werte nicht änderbar.",
"newProject.layer.41": "Geländer",
"objinfo.kind.tree": "Baum",
"objinfo.tree.many": "{n} Bäume",
"camera.title": "Kameras",
@@ -2275,6 +2305,7 @@ export const de = {
"objinfo.tree.trunkDiameter": "Stamm-Ø",
"objinfo.tree.locked": "Gesperrt — Werte nicht änderbar.",
"pick.kind.tree": "Baum",
"pick.kind.railing": "Geländer",
"cmd.column.label": "Stütze",
"cmd.column.place": "Stütze setzen:",
"cmd.column.profile": "Profil",
@@ -4332,6 +4363,7 @@ export const de = {
"anonymity.area.ceilings": "Decken",
"anonymity.area.roofs": "Dächer",
"anonymity.area.trees": "Bäume",
"anonymity.area.railings": "Geländer",
"anonymity.kind.name": "Projektname",
"anonymity.kind.number": "Projektnummer",
"anonymity.kind.titleBlock": "Büro / Bearbeiter:in",
+32
View File
@@ -1546,6 +1546,7 @@ export const en: Record<TranslationKey, string> = {
"resources.overrides.val.view_kind.elevation": "Elevation",
"resources.overrides.val.element_kind.stair": "Stair",
"resources.overrides.val.element_kind.column": "Column",
"resources.overrides.val.element_kind.railing": "Railing",
"resources.overrides.val.element_kind.opening": "Window / door",
"resources.overrides.val.element_kind.room": "Room",
"resources.overrides.val.element_kind.shadow": "Shadow",
@@ -2150,6 +2151,35 @@ export const en: Record<TranslationKey, string> = {
"cmd.tree.shape": "Shape",
"cmd.tree.status": "Status",
"cmd.tree.foliage": "Foliage",
"cmd.gelaender.label": "Railing",
"cmd.gelaender.start": "First railing point (number = height in m):",
"cmd.gelaender.next": "Next point (Enter finishes, number = height):",
"cmd.gelaender.kind": "Type",
"objinfo.kind.railing": "Railing",
"objinfo.railing.many": "{n} railings",
"objinfo.railing.section": "Railing",
"objinfo.railing.kind": "Type",
"objinfo.railing.kind.bars": "Bars",
"objinfo.railing.kind.glass": "Glass",
"objinfo.railing.kind.solid": "Solid parapet",
"objinfo.railing.kind.perforated": "Perforated sheet",
"objinfo.railing.height": "Height",
"objinfo.railing.heightHint": "Default 1.00 m per SIA 358 (fall height up to 12 m)",
"objinfo.railing.baseOffset": "Base above storey",
"objinfo.railing.baseOffsetHint": "e.g. 0.18 m on a balcony slab",
"objinfo.railing.handrail": "Handrail",
"objinfo.railing.handrailSize": "Handrail Ø",
"objinfo.railing.barSpacing": "Bar spacing (axis)",
"objinfo.railing.barSize": "Bar section",
"objinfo.railing.thickness": "Thickness",
"objinfo.railing.component": "Component",
"objinfo.railing.componentNone": "none",
"objinfo.railing.closed": "Closed (all round)",
"objinfo.railing.length": "Length",
"objinfo.railing.counts": "Bars / posts",
"objinfo.railing.points": "Points",
"objinfo.railing.locked": "Locked — values cannot be changed.",
"newProject.layer.41": "Railings",
"cmd.circlestotrees.label": "Convert circles to trees",
"objinfo.kind.tree": "Tree",
"objinfo.tree.many": "{n} trees",
@@ -2264,6 +2294,7 @@ export const en: Record<TranslationKey, string> = {
"objinfo.tree.trunkDiameter": "Trunk Ø",
"objinfo.tree.locked": "Locked — values cannot be changed.",
"pick.kind.tree": "Tree",
"pick.kind.railing": "Railing",
"cmd.column.label": "Column",
"cmd.column.place": "Place column:",
"cmd.column.profile": "Profile",
@@ -4318,6 +4349,7 @@ export const en: Record<TranslationKey, string> = {
"anonymity.area.ceilings": "Ceilings",
"anonymity.area.roofs": "Roofs",
"anonymity.area.trees": "Trees",
"anonymity.area.railings": "Railings",
"anonymity.kind.name": "project name",
"anonymity.kind.number": "project number",
"anonymity.kind.titleBlock": "office / author",
+2 -1
View File
@@ -8,7 +8,7 @@ import { patchItem, setField } from "../core/opsBuild";
import type { DesignOption, DesignOptionCombination, DesignOptionRef, DesignOptionSet, DrawingLevel, Project } from "./types";
/** Listen, deren Elemente einer Variante angehören können (gleich wie `design_options::COLLECTIONS`). */
export const DESIGN_OPTION_COLLECTIONS = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "drawings2d"] as const;
export const DESIGN_OPTION_COLLECTIONS = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "drawings2d", "railings"] as const;
export type DesignOptionCollection = (typeof DESIGN_OPTION_COLLECTIONS)[number];
/** Kombination: Satz-Id → Varianten-Id. */
@@ -490,6 +490,7 @@ const KIND_COLLECTION: Record<string, DesignOptionCollection> = {
solids: "extrudedSolids",
rooms: "rooms",
drawings: "drawings2d",
railings: "railings",
};
/** Modell-Arten ohne Variante (immer ausserhalb einer Bearbeitungsvariante). */
+3
View File
@@ -20,6 +20,8 @@ export interface GroupMembership {
treeIds: string[];
/** [213] Kameras. */
cameraIds: string[];
/** [279] Geländer. */
railingIds: string[];
}
export type MemberKind = keyof GroupMembership;
@@ -35,6 +37,7 @@ export const EMPTY_MEMBERSHIP: GroupMembership = {
openingIds: [],
treeIds: [],
cameraIds: [],
railingIds: [],
};
/** Letzte transitive Mitgliedschaft (Projekt + Gruppe): Klick-/Rahmen-Filter fragen je Element. */
+2 -1
View File
@@ -16,7 +16,7 @@ export const RENOVATION_STATUSES: readonly RenovationStatus[] = ["existing", "de
* Listen mit Umbau-Status (Räume nur Sichtbarkeit/Flächen, keine Farbe). `drawings2d`: Möbel und Symbole der Bibliothek
* (ohne Angabe = Bestand) sowie 2D-Elemente mit ausdrücklichem Status (Linienwerk, Masse …; Kern `drawing_takes_part`).
*/
export const RENOVATION_COLLECTIONS = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "drawings2d"] as const;
export const RENOVATION_COLLECTIONS = ["walls", "openings", "ceilings", "roofs", "stairs", "columns", "extrudedSolids", "rooms", "drawings2d", "railings"] as const;
export type RenovationCollection = (typeof RENOVATION_COLLECTIONS)[number];
/**
@@ -273,6 +273,7 @@ const SELECTION_KEY: Record<RenovationCollection, string> = {
extrudedSolids: "solids",
rooms: "rooms",
drawings2d: "drawings",
railings: "railings",
};
/**
+2
View File
@@ -409,6 +409,8 @@ export const sampleProject: Project = {
{ code: "30", name: "Decken", color: "#1a1a1a", lw: 0.18, visible: true, locked: false },
{ code: "31", name: "Dächer", color: "#1a1a1a", lw: 0.18, visible: true, locked: false },
{ code: "40", name: "Treppen", color: "#1a1a1a", lw: 0.18, visible: true, locked: false },
// [279] Geländer (Balkon, Galerie, Treppenauge): eigene Klasse, wie jedes Bauteil abschaltbar.
{ code: "41", name: "Geländer", color: "#1a1a1a", lw: 0.18, visible: true, locked: false },
{ code: "35", name: "Träger", color: "#0a0a0a", lw: 0.25, visible: true, locked: false },
{ code: "50", name: "Text", color: "#1a1a1a", lw: 0.13, visible: true, locked: false },
{ code: "60", name: "Räume", color: "#4a4a4a", lw: 0.13, visible: true, locked: false },
+3 -1
View File
@@ -35,7 +35,9 @@ describe("Beispielprojekt Wettbewerb", () => {
expect(p.walls.filter((w) => w.floorId === f && w.isExternal).length).toBe(4);
expect(p.rooms!.filter((r) => r.floorId === f).length).toBe(10);
}
expect(p.ceilings!.length).toBe(3);
// [279] zwei Balkonplatten mit Geländer (Stäbe 1. OG, Glas 2. OG)
expect(p.ceilings!.length).toBe(5);
expect(p.railings!.map((r) => r.kind)).toEqual(["bars", "glass"]);
expect(p.roofs![0].shape).toBe("flach");
expect(p.stairs!.length).toBe(2);
expect(p.rooms!.length).toBe(30);
+13
View File
@@ -149,6 +149,18 @@ const ceilings: NonNullable<Project["ceilings"]> = [
{ 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 },
];
// [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.
const BALCONY = [P(0.6, -HA), P(7.4, -HA), P(7.4, -1.6), P(0.6, -1.6)];
ceilings.push(
{ id: "c-balkon-og1", type: "ceiling", floorId: "eg", categoryCode: "30", outline: BALCONY, wallTypeId: "", ceilingTypeId: "wb-ct-decke", loadBearing: true },
{ id: "c-balkon-og2", type: "ceiling", floorId: "og1", categoryCode: "30", outline: BALCONY, wallTypeId: "", ceilingTypeId: "wb-ct-decke", loadBearing: true },
);
const BALCONY_RAIL = [P(0.7, -HA), P(0.7, -1.5), P(7.3, -1.5), P(7.3, -HA)];
const railings: NonNullable<Project["railings"]> = [
{ id: "gl-balkon-og1", type: "railing", floorId: "og1", categoryCode: "41", points: BALCONY_RAIL, height: 1.0, kind: "bars", handrail: true },
{ id: "gl-balkon-og2", type: "railing", floorId: "og2", categoryCode: "41", points: BALCONY_RAIL, height: 1.0, kind: "glass", handrail: true },
];
const stairs: NonNullable<Project["stairs"]> = ["eg", "og1"].map((f) => ({
id: `tr-${f}`, type: "stair" as const, floorId: f, categoryCode: "40", shape: "straight" as const, typeId: "wb-tr-beton", start: P(10, 1.4), dir: P(0, 1), runLength: 4.3, width: 1.1, totalRise: FH, stepCount: 17,
}));
@@ -293,6 +305,7 @@ export function buildWettbewerbSampleProject(): Project {
ceilings,
roofs,
stairs,
railings,
rooms: [],
units: units(),
drawings2d: cadastre(),
+61
View File
@@ -1763,6 +1763,8 @@ export type Group = {
treeIds?: Array<string>;
/** [213] Kameras (fehlt in älteren Dateien). */
cameraIds?: Array<string>;
/** [279] Geländer (fehlt in älteren Dateien). */
railingIds?: Array<string>;
/** Verschachtelte Gruppen (diese Gruppe enthält andere Gruppen als Ganzes). */
groupIds: Array<string>;
};
@@ -3252,6 +3254,10 @@ export type Project = {
* bestehende Projekte ohne `trees` gültig bleiben (Default: leer behandeln).
*/
trees?: Array<Tree>;
/**
* Geländer ([279]) — eigenes Bauteil (Balkon, Galerie, Treppenauge), siehe {@link Railing}. Optional.
*/
railings?: Array<Railing>;
/**
* Kameras ([213]) — gespeicherte Standpunkte für 3D-Ansicht und Rendering, siehe {@link Camera}. Optional
* (Default: leer behandeln).
@@ -3427,6 +3433,61 @@ export type PublishSet = {
pdfLayers?: boolean;
};
/**
* Ein Geländer ([279]) — eigenes Bauteil für Balkon, Galerie, Treppenauge und Terrasse (Absturzsicherung,
* Vorgabe 1.00 m nach SIA 358): Polylinie `points` auf einem Geschoss, Höhe, Art der Füllung, Handlauf. Grundriss
* (Linie bzw. Doppellinie je Art), Schnitt/Ansicht (Stäbe, Glasfläche, Brüstung), 3D, IFC (`IfcRailing`).
* Fusshöhe = Geschoss-UK + `baseOffset` (z. B. auf einer Balkonplatte).
*/
export type Railing = {
id: string;
type: "railing";
/** Zugehörige Zeichnungsebene (Geschoss). */
floorId: string;
/** Grafik-Kategorie (Ebene), Vorgabe "55" (Geländer). */
categoryCode: string;
/** IFC-GlobalId des Quell-Bauteils (IFC-Import/Rundreise). */
ifcGlobalId?: string;
/** Objekt-Sperre, analog `Wall.locked`. */
locked?: boolean;
/** Achse des Geländers (Polylinie im Grundriss, Meter, mindestens 2 Punkte). */
points: Array<Vec2>;
/** Geschlossener Zug (Treppenauge, Galerie ringsum); fehlt = offen. */
closed?: boolean;
/** Höhe über dem Fuss bis Oberkante Handlauf bzw. Füllung (m, Vorgabe 1.00 nach SIA 358). */
height: number;
/** Fusshöhe relativ zur Geschoss-UK (m, Vorgabe 0), z. B. 0.18 auf einer Balkonplatte. */
baseOffset?: number;
/** Art der Füllung. */
kind: RailingKind;
/** Stäbe: Achsabstand der Stäbe (m, Vorgabe 0.12; lichtes Mass bleibt unter 12 cm). */
barSpacing?: number;
/** Stäbe: Querschnitt (Kantenlänge bzw. Durchmesser, m, Vorgabe 0.014). */
barSize?: number;
/**
* Dicke der Füllung (m): Glas (Vorgabe 0.02), Brüstung (Vorgabe 0.15), Lochblech (Vorgabe 0.004); bei Stäben ohne Wirkung.
*/
thickness?: number;
/** Handlauf auf der Oberkante; fehlt = bei Stäben und Glas ja, sonst nein. */
handrail?: boolean;
/** Handlauf: Durchmesser (m, Vorgabe 0.04). */
handrailSize?: number;
/** Optionales Bauteil (Component) für Füllung/Farbe, v. a. der massiven Brüstung. */
componentId?: string;
/** Optionale Übersteuerung der Strichfarbe; sonst gilt die Kategorie-Farbe. */
color?: string;
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
renovation?: Renovation;
/** [272] Variante, zu der das Element gehört. Fehlt ⇒ Hauptmodell (immer sichtbar). */
designOption?: DesignOptionRef;
};
/**
* Art der Füllung eines Geländers ([279]): Stäbe (Rundstahl/Flachstahl, lotrecht), Glas (Ganzglas-Brüstung),
* massive Brüstung (Mauer/Beton) oder Lochblech.
*/
export type RailingKind = "bars" | "glass" | "solid" | "perforated";
/**
* Referenzlinien-Regel: setzt die `referenceLine`-Eigenschaft bei passenden
* Wänden einheitlich (Vectorworks-Stil).
+4
View File
@@ -31,6 +31,7 @@ import { ContextObjectProps } from "./ContextObjectProps";
import { SunStudySection } from "./SunStudySection";
import { SiteRulesSection } from "./SiteRulesSection";
import { TreeSection } from "./objectInfo/TreeSection";
import { RailingSection } from "./objectInfo/RailingSection";
import { CameraSection } from "./objectInfo/CameraSection";
import { ViewShadowsInfo, MeasurementSection } from "./objectInfo/InfoBlocks";
import { DimensionField, RotateField } from "./objectInfo/fields";
@@ -85,6 +86,7 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
// [137] Lage-Darstellung angeklickt (Schattenfläche / Baurechtslinie): Einstellungen der Quelle.
const site = useStore((s) => s.selection.site);
const treeSel = useStore((s) => s.selection.trees);
const railingSel = useStore((s) => s.selection.railings);
const cameraSel = useStore((s) => s.selection.cameras);
const ctxObj = sel?.kind === "contextObject" ? (storeProject.context ?? []).find((o) => o.id === sel.id) : undefined;
const quantities = useMemo(
@@ -95,6 +97,8 @@ export function ObjectInfoPanel({ showPlacement = true }: { showPlacement?: bool
// ── Leerzustand ───────────────────────────────────────────────────────────
// [149] Baum gewählt: eigene Felder (Lage, Masse, Form, Bestand).
if (sel === null && treeSel.length > 0) return <TreeSection ids={treeSel} />;
// [279] Geländer gewählt: Art, Höhe, Fusshöhe, Handlauf, Stäbe/Dicke.
if (sel === null && railingSel.length > 0) return <RailingSection ids={railingSel} />;
// [213] Kamera gewählt: Standpunkt, Ziel, Bildwinkel, Projektion, Sonne und „Kamera öffnen".
if (sel === null && cameraSel.length > 0) return <CameraSection ids={cameraSel} />;
if (sel === null && site[0] === "viewShadows") return <ViewShadowsInfo />;
+1 -1
View File
@@ -379,7 +379,7 @@ const TOOLS_2D: ToolId[] = [
"image",
];
const TOOLS_3D: ToolId[] = ["wall", "ceiling", "window", "door", "stair", "room"];
const COMMANDS_3D = ["column", "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", "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";
+103
View File
@@ -0,0 +1,103 @@
// Abschnitt „Geländer" der Objekt-Info ([279]): Art (Stäbe, Glas, Brüstung, Lochblech), Höhe (Vorgabe 1.00 m nach
// SIA 358), Fusshöhe über dem Geschoss (z. B. auf einer Balkonplatte), Handlauf, Stababstand/-querschnitt, Dicke und
// Bauteil der Brüstung. Kennzahlen (Länge, Stäbe, Pfosten) rechnet der Kern (`analysis/railingInfo.ts`). Jede Änderung
// ist ein Undo-Schritt (der Kern prüft die Op); bei mehreren gewählten Geländern wirken die Felder auf alle.
//
// Gerufen von `ObjectInfoPanel`.
import { useMemo } from "react";
import type { Railing, RailingKind } from "../../model/types";
import { useStore } from "../../state/appStore";
import { t, type TranslationKey } from "../../i18n";
import { patchItem } from "../../core";
import { Dropdown } from "../../ui/Dropdown";
import { railingInfo } from "../../analysis/railingInfo";
import { DimensionField } from "./fields";
const KINDS: RailingKind[] = ["bars", "glass", "solid", "perforated"];
/** Vorgabe des Handlaufs je Art, wenn nichts angegeben ist (Kern `railing::has_handrail`). */
const handrailDefault = (kind: RailingKind): boolean => kind === "bars" || kind === "glass";
export function RailingSection({ ids }: { ids: readonly string[] }) {
const project = useStore((st) => st.project);
const applyChange = useStore((s) => s.applyChange);
const list = (project.railings ?? []).filter((x) => ids.includes(x.id));
const rail = list[0];
const info = useMemo(() => (rail ? railingInfo(project, rail.id) : null), [project, rail]);
if (!rail) return <div className="objinfo-panel"><div className="objinfo-empty">{t("objinfo.empty")}</div></div>;
const locked = !!rail.locked;
const set = (patch: Partial<Railing>, all = false) =>
applyChange((p) => (all ? list : [rail]).filter((x) => !x.locked).flatMap((x) => patchItem(p, "railings", x.id, patch)));
const level = project.drawingLevels.find((l) => l.id === rail.floorId);
const handrail = rail.handrail ?? handrailDefault(rail.kind);
const bars = rail.kind === "bars";
const panel = rail.kind === "glass" || rail.kind === "solid" || rail.kind === "perforated";
const dflt = rail.kind === "glass" ? 0.02 : rail.kind === "solid" ? 0.15 : 0.004;
return (
<div className="objinfo-panel objinfo-railing">
<div className="objinfo-head">
<span className="objinfo-kind">{list.length > 1 ? t("objinfo.railing.many", { n: list.length }) : t("objinfo.kind.railing")}</span>
</div>
<div className="objinfo-section-label">{t("objinfo.railing.section")}</div>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.kind")}</span>
<Dropdown
value={rail.kind}
onChange={(v) => set({ kind: v as RailingKind }, true)}
options={KINDS.map((v) => ({ value: v, label: t(`objinfo.railing.kind.${v}` as TranslationKey) }))}
title={t("objinfo.railing.kind")}
width={150}
/>
</div>
<div title={t("objinfo.railing.heightHint")}>
<DimensionField label={t("objinfo.railing.height")} value={rail.height} min={0.1} onCommit={(v) => set({ height: v }, true)} />
</div>
<div title={t("objinfo.railing.baseOffsetHint")}>
<DimensionField label={t("objinfo.railing.baseOffset")} value={rail.baseOffset ?? 0} min={-Infinity} onCommit={(v) => set({ baseOffset: v === 0 ? undefined : v }, true)} />
</div>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.handrail")}</span>
<input type="checkbox" checked={handrail} disabled={locked} onChange={(e) => set({ handrail: e.target.checked }, true)} data-testid="railing-handrail" />
</div>
{handrail && <DimensionField label={t("objinfo.railing.handrailSize")} value={rail.handrailSize ?? 0.04} min={0.02} onCommit={(v) => set({ handrailSize: v })} />}
{bars && <DimensionField label={t("objinfo.railing.barSpacing")} value={rail.barSpacing ?? 0.12} min={0.03} onCommit={(v) => set({ barSpacing: v })} />}
{bars && <DimensionField label={t("objinfo.railing.barSize")} value={rail.barSize ?? 0.014} min={0.004} onCommit={(v) => set({ barSize: v })} />}
{panel && <DimensionField label={t("objinfo.railing.thickness")} value={rail.thickness ?? dflt} min={0.002} onCommit={(v) => set({ thickness: v })} />}
{rail.kind === "solid" && (
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.component")}</span>
<Dropdown
value={rail.componentId ?? ""}
onChange={(v) => set({ componentId: v || undefined })}
options={[{ value: "", label: t("objinfo.railing.componentNone") }, ...project.components.map((c) => ({ value: c.id, label: c.name }))]}
title={t("objinfo.railing.component")}
width={150}
/>
</div>
)}
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.closed")}</span>
<input type="checkbox" checked={rail.closed === true} disabled={locked || rail.points.length < 3} onChange={(e) => set({ closed: e.target.checked || undefined })} data-testid="railing-closed" />
</div>
{info && (
<>
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.length")}</span>
<span className="objinfo-fval" data-testid="railing-length">{info.length.toFixed(2)} m</span>
</div>
{bars && (
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.railing.counts")}</span>
<span className="objinfo-fval">{info.bars} / {info.posts}</span>
</div>
)}
</>
)}
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.column.floor")}</span>
<span className="objinfo-fval">{level?.name ?? rail.floorId}</span>
</div>
{locked && <div className="objinfo-muted">{t("objinfo.railing.locked")}</div>}
</div>
);
}
@@ -18,7 +18,7 @@ const AREA_TITLE = { object: "objsettings.area.object", appearance: "objsettings
export function ObjectSettingsPanel() {
const host = usePanelHost();
const sel = useSelectionInfo();
const otherSelected = useStore((s) => s.selection.trees.length + s.selection.cameras.length + s.selection.site.length > 0);
const otherSelected = useStore((s) => s.selection.trees.length + s.selection.railings.length + s.selection.cameras.length + s.selection.site.length > 0);
const isGrid = useStore((s) => (sel?.kind === "drawing2d" ? s.project.drawings2d.find((d) => d.id === sel.id)?.geom.shape === "grid" : false));
const wanted = useSyncExternalStore(subscribeSettingsArea, getSettingsArea, getSettingsArea);
+2 -1
View File
@@ -8,7 +8,7 @@ import { flattenCategories } from "../model/types";
/** Art eines auswählbaren Objekts an einer Klickstelle (Reihenfolge = Standard-Priorität). */
export type PickKind =
| "section" | "opening" | "wall" | "column" | "drawing" | "solid"
| "tree" | "camera" | "ceiling" | "stair" | "room" | "roof" | "site" | "context";
| "tree" | "railing" | "camera" | "ceiling" | "stair" | "room" | "roof" | "site" | "context";
type WithCategory = { id: string; categoryCode?: string };
@@ -26,6 +26,7 @@ function collection(project: Project, kind: PickKind): readonly WithCategory[] {
case "context": return p.context ?? [];
case "solid": return p.extrudedSolids ?? [];
case "tree": return p.trees ?? [];
case "railing": return p.railings ?? [];
case "camera": return p.cameras ?? [];
case "section":
case "site": return [];
+6
View File
@@ -110,6 +110,12 @@ export interface PickTreeMesh {
treeId: string;
}
/** [279] Geländer für den Raycast: WORLD-Dreiecke aller Teile (x, Höhe, y). */
export interface PickRailingMesh {
tris: ReadonlyArray<readonly [Vec3, Vec3, Vec3]>;
railingId: string;
}
/**
* [137] Freier Körper (`extrudedSolids`, Loft/Rotation/Abzug/B-Rep) für den Raycast: WORLD-Dreiecke
* (x, Höhe, y) des Kern-Netzes ([115], dasselbe wie im 3D-Bild; ohne Netz das Prisma über dem Umriss).
+6 -2
View File
@@ -46,7 +46,7 @@ import { collectVisibleCodes, flattenCategories } from "../model/types";
import type { DetailLevel } from "../model/viewTypes";
import { documentFor } from "../core/document";
import { coreEpoch } from "../engine/coreWasm";
import type { PickOpening, PickRoof, PickStair, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickDrawingSeg, PickStairMesh, PickDrawingMesh, PickTreeMesh } from "./pickTypes";
import type { PickOpening, PickRoof, PickStair, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickDrawingSeg, PickStairMesh, PickDrawingMesh, PickTreeMesh, PickRailingMesh } from "./pickTypes";
import {
type RMesh,
type RModel3d,
@@ -506,6 +506,8 @@ export function pickGeometry(
drawingMeshes: PickDrawingMesh[];
/** [149] Bäume (Stamm + Krone). */
trees: PickTreeMesh[];
/** [279] Geländer (alle Teile). */
railings: PickRailingMesh[];
} {
// [137]/[115] Freie Körper als Dreiecke ihres Kern-Netzes (dasselbe wie im Bild, mit der Explosion angehoben).
return documentFor(project).query("pickGeometry", [explodeGap(explode)], classFilterText(hide)) as ReturnType<typeof pickGeometry>;
@@ -555,8 +557,10 @@ export function selectionHighlightLines(
solidIds: string[] = [],
/** [149] Bäume (Kronen-Zylinder vom Fuss bis zur Spitze). */
treeIds: string[] = [],
/** [279] Geländer (Umriss der Achse, Fuss bis Oberkante). */
railingIds: string[] = [],
): Float32Array {
const sel = { walls: wallIds, ceilings: ceilingIds, openings: openingIds, stairs: stairIds, roofs: roofIds, context: contextObjectIds, columns: columnIds, solids: solidIds, trees: treeIds };
const sel = { walls: wallIds, ceilings: ceilingIds, openings: openingIds, stairs: stairIds, roofs: roofIds, context: contextObjectIds, columns: columnIds, solids: solidIds, trees: treeIds, railings: railingIds };
if (Object.values(sel).every((l) => l.length === 0)) return new Float32Array(0);
// Gerechnet im Kern (`highlight3d.rs`); Antwort f32-LE.
const b = documentFor(project).queryBin("selectionHighlight", [], JSON.stringify({ ...sel, rgb, explode: explodeGap(explode) }));
+1
View File
@@ -36,6 +36,7 @@ const EMPTY_MEM = {
openingIds: [] as string[],
treeIds: [] as string[],
cameraIds: [] as string[],
railingIds: [] as string[],
};
function project(groups: Group[]): Project {
+11
View File
@@ -28,6 +28,7 @@ const KEYS: MemberKind[] = [
"openingIds",
"treeIds",
"cameraIds",
"railingIds",
];
/** Vereinigung je Art (erste Vorkommen in Reihenfolge) — für Auswahl-Mengen in der Hülle. */
@@ -46,6 +47,7 @@ const PICK3D_KIND: Partial<Record<string, MemberKind>> = {
roof: "roofIds",
column: "columnIds",
tree: "treeIds",
railing: "railingIds",
};
/**
@@ -61,6 +63,7 @@ export function pick3dGroup(project: Project, kind: string, id: string, groupPat
/** [149] Präfix der Baum-Pick-Id im Feld `contextObjectId` (Kern `tree::TREE_PICK_PREFIX`). */
const TREE_PICK = "@tree:";
const RAILING_PICK = "@railing:";
/** [213] Präfix der Kamera-Pick-Id im Feld `contextObjectId` (Kern `plan/cameras.rs`). */
const CAMERA_PICK = "@camera:";
@@ -104,6 +107,7 @@ export function applyGroupDimming(
openingIds: new Set(mem.openingIds),
treeIds: new Set(mem.treeIds),
cameraIds: new Set(mem.cameraIds),
railingIds: new Set(mem.railingIds),
};
return primitives.map((p) => {
const rec = p as unknown as Record<string, unknown>;
@@ -121,6 +125,11 @@ export function applyGroupDimming(
hasId = true;
if (sets.treeIds.has(ctx.slice(TREE_PICK.length))) inside = true;
}
// [279] Geländer: `contextObjectId = "@railing:<id>"`.
if (typeof ctx === "string" && ctx.startsWith(RAILING_PICK)) {
hasId = true;
if (sets.railingIds.has(ctx.slice(RAILING_PICK.length))) inside = true;
}
// [213] Kameras: `contextObjectId = "@camera:<id>"`.
if (typeof ctx === "string" && ctx.startsWith(CAMERA_PICK)) {
hasId = true;
@@ -179,6 +188,7 @@ export function groupSelection(
openingIds: sel.openingIds,
...(sel.treeIds.length ? { treeIds: sel.treeIds } : {}),
...(sel.cameraIds.length ? { cameraIds: sel.cameraIds } : {}),
...(sel.railingIds.length ? { railingIds: sel.railingIds } : {}),
groupIds: [...selectedGroupIds],
};
return { ops: addItems("groups", [g]), groupId: id };
@@ -210,6 +220,7 @@ export function ungroup(
openingIds: g.openingIds,
treeIds: g.treeIds ?? [],
cameraIds: g.cameraIds ?? [],
railingIds: g.railingIds ?? [],
},
subGroupIds: g.groupIds,
};
+1 -1
View File
@@ -34,7 +34,7 @@ export interface SelectionAppearance {
/** Zahl der gewählten Elemente (ohne Gruppen, Schnittlinien, Lage-Darstellung, Bäume). */
export function selectedCount(sel: Selection): number {
return ELEMENT_KINDS.filter((k) => k !== "sectionLines" && k !== "site" && k !== "trees" && k !== "cameras").reduce((n, k) => n + sel[k].length, 0);
return ELEMENT_KINDS.filter((k) => k !== "sectionLines" && k !== "site" && k !== "trees" && k !== "railings" && k !== "cameras").reduce((n, k) => n + sel[k].length, 0);
}
/** Effektive Strichstärke und Farbe über die gewählten Wände/Decken/2D-Elemente. */
+4
View File
@@ -38,6 +38,8 @@ export function isLocked(project: Project, kind: MemberKind, id: string): boolea
return !!(project.trees ?? []).find((t) => t.id === id)?.locked;
case "cameraIds":
return !!(project.cameras ?? []).find((c) => c.id === id)?.locked;
case "railingIds":
return !!(project.railings ?? []).find((c) => c.id === id)?.locked;
}
}
@@ -64,6 +66,8 @@ export function lockOps(project: Project, kind: MemberKind, id: string, locked:
return patchItem(project, "trees", id, { locked });
case "cameraIds":
return patchItem(project, "cameras", id, { locked });
case "railingIds":
return patchItem(project, "railings", id, { locked });
}
}
+1 -1
View File
@@ -26,7 +26,7 @@ export function openObjectSettings(deps: ObjectSettingsDeps, group?: InfoGroupId
const sel = selectionInfoFor(project, selection);
let target = objectSettingsTarget(sel, deps.activeTool, isGridDrawing(sel?.kind === "drawing2d" ? sel.id : undefined));
// Baum, Lage-Darstellung und Schnittlinie sind keine `SelectionInfo`, haben aber ihre Felder in der Objekt-Info.
if (!target && (selection.trees.length > 0 || selection.cameras.length > 0 || selection.site.length > 0 || selection.sectionLines.length > 0)) {
if (!target && (selection.trees.length > 0 || selection.railings.length > 0 || selection.cameras.length > 0 || selection.site.length > 0 || selection.sectionLines.length > 0)) {
target = { group: selection.sectionLines.length > 0 ? "sectionLine" : null };
}
if (!target) return false;
+26
View File
@@ -0,0 +1,26 @@
import { describe, expect, it } from "vitest";
import type { Railing } from "../model/types";
import { railingGripPatch, railingGripPoints } from "./railingGrips";
const base = {
id: "g",
type: "railing",
floorId: "eg",
categoryCode: "41",
points: [{ x: 0, y: 0 }, { x: 3, y: 0 }, { x: 3, y: 2 }],
height: 1,
kind: "bars",
} as unknown as Railing;
describe("[279] Geländer-Griffe", () => {
it("ein Griff je Achsenpunkt", () => {
expect(railingGripPoints(base)).toEqual([{ x: 0, y: 0 }, { x: 3, y: 0 }, { x: 3, y: 2 }]);
});
it("Ziehen ersetzt genau diesen Punkt; Unsinn ändert nichts", () => {
expect(railingGripPatch(base, 1, { x: 4, y: 1 })).toEqual({ points: [{ x: 0, y: 0 }, { x: 4, y: 1 }, { x: 3, y: 2 }] });
expect(railingGripPatch(base, 5, { x: 4, y: 1 })).toEqual({});
expect(railingGripPatch(base, -1, { x: 4, y: 1 })).toEqual({});
expect(railingGripPatch(base, 0, { x: NaN, y: 1 })).toEqual({});
});
});
+17
View File
@@ -0,0 +1,17 @@
// [279] Griffe eines Geländers im Grundriss: jeder Punkt der Achse (verschieben). Die Punkte folgen dem Modell
// (`Railing.points`); ein Ziehen ersetzt genau diesen Punkt, Höhe, Art und Teilung bleiben.
//
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
import type { Railing, Vec2 } from "../model/types";
/** Griff-Punkte: alle Punkte der Achse in Reihenfolge. */
export function railingGripPoints(r: Railing): Vec2[] {
return r.points.map((p) => ({ x: p.x, y: p.y }));
}
/** Änderung beim Ziehen des Griffs `index` an `pt`; unbekannter Index ändert nichts. */
export function railingGripPatch(r: Railing, index: number, pt: Vec2): Partial<Railing> {
if (!Number.isFinite(pt.x) || !Number.isFinite(pt.y) || index < 0 || index >= r.points.length) return {};
return { points: r.points.map((p, i) => (i === index ? { x: pt.x, y: pt.y } : p)) };
}
+1 -1
View File
@@ -26,7 +26,7 @@ export function renovationFilterLabel(id: string, own: readonly { id: string; na
/** Ids der Auswahl, die einen Umbau-Status tragen (Wände, Öffnungen, Decken, Dächer, Treppen, Stützen, Körper, Räume, 2D-Elemente, Bäume). */
export function selectionRenovationIds(sel: Selection): string[] {
return [...sel.walls, ...sel.openings, ...sel.ceilings, ...sel.roofs, ...sel.stairs, ...sel.columns, ...sel.solids, ...sel.rooms, ...sel.drawings, ...sel.trees];
return [...sel.walls, ...sel.openings, ...sel.ceilings, ...sel.roofs, ...sel.stairs, ...sel.columns, ...sel.solids, ...sel.rooms, ...sel.drawings, ...sel.trees, ...sel.railings];
}
const NO_PHASES: readonly RenovationPhase[] = [];
+1
View File
@@ -86,6 +86,7 @@ describe("Selection", () => {
roomIds: [],
openingIds: [],
treeIds: [],
railingIds: [],
cameraIds: [],
contextIds: [],
});
+9
View File
@@ -41,6 +41,8 @@ export interface Selection {
trees: string[];
/** [213] Kameras (`Project.cameras`). */
cameras: string[];
/** [279] Geländer (`Project.railings`). */
railings: string[];
/**
* Gewählte Gruppen — rein informativ (Bounding-Box, Doppelklick-Ziel); die
* Mitglieder stehen zusätzlich in den übrigen Arten (s. `groupActions.ts`).
@@ -66,6 +68,7 @@ export const SELECTION_KINDS: readonly SelectionKind[] = [
"site",
"trees",
"cameras",
"railings",
"groups",
];
@@ -145,6 +148,7 @@ export function toCommandSelection(sel: Selection): CommandSelection {
roomIds: sel.rooms,
openingIds: sel.openings,
treeIds: sel.trees,
railingIds: sel.railings,
cameraIds: sel.cameras,
contextIds: sel.contextObjects,
};
@@ -168,6 +172,7 @@ export function hasTransformable(sel: Selection): boolean {
sel.rooms.length > 0 ||
sel.openings.length > 0 ||
sel.trees.length > 0 ||
sel.railings.length > 0 ||
sel.cameras.length > 0 ||
sel.contextObjects.length > 0
);
@@ -191,6 +196,8 @@ export interface SelectionIdLists {
treeIds?: string[];
/** [213] Kameras (gruppierbar wie Bäume). */
cameraIds?: string[];
/** [279] Geländer (gruppierbar). */
railingIds?: string[];
}
const ID_LIST_KEYS: [SelectionKind, keyof SelectionIdLists][] = [
@@ -208,6 +215,7 @@ const ID_LIST_KEYS: [SelectionKind, keyof SelectionIdLists][] = [
["groups", "groupIds"],
["trees", "treeIds"],
["cameras", "cameraIds"],
["railings", "railingIds"],
];
/** Auswahl → `…Ids`-Listen (passt strukturell auf `GroupMembership` und `BcfSelection`). */
@@ -240,5 +248,6 @@ export function toMembership(sel: Selection): GroupMembership {
openingIds: sel.openings,
treeIds: sel.trees,
cameraIds: sel.cameras,
railingIds: sel.railings,
};
}
+1 -1
View File
@@ -73,5 +73,5 @@ export function hideSelectionIn3d(): void {
const ids = selectionIds3d(st.selection);
if (!ids.length) return;
setView3dFilter(hideSelection3d(getView3dFilter(), ids));
st.setSelection(clearKinds("walls", "ceilings", "openings", "stairs", "solids", "columns", "roofs", "contextObjects", "trees", "cameras", "drawings", "groups"));
st.setSelection(clearKinds("walls", "ceilings", "openings", "stairs", "solids", "columns", "roofs", "contextObjects", "trees", "railings", "cameras", "drawings", "groups"));
}
+18 -1
View File
@@ -51,6 +51,7 @@ import { getPlanViewport, subscribePlanViewport } from "./planViewport";
import { growRect, meshGripIndices } from "../core";
import { patchItem, verticalExtents } from "../core";
import { treeGripPatch, treeGripPoints } from "./treeGrips";
import { railingGripPatch, railingGripPoints } from "./railingGrips";
import { cameraGripPoints } from "../core";
import type { Selection } from "./selection";
@@ -213,6 +214,9 @@ export function useGripEditing(opts: {
);
const selectedTreeId = single(selection, "trees");
const selectedTree = selectedTreeId ? (project.trees ?? []).find((x) => x.id === selectedTreeId) : undefined;
// [279] Geländer: Griffe an allen Achsenpunkten (nur auf dem Geschoss des Geländers).
const selectedRailingId = single(selection, "railings");
const selectedRailing = selectedRailingId ? (project.railings ?? []).find((x) => x.id === selectedRailingId && x.floorId === levelId) : undefined;
// [213] Kamera: Griffe an Standpunkt, Ziel und Sichtkegel-Rand (Bildwinkel); nur auf dem Geschoss der Kamera.
const selectedCameraId = single(selection, "cameras");
const selectedCamera = selectedCameraId ? (project.cameras ?? []).find((x) => x.id === selectedCameraId && x.floorId === levelId) : undefined;
@@ -278,7 +282,7 @@ export function useGripEditing(opts: {
// [26] Dach-Griffe: nur bei einzeln gewähltem, nicht gesperrtem Dach und ohne andere Griff-Träger in der Auswahl.
const roofGripsOn =
modelEditable && !!selectedRoof && !selectedRoof.locked && !!opts.moveRoofVertex && !selectedCeiling && !selectedRoom &&
!selectedExcavation && !selectedTree && !selectedSectionLine && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0;
!selectedExcavation && !selectedTree && !selectedRailing && !selectedSectionLine && effectiveDrawingIds.length === 0 && selectedWallIds.length === 0;
/** Ringe des Dachs in der Reihenfolge des flachen Index (Umriss, dann Höfe) samt Start-Index. */
const roofRings = (r: Roof): { pts: Vec2[]; off: number; bulge?: number[] }[] => {
let off = 0;
@@ -522,6 +526,11 @@ export function useGripEditing(opts: {
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
return pts;
}
if (selectedRailing && modelEditable && !selectedRailing.locked) {
const pts = railingGripPoints(selectedRailing);
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
return pts;
}
if (selectedTree && modelEditable && !selectedTree.locked) {
const pts = treeGrips(selectedTree);
pts.forEach((_, i) => { gripOwners.push({ localIndex: i }); gripOwnerRange.push([0, pts.length - 1]); });
@@ -1261,6 +1270,14 @@ export function useGripEditing(opts: {
if (!selectedCamera.locked) storeState().moveCameraGrip(selectedCamera.id, index, pt);
return;
}
// [279] Geländer: Achsenpunkt live, ein Undo-Schritt je Zug (gleicher coalesceKey).
if (selectedRailing) {
const rl = selectedRailing;
if (rl.locked) return;
const patch = railingGripPatch(rl, index, pt);
if (patch.points) storeState().applyChange((p) => patchItem(p, "railings", rl.id, patch), `railingGrip:${rl.id}:${index}`);
return;
}
// [149] Baum: Stammmitte, Kronenrand bzw. Beschriftung live, ein Undo-Schritt je Zug (gleicher coalesceKey).
if (selectedTree) {
const tr = selectedTree;
+14
View File
@@ -40,6 +40,7 @@ function selHit(sel: PlanSelection): { kind: MemberKind; id: string } | null {
if (sel.columnId) return { kind: "columnIds", id: sel.columnId };
if (sel.roofId) return { kind: "roofIds", id: sel.roofId };
if (sel.treeId) return { kind: "treeIds", id: sel.treeId };
if (sel.railingId) return { kind: "railingIds", id: sel.railingId };
if (sel.cameraId) return { kind: "cameraIds", id: sel.cameraId };
return null;
}
@@ -218,6 +219,7 @@ export function useMouseSelectionHandlers(opts: {
context: "contextObjects",
site: "site",
tree: "trees",
railing: "railings",
camera: "cameras",
} as const satisfies Record<string, SelectionKind>;
type Kind = keyof typeof channels;
@@ -239,6 +241,8 @@ export function useMouseSelectionHandlers(opts: {
? { kind: "solid", id: sel.extrudedSolidId }
: sel.treeId
? { kind: "tree", id: sel.treeId }
: sel.railingId
? { kind: "railing", id: sel.railingId }
: sel.cameraId
? { kind: "camera", id: sel.cameraId }
: sel.columnId
@@ -307,6 +311,8 @@ export function useMouseSelectionHandlers(opts: {
? ["site", sel.siteId]
: sel.treeId
? ["trees", sel.treeId]
: sel.railingId
? ["railings", sel.railingId]
: sel.cameraId
? ["cameras", sel.cameraId]
: null;
@@ -330,6 +336,7 @@ export function useMouseSelectionHandlers(opts: {
openingIds: [],
treeIds: sel.treeIds ?? [],
cameraIds: sel.cameraIds ?? [],
railingIds: sel.railingIds ?? [],
};
// Gruppen-Isolation: ausserhalb der aktiven Gruppe getroffene Elemente
// sind gesperrt (werden ignoriert), wie beim Einzelklick.
@@ -347,6 +354,7 @@ export function useMouseSelectionHandlers(opts: {
openingIds: [],
treeIds: raw.treeIds.filter((id) => isInsideActiveGroup(project, "treeIds", id, groupPath)),
cameraIds: raw.cameraIds.filter((id) => isInsideActiveGroup(project, "cameraIds", id, groupPath)),
railingIds: raw.railingIds.filter((id) => isInsideActiveGroup(project, "railingIds", id, groupPath)),
};
// Gruppen-Erweiterung: jedes getroffene Element, das zu einer sichtbaren
// Gruppe gehört, zieht deren ganze (transitive) Mitgliedschaft nach.
@@ -363,6 +371,7 @@ export function useMouseSelectionHandlers(opts: {
stairs: expanded.stairIds,
rooms: expanded.roomIds,
trees: expanded.treeIds,
railings: expanded.railingIds,
cameras: expanded.cameraIds,
groups: groupIds,
});
@@ -428,6 +437,11 @@ export function useMouseSelectionHandlers(opts: {
setSelection({ ...clearKinds(), trees: [hit.id] });
return;
}
// [279] Geländer: Objekt-Info wie im Grundriss.
if (hit.kind === "railing") {
setSelection({ ...clearKinds(), railings: [hit.id] });
return;
}
// [137] Freier Körper (Loft, Rotation, Extrusion): Objekt-Info wie im Grundriss.
if (hit.kind === "solid") {
setSelection({ ...clearKinds(), solids: [hit.id] });
+4
View File
@@ -151,6 +151,8 @@ export function useSelectionCommands(opts: {
const ctxids = new Set(selection.contextObjects);
// [149] Bäume (gesperrte bleiben).
const treeids = new Set(selection.trees.filter((id) => !(project.trees ?? []).find((t) => t.id === id)?.locked));
// [279] Geländer (gesperrte bleiben).
const railids = new Set(selection.railings.filter((id) => !(project.railings ?? []).find((r) => r.id === id)?.locked));
// [213] Kameras (gesperrte bleiben).
const camids = new Set(selection.cameras.filter((id) => !(project.cameras ?? []).find((c) => c.id === id)?.locked));
// [193] Abgeleitete Lage-Darstellung (Schatten, Baurecht) ist kein Element: Entf blendet sie aus
@@ -177,6 +179,7 @@ export function useSelectionCommands(opts: {
...removeItems(p, "openings", (o) => oids.has(o.id) || wids.has(o.hostWallId) || (!!o.hostRoofId && rfids.has(o.hostRoofId)) || (!!o.hostCeilingId && cids.has(o.hostCeilingId))),
...removeItems(p, "context", ctxids),
...removeItems(p, "trees", treeids),
...removeItems(p, "railings", railids),
...removeItems(p, "cameras", camids),
// Gelöschte Elemente verlassen ihre Gruppen.
...pruneGroupMembers(p, {
@@ -189,6 +192,7 @@ export function useSelectionCommands(opts: {
columnIds: colids,
treeIds: treeids,
cameraIds: camids,
railingIds: railids,
}),
]),
);
+1 -1
View File
@@ -21,7 +21,7 @@ export interface View3dFilter {
export const NO_VIEW3D_FILTER: View3dFilter = Object.freeze({ only: null, hidden: [] }) as View3dFilter;
/** Element-Arten, die im 3D vorkommen (Räume, Schnittlinien, Lage-Darstellung und Gruppen nicht). */
const KINDS_3D: readonly SelectionKind[] = ["walls", "ceilings", "openings", "stairs", "solids", "columns", "roofs", "contextObjects", "trees", "drawings"];
const KINDS_3D: readonly SelectionKind[] = ["walls", "ceilings", "openings", "stairs", "solids", "columns", "roofs", "contextObjects", "trees", "railings", "drawings"];
/** Element-ids der Auswahl, die im 3D vorkommen (ohne Doppel, in Wahl-Reihenfolge). */
export function selectionIds3d(sel: Selection): string[] {
+4
View File
@@ -55,6 +55,8 @@ export interface TransformSelection {
openingIds?: string[];
/** [149] Gewählte Bäume (Stammmitte wird transformiert). */
treeIds?: string[];
/** [279] Gewählte Geländer (alle Punkte der Achse werden transformiert). */
railingIds?: string[];
/** [213] Gewählte Kameras (Standpunkt und Ziel werden transformiert, Höhen/Bildwinkel bleiben). */
cameraIds?: string[];
/** [193] Gewählte Gelände-/Umgebungs-Elemente (alle Punkte x/y werden abgebildet). */
@@ -75,6 +77,7 @@ export function toTransformSel(sel: CommandSelection): TransformSelection {
roomIds: sel.roomIds,
openingIds: sel.openingIds,
treeIds: sel.treeIds,
railingIds: sel.railingIds,
cameraIds: sel.cameraIds,
contextIds: sel.contextIds,
};
@@ -98,6 +101,7 @@ export function hasTransformSelection(sel: CommandSelection, op?: string): boole
(sel.stairIds?.length ?? 0) > 0 ||
(sel.roomIds?.length ?? 0) > 0 ||
(sel.treeIds?.length ?? 0) > 0 ||
(sel.railingIds?.length ?? 0) > 0 ||
(sel.cameraIds?.length ?? 0) > 0 ||
(sel.contextIds?.length ?? 0) > 0
);
+1 -1
View File
@@ -11,7 +11,7 @@ import { anonymityPlaceParts } from "./anonymityPlace";
const AREA_KEYS = new Set([
"rooms", "drawingLevels", "layers", "groups", "blockDefs", "layouts", "masterLayouts", "drawings2d", "walls", "openings",
"stairs", "columns", "context", "extrudedSolids", "viewSnapshots", "viewSnapshotFolders", "viewTemplates", "layoutFolders",
"publishSets", "roomProgram", "export", "cameras", "components", "wallTypes", "textStyles", "ceilings", "roofs", "trees",
"publishSets", "roomProgram", "export", "cameras", "components", "wallTypes", "textStyles", "ceilings", "roofs", "trees", "railings",
"hatches", "lineStyles", "materials",
]);
+1 -1
View File
@@ -28,7 +28,7 @@ const OVERRIDE_TYPE_OPTIONS: { value: OverrideConditionType; labelKey: string }[
/** [33] Feste Werte je Kriterium (Auswahl statt Freitext); Beschriftung `resources.overrides.val.<typ>.<wert>`. */
const ENUM_VALUES: Partial<Record<OverrideConditionType, readonly string[]>> = {
element_kind: ["wall", "slab", "ground_slab", "roof", "stair", "column", "opening", "room", "shadow", "terrain", "mesh", "floor_finish"],
element_kind: ["wall", "slab", "ground_slab", "roof", "stair", "column", "railing", "opening", "room", "shadow", "terrain", "mesh", "floor_finish"],
layer_function: ["structure", "insulation", "screed", "finish", "plaster", "substructure", "membrane", "cladding", "air"],
layer_position: ["above", "structure", "below"],
view_kind: ["plan", "section", "elevation"],
+13
View File
@@ -186,6 +186,19 @@ export const CommandIcon = memo(function CommandIcon({ name }: { name: string })
<line x1="12.5" y1="9.5" x2="12.5" y2="13.5" />
</svg>
);
case "gelaender":
// [279] Geländer: Handlauf mit Pfosten und Stäben.
return (
<svg {...common}>
<line x1="1.5" y1="4.5" x2="14.5" y2="4.5" />
<line x1="1.5" y1="12.5" x2="14.5" y2="12.5" />
<line x1="2.5" y1="4.5" x2="2.5" y2="12.5" />
<line x1="8" y1="4.5" x2="8" y2="12.5" />
<line x1="13.5" y1="4.5" x2="13.5" y2="12.5" />
<line x1="5.2" y1="4.5" x2="5.2" y2="12.5" strokeWidth="0.7" />
<line x1="10.8" y1="4.5" x2="10.8" y2="12.5" strokeWidth="0.7" />
</svg>
);
case "tree":
// [149] Baum: Krone (Kreis) mit Stamm.
return (
+3 -3
View File
@@ -91,7 +91,7 @@ import { cameraAfterReady, createViewportCameraApi } from "./viewportCameraApi";
/** Ein per 3D-Klick getroffenes Bauteil, oder null (Leerraum). */
export type Pick3dHit =
| { kind: "wall" | "ceiling" | "opening" | "stair" | "roof" | "contextObject" | "drawing" | "column" | "solid" | "tree"; id: string }
| { kind: "wall" | "ceiling" | "opening" | "stair" | "roof" | "contextObject" | "drawing" | "column" | "solid" | "tree" | "railing"; id: string }
| null;
/** Klick-vs-Drag-Schwelle (Pixel): bleibt die Maus zwischen pointerdown und
@@ -1653,7 +1653,7 @@ export function Wasm3DViewport({
const ndc = toNdc(clientX, clientY);
if (!cb || !o || !ndc) return;
const ray = cameraRay(orbitCamera(o), ndc.ndcX, ndc.ndcY, ndc.aspect);
const { walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes, stairMeshes, drawingMeshes, trees } = pickGeometry(
const { walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes, stairMeshes, drawingMeshes, trees, railings } = pickGeometry(
projectRef.current,
explodeRef.current,
hideRef.current,
@@ -1662,7 +1662,7 @@ export function Wasm3DViewport({
// Meshes + freie 2D-Zeichnungen (Linie/Polylinie/Rechteck, s.
// `pickDrawingSegs`) — sonst wären im WASM-Viewport 2D-Elemente NIE
// anwählbar gewesen (Nutzer-Report).
const hit = pickNearest(ray, walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes, stairMeshes, drawingMeshes, trees);
const hit = pickNearest(ray, walls, slabs, openings, stairs, roofs, contextMeshes, drawings, columns, solids, openingMeshes, stairMeshes, drawingMeshes, trees, railings);
cb(hit ? { kind: hit.kind, id: hit.id } : null, additive);
};
+9 -2
View File
@@ -19,7 +19,7 @@
import { DRAWING_PICK_TOLERANCE } from "../core";
import { screenRight } from "./cameraBridge";
import type { Vec3, PickWall, PickOpening, PickDrawingSeg, PickSlab, PickStair, PickRoof, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickStairMesh, PickDrawingMesh, PickTreeMesh } from "../core";
import type { Vec3, PickWall, PickOpening, PickDrawingSeg, PickSlab, PickStair, PickRoof, PickContextMesh, PickColumnMesh, PickSolidMesh, PickOpeningMesh, PickStairMesh, PickDrawingMesh, PickTreeMesh, PickRailingMesh } from "../core";
/** Kamera-Parameter für den Pick-Strahl (Teilmenge von Camera3d). */
export interface RayCamera {
@@ -43,7 +43,7 @@ export interface Ray {
/** Ergebnis eines Picks: getroffenes Bauteil + Distanz entlang des Strahls. */
export interface PickHit {
kind: "wall" | "ceiling" | "opening" | "stair" | "roof" | "contextObject" | "drawing" | "column" | "solid" | "tree";
kind: "wall" | "ceiling" | "opening" | "stair" | "roof" | "contextObject" | "drawing" | "column" | "solid" | "tree" | "railing";
id: string;
t: number;
/** Bei `kind:"opening"` dieselbe Id wie `id` (ausdrucksstärkerer Zugriff). */
@@ -364,6 +364,7 @@ export function pickNearest(
stairMeshes?: readonly PickStairMesh[],
drawingMeshes?: readonly PickDrawingMesh[],
trees?: readonly PickTreeMesh[],
railings?: readonly PickRailingMesh[],
): PickHit | null;
/**
* Nächstes getroffenes Bauteil (kleinstes t) über Wände, Decken, Öffnungen und
@@ -389,6 +390,7 @@ export function pickNearest(
stairMeshes: readonly PickStairMesh[] = [],
drawingMeshes: readonly PickDrawingMesh[] = [],
trees: readonly PickTreeMesh[] = [],
railings: readonly PickRailingMesh[] = [],
): PickHit | null {
const TIE_EPS = 1e-6;
let hit: PickHit | null = null;
@@ -449,6 +451,11 @@ export function pickNearest(
const t = rayContextMeshTris(ray, { tris: tr.tris, contextObjectId: tr.treeId });
if (t !== null) consider({ kind: "tree", id: tr.treeId, t }, 1);
}
// [279] Geländer (alle Teile), Rang wie Wand/Decke.
for (const r of railings) {
const t = rayContextMeshTris(ray, { tris: r.tris, contextObjectId: r.railingId });
if (t !== null) consider({ kind: "railing", id: r.railingId, t }, 1);
}
// [137] Freie Körper (Kern-Netz, [115]), Rang wie Wand/Decke.
for (const s of solids) {
const t = rayContextMeshTris(ray, { tris: s.tris, contextObjectId: s.solidId });
+5
View File
@@ -154,6 +154,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
drawings: selectedDrawingIds,
site: selectedSite,
trees: selectedTreeIds,
railings: selectedRailingIds,
cameras: selectedCameraIds,
} = selection;
const selectedDrawingId = single(selection, "drawings");
@@ -320,6 +321,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
pickSectionLine,
pickSiteAt,
pickTree,
pickRailing,
pickCamera,
pickContextObject,
pickExtrudedSolid,
@@ -428,6 +430,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
pickColumn,
pickExtrudedSolid,
pickTree,
pickRailing,
pickCamera,
pickStair,
pickRoof,
@@ -467,6 +470,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
pickRoom,
pickRoof,
pickTree,
pickRailing,
pickCamera,
pickSiteAt,
pickContextObject,
@@ -565,6 +569,7 @@ export const PlanView = forwardRef<PlanViewHandle, PlanViewProps>(
selectedContextObjectIds,
selectedSite,
selectedTreeIds,
selectedRailingIds,
selectedCameraIds,
selectedSectionLineIds,
selectedExtrudedSolidIds,
+1
View File
@@ -35,6 +35,7 @@ const KIND_FIELD: Record<PickKind, SelectionKind> = {
drawing: "drawings",
solid: "solids",
tree: "trees",
railing: "railings",
camera: "cameras",
ceiling: "ceilings",
stair: "stairs",
+4 -1
View File
@@ -71,7 +71,7 @@ export const GRIP_HIT_PX = 9;
export const LINE_PICK_PX = 6;
export const PICK_ORDER: readonly PickKind[] = [
"section", "opening", "wall", "column", "drawing", "solid", "tree", "camera",
"section", "opening", "wall", "column", "drawing", "solid", "tree", "railing", "camera",
"ceiling", "stair", "room", "roof", "site", "context",
];
@@ -90,12 +90,15 @@ export const EMPTY_PICK: PickIds = {
contextObjectId: null,
siteId: null,
treeId: null,
railingId: null,
cameraId: null,
};
/** Mac: Cmd+Klick; sonst Strg+Klick (Alt+Klick ist die Schere, Ctrl+Klick unter macOS das Kontextmenü). */
/** [149] Präfix der Baum-Pick-Id im Feld `contextObjectId` (Kern `tree::TREE_PICK_PREFIX`). */
export const TREE_PICK = "@tree:";
/** [279] Präfix der Geländer-Pick-Id im Feld `contextObjectId` (Kern `railing::PICK_PREFIX`). */
export const RAILING_PICK = "@railing:";
/** [213] Präfix der Kamera-Pick-Id im Feld `contextObjectId` (Kern `camera::CAMERA_PICK_PREFIX`). */
export const CAMERA_PICK = "@camera:";
+4
View File
@@ -156,6 +156,8 @@ export interface PlanSelection {
* Öffnung/Wand/Stütze/2D-Element/Körper getroffen wurde; Vorrang vor Decke, Raum, Dach und Gelände.
*/
treeId?: string | null;
/** [279] Getroffenes Geländer (Pick-Fläche um die Achse, Pick-Id `@railing:<id>` im Feld `contextObjectId`); Vorrang wie der Baum. */
railingId?: string | null;
/** [213] Getroffene Kamera (Sichtkegel/Gehäuse, Pick-Id `@camera:<id>` im Feld `contextObjectId`); Vorrang vor allem ausser Öffnung/Wand/Stütze/2D-Element/Körper/Baum. */
cameraId?: string | null;
/**
@@ -187,6 +189,8 @@ export interface MarqueeSelection {
stairIds: string[];
/** [149] Getroffene Bäume (Kronenfläche, gleiche Konvention). */
treeIds?: string[];
/** [279] Getroffene Geländer (Pick-Flächen um die Achse, gleiche Konvention). */
railingIds?: string[];
/** [213] Getroffene Kameras (Pick-Flächen von Gehäuse und Sichtgrenzen, gleiche Konvention). */
cameraIds?: string[];
/**
+7 -3
View File
@@ -6,7 +6,7 @@ import type { Primitive, OwnerField, PickKind } from "../../../core";
import { useMemo, useEffect } from "react";
import { planPrimAt } from "../../../core";
import { textFrameCorners } from "../../../text/textFrame";
import { CAMERA_PICK, TREE_PICK } from "./constants";
import { CAMERA_PICK, RAILING_PICK, TREE_PICK } from "./constants";
import { PlanPickIndex } from "../../../core";
import type { Plan } from "../../../core";
import type { UnderlayGroup } from "../../../core";
@@ -36,6 +36,7 @@ export interface UsePlanHighlightsArgs {
selectedContextObjectIds: string[];
selectedSite: string[];
selectedTreeIds: string[];
selectedRailingIds?: string[];
selectedCameraIds?: string[];
selectedSectionLineIds: string[];
selectedExtrudedSolidIds: string[];
@@ -65,6 +66,7 @@ export function usePlanHighlights(inp: UsePlanHighlightsArgs) {
selectedContextObjectIds,
selectedSite,
selectedTreeIds,
selectedRailingIds,
selectedCameraIds,
selectedSectionLineIds,
selectedExtrudedSolidIds,
@@ -240,11 +242,12 @@ export function usePlanHighlights(inp: UsePlanHighlightsArgs) {
...(selectedContextObjectIds ?? []),
...(selectedSite ?? []).map((s) => "@" + s),
...(selectedTreeIds ?? []).map((s) => TREE_PICK + s),
...(selectedRailingIds ?? []).map((s) => RAILING_PICK + s),
...(selectedCameraIds ?? []).map((s) => CAMERA_PICK + s),
];
if (!ids.length) return [];
return primsOwnedBy("contextObjectId", ids, (p): p is Extract<Primitive, { kind: "polygon" }> => p.kind === "polygon");
}, [plan, selectedContextObjectIds, selectedSite, selectedTreeIds, selectedCameraIds]);
}, [plan, selectedContextObjectIds, selectedSite, selectedTreeIds, selectedRailingIds, selectedCameraIds]);
// Hervorhebung der selektierten Schnitt-/Ansichtslinie: das (unsichtbare)
// Pick-Band (Polygon mit sectionLineId) mit Akzentkontur überzeichnen.
@@ -283,8 +286,9 @@ export function usePlanHighlights(inp: UsePlanHighlightsArgs) {
if (!hoverPick) return [];
if (hoverPick.kind === "site") return primsOwnedBy("contextObjectId", ["@" + hoverPick.id], (_p): _p is Primitive => true);
if (hoverPick.kind === "tree") return primsOwnedBy("contextObjectId", [TREE_PICK + hoverPick.id], (_p): _p is Primitive => true);
if (hoverPick.kind === "railing") return primsOwnedBy("contextObjectId", [RAILING_PICK + hoverPick.id], (_p): _p is Primitive => true);
if (hoverPick.kind === "camera") return primsOwnedBy("contextObjectId", [CAMERA_PICK + hoverPick.id], (_p): _p is Primitive => true);
const field: Record<Exclude<PickKind, "site" | "tree" | "camera">, OwnerField> = {
const field: Record<Exclude<PickKind, "site" | "tree" | "railing" | "camera">, OwnerField> = {
wall: "wallId", drawing: "drawingId", ceiling: "ceilingId", opening: "openingId",
stair: "stairId", room: "roomId", roof: "roofId", context: "contextObjectId",
section: "sectionLineId", solid: "extrudedSolidId", column: "columnId",
+16 -1
View File
@@ -10,7 +10,7 @@ import type { Vec2 } from "../../../model/types";
import type { PlainCycle } from "../pickCycle";
import { selectionHas, plainCycleNext, cycleHint } from "../pickCycle";
import { t } from "../../../i18n";
import { CAMERA_PICK, LINE_PICK_PX, TREE_PICK, PICK_ORDER, EMPTY_PICK, MARQUEE_THRESHOLD_PX, cycleModifier } from "./constants";
import { CAMERA_PICK, LINE_PICK_PX, RAILING_PICK, TREE_PICK, PICK_ORDER, EMPTY_PICK, MARQUEE_THRESHOLD_PX, cycleModifier } from "./constants";
import { planPrimAt, drawingsWithinDistance } from "../../../core";
import type { ViewBox__plan_planView_geometry as ViewBox } from "../../../core";
import { PlanPickIndex } from "../../../core";
@@ -47,6 +47,7 @@ export interface UsePlanPickCycleArgs {
pickRoom: (clientX: number, clientY: number) => string | null;
pickRoof: (clientX: number, clientY: number) => string | null;
pickTree: (clientX: number, clientY: number) => string | null;
pickRailing: (clientX: number, clientY: number) => string | null;
pickCamera: (clientX: number, clientY: number) => string | null;
pickSiteAt: (clientX: number, clientY: number) => string | null;
pickContextObject: (clientX: number, clientY: number) => string | null;
@@ -100,6 +101,7 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) {
pickRoom,
pickRoof,
pickTree,
pickRailing,
pickCamera,
pickSiteAt,
pickContextObject,
@@ -262,6 +264,7 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) {
add("drawing", dp.drawingId, dp.hitIndex);
add("solid", dp.extrudedSolidId, dp.hitIndex);
add("tree", dp.treeId, dp.hitIndex);
add("railing", dp.railingId, dp.hitIndex);
add("camera", dp.cameraId, dp.hitIndex);
add("ceiling", dp.ceilingId, dp.hitIndex);
add("stair", dp.stairId, dp.hitIndex);
@@ -290,6 +293,7 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) {
addRest("room", p.roomId, idx);
addRest("roof", p.roofId, idx);
if (p.contextObjectId?.startsWith(TREE_PICK)) addRest("tree", p.contextObjectId.slice(TREE_PICK.length), idx);
else if (p.contextObjectId?.startsWith(RAILING_PICK)) addRest("railing", p.contextObjectId.slice(RAILING_PICK.length), idx);
else if (p.contextObjectId?.startsWith(CAMERA_PICK)) addRest("camera", p.contextObjectId.slice(CAMERA_PICK.length), idx);
else if (p.contextObjectId?.startsWith("@")) addRest("site", p.contextObjectId.slice(1), idx);
else addRest("context", p.contextObjectId, idx);
@@ -303,6 +307,7 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) {
addRest("room", pickRoom(clientX, clientY), null);
addRest("roof", pickRoof(clientX, clientY), null);
addRest("tree", pickTree(clientX, clientY), null);
addRest("railing", pickRailing(clientX, clientY), null);
addRest("camera", pickCamera(clientX, clientY), null);
addRest("site", pickSiteAt(clientX, clientY), null);
addRest("context", pickContextObject(clientX, clientY), null);
@@ -342,6 +347,7 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) {
contextObjectId: c.kind === "context" ? c.id : null,
siteId: c.kind === "site" ? c.id : null,
treeId: c.kind === "tree" ? c.id : null,
railingId: c.kind === "railing" ? c.id : null,
cameraId: c.kind === "camera" ? c.id : null,
});
};
@@ -542,6 +548,15 @@ export function usePlanPickCycle(inp: UsePlanPickCycleArgs) {
.marquee("contextObjectId", rect, crossing)
.filter((id) => id.startsWith(TREE_PICK))
.map((id) => id.slice(TREE_PICK.length)),
// [279] Geländer: Pick-Flächen (`contextObjectId = "@railing:<id>"`, je Teilstrecke eine).
railingIds: [
...new Set(
getPick()
.marquee("contextObjectId", rect, crossing)
.filter((id) => id.startsWith(RAILING_PICK))
.map((id) => id.slice(RAILING_PICK.length)),
),
],
// [213] Kameras: Pick-Flächen (`contextObjectId = "@camera:<id>"`).
cameraIds: [
...new Set(
Loaded 100 of 103 files, more files were not shown because too many files have changed in this diff. Show more