From d63754dbd091917b36b98b8c7b3d57f6d0ab46ca Mon Sep 17 00:00:00 2001 From: Casper Lamboo Date: Mon, 28 May 2018 11:57:16 +0200 Subject: [PATCH] fix slicing single walled paths --- src/sliceActions/optimizePaths.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sliceActions/optimizePaths.js b/src/sliceActions/optimizePaths.js index 146a2ed..68e7540 100644 --- a/src/sliceActions/optimizePaths.js +++ b/src/sliceActions/optimizePaths.js @@ -82,12 +82,12 @@ export default function optimizePaths(slices) { } function optimizeShape(shape, start) { - const inputPaths = shape.mapToLower(); + const inputPaths = shape.mapToLower().filter(path => path.length > 0); const optimizedPaths = []; const donePaths = []; while (optimizedPaths.length !== inputPaths.length) { - let minLength = false; + let minLength = Infinity; let reverse; let minPath; let offset; @@ -101,7 +101,7 @@ function optimizeShape(shape, start) { if (shape.closed) { for (let j = 0; j < path.length; j += 1) { const length = distanceTo(path[j], start); - if (minLength === false || length < minLength) { + if (length < minLength) { minPath = path; minLength = length; offset = j; @@ -110,7 +110,7 @@ function optimizeShape(shape, start) { } } else { const lengthToStart = distanceTo(path[0], start); - if (minLength === false || lengthToStart < minLength) { + if (lengthToStart < minLength) { minPath = path; minLength = lengthToStart; reverse = false;