Commit 0987d1c0 authored by Libor's avatar Libor
Browse files

Refactored tree creation. Print methods will also be refactored.

parent 7584118d
Loading
Loading
Loading
Loading
+4 −14
Original line number Diff line number Diff line
echo
echo
echo "Basics of the tree are implemented. What must be done now"
echo "is to implement internal and leaf nodes and handler to "
echo "create the whole tree. After that lookup methods need "
echo "to be implemented and also class values to store functions"
echo "values in each point. There should also be some bitmask "
echo "to tell which nodes are active for fast lookup and bitmask"
echo "to identify coordinates of given area."
echo "Add integration to tnl library -- that means: templates for"
echo "Real, Index and Device types. Add Values class to store "
echo "interpoled values in each node. Compare speed with original"
echo "VDB. Implement on CUDA. Implement 3D version (should be trivial)."
echo
echo "Currently most important is to implement math funcs,"
echo "as the original ones are exponentially complex, in 2D"
echo "its complexity is at most 2^2, in 3D its at most 2^3 (!)"
echo "which lightweigth GPU threads won't handle."


Program fails at tnlIterator2D->computeBitmaskArray() last instruction in for loop (check whats happenning in tnlBitmaskArray->setIthMask())
+1 −1
Original line number Diff line number Diff line
g++ -O1 -g -Wall -std=c++11 tnlInternalNode.h tnlInternalNode_impl.h tnlLeafNode.h tnlLeafNode_impl.h tnlNode.h tnlNode_impl.h tnlVDBMath.h tnlRootNode_test.cpp tnlRootNode.h tnlRootNode_impl.h tnlArea2D.h tnlArea2D_impl.h tnlCircle2D.h tnlCircle2D_impl.h tnlIterator2D.h tnlIterator2D_impl.h tnlBitmaskArray.h tnlBitmaskArray_impl.h tnlBitmask.h tnlBitmask_impl.h -o test
g++ -O1 -g -Wall -std=c++11 -Werror tnlInternalNode.h tnlInternalNode_impl.h tnlLeafNode.h tnlLeafNode_impl.h tnlNode.h tnlNode_impl.h tnlVDBMath.h tnlRootNode_test.cpp tnlRootNode.h tnlRootNode_impl.h tnlArea2D.h tnlArea2D_impl.h tnlCircle2D.h tnlCircle2D_impl.h tnlIterator2D.h tnlIterator2D_impl.h tnlBitmaskArray.h tnlBitmaskArray_impl.h tnlBitmask.h tnlBitmask_impl.h -o test
+1 −6
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"

//template< int LogX, int LogY >
//class tnlNode;

template< int LogX,
          int LogY = LogX >
@@ -39,6 +33,7 @@ public:
    ~tnlInternalNode();

private:
    tnlBitmaskArray< LogX * LogY >* bitmaskArray;
    tnlNode< LogX, LogY >* children[ LogX * LogY ];
};

+12 −27
Original line number Diff line number Diff line
@@ -5,12 +5,6 @@
#include <iomanip>
#include "tnlInternalNode.h"
#include "tnlLeafNode.h"
#include "tnlArea2D.h"
#include "tnlCircle2D.h"
#include "tnlBitmask.h"
#include "tnlVDBMath.h"
#include "tnlIterator2D.h"
#include "tnlBitmaskArray.h"

template< int LogX,
          int LogY >
@@ -19,13 +13,9 @@ tnlInternalNode< LogX, LogY >::tnlInternalNode( tnlArea2D* area,
                                                int X,
                                                int Y,
                                                int level )
: tnlNode< LogX, LogY >::tnlNode( area, circle, X, Y, level )
{
    this->bitmaskArray = new tnlBitmaskArray< LogX * LogY >();
    this->area = area;
    this->circle = circle;
    this->X = X;
    this->Y = Y;
    this->level = level;
}

template< int LogX,
@@ -34,22 +24,7 @@ void tnlInternalNode< LogX, LogY >::setNode( int splitX,
                                             int splitY,
                                             int depth )
{
    int depthX = splitX * tnlVDBMath::power( LogX, this->level - 1 );
    int depthY = splitY * tnlVDBMath::power( LogY, this->level - 1 );
    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->computeBitmaskArray( this->bitmaskArray, this->circle, this->X, this->Y );
    tnlNode< LogX, LogY >::setNode( splitX, splitY, this->bitmaskArray );
    this->setChildren( splitX, splitY, depth );
}

@@ -143,5 +118,15 @@ void tnlInternalNode< LogX, LogY >::print( int splitX,
            this->children[ i ]->print( splitX, splitY, depth, file );
}

template< int LogX,
          int LogY >
tnlInternalNode< LogX, LogY >::~tnlInternalNode()
{
    delete this->bitmaskArray;
    for( int i = 0; i < LogX * LogY; i++ )
        delete this->children[ i ];
    delete [] this->children;
}


#endif // _TNLINTERNALNODE_IMPL_H_INCLUDED_
+1 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ public:
    ~tnlLeafNode();

private:
    tnlBitmaskArray< LogX * LogY >* bitmaskArray;
};

#include "tnlLeafNode_impl.h"
Loading