mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-23 19:43:48 +01:00
made some functions and variables private with "_"
This commit is contained in:
parent
542badc205
commit
e46fe6ad43
@ -11,6 +11,9 @@
|
|||||||
<script src="../three.js-master/build/three.js"></script>
|
<script src="../three.js-master/build/three.js"></script>
|
||||||
<script src="lib/paper-core.js"></script>
|
<script src="lib/paper-core.js"></script>
|
||||||
|
|
||||||
|
<script src="../three.js-master/examples/js/renderers/Projector.js"></script>
|
||||||
|
|
||||||
|
<script src="../three.js-master/examples/js/renderers/CanvasRenderer.js"></script>
|
||||||
<script src="../three.js-master/examples/js/controls/EditorControls.js"></script>
|
<script src="../three.js-master/examples/js/controls/EditorControls.js"></script>
|
||||||
<script src="../three.js-master/examples/js/controls/TransformControls.js"></script>
|
<script src="../three.js-master/examples/js/controls/TransformControls.js"></script>
|
||||||
|
|
||||||
|
172520
gcode/easterbunny.js
172520
gcode/easterbunny.js
File diff suppressed because it is too large
Load Diff
78309
gcode/testgcode.js
78309
gcode/testgcode.js
File diff suppressed because it is too large
Load Diff
50
src/box.js
50
src/box.js
@ -1,7 +1,7 @@
|
|||||||
/******************************************************
|
/******************************************************
|
||||||
*
|
*
|
||||||
* WiFi-Box
|
* WiFi-Box
|
||||||
* Representation of de Doodle3DBox
|
* Representation of de Doodle3D-WiFi Box
|
||||||
* Handles all communication with the doodle box
|
* Handles all communication with the doodle box
|
||||||
* JavaScript shell for api communication
|
* JavaScript shell for api communication
|
||||||
* Check http://www.doodle3d.com/help/api-documentation
|
* Check http://www.doodle3d.com/help/api-documentation
|
||||||
@ -27,8 +27,8 @@ D3D.Box = function (localIp) {
|
|||||||
this.config = {};
|
this.config = {};
|
||||||
this.status = {};
|
this.status = {};
|
||||||
|
|
||||||
this.printBatches = [];
|
this._printBatches = [];
|
||||||
this.currentBatch = 0;
|
this._currentBatch = 0;
|
||||||
|
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
};
|
};
|
||||||
@ -74,13 +74,13 @@ D3D.Box.prototype.init = function () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.updateState();
|
scope._updateState();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.updateLoop = function () {
|
D3D.Box.prototype._updateLoop = function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
var scope = this;
|
var scope = this;
|
||||||
//TODO
|
//TODO
|
||||||
@ -88,17 +88,17 @@ D3D.Box.prototype.updateLoop = function () {
|
|||||||
//Bij error wordt gelijk zelfde data opnieuw gestuurd
|
//Bij error wordt gelijk zelfde data opnieuw gestuurd
|
||||||
//Als DoodleBox ontkoppeld wordt komt er een error in de loop waardoor pagina breekt en ververst moet worden
|
//Als DoodleBox ontkoppeld wordt komt er een error in de loop waardoor pagina breekt en ververst moet worden
|
||||||
|
|
||||||
if (this.printBatches.length > 0 && (this.status["buffered_lines"] + this.printBatches[0].length) <= this.maxBufferedLines) {
|
if (this._printBatches.length > 0 && (this.status["buffered_lines"] + this._printBatches[0].length) <= this.maxBufferedLines) {
|
||||||
//if (this.printBatches.length > 0 ) {
|
//if (this._printBatches.length > 0 ) {
|
||||||
this.printBatch();
|
this._printBatch();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
scope.updateState();
|
scope._updateState();
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.updateState = function () {
|
D3D.Box.prototype._updateState = function () {
|
||||||
//que api calls so they don't overload the d3d box
|
//que api calls so they don't overload the d3d box
|
||||||
"use strict";
|
"use strict";
|
||||||
var scope = this;
|
var scope = this;
|
||||||
@ -117,38 +117,38 @@ D3D.Box.prototype.updateState = function () {
|
|||||||
scope.onupdate(data);
|
scope.onupdate(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.updateLoop();
|
scope._updateLoop();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.print = function (gcode) {
|
D3D.Box.prototype.print = function (gcode) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
this.currentBatch = 0;
|
this._currentBatch = 0;
|
||||||
|
|
||||||
gcode = gcode.split("\n");
|
gcode = gcode.split("\n");
|
||||||
|
|
||||||
//split gcode in batches
|
//split gcode in batches
|
||||||
while (gcode.length > 0) {
|
while (gcode.length > 0) {
|
||||||
var gcodeBatch = gcode.splice(0, Math.min(this.batchSize, gcode.length));
|
var gcodeBatch = gcode.splice(0, Math.min(this.batchSize, gcode.length));
|
||||||
this.printBatches.push(gcodeBatch);
|
this._printBatches.push(gcodeBatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.printBatch = function () {
|
D3D.Box.prototype._printBatch = function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
var scope = this;
|
var scope = this;
|
||||||
|
|
||||||
var gcode = this.printBatches.shift();
|
var gcode = this._printBatches.shift();
|
||||||
|
|
||||||
this.setPrinterPrint({
|
this.setPrinterPrint({
|
||||||
"start": ((this.currentBatch === 0) ? true : false),
|
"start": ((this._currentBatch === 0) ? true : false),
|
||||||
"first": ((this.currentBatch === 0) ? true : false),
|
"first": ((this._currentBatch === 0) ? true : false),
|
||||||
"gcode": gcode.join("\n"),
|
"gcode": gcode.join("\n"),
|
||||||
"last": ((this.printBatches.length === 0) ? true : false) //only for debug purposes
|
"last": ((this._printBatches.length === 0) ? true : false) //only for debug purposes
|
||||||
}, function (error, data) {
|
}, function (error, data) {
|
||||||
if (error) {
|
if (error) {
|
||||||
scope.printBatches.unshift(gcode);
|
scope._printBatches.unshift(gcode);
|
||||||
|
|
||||||
console.warn(error);
|
console.warn(error);
|
||||||
scope.init();
|
scope.init();
|
||||||
@ -156,24 +156,24 @@ D3D.Box.prototype.printBatch = function () {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("batch sent: " + scope.currentBatch, data);
|
console.log("batch sent: " + scope._currentBatch, data);
|
||||||
|
|
||||||
if (scope.printBatches.length > 0) {
|
if (scope._printBatches.length > 0) {
|
||||||
scope.currentBatch ++;
|
scope._currentBatch ++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log("Finish sending model to printer");
|
console.log("Finish sending model to printer");
|
||||||
}
|
}
|
||||||
|
|
||||||
scope.updateState();
|
scope._updateState();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.stopPrint = function (printer) {
|
D3D.Box.prototype.stopPrint = function (printer) {
|
||||||
"use strict";
|
"use strict";
|
||||||
var scope = this;
|
var scope = this;
|
||||||
|
|
||||||
this.printBatches = [];
|
this._printBatches = [];
|
||||||
this.currentBatch = 0;
|
this._currentBatch = 0;
|
||||||
|
|
||||||
this.setPrinterStop({
|
this.setPrinterStop({
|
||||||
"gcode": printer.getEndCode()
|
"gcode": printer.getEndCode()
|
||||||
|
10
src/paths.js
10
src/paths.js
@ -29,7 +29,7 @@ D3D.Paths.prototype.setPaths = function (paths) {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Paths.prototype.clip = function (path, type) {
|
D3D.Paths.prototype._clip = function (path, type) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var solution = new ClipperLib.Paths();
|
var solution = new ClipperLib.Paths();
|
||||||
@ -44,22 +44,22 @@ D3D.Paths.prototype.clip = function (path, type) {
|
|||||||
D3D.Paths.prototype.union = function (path) {
|
D3D.Paths.prototype.union = function (path) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
return this.clip(path, ClipperLib.ClipType.ctUnion);
|
return this._clip(path, ClipperLib.ClipType.ctUnion);
|
||||||
};
|
};
|
||||||
D3D.Paths.prototype.difference = function (path) {
|
D3D.Paths.prototype.difference = function (path) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
return this.clip(path, ClipperLib.ClipType.ctDifference);
|
return this._clip(path, ClipperLib.ClipType.ctDifference);
|
||||||
};
|
};
|
||||||
D3D.Paths.prototype.intersect = function (path) {
|
D3D.Paths.prototype.intersect = function (path) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
return this.clip(path, ClipperLib.ClipType.ctIntersection);
|
return this._clip(path, ClipperLib.ClipType.ctIntersection);
|
||||||
};
|
};
|
||||||
D3D.Paths.prototype.xor = function () {
|
D3D.Paths.prototype.xor = function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
return this.clip(path, ClipperLib.ClipType.ctXor);
|
return this._clip(path, ClipperLib.ClipType.ctXor);
|
||||||
};
|
};
|
||||||
D3D.Paths.prototype.offset = function (offset) {
|
D3D.Paths.prototype.offset = function (offset) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
@ -23,7 +23,7 @@ D3D.Printer.prototype.getStartCode = function () {
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var gcode = this.config["startCode"];
|
var gcode = this.config["startCode"];
|
||||||
gcode = this.subsituteVariables(gcode);
|
gcode = this._subsituteVariables(gcode);
|
||||||
|
|
||||||
return gcode;
|
return gcode;
|
||||||
};
|
};
|
||||||
@ -32,11 +32,11 @@ D3D.Printer.prototype.getEndCode = function () {
|
|||||||
|
|
||||||
var gcode = this.config["endCode"];
|
var gcode = this.config["endCode"];
|
||||||
|
|
||||||
gcode = this.subsituteVariables(gcode);
|
gcode = this._subsituteVariables(gcode);
|
||||||
|
|
||||||
return gcode;
|
return gcode;
|
||||||
};
|
};
|
||||||
D3D.Printer.prototype.subsituteVariables = function (gcode) {
|
D3D.Printer.prototype._subsituteVariables = function (gcode) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var temperature = this.config["temperature"];
|
var temperature = this.config["temperature"];
|
||||||
|
109
src/slicer.js
109
src/slicer.js
@ -42,7 +42,7 @@ D3D.Slicer.prototype.setMesh = function (geometry, matrix) {
|
|||||||
this.geometry = geometry;
|
this.geometry = geometry;
|
||||||
|
|
||||||
//get unique lines from geometry;
|
//get unique lines from geometry;
|
||||||
this.createLines();
|
this._createLines();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
@ -58,23 +58,23 @@ D3D.Slicer.prototype.getGCode = function (printer) {
|
|||||||
this.progress.dataLayer = 0;
|
this.progress.dataLayer = 0;
|
||||||
this.progress.gcodeLayer = 0;
|
this.progress.gcodeLayer = 0;
|
||||||
|
|
||||||
var slices = this.slice(layerHeight, dimensionsZ);
|
var slices = this._slice(layerHeight, dimensionsZ);
|
||||||
|
|
||||||
this.generateInnerLines(slices, printer);
|
this._generateInnerLines(slices, printer);
|
||||||
|
|
||||||
this.generateInfills(slices, printer);
|
this._generateInfills(slices, printer);
|
||||||
|
|
||||||
if (useSupport) {
|
if (useSupport) {
|
||||||
this.generateSupport(slices, printer);
|
this._generateSupport(slices, printer);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.optimizePaths(slices, printer);
|
this._optimizePaths(slices, printer);
|
||||||
|
|
||||||
var gcode = this.slicesToGCode(slices, printer);
|
var gcode = this._slicesToGCode(slices, printer);
|
||||||
|
|
||||||
return gcode;
|
return gcode;
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype.updateProgress = function () {
|
D3D.Slicer.prototype._updateProgress = function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var faces = this.progress.currentFace / (this.progress.totalFaces - 1);
|
var faces = this.progress.currentFace / (this.progress.totalFaces - 1);
|
||||||
@ -89,12 +89,12 @@ D3D.Slicer.prototype.updateProgress = function () {
|
|||||||
this.onProgress(this.progress);
|
this.onProgress(this.progress);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype.createLines = function () {
|
D3D.Slicer.prototype._createLines = function () {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
this.progress.totalFaces = this.geometry.faces.length;
|
this.progress.totalFaces = this.geometry.faces.length;
|
||||||
|
|
||||||
this.lines = [];
|
this._lines = [];
|
||||||
var lineLookup = {};
|
var lineLookup = {};
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
@ -102,10 +102,10 @@ D3D.Slicer.prototype.createLines = function () {
|
|||||||
var index = lineLookup[b + "_" + a];
|
var index = lineLookup[b + "_" + a];
|
||||||
|
|
||||||
if (index === undefined) {
|
if (index === undefined) {
|
||||||
index = self.lines.length;
|
index = self._lines.length;
|
||||||
lineLookup[a + "_" + b] = index;
|
lineLookup[a + "_" + b] = index;
|
||||||
|
|
||||||
self.lines.push({
|
self._lines.push({
|
||||||
line: new THREE.Line3(self.geometry.vertices[a], self.geometry.vertices[b]),
|
line: new THREE.Line3(self.geometry.vertices[a], self.geometry.vertices[b]),
|
||||||
connects: [],
|
connects: [],
|
||||||
normals: []
|
normals: []
|
||||||
@ -128,20 +128,20 @@ D3D.Slicer.prototype.createLines = function () {
|
|||||||
var c = addLine(face.c, face.a);
|
var c = addLine(face.c, face.a);
|
||||||
|
|
||||||
//set connecting lines (based on face)
|
//set connecting lines (based on face)
|
||||||
this.lines[a].connects.push(b, c);
|
this._lines[a].connects.push(b, c);
|
||||||
this.lines[b].connects.push(c, a);
|
this._lines[b].connects.push(c, a);
|
||||||
this.lines[c].connects.push(a, b);
|
this._lines[c].connects.push(a, b);
|
||||||
|
|
||||||
this.lines[a].normals.push(normal);
|
this._lines[a].normals.push(normal);
|
||||||
this.lines[b].normals.push(normal);
|
this._lines[b].normals.push(normal);
|
||||||
this.lines[c].normals.push(normal);
|
this._lines[c].normals.push(normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.progress.currentFace = i;
|
this.progress.currentFace = i;
|
||||||
this.updateProgress();
|
this._updateProgress();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype.slice = function (layerHeight, height) {
|
D3D.Slicer.prototype._slice = function (layerHeight, height) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var testData = [];
|
var testData = [];
|
||||||
@ -153,8 +153,8 @@ D3D.Slicer.prototype.slice = function (layerHeight, height) {
|
|||||||
layersIntersections[layer] = [];
|
layersIntersections[layer] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var lineIndex = 0; lineIndex < this.lines.length; lineIndex ++) {
|
for (var lineIndex = 0; lineIndex < this._lines.length; lineIndex ++) {
|
||||||
var line = this.lines[lineIndex].line;
|
var line = this._lines[lineIndex].line;
|
||||||
|
|
||||||
var min = Math.ceil(Math.min(line.start.y, line.end.y) / layerHeight);
|
var min = Math.ceil(Math.min(line.start.y, line.end.y) / layerHeight);
|
||||||
var max = Math.floor(Math.max(line.start.y, line.end.y) / layerHeight);
|
var max = Math.floor(Math.max(line.start.y, line.end.y) / layerHeight);
|
||||||
@ -179,7 +179,7 @@ D3D.Slicer.prototype.slice = function (layerHeight, height) {
|
|||||||
var intersections = [];
|
var intersections = [];
|
||||||
for (var i = 0; i < layerIntersections.length; i ++) {
|
for (var i = 0; i < layerIntersections.length; i ++) {
|
||||||
var index = layerIntersections[i];
|
var index = layerIntersections[i];
|
||||||
var line = this.lines[index].line;
|
var line = this._lines[index].line;
|
||||||
|
|
||||||
if (line.start.y === line.end.y) {
|
if (line.start.y === line.end.y) {
|
||||||
var x = line.start.x;
|
var x = line.start.x;
|
||||||
@ -195,9 +195,9 @@ D3D.Slicer.prototype.slice = function (layerHeight, height) {
|
|||||||
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
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,37 +213,37 @@ D3D.Slicer.prototype.slice = function (layerHeight, height) {
|
|||||||
done.push(index);
|
done.push(index);
|
||||||
|
|
||||||
var intersection = intersections[index];
|
var intersection = intersections[index];
|
||||||
//uppercase X and Y because data goes to clipper
|
//uppercase X and Y because clipper vector
|
||||||
shape.push({X: intersection.x, Y: intersection.y});
|
shape.push({X: intersection.x, Y: intersection.y});
|
||||||
|
|
||||||
var connects = this.lines[index].connects.clone();
|
var connects = this._lines[index].connects.clone();
|
||||||
var faceNormals = this.lines[index].normals.clone();
|
var faceNormals = this._lines[index].normals.clone();
|
||||||
for (var j = 0; j < connects.length; j ++) {
|
for (var j = 0; j < connects.length; j ++) {
|
||||||
index = connects[j];
|
index = connects[j];
|
||||||
|
|
||||||
if (intersections[index] !== undefined && done.indexOf(index) === -1) {
|
if (intersections[index] !== undefined && done.indexOf(index) === -1) {
|
||||||
|
|
||||||
var a = new THREE.Vector2(intersection.x, intersection.y);
|
var a = new THREE.Vector2(intersection.x, intersection.y);
|
||||||
var b = intersections[index];
|
var b = new THREE.Vector2(intersections[index].x, intersections[index].y);
|
||||||
|
|
||||||
var faceNormal = faceNormals[Math.floor(j/2)];
|
var faceNormal = faceNormals[Math.floor(j/2)];
|
||||||
|
|
||||||
if (a.distanceTo(b) === 0 || faceNormal.length() === 0) {
|
if (a.distanceTo(b) === 0 || faceNormal.length() === 0) {
|
||||||
done.push(index);
|
done.push(index);
|
||||||
|
|
||||||
connects = connects.concat(this.lines[index].connects);
|
connects = connects.concat(this._lines[index].connects);
|
||||||
faceNormals = faceNormals.concat(this.lines[index].normals);
|
faceNormals = faceNormals.concat(this._lines[index].normals);
|
||||||
index = -1;
|
index = -1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var normal = a.sub(b).normal().normalize();
|
var normal = a.sub(b).normal().normalize();
|
||||||
|
|
||||||
//if (normal.dot(faceNormal) > 0) {
|
if (normal.dot(faceNormal) > 0) {
|
||||||
break;
|
break;
|
||||||
//}
|
}
|
||||||
//else {
|
else {
|
||||||
// index = -1;
|
index = -1;
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -289,7 +289,7 @@ D3D.Slicer.prototype.slice = function (layerHeight, height) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.progress.sliceLayer = layer;
|
this.progress.sliceLayer = layer;
|
||||||
this.updateProgress();
|
this._updateProgress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -297,12 +297,12 @@ D3D.Slicer.prototype.slice = function (layerHeight, height) {
|
|||||||
|
|
||||||
return slices;
|
return slices;
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype.generateInnerLines = function (slices, printer) {
|
D3D.Slicer.prototype._generateInnerLines = function (slices, printer) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
console.log("generating outer lines and inner lines");
|
console.log("generating outer lines and inner lines");
|
||||||
|
|
||||||
//need to scale up everything because of clipper rounding
|
//need to scale up everything because of clipper rounding errors
|
||||||
var scale = 100;
|
var scale = 100;
|
||||||
|
|
||||||
var layerHeight = printer.config["layerHeight"];
|
var layerHeight = printer.config["layerHeight"];
|
||||||
@ -335,12 +335,12 @@ D3D.Slicer.prototype.generateInnerLines = function (slices, printer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype.generateInfills = function (slices, printer) {
|
D3D.Slicer.prototype._generateInfills = function (slices, printer) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
console.log("generating infills");
|
console.log("generating infills");
|
||||||
|
|
||||||
//need to scale up everything because of clipper rounding
|
//need to scale up everything because of clipper rounding errors
|
||||||
var scale = 100;
|
var scale = 100;
|
||||||
|
|
||||||
var layerHeight = printer.config["layerHeight"];
|
var layerHeight = printer.config["layerHeight"];
|
||||||
@ -349,6 +349,7 @@ D3D.Slicer.prototype.generateInfills = function (slices, printer) {
|
|||||||
var topThickness = printer.config["topThickness"];
|
var topThickness = printer.config["topThickness"];
|
||||||
var nozzleDiameter = printer.config["nozzleDiameter"] * scale;
|
var nozzleDiameter = printer.config["nozzleDiameter"] * scale;
|
||||||
var infillOverlap = printer.config["infillOverlap"] * scale;
|
var infillOverlap = printer.config["infillOverlap"] * scale;
|
||||||
|
|
||||||
var bottomSkinCount = Math.ceil(bottomThickness/layerHeight);
|
var bottomSkinCount = Math.ceil(bottomThickness/layerHeight);
|
||||||
var topSkinCount = Math.ceil(topThickness/layerHeight);
|
var topSkinCount = Math.ceil(topThickness/layerHeight);
|
||||||
var nozzleRadius = nozzleDiameter / 2;
|
var nozzleRadius = nozzleDiameter / 2;
|
||||||
@ -357,8 +358,6 @@ D3D.Slicer.prototype.generateInfills = function (slices, printer) {
|
|||||||
for (var layer = 0; layer < slices.length; layer ++) {
|
for (var layer = 0; layer < slices.length; layer ++) {
|
||||||
var slice = slices[layer];
|
var slice = slices[layer];
|
||||||
|
|
||||||
console.log(layer + topSkinCount < slices.length);
|
|
||||||
|
|
||||||
if (layer - bottomSkinCount >= 0 && layer + topSkinCount < slices.length) {
|
if (layer - bottomSkinCount >= 0 && layer + topSkinCount < slices.length) {
|
||||||
var downSkin = slices[layer - bottomSkinCount].getOutline();
|
var downSkin = slices[layer - bottomSkinCount].getOutline();
|
||||||
var upSkin = slices[layer + topSkinCount].getOutline();
|
var upSkin = slices[layer + topSkinCount].getOutline();
|
||||||
@ -388,7 +387,7 @@ D3D.Slicer.prototype.generateInfills = function (slices, printer) {
|
|||||||
|
|
||||||
if (lowFillArea.length > 0) {
|
if (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);
|
||||||
|
|
||||||
part.fill.join(lowFillTemplate.intersect(lowFillArea));
|
part.fill.join(lowFillTemplate.intersect(lowFillArea));
|
||||||
}
|
}
|
||||||
@ -396,7 +395,7 @@ D3D.Slicer.prototype.generateInfills = function (slices, printer) {
|
|||||||
if (highFillArea.length > 0) {
|
if (highFillArea.length > 0) {
|
||||||
var bounds = highFillArea.bounds();
|
var bounds = highFillArea.bounds();
|
||||||
var even = (layer % 2 === 0);
|
var even = (layer % 2 === 0);
|
||||||
var highFillTemplate = this.getFillTemplate(bounds, hightemplateSize, even, !even);
|
var highFillTemplate = this._getFillTemplate(bounds, hightemplateSize, even, !even);
|
||||||
|
|
||||||
part.fill.join(highFillTemplate.intersect(highFillArea));
|
part.fill.join(highFillTemplate.intersect(highFillArea));
|
||||||
}
|
}
|
||||||
@ -404,15 +403,15 @@ D3D.Slicer.prototype.generateInfills = function (slices, printer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.progress.dataLayer = layer;
|
this.progress.dataLayer = layer;
|
||||||
this.updateProgress();
|
this._updateProgress();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype.generateSupport = function (slices, printer) {
|
D3D.Slicer.prototype._generateSupport = function (slices, printer) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
console.log("generating support");
|
console.log("generating support");
|
||||||
|
|
||||||
//need to scale up everything because of clipper rounding
|
//need to scale up everything because of clipper rounding errors
|
||||||
var scale = 100;
|
var scale = 100;
|
||||||
|
|
||||||
var layerHeight = printer.config["layerHeight"];
|
var layerHeight = printer.config["layerHeight"];
|
||||||
@ -441,12 +440,12 @@ D3D.Slicer.prototype.generateSupport = function (slices, printer) {
|
|||||||
if (layer === 0) {
|
if (layer === 0) {
|
||||||
supportAreas = supportAreas.offset(plateSize).difference(sliceSkin);
|
supportAreas = supportAreas.offset(plateSize).difference(sliceSkin);
|
||||||
|
|
||||||
var template = this.getFillTemplate(supportAreas.bounds(), nozzleDiameter, true, false);
|
var template = this._getFillTemplate(supportAreas.bounds(), nozzleDiameter, true, false);
|
||||||
|
|
||||||
currentSlice.support = template.intersect(supportAreas);
|
currentSlice.support = template.intersect(supportAreas);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var supportTemplate = this.getFillTemplate(supportAreas.bounds(), supportGridSize, true, true);
|
var supportTemplate = this._getFillTemplate(supportAreas.bounds(), supportGridSize, true, true);
|
||||||
|
|
||||||
currentSlice.support = supportTemplate.intersect(supportAreas).join(supportAreas.clone());
|
currentSlice.support = supportTemplate.intersect(supportAreas).join(supportAreas.clone());
|
||||||
}
|
}
|
||||||
@ -468,12 +467,12 @@ D3D.Slicer.prototype.generateSupport = function (slices, printer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype.optimizePaths = function (slices, printer) {
|
D3D.Slicer.prototype._optimizePaths = function (slices, printer) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
console.log("opimize paths");
|
console.log("opimize paths");
|
||||||
|
|
||||||
//need to scale up everything because of clipper rounding
|
//need to scale up everything because of clipper rounding errors
|
||||||
var scale = 100;
|
var scale = 100;
|
||||||
|
|
||||||
var brimOffset = printer.config["brimOffset"] * scale;
|
var brimOffset = printer.config["brimOffset"] * scale;
|
||||||
@ -508,7 +507,7 @@ D3D.Slicer.prototype.optimizePaths = function (slices, printer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
D3D.Slicer.prototype.getFillTemplate = function (bounds, size, even, uneven) {
|
D3D.Slicer.prototype._getFillTemplate = function (bounds, size, even, uneven) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var paths = new D3D.Paths([], false);
|
var paths = new D3D.Paths([], false);
|
||||||
@ -539,7 +538,7 @@ D3D.Slicer.prototype.getFillTemplate = function (bounds, size, even, uneven) {
|
|||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
};
|
};
|
||||||
D3D.Slicer.prototype.slicesToGCode = function (slices, printer) {
|
D3D.Slicer.prototype._slicesToGCode = function (slices, printer) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var gcode = new D3D.GCode().setSettings(printer);
|
var gcode = new D3D.GCode().setSettings(printer);
|
||||||
@ -602,7 +601,7 @@ D3D.Slicer.prototype.slicesToGCode = function (slices, printer) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.progress.gcodeLayer = layer;
|
this.progress.gcodeLayer = layer;
|
||||||
this.updateProgress();
|
this._updateProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
return gcode.getGCode();
|
return gcode.getGCode();
|
||||||
|
@ -66,7 +66,7 @@ Sidebar.Slicer = function ( editor ) {
|
|||||||
currentLine.setValue(data["current_line"]);
|
currentLine.setValue(data["current_line"]);
|
||||||
bufferedLines.setValue(data["buffered_lines"]);
|
bufferedLines.setValue(data["buffered_lines"]);
|
||||||
totalLines.setValue(data["total_lines"]);
|
totalLines.setValue(data["total_lines"]);
|
||||||
printBatches.setValue(doodleBox.printBatches.length);
|
printBatches.setValue(doodleBox._printBatches.length);
|
||||||
};
|
};
|
||||||
|
|
||||||
var printerTypeRow = new UI.Panel();
|
var printerTypeRow = new UI.Panel();
|
||||||
|
Loading…
Reference in New Issue
Block a user