Commit 2d742bfd authored by Libor's avatar Libor
Browse files

Bitmasks with unittests, basics for iterators and TODO list.

parent e3eb673f
Loading
Loading
Loading
Loading

src/mesh/vdb/TODO

0 → 100755
+9 −0
Original line number Diff line number Diff line
echo
echo
echo "Bitmasks seem to be alright at the moment"
echo
echo
echo "Currently most important is to implement math funcs,"
echo "as the origin 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."
+24 −0
Original line number Diff line number Diff line
#ifndef _TNLBITMASK_H_INCLUDED_
#define _TNLBITMASK_H_INCLUDED_

#include <cstdint>

class tnlBitmask
{
public:
    tnlBitmask( bool state, unsigned x, unsigned y );
    
    bool getState();
    
    unsigned getX();
    
    unsigned getY();
    
    ~tnlBitmask(){};
    
private:
    uint64_t bitmask;
};

#include "tnlBitmask_impl.h"
#endif //_TNLBITMASK_H_INCLUDED_
+22 −0
Original line number Diff line number Diff line
#ifndef _TNLBITMASKARRAY_H_INCLUDED_
#define _TNLBITMASKARRAY_H_INCLUDED_

#include <tnlBitmask.h>

template< unsigned size >
class tnlBitmaskArray
{
public:
    tnlBitmaskArray( unsigned size );

    

    ~tnlBitmaskArray();

private:
    tnlBitmask** bitmaskArray;
    unsigned size;
};

#include <tnlBitmaskArray_impl.h>
#endif // _TNLBITMASKARRAY_H_INCLUDED_
+27 −0
Original line number Diff line number Diff line
#ifndef _TNLBITMASKARRAY_IMPL_H_INCLUDED_
#define _TNLBITMASKARRAY_IMPL_H_INCLUDED_

#include <tnlBitmask.h>

template< unsigned size >
tnlBitmaskArray< size >::tnlBitmaskArray( unsigned size )
{
    this->size = size;
    this->bitmaskArray = new tnlBitmask*[size];
    // in this part all the partial masks should be computed
    // this could be handled by some iterator that knows
    // current depth of the n-tree


    	// TODO: vymyslet jak na to
}

template< unsigned size >
tnlBitmaskArray< size >::~tnlBitmaskArray()
{
    for( int i = 0; i < this->size; i++ )
        delete this->bitmaskArray[ i ];
    delete [] this->bitmaskArray;
}

#endif // _TNLBITMASKARRAY_IMPL_H_INCLUDED_
+44 −0
Original line number Diff line number Diff line
#ifndef _TNLBITMASK_IMPL_H_INCLUDED_
#define _TNLBITMASK_IMPL_H_INCLUDED_

#include <iostream>
#include <cstdint>
#include "tnlBitmask.h"

using namespace std;

tnlBitmask::tnlBitmask( bool state,
                        unsigned x,
                        unsigned y )
/*
  variables x and y have at most 30 active bits
*/                        
{
    uint64_t state64 = state;
    uint64_t x64 = x;
    x64 <<= 4;
    uint64_t y64 = y;
    y64 <<= 34;
    this->bitmask = x64 | y64 | state64;
}                        

bool tnlBitmask::getState()
{
    return this->bitmask & 1;
}

unsigned tnlBitmask::getX()
{
    unsigned mask = 3 << 30;
    unsigned x = this->bitmask >> 4;
    return ( unsigned ) ( x & ( ~mask ) );
}

unsigned tnlBitmask::getY()
{
    unsigned mask = 3 << 30;
    uint64_t y = this->bitmask >> 34;
    return ( unsigned ) ( y & ( ~mask ) );
}

#endif //_TNLBITMASK_IMPL_H_INCLUDED_
Loading