From cb9d8c3b0fc60d2d91a1fbab795dcf941813b976 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 11 Nov 2026 04:00:16 +0000 Subject: [PATCH] =?UTF-8?q?[181]=20[152]=20Importe=20als=20eigenst=C3=A4nd?= =?UTF-8?q?ige=20Elemente:=20Klasse=20Pflicht,=20Herkunft=20nur=20Auskunft?= =?UTF-8?q?,=20keine=20Import-Liste?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gelände, Höhenlinien, Netzkörper (Nachbargebäude, IFC/OBJ/STEP/DXF-Netze), Luftbilder und Baugruben (`Project.context`) sind normale Elemente: - Modell: `categoryCode` Pflicht (String) an allen fünf Arten; `layer` (Gruppierung) und `hidden` (Einzel-Ausblenden) entfallen; neu `source` (Herkunft, ohne Wirkung). `ContextObject::category_code()`. - Kern: Plan, Schnitt, Ansicht, 3D, Pick fragen nur die Klasse ab (kein „ohne Kategorie immer sichtbar"). IFC-Gelände (IfcSite bzw. Name Gelände/Terrain) wird beim Import ein Gelände-Element (`import_context::ifc_meshes`); `mesh_view::is_terrain` entfällt, geschlossene Gelände-Netze schneidet der Schnitt als Oberkante. Importe setzen `source` statt `layer` (IFC-Klasse, DXF-Layer, STEP-Datei). - Objekt-Info: Klasse im Kopf änderbar und Farbe der Klasse auch für Gelände-/Umgebungs-Elemente, Herkunft als Auskunft; Einzel-Ausblenden-Schalter entfernt. - Panel „Gelände": Import-Liste entfernt (nur Aktionen); Elemente-Panel mit Knoten „Gelände & Umgebung". - swissBUILDINGS3D/OSM/swissALTI3D/SWISSIMAGE setzen Klasse und `source`; Dach-Trennung über den DXF-Layer beim Import. - Musterhaus komplex nachgeführt (ohne `layer`); Doku: ARCHITEKTUR Abschnitt 8 (Entwurf), Glossar, READMEs. Geprüft: cargo test im Kern (bis auf den Zeit-Wächter ansicht_gross_schnell unter Last), vitest (alle), tsc, Plan-/CLI-Goldens unverändert, e2e siteSelect/excavation/terrainHide angepasst und grün. Musterhaus komplex mit zwei Nachbarnetzen: Grundriss EG/UG 1:200, Schnitt A-A, Ansicht Süd per CLI vor/nach byte-gleich (angesehen). Nicht in der Tauri-App/auf dem Mac geprüft. --- TODO.md | 17 ++- doc/ARCHITEKTUR.md | 29 ++++ e2e/excavation.spec.ts | 22 +-- e2e/siteSelect.spec.ts | 12 +- src-tauri/core/src/cmd_solid.rs | 2 - src-tauri/core/src/import_context.rs | 52 +++++-- src-tauri/core/src/import_drawing.rs | 7 +- src-tauri/core/src/import_drawing_tests.rs | 20 ++- src-tauri/core/src/mesh_view.rs | 11 +- src-tauri/core/src/model/generated.rs | 84 +++++------- src-tauri/core/src/model/manual.rs | 28 +++- src-tauri/core/src/model/mod.rs | 2 +- src-tauri/core/src/model3d/context.rs | 11 +- src-tauri/core/src/model3d/pick.rs | 9 +- src-tauri/core/src/model3d/tests.rs | 31 ++--- src-tauri/core/src/plan/context.rs | 93 ++++++------- src-tauri/core/src/plan/elevation/face.rs | 2 +- src-tauri/core/src/plan/elevation/mod.rs | 10 +- src-tauri/core/src/plan/elevation/tests.rs | 4 +- src-tauri/core/src/plan/extras.rs | 9 +- src-tauri/core/src/plan/mesh_plan.rs | 8 +- src-tauri/core/src/plan/overrides.rs | 2 +- src-tauri/core/src/plan/section/mesh_tests.rs | 33 ++--- src-tauri/core/src/plan/section/meshes.rs | 63 +++++---- src-tauri/core/src/plan/section/mod.rs | 12 +- src-tauri/core/src/plan/section/tests.rs | 2 +- src-tauri/core/src/selection_info.rs | 10 +- src-tauri/core/src/sheet_viewports.rs | 7 +- src-tauri/core/src/sun.rs | 2 +- src-tauri/core/src/tree.rs | 2 +- src/analysis/excavation.test.ts | 5 +- src/export/exportIfc.classification.test.ts | 4 +- src/export/exportMesh.complete.test.ts | 4 +- src/i18n/de.ts | 22 +-- src/i18n/en.ts | 22 +-- src/io/dwgParser.test.ts | 4 +- src/io/geoContext.ts | 21 +-- src/io/ifcImport.test.ts | 2 +- src/io/ifcImport.ts | 3 +- src/io/meshImport.test.ts | 2 +- src/io/swissBuildings3d.test.ts | 45 +++--- src/io/swissBuildings3d.ts | 29 ++-- src/model/geoRebase.test.ts | 4 +- src/model/richProject.testing.ts | 8 +- src/model/sampleProjectComplex.ts | 4 +- src/model/terrain.ts | 7 +- src/model/types.generated.ts | 89 +++++++----- src/panels/ContextObjectProps.tsx | 29 +--- src/panels/ElementTreePanel.tsx | 73 +++++++++- src/panels/ObjectInfoPanel.tsx | 10 +- src/panels/README.md | 2 +- src/panels/SitePanel.tsx | 128 +----------------- src/panels/host.ts | 12 +- src/plan/generatePlan.context.test.ts | 45 +++--- src/plan/sectionExtras.test.ts | 2 +- src/plan/toWalls3d.pickExtras.test.ts | 11 +- src/plan/toWalls3d.pickSolids.test.ts | 6 +- src/plan/toWalls3d.test.ts | 8 +- src/state/README.md | 2 +- src/state/excavationGrips.test.ts | 2 +- src/state/panelHost/selectionStyleHost.ts | 4 + src/state/panelHost/siteHost.ts | 12 +- src/state/panelHost/types.ts | 2 - src/state/selectionInfo.contextImage.test.ts | 16 ++- src/state/selectionInfo.ts | 2 + src/state/siteSelection.test.ts | 2 +- src/state/siteSlice.ts | 5 +- src/state/useProjectActions.ts | 4 - src/styles.css | 76 +---------- src/ui/ContextImportDialog.tsx | 2 +- 70 files changed, 616 insertions(+), 710 deletions(-) diff --git a/TODO.md b/TODO.md index e6efd236..ffdd595d 100644 --- a/TODO.md +++ b/TODO.md @@ -51,7 +51,15 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* Reiter aktiv und wechseln/öffnen den 3D- bzw. Grundriss-Reiter (Titel „3D · Geschoss"). Der 3D-Live-Schnitt „3D im Schnitt-Reiter" entfällt damit als Einstieg (toter Auto-Schnitt in `useSectionLineState` entfernt; der Live-Schnitt per Schalter im Objekt-Info der Schnittlinie bleibt im 3D-Reiter). Knopf „Grundriss" nur im Grundriss-Reiter hervorgehoben (`isPlanKindActive`, 11.11.). Offen: nicht in der Tauri-App geprüft. · S -- ○ **[181]** Importe als eigenständige Elemente (11.11., Wunsch Maintainer): Swisstopo-Gelände/-Gebäude, DXF-/IFC-Kontext usw. werden nach dem Import normale Modell-Elemente auf Ebenen (eigene Klasse), unabhängig von der Quelle; keine Import-Liste mehr, die Sichtbarkeit/Darstellung steuert. Gelände-Mesh als Gelände-/Freiflächen-Element, Gebäude als 3D-Körper (wie Möbel/Körper oder eigener Typ). Keine Migration nötig (nur Beispielprojekte nachführen). Opus. · L +- ◐ **[181]** Importe als eigenständige Elemente (11.11., Wunsch Maintainer). Umgesetzt (11.11.): Gelände, Höhenlinien, + Netzkörper (Nachbargebäude, IFC/OBJ/STEP/DXF-Netze), Luftbilder, Baugruben sind normale Elemente mit Pflicht-Klasse + (`categoryCode: String`); Sichtbarkeit nur über die Klasse (kein „ohne Kategorie immer sichtbar", kein `hidden`, kein + Gruppierungs-`layer`); Herkunft nur als Auskunft `source` (Objekt-Info). IFC-Gelände (`IfcSite`/Name) wird beim Import ein + Gelände-Element (`import_context::ifc_meshes`), `mesh_view::is_terrain` entfällt. Panel „Gelände" ohne Import-Liste (nur + Aktionen); Auswahl im Elemente-Panel (Knoten „Gelände & Umgebung"), Klasse im Kopf der Objekt-Info änderbar. Entwurf in + `doc/ARCHITEKTUR.md` Abschnitt 8. Geprüft: Rust/vitest/e2e, Musterhaus komplex mit Nachbarnetzen Grundriss 1:200/Schnitt/ + Ansicht per CLI vor/nach byte-gleich. Offen: Linien des Standort-Imports (OSM/swisstopo-Umrisse) bleiben je Klasse ein + `contourSet` statt einzelner 2D-Zeichnungen; Tag-Namen `importedMesh`/`terrainMesh` historisch; Mac-Gegenprobe. · L - ○ **[180]** Alles Sichtbare auf Ebene/Klasse (11.11., Vorgabe Maintainer): jedes Primitive in Plan/Schnitt/Ansicht (auch abgeleitete: Schatten, Auto-Masse, Koten, Schnitt-/Ansichtsmarken, Raster, Nordpfeil, Stempel, Gelände) hat eine Klasse/Ebene und verschwindet mit ihr; Audit + Test, der Primitives ohne Zuordnung meldet. Regel in CLAUDE.md. · M - ◐ **[133]** Musterhaus komplex: Rest. Skalieren-Kopie lässt `position`/Breite unverändert; Vollflächen-/Bildschraffur und Schraffur-Löcher beim Ausbreiten fehlen (`src/export/planToSvgString.ts`, Kern `plan/svg.rs`; wegen paralleler @@ -313,8 +321,9 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* - ◐ **[67]** Skizzenstil (`plan/sketch.rs`). Kompakte Linien-Unterlage (grosse DXF-Unterlagen), Bögen und Kreise bleiben exakt; keine Intensitäts-Einstellung; keine Hand-Schraffur. · S - ◐ **[152]** Importierte Netze in Schnitt, Ansicht, Grundriss (`core/src/mesh_view.rs`). Der Archiv-Eintrag nennt keinen - ausdrücklichen „Offen“-Teil; bekannt: IFC-Gelände ist nur im Schnitt eine Geländelinie, Ansicht und Grundriss - behandeln es weiter als Netz. · S + ausdrücklichen „Offen“-Teil. (11.11., [181]) IFC-Gelände wird beim Import ein Gelände-Element und läuft damit in Grundriss, + Schnitt, Ansicht und 3D als Gelände; offen: Baugruben auf geschlossenen Gelände-Netzen (Platte) nicht geprüft, Grundriss + zeigt ohne Äquidistanz nur den Rahmen. · S ## 3D @@ -514,7 +523,7 @@ Wer zu einer ID mehr wissen will (Entscheide, Tests, Bilder), sucht dort nach `* Auf dem Mac (Tauri/Metal) noch nicht angesehen oder geprüft; bisher nur Linux-Container, CLI-SVG, Chromium oder Unit-Tests: [116] (atomares Speichern), [117] (CSP unter `tauri://`), [118], [122], [123], [126], [110], [101], -[102], [131], [133], [136], [140], [145], [146], [153], [64], [T2], [T4], [34], [108], [65], [169], [113]. Je Punkt ansehen, dann hier und +[102], [131], [133], [136], [140], [145], [146], [153], [64], [T2], [T4], [34], [108], [65], [169], [113], [181]. Je Punkt ansehen, dann hier und im jeweiligen Eintrag streichen. · M (gesamt) --- diff --git a/doc/ARCHITEKTUR.md b/doc/ARCHITEKTUR.md index 00e888cf..c60af7f8 100644 --- a/doc/ARCHITEKTUR.md +++ b/doc/ARCHITEKTUR.md @@ -463,6 +463,34 @@ Es gibt drei Schatten, alle aus derselben Sonnenstudie (`Project.sunStudy`, Ort `ifc_import()` in `src-tauri/core/src/import_ifc.rs` (Netze über `import_context.rs`). Der Kern legt alles als **einen** Undo-Schritt an. +### Importe werden Elemente ([181], 11.11.2026) + +Was ein Import ins Modell bringt, ist danach ein gewöhnliches Element, unabhängig von der Quelle. Es gibt keine +Import-Liste und keine „Kontext-Schicht", die Sichtbarkeit oder Darstellung steuert: + +| Herkunft | Element (`Project.context`, Tag `type`) | Klasse (`categoryCode`) | +|---|---|---| +| swissALTI3D, „Gelände erzeugen", IFC `IfcSite` bzw. Name mit Gelände/Terrain | Gelände `terrainMesh` (TIN; geschlossene Netze schneidet der Schnitt als Oberkante) | „02 Gelände" | +| DXF-/DWG-Höhenlinien, OSM-/swisstopo-Linien | Höhenlinien `contourSet` | „02"/„14" bzw. je Art („11 Strasse" …) | +| swissBUILDINGS3D, OSM-Gebäude, IFC-Bauteile, OBJ/STL/glTF/PLY, STEP, DXF-Netze | Netzkörper `importedMesh` (eigene Art, wie Möbel ein 3D-Objekt) | „12 Gebäude", „31 Dächer", sonst „10 Situation" | +| SWISSIMAGE | Luftbild `image` | „03 Luftbild" | +| (gezeichnet) | Baugrube `excavation` | „07 Baugrube" | +| DXF-/DWG-/PDF-Linien und Texte | 2D-Zeichnung `drawings2d` (wie bisher) | nach DXF-Layer | + +- **Klasse ist Pflicht** (Rust `category_code: String`, `ContextObject::category_code()`); Plan, Schnitt, Ansicht, 3D und + Pick fragen nur sie (und Override-Regeln) ab. Das frühere „ohne Kategorie immer sichtbar", das Einzel-Ausblenden + (`hidden`) und der Gruppierungs-Name `layer` sind entfallen. +- **Herkunft** steht höchstens in `source` (z. B. „swissBUILDINGS3D", „IFC IfcWall", „DXF-Layer Haus") und wird nur in der + Objekt-Info angezeigt. Was von der Quelle abhängt (IFC-Gelände → Gelände-Element, Dach-Layer → Klasse „31"), entscheidet + der Import einmal (`import_context::ifc_meshes`, `src/io/swissBuildings3d.ts`); danach zählt nur die Elementart. +- **Oberfläche:** Auswahl im Plan/3D oder im Elemente-Panel (Knoten „Gelände & Umgebung", `ElementTreePanel.tsx`), Klasse + im Kopf der Objekt-Info änderbar (`onSetSelectionCategory`), Löschen wie jedes Element. Das Panel „Gelände" behält nur + Aktionen (Import, Gelände erzeugen, Baugrube, Schatten, Baurecht, Punktwolken). +- **Entscheid Netzkörper:** Nachbargebäude bleiben Netze (`importedMesh`) statt Extrusionen (`extrudedSolids`): LOD2-Dächer + und IFC-Freiformen lassen sich nicht verlustfrei extrudieren, ein Möbel-Typ existiert nicht. Die Tag-Namen + (`importedMesh`, `terrainMesh`) und der Feldname `context` sind historisch und bewusst nicht umbenannt (keine Wirkung, + viel Umbau); die Oberfläche nennt sie „Netzkörper", „Gelände", „Gelände & Umgebung". + ### Export 1. `src/export/exportIfc.ts` fragt `queryBin("ifcExportData", …)`. Im Kern sammelt @@ -549,6 +577,7 @@ schreibt `src-tauri/src/atomic_save.rs` die Datei absturzsicher. | **solid_cut** | Regel, wann Schnittflächen als volle schwarze Fläche ohne Schichten und Schraffur gezeichnet werden: bei Detail „grob" immer, sonst ab Massstabszahl 75 (also 1:100 und gröber), ausser bei Detail „fein" oder mit „Schnittflächen schraffiert" (Feld der Ebene bzw. Ansichtsvorlage). | `solid_cut()` in `plan/style.rs` | | **Tusche** | Darstellung schwarz-weiss wie ein Tuscheplan; Standard der App. Farbe nur auf Wunsch (CLI `--color`, Ansichtsvorlage mit `mono: false`). | TODO `[140]`, `plan/extras.rs` | | **Wandknoten**, **Joins** | Verschneidung von Wänden am Stoss: Gehrung, T-Stoss, Kreuzung, je Schicht nach Priorität. Ergebnis sind Schnittlinien je Wandende. | `compute_joins()` in `joins.rs`, `resolve_join_priority()` | +| **Gelände-/Umgebungs-Element** | Gelände, Höhenlinien, Netzkörper (z. B. Nachbargebäude), Luftbild, Baugrube; normale Elemente mit Pflicht-Klasse, Herkunft nur als Auskunft (`source`), [181]. | `Project.context`, `ContextObject` in `model/manual.rs` | | **Fussabdruck** | Grundriss-Umriss eines Elements. Wand: gedrehtes Rechteck (`wall_footprint()`), verdeckt Decken-Umrisse. Kontext-Gebäude: Sockelkanten des Netzes. | `plan/wall_poche.rs`, `plan/misc.rs` | | **Ansichtsbereich** | Schnitthöhe sowie Ober- und Unterkante der Sicht eines Geschosses. Legt fest, ob ein Bauteil geschnitten, darunter oder darüber (Überkopf) gezeichnet wird. | `plan/view_range.rs` | | **Override-Regel** | Grafische Regel mit Bedingungen (Ebene, Name, Bauteilart, Schicht, Massstab) und Aktionen (ausblenden, Farbe, Schraffur, Strich). Die oberste passende Regel gewinnt je Feld. | `Project.overrideRules`, `plan/overrides.rs` (`effective()`, `effective_layer()`) | diff --git a/e2e/excavation.spec.ts b/e2e/excavation.spec.ts index 29d16bb1..0c8bc947 100644 --- a/e2e/excavation.spec.ts +++ b/e2e/excavation.spec.ts @@ -1,5 +1,5 @@ // [143] Baugrube erstellen wie ein Nutzer (Mac-Befund 5.11.: „Die Baugrube lässt sich gar nicht erstellen"): -// Befehl/Panel-Knopf, Umriss tippen, Enter. Geprüft: Hinweis (Toast), Eintrag im Panel „Gelände", Linien der +// Befehl/Panel-Knopf, Umriss tippen, Enter. Geprüft: Hinweis (Toast), Eintrag im Elemente-Panel ([181]), Linien der // Baugrube im Grundriss (Farbe EXCAVATION_INK, `plan/context.rs`), Schnitt mit Gelände, Rückgängig entfernt sie. // Ursachen vorher: Kategorie „02 Gelände" (in Grundrissen oft ausgeblendet → Baugrube unsichtbar), Sohle immer // −0.30 (las eine Liste `floors`, die es nicht gibt), ohne Gelände stilles Nichts. @@ -8,7 +8,8 @@ import { blurFocus, commandInput, discardIfAsked, expect, fileMenu, openTab, sho const ink = (page: Page) => page.locator('svg.plan-svg [stroke="#1f242c"]').count(); const toast = (page: Page) => page.locator(".toast-message"); -const sitePanel = (page: Page) => page.locator(".site-panel"); +// [181] Die Baugrube ist ein normales Element: sie steht im Elemente-Panel unter „Gelände & Umgebung". +const siteElements = (page: Page) => page.getByTestId("elements-site"); async function drawExcavation(page: Page, pts: string[]): Promise { await commandInput(page).focus(); @@ -39,14 +40,15 @@ test("Musterhaus komplex: Baugrube per Panel-Knopf im Ausschnitt EG 1:100, sicht await drawExcavation(page, ["-25,-10", "-12,-10", "-12,0", "-25,0"]); await expect(toast(page).filter({ hasText: /Baugrube angelegt: Sohle −3\.00 m/ })).toBeVisible(); - await expect(sitePanel(page)).toContainText("Baugrube 2"); + await openTab(page, "Elemente"); + await expect(siteElements(page)).toContainText("Baugrube 2"); // Im Erdgeschoss-Grundriss sichtbar (Gelände „02" ist dort ausgeblendet, die Baugrube „07" nicht). await expect.poll(() => ink(page)).toBeGreaterThan(before); // Rückgängig: weg aus Panel und Plan. await blurFocus(page); await page.keyboard.press("Control+z"); - await expect(sitePanel(page)).not.toContainText("Baugrube 2"); + await expect(siteElements(page)).not.toContainText("Baugrube 2"); await expect.poll(() => ink(page)).toBe(before); }); @@ -75,7 +77,7 @@ test("Leeres Projekt mit Gelände in m ü. M.: Gelände erzeugen, Baugrube, ±0. const y = -30 + i * 5; contours.push({ z: 500 + i, pts: [-40, -20, 0, 20, 40].map((x) => ({ x, y: y + x * 0.02 })), closed: false, layer: "HL" }); } - json.context = [{ type: "contourSet", id: "hl", name: "Höhenlinien", layer: "Terrain", categoryCode: "14", contours }]; + json.context = [{ type: "contourSet", id: "hl", name: "Höhenlinien", categoryCode: "14", contours }]; json.name = "Hang"; const chooser = page.waitForEvent("filechooser"); await fileMenu(page, "Projekt öffnen"); @@ -90,11 +92,15 @@ test("Leeres Projekt mit Gelände in m ü. M.: Gelände erzeugen, Baugrube, ±0. await page.getByRole("button", { name: "Baugrube zeichnen" }).click(); await drawExcavation(page, ["-6,-5", "6,5"]); // 2 Punkte = Rechteck await expect(toast(page).filter({ hasText: /±0\.00 = 50\d\.\d\d m ü\. M\. angenommen/ })).toBeVisible(); - await expect(sitePanel(page)).toContainText("Baugrube 1"); - await expect(sitePanel(page)).toContainText(/Abtrag [1-9]/); + // [181] Im Elemente-Panel wählen, Mengen in der Objekt-Info. + await openTab(page, "Elemente"); + await siteElements(page).getByText("Baugrube 1").click(); + await openTab(page, "Objekt-Info"); + await expect(page.locator(".objinfo-panel").first()).toContainText(/Abtrag [1-9]/); await expect.poll(() => ink(page)).toBeGreaterThan(before); await blurFocus(page); await page.keyboard.press("Control+z"); - await expect(sitePanel(page)).not.toContainText("Baugrube 1"); + await openTab(page, "Elemente"); + await expect(siteElements(page)).not.toContainText("Baugrube 1"); }); diff --git a/e2e/siteSelect.spec.ts b/e2e/siteSelect.spec.ts index 7218f32f..249165d6 100644 --- a/e2e/siteSelect.spec.ts +++ b/e2e/siteSelect.spec.ts @@ -48,15 +48,9 @@ test("Musterhaus komplex: Gelände und Schatten anwählen und bearbeiten (mit Un await blurFocus(page); await page.keyboard.press("ControlOrMeta+z"); await expect(smooth).toHaveValue("2"); - // Nur dieses Netz ausblenden (Kategorie bleibt an), Undo blendet es wieder ein. - const meshVisible = objInfo(page).getByTestId("terrain-mesh-visible"); - await expect(meshVisible).toBeChecked(); - await meshVisible.uncheck(); - await expect(meshVisible).not.toBeChecked(); - await expect(objInfo(page).getByTestId("terrain-visible")).toBeChecked(); - await blurFocus(page); - await page.keyboard.press("ControlOrMeta+z"); - await expect(meshVisible).toBeChecked(); + // [181] Normales Element: Klasse „02 Gelände" im Kopf der Objekt-Info, kein Einzel-Ausblenden mehr. + await expect(objInfo(page).locator(".objinfo-field").filter({ hasText: "Klasse" }).first()).toContainText("02"); + await expect(objInfo(page).getByTestId("terrain-mesh-visible")).toHaveCount(0); // Schatten: EG 1:100, Klick in den Schlagschatten nördlich des Hauses (21. Juni, 10 Uhr; nördlich des Eingangs, ausserhalb der Baugrube). await showSnapshot(page, "EG 1:100"); diff --git a/src-tauri/core/src/cmd_solid.rs b/src-tauri/core/src/cmd_solid.rs index 249ab7cc..a2893d87 100644 --- a/src-tauri/core/src/cmd_solid.rs +++ b/src-tauri/core/src/cmd_solid.rs @@ -480,7 +480,6 @@ pub fn terrain_from_contours_with(contours: &[Value], id: &str, o: crate::terrai ("id", s(id)), ("type", s("terrainMesh")), ("name", s("Gelände")), - ("layer", s("Terrain")), ("categoryCode", s("02")), ("positions", Value::Array(pos.into_iter().map(js_num).collect())), ("indices", Value::Array(idx.into_iter().map(Value::from).collect())), @@ -606,7 +605,6 @@ fn excavation_ops(root: &Map, p: &Project, v: &Value, ctx: &Ctx, ("id", s(&ids.next("excavation"))), ("type", s("excavation")), ("name", s(&format!("Baugrube {}", n + 1))), - ("layer", s("Terrain")), ("categoryCode", s(EXCAVATION_CATEGORY)), ("outline", pvs(&pts)), ("bottom", js_num(check.bottom)), diff --git a/src-tauri/core/src/import_context.rs b/src-tauri/core/src/import_context.rs index 49c684ed..5dfd4495 100644 --- a/src-tauri/core/src/import_context.rs +++ b/src-tauri/core/src/import_context.rs @@ -141,13 +141,24 @@ pub fn color_of(v: Option<&Value>) -> Option> { v?.as_array().map(|a| a.iter().map(|x| x.as_f64().unwrap_or(f64::NAN)).collect()) } -fn mesh_value(id: String, name: String, layer: &str, color: Option, extra: Option<(&str, &str)>, positions: Vec, indices: Vec) -> Value { +/// Netzkörper (`importedMesh`, Klasse „10 Situation") mit Herkunft `source` (nur Auskunft, [181]). +fn mesh_value(id: String, name: String, source: &str, color: Option, extra: Option<(&str, &str)>, positions: Vec, indices: Vec) -> Value { + element_value("importedMesh", GENERIC_IMPORT_CODE, id, name, source, color, extra, positions, indices) +} + +/// [181] Klasse der importierten Gelände-Elemente (wie „Gelände erzeugen“). +pub const TERRAIN_CODE: &str = "02"; + +#[allow(clippy::too_many_arguments)] +fn element_value(kind: &str, code: &str, id: String, name: String, source: &str, color: Option, extra: Option<(&str, &str)>, positions: Vec, indices: Vec) -> Value { let mut o = Map::new(); o.insert("id".into(), id.into()); - o.insert("type".into(), "importedMesh".into()); + o.insert("type".into(), kind.into()); o.insert("name".into(), name.into()); - o.insert("layer".into(), layer.into()); - o.insert("categoryCode".into(), GENERIC_IMPORT_CODE.into()); + o.insert("categoryCode".into(), code.into()); + if !source.is_empty() { + o.insert("source".into(), source.into()); + } if let Some(c) = color { o.insert("color".into(), c.into()); } @@ -289,11 +300,34 @@ pub fn classification_suffix(list: &[Value]) -> String { format!(" [{}]", parts.join(" ")) } -/// Gruppierung: `"product"`, `"class"` oder `"auto"` (nach [`MAX_SINGLE`]). +/// [152]/[181] Gelände in einer IFC-Datei: Klasse `IfcSite` oder Name mit „Gelände"/„Terrain" (z. B. ein +/// `IfcGeographicElement` „Terrain"). Wird beim Import ein Gelände-Element; danach zählt nur die Elementart. +pub fn is_ifc_terrain(class: &str, name: Option<&str>) -> bool { + let name = name.unwrap_or("").to_lowercase(); + class.eq_ignore_ascii_case("IfcSite") || name.contains("ifcsite") || ["gelände", "gelaende", "terrain"].iter().any(|k| name.contains(k)) +} + +/// Gruppierung: `"product"`, `"class"` oder `"auto"` (nach [`MAX_SINGLE`]). Gelände ([`is_ifc_terrain`]) wird je +/// Bauteil ein Gelände-Element (`terrainMesh`, Klasse „02"), alles andere Netzkörper. pub fn ifc_meshes(products: &[IfcProduct], file_name: &str, group: &str, shift: [f64; 2], now: f64) -> Vec { let base = base_name(file_name, "IFC"); let stamp = stamp36(now); let d = [shift[0], shift[1], 0.0]; + let (terrain, rest): (Vec<&IfcProduct>, Vec<&IfcProduct>) = products.iter().partition(|p| is_ifc_terrain(&p.ifc_class, p.name.as_deref())); + let mut out: Vec = terrain + .iter() + .map(|p| { + let (pos, idx) = arrays(std::iter::once((p.positions, p.indices)), d); + let gid = (!p.global_id.is_empty()).then_some(("ifcGlobalId", p.global_id.as_str())); + let name = p.name.as_deref().filter(|n| !n.is_empty()).unwrap_or("Gelände").to_string(); + element_value("terrainMesh", TERRAIN_CODE, format!("imported-ifc-{stamp}-{}", next_seq()), name, &format!("IFC {}", p.ifc_class), None, gid, pos, idx) + }) + .collect(); + out.extend(ifc_body_meshes(&rest, &base, group, d, &stamp)); + out +} + +fn ifc_body_meshes(products: &[&IfcProduct], base: &str, group: &str, d: [f64; 3], stamp: &str) -> Vec { let per_product = group == "product" || (group != "class" && products.len() <= MAX_SINGLE); if per_product { return products @@ -310,7 +344,7 @@ pub fn ifc_meshes(products: &[IfcProduct], file_name: &str, group: &str, shift: mesh_value( format!("imported-ifc-{stamp}-{}", next_seq()), label + &classification_suffix(&p.classifications), - &p.ifc_class, + &format!("IFC {}", p.ifc_class), color_hex(p.color.as_deref()), gid, pos, @@ -327,7 +361,7 @@ pub fn ifc_meshes(products: &[IfcProduct], file_name: &str, group: &str, shift: let color = if colors.len() == 1 { colors.into_iter().next().filter(|c| !c.is_empty()) } else { None }; let label = [first.storey.as_deref(), Some(first.ifc_class.as_str())].into_iter().flatten().filter(|s| !s.is_empty()).collect::>().join(" "); let (pos, idx) = arrays(g.iter().map(|&i| (products[i].positions, products[i].indices)), d); - mesh_value(format!("imported-ifc-{stamp}-{}", next_seq()), format!("{base}: {label} ({})", g.len()), &first.ifc_class, color, None, pos, idx) + mesh_value(format!("imported-ifc-{stamp}-{}", next_seq()), format!("{base}: {label} ({})", g.len()), &format!("IFC {}", first.ifc_class), color, None, pos, idx) }) .collect() } @@ -478,7 +512,7 @@ pub fn mesh_shift(objects: &[MeshObject], placement: &str, origin: Option<[f64; } } -/// Objekte → Kontext-Meshes (`layer` = Gruppe, sonst Dateiname); `group`: `"object"`, `"merge"`, `"auto"`. +/// Objekte → Netzkörper (Herkunft `source` = Gruppe, sonst Dateiname); `group`: `"object"`, `"merge"`, `"auto"`. pub fn mesh_objects_to_meshes(objects: &[MeshObject], file_name: &str, placement: &str, origin: Option<[f64; 2]>, group: &str, now: f64) -> Vec { let base = base_name(file_name, "Mesh"); let d = mesh_shift(objects, placement, origin); @@ -553,6 +587,7 @@ pub fn step_meshes(bodies: &[(Vec, Vec)], file_name: &str, now: f64) - o.insert("type".into(), "importedMesh".into()); o.insert("name".into(), if n > 1 { format!("{base} ({}/{n})", i + 1) } else { base.clone() }.into()); o.insert("categoryCode".into(), GENERIC_IMPORT_CODE.into()); + o.insert("source".into(), format!("STEP {file_name}").into()); o.insert("positions".into(), Value::Array(pos.iter().map(|&x| js_num(x.to_string().parse().unwrap_or(f64::from(x)))).collect())); o.insert("indices".into(), Value::Array(idx.iter().map(|&k| js_num(k)).collect())); Value::Object(o) @@ -583,6 +618,7 @@ mod step_tests { assert_eq!(m[1]["name"], "haus (2/2)"); assert_eq!(m[0]["categoryCode"], "10"); assert!(m[0].get("layer").is_none()); + assert_eq!(m[0]["source"], "STEP haus.stp"); assert_eq!(m[0]["positions"][0], json!(0.1)); assert_eq!(m[1]["indices"], json!([0, 1, 2])); assert!(m[0]["id"].as_str().unwrap().starts_with("imported-step-")); diff --git a/src-tauri/core/src/import_drawing.rs b/src-tauri/core/src/import_drawing.rs index 68e561cf..6cd6c235 100644 --- a/src-tauri/core/src/import_drawing.rs +++ b/src-tauri/core/src/import_drawing.rs @@ -586,7 +586,7 @@ pub fn summary_json(d: &DrawingImport) -> Value { Value::Object(m) } -/// Meshes als Kontext-Objekte (`ImportedMesh`, Kategorie „10 Situation"; Layer „0" ohne `layer`). +/// Meshes als Netzkörper (`ImportedMesh`, Klasse „10 Situation"; Herkunft `source` = DXF-Layer ausser „0"). pub fn mesh_values(d: &DrawingImport) -> Vec { d.meshes .iter() @@ -596,8 +596,9 @@ pub fn mesh_values(d: &DrawingImport) -> Vec { o.insert("type".into(), "importedMesh".into()); o.insert("name".into(), m.name.clone().into()); o.insert("categoryCode".into(), GENERIC_IMPORT_CODE.into()); - if m.layer != "0" { - o.insert("layer".into(), m.layer.clone().into()); + // [181] Herkunft nur als Auskunft (DXF-Layer), ohne Wirkung. + if m.layer != "0" && !m.layer.is_empty() { + o.insert("source".into(), format!("DXF-Layer {}", m.layer).into()); } o.insert("positions".into(), Value::Array(m.positions.iter().map(|&x| js_num(x)).collect())); o.insert("indices".into(), Value::Array(m.indices.iter().map(|&x| js_num(x)).collect())); diff --git a/src-tauri/core/src/import_drawing_tests.rs b/src-tauri/core/src/import_drawing_tests.rs index 11868a60..56d317f2 100644 --- a/src-tauri/core/src/import_drawing_tests.rs +++ b/src-tauri/core/src/import_drawing_tests.rs @@ -90,6 +90,7 @@ fn ops_neue_zeichnung_mit_layer_kategorien() { assert_eq!(drawings[4]["geom"], json!({"shape": "text", "at": {"x": 5, "y": 6}, "text": "Wohnen", "height": 0.25, "angle": 0})); assert_eq!(ops[2]["collection"], json!("context")); assert!(ops[2]["items"][0].get("layer").is_none()); + assert_eq!(ops[2]["items"][0]["categoryCode"], json!("10")); // Kategorien: „Import x" mit A, B; dazu „05 Kontext" mit „10 Situation". let layers = &ops[3]["value"]; assert_eq!(layers[2]["name"], json!("Import x")); @@ -182,7 +183,9 @@ fn ifc_meshes_farbe_und_globalid() { assert_eq!(m[0]["color"], json!("#ff8000")); assert_eq!(m[0]["ifcGlobalId"], json!("2O2Fr$t4X7Zf8NOew3FLOH")); assert_eq!(m[0]["name"], json!("EG: Wand")); - assert_eq!(m[0]["layer"], json!("IfcWall")); + assert!(m[0].get("layer").is_none()); + assert_eq!(m[0]["source"], json!("IFC IfcWall")); + assert_eq!(m[0]["type"], json!("importedMesh")); let n = ifc_meshes(&[product(None, "")], "x.ifc", "product", [0.0, 0.0], 0.0); assert!(n[0].get("color").is_none() && n[0].get("ifcGlobalId").is_none()); // Zusammengelegt: gemeinsame Farbe nur, wenn alle gleich; Indizes versetzt. @@ -194,6 +197,18 @@ fn ifc_meshes_farbe_und_globalid() { assert_eq!(g[0]["positions"][0], json!(10)); let h = ifc_meshes(&[product(red(), "a"), product(Some(vec![0.0, 0.0, 1.0, 1.0]), "b")], "x.ifc", "class", [0.0, 0.0], 0.0); assert!(h[0].get("color").is_none()); + // [181] Gelände (IfcSite, IfcGeographicElement „Terrain") wird beim Import ein Gelände-Element (Klasse „02"), + // unabhängig davon, ob je Bauteil oder je Klasse zusammengelegt wird. + let site = |class: &str, name: &str| IfcProduct { ifc_class: class.into(), name: Some(name.into()), ..product(None, "s") }; + for group in ["product", "class"] { + let t = ifc_meshes(&[site("IfcSite", "Site"), site("IfcGeographicElement", "Gelände Süd"), product(None, "w")], "x.ifc", group, [0.0, 0.0], 0.0); + let types: Vec<&str> = t.iter().map(|m| m["type"].as_str().unwrap()).collect(); + assert_eq!(types.iter().filter(|&&k| k == "terrainMesh").count(), 2, "{group}: {types:?}"); + let g = t.iter().find(|m| m["type"] == "terrainMesh").unwrap(); + assert_eq!(g["categoryCode"], json!("02")); + assert!(g["source"].as_str().unwrap().starts_with("IFC ")); + assert!(t.iter().any(|m| m["type"] == "importedMesh" && m["categoryCode"] == "10")); + } assert_eq!(classification_suffix(&[]), ""); assert_eq!(classification_suffix(&[json!({"system": "", "code": "214", "name": null})]), " [214]"); } @@ -216,7 +231,8 @@ fn meshes_mitte_und_gruppen() { let obj = |g: &str, x: f64| MeshObject { name: String::new(), group: g.into(), color: Some(vec![1.0, 0.5, 0.0, 1.0]), positions: vec![x, 0.0, 1.0, x + 2.0, 2.0, 3.0], indices: vec![0.0, 1.0, 0.0] }; let m = mesh_objects_to_meshes(&[obj("", 0.0), obj("g", 10.0)], "haus.obj", "center", None, "auto", 0.0); assert_eq!(m[0]["name"], json!("haus 1")); - assert_eq!(m[0]["layer"], json!("haus")); + assert!(m[0].get("layer").is_none()); + assert_eq!(m[0]["source"], json!("haus")); assert_eq!(m[0]["color"], json!("#ff8000")); assert_eq!(m[0]["positions"], json!([-6, -1, 0, -4, 1, 2])); let m = mesh_objects_to_meshes(&[obj("g", 0.0), obj("g", 10.0)], "haus.obj", "original", None, "merge", 0.0); diff --git a/src-tauri/core/src/mesh_view.rs b/src-tauri/core/src/mesh_view.rs index 2c16bd5c..85b64d10 100644 --- a/src-tauri/core/src/mesh_view.rs +++ b/src-tauri/core/src/mesh_view.rs @@ -143,13 +143,13 @@ pub fn info(m: &ImportedMesh) -> Option> { i } -/// Die gezeichneten Netze: nicht einzeln ausgeblendet ([137]), mit mindestens einem gültigen Dreieck. +/// Die gezeichneten Netze: mit mindestens einem gültigen Dreieck. /// Kategorie-Sichtbarkeit prüft der Aufrufer (UI-Zustand). pub fn meshes(p: &Project) -> Vec> { let mut out = Vec::new(); for (index, obj) in p.context.as_deref().unwrap_or(&[]).iter().enumerate() { let ContextObject::ImportedMesh(m) = obj else { continue }; - if m.hidden == Some(true) || m.positions.len() < 9 || m.indices.len() < 3 { + if m.positions.len() < 9 || m.indices.len() < 3 { continue; } if let Some(info) = info(m) { @@ -159,13 +159,6 @@ pub fn meshes(p: &Project) -> Vec> { out } -/// [152] Gelände aus einem IFC-Import (Klasse `IfcSite` im Layer bzw. Namen, oder Name mit „Gelände"/„Terrain", -/// z. B. ein `IfcGeographicElement` „Terrain"): im Schnitt Geländelinie statt Körper. -pub fn is_terrain(m: &ImportedMesh) -> bool { - let (name, layer) = (m.name.to_lowercase(), m.layer.as_deref().unwrap_or("").to_lowercase()); - layer == "ifcsite" || name.contains("ifcsite") || ["gelände", "gelaende", "terrain"].iter().any(|k| name.contains(k)) -} - /// Linienzüge ungerichtet aneinanderhängen (Netze mit wechselnder Orientierung): was sich schliesst, /// wird Ring, der Rest bleibt offen. Endpunkte gleich auf 1e-6 (wie `mesh_section`). pub fn close_chains(lines: Vec>) -> (Vec>, Vec>) { diff --git a/src-tauri/core/src/model/generated.rs b/src-tauri/core/src/model/generated.rs index e6dfb5f8..3781870e 100644 --- a/src-tauri/core/src/model/generated.rs +++ b/src-tauri/core/src/model/generated.rs @@ -5764,9 +5764,9 @@ pub struct Project { pub rooms: Option>, /// Freie 2D-Zeichengeometrie (Line/Polyline/Rect/Circle/Arc/Text). pub drawings2d: Vec, - /// Kontext-Schicht: importierte/abgeleitete „dumme" Geometrie (Meshes, - /// Konturen, Gelände-TIN) — NICHT semantisch. Optional, damit bestehende - /// Projekte/Tests ohne `context` gültig bleiben (Default: leer behandeln). + /// [181] Gelände- und Umgebungs-Elemente (Gelände, Höhenlinien, Netzkörper wie Nachbargebäude, Luftbilder, + /// Baugruben): normale Elemente mit Klasse (`categoryCode`), unabhängig von ihrer Herkunft; s. + /// {@link ContextObject}. Fehlt das Feld, gilt die Liste als leer. #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub context: Option>, @@ -6104,17 +6104,15 @@ pub struct SequenceRule { pub struct ImportedMesh { pub id: String, pub name: String, - /// Ursprünglicher DXF-Layer-Name (für spätere Kategorisierung). + /// [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und + /// Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`). + #[serde(rename = "categoryCode")] + pub category_code: String, + /// [181] Herkunft (z. B. „swissBUILDINGS3D", „IFC IfcSite", „DXF-Layer Haus") — nur Auskunft in der + /// Objekt-Info, ohne jede Wirkung auf Darstellung oder Sichtbarkeit (die steuert allein `categoryCode`). #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] - pub layer: Option, - /// Grafik-Kategorie-Code (s. {@link LayerCategory}, `model/contextCategories.ts`) - /// — steuert Sichtbarkeit/Grau/Sperren wie bei jedem anderen Bauteil (Ebenen- - /// Panel). Fehlt er (ältere Importe vor dieser Erweiterung), bleibt das Objekt - /// IMMER sichtbar (Rückwärtskompatibilität), s. `plan/context.rs` im Kern. - #[serde(rename = "categoryCode", default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub category_code: Option, + pub source: Option, /// Farbe aus der Quelldatei (`#rrggbb`, z. B. IFC-Oberflächenstil/Material); fehlt sie, gilt die Kontext-Grundfarbe. #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] @@ -6131,11 +6129,6 @@ pub struct ImportedMesh { #[serde(rename = "creaseAngle", default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub crease_angle: Option, - /// [137] Nur dieses Netz ausblenden (Grundriss, Schnitt, Ansicht, 3D, Pick); die Kategorie bleibt - /// davon unberührt. Fehlt/false = sichtbar. - #[serde(default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub hidden: Option, pub positions: Vec, pub indices: Vec, #[serde(flatten)] @@ -6204,14 +6197,15 @@ pub struct Contour { pub struct ContourSet { pub id: String, pub name: String, - /// Ursprünglicher DXF-Layer-Name (für spätere Kategorisierung). + /// [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und + /// Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`). + #[serde(rename = "categoryCode")] + pub category_code: String, + /// [181] Herkunft (z. B. „swissBUILDINGS3D", „IFC IfcSite", „DXF-Layer Haus") — nur Auskunft in der + /// Objekt-Info, ohne jede Wirkung auf Darstellung oder Sichtbarkeit (die steuert allein `categoryCode`). #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] - pub layer: Option, - /// Grafik-Kategorie-Code, s. {@link ImportedMesh.categoryCode}. - #[serde(rename = "categoryCode", default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub category_code: Option, + pub source: Option, pub contours: Vec, #[serde(flatten)] #[ts(skip)] @@ -6220,20 +6214,22 @@ pub struct ContourSet { /// Ein TIN-Geländemodell, abgeleitet aus Konturen (Delaunay über (x,y), Z aus der /// jeweiligen Kontur-Höhe). `positions` = flaches (x,y,z…)-Array in Metern, -/// `indices` = Dreiecks-Indizes. Gelände ist NICHT semantisch (Kontext-Schicht). +/// `indices` = Dreiecks-Indizes. Gelände-Element ([181]): aus Höhenlinien erzeugt oder importiert (swissALTI3D, +/// IFC-Gelände), danach unabhängig von der Quelle. #[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize, TS)] #[serde(default)] pub struct TerrainMesh { pub id: String, pub name: String, - /// Ebenen-/Gruppierungsname (SitePanel), z. B. „Terrain". Optional. + /// [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und + /// Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`). + #[serde(rename = "categoryCode")] + pub category_code: String, + /// [181] Herkunft (z. B. „swissBUILDINGS3D", „IFC IfcSite", „DXF-Layer Haus") — nur Auskunft in der + /// Objekt-Info, ohne jede Wirkung auf Darstellung oder Sichtbarkeit (die steuert allein `categoryCode`). #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] - pub layer: Option, - /// Grafik-Kategorie-Code, s. {@link ImportedMesh.categoryCode}. - #[serde(rename = "categoryCode", default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub category_code: Option, + pub source: Option, pub positions: Vec, pub indices: Vec, /// Optionale Pro-Vertex-Albedo (flach `[r,g,b, …]`, 0..1) — ein Wert je @@ -6265,11 +6261,6 @@ pub struct TerrainMesh { #[serde(rename = "sourceId", default, skip_serializing_if = "Option::is_none")] #[ts(optional)] pub source_id: Option, - /// [137] Nur dieses Netz ausblenden (Grundriss, Schnitt, Ansicht, 3D, Pick); die Kategorie bleibt - /// davon unberührt. Fehlt/false = sichtbar. - #[serde(default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub hidden: Option, #[serde(flatten)] #[ts(skip)] pub extra: Extra, @@ -6285,12 +6276,10 @@ pub struct TerrainMesh { pub struct Excavation { pub id: String, pub name: String, - #[serde(default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub layer: Option, - #[serde(rename = "categoryCode", default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub category_code: Option, + /// [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und + /// Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`). + #[serde(rename = "categoryCode")] + pub category_code: String, pub outline: Vec, pub bottom: f64, #[serde(default, skip_serializing_if = "Option::is_none")] @@ -6356,14 +6345,15 @@ pub struct ContextImageFilters { pub struct ContextImage { pub id: String, pub name: String, - /// Ebenen-/Gruppierungsname (SitePanel), z. B. „Luftbild". Optional. + /// [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und + /// Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`). + #[serde(rename = "categoryCode")] + pub category_code: String, + /// [181] Herkunft (z. B. „swissBUILDINGS3D", „IFC IfcSite", „DXF-Layer Haus") — nur Auskunft in der + /// Objekt-Info, ohne jede Wirkung auf Darstellung oder Sichtbarkeit (die steuert allein `categoryCode`). #[serde(default, skip_serializing_if = "Option::is_none")] #[ts(optional)] - pub layer: Option, - /// Grafik-Kategorie-Code, s. {@link ImportedMesh.categoryCode}. - #[serde(rename = "categoryCode", default, skip_serializing_if = "Option::is_none")] - #[ts(optional)] - pub category_code: Option, + pub source: Option, /// Bildquelle als Data-URL (PNG/JPEG). pub src: String, /// Modell-Meter Bounding-Box (das Bild füllt [min..max] planar von oben). diff --git a/src-tauri/core/src/model/manual.rs b/src-tauri/core/src/model/manual.rs index 71f9df3b..de077c9c 100644 --- a/src-tauri/core/src/model/manual.rs +++ b/src-tauri/core/src/model/manual.rs @@ -630,7 +630,9 @@ pub enum ParametricRule { Sequence(SequenceRule), } -/// Kontext-Objekt (Tag `type`). +/// Gelände- und Umgebungs-Element (Tag `type`, Sammlung `Project.context`, [181]): Netzkörper (`importedMesh`, +/// z. B. Nachbargebäude), Höhenlinien (`contourSet`), Gelände (`terrainMesh`), Luftbild (`image`), Baugrube +/// (`excavation`). Normale Elemente mit Klasse (`categoryCode`), unabhängig davon, woher sie kommen. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize, TS)] #[serde(tag = "type")] pub enum ContextObject { @@ -646,6 +648,30 @@ pub enum ContextObject { Excavation(Excavation), } +impl ContextObject { + /// [181] Klasse/Ebene des Elements (Pflichtfeld jeder Art). + pub fn category_code(&self) -> &str { + match self { + ContextObject::ImportedMesh(m) => &m.category_code, + ContextObject::ContourSet(s) => &s.category_code, + ContextObject::TerrainMesh(t) => &t.category_code, + ContextObject::Image(i) => &i.category_code, + ContextObject::Excavation(e) => &e.category_code, + } + } + + /// Element-Id. + pub fn id(&self) -> &str { + match self { + ContextObject::ImportedMesh(m) => &m.id, + ContextObject::ContourSet(s) => &s.id, + ContextObject::TerrainMesh(t) => &t.id, + ContextObject::Image(i) => &i.id, + ContextObject::Excavation(e) => &e.id, + } + } +} + impl Default for Drawing2DGeom { fn default() -> Self { Drawing2DGeom::Pointmarker { at: Vec2::default() } diff --git a/src-tauri/core/src/model/mod.rs b/src-tauri/core/src/model/mod.rs index 088fa192..327f3cfb 100644 --- a/src-tauri/core/src/model/mod.rs +++ b/src-tauri/core/src/model/mod.rs @@ -45,7 +45,7 @@ mod tests { #[test] fn importiertes_netz_mit_farbe_und_ifc_id() { let raw: Value = serde_json::from_str( - r##"{"type":"importedMesh","id":"m","name":"Wand","color":"#aabbcc","ifcGlobalId":"2O2Fr$t4X7Zf8NOew3FLOH", + r##"{"type":"importedMesh","id":"m","name":"Wand","categoryCode":"10","source":"IFC IfcWall","color":"#aabbcc","ifcGlobalId":"2O2Fr$t4X7Zf8NOew3FLOH", "positions":[0,0,0],"indices":[0,0,0]}"##, ) .unwrap(); diff --git a/src-tauri/core/src/model3d/context.rs b/src-tauri/core/src/model3d/context.rs index 36edf287..ac3dcc38 100644 --- a/src-tauri/core/src/model3d/context.rs +++ b/src-tauri/core/src/model3d/context.rs @@ -32,18 +32,11 @@ pub fn emit_context_meshes(p: &Project) -> Vec { // [T6]/[114] Ebenen-Sichtbarkeit: ein ausgeblendetes Gelände (Kategorie „02") verschwindet auch im 3D. let hidden = hidden_category_codes(&p.layers); for obj in p.context.as_deref().unwrap_or(&[]) { - let code = match obj { - ContextObject::TerrainMesh(m) => m.category_code.as_deref(), - ContextObject::ImportedMesh(m) => m.category_code.as_deref(), - _ => None, - }; - if code.is_some_and(|c| hidden.contains(c)) { + // [181] Sichtbarkeit allein über die Klasse. + if hidden.contains(obj.category_code()) { continue; } match obj { - // [137] Einzeln ausgeblendetes Gelände. - ContextObject::TerrainMesh(m) if m.hidden == Some(true) => {} - ContextObject::ImportedMesh(m) if m.hidden == Some(true) => {} ContextObject::TerrainMesh(m) if m.positions.len() >= 9 && m.indices.len() >= 3 => { // [T6] Baugruben schneiden das Gelände; Höhen im Modellbezug (Luftbild-Farben auf das geänderte Netz übertragen). let (pos, idx, _) = crate::excavation::terrain_model_mesh(p, m); diff --git a/src-tauri/core/src/model3d/pick.rs b/src-tauri/core/src/model3d/pick.rs index bfd03816..a2464086 100644 --- a/src-tauri/core/src/model3d/pick.rs +++ b/src-tauri/core/src/model3d/pick.rs @@ -189,15 +189,10 @@ pub fn pick_geometry(p: &Project) -> Result { let stairs = pick_stairs(p); // Kontext-Meshes: rohe Welt-Dreiecke, Modell (x, y, z) → Welt (x, z, −y). let mut context_meshes = Vec::new(); - // [137] Was im 3D nicht gezeichnet wird (Kategorie aus, Gelände einzeln aus), fängt auch keinen Klick. + // [137] Was im 3D nicht gezeichnet wird (Klasse aus), fängt auch keinen Klick. let hidden = hidden_category_codes(&p.layers); for obj in p.context.as_deref().unwrap_or(&[]) { - let code = match obj { - ContextObject::TerrainMesh(m) => m.category_code.as_deref(), - ContextObject::ImportedMesh(m) => m.category_code.as_deref(), - _ => None, - }; - if code.is_some_and(|c| hidden.contains(c)) || matches!(obj, ContextObject::TerrainMesh(m) if m.hidden == Some(true)) || matches!(obj, ContextObject::ImportedMesh(m) if m.hidden == Some(true)) { + if hidden.contains(obj.category_code()) { continue; } let (pos, idx, id) = match obj { diff --git a/src-tauri/core/src/model3d/tests.rs b/src-tauri/core/src/model3d/tests.rs index af1c8755..b291709d 100644 --- a/src-tauri/core/src/model3d/tests.rs +++ b/src-tauri/core/src/model3d/tests.rs @@ -64,7 +64,7 @@ fn near(a: V3, b: V3) -> bool { /// [T6]/[114] Gelände in ausgeblendeter Kategorie kommt nicht ins 3D. #[test] fn gelaende_ausgeblendet_nicht_im_3d() { - let t = crate::model::TerrainMesh { id: "t".into(), category_code: Some("02".into()), positions: vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0], indices: vec![0.0, 1.0, 2.0], ..Default::default() }; + let t = crate::model::TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0], indices: vec![0.0, 1.0, 2.0], ..Default::default() }; let cat = |visible| crate::model::LayerCategory { code: "02".into(), name: "Gelände".into(), visible, ..Default::default() }; let mk = |visible| Project { context: Some(vec![ContextObject::TerrainMesh(t.clone())]), layers: vec![cat(visible)], ..Default::default() }; assert_eq!(emit_context_meshes(&mk(true)).len(), 1); @@ -173,21 +173,19 @@ fn pick_dachfenster_im_3d() { assert!(g.roofs.iter().any(|r| r.roof_id == "RF1" && !r.tris.is_empty())); } -/// [137] Einzeln ausgeblendetes Gelände (`hidden`) und Gelände einer ausgeblendeten Kategorie fehlen im 3D -/// und in der Pick-Geometrie; ein zweites Netz bleibt. +/// [137]/[181] Gelände-Elemente verschwinden mit ihrer Klasse aus 3D und Pick-Geometrie; ein Gelände anderer Klasse bleibt. #[test] -fn gelaende_einzeln_ausblenden() { - let mk = |id: &str, hidden: Option, code: Option<&str>| { +fn gelaende_nach_klasse_ausblenden() { + let mk = |id: &str, code: &str| { ContextObject::TerrainMesh(TerrainMesh { id: id.into(), positions: vec![0.0, 0.0, 0.0, 10.0, 0.0, 0.0, 10.0, 10.0, 1.0], indices: vec![0.0, 1.0, 2.0], - hidden, - category_code: code.map(Into::into), + category_code: code.into(), ..Default::default() }) }; - let mut p = Project { context: Some(vec![mk("a", Some(true), None), mk("b", None, None), mk("c", Some(false), Some("02"))]), ..Default::default() }; + let mut p = Project { context: Some(vec![mk("b", "05"), mk("c", "02")]), ..Default::default() }; let ids = |p: &Project| pick_geometry(p).unwrap().context_meshes.iter().map(|m| m.context_object_id.clone()).collect::>(); assert_eq!(ids(&p), vec!["b", "c"]); assert_eq!(emit_context_meshes(&p).len(), 2); @@ -583,15 +581,16 @@ fn pick_kreis_bogen_text_im_3d() { assert!(inside(&g.drawing_meshes[2].tris, 21.0, 0.2) && !inside(&g.drawing_meshes[2].tris, 22.0, 0.2)); } -/// [137] Einzeln ausgeblendetes importiertes Netz: weder im 3D noch als Pick-Dreiecke. +/// [181] Netzkörper (z. B. Nachbargebäude) in ausgeblendeter Klasse: weder im 3D noch als Pick-Dreiecke. #[test] -fn importiertes_netz_einzeln_ausgeblendet() { - let mk = |hidden: Option| Project { - context: Some(vec![ContextObject::ImportedMesh(ImportedMesh { id: "m".into(), hidden, positions: vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0], indices: vec![0.0, 1.0, 2.0], ..Default::default() })]), +fn netzkoerper_klasse_ausgeblendet() { + let mk = |visible: bool| Project { + context: Some(vec![ContextObject::ImportedMesh(ImportedMesh { id: "m".into(), category_code: "12".into(), positions: vec![0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0], indices: vec![0.0, 1.0, 2.0], ..Default::default() })]), + layers: vec![crate::model::LayerCategory { code: "12".into(), name: "Gebäude".into(), visible, ..Default::default() }], ..Default::default() }; - assert_eq!(emit_context_meshes(&mk(None)).len(), 1); - assert_eq!(pick_geometry(&mk(None)).unwrap().context_meshes.len(), 1); - assert!(emit_context_meshes(&mk(Some(true))).is_empty()); - assert!(pick_geometry(&mk(Some(true))).unwrap().context_meshes.is_empty()); + assert_eq!(emit_context_meshes(&mk(true)).len(), 1); + assert_eq!(pick_geometry(&mk(true)).unwrap().context_meshes.len(), 1); + assert!(emit_context_meshes(&mk(false)).is_empty()); + assert!(pick_geometry(&mk(false)).unwrap().context_meshes.is_empty()); } diff --git a/src-tauri/core/src/plan/context.rs b/src-tauri/core/src/plan/context.rs index e7c84663..e6557432 100644 --- a/src-tauri/core/src/plan/context.rs +++ b/src-tauri/core/src/plan/context.rs @@ -59,7 +59,7 @@ fn bbox_corners(positions: &[f64]) -> Option> { (b.len() == 4).then(|| vec![v2(b[0], b[1]), v2(b[2], b[1]), v2(b[2], b[3]), v2(b[0], b[3])]) } -/// Kontext-Schicht (`addContextContours`). Objekte ohne Kategorie bleiben immer sichtbar. Die +/// Gelände- und Umgebungs-Elemente (`Project.context`, [181]); sichtbar nach ihrer Klasse. Die /// Höhenlinien-Beschriftungen weichen den Zeichnungen des Geschosses aus (`drawings::stamp_obstacle_prims`). pub fn plan_context(c: &Ctx, out: &mut Vec) { plan_context_with(c, out, c.drawn_obstacles()); @@ -80,23 +80,14 @@ pub fn plan_context_with(c: &Ctx, out: &mut Vec, drawing_obstacles: & if meshes_done && matches!(obj, ContextObject::ImportedMesh(_)) { continue; } - let code = match obj { - ContextObject::ImportedMesh(m) => m.category_code.as_deref(), - ContextObject::ContourSet(s) => s.category_code.as_deref(), - ContextObject::TerrainMesh(t) => t.category_code.as_deref(), - ContextObject::Image(i) => i.category_code.as_deref(), - ContextObject::Excavation(e) => e.category_code.as_deref(), - }; - if code.is_some_and(|k| !c.shown(k)) { + // [181] Sichtbarkeit allein über die Klasse (kein „ohne Kategorie immer sichtbar", kein Einzel-Ausblenden). + let code = Some(obj.category_code()); + if !c.shown(obj.category_code()) { continue; } if matches!(obj, ContextObject::TerrainMesh(_) | ContextObject::ContourSet(_) | ContextObject::Excavation(_)) && !terrain_shown(c) { continue; } - // [137] Einzeln ausgeblendetes Gelände bzw. importiertes Netz (Kategorie bleibt sichtbar). - if matches!(obj, ContextObject::TerrainMesh(t) if t.hidden == Some(true)) || matches!(obj, ContextObject::ImportedMesh(m) if m.hidden == Some(true)) { - continue; - } // [33] Gelände und Höhenlinien über Regeln (Bauteilart „Gelände“): Ausblenden, Linie (Farbe, Stärke, Linienstil). let tov = match obj { ContextObject::TerrainMesh(t) => super::overrides::terrain_override(c.p, c.rule_view(), code, &t.name), @@ -171,7 +162,7 @@ pub fn plan_context_with(c: &Ctx, out: &mut Vec, drawing_obstacles: & /// [157] Sohle und Böschungsoberkante der Baugruben, die dieser Grundriss zeigt (Gelände sichtbar, Kategorie /// der Baugrube gezeigt), als Strecken — Hindernisse der Aussenbemassung und der Schnittmarken-Beschriftung. pub(super) fn excavation_segments(c: &Ctx) -> Vec<([f64; 2], [f64; 2])> { - let pits: Vec<&Excavation> = crate::excavation::excavations(c.p).into_iter().filter(|e| e.category_code.as_deref().is_none_or(|k| c.shown(k))).collect(); + let pits: Vec<&Excavation> = crate::excavation::excavations(c.p).into_iter().filter(|e| c.shown(&e.category_code)).collect(); if pits.is_empty() || !terrain_shown(c) { return Vec::new(); } @@ -977,7 +968,7 @@ pub fn plan_section_lines(c: &Ctx, out: &mut Vec) { if !excavation_segments(c).is_empty() { let house = terrain_footprint(c.p, &c.a.floor); let (mut pit, mut bands) = (Vec::new(), Vec::new()); - for e in crate::excavation::excavations(c.p).into_iter().filter(|e| e.category_code.as_deref().is_none_or(|k| c.shown(k))) { + for e in crate::excavation::excavations(c.p).into_iter().filter(|e| c.shown(&e.category_code)) { excavation_lines(c, e, &mut pit, &mut bands, &house); } for q in &pit { @@ -1057,23 +1048,25 @@ mod tests { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 60.0, 0.0, 6.0, 60.0, 40.0, 6.0, 0.0, 40.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], - category_code: Some("02".into()), + category_code: "02".into(), ..Default::default() }; let pit = Excavation { id: "bg".into(), + category_code: "02".into(), outline: vec![v2(20.0, 15.0), v2(30.0, 15.0), v2(30.0, 25.0), v2(20.0, 25.0)], bottom: 1.0, ..Default::default() }; let cs = ContourSet { id: "hl".into(), + category_code: "02".into(), contours: vec![Contour { z: 0.0, pts: vec![v2(-20.0, -5.0), v2(80.0, 50.0)], ..Default::default() }], ..Default::default() }; // Reihenfolge wie im Musterhaus komplex: Höhenlinien, Baugrube, dann das daraus erzeugte Gelände. let p = Project { context: Some(vec![ContextObject::ContourSet(cs), ContextObject::Excavation(pit), ContextObject::TerrainMesh(t)]), ..Default::default() }; - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "scale": 100}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "02"], "scale": 100}"#).unwrap(); let mut out = Vec::new(); plan_context(&Ctx::new(&p, &a), &mut out); assert_eq!(top_context(&out, 25.0, 20.0).as_deref(), Some("bg"), "Sohle"); @@ -1096,7 +1089,7 @@ mod tests { // Pfeil nach unten (Ansicht Nord, oben im Plan) und nach links/rechts. let p = Project { drawing_levels: vec![level("Ansicht Nord", [10.0, 20.0], [0.0, 20.0]), level("Ansicht West", [-5.0, 10.0], [-5.0, 0.0]), level("Ansicht Ost", [15.0, 0.0], [15.0, 10.0]), level("Schnitt A-A", [0.0, 5.0], [60.0, 5.0])], ..Default::default() }; let run = |scale: f64| { - let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["90"], "scale": {scale}, "global": true}}"#)).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["02", "90"], "scale": {scale}, "global": true}}"#)).unwrap(); let mut out = Vec::new(); plan_section_lines(&Ctx::new(&p, &a), &mut out); out @@ -1125,7 +1118,7 @@ mod tests { } } // Ausmass des Plans umfasst die Beschriftung der Ansicht Nord (über y = 20). - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["90"], "scale": 100, "global": true}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "90"], "scale": 100, "global": true}"#).unwrap(); let d = super::super::domains::plan_domains(&p, &a).unwrap(); let top = out_top(&run(100.0)); assert!(d.bounds.is_some_and(|b| b[3] >= top - 1e-9), "{:?} < {top}", d.bounds); @@ -1140,7 +1133,7 @@ mod tests { "linePoints": [{ "x": 0.0, "y": -2.0 }, { "x": 10.0, "y": -2.0 }] })).unwrap()], ..Default::default() }; - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["90"], "scale": 100, "global": true}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "90"], "scale": 100, "global": true}"#).unwrap(); let mut out = Vec::new(); plan_section_lines(&Ctx::new(&p, &a), &mut out); assert!(!out.iter().any(|q| matches!(q, Primitive::Line { .. } | Primitive::Arc { .. })), "keine Linie, kein Kreis"); @@ -1171,7 +1164,7 @@ mod tests { p }; let run = |p: &Project, mv: bool| { - let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["90"], "scale": 100, "global": true{}}}"#, if mv { r#", "modelView": "m""# } else { "" })).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["02", "90"], "scale": 100, "global": true{}}}"#, if mv { r#", "modelView": "m""# } else { "" })).unwrap(); let mut out = Vec::new(); plan_section_lines(&Ctx::new(p, &a), &mut out); out @@ -1200,7 +1193,7 @@ mod tests { } }; let run = |p: &Project| { - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["90"], "scale": 100, "global": true}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "90"], "scale": 100, "global": true}"#).unwrap(); let mut out = Vec::new(); plan_section_lines(&Ctx::new(p, &a), &mut out); out @@ -1236,7 +1229,7 @@ mod tests { .collect() }; let run = |p: &Project, scale: f64| { - let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"floor": "eg", "show": ["90", "80"], "scale": {scale}}}"#)).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"floor": "eg", "show": ["02", "90", "80"], "scale": {scale}}}"#)).unwrap(); let mut out = Vec::new(); plan_section_lines(&Ctx::new(p, &a), &mut out); out @@ -1291,7 +1284,7 @@ mod tests { assert!(outside(v2(4.0, 4.0), v2(5.0, 4.0), &rings).is_empty()); assert_eq!(outside(v2(20.0, 4.0), v2(25.0, 4.0), &rings).len(), 1); // Im Plan: Gelände z = x/10, Haus aus vier Wänden 12..18 × 0..10 → keine Höhenlinie bei x = 15 im Haus. - let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 30.0, 0.0, 3.0, 30.0, 10.0, 3.0, 0.0, 10.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.5), ..Default::default() }; + let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 30.0, 0.0, 3.0, 30.0, 10.0, 3.0, 0.0, 10.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.5), ..Default::default() }; let mut v: serde_json::Value = serde_json::from_str(include_str!("../../tests/fixtures/sample_project.json")).unwrap(); let wall = |id: &str, a: [f64; 2], b: [f64; 2]| serde_json::json!({"id": id, "type": "wall", "floorId": v["drawingLevels"][0]["id"], "categoryCode": "20", "wallTypeId": v["walls"][0]["wallTypeId"], "start": {"x": a[0], "y": a[1]}, "end": {"x": b[0], "y": b[1]}, "height": 3}); let walls = serde_json::json!([wall("a", [12.0, -2.0], [18.0, -2.0]), wall("b", [18.0, -2.0], [18.0, 12.0]), wall("c", [18.0, 12.0], [12.0, 12.0]), wall("d", [12.0, 12.0], [12.0, -2.0])]); @@ -1299,7 +1292,7 @@ mod tests { v["openings"] = serde_json::json!([]); let mut p: Project = serde_json::from_value(v).unwrap(); p.context = Some(vec![ContextObject::TerrainMesh(t)]); - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"scale": 100}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "scale": 100}"#).unwrap(); let mut out = Vec::new(); plan_context(&Ctx::new(&p, &a), &mut out); let lines: Vec<(Vec2, Vec2)> = out.iter().filter_map(|q| match q { Primitive::Line { a, b, color: Some(c), .. } if c == TERRAIN_INK => Some((*a, *b)), _ => None }).collect(); @@ -1327,13 +1320,14 @@ mod tests { // x 0..10 flach (z = 0.1 x), x 10..11 steil (z 1 → 11). let t = TerrainMesh { id: "t".into(), + category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 10.0, 0.0, 1.0, 10.0, 10.0, 1.0, 0.0, 10.0, 0.0, 11.0, 0.0, 11.0, 11.0, 10.0, 11.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0, 1.0, 4.0, 5.0, 1.0, 5.0, 2.0], contour_interval: Some(0.1), ..Default::default() }; let p = Project { context: Some(vec![ContextObject::TerrainMesh(t)]), ..Default::default() }; - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"scale": 100}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "scale": 100}"#).unwrap(); let mut out = Vec::new(); plan_context(&Ctx::new(&p, &a), &mut out); let xs: Vec = out.iter().filter_map(|q| match q { Primitive::Line { a, b, color: Some(c), .. } if c == TERRAIN_INK && (a.x - b.x).abs() < 1e-9 => Some(a.x), _ => None }).collect(); @@ -1353,18 +1347,19 @@ mod tests { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 60.0, 0.0, 6.0, 60.0, 40.0, 6.0, 0.0, 40.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], - category_code: Some("02".into()), + category_code: "02".into(), contour_interval: Some(1.0), ..Default::default() }; let pit = Excavation { id: "bg".into(), + category_code: "02".into(), outline: vec![v2(20.0, 15.0), v2(30.0, 15.0), v2(30.0, 25.0), v2(20.0, 25.0)], bottom: 1.0, ..Default::default() }; let p = Project { context: Some(vec![ContextObject::TerrainMesh(t), ContextObject::Excavation(pit)]), ..Default::default() }; - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "scale": 100}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "02"], "scale": 100}"#).unwrap(); let mut out = Vec::new(); plan_context(&Ctx::new(&p, &a), &mut out); let w = |m: f64| out.iter().filter(|q| matches!(q, Primitive::Line { weight_mm, color: Some(c), .. } if *weight_mm == m && c == TERRAIN_INK)).count(); @@ -1418,9 +1413,9 @@ mod tests { ["o1", "og", 30.0, 20.0, 38.0, 20.0] ])); // Gelände z = y/10 über 40 × 30 m: Höhenlinien waagrecht je 1 m, Zähllinien je 5 m (z = 0.5, 1.0 …). - let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 30.0, 3.0, 0.0, 30.0, 3.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() }; + let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 30.0, 3.0, 0.0, 30.0, 3.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() }; p.context = Some(vec![ContextObject::TerrainMesh(t)]); - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "scale": 100}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "floor": "eg", "scale": 100}"#).unwrap(); let mut out = Vec::new(); plan_context(&Ctx::new(&p, &a), &mut out); let lines: Vec<(Vec2, Vec2)> = out.iter().filter_map(|q| match q { Primitive::Line { a, b, color: Some(c), .. } if c == TERRAIN_INK => Some((*a, *b)), _ => None }).collect(); @@ -1452,9 +1447,9 @@ mod tests { ["a1", "eg", 18.5, 8.0, 18.5, 12.0], ["a2", "eg", 18.5, 12.0, 21.5, 12.0], ["a3", "eg", 21.5, 12.0, 21.5, 8.0] ])); // Grube mit Arbeitsraum: Nordrand bei y = 10 läuft durch den Anbau. - let pit = Excavation { id: "bg".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, ..Default::default() }; + let pit = Excavation { id: "bg".into(), category_code: "02".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, ..Default::default() }; p.context = Some(vec![ContextObject::Excavation(pit)]); - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "scale": 100}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "floor": "eg", "scale": 100}"#).unwrap(); let mut out = Vec::new(); plan_context(&Ctx::new(&p, &a), &mut out); let sohle: Vec<(Vec2, Vec2)> = out.iter().filter_map(|q| match q { Primitive::Line { a, b, color: Some(c), weight_mm, .. } if c == EXCAVATION_INK && (*weight_mm - 0.25).abs() < 1e-9 => Some((*a, *b)), _ => None }).collect(); @@ -1472,13 +1467,13 @@ mod tests { #[test] fn schnittmarke_nicht_auf_der_boeschung() { let mut p = sample_with_walls(serde_json::json!([["h1", "eg", 14.0, 0.0, 26.0, 0.0]])); - let t = TerrainMesh { id: "t".into(), positions: vec![0.0, -10.0, 0.0, 40.0, -10.0, 0.0, 40.0, 30.0, 0.0, 0.0, 30.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() }; - let pit = Excavation { id: "bg".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, slope: Some(45.0), ..Default::default() }; + let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, -10.0, 0.0, 40.0, -10.0, 0.0, 40.0, 30.0, 0.0, 0.0, 30.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() }; + let pit = Excavation { id: "bg".into(), category_code: "02".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, slope: Some(45.0), ..Default::default() }; p.context = Some(vec![ContextObject::TerrainMesh(t), ContextObject::Excavation(pit)]); // Schnittlinie mit den Enden in der West- und Ostböschung. p.drawing_levels.push(serde_json::from_value(serde_json::json!({ "id": "s", "name": "Schnitt B-B", "kind": "section", "visible": true, "locked": false, "linePoints": [{ "x": 10.5, "y": 4.0 }, { "x": 29.5, "y": 4.0 }] })).unwrap()); - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "show": ["90", "80", "02"], "scale": 100}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "show": ["02", "90", "80", "02"], "scale": 100}"#).unwrap(); let c = Ctx::new(&p, &a); let mut out = Vec::new(); plan_section_lines(&c, &mut out); @@ -1516,15 +1511,15 @@ mod tests { let mut p = sample_with_walls(serde_json::json!([ ["h1", "eg", 14.0, 0.0, 26.0, 0.0], ["h2", "eg", 26.0, 0.0, 26.0, 8.0], ["h3", "eg", 26.0, 8.0, 14.0, 8.0], ["h4", "eg", 14.0, 8.0, 14.0, 0.0] ])); - let t = TerrainMesh { id: "t".into(), positions: vec![0.0, -10.0, 0.0, 40.0, -10.0, 0.0, 40.0, 30.0, 0.0, 0.0, 30.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() }; + let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, -10.0, 0.0, 40.0, -10.0, 0.0, 40.0, 30.0, 0.0, 0.0, 30.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], ..Default::default() }; // Sohle 2 m ausserhalb, 3 m tief, 45°: Böschungsoberkante West bei x ≈ 9. - let pit = Excavation { id: "bg".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, slope: Some(45.0), ..Default::default() }; + let pit = Excavation { id: "bg".into(), category_code: "02".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, slope: Some(45.0), ..Default::default() }; p.context = Some(vec![ContextObject::TerrainMesh(t), ContextObject::Excavation(pit)]); let dim = |id: &str, off: f64| serde_json::from_value::(serde_json::json!({"id": id, "type": "drawing2d", "levelId": "eg", "categoryCode": "20", "geom": {"shape": "dimension", "pts": [{"x": 13.8, "y": 0}, {"x": 13.8, "y": 8}], "offset": off}})).unwrap(); p.drawings2d = vec![dim("autodim-eg-west-openings", 1.0), dim("autodim-eg-west-total", 2.4), dim("eigene", 1.5)]; // Masslinien (senkrecht, über die ganze Kette) je Zeichnung. let lines = |p: &Project| -> Vec<(String, f64)> { - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "scale": 100, "show": ["20"]}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "scale": 100, "show": ["02", "20"]}"#).unwrap(); let mut out = Vec::new(); for q in super::super::drawings::stamp_obstacle_prims(&Ctx::new(p, &a)) { if let Primitive::Line { a, b, drawing_id: Some(id), .. } = q { @@ -1552,12 +1547,12 @@ mod tests { #[test] fn gelaende_nur_im_erdgeschoss() { let mut p = sample_with_walls(serde_json::json!([["h1", "eg", 14.0, 0.0, 26.0, 0.0]])); - let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 30.0, 3.0, 0.0, 30.0, 3.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() }; - let pit = Excavation { id: "bg".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, ..Default::default() }; - let cs = ContourSet { id: "hl".into(), contours: vec![Contour { pts: vec![v2(0.0, 20.0), v2(40.0, 20.0)], ..Default::default() }], ..Default::default() }; + let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 30.0, 3.0, 0.0, 30.0, 3.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() }; + let pit = Excavation { id: "bg".into(), category_code: "02".into(), outline: vec![v2(12.0, -2.0), v2(28.0, -2.0), v2(28.0, 10.0), v2(12.0, 10.0)], bottom: -3.0, ..Default::default() }; + let cs = ContourSet { id: "hl".into(), category_code: "02".into(), contours: vec![Contour { pts: vec![v2(0.0, 20.0), v2(40.0, 20.0)], ..Default::default() }], ..Default::default() }; p.context = Some(vec![ContextObject::TerrainMesh(t), ContextObject::Excavation(pit), ContextObject::ContourSet(cs)]); let count = |p: &Project, floor: &str, scale: f64| { - let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"floor": "{floor}", "scale": {scale}}}"#)).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"show": ["02"], "floor": "{floor}", "scale": {scale}}}"#)).unwrap(); let mut out = Vec::new(); plan_context(&Ctx::new(p, &a), &mut out); out.iter().filter(|q| matches!(q, Primitive::Line { color: Some(c), .. } if c == TERRAIN_INK || c == EXCAVATION_INK || c == CONTEXT_LINE_COLOR)).count() @@ -1575,10 +1570,10 @@ mod tests { /// Böschungsoberkante oder Böschungsschraffur (vorher „-2.5“/„-2.2“ in der Böschung, Musterhaus komplex EG). #[test] fn hoehenkoten_nicht_auf_der_baugrube() { - let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 60.0, 0.0, 6.0, 60.0, 40.0, 6.0, 0.0, 40.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() }; - let pit = Excavation { id: "bg".into(), outline: vec![v2(20.0, 5.0), v2(40.0, 5.0), v2(40.0, 35.0), v2(20.0, 35.0)], bottom: 0.5, ..Default::default() }; + let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 60.0, 0.0, 6.0, 60.0, 40.0, 6.0, 0.0, 40.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() }; + let pit = Excavation { id: "bg".into(), category_code: "02".into(), outline: vec![v2(20.0, 5.0), v2(40.0, 5.0), v2(40.0, 35.0), v2(20.0, 35.0)], bottom: 0.5, ..Default::default() }; let p = Project { context: Some(vec![ContextObject::Excavation(pit), ContextObject::TerrainMesh(t)]), ..Default::default() }; - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02"], "scale": 100}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"show": ["02", "02"], "scale": 100}"#).unwrap(); let mut out = Vec::new(); plan_context(&Ctx::new(&p, &a), &mut out); let pit_lines: Vec<(Vec2, Vec2)> = out.iter().filter_map(|q| match q { Primitive::Line { a, b, color: Some(c), .. } if c == EXCAVATION_INK => Some((*a, *b)), _ => None }).collect(); @@ -1601,10 +1596,10 @@ mod tests { #[test] fn hoehenlinien_beschriftungen_kollisionsfrei() { // Steil: z = 4·y über 40 × 10 m → Zähllinien (z = 0.5 k) alle 0.125 m = 1.25 mm Papier. - let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 10.0, 40.0, 0.0, 10.0, 40.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() }; + let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 0.0, 40.0, 10.0, 40.0, 0.0, 10.0, 40.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], contour_interval: Some(0.1), ..Default::default() }; let dim: Drawing2D = serde_json::from_value(serde_json::json!({ "id": "d", "type": "drawing2d", "levelId": "eg", "categoryCode": "80", "geom": { "shape": "dimension", "pts": [{ "x": 2.0, "y": 5.0 }, { "x": 38.0, "y": 5.0 }], "offset": 0.0 } })).unwrap(); let p = Project { context: Some(vec![ContextObject::TerrainMesh(t)]), drawings2d: vec![dim], ..Default::default() }; - let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "show": ["80"], "scale": 100}"#).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, r#"{"floor": "eg", "show": ["02", "80"], "scale": 100}"#).unwrap(); let c = Ctx::new(&p, &a); let mut out = Vec::new(); plan_context(&c, &mut out); @@ -1649,11 +1644,11 @@ mod tests { /// Speicher), nach einem anderen Massstab und ohne Speicher (`contour_prims`). #[test] fn hoehenlinien_aus_dem_zwischenspeicher_wie_neu() { - let t = TerrainMesh { id: "t".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 2.0, 40.0, 30.0, 9.0, 0.0, 30.0, 4.0, 20.0, 15.0, 7.5], indices: vec![0.0, 1.0, 4.0, 1.0, 2.0, 4.0, 2.0, 3.0, 4.0, 3.0, 0.0, 4.0], contour_interval: Some(0.1), ..Default::default() }; + let t = TerrainMesh { id: "t".into(), category_code: "02".into(), positions: vec![0.0, 0.0, 0.0, 40.0, 0.0, 2.0, 40.0, 30.0, 9.0, 0.0, 30.0, 4.0, 20.0, 15.0, 7.5], indices: vec![0.0, 1.0, 4.0, 1.0, 2.0, 4.0, 2.0, 3.0, 4.0, 3.0, 0.0, 4.0], contour_interval: Some(0.1), ..Default::default() }; let mut p = sample_with_walls(serde_json::json!([["w1", "eg", 5, 5, 15, 5], ["w2", "eg", 15, 5, 15, 12], ["w3", "eg", 15, 12, 5, 12], ["w4", "eg", 5, 12, 5, 5]])); p.context = Some(vec![ContextObject::TerrainMesh(t.clone())]); let run = |scale: f64| { - let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"floor": "eg", "show": ["80"], "scale": {scale}}}"#)).unwrap(); + let a = super::super::domains::PlanArgs::parse(1.0, &format!(r#"{{"floor": "eg", "show": ["02", "80"], "scale": {scale}}}"#)).unwrap(); let c = Ctx::new(&p, &a); let mut out = Vec::new(); plan_context(&c, &mut out); diff --git a/src-tauri/core/src/plan/elevation/face.rs b/src-tauri/core/src/plan/elevation/face.rs index 23b1cc0c..d7cd8b58 100644 --- a/src-tauri/core/src/plan/elevation/face.rs +++ b/src-tauri/core/src/plan/elevation/face.rs @@ -134,7 +134,7 @@ pub(super) fn face_overrides(p: &Project, faces: &mut [Face], v: RuleView) { Role::Mesh => p.context.as_deref().unwrap_or(&[]).iter().find_map(|c| match c { ContextObject::ImportedMesh(m) if m.id == id => Some(m), _ => None, - }).and_then(|m| surf_ov(p, v, super::super::section::MESH_KIND, m.category_code.as_deref().unwrap_or(""), Some(&m.name), &[], None)), + }).and_then(|m| surf_ov(p, v, super::super::section::MESH_KIND, &m.category_code, Some(&m.name), &[], None)), }; memo.insert(key, o.clone()); f.ov = o; diff --git a/src-tauri/core/src/plan/elevation/mod.rs b/src-tauri/core/src/plan/elevation/mod.rs index b8971265..f3376878 100644 --- a/src-tauri/core/src/plan/elevation/mod.rs +++ b/src-tauri/core/src/plan/elevation/mod.rs @@ -224,9 +224,7 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool, let mut mesh_cat: HashMap<&str, &str> = HashMap::new(); for c in p.context.as_deref().unwrap_or(&[]) { if let ContextObject::ImportedMesh(m) = c { - if let Some(code) = m.category_code.as_deref() { - mesh_cat.entry(m.id.as_str()).or_insert(code); - } + mesh_cat.entry(m.id.as_str()).or_insert(m.category_code.as_str()); } } let category = |f: &Face| -> Option<&str> { @@ -614,13 +612,13 @@ pub fn elevation_primitives_with(p: &Project, level: &LevelSpec, shadows: bool, let depth_max = faces.iter().map(|f| f.depth_min).fold(f64::INFINITY, f64::min) + 0.3; let mut has_terrain = false; if acc.min_x.is_finite() && depth_max.is_finite() && !crate::excavation::terrains(p).is_empty() { - let terrain_shown = |c: Option<&str>| c.is_none_or(|c| vis.visible(c) && vis.render(c)); + let terrain_shown = |c: &str| vis.visible(c) && vis.render(c); for t in crate::excavation::terrains(p) { - if !terrain_shown(t.category_code.as_deref()) || t.hidden == Some(true) { + if !terrain_shown(&t.category_code) { continue; } // [33] Gelände über Regeln (Bauteilart „Gelände“): Ausblenden, Füllung der Geländefläche, Linie. - let tov = super::overrides::terrain_override(p, rv, t.category_code.as_deref(), &t.name); + let tov = super::overrides::terrain_override(p, rv, Some(&t.category_code), &t.name); if tov.as_ref().is_some_and(|(a, _)| a.hidden()) { continue; } diff --git a/src-tauri/core/src/plan/elevation/tests.rs b/src-tauri/core/src/plan/elevation/tests.rs index cd698f7e..2511cf05 100644 --- a/src-tauri/core/src/plan/elevation/tests.rs +++ b/src-tauri/core/src/plan/elevation/tests.rs @@ -36,7 +36,7 @@ fn beispiel_ansicht() { #[test] fn importierte_netze_in_der_ansicht() { use crate::mesh_view::tests::cube; - let mesh = |id: &str, (positions, indices): (Vec, Vec)| ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: Some("10".into()), color: Some("#ff0000".into()), positions, indices, ..Default::default() }); + let mesh = |id: &str, (positions, indices): (Vec, Vec)| ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: "10".into(), color: Some("#ff0000".into()), positions, indices, ..Default::default() }); // Ansicht von y = −1 nach +y, u = x + 5. let level = LevelSpec { kind: "elevation".into(), line: Some([Vec2 { x: -5.0, y: -1.0 }, Vec2 { x: 8.0, y: -1.0 }]), direction_sign: Some(1.0), ..Default::default() }; let lines = |prims: &[Primitive]| -> Vec<([f64; 2], [f64; 2])> { @@ -77,7 +77,7 @@ fn importierte_netze_in_der_ansicht() { #[test] fn verdeckte_netzflaechen_entfallen() { use crate::mesh_view::tests::cube; - let mesh = |id: &str, (positions, indices): (Vec, Vec)| ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: Some("10".into()), positions, indices, ..Default::default() }); + let mesh = |id: &str, (positions, indices): (Vec, Vec)| ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: "10".into(), positions, indices, ..Default::default() }); let level = LevelSpec { kind: "elevation".into(), line: Some([Vec2 { x: -5.0, y: -1.0 }, Vec2 { x: 8.0, y: -1.0 }]), direction_sign: Some(1.0), ..Default::default() }; let count = |prims: &[Primitive], id: &str| prims.iter().filter(|q| matches!(q, Primitive::Polygon { context_object_id: Some(i), .. } if i == id)).count(); // Wand x −1…5, 3 m hoch, bei y = 0.5; dahinter „hinten" (ganz verdeckt), „teil" (ragt rechts heraus), diff --git a/src-tauri/core/src/plan/extras.rs b/src-tauri/core/src/plan/extras.rs index c4485029..8f7f36fc 100644 --- a/src-tauri/core/src/plan/extras.rs +++ b/src-tauri/core/src/plan/extras.rs @@ -603,14 +603,7 @@ pub fn extra_bounds(p: &Project, extra: &[(Primitive, u32)], shown: impl Fn(&str } } for obj in p.context.as_deref().unwrap_or(&[]) { - let code = match obj { - ContextObject::ImportedMesh(m) => m.category_code.as_deref(), - ContextObject::ContourSet(s) => s.category_code.as_deref(), - ContextObject::TerrainMesh(t) => t.category_code.as_deref(), - ContextObject::Image(i) => i.category_code.as_deref(), - ContextObject::Excavation(e) => e.category_code.as_deref(), - }; - if code.is_some_and(|k| !shown(k)) { + if !shown(obj.category_code()) { continue; } match obj { diff --git a/src-tauri/core/src/plan/mesh_plan.rs b/src-tauri/core/src/plan/mesh_plan.rs index 31eafedd..a86728eb 100644 --- a/src-tauri/core/src/plan/mesh_plan.rs +++ b/src-tauri/core/src/plan/mesh_plan.rs @@ -62,7 +62,7 @@ fn mesh_ov(c: &Ctx, m: &ImportedMesh) -> Option { if !super::overrides::has_active(c.p, v) { return None; } - let code = m.category_code.as_deref(); + let code = Some(m.category_code.as_str()); let s = super::overrides::Subject { layer_name: code.and_then(|k| c.p.layer_category(k)).map(|k| k.name.as_str()), layer_code: code, object_name: Some(&m.name), element_kind: Some(super::section::MESH_KIND), ..Default::default() }; let (el, ly, _) = super::overrides::effective_surface(c.p.override_rules.as_deref(), &s, v); let hatch = match ly.hatch.as_deref() { @@ -181,7 +181,7 @@ pub fn plan_meshes(c: &Ctx, out: &mut Vec) -> bool { let cut = range.cut; let meshes: Vec<(MeshRef, Zone)> = mesh_view::meshes(c.p) .into_iter() - .filter(|m| m.mesh.category_code.as_deref().is_none_or(|k| c.shown(k)) && !c.rule_hidden(&m.mesh.id)) + .filter(|m| c.shown(&m.mesh.category_code) && !c.rule_hidden(&m.mesh.id)) .filter_map(|m| { let z = zone_of(&range, band, m.info.bbox[2], m.info.bbox[5])?; Some((m, z)) @@ -192,7 +192,7 @@ pub fn plan_meshes(c: &Ctx, out: &mut Vec) -> bool { } let (solid_fill, solid_hatch) = if c.solid_cut() { (HATCH_INK.to_string(), no_hatch()) } else { (super::section::BODY_FILL.to_string(), super::section::section_hatch()) }; let ovs: Vec> = meshes.iter().map(|(m, _)| mesh_ov(c, m.mesh)).collect(); - let greyed = |m: &MeshRef| m.mesh.category_code.as_deref().is_some_and(|k| c.greyed(k)); + let greyed = |m: &MeshRef| c.greyed(&m.mesh.category_code); // Schnittflächen (und Verdecker der Aufsicht in Tiefe 0). let mut below: Vec = Vec::new(); let mut cut_prims: Vec = Vec::new(); @@ -287,7 +287,7 @@ mod tests { use crate::plan::domains::PlanArgs; fn mesh(id: &str, (positions, indices): (Vec, Vec)) -> ContextObject { - ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: Some("10".into()), positions, indices, ..Default::default() }) + ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: id.into(), category_code: "10".into(), positions, indices, ..Default::default() }) } /// Zwei Geschosse: EG (0, Höhe 2.7, Schnitt 1.0), OG (2.7). diff --git a/src-tauri/core/src/plan/overrides.rs b/src-tauri/core/src/plan/overrides.rs index 03d5c9dc..655fef7e 100644 --- a/src-tauri/core/src/plan/overrides.rs +++ b/src-tauri/core/src/plan/overrides.rs @@ -358,7 +358,7 @@ pub fn hidden_elements(p: &Project, v: RuleView) -> HashSet { // [152] Importierte Netze (Bauteilart „mesh"); ohne Kategorie nur über Name/Bauteilart. for c in p.context.iter().flatten() { if let ContextObject::ImportedMesh(m) = c { - if test(super::section::MESH_KIND, m.category_code.as_deref().unwrap_or(""), Some(&m.name)) { + if test(super::section::MESH_KIND, &m.category_code, Some(&m.name)) { out.insert(m.id.clone()); } } diff --git a/src-tauri/core/src/plan/section/mesh_tests.rs b/src-tauri/core/src/plan/section/mesh_tests.rs index 17f03e64..8cc2ec8d 100644 --- a/src-tauri/core/src/plan/section/mesh_tests.rs +++ b/src-tauri/core/src/plan/section/mesh_tests.rs @@ -4,7 +4,7 @@ use super::*; use crate::mesh_view::tests::{barrel, cube, prism}; fn mesh(id: &str, (positions, indices): (Vec, Vec)) -> ContextObject { - ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: format!("Netz {id}"), category_code: Some("10".into()), positions, indices, ..Default::default() }) + ContextObject::ImportedMesh(ImportedMesh { id: id.into(), name: format!("Netz {id}"), category_code: "10".into(), positions, indices, ..Default::default() }) } /// Schnitt längs x bei y = 0 ab x = −5 (u = x + 5), Blick nach +y (hinter der Ebene: y > 0). @@ -38,12 +38,6 @@ fn wuerfel_netz_geschnitten() { let vis = Visibility { has_vis: true, invisible: ["10".to_string()].into(), ..Default::default() }; let (prims, _) = section_primitives_at(&o, false, false, &vis, 100.0, Detail::Mittel, false, &CutRules::default()); assert!(!prims.iter().any(|q| matches!(q, Primitive::Polygon { context_object_id: Some(_), .. }))); - // Einzeln ausgeblendet ([137]): weg. - let mut q = p.clone(); - if let Some(ContextObject::ImportedMesh(m)) = q.context.as_mut().and_then(|c| c.first_mut()) { - m.hidden = Some(true); - } - assert!(mesh_cuts(&compute_section(&q, &lv(false), &[]).unwrap().unwrap()).is_empty()); } #[test] @@ -168,21 +162,18 @@ fn netz_override_fuellung_und_ausblenden() { assert!(mesh_cuts(&compute_section(&q, &lv(false), &[]).unwrap().unwrap()).is_empty()); } -/// [152] IFC-Gelände (Netz „Gelaende" der Klasse IfcSite, 1 m dicke Platte) als Geländelinie mit Erdreich statt als -/// geschnittener Körper; ein Netz ohne Gelände-Merkmal bleibt Körper. +/// [152]/[181] Geschlossenes Gelände-Netz (z. B. IFC-Gelände als 1 m dicke Platte, beim Import zum Gelände-Element +/// geworden): im Schnitt Geländelinie (nur Oberkante) mit Erdreich statt geschnittener Körper; ein Netzkörper gleicher +/// Form bleibt Körper — entscheidend ist die Elementart, nicht Name oder Herkunft. #[test] -fn ifc_gelaende_als_gelaendelinie() { - let terrain = |name: &str, layer: Option<&str>| { - let (positions, indices) = cube(-4.0, 7.0, -3.0, 3.0, -1.0, 0.0); - ContextObject::ImportedMesh(ImportedMesh { id: "g".into(), name: name.into(), layer: layer.map(String::from), category_code: Some("10".into()), positions, indices, ..Default::default() }) - }; - for (name, layer) in [("Gelaende", Some("IfcSite")), ("Terrain", None), ("Site (3)", Some("IfcSite")), ("Gelände 1", Some("IfcGeographicElement"))] { - let p = with(vec![terrain(name, layer), mesh("w", cube(1.0, 3.0, -1.0, 2.0, 0.0, 2.5))]); - let ContextObject::ImportedMesh(g) = &p.context.as_ref().unwrap()[0] else { unreachable!() }; - assert!(crate::mesh_view::is_terrain(g), "{name}"); +fn geschlossenes_gelaende_als_gelaendelinie() { + let (positions, indices) = cube(-4.0, 7.0, -3.0, 3.0, -1.0, 0.0); + let terrain = ContextObject::TerrainMesh(TerrainMesh { id: "g".into(), name: "Site".into(), category_code: "02".into(), positions: positions.clone(), indices: indices.clone(), ..Default::default() }); + { + let p = with(vec![terrain, mesh("w", cube(1.0, 3.0, -1.0, 2.0, 0.0, 2.5))]); let o = compute_section(&p, &lv(false), &[]).unwrap().unwrap(); let c = mesh_cuts(&o); - assert_eq!(c.len(), 1, "nur der Würfel als Schnittfläche ({name})"); + assert_eq!(c.len(), 1, "nur der Würfel als Schnittfläche"); assert_eq!(c[0].source_id.as_deref(), Some("w")); // Geländelinie = Oberkante z = 0 über die ganze Breite (u 1 … 12), kein Unterrand. let len: f64 = o.profiles.iter().flat_map(|pr| pr.pts.windows(2)).map(|w| (w[1][0] - w[0][0]).hypot(w[1][1] - w[0][1])).sum(); @@ -195,8 +186,8 @@ fn ifc_gelaende_als_gelaendelinie() { let (prims, _) = section_primitives_at(&o, false, false, &Visibility::default(), 100.0, Detail::Mittel, false, &CutRules::default()); assert!(prims.iter().any(|q| matches!(q, Primitive::Line { cls, .. } if cls == "section-terrain"))); } - // Gewöhnliches Netz gleicher Form: Körper. - let p = with(vec![terrain("Bodenplatte", Some("IfcSlab"))]); + // Netzkörper gleicher Form (auch mit Namen „Gelände"): Körper. + let p = with(vec![ContextObject::ImportedMesh(ImportedMesh { id: "g".into(), name: "Gelände".into(), category_code: "10".into(), positions, indices, ..Default::default() })]); let o = compute_section(&p, &lv(false), &[]).unwrap().unwrap(); assert_eq!(mesh_cuts(&o).len(), 1); assert!(o.profiles.is_empty()); diff --git a/src-tauri/core/src/plan/section/meshes.rs b/src-tauri/core/src/plan/section/meshes.rs index a0b920d6..fe5b83b1 100644 --- a/src-tauri/core/src/plan/section/meshes.rs +++ b/src-tauri/core/src/plan/section/meshes.rs @@ -110,7 +110,7 @@ pub(super) fn append_mesh_sections(cuts: &mut Vec, lines: &mut Vec<(usize, c.fill = Some(BODY_FILL.into()); c.nse = nse; c.source_id = Some(m.mesh.id.clone()); - c.category = m.mesh.category_code.clone(); + c.category = Some(m.mesh.category_code.clone()); cuts.push(c); } lines.extend(open.into_iter().map(|l| (k, l))); @@ -190,10 +190,10 @@ pub(super) fn clip_line_to_u(pts: &[[f64; 2]], lo: f64, hi: f64) -> Vec = p.context.as_deref().unwrap_or(&[]).iter().filter_map(|c| if let ContextObject::TerrainMesh(t) = c { Some(t) } else { None }).collect(); - if terrains.is_empty() && terrain_meshes.is_empty() { + if terrains.is_empty() { return; } let (mut lo, mut hi) = (f64::INFINITY, f64::NEG_INFINITY); @@ -209,55 +209,54 @@ pub(super) fn append_terrain_profiles(out: &mut Output, p: &Project, base: (f64, } let range = lo.is_finite().then_some((lo, hi)); for t in terrains { - // [137] Einzeln ausgeblendetes Gelände. - if t.positions.len() < 9 || t.hidden == Some(true) { + if t.positions.len() < 9 { continue; } out.terrain_id.get_or_insert_with(|| t.id.clone()); // [T6] Gelände samt Baugruben, Höhen im Modellbezug; das gewachsene Terrain gestrichelt dazu. let st = crate::excavation::site_terrain(p, t); - let mut meshes = vec![(st.current().to_flat(-st.datum), false)]; + let mut meshes: Vec<((Vec, Vec), bool)> = vec![(st.current().to_flat(-st.datum), false)]; if st.modified.is_some() { meshes.push((st.orig.to_flat(-st.datum), true)); } + // [152]/[181] Geschlossenes Gelände-Netz (z. B. IFC-Gelände als Platte): das rohe Netz schneiden und von den + // Schnittringen nur die Oberkante nehmen (die Fläche als TIN gelesen hätte Ober- und Unterseite). + if st.modified.is_none() && is_closed(&t.indices) { + meshes = vec![((t.positions.chunks(3).flat_map(|q| [q[0], q[1], q[2] - st.datum]).collect(), t.indices.clone()), false)]; + } for ((pos, idx), natural) in meshes { - let (_, lines) = cut_mesh(&pos, &idx, base, u); + let (rings, mut lines) = cut_mesh(&pos, &idx, base, u); + for poly in rings_to_polygons(&rings) { + lines.extend(upper_edge(&poly[0])); + } for line in lines { let parts = match range { Some((lo, hi)) => clip_line_to_u(&line, lo - TERRAIN_MARGIN, hi + TERRAIN_MARGIN), None => vec![line], }; for pts in parts { - out.profiles.push(Profile { category: t.category_code.clone(), pts, natural }); + out.profiles.push(Profile { category: Some(t.category_code.clone()), pts, natural }); } } } } - for m in terrain_meshes { - let (lo, hi) = mesh_depth_range(m, base, u); - if !(lo < 0.0 && hi > 0.0) { - continue; - } - let (rings, open) = crate::mesh_view::cut(m, &[0.0, base.0, base.1, u.0, u.1]); - let mut lines = open; - for poly in rings_to_polygons(&rings) { - lines.extend(upper_edge(&poly[0])); - } - if lines.is_empty() { - continue; - } - out.terrain_id.get_or_insert_with(|| m.mesh.id.clone()); - for line in lines { - let parts = match range { - Some((lo, hi)) => clip_line_to_u(&line, lo - TERRAIN_MARGIN, hi + TERRAIN_MARGIN), - None => vec![line], - }; - for pts in parts { - out.profiles.push(Profile { category: m.mesh.category_code.clone(), pts, natural: false }); - } + append_earth(out, p, base, u); +} + +/// Geschlossenes Dreiecksnetz: jede Kante gehört zu genau zwei Dreiecken. +fn is_closed(indices: &[f64]) -> bool { + if indices.len() < 12 { + return false; + } + let mut edges: std::collections::HashMap<(u32, u32), u32> = std::collections::HashMap::new(); + for t in indices.chunks_exact(3) { + let v = [t[0] as u32, t[1] as u32, t[2] as u32]; + for k in 0..3 { + let (a, b) = (v[k], v[(k + 1) % 3]); + *edges.entry((a.min(b), a.max(b))).or_default() += 1; } } - append_earth(out, p, base, u); + edges.values().all(|&n| n == 2) } /// Tiefe des Erdreich-Bands unter der Geländelinie (m), wenn das Gelände keine `earthDepth` trägt. diff --git a/src-tauri/core/src/plan/section/mod.rs b/src-tauri/core/src/plan/section/mod.rs index b07c7eb9..c8806afe 100644 --- a/src-tauri/core/src/plan/section/mod.rs +++ b/src-tauri/core/src/plan/section/mod.rs @@ -289,7 +289,7 @@ impl CutRules { pub fn of(p: &Project, out: &Output, v: RuleView) -> CutRules { let ts = crate::excavation::terrains(p); let t = out.terrain_id.as_deref().and_then(|id| ts.iter().find(|t| t.id == id)).or(ts.first()); - let terrain = if out.profiles.is_empty() && out.earth.is_empty() { None } else { t.and_then(|t| super::overrides::terrain_override(p, v, t.category_code.as_deref(), &t.name)) }; + let terrain = if out.profiles.is_empty() && out.earth.is_empty() { None } else { t.and_then(|t| super::overrides::terrain_override(p, v, Some(&t.category_code), &t.name)) }; let terrain_dash = terrain.as_ref().and_then(|(a, _)| super::overrides::linetype_dash(p, a.linetype_id.as_deref())); let terrain_hatch = terrain.as_ref().and_then(|(_, l)| l.hatch.as_deref()).filter(|h| !matches!(*h, "none" | "material")).and_then(|id| resolve_hatch(p, id, None, None, None)); let mut ov = cut_overrides(p, &out.cuts, v); @@ -588,9 +588,9 @@ fn compute_plane(p: &Project, level: &LevelSpec, bodies: &[BodyMesh], strip: Opt let cuts = subtract_pockets_in_section(cuts, p, base, u); let mut cuts = parallel_reveal_cuts(cuts, p, &plane, &walls)?; append_body_sections(&mut cuts, p, &bodies, base, u); - // [152] Importierte Netze: geschnitten (Flächen bzw. offene Linien) und in der Projektion. - // IFC-Gelände ([152]) wird Geländelinie (`append_terrain_profiles`), kein Körper. - let (terrain_meshes, meshes): (Vec<_>, Vec<_>) = crate::mesh_view::meshes(p).into_iter().partition(|m| crate::mesh_view::is_terrain(m.mesh)); + // [152] Netzkörper: geschnitten (Flächen bzw. offene Linien) und in der Projektion. Gelände ist ein eigenes + // Element (`terrainMesh`, auch IFC-Gelände seit dem Import, [181]) und wird Geländelinie (`append_terrain_profiles`). + let meshes = crate::mesh_view::meshes(p); let mut mesh_lines = Vec::new(); append_mesh_sections(&mut cuts, &mut mesh_lines, &meshes, base, u); // [176] Segment eines geknickten Schnitts: Schnittflächen auf den Streifen (sie verdecken nur dort). @@ -602,9 +602,9 @@ fn compute_plane(p: &Project, level: &LevelSpec, bodies: &[BodyMesh], strip: Opt // Projektion hinter der Ebene exakt ([G4]); die Schnittflächen verdecken, was hinter ihnen liegt. let (mut visible, hidden) = projection_edges(p, &plane, &walls_r, &wi, &slabs_r, &bodies, &meshes, &cuts, level.hidden_lines, level.depth, strip.map_or(&[][..], |s| &s.half[..])); shaped_projection(&mut visible, p, &walls_r, &plane); - let meshes = meshes.iter().map(|m| MeshMeta { id: m.mesh.id.clone(), name: m.mesh.name.clone(), category: m.mesh.category_code.clone() }).collect(); + let meshes = meshes.iter().map(|m| MeshMeta { id: m.mesh.id.clone(), name: m.mesh.name.clone(), category: Some(m.mesh.category_code.clone()) }).collect(); let mut out = Output { cuts, visible, hidden, profiles: Vec::new(), earth: Vec::new(), terrain_id: None, meshes, mesh_lines }; - append_terrain_profiles(&mut out, p, base, u, &terrain_meshes); + append_terrain_profiles(&mut out, p, base, u); if let Some(s) = strip { unfold::clip_output(&mut out, s); } diff --git a/src-tauri/core/src/plan/section/tests.rs b/src-tauri/core/src/plan/section/tests.rs index 0115ebd5..53985d65 100644 --- a/src-tauri/core/src/plan/section/tests.rs +++ b/src-tauri/core/src/plan/section/tests.rs @@ -810,7 +810,7 @@ fn gelaende_mit_baugrube_im_schnitt() { id: "t".into(), positions: vec![-50.0, -50.0, 0.0, 50.0, -50.0, 0.0, 50.0, 50.0, 0.0, -50.0, 50.0, 0.0], indices: vec![0.0, 1.0, 2.0, 0.0, 2.0, 3.0], - category_code: Some("02".into()), + category_code: "02".into(), ..Default::default() }; let pit = Excavation { diff --git a/src-tauri/core/src/selection_info.rs b/src-tauri/core/src/selection_info.rs index cd28ea1a..9b5941f2 100644 --- a/src-tauri/core/src/selection_info.rs +++ b/src-tauri/core/src/selection_info.rs @@ -1119,14 +1119,16 @@ fn context_selection(root: &Map, o: &Value) -> J { O::default().n("e", (bb[0] + bb[2]) / 2.0 + oe).n("n", (bb[1] + bb[3]) / 2.0 + on).done() }); let image = kind == Some("image"); + // [181] Normales Element: Klasse (im Kopf der Objekt-Info änderbar) und Farbe/Stärke der Klasse; Herkunft nur als Auskunft. + let cat = category(root, field(o, "categoryCode")); O::default() .s("kind", "contextObject") .raw("id", o, "id") - .s("categoryCode", "") - .s("color", "#888888") - .n("weightMm", WALL_FALLBACK_MM) + .raw("categoryCode", o, "categoryCode") + .v("color", color_of(o, cat, "#888888")) + .v("weightMm", lw_or(None, cat, WALL_FALLBACK_MM)) .v("bbox", bbox_value(bb)) - .v("contextObject", O::default().raw("objType", o, "type").o("lv95Center", lv95).done()) + .v("contextObject", O::default().raw("objType", o, "type").raw("source", o, "source").o("lv95Center", lv95).done()) .v("isImage", Value::Bool(image)) .o("opacity", image.then(|| nn(field(o, "opacity")).cloned().unwrap_or_else(|| Value::from(1u64)))) .o("imageFilters", if image { field(o, "filters").cloned() } else { None }) diff --git a/src-tauri/core/src/sheet_viewports.rs b/src-tauri/core/src/sheet_viewports.rs index fcc5d3a0..544a242e 100644 --- a/src-tauri/core/src/sheet_viewports.rs +++ b/src-tauri/core/src/sheet_viewports.rs @@ -210,11 +210,8 @@ fn candidate_codes(p: &Project) -> HashSet { codes.extend(p.roofs.iter().flatten().map(|e| e.category_code.clone())); codes.extend(p.stairs.iter().flatten().map(|e| e.category_code.clone())); codes.extend(p.openings.iter().flatten().map(|e| e.category_code.clone())); - for c in p.context.iter().flatten() { - if let crate::model::ContextObject::TerrainMesh(t) = c { - codes.extend(t.category_code.clone()); - } - } + // [181] Gelände- und Umgebungs-Elemente tragen ihre Klasse wie jedes Bauteil. + codes.extend(p.context.iter().flatten().map(|c| c.category_code().to_string())); codes } diff --git a/src-tauri/core/src/sun.rs b/src-tauri/core/src/sun.rs index 126ed986..09dede03 100644 --- a/src-tauri/core/src/sun.rs +++ b/src-tauri/core/src/sun.rs @@ -1067,7 +1067,7 @@ fn is_tree_category(p: &Project, code: &str) -> bool { /// Gelände für den Schattenwurf: erstes sichtbares Geländenetz des Kontexts (inkl. Baugruben). fn shadow_terrain(p: &Project) -> Option> { - let t = crate::excavation::terrains(p).into_iter().find(|t| t.hidden != Some(true))?; + let t = crate::excavation::terrains(p).into_iter().next()?; let st = crate::excavation::site_terrain(p, t); (!st.current().tris.is_empty()).then_some(st) } diff --git a/src-tauri/core/src/tree.rs b/src-tauri/core/src/tree.rs index 65721dac..e45d9c60 100644 --- a/src-tauri/core/src/tree.rs +++ b/src-tauri/core/src/tree.rs @@ -191,7 +191,7 @@ pub fn bases(p: &Project) -> Vec { if trees.is_empty() { return Vec::new(); } - let site = crate::excavation::terrains(p).into_iter().find(|t| t.hidden != Some(true)).map(|t| crate::excavation::site_terrain(p, t)).filter(|st| !st.current().tris.is_empty()); + let site = crate::excavation::terrains(p).into_iter().next().map(|t| crate::excavation::site_terrain(p, t)).filter(|st| !st.current().tris.is_empty()); let idx = site.as_ref().map(|st| (st.index_current(), st.datum)); trees .iter() diff --git a/src/analysis/excavation.test.ts b/src/analysis/excavation.test.ts index adde4850..33bfae6b 100644 --- a/src/analysis/excavation.test.ts +++ b/src/analysis/excavation.test.ts @@ -12,14 +12,14 @@ function project(): Project { context: [ { id: "t", - type: "terrainMesh", + type: "terrainMesh", categoryCode: "02", name: "Gelände", positions: [-50, -50, 0, 50, -50, 0, 50, 50, 0, -50, 50, 0], indices: [0, 1, 2, 0, 2, 3], }, { id: "bg", - type: "excavation", + type: "excavation", categoryCode: "07", name: "Baugrube", outline: [ { x: -5, y: -5 }, @@ -70,6 +70,7 @@ describe("[68] Arbeitsraum, Verbau, Überlagerung", () => { id, type: "excavation" as const, name: id, + categoryCode: "07", outline: [{ x: -5 + dx, y: -5 }, { x: 5 + dx, y: -5 }, { x: 5 + dx, y: 5 }, { x: -5 + dx, y: 5 }], bottom: -3, slope: 45, diff --git a/src/export/exportIfc.classification.test.ts b/src/export/exportIfc.classification.test.ts index b1ff4339..073716e3 100644 --- a/src/export/exportIfc.classification.test.ts +++ b/src/export/exportIfc.classification.test.ts @@ -122,10 +122,10 @@ describe("Rundreise Export → Import", () => { const { products } = await inspectIfc(bytes); expect(products.find((p) => p.ifcClass === "IfcRoof")?.classifications?.[0]).toMatchObject({ system: "eBKP-H", code: "F" }); const r = await importIfcInto(sampleProject, bytes, { group: "product" }); - const roof = r.meshes.find((m) => m.layer === "IfcRoof")!; + const roof = r.meshes.find((m) => m.source === "IFC IfcRoof")!; expect(roof.name).toMatch(/ \[eBKP-H F\]$/); // Ohne Klassifikation kein Zusatz. - expect(r.meshes.find((m) => m.layer === "IfcStairFlight")?.name).not.toMatch(/\[/); + expect(r.meshes.find((m) => m.source === "IFC IfcStairFlight")?.name).not.toMatch(/\[/); }); }); diff --git a/src/export/exportMesh.complete.test.ts b/src/export/exportMesh.complete.test.ts index 5af54c0a..4d460fdb 100644 --- a/src/export/exportMesh.complete.test.ts +++ b/src/export/exportMesh.complete.test.ts @@ -42,7 +42,7 @@ const CUBE_IDX = [0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 0, 1, 5, 0, 5, 4, 1, 2, 6, function withContext(base: Project): Project { const imported: ImportedMesh = { id: "IM1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Nachbar", color: "#ff0000", positions: CUBE_POS.map((v, i) => (i % 3 === 0 ? v + 20 : v)), @@ -50,7 +50,7 @@ function withContext(base: Project): Project { }; const terrain: TerrainMesh = { id: "TM1", - type: "terrainMesh", + type: "terrainMesh", categoryCode: "02", name: "Gelände", positions: [-5, -5, 0, 25, -5, 0, 25, 25, 0, -5, 25, 0], indices: [0, 1, 2, 0, 2, 3], diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 96f87790..66cc13d5 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -458,7 +458,7 @@ export const de = { "objinfo.kind.extrudedSolid": "Extrusion", "objinfo.kind.column": "Stütze", "objinfo.kind.roof": "Dach", - "objinfo.kind.contextObject": "Kontext-Objekt", + "objinfo.kind.contextObject": "Gelände/Umgebung", "objinfo.kind.sunStudy": "Schatten (Sonnenstand)", "objinfo.kind.siteRules": "Baurecht", "objinfo.kind.viewShadows": "Schlagschatten (Ansicht)", @@ -467,13 +467,14 @@ export const de = { // ── Kontext-Objekt-Attribute (Object-Info-Panel) ──────────────────────── "objinfo.contextObject.section": "Georeferenzierung", "objinfo.contextObject.type": "Art", - "objinfo.contextObject.type.importedMesh": "Importiertes Mesh", + "objinfo.contextObject.type.importedMesh": "Netzkörper", "objinfo.contextObject.type.terrainMesh": "Gelände", "objinfo.contextObject.type.contourSet": "Höhenlinien", "objinfo.contextObject.type.image": "Luftbild", "objinfo.contextObject.type.excavation": "Baugrube", "objinfo.contextObject.lv95E": "LV95 Ost (E)", "objinfo.contextObject.lv95N": "LV95 Nord (N)", + "objinfo.contextObject.source": "Herkunft", "objinfo.contextObject.noAnchor": "Kein Standort-Bezug im Projekt", // ── Dach-Attribute (Object-Info-Panel) ────────────────────────────────── "objinfo.roof.section": "Dach", @@ -2367,16 +2368,6 @@ export const de = { "site.import": "⤓ DXF importieren", "site.generateTerrain": "Gelände erzeugen", "site.contourSet": "Kontur-Satz", - "site.empty": "Kein Kontext geladen. Importiere eine DXF-Datei (Höhenlinien oder Mesh).", - "site.delete": "Entfernen", - "site.deleteLayer": "Ganze Ebene entfernen", - "site.group.imported": "Gebäude", - "site.group.terrain": "Terrain", - "site.group.contours": "Höhenlinien", - "site.type.mesh": "Mesh", - "site.type.contours": "Konturen", - "site.type.terrain": "Gelände", - "site.type.excavation": "Baugrube", "site.smooth": "Glätten", "site.smooth.hint": "Höhenlinien als Bruchkanten, flache Dreiecke behoben, Fläche ohne Überschwingen geglättet", "site.excavation.draw": "Baugrube zeichnen", @@ -2402,17 +2393,11 @@ export const de = { "site.terrain.smooth.hint": "Gelände aus den Höhenlinien neu erzeugen (Bruchkanten bleiben, ein Undo-Schritt)", "site.terrain.smooth.raw": "roh (ohne Glättung)", "site.terrain.smooth.level": "Stufe {n}", - "site.mesh.visible": "Dieses Netz sichtbar", - "site.mesh.visible.hint": "Blendet nur dieses importierte Netz aus (Grundriss, 3D, Auswahl); die Kategorie bleibt eingeschaltet", - "site.terrain.meshVisible": "Dieses Gelände sichtbar", - "site.terrain.meshVisible.hint": "Blendet nur dieses Geländenetz aus (Grundriss, Schnitt, Ansicht, 3D); die Kategorie bleibt eingeschaltet", "site.terrain.resmooth.hint": "Raster-Gelände (swissALTI3D) zusätzlich glätten — wirkt auf die Höhen des Rasters, ein Undo-Schritt", "site.terrain.resmooth.unavailable": "Nicht verfügbar: weder Höhenlinien-Satz noch Höhenraster als Quelle (z. B. importiertes TIN)", "site.terrain.resmooth.current": "{n} Durchgänge", "site.terrain.resmooth.none": "ungeglättet", "site.terrain.resmooth.more": "+{n} Durchgänge glätten", - "site.type.image": "Luftbild", - "site.group.image": "Luftbild", "site.dwgHint": "DWG? Zuerst mit dem gratis ODA File Converter in DXF umwandeln.", "site.terrainFailed": "Kein Gelände erzeugbar (zu wenige/kollineare Konturpunkte).", @@ -3209,6 +3194,7 @@ export const de = { // ── Element-Baum (Elemente-Panel, ROADMAP §11) ────────────────────────────── "elements.title": "Elemente", "elements.search": "Elemente suchen…", + "elements.site": "Gelände & Umgebung", "elements.empty": "Keine Bauteile im Projekt.", "elements.noMatch": "Keine Treffer.", "elements.kind.wall": "Wand", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 9db6343b..d45420f6 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -456,7 +456,7 @@ export const en: Record = { "objinfo.kind.extrudedSolid": "Extrusion", "objinfo.kind.column": "Column", "objinfo.kind.roof": "Roof", - "objinfo.kind.contextObject": "Context object", + "objinfo.kind.contextObject": "Site element", "objinfo.kind.sunStudy": "Shadow (sun position)", "objinfo.kind.siteRules": "Building regulations", "objinfo.kind.viewShadows": "Cast shadow (elevation)", @@ -465,13 +465,14 @@ export const en: Record = { // ── Context object attributes (object info panel) ─────────────────────── "objinfo.contextObject.section": "Georeferencing", "objinfo.contextObject.type": "Type", - "objinfo.contextObject.type.importedMesh": "Imported mesh", + "objinfo.contextObject.type.importedMesh": "Mesh body", "objinfo.contextObject.type.terrainMesh": "Terrain", "objinfo.contextObject.type.contourSet": "Contours", "objinfo.contextObject.type.image": "Aerial image", "objinfo.contextObject.type.excavation": "Excavation", "objinfo.contextObject.lv95E": "LV95 East (E)", "objinfo.contextObject.lv95N": "LV95 North (N)", + "objinfo.contextObject.source": "Source", "objinfo.contextObject.noAnchor": "No location reference in project", // ── Roof attributes (object info panel) ───────────────────────────────── "objinfo.roof.section": "Roof", @@ -2355,16 +2356,6 @@ export const en: Record = { "site.import": "⤓ Import DXF", "site.generateTerrain": "Generate terrain", "site.contourSet": "Contour set", - "site.empty": "No context loaded. Import a DXF file (contour lines or mesh).", - "site.delete": "Remove", - "site.deleteLayer": "Remove entire layer", - "site.group.imported": "Buildings", - "site.group.terrain": "Terrain", - "site.group.contours": "Contours", - "site.type.mesh": "Mesh", - "site.type.contours": "Contours", - "site.type.terrain": "Terrain", - "site.type.excavation": "Excavation", "site.smooth": "Smooth", "site.smooth.hint": "Contours as breaklines, flat triangles fixed, surface smoothed without overshoot", "site.excavation.draw": "Draw excavation", @@ -2388,10 +2379,6 @@ export const en: Record = { "site.terrain.smooth.hint": "Regenerate the terrain from its contour lines (breaklines kept, one undo step)", "site.terrain.smooth.raw": "raw (no smoothing)", "site.terrain.smooth.level": "Level {n}", - "site.mesh.visible": "This mesh visible", - "site.mesh.visible.hint": "Hides only this imported mesh (plan, 3D, selection); the category stays on", - "site.terrain.meshVisible": "This terrain visible", - "site.terrain.meshVisible.hint": "Hides only this terrain mesh (plan, section, elevation, 3D); the category stays on", "site.terrain.resmooth.hint": "Smooth grid terrain (swissALTI3D) further — acts on the grid heights, one undo step", "site.terrain.resmooth.unavailable": "Not available: neither a contour set nor a height grid as source (e.g. imported TIN)", "site.terrain.resmooth.current": "{n} passes", @@ -2399,8 +2386,6 @@ export const en: Record = { "site.terrain.resmooth.more": "Smooth +{n} passes", "site.excavation.qty": "Cut {cut} m³ · Fill {fill} m³ · Backfill {backfill} m³", "site.excavation.noTerrain": "No terrain below the excavation", - "site.type.image": "Aerial", - "site.group.image": "Aerial imagery", "site.dwgHint": "DWG? Convert it to DXF first with the free ODA File Converter.", "site.terrainFailed": "No terrain could be generated (too few/collinear contour points).", @@ -3196,6 +3181,7 @@ export const en: Record = { // ── Element tree (Elements panel, ROADMAP §11) ────────────────────────────── "elements.title": "Elements", "elements.search": "Search elements…", + "elements.site": "Site & surroundings", "elements.empty": "No components in the project.", "elements.noMatch": "No matches.", "elements.kind.wall": "Wall", diff --git a/src/io/dwgParser.test.ts b/src/io/dwgParser.test.ts index 71131e37..55403a51 100644 --- a/src/io/dwgParser.test.ts +++ b/src/io/dwgParser.test.ts @@ -18,14 +18,14 @@ const fixture = (name: string): Uint8Array => const asBuffer = (b: Uint8Array): ArrayBuffer => b.buffer.slice(b.byteOffset, b.byteOffset + b.byteLength) as ArrayBuffer; function meshByLayer(res: ImportView, layer: string) { - const m = res.meshes.find((x) => x.layer === layer); + const m = res.meshes.find((x) => x.source === `DXF-Layer ${layer}`); expect(m, `Mesh auf Ebene ${layer}`).toBeDefined(); return m!; } /** Gemeinsame Erwartungen für alle Varianten der Kachel. */ function checkTile(res: ImportView) { - expect(res.meshes.map((m) => m.layer).sort()).toEqual(["Roof", "Wall"]); + expect(res.meshes.map((m) => m.source).sort()).toEqual(["DXF-Layer Roof", "DXF-Layer Wall"]); const roof = meshByLayer(res, "Roof"); // 3 Punkte, je um die INSERT-Einfügung verschoben (Skalierung 1, Drehung 0). expect(roof.positions).toEqual([ diff --git a/src/io/geoContext.ts b/src/io/geoContext.ts index c7504ee9..8172041d 100644 --- a/src/io/geoContext.ts +++ b/src/io/geoContext.ts @@ -3,7 +3,8 @@ // Beide Quellen liefern am Ende dasselbe: geschlossene/offene Polylinien in // LOKALEN Modell-Metern (bereits um die Origin verschoben, siehe lv95.ts), // kategorisiert nach Art (Gebäude/Strasse/Wasser/Grün/Parkplatz/Bahn/Wald). Die UI wandelt diese in -// `ContourSet`-Kontext-Objekte pro Kategorie um und legt sie in `project.context`. +// Linien-Elemente (`contourSet`) je Klasse um und legt sie in `project.context` ([181]: normale Elemente mit +// Klasse; die Quelle steht nur als Auskunft in `source`). // // Bezeichner englisch, Kommentare deutsch (CONVENTIONS.md). @@ -40,7 +41,7 @@ export interface GeoFeature { /** Default-Gebäudehöhe (m), wenn keine Höhe aus der Quelle vorliegt. */ export const DEFAULT_BUILDING_HEIGHT = 9; -/** Menschlicher Layer-/Objektname je Kategorie (deutsch, für die Kontext-Liste). */ +/** Menschlicher Objektname je Kategorie (deutsch). */ const CATEGORY_LABEL: Record = { building: "Gebäude", road: "Strassen", @@ -51,17 +52,6 @@ const CATEGORY_LABEL: Record = { forest: "Wald", }; -/** Layer-Kennung (englischer Identifier) je Kategorie — für spätere Zuordnung. */ -const CATEGORY_LAYER: Record = { - building: "context-buildings", - road: "context-roads", - water: "context-water", - green: "context-green", - parking: "context-parking", - railway: "context-railway", - forest: "context-forest", -}; - /** Erzeugt eine (kollisionsarme) ID für ein neues Kontext-Objekt. */ function contextId(prefix: string): string { return `${prefix}-${Date.now().toString(36)}-${Math.random() @@ -88,7 +78,6 @@ export function featuresToContextObjects( z: 0, pts: f.pts.map((p) => ({ x: p.x, y: p.y })), closed: f.closed, - layer: CATEGORY_LAYER[f.category], }); byCat.set(f.category, list); } @@ -100,8 +89,8 @@ export function featuresToContextObjects( id: contextId(`geo-${cat}`), type: "contourSet", name: `${CATEGORY_LABEL[cat]} (${sourceLabel})`, - layer: CATEGORY_LAYER[cat], categoryCode: GEO_CATEGORY_DEFS[cat].code, + source: sourceLabel, contours, }); } @@ -148,8 +137,8 @@ export function buildingsToMesh( id: contextId("geo-building3d"), type: "importedMesh", name: `Gebäude 3D (${sourceLabel})`, - layer: CATEGORY_LAYER.building, categoryCode: GEO_CATEGORY_DEFS.building.code, + source: sourceLabel, positions, indices, }; diff --git a/src/io/ifcImport.test.ts b/src/io/ifcImport.test.ts index e01f1426..aef46d33 100644 --- a/src/io/ifcImport.test.ts +++ b/src/io/ifcImport.test.ts @@ -117,7 +117,7 @@ describe("IFC-Import: Rundreise mit dem eigenen Export", () => { expect(meshes.length).toBe(products.length); expect(new Set(meshes.map((m) => m.id)).size).toBe(meshes.length); expect(meshes.every((m) => m.type === "importedMesh" && m.positions.length >= 9 && m.indices.length >= 3)).toBe(true); - expect(meshes.find((m) => m.layer === "IfcWall")).toBeTruthy(); + expect(meshes.find((m) => m.source === "IFC IfcWall")).toBeTruthy(); const grouped = (await importIfcInto(sampleProject, bytesOf(ifc), { group: "class" })).meshes; expect(grouped.length).toBeLessThan(meshes.length); expect(grouped.reduce((s, m) => s + m.indices.length, 0)).toBe(meshes.reduce((s, m) => s + m.indices.length, 0)); diff --git a/src/io/ifcImport.ts b/src/io/ifcImport.ts index e7e1cd34..d39a926f 100644 --- a/src/io/ifcImport.ts +++ b/src/io/ifcImport.ts @@ -1,6 +1,7 @@ // IFC-Import ([B3] Kontext-Meshes, [B4] Bauteile): dünne Fassade über `import_ifc`/`import_ifc_elements` im // Format-Modul (`src-tauri/fileio`, `ifc_import.rs`, `ifc_semantic.rs`). Die Umwandlung ins Projekt — je -// Bauteil ein `ImportedMesh` der Kontext-Schicht (GlobalId, Farbe, Klasse als `layer`; ab `MAX_SINGLE` +// Bauteil ein Netzkörper (`ImportedMesh`: GlobalId, Farbe, IFC-Klasse als Herkunft `source`; Gelände wird ein +// Gelände-Element, [181]; ab `MAX_SINGLE` // Bauteilen je Klasse + Geschoss zusammengelegt) bzw. echte Wände, Öffnungen, Decken, Stützen, Räume — macht // der Kern als EIN Undo-Schritt (`core/src/import_ifc.rs`, `ProjectDocument.importIfc`, [K4] S4). // diff --git a/src/io/meshImport.test.ts b/src/io/meshImport.test.ts index a02a4455..f63c15e6 100644 --- a/src/io/meshImport.test.ts +++ b/src/io/meshImport.test.ts @@ -59,7 +59,7 @@ function project(): Project { p.walls = [wall]; const cube: ImportedMesh = { id: "K1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Nachbar", color: "#ff8000", positions: [20, 30, 0, 24, 30, 0, 24, 36, 0, 20, 36, 0, 20, 30, 9, 24, 30, 9, 24, 36, 9, 20, 36, 9], diff --git a/src/io/swissBuildings3d.test.ts b/src/io/swissBuildings3d.test.ts index 80943fad..e449d434 100644 --- a/src/io/swissBuildings3d.test.ts +++ b/src/io/swissBuildings3d.test.ts @@ -11,7 +11,7 @@ import { splitMeshComponents, stripOverhangSoffits, concatMeshes, - BUILDING_LAYER, + BUILDINGS_SOURCE, } from "./swissBuildings3d"; import type { ImportedMesh } from "../model/types"; @@ -19,7 +19,7 @@ describe("shiftMeshToOrigin", () => { it("verschiebt x/y um die Origin, lässt z unverändert", () => { const mesh: ImportedMesh = { id: "m1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "roh", positions: [2600100, 1200050, 3.5, 2600110, 1200060, 7.2], indices: [0, 1, 0], @@ -33,7 +33,7 @@ describe("shiftMeshToOrigin", () => { it("mutiert das Eingabe-Mesh nicht", () => { const mesh: ImportedMesh = { id: "m1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "roh", positions: [2600100, 1200050, 0], indices: [], @@ -50,7 +50,7 @@ describe("clipMeshToBbox", () => { // gesuchten Radius). const mesh: ImportedMesh = { id: "m1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "roh", positions: [ 0, 0, 0, 1, 0, 0, 0, 1, 0, // Dreieck 0: innerhalb [-5,5] @@ -77,7 +77,7 @@ describe("clipMeshToBbox", () => { it("ein Dreieck, das die Box-Kante überragt, bleibt VOLLSTÄNDIG erhalten (kein Mittendurch-Schnitt)", () => { const straddling: ImportedMesh = { id: "m2", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "roh", positions: [4, 0, 0, 10, 0, 0, 4, 10, 0], // ein Eckpunkt (4,0) in [-5,5], zwei ausserhalb indices: [0, 1, 2], @@ -91,7 +91,7 @@ describe("splitMeshComponents", () => { // Zwei räumlich getrennte Dreiecke (kein gemeinsamer Vertex) = zwei Gebäude. const twoBuildings: ImportedMesh = { id: "m1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Kachel", positions: [ 0, 0, 0, 1, 0, 0, 0, 1, 0, // Gebäude A @@ -100,12 +100,12 @@ describe("splitMeshComponents", () => { indices: [0, 1, 2, 3, 4, 5], }; - it("trennt zwei unverbundene Dreiecke in zwei Meshes mit eigener Id + Ebene", () => { + it("trennt zwei unverbundene Dreiecke in zwei Meshes mit eigener Id + Herkunft", () => { const parts = splitMeshComponents(twoBuildings); expect(parts.length).toBe(2); expect(parts[0].id).not.toBe(parts[1].id); for (const p of parts) { - expect(p.layer).toBe(BUILDING_LAYER); + expect(p.source).toBe(BUILDINGS_SOURCE); expect(p.indices.length).toBe(3); // je ein Dreieck expect(p.positions.length).toBe(9); // kompaktiert: nur die 3 eigenen Vertices // Indizes sind neu gemappt (0..2), zeigen nicht mehr auf die alten Globalindizes. @@ -118,7 +118,7 @@ describe("splitMeshComponents", () => { // (getrennte Indizes, gleiche Koordinaten) — das Welding muss sie verbinden. const shared: ImportedMesh = { id: "m2", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Haus", positions: [ 0, 0, 0, 1, 0, 0, 0, 1, 0, // Dreieck 1: (0,0),(1,0),(0,1) @@ -131,21 +131,21 @@ describe("splitMeshComponents", () => { expect(parts[0].indices.length).toBe(6); }); - it("ein einzelnes zusammenhängendes Mesh bleibt ein Mesh (bekommt aber die Ebene)", () => { + it("ein einzelnes zusammenhängendes Mesh bleibt ein Mesh (bekommt aber die Herkunft)", () => { const one: ImportedMesh = { id: "m3", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Solo", positions: [0, 0, 0, 1, 0, 0, 0, 1, 0], indices: [0, 1, 2], }; const parts = splitMeshComponents(one); expect(parts.length).toBe(1); - expect(parts[0].layer).toBe(BUILDING_LAYER); + expect(parts[0].source).toBe(BUILDINGS_SOURCE); }); it("leeres/entartetes Mesh -> leeres Ergebnis (kein Crash)", () => { - const empty: ImportedMesh = { id: "e", type: "importedMesh", name: "x", positions: [], indices: [] }; + const empty: ImportedMesh = { id: "e", type: "importedMesh", categoryCode: "10", name: "x", positions: [], indices: [] }; expect(splitMeshComponents(empty)).toEqual([]); }); }); @@ -159,7 +159,7 @@ describe("stripOverhangSoffits", () => { it("entfernt eine nach unten zeigende Überstand-Untersicht oberhalb der Grundmauer", () => { const mesh: ImportedMesh = { id: "m1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Haus", positions: [ 0, 0, 0, // 0: Sockel @@ -191,7 +191,7 @@ describe("stripOverhangSoffits", () => { it("lässt ein Mesh ohne Soffiten unverändert", () => { const mesh: ImportedMesh = { id: "m1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Dreieck", positions: [0, 0, 0, 1, 0, 0, 0, 1, 0], indices: [0, 1, 2], @@ -206,7 +206,7 @@ describe("stripOverhangSoffits", () => { // Boden-Ausnahme greift VOR der Normalen-Prüfung, bleibt also erhalten. const mesh: ImportedMesh = { id: "m1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Sockel", positions: [0, 0, 0, 0, 1, 0, 1, 0, 0], // a,c,b-Reihenfolge -> nz=-1 indices: [0, 1, 2], @@ -216,7 +216,7 @@ describe("stripOverhangSoffits", () => { }); it("leeres/entartetes Mesh -> unverändert (kein Crash)", () => { - const empty: ImportedMesh = { id: "e", type: "importedMesh", name: "x", positions: [], indices: [] }; + const empty: ImportedMesh = { id: "e", type: "importedMesh", categoryCode: "10", name: "x", positions: [], indices: [] }; expect(stripOverhangSoffits(empty)).toBe(empty); }); }); @@ -226,7 +226,8 @@ describe("concatMeshes", () => { id, type: "importedMesh", name: id, - layer: id, + categoryCode: "10", + source: id, positions: [ox, 0, 0, ox + 1, 0, 0, ox, 1, 0], indices: [0, 1, 2], }); @@ -239,7 +240,7 @@ describe("concatMeshes", () => { }); it("leere Teile (kein Dreieck) werden übersprungen, kein Beitrag zu Positions/Indizes", () => { - const emptyPart: ImportedMesh = { id: "e", type: "importedMesh", name: "e", positions: [1, 2, 3], indices: [] }; + const emptyPart: ImportedMesh = { id: "e", type: "importedMesh", categoryCode: "10", name: "e", positions: [1, 2, 3], indices: [] }; const merged = concatMeshes([emptyPart, tri("a", 0)]); expect(merged?.positions).toEqual([0, 0, 0, 1, 0, 0, 0, 1, 0]); }); @@ -250,12 +251,12 @@ describe("concatMeshes", () => { }); it("ausschliesslich leere Teile -> null", () => { - const empty: ImportedMesh = { id: "e", type: "importedMesh", name: "e", positions: [], indices: [] }; + const empty: ImportedMesh = { id: "e", type: "importedMesh", categoryCode: "10", name: "e", positions: [], indices: [] }; expect(concatMeshes([empty, empty])).toBeNull(); }); - it("übernimmt Metadaten (z. B. `layer`) vom ERSTEN nicht-leeren Teil", () => { + it("übernimmt Metadaten (z. B. `source`) vom ERSTEN nicht-leeren Teil", () => { const merged = concatMeshes([tri("a", 0), tri("b", 10)]); - expect(merged?.layer).toBe("a"); + expect(merged?.source).toBe("a"); }); }); diff --git a/src/io/swissBuildings3d.ts b/src/io/swissBuildings3d.ts index 88b57070..40186da9 100644 --- a/src/io/swissBuildings3d.ts +++ b/src/io/swissBuildings3d.ts @@ -97,21 +97,27 @@ export function clipMeshToBbox( } /** Sichtbarer Ebenen-/Gruppierungsname der importierten Gebäude (SitePanel). */ -export const BUILDING_LAYER = "Gebäude"; +/** [181] Herkunft der importierten Gebäude (nur Auskunft in der Objekt-Info, ohne Wirkung). */ +export const BUILDINGS_SOURCE = "swissBUILDINGS3D"; + +/** DXF-Layer eines geparsten Netzes (aus `source` „DXF-Layer …", s. Kern `import_drawing::mesh_values`), sonst "". */ +export function dxfLayerOf(m: ImportedMesh): string { + return m.source?.startsWith("DXF-Layer ") ? m.source.slice("DXF-Layer ".length) : ""; +} /** * Zerlegt ein Mesh in seine räumlich ZUSAMMENHÄNGENDEN Komponenten (Union-Find * über verschweisste Vertices, `weldMm`) — je Komponente ein eigenes {@link ImportedMesh}. * So wird eine swissBUILDINGS3D-Kachel in EINZELNE, getrennt anwähl-/löschbare - * Gebäude aufgeteilt. Jede Komponente bekommt eine eigene Id + fortlaufenden Namen - * + `layer`. Die Zerlegung rechnet der Kern (`core/src/geo_mesh.rs`); rein (kein Netzwerk). + * Gebäude aufgeteilt. Jede Komponente bekommt eine eigene Id + fortlaufenden Namen, + * Klasse und Herkunft. Die Zerlegung rechnet der Kern (`core/src/geo_mesh.rs`); rein (kein Netzwerk). */ export function splitMeshComponents(mesh: ImportedMesh, weldMm = 1): ImportedMesh[] { const vcount = Math.floor(mesh.positions.length / 3); if (vcount < 3 || mesh.indices.length < 3) return mesh.indices.length >= 3 ? [mesh] : []; const defaults = { - layer: mesh.layer ?? BUILDING_LAYER, - categoryCode: mesh.categoryCode ?? GEO_CATEGORY_DEFS.building.code, + categoryCode: mesh.categoryCode || GEO_CATEGORY_DEFS.building.code, + source: mesh.source ?? BUILDINGS_SOURCE, }; const r = core().geo_mesh_split(Float64Array.from(mesh.positions), Float64Array.from(mesh.indices), weldMm); if (r.length === 0) return [{ ...mesh, ...defaults }]; @@ -276,7 +282,7 @@ export async function fetchBuildings3d( const roofRaw: ImportedMesh[] = []; const bodyRaw: ImportedMesh[] = []; for (const m of rawMeshes) { - ((m.layer ?? "").toLowerCase() === "roof" ? roofRaw : bodyRaw).push(m); + (dxfLayerOf(m).toLowerCase() === "roof" ? roofRaw : bodyRaw).push(m); } for (const [group, isRoof] of [ [bodyRaw, false], @@ -293,16 +299,9 @@ export async function fetchBuildings3d( for (const b of splitMeshComponents(clipped)) { meshes.push({ ...stripOverhangSoffits(b), + // [181] Normale Elemente: Klasse „12 Gebäude" bzw. „31 Dächer", Herkunft nur als Auskunft. categoryCode: isRoof ? IMPORTED_ROOF_CATEGORY.code : GEO_CATEGORY_DEFS.building.code, - // `.layer` (kosmetischer SitePanel-Gruppierungs-String, s. - // SitePanel.tsx::layerOf/groupByLayer) explizit setzen — sonst - // trägt er den rohen DXF-Layernamen aus dwgParser.ts ("Wall"/ - // "Floor"/"Roof") weiter, den `splitMeshComponents`s Fallback - // `mesh.layer ?? BUILDING_LAYER` NICHT ersetzt (nur bei leerem - // `.layer`, nicht bei einem bereits vorhandenen Wert). Ohne diesen - // Fix zerfällt die SitePanel-Gruppierung eines v3-Imports in - // „Wall"/„Floor"/„Roof" statt „Gebäude"/„Dächer". - layer: isRoof ? IMPORTED_ROOF_CATEGORY.name : BUILDING_LAYER, + source: BUILDINGS_SOURCE, }); } } diff --git a/src/model/geoRebase.test.ts b/src/model/geoRebase.test.ts index 452552b2..d8911afe 100644 --- a/src/model/geoRebase.test.ts +++ b/src/model/geoRebase.test.ts @@ -133,7 +133,7 @@ describe("translateProject", () => { context: [ { id: "CTX1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Test", positions: [0, 0, 5, 2, 3, 7], indices: [0, 1, 0], @@ -152,7 +152,7 @@ describe("translateProject", () => { context: [ { id: "CS1", - type: "contourSet", + type: "contourSet", categoryCode: "02", name: "Höhenlinien", contours: [ { diff --git a/src/model/richProject.testing.ts b/src/model/richProject.testing.ts index 2ad32a37..7f9ed6b6 100644 --- a/src/model/richProject.testing.ts +++ b/src/model/richProject.testing.ts @@ -77,15 +77,15 @@ export function richProject(): Project { ...(i % 3 === 0 ? { hatchOrigin: { x: 1, y: 1 }, hatchSource: "layer" as const, weightMm: 0.5, fillColor: "#eeeeee" } : {}), })), context: [ - { type: "importedMesh", id: "c1", name: "Nachbar", layer: "L", categoryCode: "95", color: "#aabbcc", ifcGlobalId: "2O2Fr$t4X7Zf8NOew3FLOH", positions: [0, 0, 0, 1, 0, 0, 0, 1, 0], indices: [0, 1, 2] }, + { type: "importedMesh", id: "c1", name: "Nachbar", categoryCode: "95", source: "L", color: "#aabbcc", ifcGlobalId: "2O2Fr$t4X7Zf8NOew3FLOH", positions: [0, 0, 0, 1, 0, 0, 0, 1, 0], indices: [0, 1, 2] }, { - type: "contourSet", id: "c2", name: "Höhenlinien", contours: [ + type: "contourSet", categoryCode: "02", id: "c2", name: "Höhenlinien", contours: [ { z: 400, pts: [{ x: 0, y: 0 }, { x: 5, y: 1 }], closed: false, layer: "HL", filled: true }, { z: 401, pts: [], closed: false, curve: { kind: "arc", cx: 0, cy: 0, r: 2, a0: 0, a1: 1 } }, ], }, - { type: "terrainMesh", id: "c3", name: "Gelände", positions: [0, 0, 0, 1, 0, 0, 0, 1, 0], indices: [0, 1, 2], vertexColors: [1, 0, 0, 0, 1, 0, 0, 0, 1] }, - { type: "image", id: "c4", name: "Luftbild", src: "data:image/png;base64,AAAA", min: { x: 0, y: 0 }, max: { x: 10, y: 10 }, opacity: 0.7, drape: true, filters: { saturation: 0.5, grayscale: 1 } }, + { type: "terrainMesh", categoryCode: "02", id: "c3", name: "Gelände", positions: [0, 0, 0, 1, 0, 0, 0, 1, 0], indices: [0, 1, 2], vertexColors: [1, 0, 0, 0, 1, 0, 0, 0, 1] }, + { type: "image", categoryCode: "03", id: "c4", name: "Luftbild", src: "data:image/png;base64,AAAA", min: { x: 0, y: 0 }, max: { x: 10, y: 10 }, opacity: 0.7, drape: true, filters: { saturation: 0.5, grayscale: 1 } }, ], extrudedSolids: [ { id: "x1", type: "extrudedSolid", levelId: lvl, points: [{ x: 0, y: 0 }, { x: 1, y: 0 }, { x: 1, y: 1 }], height: 2, baseOffset: 0.1, operation: "subtract", taper: 0.1, cornerRadius: 0.05, chamfer: 0.02 }, diff --git a/src/model/sampleProjectComplex.ts b/src/model/sampleProjectComplex.ts index 93620c29..60c026e4 100644 --- a/src/model/sampleProjectComplex.ts +++ b/src/model/sampleProjectComplex.ts @@ -812,12 +812,12 @@ export function buildComplexSampleProject(): Project { drawings2d: [...cadastre(), ...annotations()], context: [ { - type: "contourSet", id: "hoehenlinien", name: "Höhenlinien (Vermessung)", layer: "Terrain", categoryCode: "14", + type: "contourSet", id: "hoehenlinien", name: "Höhenlinien (Vermessung)", categoryCode: "14", source: "Vermessung (fiktiv)", contours: CONTOUR_Z.map((z) => ({ z, pts: contourAt(z), closed: false, layer: isMainContour(z) ? "HL-Haupt" : "HL" })), }, { // Baugrube: Böschung 60° (Ost 50°), Nordkante (Hang) mit Rühlwand gesichert, Sohle unter der Bodenplatte. - type: "excavation", id: "baugrube", name: "Baugrube Haupthaus", layer: "Terrain", categoryCode: "07", + type: "excavation", id: "baugrube", name: "Baugrube Haupthaus", categoryCode: "07", // Umriss = Gebäude-Grundfläche UG (mit Erker), Arbeitsraum 0.8 m; Neigungen in Grad. outline: rect(-HA, -HA, 17.2, 10 + HA), bottom: -3.35, slope: 60, fillSlope: 33.7, edgeSlopes: [60, 50, 90, 60], edgeShoring: [false, false, true, false], workingSpace: 0.8, diff --git a/src/model/terrain.ts b/src/model/terrain.ts index 44c1cf89..f609b42a 100644 --- a/src/model/terrain.ts +++ b/src/model/terrain.ts @@ -15,9 +15,6 @@ import { TERRAIN_CATEGORY } from "./contextCategories"; let terrainSeq = 0; -/** Sichtbarer Ebenen-/Gruppierungsname des Geländes (SitePanel). */ -export const TERRAIN_LAYER = "Terrain"; - /** * Erzeugt ein Gelände aus Konturen (Rust-Kern, `terrain.rs`): Konturen verdichtet und als Bruchkanten * erzwungen (constrained Delaunay), flache Dreiecke behoben, adaptiv geglättet ohne Überschwingen. @@ -124,14 +121,14 @@ export function terrainMeshFromGrid(grid: TerrainGrid): TerrainMesh { } if (positions.length < 9 || indices.length < 3) { - return { id, type: "terrainMesh", name, categoryCode: TERRAIN_CATEGORY.code, positions: [], indices: [] }; + return { id, type: "terrainMesh", name, categoryCode: TERRAIN_CATEGORY.code, source: "swissALTI3D", positions: [], indices: [] }; } return { id, type: "terrainMesh", name, - layer: TERRAIN_LAYER, categoryCode: TERRAIN_CATEGORY.code, + source: "swissALTI3D", positions, indices, contourInterval: 1, diff --git a/src/model/types.generated.ts b/src/model/types.generated.ts index 72045004..1a2b0adc 100644 --- a/src/model/types.generated.ts +++ b/src/model/types.generated.ts @@ -428,10 +428,16 @@ export type ContextImage = { type: "image"; id: string; name: string; - /** Ebenen-/Gruppierungsname (SitePanel), z. B. „Luftbild". Optional. */ - layer?: string; - /** Grafik-Kategorie-Code, s. {@link ImportedMesh.categoryCode}. */ - categoryCode?: string; + /** + * [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und + * Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`). + */ + categoryCode: string; + /** + * [181] Herkunft (z. B. „swissBUILDINGS3D", „IFC IfcSite", „DXF-Layer Haus") — nur Auskunft in der + * Objekt-Info, ohne jede Wirkung auf Darstellung oder Sichtbarkeit (die steuert allein `categoryCode`). + */ + source?: string; /** Bildquelle als Data-URL (PNG/JPEG). */ src: string; /** Modell-Meter Bounding-Box (das Bild füllt [min..max] planar von oben). */ @@ -463,7 +469,11 @@ export type ContextImage = { }; }; -/** Kontext-Objekt (Tag `type`). */ +/** + * Gelände- und Umgebungs-Element (Tag `type`, Sammlung `Project.context`, [181]): Netzkörper (`importedMesh`, + * z. B. Nachbargebäude), Höhenlinien (`contourSet`), Gelände (`terrainMesh`), Luftbild (`image`), Baugrube + * (`excavation`). Normale Elemente mit Klasse (`categoryCode`), unabhängig davon, woher sie kommen. + */ export type ContextObject = ImportedMesh | ContourSet | TerrainMesh | ContextImage | Excavation; /** @@ -494,10 +504,16 @@ export type ContourSet = { type: "contourSet"; id: string; name: string; - /** Ursprünglicher DXF-Layer-Name (für spätere Kategorisierung). */ - layer?: string; - /** Grafik-Kategorie-Code, s. {@link ImportedMesh.categoryCode}. */ - categoryCode?: string; + /** + * [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und + * Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`). + */ + categoryCode: string; + /** + * [181] Herkunft (z. B. „swissBUILDINGS3D", „IFC IfcSite", „DXF-Layer Haus") — nur Auskunft in der + * Objekt-Info, ohne jede Wirkung auf Darstellung oder Sichtbarkeit (die steuert allein `categoryCode`). + */ + source?: string; contours: Array; }; @@ -1242,8 +1258,11 @@ export type Excavation = { type: "excavation"; id: string; name: string; - layer?: string; - categoryCode?: string; + /** + * [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und + * Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`). + */ + categoryCode: string; outline: Array; bottom: number; slope?: number; @@ -1576,15 +1595,16 @@ export type ImportedMesh = { type: "importedMesh"; id: string; name: string; - /** Ursprünglicher DXF-Layer-Name (für spätere Kategorisierung). */ - layer?: string; /** - * Grafik-Kategorie-Code (s. {@link LayerCategory}, `model/contextCategories.ts`) - * — steuert Sichtbarkeit/Grau/Sperren wie bei jedem anderen Bauteil (Ebenen- - * Panel). Fehlt er (ältere Importe vor dieser Erweiterung), bleibt das Objekt - * IMMER sichtbar (Rückwärtskompatibilität), s. `plan/context.rs` im Kern. + * [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und + * Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`). */ - categoryCode?: string; + categoryCode: string; + /** + * [181] Herkunft (z. B. „swissBUILDINGS3D", „IFC IfcSite", „DXF-Layer Haus") — nur Auskunft in der + * Objekt-Info, ohne jede Wirkung auf Darstellung oder Sichtbarkeit (die steuert allein `categoryCode`). + */ + source?: string; /** * Farbe aus der Quelldatei (`#rrggbb`, z. B. IFC-Oberflächenstil/Material); fehlt sie, gilt die Kontext-Grundfarbe. */ @@ -1595,11 +1615,6 @@ export type ImportedMesh = { smoothShading?: boolean; /** [T4] Knickwinkel in Grad für das glatte Schattieren (Default 30°). */ creaseAngle?: number; - /** - * [137] Nur dieses Netz ausblenden (Grundriss, Schnitt, Ansicht, 3D, Pick); die Kategorie bleibt - * davon unberührt. Fehlt/false = sichtbar. - */ - hidden?: boolean; positions: Array; indices: Array; }; @@ -2757,9 +2772,9 @@ export type Project = { /** Freie 2D-Zeichengeometrie (Line/Polyline/Rect/Circle/Arc/Text). */ drawings2d: Array; /** - * Kontext-Schicht: importierte/abgeleitete „dumme" Geometrie (Meshes, - * Konturen, Gelände-TIN) — NICHT semantisch. Optional, damit bestehende - * Projekte/Tests ohne `context` gültig bleiben (Default: leer behandeln). + * [181] Gelände- und Umgebungs-Elemente (Gelände, Höhenlinien, Netzkörper wie Nachbargebäude, Luftbilder, + * Baugruben): normale Elemente mit Klasse (`categoryCode`), unabhängig von ihrer Herkunft; s. + * {@link ContextObject}. Fehlt das Feld, gilt die Liste als leer. */ context?: Array; /** @@ -3572,16 +3587,23 @@ export type SwingSide = "left" | "right"; /** * Ein TIN-Geländemodell, abgeleitet aus Konturen (Delaunay über (x,y), Z aus der * jeweiligen Kontur-Höhe). `positions` = flaches (x,y,z…)-Array in Metern, - * `indices` = Dreiecks-Indizes. Gelände ist NICHT semantisch (Kontext-Schicht). + * `indices` = Dreiecks-Indizes. Gelände-Element ([181]): aus Höhenlinien erzeugt oder importiert (swissALTI3D, + * IFC-Gelände), danach unabhängig von der Quelle. */ export type TerrainMesh = { type: "terrainMesh"; id: string; name: string; - /** Ebenen-/Gruppierungsname (SitePanel), z. B. „Terrain". Optional. */ - layer?: string; - /** Grafik-Kategorie-Code, s. {@link ImportedMesh.categoryCode}. */ - categoryCode?: string; + /** + * [181] Klasse/Ebene (Grafik-Kategorie, s. {@link LayerCategory}): steuert Sichtbarkeit, Grau und + * Sperren wie bei jedem anderen Element. Pflicht; Importe setzen sie (`model/contextCategories.ts`). + */ + categoryCode: string; + /** + * [181] Herkunft (z. B. „swissBUILDINGS3D", „IFC IfcSite", „DXF-Layer Haus") — nur Auskunft in der + * Objekt-Info, ohne jede Wirkung auf Darstellung oder Sichtbarkeit (die steuert allein `categoryCode`). + */ + source?: string; positions: Array; indices: Array; /** @@ -3607,11 +3629,6 @@ export type TerrainMesh = { smooth?: number; /** [137] Quelle: Id des Höhenlinien-Satzes (`contourSet`), aus dem das Netz erzeugt wurde. */ sourceId?: string; - /** - * [137] Nur dieses Netz ausblenden (Grundriss, Schnitt, Ansicht, 3D, Pick); die Kategorie bleibt - * davon unberührt. Fehlt/false = sichtbar. - */ - hidden?: boolean; }; /** Ein zusammenhängender Textabschnitt mit einheitlicher Formatierung. */ diff --git a/src/panels/ContextObjectProps.tsx b/src/panels/ContextObjectProps.tsx index 49faa6c0..0ac1d2d7 100644 --- a/src/panels/ContextObjectProps.tsx +++ b/src/panels/ContextObjectProps.tsx @@ -1,8 +1,7 @@ -// Einstellungen eines Kontext-Objekts (importiertes Mesh, Gelände, Baugrube) — gemeinsam für die Liste im -// Panel „Gelände & Kontext" und die Objekt-Info ([137]: ein angeklicktes Gelände bzw. eine Baugrube zeigt -// dort dieselben Felder). Gelände zusätzlich: Sichtbarkeit seiner Kategorie und Glättung (aus den -// Höhenlinien neu erzeugt, ein Undo-Schritt). [137] Dazu: dieses Netz einzeln ausblenden (`hidden`) und -// Raster-Gelände (swissALTI3D, ohne Höhenlinien) additiv nachglätten. +// Einstellungen eines Gelände-/Umgebungs-Elements (Netzkörper, Gelände, Baugrube) in der Objekt-Info ([137]: +// ein angeklicktes Gelände bzw. eine Baugrube zeigt dort ihre Felder). Gelände zusätzlich: Sichtbarkeit seiner +// Klasse und Glättung (aus den Höhenlinien neu erzeugt, ein Undo-Schritt); Raster-Gelände (swissALTI3D, ohne +// Höhenlinien) additiv nachglätten. [181] Sichtbarkeit nur über die Klasse — kein Einzel-Ausblenden, keine Import-Liste. // // Bezeichner englisch, UI-Text/Kommentare deutsch. Alle sichtbaren Texte über t(...). @@ -76,15 +75,6 @@ export function ContextObjectProps({ obj, quantities }: { obj: ContextObject; qu // [T4] Glatt oder kantig schattieren, Knickwinkel je Mesh (Vorgabe 30°). return (
-
+ {sel.contextObject.source && ( +
+ {t("objinfo.contextObject.source")} + {sel.contextObject.source} +
+ )} {ctxObj && (
diff --git a/src/panels/README.md b/src/panels/README.md index b15a395b..97e588a2 100644 --- a/src/panels/README.md +++ b/src/panels/README.md @@ -24,7 +24,7 @@ Kern; hier stehen Eingabe und Darstellung. Zustand über den Store (`src/state`) | `DrawingLevelsPanel.tsx`, `LayersPanel.tsx`, `ElementTreePanel.tsx` | Zeichnungsebenen, Ebenen, Baum Geschoss → Bauteilklasse → Element | | `LayoutsPanel.tsx`, `PublishSection.tsx`, `ViewSnapshotsPanel.tsx` | Layouts als Baum, Publikationssätze (`[79]`), gespeicherte Ansichten | | `RoomBalancePanel.tsx` | Flächenbilanz mit den Abschnitten `AreaTableSection.tsx`, `KennzahlenSection.tsx`, `ProgramCompareSection.tsx`, `ElementScheduleSection.tsx`, `OpeningScheduleSection.tsx`, `RoomBookSection.tsx`; Stempel-Editor `RoomStampEditor.tsx` | -| `SitePanel.tsx` | Gelände und Kontext, mit `SiteRulesSection.tsx` (Baurecht), `SunStudySection.tsx` (Schatten) und `PointCloudSection.tsx` | +| `SitePanel.tsx` | Aktionen zu Gelände und Lage (Import, Gelände erzeugen, Baugrube; keine Import-Liste, [181]), mit `SiteRulesSection.tsx` (Baurecht), `SunStudySection.tsx` (Schatten) und `PointCloudSection.tsx` | | `BcfPanel.tsx`, `ClashPanel.tsx` | BCF-Themen und Kollisionsliste; Sitzungszustand in `bcfSession.ts` und `clashSession.ts` | | `HistoryPanel.tsx` | Undo-Verlauf mit Sprung auf einen Schritt | diff --git a/src/panels/SitePanel.tsx b/src/panels/SitePanel.tsx index c17a21f2..b7e10b10 100644 --- a/src/panels/SitePanel.tsx +++ b/src/panels/SitePanel.tsx @@ -1,21 +1,15 @@ -// Inhalts-Panel „Gelände & Kontext" — verwaltet die Kontext-Schicht -// (importierte Meshes, Höhenlinien-Sätze, abgeleitetes Gelände-TIN). Handler -// kommen über usePanelHost, die Kontext-Objekte aus dem Store (`project.context`, [121]). +// Inhalts-Panel „Gelände & Kontext": Aktionen rund um die Lage — DXF-/Standort-Import, Bezugspunkt, +// „Gelände erzeugen" aus Höhenlinien, Baugrube, Schattenstudie, Baurecht, Punktwolken. // -// Aufbau: -// • Aktions-Zeile: „DXF importieren" (öffnet den in App montierten Datei- -// Dialog) + „Gelände erzeugen" (aus dem gewählten Kontur-Satz). -// • Liste der Kontext-Objekte: Name + Typ-Badge + „Entfernen". -// • Schattenstudie (SunStudySection): Schalter, Datum, Zeitregler. -// • Baurecht (SiteRulesSection): Parzelle, Grenzabstände, Baulinien, Gesamthöhe. -// • DWG-Hinweis am Fuß. +// [181] Keine Liste der importierten Dinge mehr: Gelände, Höhenlinien, Nachbargebäude, Luftbilder und +// Baugruben sind nach dem Import normale Elemente mit Klasse. Sichtbarkeit über die Klasse (Ebenen-Panel), +// Auswahl im Plan/3D oder im Elemente-Panel, Einstellungen und Löschen wie bei jedem Element (Objekt-Info). // // Bezeichner englisch, UI-Text/Kommentare deutsch (CONVENTIONS.md). Alle sichtbaren // Texte über t(...). -import { useMemo, useState } from "react"; +import { useState } from "react"; import { t } from "../i18n"; -import type { TranslationKey } from "../i18n"; import { usePanelHost } from "./host"; import type { ContextObject } from "../model/types"; import { ContextImportDialog } from "../ui/ContextImportDialog"; @@ -26,66 +20,12 @@ import { openContextImportWindowNative } from "../native/contextImportWindow"; import { SunStudySection } from "./SunStudySection"; import { SiteRulesSection } from "./SiteRulesSection"; import { PointCloudSection } from "./PointCloudSection"; -import { excavationQuantities } from "../core"; -import { ContextObjectProps } from "./ContextObjectProps"; - -/** Typ-spezifisches Badge-Label (i18n-Key) je Kontext-Objekt-Art. */ -function typeBadgeKey(obj: ContextObject): TranslationKey { - switch (obj.type) { - case "importedMesh": - return "site.type.mesh"; - case "contourSet": - return "site.type.contours"; - case "terrainMesh": - return "site.type.terrain"; - case "image": - return "site.type.image"; - case "excavation": - return "site.type.excavation"; - } -} - -/** Ebenen-/Gruppenname eines Kontext-Objekts (aus `layer`, sonst Typ-Fallback). */ -function layerOf(obj: ContextObject): string { - if (obj.layer && obj.layer.trim() !== "") return obj.layer; - switch (obj.type) { - case "importedMesh": - return t("site.group.imported"); - case "terrainMesh": - return t("site.group.terrain"); - case "contourSet": - return t("site.group.contours"); - case "image": - return t("site.group.image"); - case "excavation": - return t("site.group.terrain"); - } -} - -/** Gruppiert Kontext-Objekte nach Ebene, Reihenfolge des ersten Auftretens. */ -function groupByLayer(objects: ContextObject[]): { layer: string; items: ContextObject[] }[] { - const order: string[] = []; - const byLayer = new Map(); - for (const obj of objects) { - const layer = layerOf(obj); - let items = byLayer.get(layer); - if (!items) { - items = []; - byLayer.set(layer, items); - order.push(layer); - } - items.push(obj); - } - return order.map((layer) => ({ layer, items: byLayer.get(layer)! })); -} const NO_CONTEXT: ContextObject[] = []; export function SitePanel() { const host = usePanelHost(); const project = useStore((s) => s.project); - // Gewählte Kontext-Objekte schmal aus dem Store ([121], [130]). - const selectedContextObjectIds = useStore((s) => s.selection.contextObjects); const notify = useStore((s) => s.notify); const objects = project.context ?? NO_CONTEXT; const contourSets = objects.filter((o) => o.type === "contourSet"); @@ -102,8 +42,6 @@ export function SitePanel() { // [T6] Glätten beim Erzeugen (Bruchkanten werden immer erzwungen). const [smooth, setSmooth] = useState(true); - // [68] Mengen der Baugruben (Kern), nur neu, wenn sich das Projekt ändert. - const quantities = useMemo(() => excavationQuantities(project), [project]); const onGenerate = () => { if (!effectiveSet) return; @@ -194,60 +132,6 @@ export function SitePanel() {
- {/* Kontext-Objekte nach Ebene (`layer`) gruppiert: importierte Gebäude - liegen als EINZELNE, getrennt lösch-/anwählbare Elemente unter ihrer - Ebene (z. B. „Gebäude"), Terrain unter „Terrain". Je Gruppe ein Kopf - mit Anzahl + „ganze Ebene löschen". */} - {objects.length === 0 ? ( -
{t("site.empty")}
- ) : ( - groupByLayer(objects).map(({ layer, items }) => ( -
-
- {layer} - {items.length} - -
-
    - {items.map((obj) => ( -
  • - - {obj.name} - - - {t(typeBadgeKey(obj))} - - - -
  • - ))} -
-
- )) - )} -
{t("site.dwgHint")}
); diff --git a/src/panels/host.ts b/src/panels/host.ts index f027386b..599f35d8 100644 --- a/src/panels/host.ts +++ b/src/panels/host.ts @@ -600,14 +600,12 @@ export interface PanelHostValue { /** Setzt die Drehung der Stütze (Grad; intern in Radiant gespeichert). */ onSetColumnRotation: (deg: number) => void; - // ── Site-/Kontext-Schicht (SitePanel) ─────────────────────────────────── - // Die Kontext-Objekte selbst liest das Panel aus dem Store (`project.context`). - /** Fügt mehrere Kontext-Objekte hinzu (z. B. aus einem DXF-Import). */ + // ── Gelände und Umgebung (SitePanel, Elemente-Panel) ───────────────────── + // Die Elemente selbst liest das Panel aus dem Store (`project.context`). + /** Fügt mehrere Gelände-/Umgebungs-Elemente hinzu (z. B. aus einem Standort-Import). */ onAddContextObjects: (objs: ContextObject[]) => void; - /** Entfernt ein Kontext-Objekt per ID. */ - onRemoveContextObject: (id: string) => void; - /** Entfernt mehrere Kontext-Objekte in einem Schritt (ganze Ebene/Gruppe). */ - onRemoveContextObjects: (ids: string[]) => void; + /** [181] Wählt ein Gelände-/Umgebungs-Element (Elemente-Panel); `zoom` passt die Ansicht ein. */ + onSelectSiteElement: (id: string, opts?: { zoom?: boolean }) => void; /** * Erzeugt aus einem ContourSet (per ID) ein Gelände-TIN. Liefert die neue * TerrainMesh-ID oder null (unbekannte ID / kein sinnvolles TIN). diff --git a/src/plan/generatePlan.context.test.ts b/src/plan/generatePlan.context.test.ts index 0b6345ff..826124d4 100644 --- a/src/plan/generatePlan.context.test.ts +++ b/src/plan/generatePlan.context.test.ts @@ -1,4 +1,4 @@ -// Kontext-Schicht im Grundriss (generatePlan → addContextContours): +// Gelände-/Umgebungs-Elemente im Grundriss (generatePlan → addContextContours): // • ImportedMesh -> [152] im Geschoss nach Ansichtsbereich: Schnittfläche, Aufsicht (mesh-view), Überkopf gestrichelt. // • TerrainMesh -> nur 2D-Bounding-Box-Umriss (4 Linien). // • Nutzer-Report: importierte Gebäude waren im Plan UNSICHTBAR (nur 3D). @@ -29,7 +29,8 @@ function projectWith(context: Project["context"]): Project { } as unknown as Project; } -const visible = new Set(); +// [181] Klassen der Test-Elemente (Gelände „02", Luftbild „03", Netzkörper „10") eingeblendet. +const visible = new Set(["02", "03", "10"]); function contextLines(p: Project) { return generatePlan(p, "eg", visible).primitives.filter( @@ -55,25 +56,25 @@ function box(z0: number, z1: number) { describe("generatePlan — importierte Netze im Grundriss ([152])", () => { it("ein Gebäude durch die Schnitthöhe wird geschnitten (Poché, anwählbar)", () => { - const p = projectWith([{ id: "B1", type: "importedMesh", name: "Haus", ...box(0, 5) }]); + const p = projectWith([{ id: "B1", type: "importedMesh", categoryCode: "10", name: "Haus", ...box(0, 5) }]); const cut = generatePlan(p, "eg", visible).primitives.filter((pr) => pr.kind === "polygon" && pr.contextObjectId === "B1" && pr.fill !== "none"); expect(cut).toHaveLength(1); }); it("eine Fläche am Boden als Aufsicht, ohne Triangulations-Diagonale", () => { - const p = projectWith([{ id: "B1", type: "importedMesh", name: "Platte", positions: [0, 0, 0, 2, 0, 0, 2, 3, 0, 0, 3, 0], indices: [0, 1, 2, 0, 2, 3] }]); + const p = projectWith([{ id: "B1", type: "importedMesh", categoryCode: "10", name: "Platte", positions: [0, 0, 0, 2, 0, 0, 2, 3, 0, 0, 3, 0], indices: [0, 1, 2, 0, 2, 3] }]); expect(meshLines(p)).toHaveLength(4); }); it("ein Träger über der Schnitthöhe als gestrichelte Überkopf-Linie", () => { - const p = projectWith([{ id: "T1", type: "importedMesh", name: "Träger", ...box(2.2, 2.4) }]); + const p = projectWith([{ id: "T1", type: "importedMesh", categoryCode: "10", name: "Träger", ...box(2.2, 2.4) }]); const lines = meshLines(p); expect(lines).toHaveLength(4); expect(lines.every((l) => l.kind === "line" && Array.isArray(l.dash))).toBe(true); }); it("ein Netz des Geschosses darüber erscheint nicht", () => { - const p = projectWith([{ id: "O1", type: "importedMesh", name: "OG", ...box(2.6, 5) }]); + const p = projectWith([{ id: "O1", type: "importedMesh", categoryCode: "10", name: "OG", ...box(2.6, 5) }]); expect(generatePlan(p, "eg", visible).primitives.filter((pr) => pr.kind === "polygon" && pr.contextObjectId === "O1")).toHaveLength(0); }); }); @@ -83,7 +84,7 @@ describe("generatePlan — Kontext-Objekte anklickbar (Pick-Region)", () => { const p = projectWith([ { id: "B1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Haus", positions: [0, 0, 0, 2, 0, 0, 2, 3, 0, 0, 3, 0], indices: [0, 1, 2, 0, 2, 3], @@ -111,7 +112,7 @@ describe("generatePlan — Kontext-Objekte anklickbar (Pick-Region)", () => { const p = projectWith([ { id: "T1", - type: "terrainMesh", + type: "terrainMesh", categoryCode: "02", name: "Gelände", positions: [0, 0, 400, 10, 0, 401, 5, 8, 402], indices: [0, 1, 2], @@ -131,7 +132,7 @@ describe("generatePlan — Kontext-Umriss (TerrainMesh)", () => { const p = projectWith([ { id: "T1", - type: "terrainMesh", + type: "terrainMesh", categoryCode: "02", name: "Gelände", positions: [0, 0, 400, 10, 0, 401, 5, 8, 402], indices: [0, 1, 2], @@ -153,9 +154,8 @@ describe("generatePlan — Luftbild (ContextImage)", () => { const p = projectWith([ { id: "IMG1", - type: "image", + type: "image", categoryCode: "03", name: "Luftbild", - layer: "Luftbild", src: "data:image/jpeg;base64,AAAA", min: { x: -100, y: -80 }, max: { x: 100, y: 80 }, @@ -178,7 +178,7 @@ describe("generatePlan — Luftbild (ContextImage)", () => { const p = projectWith([ { id: "IMG1", - type: "image", + type: "image", categoryCode: "03", name: "Luftbild", src: "data:image/jpeg;base64,AAAA", min: { x: 0, y: 0 }, @@ -199,7 +199,7 @@ describe("generatePlan — Luftbild (ContextImage)", () => { const p = projectWith([ { id: "IMG1", - type: "image", + type: "image", categoryCode: "03", name: "Luftbild", src: "data:image/jpeg;base64,AAAA", min: { x: 0, y: 0 }, @@ -214,7 +214,7 @@ describe("generatePlan — Luftbild (ContextImage)", () => { const p = projectWith([ { id: "IMG1", - type: "image", + type: "image", categoryCode: "03", name: "Luftbild", src: "data:image/jpeg;base64,AAAA", min: { x: 0, y: 0 }, @@ -227,11 +227,10 @@ describe("generatePlan — Luftbild (ContextImage)", () => { }); describe("generatePlan — Kontext-Objekte: Ebenen-Sichtbarkeit (categoryCode)", () => { - // Ein Kontext-Objekt MIT `categoryCode` respektiert dieselbe visibleCodes- - // Allowlist wie jedes andere Bauteil (Wand/Dach/…) — Nutzer-Report: "sollten - // wie Gebäude/Dächer ausblendbar sein". Objekte OHNE categoryCode (ältere - // Importe) bleiben unabhängig davon immer sichtbar (Rückwärtskompatibilität). - const buildingMesh = (id: string, categoryCode?: string) => ({ + // Gelände-/Umgebungs-Elemente respektieren dieselbe visibleCodes-Allowlist wie jedes andere Bauteil + // (Wand/Dach/…) — Nutzer-Report: "sollten wie Gebäude/Dächer ausblendbar sein". [181] Die Klasse ist + // Pflicht; ein „ohne Kategorie immer sichtbar" gibt es nicht mehr. + const buildingMesh = (id: string, categoryCode: string) => ({ id, type: "importedMesh" as const, name: "Haus", @@ -258,12 +257,4 @@ describe("generatePlan — Kontext-Objekte: Ebenen-Sichtbarkeit (categoryCode)", expect(lines.length).toBeGreaterThan(0); }); - it("ein Objekt OHNE categoryCode bleibt immer sichtbar (Altbestand)", () => { - const p = projectWith([buildingMesh("B1", undefined)]); - const visibleEmpty = new Set(); // schliesst alles Benannte aus - const lines = generatePlan(p, "eg", visibleEmpty).primitives.filter( - (pr) => pr.kind === "line" && (pr as { cls?: string }).cls === "mesh-view", - ); - expect(lines.length).toBeGreaterThan(0); - }); }); diff --git a/src/plan/sectionExtras.test.ts b/src/plan/sectionExtras.test.ts index 32bfe541..2bd9bf16 100644 --- a/src/plan/sectionExtras.test.ts +++ b/src/plan/sectionExtras.test.ts @@ -27,7 +27,7 @@ function terrain(): TerrainMesh { const a = j * n + i; indices.push(a, a + 1, a + n, a + 1, a + n + 1, a + n); } - return { id: "t1", type: "terrainMesh", name: "Gelände", positions, indices }; + return { id: "t1", type: "terrainMesh", categoryCode: "02", name: "Gelände", positions, indices }; } describe("Schnitt: Gelände und freie Körper", () => { diff --git a/src/plan/toWalls3d.pickExtras.test.ts b/src/plan/toWalls3d.pickExtras.test.ts index c8c4c392..de4aefca 100644 --- a/src/plan/toWalls3d.pickExtras.test.ts +++ b/src/plan/toWalls3d.pickExtras.test.ts @@ -45,13 +45,14 @@ describe("[137] 3D-Pick Treppengeländer und 2D-Flächen", () => { expect(pick(base, down(24, 5))).toBeNull(); }); - it("importiertes Netz: hidden entfernt die Pick-Dreiecke, Undo bringt sie zurück", () => { - const mesh = { type: "importedMesh", id: "im", name: "M", positions: [30, 0, 0, 32, 0, 0, 30, 2, 0], indices: [0, 1, 2] } as ImportedMesh; - setState({ project: { ...base, stairs: [], drawings2d: [], context: [mesh] }, undoDepth: 0, redoDepth: 0, canUndo: false, canRedo: false }); + it("[181] Netzkörper in ausgeblendete Klasse verschoben: keine Pick-Dreiecke, Undo bringt sie zurück", () => { + const mesh = { type: "importedMesh", id: "im", name: "M", categoryCode: "10", positions: [30, 0, 0, 32, 0, 0, 30, 2, 0], indices: [0, 1, 2] } as ImportedMesh; + const off = { code: "99", name: "Aus", color: "#000000", lw: 0.1, visible: false } as Project["layers"][number]; + setState({ project: { ...base, layers: [...base.layers, off], stairs: [], drawings2d: [], context: [mesh] }, undoDepth: 0, redoDepth: 0, canUndo: false, canRedo: false }); getState().clearHistory(); expect(pickGeometry(getState().project).contextMeshes.map((m) => m.contextObjectId)).toEqual(["im"]); - getState().patchContextObject("im", { hidden: true }); - expect((getState().project.context![0] as ImportedMesh).hidden).toBe(true); + getState().patchContextObject("im", { categoryCode: "99" }); + expect((getState().project.context![0] as ImportedMesh).categoryCode).toBe("99"); expect(pickGeometry(getState().project).contextMeshes).toEqual([]); getState().undo(); expect(pickGeometry(getState().project).contextMeshes).toHaveLength(1); diff --git a/src/plan/toWalls3d.pickSolids.test.ts b/src/plan/toWalls3d.pickSolids.test.ts index 82d6da7a..0140ddb9 100644 --- a/src/plan/toWalls3d.pickSolids.test.ts +++ b/src/plan/toWalls3d.pickSolids.test.ts @@ -71,11 +71,11 @@ describe("[137] 3D-Pick freie Körper und Stützen", () => { expect(selectionHighlightLines(base, [], [], rgb, [], [], [], [], 0, [], ["s1"]).length).toBe(4 * 3 * 12); }); - it("einzeln ausgeblendetes Gelände fängt im 3D keinen Klick", () => { - const terrain: TerrainMesh = { id: "t1", type: "terrainMesh", name: "G", positions: [0, 0, 0, 10, 0, 0, 10, 10, 0], indices: [0, 1, 2] }; + it("[181] Gelände in ausgeblendeter Klasse fängt im 3D keinen Klick", () => { + const terrain: TerrainMesh = { id: "t1", type: "terrainMesh", categoryCode: "02", name: "G", positions: [0, 0, 0, 10, 0, 0, 10, 10, 0], indices: [0, 1, 2] }; const shown = { ...base, context: [{ ...terrain }] } as Project; expect(pickGeometry(shown).contextMeshes.map((m) => m.contextObjectId)).toEqual(["t1"]); - const hidden = { ...base, context: [{ ...terrain, hidden: true }] } as Project; + const hidden = { ...base, layers: [...base.layers, { code: "02", name: "Gelände", color: "#808080", lw: 0.13, visible: false }], context: [{ ...terrain }] } as Project; expect(pickGeometry(hidden).contextMeshes).toEqual([]); }); }); diff --git a/src/plan/toWalls3d.test.ts b/src/plan/toWalls3d.test.ts index 93ba6b63..da629be1 100644 --- a/src/plan/toWalls3d.test.ts +++ b/src/plan/toWalls3d.test.ts @@ -114,7 +114,7 @@ describe("selectionHighlightLines — Kontext-Objekte", () => { context: [ { id: "CTX1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Testgebäude", positions: [0, 0, 0, 2, 0, 0, 2, 3, 4], indices: [0, 1, 2], @@ -2559,7 +2559,7 @@ describe("pickGeometry — Kontext-Meshes (importierte Gebäude/Terrain)", () => context: [ { id: "CTX1", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Testgebäude", // model (x,y,z=Höhe) -> world (x, z, -y): ein Dreieck. positions: [0, 0, 0, 2, 0, 0, 2, 3, 4], @@ -2567,7 +2567,7 @@ describe("pickGeometry — Kontext-Meshes (importierte Gebäude/Terrain)", () => }, { id: "CONTOURS1", - type: "contourSet", + type: "contourSet", categoryCode: "02", name: "Höhenlinien", contours: [], }, @@ -2591,7 +2591,7 @@ describe("pickGeometry — Kontext-Meshes (importierte Gebäude/Terrain)", () => context: [ { id: "CTX2", - type: "importedMesh", + type: "importedMesh", categoryCode: "10", name: "Kaputt", positions: [0, 0, 0, 1, 0, 0, 1, 1, 0], indices: [0, 1, 99], // Index 99 existiert nicht diff --git a/src/state/README.md b/src/state/README.md index 6496fcf2..e93c3dab 100644 --- a/src/state/README.md +++ b/src/state/README.md @@ -20,7 +20,7 @@ geänderten Listen sind neu ([121]). | `selectionSlice.ts`, `selection.ts` | Auswahl als ein Wert (`Selection`, je Element-Art eine Menge) | | `viewSlice.ts` | Darstellung ohne Modell: aktive Ebene, Massstab, Detailgrad, Schwarz-Weiss … | | `layoutSlice.ts` | Panel-Layout (Docks, Tabs, schwebende Fenster) | -| `siteSlice.ts`, `notifySlice.ts` | Kontext-Objekte; Kurzmeldungen (`notify()`) | +| `siteSlice.ts`, `notifySlice.ts` | Gelände-/Umgebungs-Elemente (`project.context`, [181]); Kurzmeldungen (`notify()`) | | `busyStore.ts`, `cursorStore.ts`, `liveScaleStore.ts` | hochfrequente oder globale Werte ausserhalb von React-State | ## Verdrahtung (aus `App.tsx` herausgelöst) diff --git a/src/state/excavationGrips.test.ts b/src/state/excavationGrips.test.ts index 580a491f..1f219e21 100644 --- a/src/state/excavationGrips.test.ts +++ b/src/state/excavationGrips.test.ts @@ -8,7 +8,7 @@ import { excavationGripPoints } from "../core"; const pit: Excavation = { id: "bg", - type: "excavation", + type: "excavation", categoryCode: "07", name: "Baugrube", outline: [{ x: 0, y: 0 }, { x: 4, y: 0 }, { x: 4, y: 4 }, { x: 0, y: 4 }], bottom: -2, diff --git a/src/state/panelHost/selectionStyleHost.ts b/src/state/panelHost/selectionStyleHost.ts index b2e600d5..d3d3cd1e 100644 --- a/src/state/panelHost/selectionStyleHost.ts +++ b/src/state/panelHost/selectionStyleHost.ts @@ -342,6 +342,10 @@ export function buildSelectionStyleHost(c: FlatHostOpts) { case "column": applyChange((p) => patchItem(p, "columns", id, { categoryCode: code })); break; + // [181] Gelände-/Umgebungs-Elemente (Netzkörper, Gelände, Höhenlinien, Luftbild, Baugrube) wie jedes Element. + case "contextObject": + applyChange((p) => patchItem(p, "context", id, { categoryCode: code })); + break; default: break; // extrudedSolid/door: keine Kategorie am Element } }, diff --git a/src/state/panelHost/siteHost.ts b/src/state/panelHost/siteHost.ts index 878f942f..1d4b7564 100644 --- a/src/state/panelHost/siteHost.ts +++ b/src/state/panelHost/siteHost.ts @@ -1,5 +1,5 @@ // Panel-Host, Teil Lage und Elemente-Baum ([121], aus `usePanelHostBase` herausgelöst): -// Kontext-Objekte (Gelände, Aushub, Georeferenz, DXF-Import) und die Auswahl einer Zeile im +// Gelände-/Umgebungs-Elemente (Gelände, Aushub, Georeferenz, DXF-Import, Auswahl im Elemente-Panel) und die Auswahl einer Zeile im // Elemente-Panel samt Geschosswechsel und Zoom. import { setFieldIfChanged } from "../../core"; @@ -8,12 +8,14 @@ import type { ScheduleKind } from "../../export/exportSchedule"; import type { FlatHostOpts, HostPart } from "./types"; export function buildSiteHost(c: FlatHostOpts) { - const { activeLevelId, addContextObjectsAndFit, applyChange, dxfInputRef, generateTerrain, onRunCommand, patchContextObject, planViewRef, removeContextObject, removeContextObjects, setActiveLevelId, setSelection } = c; + const { activeLevelId, addContextObjectsAndFit, applyChange, dxfInputRef, generateTerrain, onRunCommand, patchContextObject, planViewRef, setActiveLevelId, setSelection } = c; return { - // ── Site-/Kontext-Schicht ────────────────────────────────────────────── + // ── Gelände und Umgebung ─────────────────────────────────────────────── onAddContextObjects: addContextObjectsAndFit, - onRemoveContextObject: removeContextObject, - onRemoveContextObjects: removeContextObjects, + onSelectSiteElement: (id: string, opts?: { zoom?: boolean }) => { + setSelection({ ...clearKinds(), contextObjects: [id] }); + if (opts?.zoom) requestAnimationFrame(() => planViewRef.current?.fit()); + }, onGenerateTerrain: generateTerrain, onPatchContextObject: patchContextObject, onStartExcavation: () => onRunCommand("excavation"), diff --git a/src/state/panelHost/types.ts b/src/state/panelHost/types.ts index 409ab8a0..75665636 100644 --- a/src/state/panelHost/types.ts +++ b/src/state/panelHost/types.ts @@ -92,8 +92,6 @@ export type PanelHostOpts = { | "importLineStyles" | "importHatches" | "addContextObjectsAndFit" - | "removeContextObject" - | "removeContextObjects" | "generateTerrain" | "patchContextObject" | "commitTransformOn" diff --git a/src/state/selectionInfo.contextImage.test.ts b/src/state/selectionInfo.contextImage.test.ts index 92c10bf3..09ab3f9a 100644 --- a/src/state/selectionInfo.contextImage.test.ts +++ b/src/state/selectionInfo.contextImage.test.ts @@ -38,6 +38,7 @@ describe("deriveSelection — Kontext-Objekt-Luftbild (ContextImage)", () => { id: "IMG1", type: "image", name: "Luftbild", + categoryCode: "03", src: "data:image/jpeg;base64,AAAA", min: { x: 0, y: 0 }, max: { x: 10, y: 10 }, @@ -54,7 +55,7 @@ describe("deriveSelection — Kontext-Objekt-Luftbild (ContextImage)", () => { it("opacity fällt auf 1 zurück, wenn das Bild keine eigene Deckkraft trägt", () => { const project = projectWith([ - { id: "IMG1", type: "image", name: "Luftbild", src: "x", min: { x: 0, y: 0 }, max: { x: 1, y: 1 } }, + { id: "IMG1", type: "image", name: "Luftbild", categoryCode: "03", src: "x", min: { x: 0, y: 0 }, max: { x: 1, y: 1 } }, ]); const sel = deriveSelection(project, { contextObjects: ["IMG1"] }); expect(sel?.opacity).toBe(1); @@ -63,11 +64,22 @@ describe("deriveSelection — Kontext-Objekt-Luftbild (ContextImage)", () => { it("isImage bleibt false/undefined für ein Nicht-Bild-Kontext-Objekt (z. B. importiertes Mesh)", () => { const project = projectWith([ - { id: "M1", type: "importedMesh", name: "Haus", positions: [0, 0, 0, 1, 0, 0, 0, 1, 0], indices: [0, 1, 2] }, + { id: "M1", type: "importedMesh", categoryCode: "10", name: "Haus", positions: [0, 0, 0, 1, 0, 0, 0, 1, 0], indices: [0, 1, 2] }, ]); const sel = deriveSelection(project, { contextObjects: ["M1"] }); expect(sel?.isImage).toBeFalsy(); expect(sel?.opacity).toBeUndefined(); expect(sel?.imageFilters).toBeUndefined(); }); + + it("[181] Klasse und Herkunft wie bei jedem Element (Klasse im Kopf änderbar, Farbe der Klasse)", () => { + const project = projectWith([ + { id: "B1", type: "importedMesh", name: "Haus", categoryCode: "12", source: "swissBUILDINGS3D", positions: [0, 0, 0, 1, 0, 0, 0, 1, 0], indices: [0, 1, 2] }, + ]); + project.layers = [{ code: "12", name: "Gebäude", color: "#123456", lw: 0.25, visible: true } as Project["layers"][number]]; + const sel = deriveSelection(project, { contextObjects: ["B1"] }); + expect(sel?.categoryCode).toBe("12"); + expect(sel?.color).toBe("#123456"); + expect(sel?.contextObject?.source).toBe("swissBUILDINGS3D"); + }); }); diff --git a/src/state/selectionInfo.ts b/src/state/selectionInfo.ts index 1996287f..e13f5aac 100644 --- a/src/state/selectionInfo.ts +++ b/src/state/selectionInfo.ts @@ -556,6 +556,8 @@ export interface DetailRefInfo { */ export interface ContextObjectInfo { objType: ContextObject["type"]; + /** [181] Herkunft (z. B. „swissBUILDINGS3D"), nur Auskunft. */ + source?: string; /** Reale LV95-Koordinate des Bbox-Mittelpunkts, falls `Project.geoAnchor` * gesetzt ist (sonst `undefined` — kein Bezug bekannt). */ lv95Center?: { e: number; n: number }; diff --git a/src/state/siteSelection.test.ts b/src/state/siteSelection.test.ts index 589424a8..fe9f1e3a 100644 --- a/src/state/siteSelection.test.ts +++ b/src/state/siteSelection.test.ts @@ -89,7 +89,7 @@ describe("[137] Raster-Gelände (swissALTI3D) nachglätten", () => { const a = j * 6 + i; indices.push(a, a + 1, a + 7, a, a + 7, a + 6); } - const grid: TerrainMesh = { id: "alti", type: "terrainMesh", name: "swissALTI3D", positions, indices, smooth: 1 }; + const grid: TerrainMesh = { id: "alti", type: "terrainMesh", categoryCode: "02", name: "swissALTI3D", positions, indices, smooth: 1 }; setState({ project: { ...p, context: [grid] }, undoDepth: 0, redoDepth: 0, canUndo: false, canRedo: false }); getState().clearHistory(); const cur = () => getState().project.context!.find((c) => c.id === "alti") as TerrainMesh; diff --git a/src/state/siteSlice.ts b/src/state/siteSlice.ts index 7a1700a9..b58d7822 100644 --- a/src/state/siteSlice.ts +++ b/src/state/siteSlice.ts @@ -1,6 +1,5 @@ -// Site-/Kontext-Slice: verwaltet die Kontext-Schicht `project.context` -// (importierte Meshes, Konturen-Sätze, abgeleitetes Gelände-TIN). Diese -// Geometrie ist „dumm"/nicht-semantisch — sie liegt bewusst NEBEN dem BIM-Modell. +// Site-Slice: Gelände- und Umgebungs-Elemente `project.context` (Netzkörper, Höhenlinien, Gelände, Luftbild, +// Baugrube). [181] Normale Elemente mit Klasse — keine eigene „Kontext-Schicht" mit Import-Liste mehr. // // Entwurfsentscheidung: `context` ist Teil von `project` (ein einziger // Wahrheits-Baum, konsistent mit projectSlice). Diese Slice MUTIERT daher diff --git a/src/state/useProjectActions.ts b/src/state/useProjectActions.ts index 46797a9f..11ea6490 100644 --- a/src/state/useProjectActions.ts +++ b/src/state/useProjectActions.ts @@ -353,8 +353,6 @@ export function useProjectActions( const pts = contextObjectsBounds(objs as ContextObject[]); if (pts) planViewRef.current?.fitBounds(pts); }; - const removeContextObject = useStore((s) => s.removeContextObject); - const removeContextObjects = useStore((s) => s.removeContextObjects); const generateTerrain = useStore((s) => s.generateTerrain); const patchContextObject = useStore((s) => s.patchContextObject); const moveGripOf = useStore((s) => s.moveGripOf); @@ -475,8 +473,6 @@ export function useProjectActions( addContextObjects, addContextObjectsAndFit, fitToContextObjects, - removeContextObject, - removeContextObjects, generateTerrain, patchContextObject, moveGripOf, diff --git a/src/styles.css b/src/styles.css index c95adb5f..88a8cdb3 100644 --- a/src/styles.css +++ b/src/styles.css @@ -4932,54 +4932,7 @@ body { background: var(--line); margin: 2px 0; } -.site-panel .site-empty { - color: var(--ink-2); - padding: 8px 4px; - line-height: 1.4; -} -.site-panel .site-group { - margin-bottom: 6px; -} -.site-panel .site-group-head { - display: flex; - align-items: center; - gap: 6px; - padding: 3px 6px; - font-size: 11px; - font-weight: 600; - color: var(--ink-2); - text-transform: uppercase; - letter-spacing: 0.04em; -} -.site-panel .site-group-name { - flex: 1 1 auto; - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -.site-panel .site-group-count { - flex: 0 0 auto; - color: var(--muted); - font-weight: 400; -} -.site-panel .site-list { - list-style: none; - margin: 0; - padding: 0; - display: flex; - flex-direction: column; - gap: 2px; -} -.site-panel .site-row { - display: flex; - flex-wrap: wrap; - align-items: center; - gap: 6px; - padding: 4px 6px; - border-radius: 5px; -} -/* [T6]/[68] Felder von Gelände und Baugrube unter der Zeile. */ +/* [T6]/[68] Felder von Gelände und Baugrube (Objekt-Info). */ .site-panel .site-props { flex: 1 0 100%; display: grid; @@ -5006,33 +4959,6 @@ body { gap: 3px; font-size: 11px; } -.site-panel .site-row:hover { - background: var(--accent-dim); -} -.site-panel .site-row-selected { - background: var(--accent-dim); - outline: 1px solid var(--accent); -} -.site-panel .site-name { - flex: 1 1 auto; - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -.site-panel .site-badge { - flex: 0 0 auto; - font-size: 10px; - padding: 1px 6px; - border-radius: 8px; - background: var(--panel-2); - color: var(--ink-2); - border: 1px solid var(--line); -} -.site-panel .site-badge-terrainMesh { - color: var(--accent); - border-color: var(--accent-border); -} .site-panel .site-remove { flex: 0 0 auto; width: 18px; diff --git a/src/ui/ContextImportDialog.tsx b/src/ui/ContextImportDialog.tsx index d08ae518..d8d3756e 100644 --- a/src/ui/ContextImportDialog.tsx +++ b/src/ui/ContextImportDialog.tsx @@ -295,8 +295,8 @@ export function ContextImportDialog({ id: `img-${Date.now()}`, type: "image", name: `Luftbild ${selected.label}`, - layer: "Luftbild", categoryCode: IMAGE_CATEGORY.code, + source: "SWISSIMAGE", src: imageResult.dataUrl, min: imageResult.min, max: imageResult.max,