Commit f4db03d5 authored by Libor's avatar Libor
Browse files

Fixed indexing.

parent 473937b3
Loading
Loading
Loading
Loading
+28 −22
Original line number Diff line number Diff line
@@ -58,28 +58,34 @@ void tnlInternalNode< LogX, LogY >::setChildren( int splitX,
                                                 int splitY,
                                                 int depth )
{
    for( int i = 0; i < LogX * LogY; i++ )
    for( int i = 0; i < LogY; i++ )
        for( int j = 0; j < LogX; j++ )
        {
        if( !this->bitmaskArray->getIthBitmask( i )->getState() )
            this->children[ i ] = NULL;
            int index = i * LogY + j;
            if( !this->bitmaskArray->getIthBitmask( index )->getState() )
                this->children[ index ] = NULL;
            else if( this->level < depth - 1 )
            {
            std::cout << "creating new node, level = " << this->level << std::endl;
            this->children[ i ] = new tnlInternalNode< LogX, LogY >( this->area,
                //std::cout << "creating new node, level = " << this->level << std::endl;
                int X = this->X * LogX + j;
                int Y = this->Y * LogY + i;
                this->children[ index ] = new tnlInternalNode< LogX, LogY >( this->area,
                                                                             this->circle,
                                                                     this->bitmaskArray->getIthBitmask( i )->getX(),
                                                                     this->bitmaskArray->getIthBitmask( i )->getY(),
                                                                             X,
                                                                             Y,
                                                                             this->level + 1 );
            this->children[ i ]->setNode( splitX, splitY, depth );
                this->children[ index ]->setNode( splitX, splitY, depth );
            }
            else
            {
            this->children[ i ] = new tnlLeafNode< LogX, LogY >( this->area,
                int X = this->X * LogX + j;
                int Y = this->Y * LogY + i;
                this->children[ index ] = new tnlLeafNode< LogX, LogY >( this->area,
                                                                         this->circle,
                                                                 this->bitmaskArray->getIthBitmask( i )->getX(),
                                                                 this->bitmaskArray->getIthBitmask( i )->getY(),
                                                                         X,
                                                                         Y,
                                                                         this->level + 1 );
            this->children[ i ]->setNode( splitX, splitY, depth );
                this->children[ index ]->setNode( splitX, splitY, depth );
            }    
        }
}
+2 −2
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ void tnlLeafNode< LogX, LogY >::setNode( int splitX,
                                         int splitY,
                                         int depth )
{
    std::cout << "tnlLeafNode::setNode" << std::endl;
    //std::cout << "tnlLeafNode::setNode" << std::endl;
    int depthX = splitX * tnlVDBMath::power( LogX, this->level );
    int depthY = splitY * tnlVDBMath::power( LogY, this->level );
    float stepX = ( float ) this->area->getLengthX() / depthX;
+37 −29
Original line number Diff line number Diff line
@@ -52,26 +52,34 @@ template< unsigned size,
void tnlRootNode< size, LogX, LogY >::createTree()
{
    this->setNode(); // first we need to create root node
    for( int i = 0; i < size; i++ )
        if( !this->bitmaskArray->getIthBitmask( i )->getState() )
            this->children[ i ] = NULL;
    for( int i = 0; i < this->nodesY; i++ )
        for( int j = 0; j < this-> nodesX; j++ )
        {
            int index = i * this->nodesY + j;
            if( !this->bitmaskArray->getIthBitmask( index )->getState() )
                this->children[ index ] = NULL;
            else if( this->level < this->depth - 1 )
            {
            this->children[ i ] = new tnlInternalNode< LogX, LogY >( this->area,
                int X = this->bitmaskArray->getIthBitmask( index )->getX() * LogX + j;
                int Y = this->bitmaskArray->getIthBitmask( index )->getY() * LogY + i;
                this->children[ index ] = new tnlInternalNode< LogX, LogY >( this->area,
                                                                             this->circle,
                                                                     this->bitmaskArray->getIthBitmask( i )->getX(),
                                                                     this->bitmaskArray->getIthBitmask( i )->getY(),
                                                                             X,
                                                                             Y,
                                                                             this->level + 1 );
            this->children[ i ]->setNode( nodesX, nodesY, this->depth );
                this->children[ index ]->setNode( nodesX, nodesY, this->depth );
            }
            else
            {
            this->children[ i ] = new tnlLeafNode< LogX, LogY >( this->area,
                int X = this->bitmaskArray->getIthBitmask( index )->getX() * LogX + j;
                int Y = this->bitmaskArray->getIthBitmask( index )->getY() * LogY + i;
                this->children[ index ] = new tnlLeafNode< LogX, LogY >( this->area,
                                                                         this->circle,
                                                                 this->bitmaskArray->getIthBitmask( i )->getX(),
                                                                 this->bitmaskArray->getIthBitmask( i )->getY(),
                                                                         X,
                                                                         Y,
                                                                         this->level + 1 );
            this->children[ i ]->setNode( nodesX, nodesY, this->depth );
                this->children[ index ]->setNode( nodesX, nodesY, this->depth );
            }
        }
}

+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
int main()
{
    fstream f;
    f.open( "mrdat.txt" );
    f.open( "mrdat.txt", ios::out | ios::trunc );
    const unsigned x = 4;
    const unsigned y = 4;
    const unsigned size = x * y;