[G1] Merge: Poché für Körper, Abzugskörper beliebiger Form, exakte Treppenuntersicht

This commit is contained in:
Claude committed 2026-11-05 06:01:26 +00:00
commit f0d9bc7aa3
8 files changed
+259 -13

No files matched your search

@@ -4,4 +4,4 @@ line 35
polygon 31
rect 1
svg 1
hash 12af29f2ceb8cdc6
hash 58399ffc23652b9f
+25
View File
@@ -58,4 +58,29 @@ describe("Schnitt: Gelände und freie Körper", () => {
const plan = generateSectionPlan((await computeSection(p, section))!);
expect(plan.primitives.some((q) => q.kind === "polygon" && q.extrudedSolidId === "ball" && q.fill === "#d9dde2")).toBe(true);
}, 30_000);
it("Abzugskörper beliebiger Form (Kugel, B-Rep) spart die Schnittflächen aus, ohne selbst zu erscheinen", async () => {
const floor = sampleProject.drawingLevels.find((l) => l.kind === "floor")!;
const [a, b] = section.linePoints!;
const cx = (a.x + b.x) / 2;
const cy = (a.y + b.y) / 2;
const r = 2;
const ball: ExtrudedSolid = {
id: "void-ball", type: "extrudedSolid", levelId: floor.id, height: 2 * r, operation: "subtract",
points: [{ x: cx - r, y: cy - r }, { x: cx + r, y: cy - r }, { x: cx + r, y: cy + r }, { x: cx - r, y: cy + r }],
brep: { spec: { kind: "sphere", center: [cx, cy, 1], r }, origin: { x: cx - r, y: cy - r } },
};
const cutArea = async (p: Project) => {
const plan = generateSectionPlan((await computeSection(p, section))!);
expect(plan.primitives.some((q) => q.kind === "polygon" && q.extrudedSolidId === "void-ball")).toBe(false);
return plan.primitives.reduce((s, q) => {
if (q.kind !== "polygon" || q.fill === "none") return s;
const n = q.pts.length;
return s + Math.abs(q.pts.reduce((t, v, i) => t + v.x * q.pts[(i + 1) % n].y - q.pts[(i + 1) % n].x * v.y, 0)) / 2;
}, 0);
};
const before = await cutArea(sampleProject);
const after = await cutArea({ ...sampleProject, extrudedSolids: [...(sampleProject.extrudedSolids ?? []), ball] });
expect(after).toBeLessThan(before - 0.1);
}, 30_000);
});
+3 -1
View File
@@ -49,7 +49,9 @@ export async function computeSection(project: Project, level: DrawingLevel): Pro
const solids = project.extrudedSolids ?? [];
for (let index = 0; index < solids.length; index++) {
const solid = solids[index];
if (solid.operation === "subtract" || isVoid(solid)) continue;
// Senkrechte Prismen-Abzugskörper rechnet der Kern selbst; alle übrigen Abzugskörper ([G1]) kommen
// als Netz mit und werden im Kern aus den Schnittflächen ausgespart.
if (isVoid(solid)) continue;
let baseZ = 0;
try {
baseZ = solid.levelId ? (getFloor(project, solid.levelId).baseElevation ?? 0) : 0;