2nd attempt at simplifying poly.union -- update support help -- fix selected mesh info
This commit is contained in:
parent
b860062e63
commit
7ae240290c
4 changed files with 25 additions and 57 deletions
|
|
@ -1730,42 +1730,27 @@
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function leftmost(p1, p2) {
|
|
||||||
if (!p1) {
|
|
||||||
return p2;
|
|
||||||
}
|
|
||||||
if (p1.x <= p2.x) {
|
|
||||||
if (p1.x < p2.x || (p1.x === p2.x && p1.y < p2.y)) {
|
|
||||||
return p2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return p1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// return top-most, left-post point
|
|
||||||
PRO.leftmost = function() {
|
|
||||||
let tl = undefined;
|
|
||||||
for (let p of this.points) {
|
|
||||||
tl = leftmost(tl, p);
|
|
||||||
}
|
|
||||||
return tl;
|
|
||||||
};
|
|
||||||
|
|
||||||
PRO.areaDiff = function(poly) {
|
PRO.areaDiff = function(poly) {
|
||||||
let a1 = this.area(),
|
let a1 = this.area(),
|
||||||
a2 = poly.area();
|
a2 = poly.area();
|
||||||
return (a1 > a2) ? a2 / a1 : a1 / a2;
|
return (a1 > a2) ? a2 / a1 : a1 / a2;
|
||||||
};
|
};
|
||||||
|
|
||||||
PRO.areaOrLength = function(poly) {
|
PRO.unionMatch = function(polys) {
|
||||||
return this.length === poly.length || this.areaDiff(poly) > 0.98;
|
return polys.filter(poly => poly.isEquivalent(this)).length;
|
||||||
|
// for (let poly of polys) {
|
||||||
|
// if (this.isEquivalent(poly)) {
|
||||||
|
// return true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return logical OR of two polygons' enclosed areas
|
* return logical OR of two polygons' enclosed areas
|
||||||
*
|
*
|
||||||
* @param {Polygon} poly
|
* @param {Polygon} poly
|
||||||
* @returns {?Polygon} intersected polygon or null if no intersection
|
* @returns {?Polygon} intersected polygon, null if no intersection, or all when indicated
|
||||||
*/
|
*/
|
||||||
PRO.union = function(poly, min, all) {
|
PRO.union = function(poly, min, all) {
|
||||||
if (!this.overlaps(poly)) return null;
|
if (!this.overlaps(poly)) return null;
|
||||||
|
|
@ -1788,33 +1773,10 @@
|
||||||
let union = POLY().fromClipperTreeUnion(ctre, poly.getZ(), minarea);
|
let union = POLY().fromClipperTreeUnion(ctre, poly.getZ(), minarea);
|
||||||
if (all) {
|
if (all) {
|
||||||
if (union.length === 2) {
|
if (union.length === 2) {
|
||||||
let src = [ this.leftmost(), poly.leftmost() ];
|
|
||||||
let dst = [ union[0].leftmost(), union[1].leftmost() ];
|
|
||||||
|
|
||||||
if (leftmost(src[0], src[1]) === src[1]) {
|
|
||||||
src.reverse();
|
|
||||||
}
|
|
||||||
if (leftmost(dst[0], dst[1]) === dst[1]) {
|
|
||||||
dst.reverse();
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
src[0].poly && src[1].poly && // missing for cam tabs
|
|
||||||
src[0].isEqual2D(dst[0]) &&
|
|
||||||
src[1].isEqual2D(dst[1]) &&
|
|
||||||
src[0].poly.areaOrLength(dst[0].poly) &&
|
|
||||||
src[1].poly.areaOrLength(dst[1].poly)
|
|
||||||
) {
|
|
||||||
return null;
|
return null;
|
||||||
// } else {
|
// if (this.unionMatch(union) || poly.unionMatch(union)) {
|
||||||
// console.log("union debug", {
|
// return null;
|
||||||
// src,
|
// }
|
||||||
// dst,
|
|
||||||
// d0: src[0].poly.areaDiff(dst[0].poly),
|
|
||||||
// d1: src[1].poly.areaDiff(dst[1].poly),
|
|
||||||
// m0: src[0].isEqual2D(dst[0]),
|
|
||||||
// m1: src[1].isEqual2D(dst[1])
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return union;
|
return union;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1954,9 +1954,9 @@
|
||||||
name = name.substring(sp + 1);
|
name = name.substring(sp + 1);
|
||||||
}
|
}
|
||||||
UI.mesh.name.innerText = name;
|
UI.mesh.name.innerText = name;
|
||||||
|
}
|
||||||
UI.mesh.points.innerText = sel.meta.vertices;
|
UI.mesh.points.innerText = sel.meta.vertices;
|
||||||
UI.mesh.faces.innerText = sel.meta.vertices / 3;
|
UI.mesh.faces.innerText = sel.meta.vertices / 3;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
UI.mesh.name.innerText = `[${selcount}]`;
|
UI.mesh.name.innerText = `[${selcount}]`;
|
||||||
UI.mesh.points.innerText = '-';
|
UI.mesh.points.innerText = '-';
|
||||||
|
|
|
||||||
|
|
@ -1664,14 +1664,19 @@
|
||||||
}
|
}
|
||||||
let groups = coplane.group(true);
|
let groups = coplane.group(true);
|
||||||
// console.log({v3cache, coplane, groups});
|
// console.log({v3cache, coplane, groups});
|
||||||
|
// let ptotl = Object.values(groups).flat().flat().length;
|
||||||
|
// console.log({ptotl});
|
||||||
|
// let pdone = 0;
|
||||||
for (let group of Object.values(groups)) {
|
for (let group of Object.values(groups)) {
|
||||||
for (let polys of group) {
|
for (let polys of group) {
|
||||||
for (let poly of polys) {
|
for (let poly of polys) {
|
||||||
if (poly.area() >= process.sliceSupportArea)
|
if (poly.area() >= process.sliceSupportArea)
|
||||||
tP(poly, polys.face);
|
tP(poly, polys.face);
|
||||||
|
// console.log(++pdone / ptotl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
widget.supports = add;
|
widget.supports = add;
|
||||||
return add.length > 0;
|
return add.length > 0;
|
||||||
};
|
};
|
||||||
|
|
@ -1742,7 +1747,8 @@
|
||||||
.add(arr[1].x, arr[1].y, arr[1].z)
|
.add(arr[1].x, arr[1].y, arr[1].z)
|
||||||
.add(arr[2].x, arr[2].y, arr[2].z);
|
.add(arr[2].x, arr[2].y, arr[2].z);
|
||||||
});
|
});
|
||||||
let union = POLY.union(parr, 0, true, {wasm:true});
|
let union = parr.length === 1 ? parr :
|
||||||
|
POLY.union(parr, 0, true, {wasm:false});
|
||||||
union.merged = parr.length;
|
union.merged = parr.length;
|
||||||
union.face = group[0];
|
union.face = group[0];
|
||||||
return union;
|
return union;
|
||||||
|
|
|
||||||
|
|
@ -381,7 +381,7 @@ kiri.lang['en-us'] = {
|
||||||
sp_dens_s: "density",
|
sp_dens_s: "density",
|
||||||
sp_dens_l: ["fraction 0.0 - 1.0","recommended 0.15","0 to disable"],
|
sp_dens_l: ["fraction 0.0 - 1.0","recommended 0.15","0 to disable"],
|
||||||
sp_size_s: "pillar size",
|
sp_size_s: "pillar size",
|
||||||
sp_size_l: ["pillar width","in millimeters"],
|
sp_size_l: ["pillar width in millimeters","smaller values exponentially","increase detection times"],
|
||||||
sp_offs_s: "part offset",
|
sp_offs_s: "part offset",
|
||||||
sp_offs_l: ["offset from part","in millimeters"],
|
sp_offs_l: ["offset from part","in millimeters"],
|
||||||
sp_gaps_s: "gap layers",
|
sp_gaps_s: "gap layers",
|
||||||
|
|
@ -389,9 +389,9 @@ kiri.lang['en-us'] = {
|
||||||
sp_span_s: "max span",
|
sp_span_s: "max span",
|
||||||
sp_span_l: ["unsupported span that causes","a new support to be generated","in millimeters"],
|
sp_span_l: ["unsupported span that causes","a new support to be generated","in millimeters"],
|
||||||
sp_angl_s: "max angle",
|
sp_angl_s: "max angle",
|
||||||
sp_angl_l: ["max overhang angle before","supporting pillar is generated"],
|
sp_angl_l: ["max overhang angle before","supporting pillar is generated","normal values 45-60","belt values 0-10"],
|
||||||
sp_area_s: "min area",
|
sp_area_s: "min area",
|
||||||
sp_area_l: ["minimum area for","a support column","in millimeters"],
|
sp_area_l: ["minimum area for","a support column","in millimeters","smaller values will","slow detection"],
|
||||||
sp_xpnd_s: "expand",
|
sp_xpnd_s: "expand",
|
||||||
sp_xpnd_l: ["expand support area","beyond part boundary","in millimeters"],
|
sp_xpnd_l: ["expand support area","beyond part boundary","in millimeters"],
|
||||||
sp_nozl_s: "extruder",
|
sp_nozl_s: "extruder",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue