[181] [152] Importe als eigenständige Elemente: Klasse Pflicht, Herkunft nur Auskunft, keine Import-Liste

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.
This commit is contained in:
Claude committed 2026-11-11 04:00:16 +00:00
1 parent a4c541bc50
commit cb9d8c3b0f
70 files changed
+616 -710

No files matched your search

+3 -2
View File
@@ -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,
+2 -2
View File
@@ -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(/\[/);
});
});
+2 -2
View File
@@ -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],
+4 -18
View File
@@ -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",
+4 -18
View File
@@ -456,7 +456,7 @@ export const en: Record<TranslationKey, string> = {
"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<TranslationKey, string> = {
// ── 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<TranslationKey, string> = {
"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<TranslationKey, string> = {
"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<TranslationKey, string> = {
"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<TranslationKey, string> = {
// ── 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",
+2 -2
View File
@@ -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([
+5 -16
View File
@@ -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<GeoCategory, string> = {
building: "Gebäude",
road: "Strassen",
@@ -51,17 +52,6 @@ const CATEGORY_LABEL: Record<GeoCategory, string> = {
forest: "Wald",
};
/** Layer-Kennung (englischer Identifier) je Kategorie — für spätere Zuordnung. */
const CATEGORY_LAYER: Record<GeoCategory, string> = {
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,
};
+1 -1
View File
@@ -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));
+2 -1
View File
@@ -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).
//
+1 -1
View File
@@ -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],
+23 -22
View File
@@ -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");
});
});
+14 -15
View File
@@ -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,
});
}
}
+2 -2
View File
@@ -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: [
{
+4 -4
View File
@@ -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 },
+2 -2
View File
@@ -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,
+2 -5
View File
@@ -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,
+53 -36
View File
@@ -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<Contour>;
};
@@ -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<Vec2>;
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<number>;
indices: Array<number>;
};
@@ -2757,9 +2772,9 @@ export type Project = {
/** Freie 2D-Zeichengeometrie (Line/Polyline/Rect/Circle/Arc/Text). */
drawings2d: Array<Drawing2D>;
/**
* 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<ContextObject>;
/**
@@ -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<number>;
indices: Array<number>;
/**
@@ -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. */
+5 -24
View File
@@ -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 (
<div className="site-props">
<label className="site-check" title={t("site.mesh.visible.hint")}>
<input
type="checkbox"
data-testid="imported-mesh-visible"
checked={obj.hidden !== true}
onChange={(e) => host.onPatchContextObject(obj.id, { hidden: e.target.checked ? undefined : true }, `site-${obj.id}-hidden`)}
/>
{t("site.mesh.visible")}
</label>
<label className="site-check">
<input
type="checkbox"
@@ -101,19 +91,10 @@ export function ContextObjectProps({ obj, quantities }: { obj: ContextObject; qu
}
if (obj.type === "terrainMesh") {
const cat = obj.categoryCode ? flattenCategories(project.layers).find((c) => c.code === obj.categoryCode) : undefined;
const cat = flattenCategories(project.layers).find((c) => c.code === obj.categoryCode);
const hasSource = (project.context ?? []).some((o) => o.type === "contourSet");
return (
<div className="site-props">
<label className="site-check" title={t("site.terrain.meshVisible.hint")}>
<input
type="checkbox"
data-testid="terrain-mesh-visible"
checked={obj.hidden !== true}
onChange={(e) => host.onPatchContextObject(obj.id, { hidden: e.target.checked ? undefined : true }, `site-${obj.id}-hidden`)}
/>
{t("site.terrain.meshVisible")}
</label>
{cat && (
<label className="site-check" title={t("site.terrain.visible.hint", { name: `${cat.code} ${cat.name}` })}>
<input type="checkbox" data-testid="terrain-visible" checked={cat.visible} onChange={() => host.onToggleCategory(cat.code)} />
+71 -2
View File
@@ -14,9 +14,14 @@
// die Plan-Ansicht ein. Auf-/zuklappbare Geschoss- und Klassen-Knoten, ein
// Textfilter oben durchsucht Name/Typ/Klasse.
//
// [181] Gelände- und Umgebungs-Elemente (Gelände, Höhenlinien, Netzkörper wie Nachbargebäude, Luftbilder,
// Baugruben) stehen als eigener Knoten „Gelände & Umgebung" daneben — wie alle anderen Elemente wähl- und
// zoombar, unabhängig davon, woher sie kommen.
//
// Bezeichner englisch, UI-Text/Kommentare deutsch (CONVENTIONS.md).
import { useMemo, useState } from "react";
import type { ContextObject } from "../model/types";
import { useStore } from "../state/appStore";
import { usePanelHost } from "./host";
import type { ScheduleKind, ScheduleRow } from "./host";
@@ -47,6 +52,12 @@ const CLASS_LABEL_KEY: Record<Exclude<ScheduleKind, "Tür">, string> = {
Extrusion: "elements.kind.extrusion",
};
/** Arten der Gelände-/Umgebungs-Elemente in Anzeigereihenfolge (Label wie in der Objekt-Info). */
const SITE_ORDER: ContextObject["type"][] = ["terrainMesh", "contourSet", "excavation", "importedMesh", "image"];
/** Sammelknoten der Gelände-/Umgebungs-Elemente (Schlüssel für das Auf-/Zuklappen). */
const SITE_KEY = "::site";
/** Kurzform einer ID für die Anzeige (voller Wert bleibt im Tooltip). */
function shortId(id: string): string {
return id.length <= 14 ? id : `${id.slice(0, 4)}…${id.slice(-6)}`;
@@ -113,6 +124,13 @@ export function ElementTreePanel() {
const q = query.trim().toLowerCase();
const searching = q.length > 0;
// [181] Gelände-/Umgebungs-Elemente, nach Suchtext gefiltert (Name, Art, Id).
const siteItems = useMemo(() => {
const all = project.context ?? [];
if (!searching) return all;
return all.filter((o) => `${o.name} ${t(`objinfo.contextObject.type.${o.type}`)} ${o.id}`.toLowerCase().includes(q));
}, [project.context, q, searching]);
const visibleRows = useMemo(() => {
if (!searching) return allRows;
return allRows.filter((r) =>
@@ -144,7 +162,7 @@ export function ElementTreePanel() {
host.onSelectScheduleRow(row.kind, row.id, row.floorId, { zoom });
};
if (allRows.length === 0) {
if (allRows.length === 0 && (project.context ?? []).length === 0) {
return (
<section className="nav-group">
<header className="nav-group-head">
@@ -183,7 +201,7 @@ export function ElementTreePanel() {
/>
</div>
{floorGroups.length === 0 ? (
{floorGroups.length === 0 && siteItems.length === 0 ? (
<div style={{ padding: "10px 10px", fontSize: 12, color: "var(--muted)" }}>
{t("elements.noMatch")}
</div>
@@ -262,6 +280,57 @@ export function ElementTreePanel() {
);
})
)}
{siteItems.length > 0 && (
<div className="level-cat" data-testid="elements-site">
<header className="level-cat-head" onClick={() => toggleFloor(SITE_KEY)}>
<span className={`level-cat-chevron${searching || !collapsedFloors.has(SITE_KEY) ? " open" : ""}`} aria-hidden="true">
▸
</span>
<span className="level-cat-title">{t("elements.site")}</span>
<span style={{ fontSize: 10, color: "var(--muted)" }}>{siteItems.length}</span>
</header>
{(searching || !collapsedFloors.has(SITE_KEY)) && (
<div className="nav-list">
{SITE_ORDER.map((kind) => {
const items = siteItems.filter((o) => o.type === kind);
if (items.length === 0) return null;
const classKey = `${SITE_KEY}::${kind}`;
const classOpen = searching || !collapsedClasses.has(classKey);
return (
<div key={classKey}>
<header className="level-cat-head" style={{ paddingLeft: 20, minHeight: 20 }} onClick={() => toggleClass(classKey)}>
<span className={`level-cat-chevron${classOpen ? " open" : ""}`} aria-hidden="true">
▸
</span>
<span className="level-cat-title" style={{ fontSize: 9 }}>
{t(`objinfo.contextObject.type.${kind}`)}
</span>
<span style={{ fontSize: 10, color: "var(--muted)" }}>{items.length}</span>
</header>
{classOpen && (
<div className="nav-list">
{items.map((o) => (
<div
key={o.id}
className="nav-row"
style={{ paddingLeft: 34 }}
title={o.id}
onClick={(e) => host.onSelectSiteElement(o.id, { zoom: e.shiftKey })}
onDoubleClick={() => host.onSelectSiteElement(o.id, { zoom: true })}
>
<span className="nav-label">{o.name}</span>
<span className="nav-elev">{o.categoryCode}</span>
</div>
))}
</div>
)}
</div>
);
})}
</div>
)}
</div>
)}
</section>
);
}
+8 -2
View File
@@ -330,8 +330,8 @@ export function ObjectInfoPanel() {
)}
</>
)}
{/* Kontext-Objekt (importiertes Gebäude/Terrain/Konturen): reale LV95-
Koordinate des Bbox-Mittelpunkts — direkt sichtbar, ob/wohin
{/* Gelände-/Umgebungs-Element (Netzkörper, Gelände, Höhenlinien …): Art, Herkunft (nur Auskunft, [181]),
Einstellungen und reale LV95-Koordinate des Bbox-Mittelpunkts — direkt sichtbar, ob/wohin
georeferenziert importiert wurde (Nutzer-Wunsch zum Prüfen). */}
{sel.contextObject && (
<>
@@ -341,6 +341,12 @@ export function ObjectInfoPanel() {
<span className="objinfo-flabel">{t("objinfo.contextObject.type")}</span>
<span className="objinfo-fval">{t(`objinfo.contextObject.type.${sel.contextObject.objType}`)}</span>
</div>
{sel.contextObject.source && (
<div className="objinfo-field">
<span className="objinfo-flabel">{t("objinfo.contextObject.source")}</span>
<span className="objinfo-fval" data-testid="context-source">{sel.contextObject.source}</span>
</div>
)}
{ctxObj && (
<div className="site-panel objinfo-site">
<ContextObjectProps obj={ctxObj} quantities={quantities} />
+1 -1
View File
@@ -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 |
+6 -122
View File
@@ -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<string, ContextObject[]>();
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() {
<PointCloudSection />
<div className="site-sep" />
{/* 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 ? (
<div className="site-empty">{t("site.empty")}</div>
) : (
groupByLayer(objects).map(({ layer, items }) => (
<div key={layer} className="site-group">
<div className="site-group-head">
<span className="site-group-name">{layer}</span>
<span className="site-group-count">{items.length}</span>
<button
type="button"
className="site-remove"
title={t("site.deleteLayer")}
aria-label={t("site.deleteLayer")}
onClick={() => host.onRemoveContextObjects(items.map((o) => o.id))}
>
×
</button>
</div>
<ul className="site-list">
{items.map((obj) => (
<li
key={obj.id}
className={
"site-row" +
(selectedContextObjectIds.includes(obj.id) ? " site-row-selected" : "")
}
>
<span className="site-name" title={obj.name}>
{obj.name}
</span>
<span className={"site-badge site-badge-" + obj.type}>
{t(typeBadgeKey(obj))}
</span>
<button
type="button"
className="site-remove"
title={t("site.delete")}
aria-label={t("site.delete")}
onClick={() => host.onRemoveContextObject(obj.id)}
>
×
</button>
<ContextObjectProps obj={obj} quantities={quantities} />
</li>
))}
</ul>
</div>
))
)}
<div className="site-hint">{t("site.dwgHint")}</div>
</div>
);
+5 -7
View File
@@ -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).
+18 -27
View File
@@ -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<string>();
// [181] Klassen der Test-Elemente (Gelände „02", Luftbild „03", Netzkörper „10") eingeblendet.
const visible = new Set<string>(["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<string>(); // 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);
});
});
+1 -1
View File
@@ -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", () => {
+6 -5
View File
@@ -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);
+3 -3
View File
@@ -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([]);
});
});
+4 -4
View File
@@ -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
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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,
@@ -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
}
},
+7 -5
View File
@@ -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"),
-2
View File
@@ -92,8 +92,6 @@ export type PanelHostOpts = {
| "importLineStyles"
| "importHatches"
| "addContextObjectsAndFit"
| "removeContextObject"
| "removeContextObjects"
| "generateTerrain"
| "patchContextObject"
| "commitTransformOn"
+14 -2
View File
@@ -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");
});
});
+2
View File
@@ -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 };
+1 -1
View File
@@ -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;
+2 -3
View File
@@ -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
-4
View File
@@ -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,
+1 -75
View File
@@ -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;
+1 -1
View File
@@ -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,