fixed closed lines detected as open lines

fixed https://github.com/Doodle3D/Doodle3D-Slicer/issues/10
This commit is contained in:
casperlamboo 2015-07-29 20:59:34 +02:00
parent d4f6776aa1
commit 2bc9d8fb35

View File

@ -208,7 +208,8 @@ export default class {
continue;
}
var firstPoint = index;
var firstPoints = [index];
var isFirstPoint = true;
var closed = false;
var shape = [];
@ -226,7 +227,7 @@ export default class {
for (var j = 0; j < connects.length; j ++) {
var index = connects[j];
if (index === firstPoint && shape.length > 2) {
if (firstPoints.indexOf(index) !== -1 && shape.length > 2) {
closed = true;
index = -1;
break;
@ -241,6 +242,10 @@ export default class {
// can't calculate normal if distance is smaller as 0.0001
if ((faceNormal.x === 0 && faceNormal.y === 0) || a.distanceTo(b) < 0.0001) {
if (isFirstPoint) {
firstPoints.push(index);
}
delete intersectionPoints[index];
connects = connects.concat(lines[index].connects);
@ -266,6 +271,7 @@ export default class {
index = -1;
}
}
isFirstPoint = false;
}
if (!closed) {
@ -704,7 +710,6 @@ export default class {
this.progress.generatedGCode = true;
this._updateProgress(settings);
return gcode.getGCode();
}