Commit f3542afa authored by Libor's avatar Libor
Browse files

Write function added.

parent f4db03d5
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -33,6 +33,9 @@ public:
                int depth,
                fstream& file );

    void write( fstream& f,
                int level );

    ~tnlInternalNode();

private:
+24 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
#define _TNLINTERNALNODE_IMPL_H_INCLUDED_

#include <iostream>
#include <iomanip>
#include "tnlInternalNode.h"
#include "tnlLeafNode.h"
#include "tnlArea2D.h"
@@ -48,7 +49,7 @@ void tnlInternalNode< LogX, LogY >::setNode( int splitX,
                                                               ( float ) ( endY - startY ) / LogY,
                                                               startX,
                                                               startY );
    iter->computeBitmaskArray( this->bitmaskArray, this->circle );
    iter->computeBitmaskArray( this->bitmaskArray, this->circle, this->X, this->Y );
    this->setChildren( splitX, splitY, depth );
}

@@ -90,6 +91,28 @@ void tnlInternalNode< LogX, LogY >::setChildren( int splitX,
        }
}

template< int LogX,
          int LogY >
void tnlInternalNode< LogX, LogY >::write( fstream& file,
                                           int level )
{
    for( int i = 0; i < LogX * LogY; i++ )
    {
        if( this->level == level )
        {
            int x = this->bitmaskArray->getIthBitmask( i )->getX();
            int y = this->bitmaskArray->getIthBitmask( i )->getY();
            bool state = this->bitmaskArray->getIthBitmask( i )->getState();
            file << "x=" << setw( 10 ) << x
                 << ", y=" << setw( 10 ) << y
                 << ", state=" << setw( 1 ) << state
                 << std::endl;
        }
        else if( this->children[ i ] )
            this->children[ i ]->write( file, level );
    }
}

template< int LogX,
          int LogY >
void tnlInternalNode< LogX, LogY >::print( int splitX,
+3 −1
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@ public:
                   float startY );

    void computeBitmaskArray( tnlBitmaskArray< size >* bitmaskArray,
                              tnlCircle2D* circle );
                              tnlCircle2D* circle,
                              int posX = 0,
                              int posY = 0 );

    void dumpIntoFile( tnlBitmaskArray< size >* bitmaskArray,
                       fstream& file,
+14 −8
Original line number Diff line number Diff line
@@ -29,7 +29,9 @@ template< unsigned size,
          int LogX,
          int LogY >
void tnlIterator2D< size, LogX, LogY >::computeBitmaskArray( tnlBitmaskArray< size >* bitmaskArray,
                                                             tnlCircle2D* circle )
                                                             tnlCircle2D* circle,
                                                             int posX,
                                                             int posY )
{
    // yeah, in matrix, i like to iterate over rows first
    for( int i = 0; i < this->cellsY; i++ )
@@ -40,7 +42,9 @@ void tnlIterator2D< size, LogX, LogY >::computeBitmaskArray( tnlBitmaskArray< si
            float y1 = this->startY + i * this->stepY;
            float y2 = this->startY + ( i + 1 ) * this->stepY;
            bool state = circle->isIntercept( x1, x2, y1, y2 );
            tnlBitmask* bitmask = new tnlBitmask( state, j, i );
            int X = posX * cellsX + j;
            int Y = posY * cellsY + i;
            tnlBitmask* bitmask = new tnlBitmask( state, X, Y );
            bitmaskArray->setIthBitmask( i * this->cellsX + j, bitmask );
        }
}
@@ -55,13 +59,15 @@ void tnlIterator2D< size, LogX, LogY >::dumpIntoFile( tnlBitmaskArray< size >* b
    for( int i = 0; i < this->cellsY; i++ )
        for( int j = 0; j < this->cellsX; j++ )
        {
            float x1 = this->startX + j * this->stepX;
            float x2 = this->startX + ( j + 1 ) * this->stepX;
            float y1 = this->startY + i * this->stepY;
            float y2 = this->startY + ( i + 1 ) * this->stepY;
            //float x1 = this->startX + j * this->stepX;
            //float x2 = this->startX + ( j + 1 ) * this->stepX;
            //float y1 = this->startY + i * this->stepY;
            //float y2 = this->startY + ( i + 1 ) * this->stepY;
            int x = bitmaskArray->getIthBitmask( i * this->cellsX + j )->getX();
            int y = bitmaskArray->getIthBitmask( i * this->cellsX + j )->getY();
            bool state = bitmaskArray->getIthBitmask( i * this->cellsX + j )->getState();
            file << "x1 = " << x1 << ", x2 = " << x2 << 
                    ", y1 = " << y1 << ", y2 = " << y2 <<
            file << "x = " << x <<
                    ", y = " << y <<
                    ", state = " << state << 
                    ", level = " << level << std::endl;
        }
+3 −0
Original line number Diff line number Diff line
@@ -27,6 +27,9 @@ public:
                int depth,
                fstream& file );

    void write( fstream& file,
                int level );

    ~tnlLeafNode();

private:
Loading