Merge remote-tracking branch 'origin/master' into worktree-agent-a9be96500bed68810
# Conflicts: # TODO.md
This commit is contained in:
36 files changed
+1412
-55
No files matched your search
+3
-18
@@ -66,7 +66,7 @@ import { IfcImportDialog, type IfcImportMode } from "./ui/IfcImportDialog";
|
||||
import { MeshImportHost } from "./ui/MeshImportDialog";
|
||||
import { openMeshFileDialog, requestMeshImport, splitMeshFiles } from "./state/meshImportStore";
|
||||
import { formatMeshReport, isMeshFile } from "./io/meshImport";
|
||||
import { clashMarkerOps, runClashCheck } from "./analysis/clash";
|
||||
import { runClashAndStore } from "./panels/clashSession";
|
||||
import { checkForUpdate } from "./update/checkForUpdate";
|
||||
import type { PlanViewHandle } from "./views/plan/PlanView";
|
||||
import type { DisplayResolver } from "./viewport/Viewport3D";
|
||||
@@ -2376,23 +2376,8 @@ export default function App() {
|
||||
onImportPointCloud: () => openPointCloudFileDialog(),
|
||||
onImportMesh: () => openMeshFileDialog(),
|
||||
onClashCheck: () => {
|
||||
const p0 = project;
|
||||
runClashCheck(p0)
|
||||
.then((clashes) => {
|
||||
applyChange((p) => clashMarkerOps(p, clashes, activeCategoryCode));
|
||||
// window.alert ist im Tauri-WKWebView wirkungslos → Toast.
|
||||
notify(
|
||||
clashes.length === 0
|
||||
? t("clash.none")
|
||||
: `${t("clash.found")}: ${clashes.length} — ` +
|
||||
clashes
|
||||
.slice(0, 5)
|
||||
.map((c, k) => `K${k + 1} ${c.a.kind}↔${c.b.kind}${c.volume !== null ? ` ${c.volume.toFixed(3)} m³` : ""}`)
|
||||
.join(", "),
|
||||
clashes.length === 0 ? "info" : "warning",
|
||||
);
|
||||
})
|
||||
.catch((err) => notify(`${t("clash.failed")}: ${err instanceof Error ? err.message : String(err)}`, "error"));
|
||||
setLayout((l) => revealPanel(l, "clash"));
|
||||
void runClashAndStore();
|
||||
},
|
||||
onKennzahlen: () => {
|
||||
const k = computeKennzahlen(project);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { sampleProject } from "../model/sampleProject";
|
||||
import { candidatePairs, clashItems, clashMarkerOps, CLASH_MARKER_PREFIX } from "./clash";
|
||||
import { candidatePairs, clashHighlightLines, clashItems, clashMarkerOps, clashSelection, CLASH_MARKER_PREFIX } from "./clash";
|
||||
import { applyOps } from "../core/ops";
|
||||
import type { Project } from "../model/types";
|
||||
import type { Clash } from "./clash";
|
||||
@@ -22,11 +22,28 @@ describe("Kollisionspruefung", () => {
|
||||
expect(items.some((i) => i.kind === "wall")).toBe(true);
|
||||
});
|
||||
it("Marker ersetzen alte Marker", () => {
|
||||
const clash = { a: it0("a", "solid"), b: it0("b", "wall"), volume: 0.12, center: [1, 2, 0.5] as [number, number, number] };
|
||||
const clash = { a: it0("a", "solid"), b: it0("b", "wall"), volume: 0.12, center: [1, 2, 0.5] as [number, number, number], min: [0.5, 1.5, 0] as [number, number, number], max: [1.5, 2.5, 1] as [number, number, number] };
|
||||
const p1 = applyClashMarkers(sampleProject, [clash, clash], "A");
|
||||
const n1 = p1.drawings2d.filter((d) => d.id.startsWith(CLASH_MARKER_PREFIX)).length;
|
||||
expect(n1).toBe(4);
|
||||
const p2 = applyClashMarkers(p1, [clash], "A");
|
||||
expect(p2.drawings2d.filter((d) => d.id.startsWith(CLASH_MARKER_PREFIX)).length).toBe(2);
|
||||
});
|
||||
it("3D-Hervorhebung: 12 Kanten je Kollision als Linienpaare im Viewport-Raum (y/z getauscht)", () => {
|
||||
const clash = { a: it0("a", "solid"), b: it0("b", "wall"), volume: 0.12, center: [1, 2, 0.5] as [number, number, number], min: [0.5, 1.5, 0] as [number, number, number], max: [1.5, 2.5, 1] as [number, number, number] };
|
||||
const lines = clashHighlightLines([clash], [1, 0, 0]);
|
||||
expect(lines.length).toBe(12 * 2 * 6);
|
||||
// erster Eckpunkt: Modell (min.x, min.y, min.z) → world (x, Höhe, y), Farbe rot
|
||||
const verts = [];
|
||||
for (let k = 0; k < lines.length; k += 6) verts.push([...lines.slice(k, k + 6)]);
|
||||
expect(verts.every((v) => v[3] === 1 && v[4] === 0 && v[5] === 0)).toBe(true);
|
||||
expect(verts.every((v) => v[0] >= 0.5 && v[0] <= 1.5 && v[1] >= 0 && v[1] <= 1 && v[2] >= 1.5 && v[2] <= 2.5)).toBe(true);
|
||||
expect(clashHighlightLines([], [1, 0, 0]).length).toBe(0);
|
||||
});
|
||||
it("Auswahl eines Paars je Bauteilart", () => {
|
||||
const clash = { a: it0("s1", "solid"), b: it0("w1", "wall"), volume: null, center: [0, 0, 0] as [number, number, number], min: [0, 0, 0] as [number, number, number], max: [1, 1, 1] as [number, number, number] };
|
||||
expect(clashSelection(clash)).toEqual({ wallIds: ["w1"], ceilingIds: [], extrudedSolidIds: ["s1"], contextObjectIds: [] });
|
||||
const m = { ...clash, a: it0("m1", "mesh"), b: it0("c1", "slab") };
|
||||
expect(clashSelection(m)).toEqual({ wallIds: [], ceilingIds: ["c1"], extrudedSolidIds: [], contextObjectIds: ["m1"] });
|
||||
});
|
||||
});
|
||||
+53
-5
@@ -30,8 +30,11 @@ export interface Clash {
|
||||
b: ClashItem;
|
||||
/** Durchdringungsvolumen (m³), `null` wenn nicht berechenbar. */
|
||||
volume: number | null;
|
||||
/** Mittelpunkt der Durchdringungslinien (Welt-Meter). */
|
||||
/** Mittelpunkt der Durchdringungslinien (Modell-Meter, z = Höhe). */
|
||||
center: [number, number, number];
|
||||
/** Hüllquader der Durchdringungslinien (Modell-Meter) — für Hervorhebung und Zoom. */
|
||||
min: [number, number, number];
|
||||
max: [number, number, number];
|
||||
}
|
||||
|
||||
/** Prefix der Marker-Ids (ein neuer Lauf ersetzt die alten Marker). */
|
||||
@@ -127,13 +130,17 @@ export async function runClashCheck(
|
||||
if (!r.colliding || r.lines.length === 0) continue;
|
||||
if (r.overlapVolume !== null && r.overlapVolume < MIN_VOLUME) continue;
|
||||
const c: [number, number, number] = [0, 0, 0];
|
||||
const min: [number, number, number] = [Infinity, Infinity, Infinity];
|
||||
const max: [number, number, number] = [-Infinity, -Infinity, -Infinity];
|
||||
for (const l of r.lines) {
|
||||
c[0] += (l[0] + l[3]) / 2;
|
||||
c[1] += (l[1] + l[4]) / 2;
|
||||
c[2] += (l[2] + l[5]) / 2;
|
||||
for (let k = 0; k < 3; k++) {
|
||||
c[k] += (l[k] + l[k + 3]) / 2;
|
||||
min[k] = Math.min(min[k], l[k], l[k + 3]);
|
||||
max[k] = Math.max(max[k], l[k], l[k + 3]);
|
||||
}
|
||||
}
|
||||
const n = r.lines.length;
|
||||
const clash: Clash = { a: items[i], b: items[j], volume: r.overlapVolume, center: [c[0] / n, c[1] / n, c[2] / n] };
|
||||
const clash: Clash = { a: items[i], b: items[j], volume: r.overlapVolume, center: [c[0] / n, c[1] / n, c[2] / n], min, max };
|
||||
// Mehrere Wandschichten derselben Wand → eine Kollision (grösstes Volumen).
|
||||
const key = [items[i].id, items[j].id].sort().join("|");
|
||||
const prev = found.get(key);
|
||||
@@ -175,3 +182,44 @@ export function clashMarkerOps(project: Project, clashes: Clash[], categoryCode:
|
||||
...addItems("drawings2d", markers),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Rote Hüllquader der Kollisionen als Linienliste für den 3D-Viewport (`set_highlight_lines`):
|
||||
* `[x, y, z, r, g, b]` je Vertex, 2 Vertices je Kante, 12 Kanten je Kollision. Modell (x, y, Höhe)
|
||||
* → Viewport-Welt (x, Höhe, y). Mindestkantenlänge 0.1 m, damit hauchdünne Durchdringungen sichtbar bleiben.
|
||||
*/
|
||||
export function clashHighlightLines(clashes: Clash[], rgb: readonly [number, number, number]): Float32Array {
|
||||
const out = new Float32Array(clashes.length * 12 * 2 * 6);
|
||||
let o = 0;
|
||||
const vert = (p: readonly number[]) => {
|
||||
out[o++] = p[0];
|
||||
out[o++] = p[2];
|
||||
out[o++] = p[1];
|
||||
out[o++] = rgb[0];
|
||||
out[o++] = rgb[1];
|
||||
out[o++] = rgb[2];
|
||||
};
|
||||
for (const c of clashes) {
|
||||
const lo = [0, 1, 2].map((k) => Math.min(c.min[k], c.center[k] - 0.05));
|
||||
const hi = [0, 1, 2].map((k) => Math.max(c.max[k], c.center[k] + 0.05));
|
||||
const corner = (i: number) => [i & 1 ? hi[0] : lo[0], i & 2 ? hi[1] : lo[1], i & 4 ? hi[2] : lo[2]];
|
||||
for (let i = 0; i < 8; i++) {
|
||||
for (const bit of [1, 2, 4]) {
|
||||
if (i & bit) continue;
|
||||
vert(corner(i));
|
||||
vert(corner(i | bit));
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** Bauteile einer Kollision je Auswahlkanal (Wand, Decke, Körper, Import). */
|
||||
export function clashSelection(c: Clash): { wallIds: string[]; ceilingIds: string[]; extrudedSolidIds: string[]; contextObjectIds: string[] } {
|
||||
const sel = { wallIds: [] as string[], ceilingIds: [] as string[], extrudedSolidIds: [] as string[], contextObjectIds: [] as string[] };
|
||||
for (const it of [c.a, c.b]) {
|
||||
const list = it.kind === "wall" ? sel.wallIds : it.kind === "slab" ? sel.ceilingIds : it.kind === "solid" ? sel.extrudedSolidIds : sel.contextObjectIds;
|
||||
if (!list.includes(it.id)) list.push(it.id);
|
||||
}
|
||||
return sel;
|
||||
}
|
||||
@@ -32,25 +32,25 @@ let lastTaper = 0;
|
||||
// ── Profil (Kern, `cmd_create.rs`): geschlossene polyline/rect/circle → Punktliste ─
|
||||
|
||||
/** Profil eines extrudierbaren 2D-Elements (Kreis: 48-Eck + Mittelpunkt/Radius). */
|
||||
interface Profile {
|
||||
export interface Profile {
|
||||
pts: Vec2[];
|
||||
circle?: { center: Vec2; r: number };
|
||||
}
|
||||
|
||||
type ProfileHit = { id: string } & Profile;
|
||||
export type ProfileHit = { id: string } & Profile;
|
||||
|
||||
function profileQuery(project: Project, req: { q: string } & Record<string, unknown>): ProfileHit | null {
|
||||
return createQuery<{ hit: (ProfileHit & { circle: Profile["circle"] | null }) | null }>(project, req).hit ?? null;
|
||||
}
|
||||
|
||||
/** Genau EIN geeignetes Profil vorgewählt (sonst null). */
|
||||
function singleSelectedProfile(project: Project, sel: CommandSelection): ProfileHit | null {
|
||||
export function singleSelectedProfile(project: Project, sel: CommandSelection): ProfileHit | null {
|
||||
if (!sel.drawingId || sel.wallIds.length > 0) return null;
|
||||
return profileQuery(project, { q: "profile", id: sel.drawingId });
|
||||
}
|
||||
|
||||
/** Nächstes Profil der Ebene am Klickpunkt (Kanten-Abstand < 0.25 m). */
|
||||
const pickProfileAt = (project: Project, levelId: string, pt: Vec2): ProfileHit | null =>
|
||||
export const pickProfileAt = (project: Project, levelId: string, pt: Vec2): ProfileHit | null =>
|
||||
profileQuery(project, { q: "pickProfile", level: levelId, pt: xy(pt) });
|
||||
|
||||
/** Commit (Kern): Quelle entfernen, Körper (Punkte + Höhe + Verjüngung) anlegen. */
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
// Loft ([T7]): ≥ 2 geschlossene Plan-Profile nacheinander anklicken (erstes = unten), Enter, dann die
|
||||
// Gesamthöhe. Die Profile werden gleichmässig über die Höhe verteilt (Kern `cmd_solid.rs`: gleiche
|
||||
// Punktzahl durch Kantenteilung, Drehsinn angeglichen) und zu einem truck-`loft`-B-Rep-Körper
|
||||
// (`ExtrudedSolid.brep`) verbunden; die Quellprofile entfallen wie beim Extrudieren.
|
||||
|
||||
import type { Command, CommandContext, CommandResult, CommandState, Vec2 } from "../types";
|
||||
import { createMutation } from "../createCore";
|
||||
import { pickProfileAt, type ProfileHit } from "./extrude";
|
||||
|
||||
let lastHeight = 3;
|
||||
|
||||
interface LoftState extends CommandState {
|
||||
phase: "pick" | "height" | "done";
|
||||
picks: ProfileHit[];
|
||||
}
|
||||
|
||||
const draft = (s: LoftState, cursor: Vec2 | null): CommandResult["draft"] => ({
|
||||
preview: s.picks.map((p) => ({ kind: "poly" as const, pts: p.pts, closed: true })),
|
||||
vertices: [],
|
||||
hud: cursor ? { at: cursor, text: s.phase === "height" ? `${lastHeight.toFixed(2)} m` : `${s.picks.length}` } : undefined,
|
||||
});
|
||||
|
||||
const finished = (): LoftState => ({ phase: "done", picks: [], lastPoint: null });
|
||||
const done = (): [CommandState, CommandResult] => [finished(), { draft: null, done: true }];
|
||||
|
||||
function commit(s: LoftState, height: number, ctx: CommandContext): [CommandState, CommandResult] {
|
||||
lastHeight = height;
|
||||
return [
|
||||
finished(),
|
||||
{ draft: null, done: true, commit: createMutation(ctx, { cmd: "loft", sources: s.picks.map((p) => p.id), height }) },
|
||||
];
|
||||
}
|
||||
|
||||
export const loftCommand: Command = {
|
||||
name: "loft",
|
||||
labelKey: "cmd.loft.label",
|
||||
prompt: (st) => ((st as LoftState).phase === "height" ? "cmd.loft.height" : (st as LoftState).picks.length < 2 ? "cmd.loft.pick" : "cmd.loft.pickMore"),
|
||||
accepts: (st) => ((st as LoftState).phase === "height" ? ["number"] : ["point"]),
|
||||
options: () => [],
|
||||
floorOnly: true,
|
||||
|
||||
init: (): LoftState => ({ phase: "pick", picks: [], lastPoint: null }),
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as LoftState;
|
||||
if (s.phase === "done") return done();
|
||||
if (s.phase === "pick") {
|
||||
if (input.kind !== "point") return [s, { draft: draft(s, null) }];
|
||||
const hit = pickProfileAt(ctx.project, ctx.level.id, input.point);
|
||||
if (!hit || s.picks.some((p) => p.id === hit.id)) return [s, { draft: draft(s, null) }];
|
||||
const ns: LoftState = { ...s, picks: [...s.picks, hit] };
|
||||
return [ns, { draft: draft(ns, input.point) }];
|
||||
}
|
||||
if (input.kind !== "number" || !(input.value > 0)) return [s, { draft: draft(s, null) }];
|
||||
return commit(s, input.value, ctx);
|
||||
},
|
||||
|
||||
onMove: (state, point): [CommandState, CommandResult] => [state, { draft: draft(state as LoftState, point) }],
|
||||
|
||||
// Enter: mit ≥ 2 Profilen zur Höhe; bei der Höhe die zuletzt benutzte übernehmen.
|
||||
onConfirm: (state, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as LoftState;
|
||||
if (s.phase === "pick") {
|
||||
if (s.picks.length < 2) return [s, { draft: draft(s, null) }];
|
||||
const ns: LoftState = { ...s, phase: "height" };
|
||||
return [ns, { draft: draft(ns, null) }];
|
||||
}
|
||||
return s.phase === "height" ? commit(s, lastHeight, ctx) : done();
|
||||
},
|
||||
onCancel: () => done(),
|
||||
};
|
||||
@@ -0,0 +1,98 @@
|
||||
// Rotationskörper ([T7]): geschlossenes Plan-Profil + Drehachse (2 Punkte im Plan) + Winkel → truck-
|
||||
// `revolve` als B-Rep-Körper (`ExtrudedSolid.brep`, Kern `cmd_solid.rs`). Das Profil muss ganz auf einer
|
||||
// Seite der Achse liegen; die Achse liegt waagrecht auf Höhe des grössten Profilabstands, ein voller
|
||||
// Körper steht also auf der Geschoss-UK. Die Quelle (Profil) wird ersetzt wie beim Extrudieren.
|
||||
//
|
||||
// Schritte: Profil wählen (oder vorselektiert) → Achse Anfang → Achse Ende → Winkel (Zahl oder Enter = zuletzt, 360).
|
||||
|
||||
import type { Command, CommandContext, CommandResult, CommandState, Vec2 } from "../types";
|
||||
import { createMutation } from "../createCore";
|
||||
import { pickProfileAt, singleSelectedProfile, type Profile } from "./extrude";
|
||||
|
||||
let lastAngle = 360;
|
||||
|
||||
interface RevState extends CommandState {
|
||||
phase: "pick" | "axisA" | "axisB" | "angle" | "done";
|
||||
profile: Profile | null;
|
||||
sourceId: string | null;
|
||||
a: Vec2 | null;
|
||||
b: Vec2 | null;
|
||||
cursor: Vec2 | null;
|
||||
}
|
||||
|
||||
const draft = (s: RevState, cursor: Vec2 | null): CommandResult["draft"] => {
|
||||
const preview: NonNullable<CommandResult["draft"]>["preview"] = [];
|
||||
if (s.profile) preview.push({ kind: "poly", pts: s.profile.pts, closed: true });
|
||||
const end = s.b ?? cursor;
|
||||
if (s.a && end) preview.push({ kind: "line", a: s.a, b: end });
|
||||
return { preview, vertices: s.a ? [s.a] : [], hud: cursor && s.phase === "angle" ? { at: cursor, text: `${lastAngle}°` } : undefined };
|
||||
};
|
||||
|
||||
const finished = (): RevState => ({ phase: "done", profile: null, sourceId: null, a: null, b: null, cursor: null, lastPoint: null });
|
||||
|
||||
const done = (): [CommandState, CommandResult] => [finished(), { draft: null, done: true }];
|
||||
|
||||
function commit(s: RevState, angle: number, ctx: CommandContext): [CommandState, CommandResult] {
|
||||
lastAngle = angle;
|
||||
return [
|
||||
finished(),
|
||||
{ draft: null, done: true, commit: createMutation(ctx, { cmd: "revolve", source: s.sourceId, a: s.a, b: s.b, angle }) },
|
||||
];
|
||||
}
|
||||
|
||||
export const revolveCommand: Command = {
|
||||
name: "revolve",
|
||||
labelKey: "cmd.revolve.label",
|
||||
prompt: (st) => {
|
||||
const p = (st as RevState).phase;
|
||||
return p === "axisA" ? "cmd.revolve.axisA" : p === "axisB" ? "cmd.revolve.axisB" : p === "angle" ? "cmd.revolve.angle" : "cmd.revolve.pick";
|
||||
},
|
||||
accepts: (st) => ((st as RevState).phase === "angle" ? ["number"] : ["point"]),
|
||||
options: () => [],
|
||||
floorOnly: true,
|
||||
|
||||
init: (): RevState => ({ phase: "pick", profile: null, sourceId: null, a: null, b: null, cursor: null, lastPoint: null }),
|
||||
|
||||
onInput: (state, input, ctx): [CommandState, CommandResult] => {
|
||||
let s = state as RevState;
|
||||
if (s.phase === "done") return done();
|
||||
if (s.phase === "pick") {
|
||||
if (input.kind !== "point") return [s, { draft: null }];
|
||||
// Vorselektiertes Profil: der erste Punkt ist gleich der Achsenanfang.
|
||||
const pre = singleSelectedProfile(ctx.project, ctx.selection);
|
||||
if (pre) {
|
||||
s = { ...s, phase: "axisA", profile: pre, sourceId: pre.id };
|
||||
} else {
|
||||
const hit = pickProfileAt(ctx.project, ctx.level.id, input.point);
|
||||
if (!hit) return [s, { draft: null }];
|
||||
const ns: RevState = { ...s, phase: "axisA", profile: hit, sourceId: hit.id };
|
||||
return [ns, { draft: draft(ns, null) }];
|
||||
}
|
||||
}
|
||||
if (s.phase === "axisA") {
|
||||
if (input.kind !== "point") return [s, { draft: draft(s, s.cursor) }];
|
||||
const ns: RevState = { ...s, phase: "axisB", a: input.point, lastPoint: input.point };
|
||||
return [ns, { draft: draft(ns, input.point) }];
|
||||
}
|
||||
if (s.phase === "axisB") {
|
||||
if (input.kind !== "point" || !s.a || Math.hypot(input.point.x - s.a.x, input.point.y - s.a.y) < 1e-6) return [s, { draft: draft(s, s.cursor) }];
|
||||
const ns: RevState = { ...s, phase: "angle", b: input.point, lastPoint: input.point };
|
||||
return [ns, { draft: draft(ns, input.point) }];
|
||||
}
|
||||
// angle
|
||||
if (input.kind !== "number" || !(input.value > 0)) return [s, { draft: draft(s, s.cursor) }];
|
||||
return commit(s, Math.min(360, input.value), ctx);
|
||||
},
|
||||
|
||||
onMove: (state, point): [CommandState, CommandResult] => {
|
||||
const s = { ...(state as RevState), cursor: point };
|
||||
return [s, { draft: draft(s, point) }];
|
||||
},
|
||||
|
||||
// Enter beim Winkel: zuletzt benutzten Winkel übernehmen.
|
||||
onConfirm: (state, ctx): [CommandState, CommandResult] => {
|
||||
const s = state as RevState;
|
||||
return s.phase === "angle" ? commit(s, lastAngle, ctx) : done();
|
||||
},
|
||||
onCancel: () => done(),
|
||||
};
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* [T7] `revolveCommand` (Profil + Achse + Winkel) und `loftCommand` (≥ 2 Profile + Höhe): beide legen
|
||||
* einen B-Rep-Körper (`ExtrudedSolid.brep`) an und entfernen die Quellprofile.
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { revolveCommand } from "./revolve";
|
||||
import { loftCommand } from "./loft";
|
||||
import type { CommandContext, CmdInput, Project } from "../types";
|
||||
|
||||
const rect = (id: string, x: number, y: number, w: number, h: number) => ({
|
||||
id,
|
||||
type: "drawing2d" as const,
|
||||
levelId: "eg",
|
||||
categoryCode: "20",
|
||||
geom: { shape: "rect" as const, min: { x, y }, max: { x: x + w, y: y + h } },
|
||||
});
|
||||
|
||||
function project(): Project {
|
||||
return {
|
||||
id: "t",
|
||||
name: "T",
|
||||
lineStyles: [],
|
||||
hatches: [],
|
||||
components: [],
|
||||
wallTypes: [],
|
||||
drawingLevels: [{ id: "eg", name: "EG", kind: "floor", visible: true, locked: false, floorHeight: 2.6, cutHeight: 1.0, baseElevation: 0 }],
|
||||
layers: [{ code: "20", name: "Zeichnung", color: "#0a0a0a", lw: 0.5, visible: true, locked: false }],
|
||||
walls: [],
|
||||
openings: [],
|
||||
ceilings: [],
|
||||
stairs: [],
|
||||
rooms: [],
|
||||
drawings2d: [rect("A", 0, 1, 2, 1), rect("B", 10, 0, 1, 1)],
|
||||
extrudedSolids: [],
|
||||
context: [],
|
||||
} as unknown as Project;
|
||||
}
|
||||
|
||||
function makeCtx(p: Project, drawingId: string | null = null): CommandContext {
|
||||
return {
|
||||
project: p,
|
||||
level: p.drawingLevels[0],
|
||||
defaultCategoryCode: "20",
|
||||
activeLineStyleId: "solid",
|
||||
activeWallTypeId: "aw",
|
||||
lastPoint: null,
|
||||
selection: { wallIds: [], drawingId },
|
||||
} as CommandContext;
|
||||
}
|
||||
|
||||
/** Spielt Eingaben ab; liefert das Projekt nach dem Commit (oder null). */
|
||||
function run(cmd: typeof revolveCommand, p: Project, inputs: Array<CmdInput | "confirm">, selected: string | null = null) {
|
||||
const ctx = makeCtx(p, selected);
|
||||
let state = cmd.init();
|
||||
let commit: ((p: Project) => Project) | undefined;
|
||||
for (const i of inputs) {
|
||||
const [ns, res] = i === "confirm" ? cmd.onConfirm(state, ctx) : cmd.onInput(state, i, ctx);
|
||||
state = ns;
|
||||
if (res.commit) commit = res.commit as typeof commit;
|
||||
}
|
||||
return commit ? commit(p) : null;
|
||||
}
|
||||
|
||||
const pt = (x: number, y: number): CmdInput => ({ kind: "point", point: { x, y } });
|
||||
|
||||
describe("revolveCommand", () => {
|
||||
it("Profil wählen, Achse (2 Punkte), Winkel → Rotationskörper, Quelle entfernt", () => {
|
||||
const next = run(revolveCommand, project(), [pt(1, 1), pt(-1, 0), pt(5, 0), { kind: "number", value: 180 }])!;
|
||||
expect(next.drawings2d.map((d) => d.id)).toEqual(["B"]);
|
||||
const s = next.extrudedSolids![0];
|
||||
expect(s.brep!.spec).toMatchObject({ kind: "transform", solid: { kind: "revolve", angleDeg: 180 } });
|
||||
expect(s.height).toBeCloseTo(4, 9); // Profil 1 … 2 m neben der Achse y=0 → r_max = 2
|
||||
});
|
||||
|
||||
it("Enter beim Winkel übernimmt den zuletzt benutzten; vorgewähltes Profil überspringt die Wahl", () => {
|
||||
run(revolveCommand, project(), [pt(1, 1), pt(-1, 0), pt(5, 0), { kind: "number", value: 90 }]);
|
||||
const next = run(revolveCommand, project(), [pt(-1, 0), pt(5, 0), "confirm"], "A")!;
|
||||
expect(next.extrudedSolids![0].brep!.spec).toMatchObject({ solid: { angleDeg: 90 } });
|
||||
});
|
||||
|
||||
it("Profil, das die Achse überquert, ergibt keinen Körper", () => {
|
||||
const next = run(revolveCommand, project(), [pt(1, 1), pt(-1, 1.5), pt(5, 1.5), "confirm"]);
|
||||
expect(next?.extrudedSolids ?? []).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe("loftCommand", () => {
|
||||
it("zwei Profile wählen, Enter, Höhe → Loft-Körper, Quellen entfernt", () => {
|
||||
const next = run(loftCommand, project(), [pt(1, 1), pt(10.5, 0), "confirm", { kind: "number", value: 3 }])!;
|
||||
expect(next.drawings2d).toHaveLength(0);
|
||||
const s = next.extrudedSolids![0];
|
||||
expect(s.height).toBe(3);
|
||||
expect(s.brep!.spec).toMatchObject({ kind: "loft" });
|
||||
expect((s.brep!.spec as { sections: unknown[] }).sections).toHaveLength(2);
|
||||
});
|
||||
|
||||
it("mit nur einem Profil bleibt Enter wirkungslos", () => {
|
||||
const next = run(loftCommand, project(), [pt(1, 1), "confirm", { kind: "number", value: 3 }]);
|
||||
expect(next?.extrudedSolids ?? []).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
@@ -53,6 +53,8 @@ import { copyCommand } from "./cmds/copy";
|
||||
import { arrayCommand } from "./cmds/array";
|
||||
import { offsetCommand } from "./cmds/offset";
|
||||
import { extrudeCommand } from "./cmds/extrude";
|
||||
import { revolveCommand } from "./cmds/revolve";
|
||||
import { loftCommand } from "./cmds/loft";
|
||||
import { trimCommand } from "./cmds/trim";
|
||||
import { breakCommand } from "./cmds/break";
|
||||
import { extendCommand } from "./cmds/extend";
|
||||
@@ -121,6 +123,8 @@ export const COMMANDS: Record<string, Command> = {
|
||||
array: arrayCommand,
|
||||
offset: offsetCommand,
|
||||
extrude: extrudeCommand,
|
||||
revolve: revolveCommand,
|
||||
loft: loftCommand,
|
||||
trim: trimCommand,
|
||||
break: breakCommand,
|
||||
extend: extendCommand,
|
||||
@@ -246,6 +250,9 @@ export const ALIASES: Record<string, string> = {
|
||||
feld: "array",
|
||||
o: "offset",
|
||||
ex: "extrude",
|
||||
rev: "revolve",
|
||||
rotation: "revolve",
|
||||
lf: "loft",
|
||||
tr: "trim",
|
||||
br: "break",
|
||||
unterbrechen: "break",
|
||||
|
||||
@@ -802,6 +802,7 @@ export const de = {
|
||||
"objinfo.stair.shape.L": "L-Treppe",
|
||||
"objinfo.stair.shape.spiral": "Wendel",
|
||||
"objinfo.stair.width": "Laufbreite",
|
||||
"objinfo.stair.column": "Mittelsäule (Radius)",
|
||||
"objinfo.stair.steps": "Stufenanzahl",
|
||||
"objinfo.stair.rise": "Steighöhe (gesamt)",
|
||||
"objinfo.stair.riser": "Steigungshöhe",
|
||||
@@ -1846,6 +1847,17 @@ export const de = {
|
||||
"cmd.offset.label": "Versatz",
|
||||
"cmd.offset.pick": "Kurve wählen:",
|
||||
"cmd.offset.side": "Seite oder Distanz:",
|
||||
"cmd.revolve.label": "Rotationskörper",
|
||||
"cmd.revolve.pick": "Geschlossenes Profil wählen:",
|
||||
"cmd.revolve.axisA": "Drehachse: Anfangspunkt:",
|
||||
"cmd.revolve.axisB": "Drehachse: Endpunkt:",
|
||||
"cmd.revolve.angle": "Drehwinkel (°, Enter = zuletzt):",
|
||||
"cmd.loft.label": "Loft",
|
||||
"cmd.loft.pick": "Profile der Reihe nach wählen (unten zuerst):",
|
||||
"cmd.loft.pickMore": "Weiteres Profil wählen oder Enter:",
|
||||
"cmd.loft.height": "Gesamthöhe:",
|
||||
"history.cmd.revolve": "Rotationskörper",
|
||||
"history.cmd.loft": "Loft",
|
||||
"cmd.extrude.label": "Extrudieren",
|
||||
"cmd.extrude.pick": "Geschlossenes Profil wählen:",
|
||||
"cmd.extrude.height": "Höhe:",
|
||||
@@ -2262,6 +2274,7 @@ export const de = {
|
||||
"mesh.import.upUncertain": "Achse unsicher, angenommen: {axis} oben (im Import-Dialog wählbar)",
|
||||
"mesh.import.dropped": "{n} ungültige oder entartete Flächen verworfen",
|
||||
"mesh.import.truncated": "abgebrochen: zu viele Dreiecke",
|
||||
"mesh.import.repaired": "repariert: {welded} Ecken verschweisst, {tris} entartete Dreiecke entfernt, {holes} Löcher geschlossen",
|
||||
"mesh.import.noFaces": "Die PLY-Datei enthält keine Flächen (Punktwolke): sie wird als Punktwolke geöffnet.",
|
||||
"mesh.import.missingExternal": "Zusätzliche Dateien fehlen: {list}. Wählen Sie sie zusammen mit dem Modell aus (oder ziehen Sie alle Dateien gemeinsam ins Fenster).",
|
||||
"mesh.importDialog.files": "Begleitdateien: {list}",
|
||||
@@ -2446,6 +2459,15 @@ export const de = {
|
||||
"siteRules.addLine.hint": "Eine Linie wählen; das Gebäude bleibt auf der Seite der Parzelle.",
|
||||
"siteRules.clearLines": "Alle Baulinien entfernen",
|
||||
"clash.none": "Keine Kollisionen gefunden.",
|
||||
"clash.run": "Prüfung starten",
|
||||
"clash.running": "Prüfung läuft …",
|
||||
"clash.clear": "Leeren",
|
||||
"clash.empty": "Keine Treffer. Die Prüfung vergleicht freie Körper und Importe mit Wänden, Decken und anderen Körpern.",
|
||||
"clash.kind.wall": "Wand",
|
||||
"clash.kind.slab": "Decke",
|
||||
"clash.kind.solid": "Körper",
|
||||
"clash.kind.mesh": "Import",
|
||||
"nav.clash": "Kollisionen",
|
||||
"clash.found": "Kollisionen gefunden",
|
||||
"clash.failed": "Kollisionsprüfung fehlgeschlagen",
|
||||
"about.title": "Über dossier",
|
||||
|
||||
@@ -799,6 +799,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"objinfo.stair.shape.L": "L-shaped",
|
||||
"objinfo.stair.shape.spiral": "Spiral",
|
||||
"objinfo.stair.width": "Run width",
|
||||
"objinfo.stair.column": "Centre column (radius)",
|
||||
"objinfo.stair.steps": "Step count",
|
||||
"objinfo.stair.rise": "Total rise",
|
||||
"objinfo.stair.riser": "Riser height",
|
||||
@@ -1834,6 +1835,17 @@ export const en: Record<TranslationKey, string> = {
|
||||
"cmd.offset.label": "Offset",
|
||||
"cmd.offset.pick": "Select curve:",
|
||||
"cmd.offset.side": "Side or distance:",
|
||||
"cmd.revolve.label": "Revolve",
|
||||
"cmd.revolve.pick": "Select closed profile:",
|
||||
"cmd.revolve.axisA": "Revolve axis: start point:",
|
||||
"cmd.revolve.axisB": "Revolve axis: end point:",
|
||||
"cmd.revolve.angle": "Revolve angle (°, Enter = last):",
|
||||
"cmd.loft.label": "Loft",
|
||||
"cmd.loft.pick": "Select profiles in order (bottom first):",
|
||||
"cmd.loft.pickMore": "Select another profile or Enter:",
|
||||
"cmd.loft.height": "Total height:",
|
||||
"history.cmd.revolve": "Revolve",
|
||||
"history.cmd.loft": "Loft",
|
||||
"cmd.extrude.label": "Extrude",
|
||||
"cmd.extrude.pick": "Select closed profile:",
|
||||
"cmd.extrude.height": "Height:",
|
||||
@@ -2212,6 +2224,7 @@ export const en: Record<TranslationKey, string> = {
|
||||
"mesh.import.upUncertain": "Axis uncertain, assumed: {axis} up (selectable in the import dialog)",
|
||||
"mesh.import.dropped": "{n} invalid or degenerate faces dropped",
|
||||
"mesh.import.truncated": "aborted: too many triangles",
|
||||
"mesh.import.repaired": "repaired: {welded} vertices welded, {tris} degenerate triangles removed, {holes} holes closed",
|
||||
"mesh.import.noFaces": "The PLY file has no faces (point cloud): opening it as a point cloud.",
|
||||
"mesh.import.missingExternal": "Additional files are missing: {list}. Select them together with the model (or drop all files into the window together).",
|
||||
"mesh.importDialog.files": "Companion files: {list}",
|
||||
@@ -2395,6 +2408,15 @@ export const en: Record<TranslationKey, string> = {
|
||||
"siteRules.addLine": "Building line from selection",
|
||||
"siteRules.addLine.hint": "Select a line; the building stays on the parcel side.",
|
||||
"siteRules.clearLines": "Remove all building lines",
|
||||
"clash.run": "Run check",
|
||||
"clash.running": "Checking …",
|
||||
"clash.clear": "Clear",
|
||||
"clash.empty": "No results. The check compares free solids and imports with walls, slabs and other solids.",
|
||||
"clash.kind.wall": "Wall",
|
||||
"clash.kind.slab": "Slab",
|
||||
"clash.kind.solid": "Solid",
|
||||
"clash.kind.mesh": "Import",
|
||||
"nav.clash": "Clashes",
|
||||
"clash.none": "No clashes found.",
|
||||
"clash.found": "Clashes found",
|
||||
"clash.failed": "Clash detection failed",
|
||||
|
||||
@@ -192,6 +192,13 @@ describe("Mesh-Import: Abbildung auf Kontext-Meshes", () => {
|
||||
expect(text).toContain("mesh.import.done");
|
||||
expect(text).toContain("mesh.import.up");
|
||||
});
|
||||
|
||||
it("Bericht nennt die Reparatur ([T5]) nur, wenn etwas repariert wurde", () => {
|
||||
const base = { format: "stl" as const, up: "z" as const, upAuto: false, upCertain: true, unitScale: 1, triangles: 12, degenerate: 0, badFaces: 0, truncated: false, warnings: [] as string[], objects: 1 };
|
||||
const tr = (k: string, v?: Record<string, string | number>) => `${k}${v ? JSON.stringify(v) : ""}`;
|
||||
expect(formatMeshReport({ ...base, repaired: { welded: 0, degenerate: 0, holes: 0 } }, tr)).not.toContain("repaired");
|
||||
expect(formatMeshReport({ ...base, repaired: { welded: 28, degenerate: 1, holes: 2 } }, tr)).toContain('mesh.import.repaired{"welded":28,"tris":1,"holes":2}');
|
||||
});
|
||||
});
|
||||
|
||||
describe("Mesh-Import: Fehler", () => {
|
||||
|
||||
@@ -64,6 +64,8 @@ export interface MeshImportReport {
|
||||
truncated: boolean;
|
||||
warnings: string[];
|
||||
objects: number;
|
||||
/** Reparatur beim Import ([T5]): zusammengelegte Ecken, entfernte entartete Dreiecke, geschlossene Löcher. */
|
||||
repaired?: { welded: number; degenerate: number; holes: number };
|
||||
}
|
||||
|
||||
/** Rohergebnis aus Rust: Zahlenpuffer + Zeichenketten. */
|
||||
@@ -198,7 +200,7 @@ export async function readMesh(bytes: Uint8Array, name: string, opts?: MeshReadO
|
||||
export function formatMeshReport(
|
||||
r: MeshImportReport,
|
||||
tr: (
|
||||
key: "mesh.import.done" | "mesh.import.up" | "mesh.import.upUncertain" | "mesh.import.dropped" | "mesh.import.truncated",
|
||||
key: "mesh.import.done" | "mesh.import.up" | "mesh.import.upUncertain" | "mesh.import.dropped" | "mesh.import.truncated" | "mesh.import.repaired",
|
||||
vars?: Record<string, string | number>,
|
||||
) => string,
|
||||
): string {
|
||||
@@ -206,6 +208,8 @@ export function formatMeshReport(
|
||||
if (r.upAuto) parts.push(tr(r.upCertain ? "mesh.import.up" : "mesh.import.upUncertain", { axis: r.up.toUpperCase() }));
|
||||
const dropped = r.degenerate + r.badFaces;
|
||||
if (dropped) parts.push(tr("mesh.import.dropped", { n: dropped }));
|
||||
const fixed = r.repaired ? r.repaired.degenerate + r.repaired.holes : 0;
|
||||
if (r.repaired && (r.repaired.welded || fixed)) parts.push(tr("mesh.import.repaired", { welded: r.repaired.welded, tris: r.repaired.degenerate, holes: r.repaired.holes }));
|
||||
if (r.truncated) parts.push(tr("mesh.import.truncated"));
|
||||
return parts.join(" · ");
|
||||
}
|
||||
@@ -2885,6 +2885,11 @@ export type Stair = {
|
||||
* Dreieck als SIA-Vollpfeil). Fehlt sie, gilt "line".
|
||||
*/
|
||||
arrowStyle?: "line" | "filled";
|
||||
/**
|
||||
* Nur Wendel: Radius (Meter) der Mittelsäule (Spindel) im Zentrum. Fehlt er oder ist er
|
||||
* ≤ 0, gibt es keine Säule.
|
||||
*/
|
||||
centerColumn?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
// Kollisionen ([T8]): Liste der Treffer der letzten Prüfung. Klick wählt beide beteiligten Bauteile
|
||||
// (Auswahl-Umriss im 3D) und fährt die 3D-Kamera auf die Durchdringung; im 3D sind alle Treffer als
|
||||
// rote Hüllquader markiert (`clashHighlightLines`, `views/viewportContent.tsx`).
|
||||
|
||||
import { t } from "../i18n";
|
||||
import { getState } from "../state/appStore";
|
||||
import { clashSelection, type Clash } from "../analysis/clash";
|
||||
import { focusCamera, viewportAvailable } from "../viewport/cameraBridge";
|
||||
import { runClashAndStore, setClashSession, useClashSession } from "./clashSession";
|
||||
|
||||
/** Klick auf einen Treffer: Bauteile wählen, Kamera auf die Durchdringung. */
|
||||
export function focusClash(c: Clash, index: number): void {
|
||||
const s = getState();
|
||||
const sel = clashSelection(c);
|
||||
s.clearSelection();
|
||||
s.setSelectedWallIds(sel.wallIds);
|
||||
s.setSelectedCeilingIds(sel.ceilingIds);
|
||||
s.setSelectedExtrudedSolidIds(sel.extrudedSolidIds);
|
||||
s.setSelectedContextObjectIds(sel.contextObjectIds);
|
||||
setClashSession({ selected: index });
|
||||
const radius = Math.hypot(c.max[0] - c.min[0], c.max[1] - c.min[1], c.max[2] - c.min[2]) / 2;
|
||||
if (viewportAvailable()) focusCamera(c.center, radius);
|
||||
}
|
||||
|
||||
const itemText = (it: Clash["a"]) => `${t(`clash.kind.${it.kind}`)} ${it.id}`;
|
||||
|
||||
export function ClashPanel() {
|
||||
const session = useClashSession();
|
||||
return (
|
||||
<div className="bcf-panel">
|
||||
<div className="bcf-bar">
|
||||
<button type="button" className="bcf-btn" disabled={session.running} onClick={() => void runClashAndStore()}>
|
||||
{session.running ? t("clash.running") : t("clash.run")}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="bcf-btn"
|
||||
disabled={session.clashes.length === 0}
|
||||
onClick={() => setClashSession({ clashes: [], selected: null })}
|
||||
>
|
||||
{t("clash.clear")}
|
||||
</button>
|
||||
</div>
|
||||
{session.clashes.length === 0 && <div className="bcf-empty">{t("clash.empty")}</div>}
|
||||
<ul className="bcf-list">
|
||||
{session.clashes.map((c, k) => (
|
||||
<li key={`${c.a.id}|${c.b.id}`}>
|
||||
<button type="button" className={`bcf-topic${k === session.selected ? " is-active" : ""}`} onClick={() => focusClash(c, k)}>
|
||||
<span className="bcf-status">{`K${k + 1}`}</span>
|
||||
<span className="bcf-topic-title">{`${itemText(c.a)} ↔ ${itemText(c.b)}`}</span>
|
||||
{c.volume !== null && <span className="bcf-count">{`${c.volume.toFixed(3)} m³`}</span>}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1461,6 +1461,13 @@ export function StairSection({
|
||||
value={stair.width}
|
||||
onCommit={(v) => host.onSetStairWidth(v)}
|
||||
/>
|
||||
{stair.shape === "spiral" && (
|
||||
<DimensionField
|
||||
label={t("objinfo.stair.column")}
|
||||
value={stair.centerColumn ?? 0}
|
||||
onCommit={(v) => host.onSetStairColumn(v)}
|
||||
/>
|
||||
)}
|
||||
<DimensionField
|
||||
label={t("objinfo.stair.steps")}
|
||||
value={stair.stepCount}
|
||||
|
||||
@@ -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", "dormer", "extrude", "solid", "solidbool", "sectionline", "viewline", "autodim", "excavation"];
|
||||
const COMMANDS_3D = ["column", "ceilingopening", "roof", "roofhole", "roofwindow", "dormer", "extrude", "revolve", "loft", "solid", "solidbool", "sectionline", "viewline", "autodim", "excavation"];
|
||||
const COMMANDS_EDIT = ["move", "copy", "array", "rotate", "mirror", "offset", "multiline", "trim", "break", "extend", "fillet", "chamfer", "join", "defblock", "measure"];
|
||||
|
||||
type ToolsView = "list" | "icons";
|
||||
|
||||
@@ -26,6 +26,7 @@ import { ElementTreePanel, ElementsTabIcon } from "./ElementTreePanel";
|
||||
import { ViewSnapshotsPanel, ViewSnapshotsTabIcon } from "./ViewSnapshotsPanel";
|
||||
import { LayoutsPanel, LayoutsTabIcon } from "./LayoutsPanel";
|
||||
import { BcfPanel } from "./BcfPanel";
|
||||
import { ClashPanel } from "./ClashPanel";
|
||||
import { HistoryPanel } from "./HistoryPanel";
|
||||
import {
|
||||
ToolsTabIcon,
|
||||
@@ -52,6 +53,7 @@ export const BUILTIN_PANEL_IDS = {
|
||||
viewSnapshots: "view-snapshots",
|
||||
layouts: "layouts",
|
||||
bcf: "bcf",
|
||||
clash: "clash",
|
||||
history: "history",
|
||||
} as const;
|
||||
|
||||
@@ -162,6 +164,16 @@ registerPanel({
|
||||
render: () => <BcfPanel />,
|
||||
});
|
||||
|
||||
// Kollisionen ([T8]) — Treffer der Kollisionsprüfung, Klick zoomt im 3D auf die Durchdringung. Nicht im
|
||||
// Standard-Layout; öffnet sich beim Prüflauf („Modell > Kollisionsprüfung") bzw. über „Fenster > Panels".
|
||||
registerPanel({
|
||||
id: BUILTIN_PANEL_IDS.clash,
|
||||
title: "nav.clash",
|
||||
icon: <BcfTabIcon />,
|
||||
hasDisplayMode: false,
|
||||
render: () => <ClashPanel />,
|
||||
});
|
||||
|
||||
// Verlauf ([84]) — Undo-Schritte als Liste, Klick springt zum Schritt. Nicht im Standard-Layout,
|
||||
// erreichbar über „Bearbeiten > Verlauf" bzw. „Fenster > Panels".
|
||||
registerPanel({
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
// Sitzungszustand der Kollisionsprüfung ([T8]): die Ergebnisse der letzten Prüfung leben ausserhalb des
|
||||
// Projekts (Marker im Grundriss kommen weiterhin als Zeichnungs-Elemente), damit Liste (ClashPanel) und
|
||||
// 3D-Hervorhebung (viewportContent) dieselben Treffer zeigen. Kleiner Modul-Speicher wie `bcfSession`.
|
||||
|
||||
import { useSyncExternalStore } from "react";
|
||||
import { clashMarkerOps, runClashCheck, type Clash } from "../analysis/clash";
|
||||
import { t } from "../i18n";
|
||||
import { getState } from "../state/appStore";
|
||||
|
||||
export interface ClashSession {
|
||||
clashes: Clash[];
|
||||
/** Index des gewählten Treffers (Liste/Zoom) oder null. */
|
||||
selected: number | null;
|
||||
/** Prüfung läuft. */
|
||||
running: boolean;
|
||||
}
|
||||
|
||||
let state: ClashSession = { clashes: [], selected: null, running: false };
|
||||
const listeners = new Set<() => void>();
|
||||
|
||||
export const getClashSession = (): ClashSession => state;
|
||||
|
||||
export function setClashSession(patch: Partial<ClashSession>): void {
|
||||
state = { ...state, ...patch };
|
||||
for (const l of listeners) l();
|
||||
}
|
||||
|
||||
export function useClashSession(): ClashSession {
|
||||
return useSyncExternalStore(
|
||||
(cb) => {
|
||||
listeners.add(cb);
|
||||
return () => listeners.delete(cb);
|
||||
},
|
||||
getClashSession,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüfung ausführen: Ergebnis in die Sitzung (Liste + 3D-Hervorhebung), Marker in den Grundriss, Meldung.
|
||||
* Läuft auf dem aktuellen Projektstand des Stores.
|
||||
*/
|
||||
export async function runClashAndStore(): Promise<void> {
|
||||
if (state.running) return;
|
||||
const st = getState();
|
||||
setClashSession({ running: true });
|
||||
try {
|
||||
const clashes = await runClashCheck(st.project);
|
||||
st.applyChange((p) => clashMarkerOps(p, clashes, st.activeCategoryCode));
|
||||
setClashSession({ clashes, selected: null, running: false });
|
||||
// window.alert ist im Tauri-WKWebView wirkungslos → Toast.
|
||||
st.notify(
|
||||
clashes.length === 0
|
||||
? t("clash.none")
|
||||
: `${t("clash.found")}: ${clashes.length} — ` +
|
||||
clashes
|
||||
.slice(0, 5)
|
||||
.map((c, k) => `K${k + 1} ${c.a.kind}↔${c.b.kind}${c.volume !== null ? ` ${c.volume.toFixed(3)} m³` : ""}`)
|
||||
.join(", "),
|
||||
clashes.length === 0 ? "info" : "warning",
|
||||
);
|
||||
} catch (err) {
|
||||
setClashSession({ running: false });
|
||||
st.notify(`${t("clash.failed")}: ${err instanceof Error ? err.message : String(err)}`, "error");
|
||||
}
|
||||
}
|
||||
@@ -530,6 +530,8 @@ export interface PanelHostValue {
|
||||
onSetStairArrowStyle: (style: "line" | "filled") => void;
|
||||
/** Setzt den Referenzpunkt der Laufbreite (links/mitte/rechts). */
|
||||
onSetStairReferenz: (referenz: "links" | "mitte" | "rechts") => void;
|
||||
/** Radius der Mittelsäule (Wendel) in Metern; ≤ 0 entfernt sie. */
|
||||
onSetStairColumn: (radius: number) => void;
|
||||
/** Weist der Treppe einen Treppentyp (Bibliothek) zu; "" löst die Zuweisung. */
|
||||
onSetStairType: (typeId: string) => void;
|
||||
|
||||
|
||||
@@ -259,6 +259,8 @@ export interface StairInfo {
|
||||
arrowStyle?: "line" | "filled";
|
||||
/** Referenzpunkt der Laufbreite (links/mitte/rechts). Fehlt → "mitte". */
|
||||
referenz?: "links" | "mitte" | "rechts";
|
||||
/** Nur Wendel: Radius der Mittelsäule (Meter); fehlt → keine Säule. */
|
||||
centerColumn?: number;
|
||||
/** Zugewiesener Treppentyp (Bibliothek, `Stair.typeId`) oder undefined. */
|
||||
typeId?: string;
|
||||
/** Geschoss, dem die Treppe zugeordnet ist. */
|
||||
|
||||
@@ -974,6 +974,10 @@ export function usePanelHostBase(opts: {
|
||||
onSetStairArrowStyle: (arrowStyle) => {
|
||||
if (selection?.kind === "stair") updateStair(selection.id, { arrowStyle });
|
||||
},
|
||||
onSetStairColumn: (radius) => {
|
||||
if (selection?.kind === "stair")
|
||||
updateStair(selection.id, { centerColumn: radius > 0 ? radius : undefined });
|
||||
},
|
||||
onSetStairReferenz: (referenz) => {
|
||||
if (selection?.kind === "stair") updateStair(selection.id, { referenz });
|
||||
},
|
||||
|
||||
@@ -234,6 +234,24 @@ export function CommandIcon({ name }: { name: string }) {
|
||||
<path d="M9.5 12.5 L12.5 9.5 L12.5 4.5" />
|
||||
</svg>
|
||||
);
|
||||
case "revolve":
|
||||
// Rotationskörper: Profil neben einer Achse, Drehbogen.
|
||||
return (
|
||||
<svg {...common}>
|
||||
<path d="M8 2.5 V13.5" strokeDasharray="1.4 1.2" />
|
||||
<path d="M9.5 4.5 H13 V11.5 H9.5 Z" />
|
||||
<path d="M6.5 4.5 H3 V11.5 H6.5" />
|
||||
</svg>
|
||||
);
|
||||
case "loft":
|
||||
// Loft: grosses Profil unten, kleines oben, verbunden.
|
||||
return (
|
||||
<svg {...common}>
|
||||
<rect x="2.5" y="9.5" width="11" height="3" />
|
||||
<rect x="5.5" y="3.5" width="5" height="2" />
|
||||
<path d="M2.5 9.5 L5.5 5.5 M13.5 9.5 L10.5 5.5" />
|
||||
</svg>
|
||||
);
|
||||
case "voidbox":
|
||||
// Durchbruch: Wand mit gestricheltem, durchkreuztem Ausschnitt.
|
||||
return (
|
||||
|
||||
@@ -5,6 +5,8 @@ import { afterEach, describe, expect, it } from "vitest";
|
||||
import { projectToModel3d, sampleProject } from "../core";
|
||||
import {
|
||||
FOV_Y,
|
||||
focusCamera,
|
||||
focusedCamera,
|
||||
camera3dFromViewCamera,
|
||||
captureSnapshot,
|
||||
getCamera,
|
||||
@@ -153,6 +155,25 @@ describe("Schnittebene", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Fokus auf einen Punkt (Kollisionsliste)", () => {
|
||||
it("zentriert das Ziel auf den Modellpunkt, behält die Blickrichtung, Abstand folgt dem Radius", () => {
|
||||
const cam = orbitCamera({ yaw: 0.4, pitch: 0.3, dist: 15, target: [1, 2, 3], ortho: false, orthoHalfHeight: 8 });
|
||||
const f = focusedCamera(cam, [4, 5, 6], 2);
|
||||
close(f.target, modelToWorld([4, 5, 6]));
|
||||
const d = (c: Camera3d) => {
|
||||
const v = [c.target[0] - c.eye[0], c.target[1] - c.eye[1], c.target[2] - c.eye[2]];
|
||||
const l = Math.hypot(...v);
|
||||
return v.map((x) => x / l);
|
||||
};
|
||||
close(d(f), d(cam));
|
||||
const near = Math.hypot(...f.target.map((t, i) => t - f.eye[i]));
|
||||
expect(near).toBeGreaterThan(2);
|
||||
expect(near).toBeLessThan(15);
|
||||
const ortho = focusedCamera({ ...cam, perspective: false, orthoHalfHeight: 8 }, [0, 0, 0], 2);
|
||||
expect(ortho.orthoHalfHeight).toBeLessThan(8);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Registrierung", () => {
|
||||
function fakeViewport() {
|
||||
const state = { cam: orbitCamera({ yaw: 0.4, pitch: 0.3, dist: 15, target: [1, 2, 3], ortho: false, orthoHalfHeight: 8 }), written: null as Camera3d | null, section: undefined as unknown };
|
||||
@@ -181,6 +202,14 @@ describe("Registrierung", () => {
|
||||
expect(setCamera(vc)).toBe(false);
|
||||
});
|
||||
|
||||
it("focusCamera schreibt die fokussierte Kamera in den Viewport (false ohne Viewport)", () => {
|
||||
expect(focusCamera([1, 2, 3], 1)).toBe(false);
|
||||
const { state, a } = fakeViewport();
|
||||
registerViewportCamera(a);
|
||||
expect(focusCamera([5, 6, 7], 1)).toBe(true);
|
||||
close(state.written!.target, modelToWorld([5, 6, 7]));
|
||||
});
|
||||
|
||||
it("getCamera → setCamera am angemeldeten Viewport lässt die Kamera unverändert", () => {
|
||||
const { state, a } = fakeViewport();
|
||||
registerViewportCamera(a);
|
||||
|
||||
@@ -257,6 +257,29 @@ export function setCamera(cam: ViewCamera, opts: { animate?: boolean } = {}): bo
|
||||
return c3 ? api.write(c3, opts.animate === true) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Kamera, die einen Modellpunkt (x, y, Höhe) ins Ziel nimmt: gleiche Blickrichtung, Abstand so, dass eine
|
||||
* Kugel vom Radius `radius` (Meter) bequem ins Bild passt; orthografisch schrumpft die Sichthöhe.
|
||||
*/
|
||||
export function focusedCamera(cam: Camera3d, centerModel: readonly number[], radius: number): Camera3d {
|
||||
const target = modelToWorld(centerModel);
|
||||
const d = norm(sub(cam.target, cam.eye)) ?? ([0, 0, -1] as V3);
|
||||
const r = Math.max(radius, 0.5);
|
||||
const dist = Math.max((r * 2.2) / Math.tan((cam.fovY || FOV_Y) / 2), 1.5);
|
||||
return {
|
||||
...cam,
|
||||
target,
|
||||
eye: [target[0] - d[0] * dist, target[1] - d[1] * dist, target[2] - d[2] * dist],
|
||||
orthoHalfHeight: cam.perspective ? cam.orthoHalfHeight : r * 2.2,
|
||||
};
|
||||
}
|
||||
|
||||
/** Fokus der Live-Kamera auf einen Modellpunkt; `false` ohne Viewport. */
|
||||
export function focusCamera(centerModel: readonly number[], radius: number, opts: { animate?: boolean } = {}): boolean {
|
||||
const cur = api?.read();
|
||||
return api && cur ? api.write(focusedCamera(cur.camera, centerModel, radius), opts.animate !== false) : false;
|
||||
}
|
||||
|
||||
/** PNG des aktuellen 3D-Bildes, oder null (kein Viewport, leeres/nicht lesbares Bild). */
|
||||
export async function captureSnapshot(opts: { maxEdge?: number } = {}): Promise<Uint8Array | null> {
|
||||
if (!api) return null;
|
||||
|
||||
@@ -37,6 +37,8 @@ import { unitsForLevel } from "../tools/displayUnits";
|
||||
import { setSheetOwnerOutlines, setSheetSnapSegments, snapSegmentsFromPrimitives } from "../tools/sheetSnapGeometry";
|
||||
import { pushNativeScene, pushNativeWalls } from "./plan/nativeSync";
|
||||
import { selectionHighlightLines } from "../core";
|
||||
import { clashHighlightLines } from "../analysis/clash";
|
||||
import { useClashSession } from "../panels/clashSession";
|
||||
import { applyGroupDimmingToPlan } from "../state/groupActions";
|
||||
import { PlanView } from "./plan/PlanView";
|
||||
import type {
|
||||
@@ -61,6 +63,8 @@ import type { DetailLevel, RenderMode, View3d, ViewType } from "../model/viewTyp
|
||||
* grauen Wand-/Deckenton, dem hellen Hidden-Line-Weiss und dem Bodenraster ab.
|
||||
*/
|
||||
const HIGHLIGHT_RGB: [number, number, number] = [1.0, 0.5, 0.1];
|
||||
/** Rot der Kollisions-Hüllquader im 3D ([T8]). */
|
||||
const CLASH_RGB: [number, number, number] = [0.88, 0.14, 0.16];
|
||||
|
||||
/** Hauptinhalt — abhängig von der aktiven Zeichnungsebene und dem Ansichtstyp. */
|
||||
export function Content({
|
||||
@@ -285,7 +289,8 @@ export function Content({
|
||||
// im WASM-Zweig (Viewport3D reicht sie nur dort an Wasm3DViewport durch);
|
||||
// die three.js-Sicht hebt die Auswahl weiterhin über ihr eigenes Material
|
||||
// hervor. Leere Auswahl → null (kein Highlight).
|
||||
const highlightLines = useMemo(
|
||||
const clashes = useClashSession().clashes;
|
||||
const selectionLines = useMemo(
|
||||
() =>
|
||||
selectedWallIds.length === 0 &&
|
||||
selectedCeilingIds.length === 0 &&
|
||||
@@ -314,6 +319,16 @@ export function Content({
|
||||
selectedContextObjectIds,
|
||||
],
|
||||
);
|
||||
// Kollisionen der letzten Prüfung: rote Hüllquader zusätzlich zur Auswahl-Hervorhebung.
|
||||
const highlightLines = useMemo(() => {
|
||||
if (clashes.length === 0) return selectionLines;
|
||||
const clashLines = clashHighlightLines(clashes, CLASH_RGB);
|
||||
if (!selectionLines) return clashLines;
|
||||
const merged = new Float32Array(selectionLines.length + clashLines.length);
|
||||
merged.set(selectionLines, 0);
|
||||
merged.set(clashLines, selectionLines.length);
|
||||
return merged;
|
||||
}, [selectionLines, clashes]);
|
||||
|
||||
if (level.kind === "section" || level.kind === "elevation") {
|
||||
return (
|
||||
|
||||
Reference in new issue
Block a user