Commit 8dde211d authored by Libor's avatar Libor
Browse files

Basic VDB structure. Not built yet.

parent 24683092
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -13,10 +13,14 @@ public:

    unsigned getEndX();

    unsigned getLengthX();

    unsigned getStartY();

    unsigned getEndY();

    unsigned getLengthY();

    ~tnlArea2D(){};

private:
+10 −0
Original line number Diff line number Diff line
@@ -24,6 +24,11 @@ unsigned tnlArea2D::getEndX()
    return this->endX;
}

unsigned tnlArea2D::getLengthX()
{
    return this->endX - this->startX;
}

unsigned tnlArea2D::getStartY()
{
    return this->startY;
@@ -34,4 +39,9 @@ unsigned tnlArea2D::getEndY()
    return this->endY;
}

unsigned tnlArea2D::getLengthY()
{
    return this->endY - this->startY;
}

#endif // _TNLAREA2D_IMPL_H_INCLUDED_
+16 −2
Original line number Diff line number Diff line
@@ -2,19 +2,33 @@
#define _TNLINTERNALNODE_H_INCLUDED_

#include "tnlNode.h"
#include "tnlArea2D"
#include "tnlCircle2D.h"
#include "tnlBitmask.h"
#include "tnlBitmaskArray.h"

template< int LogX,
          int LogY = LogX >
class tnlInternalNode : public tnlNode
{
public:
    tnlInternalNode();
    tnlInternalNode( tnlArea2D* area,
                     tnlCircle2D* circle,
                     tnlBitmask* coordinates,
                     int level );

    void setNode( int splitX,
                  int splitY,
                  int depth );

    void setChildren( int splitX,
                      int splitY,
                      int depth );

    ~tnlInternalNode();

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


+77 −0
Original line number Diff line number Diff line
#ifndef _TNLINTERNALNODE_IMPL_H_INCLUDED_
#define _TNLINTERNALNODE_IMPL_H_INCLUDED_

#include "tnlInternalNode.h"
#include "tnlArea2D.h"
#include "tnlCircle2D.h"
#include "tnlBitmask.h"
#include "tnlVDBMath.h"

template< int LogX,
          int LogY = LogX >
tnlInternalNode< LogX, LogY >::tnlInternalNode( tnlArea2D* area,
                                                tnlCircle2D* circle,
                                                tnlBitmask* coordinates,
                                                int level )
{
    this->area = area;
    this->circle = circle;
    this->coordinates = coordinates;
    this->level = level;
}

template< int LogX,
          int LogY = LogX >
void tnlInternalNode< LogX, LogY >::setNode( int splitX,
                                             int splitY,
                                             int depth )
{
    int depthX = splitX * tnlVDBMath::power( LogX, level );
    int depthY = splitY * tnlVDBMath::power( LogY, level );
    float stepX = ( float ) this->area->getLengthX() / depthX;
    float stepY = ( float ) this->area->getLengthY() / depthY;
    float startX = this->coordinates->getX() * stepX;
    float endX = ( this->coordinates->getX() + 1 ) * stepX;
    float startY = this->coordinates->getY() * stepY;
    float endY = ( this->coordinates->getY() + 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->setChildren( splitX, splitY, depth );
}

template< int LogX,
          int LogY = LogX >
void tnlInternalNode< LogX, LogY >::setChildren( int splitX,
                                                 int splitY,
                                                 int depth )
{
    for( int i = 0; i < LogX * LogY; i++ )
    {
        if( !this->bitmaskArray->getIthMask()->getState() )
            this->children[ i ] = NULL;
        else if( this->level < depth - 1 )
        {
            this->children[ i ] = new tnlInternalNode( this->area,
                                                       this->circle,
                                                       this->bitmaskArray->getIthBitmask( i ),
                                                       this->level + 1 );
            this->children[ i ]->setNode( splitX, splitY, depth );
        }
        else
        {
            this->children[ i ] = new tnlLeafNode( this->area,
                                                   this->circle,
                                                   this->bitmaskArray->getIthBitmask( i ),
                                                   this->level + 1 );
            this->children[ i ]->setNode( splitX, splitY, depth );
        }
    }
}

#endif // _TNLINTERNALNODE_IMPL_H_INCLUDED_
+0 −3
Original line number Diff line number Diff line
@@ -21,9 +21,6 @@ public:
    void computeBitmaskArray( tnlBitmaskArray< size >* bitmaskArray,
                              tnlCircle2D* circle );

    void setChildren( tnlNode< LogX, LogY >* children,
                      tnlBitmaskArray< size >* bitmaskArray );

    ~tnlIterator2D(){};

private:
Loading