import { panelDimensions, panelOutline, panelValues, validatePanel } from "../project-panel"; import type { CadKernel, CadParameters } from "./kernel"; /** One extrusion of a perforated face; the preview and STL share this solid. */ export function buildProjectPanel(c: CadKernel, input: CadParameters) { validatePanel(input); const p = panelValues(input), d = panelDimensions(p); const holes = d.openings.map(o => c.polygon(o.outline)); for (const screw of d.screws) holes.push(c.move2(c.polygon(panelOutline(p.screw_diameter, p.screw_diameter, p.screw_diameter / 2, true)), [screw.x, screw.y])); const face = c.sub2(c.polygon(d.outline), ...holes); return c.move(c.extrude(face, p.thickness), [-p.width / 2, -p.height / 2, 0]); }