[G5][107] Gauben und Dach-Verschneidung über Körper-Booleans im Kern
- [107] Schritt 2: `solid_bool.rs` (manifold-rust =0.19.1, exakter Modus) im Kern: Eingabeprüfung (endlich, |x| < 1e7, ≤ 200 000 Dreiecke, verschweisst, geschlossen, Volumen ≠ 0, Orientierung), Status nach jeder Operation, Cache je Element mit Inhalts-Hash, flache Kodierung + Bindung `solid_boolean`, TS-Fassade `geometry/solidBool.ts`; Fuzz-Tests (Rust, vitest). - [G5] `roof_assembly.rs`: L-/T-Dächer je Schicht verschnitten (Kehlen, keine Überlappung), Gauben (`Roof.dormers`, `dormer.rs`: Schlepp/Sattel/Flach/Walm) mit Loch im Hauptdach, Gaubendach, Stirn/Wangen je Wandschicht; Fenster als Opening mit `hostDormerId`. 3D, Schnitt (Bauteil-Schraffur je Schicht), Ansicht, Dachaufsicht, IFC (Teil des IfcRoof), Bauteilliste. Befehl „Gaube", Objekt-Info-Abschnitt, 3D-Griffe Breite/Tiefe. - TODO.md nachgeführt.
This commit is contained in:
33 files changed
+3083
-19
No files matched your search
@@ -0,0 +1,55 @@
|
||||
// Gaube/Lukarne ([G5]) als Engine-Befehl: ein Klick in eine geneigte Dachfläche setzt die Gaube mit der
|
||||
// Mitte ihrer Stirn an den Punkt (Breite 2.4 m, Stirnhöhe 1.5 m) und ein Fenster in die Stirn. Art als
|
||||
// Inline-Option (Schlepp/Sattel/Flach/Walm). Kern: `cmd_solid.rs::dormer_ops`, Geometrie `dormer.rs`,
|
||||
// Verschneidung mit dem Hauptdach `roof_assembly.rs`.
|
||||
|
||||
import { createMutation, xy } from "../createCore";
|
||||
import type { CmdOption, Command, CommandResult, CommandState } from "../types";
|
||||
|
||||
const KIND_OPTIONS: CmdOption[] = [
|
||||
{ id: "schlepp", labelKey: "cmd.dormer.opt.schlepp" },
|
||||
{ id: "sattel", labelKey: "cmd.dormer.opt.sattel" },
|
||||
{ id: "flach", labelKey: "cmd.dormer.opt.flach" },
|
||||
{ id: "walm", labelKey: "cmd.dormer.opt.walm" },
|
||||
];
|
||||
const KIND_IDS = new Set(KIND_OPTIONS.map((o) => o.id));
|
||||
|
||||
interface DormerState extends CommandState {
|
||||
phase: "start";
|
||||
kind: string;
|
||||
}
|
||||
|
||||
const idle = (kind = "schlepp"): [CommandState, CommandResult] => [
|
||||
{ phase: "start", kind, lastPoint: null } as DormerState,
|
||||
{ draft: null, done: true },
|
||||
];
|
||||
|
||||
export const dormerCommand: Command = {
|
||||
name: "dormer",
|
||||
labelKey: "cmd.dormer.label",
|
||||
floorOnly: true,
|
||||
prompt: () => "cmd.dormer.start",
|
||||
accepts: () => ["point", "option"],
|
||||
options: () => KIND_OPTIONS,
|
||||
init: (): DormerState => ({ phase: "start", kind: "schlepp", lastPoint: null }),
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as DormerState;
|
||||
if (input.kind === "option" && KIND_IDS.has(input.id)) {
|
||||
return [{ ...s, kind: input.id } as DormerState, { draft: null }];
|
||||
}
|
||||
if (input.kind !== "point") return [s, { draft: null }];
|
||||
return [
|
||||
{ ...s, lastPoint: input.point } as DormerState,
|
||||
{ draft: null, commit: createMutation(ctx, { cmd: "dormer", p: xy(input.point), kind: s.kind }) },
|
||||
];
|
||||
},
|
||||
|
||||
onMove: (state, point): [CommandState, CommandResult] => [
|
||||
state,
|
||||
{ draft: { preview: [{ kind: "poly", pts: [point], closed: false }], vertices: [point] } },
|
||||
],
|
||||
|
||||
onConfirm: (state): [CommandState, CommandResult] => idle((state as DormerState).kind),
|
||||
onCancel: (state): [CommandState, CommandResult] => idle((state as DormerState).kind),
|
||||
};
|
||||
@@ -19,6 +19,7 @@ import { solidBoolCommand } from "./cmds/solidbool";
|
||||
import { voidBoxCommand } from "./cmds/voidbox";
|
||||
import { ceilingOpeningCommand } from "./cmds/ceilingOpening";
|
||||
import { roofWindowCommand } from "./cmds/roofWindow";
|
||||
import { dormerCommand } from "./cmds/dormer";
|
||||
import { roofHoleCommand } from "./cmds/roofHole";
|
||||
import { roomCommand } from "./cmds/room";
|
||||
import { rectCommand } from "./cmds/rect";
|
||||
@@ -80,6 +81,7 @@ export const COMMANDS: Record<string, Command> = {
|
||||
voidbox: voidBoxCommand,
|
||||
ceilingopening: ceilingOpeningCommand,
|
||||
roofwindow: roofWindowCommand,
|
||||
dormer: dormerCommand,
|
||||
roofhole: roofHoleCommand,
|
||||
room: roomCommand,
|
||||
line: lineCommand,
|
||||
@@ -165,6 +167,8 @@ export const ALIASES: Record<string, string> = {
|
||||
aussparung: "ceilingopening",
|
||||
dachfenster: "roofwindow",
|
||||
oberlicht: "roofwindow",
|
||||
gaube: "dormer",
|
||||
lukarne: "dormer",
|
||||
dachhof: "roofhole",
|
||||
lichthof: "roofhole",
|
||||
rf: "roof",
|
||||
|
||||
@@ -235,6 +235,23 @@ function corruptions(base: Project, seed: number): [string, Project][] {
|
||||
}
|
||||
}
|
||||
});
|
||||
add("Gauben kaputt ([G5])", (p) => {
|
||||
const roofs = list(p, "roofs");
|
||||
const bad = [NaN, -1, 0, 1e9, Infinity];
|
||||
if (!Array.isArray(p.openings)) p.openings = [];
|
||||
for (const [i, rf] of roofs.entries()) {
|
||||
const o = rf.outline as { x: number; y: number }[] | undefined;
|
||||
const c = Array.isArray(o) && o[0] ? { x: o[0].x + 1, y: o[0].y + 1 } : { x: 1, y: 1 };
|
||||
rf.dormers = [
|
||||
{ id: `GD${i}a`, kind: "sattel", position: c, width: 2, frontHeight: 1.2 },
|
||||
{ id: `GD${i}b`, kind: "unbekannt", position: { x: NaN, y: 0 }, width: bad[i % bad.length], frontHeight: bad[(i + 1) % bad.length] },
|
||||
{ id: `GD${i}c`, kind: "schlepp", position: c, width: 1e-9, frontHeight: 1, depth: -5, pitchDeg: 89, overhang: NaN, wallTypeId: "fehlt", roofTypeId: "fehlt" },
|
||||
{ id: `GD${i}d`, kind: "walm", position: c, width: 3, frontHeight: 1, overhang: 1e6 },
|
||||
];
|
||||
list(p, "openings").push({ id: `GW${i}`, type: "opening", hostWallId: "", hostRoofId: rf.id, hostDormerId: `GD${i}a`, categoryCode: "21", kind: "window", position: NaN, width: 0.8, height: 0.8, sillHeight: 0.1 });
|
||||
list(p, "openings").push({ id: `GX${i}`, type: "opening", hostWallId: "", hostRoofId: rf.id, hostDormerId: "fehlt", categoryCode: "21", kind: "window", position: 0, width: 0.8, height: 0.8, sillHeight: 0 });
|
||||
}
|
||||
});
|
||||
add("Baurecht/Sonne kaputt", (p) => {
|
||||
p.siteRules = { parcel: [{ x: 0, y: 0 }, { x: NaN, y: 1 }, { x: 1, y: 1 }], setbacks: [NaN, -1], defaultSetback: NaN, buildingLines: [{ a: { x: 0, y: 0 }, b: { x: 0, y: 0 } }], maxHeight: NaN, show: true };
|
||||
p.sunStudy = { when: "kein Datum", show: true };
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { solidBoolean, type SolidMesh } from "./solidBool";
|
||||
|
||||
function box(x: number, y: number, z: number, w: number, l: number, h: number): SolidMesh {
|
||||
const p = [
|
||||
[x, y, z],
|
||||
[x + w, y, z],
|
||||
[x + w, y + l, z],
|
||||
[x, y + l, z],
|
||||
[x, y, z + h],
|
||||
[x + w, y, z + h],
|
||||
[x + w, y + l, z + h],
|
||||
[x, y + l, z + h],
|
||||
];
|
||||
const indices = [0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 0, 1, 5, 0, 5, 4, 1, 2, 6, 1, 6, 5, 2, 3, 7, 2, 7, 6, 3, 0, 4, 3, 4, 7];
|
||||
return { positions: p.flat(), indices };
|
||||
}
|
||||
|
||||
function volume(m: { positions: ArrayLike<number>; indices: ArrayLike<number> }): number {
|
||||
let v = 0;
|
||||
const P = m.positions;
|
||||
for (let t = 0; t < m.indices.length; t += 3) {
|
||||
const [a, b, c] = [m.indices[t] * 3, m.indices[t + 1] * 3, m.indices[t + 2] * 3];
|
||||
v +=
|
||||
P[a] * (P[b + 1] * P[c + 2] - P[b + 2] * P[c + 1]) -
|
||||
P[a + 1] * (P[b] * P[c + 2] - P[b + 2] * P[c]) +
|
||||
P[a + 2] * (P[b] * P[c + 1] - P[b + 1] * P[c]);
|
||||
}
|
||||
return v / 6;
|
||||
}
|
||||
|
||||
describe("solidBoolean (Kern, Manifold)", () => {
|
||||
it("bündige Differenz exakt", () => {
|
||||
const r = solidBoolean(box(0, 0, 0, 2, 2, 2), box(1, 0, 0, 1, 2, 2), "difference");
|
||||
expect(r).not.toBeNull();
|
||||
expect(volume(r!)).toBeCloseTo(4, 9);
|
||||
});
|
||||
|
||||
it("Schnitt ohne Überdeckung: leer, nicht null", () => {
|
||||
const r = solidBoolean(box(0, 0, 0, 1, 1, 1), box(5, 5, 5, 1, 1, 1), "intersection");
|
||||
expect(r).not.toBeNull();
|
||||
expect(r!.indices.length).toBe(0);
|
||||
});
|
||||
|
||||
it("kaputte Netze: null statt Ausnahme (Fuzz)", () => {
|
||||
let seed = 7;
|
||||
const rnd = () => ((seed = (seed * 1103515245 + 12345) % 2147483648) / 2147483648);
|
||||
const specials = [NaN, Infinity, -Infinity, 1e300, -0, 1e-12];
|
||||
for (let k = 0; k < 300; k++) {
|
||||
const a = box(rnd(), rnd(), rnd(), 0.5 + rnd(), 0.5 + rnd(), 0.5 + rnd());
|
||||
const pos = Array.from(a.positions);
|
||||
const idx = Array.from(a.indices);
|
||||
switch (k % 5) {
|
||||
case 0:
|
||||
pos[Math.floor(rnd() * pos.length)] = specials[k % specials.length];
|
||||
break;
|
||||
case 1:
|
||||
idx[Math.floor(rnd() * idx.length)] = Math.floor(rnd() * 50) - 5;
|
||||
break;
|
||||
case 2:
|
||||
idx.length = Math.floor(rnd() * idx.length);
|
||||
break;
|
||||
case 3:
|
||||
idx.push(...idx.slice(0, 3));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
const ops = ["union", "difference", "intersection"] as const;
|
||||
expect(() => solidBoolean({ positions: pos, indices: idx }, box(0.3, 0.3, 0.3, 1, 1, 1), ops[k % 3])).not.toThrow();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
// Körper-Booleans des Rust-Kerns ([107] Schritt 2, `src-tauri/core/src/solid_bool.rs`, Manifold-Port
|
||||
// `manifold-rust`, exakter Modus): synchron, Netze als flache Positionen/Indizes (Modell-Meter).
|
||||
// Ungültige Eingaben (offen, nicht endlich, Volumen 0, zu viele Dreiecke) ergeben `null` statt einer
|
||||
// Ausnahme; innen nach aussen gedrehte Körper werden gedreht.
|
||||
|
||||
import { core } from "../engine/coreWasm";
|
||||
|
||||
export interface SolidMesh {
|
||||
positions: ArrayLike<number>;
|
||||
indices: ArrayLike<number>;
|
||||
}
|
||||
|
||||
export type SolidOp = "union" | "difference" | "intersection";
|
||||
|
||||
const OPS: Record<SolidOp, number> = { union: 0, difference: 1, intersection: 2 };
|
||||
|
||||
function encode(m: SolidMesh): Float64Array {
|
||||
const nv = Math.floor(m.positions.length / 3);
|
||||
const nt = Math.floor(m.indices.length / 3);
|
||||
const out = new Float64Array(2 + nv * 3 + nt * 3);
|
||||
out[0] = nv;
|
||||
for (let i = 0; i < nv * 3; i++) out[1 + i] = m.positions[i];
|
||||
out[1 + nv * 3] = nt;
|
||||
for (let i = 0; i < nt * 3; i++) out[2 + nv * 3 + i] = m.indices[i];
|
||||
return out;
|
||||
}
|
||||
|
||||
/** `a op b`; `null` bei ungültiger Eingabe. Ein leeres Ergebnis (z. B. Schnitt ohne Überdeckung) hat
|
||||
* leere Listen. */
|
||||
export function solidBoolean(a: SolidMesh, b: SolidMesh, op: SolidOp): { positions: Float64Array; indices: Uint32Array } | null {
|
||||
const r = core().solid_boolean(OPS[op], encode(a), encode(b));
|
||||
if (r.length < 2) return null;
|
||||
const nv = r[0];
|
||||
const positions = r.slice(1, 1 + nv * 3);
|
||||
const nt = r[1 + nv * 3];
|
||||
const indices = Uint32Array.from(r.subarray(2 + nv * 3, 2 + nv * 3 + nt * 3));
|
||||
return { positions, indices };
|
||||
}
|
||||
@@ -488,6 +488,24 @@ export const de = {
|
||||
"objinfo.roof.courtRemove": "Hof entfernen",
|
||||
"objinfo.roof.courtAdd": "Hof hinzufügen: Befehl „Dachhof“ (Kontur zeichnen)",
|
||||
"objinfo.roof.courtAddBtn": "Hof zeichnen …",
|
||||
"objinfo.dormer.section": "Gauben",
|
||||
"objinfo.dormer.kind": "Gaubenart",
|
||||
"objinfo.dormer.kind.schlepp": "Schleppgaube",
|
||||
"objinfo.dormer.kind.sattel": "Satteldachgaube",
|
||||
"objinfo.dormer.kind.flach": "Flachdachgaube",
|
||||
"objinfo.dormer.kind.walm": "Walmgaube",
|
||||
"objinfo.dormer.remove": "Gaube entfernen",
|
||||
"objinfo.dormer.width": "Breite (aussen)",
|
||||
"objinfo.dormer.frontHeight": "Stirnhöhe",
|
||||
"objinfo.dormer.pitch": "Neigung Gaubendach",
|
||||
"objinfo.dormer.depth": "Tiefe (Schleppgaube)",
|
||||
"objinfo.dormer.overhang": "Überstand",
|
||||
"objinfo.dormer.wallType": "Wandaufbau",
|
||||
"objinfo.dormer.wallType.default": "einschichtig 15 cm",
|
||||
"objinfo.dormer.roofType": "Dachaufbau",
|
||||
"objinfo.dormer.roofType.host": "wie Hauptdach",
|
||||
"objinfo.dormer.add": "Gaube in eine Dachfläche setzen",
|
||||
"objinfo.dormer.addBtn": "Gaube setzen …",
|
||||
// ── Stützen-Attribute (Object-Info-Panel) ───────────────────────────────
|
||||
"objinfo.column.section": "Stütze",
|
||||
"objinfo.column.profile": "Profil",
|
||||
@@ -1497,6 +1515,12 @@ export const de = {
|
||||
"cmd.roof.corner": "Gegenecke:",
|
||||
"cmd.roofWindow.label": "Dachfenster",
|
||||
"cmd.roofWindow.start": "Mitte des Dachfensters (in einer Dachfläche, sonst Oberlicht in der Decke):",
|
||||
"cmd.dormer.label": "Gaube",
|
||||
"cmd.dormer.start": "Mitte der Gaubenstirn in einer geneigten Dachfläche:",
|
||||
"cmd.dormer.opt.schlepp": "Schlepp",
|
||||
"cmd.dormer.opt.sattel": "Sattel",
|
||||
"cmd.dormer.opt.flach": "Flach",
|
||||
"cmd.dormer.opt.walm": "Walm",
|
||||
"cmd.ceilingOpening.label": "Deckenloch",
|
||||
"cmd.ceilingOpening.start": "Erste Ecke der Aussparung (in einer Decke):",
|
||||
"cmd.ceilingOpening.corner": "Gegenecke:",
|
||||
@@ -2738,6 +2762,7 @@ export const de = {
|
||||
"history.cmd.break": "Auftrennen",
|
||||
"history.cmd.ceiling": "Decke zeichnen",
|
||||
"history.cmd.roofWindow": "Dachfenster",
|
||||
"history.cmd.dormer": "Gaube",
|
||||
"history.cmd.ceilingOpening": "Deckenöffnung",
|
||||
"history.cmd.chamfer": "Fase",
|
||||
"history.cmd.circle": "Kreis zeichnen",
|
||||
|
||||
@@ -486,6 +486,24 @@ export const en: Record<TranslationKey, string> = {
|
||||
"objinfo.roof.courtRemove": "Remove courtyard",
|
||||
"objinfo.roof.courtAdd": "Add a courtyard: command \"Roof court\" (draw the contour)",
|
||||
"objinfo.roof.courtAddBtn": "Draw courtyard …",
|
||||
"objinfo.dormer.section": "Dormers",
|
||||
"objinfo.dormer.kind": "Dormer type",
|
||||
"objinfo.dormer.kind.schlepp": "Shed dormer",
|
||||
"objinfo.dormer.kind.sattel": "Gable dormer",
|
||||
"objinfo.dormer.kind.flach": "Flat-roof dormer",
|
||||
"objinfo.dormer.kind.walm": "Hipped dormer",
|
||||
"objinfo.dormer.remove": "Remove dormer",
|
||||
"objinfo.dormer.width": "Width (outside)",
|
||||
"objinfo.dormer.frontHeight": "Front height",
|
||||
"objinfo.dormer.pitch": "Dormer roof pitch",
|
||||
"objinfo.dormer.depth": "Depth (shed dormer)",
|
||||
"objinfo.dormer.overhang": "Overhang",
|
||||
"objinfo.dormer.wallType": "Wall build-up",
|
||||
"objinfo.dormer.wallType.default": "single layer 15 cm",
|
||||
"objinfo.dormer.roofType": "Roof build-up",
|
||||
"objinfo.dormer.roofType.host": "as main roof",
|
||||
"objinfo.dormer.add": "Place a dormer in a roof face",
|
||||
"objinfo.dormer.addBtn": "Place dormer …",
|
||||
// ── Column attributes (object info panel) ────────────────────────────────
|
||||
"objinfo.column.section": "Column",
|
||||
"objinfo.column.profile": "Profile",
|
||||
@@ -1486,6 +1504,12 @@ export const en: Record<TranslationKey, string> = {
|
||||
"cmd.roof.corner": "Opposite corner:",
|
||||
"cmd.roofWindow.label": "Roof window",
|
||||
"cmd.roofWindow.start": "Centre of the roof window (in a roof face, otherwise skylight in the ceiling):",
|
||||
"cmd.dormer.label": "Dormer",
|
||||
"cmd.dormer.start": "Centre of the dormer front in a sloped roof face:",
|
||||
"cmd.dormer.opt.schlepp": "Shed",
|
||||
"cmd.dormer.opt.sattel": "Gable",
|
||||
"cmd.dormer.opt.flach": "Flat",
|
||||
"cmd.dormer.opt.walm": "Hipped",
|
||||
"cmd.ceilingOpening.label": "Slab opening",
|
||||
"cmd.ceilingOpening.start": "First corner of the opening (inside a slab):",
|
||||
"cmd.ceilingOpening.corner": "Opposite corner:",
|
||||
@@ -2724,6 +2748,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"history.cmd.break": "Break",
|
||||
"history.cmd.ceiling": "Draw ceiling",
|
||||
"history.cmd.roofWindow": "Roof window",
|
||||
"history.cmd.dormer": "Dormer",
|
||||
"history.cmd.ceilingOpening": "Ceiling opening",
|
||||
"history.cmd.chamfer": "Chamfer",
|
||||
"history.cmd.circle": "Draw circle",
|
||||
|
||||
@@ -631,6 +631,41 @@ export type DoorType = {
|
||||
doorFrame?: DoorFrameDetail;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gaube/Lukarne ([G5]) in einer Dachfläche: Stirnwand parallel zur Traufe, Wangen bis an das
|
||||
* Hauptdach, eigenes Dach mit dem Hauptdach verschnitten; das Hauptdach ist an der Gaube in allen
|
||||
* Schichten ausgeschnitten. Das Fenster in der Stirn ist eine `Opening` mit `hostDormerId`.
|
||||
*/
|
||||
export type Dormer = {
|
||||
id: string;
|
||||
kind: DormerKind;
|
||||
/** Mitte der Stirnwand-Aussenseite im Grundriss (Meter); legt auch die Dachfläche fest. */
|
||||
position: Vec2;
|
||||
/** Aussenbreite (Wange aussen bis Wange aussen, Meter). */
|
||||
width: number;
|
||||
/** Stirnhöhe: von der Dach-Oberkante an der Stirn bis Unterkante Gaubendach (Meter). */
|
||||
frontHeight: number;
|
||||
/**
|
||||
* Neigung des Gaubendachs in Grad (Sattel/Walm/Schlepp); fehlt ⇒ Sattel/Walm 40°, Schlepp aus der
|
||||
* Tiefe bzw. 15°, Flach 0.
|
||||
*/
|
||||
pitchDeg?: number;
|
||||
/**
|
||||
* Nur Schleppgaube: waagrechte Tiefe von der Stirn bis zum Anschluss an das Hauptdach (Meter);
|
||||
* gesetzt ⇒ die Neigung folgt daraus.
|
||||
*/
|
||||
depth?: number;
|
||||
/** Dachüberstand an Stirn und Seiten (Meter); fehlt ⇒ 0.15. */
|
||||
overhang?: number;
|
||||
/** Wandtyp für Wangen und Stirn; fehlt ⇒ einschichtig 0.15 m. */
|
||||
wallTypeId?: string;
|
||||
/** Dachtyp des Gaubendachs; fehlt ⇒ der des Hauptdachs. */
|
||||
roofTypeId?: string;
|
||||
};
|
||||
|
||||
/** Gaubenart ([G5]). */
|
||||
export type DormerKind = "schlepp" | "sattel" | "flach" | "walm";
|
||||
|
||||
/** Ein freies 2D-Zeichenelement auf einer Zeichnungsebene. */
|
||||
export type Drawing2D = {
|
||||
id: string;
|
||||
@@ -1801,6 +1836,12 @@ export type Opening = {
|
||||
* Traufe aus. Fehlt ⇒ 0 (x-Achse).
|
||||
*/
|
||||
hostAngle?: number;
|
||||
/**
|
||||
* Wirt Gaube ([G5]): Fenster in der Stirnwand der Gaube `hostDormerId` des Dachs `hostRoofId`.
|
||||
* `position` = Versatz der Fenstermitte von der Stirnmitte (Meter, + nach rechts von aussen),
|
||||
* `sillHeight` = Brüstung über der Dach-Oberkante an der Stirn.
|
||||
*/
|
||||
hostDormerId?: string;
|
||||
/** Übersteuert das Rahmen-Detail des Typs feldweise für diese Öffnung ([105]). */
|
||||
frameDetail?: FrameDetail;
|
||||
/** Ersetzt den Schichteinzug des Typs für diese Öffnung ([106]). */
|
||||
@@ -2308,6 +2349,8 @@ export type Roof = {
|
||||
* der Elementkante.
|
||||
*/
|
||||
surfacePatternOffset?: Vec2;
|
||||
/** Gauben/Lukarnen ([G5]) in den Dachflächen dieses Dachs. Fehlt ⇒ keine. */
|
||||
dormers?: Array<Dormer>;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,8 @@ import { t } from "../i18n";
|
||||
import type { TranslationKey } from "../i18n";
|
||||
import { flattenCategories, formatM } from "../model/types";
|
||||
import type {
|
||||
Dormer,
|
||||
DormerKind,
|
||||
DrawingLevel,
|
||||
RoofShape,
|
||||
SiaCategory,
|
||||
@@ -922,6 +924,103 @@ function rectOutline(x0: number, y0: number, w: number, d: number) {
|
||||
];
|
||||
}
|
||||
|
||||
/** Gauben ([G5]) des Dachs: Art, Masse, Neigung, Aufbau je Gaube; Hinzufügen über den Befehl „Gaube". */
|
||||
function DormersSection({ roof, host }: { roof: RoofInfo; host: ReturnType<typeof usePanelHost> }) {
|
||||
const dormers = roof.dormers ?? [];
|
||||
const patch = (i: number, p: Partial<Dormer>) =>
|
||||
host.onSetRoofPatch({ dormers: dormers.map((d, k) => (k === i ? { ...d, ...p } : d)) }, `dormer-${i}`);
|
||||
const num = (labelKey: TranslationKey, value: number, step: number, apply: (v: number) => void) => (
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t(labelKey)}</span>
|
||||
<input
|
||||
type="number"
|
||||
className="objinfo-text"
|
||||
step={step}
|
||||
value={Number(value.toFixed(2))}
|
||||
onChange={(e) => {
|
||||
const v = Number(e.target.value);
|
||||
if (Number.isFinite(v)) apply(v);
|
||||
}}
|
||||
title={t(labelKey)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<>
|
||||
<div className="objinfo-sep" />
|
||||
<div className="objinfo-section-label">{t("objinfo.dormer.section")}</div>
|
||||
{dormers.map((d, i) => (
|
||||
<div key={d.id} data-testid="objinfo-dormer">
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.dormer.kind")}</span>
|
||||
<Dropdown
|
||||
value={d.kind}
|
||||
onChange={(v) => patch(i, { kind: v as DormerKind })}
|
||||
options={[
|
||||
{ value: "schlepp", label: t("objinfo.dormer.kind.schlepp") },
|
||||
{ value: "sattel", label: t("objinfo.dormer.kind.sattel") },
|
||||
{ value: "flach", label: t("objinfo.dormer.kind.flach") },
|
||||
{ value: "walm", label: t("objinfo.dormer.kind.walm") },
|
||||
]}
|
||||
title={t("objinfo.dormer.kind")}
|
||||
width={130}
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
className="objinfo-typebtn"
|
||||
title={t("objinfo.dormer.remove")}
|
||||
aria-label={t("objinfo.dormer.remove")}
|
||||
onClick={() => host.onSetRoofPatch({ dormers: dormers.filter((_, k) => k !== i) })}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
</div>
|
||||
{num("objinfo.dormer.width", d.width, 0.1, (v) => patch(i, { width: Math.max(0.8, v) }))}
|
||||
{num("objinfo.dormer.frontHeight", d.frontHeight, 0.05, (v) => patch(i, { frontHeight: Math.max(0.5, v) }))}
|
||||
{d.kind !== "flach" &&
|
||||
num("objinfo.dormer.pitch", d.pitchDeg ?? (d.kind === "schlepp" ? 15 : 40), 1, (v) =>
|
||||
patch(i, { pitchDeg: Math.max(0, Math.min(75, v)), depth: undefined }),
|
||||
)}
|
||||
{d.kind === "schlepp" &&
|
||||
num("objinfo.dormer.depth", d.depth ?? 0, 0.1, (v) => patch(i, { depth: v > 0.1 ? v : undefined }))}
|
||||
{num("objinfo.dormer.overhang", d.overhang ?? 0.15, 0.05, (v) => patch(i, { overhang: Math.max(0, v) }))}
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.dormer.wallType")}</span>
|
||||
<Dropdown
|
||||
value={d.wallTypeId ?? ""}
|
||||
onChange={(v) => patch(i, { wallTypeId: v || undefined })}
|
||||
options={[
|
||||
{ value: "", label: t("objinfo.dormer.wallType.default") },
|
||||
...host.project.wallTypes.map((wt) => ({ value: wt.id, label: wt.name })),
|
||||
]}
|
||||
title={t("objinfo.dormer.wallType")}
|
||||
width={130}
|
||||
/>
|
||||
</div>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.dormer.roofType")}</span>
|
||||
<Dropdown
|
||||
value={d.roofTypeId ?? ""}
|
||||
onChange={(v) => patch(i, { roofTypeId: v || undefined })}
|
||||
options={[
|
||||
{ value: "", label: t("objinfo.dormer.roofType.host") },
|
||||
...(host.project.roofTypes ?? []).map((rt) => ({ value: rt.id, label: rt.name })),
|
||||
]}
|
||||
title={t("objinfo.dormer.roofType")}
|
||||
width={130}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<div className="objinfo-field">
|
||||
<button type="button" className="objinfo-typebtn" title={t("objinfo.dormer.add")} onClick={() => host.onRunCommand("dormer")}>
|
||||
{t("objinfo.dormer.addBtn")}
|
||||
</button>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
/** Dach-Abschnitt: Form, Neigung(en), Überstand, Firstrichtung, Dicke. */
|
||||
export function RoofSection({
|
||||
roof,
|
||||
@@ -1092,6 +1191,7 @@ export function RoofSection({
|
||||
<RoofEdgesSection roof={roof} host={host} />
|
||||
)}
|
||||
{/* Innenhöfe: Liste mit Entfernen, Hinzufügen über den Befehl „Dachhof“. */}
|
||||
<DormersSection roof={roof} host={host} />
|
||||
{roof.shape !== "pult" && (
|
||||
<>
|
||||
<div className="objinfo-sep" />
|
||||
|
||||
@@ -355,7 +355,7 @@ const TOOLS_2D: ToolId[] = [
|
||||
"image",
|
||||
];
|
||||
const TOOLS_3D: ToolId[] = ["wall", "ceiling", "window", "door", "stair", "room"];
|
||||
const COMMANDS_3D = ["column", "ceilingopening", "roof", "roofhole", "roofwindow", "extrude", "solid", "solidbool", "sectionline", "viewline", "autodim"];
|
||||
const COMMANDS_3D = ["column", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "solid", "solidbool", "sectionline", "viewline", "autodim"];
|
||||
const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "extend", "fillet", "chamfer", "join", "defblock", "measure"];
|
||||
|
||||
type ToolsView = "list" | "icons";
|
||||
|
||||
@@ -88,6 +88,8 @@ export interface RoofInfo {
|
||||
minY: number;
|
||||
/** Kanten (Umriss, dann Höfe) mit Neigungsvorgabe ([26], `roofEdgeList`). */
|
||||
edges: RoofEdge[];
|
||||
/** Gauben ([G5]) des Dachs, wie gespeichert. */
|
||||
dormers?: import("../model/types").Dormer[];
|
||||
/** Innenhöfe: Fläche (m²) und Punktzahl je Hof, in der Reihenfolge von `Roof.holes`. */
|
||||
holes: { area: number; points: number }[];
|
||||
/** Ob `edgePitchDeg` gesetzt ist. */
|
||||
|
||||
@@ -190,6 +190,15 @@ export function CommandIcon({ name }: { name: string }) {
|
||||
<rect x="6" y="6.5" width="4" height="3" strokeDasharray="1.4 1.2" />
|
||||
</svg>
|
||||
);
|
||||
case "dormer":
|
||||
// Gaube: Dachfläche mit Satteldach-Gaube und Fenster in der Stirn.
|
||||
return (
|
||||
<svg {...common}>
|
||||
<polyline points="2,13 6,5 14,5" />
|
||||
<polygon points="5.5,13 5.5,9 8,6.5 10.5,9 10.5,13" />
|
||||
<rect x="7" y="10" width="2" height="2.5" />
|
||||
</svg>
|
||||
);
|
||||
case "roofwindow":
|
||||
// Dachfenster: Dachfläche mit Fensterrahmen und Glas.
|
||||
return (
|
||||
|
||||
@@ -129,6 +129,44 @@ interface Grip {
|
||||
pos: Vec3;
|
||||
}
|
||||
|
||||
/** Gauben-Griffe: erster Index (Kern `grips.rs::DORMER_GRIP_BASE`). */
|
||||
const DORMER_GRIP_BASE = 1000;
|
||||
|
||||
/** System einer Gaube: Dachfläche über `p` (Normale → `h` nach aussen, `ew` Breite), Höhe dort. */
|
||||
function dormerGripFrame(
|
||||
planes: readonly { pts: readonly (readonly [number, number, number])[] }[],
|
||||
p: Vec2,
|
||||
): { h: [number, number]; ew: [number, number]; z: number; tanMain: number } | null {
|
||||
for (const pl of planes) {
|
||||
const pts = pl.pts;
|
||||
if (pts.length < 3) continue;
|
||||
let inside = false;
|
||||
for (let i = 0, j = pts.length - 1; i < pts.length; j = i++) {
|
||||
const a = pts[i];
|
||||
const b = pts[j];
|
||||
if (a[1] > p.y !== b[1] > p.y && p.x < ((b[0] - a[0]) * (p.y - a[1])) / (b[1] - a[1]) + a[0]) inside = !inside;
|
||||
}
|
||||
if (!inside) continue;
|
||||
let nx = 0;
|
||||
let ny = 0;
|
||||
let nz = 0;
|
||||
for (let i = 0; i < pts.length; i++) {
|
||||
const c = pts[i];
|
||||
const d = pts[(i + 1) % pts.length];
|
||||
nx += (c[1] - d[1]) * (c[2] + d[2]);
|
||||
ny += (c[2] - d[2]) * (c[0] + d[0]);
|
||||
nz += (c[0] - d[0]) * (c[1] + d[1]);
|
||||
}
|
||||
if (nz < 0) [nx, ny, nz] = [-nx, -ny, -nz];
|
||||
const hl = Math.hypot(nx, ny);
|
||||
if (!(hl > 1e-9 && nz > 1e-9)) return null;
|
||||
const h: [number, number] = [nx / hl, ny / hl];
|
||||
const z = pts[0][2] - (nx * (p.x - pts[0][0]) + ny * (p.y - pts[0][1])) / nz;
|
||||
return { h, ew: [-h[1], h[0]], z, tanMain: hl / nz };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alle Griffe der gewählten Wände + 2D-Zeichnungen: pro Wand zwei Endpunkte
|
||||
* (UK), ein Höhen-Griff (Achsmitte, OK) und ein Verschiebe-Griff (Achsmitte,
|
||||
@@ -217,6 +255,25 @@ function computeGrips(
|
||||
// g-Punkte sind MODELL [x, y, z=Höhe] → world [x, Höhe, y].
|
||||
if (apex) out.push({ kind: "roofpitch", target, index: -1, pos: [apex[0], apex[2], apex[1]] });
|
||||
}
|
||||
// Gauben ([G5]): Breiten-Griffe links/rechts der Stirn, Tiefen-Griff (Schleppgaube) hinten; Index ab
|
||||
// DORMER_GRIP_BASE (Kern `grips.rs::dormer_grip`).
|
||||
(roof.dormers ?? []).forEach((d, di) => {
|
||||
const f = dormerGripFrame(g.planes, d.position);
|
||||
if (!f) return;
|
||||
const z = f.z + d.frontHeight;
|
||||
const at = (u: number, v: number, zz: number): Vec3 => [
|
||||
d.position.x + f.ew[0] * u - f.h[0] * v,
|
||||
zz,
|
||||
d.position.y + f.ew[1] * u - f.h[1] * v,
|
||||
];
|
||||
const base = DORMER_GRIP_BASE + di * 10;
|
||||
out.push({ kind: "vertex", target, index: base, pos: at(-d.width / 2, 0, z) });
|
||||
out.push({ kind: "vertex", target, index: base + 1, pos: at(d.width / 2, 0, z) });
|
||||
if (d.kind === "schlepp") {
|
||||
const depth = d.depth ?? d.frontHeight / Math.max(0.05, f.tanMain - Math.tan(((d.pitchDeg ?? 15) * Math.PI) / 180));
|
||||
out.push({ kind: "vertex", target, index: base + 2, pos: at(0, depth, f.z + depth * f.tanMain) });
|
||||
}
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user