import { dustPortCircle, dustPortDimensions, dustPortOutline, dustPortValues, validateDustPort } from "../bolt-on-dust-port"; import type { CadKernel, CadParameters, Manifold } from "./kernel"; /** Original flat flange and straight cuff. Print orientation is flange-down. */ export function buildBoltOnDustPort(k: CadKernel, input: CadParameters): Manifold { validateDustPort(input); const p = dustPortValues(input), d = dustPortDimensions(input); const bore = k.move2(k.polygon(dustPortCircle(d.inner / 2)), [p.offset_x, p.offset_y]); const outside = k.move2(k.polygon(dustPortCircle(d.outer / 2)), [p.offset_x, p.offset_y]); const screws = d.holes.map(point => k.move2(k.polygon(dustPortCircle(p.screw_diameter / 2)), point)); const flange = k.extrude(k.sub2(k.polygon(dustPortOutline(input)), bore, ...screws), p.plate_thickness); const tube = k.move(k.extrude(k.sub2(outside, bore), p.engagement), [0, 0, p.plate_thickness]); return k.union(flange, tube); }