add progress reporting

This commit is contained in:
Simon Voordouw 2017-07-04 14:19:07 +02:00
parent 1f206e5784
commit dc99f417da
2 changed files with 28 additions and 2 deletions

View File

@ -47,6 +47,11 @@ export default class {
resolve(data.gcode);
break;
}
case 'PROGRESS': {
if (this.onprogress) {
this.onprogress(data);
}
}
}
});

View File

@ -13,32 +13,53 @@ import applyPrecision from './applyPrecision.js';
import removePrecision from './removePrecision.js';
export default function(geometry, settings) {
geometry.mergeVertices();
geometry.computeFaceNormals();
const totalStages = 15;
let current = 0;
const progressMessage = () => {
current++;
postMessage({ message: 'PROGRESS', data: { done: current, total: totalStages } });
};
geometry.mergeVertices();
progressMessage();
geometry.computeFaceNormals();
progressMessage();
// get unique lines from geometry;
const openClosed = detectOpenClosed(geometry);
progressMessage();
const lines = createLines(geometry, settings, openClosed);
progressMessage();
const {
layerIntersectionIndexes,
layerIntersectionPoints
} = calculateLayersIntersections(lines, settings);
progressMessage();
const shapes = intersectionsToShapes(layerIntersectionIndexes, layerIntersectionPoints, lines, settings);
progressMessage();
applyPrecision(shapes);
progressMessage();
const slices = shapesToSlices(shapes, settings);
progressMessage();
generateInnerLines(slices, settings);
progressMessage();
generateInfills(slices, settings);
progressMessage();
generateSupport(slices, settings);
progressMessage();
addBrim(slices, settings);
progressMessage();
optimizePaths(slices, settings);
progressMessage();
removePrecision(slices);
progressMessage();
const gcode = slicesToGCode(slices, settings);
progressMessage();
return gcode;
}