Fix progress bug

This commit is contained in:
casperlamboo 2015-07-10 09:16:03 +02:00 committed by Simon Voordouw
parent ae02c3efc2
commit 40cfcd4579
5 changed files with 2486 additions and 5983 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
"shellThickness": 0.4, "shellThickness": 0.4,
"brimOffset": 4.0, "brimOffset": 4.0,
"fillGridSize": 5.0, "fillGridSize": 5.0,
"infillOverlap": 0.5, "infillOverlap": 0.0,
"travelSpeed": 200.0, "travelSpeed": 200.0,
"retractionAmount": 3.0, "retractionAmount": 3.0,
"retractionEnabled": true, "retractionEnabled": true,
@ -13,32 +13,32 @@
"retractionMinDistance": 0.0, "retractionMinDistance": 0.0,
"supportAcceptanceMargin": 1.5, "supportAcceptanceMargin": 1.5,
"supportDistanceY": 0.4, "supportDistanceY": 0.4,
"supportUse": true, "supportUse": false,
"supportGridSize": 6.0, "supportGridSize": 6.0,
"supportMargin": 2.0, "supportMargin": 2.0,
"supportPlateSize": 4.0, "supportPlateSize": 4.0,
"outerLine": { "outerLine": {
"flowRate": 1.0, "flowRate": 1.0,
"speed": 50.0 "speed": 40.0
}, },
"innerLine": { "innerLine": {
"flowRate": 1.0, "flowRate": 1.0,
"speed": 80.0 "speed": 50.0
}, },
"fill": { "fill": {
"flowRate": 1.0, "flowRate": 1.0,
"speed": 80.0 "speed": 50.0
}, },
"brim": { "brim": {
"flowRate": 1.0, "flowRate": 1.0,
"speed": 50.0 "speed": 40.0
}, },
"support": { "support": {
"flowRate": 0.8, "flowRate": 0.8,
"speed": 100.0 "speed": 40.0
}, },
"bottom": { "bottom": {
"flowRate": 2.0, "flowRate": 1.2,
"speed": 30.0 "speed": 40.0
} }
} }

View File

