AcademySoftwareFoundation / openvdb

OpenVDB - Sparse volume data structure and tools
http://www.openvdb.org/
Apache License 2.0
2.71k stars 660 forks source link

[BUG] I cannot compile my code using NanoVDB #1707

Open Jaisiero opened 1 year ago

Jaisiero commented 1 year ago

Hi guys, I hope somebody could help me to fix this or maybe I should try an earlier commit/version. I'll leave this here anyway in cause it is useful for you guys.

Environment

Operating System: (Ubuntu 22.04) Version / Commit SHA: (master branch, SHA: 9153c12ed095156aad18f4a0ca7f754b97eb83da) Other: (Ubuntu clang version 17.0.4 (++20231031083134+309d55140c46-1~exp1~20231031083240.62), -std=c++17)

Describe the bug

I was trying to use OpenVDB and everything was fine untill I try to use NanoVDB. I got some some compilation errors:

In file included from ./src/main.cpp:8:
/usr/local/include/nanovdb/util/CreateNanoGrid.h:324:58: error: no member named 'map' in 'openvdb::v11_0::Grid<openvdb::v11_0::tree::Tree<openvdb::v11_0::tree::RootNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::LeafNode<float, 3>, 4>, 5>>>>'
  324 |     const nanovdb::Map& map() const {return this->grid().map();}
      |                                             ~~~~~~~~~~~~ ^
/usr/local/include/nanovdb/util/CreateNanoGrid.h:1719:74: note: in instantiation of member function 'nanovdb::NodeAccessor<openvdb::v11_0::Grid<openvdb::v11_0::tree::Tree<openvdb::v11_0::tree::RootNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::LeafNode<float, 3>, 4>, 5>>>>>::map' requested here
 1719 |     dstData->init({GridFlags::IsBreadthFirst}, mOffset.size, mSrcNodeAcc.map(),
      |                                                                          ^
/usr/local/include/nanovdb/util/CreateNanoGrid.h:961:34: note: in instantiation of function template specialization 'nanovdb::CreateNanoGrid<openvdb::v11_0::Grid<openvdb::v11_0::tree::Tree<openvdb::v11_0::tree::RootNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::LeafNode<float, 3>, 4>, 5>>>>>::processGrid<float>' requested here
  961 |             [&](){this->template processGrid<DstBuildT>();} );
      |                                  ^
/usr/local/include/nanovdb/util/CreateNanoGrid.h:899:34: note: in instantiation of function template specialization 'nanovdb::CreateNanoGrid<openvdb::v11_0::Grid<openvdb::v11_0::tree::Tree<openvdb::v11_0::tree::RootNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::LeafNode<float, 3>, 4>, 5>>>>>::initHandle<float, nanovdb::HostBuffer>' requested here
  899 |     auto handle = this->template initHandle<DstBuildT>(pool);
      |                                  ^
/usr/local/include/nanovdb/util/CreateNanoGrid.h:1966:31: note: in instantiation of function template specialization 'nanovdb::CreateNanoGrid<openvdb::v11_0::Grid<openvdb::v11_0::tree::Tree<openvdb::v11_0::tree::RootNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::LeafNode<float, 3>, 4>, 5>>>>>::getHandle<float, nanovdb::HostBuffer>' requested here
 1966 |     return converter.template getHandle<DstBuildT, BufferT>(buffer);
      |                               ^
./src/main.cpp:572:28: note: in instantiation of function template specialization 'nanovdb::createNanoGrid<openvdb::v11_0::Grid<openvdb::v11_0::tree::Tree<openvdb::v11_0::tree::RootNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::LeafNode<float, 3>, 4>, 5>>>>, float, nanovdb::HostBuffer>' requested here
  572 |     auto handle = nanovdb::createNanoGrid(*grid);
      |                            ^
In file included from ./src/main.cpp:8:
/usr/local/include/nanovdb/util/CreateNanoGrid.h:325:54: error: no member named 'gridClass' in 'openvdb::v11_0::Grid<openvdb::v11_0::tree::Tree<openvdb::v11_0::tree::RootNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::LeafNode<float, 3>, 4>, 5>>>>'
  325 |     GridClass gridClass() const {return this->grid().gridClass();}
      |                                         ~~~~~~~~~~~~ ^
/usr/local/include/nanovdb/util/CreateNanoGrid.h:1720:85: note: in instantiation of member function 'nanovdb::NodeAccessor<openvdb::v11_0::Grid<openvdb::v11_0::tree::Tree<openvdb::v11_0::tree::RootNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::LeafNode<float, 3>, 4>, 5>>>>>::gridClass' requested here
 1720 |                   mapToGridType<DstBuildT>(), mapToGridClass<DstBuildT>(mSrcNodeAcc.gridClass()));
      |                                                                                     ^
/usr/local/include/nanovdb/util/CreateNanoGrid.h:961:34: note: in instantiation of function template specialization 'nanovdb::CreateNanoGrid<openvdb::v11_0::Grid<openvdb::v11_0::tree::Tree<openvdb::v11_0::tree::RootNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::LeafNode<float, 3>, 4>, 5>>>>>::processGrid<float>' requested here
  961 |             [&](){this->template processGrid<DstBuildT>();} );
      |                                  ^
/usr/local/include/nanovdb/util/CreateNanoGrid.h:899:34: note: in instantiation of function template specialization 'nanovdb::CreateNanoGrid<openvdb::v11_0::Grid<openvdb::v11_0::tree::Tree<openvdb::v11_0::tree::RootNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::LeafNode<float, 3>, 4>, 5>>>>>::initHandle<float, nanovdb::HostBuffer>' requested here
  899 |     auto handle = this->template initHandle<DstBuildT>(pool);
      |                                  ^
/usr/local/include/nanovdb/util/CreateNanoGrid.h:1966:31: note: in instantiation of function template specialization 'nanovdb::CreateNanoGrid<openvdb::v11_0::Grid<openvdb::v11_0::tree::Tree<openvdb::v11_0::tree::RootNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::LeafNode<float, 3>, 4>, 5>>>>>::getHandle<float, nanovdb::HostBuffer>' requested here
 1966 |     return converter.template getHandle<DstBuildT, BufferT>(buffer);
      |                               ^
./src/main.cpp:572:28: note: in instantiation of function template specialization 'nanovdb::createNanoGrid<openvdb::v11_0::Grid<openvdb::v11_0::tree::Tree<openvdb::v11_0::tree::RootNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::InternalNode<openvdb::v11_0::tree::LeafNode<float, 3>, 4>, 5>>>>, float, nanovdb::HostBuffer>' requested here
  572 |     auto handle = nanovdb::createNanoGrid(*grid);
      |                            ^
78 warnings and 2 errors generated.
make: *** [Makefile:29: main.o] Error 1
make: Leaving directory '/home/jaisiero/Projects/openvdb_sample'

To Reproduce

The code is very simple yet. I got this code from one of your examples guys. This is line which throws the error:

    // Convert the OpenVDB grid, srcGrid, into a NanoVDB grid handle.
    auto handle = nanovdb::createNanoGrid(*grid);

Expected behavior

I wanted to convert my OpenVDB data into NanoVDB and afterwards use it inside an GLSL shader. But I couldn't.

EDIT: So i figured it out using this macro in my main.cpp before including NanoVDB headers:

define NANOVDB_USE_OPENVDB

And it worked! Definitely this should be known somewhere.

Thanks!