src/bbox.c
void bbox_divide(struct bbox *b0, struct bbox *b_tab)
{
    int ndims = b0->num_dims;
    int num_subbox = 1 << ndims; // number of sub n-dimensions bbox
    int i, j, n = 0;

    for(i = 0; i < num_subbox; i++) {
        j = 0;
        b_tab[i].num_dims = b0->num_dims;
        while(j < ndims) {
            n = (b0->lb.c[j] + b0->ub.c[j]) / 2; // the middle point of bounding
            if((i & (1 << j)) == 0) {
                b_tab[i].lb.c[j] = b0->lb.c[j];
                b_tab[i].ub.c[j] = n;
            } else {
                b_tab[i].lb.c[j] = n + 1;
                b_tab[i].ub.c[j] = b0->ub.c[j];
            }
            j++;
        }
    }
}
/*
  Generic routine to split a box in 4 or 8 based on the number of
  dimensions.
*/
Generic routine to split a box in 4 or 8 based on the number of
dimensions.
Generic routine to split a box in 4 or 8 based on the number of dimensions .
void bbox_divide(struct bbox *b0, struct bbox *b_tab)
{
    int ndims = b0->num_dims;
    int num_subbox = 1 << ndims; 
    int i, j, n = 0;
    for(i = 0; i < num_subbox; i++) {
        j = 0;
        b_tab[i].num_dims = b0->num_dims;
        while(j < ndims) {
            n = (b0->lb.c[j] + b0->ub.c[j]) / 2; 
            if((i & (1 << j)) == 0) {
                b_tab[i].lb.c[j] = b0->lb.c[j];
                b_tab[i].ub.c[j] = n;
            } else {
                b_tab[i].lb.c[j] = n + 1;
                b_tab[i].ub.c[j] = b0->ub.c[j];
            }
            j++;
        }
    }
}
void bbox_divide ( struct bbox * b0 , struct bbox * b_tab ) { int ndims = b0 -> num_dims ; int num_subbox = 1 << ndims ; int i , j , n = 0 ; for ( i = 0 ; i < num_subbox ; i ++ ) { j = 0 ; b_tab [ i ] . num_dims = b0 -> num_dims ; while ( j < ndims ) { n = ( b0 -> lb . c [ j ] + b0 -> ub . c [ j ] ) / 2 ; if ( ( i & ( 1 << j ) ) == 0 ) { b_tab [ i ] . lb . c [ j ] = b0 -> lb . c [ j ] ; b_tab [ i ] . ub . c [ j ] = n ; } else { b_tab [ i ] . lb . c [ j ] = n + 1 ; b_tab [ i ] . ub . c [ j ] = b0 -> ub . c [ j ] ; } j ++ ; } } }
Generic routine to split a box in 4 or 8 based on the number of
dimensions.
Generic routine to split a box in 4 or 8 based on the number of dimensions .
// number of sub n-dimensions bbox // the middle point of bounding