mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-22 21:47:59 +01:00
simplify code
This commit is contained in:
parent
4a61164af9
commit
0ad8de8c80
@ -71,11 +71,12 @@ function sliceAsync(settings, geometry, onProgress) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// send geometry and settings to worker to start the slicing progress
|
// send geometry and settings to worker to start the slicing progress
|
||||||
|
geometry = geometry.toJSON();
|
||||||
slicerWorker.postMessage({
|
slicerWorker.postMessage({
|
||||||
message: 'SLICE',
|
message: 'SLICE',
|
||||||
data: {
|
data: {
|
||||||
settings,
|
settings,
|
||||||
geometry: geometry.toJSON()
|
geometry
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -15,11 +15,10 @@ export default function addBrim(slices, settings) {
|
|||||||
|
|
||||||
const [firstLayer] = slices;
|
const [firstLayer] = slices;
|
||||||
|
|
||||||
firstLayer.brim = firstLayer.parts.reduce((brim, { shape }) => {
|
firstLayer.brim = firstLayer.parts.reduce((brim, { shape }) => (
|
||||||
brim.join(shape.offset(brimOffset, {
|
brim.join(shape.offset(brimOffset, {
|
||||||
...offsetOptions,
|
...offsetOptions,
|
||||||
endType: shape.closed ? 'etClosedPolygon' : 'etOpenRound'
|
endType: shape.closed ? 'etClosedPolygon' : 'etOpenRound'
|
||||||
}));
|
}))
|
||||||
return brim;
|
), new Shape([], true)).simplify('pftNonZero');
|
||||||
}, new Shape([], true)).simplify('pftNonZero');
|
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,8 @@ 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];
|
||||||
|
|
||||||
let bounds;
|
const shape = part.shape.closed ? part.outerLine : part.shape;
|
||||||
if (part.shape.closed) {
|
const bounds = shape.shapeBounds();
|
||||||
bounds = part.outerLine.shapeBounds();
|
|
||||||
} else {
|
|
||||||
bounds = part.shape.shapeBounds();
|
|
||||||
}
|
|
||||||
|
|
||||||
const top = bounds.top - start.y;
|
const top = bounds.top - start.y;
|
||||||
const bottom = start.y - bounds.bottom;
|
const bottom = start.y - bounds.bottom;
|
||||||
@ -41,7 +37,7 @@ export default function optimizePaths(slices, settings) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const part = slice.parts.splice(closestPart, 1)[0];
|
const [part] = slice.parts.splice(closestPart, 1);
|
||||||
parts.push(part);
|
parts.push(part);
|
||||||
|
|
||||||
if (part.shape.closed) {
|
if (part.shape.closed) {
|
||||||
|
Loading…
Reference in New Issue
Block a user