Abzugskoerper (Boolean im Gebaeude): Durchbruch/Nische zieht sich von Waenden, Decken, Stuetzen ab — Grundriss, Schnitt, 3D (truck-Boolean), STEP; Befehl Durchbruch, Panel-Felder
This commit is contained in:
1 parent
fd4319d8b2
commit
cafbb029fa
47 files changed
+1485
-569
No files matched your search
+32
-70
@@ -16,103 +16,53 @@
|
||||
import type { Project } from "../model/types";
|
||||
import { getFloor, roofLayers } from "../model/types";
|
||||
import { projectToModel3d } from "../plan/toWalls3d";
|
||||
import type { RWall } from "../plan/toWalls3d";
|
||||
import { roofBaseElevation, roofGeometry } from "../geometry/roof";
|
||||
import { exportStepSolids } from "../engine/truckSolid";
|
||||
import { extrudedSolidSpec } from "../plan/extrudedSolidSpec";
|
||||
import type { SolidSpec } from "../engine/truckSolid";
|
||||
import { wallSpec } from "../plan/wallSpec";
|
||||
import { bbox, hittingVoids, subtractSpec, voidPrisms, wallCorners } from "../plan/voids";
|
||||
import type { Box2 } from "../plan/voids";
|
||||
|
||||
export { wallProfile, wallSpec } from "../plan/wallSpec";
|
||||
|
||||
const EPS = 1e-6;
|
||||
/** Schicht/Öffnung so dünn, dass sie als nicht vorhanden gilt. */
|
||||
const MIN_THICKNESS = 1e-4;
|
||||
|
||||
/**
|
||||
* Wandprofil (u = Achse, v = Höhe über Wandfuss) mit Öffnungen: Löcher, die ganz im Profil
|
||||
* liegen; Öffnungen am Wandfuss (Türen) als Kerben im Aussenring. Öffnungen am Wandkopf
|
||||
* werden um 1 mm gekappt (ein Loch darf den Rand nicht berühren).
|
||||
* Boolean-Spezifikation (Bauteil − Abzugskörper) → dieselbe ohne Abzug. Scheitert truck am
|
||||
* Boolean, exportiert `exportProjectStep` das Bauteil wenigstens ungeschnitten.
|
||||
*/
|
||||
export function wallProfile(
|
||||
length: number,
|
||||
height: number,
|
||||
holes: Array<{ from: number; to: number; zBottom: number; zTop: number }>,
|
||||
baseElevation: number,
|
||||
): { outer: number[]; holes: number[][] } {
|
||||
const inner: number[][] = [];
|
||||
const notches: Array<[number, number, number]> = []; // [from, to, top]
|
||||
const cut = 1e-3;
|
||||
for (const h of holes) {
|
||||
const u0 = Math.max(0, Math.min(length, h.from));
|
||||
const u1 = Math.max(0, Math.min(length, h.to));
|
||||
if (u1 - u0 < MIN_THICKNESS) continue;
|
||||
const v0 = h.zBottom - baseElevation;
|
||||
const v1 = Math.min(height - cut, h.zTop - baseElevation);
|
||||
if (v1 - Math.max(v0, 0) < MIN_THICKNESS) continue;
|
||||
if (v0 <= cut) notches.push([u0, u1, v1]);
|
||||
else inner.push([u0, v0, u1, v0, u1, v1, u0, v1]);
|
||||
}
|
||||
// Kerben sortieren und überlappende zusammenfassen.
|
||||
notches.sort((a, b) => a[0] - b[0]);
|
||||
const merged: Array<[number, number, number]> = [];
|
||||
for (const n of notches) {
|
||||
const last = merged[merged.length - 1];
|
||||
if (last && n[0] <= last[1] + EPS) {
|
||||
last[1] = Math.max(last[1], n[1]);
|
||||
last[2] = Math.max(last[2], n[2]);
|
||||
} else merged.push([...n]);
|
||||
}
|
||||
// Aussenring CCW in (u,v): Wandfuss links→rechts mit Kerben, dann Kopf rechts→links.
|
||||
const outer: number[] = [0, 0];
|
||||
for (const [a, b, top] of merged) {
|
||||
outer.push(a, 0, a, top, b, top, b, 0);
|
||||
}
|
||||
outer.push(length, 0, length, height, 0, height);
|
||||
return { outer, holes: inner };
|
||||
}
|
||||
|
||||
export function wallSpec(w: RWall): SolidSpec | null {
|
||||
const dx = w.end[0] - w.start[0];
|
||||
const dy = w.end[1] - w.start[1];
|
||||
const len = Math.hypot(dx, dy);
|
||||
if (len < MIN_THICKNESS || w.height < MIN_THICKNESS || w.thickness < MIN_THICKNESS) return null;
|
||||
const ux = dx / len;
|
||||
const uy = dy / len;
|
||||
// u × v (v = +Z) = (uy, −ux, 0): Extrusionsrichtung. Ursprung = eine Wandfläche.
|
||||
const nx = uy;
|
||||
const ny = -ux;
|
||||
const prof = wallProfile(len, w.height, w.holes ?? [], w.baseElevation);
|
||||
return {
|
||||
kind: "extrudePlane",
|
||||
points: prof.outer,
|
||||
holes: prof.holes,
|
||||
origin: [
|
||||
w.start[0] - (nx * w.thickness) / 2,
|
||||
w.start[1] - (ny * w.thickness) / 2,
|
||||
w.baseElevation,
|
||||
],
|
||||
uAxis: [ux, uy, 0],
|
||||
vAxis: [0, 0, 1],
|
||||
depth: w.thickness,
|
||||
};
|
||||
}
|
||||
const VOID_FALLBACK = new WeakMap<SolidSpec, SolidSpec>();
|
||||
|
||||
/** Alle Bauteile des Projekts als B-Rep-Spezifikationen (reiner Kern, kein WASM). */
|
||||
export function projectSolidSpecs(project: Project): SolidSpec[] {
|
||||
const out: SolidSpec[] = [];
|
||||
const model = projectToModel3d(project, { layeredWalls: true });
|
||||
const voids = voidPrisms(project);
|
||||
const withVoids = (base: SolidSpec, foot: Box2, z0: number, z1: number): SolidSpec => {
|
||||
const hits = hittingVoids(voids, foot, z0, z1);
|
||||
if (hits.length === 0) return base;
|
||||
const spec = subtractSpec(base, hits);
|
||||
VOID_FALLBACK.set(spec, base);
|
||||
return spec;
|
||||
};
|
||||
|
||||
for (const w of model.walls) {
|
||||
const s = wallSpec(w);
|
||||
if (s) out.push(s);
|
||||
if (s) out.push(withVoids(s, bbox(wallCorners(w)), w.baseElevation, w.baseElevation + w.height));
|
||||
}
|
||||
|
||||
for (const s of model.slabs) {
|
||||
if (s.outline.length < 3 || s.zTop - s.zBottom < MIN_THICKNESS) continue;
|
||||
out.push({
|
||||
const base: SolidSpec = {
|
||||
kind: "extrude",
|
||||
points: s.outline.flatMap((p) => [p[0], p[1]]),
|
||||
height: s.zTop - s.zBottom,
|
||||
z0: s.zBottom,
|
||||
});
|
||||
};
|
||||
out.push(withVoids(base, bbox(s.outline.map((p) => ({ x: p[0], y: p[1] }))), s.zBottom, s.zTop));
|
||||
}
|
||||
|
||||
for (const roof of project.roofs ?? []) {
|
||||
@@ -148,6 +98,7 @@ export function projectSolidSpecs(project: Project): SolidSpec[] {
|
||||
}
|
||||
|
||||
for (const solid of project.extrudedSolids ?? []) {
|
||||
if (solid.operation === "subtract") continue; // Abzugskörper sind kein Material
|
||||
let baseZ = 0;
|
||||
if (solid.levelId) {
|
||||
try {
|
||||
@@ -200,6 +151,17 @@ export async function exportProjectStep(project: Project, fileName = ""): Promis
|
||||
await exportStepSolids([specs[i]], "");
|
||||
good.push(specs[i]);
|
||||
} catch (e) {
|
||||
const fallback = VOID_FALLBACK.get(specs[i]);
|
||||
if (fallback) {
|
||||
try {
|
||||
await exportStepSolids([fallback], "");
|
||||
good.push(fallback);
|
||||
skipped.push({ index: i, error: "Abzugskörper nicht abziehbar — Bauteil ungeschnitten exportiert" });
|
||||
continue;
|
||||
} catch {
|
||||
/* unten melden */
|
||||
}
|
||||
}
|
||||
skipped.push({ index: i, error: e instanceof Error ? e.message : String(e) });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user