combine interlines and outline into shell

This commit is contained in:
casperlamboo 2017-07-28 12:13:53 +02:00
parent d380db1d7a
commit 72db7105fb
8 changed files with 58 additions and 64 deletions

View File

@ -37,7 +37,7 @@ outerShell:
speed: 40.0 speed: 40.0
innerInfill: innerInfill:
flowRate: 1.0 flowRate: 1.0
speed: 50.0 speed: 80.0
gridSize: 5.0 gridSize: 5.0
outerInfill: outerInfill:
flowRate: 1.0 flowRate: 1.0

View File

@ -34,16 +34,13 @@ export default function generateInfills(slices, settings) {
for (let i = 0; i < slice.parts.length; i ++) { for (let i = 0; i < slice.parts.length; i ++) {
const part = slice.parts[i]; const part = slice.parts[i];
if (!part.shape.closed) { if (!part.shape.closed) continue;
continue;
}
const outerLine = part.outerLine; const innerShell = part.shell[part.shell.length - 1];
if (outerLine.paths.length > 0) { if (innerShell.paths.length === 0) continue;
const inset = (part.innerLines.length > 0) ? part.innerLines[part.innerLines.length - 1] : outerLine;
const fillArea = inset.offset(-nozzleRadius); const fillArea = innerShell.offset(-nozzleRadius);
let innerFillArea; let innerFillArea;
let outerFillArea; let outerFillArea;
if (surroundingLayer) { if (surroundingLayer) {
@ -69,5 +66,4 @@ export default function generateInfills(slices, settings) {
} }
} }
} }
}
} }

View File

@ -19,7 +19,7 @@ export default function generateInnerLines(slices, settings) {
shellThickness /= PRECISION; shellThickness /= PRECISION;
const nozzleRadius = nozzleDiameter / 2; const nozzleRadius = nozzleDiameter / 2;
const shells = Math.round(shellThickness / nozzleDiameter); const numShells = Math.round(shellThickness / nozzleDiameter);
for (let layer = 0; layer < slices.length; layer ++) { for (let layer = 0; layer < slices.length; layer ++) {
const slice = slices[layer]; const slice = slices[layer];
@ -32,16 +32,16 @@ export default function generateInnerLines(slices, settings) {
const outerLine = part.shape.offset(-nozzleRadius, offsetOptions); const outerLine = part.shape.offset(-nozzleRadius, offsetOptions);
if (outerLine.paths.length > 0) { if (outerLine.paths.length > 0) {
part.outerLine.join(outerLine); part.shell.push(outerLine);
// start with 1 because outerLine is the 1st (0) shell // start with 1 because outerLine is the 1st (0) shell
for (let shell = 1; shell < shells; shell += 1) { for (let inset = 1; inset < numShells; inset += 1) {
const offset = shell * nozzleDiameter; const offset = inset * nozzleDiameter;
const innerLine = outerLine.offset(-offset, offsetOptions); const shell = outerLine.offset(-offset, offsetOptions);
if (innerLine.paths.length > 0) { if (shell.paths.length > 0) {
part.innerLines.push(innerLine); part.shell.push(shell);
} else { } else {
break; break;
} }

View File

@ -5,7 +5,10 @@ export default function calculateOutlines(slices, settings) {
const slice = slices[layer]; const slice = slices[layer];
slice.outline = slice.parts.reduce((shape, part) => { slice.outline = slice.parts.reduce((shape, part) => {
if (part.outerLine) shape.join(part.outerLine); if (part.shape.closed) {
const [outerLine] = part.shell;
shape.join(outerLine);
}
return shape; return shape;
}, new Shape([], true)); }, new Shape([], true));
} }

View File

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

View File

@ -17,7 +17,7 @@ export default function optimizePaths(slices, settings) {
for (let i = 0; i < slice.parts.length; i ++) { for (let i = 0; i < slice.parts.length; i ++) {
const part = slice.parts[i]; const part = slice.parts[i];
const shape = part.shape.closed ? part.outerLine : part.shape; const shape = part.shape.closed ? part.shell[0] : part.shape;
const bounds = shape.shapeBounds(); const bounds = shape.shapeBounds();
boundingBoxes.set(part, bounds); boundingBoxes.set(part, bounds);
@ -48,9 +48,13 @@ export default function optimizePaths(slices, settings) {
parts.push(part); parts.push(part);
if (part.shape.closed) { if (part.shape.closed) {
if (part.innerFill.paths.length > 0) { for (let i = 0; i < part.shell.length; i ++) {
part.innerFill = optimizeShape(part.innerFill, start); const shell = part.shell[i];
start.copy(part.innerFill.lastPoint(true));
if (shell.paths.length === 0) continue;
part.shell[i] = optimizeShape(shell, start);
start.copy(part.shell[i].lastPoint(true));
} }
if (part.outerFill.paths.length > 0) { if (part.outerFill.paths.length > 0) {
@ -58,18 +62,9 @@ export default function optimizePaths(slices, settings) {
start.copy(part.outerFill.lastPoint(true)); start.copy(part.outerFill.lastPoint(true));
} }
for (let i = 0; i < part.innerLines.length; i ++) { if (part.innerFill.paths.length > 0) {
const innerLine = part.innerLines[i]; part.innerFill = optimizeShape(part.innerFill, start);
start.copy(part.innerFill.lastPoint(true));
if (innerLine.paths.length > 0) {
part.innerLines[i] = optimizeShape(innerLine, start);
start.copy(part.innerLines[i].lastPoint(true));
}
}
if (part.outerLine.paths.length > 0) {
part.outerLine = optimizeShape(part.outerLine, start);
start.copy(part.outerLine.lastPoint(true));
} }
} else { } else {
part.shape = optimizeShape(part.shape, start); part.shape = optimizeShape(part.shape, start);

View File

@ -10,9 +10,8 @@ export default function removePrecision(slices) {
const part = slice.parts[i]; const part = slice.parts[i];
if (part.shape.closed) { if (part.shape.closed) {
part.outerLine.scaleDown(inversePrecision); for (let i = 0; i < part.shell.length; i ++) {
for (let i = 0; i < part.innerLines.length; i ++) { const innerLine = part.shell[i];
const innerLine = part.innerLines[i];
innerLine.scaleDown(inversePrecision); innerLine.scaleDown(inversePrecision);
} }
part.innerFill.scaleDown(inversePrecision); part.innerFill.scaleDown(inversePrecision);

View File

@ -49,15 +49,17 @@ 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.innerFill, false, true, z, profiles.innerInfill); for (let i = 0; i < part.shell.length; i ++) {
pathToGCode(gcode, part.outerFill, false, false, z, profiles.outerInfill); const shell = part.shell[i];
const isOuterShell = i === 0;
for (let i = 0; i < part.innerLines.length; i ++) { const unRetract = isOuterShell;
const innerLine = part.innerLines[i]; const profile = isOuterShell ? profiles.outerShell : profiles.innerShell;
pathToGCode(gcode, innerLine, false, false, z, profiles.innerShell); pathToGCode(gcode, shell, false, unRetract, z, profile);
} }
pathToGCode(gcode, part.outerLine, true, false, z, profiles.outerShell); pathToGCode(gcode, part.outerFill, false, false, z, profiles.outerInfill);
pathToGCode(gcode, part.innerFill, true, false, z, profiles.innerInfill);
} 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);