step before layer part integration

This commit is contained in:
casperlamboo 2015-05-13 13:18:37 +02:00
parent 3a41b73c75
commit 5ac9364cc3
4 changed files with 526 additions and 19 deletions

View File

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

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

@ -70,7 +70,7 @@ var printerConfig = {
var printer = new D3D.Printer(printerConfig); var printer = new D3D.Printer(printerConfig);
var localIp = location.hash.substring(1); var localIp = location.hash.substring(1);
//var doodleBox = new D3D.Box(localIp); var doodleBox = new D3D.Box(localIp);
//var printer = doodleBox.printer; //var printer = doodleBox.printer;
var scene = new THREE.Scene(); var scene = new THREE.Scene();
@ -116,13 +116,14 @@ mesh.position.z = 100;
//scene.add(mesh); //scene.add(mesh);
var loader = new THREE.STLLoader(); var loader = new THREE.STLLoader();
loader.load("models/cube.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.BoxGeometry(10, 10, 10, 1, 1, 1);
//var geometry = new THREE.TorusGeometry(20, 10, 30, 30);
var mesh = new THREE.Mesh(geometry, material); var mesh = new THREE.Mesh(geometry, material);
mesh.position.x = 100; mesh.position.x = 100;
mesh.position.z = 100; mesh.position.z = 100;
/* /*
mesh.rotation.x = -Math.PI/2; mesh.rotation.x = -Math.PI/2;
mesh.scale.x = mesh.scale.y = mesh.scale.z = 3; mesh.scale.x = mesh.scale.y = mesh.scale.z = 3;
@ -136,7 +137,7 @@ loader.load("models/cube.stl", function (geometry) {
var canvas = document.getElementById("canvas"); var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d"); var context = canvas.getContext("2d");
var img = slicer.drawPaths(printer, 0, 1); var img = slicer.drawPaths(printer, 0, 10);
context.drawImage(img, 0, 0); context.drawImage(img, 0, 0);
gcode = slicer.getGcode(printer); gcode = slicer.getGcode(printer);

View File

@ -193,6 +193,8 @@ D3D.Slicer.prototype.slice = function (height, step) {
//stop when ther are no intersects //stop when ther are no intersects
if (slice.length > 0) { if (slice.length > 0) {
var layerParts = [];
slices.push(slice); slices.push(slice);
} }
else { else {
@ -257,8 +259,6 @@ D3D.Slicer.prototype.slicesToData = function (slices, printer) {
var highFillTemplate = this.getFillTemplate(dimensionsZ, wallThickness, (layer % 2 === 0), (layer % 2 === 1)); var highFillTemplate = this.getFillTemplate(dimensionsZ, wallThickness, (layer % 2 === 0), (layer % 2 === 1));
fills.join(highFillTemplate.intersect(highFillArea)); fills.join(highFillTemplate.intersect(highFillArea));
console.log(highFillTemplate.intersect(highFillArea));
outerLayers.push(outerLayer); outerLayers.push(outerLayer);
} }
@ -411,7 +411,7 @@ D3D.Slicer.prototype.drawPaths = function (printer, min, max) {
for (var layer = min; layer < max; layer ++) { for (var layer = min; layer < max; layer ++) {
var slice = data[layer % data.length]; var slice = data[layer % data.length];
slice.insets.draw(context, "blue"); //slice.insets.draw(context, "blue");
slice.outerLayer.draw(context, "green"); slice.outerLayer.draw(context, "green");
slice.fill.draw(context, "red"); slice.fill.draw(context, "red");
} }