tweaks to xray, debug. add poly dep to mesh for topo mod
This commit is contained in:
parent
bc5e3eda24
commit
f233bc2768
9 changed files with 47 additions and 9 deletions
|
|
@ -1597,18 +1597,17 @@ class Polygon {
|
|||
* @param {Polygon} poly clipping mask
|
||||
* @returns {?Polygon[]}
|
||||
*/
|
||||
mask(poly, nullOnEquiv) {
|
||||
mask(poly, nullOnEquiv, minarea) {
|
||||
let fillang = this.fillang && this.area() > poly.area() ? this.fillang : poly.fillang,
|
||||
clip = new clib.Clipper(),
|
||||
ctre = new clib.PolyTree(),
|
||||
sp1 = this.toClipper(),
|
||||
sp2 = poly.toClipper();
|
||||
|
||||
clip.AddPaths(sp1, ptyp.ptSubject, true);
|
||||
clip.AddPaths(sp2, ptyp.ptClip, true);
|
||||
|
||||
if (clip.Execute(ctyp.ctIntersection, ctre, cfil.pftEvenOdd, cfil.pftEvenOdd)) {
|
||||
poly = POLY.fromClipperTree(ctre, poly.getZ());
|
||||
poly = POLY.fromClipperTree(ctre, this.getZ(), undefined, undefined, minarea);
|
||||
poly.forEach(p => {
|
||||
p.fillang = fillang;
|
||||
})
|
||||
|
|
@ -1779,6 +1778,29 @@ class Polygon {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
annotate(obj = {}) {
|
||||
Object.assign(this, obj);
|
||||
return this;
|
||||
}
|
||||
|
||||
extrude(z = 1) {
|
||||
let poly = this.clone().setClockwise();
|
||||
let faces = [];
|
||||
let points = poly.points;
|
||||
let length = points.length;
|
||||
for (let i=0; i<length; i++) {
|
||||
let p0 = points[i];
|
||||
let p1 = points[(i + 1) % length];
|
||||
faces.push(p0.x, p0.y, p0.z);
|
||||
faces.push(p1.x, p1.y, p0.z);
|
||||
faces.push(p1.x, p1.y, p1.z + z);
|
||||
faces.push(p0.x, p0.y, p0.z);
|
||||
faces.push(p1.x, p1.y, p1.z + z);
|
||||
faces.push(p0.x, p0.y, p0.z + z);
|
||||
}
|
||||
return faces;
|
||||
}
|
||||
}
|
||||
|
||||
// use Slope.angleDiff() then re-test path mitering / rendering
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
// use: ext.clip2
|
||||
// use: geo.slope
|
||||
// use: geo.polygon
|
||||
gapp.register("base.polygons", [], (root, exports) => {
|
||||
gapp.register("geo.polygons", [], (root, exports) => {
|
||||
|
||||
const { base } = root;
|
||||
const { util, config, newPoint } = base;
|
||||
|
|
@ -388,7 +388,7 @@ function subtract(setA, setB, outA, outB, z, minArea, opt = {}) {
|
|||
}
|
||||
}
|
||||
|
||||
let out = polys.slice(), i, j, union, uset = [];
|
||||
let out = polys.slice(), i, j, union, uset = [], a, b;
|
||||
|
||||
outer: for (i=0; i<out.length; i++) {
|
||||
if (!out[i]) continue;
|
||||
|
|
@ -396,6 +396,10 @@ function subtract(setA, setB, outA, outB, z, minArea, opt = {}) {
|
|||
if (!out[j]) continue;
|
||||
union = out[i].union(out[j], minarea, all);
|
||||
if (union && union.length) {
|
||||
if (opt.onmerge) {
|
||||
a = out[i];
|
||||
b = out[j];
|
||||
}
|
||||
out[i] = null;
|
||||
out[j] = null;
|
||||
if (all) {
|
||||
|
|
@ -403,6 +407,9 @@ function subtract(setA, setB, outA, outB, z, minArea, opt = {}) {
|
|||
} else {
|
||||
out.push(union);
|
||||
}
|
||||
if (opt.onmerge) {
|
||||
opt.onmerge(a, b, union);
|
||||
}
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue