From 0b87e3bdbd2a934355338abf65a6e6aa0f16d89e Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Thu, 23 Apr 2020 18:01:12 -0400 Subject: [PATCH] start sla supports --- js/kiri-conf.js | 2 +- js/kiri-driver-sla.js | 34 +++++++++++++++++++++++++++++++++- js/kiri-init.js | 3 +++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/js/kiri-conf.js b/js/kiri-conf.js index 68a167d1..cce57853 100644 --- a/js/kiri-conf.js +++ b/js/kiri-conf.js @@ -319,7 +319,7 @@ let gs_kiri_conf = exports; slaFillDensity: 0, slaFillLine: 0.5, slaFirstOffset: 0, - slaSupportEnable: false, + slaSupportLayers: 0, } }, cam:{ diff --git a/js/kiri-driver-sla.js b/js/kiri-driver-sla.js index a54bcef2..c86ce3ed 100644 --- a/js/kiri-driver-sla.js +++ b/js/kiri-driver-sla.js @@ -24,6 +24,8 @@ let gs_kiri_sla = exports; printRender }, SLICER = KIRI.slicer, + newTop = KIRI.newTop, + newSlice = KIRI.newSlice, newPoint = BASE.newPoint, preview, previewSmall, @@ -66,9 +68,10 @@ let gs_kiri_sla = exports; previewSmall = samplePNG(img, 200, 125); previewLarge = samplePNG(img, 400, 300); }); + let height = process.slaSlice || 0.05; SLICER.sliceWidget(widget, { - height: process.slaSlice || 0.05, + height: height, add: !process.slaOpenTop }, function(slices) { widget.slices = slices.filter(slice => slice.tops.length); @@ -77,6 +80,35 @@ let gs_kiri_sla = exports; // that will generate a diff producing a solid projection slices = widget.slices; } + // insert support layers + if (process.slaSupportLayers) { + let zoff = height / 2; + let snew = []; + let polys = []; + let outer = slices.forEach(slice => { + polys.appendAll(slice.tops.map(t => t.poly)); + }); + let union = POLY.expand(POLY.union(polys), 2, zoff, [], 1); + for (let s=0; s { + slice.tops.push(newTop(u.clone(true).setZ(zoff))); + }); + snew.push(slice); + zoff += height; + union = POLY.expand(union, 0.1, zoff, [], 1); + } + widget.slices = slices = snew.concat(slices.map(s => { + s.tops.forEach(t => { + t.poly.setZ(s.z + zoff); + }); + s.index += snew.length; + s.z += zoff; + return s; + })); + } // reset for solids and support projections slices.forEach(function(slice) { slice.invalidateFill(); diff --git a/js/kiri-init.js b/js/kiri-init.js index ba82d3c9..7e6f10c8 100644 --- a/js/kiri-init.js +++ b/js/kiri-init.js @@ -1476,6 +1476,9 @@ var gs_kiri_init = exports; slaFillDensity: UC.newInput('density', {title:'percent infill\n0.0-1.0', convert:UC.toFloat, bound:UC.bound(0,1), modes:SLA}), slaFillLine: UC.newInput('line width', {title:'hatch line width\nin millimeters', convert:UC.toFloat, bound:UC.bound(0,5), modes:SLA}), + slaSupport: LOCAL ? UC.newGroup('support', null, {modes:SLA, group:"sla-support"}) : null, + slaSupportLayers: LOCAL ? UC.newInput('layers', {title:'base support layers\n0-10', convert:UC.toInt, bound:UC.bound(0,10), modes:SLA}) : null, + slaOutput: UC.newGroup('output', null, {modes:SLA, group:"sla-first"}), slaFirstOffset: UC.newInput('z offset', {title:'z layer offset\nalmost always 0.0\n0.0-1.0 in millimeters', convert:UC.toFloat, bound:UC.bound(0,1), modes:SLA, expert:true}), slaAntiAlias: UC.newSelect('anti alias', {title: 'enable anti-aliasing\nproduces larger files', modes:SLA}, "antialias"),