From 76d028bd151cd508e01c660f5770ec783bdcbae2 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sun, 14 Sep 2025 12:48:20 -0400 Subject: [PATCH] separate chain filter logic --- src/kiri/mode/fdm/post.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/kiri/mode/fdm/post.js b/src/kiri/mode/fdm/post.js index f818aef0..8abceaf6 100644 --- a/src/kiri/mode/fdm/post.js +++ b/src/kiri/mode/fdm/post.js @@ -326,11 +326,8 @@ function thin_type_3(params) { } } - // gather point offsets into shells - // todo: order outer shell innersection to inner - let shells = { count: 0 }; // filter chains that are too short from consideration - for (let chain of chains.filter(c => c.total >= minR)) { + chains = chains.filter(c => c.total >= minR).map(chain => { // chain reduction by merging short segments let end = chain[0]; let nuchain = [ end ]; @@ -342,7 +339,17 @@ function thin_type_3(params) { end.len += point.len; } } - chain = nuchain; + return nuchain; + }); + + // connect chains end to end following nexus branches that result + // in the longest final merged chain (open or closed) + console.log(chains); + + // gather point offsets into shells + // todo: order outer shell innersection to inner + let shells = { count: 0 }; + for (let chain of chains) { // emit chain with subdivision for long segments for (let i=0; i