| 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.cdt.dtclose__c.dtclose; |
| 48 |
import static gen.lib.cdt.dtopen__c.dtopen; |
| 49 |
import static gen.lib.label.index__c.RTreeClose; |
| 50 |
import static gen.lib.label.index__c.RTreeInsert; |
| 51 |
import static gen.lib.label.index__c.RTreeLeafListFree; |
| 52 |
import static gen.lib.label.index__c.RTreeOpen; |
| 53 |
import static gen.lib.label.index__c.RTreeSearch; |
| 54 |
import static smetana.core.JUtils.EQ; |
| 55 |
import static smetana.core.JUtilsDebug.ENTERING; |
| 56 |
import static smetana.core.JUtilsDebug.LEAVING; |
| 57 |
import static smetana.core.Macro.N; |
| 58 |
import static smetana.core.Macro.UNSUPPORTED; |
| 59 |
import h.ST_BestPos_t; |
| 60 |
import h.ST_HDict_t; |
| 61 |
import h.ST_LeafList_t; |
| 62 |
import h.ST_Node_t___; |
| 63 |
import h.ST_RTree; |
| 64 |
import h.ST_Rect_t; |
| 65 |
import h.ST_XLabels_t; |
| 66 |
import h.ST_dt_s; |
| 67 |
import h.ST_dtdisc_s; |
| 68 |
import h.ST_label_params_t; |
| 69 |
import h.ST_object_t; |
| 70 |
import h.ST_point; |
| 71 |
import h.ST_pointf; |
| 72 |
import h.ST_xlabel_t; |
| 73 |
import smetana.core.Memory; |
| 74 |
import smetana.core.Z; |
| 75 |
import smetana.core.__ptr__; |
| 76 |
public class xlabels__c { |
| 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 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
public static int icompare(ST_dt_s dt, Object v1, Object v2, ST_dtdisc_s disc) { |
| 154 |
ENTERING("5p3ac8qk4gnne5hj1dc21ysi","icompare"); |
| 155 |
try { |
| 156 |
Integer k1 = (Integer) v1; |
| 157 |
Integer k2 = (Integer) v2; |
| 158 |
return k1 - k2; |
| 159 |
} finally { |
| 160 |
LEAVING("5p3ac8qk4gnne5hj1dc21ysi","icompare"); |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
public static ST_XLabels_t xlnew(ST_object_t.Array objs, int n_objs, ST_xlabel_t.Array lbls, int n_lbls, ST_label_params_t params) { |
| 170 |
ENTERING("88mbfm305igsr7cew5qx6yldp","xlnew"); |
| 171 |
try { |
| 172 |
ST_XLabels_t xlp; |
| 173 |
xlp = new ST_XLabels_t(); |
| 174 |
|
| 175 |
xlp.setPtr("hdx", dtopen(Z.z().Hdisc, Z.z().Dtobag)); |
| 176 |
if (N(xlp.hdx)) { |
| 177 |
UNSUPPORTED("4t1y5iinm4310lkpvbal1spve"); |
| 178 |
UNSUPPORTED("3m406diamp5s5kwcqtwo4pshf"); |
| 179 |
} |
| 180 |
|
| 181 |
xlp.setPtr("spdx", RTreeOpen()); |
| 182 |
if (N(xlp.spdx)) { |
| 183 |
UNSUPPORTED("4t1y5iinm4310lkpvbal1spve"); |
| 184 |
UNSUPPORTED("3m406diamp5s5kwcqtwo4pshf"); |
| 185 |
} |
| 186 |
|
| 187 |
xlp.objs = objs; |
| 188 |
xlp.setInt("n_objs", n_objs); |
| 189 |
xlp.lbls = lbls; |
| 190 |
xlp.setInt("n_lbls", n_lbls); |
| 191 |
xlp.setPtr("params", params); |
| 192 |
return (ST_XLabels_t) xlp; |
| 193 |
} finally { |
| 194 |
LEAVING("88mbfm305igsr7cew5qx6yldp","xlnew"); |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
public static void xlfree(ST_XLabels_t xlp) { |
| 212 |
ENTERING("apvhod2s1yjb8717rb7gie2kb","xlfree"); |
| 213 |
try { |
| 214 |
RTreeClose((ST_RTree) xlp.spdx); |
| 215 |
Memory.free(xlp); |
| 216 |
} finally { |
| 217 |
LEAVING("apvhod2s1yjb8717rb7gie2kb","xlfree"); |
| 218 |
} |
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
public static int floorLog2(int n) { |
| 227 |
ENTERING("6lz36gkh8fla3z6f0lxniy368","floorLog2"); |
| 228 |
try { |
| 229 |
int pos = 0; |
| 230 |
if (n == 0) |
| 231 |
return -1; |
| 232 |
if (n >= 1 << 16) { |
| 233 |
n >>= 16; |
| 234 |
pos += 16; |
| 235 |
} |
| 236 |
if (n >= 1 << 8) { |
| 237 |
n >>= 8; |
| 238 |
pos += 8; |
| 239 |
} |
| 240 |
if (n >= 1 << 4) { |
| 241 |
n >>= 4; |
| 242 |
pos += 4; |
| 243 |
} |
| 244 |
if (n >= 1 << 2) { |
| 245 |
n >>= 2; |
| 246 |
pos += 2; |
| 247 |
} |
| 248 |
if (n >= 1 << 1) { |
| 249 |
pos += 1; |
| 250 |
} |
| 251 |
return pos; |
| 252 |
} finally { |
| 253 |
LEAVING("6lz36gkh8fla3z6f0lxniy368","floorLog2"); |
| 254 |
} |
| 255 |
} |
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
public static int xlhorder(ST_XLabels_t xlp) { |
| 263 |
ENTERING("uvnzthcpf4xiih05gxie2rx1","xlhorder"); |
| 264 |
try { |
| 265 |
double maxx = xlp.params.bb.UR.x; |
| 266 |
double maxy = xlp.params.bb.UR.y; |
| 267 |
return floorLog2(maxx > maxy ? (int)maxx : (int)maxy) + 1; |
| 268 |
} finally { |
| 269 |
LEAVING("uvnzthcpf4xiih05gxie2rx1","xlhorder"); |
| 270 |
} |
| 271 |
} |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
public static int hd_hil_s_from_xy(ST_point p, int n) { |
| 279 |
ENTERING("9lkyvq87bawe3yon7bdwvcjzq","hd_hil_s_from_xy"); |
| 280 |
try { |
| 281 |
return hd_hil_s_from_xy_((ST_point) p.copy(), n); |
| 282 |
} finally { |
| 283 |
LEAVING("9lkyvq87bawe3yon7bdwvcjzq","hd_hil_s_from_xy"); |
| 284 |
} |
| 285 |
} |
| 286 |
private static int hd_hil_s_from_xy_(ST_point p, int n) { |
| 287 |
int i, x = p.x, y = p.y, xi, yi; |
| 288 |
int s; |
| 289 |
s = 0; |
| 290 |
for (i = n - 1; i >= 0; i--) { |
| 291 |
xi = (x >> i) & 1; |
| 292 |
yi = (y >> i) & 1; |
| 293 |
s = 4 * s + 2 * xi + (xi ^ yi); |
| 294 |
x = x ^ y; |
| 295 |
y = y ^ (x & (yi - 1)); |
| 296 |
x = x ^ y; |
| 297 |
x = x ^ (-xi & (yi - 1)); |
| 298 |
y = y ^ (-xi & (yi - 1)); |
| 299 |
} |
| 300 |
return s; |
| 301 |
} |
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
public static double aabbaabb(ST_Rect_t r, ST_Rect_t s) { |
| 309 |
ENTERING("bpkzwylrchx5wta1qhytfgbtr","aabbaabb"); |
| 310 |
try { |
| 311 |
|
| 312 |
double iminx, iminy, imaxx, imaxy; |
| 313 |
if (r.boundary[2] < s.boundary[0] || r.boundary[0] > s.boundary[2]) |
| 314 |
return 0; |
| 315 |
if (r.boundary[3] < s.boundary[1] || r.boundary[1] > s.boundary[3]) |
| 316 |
return 0; |
| 317 |
|
| 318 |
|
| 319 |
iminx = |
| 320 |
r.boundary[0] > s.boundary[0] ? r.boundary[0] : s.boundary[0]; |
| 321 |
|
| 322 |
iminy = |
| 323 |
r.boundary[1] > s.boundary[1] ? r.boundary[1] : s.boundary[1]; |
| 324 |
|
| 325 |
imaxx = |
| 326 |
r.boundary[2] < s.boundary[2] ? r.boundary[2] : s.boundary[2]; |
| 327 |
|
| 328 |
imaxy = |
| 329 |
r.boundary[3] < s.boundary[3] ? r.boundary[3] : s.boundary[3]; |
| 330 |
return (imaxx - iminx) * (imaxy - iminy); |
| 331 |
} finally { |
| 332 |
LEAVING("bpkzwylrchx5wta1qhytfgbtr","aabbaabb"); |
| 333 |
} |
| 334 |
} |
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
public static boolean lblenclosing(ST_object_t objp, ST_object_t objp1) { |
| 342 |
ENTERING("2g71cq6f8w5jbmbnn2x9y5qfq","lblenclosing"); |
| 343 |
try { |
| 344 |
ST_xlabel_t.Array xlp = (ST_xlabel_t.Array) objp.lbl; |
| 345 |
|
| 346 |
if(N(xlp)) return false; |
| 347 |
return objp1.pos.x > xlp.getStruct().pos.x && |
| 348 |
objp1.pos.x < (xlp.getStruct().pos.x + xlp.getStruct().sz.y) && |
| 349 |
objp1.pos.y > xlp.getStruct().pos.y && |
| 350 |
objp1.pos.y < (xlp.getStruct().pos.y + xlp.getStruct().sz.y); |
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
} finally { |
| 357 |
LEAVING("2g71cq6f8w5jbmbnn2x9y5qfq","lblenclosing"); |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
public static void objp2rect(ST_object_t op, ST_Rect_t r) { |
| 368 |
ENTERING("dq1wkb4oxshdggv6cwtgas6m","objp2rect"); |
| 369 |
try { |
| 370 |
r.boundary[0]=((int)op.pos.x); |
| 371 |
r.boundary[1]=((int)op.pos.y); |
| 372 |
r.boundary[2]=((int)(op.pos.x+op.sz.x)); |
| 373 |
r.boundary[3]=((int)(op.pos.y+op.sz.y)); |
| 374 |
} finally { |
| 375 |
LEAVING("dq1wkb4oxshdggv6cwtgas6m","objp2rect"); |
| 376 |
} |
| 377 |
} |
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
public static void objplp2rect(ST_object_t objp, ST_Rect_t r) { |
| 385 |
ENTERING("71b5ttp3xs7lo9fqgb7ypyqgx","objplp2rect"); |
| 386 |
try { |
| 387 |
ST_xlabel_t.Array lp = (ST_xlabel_t.Array) objp.lbl; |
| 388 |
r.boundary[0]=((int)lp.getStruct().pos.x); |
| 389 |
r.boundary[1]=((int)lp.getStruct().pos.y); |
| 390 |
r.boundary[2]=((int)(lp.getStruct().pos.x+lp.getStruct().sz.x)); |
| 391 |
r.boundary[3]=((int)(lp.getStruct().pos.y+lp.getStruct().sz.y)); |
| 392 |
} finally { |
| 393 |
LEAVING("71b5ttp3xs7lo9fqgb7ypyqgx","objplp2rect"); |
| 394 |
} |
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
public static ST_Rect_t objplpmks(ST_XLabels_t xlp, ST_object_t objp) { |
| 403 |
ENTERING("ksqjbiie0e6vvaeawdxriie5","objplpmks"); |
| 404 |
try { |
| 405 |
final ST_Rect_t rect = new ST_Rect_t(); |
| 406 |
final ST_pointf p = new ST_pointf(); |
| 407 |
p.setDouble("x", 0); |
| 408 |
p.setDouble("y", 0); |
| 409 |
if (objp.lbl!=null) |
| 410 |
p.___(objp.lbl.getStruct().sz); |
| 411 |
rect.boundary[0]=((int) Math.floor(objp.pos.x - p.x)); |
| 412 |
rect.boundary[1]=((int) Math.floor(objp.pos.y - p.y)); |
| 413 |
rect.boundary[2]=((int) Math.ceil(objp.pos.x + objp.sz.x + p.x)); |
| 414 |
|
| 415 |
rect.boundary[3]=((int) Math.ceil(objp.pos.y + objp.sz.y + p.y)); |
| 416 |
|
| 417 |
return rect; |
| 418 |
} finally { |
| 419 |
LEAVING("ksqjbiie0e6vvaeawdxriie5","objplpmks"); |
| 420 |
} |
| 421 |
} |
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
public static int getintrsxi(ST_XLabels_t xlp, ST_object_t op, ST_object_t cp) { |
| 429 |
ENTERING("calnhom3s9dqvvi6crrz3h2wp","getintrsxi"); |
| 430 |
try { |
| 431 |
int i = -1; |
| 432 |
ST_xlabel_t.Array lp = (ST_xlabel_t.Array) op.lbl, clp = (ST_xlabel_t.Array) cp.lbl; |
| 433 |
assert(lp != clp); |
| 434 |
if (lp.getStruct().set == 0 || clp.getStruct().set == 0) |
| 435 |
return i; |
| 436 |
UNSUPPORTED("bofpvwtmumoe1ckgnlgbwg8bt"); |
| 437 |
UNSUPPORTED("f039op8rn0jopi9r8kora4cwz"); |
| 438 |
UNSUPPORTED("11drvggon8u61uz4iw75insly"); |
| 439 |
UNSUPPORTED("5t4dji6xy0hdyx5wguao13hy5"); |
| 440 |
UNSUPPORTED("kx0a7gocqji2ms0neepjemp0"); |
| 441 |
UNSUPPORTED("al11nyatzn20y82ligyxw6doz"); |
| 442 |
UNSUPPORTED("6u28hrhgdf9tpy6v85nmoma8q"); |
| 443 |
UNSUPPORTED("3nbwdw3wfkpmnrf8loezvflkx"); |
| 444 |
UNSUPPORTED("9352ql3e58qs4fzapgjfrms2s"); |
| 445 |
UNSUPPORTED("akdfo982ws6tlct2c4wlm7hdb"); |
| 446 |
UNSUPPORTED("6h2iz13c1pog9oqz0a4f1sqth"); |
| 447 |
UNSUPPORTED("kx0a7gocqji2ms0neepjemp0"); |
| 448 |
UNSUPPORTED("2rdl000508m132a9u1h076lba"); |
| 449 |
UNSUPPORTED("6u28hrhgdf9tpy6v85nmoma8q"); |
| 450 |
UNSUPPORTED("7p6vu0p80gdkcsj4l5hz59dqb"); |
| 451 |
UNSUPPORTED("9352ql3e58qs4fzapgjfrms2s"); |
| 452 |
UNSUPPORTED("69apu46xpi0gdi4dt1tir6dbh"); |
| 453 |
UNSUPPORTED("73lwftxejfwwrm0v22inmutya"); |
| 454 |
UNSUPPORTED("9t0t38axcdz9uuxxaxd4e5oi2"); |
| 455 |
UNSUPPORTED("an605gtk4m1ql9srrrj5k6dah"); |
| 456 |
UNSUPPORTED("cmp9l0lizmu0ars1jf1oxdms"); |
| 457 |
UNSUPPORTED("ahwo5hst5k1gyq20ve63ahe81"); |
| 458 |
UNSUPPORTED("c24nfmv9i7o5eoqaymbibp7m7"); |
| 459 |
|
| 460 |
throw new UnsupportedOperationException(); |
| 461 |
} finally { |
| 462 |
LEAVING("calnhom3s9dqvvi6crrz3h2wp","getintrsxi"); |
| 463 |
} |
| 464 |
} |
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
public static double recordointrsx(ST_XLabels_t xlp, ST_object_t op, ST_object_t cp, ST_Rect_t rp, double a, ST_object_t[] intrsx) { |
| 472 |
ENTERING("52awwxu810dg9a2pjq45aomam","recordointrsx"); |
| 473 |
try { |
| 474 |
int i = getintrsxi(xlp, op, cp); |
| 475 |
if (i < 0) |
| 476 |
i = 5; |
| 477 |
if (intrsx[i] != null) { |
| 478 |
double sa, maxa = 0.0; |
| 479 |
final ST_Rect_t srect = new ST_Rect_t(); |
| 480 |
|
| 481 |
objp2rect(intrsx[i], srect); |
| 482 |
sa = aabbaabb(rp, srect); |
| 483 |
if (sa > a) |
| 484 |
maxa = sa; |
| 485 |
|
| 486 |
if (intrsx[i].lbl!=null) { |
| 487 |
objplp2rect(intrsx[i], srect); |
| 488 |
sa = aabbaabb(rp, srect); |
| 489 |
if (sa > a) |
| 490 |
maxa = sa > maxa ? sa : maxa; |
| 491 |
} |
| 492 |
if (maxa > 0.0) |
| 493 |
return maxa; |
| 494 |
|
| 495 |
intrsx[i] = cp; |
| 496 |
return a; |
| 497 |
} |
| 498 |
intrsx[i] = cp; |
| 499 |
return a; |
| 500 |
} finally { |
| 501 |
LEAVING("52awwxu810dg9a2pjq45aomam","recordointrsx"); |
| 502 |
} |
| 503 |
} |
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
public static double recordlintrsx(ST_XLabels_t xlp, ST_object_t op, ST_object_t cp, ST_Rect_t rp, double a, ST_object_t intrsx[]) { |
| 511 |
ENTERING("2umrncgkunxoyeuc8i9hd5pwa","recordlintrsx"); |
| 512 |
try { |
| 513 |
int i = getintrsxi(xlp, op, cp); |
| 514 |
if (i < 0) |
| 515 |
i = 5; |
| 516 |
if (intrsx[i] != null) { |
| 517 |
double sa, maxa = 0.0; |
| 518 |
final ST_Rect_t srect = new ST_Rect_t(); |
| 519 |
|
| 520 |
objp2rect(intrsx[i], srect); |
| 521 |
sa = aabbaabb(rp, srect); |
| 522 |
if (sa > a) |
| 523 |
maxa = sa; |
| 524 |
|
| 525 |
if (intrsx[i].lbl!=null) { |
| 526 |
objplp2rect(intrsx[i], srect); |
| 527 |
sa = aabbaabb(rp, srect); |
| 528 |
if (sa > a) |
| 529 |
maxa = sa > maxa ? sa : maxa; |
| 530 |
} |
| 531 |
if (maxa > 0.0) |
| 532 |
return maxa; |
| 533 |
|
| 534 |
intrsx[i] = cp; |
| 535 |
return a; |
| 536 |
} |
| 537 |
intrsx[i] = cp; |
| 538 |
return a; |
| 539 |
} finally { |
| 540 |
LEAVING("2umrncgkunxoyeuc8i9hd5pwa","recordlintrsx"); |
| 541 |
} |
| 542 |
} |
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
public static ST_BestPos_t xlintersections(ST_XLabels_t xlp, ST_object_t objp, ST_object_t intrsx[]) { |
| 550 |
ENTERING("2td62i5hus8obwt8j1lo3ddj9","xlintersections"); |
| 551 |
try { |
| 552 |
return (ST_BestPos_t) xlintersections_(xlp, objp, intrsx).copy(); |
| 553 |
} finally { |
| 554 |
LEAVING("2td62i5hus8obwt8j1lo3ddj9","xlintersections"); |
| 555 |
} |
| 556 |
} |
| 557 |
|
| 558 |
private static ST_BestPos_t xlintersections_(ST_XLabels_t xlp, ST_object_t objp, ST_object_t intrsx[]) { |
| 559 |
int i; |
| 560 |
ST_LeafList_t ilp, llp; |
| 561 |
final ST_Rect_t rect = new ST_Rect_t(); |
| 562 |
final ST_Rect_t srect = new ST_Rect_t(); |
| 563 |
final ST_BestPos_t bp = new ST_BestPos_t(); |
| 564 |
|
| 565 |
bp.setInt("n", 0); |
| 566 |
bp.setDouble("area", 0.0); |
| 567 |
bp.setStruct("pos", objp.lbl.getStruct().pos); |
| 568 |
for(i=0; i<xlp.n_objs; i++) { |
| 569 |
if (EQ(objp, xlp.objs.plus(i).getStruct())) continue; |
| 570 |
if(xlp.objs.get(i).sz.x > 0 && xlp.objs.get(i).sz.y > 0) continue; |
| 571 |
if(lblenclosing(objp, (ST_object_t) xlp.objs.plus(i).getStruct())) { |
| 572 |
bp.setInt("n", bp.n+1); |
| 573 |
} |
| 574 |
} |
| 575 |
objplp2rect((ST_object_t) objp.getStruct(), rect); |
| 576 |
llp = RTreeSearch((ST_RTree)xlp.spdx, (ST_Node_t___)xlp.spdx.root, rect); |
| 577 |
if (N(llp)) |
| 578 |
return bp; |
| 579 |
for (ilp = llp; ilp!=null; ilp = (ST_LeafList_t) ilp.next) { |
| 580 |
double a, ra; |
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
ST_object_t cp = (ST_object_t) ilp.leaf.child; |
| 585 |
if (EQ(cp, objp)) |
| 586 |
continue; |
| 587 |
|
| 588 |
objp2rect((ST_object_t) cp.getStruct(), srect); |
| 589 |
a = aabbaabb(rect, srect); |
| 590 |
if (a > 0.0) { |
| 591 |
ra = recordointrsx(xlp, objp, cp, rect, a, intrsx); |
| 592 |
bp.setInt("n", bp.n+1); |
| 593 |
bp.setDouble("area", bp.area+ra); |
| 594 |
} |
| 595 |
|
| 596 |
if (N(cp.lbl) || N(cp.lbl.getStruct().set)) |
| 597 |
continue; |
| 598 |
objplp2rect((ST_object_t) cp.getStruct(), srect); |
| 599 |
a = aabbaabb(rect, srect); |
| 600 |
if (a > 0.0) { |
| 601 |
ra = recordlintrsx(xlp, objp, cp, rect, a, intrsx); |
| 602 |
bp.setInt("n", bp.n+1); |
| 603 |
bp.setDouble("area", bp.area+ra); |
| 604 |
} |
| 605 |
} |
| 606 |
RTreeLeafListFree(llp); |
| 607 |
return bp; |
| 608 |
} |
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
public static ST_BestPos_t xladjust(ST_XLabels_t xlp, ST_object_t objp) { |
| 616 |
ENTERING("8rxvucqsqnqej6h8p1osfnk4b","xladjust"); |
| 617 |
try { |
| 618 |
return (ST_BestPos_t) xladjust_(xlp, objp).copy(); |
| 619 |
} finally { |
| 620 |
LEAVING("8rxvucqsqnqej6h8p1osfnk4b","xladjust"); |
| 621 |
} |
| 622 |
} |
| 623 |
private static ST_BestPos_t xladjust_(ST_XLabels_t xlp, ST_object_t objp) { |
| 624 |
ST_xlabel_t.Array lp = (ST_xlabel_t.Array) objp.lbl; |
| 625 |
double xincr = ((2 * lp.getStruct().sz.x + objp.sz.x)) / 8; |
| 626 |
double yincr = ((2 * lp.getStruct().sz.y + objp.sz.y)) / 2; |
| 627 |
ST_object_t intrsx[] = new ST_object_t[9]; |
| 628 |
final ST_BestPos_t bp = new ST_BestPos_t(); |
| 629 |
final ST_BestPos_t nbp = new ST_BestPos_t(); |
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
lp.getStruct().pos.setDouble("x", objp.pos.x - lp.getStruct().sz.x); |
| 634 |
|
| 635 |
lp.getStruct().pos.setDouble("y", objp.pos.y + objp.sz.y); |
| 636 |
bp.___(xlintersections(xlp, objp, intrsx)); |
| 637 |
if (bp.n == 0) |
| 638 |
return bp; |
| 639 |
|
| 640 |
lp.getStruct().pos.setDouble("y", objp.pos.y); |
| 641 |
nbp.___(xlintersections(xlp, objp, intrsx)); |
| 642 |
if (nbp.n == 0) |
| 643 |
return nbp; |
| 644 |
if (nbp.area < bp.area) |
| 645 |
bp.___(nbp); |
| 646 |
|
| 647 |
lp.getStruct().pos.setDouble("y", objp.pos.y - lp.getStruct().sz.y); |
| 648 |
nbp.___(xlintersections(xlp, objp, intrsx)); |
| 649 |
if (nbp.n == 0) |
| 650 |
return nbp; |
| 651 |
if (nbp.area < bp.area) |
| 652 |
bp.___(nbp); |
| 653 |
|
| 654 |
lp.getStruct().pos.setDouble("x", objp.pos.x); |
| 655 |
|
| 656 |
lp.getStruct().pos.setDouble("y", objp.pos.y + objp.sz.y); |
| 657 |
nbp.___(xlintersections(xlp, objp, intrsx)); |
| 658 |
if (nbp.n == 0) |
| 659 |
return nbp; |
| 660 |
if (nbp.area < bp.area) |
| 661 |
bp.___(nbp); |
| 662 |
|
| 663 |
lp.getStruct().pos.setDouble("y", objp.pos.y - lp.getStruct().sz.y); |
| 664 |
nbp.___(xlintersections(xlp, objp, intrsx)); |
| 665 |
if (nbp.n == 0) |
| 666 |
return nbp; |
| 667 |
if (nbp.area < bp.area) |
| 668 |
bp.___(nbp); |
| 669 |
|
| 670 |
lp.getStruct().pos.setDouble("x", objp.pos.x + objp.sz.x); |
| 671 |
|
| 672 |
lp.getStruct().pos.setDouble("y", objp.pos.y + objp.sz.y); |
| 673 |
nbp.___(xlintersections(xlp, objp, intrsx)); |
| 674 |
if (nbp.n == 0) |
| 675 |
return nbp; |
| 676 |
if (nbp.area < bp.area) |
| 677 |
bp.___(nbp); |
| 678 |
|
| 679 |
lp.getStruct().pos.setDouble("y", objp.pos.y); |
| 680 |
nbp.___(xlintersections(xlp, objp, intrsx)); |
| 681 |
if (nbp.n == 0) |
| 682 |
return nbp; |
| 683 |
if (nbp.area < bp.area) |
| 684 |
bp.___(nbp); |
| 685 |
|
| 686 |
lp.getStruct().pos.setDouble("y", objp.pos.y - lp.getStruct().sz.y); |
| 687 |
nbp.___(xlintersections(xlp, objp, intrsx)); |
| 688 |
if (nbp.n == 0) |
| 689 |
return nbp; |
| 690 |
if (nbp.area < bp.area) |
| 691 |
bp.___(nbp); |
| 692 |
|
| 693 |
if (intrsx[6]!=null || intrsx[7]!=null || intrsx[8]!=null || intrsx[3]!=null || intrsx[0]!=null) { |
| 694 |
UNSUPPORTED("c5acs4cl77hgu5j6nmhk090uz"); |
| 695 |
UNSUPPORTED("ez8sbh237xdqdjeewev2ys74y"); |
| 696 |
UNSUPPORTED("ajgw2jggmwmofm77lgbx5eo2n"); |
| 697 |
UNSUPPORTED("nwfhss2g67z5exjkorj0brd"); |
| 698 |
UNSUPPORTED("eav75dwa3f3ieedr9mnov3a6u"); |
| 699 |
UNSUPPORTED("38u334kkfej5n3r31uv1afw9q"); |
| 700 |
UNSUPPORTED("8pbum2o0fs86ceaiuxv4efbb6"); |
| 701 |
UNSUPPORTED("5xx7o143ftoj0rhyhg1hqgioa"); |
| 702 |
UNSUPPORTED("eqanxe9w90oki7yqvwyzpfcw1"); |
| 703 |
UNSUPPORTED("8yd6g3a3f0g09gmu5f67vah0x"); |
| 704 |
UNSUPPORTED("d6ac36j6lh6qspxwnn3vi0uc3"); |
| 705 |
UNSUPPORTED("6t98dcecgbvbvtpycwiq2ynnj"); |
| 706 |
UNSUPPORTED("flupwh3kosf3fkhkxllllt1"); |
| 707 |
UNSUPPORTED("4w0qgfnt6kpuhb381pmra3ln4"); |
| 708 |
UNSUPPORTED("6st33ex0udr4mk4sa9vd119uz"); |
| 709 |
UNSUPPORTED("ajgw2jggmwmofm77lgbx5eo2n"); |
| 710 |
UNSUPPORTED("nwfhss2g67z5exjkorj0brd"); |
| 711 |
UNSUPPORTED("eolwmrajeldp9gf9ug6ue0gx2"); |
| 712 |
UNSUPPORTED("bz3822dbe0xnwj4nm7pf39kae"); |
| 713 |
UNSUPPORTED("8pbum2o0fs86ceaiuxv4efbb6"); |
| 714 |
UNSUPPORTED("5xx7o143ftoj0rhyhg1hqgioa"); |
| 715 |
UNSUPPORTED("eqanxe9w90oki7yqvwyzpfcw1"); |
| 716 |
UNSUPPORTED("8yd6g3a3f0g09gmu5f67vah0x"); |
| 717 |
UNSUPPORTED("d6ac36j6lh6qspxwnn3vi0uc3"); |
| 718 |
UNSUPPORTED("6t98dcecgbvbvtpycwiq2ynnj"); |
| 719 |
UNSUPPORTED("flupwh3kosf3fkhkxllllt1"); |
| 720 |
} |
| 721 |
|
| 722 |
lp.getStruct().pos.setDouble("x", objp.pos.x + objp.sz.x); |
| 723 |
lp.getStruct().pos.setDouble("y", objp.pos.y - lp.getStruct().sz.y); |
| 724 |
if (intrsx[2]!=null || intrsx[1]!=null || intrsx[0]!=null || intrsx[5]!=null || intrsx[8]!=null) { |
| 725 |
if (N(intrsx[1]) && N(intrsx[0])) { |
| 726 |
|
| 727 |
for (lp.getStruct().pos.setDouble("x", objp.pos.x + objp.sz.x), |
| 728 |
lp.getStruct().pos.setDouble("y", objp.pos.y - lp.getStruct().sz.y); |
| 729 |
lp.getStruct().pos.x >= (objp.pos.x - lp.getStruct().sz.x); |
| 730 |
lp.getStruct().pos.setDouble("x", lp.getStruct().pos.x - xincr)) { |
| 731 |
nbp.___(xlintersections(xlp, objp, intrsx)); |
| 732 |
if (nbp.n == 0) |
| 733 |
return nbp; |
| 734 |
if (nbp.area < bp.area) |
| 735 |
bp.___(nbp); |
| 736 |
} |
| 737 |
} |
| 738 |
if (N(intrsx[5]) && N(intrsx[8])) { |
| 739 |
UNSUPPORTED("4bcpk3ixfwrlr0yzrjv2efigj"); |
| 740 |
UNSUPPORTED("7natp0873pfsvymhhhvki1sev"); |
| 741 |
UNSUPPORTED("56ycmo0ljb7e86mnezdx3regh"); |
| 742 |
UNSUPPORTED("9cepfi69gtzy7muk9d27es8oc"); |
| 743 |
UNSUPPORTED("az41g895dhl39ckrigxl1c5jl"); |
| 744 |
UNSUPPORTED("8pbum2o0fs86ceaiuxv4efbb6"); |
| 745 |
UNSUPPORTED("5xx7o143ftoj0rhyhg1hqgioa"); |
| 746 |
UNSUPPORTED("eqanxe9w90oki7yqvwyzpfcw1"); |
| 747 |
UNSUPPORTED("8yd6g3a3f0g09gmu5f67vah0x"); |
| 748 |
UNSUPPORTED("d6ac36j6lh6qspxwnn3vi0uc3"); |
| 749 |
UNSUPPORTED("6t98dcecgbvbvtpycwiq2ynnj"); |
| 750 |
} |
| 751 |
} |
| 752 |
return bp; |
| 753 |
} |
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
public static int xlhdxload(ST_XLabels_t xlp) { |
| 761 |
ENTERING("e29g2hwlogx0zchsnvi464c7t","xlhdxload"); |
| 762 |
try { |
| 763 |
int i; |
| 764 |
int order = xlhorder(xlp); |
| 765 |
for (i = 0; i < xlp.n_objs; i++) { |
| 766 |
ST_HDict_t hp; |
| 767 |
final ST_point pi = new ST_point(); |
| 768 |
hp = new ST_HDict_t(); |
| 769 |
hp.d.child = xlp.objs.get(i); |
| 770 |
hp.d.setStruct("rect", objplpmks(xlp, (ST_object_t) xlp.objs.plus(i).getStruct())); |
| 771 |
|
| 772 |
pi.setInt("x", hp.d.rect.boundary[0] + |
| 773 |
(hp.d.rect.boundary[2] - hp.d.rect.boundary[0]) / 2); |
| 774 |
pi.setInt("y", hp.d.rect.boundary[1] + |
| 775 |
(hp.d.rect.boundary[3] - hp.d.rect.boundary[1]) / 2); |
| 776 |
hp.setInt("key", hd_hil_s_from_xy(pi, order)); |
| 777 |
if (N(xlp.hdx.searchf.exe(xlp.hdx, hp, 0000001))) |
| 778 |
return -1; |
| 779 |
} |
| 780 |
return 0; |
| 781 |
} finally { |
| 782 |
LEAVING("e29g2hwlogx0zchsnvi464c7t","xlhdxload"); |
| 783 |
} |
| 784 |
} |
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
public static void xlhdxunload(ST_XLabels_t xlp) { |
| 792 |
ENTERING("26qpvnyd6tmdut8i2wo4itza3","xlhdxunload"); |
| 793 |
try { |
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
} finally { |
| 809 |
LEAVING("26qpvnyd6tmdut8i2wo4itza3","xlhdxunload"); |
| 810 |
} |
| 811 |
} |
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
public static int xlspdxload(ST_XLabels_t xlp) { |
| 819 |
ENTERING("3wrxwwd3y5ts0ekr32o8vhuvv","xlspdxload"); |
| 820 |
try { |
| 821 |
ST_HDict_t op=null; |
| 822 |
for (op = (ST_HDict_t) xlp.hdx.searchf.exe(xlp.hdx, null, 0000200); op!=null; |
| 823 |
op = (ST_HDict_t) xlp.hdx.searchf.exe(xlp.hdx, op, 0000010)) { |
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
final ST_Node_t___[] tmp = new ST_Node_t___[] {(ST_Node_t___) xlp.spdx.root}; |
| 828 |
RTreeInsert((ST_RTree) xlp.spdx, (ST_Rect_t)op.d.rect, |
| 829 |
op.d.child, |
| 830 |
tmp, 0); |
| 831 |
xlp.spdx.setPtr("root", tmp[0]); |
| 832 |
} |
| 833 |
return 0; |
| 834 |
} finally { |
| 835 |
LEAVING("3wrxwwd3y5ts0ekr32o8vhuvv","xlspdxload"); |
| 836 |
} |
| 837 |
} |
| 838 |
|
| 839 |
|
| 840 |
|
| 841 |
|
| 842 |
|
| 843 |
|
| 844 |
public static int xlinitialize(ST_XLabels_t xlp) { |
| 845 |
ENTERING("6d3fqrllm55toeo3wscwvv4ty","xlinitialize"); |
| 846 |
try { |
| 847 |
int r=0; |
| 848 |
if ((r = xlhdxload(xlp)) < 0) |
| 849 |
return r; |
| 850 |
if ((r = xlspdxload(xlp)) < 0) |
| 851 |
return r; |
| 852 |
xlhdxunload(xlp); |
| 853 |
return dtclose((ST_dt_s) xlp.hdx); |
| 854 |
} finally { |
| 855 |
LEAVING("6d3fqrllm55toeo3wscwvv4ty","xlinitialize"); |
| 856 |
} |
| 857 |
} |
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
public static int placeLabels(ST_object_t.Array objs, int n_objs, ST_xlabel_t.Array lbls, int n_lbls, ST_label_params_t params) { |
| 865 |
ENTERING("brqgbskh3z4ah8infjompibvu","placeLabels"); |
| 866 |
try { |
| 867 |
int r, i; |
| 868 |
final ST_BestPos_t bp = new ST_BestPos_t(); |
| 869 |
ST_XLabels_t xlp = xlnew(objs, n_objs, lbls, n_lbls, params); |
| 870 |
if ((r = xlinitialize(xlp)) < 0) |
| 871 |
return r; |
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
|
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
r = 0; |
| 888 |
for (i = 0; i < n_objs; i++) { |
| 889 |
if (objs.get(i).lbl == null) |
| 890 |
continue; |
| 891 |
xladjust(xlp, (ST_object_t) objs.get(i).getStruct()); |
| 892 |
bp.___(xladjust(xlp, (ST_object_t) objs.get(i).getStruct())); |
| 893 |
if (bp.n == 0) { |
| 894 |
objs.get(i).lbl.setInt("set", 1); |
| 895 |
} else if(bp.area == 0) { |
| 896 |
objs.get(i).lbl.getStruct().pos.setDouble("x", bp.pos.x); |
| 897 |
objs.get(i).lbl.getStruct().pos.setDouble("y", bp.pos.y); |
| 898 |
objs.get(i).lbl.setInt("set", 1); |
| 899 |
} else if (params.force) { |
| 900 |
objs.get(i).lbl.getStruct().pos.setDouble("x", bp.pos.x); |
| 901 |
objs.get(i).lbl.getStruct().pos.setDouble("y", bp.pos.y); |
| 902 |
objs.get(i).lbl.setInt("set", 1); |
| 903 |
} else { |
| 904 |
r = 1; |
| 905 |
} |
| 906 |
} |
| 907 |
xlfree(xlp); |
| 908 |
return r; |
| 909 |
} finally { |
| 910 |
LEAVING("brqgbskh3z4ah8infjompibvu","placeLabels"); |
| 911 |
} |
| 912 |
} |
| 913 |
|
| 914 |
|
| 915 |
} |