add linear infill

This commit is contained in:
Stewart Allen 2020-04-15 22:19:18 -04:00
commit 453348af4b
3 changed files with 32 additions and 3 deletions

View file

@ -18,7 +18,8 @@ var gs_kiri_fill = exports;
hex: fillHexFull,
grid: fillGrid,
gyroid: fillGyroid,
triangle: fillTriangle
triangle: fillTriangle,
linear: fillLinear
};
function fillHexFull(target) {
@ -148,6 +149,32 @@ var gs_kiri_fill = exports;
}
}
function fillLinear(target) {
let bounds = target.bounds();
let height = target.zHeight();
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 tile = 1 + (1 - density);
let tile_xc = span_x / tile;
let tile_yc = span_y / tile;
if (target.zIndex() % 2 === 1) {
for (let tx=0; tx<=tile_xc; tx++) {
target.newline();
target.emit(bounds.min.y, tx * tile + bounds.min.x);
target.emit(bounds.max.y, tx * tile + bounds.min.x);
}
} else {
for (let ty=0; ty<=tile_yc; ty++) {
target.newline();
target.emit(ty * tile + bounds.min.y, bounds.min.x);
target.emit(ty * tile + bounds.min.y, bounds.max.x);
}
}
}
function fillTriangle(target) {
let bounds = target.bounds();
let height = target.zHeight();

View file

@ -709,9 +709,10 @@ let gs_kiri_slice = exports;
scope._fill_finger = POLY.fingerprint(polys);
let skippable = type !== 'gyroid' && type !== 'linear';
let miss = false;
// if the layer below has the same fingerprint, we may be able to clone its infill
if (scope.fingerprintSame(down)) {
if (skippable && scope.fingerprintSame(down)) {
// the fill fingerprint can slightly different because of solid projections
if (down._fill_finger && POLY.fingerprintCompare(scope._fill_finger, down._fill_finger)) {
for (let i=0; i<tops.length; i++) {

View file

@ -128,7 +128,8 @@ self.kiri.copyright = exports.COPYRIGHT;
{ name: "hex" },
{ name: "grid" },
{ name: "gyroid" },
{ name: "triangle" }
{ name: "triangle" },
{ name: "linear" }
],
units:[
{ name: "mm" },