order planar slices by extruder first for proper purge blocks

This commit is contained in:
Stewart Allen 2020-04-12 21:28:49 -04:00
commit 14526eb384
3 changed files with 25 additions and 16 deletions

View file

@ -390,16 +390,15 @@ let gs_kiri_fdm = exports;
zoff = 0,
meshIndex,
lastIndex,
// lastOut,
closest,
mindist,
minidx,
find,
found,
layerout = [],
slices = [],
sliceEntry;
// TODO pick a widget with a slice on the first layer and use that nozzle
// create brim, skirt, raft if specificed in FDM mode (code shared by laser)
if (process.outputBrimCount || process.outputRaft) {
let brims = [],
@ -588,7 +587,7 @@ let gs_kiri_fdm = exports;
}
}
// for each layer until no layers are found
// increment layer count until no widget has remaining slices
for (;;) {
// create list of mesh slice arrays with their platform offsets
for (meshIndex = 0; meshIndex < widgets.length; meshIndex++) {
@ -614,22 +613,30 @@ let gs_kiri_fdm = exports;
// iterate over layer slices, find closest widget, print, eliminate
for (;;) {
found = 0;
closest = null;
mindist = Infinity;
// TODO must select slices of the same extruder type first
// instead of just finding closest, create sorted list and
// next is draw from list
let order = [];
// select slices of the same extruder type first then distance
for (meshIndex = 0; meshIndex < slices.length; meshIndex++) {
sliceEntry = slices[meshIndex];
if (!sliceEntry) continue;
find = sliceEntry.slice.findClosestPointTo(printPoint.sub(sliceEntry.offset));
if (find && (!closest || find.distance < mindist)) {
closest = sliceEntry;
mindist = find.distance;
minidx = meshIndex;
if (sliceEntry) {
find = sliceEntry.slice.findClosestPointTo(printPoint.sub(sliceEntry.offset));
if (find) {
let ext = sliceEntry.slice.extruder;
let lex = lastOut ? lastOut.extruder : ext;
let dst = Math.abs(find.distance);
if (ext !== lex) dst *= 10000;
order.push({dst,sliceEntry,meshIndex});
}
}
found++;
}
order.sort((a,b) => {
return a.dst - b.dst;
});
if (order.length) {
let find = order.shift();
closest = find.sliceEntry;
minidx = find.meshIndex;
}
if (!closest) {
if (sliceEntry) lastOut = sliceEntry.slice;

View file

@ -1060,7 +1060,7 @@ var gs_kiri_init = exports;
});
SPACE.platform.onMove(API.conf.save);
SPACE.platform.setRound(true);
SPACE.useDefaultKeys(API.feature.on_key === undefined);
SPACE.useDefaultKeys(API.feature.on_key === undefined || API.feature.on_key_defaults);
UC.setCompact(compact);
@ -1640,7 +1640,7 @@ var gs_kiri_init = exports;
// SPACE.mouse.onHover(function(d,me) {
// if (d) {
// console.log(d,d.object.widget.id,d.face.materialIndex)
// // console.log(d,d.object.widget.id,d.face.materialIndex)
// // d.object.material.vertexColors = true;
// // d.object.material.needsUpdate = true;
// // d.face.vertexColors = [

View file

@ -1583,6 +1583,7 @@ self.kiri.copyright = exports.COPYRIGHT;
["print","help","local"].forEach(function(modal) {
UI[modal].style.display = (modal === which ? 'block' : 'none');
});
if (which) API.event.emit('modal.show', which);
}
function hideDialog() {
@ -1598,6 +1599,7 @@ self.kiri.copyright = exports.COPYRIGHT;
let style = UI[dialog].style;
style.display = (dialog === which && (force || style.display !== 'flex') ? 'flex' : 'none');
});
if (which) API.event.emit('dialog.show', which);
}
function showCatalog() {