Zusammenführung [291] Geländer
This commit is contained in:
29 files changed
+1444
-209
No files matched your search
@@ -63,6 +63,7 @@ Kennwort, anonym) als PDF; Austausch mit Fachplanern über DXF/IFC.
|
||||
- ◐ **[285]** Referenz-Ablauf zum zweiten Mal durchgespielt (18.11., Chromium/Linux, Haus 18 × 11 m, 2 Geschosse, 4 Wohnungen, Bilder `doc/review-285/`; nicht auf dem Mac, kein 3D-Live/Rendering/Druck). Behoben: Gesamthöhe (Baurecht, Kennzahlen) zählt die Attika (`site_rules.rs` `model_top`; vorher 5.80 statt Oberkante Attika, Ansicht zeigte +6.30; `KURZANLEITUNG` „Höhe 9.50" nicht neu geprüft). Offen, nach Schritt: Baurecht: Meldung „Gebäude innerhalb der zulässigen Fläche" steht grün schon ohne Bauteil (`panels/SiteRulesSection.tsx`) · S. Volumen: `decke` setzt die Decke immer oben ans aktive Geschoss, Bodenplatte unter EG und Balkonplatte brauchen je 6 Schritte in der Objekt-Info (OK/UK „Eigene"), kein Befehl/Option dafür (`cmds/ceiling.ts`) · S; `wand` hat keine Wandtyp-Option (Innenwände nachträglich umstellen) und setzt „Aussenbauteil"/„Tragend" nie, dadurch kein IsExternal an Aussenwänden im IFC und U-Wert „unvollständig (4 Schicht(en) ohne λ)" für den Standardaufbau (`cmds/wall.ts`, Standard-Wandtypen) · S; Zeichnungsebene „kataster" liegt im Arbeitsgrundriss über den neuen Wänden (Kataster-Gebäude deckt sie zu, bis man die Ebene ausblendet) · S; Fenster-Befehl: eine Zahl bei „Position entlang der Wand (Abstand tippen)" setzt stillschweigend die Breite (3 m statt Abstand 3 m, `cmds/opening.ts`) · S; Rampe: falsche Richtung (Anfang aussen, +6 %) hebt die Rampe über Geschosshöhe ohne Hinweis (`cmds/ramp.ts`) · S. Räume/Einheiten: `raum` legt je Aufruf nur einen Raum an, Name/Nutzung/Kategorie je Raum einzeln (10 Räume ≈ 40 Eingaben) · M; Einheit löschen/verschieben lässt leere Einheiten („0 Zi · 0.0 m²") und zählt Nummern weiter (Whg 5, 6) · S; Statusleiste: Feld „Ebene" zeigt die Klasse („20 Wände"), „Geschoss" die Zeichnungsebene (Bezeichnungen nach [180] vereinheitlichen, `ui/StatusBar.tsx`) · S; Projektname bleibt „Leeres Projekt" (Titel von Plakat/Spiegel), bis er im Mappe-Panel gesetzt wird · S. Abgabe (18.11. behoben, `presentation_sheet.rs`/`presentationSheet.ts`/`PresentationDialog.tsx`: Dialog bietet feineren Massstab (≥ 1:100) mit Knopf an, wenn er aufs Blatt passt; Situation = Parzelle (`siteRules.parcel`) ∪ Haus ± 10 m statt Haus ± 40 m, ohne Parzelle ± 30 m; Wohnungsspiegel als dritte Plakat-Tabelle bei Projekten mit Einheiten (`posterExtrasDefault`); nur Chromium/Vitest geprüft, Prüfbild `doc/review-285/r4-plakat-nachher.png` ist eine Rahmen-Skizze der Anordnung, kein gerenderter Plan; Tabellen füllen das Blatt weiter nur rechts neben der letzten Zeile, bei 3 Tabellen im Beispiel 2. Blatt; Axo-Bild bleibt auf die Grösse des grössten Grundrisses begrenzt — beides am 18.11. behoben, s. „Plakat gefüllt“) · Axo: Bäume fehlen (Entourage-Objekte da), Rampe/Haustür auf der abgewandten Seite nicht zu sehen (`plan/axo.rs`) · S. Geprüft ok: Kataster-Import und Baurecht-Zahlen (484 m² zulässig, AZ 0.41, ÜZ 0.23), GV mit Bodenplatte (686.8 = 603.5 + 83.3 m³), Wohnungsspiegel CSV/SVG, Kosten (1'094 CHF/m³), Plakat anonym (Kennwort im Titel, Projektname nirgends im PDF), PDF-Ebenen (17 OCG), IFC (Geländer, Träger, Rampe, Treppe, Dach, Räume), DXF. Nicht durchgespielt: Umbau (Abbruch Kataster-Bestand) und Varianten (nur Hinweise „noch kein Variantensatz"/„Zuerst Bauteile wählen" gesehen), Rendering-Fenster, Mac. · M Behoben (19.11., Bedienung/Modell): Baurecht-Meldung „innerhalb der zulässigen Fläche" erst mit Gebäude (sonst „Noch kein Gebäude gezeichnet", neutral) · `decke`: Option „Lage" (oben / unter dem Geschoss = Bodenplatte / frei mit getippter Oberkante, Kern `top`) · `wand`: Optionen „Wandtyp" (reihum durch die Projekt-Typen) und „Aussenbauteil" (nach Typ / ja / nein); Vorgabe `isExternal` nach dem Wandtypnamen („Aussenwand" ⇒ aussen, „Innenwand" ⇒ innen), der IFC-Export schreibt `IsExternal` nur mit Angabe im Modell (`ifc_data.rs`) · Standard-Baustoffe des Beispiel-/Leerprojekts (`sampleProject.ts`) haben λ (SIA-Richtwerte, wie `core/standards.rs`), U-Wert nicht mehr „unvollständig" · Fenster/Tür: getippte Zahl im Positionsschritt = Abstand (neues erstes Tab-Feld „Abstand"), nicht Breite · Rampe: Hinweis, wenn sie über die Geschosshöhe steigt bzw. tiefer als eine Geschosshöhe fällt · Axo: Bäume (Stamm + Krone) wie im 3D (`furniture_3d::with_context_meshes`). Nicht auf dem Mac/in der Tauri-App geprüft. Entschieden und behoben (18.11., Koordinator; Chromium/Linux, nicht auf dem Mac): Kataster/Kontext deckt im Arbeitsgrundriss die Wände nicht mehr zu — Gruppenreihenfolge und Goldens bleiben, stattdessen zeigt der Arbeitsgrundriss (Bildschirm, `contextUnderlay` aus `viewportContent.tsx`, nie Druck/PDF/SVG/CLI) Klassen „als Unterlage“ mit Deckkraft 0.35 (`drawings.rs` `underlay_class`, über den vorhandenen Transparenz-Rahmen der Senke, auch in der kompakten Linien-Unterlage); Schalter „Als Unterlage“ je Klasse (`LayerCategory.underlay`, KlLine truncated
|
||||
- ◐ **[270]** Blickrichtungen überall gleich (3D-Spiegelung behoben, Marken weichen aus; 17.11.). Offen: 3D-Bild nur numerisch (Kameramatrix, Pick-Strahl) geprüft, kein Bild aus render3d unter Linux, nicht auf dem Mac/Metal (`doc/RELEASE-1.0.md` 13.36); natives Spike-Fenster `src-tauri/src/native.rs` (Orbit-Richtung) nicht angepasst. · M
|
||||
- ◐ **[279]** Geländer als eigenes Bauteil (18.11.; Lücke 7 `doc/VERGLEICH-1.0.md`; Linux/Chromium, nicht auf dem Mac geprüft): Modell, Grundriss, Schnitt/Ansicht/3D, IFC, DXF, Befehl `gelaender` umgesetzt (`railing.rs`, `plan/railings.rs`). Nachgeführt 18.11.: Glas in Ansicht und 3D-Dokument durchscheinend (helle Füllung wie Fensterglas, Deckkraft 0.4, verdeckt nichts; Schnitt unverändert), Objektfang auf Achse (und Längskanten dicker Brüstungen), Schatten der Sonnenstudie (Prismen aus `railing::pieces`, ab 400 Teilen ohne Stäbe/Pfosten). Lochblech mit Lochmuster in Ansicht und 3D-Dokument (Punktschraffur `Dots` der Schraffur-Bibliothek auf der Tafel, `railings::perforation_hatch`; Schnitt und Grundriss unverändert); Handlauf über der Schnitthöhe bei geschnittenem Fuss im Grundriss als zwei gestrichelte Linien im Abstand der Handlaufbreite neben der Achse (`railing-handrail`, Strichmuster wie die Treppen-Handläufe über dem Schnitt; 18.11., Prüfbild `doc/review-279/03-lochblech.png`, Chromium/Linux). Offen: kein IfcRailing-Import; Loggia-Brüstung an Wänden bleibt Wand. · M
|
||||
- ◐ **[291]** Geländer: Aufbau je Feld und gebunden an Treppe/Deckenkante (19.11., nach 1.0, Leitbild Archicad; Linux/Chromium, nicht auf dem Mac geprüft). Modell (Rust, `gen:types`): `posts`/`postSpacing`/`postSize` (Pfosten an Ecken und Enden, Felder je Strecke gleich lang), `handrailProfile` (rechteckig/rund als Achteck-Stufen), `handrailHeight`, `midRails`, `fields` (Füllung je Feld: Stäbe/Glas/Brüstung/Lochblech), Bindung `stairId`+`stairSide` bzw. `ceilingId`+`edgeIndex`/`edgeCount`/`edgeInset`. Auflösung im Kern (`railing::path`): Treppe = Handlauf-Achse der Wange (`stair_rail`), Fuss lotrecht unter dem Handlauf (Höhe über der Stufenkante), Teile auf Teilstrecken geschert (`Piece.slope` = `RSlab.slope`); Deckenkante = Kantenzug nach innen versetzt, Fuss auf Decken-OK; ändert sich Treppe/Decke, folgt die Achse. Gebundene Treppenseite: eigener Treppen-Handlauf entfällt (`railing::stair_code` in Plan, 3D, IFC), sonst wie bisher. Grundriss an der Schnitthöhe geteilt (darüber Strich-Punkt), Schnitt/Ansicht/3D/3D-Dokument/Schatten/IFC aus denselben Prismen (IfcRailing ein Körper, Pset `Dossier_Railing.Axis` = aufgelöste Achse), Objekt-Info (Pfosten, Profil, Handlaufhöhe, Zwischenholme, Füllung je Feld, Bindung, „Lösen“), gebundene Geländer ohne Griffe. Befehl `gelaender` Option „an Treppe/Kante“ (ein Klick, Kern sucht nächste Wange/Kante ≤ 0.75 m). Bestehende Geländer unverändert (Goldens gleich). Tests: `railing_bound_tests.rs` (Pfosten, Ecken, Felder, Treppe/Decke ändern, Treppen-Handlauf, Befehl, Grundriss, Rundreise), `railingGrips.test.ts`, e2e `railing291.spec.ts`; Prüfbild Axo + Ansicht (Treppe mit Stabgeländer, Balkon Glas mit Pfosten) angesehen, nicht eingecheckt. Offen: Füllung je Feld in der Objekt-Info nur über Feld-Nr. (keine Auswahl im Plan); runder Handlauf nur angenähert; Treppen-Wendel ohne Pfosten-Feinheiten (Pfosten ab 10° Knick); IFC ein Körper (Pfosten nicht als Teile); gebundene Geländer bewegen sich nicht mit „Verschieben“ (folgen dem Träger); Mac/Tauri nicht geprüft. · M
|
||||
- ◐ **[278]** Nutzungseinheiten und Wohnungsspiegel (17.11.; Lücke 6; nicht auf dem Mac geprüft): `unit_schedule.rs`, Panel Flächenbilanz „Nutzungseinheiten“, CLI `--wohnungsspiegel` umgesetzt. Offen: Einheiten im Grundriss als farbige Fläche/Stempel auf eigener Klasse ([180]; `Unit.color` ist da); Summen je Typ/Geschoss nicht als eigene Blatt-Tabelle; Mindestfläche Zimmer und NWF nach kantonaler Definition fehlen; Einheit nicht in IFC/DXF; Spiegel im schmalen Dock als Karten. · M
|
||||
- ◐ **[281]** Geneigte Decken und Rampen (18.11.; Lücke 8; nicht auf dem Mac geprüft): `Ceiling.slope`, Befehl `rampe`, Schnitt/Ansicht/3D/IFC (`IfcRamp`) umgesetzt. Offen: Wandschichten werden von geneigten Decken nicht eingeschnitten (Wandoberkante: [292]); STEP-Export schreibt die Platte waagrecht (truck kennt `slope` nicht); Sonne: geneigte Decke wirft Hüllprisma-Schatten, empfängt keinen; Rampenlauf ohne Material-/Typzuordnung im IFC; Rampen-Umriss unter Schnittebene gestrichelt. Gefällelinie 18.11. mit zwei Griffen (Anfang/Ende, Kern-Op `ceilingSlopeGrip`, Gefälle in % bleibt, ein Undo-Schritt je Zug; e2e `ramp281.spec.ts`; nicht in der Tauri-App geprüft). · M
|
||||
- ◐ **[292]** Wand „OK bis Decke“ (19.11.; nach 1.0; Rest von [281]): `Wall.ceilingAttach` (Rust-Modell + `types.generated.ts`; fehlt = aus). Die Wand endet an der Unterkante der Decken ihres Geschosses — waagrecht auf Decken-UK, bei geneigter Decke mit schräger Oberkante (`ceiling_undersides` in `model3d/walls.rs` baut Unterkanten-Facetten samt Aussparungen, `wall_bands.rs` nutzt dieselbe Facetten-Logik wie „Wand an Dach“ [G2]: je Punkt gilt die tiefste Decken-UK bzw. die niedrigere von Dach und Decke, Stücke über der UK entfallen, im Deckenloch und ausserhalb der Decke bleibt die Krone, ohne Decke die Geschosshöhe; Platte bis Aussenkante der tragenden Schicht [178]). Wirkt über `emit_walls` auf 3D, Schnitt, Ansicht und IFC (Bänder, Mengen). UI: Objekt-Info Wand „Oberkante: Geschosshöhe / Bis Decke“, Befehl `wand` Option „OK bis Decke“ (Taste D/C, Vorgabe aus — keine eindeutige Regel für Innenwände). Rust-Tests `wand_ok_bis_decke_*` (waagrecht, Rückfall, geneigt, Deckenloch). Offen: Wand-Quelle `top` „an Dach“ und „frei“ bleiben die bisherigen Felder (`top`/`roofAttach`), keine gemeinsame Auswahl; Plan-Ansichtshöhe skalarer Werte (z. B. Kennzahl Wandhöhe) nutzt weiter die Krone; nicht in der Tauri-App geprüft. · S
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
// [291] Geländer an der Treppe: im Musterhaus mit „gelaender“ und der Option „an Treppe/Kante“ auf die Treppe ST1 klicken
|
||||
// (Kern bindet an die nächste Wange), das Geländer im Plan wählen, Bindung und Felder in der Objekt-Info sehen,
|
||||
// Pfostenabstand ändern, rückgängig machen und lösen.
|
||||
import type { Page } from "@playwright/test";
|
||||
import { blurFocus, commandInput, expect, 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 an Treppe binden, Felder ändern, lösen", 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");
|
||||
const bind = page.locator(".cmdline-option").filter({ hasText: "an Treppe/Kante" });
|
||||
await bind.click();
|
||||
await expect(page.locator(".cmdline-prompt")).toHaveText("Treppe (Wange) oder Deckenkante anklicken:");
|
||||
await commandInput(page).focus();
|
||||
// Treppe ST1: x 3.2–4.2, Lauf in +y; der Klick nahe x = 3.3 trifft die linke Wange.
|
||||
await typeCommand(page, "3.3,1.2");
|
||||
await blurFocus(page);
|
||||
// Option zurücksetzen (gilt über Aufrufe hinweg), damit spätere Befehle frei zeichnen.
|
||||
await commandInput(page).focus();
|
||||
await typeCommand(page, "gelaender");
|
||||
await page.locator(".cmdline-option").filter({ hasText: "an Treppe/Kante" }).click();
|
||||
await page.keyboard.press("Escape");
|
||||
await blurFocus(page);
|
||||
|
||||
const objInfo = page.locator(".objinfo-panel").first();
|
||||
await expect(async () => {
|
||||
await page.keyboard.press("Escape");
|
||||
// Achse auf der Wange unter der Schnitthöhe (Pick-Fläche um die Achse).
|
||||
await clickModel(page, 3.24, 1.0);
|
||||
await expect(page.getByTestId("railing-bound")).toBeVisible({ timeout: 1000 });
|
||||
}).toPass({ timeout: 30_000 });
|
||||
await expect(page.getByTestId("railing-bound")).toHaveText("ST1");
|
||||
const fields = page.getByTestId("railing-fields");
|
||||
const before = Number(await fields.textContent());
|
||||
expect(before).toBeGreaterThan(0);
|
||||
const spacing = objInfo.locator("label.objinfo-field").filter({ has: page.locator(".objinfo-flabel", { hasText: /^Pfostenabstand \(max\.\)$/ }) }).locator("input");
|
||||
await spacing.fill("0.5");
|
||||
await spacing.press("Enter");
|
||||
await expect(async () => expect(Number(await fields.textContent())).toBeGreaterThan(before)).toPass({ timeout: 10_000 });
|
||||
await blurFocus(page);
|
||||
await page.keyboard.press("ControlOrMeta+z");
|
||||
await expect(fields).toHaveText(String(before));
|
||||
// Lösen: die Achse bleibt als freie Polylinie, die Bindung ist weg.
|
||||
await page.getByTestId("railing-unbind").click();
|
||||
await expect(page.getByTestId("railing-bound")).toBeHidden();
|
||||
await expect(page.getByTestId("railing-length")).toBeVisible();
|
||||
});
|
||||
@@ -61,7 +61,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` |
|
||||
| `railing.rs` | [279] Geländer als eigenes Bauteil: Prismen (Pfosten, Stäbe, Tafel, Zwischenholme, Handlauf) aus einer Quelle für 3D, Schnitt, Ansicht, 3D-Dokument, IFC; [291] Aufbau je Feld, Bindung an Treppenwange/Deckenkante (`path`), Treppen-Handlauf ohne gebundene Seiten (`stair_code`); Tests in `railing_tests.rs`, `railing_bound_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 |
|
||||
|
||||
@@ -1080,9 +1080,23 @@ fn tree_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
/// (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.
|
||||
/// [291] Mit `bind: true` bindet der erste Punkt das Geländer an die nächste Treppenwange (Treppen dieses Geschosses) bzw.
|
||||
/// Deckenkante (alle Decken) innerhalb [`RAILING_BIND_TOL`]; die Achse ist dann eine Ableitung (`railing::path`), `points`
|
||||
/// trägt den aufgelösten Zug als Ersatz. Nichts in Reichweite: keine Op.
|
||||
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);
|
||||
let mut bound: Vec<(&str, Value)> = Vec::new();
|
||||
let mut floor = ctx.level.to_string();
|
||||
if v.get("bind").and_then(Value::as_bool) == Some(true) {
|
||||
let Some(&at) = pts.first() else { return Vec::new() };
|
||||
let Some((b, axis, fl)) = railing_bind_target(p, at, ctx.level) else { return Vec::new() };
|
||||
bound = b;
|
||||
pts = axis;
|
||||
if let Some(fl) = fl {
|
||||
floor = fl;
|
||||
}
|
||||
}
|
||||
if pts.len() < 2 {
|
||||
return Vec::new();
|
||||
}
|
||||
@@ -1091,12 +1105,13 @@ fn railing_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
let mut f = vec![
|
||||
("id", s(&ids.next("railing"))),
|
||||
("type", s("railing")),
|
||||
("floorId", s(ctx.level)),
|
||||
("floorId", s(&floor)),
|
||||
("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)),
|
||||
];
|
||||
f.extend(bound);
|
||||
if v.get("closed").and_then(Value::as_bool) == Some(true) && pts.len() >= 3 {
|
||||
f.push(("closed", Value::Bool(true)));
|
||||
}
|
||||
@@ -1118,6 +1133,42 @@ fn railing_ops(p: &Project, v: &Value, ctx: &Ctx, ids: &mut IdGen) -> Vec<Op> {
|
||||
add_op("railings", vec![obj(f)])
|
||||
}
|
||||
|
||||
/// [291] Fangweite (m) für die Option an Treppe/Kante: so nah muss der Klick an einer Treppenwange oder Deckenkante liegen.
|
||||
const RAILING_BIND_TOL: f64 = 0.75;
|
||||
|
||||
/// [291] Nächste Treppenwange (Treppen auf `level`) oder Deckenkante zum Punkt `at`: Felder der Bindung, Ersatz-Achse
|
||||
/// und (bei der Treppe) deren Geschoss.
|
||||
type BindTarget = (Vec<(&'static str, Value)>, Vec<V>, Option<String>);
|
||||
fn railing_bind_target(p: &Project, at: V, level: &str) -> Option<BindTarget> {
|
||||
let mut best: Option<(f64, BindTarget)> = None;
|
||||
let mut take = |d: f64, t: BindTarget| {
|
||||
if d <= RAILING_BIND_TOL && best.as_ref().is_none_or(|x| d < x.0) {
|
||||
best = Some((d, t));
|
||||
}
|
||||
};
|
||||
let dist = |pts: &[V]| pts.windows(2).map(|w| point_segment_distance(at, w[0], w[1])).fold(f64::INFINITY, f64::min);
|
||||
for st in p.stairs.as_deref().unwrap_or(&[]).iter().filter(|s| s.floor_id == level) {
|
||||
for (side, name) in [(crate::model::RailingSide::Left, "left"), (crate::model::RailingSide::Right, "right")] {
|
||||
let Some(q) = crate::railing::stair_side_path(p, st, Some(side)) else { continue };
|
||||
let axis: Vec<V> = q.iter().map(|v| (v[0], v[1])).collect();
|
||||
take(dist(&axis), (vec![("stairId", s(&st.id)), ("stairSide", s(name))], axis, Some(st.floor_id.clone())));
|
||||
}
|
||||
}
|
||||
for c in p.ceilings.as_deref().unwrap_or(&[]) {
|
||||
let n = c.outline.len();
|
||||
if n < 3 {
|
||||
continue;
|
||||
}
|
||||
for i in 0..n {
|
||||
let (a, b) = (&c.outline[i], &c.outline[(i + 1) % n]);
|
||||
let d = point_segment_distance(at, (a.x, a.y), (b.x, b.y));
|
||||
let Some(axis) = crate::railing::ceiling_edge_path(c, i as u32, 1, crate::railing::EDGE_INSET) else { continue };
|
||||
take(d, (vec![("ceilingId", s(&c.id)), ("edgeIndex", js_num(i as f64))], axis.iter().map(|q| (q[0], q[1])).collect(), None));
|
||||
}
|
||||
}
|
||||
best.map(|(_, t)| t)
|
||||
}
|
||||
|
||||
/// [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.
|
||||
|
||||
@@ -297,13 +297,12 @@ 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 };
|
||||
let Some(s) = crate::railing::spec(p, 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());
|
||||
// Umriss der Achse mit Handlaufbreite, Fuss bis Oberkante ([291] auf Treppen geneigt).
|
||||
for (q, z0, z1, slope) in crate::railing::hull(p, r, s.rail_w().max(s.thickness) / 2.0) {
|
||||
out.prism_edges_sloped(&q, z0, z1, slope.as_ref());
|
||||
}
|
||||
lift(&mut out, n, &r.id);
|
||||
}
|
||||
|
||||
@@ -2110,11 +2110,11 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
|
||||
// ── [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 (Some(s), Some(ax)) = (crate::railing::spec(&p, r), crate::railing::axis_of(&p, 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 (pp, ii) = q.mesh();
|
||||
let at = (positions.len() / 3) as u32;
|
||||
positions.extend(pp);
|
||||
indices.extend(ii.into_iter().map(|k| k + at));
|
||||
@@ -2138,7 +2138,8 @@ pub fn ifc_export_data(src: &Project, opt: &IfcOptions) -> Result<Flat, String>
|
||||
let mut psets = vec![Pset { name: "Pset_RailingCommon", props: vec![ident("Reference", &label)] }];
|
||||
renovation_props(&p, &mut psets, "Pset_RailingCommon", r.renovation.as_ref());
|
||||
// [B4] Achse (Meter, Modellkoordinaten), Höhe und Schluss: damit liest der Import das Geländer als Bauteil zurück.
|
||||
let axis_text = r.points.iter().map(|q| format!("{},{}", fmt_coord(q.x), fmt_coord(q.y))).collect::<Vec<_>>().join(";");
|
||||
// [291] Gebundene Geländer: die aufgelöste Achse (der Import liest ein freies Geländer zurück).
|
||||
let axis_text = if r.stair_id.is_some() || r.ceiling_id.is_some() { ax.iter().map(|q| format!("{},{}", fmt_coord(q[0]), fmt_coord(q[1]))).collect::<Vec<_>>().join(";") } else { r.points.iter().map(|q| format!("{},{}", fmt_coord(q.x), fmt_coord(q.y))).collect::<Vec<_>>().join(";") };
|
||||
psets.push(Pset {
|
||||
name: "Dossier_Railing",
|
||||
props: vec![
|
||||
|
||||
@@ -384,7 +384,7 @@ pub fn stair_parts(one: &Project, stair: &Stair, base: f64) -> StairParts {
|
||||
let rail_meshes = model3d::emit_stair_handrails(one);
|
||||
let rail = (!rail_meshes.is_empty()).then(|| {
|
||||
let (positions, indices) = concat(&rail_meshes);
|
||||
let sides = if one.stair_type(stair).and_then(|t| t.railing) == Some(StairTypeRailing::Beide) { 2.0 } else { 1.0 };
|
||||
let sides = if crate::railing::stair_code(one, stair) == 3 { 2.0 } else { 1.0 };
|
||||
Rail { mesh: ifc_mesh(positions, &indices, base), quantities: railing_quantities(walk_length(stair, rise) * sides, section_area) }
|
||||
});
|
||||
let guard_meshes = model3d::stair_guard_meshes(one);
|
||||
|
||||
@@ -5773,6 +5773,47 @@ pub enum RailingKind {
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [291] Profil des Handlaufs.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
pub enum RailingProfile {
|
||||
/// Rechteckig (Vorgabe; Breite = Höhe = `handrailSize`).
|
||||
#[default]
|
||||
#[serde(rename = "rect")]
|
||||
Rect,
|
||||
/// Rund (Durchmesser `handrailSize`; Körper als Achteck-Stufen angenähert).
|
||||
#[serde(rename = "round")]
|
||||
Round,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [291] Seite einer Treppe in Laufrichtung (gebundenes Geländer).
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize, TS)]
|
||||
pub enum RailingSide {
|
||||
#[default]
|
||||
#[serde(rename = "left")]
|
||||
Left,
|
||||
#[serde(rename = "right")]
|
||||
Right,
|
||||
#[serde(other)]
|
||||
#[ts(skip)]
|
||||
Unknown,
|
||||
}
|
||||
|
||||
/// [291] Füllung eines Feldes (zwischen zwei Pfosten) abweichend von `Railing.kind`.
|
||||
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)]
|
||||
#[serde(default)]
|
||||
pub struct RailingField {
|
||||
/// Feld-Nummer längs der Achse (ab 0).
|
||||
pub index: u32,
|
||||
/// Füllung dieses Feldes.
|
||||
pub kind: RailingKind,
|
||||
#[serde(flatten)]
|
||||
#[ts(skip)]
|
||||
pub extra: Extra,
|
||||
}
|
||||
|
||||
/// 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`).
|
||||
@@ -5831,6 +5872,60 @@ pub struct Railing {
|
||||
#[serde(rename = "handrailSize", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub handrail_size: Option<f64>,
|
||||
/// [291] Handlauf: Profil (rechteckig = Vorgabe, rund).
|
||||
#[serde(rename = "handrailProfile", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub handrail_profile: Option<RailingProfile>,
|
||||
/// [291] Handlauf: Höhe der Oberkante über dem Fuss (m); fehlt = `height` (Handlauf obenauf).
|
||||
#[serde(rename = "handrailHeight", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub handrail_height: Option<f64>,
|
||||
/// [291] Pfosten setzen (an Ecken und Enden automatisch, dazwischen höchstens `postSpacing`); fehlt = bei Stäben ja, sonst nein.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub posts: Option<bool>,
|
||||
/// [291] Pfosten: grösster Achsabstand (m, Vorgabe 1.20); die Felder einer Strecke werden gleich lang.
|
||||
#[serde(rename = "postSpacing", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub post_spacing: Option<f64>,
|
||||
/// [291] Pfosten: Querschnitt (Kantenlänge, m, Vorgabe 0.03).
|
||||
#[serde(rename = "postSize", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub post_size: Option<f64>,
|
||||
/// [291] Anzahl Zwischenholme (waagrechte Stäbe zwischen Fuss und Handlauf, gleich verteilt; Vorgabe 0).
|
||||
#[serde(rename = "midRails", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub mid_rails: Option<u32>,
|
||||
/// [291] Füllung je Feld (Feld = Abschnitt zwischen zwei Pfosten, längs der Achse ab 0 gezählt); fehlt ein Feld, gilt `kind`.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub fields: Option<Vec<RailingField>>,
|
||||
/// [291] Gebunden an eine Treppe: die Achse folgt der Treppenwange `stairSide` und steigt mit dem Lauf (Höhe
|
||||
/// lotrecht über der Stufenkante); `points` dient dann nur als Ersatz, falls die Treppe fehlt.
|
||||
#[serde(rename = "stairId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub stair_id: Option<String>,
|
||||
/// [291] Seite der Treppe in Laufrichtung (Vorgabe links).
|
||||
#[serde(rename = "stairSide", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub stair_side: Option<RailingSide>,
|
||||
/// [291] Gebunden an eine Deckenkante: die Achse folgt den Kanten `edgeIndex` … `edgeIndex + edgeCount − 1` des
|
||||
/// Deckenumrisses, um `edgeInset` nach innen versetzt; der Fuss steht auf der Deckenoberkante (+ `baseOffset`).
|
||||
#[serde(rename = "ceilingId", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub ceiling_id: Option<String>,
|
||||
/// [291] Erste Kante (Kante i läuft von outline[i] zu outline[i+1]).
|
||||
#[serde(rename = "edgeIndex", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub edge_index: Option<u32>,
|
||||
/// [291] Anzahl aufeinanderfolgender Kanten (Vorgabe 1; alle Kanten = geschlossen ringsum).
|
||||
#[serde(rename = "edgeCount", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub edge_count: Option<u32>,
|
||||
/// [291] Abstand der Achse von der Deckenkante nach innen (m, Vorgabe 0.05).
|
||||
#[serde(rename = "edgeInset", default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional)]
|
||||
pub edge_inset: 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)]
|
||||
|
||||
@@ -114,7 +114,8 @@ pub enum SlabSource {
|
||||
/// [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 },
|
||||
/// `fill`: Tafel mit dieser Füllung ([291] je Feld), `None` = Gestänge.
|
||||
Railing { index: usize, fill: Option<RailingKind> },
|
||||
/// [280] Index in `Project::beams` (Träger-Prisma wie eine Stütze).
|
||||
Beam { index: usize },
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! [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.
|
||||
//! `crate::railing::pieces` (lotrechte Prismen, auf Treppen geschert [291]), eine Quelle für alle Ableitungen.
|
||||
|
||||
use super::*;
|
||||
use crate::railing::{self, Part, Piece};
|
||||
@@ -12,7 +12,7 @@ fn merge<'a>(pieces: impl Iterator<Item = &'a Piece>) -> Option<(Vec<f64>, Vec<u
|
||||
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 (pp, ii) = q.mesh();
|
||||
let base = (positions.len() / 3) as u32;
|
||||
positions.extend(pp);
|
||||
indices.extend(ii.into_iter().map(|i| i + base));
|
||||
@@ -20,30 +20,39 @@ fn merge<'a>(pieces: impl Iterator<Item = &'a Piece>) -> Option<(Vec<f64>, Vec<u
|
||||
(!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.
|
||||
/// Geländer als Netze: je Geländer die Tafeln (Glas, Lochblech, Brüstung; [291] je Füllung der Felder ein Netz) und das
|
||||
/// Gestänge (Pfosten, Stäbe, Schienen, Zwischenholme, 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 });
|
||||
let mut fills: Vec<RailingKind> = vec![r.kind];
|
||||
for q in pcs.iter().filter(|q| q.part == Part::Fill) {
|
||||
if !fills.contains(&q.kind) {
|
||||
fills.push(q.kind);
|
||||
}
|
||||
}
|
||||
for fill in fills.into_iter().map(Some).chain([None]) {
|
||||
let Some((positions, indices)) = merge(pcs.iter().filter(|q| if let Some(k) = fill { q.part == Part::Fill && q.kind == k } else { q.part != Part::Fill })) else { continue };
|
||||
let color = match fill {
|
||||
Some(k) => railing::color_of(p, r, Part::Fill, k),
|
||||
None => railing::color(p, r, 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`.
|
||||
/// Geländer als Prismen-Platten (lotrecht; [291] auf Treppen mit Neigungsebene `slope`) (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, slope: None, source: SlabSource::Railing { index, fill } });
|
||||
let color = railing::color_of(p, r, q.part, q.kind);
|
||||
let fill = (q.part == Part::Fill).then_some(q.kind);
|
||||
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, slope: q.slope, source: SlabSource::Railing { index, fill } });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,12 +41,8 @@ pub(super) fn stair_input<'a>(p: &'a Project, wanted: impl Fn(&Stair, Option<&St
|
||||
buf.push(st.map_or(0.04, |t| t.tread_thickness));
|
||||
buf.push(st.and_then(|t| t.nosing).unwrap_or(0.0));
|
||||
buf.push(if st.is_some_and(|t| t.closed_risers) { 1.0 } else { 0.0 });
|
||||
buf.push(match st.and_then(|t| t.railing) {
|
||||
Some(StairTypeRailing::Links) => 1.0,
|
||||
Some(StairTypeRailing::Rechts) => 2.0,
|
||||
Some(StairTypeRailing::Beide) => 3.0,
|
||||
_ => 0.0,
|
||||
});
|
||||
// [291] Seiten mit gebundenem Geländer ohne eigenen Handlauf (das Geländer zeichnet sich selbst).
|
||||
buf.push(crate::railing::stair_code(p, s) as f64);
|
||||
buf.push(s.center_column.filter(|r| r.is_finite() && *r > 0.0).unwrap_or(0.0));
|
||||
buf.extend(s.rail_params());
|
||||
}
|
||||
|
||||
@@ -27,7 +27,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` |
|
||||
| `railings.rs` | [279] Geländer im Grundriss (Linie/Doppellinie/Fläche je Art, über Schnitt gestrichelt, [291] an der Treppe an der Schnitthöhe geteilt, Pick `@railing:<id>`); Schnitt/Ansicht/Axo über die Platten `model3d::railing_slabs` |
|
||||
| `entourage.rs` | [253] Entourage (3D-Netze der Bibliotheksobjekte) in Schnitt (Umriss, von Bauteilen verdeckt wie Bäume) und Ansicht (gefüllte Silhouetten, Maler-Reihenfolge) |
|
||||
| `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“) |
|
||||
|
||||
@@ -129,10 +129,10 @@ pub(super) fn collect_column_faces(p: &Project, frame: &[f64; 9]) -> Vec<Face> {
|
||||
pub(super) fn collect_railing_faces(p: &Project, frame: &[f64; 9]) -> Vec<Face> {
|
||||
let slabs = model3d::railing_slabs(p);
|
||||
// Glastafeln (Glasgeländer, Teil Tafel) getrennt: durchscheinend, in der Ansicht wie Fensterglas hell.
|
||||
let is_glass = |s: &model3d::RSlab| matches!(s.source, model3d::SlabSource::Railing { index, fill: true } if p.railings.as_deref().and_then(|r| r.get(index)).is_some_and(|r| r.kind == RailingKind::Glass));
|
||||
let is_glass = |s: &model3d::RSlab| matches!(s.source, model3d::SlabSource::Railing { fill: Some(RailingKind::Glass), .. });
|
||||
let (glass, rest): (Vec<_>, Vec<_>) = slabs.into_iter().partition(is_glass);
|
||||
// Lochblechtafeln: Lochmuster (Punktschraffur der Schraffur-Bibliothek, `super::super::railings::perforation_hatch`).
|
||||
let is_perf = |s: &model3d::RSlab| matches!(s.source, model3d::SlabSource::Railing { index, fill: true } if p.railings.as_deref().and_then(|r| r.get(index)).is_some_and(|r| r.kind == RailingKind::Perforated));
|
||||
let is_perf = |s: &model3d::RSlab| matches!(s.source, model3d::SlabSource::Railing { fill: Some(RailingKind::Perforated), .. });
|
||||
let (perf, rest): (Vec<_>, Vec<_>) = rest.into_iter().partition(is_perf);
|
||||
let mut faces = project_faces(frame, &[], &rest, &[]);
|
||||
faces.iter_mut().for_each(|f| f.role = Role::Railing);
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
//! 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).
|
||||
//! - **Stäbe:** eine Linie in der Achse (Handlauf über den Stäben). [291] Pfosten (aller Arten, sofern gesetzt) als kleine
|
||||
//! gefüllte Quadrate ihres Querschnitts (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.
|
||||
@@ -12,6 +13,9 @@
|
||||
//! - **Handlauf über der Schnitthöhe** (Fuss geschnitten, Handlauf darüber): zwei gestrichelte Linien im Abstand der
|
||||
//! Handlaufbreite neben der Achse (`railing-handrail`, wie die Treppen-Handläufe über dem Schnitt).
|
||||
//!
|
||||
//! - **[291] An einer Treppe** (Fuss steigt): die Achse ist an der Schnitthöhe geteilt, der Teil darüber gestrichelt
|
||||
//! (Strich-Punkt) wie Stufen und Handläufe der Treppe darüber.
|
||||
//!
|
||||
//! Pick: unsichtbare Fläche um die Achse (mindestens 4 mm Papier breit) mit `contextObjectId = "@railing:<id>"`.
|
||||
|
||||
use super::domains::Ctx;
|
||||
@@ -57,6 +61,45 @@ fn polyline(out: &mut Vec<Primitive>, pts: &[[f64; 2]], cls: &str, w: f64, color
|
||||
}
|
||||
}
|
||||
|
||||
/// [291] Achse geteilt an der Schnitthöhe (gebunden an eine Treppe steigt der Fuss): Teilzüge mit Bogenlänge (Anfang,
|
||||
/// Ende) und Fusshöhe (tiefste, höchste); waagrecht ein Teil.
|
||||
fn split_at_cut(path: &railing::Path, cut: f64) -> Vec<(Vec<[f64; 2]>, f64, f64, f64, f64)> {
|
||||
let ax = &path.pts;
|
||||
let total = railing::length(ax);
|
||||
if !path.sloped() {
|
||||
let z = path.foot[0];
|
||||
return vec![(ax.clone(), 0.0, total, z, z)];
|
||||
}
|
||||
let mut out: Vec<(Vec<[f64; 2]>, f64, f64, f64, f64)> = Vec::new();
|
||||
let above = |z: f64| z > cut + 1e-9;
|
||||
let mut cur: Vec<[f64; 2]> = vec![ax[0]];
|
||||
let (mut s0, mut acc, mut lo, mut hi) = (0.0, 0.0, path.foot[0], path.foot[0]);
|
||||
let mut state = above(path.foot[0]);
|
||||
for i in 0..ax.len() - 1 {
|
||||
let (a, b, za, zb) = (ax[i], ax[i + 1], path.foot[i], path.foot[i + 1]);
|
||||
let len = crate::jsmath::hypot2(b[0] - a[0], b[1] - a[1]);
|
||||
if above(zb) != state && (zb - za).abs() > 1e-12 {
|
||||
let t = ((cut - za) / (zb - za)).clamp(0.0, 1.0);
|
||||
let m = [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
||||
cur.push(m);
|
||||
// Der Teil über der Schnitthöhe beginnt knapp darüber (sonst gälte er als geschnitten).
|
||||
let edge = |up: bool| if up { cut + 1e-6 } else { cut };
|
||||
out.push((std::mem::replace(&mut cur, vec![m]), s0, acc + t * len, lo.min(edge(state)), hi.max(edge(state))));
|
||||
s0 = acc + t * len;
|
||||
state = !state;
|
||||
lo = edge(state);
|
||||
hi = edge(state);
|
||||
}
|
||||
cur.push(b);
|
||||
lo = lo.min(zb);
|
||||
hi = hi.max(zb);
|
||||
acc += len;
|
||||
}
|
||||
out.push((cur, s0, acc, lo, hi));
|
||||
out.retain(|q| q.0.len() >= 2 && q.2 - q.1 > 1e-9);
|
||||
out
|
||||
}
|
||||
|
||||
/// 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;
|
||||
@@ -66,9 +109,10 @@ pub(super) fn plan_railings(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
}
|
||||
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 {
|
||||
let Some(path) = railing::path(p, r) else { continue };
|
||||
let Some(s) = railing::spec(p, r) else { continue };
|
||||
let ax = &path.pts;
|
||||
if range.classify(s.z0, s.top()) == Zone::Hidden {
|
||||
continue;
|
||||
}
|
||||
let from = out.len();
|
||||
@@ -79,85 +123,45 @@ pub(super) fn plan_railings(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
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 {
|
||||
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));
|
||||
// [291] Pfosten (aller Arten, sofern gesetzt) längs der ganzen Achse.
|
||||
let posts = if s.posts && c.a.scale <= 200.0 { railing::post_stations(&path, &s) } else { Vec::new() };
|
||||
let parts = split_at_cut(&path, range.cut);
|
||||
let whole = parts.len() == 1;
|
||||
for (sub, s_a, s_b, lo, hi) in parts {
|
||||
let zone = range.classify(lo, hi + s.top_rel());
|
||||
if zone == Zone::Hidden {
|
||||
continue;
|
||||
}
|
||||
let from_part = out.len();
|
||||
let closed = whole && crate::stair_rail::is_closed(&sub);
|
||||
draw_axis(c, r, &s, &sub, closed, zone, (lw, color, &stroke, greyed, category, mm), out);
|
||||
let h = s.post_size / 2.0;
|
||||
for st in posts.iter().filter(|st| st.s >= s_a - 1e-9 && st.s <= s_b + 1e-9) {
|
||||
let (pt, d) = (st.at, st.dir);
|
||||
let n = [-d[1], d[0]];
|
||||
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));
|
||||
}
|
||||
// Handlauf ganz über der Schnitthöhe (Fuss geschnitten): gestrichelt neben der Achse, Konvention wie bei den
|
||||
// Treppen (Handlauf über dem Schnitt gestrichelt, Strichmuster „verdeckt“, dünne Linie).
|
||||
if zone == Zone::Cut && s.has_rail() && range.classify(lo + s.rail_top() - s.rail_h(), lo + s.rail_top()) == Zone::Above {
|
||||
let (_, l, rt) = railing::strips(&sub, s.rail_w() / 2.0);
|
||||
for side in [&l, &rt] {
|
||||
polyline(out, side, "railing-handrail", lw * 0.6, &stroke, Some(&super::line_pattern::HIDDEN), 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);
|
||||
}
|
||||
// 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_part, d);
|
||||
}
|
||||
_ => {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Handlauf ganz über der Schnitthöhe (Fuss geschnitten): gestrichelt neben der Achse, Konvention wie bei den Treppen
|
||||
// (Handlauf über dem Schnitt gestrichelt, Strichmuster „verdeckt“, dünne Linie).
|
||||
if zone == Zone::Cut && s.has_rail() && range.classify(s.top() - s.rail_h(), s.top()) == Zone::Above {
|
||||
let (_, l, rt) = railing::strips(&ax, s.rail_w() / 2.0);
|
||||
for side in [&l, &rt] {
|
||||
polyline(out, side, "railing-handrail", lw * 0.6, &stroke, Some(&super::line_pattern::HIDDEN), 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)) {
|
||||
@@ -166,6 +170,63 @@ pub(super) fn plan_railings(c: &Ctx, out: &mut Vec<Primitive>) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Strichstärke, Farbe (Übersteuerung), Strichfarbe, ausgegraut, Klasse, Meter je mm Papier.
|
||||
type Pen<'a> = (f64, Option<&'a str>, &'a str, Option<bool>, Option<&'a crate::model::LayerCategory>, f64);
|
||||
|
||||
/// Zeichen eines (Teil-)Zugs je Art (s. Modulkopf).
|
||||
fn draw_axis(c: &Ctx, r: &Railing, s: &railing::Spec, ax: &[[f64; 2]], closed: bool, zone: Zone, pen: Pen, out: &mut Vec<Primitive>) {
|
||||
let p = c.p;
|
||||
let (lw, color, stroke, greyed, category, mm) = pen;
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -127,7 +127,7 @@ pub enum SlabOwner<'a> {
|
||||
Stair(&'a Stair),
|
||||
Column(&'a Column),
|
||||
/// [279] Geländer; `true` = Tafel (Glas, Lochblech, Brüstung), sonst Gestänge.
|
||||
Railing(&'a Railing, bool),
|
||||
Railing(&'a Railing, Option<RailingKind>),
|
||||
/// [280] Träger.
|
||||
Beam(&'a Beam),
|
||||
}
|
||||
@@ -717,8 +717,8 @@ pub(super) fn attach_cut_styles(cuts: Vec<Cut>, p: &Project, plane: &Plane, wall
|
||||
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) => {
|
||||
match fill {
|
||||
Some(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);
|
||||
@@ -733,7 +733,7 @@ pub(super) fn attach_cut_styles(cuts: Vec<Cut>, p: &Project, plane: &Plane, wall
|
||||
cp.hatch = Some(no_hatch());
|
||||
}
|
||||
}
|
||||
(true, RailingKind::Glass) => {
|
||||
Some(RailingKind::Glass) => {
|
||||
cp.fill = Some("#cfe3ee".to_string());
|
||||
cp.hatch = Some(no_hatch());
|
||||
}
|
||||
|
||||
@@ -374,8 +374,8 @@ pub(crate) fn model_view_faces(p: &Project, vis: &Visibility, view: &dyn Fn([f64
|
||||
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),
|
||||
};
|
||||
let glass = railing && matches!(kind, Kind::Slab) && matches!(slabs.get(i), Some(SlabOwner::Railing(r, true)) if r.kind == RailingKind::Glass);
|
||||
let perforated = railing && matches!(kind, Kind::Slab) && matches!(slabs.get(i), Some(SlabOwner::Railing(r, true)) if r.kind == RailingKind::Perforated);
|
||||
let glass = railing && matches!(kind, Kind::Slab) && matches!(slabs.get(i), Some(SlabOwner::Railing(_, Some(RailingKind::Glass))));
|
||||
let perforated = railing && matches!(kind, Kind::Slab) && matches!(slabs.get(i), Some(SlabOwner::Railing(_, Some(RailingKind::Perforated))));
|
||||
OwnerRef { kind, id, stair, column, railing, glass, perforated }
|
||||
})
|
||||
.collect();
|
||||
|
||||
@@ -29,14 +29,9 @@ fn v2(x: f64, y: f64) -> Vec2 {
|
||||
Vec2 { x, y }
|
||||
}
|
||||
|
||||
/// Geländer-Code des Treppentyps (0 keins, 1 links, 2 rechts, 3 beide).
|
||||
/// Geländer-Code des Treppentyps (0 keins, 1 links, 2 rechts, 3 beide); [291] ohne Seiten mit gebundenem Geländer.
|
||||
fn railing_code(p: &Project, s: &Stair) -> u8 {
|
||||
match p.stair_type(s).and_then(|t| t.railing) {
|
||||
Some(StairTypeRailing::Links) => 1,
|
||||
Some(StairTypeRailing::Rechts) => 2,
|
||||
Some(StairTypeRailing::Beide) => 3,
|
||||
_ => 0,
|
||||
}
|
||||
crate::railing::stair_code(p, s)
|
||||
}
|
||||
|
||||
fn stair_line(a: Vec2, b: Vec2, cls: &str, weight_mm: f64, dash: Option<Option<Vec<f64>>>, stroke: &str, greyed: Option<bool>, id: &str) -> Primitive {
|
||||
|
||||
+537
-72
@@ -1,18 +1,28 @@
|
||||
//! [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
|
||||
//! Terrasse. **Eine Quelle** für die Körper: [`pieces`] zerlegt ein Geländer in Prismen `(Querschnitt, z_unten, z_oben,
|
||||
//! Teil)` wie `model3d::column_pieces` bei den Stützen — lotrecht, auf einer Treppe ([291]) längs einer Teilstrecke
|
||||
//! geschert (`slope`, dieselbe Neigungsebene wie die geneigten Decken [281]). 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).
|
||||
//! - **Achse ([`path`]):** frei die Polylinie `points` (offen; mit `closed` oder letzter = erster Punkt geschlossen);
|
||||
//! [291] gebunden an eine Treppe (`stairId` + `stairSide`) die Handlauf-Achse der Wange aus [`crate::stair_rail::rails`]
|
||||
//! mit Fusshöhe = Handlaufhöhe − [`crate::stair_rail::RAIL_HEIGHT`] (also lotrecht über der Stufenkante), oder an eine
|
||||
//! Deckenkante (`ceilingId` + `edgeIndex`/`edgeCount`, um `edgeInset` nach innen), Fuss auf der Deckenoberkante.
|
||||
//! Die Achse ist eine Ableitung: ändert sich Treppe oder Decke, folgt das Geländer. 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`]).
|
||||
//! - **Aufbau je Feld ([291], Leitbild Archicad):** Pfosten an Ecken und Enden und höchstens `postSpacing` (Vorgabe
|
||||
//! [`POST_GAP`]) auseinander, Querschnitt `postSize`; Feld = Abschnitt zwischen zwei Pfosten (auch ohne sichtbare
|
||||
//! Pfosten). Füllung je Feld (`fields`, sonst `kind`): Stäbe im Achsabstand `barSpacing` (lichtes Mass höchstens
|
||||
//! [`MAX_CLEAR_GAP`] = 12 cm nach SIA 358) mit Fussschiene, oder eine Tafel (Glas, Lochblech, Brüstung) der Dicke
|
||||
//! `thickness`. Zwischenholme (`midRails`) gleich verteilt zwischen Fuss und Handlauf. Handlauf rechteckig oder rund
|
||||
//! (Achteck-Stufen), Oberkante `handrailHeight` (Vorgabe = `height`); ohne Handlauf bei Stäben ein Obergurt.
|
||||
//! - **Höhe:** Fuss = Geschoss-UK + `baseOffset` (gebunden: Treppe bzw. Decke + `baseOffset`), Oberkante = Fuss +
|
||||
//! `height` (Vorgabe [`DEFAULT_HEIGHT`] = 1.00 m).
|
||||
//! - **Treppen-Handläufe:** Hat eine Treppe ein gebundenes Geländer auf einer Seite, entfällt dort ihr eigener Handlauf
|
||||
//! ([`stair_code`]); sonst bleibt die Absturzsicherung der Treppe wie bisher.
|
||||
|
||||
use crate::model::*;
|
||||
use crate::stair_rail::{is_closed, offset_polyline, P};
|
||||
@@ -23,17 +33,24 @@ pub const DEFAULT_HEIGHT: f64 = 1.0;
|
||||
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).
|
||||
/// Pfostenabstand (m, Vorgabe von `postSpacing`) 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;
|
||||
/// [291] Abstand der Achse von einer gebundenen Deckenkante (m, Vorgabe von `edgeInset`).
|
||||
pub const EDGE_INSET: f64 = 0.05;
|
||||
/// 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).
|
||||
/// Pfosten: Kantenlänge (m, Vorgabe von `postSize`); Fussschiene: Breite, Höhe und Lage über dem Fuss (m); Obergurt ohne
|
||||
/// Handlauf (m); Zwischenholm (Kantenlänge, m); höchstens so viele Zwischenholme.
|
||||
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);
|
||||
const MID_RAIL: f64 = 0.02;
|
||||
const MAX_MID_RAILS: u32 = 20;
|
||||
/// [291] Knick (Grad), ab dem eine Treppen-Achse eine Ecke mit Pfosten hat (Wendel, Kropfstück: feine Teilung ohne Pfosten).
|
||||
const STAIR_CORNER_DEG: f64 = 10.0;
|
||||
|
||||
/// Teil eines Geländers (für Farbe, Schnittfüllung und Menge).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
@@ -44,18 +61,53 @@ pub enum Part {
|
||||
Rail,
|
||||
/// Fussschiene.
|
||||
Foot,
|
||||
/// [291] Zwischenholm.
|
||||
Mid,
|
||||
/// Tafel: Glas, Lochblech oder massive Brüstung.
|
||||
Fill,
|
||||
}
|
||||
|
||||
/// Ein lotrechtes Prisma des Geländers.
|
||||
/// Ein Prisma des Geländers (lotrecht; mit `slope` geschert).
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Piece {
|
||||
/// Querschnitt im Grundriss (Gegenuhrzeigersinn).
|
||||
pub outline: Vec<P>,
|
||||
/// Unter- und Oberkante (absolut; mit `slope` am Ursprung der Neigungsebene).
|
||||
pub z0: f64,
|
||||
pub z1: f64,
|
||||
pub part: Part,
|
||||
/// [291] Füllung (Art der Tafel bzw. Stäbe) des Feldes, zu dem das Teil gehört.
|
||||
pub kind: RailingKind,
|
||||
/// [291] Neigungsebene `[ox, oy, gx, gy]` wie `RSlab::slope` (Treppe, geneigte Decke); `None` = waagrecht.
|
||||
pub slope: Option<[f64; 4]>,
|
||||
}
|
||||
|
||||
impl Piece {
|
||||
/// Höhenversatz der Neigungsebene am Grundrisspunkt `q`.
|
||||
pub fn dz(&self, q: P) -> f64 {
|
||||
self.slope.as_ref().map_or(0.0, |g| crate::model::helpers::slope_dz(g, q[0], q[1]))
|
||||
}
|
||||
|
||||
/// Prisma als Netz (Modell x, y, z), geschert nach `slope`.
|
||||
pub fn mesh(&self) -> (Vec<f64>, Vec<u32>) {
|
||||
let (mut pos, idx) = crate::columns3d::prism(&self.outline, self.z0, self.z1);
|
||||
if self.slope.is_some() {
|
||||
for c in pos.chunks_exact_mut(3) {
|
||||
c[2] += self.dz([c[0], c[1]]);
|
||||
}
|
||||
}
|
||||
(pos, idx)
|
||||
}
|
||||
|
||||
/// Tiefste Unter- und höchste Oberkante über den Querschnitt (Hüllprisma, z. B. für den Schatten).
|
||||
pub fn z_span(&self) -> (f64, f64) {
|
||||
let (lo, hi) = self.outline.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(a, b), q| (a.min(self.dz(*q)), b.max(self.dz(*q))));
|
||||
if lo.is_finite() {
|
||||
(self.z0 + lo, self.z1 + hi)
|
||||
} else {
|
||||
(self.z0, self.z1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Aufgelöste Masse eines Geländers (Vorgaben eingesetzt, Unsinn begrenzt).
|
||||
@@ -63,20 +115,57 @@ pub struct Piece {
|
||||
pub struct Spec {
|
||||
pub kind: RailingKind,
|
||||
pub height: f64,
|
||||
/// Absolute Höhe des Fusses.
|
||||
/// Absolute Höhe des Fusses (gebunden an eine Treppe: tiefster Punkt).
|
||||
pub z0: f64,
|
||||
/// [291] Höchster Fusspunkt (waagrecht = `z0`).
|
||||
pub z0_max: 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,
|
||||
/// [291] Oberkante des Handlaufs über dem Fuss (Vorgabe `height`).
|
||||
pub handrail_top: f64,
|
||||
pub round: bool,
|
||||
/// [291] Pfosten sichtbar, grösster Abstand, Querschnitt.
|
||||
pub posts: bool,
|
||||
pub post_gap: f64,
|
||||
pub post_size: f64,
|
||||
pub mid_rails: u32,
|
||||
}
|
||||
|
||||
impl Spec {
|
||||
/// Oberkante (absolut).
|
||||
/// Oberkante (absolut, höchster Punkt).
|
||||
pub fn top(&self) -> f64 {
|
||||
self.z0 + self.height
|
||||
self.z0_max + self.top_rel()
|
||||
}
|
||||
|
||||
/// Oberkante über dem Fuss (Füllung bzw. Handlauf, was höher liegt).
|
||||
pub fn top_rel(&self) -> f64 {
|
||||
if self.handrail {
|
||||
self.height.max(self.handrail_top)
|
||||
} else {
|
||||
self.height
|
||||
}
|
||||
}
|
||||
|
||||
/// Oberkante des Handlaufs bzw. Obergurts über dem Fuss.
|
||||
pub fn rail_top(&self) -> f64 {
|
||||
if self.handrail {
|
||||
self.handrail_top
|
||||
} else {
|
||||
self.height
|
||||
}
|
||||
}
|
||||
|
||||
/// Oberkante der Füllung über dem Fuss: unter einem Handlauf obenauf, sonst `height`.
|
||||
pub fn fill_top(&self) -> f64 {
|
||||
if self.has_rail() && self.rail_top() >= self.height - 1e-9 {
|
||||
self.rail_top() - self.rail_h()
|
||||
} else {
|
||||
self.height
|
||||
}
|
||||
}
|
||||
|
||||
/// Höhe des Handlaufs bzw. Obergurts (die Füllung endet darunter).
|
||||
@@ -120,39 +209,220 @@ pub fn has_handrail(r: &Railing) -> bool {
|
||||
r.handrail.unwrap_or(matches!(r.kind, RailingKind::Bars | RailingKind::Glass))
|
||||
}
|
||||
|
||||
/// Fusshöhe (absolut): Geschoss-UK + `baseOffset`.
|
||||
/// [291] Pfosten sichtbar? Fehlt die Angabe: bei Stäben ja, sonst nein.
|
||||
pub fn has_posts(r: &Railing) -> bool {
|
||||
r.posts.unwrap_or(matches!(r.kind, RailingKind::Bars | RailingKind::Unknown))
|
||||
}
|
||||
|
||||
/// Fusshöhe (absolut) eines freien Geländers: 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)
|
||||
p.floor(&r.floor_id).map_or(0.0, |f| f.base_elevation.unwrap_or(0.0)) + base_offset(r)
|
||||
}
|
||||
|
||||
fn base_offset(r: &Railing) -> f64 {
|
||||
r.base_offset.filter(|v| v.is_finite()).unwrap_or(0.0)
|
||||
}
|
||||
|
||||
/// [291] Woran das Geländer gebunden ist (aufgelöst; fehlt der Träger, gilt die Polylinie `points`).
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Bound {
|
||||
Free,
|
||||
Stair,
|
||||
Edge,
|
||||
}
|
||||
|
||||
/// [291] Aufgelöste Achse: Grundriss-Zug, Fusshöhe (absolut) je Punkt, Art der Bindung und ob jeder Punkt eine Ecke
|
||||
/// mit Pfosten ist (frei und an Deckenkanten ja; Treppe nur ab [`STAIR_CORNER_DEG`] Knick).
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Path {
|
||||
pub pts: Vec<P>,
|
||||
pub foot: Vec<f64>,
|
||||
pub bound: Bound,
|
||||
pub corner_deg: f64,
|
||||
}
|
||||
|
||||
impl Path {
|
||||
/// Geneigt (Fuss nicht überall gleich hoch)?
|
||||
pub fn sloped(&self) -> bool {
|
||||
let (lo, hi) = self.foot.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(a, b), z| (a.min(*z), b.max(*z)));
|
||||
hi - lo > 1e-9
|
||||
}
|
||||
|
||||
/// Fusshöhe bei der Bogenlänge `s` (linear je Teilstrecke).
|
||||
pub fn foot_at(&self, s: f64) -> f64 {
|
||||
let mut acc = 0.0;
|
||||
for (i, w) in self.pts.windows(2).enumerate() {
|
||||
let len = seg_len(w[0], w[1]);
|
||||
if s <= acc + len || i + 2 == self.pts.len() {
|
||||
let t = if len > 1e-12 { ((s - acc) / len).clamp(0.0, 1.0) } else { 0.0 };
|
||||
return self.foot[i] + (self.foot[i + 1] - self.foot[i]) * t;
|
||||
}
|
||||
acc += len;
|
||||
}
|
||||
self.foot.first().copied().unwrap_or(0.0)
|
||||
}
|
||||
}
|
||||
|
||||
fn seg_len(a: P, b: P) -> f64 {
|
||||
crate::jsmath::hypot2(b[0] - a[0], b[1] - a[1])
|
||||
}
|
||||
|
||||
/// [291] Treppe eines gebundenen Geländers (Form bekannt).
|
||||
pub fn bound_stair<'a>(p: &'a Project, r: &Railing) -> Option<&'a Stair> {
|
||||
let id = r.stair_id.as_deref().filter(|s| !s.is_empty())?;
|
||||
p.stairs.as_deref()?.iter().find(|s| s.id == id && s.shape != StairShape::Unknown)
|
||||
}
|
||||
|
||||
/// [291] Decke eines an eine Kante gebundenen Geländers (Umriss mit mindestens drei Punkten).
|
||||
pub fn bound_ceiling<'a>(p: &'a Project, r: &Railing) -> Option<&'a Ceiling> {
|
||||
let id = r.ceiling_id.as_deref().filter(|s| !s.is_empty())?;
|
||||
p.ceilings.as_deref()?.iter().find(|c| c.id == id && c.outline.len() >= 3)
|
||||
}
|
||||
|
||||
/// Geländer-Code der Seite (1 links, 2 rechts in Laufrichtung, wie `stair_rail`).
|
||||
fn side_code(side: Option<RailingSide>) -> u8 {
|
||||
if side == Some(RailingSide::Right) {
|
||||
2
|
||||
} else {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
/// [291] Handlauf-Achse einer Treppenwange (Grundriss, Höhe absolut); `None` ohne ableitbare Geometrie.
|
||||
pub fn stair_side_path(p: &Project, s: &Stair, side: Option<RailingSide>) -> Option<Vec<[f64; 3]>> {
|
||||
let params = crate::stair::decode_params(&s.encode())?;
|
||||
let (zb, zt) = p.stair_vertical_extent(s);
|
||||
if !(zt - zb > 1e-6) {
|
||||
return None;
|
||||
}
|
||||
let geo = kernel2d::stair_geometry(¶ms, zt - zb);
|
||||
let rail = crate::stair_rail::rails(¶ms, &geo, side_code(side)).into_iter().next()?;
|
||||
let mut out: Vec<[f64; 3]> = Vec::with_capacity(rail.path.len());
|
||||
for q in rail.path {
|
||||
if !(q[0].is_finite() && q[1].is_finite() && q[2].is_finite()) {
|
||||
return None;
|
||||
}
|
||||
if out.last().is_some_and(|l| (l[0] - q[0]).abs() < 1e-6 && (l[1] - q[1]).abs() < 1e-6) {
|
||||
continue;
|
||||
}
|
||||
out.push([q[0], q[1], q[2] + zb]);
|
||||
}
|
||||
(out.len() >= 2).then_some(out)
|
||||
}
|
||||
|
||||
/// [291] Kantenzug einer Decke: Kanten `edgeIndex` … `edgeIndex + edgeCount − 1` (alle = geschlossen), um `inset` nach
|
||||
/// innen versetzt.
|
||||
pub fn ceiling_edge_path(c: &Ceiling, edge_index: u32, edge_count: u32, inset: f64) -> Option<Vec<P>> {
|
||||
let n = c.outline.len();
|
||||
if n < 3 || c.outline.iter().any(|q| !(q.x.is_finite() && q.y.is_finite())) {
|
||||
return None;
|
||||
}
|
||||
let i0 = edge_index as usize % n;
|
||||
let cnt = (edge_count as usize).clamp(1, n);
|
||||
let mut pts: Vec<P> = (0..=cnt).map(|k| {
|
||||
let q = &c.outline[(i0 + k) % n];
|
||||
[q.x, q.y]
|
||||
}).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 None;
|
||||
}
|
||||
// Innen = links der Kante bei Gegenuhrzeigersinn.
|
||||
let area: f64 = (0..n).map(|i| {
|
||||
let (a, b) = (&c.outline[i], &c.outline[(i + 1) % n]);
|
||||
a.x * b.y - b.x * a.y
|
||||
}).sum();
|
||||
let d = if area >= 0.0 { inset } else { -inset };
|
||||
let out = if d.abs() > 1e-9 { offset_polyline(&pts, d) } else { pts };
|
||||
out.iter().all(|q| q[0].is_finite() && q[1].is_finite()).then_some(out)
|
||||
}
|
||||
|
||||
/// [291] Aufgelöste Achse (s. Modulkopf); `None` bei Unsinn.
|
||||
pub fn path(p: &Project, r: &Railing) -> Option<Path> {
|
||||
if let Some(s) = bound_stair(p, r) {
|
||||
if let Some(q) = stair_side_path(p, s, r.stair_side) {
|
||||
let off = base_offset(r) - crate::stair_rail::RAIL_HEIGHT;
|
||||
return Some(Path { pts: q.iter().map(|v| [v[0], v[1]]).collect(), foot: q.iter().map(|v| v[2] + off).collect(), bound: Bound::Stair, corner_deg: STAIR_CORNER_DEG });
|
||||
}
|
||||
}
|
||||
if let Some(c) = bound_ceiling(p, r) {
|
||||
let inset = r.edge_inset.filter(|v| v.is_finite()).unwrap_or(EDGE_INSET).clamp(-1.0, 5.0);
|
||||
if let Some(pts) = ceiling_edge_path(c, r.edge_index.unwrap_or(0), r.edge_count.unwrap_or(1), inset) {
|
||||
let top = p.ceiling_vertical_extent(c).1 + base_offset(r);
|
||||
if top.is_finite() {
|
||||
let foot = pts.iter().map(|q| top + c.slope_dz(q[0], q[1])).collect();
|
||||
return Some(Path { pts, foot, bound: Bound::Edge, corner_deg: 0.0 });
|
||||
}
|
||||
}
|
||||
}
|
||||
let pts = axis(r)?;
|
||||
let z = base_z(p, r);
|
||||
z.is_finite().then(|| Path { foot: vec![z; pts.len()], pts, bound: Bound::Free, corner_deg: 0.0 })
|
||||
}
|
||||
|
||||
/// [291] Grundriss-Achse (aufgelöst, s. [`path`]).
|
||||
pub fn axis_of(p: &Project, r: &Railing) -> Option<Vec<P>> {
|
||||
path(p, r).map(|a| a.pts)
|
||||
}
|
||||
|
||||
/// [291] Geländer-Code einer Treppe (0 keins, 1 links, 2 rechts, 3 beide) nach ihrem Typ, ohne die Seiten, an die ein
|
||||
/// Geländer gebunden ist (dessen Darstellung gilt dort).
|
||||
pub fn stair_code(p: &Project, s: &Stair) -> u8 {
|
||||
let code = match p.stair_type(s).and_then(|t| t.railing) {
|
||||
Some(StairTypeRailing::Links) => 1,
|
||||
Some(StairTypeRailing::Rechts) => 2,
|
||||
Some(StairTypeRailing::Beide) => 3,
|
||||
_ => 0,
|
||||
};
|
||||
code & !bound_mask(p, &s.id)
|
||||
}
|
||||
|
||||
/// [291] Seiten einer Treppe mit gebundenem Geländer (Bit 1 links, Bit 2 rechts).
|
||||
pub fn bound_mask(p: &Project, stair_id: &str) -> u8 {
|
||||
p.railings.as_deref().unwrap_or(&[]).iter().filter(|r| r.stair_id.as_deref() == Some(stair_id)).fold(0, |m, r| m | side_code(r.stair_side))
|
||||
}
|
||||
|
||||
/// 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> {
|
||||
spec_on(r, &path(p, r)?)
|
||||
}
|
||||
|
||||
fn spec_on(r: &Railing, path: &Path) -> Option<Spec> {
|
||||
let height = r.height;
|
||||
if !(height.is_finite() && height > 0.0) || height > 20.0 || axis(r).is_none() {
|
||||
if !(height.is_finite() && height > 0.0) || height > 20.0 {
|
||||
return None;
|
||||
}
|
||||
let z0 = base_z(p, r);
|
||||
if !z0.is_finite() {
|
||||
let (z0, z0_max) = path.foot.iter().fold((f64::INFINITY, f64::NEG_INFINITY), |(a, b), z| (a.min(*z), b.max(*z)));
|
||||
if !(z0.is_finite() && z0_max.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);
|
||||
let handrail_size = dim(r.handrail_size, 0.04, 0.02, 0.15).min(height / 2.0);
|
||||
Some(Spec {
|
||||
kind: if r.kind == RailingKind::Unknown { RailingKind::Bars } else { r.kind },
|
||||
height,
|
||||
z0,
|
||||
z0_max,
|
||||
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),
|
||||
handrail_size,
|
||||
handrail_top: dim(r.handrail_height, height, handrail_size.max(0.1), 20.0),
|
||||
round: r.handrail_profile == Some(RailingProfile::Round),
|
||||
posts: has_posts(r),
|
||||
post_gap: dim(r.post_spacing, POST_GAP, 0.2, 20.0),
|
||||
post_size: dim(r.post_size, POST_SIZE, 0.01, 0.3),
|
||||
mid_rails: r.mid_rails.unwrap_or(0).min(MAX_MID_RAILS),
|
||||
})
|
||||
}
|
||||
|
||||
/// 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.
|
||||
/// Achse aus den Punkten `points` als Zug: aufeinanderfolgende gleiche Punkte entfallen, ein geschlossener Zug endet auf
|
||||
/// seinem Anfang; `None` bei weniger als zwei verschiedenen Punkten oder nicht endlichen Koordinaten. Gebundene
|
||||
/// Geländer: [`axis_of`].
|
||||
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 {
|
||||
@@ -176,16 +446,22 @@ pub fn axis(r: &Railing) -> Option<Vec<P>> {
|
||||
|
||||
/// 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()
|
||||
axis.windows(2).map(|w| seg_len(w[0], w[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 (quads, l, r) = seg_quads(axis, half);
|
||||
(quads.into_iter().flatten().collect(), l, r)
|
||||
}
|
||||
|
||||
/// Wie [`strips`], die Vierecke je Teilstrecke (entartete `None`).
|
||||
fn seg_quads(axis: &[P], half: f64) -> (Vec<Option<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()))
|
||||
.map(|q| (area(&q).abs() > 1e-10 && q.iter().all(|v| v[0].is_finite() && v[1].is_finite())).then_some(q))
|
||||
.collect();
|
||||
(quads, l, r)
|
||||
}
|
||||
@@ -202,28 +478,76 @@ fn square(c: P, d: P, s: f64) -> Vec<P> {
|
||||
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)>) {
|
||||
/// Eine Pfosten- oder Stabstelle: Lage, Richtung der Teilstrecke, Bogenlänge ab dem Anfang der Achse.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct Station {
|
||||
pub at: P,
|
||||
pub dir: P,
|
||||
pub s: f64,
|
||||
}
|
||||
|
||||
/// Strecken zwischen zwei Ecken: Bereiche von Teilstrecken-Indizes (frei/Deckenkante: jede Teilstrecke; Treppe: Knick
|
||||
/// ab `corner_deg`).
|
||||
fn runs(axis: &[P], corner_deg: f64) -> Vec<std::ops::Range<usize>> {
|
||||
let nseg = axis.len().saturating_sub(1);
|
||||
let dir = |i: usize| {
|
||||
let (a, b) = (axis[i], axis[i + 1]);
|
||||
let l = seg_len(a, b);
|
||||
(l > 1e-12).then(|| [(b[0] - a[0]) / l, (b[1] - a[1]) / l])
|
||||
};
|
||||
let cos_tol = (corner_deg.to_radians()).cos();
|
||||
let mut out = Vec::new();
|
||||
let mut start = 0;
|
||||
for i in 1..nseg {
|
||||
let corner = corner_deg <= 0.0 || matches!((dir(i - 1), dir(i)), (Some(a), Some(b)) if a[0] * b[0] + a[1] * b[1] < cos_tol);
|
||||
if corner {
|
||||
out.push(start..i);
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
if start < nseg {
|
||||
out.push(start..nseg);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// Pfosten- und Stabstellen längs der Achse. Pfosten an jeder Ecke (s. [`runs`]) und höchstens `post_gap` auseinander
|
||||
/// (gleiche Felder je Strecke), Stäbe gleichmässig dazwischen, nicht nahe an einem Pfosten.
|
||||
pub fn stations(axis: &[P], spec: &Spec) -> (Vec<Station>, Vec<Station>) {
|
||||
stations_with(axis, spec, 0.0)
|
||||
}
|
||||
|
||||
fn stations_with(axis: &[P], spec: &Spec, corner_deg: f64) -> (Vec<Station>, Vec<Station>) {
|
||||
let total = length(axis);
|
||||
let (mut posts, mut bars) = (Vec::new(), Vec::new());
|
||||
if !total.is_finite() || total / POST_GAP > MAX_POSTS {
|
||||
if !total.is_finite() || total / spec.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]);
|
||||
let seg: Vec<f64> = axis.windows(2).map(|w| seg_len(w[0], w[1])).collect();
|
||||
let mut cum = vec![0.0; nseg + 1];
|
||||
for i in 0..nseg {
|
||||
cum[i + 1] = cum[i] + seg[i];
|
||||
}
|
||||
for run in runs(axis, corner_deg) {
|
||||
let len = cum[run.end] - cum[run.start];
|
||||
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;
|
||||
// Stelle beim Anteil `t` der Strecke (eine Teilstrecke: genau linear in `t`).
|
||||
let at = |t: f64| -> Station {
|
||||
let i = if run.len() == 1 { run.start } else { (run.start..run.end).find(|&i| cum[i + 1] >= cum[run.start] + t * len - 1e-12 && seg[i] > 1e-12).unwrap_or(run.end - 1) };
|
||||
let w = (axis[i], axis[i + 1]);
|
||||
let u = if run.len() == 1 { t } else if seg[i] > 1e-12 { ((cum[run.start] + t * len - cum[i]) / seg[i]).clamp(0.0, 1.0) } else { 0.0 };
|
||||
let l = seg[i].max(1e-12);
|
||||
Station { at: [w.0[0] + (w.1[0] - w.0[0]) * u, w.0[1] + (w.1[1] - w.0[1]) * u], dir: [(w.1[0] - w.0[0]) / l, (w.1[1] - w.0[1]) / l], s: cum[i] + u * seg[i] }
|
||||
};
|
||||
let n_post = (len / spec.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));
|
||||
for k in 0..n_post + usize::from(run.end == nseg && !closed) {
|
||||
posts.push(at(k as f64 / n_post as f64));
|
||||
}
|
||||
if with_bars {
|
||||
let n_bar = (len / spec.bar_spacing).round().max(1.0) as usize;
|
||||
@@ -231,8 +555,8 @@ pub fn stations(axis: &[P], spec: &Spec) -> (Vec<(P, P)>, Vec<(P, P)>) {
|
||||
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));
|
||||
if f.min(1.0 - f) * gap > spec.post_size / 2.0 + spec.bar_size / 2.0 + 0.01 {
|
||||
bars.push(at(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -240,54 +564,186 @@ pub fn stations(axis: &[P], spec: &Spec) -> (Vec<(P, P)>, Vec<(P, P)>) {
|
||||
(posts, bars)
|
||||
}
|
||||
|
||||
/// [291] Pfostenstellen einer aufgelösten Achse (Ecken nach ihrer Bindung).
|
||||
pub fn post_stations(path: &Path, spec: &Spec) -> Vec<Station> {
|
||||
stations_with(&path.pts, spec, path.corner_deg).0
|
||||
}
|
||||
|
||||
/// [291] Feld-Nummer an der Bogenlänge `s` (Pfosten-Stellen `posts`, aufsteigend).
|
||||
fn field_of(posts: &[Station], s: f64) -> usize {
|
||||
posts.iter().filter(|q| q.s <= s + 1e-9).count().saturating_sub(1)
|
||||
}
|
||||
|
||||
/// 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 }));
|
||||
let Some(path) = path(p, r) else { return Vec::new() };
|
||||
let Some(s) = spec_on(r, &path) else { return Vec::new() };
|
||||
let ax = &path.pts;
|
||||
let sloped = path.sloped();
|
||||
let (posts, bars) = stations_with(ax, &s, path.corner_deg);
|
||||
let overrides: Vec<(usize, RailingKind)> = r.fields.iter().flatten().filter(|f| f.kind != RailingKind::Unknown).map(|f| (f.index as usize, f.kind)).collect();
|
||||
let kind_at = |sv: f64| -> RailingKind {
|
||||
if overrides.is_empty() {
|
||||
return s.kind;
|
||||
}
|
||||
let k = field_of(&posts, sv);
|
||||
overrides.iter().rev().find(|(i, _)| *i == k).map_or(s.kind, |(_, kind)| *kind)
|
||||
};
|
||||
let nseg = ax.len() - 1;
|
||||
let mut cum = vec![0.0; nseg + 1];
|
||||
for i in 0..nseg {
|
||||
cum[i + 1] = cum[i] + seg_len(ax[i], ax[i + 1]);
|
||||
}
|
||||
// Teilstrecke i: Neigungsebene und Fusshöhe an ihrem Anfang.
|
||||
let seg_base = |i: usize| -> (f64, Option<[f64; 4]>) {
|
||||
if !sloped {
|
||||
return (s.z0, None);
|
||||
}
|
||||
let (a, b) = (ax[i], ax[i + 1]);
|
||||
let (za, zb) = (path.foot[i], path.foot[i + 1]);
|
||||
let l2 = (b[0] - a[0]).powi(2) + (b[1] - a[1]).powi(2);
|
||||
if (zb - za).abs() < 1e-12 || l2 < 1e-18 {
|
||||
return (za, None);
|
||||
}
|
||||
let k = (zb - za) / l2;
|
||||
(za, Some([a[0], a[1], k * (b[0] - a[0]), k * (b[1] - a[1])]))
|
||||
};
|
||||
// Teilbereiche [ta, tb] je Teilstrecke mit gleicher Füllung (ohne Abweichungen je Feld: die ganze Teilstrecke).
|
||||
let spans: Vec<Vec<(f64, f64, RailingKind)>> = (0..nseg)
|
||||
.map(|i| {
|
||||
let (s0, s1) = (cum[i], cum[i + 1]);
|
||||
if overrides.is_empty() || s1 - s0 < 1e-12 {
|
||||
return vec![(0.0, 1.0, s.kind)];
|
||||
}
|
||||
let mut cuts: Vec<f64> = vec![s0];
|
||||
cuts.extend(posts.iter().map(|q| q.s).filter(|&v| v > s0 + 1e-9 && v < s1 - 1e-9));
|
||||
cuts.push(s1);
|
||||
let mut out: Vec<(f64, f64, RailingKind)> = Vec::new();
|
||||
for w in cuts.windows(2) {
|
||||
let k = kind_at((w[0] + w[1]) / 2.0);
|
||||
let (ta, tb) = ((w[0] - s0) / (s1 - s0), (w[1] - s0) / (s1 - s0));
|
||||
match out.last_mut() {
|
||||
Some(l) if l.2 == k => l.1 = tb,
|
||||
_ => out.push((ta, tb, k)),
|
||||
}
|
||||
}
|
||||
if let Some(l) = out.last_mut() {
|
||||
l.1 = 1.0;
|
||||
}
|
||||
out
|
||||
})
|
||||
.collect();
|
||||
let lerp = |a: P, b: P, t: f64| [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
|
||||
let sub = |q: &[P], ta: f64, tb: f64| -> Vec<P> {
|
||||
if ta <= 0.0 && tb >= 1.0 {
|
||||
q.to_vec()
|
||||
} else {
|
||||
vec![lerp(q[0], q[1], ta), lerp(q[0], q[1], tb), lerp(q[3], q[2], tb), lerp(q[3], q[2], ta)]
|
||||
}
|
||||
};
|
||||
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);
|
||||
// Streifen der Breite 2·half von rel0 bis rel1 über dem Fuss, nur in Teilbereichen, deren Füllung `want` erfüllt.
|
||||
let strip_pieces = |half: f64, rel0: f64, rel1: f64, part: Part, want: &dyn Fn(RailingKind) -> bool, out: &mut Vec<Piece>| {
|
||||
if rel1 - rel0 <= 1e-6 {
|
||||
return;
|
||||
}
|
||||
let quads = seg_quads(ax, half).0;
|
||||
for (i, q) in quads.iter().enumerate() {
|
||||
let Some(q) = q else { continue };
|
||||
let (base, slope) = seg_base(i);
|
||||
for &(ta, tb, kind) in &spans[i] {
|
||||
if want(kind) && tb - ta > 1e-9 {
|
||||
out.push(Piece { outline: sub(q, ta, tb), z0: base + rel0, z1: base + rel1, part, kind, slope });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let is_bars = |k: RailingKind| matches!(k, RailingKind::Bars | RailingKind::Unknown);
|
||||
let mut out = Vec::new();
|
||||
let fill_top = s.fill_top();
|
||||
let post_top = if s.has_rail() { fill_top.max(s.rail_top() - s.rail_h()) } else { fill_top };
|
||||
let foot = |st: &Station| if sloped { path.foot_at(st.s) } else { s.z0 };
|
||||
if s.posts {
|
||||
for st in &posts {
|
||||
let z = foot(st);
|
||||
out.push(Piece { outline: square(st.at, st.dir, s.post_size), z0: z, z1: z + post_top, part: Part::Post, kind: kind_at(st.s), slope: None });
|
||||
}
|
||||
}
|
||||
for st in bars.iter().filter(|st| is_bars(kind_at(st.s))) {
|
||||
let z = foot(st);
|
||||
out.push(Piece { outline: square(st.at, st.dir, s.bar_size), z0: z + FOOT_Z.1, z1: z + fill_top, part: Part::Bar, kind: RailingKind::Bars, slope: None });
|
||||
}
|
||||
strip_pieces(FOOT_W / 2.0, FOOT_Z.0, FOOT_Z.1, Part::Foot, &is_bars, &mut out);
|
||||
// Tafeln je Füllung (eigene Dicke, wenn die Füllung des Feldes von `kind` abweicht).
|
||||
for k in [RailingKind::Glass, RailingKind::Solid, RailingKind::Perforated] {
|
||||
let th = if k == s.kind { s.thickness } else { default_thickness(k) };
|
||||
strip_pieces(th / 2.0, 0.0, fill_top, Part::Fill, &|x| x == k, &mut out);
|
||||
}
|
||||
if s.mid_rails > 0 {
|
||||
let lo = if is_bars(s.kind) { FOOT_Z.1 } else { 0.0 };
|
||||
let n = s.mid_rails;
|
||||
for k in 1..=n {
|
||||
let zc = lo + (fill_top - lo) * k as f64 / (n + 1) as f64;
|
||||
strip_pieces(MID_RAIL / 2.0, zc - MID_RAIL / 2.0, zc + MID_RAIL / 2.0, Part::Mid, &|_| true, &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);
|
||||
let (top, h, w) = (s.rail_top(), s.rail_h(), s.rail_w());
|
||||
if s.round && s.handrail {
|
||||
// Rund: drei Stufen (Achteck angenähert), damit die Körper Prismen bleiben.
|
||||
for (a, b, f) in [(0.0, 0.25, 0.7), (0.25, 0.75, 1.0), (0.75, 1.0, 0.7)] {
|
||||
strip_pieces(w * f / 2.0, top - h + a * h, top - h + b * h, Part::Rail, &|_| true, &mut out);
|
||||
}
|
||||
} else {
|
||||
strip_pieces(w / 2.0, top - h, top, Part::Rail, &|_| true, &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())
|
||||
/// [291] Hülle für die Auswahl: je Teilstrecke ein Streifen der halben Breite `half` von Fuss bis Oberkante
|
||||
/// `(Umriss, z_unten, z_oben, Neigungsebene)`.
|
||||
pub fn hull(p: &Project, r: &Railing, half: f64) -> Vec<(Vec<P>, f64, f64, Option<[f64; 4]>)> {
|
||||
let Some(path) = path(p, r) else { return Vec::new() };
|
||||
let Some(s) = spec_on(r, &path) else { return Vec::new() };
|
||||
let ax = &path.pts;
|
||||
seg_quads(ax, half)
|
||||
.0
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.filter_map(|(i, q)| {
|
||||
let q = q?;
|
||||
let (a, b, za, zb) = (ax[i], ax[i + 1], path.foot[i], path.foot[i + 1]);
|
||||
let l2 = (b[0] - a[0]).powi(2) + (b[1] - a[1]).powi(2);
|
||||
let slope = ((zb - za).abs() > 1e-12 && l2 > 1e-18).then(|| {
|
||||
let k = (zb - za) / l2;
|
||||
[a[0], a[1], k * (b[0] - a[0]), k * (b[1] - a[1])]
|
||||
});
|
||||
Some((q, za, za + s.top_rel(), slope))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// 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.
|
||||
/// Anzahl Stäbe und Pfosten (Kennzahl der Objekt-Info).
|
||||
pub fn counts(p: &Project, r: &Railing) -> (usize, usize) {
|
||||
let pcs = pieces(p, r);
|
||||
(pcs.iter().filter(|q| q.part == Part::Bar).count(), pcs.iter().filter(|q| q.part == Part::Post).count())
|
||||
}
|
||||
|
||||
/// Kennzahlen für die Objekt-Info: Länge der Achse, absolute Fuss- und Oberkante, Stäbe, Pfosten, Fläche der Ansicht (m²),
|
||||
/// [291] Felder, Bindung (`"stair"`, `"edge"` oder `null`) und aufgelöste Achse `axis` (`[[x, y], …]`); `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 path = path(p, r)?;
|
||||
let s = spec_on(r, &path)?;
|
||||
let len = length(&path.pts);
|
||||
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)}))
|
||||
let fields = stations_with(&path.pts, &s, path.corner_deg).0.len().saturating_sub(usize::from(!is_closed(&path.pts)));
|
||||
let bound = match path.bound {
|
||||
Bound::Stair => serde_json::json!("stair"),
|
||||
Bound::Edge => serde_json::json!("edge"),
|
||||
Bound::Free => serde_json::Value::Null,
|
||||
};
|
||||
Some(serde_json::json!({"length": len, "baseZ": s.z0, "topZ": s.top(), "height": s.height, "bars": bars, "posts": posts, "fields": fields, "area": len * s.height, "closed": is_closed(&path.pts), "bound": bound, "axis": path.pts}))
|
||||
}
|
||||
|
||||
/// Anzeigename für Regeln und Listen (`railing_label`): Art und Länge.
|
||||
@@ -304,8 +760,13 @@ pub fn label(r: &Railing) -> String {
|
||||
|
||||
/// 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] {
|
||||
color_of(p, r, part, r.kind)
|
||||
}
|
||||
|
||||
/// [291] Farbe eines Teils mit der Füllung `kind` seines Feldes.
|
||||
pub fn color_of(p: &Project, r: &Railing, part: Part, kind: RailingKind) -> [f64; 3] {
|
||||
let hex = |h: &str, d: [f64; 3]| crate::style::hex_to_rgb(h, d);
|
||||
match (r.kind, part) {
|
||||
match (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) => {
|
||||
@@ -414,3 +875,7 @@ mod tests {
|
||||
#[cfg(test)]
|
||||
#[path = "railing_tests.rs"]
|
||||
mod view_tests;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "railing_bound_tests.rs"]
|
||||
mod bound_tests;
|
||||
@@ -0,0 +1,257 @@
|
||||
//! [291] Geländer-Aufbau je Feld (Pfosten, Handlauf, Zwischenholme, Füllung je Feld) und gebundene Geländer (Treppe,
|
||||
//! Deckenkante): Pfostenverteilung, Ecken, Treppe bzw. Decke ändern ⇒ Geländer folgt, Treppen-Handlauf nicht doppelt,
|
||||
//! Rundreise Projektdatei.
|
||||
|
||||
use super::*;
|
||||
use serde_json::{json, Value};
|
||||
|
||||
fn project(rails: Value) -> Project {
|
||||
serde_json::from_value(json!({
|
||||
"id": "p", "name": "P", "lineStyles": [], "hatches": [], "components": [], "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": 2.8, "cutHeight": 1.0, "baseElevation": 0.0},
|
||||
{"id": "og", "name": "OG", "kind": "floor", "visible": true, "locked": false, "floorHeight": 2.8, "cutHeight": 1.0, "baseElevation": 3.0}],
|
||||
"walls": [], "openings": [], "drawings2d": [],
|
||||
"stairTypes": [{"id": "st", "name": "Beton", "structure": "beton", "closedRisers": true, "treadThickness": 0.04, "railing": "beide", "defaultWidth": 1.2}],
|
||||
"stairs": [{"id": "t1", "type": "stair", "floorId": "eg", "categoryCode": "40", "shape": "straight", "start": {"x": 0, "y": 0}, "dir": {"x": 1, "y": 0}, "runLength": 4.2, "width": 1.2, "stepCount": 16, "typeId": "st"}],
|
||||
"ceilings": [{"id": "b1", "type": "ceiling", "floorId": "eg", "categoryCode": "30", "outline": [{"x": 10, "y": 0}, {"x": 14, "y": 0}, {"x": 14, "y": 2}, {"x": 10, "y": 2}], "thickness": 0.2}],
|
||||
"railings": rails
|
||||
}))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
fn rail(extra: Value) -> Value {
|
||||
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": "bars"});
|
||||
for (k, v) in extra.as_object().unwrap() {
|
||||
r[k] = v.clone();
|
||||
}
|
||||
r
|
||||
}
|
||||
|
||||
fn n(pcs: &[Piece], part: Part) -> usize {
|
||||
pcs.iter().filter(|q| q.part == part).count()
|
||||
}
|
||||
|
||||
fn center(q: &Piece) -> P {
|
||||
let k = q.outline.len() as f64;
|
||||
[q.outline.iter().map(|v| v[0]).sum::<f64>() / k, q.outline.iter().map(|v| v[1]).sum::<f64>() / k]
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pfosten_verteilung_abstand_und_querschnitt() {
|
||||
// 4 m mit Abstand höchstens 1.0 → 4 Felder, 5 Pfosten; mit 1.5 → 3 Felder, 4 Pfosten.
|
||||
let p = project(json!([rail(json!({"postSpacing": 1.0, "postSize": 0.05}))]));
|
||||
let r = &p.railings.as_ref().unwrap()[0];
|
||||
let pcs = pieces(&p, r);
|
||||
assert_eq!(n(&pcs, Part::Post), 5);
|
||||
let post = pcs.iter().find(|q| q.part == Part::Post).unwrap();
|
||||
assert!((area(&post.outline) - 0.0025).abs() < 1e-9);
|
||||
let p = project(json!([rail(json!({"postSpacing": 1.5}))]));
|
||||
assert_eq!(n(&pieces(&p, &p.railings.as_ref().unwrap()[0]), Part::Post), 4);
|
||||
// Glas ohne Angabe: keine Pfosten; mit `posts` ja (4 m, Vorgabe 1.20 → 4 Felder, 5 Pfosten).
|
||||
let p = project(json!([rail(json!({"kind": "glass"})), rail(json!({"id": "h", "kind": "glass", "posts": true}))]));
|
||||
let rs = p.railings.as_ref().unwrap();
|
||||
assert_eq!(n(&pieces(&p, &rs[0]), Part::Post), 0);
|
||||
assert_eq!(n(&pieces(&p, &rs[1]), Part::Post), 5);
|
||||
assert_eq!(info(&p, "h").unwrap()["fields"], json!(4));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pfosten_an_ecken_und_enden() {
|
||||
// L-Zug 2 m + 1 m: Ecke und beide Enden tragen einen Pfosten; 2 m → 2 Felder, 1 m → 1 Feld: 4 Pfosten.
|
||||
let p = project(json!([rail(json!({"points": [{"x": 0, "y": 0}, {"x": 2, "y": 0}, {"x": 2, "y": 1}]}))]));
|
||||
let pcs = pieces(&p, &p.railings.as_ref().unwrap()[0]);
|
||||
let centers: Vec<P> = pcs.iter().filter(|q| q.part == Part::Post).map(center).collect();
|
||||
assert_eq!(centers.len(), 4);
|
||||
for want in [[0.0, 0.0], [2.0, 0.0], [2.0, 1.0]] {
|
||||
assert!(centers.iter().any(|c| (c[0] - want[0]).abs() < 1e-9 && (c[1] - want[1]).abs() < 1e-9), "{want:?} {centers:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn handlauf_rund_hoehe_und_zwischenholme() {
|
||||
let p = project(json!([rail(json!({"kind": "glass", "handrailProfile": "round", "handrailHeight": 1.1, "midRails": 2}))]));
|
||||
let pcs = pieces(&p, &p.railings.as_ref().unwrap()[0]);
|
||||
// Rund: drei Stufen; Oberkante 1.1, Glas bis 1.06 (unter dem Handlauf obenauf).
|
||||
assert_eq!(n(&pcs, Part::Rail), 3);
|
||||
let top = pcs.iter().map(|q| q.z1).fold(f64::MIN, f64::max);
|
||||
assert!((top - 1.1).abs() < 1e-9, "{top}");
|
||||
let fill = pcs.iter().find(|q| q.part == Part::Fill).unwrap();
|
||||
assert!((fill.z1 - 1.06).abs() < 1e-9, "{}", fill.z1);
|
||||
assert_eq!(n(&pcs, Part::Mid), 2);
|
||||
// Handlauf tiefer als die Füllung: Füllung bis `height`.
|
||||
let p = project(json!([rail(json!({"kind": "solid", "handrail": true, "handrailHeight": 0.9}))]));
|
||||
let pcs = pieces(&p, &p.railings.as_ref().unwrap()[0]);
|
||||
assert!((pcs.iter().find(|q| q.part == Part::Fill).unwrap().z1 - 1.0).abs() < 1e-9);
|
||||
assert!((pcs.iter().find(|q| q.part == Part::Rail).unwrap().z1 - 0.9).abs() < 1e-9);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fuellung_je_feld() {
|
||||
// Stabgeländer 4 m (4 Felder à 1 m), Feld 1 Glas, Feld 3 Brüstung: Stäbe nur in den Feldern 0 und 2.
|
||||
let p = project(json!([rail(json!({"postSpacing": 1.0, "fields": [{"index": 1, "kind": "glass"}, {"index": 3, "kind": "solid"}]}))]));
|
||||
let pcs = pieces(&p, &p.railings.as_ref().unwrap()[0]);
|
||||
let fills: Vec<&Piece> = pcs.iter().filter(|q| q.part == Part::Fill).collect();
|
||||
assert_eq!(fills.len(), 2);
|
||||
let xr = |q: &Piece| q.outline.iter().fold((f64::MAX, f64::MIN), |(a, b), v| (a.min(v[0]), b.max(v[0])));
|
||||
let g = fills.iter().find(|q| q.kind == RailingKind::Glass).unwrap();
|
||||
assert!((xr(g).0 - 1.0).abs() < 1e-9 && (xr(g).1 - 2.0).abs() < 1e-9, "{:?}", xr(g));
|
||||
let s = fills.iter().find(|q| q.kind == RailingKind::Solid).unwrap();
|
||||
assert!((xr(s).0 - 3.0).abs() < 1e-9);
|
||||
assert!(n(&pcs, Part::Bar) > 10);
|
||||
for b in pcs.iter().filter(|q| q.part == Part::Bar) {
|
||||
let x = center(b)[0];
|
||||
assert!(x < 1.0 || (2.0..3.0).contains(&x), "{x}");
|
||||
}
|
||||
// Fussschiene nur unter Stäben.
|
||||
assert!(pcs.iter().filter(|q| q.part == Part::Foot).all(|q| xr(q).1 <= 1.0 + 1e-9 || (xr(q).0 >= 2.0 - 1e-9 && xr(q).1 <= 3.0 + 1e-9)));
|
||||
// Ohne Abweichung je Feld: dieselben Teile wie vor [291] (ein Streifen je Teilstrecke).
|
||||
let p = project(json!([rail(json!({}))]));
|
||||
let pcs = pieces(&p, &p.railings.as_ref().unwrap()[0]);
|
||||
assert_eq!((n(&pcs, Part::Foot), n(&pcs, Part::Rail), n(&pcs, Part::Fill), n(&pcs, Part::Mid)), (1, 1, 0, 0));
|
||||
}
|
||||
|
||||
fn stair_rail(side: &str) -> Value {
|
||||
rail(json!({"id": "gt", "stairId": "t1", "stairSide": side, "points": [{"x": 0, "y": 0}, {"x": 1, "y": 0}]}))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn treppe_bindet_achse_und_steigung() {
|
||||
let mut p = project(json!([stair_rail("left")]));
|
||||
let r = p.railings.as_ref().unwrap()[0].clone();
|
||||
let path = path(&p, &r).unwrap();
|
||||
assert_eq!(path.bound, Bound::Stair);
|
||||
assert!(path.sloped());
|
||||
// Achse längs der linken Wange (y > 0 bei Laufrichtung +x), Fuss steigt von etwa 0 auf etwa 2.8.
|
||||
assert!(path.pts.iter().all(|q| q[1] > 0.4), "{:?}", path.pts);
|
||||
let (lo, hi) = (path.foot.iter().cloned().fold(f64::MAX, f64::min), path.foot.iter().cloned().fold(f64::MIN, f64::max));
|
||||
assert!(lo < 0.4 && hi > 2.4, "{lo} {hi}");
|
||||
// Höhe lotrecht über der Stufenkante: Pfosten stehen auf dem Fuss, Oberkante = Fuss + Höhe.
|
||||
let pcs = pieces(&p, &r);
|
||||
assert!(n(&pcs, Part::Post) >= 4);
|
||||
assert!(pcs.iter().filter(|q| q.part == Part::Rail).any(|q| q.slope.is_some()));
|
||||
for q in pcs.iter().filter(|q| q.part == Part::Post) {
|
||||
let c = center(q);
|
||||
let s = path.pts.windows(2).scan(0.0, |acc, w| {
|
||||
let l = seg_len(w[0], w[1]);
|
||||
let t = ((c[0] - w[0][0]) * (w[1][0] - w[0][0]) + (c[1] - w[0][1]) * (w[1][1] - w[0][1])) / (l * l);
|
||||
let here = (0.0..=1.0).contains(&t).then(|| *acc + t * l);
|
||||
*acc += l;
|
||||
Some(here)
|
||||
}).flatten().next().unwrap();
|
||||
assert!((q.z0 - path.foot_at(s)).abs() < 1e-9);
|
||||
}
|
||||
let len0 = length(&path.pts);
|
||||
// Treppe ändern (länger, anders gerichtet) ⇒ Geländer folgt.
|
||||
{
|
||||
let s = &mut p.stairs.as_mut().unwrap()[0];
|
||||
s.run_length = 5.0;
|
||||
s.dir = Vec2 { x: 0.0, y: 1.0 };
|
||||
}
|
||||
let path2 = super::path(&p, &r).unwrap();
|
||||
assert!(path2.pts.iter().all(|q| q[0] < -0.4), "{:?}", path2.pts);
|
||||
assert!(length(&path2.pts) > len0 + 0.5);
|
||||
// Rechte Seite: andere Wange.
|
||||
let p = project(json!([stair_rail("right")]));
|
||||
let path = super::path(&p, &p.railings.as_ref().unwrap()[0]).unwrap();
|
||||
assert!(path.pts.iter().all(|q| q[1] < -0.4));
|
||||
// Treppe fehlt: Ersatz `points`, waagrecht.
|
||||
let p = project(json!([rail(json!({"stairId": "weg"}))]));
|
||||
let path = super::path(&p, &p.railings.as_ref().unwrap()[0]).unwrap();
|
||||
assert_eq!(path.bound, Bound::Free);
|
||||
assert!(!path.sloped());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn treppen_handlauf_nicht_doppelt() {
|
||||
let p0 = project(json!([]));
|
||||
assert_eq!(stair_code(&p0, &p0.stairs.as_ref().unwrap()[0]), 3);
|
||||
let p = project(json!([stair_rail("left")]));
|
||||
assert_eq!(stair_code(&p, &p.stairs.as_ref().unwrap()[0]), 2);
|
||||
let p = project(json!([stair_rail("left"), rail(json!({"id": "g2", "stairId": "t1", "stairSide": "right"}))]));
|
||||
assert_eq!(stair_code(&p, &p.stairs.as_ref().unwrap()[0]), 0);
|
||||
// 3D: ohne gebundene Geländer Handlauf-Rohre der Treppe, mit beiden Seiten gebunden keine mehr.
|
||||
assert!(!crate::model3d::emit_stair_handrails(&p0).is_empty());
|
||||
assert!(crate::model3d::emit_stair_handrails(&p).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deckenkante_bindet_und_folgt() {
|
||||
let mut p = project(json!([rail(json!({"id": "gb", "floorId": "og", "ceilingId": "b1", "edgeIndex": 0, "edgeCount": 3}))]));
|
||||
let r = p.railings.as_ref().unwrap()[0].clone();
|
||||
let path = path(&p, &r).unwrap();
|
||||
assert_eq!(path.bound, Bound::Edge);
|
||||
// Kanten 0..2: (10,0)→(14,0)→(14,2)→(10,2), um 5 cm nach innen.
|
||||
assert_eq!(path.pts.len(), 4);
|
||||
assert!((path.pts[0][1] - 0.05).abs() < 1e-9 && (path.pts[1][0] - 13.95).abs() < 1e-9 && (path.pts[3][1] - 1.95).abs() < 1e-9, "{:?}", path.pts);
|
||||
// Fuss auf der Deckenoberkante (EG 0 + 2.8).
|
||||
let s = spec(&p, &r).unwrap();
|
||||
assert!((s.z0 - 2.8).abs() < 1e-9, "{}", s.z0);
|
||||
// Pfosten an allen Ecken und Enden.
|
||||
let posts: Vec<P> = pieces(&p, &r).iter().filter(|q| q.part == Part::Post).map(center).collect();
|
||||
for c in &path.pts {
|
||||
assert!(posts.iter().any(|q| (q[0] - c[0]).abs() < 1e-9 && (q[1] - c[1]).abs() < 1e-9), "{c:?}");
|
||||
}
|
||||
// Decke ändern ⇒ Geländer folgt.
|
||||
p.ceilings.as_mut().unwrap()[0].outline[1].x = 16.0;
|
||||
p.ceilings.as_mut().unwrap()[0].outline[2].x = 16.0;
|
||||
let path2 = super::path(&p, &r).unwrap();
|
||||
assert!((path2.pts[1][0] - 15.95).abs() < 1e-9);
|
||||
// Alle Kanten: geschlossen.
|
||||
let p = project(json!([rail(json!({"ceilingId": "b1", "edgeIndex": 2, "edgeCount": 4}))]));
|
||||
assert!(is_closed(&super::path(&p, &p.railings.as_ref().unwrap()[0]).unwrap().pts));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn grundriss_treppe_ueber_schnitt_gestrichelt() {
|
||||
use crate::plan::domains::{plan_domains, PlanArgs};
|
||||
use crate::plan::prim::Primitive;
|
||||
let p = project(json!([stair_rail("left")]));
|
||||
let text = json!({"floor": "eg", "show": ["41"], "scale": 50, "global": true}).to_string();
|
||||
let prims = plan_domains(&p, &PlanArgs::parse(50.0, &text).unwrap()).unwrap().columns;
|
||||
let lines: Vec<bool> = prims.iter().filter_map(|q| match q {
|
||||
Primitive::Line { cls, dash, .. } if cls == "railing-bars" => Some(matches!(dash, Some(Some(_)))),
|
||||
_ => None,
|
||||
}).collect();
|
||||
// Unter der Schnitthöhe (Fuss < 1.0) ausgezogen, darüber gestrichelt.
|
||||
assert!(lines.iter().any(|d| !d) && lines.iter().any(|d| *d), "{lines:?}");
|
||||
assert!(prims.iter().any(|q| matches!(q, Primitive::Polygon { context_object_id: Some(id), .. } if id == "@railing:gt")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn befehl_an_treppe_und_kante() {
|
||||
let p = project(json!([]));
|
||||
let root: serde_json::Map<String, Value> = serde_json::from_value(serde_json::to_value(&p).unwrap()).unwrap();
|
||||
let ops = |pt: [f64; 2]| crate::cmd_create::ops(&root, &p, &json!({"cmd": "railing", "bind": true, "pts": [pt], "kind": "glass", "ctx": {"level": "eg", "floorHeight": 2.8, "cat": "20", "wallType": "t"}, "stamp": "s"})).unwrap();
|
||||
let item = |o: Vec<crate::ops::Op>| match o.into_iter().next() {
|
||||
Some(crate::ops::Op::Add { items, .. }) => items[0].clone(),
|
||||
other => panic!("erwartet Add, war {other:?}"),
|
||||
};
|
||||
// Klick nahe der rechten Wange (y ≈ −0.6): rechte Seite der Treppe t1.
|
||||
let it = item(ops([2.0, -0.5]));
|
||||
assert_eq!((it["stairId"].as_str(), it["stairSide"].as_str(), it["floorId"].as_str()), (Some("t1"), Some("right"), Some("eg")));
|
||||
assert!(it["points"].as_array().unwrap().len() >= 2);
|
||||
// Klick auf die obere Deckenkante (y = 2, Kante 2).
|
||||
let it = item(ops([12.0, 2.1]));
|
||||
assert_eq!((it["ceilingId"].as_str(), it["edgeIndex"].as_f64()), (Some("b1"), Some(2.0)));
|
||||
// Nichts in Reichweite: keine Op.
|
||||
assert!(ops([30.0, 30.0]).is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rundreise_projektdatei() {
|
||||
let p = project(json!([
|
||||
stair_rail("right"),
|
||||
rail(json!({"id": "gb", "ceilingId": "b1", "edgeIndex": 1, "edgeCount": 2, "edgeInset": 0.1, "posts": true, "postSpacing": 1.1, "postSize": 0.04, "midRails": 3, "handrailProfile": "round", "handrailHeight": 0.95, "fields": [{"index": 0, "kind": "glass"}]}))
|
||||
]));
|
||||
let text = serde_json::to_string(&p).unwrap();
|
||||
let back: Project = serde_json::from_str(&text).unwrap();
|
||||
assert_eq!(back.railings, p.railings);
|
||||
let v: Value = serde_json::from_str(&text).unwrap();
|
||||
let r = &v["railings"][1];
|
||||
assert_eq!((r["ceilingId"].as_str(), r["edgeCount"].as_u64(), r["handrailProfile"].as_str(), r["fields"][0]["kind"].as_str()), (Some("b1"), Some(2), Some("round"), Some("glass")));
|
||||
assert_eq!(v["railings"][0]["stairSide"], json!("right"));
|
||||
// Über das Projektformat des Kerns (Laden, Migration, Prüfung).
|
||||
let crate::project_format::Parsed::Ok { project, .. } = crate::project_format::parse_project_file(&text, 0.0) else { panic!("nicht geladen") };
|
||||
assert_eq!(project.get("railings"), v.get("railings"));
|
||||
}
|
||||
@@ -217,7 +217,7 @@ pub fn collect_model_at(p: &Project, level: &str, codes: &HashSet<String>, skip:
|
||||
if !vis_el(&r.id, &r.floor_id, &r.category_code) {
|
||||
continue;
|
||||
}
|
||||
let (Some(ax), Some(sp)) = (crate::railing::axis(r), crate::railing::spec(p, r)) else { continue };
|
||||
let (Some(ax), Some(sp)) = (crate::railing::axis_of(p, r), crate::railing::spec(p, r)) else { continue };
|
||||
segs.extend(ax.windows(2).map(|w| [w[0][0], w[0][1], w[1][0], w[1][1]]));
|
||||
if sp.kind != crate::model::RailingKind::Bars && sp.thickness >= 0.1 {
|
||||
let (_, l, rr) = crate::railing::strips(&ax, sp.thickness / 2.0);
|
||||
|
||||
@@ -1078,8 +1078,10 @@ fn collect(p: &Project, k: [f64; 2], cut: Option<f64>, ground: Option<&Ground>)
|
||||
let pieces = crate::railing::pieces(p, r);
|
||||
let thin_ok = pieces.len() <= RAILING_SHADOW_PIECES;
|
||||
for q in pieces.into_iter().filter(|q| thin_ok || !matches!(q.part, crate::railing::Part::Bar | crate::railing::Part::Post)) {
|
||||
if q.outline.len() >= 3 && q.z1 > q.z0 {
|
||||
prisms.push((Prism { footprint: q.outline, z_bottom: q.z0, z_top: q.z1 }, vec![]));
|
||||
// [291] Auf Treppen geschert: Hüllprisma über die Höhenspanne des Teils.
|
||||
let (z0, z1) = q.z_span();
|
||||
if q.outline.len() >= 3 && z1 > z0 {
|
||||
prisms.push((Prism { footprint: q.outline, z_bottom: z0, z_top: z1 }, vec![]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,17 @@ export interface RailingInfo {
|
||||
baseZ: number;
|
||||
topZ: number;
|
||||
height: number;
|
||||
/** Stäbe und Pfosten (nur Art „Stäbe"). */
|
||||
/** Stäbe und (sichtbare) Pfosten. */
|
||||
bars: number;
|
||||
posts: number;
|
||||
/** Ansichtsfläche Länge × Höhe (m²). */
|
||||
area: number;
|
||||
closed: boolean;
|
||||
/** [291] Zahl der Felder (zwischen zwei Pfosten) und Bindung der Achse. */
|
||||
fields: number;
|
||||
bound: "stair" | "edge" | null;
|
||||
/** [291] Aufgelöste Achse (gebunden: aus Treppe bzw. Decke abgeleitet). */
|
||||
axis: [number, number][];
|
||||
}
|
||||
|
||||
/** Kennzahlen eines Geländers; `null` bei unbekannter Id oder unsinnigen Massen. */
|
||||
|
||||
@@ -4,7 +4,9 @@
|
||||
// 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.
|
||||
// Stäbe/Glas/Brüstung/Lochblech; [291] „an Treppe/Kante“: der nächste Klick auf eine Treppe (nächste Wange) oder eine
|
||||
// Deckenkante legt ein gebundenes Geländer an, das seinem Träger folgt (Auflösung im Kern, `railing::path`). Fusshöhe,
|
||||
// Handlauf, Pfosten, Zwischenholme, 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.
|
||||
//
|
||||
@@ -23,7 +25,7 @@ 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 };
|
||||
export const railingDefaults: { kind: RailingKind; height: number; bind: boolean } = { kind: "bars", height: 1.0, bind: false };
|
||||
|
||||
const next = <T>(list: readonly T[], v: T): T => list[(list.indexOf(v) + 1) % list.length];
|
||||
|
||||
@@ -53,6 +55,9 @@ export const railingReq = (pts: Vec2[], closed: boolean) => ({
|
||||
pts: pts.map(xy),
|
||||
});
|
||||
|
||||
/** [291] Anfrage „an Treppe/Kante“: der Kern sucht die nächste Treppenwange bzw. Deckenkante zum Klick. */
|
||||
export const railingBindReq = (pt: Vec2) => ({ cmd: "railing", kind: railingDefaults.kind, height: railingDefaults.height, bind: true, pts: [xy(pt)] });
|
||||
|
||||
const RAILING_DONE = { key: "cmd.railing.done", kind: "info" } as const;
|
||||
const appendRailing = (pts: Vec2[], closed: boolean, ctx: CommandContext) => createMutation(ctx, railingReq(pts, closed));
|
||||
|
||||
@@ -91,12 +96,13 @@ export const railingCommand: Command = {
|
||||
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"),
|
||||
prompt: (s) => ((s as RailState).phase === "next" ? "cmd.gelaender.next" : railingDefaults.bind ? "cmd.gelaender.pickTarget" : "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];
|
||||
const bind: CmdOption = { id: "bind", labelKey: "cmd.gelaender.bind", value: t(railingDefaults.bind ? "cmd.gelaender.bindOn" : "cmd.gelaender.bindOff") };
|
||||
if (ps.phase !== "next") return [kind, bind];
|
||||
return ps.points.length >= 3 ? [CLOSE, UNDO, kind] : [UNDO, kind];
|
||||
},
|
||||
init: (): RailIdle => ({ phase: "start", lastPoint: null }),
|
||||
@@ -116,6 +122,10 @@ export const railingCommand: Command = {
|
||||
railingDefaults.kind = next(KINDS, railingDefaults.kind);
|
||||
return [s, { draft: draft() }];
|
||||
}
|
||||
if (input.id === "bind" && s.phase !== "next") {
|
||||
railingDefaults.bind = !railingDefaults.bind;
|
||||
return [s, { draft: null }];
|
||||
}
|
||||
if (s.phase !== "next") return [s, { draft: null }];
|
||||
if (input.id === "undo") {
|
||||
const pts = s.points.slice(0, -1);
|
||||
@@ -132,6 +142,10 @@ export const railingCommand: Command = {
|
||||
|
||||
if (input.kind !== "point") return [s, { draft: draft() }];
|
||||
const pt = input.point;
|
||||
// [291] An Treppe/Kante: ein Klick genügt, der Kern bindet an die nächste Wange bzw. Deckenkante.
|
||||
if (s.phase !== "next" && railingDefaults.bind) {
|
||||
return [{ phase: "start", lastPoint: null } as RailIdle, { draft: null, done: true, commit: createMutation(ctx, railingBindReq(pt)), notice: RAILING_DONE }];
|
||||
}
|
||||
if (s.phase !== "next") {
|
||||
const ns: RailDrawing = { phase: "next", points: [pt], cursor: pt, lastPoint: pt };
|
||||
return [ns, { draft: railingDraft([pt], pt) }];
|
||||
|
||||
@@ -2233,6 +2233,10 @@ export const de = {
|
||||
"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",
|
||||
"cmd.gelaender.bind": "an Treppe/Kante",
|
||||
"cmd.gelaender.bindOn": "ja",
|
||||
"cmd.gelaender.bindOff": "nein",
|
||||
"cmd.gelaender.pickTarget": "Treppe (Wange) oder Deckenkante anklicken:",
|
||||
"objinfo.kind.railing": "Geländer",
|
||||
"objinfo.kind.beam": "Träger",
|
||||
"objinfo.railing.many": "{n} Geländer",
|
||||
@@ -2258,6 +2262,30 @@ export const de = {
|
||||
"objinfo.railing.counts": "Stäbe / Pfosten",
|
||||
"objinfo.railing.points": "Punkte",
|
||||
"objinfo.railing.locked": "Gesperrt — Werte nicht änderbar.",
|
||||
"objinfo.railing.handrailProfile": "Handlauf-Profil",
|
||||
"objinfo.railing.profile.rect": "rechteckig",
|
||||
"objinfo.railing.profile.round": "rund",
|
||||
"objinfo.railing.handrailHeight": "Handlaufhöhe",
|
||||
"objinfo.railing.posts": "Pfosten",
|
||||
"objinfo.railing.postSpacing": "Pfostenabstand (max.)",
|
||||
"objinfo.railing.postSize": "Pfostenquerschnitt",
|
||||
"objinfo.railing.midRails": "Zwischenholme",
|
||||
"objinfo.railing.fieldNo": "Feld Nr.",
|
||||
"objinfo.railing.fieldKind": "Füllung des Feldes",
|
||||
"objinfo.railing.fieldKindDefault": "wie Geländer",
|
||||
"objinfo.railing.fields": "Felder",
|
||||
"objinfo.railing.bound": "Gebunden",
|
||||
"objinfo.railing.bound.stair": "Treppe",
|
||||
"objinfo.railing.bound.edge": "Deckenkante",
|
||||
"objinfo.railing.boundMissing": "fehlt (Punkte gelten)",
|
||||
"objinfo.railing.stairSide": "Treppenseite",
|
||||
"objinfo.railing.side.left": "links",
|
||||
"objinfo.railing.side.right": "rechts",
|
||||
"objinfo.railing.edgeIndex": "Kante Nr.",
|
||||
"objinfo.railing.edgeCount": "Anzahl Kanten",
|
||||
"objinfo.railing.edgeInset": "Abstand zur Kante",
|
||||
"objinfo.railing.unbind": "Lösen",
|
||||
"objinfo.railing.unbindHint": "Geländer vom Träger lösen: die Punkte bleiben als freie Achse",
|
||||
"newProject.layer.41": "Geländer",
|
||||
"objinfo.kind.tree": "Baum",
|
||||
"objinfo.tree.many": "{n} Bäume",
|
||||
|
||||
@@ -2221,6 +2221,10 @@ export const en: Record<TranslationKey, string> = {
|
||||
"cmd.gelaender.start": "First railing point (number = height in m):",
|
||||
"cmd.gelaender.next": "Next point (Enter finishes, number = height):",
|
||||
"cmd.gelaender.kind": "Type",
|
||||
"cmd.gelaender.bind": "to stair/edge",
|
||||
"cmd.gelaender.bindOn": "on",
|
||||
"cmd.gelaender.bindOff": "off",
|
||||
"cmd.gelaender.pickTarget": "Click a stair (side) or slab edge:",
|
||||
"objinfo.kind.railing": "Railing",
|
||||
"objinfo.kind.beam": "Beam",
|
||||
"objinfo.railing.many": "{n} railings",
|
||||
@@ -2246,6 +2250,30 @@ export const en: Record<TranslationKey, string> = {
|
||||
"objinfo.railing.counts": "Bars / posts",
|
||||
"objinfo.railing.points": "Points",
|
||||
"objinfo.railing.locked": "Locked — values cannot be changed.",
|
||||
"objinfo.railing.handrailProfile": "Handrail profile",
|
||||
"objinfo.railing.profile.rect": "rectangular",
|
||||
"objinfo.railing.profile.round": "round",
|
||||
"objinfo.railing.handrailHeight": "Handrail height",
|
||||
"objinfo.railing.posts": "Posts",
|
||||
"objinfo.railing.postSpacing": "Post spacing (max.)",
|
||||
"objinfo.railing.postSize": "Post size",
|
||||
"objinfo.railing.midRails": "Intermediate rails",
|
||||
"objinfo.railing.fieldNo": "Panel no.",
|
||||
"objinfo.railing.fieldKind": "Panel infill",
|
||||
"objinfo.railing.fieldKindDefault": "as railing",
|
||||
"objinfo.railing.fields": "Panels",
|
||||
"objinfo.railing.bound": "Attached",
|
||||
"objinfo.railing.bound.stair": "Stair",
|
||||
"objinfo.railing.bound.edge": "Slab edge",
|
||||
"objinfo.railing.boundMissing": "missing (points apply)",
|
||||
"objinfo.railing.stairSide": "Stair side",
|
||||
"objinfo.railing.side.left": "left",
|
||||
"objinfo.railing.side.right": "right",
|
||||
"objinfo.railing.edgeIndex": "Edge no.",
|
||||
"objinfo.railing.edgeCount": "Number of edges",
|
||||
"objinfo.railing.edgeInset": "Distance from edge",
|
||||
"objinfo.railing.unbind": "Detach",
|
||||
"objinfo.railing.unbindHint": "Detach the railing from its host: the points stay as a free axis",
|
||||
"newProject.layer.41": "Railings",
|
||||
"cmd.circlestotrees.label": "Convert circles to trees",
|
||||
"objinfo.kind.tree": "Tree",
|
||||
|
||||
@@ -3608,6 +3608,46 @@ export type Railing = {
|
||||
handrail?: boolean;
|
||||
/** Handlauf: Durchmesser (m, Vorgabe 0.04). */
|
||||
handrailSize?: number;
|
||||
/** [291] Handlauf: Profil (rechteckig = Vorgabe, rund). */
|
||||
handrailProfile?: RailingProfile;
|
||||
/** [291] Handlauf: Höhe der Oberkante über dem Fuss (m); fehlt = `height` (Handlauf obenauf). */
|
||||
handrailHeight?: number;
|
||||
/**
|
||||
* [291] Pfosten setzen (an Ecken und Enden automatisch, dazwischen höchstens `postSpacing`); fehlt = bei Stäben ja, sonst nein.
|
||||
*/
|
||||
posts?: boolean;
|
||||
/**
|
||||
* [291] Pfosten: grösster Achsabstand (m, Vorgabe 1.20); die Felder einer Strecke werden gleich lang.
|
||||
*/
|
||||
postSpacing?: number;
|
||||
/** [291] Pfosten: Querschnitt (Kantenlänge, m, Vorgabe 0.03). */
|
||||
postSize?: number;
|
||||
/**
|
||||
* [291] Anzahl Zwischenholme (waagrechte Stäbe zwischen Fuss und Handlauf, gleich verteilt; Vorgabe 0).
|
||||
*/
|
||||
midRails?: number;
|
||||
/**
|
||||
* [291] Füllung je Feld (Feld = Abschnitt zwischen zwei Pfosten, längs der Achse ab 0 gezählt); fehlt ein Feld, gilt `kind`.
|
||||
*/
|
||||
fields?: Array<RailingField>;
|
||||
/**
|
||||
* [291] Gebunden an eine Treppe: die Achse folgt der Treppenwange `stairSide` und steigt mit dem Lauf (Höhe
|
||||
* lotrecht über der Stufenkante); `points` dient dann nur als Ersatz, falls die Treppe fehlt.
|
||||
*/
|
||||
stairId?: string;
|
||||
/** [291] Seite der Treppe in Laufrichtung (Vorgabe links). */
|
||||
stairSide?: RailingSide;
|
||||
/**
|
||||
* [291] Gebunden an eine Deckenkante: die Achse folgt den Kanten `edgeIndex` … `edgeIndex + edgeCount − 1` des
|
||||
* Deckenumrisses, um `edgeInset` nach innen versetzt; der Fuss steht auf der Deckenoberkante (+ `baseOffset`).
|
||||
*/
|
||||
ceilingId?: string;
|
||||
/** [291] Erste Kante (Kante i läuft von outline[i] zu outline[i+1]). */
|
||||
edgeIndex?: number;
|
||||
/** [291] Anzahl aufeinanderfolgender Kanten (Vorgabe 1; alle Kanten = geschlossen ringsum). */
|
||||
edgeCount?: number;
|
||||
/** [291] Abstand der Achse von der Deckenkante nach innen (m, Vorgabe 0.05). */
|
||||
edgeInset?: 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. */
|
||||
@@ -3618,12 +3658,26 @@ export type Railing = {
|
||||
designOption?: DesignOptionRef;
|
||||
};
|
||||
|
||||
/** [291] Füllung eines Feldes (zwischen zwei Pfosten) abweichend von `Railing.kind`. */
|
||||
export type RailingField = {
|
||||
/** Feld-Nummer längs der Achse (ab 0). */
|
||||
index: number;
|
||||
/** Füllung dieses Feldes. */
|
||||
kind: RailingKind;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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";
|
||||
|
||||
/** [291] Profil des Handlaufs. */
|
||||
export type RailingProfile = "rect" | "round";
|
||||
|
||||
/** [291] Seite einer Treppe in Laufrichtung (gebundenes Geländer). */
|
||||
export type RailingSide = "left" | "right";
|
||||
|
||||
/**
|
||||
* Referenzlinien-Regel: setzt die `referenceLine`-Eigenschaft bei passenden
|
||||
* Wänden einheitlich (Vectorworks-Stil).
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
// 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.
|
||||
// Bauteil der Brüstung. [291] Aufbau je Feld: Pfosten (an/aus, grösster Abstand, Querschnitt), Handlauf (Profil, Höhe),
|
||||
// Zwischenholme, Füllung je Feld; Bindung an Treppe (Seite) oder Deckenkante (Kante, Anzahl, Abstand) und „Lösen“ (die
|
||||
// aufgelöste Achse wird zur freien Polylinie). Kennzahlen (Länge, Felder, 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 { useMemo, useState } from "react";
|
||||
import type { Railing, RailingField, RailingKind, RailingProfile, RailingSide } from "../../model/types";
|
||||
import { useStore } from "../../state/appStore";
|
||||
import { t, type TranslationKey } from "../../i18n";
|
||||
import { patchItem } from "../../core";
|
||||
@@ -17,6 +20,10 @@ 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";
|
||||
/** [291] Vorgabe der Pfosten je Art (Kern `railing::has_posts`). */
|
||||
const postsDefault = (kind: RailingKind): boolean => kind === "bars";
|
||||
const PROFILES: RailingProfile[] = ["rect", "round"];
|
||||
const SIDES: RailingSide[] = ["left", "right"];
|
||||
|
||||
export function RailingSection({ ids }: { ids: readonly string[] }) {
|
||||
const project = useStore((st) => st.project);
|
||||
@@ -24,6 +31,7 @@ export function RailingSection({ ids }: { ids: readonly string[] }) {
|
||||
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]);
|
||||
const [fieldNo, setFieldNo] = useState(0);
|
||||
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) =>
|
||||
@@ -33,6 +41,24 @@ export function RailingSection({ ids }: { ids: readonly string[] }) {
|
||||
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;
|
||||
const posts = rail.posts ?? postsDefault(rail.kind);
|
||||
const stair = rail.stairId ? (project.stairs ?? []).find((x) => x.id === rail.stairId) : undefined;
|
||||
const ceiling = rail.ceilingId ? (project.ceilings ?? []).find((x) => x.id === rail.ceilingId) : undefined;
|
||||
const fieldKind = (rail.fields ?? []).find((f) => f.index === fieldNo)?.kind ?? "";
|
||||
const setFieldKind = (k: string) => {
|
||||
const rest: RailingField[] = (rail.fields ?? []).filter((f) => f.index !== fieldNo);
|
||||
const next = k ? [...rest, { index: fieldNo, kind: k as RailingKind }].sort((a, b) => a.index - b.index) : rest;
|
||||
set({ fields: next.length ? next : undefined });
|
||||
};
|
||||
// Lösen: die aufgelöste Achse (Kern) bleibt als freie Polylinie; ohne Kern-Achse die gespeicherten Punkte.
|
||||
const unbind = () => {
|
||||
const axis = info?.axis.map(([x, y]) => ({ x, y }));
|
||||
const closed = axis && axis.length >= 4 && Math.hypot(axis[0].x - axis[axis.length - 1].x, axis[0].y - axis[axis.length - 1].y) < 1e-6;
|
||||
set({
|
||||
stairId: undefined, stairSide: undefined, ceilingId: undefined, edgeIndex: undefined, edgeCount: undefined, edgeInset: undefined,
|
||||
...(axis && axis.length >= 2 ? { points: closed ? axis.slice(0, -1) : axis, closed: closed || undefined } : {}),
|
||||
});
|
||||
};
|
||||
return (
|
||||
<div className="objinfo-panel objinfo-railing">
|
||||
<div className="objinfo-head">
|
||||
@@ -60,6 +86,37 @@ export function RailingSection({ ids }: { ids: readonly string[] }) {
|
||||
<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 })} />}
|
||||
{handrail && (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.railing.handrailProfile")}</span>
|
||||
<Dropdown
|
||||
value={rail.handrailProfile ?? "rect"}
|
||||
onChange={(v) => set({ handrailProfile: v === "rect" ? undefined : (v as RailingProfile) }, true)}
|
||||
options={PROFILES.map((v) => ({ value: v, label: t(`objinfo.railing.profile.${v}` as TranslationKey) }))}
|
||||
title={t("objinfo.railing.handrailProfile")}
|
||||
width={150}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{handrail && <DimensionField label={t("objinfo.railing.handrailHeight")} value={rail.handrailHeight ?? rail.height} min={0.1} onCommit={(v) => set({ handrailHeight: Math.abs(v - rail.height) < 1e-9 ? undefined : v }, true)} />}
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.railing.posts")}</span>
|
||||
<input type="checkbox" checked={posts} disabled={locked} onChange={(e) => set({ posts: e.target.checked }, true)} data-testid="railing-posts" />
|
||||
</div>
|
||||
{posts && <DimensionField label={t("objinfo.railing.postSpacing")} value={rail.postSpacing ?? 1.2} min={0.2} onCommit={(v) => set({ postSpacing: v }, true)} />}
|
||||
{posts && <DimensionField label={t("objinfo.railing.postSize")} value={rail.postSize ?? 0.03} min={0.01} onCommit={(v) => set({ postSize: v }, true)} />}
|
||||
<DimensionField label={t("objinfo.railing.midRails")} value={rail.midRails ?? 0} min={0} unit="" step={1} digits={0} onCommit={(v) => set({ midRails: Math.round(v) > 0 ? Math.min(20, Math.round(v)) : undefined }, true)} />
|
||||
<DimensionField label={t("objinfo.railing.fieldNo")} value={fieldNo} min={0} unit="" step={1} digits={0} onCommit={(v) => setFieldNo(Math.max(0, Math.round(v)))} />
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.railing.fieldKind")}</span>
|
||||
<Dropdown
|
||||
value={fieldKind}
|
||||
onChange={setFieldKind}
|
||||
options={[{ value: "", label: t("objinfo.railing.fieldKindDefault") }, ...KINDS.map((v) => ({ value: v, label: t(`objinfo.railing.kind.${v}` as TranslationKey) }))]}
|
||||
title={t("objinfo.railing.fieldKind")}
|
||||
width={150}
|
||||
/>
|
||||
</div>
|
||||
{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 })} />}
|
||||
@@ -75,9 +132,44 @@ export function RailingSection({ ids }: { ids: readonly string[] }) {
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{(rail.stairId || rail.ceilingId) && <div className="objinfo-section-label">{t("objinfo.railing.bound")}</div>}
|
||||
{rail.stairId && (
|
||||
<>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.railing.bound.stair")}</span>
|
||||
<span className="objinfo-fval" data-testid="railing-bound">{stair ? stair.id : t("objinfo.railing.boundMissing")}</span>
|
||||
</div>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.railing.stairSide")}</span>
|
||||
<Dropdown
|
||||
value={rail.stairSide ?? "left"}
|
||||
onChange={(v) => set({ stairSide: v as RailingSide })}
|
||||
options={SIDES.map((v) => ({ value: v, label: t(`objinfo.railing.side.${v}` as TranslationKey) }))}
|
||||
title={t("objinfo.railing.stairSide")}
|
||||
width={150}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{rail.ceilingId && (
|
||||
<>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.railing.bound.edge")}</span>
|
||||
<span className="objinfo-fval" data-testid="railing-bound">{ceiling ? ceiling.id : t("objinfo.railing.boundMissing")}</span>
|
||||
</div>
|
||||
<DimensionField label={t("objinfo.railing.edgeIndex")} value={rail.edgeIndex ?? 0} min={0} unit="" step={1} digits={0} onCommit={(v) => set({ edgeIndex: Math.max(0, Math.round(v)) })} />
|
||||
<DimensionField label={t("objinfo.railing.edgeCount")} value={rail.edgeCount ?? 1} min={1} unit="" step={1} digits={0} onCommit={(v) => set({ edgeCount: Math.round(v) > 1 ? Math.round(v) : undefined })} />
|
||||
<DimensionField label={t("objinfo.railing.edgeInset")} value={rail.edgeInset ?? 0.05} min={-1} onCommit={(v) => set({ edgeInset: v })} />
|
||||
</>
|
||||
)}
|
||||
{(rail.stairId || rail.ceilingId) && (
|
||||
<button type="button" className="objinfo-btn" disabled={locked} onClick={unbind} title={t("objinfo.railing.unbindHint")} data-testid="railing-unbind">
|
||||
{t("objinfo.railing.unbind")}
|
||||
</button>
|
||||
)}
|
||||
<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" />
|
||||
<input type="checkbox" checked={rail.closed === true} disabled={locked || rail.points.length < 3 || !!rail.stairId || !!rail.ceilingId} onChange={(e) => set({ closed: e.target.checked || undefined })} data-testid="railing-closed" />
|
||||
</div>
|
||||
{info && (
|
||||
<>
|
||||
@@ -85,12 +177,16 @@ export function RailingSection({ ids }: { ids: readonly string[] }) {
|
||||
<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 && (
|
||||
{(bars || posts) && (
|
||||
<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.railing.fields")}</span>
|
||||
<span className="objinfo-fval" data-testid="railing-fields">{info.fields}</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<div className="objinfo-field">
|
||||
|
||||
@@ -23,4 +23,10 @@ describe("[279] Geländer-Griffe", () => {
|
||||
expect(railingGripPatch(base, -1, { x: 4, y: 1 })).toEqual({});
|
||||
expect(railingGripPatch(base, 0, { x: NaN, y: 1 })).toEqual({});
|
||||
});
|
||||
|
||||
it("[291] gebunden an Treppe oder Deckenkante: keine Griffe", () => {
|
||||
expect(railingGripPoints({ ...base, stairId: "t1" })).toEqual([]);
|
||||
expect(railingGripPoints({ ...base, ceilingId: "d1", edgeIndex: 0 })).toEqual([]);
|
||||
expect(railingGripPatch({ ...base, stairId: "t1" }, 1, { x: 4, y: 1 })).toEqual({});
|
||||
});
|
||||
});
|
||||
@@ -1,17 +1,22 @@
|
||||
// [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.
|
||||
// (`Railing.points`); ein Ziehen ersetzt genau diesen Punkt, Höhe, Art und Teilung bleiben. [291] An Treppe oder
|
||||
// Deckenkante gebundene Geländer haben keine Griffe (die Achse folgt dem Träger; lösen in der Objekt-Info).
|
||||
//
|
||||
// Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md).
|
||||
|
||||
import type { Railing, Vec2 } from "../model/types";
|
||||
|
||||
/** Griff-Punkte: alle Punkte der Achse in Reihenfolge. */
|
||||
/** An Treppe oder Deckenkante gebunden ([291]): die Achse leitet der Kern ab, Griffe gäbe es nur zum Schein. */
|
||||
const isBound = (r: Railing): boolean => !!r.stairId || !!r.ceilingId;
|
||||
|
||||
/** Griff-Punkte: alle Punkte der Achse in Reihenfolge; gebundene Geländer haben keine ([291], die Achse folgt dem Träger). */
|
||||
export function railingGripPoints(r: Railing): Vec2[] {
|
||||
if (isBound(r)) return [];
|
||||
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 {};
|
||||
if (isBound(r) || !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)) };
|
||||
}
|
||||
Reference in new issue
Block a user