Fixed bug in constucting low/high fill areas

This commit is contained in:
casperlamboo 2015-07-30 11:36:20 +02:00 committed by Simon Voordouw
parent 032f896bb4
commit 2c65ac740f

View File

@ -82,7 +82,7 @@ export default class {
} }
_createLines (settings) { _createLines (settings) {
console.log('constructing lines from geometry'); console.log('constructing unique lines from geometry');
var lines = []; var lines = [];
var lineLookup = {}; var lineLookup = {};
@ -188,8 +188,6 @@ export default class {
_intersectionsToShapes (layerIntersectionIndexes, layerIntersectionPoints, lines, settings) { _intersectionsToShapes (layerIntersectionIndexes, layerIntersectionPoints, lines, settings) {
console.log("generating slices"); console.log("generating slices");
var layerHeight = settings.config["layerHeight"];
var shapes = []; var shapes = [];
for (var layer = 1; layer < layerIntersectionIndexes.length; layer ++) { for (var layer = 1; layer < layerIntersectionIndexes.length; layer ++) {
@ -275,10 +273,10 @@ export default class {
} }
if (!closed) { if (!closed) {
var index = firstPoint; var index = firstPoints[0];
while (index !== -1) { while (index !== -1) {
if (index !== firstPoint) { if (firstPoints.indexOf(index) === -1) {
var intersection = intersectionPoints[index]; var intersection = intersectionPoints[index];
shape.unshift({X: intersection.x, Y: intersection.y}); shape.unshift({X: intersection.x, Y: intersection.y});
@ -334,7 +332,11 @@ export default class {
for (var i = 0; i < shapeParts.length; i ++) { for (var i = 0; i < shapeParts.length; i ++) {
var shapePart1 = shapeParts[i]; var shapePart1 = shapeParts[i];
if (shapePart1.closed) { if (!shapePart1.closed) {
slice.add(shapePart1);
continue;
}
var merge = false; var merge = false;
for (var j = 0; j < slice.parts.length; j ++) { for (var j = 0; j < slice.parts.length; j ++) {
@ -345,14 +347,11 @@ export default class {
break; break;
} }
} }
if (!merge) { if (!merge) {
slice.add(shapePart1); slice.add(shapePart1);
} }
} }
else {
slice.add(shapePart1);
}
}
slices.push(slice); slices.push(slice);
} }
@ -464,12 +463,13 @@ export default class {
var lowFillArea = fillArea.difference(highFillArea); var lowFillArea = fillArea.difference(highFillArea);
} }
else { else {
var lowFillArea = new Paths([], true);
var highFillArea = fillArea; var highFillArea = fillArea;
} }
var fill = new Paths([], false); var fill = new Paths([], false);
if (lowFillArea !== undefined && lowFillArea.length > 0) { if (lowFillArea.length > 0 && lowFillArea.length > 0) {
var bounds = lowFillArea.bounds(); var bounds = lowFillArea.bounds();
var lowFillTemplate = this._getFillTemplate(bounds, fillGridSize, true, true); var lowFillTemplate = this._getFillTemplate(bounds, fillGridSize, true, true);