improve slicing precision. add disabled slicer debugging
This commit is contained in:
parent
d252b7d1f6
commit
8f56f8bb96
5 changed files with 46 additions and 46 deletions
|
|
@ -333,7 +333,7 @@
|
|||
// isCloseTo() default for dist
|
||||
// sliceIntersects point merge dist for non-fill
|
||||
precision_merge : 0.005,
|
||||
precision_slice_z : 0.005,
|
||||
precision_slice_z : 0.0001,
|
||||
// Point.isInPolygon nearPolygon value
|
||||
// Point.isInPolygonNotNear nearPolygon value
|
||||
// Point.isMergable2D distToSq2D value
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@
|
|||
};
|
||||
|
||||
PRO.xray = function(dash = 3) {
|
||||
console.log('xray', this);
|
||||
// console.log('xray', this);
|
||||
this.output().setLayer(`xp`, 0x888800).addPolys(this.topPolys());
|
||||
this.lines.forEach((line, i) => {
|
||||
const group = i % dash;
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@
|
|||
const zList = this.zList;
|
||||
|
||||
function countZ(z) {
|
||||
z = UTIL.round(z,5);
|
||||
z = z.round(5);
|
||||
zList[z] = (zList[z] || 0) + 1;
|
||||
}
|
||||
|
||||
|
|
@ -116,35 +116,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (opt.trace) {
|
||||
this.findTraceLines();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// find slice candidates to trace for CNC ballmills and tapermills
|
||||
findTraceLines() {
|
||||
let zl = {};
|
||||
let le;
|
||||
let zs = Object.entries(this.zLine).map(oe => {
|
||||
return oe.map(v => parseFloat(v));
|
||||
}).sort((a,b) => {
|
||||
return b[0] - a[0];
|
||||
}).forEach((e,i) => {
|
||||
if (i > 0) {
|
||||
let zd = le[0]-e[0];
|
||||
if (zd > 0.1 && e[1] > 100) {
|
||||
// zl.push(e)
|
||||
zl[e[0].toFixed(5)] = e[1];
|
||||
zFlat[e[0].toFixed(5)] = e[1];
|
||||
}
|
||||
}
|
||||
if (e[1] > 10) {
|
||||
le = e;
|
||||
}
|
||||
});
|
||||
this.zLine = zl;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -264,8 +235,9 @@
|
|||
let retn = { z };
|
||||
|
||||
if (lines.length) {
|
||||
retn.lines = removeDuplicateLines(lines);
|
||||
retn.tops = POLY.nest(connectLines(retn.lines, opt));
|
||||
const debug = false;
|
||||
retn.lines = removeDuplicateLines(lines, debug);
|
||||
retn.tops = POLY.nest(connectLines(retn.lines, opt, debug));
|
||||
|
||||
if (opt.swapX || opt.swapY) {
|
||||
this.unswap(opt.swapX, opt.swapY, retn.lines, retn.tops);
|
||||
|
|
@ -420,7 +392,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
return array.map(v => Math.abs(parseFloat(v.toFixed(2))));
|
||||
return array.map(v => Math.abs(parseFloat(v.toFixed(5))));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -506,10 +478,9 @@
|
|||
* @param {number} [index]
|
||||
* @returns {Array}
|
||||
*/
|
||||
function connectLines(input, opt = {}) {
|
||||
function connectLines(input, opt = {}, debug) {
|
||||
// map points to all other points they're connected to
|
||||
let DBUG = BASE.debug,
|
||||
CONF = BASE.config,
|
||||
let CONF = BASE.config,
|
||||
pmap = {},
|
||||
points = [],
|
||||
output = [],
|
||||
|
|
@ -552,7 +523,7 @@
|
|||
function findPathsMinRecurse(point, path, paths, from) {
|
||||
let stack = [ ];
|
||||
if (paths.length > 10000) {
|
||||
DBUG.log("excessive path options @ "+paths.length+" #"+input.length);
|
||||
console.log("excessive path options @ "+paths.length+" #"+input.length);
|
||||
return;
|
||||
}
|
||||
for (;;) {
|
||||
|
|
@ -661,10 +632,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (debug) console.log('map', input);
|
||||
|
||||
// create point map, unique point list and point group arrays
|
||||
input.forEach(function(line) {
|
||||
p1 = cachedPoint(line.p1.round(4));
|
||||
p2 = cachedPoint(line.p2.round(4));
|
||||
p1 = cachedPoint(line.p1.round(5));
|
||||
p2 = cachedPoint(line.p2.round(5));
|
||||
addConnected(p1,p2);
|
||||
addConnected(p2,p1);
|
||||
});
|
||||
|
|
@ -676,6 +649,7 @@
|
|||
let path = [],
|
||||
paths = [];
|
||||
findPathsMinRecurse(point, path, paths);
|
||||
if (debug) console.log('dangle', {point, path, paths});
|
||||
if (paths.length > 0) emitLongestAsPolygon(paths);
|
||||
}
|
||||
});
|
||||
|
|
@ -767,7 +741,7 @@
|
|||
* @param {Line[]} lines
|
||||
* @returns {Line[]}
|
||||
*/
|
||||
function removeDuplicateLines(lines) {
|
||||
function removeDuplicateLines(lines, debug) {
|
||||
let output = [],
|
||||
tmplines = [],
|
||||
points = [],
|
||||
|
|
@ -792,6 +766,9 @@
|
|||
if (l1.key === l2.key) {
|
||||
l1.del = !l1.edge;
|
||||
l2.del = !l2.edge;
|
||||
if (debug && (l1.del || l2.del)) {
|
||||
console.log('dup', l1, l2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return l1.key < l2.key ? -1 : 1;
|
||||
|
|
|
|||
|
|
@ -300,6 +300,7 @@
|
|||
widget.adds.removeAll(widget.trace_stack.meshes);
|
||||
}
|
||||
});
|
||||
toolInfo.style.display = '';
|
||||
});
|
||||
api.event.on("cam.trace.clear", func.traceClear = () => {
|
||||
func.traceDone();
|
||||
|
|
|
|||
|
|
@ -130,14 +130,36 @@
|
|||
onupdate((opSum/opsTot) + (index/total) * opTot, msg || opOn[0]);
|
||||
}
|
||||
|
||||
// TODO pass widget.isModified() on slice and re-use cache if false
|
||||
// TODO pre-slice in background from client signal
|
||||
// TODO same applies to topo map generation
|
||||
nextOp();
|
||||
let mark = Date.now();
|
||||
let slicer = new KIRI.slicer2(widget.getPoints(), {
|
||||
zlist: true,
|
||||
zline: true
|
||||
});
|
||||
|
||||
// xray debug
|
||||
if (false) {
|
||||
console.log({slicer_setup: Date.now() - mark});
|
||||
let xlicer = new KIRI.slicer2(widget.getPoints(), {
|
||||
zlist: true,
|
||||
zline: true
|
||||
});
|
||||
let xrayind = Object.keys(xlicer.zLine)
|
||||
.map(v => parseFloat(v).round(5))
|
||||
.sort((a,b) => a-b);
|
||||
let xrayopt = { each: (data, index, total) => {
|
||||
let slice = newSlice(data.z);
|
||||
slice.addTops(data.tops);
|
||||
// data.tops.forEach(top => slice.addTop(top));
|
||||
slice.lines = data.lines;
|
||||
slice.xray();
|
||||
sliceAll.push(slice);
|
||||
}, over: false, flatoff: 0, edges: true, openok: true };
|
||||
xlicer.slice(xrayind, xrayopt);
|
||||
// xrayopt.over = true;
|
||||
// slicer.slice(xrayind, xrayopt);
|
||||
}
|
||||
|
||||
nextOp();
|
||||
let tslices = [];
|
||||
let tshadow = [];
|
||||
let tzindex = slicer.interval(minStepDown, { fit: true, off: 0.01, down: true, flats: true });
|
||||
|
|
|
|||
Loading…
Reference in a new issue