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 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));
}
}
}

View File

@ -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)
});
}

View File

@ -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);

View File

@ -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);

View File

@ -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);
}

View File

@ -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];