converging on a better polish. moving to polys vs lines
This commit is contained in:
parent
09990a14ce
commit
c51887d9ba
4 changed files with 43 additions and 30 deletions
|
|
@ -161,9 +161,9 @@ var gs_kiri_fdm = exports;
|
|||
}, "infill");
|
||||
}
|
||||
|
||||
let polish = spro.layerPolishing;
|
||||
// experimental polishing
|
||||
if (spro.layerPolishing) {
|
||||
console.log({polish:spro.layerPolishing})
|
||||
if (polish) {
|
||||
let px, py;
|
||||
widget.polish = {};
|
||||
// compute x polishing slices
|
||||
|
|
@ -197,15 +197,19 @@ console.log({polish:spro.layerPolishing})
|
|||
px.forEach(p => pa.appendAll(p));
|
||||
py.forEach(p => pa.appendAll(p));
|
||||
forSlices(1.0, 1.0, slice => {
|
||||
if (slice.index >= 2) {
|
||||
let zb = slice.down.down.z;
|
||||
if (slice.index >= polish) {
|
||||
let sd = slice;
|
||||
for (let i=0; i<polish; i++) {
|
||||
sd = sd.down;
|
||||
}
|
||||
let zb = sd.z;
|
||||
let zt = slice.z;
|
||||
let lines = [];
|
||||
let lastp;
|
||||
let equal = 0;
|
||||
let points = 0;
|
||||
pa.forEach(p => {
|
||||
p.forEachSegment((p1, p2) => {
|
||||
// if (Math.abs(p1.z - p2.z) < 0.01) {
|
||||
// return;
|
||||
// }
|
||||
// return when both below
|
||||
if (p1.z < zb && p2.z < zb) {
|
||||
return;
|
||||
|
|
@ -242,7 +246,7 @@ console.log({polish:spro.layerPolishing})
|
|||
}
|
||||
let slope = BASE.newSlope(p1, p2);
|
||||
let angle = Math.abs(slope.angle);
|
||||
if (angle < 160 && angle > 20) {
|
||||
if (angle > 20 && angle < 160) {
|
||||
return;
|
||||
}
|
||||
let len = p1.distTo2D(p2);
|
||||
|
|
@ -269,13 +273,19 @@ console.log({polish:spro.layerPolishing})
|
|||
p1 = BASE.newPoint(p1.x,p1.z,p1.y);
|
||||
p2 = BASE.newPoint(p2.x,p2.z,p2.y);
|
||||
}
|
||||
p1.index = p2.index = 1;
|
||||
if (lastp && p1.isEqual(lastp)) {
|
||||
equal++;
|
||||
}
|
||||
lines.push(p1);
|
||||
lines.push(p2);
|
||||
lines.push(lastp = p2);
|
||||
points++;
|
||||
});
|
||||
});
|
||||
if (lines.length && slice.tops.length) {
|
||||
slice.tops[0].polish = lines;
|
||||
}
|
||||
console.log(slice.z,equal,points);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -488,10 +498,14 @@ console.log({polish:spro.layerPolishing})
|
|||
}
|
||||
|
||||
layerout.layer = layer;
|
||||
// layerout.height = layerout.height || (layer === 0 ? firstLayerHeight : process.sliceHeight);
|
||||
|
||||
// if layer produced output, append to output array
|
||||
if (layerout.length) output.append(layerout);
|
||||
|
||||
// notify progress
|
||||
layer++;
|
||||
update(layer / maxLayers);
|
||||
|
||||
// retract after last layer
|
||||
if (layer === maxLayers && layerout.length) {
|
||||
layerout.last().retract = true;
|
||||
|
|
|
|||
|
|
@ -613,12 +613,15 @@ var gs_kiri_print = exports;
|
|||
});
|
||||
}
|
||||
|
||||
function outputFills(lines, bounds, fast) {
|
||||
function outputFills(lines, options) {
|
||||
var p, p1, p2, dist, len, found, group, mindist, t1, t2,
|
||||
marked = 0,
|
||||
start = 0,
|
||||
skip = false,
|
||||
lastIndex = -1;
|
||||
lastIndex = -1,
|
||||
opt = options || {},
|
||||
fast = opt.fast || false,
|
||||
fill = opt.fill >= 0 ? opt.fill : fillMult;
|
||||
|
||||
while (lines && marked < lines.length) {
|
||||
found = false;
|
||||
|
|
@ -683,7 +686,7 @@ var gs_kiri_print = exports;
|
|||
// to avoid shaking the printer to death.
|
||||
if (dist <= thinWall && len <= thinWall) {
|
||||
p2 = p1.midPointTo(p2);
|
||||
addOutput(preout, p2, fillMult * (dist / thinWall), fillSpeed);
|
||||
addOutput(preout, p2, fill * (dist / thinWall), fillSpeed);
|
||||
} else {
|
||||
// retract if dist trigger or crosses a slice top polygon
|
||||
if (dist > retractDist && (zhop || intersectsTop(startPoint, p1))) {
|
||||
|
|
@ -697,12 +700,12 @@ var gs_kiri_print = exports;
|
|||
|
||||
// bridge ends of fill when they're close together
|
||||
if (dist < thinWall) {
|
||||
addOutput(preout, p1, fillMult, fillSpeed);
|
||||
addOutput(preout, p1, fill, fillSpeed);
|
||||
} else {
|
||||
addOutput(preout, p1, 0, moveSpeed);
|
||||
}
|
||||
|
||||
addOutput(preout, p2, fillMult, fillSpeed);
|
||||
addOutput(preout, p2, fill, fillSpeed);
|
||||
}
|
||||
|
||||
startPoint = p2;
|
||||
|
|
@ -762,7 +765,7 @@ var gs_kiri_print = exports;
|
|||
outputTraces([next].appendAll(next.inner || []));
|
||||
if (next.fills) {
|
||||
next.fills.forEach(function(p) { p.z = z });
|
||||
outputFills(next.fills, next.inner, true);
|
||||
outputFills(next.fills, {fast: true});
|
||||
}
|
||||
} else {
|
||||
// top object
|
||||
|
|
@ -786,8 +789,8 @@ var gs_kiri_print = exports;
|
|||
outputTraces([].appendAll(next.innerTraces() || []), bounds);
|
||||
|
||||
// then output solid and sparse fill
|
||||
outputFills(next.fill_lines, bounds);
|
||||
outputSparse(next.fill_sparse, bounds);
|
||||
outputFills(next.fill_lines);
|
||||
outputSparse(next.fill_sparse);
|
||||
|
||||
lastTop = next;
|
||||
}
|
||||
|
|
@ -795,6 +798,12 @@ var gs_kiri_print = exports;
|
|||
return obj instanceof Polygon ? obj : obj.poly;
|
||||
});
|
||||
|
||||
// produce polishing paths when present
|
||||
if (slice.tops.length) {
|
||||
let polish = slice.tops[0].polish;
|
||||
outputFills(polish, {fast: true, fill:0});
|
||||
}
|
||||
|
||||
// offset print points
|
||||
for (i=0; i<preout.length; i++) {
|
||||
preout[i].point = preout[i].point.add(offset);
|
||||
|
|
|
|||
|
|
@ -636,17 +636,6 @@ var gs_kiri_widget = exports;
|
|||
if (!cam) slices.forEach(function(s) { s.renderSparseFill() });
|
||||
// render supports
|
||||
if (!cam) slices.forEach(function(s) { s.renderSupport() });
|
||||
// render polish (sent in debug mode only)
|
||||
if (this.polish && false) {
|
||||
let layer = KIRI.newLayer(this.mesh.newGroup());
|
||||
this.polish.x.forEach(poly => {
|
||||
layer.poly(poly, 0xff0000, false, false);
|
||||
});
|
||||
this.polish.y.forEach(poly => {
|
||||
layer.poly(poly, 0x0000ff, false, false);
|
||||
});
|
||||
layer.render();
|
||||
}
|
||||
};
|
||||
|
||||
PRO.hideSlices = function() {
|
||||
|
|
|
|||
|
|
@ -493,7 +493,8 @@ self.kiri.license = exports.LICENSE;
|
|||
DOC = SELF.document,
|
||||
LOC = SELF.location,
|
||||
SETUP = parseOpt(LOC.search.substring(1)),
|
||||
LOCAL = LOC.host.indexOf('localhost') === 0,
|
||||
HOST = LOC.host.split(':'),
|
||||
LOCAL = HOST[0] === 'localhost' || HOST[0] === 'debug',
|
||||
SECURE = isSecure(LOC.protocol),
|
||||
// ---------------
|
||||
SDB = MOTO.KV,
|
||||
|
|
|
|||
Loading…
Reference in a new issue