add render stats. remove dead code
This commit is contained in:
parent
99d34ae2de
commit
cf923c6b25
5 changed files with 28 additions and 113 deletions
|
|
@ -841,18 +841,11 @@
|
||||||
widget.setColor(color.slicing);
|
widget.setColor(color.slicing);
|
||||||
widget.slice(settings, function(sliced, error) {
|
widget.slice(settings, function(sliced, error) {
|
||||||
let mark = UTIL.time();
|
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
|
// update UI info
|
||||||
if (sliced) {
|
if (sliced) {
|
||||||
// update segment time
|
// update segment time
|
||||||
if (lastMsg) segtimes[segNumber+"_"+lastMsg] = mark - startTime;
|
if (lastMsg) segtimes[`${segNumber++}_${lastMsg}`] = mark - startTime;
|
||||||
segtimes.total = UTIL.time() - now;
|
segtimes.total = UTIL.time() - now;
|
||||||
DBUG.log(segtimes);
|
|
||||||
API.event.emit('slice', getMode());
|
API.event.emit('slice', getMode());
|
||||||
updateSliderMax(true);
|
updateSliderMax(true);
|
||||||
if (preserveMax != API.var.layer_max) {
|
if (preserveMax != API.var.layer_max) {
|
||||||
|
|
@ -860,12 +853,20 @@
|
||||||
}
|
}
|
||||||
firstMesh = false;
|
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
|
// on the last exit, update ui and call the callback
|
||||||
if (--countdown === 0 || error || errored) {
|
if (--countdown === 0 || error || errored) {
|
||||||
API.show.progress(0);
|
API.show.progress(0);
|
||||||
showSlices(preserveLayer);
|
showSlices(preserveLayer);
|
||||||
SPACE.scene.active();
|
SPACE.scene.active();
|
||||||
API.event.emit('slice.end', getMode());
|
API.event.emit('slice.end', getMode());
|
||||||
|
// print stats
|
||||||
|
DBUG.log(segtimes);
|
||||||
if (callback && typeof callback === 'function') {
|
if (callback && typeof callback === 'function') {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
@ -881,10 +882,9 @@
|
||||||
}, function(update, msg) {
|
}, function(update, msg) {
|
||||||
if (msg !== lastMsg) {
|
if (msg !== lastMsg) {
|
||||||
let mark = UTIL.time();
|
let mark = UTIL.time();
|
||||||
if (lastMsg) segtimes[segNumber+"_"+lastMsg] = mark - startTime;
|
if (lastMsg) segtimes[`${segNumber++}_${lastMsg}`] = mark - startTime;
|
||||||
lastMsg = msg;
|
lastMsg = msg;
|
||||||
startTime = mark;
|
startTime = mark;
|
||||||
segNumber++;
|
|
||||||
}
|
}
|
||||||
// on update
|
// on update
|
||||||
track[widget.id] = update;
|
track[widget.id] = update;
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,13 @@
|
||||||
constructor() {
|
constructor() {
|
||||||
this.layers = {};
|
this.layers = {};
|
||||||
this.profiles = {};
|
this.profiles = {};
|
||||||
|
this.stats = {
|
||||||
|
contour: 0,
|
||||||
|
flat_line: 0,
|
||||||
|
flat_poly: 0,
|
||||||
|
line_poly: 0,
|
||||||
|
line: 0
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
setLayer(layer, colors) {
|
setLayer(layer, colors) {
|
||||||
|
|
@ -53,6 +60,7 @@
|
||||||
}
|
}
|
||||||
for (let i=0; i<lines.length-1; i += 2) {
|
for (let i=0; i<lines.length-1; i += 2) {
|
||||||
this.addLine(lines[i], lines[i+1]);
|
this.addLine(lines[i], lines[i+1]);
|
||||||
|
this.stats.line++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,6 +77,7 @@
|
||||||
}
|
}
|
||||||
polys = flat(polys);
|
polys = flat(polys);
|
||||||
this.current.polys.appendAll(polys);
|
this.current.polys.appendAll(polys);
|
||||||
|
this.stats.line_poly += polys.length;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -103,9 +112,11 @@
|
||||||
let exp = off_opt.outs = [];
|
let exp = off_opt.outs = [];
|
||||||
if (open) {
|
if (open) {
|
||||||
exp.appendAll(POLY.expand_lines(poly, offset * 0.9, z));
|
exp.appendAll(POLY.expand_lines(poly, offset * 0.9, z));
|
||||||
|
this.stats.flat_line = 0;
|
||||||
} else {
|
} else {
|
||||||
POLY.offset([poly], offset * 0.9, off_opt);
|
POLY.offset([poly], offset * 0.9, off_opt);
|
||||||
POLY.offset([poly], -offset * 0.9, off_opt);
|
POLY.offset([poly], -offset * 0.9, off_opt);
|
||||||
|
this.stats.flat_poly = 0;
|
||||||
}
|
}
|
||||||
if (opts.outline) {
|
if (opts.outline) {
|
||||||
this.addPolys(exp.clone());
|
this.addPolys(exp.clone());
|
||||||
|
|
@ -145,6 +156,7 @@
|
||||||
});
|
});
|
||||||
const {index, faces} = ProfiledContourGeometry(profile, contour, poly.isClosed());
|
const {index, faces} = ProfiledContourGeometry(profile, contour, poly.isClosed());
|
||||||
this.current.paths.push({ index, faces, z: poly.getZ() });
|
this.current.paths.push({ index, faces, z: poly.getZ() });
|
||||||
|
this.stats.contour++;
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
if (self.kiri.Slice) return;
|
|
||||||
|
|
||||||
const KIRI = self.kiri,
|
const KIRI = self.kiri,
|
||||||
PRO = Slice.prototype,
|
PRO = Slice.prototype,
|
||||||
BASE = self.base,
|
BASE = self.base,
|
||||||
|
|
@ -14,8 +12,8 @@
|
||||||
NOKEY = BASE.key.NONE;
|
NOKEY = BASE.key.NONE;
|
||||||
|
|
||||||
KIRI.Top = Top;
|
KIRI.Top = Top;
|
||||||
KIRI.newTop = newTop;
|
|
||||||
KIRI.Slice = Slice;
|
KIRI.Slice = Slice;
|
||||||
|
KIRI.newTop = newTop;
|
||||||
KIRI.newSlice = newSlice;
|
KIRI.newSlice = newSlice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -156,24 +154,6 @@
|
||||||
return slice ? POLY.fingerprintCompare(this.fingerprint(), slice.fingerprint()) : false;
|
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) {
|
PRO.addTops = function(polys) {
|
||||||
polys.forEach(p => {
|
polys.forEach(p => {
|
||||||
this.addTop(p);
|
this.addTop(p);
|
||||||
|
|
@ -192,85 +172,6 @@
|
||||||
return top;
|
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) {
|
function newTop(poly) {
|
||||||
return new Top(poly);
|
return new Top(poly);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -594,7 +594,7 @@
|
||||||
return ondone(error);
|
return ondone(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
onupdate(1.0, "transferring");
|
onupdate(1.0, "transfer");
|
||||||
|
|
||||||
widget.stats.slice_time = UTIL.time() - startTime;
|
widget.stats.slice_time = UTIL.time() - startTime;
|
||||||
widget.modified = false;
|
widget.modified = false;
|
||||||
|
|
@ -627,9 +627,9 @@
|
||||||
* render all slice and processed data
|
* render all slice and processed data
|
||||||
*/
|
*/
|
||||||
PRO.render = function() {
|
PRO.render = function() {
|
||||||
let mark = Date.now();
|
const mark = Date.now();
|
||||||
DRIVERS[this.settings.mode.toUpperCase()].sliceRender(this);
|
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() {
|
PRO.hideSlices = function() {
|
||||||
|
|
|
||||||
|
|
@ -469,6 +469,8 @@
|
||||||
// .setLayer("flats", { face: 0xaa00aa, line: 0xaa00aa })
|
// .setLayer("flats", { face: 0xaa00aa, line: 0xaa00aa })
|
||||||
// .addAreas(top.flats);
|
// .addAreas(top.flats);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
// console.log(slice.index, slice.render.stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue