add rad points to shell inset arrays
This commit is contained in:
parent
d0bcaa28da
commit
96beba67e8
1 changed files with 15 additions and 1 deletions
|
|
@ -167,6 +167,7 @@ function thin_type_3(params) {
|
||||||
top.thin_fill = [];
|
top.thin_fill = [];
|
||||||
top.fill_sparse = [];
|
top.fill_sparse = [];
|
||||||
|
|
||||||
|
// produce trace from outside of poly inward no more than max inset
|
||||||
let { noodle, remain } = top.poly.noodle(offsetN * count);
|
let { noodle, remain } = top.poly.noodle(offsetN * count);
|
||||||
top.shells = noodle;
|
top.shells = noodle;
|
||||||
top.gaps = last = remain;
|
top.gaps = last = remain;
|
||||||
|
|
@ -180,6 +181,7 @@ function thin_type_3(params) {
|
||||||
let pointMap = new Map();
|
let pointMap = new Map();
|
||||||
let lineMap = new Map();
|
let lineMap = new Map();
|
||||||
|
|
||||||
|
// convert point to deduplicated / unique point record
|
||||||
function pointToRec(point) {
|
function pointToRec(point) {
|
||||||
let key = `${(point.x*100)|0}|${(point.y*100)|0}`;
|
let key = `${(point.x*100)|0}|${(point.y*100)|0}`;
|
||||||
let rec = pointMap.get(key);
|
let rec = pointMap.get(key);
|
||||||
|
|
@ -196,6 +198,7 @@ function thin_type_3(params) {
|
||||||
return rec;
|
return rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// convert line to unique line record. matches reversed and duplicate lines
|
||||||
function pointsToLine(p0, p1) {
|
function pointsToLine(p0, p1) {
|
||||||
p0 = pointToRec(p0);
|
p0 = pointToRec(p0);
|
||||||
p1 = pointToRec(p1);
|
p1 = pointToRec(p1);
|
||||||
|
|
@ -294,6 +297,7 @@ function thin_type_3(params) {
|
||||||
let showCross = false;
|
let showCross = false;
|
||||||
let showRad = true;
|
let showRad = true;
|
||||||
|
|
||||||
|
// divide a segment/redius into 1 or more equal subsegments
|
||||||
function div(cr) {
|
function div(cr) {
|
||||||
if (cr <= maxR) {
|
if (cr <= maxR) {
|
||||||
return [ cr ];
|
return [ cr ];
|
||||||
|
|
@ -315,6 +319,8 @@ function thin_type_3(params) {
|
||||||
if (showRad) {
|
if (showRad) {
|
||||||
top.shells = [];
|
top.shells = [];
|
||||||
}
|
}
|
||||||
|
// ranked points by inset distance
|
||||||
|
let inset = [];
|
||||||
for (let chain of chains.filter(c => c.total >= minR)) {
|
for (let chain of chains.filter(c => c.total >= minR)) {
|
||||||
// chain reduction by merging short segments
|
// chain reduction by merging short segments
|
||||||
let end = chain[0];
|
let end = chain[0];
|
||||||
|
|
@ -364,18 +370,26 @@ function thin_type_3(params) {
|
||||||
let sx = cx + yo;
|
let sx = cx + yo;
|
||||||
let sy = cy - xo;
|
let sy = cy - xo;
|
||||||
let m = 1;
|
let m = 1;
|
||||||
|
let indx = 0;
|
||||||
for (let r of pop) {
|
for (let r of pop) {
|
||||||
|
indx = Math.min(indx, pop.length - 1 - indx);
|
||||||
|
let inset_arr = inset[indx];
|
||||||
|
if (!inset_arr) {
|
||||||
|
inset_arr = inset[indx] = [];
|
||||||
|
}
|
||||||
sx -= (r/cr) * yo * m;
|
sx -= (r/cr) * yo * m;
|
||||||
sy += (r/cr) * xo * m;
|
sy += (r/cr) * xo * m;
|
||||||
circ.push(newPolygon().centerCircle({ x:sx, y:sy }, r, 10));
|
circ.push(newPolygon().centerCircle({ x:sx, y:sy }, r, 10));
|
||||||
m = 2;
|
m = 2;
|
||||||
|
inset_arr.push({ x:sx, y:sy, r });
|
||||||
|
indx++;
|
||||||
}
|
}
|
||||||
// console.log(pop);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// console.log({ inset });
|
||||||
return { last, gaps };
|
return { last, gaps };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue