diff --git a/TODO.md b/TODO.md index 5b360e2a..3a55632f 100644 --- a/TODO.md +++ b/TODO.md @@ -1705,7 +1705,13 @@ Reihenfolge = Abhängigkeiten. Neue Geometrie entsteht in Rust ([K]). - ○ **[42] Varianten.** · L - ✅ **[63] Baulinien, Grenzabstände, zulässige Hülle.** (27.10.) Parzelle/Baulinien aus Auswahl, Grenzabstand pauschal und je Kante, Gesamthöhe; zulässige Fläche und Verstösse im Grundriss. - Offen: Vorsprünge (Dachüberstand, Balkone), Hülle im 3D. + 5.11.: Vorsprünge — `SiteRules.projectionDepth` (Tiefe in Abstand/über Baulinie) und `projectionShare` (Anteil + der Fassadenlänge je Grenze/Baulinie); geprüft werden Dach-Traufumrisse (nur Tiefe) und als Vorsprung markierte + Decken/Körper (`siteProjection`, im Lage-Panel an der Auswahl; Tiefe + Anteil); ohne Tiefe wie bisher + (`site_rules.rs`, Tests). Zulässige Hülle im 3D (`show3d`, Lage-Panel „Hülle im 3D"): zulässige Fläche vom + massgebenden Terrain bis zur Gesamthöhe durchscheinend, Verstösse rot (`envelope3d` → render3d `set_ghost`, + Alpha-Pipeline). Offen: Hülle im 3D nur im Linux-Container gebaut, nicht angesehen (WebGPU/macOS); Höhenkurven/ + Gebäudeprofil (Winkel) fehlen im Modell; Wände eines Erkers nicht markierbar; Anteil grob über Ausdehnung längs der Grenze. - ◐ **[64]+[59] Sonnenstand und Schatten.** (27.10.) Schatten im Grundriss mit Zeitregler (Lage-Panel), auch in CLI/PDF. Offen: Schatten im 3D. - ○ **[88] Nur-Lese-Link fürs Web.** · M diff --git a/src/analysis/siteRules.ts b/src/analysis/siteRules.ts index 9b605804..b317f3e6 100644 --- a/src/analysis/siteRules.ts +++ b/src/analysis/siteRules.ts @@ -4,8 +4,11 @@ // • Grenzabstand: gesperrt ist alles, was näher als d_i an Kante i liegt (Puffer der Kante mit // gerundeten Enden) — so stimmen auch konkave Parzellen und einspringende Ecken. // • Baulinie: Halbebene auf der Seite des Parzellen-Schwerpunkts. -// • Gebäude-Grundfläche: Wände aller Geschosse und freie Körper (ohne Abzugskörper). Vorsprünge -// (Dachüberstand, Balkone) und ihre Sonderregeln zählen nicht. +// • Gebäude-Grundfläche: Wände aller Geschosse und freie Körper (ohne Abzugskörper). +// • Vorsprünge (nur mit `projectionDepth`): Dachüberstände und als Vorsprung markierte Decken/Körper +// (`siteProjection`) dürfen bis zur Tiefe in den Abstand ragen, markierte zusätzlich höchstens +// auf `projectionShare` der Fassadenlänge je Grenze. +// • Zulässige Hülle im 3D (`siteEnvelope3d`, mit `show3d`): durchscheinend in render3d. // Gerechnet wird im Rust-Kern (`src-tauri/core/src/site_rules.rs`), die Prüfung des Modells auf dem // Projekt-Dokument; die Flächen-Hilfen (`allowedArea`, `multiPolygonArea`) nehmen flache Daten. @@ -70,3 +73,12 @@ export function checkSiteRules(project: Project): SiteCheck | null { if (!project.siteRules) return null; return documentFor(project).query("siteCheck"); } + +/** + * Zulässige Hülle im 3D ([63], Kern `site_rules::envelope3d`) für render3d `set_ghost`: + * `[nDreieckWerte, Dreiecke (x y z r g b a)…, Kanten (x y z r g b)…]`; leer ohne Baurecht oder `show3d`. + */ +export function siteEnvelope3d(project: Project): Float32Array { + if (project.siteRules?.show3d !== true) return new Float32Array(0); + return documentFor(project).siteEnvelope(); +} diff --git a/src/core/document.ts b/src/core/document.ts index 3df3b246..0a007bc1 100644 --- a/src/core/document.ts +++ b/src/core/document.ts @@ -224,6 +224,11 @@ export class ProjectDocument { return this.handle ? core().doc_drawing_line_verts(this.handle, explode) : new Float32Array(0); } + /** Zulässige Hülle im 3D ([63]) für render3d `set_ghost`; leer ohne Baurecht oder `siteRules.show3d`. */ + siteEnvelope(): Float32Array { + return this.handle ? core().doc_site_envelope(this.handle) : new Float32Array(0); + } + /** Ansichtsschraffur auf den Flächen (Wände, Decken, Dächer) für render3d `set_pattern_lines`. */ surfacePatternLines(explode = 0): Float32Array { return this.handle ? core().doc_surface_pattern_lines(this.handle, explode) : new Float32Array(0); diff --git a/src/core/extra.ts b/src/core/extra.ts index ebd4d258..5c556f07 100644 --- a/src/core/extra.ts +++ b/src/core/extra.ts @@ -44,6 +44,7 @@ export type { AreaReport, AreaReportOptions } from "../export/areaReport"; export { sunPosition, shadowPolygons, shadowOfPrism, projectLatLon } from "../analysis/sun"; export type { SunPosition } from "../analysis/sun"; export { checkSiteRules, allowedArea, multiPolygonArea, buildingFootprint, modelTop } from "../analysis/siteRules"; +export { siteEnvelope3d } from "../analysis/siteRules"; export { excavationQuantities, type ExcavationQuantity } from "../analysis/excavation"; export type { SiteCheck } from "../analysis/siteRules"; export { sampleProject } from "../model/sampleProject"; diff --git a/src/i18n/de.ts b/src/i18n/de.ts index eea7a3d7..0550d77e 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -2531,6 +2531,14 @@ export const de = { "siteRules.addLine": "Baulinie aus Auswahl", "siteRules.addLine.hint": "Eine Linie wählen; das Gebäude bleibt auf der Seite der Parzelle.", "siteRules.clearLines": "Alle Baulinien entfernen", + "siteRules.show3d": "Hülle im 3D", + "siteRules.show3d.hint": "Zulässige Hülle (zulässige Fläche bis zur Gesamthöhe) im 3D durchscheinend zeigen, Verstösse rot.", + "siteRules.projectionDepth": "Vorsprünge bis", + "siteRules.projectionDepth.hint": "Dachüberstände und markierte Vorsprünge (Balkone, Erker) dürfen so weit in den Grenzabstand bzw. über die Baulinie ragen. Leer = keine Vorsprungsregel.", + "siteRules.projectionShare": "Vorsprünge max. Anteil Fassade", + "siteRules.projectionShare.hint": "Höchstens dieser Anteil der Fassadenlänge je Grenze darf von markierten Vorsprüngen belegt sein (Dachüberstände zählen nicht). Leer = unbegrenzt.", + "siteRules.markProjection": "Auswahl ist Vorsprung (Balkon, Erker)", + "siteRules.markProjection.hint": "Gewählte Decke oder gewählten Körper als Vorsprung nach der Vorsprungsregel prüfen.", "clash.none": "Keine Kollisionen gefunden.", "clash.run": "Prüfung starten", "clash.running": "Prüfung läuft …", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index 4d40bce2..418a8540 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -2481,6 +2481,14 @@ export const en: Record = { "siteRules.addLine": "Building line from selection", "siteRules.addLine.hint": "Select a line; the building stays on the parcel side.", "siteRules.clearLines": "Remove all building lines", + "siteRules.show3d": "Envelope in 3D", + "siteRules.show3d.hint": "Show the permissible envelope (permissible area up to the total height) translucent in 3D, violations in red.", + "siteRules.projectionDepth": "Projections up to", + "siteRules.projectionDepth.hint": "Roof overhangs and marked projections (balconies, bay windows) may extend this far into the setback or beyond the building line. Empty = no projection rule.", + "siteRules.projectionShare": "Projections max. share of façade", + "siteRules.projectionShare.hint": "At most this share of the façade length per boundary may be taken by marked projections (roof overhangs do not count). Empty = unlimited.", + "siteRules.markProjection": "Selection is a projection (balcony, bay window)", + "siteRules.markProjection.hint": "Check the selected slab or solid as a projection under the projection rule.", "clash.run": "Run check", "clash.running": "Checking …", "clash.clear": "Clear", diff --git a/src/panels/SiteRulesSection.tsx b/src/panels/SiteRulesSection.tsx index 9d0dc53d..0bb411a2 100644 --- a/src/panels/SiteRulesSection.tsx +++ b/src/panels/SiteRulesSection.tsx @@ -5,7 +5,7 @@ import { t } from "../i18n"; import { usePanelHost } from "./host"; import { useStore } from "../state/appStore"; -import { checkSiteRules, setField } from "../core"; +import { checkSiteRules, patchItem, setField } from "../core"; import type { Project, SiteRules } from "../model/types"; import { lineFromDrawing, parcelFromDrawing } from "./siteRulesInput"; @@ -18,6 +18,28 @@ function parseLen(text: string): number | undefined | null { return Number.isFinite(v) && v >= 0 ? v : null; } +/** Gewählte Decke/Körper, der als Vorsprung markiert werden kann, samt aktuellem Stand. */ +function projectionTarget( + p: Project, + sel: { kind: string; id: string } | null | undefined, +): { kind: "ceiling" | "extrudedSolid"; id: string; flag: boolean } | null { + if (sel?.kind === "ceiling") { + const c = p.ceilings?.find((x) => x.id === sel.id); + return c ? { kind: "ceiling", id: c.id, flag: c.siteProjection === true } : null; + } + if (sel?.kind === "extrudedSolid") { + const x = p.extrudedSolids?.find((e) => e.id === sel.id); + return x && x.operation !== "subtract" ? { kind: "extrudedSolid", id: x.id, flag: x.siteProjection === true } : null; + } + return null; +} + +/** Vorsprung-Markierung setzen (true) oder entfernen (Feld fehlt = normales Bauteil). */ +function withProjection(e: T, on: boolean): T { + const { siteProjection: _old, ...rest } = e; + return (on ? { ...rest, siteProjection: true } : rest) as T; +} + export function SiteRulesSection() { const host = usePanelHost(); const applyChange = useStore((s) => s.applyChange); @@ -26,6 +48,8 @@ export function SiteRulesSection() { const selDrawing = sel?.kind === "drawing2d" ? host.project.drawings2d.find((d) => d.id === sel.id) : undefined; const selParcel = parcelFromDrawing(selDrawing); const selLine = lineFromDrawing(selDrawing); + // Vorsprung markieren: gewählte Decke (Balkon) oder freier Körper (Erker). + const selProjection = projectionTarget(host.project, sel); const write = (fn: (r: SiteRules) => SiteRules | undefined, key?: string) => applyChange((p: Project) => { @@ -71,6 +95,14 @@ export function SiteRulesSection() { /> {t("siteRules.show")} + {check && ( @@ -131,6 +163,67 @@ export function SiteRulesSection() { m + + {rules.projectionDepth !== undefined && ( + + )} + {rules.projectionDepth !== undefined && selProjection && ( + + )} +
{t("siteRules.edges", { n })} {rules.parcel.map((p, i) => { diff --git a/src/viewport/useWasm3dRenderer.ts b/src/viewport/useWasm3dRenderer.ts index 66ff6214..cf8469b1 100644 --- a/src/viewport/useWasm3dRenderer.ts +++ b/src/viewport/useWasm3dRenderer.ts @@ -18,7 +18,7 @@ import { useCallback, useEffect, useRef, useState } from "react"; import type { ContextImage, Project } from "../model/types"; -import { emitDrawingLineVerts, emitSurfacePatternLines, projectToModel3d } from "../core"; +import { emitDrawingLineVerts, emitSurfacePatternLines, projectToModel3d, siteEnvelope3d } from "../core"; import type { DetailLevel } from "../model/viewTypes"; import { loadEngine3d } from "../engine/engine3d"; import { decodeMaterialTextures } from "./materialTextures"; @@ -96,6 +96,8 @@ interface WebModelRendererLike { set_drawing_lines?(vertices: Float32Array): void; /** Ansichtsschraffur auf den Flächen (`web::set_pattern_lines`), in den Kanten-Stilen gezeichnet. */ set_pattern_lines?(data: Float32Array): void; + /** Durchscheinende Körper ([63] zulässige Hülle, `web::set_ghost`): Format von `siteEnvelope3d`; leer löscht. */ + set_ghost?(data: Float32Array): void; /** Material-Farbkarten (Stil „textured") als Textur-Array hochladen * (`web::set_material_textures`). `rgba` = gepackte RGBA8-Bytes von * `layerCount` 256×256-Ebenen; Ebene 0 bleibt intern das Fallback-Schachbrett, @@ -251,6 +253,13 @@ export function useWasm3dRenderer( console.warn("render3d set_drawing_lines fehlgeschlagen:", e); } } + if (typeof r.set_ghost === "function") { + try { + r.set_ghost(siteEnvelope3d(project)); + } catch (e) { + console.warn("render3d set_ghost fehlgeschlagen:", e); + } + } if (typeof r.set_pattern_lines === "function") { try { r.set_pattern_lines(emitSurfacePatternLines(project, explode));