mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-26 15:34:57 +01:00
differentiate between open lines and closed lines for non filled paths
This commit is contained in:
parent
53bd335d7f
commit
ab4427e818
@ -2,10 +2,11 @@ import { PRECISION } from '../constants.js'
|
|||||||
|
|
||||||
export default function applyPrecision(shapes) {
|
export default function applyPrecision(shapes) {
|
||||||
for (let i = 0; i < shapes.length; i ++) {
|
for (let i = 0; i < shapes.length; i ++) {
|
||||||
const { closedShapes, openShapes } = shapes[i];
|
const { fillShapes, lineShapesOpen, lineShapesClosed } = shapes[i];
|
||||||
|
|
||||||
scaleUpShape(closedShapes);
|
scaleUpShape(fillShapes);
|
||||||
scaleUpShape(openShapes);
|
scaleUpShape(lineShapesOpen);
|
||||||
|
scaleUpShape(lineShapesClosed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ 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) continue;
|
if (!part.closed) continue;
|
||||||
|
|
||||||
const innerShell = part.shell[part.shell.length - 1];
|
const innerShell = part.shell[part.shell.length - 1];
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ export default function generateInnerLines(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) continue;
|
if (!part.closed) continue;
|
||||||
|
|
||||||
const outerLine = part.shape.offset(-nozzleRadius, offsetOptions);
|
const outerLine = part.shape.offset(-nozzleRadius, offsetOptions);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ 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.shape.closed) {
|
if (part.closed) {
|
||||||
const [outerLine] = part.shell;
|
const [outerLine] = part.shell;
|
||||||
shape.join(outerLine);
|
shape.join(outerLine);
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@ export default class {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.parts = [];
|
this.parts = [];
|
||||||
}
|
}
|
||||||
add(shape) {
|
add(shape, closed) {
|
||||||
const part = { shape };
|
const part = { shape, closed };
|
||||||
|
|
||||||
if (shape.closed) {
|
if (closed) {
|
||||||
part.shell = [];
|
part.shell = [];
|
||||||
part.innerFill = new Shape([], false);
|
part.innerFill = new Shape([], false);
|
||||||
part.outerFill = new Shape([], false);
|
part.outerFill = new Shape([], false);
|
||||||
|
@ -10,8 +10,9 @@ export default function intersectionsToShapes(layerIntersectionIndexes, layerInt
|
|||||||
|
|
||||||
if (intersectionIndexes.length === 0) continue;
|
if (intersectionIndexes.length === 0) continue;
|
||||||
|
|
||||||
const closedShapes = [];
|
const fillShapes = [];
|
||||||
const openShapes = [];
|
const lineShapesOpen = [];
|
||||||
|
const lineShapesClosed = [];
|
||||||
for (let i = 0; i < intersectionIndexes.length; i ++) {
|
for (let i = 0; i < intersectionIndexes.length; i ++) {
|
||||||
let index = intersectionIndexes[i];
|
let index = intersectionIndexes[i];
|
||||||
|
|
||||||
@ -107,14 +108,17 @@ export default function intersectionsToShapes(layerIntersectionIndexes, layerInt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (openGeometry) {
|
if (openGeometry) {
|
||||||
if (!openShape) shape.push(shape[0].clone());
|
if (openShape) {
|
||||||
openShapes.push(shape);
|
lineShapesOpen.push(shape);
|
||||||
} else {
|
} else {
|
||||||
closedShapes.push(shape);
|
lineShapesClosed.push(shape);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fillShapes.push(shape);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
layers.push({ closedShapes, openShapes });
|
layers.push({ fillShapes, lineShapesOpen, lineShapesClosed });
|
||||||
}
|
}
|
||||||
|
|
||||||
return layers;
|
return layers;
|
||||||
|
@ -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.shell[0] : part.shape;
|
const shape = part.closed ? part.shell[0] : part.shape;
|
||||||
const bounds = shape.shapeBounds();
|
const bounds = shape.shapeBounds();
|
||||||
|
|
||||||
boundingBoxes.set(part, bounds);
|
boundingBoxes.set(part, bounds);
|
||||||
@ -47,7 +47,7 @@ export default function optimizePaths(slices, settings) {
|
|||||||
const [part] = slice.parts.splice(closestPart, 1);
|
const [part] = slice.parts.splice(closestPart, 1);
|
||||||
parts.push(part);
|
parts.push(part);
|
||||||
|
|
||||||
if (part.shape.closed) {
|
if (part.closed) {
|
||||||
for (let i = 0; i < part.shell.length; i ++) {
|
for (let i = 0; i < part.shell.length; i ++) {
|
||||||
const shell = part.shell[i];
|
const shell = part.shell[i];
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ export default function removePrecision(slices) {
|
|||||||
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.closed) {
|
||||||
for (let i = 0; i < part.shell.length; i ++) {
|
for (let i = 0; i < part.shell.length; i ++) {
|
||||||
const innerLine = part.shell[i];
|
const innerLine = part.shell[i];
|
||||||
innerLine.scaleDown(inversePrecision);
|
innerLine.scaleDown(inversePrecision);
|
||||||
|
@ -9,15 +9,18 @@ export default function shapesToSlices(shapes, settings) {
|
|||||||
const sliceLayers = [];
|
const sliceLayers = [];
|
||||||
|
|
||||||
for (let layer = 0; layer < shapes.length; layer ++) {
|
for (let layer = 0; layer < shapes.length; layer ++) {
|
||||||
let { closedShapes, openShapes } = shapes[layer];
|
let { fillShapes, lineShapesOpen, lineShapesClosed } = shapes[layer];
|
||||||
|
|
||||||
closedShapes = new Shape(closedShapes, true, true, true, true)
|
fillShapes = new Shape(fillShapes, true, true, true, true)
|
||||||
.fixOrientation()
|
.fixOrientation()
|
||||||
.simplify('pftNonZero')
|
.simplify('pftNonZero')
|
||||||
.clean(cleanDelta)
|
.clean(cleanDelta)
|
||||||
.seperateShapes();
|
.seperateShapes();
|
||||||
|
|
||||||
openShapes = new Shape(openShapes, false, true, true, true);
|
lineShapesClosed = new Shape(lineShapesClosed, true, true, true, true)
|
||||||
|
.clean(cleanDelta);
|
||||||
|
|
||||||
|
lineShapesOpen = new Shape(lineShapesOpen, false, true, true, true);
|
||||||
// .clean(cleanDelta);
|
// .clean(cleanDelta);
|
||||||
// TODO
|
// TODO
|
||||||
// Cleaning is actually wanted here but there is a bug in the clean function
|
// Cleaning is actually wanted here but there is a bug in the clean function
|
||||||
@ -25,17 +28,24 @@ export default function shapesToSlices(shapes, settings) {
|
|||||||
|
|
||||||
const slice = new Slice();
|
const slice = new Slice();
|
||||||
|
|
||||||
for (let i = 0; i < closedShapes.length; i ++) {
|
for (let i = 0; i < fillShapes.length; i ++) {
|
||||||
const closedShape = closedShapes[i];
|
const fillShape = fillShapes[i];
|
||||||
slice.add(closedShape);
|
slice.add(fillShape, true);
|
||||||
|
|
||||||
// if (openShapes.path.length > 0) {
|
// if (lineShapesClosed.paths.length > 0) {
|
||||||
// openShapes = openShapes.difference(closedShape);
|
// lineShapesClosed = lineShapesClosed.difference(closedShape);
|
||||||
|
// }
|
||||||
|
// if (lineShapesOpen.paths.length > 0) {
|
||||||
|
// lineShapesOpen = lineShapesOpen.difference(closedShape);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openShapes.paths.length > 0) {
|
if (lineShapesClosed.paths.length > 0) {
|
||||||
slice.add(openShapes);
|
slice.add(lineShapesClosed, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lineShapesOpen.paths.length > 0) {
|
||||||
|
slice.add(lineShapesOpen, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
sliceLayers.push(slice);
|
sliceLayers.push(slice);
|
||||||
|
@ -37,7 +37,7 @@ export default function slicesToGCode(slices, settings) {
|
|||||||
profiles[profileType] = {
|
profiles[profileType] = {
|
||||||
...defaultProfile,
|
...defaultProfile,
|
||||||
lineProfile: isFirstLayer ? settings.firstLayer : settings[profileType]
|
lineProfile: isFirstLayer ? settings.firstLayer : settings[profileType]
|
||||||
}
|
};
|
||||||
return profiles;
|
return profiles;
|
||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ export default function slicesToGCode(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.closed) {
|
||||||
for (let i = 0; i < part.shell.length; i ++) {
|
for (let i = 0; i < part.shell.length; i ++) {
|
||||||
const shell = part.shell[i];
|
const shell = part.shell[i];
|
||||||
const isOuterShell = i === 0;
|
const isOuterShell = i === 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user