From 2c65ac740f324aa17657aab65d0d018e3b895e53 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Thu, 30 Jul 2015 11:36:20 +0200 Subject: [PATCH] Fixed bug in constucting low/high fill areas --- src/slicer.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/slicer.js b/src/slicer.js index aa9ff5b..02e50b2 100644 --- a/src/slicer.js +++ b/src/slicer.js @@ -82,7 +82,7 @@ export default class { } _createLines (settings) { - console.log('constructing lines from geometry'); + console.log('constructing unique lines from geometry'); var lines = []; var lineLookup = {}; @@ -188,8 +188,6 @@ export default class { _intersectionsToShapes (layerIntersectionIndexes, layerIntersectionPoints, lines, settings) { console.log("generating slices"); - var layerHeight = settings.config["layerHeight"]; - var shapes = []; for (var layer = 1; layer < layerIntersectionIndexes.length; layer ++) { @@ -275,10 +273,10 @@ export default class { } if (!closed) { - var index = firstPoint; + var index = firstPoints[0]; while (index !== -1) { - if (index !== firstPoint) { + if (firstPoints.indexOf(index) === -1) { var intersection = intersectionPoints[index]; shape.unshift({X: intersection.x, Y: intersection.y}); @@ -334,22 +332,23 @@ export default class { for (var i = 0; i < shapeParts.length; i ++) { var shapePart1 = shapeParts[i]; - if (shapePart1.closed) { - var merge = false; + if (!shapePart1.closed) { + slice.add(shapePart1); + continue; + } - for (var j = 0; j < slice.parts.length; j ++) { - var shapePart2 = slice.parts[j].intersect; - if (shapePart2.closed && shapePart2.intersect(shapePart1).length > 0) { - shapePart2.join(shapePart1); - merge = true; - break; - } - } - if (!merge) { - slice.add(shapePart1); + var merge = false; + + for (var j = 0; j < slice.parts.length; j ++) { + var shapePart2 = slice.parts[j].intersect; + if (shapePart2.closed && shapePart2.intersect(shapePart1).length > 0) { + shapePart2.join(shapePart1); + merge = true; + break; } } - else { + + if (!merge) { slice.add(shapePart1); } } @@ -464,12 +463,13 @@ export default class { var lowFillArea = fillArea.difference(highFillArea); } else { + var lowFillArea = new Paths([], true); var highFillArea = fillArea; } var fill = new Paths([], false); - if (lowFillArea !== undefined && lowFillArea.length > 0) { + if (lowFillArea.length > 0 && lowFillArea.length > 0) { var bounds = lowFillArea.bounds(); var lowFillTemplate = this._getFillTemplate(bounds, fillGridSize, true, true);