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,39 +34,35 @@ 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 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) { part.innerFill.join(innerFillTemplate.intersect(innerFillArea));
const inset = (part.innerLines.length > 0) ? part.innerLines[part.innerLines.length - 1] : outerLine; }
const fillArea = inset.offset(-nozzleRadius); if (outerFillArea.paths.length > 0) {
let innerFillArea; const bounds = outerFillArea.shapeBounds();
let outerFillArea; const even = (layer % 2 === 0);
if (surroundingLayer) { const outerFillTemplate = getFillTemplate(bounds, outerFillTemplateSize, even, !even);
outerFillArea = fillArea.difference(surroundingLayer).intersect(fillArea);
innerFillArea = fillArea.difference(outerFillArea);
} else {
outerFillArea = fillArea;
}
if (innerFillArea && innerFillArea.paths.length > 0) { part.outerFill.join(outerFillTemplate.intersect(outerFillArea));
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));
}
} }
} }
} }

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