5
5
#include " enums.h"
6
6
7
7
// Holds the geometric aspects of a button
8
- class DiskPart
8
+ class DiskPart
9
9
{
10
10
// Both innerRing and outerRing can take values [0,4]
11
11
// 0 is the middle point, 1-2-3 are the next outer rings, 4 is the ring outside the screen
@@ -20,26 +20,26 @@ class DiskPart
20
20
int loop, row;
21
21
22
22
public:
23
- DiskPart ();
24
- DiskPart (int inpLoop, int inpRow);
25
- int getOrigLoop () const ;
26
- int getOrigRow () const ;
27
- void mergeRadially (PosChart &positions);
28
- void mergeLaterally (PosChart &positions, lateralMergePhases ph);
29
- void getShape (int &loopStart, int &loopEnd, int &rowStart, int &rowEnd);
30
- bool isInDisk (int inpLoop, int inpRow);
23
+ DiskPart ();
24
+ DiskPart (int inpLoop, int inpRow);
25
+ int getOrigLoop () const ;
26
+ int getOrigRow () const ;
27
+ void mergeRadially (PosChart &positions);
28
+ void mergeLaterally (PosChart &positions, lateralMergePhases ph);
29
+ void getShape (int &loopStart, int &loopEnd, int &rowStart, int &rowEnd);
30
+ bool isInDisk (int inpLoop, int inpRow);
31
31
};
32
32
33
- DiskPart::DiskPart ()
33
+ DiskPart::DiskPart ()
34
34
{
35
35
}
36
- DiskPart::DiskPart (int inpLoop, int inpRow)
36
+ DiskPart::DiskPart (int inpLoop, int inpRow)
37
37
{
38
38
loop = inpLoop;
39
39
row = inpRow;
40
40
41
41
innerRing = loop;
42
- outerRing = loop+ 1 ;
42
+ outerRing = loop + 1 ;
43
43
44
44
if (loop == 0 )
45
45
{
@@ -58,35 +58,35 @@ DiskPart::DiskPart (int inpLoop, int inpRow)
58
58
}
59
59
}
60
60
61
- int DiskPart::getOrigLoop () const
61
+ int DiskPart::getOrigLoop () const
62
62
{
63
63
return loop;
64
64
}
65
- int DiskPart::getOrigRow () const
65
+ int DiskPart::getOrigRow () const
66
66
{
67
67
return row;
68
68
}
69
69
70
70
71
71
// This is the merge that will happen first.
72
- void DiskPart::mergeRadially (PosChart &positions)
72
+ void DiskPart::mergeRadially (PosChart &positions)
73
73
{
74
74
switch (loop)
75
75
{
76
76
case 0 :
77
77
// middle loop cannot merge radially
78
78
break ;
79
79
case 1 :
80
- if (positions.getLoop (2 )[row]== 0 )
80
+ if (positions.getLoop (2 )[row] == 0 )
81
81
{
82
- positions.fillPos (2 , row);
82
+ positions.fillPos (2 , row);
83
83
outerRing = 3 ;
84
84
}
85
85
break ;
86
86
case 2 :
87
- if (positions.getLoop (1 )[row]== 0 )
87
+ if (positions.getLoop (1 )[row] == 0 )
88
88
{
89
- positions.fillPos (1 , row);
89
+ positions.fillPos (1 , row);
90
90
innerRing = 1 ;
91
91
}
92
92
break ;
@@ -97,7 +97,7 @@ void DiskPart::mergeRadially (PosChart &positions)
97
97
// First phase merges non-radially-merged buttons (ccw).
98
98
// Second phase merges radially-merged buttons (ccw).
99
99
// Third phase merges any remaining empty spaces (cw).
100
- void DiskPart::mergeLaterally (PosChart &positions, lateralMergePhases ph)
100
+ void DiskPart::mergeLaterally (PosChart &positions, lateralMergePhases ph)
101
101
{
102
102
switch (ph)
103
103
{
@@ -109,18 +109,18 @@ void DiskPart::mergeLaterally (PosChart &positions, lateralMergePhases ph)
109
109
if (loop == 0 )
110
110
{
111
111
// the first loop has only two buttons
112
- if (positions.getLoop (loop)[(row + 1 ) % 2 ] == 0 )
112
+ if (positions.getLoop (loop)[(row + 1 ) % 2 ] == 0 )
113
113
{
114
- positions.fillPos (loop, (row + 1 ) % 2 );
114
+ positions.fillPos (loop, (row + 1 ) % 2 );
115
115
startSlice = stopSlice = 0 ;
116
116
}
117
117
}
118
118
else
119
119
{
120
120
// other loops have 12 buttons
121
- if (positions.getLoop (loop)[(row + 1 ) % 12 ] == 0 )
121
+ if (positions.getLoop (loop)[(row + 1 ) % 12 ] == 0 )
122
122
{
123
- positions.fillPos (loop, (row + 1 ) % 12 );
123
+ positions.fillPos (loop, (row + 1 ) % 12 );
124
124
stopSlice = (row + 2 ) % 12 ;
125
125
}
126
126
}
@@ -133,12 +133,12 @@ void DiskPart::mergeLaterally (PosChart &positions, lateralMergePhases ph)
133
133
if (outerRing - innerRing == 2 )
134
134
{
135
135
// check if both nearby positions are available
136
- if ((positions.getLoop (1 )[(row + 1 ) % 12 ] == 0 ) && (positions.getLoop (2 )[(row + 1 ) % 12 ] == 0 ))
137
- {
138
- positions.fillPos (1 , (row + 1 ) % 12 );
139
- positions.fillPos (2 , (row + 1 ) % 12 );
140
- stopSlice = (row + 2 ) % 12 ;
141
- }
136
+ if ((positions.getLoop (1 )[(row + 1 ) % 12 ] == 0 ) && (positions.getLoop (2 )[(row + 1 ) % 12 ] == 0 ))
137
+ {
138
+ positions.fillPos (1 , (row + 1 ) % 12 );
139
+ positions.fillPos (2 , (row + 1 ) % 12 );
140
+ stopSlice = (row + 2 ) % 12 ;
141
+ }
142
142
}
143
143
break ;
144
144
@@ -149,35 +149,35 @@ void DiskPart::mergeLaterally (PosChart &positions, lateralMergePhases ph)
149
149
// don't need to merge middle again
150
150
if (loop != 0 )
151
151
{
152
- if (positions.getLoop (loop)[(row + 11 ) % 12 ] == 0 )
152
+ if (positions.getLoop (loop)[(row + 11 ) % 12 ] == 0 )
153
153
{
154
- positions.fillPos (loop, (row + 11 ) % 12 );
154
+ positions.fillPos (loop, (row + 11 ) % 12 );
155
155
startSlice = (row + 11 ) % 12 ;
156
156
}
157
157
}
158
158
}
159
159
else if (outerRing - innerRing == 2 )
160
160
{
161
- if ((positions.getLoop (1 )[(row + 11 ) % 12 ] == 0 ) && (positions.getLoop (2 )[(row + 11 ) % 12 ] == 0 ))
162
- {
163
- positions.fillPos (1 , (row + 11 ) % 12 );
164
- positions.fillPos (2 , (row + 11 ) % 12 );
165
- startSlice = (row + 11 ) % 12 ;
166
- }
161
+ if ((positions.getLoop (1 )[(row + 11 ) % 12 ] == 0 ) && (positions.getLoop (2 )[(row + 11 ) % 12 ] == 0 ))
162
+ {
163
+ positions.fillPos (1 , (row + 11 ) % 12 );
164
+ positions.fillPos (2 , (row + 11 ) % 12 );
165
+ startSlice = (row + 11 ) % 12 ;
166
+ }
167
167
}
168
168
break ;
169
169
}
170
170
}
171
171
172
- void DiskPart::getShape (int &loopStart, int &loopEnd, int &rowStart, int &rowEnd)
172
+ void DiskPart::getShape (int &loopStart, int &loopEnd, int &rowStart, int &rowEnd)
173
173
{
174
174
loopStart = innerRing;
175
175
loopEnd = outerRing;
176
176
rowStart = startSlice;
177
177
rowEnd = stopSlice;
178
178
}
179
179
180
- bool DiskPart::isInDisk (int inpLoop, int inpRow)
180
+ bool DiskPart::isInDisk (int inpLoop, int inpRow)
181
181
{
182
182
switch (inpLoop)
183
183
{
0 commit comments