Merge branch 'layer-part-test'

This commit is contained in:
casperlamboo 2015-05-13 17:38:07 +02:00
commit 0bc518dcc9
10 changed files with 992 additions and 363 deletions

296
build/d3d.js vendored
View File

@ -568,140 +568,135 @@ D3D.Printer.prototype.subsituteVariables = function (gcode) {
*
******************************************************/
D3D.Path = function (path, closed) {
D3D.Paths = function (paths, closed) {
"use strict";
this.path = path || [];
Array.call(this);
this.setPaths(paths || []);
this.closed = (closed !== undefined) ? closed : true;
};
D3D.Path.prototype.setPath = function (path) {
D3D.Paths.prototype = Object.create(Array.prototype);
D3D.Paths.prototype.setPaths = function (paths) {
"use strict";
this.path = path;
for (var i = 0; i < paths.length; i ++) {
var path = paths[i];
this.push(path);
}
return this;
};
D3D.Path.prototype.union = function (path) {
D3D.Paths.prototype.clip = function (path, type) {
"use strict";
var solution = new ClipperLib.Paths();
var clipper = new ClipperLib.Clipper();
clipper.AddPaths(this.path, ClipperLib.PolyType.ptSubject, this.closed);
clipper.AddPaths(path.path, ClipperLib.PolyType.ptClip, path.closed);
clipper.Execute(ClipperLib.ClipType.ctUnion, solution);
clipper.AddPaths(this, ClipperLib.PolyType.ptSubject, this.closed);
clipper.AddPaths(path, ClipperLib.PolyType.ptClip, path.closed);
clipper.Execute(type, solution);
return new D3D.Path(solution, this.closed);
return new D3D.Paths(solution);
};
D3D.Path.prototype.difference = function (path) {
D3D.Paths.prototype.union = function (path) {
"use strict";
var solution = new ClipperLib.Paths();
var clipper = new ClipperLib.Clipper();
clipper.AddPaths(this.path, ClipperLib.PolyType.ptSubject, this.closed);
clipper.AddPaths(path.path, ClipperLib.PolyType.ptClip, path.closed);
clipper.Execute(ClipperLib.ClipType.ctDifference, solution);
return new D3D.Path(solution, this.closed);
return this.clip(path, ClipperLib.ClipType.ctUnion);
};
D3D.Path.prototype.intersect = function (path) {
D3D.Paths.prototype.difference = function (path) {
"use strict";
var solution = new ClipperLib.Paths();
var clipper = new ClipperLib.Clipper();
clipper.AddPaths(this.path, ClipperLib.PolyType.ptSubject, this.closed);
clipper.AddPaths(path.path, ClipperLib.PolyType.ptClip, path.closed);
clipper.Execute(ClipperLib.ClipType.ctIntersection, solution);
return new D3D.Path(solution, this.closed);
return this.clip(path, ClipperLib.ClipType.ctDifference);
};
D3D.Path.prototype.xor = function () {
D3D.Paths.prototype.intersect = function (path) {
"use strict";
var solution = new ClipperLib.Paths();
var clipper = new ClipperLib.Clipper();
clipper.AddPaths(this.path, ClipperLib.PolyType.ptSubject, this.closed);
clipper.AddPaths(path.path, ClipperLib.PolyType.ptClip, path.closed);
clipper.Execute(ClipperLib.ClipType.ctXor, solution);
return new D3D.Path(solution, this.closed);
return this.clip(path, ClipperLib.ClipType.ctIntersection);
};
D3D.Path.prototype.offset = function (offset) {
D3D.Paths.prototype.xor = function () {
"use strict";
return this.clip(path, ClipperLib.ClipType.ctXor);
};
D3D.Paths.prototype.offset = function (offset) {
"use strict";
var solution = new ClipperLib.Paths();
var co = new ClipperLib.ClipperOffset(1, 1);
co.AddPaths(this.path, ClipperLib.JoinType.jtRound, ClipperLib.EndType.etClosedPolygon);
co.AddPaths(this, ClipperLib.JoinType.jtRound, ClipperLib.EndType.etClosedPolygon);
co.Execute(solution, offset);
return new D3D.Path(solution, this.closed);
return new D3D.Paths(solution);
};
D3D.Path.prototype.scaleUp = function (factor) {
D3D.Paths.prototype.scaleUp = function (factor) {
"use strict";
var path = ClipperLib.JS.ScaleUpPaths(this.path, factor);
var path = ClipperLib.JS.ScaleUpPaths(this, factor);
return this;
};
D3D.Path.prototype.scaleDown = function (factor) {
D3D.Paths.prototype.scaleDown = function (factor) {
"use strict";
var path = ClipperLib.JS.ScaleDownPaths(this.path, factor);
var path = ClipperLib.JS.ScaleDownPaths(this, factor);
return this;
};
D3D.Path.prototype.tresholdArea = function (minArea) {
D3D.Paths.prototype.tresholdArea = function (minArea) {
"use strict";
for (var i = 0; i < this.path.length; i ++) {
var shape = this.path[i];
for (var i = 0; i < this.length; i ++) {
var shape = this[i];
var area = ClipperLib.Clipper.Area(shape);
if (area < minArea) {
this.path.splice(i, 1);
this.splice(i, 1);
i --;
}
}
return areas;
};
D3D.Path.prototype.area = function () {
D3D.Paths.prototype.area = function () {
"use strict";
var areas = [];
return ClipperLib.Clipper.Area(this);
};
D3D.Paths.prototype.join = function (path) {
"use strict";
for (var i = 0; i < this.path.length; i ++) {
var shape = this.path[i];
areas.push(ClipperLib.Clipper.Area(shape))
for (var i = 0; i < path.length; i ++) {
this.push(path[i]);
}
return areas;
return this;
};
D3D.Path.prototype.join = function (path) {
D3D.Paths.prototype.clone = function () {
"use strict";
this.path = this.path.concat(path.path);
return new D3D.Paths(ClipperLib.JS.Clone(this), this.closed);
};
D3D.Paths.prototype.bounds = function () {
"use strict";
return ClipperLib.Clipper.GetBounds(this);
};
D3D.Paths.prototype.reverse = function () {
"use strict";
ClipperLib.Clipper.ReversePaths(this);
return this;
}
D3D.Path.prototype.clone = function () {
"use strict";
var path = ClipperLib.JS.Clone(this.path);
return new D3D.Path(path, this.closed);
}
D3D.Path.prototype.draw = function (context, color) {
};
D3D.Paths.prototype.draw = function (context, color) {
"use strict";
context.strokeStyle = color;
for (var i = 0; i < this.path.length; i ++) {
var shape = this.path[i];
for (var i = 0; i < this.length; i ++) {
var shape = this[i];
context.beginPath();
var length = this.closed ? (shape.length + 1) : shape.length;
@ -738,12 +733,11 @@ D3D.Slicer.prototype.setMesh = function (mesh) {
mesh.updateMatrix();
var geometry = mesh.geometry.clone();
geometry.mergeVertices();
geometry.applyMatrix(mesh.matrix);
if (geometry instanceof THREE.BufferGeometry) {
geometry = new THREE.Geometry().fromBufferGeometry(geometry);
}
geometry.mergeVertices();
geometry.applyMatrix(mesh.matrix);
this.geometry = geometry;
@ -770,7 +764,8 @@ D3D.Slicer.prototype.createLines = function () {
self.lines.push({
line: new THREE.Line3(self.geometry.vertices[a], self.geometry.vertices[b]),
connects: [],
normals: []
normals: [],
ignore: 0
});
}
@ -779,22 +774,25 @@ D3D.Slicer.prototype.createLines = function () {
for (var i = 0; i < this.geometry.faces.length; i ++) {
var face = this.geometry.faces[i];
var normal = new THREE.Vector2().set(face.normal.x, face.normal.z).normalize();
//check for only adding unique lines
//returns index of said line
var a = addLine(face.a, face.b);
var b = addLine(face.b, face.c);
var c = addLine(face.c, face.a);
//if (face.normal.y !== 1 && face.normal.y !== -1) {
var normal = new THREE.Vector2().set(face.normal.x, face.normal.z).normalize();
//set connecting lines (based on face)
this.lines[a].connects.push(b, c);
this.lines[b].connects.push(c, a);
this.lines[c].connects.push(a, b);
//check for only adding unique lines
//returns index of said line
var a = addLine(face.a, face.b);
var b = addLine(face.b, face.c);
var c = addLine(face.c, face.a);
this.lines[a].normals.push(normal);
this.lines[b].normals.push(normal);
this.lines[c].normals.push(normal);
//set connecting lines (based on face)
this.lines[a].connects.push(b, c);
this.lines[b].connects.push(c, a);
this.lines[c].connects.push(a, b);
this.lines[a].normals.push(normal);
this.lines[b].normals.push(normal);
this.lines[c].normals.push(normal);
//}
}
};
D3D.Slicer.prototype.slice = function (height, step) {
@ -820,7 +818,7 @@ D3D.Slicer.prototype.slice = function (height, step) {
var slices = [];
for (var layer = 1; layer < layersIntersections.length; layer ++) {
for (var layer = 1; layer < layersIntersections.length-1; layer ++) {
var layerIntersections = layersIntersections[layer];
var y = layer*step;
@ -837,7 +835,7 @@ D3D.Slicer.prototype.slice = function (height, step) {
}
var done = [];
var slice = [];
var slice = new D3D.Paths([], true);
for (var i = 0; i < layerIntersections.length; i ++) {
var index = layerIntersections[i];
@ -898,15 +896,34 @@ D3D.Slicer.prototype.slice = function (height, step) {
//think this check is not nescesary, always higher as 0
if (shape.length > 0) {
slice.push(shape);
slice.push(new D3D.Paths([shape]));
}
}
}
var layerParts = [];
for (var i = 0; i < slice.length; i ++) {
var layerPart1 = slice[i];
var merge = false;
for (var j = 0; j < layerParts.length; j ++) {
var layerPart2 = layerParts[j];
if (layerPart2.intersect(layerPart1).length > 0) {
layerPart2.join(layerPart1);
merge = true;
break;
}
}
if (!merge) {
layerParts.push(layerPart1);
}
}
//stop when ther are no intersects
if (slice.length > 0) {
slices.push(new D3D.Path(slice, true));
//slices.push(slice);
if (layerParts.length > 0) {
slices.push(layerParts);
}
else {
break;
@ -935,36 +952,58 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
for (var layer = 0; layer < slices.length; layer ++) {
var slice = slices[layer];
var outerLayer = slice.clone();
outerLayer.scaleUp(scale);
var layerData = [];
data.push(layerData);
var insets = new D3D.Path();
for (var offset = wallThickness; offset <= shellThickness; offset += wallThickness) {
var inset = outerLayer.offset(-offset);
insets.join(inset);
var downSkin = new D3D.Paths();
if (layer - skinCount >= 0) {
var downLayer = slices[layer - skinCount];
for (var i = 0; i < downLayer.length; i ++) {
downSkin.join(downLayer[i]);
}
}
var upSkin = new D3D.Paths();
if (layer + skinCount < slices.length) {
var downLayer = slices[layer + skinCount];
for (var i = 0; i < downLayer.length; i ++) {
upSkin.join(downLayer[i]);
}
}
var surroundingLayer = upSkin.intersect(downSkin).clone().scaleUp(scale);
var sliceData = [];
var fillArea = (inset || outerLayer).offset(-wallThickness/2);
for (var i = 0; i < slice.length; i ++) {
var part = slice[i];
var downFill = (layer - skinCount >= 0) ? slices[layer - skinCount] : new D3D.Path();
var upFill = (layer + skinCount < slices.length) ? slices[layer + skinCount] : new D3D.Path();
var highFillArea = fillArea.difference(downFill.intersect(upFill).scaleUp(scale));
var outerLayer = part.clone();
outerLayer.scaleUp(scale);
var lowFillArea = fillArea.difference(highFillArea);
var insets = new D3D.Paths();
for (var offset = wallThickness; offset <= shellThickness; offset += wallThickness) {
var inset = outerLayer.offset(-offset);
insets.join(inset);
}
var fillArea = (inset || outerLayer).offset(-wallThickness/2);
var highFillArea = fillArea.difference(surroundingLayer);
var lowFillArea = fillArea.difference(highFillArea);
var fill = new D3D.Paths([]);
fill.join(lowFillTemplate.intersect(lowFillArea));
var fill = new D3D.Path([], false);
fill.join(lowFillTemplate.intersect(lowFillArea));
if (highFillArea.path.length > 0) {
var highFillTemplate = this.getFillTemplate(dimensionsZ, wallThickness, (layer % 2 === 0), (layer % 2 === 1));
fill.join(highFillTemplate.intersect(highFillArea));
}
data.push({
outerLayer: outerLayer.scaleDown(scale),
insets: insets.scaleDown(scale),
fill: fill.scaleDown(scale)
});
layerData.push({
outerLayer: outerLayer.scaleDown(scale),
fill: fill.scaleDown(scale),
insets: insets.scaleDown(scale)
});
}
}
return data;
@ -972,7 +1011,7 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
D3D.Slicer.prototype.getFillTemplate = function (dimension, size, even, uneven) {
"use strict";
var paths = [];
var paths = new D3D.Paths([], false);
if (even) {
for (var length = 0; length <= dimension; length += size) {
@ -986,7 +1025,7 @@ D3D.Slicer.prototype.getFillTemplate = function (dimension, size, even, uneven)
}
//return paths;
return new D3D.Path(paths, false);
return paths;
};
D3D.Slicer.prototype.dataToGcode = function (data, printer) {
"use strict";
@ -1008,13 +1047,15 @@ D3D.Slicer.prototype.dataToGcode = function (data, printer) {
function sliceToGcode (slice) {
var gcode = [];
for (var i = 0; i < slice.path.length; i ++) {
var shape = slice.path[i];
for (var i = 0; i < slice.length; i ++) {
var shape = slice[i];
var previousPoint;
for (var j = 0; j < shape.length; j ++) {
var point = shape[j];
var length = slice.closed ? (shape.length + 1) : shape.length;
for (var j = 0; j < length; j ++) {
var point = shape[j % shape.length];
if (j === 0) {
//TODO
@ -1082,9 +1123,13 @@ D3D.Slicer.prototype.dataToGcode = function (data, printer) {
var z = ((layer + 1) * layerHeight).toFixed(3);
gcode = gcode.concat(sliceToGcode(slice.outerLayer));
gcode = gcode.concat(sliceToGcode(slice.insets));
gcode = gcode.concat(sliceToGcode(slice.fill));
for (var i = 0; i < slice.length; i ++) {
var layerPart = slice[i];
gcode = gcode.concat(sliceToGcode(layerPart.outerLayer));
gcode = gcode.concat(sliceToGcode(layerPart.insets));
gcode = gcode.concat(sliceToGcode(layerPart.fill));
}
}
gcode = gcode.concat(printer.getEndCode());
@ -1106,13 +1151,16 @@ D3D.Slicer.prototype.drawPaths = function (printer, min, max) {
canvas.height = 400;
var context = canvas.getContext("2d");
for (var layer = min; layer < max; layer ++) {
var slice = data[layer % data.length];
slice.insets.draw(context, "blue");
slice.outerLayer.draw(context, "green");
slice.fill.draw(context, "red");
for (var i = 0; i < slice.length; i ++) {
var layerPart = slice[i];
layerPart.insets.draw(context, "blue");
layerPart.outerLayer.draw(context, "green");
layerPart.fill.draw(context, "red");
}
}
return canvas;

2
build/d3d.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -10,7 +10,7 @@ var files = [
"src/utils.js",
"src/box.js",
"src/printer.js",
"src/path.js",
"src/paths.js",
"src/slicer.js"
];

View File

@ -2876,8 +2876,8 @@
};
ClipperLib.ClipperBase.prototype.AddPaths = function (ppg, polyType, closed)
{
// console.log("-------------------------------------------");
// console.log(JSON.stringify(ppg));
// console.warn("-------------------------------------------");
// console.warn(JSON.stringify(ppg));
var result = false;
for (var i = 0, ilen = ppg.length; i < ilen; ++i)
if (this.AddPath(ppg[i], polyType, closed))
@ -3185,7 +3185,7 @@
if (this.m_Scanbeam === null)
break;
var topY = this.PopScanbeam();
//console.log("botY:" + botY + ", topY:" + topY);
//console.warn("botY:" + botY + ", topY:" + topY);
if (!this.ProcessIntersections(botY, topY))
return false;
this.ProcessEdgesAtTopOfScanbeam(topY);
@ -4747,7 +4747,7 @@
return;
//prepare for sorting ...
var e = this.m_ActiveEdges;
//console.log(JSON.stringify(JSON.decycle( e )));
//console.warn(JSON.stringify(JSON.decycle( e )));
this.m_SortedEdges = e;
while (e !== null)
{
@ -4766,13 +4766,13 @@
{
var eNext = e.NextInSEL;
var pt = new ClipperLib.IntPoint();
//console.log("e.Curr.X: " + e.Curr.X + " eNext.Curr.X" + eNext.Curr.X);
//console.warn("e.Curr.X: " + e.Curr.X + " eNext.Curr.X" + eNext.Curr.X);
if (e.Curr.X > eNext.Curr.X)
{
if (!this.IntersectPoint(e, eNext, pt) && e.Curr.X > eNext.Curr.X + 1)
{
//console.log("e.Curr.X: "+JSON.stringify(JSON.decycle( e.Curr.X )));
//console.log("eNext.Curr.X+1: "+JSON.stringify(JSON.decycle( eNext.Curr.X+1)));
//console.warn("e.Curr.X: "+JSON.stringify(JSON.decycle( e.Curr.X )));
//console.warn("eNext.Curr.X+1: "+JSON.stringify(JSON.decycle( eNext.Curr.X+1)));
ClipperLib.Error("Intersection error");
}
if (pt.Y > botY)
@ -4884,8 +4884,8 @@
else ClipperLib.Clipper.Round = R2; // eg. browser.chrome || browser.firefox || browser.opera
ClipperLib.Clipper.TopX = function (edge, currentY)
{
//if (edge.Bot == edge.Curr) alert ("edge.Bot = edge.Curr");
//if (edge.Bot == edge.Top) alert ("edge.Bot = edge.Top");
//if (edge.Bot == edge.Curr) console.warn ("edge.Bot = edge.Curr");
//if (edge.Bot == edge.Top) console.warn ("edge.Bot = edge.Top");
if (currentY == edge.Top.Y)
return edge.Top.X;
return edge.Bot.X + ClipperLib.Clipper.Round(edge.Dx * (currentY - edge.Bot.Y));
@ -6469,7 +6469,7 @@
if (solution.length > 0)
solution.splice(0, 1);
}
//console.log(JSON.stringify(solution));
//console.warn(JSON.stringify(solution));
}
else // function (polytree, delta)
{
@ -6596,7 +6596,7 @@
}
catch (err)
{
alert(err.message);
console.warn(err.message);
}
};
// ---------------------------------

BIN
models/cube.stl Normal file

Binary file not shown.

506
models/diamond.stl Executable file
View File

@ -0,0 +1,506 @@
solid OpenSCAD_Model
facet normal 0 0 0
outer loop
vertex 24 0 45.03
vertex 12 0 54.03
vertex 20.7846 -12 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 8.48528 8.48528 54.03
vertex 12 0 54.03
vertex 20.7846 12 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -12 -20.7846 45.03
vertex -20.7846 -12 45
vertex -12 -20.7846 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -12 1.46953e-015 54.03
vertex 8.48528 8.48528 54.03
vertex 7.34764e-016 12 54.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 12 0 54.03
vertex -8.48528 -8.48528 54.03
vertex 8.48528 -8.48528 54.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 12 0 54.03
vertex 8.48528 -8.48528 54.03
vertex 20.7846 -12 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 12 0 54.03
vertex 8.48528 8.48528 54.03
vertex -8.48528 -8.48528 54.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 7.34764e-016 12 54.03
vertex 1.46953e-015 24 45.03
vertex -12 20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 12 20.7846 45.03
vertex 20.7846 12 45
vertex 12 20.7846 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 7.34764e-016 12 54.03
vertex 8.48528 8.48528 54.03
vertex 12 20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -0.15 -0.259808 15
vertex 0.15 0.259808 15
vertex 0.15 -0.259808 15
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 20.7846 -12 45.03
vertex 12 -20.7846 45
vertex 20.7846 -12 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -12 1.46953e-015 54.03
vertex -20.7846 12 45.03
vertex -24 2.93906e-015 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -24 2.93906e-015 45.03
vertex -20.7846 -12 45
vertex -20.7846 -12 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 8.48528 8.48528 54.03
vertex 20.7846 12 45.03
vertex 12 20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -20.7846 -12 45
vertex -12 -20.7846 45.03
vertex -20.7846 -12 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -0.15 0.259808 15
vertex -12 20.7846 45
vertex 1.46953e-015 24 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0.15 0.259808 15
vertex 20.7846 12 45
vertex 0.3 0 15
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -2.20429e-015 -12 54.03
vertex -4.40858e-015 -24 45.03
vertex 12 -20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -2.20429e-015 -12 54.03
vertex -8.48528 -8.48528 54.03
vertex -12 -20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -24 2.93906e-015 45
vertex -20.7846 12 45.03
vertex -20.7846 12 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -0.15 0.259808 15
vertex -0.15 -0.259808 15
vertex -0.3 3.67382e-017 15
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 20.7846 12 45
vertex 20.7846 12 45.03
vertex 24 0 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 20.7846 12 45.03
vertex 12 0 54.03
vertex 24 0 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -8.48528 -8.48528 54.03
vertex 8.48528 8.48528 54.03
vertex -12 1.46953e-015 54.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 20.7846 12 45.03
vertex 20.7846 12 45
vertex 12 20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 1.46953e-015 24 45.03
vertex -12 20.7846 45
vertex -12 20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 7.34764e-016 12 54.03
vertex -12 20.7846 45.03
vertex -8.48528 8.48528 54.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 20.7846 12 45
vertex 0.15 0.259808 15
vertex 12 20.7846 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 1.46953e-015 24 45.03
vertex 7.34764e-016 12 54.03
vertex 12 20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -4.40858e-015 -24 45.03
vertex 12 -20.7846 45
vertex 12 -20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 8.48528 -8.48528 54.03
vertex -8.48528 -8.48528 54.03
vertex -2.20429e-015 -12 54.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -12 20.7846 45
vertex 1.46953e-015 24 45.03
vertex 1.46953e-015 24 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -4.40858e-015 -24 45.03
vertex -2.20429e-015 -12 54.03
vertex -12 -20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -0.15 -0.259808 15
vertex -20.7846 -12 45
vertex -0.3 3.67382e-017 15
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -0.15 0.259808 15
vertex 0.15 0.259808 15
vertex -0.15 -0.259808 15
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0.15 -0.259808 15
vertex 0.3 0 15
vertex 20.7846 -12 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -20.7846 -12 45
vertex -0.15 -0.259808 15
vertex -12 -20.7846 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 12 -20.7846 45
vertex 20.7846 -12 45.03
vertex 12 -20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0.15 -0.259808 15
vertex 0.15 0.259808 15
vertex 0.3 0 15
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -24 2.93906e-015 45.03
vertex -20.7846 12 45.03
vertex -24 2.93906e-015 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -12 1.46953e-015 54.03
vertex -24 2.93906e-015 45.03
vertex -20.7846 -12 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -12 20.7846 45
vertex -20.7846 12 45.03
vertex -12 20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -12 1.46953e-015 54.03
vertex 7.34764e-016 12 54.03
vertex -8.48528 8.48528 54.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 1.46953e-015 24 45.03
vertex 12 20.7846 45
vertex 1.46953e-015 24 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 1.46953e-015 24 45.03
vertex 12 20.7846 45.03
vertex 12 20.7846 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 20.7846 -12 45.03
vertex 8.48528 -8.48528 54.03
vertex 12 -20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 8.48528 -8.48528 54.03
vertex -2.20429e-015 -12 54.03
vertex 12 -20.7846 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 12 20.7846 45
vertex 0.15 0.259808 15
vertex 1.46953e-015 24 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0.15 0.259808 15
vertex -0.15 0.259808 15
vertex 1.46953e-015 24 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 12 -20.7846 45
vertex -4.40858e-015 -24 45.03
vertex -4.40858e-015 -24 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -4.40858e-015 -24 45.03
vertex -12 -20.7846 45.03
vertex -12 -20.7846 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -4.40858e-015 -24 45.03
vertex -12 -20.7846 45
vertex -4.40858e-015 -24 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -12 -20.7846 45
vertex -0.15 -0.259808 15
vertex -4.40858e-015 -24 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 12 -20.7846 45
vertex -4.40858e-015 -24 45
vertex 0.15 -0.259808 15
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -4.40858e-015 -24 45
vertex -0.15 -0.259808 15
vertex 0.15 -0.259808 15
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -0.15 0.259808 15
vertex -0.3 3.67382e-017 15
vertex -20.7846 12 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -0.3 3.67382e-017 15
vertex -24 2.93906e-015 45
vertex -20.7846 12 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -12 -20.7846 45.03
vertex -8.48528 -8.48528 54.03
vertex -20.7846 -12 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -8.48528 -8.48528 54.03
vertex -12 1.46953e-015 54.03
vertex -20.7846 -12 45.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -12 20.7846 45.03
vertex -20.7846 12 45.03
vertex -8.48528 8.48528 54.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -20.7846 12 45.03
vertex -12 1.46953e-015 54.03
vertex -8.48528 8.48528 54.03
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 0.3 0 15
vertex 20.7846 12 45
vertex 24 0 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 12 -20.7846 45
vertex 0.15 -0.259808 15
vertex 20.7846 -12 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -0.3 3.67382e-017 15
vertex -20.7846 -12 45
vertex -24 2.93906e-015 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -20.7846 -12 45
vertex -24 2.93906e-015 45.03
vertex -24 2.93906e-015 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 20.7846 12 45
vertex 24 0 45.03
vertex 24 0 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 24 0 45.03
vertex 20.7846 -12 45.03
vertex 20.7846 -12 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 24 0 45.03
vertex 20.7846 -12 45
vertex 24 0 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex 20.7846 -12 45
vertex 0.3 0 15
vertex 24 0 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -20.7846 12 45.03
vertex -12 20.7846 45
vertex -20.7846 12 45
endloop
endfacet
facet normal 0 0 0
outer loop
vertex -12 20.7846 45
vertex -0.15 0.259808 15
vertex -20.7846 12 45
endloop
endfacet
endsolid OpenSCAD_Model

View File

@ -11,7 +11,7 @@
<script src="src/utils.js"></script>
<script src="src/box.js"></script>
<script src="src/printer.js"></script>
<script src="src/path.js"></script>
<script src="src/paths.js"></script>
<script src="src/slicer.js"></script>
<script src="gcode/testgcode.js"></script>
@ -115,20 +115,55 @@ mesh.position.z = 100;
//scene.add(mesh);
var loader = new THREE.STLLoader();
loader.load("models/cubes.stl", function (geometry) {
loader.load("models/diamond.stl", function (geometry) {
var geometry = new THREE.BoxGeometry(10, 10, 10, 1, 1, 1);
//var geometry = new THREE.TorusGeometry(20, 10, 30, 30);
var geometry = (function () {
"use strict";
var circle = new THREE.Shape();
circle.absarc(0, 0, 10, 0, Math.PI*2, false);
var hole = new THREE.Path();
hole.absarc(0, 0, 5, 0, Math.PI*2, true );
circle.holes.push(hole);
var matrix = new THREE.Matrix4();
matrix.makeRotationX(Math.PI*1.5);
var geometry = new THREE.ExtrudeGeometry(circle, {
amount: 3,
bevelEnabled: false,
steps: 1
});
geometry.applyMatrix(matrix);
return geometry;
})();
var mesh = new THREE.Mesh(geometry, material);
mesh.position.x = 100;
mesh.position.z = 100;
/*
mesh.rotation.x = -Math.PI/2;
mesh.scale.x = mesh.scale.y = mesh.scale.z = 3;
//mesh is lifted a little bit...
mesh.position.y = -0.6552429199218741;
*/
scene.add(mesh);
var slicer = new D3D.Slicer().setMesh(mesh);
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");
//var img = slicer.drawPaths(printer, 7, 8);
//context.drawImage(img, 0, 0);
gcode = slicer.getGcode(printer);
});

View File

@ -1,153 +0,0 @@
/******************************************************
*
* Path
*
* Abstraction layer for annoying clipper js
*
******************************************************/
D3D.Path = function (path, closed) {
"use strict";
this.path = path || [];
this.closed = (closed !== undefined) ? closed : true;
};
D3D.Path.prototype.setPath = function (path) {
"use strict";
this.path = path;
return this;
};
D3D.Path.prototype.union = function (path) {
"use strict";
var solution = new ClipperLib.Paths();
var clipper = new ClipperLib.Clipper();
clipper.AddPaths(this.path, ClipperLib.PolyType.ptSubject, this.closed);
clipper.AddPaths(path.path, ClipperLib.PolyType.ptClip, path.closed);
clipper.Execute(ClipperLib.ClipType.ctUnion, solution);
return new D3D.Path(solution, this.closed);
};
D3D.Path.prototype.difference = function (path) {
"use strict";
var solution = new ClipperLib.Paths();
var clipper = new ClipperLib.Clipper();
clipper.AddPaths(this.path, ClipperLib.PolyType.ptSubject, this.closed);
clipper.AddPaths(path.path, ClipperLib.PolyType.ptClip, path.closed);
clipper.Execute(ClipperLib.ClipType.ctDifference, solution);
return new D3D.Path(solution, this.closed);
};
D3D.Path.prototype.intersect = function (path) {
"use strict";
var solution = new ClipperLib.Paths();
var clipper = new ClipperLib.Clipper();
clipper.AddPaths(this.path, ClipperLib.PolyType.ptSubject, this.closed);
clipper.AddPaths(path.path, ClipperLib.PolyType.ptClip, path.closed);
clipper.Execute(ClipperLib.ClipType.ctIntersection, solution);
return new D3D.Path(solution, this.closed);
};
D3D.Path.prototype.xor = function () {
"use strict";
var solution = new ClipperLib.Paths();
var clipper = new ClipperLib.Clipper();
clipper.AddPaths(this.path, ClipperLib.PolyType.ptSubject, this.closed);
clipper.AddPaths(path.path, ClipperLib.PolyType.ptClip, path.closed);
clipper.Execute(ClipperLib.ClipType.ctXor, solution);
return new D3D.Path(solution, this.closed);
};
D3D.Path.prototype.offset = function (offset) {
"use strict";
var solution = new ClipperLib.Paths();
var co = new ClipperLib.ClipperOffset(1, 1);
co.AddPaths(this.path, ClipperLib.JoinType.jtRound, ClipperLib.EndType.etClosedPolygon);
co.Execute(solution, offset);
return new D3D.Path(solution, this.closed);
};
D3D.Path.prototype.scaleUp = function (factor) {
"use strict";
var path = ClipperLib.JS.ScaleUpPaths(this.path, factor);
return this;
};
D3D.Path.prototype.scaleDown = function (factor) {
"use strict";
var path = ClipperLib.JS.ScaleDownPaths(this.path, factor);
return this;
};
D3D.Path.prototype.tresholdArea = function (minArea) {
"use strict";
for (var i = 0; i < this.path.length; i ++) {
var shape = this.path[i];
var area = ClipperLib.Clipper.Area(shape);
if (area < minArea) {
this.path.splice(i, 1);
i --;
}
}
return areas;
};
D3D.Path.prototype.area = function () {
"use strict";
var areas = [];
for (var i = 0; i < this.path.length; i ++) {
var shape = this.path[i];
areas.push(ClipperLib.Clipper.Area(shape))
}
return areas;
};
D3D.Path.prototype.join = function (path) {
"use strict";
this.path = this.path.concat(path.path);
return this;
}
D3D.Path.prototype.clone = function () {
"use strict";
var path = ClipperLib.JS.Clone(this.path);
return new D3D.Path(path, this.closed);
}
D3D.Path.prototype.draw = function (context, color) {
"use strict";
context.strokeStyle = color;
for (var i = 0; i < this.path.length; i ++) {
var shape = this.path[i];
context.beginPath();
var length = this.closed ? (shape.length + 1) : shape.length;
for (var j = 0; j < length; j ++) {
var point = shape[j % shape.length];
context.lineTo(point.X*2, point.Y*2);
}
context.stroke();
}
};

148
src/paths.js Normal file
View File

@ -0,0 +1,148 @@
/******************************************************
*
* Path
*
* Abstraction layer for annoying clipper js
*
******************************************************/
D3D.Paths = function (paths, closed) {
"use strict";
Array.call(this);
this.setPaths(paths || []);
this.closed = (closed !== undefined) ? closed : true;
};
D3D.Paths.prototype = Object.create(Array.prototype);
D3D.Paths.prototype.setPaths = function (paths) {
"use strict";
for (var i = 0; i < paths.length; i ++) {
var path = paths[i];
this.push(path);
}
return this;
};
D3D.Paths.prototype.clip = function (path, type) {
"use strict";
var solution = new ClipperLib.Paths();
var clipper = new ClipperLib.Clipper();
clipper.AddPaths(this, ClipperLib.PolyType.ptSubject, this.closed);
clipper.AddPaths(path, ClipperLib.PolyType.ptClip, path.closed);
clipper.Execute(type, solution);
return new D3D.Paths(solution);
};
D3D.Paths.prototype.union = function (path) {
"use strict";
return this.clip(path, ClipperLib.ClipType.ctUnion);
};
D3D.Paths.prototype.difference = function (path) {
"use strict";
return this.clip(path, ClipperLib.ClipType.ctDifference);
};
D3D.Paths.prototype.intersect = function (path) {
"use strict";
return this.clip(path, ClipperLib.ClipType.ctIntersection);
};
D3D.Paths.prototype.xor = function () {
"use strict";
return this.clip(path, ClipperLib.ClipType.ctXor);
};
D3D.Paths.prototype.offset = function (offset) {
"use strict";
var solution = new ClipperLib.Paths();
var co = new ClipperLib.ClipperOffset(1, 1);
co.AddPaths(this, ClipperLib.JoinType.jtRound, ClipperLib.EndType.etClosedPolygon);
co.Execute(solution, offset);
return new D3D.Paths(solution);
};
D3D.Paths.prototype.scaleUp = function (factor) {
"use strict";
var path = ClipperLib.JS.ScaleUpPaths(this, factor);
return this;
};
D3D.Paths.prototype.scaleDown = function (factor) {
"use strict";
var path = ClipperLib.JS.ScaleDownPaths(this, factor);
return this;
};
D3D.Paths.prototype.tresholdArea = function (minArea) {
"use strict";
for (var i = 0; i < this.length; i ++) {
var shape = this[i];
var area = ClipperLib.Clipper.Area(shape);
if (area < minArea) {
this.splice(i, 1);
i --;
}
}
return areas;
};
D3D.Paths.prototype.area = function () {
"use strict";
return ClipperLib.Clipper.Area(this);
};
D3D.Paths.prototype.join = function (path) {
"use strict";
for (var i = 0; i < path.length; i ++) {
this.push(path[i]);
}
return this;
};
D3D.Paths.prototype.clone = function () {
"use strict";
return new D3D.Paths(ClipperLib.JS.Clone(this), this.closed);
};
D3D.Paths.prototype.bounds = function () {
"use strict";
return ClipperLib.Clipper.GetBounds(this);
};
D3D.Paths.prototype.reverse = function () {
"use strict";
ClipperLib.Clipper.ReversePaths(this);
return this;
};
D3D.Paths.prototype.draw = function (context, color) {
"use strict";
context.strokeStyle = color;
for (var i = 0; i < this.length; i ++) {
var shape = this[i];
context.beginPath();
var length = this.closed ? (shape.length + 1) : shape.length;
for (var j = 0; j < length; j ++) {
var point = shape[j % shape.length];
context.lineTo(point.X*2, point.Y*2);
}
context.stroke();
}
};

View File

@ -64,28 +64,25 @@ D3D.Slicer.prototype.createLines = function () {
for (var i = 0; i < this.geometry.faces.length; i ++) {
var face = this.geometry.faces[i];
var normal = new THREE.Vector2().set(face.normal.x, face.normal.z).normalize();
//check for only adding unique lines
//returns index of said line
var a = addLine(face.a, face.b);
var b = addLine(face.b, face.c);
var c = addLine(face.c, face.a);
//if (face.normal.y !== 1 && face.normal.y !== -1) {
var normal = new THREE.Vector2().set(face.normal.x, face.normal.z).normalize();
//set connecting lines (based on face)
this.lines[a].connects.push(b, c);
this.lines[b].connects.push(c, a);
this.lines[c].connects.push(a, b);
//check for only adding unique lines
//returns index of said line
var a = addLine(face.a, face.b);
var b = addLine(face.b, face.c);
var c = addLine(face.c, face.a);
this.lines[a].normals.push(normal);
this.lines[b].normals.push(normal);
this.lines[c].normals.push(normal);
//set connecting lines (based on face)
this.lines[a].connects.push(b, c);
this.lines[b].connects.push(c, a);
this.lines[c].connects.push(a, b);
if (face.normal.y === 1 || face.normal.y === -1) {
this.lines[a].ignore ++;
this.lines[b].ignore ++;
this.lines[c].ignore ++;
}
this.lines[a].normals.push(normal);
this.lines[b].normals.push(normal);
this.lines[c].normals.push(normal);
//}
}
};
D3D.Slicer.prototype.slice = function (height, step) {
@ -99,21 +96,19 @@ D3D.Slicer.prototype.slice = function (height, step) {
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);
if (line.ignore < 2) {
for (var layerIndex = min; layerIndex <= max; layerIndex ++) {
if (layerIndex >= 0) {
if (layersIntersections[layerIndex] === undefined) {
layersIntersections[layerIndex] = [];
}
layersIntersections[layerIndex].push(i);
for (var layerIndex = min; layerIndex <= max; layerIndex ++) {
if (layerIndex >= 0) {
if (layersIntersections[layerIndex] === undefined) {
layersIntersections[layerIndex] = [];
}
layersIntersections[layerIndex].push(i);
}
}
}
var slices = [];
for (var layer = 1; layer < layersIntersections.length; layer ++) {
for (var layer = 1; layer < layersIntersections.length-1; layer ++) {
var layerIntersections = layersIntersections[layer];
var y = layer*step;
@ -130,7 +125,7 @@ D3D.Slicer.prototype.slice = function (height, step) {
}
var done = [];
var slice = [];
var slice = new D3D.Paths([], true);
for (var i = 0; i < layerIntersections.length; i ++) {
var index = layerIntersections[i];
@ -191,15 +186,34 @@ D3D.Slicer.prototype.slice = function (height, step) {
//think this check is not nescesary, always higher as 0
if (shape.length > 0) {
slice.push(shape);
slice.push(new D3D.Paths([shape]));
}
}
}
var layerParts = [];
for (var i = 0; i < slice.length; i ++) {
var layerPart1 = slice[i];
var merge = false;
for (var j = 0; j < layerParts.length; j ++) {
var layerPart2 = layerParts[j];
if (layerPart2.intersect(layerPart1).length > 0) {
layerPart2.join(layerPart1);
merge = true;
break;
}
}
if (!merge) {
layerParts.push(layerPart1);
}
}
//stop when ther are no intersects
if (slice.length > 0) {
slices.push(new D3D.Path(slice, true));
//slices.push(slice);
if (layerParts.length > 0) {
slices.push(layerParts);
}
else {
break;
@ -228,37 +242,58 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
for (var layer = 0; layer < slices.length; layer ++) {
var slice = slices[layer];
var outerLayer = slice.clone();
outerLayer.scaleUp(scale);
var layerData = [];
data.push(layerData);
var insets = new D3D.Path();
for (var offset = wallThickness; offset <= shellThickness; offset += wallThickness) {
var inset = outerLayer.offset(-offset);
insets.join(inset);
var downSkin = new D3D.Paths();
if (layer - skinCount >= 0) {
var downLayer = slices[layer - skinCount];
for (var i = 0; i < downLayer.length; i ++) {
downSkin.join(downLayer[i]);
}
}
var upSkin = new D3D.Paths();
if (layer + skinCount < slices.length) {
var downLayer = slices[layer + skinCount];
for (var i = 0; i < downLayer.length; i ++) {
upSkin.join(downLayer[i]);
}
}
var surroundingLayer = upSkin.intersect(downSkin).clone().scaleUp(scale);
var sliceData = [];
var fillArea = (inset || outerLayer).offset(-wallThickness/2);
for (var i = 0; i < slice.length; i ++) {
var part = slice[i];
var downFill = (layer - skinCount >= 0) ? slices[layer - skinCount] : new D3D.Path();
var upFill = (layer + skinCount < slices.length) ? slices[layer + skinCount] : new D3D.Path();
var highFillArea = fillArea.difference(downFill.intersect(upFill).scaleUp(scale));
var outerLayer = part.clone();
outerLayer.scaleUp(scale);
var lowFillArea = fillArea.difference(highFillArea);
var insets = new D3D.Paths();
for (var offset = wallThickness; offset <= shellThickness; offset += wallThickness) {
var inset = outerLayer.offset(-offset);
insets.join(inset);
}
var fillArea = (inset || outerLayer).offset(-wallThickness/2);
var highFillArea = fillArea.difference(surroundingLayer);
var lowFillArea = fillArea.difference(highFillArea);
var fill = new D3D.Paths([]);
fill.join(lowFillTemplate.intersect(lowFillArea));
var fill = new D3D.Path([], false);
fill.join(lowFillTemplate.intersect(lowFillArea));
if (highFillArea.path.length > 0) {
var highFillTemplate = this.getFillTemplate(dimensionsZ, wallThickness, (layer % 2 === 0), (layer % 2 === 1));
var highFillStrokes = highFillArea;
fill.join(highFillTemplate.intersect(highFillStrokes));
}
fill.join(highFillTemplate.intersect(highFillArea));
data.push({
outerLayer: outerLayer.scaleDown(scale),
insets: insets.scaleDown(scale),
fill: fill.scaleDown(scale)
});
layerData.push({
outerLayer: outerLayer.scaleDown(scale),
fill: fill.scaleDown(scale),
insets: insets.scaleDown(scale)
});
}
}
return data;
@ -266,7 +301,7 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
D3D.Slicer.prototype.getFillTemplate = function (dimension, size, even, uneven) {
"use strict";
var paths = [];
var paths = new D3D.Paths([], false);
if (even) {
for (var length = 0; length <= dimension; length += size) {
@ -280,7 +315,7 @@ D3D.Slicer.prototype.getFillTemplate = function (dimension, size, even, uneven)
}
//return paths;
return new D3D.Path(paths, false);
return paths;
};
D3D.Slicer.prototype.dataToGcode = function (data, printer) {
"use strict";
@ -302,13 +337,15 @@ D3D.Slicer.prototype.dataToGcode = function (data, printer) {
function sliceToGcode (slice) {
var gcode = [];
for (var i = 0; i < slice.path.length; i ++) {
var shape = slice.path[i];
for (var i = 0; i < slice.length; i ++) {
var shape = slice[i];
var previousPoint;
for (var j = 0; j < shape.length; j ++) {
var point = shape[j];
var length = slice.closed ? (shape.length + 1) : shape.length;
for (var j = 0; j < length; j ++) {
var point = shape[j % shape.length];
if (j === 0) {
//TODO
@ -376,9 +413,13 @@ D3D.Slicer.prototype.dataToGcode = function (data, printer) {
var z = ((layer + 1) * layerHeight).toFixed(3);
gcode = gcode.concat(sliceToGcode(slice.outerLayer));
gcode = gcode.concat(sliceToGcode(slice.insets));
gcode = gcode.concat(sliceToGcode(slice.fill));
for (var i = 0; i < slice.length; i ++) {
var layerPart = slice[i];
gcode = gcode.concat(sliceToGcode(layerPart.outerLayer));
gcode = gcode.concat(sliceToGcode(layerPart.insets));
gcode = gcode.concat(sliceToGcode(layerPart.fill));
}
}
gcode = gcode.concat(printer.getEndCode());
@ -403,9 +444,13 @@ D3D.Slicer.prototype.drawPaths = function (printer, min, max) {
for (var layer = min; layer < max; layer ++) {
var slice = data[layer % data.length];
slice.insets.draw(context, "blue");
slice.outerLayer.draw(context, "green");
slice.fill.draw(context, "red");
for (var i = 0; i < slice.length; i ++) {
var layerPart = slice[i];
layerPart.insets.draw(context, "blue");
layerPart.outerLayer.draw(context, "green");
layerPart.fill.draw(context, "red");
}
}
return canvas;