[K4] STEP-Export liest Kern-Spezifikationen (solid_specs), TS-Void-Helfer gelöscht

This commit is contained in:
Claude committed 2026-10-29 17:48:38 +00:00
1 parent 27c187de01
commit 9d7c0c8bf3
4 files changed
+30 -102

No files matched your search

+5 -1
View File
@@ -775,7 +775,7 @@ truck (`trucksolid`) bleibt eigenes WASM-Modul (Panic-Isolation), wird vom Kern
✅ (29.10.) **Rich-Text-Bearbeitung im Kern** ([K4]): `core/src/rich_text.rs` (Marks setzen/umschalten, `isMarkActive`,
`commonMarkValue`, Normalisieren, stabile Serialisierung, Stile anwenden; Offsets in UTF-16 wie TS), Bindungen
`web/rich_text.rs`; `text/richText.ts` behält Konstruktoren/Reintext/`DEFAULT_PRESETS` und ist sonst Fassade mit gleichen
Signaturen (gelöscht: `mapRunsInRange`, `marksEqual`, `normalizeMarks`, `makeRun`, kein Aufrufer). Gleichheit (einmalig,
Signaturen (gelöscht: `mapRunsInRange`, `marksEqual`, `normalizeMarks`, kein Aufrufer). Gleichheit (einmalig,
Test gelöscht): 500 Zufallsdokumente × alle Operationen alt/neu gleich. Abweichung: Bereich mitten in einem Surrogatpaar
ergibt U+FFFD (im Editor nicht erreichbar). Nicht in der Tauri-App geprüft.
✅ (29.10.) **Gebäude-Mesh-Aufbereitung im Kern** ([K4]): `core/src/geo_mesh.rs` (Zuschnitt auf Bounding-Box, Zerlegen in
@@ -790,6 +790,10 @@ truck (`trucksolid`) bleibt eigenes WASM-Modul (Panic-Isolation), wird vom Kern
Kontextobjekt-Erzeugung (`featuresToContextObjects`) bleibt TS (Modellobjekte mit Ids und Beschriftung). Gleichheit
(einmalig, Test gelöscht): 400 Zufallsfolgen von Footprints (Kreis, Stern, unregelmässig, geschlossen, entartet, offen,
Höhen inkl. ungültig) Positionen und Indizes identisch.
✅ (29.10.) **STEP-Export liest die Kern-Spezifikationen** ([K4]): `export/exportStep.ts` holt Wände/Decken samt
„Bauteil − Abzugskörper" aus `model3dParts` (`solid_specs.rs`); gelöscht: `voidPrisms`, `hittingVoids`, `subtractSpec`,
`bbox`, `wallCorners`, `isVoidSolid`, `solidBaseZ` aus `plan/voids.ts`. Gleichheit (einmalig, Test gelöscht): Spezifikationen
des Beispielprojekts und von 6 Projekten mit Abzugskörper JSON-gleich alt/neu.
✅ (29.10.) **Fang-Kandidaten aus dem Modell im Kern** ([K4] S3/[K3d]): `snap_model.rs` sammelt je Dokument-Stand,
Geschoss und sichtbaren Ebenen (vorher `baseSegments`/`collectCircles`/`roomAnchors`/`ellipseCenters` in
`tools/snapping.ts`): Wandachsen + Schichtgrenzen, Raum-/Decken- (mit Aussparungen)/Dach-/Treppen-/Stützen-Umrisse,
+19 -18
View File
@@ -15,14 +15,14 @@
import type { Project } from "../model/types";
import { getFloor, roofLayers } from "../model/types";
import { projectToModel3d } from "../plan/toWalls3d";
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";
import { bbox, hittingVoids, subtractSpec, voidPrisms, wallCorners } from "../plan/voids";
import type { Box2 } from "../plan/voids";
export { wallProfile, wallSpec } from "../plan/wallSpec";
@@ -39,31 +39,32 @@ 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;
// 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;
};
for (const w of model.walls) {
model.walls.forEach((w, i) => {
const s = wallSpec(w);
if (s) out.push(withVoids(s, bbox(wallCorners(w)), w.baseElevation, w.baseElevation + w.height));
}
if (s) out.push(withCut(s, wallCut.get(i)));
});
for (const s of model.slabs) {
if (s.outline.length < 3 || s.zTop - s.zBottom < MIN_THICKNESS) continue;
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(withVoids(base, bbox(s.outline.map((p) => ({ x: p[0], y: p[1] }))), s.zBottom, s.zTop));
}
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);
+1 -83
View File
@@ -9,8 +9,7 @@
// (`core/src/plan/section.rs`).
// • 3D: Boolean-Differenz (truck, Mesh-CSG-Fallback); welche Bauteile getroffen sind und
// ihre Spezifikation rechnet der Kern (`core/src/solid_specs.rs`), s. `toWalls3d/voids3d.ts`.
// • STEP: `exportStep.ts` mit den Helfern unten (gleiche Regeln wie `solid_specs.rs`; fallen,
// wenn der STEP-Sammler die Kern-Spezifikationen liest).
// • STEP: `exportStep.ts` liest dieselben Kern-Spezifikationen (`model3dParts` mit Abzugskörpern).
//
// Abzugskörper sind senkrechte Prismen (Profil × Höhe, ohne Verjüngung/B-Rep) — damit bleiben
// Grundriss und Schnitt exakt analytisch (ein Prisma schneidet eine waagrechte Ebene in seiner
@@ -21,44 +20,6 @@
import type { Pair } from "../geometry/polygonBool";
import { core } from "../engine/coreWasm";
import type { ExtrudedSolid, Project, Vec2 } from "../model/types";
import { getFloor } from "../model/types";
import type { SolidSpec } from "../engine/truckSolid";
import type { RWall } from "./toWalls3d/shared";
export interface VoidPrism {
id: string;
pts: Vec2[];
z0: number;
z1: number;
}
/** Ob ein Körper als Abzugskörper wirkt (Prisma mit gültigem Profil). */
export function isVoidSolid(s: ExtrudedSolid): boolean {
return s.operation === "subtract" && !s.brep && (s.taper ?? 0) < 1e-6 && s.points.length >= 3 && s.height > 0;
}
/** UK des Körpers (Geschoss-UK + `baseOffset`). */
export function solidBaseZ(project: Project, s: ExtrudedSolid): number {
let base = 0;
try {
base = getFloor(project, s.levelId).baseElevation ?? 0;
} catch {
base = 0;
}
return base + (s.baseOffset ?? 0);
}
/** Alle Abzugskörper des Projekts (Welt-Höhen). */
export function voidPrisms(project: Project): VoidPrism[] {
const out: VoidPrism[] = [];
for (const s of project.extrudedSolids ?? []) {
if (!isVoidSolid(s)) continue;
const z0 = solidBaseZ(project, s);
out.push({ id: s.id, pts: s.points, z0, z1: z0 + s.height });
}
return out;
}
// ── Polygon-Booleans (Rust-Kern, `voids.rs`) ─────────────────────────────────
@@ -103,46 +64,3 @@ export function subtractRings(
}
return out;
}
// ── 3D / B-Rep ───────────────────────────────────────────────────────────────
export type Box2 = { x0: number; y0: number; x1: number; y1: number };
export const bbox = (pts: Array<{ x: number; y: number }>): Box2 => ({
x0: Math.min(...pts.map((p) => p.x)),
y0: Math.min(...pts.map((p) => p.y)),
x1: Math.max(...pts.map((p) => p.x)),
y1: Math.max(...pts.map((p) => p.y)),
});
const boxHit = (a: Box2, b: Box2) => a.x0 < b.x1 && b.x0 < a.x1 && a.y0 < b.y1 && b.y0 < a.y1;
export function wallCorners(w: RWall): Array<{ x: number; y: number }> {
const dx = w.end[0] - w.start[0];
const dy = w.end[1] - w.start[1];
const len = Math.hypot(dx, dy) || 1;
const nx = (-dy / len) * (w.thickness / 2);
const ny = (dx / len) * (w.thickness / 2);
return [
{ x: w.start[0] + nx, y: w.start[1] + ny },
{ x: w.end[0] + nx, y: w.end[1] + ny },
{ x: w.end[0] - nx, y: w.end[1] - ny },
{ x: w.start[0] - nx, y: w.start[1] - ny },
];
}
const voidSpec = (v: VoidPrism): SolidSpec => ({
kind: "extrude",
points: v.pts.flatMap((p) => [p.x, p.y]),
height: v.z1 - v.z0,
z0: v.z0,
});
/** Bauteil minus alle Körper (verkettete Differenzen). */
export function subtractSpec(base: SolidSpec, voids: VoidPrism[]): SolidSpec {
return voids.reduce<SolidSpec>((acc, v) => ({ kind: "boolean", op: "difference", a: acc, b: voidSpec(v) }), base);
}
/** Abzugskörper, die ein Prisma (Grundriss-Hülle + Höhenbereich) treffen. */
export function hittingVoids(voids: VoidPrism[], foot: Box2, z0: number, z1: number): VoidPrism[] {
return voids.filter((v) => v.z0 < z1 - 1e-6 && v.z1 > z0 + 1e-6 && boxHit(bbox(v.pts), foot));
}
+5
View File
@@ -55,6 +55,11 @@ export function docFromText(text: string, marks: Marks = {}): RichTextDoc {
return { version: 1, paragraphs };
}
/** Erzeugt einen Run (defensive Kopie der Marks). */
export function makeRun(text: string, marks: Marks = {}): TextRun {
return { text, marks: { ...marks } };
}
// ── Extraktion ─────────────────────────────────────────────────────────────
/** Reintext des Dokuments; Absätze werden mit "\n" verbunden. */