checkpoint before cut/prepare refactor. comments
This commit is contained in:
parent
a15e73495f
commit
8017fe37e5
5 changed files with 33 additions and 17 deletions
|
|
@ -16,7 +16,9 @@ const DEG2RAD = Math.PI / 180;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* emit each element in an array based on
|
* emit each element in an array based on
|
||||||
* the next closest endpoint.
|
* the next closest endpoint. arrays contain
|
||||||
|
* elements with { first, last } points and
|
||||||
|
* may be open polys, unlike poly2polyEmit
|
||||||
*/
|
*/
|
||||||
function tip2tipEmit(array, startPoint, emitter) {
|
function tip2tipEmit(array, startPoint, emitter) {
|
||||||
let mindist, dist, found, count = 0;
|
let mindist, dist, found, count = 0;
|
||||||
|
|
|
||||||
|
|
@ -129,13 +129,13 @@ function sliceEmitObjects(print, slice, groups, opt = { }) {
|
||||||
let lastEmit = opt.lastEmit;
|
let lastEmit = opt.lastEmit;
|
||||||
let zcolor = print.settings.process.ctOutZColor;
|
let zcolor = print.settings.process.ctOutZColor;
|
||||||
|
|
||||||
function laserOut(poly, group, type, indexed) {
|
function polyOut(poly, group, type, indexed) {
|
||||||
if (!poly) {
|
if (!poly) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (Array.isArray(poly)) {
|
if (Array.isArray(poly)) {
|
||||||
poly.forEach((pi, index) => {
|
poly.forEach((pi, index) => {
|
||||||
laserOut(pi, group, type, indexed ? index : undefined);
|
polyOut(pi, group, type, indexed ? index : undefined);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let pathOpt = zcolor ? {extrude: slice.z, rate: slice.z} : {extrude: 1, rate: 1};
|
let pathOpt = zcolor ? {extrude: slice.z, rate: slice.z} : {extrude: 1, rate: 1};
|
||||||
|
|
@ -153,7 +153,7 @@ function sliceEmitObjects(print, slice, groups, opt = { }) {
|
||||||
if (stacked && type === "out" && lastEmit) {
|
if (stacked && type === "out" && lastEmit) {
|
||||||
for (let out of lastEmit.out) {
|
for (let out of lastEmit.out) {
|
||||||
if (out.isInside(poly)) {
|
if (out.isInside(poly)) {
|
||||||
laserOut(out, group, "mark");
|
polyOut(out, group, "mark");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -166,15 +166,15 @@ function sliceEmitObjects(print, slice, groups, opt = { }) {
|
||||||
let offset = slice.offset;
|
let offset = slice.offset;
|
||||||
let inner = offset.map(poly => poly.inner || []).flat();
|
let inner = offset.map(poly => poly.inner || []).flat();
|
||||||
// cut inside before outside
|
// cut inside before outside
|
||||||
laserOut(inner, group, "in", offset.length > 1);
|
polyOut(inner, group, "in", offset.length > 1);
|
||||||
laserOut(offset, group, "out", offset.length > 1);
|
polyOut(offset, group, "out", offset.length > 1);
|
||||||
groups.push(group);
|
groups.push(group);
|
||||||
} else {
|
} else {
|
||||||
for (let top of slice.offset) {
|
for (let top of slice.offset) {
|
||||||
let group = [];
|
let group = [];
|
||||||
group.thick = slice.thick;
|
group.thick = slice.thick;
|
||||||
laserOut([ top ], group, "in");
|
polyOut([ top ], group, "in");
|
||||||
laserOut(top.inner || [], group, "out");
|
polyOut(top.inner || [], group, "out");
|
||||||
groups.push(group);
|
groups.push(group);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -274,9 +274,12 @@ async function prepare(widgets, settings, update) {
|
||||||
// emit objects from each slice into output array
|
// emit objects from each slice into output array
|
||||||
for (let widget of widgets) {
|
for (let widget of widgets) {
|
||||||
// slice stack merging
|
// slice stack merging
|
||||||
|
// there is not layout in this mode
|
||||||
|
// there are no inner vs outer polys
|
||||||
|
// merged/same polys "increase" color/weight
|
||||||
if (process.ctOutMerged) {
|
if (process.ctOutMerged) {
|
||||||
let merged = [];
|
let merged = [];
|
||||||
widget.slices.forEach(slice => {
|
for (let slice of widget.slices) {
|
||||||
let polys = [];
|
let polys = [];
|
||||||
slice.offset.clone(true).forEach(p => p.flattenTo(polys));
|
slice.offset.clone(true).forEach(p => p.flattenTo(polys));
|
||||||
polys.forEach(p => {
|
polys.forEach(p => {
|
||||||
|
|
@ -295,10 +298,10 @@ async function prepare(widgets, settings, update) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
update((slices++ / totalSlices) * 0.5, "prepare");
|
update((slices++ / totalSlices) * 0.5, "prepare");
|
||||||
});
|
}
|
||||||
let start = newPoint(0,0,0);
|
let start = newPoint(0,0,0);
|
||||||
let gather = [];
|
let gather = [];
|
||||||
merged.forEach(poly => {
|
for (let poly of merged) {
|
||||||
if (knifeOn) {
|
if (knifeOn) {
|
||||||
addKnifeRadii(poly);
|
addKnifeRadii(poly);
|
||||||
}
|
}
|
||||||
|
|
@ -306,19 +309,20 @@ async function prepare(widgets, settings, update) {
|
||||||
extrude: poly.depth,
|
extrude: poly.depth,
|
||||||
rate: poly.depth * 10
|
rate: poly.depth * 10
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
output.push(gather);
|
output.push(gather);
|
||||||
} else {
|
} else {
|
||||||
if (knifeOn) {
|
if (knifeOn) {
|
||||||
widget.slices.forEach(slice => {
|
for (let slice of widget.slices) {
|
||||||
slice.offset.forEach(poly => {
|
slice.offset.forEach(poly => {
|
||||||
addKnifeRadii(poly);
|
addKnifeRadii(poly);
|
||||||
if (poly.inner) poly.inner.forEach(ip => {
|
if (poly.inner) poly.inner.forEach(ip => {
|
||||||
addKnifeRadii(ip);
|
addKnifeRadii(ip);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
// TODO packing / layout SHOULD be done here instead
|
||||||
let lastEmit;
|
let lastEmit;
|
||||||
for (let slice of widget.slices.reverse()) {
|
for (let slice of widget.slices.reverse()) {
|
||||||
lastEmit = sliceEmitObjects(print, slice, output, {simple: knifeOn, lastEmit});
|
lastEmit = sliceEmitObjects(print, slice, output, {simple: knifeOn, lastEmit});
|
||||||
|
|
@ -379,6 +383,8 @@ async function prepare(widgets, settings, update) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log({ output });
|
||||||
|
|
||||||
return kiri.render.path(output, (progress, layer) => {
|
return kiri.render.path(output, (progress, layer) => {
|
||||||
update(0.5 + progress * 0.5, "render", layer);
|
update(0.5 + progress * 0.5, "render", layer);
|
||||||
}, { thin: true, z: 0, action: "cut", moves: process.knifeOn });
|
}, { thin: true, z: 0, action: "cut", moves: process.knifeOn });
|
||||||
|
|
@ -419,7 +425,6 @@ function exportElements(settings, output, onpre, onpoly, onpost, onpoint, onlaye
|
||||||
});
|
});
|
||||||
size.w = max.x - min.x;
|
size.w = max.x - min.x;
|
||||||
size.h = max.y - min.y;
|
size.h = max.y - min.y;
|
||||||
console.log('export bounds', min, max, size);
|
|
||||||
|
|
||||||
let bounds = base.newBounds();
|
let bounds = base.newBounds();
|
||||||
if (ctOriginCenter) {
|
if (ctOriginCenter) {
|
||||||
|
|
|
||||||
|
|
@ -903,6 +903,7 @@ gapp.register("kiri.main", [], (root, exports) => {
|
||||||
current.mode = mode;
|
current.mode = mode;
|
||||||
MODE = MODES[mode];
|
MODE = MODES[mode];
|
||||||
DRIVER = kiri.driver[mode];
|
DRIVER = kiri.driver[mode];
|
||||||
|
kiri.driver.current = DRIVER;
|
||||||
// gcode edit area for any non-SLA mode
|
// gcode edit area for any non-SLA mode
|
||||||
api.uc.setVisible($('gcode-edit'), mode !== 'SLA');
|
api.uc.setVisible($('gcode-edit'), mode !== 'SLA');
|
||||||
// highlight selected mode menu item
|
// highlight selected mode menu item
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ const { COLOR, MODES } = consts;
|
||||||
|
|
||||||
const V0 = new THREE.Vector3(0,0,0);
|
const V0 = new THREE.Vector3(0,0,0);
|
||||||
|
|
||||||
|
let setbounds = undefined;
|
||||||
let grouping = false;
|
let grouping = false;
|
||||||
let topZ = 0;
|
let topZ = 0;
|
||||||
|
|
||||||
|
|
@ -218,8 +219,14 @@ function platformUpdateStock() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function platformSetBounds(bounds) {
|
||||||
|
setbounds = bounds;
|
||||||
|
return platformUpdateBounds();
|
||||||
|
}
|
||||||
|
|
||||||
function platformUpdateBounds() {
|
function platformUpdateBounds() {
|
||||||
const bounds = new THREE.Box3();
|
const bounds = setbounds || new THREE.Box3();
|
||||||
|
if (!setbounds)
|
||||||
api.widgets.each(widget => {
|
api.widgets.each(widget => {
|
||||||
let wp = widget.track.pos;
|
let wp = widget.track.pos;
|
||||||
let wb = widget.getBoundingBox().clone();
|
let wb = widget.getBoundingBox().clone();
|
||||||
|
|
@ -911,6 +918,7 @@ const platform = api.platform = {
|
||||||
select: platformSelect,
|
select: platformSelect,
|
||||||
select_all: platformSelectAll,
|
select_all: platformSelectAll,
|
||||||
selected_count: platformSelectedCount,
|
selected_count: platformSelectedCount,
|
||||||
|
set_bounds: platformSetBounds,
|
||||||
update_origin: platformUpdateOrigin,
|
update_origin: platformUpdateOrigin,
|
||||||
update_bounds: platformUpdateBounds,
|
update_bounds: platformUpdateBounds,
|
||||||
update_size: platformUpdateSize,
|
update_size: platformUpdateSize,
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ th, tr, td, label {
|
||||||
.dark #mod-print,
|
.dark #mod-print,
|
||||||
.dark #mod-print .header label
|
.dark #mod-print .header label
|
||||||
{
|
{
|
||||||
background-color: #222;
|
background-color: #282828;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
.dark #render-tools .pop,
|
.dark #render-tools .pop,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue