separate inner fill and outer fill

This commit is contained in:
casperlamboo 2017-07-28 11:05:48 +02:00
parent a19ffbffab
commit 39f29eb489
6 changed files with 36 additions and 26 deletions

View File

@ -19,7 +19,7 @@ export default function generateInfills(slices, settings) {
const bottomSkinCount = Math.ceil(bottomThickness/layerHeight); const bottomSkinCount = Math.ceil(bottomThickness/layerHeight);
const topSkinCount = Math.ceil(topThickness/layerHeight); const topSkinCount = Math.ceil(topThickness/layerHeight);
const nozzleRadius = nozzleDiameter / 2; 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 ++) { for (let layer = 0; layer < slices.length; layer ++) {
const slice = slices[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 inset = (part.innerLines.length > 0) ? part.innerLines[part.innerLines.length - 1] : outerLine;
const fillArea = inset.offset(-nozzleRadius); const fillArea = inset.offset(-nozzleRadius);
let lowFillArea; let innerFillArea;
let highFillArea; let outerFillArea;
if (surroundingLayer) { if (surroundingLayer) {
highFillArea = fillArea.difference(surroundingLayer).intersect(fillArea); outerFillArea = fillArea.difference(surroundingLayer).intersect(fillArea);
lowFillArea = fillArea.difference(highFillArea); innerFillArea = fillArea.difference(outerFillArea);
} else { } else {
highFillArea = fillArea; outerFillArea = fillArea;
} }
if (lowFillArea && lowFillArea.paths.length > 0) { if (innerFillArea && innerFillArea.paths.length > 0) {
const bounds = lowFillArea.shapeBounds(); const bounds = innerFillArea.shapeBounds();
const lowFillTemplate = getFillTemplate(bounds, infillGridSize, true, true); const innerFillTemplate = getFillTemplate(bounds, infillGridSize, true, true);
part.fill.join(lowFillTemplate.intersect(lowFillArea)); part.innerFill.join(innerFillTemplate.intersect(innerFillArea));
} }
if (highFillArea.paths.length > 0) { if (outerFillArea.paths.length > 0) {
const bounds = highFillArea.shapeBounds(); const bounds = outerFillArea.shapeBounds();
const even = (layer % 2 === 0); 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));
} }
} }
} }

View File

@ -117,7 +117,7 @@ export default class {
return this; return this;
} }
retract({ enabled, speed, minDistance }) { retract({ enabled, speed, minDistance, amount }) {
if (!this._isRetracted && enabled) { if (!this._isRetracted && enabled) {
this._isRetracted = true; this._isRetracted = true;
@ -126,7 +126,7 @@ export default class {
if (this._extruder > minDistance) { if (this._extruder > minDistance) {
this._addGCode({ this._addGCode({
[MOVE]: 0, [MOVE]: 0,
[EXTRUDER]: (this._extruder - retractionAmount).toFixed(3), [EXTRUDER]: (this._extruder - amount).toFixed(3),
[SPEED]: speed.toFixed(3) [SPEED]: speed.toFixed(3)
}); });
} }

View File

@ -10,7 +10,8 @@ export default class {
if (shape.closed) { if (shape.closed) {
part.innerLines = []; part.innerLines = [];
part.outerLine = new Shape([], true); part.outerLine = new Shape([], true);
part.fill = new Shape([], false); part.innerFill = new Shape([], false);
part.outerFill = new Shape([], false);
} }
this.parts.push(part); this.parts.push(part);

View File

@ -48,9 +48,14 @@ export default function optimizePaths(slices, settings) {
parts.push(part); parts.push(part);
if (part.shape.closed) { if (part.shape.closed) {
if (part.outerLine.paths.length > 0) { if (part.innerFill.paths.length > 0) {
part.outerLine = optimizeShape(part.outerLine, start); part.innerFill = optimizeShape(part.innerFill, start);
start.copy(part.outerLine.lastPoint(true)); 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 ++) { 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) { if (part.outerLine.paths.length > 0) {
part.fill = optimizeShape(part.fill, start); part.outerLine = optimizeShape(part.outerLine, start);
start.copy(part.fill.lastPoint(true)); start.copy(part.outerLine.lastPoint(true));
} }
} else { } else {
part.shape = optimizeShape(part.shape, start); part.shape = optimizeShape(part.shape, start);

View File

@ -15,7 +15,8 @@ export default function removePrecision(slices) {
const innerLine = part.innerLines[i]; const innerLine = part.innerLines[i];
innerLine.scaleDown(inversePrecision); innerLine.scaleDown(inversePrecision);
} }
part.fill.scaleDown(inversePrecision); part.innerFill.scaleDown(inversePrecision);
part.outerFill.scaleDown(inversePrecision);
} else { } else {
part.shape.scaleDown(inversePrecision); part.shape.scaleDown(inversePrecision);
} }

View File

@ -49,14 +49,15 @@ export default function slicesToGCode(slices, settings) {
const part = slice.parts[i]; const part = slice.parts[i];
if (part.shape.closed) { 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 ++) { for (let i = 0; i < part.innerLines.length; i ++) {
const innerLine = part.innerLines[i]; const innerLine = part.innerLines[i];
pathToGCode(gcode, innerLine, false, false, z, profiles.innerShell); 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 { } else {
const retract = !(slice.parts.length === 1 && typeof slice.support === 'undefined'); const retract = !(slice.parts.length === 1 && typeof slice.support === 'undefined');
pathToGCode(gcode, part.shape, retract, retract, z, profiles.outerShell); 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 { closed } = shape;
const paths = shape.mapToLower(); const paths = shape.mapToLower();
console.log('retractionProfile: ', retractionProfile);
for (let i = 0; i < paths.length; i ++) { for (let i = 0; i < paths.length; i ++) {
const line = paths[i]; const line = paths[i];