diff --git a/src/settings/default.yml b/src/settings/default.yml index 77db94c..0fd05a0 100644 --- a/src/settings/default.yml +++ b/src/settings/default.yml @@ -35,7 +35,6 @@ innerLine: fill: flowRate: 1.0 speed: 50.0 - overlap: 0.0 gridSize: 5.0 brim: flowRate: 1.0 diff --git a/src/sliceActions/generateInfills.js b/src/sliceActions/generateInfills.js index 40ed2a6..31c4ec7 100644 --- a/src/sliceActions/generateInfills.js +++ b/src/sliceActions/generateInfills.js @@ -8,8 +8,7 @@ export default function generateInfills(slices, settings) { fill: { gridSize: fillGridSize }, bottom: { thickness: bottomThickness }, top: { thickness: topThickness }, - nozzleDiameter, - fill: { overlap: infillOverlap } + nozzleDiameter } = settings; fillGridSize /= PRECISION; @@ -47,13 +46,7 @@ export default function generateInfills(slices, settings) { let lowFillArea; let highFillArea; if (surroundingLayer) { - highFillArea = fillArea.difference(surroundingLayer); - - if (infillOverlap > 0) { - highFillArea = highFillArea.offset(infillOverlap); - } - - highFillArea = highFillArea.intersect(fillArea); + highFillArea = fillArea.difference(surroundingLayer).intersect(fillArea); lowFillArea = fillArea.difference(highFillArea); } else { highFillArea = fillArea; diff --git a/src/sliceActions/generateInnerLines.js b/src/sliceActions/generateInnerLines.js index 046369c..cfab81e 100644 --- a/src/sliceActions/generateInnerLines.js +++ b/src/sliceActions/generateInnerLines.js @@ -32,7 +32,8 @@ export default function generateInnerLines(slices, settings) { if (outerLine.paths.length > 0) { part.outerLine.join(outerLine); - for (let shell = 1; shell <= shells; shell += 1) { + // start with 1 because outerLine is the 1st (0) shell + for (let shell = 1; shell < shells; shell += 1) { const offset = shell * nozzleDiameter; const innerLine = outerLine.offset(-offset, offsetOptions); diff --git a/src/sliceActions/helpers/GCode.js b/src/sliceActions/helpers/GCode.js index 18f0261..48bc6dc 100644 --- a/src/sliceActions/helpers/GCode.js +++ b/src/sliceActions/helpers/GCode.js @@ -107,7 +107,7 @@ export default class { const lineLength = this._nozzlePosition.distanceTo(newNozzlePosition); const filamentSurfaceArea = Math.pow((filamentThickness / 2), 2) * Math.PI; - this._extruder += lineLength * nozzleDiameter * layerHeight / filamentSurfaceArea * flowRate; + this._extruder += lineLength * ((nozzleDiameter * layerHeight) / filamentSurfaceArea) * flowRate; this._addGCode({ [MOVE]: 1, @@ -164,7 +164,7 @@ export default class { const speed = retractionSpeed * 60; - if (this._extruder > retractionMinDistance && retractionEnabled) { + if (this._extruder > retractionMinDistance) { this._addGCode({ [MOVE]: 0, [EXTRUDER]: (this._extruder - retractionAmount).toFixed(3), diff --git a/src/sliceActions/optimizePaths.js b/src/sliceActions/optimizePaths.js index 6cc861c..5c6e718 100644 --- a/src/sliceActions/optimizePaths.js +++ b/src/sliceActions/optimizePaths.js @@ -13,6 +13,15 @@ export default function optimizePaths(slices, settings) { } const parts = []; + const boundingBoxes = new WeakMap(); + for (let i = 0; i < slice.parts.length; i ++) { + const part = slice.parts[i]; + + const shape = part.shape.closed ? part.outerLine : part.shape; + const bounds = shape.shapeBounds(); + + boundingBoxes.set(part, bounds); + } while (slice.parts.length > 0) { let closestDistance = Infinity; @@ -20,16 +29,14 @@ export default function optimizePaths(slices, settings) { for (let i = 0; i < slice.parts.length; i ++) { const part = slice.parts[i]; + const bounds = boundingBoxes.get(part); - const shape = part.shape.closed ? part.outerLine : part.shape; - const bounds = shape.shapeBounds(); + const topDistance = bounds.top - start.y; + const bottomDistance = start.y - bounds.bottom; + const leftDistance = bounds.left - start.x; + const rightDistance = start.x - bounds.right; - const top = bounds.top - start.y; - const bottom = start.y - bounds.bottom; - const left = bounds.left - start.x; - const right = start.x - bounds.right; - - const distance = Math.max(top, bottom, left, right); + const distance = Math.max(topDistance, bottomDistance, leftDistance, rightDistance); if (distance < closestDistance) { closestDistance = distance;