move cam slice rendering into driver
This commit is contained in:
parent
c3fd40d205
commit
57a380872d
3 changed files with 70 additions and 6 deletions
|
|
@ -16,6 +16,7 @@ var gs_kiri_cam = exports;
|
||||||
POLY = BASE.polygons,
|
POLY = BASE.polygons,
|
||||||
CAM = KIRI.driver.CAM = {
|
CAM = KIRI.driver.CAM = {
|
||||||
slice,
|
slice,
|
||||||
|
sliceRender,
|
||||||
printSetup,
|
printSetup,
|
||||||
printExport,
|
printExport,
|
||||||
getToolById,
|
getToolById,
|
||||||
|
|
@ -420,7 +421,7 @@ var gs_kiri_cam = exports;
|
||||||
x, y, tv, ltv;
|
x, y, tv, ltv;
|
||||||
|
|
||||||
// for each Y slice, find z grid value (x/z swapped)
|
// for each Y slice, find z grid value (x/z swapped)
|
||||||
for (let j=0; j<slices.length; j++) {
|
for (let j=0, jl=slices.length; j<jl; j++) {
|
||||||
let slice = slices[j],
|
let slice = slices[j],
|
||||||
lines = slice.lines;
|
lines = slice.lines;
|
||||||
gridy = 0;
|
gridy = 0;
|
||||||
|
|
@ -429,8 +430,7 @@ var gs_kiri_cam = exports;
|
||||||
gridi = gridx * stepsy + gridy;
|
gridi = gridx * stepsy + gridy;
|
||||||
gridv = data[gridi] || 0;
|
gridv = data[gridi] || 0;
|
||||||
// strategy using raw lines (faster slice, but more lines)
|
// strategy using raw lines (faster slice, but more lines)
|
||||||
for (let i=0; i<lines.length; i++) {
|
for (let i=0, il=lines.length; i<il; i++) {
|
||||||
// let {p1, p2} = lines[i];
|
|
||||||
let line = lines[i], p1 = line.p1, p2 = line.p2;
|
let line = lines[i], p1 = line.p1, p2 = line.p2;
|
||||||
if (
|
if (
|
||||||
(p1.z > zMin || p2.z > zMin) && // one endpoint above 0
|
(p1.z > zMin || p2.z > zMin) && // one endpoint above 0
|
||||||
|
|
@ -514,7 +514,7 @@ var gs_kiri_cam = exports;
|
||||||
if (proc.finishingYOn) {
|
if (proc.finishingYOn) {
|
||||||
startTime = time();
|
startTime = time();
|
||||||
// emit slice per Y
|
// emit slice per Y
|
||||||
for (y = minY; y < maxY; y += toolStep) {
|
for (y = minY; y <= maxY; y += toolStep) {
|
||||||
gridy = Math.round(((y - minY) / boundsY) * stepsy);
|
gridy = Math.round(((y - minY) / boundsY) * stepsy);
|
||||||
lx = gridx = 0;
|
lx = gridx = 0;
|
||||||
slice = newSlice(gridy, mesh.newGroup ? mesh.newGroup() : null);
|
slice = newSlice(gridy, mesh.newGroup ? mesh.newGroup() : null);
|
||||||
|
|
@ -1050,6 +1050,68 @@ var gs_kiri_cam = exports;
|
||||||
ondone();
|
ondone();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// runs in browser main
|
||||||
|
function sliceRender(widget) {
|
||||||
|
let slices = widget.slices;
|
||||||
|
if (!slices) return;
|
||||||
|
|
||||||
|
slices.forEach(function(slice) {
|
||||||
|
let tops = slice.tops,
|
||||||
|
layers = slice.layers,
|
||||||
|
outline = layers.outline,
|
||||||
|
open = (slice.camMode === CPRO.FINISH_X || slice.camMode === CPRO.FINISH_Y);
|
||||||
|
|
||||||
|
layers.outline.clear(); // slice raw edges
|
||||||
|
layers.trace.clear(); // roughing
|
||||||
|
layers.solid.clear(); // finish
|
||||||
|
layers.bridge.clear(); // finish x
|
||||||
|
layers.flat.clear(); // finish y
|
||||||
|
layers.fill.clear(); // facing
|
||||||
|
|
||||||
|
tops.forEach(function(top) {
|
||||||
|
outline.poly(top.poly, 0x999900, true, open);
|
||||||
|
if (top.inner) outline.poly(top.inner, 0xdddddd, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
// various finishing
|
||||||
|
let layer;
|
||||||
|
slice.tops.forEach(function(top) {
|
||||||
|
switch (slice.camMode) {
|
||||||
|
case CPRO.FINISH:
|
||||||
|
layer = layers.solid;
|
||||||
|
break;
|
||||||
|
case CPRO.FINISH_X:
|
||||||
|
layer = layers.bridge;
|
||||||
|
break;
|
||||||
|
case CPRO.FINISH_Y:
|
||||||
|
layer = layers.flat;
|
||||||
|
break;
|
||||||
|
default: // roughing
|
||||||
|
layer = layers.trace;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (top.traces) {
|
||||||
|
layer.poly(top.traces, 0x0, true, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// facing (once used fill, now part of roughing)
|
||||||
|
layer = slice.layers.fill;
|
||||||
|
slice.tops.forEach(function(top) {
|
||||||
|
if (top.fill_lines) {
|
||||||
|
layer.lines(top.fill_lines, fill_color);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
outline.render();
|
||||||
|
layers.trace.render();
|
||||||
|
layers.solid.render();
|
||||||
|
layers.bridge.render();
|
||||||
|
layers.flat.render();
|
||||||
|
layers.fill.render();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DRIVER PRINT CONTRACT
|
* DRIVER PRINT CONTRACT
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -468,7 +468,8 @@ var gs_kiri_init = exports;
|
||||||
let name = WIN.prompt("Download Settings Filename", "kiriconf");
|
let name = WIN.prompt("Download Settings Filename", "kiriconf");
|
||||||
if (!name) return;
|
if (!name) return;
|
||||||
let json = API.conf.export(),
|
let json = API.conf.export(),
|
||||||
url = WIN.URL.createObjectURL(new Blob([json], {type: "octet/stream"}));
|
blob = new Blob([json], {type: "octet/stream"}),
|
||||||
|
url = WIN.URL.createObjectURL(blob);
|
||||||
$('help').innerHTML = `<a id="sexport" href="${url}" download="${name}.b64">x</a>`;
|
$('help').innerHTML = `<a id="sexport" href="${url}" download="${name}.b64">x</a>`;
|
||||||
$('sexport').click();
|
$('sexport').click();
|
||||||
}
|
}
|
||||||
|
|
@ -1296,7 +1297,7 @@ var gs_kiri_init = exports;
|
||||||
layers: UC.setGroup($("layers")),
|
layers: UC.setGroup($("layers")),
|
||||||
layerOutline: UC.newBoolean(LANG.la_olin, onLayerToggle, {modes:LOCAL ? ALL : FDM_LASER}),
|
layerOutline: UC.newBoolean(LANG.la_olin, onLayerToggle, {modes:LOCAL ? ALL : FDM_LASER}),
|
||||||
layerTrace: UC.newBoolean(LANG.la_trce, onLayerToggle, {modes:FDM_LASER}),
|
layerTrace: UC.newBoolean(LANG.la_trce, onLayerToggle, {modes:FDM_LASER}),
|
||||||
layerFacing: UC.newBoolean(LANG.la_face, onLayerToggle, {modes:CAM}),
|
layerFacing: UC.newBoolean(LANG.la_face, onLayerToggle, {modes:[]}), // see sliceRender() in CAM
|
||||||
layerRough: UC.newBoolean(LANG.la_ruff, onLayerToggle, {modes:CAM}),
|
layerRough: UC.newBoolean(LANG.la_ruff, onLayerToggle, {modes:CAM}),
|
||||||
layerFinish: UC.newBoolean(LANG.la_fini, onLayerToggle, {modes:CAM}),
|
layerFinish: UC.newBoolean(LANG.la_fini, onLayerToggle, {modes:CAM}),
|
||||||
layerFinishX: UC.newBoolean(LANG.la_finx, onLayerToggle, {modes:CAM}),
|
layerFinishX: UC.newBoolean(LANG.la_finx, onLayerToggle, {modes:CAM}),
|
||||||
|
|
|
||||||
1
notes.md
1
notes.md
|
|
@ -43,6 +43,7 @@
|
||||||
* `B` fails in pancaking (clone) when there are no sliced layers (like z bottom too high)
|
* `B` fails in pancaking (clone) when there are no sliced layers (like z bottom too high)
|
||||||
* `B` linear finishing should extend beyond part boundaries by tool radius
|
* `B` linear finishing should extend beyond part boundaries by tool radius
|
||||||
* `B` outside cutting direction in roughing mode inverted
|
* `B` outside cutting direction in roughing mode inverted
|
||||||
|
* `F` z bounded slices (extension of z bottom offset feature)
|
||||||
* `F` do not mill out thru-pockets. cut outline only.
|
* `F` do not mill out thru-pockets. cut outline only.
|
||||||
* `F` use arcs to connect hard angles
|
* `F` use arcs to connect hard angles
|
||||||
* `F` do not rough areas that go all the way through the part
|
* `F` do not rough areas that go all the way through the part
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue