Browse files

Got Fill? Even seems to do the right thing adding bridges and capping…

… local maxima.
  • Loading branch information...
1 parent 6811cea commit e3b7c5882a01e869a25bc1c4abeafb9cd38673a6 @clothbot clothbot committed Sep 12, 2010
Showing with 208 additions and 8 deletions.
  1. +4 −4 AreaWriter.pde
  2. +58 −0 Extruder.pde
  3. +101 −0 Fill.pde
  4. +27 −0 Material.pde
  5. +17 −3 SuperSkein.pde
  6. +1 −1 config.txt
View
8 AreaWriter.pde
@@ -136,10 +136,6 @@ class AreaWriter {
for(int SliceNum=0;SliceNum<SliceAreaList.size();SliceNum++)
{
SSArea thisArea;
- if(SliceAreaList.size()>0) {
- thisArea = (SSArea) SliceAreaList.get(SliceNum);
- if(!thisArea.isEmpty()) GCodeWriteArea(SliceNum, thisArea);
- }
if(ShellAreaList.size()>0) {
thisArea = (SSArea) ShellAreaList.get(SliceNum);
if(!thisArea.isEmpty()) GCodeWriteArea(SliceNum, thisArea);
@@ -148,6 +144,10 @@ class AreaWriter {
thisArea = (SSArea) FillAreaList.get(SliceNum);
if(!thisArea.isEmpty()) GCodeWriteArea(SliceNum, thisArea);
}
+ if(SliceAreaList.size()>0) {
+ thisArea = (SSArea) SliceAreaList.get(SliceNum);
+ if(!thisArea.isEmpty()) GCodeWriteArea(SliceNum, thisArea);
+ }
}
}
View
58 Extruder.pde
@@ -0,0 +1,58 @@
+// Extruder Class
+import java.lang.Math;
+
+class Extruder {
+ int ToolNum;
+ Material Filament;
+ float ZThick;
+ float Diameter;
+ float FlowRate;
+
+ Extruder() {
+ ToolNum=0;
+ Filament=new Material("ABS");
+ Diameter=0.6;
+ ZThick=0.37;
+ }
+
+ Extruder(int anInt) {
+ ToolNum=anInt;
+ Filament=new Material("ABS");
+ Diameter=0.6;
+ ZThick=0.37;
+ }
+
+ Extruder(int anInt, String aString) {
+ ToolNum=anInt;
+ Filament=new Material(aString);
+ Diameter=0.6;
+ ZThick=0.37;
+ }
+
+ void setDiameter(float aFloat) {
+ Diameter=aFloat;
+ if(ZThick>Diameter) {
+ println("Z thickness greater than extruded diameter. Setting Z thickness to half diameter.");
+ ZThick=Diameter/2;
+ }
+ }
+
+ void setZThick(float aFloat) {
+ if(aFloat<Diameter) {
+ ZThick=aFloat;
+ } else {
+ println("Z thickness greater than extruded diameter. Setting Z thickness to half diameter.");
+ ZThick=Diameter/2;
+ }
+ }
+
+ void setFlowRate(float aFloat) {
+ FlowRate=aFloat;
+ }
+
+ float calcWallWidth() {
+ float freespace_area=PI*pow(Diameter/2,2);
+ return(freespace_area/ZThick);
+ }
+}
+
View
101 Fill.pde
@@ -0,0 +1,101 @@
+// Fill Generation
+import java.awt.geom.Rectangle2D;
+
+class Fill {
+
+ boolean debugFlag;
+ int Width;
+ int Height;
+ Extruder ExtruderProperties;
+ float SparseFillDensity;
+ float RotateFillAngle;
+ SSArea SparseFill;
+ SSArea BridgeFill;
+
+ Fill(boolean bFlag, int iWidth, int iHeight, float fillDensity) {
+ RotateFillAngle=45.0;
+ debugFlag=bFlag;
+ Width=iWidth;
+ Height=iHeight;
+ if(fillDensity<0 || fillDensity>1.0) {
+ println("Sparse Fill Density out of 0 to 1.0 range. Setting to 0.5");
+ SparseFillDensity=0.5;
+ } else {
+ SparseFillDensity=fillDensity;
+ }
+ ExtruderProperties = new Extruder();
+ SparseFill = new SSArea();
+ SparseFill.setGridScale(0.01);
+ float wallWidth=ExtruderProperties.calcWallWidth();
+ for(float dx=0;dx<Width; dx+=2*wallWidth/fillDensity) {
+ Rectangle2D thisRect=new Rectangle2D.Float(dx,0,wallWidth/fillDensity,Height);
+ Area thisRectArea=new Area(thisRect);
+ AffineTransform centerAreaTransform = new AffineTransform();
+ centerAreaTransform.setToTranslation(-Width/2,-Height/2);
+ thisRectArea.transform(centerAreaTransform);
+ SparseFill.add(thisRectArea);
+ }
+ BridgeFill = new SSArea();
+ BridgeFill.setGridScale(0.01);
+ for(float dx=0;dx<Width; dx+=2*wallWidth) {
+ Rectangle2D thisRect=new Rectangle2D.Float(dx,0,wallWidth,Height);
+ Area thisRectArea=new Area(thisRect);
+ AffineTransform centerAreaTransform = new AffineTransform();
+ centerAreaTransform.setToTranslation(-Width/2,-Height/2);
+ thisRectArea.transform(centerAreaTransform);
+ BridgeFill.add(thisRectArea);
+ }
+ }
+
+ ArrayList GenerateFill(ArrayList SliceList) {
+ ArrayList FillAreaList = new ArrayList();
+ float wallWidth=ExtruderProperties.calcWallWidth();
+ for(int LayerNum=0; LayerNum<SliceList.size();LayerNum++) {
+ SSArea thisArea = (SSArea) SliceList.get(LayerNum);
+ // Shell area to subtract off slice.
+ SSArea thisShell = new SSArea();
+ thisShell.setGridScale(thisArea.getGridScale());
+ thisShell.add(thisArea);
+ thisShell.makeShell(wallWidth);
+ // Fill mask area
+ SSArea thisFill = new SSArea();
+ thisFill.setGridScale(thisArea.getGridScale());
+ thisFill.add(thisArea);
+ thisFill.subtract(thisShell);
+ // Identify bridge areas for special treatment.
+ SSArea thisBridge = new SSArea();
+ thisBridge.setGridScale(thisFill.getGridScale());
+ thisBridge.add(thisFill);
+ AffineTransform rotateFill = new AffineTransform();
+ rotateFill.setToRotation(2*PI*RotateFillAngle/360.0);
+ BridgeFill.transform(rotateFill);
+ SparseFill.transform(rotateFill);
+ if(LayerNum==0 || LayerNum==SliceList.size()-1) {
+ // Bottom and Top layer special case.
+ thisFill.intersect(BridgeFill);
+ } else {
+ SSArea prevArea = (SSArea) SliceList.get(LayerNum-1);
+ thisBridge.subtract(prevArea);
+ // Identify cap areas for special treatment.
+ SSArea nextArea = (SSArea) SliceList.get(LayerNum+1);
+ SSArea thisCap = new SSArea();
+ thisCap.setGridScale(thisFill.getGridScale());
+ thisCap.add(thisArea);
+ thisCap.subtract(nextArea);
+ thisBridge.add(thisCap);
+ if(!thisBridge.isEmpty()) {
+ thisFill.subtract(thisBridge);
+ thisBridge.intersect(BridgeFill);
+ thisFill.intersect(SparseFill);
+ thisFill.add(thisBridge);
+ } else {
+ thisFill.intersect(SparseFill);
+ }
+ }
+ // Subtract bridge areas from fill mask
+ FillAreaList.add(LayerNum,thisFill);
+ }
+ return(FillAreaList);
+ }
+}
+
View
27 Material.pde
@@ -0,0 +1,27 @@
+// Material Class
+
+class Material {
+ String TypeName;
+ float MeltTemp;
+ float ExtrudeTemp;
+
+ Material(String aString) {
+ if(aString == "ABS") {
+ TypeName=aString;
+ MeltTemp=100.0;
+ ExtrudeTemp=220.0;
+ } else {
+ TypeName=aString;
+ MeltTemp=0;
+ ExtrudeTemp=0;
+ }
+ }
+
+ void setMeltTemp(float aFloat) {
+ MeltTemp=aFloat;
+ }
+ void setExtrudeTemp(float aFloat) {
+ ExtrudeTemp=aFloat;
+ }
+
+}
View
20 SuperSkein.pde
@@ -247,7 +247,10 @@ void mousePressed()
if(GUIPage==0)STLName.checkFocus(mouseX,mouseY);
if(GUIPage==0)STLScale.checkFocus(mouseX,mouseY);
if(GUIPage==0)STLXRotate.checkFocus(mouseX,mouseY);
- if(GUIPage==0 && STLName.Focus) STLName.Text=selectInput();
+ if(GUIPage==0 && STLName.Focus) {
+ String newName=selectInput("Select STL to Load");
+ STLName.Text=newName;
+ }
if(LeftButton.over(mouseX,mouseY))GUIPage--;
if(RightButton.over(mouseX,mouseY))GUIPage++;
@@ -354,20 +357,22 @@ class FileWriteProc implements Runnable{
thisSubArea.subtract(thisShell);
ShellAreaList.add(ShellNum,thisSubArea);
}
+ Fill areaFill=new Fill(true,round(BuildPlatformWidth),round(BuildPlatformHeight),0.2);
+ ArrayList FillAreaList = areaFill.GenerateFill(ShellAreaList);
String GCodeFileName = selectOutput("Save G-Code to This File");
if(GCodeFileName == null) {
println("No file was selected; using STL File as G-Code file prefix.");
GCodeFileName=STLName.Text+".gcode";
}
- AreaWriter gcodeOut=new AreaWriter(false,round(BuildPlatformWidth),round(BuildPlatformHeight));
+ AreaWriter gcodeOut=new AreaWriter(debugFlag,round(BuildPlatformWidth),round(BuildPlatformHeight));
gcodeOut.setOperatingTemp(OperatingTemp);
gcodeOut.setFlowRate(FlowRate);
gcodeOut.setLayerThickness(LayerThickness);
gcodeOut.setPrintHeadSpeed(PrintHeadSpeed);
- gcodeOut.ArrayList2GCode(GCodeFileName,SliceAreaList,ShellAreaList,new ArrayList());
+ gcodeOut.ArrayList2GCode(GCodeFileName,SliceAreaList,ShellAreaList,FillAreaList);
FileWriteFraction=1.5;
print("\nFinished Slicing! Bounding Box is:\n");
@@ -398,6 +403,7 @@ class DXFWriteProc implements Runnable{
}
String DXFSliceFileName;
String DXFShellFileName;
+ String DXFFillFileName;
// int DXFSliceNum;
String OpenSCADFileName = DXFSliceFilePrefix + "_" + LayerThickness + ".scad";
@@ -429,6 +435,7 @@ class DXFWriteProc implements Runnable{
thisArea.Slice2Area(ThisSlice);
SliceAreaList.add(SliceNum, thisArea);
}
+
ArrayList ShellAreaList = new ArrayList();
for(int ShellNum=0;ShellNum<SliceAreaList.size();ShellNum++) {
SSArea thisArea = (SSArea) SliceAreaList.get(ShellNum);
@@ -451,6 +458,9 @@ class DXFWriteProc implements Runnable{
ShellAreaList.add(ShellNum,thisShell);
}
+ Fill areaFill=new Fill(true,round(BuildPlatformWidth),round(BuildPlatformHeight),0.2);
+ ArrayList FillAreaList = areaFill.GenerateFill(SliceAreaList);
+
DXFSliceFileName = DXFSliceFilePrefix + "_slices_" + LayerThickness + ".dxf";
print("DXF Slice File Name: " + DXFSliceFileName + "\n");
AreaWriter dxfOut = new AreaWriter(false,round(BuildPlatformWidth),round(BuildPlatformHeight));
@@ -460,6 +470,10 @@ class DXFWriteProc implements Runnable{
print("DXF Shell File Name: " + DXFShellFileName + "\n");
dxfOut.ArrayList2DXF(DXFShellFileName,ShellAreaList);
+ DXFFillFileName = DXFSliceFilePrefix + "_fill_" + LayerThickness + ".dxf";
+ print("DXF Fill File Name: " + DXFFillFileName + "\n");
+ dxfOut.ArrayList2DXF(DXFFillFileName,FillAreaList);
+
for(int DXFSliceNum=0;DXFSliceNum<SliceAreaList.size();DXFSliceNum++) {
output.println(" if(index>="+DXFSliceNum+"&&index<(1+"+DXFSliceNum+")) {");
output.println(" echo(\" Instantiating slice "+DXFSliceNum+".\");");
View
2 config.txt
@@ -1,6 +1,6 @@
CONFIG_SCALE 1.0
CONFIG_XROTATE 0.0
-CONFIG_STLFILE Z_Bracket.stl
+CONFIG_STLFILE sculpt_dragon.stl
MACHINE_OPTEMP 220
MACHINE_FLOWRATE 190
CONFIG_SINK 0.0

0 comments on commit e3b7c58

Please sign in to comment.