diff --git a/src/sliceActions/generateInfills.js b/src/sliceActions/generateInfills.js index d071e55..14c5f66 100644 --- a/src/sliceActions/generateInfills.js +++ b/src/sliceActions/generateInfills.js @@ -19,7 +19,7 @@ export default function generateInfills(slices, settings) { const bottomSkinCount = Math.ceil(bottomThickness/layerHeight); const topSkinCount = Math.ceil(topThickness/layerHeight); const nozzleRadius = nozzleDiameter / 2; - const hightemplateSize = Math.sqrt(2 * Math.pow(nozzleDiameter, 2)); + const outerFillTemplateSize = Math.sqrt(2 * Math.pow(nozzleDiameter, 2)); for (let layer = 0; layer < slices.length; layer ++) { const slice = slices[layer]; @@ -44,28 +44,28 @@ export default function generateInfills(slices, settings) { const inset = (part.innerLines.length > 0) ? part.innerLines[part.innerLines.length - 1] : outerLine; const fillArea = inset.offset(-nozzleRadius); - let lowFillArea; - let highFillArea; + let innerFillArea; + let outerFillArea; if (surroundingLayer) { - highFillArea = fillArea.difference(surroundingLayer).intersect(fillArea); - lowFillArea = fillArea.difference(highFillArea); + outerFillArea = fillArea.difference(surroundingLayer).intersect(fillArea); + innerFillArea = fillArea.difference(outerFillArea); } else { - highFillArea = fillArea; + outerFillArea = fillArea; } - if (lowFillArea && lowFillArea.paths.length > 0) { - const bounds = lowFillArea.shapeBounds(); - const lowFillTemplate = getFillTemplate(bounds, infillGridSize, true, true); + if (innerFillArea && innerFillArea.paths.length > 0) { + const bounds = innerFillArea.shapeBounds(); + const innerFillTemplate = getFillTemplate(bounds, infillGridSize, true, true); - part.fill.join(lowFillTemplate.intersect(lowFillArea)); + part.innerFill.join(innerFillTemplate.intersect(innerFillArea)); } - if (highFillArea.paths.length > 0) { - const bounds = highFillArea.shapeBounds(); + if (outerFillArea.paths.length > 0) { + const bounds = outerFillArea.shapeBounds(); const even = (layer % 2 === 0); - const highFillTemplate = getFillTemplate(bounds, hightemplateSize, even, !even); + const outerFillTemplate = getFillTemplate(bounds, outerFillTemplateSize, even, !even); - part.fill.join(highFillTemplate.intersect(highFillArea)); + part.outerFill.join(outerFillTemplate.intersect(outerFillArea)); } } } diff --git a/src/sliceActions/helpers/GCode.js b/src/sliceActions/helpers/GCode.js index c8df4ad..4323ce9 100644 --- a/src/sliceActions/helpers/GCode.js +++ b/src/sliceActions/helpers/GCode.js @@ -117,7 +117,7 @@ export default class { return this; } - retract({ enabled, speed, minDistance }) { + retract({ enabled, speed, minDistance, amount }) { if (!this._isRetracted && enabled) { this._isRetracted = true; @@ -126,7 +126,7 @@ export default class { if (this._extruder > minDistance) { this._addGCode({ [MOVE]: 0, - [EXTRUDER]: (this._extruder - retractionAmount).toFixed(3), + [EXTRUDER]: (this._extruder - amount).toFixed(3), [SPEED]: speed.toFixed(3) }); } diff --git a/src/sliceActions/helpers/Slice.js b/src/sliceActions/helpers/Slice.js index 968f70a..ee966ff 100644 --- a/src/sliceActions/helpers/Slice.js +++ b/src/sliceActions/helpers/Slice.js @@ -10,7 +10,8 @@ export default class { if (shape.closed) { part.innerLines = []; part.outerLine = new Shape([], true); - part.fill = new Shape([], false); + part.innerFill = new Shape([], false); + part.outerFill = new Shape([], false); } this.parts.push(part); diff --git a/src/sliceActions/optimizePaths.js b/src/sliceActions/optimizePaths.js index 5c6e718..8f67786 100644 --- a/src/sliceActions/optimizePaths.js +++ b/src/sliceActions/optimizePaths.js @@ -48,9 +48,14 @@ export default function optimizePaths(slices, settings) { parts.push(part); if (part.shape.closed) { - if (part.outerLine.paths.length > 0) { - part.outerLine = optimizeShape(part.outerLine, start); - start.copy(part.outerLine.lastPoint(true)); + if (part.innerFill.paths.length > 0) { + part.innerFill = optimizeShape(part.innerFill, start); + start.copy(part.innerFill.lastPoint(true)); + } + + if (part.outerFill.paths.length > 0) { + part.outerFill = optimizeShape(part.outerFill, start); + start.copy(part.outerFill.lastPoint(true)); } for (let i = 0; i < part.innerLines.length; i ++) { @@ -62,9 +67,9 @@ export default function optimizePaths(slices, settings) { } } - if (part.fill.paths.length > 0) { - part.fill = optimizeShape(part.fill, start); - start.copy(part.fill.lastPoint(true)); + if (part.outerLine.paths.length > 0) { + part.outerLine = optimizeShape(part.outerLine, start); + start.copy(part.outerLine.lastPoint(true)); } } else { part.shape = optimizeShape(part.shape, start); diff --git a/src/sliceActions/removePrecision.js b/src/sliceActions/removePrecision.js index ec02f25..f84ce05 100644 --- a/src/sliceActions/removePrecision.js +++ b/src/sliceActions/removePrecision.js @@ -15,7 +15,8 @@ export default function removePrecision(slices) { const innerLine = part.innerLines[i]; innerLine.scaleDown(inversePrecision); } - part.fill.scaleDown(inversePrecision); + part.innerFill.scaleDown(inversePrecision); + part.outerFill.scaleDown(inversePrecision); } else { part.shape.scaleDown(inversePrecision); } diff --git a/src/sliceActions/slicesToGCode.js b/src/sliceActions/slicesToGCode.js index 02cac68..9e95135 100644 --- a/src/sliceActions/slicesToGCode.js +++ b/src/sliceActions/slicesToGCode.js @@ -49,14 +49,15 @@ export default function slicesToGCode(slices, settings) { const part = slice.parts[i]; if (part.shape.closed) { - pathToGCode(gcode, part.outerLine, false, true, profiles.outerShell); + pathToGCode(gcode, part.innerFill, false, true, z, profiles.innerInfill); + pathToGCode(gcode, part.outerFill, false, false, z, profiles.outerInfill); for (let i = 0; i < part.innerLines.length; i ++) { const innerLine = part.innerLines[i]; pathToGCode(gcode, innerLine, false, false, z, profiles.innerShell); } - pathToGCode(gcode, part.fill, true, false, z, profiles.outerInfill); + pathToGCode(gcode, part.outerLine, true, false, z, profiles.outerShell); } else { const retract = !(slice.parts.length === 1 && typeof slice.support === 'undefined'); pathToGCode(gcode, part.shape, retract, retract, z, profiles.outerShell); @@ -75,6 +76,8 @@ function pathToGCode(gcode, shape, retract, unRetract, z, { lineProfile, travelP const { closed } = shape; const paths = shape.mapToLower(); + console.log('retractionProfile: ', retractionProfile); + for (let i = 0; i < paths.length; i ++) { const line = paths[i];