fixed look up function

This commit is contained in:
casperlamboo 2015-05-01 11:03:07 +02:00
parent d33f0d336c
commit d7dfdb62d9
3 changed files with 50 additions and 40 deletions

View File

@ -16,7 +16,7 @@ doodleBox.onload = function () {
var geometry = new THREE.TorusGeometry(40, 20, 10, 10); var geometry = new THREE.TorusGeometry(40, 20, 10, 10);
var slicer = new D3D.Slicer().setGeometry(geometry); var slicer = new D3D.Slicer().setGeometry(geometry);
var gcode = slicer.getGcode(doodlBox.printer); var gcode = slicer.getGcode(doodleBox.printer);
doodleBox.print(gcode); doodleBox.print(gcode);
}; };

View File

@ -25,15 +25,17 @@ canvas {border: 1px solid black;}
<canvas id="canvas" width="400" height="400"></canvas> <canvas id="canvas" width="400" height="400"></canvas>
<script> <script>
//nieuwe config
//geimplimenteerd worden in de doodlebox?
var printerConfig = { var printerConfig = {
"printer.baudrate": "115200", "printer.baudrate": "115200", //wat is dit?
"printer.bed.temperature": 70, "printer.bed.temperature": 70,
"printer.bottomFlowRate": 1.0, "printer.bottomFlowRate": 1.0,
"printer.bottomLayerSpeed": 35, "printer.bottomLayerSpeed": 35,
"printer.dimensions.x": 200, "printer.dimensions.x": 200,
"printer.dimensions.y": 200, "printer.dimensions.y": 200,
"printer.dimensions.z": 200, "printer.dimensions.z": 200,
"printer.enableTraveling": true, "printer.enableTraveling": true, //wat is dit?
"printer.endcode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)", "printer.endcode": "M107 ;fan off\nG91 ;relative positioning\nG1 E-1 F300 ;retract the filament a bit before lifting the nozzle, to release some of the pressure\nG1 Z+0.5 E-5 X-20 Y-20 F9000 ;move Z up a bit and retract filament even more\nG28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way\nM84 ;disable axes / steppers\nG90 ;absolute positioning\nM104 S{preheatTemp}\n{if heatedBed}M140 S{preheatBedTemp}\nM117 Done ;display message (20 characters to clear whole screen)",
"printer.filamentThickness": 2.89, "printer.filamentThickness": 2.89,
"printer.firstLayerSlow": true, "printer.firstLayerSlow": true,
@ -52,8 +54,15 @@ var printerConfig = {
"printer.temperature": 230, "printer.temperature": 230,
"printer.travelSpeed": 200, "printer.travelSpeed": 200,
"printer.type": "ultimaker", "printer.type": "ultimaker",
"printer.useSubLayers": true, "printer.useSubLayers": true, //wat is dit?
"printer.wallThickness": 0.5 "printer.wallThickness": 0.4,
//variabele toevoegen;
//overleg met rick;
//-snelheid, retraction etc voor verschillende types (outerlayer, innerlayer, fill)
"printer.shellThickness": 0.8,
"printer.fillSize": 5, //dit is het raster aan de binnen kant van de geometry
"printer.brimOffset": 5
}; };
var printer = new D3D.Printer(printerConfig); var printer = new D3D.Printer(printerConfig);
@ -94,8 +103,8 @@ 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(40, 20, 10, 10); var geometry = new THREE.TorusGeometry(20, 10, 10, 10);
var geometry = new THREE.BoxGeometry(20, 10, 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);
scene.add(mesh); scene.add(mesh);
@ -110,7 +119,8 @@ var slicer = new D3D.Slicer().setGeometry(geometry);
var gcode = slicer.getGcode(printer); var gcode = slicer.getGcode(printer);
/*var canvas = document.getElementById("canvas"); /*
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d"); var context = canvas.getContext("2d");
function drawPolygons (paths, color) { function drawPolygons (paths, color) {
@ -123,26 +133,33 @@ function drawPolygons (paths, color) {
for (var i = 0; i < paths.length; i ++) { for (var i = 0; i < paths.length; i ++) {
var path = paths[i]; var path = paths[i];
context.moveTo((path[0].X- 100) * 8.0 + 200, (path[0].Y- 100) * 8.0 + 200); context.moveTo((path[0].X- 100) * 6.0 + 200, (path[0].Y- 100) * 6.0 + 200);
for (var j = 0; j < path.length; j ++) { for (var j = 0; j < path.length; j ++) {
var point = path[j]; var point = path[j];
context.lineTo((point.X- 100) * 8.0 + 200, (point.Y- 100) * 8.0 + 200); context.lineTo((point.X- 100) * 6.0 + 200, (point.Y- 100) * 6.0 + 200);
} }
context.closePath(); context.closePath();
} }
context.stroke(); context.stroke();
} }
for (var layer = 0; layer < gcode.length; layer ++) { var layer = 0;
setInterval(function () {
context.clearRect(0, 0, 400, 400);
//for (var layer = 0; layer < gcode.length; layer ++) {
//var layer = 31; //var layer = 31;
var slice = gcode[layer]; var slice = gcode[layer % gcode.length];
drawPolygons(slice.outerLayer, "red"); //drawPolygons(slice.outerLayer, "red");
drawPolygons(slice.innerLayer, "green"); //drawPolygons(slice.innerLayer, "green");
drawPolygons(slice.fill, "blue"); drawPolygons(slice.fill, "blue");
}*/
context.fillText("layer: " + layer, 10, 10);
//}
layer ++;
}, 100);
*/
(function animate () { (function animate () {
"use strict"; "use strict";

View File

@ -199,26 +199,24 @@ D3D.Slicer.prototype.getFillTemplate = function (dimension, size, even, uneven)
D3D.Slicer.prototype.slicesToData = function (slices, printer) { D3D.Slicer.prototype.slicesToData = function (slices, printer) {
"use strict"; "use strict";
var data = [];
//scale because of clipper crap //scale because of clipper crap
var scale = 100; var scale = 100;
var layerHeight = printer.config["printer.layerHeight"] * scale; var layerHeight = printer.config["printer.layerHeight"] * scale;
var dimensionsZ = printer.config["printer.dimensions.z"] * scale; var dimensionsZ = printer.config["printer.dimensions.z"] * scale;
//variables should come from config var wallThickness = printer.config["printer.wallThickness"] * scale;
//aan rick voorleggen var shellThickness = printer.config["printer.shellThickness"] * scale;
var nozzleSize = 0.4 * scale; var fillSize = printer.config["printer.fillSize"] * scale;
var shellThickness = 0.8 * scale; var brimOffset = printer.config["printer.brimOffset"] * scale;
var fillSize = 5 * scale;
var brimOffset = 5 * scale; var data = [];
var lowFillTemplate = this.getFillTemplate(dimensionsZ, fillSize, true, true); var lowFillTemplate = this.getFillTemplate(dimensionsZ, fillSize, true, true);
for (var layer = 0; layer < slices.length; layer ++) { for (var layer = 0; layer < slices.length; layer ++) {
var slice = slices[layer]; var slice = slices[layer];
var highFillTemplate = this.getFillTemplate(dimensionsZ, nozzleSize, (layer % 2 === 0), (layer % 2 === 1));
var highFillTemplate = this.getFillTemplate(dimensionsZ, wallThickness, (layer % 2 === 0), (layer % 2 === 1));
//var outerLayer = ClipperLib.JS.Clean(slice, 1.0); //var outerLayer = ClipperLib.JS.Clean(slice, 1.0);
var outerLayer = slice.clone(); var outerLayer = slice.clone();
@ -226,17 +224,17 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
var innerLayer = []; var innerLayer = [];
for (var i = nozzleSize; i < shellThickness; i += nozzleSize) { for (var i = wallThickness; i < shellThickness; i += wallThickness) {
var inset = this.getInset(outerLayer, i); var inset = this.getInset(outerLayer, i);
innerLayer = innerLayer.concat(inset); innerLayer = innerLayer.concat(inset);
} }
var fillArea = this.getInset((inset || outerLayer), nozzleSize); var fillArea = this.getInset((inset || outerLayer), wallThickness);
var highFill; var highFill;
var fillAbove; var fillAbove = undefined;
for (var i = 1; i < shellThickness/layerHeight; i ++) { for (var i = 1; i < shellThickness/layerHeight; i ++) {
var newLayer = ClipperLib.JS.Clone(slices[layer + i]); var newLayer = ClipperLib.JS.Clone(slices[layer + i]);
ClipperLib.JS.ScaleUpPaths(newLayer, scale); ClipperLib.JS.ScaleUpPaths(newLayer, scale);
@ -247,21 +245,16 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
break; break;
} }
else if (fillAbove === undefined) { else if (fillAbove === undefined) {
}
else {
}
if (fillAbove === undefined) {
fillAbove = newLayer; fillAbove = newLayer;
} }
else { else {
// var c = new ClipperLib.Clipper(); var c = new ClipperLib.Clipper();
// var solution = new ClipperLib.Paths(); var solution = new ClipperLib.Paths();
// c.AddPaths(fillArea, ClipperLib.PolyType.ptSubject, true); c.AddPaths(fillArea, ClipperLib.PolyType.ptSubject, true);
// c.AddPaths(fillAbove, ClipperLib.PolyType.ptClip, true); c.AddPaths(fillAbove, ClipperLib.PolyType.ptClip, true);
// c.Execute(ClipperLib.ClipType.ctDifference, solution); c.Execute(ClipperLib.ClipType.ctIntersection, solution);
fillAbove = solution;
} }
} }
//kijkt alleen nog naar boven //kijkt alleen nog naar boven