Merge branch 'rel-4.0' into dev-4.0-refactor-mesh
This commit is contained in:
commit
19e50b2635
4 changed files with 58 additions and 20 deletions
|
|
@ -323,12 +323,11 @@ function setContains(setA, poly) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function flatten(polys, to, crush) {
|
function flatten(polys, to = [], crush) {
|
||||||
to = to || [];
|
for (let poly of polys) {
|
||||||
polys.forEach(function(poly) {
|
|
||||||
poly.flattenTo(to);
|
poly.flattenTo(to);
|
||||||
if (crush) poly.inner = null;
|
if (crush) poly.inner = null;
|
||||||
});
|
}
|
||||||
return to;
|
return to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -990,18 +989,36 @@ function rayIntersect(start, slope, polygons, for_fill) {
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pd(a,b) {
|
||||||
|
return a > b ? Math.abs(1-b/a) : Math.abs(1-a/b);
|
||||||
|
}
|
||||||
|
|
||||||
function fingerprint(polys) {
|
function fingerprint(polys) {
|
||||||
let finger = [];
|
let recs = flatten(polys).map(p => {
|
||||||
flatten(polys).sort((a,b) => {
|
return {
|
||||||
return a.area() > b.area();
|
l: p.length,
|
||||||
}).forEach(p => {
|
a: p.area(),
|
||||||
finger.push({
|
p: p.perimeter(),
|
||||||
c: p.circularityDeep(),
|
c: p.circularity(),
|
||||||
p: p.perimeterDeep(),
|
|
||||||
b: p.bounds
|
b: p.bounds
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
return finger;
|
recs.sort((a,b) => {
|
||||||
|
if (pd(a.a, b.a) > 0.005) {
|
||||||
|
return b.a - a.a;
|
||||||
|
}
|
||||||
|
if (pd(a.p, b.p) > 0.005) {
|
||||||
|
return b.p - a.p;
|
||||||
|
}
|
||||||
|
if (pd(a.c, b.c) > 0.02) {
|
||||||
|
return b.c - a.c;
|
||||||
|
}
|
||||||
|
if (Math.abs(a.b.minx - b.b.minx) > 0.1) {
|
||||||
|
return b.b.minx - a.b.minx;
|
||||||
|
}
|
||||||
|
return b.b.miny - a.b.miny;
|
||||||
|
})
|
||||||
|
return recs;
|
||||||
}
|
}
|
||||||
|
|
||||||
// compare fingerprint arrays
|
// compare fingerprint arrays
|
||||||
|
|
@ -1021,16 +1038,25 @@ function fingerprintCompare(a, b) {
|
||||||
for (let i=0; i<a.length; i++) {
|
for (let i=0; i<a.length; i++) {
|
||||||
let ra = a[i];
|
let ra = a[i];
|
||||||
let rb = b[i];
|
let rb = b[i];
|
||||||
|
// test poly area
|
||||||
|
if (Math.abs(ra.a - rb.a) > 1) {
|
||||||
|
console.log('area', Math.abs(ra.a - rb.a));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// test circularity
|
// test circularity
|
||||||
if (Math.abs(ra.c - rb.c) > 0.001) {
|
if (pd(ra.c, rb.c) > 0.02) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// test perimeter
|
// test perimeter
|
||||||
if (Math.abs(ra.p - rb.p) > 0.01) {
|
if (pd(ra.p, rb.p) > 0.005) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// test bounds
|
// test bounds
|
||||||
if (ra.b.delta(rb.b) > 0.01) {
|
if (ra.b.delta(rb.b) > 0.1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// test poly point count
|
||||||
|
if (a.length < 20 && pd(ra.l, rb.l) > 0.05) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,15 @@ gapp.register("kiri.main", [], (root, exports) => {
|
||||||
function setProgress(value = 0, msg) {
|
function setProgress(value = 0, msg) {
|
||||||
value = (value * 100).round(4);
|
value = (value * 100).round(4);
|
||||||
UI.progress.width = value+'%';
|
UI.progress.width = value+'%';
|
||||||
if (msg) UI.prostatus.innerHTML = msg;
|
if (self.debug) {
|
||||||
|
// console.log(msg, value.round(2));
|
||||||
|
UI.prostatus.style.display = 'flex';
|
||||||
|
if (msg) {
|
||||||
|
UI.prostatus.innerHTML = msg;
|
||||||
|
} else {
|
||||||
|
UI.prostatus.innerHTML = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function bound(v,min,max) {
|
function bound(v,min,max) {
|
||||||
|
|
|
||||||
|
|
@ -1427,13 +1427,17 @@ th, tr, td, label {
|
||||||
}
|
}
|
||||||
#progtxt {
|
#progtxt {
|
||||||
display: none;
|
display: none;
|
||||||
color: white;
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: 200%;
|
||||||
|
color: #888;
|
||||||
margin: 0 5px 0 5px;
|
margin: 0 5px 0 5px;
|
||||||
padding: 0 5px 2px 5px;
|
padding: 0 5px 2px 5px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
vertical-align: middle;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#modal {
|
#modal {
|
||||||
|
|
|
||||||
|
|
@ -225,7 +225,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- line betwwen menu bar and main application windows -->
|
<!-- line betwwen menu bar and main application windows -->
|
||||||
<div id="progress"><div id="progbar"><div id="progtxt">loading</div></div></div>
|
<div id="progress"><div id="progbar"></div><div id="progtxt">loading</div></div>
|
||||||
|
|
||||||
<!-- toolbar with mesh and rendering options -->
|
<!-- toolbar with mesh and rendering options -->
|
||||||
<div>
|
<div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue