properly calculate if frags and forks exist
This commit is contained in:
parent
39f6b87dea
commit
28b83a75e1
1 changed files with 7 additions and 9 deletions
|
|
@ -580,9 +580,6 @@
|
||||||
function addConnected(p1, p2) {
|
function addConnected(p1, p2) {
|
||||||
if (!p1.group) p1.group = [ p2 ];
|
if (!p1.group) p1.group = [ p2 ];
|
||||||
else p1.group.push(p2);
|
else p1.group.push(p2);
|
||||||
gl = p1.group.length;
|
|
||||||
forks = forks || gl > 2;
|
|
||||||
frays = frays || gl < 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function perimeter(array) {
|
function perimeter(array) {
|
||||||
|
|
@ -686,6 +683,13 @@
|
||||||
// console.log({points, forks: points.filter(p => p.group.length !== 2)});
|
// console.log({points, forks: points.filter(p => p.group.length !== 2)});
|
||||||
// for each unused point, find the longest non-intersecting path
|
// for each unused point, find the longest non-intersecting path
|
||||||
|
|
||||||
|
for (let point of points) {
|
||||||
|
gl = point.group.length;
|
||||||
|
forks = forks || gl > 2;
|
||||||
|
frays = frays || gl < 2;
|
||||||
|
}
|
||||||
|
// if (debug && (forks || frays)) console.log({forks, frays});
|
||||||
|
|
||||||
// process paths starting with forks
|
// process paths starting with forks
|
||||||
if (forks)
|
if (forks)
|
||||||
for (let point of points) {
|
for (let point of points) {
|
||||||
|
|
@ -723,9 +727,6 @@
|
||||||
|
|
||||||
if (debug && connect.length) console.log({connect});
|
if (debug && connect.length) console.log({connect});
|
||||||
|
|
||||||
// ensure perimeters are seeded
|
|
||||||
connect.forEach(a => perimeter(a));
|
|
||||||
|
|
||||||
// progressively connect open polygons within a bridge distance
|
// progressively connect open polygons within a bridge distance
|
||||||
let iter = 1000;
|
let iter = 1000;
|
||||||
let mingap;
|
let mingap;
|
||||||
|
|
@ -799,14 +800,12 @@
|
||||||
reverse.reverse();
|
reverse.reverse();
|
||||||
}
|
}
|
||||||
if (swap) {
|
if (swap) {
|
||||||
next.perimeter += root.perimeter;
|
|
||||||
next.appendAll(root);
|
next.appendAll(root);
|
||||||
connect[i] = next;
|
connect[i] = next;
|
||||||
connect[swap] = root;
|
connect[swap] = root;
|
||||||
root.delete = true;
|
root.delete = true;
|
||||||
next.merged = true;
|
next.merged = true;
|
||||||
} else {
|
} else {
|
||||||
root.perimeter += next.perimeter;
|
|
||||||
root.appendAll(next);
|
root.appendAll(next);
|
||||||
next.delete = true;
|
next.delete = true;
|
||||||
root.merged = true;
|
root.merged = true;
|
||||||
|
|
@ -842,7 +841,6 @@
|
||||||
emit(BASE.newPolygon().addPoints(array));
|
emit(BASE.newPolygon().addPoints(array));
|
||||||
} else {
|
} else {
|
||||||
// tail meets head (far)
|
// tail meets head (far)
|
||||||
// console.log({dist});
|
|
||||||
emit(BASE.newPolygon().addPoints(array)
|
emit(BASE.newPolygon().addPoints(array)
|
||||||
// .setOpen()
|
// .setOpen()
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue