| 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 |
package gen.lib.label; |
| 47 |
import static gen.lib.label.node__c.AddBranch; |
| 48 |
import static gen.lib.label.node__c.InitNode; |
| 49 |
import static gen.lib.label.node__c.RTreeNewNode; |
| 50 |
import static gen.lib.label.rectangle__c.CombineRect; |
| 51 |
import static gen.lib.label.rectangle__c.NullRect; |
| 52 |
import static gen.lib.label.rectangle__c.RectArea; |
| 53 |
import static smetana.core.JUtilsDebug.ENTERING; |
| 54 |
import static smetana.core.JUtilsDebug.LEAVING; |
| 55 |
import static smetana.core.Macro.N; |
| 56 |
import static smetana.core.Macro.UNSUPPORTED; |
| 57 |
import h.Branch_t; |
| 58 |
import h.ST_Branch_t; |
| 59 |
import h.ST_Node_t___; |
| 60 |
import h.ST_PartitionVars; |
| 61 |
import h.ST_RTree; |
| 62 |
import h.ST_Rect_t; |
| 63 |
|
| 64 |
public class split_q__c { |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public static void SplitNode(ST_RTree rtp, ST_Node_t___ n, ST_Branch_t b, ST_Node_t___ nn[]) { |
| 70 |
ENTERING("6vl3snxd6k95gamfkwfsfdguc","SplitNode"); |
| 71 |
try { |
| 72 |
ST_PartitionVars p; |
| 73 |
int level; |
| 74 |
int area; |
| 75 |
|
| 76 |
|
| 77 |
if (rtp.StatFlag!=0) { |
| 78 |
UNSUPPORTED("akhni40ndam0u9c6i7raxw4mp"); |
| 79 |
UNSUPPORTED("4g80zdlbvunm838x8g3ic9tex"); |
| 80 |
UNSUPPORTED("9352ql3e58qs4fzapgjfrms2s"); |
| 81 |
UNSUPPORTED("2cjo6wz1rmxfm5k7u7rw5dqpj"); |
| 82 |
} |
| 83 |
|
| 84 |
level = n.level; |
| 85 |
GetBranches(rtp, n, b); |
| 86 |
|
| 87 |
p = rtp.split.Partitions[0]; |
| 88 |
MethodZero(rtp); |
| 89 |
area = RectArea((ST_Rect_t)p.cover[0]) + RectArea((ST_Rect_t)p.cover[1]); |
| 90 |
|
| 91 |
if (rtp.StatFlag!=0 && N(rtp.Deleting) && area!=0) |
| 92 |
UNSUPPORTED("z7xk6s3hzi3qcoiq2exj9hpv"); |
| 93 |
|
| 94 |
nn[0] = RTreeNewNode(rtp); |
| 95 |
n.setInt("level", level); |
| 96 |
nn[0].setInt("level", level); |
| 97 |
LoadNodes(rtp, n, nn[0], p); |
| 98 |
|
| 99 |
} finally { |
| 100 |
LEAVING("6vl3snxd6k95gamfkwfsfdguc","SplitNode"); |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
public static void GetBranches(ST_RTree rtp, ST_Node_t___ n, ST_Branch_t b) { |
| 110 |
ENTERING("al7lyin008m7kvrvuxhcuvn61","GetBranches"); |
| 111 |
try { |
| 112 |
int i; |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
for (i = 0; i < 64; i++) { |
| 117 |
|
| 118 |
rtp.split.BranchBuf[i].___(n.branch[i]); |
| 119 |
} |
| 120 |
rtp.split.BranchBuf[64].___(b); |
| 121 |
|
| 122 |
rtp.split.CoverSplit.___(rtp.split.BranchBuf[0].rect); |
| 123 |
for (i = 1; i < 64 + 1; i++) { |
| 124 |
rtp.split.setStruct("CoverSplit", |
| 125 |
CombineRect((ST_Rect_t)rtp.split.CoverSplit, |
| 126 |
(ST_Rect_t)rtp.split.BranchBuf[i].castTo(ST_Rect_t.class))); |
| 127 |
} |
| 128 |
rtp.split.setInt("CoverSplitArea", RectArea((ST_Rect_t)rtp.split.CoverSplit)); |
| 129 |
InitNode(n); |
| 130 |
} finally { |
| 131 |
LEAVING("al7lyin008m7kvrvuxhcuvn61","GetBranches"); |
| 132 |
} |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
public static void MethodZero(ST_RTree rtp) { |
| 141 |
ENTERING("4woz5xy4gjlahoj7no3ljxmex","MethodZero"); |
| 142 |
try { |
| 143 |
ST_Rect_t r; |
| 144 |
int i, growth0, growth1, diff, biggestDiff; |
| 145 |
int group, chosen=0, betterGroup=0; |
| 146 |
InitPVars(rtp); |
| 147 |
PickSeeds(rtp); |
| 148 |
while (rtp.split.Partitions[0].count[0] + |
| 149 |
rtp.split.Partitions[0].count[1] < 64 + 1 && |
| 150 |
rtp.split.Partitions[0].count[0] < 64 + 1 - rtp.MinFill |
| 151 |
&& rtp.split.Partitions[0].count[1] < |
| 152 |
64 + 1 - rtp.MinFill) { |
| 153 |
biggestDiff = -1; |
| 154 |
for (i = 0; i < 64 + 1; i++) { |
| 155 |
if (N(rtp.split.Partitions[0].taken[i])) { |
| 156 |
final ST_Rect_t rect = new ST_Rect_t(); |
| 157 |
r = (ST_Rect_t) rtp.split.BranchBuf[i].castTo(ST_Rect_t.class); |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
rect.___(CombineRect(r, (ST_Rect_t) rtp.split.Partitions[0].cover[0])); |
| 167 |
growth0 = |
| 168 |
RectArea((ST_Rect_t)rect) - rtp.split.Partitions[0].area[0]; |
| 169 |
rect.___(CombineRect(r, (ST_Rect_t) rtp.split.Partitions[0].cover[1])); |
| 170 |
growth1 = |
| 171 |
RectArea((ST_Rect_t)rect) - rtp.split.Partitions[0].area[1]; |
| 172 |
diff = growth1 - growth0; |
| 173 |
if (diff >= 0) |
| 174 |
group = 0; |
| 175 |
else { |
| 176 |
group = 1; |
| 177 |
diff = -diff; |
| 178 |
} |
| 179 |
if (diff > biggestDiff) { |
| 180 |
biggestDiff = diff; |
| 181 |
chosen = i; |
| 182 |
betterGroup = group; |
| 183 |
} else if (diff == biggestDiff && |
| 184 |
rtp.split.Partitions[0].count[group] < |
| 185 |
rtp.split.Partitions[0].count[betterGroup]) { |
| 186 |
chosen = i; |
| 187 |
betterGroup = group; |
| 188 |
} |
| 189 |
} |
| 190 |
} |
| 191 |
Classify(rtp, chosen, betterGroup); |
| 192 |
} |
| 193 |
|
| 194 |
if (rtp.split.Partitions[0].count[0] + |
| 195 |
rtp.split.Partitions[0].count[1] < 64 + 1) { |
| 196 |
group = 0; |
| 197 |
UNSUPPORTED("4edp65b21liyii0fj1ikco7o0"); |
| 198 |
UNSUPPORTED("20lpsuiyepr2ujozaf6gp4cc"); |
| 199 |
UNSUPPORTED("9qtt6i40h8vtjp2cvqyb8ycaz"); |
| 200 |
UNSUPPORTED("2x1nx9nsne4x3ygmcywl1m3og"); |
| 201 |
UNSUPPORTED("jdepsnmrs3ghh78ql301sfvu"); |
| 202 |
UNSUPPORTED("gqfhorilvtlogp6f2ozx5akf"); |
| 203 |
UNSUPPORTED("flupwh3kosf3fkhkxllllt1"); |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
} finally { |
| 210 |
LEAVING("4woz5xy4gjlahoj7no3ljxmex","MethodZero"); |
| 211 |
} |
| 212 |
} |
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
public static void PickSeeds(ST_RTree rtp) { |
| 220 |
ENTERING("8rui4cun4tvq5xy6ke6r3p55e","PickSeeds"); |
| 221 |
try { |
| 222 |
int i, j; |
| 223 |
int waste, worst; |
| 224 |
int seed0=0, seed1=0; |
| 225 |
int area[] = new int[64 + 1]; |
| 226 |
for (i = 0; i < 64 + 1; i++) |
| 227 |
area[i] = RectArea((ST_Rect_t) rtp.split.BranchBuf[i].rect); |
| 228 |
|
| 229 |
worst=0; |
| 230 |
for (i = 0; i < 64; i++) { |
| 231 |
for (j = i + 1; j < 64 + 1; j++) { |
| 232 |
final ST_Rect_t rect = new ST_Rect_t(); |
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
rect.___( |
| 237 |
CombineRect((ST_Rect_t)rtp.split.BranchBuf[i].rect, |
| 238 |
(ST_Rect_t)rtp.split.BranchBuf[j].rect)); |
| 239 |
waste = RectArea((ST_Rect_t)rect) - area[i] - area[j]; |
| 240 |
if (waste > worst) { |
| 241 |
worst = waste; |
| 242 |
seed0 = i; |
| 243 |
seed1 = j; |
| 244 |
} |
| 245 |
} |
| 246 |
} |
| 247 |
Classify(rtp, seed0, 0); |
| 248 |
Classify(rtp, seed1, 1); |
| 249 |
} finally { |
| 250 |
LEAVING("8rui4cun4tvq5xy6ke6r3p55e","PickSeeds"); |
| 251 |
} |
| 252 |
} |
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
public static void Classify(ST_RTree rtp, int i, int group) { |
| 260 |
ENTERING("4qyy2dpbkziuubssvfwb8u1sh","Classify"); |
| 261 |
try { |
| 262 |
|
| 263 |
rtp.split.Partitions[0].partition[i]=group; |
| 264 |
rtp.split.Partitions[0].taken[i]=1; |
| 265 |
if (rtp.split.Partitions[0].count[group] == 0) |
| 266 |
rtp.split.Partitions[0].cover[group].___( |
| 267 |
rtp.split.BranchBuf[i].rect); |
| 268 |
else |
| 269 |
rtp.split.Partitions[0].cover[group].___( |
| 270 |
CombineRect((ST_Rect_t)rtp.split.BranchBuf[i].rect, |
| 271 |
(ST_Rect_t)rtp.split.Partitions[0].cover[group])); |
| 272 |
rtp.split.Partitions[0].area[group]= |
| 273 |
RectArea((ST_Rect_t)rtp.split.Partitions[0].cover[group]); |
| 274 |
|
| 275 |
rtp.split.Partitions[0].count[group]= |
| 276 |
rtp.split.Partitions[0].count[group]+1; |
| 277 |
} finally { |
| 278 |
LEAVING("4qyy2dpbkziuubssvfwb8u1sh","Classify"); |
| 279 |
} |
| 280 |
} |
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
public static void LoadNodes(ST_RTree rtp, ST_Node_t___ n, ST_Node_t___ q, ST_PartitionVars p) { |
| 288 |
ENTERING("ay7l4setwyl3hbx4o2jpa7vyz","LoadNodes"); |
| 289 |
try { |
| 290 |
int i; |
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
for (i = 0; i < 64 + 1; i++) { |
| 295 |
|
| 296 |
|
| 297 |
if (rtp.split.Partitions[0].partition[i] == 0) |
| 298 |
AddBranch(rtp, (ST_Branch_t)rtp.split.BranchBuf[i].castTo(Branch_t.class), n, null); |
| 299 |
else if (rtp.split.Partitions[0].partition[i] == 1) |
| 300 |
AddBranch(rtp, (ST_Branch_t)rtp.split.BranchBuf[i].castTo(Branch_t.class), q, null); |
| 301 |
} |
| 302 |
} finally { |
| 303 |
LEAVING("ay7l4setwyl3hbx4o2jpa7vyz","LoadNodes"); |
| 304 |
} |
| 305 |
} |
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
public static void InitPVars(ST_RTree rtp) { |
| 313 |
ENTERING("dvgjc83sogjhzf5kxpir405rh","InitPVars"); |
| 314 |
int i; |
| 315 |
rtp.split.Partitions[0].count[0]=0; |
| 316 |
rtp.split.Partitions[0].count[1]=0; |
| 317 |
rtp.split.Partitions[0].cover[0].___(NullRect()); |
| 318 |
rtp.split.Partitions[0].cover[1].___(NullRect()); |
| 319 |
rtp.split.Partitions[0].area[0]=0; |
| 320 |
rtp.split.Partitions[0].area[1]=0; |
| 321 |
for (i = 0; i < 64 + 1; i++) { |
| 322 |
rtp.split.Partitions[0].taken[i]=0; |
| 323 |
rtp.split.Partitions[0].partition[i]=-1; |
| 324 |
} |
| 325 |
try { |
| 326 |
} finally { |
| 327 |
LEAVING("dvgjc83sogjhzf5kxpir405rh","InitPVars"); |
| 328 |
} |
| 329 |
} |
| 330 |
|
| 331 |
|
| 332 |
} |