Skip to content

Commit

Permalink
Saving work in progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
clothbot committed Sep 7, 2010
1 parent 4e0758d commit 5d895ae
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 18 deletions.
19 changes: 9 additions & 10 deletions Slice.pde
Expand Up @@ -3,7 +3,7 @@
class Slice {

ArrayList Lines;
ArrayList Paths;
SSPath SlicePath;

//Right now this is all in the constructor.
//It might make more sense to split these
Expand Down Expand Up @@ -99,20 +99,19 @@ class Slice {
Lines.add(LineToMove);
UnsortedLines.remove(iNextLine);
}
Paths = new ArrayList();
// Paths = new ArrayList();
SSLine thisLine=(SSLine) Lines.get(0);
SSPath thisPath=new SSPath(thisLine);
Paths.add(thisPath);
SlicePath=new SSPath(thisLine);
// Paths.add(thisPath);
PVector prevPt=new PVector(thisLine.x2,thisLine.y2);
for(int i=1;i<Lines.size();i++) {
SSLine newLine=(SSLine) Lines.get(i);
if(newLine.x1 == prevPt.x && newLine.y1 == prevPt.y) {
thisPath.append(newLine,true);
} else {
thisPath.closePath();
thisPath=new SSPath(newLine);
Paths.add(thisPath);
boolean connectFlag=true;
if(newLine.x1 != prevPt.x || newLine.y1 != prevPt.y) {
SlicePath.closePath();
connectFlag=false;
}
SlicePath.append(newLine,connectFlag);
prevPt = new PVector(newLine.x2,newLine.y2);
}
}
Expand Down
43 changes: 35 additions & 8 deletions SuperSkein.pde
Expand Up @@ -4,6 +4,7 @@
//Note! Only takes binary-coded STL. ASCII
//STL just breaks it for now.
import processing.dxf.*;
import java.awt.geom.PathIterator;

//The config file takes precedence over these parameters!

Expand Down Expand Up @@ -405,7 +406,7 @@ class DXFWriteProc implements Runnable{
output.println("\nmodule dxf_slice(index=0) {");

Slice ThisSlice;
ArrayList PolyArray;
// ArrayList PolyArray;
float Layers = STLFile.bz2/LayerThickness;
int renderWidth=width, renderHeight=height;
int sliceCount=0;
Expand All @@ -419,14 +420,40 @@ class DXFWriteProc implements Runnable{
pgDxf.setLayer(DXFSliceNum);
DXFWriteFraction = (ZLevel/(STLFile.bz2-LayerThickness));
ThisSlice = new Slice(STLFile,ZLevel);
Poly2D ThisPoly2D = new Poly2D(0.01);
PolyArray = ThisPoly2D.Slice2Poly2DList(ThisSlice);
// Poly2D ThisPoly2D = new Poly2D(0.01);
// PolyArray = ThisPoly2D.Slice2Poly2DList(ThisSlice);
lin = (SSLine) ThisSlice.Lines.get(0);
for(int j = 0;j<ThisSlice.Lines.size();j++)
{
lin = (SSLine) ThisSlice.Lines.get(j);
pgDxf.line(lin.x1, lin.y1, lin.x2, lin.y2);
}
PathIterator pathIter=ThisSlice.SlicePath.getPathIterator(new AffineTransform());
float[] prevCoords={0,0,0,0,0,0};
int segType = pathIter.currentSegment(prevCoords);
pathIter.next();
// for(int j = 0;j<ThisSlice.Lines.size();j++)
// {
// lin = (SSLine) ThisSlice.Lines.get(j);
// pgDxf.line(lin.x1, lin.y1, lin.x2, lin.y2);
// }
float[] newCoords={0,0,0,0,0,0};
float[] firstCoords=prevCoords;
while(!pathIter.isDone()) {
segType=pathIter.currentSegment(newCoords);
if(segType == PathIterator.SEG_LINETO ) {
println(" SEG_LINETO: "+newCoords[0]+" "+newCoords[1]+"\n");
pgDxf.line(prevCoords[0],prevCoords[1],newCoords[0],newCoords[1]);
prevCoords=newCoords;
} else if( segType==PathIterator.SEG_CLOSE) {
println(" SEG_CLOSE: "+newCoords[0]+" "+newCoords[1]+"\n");
pgDxf.line(prevCoords[0],prevCoords[1],newCoords[0],newCoords[1]);
// pgDxf.line(newCoords[0],newCoords[1],firstCoords[0],firstCoords[1]);
prevCoords=newCoords;
} else if(segType == PathIterator.SEG_MOVETO) {
println(" SEG_MOVETO: "+newCoords[0]+" "+newCoords[1]+"\n");
prevCoords=newCoords;
firstCoords=newCoords;
} else {
println(" segType: "+segType+"\n");
}
pathIter.next();
}
output.println(" if(index>="+DXFSliceNum+"&&index<(1+"+DXFSliceNum+")) {");
output.println(" echo(\" Instantiating slice "+DXFSliceNum+".\");");
output.println(" import_dxf(file=\"" + DXFSliceFileName + "\", layer=\""+DXFSliceNum+"\");\n" );
Expand Down

0 comments on commit 5d895ae

Please sign in to comment.