diff --git a/src/kiri/mode/fdm/post.js b/src/kiri/mode/fdm/post.js index 00b85f98..40c5a15d 100644 --- a/src/kiri/mode/fdm/post.js +++ b/src/kiri/mode/fdm/post.js @@ -163,22 +163,29 @@ function thin_type_2(params) { } function thin_type_3(params) { + // offsetN usually = extrusion width (nozzle diameter) let { z, top, count, offsetN, last, gaps } = params; - top.thin_fill = []; - top.fill_sparse = []; // produce trace from outside of poly inward no more than max inset let { noodle, remain } = top.poly.noodle(offsetN * count); + // top.shells = noodle; top.gaps = last = remain; - let thin = top.thin_fill; + let thin = top.thin_fill = []; + let sparse = top.fill_sparse = []; let scale = 1000; let minR = offsetN / 2; let maxR = minR * 1.5; - let minSpur = 0; // offsetN * 3; - let mergeClosePoints = true; + let minSpur = offsetN * 3; + let interpolateShortSpur = true; + let showChainInterpPoints = true; + let showChainRawPoints = false; + let showNoodle = false; + let showMid = true; + let showCross = true; + let showRad = true; let pointMap = new Map(); let lineMap = new Map(); @@ -246,7 +253,6 @@ function thin_type_3(params) { } // connect segments into chains - // console.log({ seg: [...lineMap.values()].sort((s1,s2) => s2.len - s1.len) }); for (let seg of lineMap.values()) { let { p0, p1 } = seg; let len = seg.len = Math.hypot(p0.x-p1.x, p0.y-p1.y); @@ -318,12 +324,6 @@ function thin_type_3(params) { // merging longer chains. then shorten remaining nexus chain // intersections by minR - let showNoodle = false; - let showMid = true; - let showCross = false; - let showRad = false; - let showShells = false; - // render inset "noodle" if (showNoodle) { top.shells.appendAll(noodle); @@ -351,24 +351,6 @@ function thin_type_3(params) { chains = chains.filter(c => c.total >= minR); chains.sort((c1,c2) => c2.total - c1.total); - // merge chain points that are too close - if (mergeClosePoints) - chains = chains.map(chain => { - // chain reduction by merging short segments - let end = chain[0]; - let nuchain = [ end ]; - nuchain.total = chain.total; - for (let point of chain.slice(1)) { - if (point.len === undefined || point.len + end.len >= minR) { - nuchain.push(point); - end = point; - } else { - end.len += point.len; - } - } - return nuchain; - }); - // map chains to nexus via endpoints let nexus = {}; function addEp(point, chain) { @@ -403,8 +385,11 @@ function thin_type_3(params) { // gather point offsets into shells // todo: order outer shell innersection to inner - let shells = { count: 0 }; for (let chain of chains) { + if (showChainRawPoints) + for (let pt of chain) { + top.shells.push(newPolygon().centerCircle(pt, pt.r ?? 0.1, 10)); + } // emit chain with subdivision for long segments for (let i=0; i 1) { - // top.shells.push(poly); - // poly = new Polygon().setOpen(); - // } - // arr[find.pi] = undefined; - // poly.push(lp = find.pt); - // } else { - // break; - // } - // } - // console.log({ poly }); - // if (poly.length > 1) { - // top.shells.push(poly); - // } - // } + POLY.setZ([...thin, ...top.shells], z); return { last, gaps }; }