Changeset 5266


Ignore:
Timestamp:
08/16/10 08:44:55 (15 years ago)
Author:
Mathieu Morlighem
Message:

as usual

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/Bamg/QuadTree.cpp

    r5224 r5266  
    241241                Icoor1                ii[MaxDeep];
    242242                Icoor1                jj[MaxDeep];
    243                 register int          level  = 0;
     243                register int          level;
    244244                register long         n0;
    245245                register QuadTreeBox *b;
     
    279279                        i0 += I_IJ(k,hb2); // i orign of QuadTreeBox (macro)
    280280                        j0 += J_IJ(k,hb2); // j orign of QuadTreeBox
    281                         hb = hb2;
     281                        hb = hb2;          // size of the box (in Int)
    282282                }
    283283
     
    307307                //initialize pb pi ii and jj
    308308                pb[0]=b;                  //pointer toward the box b
    309                 pi[0]=b->nbitems>0? (int)b->nbitems:4;//number of vertices in the box
     309                pi[0]=b->nbitems>0? (int)b->nbitems:4;//number of boxes in b
    310310                ii[0]=i0;                 // i coordinate of the box
    311311                jj[0]=j0;                 // j coordinate of the box
     
    314314                h=hb;
    315315
    316                 /*loop, until level=0*/
     316                /*loop, until level=0 (main quadtree box)*/
     317                level=0;
    317318                do {
    318                         //get current box
     319
     320                        /*get current box*/
    319321                        b= pb[level];
    320322
    321                         //Loop over the vertices in current box (if not empty!)
     323                        /*Loop over the items in current box (if not empty!)*/
    322324                        while (pi[level]--){
    323325
    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;
    331332                                        h0 = NORM(iplus,i2.x,jplus,i2.y);
    332                                         if (h0 <h){
    333                                                 h = h0;
    334                                                 nearest_v = b->v[k];
     333                                        if (h0<h){
     334                                                h=h0;
     335                                                nearest_v=b->v[k];
    335336                                        }
    336337                                }
    337 
     338                                /*else: current box b is pointing toward 4 boxes (There must be a vertex at some point)*/
    338339                                else{
    339                                         register QuadTreeBox* b0=b;
     340                                        QuadTreeBox* b0=b;
    340341
    341342                                        //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*/
    344346                                                hb>>=1;
    345                                                 register Icoor1 iii = ii[level]+I_IJ(k,hb);
    346                                                 register Icoor1 jjj = jj[level]+J_IJ(k,hb);
    347 
    348                                                 //if the current point is in b,go to next box
     347                                                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*/
    349351                                                if (INTER_SEG(iii,iii+hb,iplus-h,iplus+h) && INTER_SEG(jjj,jjj+hb,jplus-h,jplus+h)){
    350352                                                        pb[++level]=  b;
     
    361363                                                }
    362364                                        }
    363                                         //Go backwards
    364                                         else b=b0;
     365                                        /*Go backwards*/
     366                                        else{
     367                                                b=b0;
     368                                        }
    365369                                }
    366370                        }
     
    371375                } while (level--);
    372376
    373                 //return nearest_v, nearest vertex
     377                /*return nearest_v, nearest vertex*/
    374378                return nearest_v;
     379
    375380        }
    376381        /*}}}1*/
     
    535540                do {   
    536541                        b= pb[l];
    537                         while (pi[l]--)
    538                           {           
     542                        while (pi[l]--){             
    539543                                register int k = pi[l];
    540544
    541                                 if (b->nbitems>0) // BamgVertex QuadTreeBox none empty
    542                                   {
     545                                if (b->nbitems>0){ // BamgVertex QuadTreeBox none empty
    543546                                        I2 i2 =  b->v[k]->i;
    544547                                        if ( ABS(i-i2.x) <hx && ABS(j-i2.y) <hy )
     
    548551                                                if( (dd= LengthInterpole(Mx(XY), b->v[k]->m(XY)))  < seuil ){
    549552                                                        return b->v[k];
    550                                                   }
     553                                                }
    551554                                          }
    552                                   }
    553                                 else // Pointer QuadTreeBox
    554                                   {
     555                                }
     556                                else{ // Pointer QuadTreeBox
    555557                                        register QuadTreeBox *b0=b;
    556                                         if ((b=b->b[k]))
    557                                           {
     558                                        if ((b=b->b[k])){
    558559                                                hb >>=1 ; // div by 2
    559560                                                register long iii = ii[l]+I_IJ(k,hb);
    560561                                                register long jjj = jj[l]+J_IJ(k,hb);
    561562
    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)){
    564564                                                        pb[++l]=  b;
    565565                                                        pi[l]= b->nbitems>0 ?(int)  b->nbitems : 4  ;
     
    567567                                                        jj[l]= jjj;
    568568
    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                        }
    577580                        hb <<= 1; // mul by 2
    578581                } while (l--);
Note: See TracChangeset for help on using the changeset viewer.