Changeset 5266
- Timestamp:
- 08/16/10 08:44:55 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/objects/Bamg/QuadTree.cpp
r5224 r5266 241 241 Icoor1 ii[MaxDeep]; 242 242 Icoor1 jj[MaxDeep]; 243 register int level = 0;243 register int level; 244 244 register long n0; 245 245 register QuadTreeBox *b; … … 279 279 i0 += I_IJ(k,hb2); // i orign of QuadTreeBox (macro) 280 280 j0 += J_IJ(k,hb2); // j orign of QuadTreeBox 281 hb = hb2; 281 hb = hb2; // size of the box (in Int) 282 282 } 283 283 … … 307 307 //initialize pb pi ii and jj 308 308 pb[0]=b; //pointer toward the box b 309 pi[0]=b->nbitems>0? (int)b->nbitems:4;//number of vertices in the box309 pi[0]=b->nbitems>0? (int)b->nbitems:4;//number of boxes in b 310 310 ii[0]=i0; // i coordinate of the box 311 311 jj[0]=j0; // j coordinate of the box … … 314 314 h=hb; 315 315 316 /*loop, until level=0*/ 316 /*loop, until level=0 (main quadtree box)*/ 317 level=0; 317 318 do { 318 //get current box 319 320 /*get current box*/ 319 321 b= pb[level]; 320 322 321 / /Loop over the vertices in current box (if not empty!)323 /*Loop over the items in current box (if not empty!)*/ 322 324 while (pi[level]--){ 323 325 324 //k = number of vertices in the box if there are vertices 325 //k = 4 if the current box is pointing toward 4 other boxes 326 register int k=pi[level]; 327 328 //if the current subbox is holding vertices, 329 if (b->nbitems>0){ // BamgVertex QuadTreeBox not empty 330 I2 i2 = b->v[k]->i; 326 /*k = number of items in the box*/ 327 int k=pi[level]; 328 329 /*if the current subbox is holding vertices*/ 330 if (b->nbitems>0){ 331 I2 i2=b->v[k]->i; 331 332 h0 = NORM(iplus,i2.x,jplus,i2.y); 332 if (h0 333 h =h0;334 nearest_v =b->v[k];333 if (h0<h){ 334 h=h0; 335 nearest_v=b->v[k]; 335 336 } 336 337 } 337 338 /*else: current box b is pointing toward 4 boxes (There must be a vertex at some point)*/ 338 339 else{ 339 registerQuadTreeBox* b0=b;340 QuadTreeBox* b0=b; 340 341 341 342 //if the next box exists: 342 if ((b=b->b[k])){ 343 //shifted righ by one bit: hb2=01000000 -> 00100000 343 if (b=b->b[k]){ 344 345 /*Get size (hb) and coordinates of the current sub-box*/ 344 346 hb>>=1; 345 registerIcoor1 iii = ii[level]+I_IJ(k,hb);346 registerIcoor1 jjj = jj[level]+J_IJ(k,hb);347 348 / /if the current point is in b,go to next box347 Icoor1 iii = ii[level]+I_IJ(k,hb); 348 Icoor1 jjj = jj[level]+J_IJ(k,hb); 349 350 /*if the current point (iplus,jplus) is in b,go to next box*/ 349 351 if (INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)){ 350 352 pb[++level]= b; … … 361 363 } 362 364 } 363 //Go backwards 364 else b=b0; 365 /*Go backwards*/ 366 else{ 367 b=b0; 368 } 365 369 } 366 370 } … … 371 375 } while (level--); 372 376 373 / /return nearest_v, nearest vertex377 /*return nearest_v, nearest vertex*/ 374 378 return nearest_v; 379 375 380 } 376 381 /*}}}1*/ … … 535 540 do { 536 541 b= pb[l]; 537 while (pi[l]--) 538 { 542 while (pi[l]--){ 539 543 register int k = pi[l]; 540 544 541 if (b->nbitems>0) // BamgVertex QuadTreeBox none empty 542 { 545 if (b->nbitems>0){ // BamgVertex QuadTreeBox none empty 543 546 I2 i2 = b->v[k]->i; 544 547 if ( ABS(i-i2.x) <hx && ABS(j-i2.y) <hy ) … … 548 551 if( (dd= LengthInterpole(Mx(XY), b->v[k]->m(XY))) < seuil ){ 549 552 return b->v[k]; 550 553 } 551 554 } 552 } 553 else // Pointer QuadTreeBox 554 { 555 } 556 else{ // Pointer QuadTreeBox 555 557 register QuadTreeBox *b0=b; 556 if ((b=b->b[k])) 557 { 558 if ((b=b->b[k])){ 558 559 hb >>=1 ; // div by 2 559 560 register long iii = ii[l]+I_IJ(k,hb); 560 561 register long jjj = jj[l]+J_IJ(k,hb); 561 562 562 if (INTER_SEG(iii,iii+hb,i-hx,i+hx) && INTER_SEG(jjj,jjj+hb,j-hy,j+hy)) 563 { 563 if (INTER_SEG(iii,iii+hb,i-hx,i+hx) && INTER_SEG(jjj,jjj+hb,j-hy,j+hy)){ 564 564 pb[++l]= b; 565 565 pi[l]= b->nbitems>0 ?(int) b->nbitems : 4 ; … … 567 567 jj[l]= jjj; 568 568 569 } 570 else 571 b=b0, hb <<=1 ; 572 } 573 else 574 b=b0; 575 } 576 } 569 } 570 else{ 571 b=b0; 572 hb <<=1 ; 573 } 574 } 575 else{ 576 b=b0; 577 } 578 } 579 } 577 580 hb <<= 1; // mul by 2 578 581 } while (l--);
Note:
See TracChangeset
for help on using the changeset viewer.