[128] Merge: Kollisions-Vorprüfung und STEP-Körperzerlegung im Rust-Kern (layoutModel bleibt dünne TS-Schicht)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NTYBZBvLYCtugMJoKXaB67
This commit is contained in:
10 files changed
+268
-108
No files matched your search
+13
-13
@@ -3,6 +3,8 @@
|
||||
// (Wandschichten, Decken, andere Körper). Wand↔Wand und Wand↔Decke werden NICHT geprüft —
|
||||
// sie greifen konstruktiv ineinander (Gehrungen, Auflager) und wären reine Falschmeldungen.
|
||||
//
|
||||
// Vorstufe (Hüllquader-Paare) im Rust-Kern (`clash_broad.rs`), Feinprüfung in trucksolid.
|
||||
//
|
||||
// Ergebnis: je Kollision ein Paar + Durchdringungsvolumen + Mittelpunkt. `clashMarkers`
|
||||
// macht daraus rote Markierungen (Kreis + Text, nicht druckend) auf dem passenden Geschoss.
|
||||
|
||||
@@ -13,6 +15,7 @@ import { getFloor } from "../model/types";
|
||||
import { projectToModel3d } from "../plan/toWalls3d";
|
||||
import { extrudedSolidSpec } from "../plan/extrudedSolidSpec";
|
||||
import { wallSpec } from "../plan/wallSpec";
|
||||
import { core } from "../engine/coreWasm";
|
||||
import { solidClash, solidProps } from "../engine/truckSolid";
|
||||
import type { SolidSpec } from "../engine/truckSolid";
|
||||
|
||||
@@ -80,21 +83,18 @@ export function clashItems(project: Project): ClashItem[] {
|
||||
|
||||
type Box = { min: [number, number, number]; max: [number, number, number] };
|
||||
|
||||
const overlaps = (a: Box, b: Box, eps = 0.002): boolean =>
|
||||
a.min[0] < b.max[0] - eps && b.min[0] < a.max[0] - eps &&
|
||||
a.min[1] < b.max[1] - eps && b.min[1] < a.max[1] - eps &&
|
||||
a.min[2] < b.max[2] - eps && b.min[2] < a.max[2] - eps;
|
||||
|
||||
/** Zu prüfende Paare: mindestens ein freier Körper, Hüllquader überlappen (reiner Kern). */
|
||||
/** Zu prüfende Paare: mindestens ein freier Körper, Hüllquader überlappen (Rust-Kern, `clash_broad.rs`). */
|
||||
export function candidatePairs(items: ClashItem[], boxes: Box[]): Array<[number, number]> {
|
||||
const groups = new Map<string, number>();
|
||||
const flat = new Float64Array(items.length * 8);
|
||||
items.forEach((it, i) => {
|
||||
const g = groups.get(it.id) ?? groups.size;
|
||||
groups.set(it.id, g);
|
||||
flat.set([FREE.has(it.kind) ? 1 : 0, g, ...boxes[i].min, ...boxes[i].max], i * 8);
|
||||
});
|
||||
const out = core().clash_candidate_pairs(flat);
|
||||
const pairs: Array<[number, number]> = [];
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
for (let j = i + 1; j < items.length; j++) {
|
||||
if (!FREE.has(items[i].kind) && !FREE.has(items[j].kind)) continue;
|
||||
if (items[i].id === items[j].id) continue;
|
||||
if (overlaps(boxes[i], boxes[j])) pairs.push([i, j]);
|
||||
}
|
||||
}
|
||||
for (let k = 0; k < out.length; k += 2) pairs.push([out[k], out[k + 1]]);
|
||||
return pairs;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ export type QueryName =
|
||||
| "scheduleCsv"
|
||||
| "pickGeometry"
|
||||
| "model3dParts"
|
||||
| "projectSolidSpecs"
|
||||
| "planDomains"
|
||||
| "ifcExportData"
|
||||
| "meshExportData"
|
||||
|
||||
@@ -14,115 +14,25 @@
|
||||
// Koordinaten: Modell-Meter, X/Y = Grundriss, Z = Höhe (wie die Eingabe von render3d).
|
||||
|
||||
import type { Project } from "../model/types";
|
||||
import { getFloor, roofLayers } from "../model/types";
|
||||
import { documentFor } from "../core/document";
|
||||
import type { RSlab, RWall } from "../plan/toWalls3d/shared";
|
||||
import type { VoidCuts } from "../plan/toWalls3d/voids3d";
|
||||
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";
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Boolean-Spezifikation (Bauteil − Abzugskörper) → dieselbe ohne Abzug. Scheitert truck am
|
||||
* Boolean, exportiert `exportProjectStep` das Bauteil wenigstens ungeschnitten.
|
||||
*/
|
||||
const VOID_FALLBACK = new WeakMap<SolidSpec, SolidSpec>();
|
||||
|
||||
/** Alle Bauteile des Projekts als B-Rep-Spezifikationen (reiner Kern, kein WASM). */
|
||||
/** Alle Bauteile des Projekts als B-Rep-Spezifikationen (Rust-Kern, `solid_specs.rs::project_solid_specs`; kein truck-WASM). */
|
||||
export function projectSolidSpecs(project: Project): SolidSpec[] {
|
||||
const out: SolidSpec[] = [];
|
||||
// Wände und Decken samt „Bauteil − Abzugskörper" aus dem Kern (`solid_specs.rs`, Abfrage `model3dParts` mit
|
||||
// Abzugskörpern): Detail „fein" (2), geschichtete Wände.
|
||||
const model = documentFor(project).query<{ walls: RWall[]; slabs: RSlab[]; voidCuts?: VoidCuts }>("model3dParts", [1, 2, 0, 1]);
|
||||
const wallCut = new Map(model.voidCuts?.walls ?? []);
|
||||
const slabCut = new Map(model.voidCuts?.slabs ?? []);
|
||||
const withCut = (base: SolidSpec, cut: SolidSpec | undefined): SolidSpec => {
|
||||
if (!cut) return base;
|
||||
VOID_FALLBACK.set(cut, base);
|
||||
return cut;
|
||||
};
|
||||
|
||||
model.walls.forEach((w, i) => {
|
||||
const s = wallSpec(w);
|
||||
if (s) out.push(withCut(s, wallCut.get(i)));
|
||||
});
|
||||
|
||||
model.slabs.forEach((s, i) => {
|
||||
if (s.outline.length < 3 || s.zTop - s.zBottom < MIN_THICKNESS) return;
|
||||
const base: SolidSpec = {
|
||||
kind: "extrude",
|
||||
points: s.outline.flatMap((p) => [p[0], p[1]]),
|
||||
height: s.zTop - s.zBottom,
|
||||
z0: s.zBottom,
|
||||
};
|
||||
out.push(withCut(base, slabCut.get(i)));
|
||||
});
|
||||
|
||||
for (const roof of project.roofs ?? []) {
|
||||
const total = roofLayers(project, roof).reduce((sum, l) => sum + Math.max(0, l.thickness), 0);
|
||||
if (total < MIN_THICKNESS) continue;
|
||||
const g = roofGeometry(roof, roofBaseElevation(project, roof));
|
||||
for (const pl of g.planes) {
|
||||
const p = pl.pts;
|
||||
if (p.length < 3) continue;
|
||||
// Lokales Koordinatensystem der (ebenen, konvexen) Dachfläche.
|
||||
const e1 = sub(p[1], p[0]);
|
||||
const e2 = sub(p[2], p[0]);
|
||||
let n = cross(e1, e2);
|
||||
const nl = Math.hypot(n[0], n[1], n[2]);
|
||||
if (nl < EPS) continue;
|
||||
n = [n[0] / nl, n[1] / nl, n[2] / nl];
|
||||
if (n[2] < 0) n = [-n[0], -n[1], -n[2]]; // Normale nach oben
|
||||
const el = Math.hypot(e1[0], e1[1], e1[2]);
|
||||
const u: [number, number, number] = [e1[0] / el, e1[1] / el, e1[2] / el];
|
||||
const v = cross(n, u); // u × v = n
|
||||
out.push({
|
||||
kind: "extrudePlane",
|
||||
points: p.flatMap((q) => {
|
||||
const d = sub(q, p[0]);
|
||||
return [dot(d, u), dot(d, v)];
|
||||
}),
|
||||
origin: [p[0][0], p[0][1], p[0][2]],
|
||||
uAxis: u,
|
||||
vAxis: [v[0], v[1], v[2]],
|
||||
depth: -total, // nach unten (Eindeckung oben)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (const solid of project.extrudedSolids ?? []) {
|
||||
if (solid.operation === "subtract") continue; // Abzugskörper sind kein Material
|
||||
let baseZ = 0;
|
||||
if (solid.levelId) {
|
||||
try {
|
||||
baseZ = getFloor(project, solid.levelId).baseElevation ?? 0;
|
||||
} catch {
|
||||
baseZ = 0;
|
||||
}
|
||||
}
|
||||
const spec = extrudedSolidSpec(solid, baseZ);
|
||||
if (spec) out.push(spec);
|
||||
}
|
||||
return out;
|
||||
const r = documentFor(project).query<{ specs: SolidSpec[]; fallbacks: [number, SolidSpec][] }>("projectSolidSpecs", []);
|
||||
for (const [i, base] of r.fallbacks) VOID_FALLBACK.set(r.specs[i], base);
|
||||
return r.specs;
|
||||
}
|
||||
|
||||
type V3 = [number, number, number];
|
||||
const sub = (a: ArrayLike<number>, b: ArrayLike<number>): V3 => [a[0] - b[0], a[1] - b[1], a[2] - b[2]];
|
||||
const dot = (a: ArrayLike<number>, b: ArrayLike<number>): number => a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
||||
const cross = (a: ArrayLike<number>, b: ArrayLike<number>): V3 => [
|
||||
a[1] * b[2] - a[2] * b[1],
|
||||
a[2] * b[0] - a[0] * b[2],
|
||||
a[0] * b[1] - a[1] * b[0],
|
||||
];
|
||||
|
||||
/** Ergebnis des Projekt-Exports. */
|
||||
export interface StepExportResult {
|
||||
text: string;
|
||||
|
||||
Reference in new issue
Block a user