Commit 473937b3 authored by Libor's avatar Libor
Browse files

Added file stream output.

parent 255f644b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
#ifndef _TNLINTERNALNODE_H_INCLUDED_
#define _TNLINTERNALNODE_H_INCLUDED_

#include <fstream>
#include "tnlNode.h"
#include "tnlArea2D.h"
#include "tnlCircle2D.h"
@@ -27,6 +28,11 @@ public:
                      int splitY,
                      int depth );

    void print( int splitX,
                int splitY,
                int depth,
                fstream& file );

    ~tnlInternalNode();

private:
+33 −0
Original line number Diff line number Diff line
#ifndef _TNLINTERNALNODE_IMPL_H_INCLUDED_
#define _TNLINTERNALNODE_IMPL_H_INCLUDED_

#include <iostream>
#include "tnlInternalNode.h"
#include "tnlLeafNode.h"
#include "tnlArea2D.h"
@@ -63,6 +64,7 @@ void tnlInternalNode< LogX, LogY >::setChildren( int splitX,
            this->children[ i ] = 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,
                                                                     this->circle,
                                                                     this->bitmaskArray->getIthBitmask( i )->getX(),
@@ -82,4 +84,35 @@ void tnlInternalNode< LogX, LogY >::setChildren( int splitX,
    }
}

template< int LogX,
          int LogY >
void tnlInternalNode< LogX, LogY >::print( int splitX,
                                           int splitY,
                                           int depth,
                                           fstream& file )
{
    int depthX = splitX * tnlVDBMath::power( LogX, this->level );
    int depthY = splitY * tnlVDBMath::power( LogY, this->level );
    float stepX = ( float ) this->area->getLengthX() / depthX;
    float stepY = ( float ) this->area->getLengthY() / depthY;
    float startX = this->X * stepX;
    float endX = ( this->X + 1 ) * stepX;
    float startY = this->Y * stepY;
    float endY = ( this->Y + 1 ) * stepY;
    tnlIterator2D< LogX * LogY, LogX, LogY >* iter =
                 new tnlIterator2D< LogX * LogY, LogX, LogY >( LogX,
                                                               LogY,
                                                               ( float ) ( endX - startX ) / LogX,
                                                               ( float ) ( endY - startY ) / LogY,
                                                               startX,
                                                               startY );
    iter->dumpIntoFile( this->bitmaskArray, file, this->level );
    for( int i = 0; i < LogX * LogY; i++ )
        if( this->children[ i ] == NULL )
            continue;
        else
            this->children[ i ]->print( splitX, splitY, depth, file );
}


#endif // _TNLINTERNALNODE_IMPL_H_INCLUDED_
+5 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@

#include "tnlBitmaskArray.h"
#include "tnlCircle2D.h"
#include <fstream>

template< unsigned size,
          int LogX,
@@ -20,6 +21,10 @@ public:
    void computeBitmaskArray( tnlBitmaskArray< size >* bitmaskArray,
                              tnlCircle2D* circle );

    void dumpIntoFile( tnlBitmaskArray< size >* bitmaskArray,
                       fstream& file,
                       int level = 0 );

    ~tnlIterator2D(){};

private:
+23 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#include "tnlBitmaskArray.h"
#include "tnlBitmask.h"
#include "tnlCircle2D.h"
#include <fstream>

template< unsigned size,
          int LogX,
@@ -44,4 +45,26 @@ void tnlIterator2D< size, LogX, LogY >::computeBitmaskArray( tnlBitmaskArray< si
        }
}

template< unsigned size,
          int LogX,
          int LogY >
void tnlIterator2D< size, LogX, LogY >::dumpIntoFile( tnlBitmaskArray< size >* bitmaskArray,
                                                      fstream& file,
                                                      int level )
{
    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;
            bool state = bitmaskArray->getIthBitmask( i * this->cellsX + j )->getState();
            file << "x1 = " << x1 << ", x2 = " << x2 << 
                    ", y1 = " << y1 << ", y2 = " << y2 <<
                    ", state = " << state << 
                    ", level = " << level << std::endl;
        }
}

#endif // _TNLITERATOR2D_IMPL_H_INCLUDED_
+6 −0
Original line number Diff line number Diff line
#ifndef _TNLLEAFNODE_H_INCLUDED_
#define _TNLLEAFNODE_H_INCLUDED_

#include <fstream>
#include "tnlNode.h"
#include "tnlArea2D.h"
#include "tnlCircle2D.h"
@@ -21,6 +22,11 @@ public:
                  int splitY,
                  int depth );

    void print( int splitX,
                int splitY,
                int depth,
                fstream& file );

    ~tnlLeafNode();

private:
Loading