add render stats. remove dead code

This commit is contained in:
Stewart Allen 2020-11-07 19:57:11 -05:00
commit cf923c6b25
5 changed files with 28 additions and 113 deletions

View file

@ -841,18 +841,11 @@
widget.setColor(color.slicing);
widget.slice(settings, function(sliced, error) {
let mark = UTIL.time();
// on done
widget.render();
// clear wireframe
widget.setWireframe(false, color.wireframe, color.wireframe_opacity);
widget.setOpacity(camOrLaser ? color.cam_sliced_opacity : color.sliced_opacity);
widget.setColor(color.deselected);
// update UI info
if (sliced) {
// update segment time
if (lastMsg) segtimes[segNumber+"_"+lastMsg] = mark - startTime;
if (lastMsg) segtimes[`${segNumber++}_${lastMsg}`] = mark - startTime;
segtimes.total = UTIL.time() - now;
DBUG.log(segtimes);
API.event.emit('slice', getMode());
updateSliderMax(true);
if (preserveMax != API.var.layer_max) {
@ -860,12 +853,20 @@
}
firstMesh = false;
}
// on done
segtimes[`${segNumber}_draw`] = widget.render();
// clear wireframe
widget.setWireframe(false, color.wireframe, color.wireframe_opacity);
widget.setOpacity(camOrLaser ? color.cam_sliced_opacity : color.sliced_opacity);
widget.setColor(color.deselected);
// on the last exit, update ui and call the callback
if (--countdown === 0 || error || errored) {
API.show.progress(0);
showSlices(preserveLayer);
SPACE.scene.active();
API.event.emit('slice.end', getMode());
// print stats
DBUG.log(segtimes);
if (callback && typeof callback === 'function') {
callback();
}
@ -881,10 +882,9 @@
}, function(update, msg) {
if (msg !== lastMsg) {
let mark = UTIL.time();
if (lastMsg) segtimes[segNumber+"_"+lastMsg] = mark - startTime;
if (lastMsg) segtimes[`${segNumber++}_${lastMsg}`] = mark - startTime;
lastMsg = msg;
startTime = mark;
segNumber++;
}
// on update
track[widget.id] = update;

View file

@ -9,6 +9,13 @@
constructor() {
this.layers = {};
this.profiles = {};
this.stats = {
contour: 0,
flat_line: 0,
flat_poly: 0,
line_poly: 0,
line: 0
};
}
setLayer(layer, colors) {
@ -53,6 +60,7 @@
}
for (let i=0; i<lines.length-1; i += 2) {
this.addLine(lines[i], lines[i+1]);
this.stats.line++;
}
}
@ -69,6 +77,7 @@
}
polys = flat(polys);
this.current.polys.appendAll(polys);
this.stats.line_poly += polys.length;
return this;
}
@ -103,9 +112,11 @@
let exp = off_opt.outs = [];
if (open) {
exp.appendAll(POLY.expand_lines(poly, offset * 0.9, z));
this.stats.flat_line = 0;
} else {
POLY.offset([poly], offset * 0.9, off_opt);
POLY.offset([poly], -offset * 0.9, off_opt);
this.stats.flat_poly = 0;
}
if (opts.outline) {
this.addPolys(exp.clone());
@ -145,6 +156,7 @@
});
const {index, faces} = ProfiledContourGeometry(profile, contour, poly.isClosed());
this.current.paths.push({ index, faces, z: poly.getZ() });
this.stats.contour++;
});
return this;
}

View file

@ -4,8 +4,6 @@
(function() {
if (self.kiri.Slice) return;
const KIRI = self.kiri,
PRO = Slice.prototype,
BASE = self.base,
@ -14,8 +12,8 @@
NOKEY = BASE.key.NONE;
KIRI.Top = Top;
KIRI.newTop = newTop;
KIRI.Slice = Slice;
KIRI.newTop = newTop;
KIRI.newSlice = newSlice;
/**
@ -156,24 +154,6 @@
return slice ? POLY.fingerprintCompare(this.fingerprint(), slice.fingerprint()) : false;
};
/**
* Add a polygon to a slice creating a new top when necessary.
*
* @param {Polygon} poly to merge into a top
*/
// PRO.mergeTop = function(poly) {
// let slice = this,
// tops = slice.tops,
// union, i;
// for (i=0; i<tops.length; i++) {
// if (union = poly.union(tops[i].poly)) {
// tops[i].poly = union;
// return tops[i];
// }
// }
// return slice.addTop(poly);
// };
PRO.addTops = function(polys) {
polys.forEach(p => {
this.addTop(p);
@ -192,85 +172,6 @@
return top;
};
/**
* Returns all top polygons as an array
*
* @param {Polygon[]} out array to populate
* @returns {Polygon[]} array of top polygons
*/
// PRO.gatherTopPolys = function(out) {
// this.tops.forEach(function(top) {
// out.push(top.poly);
// });
// return out;
// };
/**
* Appends all inner trace inner polygons (holes)
* into a given array and returns it
*
* @param {Polygon[]} out array to populate
* @returns {Polygon[]} array of top polygons
*/
// PRO.gatherTopPolyInners = function(out) {
// this.tops.forEach(function(top) {
// if (top.poly.inner) out.appendAll(top.poly.inner);
// });
// return out;
// };
/**
* Appends all trace polygons into a given array and returns it
*
* @param {Polygon[]} out array to populate
* @returns {Polygon[]} array of top polygons
*/
// PRO.gatherTraces = function(out) {
// this.tops.forEach(function(top) {
// out.appendAll(top.traces);
// });
// return out;
// };
/**
* Appends all innermost trace polygons into a given array and returns it
*
* @param {Polygon[]} out array to populate
* @returns {Polygon[]} array of top polygons
*/
// PRO.gatherInner = function(out) {
// this.tops.forEach(function(top) {
// out.appendAll(top.inner);
// });
// return out;
// };
/**
* Appends all solid area polygons into a given array and returns it
*
* @param {Polygon[]} out array to populate
* @returns {Polygon[]} array of top polygons
*/
// PRO.gatherSolids = function(out) {
// this.tops.forEach(function(top) {
// out.appendAll(top.solids);
// });
// return out;
// };
/**
* return all fill lines. includes points for solid layers,
* solid polygon regions and support line polygons.
*
* @param {Point[]} [lines] array to append to
*/
// PRO.gatherFillLines = function(lines) {
// this.tops.forEach(function(top) {
// if (top.fill_lines) lines.appendAll(top.fill_lines);
// });
// return lines;
// };
function newTop(poly) {
return new Top(poly);
}

View file

@ -594,7 +594,7 @@
return ondone(error);
}
onupdate(1.0, "transferring");
onupdate(1.0, "transfer");
widget.stats.slice_time = UTIL.time() - startTime;
widget.modified = false;
@ -627,9 +627,9 @@
* render all slice and processed data
*/
PRO.render = function() {
let mark = Date.now();
const mark = Date.now();
DRIVERS[this.settings.mode.toUpperCase()].sliceRender(this);
if (KIRI.api.const.LOCAL) console.log({sliceRender: Date.now() - mark});
return Date.now() - mark;
};
PRO.hideSlices = function() {

View file

@ -469,6 +469,8 @@
// .setLayer("flats", { face: 0xaa00aa, line: 0xaa00aa })
// .addAreas(top.flats);
// }
// console.log(slice.index, slice.render.stats);
}
/**