fix tab cuts and stock clip to in roughing
This commit is contained in:
parent
53ee6783f7
commit
ce444c2b33
4 changed files with 45 additions and 35 deletions
|
|
@ -19,6 +19,7 @@ let meshes = {},
|
|||
speed,
|
||||
origin,
|
||||
color = 0,
|
||||
dark = false,
|
||||
A2R = Math.PI / 180;
|
||||
|
||||
export function animate_clear2(api) {
|
||||
|
|
@ -35,6 +36,7 @@ export function animate_clear2(api) {
|
|||
export function animate2(api, delay) {
|
||||
let alert = api.alerts.show("building animation");
|
||||
let settings = api.conf.get();
|
||||
dark = settings.controller.dark;
|
||||
client.animate_setup2(settings, data => {
|
||||
handleUpdate(data);
|
||||
if (data) {
|
||||
|
|
@ -89,7 +91,7 @@ Object.assign(client, {
|
|||
|
||||
animate_setup2(settings, ondone) {
|
||||
initPathMesh();
|
||||
color = settings.controller.dark ? 0x888888 : 0;
|
||||
color = dark ? 0x888888 : 0;
|
||||
material = material ?? new THREE.MeshPhongMaterial({
|
||||
flatShading: true,
|
||||
transparent: false,
|
||||
|
|
@ -113,7 +115,7 @@ function initPathMesh() {
|
|||
max = 10000,
|
||||
rot = new THREE.Euler(0,0,0),
|
||||
geo = new THREE.BufferGeometry(),
|
||||
mat = new THREE.LineBasicMaterial({ color: 0xffff00 }),
|
||||
mat = new THREE.LineBasicMaterial({ color: dark ? 0xffff00 : 0x771100 }),
|
||||
pos = new Float32Array(max * 6),
|
||||
lines = new THREE.LineSegments(geo, mat),
|
||||
vec = new THREE.Vector3(0,0,0),
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ class OpOutline extends CamOp {
|
|||
|
||||
async slice(progress) {
|
||||
let { op, state } = this;
|
||||
let { settings, widget, slicer, addSlices, tshadow, thruHoles, unsafe, color } = state;
|
||||
let { settings, slicer, addSlices, tshadow, thruHoles, unsafe, color } = state;
|
||||
let { updateToolDiams, tabs, cutTabs, cutPolys, workarea, zMax, shadowAt } = state;
|
||||
let { process, stock } = settings;
|
||||
let { controller } = settings;
|
||||
|
||||
if (op.down <= 0) {
|
||||
throw `invalid step down "${op.down}"`;
|
||||
|
|
@ -191,7 +192,7 @@ class OpOutline extends CamOp {
|
|||
tabs.forEach(tab => {
|
||||
tab.off = POLY.expand([tab.poly], toolDiam / 2).flat();
|
||||
});
|
||||
offset = cutTabs(tabs, offset, slice.z);
|
||||
offset = cutTabs(tabs, offset);
|
||||
}
|
||||
|
||||
if (process.camStockClipTo && stock.x && stock.y && stock.center) {
|
||||
|
|
@ -208,9 +209,12 @@ class OpOutline extends CamOp {
|
|||
|
||||
// project empty up and render
|
||||
for (let slice of slices) {
|
||||
if (false) slice.output()
|
||||
if (controller.devel) slice.output()
|
||||
.setLayer("slice", {line: 0xaaaa00}, false)
|
||||
.addPolys(slice.topPolys())
|
||||
if (controller.devel) slice.output()
|
||||
.setLayer("shadow", {line: 0x557799}, false)
|
||||
.addPolys(slice.shadow)
|
||||
slice.output()
|
||||
.setLayer(state.layername, {face: color, line: color})
|
||||
.addPolys(slice.camLines);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class OpRough extends CamOp {
|
|||
let { updateToolDiams, thruHoles, tabs, cutTabs, cutPolys } = state;
|
||||
let { ztOff, zMax, shadowAt, isIndexed} = state;
|
||||
let { workarea } = state;
|
||||
let { process, stock } = settings;
|
||||
let { controller, process, stock } = settings;
|
||||
|
||||
if (op.down <= 0) {
|
||||
throw `invalid step down "${op.down}"`;
|
||||
|
|
@ -206,20 +206,6 @@ class OpRough extends CamOp {
|
|||
}
|
||||
}
|
||||
|
||||
if (tabs) {
|
||||
tabs.forEach(tab => {
|
||||
tab.off = POLY.expand([tab.poly], toolDiam / 2).flat();
|
||||
});
|
||||
offset = cutTabs(tabs, offset, slice.z);
|
||||
}
|
||||
|
||||
if (!offset) return;
|
||||
|
||||
if (process.camStockClipTo && stock.x && stock.y && stock.center) {
|
||||
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) {
|
||||
|
|
@ -236,24 +222,42 @@ class OpRough extends CamOp {
|
|||
}
|
||||
});
|
||||
|
||||
if (process.camStockClipTo && stock.x && stock.y && stock.center) {
|
||||
let rect = newPolygon().centerRectangle(stock.center, stock.x + 0.001, stock.y + 0.001);
|
||||
offset = cutPolys([rect], offset, slice.z, true);
|
||||
}
|
||||
|
||||
if (tabs) {
|
||||
tabs.forEach(tab => {
|
||||
tab.off = POLY.expand([tab.poly], toolDiam / 2).flat();
|
||||
});
|
||||
offset = cutTabs(tabs, offset);
|
||||
}
|
||||
|
||||
if (!offset) return;
|
||||
|
||||
slice.camLines = offset;
|
||||
if (roughLeaveZ) {
|
||||
// offset roughing in Z as well to minimize
|
||||
// tool marks on curved surfaces
|
||||
// offset roughing in Z as well to minimize tool marks on curved surfaces
|
||||
// const roughLeaveZ = 1 * Math.min(roughDown, roughLeave / 2);
|
||||
slice.camLines.forEach(p => {
|
||||
p.setZ(p.getZ() + roughLeaveZ);
|
||||
});
|
||||
for (let poly of slice.camLines) {
|
||||
for (let point of poly.points) point.z += roughLeaveZ;
|
||||
}
|
||||
}
|
||||
if (controller.devel) {
|
||||
slice.output()
|
||||
.setLayer("tabs clip", {line: 0xaa00aa}, true)
|
||||
.addPolys(tabs.map(tab => tab.off).flat());
|
||||
slice.output()
|
||||
.setLayer("slice", {line: 0xaaaa00}, true)
|
||||
.addPolys(slice.topPolys())
|
||||
// .setLayer("top shadow", {line: 0x0000aa})
|
||||
// .addPolys(tshadow)
|
||||
// .setLayer("rough shadow", {line: 0x00aa00})
|
||||
// .addPolys(shadow)
|
||||
.setLayer("shadow clip", {line: 0xaa0000})
|
||||
.addPolys(shell);
|
||||
}
|
||||
if (false) slice.output()
|
||||
.setLayer("slice", {line: 0xaaaa00}, true)
|
||||
.addPolys(slice.topPolys())
|
||||
// .setLayer("top shadow", {line: 0x0000aa})
|
||||
// .addPolys(tshadow)
|
||||
// .setLayer("rough shadow", {line: 0x00aa00})
|
||||
// .addPolys(shadow)
|
||||
.setLayer("rough shell", {line: 0xaa0000})
|
||||
.addPolys(shell);
|
||||
progress(0.5 + 0.5 * (index / slices.length));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -801,7 +801,7 @@ function cutTabs(tabs, offset) {
|
|||
|
||||
function cutPolys(polys, offset) {
|
||||
let noff = [];
|
||||
offset.forEach(op => noff.appendAll(op.cut(POLY.union(polys, 0, true))));
|
||||
offset.forEach(op => noff.appendAll( op.cut(POLY.union(polys, 0, true), true) ));
|
||||
return healPolys(noff);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue