add first approximation of thin fill
This commit is contained in:
parent
b6962b084b
commit
456f3f1e30
5 changed files with 69 additions and 16 deletions
|
|
@ -493,7 +493,7 @@ var gs_base_polygons = exports;
|
||||||
polys = fromClipperTree(ctre, z);
|
polys = fromClipperTree(ctre, z);
|
||||||
|
|
||||||
// detect possible thin walls
|
// detect possible thin walls
|
||||||
if (polys.length && thins) {
|
if (thins) {
|
||||||
var circ1 = sumCirc(orig),
|
var circ1 = sumCirc(orig),
|
||||||
circ2 = sumCirc(polys),
|
circ2 = sumCirc(polys),
|
||||||
diff = Math.abs(1 - (circ1 / circ2));
|
diff = Math.abs(1 - (circ1 / circ2));
|
||||||
|
|
@ -578,6 +578,8 @@ var gs_base_polygons = exports;
|
||||||
* @returns {Point[]} supplied output or new array
|
* @returns {Point[]} supplied output or new array
|
||||||
*/
|
*/
|
||||||
function fillArea(polys, angle, spacing, output, minLen, maxLen) {
|
function fillArea(polys, angle, spacing, output, minLen, maxLen) {
|
||||||
|
if (polys.length === 0) return;
|
||||||
|
|
||||||
var i = 1,
|
var i = 1,
|
||||||
p0 = polys[0],
|
p0 = polys[0],
|
||||||
zpos = p0.getZ(),
|
zpos = p0.getZ(),
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,7 @@ var gs_kiri_fdm = exports;
|
||||||
}, "solids");
|
}, "solids");
|
||||||
forSlices(0.35, 0.5, function(slice) {
|
forSlices(0.35, 0.5, function(slice) {
|
||||||
slice.doSolidsFill(fillSpacing, sliceFillAngle, minSolid);
|
slice.doSolidsFill(fillSpacing, sliceFillAngle, minSolid);
|
||||||
|
slice.doThinFill(fillSpacing, sliceFillAngle);
|
||||||
sliceFillAngle += 90.0;
|
sliceFillAngle += 90.0;
|
||||||
}, "solids");
|
}, "solids");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -347,6 +347,32 @@ var gs_kiri_slice = exports;
|
||||||
layer.render();
|
layer.render();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* given two arrays of points (lines), eliminate intersections of the second
|
||||||
|
* to the first, then return a unified array.
|
||||||
|
*
|
||||||
|
* @param {Point[]} r1
|
||||||
|
* @param {Point[]} r2
|
||||||
|
* @returns {Point[]}
|
||||||
|
*/
|
||||||
|
function cullIntersections(r1, r2) {
|
||||||
|
if (!(r1 && r2 && r1.length && r2.length)) return;
|
||||||
|
if (r2.length > r1.length) {
|
||||||
|
var r3 = r1;
|
||||||
|
r1 = r2;
|
||||||
|
r2 = r3;
|
||||||
|
}
|
||||||
|
var valid = r1.slice();
|
||||||
|
outer: for (var i=0; i<r2.length; i += 2) {
|
||||||
|
for (var j=0; j<r1.length; j += 2) {
|
||||||
|
if (UTIL.intersect(r1[j], r1[j+1], r2[i], r2[i+1])) continue outer;
|
||||||
|
}
|
||||||
|
valid.push(r2[i]);
|
||||||
|
valid.push(r2[i+1]);
|
||||||
|
}
|
||||||
|
return valid;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compute offset shell polygons. For FDM, the first offset is usually half
|
* Compute offset shell polygons. For FDM, the first offset is usually half
|
||||||
* of the nozzle width. Each subsequent offset is a full nozzle width. User
|
* of the nozzle width. Each subsequent offset is a full nozzle width. User
|
||||||
|
|
@ -368,7 +394,8 @@ var gs_kiri_slice = exports;
|
||||||
if (opt.vase) top.poly = top.poly.clone(false);
|
if (opt.vase) top.poly = top.poly.clone(false);
|
||||||
top.traces = [];
|
top.traces = [];
|
||||||
top.inner = [];
|
top.inner = [];
|
||||||
var last = [];
|
var last = [],
|
||||||
|
z = top.poly.getZ();
|
||||||
|
|
||||||
if (opt.thin) {
|
if (opt.thin) {
|
||||||
top.thin_fill = [];
|
top.thin_fill = [];
|
||||||
|
|
@ -402,18 +429,19 @@ var gs_kiri_slice = exports;
|
||||||
},
|
},
|
||||||
// thin wall probe
|
// thin wall probe
|
||||||
function(p1, p2) {
|
function(p1, p2) {
|
||||||
// var pall = [].appendAll(p1).appendAll(p2),
|
var pall = POLY.nest([].appendAll(p1).appendAll(p2), true),
|
||||||
// r1 = fillArea(pall, 45, offsetN, [], offsetN, offsetN * 2),
|
pnew = POLY.expand(pall, -offset1, z, null, 1),
|
||||||
// r2 = fillArea(pall, 135, offsetN, [], offsetN, offsetN * 2),
|
r1 = fillArea(pnew, 45, offsetN, [], 0, offsetN * 2),
|
||||||
// rall = top.thin_fill.appendAll(r1).appendAll(r2);
|
r2 = fillArea(pnew, 135, offsetN, [], 0, offsetN * 2),
|
||||||
// console.log([slice.index, p1, p2, r1, r2]);
|
rall = top.thin_fill.appendAll(cullIntersections(r1, r2));
|
||||||
|
// if (rall.length) console.log([slice.index, pnew.length, rall.length]);
|
||||||
},
|
},
|
||||||
top.poly.getZ());
|
z);
|
||||||
} else {
|
} else {
|
||||||
POLY.expand(
|
POLY.expand(
|
||||||
[top.poly],
|
[top.poly],
|
||||||
-offset1,
|
-offset1,
|
||||||
top.poly.getZ(),
|
z,
|
||||||
top.traces,
|
top.traces,
|
||||||
count,
|
count,
|
||||||
-offsetN,
|
-offsetN,
|
||||||
|
|
@ -610,9 +638,9 @@ var gs_kiri_slice = exports;
|
||||||
poly = POLY.fromClipperNode(node, scope.z);
|
poly = POLY.fromClipperNode(node, scope.z);
|
||||||
tops.forEach(function(top) {
|
tops.forEach(function(top) {
|
||||||
// filter out polygons under min length (0.5mm)
|
// filter out polygons under min length (0.5mm)
|
||||||
if (poly.isInside(top.poly) && poly.perimeter() > 0.5) {
|
// if (poly.isInside(top.poly) && poly.perimeter() > 0.5) {
|
||||||
top.fill_sparse.push(poly);
|
top.fill_sparse.push(poly);
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -802,6 +830,24 @@ var gs_kiri_slice = exports;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fill thin areas, if present
|
||||||
|
* @return {boolean} true if filled, false if not
|
||||||
|
*/
|
||||||
|
PRO.doThinFill = function(spacing, angle) {
|
||||||
|
this.tops.forEach(function(top) {
|
||||||
|
if (top.thin_fill.length > 0) {
|
||||||
|
if (top.fill_lines) {
|
||||||
|
top.fill_lines.appendAll(top.thin_fill)
|
||||||
|
} else {
|
||||||
|
top.fill_lines = top.thin_fill;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
PRO.renderSolidOutlines = function() {
|
PRO.renderSolidOutlines = function() {
|
||||||
var layer = this.layers.solid,
|
var layer = this.layers.solid,
|
||||||
trimmed = this.solids.trimmed;
|
trimmed = this.solids.trimmed;
|
||||||
|
|
|
||||||
12
js/kiri.js
12
js/kiri.js
|
|
@ -2593,7 +2593,10 @@ self.kiri.license = exports.LICENSE;
|
||||||
showSerial(true);
|
showSerial(true);
|
||||||
break;
|
break;
|
||||||
case cca('U'): // full settings url
|
case cca('U'): // full settings url
|
||||||
storeSettingsToServer();
|
storeSettingsToServer(true);
|
||||||
|
break;
|
||||||
|
case cca('u'): // full settings url
|
||||||
|
loadSettingsFromServer(prompt("settings id to load"));
|
||||||
break;
|
break;
|
||||||
case cca('s'): // complete slice
|
case cca('s'): // complete slice
|
||||||
prepareSlices();
|
prepareSlices();
|
||||||
|
|
@ -2704,8 +2707,8 @@ self.kiri.license = exports.LICENSE;
|
||||||
moveSelection(x, y, z, true);
|
moveSelection(x, y, z, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadSettingsFromServer() {
|
function loadSettingsFromServer(tok) {
|
||||||
var hash = LOC.hash.substring(1).split("/");
|
var hash = tok || LOC.hash.substring(1).split("/");
|
||||||
if (hash.length === 2) {
|
if (hash.length === 2) {
|
||||||
new moto.Ajax(function(reply) {
|
new moto.Ajax(function(reply) {
|
||||||
if (reply) {
|
if (reply) {
|
||||||
|
|
@ -2722,13 +2725,14 @@ self.kiri.license = exports.LICENSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function storeSettingsToServer() {
|
function storeSettingsToServer(display) {
|
||||||
var set = btoa(JSON.stringify(settings));
|
var set = btoa(JSON.stringify(settings));
|
||||||
new moto.Ajax(function(reply) {
|
new moto.Ajax(function(reply) {
|
||||||
if (reply) {
|
if (reply) {
|
||||||
var res = JSON.parse(reply);
|
var res = JSON.parse(reply);
|
||||||
if (res && res.ver) {
|
if (res && res.ver) {
|
||||||
LOC.hash = res.space + "/" + res.ver;
|
LOC.hash = res.space + "/" + res.ver;
|
||||||
|
if (display) alert("unique settings id is: " + res.space + "/" + res.ver);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
updateSpaceState();
|
updateSpaceState();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
var exports = {
|
var exports = {
|
||||||
COPYRIGHT:"Copyright (C) 2014-2017 Stewart Allen <stewart@neuron.com> - All Rights Reserved",
|
COPYRIGHT:"Copyright (C) 2014-2017 Stewart Allen <stewart@neuron.com> - All Rights Reserved",
|
||||||
LICENSE:"Unauthorized copying, modification and re-distribution are strictly prohibited without prior written consent.",
|
LICENSE:"Unauthorized copying, modification and re-distribution are strictly prohibited without prior written consent.",
|
||||||
VERSION:"1.0.81"
|
VERSION:"1.0.82"
|
||||||
};
|
};
|
||||||
if (!module) var module = {};
|
if (!module) var module = {};
|
||||||
module.exports = exports;
|
module.exports = exports;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue