From 456f3f1e30e24130e38f11e1e64decff6f49738d Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Thu, 11 Jan 2018 08:01:42 -0500 Subject: [PATCH] add first approximation of thin fill --- js/geo-polygons.js | 4 ++- js/kiri-driver-fdm.js | 1 + js/kiri-slice.js | 66 ++++++++++++++++++++++++++++++++++++------- js/kiri.js | 12 +++++--- js/license.js | 2 +- 5 files changed, 69 insertions(+), 16 deletions(-) diff --git a/js/geo-polygons.js b/js/geo-polygons.js index 31362255..664b3aba 100644 --- a/js/geo-polygons.js +++ b/js/geo-polygons.js @@ -493,7 +493,7 @@ var gs_base_polygons = exports; polys = fromClipperTree(ctre, z); // detect possible thin walls - if (polys.length && thins) { + if (thins) { var circ1 = sumCirc(orig), circ2 = sumCirc(polys), diff = Math.abs(1 - (circ1 / circ2)); @@ -578,6 +578,8 @@ var gs_base_polygons = exports; * @returns {Point[]} supplied output or new array */ function fillArea(polys, angle, spacing, output, minLen, maxLen) { + if (polys.length === 0) return; + var i = 1, p0 = polys[0], zpos = p0.getZ(), diff --git a/js/kiri-driver-fdm.js b/js/kiri-driver-fdm.js index 80c23067..eed24547 100644 --- a/js/kiri-driver-fdm.js +++ b/js/kiri-driver-fdm.js @@ -131,6 +131,7 @@ var gs_kiri_fdm = exports; }, "solids"); forSlices(0.35, 0.5, function(slice) { slice.doSolidsFill(fillSpacing, sliceFillAngle, minSolid); + slice.doThinFill(fillSpacing, sliceFillAngle); sliceFillAngle += 90.0; }, "solids"); } diff --git a/js/kiri-slice.js b/js/kiri-slice.js index 50ff732b..1a706775 100644 --- a/js/kiri-slice.js +++ b/js/kiri-slice.js @@ -347,6 +347,32 @@ var gs_kiri_slice = exports; 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 0.5) { + // if (poly.isInside(top.poly) && poly.perimeter() > 0.5) { top.fill_sparse.push(poly); - } + // } }); }); } @@ -802,6 +830,24 @@ var gs_kiri_slice = exports; 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() { var layer = this.layers.solid, trimmed = this.solids.trimmed; diff --git a/js/kiri.js b/js/kiri.js index 2ac3ee3a..b7143a70 100644 --- a/js/kiri.js +++ b/js/kiri.js @@ -2593,7 +2593,10 @@ self.kiri.license = exports.LICENSE; showSerial(true); break; case cca('U'): // full settings url - storeSettingsToServer(); + storeSettingsToServer(true); + break; + case cca('u'): // full settings url + loadSettingsFromServer(prompt("settings id to load")); break; case cca('s'): // complete slice prepareSlices(); @@ -2704,8 +2707,8 @@ self.kiri.license = exports.LICENSE; moveSelection(x, y, z, true); } - function loadSettingsFromServer() { - var hash = LOC.hash.substring(1).split("/"); + function loadSettingsFromServer(tok) { + var hash = tok || LOC.hash.substring(1).split("/"); if (hash.length === 2) { new moto.Ajax(function(reply) { if (reply) { @@ -2722,13 +2725,14 @@ self.kiri.license = exports.LICENSE; } } - function storeSettingsToServer() { + function storeSettingsToServer(display) { var set = btoa(JSON.stringify(settings)); new moto.Ajax(function(reply) { if (reply) { var res = JSON.parse(reply); if (res && res.ver) { LOC.hash = res.space + "/" + res.ver; + if (display) alert("unique settings id is: " + res.space + "/" + res.ver); } } else { updateSpaceState(); diff --git a/js/license.js b/js/license.js index 53f606cb..5ebda2c4 100644 --- a/js/license.js +++ b/js/license.js @@ -1,7 +1,7 @@ var exports = { COPYRIGHT:"Copyright (C) 2014-2017 Stewart Allen - All Rights Reserved", 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 = {}; module.exports = exports;