fix linear infill density. stub in sliceFillWidth

This commit is contained in:
Stewart Allen 2021-03-15 11:00:05 -04:00
commit ebd31d8dc7
7 changed files with 40 additions and 29 deletions

View file

@ -33,6 +33,7 @@
// slice
"sliceShells": LANG.sl_shel_s,
"sliceFillType": LANG.fi_type,
"sliceFillWidth": LANG.fi_wdth_s,
"sliceFillSparse": LANG.fi_pcnt_s,
"sliceSolidMinArea": LANG.ad_msol_s,
// prepare

View file

@ -155,27 +155,28 @@
function fillLinear(target) {
let bounds = target.bounds();
let height = target.zHeight();
let density = target.density();
let line = target.lineWidth();
let span_x = bounds.max.x - bounds.min.x;
let span_y = bounds.max.y - bounds.min.y;
let density = target.density();
let offset = target.offset() / 2;
let line = target.lineWidth();
let mf = Math.max(span_x, span_y) / line;
let tile = 1 + (1 - density);
let tile_xc = Math.ceil(span_x / tile);
let tile_yc = Math.ceil(span_y / tile);
let steps_x = (span_x / line) * density;
let steps_y = (span_y / line) * density;
let step_x = span_x / steps_x;
let step_y = span_x / steps_x;
if (target.zIndex() % 2 === 1) {
for (let tx=0; tx<=tile_xc; tx++) {
for (let tx=bounds.min.x; tx<=bounds.max.x; tx += step_x) {
target.newline();
target.emit(tx * tile + bounds.min.x, bounds.min.y);
target.emit(tx * tile + bounds.min.x, bounds.max.y);
target.emit(tx, bounds.min.y);
target.emit(tx, bounds.max.y);
}
} else {
for (let ty=0; ty<=tile_yc; ty++) {
for (let ty=bounds.min.y; ty<=bounds.max.y; ty += step_y) {
target.newline();
target.emit(bounds.min.x, ty * tile + bounds.min.y);
target.emit(bounds.max.x, ty * tile + bounds.min.y);
target.emit(bounds.min.x, ty);
target.emit(bounds.max.x, ty);
}
}
}

View file

@ -294,6 +294,7 @@
let isTop = slice.index > slices.length - spro.sliceTopLayers-1;
let isDense = params.sliceFillSparse > 0.98;
let solid = (isBottom || ((isTop || isDense) && !vaseMode)) && !isSynth;
let solidWidth = params.sliceFillWidth || 1;
let spaceMult = first ? spro.firstLayerLineMult || 1 : 1;
let offset = shellOffset * spaceMult;
let fillOff = fillOffset * spaceMult;
@ -305,7 +306,7 @@
danger: ctrl.danger
});
if (solid) {
let fillSpace = fillSpacing * spaceMult;
let fillSpace = fillSpacing * spaceMult * solidWidth;
doSolidLayerFill(slice, fillSpace, sliceFillAngle);
}
sliceFillAngle += 90.0;
@ -381,9 +382,11 @@
projectBridges(slice, solidLayers);
}, "solids");
forSlices(0.35, 0.5, slice => {
let params = getRangeParameters(settings, slice.index);
let first = slice.index === 0;
let spaceMult = first ? spro.firstLayerLineMult || 1 : 1;
let fillSpace = fillSpacing * spaceMult;
let solidWidth = params.sliceFillWidth || 1;
let spaceMult = first ? params.firstLayerLineMult || 1 : 1;
let fillSpace = fillSpacing * spaceMult * solidWidth;
doSolidsFill(slice, fillSpace, sliceFillAngle, minSolid);
sliceFillAngle += 90.0;
}, "solids");
@ -439,7 +442,8 @@
// render if not explicitly disabled
if (render) {
forSlices(0.9, 1.0, slice => {
doRender(slice, isSynth);
let params = getRangeParameters(settings, slice.index);
doRender(slice, isSynth, params);
}, "render");
}
@ -462,9 +466,10 @@
return Math.max(min,Math.min(max,v));
}
function doRender(slice, isSynth) {
function doRender(slice, isSynth, params) {
const output = slice.output();
const height = slice.height / 2;
const solidWidth = params.sliceFillWidth || 1;
slice.tops.forEach(top => {
if (isThin) output
@ -489,7 +494,7 @@
if (top.fill_lines && top.fill_lines.length) output
.setLayer("fill", isSynth ? COLOR.support : COLOR.fill)
.addLines(top.fill_lines, vopt({ offset, height }));
.addLines(top.fill_lines, vopt({ offset: offset * solidWidth, height }));
if (top.fill_sparse) output
.setLayer("infill", COLOR.infill)