Reconstruction of Enright Test using OpenVDB

112 Views Asked by At

I want to recreate the Enright Test results with OpenVDB as mentioned in the article by Ken Museth.

After setting up OpenVDB I've Created the sphere similarly to the way it was described in the OpenVDB test git.

I have recieved results which are very different than the results shown in the article.

my code is shown below:

openvdb::GridCPtrVec SphereTest(){
openvdb::GridCPtrVec GridVec;

float fGridSize = 512;

int iGridSize = 512;

double w = 1;

openvdb::Vec3f centerEnright(0.35*fGridSize, 0.35*fGridSize, 0.35*fGridSize);

openvdb::FloatGrid::Ptr grid(new openvdb::FloatGrid());

grid->setGridClass(openvdb::GridClass::GRID_LEVEL_SET);

auto tree = grid->treePtr();

auto outside = 5 * w;

auto inside = -outside;

for (int i = 0; i < iGridSize; ++i)
{
    for (int j = 0; j < iGridSize; j++)
    {
        for (int k = 0; k < iGridSize; k++)
        {
            openvdb::Coord coord(i, j, k);
            const openvdb::Vec3f p = grid->transform().indexToWorld(coord);
            const float dist = float((p - centerEnright).length() - (0.15*fGridSize));
            auto aDist = abs(dist);

            if (aDist < outside)
            {
                if (dist>0)
                    tree->setValue(coord, dist);
                else
                    tree->setValue(coord, dist);
            }
            else
            {
                if (dist>outside)
                    tree->setValueOff(coord, outside);
                else
                    tree->setValueOff(coord, inside);
            }


        }
    }
}

std::cout << "Active Voxels MV: " << grid->activeVoxelCount() / 1000000.0 << "\n";

double mem = MemInfo::virtualMemUsedByMe();

std::cout << "Memory MB: " << mem / 1000000.0 << "\n";

openvdb::tools::pruneLevelSet(grid->tree());

std::cout << "Active Voxels MV: " << grid->activeVoxelCount() / 1000000.0 << "\n";

double lastmem=mem;

mem = MemInfo::virtualMemUsedByMe();

std::cout << "Memory MB: " << (mem-lastmem) / 1000000.0 << "\n";

GridVec.push_back(grid);}

my results are as follows :

Active Voxels MV: 0.742089

Memory MB: 617.325

after

Active Voxels MV: 0.742089

Memory MB: 56.234

and as one can see it is ten folds bigger from the results in the article.

Results can be seen in Tables II ,III and IV in the article referring to the 512^3 gridsize , with the [6,5,4,3] tree branching. I've reached the almost the same number of active voxels(Table III) , but with significant additional memory consumption table(IV), while the results of Table II are very confusing. am I missing something? or doing something wrong , maybe not activating some kind of compression, or bit quantization as the article states.

also when looking at the generated grid using the viewer it shows a perfect rounded sphere(not voxelized in the boolean manner) , which is what I'm going for.

any thoughts?

thank you

0

There are 0 best solutions below