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
innerInfill:
flowRate: 1.0
speed: 50.0
speed: 80.0
gridSize: 5.0
outerInfill:
flowRate: 1.0

View File

@ -34,39 +34,35 @@ export default function generateInfills(slices, settings) {
for (let i = 0; i < slice.parts.length; i ++) {
const part = slice.parts[i];
if (!part.shape.closed) {
continue;
if (!part.shape.closed) continue;
const innerShell = part.shell[part.shell.length - 1];
if (innerShell.paths.length === 0) continue;
const fillArea = innerShell.offset(-nozzleRadius);
let innerFillArea;
let outerFillArea;
if (surroundingLayer) {
outerFillArea = fillArea.difference(surroundingLayer).intersect(fillArea);
innerFillArea = fillArea.difference(outerFillArea);
} else {
outerFillArea = fillArea;
}
const outerLine = part.outerLine;
if (innerFillArea && innerFillArea.paths.length > 0) {
const bounds = innerFillArea.shapeBounds();
const innerFillTemplate = getFillTemplate(bounds, infillGridSize, true, true);
if (outerLine.paths.length > 0) {
const inset = (part.innerLines.length > 0) ? part.innerLines[part.innerLines.length - 1] : outerLine;
part.innerFill.join(innerFillTemplate.intersect(innerFillArea));
}
const fillArea = inset.offset(-nozzleRadius);
let innerFillArea;
let outerFillArea;
if (surroundingLayer) {
outerFillArea = fillArea.difference(surroundingLayer).intersect(fillArea);
innerFillArea = fillArea.difference(outerFillArea);
} else {
outerFillArea = fillArea;
}
if (outerFillArea.paths.length > 0) {
const bounds = outerFillArea.shapeBounds();
const even = (layer % 2 === 0);
const outerFillTemplate = getFillTemplate(bounds, outerFillTemplateSize, even, !even);
if (innerFillArea && innerFillArea.paths.length > 0) {
const bounds = innerFillArea.shapeBounds();
const innerFillTemplate = getFillTemplate(bounds, infillGridSize, true, true);
part.innerFill.join(innerFillTemplate.intersect(innerFillArea));
}
if (outerFillArea.paths.length > 0) {
const bounds = outerFillArea.shapeBounds();
const even = (layer % 2 === 0);
const outerFillTemplate = getFillTemplate(bounds, outerFillTemplateSize, even, !even);
part.outerFill.join(outerFillTemplate.intersect(outerFillArea));
}
part.outerFill.join(outerFillTemplate.intersect(outerFillArea));
}
}
}

View File

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

View File

@ -5,7 +5,10 @@ export default function calculateOutlines(slices, settings) {
const slice = slices[layer];
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;
}, new Shape([], true));
}

View File

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

View File

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

View File

@ -49,15 +49,17 @@ export default function slicesToGCode(slices, settings) {
const part = slice.parts[i];
if (part.shape.closed) {
pathToGCode(gcode, part.innerFill, false, true, z, profiles.innerInfill);
pathToGCode(gcode, part.outerFill, false, false, z, profiles.outerInfill);
for (let i = 0; i < part.shell.length; i ++) {
const shell = part.shell[i];
const isOuterShell = i === 0;
for (let i = 0; i < part.innerLines.length; i ++) {
const innerLine = part.innerLines[i];
pathToGCode(gcode, innerLine, false, false, z, profiles.innerShell);
const unRetract = isOuterShell;
const profile = isOuterShell ? profiles.outerShell : 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 {
const retract = !(slice.parts.length === 1 && typeof slice.support === 'undefined');
pathToGCode(gcode, part.shape, retract, retract, z, profiles.outerShell);