start sla supports

This commit is contained in:
Stewart Allen 2020-04-23 18:01:12 -04:00
commit 0b87e3bdbd
3 changed files with 37 additions and 2 deletions

View file

@ -319,7 +319,7 @@ let gs_kiri_conf = exports;
slaFillDensity: 0,
slaFillLine: 0.5,
slaFirstOffset: 0,
slaSupportEnable: false,
slaSupportLayers: 0,
}
},
cam:{

View file

@ -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<process.slaSupportLayers; s++) {
let slice = newSlice(zoff);
slice.height = height;
slice.index = snew.length;
union.forEach(u => {
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();

View file

@ -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"),