Merge [281] Geneigte Decken und Rampen (IFC-Datensatz der geneigten Decke auf 27, 26 bleibt Geländer)
This commit is contained in:
60 files changed
+1273
-66
No files matched your search
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* [281] `rampCommand` — Umriss, Gefällelinie, Gefälle in %: eine Decke mit `slope` (Rampe), OK am Anfang auf dem
|
||||
* Geschossboden; Enter beim Gefälle übernimmt 6 %.
|
||||
*/
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { rampCommand, RAMP_DEFAULT_PERCENT } from "./ramp";
|
||||
import type { CommandContext, CommandState, Project, Vec2 } from "../types";
|
||||
|
||||
function project(): Project {
|
||||
return {
|
||||
id: "t",
|
||||
name: "T",
|
||||
lineStyles: [],
|
||||
hatches: [],
|
||||
components: [{ id: "beton", name: "Beton", color: "#999999", joinPriority: 100 }],
|
||||
wallTypes: [{ id: "aw", name: "AW", layers: [{ componentId: "beton", thickness: 0.2 }] }],
|
||||
ceilingTypes: [{ id: "ct", name: "Platte", layers: [{ componentId: "beton", thickness: 0.25 }] }],
|
||||
drawingLevels: [{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 }],
|
||||
layers: [{ code: "30", name: "Decken", color: "#000000", lw: 0.35, visible: true, locked: false }],
|
||||
walls: [],
|
||||
openings: [],
|
||||
ceilings: [],
|
||||
stairs: [],
|
||||
rooms: [],
|
||||
drawings2d: [],
|
||||
context: [],
|
||||
} as unknown as Project;
|
||||
}
|
||||
|
||||
const ctxOf = (p: Project): CommandContext => ({
|
||||
project: p,
|
||||
level: p.drawingLevels[0],
|
||||
defaultCategoryCode: "30",
|
||||
activeLineStyleId: "solid",
|
||||
activeWallTypeId: "aw",
|
||||
lastPoint: null,
|
||||
selection: { wallIds: [], drawingId: null },
|
||||
});
|
||||
|
||||
function run(pts: Vec2[], percent: number | null): Project {
|
||||
const p = project();
|
||||
const ctx = ctxOf(p);
|
||||
let state: CommandState = rampCommand.init();
|
||||
let commit: ((q: Project) => Project) | undefined;
|
||||
for (const point of pts) {
|
||||
const [ns, res] = rampCommand.onInput(state, { kind: "point", point }, ctx);
|
||||
state = ns;
|
||||
commit = res.commit ?? commit;
|
||||
}
|
||||
const [, res] = percent === null ? rampCommand.onConfirm(state, ctx) : rampCommand.onInput(state, { kind: "number", value: percent }, ctx);
|
||||
commit = res.commit ?? commit;
|
||||
return commit ? commit(p) : p;
|
||||
}
|
||||
|
||||
const outline: Vec2[] = [
|
||||
{ x: 0, y: 0 },
|
||||
{ x: 10, y: 0 },
|
||||
{ x: 10, y: 3 },
|
||||
{ x: 0, y: 3 },
|
||||
{ x: 0, y: 0 }, // Klick auf den Startpunkt schliesst
|
||||
];
|
||||
|
||||
describe("rampCommand", () => {
|
||||
it("Umriss + Gefällelinie + −15 % ergibt eine abwärts geneigte Rampe", () => {
|
||||
const q = run([...outline, { x: 0, y: 1.5 }, { x: 10, y: 1.5 }], -15);
|
||||
const c = q.ceilings![0];
|
||||
expect(c.slope?.ramp).toBe(true);
|
||||
expect(c.slope?.rise).toBeCloseTo(-1.5, 9);
|
||||
expect(c.slope?.from).toEqual({ x: 0, y: 1.5 });
|
||||
expect(c.top).toEqual({ mode: "floor", floorId: "eg", offset: 0 });
|
||||
});
|
||||
|
||||
it("Enter beim Gefälle übernimmt die Vorgabe (6 %)", () => {
|
||||
const q = run([...outline, { x: 0, y: 1.5 }, { x: 5, y: 1.5 }], null);
|
||||
expect(q.ceilings![0].slope?.rise).toBeCloseTo((RAMP_DEFAULT_PERCENT / 100) * 5, 9);
|
||||
});
|
||||
|
||||
it("Gefälle 0 legt nichts an", () => {
|
||||
const q = run([...outline, { x: 0, y: 1.5 }, { x: 5, y: 1.5 }], 0);
|
||||
expect(q.ceilings ?? []).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,133 @@
|
||||
// [281] Rampe — Decke mit Neigung als eigener Befehl: Umriss (wie „Decke"), dann die Gefällelinie (Anfang auf
|
||||
// Geschosshöhe, Ende) und das Gefälle in %. Der Kern (`cmd_create.rs`, `ramp`) legt eine Decke mit `slope`
|
||||
// ({from, to, rise, ramp: true}) und OK am Anfang auf dem Geschossboden an.
|
||||
// Schritte:
|
||||
// 1) „Erster Umrisspunkt der Rampe:" → Punkt
|
||||
// 2) „Nächster Punkt ( Schliessen ):" … Klick auf den Startpunkt, „Schliessen" oder Enter (≥ 3 Punkte)
|
||||
// 3) „Anfang der Gefällelinie:" → Punkt
|
||||
// 4) „Ende der Gefällelinie:" → Punkt
|
||||
// 5) „Gefälle in % (negativ = abwärts) <6>:" → Zahl, Enter = 6 % (SIA 500, rollstuhlgerecht)
|
||||
|
||||
import type { Command, CommandContext, CommandResult, CommandState, CmdOption, DraftShape, ToolDraft, Vec2 } from "../types";
|
||||
import { createMutation, xy } from "../createCore";
|
||||
|
||||
const EPS = 1e-6;
|
||||
const CLOSE_HIT = 0.08;
|
||||
/** Vorgabe, wenn beim Gefälle nur Enter kommt (SIA 500: höchstens 6 %). */
|
||||
export const RAMP_DEFAULT_PERCENT = 6;
|
||||
|
||||
type Phase = "start" | "next" | "from" | "to" | "percent";
|
||||
interface RampState extends CommandState {
|
||||
phase: Phase;
|
||||
points: Vec2[];
|
||||
from?: Vec2;
|
||||
to?: Vec2;
|
||||
cursor: Vec2 | null;
|
||||
}
|
||||
|
||||
const CLOSE: CmdOption = { id: "close", labelKey: "cmd.polyline.close" };
|
||||
const UNDO: CmdOption = { id: "undo", labelKey: "cmd.polyline.undo" };
|
||||
|
||||
const dist = (a: Vec2, b: Vec2) => Math.hypot(b.x - a.x, b.y - a.y);
|
||||
|
||||
function draft(s: RampState): ToolDraft {
|
||||
const closed = s.phase !== "start" && s.phase !== "next";
|
||||
const pts = !closed && s.cursor ? [...s.points, s.cursor] : s.points;
|
||||
const preview: DraftShape[] = [{ kind: "poly", pts, closed: closed || pts.length >= 3 }];
|
||||
const a = s.from;
|
||||
const b = s.to ?? (s.phase === "to" ? s.cursor : null);
|
||||
if (a && b) preview.push({ kind: "poly", pts: [a, b], closed: false });
|
||||
const d: ToolDraft = { preview, vertices: s.points };
|
||||
if (a && b && dist(a, b) > EPS) d.hud = { at: b, text: `${dist(a, b).toFixed(2)} m` };
|
||||
return d;
|
||||
}
|
||||
|
||||
const idle = (): RampState => ({ phase: "start", points: [], cursor: null, lastPoint: null });
|
||||
|
||||
function commit(s: RampState, percent: number, ctx: CommandContext): [CommandState, CommandResult] {
|
||||
const req = { cmd: "ramp", pts: s.points.map(xy), from: xy(s.from!), to: xy(s.to!), percent };
|
||||
return [idle(), { draft: null, done: true, commit: createMutation(ctx, req) }];
|
||||
}
|
||||
|
||||
const closeOutline = (s: RampState): [CommandState, CommandResult] => {
|
||||
const ns: RampState = { ...s, phase: "from", cursor: null, lastPoint: null };
|
||||
return [ns, { draft: draft(ns) }];
|
||||
};
|
||||
|
||||
export const rampCommand: Command = {
|
||||
name: "ramp",
|
||||
labelKey: "cmd.ramp.label",
|
||||
floorOnly: true,
|
||||
prompt: (st) => {
|
||||
const p = (st as RampState).phase;
|
||||
return p === "start" ? "cmd.ramp.start" : p === "next" ? "cmd.ramp.next" : p === "from" ? "cmd.ramp.from" : p === "to" ? "cmd.ramp.to" : "cmd.ramp.percent";
|
||||
},
|
||||
accepts: (st) => {
|
||||
const p = (st as RampState).phase;
|
||||
return p === "percent" ? ["number"] : p === "next" ? ["point", "number", "option"] : ["point", "number"];
|
||||
},
|
||||
options: (st) => {
|
||||
const s = st as RampState;
|
||||
if (s.phase !== "next") return [];
|
||||
return s.points.length >= 3 ? [CLOSE, UNDO] : [UNDO];
|
||||
},
|
||||
init: () => idle(),
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as RampState;
|
||||
if (input.kind === "option") {
|
||||
if (s.phase !== "next") return [s, { draft: draft(s) }];
|
||||
if (input.id === "undo") {
|
||||
const points = s.points.slice(0, -1);
|
||||
if (points.length === 0) return [idle(), { draft: null }];
|
||||
const ns = { ...s, points, lastPoint: points[points.length - 1] };
|
||||
return [ns, { draft: draft(ns) }];
|
||||
}
|
||||
if (input.id === "close" && s.points.length >= 3) return closeOutline(s);
|
||||
return [s, { draft: draft(s) }];
|
||||
}
|
||||
if (s.phase === "percent") {
|
||||
if (input.kind !== "number" || !isFinite(input.value) || input.value === 0) return [s, { draft: draft(s) }];
|
||||
return commit(s, input.value, ctx);
|
||||
}
|
||||
if (input.kind !== "point") return [s, { draft: s.phase === "start" ? null : draft(s) }];
|
||||
const pt = input.point;
|
||||
switch (s.phase) {
|
||||
case "start": {
|
||||
const ns: RampState = { phase: "next", points: [pt], cursor: pt, lastPoint: pt };
|
||||
return [ns, { draft: draft(ns) }];
|
||||
}
|
||||
case "next": {
|
||||
if (s.points.length >= 3 && dist(s.points[0], pt) < CLOSE_HIT) return closeOutline(s);
|
||||
if (dist(s.points[s.points.length - 1], pt) < EPS) return [s, { draft: draft(s) }];
|
||||
const ns: RampState = { ...s, points: [...s.points, pt], cursor: pt, lastPoint: pt };
|
||||
return [ns, { draft: draft(ns) }];
|
||||
}
|
||||
case "from": {
|
||||
const ns: RampState = { ...s, phase: "to", from: pt, cursor: pt, lastPoint: pt };
|
||||
return [ns, { draft: draft(ns) }];
|
||||
}
|
||||
default: {
|
||||
if (!s.from || dist(s.from, pt) < 0.01) return [s, { draft: draft(s) }];
|
||||
const ns: RampState = { ...s, phase: "percent", to: pt, cursor: null, lastPoint: pt };
|
||||
return [ns, { draft: draft(ns) }];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onMove: (state, point): [CommandState, CommandResult] => {
|
||||
const s = state as RampState;
|
||||
if (s.phase === "start") return [s, { draft: null }];
|
||||
const ns: RampState = { ...s, cursor: point };
|
||||
return [ns, { draft: draft(ns) }];
|
||||
},
|
||||
|
||||
// Enter: Umriss schliessen (≥ 3 Punkte) bzw. beim Gefälle die Vorgabe übernehmen.
|
||||
onConfirm: (state, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as RampState;
|
||||
if (s.phase === "next" && s.points.length >= 3) return closeOutline(s);
|
||||
if (s.phase === "percent") return commit(s, RAMP_DEFAULT_PERCENT, ctx);
|
||||
return [idle(), { draft: null, done: true }];
|
||||
},
|
||||
onCancel: (): [CommandState, CommandResult] => [idle(), { draft: null, done: true }],
|
||||
};
|
||||
@@ -21,6 +21,7 @@ import { solidBoolCommand } from "./cmds/solidbool";
|
||||
import { solidToPartsCommand } from "./cmds/solidToParts";
|
||||
import { voidBoxCommand } from "./cmds/voidbox";
|
||||
import { ceilingOpeningCommand } from "./cmds/ceilingOpening";
|
||||
import { rampCommand } from "./cmds/ramp";
|
||||
import { roofWindowCommand } from "./cmds/roofWindow";
|
||||
import { dormerCommand } from "./cmds/dormer";
|
||||
import { roofHoleCommand } from "./cmds/roofHole";
|
||||
@@ -103,6 +104,7 @@ export const COMMANDS: Record<string, Command> = {
|
||||
solidtoparts: solidToPartsCommand,
|
||||
voidbox: voidBoxCommand,
|
||||
ceilingopening: ceilingOpeningCommand,
|
||||
ramp: rampCommand,
|
||||
roofwindow: roofWindowCommand,
|
||||
dormer: dormerCommand,
|
||||
roofhole: roofHoleCommand,
|
||||
@@ -216,6 +218,7 @@ export const ALIASES: Record<string, string> = {
|
||||
kugel: "solid",
|
||||
body: "solid",
|
||||
deckenloch: "ceilingopening",
|
||||
rampe: "ramp",
|
||||
aussparung: "ceilingopening",
|
||||
dachfenster: "roofwindow",
|
||||
oberlicht: "roofwindow",
|
||||
|
||||
@@ -664,6 +664,18 @@ export const de = {
|
||||
"objinfo.ceiling.top": "Oberkante (OK)",
|
||||
"objinfo.ceiling.bottom": "Unterkante (UK)",
|
||||
"objinfo.ceiling.height": "Dicke (OK−UK)",
|
||||
"objinfo.ceiling.slope.section": "Neigung",
|
||||
"objinfo.ceiling.slope.off": "aus",
|
||||
"objinfo.ceiling.slope.on": "Gefälle",
|
||||
"objinfo.ceiling.slope.ramp": "Rampe",
|
||||
"objinfo.ceiling.slope.percent": "Gefälle",
|
||||
"objinfo.ceiling.slope.angle": "Neigungswinkel",
|
||||
"objinfo.ceiling.slope.rise": "Höhenunterschied",
|
||||
"objinfo.ceiling.slope.direction": "Richtung (aufwärts)",
|
||||
"objinfo.ceiling.slope.refX": "Bezugspunkt X",
|
||||
"objinfo.ceiling.slope.refY": "Bezugspunkt Y",
|
||||
"objinfo.ceiling.slope.length": "Länge Gefällelinie",
|
||||
"objinfo.ceiling.slope.hint": "Am Bezugspunkt liegt die Decke auf der eingestellten OK/UK; in Richtung aufwärts steigt sie um den Höhenunterschied (Schichten folgen, Dicke lotrecht).",
|
||||
"objinfo.ceiling.openings": "Aussparungen",
|
||||
"objinfo.ceiling.removeOpening": "Aussparung entfernen",
|
||||
"objinfo.ceiling.area": "Fläche",
|
||||
@@ -2039,6 +2051,12 @@ export const de = {
|
||||
"cmd.ceiling.label": "Decke",
|
||||
"cmd.ceiling.start": "Erster Umrisspunkt der Decke:",
|
||||
"cmd.ceiling.next": "Nächster Punkt ( Schliessen ):",
|
||||
"cmd.ramp.label": "Rampe",
|
||||
"cmd.ramp.start": "Erster Umrisspunkt der Rampe:",
|
||||
"cmd.ramp.next": "Nächster Punkt ( Schliessen ):",
|
||||
"cmd.ramp.from": "Anfang der Gefällelinie (auf Geschosshöhe):",
|
||||
"cmd.ramp.to": "Ende der Gefällelinie:",
|
||||
"cmd.ramp.percent": "Gefälle in % (negativ = abwärts) <6>:",
|
||||
"cmd.solidbool.label": "Körper verschneiden",
|
||||
"cmd.solidbool.first": "Ersten Körper wählen:",
|
||||
"cmd.solidbool.second": "Zweiten Körper wählen:",
|
||||
@@ -3954,6 +3972,7 @@ export const de = {
|
||||
"history.cmd.block": "Block einfügen",
|
||||
"history.cmd.break": "Auftrennen",
|
||||
"history.cmd.ceiling": "Decke zeichnen",
|
||||
"history.cmd.ramp": "Rampe zeichnen",
|
||||
"history.cmd.roofWindow": "Dachfenster",
|
||||
"history.cmd.dormer": "Gaube",
|
||||
"history.cmd.ceilingOpening": "Deckenöffnung",
|
||||
|
||||
@@ -663,6 +663,18 @@ export const en: Record<TranslationKey, string> = {
|
||||
"objinfo.ceiling.top": "Top (OK)",
|
||||
"objinfo.ceiling.bottom": "Bottom (UK)",
|
||||
"objinfo.ceiling.height": "Thickness (OK−UK)",
|
||||
"objinfo.ceiling.slope.section": "Slope",
|
||||
"objinfo.ceiling.slope.off": "off",
|
||||
"objinfo.ceiling.slope.on": "Slope",
|
||||
"objinfo.ceiling.slope.ramp": "Ramp",
|
||||
"objinfo.ceiling.slope.percent": "Gradient",
|
||||
"objinfo.ceiling.slope.angle": "Slope angle",
|
||||
"objinfo.ceiling.slope.rise": "Height difference",
|
||||
"objinfo.ceiling.slope.direction": "Direction (upward)",
|
||||
"objinfo.ceiling.slope.refX": "Reference point X",
|
||||
"objinfo.ceiling.slope.refY": "Reference point Y",
|
||||
"objinfo.ceiling.slope.length": "Slope line length",
|
||||
"objinfo.ceiling.slope.hint": "At the reference point the slab sits at its set top/bottom; in the upward direction it rises by the height difference (layers follow, thickness measured vertically).",
|
||||
"objinfo.ceiling.openings": "Openings",
|
||||
"objinfo.ceiling.removeOpening": "Remove opening",
|
||||
"objinfo.ceiling.area": "Area",
|
||||
@@ -2028,6 +2040,12 @@ export const en: Record<TranslationKey, string> = {
|
||||
"cmd.ceiling.label": "Ceiling",
|
||||
"cmd.ceiling.start": "First outline point of ceiling:",
|
||||
"cmd.ceiling.next": "Next point ( Close ):",
|
||||
"cmd.ramp.label": "Ramp",
|
||||
"cmd.ramp.start": "First outline point of the ramp:",
|
||||
"cmd.ramp.next": "Next point ( Close ):",
|
||||
"cmd.ramp.from": "Start of the slope line (at storey level):",
|
||||
"cmd.ramp.to": "End of the slope line:",
|
||||
"cmd.ramp.percent": "Gradient in % (negative = downward) <6>:",
|
||||
"cmd.solidbool.label": "Boolean solids",
|
||||
"cmd.solidbool.first": "Select first solid:",
|
||||
"cmd.solidbool.second": "Select second solid:",
|
||||
@@ -3940,6 +3958,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"history.cmd.block": "Insert block",
|
||||
"history.cmd.break": "Break",
|
||||
"history.cmd.ceiling": "Draw ceiling",
|
||||
"history.cmd.ramp": "Draw ramp",
|
||||
"history.cmd.roofWindow": "Roof window",
|
||||
"history.cmd.dormer": "Dormer",
|
||||
"history.cmd.ceilingOpening": "Ceiling opening",
|
||||
|
||||
@@ -36,8 +36,10 @@ describe("Beispielprojekt Wettbewerb", () => {
|
||||
expect(p.rooms!.filter((r) => r.floorId === f).length).toBe(10);
|
||||
}
|
||||
// [279] zwei Balkonplatten mit Geländer (Stäbe 1. OG, Glas 2. OG)
|
||||
expect(p.ceilings!.length).toBe(5);
|
||||
expect(p.ceilings!.length).toBe(6);
|
||||
expect(p.railings!.map((r) => r.kind)).toEqual(["bars", "glass"]);
|
||||
// [281] Eingangsrampe (6 %) an der Ostfassade.
|
||||
expect(p.ceilings!.find((c) => c.id === "c-rampe")?.slope?.ramp).toBe(true);
|
||||
expect(p.roofs![0].shape).toBe("flach");
|
||||
expect(p.stairs!.length).toBe(2);
|
||||
expect(p.rooms!.length).toBe(30);
|
||||
|
||||
@@ -64,6 +64,7 @@ const LEVELS: DrawingLevel[] = [
|
||||
const CEILING_TYPES: CeilingType[] = [
|
||||
{ id: "wb-ct-decke", name: "Geschossdecke Unterlagsboden, Trittschall, STB 37 cm", layers: [L("std-c-parkett", 0.015), L("std-c-zementestrich", 0.065), L("std-c-trittschall", 0.04), L("std-c-stahlbeton", 0.24), L("std-c-innenputz", 0.01)] },
|
||||
{ id: "wb-ct-bodenplatte", name: "Bodenplatte STB auf XPS", layers: [L("std-c-zementestrich", 0.08), L("std-c-xps", 0.12), L("std-c-stahlbeton", 0.25), L("std-c-kies", 0.1)] },
|
||||
{ id: "wb-ct-rampe", name: "Rampe STB auf Kies", layers: [L("std-c-stahlbeton", 0.22), L("std-c-kies", 0.15)] },
|
||||
];
|
||||
const ROOF_TYPES: RoofType[] = [{ id: "wb-rt-flach", name: "Flachdach Umkehrdach bekiest", layers: [L("std-c-kies", 0.06), L("std-c-xps", 0.18), L("std-c-stahlbeton", 0.22)] }];
|
||||
const WINDOW_TYPES: WindowType[] = [
|
||||
@@ -148,6 +149,12 @@ const ceilings: NonNullable<Project["ceilings"]> = [
|
||||
{ id: "c-bodenplatte", type: "ceiling", floorId: "eg", categoryCode: "30", outline: slab, wallTypeId: "", ceilingTypeId: "wb-ct-bodenplatte", top: { mode: "floor", floorId: "eg", offset: 0 }, loadBearing: true },
|
||||
{ id: "c-eg", type: "ceiling", floorId: "eg", categoryCode: "30", outline: slab, openings: [HOLE], wallTypeId: "", ceilingTypeId: "wb-ct-decke", loadBearing: true },
|
||||
{ id: "c-og1", type: "ceiling", floorId: "og1", categoryCode: "30", outline: slab, openings: [HOLE], wallTypeId: "", ceilingTypeId: "wb-ct-decke", loadBearing: true },
|
||||
// [281] Eingangsrampe an der Ostfassade (im Schnitt B-B längs): 6 m mit 6 % vom Gelände (−0.36) bis ±0.00.
|
||||
{
|
||||
id: "c-rampe", type: "ceiling", floorId: "eg", categoryCode: "30", outline: [P(W + HA, 2), P(W + HA + 6, 2), P(W + HA + 6, 5), P(W + HA, 5)],
|
||||
wallTypeId: "", ceilingTypeId: "wb-ct-rampe", top: { mode: "floor", floorId: "eg", offset: 0 }, isExternal: true,
|
||||
slope: { from: P(W + HA, 3.5), to: P(W + HA + 6, 3.5), rise: -0.36, ramp: true },
|
||||
},
|
||||
];
|
||||
// [279] Balkone an der Südfassade (Wohnung West): Betonplatte 1.4 m tief über dem EG bzw. 1. OG, Geländer an den drei freien
|
||||
// Seiten — Stäbe im 1. OG, Glas im 2. OG. Fusshöhe auf der Plattenoberkante (Geschoss-UK), Höhe 1.00 m nach SIA 358.
|
||||
|
||||
@@ -222,6 +222,8 @@ export type Ceiling = {
|
||||
* Z-Wert; „floor" bindet die UK an ein Geschoss.
|
||||
*/
|
||||
bottom?: VerticalAnchor;
|
||||
/** [281] Neigung (geneigte Decke, Rampe, Gefälle). Fehlt ⇒ waagrecht. */
|
||||
slope?: CeilingSlope;
|
||||
/** [271] Umbau: Status (Bestand, Abbruch, Neu) und Etappe. Fehlt ⇒ Bestand. */
|
||||
renovation?: Renovation;
|
||||
/**
|
||||
@@ -230,6 +232,26 @@ export type Ceiling = {
|
||||
designOption?: DesignOptionRef;
|
||||
};
|
||||
|
||||
/**
|
||||
* [281] Neigung einer Decke oder Rampe: Ober- und Unterkante (alle Schichten) folgen einer Ebene, die
|
||||
* längs der Gefällelinie `from` → `to` gleichmässig steigt oder fällt. Am Bezugspunkt `from` liegt die Decke
|
||||
* auf ihrer eingestellten Höhe (`top`/`bottom`); bei `to` um `rise` höher (negativ = tiefer). Quer zur
|
||||
* Gefällelinie bleibt die Höhe gleich. Die Dicke bleibt lotrecht gemessen (Schichten verschoben, nicht gedreht).
|
||||
* Gefälle in % = `rise` / |`to` − `from`| · 100.
|
||||
*/
|
||||
export type CeilingSlope = {
|
||||
/** Bezugspunkt im Grundriss (Meter): dort gilt die eingestellte Höhe der Decke. */
|
||||
from: Vec2;
|
||||
/** Zweiter Punkt der Gefällelinie (Meter); die Richtung `from` → `to` ist die Fallinie. */
|
||||
to: Vec2;
|
||||
/** Höhenunterschied der Decke von `from` nach `to` (Meter; positiv = steigt zu `to`). */
|
||||
rise: number;
|
||||
/**
|
||||
* Als Rampe darstellen: Grundriss mit Lauflinie und Pfeil (aufwärts), IFC als `IfcRamp`/`IfcRampFlight`.
|
||||
*/
|
||||
ramp?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* Ein Deckentyp (Deckenstil) = geordneter Schichtaufbau EINER Decke, liegend
|
||||
* gestapelt (oben → unten) — das horizontale Gegenstück zum `WallType`. Nutzt
|
||||
|
||||
@@ -379,7 +379,7 @@ const TOOLS_2D: ToolId[] = [
|
||||
"image",
|
||||
];
|
||||
const TOOLS_3D: ToolId[] = ["wall", "ceiling", "window", "door", "stair", "room"];
|
||||
const COMMANDS_3D = ["column", "gelaender", "tree", "circlestotrees", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "solidtoparts", "sectionline", "viewline", "ansichten", "autodim", "excavation"];
|
||||
const COMMANDS_3D = ["column", "gelaender", "tree", "circlestotrees", "ceilingopening", "ramp", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "solidtoparts", "sectionline", "viewline", "ansichten", "autodim", "excavation"];
|
||||
const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "split", "extend", "fillet", "chamfer", "join", "defblock", "measure", "erkennen"];
|
||||
|
||||
type ToolsView = "list" | "icons";
|
||||
|
||||
@@ -35,6 +35,7 @@ import type {
|
||||
Stair,
|
||||
StairShape,
|
||||
Vec2,
|
||||
CeilingSlope,
|
||||
VerticalAnchor,
|
||||
WallReferenceLine,
|
||||
WallType,
|
||||
@@ -451,6 +452,11 @@ export interface PanelHostValue {
|
||||
* haben — additive Erweiterung analog `onSetWallBottom`.
|
||||
*/
|
||||
onSetCeilingBottom?: (anchor: VerticalAnchor | null) => void;
|
||||
/**
|
||||
* [281] Neigung der gewählten Decke(n) setzen (`null` = waagrecht). `"enable"` schaltet sie mit einer Vorgabe ein:
|
||||
* Gefällelinie längs der längeren Seite der Hüllbox, Bezugspunkt in deren Mitte am Anfang, 2 % bzw. als Rampe 6 %.
|
||||
*/
|
||||
onSetCeilingSlope?: (slope: CeilingSlope | null | { enable: "slope" | "ramp" }) => void;
|
||||
|
||||
// ── Öffnungs-Attribute (Object-Info-Panel; nur die selektierte Öffnung) ─
|
||||
/** Wechselt die Art (Fenster/Tür); setzt bei Tür die Tür-Defaults. */
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
import { useStore } from "../../state/appStore";
|
||||
import type { CeilingInfo } from "../../state/selectionInfo";
|
||||
import type { CeilingSlope } from "../../model/types";
|
||||
import { usePanelHost } from "../host";
|
||||
import { t } from "../../i18n";
|
||||
import { Dropdown } from "../../ui/Dropdown";
|
||||
@@ -174,6 +175,114 @@ export function CeilingSection({
|
||||
<span className="objinfo-flabel">{t("objinfo.ceiling.height")}</span>
|
||||
<span className="objinfo-fval">{formatM(ceiling.zTop - ceiling.zBottom)}</span>
|
||||
</div>
|
||||
<SlopeRows ceiling={ceiling} host={host} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
const DEG = Math.PI / 180;
|
||||
|
||||
/**
|
||||
* [281] Abschnitt „Neigung": aus / Gefälle / Rampe; Gefälle in % und Grad, Höhenunterschied, Richtung (aufwärts) und
|
||||
* Bezugspunkt. Gespeichert wird nur `slope` ({from, to, rise, ramp}); die Felder rechnen daraus um.
|
||||
*/
|
||||
function SlopeRows({ ceiling, host }: { ceiling: CeilingInfo; host: ReturnType<typeof usePanelHost> }) {
|
||||
const s = ceiling.slope;
|
||||
const mode: "off" | "on" | "ramp" = !s ? "off" : s.ramp ? "ramp" : "on";
|
||||
const len = s ? Math.hypot(s.to.x - s.from.x, s.to.y - s.from.y) : 0;
|
||||
const pct = s && len > 1e-9 ? (s.rise / len) * 100 : 0;
|
||||
// Richtung aufwärts: von `from` nach `to`, bei negativem Höhenunterschied umgekehrt.
|
||||
const dirDeg = s ? (((Math.atan2(s.to.y - s.from.y, s.to.x - s.from.x) / DEG + (s.rise < 0 ? 180 : 0)) % 360) + 360) % 360 : 0;
|
||||
const set = (patch: Partial<CeilingSlope>) => {
|
||||
if (s) host.onSetCeilingSlope?.({ ...s, ...patch });
|
||||
};
|
||||
const setRise = (rise: number) => {
|
||||
if (isFinite(rise) && rise !== 0) set({ rise });
|
||||
};
|
||||
const choose = (m: "off" | "on" | "ramp") => {
|
||||
if (m === mode) return;
|
||||
if (m === "off") host.onSetCeilingSlope?.(null);
|
||||
else host.onSetCeilingSlope?.({ enable: m === "ramp" ? "ramp" : "slope" });
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<div className="objinfo-sep" />
|
||||
<div className="objinfo-section-label" title={t("objinfo.ceiling.slope.hint")}>
|
||||
{t("objinfo.ceiling.slope.section")}
|
||||
</div>
|
||||
<div className="objinfo-field">
|
||||
<div className="objinfo-segment" data-testid="objinfo-ceiling-slope-mode">
|
||||
{(["off", "on", "ramp"] as const).map((m) => (
|
||||
<button
|
||||
key={m}
|
||||
type="button"
|
||||
data-testid={`objinfo-ceiling-slope-${m}`}
|
||||
className={"objinfo-seg-btn" + (mode === m ? " active" : "")}
|
||||
onClick={() => choose(m)}
|
||||
>
|
||||
{t(`objinfo.ceiling.slope.${m}`)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{s && (
|
||||
<>
|
||||
<div data-testid="objinfo-ceiling-slope-percent">
|
||||
<DimensionField
|
||||
label={t("objinfo.ceiling.slope.percent")}
|
||||
value={Math.abs(pct)}
|
||||
unit="%"
|
||||
digits={1}
|
||||
step={0.5}
|
||||
min={0}
|
||||
onCommit={(v) => setRise(Math.sign(s.rise || 1) * (v / 100) * len)}
|
||||
/>
|
||||
</div>
|
||||
<DimensionField
|
||||
label={t("objinfo.ceiling.slope.angle")}
|
||||
value={Math.atan(Math.abs(pct) / 100) / DEG}
|
||||
unit="°"
|
||||
digits={2}
|
||||
step={0.5}
|
||||
min={0}
|
||||
onCommit={(v) => v < 89 && setRise(Math.sign(s.rise || 1) * Math.tan(v * DEG) * len)}
|
||||
/>
|
||||
<DimensionField
|
||||
label={t("objinfo.ceiling.slope.rise")}
|
||||
value={Math.abs(s.rise)}
|
||||
min={0}
|
||||
onCommit={(v) => setRise(Math.sign(s.rise || 1) * v)}
|
||||
/>
|
||||
<DimensionField
|
||||
label={t("objinfo.ceiling.slope.direction")}
|
||||
value={dirDeg}
|
||||
unit="°"
|
||||
digits={1}
|
||||
min={-360}
|
||||
onCommit={(a) => {
|
||||
// Gefällelinie dreht um den Bezugspunkt; aufwärts = Richtung, der Höhenunterschied wird positiv.
|
||||
const r = a * DEG;
|
||||
set({ to: { x: s.from.x + Math.cos(r) * len, y: s.from.y + Math.sin(r) * len }, rise: Math.abs(s.rise) });
|
||||
}}
|
||||
/>
|
||||
<DimensionField
|
||||
label={t("objinfo.ceiling.slope.refX")}
|
||||
value={s.from.x}
|
||||
min={-Infinity}
|
||||
onCommit={(x) => set({ from: { x, y: s.from.y }, to: { x: s.to.x + x - s.from.x, y: s.to.y } })}
|
||||
/>
|
||||
<DimensionField
|
||||
label={t("objinfo.ceiling.slope.refY")}
|
||||
value={s.from.y}
|
||||
min={-Infinity}
|
||||
onCommit={(y) => set({ from: { x: s.from.x, y }, to: { x: s.to.x, y: s.to.y + y - s.from.y } })}
|
||||
/>
|
||||
<div className="objinfo-field">
|
||||
<span className="objinfo-flabel">{t("objinfo.ceiling.slope.length")}</span>
|
||||
<span className="objinfo-fval">{formatM(len)}</span>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -58,6 +58,8 @@ export interface PickSlab {
|
||||
zBottom: number;
|
||||
zTop: number;
|
||||
ceilingId: string;
|
||||
/** [281] Geneigte Decke: Neigungsebene `[ox, oy, gx, gy]`, Höhe + gx·(x−ox) + gy·(y−oy). */
|
||||
slope?: readonly [number, number, number, number];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -201,6 +201,8 @@ export interface RSlab {
|
||||
* render3d `SlabInput::monolith`.
|
||||
*/
|
||||
monolith?: string;
|
||||
/** [281] Geneigte Decke/Rampe: Neigungsebene `[ox, oy, gx, gy]` (render3d `SlabInput::slope`). */
|
||||
slope?: [number, number, number, number];
|
||||
}
|
||||
|
||||
/** Art eines rohen Kontext-Meshes (bestimmt in render3d die Default-Einfärbung). */
|
||||
|
||||
@@ -137,6 +137,33 @@ export function buildElementAttributesHost(c: FlatHostOpts) {
|
||||
onSetCeilingBottom: (anchor) => {
|
||||
if (selection?.kind === "ceiling") patchAll("ceilings", selection.id, { bottom: anchor ?? undefined });
|
||||
},
|
||||
onSetCeilingSlope: (slope) => {
|
||||
if (selection?.kind !== "ceiling") return;
|
||||
if (slope === null) return patchAll("ceilings", selection.id, { slope: undefined });
|
||||
if (!("enable" in slope)) return patchAll("ceilings", selection.id, { slope }, "ceiling-slope");
|
||||
// [281] Einschalten: je Decke eine Vorgabe aus ihrer Hüllbox (längere Seite = Gefällelinie, aufwärts).
|
||||
const ramp = slope.enable === "ramp";
|
||||
const ids = targetIds("ceilings", selection.id);
|
||||
getState().groupChanges(() => {
|
||||
for (const id of ids) {
|
||||
const c = (getState().project.ceilings ?? []).find((x) => x.id === id);
|
||||
if (!c || c.outline.length < 3) continue;
|
||||
if (c.slope) {
|
||||
updateCeiling(id, { slope: { ...c.slope, ramp: ramp || undefined } });
|
||||
continue;
|
||||
}
|
||||
const xs = c.outline.map((q) => q.x);
|
||||
const ys = c.outline.map((q) => q.y);
|
||||
const [x0, x1, y0, y1] = [Math.min(...xs), Math.max(...xs), Math.min(...ys), Math.max(...ys)];
|
||||
const alongX = x1 - x0 >= y1 - y0;
|
||||
const from = alongX ? { x: x0, y: (y0 + y1) / 2 } : { x: (x0 + x1) / 2, y: y0 };
|
||||
const to = alongX ? { x: x1, y: (y0 + y1) / 2 } : { x: (x0 + x1) / 2, y: y1 };
|
||||
const len = Math.hypot(to.x - from.x, to.y - from.y);
|
||||
if (!(len > 0.01)) continue;
|
||||
updateCeiling(id, { slope: { from, to, rise: (ramp ? 0.06 : 0.02) * len, ramp: ramp || undefined } });
|
||||
}
|
||||
});
|
||||
},
|
||||
// ── Öffnungs-Attribute (nur bei selektierter Öffnung) ──────────────────
|
||||
onSetOpeningKind: (kind) => {
|
||||
if (selection?.kind === "opening")
|
||||
|
||||
@@ -19,6 +19,7 @@ import { EMPTY_SELECTION, mergeSelection, single } from "./selection";
|
||||
import type { Selection } from "./selection";
|
||||
import type {
|
||||
AttributeSource,
|
||||
CeilingSlope,
|
||||
DimRef,
|
||||
ColumnProfile,
|
||||
ContextImage,
|
||||
@@ -200,6 +201,8 @@ export interface CeilingInfo {
|
||||
/** Aufgelöste absolute UK/OK (Meter). */
|
||||
zBottom: number;
|
||||
zTop: number;
|
||||
/** [281] Neigung (geneigte Decke/Rampe); fehlt = waagrecht. */
|
||||
slope?: CeilingSlope;
|
||||
/** Aussparungen (Treppenauge/Schacht) als BBox-Masse, Reihenfolge = Modell. */
|
||||
openings: { width: number; depth: number }[];
|
||||
}
|
||||
|
||||
@@ -59,6 +59,8 @@ declare global {
|
||||
fakeRender: () => void;
|
||||
/** [173] Linien einer Klasse (z. B. "door-lintel") im Grundriss der aktiven Ebene (alle Kategorien, 1:50, Detailgrad der Anzeige). */
|
||||
planLines: (cls: string) => number;
|
||||
/** [281] Neigung je Decke (`id` → {rise, ramp}; waagrecht fehlt). */
|
||||
ceilingSlopes: () => Record<string, { rise: number; ramp: boolean }>;
|
||||
/** [173] Modelldarstellung der aktiven Ebene (Feld `modelViewOptionId`). */
|
||||
modelView: () => string | undefined;
|
||||
/** [173] Schnitt der aktiven Ebene (1:50, Detailgrad der Anzeige): Zahl der Wand-Schnittflächen und ihre Fläche (m²). */
|
||||
@@ -157,6 +159,8 @@ export function installTestHooks(): void {
|
||||
},
|
||||
notices: () => getState().notifications.map((n) => n.message),
|
||||
fakeRender: () => fakeRender(),
|
||||
ceilingSlopes: () =>
|
||||
Object.fromEntries((getState().project.ceilings ?? []).flatMap((c) => (c.slope ? [[c.id, { rise: c.slope.rise, ramp: !!c.slope.ramp }]] : []))),
|
||||
planLines: (cls) => {
|
||||
const s = getState();
|
||||
const codes = new Set<string>();
|
||||
|
||||
@@ -269,6 +269,15 @@ export const CommandIcon = memo(function CommandIcon({ name }: { name: string })
|
||||
<line x1="6.2" y1="8" x2="9.8" y2="8" />
|
||||
</svg>
|
||||
);
|
||||
case "ramp":
|
||||
// [281] Rampe: geneigte Platte mit Lauflinie und Pfeil.
|
||||
return (
|
||||
<svg {...common}>
|
||||
<polygon points="2,12 14,7 14,10 2,14" />
|
||||
<line x1="4" y1="11.4" x2="11.5" y2="8.3" />
|
||||
<polyline points="9.6,7.8 11.5,8.3 10.6,10" />
|
||||
</svg>
|
||||
);
|
||||
case "ceilingopening":
|
||||
// Deckenloch: Decken-Rechteck mit ausgespartem Innenrechteck.
|
||||
return (
|
||||
|
||||
@@ -107,6 +107,15 @@ const SLAB: PickSlab = {
|
||||
};
|
||||
|
||||
describe("raySlabPrism", () => {
|
||||
it("[281] geneigte Platte: Deckel um den Versatz der Neigungsebene höher", () => {
|
||||
// Steigt 15 % nach +x: bei x = 3 liegt die OK auf 3.0 + 0.45 = 3.45 → senkrecht von y = 10: t = 6.55.
|
||||
const sloped = { ...SLAB, slope: [0, 0, 0.15, 0] as const };
|
||||
expect(raySlabPrism({ origin: [3, 10, 2], dir: [0, -1, 0] }, sloped)!).toBeCloseTo(6.55, 6);
|
||||
// Waagrechter Strahl auf 3.2: an der Seite x = 0 (2.9..3.0) vorbei, trifft die steigende Oberseite bei
|
||||
// 3.0 + 0.15·x = 3.2 → x = 4/3 (Strahl von −5 aus: t = 19/3).
|
||||
expect(raySlabPrism({ origin: [-5, 3.2, 2], dir: [1, 0, 0] }, sloped)!).toBeCloseTo(19 / 3, 6);
|
||||
});
|
||||
|
||||
it("Strahl von oben trifft den Deckel (kleinstes t)", () => {
|
||||
// eye (2,10,2) senkrecht nach unten: Deckel y=3 bei t=7.
|
||||
const t = raySlabPrism({ origin: [2, 10, 2], dir: [0, -1, 0] }, SLAB);
|
||||
|
||||
@@ -301,7 +301,14 @@ function rayPrismXZ(
|
||||
* oder null — s. {@link rayPrismXZ}.
|
||||
*/
|
||||
export function raySlabPrism(ray: Ray, slab: PickSlab): number | null {
|
||||
return rayPrismXZ(ray, slab.outline, slab.zBottom, slab.zTop);
|
||||
const g = slab.slope;
|
||||
if (!g) return rayPrismXZ(ray, slab.outline, slab.zBottom, slab.zTop);
|
||||
// [281] Geneigte Platte: in den ungescherten Raum abbilden (Höhe − Versatz der Neigungsebene). Die Scherung ist
|
||||
// affin, der Strahlparameter t bleibt also gleich.
|
||||
const [ox, oz] = [ray.origin[0], ray.origin[2]];
|
||||
const origin: Vec3 = [ox, ray.origin[1] - (g[2] * (ox - g[0]) + g[3] * (oz - g[1])), oz];
|
||||
const dir: Vec3 = [ray.dir[0], ray.dir[1] - (g[2] * ray.dir[0] + g[3] * ray.dir[2]), ray.dir[2]];
|
||||
return rayPrismXZ({ ...ray, origin, dir }, slab.outline, slab.zBottom, slab.zTop);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user