@ -241,7 +241,7 @@ D3D.Paths.prototype.draw = function (context, color) {
for (var j = 0; j < shape.length; j ++) { for (var j = 0; j < shape.length; j ++) {
var point = shape[j % shape.length]; var point = shape[j % shape.length];
context.lineTo(point.X*2, point.Y*2); context.lineTo(point.X * 2, point.Y * 2);
} }
if (this.closed) { if (this.closed) {
context.closePath(); context.closePath();

View File

@ -42,9 +42,6 @@ D3D.Slicer.prototype.setMesh = function (geometry, matrix) {
this.geometry = geometry; this.geometry = geometry;
//get unique lines from geometry;
this._createLines();
return this; return this;
}; };
D3D.Slicer.prototype.getGCode = function (printer) { D3D.Slicer.prototype.getGCode = function (printer) {
@ -54,12 +51,10 @@ D3D.Slicer.prototype.getGCode = function (printer) {
var dimensionsZ = printer.config["dimensionsZ"]; var dimensionsZ = printer.config["dimensionsZ"];
var useSupport = printer.config["supportUse"]; var useSupport = printer.config["supportUse"];
this.progress.totalLayers = Math.floor(Math.min(this.geometry.boundingBox.max.y, dimensionsZ) / layerHeight); //get unique lines from geometry;
this.progress.sliceLayer = 0; this._createLines(printer);
this.progress.dataLayer = 0;
this.progress.gcodeLayer = 0;
var slices = this._slice(layerHeight, dimensionsZ); var slices = this._slice(printer);
this._generateInnerLines(slices, printer); this._generateInnerLines(slices, printer);
@ -78,17 +73,22 @@ D3D.Slicer.prototype.getGCode = function (printer) {
D3D.Slicer.prototype._updateProgress = function () { D3D.Slicer.prototype._updateProgress = function () {
'use strict'; 'use strict';
var useSupport = printer.config["supportUse"];
var progress = {}; var progress = {};
var procent = 0; var procent = 0;
var length = 0; var length = 0;
for (var i in this.progress) { for (var i in this.progress) {
progress[i] = this.progress[i]; if (!(!useSupport && i === "generatedSupport")) {
procent += this.progress[i] ? 1 : 0; progress[i] = this.progress[i];
length ++; if (this.progress[i]) {
procent ++;
}
length ++;
}
} }
console.log(procent, length);
progress.procent = procent / length; progress.procent = procent / length;
if (this.onProgress !== undefined) { if (this.onProgress !== undefined) {
@ -96,7 +96,7 @@ D3D.Slicer.prototype._updateProgress = function () {
this.onProgress(progress); this.onProgress(progress);
} }
}; };
D3D.Slicer.prototype._createLines = function () { D3D.Slicer.prototype._createLines = function (printer) {
"use strict"; "use strict";
this._lines = []; this._lines = [];
@ -144,12 +144,15 @@ D3D.Slicer.prototype._createLines = function () {
} }
this.progress.createdLines = true; this.progress.createdLines = true;
this._updateProgress(); this._updateProgress(printer);
}; };
D3D.Slicer.prototype._slice = function (layerHeight, height) { D3D.Slicer.prototype._slice = function (printer) {
"use strict"; "use strict";
var testData = []; var layerHeight = printer.config["layerHeight"];
var height = printer.config["dimensionsZ"];
//var testData = [];
var numLayers = height / layerHeight; var numLayers = height / layerHeight;
@ -172,7 +175,7 @@ D3D.Slicer.prototype._slice = function (layerHeight, height) {
} }
var slices = []; var slices = [];
var testPoints = []; //var testPoints = [];
for (var layer = 1; layer < layersIntersections.length; layer ++) { for (var layer = 1; layer < layersIntersections.length; layer ++) {
var layerIntersections = layersIntersections[layer]; var layerIntersections = layersIntersections[layer];
@ -197,13 +200,13 @@ D3D.Slicer.prototype._slice = function (layerHeight, height) {
} }
intersections[index] = new THREE.Vector2(z, x); intersections[index] = new THREE.Vector2(z, x);
testPoints.push({ /*testPoints.push({
x: z, x: z,
y: x, y: x,
connects: this._lines[index].connects, connects: this._lines[index].connects,
index: index, index: index,
normals: this._lines[index].normals normals: this._lines[index].normals
}); });*/
} }
var done = []; var done = [];
@ -286,19 +289,19 @@ D3D.Slicer.prototype._slice = function (layerHeight, height) {
slices.push(slice); slices.push(slice);
if (layer === 218) { /*if (layer === 218) {
testData.push({ testData.push({
testPoints: testPoints, testPoints: testPoints,
pathData: slice.parts pathData: slice.parts
}); });
} }*/
} }
} }
//console.log(JSON.stringify(testData)); //console.log(JSON.stringify(testData));
this.progress.sliced = true; this.progress.sliced = true;
this._updateProgress(); this._updateProgress(printer);
return slices; return slices;
}; };
@ -321,7 +324,7 @@ D3D.Slicer.prototype._generateInnerLines = function (slices, printer) {
for (var i = 0; i < slice.parts.length; i ++) { for (var i = 0; i < slice.parts.length; i ++) {
var part = slice.parts[i]; var part = slice.parts[i];
var outerLine = part.intersect.clone().scaleUp(scale); var outerLine = part.intersect.clone().scaleUp(scale).offset(-nozzleRadius);
if (outerLine.length > 0) { if (outerLine.length > 0) {
part.outerLine = outerLine; part.outerLine = outerLine;
@ -341,7 +344,7 @@ D3D.Slicer.prototype._generateInnerLines = function (slices, printer) {
} }
this.progress.generatedInnerLines = true; this.progress.generatedInnerLines = true;
this._updateProgress(); this._updateProgress(printer);
}; };
D3D.Slicer.prototype._generateInfills = function (slices, printer) { D3D.Slicer.prototype._generateInfills = function (slices, printer) {
"use strict"; "use strict";
@ -412,7 +415,7 @@ D3D.Slicer.prototype._generateInfills = function (slices, printer) {
} }
this.progress.generatedInfills = true; this.progress.generatedInfills = true;
this._updateProgress(); this._updateProgress(printer);
}; };
D3D.Slicer.prototype._generateSupport = function (slices, printer) { D3D.Slicer.prototype._generateSupport = function (slices, printer) {
"use strict"; "use strict";
@ -476,7 +479,7 @@ D3D.Slicer.prototype._generateSupport = function (slices, printer) {
} }
this.progress.generatedSupport = true; this.progress.generatedSupport = true;
this._updateProgress(); this._updateProgress(printer);
}; };
D3D.Slicer.prototype._optimizePaths = function (slices, printer) { D3D.Slicer.prototype._optimizePaths = function (slices, printer) {
@ -520,7 +523,7 @@ D3D.Slicer.prototype._optimizePaths = function (slices, printer) {
} }
this.progress.optimizedPaths = true; this.progress.optimizedPaths = true;
this._updateProgress(); this._updateProgress(printer);
} }
D3D.Slicer.prototype._getFillTemplate = function (bounds, size, even, uneven) { D3D.Slicer.prototype._getFillTemplate = function (bounds, size, even, uneven) {