heal polys before tracing
This commit is contained in:
parent
2923a0bd88
commit
208a2f2b0c
3 changed files with 16 additions and 3 deletions
1
notes.md
1
notes.md
|
|
@ -54,7 +54,6 @@
|
|||
# CAM
|
||||
|
||||
* `B` trace clear and follow need depth-first support
|
||||
* `B` trace follow open polys should "heal" if ends touch
|
||||
* `B` trace open polys are not wound consistently
|
||||
* `B` path routing with tabs sometimes makes no sense
|
||||
* `B` clicking on a pop-op should pin it until clicked or [esc]
|
||||
|
|
|
|||
|
|
@ -685,7 +685,7 @@
|
|||
let { op, state } = this;
|
||||
let { tool, rate, down, plunge, offset } = op;
|
||||
let { settings, widget, sliceAll, zMax, tabs } = state;
|
||||
let { updateToolDiams, cutTabs, cutPolys } = state;
|
||||
let { updateToolDiams, cutTabs, cutPolys, healPolys } = state;
|
||||
let { process, stock } = settings;
|
||||
// generate tracing offsets from chosen features
|
||||
let sliceOut = this.sliceOut = [];
|
||||
|
|
@ -744,6 +744,8 @@
|
|||
.setLayer("clear", {line: 0xaa00aa}, false)
|
||||
.addPolys(slice.camLines)
|
||||
}
|
||||
// connect selected segments if open and touching
|
||||
polys = healPolys(polys);
|
||||
switch (op.mode) {
|
||||
case "follow":
|
||||
for (let poly of polys) {
|
||||
|
|
|
|||
|
|
@ -106,6 +106,7 @@
|
|||
tabs,
|
||||
cutTabs,
|
||||
cutPolys,
|
||||
healPolys,
|
||||
slicer,
|
||||
sliceAll,
|
||||
updateToolDiams,
|
||||
|
|
@ -273,8 +274,11 @@
|
|||
|
||||
function cutPolys(polys, offset, z, inter) {
|
||||
let noff = [];
|
||||
// tabs = tabs.filter(tab => z < tab.pos.z + tab.dim.z/2).map(tab => tab.off).flat();
|
||||
offset.forEach(op => noff.appendAll( op.cut(POLY.union(polys, 0, true), inter) ));
|
||||
return healPolys(noff);
|
||||
}
|
||||
|
||||
function healPolys(noff) {
|
||||
if (noff.length > 1) {
|
||||
let heal = 0;
|
||||
// heal/rejoin open segments that share endpoints
|
||||
|
|
@ -317,6 +321,14 @@
|
|||
// cull nulls
|
||||
noff = noff.filter(o => o);
|
||||
}
|
||||
// close poly if head meets tail
|
||||
for (let poly of noff) {
|
||||
if (poly.open && poly.first().isMergable2D(poly.last())) {
|
||||
poly.points.pop();
|
||||
poly.length--;
|
||||
poly.open = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return noff;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue