mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-19 04:27:55 +01:00
clean up files
This commit is contained in:
parent
5bb67cd788
commit
882f885d97
143
slice_test.html
143
slice_test.html
@ -25,49 +25,41 @@ canvas {border: 1px solid black;}
|
||||
<canvas id="canvas" width="400" height="400"></canvas>
|
||||
|
||||
<script>
|
||||
var localIp = location.hash.substring(1);
|
||||
var doodleBox = new D3D.Box(localIp);
|
||||
var printerConfig = {
|
||||
"printer.baudrate": "115200",
|
||||
"printer.bed.temperature": 70,
|
||||
"printer.bottomFlowRate": 1.0,
|
||||
"printer.bottomLayerSpeed": 35,
|
||||
"printer.dimensions.x": 200,
|
||||
"printer.dimensions.y": 200,
|
||||
"printer.dimensions.z": 200,
|
||||
"printer.enableTraveling": true,
|
||||
"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.firstLayerSlow": true,
|
||||
"printer.heatedbed": false,
|
||||
"printer.heatup.bed.temperature": 70,
|
||||
"printer.heatup.enabled": true,
|
||||
"printer.heatup.temperature": 180,
|
||||
"printer.layerHeight": 0.3,
|
||||
"printer.retraction.amount": 3,
|
||||
"printer.retraction.enabled": true,
|
||||
"printer.retraction.minDistance": 5,
|
||||
"printer.retraction.speed": 50,
|
||||
"printer.screenToMillimeterScale": 0.3,
|
||||
"printer.speed": 70,
|
||||
"printer.startcode": ";Generated with Doodle3D (default)\nM109 S{printingTemp} ;set target temperature \n{if heatedBed}M190 S{printingBedTemp} ;set target bed temperature\nG21 ;metric values\nG91 ;relative positioning\nM107 ;start with the fan off\nG28 X0 Y0 ;move X/Y to min endstops\nG28 Z0 ;move Z to min endstops\nG1 Z15 F9000 ;move the platform down 15mm\nG92 E0 ;zero the extruded length\nG1 F200 E10 ;extrude 10mm of feed stock\nG92 E0 ;zero the extruded length again\nG92 E0 ;zero the extruded length again\nG1 F9000\nG90 ;absolute positioning\nM117 Printing Doodle... ;display message (20 characters to clear whole screen)",
|
||||
"printer.temperature": 230,
|
||||
"printer.travelSpeed": 200,
|
||||
"printer.type": "ultimaker",
|
||||
"printer.useSubLayers": true,
|
||||
"printer.wallThickness": 0.5
|
||||
};
|
||||
|
||||
var gcode;
|
||||
doodleBox.onload = function () {
|
||||
doodleBox.printer.config["printer.bottomFlowRate"] = 1.0;
|
||||
doodleBox.printer.config["printer.layerHeight"] = 0.3;
|
||||
doodleBox.printer.config["printer.retraction.enabled"] = false;
|
||||
|
||||
gcode = slicer.getGcode(doodleBox.printer.config);
|
||||
|
||||
var canvas = document.getElementById("canvas");
|
||||
var context = canvas.getContext("2d");
|
||||
|
||||
function drawPolygons (paths, color) {
|
||||
context.fillStyle = color;
|
||||
context.strokeStyle = color;
|
||||
context.beginPath();
|
||||
|
||||
for (var i = 0; i < paths.length; i ++) {
|
||||
var path = paths[i];
|
||||
|
||||
context.moveTo((path[0].X- 100) * 8.0 + 200, (path[0].Y- 100) * 8.0 + 200);
|
||||
|
||||
for (var j = 0; j < path.length; j ++) {
|
||||
var point = path[j];
|
||||
context.lineTo((point.X- 100) * 8.0 + 200, (point.Y- 100) * 8.0 + 200);
|
||||
}
|
||||
context.closePath();
|
||||
}
|
||||
context.stroke();
|
||||
}
|
||||
|
||||
//for (var layer = 0; layer < gcode.length; layer ++) {
|
||||
var layer = 0;
|
||||
var slice = gcode[layer];
|
||||
|
||||
console.log(gcode.length);
|
||||
|
||||
drawPolygons(slice.outerLayer, "red");
|
||||
drawPolygons(slice.innerLayer, "green");
|
||||
drawPolygons(slice.fill, "blue");
|
||||
//}*/
|
||||
//var localIp = location.hash.substring(1);
|
||||
//var doodleBox = new D3D.Box(localIp);
|
||||
var doodleBox = {
|
||||
printer: new D3D.Printer(printerConfig)
|
||||
};
|
||||
|
||||
var scene = new THREE.Scene();
|
||||
@ -116,50 +108,41 @@ var context = canvas.getContext("2d");
|
||||
var slicer = new D3D.Slicer().setGeometry(geometry);
|
||||
//slicer.draw(1, context);
|
||||
|
||||
/*
|
||||
(function () {
|
||||
var slicer = new D3D.Slicer().setGeometry(geometry);
|
||||
var slices = slicer.slice(200, 0.2);
|
||||
slices.shift();
|
||||
//var slices = slicer.slice(1, 1);
|
||||
var gcode = slicer.getGcode(printerConfig);
|
||||
|
||||
CAL.Scene.setCanvas(document.getElementById("canvas"));
|
||||
var canvas = document.getElementById("canvas");
|
||||
var context = canvas.getContext("2d");
|
||||
|
||||
//error at layer 0;
|
||||
//maybe because of geomety
|
||||
function drawPolygons (paths, color) {
|
||||
context.fillStyle = color;
|
||||
context.strokeStyle = color;
|
||||
context.beginPath();
|
||||
|
||||
for (var i = 0; i < paths.length; i ++) {
|
||||
var path = paths[i];
|
||||
|
||||
context.moveTo((path[0].X- 100) * 8.0 + 200, (path[0].Y- 100) * 8.0 + 200);
|
||||
|
||||
for (var j = 0; j < path.length; j ++) {
|
||||
var point = path[j];
|
||||
context.lineTo((point.X- 100) * 8.0 + 200, (point.Y- 100) * 8.0 + 200);
|
||||
}
|
||||
context.closePath();
|
||||
}
|
||||
context.stroke();
|
||||
}
|
||||
|
||||
//for (var layer = 0; layer < gcode.length; layer ++) {
|
||||
var layer = 0;
|
||||
var slice = gcode[layer];
|
||||
|
||||
var shapes = [];
|
||||
console.log(gcode.length);
|
||||
|
||||
var slice = slices[layer];
|
||||
drawPolygons(slice.outerLayer, "red");
|
||||
drawPolygons(slice.innerLayer, "green");
|
||||
drawPolygons(slice.fill, "blue");
|
||||
//}*/
|
||||
|
||||
//downloadFile("slice.json", JSON.stringify(slice));
|
||||
|
||||
for (var i = 0; i < slice.length; i ++) {
|
||||
var shape = new CAL.Shape({shapeColor: false});
|
||||
shapes.push(shape);
|
||||
|
||||
for (var j = 0; j < slice[i].length; j ++) {
|
||||
var point = slice[i][j];
|
||||
shape.addPoint(new CAL.Vector(point.X, point.Y));
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < shapes.length; i ++) {
|
||||
var shape = shapes[i];
|
||||
|
||||
shape.draw(CAL.Scene.context);
|
||||
CAL.Scene.context.strokeStyle = "#FF0000";
|
||||
|
||||
for (var j = 0; j < shape.points.length; j ++) {
|
||||
var normal = shape.getNormal(j).scale(20);
|
||||
var point = shape.points[j];
|
||||
|
||||
normal.draw(CAL.Scene.context, point.x, point.y);
|
||||
}
|
||||
}
|
||||
})();
|
||||
*/
|
||||
|
||||
(function animate () {
|
||||
requestAnimationFrame(animate);
|
||||
|
@ -11,7 +11,6 @@
|
||||
* voor laag 5 = 5 diff (3 && 4 && 6 && 7))
|
||||
*
|
||||
******************************************************/
|
||||
var use_deprecated = true;
|
||||
|
||||
D3D.Slicer = function () {
|
||||
"use strict";
|
||||
@ -134,7 +133,9 @@ D3D.Slicer.prototype.slice = function (height, step) {
|
||||
index = connects[j];
|
||||
|
||||
if (intersections[index] && done.indexOf(index) === -1) {
|
||||
var normal = new THREE.Vector2().copy(intersection).sub(intersections[index]).normal().normalize();
|
||||
var a = new THREE.Vector2().set(intersection.x, intersection.y);
|
||||
var b = intersections[index];
|
||||
var normal = a.sub(b).normal().normalize();
|
||||
var faceNormal = faceNormals[Math.floor(j/2)];
|
||||
|
||||
if (normal.dot(faceNormal) > 0) {
|
||||
@ -179,6 +180,8 @@ D3D.Slicer.prototype.getInset = function (slice, offset) {
|
||||
return solution;
|
||||
};
|
||||
D3D.Slicer.prototype.getFillTemplate = function (dimension, size, even, uneven) {
|
||||
"use strict";
|
||||
|
||||
var paths = new ClipperLib.Paths();
|
||||
|
||||
if (even) {
|
||||
@ -195,6 +198,8 @@ D3D.Slicer.prototype.getFillTemplate = function (dimension, size, even, uneven)
|
||||
return paths;
|
||||
};
|
||||
D3D.Slicer.prototype.slicesToData = function (slices, config) {
|
||||
"use strict";
|
||||
|
||||
var data = [];
|
||||
|
||||
//scale because of clipper crap
|
||||
@ -202,7 +207,7 @@ D3D.Slicer.prototype.slicesToData = function (slices, config) {
|
||||
|
||||
var layerHeight = config["printer.layerHeight"] * scale;
|
||||
var dimensionsZ = config["printer.dimensions.z"] * scale;
|
||||
//should come from config???
|
||||
//variables should come from config
|
||||
//aan rick voorleggen
|
||||
var nozzleSize = 0.4 * scale;
|
||||
var shellThickness = 0.8 * scale;
|
||||
@ -232,45 +237,67 @@ D3D.Slicer.prototype.slicesToData = function (slices, config) {
|
||||
var highFill;
|
||||
|
||||
var fillAbove;
|
||||
//for (var i = 1; i < shellThickness/layerHeight; i ++) {
|
||||
var newLayer = ClipperLib.JS.Clone(slices[layer + 1] || []);
|
||||
for (var i = 1; i < shellThickness/layerHeight; i ++) {
|
||||
var newLayer = ClipperLib.JS.Clone(slices[layer + i]);
|
||||
ClipperLib.JS.ScaleUpPaths(newLayer, scale);
|
||||
fillAbove = newLayer;
|
||||
//}
|
||||
|
||||
if (newLayer.length === 0) {
|
||||
fillAbove = [];
|
||||
|
||||
break;
|
||||
}
|
||||
else if (fillAbove === undefined) {
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
|
||||
if (fillAbove === undefined) {
|
||||
fillAbove = newLayer;
|
||||
}
|
||||
else {
|
||||
// var c = new ClipperLib.Clipper();
|
||||
// var solution = new ClipperLib.Paths();
|
||||
// c.AddPaths(fillArea, ClipperLib.PolyType.ptSubject, true);
|
||||
// c.AddPaths(fillAbove, ClipperLib.PolyType.ptClip, true);
|
||||
// c.Execute(ClipperLib.ClipType.ctDifference, solution);
|
||||
}
|
||||
}
|
||||
//kijkt alleen nog naar boven
|
||||
//omliggende lagen hebben inhoud van lowFill;
|
||||
//inset moet opgevult worden;
|
||||
//verschill tussen lowFill en inset moet vol, rest is raster
|
||||
|
||||
var c = new ClipperLib.Clipper();
|
||||
var clipper = new ClipperLib.Clipper();
|
||||
var highFillArea = new ClipperLib.Paths();
|
||||
c.AddPaths(fillArea, ClipperLib.PolyType.ptSubject, true);
|
||||
c.AddPaths(fillAbove, ClipperLib.PolyType.ptClip, true);
|
||||
c.Execute(ClipperLib.ClipType.ctDifference, highFillArea);
|
||||
clipper.AddPaths(fillArea, ClipperLib.PolyType.ptSubject, true);
|
||||
clipper.AddPaths(fillAbove, ClipperLib.PolyType.ptClip, true);
|
||||
clipper.Execute(ClipperLib.ClipType.ctDifference, highFillArea);
|
||||
|
||||
var c = new ClipperLib.Clipper();
|
||||
var clipper = new ClipperLib.Clipper();
|
||||
var lowFillArea = new ClipperLib.Paths();
|
||||
c.AddPaths(fillArea, ClipperLib.PolyType.ptSubject, true);
|
||||
c.AddPaths(highFillArea, ClipperLib.PolyType.ptClip, true);
|
||||
c.Execute(ClipperLib.ClipType.ctDifference, lowFillArea);
|
||||
clipper.AddPaths(fillArea, ClipperLib.PolyType.ptSubject, true);
|
||||
clipper.AddPaths(highFillArea, ClipperLib.PolyType.ptClip, true);
|
||||
clipper.Execute(ClipperLib.ClipType.ctDifference, lowFillArea);
|
||||
|
||||
var fill = [];
|
||||
|
||||
var c = new ClipperLib.Clipper();
|
||||
var solution = new ClipperLib.Paths();
|
||||
c.AddPaths(lowFillTemplate, ClipperLib.PolyType.ptSubject, false);
|
||||
c.AddPaths(lowFillArea, ClipperLib.PolyType.ptClip, true);
|
||||
c.Execute(ClipperLib.ClipType.ctIntersection, solution);
|
||||
var clipper = new ClipperLib.Clipper();
|
||||
var lowFillStrokes = new ClipperLib.Paths();
|
||||
clipper.AddPaths(lowFillTemplate, ClipperLib.PolyType.ptSubject, false);
|
||||
clipper.AddPaths(lowFillArea, ClipperLib.PolyType.ptClip, true);
|
||||
clipper.Execute(ClipperLib.ClipType.ctIntersection, lowFillStrokes);
|
||||
|
||||
fill = fill.concat(solution);
|
||||
fill = fill.concat(lowFillStrokes);
|
||||
|
||||
var c = new ClipperLib.Clipper();
|
||||
var solution = new ClipperLib.Paths();
|
||||
c.AddPaths(highFillTemplate, ClipperLib.PolyType.ptSubject, false);
|
||||
c.AddPaths(highFillArea, ClipperLib.PolyType.ptClip, true);
|
||||
c.Execute(ClipperLib.ClipType.ctIntersection, solution);
|
||||
var clipper = new ClipperLib.Clipper();
|
||||
var highFillStrokes = new ClipperLib.Paths();
|
||||
clipper.AddPaths(highFillTemplate, ClipperLib.PolyType.ptSubject, false);
|
||||
clipper.AddPaths(highFillArea, ClipperLib.PolyType.ptClip, true);
|
||||
clipper.Execute(ClipperLib.ClipType.ctIntersection, highFillStrokes);
|
||||
|
||||
fill = fill.concat(solution);
|
||||
fill = fill.concat(highFillStrokes);
|
||||
|
||||
ClipperLib.JS.ScaleDownPaths(outerLayer, scale);
|
||||
ClipperLib.JS.ScaleDownPaths(innerLayer, scale);
|
||||
@ -380,7 +407,7 @@ D3D.Slicer.prototype.getGcode = function (config) {
|
||||
//var slices = [slices.shift()];
|
||||
|
||||
var data = this.slicesToData(slices, config);
|
||||
//return data;
|
||||
return data;
|
||||
|
||||
for (var layer = 0; layer < data.length; layer ++) {
|
||||
var slice = data[layer];
|
||||
|
@ -11,6 +11,7 @@ var D3D = {
|
||||
"contact": "develop@doodle3d.com"
|
||||
};
|
||||
|
||||
//add normal function to Three.js Vector class
|
||||
THREE.Vector2.prototype.normal = function () {
|
||||
var x = this.y;
|
||||
var y = -this.x;
|
||||
@ -87,7 +88,6 @@ Array.prototype.clone = function () {
|
||||
return array;
|
||||
};
|
||||
|
||||
|
||||
function applyMouseControls (renderer, camera, maxDistance) {
|
||||
"use strict";
|
||||
//TODO
|
||||
|
Loading…
Reference in New Issue
Block a user