mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-16 19:17:57 +01:00
init
slicing works; produces errors though
This commit is contained in:
parent
5e43789f82
commit
d9869634c7
@ -103,7 +103,7 @@ var geometry = (function () {
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
var material = new THREE.MeshLambertMaterial({color: 0x000000, wireframe: true});
|
var material = new THREE.MeshLambertMaterial({color: 0x000000, wireframe: true});
|
||||||
//var geometry = new THREE.TorusGeometry(20, 10, 30, 30);
|
var geometry = new THREE.TorusGeometry(20, 10, 30, 30);
|
||||||
//var geometry = new THREE.BoxGeometry(20, 5, 20, 1, 1, 1);
|
//var geometry = new THREE.BoxGeometry(20, 5, 20, 1, 1, 1);
|
||||||
//var geometry = new THREE.SphereGeometry(10, 10, 10);
|
//var geometry = new THREE.SphereGeometry(10, 10, 10);
|
||||||
var mesh = new THREE.Mesh(geometry, material);
|
var mesh = new THREE.Mesh(geometry, material);
|
||||||
@ -119,9 +119,9 @@ gcode = slicer.getGcode(printer);
|
|||||||
var canvas = document.getElementById("canvas");
|
var canvas = document.getElementById("canvas");
|
||||||
var context = canvas.getContext("2d");
|
var context = canvas.getContext("2d");
|
||||||
|
|
||||||
var layer = 149;
|
//var layer = 0;
|
||||||
var img = slicer.drawPaths(printer, layer, layer + 1);
|
//var img = slicer.drawPaths(printer, layer, layer + 1);
|
||||||
context.drawImage(img, 0, 0);
|
//context.drawImage(img, 0, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var loader = new THREE.STLLoader();
|
var loader = new THREE.STLLoader();
|
||||||
|
39
src/box.js
39
src/box.js
@ -59,8 +59,8 @@ D3D.Box.prototype.update = 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.progress["buffered_lines"] + this.batchSize) <= this.maxBufferedLines) {
|
if (this.printBatches.length > 0 && (this.printer.status["buffered_lines"] + this.batchSize) <= this.maxBufferedLines) {
|
||||||
if (this.printBatches.length > 0 ) {
|
//if (this.printBatches.length > 0 ) {
|
||||||
this.printBatch();
|
this.printBatch();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -142,6 +142,7 @@ D3D.Box.prototype.stopPrint = function () {
|
|||||||
];
|
];
|
||||||
|
|
||||||
this.setPrinterStop({
|
this.setPrinterStop({
|
||||||
|
//"gcode": {}
|
||||||
"gcode": finishMove.join("\n")
|
"gcode": finishMove.join("\n")
|
||||||
}, function (data) {
|
}, function (data) {
|
||||||
console.log("Printer stop command sent");
|
console.log("Printer stop command sent");
|
||||||
@ -153,19 +154,20 @@ D3D.Box.prototype.stopPrint = function () {
|
|||||||
//COMMUNICATION SHELL
|
//COMMUNICATION SHELL
|
||||||
//see http://www.doodle3d.com/help/api-documentation
|
//see http://www.doodle3d.com/help/api-documentation
|
||||||
D3D.Box.prototype.getConfig = function (keys, callback) {
|
D3D.Box.prototype.getConfig = function (keys, callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "config/?" + keys.join("=&") + "=", callback);
|
getAPI(this.api + "config/?" + keys.join("=&") + "=", callback);
|
||||||
|
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getConfigAll = function (callback) {
|
D3D.Box.prototype.getConfigAll = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "config/all", callback);
|
getAPI(this.api + "config/all", callback);
|
||||||
|
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.setConfig = function (data, callback) {
|
D3D.Box.prototype.setConfig = function (data, callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
@ -186,13 +188,13 @@ D3D.Box.prototype.setConfig = function (data, callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getInfo = function (callback) {
|
D3D.Box.prototype.getInfo = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "info", callback);
|
getAPI(this.api + "info", callback);
|
||||||
|
|
||||||
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getInfoStatus = function (callback) {
|
D3D.Box.prototype.getInfoStatus = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "info/status", callback);
|
getAPI(this.api + "info/status", callback);
|
||||||
@ -207,7 +209,6 @@ D3D.Box.prototype.downloadInfoLogFiles = function () {
|
|||||||
window.location = this.api + "info/logfiles";
|
window.location = this.api + "info/logfiles";
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getInfoAcces = function (callback) {
|
D3D.Box.prototype.getInfoAcces = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "info/access", callback);
|
getAPI(this.api + "info/access", callback);
|
||||||
@ -215,7 +216,6 @@ D3D.Box.prototype.getInfoAcces = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getNetworkScan = function (callback) {
|
D3D.Box.prototype.getNetworkScan = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "network/scan", callback);
|
getAPI(this.api + "network/scan", callback);
|
||||||
@ -223,7 +223,6 @@ D3D.Box.prototype.getNetworkScan = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getNetworkKnown = function (callback) {
|
D3D.Box.prototype.getNetworkKnown = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "network/known", callback);
|
getAPI(this.api + "network/known", callback);
|
||||||
@ -231,7 +230,6 @@ D3D.Box.prototype.getNetworkKnown = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getNetworkStatus = function (callback) {
|
D3D.Box.prototype.getNetworkStatus = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "network/status", callback);
|
getAPI(this.api + "network/status", callback);
|
||||||
@ -239,7 +237,6 @@ D3D.Box.prototype.getNetworkStatus = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.setNetworkAssosiate = function (data, callback) {
|
D3D.Box.prototype.setNetworkAssosiate = function (data, callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
sendAPI(this.api + "network/associate", data, callback);
|
sendAPI(this.api + "network/associate", data, callback);
|
||||||
@ -263,17 +260,15 @@ D3D.Box.prototype.setNetworkOpenAP = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.setNetworkRemove = function (ssid, callback) {
|
D3D.Box.prototype.setNetworkRemove = function (ssid, callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
sendAPI(this.api + "network/remove", {
|
sendAPI(this.api + "network/remove", {
|
||||||
ssid: ssid
|
"ssid": ssid
|
||||||
}, callback);
|
}, callback);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getNetworkSignin = function (callback) {
|
D3D.Box.prototype.getNetworkSignin = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "network/signin", callback);
|
getAPI(this.api + "network/signin", callback);
|
||||||
@ -281,7 +276,6 @@ D3D.Box.prototype.getNetworkSignin = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getNetworkAlive = function (callback) {
|
D3D.Box.prototype.getNetworkAlive = function (callback) {
|
||||||
//works but returns empty array
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "network/alive", callback);
|
getAPI(this.api + "network/alive", callback);
|
||||||
@ -289,7 +283,6 @@ D3D.Box.prototype.getNetworkAlive = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getPrinterTemperature = function (callback) {
|
D3D.Box.prototype.getPrinterTemperature = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "printer/temperature", callback);
|
getAPI(this.api + "printer/temperature", callback);
|
||||||
@ -297,7 +290,6 @@ D3D.Box.prototype.getPrinterTemperature = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getPrinterProgress = function (callback) {
|
D3D.Box.prototype.getPrinterProgress = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "printer/progress", callback);
|
getAPI(this.api + "printer/progress", callback);
|
||||||
@ -305,7 +297,6 @@ D3D.Box.prototype.getPrinterProgress = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getPrinterState = function (callback) {
|
D3D.Box.prototype.getPrinterState = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "printer/state", callback);
|
getAPI(this.api + "printer/state", callback);
|
||||||
@ -313,7 +304,6 @@ D3D.Box.prototype.getPrinterState = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getPrinterListAll = function (callback) {
|
D3D.Box.prototype.getPrinterListAll = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "printer/listall", callback);
|
getAPI(this.api + "printer/listall", callback);
|
||||||
@ -321,7 +311,6 @@ D3D.Box.prototype.getPrinterListAll = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.setPrinterHeatup = function (callback) {
|
D3D.Box.prototype.setPrinterHeatup = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
sendAPI(this.api + "printer/heatup", {}, callback);
|
sendAPI(this.api + "printer/heatup", {}, callback);
|
||||||
@ -329,7 +318,6 @@ D3D.Box.prototype.setPrinterHeatup = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.setPrinterPrint = function (data, callback) {
|
D3D.Box.prototype.setPrinterPrint = function (data, callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
sendAPI(this.api + "printer/print", data, callback);
|
sendAPI(this.api + "printer/print", data, callback);
|
||||||
@ -337,7 +325,6 @@ D3D.Box.prototype.setPrinterPrint = function (data, callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.setPrinterStop = function (data, callback) {
|
D3D.Box.prototype.setPrinterStop = function (data, callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
sendAPI(this.api + "printer/stop", data, callback);
|
sendAPI(this.api + "printer/stop", data, callback);
|
||||||
@ -345,7 +332,6 @@ D3D.Box.prototype.setPrinterStop = function (data, callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getSketch = function (id, callback) {
|
D3D.Box.prototype.getSketch = function (id, callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "sketch/?id=" + id, callback);
|
getAPI(this.api + "sketch/?id=" + id, callback);
|
||||||
@ -353,7 +339,6 @@ D3D.Box.prototype.getSketch = function (id, callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.setSketch = function (data, callback) {
|
D3D.Box.prototype.setSketch = function (data, callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
sendAPI(this.api + "sketch", {
|
sendAPI(this.api + "sketch", {
|
||||||
@ -363,7 +348,6 @@ D3D.Box.prototype.setSketch = function (data, callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getSketchStatus = function (callback) {
|
D3D.Box.prototype.getSketchStatus = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "sketch/status", callback);
|
getAPI(this.api + "sketch/status", callback);
|
||||||
@ -371,7 +355,6 @@ D3D.Box.prototype.getSketchStatus = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.setSketchClear = function (callback) {
|
D3D.Box.prototype.setSketchClear = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
sendAPI(this.api + "sketch/clear", callback);
|
sendAPI(this.api + "sketch/clear", callback);
|
||||||
@ -379,7 +362,6 @@ D3D.Box.prototype.setSketchClear = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getSystemVersions = function (callback) {
|
D3D.Box.prototype.getSystemVersions = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "system/fwversions", callback);
|
getAPI(this.api + "system/fwversions", callback);
|
||||||
@ -387,7 +369,6 @@ D3D.Box.prototype.getSystemVersions = function (callback) {
|
|||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
D3D.Box.prototype.getUpdateStatus = function (callback) {
|
D3D.Box.prototype.getUpdateStatus = function (callback) {
|
||||||
//works
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
getAPI(this.api + "update/status", callback);
|
getAPI(this.api + "update/status", callback);
|
||||||
|
@ -87,39 +87,48 @@ D3D.Slicer.prototype.createLines = function () {
|
|||||||
D3D.Slicer.prototype.slice = function (height, step) {
|
D3D.Slicer.prototype.slice = function (height, step) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
//something for optimalization...
|
||||||
|
var layersIntersections = [];
|
||||||
|
|
||||||
|
for (var i = 0; i < this.lines.length; i ++) {
|
||||||
|
var line = this.lines[i];
|
||||||
|
|
||||||
|
var min = Math.ceil(Math.min(line.line.start.y, line.line.end.y) / step);
|
||||||
|
var max = Math.floor(Math.max(line.line.start.y, line.line.end.y) / step);
|
||||||
|
|
||||||
|
for (var layerIndex = min; layerIndex < max; layerIndex ++) {
|
||||||
|
if (layerIndex >= 0) {
|
||||||
|
if (layersIntersections[layerIndex] === undefined) {
|
||||||
|
layersIntersections[layerIndex] = [];
|
||||||
|
}
|
||||||
|
layersIntersections[layerIndex].push(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var slices = [];
|
var slices = [];
|
||||||
|
|
||||||
var plane = new THREE.Plane();
|
var plane = new THREE.Plane();
|
||||||
|
|
||||||
for (var z = 0; z < height; z += step) {
|
for (var layer = 1; layer < layersIntersections.length; layer ++) {
|
||||||
|
var layerIntersections = layersIntersections[layer];
|
||||||
|
var z = layer*step;
|
||||||
plane.set(new THREE.Vector3(0, -1, 0), z);
|
plane.set(new THREE.Vector3(0, -1, 0), z);
|
||||||
|
|
||||||
var slice = [];
|
|
||||||
|
|
||||||
var intersections = [];
|
var intersections = [];
|
||||||
|
for (var i = 0; i < layerIntersections.length; i ++) {
|
||||||
for (var i = 0; i < this.lines.length; i ++) {
|
var index = layerIntersections[i];
|
||||||
var line = this.lines[i].line;
|
var line = this.lines[index].line;
|
||||||
|
|
||||||
var intersection = plane.intersectLine(line);
|
var intersection = plane.intersectLine(line);
|
||||||
|
intersections[index] = new THREE.Vector2(intersection.x + 100, intersection.z + 100);
|
||||||
if (intersection !== undefined) {
|
|
||||||
//remove +100 when implimenting good structure for geometry is complete
|
|
||||||
var point = new THREE.Vector2(intersection.x + 100, intersection.z + 100);
|
|
||||||
|
|
||||||
intersections.push(point);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
intersections.push(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var done = [];
|
var done = [];
|
||||||
for (var i = 0; i < intersections.length; i ++) {
|
var slice = [];
|
||||||
|
for (var i = 0; i < layerIntersections.length; i ++) {
|
||||||
if (intersections[i] && done.indexOf(i) === -1) {
|
var index = layerIntersections[i];
|
||||||
var index = i;
|
|
||||||
|
|
||||||
|
if (done.indexOf(index) === -1) {
|
||||||
var shape = [];
|
var shape = [];
|
||||||
|
|
||||||
while (index !== -1) {
|
while (index !== -1) {
|
||||||
@ -444,8 +453,11 @@ D3D.Slicer.prototype.drawPaths = function (printer, min, max) {
|
|||||||
context.stroke();
|
context.stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var start = new Date().getTime();
|
||||||
var slices = this.slice(dimensionsZ, layerHeight);
|
var slices = this.slice(dimensionsZ, layerHeight);
|
||||||
slices.shift();
|
slices.shift();
|
||||||
|
var end = new Date().getTime();
|
||||||
|
console.log(end - start);
|
||||||
|
|
||||||
var data = this.slicesToData(slices, printer);
|
var data = this.slicesToData(slices, printer);
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ function sendAPI (url, data, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
console.warn("failed connecting to " + url);
|
console.warn("Failed connecting to " + url);
|
||||||
sendAPI(url, data, callback);
|
sendAPI(url, data, callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ function getAPI (url, callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
console.warn("failed connecting to " + url);
|
console.warn("Failed connecting to " + url);
|
||||||
getAPI(url, callback);
|
getAPI(url, callback);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user