mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-22 21:47:59 +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) {
|
||||
for (let i = 0; i < shapes.length; i ++) {
|
||||
const { closedShapes, openShapes } = shapes[i];
|
||||
const { fillShapes, lineShapesOpen, lineShapesClosed } = shapes[i];
|
||||
|
||||
scaleUpShape(closedShapes);
|
||||
scaleUpShape(openShapes);
|
||||
scaleUpShape(fillShapes);
|
||||
scaleUpShape(lineShapesOpen);
|
||||
scaleUpShape(lineShapesClosed);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ 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.closed) continue;
|
||||
|
||||
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 ++) {
|
||||
const part = slice.parts[i];
|
||||
|
||||
if (!part.shape.closed) continue;
|
||||
if (!part.closed) continue;
|
||||
|
||||
const outerLine = part.shape.offset(-nozzleRadius, offsetOptions);
|
||||
|
||||
|
@ -5,7 +5,7 @@ export default function calculateOutlines(slices, settings) {
|
||||
const slice = slices[layer];
|
||||
|
||||
slice.outline = slice.parts.reduce((shape, part) => {
|
||||
if (part.shape.closed) {
|
||||
if (part.closed) {
|
||||
const [outerLine] = part.shell;
|
||||
shape.join(outerLine);
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ export default class {
|
||||
constructor() {
|
||||
this.parts = [];
|
||||
}
|
||||
add(shape) {
|
||||
const part = { shape };
|
||||
add(shape, closed) {
|
||||
const part = { shape, closed };
|
||||
|
||||
if (shape.closed) {
|
||||
if (closed) {
|
||||
part.shell = [];
|
||||
part.innerFill = new Shape([], false);
|
||||
part.outerFill = new Shape([], false);
|
||||
|
@ -10,8 +10,9 @@ export default function intersectionsToShapes(layerIntersectionIndexes, layerInt
|
||||
|
||||
if (intersectionIndexes.length === 0) continue;
|
||||
|
||||
const closedShapes = [];
|
||||
const openShapes = [];
|
||||
const fillShapes = [];
|
||||
const lineShapesOpen = [];
|
||||
const lineShapesClosed = [];
|
||||
for (let i = 0; i < intersectionIndexes.length; i ++) {
|
||||
let index = intersectionIndexes[i];
|
||||
|
||||
@ -107,14 +108,17 @@ export default function intersectionsToShapes(layerIntersectionIndexes, layerInt
|
||||
}
|
||||
|
||||
if (openGeometry) {
|
||||
if (!openShape) shape.push(shape[0].clone());
|
||||
openShapes.push(shape);
|
||||
if (openShape) {
|
||||
lineShapesOpen.push(shape);
|
||||
} else {
|
||||
lineShapesClosed.push(shape);
|
||||
}
|
||||
} else {
|
||||
closedShapes.push(shape);
|
||||
fillShapes.push(shape);
|
||||
}
|
||||
}
|
||||
|
||||
layers.push({ closedShapes, openShapes });
|
||||
layers.push({ fillShapes, lineShapesOpen, lineShapesClosed });
|
||||
}
|
||||
|
||||
return layers;
|
||||
|
@ -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.shell[0] : part.shape;
|
||||
const shape = part.closed ? part.shell[0] : part.shape;
|
||||
const bounds = shape.shapeBounds();
|
||||
|
||||
boundingBoxes.set(part, bounds);
|
||||
@ -47,7 +47,7 @@ export default function optimizePaths(slices, settings) {
|
||||
const [part] = slice.parts.splice(closestPart, 1);
|
||||
parts.push(part);
|
||||
|
||||
if (part.shape.closed) {
|
||||
if (part.closed) {
|
||||
for (let i = 0; i < part.shell.length; i ++) {
|
||||
const shell = part.shell[i];
|
||||
|
||||
|
@ -9,7 +9,7 @@ export default function removePrecision(slices) {
|
||||
for (let i = 0; i < slice.parts.length; i ++) {
|
||||
const part = slice.parts[i];
|
||||
|
||||
if (part.shape.closed) {
|
||||
if (part.closed) {
|
||||
for (let i = 0; i < part.shell.length; i ++) {
|
||||
const innerLine = part.shell[i];
|
||||
innerLine.scaleDown(inversePrecision);
|
||||
|
@ -9,15 +9,18 @@ export default function shapesToSlices(shapes, settings) {
|
||||
const sliceLayers = [];
|
||||
|
||||
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()
|
||||
.simplify('pftNonZero')
|
||||
.clean(cleanDelta)
|
||||
.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);
|
||||
// TODO
|
||||
// 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();
|
||||
|
||||
for (let i = 0; i < closedShapes.length; i ++) {
|
||||
const closedShape = closedShapes[i];
|
||||
slice.add(closedShape);
|
||||
for (let i = 0; i < fillShapes.length; i ++) {
|
||||
const fillShape = fillShapes[i];
|
||||
slice.add(fillShape, true);
|
||||
|
||||
// if (openShapes.path.length > 0) {
|
||||
// openShapes = openShapes.difference(closedShape);
|
||||
// if (lineShapesClosed.paths.length > 0) {
|
||||
// lineShapesClosed = lineShapesClosed.difference(closedShape);
|
||||
// }
|
||||
// if (lineShapesOpen.paths.length > 0) {
|
||||
// lineShapesOpen = lineShapesOpen.difference(closedShape);
|
||||
// }
|
||||
}
|
||||
|
||||
if (openShapes.paths.length > 0) {
|
||||
slice.add(openShapes);
|
||||
if (lineShapesClosed.paths.length > 0) {
|
||||
slice.add(lineShapesClosed, false);
|
||||
}
|
||||
|
||||
if (lineShapesOpen.paths.length > 0) {
|
||||
slice.add(lineShapesOpen, false);
|
||||
}
|
||||
|
||||
sliceLayers.push(slice);
|
||||
|
@ -37,7 +37,7 @@ export default function slicesToGCode(slices, settings) {
|
||||
profiles[profileType] = {
|
||||
...defaultProfile,
|
||||
lineProfile: isFirstLayer ? settings.firstLayer : settings[profileType]
|
||||
}
|
||||
};
|
||||
return profiles;
|
||||
}, {});
|
||||
|
||||
@ -48,7 +48,7 @@ export default function slicesToGCode(slices, settings) {
|
||||
for (let i = 0; i < slice.parts.length; i ++) {
|
||||
const part = slice.parts[i];
|
||||
|
||||
if (part.shape.closed) {
|
||||
if (part.closed) {
|
||||
for (let i = 0; i < part.shell.length; i ++) {
|
||||
const shell = part.shell[i];
|
||||
const isOuterShell = i === 0;
|
||||
|
Loading…
Reference in New Issue
Block a user