AcademySoftwareFoundation / openvdb

OpenVDB - Sparse volume data structure and tools
http://www.openvdb.org/
Mozilla Public License 2.0
2.59k stars 643 forks source link

[BUG] NanoVDB `GridHandler` error #1863

Open mesteban-22 opened 1 month ago

mesteban-22 commented 1 month ago

Environment

Linux Ubuntu 24.04 LTS OpenVDB: 11.0.0 Ubuntu clang version 18.1.8 & Ubuntu 10.5.0-4ubuntu2

Describe the bug

Unable to compile the NanoVDB first example.

To Reproduce

Steps to reproduce the behavior:

  1. Build with NANOVDB_USE_CUDA, NANOVDB_USE_OPENVDB
  2. Copy the file from first example. Used CMakeLists.txt for compiling the example
    
    cmake_minimum_required(VERSION 3.28)
    project(test LANGUAGES CXX CUDA)

include_directories( /usr/local/cuda/include )

set(CMAKE_CXX_STANDARD 17)

list(APPEND CMAKE_MODULE_PATH "/usr/local/lib/cmake/OpenVDB") find_package(OpenVDB REQUIRED) add_executable(nanoVDB_test main.cpp)

target_link_libraries(test OpenVDB::openvdb)


3. Compilation error (same for clang and gcc)

In file included from main.cpp:2: /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' requested here 961 | [&](){this->template processGrid();} ); | ^ /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(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); | ^ /home/mesteban/CLionProjects/nanoVDB-test/main.cpp:13:32: 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 13 | auto handle = nanovdb::createNanoGrid(srcGrid); | ^ In file included from /home/mesteban/CLionProjects/nanoVDB-test/main.cpp:2: /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(), mapToGridClass(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' requested here 961 | [&](){this->template processGrid();} ); | ^ /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(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); | ^ main.cpp:13:32: 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 /home/mesteban/CLionProjects/nanoVDB-test/main.cpp:13:32: 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 13 | auto handle = nanovdb::createNanoGrid(srcGrid); | ^

apradhana commented 1 month ago

Thanks for reporting this. I was able to reproduce the error. Thanks to @matthewdcong who pointed out that adding target_compile_definitions(nanovdb_test PRIVATE "NANOVDB_USE_OPENVDB") to the CMakeLists fixes the problem. Here is the CMakeLists I end up using:

cmake_minimum_required(VERSION 3.27)
project(test LANGUAGES CXX CUDA)

include_directories(
    /usr/local/cuda/include
)

set(CMAKE_CXX_STANDARD 17)
list(APPEND CMAKE_MODULE_PATH "/usr/local/lib/cmake/OpenVDB")
find_package(OpenVDB "11.0.1" REQUIRED COMPONENTS openvdb nanovdb)
add_executable(nanovdb_test main.cpp)
target_compile_definitions(nanovdb_test PRIVATE "NANOVDB_USE_OPENVDB")
target_link_libraries(nanovdb_test OpenVDB::openvdb OpenVDB::nanovdb)