diff --git a/js/geo-polygons.js b/js/geo-polygons.js index 80fdd7a9..70aae10f 100644 --- a/js/geo-polygons.js +++ b/js/geo-polygons.js @@ -834,6 +834,7 @@ var gs_base_polygons = exports; }).forEach(p => { finger.push(p.area()); finger.push(p.perimeter()); + finger.push(p.bounds); }); return finger; } @@ -848,13 +849,19 @@ var gs_base_polygons = exports; if (a.length !== b.length) { return false; } - for (let i=0; i 0.001) { return false; } if (Math.abs(a[i+1] - b[i+1]) > 0.0001) { return false; } + if (Math.abs(a[i+2].centerx() - b[i+2].centerx()) > 0.0001) { + return false; + } + if (Math.abs(a[i+2].centery() - b[i+2].centery()) > 0.0001) { + return false; + } } return true; } diff --git a/notes.md b/notes.md index 21a708c6..c7ed917b 100644 --- a/notes.md +++ b/notes.md @@ -30,6 +30,7 @@ * `F` option to support interior bridges when 0% infill * `P` disable infill fingerprinting for gyroids * `P` refactor thin fill to use outline and inside poly normal dist to self +* `P` segment large polygons for extremely large parts / infill # SLA diff --git a/web/kiri/gyroid-test.html b/web/kiri/gyroid-test.html index b7fa003b..abda3f7e 100644 --- a/web/kiri/gyroid-test.html +++ b/web/kiri/gyroid-test.html @@ -31,13 +31,17 @@ min-width: 3px; min-height: 3px; } - #stats { + #stats,#opts { text-align: center; } + #stats { + margin-top: 5px; + } #stats > input { pointer-events: none; outline: none; width: 5em; + background-color: #eee; } svg { border: 1px solid #888; @@ -97,33 +101,32 @@ } class Grid { - constructor(x,y,div) { - this.x = (x/div)|0; - this.y = (y/div)|0; + constructor(size,div) { + this.size = (size/div)|0; this.div = div; - this.grid = new Array(this.x * this.y); + this.grid = new Array(div * div); } get(x,y) { - x = (x/this.div)|0; - y = (y/this.div)|0; - let pos = x + y * this.x; + x = (x/this.size)|0; + y = (y/this.size)|0; + let pos = x + y * this.size; let rec = this.grid[pos]; if (rec) return rec; return this.grid[pos] = []; } _get(x,y) { - if (x < 0 || y < 0 || x > this.x || y > this.y) return undefined; - return this.grid[x + y * this.x]; + if (x < 0 || y < 0 || x > this.size || y > this.size) return undefined; + return this.grid[x + y * this.size]; } peers(x,y) { let grid = this.grid; let r = this.x; // console.log('peers',x,y) - x = (x/this.div)|0; - y = (y/this.div)|0; + x = (x/this.size)|0; + y = (y/this.size)|0; let peers = [], p; p = this._get(x,y); if (p) peers.push(p); p = this._get(x-1,y); if (p) peers.push(p); @@ -145,17 +148,48 @@ let zcache = {}; let timer = new Timer(); let maxdist = rez * 0.01; - let fast = false; + let fast = true; + let tip = 0.2; function $(id) { return document.getElementById(id); } function init() { + let opt = document.location.search.substring(1).split('&').map(v => { + return v.split('=').map(v => decodeURIComponent(v)); + }).reduce( (m,v) => { + m[v[0]] = v[1]; + return m; + }, {}); + function reload() { + opt.speed = $('fast').checked ? 'fast' : 'slow'; + opt.caps = $('caps').checked ? 1 : 0; + opt.raw = $('raw').checked ? 1 : 0; + let search = []; + Object.entries(opt).forEach((k,v) => { + search.push(encodeURIComponent(k[0]) + '=' + encodeURIComponent(k[1])); + }); + document.location.search = search.join('&'); + }; + $('offset').onkeypress = (ev) => { + if (ev.key === 'Enter') { + opt.offset = $('offset').value; + reload(); + } + }; + $('offset').focus(); + if (opt.offset) tip = $('offset').value = (parseFloat(opt.offset) || 0); + if (opt.raw) $('raw').checked = opt.raw === 1; + if (opt.caps) $('caps').checked = opt.caps === 1; + $('fast').checked = fast = opt.speed !== 'slow'; + $('fast').onchange = reload; + $('raw').onchange = update; + $('caps').onchange = update; $('zval').max = rez; let mark = Date.now(); - for (let z=0; z= tip) || (v0 >= tip && v1 <= tip) || (v0 <= -tip && v1 >= -tip) || (v0 >= -tip && v1 <= -tip) ) { - // if ((v0 <= 0 && v1 >= 0) || (v0 >= 0 && v1 <= 0)) { edge.put(x,y,1); points++; points_lr++; @@ -224,7 +263,6 @@ (v0 <= tip && v1 >= tip) || (v0 >= tip && v1 <= tip) || (v0 <= -tip && v1 >= -tip) || (v0 >= -tip && v1 <= -tip) ) { - // if ((v0 <= 0 && v1 >= 0) || (v0 >= 0 && v1 <= 0)) { if (edge.get(x,y)) { edge.put(x,y,3); } else { @@ -243,7 +281,7 @@ // create sparse representation let sparse = []; let center = rez / 2; - let grid = new Grid(size,size,10); + let grid = new Grid(size,10); for (let x=0; x'); - raw.forEach(point => { - let x = point.x; - let y = point.y; - let color = ['black','#f00a','#0f0a','#00fa'][point.val]; - html.push(``); - }) + if ($('raw').checked) { + html.push(''); + raw.forEach(point => { + let x = point.x; + let y = point.y; + let color = ['black','#f00a','#0f0a','#00fa'][point.val]; + html.push(``); + }) + html.push(''); + } // polys.forEach(poly => { // poly.forEach(point => { // let x = point.x; @@ -409,7 +450,6 @@ // html.push(``); // }); // }); - html.push(''); // points joined into poly lines html.push(''); @@ -419,7 +459,9 @@ .join(',')).join(' '); let x = poly[0].x - 1; let y = poly[0].y - 1; - html.push(``); + if ($('caps').checked) { + html.push(``); + } html.push(``); }); html.push(''); @@ -434,6 +476,12 @@
+
+ offset + raw + caps + fast +