-class dBolt {
- dStrip v, h;
- int vpos, hpos;
- dBolt(dStrip _v, dStrip _h, int _vpos, int _hpos) {
- v=_v; h=_h; vpos=_vpos; hpos=_hpos;
- if (v.b0 == null) { v.b0=this; h.b0=this; }
- else { v.b1=this; h.b1=this; }
- }
-}
-
-class dVertex {
- dStrip s1 , s2 ;
- int dir1, dir2 ;
- dVertex(dStrip s, int d) {
- int _a = (s.iS%4==1)? (d==1? 5: 3) :
- (s.iS%4==3)? (d==1? 9:11) :
- (d==1) ? (s.Top()?4:12) : (s.Top()?12:4);
- dir1 = d * (s.isVert() ? -1 : 1);
- dir2 = d;
- s1 = DL_.DS[s.iCube() + ((s.iS+_a) % 16)];
- s2 = DL_.DS[d == 1 ? (s.idx == s.iFace()+3 ? s.idx-3 : s.idx+1):
- (s.idx == s.iFace() ? s.idx+3 : s.idx-1)];
- swapout(1 , 6);
- swapout(15,-6);
- }
- void swapout(int a, int b) {
- if (s1.iS == a) { s1 = DL_.DS[s1.idx + b]; dir1 = -dir1; }
- if (s2.iS == a) { s2 = DL_.DS[s2.idx + b]; dir2 = -dir2; }
- }
-
-}
-
-class dStrip { // THIS WAS SUCH A PAIN!
- int row, col, ci, idx, iS, axis; // 1-y, 2-left, 3-right
- Strip s;
- boolean bTop; // direction: top ccw, bottom cw.
-
- boolean Top (){ return axis!=1 && bTop ; }
- boolean Bottom(){ return axis!=1 && !bTop; }
- boolean isVert(){ return axis==1; }
- boolean isHorz(){ return axis!=1; }
- int iCube (){ return 16*floor(idx/16); }
- int iFace (){ return iCube() + 4*floor(iS/4); }
-
- void init(Strip _s, int _i, int _row, int _col) {
- idx = _i; row = _row; col = _col; s = _s;
- iS = idx%16; bTop = (iS%4==0);
- ci = s.points.get(0).index;
- DL_.DQ[col][row] = iCube();
- switch (iS) {
- case 4: case 6 : case 12: case 14: axis=2; break;
- case 0: case 2 : case 8 : case 10: axis=3; break;
- default: axis=1; break;
- }
- }
-
- void addBolts() {
- v0 = new dVertex(this, 1);
- v1 = new dVertex(this,-1);
-
-
- if (iS == 7 && col != 0 && row != 0) // left bottom
- new dBolt(this, DL_.GetStrip(row-1,col-1,(col % 2 == 1) ? 8 : 12),
- 4, (col % 2 == 1) ? 6 : 9);
-
- if (iS == 7 && col != 0 && row < MaxCubeHeight*2-2) // left top
- new dBolt(this, DL_.GetStrip(row+1,col-1,(col % 2 == 1) ? 10 : 14),
- 11, (col % 2 == 1) ? 9 : 6);
-
- if (iS == 9 && col < NumBackTowers-1 && row < MaxCubeHeight*2-2) // right top
- new dBolt(this, DL_.GetStrip(row+1,col+1,(col % 2 == 1) ? 6 : 2),
- 4, (col % 2 == 1) ? 6 : 9);
-
- if (iS == 9 && col < NumBackTowers-1 && row != 0) // right bottom
- new dBolt(this, DL_.GetStrip(row-1,col+1,(col % 2 == 1) ? 4 : 0),
- 11, (col % 2 == 1) ? 9 : 6);
- }
-
- dBolt b0, b1;
- dVertex v0, v1;
-}
-