add clip-to-stock for roughing and outlines

This commit is contained in:
Stewart Allen 2021-01-06 12:32:32 -05:00
commit 7aee1b19a5
7 changed files with 31 additions and 7 deletions

View file

@ -105,8 +105,9 @@
slice(progress) {
let { op, state } = this;
let { settings, widget, slicer, sliceAll, unsafe } = state;
let { updateToolDiams, thruHoles, tabs, cutTabs } = state;
let { updateToolDiams, thruHoles, tabs, cutTabs, cutPolys } = state;
let { tshadow, shadowTop, ztOff, zBottom, zMax } = state;
let { process, stock } = settings;
let roughIn = op.inside;
let roughTop = op.top;
@ -261,6 +262,11 @@
if (!offset) return;
if (process.camStockClipTo) {
let rect = newPolygon().centerRectangle(stock.center, stock.x, stock.y);
offset = cutPolys([rect], offset, slice.z, true);
}
// elimate double inset on inners
offset.forEach(op => {
if (op.inner) {
@ -376,7 +382,8 @@
slice(progress) {
let { op, state } = this;
let { settings, widget, slicer, sliceAll, tshadow, thruHoles, unsafe } = state;
let { updateToolDiams, zThru, zBottom, shadowTop, tabs, cutTabs } = state;
let { updateToolDiams, zThru, zBottom, shadowTop, tabs, cutTabs, cutPolys } = state;
let { process, stock } = settings;
let toolDiam = this.toolDiam = new CAM.Tool(settings, op.tool).fluteDiameter();
updateToolDiams(toolDiam);
@ -497,6 +504,11 @@
CAM.addDogbones(offset, toolDiam / 5);
}
if (process.camStockClipTo) {
let rect = newPolygon().centerRectangle(stock.center, stock.x, stock.y);
offset = cutPolys([rect], offset, slice.z, true);
}
// offset.xout(`slice ${slice.z}`);
slice.camLines = offset;
if (false) slice.output()

View file

@ -105,6 +105,7 @@
bounds,
tabs,
cutTabs,
cutPolys,
slicer,
sliceAll,
updateToolDiams,
@ -265,10 +266,15 @@
return true;
};
function cutTabs(tabs, offset, z) {
let noff = [];
function cutTabs(tabs, offset, z, inter) {
tabs = tabs.filter(tab => z < tab.pos.z + tab.dim.z/2).map(tab => tab.off).flat();
offset.forEach(op => noff.appendAll( op.cut(POLY.union(tabs, 0, true)) ));
return cutPolys(tabs, offset, z, false);
}
function cutPolys(polys, offset, z, inter) {
let noff = [];
// tabs = tabs.filter(tab => z < tab.pos.z + tab.dim.z/2).map(tab => tab.off).flat();
offset.forEach(op => noff.appendAll( op.cut(POLY.union(polys, 0, true), inter) ));
if (noff.length > 1) {
let heal = 0;
// heal/rejoin open segments that share endpoints