-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fill.pde
103 lines (98 loc) · 3.52 KB
/
Fill.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// 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();
float wallWidth = MyConfig.WallWidth;
for(float dx=0;dx<2*Width; dx+=2*wallWidth/fillDensity) {
Rectangle2D thisRect=new Rectangle2D.Float(dx,0,wallWidth/fillDensity,2*Height);
Area thisRectArea=new Area(thisRect);
AffineTransform centerAreaTransform = new AffineTransform();
centerAreaTransform.setToTranslation(-Width,-Height);
thisRectArea.transform(centerAreaTransform);
SparseFill.add(thisRectArea);
}
BridgeFill = new SSArea();
BridgeFill.setGridScale(0.01);
for(float dx=0;dx<2*Width; dx+=2*wallWidth) {
Rectangle2D thisRect=new Rectangle2D.Float(dx,0,wallWidth,2*Height);
Area thisRectArea=new Area(thisRect);
AffineTransform centerAreaTransform = new AffineTransform();
centerAreaTransform.setToTranslation(-Width,-Height);
thisRectArea.transform(centerAreaTransform);
BridgeFill.add(thisRectArea);
}
}
ArrayList GenerateFill(ArrayList SliceList) {
ArrayList FillAreaList = new ArrayList();
//float wallWidth=ExtruderProperties.calcWallWidth();
float wallWidth = MyConfig.WallWidth;
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,8);
// 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);
}
}