diff --git a/src/analysis/clash.ts b/src/analysis/clash.ts index d5f71175..09c5aa48 100644 --- a/src/analysis/clash.ts +++ b/src/analysis/clash.ts @@ -10,7 +10,7 @@ import type { Drawing2D, Project, Vec2 } from "../model/types"; import { getFloor } from "../model/types"; import { projectToModel3d } from "../plan/toWalls3d"; import { extrudedSolidSpec } from "../plan/extrudedSolidSpec"; -import { wallSpec } from "../export/exportStep"; +import { wallSpec } from "../plan/wallSpec"; import { solidClash, solidProps } from "../engine/truckSolid"; import type { SolidSpec } from "../engine/truckSolid"; @@ -56,6 +56,7 @@ export function clashItems(project: Project): ClashItem[] { }); } for (const solid of project.extrudedSolids ?? []) { + if (solid.operation === "subtract") continue; // Abzugskörper sind gewollte Durchdringungen let baseZ = 0; try { baseZ = solid.levelId ? (getFloor(project, solid.levelId).baseElevation ?? 0) : 0; diff --git a/src/commands/cmds/voidbox.test.ts b/src/commands/cmds/voidbox.test.ts new file mode 100644 index 00000000..41517a7d --- /dev/null +++ b/src/commands/cmds/voidbox.test.ts @@ -0,0 +1,26 @@ +import { describe, expect, it } from "vitest"; +import { sampleProject } from "../../model/sampleProject"; +import type { CommandContext } from "../types"; +import { voidBoxCommand, voidFromInputs } from "./voidbox"; + +const ctx = { project: sampleProject, level: { id: "eg" } } as unknown as CommandContext; + +describe("Durchbruch", () => { + it("legt einen Abzugskoerper mit Hoehe und Abstand an", () => { + let st = voidBoxCommand.init(); + [st] = voidBoxCommand.onInput(st, { kind: "point", point: { x: 1, y: 1 } }, ctx); + [st] = voidBoxCommand.onInput(st, { kind: "point", point: { x: 1.4, y: 2 } }, ctx); + [st] = voidBoxCommand.onInput(st, { kind: "number", value: 0.3 }, ctx); + const [, res] = voidBoxCommand.onInput(st, { kind: "number", value: 1.2 }, ctx); + const p = res.commit!(sampleProject); + const v = p.extrudedSolids!.at(-1)!; + expect(v.operation).toBe("subtract"); + expect(v.height).toBe(0.3); + expect(v.baseOffset).toBe(1.2); + expect(v.points).toHaveLength(4); + }); + it("entartete Eingaben ergeben nichts", () => { + expect(voidFromInputs("eg", { x: 0, y: 0 }, { x: 0, y: 1 }, 1, 0)).toBeNull(); + expect(voidFromInputs("eg", { x: 0, y: 0 }, { x: 1, y: 1 }, 0, 0)).toBeNull(); + }); +}); diff --git a/src/commands/cmds/voidbox.ts b/src/commands/cmds/voidbox.ts new file mode 100644 index 00000000..c243c9f3 --- /dev/null +++ b/src/commands/cmds/voidbox.ts @@ -0,0 +1,136 @@ +// Durchbruch — legt einen quaderförmigen Abzugskörper an (`ExtrudedSolid.operation = +// "subtract"`, s. `plan/voids.ts`): er zieht sich von allen Wänden, Decken und Stützen ab, die er +// durchdringt (Grundriss, Schnitt, 3D, STEP). Für Leitungsdurchbrüche, Nischen, Schlitze. +// +// Schritte: Ecke → Gegenecke → Höhe → Abstand über Geschoss-UK (Zahl tippen; Enter = 0). +// Beliebige Profile: Polylinie extrudieren und im Objekt-Panel „Abzugskörper" setzen. + +import type { ExtrudedSolid } from "../../model/types"; +import { uniqueId } from "../../tools/types"; +import type { Command, CommandResult, CommandState, Project, ToolDraft, Vec2 } from "../types"; + +type Step = "corner" | "corner2" | "height" | "offset"; + +interface VoidState extends CommandState { + step: Step; + p0: Vec2 | null; + p1: Vec2 | null; + height: number | null; + cursor: Vec2 | null; +} + +/** Letzte Werte (Enter übernimmt sie beim nächsten Mal). */ +let lastHeight = 0.3; +let lastOffset = 1.0; + +const rectPts = (a: Vec2, b: Vec2): Vec2[] => { + const [x0, x1] = [Math.min(a.x, b.x), Math.max(a.x, b.x)]; + const [y0, y1] = [Math.min(a.y, b.y), Math.max(a.y, b.y)]; + return [{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x1, y: y1 }, { x: x0, y: y1 }]; +}; + +/** Abzugskörper aus den Eingaben (reiner Kern, getestet). */ +export function voidFromInputs(levelId: string, a: Vec2, b: Vec2, height: number, offset: number): ExtrudedSolid | null { + if (Math.abs(b.x - a.x) < 1e-6 || Math.abs(b.y - a.y) < 1e-6 || !(height > 1e-6)) return null; + return { + id: uniqueId("void"), + type: "extrudedSolid", + levelId, + points: rectPts(a, b), + height, + operation: "subtract", + ...(Math.abs(offset) > 1e-9 ? { baseOffset: offset } : {}), + }; +} + +function draftOf(s: VoidState): ToolDraft | null { + if (!s.p0) return null; + const b = s.p1 ?? s.cursor ?? s.p0; + const pts = rectPts(s.p0, b); + return { + preview: [ + { kind: "poly", pts, closed: true }, + { kind: "line", a: pts[0], b: pts[2] }, + { kind: "line", a: pts[1], b: pts[3] }, + ], + vertices: [s.p0], + hud: { + at: b, + text: + s.step === "corner2" + ? `${Math.abs(b.x - s.p0.x).toFixed(2)} × ${Math.abs(b.y - s.p0.y).toFixed(2)} m` + : s.step === "height" + ? `h = ${lastHeight.toFixed(2)} m (Enter)` + : `UK + ${lastOffset.toFixed(2)} m (Enter)`, + }, + }; +} + +const reset = (): VoidState => ({ phase: "void", step: "corner", p0: null, p1: null, height: null, cursor: null, lastPoint: null }); + +const PROMPT: Record = { + corner: "cmd.void.corner", + corner2: "cmd.void.corner2", + height: "cmd.void.height", + offset: "cmd.void.offset", +}; + +function finish(s: VoidState, offset: number, levelId: string): [CommandState, CommandResult] { + lastOffset = offset; + const solid = s.p0 && s.p1 && s.height ? voidFromInputs(levelId, s.p0, s.p1, s.height, offset) : null; + return [ + reset(), + { + draft: null, + done: true, + commit: (p: Project) => (solid ? { ...p, extrudedSolids: [...(p.extrudedSolids ?? []), solid] } : p), + }, + ]; +} + +export const voidBoxCommand: Command = { + name: "voidbox", + labelKey: "cmd.void.label", + floorOnly: true, + prompt: (st) => PROMPT[(st as VoidState).step] as never, + accepts: (st) => ((st as VoidState).step === "height" || (st as VoidState).step === "offset" ? ["number"] : ["point"]), + options: () => [], + init: (): VoidState => reset(), + + onInput: (state, input, ctx): [CommandState, CommandResult] => { + const s = state as VoidState; + if (s.step === "corner" && input.kind === "point") { + const ns: VoidState = { ...s, step: "corner2", p0: input.point, cursor: input.point, lastPoint: input.point }; + return [ns, { draft: draftOf(ns) }]; + } + if (s.step === "corner2" && input.kind === "point") { + const ns: VoidState = { ...s, step: "height", p1: input.point }; + return [ns, { draft: draftOf(ns) }]; + } + if (s.step === "height" && input.kind === "number" && input.value > 0) { + lastHeight = input.value; + const ns: VoidState = { ...s, step: "offset", height: input.value }; + return [ns, { draft: draftOf(ns) }]; + } + if (s.step === "offset" && input.kind === "number") return finish(s, input.value, ctx.level.id); + return [s, { draft: draftOf(s) }]; + }, + + onMove: (state, point): [CommandState, CommandResult] => { + const s = state as VoidState; + const ns: VoidState = { ...s, cursor: point }; + return [ns, { draft: draftOf(ns) }]; + }, + + // Enter übernimmt die letzten Werte (Höhe bzw. Abstand). + onConfirm: (state, ctx): [CommandState, CommandResult] => { + const s = state as VoidState; + if (s.step === "height") { + const ns: VoidState = { ...s, step: "offset", height: lastHeight }; + return [ns, { draft: draftOf(ns) }]; + } + if (s.step === "offset") return finish(s, lastOffset, ctx.level.id); + return [reset(), { draft: null, done: true }]; + }, + onCancel: (): [CommandState, CommandResult] => [reset(), { draft: null, done: true }], +}; diff --git a/src/commands/registry.ts b/src/commands/registry.ts index 756b7fbb..065f05f2 100644 --- a/src/commands/registry.ts +++ b/src/commands/registry.ts @@ -16,6 +16,7 @@ import { columnCommand } from "./cmds/column"; import { roofCommand } from "./cmds/roof"; import { solidCommand } from "./cmds/solid"; import { solidBoolCommand } from "./cmds/solidbool"; +import { voidBoxCommand } from "./cmds/voidbox"; import { ceilingOpeningCommand } from "./cmds/ceilingOpening"; import { roomCommand } from "./cmds/room"; import { rectCommand } from "./cmds/rect"; @@ -73,6 +74,7 @@ export const COMMANDS: Record = { roof: roofCommand, solid: solidCommand, solidbool: solidBoolCommand, + voidbox: voidBoxCommand, ceilingopening: ceilingOpeningCommand, room: roomCommand, line: lineCommand, @@ -144,6 +146,9 @@ export const ALIASES: Record = { stütze: "column", dach: "roof", koerper: "solid", + durchbruch: "voidbox", + nische: "voidbox", + void: "voidbox", koerperbool: "solidbool", verschneiden: "solidbool", bool: "solidbool", diff --git a/src/export/exportStep.test.ts b/src/export/exportStep.test.ts index 04423b93..8eba82ce 100644 --- a/src/export/exportStep.test.ts +++ b/src/export/exportStep.test.ts @@ -50,4 +50,27 @@ describe("STEP-Export Ende-zu-Ende (truck-WASM)", () => { expect(back.length).toBeGreaterThan(5); expect(back.every((m) => m.indices.length >= 12)).toBe(true); }, 60_000); + + it("Abzugskörper: Wandschichten werden boolesch geschnitten (Volumen kleiner), STEP bleibt gültig", async () => { + const mod: any = await import("../engine/pkgTruck/trucksolid.js"); + await mod.default({ module_or_path: readFileSync("src/engine/pkgTruck/trucksolid_bg.wasm") }); + const w = sampleProject.walls[0]; + const mx = (w.start.x + w.end.x) / 2; + const my = (w.start.y + w.end.y) / 2; + const p = { + ...sampleProject, + extrudedSolids: [{ + id: "v", type: "extrudedSolid" as const, levelId: w.floorId, operation: "subtract" as const, height: 0.8, baseOffset: 0.5, + points: [{ x: mx - 0.3, y: my - 1 }, { x: mx + 0.3, y: my - 1 }, { x: mx + 0.3, y: my + 1 }, { x: mx - 0.3, y: my + 1 }], + }], + }; + const specs = projectSolidSpecs(p); + const bools = specs.filter((s) => s.kind === "boolean"); + expect(bools.length).toBeGreaterThan(0); + const vol = (spec: unknown) => JSON.parse(mod.solid_props(JSON.stringify({ spec }))).volume as number; + const b0 = bools[0] as { a: unknown }; + expect(vol(bools[0])).toBeLessThan(vol(b0.a) - 1e-4); + const step: string = mod.export_step(JSON.stringify({ solids: bools, fileName: "void.stp" })); + expect(step.startsWith("ISO-10303-21;")).toBe(true); + }, 60_000); }); diff --git a/src/export/exportStep.ts b/src/export/exportStep.ts index 3bfb4657..a9a0cb87 100644 --- a/src/export/exportStep.ts +++ b/src/export/exportStep.ts @@ -16,103 +16,53 @@ import type { Project } from "../model/types"; import { getFloor, roofLayers } from "../model/types"; import { projectToModel3d } from "../plan/toWalls3d"; -import type { RWall } from "../plan/toWalls3d"; import { roofBaseElevation, roofGeometry } from "../geometry/roof"; import { exportStepSolids } from "../engine/truckSolid"; import { extrudedSolidSpec } from "../plan/extrudedSolidSpec"; import type { SolidSpec } from "../engine/truckSolid"; +import { wallSpec } from "../plan/wallSpec"; +import { bbox, hittingVoids, subtractSpec, voidPrisms, wallCorners } from "../plan/voids"; +import type { Box2 } from "../plan/voids"; + +export { wallProfile, wallSpec } from "../plan/wallSpec"; const EPS = 1e-6; /** Schicht/Öffnung so dünn, dass sie als nicht vorhanden gilt. */ const MIN_THICKNESS = 1e-4; /** - * Wandprofil (u = Achse, v = Höhe über Wandfuss) mit Öffnungen: Löcher, die ganz im Profil - * liegen; Öffnungen am Wandfuss (Türen) als Kerben im Aussenring. Öffnungen am Wandkopf - * werden um 1 mm gekappt (ein Loch darf den Rand nicht berühren). + * Boolean-Spezifikation (Bauteil − Abzugskörper) → dieselbe ohne Abzug. Scheitert truck am + * Boolean, exportiert `exportProjectStep` das Bauteil wenigstens ungeschnitten. */ -export function wallProfile( - length: number, - height: number, - holes: Array<{ from: number; to: number; zBottom: number; zTop: number }>, - baseElevation: number, -): { outer: number[]; holes: number[][] } { - const inner: number[][] = []; - const notches: Array<[number, number, number]> = []; // [from, to, top] - const cut = 1e-3; - for (const h of holes) { - const u0 = Math.max(0, Math.min(length, h.from)); - const u1 = Math.max(0, Math.min(length, h.to)); - if (u1 - u0 < MIN_THICKNESS) continue; - const v0 = h.zBottom - baseElevation; - const v1 = Math.min(height - cut, h.zTop - baseElevation); - if (v1 - Math.max(v0, 0) < MIN_THICKNESS) continue; - if (v0 <= cut) notches.push([u0, u1, v1]); - else inner.push([u0, v0, u1, v0, u1, v1, u0, v1]); - } - // Kerben sortieren und überlappende zusammenfassen. - notches.sort((a, b) => a[0] - b[0]); - const merged: Array<[number, number, number]> = []; - for (const n of notches) { - const last = merged[merged.length - 1]; - if (last && n[0] <= last[1] + EPS) { - last[1] = Math.max(last[1], n[1]); - last[2] = Math.max(last[2], n[2]); - } else merged.push([...n]); - } - // Aussenring CCW in (u,v): Wandfuss links→rechts mit Kerben, dann Kopf rechts→links. - const outer: number[] = [0, 0]; - for (const [a, b, top] of merged) { - outer.push(a, 0, a, top, b, top, b, 0); - } - outer.push(length, 0, length, height, 0, height); - return { outer, holes: inner }; -} - -export function wallSpec(w: RWall): SolidSpec | null { - const dx = w.end[0] - w.start[0]; - const dy = w.end[1] - w.start[1]; - const len = Math.hypot(dx, dy); - if (len < MIN_THICKNESS || w.height < MIN_THICKNESS || w.thickness < MIN_THICKNESS) return null; - const ux = dx / len; - const uy = dy / len; - // u × v (v = +Z) = (uy, −ux, 0): Extrusionsrichtung. Ursprung = eine Wandfläche. - const nx = uy; - const ny = -ux; - const prof = wallProfile(len, w.height, w.holes ?? [], w.baseElevation); - return { - kind: "extrudePlane", - points: prof.outer, - holes: prof.holes, - origin: [ - w.start[0] - (nx * w.thickness) / 2, - w.start[1] - (ny * w.thickness) / 2, - w.baseElevation, - ], - uAxis: [ux, uy, 0], - vAxis: [0, 0, 1], - depth: w.thickness, - }; -} +const VOID_FALLBACK = new WeakMap(); /** Alle Bauteile des Projekts als B-Rep-Spezifikationen (reiner Kern, kein WASM). */ export function projectSolidSpecs(project: Project): SolidSpec[] { const out: SolidSpec[] = []; const model = projectToModel3d(project, { layeredWalls: true }); + const voids = voidPrisms(project); + const withVoids = (base: SolidSpec, foot: Box2, z0: number, z1: number): SolidSpec => { + const hits = hittingVoids(voids, foot, z0, z1); + if (hits.length === 0) return base; + const spec = subtractSpec(base, hits); + VOID_FALLBACK.set(spec, base); + return spec; + }; for (const w of model.walls) { const s = wallSpec(w); - if (s) out.push(s); + if (s) out.push(withVoids(s, bbox(wallCorners(w)), w.baseElevation, w.baseElevation + w.height)); } for (const s of model.slabs) { if (s.outline.length < 3 || s.zTop - s.zBottom < MIN_THICKNESS) continue; - out.push({ + const base: SolidSpec = { kind: "extrude", points: s.outline.flatMap((p) => [p[0], p[1]]), height: s.zTop - s.zBottom, z0: s.zBottom, - }); + }; + out.push(withVoids(base, bbox(s.outline.map((p) => ({ x: p[0], y: p[1] }))), s.zBottom, s.zTop)); } for (const roof of project.roofs ?? []) { @@ -148,6 +98,7 @@ export function projectSolidSpecs(project: Project): SolidSpec[] { } for (const solid of project.extrudedSolids ?? []) { + if (solid.operation === "subtract") continue; // Abzugskörper sind kein Material let baseZ = 0; if (solid.levelId) { try { @@ -200,6 +151,17 @@ export async function exportProjectStep(project: Project, fileName = ""): Promis await exportStepSolids([specs[i]], ""); good.push(specs[i]); } catch (e) { + const fallback = VOID_FALLBACK.get(specs[i]); + if (fallback) { + try { + await exportStepSolids([fallback], ""); + good.push(fallback); + skipped.push({ index: i, error: "Abzugskörper nicht abziehbar — Bauteil ungeschnitten exportiert" }); + continue; + } catch { + /* unten melden */ + } + } skipped.push({ index: i, error: e instanceof Error ? e.message : String(e) }); } } diff --git a/src/i18n/de.ts b/src/i18n/de.ts index 67253491..b59eb6f7 100644 --- a/src/i18n/de.ts +++ b/src/i18n/de.ts @@ -712,6 +712,9 @@ export const de = { "objinfo.extrudedSolid.cornerRadius": "Eckenradius", "objinfo.extrudedSolid.chamfer": "Fase", "objinfo.extrudedSolid.brep": "B-Rep-Körper", + "objinfo.extrudedSolid.baseOffset": "Abstand über Geschoss-UK", + "objinfo.extrudedSolid.subtract": "Abzugskörper", + "objinfo.extrudedSolid.subtractHint": "Zieht den Körper von Wänden, Decken und Stützen ab (Aussparung/Durchbruch)", "objinfo.extrudedSolid.volume": "Volumen", "objinfo.extrudedSolid.surface": "Oberfläche", "objinfo.extrudedSolid.centroid": "Schwerpunkt", @@ -1281,6 +1284,11 @@ export const de = { "cmd.solidbool.op.union": "Vereinigung", "cmd.solidbool.op.difference": "Differenz", "cmd.solidbool.op.intersection": "Durchschnitt", + "cmd.void.label": "Durchbruch", + "cmd.void.corner": "Erste Ecke des Durchbruchs:", + "cmd.void.corner2": "Gegenecke:", + "cmd.void.height": "Höhe (Enter = letzte):", + "cmd.void.offset": "Abstand über Geschoss-UK (Enter = letzter):", "cmd.solid.label": "Körper", "cmd.solid.center": "Mittelpunkt bzw. erste Ecke:", "cmd.solid.radius": "Radius:", diff --git a/src/i18n/en.ts b/src/i18n/en.ts index e55abc36..d5267c68 100644 --- a/src/i18n/en.ts +++ b/src/i18n/en.ts @@ -708,6 +708,9 @@ export const en: Record = { "objinfo.extrudedSolid.cornerRadius": "Corner radius", "objinfo.extrudedSolid.chamfer": "Chamfer", "objinfo.extrudedSolid.brep": "B-rep solid", + "objinfo.extrudedSolid.baseOffset": "Offset above storey base", + "objinfo.extrudedSolid.subtract": "Subtraction body", + "objinfo.extrudedSolid.subtractHint": "Subtracts the body from walls, slabs and columns (recess/penetration)", "objinfo.extrudedSolid.volume": "Volume", "objinfo.extrudedSolid.surface": "Surface", "objinfo.extrudedSolid.centroid": "Centroid", @@ -1270,6 +1273,11 @@ export const en: Record = { "cmd.solidbool.op.union": "Union", "cmd.solidbool.op.difference": "Difference", "cmd.solidbool.op.intersection": "Intersection", + "cmd.void.label": "Penetration", + "cmd.void.corner": "First corner of the penetration:", + "cmd.void.corner2": "Opposite corner:", + "cmd.void.height": "Height (Enter = last):", + "cmd.void.offset": "Offset above storey base (Enter = last):", "cmd.solid.label": "Solid", "cmd.solid.center": "Center or first corner:", "cmd.solid.radius": "Radius:", diff --git a/src/model/types.ts b/src/model/types.ts index bd6b5dc5..22b0845f 100644 --- a/src/model/types.ts +++ b/src/model/types.ts @@ -2204,6 +2204,15 @@ export interface ExtrudedSolid { points: Vec2[]; /** Extrusionshöhe in Metern (> 0), nach +Z ab der Geschoss-UK. */ height: number; + /** Abstand der Körper-UK über der Geschoss-UK (Meter, Default 0). */ + baseOffset?: number; + /** + * Boolesche Rolle im Gebäude: "subtract" = Abzugskörper (Aussparung/Durchbruch/Nische). + * Er zieht sich von allen Wänden, Decken und Stützen ab, die er durchdringt — in 3D + * (truck-Boolean), im Grundriss und im Schnitt; selbst wird er nur als Umriss gezeigt. + * Fehlt = normaler Körper. + */ + operation?: "subtract"; /** * Gesetzt, wenn das Profil ein Kreis ist (aus einem `Drawing2D` mit * `shape:"circle"`) — `points` bleibt die Tessellierung, `toWalls3d.ts` diff --git a/src/panels/ObjectInfoPanel.tsx b/src/panels/ObjectInfoPanel.tsx index e70a73ba..08fe6d61 100644 --- a/src/panels/ObjectInfoPanel.tsx +++ b/src/panels/ObjectInfoPanel.tsx @@ -712,6 +712,35 @@ export function ExtrudedSolidSection({ + {/* Abstand über Geschoss-UK (Brüstungs-/Durchbruchshöhe). */} +
+ {t("objinfo.extrudedSolid.baseOffset")} + { + const v = Number(e.target.value); + if (Number.isFinite(v)) host.onSetExtrudedSolidBaseOffset(v); + }} + title={t("objinfo.extrudedSolid.baseOffset")} + /> +
+ + {/* Abzugskörper: zieht sich von Wänden/Decken/Stützen ab (Grundriss, Schnitt, 3D, STEP). */} + {solid.canSubtract && ( +
+ {t("objinfo.extrudedSolid.subtract")} + host.onSetExtrudedSolidSubtract(e.target.checked)} + title={t("objinfo.extrudedSolid.subtractHint")} + /> +
+ )} + {solid.brepLabel && (
{t("objinfo.extrudedSolid.brep")} diff --git a/src/panels/host.ts b/src/panels/host.ts index 0ba1ecbe..d19ece2e 100644 --- a/src/panels/host.ts +++ b/src/panels/host.ts @@ -536,6 +536,10 @@ export interface PanelHostValue { onSetExtrudedSolidCornerRadius: (radius: number) => void; /** Setzt die Fase der Aussenkontur (Meter, ≥ 0). */ onSetExtrudedSolidChamfer: (chamfer: number) => void; + /** Abzugskörper ein/aus (zieht sich von Wänden/Decken/Stützen ab). */ + onSetExtrudedSolidSubtract: (subtract: boolean) => void; + /** Abstand der Körper-UK über der Geschoss-UK (Meter). */ + onSetExtrudedSolidBaseOffset: (offset: number) => void; // ── Stützen-Attribute (Tragwerk; nur die selektierte Stütze) ──────────── /** Wechselt das Profil (Rechteck/Kreis); leitet ein sinnvolles Mass ab. */ diff --git a/src/plan/extrudedSolidSpec.ts b/src/plan/extrudedSolidSpec.ts index 54c66e37..8e749fc4 100644 --- a/src/plan/extrudedSolidSpec.ts +++ b/src/plan/extrudedSolidSpec.ts @@ -20,7 +20,8 @@ export function needsBrepPath(solid: ExtrudedSolid): boolean { * B-Rep-Spezifikation des Körpers, UK auf `baseZ`. `null`, wenn truck dafür (noch) keine * Beschreibung hat (Pyramide: Spitze als B-Rep entartet). */ -export function extrudedSolidSpec(solid: ExtrudedSolid, baseZ: number): SolidSpec | null { +export function extrudedSolidSpec(solid: ExtrudedSolid, floorZ: number): SolidSpec | null { + const baseZ = floorZ + (solid.baseOffset ?? 0); if (solid.brep) { const p0 = solid.points[0]; const dx = p0 ? p0.x - solid.brep.origin.x : 0; diff --git a/src/plan/generatePlan.ts b/src/plan/generatePlan.ts index 908be1e9..eb2da4a8 100644 --- a/src/plan/generatePlan.ts +++ b/src/plan/generatePlan.ts @@ -70,6 +70,7 @@ import { type Primitive, } from "./generatePlan/shared"; import { addCeilingPoche } from "./generatePlan/ceilings"; +import { subtractVoidsInPlan } from "./voids"; import { addContextContours } from "./generatePlan/context"; import { DEFAULT_SCALE_DENOMINATOR } from "../model/dimension"; import { @@ -662,6 +663,9 @@ export function generatePlan( // Schwarz-Weiss (mono): nachträglich alle Farben auf reine Tinte zwingen. // Element-/Kategorie-/Hatch-Farben werden ignoriert, Füllungen werden weiss, // Musterlinien/Striche schwarz — so entsteht ein reiner S/W-Plan. + // Abzugskörper (Aussparungen/Durchbrüche): von Wand-/Stützen-/Decken-Poché abziehen. + subtractVoidsInPlan(primitives, project, (floor?.baseElevation ?? 0) + (floor?.cutHeight ?? 1.0)); + if (mono) toMono(primitives); // Georeferenzierte Luftbilder als Hintergrund-Ebenen (nur interaktive Ansicht, @@ -925,6 +929,7 @@ export function generateSectionPlan( ceilingId: kind === "slab" && !cp.stairId ? sourceId : undefined, roofId: kind === "roof" ? sourceId : undefined, stairId: cp.stairId, + noStrokeEdges: cp.noStrokeEdges, greyed: cp.categoryCode !== undefined && catDisplay(cp.categoryCode).greyed, }); } diff --git a/src/plan/generatePlan/structures.ts b/src/plan/generatePlan/structures.ts index e0be2b5a..c82436f5 100644 --- a/src/plan/generatePlan/structures.ts +++ b/src/plan/generatePlan/structures.ts @@ -30,6 +30,28 @@ const EXTRUSION_STROKE = "#d98c40"; * keine Schnitt-Poché/Kategorie-Zuordnung hat. */ export function addExtrudedSolidOutline(out: Primitive[], solid: ExtrudedSolid): void { + if (solid.operation === "subtract") { + // Abzugskörper (Aussparung): gestrichelter Umriss + Diagonalkreuz (Durchbruch-Symbol), + // darunter eine unsichtbare Fläche für die Auswahl. + out.push({ + kind: "polygon", + pts: solid.points, + fill: "none", + stroke: "none", + strokeWidthMm: 0, + hatch: NO_HATCH, + extrudedSolidId: solid.id, + }); + const n = solid.points.length; + const seg = (a: (typeof solid.points)[number], b: (typeof solid.points)[number], dash: number[] | null) => + out.push({ kind: "line", a, b, cls: "void", weightMm: SYMBOL_HAIRLINE_MM, dash, color: EXTRUSION_STROKE }); + for (let i = 0; i < n; i++) seg(solid.points[i], solid.points[(i + 1) % n], [2, 1]); + if (n === 4) { + seg(solid.points[0], solid.points[2], null); + seg(solid.points[1], solid.points[3], null); + } + return; + } out.push({ kind: "polygon", pts: solid.points, diff --git a/src/plan/nativeSync.ts b/src/plan/nativeSync.ts index 9217ae0d..7c699e31 100644 --- a/src/plan/nativeSync.ts +++ b/src/plan/nativeSync.ts @@ -87,7 +87,7 @@ export function pushNativeWalls(project: Project): void { clearTimeout(wallsTimer); wallsTimer = setTimeout(async () => { if (!(await isNativeEnabled())) return; - void invokeNative("push_native_walls", { walls: projectToModel3d(project) }); + void invokeNative("push_native_walls", { walls: projectToModel3d(project, { voids: true }) }); }, DEBOUNCE_MS); } diff --git a/src/plan/toSection.ts b/src/plan/toSection.ts index 22b8a4df..b9e6ad29 100644 --- a/src/plan/toSection.ts +++ b/src/plan/toSection.ts @@ -24,6 +24,7 @@ import { dot, leftNormal, normalize, sub } from "../model/geometry"; import { openingInterval, openingVerticalExtent } from "../geometry/opening"; import { roofBaseElevation, roofGeometry } from "../geometry/roof"; import { projectToModel3d } from "./toWalls3d"; +import { subtractVoidsInSection } from "./voids"; import { loadEngine3d } from "../engine/engine3d"; import { HATCH_INK, @@ -50,6 +51,8 @@ export interface SectionCutPolygon { color: [number, number, number]; /** Ring-Ecken (u, v). */ pts: Array<[number, number]>; + /** Nicht gestrichene Kanten (Stege eingehängter Löcher, s. `plan/voids.ts`). */ + noStrokeEdges?: number[]; /** * Echte Poché-Füllfarbe des geschnittenen Bauteils (tragende Wandschicht * bzw. erste Deckenschicht), von `computeSection` aufgelöst. Fehlt, wenn das @@ -1266,6 +1269,13 @@ export async function computeSection( cp.categoryCode = st.categoryCode; } output.cutPolygons = mergeMonolithCuts(output.cutPolygons, (i) => model.slabs[i]?.monolith); + // Abzugskörper (Aussparungen/Durchbrüche) aus den geschnittenen Bauteilen entfernen. + output.cutPolygons = subtractVoidsInSection( + output.cutPolygons, + project, + { x: plane.point[0], y: plane.point[2] }, + sectionUAxisModel(plane), + ); // Schnitt-Tiefe: Kanten weiter als `level.depth` hinter der Ebene ausblenden. if (level.depth !== undefined) filterByDepth(output, project, plane, level.depth); return output; diff --git a/src/plan/toWalls3d.ts b/src/plan/toWalls3d.ts index 3afbf79d..b5519d01 100644 --- a/src/plan/toWalls3d.ts +++ b/src/plan/toWalls3d.ts @@ -68,6 +68,7 @@ import { emitWall } from "./toWalls3d/bands"; import { emitSlabs } from "./toWalls3d/ceilings"; import { emitStairMeshes, emitStairRailings, emitStairs } from "./toWalls3d/stairs"; import { emitExtrudedSolids, TRUCK_MESH_READY_EVENT } from "./toWalls3d/extrusions"; +import { applyVoids3d } from "./toWalls3d/voids3d"; import { emitDrawingLineVerts, pickDrawingSegs } from "./toWalls3d/drawing2d"; import { emitColumns } from "./toWalls3d/columns"; import { emitRoofCutLayers, emitRoofs } from "./toWalls3d/roofs"; @@ -199,13 +200,18 @@ export interface Model3dOptions { detail?: DetailLevel; /** Schnitt-Eingabe: Treppen immer als Tritt-Prismen (s. `emitStairs` `forSection`). */ forSection?: boolean; + /** + * 3D-Viewer: Abzugskörper per truck-Boolean von Wänden/Decken abziehen (s. + * `toWalls3d/voids3d.ts`). Schnitt/Ansicht/Export behandeln Abzugskörper selbst. + */ + voids?: boolean; } /** Das volle 3D-Modell: Wände (mit Öffnungen) + Deckenplatten + Kontext-Meshes. */ export function projectToModel3d(project: Project, opts: Model3dOptions = {}): RModel3d { const layered = opts.layeredWalls ?? true; const detail = opts.detail ?? "fein"; - return { + const model: RModel3d = { walls: projectToWalls3d(project, layered), // Decken + Treppen (Treppentritte als extrudierte Slabs) — so wird die Treppe // auch im WASM/wgpu-Renderer sichtbar (der three.js-Pfad rendert sie separat). @@ -231,6 +237,8 @@ export function projectToModel3d(project: Project, opts: Model3dOptions = {}): R // weil `section.rs` beliebige Dreiecksnetze nicht schneiden kann. roofLayers: emitRoofCutLayers(project), }; + if (opts.voids) applyVoids3d(model, project); + return model; } /** diff --git a/src/plan/toWalls3d/extrusions.ts b/src/plan/toWalls3d/extrusions.ts index 82c20208..8bcbfccf 100644 --- a/src/plan/toWalls3d/extrusions.ts +++ b/src/plan/toWalls3d/extrusions.ts @@ -36,7 +36,7 @@ const truckMeshCache = new Map(); function extrudedSolidSignature(solid: ExtrudedSolid): string { const brep = solid.brep ? `${JSON.stringify(solid.brep.spec)}@${solid.brep.origin.x},${solid.brep.origin.y}` : ""; - return `${solid.height}|${solid.taper ?? 0}|${solid.cornerRadius ?? 0}|${solid.chamfer ?? 0}|${brep}|${solid.points.map((p) => `${p.x},${p.y}`).join(";")}`; + return `${solid.baseOffset ?? 0}|${solid.height}|${solid.taper ?? 0}|${solid.cornerRadius ?? 0}|${solid.chamfer ?? 0}|${brep}|${solid.points.map((p) => `${p.x},${p.y}`).join(";")}`; } export function emitExtrudedSolids(project: Project): RMesh[] { @@ -51,6 +51,8 @@ export function emitExtrudedSolids(project: Project): RMesh[] { } for (const solid of project.extrudedSolids ?? []) { if (solid.points.length < 3 || solid.height <= 0) continue; + // Abzugskörper sind kein Material (sie wirken über `voids3d.ts`). + if (solid.operation === "subtract") continue; const signature = extrudedSolidSignature(solid); let entry = truckMeshCache.get(solid.id); if (!entry || entry.signature !== signature) { @@ -67,11 +69,12 @@ export function emitExtrudedSolids(project: Project): RMesh[] { } catch { // Geschoss nicht (mehr) auflösbar: bei UK 0 extrudieren (Fallback). } + baseZ += solid.baseOffset ?? 0; // Kreis-Profil: echte runde truck-Extrusion (extrudeCircle) statt der // 48-Eck-Tessellierung in `points` — glattes Zylinder-Mesh. const taper = solid.taper ?? 0; // B-Rep-Pfad (Grundkörper, Eckenradius): die Spezifikation trägt die UK (baseZ) selbst. - const brepSpec = needsBrepPath(solid) ? extrudedSolidSpec(solid, baseZ) : null; + const brepSpec = needsBrepPath(solid) ? extrudedSolidSpec(solid, baseZ - (solid.baseOffset ?? 0)) : null; const extrusion = brepSpec ? buildSolidMesh(brepSpec, 0.005) : solid.circle diff --git a/src/plan/toWalls3d/voids3d.ts b/src/plan/toWalls3d/voids3d.ts new file mode 100644 index 00000000..3f167db6 --- /dev/null +++ b/src/plan/toWalls3d/voids3d.ts @@ -0,0 +1,101 @@ +// Abzugskörper im 3D (s. `plan/voids.ts`): jede Wandschicht und Decke, die ein Abzugskörper +// durchdringt, wird über truck als Boolean-Differenz gebaut (B-Rep, bei bündigen Flächen +// automatisch Mesh-CSG) und statt des Prismas als Mesh gezeigt. +// +// Wie die Extrusionen (`extrusions.ts`) asynchron mit modulweitem Cache: solange das Ergebnis +// lädt, bleibt das ungeschnittene Prisma stehen; ist es fertig, feuert +// `TRUCK_MESH_READY_EVENT` und der Viewer pusht das Modell neu. + +import type { Project } from "../../model/types"; +import { buildSolidMesh } from "../../engine/truckSolid"; +import type { SolidSpec } from "../../engine/truckSolid"; +import { wallSpec } from "../wallSpec"; +import { bbox, hittingVoids, subtractSpec, voidPrisms, wallCorners } from "../voids"; +import { TRUCK_MESH_READY_EVENT } from "./extrusions"; +import type { RMesh, RModel3d, RSlab, RVec2, RWall } from "./shared"; + +interface Entry { + signature: string; + /** null = lädt noch; "failed" = Boolean scheiterte (Prisma bleibt). */ + mesh: RMesh | null | "failed"; +} +const cache = new Map(); + +function request(key: string, signature: string, spec: SolidSpec, make: (m: { positions: number[]; indices: number[] }) => RMesh): Entry { + let e = cache.get(key); + if (e && e.signature === signature) return e; + const entry: Entry = { signature, mesh: null }; + cache.set(key, entry); + buildSolidMesh(spec, 0.005) + .then((m) => { + const cur = cache.get(key); + if (cur !== entry) return; + entry.mesh = make(m); + window.dispatchEvent(new Event(TRUCK_MESH_READY_EVENT)); + }) + .catch((err) => { + entry.mesh = "failed"; + console.warn("Abzugskörper-Boolean fehlgeschlagen:", err); + }); + e = entry; + return e; +} + +/** + * Ersetzt in `model` die von Abzugskörpern getroffenen Wandschichten/Decken durch ihre + * Boolean-Meshes (sobald geladen). Ohne `window` (Tests/Node) bleibt das Modell unverändert. + */ +export function applyVoids3d(model: RModel3d, project: Project): void { + if (typeof window === "undefined") return; + const voids = voidPrisms(project); + if (voids.length === 0) return; + const live = new Set(); + + const walls: RWall[] = []; + model.walls.forEach((w, i) => { + const hits = hittingVoids(voids, bbox(wallCorners(w)), w.baseElevation, w.baseElevation + w.height); + const base = hits.length ? wallSpec(w) : null; + if (!base) { + walls.push(w); + return; + } + const key = `w:${w.wallId}:${i}`; + live.add(key); + const spec = subtractSpec(base, hits); + const e = request(key, JSON.stringify(spec), spec, (m) => ({ + positions: m.positions, + indices: m.indices, + kind: "extrusion", + color: w.color, + ...(w.materialIndex !== undefined ? { materialIndex: w.materialIndex } : {}), + })); + if (e.mesh && e.mesh !== "failed") model.meshes.push(e.mesh); + else walls.push(w); + }); + model.walls = walls; + + const slabs: RSlab[] = []; + model.slabs.forEach((s, i) => { + const foot = bbox(s.outline.map((p: RVec2) => ({ x: p[0], y: p[1] }))); + const hits = s.outline.length >= 3 ? hittingVoids(voids, foot, s.zBottom, s.zTop) : []; + if (hits.length === 0) { + slabs.push(s); + return; + } + const key = `s:${s.ceilingId}:${i}`; + live.add(key); + const base: SolidSpec = { kind: "extrude", points: s.outline.flatMap((p) => [p[0], p[1]]), height: s.zTop - s.zBottom, z0: s.zBottom }; + const spec = subtractSpec(base, hits); + const e = request(key, JSON.stringify(spec), spec, (m) => ({ + positions: m.positions, + indices: m.indices, + kind: "extrusion", + color: s.color, + })); + if (e.mesh && e.mesh !== "failed") model.meshes.push(e.mesh); + else slabs.push(s); + }); + model.slabs = slabs; + + for (const k of cache.keys()) if (!live.has(k)) cache.delete(k); +} diff --git a/src/plan/voids.test.ts b/src/plan/voids.test.ts new file mode 100644 index 00000000..557bca69 --- /dev/null +++ b/src/plan/voids.test.ts @@ -0,0 +1,86 @@ +import { describe, expect, it } from "vitest"; +import type { Pair } from "polygon-clipping"; +import { generatePlan } from "./generatePlan"; +import { sampleProject } from "../model/sampleProject"; +import type { ExtrudedSolid, Project } from "../model/types"; +import { keyhole, segmentOutside, subtractRings, subtractVoidsInSection, voidPrisms, voidSectionRects } from "./voids"; + +const sq = (x0: number, y0: number, x1: number, y1: number): Pair[] => [[x0, y0], [x1, y0], [x1, y1], [x0, y1]]; +const area = (r: Pair[]) => Math.abs(r.reduce((s, p, i) => s + p[0] * r[(i + 1) % r.length][1] - r[(i + 1) % r.length][0] * p[1], 0) / 2); + +function withVoid(p: Project, v: Partial): Project { + const solid: ExtrudedSolid = { id: "void1", type: "extrudedSolid", levelId: p.walls[0].floorId, operation: "subtract", height: 2, points: [], ...v }; + return { ...p, extrudedSolids: [...(p.extrudedSolids ?? []), solid] }; +} + +describe("Abzugskoerper — Polygon-Kern", () => { + it("Loch ganz innen: Schluesselloch mit zwei ungestrichenen Stegkanten, Flaeche stimmt", () => { + const r = subtractRings(sq(0, 0, 4, 2), [sq(1, 0.5, 2, 1.5)])!; + expect(r).toHaveLength(1); + expect(area(r[0].pts)).toBeCloseTo(8 - 1, 9); + expect(r[0].noStrokeEdges).toHaveLength(2); + }); + it("Durchbruch quer: zwei Restteile", () => { + const r = subtractRings(sq(0, 0, 4, 0.3), [sq(1, -1, 2, 1)])!; + expect(r).toHaveLength(2); + expect(r.reduce((s, x) => s + area(x.pts), 0)).toBeCloseTo(0.9, 9); + }); + it("ohne Ueberschneidung: null (Original bleibt)", () => { + expect(subtractRings(sq(0, 0, 1, 1), [sq(5, 5, 6, 6)])).toBeNull(); + }); + it("ungestrichene Originalkanten bleiben ungestrichen", () => { + // Kante 1 (rechts, x=4) ungestrichen; der Schnitt links lässt sie unberührt. + const r = subtractRings(sq(0, 0, 4, 2), [sq(-1, -1, 1, 3)], [1])!; + const edges = r[0].noStrokeEdges.map((i) => [r[0].pts[i], r[0].pts[(i + 1) % r[0].pts.length]]); + expect(edges.every(([a, b]) => a[0] === 4 && b[0] === 4)).toBe(true); + }); + it("keyhole haengt mehrere Loecher ein", () => { + const k = keyhole([sq(0, 0, 10, 2), sq(1, 0.5, 2, 1.5).reverse(), sq(5, 0.5, 6, 1.5).reverse()]); + expect(k.bridges).toHaveLength(4); + }); + it("segmentOutside: Linie durch Quadrat in zwei Teile", () => { + const parts = segmentOutside({ x: 0, y: 0.5 }, { x: 4, y: 0.5 }, [sq(1, 0, 2, 1)]); + expect(parts.map(([a, b]) => [a, b])).toEqual([[0, 0.25], [0.5, 1]]); + }); +}); + +describe("Abzugskoerper — Grundriss und Schnitt", () => { + const w = sampleProject.walls[0]; + const mx = (w.start.x + w.end.x) / 2; + const my = (w.start.y + w.end.y) / 2; + const box = [{ x: mx - 0.3, y: my - 1 }, { x: mx + 0.3, y: my - 1 }, { x: mx + 0.3, y: my + 1 }, { x: mx - 0.3, y: my + 1 }]; + const vis = new Set(sampleProject.layers.map((l) => l.code)); + const wallPolys = (p: Project) => generatePlan(p, w.floorId, vis).primitives.filter((q) => q.kind === "polygon" && q.wallId === w.id); + + it("Durchbruch auf Schnitthoehe teilt die Wand-Poché, Umrisslinien enden am Koerper", () => { + const p = withVoid(sampleProject, { points: box }); + const before = wallPolys(sampleProject).length; + expect(wallPolys(p).length).toBeGreaterThan(before); + const lines = generatePlan(p, w.floorId, vis).primitives.filter( + (q) => q.kind === "line" && (q.cls === "wall-outline" || q.cls === "layer-joint"), + ); + for (const l of lines) { + if (l.kind !== "line") continue; + const cx = (l.a.x + l.b.x) / 2; + const cy = (l.a.y + l.b.y) / 2; + const inside = cx > mx - 0.3 + 1e-6 && cx < mx + 0.3 - 1e-6 && cy > my - 1 && cy < my + 1; + expect(inside).toBe(false); + } + }); + it("Koerper ueber der Schnitthoehe aendert den Grundriss nicht", () => { + const p = withVoid(sampleProject, { points: box, baseOffset: 1.5, height: 0.5 }); + expect(wallPolys(p).length).toBe(wallPolys(sampleProject).length); + }); + it("Schnitt: Rechtecke aus Grundflaeche x Hoehenbereich, Abzug aus Cut-Polygonen", () => { + const p = withVoid(sampleProject, { points: box, baseOffset: 0.5, height: 1 }); + const [v] = voidPrisms(p); + const rects = voidSectionRects(v, { x: 0, y: my }, { x: 1, y: 0 }); + expect(rects).toHaveLength(1); + expect(rects[0][0][0]).toBeCloseTo(mx - 0.3, 9); + expect(rects[0][2][1]).toBeCloseTo(v.z1, 9); + const cuts = [{ pts: sq(mx - 2, 0, mx + 2, 2.5) as Array<[number, number]> }]; + const out = subtractVoidsInSection(cuts, p, { x: 0, y: my }, { x: 1, y: 0 }); + expect(out).toHaveLength(1); + expect(area(out[0].pts)).toBeCloseTo(4 * 2.5 - 0.6 * 1, 6); + }); +}); diff --git a/src/plan/voids.ts b/src/plan/voids.ts new file mode 100644 index 00000000..2b8d6b7f --- /dev/null +++ b/src/plan/voids.ts @@ -0,0 +1,421 @@ +// Abzugskörper (`ExtrudedSolid.operation === "subtract"`): Aussparungen, Durchbrüche und +// Nischen, die sich von Wänden, Decken und Stützen abziehen — in ALLEN abgeleiteten +// Ansichten aus demselben Modell: +// +// • Grundriss: Poché-Polygone der getroffenen Bauteile minus Körper-Grundfläche, sofern der +// Körper die Schnitthöhe (Wände/Stützen) bzw. die Platte (Decken) durchdringt. +// • Schnitt: Cut-Polygone minus Körper-Schnitt (Grundfläche ∩ Schnittspur × Höhenbereich). +// • 3D/STEP: Boolean-Differenz (truck, Mesh-CSG-Fallback), s. `toWalls3d/voids3d.ts` +// bzw. `exportStep.ts`. +// +// Abzugskörper sind senkrechte Prismen (Profil × Höhe, ohne Verjüngung/B-Rep) — damit bleiben +// Grundriss und Schnitt exakt analytisch (ein Prisma schneidet eine waagrechte Ebene in seiner +// Grundfläche und eine senkrechte Ebene in Rechtecken). +// +// Polygone mit Loch (Körper ganz im Bauteil) werden über einen Steg an den Aussenring +// gehängt (Schlüsselloch); die beiden Stegkanten sind nicht gestrichen (`noStrokeEdges`). + +import polygonClipping from "polygon-clipping"; +import type { Pair, Polygon as PcPolygon, MultiPolygon } from "polygon-clipping"; +import type { ExtrudedSolid, Project, Vec2 } from "../model/types"; +import { getFloor } from "../model/types"; +import { ceilingVerticalExtent, columnVerticalExtent } from "../model/wall"; +import type { Primitive } from "./generatePlan/shared"; +import type { SolidSpec } from "../engine/truckSolid"; +import type { RWall } from "./toWalls3d/shared"; + +export interface VoidPrism { + id: string; + pts: Vec2[]; + z0: number; + z1: number; +} + +const EPS = 1e-7; + +/** Ob ein Körper als Abzugskörper wirkt (Prisma mit gültigem Profil). */ +export function isVoidSolid(s: ExtrudedSolid): boolean { + return s.operation === "subtract" && !s.brep && (s.taper ?? 0) < 1e-6 && s.points.length >= 3 && s.height > 0; +} + +/** UK des Körpers (Geschoss-UK + `baseOffset`). */ +export function solidBaseZ(project: Project, s: ExtrudedSolid): number { + let base = 0; + try { + base = getFloor(project, s.levelId).baseElevation ?? 0; + } catch { + base = 0; + } + return base + (s.baseOffset ?? 0); +} + +/** Alle Abzugskörper des Projekts (Welt-Höhen). */ +export function voidPrisms(project: Project): VoidPrism[] { + const out: VoidPrism[] = []; + for (const s of project.extrudedSolids ?? []) { + if (!isVoidSolid(s)) continue; + const z0 = solidBaseZ(project, s); + out.push({ id: s.id, pts: s.points, z0, z1: z0 + s.height }); + } + return out; +} + +// ── Polygon-Booleans ───────────────────────────────────────────────────────── + +const ring = (pts: Vec2[]): Pair[] => pts.map((p) => [p.x, p.y] as Pair); + +/** Fläche (vorzeichenbehaftet) eines Rings. */ +function signedArea(r: Pair[]): number { + let a = 0; + for (let i = 0; i < r.length; i++) { + const p = r[i]; + const q = r[(i + 1) % r.length]; + a += p[0] * q[1] - q[0] * p[1]; + } + return a / 2; +} + +/** Ring ohne doppelten Schlusspunkt (polygon-clipping liefert geschlossene Ringe). */ +function openRing(r: Pair[]): Pair[] { + if (r.length > 1) { + const a = r[0]; + const b = r[r.length - 1]; + if (Math.abs(a[0] - b[0]) < EPS && Math.abs(a[1] - b[1]) < EPS) return r.slice(0, -1); + } + return r; +} + +/** + * Löcher per Steg in den Aussenring einhängen (Schlüsselloch). Liefert die Punkte und die + * Indizes der Stegkanten (Kante i = pts[i] → pts[i+1]). + */ +export function keyhole(poly: Pair[][]): { pts: Pair[]; bridges: number[] } { + let outer = openRing(poly[0]); + const bridges: number[] = []; + const holes = poly.slice(1).map(openRing).filter((h) => h.length >= 3); + // Löcher von rechts nach links einhängen (Stege kreuzen sich so nicht). + holes.sort((a, b) => Math.max(...b.map((p) => p[0])) - Math.max(...a.map((p) => p[0]))); + for (const hole of holes) { + // Lochpunkt mit grösstem x, nächster Aussenring-Punkt dazu. + let hi = 0; + for (let i = 1; i < hole.length; i++) if (hole[i][0] > hole[hi][0]) hi = i; + const h = hole[hi]; + let oi = 0; + let best = Infinity; + for (let i = 0; i < outer.length; i++) { + const d = Math.hypot(outer[i][0] - h[0], outer[i][1] - h[1]); + if (d < best) { + best = d; + oi = i; + } + } + const holeSeq = [...hole.slice(hi), ...hole.slice(0, hi), h]; + const next: Pair[] = [...outer.slice(0, oi + 1), ...holeSeq, outer[oi], ...outer.slice(oi + 1)]; + // Indizes der beiden Stegkanten (alte Stegindizes hinter oi verschieben sich). + const shift = holeSeq.length + 1; + for (let k = 0; k < bridges.length; k++) if (bridges[k] > oi) bridges[k] += shift; + bridges.push(oi, oi + holeSeq.length); + outer = next; + } + return { pts: outer, bridges }; +} + +/** Liegt Segment a→b auf Segment p→q (kollinear, innerhalb)? */ +function onSegment(a: Pair, b: Pair, p: Pair, q: Pair, tol = 1e-6): boolean { + const dx = q[0] - p[0]; + const dy = q[1] - p[1]; + const len = Math.hypot(dx, dy); + if (len < EPS) return false; + const dist = (r: Pair) => Math.abs((r[0] - p[0]) * dy - (r[1] - p[1]) * dx) / len; + const t = (r: Pair) => ((r[0] - p[0]) * dx + (r[1] - p[1]) * dy) / (len * len); + return dist(a) < tol && dist(b) < tol && t(a) > -tol && t(a) < 1 + tol && t(b) > -tol && t(b) < 1 + tol; +} + +/** + * Polygon (Ring `pts`, optional nicht gestrichene Kanten) minus Schneider. Liefert die + * Rest-Polygone mit übertragenen `noStrokeEdges` (eine Kante bleibt ungestrichen, wenn sie + * auf einer ungestrichenen Kante des Originals liegt; Stege sind immer ungestrichen). + * `null` = keine Überschneidung (Original unverändert lassen). + */ +export function subtractRings( + pts: Pair[], + cutters: Pair[][], + noStroke: number[] = [], +): Array<{ pts: Pair[]; noStrokeEdges: number[] }> | null { + if (pts.length < 3 || cutters.length === 0) return null; + const subject: PcPolygon = [pts]; + const clips: MultiPolygon = cutters.filter((c) => c.length >= 3).map((c) => [c] as PcPolygon); + if (clips.length === 0) return null; + // Schnell-Test: überlappen die Hüllen überhaupt? + let hit = false; + try { + hit = polygonClipping.intersection(subject, ...clips).length > 0; + } catch { + return null; + } + if (!hit) return null; + let diff: MultiPolygon; + try { + diff = polygonClipping.difference(subject, ...clips); + } catch { + return null; + } + const area0 = Math.abs(signedArea(pts)); + const out: Array<{ pts: Pair[]; noStrokeEdges: number[] }> = []; + for (const poly of diff) { + const { pts: kp, bridges } = keyhole(poly); + if (kp.length < 3 || Math.abs(signedArea(openRing(poly[0]))) < area0 * 1e-9) continue; + // Orientierung des Originals beibehalten (Schraffur-/Strich-Logik ist orientierungsfrei, + // aber Tests und Nachbearbeitungen erwarten den Umlaufsinn). + const sameDir = Math.sign(signedArea(kp)) === Math.sign(signedArea(pts)) || signedArea(pts) === 0; + const ringPts = sameDir ? kp : [...kp].reverse(); + const n = ringPts.length; + const bridgeSet = new Set(sameDir ? bridges : bridges.map((i) => (n - 2 - i + n) % n)); + const ns: number[] = []; + for (let i = 0; i < n; i++) { + const a = ringPts[i]; + const b = ringPts[(i + 1) % n]; + if (bridgeSet.has(i)) { + ns.push(i); + continue; + } + for (const e of noStroke) { + const p = pts[e]; + const q = pts[(e + 1) % pts.length]; + if (p && q && onSegment(a, b, p, q)) { + ns.push(i); + break; + } + } + } + out.push({ pts: ringPts, noStrokeEdges: ns }); + } + return out; +} + +// ── Grundriss ──────────────────────────────────────────────────────────────── + +function pointInRing(x: number, y: number, r: Pair[]): boolean { + let inside = false; + for (let i = 0, j = r.length - 1; i < r.length; j = i++) { + const [xi, yi] = r[i]; + const [xj, yj] = r[j]; + if (yi > y !== yj > y && x < ((xj - xi) * (y - yi)) / (yj - yi) + xi) inside = !inside; + } + return inside; +} + +/** Teile der Strecke a→b ausserhalb aller Ringe, als Parameter-Intervalle [t0, t1]. */ +export function segmentOutside(a: Vec2, b: Vec2, cutters: Pair[][]): Array<[number, number]> { + const ts = [0, 1]; + const dx = b.x - a.x; + const dy = b.y - a.y; + for (const r of cutters) { + for (let i = 0; i < r.length; i++) { + const p = r[i]; + const q = r[(i + 1) % r.length]; + const ex = q[0] - p[0]; + const ey = q[1] - p[1]; + const den = dx * ey - dy * ex; + if (Math.abs(den) < 1e-14) continue; + const t = ((p[0] - a.x) * ey - (p[1] - a.y) * ex) / den; + const u = ((p[0] - a.x) * dy - (p[1] - a.y) * dx) / den; + if (t > 0 && t < 1 && u >= -1e-9 && u <= 1 + 1e-9) ts.push(t); + } + } + ts.sort((x, y) => x - y); + const out: Array<[number, number]> = []; + for (let i = 0; i + 1 < ts.length; i++) { + const [t0, t1] = [ts[i], ts[i + 1]]; + if (t1 - t0 < 1e-9) continue; + const tm = (t0 + t1) / 2; + const mx = a.x + dx * tm; + const my = a.y + dy * tm; + if (cutters.some((r) => pointInRing(mx, my, r))) continue; + const last = out[out.length - 1]; + if (last && Math.abs(last[1] - t0) < 1e-9) last[1] = t1; + else out.push([t0, t1]); + } + return out; +} + +/** Linien-Klassen der Wand-Poché, die ein Abzugskörper auf Schnitthöhe unterbricht. */ +const WALL_LINE_CLS = new Set(["wall-outline", "layer-joint", "layer-joint-l"]); + +/** + * Zieht die Abzugskörper von den Bauteil-Polygonen eines Grundrisses ab (in place). + * Wände: wenn der Körper die Schnitthöhe `cutZ` durchdringt. Stützen: ebenso, über ihren + * Höhenbereich. Decken: wenn der Körper die Platte durchdringt (Deckendurchbruch). + */ +export function subtractVoidsInPlan(prims: Primitive[], project: Project, cutZ: number): void { + const voids = voidPrisms(project); + if (voids.length === 0) return; + const ceilings = new Map((project.ceilings ?? []).map((c) => [c.id, c])); + const columns = new Map((project.columns ?? []).map((c) => [c.id, c])); + const cuttersFor = (z0: number, z1: number): Pair[][] => + voids.filter((v) => v.z0 < z1 - EPS && v.z1 > z0 + EPS).map((v) => ring(v.pts)); + const wallCutters = cuttersFor(cutZ - 1e-4, cutZ + 1e-4); + const out: Primitive[] = []; + for (const pr of prims) { + if (pr.kind === "line" && WALL_LINE_CLS.has(pr.cls) && wallCutters.length) { + const parts = segmentOutside(pr.a, pr.b, wallCutters); + const whole = parts.length === 1 && parts[0][0] === 0 && parts[0][1] === 1; + if (whole) out.push(pr); + else + for (const [t0, t1] of parts) { + const at = (t: number) => ({ x: pr.a.x + (pr.b.x - pr.a.x) * t, y: pr.a.y + (pr.b.y - pr.a.y) * t }); + out.push({ ...pr, a: at(t0), b: at(t1) }); + } + continue; + } + if (pr.kind !== "polygon" || pr.extrudedSolidId) { + out.push(pr); + continue; + } + let cutters: Pair[][] | null = null; + if (pr.wallId) cutters = wallCutters; + else if (pr.ceilingId) { + const c = ceilings.get(pr.ceilingId); + if (c) { + const { zBottom, zTop } = ceilingVerticalExtent(project, c); + cutters = cuttersFor(zBottom, zTop); + } + } else if (pr.columnId) { + const c = columns.get(pr.columnId); + if (c) { + const { zBottom, zTop } = columnVerticalExtent(project, c); + cutters = zBottom <= cutZ && zTop >= cutZ ? wallCutters : cuttersFor(zBottom, zTop); + } + } + if (!cutters || cutters.length === 0) { + out.push(pr); + continue; + } + const rest = subtractRings(ring(pr.pts), cutters, pr.noStrokeEdges ?? []); + if (rest === null) { + out.push(pr); + continue; + } + for (const r of rest) { + out.push({ + ...pr, + pts: r.pts.map(([x, y]) => ({ x, y })), + noStrokeEdges: r.noStrokeEdges.length ? r.noStrokeEdges : undefined, + }); + } + } + prims.length = 0; + for (const p of out) prims.push(p); +} + +// ── Schnitt ────────────────────────────────────────────────────────────────── + +/** + * Schnitt-Rechtecke (u, v) eines Abzugskörpers mit der senkrechten Ebene durch `base` in + * Richtung `uDir` (Einheitsvektor; u = Abstand entlang uDir ab `base`). + */ +export function voidSectionRects(v: VoidPrism, base: Vec2, uDir: Vec2): Pair[][] { + const ts: number[] = []; + const n = v.pts.length; + // Normale der Schnittspur: Punkt-Seite über das Kreuzprodukt. + const side = (p: Vec2) => (p.x - base.x) * uDir.y - (p.y - base.y) * uDir.x; + for (let i = 0; i < n; i++) { + const a = v.pts[i]; + const b = v.pts[(i + 1) % n]; + const sa = side(a); + const sb = side(b); + // Halboffene Regel (eine Ecke auf der Spur zählt nur einmal). + if ((sa > 0) === (sb > 0)) continue; + const t = sa / (sa - sb); + const px = a.x + (b.x - a.x) * t; + const py = a.y + (b.y - a.y) * t; + ts.push((px - base.x) * uDir.x + (py - base.y) * uDir.y); + } + ts.sort((a, b) => a - b); + const rects: Pair[][] = []; + for (let i = 0; i + 1 < ts.length; i += 2) { + const [u0, u1] = [ts[i], ts[i + 1]]; + if (u1 - u0 < 1e-6) continue; + rects.push([ + [u0, v.z0], + [u1, v.z0], + [u1, v.z1], + [u0, v.z1], + ]); + } + return rects; +} + +/** Minimal-Form eines Schnitt-Polygons (s. `SectionCutPolygon` in toSection.ts). */ +interface CutPolyLike { + pts: Array<[number, number]>; + noStrokeEdges?: number[]; +} + +/** Zieht die Abzugskörper von den Cut-Polygonen eines Schnitts ab (neue Liste). */ +export function subtractVoidsInSection( + cuts: T[], + project: Project, + base: Vec2, + uDir: Vec2, +): T[] { + const voids = voidPrisms(project); + if (voids.length === 0) return cuts; + const rects = voids.flatMap((v) => voidSectionRects(v, base, uDir)); + if (rects.length === 0) return cuts; + const out: T[] = []; + for (const cp of cuts) { + const rest = subtractRings(cp.pts as Pair[], rects, cp.noStrokeEdges ?? []); + if (rest === null) { + out.push(cp); + continue; + } + for (const r of rest) { + out.push({ ...cp, pts: r.pts as Array<[number, number]>, noStrokeEdges: r.noStrokeEdges.length ? r.noStrokeEdges : undefined }); + } + } + return out; +} + +// ── 3D / B-Rep ─────────────────────────────────────────────────────────────── + +export type Box2 = { x0: number; y0: number; x1: number; y1: number }; +export const bbox = (pts: Array<{ x: number; y: number }>): Box2 => ({ + x0: Math.min(...pts.map((p) => p.x)), + y0: Math.min(...pts.map((p) => p.y)), + x1: Math.max(...pts.map((p) => p.x)), + y1: Math.max(...pts.map((p) => p.y)), +}); +const boxHit = (a: Box2, b: Box2) => a.x0 < b.x1 && b.x0 < a.x1 && a.y0 < b.y1 && b.y0 < a.y1; + +export function wallCorners(w: RWall): Array<{ x: number; y: number }> { + const dx = w.end[0] - w.start[0]; + const dy = w.end[1] - w.start[1]; + const len = Math.hypot(dx, dy) || 1; + const nx = (-dy / len) * (w.thickness / 2); + const ny = (dx / len) * (w.thickness / 2); + return [ + { x: w.start[0] + nx, y: w.start[1] + ny }, + { x: w.end[0] + nx, y: w.end[1] + ny }, + { x: w.end[0] - nx, y: w.end[1] - ny }, + { x: w.start[0] - nx, y: w.start[1] - ny }, + ]; +} + +const voidSpec = (v: VoidPrism): SolidSpec => ({ + kind: "extrude", + points: v.pts.flatMap((p) => [p.x, p.y]), + height: v.z1 - v.z0, + z0: v.z0, +}); + +/** Bauteil minus alle Körper (verkettete Differenzen). */ +export function subtractSpec(base: SolidSpec, voids: VoidPrism[]): SolidSpec { + return voids.reduce((acc, v) => ({ kind: "boolean", op: "difference", a: acc, b: voidSpec(v) }), base); +} + +/** Abzugskörper, die ein Prisma (Grundriss-Hülle + Höhenbereich) treffen. */ +export function hittingVoids(voids: VoidPrism[], foot: Box2, z0: number, z1: number): VoidPrism[] { + return voids.filter((v) => v.z0 < z1 - 1e-6 && v.z1 > z0 + 1e-6 && boxHit(bbox(v.pts), foot)); +} + diff --git a/src/plan/wallSpec.ts b/src/plan/wallSpec.ts new file mode 100644 index 00000000..52acb406 --- /dev/null +++ b/src/plan/wallSpec.ts @@ -0,0 +1,81 @@ +// B-Rep-Spezifikation einer Wand(schicht) (`RWall`) für truck: Wandprofil (Achse × Höhe) mit +// den Öffnungen als Löcher bzw. Kerben, um die Dicke extrudiert — OHNE Boolean (B-Rep-Booleans +// scheitern an den bündigen Laibungsflächen). Gemeinsame Quelle für STEP-Export, Abzugskörper +// im 3D und Kollisionsprüfung. + +import type { SolidSpec } from "../engine/truckSolid"; +import type { RWall } from "./toWalls3d/shared"; + +const EPS = 1e-6; +/** Schicht/Öffnung so dünn, dass sie als nicht vorhanden gilt. */ +const MIN_THICKNESS = 1e-4; + +/** + * Wandprofil (u = Achse, v = Höhe über Wandfuss) mit Öffnungen: Löcher, die ganz im Profil + * liegen; Öffnungen am Wandfuss (Türen) als Kerben im Aussenring. Öffnungen am Wandkopf + * werden um 1 mm gekappt (ein Loch darf den Rand nicht berühren). + */ +export function wallProfile( + length: number, + height: number, + holes: Array<{ from: number; to: number; zBottom: number; zTop: number }>, + baseElevation: number, +): { outer: number[]; holes: number[][] } { + const inner: number[][] = []; + const notches: Array<[number, number, number]> = []; // [from, to, top] + const cut = 1e-3; + for (const h of holes) { + const u0 = Math.max(0, Math.min(length, h.from)); + const u1 = Math.max(0, Math.min(length, h.to)); + if (u1 - u0 < MIN_THICKNESS) continue; + const v0 = h.zBottom - baseElevation; + const v1 = Math.min(height - cut, h.zTop - baseElevation); + if (v1 - Math.max(v0, 0) < MIN_THICKNESS) continue; + if (v0 <= cut) notches.push([u0, u1, v1]); + else inner.push([u0, v0, u1, v0, u1, v1, u0, v1]); + } + // Kerben sortieren und überlappende zusammenfassen. + notches.sort((a, b) => a[0] - b[0]); + const merged: Array<[number, number, number]> = []; + for (const n of notches) { + const last = merged[merged.length - 1]; + if (last && n[0] <= last[1] + EPS) { + last[1] = Math.max(last[1], n[1]); + last[2] = Math.max(last[2], n[2]); + } else merged.push([...n]); + } + // Aussenring CCW in (u,v): Wandfuss links→rechts mit Kerben, dann Kopf rechts→links. + const outer: number[] = [0, 0]; + for (const [a, b, top] of merged) { + outer.push(a, 0, a, top, b, top, b, 0); + } + outer.push(length, 0, length, height, 0, height); + return { outer, holes: inner }; +} + +export function wallSpec(w: RWall): SolidSpec | null { + const dx = w.end[0] - w.start[0]; + const dy = w.end[1] - w.start[1]; + const len = Math.hypot(dx, dy); + if (len < MIN_THICKNESS || w.height < MIN_THICKNESS || w.thickness < MIN_THICKNESS) return null; + const ux = dx / len; + const uy = dy / len; + // u × v (v = +Z) = (uy, −ux, 0): Extrusionsrichtung. Ursprung = eine Wandfläche. + const nx = uy; + const ny = -ux; + const prof = wallProfile(len, w.height, w.holes ?? [], w.baseElevation); + return { + kind: "extrudePlane", + points: prof.outer, + holes: prof.holes, + origin: [ + w.start[0] - (nx * w.thickness) / 2, + w.start[1] - (ny * w.thickness) / 2, + w.baseElevation, + ], + uAxis: [ux, uy, 0], + vAxis: [0, 0, 1], + depth: w.thickness, + }; +} + diff --git a/src/state/selectionInfo.ts b/src/state/selectionInfo.ts index 6ff86126..0d428d37 100644 --- a/src/state/selectionInfo.ts +++ b/src/state/selectionInfo.ts @@ -323,6 +323,12 @@ export interface ExtrudedSolidInfo { brepLabel?: string; /** Grundfläche des Profils (m²). */ area: number; + /** Abzugskörper (Aussparung/Durchbruch). */ + subtract: boolean; + /** Abzugskörper möglich (senkrechtes Prisma ohne B-Rep/Verjüngung). */ + canSubtract: boolean; + /** Abstand der UK über der Geschoss-UK (m). */ + baseOffset: number; /** B-Rep-Beschreibung (Weltkoordinaten) für Kennwerte — `null`, wenn truck keine hat. */ spec: SolidSpec | null; /** Geschoss, dessen `baseElevation` die UK des Körpers bestimmt. */ @@ -1056,7 +1062,10 @@ function extrudedSolidSelection(project: Project, s: ExtrudedSolid): Selection { chamfer: s.chamfer ?? 0, ...(s.brep ? { brepLabel: s.brep.label ?? "B-Rep" } : {}), area: polygonArea(s.points), - spec: extrudedSolidSpec(s, floor?.baseElevation ?? 0), + spec: s.operation === "subtract" ? null : extrudedSolidSpec(s, floor?.baseElevation ?? 0), + subtract: s.operation === "subtract", + canSubtract: !s.brep && (s.taper ?? 0) < 1e-6, + baseOffset: s.baseOffset ?? 0, floorId: s.levelId, floorName: floor?.name ?? s.levelId, }; diff --git a/src/state/usePanelHostBase.ts b/src/state/usePanelHostBase.ts index 1b1e3bdc..a2daa86c 100644 --- a/src/state/usePanelHostBase.ts +++ b/src/state/usePanelHostBase.ts @@ -1051,6 +1051,26 @@ export function usePanelHostBase(opts: { ), })); }, + onSetExtrudedSolidSubtract: (subtract) => { + if (selection?.kind !== "extrudedSolid") return; + const id = selection.id; + setProject((p) => ({ + ...p, + extrudedSolids: (p.extrudedSolids ?? []).map((s) => + s.id === id ? { ...s, operation: subtract ? ("subtract" as const) : undefined } : s, + ), + })); + }, + onSetExtrudedSolidBaseOffset: (offset) => { + if (selection?.kind !== "extrudedSolid" || !Number.isFinite(offset)) return; + const id = selection.id; + setProject((p) => ({ + ...p, + extrudedSolids: (p.extrudedSolids ?? []).map((s) => + s.id === id ? { ...s, baseOffset: Math.abs(offset) > 1e-9 ? offset : undefined } : s, + ), + })); + }, // ── Stützen-Attribute (Tragwerk; nur bei selektierter Stütze) ────────── onSetColumnProfileKind: (kind) => { if (selection?.kind !== "column") return; diff --git a/src/ui/ribbon/CommandIcon.tsx b/src/ui/ribbon/CommandIcon.tsx index 03bf1694..eab75b33 100644 --- a/src/ui/ribbon/CommandIcon.tsx +++ b/src/ui/ribbon/CommandIcon.tsx @@ -186,6 +186,15 @@ export function CommandIcon({ name }: { name: string }) { ); + case "voidbox": + // Durchbruch: Wand mit gestricheltem, durchkreuztem Ausschnitt. + return ( + + + + + + ); case "solidbool": // Verschneiden: zwei überlappende Körper. return ( diff --git a/src/viewport/useWasm3dRenderer.ts b/src/viewport/useWasm3dRenderer.ts index 503688dd..fcbf4804 100644 --- a/src/viewport/useWasm3dRenderer.ts +++ b/src/viewport/useWasm3dRenderer.ts @@ -202,7 +202,7 @@ export function useWasm3dRenderer( const r = rendererRef.current; if (!r || !project) return; try { - r.set_model(JSON.stringify(projectToModel3d(project, { detail }))); + r.set_model(JSON.stringify(projectToModel3d(project, { detail, voids: true }))); } catch (e) { console.warn("render3d set_model fehlgeschlagen:", e); } diff --git a/website/assets/css/custom.css b/website/assets/css/custom.css deleted file mode 100644 index 4062d916..00000000 --- a/website/assets/css/custom.css +++ /dev/null @@ -1,210 +0,0 @@ -/* DOSSIER — Custom-CSS-Einstiegspunkt des Hextra-Themes (wird von - layouts/_partials/head.html automatisch nach main.css eingebunden). - - Alles hier ist bewusst unter eigenen Klassen (.dossier-*) und einem - eigenen Token-Namespace (--do-*) gekapselt, statt html/body global zu - überschreiben — das Theme bringt sein eigenes, ausgereiftes Hell/Dunkel- - System mit (Tailwind, .dark auf ), das wir für Suche, Docs-Sidebar, - Code-Blöcke etc. unverändert weiterverwenden wollen. - - Wo wir bewusst "wie das eigentliche Programm" aussehen wollen — Startseite, - Wortmarke oben links —, holen wir uns die echten Farben/den echten Font aus - src/styles.css (App-Hell-Theme) in diesen eigenen Namespace. */ - -@font-face { - font-family: "archivo"; - font-style: normal; - font-weight: 100 900; - font-display: swap; - src: url("/fonts/archivo.woff2") format("woff2"); -} - -.dossier-home, -.dossier-logo { - --do-font: "archivo", system-ui, sans-serif; - --do-font-mono: ui-monospace, "SF Mono", Menlo, monospace; - - /* 1:1 aus src/styles.css :root (App-Hell-Theme). Akzent bewusst NEUTRAL — - kein Petrol-Grün/Teal/Gelb: das war eine veraltete Annahme, die App hat - seit einer Nutzer-Vorgabe nur noch diesen einen neutralen Akzent. */ - --do-panel: #e0dbd4; - --do-panel-2: #d4cfc8; - --do-field: #f5f2ec; - --do-ink: #1a1a18; - --do-dim: #555550; - --do-muted: #8a8580; - --do-border: #c8c2ba; - --do-accent: #4a453e; - --do-accent-light: #6b655c; - --do-accent-dim: #f5f2ec; - --do-accent-border: rgba(58, 53, 46, 0.2); - /* --input in der App — Sekundär-Button-Fläche (s. .imp-btn in styles.css). */ - --do-input: #ece8e2; - - --do-radius: 3px; -} - -html.dark .dossier-home, -html.dark .dossier-logo { - /* 1:1 aus src/styles.css :root[data-theme="dark"]. */ - --do-panel: #1d1d1d; - --do-panel-2: #262626; - --do-field: #2a2a2a; - --do-ink: #ededed; - --do-dim: #a8a8a8; - --do-muted: #6e6e6e; - --do-border: #383838; - --do-accent: #4d4d4d; - --do-accent-light: #5e5e5e; - --do-accent-dim: rgba(255, 255, 255, 0.07); - --do-accent-border: rgba(255, 255, 255, 0.22); - --do-input: #0a0a0a; -} - -/* ---- Wortmarke oben links — identisch zur App: "dossier" klein, Punkt im - neutralen App-Akzent. Ersetzt den generischen Hextra-Seitentitel. ---- */ -.dossier-logo { - display: inline-flex; - align-items: baseline; - font-family: var(--do-font); - font-weight: 800; - font-size: 1.05rem; - letter-spacing: -0.01em; - text-transform: lowercase; - color: var(--do-ink); - white-space: nowrap; -} -.dossier-logo__dot { - color: var(--do-accent); -} -a:hover > .dossier-logo .dossier-logo__dot { - filter: brightness(1.25); -} - -/* ---- "bald"-Badge im Hauptmenü (Forum-Link, hugo.toml). ---- */ -.navbar-badge { - display: inline-block; - font-size: .62em; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; - color: #fff; background: #9a948a; padding: .1em .45em; border-radius: 999px; - margin-left: .4em; vertical-align: middle; -} -html.dark .navbar-badge { background: #6b665c; } - -/* ================================================================== - Startseite — eigenes Layout (layouts/index.html), eingehängt in - Hextra's Standard-Navbar/Footer/Content-Breite. - ================================================================== */ -.dossier-home { - font-family: var(--do-font); - color: var(--do-ink); - max-width: 56rem; - margin-inline: auto; - padding-block: 0.5rem 2rem; -} -.dossier-home h1, -.dossier-home h2 { font-family: var(--do-font); margin: 0; text-wrap: balance; } -.dossier-home p { margin: 0; } -.dossier-home a { text-decoration: none; } - -.dh-section { padding-block: clamp(2.2rem, 5vw, 3.4rem); } -.dh-section + .dh-section { border-top: 1px dashed var(--do-border); } - -.dh-label { - display: flex; align-items: center; gap: .55em; - font-size: .72rem; font-weight: 700; letter-spacing: .14em; - text-transform: uppercase; color: var(--do-accent); margin-bottom: 1rem; -} -.dh-label::before { - content: ""; width: 6px; height: 6px; flex: none; - background: var(--do-accent); border-radius: 1px; -} - -/* ---- Hero ---- */ -.dh-hero { padding-block: clamp(1.6rem, 5vw, 2.6rem) clamp(2.2rem, 5vw, 3.2rem); } -.dh-hero .dh-hook { - font-size: clamp(2rem, 5vw, 3.2rem); font-weight: 800; line-height: 1.08; - letter-spacing: -.02em; max-width: 24ch; -} -.dh-hero .dh-hook .accent { color: var(--do-accent); } -.dh-hero .dh-lead { font-size: clamp(1.02rem, 1.6vw, 1.14rem); color: var(--do-dim); max-width: 38rem; margin-top: 1.3rem; } -.dh-hero .dh-actions { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1.8rem; } -.dh-hero .dh-meta { font-size: .85rem; color: var(--do-muted); margin-top: 1.8rem; } - -/* Wie .imp-btn in der App (Import-Dialog, src/styles.css) — Pille statt - eckigem Button, das ist der tatsächliche Button-Stil des Programms. */ -.dh-btn { - display: inline-flex; align-items: center; gap: .4em; - font-family: var(--do-font); - font-size: .85rem; font-weight: 600; - padding: .55em 1.35em; border: 1px solid var(--do-border); border-radius: 999px; - background: var(--do-input); - color: var(--do-dim); - transition: background .14s, border-color .14s, color .14s; -} -.dh-btn:hover { color: var(--do-ink); border-color: var(--do-accent-border); } -.dh-btn--primary { background: var(--do-accent); border-color: var(--do-accent); color: #fff; } -.dh-btn--primary:hover { background: var(--do-accent-light); border-color: var(--do-accent-light); color: #fff; } - -/* ---- App-Mockup unter dem Hero: eine Miniatur der echten Ansichts- - Segmentpille + Kommandozeile, rein aus CSS, in den echten Programmfarben - — statt eines Screenshots, der sofort veraltet. ---- */ -.dh-mockup { - display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; - margin-top: 2.2rem; padding: .6rem .7rem; - background: var(--do-panel); border: 1px solid var(--do-border); border-radius: 8px; - font-family: var(--do-font); -} -.dh-seg { - display: inline-flex; align-items: stretch; height: 24px; - border-radius: 8px; overflow: hidden; background: var(--do-field); - padding: 2px; gap: 1px; -} -.dh-seg__cell { - display: inline-flex; align-items: center; justify-content: center; - padding: 0 .6rem; border-radius: 5px; font-size: .74rem; font-weight: 600; - color: var(--do-dim); background: transparent; -} -.dh-seg__cell.is-active { background: var(--do-panel-2); color: var(--do-ink); } -.dh-cmd { - display: inline-flex; align-items: center; gap: .5em; - height: 24px; padding-inline: .65rem; border-radius: 6px; - background: var(--do-field); color: var(--do-dim); font-size: .78rem; - font-family: var(--do-font-mono); -} -.dh-cmd::before { content: "›"; color: var(--do-accent); font-family: var(--do-font); font-weight: 700; } - -/* ---- Ansatz ---- */ -.dh-ansatz h2 { font-size: clamp(1.35rem, 2.4vw, 1.8rem); font-weight: 700; letter-spacing: -.01em; } -.dh-ansatz p:not(.dh-views) { margin-top: 1rem; max-width: 38rem; color: var(--do-ink); } -.dh-ansatz .dh-views { margin-top: 1.3rem; font-size: .85rem; color: var(--do-dim); font-family: var(--do-font-mono); } - -/* ---- Feature-Liste — ein Datenblatt, keine Karten: Zeilen reagieren - dezent auf Hover, wie Zeilen einer Bauteilliste im Programm selbst. ---- */ -.dh-features h2, .dh-features .dh-label { margin-bottom: 1.1rem; } -.dh-feature-list { margin: 0; } -.dh-feature-row { - display: grid; grid-template-columns: 12.5rem 1fr; gap: 1.4rem; - padding: 1rem .7rem; margin-inline: -.7rem; - border-top: 1px dashed var(--do-border); - transition: background .15s; -} -.dh-feature-row:first-child { border-top: 1px solid var(--do-border); } -.dh-feature-row:hover { background: var(--do-panel-2); } -.dh-feature-row dt { font-weight: 700; } -.dh-feature-row dd { margin: 0; color: var(--do-dim); max-width: 34rem; } -@media (max-width: 640px) { - .dh-feature-row { grid-template-columns: 1fr; gap: .3rem; } -} - -/* ---- Stack ---- */ -.dh-stack { display: flex; align-items: baseline; gap: 1.4rem; flex-wrap: wrap; } -.dh-stack .dh-label { margin-bottom: 0; } -.dh-stack-list { color: var(--do-dim); font-size: .9rem; } - -/* ---- Herkunft ---- */ -.dh-origin h2 { font-size: clamp(1.25rem, 2.1vw, 1.5rem); font-weight: 700; max-width: 32ch; } -.dh-origin p { margin-top: 1rem; color: var(--do-dim); max-width: 38rem; } - -.dh-cta { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1.6rem; } - -@media (prefers-reduced-motion: reduce) { .dossier-home * { transition: none !important; } } diff --git a/website/assets/css/site.css b/website/assets/css/site.css new file mode 100644 index 00000000..f304e12c --- /dev/null +++ b/website/assets/css/site.css @@ -0,0 +1,195 @@ +/* DOSSIER-Website. Bewusst schlicht: Papier, Tinte, Haarlinien wie auf einem + Plan. Farben aus dem App-Hell-Theme (src/styles.css), kein Akzent. */ + +@font-face { + font-family: "archivo"; + font-style: normal; + font-weight: 100 900; + font-display: swap; + src: url("/fonts/archivo.woff2") format("woff2"); +} + +:root { + --paper: #f5f2ec; + --ink: #1a1a18; + --dim: #5f5b55; + --hair: #cfc9c0; + --code: #ebe6de; + --sans: "archivo", system-ui, sans-serif; + --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace; +} + +@media (prefers-color-scheme: dark) { + :root { + --paper: #141413; + --ink: #e6e3dd; + --dim: #9a968f; + --hair: #3a3935; + --code: #1f1f1d; + } +} + +* { box-sizing: border-box; } + +html { -webkit-text-size-adjust: 100%; } + +body { + margin: 0; + padding: 0 16px; + background: var(--paper); + color: var(--ink); + font: 16px/1.55 var(--sans); +} + +a { color: inherit; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; } +a:hover { text-decoration-thickness: 2px; } + +code, pre, kbd { font-family: var(--mono); font-size: .875em; } + +/* ---- Kopf und Fuss -------------------------------------------------- */ + +.top, .foot, .home, .docs { max-width: 64rem; margin-inline: auto; } + +.top { + display: flex; + flex-wrap: wrap; + align-items: baseline; + justify-content: space-between; + gap: .5rem 1.5rem; + padding: 1.25rem 0 1rem; + border-bottom: 1px solid var(--ink); +} +.mark { + font-weight: 800; + font-size: 1.15rem; + letter-spacing: -.01em; + text-decoration: none; +} +.top nav { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; font: .875rem var(--mono); } +.top nav a { text-decoration: none; } +.top nav a:hover, .top nav a[aria-current] { text-decoration: underline; } + +.foot { + display: flex; + flex-wrap: wrap; + gap: .25rem 1.5rem; + margin-top: 4rem; + padding: 1rem 0 2rem; + border-top: 1px solid var(--ink); + font: .8rem var(--mono); + color: var(--dim); +} + +/* ---- Startseite ----------------------------------------------------- */ + +.home { padding-top: 2.5rem; } +.home > * { max-width: 44rem; } + +/* Plankopf: Felder mit kleiner Beschriftung oben, Wert darunter. Die + Haarlinien entstehen aus einem 1px-Gap über dem Tintenhintergrund. */ +.titleblock { + display: grid; + grid-template-columns: repeat(4, 1fr); + gap: 1px; + margin: 0 0 2.5rem; + background: var(--ink); + border: 1.5px solid var(--ink); +} +.titleblock > div { background: var(--paper); padding: .4rem .6rem .5rem; min-width: 0; } +.titleblock .tb-wide { grid-column: span 2; } +.titleblock dt { + font: .65rem var(--mono); + text-transform: uppercase; + letter-spacing: .08em; + color: var(--dim); +} +.titleblock dd { margin: .1rem 0 0; font-size: .95rem; } +.titleblock .tb-name { font-weight: 800; font-size: 1.6rem; line-height: 1.1; letter-spacing: -.01em; } + +@media (max-width: 560px) { + .titleblock { grid-template-columns: 1fr 1fr; } +} + +/* ---- Fliesstext ----------------------------------------------------- */ + +.prose { min-width: 0; } +.prose > :first-child { margin-top: 0; } + +.prose h1 { font-size: 1.75rem; line-height: 1.2; font-weight: 800; letter-spacing: -.01em; margin: 0 0 1.5rem; } + +.prose h2 { + margin: 3rem 0 1rem; + padding-top: .5rem; + border-top: 1px solid var(--ink); + font: 600 .8rem var(--mono); + text-transform: uppercase; + letter-spacing: .08em; +} +.prose h3 { font-size: 1rem; margin: 2rem 0 .5rem; } + +.prose p, .prose ul, .prose ol, .prose pre, .prose table { margin: 0 0 1rem; } +.prose ul, .prose ol { padding-left: 1.25rem; } +.prose li { margin-bottom: .25rem; } + +.prose :not(pre) > code { background: var(--code); padding: .05em .3em; } + +.prose pre { + background: var(--code); + padding: .75rem 1rem; + overflow-x: auto; + line-height: 1.45; +} +.prose pre code { font-size: .8rem; } + +.prose table { border-collapse: collapse; width: 100%; font-size: .9rem; display: block; overflow-x: auto; } +.prose th, .prose td { text-align: left; vertical-align: top; padding: .35rem .75rem .35rem 0; border-bottom: 1px solid var(--hair); } +.prose th { font: 600 .75rem var(--mono); text-transform: uppercase; letter-spacing: .06em; border-bottom-color: var(--ink); } + +.prose blockquote { margin: 0 0 1rem; padding-left: 1rem; border-left: 2px solid var(--ink); color: var(--dim); } + +.prose hr { border: 0; border-top: 1px dashed var(--hair); margin: 2rem 0; } + +/* Commit-Log */ +.log { list-style: none; padding: 0; font: .8rem/1.5 var(--mono); } +.log li { display: grid; grid-template-columns: auto auto 1fr; gap: 0 .75rem; padding: .3rem 0; border-bottom: 1px solid var(--hair); margin: 0; } +.log time { color: var(--dim); } +.log a { text-decoration: none; } +.log a:hover { text-decoration: underline; } +.log code { font-size: 1em; background: none; padding: 0; } +@media (max-width: 560px) { + .log li { grid-template-columns: auto 1fr; } + .log span { grid-column: 1 / -1; } +} + +/* Inhaltsverzeichnisse in der Doku (ehemals Hextra-Cards) */ +.index { list-style: none; padding: 0 !important; border-top: 1px solid var(--hair); } +.index li { margin: 0; padding: .45rem 0; border-bottom: 1px solid var(--hair); } +.index a { font-weight: 600; } +.index span { display: block; color: var(--dim); font-size: .9rem; } + +/* ---- Doku ----------------------------------------------------------- */ + +.docs { padding-top: 2.5rem; display: grid; gap: 2rem; } + +@media (min-width: 860px) { + .docs { grid-template-columns: 13rem minmax(0, 44rem); gap: 3rem; } + .docnav { position: sticky; top: 1.5rem; align-self: start; } +} + +.docnav { font-size: .9rem; } +.docnav a { text-decoration: none; } +.docnav a:hover, .docnav a[aria-current] { text-decoration: underline; } +.docnav a[aria-current] { font-weight: 700; } +.docnav p { + margin: 1.25rem 0 .35rem; + font: 600 .7rem var(--mono); + text-transform: uppercase; + letter-spacing: .08em; +} +.docnav ul { list-style: none; margin: 0; padding: 0; } +.docnav li { margin: 0 0 .2rem; } + +@media (max-width: 859px) { + .docnav { border-bottom: 1px solid var(--hair); padding-bottom: 1rem; } + .docnav ul { display: flex; flex-wrap: wrap; gap: .2rem 1rem; } +} diff --git a/website/content/_index.md b/website/content/_index.md index 75be7c07..ca94dc5e 100644 --- a/website/content/_index.md +++ b/website/content/_index.md @@ -1,3 +1,93 @@ --- title: "DOSSIER" --- + +DOSSIER ist ein CAD-Programm für Architektur. Man zeichnet in 2D wie in +anderen CAD-Programmen und modelliert das Gebäude aus Bauteilen: Wände, Decken, +Dächer, Treppen, Öffnungen, Räume. Grundriss, Schnitt, Ansicht, 3D und PDF +werden aus diesem Modell berechnet und nicht separat gezeichnet. + +Es ist die eigenständige Neuimplementierung des Rhino-Plugins +[DOSSIER](https://git.openbureau.ch/karim/dossier), mit eigenem Datenmodell +und eigenen Renderern in Rust. Teil von [openbureau](https://openbureau.ch). + +```text + ┌──────────────────────────┐ + │ Projekt (semantisches │ + │ Modell, intern Meter) │ + └────────────┬─────────────┘ + ┌──────────────┬──────────┼───────────┬───────────────┐ + ▼ ▼ ▼ ▼ ▼ + Grundriss Schnitt Ansicht 3D Export (IFC, STEP, + (analytisch (Rust-WASM, (Projektion) (WebGPU) DXF, PDF, SVG, …) + aus Para- Prioritäts- + metern) logik) +``` + +## Stand + +Version 0.1.0. Es gibt noch keine Installer, DOSSIER wird aus dem Quellcode +gebaut. Es läuft auf macOS (Tauri) und Linux (Electron), im Browser mit +Einschränkungen. + +Rund 119 000 Zeilen TypeScript und 23 000 Zeilen Rust, etwa 1 900 Vitest- und +180 Rust-Tests. + +## Bauen + +Voraussetzungen: Node.js, Rust mit dem Target `wasm32-unknown-unknown`, für +Tauri die [Tauri-Voraussetzungen](https://tauri.app/start/prerequisites/). + +```bash +git clone https://git.openbureau.ch/karim/DOSSIER-STANDALONE.git +cd DOSSIER-STANDALONE +npm install +npm run build:engine && npm run build:engine3d && npm run build:truck +npm run tauri:dev # macOS +npm run electron # Linux +``` + +Details unter [Installation](/docs/anleitung/installation/). + +## Was drin ist + +- **Bauteile:** Wände mit Schichten und Verschneidung nach Priorität, Fenster + und Türen, Decken, Dächer, Treppen, Stützen, Räume nach SIA 416 +- **2D:** Zeichnen und Bearbeiten, Bemassung, Text, Schraffuren +- **Befehlszeile** mit rund 55 Befehlen und getippten Koordinaten: `5,3`, + `r5,3`, `5<45` +- **Ansichten:** Grundriss je Geschoss, Schnitt, Ansicht, 3D mit Schnittebene +- **Pläne:** Layouts mit mehreren Ansichtsfenstern, Plankopf, mehrseitiges PDF +- **Volumenkörper:** B-Rep über [truck](https://github.com/ricosjp/truck), + Booleans, Kollisionsprüfung +- **Import:** DXF, DWG, STEP, PDF, Bilder, swisstopo, OpenStreetMap +- **Export:** PDF, SVG, DXF, IFC4, STEP, STL, OBJ, CSV + +Die vollständige Liste steht im +[README](https://git.openbureau.ch/karim/DOSSIER-STANDALONE). + +## Was fehlt + +- DWG und DXF werden gelesen, aber noch nicht in Wände und Öffnungen + übersetzt. DWG schreiben geht nicht. +- `make2D`: eine 3D-Sicht als flache 2D-Zeichnung ausgeben. +- Öffnungen werden als achsparallele Löcher aus der Wand geschnitten, nicht + über allgemeine Booleans. +- Dachfenster. + +## Log + +{{< log >}} + +## Kontakt + +Fehler und Wünsche als +[Issue](https://git.openbureau.ch/karim/DOSSIER-STANDALONE/issues), Fragen im +[Forum](https://dossier.openbureau.ch/forum). + +## Lizenz + +[AGPL-3.0-or-later](https://git.openbureau.ch/karim/DOSSIER-STANDALONE/src/branch/master/LICENSE). +Wer DOSSIER verändert und als Netzwerkdienst betreibt, muss den geänderten +Quellcode den Nutzern zugänglich machen. Die mitgelieferten Materialien von +ambientCG stehen unter CC0. diff --git a/website/content/docs/_index.md b/website/content/docs/_index.md index c55e3472..901839b4 100644 --- a/website/content/docs/_index.md +++ b/website/content/docs/_index.md @@ -2,21 +2,13 @@ title: "Dokumentation" linkTitle: "Dokumentation" weight: 1 -sidebar: - open: true --- -DOSSIER ist eine Open-Source-Design-Suite für Architekten: klassisches -2D-Zeichnen und ein semantisches 3D-Gebäudemodell in einem Programm, daraus -abgeleitet saubere, normgerechte Pläne. Diese Seiten sind der -laufend aktualisierte Ist-Zustand — für die vollständige Rohfassung siehe -[STATUS.md](https://git.openbureau.ch/karim/DOSSIER-STANDALONE/raw/branch/master/STATUS.md) -im Repository. +Die Anleitung beschreibt die Bedienung, der Teil für Entwickler den Code. Den +genauesten Stand hat das +[README](https://git.openbureau.ch/karim/DOSSIER-STANDALONE) im Repository. {{< cards >}} - {{< card link="anleitung" title="Anleitung" icon="play" subtitle="Bedienung: erste Schritte, Kommandosystem, Bauteile, Export." >}} - {{< card link="entwickler" title="Für Entwickler" icon="template" subtitle="Architektur, Technik-Stack, Setup, Konventionen." >}} + {{< card link="anleitung" title="Anleitung" subtitle="Installation, erste Schritte, Befehlszeile, Bauteile, Export." >}} + {{< card link="entwickler" title="Für Entwickler" subtitle="Aufbau, Technik, Setup, Konventionen." >}} {{< /cards >}} - -Das Forum für Fragen, Diskussion und Support folgt — bis dahin ist das -Repository die primäre Anlaufstelle. diff --git a/website/content/docs/anleitung/_index.md b/website/content/docs/anleitung/_index.md index 01a8cc2e..a6f54a6e 100644 --- a/website/content/docs/anleitung/_index.md +++ b/website/content/docs/anleitung/_index.md @@ -2,37 +2,14 @@ title: "Anleitung" linkTitle: "Anleitung" weight: 1 -sidebar: - open: true --- -Vollständige Anleitung zu DOSSIER — von der Installation über das tägliche -Zeichnen und Modellieren bis zu Export/Import und bekannten Einschränkungen. -Für Architektur/Technik-Stack siehe [Für Entwickler](../entwickler/). - -## Erste Schritte - {{< cards >}} - {{< card link="installation" title="Installation" icon="download" subtitle="Bauen aus dem Quellcode: macOS (Tauri), Linux (Electron), Browser." >}} - {{< card link="erste-schritte" title="Erste Schritte" icon="play" subtitle="Start, neues Projekt, Geschosse und Ebenen, Oberfläche." >}} - {{< card link="kommandosystem" title="Kommandosystem" icon="terminal" subtitle="Getippte Koordinaten, Tab-Feldzyklus, Snapping — Rhino-artig." >}} + {{< card link="installation" title="Installation" subtitle="Aus dem Quellcode bauen: macOS (Tauri), Linux (Electron), Browser." >}} + {{< card link="erste-schritte" title="Erste Schritte" subtitle="Neues Projekt, Geschosse und Ebenen, Oberfläche." >}} + {{< card link="kommandosystem" title="Kommandosystem" subtitle="Getippte Koordinaten, Tab-Feldzyklus, Fang." >}} + {{< card link="bauteile" title="Bauteile und Zeichnen" subtitle="2D-Werkzeuge, Wände, Türen, Treppen, Dächer, Räume." >}} + {{< card link="export-import" title="Export und Import" subtitle="PDF, DXF, IFC4, STL/OBJ, CSV; DXF/DWG, swisstopo, OSM." >}} + {{< card link="layouts" title="Layouts und Plansätze" subtitle="Mehrere Ansichtsfenster pro Blatt, Ausschnitte, Kamera-Presets." >}} + {{< card link="troubleshooting" title="Bekannte Einschränkungen" subtitle="Was noch nicht geht." >}} {{< /cards >}} - -## Im Alltag - -{{< cards >}} - {{< card link="bauteile" title="Bauteile & Zeichnen" icon="cube" subtitle="2D-Werkzeuge und semantische Bauteile: Wände, Türen, Treppen, Dächer, Räume." >}} - {{< card link="export-import" title="Export & Import" icon="upload" subtitle="PDF, DXF, IFC4, STL/OBJ, CSV — und Import von DXF/DWG, Swisstopo, OSM." >}} - {{< card link="layouts" title="Layouts & Plansätze" icon="document-duplicate" subtitle="Mehrere Viewports pro Blatt, Ausschnitte, Kamera-Presets." >}} -{{< /cards >}} - -## Für Fortgeschrittene - -{{< cards >}} - {{< card link="troubleshooting" title="Bekannte Einschränkungen" icon="exclamation-circle" subtitle="Was bewusst noch offen ist — ehrlich, ohne Beschönigung." >}} - {{< card link="../entwickler" title="Für Entwickler" icon="template" subtitle="Architektur, Technik-Stack, Setup, Konventionen." >}} -{{< /cards >}} - -Das Forum für Fragen, Diskussion und Support folgt — bis dahin ist das -[Repository](https://git.openbureau.ch/karim/DOSSIER-STANDALONE) die primäre -Anlaufstelle. diff --git a/website/content/docs/entwickler/_index.md b/website/content/docs/entwickler/_index.md index 999f8aec..293310c5 100644 --- a/website/content/docs/entwickler/_index.md +++ b/website/content/docs/entwickler/_index.md @@ -2,19 +2,13 @@ title: "Für Entwickler" linkTitle: "Für Entwickler" weight: 2 -sidebar: - open: false --- -Hintergrund und Referenz für alle, die am Code selbst arbeiten — Architektur, -Technik-Stack, lokales Setup, Konventionen. Für die Bedienung der App siehe -[Anleitung](../anleitung/). - {{< cards >}} - {{< card link="grundgedanke" title="Grundgedanke" subtitle="Ein Modell, jede Ansicht daraus abgeleitet." >}} - {{< card link="stand" title="Stand & Funktionen" subtitle="Was heute funktioniert, was bewusst noch offen ist." >}} + {{< card link="grundgedanke" title="Grundgedanke" subtitle="Ein Modell, alle Ansichten daraus berechnet." >}} + {{< card link="stand" title="Stand und Funktionen" subtitle="Was funktioniert und was offen ist." >}} {{< card link="technik-stack" title="Technik-Stack" subtitle="Rust/WASM/WebGPU, Tauri, Electron, React." >}} {{< card link="setup" title="Lokal einrichten" subtitle="Bauen, Engines kompilieren, testen." >}} {{< card link="aufbau" title="Aufbau" subtitle="Wie der Code organisiert ist." >}} - {{< card link="konventionen" title="Konventionen" subtitle="Sprache, Terminologie, Einheiten, SIA." >}} + {{< card link="konventionen" title="Konventionen" subtitle="Sprache, Begriffe, Einheiten, SIA." >}} {{< /cards >}} diff --git a/website/data/dossier.yaml b/website/data/dossier.yaml deleted file mode 100644 index 77ff5933..00000000 --- a/website/data/dossier.yaml +++ /dev/null @@ -1,36 +0,0 @@ -# Inhalt der DOSSIER-Landingpage. Bearbeitbar ohne Template-Änderung. - -features: - - title: "2D-Zeichenwerkzeuge" - body: "Linie, Polylinie, Rechteck, Kreis, Bogen, Text/Textspalte, Bild/PDF-Import — klassisches Freihand-Zeichnen neben den semantischen Bauteilen, im selben Plan." - - title: "Semantisches Modell" - body: "Mehrschichtige Wände, L-Eck-Gehrung und Prioritäts-T-/X-Stösse — konsistent in Grundriss, 3D-Viewport und Live-Schnitt." - - title: "Parametrische Bauteile" - body: "Wände, Decken, Treppen (gerade · L · Wendel), Dächer (Flach/Pult/Sattel/Walm/Mansarde/Zelt), Stützen." - - title: "Türen & Fenster" - body: "In Wänden gehostet, mit Rahmen/Zarge/Kämpfer/Oberlicht und echten Rechteck-Löchern im 3D-Wandkörper." - - title: "Kommandosystem" - body: "Getippte Koordinaten (5,3 · r5,3 · 5<45), Tab-Feldzyklus, Snapping, Grips, Trim/Split/Join." - - title: "Live 2D↔3D-Schnitt" - body: "Eine Schnittebene im 3D-Viewport folgt derselben Prioritäts-Logik wie der 2D-Plan-Schnitt. Keine Diskrepanz." - - title: "Vektor-Export" - body: "PDF mit Mehrseiten-Layouts, DXF, IFC4 (mit echten Fenster-/Tür-Löchern), STL/OBJ, CSV-Bauteilliste." - - title: "SIA-416-Räume" - body: "Automatische Flächenbilanz mit CSV-Export. Zeichnungsnormen und Symbolik nach SIA." - - title: "Materialbibliothek" - body: "13 gebündelte PBR-Starter plus Live-Suche der kompletten ambientCG-Bibliothek (1K/2K/4K, On-Demand)." - - title: "Layouts & Plansätze" - body: "Mehrere Viewports pro Blatt, Ausschnitte (View-Snapshots), Kamera-Presets, Norden-Rotation." - - title: "Swisstopo & DXF" - body: "swissBUILDINGS3D / ALTI3D / SWISSIMAGE, radiusgenau zugeschnitten; OSM-Kontext; DXF/DWG, .lin/.pat." - - title: "Native Desktop-App" - body: "Randlose Fenster, native Speichern/Öffnen-Dialoge, eigenes .obp-Format mit OS-Level-Lock gegen Doppelöffnen." - - title: "Resource Manager" - body: "Component-/Hatch-/Linien-/Typ-Editoren, regelbasierte Overrides, dockbare Panels, i18n (de/en)." - -stack: - - "TypeScript / React" - - "Rust / wgpu" - - "WebGPU / WebGL2" - - "Tauri" - - "Electron" diff --git a/website/hugo.toml b/website/hugo.toml index 5a9c0d6d..5b76a7c6 100644 --- a/website/hugo.toml +++ b/website/hugo.toml @@ -1,20 +1,9 @@ baseURL = "https://dossier.openbureau.ch/" title = "DOSSIER" -theme = "hextra" -enableRobotsTXT = true -enableEmoji = true - +languageCode = "de-CH" defaultContentLanguage = "de" -[languages.de] - label = "Deutsch" - weight = 1 - title = "DOSSIER" - contentDir = "content" - -[module] - [module.hugoVersion] - extended = true - min = "0.146.0" +enableRobotsTXT = true +disableKinds = ["taxonomy", "term", "rss"] [markup] [markup.highlight] @@ -22,102 +11,14 @@ defaultContentLanguage = "de" [markup.goldmark.renderer] unsafe = true -enableInlineShortcodes = true - -[[menu.main]] - identifier = "produkt" - name = "Produkt" - pageRef = "/" - weight = 1 - -[[menu.main]] - identifier = "documentation" - name = "Dokumentation" - pageRef = "/docs" - weight = 2 - -[[menu.main]] - identifier = "forum" - name = "Forum" - url = "https://dossier.openbureau.ch/forum" - weight = 3 - -[[menu.main]] - name = "Search" - weight = 4 - [menu.main.params] - type = "search" - -[[menu.main]] - name = "Theme" - weight = 5 - [menu.main.params] - type = "theme-toggle" - -[[menu.main]] - identifier = "quellcode" - name = "Quellcode ↗" - url = "https://git.openbureau.ch/karim/DOSSIER-STANDALONE" - weight = 6 - [params] - description = "DOSSIER ist eine Open-Source-Design-Suite für Architekten: klassisches 2D-Zeichnen und ein semantisches 3D-Gebäudemodell in einem Programm — daraus abgeleitet saubere, normgerechte Pläne. Eigenständige Desktop-App." - externalLinkDecoration = false + description = "DOSSIER ist ein Open-Source-CAD für Architektur: 2D-Zeichnen und ein Gebäudemodell aus Bauteilen, aus dem Grundriss, Schnitt, Ansicht und PDF berechnet werden. AGPL-3.0." + version = "0.1.0" - [params.navbar] - displayTitle = true - displayLogo = false - width = "normal" - - [params.theme] - default = "light" - displayToggle = true - - [params.footer] - enable = true - displayCopyright = true - displayPoweredBy = false - width = "normal" - - [params.page] - width = "normal" - - displayUpdatedDate = false - - [params.search] - enable = true - type = "flexsearch" - [params.search.flexsearch] - index = "content" - tokenize = "forward" - - [params.editURL] - enable = false - - [params.toc] - displayTags = false - - # ---- eigene Inhalte für die bespoke Startseite (layouts/hextra-home.html) ---- - [params.dossier] - wordmark = "DOSSIER" - role = "Design-Suite für Architekten — 2D-Zeichnen & semantisches 3D-Modell" - - hookMain = "2D zeichnen. 3D modellieren." - hookAccent = "Ein Programm, ein Modell." - lead = "DOSSIER ist eine Design-Suite für Architekten, kein reines BIM-Tool: klassisches 2D-Zeichnen (Linien, Polylinien, Bemassung, Rhino-artige Kommandozeile) und ein semantisches 3D-Gebäudemodell (Wände, Türen, Treppen, Dächer als echte Bauteile) im selben Programm. Jeder Plan — Grundriss, Schnitt, Ansicht, PDF — wird aus diesem einen Modell abgeleitet." - - meta = "macOS · Linux · Browser — Rust / WASM / WebGPU — AGPL-3.0" - - ansatzTitle = "Ein Modell. Keine Kopien." - ansatzBody = "Es gibt ein semantisches Modell als einzige Wahrheit. Jede Ansicht wird daraus abgeleitet — Darstellung (Detailgrad, Linienstärken, Schraffuren) wird erst beim Rendern angewandt, nie in die Geometrie eingebacken. Wer eine Wand verschiebt, verschiebt sie überall." - ansatzViews = "3D-Viewport → Grundriss → Schnitt → Ansicht → PDF-Plansatz → IFC / DXF" - - originTitle = "Aus dem Rhino-Plugin herausgewachsen — jetzt eigenständig." - originBody = "DOSSIER ist die eigenständige Neuimplementierung des gleichnamigen Rhino-Plugins: dieselbe Denkweise — Geschosse, Kategorie-Ebenen, mehrschichtige Bauteile, Prioritäts-Verschneidung — jetzt mit eigenem Datenmodell und eigener Rendering-Engine." - - repo = "https://git.openbureau.ch/karim/DOSSIER-STANDALONE" - license = "https://git.openbureau.ch/karim/DOSSIER-STANDALONE/raw/branch/master/LICENSE" - bureau = "https://openbureau.ch" - rapport = "https://rapport.openbureau.ch" - forum = "https://dossier.openbureau.ch/forum" - forumSoon = false + repo = "https://git.openbureau.ch/karim/DOSSIER-STANDALONE" + # Gitea-API für das Commit-Log auf der Startseite (wird beim Bauen geholt; + # ohne Netz fällt der Abschnitt auf einen Link zurück). + commitsApi = "https://git.openbureau.ch/api/v1/repos/karim/DOSSIER-STANDALONE/commits?limit=12&stat=false&verification=false&files=false" + plugin = "https://git.openbureau.ch/karim/dossier" + bureau = "https://openbureau.ch" + forum = "https://dossier.openbureau.ch/forum" diff --git a/website/i18n/de.yaml b/website/i18n/de.yaml deleted file mode 100644 index 3e0bcd17..00000000 --- a/website/i18n/de.yaml +++ /dev/null @@ -1 +0,0 @@ -copyright: "© 2026 Karim Gabriele Varano — DOSSIER ist Teil der [openbureau](https://openbureau.ch)-Suite, AGPL-3.0-or-later." diff --git a/website/layouts/_partials/commits.html b/website/layouts/_partials/commits.html new file mode 100644 index 00000000..47da4115 --- /dev/null +++ b/website/layouts/_partials/commits.html @@ -0,0 +1,11 @@ +{{- /* Letzte Commits aus der Gitea-API, beim Bauen geholt. Ohne Netz: leere + Liste, die Startseite zeigt dann nur den Link aufs Repo. */ -}} +{{- $commits := slice -}} +{{- with try (resources.GetRemote site.Params.commitsApi) -}} + {{- with .Err -}} + {{- warnf "Commit-Log nicht geladen: %s" . -}} + {{- else -}} + {{- with .Value -}}{{- $commits = .Content | transform.Unmarshal -}}{{- end -}} + {{- end -}} +{{- end -}} +{{- return $commits -}} diff --git a/website/layouts/_partials/docnav.html b/website/layouts/_partials/docnav.html new file mode 100644 index 00000000..a572e3f0 --- /dev/null +++ b/website/layouts/_partials/docnav.html @@ -0,0 +1,13 @@ +{{- $docs := site.GetPage "/docs" -}} +{{- $cur := .RelPermalink -}} + diff --git a/website/layouts/_partials/navbar-title.html b/website/layouts/_partials/navbar-title.html deleted file mode 100644 index cb7a5fc8..00000000 --- a/website/layouts/_partials/navbar-title.html +++ /dev/null @@ -1,7 +0,0 @@ -{{- /* Site-Override der Theme-Wortmarke oben links: statt Logo-Bild + Site-Titel - die echte App-Wortmarke — "dossier" klein, Punkt im neutralen App-Akzent, - exakt wie in TopBar.tsx/StartScreen.tsx (siehe assets/css/custom.css - .dossier-logo). */ -}} - - - diff --git a/website/layouts/_shortcodes/card.html b/website/layouts/_shortcodes/card.html new file mode 100644 index 00000000..7671008c --- /dev/null +++ b/website/layouts/_shortcodes/card.html @@ -0,0 +1 @@ +
  • {{ .Get "title" }}{{ with .Get "subtitle" }} {{ . }}{{ end }}
  • diff --git a/website/layouts/_shortcodes/cards.html b/website/layouts/_shortcodes/cards.html new file mode 100644 index 00000000..0f8c4fda --- /dev/null +++ b/website/layouts/_shortcodes/cards.html @@ -0,0 +1 @@ +
      {{ .Inner }}
    diff --git a/website/layouts/_shortcodes/log.html b/website/layouts/_shortcodes/log.html new file mode 100644 index 00000000..796a1602 --- /dev/null +++ b/website/layouts/_shortcodes/log.html @@ -0,0 +1,9 @@ +{{- $commits := partialCached "commits.html" .Page -}} +{{- with $commits }} +
      + {{- range . }} +
    1. {{ substr .sha 0 7 }} {{ index (split .commit.message "\n") 0 }}
    2. + {{- end }} +
    +{{- end }} +

    Alle Commits

    diff --git a/website/layouts/baseof.html b/website/layouts/baseof.html new file mode 100644 index 00000000..c7d0b77e --- /dev/null +++ b/website/layouts/baseof.html @@ -0,0 +1,33 @@ + + + + + + {{ if .IsHome }}DOSSIER{{ else }}{{ .Title }} · DOSSIER{{ end }} + + + + {{ $css := resources.Get "css/site.css" | minify | fingerprint }} + + + +
    + dossier. + +
    + + {{ block "main" . }}{{ end }} + + + + diff --git a/website/layouts/home.html b/website/layouts/home.html new file mode 100644 index 00000000..0395ef92 --- /dev/null +++ b/website/layouts/home.html @@ -0,0 +1,21 @@ +{{ define "main" }} +{{ $commits := partialCached "commits.html" . }} +
    + {{/* Plankopf statt Hero: nur Fakten. */}} +
    +
    Projekt
    DOSSIER
    +
    Inhalt
    Open-Source-CAD für Architektur
    +
    Version
    {{ site.Params.version }}
    +
    Lizenz
    AGPL-3.0
    +
    Plattform
    macOS, Linux, Browser
    +
    Letzter Commit
    + {{- with index $commits 0 }}{{ time.Format "02.01.2006" .commit.author.date }} + {{- else }}{{ now.Format "02.01.2006" }}{{ end -}} +
    +
    + +
    + {{ .Content }} +
    +
    +{{ end }} diff --git a/website/layouts/index.html b/website/layouts/index.html deleted file mode 100644 index 459c35e6..00000000 --- a/website/layouts/index.html +++ /dev/null @@ -1,74 +0,0 @@ -{{/* Bespoke Startseite: löst den generischen "hextra-home.html"-Titel-nur- - Fallback ab. Hängt in Hextra's eigenem Navbar/Footer/Sidebar-Rahmen - (baseof.html "main"-Block, gleiche Struktur wie hextra-home.html), - Inhalt/Styling ist eigenständig unter .dossier-home (s. custom.css). */}} -{{ define "main" }} -{{ $p := .Site.Params.dossier }} -{{ $d := hugo.Data.dossier }} -
    - {{ partial "sidebar.html" (dict "context" . "disableSidebar" true) }} -
    - -
    - -
    -

    {{ $p.hookMain }} {{ $p.hookAccent }}

    -

    {{ $p.lead }}

    - - - {{/* Miniatur-Nachbau der echten Oberleiste — Ansichts-Segmentpille, - Kommandozeile —, in den echten Programmfarben. Bewusst kein - Screenshot: veraltet nie, lädt ohne Bild. */}} - - -

    {{ $p.meta }}

    -
    - -
    -

    {{ $p.ansatzTitle }}

    -

    {{ $p.ansatzBody }}

    -

    {{ $p.ansatzViews }}

    -
    - -
    -

    Funktionen

    -
    - {{ range $d.features }} -
    -
    {{ .title | safeHTML }}
    -
    {{ .body | safeHTML }}
    -
    - {{ end }} -
    -
    - -
    - Aufgebaut auf -

    {{ delimit $d.stack " · " }}

    -
    - -
    -

    {{ $p.originTitle }}

    -

    {{ $p.originBody }}

    - -
    - -
    -
    -
    -{{ end }} diff --git a/website/layouts/page.html b/website/layouts/page.html new file mode 100644 index 00000000..705f6774 --- /dev/null +++ b/website/layouts/page.html @@ -0,0 +1,9 @@ +{{ define "main" }} +
    + {{ partial "docnav.html" . }} +
    +

    {{ .Title }}

    + {{ .Content }} +
    +
    +{{ end }} diff --git a/website/layouts/section.html b/website/layouts/section.html new file mode 100644 index 00000000..705f6774 --- /dev/null +++ b/website/layouts/section.html @@ -0,0 +1,9 @@ +{{ define "main" }} +
    + {{ partial "docnav.html" . }} +
    +

    {{ .Title }}

    + {{ .Content }} +
    +
    +{{ end }} diff --git a/website/static/favicon.svg b/website/static/favicon.svg new file mode 100644 index 00000000..42de0095 --- /dev/null +++ b/website/static/favicon.svg @@ -0,0 +1 @@ +