synthesize a support widget to encapsulate nozzle and other settings
This commit is contained in:
parent
58a70b0396
commit
a661ef618a
6 changed files with 64 additions and 13 deletions
|
|
@ -393,7 +393,7 @@ let gs_kiri_fdm = exports;
|
|||
* @param {Function} update incremental callback
|
||||
*/
|
||||
function printSetup(print, update) {
|
||||
let widgets = print.widgets,
|
||||
let widgets = print.widgets.slice(),
|
||||
settings = fixExtruders(print.settings),
|
||||
device = settings.device,
|
||||
nozzle = device.extruders[0].extNozzle,
|
||||
|
|
@ -542,6 +542,32 @@ let gs_kiri_fdm = exports;
|
|||
bounds.max.y = Math.max(bounds.max.y, bbounds.maxy);
|
||||
}
|
||||
|
||||
// synthesize a support widget, if needed
|
||||
if (process.sliceSupportEnable) {
|
||||
let swidget = KIRI.newWidget();
|
||||
let sslices = swidget.slices = [];
|
||||
widgets.forEach(function(widget) {
|
||||
let slices = widget.slices;
|
||||
while (sslices.length < slices.length) {
|
||||
let sslice = KIRI.newSlice(slices[sslices.length].z);
|
||||
sslice.extruder = process.sliceSupportNozzle;
|
||||
sslices.push(sslice);
|
||||
}
|
||||
slices.forEach((slice,index) => {
|
||||
if (!slice.supports) return;
|
||||
if (sslices[index].supports) {
|
||||
sslices[index].supports.appendAll(slice.supports);
|
||||
} else {
|
||||
sslices[index].supports = slice.supports;
|
||||
}
|
||||
});
|
||||
});
|
||||
swidget.support = true;
|
||||
swidget.mesh = { widget: swidget }; // fake for lookup
|
||||
settings.widget[swidget.id] = { extruder: process.sliceSupportNozzle };
|
||||
widgets.push(swidget);
|
||||
}
|
||||
|
||||
let extruders = [];
|
||||
let extcount = 0;
|
||||
|
||||
|
|
@ -615,7 +641,11 @@ let gs_kiri_fdm = exports;
|
|||
}
|
||||
let mslices = mesh.widget.slices;
|
||||
if (mslices && mslices[layer]) {
|
||||
slices.push({slice:mslices[layer], offset:mesh.position});
|
||||
slices.push({
|
||||
slice: mslices[layer],
|
||||
offset: mesh.position || {x:0, y:0, z:0},
|
||||
widget: mesh.widget
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -656,6 +686,7 @@ let gs_kiri_fdm = exports;
|
|||
closest = find.sliceEntry;
|
||||
minidx = find.meshIndex;
|
||||
}
|
||||
|
||||
if (!closest) {
|
||||
if (sliceEntry) lastOut = sliceEntry.slice;
|
||||
break;
|
||||
|
|
@ -677,7 +708,10 @@ let gs_kiri_fdm = exports;
|
|||
printPoint.sub(closest.offset),
|
||||
closest.offset,
|
||||
layerout,
|
||||
{ first: closest.slice.index === 0 }
|
||||
{
|
||||
first: closest.slice.index === 0,
|
||||
support: closest.widget.support
|
||||
}
|
||||
);
|
||||
lastOut = closest.slice;
|
||||
lastExt = lastOut.ext
|
||||
|
|
|
|||
|
|
@ -648,6 +648,7 @@ let gs_kiri_print = exports;
|
|||
origin = startPoint.add(offset),
|
||||
zhop = process.zHopDistance || 0,
|
||||
antiBacklash = process.antiBacklash,
|
||||
doSupport = opt.support,
|
||||
z = slice.z;
|
||||
|
||||
// apply first layer extrusion multipliers
|
||||
|
|
@ -867,9 +868,16 @@ let gs_kiri_print = exports;
|
|||
}
|
||||
}
|
||||
|
||||
let all = [].appendAll(slice.supports || []).appendAll(slice.tops || []);
|
||||
let out = [];
|
||||
if (slice.tops) {
|
||||
out.appendAll(slice.tops);
|
||||
};
|
||||
if (opt.support && slice.supports) {
|
||||
out.appendAll(slice.supports);
|
||||
}
|
||||
|
||||
let lastTop = null;
|
||||
outputOrderClosest(all || [], function(next) {
|
||||
outputOrderClosest(out, function(next) {
|
||||
if (next instanceof Polygon) {
|
||||
// support polygon
|
||||
next.setZ(z);
|
||||
|
|
|
|||
|
|
@ -1226,12 +1226,21 @@ let gs_kiri_slice = exports;
|
|||
PRO.findClosestPointTo = function(target) {
|
||||
let min, find;
|
||||
|
||||
this.tops.forEach(function(top) {
|
||||
find = top.poly.findClosestPointTo(target);
|
||||
if (!min || find.distance < min.distance) {
|
||||
min = find;
|
||||
}
|
||||
});
|
||||
if (this.tops.length) {
|
||||
this.tops.forEach(function(top) {
|
||||
find = top.poly.findClosestPointTo(target);
|
||||
if (!min || find.distance < min.distance) {
|
||||
min = find;
|
||||
}
|
||||
});
|
||||
} else if (this.supports) {
|
||||
this.supports.forEach(function(poly) {
|
||||
find = poly.findClosestPointTo(target);
|
||||
if (!min || find.distance < min.distance) {
|
||||
min = find;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return min;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -153,6 +153,7 @@ let gs_kiri_widget = exports;
|
|||
progress: 0
|
||||
};
|
||||
this.saved = false;
|
||||
this.support = false; // is synthesized support widget
|
||||
}
|
||||
|
||||
/** ******************************************************************
|
||||
|
|
|
|||
|
|
@ -1153,7 +1153,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
space = space || proc.outputTileSpacing || 1;
|
||||
break;
|
||||
case MODES.FDM:
|
||||
space = space || (proc.sliceSupportExtra || 0) + 1;
|
||||
space = space || ((proc.sliceSupportExtra || 0) * 2) + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue