diff --git a/.github/workflows/ax.yml b/.github/workflows/ax.yml index b353646092..be512fbc2c 100644 --- a/.github/workflows/ax.yml +++ b/.github/workflows/ax.yml @@ -70,20 +70,14 @@ jobs: - { image: '2023-clang15', cxx: 'clang++', build: 'Release', cmake: '' } - { image: '2023-clang15', cxx: 'g++', build: 'Release', cmake: '' } - { image: '2023-clang15', cxx: 'clang++', build: 'Debug', cmake: '' } - - { image: '2022-clang11', cxx: 'clang++', build: 'Release', cmake: '' } - - { image: '2022-clang11', cxx: 'g++', build: 'Release', cmake: '' } - - { image: '2021-clang10', cxx: 'clang++', build: 'Release', cmake: '-DDISABLE_DEPENDENCY_VERSION_CHECKS=ON' } - - { image: '2021-clang10', cxx: 'g++', build: 'Release', cmake: '-DDISABLE_DEPENDENCY_VERSION_CHECKS=ON' } fail-fast: false steps: - - name: Enable Node 16 - if: contains(matrix.config.image, '2021') || contains(matrix.config.image, '2022') - run: | - echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV - uses: actions/checkout@v3 - - name: pybind11 + - name: nanobind #if: contains(matrix.config.image, '2023') == false - run: ./ci/install_pybind11.sh 2.10.0 + run: ./ci/install_nanobind.sh 2.0.0 + - name: install_gtest + run: ./ci/install_gtest.sh 1.15.2 - name: timestamp id: timestamp run: echo "timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT @@ -128,9 +122,8 @@ jobs: strategy: matrix: config: - #@note llvm10 never got its own brew formula... - # Last macos runner befor M1 (macos-14) - - { runner: 'macos-13', cxx: 'clang++', build: 'Release', llvm: '12' } + # Last macos runner before M1 (macos-14) + - { runner: 'macos-13', cxx: 'clang++', build: 'Release', llvm: '15' } - { runner: 'macos-13', cxx: 'clang++', build: 'Release', llvm: '13' } fail-fast: false steps: @@ -161,7 +154,7 @@ jobs: github.event.inputs.type == 'grammar' runs-on: ${{ (github.repository_owner == 'AcademySoftwareFoundation' && 'ubuntu-20.04-8c-32g-300h') || 'ubuntu-latest' }} container: - image: aswf/ci-openvdb:2022-clang11 + image: aswf/ci-openvdb:2023-clang15 steps: - uses: actions/checkout@v3 - name: build diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fa1956fd22..6d479e57a5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,27 +76,21 @@ jobs: strategy: matrix: config: - # @note we specifically use clang15.0 (not clang15) here as the newest - # versions of the clang15.X containers have some issues with the GLFW - # installation - - { cxx: clang++, image: '2023-clang15.0', abi: '11', build: 'Release', cmake: '' } - - { cxx: g++, image: '2023-clang15.0', abi: '11', build: 'Release', cmake: '' } - - { cxx: clang++, image: '2022-clang11', abi: '11', build: 'Debug', cmake: '' } - - { cxx: clang++, image: '2022-clang11', abi: '10', build: 'Release', cmake: '' } - - { cxx: g++, image: '2022-clang11', abi: '10', build: 'Release', cmake: '' } - - { cxx: clang++, image: '2022-clang11', abi: '9', build: 'Release', cmake: '-DDISABLE_DEPENDENCY_VERSION_CHECKS=ON' } - - { cxx: g++, image: '2022-clang11', abi: '9', build: 'Release', cmake: '-DDISABLE_DEPENDENCY_VERSION_CHECKS=ON' } + - { cxx: clang++, image: '2024', abi: '12', build: 'Release', cmake: '' } + - { cxx: g++, image: '2024', abi: '12', build: 'Release', cmake: '' } + - { cxx: clang++, image: '2024', abi: '12', build: 'Debug', cmake: '' } + - { cxx: clang++, image: '2023', abi: '11', build: 'Release', cmake: '-DDISABLE_DEPENDENCY_VERSION_CHECKS=ON' } + - { cxx: g++, image: '2023', abi: '11', build: 'Release', cmake: '-DDISABLE_DEPENDENCY_VERSION_CHECKS=ON' } fail-fast: false steps: - - name: Enable Node 16 - # Solution taken from https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default - if: contains(matrix.config.image, '2022') - run: | - echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV - uses: actions/checkout@v3 - - name: pybind11 - #if: contains(matrix.config.image, '2023') == false - run: ./ci/install_pybind11.sh 2.10.0 + - name: nanobind + run: ./ci/install_nanobind.sh 2.0.0 + - name: glfw + if: contains(matrix.config.image, '2023') == true + run: ./ci/install_glfw.sh 3.3.10 + - name: install_gtest + run: ./ci/install_gtest.sh 1.15.2 - name: timestamp id: timestamp run: echo "timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT @@ -152,7 +146,8 @@ jobs: echo "$Env:VCPKG_INSTALLATION_ROOT\installed\x64-windows\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "${{github.workspace}}\build\openvdb\openvdb\Release" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: install - run: ./ci/install_windows.sh + shell: powershell + run: .\ci\install_windows.ps1 - name: build run: > ./ci/build.sh -v diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 21a9e2bac8..617ae20a12 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -40,25 +40,18 @@ jobs: container: # @note We can't update this as epydoc doesn't support python3. We'll # need to re-write the python docs to use sphinx - image: aswf/ci-openvdb:2022 + image: aswf/ci-openvdb:2024 steps: - - name: Enable Node 16 - run: | - echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: install_doxygen run: ./ci/install_doxygen.sh 1_8_11 - - name: pybind11 + - name: nanobind #if: contains(matrix.config.image, '2023') == false - run: ./ci/install_pybind11.sh 2.10.0 + run: ./ci/install_nanobind.sh 2.0.0 # - name: install_epydoc # run: pip install epydoc - name: install_latex run: | - # Fix error: Cannot prepare internal mirrorlist: No URLs in mirrorlist. CentOS 8 reached EOL means need to replace the official mirror to vault.centos.org - # Comment out mirrorlist and replace #baseurl=...mirror.centos.org with baseurl=...vault.centos.org in files starting with CentOS- in /etc/yum.repos.d folder - sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* - sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* yum -y install texlive-latex-bin texlive-dvips texlive-collection-fontsrecommended texlive-collection-latexrecommended - name: build run: > @@ -92,7 +85,7 @@ jobs: github.event.inputs.deploy == 'docs' uses: peaceiris/actions-gh-pages@v3 with: - deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} + deploy_key: ${{ secrets.PRIVATE_KEY }} publish_dir: /usr/local/share/doc/OpenVDB/html destination_dir: documentation/doxygen external_repository: AcademySoftwareFoundation/openvdb-website diff --git a/.github/workflows/houdini.yml b/.github/workflows/houdini.yml index 3f2445cd21..28efc703b8 100644 --- a/.github/workflows/houdini.yml +++ b/.github/workflows/houdini.yml @@ -75,25 +75,26 @@ jobs: strategy: matrix: config: - - { cxx: clang++, image: '2023.0', hou_hash: '20_0-newabi', build: 'Release', components: 'core,hou,bin,view,render,python,test,axcore,axbin,axtest' } - - { cxx: clang++, image: '2022', hou_hash: '20_0-oldabi', build: 'Release', components: 'core,hou' } - - { cxx: clang++, image: '2021', hou_hash: '19_5', build: 'Release', components: 'core,hou' } - - { cxx: clang++, image: '2023.0', hou_hash: '20_0-newabi', build: 'Debug', components: 'core,hou,bin,view,render,python,test,axcore,axbin,axtest' } - - { cxx: g++, image: '2023.0', hou_hash: '20_0-newabi', build: 'Release', components: 'core,hou,bin,view,render,python,test,axcore,axbin,axtest' } - - { cxx: g++, image: '2022', hou_hash: '20_0-oldabi', build: 'Release', components: 'core,hou' } + - { cxx: clang++, image: '2024', hou_hash: '20_5', build: 'Release', components: 'core,hou,bin,view,render,python,test' } + - { cxx: clang++, image: '2023', hou_hash: '20_5', build: 'Debug', components: 'core,hou,bin,view,render,python,test,axcore,axbin,axtest' } + - { cxx: g++, image: '2023', hou_hash: '20_5', build: 'Release', components: 'core,hou,bin,view,render,python,test,axcore,axbin,axtest' } + - { cxx: clang++, image: '2023', hou_hash: '20_0-newabi', build: 'Release', components: 'core,hou,bin,view,render,python,test,axcore,axbin,axtest' } + - { cxx: g++, image: '2023', hou_hash: '20_0-newabi', build: 'Release', components: 'core,hou,bin,view,render,python,test,axcore,axbin,axtest' } fail-fast: false steps: - # See note on this step in the Houdini weekly.yml job - # We can remove this when we no longer use < 2023 images - - name: Enable Node 16 - run: | - echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV - name: remove zstd run: yum -y remove zstd - uses: actions/checkout@v3 - - name: pybind11 + - name: nanobind #if: contains(matrix.config.image, '2023') == false - run: ./ci/install_pybind11.sh 2.10.0 + run: ./ci/install_nanobind.sh 2.0.0 + - name: glfw + if: contains(matrix.config.image, '2023') == true + run: ./ci/install_glfw.sh 3.3.10 + - name: cppunit + run: ./ci/install_cppunit.sh 1.15.1 + - name: install_gtest + run: ./ci/install_gtest.sh 1.15.2 - name: timestamp id: timestamp run: echo "timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT diff --git a/.github/workflows/nanovdb.yml b/.github/workflows/nanovdb.yml index ed98499aaf..0efc4580a8 100644 --- a/.github/workflows/nanovdb.yml +++ b/.github/workflows/nanovdb.yml @@ -61,30 +61,21 @@ jobs: strategy: matrix: config: - - { cxx: g++, image: '2022-clang11', build: 'Release' } - - { cxx: g++, image: '2022-clang11', build: 'Debug' } - - { cxx: clang++, image: '2022-clang11', build: 'Release' } - - { cxx: clang++, image: '2022-clang11', build: 'Debug' } + - { cxx: g++, image: '2024', build: 'Release' } + - { cxx: g++, image: '2024', build: 'Debug' } + - { cxx: clang++, image: '2024', build: 'Release' } + - { cxx: clang++, image: '2024', build: 'Debug' } fail-fast: false steps: - - name: Enable Node 16 - if: contains(matrix.config.image, '2022') - run: | - echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV - uses: actions/checkout@v3 - - name: install_cuda_11 + - name: setup_cuda_12 run: | - # Fix error: Cannot prepare internal mirrorlist: No URLs in mirrorlist. CentOS 8 reached EOL means need to replace the official mirror to vault.centos.org - # Comment out mirrorlist and replace #baseurl=...mirror.centos.org with baseurl=...vault.centos.org in files starting with CentOS- in /etc/yum.repos.d folder - sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* - sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* yum -y install yum-utils - yum-config-manager --add-repo http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-rhel7.repo - echo "Installing cuda toolkit" - yum --enablerepo=epel -y install cuda-toolkit-11-6 - echo "/usr/local/cuda-11.6/bin" >> $GITHUB_PATH - echo "LD_LIBRARY_PATH=/usr/local/cuda-11.6/lib64:$LD_LIBRARY_PATH" >> $GITHUB_ENV + echo "/usr/local/cuda-12/bin" >> $GITHUB_PATH + echo "LD_LIBRARY_PATH=/usr/local/cuda-12/lib64:$LD_LIBRARY_PATH" >> $GITHUB_ENV - name: build + # NOTE: CMAKE_POSITION_INDEPENDENT_CODE set to fix default behaviour change in clang 14 + # https://github.com/AcademySoftwareFoundation/aswf-docker/issues/228 run: > ./ci/build.sh -v --build-type=${{ matrix.config.build }} @@ -95,6 +86,7 @@ jobs: -DNANOVDB_USE_OPENVDB=ON -DCMAKE_INSTALL_PREFIX=`pwd` -DUSE_BLOSC=OFF + -DCMAKE_POSITION_INDEPENDENT_CODE=ON \' - name: test run: cd build && sudo ctest -V -E ".*cuda.*" @@ -121,9 +113,9 @@ jobs: - name: install_cuda shell: powershell run: .\ci\install_windows_cuda.ps1 - - name: install_deps - shell: bash - run: ./ci/install_windows.sh + - name: install + shell: powershell + run: .\ci\install_windows.ps1 - name: build shell: bash run: > @@ -154,8 +146,8 @@ jobs: strategy: matrix: config: - - { runner: 'macos-12', cxx: 'clang++', build: 'Release' } - - { runner: 'macos-12', cxx: 'clang++', build: 'Debug' } + - { runner: 'macos-13', cxx: 'clang++', build: 'Release' } + - { runner: 'macos-13', cxx: 'clang++', build: 'Debug' } fail-fast: false steps: - uses: actions/checkout@v3 @@ -178,12 +170,12 @@ jobs: github.event.inputs.type == 'all' || github.event.inputs.type == 'linux' runs-on: ${{ (github.repository_owner == 'AcademySoftwareFoundation' && 'ubuntu-20.04-8c-32g-300h') || 'ubuntu-latest' }} + container: + image: aswf/ci-openvdb:2024 steps: - uses: actions/checkout@v3 - name: install_gtest - run: | - sudo apt-get update - sudo apt-get -q install -y libgtest-dev + run: ./ci/install_gtest.sh 1.15.2 - name: build_and_test run: | cd nanovdb/nanovdb diff --git a/.github/workflows/weekly.yml b/.github/workflows/weekly.yml index 5debe30be5..747c8af744 100644 --- a/.github/workflows/weekly.yml +++ b/.github/workflows/weekly.yml @@ -70,16 +70,12 @@ jobs: strategy: matrix: config: - - { houdini_version: '19.5', platform: 'linux_x86_64_gcc9.3', hou_hash: '19_5' } - - { houdini_version: '20.0', platform: 'linux_x86_64_gcc9.3', hou_hash: '20_0-oldabi' } - { houdini_version: '20.0', platform: 'linux_x86_64_gcc11.2', hou_hash: '20_0-newabi' } + - { houdini_version: '20.5', platform: 'linux_x86_64_gcc11.2', hou_hash: '20_5' } fail-fast: false container: - image: aswf/ci-base:2023 + image: aswf/ci-base:2024 steps: - - name: Enable Node 16 - run: | - echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV - uses: actions/checkout@v3 # We bumped from the 2021 CI image to 2023 here to fix some OpenSSL issues # with the Houdini download script. In so doing we broke some of the caching @@ -153,10 +149,7 @@ jobs: runs-on: ${{ (github.repository_owner == 'AcademySoftwareFoundation' && 'ubuntu-20.04-8c-32g-300h') || 'ubuntu-latest' }} name: linux-extra:${{ matrix.config.name }} container: - # @note we specifically use clang15.0 (not clang15) here as the newest - # versions of the clang15.X containers have some issues with the GLFW - # installation - image: aswf/ci-openvdb:2023-clang15.0 + image: aswf/ci-openvdb:2024 env: CXX: clang++ strategy: @@ -168,19 +161,16 @@ jobs: - { name: 'sse', build: 'Release', components: 'core,python,bin,view,render,test', cmake: '-DOPENVDB_SIMD=SSE42' } - { name: 'avx', build: 'Release', components: 'core,python,bin,view,render,test', cmake: '-DOPENVDB_SIMD=AVX' } - { name: 'numpy', build: 'Release', components: 'core,python,bin,view,render,test', cmake: '-DUSE_NUMPY=ON -DOPENVDB_PYTHON_WRAP_ALL_GRID_TYPES=ON' } - - { name: 'asan', build: 'asan', components: 'core,test,axcore,axtest', cmake: '-DNANOVDB_USE_OPENVDB=ON -DOPENVDB_AX_STATIC=OFF -DOPENVDB_CORE_STATIC=OFF -DUSE_BLOSC=OFF' } # We never called blosc_destroy(), so disable blosc to silence these errors - - { name: 'ubsan', build: 'ubsan', components: 'core,test,axcore,axtest', cmake: '' } - - { name: 'c++20', build: 'Release', components: 'core,test,axcore,axtest', cmake: '-DCMAKE_CXX_STANDARD=20' } - - { name: 'conf', build: 'Release', components: 'core,python,bin,view,render,test,axcore,axtest', cmake: '-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON' } + - { name: 'asan', build: 'asan', components: 'core,test', cmake: '-DNANOVDB_USE_OPENVDB=ON -DOPENVDB_AX_STATIC=OFF -DOPENVDB_CORE_STATIC=OFF -DUSE_BLOSC=OFF' } # We never called blosc_destroy(), so disable blosc to silence these errors + - { name: 'ubsan', build: 'ubsan', components: 'core,test', cmake: '-DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations" ' } + - { name: 'c++20', build: 'Release', components: 'core,test', cmake: '-DCMAKE_CXX_STANDARD=20' } + - { name: 'conf', build: 'Release', components: 'core,python,bin,view,render,test', cmake: '-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON' } fail-fast: false steps: - - name: Enable Node 16 - run: | - echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV - uses: actions/checkout@v3 - - name: pybind11 + - name: nanobind #if: contains(container.image, '2023') == false - run: ./ci/install_pybind11.sh 2.10.0 + run: ./ci/install_nanobind.sh 2.0.0 - name: build run: > ./ci/build.sh -v @@ -206,14 +196,15 @@ jobs: # Disable the clang job for now. See https://github.com/actions/runner-images/issues/8659 # - { runson: ubuntu-latest, cxx: clang++, cmake: '' } # @todo gcc on macos - - { runson: macos-latest, cxx: '', cmake: '-D CMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm@15/bin/clang++' } + - { runson: macos-latest, cxx: '', cmake: '-DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm@15/bin/clang++ -DLLVM_DIR=/opt/homebrew/opt/llvm@15/lib/cmake/llvm' } fail-fast: false steps: - uses: actions/checkout@v3 - name: install_deps run: | if [ "$RUNNER_OS" == "Linux" ]; then - sudo apt-get -q install -y libboost-dev libboost-iostreams-dev libtbb-dev libblosc-dev llvm-dev libgtest-dev libcppunit-dev pybind11-dev + sudo apt-get -q install -y libboost-dev libboost-iostreams-dev libtbb-dev libblosc-dev llvm-dev libgtest-dev libcppunit-dev + ./ci/install_nanobind.sh 2.0.0 elif [ "$RUNNER_OS" == "macOS" ]; then ./ci/install_macos.sh 15 ./ci/install_tbb_macos.sh @@ -224,8 +215,8 @@ jobs: run: > ./ci/build.sh -v --build-type=Release - --components=\"core,axcore,python,bin,render,test,axtest,axbin\" - --cargs=\"-DCMAKE_CXX_STANDARD=20 -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install ${{ matrix.config.cmake }}\" + --components=\"core,axcore,python,bin,render,test,axbin\" + --cargs=\"-DCMAKE_CXX_STANDARD=20 -DOPENVDB_USE_DELAYED_LOADING=OFF -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install ${{ matrix.config.cmake }}\" - name: test run: cd build && ctest -V @@ -260,7 +251,8 @@ jobs: echo "$Env:VCPKG_INSTALLATION_ROOT\installed\${{ matrix.config.vc }}\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo "${{github.workspace}}\build\openvdb\openvdb\${{ matrix.config.build }}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: install - run: ./ci/install_windows.sh + shell: powershell + run: .\ci\install_windows.ps1 - name: build run: > ./ci/build.sh -v @@ -303,25 +295,14 @@ jobs: matrix: config: # Unified - - { image: '2022-clang14', cxx: 'clang++', build: 'Release', components: 'core,bin,axcore,axbin,axtest', cmake: '' } - - { image: '2022-clang14', cxx: 'g++', build: 'Release', components: 'core,bin,axcore,axbin,axtest', cmake: '' } - - { image: '2022-clang13', cxx: 'clang++', build: 'Release', components: 'core,bin,axcore,axbin,axtest', cmake: '' } - - { image: '2022-clang13', cxx: 'g++', build: 'Release', components: 'core,bin,axcore,axbin,axtest', cmake: '' } - # Standalone - - { image: '2021-clang10', cxx: 'clang++', build: 'Release', components: 'core', cmake: '-DDISABLE_DEPENDENCY_VERSION_CHECKS=ON' } - - { image: '2022-clang11', cxx: 'clang++', build: 'Debug', components: 'core', cmake: '' } - - { image: '2022-clang11', cxx: 'clang++', build: 'Release', components: 'core', cmake: '' } - - { image: '2022-clang11', cxx: 'g++', build: 'Release', components: 'core', cmake: '' } + - { image: '2023-clang15', cxx: 'clang++', build: 'Release', components: 'core,bin,axcore,axbin,axtest', cmake: '' } + - { image: '2023-clang15', cxx: 'g++', build: 'Release', components: 'core,bin,axcore,axbin,axtest', cmake: '' } fail-fast: false steps: - - name: Enable Node 16 - if: contains(matrix.config.image, '2021') || contains(matrix.config.image, '2022') - run: | - echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV - uses: actions/checkout@v3 - - name: pybind11 + - name: nanobind #f: contains(matrix.config.image, '2023') == false - run: ./ci/install_pybind11.sh 2.10.0 + run: ./ci/install_nanobind.sh 2.0.0 - name: build run: > ./ci/build.sh -v @@ -365,9 +346,7 @@ jobs: strategy: matrix: config: - - { cxx: 'clang++', build: 'Release', llvm: '14' } - { cxx: 'clang++', build: 'Release', llvm: '15' } - #- { cxx: 'clang++', build: 'Release', llvm: '16' } - not supported yet fail-fast: false steps: - uses: actions/checkout@v3 @@ -420,7 +399,8 @@ jobs: - name: llvm run: ./ci/install_llvm_windows.sh ${{ matrix.config.crt }} - name: install - run: ./ci/install_windows.sh + shell: powershell + run: .\ci\install_windows.ps1 - name: build run: > ./ci/build.sh -v @@ -482,9 +462,9 @@ jobs: - name: install_cuda shell: powershell run: .\ci\install_windows_cuda.ps1 - - name: install_deps - shell: bash - run: ./ci/install_windows.sh + - name: install + shell: powershell + run: .\ci\install_windows.ps1 - name: build shell: bash run: > @@ -522,9 +502,6 @@ jobs: blosc: ['1.18.0','1.19.0','1.20.0','1.21.0'] fail-fast: false steps: - - name: Enable Node 16 - run: | - echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV - uses: actions/checkout@v3 - name: install_blosc run: sudo ./ci/install_blosc.sh ${{ matrix.blosc }} diff --git a/CHANGES b/CHANGES index c0d27a1ce9..ca2d030a4e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,7 +1,210 @@ OpenVDB Version History ======================= -Version 11.0.1 - In development +Version 12.0.1 - In development + +Version 12.0.0 - October 31, 2024 + + OpenVDB is now licensed under the Apache 2.0 license, instead of the MPL 2.0 license. + + This version introduces ABI changes relative to older major releases, + so to preserve ABI compatibility it might be necessary to define the + macro OPENVDB_ABI_VERSION_NUMBER=N, where, for example, N is 10 for + Houdini 20.0 and 11 for Houdini 20.5. + + GCC 9 is no longer supported. + + OpenVDB: + New features: + - Added fillet() method in tools::LevelSetFilter to round off concave edges + to create smoother transition between surfaces. + + Improvements: + - Added openvdb::assertAbort to replace cassert and a + OPENVDB_ENABLE_ASSERTS cmake argument/compile define to toggle + assertions in OpenVDB code, independantly of NDEBUG. Asserts are + no longer enabled by default in when NDEBUG is absent (e.g. + Debug builds). + - Removed last traces of Boost when OPENVDB_USE_DELAYED_LOADING is OFF + [Reported by Brian McKinnon] + - RootNode code cleanup to eliminate redundant key conversion and + to create map values in-place. + - Add RootNode::deleteChildOrTile() to delete a child or tile of + the root node. + - ValueAccessors are now defined and created in the Tree class + instead of in the Grid class so that custom Tree implementations + may define and create their own ValueAccessors if desired. + - Added support for PDAL to vdb_tool [Contributed by Tom Matterson] + - LeafManager and NodeManager now use Index64 for leaf counts internally. + - Added RootNode::probeChild() const. + - Added RootNode::probeChild() and RootNode::probeConstChild(). + - Added RootNode::probe() and RootNode::probeConst() to query key presence, + child node, value and active state. + - Added InternalNode::probeChild() const. + - Added InternalNode::probeChild() and probeChildConst() with coord access + and optionally value and active state. + - Added InternalNode::probeChild() and probeChildConst() with index access + and optionally value and active state. + - Added InternalNode::isValueOff(), LeafNode::isValueOff(), + LeafNodeBool::isValueOff(), LeafNodeMask::isValueOff(). + - Added LeafNodeMask::probeValue(Index,val), LeafNodeBool::probeValue(Index,val). + - Added RootNode::getValueUnsafe(), RootNode::getChildUnsafe(), + RootNode::getConstChildUnsafe(). + - Added InternalNode::getValueUnsafe(), InternalNode::getChildUnsafe(), + InternalNode::getConstChildUnsafe(). + - Added InternalNode::setActiveStateUnsafe(), InternalNode::setValueOnlyUnsafe(), + InternalNode::setValueOnUnsafe(), InternalNode::setValueOffUnsafe(). + - Added InternalNode::setChildUnsafe(), InternalNode::resetChildUnsafe(), + InternalNode::stealChildUnsafe(), InternalNode::deleteChildUnsafe(). + - For LeafNode, LeafNodeBool and LeafNodeMask - added + LeafNode::getValueUnsafe(), LeafNode::setActiveStateunsafe(), + LeafNode::setValueOnlyUnsafe(), LeafNode::setValueOnUnsafe(), + LeafNode::setValueOffUnsafe(). + + ABI changes: + - Tree::leafCount(), Tree::unallocatedLeafCount(), + Tree::nonLeafCount() and Tree::nodeCount() now use Index64 in their + return types instead of Index32. + + API Changes: + - RootNode::tileCount(), RootNode::activeTileCount() and + RootNode::inactiveTileCount() are now public. + - RootNode::hasKey() and RootNode::coordToKey() are now public. + - RootNode::leafCount(), RootNode::nonLeafCount() and RootNode::nodeCount() + now use Index64 instead of Index32. The Index32 variant is deprecated. + - InternalNode::leafCount(), InternalNode::nonLeafCount() and + InternalNode::nodeCount() now use Index64 instead of Index32. The Index32 + variant is deprecated. + - LeafNode::leafCount() and LeafNode::nonLeafCount() now use Index64 instead + of Index32. The Index32 variant is deprecated. + + Bug Fixes: + - Fix potential crash reading corrupt .vdb files with invalid + blosc or zip chunks. + [Fix thanks to Matthias Ueberheide] + - Fix a bug in RootNode::setOrigin() where the origin was updated + before the error was thrown potentially leaving the root in an + invalid state. + - Fixed a thread sanitizer issue which could cause undefined + behaviour in VolumeToSpheres::fillWithSpheres + [Reported by Jérémie Dumas] + - Fixed an occurance of undefined behaviour in tools::activate + (though this would typically not have manifested with any + unintended behaviour) + + NanoVDB: + Bug fix: + - nanovdb::readGrids works with raw grid buffer. + + Improvements: + - Restructure files location and namespace to be more align with + OpenVDB. The namespaces touched by the restructuring are: io, + cuda, util, tools, and math. + - Add two scripts updateFiles.sh and updateFiles.py to update the + files using NanoVDB. The script updateFiles.py works on both + Windows and Linux. For a more complete list of changes, see API + Changes (details). + + - cuda::PointsToGrid supports target density. + - Add support for NanoVDB Grid of type UInt8. + - Add ability to use externally managed CUDA buffer. + - Add create methods for CudaDeviceBuffer and exceptions. + - Improve GridValidator logic, e.g. include check for grid count. + - Add operator > and >= for class Coord according to lexicographical order. + - Add toCodec to convert string to Codec enumeration type. + - Add nanovdb::strlen(). + - Add strncpy util. + - Add NANOVDB_DISABLE_SYNC_CUDA_MALLOC that maps cudaMallocAsync + and cudaFreeAsync to cudaMalloc and cudaFree respectively. + - Add guard to UINT64_C. + - Remove use of cudaMallocAsync in PointsToGrid.cuh. + - Align PNanoVDB blind metadata to NanoVDB. + + API Changes: + - Change mapToGridType to toGridType. + - Change mapToMagic to toMagic. + - Change CpuTimer.h to Timer.h. + + API Changes (details): + - These APIs are now under the math namespace: Ray, DDA, HDDA, + Vec3, Vec4, BBox, ZeroCrossing, TreeMarcher, PointTreeMarcher, + BoxStencil, CurvatureStencil, GradStencil, WenoStencil, AlignUp, + Min, Max, Abs, Clamp, Sqrt, Sign, Maximum, Delta, RoundDown, pi, + isApproxZero, Round, createSampler, SampleFromVoxels. + + - These APIs are now under the tools namespace: createNanoGrid, + StatsMode, createLevelSetSphere, createFogVolumeSphere, + createFogVolumeSphere, createFogVolumeSphere, + createFogVolumeTorus, createLevelSetBox, CreateNanoGrid, + updateGridStats, evalChecksum, validateChecksum, checkGrid, + Extrema. + - These APIs are now under the util namespace: is_floating_point, + findLowestOn, findHighestOn, Range, streq, strcpy, strcat, + empty, Split, invoke, forEach, reduce, prefixSum, is_same, + is_specialization, PtrAdd, PtrDiff. + + - Move nanovdb::build to nanovdb::tools::build. + - Rename nanovdb::BBoxR to nanovdb::Vec3dBBox. + - Rename nanovdb::BBox to nanovdb::Vec3dBbox. + - Move nanovdb::cudaCreateNodeManager to nanovdb::cuda::createNodeManager. + - Move and rename nanovdb::cudaVoxelsToGrid to nanovdb::cuda::voxelsToGrid. + - Move and rename nanovdb::cudaPointsToGrid to nanovdb::cuda::pointsToGrid. + - Move nanovdb::DitherLUT to nanovdb::math::DitherLUT. + - Move and rename nanovdb::PackedRGBA8 to nanovdb::math::Rgba8. + - Move nanovdb::Rgba8 to nanovdb::math::Rgba8. + - Move and rename nanovdb::CpuTimer to nanovdb::util::Timer. + - Move nanovdb::GpuTimer to nanovdb::util::cuda::Timer. + - Move and rename nanovdb::CountOn to nanovdb::util::countOn. + + - Move util/GridHandle.h to GridHandle.h. + - Move util/BuildGrid.h to tools/GridBuilder.h. + - Move util/GridBuilder.h to tools/GridBuilder.h. + - Move util/IO.h to io/IO.h. + - Move util/CSampleFromVoxels.h to math/CSampleFromVoxels.h. + - Move util/DitherLUT.h to math/DitherLUT.h. + - Move util/HDDA.h to math/HDDA.h. + - Move util/Ray.h to math/Ray.h. + - Move util/SampleFromVoxels.h to math/SampleFromVoxels.h. + - Move util/Stencils.h to nanovdb/math/Stencils.h. + - Move util/CreateNanoGrid.h to tools/CreateNanoGrid.h. + - Move and rename util/Primitives.h to tools/CreatePrimitives.h. + - Move util/GridChecksum.h to tools/GridChecksum.h. + - Move util/GridStats.h to tools/GridStats.h. + - Move util/GridChecksum.h to tools/GridChecksum.h. + - Move util/GridValidator.h to tools/GridValidator.h. + - Move util/NanoToOpenVDB.h to tools/NanoToOpenVDB.h. + - Move util/cuda/CudaGridChecksum.cuh to tools/cuda/CudaGridChecksum.cuh. + - Move util/cuda/CudaGridStats.cuh to tools/cuda/CudaGridStats.cuh. + - Move util/cuda/CudaGridValidator.cuh to tools/cuda/CudaGridValidator.cuh. + - Move util/cuda/CudaIndexToGrid.cuh to tools/cuda/CudaIndexToGrid.cuh. + - Move and rename util/cuda/CudaPointsToGrid.cuh to tools/cuda/PointsToGrid.cuh. + - Move util/cuda/CudaSignedFloodFill.cuh to tools/cuda/CudaSignedFloodFill.cuh. + - Move and rename util/cuda/CudaDeviceBuffer.h to cuda/DeviceBuffer.h. + - Move and rename util/cuda/CudaGridHandle.cuh to cuda/GridHandle.cuh. + - Move and rename util/cuda/CudaUtils.h to util/cuda/Util.h. + - Move and consolidate util/cuda/GpuTimer.h to util/cuda/Timer.h. + + Houdini: + - When OPENVDB_ENABLE_RPATH is ON, the location of + libopenvdb_houdini is now added to the rpath of all Houdini + dsos. + + Python: + - OpenVDB Python bindings are now implemented using nanobind + instead of pybind11 + - The OpenVDB Python module has been changed from pyopenvdb to openvdb + - Added Python bindings for NanoVDB + + Build: + - Fixed an issue with OpenVDB AX's CMake on Windows where the + static and shared library targets would have the same name + [Reported by Nicholas Yue] + - USE_EXPLICIT_INSTANTIATION is now disabled on Windows by default + due to OOM linker issues. + - Jemalloc is now the preferred allocator of choice on all + platforms when CONCURRENT_MALLOC is set to Auto. + - Fixed an issue with the Blosc CMake FindPackage for the OpenVDB + Windows static library. Version 11.0.0 - November 1, 2023 @@ -399,7 +602,6 @@ Version 9.1.0 - June 9, 2022 Positional arguments as input files are deprecated. - Added tools::minMax() which supports multithreaded evaluation of active minimum and maximum values. Grid::evalMinMax() has been deprecated. - [Contributed by Greg Hurst] - Significant performance improvements to AX point kernels, primarily due to providing AX access to attribute buffers for superior code generation. - vdb_print now prints both the in-core memory and total memory usage for diff --git a/CMakeLists.txt b/CMakeLists.txt index ea389222ca..e17ee726b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -42,7 +42,7 @@ # note: cmake_minimum_required must be called before project commands to # ensure policy scope is set up correctly -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) # CMP0091 allows for MSVC ABI targetting via CMAKE_MSVC_RUNTIME_LIBRARY # from CMake 3.15 and above. Must come before project(). @@ -52,7 +52,7 @@ endif() ###### Version -set(OpenVDB_MAJOR_VERSION 11) +set(OpenVDB_MAJOR_VERSION 12) set(OpenVDB_MINOR_VERSION 0) set(OpenVDB_PATCH_VERSION 1) set(OpenVDB_VERSION "${OpenVDB_MAJOR_VERSION}.${OpenVDB_MINOR_VERSION}.${OpenVDB_PATCH_VERSION}") @@ -285,6 +285,30 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") # Add cmake modules to installation command +if(SKBUILD) + set(OPENVDB_INSTALL_BINDIR openvdb/${CMAKE_INSTALL_BINDIR}) + set(OPENVDB_INSTALL_LIBDIR openvdb/${CMAKE_INSTALL_LIBDIR}) + set(OPENVDB_INSTALL_INCLUDEDIR openvdb/${CMAKE_INSTALL_INCLUDEDIR}) + + if(OPENVDB_BUILD_NANOVDB) + set(NANOVDB_INSTALL_BINDIR nanovdb/${CMAKE_INSTALL_BINDIR}) + set(NANOVDB_INSTALL_LIBDIR nanovdb/${CMAKE_INSTALL_LIBDIR}) + set(NANOVDB_INSTALL_INCLUDEDIR nanovdb/${CMAKE_INSTALL_INCLUDEDIR}) + set(NANOVDB_INSTALL_DOCDIR nanovdb/${CMAKE_INSTALL_DOCDIR}) + endif() +else() + set(OPENVDB_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR}) + set(OPENVDB_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}) + set(OPENVDB_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}) + + if(OPENVDB_BUILD_NANOVDB) + set(NANOVDB_INSTALL_BINDIR ${CMAKE_INSTALL_BINDIR}) + set(NANOVDB_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR}) + set(NANOVDB_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}) + set(NANOVDB_INSTALL_DOCDIR ${CMAKE_INSTALL_DOCDIR}) + endif() +endif() + if(OPENVDB_INSTALL_CMAKE_MODULES) set(OPENVDB_CMAKE_MODULES cmake/FindBlosc.cmake @@ -298,7 +322,7 @@ if(OPENVDB_INSTALL_CMAKE_MODULES) cmake/OpenVDBMayaSetup.cmake cmake/OpenVDBUtils.cmake ) - install(FILES ${OPENVDB_CMAKE_MODULES} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/OpenVDB) + install(FILES ${OPENVDB_CMAKE_MODULES} DESTINATION ${OPENVDB_INSTALL_LIBDIR}/cmake/OpenVDB) endif() # Configure component dependencies by loading the Houdini/Maya setup @@ -451,6 +475,33 @@ if(NOT OPENVDB_BUILD_NANOVDB AND find_package(OpenVDB REQUIRED COMPONENTS nanovdb) endif() +# Locate Python and nanobind if necessary +if(OPENVDB_BUILD_PYTHON_MODULE OR (OPENVDB_BUILD_NANOVDB AND NANOVDB_BUILD_PYTHON_MODULE)) + + # Call find_package(Python ...) + find_package(Python ${MINIMUM_PYTHON_VERSION} REQUIRED COMPONENTS Development Interpreter) + find_package(nanobind ${MINIMUM_NANOBIND_VERSION} REQUIRED) + + if(OPENVDB_FUTURE_DEPRECATION AND FUTURE_MINIMUM_PYTHON_VERSION) + if(Python_VERSION VERSION_LESS ${FUTURE_MINIMUM_PYTHON_VERSION}) + message(DEPRECATION "Support for Python versions < ${FUTURE_MINIMUM_GLFW_VERSION} " + "is deprecated and will be removed.") + endif() + endif() + + if(NOT DEFINED VDB_PYTHON_INSTALL_DIRECTORY) + if(DEFINED Python_SITELIB) + get_filename_component(Python_PACKAGES_DIR ${Python_SITELIB} NAME) + else() + set(Python_PACKAGES_DIR "site-packages") + endif() + set(VDB_PYTHON_INSTALL_DIRECTORY + ${CMAKE_INSTALL_LIBDIR}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/${Python_PACKAGES_DIR} + CACHE STRING "The directory to install the openvdb and nanovdb Python modules." + ) + endif() +endif() + # Validate the OpenVDB ABI Version. If OpenVDB_ABI is not set, we're either building # the core library OR the ABI hasn't been deduced from a VDB installation. Use the diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e0838e682c..790885bf80 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,7 +22,7 @@ open source software best practice policies of the Linux Foundation. #### License -OpenVDB is licensed under the [Mozilla Public License, version 2.0](LICENSE.md) +OpenVDB is licensed under the [Apache License, version 2.0](LICENSE.md) license. Contributions to OpenVDB should abide by that standard license. @@ -54,7 +54,7 @@ Every commit must be signed off. That is, every commit log message must include a “`Signed-off-by`” line (generated, for example, with “`git commit --signoff`”), indicating that the committer wrote the code and has the right to release it under the -[Mozilla Public License, version 2.0](LICENSE.md) +[Apache License, version 2.0](LICENSE.md) license. See the [TAC documentation on contribution sign off](https://github.com/AcademySoftwareFoundation/tac/blob/master/process/contributing.md#contribution-sign-off) for more information on this requirement. ## Maintainer diff --git a/LICENSE b/LICENSE index a612ad9813..d9a10c0d8e 100644 --- a/LICENSE +++ b/LICENSE @@ -1,373 +1,176 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/README.md b/README.md index 32b95c3b20..2eb65de52d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ [Discussion Forum](https://github.com/AcademySoftwareFoundation/openvdb/discussions) | [Documentation](https://www.openvdb.org/documentation/doxygen) | [Releases](https://github.com/AcademySoftwareFoundation/openvdb/releases) | -[License](https://www.mozilla.org/MPL/2.0) | +[License](https://www.apache.org/licenses/LICENSE-2.0) | [Slack](https://slack.aswf.io/) OpenVDB is an open source C++ library comprising a novel hierarchical data @@ -28,14 +28,14 @@ generally less stable than the [production releases](https://github.com/AcademyS ### License -OpenVDB is released under the [Mozilla Public License Version 2.0](https://www.mozilla.org/MPL/2.0/), +OpenVDB is released under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0), which is a free, open source software license developed and maintained by the -Mozilla Foundation. +Apache Software Foundation. The trademarks of any contributor to this project may not be used in association with the project without the contributor's express permission. -NOTE: OpenVDB is in the process of changing its license from [Mozilla Public License Version 2.0](https://www.mozilla.org/MPL/2.0/) to [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0)! Please see the file RE-LICENSE_NOTE.txt for more details. +NOTE: OpenVDB has completed re-licensing from [Mozilla Public License Version 2.0](https://www.mozilla.org/MPL/2.0/) to [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0). Please see the file RE-LICENSE_NOTE.txt for more details. ### Contributing diff --git a/ci/build.sh b/ci/build.sh index d2e8e96603..110455c881 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -184,11 +184,12 @@ set -x # - always enabled the python tests with OPENVDB_BUILD_PYTHON_UNITTESTS if the python module is in use, # regardless of the 'test' component being enabled or not (see the OPENVDB_BUILD_PYTHON_UNITTESTS option). cmake \ - -DOPENVDB_USE_DEPRECATED_ABI_9=ON \ -DOPENVDB_USE_DEPRECATED_ABI_10=ON \ + -DOPENVDB_USE_DEPRECATED_ABI_11=ON \ -DOPENVDB_BUILD_VDB_PRINT=ON \ -DOPENVDB_BUILD_VDB_LOD=ON \ -DOPENVDB_BUILD_VDB_TOOL=ON \ + -DOPENVDB_BUILD_VDB_TOOL_UNITTESTS=ON \ -DOPENVDB_TOOL_USE_NANO=OFF \ -DOPENVDB_BUILD_PYTHON_UNITTESTS=ON \ -DMSVC_MP_THREAD_COUNT=${PARMS[-j]} \ diff --git a/ci/download_houdini.py b/ci/download_houdini.py index 096e389133..5467a084dd 100755 --- a/ci/download_houdini.py +++ b/ci/download_houdini.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 # # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # # Python script to download the latest Houdini builds # using the SideFX download API: diff --git a/ci/install_cppunit.sh b/ci/install_cppunit.sh new file mode 100755 index 0000000000..7f64238e8a --- /dev/null +++ b/ci/install_cppunit.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +set -ex +CURL_VERSION="$1" + +wget -O cppunit.tar.gz https://dev-www.libreoffice.org/src/cppunit-${CURL_VERSION}.tar.gz + +tar -xzf cppunit.tar.gz + +cd cppunit-${CURL_VERSION} + +./configure + +make -j8 +make install diff --git a/ci/install_glfw.sh b/ci/install_glfw.sh new file mode 100755 index 0000000000..33108657f4 --- /dev/null +++ b/ci/install_glfw.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -ex +GLFW_VERSION="$1" + +git clone https://github.com/glfw/glfw.git +cd glfw + +if [ "$GLFW_VERSION" != "latest" ]; then + git checkout tags/${GLFW_VERSION} -b ${GLFW_VERSION} +fi + +mkdir build +cd build + +cmake .. + +make -j8 +make install diff --git a/ci/install_gtest.sh b/ci/install_gtest.sh new file mode 100755 index 0000000000..71d7fbd7bb --- /dev/null +++ b/ci/install_gtest.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -ex + +GTEST_VERSION="$1" + + +git clone https://github.com/google/googletest.git -b v${GTEST_VERSION} +cd googletest +mkdir build +cd build +cmake .. + +make -j$(nproc) + +sudo make install diff --git a/ci/install_llvm_windows.sh b/ci/install_llvm_windows.sh index 642013d46a..c174c50296 100644 --- a/ci/install_llvm_windows.sh +++ b/ci/install_llvm_windows.sh @@ -4,7 +4,7 @@ set -ex LLVM_CRT="$1" -git clone -b llvmorg-12.0.0 --depth 1 https://github.com/llvm/llvm-project.git llvm +git clone -b llvmorg-14.0.0 --depth 1 https://github.com/llvm/llvm-project.git llvm cd llvm mkdir .build diff --git a/ci/install_macos.sh b/ci/install_macos.sh index 0d7899687d..80b71d4864 100755 --- a/ci/install_macos.sh +++ b/ci/install_macos.sh @@ -18,12 +18,13 @@ brew install glfw brew install googletest brew install jq # for trivial parsing of brew json brew install openexr -brew install pybind11 # also installs the dependent python version +brew install nanobind # also installs the dependent python version +brew install robin-map # required for nanobind brew install zlib brew install jemalloc -# Alias python version installed by pybind11 to path -py_version=$(brew info pybind11 --json | \ +# Alias python version installed by nanobind to path +py_version=$(brew info nanobind --json | \ jq -cr '.[].dependencies[] | select(. | startswith("python"))') echo "Using python $py_version" # export for subsequent action steps (note, not exported for this env) diff --git a/ci/install_pybind11.sh b/ci/install_nanobind.sh similarity index 75% rename from ci/install_pybind11.sh rename to ci/install_nanobind.sh index ccf16aaa67..50b6766b81 100755 --- a/ci/install_pybind11.sh +++ b/ci/install_nanobind.sh @@ -9,8 +9,8 @@ if [ ! -z "${INSTALL_ROOT}" ]; then CMAKE_EXTRA+=("-DCMAKE_INSTALL_PREFIX=${INSTALL_ROOT}") fi -git clone https://github.com/pybind/pybind11.git -cd pybind11 +git clone --recurse-submodules https://github.com/wjakob/nanobind.git +cd nanobind if [ "$PYBIND11_VERSION" != "latest" ]; then git checkout tags/v${PYBIND11_VERSION} -b v${PYBIND11_VERSION} @@ -20,9 +20,9 @@ mkdir build cd build cmake \ - -DPYBIND11_TEST=OFF \ + -DNB_TEST=OFF \ "${CMAKE_EXTRA[@]}" \ .. make -j8 -make install +sudo make install diff --git a/ci/install_windows.ps1 b/ci/install_windows.ps1 new file mode 100644 index 0000000000..6054cb96bf --- /dev/null +++ b/ci/install_windows.ps1 @@ -0,0 +1,40 @@ +# Enable verbose and stop on error +$ErrorActionPreference = "Stop" +$VerbosePreference = "Continue" + +# Required dependencies +$vcpkgPackages = @( + "zlib", + "libpng", + "openexr", + "tbb", + "gtest", + "cppunit", + "blosc", + "glfw3", + "glew", + "python3", + "jemalloc", + "boost-iostreams", + "boost-interprocess", + "boost-algorithm", + "nanobind" +) + +# Update vcpkg +vcpkg update + +# Allow the vcpkg command to fail once so we can retry with the latest +try { + vcpkg install $vcpkgPackages +} catch { + Write-Host "vcpkg install failed, retrying with latest ports..." + # Retry the installation with updated ports + Push-Location $env:VCPKG_INSTALLATION_ROOT + git pull + Pop-Location + vcpkg update + vcpkg install $vcpkgPackages +} + +Write-Host "vcpkg install completed successfully" diff --git a/ci/install_windows.sh b/ci/install_windows.sh deleted file mode 100755 index 9620ee42a7..0000000000 --- a/ci/install_windows.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -set -x -set -e - -# Required dependencies -VCPKG_INSTALL_CMD="vcpkg install - zlib - libpng - openexr - tbb - gtest - cppunit - blosc - glfw3 - glew - python3 - jemalloc - boost-iostreams - boost-interprocess - boost-algorithm - pybind11 - --clean-after-build" - -# Update vcpkg -vcpkg update - -# Allow the vcpkg command to fail once so we can retry with the latest -set +e -$VCPKG_INSTALL_CMD -STATUS=$? - -# Subsequent commands cannot fail -set -x - -if [ $STATUS -ne 0 ]; then - # Try once more with latest ports - echo "vcpkg install failed, retrying with latest ports..." - cd $VCPKG_INSTALLATION_ROOT && git pull && cd- - vcpkg update - $VCPKG_INSTALL_CMD -fi - -echo "vcpkg install completed successfully" diff --git a/ci/test_install.sh b/ci/test_install.sh index be6a477dd8..da4bc0f004 100755 --- a/ci/test_install.sh +++ b/ci/test_install.sh @@ -8,7 +8,7 @@ set -e # the expected VDB installation cmakelists=" -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(TestInstall LANGUAGES CXX) find_package(OpenVDB REQUIRED COMPONENTS openvdb) add_executable(test_vdb_print \"../openvdb_cmd/vdb_print/main.cc\") diff --git a/cmake/FindBlosc.cmake b/cmake/FindBlosc.cmake index 9b873cfb63..158050e216 100644 --- a/cmake/FindBlosc.cmake +++ b/cmake/FindBlosc.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[.rst: @@ -88,7 +88,7 @@ may be provided to tell this module where to look. #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) include(GNUInstallDirs) mark_as_advanced( diff --git a/cmake/FindCppUnit.cmake b/cmake/FindCppUnit.cmake index 18ef1025f4..34bdced9ed 100644 --- a/cmake/FindCppUnit.cmake +++ b/cmake/FindCppUnit.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[.rst: @@ -83,7 +83,7 @@ may be provided to tell this module where to look. #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) include(GNUInstallDirs) diff --git a/cmake/FindJemalloc.cmake b/cmake/FindJemalloc.cmake index f992aa13f6..9b2e14555c 100644 --- a/cmake/FindJemalloc.cmake +++ b/cmake/FindJemalloc.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[.rst: @@ -64,7 +64,7 @@ may be provided to tell this module where to look. #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) include(GNUInstallDirs) diff --git a/cmake/FindLog4cplus.cmake b/cmake/FindLog4cplus.cmake index 3a9deab904..7e3a584806 100644 --- a/cmake/FindLog4cplus.cmake +++ b/cmake/FindLog4cplus.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[.rst: @@ -87,7 +87,7 @@ may be provided to tell this module where to look. #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) include(GNUInstallDirs) diff --git a/cmake/FindOpenEXR.cmake b/cmake/FindOpenEXR.cmake index 863e00c781..a8aea21d01 100644 --- a/cmake/FindOpenEXR.cmake +++ b/cmake/FindOpenEXR.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[.rst: @@ -93,7 +93,7 @@ may be provided to tell this module where to look. #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) include(GNUInstallDirs) diff --git a/cmake/FindOpenVDB.cmake b/cmake/FindOpenVDB.cmake index c4213c853a..33b08388c0 100644 --- a/cmake/FindOpenVDB.cmake +++ b/cmake/FindOpenVDB.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[.rst: @@ -109,7 +109,7 @@ may be provided to tell this module where to look. #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) include(GNUInstallDirs) @@ -334,10 +334,8 @@ set(_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) set(OPENVDB_PYTHON_PATH_SUFFIXES lib64/python - lib64/python2.7 lib64/python3 lib/python - lib/python2.7 lib/python3 ) @@ -491,37 +489,11 @@ endif() # Add standard dependencies find_package(TBB REQUIRED COMPONENTS tbb) -find_package(Boost REQUIRED COMPONENTS iostreams) # Add deps for pyopenvdb -# @todo track for numpy if(pyopenvdb IN_LIST OpenVDB_FIND_COMPONENTS) find_package(Python REQUIRED) - - # Boost python handling - try and find both python and pythonXx (version suffixed). - # Prioritize the version suffixed library, failing if neither exist. - - find_package(Boost ${MINIMUM_BOOST_VERSION} - QUIET COMPONENTS python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR} - ) - - if(TARGET Boost::python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) - set(BOOST_PYTHON_LIB "python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") - message(STATUS "Found boost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") - else() - find_package(Boost ${MINIMUM_BOOST_VERSION} QUIET COMPONENTS python) - if(TARGET Boost::python) - set(BOOST_PYTHON_LIB "python") - message(STATUS "Found non-suffixed boost_python, assuming to be python version " - "\"${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}\" compatible" - ) - else() - message(FATAL_ERROR "Unable to find boost_python or " - "boost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}." - ) - endif() - endif() endif() # Add deps for openvdb_ax @@ -656,6 +628,10 @@ if(OpenVDB_USES_IMATH_HALF) find_package(Imath REQUIRED CONFIG) endif() +if(OpenVDB_USES_DELAYED_LOADING) + find_package(Boost REQUIRED COMPONENTS iostreams) +endif() + if(UNIX) find_package(Threads REQUIRED) endif() @@ -766,7 +742,7 @@ if(OpenVDB_pyopenvdb_LIBRARY) set_target_properties(OpenVDB::pyopenvdb PROPERTIES IMPORTED_LOCATION "${OpenVDB_pyopenvdb_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${OpenVDB_pyopenvdb_INCLUDE_DIR};${PYTHON_INCLUDE_DIR}" - INTERFACE_LINK_LIBRARIES "OpenVDB::openvdb;Boost::${BOOST_PYTHON_LIB};${PYTHON_LIBRARIES}" + INTERFACE_LINK_LIBRARIES "OpenVDB::openvdb;${PYTHON_LIBRARIES}" INTERFACE_COMPILE_FEATURES cxx_std_17 ) endif() diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake index 7c85bb7d9a..eda06bb754 100644 --- a/cmake/FindTBB.cmake +++ b/cmake/FindTBB.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[.rst: @@ -93,7 +93,7 @@ may be provided to tell this module where to look. #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) include(GNUInstallDirs) diff --git a/cmake/OpenVDBGLFW3Setup.cmake b/cmake/OpenVDBGLFW3Setup.cmake index c0fac4c716..26980fc6ff 100644 --- a/cmake/OpenVDBGLFW3Setup.cmake +++ b/cmake/OpenVDBGLFW3Setup.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[.rst: @@ -47,7 +47,7 @@ The following variables may be provided to tell this module where to look. # Find the glfw3 installation and use glfw's CMake to initialize # the glfw lib -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) set(_FIND_GLFW3_ADDITIONAL_OPTIONS "") if(DISABLE_CMAKE_SEARCH_PATHS) @@ -109,18 +109,6 @@ endif() set(glfw3_FIND_VERSION ${MINIMUM_GLFW_VERSION}) find_package(glfw3 ${MINIMUM_GLFW_VERSION} REQUIRED) -# We only use find_package_handle_standard_args to verify and print -# appropriate messages. This now explicitly errors in 3.19... -# @todo Improve this entire GLFW3 search -# https://gitlab.kitware.com/cmake/cmake/-/issues/21505 -if(${CMAKE_VERSION} VERSION_LESS 3.19) - find_package(PackageHandleStandardArgs) - find_package_handle_standard_args(glfw3 - REQUIRED_VARS glfw3_DIR glfw3_FOUND - VERSION_VAR glfw3_VERSION - ) -endif() - if(OPENVDB_FUTURE_DEPRECATION AND FUTURE_MINIMUM_GLFW_VERSION) if(glfw3_VERSION VERSION_LESS ${FUTURE_MINIMUM_GLFW_VERSION}) message(DEPRECATION "Support for GLFW versions < ${FUTURE_MINIMUM_GLFW_VERSION} " diff --git a/cmake/OpenVDBHoudiniSetup.cmake b/cmake/OpenVDBHoudiniSetup.cmake index 88325c931f..a4ab24f2e0 100644 --- a/cmake/OpenVDBHoudiniSetup.cmake +++ b/cmake/OpenVDBHoudiniSetup.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[.rst: @@ -73,7 +73,7 @@ may be provided to tell this module where to look. # Find the Houdini installation and use Houdini's CMake to initialize # the Houdini lib -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) # Include utility functions for version information include(${CMAKE_CURRENT_LIST_DIR}/OpenVDBUtils.cmake) diff --git a/cmake/OpenVDBMayaSetup.cmake b/cmake/OpenVDBMayaSetup.cmake index a4797601c1..4ff3166a2e 100644 --- a/cmake/OpenVDBMayaSetup.cmake +++ b/cmake/OpenVDBMayaSetup.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[.rst: @@ -51,7 +51,7 @@ variables may be provided to tell this module where to look. # Find the Maya installation and use Maya's CMake to initialize # the Maya lib -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) set(_FIND_MAYA_ADDITIONAL_OPTIONS "") diff --git a/cmake/OpenVDBUtils.cmake b/cmake/OpenVDBUtils.cmake index e629e996e8..b2f07c7549 100644 --- a/cmake/OpenVDBUtils.cmake +++ b/cmake/OpenVDBUtils.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[.rst: @@ -57,7 +57,7 @@ The following functions are provided: #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) function(OPENVDB_GET_VERSION_DEFINE HEADER KEY VALUE) diff --git a/cmake/Uninstall.cmake b/cmake/Uninstall.cmake index 5c67af77bb..e95c4c5229 100644 --- a/cmake/Uninstall.cmake +++ b/cmake/Uninstall.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[.rst: @@ -16,7 +16,7 @@ existing from a previous run of cmake. #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) set(MANIFEST "${CMAKE_CURRENT_BINARY_DIR}/install_manifest.txt") diff --git a/cmake/config/OpenVDBCXX.cmake b/cmake/config/OpenVDBCXX.cmake index 36490afe5a..3586732bdb 100644 --- a/cmake/config/OpenVDBCXX.cmake +++ b/cmake/config/OpenVDBCXX.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) ############################################################################### @@ -184,20 +184,23 @@ if(OPENVDB_CXX_STRICT) add_compile_options("$<$,$,9.3.0>>:-Wimplicit-fallthrough>") # Only check global constructors for libraries (we should really check for # executables too but gtest relies on these types of constructors for its - # framework). - add_compile_options("$<$,EXECUTABLE>>,$>:-Wglobal-constructors>") + # framework). nanobind also incorporates these constructors so skip it as well. + add_compile_options("$<$,EXECUTABLE>,$,nanobind-static>>>,$>:-Wglobal-constructors>") add_compile_options("$<$:-Wno-sign-conversion>") # GNU add_compile_options("$<$:-Werror>") add_compile_options("$<$:-Wall>") add_compile_options("$<$:-Wextra>") - add_compile_options("$<$:-pedantic>") add_compile_options("$<$:-Wcast-align>") - add_compile_options("$<$:-Wcast-qual>") - add_compile_options("$<$:-Wconversion>") add_compile_options("$<$:-Wdisabled-optimization>") add_compile_options("$<$:-Woverloaded-virtual>") add_compile_options("$<$:-Wnon-virtual-dtor>") + # Disable select warnings for the nanobind static library + add_compile_options("$<$,nanobind-static>,$,openvdb_python>,$,nanovdb_python>>>,$>:-pedantic>") + add_compile_options("$<$,nanobind-static>,$,openvdb_python>,$,nanovdb_python>>>,$>:-Wcast-qual>") + add_compile_options("$<$,nanobind-static>,$,openvdb_python>,$,nanovdb_python>>>,$>:-Wconversion>") + add_compile_options("$<$,nanobind-static>,$,openvdb_python>,$,nanovdb_python>>,$>:-Wno-unused-variable>") + add_compile_options("$<$,nanobind-static>,$,openvdb_python>,$,nanovdb_python>>,$>:-Wno-unused-but-set-parameter>") else() # NO OPENVDB_CXX_STRICT, suppress some warnings if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") diff --git a/cmake/config/OpenVDBVersions.cmake b/cmake/config/OpenVDBVersions.cmake index f956b8fdbe..0b8dd5ef6a 100644 --- a/cmake/config/OpenVDBVersions.cmake +++ b/cmake/config/OpenVDBVersions.cmake @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -8,7 +8,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) ############################################################################### @@ -34,24 +34,26 @@ if(NOT DISABLE_DEPENDENCY_VERSION_CHECKS) # What's usually important is that the version of libstdc++ and glibc in use # matches. Compilers other than GCC should provide options to ensure this # targetting e.g. --gcc-toolchain and -fgnuc-version with Clang. - set(MINIMUM_GCC_VERSION 9.3.1) + set(MINIMUM_GCC_VERSION 11.2.1) set(MINIMUM_CLANG_VERSION 5.0) set(MINIMUM_ICC_VERSION 19) - set(MINIMUM_MSVC_VERSION 19.28) # 1928 (Visual Studio 2019 Version 16.8 + 16.9) + set(MINIMUM_MSVC_VERSION 19.30) # 1928 (Visual Studio 2019 Version 16.8 + 16.9) - # Should be 1.76 for VFX 22, but only version in apt is 1.73 - set(MINIMUM_BOOST_VERSION 1.73) - set(MINIMUM_PYBIND_VERSION 2.9.1) + set(MINIMUM_BOOST_VERSION 1.80) + # Nanobind does not store the version in the CMake config file in 2.0.0. + # This issue was fixed in 2.1.0 so next time we bump the minimum version, + # we can define this. + #set(MINIMUM_NANOBIND_VERSION 2.0.0) set(MINIMUM_IMATH_VERSION 3.1) set(MINIMUM_OPENEXR_VERSION 3.1) set(MINIMUM_ZLIB_VERSION 1.2.7) set(MINIMUM_TBB_VERSION 2020.3) - set(MINIMUM_LLVM_VERSION 10.0.0) + set(MINIMUM_LLVM_VERSION 13.0.0) set(MINIMUM_BLOSC_VERSION 1.17.0) set(MINIMUM_GLFW_VERSION 3.1) - set(MINIMUM_PYTHON_VERSION 3.9.1) - set(MINIMUM_NUMPY_VERSION 1.20.0) + set(MINIMUM_PYTHON_VERSION 3.10) + set(MINIMUM_NUMPY_VERSION 1.23.0) set(MINIMUM_GOOGLETEST_VERSION 1.10) set(MINIMUM_LOG4CPLUS_VERSION 1.1.2) @@ -66,20 +68,21 @@ endif() # @note At the time of writing, any variables that are commented out don't # have target transitional versions. -set(FUTURE_MINIMUM_GCC_VERSION 11.2.1) -set(FUTURE_MINIMUM_MSVC_VERSION 19.30) # 1930 (Visual Studio 2022) +# set(FUTURE_MINIMUM_GCC_VERSION 11.2.1) +# set(FUTURE_MINIMUM_MSVC_VERSION 19.30) # set(FUTURE_MINIMUM_ICC_VERSION 19) # set(FUTURE_MINIMUM_CXX_STANDARD 20) -set(FUTURE_MINIMUM_CMAKE_VERSION 3.20) -# set(FUTURE_MINIMUM_OPENEXR_VERSION 3.1) -set(FUTURE_MINIMUM_BOOST_VERSION 1.80) +set(FUTURE_MINIMUM_CMAKE_VERSION 3.24) +set(FUTURE_MINIMUM_OPENEXR_VERSION 3.2) +set(FUTURE_MINIMUM_BOOST_VERSION 1.82) set(FUTURE_MINIMUM_GLFW_VERSION 3.3) set(FUTURE_MINIMUM_LOG4CPLUS_VERSION 2.0) +# set(FUTURE_MINIMUM_NANOBIND_VERSION 2.1.0) # set(FUTURE_MINIMUM_BLOSC_VERSION 1.17.0) # set(FUTURE_MINIMUM_TBB_VERSION 2020.3) -set(FUTURE_MINIMUM_PYTHON_VERSION 3.10) -set(FUTURE_MINIMUM_NUMPY_VERSION 1.23.0) +set(FUTURE_MINIMUM_PYTHON_VERSION 3.11) +set(FUTURE_MINIMUM_NUMPY_VERSION 1.26.0) # set(FUTURE_MINIMUM_HOUDINI_VERSION 20.0) -set(FUTURE_MINIMUM_LLVM_VERSION 13.0.0) +set(FUTURE_MINIMUM_LLVM_VERSION 15.0.0) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 012c049a84..67e5f259e5 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(OpenVDBDocs LANGUAGES NONE) include(GNUInstallDirs) diff --git a/doc/build.txt b/doc/build.txt index 3dbfb48d57..c04e870aa3 100644 --- a/doc/build.txt +++ b/doc/build.txt @@ -238,10 +238,8 @@ it's a good idea to read the above section on DCC | Supported Version | OpenVDB ABI | -------- | ----------------- | ----------- | -Houdini | 19.5 | 9 | Houdini | 20.0 | 10 | -Maya | 2018 | Any | -Maya | 2019 | Any | +Houdini | 20.5 | 11 | @subsection buildBuildHou Building Against Houdini @@ -263,11 +261,11 @@ CppUnit | A unit testing framework module for C++ GLFW | Simple API for OpenGL development | OpenVDB View | Doxygen | Documentation generation from C++ | Documentation | Log4cplus | An optional dependency for improved OpenVDB Logging | Optional (All) | -PyBind11 | C++/python bindings | Optional (Python) | +nanobind | C++/python bindings | Optional (Python) | NumPy | Scientific computing with Python | Optional (Python) | LLVM | Target-independent code generation | OpenVDB AX | -At a minimum, boost, a matching C++17 compiler and CMake will be required. See +At a minimum a matching C++17 compiler and CMake will be required. See the full [dependency list](@ref dependencies) for help with downloading and installing the above software. Note that as Blosc and ZLib are provided as part of the Houdini installation `USE_BLOSC` and `USE_ZLIB` should be left `ON`. @@ -357,7 +355,7 @@ Doxygen | Documentation generation from C++ OpenEXR | EXR serialization support | OpenVDB Render | Imath | Used half precision floating points and EXR serialization support | Optional (All) | Log4cplus | An optional dependency for improved OpenVDB Logging | Optional (All) | -PyBind11 | C++/python bindings | Optional (Python) | +nanobind | C++/python bindings | Optional (Python) | NumPy | Scientific computing with Python | Optional (Python) | LLVM | Target-independent code generation | OpenVDB AX | @@ -514,7 +512,7 @@ You can add the below CMake snippet to your main `CMakeLists.txt` to bring in OpenVDB as a dependency: @code{.cmake} -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) list(APPEND CMAKE_MODULE_PATH "/location/of/openvdb/install/lib/cmake/OpenVDB") find_package(OpenVDB REQUIRED) target_link_libraries(myapp OpenVDB::openvdb) @@ -607,13 +605,6 @@ OpenVDB uses [imported targets](https://cmake.org/cmake/help/latest/command/add_ for all its dependencies. For imported Boost compatibility, the following versions of CMake are required: - - Boost 1.73 requires CMake 3.17.2 or newer. - - Boost 1.74 requires CMake 3.19 or newer. - - Boost 1.75 requires CMake 3.19.5 or newer. - - Boost 1.76 requires CMake 3.20.3 or newer. - - Boost 1.77 requires CMake 3.21.3 or newer. - - Boost 1.78 requires CMake 3.22.2 or newer. - - Boost 1.79 requires CMake 3.23.2 or newer. - Boost 1.80 requires CMake 3.24.2 or newer. - Boost 1.81 requires CMake 3.25.2 or newer. - Boost 1.82 requires CMake 3.27.0 or newer. diff --git a/doc/changes.txt b/doc/changes.txt index b7435d86d2..1ed11d5f11 100644 --- a/doc/changes.txt +++ b/doc/changes.txt @@ -2,6 +2,231 @@ @page changes Release Notes +@htmlonly @endhtmlonly +@par +Version 12.0.1 - In development + +@htmlonly @endhtmlonly +@par +Version 12.0.0 - October 31, 2024 + +@par +
+OpenVDB is now licensed under the Apache 2.0 license, instead of the MPL 2.0 license. +
+ +@par +
+This version introduces ABI changes relative to older major releases, so to +preserve ABI compatibility it might be necessary to define the macro +OPENVDB_ABI_VERSION_NUMBER=N, where, for example, +N is 10 for Houdini 20.0 and 11 for Houdini 20.5. +
+ +@par +
+GCC 9 is no longer supported. +
+ +@par +OpenVDB: +- New features: + - Added tools::LevelSetFilter::fillet() method to round off concave edges + to create smoother transition between surfaces. + +- Improvements: + - Added openvdb::assertAbort to replace cassert and a + @c OPENVDB_ENABLE_ASSERTS cmake argument/compile define to toggle + assertions in OpenVDB code, independantly of NDEBUG. Asserts are + no longer enabled by default in when NDEBUG is absent (e.g. + Debug builds). + - Removed last traces of Boost when @c OPENVDB_USE_DELAYED_LOADING is OFF + [Reported by Brian McKinnon] + - RootNode code cleanup to eliminate redundant key conversion and + to create map values in-place. + - Add RootNode::deleteChildOrTile() to delete a child or tile of + the root node. + - ValueAccessors are now defined and created in the Tree class + instead of in the Grid class so that custom Tree implementations + may define and create their own ValueAccessors if desired. + - Added support for PDAL to vdb_tool [Contributed by Tom Matterson] + - LeafManager and NodeManager now use Index64 for leaf counts internally. + - Added RootNode::probeChild() const. + - Added RootNode::probeChild() and RootNode::probeConstChild(). + - Added RootNode::probe() and RootNode::probeConst() to query key presence, + child node, value and active state. + - Added InternalNode::probeChild() const. + - Added InternalNode::probeChild() and probeChildConst() with coord access + and optionally value and active state. + - Added InternalNode::probeChild() and probeChildConst() with index access + and optionally value and active state. + - Added InternalNode::isValueOff(), LeafNode::isValueOff(), + LeafNodeBool::isValueOff(), LeafNodeMask::isValueOff(). + - Added LeafNodeMask::probeValue(Index,val), LeafNodeBool::probeValue(Index,val). + - Added RootNode::getValueUnsafe(), RootNode::getChildUnsafe(), + RootNode::getConstChildUnsafe(). + - Added InternalNode::getValueUnsafe(), InternalNode::getChildUnsafe(), + InternalNode::getConstChildUnsafe(). + - Added InternalNode::setActiveStateUnsafe(), InternalNode::setValueOnlyUnsafe(), + InternalNode::setValueOnUnsafe(), InternalNode::setValueOffUnsafe(). + - Added InternalNode::setChildUnsafe(), InternalNode::resetChildUnsafe(), + InternalNode::stealChildUnsafe(), InternalNode::deleteChildUnsafe(). + - For LeafNode, LeafNodeBool and LeafNodeMask - added + LeafNode::getValueUnsafe(), LeafNode::setActiveStateunsafe(), + LeafNode::setValueOnlyUnsafe(), LeafNode::setValueOnUnsafe(), + LeafNode::setValueOffUnsafe(). + +- ABI changes: + - Tree::leafCount(), Tree::unallocatedLeafCount(), + Tree::nonLeafCount() and Tree::nodeCount() now use Index64 in their + return types instead of Index32. + +- API Changes: + - RootNode::tileCount(), RootNode::activeTileCount() and + RootNode::inactiveTileCount() are now public. + - RootNode::hasKey() and RootNode::coordToKey() are now public. + - RootNode::leafCount(), RootNode::nonLeafCount() and RootNode::nodeCount() + now use Index64 instead of Index32. The Index32 variant is deprecated. + - InternalNode::leafCount(), InternalNode::nonLeafCount() and + InternalNode::nodeCount() now use Index64 instead of Index32. The Index32 + variant is deprecated. + - LeafNode::leafCount() and LeafNode::nonLeafCount() now use Index64 instead + of Index32. The Index32 variant is deprecated. + +- Bug Fixes: + - Fix potential crash reading corrupt .vdb files with invalid + blosc or zip chunks. + [Reported by Matthias Ueberheide] + + - Fix a bug in RootNode::setOrigin() where the origin was updated + before the error was thrown potentially leaving the root in an + invalid state. + - Fixed a thread sanitizer issue which could cause undefined + behaviour in VolumeToSpheres::fillWithSpheres + [Reported by Jérémie Dumas] + - Fixed an occurance of undefined behaviour in tools::activate + (though this would typically not have manifested with any + unintended behaviour) + +@par +NanoVDB: +- Bug fix: + - nanovdb::readGrids works with raw grid buffer. + +- Improvements: + - Restructure files location and namespace to be more align with + OpenVDB. The namespaces touched by the restructuring are: io, + cuda, util, tools, and math. + - Add two scripts updateFiles.sh and updateFiles.py to update the + files using NanoVDB. The script updateFiles.py works on both + Windows and Linux. For a more complete list of changes, see API + Changes (details). + + - cuda::PointsToGrid supports target density. + - Add support for NanoVDB Grid of type UInt8. + - Add ability to use externally managed CUDA buffer. + - Add create methods for CudaDeviceBuffer and exceptions. + - Improve GridValidator logic, e.g. include check for grid count. + - Add operator > and >= for class Coord according to lexicographical order. + - Add toCodec to convert string to Codec enumeration type. + - Add nanovdb::strlen(). + - Add strncpy util. + - Add @c NANOVDB_DISABLE_SYNC_CUDA_MALLOC that maps cudaMallocAsync + and cudaFreeAsync to cudaMalloc and cudaFree respectively. + - Add guard to @c UINT64_C. + - Remove use of cudaMallocAsync in PointsToGrid.cuh. + - Align PNanoVDB blind metadata to NanoVDB. + +- API Changes: + - Change mapToGridType to toGridType. + - Change mapToMagic to toMagic. + - Change CpuTimer.h to Timer.h. + +- API Changes (details): + - These APIs are now under the math namespace: Ray, DDA, HDDA, + Vec3, Vec4, BBox, ZeroCrossing, TreeMarcher, PointTreeMarcher, + BoxStencil, CurvatureStencil, GradStencil, WenoStencil, AlignUp, + Min, Max, Abs, Clamp, Sqrt, Sign, Maximum, Delta, RoundDown, pi, + isApproxZero, Round, createSampler, SampleFromVoxels. + + - These APIs are now under the tools namespace: createNanoGrid, + StatsMode, createLevelSetSphere, createFogVolumeSphere, + createFogVolumeSphere, createFogVolumeSphere, + createFogVolumeTorus, createLevelSetBox, CreateNanoGrid, + updateGridStats, evalChecksum, validateChecksum, checkGrid, + Extrema. + - These APIs are now under the util namespace: is_floating_point, + findLowestOn, findHighestOn, Range, streq, strcpy, strcat, + empty, Split, invoke, forEach, reduce, prefixSum, is_same, + is_specialization, PtrAdd, PtrDiff. + + - Move nanovdb::build to nanovdb::tools::build. + - Rename nanovdb::BBoxR to nanovdb::Vec3dBBox. + - Rename nanovdb::BBox to nanovdb::Vec3dBbox. + - Move nanovdb::cudaCreateNodeManager to nanovdb::cuda::createNodeManager. + - Move and rename nanovdb::cudaVoxelsToGrid to nanovdb::cuda::voxelsToGrid. + - Move and rename nanovdb::cudaPointsToGrid to nanovdb::cuda::pointsToGrid. + - Move nanovdb::DitherLUT to nanovdb::math::DitherLUT. + - Move and rename nanovdb::PackedRGBA8 to nanovdb::math::Rgba8. + - Move nanovdb::Rgba8 to nanovdb::math::Rgba8. + - Move and rename nanovdb::CpuTimer to nanovdb::util::Timer. + - Move nanovdb::GpuTimer to nanovdb::util::cuda::Timer. + - Move and rename nanovdb::CountOn to nanovdb::util::countOn. + + - Move util/GridHandle.h to GridHandle.h. + - Move util/BuildGrid.h to tools/GridBuilder.h. + - Move util/GridBuilder.h to tools/GridBuilder.h. + - Move util/IO.h to io/IO.h. + - Move util/CSampleFromVoxels.h to math/CSampleFromVoxels.h. + - Move util/DitherLUT.h to math/DitherLUT.h. + - Move util/HDDA.h to math/HDDA.h. + - Move util/Ray.h to math/Ray.h. + - Move util/SampleFromVoxels.h to math/SampleFromVoxels.h. + - Move util/Stencils.h to nanovdb/math/Stencils.h. + - Move util/CreateNanoGrid.h to tools/CreateNanoGrid.h. + - Move and rename util/Primitives.h to tools/CreatePrimitives.h. + - Move util/GridChecksum.h to tools/GridChecksum.h. + - Move util/GridStats.h to tools/GridStats.h. + - Move util/GridChecksum.h to tools/GridChecksum.h. + - Move util/GridValidator.h to tools/GridValidator.h. + - Move util/NanoToOpenVDB.h to tools/NanoToOpenVDB.h. + - Move util/cuda/CudaGridChecksum.cuh to tools/cuda/CudaGridChecksum.cuh. + - Move util/cuda/CudaGridStats.cuh to tools/cuda/CudaGridStats.cuh. + - Move util/cuda/CudaGridValidator.cuh to tools/cuda/CudaGridValidator.cuh. + - Move util/cuda/CudaIndexToGrid.cuh to tools/cuda/CudaIndexToGrid.cuh. + - Move and rename util/cuda/CudaPointsToGrid.cuh to tools/cuda/PointsToGrid.cuh. + - Move util/cuda/CudaSignedFloodFill.cuh to tools/cuda/CudaSignedFloodFill.cuh. + - Move and rename util/cuda/CudaDeviceBuffer.h to cuda/DeviceBuffer.h. + - Move and rename util/cuda/CudaGridHandle.cuh to cuda/GridHandle.cuh. + - Move and rename util/cuda/CudaUtils.h to util/cuda/Util.h. + - Move and consolidate util/cuda/GpuTimer.h to util/cuda/Timer.h. + +@par +Python: + - OpenVDB Python bindings are now implemented using nanobind + instead of pybind11 + - The OpenVDB Python module has been changed from pyopenvdb to openvdb + - Added Python bindings for NanoVDB + +@par +Houdini: + - When @c OPENVDB_ENABLE_RPATH is @c ON, the location of + libopenvdb_houdini is now added to the rpath of all Houdini + dsos. + +@par +Build: + - Fixed an issue with OpenVDB AX's CMake on Windows where the + static and shared library targets would have the same name + [Reported by Nicholas Yue] + - @c USE_EXPLICIT_INSTANTIATION is now disabled on Windows by default + due to OOM linker issues. + - Jemalloc is now the preferred allocator of choice on all + platforms when @c CONCURRENT_MALLOC is set to Auto. + - Fixed an issue with the Blosc CMake FindPackage for the OpenVDB + Windows static library. + + @htmlonly @endhtmlonly @par Version 11.0.0 - November 1, 2023 diff --git a/doc/codingstyle.txt b/doc/codingstyle.txt index 2a9a60aaf9..6f298e83e7 100644 --- a/doc/codingstyle.txt +++ b/doc/codingstyle.txt @@ -7,7 +7,7 @@ This document details the coding practices that are used in the OpenVDB codebase. Contributed code should conform to these guidelines to maintain consistency and maintainability. If there is a rule that you would like -clarified, changed, or added, please send a note to openvdb@gmail.com. +clarified, changed, or added, please send a note to openvdb-dev@lists.aswf.io. @section sStyleContents Contents diff --git a/doc/dependencies.txt b/doc/dependencies.txt index 16d3884fd0..041fb834c0 100644 --- a/doc/dependencies.txt +++ b/doc/dependencies.txt @@ -36,12 +36,12 @@ Reference Platform, but for those that do, their specified versions are Component | Requirements | Optional ----------------------- | ----------------------------------------------- | -------- -OpenVDB Core Library | CMake, C++17 compiler, TBB::tbb, Boost::headers | Blosc, ZLib, Log4cplus, Imath::Imath, Boost::iostream +OpenVDB Core Library | CMake, C++17 compiler, TBB::tbb | Blosc, ZLib, Log4cplus, Imath::Imath, Boost::iostream OpenVDB Print | Core Library dependencies | - OpenVDB LOD | Core Library dependencies | - OpenVDB Render | Core Library dependencies | OpenEXR, Imath::Imath, libpng OpenVDB View | Core Library dependencies, OpenGL, GLFW3, GLEW* | - -OpenVDB Python | Core Library dependencies, Python, PyBind11 | NumPy +OpenVDB Python | Core Library dependencies, Python, nanobind | NumPy OpenVDB AX | Core Library dependencies, LLVM | Bison, Flex NanoVDB | - | Core Library, CUDA, TBB, Blosc, ZLib OpenVDB UnitTests | Core Library dependencies, GoogleTest | CppUnit** @@ -56,22 +56,22 @@ OpenVDB Documentation | Doxygen | - Package | Minimum | Recommended | Description | apt-get | Homebrew | Source -------------- | ------- | ----------- | ----------------------------------------------------------------- | ------- | -------- | ------ -CMake | 3.18 | Latest | Cross-platform family of tools designed to help build software | Y | Y | https://cmake.org -GCC | 9.3.1 | 11.2.1 | C++ 17 Compiler: The GNU Compiler Collection | Y | Y | https://www.gnu.org/software/gcc +CMake | 3.20 | Latest | Cross-platform family of tools designed to help build software | Y | Y | https://cmake.org +GCC | 11.2.1 | 11.2.1 | C++ 17 Compiler: The GNU Compiler Collection | Y | Y | https://www.gnu.org/software/gcc Clang | 5.0 | Latest | C++ 17 Compiler: A C language family frontend for LLVM | Y | Y | https://clang.llvm.org Intel ICC | 19 | Latest | C++ 17 Compiler: Intels C++ Compiler | Y | Y | https://software.intel.com/en-us/c-compilers -MSVC | 19.28 | 19.30 | C++ 17 Compiler: Microsoft Visual C++ Compiler | Y | Y | https://visualstudio.microsoft.com/vs +MSVC | 19.30 | 19.30 | C++ 17 Compiler: Microsoft Visual C++ Compiler | Y | Y | https://visualstudio.microsoft.com/vs Imath | 3.1 | Latest | Half precision floating points | Y | Y | http://www.openexr.com OpenEXR | 3.1 | Latest | EXR serialization support | Y | Y | http://www.openexr.com -TBB | 2020.2 | 2020.3 | Threading Building Blocks - template library for task parallelism | Y | Y | https://www.threadingbuildingblocks.org +TBB | 2020.3 | 2020.3 | Threading Building Blocks - template library for task parallelism | Y | Y | https://www.threadingbuildingblocks.org ZLIB | 1.2.7 | Latest | Compression library for disk serialization compression | Y | Y | https://www.zlib.net -Boost | 1.73 | 1.80 | Components: headers, iostreams | Y | Y | https://www.boost.org -LLVM | 10.0.0 | 13.0.0* | Target-independent code generation | Y | Y | https://llvm.org/ -Bison | 3.0.0 | 3.7.0 | General-purpose parser generator | Y | Y | https://www.gnu.org/software/gcc -Flex | 2.6.0 | 2.6.4 | Fast lexical analyzer generator | Y | Y | https://github.com/westes/flex -Python | 3.9.1 | 3.10 | The python interpreter and libraries | Y | Y | https://www.python.org -PyBind11 | 2.9.1 | Latest | C++/python bindings | Y | Y | https://pybind11.readthedocs.io -NumPy | 1.20.0 | 1.23.0 | Scientific computing with Python | Y | Y | http://www.numpy.org +Boost | 1.80 | 1.82 | Components: iostreams | Y | Y | https://www.boost.org +LLVM | 13.0.0 | 15.0.0* | Target-independent code generation | Y | Y | https://llvm.org/ +Bison | 3.7.0 | 3.7.0 | General-purpose parser generator | Y | Y | https://www.gnu.org/software/gcc +Flex | 2.6.4 | 2.6.4 | Fast lexical analyzer generator | Y | Y | https://github.com/westes/flex +Python | 3.10 | 3.11 | The python interpreter and libraries | Y | Y | https://www.python.org +nanobind | 2.0.0 | 2.1.0 | C++/python bindings | Y | Y | https://nanobind.readthedocs.io +NumPy | 1.23.0 | 1.26.0 | Scientific computing with Python | Y | Y | http://www.numpy.org GoogleTest | 1.10 | Latest | A unit testing framework module for C++ | Y | Y | https://github.com/google/googletest CppUnit | 1.10 | Latest | A unit testing framework module for C++ | N | Y | https://freedesktop.org/wiki/Software/cppunit Blosc | 1.17.0* | 1.17.0 | Recommended dependency for improved disk compression | Y | Y | https://github.com/Blosc/c-blosc/releases @@ -145,11 +145,11 @@ apt-get install zlibc # zlib apt-get install libboost-iostreams-dev # Boost::iostream apt-get install libblosc-dev # Blosc # AX -apt-get install llvm-10-dev # LLVM +apt-get install llvm-15-dev # LLVM # Python -apt-get install pybind11-dev # Python apt-get install python-dev # Python apt-get install python-numpy # NumPy +pip install nanobind # nanobind # Optional apt-get install libpng-dev # libpng apt-get install libopenexr-dev # OpenEXR @@ -180,9 +180,9 @@ brew install c-blosc # blosc # AX brew install llvm # LLVM # Python -brew install pybind11 # PyBind11 brew install python # Python brew install numpy # NumPy +brew install nanobind # nanobind # Unit Tests brew install gtest # GoogleTest brew install cppunit # CppUnit diff --git a/doc/faq.txt b/doc/faq.txt index c318dc1de6..ffa56f66ca 100644 --- a/doc/faq.txt +++ b/doc/faq.txt @@ -40,10 +40,10 @@ details of VDB are described in the paper "VDB: High-Resolution Sparse Volumes with Dynamic Topology". @section sWhatLicense What license is OpenVDB distributed under? -OpenVDB is released under the Mozilla Public License Version 2.0, which is a -free, open source software license developed and maintained by the Mozilla -Foundation. For more information about this license, see the -Mozilla FAQ. +OpenVDB is released under the Apache License Version 2.0, which is a +free, open source software license developed and maintained by the Apache Software +Foundation. For more information about this license, see +Apache License, Version 2. @section sWhatCLA Is there a Contributor License Agreement for OpenVDB? Yes, developers who wish to contribute code to be considered for inclusion diff --git a/nanovdb/nanovdb/CMakeLists.txt b/nanovdb/nanovdb/CMakeLists.txt index 5ef70a9fc1..4e0284ecbf 100644 --- a/nanovdb/nanovdb/CMakeLists.txt +++ b/nanovdb/nanovdb/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(NanoVDB LANGUAGES C CXX) include(GNUInstallDirs) @@ -26,6 +26,7 @@ option(NANOVDB_BUILD_TOOLS "Build command-line tools" ON) option(NANOVDB_BUILD_UNITTESTS "Build Unit tests" OFF) option(NANOVDB_BUILD_EXAMPLES "Build examples" OFF) #option(NANOVDB_BUILD_BENCHMARK "Build benchmark in examples" OFF) +option(NANOVDB_BUILD_PYTHON_MODULE "Build the nanovdb Python module" OFF) option(NANOVDB_USE_INTRINSICS "Build with hardware intrinsics support" OFF) option(NANOVDB_USE_CUDA "Build with CUDA support" OFF) @@ -73,18 +74,16 @@ endif() #if(NANOVDB_BUILD_UNITTESTS OR NANOVDB_BUILD_BENCHMARK) if(NANOVDB_BUILD_UNITTESTS) - find_package(GTest REQUIRED) + find_package(GTest ${MINIMUM_GOOGLETEST_VERSION} REQUIRED) endif() if(NANOVDB_USE_CUDA) set(CMAKE_CUDA_STANDARD 17) set(CMAKE_CUDA_STANDARD_REQUIRED ON) - if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) - # Allow the user to provide CMAKE_CUDA_ARCHITECTURES - if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) - set(CMAKE_CUDA_ARCHITECTURES 75) - endif() + # Allow the user to provide CMAKE_CUDA_ARCHITECTURES + if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) + set(CMAKE_CUDA_ARCHITECTURES 75) endif() enable_language(CUDA) @@ -123,15 +122,15 @@ if(NANOVDB_USE_OPENVDB) endif() if(NANOVDB_USE_TBB AND NOT TARGET TBB::tbb) - find_package(TBB REQUIRED) + find_package(TBB ${MINIMUM_TBB_VERSION} REQUIRED) endif() if(NANOVDB_USE_BLOSC AND NOT TARGET Blosc::blosc) - find_package(Blosc REQUIRED) + find_package(Blosc ${MINIMUM_BLOSC_VERSION} REQUIRED) endif() if(NANOVDB_USE_ZLIB AND NOT TARGET ZLIB::ZLIB) - find_package(ZLIB REQUIRED) + find_package(ZLIB ${MINIMUM_ZLIB_VERSION} REQUIRED) endif() if(NANOVDB_USE_MAGICAVOXEL) @@ -321,16 +320,16 @@ if(TARGET Threads::Threads) target_link_libraries(nanovdb INTERFACE Threads::Threads) endif() -set(NANOVDB_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/nanovdb) -set(NANOVDB_INSTALL_CUDA_DIR ${NANOVDB_INSTALL_INCLUDE_DIR}/cuda) -set(NANOVDB_INSTALL_IO_DIR ${NANOVDB_INSTALL_INCLUDE_DIR}/io) -set(NANOVDB_INSTALL_MATH_DIR ${NANOVDB_INSTALL_INCLUDE_DIR}/math) -set(NANOVDB_INSTALL_TOOLS_DIR ${NANOVDB_INSTALL_INCLUDE_DIR}/tools) +set(NANOVDB_INSTALL_ROOT_DIR ${NANOVDB_INSTALL_INCLUDEDIR}/nanovdb) +set(NANOVDB_INSTALL_CUDA_DIR ${NANOVDB_INSTALL_ROOT_DIR}/cuda) +set(NANOVDB_INSTALL_IO_DIR ${NANOVDB_INSTALL_ROOT_DIR}/io) +set(NANOVDB_INSTALL_MATH_DIR ${NANOVDB_INSTALL_ROOT_DIR}/math) +set(NANOVDB_INSTALL_TOOLS_DIR ${NANOVDB_INSTALL_ROOT_DIR}/tools) set(NANOVDB_INSTALL_TOOLS_CUDA_DIR ${NANOVDB_INSTALL_TOOLS_DIR}/cuda) -set(NANOVDB_INSTALL_UTIL_DIR ${NANOVDB_INSTALL_INCLUDE_DIR}/util) +set(NANOVDB_INSTALL_UTIL_DIR ${NANOVDB_INSTALL_ROOT_DIR}/util) set(NANOVDB_INSTALL_UTIL_CUDA_DIR ${NANOVDB_INSTALL_UTIL_DIR}/cuda) -install(FILES ${NANOVDB_INCLUDE_FILES} DESTINATION ${NANOVDB_INSTALL_INCLUDE_DIR}) +install(FILES ${NANOVDB_INCLUDE_FILES} DESTINATION ${NANOVDB_INSTALL_ROOT_DIR}) install(FILES ${NANOVDB_INCLUDE_CUDA_FILES} DESTINATION ${NANOVDB_INSTALL_CUDA_DIR}) install(FILES ${NANOVDB_INCLUDE_IO_FILES} DESTINATION ${NANOVDB_INSTALL_IO_DIR}) install(FILES ${NANOVDB_INCLUDE_MATH_FILES} DESTINATION ${NANOVDB_INSTALL_MATH_DIR}) @@ -354,3 +353,7 @@ endif() if(NANOVDB_BUILD_EXAMPLES) add_subdirectory(examples) endif() + +if(NANOVDB_BUILD_PYTHON_MODULE) + add_subdirectory(python) +endif() diff --git a/nanovdb/nanovdb/CNanoVDB.h b/nanovdb/nanovdb/CNanoVDB.h index a3d8873e7e..c714f94d13 100644 --- a/nanovdb/nanovdb/CNanoVDB.h +++ b/nanovdb/nanovdb/CNanoVDB.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // // Simple C-wrapper for the nanovdb structure diff --git a/nanovdb/nanovdb/GridHandle.h b/nanovdb/nanovdb/GridHandle.h index a3d868e8be..05e492046b 100644 --- a/nanovdb/nanovdb/GridHandle.h +++ b/nanovdb/nanovdb/GridHandle.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/GridHandle.h diff --git a/nanovdb/nanovdb/HostBuffer.h b/nanovdb/nanovdb/HostBuffer.h index c664856a07..70c9ce0fa4 100644 --- a/nanovdb/nanovdb/HostBuffer.h +++ b/nanovdb/nanovdb/HostBuffer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! @file nanovdb/HostBuffer.h diff --git a/nanovdb/nanovdb/NanoVDB.h b/nanovdb/nanovdb/NanoVDB.h index 5e912a7868..36b412b0e4 100644 --- a/nanovdb/nanovdb/NanoVDB.h +++ b/nanovdb/nanovdb/NanoVDB.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/NanoVDB.h diff --git a/nanovdb/nanovdb/NodeManager.h b/nanovdb/nanovdb/NodeManager.h index 0e95ecf872..0d7686eb2d 100644 --- a/nanovdb/nanovdb/NodeManager.h +++ b/nanovdb/nanovdb/NodeManager.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/NodeManager.h diff --git a/nanovdb/nanovdb/PNanoVDB.h b/nanovdb/nanovdb/PNanoVDB.h index 40888f242c..3e7b306b3a 100644 --- a/nanovdb/nanovdb/PNanoVDB.h +++ b/nanovdb/nanovdb/PNanoVDB.h @@ -1,6 +1,6 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/PNanoVDB.h diff --git a/nanovdb/nanovdb/Readme.md b/nanovdb/nanovdb/Readme.md index 15fda0a2eb..21f247a5e5 100644 --- a/nanovdb/nanovdb/Readme.md +++ b/nanovdb/nanovdb/Readme.md @@ -9,6 +9,6 @@ A lightweight GPU friendly version of VDB initially targeting rendering applicat * [Examples](../../doc/nanovdb/HelloWorld.md) ### Copyright Contributors to the OpenVDB Project -### SPDX-License-Identifier: MPL-2.0 +### SPDX-License-Identifier: Apache-2.0 [![CircleCI](https://circleci.com/gh/NVIDIA-Omniverse/NanoVDB.svg?style=svg&circle-token=6c3b9bb166841033a0e0c1a9ee5ac49f73d89152)](https://circleci.com/gh/NVIDIA-Omniverse/NanoVDB) diff --git a/nanovdb/nanovdb/cmd/CMakeLists.txt b/nanovdb/nanovdb/cmd/CMakeLists.txt index 758f4e89c7..985a7d1d70 100644 --- a/nanovdb/nanovdb/cmd/CMakeLists.txt +++ b/nanovdb/nanovdb/cmd/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(NanoVDBExamples LANGUAGES CXX) include(GNUInstallDirs) @@ -32,17 +32,17 @@ if(NOT NANOVDB_USE_OPENVDB) else() add_executable(nanovdb_convert convert/nanovdb_convert.cc) target_link_libraries(nanovdb_convert PRIVATE nanovdb) - install(TARGETS nanovdb_convert RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + install(TARGETS nanovdb_convert RUNTIME DESTINATION ${NANOVDB_INSTALL_BINDIR}) endif() # ----------------------------------------------------------------------------- # nanovdb_print add_executable(nanovdb_print print/nanovdb_print.cc) target_link_libraries(nanovdb_print PRIVATE nanovdb) -install(TARGETS nanovdb_print RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS nanovdb_print RUNTIME DESTINATION ${NANOVDB_INSTALL_BINDIR}) # ----------------------------------------------------------------------------- # nanovdb_validate add_executable(nanovdb_validate validate/nanovdb_validate.cc) target_link_libraries(nanovdb_validate PRIVATE nanovdb) -install(TARGETS nanovdb_validate RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS nanovdb_validate RUNTIME DESTINATION ${NANOVDB_INSTALL_BINDIR}) diff --git a/nanovdb/nanovdb/cmd/convert/nanovdb_convert.cc b/nanovdb/nanovdb/cmd/convert/nanovdb_convert.cc index 9133bd7f8c..e5b5981f5d 100644 --- a/nanovdb/nanovdb/cmd/convert/nanovdb_convert.cc +++ b/nanovdb/nanovdb/cmd/convert/nanovdb_convert.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb_convert.cc diff --git a/nanovdb/nanovdb/cmd/print/nanovdb_print.cc b/nanovdb/nanovdb/cmd/print/nanovdb_print.cc index dd091e75a7..561876d066 100644 --- a/nanovdb/nanovdb/cmd/print/nanovdb_print.cc +++ b/nanovdb/nanovdb/cmd/print/nanovdb_print.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb_print.cc diff --git a/nanovdb/nanovdb/cmd/validate/nanovdb_validate.cc b/nanovdb/nanovdb/cmd/validate/nanovdb_validate.cc index 2d563d92de..f64ef60378 100644 --- a/nanovdb/nanovdb/cmd/validate/nanovdb_validate.cc +++ b/nanovdb/nanovdb/cmd/validate/nanovdb_validate.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb_validate.cc diff --git a/nanovdb/nanovdb/cuda/DeviceBuffer.h b/nanovdb/nanovdb/cuda/DeviceBuffer.h index 171235afbc..465bd9dc6b 100644 --- a/nanovdb/nanovdb/cuda/DeviceBuffer.h +++ b/nanovdb/nanovdb/cuda/DeviceBuffer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file DeviceBuffer.h diff --git a/nanovdb/nanovdb/cuda/GridHandle.cuh b/nanovdb/nanovdb/cuda/GridHandle.cuh index db3a99d713..a0fc96cb16 100644 --- a/nanovdb/nanovdb/cuda/GridHandle.cuh +++ b/nanovdb/nanovdb/cuda/GridHandle.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/cuda/GridHandle.cuh diff --git a/nanovdb/nanovdb/cuda/NodeManager.cuh b/nanovdb/nanovdb/cuda/NodeManager.cuh index 8e9f24d0f8..639155ce7f 100644 --- a/nanovdb/nanovdb/cuda/NodeManager.cuh +++ b/nanovdb/nanovdb/cuda/NodeManager.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/cuda/NodeManager.cuh diff --git a/nanovdb/nanovdb/examples/CMakeLists.txt b/nanovdb/nanovdb/examples/CMakeLists.txt index e86c17bc32..d06371cd95 100644 --- a/nanovdb/nanovdb/examples/CMakeLists.txt +++ b/nanovdb/nanovdb/examples/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(NanoVDBExamples LANGUAGES CXX) include(GNUInstallDirs) @@ -78,7 +78,7 @@ function(NANOVDB_EXAMPLE) target_include_directories(${EXAMPLE_NAME} PUBLIC ex_util) target_link_libraries(${EXAMPLE_NAME} PRIVATE nanovdb) - install(TARGETS ${EXAMPLE_NAME} DESTINATION ${CMAKE_INSTALL_DOCDIR}/examples) + install(TARGETS ${EXAMPLE_NAME} DESTINATION ${NANOVDB_INSTALL_DOCDIR}/examples) endfunction() # ----------------------------------------------------------------------- diff --git a/nanovdb/nanovdb/examples/ex_bump_pool_buffer/bump_pool_buffer.cc b/nanovdb/nanovdb/examples/ex_bump_pool_buffer/bump_pool_buffer.cc index bcd54036ec..a3e84ae762 100644 --- a/nanovdb/nanovdb/examples/ex_bump_pool_buffer/bump_pool_buffer.cc +++ b/nanovdb/nanovdb/examples/ex_bump_pool_buffer/bump_pool_buffer.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/nanovdb/nanovdb/examples/ex_collide_level_set/common.h b/nanovdb/nanovdb/examples/ex_collide_level_set/common.h index dc54e8f5f1..0b476588fd 100644 --- a/nanovdb/nanovdb/examples/ex_collide_level_set/common.h +++ b/nanovdb/nanovdb/examples/ex_collide_level_set/common.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #pragma once diff --git a/nanovdb/nanovdb/examples/ex_collide_level_set/main.cc b/nanovdb/nanovdb/examples/ex_collide_level_set/main.cc index 5d0ae28475..7771737fca 100644 --- a/nanovdb/nanovdb/examples/ex_collide_level_set/main.cc +++ b/nanovdb/nanovdb/examples/ex_collide_level_set/main.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/nanovdb/nanovdb/examples/ex_collide_level_set/nanovdb.cu b/nanovdb/nanovdb/examples/ex_collide_level_set/nanovdb.cu index 7eb9f2de06..98f9e5128f 100644 --- a/nanovdb/nanovdb/examples/ex_collide_level_set/nanovdb.cu +++ b/nanovdb/nanovdb/examples/ex_collide_level_set/nanovdb.cu @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #define _USE_MATH_DEFINES #include diff --git a/nanovdb/nanovdb/examples/ex_collide_level_set/openvdb.cc b/nanovdb/nanovdb/examples/ex_collide_level_set/openvdb.cc index 294ded6010..7c71392d32 100644 --- a/nanovdb/nanovdb/examples/ex_collide_level_set/openvdb.cc +++ b/nanovdb/nanovdb/examples/ex_collide_level_set/openvdb.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #if defined(NANOVDB_USE_OPENVDB) diff --git a/nanovdb/nanovdb/examples/ex_index_grid_cuda/index_grid_cuda.cc b/nanovdb/nanovdb/examples/ex_index_grid_cuda/index_grid_cuda.cc index 1bb2a855d9..8f731b014b 100644 --- a/nanovdb/nanovdb/examples/ex_index_grid_cuda/index_grid_cuda.cc +++ b/nanovdb/nanovdb/examples/ex_index_grid_cuda/index_grid_cuda.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include // for nanovdb::tools::createLevelSetSphere diff --git a/nanovdb/nanovdb/examples/ex_index_grid_cuda/index_grid_cuda_kernel.cu b/nanovdb/nanovdb/examples/ex_index_grid_cuda/index_grid_cuda_kernel.cu index ed1ae04100..82a226e15b 100644 --- a/nanovdb/nanovdb/examples/ex_index_grid_cuda/index_grid_cuda_kernel.cu +++ b/nanovdb/nanovdb/examples/ex_index_grid_cuda/index_grid_cuda_kernel.cu @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // this defined the core tree data structure of NanoVDB accessable on both the host and device #include // required since GridHandle has device code diff --git a/nanovdb/nanovdb/examples/ex_make_custom_nanovdb/make_custom_nanovdb.cc b/nanovdb/nanovdb/examples/ex_make_custom_nanovdb/make_custom_nanovdb.cc index 6ee036eddb..8aa13d1707 100644 --- a/nanovdb/nanovdb/examples/ex_make_custom_nanovdb/make_custom_nanovdb.cc +++ b/nanovdb/nanovdb/examples/ex_make_custom_nanovdb/make_custom_nanovdb.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/nanovdb/nanovdb/examples/ex_make_custom_nanovdb_cuda/make_custom_nanovdb_cuda.cc b/nanovdb/nanovdb/examples/ex_make_custom_nanovdb_cuda/make_custom_nanovdb_cuda.cc index 1846e010e8..b28c35d35b 100644 --- a/nanovdb/nanovdb/examples/ex_make_custom_nanovdb_cuda/make_custom_nanovdb_cuda.cc +++ b/nanovdb/nanovdb/examples/ex_make_custom_nanovdb_cuda/make_custom_nanovdb_cuda.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #undef NANOVDB_USE_OPENVDB // Prevents include/openvdb/points/AttributeArray.h:1841:25: error: ‘stride’ cannot be used as a function diff --git a/nanovdb/nanovdb/examples/ex_make_custom_nanovdb_cuda/make_custom_nanovdb_cuda_kernel.cu b/nanovdb/nanovdb/examples/ex_make_custom_nanovdb_cuda/make_custom_nanovdb_cuda_kernel.cu index 0ab22d15ef..70ba0e87cb 100644 --- a/nanovdb/nanovdb/examples/ex_make_custom_nanovdb_cuda/make_custom_nanovdb_cuda_kernel.cu +++ b/nanovdb/nanovdb/examples/ex_make_custom_nanovdb_cuda/make_custom_nanovdb_cuda_kernel.cu @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // this defined the core tree data structure of NanoVDB accessable on both the host and device #include // required since GridHandle has device code diff --git a/nanovdb/nanovdb/examples/ex_make_funny_nanovdb/make_funny_nanovdb.cc b/nanovdb/nanovdb/examples/ex_make_funny_nanovdb/make_funny_nanovdb.cc index 7997fc78e6..944fc9bd2a 100644 --- a/nanovdb/nanovdb/examples/ex_make_funny_nanovdb/make_funny_nanovdb.cc +++ b/nanovdb/nanovdb/examples/ex_make_funny_nanovdb/make_funny_nanovdb.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/nanovdb/nanovdb/examples/ex_make_nanovdb_sphere/make_nanovdb_sphere.cc b/nanovdb/nanovdb/examples/ex_make_nanovdb_sphere/make_nanovdb_sphere.cc index a7f8980a64..c5dfad8a3d 100644 --- a/nanovdb/nanovdb/examples/ex_make_nanovdb_sphere/make_nanovdb_sphere.cc +++ b/nanovdb/nanovdb/examples/ex_make_nanovdb_sphere/make_nanovdb_sphere.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include diff --git a/nanovdb/nanovdb/examples/ex_make_typed_grids/make_typed_grids.cc b/nanovdb/nanovdb/examples/ex_make_typed_grids/make_typed_grids.cc index bcb0ffce95..e301f06d49 100644 --- a/nanovdb/nanovdb/examples/ex_make_typed_grids/make_typed_grids.cc +++ b/nanovdb/nanovdb/examples/ex_make_typed_grids/make_typed_grids.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/nanovdb/nanovdb/examples/ex_map_pool_buffer/map_pool_buffer.cc b/nanovdb/nanovdb/examples/ex_map_pool_buffer/map_pool_buffer.cc index 5b00ca30d8..7f85b9362d 100644 --- a/nanovdb/nanovdb/examples/ex_map_pool_buffer/map_pool_buffer.cc +++ b/nanovdb/nanovdb/examples/ex_map_pool_buffer/map_pool_buffer.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/nanovdb/nanovdb/examples/ex_modify_nanovdb_thrust/modify_nanovdb_thrust.cc b/nanovdb/nanovdb/examples/ex_modify_nanovdb_thrust/modify_nanovdb_thrust.cc index 54d369fd53..2ff54fdc75 100644 --- a/nanovdb/nanovdb/examples/ex_modify_nanovdb_thrust/modify_nanovdb_thrust.cc +++ b/nanovdb/nanovdb/examples/ex_modify_nanovdb_thrust/modify_nanovdb_thrust.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @brief This examples demonstrates how values in a NanpVDB grid can be /// modified on the device. It depends on NanoVDB and CUDA thrust. diff --git a/nanovdb/nanovdb/examples/ex_modify_nanovdb_thrust/modify_nanovdb_thrust.cu b/nanovdb/nanovdb/examples/ex_modify_nanovdb_thrust/modify_nanovdb_thrust.cu index a8590d751b..4c602f8a44 100644 --- a/nanovdb/nanovdb/examples/ex_modify_nanovdb_thrust/modify_nanovdb_thrust.cu +++ b/nanovdb/nanovdb/examples/ex_modify_nanovdb_thrust/modify_nanovdb_thrust.cu @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @brief This examples demonstrates how values in a NanpVDB grid can be /// modified on the device. It depends on NanoVDB and CUDA thrust. diff --git a/nanovdb/nanovdb/examples/ex_nodemanager_cuda/nodemanager_cuda.cc b/nanovdb/nanovdb/examples/ex_nodemanager_cuda/nodemanager_cuda.cc index 2ffe307866..ae912a2493 100644 --- a/nanovdb/nanovdb/examples/ex_nodemanager_cuda/nodemanager_cuda.cc +++ b/nanovdb/nanovdb/examples/ex_nodemanager_cuda/nodemanager_cuda.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // replace with your own dependencies for generating the OpenVDB grid #include // converter from OpenVDB to NanoVDB (includes NanoVDB.h and GridManager.h) diff --git a/nanovdb/nanovdb/examples/ex_nodemanager_cuda/nodemanager_cuda_kernel.cu b/nanovdb/nanovdb/examples/ex_nodemanager_cuda/nodemanager_cuda_kernel.cu index 246d53e9e6..ae3b3990ff 100644 --- a/nanovdb/nanovdb/examples/ex_nodemanager_cuda/nodemanager_cuda_kernel.cu +++ b/nanovdb/nanovdb/examples/ex_nodemanager_cuda/nodemanager_cuda_kernel.cu @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // this defined the core tree data structure of NanoVDB accessable on both the host and device #include diff --git a/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb/openvdb_to_nanovdb.cc b/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb/openvdb_to_nanovdb.cc index 68ca9bec83..2fe5a4a7e4 100644 --- a/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb/openvdb_to_nanovdb.cc +++ b/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb/openvdb_to_nanovdb.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // replace with your own dependencies for generating the OpenVDB grid #include // converter from OpenVDB to NanoVDB (includes NanoVDB.h and GridManager.h) diff --git a/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_accessor/openvdb_to_nanovdb_accessor.cc b/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_accessor/openvdb_to_nanovdb_accessor.cc index de7f3d62bb..e4667f19e2 100644 --- a/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_accessor/openvdb_to_nanovdb_accessor.cc +++ b/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_accessor/openvdb_to_nanovdb_accessor.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // replace with your own dependencies for generating the OpenVDB grid #include // converter from OpenVDB to NanoVDB (includes NanoVDB.h and GridManager.h) diff --git a/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_cuda/openvdb_to_nanovdb_cuda.cc b/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_cuda/openvdb_to_nanovdb_cuda.cc index ca4eacf1c8..73441474ea 100644 --- a/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_cuda/openvdb_to_nanovdb_cuda.cc +++ b/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_cuda/openvdb_to_nanovdb_cuda.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // replace with your own dependencies for generating the OpenVDB grid #include // converter from OpenVDB to NanoVDB (includes NanoVDB.h and GridManager.h) diff --git a/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_cuda/openvdb_to_nanovdb_cuda_kernel.cu b/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_cuda/openvdb_to_nanovdb_cuda_kernel.cu index 2db56ef9ef..e0bf9a021d 100644 --- a/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_cuda/openvdb_to_nanovdb_cuda_kernel.cu +++ b/nanovdb/nanovdb/examples/ex_openvdb_to_nanovdb_cuda/openvdb_to_nanovdb_cuda_kernel.cu @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // this defined the core tree data structure of NanoVDB accessable on both the host and device #include // required since GridHandle has device code diff --git a/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/common.h b/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/common.h index edc4c27a32..dc0e601f26 100644 --- a/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/common.h +++ b/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/common.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #pragma once diff --git a/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/main.cc b/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/main.cc index fb429494c6..697afcf857 100644 --- a/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/main.cc +++ b/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/main.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/nanovdb.cu b/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/nanovdb.cu index 9e2c95a64c..a7b9c94a5f 100644 --- a/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/nanovdb.cu +++ b/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/nanovdb.cu @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #define _USE_MATH_DEFINES #include diff --git a/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/openvdb.cc b/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/openvdb.cc index c41d597c61..e5ca200c6c 100644 --- a/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/openvdb.cc +++ b/nanovdb/nanovdb/examples/ex_raytrace_fog_volume/openvdb.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #if defined(NANOVDB_USE_OPENVDB) diff --git a/nanovdb/nanovdb/examples/ex_raytrace_level_set/common.h b/nanovdb/nanovdb/examples/ex_raytrace_level_set/common.h index edc4c27a32..dc0e601f26 100644 --- a/nanovdb/nanovdb/examples/ex_raytrace_level_set/common.h +++ b/nanovdb/nanovdb/examples/ex_raytrace_level_set/common.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #pragma once diff --git a/nanovdb/nanovdb/examples/ex_raytrace_level_set/main.cc b/nanovdb/nanovdb/examples/ex_raytrace_level_set/main.cc index 88ef4125d2..71cd8959af 100644 --- a/nanovdb/nanovdb/examples/ex_raytrace_level_set/main.cc +++ b/nanovdb/nanovdb/examples/ex_raytrace_level_set/main.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/nanovdb/nanovdb/examples/ex_raytrace_level_set/nanovdb.cu b/nanovdb/nanovdb/examples/ex_raytrace_level_set/nanovdb.cu index d2864032e5..378211c602 100644 --- a/nanovdb/nanovdb/examples/ex_raytrace_level_set/nanovdb.cu +++ b/nanovdb/nanovdb/examples/ex_raytrace_level_set/nanovdb.cu @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #define _USE_MATH_DEFINES #include diff --git a/nanovdb/nanovdb/examples/ex_raytrace_level_set/openvdb.cc b/nanovdb/nanovdb/examples/ex_raytrace_level_set/openvdb.cc index ef64f1d463..4734d1abd7 100644 --- a/nanovdb/nanovdb/examples/ex_raytrace_level_set/openvdb.cc +++ b/nanovdb/nanovdb/examples/ex_raytrace_level_set/openvdb.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #if defined(NANOVDB_USE_OPENVDB) diff --git a/nanovdb/nanovdb/examples/ex_read_nanovdb_sphere/read_nanovdb_sphere.cc b/nanovdb/nanovdb/examples/ex_read_nanovdb_sphere/read_nanovdb_sphere.cc index 9bdf8f8f9d..e2386216c4 100644 --- a/nanovdb/nanovdb/examples/ex_read_nanovdb_sphere/read_nanovdb_sphere.cc +++ b/nanovdb/nanovdb/examples/ex_read_nanovdb_sphere/read_nanovdb_sphere.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include diff --git a/nanovdb/nanovdb/examples/ex_read_nanovdb_sphere_accessor_cuda/read_nanovdb_sphere_accessor_cuda.cu b/nanovdb/nanovdb/examples/ex_read_nanovdb_sphere_accessor_cuda/read_nanovdb_sphere_accessor_cuda.cu index c07393a77f..0a44933a40 100644 --- a/nanovdb/nanovdb/examples/ex_read_nanovdb_sphere_accessor_cuda/read_nanovdb_sphere_accessor_cuda.cu +++ b/nanovdb/nanovdb/examples/ex_read_nanovdb_sphere_accessor_cuda/read_nanovdb_sphere_accessor_cuda.cu @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // this is required to read (and write) NanoVDB files on the host #include // required for CUDA memory management diff --git a/nanovdb/nanovdb/examples/ex_read_nanovdb_sphere_accessor_cuda/read_nanovdb_sphere_accessor_cuda_kernel.cu b/nanovdb/nanovdb/examples/ex_read_nanovdb_sphere_accessor_cuda/read_nanovdb_sphere_accessor_cuda_kernel.cu index 31301e2d17..4a15e477c3 100644 --- a/nanovdb/nanovdb/examples/ex_read_nanovdb_sphere_accessor_cuda/read_nanovdb_sphere_accessor_cuda_kernel.cu +++ b/nanovdb/nanovdb/examples/ex_read_nanovdb_sphere_accessor_cuda/read_nanovdb_sphere_accessor_cuda_kernel.cu @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // this defined the core tree data structure of NanoVDB accessable on both the host and device #include // for printf diff --git a/nanovdb/nanovdb/examples/ex_util/ComputePrimitives.h b/nanovdb/nanovdb/examples/ex_util/ComputePrimitives.h index 432623222b..b14b93a9e2 100644 --- a/nanovdb/nanovdb/examples/ex_util/ComputePrimitives.h +++ b/nanovdb/nanovdb/examples/ex_util/ComputePrimitives.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ComputePrimitives.h /// @brief A collection of parallel compute primitives diff --git a/nanovdb/nanovdb/examples/ex_vox_to_nanovdb/VoxToNanoVDB.h b/nanovdb/nanovdb/examples/ex_vox_to_nanovdb/VoxToNanoVDB.h index ab9316ad33..1efe5a905b 100644 --- a/nanovdb/nanovdb/examples/ex_vox_to_nanovdb/VoxToNanoVDB.h +++ b/nanovdb/nanovdb/examples/ex_vox_to_nanovdb/VoxToNanoVDB.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #pragma once diff --git a/nanovdb/nanovdb/examples/ex_vox_to_nanovdb/vox_to_nanovdb.cc b/nanovdb/nanovdb/examples/ex_vox_to_nanovdb/vox_to_nanovdb.cc index 27b1b67d2b..bdac9dde98 100644 --- a/nanovdb/nanovdb/examples/ex_vox_to_nanovdb/vox_to_nanovdb.cc +++ b/nanovdb/nanovdb/examples/ex_vox_to_nanovdb/vox_to_nanovdb.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include "VoxToNanoVDB.h" diff --git a/nanovdb/nanovdb/examples/ex_voxels_to_grid_cuda/ex_voxels_to_grid_cuda.cu b/nanovdb/nanovdb/examples/ex_voxels_to_grid_cuda/ex_voxels_to_grid_cuda.cu index 83ffc37067..020c27badb 100644 --- a/nanovdb/nanovdb/examples/ex_voxels_to_grid_cuda/ex_voxels_to_grid_cuda.cu +++ b/nanovdb/nanovdb/examples/ex_voxels_to_grid_cuda/ex_voxels_to_grid_cuda.cu @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/nanovdb/nanovdb/examples/ex_write_nanovdb_grids/write_nanovdb_grids.cc b/nanovdb/nanovdb/examples/ex_write_nanovdb_grids/write_nanovdb_grids.cc index 2f9465e62e..20acbfa1be 100644 --- a/nanovdb/nanovdb/examples/ex_write_nanovdb_grids/write_nanovdb_grids.cc +++ b/nanovdb/nanovdb/examples/ex_write_nanovdb_grids/write_nanovdb_grids.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/nanovdb/nanovdb/io/IO.h b/nanovdb/nanovdb/io/IO.h index 3c6259140f..a7110846a9 100644 --- a/nanovdb/nanovdb/io/IO.h +++ b/nanovdb/nanovdb/io/IO.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file IO.h diff --git a/nanovdb/nanovdb/math/CSampleFromVoxels.h b/nanovdb/nanovdb/math/CSampleFromVoxels.h index 1af914f5b2..c7820a700e 100644 --- a/nanovdb/nanovdb/math/CSampleFromVoxels.h +++ b/nanovdb/nanovdb/math/CSampleFromVoxels.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // // Simple C-wrapper for voxel interpolation functions diff --git a/nanovdb/nanovdb/math/DitherLUT.h b/nanovdb/nanovdb/math/DitherLUT.h index 4a980e2aa1..7add4a6f33 100644 --- a/nanovdb/nanovdb/math/DitherLUT.h +++ b/nanovdb/nanovdb/math/DitherLUT.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Jeff Lait /// diff --git a/nanovdb/nanovdb/math/HDDA.h b/nanovdb/nanovdb/math/HDDA.h index 420692c833..c72a58a717 100644 --- a/nanovdb/nanovdb/math/HDDA.h +++ b/nanovdb/nanovdb/math/HDDA.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file HDDA.h /// diff --git a/nanovdb/nanovdb/math/Math.h b/nanovdb/nanovdb/math/Math.h index 84100d499c..da3a616248 100644 --- a/nanovdb/nanovdb/math/Math.h +++ b/nanovdb/nanovdb/math/Math.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file Math.h diff --git a/nanovdb/nanovdb/math/Ray.h b/nanovdb/nanovdb/math/Ray.h index 9f08288007..236982f395 100644 --- a/nanovdb/nanovdb/math/Ray.h +++ b/nanovdb/nanovdb/math/Ray.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file Ray.h /// diff --git a/nanovdb/nanovdb/math/SampleFromVoxels.h b/nanovdb/nanovdb/math/SampleFromVoxels.h index e4f1e26018..d183f74a58 100644 --- a/nanovdb/nanovdb/math/SampleFromVoxels.h +++ b/nanovdb/nanovdb/math/SampleFromVoxels.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 ////////////////////////////////////////////////////////////////////////// /// diff --git a/nanovdb/nanovdb/math/Stencils.h b/nanovdb/nanovdb/math/Stencils.h index cc935bf827..e46638106c 100644 --- a/nanovdb/nanovdb/math/Stencils.h +++ b/nanovdb/nanovdb/math/Stencils.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Ken Museth /// diff --git a/nanovdb/nanovdb/python/CMakeLists.txt b/nanovdb/nanovdb/python/CMakeLists.txt new file mode 100644 index 0000000000..d5c50792ee --- /dev/null +++ b/nanovdb/nanovdb/python/CMakeLists.txt @@ -0,0 +1,57 @@ +option(NANOVDB_BUILD_PYTHON_UNITTESTS [=[ + "Include the NanoVDB Python unit test. Requires a python interpreter]=] +${NANOVDB_BUILD_UNITTESTS}) + +nanobind_add_module(nanovdb_python NB_STATIC + NanoVDBModule.cc + PyCreateNanoGrid.cc + PyGridChecksum.cc + PyGridHandle.cc + PyGridStats.cc + PyGridValidator.cc + PyHostBuffer.cc + PyIO.cc + PyMath.cc + PyNanoToOpenVDB.cc + PyPrimitives.cc + PySampleFromVoxels.cc + PyTools.cc + cuda/PyDeviceBuffer.cc + cuda/PyDeviceGridHandle.cu + cuda/PyPointsToGrid.cu + cuda/PySampleFromVoxels.cu + cuda/PySignedFloodFill.cu +) + +target_include_directories(nanovdb_python PRIVATE ${CUDA_INCLUDE_DIRECTORY}) +target_link_libraries(nanovdb_python PRIVATE nanovdb ${CUDA_LIBRARIES} ${NANOVDB_BLOSC} ${NANOVDB_ZLIB} ${NANOVDB_OPENVDB} ${NANOVDB_TBB}) +target_compile_definitions(nanovdb_python PRIVATE ${NANOVDB_USE_CUDA_FLAG} ${NANOVDB_USE_BLOSC_FLAG} ${NANOVDB_USE_ZLIB_FLAG} ${NANOVDB_USE_OPENVDB_FLAG} ${NANOVDB_USE_TBB_FLAG}) +set_target_properties(nanovdb_python PROPERTIES OUTPUT_NAME "nanovdb") +if(SKBUILD) + set_target_properties(nanovdb_python PROPERTIES INSTALL_RPATH "$ORIGIN/../../openvdb/lib") + install(TARGETS nanovdb_python DESTINATION ${NANOVDB_INSTALL_LIBDIR}) + install(FILES __init__.py DESTINATION nanovdb) +else() + install(TARGETS nanovdb_python DESTINATION ${VDB_PYTHON_INSTALL_DIRECTORY}) +endif() + +# pytest +if(NANOVDB_BUILD_PYTHON_UNITTESTS) + + set(NANOVDB_PYTHON_WORKING_DIR "${CMAKE_CURRENT_BINARY_DIR}") + if(WIN32) + set(NANOVDB_PYTHON_WORKING_DIR "${NANOVDB_PYTHON_WORKING_DIR}/$") + endif() + + add_test(NAME pytest_nanovdb + COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/TestNanoVDB.py -v + WORKING_DIRECTORY "${NANOVDB_PYTHON_WORKING_DIR}") + + if(WIN32) + set(PYTHONPATH "$ENV{PYTHONPATH};${NANOVDB_PYTHON_WORKING_DIR}") + string(REPLACE "\\;" ";" PYTHONPATH "${PYTHONPATH}") + string(REPLACE ";" "\\;" PYTHONPATH "${PYTHONPATH}") + else() + set_tests_properties(pytest_nanovdb PROPERTIES ENVIRONMENT "PYTHONPATH=$ENV{PYTHONPATH}:${NANOVDB_PYTHON_WORKING_DIR}") + endif() +endif() diff --git a/nanovdb/nanovdb/python/NanoVDBModule.cc b/nanovdb/nanovdb/python/NanoVDBModule.cc new file mode 100644 index 0000000000..583b5464f9 --- /dev/null +++ b/nanovdb/nanovdb/python/NanoVDBModule.cc @@ -0,0 +1,413 @@ +#include +#include +#include +#include + +#include +#include // for __repr__ +#ifdef NANOVDB_USE_CUDA +#include +#endif + +#include + +#include "cuda/PyDeviceBuffer.h" +#include "PyGridHandle.h" +#include "PyHostBuffer.h" +#include "PyIO.h" +#include "PyMath.h" +#include "PyTools.h" +#include "PyGridChecksum.h" + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace pynanovdb { + +void defineVersion(nb::module_& m) +{ + nb::class_(m, "Version", "Bit-compacted representation of all three version numbers") + .def(nb::init<>()) + .def(nb::init(), "data"_a) + .def(nb::init(), "major"_a, "minor"_a, "patch"_a) + .def(nb::self == nb::self, "rhs"_a) + .def(nb::self < nb::self, "rhs"_a) + .def(nb::self <= nb::self, "rhs"_a) + .def(nb::self > nb::self, "rhs"_a) + .def(nb::self >= nb::self, "rhs"_a) + .def("id", &Version::id) + .def("getMajor", &Version::getMajor) + .def("getMinor", &Version::getMinor) + .def("getPatch", &Version::getPatch) + .def("age", &Version::age) + .def("__repr__", [](const Version& version) { + char str[strlen()]; + toStr(str, version); + return std::string(str); + }); +} + +void definePointTypes(nb::module_& m) +{ + nb::enum_(m, "PointType") + .value("Disable", PointType::Disable) + .value("PointID", PointType::PointID) + .value("World64", PointType::World64) + .value("World32", PointType::World32) + .value("Grid64", PointType::Grid64) + .value("Grid32", PointType::Grid32) + .value("Voxel32", PointType::Voxel32) + .value("Voxel16", PointType::Voxel16) + .value("Voxel8", PointType::Voxel8) + .value("Default", PointType::Default) + .value("End", PointType::End); +} + +template void defineMask(nb::module_& m, const char* name, const char* doc) +{ + nb::class_>(m, name, doc) + .def_static("memUsage", &Mask::memUsage) + .def_static("bitCount", &Mask::bitCount) + .def_static("wordCount", &Mask::wordCount) + .def("countOn", nb::overload_cast<>(&Mask::countOn, nb::const_)) + .def("countOn", nb::overload_cast(&Mask::countOn, nb::const_), "i"_a) + .def(nb::init<>()) + .def(nb::init(), "on"_a) + .def(nb::init>(), "other"_a) + .def(nb::self == nb::self, "other"_a) + .def(nb::self != nb::self, "other"_a) + .def("isOn", nb::overload_cast(&Mask::isOn, nb::const_), "n"_a) + .def("isOff", nb::overload_cast(&Mask::isOff, nb::const_), "n"_a) + .def("isOn", nb::overload_cast<>(&Mask::isOn, nb::const_)) + .def("isOff", nb::overload_cast<>(&Mask::isOff, nb::const_)) + .def("setOn", nb::overload_cast(&Mask::setOn), "n"_a) + .def("setOff", nb::overload_cast(&Mask::setOff), "n"_a) + .def("set", nb::overload_cast(&Mask::set), "n"_a, "on"_a) + .def("setOn", nb::overload_cast<>(&Mask::setOn)) + .def("setOff", nb::overload_cast<>(&Mask::setOff)) + .def("set", nb::overload_cast(&Mask::set), "on"_a) + .def("toggle", nb::overload_cast<>(&Mask::toggle)) + .def("toggle", nb::overload_cast(&Mask::toggle), "n"_a) + .def( + "__iand__", [](Mask& a, const Mask& b) { return a &= b; }, nb::is_operator(), "other"_a) + .def( + "__ior__", [](Mask& a, const Mask& b) { return a |= b; }, nb::is_operator(), "other"_a) + .def( + "__isub__", [](Mask& a, const Mask& b) { return a -= b; }, nb::is_operator(), "other"_a) + .def( + "__ixor__", [](Mask& a, const Mask& b) { return a ^= b; }, nb::is_operator(), "other"_a) + .def("findFirstOn", &Mask::template findFirst) + .def("findFirstOff", &Mask::template findFirst) + .def("findNextOn", &Mask::template findNext, "start"_a) + .def("findNextOff", &Mask::template findNext, "start"_a) + .def("findPrevOn", &Mask::template findPrev, "start"_a) + .def("findPrevOff", &Mask::template findPrev, "start"_a); +} + +void defineMap(nb::module_& m) +{ + nb::class_(m, "Map", "Defines an affine transform and its inverse represented as a 3x3 matrix and a vec3 translation") + .def(nb::init<>()) + .def(nb::init(), "s"_a, "t"_a = Vec3d(0.)) + .def("set", nb::overload_cast(&Map::template set), "scale"_a, "translation"_a, "taper"_a = 1.) + .def("set", nb::overload_cast(&Map::template set), "scale"_a, "translation"_a, "taper"_a = 1.) + .def("applyMap", nb::overload_cast(&Map::template applyMap, nb::const_), "ijk"_a) + .def("applyMap", nb::overload_cast(&Map::template applyMap, nb::const_), "ijk"_a) + .def("applyMapF", nb::overload_cast(&Map::template applyMapF, nb::const_), "ijk"_a) + .def("applyMapF", nb::overload_cast(&Map::template applyMapF, nb::const_), "ijk"_a) + .def("applyJacobian", nb::overload_cast(&Map::template applyJacobian, nb::const_), "ijk"_a) + .def("applyJacobian", nb::overload_cast(&Map::template applyJacobian, nb::const_), "ijk"_a) + .def("applyJacobianF", nb::overload_cast(&Map::template applyJacobianF, nb::const_), "ijk"_a) + .def("applyJacobianF", nb::overload_cast(&Map::template applyJacobianF, nb::const_), "ijk"_a) + .def("applyInverseMap", nb::overload_cast(&Map::template applyInverseMap, nb::const_), "xyz"_a) + .def("applyInverseMap", nb::overload_cast(&Map::template applyInverseMap, nb::const_), "xyz"_a) + .def("applyInverseMapF", nb::overload_cast(&Map::template applyInverseMapF, nb::const_), "xyz"_a) + .def("applyInverseMapF", nb::overload_cast(&Map::template applyInverseMapF, nb::const_), "xyz"_a) + .def("applyInverseJacobian", nb::overload_cast(&Map::template applyInverseJacobian, nb::const_), "xyz"_a) + .def("applyInverseJacobian", nb::overload_cast(&Map::template applyInverseJacobian, nb::const_), "xyz"_a) + .def("applyInverseJacobianF", nb::overload_cast(&Map::template applyInverseJacobianF, nb::const_), "xyz"_a) + .def("applyInverseJacobianF", nb::overload_cast(&Map::template applyInverseJacobianF, nb::const_), "xyz"_a) + .def("applyIJT", nb::overload_cast(&Map::template applyIJT, nb::const_), "xyz"_a) + .def("applyIJT", nb::overload_cast(&Map::template applyIJT, nb::const_), "xyz"_a) + .def("applyIJTF", nb::overload_cast(&Map::template applyIJTF, nb::const_), "xyz"_a) + .def("applyIJTF", nb::overload_cast(&Map::template applyIJTF, nb::const_), "xyz"_a) + .def("getVoxelSize", &Map::getVoxelSize); +} + +void defineGridData(nb::module_& m) +{ + nb::class_(m, "GridData") + .def("isValid", &GridData::isValid) + .def("setMinMaxOn", &GridData::setMinMaxOn, "on"_a = true) + .def("setBBoxOn", &GridData::setBBoxOn, "on"_a = true) + .def("setLongGridNameOn", &GridData::setLongGridNameOn, "on"_a = true) + .def("setAverageOn", &GridData::setAverageOn, "on"_a = true) + .def("setStdDeviationOn", &GridData::setStdDeviationOn, "on"_a = true) + .def("setGridName", &GridData::setGridName, "src"_a) + .def("applyMap", nb::overload_cast(&GridData::template applyMap, nb::const_), "xyz"_a) + .def("applyMap", nb::overload_cast(&GridData::template applyMap, nb::const_), "xyz"_a) + .def("applyMapF", nb::overload_cast(&GridData::template applyMapF, nb::const_), "xyz"_a) + .def("applyMapF", nb::overload_cast(&GridData::template applyMapF, nb::const_), "xyz"_a) + .def("applyJacobian", nb::overload_cast(&GridData::template applyJacobian, nb::const_), "xyz"_a) + .def("applyJacobian", nb::overload_cast(&GridData::template applyJacobian, nb::const_), "xyz"_a) + .def("applyJacobianF", nb::overload_cast(&GridData::template applyJacobianF, nb::const_), "xyz"_a) + .def("applyJacobianF", nb::overload_cast(&GridData::template applyJacobianF, nb::const_), "xyz"_a) + .def("applyInverseMap", nb::overload_cast(&GridData::template applyInverseMap, nb::const_), "xyz"_a) + .def("applyInverseMap", nb::overload_cast(&GridData::template applyInverseMap, nb::const_), "xyz"_a) + .def("applyInverseMapF", nb::overload_cast(&GridData::template applyInverseMapF, nb::const_), "xyz"_a) + .def("applyInverseMapF", nb::overload_cast(&GridData::template applyInverseMapF, nb::const_), "xyz"_a) + .def("applyInverseJacobian", nb::overload_cast(&GridData::template applyInverseJacobian, nb::const_), "xyz"_a) + .def("applyInverseJacobian", nb::overload_cast(&GridData::template applyInverseJacobian, nb::const_), "xyz"_a) + .def("applyInverseJacobianF", nb::overload_cast(&GridData::template applyInverseJacobianF, nb::const_), "xyz"_a) + .def("applyInverseJacobianF", nb::overload_cast(&GridData::template applyInverseJacobianF, nb::const_), "xyz"_a) + .def("applyIJT", nb::overload_cast(&GridData::template applyIJT, nb::const_), "xyz"_a) + .def("applyIJT", nb::overload_cast(&GridData::template applyIJT, nb::const_), "xyz"_a) + .def("applyIJTF", nb::overload_cast(&GridData::template applyIJTF, nb::const_), "xyz"_a) + .def("applyIJTF", nb::overload_cast(&GridData::template applyIJTF, nb::const_), "xyz"_a) + .def("gridName", &GridData::gridName) + .def("memUsage", &GridData::memUsage) + .def("worldBBox", &GridData::worldBBox) + .def("indexBBox", &GridData::indexBBox) + .def("isEmpty", &GridData::isEmpty); +} + +template void defineGrid(nb::module_& m, const char* name) +{ + nb::class_, GridData>(m, name) + .def("version", &NanoGrid::version) + .def("memUsage", &NanoGrid::memUsage) + .def("gridSize", &NanoGrid::gridSize) + .def("gridIndex", &NanoGrid::gridIndex) + .def("gridCount", &NanoGrid::gridCount) + .def("getAccessor", &NanoGrid::getAccessor) + .def("voxelSize", &NanoGrid::voxelSize) + .def("map", &NanoGrid::map) + .def("worldBBox", &NanoGrid::worldBBox) + .def("indexBBox", &NanoGrid::indexBBox) + .def("activeVoxelCount", &NanoGrid::activeVoxelCount) + .def("isValid", &NanoGrid::isValid) + .def("gridType", &NanoGrid::gridType) + .def("gridClass", &NanoGrid::gridClass) + .def("isLevelSet", &NanoGrid::isLevelSet) + .def("isFogVolume", &NanoGrid::isFogVolume) + .def("isStaggered", &NanoGrid::isStaggered) + .def("isPointIndex", &NanoGrid::isPointIndex) + .def("isGridIndex", &NanoGrid::isGridIndex) + .def("isPointData", &NanoGrid::isPointData) + .def("isMask", &NanoGrid::isMask) + .def("isUnknown", &NanoGrid::isUnknown) + .def("hasMinMax", &NanoGrid::hasMinMax) + .def("hasBBox", &NanoGrid::hasBBox) + .def("hasLongGridName", &NanoGrid::hasLongGridName) + .def("hasAverage", &NanoGrid::hasAverage) + .def("hasStdDeviation", &NanoGrid::hasStdDeviation) + .def("isBreadthFirst", &NanoGrid::isBreadthFirst) + // .def("isLexicographic", &NanoGrid::isLexicographic) + .def("isSequential", [](const NanoGrid& grid) { return grid.isSequential(); }) + .def("gridName", &NanoGrid::gridName) + .def("shortGridName", &NanoGrid::shortGridName) + .def("checksum", &NanoGrid::checksum) + .def("isEmpty", &NanoGrid::isEmpty); +} + +template nb::class_> defineAccessor(nb::module_& m, const char* name) +{ + using ValueType = typename DefaultReadAccessor::ValueType; + using CoordType = typename DefaultReadAccessor::CoordType; + + nb::class_> accessor(m, name); + accessor.def(nb::init&>(), "grid"_a) + .def("getValue", nb::overload_cast(&DefaultReadAccessor::getValue, nb::const_), "ijk"_a) + .def("getValue", nb::overload_cast(&DefaultReadAccessor::getValue, nb::const_), "i"_a, "j"_a, "k"_a) + .def( + "__call__", [](const DefaultReadAccessor& accessor, const CoordType& ijk) { return accessor.getValue(ijk); }, nb::is_operator(), "ijk"_a) + .def( + "__call__", + [](const DefaultReadAccessor& accessor, int i, int j, int k) { return accessor.getValue(i, j, k); }, + nb::is_operator(), + "i"_a, + "j"_a, + "k"_a) + .def("isActive", &DefaultReadAccessor::isActive, "ijk"_a) + .def( + "probeValue", + [](const DefaultReadAccessor& accessor, const CoordType& ijk) { + ValueType v; + bool isOn = accessor.probeValue(ijk, v); + return std::make_tuple(v, isOn); + }, + "ijk"_a); + return accessor; +} + +template void defineScalarAccessor(nb::module_& m, const char* name) +{ + using ValueType = typename DefaultReadAccessor::ValueType; + using CoordType = typename DefaultReadAccessor::CoordType; + + defineAccessor(m, name) + .def("getNodeInfo", &DefaultReadAccessor::getNodeInfo, "ijk"_a) + .def( + "setVoxel", + [](DefaultReadAccessor& accessor, const CoordType& ijk, const ValueType& v) { + using OpT = SetVoxel; + accessor.template set(ijk, v); + }, + "ijk"_a, + "v"_a); +} + +template void defineVectorAccessor(nb::module_& m, const char* name) +{ + using ValueType = typename DefaultReadAccessor::ValueType; + using CoordType = typename DefaultReadAccessor::CoordType; + + defineAccessor(m, name).def( + "setVoxel", + [](DefaultReadAccessor& accessor, const CoordType& ijk, const ValueType& v) { + using OpT = SetVoxel; + accessor.template set(ijk, v); + }, + "ijk"_a, + "v"_a); +} + +template void defineNodeInfo(nb::module_& m, const char* name) +{ + nb::class_::NodeInfo>(m, name) + .def_ro("level", &GetNodeInfo::NodeInfo::level) + .def_ro("dim", &GetNodeInfo::NodeInfo::dim) + .def_ro("minimum", &GetNodeInfo::NodeInfo::minimum) + .def_ro("maximum", &GetNodeInfo::NodeInfo::maximum) + .def_ro("average", &GetNodeInfo::NodeInfo::average) + .def_ro("stdDevi", &GetNodeInfo::NodeInfo::stdDevi) + .def_ro("bbox", &GetNodeInfo::NodeInfo::bbox); +} + +bool isCudaAvailable() +{ +#ifdef NANOVDB_USE_CUDA + return true; +#else + return false; +#endif +} + +NB_MODULE(nanovdb, m) +{ + m.doc() = "Python module for NanoVDB"; + m.def("isCudaAvailable", &isCudaAvailable, "Returns whether or not the module was compiled with CUDA support"); + + nb::enum_(m, "GridType") + .value("Unknown", GridType::Unknown) + .value("Float", GridType::Float) + .value("Double", GridType::Double) + .value("Int16", GridType::Int16) + .value("Int32", GridType::Int32) + .value("Int64", GridType::Int64) + .value("Vec3f", GridType::Vec3f) + .value("Vec3d", GridType::Vec3d) + .value("Mask", GridType::Mask) + .value("Half", GridType::Half) + .value("UInt32", GridType::UInt32) + .value("Boolean", GridType::Boolean) + .value("RGBA8", GridType::RGBA8) + .value("Fp4", GridType::Fp4) + .value("Fp8", GridType::Fp8) + .value("Fp16", GridType::Fp16) + .value("FpN", GridType::FpN) + .value("Vec4f", GridType::Vec4f) + .value("Vec4d", GridType::Vec4d) + .value("Index", GridType::Index) + .value("OnIndex", GridType::OnIndex) + .value("IndexMask", GridType::IndexMask) + .value("OnIndexMask", GridType::OnIndexMask) + .value("PointIndex", GridType::PointIndex) + .value("Vec3u8", GridType::Vec3u8) + .value("Vec3u16", GridType::Vec3u16) + .value("End", GridType::End) + .export_values(); + // .def("__repr__", [](const GridType& gridType) { + // char str[strlen()]; + // toStr(str, gridType); + // return std::string(str); + // }); + + nb::enum_(m, "GridClass") + .value("Unknown", GridClass::Unknown) + .value("LevelSet", GridClass::LevelSet) + .value("FogVolume", GridClass::FogVolume) + .value("Staggered", GridClass::Staggered) + .value("PointIndex", GridClass::PointIndex) + .value("PointData", GridClass::PointData) + .value("Topology", GridClass::Topology) + .value("VoxelVolume", GridClass::VoxelVolume) + .value("IndexGrid", GridClass::IndexGrid) + .value("TensorGrid", GridClass::TensorGrid) + .value("End", GridClass::End) + .export_values(); + // .def("__repr__", [](const GridClass& gridClass) { + // char str[strlen()]; + // toStr(str, gridClass); + // return std::string(str); + // }); + + defineVersion(m); + + nb::module_ mathModule = m.def_submodule("math"); + mathModule.doc() = "A submodule that implements math functions"; + defineMathModule(mathModule); + + definePointTypes(m); + + defineMask<5>(m, "UpperInternalNodeMask", "Bit-mask for encoding active states of upper internal nodes"); + defineMask<4>(m, "LowerInternalNodeMask", "Bit-mask for encoding active states of lower internal nodes"); + defineMask<3>(m, "LeafMask", "Bit-mask for encoding active states of leaf nodes"); + + defineMap(m); + + defineGridData(m); + + defineGrid(m, "FloatGrid"); + defineScalarAccessor(m, "FloatReadAccessor"); + defineNodeInfo(m, "FloatNodeInfo"); + + defineGrid(m, "DoubleGrid"); + defineScalarAccessor(m, "DoubleReadAccessor"); + defineNodeInfo(m, "DoubleNodeInfo"); + + defineGrid(m, "Int32Grid"); + defineScalarAccessor(m, "Int32ReadAccessor"); + defineNodeInfo(m, "Int32NodeInfo"); + + defineGrid(m, "Vec3fGrid"); + defineVectorAccessor(m, "Vec3fReadVectorAccessor"); + + defineGrid(m, "RGBA8Grid"); + defineVectorAccessor(m, "RGBA8ReadAccessor"); + + defineGrid(m, "PointGrid"); + defineAccessor(m, "PointReadAccessor"); + + defineHostBuffer(m); + defineHostGridHandle(m); + + defineCheckMode(m); + defineChecksum(m); + +#ifdef NANOVDB_USE_CUDA + defineDeviceBuffer(m); + defineDeviceGridHandle(m); +#endif + + nb::module_ toolsModule = m.def_submodule("tools"); + toolsModule.doc() = "A submodule that implements tools for NanoVDB grids"; + defineToolsModule(toolsModule); + + nb::module_ ioModule = m.def_submodule("io"); + ioModule.doc() = "A submodule that implements I/O functionality for NanoVDB grids"; + defineIOModule(ioModule); +} + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PyCreateNanoGrid.cc b/nanovdb/nanovdb/python/PyCreateNanoGrid.cc new file mode 100644 index 0000000000..c776865306 --- /dev/null +++ b/nanovdb/nanovdb/python/PyCreateNanoGrid.cc @@ -0,0 +1,53 @@ +#include "PyCreateNanoGrid.h" + +#include +#include +#ifdef NANOVDB_USE_OPENVDB +#include +#endif + +#include +#include + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace pynanovdb { + +namespace { + +template +GridHandle createNanoGridFromFunc(const BuildT& background, + const std::string& name, + GridClass gridClass, + const std::function& func, + const CoordBBox& bbox) +{ + nanovdb::tools::build::Grid srcGrid(background, name, gridClass); + srcGrid(func, bbox); + return nanovdb::tools::createNanoGrid(srcGrid); +} + +} // namespace + +template void defineCreateNanoGrid(nb::module_& m, const char* name) +{ + m.def(name, &createNanoGridFromFunc, nb::call_guard(), "background"_a, "name"_a, "gridClass"_a, "func"_a, "bbox"_a); +} + +template void defineOpenToNanoVDB(nb::module_& m) +{ +#ifdef NANOVDB_USE_OPENVDB + m.def("openToNanoVDB", &tools::openToNanoVDB, "base"_a, "sMode"_a = tools::StatsMode::Default, "cMode"_a = CheckMode::Default, "verbose"_a = 0); +#endif +} + +template void defineCreateNanoGrid(nb::module_&, const char*); +template void defineCreateNanoGrid(nb::module_&, const char*); +template void defineCreateNanoGrid(nb::module_&, const char*); +template void defineCreateNanoGrid(nb::module_&, const char*); + +template void defineOpenToNanoVDB(nb::module_&); + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PyCreateNanoGrid.h b/nanovdb/nanovdb/python/PyCreateNanoGrid.h new file mode 100644 index 0000000000..863ca1b396 --- /dev/null +++ b/nanovdb/nanovdb/python/PyCreateNanoGrid.h @@ -0,0 +1,18 @@ +#ifndef NANOVDB_PYCREATENANOGRID_HAS_BEEN_INCLUDED +#define NANOVDB_PYCREATENANOGRID_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +template void defineCreateNanoGrid(nb::module_& m, const char* name); + +#ifdef NANOVDB_USE_OPENVDB +template void defineOpenToNanoVDB(nb::module_& m); +#endif + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/PyGridChecksum.cc b/nanovdb/nanovdb/python/PyGridChecksum.cc new file mode 100644 index 0000000000..ba6e709b10 --- /dev/null +++ b/nanovdb/nanovdb/python/PyGridChecksum.cc @@ -0,0 +1,34 @@ +#include "PyGridChecksum.h" + +#include + +#include + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace pynanovdb { + +void defineCheckMode(nb::module_& m) +{ + nb::enum_(m, "CheckMode") + .value("Disable", CheckMode::Disable) + .value("Partial", CheckMode::Partial) + .value("Full", CheckMode::Full) + .value("Default", CheckMode::Default) + .value("End", CheckMode::End); +} + +void defineChecksum(nb::module_& m) +{ + nb::class_(m, "Checksum").def(nb::self == nb::self, "rhs"_a).def(nb::self != nb::self, "rhs"_a); +} + +void defineUpdateChecksum(nb::module_& m) +{ + m.def( + "updateChecksum", [](GridData* gridData, CheckMode mode) { tools::updateChecksum(gridData, mode); }, "gridData"_a, "mode"_a); +} + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PyGridChecksum.h b/nanovdb/nanovdb/python/PyGridChecksum.h new file mode 100644 index 0000000000..f8c2048b83 --- /dev/null +++ b/nanovdb/nanovdb/python/PyGridChecksum.h @@ -0,0 +1,16 @@ +#ifndef NANOVDB_PYGRIDCHECKSUM_HAS_BEEN_INCLUDED +#define NANOVDB_PYGRIDCHECKSUM_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +void defineCheckMode(nb::module_& m); +void defineChecksum(nb::module_& m); +void defineUpdateChecksum(nb::module_& m); + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/PyGridHandle.cc b/nanovdb/nanovdb/python/PyGridHandle.cc new file mode 100644 index 0000000000..4f4e8ff72d --- /dev/null +++ b/nanovdb/nanovdb/python/PyGridHandle.cc @@ -0,0 +1,25 @@ +#include "PyGridHandle.h" +#include + +#include + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace pynanovdb { + +void defineHostGridHandle(nb::module_& m) +{ + using BufferT = HostBuffer; + defineGridHandle(m, "GridHandle") + .def( + "__init__", + [](GridHandle& handle, nb::ndarray, nb::device::cpu> t) { + auto buffer = BufferT::createFull(t.size() * sizeof(uint32_t), t.data()); + new (&handle) GridHandle(std::move(buffer)); + }, + "t"_a.noconvert()); +} + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PyGridHandle.h b/nanovdb/nanovdb/python/PyGridHandle.h new file mode 100644 index 0000000000..a15c588c83 --- /dev/null +++ b/nanovdb/nanovdb/python/PyGridHandle.h @@ -0,0 +1,73 @@ +#ifndef NANOVDB_PYGRIDHANDLE_HAS_BEEN_INCLUDED +#define NANOVDB_PYGRIDHANDLE_HAS_BEEN_INCLUDED + +#include +#include + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +template nb::class_> defineGridHandle(nb::module_& m, const char* name) +{ + return nb::class_>(m, name) + .def(nb::init<>()) + .def("reset", &nanovdb::GridHandle::reset) + .def("size", &nanovdb::GridHandle::size) + .def("isEmpty", &nanovdb::GridHandle::isEmpty) + .def("empty", &nanovdb::GridHandle::empty) + .def( + "__bool__", [](const nanovdb::GridHandle& handle) { handle.empty(); }, nb::is_operator()) + .def("floatGrid", nb::overload_cast(&nanovdb::GridHandle::template grid), nb::arg("n") = 0, nb::rv_policy::reference_internal) + .def("doubleGrid", + nb::overload_cast(&nanovdb::GridHandle::template grid), + nb::arg("n") = 0, + nb::rv_policy::reference_internal) + .def("int32Grid", + nb::overload_cast(&nanovdb::GridHandle::template grid), + nb::arg("n") = 0, + nb::rv_policy::reference_internal) + .def("vec3fGrid", + nb::overload_cast(&nanovdb::GridHandle::template grid), + nb::arg("n") = 0, + nb::rv_policy::reference_internal) + .def("rgba8Grid", + nb::overload_cast(&nanovdb::GridHandle::template grid), + nb::arg("n") = 0, + nb::rv_policy::reference_internal) + .def("isPadded", &nanovdb::GridHandle::isPadded) + .def("gridCount", &nanovdb::GridHandle::gridCount) + .def("gridSize", &nanovdb::GridHandle::gridSize, nb::arg("n") = 0) + .def("gridType", &nanovdb::GridHandle::gridType, nb::arg("n") = 0) + .def( + "gridData", + [](nanovdb::GridHandle& handle, uint32_t n) { return nb::bytes(handle.gridData(n), handle.gridSize(n)); }, + nb::arg("n") = 0, + nb::rv_policy::reference_internal) + .def("write", nb::overload_cast(&nanovdb::GridHandle::write, nb::const_), nb::arg("fileName")) + .def("write", nb::overload_cast(&nanovdb::GridHandle::write, nb::const_), nb::arg("fileName"), nb::arg("n")) + .def( + "read", [](nanovdb::GridHandle& handle, const std::string& fileName) { handle.read(fileName); }, nb::arg("fileName")) + .def( + "read", + [](nanovdb::GridHandle& handle, const std::string& fileName, uint32_t n) { handle.read(fileName, n); }, + nb::arg("fileName"), + nb::arg("n")) + .def( + "read", + [](nanovdb::GridHandle& handle, const std::string& fileName, const std::string& gridName) { handle.read(fileName, gridName); }, + nb::arg("fileName"), + nb::arg("gridName")); + +} + +void defineHostGridHandle(nb::module_& m); +#ifdef NANOVDB_USE_CUDA +void defineDeviceGridHandle(nb::module_& m); +#endif + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/PyGridStats.cc b/nanovdb/nanovdb/python/PyGridStats.cc new file mode 100644 index 0000000000..7f8598a7ac --- /dev/null +++ b/nanovdb/nanovdb/python/PyGridStats.cc @@ -0,0 +1,21 @@ +#include "PyGridStats.h" + +#include + +namespace nb = nanobind; +using namespace nanovdb; + +namespace pynanovdb { + +void defineStatsMode(nb::module_& m) +{ + nb::enum_(m, "StatsMode") + .value("Disable", tools::StatsMode::Disable) + .value("BBox", tools::StatsMode::BBox) + .value("MinMax", tools::StatsMode::MinMax) + .value("All", tools::StatsMode::All) + .value("Default", tools::StatsMode::Default) + .value("End", tools::StatsMode::End); +} + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PyGridStats.h b/nanovdb/nanovdb/python/PyGridStats.h new file mode 100644 index 0000000000..c53af4567d --- /dev/null +++ b/nanovdb/nanovdb/python/PyGridStats.h @@ -0,0 +1,14 @@ +#ifndef NANOVDB_PYGRIDSTATS_HAS_BEEN_INCLUDED +#define NANOVDB_PYGRIDSTATS_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +void defineStatsMode(nb::module_& m); + +} + +#endif diff --git a/nanovdb/nanovdb/python/PyGridValidator.cc b/nanovdb/nanovdb/python/PyGridValidator.cc new file mode 100644 index 0000000000..278588b466 --- /dev/null +++ b/nanovdb/nanovdb/python/PyGridValidator.cc @@ -0,0 +1,27 @@ +#include "PyGridValidator.h" + +#include +#include +#ifdef NANOVDB_USE_CUDA +#include +#endif + +#include + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace pynanovdb { + +template void defineValidateGrids(nb::module_& m) +{ + m.def("validateGrids", &tools::validateGrids>, "handle"_a, "mode"_a, "verbose"_a); +} + +template void defineValidateGrids(nb::module_&); +#ifdef NANOVDB_USE_CUDA +template void defineValidateGrids(nb::module_&); +#endif + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PyGridValidator.h b/nanovdb/nanovdb/python/PyGridValidator.h new file mode 100644 index 0000000000..6725f88b4d --- /dev/null +++ b/nanovdb/nanovdb/python/PyGridValidator.h @@ -0,0 +1,14 @@ +#ifndef NANOVDB_PYGRIDVALIDATOR_HAS_BEEN_INCLUDED +#define NANOVDB_PYGRIDVALIDATOR_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +template void defineValidateGrids(nb::module_& m); + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/PyHostBuffer.cc b/nanovdb/nanovdb/python/PyHostBuffer.cc new file mode 100644 index 0000000000..4af48c2040 --- /dev/null +++ b/nanovdb/nanovdb/python/PyHostBuffer.cc @@ -0,0 +1,15 @@ +#include "PyHostBuffer.h" + +#include + +namespace nb = nanobind; +using namespace nanovdb; + +namespace pynanovdb { + +void defineHostBuffer(nb::module_& m) +{ + nb::class_(m, "HostBuffer"); +} + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PyHostBuffer.h b/nanovdb/nanovdb/python/PyHostBuffer.h new file mode 100644 index 0000000000..f1bf704edc --- /dev/null +++ b/nanovdb/nanovdb/python/PyHostBuffer.h @@ -0,0 +1,14 @@ +#ifndef NANOVDB_PYHOSTBUFFER_HAS_BEEN_INCLUDED +#define NANOVDB_PYHOSTBUFFER_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +void defineHostBuffer(nb::module_& m); + +} + +#endif diff --git a/nanovdb/nanovdb/python/PyIO.cc b/nanovdb/nanovdb/python/PyIO.cc new file mode 100644 index 0000000000..d77cb40f86 --- /dev/null +++ b/nanovdb/nanovdb/python/PyIO.cc @@ -0,0 +1,153 @@ +#include "PyIO.h" + +#include +#ifdef NANOVDB_USE_CUDA +#include +#endif + +#include +#include +#include + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace pynanovdb { + +namespace { + +void defineFileGridMetaData(nb::module_& m) +{ + nb::class_(m, "FileMetaData") + .def_ro("gridSize", &io::FileMetaData::gridSize) + .def_ro("fileSize", &io::FileMetaData::fileSize) + .def_ro("nameKey", &io::FileMetaData::nameKey) + .def_ro("voxelCount", &io::FileMetaData::voxelCount) + .def_ro("gridType", &io::FileMetaData::gridType) + .def_ro("gridClass", &io::FileMetaData::gridClass) + .def_ro("indexBBox", &io::FileMetaData::indexBBox) + .def_ro("worldBBox", &io::FileMetaData::worldBBox) + .def_ro("voxelSize", &io::FileMetaData::voxelSize) + .def_ro("nameSize", &io::FileMetaData::nameSize) + .def_prop_ro("nodeCount", + [](io::FileMetaData& metaData) { + return std::make_tuple(metaData.nodeCount[0], metaData.nodeCount[1], metaData.nodeCount[2], metaData.nodeCount[3]); + }) + .def_prop_ro("tileCount", + [](io::FileMetaData& metaData) { return std::make_tuple(metaData.tileCount[0], metaData.tileCount[1], metaData.tileCount[2]); }) + .def_ro("codec", &io::FileMetaData::codec) + .def_ro("padding", &io::FileMetaData::padding) + .def_ro("version", &io::FileMetaData::version); + + nb::bind_vector>(m, "FileMetaDataVector"); + + nb::class_(m, "FileGridMetaData") + .def_ro("gridName", &io::FileGridMetaData::gridName) + .def("memUsage", &io::FileGridMetaData::memUsage); + + nb::bind_vector>(m, "FileGridMetaDataVector"); +} + +template void defineReadWriteGrid(nb::module_& m) +{ + m.def("hasGrid", nb::overload_cast(&io::hasGrid), "fileName"_a, "gridName"_a); + m.def("readGridMetaData", nb::overload_cast(&io::readGridMetaData), "fileName"_a); +} + +template nb::list readGrids(const std::string& fileName, int verbose, const BufferT& buffer) +{ + auto handles = nanovdb::io::readGrids(fileName, verbose, buffer); + nb::list handleList; + for (size_t i = 0; i < handles.size(); ++i) { + handleList.append(std::move(handles[i])); + } + return handleList; +} + +template void writeGrids(const std::string& fileName, nb::list handles, io::Codec codec, int verbose) +{ + for (size_t i = 0; i < handles.size(); ++i) { + nanovdb::io::writeGrid(fileName, nb::cast&>(handles[i]), codec, verbose); + } +} + +void defineHostReadWriteGrid(nb::module_& m) +{ + using BufferT = HostBuffer; + defineReadWriteGrid(m); + + m.def("writeGrid", + nb::overload_cast&, io::Codec, int>(&io::template writeGrid), + "fileName"_a, + "handle"_a, + "codec"_a = io::Codec::NONE, + "verbose"_a = 0); + m.def("writeGrids", &writeGrids, "fileName"_a, "handles"_a, "codec"_a = io::Codec::NONE, "verbose"_a = 0); + m.def("readGrid", + nb::overload_cast(&io::template readGrid), + "fileName"_a, + "n"_a = 0, + "verbose"_a = 0, + "buffer"_a = BufferT()); + m.def("readGrid", + nb::overload_cast(&io::template readGrid), + "fileName"_a, + "gridName"_a, + "verbose"_a = 0, + "buffer"_a = BufferT()); + m.def("readGrids", &readGrids, "fileName"_a, "verbose"_a = 0, "buffer"_a = BufferT()); +} + +#ifdef NANOVDB_USE_CUDA +void defineDeviceReadWriteGrid(nb::module_& m) +{ + using BufferT = cuda::DeviceBuffer; + defineReadWriteGrid(m); + + m.def("deviceWriteGrid", + nb::overload_cast&, io::Codec, int>(&io::template writeGrid), + "fileName"_a, + "handle"_a, + "codec"_a = io::Codec::NONE, + "verbose"_a = 0); + m.def("deviceWriteGrids", &writeGrids, "fileName"_a, "handles"_a, "codec"_a = io::Codec::NONE, "verbose"_a = 0); + m.def("deviceReadGrid", + nb::overload_cast(&io::template readGrid), + "fileName"_a, + "n"_a = 0, + "verbose"_a = 0, + "buffer"_a = BufferT()); + m.def("deviceReadGrid", + nb::overload_cast(&io::template readGrid), + "fileName"_a, + "gridName"_a, + "verbose"_a = 0, + "buffer"_a = BufferT()); + m.def("deviceReadGrids", &readGrids, "fileName"_a, "verbose"_a = 0, "buffer"_a = BufferT()); +} +#endif + +} // namespace + +void defineIOModule(nb::module_& m) +{ + nb::enum_(m, "Codec") + .value("NONE", io::Codec::NONE) + .value("ZIP", io::Codec::ZIP) + .value("BLOSC", io::Codec::BLOSC) + .export_values(); + // .def("__repr__", [](const io::Codec& codec) { + // char str[strlen()]; + // toStr(str, codec); + // return std::string(str); + // }); + + defineFileGridMetaData(m); + defineHostReadWriteGrid(m); +#ifdef NANOVDB_USE_CUDA + defineDeviceReadWriteGrid(m); +#endif +} + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PyIO.h b/nanovdb/nanovdb/python/PyIO.h new file mode 100644 index 0000000000..907ef0f7f9 --- /dev/null +++ b/nanovdb/nanovdb/python/PyIO.h @@ -0,0 +1,14 @@ +#ifndef NANOVDB_PYIO_HAS_BEEN_INCLUDED +#define NANOVDB_PYIO_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +void defineIOModule(nb::module_& m); + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/PyMath.cc b/nanovdb/nanovdb/python/PyMath.cc new file mode 100644 index 0000000000..06a4ad5606 --- /dev/null +++ b/nanovdb/nanovdb/python/PyMath.cc @@ -0,0 +1,407 @@ +#include "PyMath.h" + +#include + +#include +#include // for __repr__ + +#include +#include + +#include "PySampleFromVoxels.h" +#include "cuda/PySampleFromVoxels.h" + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace pynanovdb { + +namespace { + +void defineCoord(nb::module_& m) +{ + using ValueType = math::Coord::ValueType; + + nb::class_(m, "Coord", "Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord") + .def(nb::init<>()) + .def(nb::init(), "n"_a) + .def(nb::init(), "i"_a, "j"_a, "k"_a) + .def_prop_rw( + "x", [](const math::Coord& ijk) { return ijk.x(); }, [](math::Coord& ijk, int32_t i) { ijk.x() = i; }) + .def_prop_rw( + "y", [](const math::Coord& ijk) { return ijk.y(); }, [](math::Coord& ijk, int32_t j) { ijk.y() = j; }) + .def_prop_rw( + "z", [](const math::Coord& ijk) { return ijk.z(); }, [](math::Coord& ijk, int32_t k) { ijk.z() = k; }) + .def_static("max", &math::Coord::max) + .def_static("min", &math::Coord::min) + .def_static("memUsage", &math::Coord::memUsage) + .def( + "__getitem__", + [](const math::Coord& ijk, size_t i) { + if (i >= 3) { + throw nb::index_error(); + } + return ijk[static_cast(i)]; + }, + "i"_a) + .def( + "__setitem__", + [](math::Coord& ijk, size_t i, ValueType value) { + if (i >= 3) { + throw nb::index_error(); + } + ijk[static_cast(i)] = value; + }, + "i"_a, + "value"_a) + .def( + "__and__", [](const math::Coord& a, math::Coord::IndexType b) { return a & b; }, nb::is_operator(), "n"_a) + .def( + "__lshift__", [](const math::Coord& a, math::Coord::IndexType b) { return a << b; }, nb::is_operator(), "n"_a) + .def( + "__rshift__", [](const math::Coord& a, math::Coord::IndexType b) { return a >> b; }, nb::is_operator(), "n"_a) + .def(nb::self < nb::self, "rhs"_a) + .def(nb::self == nb::self, "rhs"_a) + .def(nb::self != nb::self, "rhs"_a) + .def( + "__iand__", [](math::Coord& a, int b) { return a &= b; }, nb::is_operator(), "n"_a) + .def( + "__ilshift__", [](math::Coord& a, uint32_t b) { return a <<= b; }, nb::is_operator(), "n"_a) + .def( + "__irshift__", [](math::Coord& a, uint32_t b) { return a >>= b; }, nb::is_operator(), "n"_a) + .def( + "__iadd__", [](math::Coord& a, int b) { return a += b; }, nb::is_operator(), "n"_a) + .def(nb::self + nb::self, "rhs"_a) + .def(nb::self - nb::self, "rhs"_a) + .def(-nb::self) + .def(nb::self += nb::self, "rhs"_a) + .def(nb::self -= nb::self, "rhs"_a) + .def("minComponent", &math::Coord::minComponent, "other"_a) + .def("maxComponent", &math::Coord::maxComponent, "other"_a) + .def("offsetBy", nb::overload_cast(&math::Coord::offsetBy, nb::const_), "dx"_a, "dy"_a, "dz"_a) + .def("offsetBy", nb::overload_cast(&math::Coord::offsetBy, nb::const_), "n"_a) + .def_static("lessThan", &math::Coord::lessThan, "a"_a, "b"_a) + .def_static("Floor", &math::Coord::template Floor>, "xyz"_a) + .def_static("Floor", &math::Coord::template Floor>, "xyz"_a) + .def("hash", &math::Coord::template hash<12>) + .def("octant", &math::Coord::octant) + .def("asVec3s", &math::Coord::asVec3s) + .def("asVec3d", &math::Coord::asVec3d) + .def("round", &math::Coord::round) + .def("__repr__", [](const math::Coord& ijk) { + std::stringstream ostr; + ostr << ijk; + return ostr.str(); + }); +} + +template void defineVec3(nb::module_& m, const char* name, const char* doc) +{ + nb::class_>(m, name, doc) + .def(nb::init<>()) + .def(nb::init(), "x"_a) + .def(nb::init(), "x"_a, "y"_a, "z"_a) + .def(nb::init>(), "v"_a) + .def(nb::init(), "ijk"_a) + .def(nb::self == nb::self, "rhs"_a) + .def(nb::self != nb::self, "rhs"_a) + .def( + "__getitem__", + [](const math::Vec3& v, size_t i) { + if (i >= math::Vec3::SIZE) { + throw nb::index_error(); + } + return v[static_cast(i)]; + }, + "i"_a) + .def( + "__setitem__", + [](math::Vec3& v, size_t i, T value) { + if (i >= math::Vec3::SIZE) { + throw nb::index_error(); + } + v[static_cast(i)] = value; + }, + "i"_a, + "value"_a) + .def("dot", &math::Vec3::template dot>, "v"_a) + .def("cross", &math::Vec3::template cross>, "v"_a) + .def("lengthSqr", &math::Vec3::lengthSqr) + .def("length", &math::Vec3::length) + .def(-nb::self) + .def(nb::self * nb::self, "v"_a) + .def(nb::self / nb::self, "v"_a) + .def(nb::self + nb::self, "v"_a) + .def(nb::self - nb::self, "v"_a) + .def(nb::self + math::Coord(), "ijk"_a) + .def(nb::self - math::Coord(), "ijk"_a) + .def(nb::self * T(), "s"_a) + .def(nb::self / T(), "s"_a) + .def(nb::self += nb::self, "v"_a) + .def(nb::self += math::Coord(), "ijk"_a) + .def(nb::self -= nb::self, "v"_a) + .def(nb::self -= math::Coord(), "ijk"_a) + .def(nb::self *= T(), "s"_a) + .def(nb::self /= T(), "s"_a) + .def("normalize", &math::Vec3::normalize) + .def("minComponent", &math::Vec3::minComponent, "other"_a) + .def("maxComponent", &math::Vec3::maxComponent, "other"_a) + .def("min", &math::Vec3::min) + .def("max", &math::Vec3::max) + .def("floor", &math::Vec3::floor) + .def("ceil", &math::Vec3::ceil) + .def("round", &math::Vec3::round) + .def( + "__mul__", [](const T& a, math::Vec3 b) { return a * b; }, nb::is_operator(), "b"_a) + .def( + "__truediv__", [](const T& a, math::Vec3 b) { return a / b; }, nb::is_operator(), "b"_a) + .def("__repr__", [](const math::Vec3& v) { + std::stringstream ostr; + ostr << v; + return ostr.str(); + }); +} + +template void defineVec4(nb::module_& m, const char* name, const char* doc) +{ + nb::class_>(m, name, doc) + .def(nb::init<>()) + .def(nb::init(), "x"_a) + .def(nb::init(), "x"_a, "y"_a, "z"_a, "w"_a) + .def(nb::init>(), "v"_a) + .def(nb::self == nb::self, "rhs"_a) + .def(nb::self != nb::self, "rhs"_a) + .def( + "__getitem__", + [](const math::Vec4& v, size_t i) { + if (i >= math::Vec4::SIZE) { + throw nb::index_error(); + } + return v[static_cast(i)]; + }, + "i"_a) + .def( + "__setitem__", + [](math::Vec4& v, size_t i, T value) { + if (i >= math::Vec4::SIZE) { + throw nb::index_error(); + } + v[static_cast(i)] = value; + }, + "i"_a, + "value"_a) + .def("dot", &math::Vec4::template dot>, "v"_a) + .def("lengthSqr", &math::Vec4::lengthSqr) + .def("length", &math::Vec4::length) + .def(-nb::self) + .def(nb::self * nb::self, "v"_a) + .def(nb::self / nb::self, "v"_a) + .def(nb::self + nb::self, "v"_a) + .def(nb::self - nb::self, "v"_a) + .def(nb::self * T(), "s"_a) + .def(nb::self / T(), "s"_a) + .def(nb::self += nb::self, "v"_a) + .def(nb::self -= nb::self, "v"_a) + .def(nb::self *= T(), "s"_a) + .def(nb::self /= T(), "s"_a) + .def("normalize", &math::Vec4::normalize) + .def("minComponent", &math::Vec4::minComponent, "other"_a) + .def("maxComponent", &math::Vec4::maxComponent, "other"_a) + .def( + "__mul__", [](const T& a, math::Vec4 b) { return a * b; }, nb::is_operator(), "b"_a) + .def( + "__truediv__", [](const T& a, math::Vec4 b) { return a / b; }, nb::is_operator(), "b"_a) + .def("__repr__", [](const math::Vec4& v) { + std::stringstream ostr; + ostr << v; + return ostr.str(); + }); +} + +void defineRgba8(nb::module_& m) +{ + using ValueType = math::Rgba8::ValueType; + + nb::class_(m, "Rgba8", "8-bit red, green, blue, alpha packed into 32 bit unsigned int") + .def(nb::init<>()) + .def(nb::init(), "other"_a) + .def(nb::init(), "r"_a, "g"_a, "b"_a, "a"_a = 255) + .def(nb::init(), "v"_a) + .def(nb::init(), "r"_a, "g"_a, "b"_a, "a"_a = 1.0) + .def(nb::init(), "rgb"_a) + .def(nb::init(), "rgba"_a) + .def(nb::self < nb::self, "rhs"_a) + .def(nb::self == nb::self, "rhs"_a) + .def("lengthSqr", &math::Rgba8::lengthSqr) + .def("length", &math::Rgba8::length) + .def("asFloat", &math::Rgba8::asFloat, "n"_a) + .def( + "__getitem__", + [](const math::Rgba8& rgba, size_t i) { + if (i >= 4) { + throw nb::index_error(); + } + return rgba[static_cast(i)]; + }, + "i"_a) + .def( + "__setitem__", + [](math::Rgba8& rgba, size_t i, ValueType value) { + if (i >= 4) { + throw nb::index_error(); + } + rgba[static_cast(i)] = value; + }, + "i"_a, + "value"_a) + .def_prop_rw( + "packed", [](const math::Rgba8& rgba) { return rgba.packed(); }, [](math::Rgba8& rgba, uint32_t packed) { rgba.packed() = packed; }) + .def_prop_rw( + "r", [](const math::Rgba8& rgba) { return rgba.r(); }, [](math::Rgba8& rgba, uint8_t r) { rgba.r() = r; }) + .def_prop_rw( + "g", [](const math::Rgba8& rgba) { return rgba.g(); }, [](math::Rgba8& rgba, uint8_t g) { rgba.g() = g; }) + .def_prop_rw( + "b", [](const math::Rgba8& rgba) { return rgba.b(); }, [](math::Rgba8& rgba, uint8_t b) { rgba.b() = b; }) + .def_prop_rw( + "a", [](const math::Rgba8& rgba) { return rgba.a(); }, [](math::Rgba8& rgba, uint8_t a) { rgba.a() = a; }) + .def("asVec3f", [](const math::Rgba8& rgba) { return Vec3f(rgba); }) + .def("asVec4f", [](const math::Rgba8& rgba) { return Vec4f(rgba); }); +} + +template void defineBaseBBox(nb::module_& m, const char* name) +{ + nb::class_>(m, name) + .def(nb::self == nb::self, "rhs"_a) + .def(nb::self != nb::self, "rhs"_a) + .def( + "__getitem__", + [](const math::BaseBBox& bbox, size_t i) { + if (i >= 2) { + throw nb::index_error(); + } + return bbox[static_cast(i)]; + }, + "i"_a) + .def( + "__setitem__", + [](math::BaseBBox& bbox, size_t i, const Vec3T& value) { + if (i >= 2) { + throw nb::index_error(); + } + bbox[static_cast(i)] = value; + }, + "i"_a, + "value"_a) + .def_prop_rw( + "min", [](const math::BaseBBox& bbox) { return bbox.min(); }, [](math::BaseBBox& bbox, const Vec3T& min) { bbox.min() = min; }) + .def_prop_rw( + "max", [](const math::BaseBBox& bbox) { return bbox.max(); }, [](math::BaseBBox& bbox, const Vec3T& max) { bbox.max() = max; }) + .def("translate", &math::BaseBBox::translate, "xyz"_a) + .def("expand", nb::overload_cast(&math::BaseBBox::expand), "xyz"_a) + .def("expand", nb::overload_cast&>(&math::BaseBBox::expand), "bbox"_a) + .def("intersect", &math::BaseBBox::intersect, "bbox"_a) + .def("isInside", &math::BaseBBox::isInside, "xyz"_a); +} + +template void defineBBoxFloatingPoint(nb::module_& m, const char* name, const char* doc) +{ + nb::class_, math::BaseBBox>(m, name, doc) + .def(nb::init<>()) + .def(nb::init(), "min"_a, "max"_a) + .def(nb::init(), "min"_a, "max"_a) + .def_static("createCube", &math::BBox::createCube, "min"_a, "dim"_a) + .def(nb::init&>(), "bbox"_a) + .def("empty", &math::BBox::empty) + .def("dim", &math::BBox::dim) + .def("isInside", &math::BBox::isInside, "p"_a) + .def("__repr__", [](const math::BBox& b) { + std::stringstream ostr; + ostr << b; + return ostr.str(); + }); +} + +template void defineBBoxInteger(nb::module_& m, const char* name, const char* doc) +{ + using ValueType = typename CoordT::ValueType; + + nb::class_, math::BaseBBox>(m, name, doc) + .def(nb::init<>()) + .def(nb::init(), "min"_a, "max"_a) + .def( + "__iter__", + [](const math::BBox& b) { return nb::make_iterator(nb::type>(), "CoordBBoxIterator", b.begin(), b.end()); }, + nb::keep_alive<0, 1>()) + .def_static("createCube", nb::overload_cast(&math::BBox::createCube), "min"_a, "dim"_a) + .def_static("createCube", nb::overload_cast(&math::BBox::createCube), "min"_a, "max"_a) + .def("is_divisible", &math::BBox::is_divisible) + .def("empty", &math::BBox::empty) + .def("dim", &math::BBox::dim) + .def("volume", &math::BBox::volume) + .def("isInside", nb::overload_cast(&math::BBox::isInside, nb::const_), "p"_a) + .def("isInside", nb::overload_cast&>(&math::BBox::isInside, nb::const_), "b"_a) + .def("asFloat", &math::BBox::template asReal) + .def("asDouble", &math::BBox::template asReal) + .def("hasOverlap", &math::BBox::hasOverlap, "b"_a) + .def("expandBy", &math::BBox::expandBy, "padding"_a) + .def("__repr__", [](const CoordBBox& b) { + std::stringstream ostr; + ostr << b; + return ostr.str(); + }); +} + +} // namespace + +void defineMathModule(nb::module_& m) +{ + defineCoord(m); + + defineVec3(m, "Vec3f", "Vector class with three float components, similar to openvdb::math::Vec3f"); + defineVec3(m, "Vec3d", "Vector class with three double components, similar to openvdb::math::Vec3d"); + + defineVec4(m, "Vec4f", "Vector class with four float components, similar to openvdb::math::Vec4f"); + defineVec4(m, "Vec4d", "Vector class with four double components, similar to openvdb::math::Vec4f"); + + defineRgba8(m); + + defineBaseBBox(m, "Vec3fBaseBBox"); + defineBBoxFloatingPoint(m, "Vec3fBBox", "Bounding box for Vec3f minimum and maximum"); + + defineBaseBBox(m, "Vec3dBaseBBox"); + defineBBoxFloatingPoint(m, "Vec3dBBox", "Bounding box for Vec3d minimum and maximum"); + + defineBaseBBox(m, "CoordBaseBBox"); + defineBBoxInteger(m, "CoordBBox", "Bounding box for Coord minimum and maximum"); + + defineNearestNeighborSampler(m, "FloatNearestNeighborSampler"); + defineTrilinearSampler(m, "FloatTrilinearSampler"); + defineTriquadraticSampler(m, "FloatTriquadraticSampler"); + defineTricubicSampler(m, "FloatTricubicSampler"); + + defineNearestNeighborSampler(m, "DoubleNearestNeighborSampler"); + defineTrilinearSampler(m, "DoubleTrilinearSampler"); + defineTriquadraticSampler(m, "DoubleTriquadraticSampler"); + defineTricubicSampler(m, "DoubleTricubicSampler"); + + defineNearestNeighborSampler(m, "Int32NearestNeighborSampler"); + defineTrilinearSampler(m, "Int32TrilinearSampler"); + defineTriquadraticSampler(m, "Int32TriquadraticSampler"); + defineTricubicSampler(m, "Int32TricubicSampler"); + + defineNearestNeighborSampler(m, "Vec3fNearestNeighborSampler"); + defineTrilinearSampler(m, "Vec3fTrilinearSampler"); + defineTriquadraticSampler(m, "Vec3fTriquadraticSampler"); + defineTricubicSampler(m, "Vec3fTricubicSampler"); + +#ifdef NANOVDB_USE_CUDA + nb::module_ cudaModule = m.def_submodule("cuda"); + cudaModule.doc() = "A submodule that implements CUDA-accelerated math functions"; + + defineSampleFromVoxels(cudaModule, "sampleFromVoxels"); + defineSampleFromVoxels(cudaModule, "sampleFromVoxels"); +#endif +} + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PyMath.h b/nanovdb/nanovdb/python/PyMath.h new file mode 100644 index 0000000000..e9a2cde791 --- /dev/null +++ b/nanovdb/nanovdb/python/PyMath.h @@ -0,0 +1,14 @@ +#ifndef NANOVDB_PYMATH_HAS_BEEN_INCLUDED +#define NANOVDB_PYMATH_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +void defineMathModule(nb::module_& m); + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/PyNanoToOpenVDB.cc b/nanovdb/nanovdb/python/PyNanoToOpenVDB.cc new file mode 100644 index 0000000000..8225cd78ca --- /dev/null +++ b/nanovdb/nanovdb/python/PyNanoToOpenVDB.cc @@ -0,0 +1,29 @@ +#include "PyNanoToOpenVDB.h" + +#include +#include +#ifdef NANOVDB_USE_OPENVDB +#include +#include +#endif + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace pynanovdb { + +template void defineNanoToOpenVDB(nb::module_& m) +{ +#ifdef NANOVDB_USE_OPENVDB + // Wrap nanoToOpenVDB into a lambda to workaround an MSVC compiler bug + m.def( + "nanoToOpenVDB", [](GridHandle& handle, int verbose, uint32_t n){ + return tools::nanoToOpenVDB(handle, verbose, n); + }, "handle"_a, "verbose"_a = 0, "n"_a = 0); +#endif +} + +template void defineNanoToOpenVDB(nb::module_&); + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PyNanoToOpenVDB.h b/nanovdb/nanovdb/python/PyNanoToOpenVDB.h new file mode 100644 index 0000000000..ac60fdbf96 --- /dev/null +++ b/nanovdb/nanovdb/python/PyNanoToOpenVDB.h @@ -0,0 +1,14 @@ +#ifndef NANOVDB_PYNANOTOOPENVDB_HAS_BEEN_INCLUDED +#define NANOVDB_PYNANOTOOPENVDB_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +template void defineNanoToOpenVDB(nb::module_& m); + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/PyPrimitives.cc b/nanovdb/nanovdb/python/PyPrimitives.cc new file mode 100644 index 0000000000..3b7f11c0d9 --- /dev/null +++ b/nanovdb/nanovdb/python/PyPrimitives.cc @@ -0,0 +1,202 @@ +#include "PyPrimitives.h" + +#include + +#include +#ifdef NANOVDB_USE_CUDA +#include +#endif + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace pynanovdb { + +namespace { + +template +GridHandle createLevelSetSphere(GridType gridType, + double radius, + const Vec3d& center, + double voxelSize, + double halfWidth, + const Vec3d& origin, + const std::string& name, + tools::StatsMode sMode, + CheckMode cMode, + const BufferT& buffer) +{ + switch (gridType) { + case GridType::Float: return createLevelSetSphere(radius, center, voxelSize, halfWidth, origin, name, sMode, cMode, buffer); + case GridType::Double: return createLevelSetSphere(radius, center, voxelSize, halfWidth, origin, name, sMode, cMode, buffer); + default: { + std::stringstream ss; + // ss << "Cannot createLevelSetSphere for grid of type \"" << toStr(gridType); + throw std::runtime_error(ss.str() + "\""); + } + } +} + +template +GridHandle createLevelSetTorus(GridType gridType, + double majorRadius, + double minorRadius, + const Vec3d& center, + double voxelSize, + double halfWidth, + const Vec3d& origin, + const std::string& name, + tools::StatsMode sMode, + CheckMode cMode, + const BufferT& buffer) +{ + switch (gridType) { + case GridType::Float: + return createLevelSetTorus(majorRadius, minorRadius, center, voxelSize, halfWidth, origin, name, sMode, cMode, buffer); + case GridType::Double: + return createLevelSetTorus(majorRadius, minorRadius, center, voxelSize, halfWidth, origin, name, sMode, cMode, buffer); + default: { + std::stringstream ss; + // ss << "Cannot createLevelSetTorus for grid of type \"" << toStr(gridType); + throw std::runtime_error(ss.str() + "\""); + } + } +} + +template +GridHandle createFogVolumeSphere(GridType gridType, + double radius, + const Vec3d& center, + double voxelSize, + double halfWidth, + const Vec3d& origin, + const std::string& name, + tools::StatsMode sMode, + CheckMode cMode, + const BufferT& buffer) +{ + switch (gridType) { + case GridType::Float: return createFogVolumeSphere(radius, center, voxelSize, halfWidth, origin, name, sMode, cMode, buffer); + case GridType::Double: return createFogVolumeSphere(radius, center, voxelSize, halfWidth, origin, name, sMode, cMode, buffer); + default: { + std::stringstream ss; + // ss << "Cannot createFogVolumeSphere for grid of type \"" << toStr(gridType); + throw std::runtime_error(ss.str() + "\""); + } + } +} + +template +GridHandle createFogVolumeTorus(GridType gridType, + double majorRadius, + double minorRadius, + const Vec3d& center, + double voxelSize, + double halfWidth, + const Vec3d& origin, + const std::string& name, + tools::StatsMode sMode, + CheckMode cMode, + const BufferT& buffer) +{ + switch (gridType) { + case GridType::Float: + return createFogVolumeTorus(majorRadius, minorRadius, center, voxelSize, halfWidth, origin, name, sMode, cMode, buffer); + case GridType::Double: + return createFogVolumeTorus(majorRadius, minorRadius, center, voxelSize, halfWidth, origin, name, sMode, cMode, buffer); + default: { + std::stringstream ss; + // ss << "Cannot createFogVolumeTorus for grid of type \"" << toStr(gridType); + throw std::runtime_error(ss.str() + "\""); + } + } +} + +} // namespace + +template void definePrimitives(nb::module_& m) +{ + m.def("createLevelSetSphere", + nb::overload_cast( + &createLevelSetSphere), + "gridType"_a = GridType::Float, + "radius"_a = 100.0, + "center"_a = Vec3d(0.0), + "voxelSize"_a = 1.0, + "halfWidth"_a = 3.0, + "origin"_a = Vec3d(0.0), + "name"_a = "sphere_ls", + "sMode"_a = tools::StatsMode::Default, + "cMode"_a = CheckMode::Default, + "buffer"_a = BufferT()); + + m.def("createLevelSetTorus", + nb::overload_cast(&createLevelSetTorus), + "gridType"_a = GridType::Float, + "majorRadius"_a = 100.0, + "minorRadius"_a = 50.0, + "center"_a = Vec3d(0.0), + "voxelSize"_a = 1.0, + "halfWidth"_a = 3.0, + "origin"_a = Vec3d(0.0), + "name"_a = "torus_ls", + "sMode"_a = tools::StatsMode::Default, + "cMode"_a = CheckMode::Default, + "buffer"_a = BufferT()); + + m.def("createFogVolumeSphere", + nb::overload_cast( + &createFogVolumeSphere), + "gridType"_a = GridType::Float, + "radius"_a = 100.0, + "center"_a = Vec3d(0.0), + "voxelSize"_a = 1.0, + "halfWidth"_a = 3.0, + "origin"_a = Vec3d(0.0), + "name"_a = "sphere_fog", + "sMode"_a = tools::StatsMode::Default, + "cMode"_a = CheckMode::Default, + "buffer"_a = BufferT()); + + m.def("createFogVolumeTorus", + nb::overload_cast(&createFogVolumeTorus), + "gridType"_a = GridType::Float, + "majorRadius"_a = 100.0, + "minorRadius"_a = 50.0, + "center"_a = Vec3d(0.0), + "voxelSize"_a = 1.0, + "halfWidth"_a = 3.0, + "origin"_a = Vec3d(0.0), + "name"_a = "torus_fog", + "sMode"_a = tools::StatsMode::Default, + "cMode"_a = CheckMode::Default, + "buffer"_a = BufferT()); +} + +template void definePrimitives(nb::module_&); +#ifdef NANOVDB_USE_CUDA +template void definePrimitives(nb::module_&); +#endif + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PyPrimitives.h b/nanovdb/nanovdb/python/PyPrimitives.h new file mode 100644 index 0000000000..8be1e0208c --- /dev/null +++ b/nanovdb/nanovdb/python/PyPrimitives.h @@ -0,0 +1,14 @@ +#ifndef NANOVDB_PYPRIMITIVES_HAS_BEEN_INCLUDED +#define NANOVDB_PYPRIMITIVES_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +template void definePrimitives(nb::module_& m); + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/PySampleFromVoxels.cc b/nanovdb/nanovdb/python/PySampleFromVoxels.cc new file mode 100644 index 0000000000..2a3b7e5b6e --- /dev/null +++ b/nanovdb/nanovdb/python/PySampleFromVoxels.cc @@ -0,0 +1,86 @@ +#include "PySampleFromVoxels.h" + +#include +#include + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace pynanovdb { + +namespace { + +template void defineSampleFromVoxels(nb::module_& m, const char* name) +{ + using CoordT = typename TreeT::CoordType; + nb::class_>(m, name) + .def( + "__call__", [](const math::SampleFromVoxels& sampler, const CoordT& ijk) { return sampler(ijk); }, nb::is_operator(), "ijk"_a) + .def( + "__call__", [](const math::SampleFromVoxels& sampler, const Vec3f& xyz) { return sampler(xyz); }, nb::is_operator(), "xyz"_a) + .def( + "__call__", [](const math::SampleFromVoxels& sampler, const Vec3d& xyz) { return sampler(xyz); }, nb::is_operator(), "xyz"_a); +} + +template void defineCreateSampler(nb::module_& m, const char* name) +{ + m.def( + name, [](const Grid& grid) { return math::createSampler(grid.tree()); }, "grid"_a); +} + +} // namespace + +template void defineNearestNeighborSampler(nb::module_& m, const char* name) +{ + using TreeT = NanoTree; + + defineSampleFromVoxels(m, name); + defineCreateSampler(m, "createNearestNeighborSampler"); +} + +template void defineTrilinearSampler(nb::module_& m, const char* name) +{ + using TreeT = NanoTree; + + defineSampleFromVoxels(m, name); + defineCreateSampler(m, "createTrilinearSampler"); +} + +template void defineTriquadraticSampler(nb::module_& m, const char* name) +{ + using TreeT = NanoTree; + + defineSampleFromVoxels(m, name); + defineCreateSampler(m, "createTriquadraticSampler"); +} + +template void defineTricubicSampler(nb::module_& m, const char* name) +{ + using TreeT = NanoTree; + + defineSampleFromVoxels(m, name); + defineCreateSampler(m, "createTricubicSampler"); +} + +template void defineNearestNeighborSampler(nb::module_&, const char*); +template void defineTrilinearSampler(nb::module_&, const char*); +template void defineTriquadraticSampler(nb::module_&, const char*); +template void defineTricubicSampler(nb::module_&, const char*); + +template void defineNearestNeighborSampler(nb::module_&, const char*); +template void defineTrilinearSampler(nb::module_&, const char*); +template void defineTriquadraticSampler(nb::module_&, const char*); +template void defineTricubicSampler(nb::module_&, const char*); + +template void defineNearestNeighborSampler(nb::module_&, const char*); +template void defineTrilinearSampler(nb::module_&, const char*); +template void defineTriquadraticSampler(nb::module_&, const char*); +template void defineTricubicSampler(nb::module_&, const char*); + +template void defineNearestNeighborSampler(nb::module_&, const char*); +template void defineTrilinearSampler(nb::module_&, const char*); +template void defineTriquadraticSampler(nb::module_&, const char*); +template void defineTricubicSampler(nb::module_&, const char*); + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PySampleFromVoxels.h b/nanovdb/nanovdb/python/PySampleFromVoxels.h new file mode 100644 index 0000000000..140db2f3be --- /dev/null +++ b/nanovdb/nanovdb/python/PySampleFromVoxels.h @@ -0,0 +1,17 @@ +#ifndef NANOVDB_PYSAMPLEFROMVOXELS_HAS_BEEN_INCLUDED +#define NANOVDB_PYSAMPLEFROMVOXELS_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +template void defineNearestNeighborSampler(nb::module_& m, const char* name); +template void defineTrilinearSampler(nb::module_& m, const char* name); +template void defineTriquadraticSampler(nb::module_& m, const char* name); +template void defineTricubicSampler(nb::module_& m, const char* name); + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/PyTools.cc b/nanovdb/nanovdb/python/PyTools.cc new file mode 100644 index 0000000000..de74380987 --- /dev/null +++ b/nanovdb/nanovdb/python/PyTools.cc @@ -0,0 +1,59 @@ +#include "PyTools.h" + +#include +#include +#ifdef NANOVDB_USE_CUDA +#include +#endif + +#include "PyGridStats.h" +#include "PyCreateNanoGrid.h" +#include "PyPrimitives.h" +#include "PyGridChecksum.h" +#include "PyGridValidator.h" +#include "PyNanoToOpenVDB.h" +#ifdef NANOVDB_USE_CUDA +#include "cuda/PyPointsToGrid.h" +#include "cuda/PySignedFloodFill.h" +#endif + +namespace nb = nanobind; +using namespace nanovdb; + +namespace pynanovdb { + +void defineToolsModule(nb::module_& m) +{ + defineUpdateChecksum(m); + defineValidateGrids(m); + + defineStatsMode(m); + + definePrimitives(m); + + defineCreateNanoGrid(m, "createFloatGrid"); + defineCreateNanoGrid(m, "createDoubleGrid"); + defineCreateNanoGrid(m, "createInt32Grid"); + defineCreateNanoGrid(m, "createVec3fGrid"); + +#ifdef NANOVDB_USE_OPENVDB + defineOpenToNanoVDB(m); + defineNanoToOpenVDB(m); +#endif + +#ifdef NANOVDB_USE_CUDA + nb::module_ cudaModule = m.def_submodule("cuda"); + cudaModule.doc() = "A submodule that implements CUDA-accelerated tools"; + + defineValidateGrids(m); + + definePrimitives(cudaModule); + + defineSignedFloodFill(cudaModule, "signedFloodFill"); + defineSignedFloodFill(cudaModule, "signedFloodFill"); + + definePointsToGrid(cudaModule, "pointsToRGBA8Grid"); +#endif +} + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/PyTools.h b/nanovdb/nanovdb/python/PyTools.h new file mode 100644 index 0000000000..be6e49ff53 --- /dev/null +++ b/nanovdb/nanovdb/python/PyTools.h @@ -0,0 +1,14 @@ +#ifndef NANOVDB_PYTOOLS_HAS_BEEN_INCLUDED +#define NANOVDB_PYTOOLS_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +void defineToolsModule(nb::module_& m); + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/__init__.py b/nanovdb/nanovdb/python/__init__.py new file mode 100644 index 0000000000..7bce6a9559 --- /dev/null +++ b/nanovdb/nanovdb/python/__init__.py @@ -0,0 +1,7 @@ +import sys +if sys.platform == "win32": + import os + openvdb_dll_directory = os.path.join(os.path.dirname(os.path.abspath(__file__)), os.pardir, 'openvdb', 'lib') + os.add_dll_directory(directory) + +from .lib.nanovdb import * diff --git a/nanovdb/nanovdb/python/cuda/PyDeviceBuffer.cc b/nanovdb/nanovdb/python/cuda/PyDeviceBuffer.cc new file mode 100644 index 0000000000..58a6d984f3 --- /dev/null +++ b/nanovdb/nanovdb/python/cuda/PyDeviceBuffer.cc @@ -0,0 +1,19 @@ +#ifdef NANOVDB_USE_CUDA + +#include "PyDeviceBuffer.h" + +#include + +namespace nb = nanobind; +using namespace nanovdb; + +namespace pynanovdb { + +void defineDeviceBuffer(nb::module_& m) +{ + nb::class_(m, "DeviceBuffer"); +} + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/cuda/PyDeviceBuffer.h b/nanovdb/nanovdb/python/cuda/PyDeviceBuffer.h new file mode 100644 index 0000000000..c65239cb69 --- /dev/null +++ b/nanovdb/nanovdb/python/cuda/PyDeviceBuffer.h @@ -0,0 +1,16 @@ +#ifndef NANOVDB_CUDA_PYDEVICEBUFFER_HAS_BEEN_INCLUDED +#define NANOVDB_CUDA_PYDEVICEBUFFER_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +#ifdef NANOVDB_USE_CUDA +void defineDeviceBuffer(nb::module_& m); +#endif + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/cuda/PyDeviceGridHandle.cu b/nanovdb/nanovdb/python/cuda/PyDeviceGridHandle.cu new file mode 100644 index 0000000000..a8dc924d7f --- /dev/null +++ b/nanovdb/nanovdb/python/cuda/PyDeviceGridHandle.cu @@ -0,0 +1,45 @@ +#ifdef NANOVDB_USE_CUDA + +#include "../PyGridHandle.h" +#include + +#include + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace pynanovdb { + +void defineDeviceGridHandle(nb::module_& m) +{ + using BufferT = nanovdb::cuda::DeviceBuffer; + defineGridHandle(m, "DeviceGridHandle") + .def( + "__init__", + [](GridHandle& handle, + nb::ndarray, nb::device::cpu> cpu_t, + nb::ndarray, nb::device::cuda> cuda_t) { + assert(cpu_t.size() == cuda_t.size()); + BufferT buffer(cpu_t.size() * sizeof(uint32_t), cpu_t.data(), cuda_t.data()); + new (&handle) GridHandle(std::move(buffer)); + }, + "cpu_t"_a.noconvert(), + "cuda_t"_a.noconvert()) + .def("deviceFloatGrid", nb::overload_cast(&GridHandle::template deviceGrid), "n"_a = 0, nb::rv_policy::reference_internal) + .def("deviceDoubleGrid", nb::overload_cast(&GridHandle::template deviceGrid), "n"_a = 0, nb::rv_policy::reference_internal) + .def("deviceInt32Grid", nb::overload_cast(&GridHandle::template deviceGrid), "n"_a = 0, nb::rv_policy::reference_internal) + .def("deviceVec3fGrid", nb::overload_cast(&GridHandle::template deviceGrid), "n"_a = 0, nb::rv_policy::reference_internal) + .def("deviceRGBA8Grid", + nb::overload_cast(&GridHandle::template deviceGrid), + "n"_a = 0, + nb::rv_policy::reference_internal) + .def( + "deviceUpload", [](GridHandle& handle, bool sync) { handle.deviceUpload(nullptr, sync); }, "sync"_a = true) + .def( + "deviceDownload", [](GridHandle& handle, bool sync) { handle.deviceDownload(nullptr, sync); }, "sync"_a = true); +} + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/cuda/PyPointsToGrid.cu b/nanovdb/nanovdb/python/cuda/PyPointsToGrid.cu new file mode 100644 index 0000000000..82a5826fc4 --- /dev/null +++ b/nanovdb/nanovdb/python/cuda/PyPointsToGrid.cu @@ -0,0 +1,56 @@ +#include "PyPointsToGrid.h" + +#include + +#include + +namespace nb = nanobind; +using namespace nb::literals; + +namespace pynanovdb { + +class NdArrayCoordPtr +{ + const int32_t* data; + int64_t stride0, stride1; + +public: + __hostdev__ NdArrayCoordPtr(const int32_t* data, int64_t stride0, int64_t stride1) + : data(data) + , stride0(stride0) + , stride1(stride1) + { + } + __hostdev__ inline nanovdb::Coord operator[](size_t i) const + { + nanovdb::Coord::ValueType x = data[i * stride0 + 0 * stride1]; + nanovdb::Coord::ValueType y = data[i * stride0 + 1 * stride1]; + nanovdb::Coord::ValueType z = data[i * stride0 + 2 * stride1]; + return nanovdb::Coord(x, y, z); + } + __hostdev__ inline nanovdb::Coord operator*() const + { + size_t i = 0; + nanovdb::Coord::ValueType x = data[i * stride0 + 0 * stride1]; + nanovdb::Coord::ValueType y = data[i * stride0 + 1 * stride1]; + nanovdb::Coord::ValueType z = data[i * stride0 + 2 * stride1]; + return nanovdb::Coord(x, y, z); + } +}; + +template void definePointsToGrid(nb::module_& m, const char* name) +{ + m.def( + name, + [](nb::ndarray, nb::c_contig, nb::device::cuda> tensor) { + NdArrayCoordPtr points(tensor.data(), tensor.stride(0), tensor.stride(1)); + nanovdb::tools::cuda::PointsToGrid converter; + auto handle = converter.getHandle(points, tensor.shape(0)); + return handle; + }, + "tensor"_a); +} + +template void definePointsToGrid(nb::module_&, const char*); + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/cuda/PyPointsToGrid.h b/nanovdb/nanovdb/python/cuda/PyPointsToGrid.h new file mode 100644 index 0000000000..4bb530ac22 --- /dev/null +++ b/nanovdb/nanovdb/python/cuda/PyPointsToGrid.h @@ -0,0 +1,14 @@ +#ifndef NANOVDB_CUDA_PYPOINTSTOGRID_HAS_BEEN_INCLUDED +#define NANOVDB_CUDA_PYPOINTSTOGRID_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +template void definePointsToGrid(nb::module_& m, const char* name); + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/cuda/PySampleFromVoxels.cu b/nanovdb/nanovdb/python/cuda/PySampleFromVoxels.cu new file mode 100644 index 0000000000..8bab06e51e --- /dev/null +++ b/nanovdb/nanovdb/python/cuda/PySampleFromVoxels.cu @@ -0,0 +1,89 @@ +#include "PySampleFromVoxels.h" + +#include + +#include +#include + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace { + +template __global__ void sampleFromVoxels(unsigned int numPoints, const BuildT* points, const NanoGrid* d_grid, BuildT* values) +{ + using TreeT = NanoTree; + using Vec3T = math::Vec3; + + for (unsigned int i = threadIdx.x + blockIdx.x * blockDim.x; i < numPoints; i += blockDim.x * gridDim.x) { + Vec3T worldPos(points[3 * i], points[3 * i + 1], points[3 * i + 2]); + Vec3T indexPos = d_grid->worldToIndex(worldPos); + + math::SampleFromVoxels sampler(d_grid->tree()); + values[i] = sampler(indexPos); + } +} + +template +__global__ void sampleFromVoxels(unsigned int numPoints, const BuildT* points, const NanoGrid* d_grid, BuildT* values, BuildT* gradients) +{ + using TreeT = NanoTree; + using Vec3T = math::Vec3; + + for (unsigned int i = threadIdx.x + blockIdx.x * blockDim.x; i < numPoints; i += blockDim.x * gridDim.x) { + Vec3T worldPos(points[3 * i], points[3 * i + 1], points[3 * i + 2]); + Vec3T indexPos = d_grid->worldToIndex(worldPos); + + math::SampleFromVoxels sampler(d_grid->tree()); + values[i] = sampler(indexPos); + + Vec3T inv2Dx = (BuildT).5 / d_grid->voxelSize(); + Vec3T gradient = Vec3T(sampler(indexPos + Vec3T(1, 0, 0)) - sampler(indexPos - Vec3T(1, 0, 0)), + sampler(indexPos + Vec3T(0, 1, 0)) - sampler(indexPos - Vec3T(0, 1, 0)), + sampler(indexPos + Vec3T(0, 0, 1)) - sampler(indexPos - Vec3T(0, 0, 1))) * + inv2Dx; + gradients[3 * i] = gradient[0]; + gradients[3 * i + 1] = gradient[1]; + gradients[3 * i + 2] = gradient[2]; + } +} + +} // namespace + +namespace pynanovdb { + +template void defineSampleFromVoxels(nb::module_& m, const char* name) +{ + m.def( + name, + [](nb::ndarray, nb::c_contig, nb::device::cuda> points, + NanoGrid* d_grid, + nb::ndarray, nb::device::cuda> values) { + constexpr unsigned int numThreads = 128; + unsigned int numBlocks = (points.shape(0) + numThreads - 1) / numThreads; + sampleFromVoxels<<>>(points.shape(0), points.data(), d_grid, values.data()); + }, + "points"_a, + "d_grid"_a, + "values"_a); + m.def( + name, + [](nb::ndarray, nb::c_contig, nb::device::cuda> points, + NanoGrid* d_grid, + nb::ndarray, nb::device::cuda> values, + nb::ndarray, nb::device::cuda> gradients) { + constexpr unsigned int numThreads = 128; + unsigned int numBlocks = (points.shape(0) + numThreads - 1) / numThreads; + sampleFromVoxels<<>>(points.shape(0), points.data(), d_grid, values.data(), gradients.data()); + }, + "points"_a, + "d_grid"_a, + "values"_a, + "gradients"_a); +} + +template void defineSampleFromVoxels(nb::module_&, const char*); +template void defineSampleFromVoxels(nb::module_&, const char*); + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/cuda/PySampleFromVoxels.h b/nanovdb/nanovdb/python/cuda/PySampleFromVoxels.h new file mode 100644 index 0000000000..c23a97e849 --- /dev/null +++ b/nanovdb/nanovdb/python/cuda/PySampleFromVoxels.h @@ -0,0 +1,14 @@ +#ifndef NANOVDB_CUDA_PYSAMPLEFROMVOXELS_HAS_BEEN_INCLUDED +#define NANOVDB_CUDA_PYSAMPLEFROMVOXELS_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +template void defineSampleFromVoxels(nb::module_& m, const char* name); + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/cuda/PySignedFloodFill.cu b/nanovdb/nanovdb/python/cuda/PySignedFloodFill.cu new file mode 100644 index 0000000000..2b68ca38df --- /dev/null +++ b/nanovdb/nanovdb/python/cuda/PySignedFloodFill.cu @@ -0,0 +1,20 @@ +#include "PySignedFloodFill.h" + +#include + +namespace nb = nanobind; +using namespace nb::literals; +using namespace nanovdb; + +namespace pynanovdb { + +template void defineSignedFloodFill(nb::module_& m, const char* name) +{ + m.def( + name, [](NanoGrid* d_grid, bool verbose) { return tools::cuda::signedFloodFill(d_grid, verbose); }, "d_grid"_a, "verbose"_a = false); +} + +template void defineSignedFloodFill(nb::module_&, const char*); +template void defineSignedFloodFill(nb::module_&, const char*); + +} // namespace pynanovdb diff --git a/nanovdb/nanovdb/python/cuda/PySignedFloodFill.h b/nanovdb/nanovdb/python/cuda/PySignedFloodFill.h new file mode 100644 index 0000000000..7ae16defe7 --- /dev/null +++ b/nanovdb/nanovdb/python/cuda/PySignedFloodFill.h @@ -0,0 +1,14 @@ +#ifndef NANOVDB_CUDA_PYSIGNEDFLOODFILL_HAS_BEEN_INCLUDED +#define NANOVDB_CUDA_PYSIGNEDFLOODFILL_HAS_BEEN_INCLUDED + +#include + +namespace nb = nanobind; + +namespace pynanovdb { + +template void defineSignedFloodFill(nb::module_& m, const char* name); + +} // namespace pynanovdb + +#endif diff --git a/nanovdb/nanovdb/python/test/TestNanoVDB.py b/nanovdb/nanovdb/python/test/TestNanoVDB.py new file mode 100644 index 0000000000..fca793295e --- /dev/null +++ b/nanovdb/nanovdb/python/test/TestNanoVDB.py @@ -0,0 +1,853 @@ +# /usr/bin/env python + +import nanovdb +import unittest +import tempfile + + +class TestVersion(unittest.TestCase): + def test_operators(self): + currentVersion = nanovdb.Version() + initialVersion = nanovdb.Version(1, 0, 0) + self.assertEqual(initialVersion.getMajor(), 1) + self.assertEqual(initialVersion.getMinor(), 0) + self.assertEqual(initialVersion.getPatch(), 0) + self.assertTrue(currentVersion > initialVersion) + self.assertFalse(currentVersion < initialVersion) + self.assertFalse(currentVersion == initialVersion) + self.assertTrue(initialVersion.age() < 0) + + alsoCurrentVersion = nanovdb.Version(currentVersion.id()) + self.assertTrue(currentVersion == alsoCurrentVersion) + self.assertFalse(currentVersion > alsoCurrentVersion) + self.assertTrue(currentVersion >= alsoCurrentVersion) + self.assertFalse(currentVersion < alsoCurrentVersion) + self.assertTrue(currentVersion <= alsoCurrentVersion) + + +class TestCoord(unittest.TestCase): + def test_operators(self): + ijk = nanovdb.math.Coord() + self.assertEqual(ijk[0], 0) + self.assertEqual(ijk[1], 0) + self.assertEqual(ijk[2], 0) + self.assertEqual(ijk.x, 0) + self.assertEqual(ijk.y, 0) + self.assertEqual(ijk.z, 0) + + ijk.x = 1 + ijk[1] = 2 + ijk.z += 3 + self.assertEqual(ijk, nanovdb.math.Coord(1, 2, 3)) + self.assertNotEqual(ijk, nanovdb.math.Coord(4)) + + def test_hash(self): + self.assertEqual(0, nanovdb.math.Coord(1, 2, 3).octant()) + self.assertEqual(0, nanovdb.math.Coord(1, 9, 3).octant()) + self.assertEqual(1, nanovdb.math.Coord(-1, 2, 3).octant()) + self.assertEqual(2, nanovdb.math.Coord(1, -2, 3).octant()) + self.assertEqual(3, nanovdb.math.Coord(-1, -2, 3).octant()) + self.assertEqual(4, nanovdb.math.Coord(1, 2, -3).octant()) + self.assertEqual(5, nanovdb.math.Coord(-1, 2, -3).octant()) + self.assertEqual(6, nanovdb.math.Coord(1, -2, -3).octant()) + self.assertEqual(7, nanovdb.math.Coord(-1, -2, -3).octant()) + + +class TestVec3dBBox(unittest.TestCase): + def test_functions(self): + bbox = nanovdb.math.Vec3dBBox() + self.assertTrue(bbox.empty()) + + bbox.expand(nanovdb.math.Vec3d(57.0, -31.0, 60.0)) + self.assertTrue(bbox.empty()) + self.assertEqual(nanovdb.math.Vec3d(0.0), bbox.dim()) + self.assertEqual(57.0, bbox[0][0]) + self.assertEqual(-31.0, bbox[0][1]) + self.assertEqual(60.0, bbox[0][2]) + self.assertEqual(57.0, bbox[1][0]) + self.assertEqual(-31.0, bbox[1][1]) + self.assertEqual(60.0, bbox[1][2]) + + bbox.expand(nanovdb.math.Vec3d(58.0, 0.0, 62.0)) + self.assertFalse(bbox.empty()) + self.assertEqual(nanovdb.math.Vec3d(1.0, 31.0, 2.0), bbox.dim()) + self.assertEqual(57.0, bbox[0][0]) + self.assertEqual(-31.0, bbox[0][1]) + self.assertEqual(60.0, bbox[0][2]) + self.assertEqual(58.0, bbox[1][0]) + self.assertEqual(0.0, bbox[1][1]) + self.assertEqual(62.0, bbox[1][2]) + + +class TestCoordBBox(unittest.TestCase): + def test_functions(self): + bbox = nanovdb.math.CoordBBox() + self.assertTrue(bbox.empty()) + + bbox.expand(nanovdb.math.Coord(57, -31, 60)) + self.assertFalse(bbox.empty()) + self.assertEqual(nanovdb.math.Coord(1), bbox.dim()) + self.assertEqual(57, bbox[0][0]) + self.assertEqual(-31, bbox[0][1]) + self.assertEqual(60, bbox[0][2]) + self.assertEqual(57, bbox[1][0]) + self.assertEqual(-31, bbox[1][1]) + self.assertEqual(60, bbox[1][2]) + + bbox.expand(nanovdb.math.Coord(58, 0, 62)) + self.assertFalse(bbox.empty()) + self.assertEqual(nanovdb.math.Coord(2, 32, 3), bbox.dim()) + self.assertEqual(57, bbox[0][0]) + self.assertEqual(-31, bbox[0][1]) + self.assertEqual(60, bbox[0][2]) + self.assertEqual(58, bbox[1][0]) + self.assertEqual(0, bbox[1][1]) + self.assertEqual(62, bbox[1][2]) + + def test_convert(self): + bbox = nanovdb.math.CoordBBox( + nanovdb.math.Coord(57, -31, 60), nanovdb.math.Coord(58, 0, 62) + ) + bbox2 = bbox.asDouble() + self.assertFalse(bbox2.empty()) + self.assertEqual(nanovdb.math.Vec3d(57.0, -31.0, 60.0), bbox2.min) + self.assertEqual(nanovdb.math.Vec3d(59.0, 1.0, 63.0), bbox2.max) + + def test_iterator(self): + bbox = nanovdb.math.CoordBBox( + nanovdb.math.Coord(57, -31, 60), nanovdb.math.Coord(58, 0, 62) + ) + ijk = iter(bbox) + for i in range(bbox.min[0], bbox.max[0] + 1): + for j in range(bbox.min[1], bbox.max[1] + 1): + for k in range(bbox.min[2], bbox.max[2] + 1): + self.assertTrue(iter) + coord = next(ijk) + self.assertTrue(bbox.isInside(coord)) + self.assertEqual(coord.x, i) + self.assertEqual(coord.y, j) + self.assertEqual(coord.z, k) + + def test_create_cube(self): + self.assertEqual( + nanovdb.math.Coord(-7, -7, -7), + nanovdb.math.CoordBBox.createCube(nanovdb.math.Coord(-7), 8).min, + ) + self.assertEqual( + nanovdb.math.Coord(0, 0, 0), + nanovdb.math.CoordBBox.createCube(nanovdb.math.Coord(-7), 8).max, + ) + self.assertEqual( + nanovdb.math.Coord(-7, -7, -7), nanovdb.math.CoordBBox.createCube(-7, 0).min + ) + self.assertEqual( + nanovdb.math.Coord(0, 0, 0), nanovdb.math.CoordBBox.createCube(-7, 0).max + ) + + +class TestVec3(unittest.TestCase): + def test_float(self): + a = nanovdb.math.Vec3f() + self.assertEqual(a, nanovdb.math.Vec3f(0.0)) + b = nanovdb.math.Vec3f(1.0) + self.assertEqual(b[0], 1.0) + self.assertEqual(b[1], 1.0) + self.assertEqual(b[2], 1.0) + c = a + b + c[0] = 2.0 + c[1] = 3.0 + c[2] = 4.0 + + self.assertEqual(a + b, b) + self.assertEqual(b - c, -nanovdb.math.Vec3f(1.0, 2.0, 3.0)) + self.assertEqual(c * 5.0, nanovdb.math.Vec3f(10.0, 15.0, 20.0)) + self.assertEqual(b.cross(c), nanovdb.math.Vec3f(1.0, -2.0, 1.0)) + self.assertEqual(c.dot(c), c.lengthSqr()) + + def test_double(self): + a = nanovdb.math.Vec3d() + self.assertEqual(a, nanovdb.math.Vec3d(0.0)) + b = nanovdb.math.Vec3d(1.0) + self.assertEqual(b[0], 1.0) + self.assertEqual(b[1], 1.0) + self.assertEqual(b[2], 1.0) + c = a + b + c[0] = 2.0 + c[1] = 3.0 + c[2] = 4.0 + + self.assertEqual(a + b, b) + self.assertEqual(b - c, -nanovdb.math.Vec3d(1.0, 2.0, 3.0)) + self.assertEqual(c * 5.0, nanovdb.math.Vec3d(10.0, 15.0, 20.0)) + self.assertEqual(b.cross(c), nanovdb.math.Vec3d(1.0, -2.0, 1.0)) + self.assertEqual(c.dot(c), c.lengthSqr()) + + +class TestVec4(unittest.TestCase): + def test_float(self): + a = nanovdb.math.Vec4f() + self.assertEqual(a, nanovdb.math.Vec4f(0.0)) + b = nanovdb.math.Vec4f(1.0) + self.assertEqual(b[0], 1.0) + self.assertEqual(b[1], 1.0) + self.assertEqual(b[2], 1.0) + self.assertEqual(b[3], 1.0) + c = a + b + c[0] = 2.0 + c[1] = 3.0 + c[2] = 4.0 + c[3] = 5.0 + + self.assertEqual(a + b, b) + self.assertEqual(b - c, -nanovdb.math.Vec4f(1.0, 2.0, 3.0, 4.0)) + self.assertEqual(c * 5.0, nanovdb.math.Vec4f(10.0, 15.0, 20.0, 25.0)) + self.assertEqual(c.lengthSqr(), 54.0) + + def test_double(self): + a = nanovdb.math.Vec4d() + self.assertEqual(a, nanovdb.math.Vec4d(0.0)) + b = nanovdb.math.Vec4d(1.0) + self.assertEqual(b[0], 1.0) + self.assertEqual(b[1], 1.0) + self.assertEqual(b[2], 1.0) + self.assertEqual(b[3], 1.0) + c = a + b + c[0] = 2.0 + c[1] = 3.0 + c[2] = 4.0 + c[3] = 5.0 + + self.assertEqual(a + b, b) + self.assertEqual(b - c, -nanovdb.math.Vec4d(1.0, 2.0, 3.0, 4.0)) + self.assertEqual(c * 5.0, nanovdb.math.Vec4d(10.0, 15.0, 20.0, 25.0)) + self.assertEqual(c.lengthSqr(), 54.0) + + +class TestRgba8(unittest.TestCase): + def test(self): + a = nanovdb.math.Rgba8() + self.assertEqual(a, nanovdb.math.Rgba8(0)) + b = nanovdb.math.Rgba8(127) + self.assertEqual(b[0], 127) + self.assertEqual(b[1], 127) + self.assertEqual(b[2], 127) + self.assertEqual(b[3], 127) + b.r = 255 + b.g = 255 + b.b = 255 + b.a = 255 + self.assertEqual(b.packed, 2**32 - 1) + self.assertEqual(b.asFloat(0), 1.0) + self.assertEqual(b.asFloat(1), 1.0) + self.assertEqual(b.asFloat(2), 1.0) + self.assertEqual(b.asFloat(3), 1.0) + self.assertEqual(b.asVec3f(), nanovdb.math.Vec3f(1.0)) + self.assertEqual(b.asVec4f(), nanovdb.math.Vec4f(1.0)) + + +class TestMask(unittest.TestCase): + def test_leaf_mask(self): + self.assertEqual(8, nanovdb.LeafMask.wordCount()) + self.assertEqual(512, nanovdb.LeafMask.bitCount()) + self.assertEqual(8 * 8, nanovdb.LeafMask.memUsage()) + + mask = nanovdb.LeafMask() + self.assertEqual(0, mask.countOn()) + self.assertTrue(mask.isOff()) + self.assertFalse(mask.isOn()) + for i in range(nanovdb.LeafMask.bitCount()): + self.assertFalse(mask.isOn(i)) + self.assertTrue(mask.isOff(i)) + + for i in range(1000): + self.assertEqual(512, mask.findNextOn(i)) + self.assertEqual(512, mask.findPrevOn(i)) + self.assertEqual(i if i < 512 else 512, mask.findNextOff(i)) + self.assertEqual(i if i < 512 else 512, mask.findPrevOff(i)) + + mask.setOn(256) + self.assertFalse(mask.isOff()) + self.assertFalse(mask.isOn()) + + +class TestMap(unittest.TestCase): + def test_functions(self): + map1 = nanovdb.Map() + map2 = nanovdb.Map() + + self.assertEqual(nanovdb.math.Vec3d(1.0), map1.getVoxelSize()) + map1.set(1.0, nanovdb.math.Vec3d(0.0)) + self.assertEqual(nanovdb.math.Vec3d(1.0), map1.getVoxelSize()) + map2.set(2.0, nanovdb.math.Vec3d(0.0)) + self.assertEqual(nanovdb.math.Vec3d(2.0), map2.getVoxelSize()) + map1 = map2 + self.assertEqual(nanovdb.math.Vec3d(2.0), map2.getVoxelSize()) + self.assertEqual(nanovdb.math.Vec3d(2.0), map1.getVoxelSize()) + + +class TestGrid(unittest.TestCase): + def test_float_grid(self): + handle = nanovdb.tools.createFogVolumeSphere() + self.assertEqual(handle.gridCount(), 1) + for i in range(handle.gridCount()): + self.assertTrue(handle.gridSize(i) > 0) + self.assertEqual(handle.gridType(i), nanovdb.GridType.Float) + grid = handle.floatGrid(i) + self.assertIsNotNone(grid) + accessor = nanovdb.FloatReadAccessor(grid) + coord = nanovdb.math.Coord(0) + self.assertEqual(accessor.getValue(0, 0, 0), accessor.getValue(coord)) + self.assertEqual(accessor.getValue(coord), accessor(coord)) + self.assertEqual(accessor(coord), accessor(0, 0, 0)) + self.assertTrue(accessor.isActive(coord)) + nodeInfo = accessor.getNodeInfo(coord) + self.assertTrue(nodeInfo.bbox.isInside(coord)) + self.assertEqual(accessor.probeValue(coord), (1.0, True)) + + def test_checksum(self): + handle = nanovdb.tools.createFogVolumeTorus() + self.assertEqual(handle.gridCount(), 1) + for i in range(handle.gridCount()): + self.assertTrue(handle.gridSize(i) > 0) + self.assertEqual(handle.gridType(i), nanovdb.GridType.Float) + grid = handle.floatGrid(i) + self.assertIsNotNone(grid) + checksum = grid.checksum() + nanovdb.tools.updateChecksum(grid, nanovdb.CheckMode.Default) + updatedChecksum = grid.checksum() + self.assertEqual(checksum, updatedChecksum) + + +class TestGridHandleExchange(unittest.TestCase): + def test_list_to_vector(self): + handle = nanovdb.tools.createLevelSetTorus(nanovdb.GridType.Double) + self.assertEqual(handle.gridCount(), 1) + self.assertIsNotNone(handle.doubleGrid()) + handles = [handle, handle] + dstFile = tempfile.NamedTemporaryFile() + nanovdb.io.writeGrids(dstFile.name, handles) + + +class TestReadWriteGrids(unittest.TestCase): + def setUp(self): + self.gridName = "sphere_ls" + sphereHandle = nanovdb.tools.createLevelSetSphere( + nanovdb.GridType.Float, name=self.gridName + ) + self.srcFile = tempfile.NamedTemporaryFile() + nanovdb.io.writeGrid(self.srcFile.name, sphereHandle) + nanovdb.io.writeGrid(self.srcFile.name, sphereHandle) + self.dstFile = tempfile.NamedTemporaryFile() + + def test_metadata(self): + metadataList = nanovdb.io.readGridMetaData(self.srcFile.name) + for metadata in metadataList: + self.assertEqual(metadata.gridName, self.gridName) + self.assertTrue(metadata.memUsage() > 0) + self.assertTrue(metadata.gridSize > 0) + self.assertTrue(metadata.fileSize > 0) + self.assertTrue(metadata.voxelCount > 0) + self.assertEqual(metadata.gridType, nanovdb.GridType.Float) + self.assertEqual(metadata.gridClass, nanovdb.GridClass.LevelSet) + self.assertTrue(metadata.indexBBox.isInside(nanovdb.math.Coord(0))) + self.assertTrue(metadata.worldBBox.isInside(nanovdb.math.Vec3d(0.0))) + self.assertEqual(metadata.voxelSize, nanovdb.math.Vec3d(1.0)) + self.assertEqual(metadata.nameSize, len(self.gridName) + 1) + self.assertIsInstance(metadata.nodeCount, tuple) + self.assertIsInstance(metadata.tileCount, tuple) + self.assertEqual(metadata.codec, nanovdb.io.Codec.NONE) + self.assertEqual(metadata.padding, 0) + self.assertEqual(metadata.version, nanovdb.Version()) + + def test_read_write_grid(self): + self.assertTrue(nanovdb.io.hasGrid(self.srcFile.name, self.gridName)) + handle = nanovdb.io.readGrid(self.srcFile.name) + self.assertEqual(handle.gridCount(), 1) + for i in range(handle.gridCount()): + self.assertTrue(handle.gridSize(i) > 0) + self.assertEqual(handle.gridType(i), nanovdb.GridType.Float) + grid = handle.floatGrid(i) + self.assertIsNotNone(grid) + self.assertTrue(grid.activeVoxelCount() > 0) + self.assertTrue(grid.isSequential()) + self.assertEqual(grid.gridName(), self.gridName) + + nanovdb.io.writeGrid(self.dstFile.name, handle, nanovdb.io.Codec.NONE) + self.assertTrue(nanovdb.io.hasGrid(self.dstFile.name, self.gridName)) + nanovdb.io.writeGrid(self.dstFile.name, handle, nanovdb.io.Codec.BLOSC) + self.assertTrue(nanovdb.io.hasGrid(self.dstFile.name, self.gridName)) + nanovdb.io.writeGrid(self.dstFile.name, handle, nanovdb.io.Codec.ZIP) + self.assertTrue(nanovdb.io.hasGrid(self.dstFile.name, self.gridName)) + + def test_read_write_grids(self): + handles = nanovdb.io.readGrids(self.srcFile.name) + self.assertEqual(len(handles), 1) + nanovdb.io.writeGrids(self.dstFile.name, handles, nanovdb.io.Codec.NONE) + + try: + nanovdb.io.writeGrids(self.dstFile.name, handles, nanovdb.io.Codec.BLOSC) + except RuntimeError: + print("BLOSC compression codec not supported. Skipping...") + + try: + nanovdb.io.writeGrids(self.dstFile.name, handles, nanovdb.io.Codec.ZIP) + except RuntimeError: + print("ZIP compression codec not supported. Skipping...") + + +@unittest.skipIf( + not nanovdb.isCudaAvailable(), "nanovdb module was compiled without CUDA support" +) +class TestDeviceReadWriteGrids(unittest.TestCase): + def setUp(self): + self.gridName = "sphere_ls" + sphereHandle = nanovdb.tools.cuda.createLevelSetSphere( + nanovdb.GridType.Float, name=self.gridName + ) + self.srcFile = tempfile.NamedTemporaryFile() + nanovdb.io.deviceWriteGrid(self.srcFile.name, sphereHandle) + nanovdb.io.deviceWriteGrid(self.srcFile.name, sphereHandle) + self.dstFile = tempfile.NamedTemporaryFile() + + def test_metadata(self): + metadataList = nanovdb.io.readGridMetaData(self.srcFile.name) + for metadata in metadataList: + self.assertEqual(metadata.gridName, self.gridName) + self.assertTrue(metadata.memUsage() > 0) + self.assertTrue(metadata.gridSize > 0) + self.assertTrue(metadata.fileSize > 0) + self.assertTrue(metadata.voxelCount > 0) + self.assertEqual(metadata.gridType, nanovdb.GridType.Float) + self.assertEqual(metadata.gridClass, nanovdb.GridClass.LevelSet) + self.assertTrue(metadata.indexBBox.isInside(nanovdb.math.Coord(0))) + self.assertTrue(metadata.worldBBox.isInside(nanovdb.math.Vec3d(0.0))) + self.assertEqual(metadata.voxelSize, nanovdb.math.Vec3d(1.0)) + self.assertEqual(metadata.nameSize, len(self.gridName) + 1) + self.assertIsInstance(metadata.nodeCount, tuple) + self.assertIsInstance(metadata.tileCount, tuple) + self.assertEqual(metadata.codec, nanovdb.io.Codec.NONE) + self.assertEqual(metadata.padding, 0) + self.assertEqual(metadata.version, nanovdb.Version()) + + def test_read_write_grid(self): + self.assertTrue(nanovdb.io.hasGrid(self.srcFile.name, self.gridName)) + handle = nanovdb.io.deviceReadGrid(self.srcFile.name) + self.assertEqual(handle.gridCount(), 1) + for i in range(handle.gridCount()): + self.assertTrue(handle.gridSize(i) > 0) + self.assertEqual(handle.gridType(i), nanovdb.GridType.Float) + grid = handle.floatGrid(i) + self.assertIsNotNone(grid) + deviceGrid = handle.deviceFloatGrid(i) + self.assertIsNone(deviceGrid) + handle.deviceUpload() + deviceGrid = handle.deviceFloatGrid(i) + handle.deviceDownload() + grid = handle.floatGrid(i) + self.assertIsNotNone(grid) + self.assertIsNotNone(deviceGrid) + self.assertTrue(grid.activeVoxelCount() > 0) + self.assertTrue(grid.isSequential()) + self.assertEqual(grid.gridName(), self.gridName) + + nanovdb.io.deviceWriteGrid(self.dstFile.name, handle, nanovdb.io.Codec.NONE) + self.assertTrue(nanovdb.io.hasGrid(self.dstFile.name, self.gridName)) + nanovdb.io.deviceWriteGrid(self.dstFile.name, handle, nanovdb.io.Codec.BLOSC) + self.assertTrue(nanovdb.io.hasGrid(self.dstFile.name, self.gridName)) + nanovdb.io.deviceWriteGrid(self.dstFile.name, handle, nanovdb.io.Codec.ZIP) + self.assertTrue(nanovdb.io.hasGrid(self.dstFile.name, self.gridName)) + + def test_read_write_grids(self): + handles = nanovdb.io.deviceReadGrids(self.srcFile.name) + self.assertEqual(len(handles), 1) + nanovdb.io.deviceWriteGrids(self.dstFile.name, handles, nanovdb.io.Codec.NONE) + + try: + nanovdb.io.deviceWriteGrids( + self.dstFile.name, handles, nanovdb.io.Codec.BLOSC + ) + except RuntimeError: + print("BLOSC compression codec not supported. Skipping...") + + try: + nanovdb.io.deviceWriteGrids( + self.dstFile.name, handles, nanovdb.io.Codec.ZIP + ) + except RuntimeError: + print("ZIP compression codec not supported. Skipping...") + + +@unittest.skipIf( + not nanovdb.isCudaAvailable(), "nanovdb module was compiled without CUDA support" +) +class TestPointsToGrid(unittest.TestCase): + def test_points_to_grid(self): + try: + import torch + + tensor = torch.tensor( + [[1, 2, 3]], dtype=torch.int32, device=torch.device("cuda", 0) + ) + handle = nanovdb.tools.cuda.pointsToRGBA8Grid(tensor) + deviceGrid = handle.deviceRGBA8Grid() + self.assertTrue(deviceGrid) + grid = handle.rgba8Grid() + self.assertFalse(grid) + handle.deviceDownload() + grid = handle.rgba8Grid() + self.assertTrue(grid) + except ImportError: + print("PyTorch not found. Skipping...") + pass + + +@unittest.skipIf( + not nanovdb.isCudaAvailable(), "nanovdb module was compiled without CUDA support" +) +class TestSignedFloodFill(unittest.TestCase): + def test_signed_flood_fill_float(self): + handle = nanovdb.tools.cuda.createLevelSetSphere(nanovdb.GridType.Float, 100) + grid = handle.floatGrid() + self.assertIsNotNone(grid) + accessor = grid.getAccessor() + self.assertFalse(accessor.isActive(nanovdb.math.Coord(103, 0, 0))) + self.assertTrue(accessor.isActive(nanovdb.math.Coord(100, 0, 0))) + self.assertFalse(accessor.isActive(nanovdb.math.Coord(97, 0, 0))) + self.assertEqual(3.0, accessor(103, 0, 0)) + self.assertEqual(0.0, accessor(100, 0, 0)) + self.assertEqual(-3.0, accessor(97, 0, 0)) + accessor.setVoxel(nanovdb.math.Coord(103, 0, 0), -1.0) + accessor.setVoxel(nanovdb.math.Coord(97, 0, 0), 1.0) + self.assertEqual(-1.0, accessor(103, 0, 0)) + self.assertEqual(0.0, accessor(100, 0, 0)) + self.assertEqual(1.0, accessor(97, 0, 0)) + handle.deviceUpload() + deviceGrid = handle.deviceFloatGrid(0) + self.assertIsNotNone(deviceGrid) + nanovdb.tools.cuda.signedFloodFill(deviceGrid) + handle.deviceDownload() + grid = handle.floatGrid() + self.assertIsNotNone(grid) + accessor = grid.getAccessor() + self.assertEqual(3.0, accessor(103, 0, 0)) + self.assertEqual(0.0, accessor(100, 0, 0)) + self.assertEqual(-3.0, accessor(97, 0, 0)) + # self.assertFalse(grid.isLexicographic()) + self.assertTrue(grid.isBreadthFirst()) + + def test_signed_flood_fill_double(self): + handle = nanovdb.tools.cuda.createLevelSetSphere(nanovdb.GridType.Double, 100) + grid = handle.doubleGrid() + self.assertIsNotNone(grid) + accessor = grid.getAccessor() + self.assertFalse(accessor.isActive(nanovdb.math.Coord(103, 0, 0))) + self.assertTrue(accessor.isActive(nanovdb.math.Coord(100, 0, 0))) + self.assertFalse(accessor.isActive(nanovdb.math.Coord(97, 0, 0))) + self.assertEqual(3.0, accessor(103, 0, 0)) + self.assertEqual(0.0, accessor(100, 0, 0)) + self.assertEqual(-3.0, accessor(97, 0, 0)) + accessor.setVoxel(nanovdb.math.Coord(103, 0, 0), -1.0) + accessor.setVoxel(nanovdb.math.Coord(97, 0, 0), 1.0) + self.assertEqual(-1.0, accessor(103, 0, 0)) + self.assertEqual(0.0, accessor(100, 0, 0)) + self.assertEqual(1.0, accessor(97, 0, 0)) + handle.deviceUpload() + deviceGrid = handle.deviceDoubleGrid(0) + self.assertIsNotNone(deviceGrid) + nanovdb.tools.cuda.signedFloodFill(deviceGrid) + handle.deviceDownload() + grid = handle.doubleGrid() + self.assertIsNotNone(grid) + accessor = grid.getAccessor() + self.assertEqual(3.0, accessor(103, 0, 0)) + self.assertEqual(0.0, accessor(100, 0, 0)) + self.assertEqual(-3.0, accessor(97, 0, 0)) + # self.assertFalse(grid.isLexicographic()) + self.assertTrue(grid.isBreadthFirst()) + + +@unittest.skipIf( + not nanovdb.isCudaAvailable(), "nanovdb module was compiled without CUDA support" +) +class TestSampleFromPoints(unittest.TestCase): + def test_sample_from_points_float(self): + try: + import torch + + radius = 100.0 + world_space_pos = nanovdb.math.Vec3f(radius) + voxelSize = 0.5 + halfWidth = 5.0 + value = halfWidth * voxelSize + handle = nanovdb.tools.cuda.createLevelSetSphere( + nanovdb.GridType.Float, + radius=radius, + halfWidth=halfWidth, + voxelSize=voxelSize, + ) + handle.deviceUpload() + grid = handle.deviceFloatGrid() + self.assertIsNotNone(grid) + + points = torch.tensor( + [ + [10.0, 0.0, 0.0], # interior point outside the narrow band + [100.0, 0.0, 0.0], # on the boundary + [0.0, 0.0, 99.0], # interior point inside the narrow band + [0.0, 101.0, 0.0], # exterior point inside the narrow band + [110.0, 0.0, 0.0], # exterior point ouside the narrow band + ], + dtype=torch.float32, + device=torch.device("cuda", 0), + ) + values = torch.zeros( + [5], dtype=torch.float32, device=torch.device("cuda", 0) + ) + gradients = torch.zeros( + [5, 3], dtype=torch.float32, device=torch.device("cuda", 0) + ) + expected_values = torch.tensor( + [-value, 0.0, -1.0, 1.0, value], dtype=torch.float32 + ) + expected_gradients = torch.tensor( + [ + [0.0, 0.0, 0.0], + [1.0, 0.0, 0.0], + [0.0, 0.0, 1.0], + [0.0, 1.0, 0.0], + [0.0, 0.0, 0.0], + ], + dtype=torch.float32, + device=torch.device("cuda", 0), + ) + nanovdb.math.cuda.sampleFromVoxels(points, grid, values, gradients) + for i in range(5): + self.assertEqual(values[i], expected_values[i]) + for i in range(5): + for j in range(3): + self.assertEqual(gradients[i][j], expected_gradients[i][j]) + + except ImportError: + print("PyTorch not found. Skipping...") + pass + + def test_sample_from_points_double(self): + try: + import torch + + radius = 100.0 + world_space_pos = nanovdb.math.Vec3d(radius) + voxelSize = 0.5 + halfWidth = 5.0 + value = halfWidth * voxelSize + handle = nanovdb.tools.cuda.createLevelSetSphere( + nanovdb.GridType.Double, + radius=radius, + halfWidth=halfWidth, + voxelSize=voxelSize, + ) + handle.deviceUpload() + grid = handle.deviceDoubleGrid() + self.assertIsNotNone(grid) + + points = torch.tensor( + [ + [10.0, 0.0, 0.0], + [100.0, 0.0, 0.0], + [0.0, 0.0, 99.0], + [0.0, 101.0, 0.0], + [110.0, 0.0, 0.0], + ], + dtype=torch.float64, + device=torch.device("cuda", 0), + ) + values = torch.zeros( + [5], dtype=torch.float64, device=torch.device("cuda", 0) + ) + expected_values = torch.tensor( + [-value, 0.0, -1.0, 1.0, value], dtype=torch.float64 + ) + nanovdb.math.cuda.sampleFromVoxels(points, grid, values) + for i in range(5): + self.assertEqual(values[i], expected_values[i]) + + except ImportError: + print("PyTorch not found. Skipping...") + pass + + +class TestSampler(unittest.TestCase): + def test_float_sampler(self): + radius = 100.0 + world_space_pos = nanovdb.math.Vec3f(radius) + voxelSize = 0.1 + halfWidth = 5.0 + value = halfWidth * voxelSize + + handle = nanovdb.tools.createLevelSetSphere( + nanovdb.GridType.Float, + radius=radius, + halfWidth=halfWidth, + voxelSize=voxelSize, + ) + grid = handle.floatGrid() + xform = grid.map() + index_space_pos = xform.applyInverseMap(world_space_pos) + sampler = nanovdb.math.createNearestNeighborSampler(grid) + self.assertEqual(value, sampler(index_space_pos)) + + sampler = nanovdb.math.createTrilinearSampler(grid) + self.assertEqual(value, sampler(index_space_pos)) + + sampler = nanovdb.math.createTriquadraticSampler(grid) + self.assertEqual(value, sampler(index_space_pos)) + + sampler = nanovdb.math.createTricubicSampler(grid) + self.assertEqual(value, sampler(index_space_pos)) + + def test_double_sampler(self): + radius = 100.0 + world_space_pos = nanovdb.math.Vec3d(radius) + voxelSize = 0.1 + halfWidth = 5.0 + value = halfWidth * voxelSize + + handle = nanovdb.tools.createLevelSetSphere( + nanovdb.GridType.Double, + radius=radius, + halfWidth=halfWidth, + voxelSize=voxelSize, + ) + grid = handle.doubleGrid() + xform = grid.map() + index_space_pos = xform.applyInverseMap(world_space_pos) + sampler = nanovdb.math.createNearestNeighborSampler(grid) + self.assertEqual(value, sampler(index_space_pos)) + + sampler = nanovdb.math.createTrilinearSampler(grid) + self.assertEqual(value, sampler(index_space_pos)) + + sampler = nanovdb.math.createTriquadraticSampler(grid) + self.assertEqual(value, sampler(index_space_pos)) + + sampler = nanovdb.math.createTricubicSampler(grid) + self.assertEqual(value, sampler(index_space_pos)) + + +class TestCreateNanoGrid(unittest.TestCase): + def test_create_float_nano_grid(self): + bbox = nanovdb.math.CoordBBox( + nanovdb.math.Coord(0), nanovdb.math.Coord(2 * 4 - 1) + ) + handle = nanovdb.tools.createFloatGrid( + 0.0, "test_float", nanovdb.GridClass.Unknown, lambda ijk: 1.0, bbox + ) + self.assertEqual(handle.gridCount(), 1) + for i in range(handle.gridCount()): + self.assertTrue(handle.gridSize(i) > 0) + self.assertEqual(handle.gridType(i), nanovdb.GridType.Float) + grid = handle.floatGrid(i) + self.assertIsNotNone(grid) + self.assertTrue(grid.activeVoxelCount() > 0) + self.assertTrue(grid.isSequential()) + self.assertEqual(grid.gridName(), "test_float") + self.assertEqual(grid.gridClass(), nanovdb.GridClass.Unknown) + + def test_create_double_nano_grid(self): + bbox = nanovdb.math.CoordBBox( + nanovdb.math.Coord(0), nanovdb.math.Coord(2 * 4 - 1) + ) + handle = nanovdb.tools.createDoubleGrid( + 0.0, "test_double", nanovdb.GridClass.Unknown, lambda ijk: 1.0, bbox + ) + self.assertEqual(handle.gridCount(), 1) + for i in range(handle.gridCount()): + self.assertTrue(handle.gridSize(i) > 0) + self.assertEqual(handle.gridType(i), nanovdb.GridType.Double) + grid = handle.doubleGrid(i) + self.assertIsNotNone(grid) + self.assertTrue(grid.activeVoxelCount() > 0) + self.assertTrue(grid.isSequential()) + self.assertEqual(grid.gridName(), "test_double") + self.assertEqual(grid.gridClass(), nanovdb.GridClass.Unknown) + + def test_create_int_nano_grid(self): + bbox = nanovdb.math.CoordBBox( + nanovdb.math.Coord(0), nanovdb.math.Coord(2 * 4 - 1) + ) + handle = nanovdb.tools.createInt32Grid( + 0, "test_int", nanovdb.GridClass.Unknown, lambda ijk: 1, bbox + ) + self.assertEqual(handle.gridCount(), 1) + for i in range(handle.gridCount()): + self.assertTrue(handle.gridSize(i) > 0) + self.assertEqual(handle.gridType(i), nanovdb.GridType.Int32) + grid = handle.int32Grid(i) + self.assertIsNotNone(grid) + self.assertTrue(grid.activeVoxelCount() > 0) + self.assertTrue(grid.isSequential()) + self.assertEqual(grid.gridName(), "test_int") + self.assertEqual(grid.gridClass(), nanovdb.GridClass.Unknown) + + def test_create_vec3f_nano_grid(self): + bbox = nanovdb.math.CoordBBox( + nanovdb.math.Coord(0), nanovdb.math.Coord(2 * 4 - 1) + ) + handle = nanovdb.tools.createVec3fGrid( + nanovdb.math.Vec3f(0.0), + "test_vec3f", + nanovdb.GridClass.Unknown, + lambda ijk: nanovdb.math.Vec3f(1.0), + bbox, + ) + self.assertEqual(handle.gridCount(), 1) + for i in range(handle.gridCount()): + self.assertTrue(handle.gridSize(i) > 0) + self.assertEqual(handle.gridType(i), nanovdb.GridType.Vec3f) + grid = handle.vec3fGrid(i) + self.assertIsNotNone(grid) + self.assertTrue(grid.activeVoxelCount() > 0) + self.assertTrue(grid.isSequential()) + self.assertEqual(grid.gridName(), "test_vec3f") + self.assertEqual(grid.gridClass(), nanovdb.GridClass.Unknown) + + +class TestNanoToOpenVDB(unittest.TestCase): + def test_function(self): + handle = nanovdb.tools.createLevelSetSphere() + try: + import openvdb + + sphere = nanovdb.tools.nanoToOpenVDB(handle) + self.assertEqual(sphere.name, "sphere_ls") + self.assertFalse(sphere.empty()) + except ImportError: + print("openvdb not found. Skipping...") + pass + + +class TestOpenToNanoVDB(unittest.TestCase): + def test_function(self): + try: + import openvdb + + sphere = openvdb.createLevelSetSphere(100.0) + sphere.name = "test_sphere" + handle = nanovdb.tools.openToNanoVDB(sphere) + self.assertEqual(handle.gridCount(), 1) + for i in range(handle.gridCount()): + self.assertTrue(handle.gridSize(i) > 0) + self.assertEqual(handle.gridType(i), nanovdb.GridType.Float) + grid = handle.floatGrid(i) + self.assertIsNotNone(grid) + self.assertTrue(grid.activeVoxelCount() > 0) + self.assertTrue(grid.isSequential()) + self.assertEqual(grid.gridName(), "test_sphere") + self.assertEqual(grid.gridClass(), nanovdb.GridClass.LevelSet) + except ImportError: + print("openvdb not found. Skipping...") + pass + + +if __name__ == "__main__": + unittest.main() diff --git a/nanovdb/nanovdb/tools/CreateNanoGrid.h b/nanovdb/nanovdb/tools/CreateNanoGrid.h index 0615cb6e22..6f1ce04076 100644 --- a/nanovdb/nanovdb/tools/CreateNanoGrid.h +++ b/nanovdb/nanovdb/tools/CreateNanoGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/CreateNanoGrid.h diff --git a/nanovdb/nanovdb/tools/CreatePrimitives.h b/nanovdb/nanovdb/tools/CreatePrimitives.h index a28d5bacd4..95b8491879 100644 --- a/nanovdb/nanovdb/tools/CreatePrimitives.h +++ b/nanovdb/nanovdb/tools/CreatePrimitives.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/CreatePrimitives.h diff --git a/nanovdb/nanovdb/tools/GridBuilder.h b/nanovdb/nanovdb/tools/GridBuilder.h index 3072a59348..428215ba65 100644 --- a/nanovdb/nanovdb/tools/GridBuilder.h +++ b/nanovdb/nanovdb/tools/GridBuilder.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/GridBuilder.h @@ -1158,7 +1158,7 @@ struct LeafNode ValueIterator& operator=(const ValueIterator&) = default; ValueType operator*() const { NANOVDB_ASSERT(*this); return mParent->mValues[mPos];} Coord getCoord() const { NANOVDB_ASSERT(*this); return mParent->offsetToGlobalCoord(mPos);} - bool isActive() const { NANOVDB_ASSERT(*this); return mParent->isActive(mPos);} + bool isActive() const { NANOVDB_ASSERT(*this); return mParent->mValueMask.isOn(mPos);} operator bool() const {return mPos < SIZE;} ValueIterator& operator++() {++mPos; return *this;} ValueIterator operator++(int) { diff --git a/nanovdb/nanovdb/tools/GridChecksum.h b/nanovdb/nanovdb/tools/GridChecksum.h index 882ab9222a..62323c30f5 100644 --- a/nanovdb/nanovdb/tools/GridChecksum.h +++ b/nanovdb/nanovdb/tools/GridChecksum.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/GridChecksum.h diff --git a/nanovdb/nanovdb/tools/GridStats.h b/nanovdb/nanovdb/tools/GridStats.h index f07f5a6040..fac54b20f7 100644 --- a/nanovdb/nanovdb/tools/GridStats.h +++ b/nanovdb/nanovdb/tools/GridStats.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/GridStats.h diff --git a/nanovdb/nanovdb/tools/GridValidator.h b/nanovdb/nanovdb/tools/GridValidator.h index fbc4e14ded..6a8565cbef 100644 --- a/nanovdb/nanovdb/tools/GridValidator.h +++ b/nanovdb/nanovdb/tools/GridValidator.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/GridValidator.h diff --git a/nanovdb/nanovdb/tools/NanoToOpenVDB.h b/nanovdb/nanovdb/tools/NanoToOpenVDB.h index 3723a4ecb1..5966ece95c 100644 --- a/nanovdb/nanovdb/tools/NanoToOpenVDB.h +++ b/nanovdb/nanovdb/tools/NanoToOpenVDB.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/NanoToOpenVDB.h diff --git a/nanovdb/nanovdb/tools/cuda/AddBlindData.cuh b/nanovdb/nanovdb/tools/cuda/AddBlindData.cuh index a7dcfcd6f5..aab5796f57 100644 --- a/nanovdb/nanovdb/tools/cuda/AddBlindData.cuh +++ b/nanovdb/nanovdb/tools/cuda/AddBlindData.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/cuda/AddBlindData.cuh diff --git a/nanovdb/nanovdb/tools/cuda/GridChecksum.cuh b/nanovdb/nanovdb/tools/cuda/GridChecksum.cuh index b1f61e2fe7..5cc964e5d5 100644 --- a/nanovdb/nanovdb/tools/cuda/GridChecksum.cuh +++ b/nanovdb/nanovdb/tools/cuda/GridChecksum.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/cuda/GridChecksum.cuh diff --git a/nanovdb/nanovdb/tools/cuda/GridStats.cuh b/nanovdb/nanovdb/tools/cuda/GridStats.cuh index 34c615f6d2..0ba570acfa 100644 --- a/nanovdb/nanovdb/tools/cuda/GridStats.cuh +++ b/nanovdb/nanovdb/tools/cuda/GridStats.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/cuda/GridStats.cuh diff --git a/nanovdb/nanovdb/tools/cuda/GridValidator.cuh b/nanovdb/nanovdb/tools/cuda/GridValidator.cuh index 2edfc0bdb1..aaa28412dd 100644 --- a/nanovdb/nanovdb/tools/cuda/GridValidator.cuh +++ b/nanovdb/nanovdb/tools/cuda/GridValidator.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/cuda/GridValidator.cuh diff --git a/nanovdb/nanovdb/tools/cuda/IndexToGrid.cuh b/nanovdb/nanovdb/tools/cuda/IndexToGrid.cuh index 756a4fde63..d26b09a24f 100644 --- a/nanovdb/nanovdb/tools/cuda/IndexToGrid.cuh +++ b/nanovdb/nanovdb/tools/cuda/IndexToGrid.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/cuda/IndexToGrid.cuh diff --git a/nanovdb/nanovdb/tools/cuda/PointsToGrid.cuh b/nanovdb/nanovdb/tools/cuda/PointsToGrid.cuh index 70134b5e7b..bcf335efe1 100644 --- a/nanovdb/nanovdb/tools/cuda/PointsToGrid.cuh +++ b/nanovdb/nanovdb/tools/cuda/PointsToGrid.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/cuda/PointsToGrid.cuh diff --git a/nanovdb/nanovdb/tools/cuda/SignedFloodFill.cuh b/nanovdb/nanovdb/tools/cuda/SignedFloodFill.cuh index 82aece2784..f214247a82 100644 --- a/nanovdb/nanovdb/tools/cuda/SignedFloodFill.cuh +++ b/nanovdb/nanovdb/tools/cuda/SignedFloodFill.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/tools/cuda/SignedFloodFill.cuh diff --git a/nanovdb/nanovdb/unittest/CMakeLists.txt b/nanovdb/nanovdb/unittest/CMakeLists.txt index b0a32be445..ac63a610d4 100644 --- a/nanovdb/nanovdb/unittest/CMakeLists.txt +++ b/nanovdb/nanovdb/unittest/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(NanoVDBTests LANGUAGES CXX) include(GNUInstallDirs) diff --git a/nanovdb/nanovdb/unittest/TestNanoVDB.cc b/nanovdb/nanovdb/unittest/TestNanoVDB.cc index 4d39b443bb..33e120c063 100644 --- a/nanovdb/nanovdb/unittest/TestNanoVDB.cc +++ b/nanovdb/nanovdb/unittest/TestNanoVDB.cc @@ -1,9 +1,10 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // Uncomment to temporarily disable testing of PNanoVDB //#define DISABLE_PNANOVDB +#include #include #include #include // for std::stringstream diff --git a/nanovdb/nanovdb/unittest/TestNanoVDB.cu b/nanovdb/nanovdb/unittest/TestNanoVDB.cu index 0b0ee9eccf..0d5f797299 100644 --- a/nanovdb/nanovdb/unittest/TestNanoVDB.cu +++ b/nanovdb/nanovdb/unittest/TestNanoVDB.cu @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/nanovdb/nanovdb/unittest/TestOpenVDB.cc b/nanovdb/nanovdb/unittest/TestOpenVDB.cc index 06b9da7f4c..238bdc8026 100644 --- a/nanovdb/nanovdb/unittest/TestOpenVDB.cc +++ b/nanovdb/nanovdb/unittest/TestOpenVDB.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/nanovdb/nanovdb/unittest/pnanovdb_validate_strides.h b/nanovdb/nanovdb/unittest/pnanovdb_validate_strides.h index 02f27c1ea3..6d2eef02d4 100644 --- a/nanovdb/nanovdb/unittest/pnanovdb_validate_strides.h +++ b/nanovdb/nanovdb/unittest/pnanovdb_validate_strides.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file pnanovdb_validate_strides.h diff --git a/nanovdb/nanovdb/util/CpuTimer.h b/nanovdb/nanovdb/util/CpuTimer.h index af1ac90d77..4c22f01d5f 100644 --- a/nanovdb/nanovdb/util/CpuTimer.h +++ b/nanovdb/nanovdb/util/CpuTimer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/CreateNanoGrid.h b/nanovdb/nanovdb/util/CreateNanoGrid.h index eeef8ab71b..60fa3fd581 100644 --- a/nanovdb/nanovdb/util/CreateNanoGrid.h +++ b/nanovdb/nanovdb/util/CreateNanoGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/DitherLUT.h b/nanovdb/nanovdb/util/DitherLUT.h index 270f82d378..4d6ff166a9 100644 --- a/nanovdb/nanovdb/util/DitherLUT.h +++ b/nanovdb/nanovdb/util/DitherLUT.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/ForEach.h b/nanovdb/nanovdb/util/ForEach.h index f4c20f2bce..d71769c5ab 100644 --- a/nanovdb/nanovdb/util/ForEach.h +++ b/nanovdb/nanovdb/util/ForEach.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/util/ForEach.h diff --git a/nanovdb/nanovdb/util/GridBuilder.h b/nanovdb/nanovdb/util/GridBuilder.h index bc1ce63eb5..681da5ff33 100644 --- a/nanovdb/nanovdb/util/GridBuilder.h +++ b/nanovdb/nanovdb/util/GridBuilder.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/GridChecksum.h b/nanovdb/nanovdb/util/GridChecksum.h index 1b0075f9c0..1c70c7b39f 100644 --- a/nanovdb/nanovdb/util/GridChecksum.h +++ b/nanovdb/nanovdb/util/GridChecksum.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/GridStats.h b/nanovdb/nanovdb/util/GridStats.h index e84b14229b..61de3b0d7b 100644 --- a/nanovdb/nanovdb/util/GridStats.h +++ b/nanovdb/nanovdb/util/GridStats.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/GridValidator.h b/nanovdb/nanovdb/util/GridValidator.h index 476e760d4e..8dc1465cba 100644 --- a/nanovdb/nanovdb/util/GridValidator.h +++ b/nanovdb/nanovdb/util/GridValidator.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/HDDA.h b/nanovdb/nanovdb/util/HDDA.h index 4430c40701..9944833b9d 100644 --- a/nanovdb/nanovdb/util/HDDA.h +++ b/nanovdb/nanovdb/util/HDDA.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/HostBuffer.h b/nanovdb/nanovdb/util/HostBuffer.h index b843eed478..a893d4944c 100644 --- a/nanovdb/nanovdb/util/HostBuffer.h +++ b/nanovdb/nanovdb/util/HostBuffer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/IO.h b/nanovdb/nanovdb/util/IO.h index 49d51e4f24..385d4251b8 100644 --- a/nanovdb/nanovdb/util/IO.h +++ b/nanovdb/nanovdb/util/IO.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/Invoke.h b/nanovdb/nanovdb/util/Invoke.h index f0e1561bb4..677e033c5a 100644 --- a/nanovdb/nanovdb/util/Invoke.h +++ b/nanovdb/nanovdb/util/Invoke.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/util/Invoke.h diff --git a/nanovdb/nanovdb/util/NanoToOpenVDB.h b/nanovdb/nanovdb/util/NanoToOpenVDB.h index ea7c956104..a6c2168231 100644 --- a/nanovdb/nanovdb/util/NanoToOpenVDB.h +++ b/nanovdb/nanovdb/util/NanoToOpenVDB.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/NodeManager.h b/nanovdb/nanovdb/util/NodeManager.h index 5f665ee7f6..076a18eba6 100644 --- a/nanovdb/nanovdb/util/NodeManager.h +++ b/nanovdb/nanovdb/util/NodeManager.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/OpenToNanoVDB.h b/nanovdb/nanovdb/util/OpenToNanoVDB.h index a4cecde1de..c7dcce334b 100644 --- a/nanovdb/nanovdb/util/OpenToNanoVDB.h +++ b/nanovdb/nanovdb/util/OpenToNanoVDB.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/PrefixSum.h b/nanovdb/nanovdb/util/PrefixSum.h index 0f70a81a10..1100108736 100644 --- a/nanovdb/nanovdb/util/PrefixSum.h +++ b/nanovdb/nanovdb/util/PrefixSum.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/util/PrefixSum.h diff --git a/nanovdb/nanovdb/util/Primitives.h b/nanovdb/nanovdb/util/Primitives.h index 0d6714e0d2..79cfe61589 100644 --- a/nanovdb/nanovdb/util/Primitives.h +++ b/nanovdb/nanovdb/util/Primitives.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/Range.h b/nanovdb/nanovdb/util/Range.h index c12873513e..e9ff766ede 100644 --- a/nanovdb/nanovdb/util/Range.h +++ b/nanovdb/nanovdb/util/Range.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/util/Range.h diff --git a/nanovdb/nanovdb/util/Ray.h b/nanovdb/nanovdb/util/Ray.h index 1fed33bf7c..9038490903 100644 --- a/nanovdb/nanovdb/util/Ray.h +++ b/nanovdb/nanovdb/util/Ray.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/Reduce.h b/nanovdb/nanovdb/util/Reduce.h index eb0a5e749c..f171b252da 100644 --- a/nanovdb/nanovdb/util/Reduce.h +++ b/nanovdb/nanovdb/util/Reduce.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/util/Reduce.h diff --git a/nanovdb/nanovdb/util/SampleFromVoxels.h b/nanovdb/nanovdb/util/SampleFromVoxels.h index b40ea82677..0280244416 100644 --- a/nanovdb/nanovdb/util/SampleFromVoxels.h +++ b/nanovdb/nanovdb/util/SampleFromVoxels.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/Stencils.h b/nanovdb/nanovdb/util/Stencils.h index c93b4a15cf..2de91c5278 100644 --- a/nanovdb/nanovdb/util/Stencils.h +++ b/nanovdb/nanovdb/util/Stencils.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/Timer.h b/nanovdb/nanovdb/util/Timer.h index 992b055b4c..b2d8dc9e9c 100644 --- a/nanovdb/nanovdb/util/Timer.h +++ b/nanovdb/nanovdb/util/Timer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file nanovdb/util/Timer.h /// diff --git a/nanovdb/nanovdb/util/Util.h b/nanovdb/nanovdb/util/Util.h index e8ebfc1c63..7dcdfbdb84 100644 --- a/nanovdb/nanovdb/util/Util.h +++ b/nanovdb/nanovdb/util/Util.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/util/Util.h diff --git a/nanovdb/nanovdb/util/cuda/CudaAddBlindData.cuh b/nanovdb/nanovdb/util/cuda/CudaAddBlindData.cuh index d366bd9845..39ece43d04 100644 --- a/nanovdb/nanovdb/util/cuda/CudaAddBlindData.cuh +++ b/nanovdb/nanovdb/util/cuda/CudaAddBlindData.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/cuda/CudaDeviceBuffer.h b/nanovdb/nanovdb/util/cuda/CudaDeviceBuffer.h index b05fbac802..65371c6cba 100644 --- a/nanovdb/nanovdb/util/cuda/CudaDeviceBuffer.h +++ b/nanovdb/nanovdb/util/cuda/CudaDeviceBuffer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/cuda/CudaGridChecksum.cuh b/nanovdb/nanovdb/util/cuda/CudaGridChecksum.cuh index e52ee89ac4..fe897d457f 100644 --- a/nanovdb/nanovdb/util/cuda/CudaGridChecksum.cuh +++ b/nanovdb/nanovdb/util/cuda/CudaGridChecksum.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/cuda/CudaGridHandle.cuh b/nanovdb/nanovdb/util/cuda/CudaGridHandle.cuh index 9e0c0faeb4..db68f2386a 100644 --- a/nanovdb/nanovdb/util/cuda/CudaGridHandle.cuh +++ b/nanovdb/nanovdb/util/cuda/CudaGridHandle.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/cuda/CudaGridStats.cuh b/nanovdb/nanovdb/util/cuda/CudaGridStats.cuh index 64c6490768..acc62af585 100644 --- a/nanovdb/nanovdb/util/cuda/CudaGridStats.cuh +++ b/nanovdb/nanovdb/util/cuda/CudaGridStats.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/cuda/CudaGridValidator.cuh b/nanovdb/nanovdb/util/cuda/CudaGridValidator.cuh index ca535d4013..a89c8cae4a 100644 --- a/nanovdb/nanovdb/util/cuda/CudaGridValidator.cuh +++ b/nanovdb/nanovdb/util/cuda/CudaGridValidator.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/cuda/CudaIndexToGrid.cuh b/nanovdb/nanovdb/util/cuda/CudaIndexToGrid.cuh index ed5e67da33..4a15b52357 100644 --- a/nanovdb/nanovdb/util/cuda/CudaIndexToGrid.cuh +++ b/nanovdb/nanovdb/util/cuda/CudaIndexToGrid.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/cuda/CudaNodeManager.cuh b/nanovdb/nanovdb/util/cuda/CudaNodeManager.cuh index 5aa5b84965..ca287266c4 100644 --- a/nanovdb/nanovdb/util/cuda/CudaNodeManager.cuh +++ b/nanovdb/nanovdb/util/cuda/CudaNodeManager.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/cuda/CudaPointsToGrid.cuh b/nanovdb/nanovdb/util/cuda/CudaPointsToGrid.cuh index 91e7ad0b5c..7494b607ec 100644 --- a/nanovdb/nanovdb/util/cuda/CudaPointsToGrid.cuh +++ b/nanovdb/nanovdb/util/cuda/CudaPointsToGrid.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/cuda/CudaSignedFloodFill.cuh b/nanovdb/nanovdb/util/cuda/CudaSignedFloodFill.cuh index f9ba99b8fc..7f0d9ce069 100644 --- a/nanovdb/nanovdb/util/cuda/CudaSignedFloodFill.cuh +++ b/nanovdb/nanovdb/util/cuda/CudaSignedFloodFill.cuh @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/cuda/CudaUtils.h b/nanovdb/nanovdb/util/cuda/CudaUtils.h index e154ff9b4e..38f7c94a37 100644 --- a/nanovdb/nanovdb/util/cuda/CudaUtils.h +++ b/nanovdb/nanovdb/util/cuda/CudaUtils.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/cuda/GpuTimer.h b/nanovdb/nanovdb/util/cuda/GpuTimer.h index be7f81b227..ee0b0c716d 100644 --- a/nanovdb/nanovdb/util/cuda/GpuTimer.h +++ b/nanovdb/nanovdb/util/cuda/GpuTimer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for NANOVDB_DEPRECATED_HEADER #include diff --git a/nanovdb/nanovdb/util/cuda/Timer.h b/nanovdb/nanovdb/util/cuda/Timer.h index 1bb7224461..07c9366a0d 100644 --- a/nanovdb/nanovdb/util/cuda/Timer.h +++ b/nanovdb/nanovdb/util/cuda/Timer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file nanovdb/util/cuda/Timer.h /// diff --git a/nanovdb/nanovdb/util/cuda/Util.h b/nanovdb/nanovdb/util/cuda/Util.h index 8ebfde61e2..8d1711b3aa 100644 --- a/nanovdb/nanovdb/util/cuda/Util.h +++ b/nanovdb/nanovdb/util/cuda/Util.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /*! \file nanovdb/util/cuda/Util.h diff --git a/openvdb/openvdb/CMakeLists.txt b/openvdb/openvdb/CMakeLists.txt index 9cc531cdf7..3db0e4e144 100644 --- a/openvdb/openvdb/CMakeLists.txt +++ b/openvdb/openvdb/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(OpenVDBCore LANGUAGES CXX) include(GNUInstallDirs) @@ -110,16 +110,14 @@ endif() if(OPENVDB_USE_DELAYED_LOADING) find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS iostreams) -else() - find_package(Boost ${MINIMUM_BOOST_VERSION} REQUIRED COMPONENTS headers) -endif() -if(OPENVDB_FUTURE_DEPRECATION AND FUTURE_MINIMUM_BOOST_VERSION) - # The X.Y.Z boost version value isn't available until CMake 3.14 - set(FULL_BOOST_VERSION "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") - if(${FULL_BOOST_VERSION} VERSION_LESS FUTURE_MINIMUM_BOOST_VERSION) - message(DEPRECATION "Support for Boost versions < ${FUTURE_MINIMUM_BOOST_VERSION} " - "is deprecated and will be removed.") + if(OPENVDB_FUTURE_DEPRECATION AND FUTURE_MINIMUM_BOOST_VERSION) + # The X.Y.Z boost version value isn't available until CMake 3.14 + set(FULL_BOOST_VERSION "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}") + if(${FULL_BOOST_VERSION} VERSION_LESS FUTURE_MINIMUM_BOOST_VERSION) + message(DEPRECATION "Support for Boost versions < ${FUTURE_MINIMUM_BOOST_VERSION} " + "is deprecated and will be removed.") + endif() endif() endif() @@ -246,20 +244,17 @@ endif() if(OPENVDB_USE_DELAYED_LOADING) list(APPEND OPENVDB_CORE_DEPENDENT_LIBS Boost::iostreams) -else() - list(APPEND OPENVDB_CORE_DEPENDENT_LIBS Boost::headers) -endif() - -if(WIN32) - # Boost headers contain #pragma commands on Windows which causes Boost - # libraries to be linked in automatically. Custom boost installations - # may find that these naming conventions don't always match and can - # cause linker errors. This option disables this feature of Boost. Note - # -DBOOST_ALL_NO_LIB can also be provided manually. - if(OPENVDB_DISABLE_BOOST_IMPLICIT_LINKING) - list(APPEND OPENVDB_CORE_DEPENDENT_LIBS - Boost::disable_autolinking # add -DBOOST_ALL_NO_LIB - ) + if(WIN32) + # Boost headers contain #pragma commands on Windows which causes Boost + # libraries to be linked in automatically. Custom boost installations + # may find that these naming conventions don't always match and can + # cause linker errors. This option disables this feature of Boost. Note + # -DBOOST_ALL_NO_LIB can also be provided manually. + if(OPENVDB_DISABLE_BOOST_IMPLICIT_LINKING) + list(APPEND OPENVDB_CORE_DEPENDENT_LIBS + Boost::disable_autolinking # add -DBOOST_ALL_NO_LIB + ) + endif() endif() endif() @@ -725,27 +720,27 @@ endif() if(OPENVDB_CORE_STATIC) install(TARGETS openvdb_static - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR} + LIBRARY DESTINATION ${OPENVDB_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${OPENVDB_INSTALL_LIBDIR} ) endif() if(OPENVDB_CORE_SHARED) install(TARGETS openvdb_shared - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR} + LIBRARY DESTINATION ${OPENVDB_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${OPENVDB_INSTALL_LIBDIR} ) endif() -install(FILES ${OPENVDB_LIBRARY_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openvdb/version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb) -install(FILES ${OPENVDB_LIBRARY_IO_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/io) -install(FILES ${OPENVDB_LIBRARY_MATH_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/math) -install(FILES ${OPENVDB_LIBRARY_POINTS_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/points) -install(FILES ${OPENVDB_LIBRARY_POINTS_IMPL_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/points/impl) -install(FILES ${OPENVDB_LIBRARY_TOOLS_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/tools) -install(FILES ${OPENVDB_LIBRARY_TREE_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/tree) -install(FILES ${OPENVDB_LIBRARY_UTIL_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/util) -install(FILES ${OPENVDB_LIBRARY_THREAD_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/thread) +install(FILES ${OPENVDB_LIBRARY_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openvdb/version.h DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb) +install(FILES ${OPENVDB_LIBRARY_IO_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/io) +install(FILES ${OPENVDB_LIBRARY_MATH_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/math) +install(FILES ${OPENVDB_LIBRARY_POINTS_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/points) +install(FILES ${OPENVDB_LIBRARY_POINTS_IMPL_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/points/impl) +install(FILES ${OPENVDB_LIBRARY_TOOLS_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/tools) +install(FILES ${OPENVDB_LIBRARY_TREE_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/tree) +install(FILES ${OPENVDB_LIBRARY_UTIL_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/util) +install(FILES ${OPENVDB_LIBRARY_THREAD_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb/thread) diff --git a/openvdb/openvdb/COPYRIGHT b/openvdb/openvdb/COPYRIGHT index 4f8f1897d1..7ebccaf678 100644 --- a/openvdb/openvdb/COPYRIGHT +++ b/openvdb/openvdb/COPYRIGHT @@ -1,2 +1,2 @@ Copyright Contributors to the OpenVDB Project -SPDX-License-Identifier: MPL-2.0 \ No newline at end of file +SPDX-License-Identifier: Apache-2.0 \ No newline at end of file diff --git a/openvdb/openvdb/Exceptions.h b/openvdb/openvdb/Exceptions.h index 4cf9f47e97..a656edd1ae 100644 --- a/openvdb/openvdb/Exceptions.h +++ b/openvdb/openvdb/Exceptions.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_EXCEPTIONS_HAS_BEEN_INCLUDED #define OPENVDB_EXCEPTIONS_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/Grid.cc b/openvdb/openvdb/Grid.cc index 1e14cb08a4..b53c4fd21e 100644 --- a/openvdb/openvdb/Grid.cc +++ b/openvdb/openvdb/Grid.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "Grid.h" #include "Metadata.h" diff --git a/openvdb/openvdb/Grid.h b/openvdb/openvdb/Grid.h index 14aad39122..cb2d2eba74 100644 --- a/openvdb/openvdb/Grid.h +++ b/openvdb/openvdb/Grid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_GRID_HAS_BEEN_INCLUDED #define OPENVDB_GRID_HAS_BEEN_INCLUDED @@ -586,10 +586,10 @@ class Grid: public GridBase using ValueAllIter = typename _TreeType::ValueAllIter; using ValueAllCIter = typename _TreeType::ValueAllCIter; - using Accessor = typename tree::ValueAccessor<_TreeType, true>; - using ConstAccessor = typename tree::ValueAccessor; - using UnsafeAccessor = typename tree::ValueAccessor<_TreeType, false>; - using ConstUnsafeAccessor = typename tree::ValueAccessor; + using Accessor = typename _TreeType::Accessor; + using ConstAccessor = typename _TreeType::ConstAccessor; + using UnsafeAccessor = typename _TreeType::UnsafeAccessor; + using ConstUnsafeAccessor = typename _TreeType::ConstUnsafeAccessor; /// @brief ValueConverter::Type is the type of a grid having the same /// hierarchy as this grid but a different value type, T. @@ -729,7 +729,7 @@ class Grid: public GridBase /// @brief Return an accessor that provides random read and write access /// to this grid's voxels. /// @details The accessor is safe in the sense that it is registered with this grid's tree. - Accessor getAccessor() { return Accessor(tree()); } + Accessor getAccessor() { return mTree->getAccessor(); } /// @brief Return an unsafe accessor that provides random read and write access /// to this grid's voxels. /// @details The accessor is unsafe in the sense that it is not registered @@ -737,11 +737,11 @@ class Grid: public GridBase /// over a registered accessor, but it is unsafe if the tree topology is modified. /// @warning Only use this method if you're an expert and know the /// risks of using an unregistered accessor (see tree/ValueAccessor.h) - UnsafeAccessor getUnsafeAccessor() { return UnsafeAccessor(tree()); } + UnsafeAccessor getUnsafeAccessor() { return mTree->getUnsafeAccessor(); } /// Return an accessor that provides random read-only access to this grid's voxels. - ConstAccessor getAccessor() const { return ConstAccessor(tree()); } + ConstAccessor getAccessor() const { return mTree->getConstAccessor(); } /// Return an accessor that provides random read-only access to this grid's voxels. - ConstAccessor getConstAccessor() const { return ConstAccessor(tree()); } + ConstAccessor getConstAccessor() const { return mTree->getConstAccessor(); } /// @brief Return an unsafe accessor that provides random read-only access /// to this grid's voxels. /// @details The accessor is unsafe in the sense that it is not registered @@ -749,7 +749,7 @@ class Grid: public GridBase /// over a registered accessor, but it is unsafe if the tree topology is modified. /// @warning Only use this method if you're an expert and know the /// risks of using an unregistered accessor (see tree/ValueAccessor.h) - ConstUnsafeAccessor getConstUnsafeAccessor() const { return ConstUnsafeAccessor(tree()); } + ConstUnsafeAccessor getConstUnsafeAccessor() const { return mTree->getConstUnsafeAccessor(); } /// Return an iterator over all of this grid's active values (tile and voxel). ValueOnIter beginValueOn() { return tree().beginValueOn(); } @@ -1063,7 +1063,7 @@ struct TreeAdapter using TreePtrType = typename TreeType::Ptr; using ConstTreePtrType = typename TreeType::ConstPtr; using NonConstTreePtrType = typename NonConstTreeType::Ptr; - using GridType = Grid; + using GridType = Grid; using NonConstGridType = Grid; using GridPtrType = typename GridType::Ptr; using NonConstGridPtrType = typename NonConstGridType::Ptr; @@ -1073,14 +1073,14 @@ struct TreeAdapter using ConstAccessorType = typename tree::ValueAccessor; using NonConstAccessorType = typename tree::ValueAccessor; - static TreeType& tree(TreeType& t) { return t; } - static TreeType& tree(GridType& g) { return g.tree(); } - static const TreeType& tree(const TreeType& t) { return t; } - static const TreeType& tree(const GridType& g) { return g.tree(); } - static const TreeType& constTree(TreeType& t) { return t; } - static const TreeType& constTree(GridType& g) { return g.constTree(); } - static const TreeType& constTree(const TreeType& t) { return t; } - static const TreeType& constTree(const GridType& g) { return g.constTree(); } + static NonConstTreeType& tree(NonConstTreeType& t) { return t; } + static NonConstTreeType& tree(NonConstGridType& g) { return g.tree(); } + static const NonConstTreeType& tree(const NonConstTreeType& t) { return t; } + static const NonConstTreeType& tree(const NonConstGridType& g) { return g.tree(); } + static const NonConstTreeType& constTree(NonConstTreeType& t) { return t; } + static const NonConstTreeType& constTree(NonConstGridType& g) { return g.constTree(); } + static const NonConstTreeType& constTree(const NonConstTreeType& t) { return t; } + static const NonConstTreeType& constTree(const NonConstGridType& g) { return g.constTree(); } }; @@ -1103,19 +1103,19 @@ struct TreeAdapter > using ConstAccessorType = typename tree::ValueAccessor; using NonConstAccessorType = typename tree::ValueAccessor; - static TreeType& tree(TreeType& t) { return t; } - static TreeType& tree(GridType& g) { return g.tree(); } - static const TreeType& tree(const TreeType& t) { return t; } - static const TreeType& tree(const GridType& g) { return g.tree(); } - static const TreeType& constTree(TreeType& t) { return t; } - static const TreeType& constTree(GridType& g) { return g.constTree(); } - static const TreeType& constTree(const TreeType& t) { return t; } - static const TreeType& constTree(const GridType& g) { return g.constTree(); } + static NonConstTreeType& tree(NonConstTreeType& t) { return t; } + static NonConstTreeType& tree(NonConstGridType& g) { return g.tree(); } + static const NonConstTreeType& tree(const NonConstTreeType& t) { return t; } + static const NonConstTreeType& tree(const NonConstGridType& g) { return g.tree(); } + static const NonConstTreeType& constTree(NonConstTreeType& t) { return t; } + static const NonConstTreeType& constTree(NonConstGridType& g) { return g.constTree(); } + static const NonConstTreeType& constTree(const NonConstTreeType& t) { return t; } + static const NonConstTreeType& constTree(const NonConstGridType& g) { return g.constTree(); } }; -/// Partial specialization for ValueAccessor types +/// Partial specialization for const Grid types template -struct TreeAdapter > +struct TreeAdapter > { using TreeType = _TreeType; using NonConstTreeType = typename std::remove_const::type; @@ -1132,16 +1132,51 @@ struct TreeAdapter > using ConstAccessorType = typename tree::ValueAccessor; using NonConstAccessorType = typename tree::ValueAccessor; - static TreeType& tree(TreeType& t) { return t; } - static TreeType& tree(GridType& g) { return g.tree(); } - static TreeType& tree(AccessorType& a) { return a.tree(); } - static const TreeType& tree(const TreeType& t) { return t; } - static const TreeType& tree(const GridType& g) { return g.tree(); } - static const TreeType& tree(const AccessorType& a) { return a.tree(); } - static const TreeType& constTree(TreeType& t) { return t; } - static const TreeType& constTree(GridType& g) { return g.constTree(); } - static const TreeType& constTree(const TreeType& t) { return t; } - static const TreeType& constTree(const GridType& g) { return g.constTree(); } + static NonConstTreeType& tree(NonConstTreeType& t) { return t; } + static NonConstTreeType& tree(NonConstGridType& g) { return g.tree(); } + static const NonConstTreeType& tree(const NonConstTreeType& t) { return t; } + static const NonConstTreeType& tree(const NonConstGridType& g) { return g.tree(); } + static const NonConstTreeType& constTree(NonConstTreeType& t) { return t; } + static const NonConstTreeType& constTree(NonConstGridType& g) { return g.constTree(); } + static const NonConstTreeType& constTree(const NonConstTreeType& t) { return t; } + static const NonConstTreeType& constTree(const NonConstGridType& g) { return g.constTree(); } +}; + +/// Partial specialization for ValueAccessor types +template +struct TreeAdapter > +{ + using TreeType = _TreeType; + using NonConstTreeType = typename std::remove_const::type; + using TreePtrType = typename TreeType::Ptr; + using ConstTreePtrType = typename TreeType::ConstPtr; + using NonConstTreePtrType = typename NonConstTreeType::Ptr; + using GridType = Grid; + using NonConstGridType = Grid; + using GridPtrType = typename GridType::Ptr; + using NonConstGridPtrType = typename NonConstGridType::Ptr; + using ConstGridPtrType = typename GridType::ConstPtr; + using ValueType = typename TreeType::ValueType; + using AccessorType = typename tree::ValueAccessor; + using ConstAccessorType = typename tree::ValueAccessor; + using NonConstAccessorType = typename tree::ValueAccessor; + + static NonConstTreeType& tree(NonConstTreeType& t) { return t; } + static NonConstTreeType& tree(NonConstGridType& g) { return g.tree(); } + static NonConstTreeType& tree(NonConstAccessorType& a) { return a.tree(); } + static const NonConstTreeType& tree(ConstAccessorType& a) { return a.tree(); } + static const NonConstTreeType& tree(const NonConstTreeType& t) { return t; } + static const NonConstTreeType& tree(const NonConstGridType& g) { return g.tree(); } + static const NonConstTreeType& tree(const NonConstAccessorType& a) { return a.tree(); } + static const NonConstTreeType& tree(const ConstAccessorType& a) { return a.tree(); } + static const NonConstTreeType& constTree(NonConstTreeType& t) { return t; } + static const NonConstTreeType& constTree(NonConstGridType& g) { return g.constTree(); } + static const NonConstTreeType& constTree(NonConstAccessorType& a) { return a.tree(); } + static const NonConstTreeType& constTree(ConstAccessorType& a) { return a.tree(); } + static const NonConstTreeType& constTree(const NonConstTreeType& t) { return t; } + static const NonConstTreeType& constTree(const NonConstGridType& g) { return g.constTree(); } + static const NonConstTreeType& constTree(const NonConstAccessorType& a) { return a.tree(); } + static const NonConstTreeType& constTree(const ConstAccessorType& a) { return a.tree(); } }; //@} diff --git a/openvdb/openvdb/LICENSE b/openvdb/openvdb/LICENSE index a612ad9813..d9a10c0d8e 100644 --- a/openvdb/openvdb/LICENSE +++ b/openvdb/openvdb/LICENSE @@ -1,373 +1,176 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/openvdb/openvdb/MetaMap.cc b/openvdb/openvdb/MetaMap.cc index a48934b0cb..ba19ca0a1e 100644 --- a/openvdb/openvdb/MetaMap.cc +++ b/openvdb/openvdb/MetaMap.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "MetaMap.h" diff --git a/openvdb/openvdb/MetaMap.h b/openvdb/openvdb/MetaMap.h index 8f01acd79c..7b109bcaf0 100644 --- a/openvdb/openvdb/MetaMap.h +++ b/openvdb/openvdb/MetaMap.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_METADATA_METAMAP_HAS_BEEN_INCLUDED #define OPENVDB_METADATA_METAMAP_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/Metadata.cc b/openvdb/openvdb/Metadata.cc index a68c4ef6fa..8819d4cb06 100644 --- a/openvdb/openvdb/Metadata.cc +++ b/openvdb/openvdb/Metadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "Metadata.h" diff --git a/openvdb/openvdb/Metadata.h b/openvdb/openvdb/Metadata.h index 8105c225ad..d17082e150 100644 --- a/openvdb/openvdb/Metadata.h +++ b/openvdb/openvdb/Metadata.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_METADATA_HAS_BEEN_INCLUDED #define OPENVDB_METADATA_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/Platform.cc b/openvdb/openvdb/Platform.cc index 4a7f61152f..aa54fd56d8 100644 --- a/openvdb/openvdb/Platform.cc +++ b/openvdb/openvdb/Platform.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // For Windows, we need these includes to ensure all OPENVDB_API // functions/classes are compiled into the shared library. diff --git a/openvdb/openvdb/Platform.h b/openvdb/openvdb/Platform.h index b8a8f1cb6f..eebd4620ad 100644 --- a/openvdb/openvdb/Platform.h +++ b/openvdb/openvdb/Platform.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// /// @file Platform.h @@ -211,16 +211,10 @@ #define OPENVDB_NO_TYPE_CONVERSION_WARNING_END #elif defined __GNUC__ // -Wfloat-conversion was only introduced in GCC 4.9 - #if OPENVDB_CHECK_GCC(4, 9) - #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wconversion\"") \ - _Pragma("GCC diagnostic ignored \"-Wfloat-conversion\"") - #else - #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wconversion\"") - #endif + #define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN \ + _Pragma("GCC diagnostic push") \ + _Pragma("GCC diagnostic ignored \"-Wconversion\"") \ + _Pragma("GCC diagnostic ignored \"-Wfloat-conversion\"") #define OPENVDB_NO_TYPE_CONVERSION_WARNING_END \ _Pragma("GCC diagnostic pop") #else diff --git a/openvdb/openvdb/PlatformConfig.h b/openvdb/openvdb/PlatformConfig.h index 33a5e8f883..7ec27afd0c 100644 --- a/openvdb/openvdb/PlatformConfig.h +++ b/openvdb/openvdb/PlatformConfig.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// /// @file PlatformConfig.h /// @note PlatformConfig.h will be marked as deprecated in the future diff --git a/openvdb/openvdb/TypeList.h b/openvdb/openvdb/TypeList.h index 2f66033ede..65a26fabcc 100644 --- a/openvdb/openvdb/TypeList.h +++ b/openvdb/openvdb/TypeList.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file TypeList.h /// diff --git a/openvdb/openvdb/Types.h b/openvdb/openvdb/Types.h index d654750b7e..9d05033c7d 100644 --- a/openvdb/openvdb/Types.h +++ b/openvdb/openvdb/Types.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_TYPES_HAS_BEEN_INCLUDED #define OPENVDB_TYPES_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/io/Archive.cc b/openvdb/openvdb/io/Archive.cc index 9b1374c9cc..8f99565f20 100644 --- a/openvdb/openvdb/io/Archive.cc +++ b/openvdb/openvdb/io/Archive.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "Archive.h" @@ -357,10 +357,10 @@ struct PopulateDelayedLoadMetadataOp using MaskT = typename LeafT::NodeMaskType; const TreeT& tree = grid.constTree(); - const Index32 leafCount = tree.leafCount(); + const Index64 leafCount = tree.leafCount(); // early exit if not leaf nodes - if (leafCount == Index32(0)) return; + if (leafCount == Index64(0)) return; metadata.resizeMask(leafCount); diff --git a/openvdb/openvdb/io/Archive.h b/openvdb/openvdb/io/Archive.h index 8b4e483860..4e4e680273 100644 --- a/openvdb/openvdb/io/Archive.h +++ b/openvdb/openvdb/io/Archive.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_IO_ARCHIVE_HAS_BEEN_INCLUDED #define OPENVDB_IO_ARCHIVE_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/io/Compression.cc b/openvdb/openvdb/io/Compression.cc index bfe1edcd87..b9f4847066 100644 --- a/openvdb/openvdb/io/Compression.cc +++ b/openvdb/openvdb/io/Compression.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "Compression.h" diff --git a/openvdb/openvdb/io/Compression.h b/openvdb/openvdb/io/Compression.h index 0316db0544..b21edb12e9 100644 --- a/openvdb/openvdb/io/Compression.h +++ b/openvdb/openvdb/io/Compression.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_IO_COMPRESSION_HAS_BEEN_INCLUDED #define OPENVDB_IO_COMPRESSION_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/io/DelayedLoadMetadata.cc b/openvdb/openvdb/io/DelayedLoadMetadata.cc index 29a783705a..1f958b0a4c 100644 --- a/openvdb/openvdb/io/DelayedLoadMetadata.cc +++ b/openvdb/openvdb/io/DelayedLoadMetadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "DelayedLoadMetadata.h" diff --git a/openvdb/openvdb/io/DelayedLoadMetadata.h b/openvdb/openvdb/io/DelayedLoadMetadata.h index b80c666df4..8ba9d6f519 100644 --- a/openvdb/openvdb/io/DelayedLoadMetadata.h +++ b/openvdb/openvdb/io/DelayedLoadMetadata.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_DELAYED_LOAD_METADATA_HAS_BEEN_INCLUDED #define OPENVDB_DELAYED_LOAD_METADATA_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/io/File.cc b/openvdb/openvdb/io/File.cc index 723b94691c..42e02545c5 100644 --- a/openvdb/openvdb/io/File.cc +++ b/openvdb/openvdb/io/File.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file io/File.cc diff --git a/openvdb/openvdb/io/File.h b/openvdb/openvdb/io/File.h index c258d4564e..41dd6f9694 100644 --- a/openvdb/openvdb/io/File.h +++ b/openvdb/openvdb/io/File.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file File.h diff --git a/openvdb/openvdb/io/GridDescriptor.cc b/openvdb/openvdb/io/GridDescriptor.cc index e725acdef0..2c6c3826aa 100644 --- a/openvdb/openvdb/io/GridDescriptor.cc +++ b/openvdb/openvdb/io/GridDescriptor.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "GridDescriptor.h" diff --git a/openvdb/openvdb/io/GridDescriptor.h b/openvdb/openvdb/io/GridDescriptor.h index 93cd628538..9ef03262e2 100644 --- a/openvdb/openvdb/io/GridDescriptor.h +++ b/openvdb/openvdb/io/GridDescriptor.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_IO_GRIDDESCRIPTOR_HAS_BEEN_INCLUDED #define OPENVDB_IO_GRIDDESCRIPTOR_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/io/Queue.cc b/openvdb/openvdb/io/Queue.cc index daf9654572..8f4536f5eb 100644 --- a/openvdb/openvdb/io/Queue.cc +++ b/openvdb/openvdb/io/Queue.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file Queue.cc /// @author Peter Cucka diff --git a/openvdb/openvdb/io/Queue.h b/openvdb/openvdb/io/Queue.h index 302573487f..d7d13800d6 100644 --- a/openvdb/openvdb/io/Queue.h +++ b/openvdb/openvdb/io/Queue.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file Queue.h /// @author Peter Cucka diff --git a/openvdb/openvdb/io/Stream.cc b/openvdb/openvdb/io/Stream.cc index 8ff41fdf24..662a2f4cd9 100644 --- a/openvdb/openvdb/io/Stream.cc +++ b/openvdb/openvdb/io/Stream.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "Stream.h" diff --git a/openvdb/openvdb/io/Stream.h b/openvdb/openvdb/io/Stream.h index 049bc43dd4..e2978dc20d 100644 --- a/openvdb/openvdb/io/Stream.h +++ b/openvdb/openvdb/io/Stream.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_IO_STREAM_HAS_BEEN_INCLUDED #define OPENVDB_IO_STREAM_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/io/TempFile.cc b/openvdb/openvdb/io/TempFile.cc index d827b2c522..290f2e6b9c 100644 --- a/openvdb/openvdb/io/TempFile.cc +++ b/openvdb/openvdb/io/TempFile.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file TempFile.cc diff --git a/openvdb/openvdb/io/TempFile.h b/openvdb/openvdb/io/TempFile.h index 6f5c991d9c..cbbdec2250 100644 --- a/openvdb/openvdb/io/TempFile.h +++ b/openvdb/openvdb/io/TempFile.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file TempFile.h diff --git a/openvdb/openvdb/io/io.h b/openvdb/openvdb/io/io.h index f63afd35ac..bf3ec0d162 100644 --- a/openvdb/openvdb/io/io.h +++ b/openvdb/openvdb/io/io.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_IO_IO_HAS_BEEN_INCLUDED #define OPENVDB_IO_IO_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/math/BBox.h b/openvdb/openvdb/math/BBox.h index b2e8d70ea0..4fdcf1027c 100644 --- a/openvdb/openvdb/math/BBox.h +++ b/openvdb/openvdb/math/BBox.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_MATH_BBOX_HAS_BEEN_INCLUDED #define OPENVDB_MATH_BBOX_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/math/ConjGradient.h b/openvdb/openvdb/math/ConjGradient.h index 2fd8bc4da2..483db1fa00 100644 --- a/openvdb/openvdb/math/ConjGradient.h +++ b/openvdb/openvdb/math/ConjGradient.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ConjGradient.h /// @authors D.J. Hill, Peter Cucka diff --git a/openvdb/openvdb/math/Coord.h b/openvdb/openvdb/math/Coord.h index 154a3743e5..0f0ff9c4bb 100644 --- a/openvdb/openvdb/math/Coord.h +++ b/openvdb/openvdb/math/Coord.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_MATH_COORD_HAS_BEEN_INCLUDED #define OPENVDB_MATH_COORD_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/math/DDA.h b/openvdb/openvdb/math/DDA.h index ea034c69d5..73773c5660 100644 --- a/openvdb/openvdb/math/DDA.h +++ b/openvdb/openvdb/math/DDA.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file DDA.h /// diff --git a/openvdb/openvdb/math/FiniteDifference.h b/openvdb/openvdb/math/FiniteDifference.h index 5779ffa926..f269f46a10 100644 --- a/openvdb/openvdb/math/FiniteDifference.h +++ b/openvdb/openvdb/math/FiniteDifference.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file math/FiniteDifference.h diff --git a/openvdb/openvdb/math/LegacyFrustum.h b/openvdb/openvdb/math/LegacyFrustum.h index a17b9493b2..e0ebae461e 100644 --- a/openvdb/openvdb/math/LegacyFrustum.h +++ b/openvdb/openvdb/math/LegacyFrustum.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file math/LegacyFrustum.h diff --git a/openvdb/openvdb/math/Maps.cc b/openvdb/openvdb/math/Maps.cc index 0be1904b8d..a6ed7e4411 100644 --- a/openvdb/openvdb/math/Maps.cc +++ b/openvdb/openvdb/math/Maps.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "Maps.h" #include diff --git a/openvdb/openvdb/math/Maps.h b/openvdb/openvdb/math/Maps.h index 707ae8413c..03ee7f1f1d 100644 --- a/openvdb/openvdb/math/Maps.h +++ b/openvdb/openvdb/math/Maps.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file math/Maps.h diff --git a/openvdb/openvdb/math/Mat.h b/openvdb/openvdb/math/Mat.h index 5d5bf7fa9a..d48caced5f 100644 --- a/openvdb/openvdb/math/Mat.h +++ b/openvdb/openvdb/math/Mat.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Mat.h /// @author Joshua Schpok diff --git a/openvdb/openvdb/math/Mat3.h b/openvdb/openvdb/math/Mat3.h index a503b22ca9..01c66d8868 100644 --- a/openvdb/openvdb/math/Mat3.h +++ b/openvdb/openvdb/math/Mat3.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_MATH_MAT3_H_HAS_BEEN_INCLUDED #define OPENVDB_MATH_MAT3_H_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/math/Mat4.h b/openvdb/openvdb/math/Mat4.h index 7a3db1bfed..91a256b7ba 100644 --- a/openvdb/openvdb/math/Mat4.h +++ b/openvdb/openvdb/math/Mat4.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_MATH_MAT4_H_HAS_BEEN_INCLUDED #define OPENVDB_MATH_MAT4_H_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/math/Math.h b/openvdb/openvdb/math/Math.h index 7593118c2c..4d5e3423a9 100644 --- a/openvdb/openvdb/math/Math.h +++ b/openvdb/openvdb/math/Math.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Math.h /// @brief General-purpose arithmetic and comparison routines, most of which @@ -11,7 +11,6 @@ #include #include #include -#include #include // for std::max() #include #include // for std::ceil(), std::fabs(), std::pow(), std::sqrt(), etc. @@ -917,10 +916,9 @@ enum RotationOrder { ZXZ_ROTATION }; - -template +template && std::is_arithmetic_v>> struct promote { - using type = typename boost::numeric::conversion_traits::supertype; + using type = typename std::common_type_t; }; /// @brief Return the index [0,1,2] of the smallest value in a 3D vector. diff --git a/openvdb/openvdb/math/Operators.h b/openvdb/openvdb/math/Operators.h index 7ec64e4ef8..53f4eb19d6 100644 --- a/openvdb/openvdb/math/Operators.h +++ b/openvdb/openvdb/math/Operators.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file math/Operators.h diff --git a/openvdb/openvdb/math/Proximity.cc b/openvdb/openvdb/math/Proximity.cc index d52bdc37a4..d7e9fd3a95 100644 --- a/openvdb/openvdb/math/Proximity.cc +++ b/openvdb/openvdb/math/Proximity.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "Proximity.h" diff --git a/openvdb/openvdb/math/Proximity.h b/openvdb/openvdb/math/Proximity.h index 8206d4fcd3..3a4ffa6197 100644 --- a/openvdb/openvdb/math/Proximity.h +++ b/openvdb/openvdb/math/Proximity.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_MATH_PROXIMITY_HAS_BEEN_INCLUDED #define OPENVDB_MATH_PROXIMITY_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/math/QuantizedUnitVec.cc b/openvdb/openvdb/math/QuantizedUnitVec.cc index b3b36b6e91..5606e39339 100644 --- a/openvdb/openvdb/math/QuantizedUnitVec.cc +++ b/openvdb/openvdb/math/QuantizedUnitVec.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "QuantizedUnitVec.h" diff --git a/openvdb/openvdb/math/QuantizedUnitVec.h b/openvdb/openvdb/math/QuantizedUnitVec.h index 9163fab746..6373a36ca7 100644 --- a/openvdb/openvdb/math/QuantizedUnitVec.h +++ b/openvdb/openvdb/math/QuantizedUnitVec.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_MATH_QUANTIZED_UNIT_VEC_HAS_BEEN_INCLUDED #define OPENVDB_MATH_QUANTIZED_UNIT_VEC_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/math/Quat.h b/openvdb/openvdb/math/Quat.h index d9db902aac..d16522f65e 100644 --- a/openvdb/openvdb/math/Quat.h +++ b/openvdb/openvdb/math/Quat.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_MATH_QUAT_H_HAS_BEEN_INCLUDED #define OPENVDB_MATH_QUAT_H_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/math/Ray.h b/openvdb/openvdb/math/Ray.h index 260ec478d3..24daf9bc40 100644 --- a/openvdb/openvdb/math/Ray.h +++ b/openvdb/openvdb/math/Ray.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Ray.h /// diff --git a/openvdb/openvdb/math/Stats.h b/openvdb/openvdb/math/Stats.h index 61ff1a8cc3..16cf61477a 100644 --- a/openvdb/openvdb/math/Stats.h +++ b/openvdb/openvdb/math/Stats.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Stats.h /// diff --git a/openvdb/openvdb/math/Stencils.h b/openvdb/openvdb/math/Stencils.h index 58d96d51d4..0c4ed2c0c8 100644 --- a/openvdb/openvdb/math/Stencils.h +++ b/openvdb/openvdb/math/Stencils.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Ken Museth /// diff --git a/openvdb/openvdb/math/Transform.cc b/openvdb/openvdb/math/Transform.cc index 430f91298f..8da23a9eb5 100644 --- a/openvdb/openvdb/math/Transform.cc +++ b/openvdb/openvdb/math/Transform.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "Transform.h" #include "LegacyFrustum.h" diff --git a/openvdb/openvdb/math/Transform.h b/openvdb/openvdb/math/Transform.h index 3e6486de87..a44c0bfb3c 100644 --- a/openvdb/openvdb/math/Transform.h +++ b/openvdb/openvdb/math/Transform.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_MATH_TRANSFORM_HAS_BEEN_INCLUDED #define OPENVDB_MATH_TRANSFORM_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/math/Tuple.h b/openvdb/openvdb/math/Tuple.h index e737ff6ec8..329bf82059 100644 --- a/openvdb/openvdb/math/Tuple.h +++ b/openvdb/openvdb/math/Tuple.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Tuple.h /// @author Ben Kwa diff --git a/openvdb/openvdb/math/Vec2.h b/openvdb/openvdb/math/Vec2.h index 73caa15243..a4abf85a74 100644 --- a/openvdb/openvdb/math/Vec2.h +++ b/openvdb/openvdb/math/Vec2.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_MATH_VEC2_HAS_BEEN_INCLUDED #define OPENVDB_MATH_VEC2_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/math/Vec3.h b/openvdb/openvdb/math/Vec3.h index 2ea5d32838..76759fbbbc 100644 --- a/openvdb/openvdb/math/Vec3.h +++ b/openvdb/openvdb/math/Vec3.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_MATH_VEC3_HAS_BEEN_INCLUDED #define OPENVDB_MATH_VEC3_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/math/Vec4.h b/openvdb/openvdb/math/Vec4.h index 77ff7707ad..1f35f7777d 100644 --- a/openvdb/openvdb/math/Vec4.h +++ b/openvdb/openvdb/math/Vec4.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_MATH_VEC4_HAS_BEEN_INCLUDED #define OPENVDB_MATH_VEC4_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/openvdb.cc b/openvdb/openvdb/openvdb.cc index c776409dfc..ee58883918 100644 --- a/openvdb/openvdb/openvdb.cc +++ b/openvdb/openvdb/openvdb.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "openvdb.h" #include "io/DelayedLoadMetadata.h" @@ -14,31 +14,32 @@ #include #endif -#if OPENVDB_ABI_VERSION_NUMBER <= 8 - #error ABI <= 8 is no longer supported +#if OPENVDB_ABI_VERSION_NUMBER <= 9 + #error ABI <= 9 is no longer supported #endif // If using an OPENVDB_ABI_VERSION_NUMBER that has been deprecated, issue an // error directive. This can be optionally suppressed by defining: // OPENVDB_USE_DEPRECATED_ABI_=ON. -#ifndef OPENVDB_USE_DEPRECATED_ABI_9 - #if OPENVDB_ABI_VERSION_NUMBER == 9 - #error ABI = 9 is deprecated, CMake option OPENVDB_USE_DEPRECATED_ABI_9 suppresses this error - #endif -#endif #ifndef OPENVDB_USE_DEPRECATED_ABI_10 #if OPENVDB_ABI_VERSION_NUMBER == 10 #error ABI = 10 is deprecated, CMake option OPENVDB_USE_DEPRECATED_ABI_10 suppresses this error #endif #endif +#ifndef OPENVDB_USE_DEPRECATED_ABI_11 + #if OPENVDB_ABI_VERSION_NUMBER == 11 + PRAGMA(message("NOTE: ABI = 11 is deprecated, define OPENVDB_USE_DEPRECATED_ABI_11 " + "to suppress this message")) + #endif +#endif // If using a future OPENVDB_ABI_VERSION_NUMBER, issue an error directive. // This can be optionally suppressed by defining: // OPENVDB_USE_FUTURE_ABI_=ON. -#ifndef OPENVDB_USE_FUTURE_ABI_12 - #if OPENVDB_ABI_VERSION_NUMBER == 12 - #error ABI = 12 is still in active development and has not been finalized, \ -CMake option OPENVDB_USE_FUTURE_ABI_12 suppresses this error +#ifndef OPENVDB_USE_FUTURE_ABI_13 + #if OPENVDB_ABI_VERSION_NUMBER == 13 + #error ABI = 13 is still in active development and has not been finalized, \ +CMake option OPENVDB_USE_FUTURE_ABI_13 suppresses this error #endif #endif diff --git a/openvdb/openvdb/openvdb.h b/openvdb/openvdb/openvdb.h index dbdb88ed41..1e47cae1a9 100644 --- a/openvdb/openvdb/openvdb.h +++ b/openvdb/openvdb/openvdb.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_OPENVDB_HAS_BEEN_INCLUDED #define OPENVDB_OPENVDB_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/points/AttributeArray.cc b/openvdb/openvdb/points/AttributeArray.cc index 6a7d0b9d33..a24fc5a2bd 100644 --- a/openvdb/openvdb/points/AttributeArray.cc +++ b/openvdb/openvdb/points/AttributeArray.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/AttributeArray.cc diff --git a/openvdb/openvdb/points/AttributeArray.h b/openvdb/openvdb/points/AttributeArray.h index 25ebbe8079..f09b58821f 100644 --- a/openvdb/openvdb/points/AttributeArray.h +++ b/openvdb/openvdb/points/AttributeArray.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/AttributeArray.h /// @@ -145,14 +145,6 @@ class OPENVDB_API AttributeArray /// Return a copy of this attribute. virtual AttributeArray::Ptr copy() const = 0; -#if OPENVDB_ABI_VERSION_NUMBER < 10 - /// Return a copy of this attribute. -#ifndef _MSC_VER - OPENVDB_DEPRECATED_MESSAGE("In-memory compression no longer supported, use AttributeArray::copy() instead") -#endif - virtual AttributeArray::Ptr copyUncompressed() const = 0; -#endif - /// Return the number of elements in this array. /// @note This does not count each data element in a strided array virtual Index size() const = 0; @@ -197,13 +189,11 @@ class OPENVDB_API AttributeArray /// Return the number of bytes of memory used by this attribute. virtual size_t memUsage() const = 0; -#if OPENVDB_ABI_VERSION_NUMBER >= 10 /// Return the number of bytes of memory used by this attribute array once it /// has been deserialized (this may be different to memUsage() if delay-loading /// is in use). Note that this method does NOT consider the fact that a /// uniform attribute could be expanded and only deals with delay-loading. virtual size_t memUsageIfLoaded() const = 0; -#endif /// Create a new attribute array of the given (registered) type, length and stride. /// @details If @a lock is non-null, the AttributeArray registry mutex @@ -228,15 +218,6 @@ class OPENVDB_API AttributeArray template bool hasValueType() const { return this->type().first == typeNameAsString(); } -#if OPENVDB_ABI_VERSION_NUMBER < 10 - /// @brief Set value at given index @a n from @a sourceIndex of another @a sourceArray. - // Windows does not allow base classes to be easily deprecated. -#ifndef _MSC_VER - OPENVDB_DEPRECATED_MESSAGE("Use copyValues() with source-target index pairs") -#endif - virtual void set(const Index n, const AttributeArray& sourceArray, const Index sourceIndex) = 0; -#endif - /// @brief Copy values into this array from a source array to a target array /// as referenced by an iterator. /// @details Iterators must adhere to the ForwardIterator interface described @@ -278,19 +259,6 @@ class OPENVDB_API AttributeArray /// Compact the existing array to become uniform if all values are identical virtual bool compact() = 0; -#if OPENVDB_ABI_VERSION_NUMBER < 10 - // Windows does not allow base classes to be deprecated -#ifndef _MSC_VER - OPENVDB_DEPRECATED_MESSAGE("Previously this compressed the attribute array, now it does nothing") -#endif - virtual bool compress() = 0; - // Windows does not allow base classes to be deprecated -#ifndef _MSC_VER - OPENVDB_DEPRECATED_MESSAGE("Previously this uncompressed the attribute array, now it does nothing") -#endif - virtual bool decompress() = 0; -#endif - /// @brief Specify whether this attribute should be hidden (e.g., from UI or iterators). /// @details This is useful if the attribute is used for blind data or as scratch space /// for a calculation. @@ -359,10 +327,8 @@ class OPENVDB_API AttributeArray bool operator==(const AttributeArray& other) const; bool operator!=(const AttributeArray& other) const { return !this->operator==(other); } -#if OPENVDB_ABI_VERSION_NUMBER >= 9 /// Indirect virtual function to retrieve the data buffer cast to a char byte array const char* constDataAsByteArray() const { return this->dataAsByteArray(); } -#endif private: friend class ::TestAttributeArray; @@ -565,11 +531,6 @@ class TypedAttributeArray final: public AttributeArray /// while being copied using this copy-constructor in another thread. /// It is not thread-safe for write. TypedAttributeArray(const TypedAttributeArray&); -#if OPENVDB_ABI_VERSION_NUMBER < 10 - /// Deep copy constructor. - OPENVDB_DEPRECATED_MESSAGE("Use copy-constructor without unused bool parameter") - TypedAttributeArray(const TypedAttributeArray&, bool /*unused*/); -#endif /// Deep copy assignment operator. /// @note this operator is thread-safe. @@ -585,13 +546,6 @@ class TypedAttributeArray final: public AttributeArray /// @note This method is thread-safe. AttributeArray::Ptr copy() const override; -#if OPENVDB_ABI_VERSION_NUMBER < 10 - /// Return a copy of this attribute. - /// @note This method is thread-safe. - OPENVDB_DEPRECATED_MESSAGE("In-memory compression no longer supported, use AttributeArray::copy() instead") - AttributeArray::Ptr copyUncompressed() const override; -#endif - /// Return a new attribute array of the given length @a n and @a stride with uniform value zero. static Ptr create(Index n, Index strideOrTotalSize = 1, bool constantStride = true, const Metadata* metadata = nullptr); @@ -657,13 +611,11 @@ class TypedAttributeArray final: public AttributeArray /// Return the number of bytes of memory used by this attribute. size_t memUsage() const override; -#if OPENVDB_ABI_VERSION_NUMBER >= 10 /// Return the number of bytes of memory used by this attribute array once it /// has been deserialized (this may be different to memUsage() if delay-loading /// is in use). Note that this method does NOT consider the fact that a /// uniform attribute could be expanded and only deals with delay-loading. size_t memUsageIfLoaded() const override; -#endif /// Return the value at index @a n (assumes in-core) ValueType getUnsafe(Index n) const; @@ -691,12 +643,6 @@ class TypedAttributeArray final: public AttributeArray /// (assumes in-core) static void setUnsafe(AttributeArray* array, const Index n, const ValueType& value); -#if OPENVDB_ABI_VERSION_NUMBER < 10 - /// Set value at given index @a n from @a sourceIndex of another @a sourceArray - OPENVDB_DEPRECATED_MESSAGE("Use copyValues() with source-target index pairs") - void set(const Index n, const AttributeArray& sourceArray, const Index sourceIndex) override; -#endif - /// Return @c true if this array is stored as a single uniform value. bool isUniform() const override { return mIsUniform; } /// @brief Replace the single value storage with an array of length size(). @@ -719,15 +665,6 @@ class TypedAttributeArray final: public AttributeArray /// Non-member equivalent to fill() that static_casts array to this TypedAttributeArray static void fill(AttributeArray* array, const ValueType& value); -#if OPENVDB_ABI_VERSION_NUMBER < 10 - /// Compress the attribute array. - OPENVDB_DEPRECATED_MESSAGE("Previously this compressed the attribute array, now it does nothing") - bool compress() override; - /// Uncompress the attribute array. - OPENVDB_DEPRECATED_MESSAGE("Previously this uncompressed the attribute array, now it does nothing") - bool decompress() override; -#endif - /// Read attribute data from a stream. void read(std::istream&) override; /// Write attribute data to a stream. @@ -789,14 +726,7 @@ class TypedAttributeArray final: public AttributeArray /// Load data from memory-mapped file. inline void doLoad() const; /// Load data from memory-mapped file (unsafe as this function is not protected by a mutex). -#if OPENVDB_ABI_VERSION_NUMBER >= 10 inline void doLoadUnsafe() const; -#else - /// @param compression parameter no longer used - inline void doLoadUnsafe(const bool compression = true) const; - /// Compress in-core data assuming mutex is locked - inline bool compressUnsafe(); -#endif /// Toggle out-of-core state inline void setOutOfCore(const bool); @@ -1275,15 +1205,6 @@ TypedAttributeArray::copy() const } -#if OPENVDB_ABI_VERSION_NUMBER < 10 -template -AttributeArray::Ptr -TypedAttributeArray::copyUncompressed() const -{ - return this->copy(); -} -#endif - template size_t TypedAttributeArray::arrayMemUsage() const @@ -1385,14 +1306,13 @@ TypedAttributeArray::memUsage() const return sizeof(*this) + (bool(mData) ? this->arrayMemUsage() : 0); } -#if OPENVDB_ABI_VERSION_NUMBER >= 10 + template size_t TypedAttributeArray::memUsageIfLoaded() const { return sizeof(*this) + (mIsUniform ? 1 : this->dataSize()) * sizeof(StorageType); } -#endif template @@ -1497,21 +1417,6 @@ TypedAttributeArray::setUnsafe(AttributeArray* array, const } -#if OPENVDB_ABI_VERSION_NUMBER < 10 -template -void -TypedAttributeArray::set(Index n, const AttributeArray& sourceArray, const Index sourceIndex) -{ - const TypedAttributeArray& sourceTypedArray = static_cast(sourceArray); - - ValueType sourceValue; - sourceTypedArray.get(sourceIndex, sourceValue); - - this->set(n, sourceValue); -} -#endif - - template void TypedAttributeArray::expand(bool fill) @@ -1605,32 +1510,6 @@ TypedAttributeArray::fill(AttributeArray* array, const Value } -#if OPENVDB_ABI_VERSION_NUMBER < 10 -template -inline bool -TypedAttributeArray::compress() -{ - return false; -} - - -template -inline bool -TypedAttributeArray::compressUnsafe() -{ - return false; -} - - -template -inline bool -TypedAttributeArray::decompress() -{ - return false; -} -#endif - - template bool TypedAttributeArray::isOutOfCore() const @@ -1976,11 +1855,7 @@ TypedAttributeArray::writePagedBuffers(compression::PagedOut template void -#if OPENVDB_ABI_VERSION_NUMBER >= 10 TypedAttributeArray::doLoadUnsafe() const -#else -TypedAttributeArray::doLoadUnsafe(const bool /*compression*/) const -#endif { if (!(this->isOutOfCore())) return; diff --git a/openvdb/openvdb/points/AttributeArrayString.cc b/openvdb/openvdb/points/AttributeArrayString.cc index 7a5025a4e1..b04d1ebb78 100644 --- a/openvdb/openvdb/points/AttributeArrayString.cc +++ b/openvdb/openvdb/points/AttributeArrayString.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/AttributeArrayString.cc diff --git a/openvdb/openvdb/points/AttributeArrayString.h b/openvdb/openvdb/points/AttributeArrayString.h index 2ab2391b9a..6c2b8089c3 100644 --- a/openvdb/openvdb/points/AttributeArrayString.h +++ b/openvdb/openvdb/points/AttributeArrayString.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/AttributeArrayString.h /// diff --git a/openvdb/openvdb/points/AttributeGroup.cc b/openvdb/openvdb/points/AttributeGroup.cc index c9dff68aab..4f022bae7d 100644 --- a/openvdb/openvdb/points/AttributeGroup.cc +++ b/openvdb/openvdb/points/AttributeGroup.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/AttributeGroup.cc diff --git a/openvdb/openvdb/points/AttributeGroup.h b/openvdb/openvdb/points/AttributeGroup.h index 449128a592..7fc007099c 100644 --- a/openvdb/openvdb/points/AttributeGroup.h +++ b/openvdb/openvdb/points/AttributeGroup.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/AttributeGroup.h /// diff --git a/openvdb/openvdb/points/AttributeSet.cc b/openvdb/openvdb/points/AttributeSet.cc index a1d58d2162..1eebe436ff 100644 --- a/openvdb/openvdb/points/AttributeSet.cc +++ b/openvdb/openvdb/points/AttributeSet.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/AttributeSet.cc @@ -140,7 +140,6 @@ AttributeSet::memUsage() const } -#if OPENVDB_ABI_VERSION_NUMBER >= 10 size_t AttributeSet::memUsageIfLoaded() const { @@ -150,7 +149,6 @@ AttributeSet::memUsageIfLoaded() const } return bytes; } -#endif size_t diff --git a/openvdb/openvdb/points/AttributeSet.h b/openvdb/openvdb/points/AttributeSet.h index 1398f58728..3137eb7413 100644 --- a/openvdb/openvdb/points/AttributeSet.h +++ b/openvdb/openvdb/points/AttributeSet.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/AttributeSet.h /// @@ -114,12 +114,10 @@ class OPENVDB_API AttributeSet /// Return the number of bytes of memory used by this attribute set. size_t memUsage() const; -#if OPENVDB_ABI_VERSION_NUMBER >= 10 /// Return the number of bytes of memory used by this attribute set once it /// has been deserialized (this may be different to memUsage() if delay-loading /// is in use). size_t memUsageIfLoaded() const; -#endif /// @brief Return the position of the attribute array whose name is @a name, /// or @c INVALID_POS if no match is found. diff --git a/openvdb/openvdb/points/IndexFilter.h b/openvdb/openvdb/points/IndexFilter.h index a9bbf2954f..9f0e57d708 100644 --- a/openvdb/openvdb/points/IndexFilter.h +++ b/openvdb/openvdb/points/IndexFilter.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/IndexFilter.h /// @@ -245,7 +245,7 @@ class RandomLeafFilter std::mt19937 generator(seed); std::uniform_int_distribution dist(0, std::numeric_limits::max() - 1); - Index32 leafCounter = 0; + Index64 leafCounter = 0; float totalPointsFloat = 0.0f; int totalPoints = 0; for (auto iter = tree.cbeginLeaf(); iter; ++iter) { diff --git a/openvdb/openvdb/points/IndexIterator.h b/openvdb/openvdb/points/IndexIterator.h index 9a8e300d57..affddef9eb 100644 --- a/openvdb/openvdb/points/IndexIterator.h +++ b/openvdb/openvdb/points/IndexIterator.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/IndexIterator.h /// diff --git a/openvdb/openvdb/points/PointAdvect.h b/openvdb/openvdb/points/PointAdvect.h index 884a68eba7..e8c1ee266c 100644 --- a/openvdb/openvdb/points/PointAdvect.h +++ b/openvdb/openvdb/points/PointAdvect.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Dan Bailey /// diff --git a/openvdb/openvdb/points/PointAttribute.h b/openvdb/openvdb/points/PointAttribute.h index ae989703a9..0710ed3c47 100644 --- a/openvdb/openvdb/points/PointAttribute.h +++ b/openvdb/openvdb/points/PointAttribute.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Dan Bailey, Khang Ngo /// diff --git a/openvdb/openvdb/points/PointConversion.h b/openvdb/openvdb/points/PointConversion.h index bc2dce3d97..dbdfd97b6d 100644 --- a/openvdb/openvdb/points/PointConversion.h +++ b/openvdb/openvdb/points/PointConversion.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Dan Bailey, Nick Avramoussis /// diff --git a/openvdb/openvdb/points/PointCount.h b/openvdb/openvdb/points/PointCount.h index 3a77b7e110..d3fef689db 100644 --- a/openvdb/openvdb/points/PointCount.h +++ b/openvdb/openvdb/points/PointCount.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/PointCount.h /// diff --git a/openvdb/openvdb/points/PointDataGrid.h b/openvdb/openvdb/points/PointDataGrid.h index 5e1a7ac21b..9852796753 100644 --- a/openvdb/openvdb/points/PointDataGrid.h +++ b/openvdb/openvdb/points/PointDataGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Dan Bailey /// @@ -504,9 +504,7 @@ class PointDataLeafNode : public tree::LeafNode, io::MultiPass { Index64 memUsage() const; -#if OPENVDB_ABI_VERSION_NUMBER >= 10 Index64 memUsageIfLoaded() const; -#endif void evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels = true) const; @@ -1524,14 +1522,12 @@ PointDataLeafNode::memUsage() const return BaseLeaf::memUsage() + mAttributeSet->memUsage(); } -#if OPENVDB_ABI_VERSION_NUMBER >= 10 template inline Index64 PointDataLeafNode::memUsageIfLoaded() const { return BaseLeaf::memUsageIfLoaded() + mAttributeSet->memUsageIfLoaded(); } -#endif template inline void diff --git a/openvdb/openvdb/points/PointDelete.h b/openvdb/openvdb/points/PointDelete.h index 8c9ee5a36c..de7dcb14f3 100644 --- a/openvdb/openvdb/points/PointDelete.h +++ b/openvdb/openvdb/points/PointDelete.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Nick Avramoussis, Francisco Gochez, Dan Bailey /// diff --git a/openvdb/openvdb/points/PointGroup.h b/openvdb/openvdb/points/PointGroup.h index 9ad58b82d6..8b78090d0a 100644 --- a/openvdb/openvdb/points/PointGroup.h +++ b/openvdb/openvdb/points/PointGroup.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Dan Bailey /// diff --git a/openvdb/openvdb/points/PointMask.h b/openvdb/openvdb/points/PointMask.h index cbd3dc6a89..3630416f7e 100644 --- a/openvdb/openvdb/points/PointMask.h +++ b/openvdb/openvdb/points/PointMask.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/PointMask.h /// diff --git a/openvdb/openvdb/points/PointMove.h b/openvdb/openvdb/points/PointMove.h index 721dd13501..4dc2f35b59 100644 --- a/openvdb/openvdb/points/PointMove.h +++ b/openvdb/openvdb/points/PointMove.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Dan Bailey /// diff --git a/openvdb/openvdb/points/PointRasterizeFrustum.h b/openvdb/openvdb/points/PointRasterizeFrustum.h index fea31761f6..30c3927c28 100644 --- a/openvdb/openvdb/points/PointRasterizeFrustum.h +++ b/openvdb/openvdb/points/PointRasterizeFrustum.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Dan Bailey, Rick Hankins /// diff --git a/openvdb/openvdb/points/PointRasterizeSDF.h b/openvdb/openvdb/points/PointRasterizeSDF.h index c7b60b598a..c78ef0d2ed 100644 --- a/openvdb/openvdb/points/PointRasterizeSDF.h +++ b/openvdb/openvdb/points/PointRasterizeSDF.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Nick Avramoussis /// diff --git a/openvdb/openvdb/points/PointRasterizeTrilinear.h b/openvdb/openvdb/points/PointRasterizeTrilinear.h index 2f347bfdba..8932e2149b 100644 --- a/openvdb/openvdb/points/PointRasterizeTrilinear.h +++ b/openvdb/openvdb/points/PointRasterizeTrilinear.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Nick Avramoussis /// diff --git a/openvdb/openvdb/points/PointReplicate.h b/openvdb/openvdb/points/PointReplicate.h index d14520e0b3..e345e759a1 100644 --- a/openvdb/openvdb/points/PointReplicate.h +++ b/openvdb/openvdb/points/PointReplicate.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Nick Avramoussis /// diff --git a/openvdb/openvdb/points/PointSample.h b/openvdb/openvdb/points/PointSample.h index c2c883e692..e98efeaafa 100644 --- a/openvdb/openvdb/points/PointSample.h +++ b/openvdb/openvdb/points/PointSample.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Nick Avramoussis, Francisco Gochez, Dan Bailey /// diff --git a/openvdb/openvdb/points/PointScatter.h b/openvdb/openvdb/points/PointScatter.h index cf1c547ae8..d784bd70f2 100644 --- a/openvdb/openvdb/points/PointScatter.h +++ b/openvdb/openvdb/points/PointScatter.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Nick Avramoussis /// diff --git a/openvdb/openvdb/points/PointStatistics.h b/openvdb/openvdb/points/PointStatistics.h index 9fcd43696a..0ad180bb71 100644 --- a/openvdb/openvdb/points/PointStatistics.h +++ b/openvdb/openvdb/points/PointStatistics.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Nick Avramoussis /// diff --git a/openvdb/openvdb/points/PointTransfer.h b/openvdb/openvdb/points/PointTransfer.h index 8f9bfc3806..1a7f42fc59 100644 --- a/openvdb/openvdb/points/PointTransfer.h +++ b/openvdb/openvdb/points/PointTransfer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Nick Avramoussis /// diff --git a/openvdb/openvdb/points/StreamCompression.cc b/openvdb/openvdb/points/StreamCompression.cc index ad4f8990d6..3f24b1b0e6 100644 --- a/openvdb/openvdb/points/StreamCompression.cc +++ b/openvdb/openvdb/points/StreamCompression.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/StreamCompression.cc diff --git a/openvdb/openvdb/points/StreamCompression.h b/openvdb/openvdb/points/StreamCompression.h index d9f77bd1c6..c7dcd4a8e9 100644 --- a/openvdb/openvdb/points/StreamCompression.h +++ b/openvdb/openvdb/points/StreamCompression.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/StreamCompression.h /// diff --git a/openvdb/openvdb/points/impl/PointAttributeImpl.h b/openvdb/openvdb/points/impl/PointAttributeImpl.h index fb8d595da4..7b92229117 100644 --- a/openvdb/openvdb/points/impl/PointAttributeImpl.h +++ b/openvdb/openvdb/points/impl/PointAttributeImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Dan Bailey, Khang Ngo /// diff --git a/openvdb/openvdb/points/impl/PointConversionImpl.h b/openvdb/openvdb/points/impl/PointConversionImpl.h index 0ac4e7aee7..22fc09a5a0 100644 --- a/openvdb/openvdb/points/impl/PointConversionImpl.h +++ b/openvdb/openvdb/points/impl/PointConversionImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Dan Bailey, Nick Avramoussis /// diff --git a/openvdb/openvdb/points/impl/PointCountImpl.h b/openvdb/openvdb/points/impl/PointCountImpl.h index e90c25812e..29c998b9c8 100644 --- a/openvdb/openvdb/points/impl/PointCountImpl.h +++ b/openvdb/openvdb/points/impl/PointCountImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Dan Bailey /// diff --git a/openvdb/openvdb/points/impl/PointDeleteImpl.h b/openvdb/openvdb/points/impl/PointDeleteImpl.h index 5b082a7f31..3da917fb96 100644 --- a/openvdb/openvdb/points/impl/PointDeleteImpl.h +++ b/openvdb/openvdb/points/impl/PointDeleteImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Nick Avramoussis, Francisco Gochez, Dan Bailey /// diff --git a/openvdb/openvdb/points/impl/PointGroupImpl.h b/openvdb/openvdb/points/impl/PointGroupImpl.h index 1fb1c32472..c8a58e1eae 100644 --- a/openvdb/openvdb/points/impl/PointGroupImpl.h +++ b/openvdb/openvdb/points/impl/PointGroupImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Dan Bailey /// diff --git a/openvdb/openvdb/points/impl/PointMaskImpl.h b/openvdb/openvdb/points/impl/PointMaskImpl.h index 474cdb815c..9c05c623b7 100644 --- a/openvdb/openvdb/points/impl/PointMaskImpl.h +++ b/openvdb/openvdb/points/impl/PointMaskImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file PointMaskImpl.h /// diff --git a/openvdb/openvdb/points/impl/PointMoveImpl.h b/openvdb/openvdb/points/impl/PointMoveImpl.h index 4b76d8f7cf..2b88120e58 100644 --- a/openvdb/openvdb/points/impl/PointMoveImpl.h +++ b/openvdb/openvdb/points/impl/PointMoveImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Dan Bailey /// diff --git a/openvdb/openvdb/points/impl/PointRasterizeFrustumImpl.h b/openvdb/openvdb/points/impl/PointRasterizeFrustumImpl.h index 9fecd22f69..3578b44e83 100644 --- a/openvdb/openvdb/points/impl/PointRasterizeFrustumImpl.h +++ b/openvdb/openvdb/points/impl/PointRasterizeFrustumImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Dan Bailey /// diff --git a/openvdb/openvdb/points/impl/PointRasterizeSDFImpl.h b/openvdb/openvdb/points/impl/PointRasterizeSDFImpl.h index 37bfef7ff0..1040e35e9d 100644 --- a/openvdb/openvdb/points/impl/PointRasterizeSDFImpl.h +++ b/openvdb/openvdb/points/impl/PointRasterizeSDFImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Nick Avramoussis /// diff --git a/openvdb/openvdb/points/impl/PointRasterizeTrilinearImpl.h b/openvdb/openvdb/points/impl/PointRasterizeTrilinearImpl.h index 20a83269f9..10482d79fe 100644 --- a/openvdb/openvdb/points/impl/PointRasterizeTrilinearImpl.h +++ b/openvdb/openvdb/points/impl/PointRasterizeTrilinearImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Nick Avramoussis /// diff --git a/openvdb/openvdb/points/impl/PointReplicateImpl.h b/openvdb/openvdb/points/impl/PointReplicateImpl.h index 5990d98544..190759e34c 100644 --- a/openvdb/openvdb/points/impl/PointReplicateImpl.h +++ b/openvdb/openvdb/points/impl/PointReplicateImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Nick Avramoussis /// diff --git a/openvdb/openvdb/points/impl/PointSampleImpl.h b/openvdb/openvdb/points/impl/PointSampleImpl.h index 851e448248..30dbdc476b 100644 --- a/openvdb/openvdb/points/impl/PointSampleImpl.h +++ b/openvdb/openvdb/points/impl/PointSampleImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Nick Avramoussis, Francisco Gochez, Dan Bailey /// diff --git a/openvdb/openvdb/points/impl/PointScatterImpl.h b/openvdb/openvdb/points/impl/PointScatterImpl.h index 842dc6a40b..e17ef097c3 100644 --- a/openvdb/openvdb/points/impl/PointScatterImpl.h +++ b/openvdb/openvdb/points/impl/PointScatterImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Nick Avramoussis /// diff --git a/openvdb/openvdb/points/impl/PointStatisticsImpl.h b/openvdb/openvdb/points/impl/PointStatisticsImpl.h index 6dd9422164..4427ee93c6 100644 --- a/openvdb/openvdb/points/impl/PointStatisticsImpl.h +++ b/openvdb/openvdb/points/impl/PointStatisticsImpl.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Nick Avramoussis /// diff --git a/openvdb/openvdb/points/points.cc b/openvdb/openvdb/points/points.cc index b5a64f7330..a9188dd5b1 100644 --- a/openvdb/openvdb/points/points.cc +++ b/openvdb/openvdb/points/points.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file points/points.cc diff --git a/openvdb/openvdb/python/CMakeLists.txt b/openvdb/openvdb/python/CMakeLists.txt index d3c983a830..c67884bce3 100644 --- a/openvdb/openvdb/python/CMakeLists.txt +++ b/openvdb/openvdb/python/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(OpenVDBPython LANGUAGES CXX) include(GNUInstallDirs) @@ -49,85 +49,9 @@ if(USE_AX) endif() endif() -# Small function which mimics basic output (bar components) of -# FindPackageHandleStandardArgs. This is required as we want to ensure -# the minimum python version is MINIMUM_PYTHON_VERSION - however this cannot -# be provided to find_package(Python) with differing major versions. e.g. -# calls to find_package(Python 2.7) fails if python3 is found on the system. -function(OPENVDB_CHECK_PYTHON_VERSION) - set(PY_TARGET ${ARGV0}) - set(PY_TARGET_VERSION ${ARGV1}) - set(PY_TARGET_INCLUDES ${ARGV2}) - set(MIN_VERSION ${ARGV3}) - set(FUTURE_MIN_VERSION ${ARGV4}) - - if(NOT TARGET ${PY_TARGET}) - message(FATAL_ERROR "Could NOT find ${PY_TARGET} (Required is at least version " - "\"${MIN_VERSION}\")" - ) - endif() - - if(PY_TARGET_VERSION AND MIN_VERSION) - if(PY_TARGET_VERSION VERSION_LESS MIN_VERSION) - message(FATAL_ERROR "Could NOT find ${PY_TARGET}: Found unsuitable version " - "\"${PY_TARGET_VERSION}\" but required is at least \"${MIN_VERSION}\" (found ${PY_TARGET_INCLUDES})" - ) - endif() - endif() - - message(STATUS "Found ${PY_TARGET}: ${PY_TARGET_INCLUDES}) (found suitable " - "version \"${PY_TARGET_VERSION}\", minimum required is \"${MIN_VERSION}\")" - ) - - if(OPENVDB_FUTURE_DEPRECATION AND PY_TARGET_VERSION AND FUTURE_MIN_VERSION) - if(PY_TARGET_VERSION VERSION_LESS FUTURE_MIN_VERSION) - message(DEPRECATION "Support for ${PY_TARGET} versions < ${FUTURE_MIN_VERSION} " - "is deprecated and will be removed.") - endif() - endif() -endfunction() - -# Configure Python and Numpy. -# To ensure consistent versions between components Interpreter, Compiler, -# Development and NumPy, specify all components at the same time when using -# FindPython. -set(OPENVDB_PYTHON_DEPS) - -# @note explicitly only search for Development.Module from 3.18 as searching -# Development.Embed can cause issues on linux systems where it doesn't exist -set(OPENVDB_PYTHON_REQUIRED_COMPONENTS Development.Module Interpreter) - -if(NOT DEFINED PYOPENVDB_INSTALL_DIRECTORY) - list(APPEND OPENVDB_PYTHON_REQUIRED_COMPONENTS Interpreter) -endif() - -if(USE_NUMPY) - list(APPEND OPENVDB_PYTHON_REQUIRED_COMPONENTS NumPy) -endif() - -# Make sure find_package(Python) is only ever invoked once with all required components -find_package(Python COMPONENTS ${OPENVDB_PYTHON_REQUIRED_COMPONENTS}) -find_package(pybind11 ${MINIMUM_PYBIND_VERSION} CONFIG REQUIRED) - -openvdb_check_python_version(Python::Module - "${Python_VERSION}" - "${Python_INCLUDE_DIRS}" - "${MINIMUM_PYTHON_VERSION}" - "${FUTURE_MINIMUM_PYTHON_VERSION}") -list(APPEND OPENVDB_PYTHON_DEPS Python::Module) - -if(USE_NUMPY) - openvdb_check_python_version(Python::NumPy - "${Python_NumPy_VERSION}" - "${Python_NumPy_INCLUDE_DIRS}" - "${MINIMUM_NUMPY_VERSION}" - "${FUTURE_MINIMUM_NUMPY_VERSION}") - list(APPEND OPENVDB_PYTHON_DEPS Python::NumPy) -endif() - ########################################################################## -set(OPENVDB_PYTHON_MODULE_SOURCE_FILES +nanobind_add_module(openvdb_python NB_STATIC pyFloatGrid.cc pyGridBase.cc pyIntGrid.cc @@ -138,63 +62,51 @@ set(OPENVDB_PYTHON_MODULE_SOURCE_FILES pyVec3Grid.cc ) -if(NOT DEFINED PYOPENVDB_INSTALL_DIRECTORY) - get_filename_component(Python_PACKAGES_DIR ${Python_SITELIB} NAME) - set(PYOPENVDB_INSTALL_DIRECTORY - ${CMAKE_INSTALL_LIBDIR}/python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/${Python_PACKAGES_DIR} - CACHE STRING "The directory to install the pyopenvdb.so module." - ) -endif() - -pybind11_add_module(pyopenvdb ${OPENVDB_PYTHON_MODULE_SOURCE_FILES}) - -target_link_libraries(pyopenvdb PUBLIC - ${OPENVDB_LIB} - ${OPENVDB_PYTHON_DEPS} -) - +target_link_libraries(openvdb_python PUBLIC ${OPENVDB_LIB}) if(OPENVDB_PYTHON_WRAP_ALL_GRID_TYPES) - target_compile_definitions(pyopenvdb PRIVATE "-DPY_OPENVDB_WRAP_ALL_GRID_TYPES") + target_compile_definitions(openvdb_python PRIVATE "-DPY_OPENVDB_WRAP_ALL_GRID_TYPES") endif() if(USE_NUMPY) - target_compile_definitions(pyopenvdb PUBLIC "-DPY_OPENVDB_USE_NUMPY") + target_compile_definitions(openvdb_python PUBLIC "-DPY_OPENVDB_USE_NUMPY") endif() if(USE_AX) - target_link_libraries(pyopenvdb PUBLIC ${OPENVDB_AX_LIB}) - target_compile_definitions(pyopenvdb PUBLIC "-DPY_OPENVDB_USE_AX") + target_link_libraries(openvdb_python PUBLIC ${OPENVDB_AX_LIB}) + target_compile_definitions(openvdb_python PUBLIC "-DPY_OPENVDB_USE_AX") +endif() +set_target_properties(openvdb_python PROPERTIES OUTPUT_NAME "openvdb") +if(SKBUILD) + set_target_properties(openvdb_python PROPERTIES INSTALL_RPATH "$ORIGIN") + install(TARGETS openvdb_python DESTINATION ${OPENVDB_INSTALL_LIBDIR}) + install(FILES __init__.py DESTINATION openvdb) +else() + install(TARGETS openvdb_python DESTINATION ${VDB_PYTHON_INSTALL_DIRECTORY}) endif() - -install(TARGETS - pyopenvdb - DESTINATION - ${PYOPENVDB_INSTALL_DIRECTORY} -) # pytest if(OPENVDB_BUILD_PYTHON_UNITTESTS) - set(PYVDB_WORKING_DIR "${CMAKE_CURRENT_BINARY_DIR}") + set(OPENVDB_PYTHON_WORKING_DIR "${CMAKE_CURRENT_BINARY_DIR}") if(WIN32) - set(PYVDB_WORKING_DIR "${PYVDB_WORKING_DIR}/$") + set(OPENVDB_PYTHON_WORKING_DIR "${OPENVDB_PYTHON_WORKING_DIR}/$") endif() - add_test(NAME pytest + add_test(NAME pytest_openvdb COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/TestOpenVDB.py -v - WORKING_DIRECTORY "${PYVDB_WORKING_DIR}") + WORKING_DIRECTORY "${OPENVDB_PYTHON_WORKING_DIR}") - set(PYOPENVDB_TEST_ENV "") + set(OPENVDB_PYTHON_TEST_ENV "") if(USE_AX) - list(APPEND PYOPENVDB_TEST_ENV "OPENVDB_TEST_PYTHON_AX=1") + list(APPEND OPENVDB_PYTHON_TEST_ENV "OPENVDB_TEST_PYTHON_AX=1") endif() if(WIN32) - set(PYTHONPATH "$ENV{PYTHONPATH};${PYVDB_WORKING_DIR}") + set(PYTHONPATH "$ENV{PYTHONPATH};${OPENVDB_PYTHON_WORKING_DIR}") string(REPLACE "\\;" ";" PYTHONPATH "${PYTHONPATH}") string(REPLACE ";" "\\;" PYTHONPATH "${PYTHONPATH}") - set_tests_properties(pytest PROPERTIES - ENVIRONMENT "PYTHONPATH=${PYTHONPATH};${PYOPENVDB_TEST_ENV}") + set_tests_properties(pytest_openvdb PROPERTIES + ENVIRONMENT "PYTHONPATH=${PYTHONPATH};${OPENVDB_PYTHON_TEST_ENV}") else() - set_tests_properties(pytest PROPERTIES - ENVIRONMENT "PYTHONPATH=$ENV{PYTHONPATH}:${PYVDB_WORKING_DIR};${PYOPENVDB_TEST_ENV}") + set_tests_properties(pytest_openvdb PROPERTIES + ENVIRONMENT "PYTHONPATH=$ENV{PYTHONPATH}:${OPENVDB_PYTHON_WORKING_DIR};${OPENVDB_PYTHON_TEST_ENV}") endif() endif() diff --git a/openvdb/openvdb/python/__init__.py b/openvdb/openvdb/python/__init__.py new file mode 100644 index 0000000000..1b25ddfcc5 --- /dev/null +++ b/openvdb/openvdb/python/__init__.py @@ -0,0 +1 @@ +from .lib.openvdb import * diff --git a/openvdb/openvdb/python/pyAccessor.h b/openvdb/openvdb/python/pyAccessor.h index f41283a476..551e7a464e 100644 --- a/openvdb/openvdb/python/pyAccessor.h +++ b/openvdb/openvdb/python/pyAccessor.h @@ -1,17 +1,17 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_PYACCESSOR_HAS_BEEN_INCLUDED #define OPENVDB_PYACCESSOR_HAS_BEEN_INCLUDED -#include -#include +#include +#include #include #include "pyutil.h" namespace pyAccessor { -namespace py = pybind11; +namespace nb = nanobind; using namespace openvdb::OPENVDB_VERSION_NAME; @@ -69,7 +69,7 @@ struct AccessorTraits static void notWritable() { - throw py::type_error("accessor is read-only"); + throw nb::type_error("accessor is read-only"); } }; //@} @@ -173,86 +173,71 @@ class AccessorWrap } /// @brief Define a Python wrapper class for this C++ class. - static void wrap(py::module_ m) + static void wrap(nb::module_ m) { const std::string pyGridTypeName = pyutil::GridTraits::name(), - pyValueTypeName = openvdb::typeNameAsString(), pyAccessorTypeName = Traits::typeName(); - py::class_(m, - (pyGridTypeName + pyAccessorTypeName).c_str(), //pybind11 requires a unique class name for each template instantiation + nb::class_(m, + (pyGridTypeName + pyAccessorTypeName).c_str(), //nanobind requires a unique class name for each template instantiation (std::string(Traits::IsConst ? "Read-only" : "Read/write") + " access by (i, j, k) index coordinates to the voxels\nof a " + pyGridTypeName).c_str()) .def("copy", &AccessorWrap::copy, - ("copy() -> " + pyAccessorTypeName + "\n\n" - "Return a copy of this accessor.").c_str()) + "Return a copy of this accessor.") .def("clear", &AccessorWrap::clear, - "clear()\n\n" "Clear this accessor of all cached data.") - .def_property_readonly("parent", &AccessorWrap::parent, + .def_prop_ro("parent", &AccessorWrap::parent, ("this accessor's parent " + pyGridTypeName).c_str()) // // Voxel access // .def("getValue", &AccessorWrap::getValue, - py::arg("ijk"), - ("getValue(ijk) -> " + pyValueTypeName + "\n\n" - "Return the value of the voxel at coordinates (i, j, k).").c_str()) + nb::arg("ijk"), + "Return the value of the voxel at coordinates (i, j, k).") .def("getValueDepth", &AccessorWrap::getValueDepth, - py::arg("ijk"), - "getValueDepth(ijk) -> int\n\n" + nb::arg("ijk"), "Return the tree depth (0 = root) at which the value of voxel\n" "(i, j, k) resides. If (i, j, k) isn't explicitly represented in\n" "the tree (i.e., it is implicitly a background voxel), return -1.") .def("isVoxel", &AccessorWrap::isVoxel, - py::arg("ijk"), - "isVoxel(ijk) -> bool\n\n" + nb::arg("ijk"), "Return True if voxel (i, j, k) resides at the leaf level of the tree.") .def("probeValue", &AccessorWrap::probeValue, - py::arg("ijk"), - "probeValue(ijk) -> value, bool\n\n" + nb::arg("ijk"), "Return the value of the voxel at coordinates (i, j, k)\n" "together with the voxel's active state.") .def("isValueOn", &AccessorWrap::isValueOn, - py::arg("ijk"), - "isValueOn(ijk) -> bool\n\n" + nb::arg("ijk"), "Return the active state of the voxel at coordinates (i, j, k).") .def("setActiveState", &AccessorWrap::setActiveState, - py::arg("ijk"), py::arg("on"), - "setActiveState(ijk, on)\n\n" + nb::arg("ijk"), nb::arg("on"), "Mark voxel (i, j, k) as either active or inactive (True or False),\n" "but don't change its value.") .def("setValueOnly", &AccessorWrap::setValueOnly, - py::arg("ijk"), py::arg("value"), - "setValueOnly(ijk, value)\n\n" + nb::arg("ijk"), nb::arg("value"), "Set the value of voxel (i, j, k), but don't change its active state.") .def("setValueOn", &AccessorWrap::setValueOn, - py::arg("ijk"), py::arg("value") = py::none(), - "setValueOn(ijk, value)\n\n" - "Mark voxel (i, j, k) as active and set the voxel's value if specified.\n") + nb::arg("ijk"), nb::arg("value") = nb::none(), + "Mark voxel (i, j, k) as active and set the voxel's value if specified.") .def("setValueOff", &AccessorWrap::setValueOff, - py::arg("ijk"), py::arg("value") = py::none(), - "setValueOff(ijk, value)\n\n" + nb::arg("ijk"), nb::arg("value") = nb::none(), "Mark voxel (i, j, k) as inactive and set the voxel's value if specified.") .def("isCached", &AccessorWrap::isCached, - py::arg("ijk"), - "isCached(ijk) -> bool\n\n" - "Return True if this accessor has cached the path to voxel (i, j, k).") - - ; // py::class_ + nb::arg("ijk"), + "Return True if this accessor has cached the path to voxel (i, j, k)."); } private: diff --git a/openvdb/openvdb/python/pyFloatGrid.cc b/openvdb/openvdb/python/pyFloatGrid.cc index 39e57b09d1..6d20e60978 100644 --- a/openvdb/openvdb/python/pyFloatGrid.cc +++ b/openvdb/openvdb/python/pyFloatGrid.cc @@ -1,26 +1,25 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file pyFloatGrid.cc /// @author Peter Cucka -/// @brief pybind11 wrappers for scalar, floating-point openvdb::Grid types +/// @brief nanobind wrappers for scalar, floating-point openvdb::Grid types #include "pyGrid.h" /// Create a Python wrapper for each supported Grid type. void -exportFloatGrid(py::module_ m) +exportFloatGrid(nb::module_ m) { - pyGrid::exportGrid(m); + pyGrid::exportScalarGrid(m); #ifdef PY_OPENVDB_WRAP_ALL_GRID_TYPES - pyGrid::exportGrid(m); + pyGrid::exportScalarGrid(m); #endif m.def("createLevelSetSphere", &pyGrid::createLevelSetSphere, - py::arg("radius"), py::arg("center")=openvdb::Coord(), py::arg("voxelSize")=1.0, - py::arg("halfWidth")=openvdb::LEVEL_SET_HALF_WIDTH, - "createLevelSetSphere(radius, center, voxelSize, halfWidth) -> FloatGrid\n\n" + nb::arg("radius"), nb::arg("center")=openvdb::Coord(), nb::arg("voxelSize")=1.0, + nb::arg("halfWidth")=openvdb::LEVEL_SET_HALF_WIDTH, "Return a grid containing a narrow-band level set representation\n" "of a sphere."); } diff --git a/openvdb/openvdb/python/pyGrid.h b/openvdb/openvdb/python/pyGrid.h index 539bf42991..a8948064a6 100644 --- a/openvdb/openvdb/python/pyGrid.h +++ b/openvdb/openvdb/python/pyGrid.h @@ -1,18 +1,23 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file pyGrid.h /// @author Peter Cucka -/// @brief pybind11 wrapper for openvdb::Grid +/// @brief nanobind wrapper for openvdb::Grid #ifndef OPENVDB_PYGRID_HAS_BEEN_INCLUDED #define OPENVDB_PYGRID_HAS_BEEN_INCLUDED -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #ifdef PY_OPENVDB_USE_NUMPY -#include +#include +#include #include #include // for tools::volumeToMesh() #endif @@ -38,7 +43,7 @@ #include #include -namespace py = pybind11; +namespace nb = nanobind; #ifdef __clang__ // This is a private header, so it's OK to include a "using namespace" directive. @@ -66,10 +71,10 @@ copyGrid(GridType& grid) template inline bool -sharesWith(const GridType& grid, py::object other) +sharesWith(const GridType& grid, nb::object other) { - if (py::isinstance(other)) { - typename GridType::ConstPtr otherGrid = py::cast(other); + if (nb::isinstance(other)) { + typename GridType::ConstPtr otherGrid = nb::cast(other); return (&otherGrid->tree() == &grid.tree()); } return false; @@ -131,7 +136,7 @@ struct AccessorHelper static Wrapper wrap(typename GridType::Ptr grid) { if (!grid) { - throw py::value_error("null grid"); + throw nb::value_error("null grid"); } return Wrapper(grid); } @@ -145,7 +150,7 @@ struct AccessorHelper static Wrapper wrap(typename GridType::ConstPtr grid) { if (!grid) { - throw py::value_error("null grid"); + throw nb::value_error("null grid"); } return Wrapper(grid); } @@ -205,7 +210,7 @@ getNodeLog2Dims(const GridType& grid) template -inline Index +inline Index64 treeDepth(const GridType& grid) { return grid.tree().treeDepth(); @@ -213,7 +218,7 @@ treeDepth(const GridType& grid) template -inline Index32 +inline Index64 leafCount(const GridType& grid) { return grid.tree().leafCount(); @@ -221,7 +226,7 @@ leafCount(const GridType& grid) template -inline Index32 +inline Index64 nonLeafCount(const GridType& grid) { return grid.tree().nonLeafCount(); @@ -307,372 +312,210 @@ signedFloodFill(GridType& grid) template inline void -copyFromArray(GridType&, const py::object&, py::object, py::object) +copyFromArrayScalar(GridType&, const nb::object&, nb::object, nb::object) { PyErr_SetString(PyExc_NotImplementedError, "this module was built without NumPy support"); - throw py::error_already_set(); + throw nb::python_error(); } template inline void -copyToArray(GridType&, const py::object&, py::object) +copyFromArrayVector(GridType&, const nb::object&, nb::object, nb::object) { PyErr_SetString(PyExc_NotImplementedError, "this module was built without NumPy support"); - throw py::error_already_set(); -} - -#else // if defined(PY_OPENVDB_USE_NUMPY) - -using ArrayDimVec = std::vector; - -// ID numbers for supported value types -enum class DtId { NONE, FLOAT, DOUBLE, BOOL, INT16, INT32, INT64, UINT32, UINT64/*, HALF*/ }; - -template struct NumPyToCpp {}; -template<> struct NumPyToCpp { using type = float; }; -template<> struct NumPyToCpp { using type = double; }; -template<> struct NumPyToCpp { using type = bool; }; -template<> struct NumPyToCpp { using type = Int16; }; -template<> struct NumPyToCpp { using type = Int32; }; -template<> struct NumPyToCpp { using type = Int64; }; -template<> struct NumPyToCpp { using type = Index32; }; -template<> struct NumPyToCpp { using type = Index64; }; -//template<> struct NumPyToCpp { using type = math::half; }; - - -#if 0 -template struct CppToNumPy { static const DtId typeId = DtId::NONE; }; -template<> struct CppToNumPy { static const DtId typeId = DtId::FLOAT; }; -template<> struct CppToNumPy { static const DtId typeId = DtId::DOUBLE; }; -template<> struct CppToNumPy { static const DtId typeId = DtId::BOOL; }; -template<> struct CppToNumPy { static const DtId typeId = DtId::INT16; }; -template<> struct CppToNumPy { static const DtId typeId = DtId::INT32; }; -template<> struct CppToNumPy { static const DtId typeId = DtId::INT64; }; -template<> struct CppToNumPy { static const DtId typeId = DtId::UINT32; }; -template<> struct CppToNumPy { static const DtId typeId = DtId::UINT64; }; -//template<> struct CppToNumPy { static const DtId typeId = DtId::HALF; }; -#endif - - -// Return the ID number of the given NumPy array's data type. -/// @todo Revisit this if and when py::numpy::dtype ever provides a type number accessor. -inline DtId -arrayTypeId(const py::array& array) -{ - const auto dtype = array.dtype(); - if (dtype.is(py::dtype::of())) return DtId::FLOAT; - if (dtype.is(py::dtype::of())) return DtId::DOUBLE; - if (dtype.is(py::dtype::of())) return DtId::BOOL; - if (dtype.is(py::dtype::of())) return DtId::INT16; - if (dtype.is(py::dtype::of())) return DtId::INT32; - if (dtype.is(py::dtype::of())) return DtId::INT64; - if (dtype.is(py::dtype::of())) return DtId::UINT32; - if (dtype.is(py::dtype::of())) return DtId::UINT64; - //if (dtype.is(py::dtype::of())) return DtId::HALF; - throw openvdb::TypeError{}; + throw nb::python_error(); } - -// Return a string description of the given NumPy array's data type. -inline std::string -arrayTypeName(const py::array& array) +template +inline void +copyToArrayScalar(GridType&, const nb::object&, nb::object) { - return py::str(array.dtype()); + PyErr_SetString(PyExc_NotImplementedError, "this module was built without NumPy support"); + throw nb::python_error(); } - -// Return the dimensions of the given NumPy array. -inline ArrayDimVec -arrayDimensions(const py::array& array) +template +inline void +copyToArrayVector(GridType&, const nb::object&, nb::object) { - ArrayDimVec dims; - for (size_t i = 0, N = array.ndim(); i < N; ++i) { - dims.push_back(array.shape(i)); - } - return dims; + PyErr_SetString(PyExc_NotImplementedError, "this module was built without NumPy support"); + throw nb::python_error(); } +#else // if defined(PY_OPENVDB_USE_NUMPY) - -// Abstract base class for helper classes that copy data between -// NumPy arrays of various types and grids of various types template -class CopyOpBase +inline void +copyFromArrayScalar(GridType& grid, nb::ndarray array, const Coord& origin, const typename GridType::ValueType& tolerance) { -public: - using ValueT = typename GridType::ValueType; - - CopyOpBase(bool toGrid, GridType& grid, py::array array, - const Coord& origin, const typename GridType::ValueType& tolerance) - : mToGrid(toGrid) - , mGrid(&grid) - { - mArray = array.mutable_data(); - mArrayTypeName = arrayTypeName(array); - mArrayTypeId = arrayTypeId(array); - mArrayDims = arrayDimensions(array); - - mTolerance = tolerance; - - // Compute the bounding box of the region of the grid that is to be copied from or to. - // origin specifies the coordinates (i, j, k) of the voxel at which to start populating data. - // Voxel (i, j, k) will correspond to array element (0, 0, 0). - Coord bboxMax = origin; - for (size_t n = 0, N = std::min(mArrayDims.size(), 3); n < N; ++n) { - bboxMax[n] += int(mArrayDims[n]) - 1; - } - mBBox.reset(origin, bboxMax); + if (array.ndim() != 3) { + std::stringstream ss; + ss << "Expected array with ndim = 3, found array with ndim = " << array.ndim(); + throw nb::value_error(ss.str().c_str()); } - virtual ~CopyOpBase() {} - void operator()() const - { - try { - if (mToGrid) { - copyFromArray(); // copy data from the array to the grid - } else { - copyToArray(); // copy data from the grid to the array - } - } catch (openvdb::TypeError&) { - std::ostringstream os; - os << "unsupported NumPy data type "; - os << mArrayTypeName.c_str(); - throw py::type_error(os.str()); - } + // Compute the bounding box of the region of the grid that is to be copied from or to. + // origin specifies the coordinates (i, j, k) of the voxel at which to start populating data. + // Voxel (i, j, k) will correspond to array element (0, 0, 0). + CoordBBox bbox(origin, origin + Coord(static_cast(array.shape(0)), static_cast(array.shape(1)), static_cast(array.shape(2))) - Coord(1)); + if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else { + throw openvdb::TypeError(); } +} -protected: - virtual void validate() const = 0; - virtual void copyFromArray() const = 0; - virtual void copyToArray() const = 0; - - template - void fromArray() const - { - validate(); - tools::Dense valArray(mBBox, static_cast(mArray)); - tools::copyFromDense(valArray, *mGrid, mTolerance); - } - - template - void toArray() const - { - validate(); - tools::Dense valArray(mBBox, static_cast(mArray)); - tools::copyToDense(*mGrid, valArray); - } - - - bool mToGrid; // if true, copy from the array to the grid, else vice-versa - void* mArray; - GridType* mGrid; - DtId mArrayTypeId; - ArrayDimVec mArrayDims; - std::string mArrayTypeName; - CoordBBox mBBox; - ValueT mTolerance; -}; // class CopyOpBase - - -// Helper subclass that can be specialized for various grid and NumPy array types -template class CopyOp: public CopyOpBase {}; - -// Specialization for scalar grids template -class CopyOp: public CopyOpBase +inline void +copyFromArrayVector(GridType& grid, nb::ndarray array, const Coord& origin, const typename GridType::ValueType& tolerance) { -public: - CopyOp(bool toGrid, GridType& grid, py::array array, const Coord& coord, - const typename GridType::ValueType& tolerance = zeroVal()): - CopyOpBase(toGrid, grid, array, coord, tolerance) - { + if (array.ndim() != 4) { + std::stringstream ss; + ss << "Expected array with ndim = 4, found array with ndim = " << array.ndim(); + throw nb::value_error(ss.str().c_str()); } -protected: - void validate() const override - { - if (this->mArrayDims.size() != 3) { - std::ostringstream os; - os << "expected 3-dimensional array, found " - << this->mArrayDims.size() << "-dimensional array"; - throw py::value_error(os.str()); - } + // Compute the bounding box of the region of the grid that is to be copied from or to. + // origin specifies the coordinates (i, j, k) of the voxel at which to start populating data. + // Voxel (i, j, k) will correspond to array element (0, 0, 0). + CoordBBox bbox(origin, origin + Coord(static_cast(array.shape(0)), static_cast(array.shape(1)), static_cast(array.shape(2))) - Coord(1)); + if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyFromDense(valArray, grid, tolerance); + } else { + throw openvdb::TypeError(); } +} -#ifdef __clang__ - // Suppress "enum value not explicitly handled" warnings - PRAGMA(clang diagnostic push) - PRAGMA(clang diagnostic ignored "-Wswitch-enum") -#endif - - void copyFromArray() const override - { - switch (this->mArrayTypeId) { - case DtId::FLOAT: this->template fromArray::type>(); break; - case DtId::DOUBLE:this->template fromArray::type>();break; - case DtId::BOOL: this->template fromArray::type>(); break; - case DtId::INT16: this->template fromArray::type>(); break; - case DtId::INT32: this->template fromArray::type>(); break; - case DtId::INT64: this->template fromArray::type>(); break; - case DtId::UINT32:this->template fromArray::type>();break; - case DtId::UINT64:this->template fromArray::type>();break; - default: throw openvdb::TypeError(); break; - } - } - - void copyToArray() const override - { - switch (this->mArrayTypeId) { - case DtId::FLOAT: this->template toArray::type>(); break; - case DtId::DOUBLE: this->template toArray::type>(); break; - case DtId::BOOL: this->template toArray::type>(); break; - case DtId::INT16: this->template toArray::type>(); break; - case DtId::INT32: this->template toArray::type>(); break; - case DtId::INT64: this->template toArray::type>(); break; - case DtId::UINT32: this->template toArray::type>(); break; - case DtId::UINT64: this->template toArray::type>(); break; - default: throw openvdb::TypeError(); break; - } - } - -#ifdef __clang__ - PRAGMA(clang diagnostic pop) -#endif - -}; // class CopyOp - -// Specialization for Vec3 grids template -class CopyOp: public CopyOpBase +inline void +copyToArrayScalar(GridType& grid, nb::ndarray array, const Coord& origin) { -public: - CopyOp(bool toGrid, GridType& grid, py::array array, const Coord& coord, - const typename GridType::ValueType& tolerance = zeroVal()): - CopyOpBase(toGrid, grid, array, coord, tolerance) - { - } - -protected: - void validate() const override - { - if (this->mArrayDims.size() != 4) { - std::ostringstream os; - os << "expected 4-dimensional array, found " - << this->mArrayDims.size() << "-dimensional array"; - throw py::value_error(os.str()); - } - if (this->mArrayDims[3] != 3) { - std::ostringstream os; - os << "expected " << this->mArrayDims[0] << "x" << this->mArrayDims[1] - << "x" << this->mArrayDims[2] << "x3 array, found " << this->mArrayDims[0] - << "x" << this->mArrayDims[1] << "x" << this->mArrayDims[2] - << "x" << this->mArrayDims[3] << " array"; - throw py::value_error(os.str()); - } - } - -#ifdef __clang__ - // Suppress "enum value not explicitly handled" warnings - PRAGMA(clang diagnostic push) - PRAGMA(clang diagnostic ignored "-Wswitch-enum") -#endif - - void copyFromArray() const override - { - switch (this->mArrayTypeId) { - case DtId::FLOAT: - this->template fromArray::type>>(); break; - case DtId::DOUBLE: - this->template fromArray::type>>(); break; - case DtId::BOOL: - this->template fromArray::type>>(); break; - case DtId::INT16: - this->template fromArray::type>>(); break; - case DtId::INT32: - this->template fromArray::type>>(); break; - case DtId::INT64: - this->template fromArray::type>>(); break; - case DtId::UINT32: - this->template fromArray::type>>(); break; - case DtId::UINT64: - this->template fromArray::type>>(); break; - default: throw openvdb::TypeError(); break; - } + if (array.ndim() != 3) { + std::stringstream ss; + ss << "Expected array with ndim = 3, found array with ndim = " << array.ndim(); + throw nb::value_error(ss.str().c_str()); } - void copyToArray() const override - { - switch (this->mArrayTypeId) { - case DtId::FLOAT: - this->template toArray::type>>(); break; - case DtId::DOUBLE: - this->template toArray::type>>(); break; - case DtId::BOOL: - this->template toArray::type>>(); break; - case DtId::INT16: - this->template toArray::type>>(); break; - case DtId::INT32: - this->template toArray::type>>(); break; - case DtId::INT64: - this->template toArray::type>>(); break; - case DtId::UINT32: - this->template toArray::type>>(); break; - case DtId::UINT64: - this->template toArray::type>>(); break; - default: throw openvdb::TypeError(); break; - } + // Compute the bounding box of the region of the grid that is to be copied from or to. + // origin specifies the coordinates (i, j, k) of the voxel at which to start populating data. + // Voxel (i, j, k) will correspond to array element (0, 0, 0). + CoordBBox bbox(origin, origin + Coord(static_cast(array.shape(0)), static_cast(array.shape(1)), static_cast(array.shape(2))) - Coord(1)); + if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense valArray(bbox, reinterpret_cast(array.data())); + tools::copyToDense(grid, valArray); + } else { + throw openvdb::TypeError(); } - -#ifdef __clang__ - PRAGMA(clang diagnostic pop) -#endif - -}; // class CopyOp - - -template -inline void -copyFromArray(GridType& grid, py::array array, const Coord& coord, const typename GridType::ValueType& tolerance) -{ - using ValueT = typename GridType::ValueType; - CopyOp::Size> - op(/*toGrid=*/true, grid, array, coord, tolerance); - op(); } - template inline void -copyToArray(GridType& grid, py::array array, const Coord& coord) +copyToArrayVector(GridType& grid, nb::ndarray array, const Coord& origin) { - using ValueT = typename GridType::ValueType; - CopyOp::Size> - op(/*toGrid=*/false, grid, array, coord); - op(); -} - - -template<> -inline void -copyFromArray(points::PointDataGrid& /*grid*/, py::array /*array*/, - const Coord& /*coord*/, const typename points::PointDataGrid::ValueType& /*tolerance*/) -{ - PyErr_SetString(PyExc_NotImplementedError, - "copying NumPy arrays for PointDataGrids is not supported"); - throw py::error_already_set(); -} - + if (array.ndim() != 4) { + std::stringstream ss; + ss << "Expected array with ndim = 4, found array with ndim = " << array.ndim(); + throw nb::value_error(ss.str().c_str()); + } -template<> -inline void -copyToArray(points::PointDataGrid& /*grid*/, py::array /*array*/, const Coord& /*coord*/) -{ - PyErr_SetString(PyExc_NotImplementedError, - "copying NumPy arrays for PointDataGrids is not supported"); - throw py::error_already_set(); + // Compute the bounding box of the region of the grid that is to be copied from or to. + // origin specifies the coordinates (i, j, k) of the voxel at which to start populating data. + // Voxel (i, j, k) will correspond to array element (0, 0, 0). + CoordBBox bbox(origin, origin + Coord(static_cast(array.shape(0)), static_cast(array.shape(1)), static_cast(array.shape(2))) - Coord(1)); + if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyToDense(grid, valArray); + } else if (array.dtype() == nb::dtype()) { + tools::Dense> valArray(bbox, reinterpret_cast*>(array.data())); + tools::copyToDense(grid, valArray); + } else { + throw openvdb::TypeError(); + } } - #endif // defined(PY_OPENVDB_USE_NUMPY) @@ -683,195 +526,184 @@ copyToArray(points::PointDataGrid& /*grid*/, py::array /*array*/, const Coord& / template inline typename GridType::Ptr -meshToLevelSet(py::object, py::object, py::object, py::object, py::object) +meshToLevelSet(nb::object, nb::object, nb::object, nb::object, nb::object) { PyErr_SetString(PyExc_NotImplementedError, "this module was built without NumPy support"); - throw py::error_already_set(); + throw nb::python_error(); return typename GridType::Ptr(); } template -inline py::object -volumeToQuadMesh(const GridType&, py::object) +inline typename GridType::Ptr +meshToSignedDistanceField(nb::object, nb::object, nb::object, nb::object, nb::object, nb::object) { PyErr_SetString(PyExc_NotImplementedError, "this module was built without NumPy support"); - throw py::error_already_set(); - return py::object(); + throw nb::python_error(); + return typename GridType::Ptr(); } template -inline py::object -volumeToMesh(const GridType&, py::object, py::object) +inline nb::object +volumeToQuadMesh(const GridType&, nb::object) { PyErr_SetString(PyExc_NotImplementedError, "this module was built without NumPy support"); - throw py::error_already_set(); - return py::object(); + throw nb::python_error(); + return nb::object(); +} + +template +inline nb::object +volumeToMesh(const GridType&, nb::object, nb::object) +{ + PyErr_SetString(PyExc_NotImplementedError, "this module was built without NumPy support"); + throw nb::python_error(); + return nb::object(); } #else // if defined(PY_OPENVDB_USE_NUMPY) -// Helper class for meshToLevelSet() -template -struct CopyVecOp { - void operator()(const void* srcPtr, DstT* dst, size_t count) { - const SrcT* src = static_cast(srcPtr); - for (size_t i = count; i > 0; --i, ++src, ++dst) { - *dst = static_cast(*src); - } - } -}; -// Partial specialization for source and destination arrays of the same type -template -struct CopyVecOp { - void operator()(const void* srcPtr, T* dst, size_t count) { - const T* src = static_cast(srcPtr); - ::memcpy(dst, src, count * sizeof(T)); +/// @brief Given NumPy arrays of points, triangle indices, and quad indices, +/// call tools::meshToLevelSet() to generate a level set grid. +template +inline typename GridType::Ptr +meshToLevelSet( + nb::ndarray, nb::device::cpu> pointsObj, + std::optional, nb::device::cpu>>& trianglesObj, + std::optional, nb::device::cpu>>& quadsObj, + math::Transform::Ptr xform, float halfWidth) +{ + // Extract the list of mesh vertices from the arguments to this method. + std::vector points(pointsObj.shape(0)); + // Copy values from the array to the vector. + for (size_t i = 0; i < pointsObj.shape(0); ++i) + points[i] = Vec3s(pointsObj(i, 0), pointsObj(i, 1), pointsObj(i, 2)); + + // Extract the list of triangle indices from the arguments to this method. + std::vector triangles; + if (trianglesObj) { + triangles.resize(trianglesObj->shape(0)); + for (size_t i = 0; i < trianglesObj->shape(0); ++i) + triangles[i] = Vec3I((*trianglesObj)(i, 0), (*trianglesObj)(i, 1), (*trianglesObj)(i, 2)); } -}; + // Extract the list of quad indices from the arguments to this method. + std::vector quads; + if (quadsObj) { + quads.resize(quadsObj->shape(0)); + for (size_t i = 0; i < quadsObj->shape(0); ++i) + quads[i] = Vec4I((*quadsObj)(i, 0), (*quadsObj)(i, 1), (*quadsObj)(i, 2), (*quadsObj)(i, 3)); + } -// Helper function for use with meshToLevelSet() to copy vectors of various types -// and sizes from NumPy arrays to STL vectors -template -inline void -copyVecArray(py::array& arrayObj, std::vector& vec) -{ - using ValueT = typename VecT::ValueType; - - // Get the input array dimensions. - const auto dims = arrayDimensions(arrayObj); - const size_t M = dims.empty() ? 0 : dims[0]; - const size_t N = VecT().numElements(); - if (M == 0 || N == 0) return; - - // Preallocate the output vector. - vec.resize(M); - - // Copy values from the input array to the output vector (with type conversion, if necessary). - const void* src = arrayObj.data(); - ValueT* dst = &vec[0][0]; - switch (arrayTypeId(arrayObj)) { - case DtId::FLOAT: CopyVecOp::type, ValueT>()(src, dst, M*N); break; - case DtId::DOUBLE: CopyVecOp::type, ValueT>()(src, dst, M*N); break; - case DtId::INT16: CopyVecOp::type, ValueT>()(src, dst, M*N); break; - case DtId::INT32: CopyVecOp::type, ValueT>()(src, dst, M*N); break; - case DtId::INT64: CopyVecOp::type, ValueT>()(src, dst, M*N); break; - case DtId::UINT32: CopyVecOp::type, ValueT>()(src, dst, M*N); break; - case DtId::UINT64: CopyVecOp::type, ValueT>()(src, dst, M*N); break; - default: break; + // Generate and return a level set grid. + if (xform) { + return tools::meshToLevelSet(*xform, points, triangles, quads, halfWidth); + } + else { + math::Transform::Ptr identity = math::Transform::createLinearTransform(); + return tools::meshToLevelSet(*identity, points, triangles, quads, halfWidth); } } - -/// @brief Given NumPy arrays of points, triangle indices, and quad indices, -/// call tools::meshToLevelSet() to generate a level set grid. template inline typename GridType::Ptr -meshToLevelSet(py::array_t pointsObj, py::array_t trianglesObj, py::array_t quadsObj, math::Transform::Ptr xform, float halfWidth) +meshToSignedDistanceField( + nb::ndarray, nb::device::cpu> pointsObj, + std::optional, nb::device::cpu>>& trianglesObj, + std::optional, nb::device::cpu>>& quadsObj, + math::Transform::Ptr xform, float exBandWidth, float inBandWidth) { - auto validate2DArray = [](py::array array, ssize_t N) { - if (array.ndim() != 2 || array.shape(1) != N) { - std::ostringstream os; - os << "Expected a 2-dimensional numpy.ndarray with shape(1) = "<< N; - os << ", found " << array.ndim() << "-dimensional array with shape = ("; - for (ssize_t i = 0; i < array.ndim(); ++i) { - os << array.shape(i); - if (i != array.ndim() - 1) - os << ", "; - } - os <<")."; - throw py::type_error(os.str()); - } - }; - // Extract the list of mesh vertices from the arguments to this method. - std::vector points; - // Throw an exception if the array has the wrong type or dimensions. - validate2DArray(pointsObj, 3); + std::vector points(pointsObj.shape(0)); // Copy values from the array to the vector. - copyVecArray(pointsObj, points); + for (size_t i = 0; i < pointsObj.shape(0); ++i) + points[i] = Vec3s(pointsObj(i, 0), pointsObj(i, 1), pointsObj(i, 2)); // Extract the list of triangle indices from the arguments to this method. std::vector triangles; - validate2DArray(trianglesObj, 3); - copyVecArray(trianglesObj, triangles); + if (trianglesObj) { + triangles.resize(trianglesObj->shape(0)); + for (size_t i = 0; i < trianglesObj->shape(0); ++i) + triangles[i] = Vec3I((*trianglesObj)(i, 0), (*trianglesObj)(i, 1), (*trianglesObj)(i, 2)); + } // Extract the list of quad indices from the arguments to this method. - std::vector quads; - validate2DArray(quadsObj, 4); - copyVecArray(quadsObj, quads); + std::vector quads; + if (quadsObj) { + quads.resize(quadsObj->shape(0)); + for (size_t i = 0; i < quadsObj->shape(0); ++i) + quads[i] = Vec4I((*quadsObj)(i, 0), (*quadsObj)(i, 1), (*quadsObj)(i, 2), (*quadsObj)(i, 3)); + } // Generate and return a level set grid. if (xform) { - return tools::meshToLevelSet(*xform, points, triangles, quads, halfWidth); + return tools::meshToSignedDistanceField(*xform, points, triangles, quads, exBandWidth, inBandWidth); } else { math::Transform::Ptr identity = math::Transform::createLinearTransform(); - return tools::meshToLevelSet(*identity, points, triangles, quads, halfWidth); + return tools::meshToSignedDistanceField(*identity, points, triangles, quads, exBandWidth, inBandWidth); } } template::value>* = nullptr> -inline std::tuple, py::array_t > +inline std::tuple, nb::ndarray > volumeToQuadMesh(const GridType&, double) { OPENVDB_THROW(TypeError, "volume to mesh conversion is supported only for scalar grids"); } template::value>* = nullptr> -inline std::tuple, py::array_t > +inline std::tuple, nb::ndarray > volumeToQuadMesh(const GridType& grid, double isovalue) { // Mesh the input grid and populate lists of mesh vertices and face vertex indices. - std::vector points; - std::vector quads; - tools::volumeToMesh(grid, points, quads, isovalue); + auto points = new std::vector(); + auto quads = new std::vector(); + tools::volumeToMesh(grid, *points, *quads, isovalue); - std::vector shape = { static_cast(points.size()), 3 }; - std::vector strides = { 3 * static_cast(sizeof(float)), static_cast(sizeof(float))}; - py::array_t pointArrayObj(py::buffer_info(points.data(), sizeof(float), py::format_descriptor::format(), 2, shape, strides)); + nb::capsule pointsDeleter(points, [](void* p) noexcept { + delete (std::vector*) p; + }); + nb::ndarray pointArray(points->data(), {points->size(), 3}, pointsDeleter, {3, 1}); - shape = { static_cast(quads.size()), 4 }; - strides = { 4 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))}; - py::array_t quadArrayObj(py::buffer_info(quads.data(), sizeof(Index32), py::format_descriptor::format(), 2, shape, strides)); + nb::capsule quadsDeleter(quads, [](void* p) noexcept { + delete (std::vector*) p; + }); + nb::ndarray quadArray(quads->data(), {quads->size(), 4}, quadsDeleter, {4, 1}); - return std::make_tuple(pointArrayObj, quadArrayObj); + return std::make_tuple(pointArray, quadArray); } template::value>* = nullptr> -inline std::tuple, py::array_t, py::array_t > +inline std::tuple, nb::ndarray, nb::ndarray > volumeToMesh(const GridType&, double, double) { OPENVDB_THROW(TypeError, "volume to mesh conversion is supported only for scalar grids"); } template::value>* = nullptr> -inline std::tuple, py::array_t, py::array_t > +inline std::tuple, nb::ndarray, nb::ndarray > volumeToMesh(const GridType& grid, double isovalue, double adaptivity) { // Mesh the input grid and populate lists of mesh vertices and face vertex indices. - std::vector points; - std::vector triangles; - std::vector quads; - tools::volumeToMesh(grid, points, triangles, quads, isovalue, adaptivity); - - // Create a deep copy of the array (because the point vector will be destroyed - // when this function returns). - - std::vector shape = { static_cast(points.size()), 3 }; - std::vector strides = { 3 * static_cast(sizeof(float)), static_cast(sizeof(float))}; - py::buffer_info pointInfo(points.data(), sizeof(float), py::format_descriptor::format(), 2, shape, strides); - py::array_t pointArray(pointInfo); - - shape = { static_cast(triangles.size()), 3 }; - strides = { 3 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))}; - py::buffer_info triangleInfo(triangles.data(), sizeof(Index32), py::format_descriptor::format(), 2, shape, strides); - py::array_t triangleArray(triangleInfo); - - shape = { static_cast(quads.size()), 4 }; - strides = { 4 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))}; - py::buffer_info quadInfo(quads.data(), sizeof(Index32), py::format_descriptor::format(), 2, shape, strides); - py::array_t quadArray(quadInfo); + auto points = new std::vector(); + auto triangles = new std::vector(); + auto quads = new std::vector(); + tools::volumeToMesh(grid, *points, *triangles, *quads, isovalue, adaptivity); + + nb::capsule pointsDeleter(points, [](void* p) noexcept { + delete (std::vector*) p; + }); + nb::ndarray pointArray(points->data(), {points->size(), 3}, pointsDeleter, {3, 1}); + + nb::capsule trianglesDeleter(triangles, [](void* p) noexcept { + delete (std::vector*) p; + }); + nb::ndarray triangleArray(triangles->data(), {triangles->size(), 3}, trianglesDeleter, {3, 1}); + + nb::capsule quadsDeleter(quads, [](void* p) noexcept { + delete (std::vector*) p; + }); + nb::ndarray quadArray(quads->data(), {quads->size(), 4}, quadsDeleter, {4, 1}); return std::make_tuple(pointArray, triangleArray, quadArray); } @@ -884,35 +716,35 @@ volumeToMesh(const GridType& grid, double isovalue, double adaptivity) template inline void -applyMap(const char* methodName, GridType& grid, py::object funcObj) +applyMap(const char* methodName, GridType& grid, nb::object funcObj) { using ValueT = typename GridType::ValueType; for (IterType it = grid.tree().template begin(); it; ++it) { // Evaluate the functor. - py::object result = funcObj(*it); + nb::object result = funcObj(*it); // Verify that the result is of type GridType::ValueType. try { - py::cast(result); - } catch (py::cast_error&) { + nb::cast(result); + } catch (nb::cast_error&) { std::ostringstream os; os << "expected callable argument to "; os << pyutil::GridTraits::name(); os << "." << methodName << "() to return "; os << openvdb::typeNameAsString(); os << ", found " << pyutil::className(result); - throw py::type_error(os.str()); + throw nb::type_error(os.str().c_str()); } - it.setValue(py::cast(result)); + it.setValue(nb::cast(result)); } } template inline void -mapOn(GridType& grid, py::object funcObj) +mapOn(GridType& grid, nb::object funcObj) { applyMap("mapOn", grid, funcObj); } @@ -920,7 +752,7 @@ mapOn(GridType& grid, py::object funcObj) template inline void -mapOff(GridType& grid, py::object funcObj) +mapOff(GridType& grid, nb::object funcObj) { applyMap("mapOff", grid, funcObj); } @@ -928,7 +760,7 @@ mapOff(GridType& grid, py::object funcObj) template inline void -mapAll(GridType& grid, py::object funcObj) +mapAll(GridType& grid, nb::object funcObj) { applyMap("mapAll", grid, funcObj); } @@ -1098,11 +930,11 @@ struct IterItemSetter using ValueT = typename GridT::ValueType; static void setValue(const IterT&, const ValueT&) { - throw py::attribute_error("can't set attribute 'value'"); + throw nb::attribute_error("can't set attribute 'value'"); } static void setActive(const IterT&, bool /*on*/) { - throw py::attribute_error("can't set attribute 'active'"); + throw nb::attribute_error("can't set attribute 'active'"); } }; @@ -1165,41 +997,41 @@ class IterValueProxy /// @brief Return the value for the given key. /// @throw KeyError if the key is invalid - py::object getItem(py::object keyObj) const + nb::object getItem(nb::object keyObj) const { - if (py::isinstance(keyObj)) { - const std::string key = py::cast(keyObj); - if (key == "value") return py::cast(this->getValue()); - else if (key == "active") return py::cast(this->getActive()); - else if (key == "depth") return py::cast(this->getDepth()); - else if (key == "min") return py::cast(this->getBBoxMin()); - else if (key == "max") return py::cast(this->getBBoxMax()); - else if (key == "count") return py::cast(this->getVoxelCount()); + if (nb::isinstance(keyObj)) { + const std::string key = nb::cast(keyObj); + if (key == "value") return nb::cast(this->getValue()); + else if (key == "active") return nb::cast(this->getActive()); + else if (key == "depth") return nb::cast(this->getDepth()); + else if (key == "min") return nb::cast(this->getBBoxMin()); + else if (key == "max") return nb::cast(this->getBBoxMax()); + else if (key == "count") return nb::cast(this->getVoxelCount()); } - throw py::key_error(py::cast(keyObj.attr("__repr__")())); - return py::object(); + throw nb::key_error(nb::cast(keyObj.attr("__repr__")()).c_str()); + return nb::object(); } /// @brief Set the value for the given key. /// @throw KeyError if the key is invalid /// @throw AttributeError if the key refers to a read-only item - void setItem(py::object keyObj, py::object valObj) + void setItem(nb::object keyObj, nb::object valObj) { - if (py::isinstance(keyObj)) { - const std::string key = py::cast(keyObj); + if (nb::isinstance(keyObj)) { + const std::string key = nb::cast(keyObj); if (key == "value") { - this->setValue(py::cast(valObj)); return; + this->setValue(nb::cast(valObj)); return; } else if (key == "active") { - this->setActive(py::cast(valObj)); return; + this->setActive(nb::cast(valObj)); return; } else if (this->hasKey(key)) { std::ostringstream os; os << "can't set attribute '"; - os << py::cast(keyObj.attr("__repr__")()); + os << nb::cast(keyObj.attr("__repr__")()); os << "'"; - throw py::attribute_error(os.str()); + throw nb::attribute_error(os.str().c_str()); } } - throw py::key_error(py::cast(keyObj.attr("__repr__")())); + throw nb::key_error(nb::cast(keyObj.attr("__repr__")()).c_str()); } bool operator==(const IterValueProxy& other) const @@ -1217,16 +1049,16 @@ class IterValueProxy std::ostream& put(std::ostream& os) const { // valuesAsStrings = ["%s: %s" % key, repr(this[key]) for key in this.keys()] - py::list valuesAsStrings; + nb::list valuesAsStrings; for (int i = 0; this->keys()[i] != nullptr; ++i) { - py::str + nb::str key(this->keys()[i]), val(this->getItem(key).attr("__repr__")()); - valuesAsStrings.append(py::str("'%s': %s").format(py::make_tuple(key, val))); + valuesAsStrings.append(nb::str("'%s': %s").format(nb::make_tuple(key, val))); } // print ", ".join(valuesAsStrings) - py::object joined = py::str(", ").attr("join")(valuesAsStrings); - std::string s = py::cast(joined); + nb::object joined = nb::str(", ").attr("join")(valuesAsStrings); + std::string s = nb::cast(joined); os << "{" << s << "}"; return os; } @@ -1268,45 +1100,43 @@ class IterWrap IterValueProxyT next() { if (!mIter) { - throw py::stop_iteration("no more values"); + throw nb::stop_iteration("no more values"); } IterValueProxyT result(mGrid, mIter); ++mIter; return result; } - static py::object returnSelf(const py::object& obj) { return obj; } + static nb::object returnSelf(const nb::object& obj) { return obj; } /// @brief Define a Python wrapper class for this C++ class and another for /// the IterValueProxy class returned by iterators of this type. - static void wrap(py::module_ m) + static void wrap(nb::module_ m) { const std::string gridClassName = pyutil::GridTraits::type>::name(), iterClassName = gridClassName + Traits::name(), valueClassName = gridClassName + Traits::name() + "Value"; - py::class_(m, + nb::class_(m, iterClassName.c_str(), /*docstring=*/Traits::descr().c_str()) - .def_property_readonly("parent", &IterWrap::parent, + .def_prop_ro("parent", &IterWrap::parent, ("the " + gridClassName + " over which to iterate").c_str()) - .def("next", &IterWrap::next, ("next() -> " + valueClassName).c_str()) - .def("__next__", &IterWrap::next, ("__next__() -> " + valueClassName).c_str()) + .def("next", &IterWrap::next) + .def("__next__", &IterWrap::next) .def("__iter__", &returnSelf); - py::class_(m, + nb::class_(m, valueClassName.c_str(), /*docstring=*/("Proxy for a tile or voxel value in a " + gridClassName).c_str()) .def("copy", &IterValueProxyT::copy, - ("copy() -> " + valueClassName + "\n\n" - "Return a shallow copy of this value, i.e., one that shares\n" - "its data with the original.").c_str()) + "Return a shallow copy of this value, i.e., one that shares its data with the original.") - .def_property_readonly("parent", &IterValueProxyT::parent, + .def_prop_ro("parent", &IterValueProxyT::parent, ("the " + gridClassName + " to which this value belongs").c_str()) .def("__str__", &IterValueProxyT::info) @@ -1315,30 +1145,26 @@ class IterWrap .def("__eq__", &IterValueProxyT::operator==) .def("__ne__", &IterValueProxyT::operator!=) - .def_property("value", &IterValueProxyT::getValue, &IterValueProxyT::setValue, + .def_prop_rw("value", &IterValueProxyT::getValue, &IterValueProxyT::setValue, "value of this tile or voxel") - .def_property("active", &IterValueProxyT::getActive, &IterValueProxyT::setActive, + .def_prop_rw("active", &IterValueProxyT::getActive, &IterValueProxyT::setActive, "active state of this tile or voxel") - .def_property_readonly("depth", &IterValueProxyT::getDepth, + .def_prop_ro("depth", &IterValueProxyT::getDepth, "tree depth at which this value is stored") - .def_property_readonly("min", &IterValueProxyT::getBBoxMin, + .def_prop_ro("min", &IterValueProxyT::getBBoxMin, "lower bound of the axis-aligned bounding box of this tile or voxel") - .def_property_readonly("max", &IterValueProxyT::getBBoxMax, + .def_prop_ro("max", &IterValueProxyT::getBBoxMax, "upper bound of the axis-aligned bounding box of this tile or voxel") - .def_property_readonly("count", &IterValueProxyT::getVoxelCount, + .def_prop_ro("count", &IterValueProxyT::getVoxelCount, "number of voxels spanned by this value") .def_static("keys", &IterValueProxyT::getKeys, - "keys() -> list\n\n" "Return a list of keys for this tile or voxel.") .def_static("__contains__", &IterValueProxyT::hasKey, - "__contains__(key) -> bool\n\n" "Return True if the given key exists.") .def("__getitem__", &IterValueProxyT::getItem, - "__getitem__(key) -> value\n\n" "Return the value of the item with the given key.") .def("__setitem__", &IterValueProxyT::setItem, - "__setitem__(key, value)\n\n" "Set the value of the item with the given key."); } @@ -1353,13 +1179,11 @@ class IterWrap //////////////////////////////////////// -template +template struct PickleSuite { - using GridPtrT = typename GridT::Ptr; - /// Return a tuple representing the state of the given Grid. - static py::tuple getState(const GridPtrT& grid) + static std::tuple getState(const typename GridType::Ptr& grid) { // Serialize the Grid to a string. std::ostringstream ostr(std::ios_base::binary); @@ -1372,30 +1196,15 @@ struct PickleSuite // Construct a state tuple for the serialized Grid. // Convert the byte string to a "bytes" sequence. const std::string s = ostr.str(); - py::bytes bytesObj(s); - return py::make_tuple(bytesObj); + nb::bytes bytesObj(s.c_str(), s.length()); + return std::make_tuple(bytesObj); } /// Restore the given Grid to a saved state. - static GridPtrT setState(py::tuple state) + static void setState(GridType& grid, std::tuple state) { - bool badState = (py::len(state) != 1); - - std::string serialized; - if (!badState) { - // Extract the sequence containing the serialized Grid. - if (py::isinstance(state[0])) - serialized = py::cast(state[0]); - else - badState = true; - } - - if (badState) { - std::ostringstream os; - os << "expected (dict, bytes) tuple in call to __setstate__; found "; - os << py::cast(state.attr("__repr__")()); - throw py::value_error(os.str()); - } + nb::bytes bytesObj = std::get<0>(state); + std::string serialized(bytesObj.c_str(), bytesObj.c_str() + bytesObj.size()); // Restore the internal state of the C++ object. GridPtrVecPtr grids; @@ -1405,12 +1214,13 @@ struct PickleSuite grids = strm.getGrids(); // (note: file-level metadata is ignored) } if (grids && !grids->empty()) { - if (GridPtrT savedGrid = gridPtrCast((*grids)[0])) { - return savedGrid; + if (typename GridType::Ptr savedGrid = gridPtrCast((*grids)[0])) { + new (&grid) GridType(*savedGrid); + return; } } - return GridPtrT(); + new (&grid) GridType(); } }; // struct PickleSuite @@ -1420,11 +1230,10 @@ struct PickleSuite /// Create a Python wrapper for a particular template instantiation of Grid. template -inline void -exportGrid(py::module_ m) +inline nb::class_ +exportGrid(nb::module_ m) { using ValueT = typename GridType::ValueType; - using GridPtr = typename GridType::Ptr; using Traits = pyutil::GridTraits; using ValueOnCIterT = typename GridType::ValueOnCIter; @@ -1440,135 +1249,88 @@ exportGrid(py::module_ m) std::string docstring = docstream.str(); // Define the Grid wrapper class and make it the current scope. - py::class_(m, - /*classname=*/pyGridTypeName.c_str(), - /*docstring=*/(Traits::descr()).c_str()) - .def(py::init<>(), docstring.c_str()) - .def(py::init(), py::arg("background"), + nb::class_ typedGridClass(m, + /*classname=*/(Traits::name()), + /*docstring=*/(Traits::descr()).c_str()); + typedGridClass + .def(nb::init<>(), docstring.c_str()) + .def(nb::init(), nb::arg("background"), "Initialize with the given background value.") .def("copy", &pyGrid::copyGrid, - ("copy() -> " + pyGridTypeName + "\n\n" - "Return a shallow copy of this grid, i.e., a grid\n" - "that shares its voxel data with this grid.").c_str()) + "Return a shallow copy of this grid, i.e., a grid that shares its voxel data with this grid.") .def("deepCopy", &GridType::deepCopy, - ("deepCopy() -> " + pyGridTypeName + "\n\n" - "Return a deep copy of this grid.\n").c_str()) + "Return a deep copy of this grid.") - .def(py::pickle(&PickleSuite::getState, &PickleSuite::setState)) + .def("__getstate__", &PickleSuite::getState) + .def("__setstate__", &PickleSuite::setState) .def("sharesWith", &pyGrid::sharesWith, - ("sharesWith(" + pyGridTypeName + ") -> bool\n\n" - "Return True if this grid shares its voxel data with the given grid.").c_str()) - - /// @todo Any way to set a docstring for a class property? - .def_property_readonly_static("valueTypeName", [](const py::object&) { return pyGrid::getValueType(); }) - /// @todo docstring = "name of this grid's value type" - .def_property_readonly_static("zeroValue", [](const py::object&) { return pyGrid::getZeroValue(); }) - /// @todo docstring = "zero, as expressed in this grid's value type" - .def_property_readonly_static("oneValue", [](const py::object&) { return pyGrid::getOneValue(); }) - /// @todo docstring = "one, as expressed in this grid's value type" + "Return whether or not this grid shares its voxel data with the given grid.") + + .def_prop_ro_static("valueTypeName", [](const nb::object&) { return pyGrid::getValueType(); }, "Name of this grid's value type") + .def_prop_ro_static("zeroValue", [](const nb::object&) { return pyGrid::getZeroValue(); }, "Zero, as expressed in this grid's value type") + .def_prop_ro_static("oneValue", [](const nb::object&) { return pyGrid::getOneValue(); }, "One, as expressed in this grid's value type") /// @todo Is Grid.typeName ever needed? - //.def_property_static("typeName", &GridType::gridType) - /// @todo docstring = to "name of this grid's type" + //.def_prop_rw_static("typeName", &GridType::gridType, "Name of this grid's type") - .def_property("background", + .def_prop_rw("background", &pyGrid::getGridBackground, &pyGrid::setGridBackground, "value of this grid's background voxels") .def("getAccessor", &pyGrid::getAccessor, - ("getAccessor() -> " + pyGridTypeName + "Accessor\n\n" - "Return an accessor that provides random read and write access\n" - "to this grid's voxels.").c_str()) + "Return an accessor that provides random read and write access to this grid's voxels.") .def("getConstAccessor", &pyGrid::getConstAccessor, - ("getConstAccessor() -> " + pyGridTypeName + "Accessor\n\n" - "Return an accessor that provides random read-only access\n" - "to this grid's voxels.").c_str()) + "Return an accessor that provides random read-only access to this grid's voxels.") // // Statistics // .def("evalLeafBoundingBox", &pyGrid::evalLeafBoundingBox, - "evalLeafBoundingBox() -> xyzMin, xyzMax\n\n" - "Return the coordinates of opposite corners of the axis-aligned\n" - "bounding box of all leaf nodes.") + "Return the coordinates of opposite corners of the axis-aligned bounding box of all leaf nodes.") .def("evalLeafDim", &pyGrid::evalLeafDim, - "evalLeafDim() -> x, y, z\n\n" - "Return the dimensions of the axis-aligned bounding box\n" - "of all leaf nodes.") + "Return the dimensions of the axis-aligned bounding box of all leaf nodes.") - .def_property_readonly("treeDepth", &pyGrid::treeDepth, + .def_prop_ro("treeDepth", &pyGrid::treeDepth, "depth of this grid's tree from root node to leaf node") .def("nodeLog2Dims", &pyGrid::getNodeLog2Dims, - "list of Log2Dims of the nodes of this grid's tree\n" - "in order from root to leaf") + "list of Log2Dims of the nodes of this grid's tree in order from root to leaf") .def("leafCount", &pyGrid::leafCount, - "leafCount() -> int\n\n" "Return the number of leaf nodes in this grid's tree.") .def("nonLeafCount", &pyGrid::nonLeafCount, - "nonLeafCount() -> int\n\n" "Return the number of non-leaf nodes in this grid's tree.") .def("activeLeafVoxelCount", &pyGrid::activeLeafVoxelCount, - "activeLeafVoxelCount() -> int\n\n" - "Return the number of active voxels that are stored\n" - "in the leaf nodes of this grid's tree.") + "Return the number of active voxels that are stored in the leaf nodes of this grid's tree.") .def("evalMinMax", &pyGrid::evalMinMax, - "evalMinMax() -> min, max\n\n" "Return the minimum and maximum active values in this grid.") .def("getIndexRange", &pyGrid::getIndexRange, - "getIndexRange() -> min, max\n\n" - "Return the minimum and maximum coordinates that are represented\n" - "in this grid. These might include background voxels.") + "Return the minimum and maximum coordinates that are represented in this grid. These might include background voxels.") //.def("expand", &pyGrid::expandIndexRange, - // py::arg("xyz"), - // "expand(xyz)\n\n" + // nb::arg("xyz"), // "Expand this grid's index range to include the given coordinates.") // // Tools // .def("fill", &pyGrid::fill, - py::arg("min"), py::arg("max"), py::arg("value"), py::arg("active")=true, - "fill(min, max, value, active=True)\n\n" - "Set all voxels within a given axis-aligned box to\n" - "a constant value (either active or inactive).") + nb::arg("min"), nb::arg("max"), nb::arg("value"), nb::arg("active")=true, + "Set all voxels within a given axis-aligned box to a constant value (either active or inactive).") .def("signedFloodFill", &pyGrid::signedFloodFill, - "signedFloodFill()\n\n" - "Propagate the sign from a narrow-band level set into inactive\n" - "voxels and tiles.") - - .def("copyFromArray", &pyGrid::copyFromArray, - py::arg("array"), py::arg("ijk")=Coord(0,0,0), - py::arg("tolerance")=pyGrid::getZeroValue(), - ("copyFromArray(array, ijk=(0, 0, 0), tolerance=0)\n\n" - "Populate this grid, starting at voxel (i, j, k), with values\nfrom a " - + std::string(openvdb::VecTraits::IsVec ? "four" : "three") - + "-dimensional array. Mark voxels as inactive\n" - "if and only if their values are equal to this grid's\n" - "background value within the given tolerance.").c_str()) - .def("copyToArray", &pyGrid::copyToArray, - py::arg("array"), py::arg("ijk")=Coord(0,0,0), - ("copyToArray(array, ijk=(0, 0, 0))\n\nPopulate a " - + std::string(openvdb::VecTraits::IsVec ? "four" : "three") - + "-dimensional array with values\n" - "from this grid, starting at voxel (i, j, k).").c_str()) - + "Propagate the sign from a narrow-band level set into inactive voxels and tiles.") .def("convertToQuads", &pyGrid::volumeToQuadMesh, - py::arg("isovalue")=0, - "convertToQuads(isovalue=0) -> points, quads\n\n" + nb::arg("isovalue")=0, "Uniformly mesh a scalar grid that has a continuous isosurface\n" "at the given isovalue. Return a NumPy array of world-space\n" "points and a NumPy array of 4-tuples of point indices, which\n" "specify the vertices of the quadrilaterals that form the mesh.") .def("convertToPolygons", &pyGrid::volumeToMesh, - py::arg("isovalue")=0, py::arg("adaptivity")=0, - "convertToPolygons(isovalue=0, adaptivity=0) -> points, triangles, quads\n\n" + nb::arg("isovalue")=0, nb::arg("adaptivity")=0, "Adaptively mesh a scalar grid that has a continuous isosurface\n" "at the given isovalue. Return a NumPy array of world-space\n" "points and NumPy arrays of 3- and 4-tuples of point indices,\n" @@ -1579,74 +1341,85 @@ exportGrid(py::module_ m) "with some loss of surface detail.") .def_static("createLevelSetFromPolygons", &pyGrid::meshToLevelSet, - py::arg("points"), + nb::arg("points"), +#ifdef PY_OPENVDB_USE_NUMPY + nb::arg("triangles")=nb::none(), + nb::arg("quads")=nb::none(), +#else + nb::arg("triangles")=std::vector(), + nb::arg("quads")=std::vector(), +#endif + nb::arg("transform")=openvdb::math::Transform(), + nb::arg("halfWidth")=openvdb::LEVEL_SET_HALF_WIDTH, + "Convert a triangle and/or quad mesh to a narrow-band level set volume.\n" + "The mesh must form a closed surface, but the surface need not be\n" + "manifold and may have self intersections and degenerate faces.\n" + "The mesh is described by a NumPy array of world-space points\n" + "and NumPy arrays of 3- and 4-tuples of point indices that specify\n" + "the vertices of the triangles and quadrilaterals that form the mesh.\n" + "Either the triangle or the quad array may be empty or None.\n" + "The resulting volume will have the given transform (or the identity\n" + "transform if no transform is given) and a narrow band width of\n" + "2 x halfWidth voxels.") + .def_static("createLevelSetFromPolygons", + &pyGrid::meshToSignedDistanceField, + nb::arg("points"), #ifdef PY_OPENVDB_USE_NUMPY - py::arg("triangles")=py::array_t({ 0, 3 }, { 3 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))} ), - py::arg("quads")=py::array_t({ 0, 4 }, { 4 * static_cast(sizeof(Index32)), static_cast(sizeof(Index32))} ), + nb::arg("triangles")=nb::none(), + nb::arg("quads")=nb::none(), #else - py::arg("triangles")=std::vector(), - py::arg("quads")=std::vector(), + nb::arg("triangles")=std::vector(), + nb::arg("quads")=std::vector(), #endif - py::arg("transform")=py::none(), - py::arg("halfWidth")=openvdb::LEVEL_SET_HALF_WIDTH, - ("createLevelSetFromPolygons(points, triangles=None, quads=None,\n" - " transform=None, halfWidth=" - + std::to_string(openvdb::LEVEL_SET_HALF_WIDTH) + ") -> " - + pyGridTypeName + "\n\n" - "Convert a triangle and/or quad mesh to a narrow-band level set volume.\n" - "The mesh must form a closed surface, but the surface need not be\n" - "manifold and may have self intersections and degenerate faces.\n" - "The mesh is described by a NumPy array of world-space points\n" - "and NumPy arrays of 3- and 4-tuples of point indices that specify\n" - "the vertices of the triangles and quadrilaterals that form the mesh.\n" - "Either the triangle or the quad array may be empty or None.\n" - "The resulting volume will have the given transform (or the identity\n" - "transform if no transform is given) and a narrow band width of\n" - "2 x halfWidth voxels.").c_str()) + nb::arg("transform")=openvdb::math::Transform(), + nb::arg("exBandWidth")=openvdb::LEVEL_SET_HALF_WIDTH, + nb::arg("inBandWidth")=openvdb::LEVEL_SET_HALF_WIDTH, + "Convert a triangle and/or quad mesh to a narrow-band level set volume.\n" + "The mesh must form a closed surface, but the surface need not be\n" + "manifold and may have self intersections and degenerate faces.\n" + "The mesh is described by a NumPy array of world-space points\n" + "and NumPy arrays of 3- and 4-tuples of point indices that specify\n" + "the vertices of the triangles and quadrilaterals that form the mesh.\n" + "Either the triangle or the quad array may be empty or None.\n" + "The resulting volume will have the given transform (or the identity\n" + "transform if no transform is given) and a narrow band width of\n" + "exBandWidth exterior voxels and inBandWidth interior voxels.") + .def("prune", &pyGrid::prune, - py::arg("tolerance") = 0, - "prune(tolerance=0)\n\n" - "Remove nodes whose values all have the same active state\n" - "and are equal to within a given tolerance.") + nb::arg("tolerance") = 0, + "Remove nodes whose values all have the same active state and are equal to within a given tolerance.") .def("pruneInactive", &pyGrid::pruneInactive, - py::arg("value") = py::none(), - "pruneInactive()\n\n" - "Remove nodes whose values are all inactive and replace them\n" - "with background tiles.") + nb::arg("value") = nb::none(), + "Remove nodes whose values are all inactive and replace them with background tiles.") .def("merge", &GridType::merge, - ("merge(" + pyGridTypeName + ")\n\n" "Move child nodes from the other grid into this grid wherever\n" "those nodes correspond to constant-value tiles in this grid,\n" "and replace leaf-level inactive voxels in this grid with\n" "corresponding voxels in the other grid that are active.\n\n" - "Note: this operation always empties the other grid.").c_str()) + "Note: this operation always empties the other grid.") .def("mapOn", &pyGrid::mapOn, - py::arg("function"), - "mapOn(function)\n\n" + nb::arg("function"), "Iterate over all the active (\"on\") values (tile and voxel)\n" "of this grid and replace each value with function(value).\n\n" "Example: grid.mapOn(lambda x: x * 2 if x < 0.5 else x)") .def("mapOff", &pyGrid::mapOff, - py::arg("function"), - "mapOff(function)\n\n" + nb::arg("function"), "Iterate over all the inactive (\"off\") values (tile and voxel)\n" "of this grid and replace each value with function(value).\n\n" "Example: grid.mapOff(lambda x: x * 2 if x < 0.5 else x)") .def("mapAll", &pyGrid::mapAll, - py::arg("function"), - "mapAll(function)\n\n" + nb::arg("function"), "Iterate over all values (tile and voxel) of this grid\n" "and replace each value with function(value).\n\n" "Example: grid.mapAll(lambda x: x * 2 if x < 0.5 else x)") .def("combine", &pyGrid::combine, - py::arg("grid"), py::arg("function"), - "combine(grid, function)\n\n" + nb::arg("grid"), nb::arg("function"), "Compute function(self, other) over all corresponding pairs\n" "of values (tile or voxel) of this grid and the other grid\n" "and store the result in this grid.\n\n" @@ -1657,24 +1430,18 @@ exportGrid(py::module_ m) // Iterators // .def("citerOnValues", &pyGrid::IterTraits::begin, - "citerOnValues() -> iterator\n\n" - "Return a read-only iterator over this grid's active\ntile and voxel values.") + "Return a read-only iterator over this grid's active tile and voxel values.") .def("citerOffValues", &pyGrid::IterTraits::begin, - "iterOffValues() -> iterator\n\n" - "Return a read-only iterator over this grid's inactive\ntile and voxel values.") + "Return a read-only iterator over this grid's inactive tile and voxel values.") .def("citerAllValues", &pyGrid::IterTraits::begin, - "iterAllValues() -> iterator\n\n" - "Return a read-only iterator over all of this grid's\ntile and voxel values.") + "Return a read-only iterator over all of this grid's tile and voxel values.") .def("iterOnValues", &pyGrid::IterTraits::begin, - "iterOnValues() -> iterator\n\n" - "Return a read/write iterator over this grid's active\ntile and voxel values.") + "Return a read/write iterator over this grid's active tile and voxel values.") .def("iterOffValues", &pyGrid::IterTraits::begin, - "iterOffValues() -> iterator\n\n" - "Return a read/write iterator over this grid's inactive\ntile and voxel values.") + "Return a read/write iterator over this grid's inactive tile and voxel values.") .def("iterAllValues", &pyGrid::IterTraits::begin, - "iterAllValues() -> iterator\n\n" - "Return a read/write iterator over all of this grid's\ntile and voxel values."); + "Return a read/write iterator over all of this grid's tile and voxel values."); // Wrap const and non-const value accessors and expose them // as nested classes of the Grid class. @@ -1690,7 +1457,45 @@ exportGrid(py::module_ m) IterWrap::wrap(m); // Add the Python type object for this grid type to the module-level list. - py::cast(m.attr("GridTypes")).append(m.attr(pyGridTypeName.c_str())); + nb::cast(m.attr("GridTypes")).append(m.attr(Traits::name())); + + return typedGridClass; +} + +template +inline void +exportScalarGrid(nb::module_ m) +{ + exportGrid(m) + .def("copyFromArray", &pyGrid::copyFromArrayScalar, + nb::arg("array").noconvert(), nb::arg("ijk")=Coord(0,0,0), + nb::arg("tolerance")=pyGrid::getZeroValue(), + "Populate this grid, starting at voxel (i, j, k), with values\n" + "from a three-dimensional array. Mark voxels as inactive\n" + "if and only if their values are equal to this grid's\n" + "background value within the given tolerance.") + .def("copyToArray", &pyGrid::copyToArrayScalar, + nb::arg("array").noconvert(), nb::arg("ijk")=Coord(0,0,0), + "Populate a three-dimensional array with values\n" + "from this grid, starting at voxel (i, j, k)."); +} + +template +inline void +exportVectorGrid(nb::module_ m) +{ + exportGrid(m) + .def("copyFromArray", &pyGrid::copyFromArrayVector, + nb::arg("array").noconvert(), nb::arg("ijk")=Coord(0,0,0), + nb::arg("tolerance")=pyGrid::getZeroValue(), + "Populate this grid, starting at voxel (i, j, k), with values\n" + "from a four-dimensional array. Mark voxels as inactive\n" + "if and only if their values are equal to this grid's\n" + "background value within the given tolerance.") + .def("copyToArray", &pyGrid::copyToArrayVector, + nb::arg("array").noconvert(), nb::arg("ijk")=Coord(0,0,0), + "Populate a four-dimensional array with values\n" + "from this grid, starting at voxel (i, j, k)."); } } // namespace pyGrid diff --git a/openvdb/openvdb/python/pyGridBase.cc b/openvdb/openvdb/python/pyGridBase.cc index 0e10a58381..02889bf09b 100644 --- a/openvdb/openvdb/python/pyGridBase.cc +++ b/openvdb/openvdb/python/pyGridBase.cc @@ -1,20 +1,25 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 - -#include -#include +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include +#include +#include #include +#include #include "pyTypeCasters.h" -namespace py = pybind11; +namespace nb = nanobind; using namespace openvdb::OPENVDB_VERSION_NAME; /// Create a Python wrapper for GridBase. void -exportGridBase(py::module_ m) +exportGridBase(nb::module_ m) { // Add a module-level list that gives the types of all supported Grid classes. - m.attr("GridTypes") = py::list(); + m.attr("GridTypes") = nb::list(); auto setName = [](GridBase::Ptr grid, const std::string& name) { if (name.empty()) { @@ -101,20 +106,20 @@ exportGridBase(py::module_ m) auto getMetadataKeys = [](GridBase::ConstPtr grid) { // Return an iterator over the "keys" view of a dict. - return py::make_key_iterator(static_cast(*grid).beginMeta(), static_cast(*grid).endMeta()); + return nb::make_key_iterator(nb::type(), "key_iterator", static_cast(*grid).beginMeta(), static_cast(*grid).endMeta()); }; auto getMetadata = [](GridBase::ConstPtr grid, const std::string& name) { Metadata::ConstPtr metadata = (*grid)[name]; if (!metadata) { - throw py::key_error(name.c_str()); + throw nb::key_error(name.c_str()); } MetaMap metamap; metamap.insertMeta(name, *metadata); // todo: Add/refactor out type_casters for each TypedMetadata from MetaMap's type_caster - return py::cast(py::dict(py::cast(metamap))[py::str(name)]); + return nb::cast(nb::cast(nb::cast(metamap))[nb::str(name.c_str())]); }; @@ -129,9 +134,9 @@ exportGridBase(py::module_ m) // converter (see pyOpenVDBModule.cc) to convert the dict to a MetaMap // containing a Metadata object of the appropriate type. // todo: Add/refactor out type_casters for each TypedMetadata from MetaMap's type_caster - py::dict dictObj; - dictObj[py::str(name)] = value; - MetaMap metamap = py::cast(dictObj); + nb::dict dictObj; + dictObj[nb::str(name.c_str())] = value; + MetaMap metamap = nb::cast(dictObj); if (Metadata::Ptr metadata = metamap[name]) { grid->removeMeta(name); @@ -143,7 +148,7 @@ exportGridBase(py::module_ m) auto removeMetadata = [](GridBase::Ptr grid, const std::string& name) { Metadata::Ptr metadata = (*grid)[name]; if (!metadata) { - throw py::key_error(name.c_str()); + throw nb::key_error(name.c_str()); } grid->removeMeta(name); }; @@ -155,88 +160,72 @@ exportGridBase(py::module_ m) auto evalActiveVoxelBoundingBox = [](GridBase::ConstPtr grid) { CoordBBox bbox = grid->evalActiveVoxelBoundingBox(); - return py::make_tuple(bbox.min(), bbox.max()); + return nb::make_tuple(bbox.min(), bbox.max()); }; // Export GridBase in order to properly support inheritance for typed Grids // and expose the corresponding base-class properties. - py::class_(m, "GridBase") + nb::class_(m, "GridBase") .def("empty", &GridBase::empty, - "empty() -> bool\n\n" "Return True if this grid contains only background voxels.") .def("__nonzero__", [](GridBase::ConstPtr grid) { return !grid->empty(); }) .def("clear", &GridBase::clear, - "clear()\n\n" "Remove all tiles from this grid and all nodes other than the root node.") - .def_property("name", &GridBase::getName, setName, + .def_prop_rw("name", &GridBase::getName, setName, "this grid's user-specified name") - .def_property("creator", &GridBase::getCreator, setCreator, + .def_prop_rw("creator", &GridBase::getCreator, setCreator, "user-specified description of this grid's creator") - .def_property("gridClass", getGridClass, setGridClass, + .def_prop_rw("gridClass", getGridClass, setGridClass, "the class of volumetric data (level set, fog volume, etc.)\n" "stored in this grid") - .def_property("vectorType", getVecType, setVecType, + .def_prop_rw("vectorType", getVecType, setVecType, "how transforms are applied to values stored in this grid") - .def_property("transform", static_cast(&GridBase::transformPtr), + .def_prop_rw("transform", static_cast(&GridBase::transformPtr), setGridTransform, "transform associated with this grid") - .def("info", gridInfo, py::arg("verbosity") = 1, - "info(verbosity=1) -> str\n\n" + .def("info", gridInfo, nb::arg("verbosity") = 1, "Return a string containing information about this grid\n" - "with a specified level of verbosity.\n") + "with a specified level of verbosity.") .def("activeVoxelCount", &GridBase::activeVoxelCount, - "activeVoxelCount() -> int\n\n" "Return the number of active voxels in this grid.") .def("evalActiveVoxelBoundingBox", evalActiveVoxelBoundingBox, - "evalActiveVoxelBoundingBox() -> xyzMin, xyzMax\n\n" "Return the coordinates of opposite corners of the axis-aligned\n" "bounding box of all active voxels.") .def("evalActiveVoxelDim", &GridBase::evalActiveVoxelDim, - "evalActiveVoxelDim() -> x, y, z\n\n" "Return the dimensions of the axis-aligned bounding box of all\n" "active voxels.") .def("memUsage", &GridBase::memUsage, - "memUsage() -> int\n\n" "Return the memory usage of this grid in bytes.") .def("addStatsMetadata", &GridBase::addStatsMetadata, - "addStatsMetadata()\n\n" "Add metadata to this grid comprising the current values\n" "of statistics like the active voxel count and bounding box.\n" "(This metadata is not automatically kept up-to-date with\n" "changes to this grid.)") .def("getStatsMetadata", getStatsMetadata, - "getStatsMetadata() -> dict\n\n" "Return a (possibly empty) dict containing just the metadata\n" "that was added to this grid with addStatsMetadata().") - .def_property("metadata", getAllMetadata, replaceAllMetadata, + .def_prop_rw("metadata", getAllMetadata, replaceAllMetadata, "dict of this grid's metadata\n\n" "Setting this attribute replaces all of this grid's metadata,\n" "but mutating it in place has no effect on the grid, since\n" "the value of this attribute is a only a copy of the metadata.\n" "Use either indexing or updateMetadata() to mutate metadata in place.") .def("updateMetadata", updateMetadata, - "updateMetadata(dict)\n\n" "Add metadata to this grid, replacing any existing items\n" "having the same names as the new items.") .def("__getitem__", getMetadata, - "__getitem__(name) -> value\n\n" "Return the metadata value associated with the given name.") .def("__setitem__", setMetadata, - "__setitem__(name, value)\n\n" "Add metadata to this grid, replacing any existing item having\n" "the same name as the new item.") .def("__delitem__", removeMetadata, - "__delitem__(name)\n\n" "Remove the metadata with the given name.") .def("__contains__", hasMetadata, - "__contains__(name) -> bool\n\n" "Return True if this grid contains metadata with the given name.") .def("__iter__", getMetadataKeys, - "__iter__() -> iterator\n\n" "Return an iterator over this grid's metadata keys.") .def("iterkeys", getMetadataKeys, - "iterkeys() -> iterator\n\n" "Return an iterator over this grid's metadata keys.") - .def_property("saveFloatAsHalf", + .def_prop_rw("saveFloatAsHalf", &GridBase::saveFloatAsHalf, &GridBase::setSaveFloatAsHalf, "if True, write floating-point voxel values as 16-bit half floats"); } diff --git a/openvdb/openvdb/python/pyIntGrid.cc b/openvdb/openvdb/python/pyIntGrid.cc index 14b737f335..3a9c3161ca 100644 --- a/openvdb/openvdb/python/pyIntGrid.cc +++ b/openvdb/openvdb/python/pyIntGrid.cc @@ -1,17 +1,17 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file pyIntGrid.cc -/// @brief pybind11 wrappers for scalar, integer-valued openvdb::Grid types +/// @brief nanobind wrappers for scalar, integer-valued openvdb::Grid types #include "pyGrid.h" void -exportIntGrid(py::module_ m) +exportIntGrid(nb::module_ m) { - pyGrid::exportGrid(m); + pyGrid::exportScalarGrid(m); #ifdef PY_OPENVDB_WRAP_ALL_GRID_TYPES - pyGrid::exportGrid(m); - pyGrid::exportGrid(m); + pyGrid::exportScalarGrid(m); + pyGrid::exportScalarGrid(m); #endif } diff --git a/openvdb/openvdb/python/pyMetadata.cc b/openvdb/openvdb/python/pyMetadata.cc index 11f7d33d84..47d3aff800 100644 --- a/openvdb/openvdb/python/pyMetadata.cc +++ b/openvdb/openvdb/python/pyMetadata.cc @@ -1,35 +1,38 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 -#include +#include +#include +#include #include #include "pyTypeCasters.h" -namespace py = pybind11; +namespace nb = nanobind; using namespace openvdb::OPENVDB_VERSION_NAME; namespace { class MetadataWrap: public Metadata { + NB_TRAMPOLINE(Metadata, 8); private: MetadataWrap(); public: MetadataWrap(const MetadataWrap&) = delete; MetadataWrap& operator=(const MetadataWrap&) = delete; - Name typeName() const override { PYBIND11_OVERRIDE_PURE(Name, Metadata, typeName, ); } - Metadata::Ptr copy() const override { PYBIND11_OVERRIDE_PURE(Metadata::Ptr, Metadata, copy, ); } - void copy(const Metadata& other) override { PYBIND11_OVERRIDE_PURE(void, Metadata, copy, other); } - std::string str() const override { PYBIND11_OVERRIDE_PURE(std::string, Metadata, str, ); } - bool asBool() const override { PYBIND11_OVERRIDE_PURE(bool, Metadata, asBool, ); } - Index32 size() const override { PYBIND11_OVERRIDE_PURE(Index32, Metadata, size, ); } + Name typeName() const override { NB_OVERRIDE_PURE(typeName); } + Metadata::Ptr copy() const override { NB_OVERRIDE_PURE(copy); } + void copy(const Metadata& other) override { NB_OVERRIDE_PURE(copy, other); } + std::string str() const override { NB_OVERRIDE_PURE(str); } + bool asBool() const override { NB_OVERRIDE_PURE(asBool); } + Index32 size() const override { NB_OVERRIDE_PURE(size); } protected: void readValue(std::istream& is, Index32 numBytes) override { - PYBIND11_OVERRIDE_PURE(void, Metadata, readValue, is, numBytes); + NB_OVERRIDE_PURE(readValue, is, numBytes); } void writeValue(std::ostream& os) const override { - PYBIND11_OVERRIDE_PURE(void, Metadata, writeValue, os); + NB_OVERRIDE_PURE(writeValue, os); } }; @@ -37,21 +40,21 @@ class MetadataWrap: public Metadata void -exportMetadata(py::module_ m) +exportMetadata(nb::module_ m) { - py::class_(m, + nb::class_(m, /*classname=*/"Metadata", /*docstring=*/ "Class that holds the value of a single item of metadata of a type\n" "for which no Python equivalent exists (typically a custom type)") .def("copy", static_cast(&Metadata::copy), - "copy() -> Metadata\n\nReturn a copy of this value.") + "Return a copy of this value.") .def("copy", static_cast(&Metadata::copy), - "copy() -> Metadata\n\nReturn a copy of this value.") + "Return a copy of this value.") .def("type", &Metadata::typeName, - "type() -> str\n\nReturn the name of this value's type.") + "Return the name of this value's type.") .def("size", &Metadata::size, - "size() -> int\n\nReturn the size of this value in bytes.") + "Return the size of this value in bytes.") .def("__nonzero__", &Metadata::asBool) .def("__str__", &Metadata::str); } diff --git a/openvdb/openvdb/python/pyOpenVDBModule.cc b/openvdb/openvdb/python/pyOpenVDBModule.cc index 0575919ebc..4b73e1b40a 100644 --- a/openvdb/openvdb/python/pyOpenVDBModule.cc +++ b/openvdb/openvdb/python/pyOpenVDBModule.cc @@ -1,14 +1,15 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // must be included before python on macos #include // for strncmp(), strrchr(), etc. #include #include #include // for std::make_pair() -#include -#include -#include +#include +#include +#include +#include #include #include "pyGrid.h" #include "pyutil.h" @@ -18,16 +19,16 @@ #include #endif -namespace py = pybind11; +namespace nb = nanobind; // Forward declarations -void exportTransform(py::module_ m); -void exportMetadata(py::module_ m); -void exportGridBase(py::module_ m); -void exportFloatGrid(py::module_ m); -void exportIntGrid(py::module_ m); -void exportVec3Grid(py::module_ m); -void exportPointGrid(py::module_ m); +void exportTransform(nb::module_ m); +void exportMetadata(nb::module_ m); +void exportGridBase(nb::module_ m); +void exportFloatGrid(nb::module_ m); +void exportIntGrid(nb::module_ m); +void exportVec3Grid(nb::module_ m); +void exportPointGrid(nb::module_ m); namespace _openvdbmodule { @@ -83,7 +84,7 @@ readFromFile(const std::string& filename, const std::string& gridName) if (!vdbFile.hasGrid(gridName)) { std::ostringstream os; os << "file " << filename << " has no grid named \"" << gridName << "\""; - throw py::key_error(os.str()); + throw nb::key_error(os.str().c_str()); } GridBase::Ptr grid = vdbFile.readGrid(gridName); @@ -129,7 +130,7 @@ readGridMetadataFromFile(const std::string& filename, const std::string& gridNam if (!vdbFile.hasGrid(gridName)) { std::ostringstream os; os << "file " << filename << " has no grid named \"" << gridName <<"\""; - throw py::key_error(os.str()); + throw nb::key_error(os.str().c_str()); } return vdbFile.readGridMetadata(gridName); @@ -241,7 +242,7 @@ setLoggingLevel(const std::string& loggingLevel) PyErr_Format(PyExc_ValueError, "expected logging level \"debug\", \"info\", \"warn\", \"error\", or \"fatal\"," " got \"%s\"", levelStr.c_str()); - throw py::error_already_set(); + throw nb::python_error(); } @@ -325,22 +326,8 @@ struct VecTypeDescr //////////////////////////////////////// - -#ifdef DWA_OPENVDB -#define PY_OPENVDB_MODULE_NAME _openvdb -extern "C" { void init_openvdb(); } -#else -#define PY_OPENVDB_MODULE_NAME pyopenvdb -extern "C" { void initpyopenvdb(); } -#endif - -PYBIND11_MODULE(PY_OPENVDB_MODULE_NAME, m) +NB_MODULE(openvdb, m) { - // Don't auto-generate ugly, C++-style function signatures. - py::options docOptions; - docOptions.disable_function_signatures(); - docOptions.enable_user_defined_docstrings(); - using namespace openvdb::OPENVDB_VERSION_NAME; // Initialize OpenVDB. @@ -349,12 +336,12 @@ PYBIND11_MODULE(PY_OPENVDB_MODULE_NAME, m) openvdb::ax::initialize(); #endif -#define PYOPENVDB_TRANSLATE_EXCEPTION(_classname) \ - py::register_exception_translator([](std::exception_ptr p) { \ - try { \ - if (p) std::rethrow_exception(p); \ - } catch (const _classname &e) { \ - _openvdbmodule::translateException<_classname>(e); \ +#define PYOPENVDB_TRANSLATE_EXCEPTION(_classname) \ + nb::register_exception_translator([](const std::exception_ptr &p, void*) { \ + try { \ + std::rethrow_exception(p); \ + } catch (const _classname &e) { \ + _openvdbmodule::translateException<_classname>(e); \ } \ }); @@ -383,83 +370,71 @@ PYBIND11_MODULE(PY_OPENVDB_MODULE_NAME, m) m.def("read", &_openvdbmodule::readFromFile, - "read(filename, gridname) -> Grid\n\n" "Read a single grid from a .vdb file.", - py::arg("filename"), py::arg("gridname")); + nb::arg("filename"), nb::arg("gridname")); #ifdef PY_OPENVDB_USE_AX m.def("ax", - py::overload_cast(&_openvdbmodule::axrun), - "ax(code, grids) -> Grid\n\n" + nb::overload_cast(&_openvdbmodule::axrun), "Run AX code on a VDB grid.", - py::arg("code"), py::arg("grid")); + nb::arg("code"), nb::arg("grid")); m.def("ax", - py::overload_cast(&_openvdbmodule::axrun), - "ax(code, grids) -> Grid\n\n" + nb::overload_cast(&_openvdbmodule::axrun), "Run AX code on some VDB grids.", - py::arg("code"), py::arg("grids")); + nb::arg("code"), nb::arg("grids")); #endif m.def("readAll", &_openvdbmodule::readAllFromFile, - "readAll(filename) -> list, dict\n\n" - "Read a .vdb file and return a list of grids and\n" + "Read a .vdb file and return a list of grids and " "a dict of file-level metadata.", - py::arg("filename")); + nb::arg("filename")); m.def("readMetadata", &_openvdbmodule::readFileMetadata, - "readMetadata(filename) -> dict\n\n" "Read file-level metadata from a .vdb file.", - py::arg("filename")); + nb::arg("filename")); m.def("readGridMetadata", &_openvdbmodule::readGridMetadataFromFile, - "readGridMetadata(filename, gridname) -> Grid\n\n" - "Read a single grid's metadata and transform (but not its tree)\n" + "Read a single grid's metadata and transform (but not its tree) " "from a .vdb file.", - py::arg("filename"), py::arg("gridname")); + nb::arg("filename"), nb::arg("gridname")); m.def("readAllGridMetadata", &_openvdbmodule::readAllGridMetadataFromFile, - "readAllGridMetadata(filename) -> list\n\n" - "Read a .vdb file and return a list of grids populated with\n" + "Read a .vdb file and return a list of grids populated with " "their metadata and transforms, but not their trees.", - py::arg("filename")); + nb::arg("filename")); m.def("write", - py::overload_cast(&_openvdbmodule::writeToFile), - "write(filename, grids, metadata=None)\n\n" - "Write a grid and (optionally) a dict\n" + nb::overload_cast(&_openvdbmodule::writeToFile), + "Write a grid and (optionally) a dict " "of (name, value) metadata pairs to a .vdb file.", - py::arg("filename"), py::arg("grid"), py::arg("metadata") = py::dict()); + nb::arg("filename"), nb::arg("grid"), nb::arg("metadata") = nb::dict()); m.def("write", - py::overload_cast(&_openvdbmodule::writeToFile), - "write(filename, grids, metadata=None)\n\n" - "Write a sequence of grids and (optionally) a dict\n" + nb::overload_cast(&_openvdbmodule::writeToFile), + "Write a sequence of grids and (optionally) a dict " "of (name, value) metadata pairs to a .vdb file.", - py::arg("filename"), py::arg("grids"), py::arg("metadata") = py::dict()); + nb::arg("filename"), nb::arg("grids"), nb::arg("metadata") = nb::dict()); m.def("getLoggingLevel", &_openvdbmodule::getLoggingLevel, - "getLoggingLevel() -> str\n\n" - "Return the severity threshold (\"debug\", \"info\", \"warn\", \"error\",\n" + "Return the severity threshold (\"debug\", \"info\", \"warn\", \"error\", " "or \"fatal\") for error messages."); m.def("setLoggingLevel", &_openvdbmodule::setLoggingLevel, - "setLoggingLevel(level)\n\n" - "Specify the severity threshold (\"debug\", \"info\", \"warn\", \"error\",\n" - "or \"fatal\") for error messages. Messages of lower severity\n" + "Specify the severity threshold (\"debug\", \"info\", \"warn\", \"error\", " + "or \"fatal\") for error messages. Messages of lower severity " "will be suppressed.", - py::arg("level")); + nb::arg("level")); m.def("setProgramName", &_openvdbmodule::setProgramName, - "setProgramName(name, color=True)\n\n" - "Specify the program name to be displayed in error messages,\n" + "Specify the program name to be displayed in error messages, " "and optionally specify whether to print error messages in color.", - py::arg("name"), py::arg("color") = true); + nb::arg("name"), nb::arg("color") = true); // Add some useful module-level constants. - m.attr("LIBRARY_VERSION") = py::make_tuple( + m.attr("LIBRARY_VERSION") = std::make_tuple( openvdb::OPENVDB_LIBRARY_MAJOR_VERSION, openvdb::OPENVDB_LIBRARY_MINOR_VERSION, openvdb::OPENVDB_LIBRARY_PATCH_VERSION); @@ -471,4 +446,4 @@ PYBIND11_MODULE(PY_OPENVDB_MODULE_NAME, m) pyutil::StringEnum<_openvdbmodule::GridClassDescr>::wrap(m); pyutil::StringEnum<_openvdbmodule::VecTypeDescr>::wrap(m); -} // PYBIND11_MODULE +} // NB_MODULE diff --git a/openvdb/openvdb/python/pyPointGrid.cc b/openvdb/openvdb/python/pyPointGrid.cc index d86da8647b..c842b5b189 100644 --- a/openvdb/openvdb/python/pyPointGrid.cc +++ b/openvdb/openvdb/python/pyPointGrid.cc @@ -1,25 +1,25 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file pyPointGrid.cc -/// @brief pybind11 wrappers for point openvdb::Grid types +/// @brief nanobind wrappers for point openvdb::Grid types -#include +#include #include "pyGrid.h" -namespace py = pybind11; +namespace nb = nanobind; #ifdef PY_OPENVDB_WRAP_ALL_GRID_TYPES void -exportPointGrid(py::module_ m) +exportPointGrid(nb::module_ m) { pyGrid::exportGrid(m); } #else void -exportPointGrid(py::module_) +exportPointGrid(nb::module_) { } #endif diff --git a/openvdb/openvdb/python/pyTransform.cc b/openvdb/openvdb/python/pyTransform.cc index b5116dfaef..524aed2361 100644 --- a/openvdb/openvdb/python/pyTransform.cc +++ b/openvdb/openvdb/python/pyTransform.cc @@ -1,27 +1,20 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 - -#include -#include -#include -#include +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include +#include +#include #include #include "pyTypeCasters.h" -namespace py = pybind11; +namespace nb = nanobind; using namespace openvdb::OPENVDB_VERSION_NAME; namespace pyTransform { -inline void scale1(math::Transform& t, double s) { t.preScale(s); } -inline void scale3(math::Transform& t, const Vec3d& xyz) { t.preScale(xyz); } - -inline Vec3d voxelDim0(math::Transform& t) { return t.voxelSize(); } -inline Vec3d voxelDim1(math::Transform& t, const Vec3d& p) { return t.voxelSize(p); } - -inline double voxelVolume0(math::Transform& t) { return t.voxelVolume(); } -inline double voxelVolume1(math::Transform& t, const Vec3d& p) { return t.voxelVolume(p); } - inline Vec3d indexToWorld(math::Transform& t, const Vec3d& p) { return t.indexToWorld(p); } inline Vec3d worldToIndex(math::Transform& t, const Vec3d& p) { return t.worldToIndex(p); } @@ -67,7 +60,7 @@ createLinearTransform(const std::vector >& sequence) } } if (!is4x4Seq) { - throw py::value_error("expected a 4 x 4 sequence of numeric values"); + throw nb::value_error("expected a 4 x 4 sequence of numeric values"); } return math::Transform::createLinearTransform(m); @@ -91,17 +84,18 @@ struct PickleSuite enum { STATE_MAJOR = 0, STATE_MINOR, STATE_FORMAT, STATE_XFORM }; /// Return a tuple representing the state of the given Transform. - static py::tuple getState(const math::Transform& xform) + static std::tuple getState(const math::Transform& xform) { std::ostringstream ostr(std::ios_base::binary); // Serialize the Transform to a string. xform.write(ostr); + nb::bytes bytesObj(ostr.str().c_str(), ostr.str().length()); + // Construct a state tuple comprising the version numbers of // the serialization format and the serialized Transform. // Convert the byte string to a "bytes" sequence. - py::bytes bytesObj(ostr.str()); - return py::make_tuple( + return std::make_tuple( uint32_t(OPENVDB_LIBRARY_MAJOR_VERSION), uint32_t(OPENVDB_LIBRARY_MINOR_VERSION), uint32_t(OPENVDB_FILE_VERSION), @@ -109,48 +103,23 @@ struct PickleSuite } /// Restore the given Transform to a saved state. - static math::Transform setState(py::tuple state) + static void setState(math::Transform& xform, const std::tuple& state) { - bool badState = (py::len(state) != 4); - openvdb::VersionId libVersion; uint32_t formatVersion = 0; - if (!badState) { - // Extract the serialization format version numbers. - const int idx[3] = { STATE_MAJOR, STATE_MINOR, STATE_FORMAT }; - uint32_t version[3] = { 0, 0, 0 }; - for (int i = 0; i < 3 && !badState; ++i) { - if (py::isinstance(state[idx[i]])) - version[i] = py::cast(state[idx[i]]); - else badState = true; - } - libVersion.first = version[0]; - libVersion.second = version[1]; - formatVersion = version[2]; - } - std::string serialized; - if (!badState) { - // Extract the sequence containing the serialized Transform. - py::object bytesObj = state[int(STATE_XFORM)]; - if (py::isinstance(bytesObj)) - serialized = py::cast(bytesObj); - else badState = true; - } + libVersion.first = std::get<0>(state); + libVersion.second = std::get<1>(state); + formatVersion = std::get<2>(state); - if (badState) { - std::ostringstream os; - os << "expected (int, int, int, bytes) tuple in call to __setstate__; found "; - os << py::cast(state.attr("__repr__")()); - throw py::value_error(os.str()); - } + nb::bytes bytesObj = std::get<3>(state); + std::string serialized(bytesObj.c_str(), bytesObj.c_str() + bytesObj.size()); // Restore the internal state of the C++ object. std::istringstream istr(serialized, std::ios_base::binary); io::setVersion(istr, libVersion, formatVersion); - math::Transform xform; + new (&xform) math::Transform; xform.read(istr); - return xform; } }; // struct PickleSuite @@ -158,102 +127,97 @@ struct PickleSuite void -exportTransform(py::module_ m) +exportTransform(nb::module_ m) { - py::enum_(m, "Axis") + nb::enum_(m, "Axis") .value("X", math::X_AXIS) .value("Y", math::Y_AXIS) .value("Z", math::Z_AXIS) .export_values(); - py::class_(m, "Transform") - .def(py::init<>()) + nb::class_(m, "Transform") + .def(nb::init<>()) .def("deepCopy", &math::Transform::copy, - "deepCopy() -> Transform\n\n" "Return a copy of this transform.") /// @todo Should this also be __str__()? .def("info", &pyTransform::info, - "info() -> str\n\n" - "Return a string containing a description of this transform.\n") + "Return a string containing a description of this transform.") - .def(py::pickle(&pyTransform::PickleSuite::getState, &pyTransform::PickleSuite::setState)) + .def("__getstate__", &pyTransform::PickleSuite::getState) + .def("__setstate__", &pyTransform::PickleSuite::setState) - .def_property_readonly("typeName", &math::Transform::mapType, + .def_prop_ro("typeName", &math::Transform::mapType, "name of this transform's type") - .def_property_readonly("isLinear", &math::Transform::isLinear, + .def_prop_ro("isLinear", &math::Transform::isLinear, "True if this transform is linear") - .def("rotate", &math::Transform::preRotate, - py::arg("radians"), py::arg("axis") = math::X_AXIS, - "rotate(radians, axis)\n\n" - "Accumulate a rotation about either Axis.X, Axis.Y or Axis.Z.") - .def("translate", &math::Transform::postTranslate, py::arg("xyz"), - "translate((x, y, z))\n\n" - "Accumulate a translation.") - .def("scale", &pyTransform::scale1, py::arg("s"), - "scale(s)\n\n" - "Accumulate a uniform scale.") - .def("scale", &pyTransform::scale3, py::arg("sxyz"), - "scale((sx, sy, sz))\n\n" - "Accumulate a nonuniform scale.") - .def("shear", &math::Transform::preShear, - py::arg("s"), py::arg("axis0"), py::arg("axis1"), - "shear(s, axis0, axis1)\n\n" - "Accumulate a shear (axis0 and axis1 are either\n" - "Axis.X, Axis.Y or Axis.Z).") - - .def("voxelSize", &pyTransform::voxelDim0, - "voxelSize() -> (dx, dy, dz)\n\n" + .def("preRotate", &math::Transform::preRotate, + nb::arg("radians"), nb::arg("axis") = math::X_AXIS, + "Prepend a rotation about either Axis.X, Axis.Y or Axis.Z.") + .def("preTranslate", &math::Transform::preTranslate, nb::arg("xyz"), + "Prepend a translation.") + .def("preScale", nb::overload_cast(&math::Transform::preScale), nb::arg("s"), + "Prepend a uniform scale.") + .def("preScale", nb::overload_cast(&math::Transform::preScale), nb::arg("sxyz"), + "Prepend a nonuniform scale.") + .def("preShear", &math::Transform::preShear, + nb::arg("s"), nb::arg("axis0"), nb::arg("axis1"), + "Prepend a shear (axis0 and axis1 are either Axis.X, Axis.Y or Axis.Z).") + + .def("postRotate", &math::Transform::postRotate, + nb::arg("radians"), nb::arg("axis") = math::X_AXIS, + "Postfix a rotation about either Axis.X, Axis.Y or Axis.Z.") + .def("postTranslate", &math::Transform::postTranslate, nb::arg("xyz"), + "Postfix a translation.") + .def("postScale", nb::overload_cast(&math::Transform::postScale), nb::arg("s"), + "Postfix a uniform scale.") + .def("postScale", nb::overload_cast(&math::Transform::postScale), nb::arg("sxyz"), + "Postfix a nonuniform scale.") + .def("postShear", &math::Transform::postShear, + nb::arg("s"), nb::arg("axis0"), nb::arg("axis1"), + "Postfix a shear (axis0 and axis1 are either Axis.X, Axis.Y or Axis.Z).") + + .def("voxelSize", nb::overload_cast<>(&math::Transform::voxelSize, nb::const_), "Return the size of voxels of the linear component of this transform.") - .def("voxelSize", &pyTransform::voxelDim1, py::arg("xyz"), - "voxelSize((x, y, z)) -> (dx, dy, dz)\n\n" + .def("voxelSize", nb::overload_cast(&math::Transform::voxelSize, nb::const_), nb::arg("xyz"), "Return the size of the voxel at position (x, y, z).") - .def("voxelVolume", &pyTransform::voxelVolume0, - "voxelVolume() -> float\n\n" + .def("voxelVolume", nb::overload_cast<>(&math::Transform::voxelVolume, nb::const_), "Return the voxel volume of the linear component of this transform.") - .def("voxelVolume", &pyTransform::voxelVolume1, py::arg("xyz"), - "voxelVolume((x, y, z)) -> float\n\n" + .def("voxelVolume", nb::overload_cast(&math::Transform::voxelVolume, nb::const_), nb::arg("xyz"), "Return the voxel volume at position (x, y, z).") - .def("indexToWorld", &pyTransform::indexToWorld, py::arg("xyz"), - "indexToWorld((x, y, z)) -> (x', y', z')\n\n" + .def("indexToWorld", &pyTransform::indexToWorld, nb::arg("xyz"), "Apply this transformation to the given coordinates.") - .def("worldToIndex", &pyTransform::worldToIndex, py::arg("xyz"), - "worldToIndex((x, y, z)) -> (x', y', z')\n\n" + .def("worldToIndex", &pyTransform::worldToIndex, nb::arg("xyz"), "Apply the inverse of this transformation to the given coordinates.") .def("worldToIndexCellCentered", &pyTransform::worldToIndexCellCentered, - py::arg("xyz"), - "worldToIndexCellCentered((x, y, z)) -> (i, j, k)\n\n" + nb::arg("xyz"), "Apply the inverse of this transformation to the given coordinates\n" "and round the result to the nearest integer coordinates.") .def("worldToIndexNodeCentered", &pyTransform::worldToIndexNodeCentered, - py::arg("xyz"), - "worldToIndexNodeCentered((x, y, z)) -> (i, j, k)\n\n" + nb::arg("xyz"), "Apply the inverse of this transformation to the given coordinates\n" "and round the result down to the nearest integer coordinates.") // Allow Transforms to be compared for equality and inequality. - .def(py::self == py::self) - .def(py::self != py::self); + .def(nb::self == nb::self) + .def(nb::self != nb::self); - m.def("createLinearTransform", py::overload_cast(&pyTransform::createLinearTransform), - py::arg("voxelSize") = 1.0, - "createLinearTransform(voxelSize) -> Transform\n\n" + m.def("createLinearTransform", nb::overload_cast(&pyTransform::createLinearTransform), + nb::arg("voxelSize") = 1.0, "Create a new linear transform with the given uniform voxel size."); - m.def("createLinearTransform", py::overload_cast >&>(&pyTransform::createLinearTransform), py::arg("matrix"), - "createLinearTransform(matrix) -> Transform\n\n" + m.def("createLinearTransform", nb::overload_cast >&>(&pyTransform::createLinearTransform), nb::arg("matrix"), "Create a new linear transform from a 4 x 4 matrix given as a sequence\n" "of the form [[a, b, c, d], [e, f, g, h], [i, j, k, l], [m, n, o, p]],\n" "where [m, n, o, p] is the translation component."); m.def("createFrustumTransform", &pyTransform::createFrustum, - py::arg("xyzMin"), py::arg("xyzMax"), - py::arg("taper"), py::arg("depth"), py::arg("voxelSize") = 1.0, - "createFrustumTransform(xyzMin, xyzMax, taper, depth, voxelSize) -> Transform\n\n" + nb::arg("xyzMin"), nb::arg("xyzMax"), + nb::arg("taper"), nb::arg("depth"), nb::arg("voxelSize") = 1.0, "Create a new frustum transform with unit bounding box (xyzMin, xyzMax)\n" "and the given taper, depth and uniform voxel size."); } diff --git a/openvdb/openvdb/python/pyTypeCasters.h b/openvdb/openvdb/python/pyTypeCasters.h index b30af05c6a..c9faf3f0bd 100644 --- a/openvdb/openvdb/python/pyTypeCasters.h +++ b/openvdb/openvdb/python/pyTypeCasters.h @@ -1,29 +1,30 @@ #ifndef OPENVDB_PYTYPECASTERS_HAS_BEEN_INCLUDED #define OPENVDB_PYTYPECASTERS_HAS_BEEN_INCLUDED -#include +#include +#include #include #include // Custom type casters must be defined consistently in EVERY translation unit of -// pybind11 code. Thus, we define them in this header file and include it in every +// nanobind code. Thus, we define them in this header file and include it in every // implementation file. -namespace py = pybind11; +namespace nb = nanobind; -namespace pybind11 { namespace detail { +namespace nanobind { namespace detail { template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Coord, const_name("openvdb::Coord")); + NB_TYPE_CASTER(openvdb::Coord, const_name("openvdb::Coord")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; Py_ssize_t length = PySequence_Length(source); if (length == 1) { - openvdb::Coord::Int32 items[1]; + openvdb::Coord::Int32 items[1] = { 0 }; // init required to workaround gcc warning for (Py_ssize_t i = 0; i < length; ++i) { PyObject* item = PySequence_GetItem(source, i); if (item) { @@ -43,7 +44,7 @@ namespace pybind11 { namespace detail { } else if (length == 3) { - openvdb::Coord::Int32 items[3]; + openvdb::Coord::Int32 items[3] = { 0, 0, 0 }; // init required to workaround gcc warning for (Py_ssize_t i = 0; i < length; ++i) { PyObject* item = PySequence_GetItem(source, i); if (item) { @@ -67,17 +68,17 @@ namespace pybind11 { namespace detail { } } - static handle cast(openvdb::Coord src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1], src[2]); + static handle from_cpp(openvdb::Coord src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1], src[2]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec2i, const_name("openvdb::Vec2i")); + NB_TYPE_CASTER(openvdb::Vec2i, const_name("openvdb::Vec2i")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -103,17 +104,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Vec2i src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1]); + static handle from_cpp(openvdb::Vec2i src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec2I, const_name("openvdb::Vec2I")); + NB_TYPE_CASTER(openvdb::Vec2I, const_name("openvdb::Vec2I")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -139,17 +140,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Vec2I src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1]); + static handle from_cpp(openvdb::Vec2I src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec2s, const_name("openvdb::Vec2s")); + NB_TYPE_CASTER(openvdb::Vec2s, const_name("openvdb::Vec2s")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -175,17 +176,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Vec2s src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1]); + static handle from_cpp(openvdb::Vec2s src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec2d, const_name("openvdb::Vec2d")); + NB_TYPE_CASTER(openvdb::Vec2d, const_name("openvdb::Vec2d")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -211,17 +212,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Vec2d src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1]); + static handle from_cpp(openvdb::Vec2d src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec3i, const_name("openvdb::Vec3i")); + NB_TYPE_CASTER(openvdb::Vec3i, const_name("openvdb::Vec3i")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -247,17 +248,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Vec3i src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1], src[2]); + static handle from_cpp(openvdb::Vec3i src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1], src[2]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec3I, const_name("openvdb::Vec3I")); + NB_TYPE_CASTER(openvdb::Vec3I, const_name("openvdb::Vec3I")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -283,17 +284,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Vec3I src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1], src[2]); + static handle from_cpp(openvdb::Vec3I src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1], src[2]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec3s, const_name("openvdb::Vec3s")); + NB_TYPE_CASTER(openvdb::Vec3s, const_name("openvdb::Vec3s")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -319,17 +320,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Vec3s src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1], src[2]); + static handle from_cpp(openvdb::Vec3s src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1], src[2]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec3d, const_name("openvdb::Vec3d")); + NB_TYPE_CASTER(openvdb::Vec3d, const_name("openvdb::Vec3d")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -355,17 +356,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Vec3d src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1], src[2]); + static handle from_cpp(openvdb::Vec3d src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1], src[2]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec4i, const_name("openvdb::Vec4i")); + NB_TYPE_CASTER(openvdb::Vec4i, const_name("openvdb::Vec4i")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -391,17 +392,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Vec4i src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1], src[2], src[3]); + static handle from_cpp(openvdb::Vec4i src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1], src[2], src[3]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec4I, const_name("openvdb::Vec4I")); + NB_TYPE_CASTER(openvdb::Vec4I, const_name("openvdb::Vec4I")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -427,17 +428,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Vec4I src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1], src[2], src[3]); + static handle from_cpp(openvdb::Vec4I src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1], src[2], src[3]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec4s, const_name("openvdb::Vec4s")); + NB_TYPE_CASTER(openvdb::Vec4s, const_name("openvdb::Vec4s")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -463,17 +464,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Vec4s src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1], src[2], src[3]); + static handle from_cpp(openvdb::Vec4s src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1], src[2], src[3]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec4d, const_name("openvdb::Vec4d")); + NB_TYPE_CASTER(openvdb::Vec4d, const_name("openvdb::Vec4d")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -499,17 +500,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Vec4d src, return_value_policy, handle) { - py::tuple tuple = py::make_tuple(src[0], src[1], src[2], src[3]); + static handle from_cpp(openvdb::Vec4d src, rv_policy, cleanup_list*) noexcept { + nb::tuple tuple = nb::make_tuple(src[0], src[1], src[2], src[3]); return tuple.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Mat4s, const_name("openvdb::Mat4s")); + NB_TYPE_CASTER(openvdb::Mat4s, const_name("openvdb::Mat4s")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -552,10 +553,10 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Mat4s src, return_value_policy, handle) { - py::list list; + static handle from_cpp(openvdb::Mat4s src, rv_policy, cleanup_list*) noexcept { + nb::list list; for (int i = 0; i < 4; ++i) { - py::list sublist; + nb::list sublist; for (int j = 0; j < 4; ++j) { sublist.append(src(i, j)); } @@ -567,9 +568,9 @@ namespace pybind11 { namespace detail { template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Mat4d, const_name("openvdb::Mat4d")); + NB_TYPE_CASTER(openvdb::Mat4d, const_name("openvdb::Mat4d")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); if (!PySequence_Check(source)) return false; @@ -612,10 +613,10 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::Mat4d src, return_value_policy, handle) { - py::list list; + static handle from_cpp(openvdb::Mat4d src, rv_policy, cleanup_list*) noexcept { + nb::list list; for (int i = 0; i < 4; ++i) { - py::list sublist; + nb::list sublist; for (int j = 0; j < 4; ++j) { sublist.append(src(i, j)); } @@ -627,9 +628,9 @@ namespace pybind11 { namespace detail { template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::PointIndex32, const_name("openvdb::PointIndex32")); + NB_TYPE_CASTER(openvdb::PointIndex32, const_name("openvdb::PointIndex32")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); PyObject* number = PyNumber_Long(source); if (number) { @@ -643,17 +644,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::PointIndex32 src, return_value_policy, handle) { - py::int_ integer(static_cast(src)); + static handle from_cpp(openvdb::PointIndex32 src, rv_policy, cleanup_list*) noexcept { + nb::int_ integer(static_cast(src)); return integer.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::PointIndex64, const_name("openvdb::PointIndex64")); + NB_TYPE_CASTER(openvdb::PointIndex64, const_name("openvdb::PointIndex64")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); PyObject* number = PyNumber_Long(source); if (number) { @@ -667,17 +668,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::PointIndex64 src, return_value_policy, handle) { - py::int_ integer(static_cast(src)); + static handle from_cpp(openvdb::PointIndex64 src, rv_policy, cleanup_list*) noexcept { + nb::int_ integer(static_cast(src)); return integer.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::PointDataIndex32, const_name("openvdb::PointDataIndex32")); + NB_TYPE_CASTER(openvdb::PointDataIndex32, const_name("openvdb::PointDataIndex32")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); PyObject* number = PyNumber_Long(source); if (number) { @@ -691,17 +692,17 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::PointDataIndex32 src, return_value_policy, handle) { - py::int_ integer(static_cast(src)); + static handle from_cpp(openvdb::PointDataIndex32 src, rv_policy, cleanup_list*) noexcept { + nb::int_ integer(static_cast(src)); return integer.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::PointDataIndex64, const_name("openvdb::PointDataIndex64")); + NB_TYPE_CASTER(openvdb::PointDataIndex64, const_name("openvdb::PointDataIndex64")) - bool load(handle src, bool) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { PyObject* source = src.ptr(); PyObject* number = PyNumber_Long(source); if (number) { @@ -715,308 +716,308 @@ namespace pybind11 { namespace detail { return true; } - static handle cast(openvdb::PointDataIndex64 src, return_value_policy, handle) { - py::int_ integer(static_cast(src)); + static handle from_cpp(openvdb::PointDataIndex64 src, rv_policy, cleanup_list*) noexcept { + nb::int_ integer(static_cast(src)); return integer.release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::StringMetadata, _("openvdb::StringMetadata")); + NB_TYPE_CASTER(openvdb::StringMetadata, const_name("openvdb::StringMetadata")) - bool load(handle src, bool) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { + if (!nb::isinstance(src)) { return false; } - value.setValue(py::cast(src)); + value.setValue(nb::cast(src)); return true; } - static handle cast(openvdb::StringMetadata src, return_value_policy, handle) { - return py::str(src.value()).release(); + static handle from_cpp(openvdb::StringMetadata src, rv_policy, cleanup_list*) noexcept { + return nb::str(src.value().c_str()).release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::BoolMetadata, _("openvdb::BoolMetadata")); + NB_TYPE_CASTER(openvdb::BoolMetadata, const_name("openvdb::BoolMetadata")) - bool load(handle src, bool) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { + if (!nb::isinstance(src)) { return false; } - value.setValue(py::cast(src)); + value.setValue(nb::cast(src)); return true; } - static handle cast(openvdb::BoolMetadata src, return_value_policy, handle) { - return py::bool_(src.value()).release(); + static handle from_cpp(openvdb::BoolMetadata src, rv_policy, cleanup_list*) noexcept { + return nb::bool_(src.value()).release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Int32Metadata, _("openvdb::Int32Metadata")); + NB_TYPE_CASTER(openvdb::Int32Metadata, const_name("openvdb::Int32Metadata")) - bool load(handle src, bool) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { + if (!nb::isinstance(src)) { return false; } - value.setValue(py::cast(src)); + value.setValue(nb::cast(src)); return true; } - static handle cast(openvdb::Int32Metadata src, return_value_policy, handle) { - return py::int_(src.value()).release(); + static handle from_cpp(openvdb::Int32Metadata src, rv_policy, cleanup_list*) noexcept { + return nb::int_(src.value()).release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Int64Metadata, _("openvdb::Int64Metadata")); + NB_TYPE_CASTER(openvdb::Int64Metadata, const_name("openvdb::Int64Metadata")) - bool load(handle src, bool) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { + if (!nb::isinstance(src)) { return false; } - value.setValue(py::cast(src)); + value.setValue(nb::cast(src)); return true; } - static handle cast(openvdb::Int64Metadata src, return_value_policy, handle) { - return py::int_(src.value()).release(); + static handle from_cpp(openvdb::Int64Metadata src, rv_policy, cleanup_list*) noexcept { + return nb::int_(src.value()).release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::FloatMetadata, _("openvdb::FloatMetadata")); + NB_TYPE_CASTER(openvdb::FloatMetadata, const_name("openvdb::FloatMetadata")) - bool load(handle src, bool) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { + if (!nb::isinstance(src)) { return false; } - value.setValue(py::cast(src)); + value.setValue(nb::cast(src)); return true; } - static handle cast(openvdb::FloatMetadata src, return_value_policy, handle) { - return py::float_(src.value()).release(); + static handle from_cpp(openvdb::FloatMetadata src, rv_policy, cleanup_list*) noexcept { + return nb::float_(src.value()).release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::DoubleMetadata, _("openvdb::DoubleMetadata")); + NB_TYPE_CASTER(openvdb::DoubleMetadata, const_name("openvdb::DoubleMetadata")) - bool load(handle src, bool) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t, cleanup_list*) noexcept { + if (!nb::isinstance(src)) { return false; } - value.setValue(py::cast(src)); + value.setValue(nb::cast(src)); return true; } - static handle cast(openvdb::DoubleMetadata src, return_value_policy, handle) { - return py::float_(src.value()).release(); + static handle from_cpp(openvdb::DoubleMetadata src, rv_policy, cleanup_list*) noexcept { + return nb::float_(src.value()).release(); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec2IMetadata, _("openvdb::Vec2IMetadata")); + NB_TYPE_CASTER(openvdb::Vec2IMetadata, const_name("openvdb::Vec2IMetadata")) - bool load(handle src, bool convert) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t flags, cleanup_list* cleanup) { + if (!nb::isinstance(src)) { return false; } - make_caster conv; - if (!conv.load(src, convert)) + make_caster caster; + if (!caster.from_python(src, flags, cleanup)) return false; - value.setValue(cast_op(std::move(conv))); + value.setValue(caster.operator cast_t()); return true; } - static handle cast(openvdb::Vec2IMetadata src, return_value_policy policy, handle parent) { - return make_caster::cast(src.value(), policy, parent); + static handle from_cpp(openvdb::Vec2IMetadata src, rv_policy policy, cleanup_list* cleanup) { + return make_caster::from_cpp(src.value(), policy, cleanup); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec3IMetadata, _("openvdb::Vec3IMetadata")); + NB_TYPE_CASTER(openvdb::Vec3IMetadata, const_name("openvdb::Vec3IMetadata")) - bool load(handle src, bool convert) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t flags, cleanup_list* cleanup) { + if (!nb::isinstance(src)) { return false; } - make_caster conv; - if (!conv.load(src, convert)) + make_caster caster; + if (!caster.from_python(src, flags, cleanup)) return false; - value.setValue(cast_op(std::move(conv))); + value.setValue(caster.operator cast_t()); return true; } - static handle cast(openvdb::Vec3IMetadata src, return_value_policy policy, handle parent) { - return make_caster::cast(src.value(), policy, parent); + static handle from_cpp(openvdb::Vec3IMetadata src, rv_policy policy, cleanup_list* cleanup) { + return make_caster::from_cpp(src.value(), policy, cleanup); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec4IMetadata, _("openvdb::Vec4IMetadata")); + NB_TYPE_CASTER(openvdb::Vec4IMetadata, const_name("openvdb::Vec4IMetadata")) - bool load(handle src, bool convert) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t flags, cleanup_list* cleanup) { + if (!nb::isinstance(src)) { return false; } - make_caster conv; - if (!conv.load(src, convert)) + make_caster caster; + if (!caster.from_python(src, flags, cleanup)) return false; - value.setValue(cast_op(std::move(conv))); + value.setValue(caster.operator cast_t()); return true; } - static handle cast(openvdb::Vec4IMetadata src, return_value_policy policy, handle parent) { - return make_caster::cast(src.value(), policy, parent); + static handle from_cpp(openvdb::Vec4IMetadata src, rv_policy policy, cleanup_list* cleanup) { + return make_caster::from_cpp(src.value(), policy, cleanup); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec2DMetadata, _("openvdb::Vec2DMetadata")); + NB_TYPE_CASTER(openvdb::Vec2DMetadata, const_name("openvdb::Vec2DMetadata")) - bool load(handle src, bool convert) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t flags, cleanup_list* cleanup) { + if (!nb::isinstance(src)) { return false; } - make_caster conv; - if (!conv.load(src, convert)) + make_caster caster; + if (!caster.from_python(src, flags, cleanup)) return false; - value.setValue(cast_op(std::move(conv))); + value.setValue(caster.operator cast_t()); return true; } - static handle cast(openvdb::Vec2DMetadata src, return_value_policy policy, handle parent) { - return make_caster::cast(src.value(), policy, parent); + static handle from_cpp(openvdb::Vec2DMetadata src, rv_policy policy, cleanup_list* cleanup) { + return make_caster::from_cpp(src.value(), policy, cleanup); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec3DMetadata, _("openvdb::Vec3DMetadata")); + NB_TYPE_CASTER(openvdb::Vec3DMetadata, const_name("openvdb::Vec3DMetadata")) - bool load(handle src, bool convert) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t flags, cleanup_list* cleanup) { + if (!nb::isinstance(src)) { return false; } - make_caster conv; - if (!conv.load(src, convert)) + make_caster caster; + if (!caster.from_python(src, flags, cleanup)) return false; - value.setValue(cast_op(std::move(conv))); + value.setValue(caster.operator cast_t()); return true; } - static handle cast(openvdb::Vec3DMetadata src, return_value_policy policy, handle parent) { - return make_caster::cast(src.value(), policy, parent); + static handle from_cpp(openvdb::Vec3DMetadata src, rv_policy policy, cleanup_list* cleanup) { + return make_caster::from_cpp(src.value(), policy, cleanup); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Vec4DMetadata, _("openvdb::Vec4DMetadata")); + NB_TYPE_CASTER(openvdb::Vec4DMetadata, const_name("openvdb::Vec4DMetadata")) - bool load(handle src, bool convert) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t flags, cleanup_list* cleanup) { + if (!nb::isinstance(src)) { return false; } - make_caster conv; - if (!conv.load(src, convert)) + make_caster caster; + if (!caster.from_python(src, flags, cleanup)) return false; - value.setValue(cast_op(std::move(conv))); + value.setValue(caster.operator cast_t()); return true; } - static handle cast(openvdb::Vec4DMetadata src, return_value_policy policy, handle parent) { - return make_caster::cast(src.value(), policy, parent); + static handle from_cpp(openvdb::Vec4DMetadata src, rv_policy policy, cleanup_list* cleanup) { + return make_caster::from_cpp(src.value(), policy, cleanup); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Mat4SMetadata, _("openvdb::Mat4SMetadata")); + NB_TYPE_CASTER(openvdb::Mat4SMetadata, const_name("openvdb::Mat4SMetadata")) - bool load(handle src, bool convert) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t flags, cleanup_list* cleanup) { + if (!nb::isinstance(src)) { return false; } - make_caster conv; - if (!conv.load(src, convert)) + make_caster caster; + if (!caster.from_python(src, flags, cleanup)) return false; - value.setValue(cast_op(std::move(conv))); + value.setValue(caster.operator cast_t()); return true; } - static handle cast(openvdb::Mat4SMetadata src, return_value_policy policy, handle parent) { - return make_caster::cast(src.value(), policy, parent); + static handle from_cpp(openvdb::Mat4SMetadata src, rv_policy policy, cleanup_list* cleanup) { + return make_caster::from_cpp(src.value(), policy, cleanup); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::Mat4DMetadata, _("openvdb::Mat4DMetadata")); + NB_TYPE_CASTER(openvdb::Mat4DMetadata, const_name("openvdb::Mat4DMetadata")) - bool load(handle src, bool convert) { - if (!py::isinstance(src)) { + bool from_python(handle src, uint8_t flags, cleanup_list* cleanup) { + if (!nb::isinstance(src)) { return false; } - make_caster conv; - if (!conv.load(src, convert)) + make_caster caster; + if (!caster.from_python(src, flags, cleanup)) return false; - value.setValue(cast_op(std::move(conv))); + value.setValue(caster.operator cast_t()); return true; } - static handle cast(openvdb::Mat4DMetadata src, return_value_policy policy, handle parent) { - return make_caster::cast(src.value(), policy, parent); + static handle from_cpp(openvdb::Mat4DMetadata src, rv_policy policy, cleanup_list* cleanup) { + return make_caster::from_cpp(src.value(), policy, cleanup); } }; template <> struct type_caster { public: - PYBIND11_TYPE_CASTER(openvdb::MetaMap, _("openvdb::MetaMap")); + NB_TYPE_CASTER(openvdb::MetaMap, const_name("openvdb::MetaMap")) - bool load(handle src, bool convert) { - py::dict dictionary = py::reinterpret_borrow(src); + bool from_python(handle src, uint8_t flags, cleanup_list* cleanup) { + nb::dict dictionary = nb::borrow(src); for (auto [key, val] : dictionary) { std::string name; - if (py::isinstance(key)) { - name = py::cast(key); + if (nb::isinstance(key)) { + name = nb::cast(key); } else { - throw py::type_error("Expected string as metadata name"); + throw nb::type_error("Expected string as metadata name"); } // Note: the order of the following tests is significant, as it @@ -1025,69 +1026,69 @@ namespace pybind11 { namespace detail { // all floating point metadata is promoted to doubles. bool success = false; - if (py::isinstance(val)) { - make_caster conv; - if(conv.load(val, convert)) { - value.insertMeta(name, cast_op(std::move(conv))); + if (nb::isinstance(val)) { + make_caster caster; + if(caster.from_python(val, flags, cleanup)) { + value.insertMeta(name, caster.operator cast_t()); success = true; } - } else if (py::isinstance(val)) { - make_caster conv; - if(conv.load(val, convert)) { - value.insertMeta(name, cast_op(std::move(conv))); + } else if (nb::isinstance(val)) { + make_caster caster; + if(caster.from_python(val, flags, cleanup)) { + value.insertMeta(name, caster.operator cast_t()); success = true; } - } else if (py::isinstance(val)) { - const openvdb::Int64 n = py::cast(val); + } else if (nb::isinstance(val)) { + const openvdb::Int64 n = nb::cast(val); if (n <= std::numeric_limits::max() && n >= std::numeric_limits::min()) { - make_caster conv; - if(conv.load(val, convert)) { - value.insertMeta(name, cast_op(std::move(conv))); + make_caster caster; + if(caster.from_python(val, flags, cleanup)) { + value.insertMeta(name, caster.operator cast_t()); success = true; } } else { - make_caster conv; - if(conv.load(val, convert)) { - value.insertMeta(name, cast_op(std::move(conv))); + make_caster caster; + if(caster.from_python(val, flags, cleanup)) { + value.insertMeta(name, caster.operator cast_t()); success = true; } } - } else if (py::isinstance(val)) { - make_caster conv; - if(conv.load(val, convert)) { - value.insertMeta(name, cast_op(std::move(conv))); + } else if (nb::isinstance(val)) { + make_caster caster; + if(caster.from_python(val, flags, cleanup)) { + value.insertMeta(name, caster.operator cast_t()); success = true; } - } else if (py::isinstance(val)) { - py::tuple t = py::cast(val); + } else if (nb::isinstance(val)) { + nb::tuple t = nb::cast(val); size_t size = t.size(); bool isIntegerTuple = true; for (size_t i = 0; i < size; ++i) { - isIntegerTuple &= py::isinstance(t[i]); + isIntegerTuple &= nb::isinstance(t[i]); } if (isIntegerTuple) { switch(size) { case 2: { - make_caster conv; - if (conv.load(val, convert)) { - value.insertMeta(name, cast_op(std::move(conv))); + make_caster caster; + if (caster.from_python(val, flags, cleanup)) { + value.insertMeta(name, caster.operator cast_t()); success = true; } break; } case 3: { - make_caster conv; - if (conv.load(val, convert)) { - value.insertMeta(name, cast_op(std::move(conv))); + make_caster caster; + if (caster.from_python(val, flags, cleanup)) { + value.insertMeta(name, caster.operator cast_t()); success = true; } break; } case 4: { - make_caster conv; - if (conv.load(val, convert)) { - value.insertMeta(name, cast_op(std::move(conv))); + make_caster caster; + if (caster.from_python(val, flags, cleanup)) { + value.insertMeta(name, caster.operator cast_t()); success = true; } break; @@ -1098,25 +1099,25 @@ namespace pybind11 { namespace detail { } else { switch(size) { case 2: { - make_caster conv; - if (conv.load(val, convert)) { - value.insertMeta(name, cast_op(std::move(conv))); + make_caster caster; + if (caster.from_python(val, flags, cleanup)) { + value.insertMeta(name, caster.operator cast_t()); success = true; } break; } case 3: { - make_caster conv; - if (conv.load(val, convert)) { - value.insertMeta(name, cast_op(std::move(conv))); + make_caster caster; + if (caster.from_python(val, flags, cleanup)) { + value.insertMeta(name, caster.operator cast_t()); success = true; } break; } case 4: { - make_caster conv; - if (conv.load(val, convert)) { - value.insertMeta(name, cast_op(std::move(conv))); + make_caster caster; + if (caster.from_python(val, flags, cleanup)) { + value.insertMeta(name, caster.operator cast_t()); success = true; } break; @@ -1125,14 +1126,14 @@ namespace pybind11 { namespace detail { break; } } - } else if (py::isinstance(val)) { - make_caster conv; - if (conv.load(val, convert)) { - value.insertMeta(name, cast_op(std::move(conv))); + } else if (nb::isinstance(val)) { + make_caster caster; + if (caster.from_python(val, flags, cleanup)) { + value.insertMeta(name, caster.operator cast_t()); success = true; } - } else if (py::isinstance(val)) { - openvdb::Metadata::Ptr metadata = py::cast(val); + } else if (nb::isinstance(val)) { + openvdb::Metadata::Ptr metadata = nb::cast(val); if (metadata) { value.insertMeta(name, *metadata); } @@ -1140,57 +1141,57 @@ namespace pybind11 { namespace detail { } if (!success) { - const std::string valAsStr = py::cast(val.attr("__str__")()); - const std::string valType = py::cast(val.attr("__class__").attr("__name__")); - throw py::type_error(std::string("metadata value " + valAsStr + " of type " + valType + " is not allowed")); + const std::string valAsStr = nb::cast(val.attr("__str__")()); + const std::string valType = nb::cast(val.attr("__class__").attr("__name__")); + throw nb::type_error(std::string("metadata value " + valAsStr + " of type " + valType + " is not allowed").c_str()); } } return true; } - static handle cast(openvdb::MetaMap src, return_value_policy policy, handle parent) { - py::dict dict; + static handle from_cpp(openvdb::MetaMap src, rv_policy policy, cleanup_list* cleanup) { + nb::dict dict; for (openvdb::MetaMap::ConstMetaIterator it = src.beginMeta(); it != src.endMeta(); ++it) { if (openvdb::Metadata::Ptr meta = it->second) { - py::object obj(py::cast(meta)); + nb::object obj(nb::cast(meta)); const std::string typeName = meta->typeName(); if (typeName == openvdb::StringMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::DoubleMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::FloatMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Int32Metadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Int64Metadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::BoolMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Vec2DMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Vec2IMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Vec2SMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Vec3DMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Vec3IMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Vec3SMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Vec4DMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Vec4IMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Vec4SMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Mat4SMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } else if (typeName == openvdb::Mat4DMetadata::staticTypeName()) { - obj = reinterpret_steal(make_caster::cast(static_cast(*meta), policy, parent)); + obj = steal(make_caster::from_cpp(static_cast(*meta), policy, cleanup)); } - dict[py::str(it->first)] = obj; + dict[nb::str(it->first.c_str())] = obj; } } return dict.release(); diff --git a/openvdb/openvdb/python/pyVec3Grid.cc b/openvdb/openvdb/python/pyVec3Grid.cc index bd581af916..d16bca2b17 100644 --- a/openvdb/openvdb/python/pyVec3Grid.cc +++ b/openvdb/openvdb/python/pyVec3Grid.cc @@ -1,17 +1,17 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file pyVec3Grid.cc -/// @brief pybind11 wrappers for vector-valued openvdb::Grid types +/// @brief nanobind wrappers for vector-valued openvdb::Grid types #include "pyGrid.h" void -exportVec3Grid(py::module_ m) +exportVec3Grid(nb::module_ m) { - pyGrid::exportGrid(m); + pyGrid::exportVectorGrid(m); #ifdef PY_OPENVDB_WRAP_ALL_GRID_TYPES - pyGrid::exportGrid(m); - pyGrid::exportGrid(m); + pyGrid::exportVectorGrid(m); + pyGrid::exportVectorGrid(m); #endif } diff --git a/openvdb/openvdb/python/pyutil.h b/openvdb/openvdb/python/pyutil.h index 1727e0aace..0334fab2b6 100644 --- a/openvdb/openvdb/python/pyutil.h +++ b/openvdb/openvdb/python/pyutil.h @@ -1,18 +1,18 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_PYUTIL_HAS_BEEN_INCLUDED #define OPENVDB_PYUTIL_HAS_BEEN_INCLUDED #include #include -#include +#include #include #include #include #include // for std::pair -namespace py = pybind11; +namespace nb = nanobind; namespace pyutil { @@ -73,7 +73,7 @@ GRID_TRAITS(openvdb::points::PointDataGrid, "PointDataGrid"); // Note that the elements are pointers to C strings (char**), because -// py::class_::def_readonly() requires a pointer to a static member. +// nb::class_::def_ro() requires a pointer to a static member. typedef std::pair CStringPair; @@ -103,10 +103,10 @@ template struct StringEnum { /// Return the (key, value) map as a Python dict. - static py::dict items() + static nb::dict items() { static std::mutex sMutex; - static py::dict itemDict; + static nb::dict itemDict; if (!itemDict) { // The first time this function is called, populate // the static dict with (key, value) pairs. @@ -116,8 +116,8 @@ struct StringEnum const CStringPair item = Descr::item(i); OPENVDB_START_THREADSAFE_STATIC_WRITE if (item.first) { - itemDict[py::str(*item.first)] = - py::str(*item.second); + itemDict[nb::str(*item.first)] = + nb::str(*item.second); } OPENVDB_FINISH_THREADSAFE_STATIC_WRITE else break; @@ -128,33 +128,33 @@ struct StringEnum } /// Return the keys as a Python list of strings. - static py::object keys() { return items().attr("keys")(); } + static nb::object keys() { return items().attr("keys")(); } /// Return the number of keys as a Python int. - py::int_ numItems() const + nb::int_ numItems() const { - return py::int_(py::len(items())); + return nb::int_(nb::len(items())); } /// Return the value (as a Python string) for the given key. - py::object getItem(py::object keyObj) const { return items()[keyObj]; } + nb::object getItem(nb::object keyObj) const { return items()[keyObj]; } /// Return a Python iterator over the keys. - py::object iter() const { return items().attr("__iter__")(); } + nb::object iter() const { return items().attr("__iter__")(); } /// Register this enum. - static void wrap(py::module_ m) + static void wrap(nb::module_ m) { - py::class_ cls( + nb::class_ cls( m, /*classname=*/Descr::name(), /*docstring=*/Descr::doc()); - cls.def_static("keys", &StringEnum::keys, "keys() -> list") - .def("__len__", &StringEnum::numItems, "__len__() -> int") - .def("__iter__", &StringEnum::iter, "__iter__() -> iterator") - .def("__getitem__", &StringEnum::getItem, "__getitem__(str) -> str") + cls.def_static("keys", &StringEnum::keys) + .def("__len__", &StringEnum::numItems) + .def("__iter__", &StringEnum::iter) + .def("__getitem__", &StringEnum::getItem) /*end*/; // Add a read-only, class-level attribute for each (key, value) pair. for (int i = 0; ; ++i) { const CStringPair item = Descr::item(i); - if (item.first) cls.def_readonly_static(*item.first, item.second); + if (item.first) cls.def_ro_static(*item.first, item.second); else break; } } @@ -165,9 +165,9 @@ struct StringEnum /// Return the name of the given Python object's class. inline std::string -className(py::handle h) +className(nb::handle h) { - return py::cast(h.attr("__class__").attr("__name__")); + return nb::cast(h.attr("__class__").attr("__name__")); } } // namespace pyutil diff --git a/openvdb/openvdb/python/test/TestOpenVDB.py b/openvdb/openvdb/python/test/TestOpenVDB.py index 2cc13e932c..7e354ed2b2 100644 --- a/openvdb/openvdb/python/test/TestOpenVDB.py +++ b/openvdb/openvdb/python/test/TestOpenVDB.py @@ -1,6 +1,6 @@ #!/usr/local/bin/python # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 """ Unit tests for the OpenVDB Python module @@ -12,7 +12,6 @@ import os, os.path import sys import unittest -import inspect # If on Windows, add required dll directories from our binary build tree if 'add_dll_directory' in dir(os): @@ -23,7 +22,7 @@ os.add_dll_directory(os.getcwd() + '\\..\\..\\..\\..\\openvdb_ax\\openvdb_ax\\' + config) -import pyopenvdb as openvdb +import openvdb def valueFactory(zeroValue, elemValue): @@ -46,14 +45,14 @@ def valueFactory(zeroValue, elemValue): def ax_is_enabled(): ''' - Return true if we should be testing pyopenvdb.ax(). This environment + Return true if we should be testing openvdb.ax(). This environment variable is set by the CMake test command if we expect AX to be tested. ''' - ax_hook_exists = 'ax' in dir(openvdb) and inspect.isbuiltin(openvdb.ax) + ax_hook_exists = hasattr(openvdb, 'ax') ax_is_enabled = os.getenv('OPENVDB_TEST_PYTHON_AX') if ax_is_enabled and not ax_hook_exists: raise RuntimeError('Expected to test the AX python hooks but ' - 'pyopenvdb.ax() has not been located.') + 'openvdb.ax() has not been located.') return ax_is_enabled @@ -322,7 +321,7 @@ def testGridIterators(self): # Verify that writing through a const iterator is not allowed. value = grid.citerOnValues().next() - self.assertRaises(AttributeError, lambda: setattr(value, 'active', 0)) + self.assertRaises(AttributeError, lambda: setattr(value, 'active', False)) self.assertRaises(AttributeError, lambda: setattr(value, 'depth', 0)) # Verify that some value attributes are immutable, even given a non-const iterator. value = grid.iterOnValues().next() @@ -679,7 +678,7 @@ def createArrays(): for dtype in (np.float32, np.int32, np.float64, np.int64, np.uint32, bool): # Return a new NumPy array. arr = np.ndarray(shape, dtype) - arr.fill(-100) + arr.fill(999) yield arr # Test copying from arrays of various types to grids of various types. @@ -787,8 +786,6 @@ def testMeshConversion(self): # Vector-valued grids can't be used to store level sets. self.assertRaises(TypeError, lambda: openvdb.Vec3SGrid.createLevelSetFromPolygons( cubePoints, quads=cubeQuads, transform=xform, halfWidth=halfWidth)) - # The "points" argument to createLevelSetFromPolygons() can be a regular array. - openvdb.FloatGrid.createLevelSetFromPolygons(cubeVertices, quads=cubeQuads, transform=xform, halfWidth=halfWidth) # The "points" argument to createLevelSetFromPolygons() can be an array that's implicitly convertible to float openvdb.FloatGrid.createLevelSetFromPolygons(np.array(cubeVertices, bool), quads=cubeQuads, transform=xform, halfWidth=halfWidth) # The "triangles" argument to createLevelSetFromPolygons() must be an N x 3 NumPy array. diff --git a/openvdb/openvdb/thread/Threading.h b/openvdb/openvdb/thread/Threading.h index 8c01b7c821..b339a85ecc 100644 --- a/openvdb/openvdb/thread/Threading.h +++ b/openvdb/openvdb/thread/Threading.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Threading.h diff --git a/openvdb/openvdb/tools/Activate.h b/openvdb/openvdb/tools/Activate.h index c23b09acc3..89442b1174 100644 --- a/openvdb/openvdb/tools/Activate.h +++ b/openvdb/openvdb/tools/Activate.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Activate.h /// diff --git a/openvdb/openvdb/tools/ChangeBackground.h b/openvdb/openvdb/tools/ChangeBackground.h index aee8b4ac37..160a1ef35c 100644 --- a/openvdb/openvdb/tools/ChangeBackground.h +++ b/openvdb/openvdb/tools/ChangeBackground.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file ChangeBackground.h /// diff --git a/openvdb/openvdb/tools/Clip.h b/openvdb/openvdb/tools/Clip.h index 24f64a9985..d01ffc31aa 100644 --- a/openvdb/openvdb/tools/Clip.h +++ b/openvdb/openvdb/tools/Clip.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file Clip.h /// diff --git a/openvdb/openvdb/tools/Composite.h b/openvdb/openvdb/tools/Composite.h index c70bec4e19..c0a594a22a 100644 --- a/openvdb/openvdb/tools/Composite.h +++ b/openvdb/openvdb/tools/Composite.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Composite.h /// diff --git a/openvdb/openvdb/tools/Count.h b/openvdb/openvdb/tools/Count.h index c4db00d60c..03dc719b86 100644 --- a/openvdb/openvdb/tools/Count.h +++ b/openvdb/openvdb/tools/Count.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Count.h /// diff --git a/openvdb/openvdb/tools/Dense.h b/openvdb/openvdb/tools/Dense.h index 29a458fb7f..042c7b1019 100644 --- a/openvdb/openvdb/tools/Dense.h +++ b/openvdb/openvdb/tools/Dense.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file Dense.h /// diff --git a/openvdb/openvdb/tools/DenseSparseTools.h b/openvdb/openvdb/tools/DenseSparseTools.h index 817ffcfb44..12afb94e94 100644 --- a/openvdb/openvdb/tools/DenseSparseTools.h +++ b/openvdb/openvdb/tools/DenseSparseTools.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_TOOLS_DENSESPARSETOOLS_HAS_BEEN_INCLUDED #define OPENVDB_TOOLS_DENSESPARSETOOLS_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/tools/Diagnostics.h b/openvdb/openvdb/tools/Diagnostics.h index eab32881fc..c603ddc721 100644 --- a/openvdb/openvdb/tools/Diagnostics.h +++ b/openvdb/openvdb/tools/Diagnostics.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// /// @file Diagnostics.h /// diff --git a/openvdb/openvdb/tools/FastSweeping.h b/openvdb/openvdb/tools/FastSweeping.h index c457700f77..b7d652a217 100644 --- a/openvdb/openvdb/tools/FastSweeping.h +++ b/openvdb/openvdb/tools/FastSweeping.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file FastSweeping.h /// diff --git a/openvdb/openvdb/tools/Filter.h b/openvdb/openvdb/tools/Filter.h index 8f9e1eef69..94cdde016d 100644 --- a/openvdb/openvdb/tools/Filter.h +++ b/openvdb/openvdb/tools/Filter.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Ken Museth /// diff --git a/openvdb/openvdb/tools/FindActiveValues.h b/openvdb/openvdb/tools/FindActiveValues.h index 4c30bea0f5..b528f8fc22 100644 --- a/openvdb/openvdb/tools/FindActiveValues.h +++ b/openvdb/openvdb/tools/FindActiveValues.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /////////////////////////////////////////////////////////////////////////// // diff --git a/openvdb/openvdb/tools/GridOperators.h b/openvdb/openvdb/tools/GridOperators.h index 4a291b3bb5..e177b11d3e 100644 --- a/openvdb/openvdb/tools/GridOperators.h +++ b/openvdb/openvdb/tools/GridOperators.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file tools/GridOperators.h /// diff --git a/openvdb/openvdb/tools/GridTransformer.h b/openvdb/openvdb/tools/GridTransformer.h index 87df077813..0602cf61ad 100644 --- a/openvdb/openvdb/tools/GridTransformer.h +++ b/openvdb/openvdb/tools/GridTransformer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file GridTransformer.h /// @author Peter Cucka diff --git a/openvdb/openvdb/tools/Interpolation.h b/openvdb/openvdb/tools/Interpolation.h index 5a3cbc2eca..b3870c0838 100644 --- a/openvdb/openvdb/tools/Interpolation.h +++ b/openvdb/openvdb/tools/Interpolation.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file Interpolation.h /// diff --git a/openvdb/openvdb/tools/LevelSetAdvect.h b/openvdb/openvdb/tools/LevelSetAdvect.h index 4fe44d3450..7d4787d09c 100644 --- a/openvdb/openvdb/tools/LevelSetAdvect.h +++ b/openvdb/openvdb/tools/LevelSetAdvect.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Ken Museth /// diff --git a/openvdb/openvdb/tools/LevelSetFilter.h b/openvdb/openvdb/tools/LevelSetFilter.h index a31b7344be..bc1a425815 100644 --- a/openvdb/openvdb/tools/LevelSetFilter.h +++ b/openvdb/openvdb/tools/LevelSetFilter.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Ken Museth /// @@ -95,6 +95,23 @@ class LevelSetFilter : public LevelSetTracker Filter f(this, mask); f.meanCurvature(); } + /// @brief One iteration of filleting on the level set. + /// @param mask Optional alpha mask. + /// + /// @note This filter rounds off concave edges to create a smoother + /// transition between surfaces. Fillets a level set by offsetting + /// at locations with a negative principal curvature, proportional + /// to its magnitude leaves locations with non-negative principal + /// curvatures untouched. This filter converges to the convex hull + /// if iterated enough times. + /// + /// @details See also Level Set Methods and Fast Marching Methods + /// by James Sethian, pp. 204. + void fillet(const MaskType* mask = nullptr) + { + Filter f(this, mask); f.fillet(); + } + /// @brief One iteration of Laplacian flow of the level set. /// @param mask Optional alpha mask. void laplacian(const MaskType* mask = nullptr) @@ -168,6 +185,7 @@ class LevelSetFilter : public LevelSetTracker void gaussian(int width); void laplacian(); void meanCurvature(); + void fillet(); void offset(ValueType value); void operator()(const LeafRange& r) const { @@ -210,6 +228,7 @@ class LevelSetFilter : public LevelSetTracker void medianImpl(const LeafRange&, int); void meanCurvatureImpl(const LeafRange&); + void filletImpl(const LeafRange&); void laplacianImpl(const LeafRange&); void offsetImpl(const LeafRange&, ValueType); @@ -301,6 +320,22 @@ LevelSetFilter::Filter::meanCurvature() mParent->endInterrupter(); } +template +inline void +LevelSetFilter::Filter::fillet() +{ + mParent->startInterrupter("Filleting level set"); + + mParent->leafs().rebuildAuxBuffers(1, mParent->getGrainSize()==0); + + mTask = std::bind(&Filter::filletImpl, std::placeholders::_1, std::placeholders::_2); + this->cook(true); + + mParent->track(); + + mParent->endInterrupter(); +} + template inline void LevelSetFilter::Filter::laplacian() @@ -378,6 +413,52 @@ LevelSetFilter::Filter::meanCurvatureImpl(const LeafRa } } +/// Fillets a level set by offsetting at locations with a negative principal +/// curvature, proportional to its magnitude. Leaves locations with non-negative +/// principal curvatures untouched. This filter converges to the convex hull if +/// iterated enough times. +template +inline void +LevelSetFilter::Filter::filletImpl(const LeafRange& range) +{ + mParent->checkInterrupter(); + + const ValueType dx = mParent->voxelSize(), dt = math::Pow2(dx) / ValueType(3); + math::CurvatureStencil stencil(mParent->grid(), dx); + + if (mMask) { + typename AlphaMaskT::FloatType a, b; + AlphaMaskT alpha(mParent->grid(), *mMask, mParent->minMask(), + mParent->maxMask(), mParent->isMaskInverted()); + for (LeafIterT leafIter=range.begin(); leafIter; ++leafIter) { + ValueType* buffer = leafIter.buffer(1).data(); + for (VoxelCIterT iter = leafIter->cbeginValueOn(); iter; ++iter) { + if (alpha(iter.getCoord(), a, b)) { + stencil.moveTo(iter); + + const ValueType kappa = stencil.principalCurvatures().first; + + const ValueType phi0 = *iter, + phi1 = phi0 + math::Min(ValueType(0), dt*kappa); + buffer[iter.pos()] = b * phi0 + a * phi1; + } + } + } + } else { + for (LeafIterT leafIter=range.begin(); leafIter; ++leafIter) { + ValueType* buffer = leafIter.buffer(1).data(); + for (VoxelCIterT iter = leafIter->cbeginValueOn(); iter; ++iter) { + stencil.moveTo(iter); + + const ValueType kappa = stencil.principalCurvatures().first; + + if (math::isNegative(kappa)) + buffer[iter.pos()] = *iter + dt*kappa; + } + } + } +} + /// Performs Laplacian diffusion. Note if the grids contains a true /// signed distance field (e.g. a solution to the Eikonal equation) /// Laplacian diffusions (e.g. geometric heat equation) is actually diff --git a/openvdb/openvdb/tools/LevelSetFracture.h b/openvdb/openvdb/tools/LevelSetFracture.h index cf27843f3c..2c457e75c6 100644 --- a/openvdb/openvdb/tools/LevelSetFracture.h +++ b/openvdb/openvdb/tools/LevelSetFracture.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file tools/LevelSetFracture.h /// diff --git a/openvdb/openvdb/tools/LevelSetMeasure.h b/openvdb/openvdb/tools/LevelSetMeasure.h index a4ad847704..5a31ffe6fe 100644 --- a/openvdb/openvdb/tools/LevelSetMeasure.h +++ b/openvdb/openvdb/tools/LevelSetMeasure.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Ken Museth /// diff --git a/openvdb/openvdb/tools/LevelSetMorph.h b/openvdb/openvdb/tools/LevelSetMorph.h index 6812999bbf..e455d07d25 100644 --- a/openvdb/openvdb/tools/LevelSetMorph.h +++ b/openvdb/openvdb/tools/LevelSetMorph.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Ken Museth /// diff --git a/openvdb/openvdb/tools/LevelSetPlatonic.h b/openvdb/openvdb/tools/LevelSetPlatonic.h index a1be4fd38e..f1f689b7c9 100644 --- a/openvdb/openvdb/tools/LevelSetPlatonic.h +++ b/openvdb/openvdb/tools/LevelSetPlatonic.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Ken Museth /// diff --git a/openvdb/openvdb/tools/LevelSetRebuild.h b/openvdb/openvdb/tools/LevelSetRebuild.h index 6f4fd6e3b7..1a82cc52a8 100644 --- a/openvdb/openvdb/tools/LevelSetRebuild.h +++ b/openvdb/openvdb/tools/LevelSetRebuild.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_TOOLS_LEVELSETREBUILD_HAS_BEEN_INCLUDED #define OPENVDB_TOOLS_LEVELSETREBUILD_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/tools/LevelSetSphere.h b/openvdb/openvdb/tools/LevelSetSphere.h index 86c7bbe950..83dac13496 100644 --- a/openvdb/openvdb/tools/LevelSetSphere.h +++ b/openvdb/openvdb/tools/LevelSetSphere.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// /// @file LevelSetSphere.h /// diff --git a/openvdb/openvdb/tools/LevelSetTracker.h b/openvdb/openvdb/tools/LevelSetTracker.h index 37bf176172..d171cabf95 100644 --- a/openvdb/openvdb/tools/LevelSetTracker.h +++ b/openvdb/openvdb/tools/LevelSetTracker.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Ken Museth /// diff --git a/openvdb/openvdb/tools/LevelSetUtil.h b/openvdb/openvdb/tools/LevelSetUtil.h index fd74c8ce12..012da732ec 100644 --- a/openvdb/openvdb/tools/LevelSetUtil.h +++ b/openvdb/openvdb/tools/LevelSetUtil.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file tools/LevelSetUtil.h /// diff --git a/openvdb/openvdb/tools/Mask.h b/openvdb/openvdb/tools/Mask.h index 3e75ce77e3..daecf0b0d2 100644 --- a/openvdb/openvdb/tools/Mask.h +++ b/openvdb/openvdb/tools/Mask.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file Mask.h /// diff --git a/openvdb/openvdb/tools/Merge.h b/openvdb/openvdb/tools/Merge.h index e56306aea5..a7afd4d055 100644 --- a/openvdb/openvdb/tools/Merge.h +++ b/openvdb/openvdb/tools/Merge.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Merge.h /// diff --git a/openvdb/openvdb/tools/MeshToVolume.h b/openvdb/openvdb/tools/MeshToVolume.h index 931d01a0f9..6d85f23576 100644 --- a/openvdb/openvdb/tools/MeshToVolume.h +++ b/openvdb/openvdb/tools/MeshToVolume.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file MeshToVolume.h /// @@ -16,7 +16,7 @@ #ifndef OPENVDB_TOOLS_MESH_TO_VOLUME_HAS_BEEN_INCLUDED #define OPENVDB_TOOLS_MESH_TO_VOLUME_HAS_BEEN_INCLUDED -#include // for OPENVDB_HAS_CXX11 +#include #include #include // for GodunovsNormSqrd #include // for closestPointOnTriangleToPoint diff --git a/openvdb/openvdb/tools/Morphology.h b/openvdb/openvdb/tools/Morphology.h index 4780d04574..c7c0590bea 100644 --- a/openvdb/openvdb/tools/Morphology.h +++ b/openvdb/openvdb/tools/Morphology.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Morphology.h /// diff --git a/openvdb/openvdb/tools/MultiResGrid.h b/openvdb/openvdb/tools/MultiResGrid.h index 4260cf48ce..10eee0e1b4 100644 --- a/openvdb/openvdb/tools/MultiResGrid.h +++ b/openvdb/openvdb/tools/MultiResGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file MultiResGrid.h /// diff --git a/openvdb/openvdb/tools/NodeVisitor.h b/openvdb/openvdb/tools/NodeVisitor.h index 857b1c38dc..5bf436f9c8 100644 --- a/openvdb/openvdb/tools/NodeVisitor.h +++ b/openvdb/openvdb/tools/NodeVisitor.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file NodeVisitor.h /// diff --git a/openvdb/openvdb/tools/ParticleAtlas.h b/openvdb/openvdb/tools/ParticleAtlas.h index be53597f88..0856e8c938 100644 --- a/openvdb/openvdb/tools/ParticleAtlas.h +++ b/openvdb/openvdb/tools/ParticleAtlas.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ParticleAtlas.h /// diff --git a/openvdb/openvdb/tools/ParticlesToLevelSet.h b/openvdb/openvdb/tools/ParticlesToLevelSet.h index 15baffd329..870effe323 100644 --- a/openvdb/openvdb/tools/ParticlesToLevelSet.h +++ b/openvdb/openvdb/tools/ParticlesToLevelSet.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Ken Museth /// diff --git a/openvdb/openvdb/tools/PointAdvect.h b/openvdb/openvdb/tools/PointAdvect.h index 6ce79978e9..e3d9d35723 100644 --- a/openvdb/openvdb/tools/PointAdvect.h +++ b/openvdb/openvdb/tools/PointAdvect.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Ken Museth, D.J. Hill (openvdb port, added staggered grid support) /// diff --git a/openvdb/openvdb/tools/PointIndexGrid.h b/openvdb/openvdb/tools/PointIndexGrid.h index e502aae55b..463a07039f 100644 --- a/openvdb/openvdb/tools/PointIndexGrid.h +++ b/openvdb/openvdb/tools/PointIndexGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file PointIndexGrid.h /// diff --git a/openvdb/openvdb/tools/PointPartitioner.h b/openvdb/openvdb/tools/PointPartitioner.h index 1fa80edfda..22336f125b 100644 --- a/openvdb/openvdb/tools/PointPartitioner.h +++ b/openvdb/openvdb/tools/PointPartitioner.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file PointPartitioner.h /// diff --git a/openvdb/openvdb/tools/PointScatter.h b/openvdb/openvdb/tools/PointScatter.h index 7ad03433c5..6411809e36 100644 --- a/openvdb/openvdb/tools/PointScatter.h +++ b/openvdb/openvdb/tools/PointScatter.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Ken Museth /// diff --git a/openvdb/openvdb/tools/PointsToMask.h b/openvdb/openvdb/tools/PointsToMask.h index bfe5f9502c..33c936c460 100644 --- a/openvdb/openvdb/tools/PointsToMask.h +++ b/openvdb/openvdb/tools/PointsToMask.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author Ken Museth /// diff --git a/openvdb/openvdb/tools/PoissonSolver.h b/openvdb/openvdb/tools/PoissonSolver.h index fb2e5642fd..008a39b32a 100644 --- a/openvdb/openvdb/tools/PoissonSolver.h +++ b/openvdb/openvdb/tools/PoissonSolver.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file PoissonSolver.h /// diff --git a/openvdb/openvdb/tools/PotentialFlow.h b/openvdb/openvdb/tools/PotentialFlow.h index 2fc0ab0e83..b90d6cc742 100644 --- a/openvdb/openvdb/tools/PotentialFlow.h +++ b/openvdb/openvdb/tools/PotentialFlow.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file tools/PotentialFlow.h /// diff --git a/openvdb/openvdb/tools/Prune.h b/openvdb/openvdb/tools/Prune.h index b05c80e42f..36f246e9b8 100644 --- a/openvdb/openvdb/tools/Prune.h +++ b/openvdb/openvdb/tools/Prune.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Prune.h /// diff --git a/openvdb/openvdb/tools/RayIntersector.h b/openvdb/openvdb/tools/RayIntersector.h index d9b2d3a31e..c97942ad82 100644 --- a/openvdb/openvdb/tools/RayIntersector.h +++ b/openvdb/openvdb/tools/RayIntersector.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// /// @file RayIntersector.h /// diff --git a/openvdb/openvdb/tools/RayTracer.h b/openvdb/openvdb/tools/RayTracer.h index 659270176b..fc11b34161 100644 --- a/openvdb/openvdb/tools/RayTracer.h +++ b/openvdb/openvdb/tools/RayTracer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file RayTracer.h /// diff --git a/openvdb/openvdb/tools/SignedFloodFill.h b/openvdb/openvdb/tools/SignedFloodFill.h index 228376ff4d..03ff521dd0 100644 --- a/openvdb/openvdb/tools/SignedFloodFill.h +++ b/openvdb/openvdb/tools/SignedFloodFill.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SignedFloodFill.h /// diff --git a/openvdb/openvdb/tools/Statistics.h b/openvdb/openvdb/tools/Statistics.h index 5daa808dec..6ac636c2f1 100644 --- a/openvdb/openvdb/tools/Statistics.h +++ b/openvdb/openvdb/tools/Statistics.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Statistics.h /// diff --git a/openvdb/openvdb/tools/TopologyToLevelSet.h b/openvdb/openvdb/tools/TopologyToLevelSet.h index 4bc0888542..372f740b53 100644 --- a/openvdb/openvdb/tools/TopologyToLevelSet.h +++ b/openvdb/openvdb/tools/TopologyToLevelSet.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file TopologyToLevelSet.h /// diff --git a/openvdb/openvdb/tools/ValueTransformer.h b/openvdb/openvdb/tools/ValueTransformer.h index 9f7ac8f5c4..0d9af45858 100644 --- a/openvdb/openvdb/tools/ValueTransformer.h +++ b/openvdb/openvdb/tools/ValueTransformer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file ValueTransformer.h /// @@ -135,12 +135,14 @@ inline void foreach(const IterT& iter, const XformOp& op, /// consider using @c tbb::parallel_for() or @c tbb::parallel_reduce() in conjunction /// with a tree::IteratorRange that wraps a grid or tree iterator. template -inline void transformValues(const InIterT& inIter, OutGridT& outGrid, +inline OPENVDB_UBSAN_SUPPRESS("undefined") +void transformValues(const InIterT& inIter, OutGridT& outGrid, XformOp& op, bool threaded = true, bool shareOp = true, MergePolicy merge = MERGE_ACTIVE_STATES); template -inline void transformValues(const InIterT& inIter, OutGridT& outGrid, +inline OPENVDB_UBSAN_SUPPRESS("undefined") +void transformValues(const InIterT& inIter, OutGridT& outGrid, const XformOp& op, bool threaded = true, bool shareOp = true, MergePolicy merge = MERGE_ACTIVE_STATES); @@ -585,8 +587,8 @@ class CopyableOpTransformer template -inline void -transformValues(const InIterT& inIter, OutGridT& outGrid, XformOp& op, +inline OPENVDB_UBSAN_SUPPRESS("undefined") +void transformValues(const InIterT& inIter, OutGridT& outGrid, XformOp& op, bool threaded, bool shared, MergePolicy merge) { using Adapter = TreeAdapter; @@ -603,8 +605,8 @@ transformValues(const InIterT& inIter, OutGridT& outGrid, XformOp& op, } template -inline void -transformValues(const InIterT& inIter, OutGridT& outGrid, const XformOp& op, +inline OPENVDB_UBSAN_SUPPRESS("undefined") +void transformValues(const InIterT& inIter, OutGridT& outGrid, const XformOp& op, bool threaded, bool /*share*/, MergePolicy merge) { using Adapter = TreeAdapter; diff --git a/openvdb/openvdb/tools/VectorTransformer.h b/openvdb/openvdb/tools/VectorTransformer.h index ee2a27cfb4..5906ef0b05 100644 --- a/openvdb/openvdb/tools/VectorTransformer.h +++ b/openvdb/openvdb/tools/VectorTransformer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file VectorTransformer.h diff --git a/openvdb/openvdb/tools/VelocityFields.h b/openvdb/openvdb/tools/VelocityFields.h index d48fe4b279..4c9ac1ae87 100644 --- a/openvdb/openvdb/tools/VelocityFields.h +++ b/openvdb/openvdb/tools/VelocityFields.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /////////////////////////////////////////////////////////////////////////// // diff --git a/openvdb/openvdb/tools/VolumeAdvect.h b/openvdb/openvdb/tools/VolumeAdvect.h index de4593fb29..aa7b856134 100644 --- a/openvdb/openvdb/tools/VolumeAdvect.h +++ b/openvdb/openvdb/tools/VolumeAdvect.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /////////////////////////////////////////////////////////////////////////// // diff --git a/openvdb/openvdb/tools/VolumeToMesh.h b/openvdb/openvdb/tools/VolumeToMesh.h index 603ecc259d..509fc1187b 100644 --- a/openvdb/openvdb/tools/VolumeToMesh.h +++ b/openvdb/openvdb/tools/VolumeToMesh.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file VolumeToMesh.h /// diff --git a/openvdb/openvdb/tools/VolumeToSpheres.h b/openvdb/openvdb/tools/VolumeToSpheres.h index 648ec3aaad..b5d7b95181 100644 --- a/openvdb/openvdb/tools/VolumeToSpheres.h +++ b/openvdb/openvdb/tools/VolumeToSpheres.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file tools/VolumeToSpheres.h /// diff --git a/openvdb/openvdb/tree/InternalNode.h b/openvdb/openvdb/tree/InternalNode.h index 7cf653f901..534fc9553d 100644 --- a/openvdb/openvdb/tree/InternalNode.h +++ b/openvdb/openvdb/tree/InternalNode.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file InternalNode.h /// @@ -274,9 +274,11 @@ class InternalNode /// Set the transient data value. void setTransientData(Index32 transientData) { mTransientData = transientData; } - Index32 leafCount() const; + Index64 leafCount() const; + Index64 nonLeafCount() const; + void nodeCount(std::vector &vec) const; + OPENVDB_DEPRECATED_MESSAGE("Use input type std::vector for nodeCount.") void nodeCount(std::vector &vec) const; - Index32 nonLeafCount() const; Index32 childCount() const; Index64 onVoxelCount() const; Index64 offVoxelCount() const; @@ -331,7 +333,11 @@ class InternalNode /// Return @c true if the voxel at the given coordinates is active. bool isValueOn(const Coord& xyz) const; /// Return @c true if the voxel at the given offset is active. - bool isValueOn(Index offset) const { return mValueMask.isOn(offset); } + bool isValueOn(Index offset) const { OPENVDB_ASSERT(offset < NUM_VALUES); return mValueMask.isOn(offset); } + /// Return @c true if the voxel at the given coordinates is inactive. + bool isValueOff(const Coord& xyz) const; + /// Return @c true if the voxel at the given offset is inactive. + bool isValueOff(Index offset) const { OPENVDB_ASSERT(offset < NUM_VALUES); return mValueMask.isOff(offset); } /// Return @c true if this node or any of its child nodes have any active tiles. bool hasActiveTiles() const; @@ -458,6 +464,79 @@ class InternalNode void readBuffers(std::istream&, const CoordBBox&, bool fromHalf = false); + // + // Unsafe methods + // + // WARNING: For improved performance, these unsafe methods do not check the value or + // child masks. If used incorrectly, at best they will leave the InternalNode in an + // invalid state and at worst cause the application to crash. Always use the safer + // alternative method(s) unless you really know what you're doing. + // Enabling OpenVDB asserts will catch where assumptions are incorrectly invalidated. + + /// @brief Return the tile value at offset. + /// @note Use getValue(const Coord&) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + const ValueType& getValueUnsafe(Index offset) const; + /// @brief Return the tile value and active state at offset. + /// @note Use probeValue(const Coord&, ValueType&) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + bool getValueUnsafe(Index offset, ValueType& value) const; + + /// @brief Return the child node at offset. + /// @note Use probeChild(const Coord&) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + ChildNodeType* getChildUnsafe(Index offset); + /// @brief Return the child node at offset. + /// @note Use probeConstChild(const Coord&) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + const ChildNodeType* getConstChildUnsafe(Index offset) const; + /// @brief Return the child node at offset. + /// @note Use probeChild(const Coord&) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + const ChildNodeType* getChildUnsafe(Index offset) const; + + /// @brief Set the tile active state at offset but don't change its value. + /// @note Use setActiveState(const Coord&, bool) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + void setActiveStateUnsafe(Index offset, bool on); + /// @brief Set the tile value at offset but don't change its value. + /// @note Use setValueOnly(const Coord&, const ValueType&) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + void setValueOnlyUnsafe(Index offset, const ValueType& value); + /// @brief Mark the tile active at offset but don't change its value. + /// @note Use setValueOn(const Coord&) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + void setValueOnUnsafe(Index offset); + /// @brief Set the tile value at offset and mark the voxel as active. + /// @note Use setValueOn(const Coord&, const ValueType&) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + void setValueOnUnsafe(Index offset, const ValueType& value); + /// @brief Mark the tile inactive at offset but don't change its value. + /// @note Use setValueOff(const Coord&) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + void setValueOffUnsafe(Index offset); + /// @brief Set the tile value at offset and mark the voxel as inactive. + /// @note Use setValueOff(const Coord&, const ValueType&) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + void setValueOffUnsafe(Index offset, const ValueType& value); + + /// @brief Replace a tile at offset with the given child node. + /// @note Use addChild(ChildNodeType*) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + void setChildUnsafe(Index offset, ChildNodeType* child); + /// @brief Replace a child node at offset with the given child node. + /// @note Use addChild(ChildNodeType*) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + void resetChildUnsafe(Index offset, ChildNodeType* child); + /// @brief Replace a child node at offset with the given value and active state. + /// @note Use addChild(ChildNodeType*) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + ChildNodeType* stealChildUnsafe(Index offset, const ValueType& value, bool active); + /// @brief Delete a child node at offset and replace with the given value and active state. + /// @note Use addTile(Index, const ValueType&, bool) for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + void deleteChildUnsafe(Index offset, const ValueType& value, bool active); + // // Aux methods // @@ -620,6 +699,43 @@ class InternalNode /// If no such node exists, return nullptr. template NodeType* probeNode(const Coord& xyz); template const NodeType* probeConstNode(const Coord& xyz) const; + template const NodeType* probeNode(const Coord& xyz) const { return this->probeConstNode(xyz); } + //@} + + //@{ + /// @brief Return a pointer to the child node that contains voxel (x, y, z). + /// If no such node exists, return nullptr. + ChildNodeType* probeChild(const Coord& xyz); + const ChildNodeType* probeConstChild(const Coord& xyz) const; + const ChildNodeType* probeChild(const Coord& xyz) const { return this->probeConstChild(xyz); } + //@} + + //@{ + /// @brief Return a pointer to the child node that contains voxel (x, y, z). + /// If no such node exists, return nullptr. + ChildNodeType* probeChild(const Coord& xyz, ValueType& value, bool& active); + const ChildNodeType* probeConstChild(const Coord& xyz, ValueType& value, bool& active) const; + const ChildNodeType* probeChild(const Coord& xyz, ValueType& value, bool& active) const { return this->probeConstChild(xyz, value, active); } + //@} + + //@{ + /// @brief Return a pointer to the child node for a specific offset. + /// If no such node exists, return nullptr. + /// @warning This method should only be used by experts seeking low-level optimizations. + /// @note Out-of-bounds memory access attempts will wrap around using modulo indexing. + ChildNodeType* probeChildUnsafe(Index offset); + const ChildNodeType* probeConstChildUnsafe(Index offset) const; + const ChildNodeType* probeChildUnsafe(Index offset) const { return this->probeConstChildUnsafe(offset); } + //@} + + //@{ + /// @brief Return a pointer to the child node for a specific offset. + /// If no such node exists, return nullptr. + /// @warning This method should only be used by experts seeking low-level optimizations. + /// @note Out-of-bounds memory access attempts will wrap around using modulo indexing. + ChildNodeType* probeChildUnsafe(Index offset, ValueType& value, bool& active); + const ChildNodeType* probeConstChildUnsafe(Index offset, ValueType& value, bool& active) const; + const ChildNodeType* probeChildUnsafe(Index offset, ValueType& value, bool& active) const { return this->probeConstChildUnsafe(offset, value, active); } //@} //@{ @@ -988,11 +1104,11 @@ InternalNode::~InternalNode() template -inline Index32 +inline Index64 InternalNode::leafCount() const { if (ChildNodeType::getLevel() == 0) return mChildMask.countOn(); - Index32 sum = 0; + Index64 sum = 0; for (ChildOnCIter iter = this->cbeginChildOn(); iter; ++iter) { sum += iter->leafCount(); } @@ -1001,7 +1117,7 @@ InternalNode::leafCount() const template inline void -InternalNode::nodeCount(std::vector &vec) const +InternalNode::nodeCount(std::vector &vec) const { OPENVDB_ASSERT(vec.size() > ChildNodeType::LEVEL); const auto count = mChildMask.countOn(); @@ -1011,12 +1127,28 @@ InternalNode::nodeCount(std::vector &vec) const vec[ChildNodeType::LEVEL] += count; } +template +inline void +InternalNode::nodeCount(std::vector &vec) const +{ + OPENVDB_ASSERT(vec.size() > ChildNodeType::LEVEL); + const auto count = mChildMask.countOn(); + if (ChildNodeType::LEVEL > 0 && count > 0) { + for (auto iter = this->cbeginChildOn(); iter; ++iter) { + OPENVDB_NO_DEPRECATION_WARNING_BEGIN + iter->nodeCount(vec); + OPENVDB_NO_DEPRECATION_WARNING_END + } + } + vec[ChildNodeType::LEVEL] += count; +} + template -inline Index32 +inline Index64 InternalNode::nonLeafCount() const { - Index32 sum = 1; + Index64 sum = 1; if (ChildNodeType::getLevel() == 0) return sum; for (ChildOnCIter iter = this->cbeginChildOn(); iter; ++iter) { sum += iter->nonLeafCount(); @@ -1248,6 +1380,82 @@ InternalNode::probeConstNodeAndCache(const Coord& xyz, Accessor //////////////////////////////////////// +template +inline ChildT* +InternalNode::probeChild(const Coord& xyz) +{ + const Index n = this->coordToOffset(xyz); + return this->probeChildUnsafe(n); +} + +template +inline const ChildT* +InternalNode::probeConstChild(const Coord& xyz) const +{ + const Index n = this->coordToOffset(xyz); + return this->probeConstChildUnsafe(n); +} + +template +inline ChildT* +InternalNode::probeChild(const Coord& xyz, ValueType& value, bool& active) +{ + const Index n = this->coordToOffset(xyz); + return this->probeChildUnsafe(n, value, active); +} + +template +inline const ChildT* +InternalNode::probeConstChild(const Coord& xyz, ValueType& value, bool& active) const +{ + const Index n = this->coordToOffset(xyz); + return this->probeConstChildUnsafe(n, value, active); +} + +template +inline ChildT* +InternalNode::probeChildUnsafe(Index offset) +{ + OPENVDB_ASSERT(offset < NUM_VALUES); + if (mChildMask.isOn(offset)) return mNodes[offset].getChild(); + return nullptr; +} + +template +inline const ChildT* +InternalNode::probeConstChildUnsafe(Index offset) const +{ + OPENVDB_ASSERT(offset < NUM_VALUES); + if (mChildMask.isOn(offset)) return mNodes[offset].getChild(); + return nullptr; +} + +template +inline ChildT* +InternalNode::probeChildUnsafe(Index offset, ValueType& value, bool& active) +{ + OPENVDB_ASSERT(offset < NUM_VALUES); + if (mChildMask.isOn(offset)) return mNodes[offset].getChild(); + value = mNodes[offset].getValue(); + active = mValueMask.isOn(offset); + return nullptr; +} + +template +inline const ChildT* +InternalNode::probeConstChildUnsafe(Index offset, ValueType& value, bool& active) const +{ + OPENVDB_ASSERT(offset < NUM_VALUES); + if (mChildMask.isOn(offset)) return mNodes[offset].getChild(); + value = mNodes[offset].getValue(); + active = mValueMask.isOn(offset); + return nullptr; +} + + +//////////////////////////////////////// + + template inline typename ChildT::LeafNodeType* InternalNode::probeLeaf(const Coord& xyz) @@ -1550,8 +1758,17 @@ inline bool InternalNode::isValueOn(const Coord& xyz) const { const Index n = this->coordToOffset(xyz); - if (this->isChildMaskOff(n)) return this->isValueMaskOn(n); - return mNodes[n].getChild()->isValueOn(xyz); + return this->isChildMaskOff(n) ? this->isValueMaskOn(n) + : mNodes[n].getChild()->isValueOn(xyz); +} + +template +inline bool +InternalNode::isValueOff(const Coord& xyz) const +{ + const Index n = this->coordToOffset(xyz); + return this->isChildMaskOff(n) ? this->isValueMaskOn(n) + : mNodes[n].getChild()->isValueOff(xyz); } template @@ -2272,6 +2489,156 @@ InternalNode::getLastValue() const //////////////////////////////////////// +template +inline const typename ChildT::ValueType& +InternalNode::getValueUnsafe(Index n) const +{ + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOff(n)); + return mNodes[n].getValue(); +} + +template +inline bool +InternalNode::getValueUnsafe(Index n, ValueType& value) const +{ + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOff(n)); + value = mNodes[n].getValue(); + return mValueMask.isOn(n); +} + +template +inline ChildT* +InternalNode::getChildUnsafe(Index n) +{ + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOn(n)); + return mNodes[n].getChild(); +} + +template +inline const ChildT* +InternalNode::getConstChildUnsafe(Index n) const +{ + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOn(n)); + return mNodes[n].getChild(); +} + +template +inline const ChildT* +InternalNode::getChildUnsafe(Index n) const +{ + return this->getConstChildUnsafe(n); +} + +template +inline void +InternalNode::setActiveStateUnsafe(Index n, bool on) +{ + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOff(n)); + mValueMask.set(n, on); +} + +template +inline void +InternalNode::setValueOnlyUnsafe(Index n, const ValueType& value) +{ + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOff(n)); + mNodes[n].setValue(value); +} + +template +inline void +InternalNode::setValueOnUnsafe(Index n) +{ + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOff(n)); + mValueMask.setOn(n); +} + +template +inline void +InternalNode::setValueOnUnsafe(Index n, const ValueType& value) +{ + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOff(n)); + mNodes[n].setValue(value); + mValueMask.setOn(n); +} + +template +inline void +InternalNode::setValueOffUnsafe(Index n) +{ + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOff(n)); + mValueMask.setOff(n); +} + +template +inline void +InternalNode::setValueOffUnsafe(Index n, const ValueType& value) +{ + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOff(n)); + mNodes[n].setValue(value); + mValueMask.setOff(n); +} + +template +inline void +InternalNode::setChildUnsafe(Index n, ChildNodeType* child) +{ + // replace tile with child + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOff(n)); + mNodes[n].setChild(child); + mChildMask.setOn(n); + mValueMask.setOff(n); +} + +template +inline void +InternalNode::resetChildUnsafe(Index n, ChildNodeType* child) +{ + // replace child with child + OPENVDB_ASSERT(child); + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOn(n)); + delete mNodes[n].getChild(); + mNodes[n].setChild(child); +} + +template +inline ChildT* +InternalNode::stealChildUnsafe(Index n, const ValueType& value, bool active) +{ + // replace child with tile (and return child) + OPENVDB_ASSERT(n < NUM_VALUES); + OPENVDB_ASSERT(mChildMask.isOn(n)); + auto* child = mNodes[n].getChild(); + mChildMask.setOff(n); + mValueMask.set(n, active); + mNodes[n].setValue(value); + return child; +} + +template +inline void +InternalNode::deleteChildUnsafe(Index n, const ValueType& value, bool active) +{ + // replace child with tile (and delete child) + delete this->stealChildUnsafe(n, value, active); +} + + +//////////////////////////////////////// + + template inline void InternalNode::negate() diff --git a/openvdb/openvdb/tree/Iterator.h b/openvdb/openvdb/tree/Iterator.h index d3512aa06c..1116c2b34f 100644 --- a/openvdb/openvdb/tree/Iterator.h +++ b/openvdb/openvdb/tree/Iterator.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file tree/Iterator.h /// diff --git a/openvdb/openvdb/tree/LeafBuffer.h b/openvdb/openvdb/tree/LeafBuffer.h index 391a9fc1ad..6bdbdaf82b 100644 --- a/openvdb/openvdb/tree/LeafBuffer.h +++ b/openvdb/openvdb/tree/LeafBuffer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_TREE_LEAFBUFFER_HAS_BEEN_INCLUDED #define OPENVDB_TREE_LEAFBUFFER_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/tree/LeafManager.h b/openvdb/openvdb/tree/LeafManager.h index 0f6293d443..e8d427d025 100644 --- a/openvdb/openvdb/tree/LeafManager.h +++ b/openvdb/openvdb/tree/LeafManager.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file LeafManager.h /// @@ -596,7 +596,7 @@ class LeafManager // Compute the leaf counts for each node - std::vector leafCounts; + std::vector leafCounts; if (serial) { leafCounts.reserve(leafParents.size()); for (LeafParentT* leafParent : leafParents) { diff --git a/openvdb/openvdb/tree/LeafNode.h b/openvdb/openvdb/tree/LeafNode.h index 93f7927afd..c47bac7ed6 100644 --- a/openvdb/openvdb/tree/LeafNode.h +++ b/openvdb/openvdb/tree/LeafNode.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED #define OPENVDB_TREE_LEAFNODE_HAS_BEEN_INCLUDED @@ -129,11 +129,13 @@ class LeafNode /// Return the dimension of child nodes of this LeafNode, which is one for voxels. static Index getChildDim() { return 1; } /// Return the leaf count for this node, which is one. - static Index32 leafCount() { return 1; } + static Index64 leafCount() { return 1; } /// no-op + void nodeCount(std::vector &) const {} + OPENVDB_DEPRECATED_MESSAGE("Use input type std::vector for nodeCount.") void nodeCount(std::vector &) const {} /// Return the non-leaf count for this node, which is zero. - static Index32 nonLeafCount() { return 0; } + static Index64 nonLeafCount() { return 0; } /// Return the child count for this node, which is zero. static Index32 childCount() { return 0; } @@ -473,9 +475,13 @@ class LeafNode void setValuesOff() { mValueMask.setOff(); } /// Return @c true if the voxel at the given coordinates is active. - bool isValueOn(const Coord& xyz) const {return this->isValueOn(LeafNode::coordToOffset(xyz));} + bool isValueOn(const Coord& xyz) const { return this->isValueOn(LeafNode::coordToOffset(xyz)); } /// Return @c true if the voxel at the given offset is active. - bool isValueOn(Index offset) const { return mValueMask.isOn(offset); } + bool isValueOn(Index offset) const { OPENVDB_ASSERT(offset < SIZE); return mValueMask.isOn(offset); } + /// Return @c true if the voxel at the given coordinates is inactive. + bool isValueOff(const Coord& xyz) const { return this->isValueOff(LeafNode::coordToOffset(xyz)); } + /// Return @c true if the voxel at the given offset is inactive. + bool isValueOff(Index offset) const { OPENVDB_ASSERT(offset < SIZE); return mValueMask.isOff(offset); } /// Return @c false since leaf nodes never contain tiles. static bool hasActiveTiles() { return false; } @@ -825,6 +831,29 @@ class LeafNode /// Return @c true if all of this node's values are inactive. bool isInactive() const { return mValueMask.isOff(); } + // + // Unsafe methods + // + // These methods are not in fact unsafe, but are only offered so that + // the same methods can be called on both internal nodes and leaf nodes. + + /// Return the value of the voxel at the given offset. + const ValueType& getValueUnsafe(Index offset) const { return this->getValue(offset); } + /// Return true if the voxel at the given offset is active and set value. + bool getValueUnsafe(Index offset, ValueType& value) const { return this->probeValue(offset, value); } + /// Set the active state of the voxel at the given offset but don't change its value. + void setActiveStateUnsafe(Index offset, bool on) { this->setActiveState(offset, on); } + /// Set the value of the voxel at the given coordinates but don't change its active state. + void setValueOnlyUnsafe(Index offset, const ValueType& value) { return this->setValueOnly(offset, value); } + /// Mark the voxel at the given offset as active but don't change its value. + void setValueOnUnsafe(Index offset) { this->setValueOn(offset); } + /// Set the value of the voxel at the given coordinates and mark the voxel as active. + void setValueOnUnsafe(Index offset, const ValueType& value) { this->setValueOn(offset, value); } + /// Mark the voxel at the given offset as inactive but don't change its value. + void setValueOffUnsafe(Index offset) { this->setValueOff(offset); } + /// Set the value of the voxel at the given coordinates and mark the voxel as active. + void setValueOffUnsafe(Index offset, const ValueType& value) { this->setValueOff(offset, value); } + protected: friend class ::TestLeaf; template friend class ::TestLeafIO; diff --git a/openvdb/openvdb/tree/LeafNodeBool.h b/openvdb/openvdb/tree/LeafNodeBool.h index a5290dbbbc..15145ae874 100644 --- a/openvdb/openvdb/tree/LeafNodeBool.h +++ b/openvdb/openvdb/tree/LeafNodeBool.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED #define OPENVDB_TREE_LEAF_NODE_BOOL_HAS_BEEN_INCLUDED @@ -131,10 +131,12 @@ class LeafNode static void getNodeLog2Dims(std::vector& dims) { dims.push_back(Log2Dim); } static Index getChildDim() { return 1; } - static Index32 leafCount() { return 1; } + static Index64 leafCount() { return 1; } /// no-op + void nodeCount(std::vector &) const {} + OPENVDB_DEPRECATED_MESSAGE("Use input type std::vector for nodeCount.") void nodeCount(std::vector &) const {} - static Index32 nonLeafCount() { return 0; } + static Index64 nonLeafCount() { return 0; } /// Return the number of active voxels. Index64 onVoxelCount() const { return mValueMask.countOn(); } @@ -240,6 +242,10 @@ class LeafNode /// @param xyz the coordinates of the voxel to be probed /// @param[out] val the value of the voxel at the given coordinates bool probeValue(const Coord& xyz, bool& val) const; + /// @brief Return @c true if the voxel at the given offset is active. + /// @param offset the linear offset of the voxel to be probed + /// @param[out] val the value of the voxel at the given coordinates + bool probeValue(Index offset, bool& val) const; /// Return the level (0) at which leaf node values reside. static Index getValueLevel(const Coord&) { return LEVEL; } @@ -295,9 +301,13 @@ class LeafNode void setValuesOff() { mValueMask.setOff(); } /// Return @c true if the voxel at the given coordinates is active. - bool isValueOn(const Coord& xyz) const { return mValueMask.isOn(this->coordToOffset(xyz)); } + bool isValueOn(const Coord& xyz) const { return this->isValueOn(this->coordToOffset(xyz)); } /// Return @c true if the voxel at the given offset is active. bool isValueOn(Index offset) const { OPENVDB_ASSERT(offset < SIZE); return mValueMask.isOn(offset); } + /// Return @c true if the voxel at the given coordinates is inactive. + bool isValueOff(const Coord& xyz) const { return this->isValueOff(this->coordToOffset(xyz)); } + /// Return @c true if the voxel at the given offset is inactive. + bool isValueOff(Index offset) const { OPENVDB_ASSERT(offset < SIZE); return mValueMask.isOff(offset); } /// Return @c false since leaf nodes never contain tiles. static bool hasActiveTiles() { return false; } @@ -457,6 +467,29 @@ class LeafNode /// Return @c true if all of this node's values are inactive. bool isInactive() const { return mValueMask.isOff(); } + // + // Unsafe methods + // + // These methods are not in fact unsafe, but are only offered so that + // the same methods can be called on both internal nodes and leaf nodes. + + /// Return the value of the voxel at the given offset. + const bool& getValueUnsafe(Index offset) const { return this->getValue(offset); } + /// Return true if the voxel at the given offset is active and set value. + bool getValueUnsafe(Index offset, bool& value) const { return this->probeValue(offset, value); } + /// Set the active state of the voxel at the given offset but don't change its value. + void setActiveStateUnsafe(Index offset, bool on) { this->setActiveState(offset, on); } + /// Set the value of the voxel at the given coordinates but don't change its active state. + void setValueOnlyUnsafe(Index offset, const bool& value) { return this->setValueOnly(offset, value); } + /// Mark the voxel at the given offset as active but don't change its value. + void setValueOnUnsafe(Index offset) { this->setValueOn(offset); } + /// Set the value of the voxel at the given coordinates and mark the voxel as active. + void setValueOnUnsafe(Index offset, const bool& value) { this->setValueOn(offset, value); } + /// Mark the voxel at the given offset as inactive but don't change its value. + void setValueOffUnsafe(Index offset) { this->setValueOff(offset); } + /// Set the value of the voxel at the given coordinates and mark the voxel as active. + void setValueOffUnsafe(Index offset, const bool& value) { this->setValueOff(offset, value); } + void resetBackground(bool oldBackground, bool newBackground); void negate() { mBuffer.mData.toggle(); } @@ -1188,12 +1221,18 @@ template inline bool LeafNode::probeValue(const Coord& xyz, bool& val) const { - const Index offset = this->coordToOffset(xyz); + return this->probeValue(this->coordToOffset(xyz), val); +} + +template +inline bool +LeafNode::probeValue(Index offset, bool& val) const +{ + OPENVDB_ASSERT(offset < SIZE); val = mBuffer.mData.isOn(offset); return mValueMask.isOn(offset); } - template inline void LeafNode::setValueOn(const Coord& xyz, bool val) diff --git a/openvdb/openvdb/tree/LeafNodeMask.h b/openvdb/openvdb/tree/LeafNodeMask.h index d044130ab8..b861685f5b 100644 --- a/openvdb/openvdb/tree/LeafNodeMask.h +++ b/openvdb/openvdb/tree/LeafNodeMask.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED #define OPENVDB_TREE_LEAF_NODE_MASK_HAS_BEEN_INCLUDED @@ -112,11 +112,13 @@ class LeafNode /// Return the dimension of child nodes of this LeafNode, which is one for voxels. static Index getChildDim() { return 1; } /// Return the leaf count for this node, which is one. - static Index32 leafCount() { return 1; } + static Index64 leafCount() { return 1; } /// no-op + void nodeCount(std::vector &) const {} + OPENVDB_DEPRECATED_MESSAGE("Use input type std::vector for nodeCount.") void nodeCount(std::vector &) const {} /// Return the non-leaf count for this node, which is zero. - static Index32 nonLeafCount() { return 0; } + static Index64 nonLeafCount() { return 0; } /// Return the number of active voxels. Index64 onVoxelCount() const { return mBuffer.mData.countOn(); } @@ -222,6 +224,10 @@ class LeafNode /// @param xyz the coordinates of the voxel to be probed /// @param[out] val the value of the voxel at the given coordinates bool probeValue(const Coord& xyz, bool& val) const; + /// @brief Return @c true if the voxel at the given offset is active. + /// @param offset the linear offset of the voxel to be probed + /// @param[out] val the value of the voxel at the given coordinates + bool probeValue(Index offset, bool& val) const; /// Return the level (0) at which leaf node values reside. static Index getValueLevel(const Coord&) { return LEVEL; } @@ -277,9 +283,13 @@ class LeafNode void setValuesOff() { mBuffer.mData.setOff(); } /// Return @c true if the voxel at the given coordinates is active. - bool isValueOn(const Coord& xyz) const { return mBuffer.mData.isOn(this->coordToOffset(xyz)); } + bool isValueOn(const Coord& xyz) const { return this->isValueOn(this->coordToOffset(xyz)); } /// Return @c true if the voxel at the given offset is active. bool isValueOn(Index offset) const { OPENVDB_ASSERT(offset < SIZE); return mBuffer.mData.isOn(offset); } + /// Return @c true if the voxel at the given coordinates is inactive. + bool isValueOff(const Coord& xyz) const { return this->isValueOff(this->coordToOffset(xyz)); } + /// Return @c true if the voxel at the given offset is inactive. + bool isValueOff(Index offset) const { OPENVDB_ASSERT(offset < SIZE); return mBuffer.mData.isOff(offset); } /// Return @c false since leaf nodes never contain tiles. static bool hasActiveTiles() { return false; } @@ -440,6 +450,29 @@ class LeafNode /// Return @c true if all of this node's values are inactive. bool isInactive() const { return mBuffer.mData.isOff(); } + // + // Unsafe methods + // + // These methods are not in fact unsafe, but are only offered so that + // the same methods can be called on both internal nodes and leaf nodes. + + /// Return the value of the voxel at the given offset. + const bool& getValueUnsafe(Index offset) const { return this->getValue(offset); } + /// Return true if the voxel at the given offset is active and set value. + bool getValueUnsafe(Index offset, bool& value) const { return this->probeValue(offset, value); } + /// Set the active state of the voxel at the given offset but don't change its value. + void setActiveStateUnsafe(Index offset, bool on) { this->setActiveState(offset, on); } + /// Set the value of the voxel at the given coordinates but don't change its active state. + void setValueOnlyUnsafe(Index offset, const bool& value) { return this->setValueOnly(offset, value); } + /// Mark the voxel at the given offset as active but don't change its value. + void setValueOnUnsafe(Index offset) { this->setValueOn(offset); } + /// Set the value of the voxel at the given coordinates and mark the voxel as active. + void setValueOnUnsafe(Index offset, const bool& value) { this->setValueOn(offset, value); } + /// Mark the voxel at the given offset as inactive but don't change its value. + void setValueOffUnsafe(Index offset) { this->setValueOff(offset); } + /// Set the value of the voxel at the given coordinates and mark the voxel as active. + void setValueOffUnsafe(Index offset, const bool& value) { this->setValueOff(offset, value); } + /// @brief no-op since for this template specialization voxel /// values and states are indistinguishable. void resetBackground(bool, bool) {} @@ -1109,7 +1142,14 @@ template inline bool LeafNode::probeValue(const Coord& xyz, bool& val) const { - const Index offset = this->coordToOffset(xyz); + return this->probeValue(this->coordToOffset(xyz), val); +} + + +template +inline bool +LeafNode::probeValue(Index offset, bool& val) const +{ val = mBuffer.mData.isOn(offset); return val; } diff --git a/openvdb/openvdb/tree/NodeManager.h b/openvdb/openvdb/tree/NodeManager.h index ce483bd7df..1023c00748 100644 --- a/openvdb/openvdb/tree/NodeManager.h +++ b/openvdb/openvdb/tree/NodeManager.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file tree/NodeManager.h /// @@ -107,7 +107,7 @@ class NodeList { // Compute the node counts for each node - std::vector nodeCounts; + std::vector nodeCounts; if (serial) { nodeCounts.reserve(parents.nodeCount()); for (size_t i = 0; i < parents.nodeCount(); i++) { @@ -328,7 +328,7 @@ class NodeList void operator()(const NodeRange& range) const { for (typename NodeRange::Iterator it = range.begin(); it; ++it) { - OpT::template eval(mNodeOp, it); + OpT::eval(mNodeOp, it); } } const NodeOp mNodeOp; @@ -348,7 +348,7 @@ class NodeList void operator()(const NodeRange& range) const { for (typename NodeRange::Iterator it = range.begin(); it; ++it) { - OpT::template eval(mNodeOp, it); + OpT::eval(mNodeOp, it); } } const NodeOp& mNodeOp; @@ -373,7 +373,7 @@ class NodeList void operator()(const NodeRange& range) { for (typename NodeRange::Iterator it = range.begin(); it; ++it) { - OpT::template eval(*mNodeOp, it); + OpT::eval(*mNodeOp, it); } } void join(const NodeReducer& other) diff --git a/openvdb/openvdb/tree/NodeUnion.h b/openvdb/openvdb/tree/NodeUnion.h index 7901e1050c..a2506f12b6 100644 --- a/openvdb/openvdb/tree/NodeUnion.h +++ b/openvdb/openvdb/tree/NodeUnion.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file NodeUnion.h /// diff --git a/openvdb/openvdb/tree/RootNode.h b/openvdb/openvdb/tree/RootNode.h index 0d182b5864..8bbf2ee618 100644 --- a/openvdb/openvdb/tree/RootNode.h +++ b/openvdb/openvdb/tree/RootNode.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// /// @file RootNode.h /// @@ -140,6 +140,7 @@ class RootNode NodeStruct(ChildType& c): child(&c) {} NodeStruct(const Tile& t): child(nullptr), tile(t) {} NodeStruct(const NodeStruct&) = default; + NodeStruct(NodeStruct&&) noexcept = default; NodeStruct& operator=(const NodeStruct&) = default; ~NodeStruct() {} ///< @note doesn't delete child @@ -483,14 +484,19 @@ class RootNode template static bool hasCompatibleValueType(const RootNode& other); - Index32 leafCount() const; - Index32 nonLeafCount() const; + Index64 leafCount() const; + Index64 nonLeafCount() const; Index32 childCount() const; + Index32 tileCount() const; + Index32 activeTileCount() const; + Index32 inactiveTileCount() const; Index64 onVoxelCount() const; Index64 offVoxelCount() const; Index64 onLeafVoxelCount() const; Index64 offLeafVoxelCount() const; Index64 onTileCount() const; + void nodeCount(std::vector &vec) const; + OPENVDB_DEPRECATED_MESSAGE("Use input type std::vector for nodeCount.") void nodeCount(std::vector &vec) const; bool isValueOn(const Coord& xyz) const; @@ -706,6 +712,12 @@ class RootNode template void addTileAndCache(Index level, const Coord& xyz, const ValueType&, bool state, AccessorT&); + /// @brief Delete any child or tile containing voxel (x, y, z) at the root level. + /// Do nothing if no child or tile was found. + /// @warning This method will invalidate any existing RootNode iterators. + /// @return @c true if child or tile was deleted + bool deleteChildOrTile(const Coord& xyz); + /// @brief Return a pointer to the leaf node that contains voxel (x, y, z). /// If no such node exists, create one that preserves the values and /// active states of all voxels. @@ -724,9 +736,20 @@ class RootNode template NodeT* probeNode(const Coord& xyz); template + const NodeT* probeNode(const Coord& xyz) const; + template const NodeT* probeConstNode(const Coord& xyz) const; //@} + //@{ + /// @brief Return a pointer to the root child node that contains voxel (x, y, z). + /// If no such node exists, query and set the tile value and active status and + /// return @c nullptr. + bool probe(const Coord& xyz, ChildNodeType*& child, ValueType& value, bool& active); + bool probeConst(const Coord& xyz, const ChildNodeType*& child, ValueType& value, bool& active) const; + bool probe(const Coord& xyz, const ChildNodeType*& child, ValueType& value, bool& active) const { return this->probeConst(xyz, child, value, active); } + //} + //@{ /// @brief Same as probeNode() but, if necessary, update the given accessor with pointers /// to the nodes along the path from the root node to the node containing the coordinate. @@ -736,12 +759,20 @@ class RootNode const NodeT* probeConstNodeAndCache(const Coord& xyz, AccessorT& acc) const; //@} + //@{ + /// @brief Return a pointer to the root child node that contains voxel (x, y, z). + /// If no such node exists, return @c nullptr. + ChildNodeType* probeChild(const Coord& xyz); + const ChildNodeType* probeConstChild(const Coord& xyz) const; + const ChildNodeType* probeChild(const Coord& xyz) const { return this->probeConstChild(xyz); } + //@} + //@{ /// @brief Return a pointer to the leaf node that contains voxel (x, y, z). /// If no such node exists, return @c nullptr. LeafNodeType* probeLeaf(const Coord& xyz); const LeafNodeType* probeConstLeaf(const Coord& xyz) const; - const LeafNodeType* probeLeaf(const Coord& xyz) const; + const LeafNodeType* probeLeaf(const Coord& xyz) const { return this->probeConstLeaf(xyz); } //@} //@{ @@ -755,6 +786,35 @@ class RootNode const LeafNodeType* probeLeafAndCache(const Coord& xyz, AccessorT& acc) const; //@} + // + // Unsafe methods + // + // WARNING: For improved performance, these unsafe methods assume that the tile + // or child exists. If used incorrectly, this can cause the application to crash. + // Always use the safer alternative method(s) unless you really know what you're doing. + // Enabling OpenVDB asserts will catch where assumptions are incorrectly invalidated. + + /// @brief Return the tile value at the given coordinate. + /// @note Use cbeginValueAll() for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + const ValueType& getTileValueUnsafe(const Coord& xyz) const; + /// @brief Return the tile value and active state at the given coordinate. + /// @note Use cbeginValueAll() for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + bool getTileValueUnsafe(const Coord& xyz, ValueType& value) const; + /// @brief Return the child node at the given coordinate. + /// @note Use beginChildAll() for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + ChildNodeType* getChildUnsafe(const Coord& xyz); + /// @brief Return the child node at the given coordinate. + /// @note Use cbeginChildAll() for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + const ChildNodeType* getConstChildUnsafe(const Coord& xyz) const; + /// @brief Return the child node at the given coordinate. + /// @note Use cbeginChildAll() for a safer alternative. + /// @warning This method should only be used by experts seeking low-level optimizations. + const ChildNodeType* getChildUnsafe(const Coord& xyz) const; + // // Aux methods @@ -881,7 +941,6 @@ class RootNode void combine2(const RootNode& other0, const OtherRootNode& other1, CombineOp& op, bool prune = false); -#if OPENVDB_ABI_VERSION_NUMBER >= 10 /// Return the grid index coordinates of this node's local origin. const Coord& origin() const { return mOrigin; } /// @brief change the origin on this root node @@ -890,7 +949,12 @@ class RootNode /// @warning This method will throw if the origin is non-zero, since /// other tools do not yet support variable offsets. void setOrigin(const Coord &origin); -#endif + + /// Return a MapType key for the given coordinates, offset by the mOrigin. + Coord coordToKey(const Coord& xyz) const { return (xyz - mOrigin) & ~(ChildType::DIM - 1); } + + /// Return @c true if this node's mTable contains the given key. + bool hasKey(const Coord& key) const { return mTable.find(key) != mTable.end(); } private: /// During topology-only construction, access is needed @@ -900,32 +964,9 @@ class RootNode template friend struct RootNodeCopyHelper; template friend struct RootNodeCombineHelper; - /// Currently no-op, but can be used to define empty and delete keys for mTable - void initTable() {} - //@{ - /// @internal Used by doVisit2(). - void resetTable(MapType& table) { mTable.swap(table); table.clear(); } - void resetTable(const MapType&) const {} - //@} - - Index getChildCount() const; - Index getTileCount() const; - Index getActiveTileCount() const; - Index getInactiveTileCount() const; - -#if OPENVDB_ABI_VERSION_NUMBER < 10 - /// Static method that returns a MapType key for the given coordinates. - static Coord coordToKey(const Coord& xyz) {return xyz & ~(ChildType::DIM - 1); } -#else - /// Return a MapType key for the given coordinates, offset by the mOrigin. - Coord coordToKey(const Coord& xyz) const { return (xyz - mOrigin) & ~(ChildType::DIM - 1); } -#endif - /// Insert this node's mTable keys into the given set. void insertKeys(CoordSet&) const; - /// Return @c true if this node's mTable contains the given key. - bool hasKey(const Coord& key) const { return mTable.find(key) != mTable.end(); } //@{ /// @brief Look up the given key in this node's mTable. /// @return an iterator pointing to the matching mTable entry or to mTable.end(). @@ -963,9 +1004,7 @@ class RootNode MapType mTable; ValueType mBackground; -#if OPENVDB_ABI_VERSION_NUMBER >= 10 Coord mOrigin; -#endif /// Transient Data (not serialized) Index32 mTransientData = 0; }; // end of RootNode class @@ -1032,11 +1071,8 @@ template inline RootNode::RootNode() : mBackground(zeroVal()) -#if OPENVDB_ABI_VERSION_NUMBER >= 10 , mOrigin(0, 0, 0) -#endif { - this->initTable(); } @@ -1044,11 +1080,8 @@ template inline RootNode::RootNode(const ValueType& background) : mBackground(background) -#if OPENVDB_ABI_VERSION_NUMBER >= 10 , mOrigin(0, 0, 0) -#endif { - this->initTable(); } @@ -1058,28 +1091,23 @@ inline RootNode::RootNode(const RootNode& other, const ValueType& backgd, const ValueType& foregd, TopologyCopy) : mBackground(backgd) -#if OPENVDB_ABI_VERSION_NUMBER >= 10 , mOrigin(other.mOrigin) -#endif , mTransientData(other.mTransientData) { using OtherRootT = RootNode; -#if OPENVDB_ABI_VERSION_NUMBER >= 10 if (mOrigin != Coord(0,0,0)) { OPENVDB_THROW(ValueError, "RootNode::RootNode: non-zero offsets are currently not supported"); } -#endif enforceSameConfiguration(other); const Tile bgTile(backgd, /*active=*/false), fgTile(foregd, true); - this->initTable(); for (typename OtherRootT::MapCIter i=other.mTable.begin(), e=other.mTable.end(); i != e; ++i) { - mTable[i->first] = OtherRootT::isTile(i) + mTable.emplace(i->first, OtherRootT::isTile(i) ? NodeStruct(OtherRootT::isTileOn(i) ? fgTile : bgTile) - : NodeStruct(*(new ChildT(OtherRootT::getChild(i), backgd, foregd, TopologyCopy()))); + : NodeStruct(*(new ChildT(OtherRootT::getChild(i), backgd, foregd, TopologyCopy())))); } } @@ -1090,27 +1118,24 @@ inline RootNode::RootNode(const RootNode& other, const ValueType& backgd, TopologyCopy) : mBackground(backgd) -#if OPENVDB_ABI_VERSION_NUMBER >= 10 , mOrigin(other.mOrigin) -#endif , mTransientData(other.mTransientData) { using OtherRootT = RootNode; -#if OPENVDB_ABI_VERSION_NUMBER >= 10 if (mOrigin != Coord(0,0,0)) { OPENVDB_THROW(ValueError, "RootNode::RootNode: non-zero offsets are currently not supported"); } -#endif enforceSameConfiguration(other); const Tile bgTile(backgd, /*active=*/false), fgTile(backgd, true); - this->initTable(); + for (typename OtherRootT::MapCIter i=other.mTable.begin(), e=other.mTable.end(); i != e; ++i) { - mTable[i->first] = OtherRootT::isTile(i) + mTable.emplace(i->first, + OtherRootT::isTile(i) ? NodeStruct(OtherRootT::isTileOn(i) ? fgTile : bgTile) - : NodeStruct(*(new ChildT(OtherRootT::getChild(i), backgd, TopologyCopy()))); + : NodeStruct(*(new ChildT(OtherRootT::getChild(i), backgd, TopologyCopy())))); } } @@ -1146,7 +1171,6 @@ struct RootNodeCopyHelper { using ValueT = typename RootT::ValueType; using ChildT = typename RootT::ChildNodeType; - using NodeStruct = typename RootT::NodeStruct; using Tile = typename RootT::Tile; using OtherValueT = typename OtherRootT::ValueType; using OtherMapCIter = typename OtherRootT::MapCIter; @@ -1158,26 +1182,23 @@ struct RootNodeCopyHelper }; self.mBackground = Local::convertValue(other.mBackground); -#if OPENVDB_ABI_VERSION_NUMBER >= 10 if (other.mOrigin != Coord(0,0,0)) { OPENVDB_THROW(ValueError, "RootNodeCopyHelper::copyWithValueConversion: non-zero offsets are currently not supported"); } self.mOrigin = other.mOrigin; -#endif self.mTransientData = other.mTransientData; self.clear(); - self.initTable(); for (OtherMapCIter i = other.mTable.begin(), e = other.mTable.end(); i != e; ++i) { if (other.isTile(i)) { // Copy the other node's tile, but convert its value to this node's ValueType. const OtherTile& otherTile = other.getTile(i); - self.mTable[i->first] = NodeStruct( + self.mTable.emplace(i->first, Tile(Local::convertValue(otherTile.value), otherTile.active)); } else { // Copy the other node's child, but convert its values to this node's ValueType. - self.mTable[i->first] = NodeStruct(*(new ChildT(other.getChild(i)))); + self.mTable.emplace(i->first, *(new ChildT(other.getChild(i)))); } } } @@ -1191,20 +1212,17 @@ RootNode::operator=(const RootNode& other) { if (&other != this) { mBackground = other.mBackground; -#if OPENVDB_ABI_VERSION_NUMBER >= 10 mOrigin = other.mOrigin; if (mOrigin != Coord(0,0,0)) { OPENVDB_THROW(ValueError, "RootNode::operator=: non-zero offsets are currently not supported"); } -#endif mTransientData = other.mTransientData; this->clear(); - this->initTable(); for (MapCIter i = other.mTable.begin(), e = other.mTable.end(); i != e; ++i) { - mTable[i->first] = - isTile(i) ? NodeStruct(getTile(i)) : NodeStruct(*(new ChildT(getChild(i)))); + mTable.emplace(i->first, + isTile(i) ? NodeStruct(getTile(i)) : NodeStruct(*(new ChildT(getChild(i))))); } } return *this; @@ -1321,8 +1339,8 @@ inline typename RootNode::MapIter RootNode::findOrAddCoord(const Coord& xyz) { const Coord key = coordToKey(xyz); - std::pair result = mTable.insert( - typename MapType::value_type(key, NodeStruct(Tile(mBackground, /*active=*/false)))); + std::pair result = mTable.try_emplace(key, + Tile(mBackground, /*active=*/false)); return result.first; } @@ -1332,8 +1350,8 @@ inline bool RootNode::expand(const Coord& xyz) { const Coord key = coordToKey(xyz); - std::pair result = mTable.insert( - typename MapType::value_type(key, NodeStruct(Tile(mBackground, /*active=*/false)))); + std::pair result = mTable.try_emplace(key, + Tile(mBackground, /*active=*/false)); return result.second; // return true if the key did not already exist } @@ -1524,43 +1542,38 @@ RootNode::evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels) const template -inline Index -RootNode::getChildCount() const { - return this->childCount(); -} - - -template -inline Index -RootNode::getTileCount() const +inline Index64 +RootNode::leafCount() const { - Index sum = 0; + Index64 sum = 0; for (MapCIter i = mTable.begin(), e = mTable.end(); i != e; ++i) { - if (isTile(i)) ++sum; + if (isChild(i)) sum += getChild(i).leafCount(); } return sum; } template -inline Index -RootNode::getActiveTileCount() const +inline Index64 +RootNode::nonLeafCount() const { - Index sum = 0; - for (MapCIter i = mTable.begin(), e = mTable.end(); i != e; ++i) { - if (isTileOn(i)) ++sum; + Index64 sum = 1; + if (ChildT::LEVEL != 0) { + for (MapCIter i = mTable.begin(), e = mTable.end(); i != e; ++i) { + if (isChild(i)) sum += getChild(i).nonLeafCount(); + } } return sum; } template -inline Index -RootNode::getInactiveTileCount() const +inline Index32 +RootNode::childCount() const { Index sum = 0; for (MapCIter i = mTable.begin(), e = mTable.end(); i != e; ++i) { - if (isTileOff(i)) ++sum; + if (isChild(i)) ++sum; } return sum; } @@ -1568,11 +1581,11 @@ RootNode::getInactiveTileCount() const template inline Index32 -RootNode::leafCount() const +RootNode::tileCount() const { Index32 sum = 0; for (MapCIter i = mTable.begin(), e = mTable.end(); i != e; ++i) { - if (isChild(i)) sum += getChild(i).leafCount(); + if (isTile(i)) ++sum; } return sum; } @@ -1580,13 +1593,11 @@ RootNode::leafCount() const template inline Index32 -RootNode::nonLeafCount() const +RootNode::activeTileCount() const { - Index32 sum = 1; - if (ChildT::LEVEL != 0) { - for (MapCIter i = mTable.begin(), e = mTable.end(); i != e; ++i) { - if (isChild(i)) sum += getChild(i).nonLeafCount(); - } + Index32 sum = 0; + for (MapCIter i = mTable.begin(), e = mTable.end(); i != e; ++i) { + if (isTileOn(i)) ++sum; } return sum; } @@ -1594,11 +1605,11 @@ RootNode::nonLeafCount() const template inline Index32 -RootNode::childCount() const +RootNode::inactiveTileCount() const { - Index sum = 0; + Index32 sum = 0; for (MapCIter i = mTable.begin(), e = mTable.end(); i != e; ++i) { - if (isChild(i)) ++sum; + if (isTileOff(i)) ++sum; } return sum; } @@ -1674,6 +1685,22 @@ RootNode::onTileCount() const return sum; } +template +inline void +RootNode::nodeCount(std::vector &vec) const +{ + OPENVDB_ASSERT(vec.size() > LEVEL); + Index64 sum = 0; + for (MapCIter i = mTable.begin(), e = mTable.end(); i != e; ++i) { + if (isChild(i)) { + ++sum; + getChild(i).nodeCount(vec); + } + } + vec[LEVEL] = 1;// one root node + vec[ChildNodeType::LEVEL] = sum; +} + template inline void RootNode::nodeCount(std::vector &vec) const @@ -1683,7 +1710,9 @@ RootNode::nodeCount(std::vector &vec) const for (MapCIter i = mTable.begin(), e = mTable.end(); i != e; ++i) { if (isChild(i)) { ++sum; + OPENVDB_NO_DEPRECATION_WARNING_BEGIN getChild(i).nodeCount(vec); + OPENVDB_NO_DEPRECATION_WARNING_END } } vec[LEVEL] = 1;// one root node @@ -1790,11 +1819,12 @@ inline void RootNode::setActiveState(const Coord& xyz, bool on) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { if (on) { child = new ChildT(xyz, mBackground); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else { // Nothing to do; (x, y, z) is background and therefore already inactive. } @@ -1813,11 +1843,12 @@ inline void RootNode::setActiveStateAndCache(const Coord& xyz, bool on, AccessorT& acc) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { if (on) { child = new ChildT(xyz, mBackground); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else { // Nothing to do; (x, y, z) is background and therefore already inactive. } @@ -1839,11 +1870,12 @@ inline void RootNode::setValueOff(const Coord& xyz, const ValueType& value) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { if (!math::isExactlyEqual(mBackground, value)) { child = new ChildT(xyz, mBackground); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } } else if (isChild(iter)) { child = &getChild(iter); @@ -1860,11 +1892,12 @@ inline void RootNode::setValueOffAndCache(const Coord& xyz, const ValueType& value, AccessorT& acc) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { if (!math::isExactlyEqual(mBackground, value)) { child = new ChildT(xyz, mBackground); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } } else if (isChild(iter)) { child = &getChild(iter); @@ -1884,10 +1917,11 @@ inline void RootNode::setValueOn(const Coord& xyz, const ValueType& value) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { child = new ChildT(xyz, mBackground); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else if (isChild(iter)) { child = &getChild(iter); } else if (isTileOff(iter) || !math::isExactlyEqual(getTile(iter).value, value)) { @@ -1903,10 +1937,11 @@ inline void RootNode::setValueAndCache(const Coord& xyz, const ValueType& value, AccessorT& acc) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { child = new ChildT(xyz, mBackground); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else if (isChild(iter)) { child = &getChild(iter); } else if (isTileOff(iter) || !math::isExactlyEqual(getTile(iter).value, value)) { @@ -1925,10 +1960,11 @@ inline void RootNode::setValueOnly(const Coord& xyz, const ValueType& value) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { child = new ChildT(xyz, mBackground); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else if (isChild(iter)) { child = &getChild(iter); } else if (!math::isExactlyEqual(getTile(iter).value, value)) { @@ -1944,10 +1980,11 @@ inline void RootNode::setValueOnlyAndCache(const Coord& xyz, const ValueType& value, AccessorT& acc) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { child = new ChildT(xyz, mBackground); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else if (isChild(iter)) { child = &getChild(iter); } else if (!math::isExactlyEqual(getTile(iter).value, value)) { @@ -1967,10 +2004,11 @@ inline void RootNode::modifyValue(const Coord& xyz, const ModifyOp& op) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { child = new ChildT(xyz, mBackground); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else if (isChild(iter)) { child = &getChild(iter); } else { @@ -1999,10 +2037,11 @@ inline void RootNode::modifyValueAndCache(const Coord& xyz, const ModifyOp& op, AccessorT& acc) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { child = new ChildT(xyz, mBackground); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else if (isChild(iter)) { child = &getChild(iter); } else { @@ -2035,10 +2074,11 @@ inline void RootNode::modifyValueAndActiveState(const Coord& xyz, const ModifyOp& op) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { child = new ChildT(xyz, mBackground); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else if (isChild(iter)) { child = &getChild(iter); } else { @@ -2063,10 +2103,11 @@ RootNode::modifyValueAndActiveStateAndCache( const Coord& xyz, const ModifyOp& op, AccessorT& acc) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { child = new ChildT(xyz, mBackground); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else if (isChild(iter)) { child = &getChild(iter); } else { @@ -2154,13 +2195,13 @@ RootNode::fill(const CoordBBox& bbox, const ValueType& value, bool activ // No child or tile exists. Create a child and initialize it // with the background value. child = new ChildT(xyz, mBackground); - mTable[tileMin] = NodeStruct(*child); + mTable.emplace(tileMin, *child); } else if (isTile(iter)) { // Replace the tile with a newly-created child that is filled // with the tile's value and active state. const Tile& tile = getTile(iter); child = new ChildT(xyz, tile.value, tile.active); - mTable[tileMin] = NodeStruct(*child); + setChild(iter, *child); } else if (isChild(iter)) { child = &getChild(iter); } @@ -2314,7 +2355,7 @@ RootNode::writeTopology(std::ostream& os, bool toHalf) const } io::setGridBackgroundValuePtr(os, &mBackground); - const Index numTiles = this->getTileCount(), numChildren = this->childCount(); + const Index numTiles = this->tileCount(), numChildren = this->childCount(); os.write(reinterpret_cast(&numTiles), sizeof(Index)); os.write(reinterpret_cast(&numChildren), sizeof(Index)); @@ -2361,7 +2402,6 @@ RootNode::readTopology(std::istream& is, bool fromHalf) is.read(reinterpret_cast(rangeMin.asPointer()), 3 * sizeof(Int32)); is.read(reinterpret_cast(rangeMax.asPointer()), 3 * sizeof(Int32)); - this->initTable(); Index tableSize = 0, log2Dim[4] = { 0, 0, 0, 0 }; Int32 offset[3]; for (int i = 0; i < 3; ++i) { @@ -2394,14 +2434,14 @@ RootNode::readTopology(std::istream& is, bool fromHalf) // Read in and insert a child node. ChildT* child = new ChildT(PartialCreate(), origin, mBackground); child->readTopology(is); - mTable[origin] = NodeStruct(*child); + mTable.emplace(origin, *child); } else { // Read in a tile value and insert a tile, but only if the value // is either active or non-background. ValueType value; is.read(reinterpret_cast(&value), sizeof(ValueType)); if (valueMask.isOn(i) || (!math::isApproxEqual(value, mBackground))) { - mTable[origin] = NodeStruct(Tile(value, valueMask.isOn(i))); + mTable.emplace(origin, Tile(value, valueMask.isOn(i))); } } } @@ -2428,7 +2468,7 @@ RootNode::readTopology(std::istream& is, bool fromHalf) is.read(reinterpret_cast(vec), 3 * sizeof(Int32)); is.read(reinterpret_cast(&value), sizeof(ValueType)); is.read(reinterpret_cast(&active), sizeof(bool)); - mTable[Coord(vec)] = NodeStruct(Tile(value, active)); + mTable.emplace(Coord(vec), Tile(value, active)); } // Read child nodes. @@ -2437,7 +2477,7 @@ RootNode::readTopology(std::istream& is, bool fromHalf) Coord origin(vec); ChildT* child = new ChildT(PartialCreate(), origin, mBackground); child->readTopology(is, fromHalf); - mTable[Coord(vec)] = NodeStruct(*child); + mTable.emplace(Coord(vec), *child); } return true; // not empty @@ -2575,14 +2615,15 @@ RootNode::addLeaf(LeafNodeType* leaf) if (leaf == nullptr) return; ChildT* child = nullptr; const Coord& xyz = leaf->origin(); - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { if (ChildT::LEVEL>0) { child = new ChildT(xyz, mBackground, false); } else { child = reinterpret_cast(leaf); } - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else if (isChild(iter)) { if (ChildT::LEVEL>0) { child = &getChild(iter); @@ -2610,14 +2651,15 @@ RootNode::addLeafAndCache(LeafNodeType* leaf, AccessorT& acc) if (leaf == nullptr) return; ChildT* child = nullptr; const Coord& xyz = leaf->origin(); - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { if (ChildT::LEVEL>0) { child = new ChildT(xyz, mBackground, false); } else { child = reinterpret_cast(leaf); } - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else if (isChild(iter)) { if (ChildT::LEVEL>0) { child = &getChild(iter); @@ -2643,34 +2685,34 @@ RootNode::addChild(ChildT* child) { if (!child) return false; const Coord& xyz = child->origin(); - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) {//background - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else {//child or tile setChild(iter, *child);//this also deletes the existing child node } return true; } -#if OPENVDB_ABI_VERSION_NUMBER >= 10 template inline void RootNode::setOrigin(const Coord &origin) { - mOrigin = origin; - if (mOrigin != Coord(0,0,0)) { + if (origin != Coord(0,0,0)) { OPENVDB_THROW(ValueError, "RootNode::setOrigin: non-zero offsets are currently not supported"); } + mOrigin = origin; } -#endif template inline void RootNode::addTile(const Coord& xyz, const ValueType& value, bool state) { - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) {//background - mTable[this->coordToKey(xyz)] = NodeStruct(Tile(value, state)); + mTable.emplace(key, Tile(value, state)); } else {//child or tile setTile(iter, Tile(value, state));//this also deletes the existing child node } @@ -2682,14 +2724,15 @@ RootNode::addTile(Index level, const Coord& xyz, const ValueType& value, bool state) { if (LEVEL >= level) { - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) {//background if (LEVEL > level) { ChildT* child = new ChildT(xyz, mBackground, false); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); child->addTile(level, xyz, value, state); } else { - mTable[this->coordToKey(xyz)] = NodeStruct(Tile(value, state)); + mTable.emplace(key, Tile(value, state)); } } else if (isChild(iter)) {//child if (LEVEL > level) { @@ -2717,15 +2760,16 @@ RootNode::addTileAndCache(Index level, const Coord& xyz, const ValueType bool state, AccessorT& acc) { if (LEVEL >= level) { - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) {//background if (LEVEL > level) { ChildT* child = new ChildT(xyz, mBackground, false); acc.insert(xyz, child); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); child->addTileAndCache(level, xyz, value, state, acc); } else { - mTable[this->coordToKey(xyz)] = NodeStruct(Tile(value, state)); + mTable.emplace(key, Tile(value, state)); } } else if (isChild(iter)) {//child if (LEVEL > level) { @@ -2749,6 +2793,22 @@ RootNode::addTileAndCache(Index level, const Coord& xyz, const ValueType } +template +inline bool +RootNode::deleteChildOrTile(const Coord& xyz) +{ + Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); + if (iter != mTable.end()) { + // the child must be deleted to prevent a memory leak + if (isChild(iter)) delete iter->second.child; + mTable.erase(iter); + return true; + } + return false; +} + + //////////////////////////////////////// @@ -2757,10 +2817,11 @@ inline typename ChildT::LeafNodeType* RootNode::touchLeaf(const Coord& xyz) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { child = new ChildT(xyz, mBackground, false); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else if (isChild(iter)) { child = &getChild(iter); } else { @@ -2777,10 +2838,11 @@ inline typename ChildT::LeafNodeType* RootNode::touchLeafAndCache(const Coord& xyz, AccessorT& acc) { ChildT* child = nullptr; - MapIter iter = this->findCoord(xyz); + const Coord key = this->coordToKey(xyz); + MapIter iter = this->findKey(key); if (iter == mTable.end()) { child = new ChildT(xyz, mBackground, false); - mTable[this->coordToKey(xyz)] = NodeStruct(*child); + mTable.emplace(key, *child); } else if (isChild(iter)) { child = &getChild(iter); } else { @@ -2813,6 +2875,15 @@ RootNode::probeNode(const Coord& xyz) } +template +template +inline const NodeT* +RootNode::probeNode(const Coord& xyz) const +{ + return this->template probeConstNode(xyz); +} + + template template inline const NodeT* @@ -2831,6 +2902,62 @@ RootNode::probeConstNode(const Coord& xyz) const } +template +inline bool +RootNode::probe(const Coord& xyz, ChildNodeType*& child, ValueType& value, bool& active) +{ + MapIter iter = this->findCoord(xyz); + if (iter == mTable.end()) { + child = nullptr; + return false; + } else if (isChild(iter)) { + child = &getChild(iter); + return true; + } + const Tile& tile = getTile(iter); + child = nullptr; + value = tile.value; + active = tile.active; + return true; +} + + +template +inline bool +RootNode::probeConst(const Coord& xyz, const ChildNodeType*& child, ValueType& value, bool& active) const +{ + MapCIter iter = this->findCoord(xyz); + if (iter == mTable.end()) { + child = nullptr; + return false; + } else if (isChild(iter)) { + child = &getChild(iter); + return true; + } + const Tile& tile = getTile(iter); + child = nullptr; + value = tile.value; + active = tile.active; + return true; +} + + +template +inline ChildT* +RootNode::probeChild(const Coord& xyz) +{ + return this->template probeNode(xyz); +} + + +template +inline const ChildT* +RootNode::probeConstChild(const Coord& xyz) const +{ + return this->template probeConstNode(xyz); +} + + template inline typename ChildT::LeafNodeType* RootNode::probeLeaf(const Coord& xyz) @@ -2914,6 +3041,64 @@ RootNode::probeConstNodeAndCache(const Coord& xyz, AccessorT& acc) const //////////////////////////////////////// + +template +inline const typename ChildT::ValueType& +RootNode::getTileValueUnsafe(const Coord& xyz) const +{ + MapCIter iter = this->findCoord(xyz); + OPENVDB_ASSERT(iter != mTable.end()); + OPENVDB_ASSERT(isTile(iter)); + return getTile(iter).value; +} + + +template +inline bool +RootNode::getTileValueUnsafe(const Coord& xyz, ValueType& value) const +{ + MapCIter iter = this->findCoord(xyz); + OPENVDB_ASSERT(iter != mTable.end()); + OPENVDB_ASSERT(isTile(iter)); + const Tile& tile = getTile(iter); + value = tile.value; + return tile.active; +} + + +template +inline ChildT* +RootNode::getChildUnsafe(const Coord& xyz) +{ + MapIter iter = this->findCoord(xyz); + OPENVDB_ASSERT(iter != mTable.end()); + OPENVDB_ASSERT(isChild(iter)); + return &getChild(iter); +} + + +template +inline const ChildT* +RootNode::getConstChildUnsafe(const Coord& xyz) const +{ + MapCIter iter = this->findCoord(xyz); + OPENVDB_ASSERT(iter != mTable.end()); + OPENVDB_ASSERT(isChild(iter)); + return &getChild(iter); +} + + +template +inline const ChildT* +RootNode::getChildUnsafe(const Coord& xyz) const +{ + return this->getConstChildUnsafe(xyz); +} + + +//////////////////////////////////////// + + template template inline void @@ -3021,7 +3206,7 @@ RootNode::merge(RootNode& other) if (j == mTable.end()) { // insert other node's child ChildNodeType& child = stealChild(i, Tile(other.mBackground, /*on=*/false)); child.resetBackground(other.mBackground, mBackground); - mTable[i->first] = NodeStruct(child); + mTable.emplace(i->first, child); } else if (isTile(j)) { if (isTileOff(j)) { // replace inactive tile with other node's child ChildNodeType& child = stealChild(i, Tile(other.mBackground, /*on=*/false)); @@ -3034,7 +3219,7 @@ RootNode::merge(RootNode& other) } } else if (other.isTileOn(i)) { if (j == mTable.end()) { // insert other node's active tile - mTable[i->first] = i->second; + mTable.emplace(i->first, i->second); } else if (!isTileOn(j)) { // Replace anything except an active tile with the other node's active tile. setTile(j, Tile(other.getTile(i).value, true)); @@ -3050,7 +3235,7 @@ RootNode::merge(RootNode& other) if (j == mTable.end()) { // insert other node's child ChildNodeType& child = stealChild(i, Tile(other.mBackground, /*on=*/false)); child.resetBackground(other.mBackground, mBackground); - mTable[i->first] = NodeStruct(child); + mTable.emplace(i->first, child); } else if (isTile(j)) { // replace tile with other node's child ChildNodeType& child = stealChild(i, Tile(other.mBackground, /*on=*/false)); child.resetBackground(other.mBackground, mBackground); @@ -3071,7 +3256,7 @@ RootNode::merge(RootNode& other) // Steal and insert the other node's child. ChildNodeType& child = stealChild(i, Tile(other.mBackground, /*on=*/false)); child.resetBackground(other.mBackground, mBackground); - mTable[i->first] = NodeStruct(child); + mTable.emplace(i->first, child); } else if (isTile(j)) { // Replace this node's tile with the other node's child. ChildNodeType& child = stealChild(i, Tile(other.mBackground, /*on=*/false)); @@ -3091,7 +3276,7 @@ RootNode::merge(RootNode& other) } else if (other.isTileOn(i)) { if (j == mTable.end()) { // Insert a copy of the other node's active tile. - mTable[i->first] = i->second; + mTable.emplace(i->first, i->second); } else if (isTileOff(j)) { // Replace this node's inactive tile with a copy of the other's active tile. setTile(j, Tile(other.getTile(i).value, true)); @@ -3130,7 +3315,7 @@ RootNode::topologyUnion(const RootNode& other, const boo MapIter j = mTable.find(i->first); if (other.isChild(i)) { if (j == mTable.end()) { // create child branch with identical topology - mTable[i->first] = NodeStruct( + mTable.emplace(i->first, *(new ChildT(other.getChild(i), mBackground, TopologyCopy()))); } else if (this->isChild(j)) { // union with child branch this->getChild(j).topologyUnion(other.getChild(i), preserveTiles); @@ -3144,7 +3329,7 @@ RootNode::topologyUnion(const RootNode& other, const boo } } else if (other.isTileOn(i)) { // other is an active tile if (j == mTable.end()) { // insert an active tile - mTable[i->first] = NodeStruct(Tile(mBackground, true)); + mTable.emplace(i->first, Tile(mBackground, true)); } else if (this->isChild(j)) { this->getChild(j).setValuesOn(); } else if (this->isTileOff(j)) { diff --git a/openvdb/openvdb/tree/Tree.h b/openvdb/openvdb/tree/Tree.h index 44e77c5307..9db13edcc2 100644 --- a/openvdb/openvdb/tree/Tree.h +++ b/openvdb/openvdb/tree/Tree.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file tree/Tree.h @@ -102,7 +102,11 @@ class OPENVDB_API TreeBase /// @sa readNonresidentBuffers, io::File::open virtual void clipUnallocatedNodes() = 0; /// Return the total number of unallocated leaf nodes residing in this tree. +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + virtual Index64 unallocatedLeafCount() const = 0; +#else virtual Index32 unallocatedLeafCount() const = 0; +#endif // @@ -113,13 +117,25 @@ class OPENVDB_API TreeBase /// A tree with only a root node and leaf nodes has depth 2, for example. virtual Index treeDepth() const = 0; /// Return the number of leaf nodes. +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + virtual Index64 leafCount() const = 0; +#else virtual Index32 leafCount() const = 0; +#endif /// Return a vector with node counts. The number of nodes of type NodeType /// is given as element NodeType::LEVEL in the return vector. Thus, the size /// of this vector corresponds to the height (or depth) of this tree. +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + virtual std::vector nodeCount() const = 0; +#else virtual std::vector nodeCount() const = 0; +#endif /// Return the number of non-leaf nodes. +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + virtual Index64 nonLeafCount() const = 0; +#else virtual Index32 nonLeafCount() const = 0; +#endif /// Return the number of active voxels stored in leaf nodes. virtual Index64 activeLeafVoxelCount() const = 0; /// Return the number of inactive voxels stored in leaf nodes. @@ -188,6 +204,11 @@ class Tree: public TreeBase static const Index DEPTH = RootNodeType::LEVEL + 1; + using Accessor = ValueAccessor; + using ConstAccessor = ValueAccessor; + using UnsafeAccessor = ValueAccessor; + using ConstUnsafeAccessor = ValueAccessor; + /// @brief ValueConverter::Type is the type of a tree having the same /// hierarchy as this tree but a different value type, T. /// @@ -338,18 +359,37 @@ class Tree: public TreeBase /// A tree with only a root node and leaf nodes has depth 2, for example. Index treeDepth() const override { return DEPTH; } /// Return the number of leaf nodes. - Index32 leafCount() const override { return mRoot.leafCount(); } +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + Index64 leafCount() const override { return mRoot.leafCount(); } +#else + Index32 leafCount() const override { return static_cast(mRoot.leafCount()); } +#endif /// Return a vector with node counts. The number of nodes of type NodeType /// is given as element NodeType::LEVEL in the return vector. Thus, the size /// of this vector corresponds to the height (or depth) of this tree. +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + std::vector nodeCount() const override + { + std::vector vec(DEPTH, 0); + mRoot.nodeCount( vec ); + return vec;// Named Return Value Optimization + } +#else std::vector nodeCount() const override { std::vector vec(DEPTH, 0); + OPENVDB_NO_DEPRECATION_WARNING_BEGIN mRoot.nodeCount( vec ); + OPENVDB_NO_DEPRECATION_WARNING_END return vec;// Named Return Value Optimization } +#endif /// Return the number of non-leaf nodes. - Index32 nonLeafCount() const override { return mRoot.nonLeafCount(); } +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + Index64 nonLeafCount() const override { return mRoot.nonLeafCount(); } +#else + Index32 nonLeafCount() const override { return static_cast(mRoot.nonLeafCount()); } +#endif /// Return the number of active voxels stored in leaf nodes. Index64 activeLeafVoxelCount() const override { return tools::countActiveLeafVoxels(*this); } /// Return the number of inactive voxels stored in leaf nodes. @@ -464,7 +504,11 @@ class Tree: public TreeBase void clipUnallocatedNodes() override; /// Return the total number of unallocated leaf nodes residing in this tree. +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + Index64 unallocatedLeafCount() const override; +#else Index32 unallocatedLeafCount() const override; +#endif //@{ /// @brief Set all voxels within a given axis-aligned box to a constant value. @@ -623,6 +667,31 @@ class Tree: public TreeBase /// Remove all tiles from this tree and all nodes other than the root node. void clear(); + /// @brief Return an accessor that provides random read and write access + /// to this tree's voxels. + /// @details The accessor is safe in the sense that it is registered with this tree. + Accessor getAccessor(); + /// @brief Return an unsafe accessor that provides random read and write access + /// to this tree's voxels. + /// @details The accessor is unsafe in the sense that it is not registered + /// with this tree's tree. In some rare cases this can give a performance advantage + /// over a registered accessor, but it is unsafe if the tree topology is modified. + /// @warning Only use this method if you're an expert and know the + /// risks of using an unregistered accessor (see tree/ValueAccessor.h) + UnsafeAccessor getUnsafeAccessor(); + /// Return an accessor that provides random read-only access to this tree's voxels. + ConstAccessor getAccessor() const; + /// Return an accessor that provides random read-only access to this tree's voxels. + ConstAccessor getConstAccessor() const; + /// @brief Return an unsafe accessor that provides random read-only access + /// to this tree's voxels. + /// @details The accessor is unsafe in the sense that it is not registered + /// with this tree. In some rare cases this can give a performance advantage + /// over a registered accessor, but it is unsafe if the tree topology is modified. + /// @warning Only use this method if you're an expert and know the + /// risks of using an unregistered accessor (see tree/ValueAccessor.h) + ConstUnsafeAccessor getConstUnsafeAccessor(); + /// Clear all registered accessors. void clearAllAccessors(); @@ -1318,6 +1387,41 @@ Tree::clear() //////////////////////////////////////// +template +typename Tree::Accessor +Tree::getAccessor() +{ + return Accessor(*this); +} + +template +typename Tree::UnsafeAccessor +Tree::getUnsafeAccessor() +{ + return UnsafeAccessor(*this); +} + +template +typename Tree::ConstAccessor +Tree::getAccessor() const +{ + return ConstAccessor(*this); +} + +template +typename Tree::ConstAccessor +Tree::getConstAccessor() const +{ + return ConstAccessor(*this); +} + +template +typename Tree::ConstUnsafeAccessor +Tree::getConstUnsafeAccessor() +{ + return ConstUnsafeAccessor(*this); +} + template inline void Tree::attachAccessor(ValueAccessorBase& accessor) const @@ -1608,6 +1712,16 @@ Tree::clipUnallocatedNodes() } } +#if OPENVDB_ABI_VERSION_NUMBER >= 12 +template +inline Index64 +Tree::unallocatedLeafCount() const +{ + Index64 sum = 0; + for (auto it = this->cbeginLeaf(); it; ++it) if (!it->isAllocated()) ++sum; + return sum; +} +#else template inline Index32 Tree::unallocatedLeafCount() const @@ -1616,6 +1730,7 @@ Tree::unallocatedLeafCount() const for (auto it = this->cbeginLeaf(); it; ++it) if (!it->isAllocated()) ++sum; return sum; } +#endif template @@ -1971,7 +2086,7 @@ Tree::print(std::ostream& os, int verboseLevel) const } const auto nodeCount = this->nodeCount();//fast - const Index32 leafCount = nodeCount.front();// leaf is the first element + const Index64 leafCount = nodeCount.front();// leaf is the first element OPENVDB_ASSERT(dims.size() == nodeCount.size()); Index64 totalNodeCount = 0; diff --git a/openvdb/openvdb/tree/TreeIterator.h b/openvdb/openvdb/tree/TreeIterator.h index c3d1f76780..e0d0c63017 100644 --- a/openvdb/openvdb/tree/TreeIterator.h +++ b/openvdb/openvdb/tree/TreeIterator.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file tree/TreeIterator.h diff --git a/openvdb/openvdb/tree/ValueAccessor.h b/openvdb/openvdb/tree/ValueAccessor.h index bf749e8785..542ff0d1b3 100644 --- a/openvdb/openvdb/tree/ValueAccessor.h +++ b/openvdb/openvdb/tree/ValueAccessor.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file tree/ValueAccessor.h /// diff --git a/openvdb/openvdb/unittest/CMakeLists.txt b/openvdb/openvdb/unittest/CMakeLists.txt index 3fa4b9130b..b1e04ebcfe 100644 --- a/openvdb/openvdb/unittest/CMakeLists.txt +++ b/openvdb/openvdb/unittest/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(OpenVDBUnitTests LANGUAGES CXX) include(GNUInstallDirs) @@ -111,6 +111,7 @@ else() TestInt32Metadata.cc TestInt64Metadata.cc TestInternalOrigin.cc + TestInternalNode.cc TestLaplacian.cc TestLeaf.cc TestLeafBool.cc @@ -118,6 +119,7 @@ else() TestLeafManager.cc TestLeafMask.cc TestLeafOrigin.cc + TestLevelSetFilter.cc TestLevelSetRayIntersector.cc TestLevelSetUtil.cc TestLinearInterp.cc @@ -166,6 +168,7 @@ else() TestQuantizedUnitVec.cc TestQuat.cc TestRay.cc + TestRootNode.cc TestStats.cc TestStencils.cc TestStream.cc diff --git a/openvdb/openvdb/unittest/PointBuilder.h b/openvdb/openvdb/unittest/PointBuilder.h index 3ae05dae3f..f67beedb00 100644 --- a/openvdb/openvdb/unittest/PointBuilder.h +++ b/openvdb/openvdb/unittest/PointBuilder.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_UNITTEST_POINT_BUILDER_HAS_BEEN_INCLUDED #define OPENVDB_UNITTEST_POINT_BUILDER_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/unittest/TestActivate.cc b/openvdb/openvdb/unittest/TestActivate.cc index 5e591706c2..9a2ef8e3cd 100644 --- a/openvdb/openvdb/unittest/TestActivate.cc +++ b/openvdb/openvdb/unittest/TestActivate.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestAttributeArray.cc b/openvdb/openvdb/unittest/TestAttributeArray.cc index 65fabbec0d..9ec63f3b7b 100644 --- a/openvdb/openvdb/unittest/TestAttributeArray.cc +++ b/openvdb/openvdb/unittest/TestAttributeArray.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestAttributeArrayString.cc b/openvdb/openvdb/unittest/TestAttributeArrayString.cc index 6630b46f55..7d9745b88f 100644 --- a/openvdb/openvdb/unittest/TestAttributeArrayString.cc +++ b/openvdb/openvdb/unittest/TestAttributeArrayString.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestAttributeGroup.cc b/openvdb/openvdb/unittest/TestAttributeGroup.cc index 2517e128e0..9ff9398536 100644 --- a/openvdb/openvdb/unittest/TestAttributeGroup.cc +++ b/openvdb/openvdb/unittest/TestAttributeGroup.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestAttributeSet.cc b/openvdb/openvdb/unittest/TestAttributeSet.cc index c7b103f5fc..fd390e3b6d 100644 --- a/openvdb/openvdb/unittest/TestAttributeSet.cc +++ b/openvdb/openvdb/unittest/TestAttributeSet.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestBBox.cc b/openvdb/openvdb/unittest/TestBBox.cc index 5c7a8be59c..b5396e93d0 100644 --- a/openvdb/openvdb/unittest/TestBBox.cc +++ b/openvdb/openvdb/unittest/TestBBox.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestClip.cc b/openvdb/openvdb/unittest/TestClip.cc index 0fcb14f191..20e9f33794 100644 --- a/openvdb/openvdb/unittest/TestClip.cc +++ b/openvdb/openvdb/unittest/TestClip.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include // for math::NonlinearFrustumMap diff --git a/openvdb/openvdb/unittest/TestConjGradient.cc b/openvdb/openvdb/unittest/TestConjGradient.cc index 8134253d32..147322e09a 100644 --- a/openvdb/openvdb/unittest/TestConjGradient.cc +++ b/openvdb/openvdb/unittest/TestConjGradient.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestCoord.cc b/openvdb/openvdb/unittest/TestCoord.cc index f4a4399b9f..67e0a86b56 100644 --- a/openvdb/openvdb/unittest/TestCoord.cc +++ b/openvdb/openvdb/unittest/TestCoord.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestCount.cc b/openvdb/openvdb/unittest/TestCount.cc index 0c82efcbbd..3ce3f5227b 100644 --- a/openvdb/openvdb/unittest/TestCount.cc +++ b/openvdb/openvdb/unittest/TestCount.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include diff --git a/openvdb/openvdb/unittest/TestCpt.cc b/openvdb/openvdb/unittest/TestCpt.cc index c918798ede..14a3dae77a 100644 --- a/openvdb/openvdb/unittest/TestCpt.cc +++ b/openvdb/openvdb/unittest/TestCpt.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestCurl.cc b/openvdb/openvdb/unittest/TestCurl.cc index 1aa719d2da..f3deefe3d4 100644 --- a/openvdb/openvdb/unittest/TestCurl.cc +++ b/openvdb/openvdb/unittest/TestCurl.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestDelayedLoadMetadata.cc b/openvdb/openvdb/unittest/TestDelayedLoadMetadata.cc index e5d77209a4..d1617863e8 100644 --- a/openvdb/openvdb/unittest/TestDelayedLoadMetadata.cc +++ b/openvdb/openvdb/unittest/TestDelayedLoadMetadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestDense.cc b/openvdb/openvdb/unittest/TestDense.cc index 4d1800dc01..8d6ca3e90d 100644 --- a/openvdb/openvdb/unittest/TestDense.cc +++ b/openvdb/openvdb/unittest/TestDense.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 //#define BENCHMARK_TEST diff --git a/openvdb/openvdb/unittest/TestDenseSparseTools.cc b/openvdb/openvdb/unittest/TestDenseSparseTools.cc index cebfa54660..236fdafa12 100644 --- a/openvdb/openvdb/unittest/TestDenseSparseTools.cc +++ b/openvdb/openvdb/unittest/TestDenseSparseTools.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestDiagnostics.cc b/openvdb/openvdb/unittest/TestDiagnostics.cc index 949dc4ebd3..d5fbf3fbae 100644 --- a/openvdb/openvdb/unittest/TestDiagnostics.cc +++ b/openvdb/openvdb/unittest/TestDiagnostics.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestDivergence.cc b/openvdb/openvdb/unittest/TestDivergence.cc index c1086650bf..38a2fde018 100644 --- a/openvdb/openvdb/unittest/TestDivergence.cc +++ b/openvdb/openvdb/unittest/TestDivergence.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestDoubleMetadata.cc b/openvdb/openvdb/unittest/TestDoubleMetadata.cc index 72ec519877..66499d8d0d 100644 --- a/openvdb/openvdb/unittest/TestDoubleMetadata.cc +++ b/openvdb/openvdb/unittest/TestDoubleMetadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestExceptions.cc b/openvdb/openvdb/unittest/TestExceptions.cc index 10f3f80936..8f88bd3293 100644 --- a/openvdb/openvdb/unittest/TestExceptions.cc +++ b/openvdb/openvdb/unittest/TestExceptions.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include diff --git a/openvdb/openvdb/unittest/TestFastSweeping.cc b/openvdb/openvdb/unittest/TestFastSweeping.cc index 2ecf25dc57..9bddbf7fbf 100644 --- a/openvdb/openvdb/unittest/TestFastSweeping.cc +++ b/openvdb/openvdb/unittest/TestFastSweeping.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file TestFastSweeping.cc /// diff --git a/openvdb/openvdb/unittest/TestFile.cc b/openvdb/openvdb/unittest/TestFile.cc index df50881c79..dd344cb515 100644 --- a/openvdb/openvdb/unittest/TestFile.cc +++ b/openvdb/openvdb/unittest/TestFile.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -1866,7 +1866,7 @@ TEST_F(TestFile, testMultiPassIO) file.open(); const auto newGrid = GridBase::grid( file.readGrid("test", BBoxd(Vec3d(0), Vec3d(1)))); - EXPECT_EQ(Index32(1), newGrid->tree().leafCount()); + EXPECT_EQ(Index64(1), newGrid->tree().leafCount()); auto leafIter = newGrid->tree().beginLeaf(); EXPECT_EQ(3, int(leafIter->mReadPasses.size())); diff --git a/openvdb/openvdb/unittest/TestFilter.cc b/openvdb/openvdb/unittest/TestFilter.cc index 8009b98762..12f9cdedd6 100644 --- a/openvdb/openvdb/unittest/TestFilter.cc +++ b/openvdb/openvdb/unittest/TestFilter.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -245,7 +245,7 @@ TEST_F(TestFilter, testFilterTiles) openvdb::FloatGrid::Ptr ref = openvdb::FloatGrid::create(0.0f); auto& tree = ref->tree(); tree.addTile(test.mLevel, Coord(0), 1.0f, true); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); EXPECT_EQ(test.mVoxels, tree.activeVoxelCount()); EXPECT_EQ(1.0f, tree.getValue(Coord(0))); @@ -262,7 +262,7 @@ TEST_F(TestFilter, testFilterTiles) // disable tile processing, do nothing filter.setProcessTiles(false); filter.offset(1.0f); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); EXPECT_EQ(test.mVoxels, tree.activeVoxelCount()); EXPECT_EQ(1.0f, tree.getValue(Coord(0))); @@ -271,7 +271,7 @@ TEST_F(TestFilter, testFilterTiles) // enable filter.setProcessTiles(true); filter.offset(1.0f); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); EXPECT_EQ(test.mVoxels, tree.activeVoxelCount()); EXPECT_EQ(2.0f, tree.getValue(Coord(0))); @@ -285,7 +285,7 @@ TEST_F(TestFilter, testFilterTiles) // disable tile processing, do nothing filter.setProcessTiles(false); filter.mean(width, iter); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); EXPECT_EQ(test.mVoxels, tree.activeVoxelCount()); EXPECT_EQ(1.0f, tree.getValue(Coord(0))); @@ -308,7 +308,7 @@ TEST_F(TestFilter, testFilterTiles) // disable tile processing, do nothing filter.setProcessTiles(false); filter.median(width, iter); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); EXPECT_EQ(test.mVoxels, tree.activeVoxelCount()); EXPECT_EQ(1.0f, tree.getValue(Coord(0))); @@ -339,7 +339,7 @@ TEST_F(TestFilter, testFilterTiles) openvdb::FloatGrid::Ptr ref = openvdb::FloatGrid::create(1.0f); auto& tree = ref->tree(); tree.addTile(test.mLevel, Coord(0), 1.0f, true); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); EXPECT_EQ(test.mVoxels, tree.activeVoxelCount()); EXPECT_EQ(1.0f, tree.getValue(Coord(0))); @@ -355,7 +355,7 @@ TEST_F(TestFilter, testFilterTiles) openvdb::tools::Filter filter(*grid); filter.setProcessTiles(true); filter.mean(width, iter); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); EXPECT_EQ(test.mVoxels, tree.activeVoxelCount()); EXPECT_EQ(1.0f, tree.getValue(Coord(0))); @@ -368,7 +368,7 @@ TEST_F(TestFilter, testFilterTiles) openvdb::tools::Filter filter(*grid); filter.setProcessTiles(true); filter.median(width, iter); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); EXPECT_EQ(test.mVoxels, tree.activeVoxelCount()); EXPECT_EQ(1.0f, tree.getValue(Coord(0))); @@ -387,7 +387,7 @@ TEST_F(TestFilter, testFilterTiles) openvdb::FloatGrid::Ptr ref = openvdb::FloatGrid::create(1.0f); auto& tree = ref->tree(); tree.addTile(1, Coord(0), 1.0f, true); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); EXPECT_EQ(Index64(LeafT::NUM_VALUES), tree.activeVoxelCount()); EXPECT_EQ(1.0f, tree.getValue(Coord(0))); @@ -402,7 +402,7 @@ TEST_F(TestFilter, testFilterTiles) // filter.setProcessTiles(true); filter.mean(1, 1); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); EXPECT_EQ(Index64(LeafT::NUM_VALUES), tree.activeVoxelCount()); EXPECT_EQ(1.0f, tree.getValue(Coord(0))); @@ -410,11 +410,11 @@ TEST_F(TestFilter, testFilterTiles) // create leaf neighbour tree.touchLeaf(Coord(-1,0,0)); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); filter.mean(1, 1); - EXPECT_EQ(Index32(2), tree.leafCount()); + EXPECT_EQ(Index64(2), tree.leafCount()); EXPECT_EQ(Index64(0), tree.activeTileCount()); EXPECT_EQ(Index64(LeafT::NUM_VALUES), tree.activeVoxelCount()); } @@ -426,18 +426,18 @@ TEST_F(TestFilter, testFilterTiles) openvdb::FloatGrid::Ptr ref = openvdb::FloatGrid::create(1.0f); auto& tree = ref->tree(); tree.addTile(level, Coord(0), 1.0f, true); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); EXPECT_EQ(1.0f, tree.getValue(Coord(0))); EXPECT_TRUE(tree.isValueOn(Coord(0))); // create a leaf and tile neighbour tree.touchLeaf(Coord(-int(LeafT::DIM),0,0)); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); // create tile level 1 neighbour with a different value tree.addTile(1, Coord(-int(LeafT::DIM),0,LeafT::DIM*3), 2.0f, true); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(Index64(2), tree.activeTileCount()); return ref; }; @@ -453,7 +453,7 @@ TEST_F(TestFilter, testFilterTiles) // (+ itself becomes a leaf) filter.mean(/*width*/LeafT::DIM+1, /*iter*/1); // 2 leaf nodes from the tile/leaf neighbours + their neighbours - EXPECT_EQ(Index32(2+4+5), tree.leafCount()); + EXPECT_EQ(Index64(2+4+5), tree.leafCount()); EXPECT_EQ((Index64(InternalNode1::NUM_VALUES) - 1) + (Index64(InternalNode2::NUM_VALUES) - (4+5)), tree.activeTileCount()); EXPECT_EQ(Index64(InternalNode1::NUM_VOXELS) + @@ -467,7 +467,7 @@ TEST_F(TestFilter, testFilterTiles) filter.setProcessTiles(true); // with width = 2 and iter = 2, edge/vertex neighbours should also be voxelized filter.mean(/*width*/2, /*iter*/2); - EXPECT_EQ(Index32(2+4+6), tree.leafCount()); + EXPECT_EQ(Index64(2+4+6), tree.leafCount()); EXPECT_EQ((Index64(InternalNode1::NUM_VALUES) - 1) + (Index64(InternalNode2::NUM_VALUES) - (4+6)), tree.activeTileCount()); EXPECT_EQ(Index64(InternalNode1::NUM_VOXELS) + @@ -481,7 +481,7 @@ TEST_F(TestFilter, testFilterTiles) filter.setProcessTiles(true); // with width = 1 and iter = 9 - checks an iter count > LeafT::DIM filter.mean(/*width*/1, /*iter*/LeafT::DIM+1); - EXPECT_EQ(Index32(38), tree.leafCount()); + EXPECT_EQ(Index64(38), tree.leafCount()); EXPECT_EQ((Index64(InternalNode2::NUM_VALUES) - 36), tree.activeTileCount()); EXPECT_EQ(Index64(InternalNode2::NUM_VOXELS) + Index64(LeafT::NUM_VOXELS), tree.activeVoxelCount()); diff --git a/openvdb/openvdb/unittest/TestFindActiveValues.cc b/openvdb/openvdb/unittest/TestFindActiveValues.cc index 7dd6415777..fed5d4b070 100644 --- a/openvdb/openvdb/unittest/TestFindActiveValues.cc +++ b/openvdb/openvdb/unittest/TestFindActiveValues.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestFloatMetadata.cc b/openvdb/openvdb/unittest/TestFloatMetadata.cc index b3130a7aff..97894533a8 100644 --- a/openvdb/openvdb/unittest/TestFloatMetadata.cc +++ b/openvdb/openvdb/unittest/TestFloatMetadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestGradient.cc b/openvdb/openvdb/unittest/TestGradient.cc index 3950587249..ce1bf47691 100644 --- a/openvdb/openvdb/unittest/TestGradient.cc +++ b/openvdb/openvdb/unittest/TestGradient.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestGrid.cc b/openvdb/openvdb/unittest/TestGrid.cc index 1e9d058b77..27c76ec0f6 100644 --- a/openvdb/openvdb/unittest/TestGrid.cc +++ b/openvdb/openvdb/unittest/TestGrid.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -40,6 +40,11 @@ class ProxyTree: public openvdb::TreeBase using Ptr = openvdb::SharedPtr; using ConstPtr = openvdb::SharedPtr; + using Accessor = void; + using ConstAccessor = void; + using UnsafeAccessor = void; + using ConstUnsafeAccessor = void; + static const openvdb::Index DEPTH; static const ValueType backg; @@ -70,7 +75,11 @@ class ProxyTree: public openvdb::TreeBase void prune(const ValueType& = 0) {} void clip(const openvdb::CoordBBox&) {} void clipUnallocatedNodes() override {} +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + openvdb::Index64 unallocatedLeafCount() const override { return 0; } +#else openvdb::Index32 unallocatedLeafCount() const override { return 0; } +#endif void getIndexRange(openvdb::CoordBBox&) const override {} bool evalLeafBoundingBox(openvdb::CoordBBox& bbox) const override @@ -83,10 +92,17 @@ class ProxyTree: public openvdb::TreeBase { dim = openvdb::Coord(0, 0, 0); return false; } openvdb::Index treeDepth() const override { return 0; } - openvdb::Index leafCount() const override { return 0; } +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + openvdb::Index64 leafCount() const override { return 0; } + std::vector nodeCount() const override + { return std::vector(DEPTH, 0); } + openvdb::Index64 nonLeafCount() const override { return 0; } +#else + openvdb::Index32 leafCount() const override { return 0; } std::vector nodeCount() const override { return std::vector(DEPTH, 0); } - openvdb::Index nonLeafCount() const override { return 0; } + openvdb::Index32 nonLeafCount() const override { return 0; } +#endif openvdb::Index64 activeVoxelCount() const override { return 0UL; } openvdb::Index64 inactiveVoxelCount() const override { return 0UL; } openvdb::Index64 activeLeafVoxelCount() const override { return 0UL; } @@ -265,7 +281,7 @@ TEST_F(TestGrid, testCopyGrid) // shallow-copy a const grid but supply a new transform and meta map EXPECT_EQ(1.0, grid1->transform().voxelSize().x()); EXPECT_EQ(size_t(0), grid1->metaCount()); - EXPECT_EQ(Index(2), grid1->tree().leafCount()); + EXPECT_EQ(Index64(2), grid1->tree().leafCount()); math::Transform::Ptr xform(math::Transform::createLinearTransform(/*voxelSize=*/0.25)); MetaMap meta; @@ -278,7 +294,7 @@ TEST_F(TestGrid, testCopyGrid) EXPECT_EQ(0.25, grid3->transform().voxelSize().x()); EXPECT_EQ(size_t(1), grid3->metaCount()); - EXPECT_EQ(Index(2), tree3.leafCount()); + EXPECT_EQ(Index64(2), tree3.leafCount()); EXPECT_EQ(long(3), constGrid1->constTreePtr().use_count()); } @@ -512,3 +528,105 @@ TEST_F(TestGrid, testApply) EXPECT_EQ(4, n); } } + +TEST_F(TestGrid, testAdapter) +{ + openvdb::FloatGrid floatGrid; + const openvdb::FloatGrid constFloatGrid = floatGrid; + openvdb::FloatTree& floatTree = floatGrid.tree(); + const openvdb::FloatTree& constFloatTree = floatGrid.constTree(); + openvdb::tree::ValueAccessor floatAcc(floatGrid.tree()); + openvdb::tree::ValueAccessor constFloatAcc(floatGrid.constTree()); + + { + // test TreeAdapter + + using AdapterT = openvdb::TreeAdapter; + + AdapterT::tree(floatTree); + AdapterT::tree(floatGrid); + AdapterT::tree(constFloatTree); + AdapterT::tree(constFloatGrid); + AdapterT::constTree(floatTree); + AdapterT::constTree(floatGrid); + AdapterT::constTree(constFloatTree); + AdapterT::constTree(constFloatGrid); + + // test TreeAdapter + + using ConstAdapterT = openvdb::TreeAdapter; + + ConstAdapterT::tree(floatTree); + ConstAdapterT::tree(floatGrid); + ConstAdapterT::tree(constFloatTree); + ConstAdapterT::tree(constFloatGrid); + ConstAdapterT::constTree(floatTree); + ConstAdapterT::constTree(floatGrid); + ConstAdapterT::constTree(constFloatTree); + ConstAdapterT::constTree(constFloatGrid); + } + + { + // test TreeAdapter + + using AdapterT = openvdb::TreeAdapter; + + AdapterT::tree(floatTree); + AdapterT::tree(floatGrid); + AdapterT::tree(constFloatTree); + AdapterT::tree(constFloatGrid); + AdapterT::constTree(floatTree); + AdapterT::constTree(floatGrid); + AdapterT::constTree(constFloatTree); + AdapterT::constTree(constFloatGrid); + + // test TreeAdapter + + using ConstAdapterT = openvdb::TreeAdapter; + + ConstAdapterT::tree(floatTree); + ConstAdapterT::tree(floatGrid); + ConstAdapterT::tree(constFloatTree); + ConstAdapterT::tree(constFloatGrid); + ConstAdapterT::constTree(floatTree); + ConstAdapterT::constTree(floatGrid); + ConstAdapterT::constTree(constFloatTree); + ConstAdapterT::constTree(constFloatGrid); + } + + { + // test TreeAdapter> + + using AdapterT = openvdb::TreeAdapter>; + + AdapterT::tree(floatTree); + AdapterT::tree(floatGrid); + AdapterT::tree(floatAcc); + AdapterT::tree(constFloatAcc); + AdapterT::tree(constFloatTree); + AdapterT::tree(constFloatGrid); + AdapterT::constTree(floatTree); + AdapterT::constTree(floatGrid); + AdapterT::constTree(floatAcc); + AdapterT::constTree(constFloatAcc); + AdapterT::constTree(constFloatTree); + AdapterT::constTree(constFloatGrid); + + // test TreeAdapter> + + using AdapterConstT = openvdb::TreeAdapter>; + + AdapterConstT::tree(floatTree); + AdapterConstT::tree(floatGrid); + AdapterConstT::tree(floatAcc); + AdapterConstT::tree(constFloatAcc); + AdapterConstT::tree(constFloatTree); + AdapterConstT::tree(constFloatGrid); + AdapterConstT::constTree(floatTree); + AdapterConstT::constTree(floatGrid); + AdapterConstT::constTree(floatAcc); + AdapterConstT::constTree(constFloatAcc); + AdapterConstT::constTree(constFloatTree); + AdapterConstT::constTree(constFloatGrid); + } +} diff --git a/openvdb/openvdb/unittest/TestGridBbox.cc b/openvdb/openvdb/unittest/TestGridBbox.cc index efd75a5f4d..cdb9210196 100644 --- a/openvdb/openvdb/unittest/TestGridBbox.cc +++ b/openvdb/openvdb/unittest/TestGridBbox.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestGridDescriptor.cc b/openvdb/openvdb/unittest/TestGridDescriptor.cc index 60ae0e6e4b..c45e8d0433 100644 --- a/openvdb/openvdb/unittest/TestGridDescriptor.cc +++ b/openvdb/openvdb/unittest/TestGridDescriptor.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestGridIO.cc b/openvdb/openvdb/unittest/TestGridIO.cc index ab68cebee5..63baacc7eb 100644 --- a/openvdb/openvdb/unittest/TestGridIO.cc +++ b/openvdb/openvdb/unittest/TestGridIO.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestGridTransformer.cc b/openvdb/openvdb/unittest/TestGridTransformer.cc index 3129e36733..140a22eeb8 100644 --- a/openvdb/openvdb/unittest/TestGridTransformer.cc +++ b/openvdb/openvdb/unittest/TestGridTransformer.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestIndexFilter.cc b/openvdb/openvdb/unittest/TestIndexFilter.cc index fb7d5532da..3389511d85 100644 --- a/openvdb/openvdb/unittest/TestIndexFilter.cc +++ b/openvdb/openvdb/unittest/TestIndexFilter.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -157,7 +157,7 @@ TEST_F(TestIndexFilter, testActiveFilter) // check there are two leafs - EXPECT_EQ(Index32(2), points->tree().leafCount()); + EXPECT_EQ(Index64(2), points->tree().leafCount()); ActiveFilter activeFilter; InactiveFilter inActiveFilter; @@ -551,7 +551,7 @@ TEST_F(TestIndexFilter, testAttributeHashFilter) // four points, two leafs - EXPECT_EQ(tree.leafCount(), Index32(2)); + EXPECT_EQ(tree.leafCount(), Index64(2)); appendAttribute(tree, "id"); @@ -846,7 +846,7 @@ TEST_F(TestIndexFilter, testBBoxFilter) PointDataTree& tree = grid->tree(); // check one leaf per point - EXPECT_EQ(tree.leafCount(), Index32(2)); + EXPECT_EQ(tree.leafCount(), Index64(2)); // build some bounding box filters to test diff --git a/openvdb/openvdb/unittest/TestIndexIterator.cc b/openvdb/openvdb/unittest/TestIndexIterator.cc index 99d092a8e0..0c7b8978ea 100644 --- a/openvdb/openvdb/unittest/TestIndexIterator.cc +++ b/openvdb/openvdb/unittest/TestIndexIterator.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestInit.cc b/openvdb/openvdb/unittest/TestInit.cc index 4a19ab334b..e5093de85a 100644 --- a/openvdb/openvdb/unittest/TestInit.cc +++ b/openvdb/openvdb/unittest/TestInit.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestInt32Metadata.cc b/openvdb/openvdb/unittest/TestInt32Metadata.cc index 576d7f4eed..3457e290cb 100644 --- a/openvdb/openvdb/unittest/TestInt32Metadata.cc +++ b/openvdb/openvdb/unittest/TestInt32Metadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestInt64Metadata.cc b/openvdb/openvdb/unittest/TestInt64Metadata.cc index 29134c3395..f7bf9c4add 100644 --- a/openvdb/openvdb/unittest/TestInt64Metadata.cc +++ b/openvdb/openvdb/unittest/TestInt64Metadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestInternalNode.cc b/openvdb/openvdb/unittest/TestInternalNode.cc new file mode 100644 index 0000000000..14b56d6325 --- /dev/null +++ b/openvdb/openvdb/unittest/TestInternalNode.cc @@ -0,0 +1,333 @@ + +// Copyright Contributors to the OpenVDB Project +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include + +using namespace openvdb; +using namespace openvdb::tree; + + +class TestInternalNode: public ::testing::Test +{ +}; + + +TEST_F(TestInternalNode, test) +{ + const Coord c0(1000, 1000, 1000); + const Coord c1(896, 896, 896); + + using LeafNodeType = openvdb::tree::LeafNode; + using InternalNodeType = openvdb::tree::InternalNode; + using ChildType = LeafNodeType; + + { // test inserting child nodes directly and indirectly + Coord c2 = c1.offsetBy(8,0,0); + Coord c3 = c1.offsetBy(16,16,16); + + InternalNodeType internalNode(c1, 0.0f); + internalNode.touchLeaf(c2); + internalNode.touchLeaf(c3); + + EXPECT_EQ(Index(2), internalNode.leafCount()); + EXPECT_EQ(Index32(2), internalNode.childCount()); + EXPECT_TRUE(!internalNode.hasActiveTiles()); + + { // verify c0 and c1 are the root node coordinates + auto childIter = internalNode.cbeginChildOn(); + EXPECT_EQ(c2, childIter.getCoord()); + ++childIter; + EXPECT_EQ(c3, childIter.getCoord()); + } + + // copy the internal node + InternalNodeType internalNodeCopy(internalNode); + + // steal the internal node children leaving it empty again + std::vector children; + internalNode.stealNodes(children, 0.0f, false); + EXPECT_EQ(Index(0), internalNode.leafCount()); + EXPECT_EQ(Index32(0), internalNode.childCount()); + + // insert the root node children directly + for (ChildType* child : children) { + internalNode.addChild(child); + } + EXPECT_EQ(Index(2), internalNode.leafCount()); + EXPECT_EQ(Index32(2), internalNode.childCount()); + + { // verify the coordinates of the root node children + auto childIter = internalNode.cbeginChildOn(); + EXPECT_EQ(c2, childIter.getCoord()); + ++childIter; + EXPECT_EQ(c3, childIter.getCoord()); + } + } + + { // test inserting a tile and replacing with a child node + InternalNodeType internalNode(c1, 0.0f); + EXPECT_TRUE(!internalNode.hasActiveTiles()); + EXPECT_EQ(Index(0), internalNode.leafCount()); + EXPECT_EQ(Index32(0), internalNode.childCount()); + + // add a tile + internalNode.addTile(Index(0), /*value=*/1.0f, /*state=*/true); + EXPECT_TRUE(internalNode.hasActiveTiles()); + EXPECT_EQ(Index(0), internalNode.leafCount()); + EXPECT_EQ(Index32(0), internalNode.childCount()); + + // replace the tile with a child node + EXPECT_TRUE(internalNode.addChild(new ChildType(c1, 2.0f))); + EXPECT_TRUE(!internalNode.hasActiveTiles()); + EXPECT_EQ(Index(1), internalNode.leafCount()); + EXPECT_EQ(Index32(1), internalNode.childCount()); + EXPECT_EQ(c1, internalNode.cbeginChildOn().getCoord()); + EXPECT_NEAR(internalNode.cbeginChildOn()->getValue(0), 2.0f, /*tolerance=*/0.0); + + // replace the child node with another child node + EXPECT_TRUE(internalNode.addChild(new ChildType(c1, 3.0f))); + EXPECT_NEAR(internalNode.cbeginChildOn()->getValue(0), 3.0f, /*tolerance=*/0.0); + } + + { // test inserting child nodes that do and do not belong to the internal node + InternalNodeType internalNode(c1, 0.0f); + + // succeed if child belongs to this internal node + EXPECT_TRUE(internalNode.addChild(new ChildType(c0.offsetBy(8,0,0)))); + EXPECT_TRUE(internalNode.probeLeaf(c0.offsetBy(8,0,0))); + Index index1 = internalNode.coordToOffset(c0); + Index index2 = internalNode.coordToOffset(c0.offsetBy(8,0,0)); + EXPECT_TRUE(!internalNode.isChildMaskOn(index1)); + EXPECT_TRUE(internalNode.isChildMaskOn(index2)); + + // fail otherwise + auto* child = new ChildType(c0.offsetBy(8000,0,0)); + EXPECT_TRUE(!internalNode.addChild(child)); + delete child; + } + + { // test transient data + InternalNodeType internalNode(c1, 0.0f); + EXPECT_EQ(Index32(0), internalNode.transientData()); + internalNode.setTransientData(Index32(5)); + EXPECT_EQ(Index32(5), internalNode.transientData()); + InternalNodeType internalNode2(internalNode); + EXPECT_EQ(Index32(5), internalNode2.transientData()); + InternalNodeType internalNode3 = internalNode; + EXPECT_EQ(Index32(5), internalNode3.transientData()); + } +} + +TEST_F(TestInternalNode, testProbe) +{ + using RootNode = FloatTree::RootNodeType; + using InternalNode = RootNode::ChildNodeType; + + const Coord ijk(0, 0, 4096); + InternalNode internalNode(ijk, 1.0f); + + internalNode.addTile(32, 3.0f, true); // (0, 128, 4096) + internalNode.addTile(33, 4.0f, true); // (0, 128, 4224) + + auto* child = new InternalNode::ChildNodeType(Coord(0, 256, 4096), 5.0f, true); + EXPECT_TRUE(internalNode.addChild(child)); // always returns true + + { // probeNode, probeConstNode + auto* node1 = internalNode.probeNode(Coord(0, 256, 4096)); + EXPECT_TRUE(bool(node1)); + auto* node2 = internalNode.probeNode(Coord(0, 128, 4096)); + EXPECT_FALSE(bool(node2)); + const InternalNode& constInternalNode = internalNode; + auto* node3 = constInternalNode.probeNode(Coord(0, 256, 4096)); + EXPECT_TRUE(bool(node3)); + auto* node4 = constInternalNode.probeNode(Coord(0, 128, 4096)); + EXPECT_FALSE(bool(node4)); + auto* node5 = internalNode.probeConstNode(Coord(0, 256, 4096)); + EXPECT_TRUE(bool(node5)); + auto* node6 = internalNode.probeConstNode(Coord(0, 128, 4096)); + EXPECT_FALSE(bool(node6)); + } + + { // probeChild, probeConstChild + auto* node1 = internalNode.probeChild(Coord(0, 256, 4096)); + EXPECT_TRUE(bool(node1)); + auto* node2 = internalNode.probeChild(Coord(0, 128, 4096)); + EXPECT_FALSE(bool(node2)); + const InternalNode& constInternalNode = internalNode; + auto* node3 = constInternalNode.probeChild(Coord(0, 256, 4096)); + EXPECT_TRUE(bool(node3)); + auto* node4 = constInternalNode.probeChild(Coord(0, 128, 4096)); + EXPECT_FALSE(bool(node4)); + auto* node5 = internalNode.probeConstChild(Coord(0, 256, 4096)); + EXPECT_TRUE(bool(node5)); + auto* node6 = internalNode.probeConstChild(Coord(0, 128, 4096)); + EXPECT_FALSE(bool(node6)); + } + + { // probeChildUnsafe, probeConstChildUnsafe + auto* node1 = internalNode.probeChildUnsafe(64); + EXPECT_TRUE(bool(node1)); + auto* node2 = internalNode.probeChildUnsafe(33); + EXPECT_FALSE(bool(node2)); + const InternalNode& constInternalNode = internalNode; + auto* node3 = constInternalNode.probeChildUnsafe(64); + EXPECT_TRUE(bool(node3)); + auto* node4 = constInternalNode.probeChildUnsafe(33); + EXPECT_FALSE(bool(node4)); + auto* node5 = internalNode.probeConstChildUnsafe(64); + EXPECT_TRUE(bool(node5)); + auto* node6 = internalNode.probeConstChildUnsafe(33); + EXPECT_FALSE(bool(node6)); + } + + float value = -1.0f; + bool active = false; + + { // probeChild, probeConstChild with value and active status + auto* node1 = internalNode.probeChild(Coord(0, 256, 4096), value, active); + EXPECT_TRUE(bool(node1)); + EXPECT_EQ(value, -1.0f); + EXPECT_FALSE(active); + auto* node2 = internalNode.probeChild(Coord(0, 128, 4096), value, active); + EXPECT_FALSE(bool(node2)); + EXPECT_EQ(value, 3.0f); value = -1.0f; + EXPECT_TRUE(active); active = false; + const InternalNode& constInternalNode = internalNode; + auto* node3 = constInternalNode.probeChild(Coord(0, 256, 4096), value, active); + EXPECT_TRUE(bool(node3)); + EXPECT_EQ(value, -1.0f); + EXPECT_FALSE(active); + auto* node4 = constInternalNode.probeChild(Coord(0, 128, 4096), value, active); + EXPECT_FALSE(bool(node4)); + EXPECT_EQ(value, 3.0f); value = -1.0f; + EXPECT_TRUE(active); active = false; + auto* node5 = internalNode.probeConstChild(Coord(0, 256, 4096), value, active); + EXPECT_TRUE(bool(node5)); + EXPECT_EQ(value, -1.0f); + EXPECT_FALSE(active); + auto* node6 = internalNode.probeConstChild(Coord(0, 128, 4096), value, active); + EXPECT_FALSE(bool(node6)); + EXPECT_EQ(value, 3.0f); value = -1.0f; + EXPECT_TRUE(active); active = false; + } + + { // probeChildUnsafe, probeConstChildUnsafe with value and active status + auto* node1 = internalNode.probeChildUnsafe(64, value, active); + EXPECT_TRUE(bool(node1)); + EXPECT_EQ(value, -1.0f); + EXPECT_FALSE(active); + auto* node2 = internalNode.probeChildUnsafe(33, value, active); + EXPECT_FALSE(bool(node2)); + EXPECT_EQ(value, 4.0f); value = -1.0f; + EXPECT_TRUE(active); active = false; + const InternalNode& constInternalNode = internalNode; + auto* node3 = constInternalNode.probeChildUnsafe(64, value, active); + EXPECT_TRUE(bool(node3)); + EXPECT_EQ(value, -1.0f); + EXPECT_FALSE(active); + auto* node4 = constInternalNode.probeChildUnsafe(33, value, active); + EXPECT_FALSE(bool(node4)); + EXPECT_EQ(value, 4.0f); value = -1.0f; + EXPECT_TRUE(active); active = false; + auto* node5 = internalNode.probeConstChildUnsafe(64, value, active); + EXPECT_TRUE(bool(node5)); + EXPECT_EQ(value, -1.0f); + EXPECT_FALSE(active); + auto* node6 = internalNode.probeConstChildUnsafe(33, value, active); + EXPECT_FALSE(bool(node6)); + EXPECT_EQ(value, 4.0f); value = -1.0f; + EXPECT_TRUE(active); active = false; + } +} + +TEST_F(TestInternalNode, testUnsafe) +{ + using RootNode = FloatTree::RootNodeType; + using InternalNode = RootNode::ChildNodeType; + + const Coord ijk(0, 0, 4096); + InternalNode internalNode(ijk, 1.0f); + + internalNode.addTile(32, 3.0f, true); // (0, 128, 4096) + internalNode.addTile(33, 4.0f, false); // (0, 128, 4224) + + auto* child = new InternalNode::ChildNodeType(Coord(0, 256, 4096), 5.0f, true); + EXPECT_TRUE(internalNode.addChild(child)); // always returns true + + { // get value + + EXPECT_EQ(internalNode.getValueUnsafe(32), 3.0f); + EXPECT_EQ(internalNode.getValueUnsafe(33), 4.0f); + + float value = -1.0f; + EXPECT_TRUE(internalNode.getValueUnsafe(32, value)); + EXPECT_EQ(value, 3.0f); value = -1.0f; + EXPECT_FALSE(internalNode.getValueUnsafe(33, value)); + EXPECT_EQ(value, 4.0f); value = -1.0f; + } + + { // set value and active state + EXPECT_TRUE(internalNode.isValueOn(32)); + internalNode.setValueOffUnsafe(32); + EXPECT_TRUE(internalNode.isValueOff(32)); + internalNode.setValueOnUnsafe(32); + EXPECT_TRUE(internalNode.isValueOn(32)); + internalNode.setActiveStateUnsafe(32, false); + EXPECT_TRUE(internalNode.isValueOff(32)); + internalNode.setActiveStateUnsafe(32, true); + EXPECT_TRUE(internalNode.isValueOn(32)); + + internalNode.setValueOnlyUnsafe(32, 5.0f); + EXPECT_EQ(internalNode.getValueUnsafe(32), 5.0f); + EXPECT_TRUE(internalNode.isValueOn(32)); + internalNode.setValueOffUnsafe(32); + EXPECT_TRUE(internalNode.isValueOff(32)); + internalNode.setValueOnUnsafe(32); + EXPECT_TRUE(internalNode.isValueOn(32)); + + internalNode.setValueOnUnsafe(33, 7.0f); + EXPECT_TRUE(internalNode.isValueOn(33)); + EXPECT_EQ(internalNode.getValueUnsafe(33), 7.0f); + internalNode.setValueOffUnsafe(33, 6.0f); + EXPECT_TRUE(internalNode.isValueOff(33)); + EXPECT_EQ(internalNode.getValueUnsafe(33), 6.0f); + } + + { // get child + auto* node1 = internalNode.getChildUnsafe(64); + EXPECT_TRUE(bool(node1)); + const InternalNode& constInternalNode = internalNode; + auto* node2 = constInternalNode.getChildUnsafe(64); + EXPECT_TRUE(bool(node2)); + auto* node3 = internalNode.getConstChildUnsafe(64); + EXPECT_TRUE(bool(node3)); + } + + { // set child + auto* child1 = new InternalNode::ChildNodeType(Coord(0, 128, 0), 8.0f, true); + internalNode.setChildUnsafe(32, child1); + auto* node1 = internalNode.getChildUnsafe(32); + EXPECT_TRUE(node1); + EXPECT_EQ(node1->origin(), Coord(0, 128, 0)); + + auto* child2 = new InternalNode::ChildNodeType(Coord(0, 256, 0), 9.0f, true); + internalNode.resetChildUnsafe(64, child2); + auto* node2 = internalNode.getChildUnsafe(64); + EXPECT_TRUE(node2); + EXPECT_EQ(node2->origin(), Coord(0, 256, 0)); + + auto* node3 = internalNode.stealChildUnsafe(64, 12.0f, false); + EXPECT_TRUE(node3); + EXPECT_EQ(node3->origin(), Coord(0, 256, 0)); + delete node3; + EXPECT_EQ(internalNode.getValueUnsafe(64), 12.0f); + EXPECT_TRUE(internalNode.isValueOff(64)); + + internalNode.deleteChildUnsafe(32, 13.0f, true); + EXPECT_EQ(internalNode.getValueUnsafe(32), 13.0f); + EXPECT_TRUE(internalNode.isValueOn(32)); + } +} diff --git a/openvdb/openvdb/unittest/TestInternalOrigin.cc b/openvdb/openvdb/unittest/TestInternalOrigin.cc index f68887848e..d305cb61c1 100644 --- a/openvdb/openvdb/unittest/TestInternalOrigin.cc +++ b/openvdb/openvdb/unittest/TestInternalOrigin.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestLaplacian.cc b/openvdb/openvdb/unittest/TestLaplacian.cc index 56a16e3fc2..d49e06b337 100644 --- a/openvdb/openvdb/unittest/TestLaplacian.cc +++ b/openvdb/openvdb/unittest/TestLaplacian.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestLeaf.cc b/openvdb/openvdb/unittest/TestLeaf.cc index 96efa1de71..ee6f6324ad 100644 --- a/openvdb/openvdb/unittest/TestLeaf.cc +++ b/openvdb/openvdb/unittest/TestLeaf.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -508,8 +508,8 @@ TEST_F(TestLeaf, testCount) EXPECT_EQ(Index(512), leaf.numValues()); EXPECT_EQ(Index(0), leaf.getLevel()); EXPECT_EQ(Index(1), leaf.getChildDim()); - EXPECT_EQ(Index(1), leaf.leafCount()); - EXPECT_EQ(Index(0), leaf.nonLeafCount()); + EXPECT_EQ(Index64(1), leaf.leafCount()); + EXPECT_EQ(Index64(0), leaf.nonLeafCount()); EXPECT_EQ(Index(0), leaf.childCount()); std::vector dims; @@ -533,3 +533,41 @@ TEST_F(TestLeaf, testTransientData) LeafT leaf3 = leaf; EXPECT_EQ(Index32(5), leaf3.transientData()); } + +TEST_F(TestLeaf, testUnsafe) +{ + using namespace openvdb; + using LeafT = tree::LeafNode; + const Coord origin(-9, -2, -8); + LeafT leaf(origin, 1.0f, false); + + EXPECT_FALSE(leaf.isValueOn(1)); + EXPECT_TRUE(leaf.isValueOff(1)); + EXPECT_EQ(leaf.getValueUnsafe(1), 1.0f); + float value = -1.0f; + EXPECT_FALSE(leaf.getValueUnsafe(1, value)); + EXPECT_EQ(value, 1.0f); value = -1.0f; + + EXPECT_TRUE(leaf.isValueOff(32)); + leaf.setValueOnUnsafe(32); + EXPECT_TRUE(leaf.isValueOn(32)); + leaf.setValueOffUnsafe(32); + EXPECT_TRUE(leaf.isValueOff(32)); + leaf.setActiveStateUnsafe(32, true); + EXPECT_TRUE(leaf.isValueOn(32)); + leaf.setActiveStateUnsafe(32, false); + EXPECT_TRUE(leaf.isValueOff(32)); + + leaf.setValueOnlyUnsafe(32, 5.0f); + EXPECT_EQ(leaf.getValueUnsafe(32), 5.0f); + EXPECT_TRUE(leaf.isValueOff(32)); + leaf.setValueOnUnsafe(32); + EXPECT_TRUE(leaf.isValueOn(32)); + + leaf.setValueOnUnsafe(33, 7.0f); + EXPECT_TRUE(leaf.isValueOn(33)); + EXPECT_EQ(leaf.getValueUnsafe(33), 7.0f); + leaf.setValueOffUnsafe(33, 6.0f); + EXPECT_TRUE(leaf.isValueOff(33)); + EXPECT_EQ(leaf.getValueUnsafe(33), 6.0f); +} diff --git a/openvdb/openvdb/unittest/TestLeafBool.cc b/openvdb/openvdb/unittest/TestLeafBool.cc index f215dc5219..fa9c343b09 100644 --- a/openvdb/openvdb/unittest/TestLeafBool.cc +++ b/openvdb/openvdb/unittest/TestLeafBool.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -653,3 +653,41 @@ TEST_F(TestLeafBool, testTransientData) LeafType leaf3 = leaf; EXPECT_EQ(openvdb::Index32(5), leaf3.transientData()); } + +TEST_F(TestLeafBool, testUnsafe) +{ + using namespace openvdb; + using LeafT = tree::LeafNode; + const Coord origin(-9, -2, -8); + LeafT leaf(origin, true, false); + + EXPECT_FALSE(leaf.isValueOn(1)); + EXPECT_TRUE(leaf.isValueOff(1)); + EXPECT_EQ(leaf.getValueUnsafe(1), true); + bool value = false; + EXPECT_FALSE(leaf.getValueUnsafe(1, value)); + EXPECT_EQ(value, true); value = false; + + EXPECT_TRUE(leaf.isValueOff(32)); + leaf.setValueOnUnsafe(32); + EXPECT_TRUE(leaf.isValueOn(32)); + leaf.setValueOffUnsafe(32); + EXPECT_TRUE(leaf.isValueOff(32)); + leaf.setActiveStateUnsafe(32, true); + EXPECT_TRUE(leaf.isValueOn(32)); + leaf.setActiveStateUnsafe(32, false); + EXPECT_TRUE(leaf.isValueOff(32)); + + leaf.setValueOnlyUnsafe(32, false); + EXPECT_EQ(leaf.getValueUnsafe(32), false); + EXPECT_TRUE(leaf.isValueOff(32)); + leaf.setValueOnUnsafe(32); + EXPECT_TRUE(leaf.isValueOn(32)); + + leaf.setValueOnUnsafe(33, false); + EXPECT_TRUE(leaf.isValueOn(33)); + EXPECT_EQ(leaf.getValueUnsafe(33), false); + leaf.setValueOffUnsafe(33, true); + EXPECT_TRUE(leaf.isValueOff(33)); + EXPECT_EQ(leaf.getValueUnsafe(33), true); +} diff --git a/openvdb/openvdb/unittest/TestLeafIO.cc b/openvdb/openvdb/unittest/TestLeafIO.cc index 40cfa24638..d160d646ea 100644 --- a/openvdb/openvdb/unittest/TestLeafIO.cc +++ b/openvdb/openvdb/unittest/TestLeafIO.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestLeafManager.cc b/openvdb/openvdb/unittest/TestLeafManager.cc index 84770c7686..7430871a41 100644 --- a/openvdb/openvdb/unittest/TestLeafManager.cc +++ b/openvdb/openvdb/unittest/TestLeafManager.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestLeafMask.cc b/openvdb/openvdb/unittest/TestLeafMask.cc index fa7eadba6c..7597158f45 100644 --- a/openvdb/openvdb/unittest/TestLeafMask.cc +++ b/openvdb/openvdb/unittest/TestLeafMask.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -574,3 +574,42 @@ TEST_F(TestLeafMask, testTransientData) LeafType leaf3 = leaf; EXPECT_EQ(openvdb::Index32(5), leaf3.transientData()); } + +TEST_F(TestLeafMask, testUnsafe) +{ + using namespace openvdb; + using LeafT = tree::LeafNode; + const Coord origin(-9, -2, -8); + LeafT leaf(origin, false, /*dummy=*/false); + + EXPECT_FALSE(leaf.isValueOn(1)); + EXPECT_TRUE(leaf.isValueOff(1)); + EXPECT_EQ(leaf.getValueUnsafe(1), false); + bool value = true; + EXPECT_FALSE(leaf.getValueUnsafe(1, value)); + EXPECT_EQ(value, false); + + EXPECT_TRUE(leaf.isValueOff(32)); + leaf.setValueOnUnsafe(32); + EXPECT_TRUE(leaf.isValueOn(32)); + leaf.setValueOffUnsafe(32); + EXPECT_TRUE(leaf.isValueOff(32)); + leaf.setActiveStateUnsafe(32, true); + EXPECT_TRUE(leaf.isValueOn(32)); + leaf.setActiveStateUnsafe(32, false); + EXPECT_TRUE(leaf.isValueOff(32)); + + leaf.setValueOnlyUnsafe(32, true); + EXPECT_EQ(leaf.getValueUnsafe(32), true); + EXPECT_TRUE(leaf.isValueOn(32)); + leaf.setValueOffUnsafe(32); + EXPECT_TRUE(leaf.isValueOff(32)); + + leaf.setValueOnUnsafe(33, true); + EXPECT_TRUE(leaf.isValueOn(33)); + EXPECT_EQ(leaf.getValueUnsafe(33), true); + leaf.setValueOffUnsafe(33, false); + EXPECT_TRUE(leaf.isValueOff(33)); + EXPECT_EQ(leaf.getValueUnsafe(33), false); +} + diff --git a/openvdb/openvdb/unittest/TestLeafOrigin.cc b/openvdb/openvdb/unittest/TestLeafOrigin.cc index 2bc95accf9..b7f73be4fb 100644 --- a/openvdb/openvdb/unittest/TestLeafOrigin.cc +++ b/openvdb/openvdb/unittest/TestLeafOrigin.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestLevelSetFilter.cc b/openvdb/openvdb/unittest/TestLevelSetFilter.cc new file mode 100644 index 0000000000..12fc472f01 --- /dev/null +++ b/openvdb/openvdb/unittest/TestLevelSetFilter.cc @@ -0,0 +1,80 @@ +// Copyright Contributors to the OpenVDB Project +// SPDX-License-Identifier: Apache-2.0 + +#include +#include +#include +#include +#include // for csgUnion() + +#include + +using namespace openvdb; + +class TestLevelSetFilter: public ::testing::Test +{ +public: + void SetUp() override { openvdb::initialize(); } + void TearDown() override { openvdb::uninitialize(); } + + void testLevelSetFillet(); +}; // class TestLevelSetFilter + + +//////////////////////////////////////// + + +TEST_F(TestLevelSetFilter, testLevelSetFillet) +{ + using GridT = FloatGrid; + using FilterT = tools::LevelSetFilter; + + const float radius = 5.0f; + const float voxelSize = 1.0f; + const float halfWidth = 3.0f; + typename GridT::Ptr sdfGrid = tools::createLevelSetSphere(/*radius=*/radius, + /*center=*/Vec3f(-radius, 0.0f, 0.0f), + /*dx=*/voxelSize, /*halfWidth*/ halfWidth); + typename GridT::Ptr sdfGridB = tools::createLevelSetSphere(/*radius=*/radius, + /*center=*/Vec3f(radius, 0.0f, 0.0f), + /*dx=*/voxelSize, /*halfWidth*/ halfWidth); + typename GridT::Accessor acc = sdfGrid->getAccessor(); + + EXPECT_TRUE(sdfGrid); + EXPECT_TRUE(sdfGridB); + + tools::csgUnion(*sdfGrid, *sdfGridB); + + { + EXPECT_TRUE(sdfGrid); + + Coord ijk(0, 3, 0); + + // We expect that the intersection between the two spheres are at (0, 0, 0) + // so the SDF value of the union in these offsets locations should be > 0 + EXPECT_TRUE(acc.getValue(ijk) > 0.f); + EXPECT_TRUE(acc.getValue(ijk.offsetBy(0, 0, 1)) > 0.0f); + EXPECT_TRUE(acc.getValue(ijk.offsetBy(0, 0,-1)) > 0.0f); + EXPECT_TRUE(acc.getValue(ijk.offsetBy(0,-1, 0)) > 0.0f); + EXPECT_TRUE(acc.getValue(ijk.offsetBy(0,-1, 1)) > 0.0f); + EXPECT_TRUE(acc.getValue(ijk.offsetBy(0,-1,-1)) > 0.0f); + } + + FilterT filter(*sdfGrid); + filter.fillet(); + + { + EXPECT_TRUE(sdfGrid); + + Coord ijk(0, 3, 0); + + // After the fillet operation, we expect that the zero-isocontour is + // pushed outward. + EXPECT_TRUE(acc.getValue(ijk) < 0.f); + EXPECT_TRUE(acc.getValue(ijk.offsetBy(0, 0, 1)) < 0.0f); + EXPECT_TRUE(acc.getValue(ijk.offsetBy(0, 0,-1)) < 0.0f); + EXPECT_TRUE(acc.getValue(ijk.offsetBy(0,-1, 0)) < 0.0f); + EXPECT_TRUE(acc.getValue(ijk.offsetBy(0,-1, 1)) < 0.0f); + EXPECT_TRUE(acc.getValue(ijk.offsetBy(0,-1,-1)) < 0.0f); + } +} diff --git a/openvdb/openvdb/unittest/TestLevelSetRayIntersector.cc b/openvdb/openvdb/unittest/TestLevelSetRayIntersector.cc index a1971660ce..aeeec180a0 100644 --- a/openvdb/openvdb/unittest/TestLevelSetRayIntersector.cc +++ b/openvdb/openvdb/unittest/TestLevelSetRayIntersector.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file unittest/TestLevelSetRayIntersector.cc /// @author Ken Museth diff --git a/openvdb/openvdb/unittest/TestLevelSetUtil.cc b/openvdb/openvdb/unittest/TestLevelSetUtil.cc index 3887ff358c..78e14ac9fa 100644 --- a/openvdb/openvdb/unittest/TestLevelSetUtil.cc +++ b/openvdb/openvdb/unittest/TestLevelSetUtil.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -146,7 +146,7 @@ TEST_F(TestLevelSetUtil, testSegmentationTools) openvdb::tools::segmentSDF(*sdfGrid, segments); EXPECT_EQ(size_t(1), segments.size()); - EXPECT_EQ(openvdb::Index32(0), segments[0]->tree().leafCount()); + EXPECT_EQ(openvdb::Index64(0), segments[0]->tree().leafCount()); EXPECT_EQ(10.2f, segments[0]->background()); } @@ -173,7 +173,7 @@ TEST_F(TestLevelSetUtil, testSegmentationTools) openvdb::tools::segmentSDF(*sdfGrid, segments); EXPECT_EQ(size_t(1), segments.size()); - EXPECT_EQ(openvdb::Index32(0), segments[0]->tree().leafCount()); + EXPECT_EQ(openvdb::Index64(0), segments[0]->tree().leafCount()); EXPECT_EQ(sdfGrid->background(), segments[0]->background()); } @@ -195,14 +195,14 @@ TEST_F(TestLevelSetUtil, testSegmentationTools) openvdb::FloatGrid::Ptr grid = openvdb::FloatGrid::create(/*background=*/3.1f); - EXPECT_EQ(openvdb::Index32(0), grid->tree().leafCount()); + EXPECT_EQ(openvdb::Index64(0), grid->tree().leafCount()); std::vector segments; openvdb::tools::segmentActiveVoxels(*grid, segments); // note that an empty volume should segment into an empty volume EXPECT_EQ(size_t(1), segments.size()); - EXPECT_EQ(openvdb::Index32(0), segments[0]->tree().leafCount()); + EXPECT_EQ(openvdb::Index64(0), segments[0]->tree().leafCount()); EXPECT_EQ(3.1f, segments[0]->background()); } @@ -213,14 +213,14 @@ TEST_F(TestLevelSetUtil, testSegmentationTools) grid->tree().touchLeaf(openvdb::Coord(0,0,0)); grid->tree().touchLeaf(openvdb::Coord(100,100,100)); - EXPECT_EQ(openvdb::Index32(2), grid->tree().leafCount()); + EXPECT_EQ(openvdb::Index64(2), grid->tree().leafCount()); EXPECT_EQ(openvdb::Index64(0), grid->tree().activeVoxelCount()); std::vector segments; openvdb::tools::segmentActiveVoxels(*grid, segments); EXPECT_EQ(size_t(1), segments.size()); - EXPECT_EQ(openvdb::Index32(0), segments[0]->tree().leafCount()); + EXPECT_EQ(openvdb::Index64(0), segments[0]->tree().leafCount()); } } diff --git a/openvdb/openvdb/unittest/TestLinearInterp.cc b/openvdb/openvdb/unittest/TestLinearInterp.cc index 137c81f7de..19208a7107 100644 --- a/openvdb/openvdb/unittest/TestLinearInterp.cc +++ b/openvdb/openvdb/unittest/TestLinearInterp.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "gtest/gtest.h" #include diff --git a/openvdb/openvdb/unittest/TestMaps.cc b/openvdb/openvdb/unittest/TestMaps.cc index 85da25eb8c..28061b63f2 100644 --- a/openvdb/openvdb/unittest/TestMaps.cc +++ b/openvdb/openvdb/unittest/TestMaps.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestMat4Metadata.cc b/openvdb/openvdb/unittest/TestMat4Metadata.cc index d7a58b8379..fcf89d3613 100644 --- a/openvdb/openvdb/unittest/TestMat4Metadata.cc +++ b/openvdb/openvdb/unittest/TestMat4Metadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestMath.cc b/openvdb/openvdb/unittest/TestMath.cc index 8b5b4ba290..e7e721e7a1 100644 --- a/openvdb/openvdb/unittest/TestMath.cc +++ b/openvdb/openvdb/unittest/TestMath.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestMeanCurvature.cc b/openvdb/openvdb/unittest/TestMeanCurvature.cc index c4c7de1cbd..904e74f68c 100644 --- a/openvdb/openvdb/unittest/TestMeanCurvature.cc +++ b/openvdb/openvdb/unittest/TestMeanCurvature.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestMerge.cc b/openvdb/openvdb/unittest/TestMerge.cc index 69fccf40cb..3a98d58479 100644 --- a/openvdb/openvdb/unittest/TestMerge.cc +++ b/openvdb/openvdb/unittest/TestMerge.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -82,7 +82,7 @@ TEST_F(TestMerge, testTreeToMerge) { // non-const tree FloatGrid::Ptr grid = createLevelSet(); grid->tree().touchLeaf(Coord(8)); - EXPECT_EQ(Index(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); tools::TreeToMerge treeToMerge{grid->tree(), Steal()}; EXPECT_EQ(&grid->constTree().root(), treeToMerge.rootPtr()); @@ -98,14 +98,14 @@ TEST_F(TestMerge, testTreeToMerge) const LeafNode* leafNode = treeToMerge.probeConstNode(Coord(8)); EXPECT_TRUE(leafNode); EXPECT_EQ(grid->constTree().probeConstLeaf(Coord(8)), leafNode); - EXPECT_EQ(Index(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); EXPECT_EQ(Index(1), grid->tree().root().childCount()); // steal leaf node std::unique_ptr leafNodePtr = treeToMerge.stealOrDeepCopyNode(Coord(8)); EXPECT_TRUE(leafNodePtr); - EXPECT_EQ(Index(0), grid->tree().leafCount()); + EXPECT_EQ(Index64(0), grid->tree().leafCount()); EXPECT_EQ(leafNodePtr->origin(), Coord(8)); EXPECT_EQ(Index(1), grid->tree().root().childCount()); @@ -139,7 +139,7 @@ TEST_F(TestMerge, testTreeToMerge) { // const tree FloatGrid::Ptr grid = createLevelSet(); grid->tree().touchLeaf(Coord(8)); - EXPECT_EQ(Index(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); tools::TreeToMerge treeToMerge{grid->constTree(), DeepCopy(), /*initialize=*/false}; EXPECT_TRUE(!treeToMerge.hasMask()); @@ -158,14 +158,14 @@ TEST_F(TestMerge, testTreeToMerge) const LeafNode* leafNode = treeToMerge.probeConstNode(Coord(8)); EXPECT_TRUE(leafNode); EXPECT_EQ(grid->constTree().probeConstLeaf(Coord(8)), leafNode); - EXPECT_EQ(Index(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); EXPECT_EQ(Index(1), grid->tree().root().childCount()); { // deep copy leaf node tools::TreeToMerge treeToMerge2{grid->constTree(), DeepCopy()}; std::unique_ptr leafNodePtr = treeToMerge2.stealOrDeepCopyNode(Coord(8)); EXPECT_TRUE(leafNodePtr); - EXPECT_EQ(Index(1), grid->tree().leafCount()); // leaf has not been stolen + EXPECT_EQ(Index64(1), grid->tree().leafCount()); // leaf has not been stolen EXPECT_EQ(leafNodePtr->origin(), Coord(8)); EXPECT_EQ(Index(1), grid->tree().root().childCount()); } @@ -221,7 +221,7 @@ TEST_F(TestMerge, testTreeToMerge) FloatGrid::Ptr grid = createLevelSet(); grid->tree().touchLeaf(Coord(8)); - EXPECT_EQ(Index(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); treeToMerge.reset(grid->treePtr(), Steal()); } @@ -241,7 +241,7 @@ TEST_F(TestMerge, testTreeToMerge) EXPECT_TRUE(!treeToMerge2.treeToSteal()); EXPECT_TRUE(treeToMerge2.treeToDeepCopy()); - EXPECT_EQ(Index(0), treeToMerge2.treeToDeepCopy()->leafCount()); + EXPECT_EQ(Index64(0), treeToMerge2.treeToDeepCopy()->leafCount()); FloatGrid::Ptr grid = createLevelSet(); grid->tree().touchLeaf(Coord(8)); @@ -249,7 +249,7 @@ TEST_F(TestMerge, testTreeToMerge) EXPECT_TRUE(treeToMerge2.treeToSteal()); EXPECT_TRUE(!treeToMerge2.treeToDeepCopy()); - EXPECT_EQ(Index(1), treeToMerge2.treeToSteal()->leafCount()); + EXPECT_EQ(Index64(1), treeToMerge2.treeToSteal()->leafCount()); } } @@ -908,7 +908,7 @@ TEST_F(TestMerge, testCsgUnion) tree::DynamicNodeManager nodeManager(grid->tree()); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); } { // merge a leaf node into a grid with an outside tile @@ -955,8 +955,8 @@ TEST_F(TestMerge, testCsgUnion) tree::DynamicNodeManager nodeManager(grid->tree()); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), grid->tree().leafCount()); - EXPECT_EQ(Index32(0), grid2->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(0), grid2->tree().leafCount()); // test background values are remapped @@ -1027,8 +1027,8 @@ TEST_F(TestMerge, testCsgUnion) FloatGrid::Ptr grid2 = createLevelSet(); grid2->tree().touchLeaf(Coord(0, 0, 0)); - EXPECT_EQ(Index32(0), grid->tree().leafCount()); - EXPECT_EQ(Index32(1), grid2->tree().leafCount()); + EXPECT_EQ(Index64(0), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid2->tree().leafCount()); // merge from a const tree @@ -1038,9 +1038,9 @@ TEST_F(TestMerge, testCsgUnion) tree::DynamicNodeManager nodeManager(grid->tree()); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); // leaf has been deep copied not stolen - EXPECT_EQ(Index32(1), grid2->tree().leafCount()); + EXPECT_EQ(Index64(1), grid2->tree().leafCount()); } } @@ -1772,7 +1772,7 @@ TEST_F(TestMerge, testCsgIntersection) tree::DynamicNodeManager nodeManager(grid->tree()); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(0), grid->tree().leafCount()); + EXPECT_EQ(Index64(0), grid->tree().leafCount()); } { // merge a leaf node into a grid with a background tile @@ -1785,7 +1785,7 @@ TEST_F(TestMerge, testCsgIntersection) tree::DynamicNodeManager nodeManager(grid->tree()); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(0), grid->tree().leafCount()); + EXPECT_EQ(Index64(0), grid->tree().leafCount()); } { // merge a leaf node into a grid with an outside tile @@ -1828,8 +1828,8 @@ TEST_F(TestMerge, testCsgIntersection) tree::DynamicNodeManager nodeManager(grid->tree()); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), grid->tree().leafCount()); - EXPECT_EQ(Index32(0), grid2->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(0), grid2->tree().leafCount()); // test background values are remapped @@ -1901,8 +1901,8 @@ TEST_F(TestMerge, testCsgIntersection) FloatGrid::Ptr grid2 = createLevelSet(); grid2->tree().touchLeaf(Coord(0, 0, 0)); - EXPECT_EQ(Index32(0), grid->tree().leafCount()); - EXPECT_EQ(Index32(1), grid2->tree().leafCount()); + EXPECT_EQ(Index64(0), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid2->tree().leafCount()); // merge from a const tree @@ -1912,9 +1912,9 @@ TEST_F(TestMerge, testCsgIntersection) tree::DynamicNodeManager nodeManager(grid->tree()); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); // leaf has been deep copied not stolen - EXPECT_EQ(Index32(1), grid2->tree().leafCount()); + EXPECT_EQ(Index64(1), grid2->tree().leafCount()); } { // merge three leaf nodes from four grids @@ -2472,15 +2472,15 @@ TEST_F(TestMerge, testCsgDifference) FloatGrid::Ptr grid2 = createLevelSet(); grid2->tree().touchLeaf(Coord(0, 0, 0)); - EXPECT_EQ(Index32(0), grid->tree().leafCount()); - EXPECT_EQ(Index32(1), grid2->tree().leafCount()); + EXPECT_EQ(Index64(0), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid2->tree().leafCount()); tools::CsgDifferenceOp mergeOp(grid2->tree(), Steal()); tree::DynamicNodeManager nodeManager(grid->tree()); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), grid->tree().leafCount()); - EXPECT_EQ(Index32(0), grid2->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(0), grid2->tree().leafCount()); } { // merge two leaf nodes into a grid @@ -2489,8 +2489,8 @@ TEST_F(TestMerge, testCsgDifference) FloatGrid::Ptr grid2 = createLevelSet(); grid2->tree().touchLeaf(Coord(0, 0, 0)); - EXPECT_EQ(Index32(1), grid->tree().leafCount()); - EXPECT_EQ(Index32(1), grid2->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid2->tree().leafCount()); tools::CsgDifferenceOp mergeOp(grid2->tree(), Steal()); tree::DynamicNodeManager nodeManager(grid->tree()); @@ -2556,15 +2556,15 @@ TEST_F(TestMerge, testCsgDifference) FloatGrid::Ptr grid2 = createLevelSet(); grid2->tree().touchLeaf(Coord(0, 0, 0)); - EXPECT_EQ(Index32(0), grid->tree().leafCount()); - EXPECT_EQ(Index32(1), grid2->tree().leafCount()); + EXPECT_EQ(Index64(0), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid2->tree().leafCount()); tools::CsgDifferenceOp mergeOp(grid2->constTree(), DeepCopy()); tree::DynamicNodeManager nodeManager(grid->tree()); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), grid->tree().leafCount()); - EXPECT_EQ(Index32(1), grid2->tree().leafCount()); + EXPECT_EQ(Index64(1), grid->tree().leafCount()); + EXPECT_EQ(Index64(1), grid2->tree().leafCount()); } } @@ -2887,7 +2887,7 @@ TEST_F(TestMerge, testSum) tree::DynamicNodeManager nodeManager(tree); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(tree.cbeginLeaf()->getFirstValue(), 0.0f); } @@ -2902,7 +2902,7 @@ TEST_F(TestMerge, testSum) tree::DynamicNodeManager nodeManager(tree); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(Index(0), getTileCount(tree.root())); auto iter = tree.cbeginLeaf(); EXPECT_EQ(iter->getValue(0), 10.0f); @@ -2924,7 +2924,7 @@ TEST_F(TestMerge, testSum) tree::DynamicNodeManager nodeManager(tree); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(Index(0), getTileCount(tree.root())); auto iter = tree.cbeginLeaf(); EXPECT_EQ(iter->getValue(0), 210.0f); @@ -2949,7 +2949,7 @@ TEST_F(TestMerge, testSum) tree::DynamicNodeManager nodeManager(tree); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(Index(0), getTileCount(tree.root())); auto iter = tree.cbeginLeaf(); EXPECT_EQ(iter->getValue(0), 210.0f); @@ -2973,7 +2973,7 @@ TEST_F(TestMerge, testSum) tree::DynamicNodeManager nodeManager(tree); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(Index(0), getTileCount(tree.root())); auto iter = tree.cbeginLeaf(); EXPECT_EQ(iter->getValue(0), 15.0f); @@ -2995,7 +2995,7 @@ TEST_F(TestMerge, testSum) tree::DynamicNodeManager nodeManager(tree); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(Index(0), getTileCount(tree.root())); auto iter = tree.cbeginLeaf(); EXPECT_EQ(iter->getValue(0), 10.0f); @@ -3017,7 +3017,7 @@ TEST_F(TestMerge, testSum) tree::DynamicNodeManager nodeManager(tree); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(Index(0), getTileCount(tree.root())); auto iter = tree.cbeginLeaf(); EXPECT_EQ(iter->getValue(0), 10.0f); @@ -3039,7 +3039,7 @@ TEST_F(TestMerge, testSum) tree::DynamicNodeManager nodeManager(tree); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(Index(0), getTileCount(tree.root())); auto iter = tree.cbeginLeaf(); EXPECT_EQ(iter->getValue(0), 10.0f); @@ -3155,8 +3155,8 @@ TEST_F(TestMerge, testSum) FloatGrid::Ptr grid2 = createLevelSet(); tree2.touchLeaf(Coord(0, 0, 0)); - EXPECT_EQ(Index32(0), tree.leafCount()); - EXPECT_EQ(Index32(1), tree2.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); + EXPECT_EQ(Index64(1), tree2.leafCount()); // merge from a const tree @@ -3168,9 +3168,9 @@ TEST_F(TestMerge, testSum) tree::DynamicNodeManager nodeManager(tree); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); // leaf has been deep copied not stolen - EXPECT_EQ(Index32(1), tree2.leafCount()); + EXPECT_EQ(Index64(1), tree2.leafCount()); } } @@ -3185,7 +3185,7 @@ TEST_F(TestMerge, testSum) tree::DynamicNodeManager nodeManager(tree); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(Index(0), getTileCount(tree.root())); auto iter = tree.cbeginLeaf(); EXPECT_EQ(iter->getValue(0), Vec3s(1.0f, 2.0f, 3.0f)); @@ -3206,7 +3206,7 @@ TEST_F(TestMerge, testSum) tree::DynamicNodeManager nodeManager(tree); nodeManager.foreachTopDown(mergeOp); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_EQ(Index(0), getTileCount(tree.root())); auto iter = tree.cbeginLeaf(); EXPECT_FALSE(iter->isValueOn(0)); diff --git a/openvdb/openvdb/unittest/TestMeshToVolume.cc b/openvdb/openvdb/unittest/TestMeshToVolume.cc index d4d0e92c1f..0ec75e4dad 100644 --- a/openvdb/openvdb/unittest/TestMeshToVolume.cc +++ b/openvdb/openvdb/unittest/TestMeshToVolume.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestMetaMap.cc b/openvdb/openvdb/unittest/TestMetaMap.cc index 20e2ba0dfc..2c37af43b8 100644 --- a/openvdb/openvdb/unittest/TestMetaMap.cc +++ b/openvdb/openvdb/unittest/TestMetaMap.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestMetadata.cc b/openvdb/openvdb/unittest/TestMetadata.cc index bdf3efd685..5d7334bb44 100644 --- a/openvdb/openvdb/unittest/TestMetadata.cc +++ b/openvdb/openvdb/unittest/TestMetadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestMetadataIO.cc b/openvdb/openvdb/unittest/TestMetadataIO.cc index b98d75b73e..324e87a298 100644 --- a/openvdb/openvdb/unittest/TestMetadataIO.cc +++ b/openvdb/openvdb/unittest/TestMetadataIO.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestMorphology.cc b/openvdb/openvdb/unittest/TestMorphology.cc index 71aeb716c8..a03e1db857 100644 --- a/openvdb/openvdb/unittest/TestMorphology.cc +++ b/openvdb/openvdb/unittest/TestMorphology.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -113,7 +113,7 @@ TestMorphologyInternal::testMorphActiveLeafValues() EXPECT_EQ(Index64(1), tree.activeVoxelCount()); openvdb::tools::erodeActiveValues(tree, 1, NN, openvdb::tools::IGNORE_TILES); EXPECT_EQ(Index64(0), tree.activeVoxelCount()); - EXPECT_EQ(Index32(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); // check values if (!IsMask) { EXPECT_EQ(tree.getValue(xyz), ValueType(1.0)); @@ -124,7 +124,7 @@ TestMorphologyInternal::testMorphActiveLeafValues() { // Create an active, leaf node-sized tile and a single edge/corner voxel tree.clear(); tree.addTile(/*level*/1, Coord(0), ValueType(1.0), true); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(leafDim * leafDim * leafDim), tree.activeVoxelCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); @@ -143,7 +143,7 @@ TestMorphologyInternal::testMorphActiveLeafValues() if (NN == openvdb::tools::NN_FACE_EDGE_VERTEX) expected += 22; // 4 overlapping EXPECT_EQ(expected, tree.activeVoxelCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); - Index32 leafs; + Index64 leafs; if (NN == openvdb::tools::NN_FACE) leafs = 3; if (NN == openvdb::tools::NN_FACE_EDGE) leafs = 6; if (NN == openvdb::tools::NN_FACE_EDGE_VERTEX) leafs = 7; @@ -434,7 +434,7 @@ TestMorphologyInternal::testMorphActiveValues() { // Test behaviour with an existing active tile at (0,0,0) tree.clear(); tree.addTile(/*level*/1, Coord(0), ValueType(1.0), true); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(leafDim * leafDim * leafDim), tree.activeVoxelCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); @@ -450,7 +450,7 @@ TestMorphologyInternal::testMorphActiveValues() TreeT erodeexp(tree), erodepres(tree); openvdb::tools::erodeActiveValues(erodeexp, 1, NN, openvdb::tools::EXPAND_TILES); Index64 expected = (leafDim-2) * (leafDim-2) * (leafDim-2); - EXPECT_EQ(Index32(1), erodeexp.leafCount()); + EXPECT_EQ(Index64(1), erodeexp.leafCount()); EXPECT_EQ(expected, erodeexp.activeVoxelCount()); EXPECT_EQ(Index64(0), erodeexp.activeTileCount()); EXPECT_TRUE(erodeexp.probeConstLeaf(Coord(0))); @@ -465,7 +465,7 @@ TestMorphologyInternal::testMorphActiveValues() if (NN == openvdb::tools::NN_FACE) expected += (leafDim * leafDim) * 6; // faces if (NN == openvdb::tools::NN_FACE_EDGE) expected += ((leafDim * leafDim) * 6) + (leafDim) * 12; // edges if (NN == openvdb::tools::NN_FACE_EDGE_VERTEX) expected += ((leafDim * leafDim) * 6) + ((leafDim) * 12) + 8; // edges - EXPECT_EQ(Index32(1+offsets), tree.leafCount()); + EXPECT_EQ(Index64(1+offsets), tree.leafCount()); EXPECT_EQ(expected, tree.activeVoxelCount()); EXPECT_EQ(Index64(0), tree.activeTileCount()); // Check actual values around center node faces @@ -492,7 +492,7 @@ TestMorphologyInternal::testMorphActiveValues() TreeT erode(tree); openvdb::tools::erodeActiveValues(erode, 1, NN, openvdb::tools::IGNORE_TILES); Index64 expected = leafDim * leafDim * leafDim; - EXPECT_EQ(Index32(1+offsets), erode.leafCount()); + EXPECT_EQ(Index64(1+offsets), erode.leafCount()); EXPECT_EQ(expected, erode.activeVoxelCount()); EXPECT_EQ(Index64(0), erode.activeTileCount()); EXPECT_TRUE(erode.probeConstLeaf(Coord(0))); @@ -514,7 +514,7 @@ TestMorphologyInternal::testMorphActiveValues() if (NN == openvdb::tools::NN_FACE_EDGE) expected += ((leafDim * leafDim) * 6) + (leafDim) * 12; // edges if (NN == openvdb::tools::NN_FACE_EDGE_VERTEX) expected += ((leafDim * leafDim) * 6) + ((leafDim) * 12) + 8; // edges - EXPECT_EQ(Index32(offsets), tree.leafCount()); + EXPECT_EQ(Index64(offsets), tree.leafCount()); EXPECT_EQ(expected, tree.activeVoxelCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); EXPECT_TRUE(copy.hasSameTopology(tree)); @@ -539,7 +539,7 @@ TestMorphologyInternal::testMorphActiveValues() openvdb::tools::erodeActiveValues(erode, 1, NN, openvdb::tools::PRESERVE_TILES); // PRESERVE_TILES will prune the result Index64 expected = leafDim * leafDim * leafDim; - EXPECT_EQ(Index32(0), erode.leafCount()); + EXPECT_EQ(Index64(0), erode.leafCount()); EXPECT_EQ(expected, erode.activeVoxelCount()); EXPECT_EQ(Index64(1), erode.activeTileCount()); EXPECT_TRUE(!erode.probeConstLeaf(Coord(0))); @@ -549,7 +549,7 @@ TestMorphologyInternal::testMorphActiveValues() { // Test tile preservation with voxel topology - create an active, leaf node-sized tile and a single edge voxel tree.clear(); tree.addTile(/*level*/1, Coord(0), ValueType(1.0), true); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_EQ(Index64(leafDim * leafDim * leafDim), tree.activeVoxelCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); @@ -575,7 +575,7 @@ TestMorphologyInternal::testMorphActiveValues() // Check actual values around center node faces EXPECT_EQ(Index64(1), tree.activeTileCount()); - EXPECT_EQ(Index32(offsets), tree.leafCount()); + EXPECT_EQ(Index64(offsets), tree.leafCount()); EXPECT_TRUE(!tree.probeConstLeaf(Coord(0))); EXPECT_TRUE(tree.isValueOn(Coord(0))); for (int i = 0; i < int(leafDim); ++i) { @@ -592,7 +592,7 @@ TestMorphologyInternal::testMorphActiveValues() { // Test tile is preserved with erosions IGNORE_TILES, irrespective of iterations openvdb::tools::erodeActiveValues(tree, 10, NN, openvdb::tools::IGNORE_TILES); EXPECT_EQ(Index64(1), tree.activeTileCount()); - EXPECT_EQ(Index32(offsets), tree.leafCount()); + EXPECT_EQ(Index64(offsets), tree.leafCount()); EXPECT_EQ(Index64(leafDim * leafDim * leafDim), tree.activeVoxelCount()); EXPECT_TRUE(!tree.probeConstLeaf(Coord(0))); EXPECT_TRUE(tree.isValueOn(Coord(0))); @@ -613,7 +613,7 @@ TestMorphologyInternal::testMorphActiveValues() tree.touchLeaf(Coord(leafDim*6, 0, 0))->setValuesOn(); Index64 expected = (leafDim * leafDim * leafDim) + ((leafDim * leafDim * leafDim) - (leafDim * leafDim)) * 2; - EXPECT_EQ(Index32(3), tree.leafCount()); + EXPECT_EQ(Index64(3), tree.leafCount()); EXPECT_EQ(expected, tree.activeVoxelCount()); EXPECT_EQ(Index64(0), tree.activeTileCount()); @@ -631,7 +631,7 @@ TestMorphologyInternal::testMorphActiveValues() if (NN == openvdb::tools::NN_FACE_EDGE) expected = offsets*3 -10; if (NN == openvdb::tools::NN_FACE_EDGE_VERTEX) expected = offsets*3 -18; if (!IsMask) expected += 1; - EXPECT_EQ(Index32(expected), tree.leafCount()); + EXPECT_EQ(Index64(expected), tree.leafCount()); // first if (IsMask) { // should have been pruned @@ -654,7 +654,7 @@ TestMorphologyInternal::testMorphActiveValues() openvdb::tools::PRESERVE_TILES); expected = (leafDim * leafDim * leafDim) + ((leafDim * leafDim * leafDim) - (leafDim * leafDim)) * 2; - EXPECT_EQ(Index32(2), tree.leafCount()); + EXPECT_EQ(Index64(2), tree.leafCount()); EXPECT_EQ(expected, tree.activeVoxelCount()); EXPECT_EQ(Index64(1), tree.activeTileCount()); } diff --git a/openvdb/openvdb/unittest/TestMultiResGrid.cc b/openvdb/openvdb/unittest/TestMultiResGrid.cc index 2ac2f804a8..32735d508f 100644 --- a/openvdb/openvdb/unittest/TestMultiResGrid.cc +++ b/openvdb/openvdb/unittest/TestMultiResGrid.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestName.cc b/openvdb/openvdb/unittest/TestName.cc index e56fa2984e..89fc2d1ebc 100644 --- a/openvdb/openvdb/unittest/TestName.cc +++ b/openvdb/openvdb/unittest/TestName.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestNodeIterator.cc b/openvdb/openvdb/unittest/TestNodeIterator.cc index 74a0987de9..a977e4200c 100644 --- a/openvdb/openvdb/unittest/TestNodeIterator.cc +++ b/openvdb/openvdb/unittest/TestNodeIterator.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include diff --git a/openvdb/openvdb/unittest/TestNodeManager.cc b/openvdb/openvdb/unittest/TestNodeManager.cc index 6041825bbc..6bd4759b3e 100644 --- a/openvdb/openvdb/unittest/TestNodeManager.cc +++ b/openvdb/openvdb/unittest/TestNodeManager.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -294,8 +294,8 @@ TEST_F(TestNodeManager, testDynamic) std::make_unique(Coord(0, 0, 0), /*value=*/1.0f); EXPECT_TRUE(sourceTree.root().addChild(child.release())); - EXPECT_EQ(Index32(0), sourceTree.leafCount()); - EXPECT_EQ(Index32(2), sourceTree.nonLeafCount()); + EXPECT_EQ(Index64(0), sourceTree.leafCount()); + EXPECT_EQ(Index64(2), sourceTree.nonLeafCount()); ExpandOp expandOp; @@ -304,7 +304,7 @@ TEST_F(TestNodeManager, testDynamic) openvdb::tree::NodeManager manager(tree); EXPECT_EQ(Index64(1), manager.nodeCount()); manager.foreachTopDown(expandOp); - EXPECT_EQ(Index32(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); // first level has been expanded, but node manager cache does not include the new nodes SumOp sumOp; @@ -324,7 +324,7 @@ TEST_F(TestNodeManager, testDynamic) Int32Tree tree(sourceTree); openvdb::tree::DynamicNodeManager manager(tree); manager.foreachTopDown(expandOp, /*threaded=*/true, /*leafGrainSize=*/32, /*nonLeafGrainSize=*/8); - EXPECT_EQ(Index32(32768), tree.leafCount()); + EXPECT_EQ(Index64(32768), tree.leafCount()); SumOp sumOp; manager.reduceTopDown(sumOp); @@ -340,7 +340,7 @@ TEST_F(TestNodeManager, testDynamic) openvdb::tree::DynamicNodeManager manager(tree); ExpandOp zeroExpandOp(true); manager.foreachTopDown(zeroExpandOp); - EXPECT_EQ(Index32(32768), tree.leafCount()); + EXPECT_EQ(Index64(32768), tree.leafCount()); SumOp sumOp; manager.reduceTopDown(sumOp); diff --git a/openvdb/openvdb/unittest/TestNodeMask.cc b/openvdb/openvdb/unittest/TestNodeMask.cc index d988c65ffc..b501e12ea2 100644 --- a/openvdb/openvdb/unittest/TestNodeMask.cc +++ b/openvdb/openvdb/unittest/TestNodeMask.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestNodeVisitor.cc b/openvdb/openvdb/unittest/TestNodeVisitor.cc index aa14faba32..e24bf72bb2 100644 --- a/openvdb/openvdb/unittest/TestNodeVisitor.cc +++ b/openvdb/openvdb/unittest/TestNodeVisitor.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -22,7 +22,7 @@ struct NodeCountOp counts[level]++; } - std::vector counts; + std::vector counts; }; // struct NodeCountOp @@ -35,10 +35,14 @@ TEST_F(TestNodeVisitor, testNodeCount) NodeCountOp nodeCountOp; tools::visitNodesDepthFirst(grid->tree(), nodeCountOp); - std::vector nodeCount1 = nodeCountOp.counts; + std::vector nodeCount1 = nodeCountOp.counts; +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + std::vector nodeCount2 = grid->tree().nodeCount(); +#else std::vector nodeCount2 = grid->tree().nodeCount(); +#endif - EXPECT_EQ(nodeCount1.size(), nodeCount2.size()); + EXPECT_EQ(nodeCount1.size(), Index64(nodeCount2.size())); for (size_t i = 0; i < nodeCount1.size(); i++) { EXPECT_EQ(nodeCount1[i], nodeCount2[i]); @@ -55,7 +59,7 @@ struct LeafCountOp void operator()(const NodeT&, size_t) { } void operator()(const LeafT&, size_t) { count++; } - openvdb::Index32 count{0}; + openvdb::Index64 count{0}; }; // struct LeafCountOp @@ -94,7 +98,7 @@ struct DescendOp } openvdb::Index32 previousLevel{0}; - openvdb::Index32 count{0}; + openvdb::Index64 count{0}; }; // struct DescendOp @@ -142,9 +146,14 @@ TEST_F(TestNodeVisitor, testOriginArray) FloatGrid::Ptr grid = tools::createLevelSetCube(/*scale=*/10.0f); + Index64 totalNodeCount(0); +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + std::vector nodeCount = grid->tree().nodeCount(); + for (Index64 count : nodeCount) totalNodeCount += count; +#else std::vector nodeCount = grid->tree().nodeCount(); - Index32 totalNodeCount(0); - for (Index32 count : nodeCount) totalNodeCount += count; + for (Index32 count : nodeCount) totalNodeCount += Index64(count); +#endif // use an offset size_t offset = 10; @@ -203,12 +212,12 @@ TEST_F(TestNodeVisitor, testPartialDeactivate) DeactivateOp deactivateOp; tools::DepthFirstNodeVisitor::visit(*iter, deactivateOp); - EXPECT_EQ(Index32(1413), grid->tree().leafCount()); + EXPECT_EQ(Index64(1413), grid->tree().leafCount()); tools::pruneInactive(grid->tree()); // a subset of the leaf nodes have now been deactivated and removed - EXPECT_EQ(Index32(1195), grid->tree().leafCount()); + EXPECT_EQ(Index64(1195), grid->tree().leafCount()); } diff --git a/openvdb/openvdb/unittest/TestParticleAtlas.cc b/openvdb/openvdb/unittest/TestParticleAtlas.cc index e95f50b7b6..24d7defbda 100644 --- a/openvdb/openvdb/unittest/TestParticleAtlas.cc +++ b/openvdb/openvdb/unittest/TestParticleAtlas.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestParticlesToLevelSet.cc b/openvdb/openvdb/unittest/TestParticlesToLevelSet.cc index 0743d6c32e..afe381ebb4 100644 --- a/openvdb/openvdb/unittest/TestParticlesToLevelSet.cc +++ b/openvdb/openvdb/unittest/TestParticlesToLevelSet.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestPointAdvect.cc b/openvdb/openvdb/unittest/TestPointAdvect.cc index f1d3fdfaa9..123afdc060 100644 --- a/openvdb/openvdb/unittest/TestPointAdvect.cc +++ b/openvdb/openvdb/unittest/TestPointAdvect.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestPointAttribute.cc b/openvdb/openvdb/unittest/TestPointAttribute.cc index df022d196e..4fff63f23e 100644 --- a/openvdb/openvdb/unittest/TestPointAttribute.cc +++ b/openvdb/openvdb/unittest/TestPointAttribute.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -36,7 +36,7 @@ TEST_F(TestPointAttribute, testAppendDrop) PointDataTree& tree = grid->tree(); // check one leaf per point - EXPECT_EQ(tree.leafCount(), Index32(4)); + EXPECT_EQ(tree.leafCount(), Index64(4)); // retrieve first and last leaf attribute sets @@ -298,7 +298,7 @@ TEST_F(TestPointAttribute, testRename) PointDataTree& tree = grid->tree(); // check one leaf per point - EXPECT_EQ(tree.leafCount(), Index32(4)); + EXPECT_EQ(tree.leafCount(), Index64(4)); const openvdb::TypedMetadata defaultValue(5.0f); @@ -373,7 +373,7 @@ TEST_F(TestPointAttribute, testBloscCompress) PointDataTree& tree = grid->tree(); // check two leaves - EXPECT_EQ(tree.leafCount(), Index32(2)); + EXPECT_EQ(tree.leafCount(), Index64(2)); // retrieve first and last leaf attribute sets diff --git a/openvdb/openvdb/unittest/TestPointConversion.cc b/openvdb/openvdb/unittest/TestPointConversion.cc index a5197d1616..d6420019cf 100644 --- a/openvdb/openvdb/unittest/TestPointConversion.cc +++ b/openvdb/openvdb/unittest/TestPointConversion.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestPointCount.cc b/openvdb/openvdb/unittest/TestPointCount.cc index 96c838c0d5..58ea887907 100644 --- a/openvdb/openvdb/unittest/TestPointCount.cc +++ b/openvdb/openvdb/unittest/TestPointCount.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -186,7 +186,7 @@ TEST_F(TestPointCount, testGroup) PointDataTree& tree = grid->tree(); // check one leaf - EXPECT_EQ(tree.leafCount(), Index32(1)); + EXPECT_EQ(tree.leafCount(), Index64(1)); // retrieve first and last leaf attribute sets @@ -371,7 +371,7 @@ TEST_F(TestPointCount, testGroup) grid = createPointDataGrid(positions, *transform); PointDataTree& tree2 = grid->tree(); - EXPECT_EQ(tree2.leafCount(), Index32(4)); + EXPECT_EQ(tree2.leafCount(), Index64(4)); leafIter = tree2.beginLeaf(); diff --git a/openvdb/openvdb/unittest/TestPointDataLeaf.cc b/openvdb/openvdb/unittest/TestPointDataLeaf.cc index 47cf9ca541..b22153e05a 100644 --- a/openvdb/openvdb/unittest/TestPointDataLeaf.cc +++ b/openvdb/openvdb/unittest/TestPointDataLeaf.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -1523,7 +1523,7 @@ TEST_F(TestPointDataLeaf, testCopyDescriptor) PointDataTree tree2(tree); - EXPECT_EQ(tree2.leafCount(), openvdb::Index32(2)); + EXPECT_EQ(tree2.leafCount(), openvdb::Index64(2)); descrA->setGroup("test", size_t(1)); diff --git a/openvdb/openvdb/unittest/TestPointDelete.cc b/openvdb/openvdb/unittest/TestPointDelete.cc index 6ce14b4bec..fd3d68ce9e 100644 --- a/openvdb/openvdb/unittest/TestPointDelete.cc +++ b/openvdb/openvdb/unittest/TestPointDelete.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestPointGroup.cc b/openvdb/openvdb/unittest/TestPointGroup.cc index 8b8f216dd7..8133956c2b 100644 --- a/openvdb/openvdb/unittest/TestPointGroup.cc +++ b/openvdb/openvdb/unittest/TestPointGroup.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -137,7 +137,7 @@ TEST_F(TestPointGroup, testAppendDrop) PointDataTree& tree = grid->tree(); // check one leaf per point - EXPECT_EQ(tree.leafCount(), Index32(4)); + EXPECT_EQ(tree.leafCount(), Index64(4)); // retrieve first and last leaf attribute sets @@ -312,7 +312,7 @@ TEST_F(TestPointGroup, testCompact) PointDataTree& tree = grid->tree(); // check one leaf - EXPECT_EQ(tree.leafCount(), Index32(1)); + EXPECT_EQ(tree.leafCount(), Index64(1)); // retrieve first and last leaf attribute sets diff --git a/openvdb/openvdb/unittest/TestPointIndexGrid.cc b/openvdb/openvdb/unittest/TestPointIndexGrid.cc index da0ca4c1b0..ff37f35c68 100644 --- a/openvdb/openvdb/unittest/TestPointIndexGrid.cc +++ b/openvdb/openvdb/unittest/TestPointIndexGrid.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include diff --git a/openvdb/openvdb/unittest/TestPointInstantiate.cc b/openvdb/openvdb/unittest/TestPointInstantiate.cc index 4427a54bdf..df2db82a07 100644 --- a/openvdb/openvdb/unittest/TestPointInstantiate.cc +++ b/openvdb/openvdb/unittest/TestPointInstantiate.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // this removes the PointDataGrid and PointDataTree aliases #define OPENVDB_DISABLE_POINT_DATA_TREE_ALIAS diff --git a/openvdb/openvdb/unittest/TestPointMask.cc b/openvdb/openvdb/unittest/TestPointMask.cc index 97d808907c..0b8bb1104a 100644 --- a/openvdb/openvdb/unittest/TestPointMask.cc +++ b/openvdb/openvdb/unittest/TestPointMask.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestPointMove.cc b/openvdb/openvdb/unittest/TestPointMove.cc index 14e28729eb..cf165a9998 100644 --- a/openvdb/openvdb/unittest/TestPointMove.cc +++ b/openvdb/openvdb/unittest/TestPointMove.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -766,7 +766,7 @@ TEST_F(TestPointMove, testCustomDeformer) PointDataGrid::Ptr points = positionsToGrid(positions, voxelSize); PointDataGrid::Ptr cachedPoints = points->deepCopy(); - const int leafCount = points->tree().leafCount(); + const int leafCount = int(points->tree().leafCount()); const int pointCount = int(positions.size()); std::atomic resetCalls, applyCalls; diff --git a/openvdb/openvdb/unittest/TestPointPartitioner.cc b/openvdb/openvdb/unittest/TestPointPartitioner.cc index 862d277301..c42df654f9 100644 --- a/openvdb/openvdb/unittest/TestPointPartitioner.cc +++ b/openvdb/openvdb/unittest/TestPointPartitioner.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestPointRasterizeFrustum.cc b/openvdb/openvdb/unittest/TestPointRasterizeFrustum.cc index 3501417f1b..9d0d1ffa72 100644 --- a/openvdb/openvdb/unittest/TestPointRasterizeFrustum.cc +++ b/openvdb/openvdb/unittest/TestPointRasterizeFrustum.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include diff --git a/openvdb/openvdb/unittest/TestPointRasterizeSDF.cc b/openvdb/openvdb/unittest/TestPointRasterizeSDF.cc index 3a0e7fa54b..3af09c8288 100644 --- a/openvdb/openvdb/unittest/TestPointRasterizeSDF.cc +++ b/openvdb/openvdb/unittest/TestPointRasterizeSDF.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -135,7 +135,7 @@ TEST_F(TestPointRasterizeSDF, testRasterizeSpheres) EXPECT_EQ(GRID_LEVEL_SET, sdf->getGridClass()); EXPECT_EQ(float(s.halfband * s.points->voxelSize()[0]), sdf->background()); - EXPECT_EQ(Index32(8), sdf->tree().leafCount()); + EXPECT_EQ(Index64(8), sdf->tree().leafCount()); EXPECT_EQ(Index64(0), sdf->tree().activeTileCount()); EXPECT_EQ(Index64(485), sdf->tree().activeVoxelCount()); @@ -163,7 +163,7 @@ TEST_F(TestPointRasterizeSDF, testRasterizeSpheres) EXPECT_EQ(GRID_LEVEL_SET, sdf->getGridClass()); EXPECT_EQ(float(s.halfband * s.points->voxelSize()[0]), sdf->background()); - EXPECT_EQ(Index32(8), sdf->tree().leafCount()); + EXPECT_EQ(Index64(8), sdf->tree().leafCount()); EXPECT_EQ(Index64(0), sdf->tree().activeTileCount()); EXPECT_EQ(Index64(739), sdf->tree().activeVoxelCount()); @@ -192,7 +192,7 @@ TEST_F(TestPointRasterizeSDF, testRasterizeSpheres) EXPECT_EQ(GRID_LEVEL_SET, sdf->getGridClass()); EXPECT_EQ(float(s.halfband * s.transform->voxelSize()[0]), sdf->background()); - EXPECT_EQ(Index32(27), sdf->tree().leafCount()); + EXPECT_EQ(Index64(27), sdf->tree().leafCount()); EXPECT_EQ(Index64(0), sdf->tree().activeTileCount()); EXPECT_EQ(Index64(5005), sdf->tree().activeVoxelCount()); @@ -236,7 +236,7 @@ TEST_F(TestPointRasterizeSDF, testRasterizeSpheres) EXPECT_EQ(GRID_LEVEL_SET, sdf->getGridClass()); EXPECT_EQ(float(s.halfband * s.points->voxelSize()[0]), sdf->background()); - EXPECT_EQ(Index32(8), sdf->tree().leafCount()); + EXPECT_EQ(Index64(8), sdf->tree().leafCount()); EXPECT_EQ(Index64(0), sdf->tree().activeTileCount()); EXPECT_EQ(Index64(485), sdf->tree().activeVoxelCount()); @@ -265,7 +265,7 @@ TEST_F(TestPointRasterizeSDF, testRasterizeSpheres) EXPECT_EQ(GRID_LEVEL_SET, sdf->getGridClass()); EXPECT_EQ(float(s.halfband * s.points->voxelSize()[0]), sdf->background()); - EXPECT_EQ(Index32(38), sdf->tree().leafCount()); + EXPECT_EQ(Index64(38), sdf->tree().leafCount()); EXPECT_EQ(Index64(0), sdf->tree().activeTileCount()); EXPECT_EQ(Index64(485*8), sdf->tree().activeVoxelCount()); // 485 per sphere @@ -306,7 +306,7 @@ TEST_F(TestPointRasterizeSDF, testRasterizeSpheres) EXPECT_EQ(GRID_LEVEL_SET, sdf->getGridClass()); EXPECT_EQ(float(s.halfband * s.transform->voxelSize()[0]), sdf->background()); - EXPECT_EQ(Index32(46), sdf->tree().leafCount()); + EXPECT_EQ(Index64(46), sdf->tree().leafCount()); EXPECT_EQ(Index64(0), sdf->tree().activeTileCount()); EXPECT_EQ(Index64(7198), sdf->tree().activeVoxelCount()); @@ -359,7 +359,7 @@ TEST_F(TestPointRasterizeSDF, testRasterizeSpheres) EXPECT_EQ(GRID_LEVEL_SET, sdf->getGridClass()); EXPECT_EQ(float(s.halfband * s.points->voxelSize()[0]), sdf->background()); - EXPECT_EQ(Index32(17), sdf->tree().leafCount()); // less leaf nodes, active points are on a single face + EXPECT_EQ(Index64(17), sdf->tree().leafCount()); // less leaf nodes, active points are on a single face EXPECT_EQ(Index64(0), sdf->tree().activeTileCount()); EXPECT_EQ(Index64(485*4), sdf->tree().activeVoxelCount()); // 485 per sphere @@ -568,7 +568,7 @@ TEST_F(TestPointRasterizeSDF, testRasterizeVariableSpheres) EXPECT_EQ(GRID_LEVEL_SET, sdf->getGridClass()); EXPECT_EQ(float(s.halfband * s.points->voxelSize()[0]), sdf->background()); - EXPECT_EQ(Index32(8), sdf->tree().leafCount()); // less leaf nodes, active points are on a single face + EXPECT_EQ(Index64(8), sdf->tree().leafCount()); // less leaf nodes, active points are on a single face EXPECT_EQ(Index64(0), sdf->tree().activeTileCount()); EXPECT_EQ(Index64(1454), sdf->tree().activeVoxelCount()); // 485 per sphere @@ -732,7 +732,7 @@ TEST_F(TestPointRasterizeSDF, testRasterizeSmoothSpheres) EXPECT_EQ(GRID_LEVEL_SET, sdf->getGridClass()); EXPECT_EQ(float(s.halfband * s.points->voxelSize()[0]), sdf->background()); - EXPECT_EQ(Index32(44), sdf->tree().leafCount()); + EXPECT_EQ(Index64(44), sdf->tree().leafCount()); EXPECT_EQ(Index64(0), sdf->tree().activeTileCount()); EXPECT_EQ(Index64(6303), sdf->tree().activeVoxelCount()); const CoordBBox bounds(Coord(-7), Coord(7)); @@ -874,7 +874,7 @@ TEST_F(TestPointRasterizeSDF, testRasterizeVariableSmoothSpheres) EXPECT_TRUE(sdf->transform() == s.points->transform()); EXPECT_EQ(GRID_LEVEL_SET, sdf->getGridClass()); EXPECT_EQ(float(s.halfband * s.points->voxelSize()[0]), sdf->background()); - EXPECT_EQ(Index32(64), sdf->tree().leafCount()); + EXPECT_EQ(Index64(64), sdf->tree().leafCount()); EXPECT_EQ(Index64(0), sdf->tree().activeTileCount()); EXPECT_EQ(Index64(15011), sdf->tree().activeVoxelCount()); for (auto iter = sdf->cbeginValueOn(); iter; ++iter) { diff --git a/openvdb/openvdb/unittest/TestPointRasterizeTrilinear.cc b/openvdb/openvdb/unittest/TestPointRasterizeTrilinear.cc index 6346e98f9e..330a6a8140 100644 --- a/openvdb/openvdb/unittest/TestPointRasterizeTrilinear.cc +++ b/openvdb/openvdb/unittest/TestPointRasterizeTrilinear.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestPointReplicate.cc b/openvdb/openvdb/unittest/TestPointReplicate.cc index e382bca26d..97da67d3e2 100644 --- a/openvdb/openvdb/unittest/TestPointReplicate.cc +++ b/openvdb/openvdb/unittest/TestPointReplicate.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "PointBuilder.h" diff --git a/openvdb/openvdb/unittest/TestPointSample.cc b/openvdb/openvdb/unittest/TestPointSample.cc index ab1f7af022..3fa2774b31 100644 --- a/openvdb/openvdb/unittest/TestPointSample.cc +++ b/openvdb/openvdb/unittest/TestPointSample.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestPointScatter.cc b/openvdb/openvdb/unittest/TestPointScatter.cc index 7a31764718..58bf459ab6 100644 --- a/openvdb/openvdb/unittest/TestPointScatter.cc +++ b/openvdb/openvdb/unittest/TestPointScatter.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -36,7 +36,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) BoolGrid grid; grid.sparseFill(boxBounds, false, /*active*/true); auto points = points::uniformPointScatter(grid, total); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(total, pointCount(points->tree())); } @@ -44,7 +44,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) DoubleGrid grid; grid.sparseFill(boxBounds, 0.0, /*active*/true); auto points = points::uniformPointScatter(grid, total); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(total, pointCount(points->tree())); } @@ -52,7 +52,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) FloatGrid grid; grid.sparseFill(boxBounds, 0.0f, /*active*/true); auto points = points::uniformPointScatter(grid, total); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(total, pointCount(points->tree())); } @@ -60,7 +60,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) Int32Grid grid; grid.sparseFill(boxBounds, 0, /*active*/true); auto points = points::uniformPointScatter(grid, total); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(total, pointCount(points->tree())); } @@ -68,7 +68,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) Int64Grid grid; grid.sparseFill(boxBounds, 0, /*active*/true); auto points = points::uniformPointScatter(grid, total); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(total, pointCount(points->tree())); } @@ -76,7 +76,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) MaskGrid grid; grid.sparseFill(boxBounds, /*maskBuffer*/true); auto points = points::uniformPointScatter(grid, total); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(total, pointCount(points->tree())); } @@ -84,7 +84,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) Vec3DGrid grid; grid.sparseFill(boxBounds, Vec3d(), /*active*/true); auto points = points::uniformPointScatter(grid, total); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(total, pointCount(points->tree())); } @@ -92,7 +92,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) Vec3IGrid grid; grid.sparseFill(boxBounds, Vec3i(), /*active*/true); auto points = points::uniformPointScatter(grid, total); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(total, pointCount(points->tree())); } @@ -100,7 +100,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) Vec3SGrid grid; grid.sparseFill(boxBounds, Vec3f(), /*active*/true); auto points = points::uniformPointScatter(grid, total); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(total, pointCount(points->tree())); } @@ -108,7 +108,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) PointDataGrid grid; grid.sparseFill(boxBounds, 0, /*active*/true); auto points = points::uniformPointScatter(grid, total); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(total, pointCount(points->tree())); } @@ -128,7 +128,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) BoolGrid grid; grid.sparseFill(boxBounds, false, /*active*/true); auto points = points::uniformPointScatter(grid, 1); - EXPECT_EQ(Index32(1), points->tree().leafCount()); + EXPECT_EQ(Index64(1), points->tree().leafCount()); EXPECT_EQ(Index64(1), points->activeVoxelCount()); EXPECT_EQ(Index64(1), pointCount(points->tree())); } @@ -145,7 +145,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) auto points = points::uniformPointScatter(grid, total); EXPECT_EQ(Index64(0), points->tree().activeTileCount()); - EXPECT_EQ(Index32(1), points->tree().leafCount()); + EXPECT_EQ(Index64(1), points->tree().leafCount()); EXPECT_TRUE(Index64(NUM_VALUES) > points->tree().activeVoxelCount()); EXPECT_EQ(total, pointCount(points->tree())); @@ -226,7 +226,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) points = points::uniformPointScatter(grid, total); - EXPECT_EQ(Index32(1), points->tree().leafCount()); + EXPECT_EQ(Index64(1), points->tree().leafCount()); EXPECT_TRUE(Index64(NUM_VALUES) > points->tree().activeVoxelCount()); EXPECT_EQ(total, pointCount(points->tree())); @@ -234,7 +234,7 @@ TEST_F(TestPointScatter, testUniformPointScatter) points = points::uniformPointScatter(grid, Index64(NUM_VALUES)); - EXPECT_EQ(Index32(1), points->tree().leafCount()); + EXPECT_EQ(Index64(1), points->tree().leafCount()); EXPECT_EQ(Index64(NUM_VALUES), points->activeVoxelCount()); EXPECT_EQ(Index64(NUM_VALUES), pointCount(points->tree())); @@ -262,7 +262,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) BoolGrid grid; grid.sparseFill(boxBounds, false, /*active*/true); auto points = points::denseUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -270,7 +270,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) DoubleGrid grid; grid.sparseFill(boxBounds, 0.0, /*active*/true); auto points = points::denseUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -278,7 +278,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) FloatGrid grid; grid.sparseFill(boxBounds, 0.0f, /*active*/true); auto points = points::denseUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -286,7 +286,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) Int32Grid grid; grid.sparseFill(boxBounds, 0, /*active*/true); auto points = points::denseUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -294,7 +294,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) Int64Grid grid; grid.sparseFill(boxBounds, 0, /*active*/true); auto points = points::denseUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -302,7 +302,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) MaskGrid grid; grid.sparseFill(boxBounds, /*maskBuffer*/true); auto points = points::denseUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -310,7 +310,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) Vec3DGrid grid; grid.sparseFill(boxBounds, Vec3d(), /*active*/true); auto points = points::denseUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -318,7 +318,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) Vec3IGrid grid; grid.sparseFill(boxBounds, Vec3i(), /*active*/true); auto points = points::denseUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -326,7 +326,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) Vec3SGrid grid; grid.sparseFill(boxBounds, Vec3f(), /*active*/true); auto points = points::denseUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -334,7 +334,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) PointDataGrid grid; grid.sparseFill(boxBounds, 0, /*active*/true); auto points = points::denseUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -354,7 +354,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) BoolGrid grid; grid.sparseFill(boxBounds, false, /*active*/true); auto points = points::denseUniformPointScatter(grid, 0.8f); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); // Note that a value of 22 is precomputed as the number of active // voxels/points produced by a value of 0.8 EXPECT_EQ(Index64(22), points->activeVoxelCount()); @@ -373,7 +373,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) const Index32 NUM_VALUES = BoolGrid::TreeType::LeafNodeType::NUM_VALUES; - EXPECT_EQ(Index32(1), grid.tree().leafCount()); + EXPECT_EQ(Index64(1), grid.tree().leafCount()); EXPECT_EQ(Index64(NUM_VALUES + 1), grid.activeVoxelCount()); auto points = points::denseUniformPointScatter(grid, pointsPerVoxel); @@ -381,7 +381,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) const Index64 expectedCount = Index64(pointsPerVoxel * (NUM_VALUES + 1)); EXPECT_EQ(Index64(0), points->tree().activeTileCount()); - EXPECT_EQ(Index32(2), points->tree().leafCount()); + EXPECT_EQ(Index64(2), points->tree().leafCount()); EXPECT_EQ(Index64(NUM_VALUES + 1), points->activeVoxelCount()); EXPECT_EQ(expectedCount, pointCount(points->tree())); @@ -462,7 +462,7 @@ TEST_F(TestPointScatter, testDenseUniformPointScatter) points = points::denseUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(2), points->tree().leafCount()); + EXPECT_EQ(Index64(2), points->tree().leafCount()); EXPECT_EQ(Index64(NUM_VALUES + 1), points->activeVoxelCount()); EXPECT_EQ(expectedCount, pointCount(points->tree())); } @@ -480,7 +480,7 @@ TEST_F(TestPointScatter, testNonUniformPointScatter) grid.sparseFill(totalBoxBounds, false, /*active*/true); grid.sparseFill(activeBoxBounds, true, /*active*/true); auto points = points::nonUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -489,7 +489,7 @@ TEST_F(TestPointScatter, testNonUniformPointScatter) grid.sparseFill(totalBoxBounds, 0.0, /*active*/true); grid.sparseFill(activeBoxBounds, 1.0, /*active*/true); auto points = points::nonUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -498,7 +498,7 @@ TEST_F(TestPointScatter, testNonUniformPointScatter) grid.sparseFill(totalBoxBounds, 0.0f, /*active*/true); grid.sparseFill(activeBoxBounds, 1.0f, /*active*/true); auto points = points::nonUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -507,7 +507,7 @@ TEST_F(TestPointScatter, testNonUniformPointScatter) grid.sparseFill(totalBoxBounds, 0, /*active*/true); grid.sparseFill(activeBoxBounds, 1, /*active*/true); auto points = points::nonUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -516,7 +516,7 @@ TEST_F(TestPointScatter, testNonUniformPointScatter) grid.sparseFill(totalBoxBounds, 0, /*active*/true); grid.sparseFill(activeBoxBounds, 1, /*active*/true); auto points = points::nonUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -525,7 +525,7 @@ TEST_F(TestPointScatter, testNonUniformPointScatter) grid.sparseFill(totalBoxBounds, /*maskBuffer*/0); grid.sparseFill(activeBoxBounds, /*maskBuffer*/1); auto points = points::nonUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(8), points->tree().leafCount()); + EXPECT_EQ(Index64(8), points->tree().leafCount()); EXPECT_EQ(Index64(27), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 27), pointCount(points->tree())); } @@ -543,7 +543,7 @@ TEST_F(TestPointScatter, testNonUniformPointScatter) const Index32 NUM_VALUES = BoolGrid::TreeType::LeafNodeType::NUM_VALUES; - EXPECT_EQ(Index32(1), grid.tree().leafCount()); + EXPECT_EQ(Index64(1), grid.tree().leafCount()); EXPECT_EQ(Index64(NUM_VALUES + 1), grid.activeVoxelCount()); auto points = points::nonUniformPointScatter(grid, pointsPerVoxel); @@ -551,7 +551,7 @@ TEST_F(TestPointScatter, testNonUniformPointScatter) const Index64 expectedCount = Index64(pointsPerVoxel * (NUM_VALUES + 1)); EXPECT_EQ(Index64(0), points->tree().activeTileCount()); - EXPECT_EQ(Index32(2), points->tree().leafCount()); + EXPECT_EQ(Index64(2), points->tree().leafCount()); EXPECT_EQ(Index64(NUM_VALUES + 1), points->activeVoxelCount()); EXPECT_EQ(expectedCount, pointCount(points->tree())); @@ -637,7 +637,7 @@ TEST_F(TestPointScatter, testNonUniformPointScatter) points = points::nonUniformPointScatter(countGrid, pointsPerVoxel); - EXPECT_EQ(Index32(1), points->tree().leafCount()); + EXPECT_EQ(Index64(1), points->tree().leafCount()); EXPECT_EQ(Index64(7), points->activeVoxelCount()); EXPECT_EQ(Index64(pointsPerVoxel * 28), pointCount(points->tree())); @@ -656,7 +656,7 @@ TEST_F(TestPointScatter, testNonUniformPointScatter) points = points::nonUniformPointScatter(grid, pointsPerVoxel); - EXPECT_EQ(Index32(2), points->tree().leafCount()); + EXPECT_EQ(Index64(2), points->tree().leafCount()); EXPECT_EQ(Index64(NUM_VALUES + 1), points->activeVoxelCount()); EXPECT_EQ(expectedCount, pointCount(points->tree())); } diff --git a/openvdb/openvdb/unittest/TestPointStatistics.cc b/openvdb/openvdb/unittest/TestPointStatistics.cc index 0093694002..5a5b7a91ff 100644 --- a/openvdb/openvdb/unittest/TestPointStatistics.cc +++ b/openvdb/openvdb/unittest/TestPointStatistics.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include diff --git a/openvdb/openvdb/unittest/TestPointsToMask.cc b/openvdb/openvdb/unittest/TestPointsToMask.cc index 8f8393eb9c..ca4176e587 100644 --- a/openvdb/openvdb/unittest/TestPointsToMask.cc +++ b/openvdb/openvdb/unittest/TestPointsToMask.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include // for math::Random01 diff --git a/openvdb/openvdb/unittest/TestPoissonSolver.cc b/openvdb/openvdb/unittest/TestPoissonSolver.cc index 8bd477893f..40851624fe 100644 --- a/openvdb/openvdb/unittest/TestPoissonSolver.cc +++ b/openvdb/openvdb/unittest/TestPoissonSolver.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file unittest/TestPoissonSolver.cc /// @authors D.J. Hill, Peter Cucka diff --git a/openvdb/openvdb/unittest/TestPotentialFlow.cc b/openvdb/openvdb/unittest/TestPotentialFlow.cc index 5806ccbcb8..e3b10058ef 100644 --- a/openvdb/openvdb/unittest/TestPotentialFlow.cc +++ b/openvdb/openvdb/unittest/TestPotentialFlow.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file unittest/TestPotentialFlow.cc diff --git a/openvdb/openvdb/unittest/TestPrePostAPI.cc b/openvdb/openvdb/unittest/TestPrePostAPI.cc index 4c4cebe529..0cc935188c 100644 --- a/openvdb/openvdb/unittest/TestPrePostAPI.cc +++ b/openvdb/openvdb/unittest/TestPrePostAPI.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestQuadraticInterp.cc b/openvdb/openvdb/unittest/TestQuadraticInterp.cc index 2e16975860..d62cdb98f3 100644 --- a/openvdb/openvdb/unittest/TestQuadraticInterp.cc +++ b/openvdb/openvdb/unittest/TestQuadraticInterp.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file TestQuadraticInterp.cc diff --git a/openvdb/openvdb/unittest/TestQuantizedUnitVec.cc b/openvdb/openvdb/unittest/TestQuantizedUnitVec.cc index 3e0389d695..4082f06abe 100644 --- a/openvdb/openvdb/unittest/TestQuantizedUnitVec.cc +++ b/openvdb/openvdb/unittest/TestQuantizedUnitVec.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestQuat.cc b/openvdb/openvdb/unittest/TestQuat.cc index 5516fd27a4..53462df7a3 100644 --- a/openvdb/openvdb/unittest/TestQuat.cc +++ b/openvdb/openvdb/unittest/TestQuat.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestRay.cc b/openvdb/openvdb/unittest/TestRay.cc index 844f5a490e..8ce58e620e 100644 --- a/openvdb/openvdb/unittest/TestRay.cc +++ b/openvdb/openvdb/unittest/TestRay.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestRootNode.cc b/openvdb/openvdb/unittest/TestRootNode.cc new file mode 100644 index 0000000000..e774f3b66b --- /dev/null +++ b/openvdb/openvdb/unittest/TestRootNode.cc @@ -0,0 +1,616 @@ +// Copyright Contributors to the OpenVDB Project +// SPDX-License-Identifier: Apache-2.0 + +#include +#include + +#include + +using namespace openvdb; +using namespace tree; + +class TestRoot: public ::testing::Test +{ +}; + + +TEST_F(TestRoot, test) +{ + using RootNodeType = FloatTree::RootNodeType; + using ChildType = RootNodeType::ChildNodeType; + const Coord c0(0,0,0), c1(49152, 16384, 28672); + + { // test inserting child nodes directly and indirectly + RootNodeType root(0.0f); + EXPECT_TRUE(root.empty()); + EXPECT_EQ(Index32(0), root.childCount()); + + // populate the tree by inserting the two leaf nodes containing c0 and c1 + root.touchLeaf(c0); + root.touchLeaf(c1); + EXPECT_EQ(Index(2), root.getTableSize()); + EXPECT_EQ(Index32(2), root.childCount()); + EXPECT_TRUE(!root.hasActiveTiles()); + + { // verify c0 and c1 are the root node coordinates + auto rootIter = root.cbeginChildOn(); + EXPECT_EQ(c0, rootIter.getCoord()); + ++rootIter; + EXPECT_EQ(c1, rootIter.getCoord()); + } + + // copy the root node + RootNodeType rootCopy(root); + + // steal the root node children leaving the root node empty again + std::vector children; + root.stealNodes(children); + EXPECT_TRUE(root.empty()); + + // insert the root node children directly + for (ChildType* child : children) { + root.addChild(child); + } + EXPECT_EQ(Index(2), root.getTableSize()); + EXPECT_EQ(Index32(2), root.childCount()); + + { // verify the coordinates of the root node children + auto rootIter = root.cbeginChildOn(); + EXPECT_EQ(c0, rootIter.getCoord()); + ++rootIter; + EXPECT_EQ(c1, rootIter.getCoord()); + } + } + + { // test inserting tiles and replacing them with child nodes + RootNodeType root(0.0f); + EXPECT_TRUE(root.empty()); + + // no-op + root.addChild(nullptr); + + // populate the root node by inserting tiles + root.addTile(c0, /*value=*/1.0f, /*state=*/true); + root.addTile(c1, /*value=*/2.0f, /*state=*/true); + EXPECT_EQ(Index(2), root.getTableSize()); + EXPECT_EQ(Index32(0), root.childCount()); + EXPECT_TRUE(root.hasActiveTiles()); + EXPECT_NEAR(root.getValue(c0), 1.0f, /*tolerance=*/0.0); + EXPECT_NEAR(root.getValue(c1), 2.0f, /*tolerance=*/0.0); + + // insert child nodes with the same coordinates + root.addChild(new ChildType(c0, 3.0f)); + root.addChild(new ChildType(c1, 4.0f)); + + // insert a new child at c0 + root.addChild(new ChildType(c0, 5.0f)); + + // verify active tiles have been replaced by child nodes + EXPECT_EQ(Index(2), root.getTableSize()); + EXPECT_EQ(Index32(2), root.childCount()); + EXPECT_TRUE(!root.hasActiveTiles()); + + { // verify the coordinates of the root node children + auto rootIter = root.cbeginChildOn(); + EXPECT_EQ(c0, rootIter.getCoord()); + EXPECT_NEAR(root.getValue(c0), 5.0f, /*tolerance=*/0.0); + ++rootIter; + EXPECT_EQ(c1, rootIter.getCoord()); + } + } + + { // test transient data + RootNodeType rootNode(0.0f); + EXPECT_EQ(Index32(0), rootNode.transientData()); + rootNode.setTransientData(Index32(5)); + EXPECT_EQ(Index32(5), rootNode.transientData()); + RootNodeType rootNode2(rootNode); + EXPECT_EQ(Index32(5), rootNode2.transientData()); + RootNodeType rootNode3 = rootNode; + EXPECT_EQ(Index32(5), rootNode3.transientData()); + } +} + +TEST_F(TestRoot, testMap) +{ + using RootNode = FloatTree::RootNodeType; + + { // empty root node + RootNode root(1.0f); + + // background checks + + EXPECT_EQ(root.background(), 1.0f); + root.setBackground(2.0f, false); + EXPECT_EQ(root.background(), 2.0f); + EXPECT_EQ(root.numBackgroundTiles(), 0); + + // count checks + + EXPECT_TRUE(root.empty()); + EXPECT_FALSE(root.hasActiveTiles()); + EXPECT_EQ(root.getTableSize(), 0); + EXPECT_EQ(root.leafCount(), 0); + EXPECT_EQ(root.nonLeafCount(), 1); // root counts as a node + EXPECT_EQ(root.childCount(), 0); + EXPECT_EQ(root.tileCount(), 0); + EXPECT_EQ(root.activeTileCount(), 0); + EXPECT_EQ(root.inactiveTileCount(), 0); + + EXPECT_EQ(root.onVoxelCount(), 0); + EXPECT_EQ(root.offVoxelCount(), 0); + EXPECT_EQ(root.onLeafVoxelCount(), 0); + EXPECT_EQ(root.offLeafVoxelCount(), 0); + EXPECT_EQ(root.onTileCount(), 0); + + // bounding box checks + + EXPECT_EQ(root.getMinIndex(), Coord()); + EXPECT_EQ(root.getMaxIndex(), Coord()); + EXPECT_EQ(root.getWidth(), 0); + EXPECT_EQ(root.getHeight(), 0); + EXPECT_EQ(root.getDepth(), 0); + EXPECT_EQ(root.getNodeBoundingBox(), CoordBBox::inf()); // always infinite + + CoordBBox bbox; + root.evalActiveBoundingBox(bbox); + EXPECT_EQ(bbox, CoordBBox()); // empty bbox + + root.getIndexRange(bbox); + EXPECT_EQ(bbox, CoordBBox(Coord(0), Coord(0))); // zero bbox + + // origin checks + + root.setOrigin(Coord(0, 0, 0)); + EXPECT_THROW(root.setOrigin(Coord(1, 2, 3)), ValueError); // non-zero origins not supported + + // key checks + + EXPECT_EQ(root.getValueDepth(Coord(0, 0, 0)), -1); + + EXPECT_EQ(root.coordToKey(Coord(0, 0, 0)), Coord(0, 0, 0)); + EXPECT_EQ(root.coordToKey(Coord(1, 2, 3)), Coord(0, 0, 0)); + EXPECT_EQ(root.coordToKey(Coord(5000, 6000, 7000)), Coord(4096, 4096, 4096)); + + EXPECT_FALSE(root.hasKey(Coord(0, 0, 0))); + } + + { // one active, non-background root node tile + RootNode root(1.0f); + root.addTile(Coord(1, 2, 3), 2.0f, true); + + // background checks + + EXPECT_EQ(root.background(), 1.0f); + EXPECT_EQ(root.numBackgroundTiles(), 0); + + // count checks + + EXPECT_FALSE(root.empty()); + EXPECT_TRUE(root.hasActiveTiles()); + EXPECT_EQ(root.getTableSize(), 1); + EXPECT_EQ(root.leafCount(), 0); + EXPECT_EQ(root.nonLeafCount(), 1); + EXPECT_EQ(root.childCount(), 0); + EXPECT_EQ(root.tileCount(), 1); + EXPECT_EQ(root.activeTileCount(), 1); + EXPECT_EQ(root.inactiveTileCount(), 0); + + Index64 voxels = Index64(4096) * 4096 * 4096; + EXPECT_EQ(root.onVoxelCount(), voxels); + EXPECT_EQ(root.offVoxelCount(), 0); + EXPECT_EQ(root.onLeafVoxelCount(), 0); + EXPECT_EQ(root.offLeafVoxelCount(), 0); + EXPECT_EQ(root.onTileCount(), 1); + + // bounding box checks + + EXPECT_EQ(root.getMinIndex(), Coord(0)); + EXPECT_EQ(root.getMaxIndex(), Coord(4095)); + EXPECT_EQ(root.getWidth(), 4095); + EXPECT_EQ(root.getHeight(), 4095); + EXPECT_EQ(root.getDepth(), 4095); + EXPECT_EQ(root.getNodeBoundingBox(), CoordBBox::inf()); // always infinite + + CoordBBox bbox; + root.evalActiveBoundingBox(bbox); + EXPECT_EQ(bbox, CoordBBox(Coord(0), Coord(4095))); + + root.getIndexRange(bbox); + EXPECT_EQ(bbox, CoordBBox(Coord(0), Coord(4095))); + + // key checks + + EXPECT_EQ(root.getValueDepth(Coord(0, 0, 0)), 0); + + EXPECT_EQ(root.coordToKey(Coord(0, 0, 0)), Coord(0, 0, 0)); + EXPECT_EQ(root.coordToKey(Coord(1, 2, 3)), Coord(0, 0, 0)); + EXPECT_EQ(root.coordToKey(Coord(5000, 6000, 7000)), Coord(4096, 4096, 4096)); + + EXPECT_TRUE(root.hasKey(Coord(0, 0, 0))); + EXPECT_FALSE(root.hasKey(Coord(1, 2, 3))); + + // erase background tiles + + root.eraseBackgroundTiles(); + EXPECT_EQ(root.getTableSize(), 1); + EXPECT_TRUE(root.hasKey(Coord(0, 0, 0))); + + // clear root + + root.clear(); + EXPECT_EQ(root.getTableSize(), 0); + EXPECT_FALSE(root.hasKey(Coord(0, 0, 0))); + } + + { // one inactive, background root node tile + RootNode root(1.0f); + root.addTile(Coord(1, 2, 3), 1.0f, false); + + // background checks + + EXPECT_EQ(root.background(), 1.0f); + EXPECT_EQ(root.numBackgroundTiles(), 1); + + // count checks + + EXPECT_TRUE(root.empty()); // root is empty if it only has inactive background tiles + EXPECT_FALSE(root.hasActiveTiles()); + EXPECT_EQ(root.getTableSize(), 1); + EXPECT_EQ(root.leafCount(), 0); + EXPECT_EQ(root.nonLeafCount(), 1); + EXPECT_EQ(root.childCount(), 0); + EXPECT_EQ(root.tileCount(), 1); + EXPECT_EQ(root.activeTileCount(), 0); + EXPECT_EQ(root.inactiveTileCount(), 1); + + EXPECT_EQ(root.onVoxelCount(), 0); + EXPECT_EQ(root.offVoxelCount(), 0); + EXPECT_EQ(root.onLeafVoxelCount(), 0); + EXPECT_EQ(root.offLeafVoxelCount(), 0); + EXPECT_EQ(root.onTileCount(), 0); + + // bounding box checks + + EXPECT_EQ(root.getMinIndex(), Coord(0)); + EXPECT_EQ(root.getMaxIndex(), Coord(4095)); + EXPECT_EQ(root.getWidth(), 4095); + EXPECT_EQ(root.getHeight(), 4095); + EXPECT_EQ(root.getDepth(), 4095); + EXPECT_EQ(root.getNodeBoundingBox(), CoordBBox::inf()); // always infinite + + CoordBBox bbox; + root.evalActiveBoundingBox(bbox); + EXPECT_EQ(bbox, CoordBBox()); // empty bbox + + root.getIndexRange(bbox); + EXPECT_EQ(bbox, CoordBBox(Coord(0), Coord(4095))); + + // key checks + + EXPECT_EQ(root.getValueDepth(Coord(0, 0, 0)), 0); + + EXPECT_EQ(root.coordToKey(Coord(0, 0, 0)), Coord(0, 0, 0)); + EXPECT_EQ(root.coordToKey(Coord(1, 2, 3)), Coord(0, 0, 0)); + EXPECT_EQ(root.coordToKey(Coord(5000, 6000, 7000)), Coord(4096, 4096, 4096)); + + EXPECT_TRUE(root.hasKey(Coord(0, 0, 0))); + EXPECT_FALSE(root.hasKey(Coord(1, 2, 3))); + + // erase background tiles + + root.eraseBackgroundTiles(); + EXPECT_EQ(root.getTableSize(), 0); + EXPECT_FALSE(root.hasKey(Coord(0, 0, 0))); + } + + { // one active, background root node tile + RootNode root(1.0f); + root.addTile(Coord(1, 2, 3), 1.0f, true); + + // background checks + + EXPECT_EQ(root.background(), 1.0f); + EXPECT_EQ(root.numBackgroundTiles(), 0); + + // count checks + + EXPECT_FALSE(root.empty()); + EXPECT_TRUE(root.hasActiveTiles()); + EXPECT_EQ(root.getTableSize(), 1); + EXPECT_EQ(root.leafCount(), 0); + EXPECT_EQ(root.nonLeafCount(), 1); + EXPECT_EQ(root.childCount(), 0); + EXPECT_EQ(root.tileCount(), 1); + EXPECT_EQ(root.activeTileCount(), 1); + EXPECT_EQ(root.inactiveTileCount(), 0); + + Index64 voxels = Index64(4096) * 4096 * 4096; + EXPECT_EQ(root.onVoxelCount(), voxels); + EXPECT_EQ(root.offVoxelCount(), 0); + EXPECT_EQ(root.onLeafVoxelCount(), 0); + EXPECT_EQ(root.offLeafVoxelCount(), 0); + EXPECT_EQ(root.onTileCount(), 1); + + // bounding box checks + + EXPECT_EQ(root.getMinIndex(), Coord(0)); + EXPECT_EQ(root.getMaxIndex(), Coord(4095)); + EXPECT_EQ(root.getWidth(), 4095); + EXPECT_EQ(root.getHeight(), 4095); + EXPECT_EQ(root.getDepth(), 4095); + EXPECT_EQ(root.getNodeBoundingBox(), CoordBBox::inf()); // always infinite + + CoordBBox bbox; + root.evalActiveBoundingBox(bbox); + EXPECT_EQ(bbox, CoordBBox(Coord(0), Coord(4095))); + + root.getIndexRange(bbox); + EXPECT_EQ(bbox, CoordBBox(Coord(0), Coord(4095))); + + // key checks + + EXPECT_EQ(root.getValueDepth(Coord(0, 0, 0)), 0); + + EXPECT_EQ(root.coordToKey(Coord(0, 0, 0)), Coord(0, 0, 0)); + EXPECT_EQ(root.coordToKey(Coord(1, 2, 3)), Coord(0, 0, 0)); + EXPECT_EQ(root.coordToKey(Coord(5000, 6000, 7000)), Coord(4096, 4096, 4096)); + + EXPECT_TRUE(root.hasKey(Coord(0, 0, 0))); + EXPECT_FALSE(root.hasKey(Coord(1, 2, 3))); + } + + { // one internal node tile (which implicitly adds a root node child) + RootNode root(1.0f); + root.addTile(2, Coord(1, 2, 3), 2.0f, true); + + // count checks + + EXPECT_FALSE(root.empty()); + EXPECT_TRUE(root.hasActiveTiles()); // this method recurses down the tree + EXPECT_EQ(root.getTableSize(), 1); + EXPECT_EQ(root.leafCount(), 0); + EXPECT_EQ(root.nonLeafCount(), 2); + EXPECT_EQ(root.childCount(), 1); + EXPECT_EQ(root.tileCount(), 0); + EXPECT_EQ(root.activeTileCount(), 0); + EXPECT_EQ(root.inactiveTileCount(), 0); + + Index64 totalVoxels = Index64(4096) * 4096 * 4096; + Index64 onVoxels = Index64(128) * 128 * 128; + EXPECT_EQ(root.onVoxelCount(), onVoxels); + EXPECT_EQ(root.offVoxelCount(), totalVoxels - onVoxels); + EXPECT_EQ(root.onLeafVoxelCount(), 0); + EXPECT_EQ(root.offLeafVoxelCount(), 0); + EXPECT_EQ(root.onTileCount(), 1); + + // bounding box checks + + EXPECT_EQ(root.getMinIndex(), Coord(0)); + EXPECT_EQ(root.getMaxIndex(), Coord(4095)); + EXPECT_EQ(root.getWidth(), 4095); + EXPECT_EQ(root.getHeight(), 4095); + EXPECT_EQ(root.getDepth(), 4095); + EXPECT_EQ(root.getNodeBoundingBox(), CoordBBox::inf()); // always infinite + + CoordBBox bbox; + root.evalActiveBoundingBox(bbox); + EXPECT_EQ(bbox, CoordBBox(Coord(0), Coord(127))); + + root.getIndexRange(bbox); + EXPECT_EQ(bbox, CoordBBox(Coord(0), Coord(4095))); + + // key checks + + EXPECT_EQ(root.getValueDepth(Coord(0, 0, 0)), 1); // InternalNode 1 + + EXPECT_EQ(root.coordToKey(Coord(0, 0, 0)), Coord(0, 0, 0)); + EXPECT_EQ(root.coordToKey(Coord(1, 2, 3)), Coord(0, 0, 0)); + EXPECT_EQ(root.coordToKey(Coord(5000, 6000, 7000)), Coord(4096, 4096, 4096)); + + EXPECT_TRUE(root.hasKey(Coord(0, 0, 0))); + EXPECT_FALSE(root.hasKey(Coord(1, 2, 3))); + } +} + +TEST_F(TestRoot, testDelete) +{ + using RootNode = FloatTree::RootNodeType; + + RootNode root(1.0f); + + root.addTile(Coord(1, 2, 3), 2.0f, true); + root.addTile(Coord(4096, 2, 3), 3.0f, true); + + auto* child = new RootNode::ChildNodeType(Coord(0, 0, 4096), 5.0f, true); + EXPECT_TRUE(root.addChild(child)); // always returns true + + EXPECT_EQ(root.getTableSize(), 3); + EXPECT_TRUE(root.hasKey(Coord(0, 0, 0))); + EXPECT_TRUE(root.hasKey(Coord(4096, 0, 0))); + EXPECT_TRUE(root.hasKey(Coord(0, 0, 4096))); + EXPECT_FALSE(root.hasKey(Coord(4096, 4096, 0))); + + EXPECT_FALSE(root.deleteChildOrTile(Coord(4096, 4096, 0))); + + EXPECT_EQ(root.getTableSize(), 3); + EXPECT_TRUE(root.hasKey(Coord(0, 0, 0))); + EXPECT_TRUE(root.hasKey(Coord(4096, 0, 0))); + EXPECT_TRUE(root.hasKey(Coord(0, 0, 4096))); + EXPECT_FALSE(root.hasKey(Coord(4096, 4096, 0))); + + EXPECT_TRUE(root.deleteChildOrTile(Coord(4096, 5, 6))); + + EXPECT_EQ(root.getTableSize(), 2); + EXPECT_TRUE(root.hasKey(Coord(0, 0, 0))); + EXPECT_FALSE(root.hasKey(Coord(4096, 0, 0))); + EXPECT_TRUE(root.hasKey(Coord(0, 0, 4096))); + EXPECT_FALSE(root.hasKey(Coord(4096, 4096, 0))); + + EXPECT_TRUE(root.deleteChildOrTile(Coord(1, 5, 4097))); + + EXPECT_EQ(root.getTableSize(), 1); + EXPECT_TRUE(root.hasKey(Coord(0, 0, 0))); + EXPECT_FALSE(root.hasKey(Coord(4096, 0, 0))); + EXPECT_FALSE(root.hasKey(Coord(0, 0, 4096))); + EXPECT_FALSE(root.hasKey(Coord(4096, 4096, 0))); + + EXPECT_TRUE(root.deleteChildOrTile(Coord(1, 5, 7))); + + EXPECT_EQ(root.getTableSize(), 0); + EXPECT_FALSE(root.hasKey(Coord(0, 0, 0))); + EXPECT_FALSE(root.hasKey(Coord(4096, 0, 0))); + EXPECT_FALSE(root.hasKey(Coord(0, 0, 4096))); + EXPECT_FALSE(root.hasKey(Coord(4096, 4096, 0))); +} + + +TEST_F(TestRoot, testProbe) +{ + using RootNode = FloatTree::RootNodeType; + + RootNode root(1.0f); + + root.addTile(Coord(1, 2, 3), 2.0f, true); + root.addTile(Coord(4096, 2, 3), 3.0f, false); + + auto* child = new RootNode::ChildNodeType(Coord(0, 0, 4096), 5.0f, true); + EXPECT_TRUE(root.addChild(child)); // always returns true + + { // probeNode, probeConstNode + auto* node1 = root.probeNode(Coord(0, 0, 4096)); + EXPECT_TRUE(bool(node1)); + auto* node2 = root.probeNode(Coord(4096, 0, 0)); + EXPECT_FALSE(bool(node2)); + const RootNode& constRoot = root; + auto* node3 = constRoot.probeNode(Coord(0, 0, 4096)); + EXPECT_TRUE(bool(node3)); + auto* node4 = constRoot.probeNode(Coord(4096, 0, 0)); + EXPECT_FALSE(bool(node4)); + auto* node5 = root.probeConstNode(Coord(0, 0, 4096)); + EXPECT_TRUE(bool(node5)); + auto* node6 = root.probeConstNode(Coord(4096, 0, 0)); + EXPECT_FALSE(bool(node6)); + } + + { // probeChild, probeConstChild + auto* node1 = root.probeChild(Coord(0, 0, 4096)); + EXPECT_TRUE(bool(node1)); + auto* node2 = root.probeChild(Coord(4096, 0, 0)); + EXPECT_FALSE(bool(node2)); + const RootNode& constRoot = root; + auto* node3 = constRoot.probeChild(Coord(0, 0, 4096)); + EXPECT_TRUE(bool(node3)); + auto* node4 = constRoot.probeChild(Coord(4096, 0, 0)); + EXPECT_FALSE(bool(node4)); + auto* node5 = root.probeConstChild(Coord(0, 0, 4096)); + EXPECT_TRUE(bool(node5)); + auto* node6 = root.probeConstChild(Coord(4096, 0, 0)); + EXPECT_FALSE(bool(node6)); + } + + RootNode::ChildNodeType* childPtr = nullptr; + const RootNode::ChildNodeType* constChildPtr = nullptr; + float value = -1.0f; + bool active = false; + + { // probe, probeConst - child + bool keyExists = root.probe(Coord(0, 0, 4096), childPtr, value, active); + EXPECT_TRUE(keyExists); + EXPECT_TRUE(bool(childPtr)); + childPtr = nullptr; + keyExists = root.probe(Coord(0, 10, 4096), childPtr, value, active); + EXPECT_TRUE(keyExists); + EXPECT_TRUE(bool(childPtr)); + childPtr = nullptr; + EXPECT_FALSE(root.probe(Coord(4096, 4096, 4096), childPtr, value, active)); + EXPECT_FALSE(bool(childPtr)); + + const RootNode& constRoot = root; + keyExists = constRoot.probe(Coord(0, 0, 4096), constChildPtr, value, active); + EXPECT_TRUE(keyExists); + EXPECT_TRUE(bool(constChildPtr)); + constChildPtr = nullptr; + EXPECT_FALSE(root.probe(Coord(4096, 4096, 4096), constChildPtr, value, active)); + EXPECT_FALSE(bool(childPtr)); + + keyExists = root.probeConst(Coord(0, 0, 4096), constChildPtr, value, active); + EXPECT_TRUE(keyExists); + EXPECT_TRUE(bool(constChildPtr)); + constChildPtr = nullptr; + EXPECT_FALSE(root.probeConst(Coord(4096, 4096, 4096), constChildPtr, value, active)); + EXPECT_FALSE(bool(constChildPtr)); + } + + { // probe, probeConst - tile + EXPECT_TRUE(root.probe(Coord(0, 0, 0), childPtr, value, active)); + EXPECT_FALSE(bool(childPtr)); + EXPECT_EQ(value, 2.0f); + EXPECT_EQ(active, true); + value = -1.0f; + EXPECT_TRUE(root.probe(Coord(4096, 0, 0), childPtr, value, active)); + EXPECT_FALSE(bool(childPtr)); + EXPECT_EQ(value, 3.0f); + EXPECT_EQ(active, false); + EXPECT_FALSE(root.probe(Coord(4096, 4096, 4096), childPtr, value, active)); + EXPECT_FALSE(bool(childPtr)); + + const RootNode& constRoot = root; + EXPECT_TRUE(constRoot.probe(Coord(0, 0, 0), constChildPtr, value, active)); + EXPECT_FALSE(bool(constChildPtr)); + EXPECT_EQ(value, 2.0f); + EXPECT_EQ(active, true); + value = -1.0f; + EXPECT_TRUE(root.probe(Coord(4096, 0, 0), constChildPtr, value, active)); + EXPECT_FALSE(bool(constChildPtr)); + EXPECT_EQ(value, 3.0f); + EXPECT_EQ(active, false); + EXPECT_FALSE(root.probe(Coord(4096, 4096, 4096), constChildPtr, value, active)); + EXPECT_FALSE(bool(constChildPtr)); + + EXPECT_TRUE(root.probeConst(Coord(0, 0, 0), constChildPtr, value, active)); + EXPECT_FALSE(bool(constChildPtr)); + EXPECT_EQ(value, 2.0f); + EXPECT_EQ(active, true); + value = -1.0f; + EXPECT_TRUE(root.probeConst(Coord(4096, 0, 0), constChildPtr, value, active)); + EXPECT_FALSE(bool(constChildPtr)); + EXPECT_EQ(value, 3.0f); + EXPECT_EQ(active, false); + EXPECT_FALSE(root.probeConst(Coord(4096, 4096, 4096), constChildPtr, value, active)); + EXPECT_FALSE(bool(constChildPtr)); + } +} + +TEST_F(TestRoot, testUnsafe) +{ + using RootNode = FloatTree::RootNodeType; + + RootNode root(1.0f); + + root.addTile(Coord(1, 2, 3), 2.0f, true); + root.addTile(Coord(4096, 2, 3), 3.0f, false); + + auto* child = new RootNode::ChildNodeType(Coord(0, 0, 4096), 5.0f, true); + EXPECT_TRUE(root.addChild(child)); // always returns true + + { // get value + EXPECT_EQ(root.getTileValueUnsafe(Coord(1, 2, 3)), 2.0f); + EXPECT_EQ(root.getTileValueUnsafe(Coord(4096, 2, 3)), 3.0f); + float value = -1.0f; + EXPECT_TRUE(root.getTileValueUnsafe(Coord(1, 2, 3), value)); + EXPECT_EQ(value, 2.0f); value = -1.0f; + EXPECT_FALSE(root.getTileValueUnsafe(Coord(4096, 2, 3), value)); + EXPECT_EQ(value, 3.0f); value = -1.0f; + } + + { // get child + auto* node1 = root.getChildUnsafe(Coord(0, 0, 4096)); + EXPECT_TRUE(node1); + const RootNode& constRoot = root; + auto* node2 = constRoot.getChildUnsafe(Coord(0, 0, 4096)); + EXPECT_TRUE(node2); + auto* node3 = root.getConstChildUnsafe(Coord(0, 0, 4096)); + EXPECT_TRUE(node3); + } +} diff --git a/openvdb/openvdb/unittest/TestStats.cc b/openvdb/openvdb/unittest/TestStats.cc index 0e40d5d1b7..4663cf6469 100644 --- a/openvdb/openvdb/unittest/TestStats.cc +++ b/openvdb/openvdb/unittest/TestStats.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include // for ISGradient diff --git a/openvdb/openvdb/unittest/TestStencils.cc b/openvdb/openvdb/unittest/TestStencils.cc index 804dd61fcf..82d5b9579e 100644 --- a/openvdb/openvdb/unittest/TestStencils.cc +++ b/openvdb/openvdb/unittest/TestStencils.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestStream.cc b/openvdb/openvdb/unittest/TestStream.cc index fb5621bd2f..cc9bde5b75 100644 --- a/openvdb/openvdb/unittest/TestStream.cc +++ b/openvdb/openvdb/unittest/TestStream.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestStreamCompression.cc b/openvdb/openvdb/unittest/TestStreamCompression.cc index a7088d9dee..79cf6a2b4c 100644 --- a/openvdb/openvdb/unittest/TestStreamCompression.cc +++ b/openvdb/openvdb/unittest/TestStreamCompression.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include // io::COMPRESS_BLOSC diff --git a/openvdb/openvdb/unittest/TestStringMetadata.cc b/openvdb/openvdb/unittest/TestStringMetadata.cc index a5390593a4..3bc0bc7125 100644 --- a/openvdb/openvdb/unittest/TestStringMetadata.cc +++ b/openvdb/openvdb/unittest/TestStringMetadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestTools.cc b/openvdb/openvdb/unittest/TestTools.cc index 07105cf888..df17050a06 100644 --- a/openvdb/openvdb/unittest/TestTools.cc +++ b/openvdb/openvdb/unittest/TestTools.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -1498,7 +1498,6 @@ struct FloatToVec } - TEST_F(TestTools, testTransformValues) { using openvdb::CoordBBox; @@ -1707,8 +1706,8 @@ TEST_F(TestTools, testPrune) const float value = 5.345f; FloatTree tree(value); - EXPECT_EQ(Index32(0), tree.leafCount()); - EXPECT_EQ(Index32(1), tree.nonLeafCount()); // root node + EXPECT_EQ(Index64(0), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.nonLeafCount()); // root node EXPECT_TRUE(tree.empty()); tree.fill(CoordBBox(Coord(-10), Coord(10)), value, /*active=*/false); @@ -1716,8 +1715,8 @@ TEST_F(TestTools, testPrune) tools::prune(tree); - EXPECT_EQ(Index32(0), tree.leafCount()); - EXPECT_EQ(Index32(1), tree.nonLeafCount()); // root node + EXPECT_EQ(Index64(0), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.nonLeafCount()); // root node EXPECT_TRUE(tree.empty()); } @@ -1739,18 +1738,18 @@ TEST_F(TestTools, testPrune) FloatTree tree(val); tree.addLeaf(leaf); - EXPECT_EQ(Index32(1), tree.leafCount()); - EXPECT_EQ(Index32(3), tree.nonLeafCount()); // root+2*internal + EXPECT_EQ(Index64(1), tree.leafCount()); + EXPECT_EQ(Index64(3), tree.nonLeafCount()); // root+2*internal tools::prune(tree);// tolerance is zero - EXPECT_EQ(Index32(1), tree.leafCount()); - EXPECT_EQ(Index32(3), tree.nonLeafCount()); // root+2*internal + EXPECT_EQ(Index64(1), tree.leafCount()); + EXPECT_EQ(Index64(3), tree.nonLeafCount()); // root+2*internal tools::prune(tree, tol); - EXPECT_EQ(Index32(0), tree.leafCount()); - EXPECT_EQ(Index32(3), tree.nonLeafCount()); // root+2*internal + EXPECT_EQ(Index64(0), tree.leafCount()); + EXPECT_EQ(Index64(3), tree.nonLeafCount()); // root+2*internal std::sort(data.begin(), data.end()); const float median = data[(LeafNodeT::NUM_VALUES-1)>>1]; @@ -1765,7 +1764,7 @@ TEST_F(TestTools, testPrune) io::File sourceFile("/usr/pic1/Data/OpenVDB/LevelSetModels/crawler.vdb"); sourceFile.open(false);//disable delayed loading FloatGrid::Ptr grid = gridPtrCast(sourceFile.getGrids()->at(0)); - const Index32 leafCount = grid->tree().leafCount(); + const Index64 leafCount = grid->tree().leafCount(); timer.start("\nSerial tolerance prune"); grid->tree().prune(); @@ -1778,7 +1777,7 @@ TEST_F(TestTools, testPrune) io::File sourceFile("/usr/pic1/Data/OpenVDB/LevelSetModels/crawler.vdb"); sourceFile.open(false);//disable delayed loading FloatGrid::Ptr grid = gridPtrCast(sourceFile.getGrids()->at(0)); - const Index32 leafCount = grid->tree().leafCount(); + const Index64 leafCount = grid->tree().leafCount(); timer.start("\nParallel tolerance prune"); tools::prune(grid->tree()); diff --git a/openvdb/openvdb/unittest/TestTopologyToLevelSet.cc b/openvdb/openvdb/unittest/TestTopologyToLevelSet.cc index e484cf325b..feec82ca22 100644 --- a/openvdb/openvdb/unittest/TestTopologyToLevelSet.cc +++ b/openvdb/openvdb/unittest/TestTopologyToLevelSet.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include diff --git a/openvdb/openvdb/unittest/TestTransform.cc b/openvdb/openvdb/unittest/TestTransform.cc index 1b33df3d71..a2a173d420 100644 --- a/openvdb/openvdb/unittest/TestTransform.cc +++ b/openvdb/openvdb/unittest/TestTransform.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestTree.cc b/openvdb/openvdb/unittest/TestTree.cc index 74ec5d63ab..a5ac2afade 100644 --- a/openvdb/openvdb/unittest/TestTree.cc +++ b/openvdb/openvdb/unittest/TestTree.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -1343,15 +1343,15 @@ TEST_F(TestTree, testTopologyUnion) tree0.addTile(1, xyz, true, true); // leaf level tile tree1.touchLeaf(xyz)->setValueOn(0); // single leaf tree0.topologyUnion(tree1, true); // single tile - EXPECT_EQ(openvdb::Index32(0), tree0.leafCount()); - EXPECT_EQ(openvdb::Index32(3), tree0.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(0), tree0.leafCount()); + EXPECT_EQ(openvdb::Index64(3), tree0.nonLeafCount()); EXPECT_EQ(openvdb::Index64(1), tree0.activeTileCount()); EXPECT_EQ(openvdb::Index64(LeafT::NUM_VOXELS), tree0.activeVoxelCount()); tree1.addTile(1, xyz + openvdb::Coord(8), true, true); // leaf + tile tree0.topologyUnion(tree1, true); // two tiles - EXPECT_EQ(openvdb::Index32(0), tree0.leafCount()); - EXPECT_EQ(openvdb::Index32(3), tree0.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(0), tree0.leafCount()); + EXPECT_EQ(openvdb::Index64(3), tree0.nonLeafCount()); EXPECT_EQ(openvdb::Index64(2), tree0.activeTileCount()); EXPECT_EQ(openvdb::Index64(LeafT::NUM_VOXELS*2), tree0.activeVoxelCount()); @@ -1359,8 +1359,8 @@ TEST_F(TestTree, testTopologyUnion) tree0.clear(); tree0.addTile(2, xyz, true, true); tree0.topologyUnion(tree1, true); // all topology in tree1 is already active. no change - EXPECT_EQ(openvdb::Index32(0), tree0.leafCount()); - EXPECT_EQ(openvdb::Index32(2), tree0.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(0), tree0.leafCount()); + EXPECT_EQ(openvdb::Index64(2), tree0.nonLeafCount()); EXPECT_EQ(openvdb::Index64(1), tree0.activeTileCount()); EXPECT_EQ(openvdb::Index64(InternalT1::NUM_VOXELS), tree0.activeVoxelCount()); @@ -1368,8 +1368,8 @@ TEST_F(TestTree, testTopologyUnion) tree0.clear(); tree0.addTile(3, xyz, true, true); tree0.topologyUnion(tree1, true); - EXPECT_EQ(openvdb::Index32(0), tree0.leafCount()); - EXPECT_EQ(openvdb::Index32(1), tree0.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(0), tree0.leafCount()); + EXPECT_EQ(openvdb::Index64(1), tree0.nonLeafCount()); EXPECT_EQ(openvdb::Index64(1), tree0.activeTileCount()); EXPECT_EQ(openvdb::Index64(InternalT2::NUM_VOXELS), tree0.activeVoxelCount()); @@ -1379,8 +1379,8 @@ TEST_F(TestTree, testTopologyUnion) tree0.addTile(1, xyz, true, true); tree1.addTile(2, xyz, true, true); tree0.topologyUnion(tree1, true); - EXPECT_EQ(openvdb::Index32(0), tree0.leafCount()); - EXPECT_EQ(openvdb::Index32(3), tree0.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(0), tree0.leafCount()); + EXPECT_EQ(openvdb::Index64(3), tree0.nonLeafCount()); openvdb::Index64 tiles = openvdb::Index64(InternalT1::DIM) / InternalT1::getChildDim(); tiles = tiles * tiles * tiles; EXPECT_EQ(tiles, tree0.activeTileCount()); @@ -1429,22 +1429,22 @@ TEST_F(TestTree, testTopologyIntersection) tree0.setValue(openvdb::Coord( 400, 30, 20), 2.0f); tree0.setValue(openvdb::Coord( 8, 11, 11), 3.0f); EXPECT_EQ(openvdb::Index64(3), tree0.activeVoxelCount()); - EXPECT_EQ(openvdb::Index32(3), tree0.leafCount() ); + EXPECT_EQ(openvdb::Index64(3), tree0.leafCount() ); tree1.setValue(openvdb::Coord( 500, 301, 200), 4.0f); tree1.setValue(openvdb::Coord( 400, 30, 20), 5.0f); tree1.setValue(openvdb::Coord( 8, 11, 11), 6.0f); EXPECT_EQ(openvdb::Index64(3), tree1.activeVoxelCount()); - EXPECT_EQ(openvdb::Index32(3), tree1.leafCount() ); + EXPECT_EQ(openvdb::Index64(3), tree1.leafCount() ); tree1.topologyIntersection(tree0); - EXPECT_EQ( openvdb::Index32(3), tree1.leafCount() ); + EXPECT_EQ( openvdb::Index64(3), tree1.leafCount() ); EXPECT_EQ( openvdb::Index64(2), tree1.activeVoxelCount() ); EXPECT_TRUE(!tree1.empty()); openvdb::tools::pruneInactive(tree1); EXPECT_TRUE(!tree1.empty()); - EXPECT_EQ( openvdb::Index32(2), tree1.leafCount() ); + EXPECT_EQ( openvdb::Index64(2), tree1.leafCount() ); EXPECT_EQ( openvdb::Index64(2), tree1.activeVoxelCount() ); } {//passive tile @@ -1453,17 +1453,17 @@ TEST_F(TestTree, testTopologyIntersection) openvdb::FloatTree tree0(background), tree1(background); tree0.fill(openvdb::CoordBBox(openvdb::Coord(0),openvdb::Coord(dim-1)),2.0f, false); EXPECT_EQ(openvdb::Index64(0), tree0.activeVoxelCount()); - EXPECT_EQ(openvdb::Index32(0), tree0.leafCount() ); + EXPECT_EQ(openvdb::Index64(0), tree0.leafCount() ); tree1.setValue(openvdb::Coord( 500, 301, 200), 4.0f); tree1.setValue(openvdb::Coord( 400, 30, 20), 5.0f); tree1.setValue(openvdb::Coord( dim, 11, 11), 6.0f); - EXPECT_EQ(openvdb::Index32(3), tree1.leafCount() ); + EXPECT_EQ(openvdb::Index64(3), tree1.leafCount() ); EXPECT_EQ(openvdb::Index64(3), tree1.activeVoxelCount()); tree1.topologyIntersection(tree0); - EXPECT_EQ( openvdb::Index32(0), tree1.leafCount() ); + EXPECT_EQ( openvdb::Index64(0), tree1.leafCount() ); EXPECT_EQ( openvdb::Index64(0), tree1.activeVoxelCount() ); EXPECT_TRUE(tree1.empty()); } @@ -1473,17 +1473,17 @@ TEST_F(TestTree, testTopologyIntersection) openvdb::FloatTree tree0(background), tree1(background); tree1.fill(openvdb::CoordBBox(openvdb::Coord(0),openvdb::Coord(dim-1)),2.0f, true); EXPECT_EQ(dim*dim*dim, tree1.activeVoxelCount()); - EXPECT_EQ(openvdb::Index32(0), tree1.leafCount() ); + EXPECT_EQ(openvdb::Index64(0), tree1.leafCount() ); tree0.setValue(openvdb::Coord( 500, 301, 200), 4.0f); tree0.setValue(openvdb::Coord( 400, 30, 20), 5.0f); tree0.setValue(openvdb::Coord( dim, 11, 11), 6.0f); EXPECT_EQ(openvdb::Index64(3), tree0.activeVoxelCount()); - EXPECT_EQ(openvdb::Index32(3), tree0.leafCount() ); + EXPECT_EQ(openvdb::Index64(3), tree0.leafCount() ); tree1.topologyIntersection(tree0); - EXPECT_EQ( openvdb::Index32(2), tree1.leafCount() ); + EXPECT_EQ( openvdb::Index64(2), tree1.leafCount() ); EXPECT_EQ( openvdb::Index64(2), tree1.activeVoxelCount() ); EXPECT_TRUE(!tree1.empty()); openvdb::tools::pruneInactive(tree1); @@ -1522,10 +1522,10 @@ TEST_F(TestTree, testTopologyIntersection) tree3.setValue(iter.getCoord(), vec_val); } - EXPECT_EQ(openvdb::Index32(4), tree0.leafCount()); - EXPECT_EQ(openvdb::Index32(4), tree1.leafCount()); - EXPECT_EQ(openvdb::Index32(7), tree2.leafCount()); - EXPECT_EQ(openvdb::Index32(7), tree3.leafCount()); + EXPECT_EQ(openvdb::Index64(4), tree0.leafCount()); + EXPECT_EQ(openvdb::Index64(4), tree1.leafCount()); + EXPECT_EQ(openvdb::Index64(7), tree2.leafCount()); + EXPECT_EQ(openvdb::Index64(7), tree3.leafCount()); //tree1.topologyInterection(tree2);//should make tree1 = tree0 @@ -1673,22 +1673,22 @@ TEST_F(TestTree, testTopologyDifference) tree0.setValue(openvdb::Coord( 400, 30, 20), 2.0f); tree0.setValue(openvdb::Coord( 8, 11, 11), 3.0f); EXPECT_EQ(openvdb::Index64(3), tree0.activeVoxelCount()); - EXPECT_EQ(openvdb::Index32(3), tree0.leafCount() ); + EXPECT_EQ(openvdb::Index64(3), tree0.leafCount() ); tree1.setValue(openvdb::Coord( 500, 301, 200), 4.0f); tree1.setValue(openvdb::Coord( 400, 30, 20), 5.0f); tree1.setValue(openvdb::Coord( 8, 11, 11), 6.0f); EXPECT_EQ(openvdb::Index64(3), tree1.activeVoxelCount()); - EXPECT_EQ(openvdb::Index32(3), tree1.leafCount() ); + EXPECT_EQ(openvdb::Index64(3), tree1.leafCount() ); tree1.topologyDifference(tree0); - EXPECT_EQ( openvdb::Index32(3), tree1.leafCount() ); + EXPECT_EQ( openvdb::Index64(3), tree1.leafCount() ); EXPECT_EQ( openvdb::Index64(1), tree1.activeVoxelCount() ); EXPECT_TRUE(!tree1.empty()); openvdb::tools::pruneInactive(tree1); EXPECT_TRUE(!tree1.empty()); - EXPECT_EQ( openvdb::Index32(1), tree1.leafCount() ); + EXPECT_EQ( openvdb::Index64(1), tree1.leafCount() ); EXPECT_EQ( openvdb::Index64(1), tree1.activeVoxelCount() ); } {//passive tile @@ -1699,22 +1699,22 @@ TEST_F(TestTree, testTopologyDifference) EXPECT_EQ(openvdb::Index64(0), tree0.activeVoxelCount()); EXPECT_TRUE(!tree0.hasActiveTiles()); EXPECT_EQ(openvdb::Index64(0), tree0.root().onTileCount()); - EXPECT_EQ(openvdb::Index32(0), tree0.leafCount() ); + EXPECT_EQ(openvdb::Index64(0), tree0.leafCount() ); tree1.setValue(openvdb::Coord( 500, 301, 200), 4.0f); tree1.setValue(openvdb::Coord( 400, 30, 20), 5.0f); tree1.setValue(openvdb::Coord( dim, 11, 11), 6.0f); EXPECT_EQ(openvdb::Index64(3), tree1.activeVoxelCount()); EXPECT_TRUE(!tree1.hasActiveTiles()); - EXPECT_EQ(openvdb::Index32(3), tree1.leafCount() ); + EXPECT_EQ(openvdb::Index64(3), tree1.leafCount() ); tree1.topologyDifference(tree0); - EXPECT_EQ( openvdb::Index32(3), tree1.leafCount() ); + EXPECT_EQ( openvdb::Index64(3), tree1.leafCount() ); EXPECT_EQ( openvdb::Index64(3), tree1.activeVoxelCount() ); EXPECT_TRUE(!tree1.empty()); openvdb::tools::pruneInactive(tree1); - EXPECT_EQ( openvdb::Index32(3), tree1.leafCount() ); + EXPECT_EQ( openvdb::Index64(3), tree1.leafCount() ); EXPECT_EQ( openvdb::Index64(3), tree1.activeVoxelCount() ); EXPECT_TRUE(!tree1.empty()); } @@ -1726,14 +1726,14 @@ TEST_F(TestTree, testTopologyDifference) EXPECT_EQ(dim*dim*dim, tree1.activeVoxelCount()); EXPECT_TRUE(tree1.hasActiveTiles()); EXPECT_EQ(openvdb::Index64(1), tree1.root().onTileCount()); - EXPECT_EQ(openvdb::Index32(0), tree0.leafCount() ); + EXPECT_EQ(openvdb::Index64(0), tree0.leafCount() ); tree0.setValue(openvdb::Coord( 500, 301, 200), 4.0f); tree0.setValue(openvdb::Coord( 400, 30, 20), 5.0f); tree0.setValue(openvdb::Coord( int(dim), 11, 11), 6.0f); EXPECT_TRUE(!tree0.hasActiveTiles()); EXPECT_EQ(openvdb::Index64(3), tree0.activeVoxelCount()); - EXPECT_EQ(openvdb::Index32(3), tree0.leafCount() ); + EXPECT_EQ(openvdb::Index64(3), tree0.leafCount() ); EXPECT_TRUE( tree0.isValueOn(openvdb::Coord( int(dim), 11, 11))); EXPECT_TRUE(!tree1.isValueOn(openvdb::Coord( int(dim), 11, 11))); @@ -1754,22 +1754,22 @@ TEST_F(TestTree, testTopologyDifference) EXPECT_EQ(dim*dim*dim, tree1.activeVoxelCount()); EXPECT_TRUE(tree1.hasActiveTiles()); EXPECT_EQ(openvdb::Index64(1), tree1.root().onTileCount()); - EXPECT_EQ(openvdb::Index32(0), tree0.leafCount() ); + EXPECT_EQ(openvdb::Index64(0), tree0.leafCount() ); tree0.setValue(openvdb::Coord( 500, 301, 200), 4.0f); tree0.setValue(openvdb::Coord( 400, 30, 20), 5.0f); tree0.setValue(openvdb::Coord( dim, 11, 11), 6.0f); EXPECT_TRUE(!tree0.hasActiveTiles()); EXPECT_EQ(openvdb::Index64(3), tree0.activeVoxelCount()); - EXPECT_EQ(openvdb::Index32(3), tree0.leafCount() ); + EXPECT_EQ(openvdb::Index64(3), tree0.leafCount() ); tree0.topologyDifference(tree1); - EXPECT_EQ( openvdb::Index32(1), tree0.leafCount() ); + EXPECT_EQ( openvdb::Index64(1), tree0.leafCount() ); EXPECT_EQ( openvdb::Index64(1), tree0.activeVoxelCount() ); EXPECT_TRUE(!tree0.empty()); openvdb::tools::pruneInactive(tree0); - EXPECT_EQ( openvdb::Index32(1), tree0.leafCount() ); + EXPECT_EQ( openvdb::Index64(1), tree0.leafCount() ); EXPECT_EQ( openvdb::Index64(1), tree0.activeVoxelCount() ); EXPECT_TRUE(!tree1.empty()); } @@ -1806,10 +1806,10 @@ TEST_F(TestTree, testTopologyDifference) tree3.setValue(iter.getCoord(), vec_val); } - EXPECT_EQ(openvdb::Index32(4), tree0.leafCount()); - EXPECT_EQ(openvdb::Index32(4), tree1.leafCount()); - EXPECT_EQ(openvdb::Index32(7), tree2.leafCount()); - EXPECT_EQ(openvdb::Index32(7), tree3.leafCount()); + EXPECT_EQ(openvdb::Index64(4), tree0.leafCount()); + EXPECT_EQ(openvdb::Index64(4), tree1.leafCount()); + EXPECT_EQ(openvdb::Index64(7), tree2.leafCount()); + EXPECT_EQ(openvdb::Index64(7), tree3.leafCount()); //tree1.topologyInterection(tree2);//should make tree1 = tree0 @@ -2094,16 +2094,16 @@ TEST_F(TestTree, testPruneInactive) tree.setValue(Coord( 5, 10,-20), 0.3f); // Verify that the tree has the expected numbers of active voxels and leaf nodes. EXPECT_EQ(Index64(8), tree.activeVoxelCount()); - EXPECT_EQ(Index32(8), tree.leafCount()); + EXPECT_EQ(Index64(8), tree.leafCount()); // Verify that prune() has no effect, since the values are all different. openvdb::tools::prune(tree); EXPECT_EQ(Index64(8), tree.activeVoxelCount()); - EXPECT_EQ(Index32(8), tree.leafCount()); + EXPECT_EQ(Index64(8), tree.leafCount()); // Verify that pruneInactive() has no effect, since the values are active. openvdb::tools::pruneInactive(tree); EXPECT_EQ(Index64(8), tree.activeVoxelCount()); - EXPECT_EQ(Index32(8), tree.leafCount()); + EXPECT_EQ(Index64(8), tree.leafCount()); // Make some of the active values inactive, without changing their values. tree.setValueOff(Coord(-5, 10, 20)); @@ -2111,15 +2111,15 @@ TEST_F(TestTree, testPruneInactive) tree.setValueOff(Coord(-5, 10,-20)); tree.setValueOff(Coord(-5,-10,-20)); EXPECT_EQ(Index64(4), tree.activeVoxelCount()); - EXPECT_EQ(Index32(8), tree.leafCount()); + EXPECT_EQ(Index64(8), tree.leafCount()); // Verify that prune() has no effect, since the values are still different. openvdb::tools::prune(tree); EXPECT_EQ(Index64(4), tree.activeVoxelCount()); - EXPECT_EQ(Index32(8), tree.leafCount()); + EXPECT_EQ(Index64(8), tree.leafCount()); // Verify that pruneInactive() prunes the nodes containing only inactive voxels. openvdb::tools::pruneInactive(tree); EXPECT_EQ(Index64(4), tree.activeVoxelCount()); - EXPECT_EQ(Index32(4), tree.leafCount()); + EXPECT_EQ(Index64(4), tree.leafCount()); // Make all of the active values inactive, without changing their values. tree.setValueOff(Coord( 5, 10, 20)); @@ -2127,11 +2127,11 @@ TEST_F(TestTree, testPruneInactive) tree.setValueOff(Coord( 5,-10,-20)); tree.setValueOff(Coord( 5, 10,-20)); EXPECT_EQ(Index64(0), tree.activeVoxelCount()); - EXPECT_EQ(Index32(4), tree.leafCount()); + EXPECT_EQ(Index64(4), tree.leafCount()); // Verify that prune() has no effect, since the values are still different. openvdb::tools::prune(tree); EXPECT_EQ(Index64(0), tree.activeVoxelCount()); - EXPECT_EQ(Index32(4), tree.leafCount()); + EXPECT_EQ(Index64(4), tree.leafCount()); // Verify that pruneInactive() prunes all of the remaining leaf nodes. openvdb::tools::pruneInactive(tree); EXPECT_TRUE(tree.empty()); @@ -2158,7 +2158,7 @@ TEST_F(TestTree, testPruneLevelSet) } } - const openvdb::Index32 leafCount = tree.leafCount(); + const openvdb::Index64 leafCount = tree.leafCount(); EXPECT_EQ(tree.activeVoxelCount(), count); EXPECT_EQ(tree.activeLeafVoxelCount(), count); @@ -2646,6 +2646,7 @@ TEST_F(TestTree, testStealNodes) TEST_F(TestTree, testStealNode) { using openvdb::Index; + using openvdb::Index64; using openvdb::FloatTree; const float background=0.0f, value = 5.6f, epsilon=0.000001f; @@ -2656,19 +2657,19 @@ TEST_F(TestTree, testStealNode) EXPECT_EQ(Index(0), NodeT::getLevel()); FloatTree tree(background); - EXPECT_EQ(Index(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_TRUE(!tree.isValueOn(xyz)); EXPECT_NEAR(background, tree.getValue(xyz), epsilon); EXPECT_TRUE(tree.root().stealNode(xyz, value, false) == nullptr); tree.setValue(xyz, value); - EXPECT_EQ(Index(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_TRUE(tree.isValueOn(xyz)); EXPECT_NEAR(value, tree.getValue(xyz), epsilon); NodeT* node = tree.root().stealNode(xyz, background, false); EXPECT_TRUE(node != nullptr); - EXPECT_EQ(Index(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_TRUE(!tree.isValueOn(xyz)); EXPECT_NEAR(background, tree.getValue(xyz), epsilon); EXPECT_TRUE(tree.root().stealNode(xyz, value, false) == nullptr); @@ -2681,19 +2682,19 @@ TEST_F(TestTree, testStealNode) EXPECT_EQ(Index(1), NodeT::getLevel()); FloatTree tree(background); - EXPECT_EQ(Index(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_TRUE(!tree.isValueOn(xyz)); EXPECT_NEAR(background, tree.getValue(xyz), epsilon); EXPECT_TRUE(tree.root().stealNode(xyz, value, false) == nullptr); tree.setValue(xyz, value); - EXPECT_EQ(Index(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_TRUE(tree.isValueOn(xyz)); EXPECT_NEAR(value, tree.getValue(xyz), epsilon); NodeT* node = tree.root().stealNode(xyz, background, false); EXPECT_TRUE(node != nullptr); - EXPECT_EQ(Index(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_TRUE(!tree.isValueOn(xyz)); EXPECT_NEAR(background, tree.getValue(xyz), epsilon); EXPECT_TRUE(tree.root().stealNode(xyz, value, false) == nullptr); @@ -2706,19 +2707,19 @@ TEST_F(TestTree, testStealNode) EXPECT_EQ(Index(2), NodeT::getLevel()); FloatTree tree(background); - EXPECT_EQ(Index(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_TRUE(!tree.isValueOn(xyz)); EXPECT_NEAR(background, tree.getValue(xyz), epsilon); EXPECT_TRUE(tree.root().stealNode(xyz, value, false) == nullptr); tree.setValue(xyz, value); - EXPECT_EQ(Index(1), tree.leafCount()); + EXPECT_EQ(Index64(1), tree.leafCount()); EXPECT_TRUE(tree.isValueOn(xyz)); EXPECT_NEAR(value, tree.getValue(xyz), epsilon); NodeT* node = tree.root().stealNode(xyz, background, false); EXPECT_TRUE(node != nullptr); - EXPECT_EQ(Index(0), tree.leafCount()); + EXPECT_EQ(Index64(0), tree.leafCount()); EXPECT_TRUE(!tree.isValueOn(xyz)); EXPECT_NEAR(background, tree.getValue(xyz), epsilon); EXPECT_TRUE(tree.root().stealNode(xyz, value, false) == nullptr); @@ -2743,7 +2744,7 @@ TEST_F(TestTree, testNodeCount) std::vector dims; tree.getNodeLog2Dims(dims); - std::vector nodeCount1(dims.size()); + std::vector nodeCount1(dims.size()); //timer.start("Old technique");// use for benchmark test for (auto it = tree.cbeginNode(); it; ++it) ++(nodeCount1[dims.size()-1-it.getDepth()]); //timer.restart("New technique");// use for benchmark test @@ -2755,204 +2756,3 @@ TEST_F(TestTree, testNodeCount) EXPECT_EQ(tree.leafCount(), nodeCount2.front());// leaf nodes for (size_t i=0; i children; - root.stealNodes(children); - EXPECT_TRUE(root.empty()); - - // insert the root node children directly - for (ChildType* child : children) { - root.addChild(child); - } - EXPECT_EQ(openvdb::Index(2), root.getTableSize()); - EXPECT_EQ(openvdb::Index32(2), root.childCount()); - - { // verify the coordinates of the root node children - auto rootIter = root.cbeginChildOn(); - EXPECT_EQ(c0, rootIter.getCoord()); - ++rootIter; - EXPECT_EQ(c1, rootIter.getCoord()); - } - } - - { // test inserting tiles and replacing them with child nodes - RootNodeType root(0.0f); - EXPECT_TRUE(root.empty()); - - // no-op - root.addChild(nullptr); - - // populate the root node by inserting tiles - root.addTile(c0, /*value=*/1.0f, /*state=*/true); - root.addTile(c1, /*value=*/2.0f, /*state=*/true); - EXPECT_EQ(openvdb::Index(2), root.getTableSize()); - EXPECT_EQ(openvdb::Index32(0), root.childCount()); - EXPECT_TRUE(root.hasActiveTiles()); - ASSERT_DOUBLES_EXACTLY_EQUAL(1.0f, root.getValue(c0)); - ASSERT_DOUBLES_EXACTLY_EQUAL(2.0f, root.getValue(c1)); - - // insert child nodes with the same coordinates - root.addChild(new ChildType(c0, 3.0f)); - root.addChild(new ChildType(c1, 4.0f)); - - // insert a new child at c0 - root.addChild(new ChildType(c0, 5.0f)); - - // verify active tiles have been replaced by child nodes - EXPECT_EQ(openvdb::Index(2), root.getTableSize()); - EXPECT_EQ(openvdb::Index32(2), root.childCount()); - EXPECT_TRUE(!root.hasActiveTiles()); - - { // verify the coordinates of the root node children - auto rootIter = root.cbeginChildOn(); - EXPECT_EQ(c0, rootIter.getCoord()); - ASSERT_DOUBLES_EXACTLY_EQUAL(5.0f, root.getValue(c0)); - ++rootIter; - EXPECT_EQ(c1, rootIter.getCoord()); - } - } - - { // test transient data - RootNodeType rootNode(0.0f); - EXPECT_EQ(openvdb::Index32(0), rootNode.transientData()); - rootNode.setTransientData(openvdb::Index32(5)); - EXPECT_EQ(openvdb::Index32(5), rootNode.transientData()); - RootNodeType rootNode2(rootNode); - EXPECT_EQ(openvdb::Index32(5), rootNode2.transientData()); - RootNodeType rootNode3 = rootNode; - EXPECT_EQ(openvdb::Index32(5), rootNode3.transientData()); - } -} - -TEST_F(TestTree, testInternalNode) -{ - const openvdb::Coord c0(1000, 1000, 1000); - const openvdb::Coord c1(896, 896, 896); - - using InternalNodeType = InternalNodeType1; - using ChildType = LeafNodeType; - - { // test inserting child nodes directly and indirectly - openvdb::Coord c2 = c1.offsetBy(8,0,0); - openvdb::Coord c3 = c1.offsetBy(16,16,16); - - InternalNodeType internalNode(c1, 0.0f); - internalNode.touchLeaf(c2); - internalNode.touchLeaf(c3); - - EXPECT_EQ(openvdb::Index(2), internalNode.leafCount()); - EXPECT_EQ(openvdb::Index32(2), internalNode.childCount()); - EXPECT_TRUE(!internalNode.hasActiveTiles()); - - { // verify c0 and c1 are the root node coordinates - auto childIter = internalNode.cbeginChildOn(); - EXPECT_EQ(c2, childIter.getCoord()); - ++childIter; - EXPECT_EQ(c3, childIter.getCoord()); - } - - // copy the internal node - InternalNodeType internalNodeCopy(internalNode); - - // steal the internal node children leaving it empty again - std::vector children; - internalNode.stealNodes(children, 0.0f, false); - EXPECT_EQ(openvdb::Index(0), internalNode.leafCount()); - EXPECT_EQ(openvdb::Index32(0), internalNode.childCount()); - - // insert the root node children directly - for (ChildType* child : children) { - internalNode.addChild(child); - } - EXPECT_EQ(openvdb::Index(2), internalNode.leafCount()); - EXPECT_EQ(openvdb::Index32(2), internalNode.childCount()); - - { // verify the coordinates of the root node children - auto childIter = internalNode.cbeginChildOn(); - EXPECT_EQ(c2, childIter.getCoord()); - ++childIter; - EXPECT_EQ(c3, childIter.getCoord()); - } - } - - { // test inserting a tile and replacing with a child node - InternalNodeType internalNode(c1, 0.0f); - EXPECT_TRUE(!internalNode.hasActiveTiles()); - EXPECT_EQ(openvdb::Index(0), internalNode.leafCount()); - EXPECT_EQ(openvdb::Index32(0), internalNode.childCount()); - - // add a tile - internalNode.addTile(openvdb::Index(0), /*value=*/1.0f, /*state=*/true); - EXPECT_TRUE(internalNode.hasActiveTiles()); - EXPECT_EQ(openvdb::Index(0), internalNode.leafCount()); - EXPECT_EQ(openvdb::Index32(0), internalNode.childCount()); - - // replace the tile with a child node - EXPECT_TRUE(internalNode.addChild(new ChildType(c1, 2.0f))); - EXPECT_TRUE(!internalNode.hasActiveTiles()); - EXPECT_EQ(openvdb::Index(1), internalNode.leafCount()); - EXPECT_EQ(openvdb::Index32(1), internalNode.childCount()); - EXPECT_EQ(c1, internalNode.cbeginChildOn().getCoord()); - ASSERT_DOUBLES_EXACTLY_EQUAL(2.0f, internalNode.cbeginChildOn()->getValue(0)); - - // replace the child node with another child node - EXPECT_TRUE(internalNode.addChild(new ChildType(c1, 3.0f))); - ASSERT_DOUBLES_EXACTLY_EQUAL(3.0f, internalNode.cbeginChildOn()->getValue(0)); - } - - { // test inserting child nodes that do and do not belong to the internal node - InternalNodeType internalNode(c1, 0.0f); - - // succeed if child belongs to this internal node - EXPECT_TRUE(internalNode.addChild(new ChildType(c0.offsetBy(8,0,0)))); - EXPECT_TRUE(internalNode.probeLeaf(c0.offsetBy(8,0,0))); - openvdb::Index index1 = internalNode.coordToOffset(c0); - openvdb::Index index2 = internalNode.coordToOffset(c0.offsetBy(8,0,0)); - EXPECT_TRUE(!internalNode.isChildMaskOn(index1)); - EXPECT_TRUE(internalNode.isChildMaskOn(index2)); - - // fail otherwise - auto* child = new ChildType(c0.offsetBy(8000,0,0)); - EXPECT_TRUE(!internalNode.addChild(child)); - delete child; - } - - { // test transient data - InternalNodeType internalNode(c1, 0.0f); - EXPECT_EQ(openvdb::Index32(0), internalNode.transientData()); - internalNode.setTransientData(openvdb::Index32(5)); - EXPECT_EQ(openvdb::Index32(5), internalNode.transientData()); - InternalNodeType internalNode2(internalNode); - EXPECT_EQ(openvdb::Index32(5), internalNode2.transientData()); - InternalNodeType internalNode3 = internalNode; - EXPECT_EQ(openvdb::Index32(5), internalNode3.transientData()); - } -} diff --git a/openvdb/openvdb/unittest/TestTreeCombine.cc b/openvdb/openvdb/unittest/TestTreeCombine.cc index b4fb8bc923..d761a47511 100644 --- a/openvdb/openvdb/unittest/TestTreeCombine.cc +++ b/openvdb/openvdb/unittest/TestTreeCombine.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestTreeGetSetValues.cc b/openvdb/openvdb/unittest/TestTreeGetSetValues.cc index df272cc384..ea5ce6e9f8 100644 --- a/openvdb/openvdb/unittest/TestTreeGetSetValues.cc +++ b/openvdb/openvdb/unittest/TestTreeGetSetValues.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -224,108 +224,108 @@ TEST_F(TestTreeGetSetValues, testFill) // The following tests assume a [3,2,3] tree configuration. tree.clear(); - EXPECT_EQ(openvdb::Index32(0), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(1), tree.nonLeafCount()); // root node + EXPECT_EQ(openvdb::Index64(0), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(1), tree.nonLeafCount()); // root node // Partially fill a single leaf node. tree.fill(CoordBBox(Coord(8), Coord(14)), 0.0); - EXPECT_EQ(openvdb::Index32(1), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(3), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(1), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(3), tree.nonLeafCount()); // Completely fill the leaf node, replacing it with a tile. tree.fill(CoordBBox(Coord(8), Coord(15)), 0.0); - EXPECT_EQ(openvdb::Index32(0), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(3), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(0), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(3), tree.nonLeafCount()); { const int activeVoxelCount = int(tree.activeVoxelCount()); // Fill a single voxel of the tile with a different (active) value. tree.fill(CoordBBox(Coord(10), Coord(10)), 1.0); - EXPECT_EQ(openvdb::Index32(1), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(3), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(1), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(3), tree.nonLeafCount()); EXPECT_EQ(activeVoxelCount, int(tree.activeVoxelCount())); // Fill the voxel with an inactive value. tree.fill(CoordBBox(Coord(10), Coord(10)), 1.0, /*active=*/false); - EXPECT_EQ(openvdb::Index32(1), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(3), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(1), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(3), tree.nonLeafCount()); EXPECT_EQ(activeVoxelCount - 1, int(tree.activeVoxelCount())); // Completely fill the leaf node, replacing it with a tile again. tree.fill(CoordBBox(Coord(8), Coord(15)), 0.0); - EXPECT_EQ(openvdb::Index32(0), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(3), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(0), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(3), tree.nonLeafCount()); } // Expand by one voxel, creating seven neighboring leaf nodes. tree.fill(CoordBBox(Coord(8), Coord(16)), 0.0); - EXPECT_EQ(openvdb::Index32(7), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(3), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(7), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(3), tree.nonLeafCount()); // Completely fill the internal node containing the tile, replacing it with // a tile at the next level of the tree. tree.fill(CoordBBox(Coord(0), Coord(31)), 0.0); - EXPECT_EQ(openvdb::Index32(0), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(2), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(0), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(2), tree.nonLeafCount()); // Expand by one voxel, creating a layer of leaf nodes on three faces. tree.fill(CoordBBox(Coord(0), Coord(32)), 0.0); - EXPECT_EQ(openvdb::Index32(5*5 + 4*5 + 4*4), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(2 + 7), tree.nonLeafCount()); // +7 internal nodes + EXPECT_EQ(openvdb::Index64(5*5 + 4*5 + 4*4), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(2 + 7), tree.nonLeafCount()); // +7 internal nodes // Completely fill the second-level internal node, replacing it with a root-level tile. tree.fill(CoordBBox(Coord(0), Coord(255)), 0.0); - EXPECT_EQ(openvdb::Index32(0), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(1), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(0), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(1), tree.nonLeafCount()); // Repeat, filling with an inactive value. tree.clear(); - EXPECT_EQ(openvdb::Index32(0), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(1), tree.nonLeafCount()); // root node + EXPECT_EQ(openvdb::Index64(0), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(1), tree.nonLeafCount()); // root node // Partially fill a single leaf node. tree.fill(CoordBBox(Coord(8), Coord(14)), 0.0, /*active=*/false); - EXPECT_EQ(openvdb::Index32(1), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(3), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(1), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(3), tree.nonLeafCount()); // Completely fill the leaf node, replacing it with a tile. tree.fill(CoordBBox(Coord(8), Coord(15)), 0.0, /*active=*/false); - EXPECT_EQ(openvdb::Index32(0), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(3), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(0), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(3), tree.nonLeafCount()); // Expand by one voxel, creating seven neighboring leaf nodes. tree.fill(CoordBBox(Coord(8), Coord(16)), 0.0, /*active=*/false); - EXPECT_EQ(openvdb::Index32(7), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(3), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(7), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(3), tree.nonLeafCount()); // Completely fill the internal node containing the tile, replacing it with // a tile at the next level of the tree. tree.fill(CoordBBox(Coord(0), Coord(31)), 0.0, /*active=*/false); - EXPECT_EQ(openvdb::Index32(0), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(2), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(0), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(2), tree.nonLeafCount()); // Expand by one voxel, creating a layer of leaf nodes on three faces. tree.fill(CoordBBox(Coord(0), Coord(32)), 0.0, /*active=*/false); - EXPECT_EQ(openvdb::Index32(5*5 + 4*5 + 4*4), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(2 + 7), tree.nonLeafCount()); // +7 internal nodes + EXPECT_EQ(openvdb::Index64(5*5 + 4*5 + 4*4), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(2 + 7), tree.nonLeafCount()); // +7 internal nodes // Completely fill the second-level internal node, replacing it with a root-level tile. tree.fill(CoordBBox(Coord(0), Coord(255)), 0.0, /*active=*/false); - EXPECT_EQ(openvdb::Index32(0), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(1), tree.nonLeafCount()); + EXPECT_EQ(openvdb::Index64(0), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(1), tree.nonLeafCount()); tree.clear(); - EXPECT_EQ(openvdb::Index32(0), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(1), tree.nonLeafCount()); // root node + EXPECT_EQ(openvdb::Index64(0), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(1), tree.nonLeafCount()); // root node EXPECT_TRUE(tree.empty()); // Partially fill a region with inactive background values. tree.fill(CoordBBox(Coord(27), Coord(254)), background, /*active=*/false); // Confirm that after pruning, the tree is empty. openvdb::tools::prune(tree); - EXPECT_EQ(openvdb::Index32(0), tree.leafCount()); - EXPECT_EQ(openvdb::Index32(1), tree.nonLeafCount()); // root node + EXPECT_EQ(openvdb::Index64(0), tree.leafCount()); + EXPECT_EQ(openvdb::Index64(1), tree.nonLeafCount()); // root node EXPECT_TRUE(tree.empty()); } diff --git a/openvdb/openvdb/unittest/TestTreeIterators.cc b/openvdb/openvdb/unittest/TestTreeIterators.cc index 3ffcfcf5a2..ad039efb85 100644 --- a/openvdb/openvdb/unittest/TestTreeIterators.cc +++ b/openvdb/openvdb/unittest/TestTreeIterators.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestTypeList.cc b/openvdb/openvdb/unittest/TestTypeList.cc index 5c084c867c..9f8a98d94d 100644 --- a/openvdb/openvdb/unittest/TestTypeList.cc +++ b/openvdb/openvdb/unittest/TestTypeList.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestTypes.cc b/openvdb/openvdb/unittest/TestTypes.cc index 6af47a69b8..8be3a776fc 100644 --- a/openvdb/openvdb/unittest/TestTypes.cc +++ b/openvdb/openvdb/unittest/TestTypes.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestUtil.cc b/openvdb/openvdb/unittest/TestUtil.cc index 4c4f1f6084..1a41932dc0 100644 --- a/openvdb/openvdb/unittest/TestUtil.cc +++ b/openvdb/openvdb/unittest/TestUtil.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestValueAccessor.cc b/openvdb/openvdb/unittest/TestValueAccessor.cc index b4907a7cd0..947552e37a 100644 --- a/openvdb/openvdb/unittest/TestValueAccessor.cc +++ b/openvdb/openvdb/unittest/TestValueAccessor.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -587,6 +587,7 @@ TEST_F(TestValueAccessor, testMultiThreadedRWAccessors) TEST_F(TestValueAccessor, testAccessorRegistration) { using openvdb::Index; + using openvdb::Index64; const float background = 5.0f, value = -9.345f; const openvdb::Coord c0(5, 10, 20); @@ -597,29 +598,29 @@ TEST_F(TestValueAccessor, testAccessorRegistration) // Set a single leaf voxel via the accessor and verify that // the cache is populated. acc.setValue(c0, value); - EXPECT_EQ(Index(1), tree->leafCount()); - EXPECT_EQ(tree->root().getLevel(), tree->nonLeafCount()); + EXPECT_EQ(Index64(1), tree->leafCount()); + EXPECT_EQ(Index64(tree->root().getLevel()), tree->nonLeafCount()); EXPECT_TRUE(acc.getNode() != nullptr); // Reset the voxel to the background value and verify that no nodes // have been deleted and that the cache is still populated. tree->setValueOff(c0, background); - EXPECT_EQ(Index(1), tree->leafCount()); - EXPECT_EQ(tree->root().getLevel(), tree->nonLeafCount()); + EXPECT_EQ(Index64(1), tree->leafCount()); + EXPECT_EQ(Index64(tree->root().getLevel()), tree->nonLeafCount()); EXPECT_TRUE(acc.getNode() != nullptr); // Prune the tree and verify that only the root node remains and that // the cache has been cleared. openvdb::tools::prune(*tree); //tree->prune(); - EXPECT_EQ(Index(0), tree->leafCount()); - EXPECT_EQ(Index(1), tree->nonLeafCount()); // root node only + EXPECT_EQ(Index64(0), tree->leafCount()); + EXPECT_EQ(Index64(1), tree->nonLeafCount()); // root node only EXPECT_TRUE(acc.getNode() == nullptr); // Set the leaf voxel again and verify that the cache is repopulated. acc.setValue(c0, value); - EXPECT_EQ(Index(1), tree->leafCount()); - EXPECT_EQ(tree->root().getLevel(), tree->nonLeafCount()); + EXPECT_EQ(Index64(1), tree->leafCount()); + EXPECT_EQ(Index64(tree->root().getLevel()), tree->nonLeafCount()); EXPECT_TRUE(acc.getNode() != nullptr); // Delete the tree and verify that the cache has been cleared. @@ -665,8 +666,6 @@ TEST_F(TestValueAccessor, testGetNode) } } -#if OPENVDB_ABI_VERSION_NUMBER >= 10 - template struct AssertBypass { inline void operator()() { @@ -703,5 +702,3 @@ TEST_F(TestValueAccessor, testBypassLeafAPI) static_assert(!ValueAccessor2::BypassLeafAPI); static_assert(!ValueAccessor3::BypassLeafAPI); } - -#endif diff --git a/openvdb/openvdb/unittest/TestVec2Metadata.cc b/openvdb/openvdb/unittest/TestVec2Metadata.cc index 770b9cf529..85d29f2486 100644 --- a/openvdb/openvdb/unittest/TestVec2Metadata.cc +++ b/openvdb/openvdb/unittest/TestVec2Metadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestVec3Metadata.cc b/openvdb/openvdb/unittest/TestVec3Metadata.cc index 47f83c9616..8cf58d61e3 100644 --- a/openvdb/openvdb/unittest/TestVec3Metadata.cc +++ b/openvdb/openvdb/unittest/TestVec3Metadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestVolumeRayIntersector.cc b/openvdb/openvdb/unittest/TestVolumeRayIntersector.cc index dc061b9488..ed2fef1ae0 100644 --- a/openvdb/openvdb/unittest/TestVolumeRayIntersector.cc +++ b/openvdb/openvdb/unittest/TestVolumeRayIntersector.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file unittest/TestVolumeRayIntersector.cc /// @author Ken Museth diff --git a/openvdb/openvdb/unittest/TestVolumeToMesh.cc b/openvdb/openvdb/unittest/TestVolumeToMesh.cc index ef40282569..e1479e5315 100644 --- a/openvdb/openvdb/unittest/TestVolumeToMesh.cc +++ b/openvdb/openvdb/unittest/TestVolumeToMesh.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb/openvdb/unittest/TestVolumeToSpheres.cc b/openvdb/openvdb/unittest/TestVolumeToSpheres.cc index 296c341f76..7d7979b6be 100644 --- a/openvdb/openvdb/unittest/TestVolumeToSpheres.cc +++ b/openvdb/openvdb/unittest/TestVolumeToSpheres.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include // for createLevelSetSphere diff --git a/openvdb/openvdb/unittest/main.cc b/openvdb/openvdb/unittest/main.cc index 3fa6b56726..5066512862 100644 --- a/openvdb/openvdb/unittest/main.cc +++ b/openvdb/openvdb/unittest/main.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for std::shuffle() #include // for std::round() diff --git a/openvdb/openvdb/unittest/util.h b/openvdb/openvdb/unittest/util.h index eef0767c5f..110a8e7290 100644 --- a/openvdb/openvdb/unittest/util.h +++ b/openvdb/openvdb/unittest/util.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_UNITTEST_UTIL_HAS_BEEN_INCLUDED #define OPENVDB_UNITTEST_UTIL_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/util/Assert.cc b/openvdb/openvdb/util/Assert.cc index 540293b2b3..74e8ef1660 100644 --- a/openvdb/openvdb/util/Assert.cc +++ b/openvdb/openvdb/util/Assert.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// /// @file Platform.h diff --git a/openvdb/openvdb/util/Assert.h b/openvdb/openvdb/util/Assert.h index aa56f911c2..234213f008 100644 --- a/openvdb/openvdb/util/Assert.h +++ b/openvdb/openvdb/util/Assert.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// /// @file Assert.h diff --git a/openvdb/openvdb/util/CpuTimer.h b/openvdb/openvdb/util/CpuTimer.h index e068e5b8cd..774c4f7531 100644 --- a/openvdb/openvdb/util/CpuTimer.h +++ b/openvdb/openvdb/util/CpuTimer.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_UTIL_CPUTIMER_HAS_BEEN_INCLUDED #define OPENVDB_UTIL_CPUTIMER_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/util/ExplicitInstantiation.h b/openvdb/openvdb/util/ExplicitInstantiation.h index de5bfc801f..44ab44a478 100644 --- a/openvdb/openvdb/util/ExplicitInstantiation.h +++ b/openvdb/openvdb/util/ExplicitInstantiation.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_UTIL_EXPLICIT_INSTANTIATION_HAS_BEEN_INCLUDED #define OPENVDB_UTIL_EXPLICIT_INSTANTIATION_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/util/Formats.cc b/openvdb/openvdb/util/Formats.cc index e7b873315f..c03b14c1f7 100644 --- a/openvdb/openvdb/util/Formats.cc +++ b/openvdb/openvdb/util/Formats.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "Formats.h" #include diff --git a/openvdb/openvdb/util/Formats.h b/openvdb/openvdb/util/Formats.h index e603891ad2..362761f234 100644 --- a/openvdb/openvdb/util/Formats.h +++ b/openvdb/openvdb/util/Formats.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Ken Museth /// diff --git a/openvdb/openvdb/util/MapsUtil.h b/openvdb/openvdb/util/MapsUtil.h index 16c2c8e1a1..ffdd0355c7 100644 --- a/openvdb/openvdb/util/MapsUtil.h +++ b/openvdb/openvdb/util/MapsUtil.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file MapsUtil.h diff --git a/openvdb/openvdb/util/Name.h b/openvdb/openvdb/util/Name.h index 68225513e2..5bbc33a6fe 100644 --- a/openvdb/openvdb/util/Name.h +++ b/openvdb/openvdb/util/Name.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_UTIL_NAME_HAS_BEEN_INCLUDED #define OPENVDB_UTIL_NAME_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/util/NodeMasks.h b/openvdb/openvdb/util/NodeMasks.h index 4d8c212d59..370f3b0555 100644 --- a/openvdb/openvdb/util/NodeMasks.h +++ b/openvdb/openvdb/util/NodeMasks.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @author Ken Museth /// diff --git a/openvdb/openvdb/util/NullInterrupter.h b/openvdb/openvdb/util/NullInterrupter.h index 2d04f18263..7d92a8ae65 100644 --- a/openvdb/openvdb/util/NullInterrupter.h +++ b/openvdb/openvdb/util/NullInterrupter.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file NullInterrupter.h diff --git a/openvdb/openvdb/util/PagedArray.h b/openvdb/openvdb/util/PagedArray.h index f98e621f40..bf9bedf2af 100644 --- a/openvdb/openvdb/util/PagedArray.h +++ b/openvdb/openvdb/util/PagedArray.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// /// @file PagedArray.h /// diff --git a/openvdb/openvdb/util/Util.h b/openvdb/openvdb/util/Util.h index 7344269ab7..49e99c97a9 100644 --- a/openvdb/openvdb/util/Util.h +++ b/openvdb/openvdb/util/Util.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_UTIL_UTIL_HAS_BEEN_INCLUDED #define OPENVDB_UTIL_UTIL_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/util/logging.h b/openvdb/openvdb/util/logging.h index d799ffb599..5ddca8ffe8 100644 --- a/openvdb/openvdb/util/logging.h +++ b/openvdb/openvdb/util/logging.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_UTIL_LOGGING_HAS_BEEN_INCLUDED #define OPENVDB_UTIL_LOGGING_HAS_BEEN_INCLUDED diff --git a/openvdb/openvdb/version.h.in b/openvdb/openvdb/version.h.in index 54a7b3742d..1591071955 100644 --- a/openvdb/openvdb/version.h.in +++ b/openvdb/openvdb/version.h.in @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file openvdb/version.h /// @brief Library and file format version numbers @@ -175,10 +175,10 @@ // This can be suppressed by defining OPENVDB_USE_FUTURE_ABI_=ON. // Note that, whilst the VDB CMake does not allow this option to be hit, // it exists to propagate this message to downstream targets - #if OPENVDB_ABI_VERSION_NUMBER == 12 - #ifndef OPENVDB_USE_FUTURE_ABI_12 - PRAGMA(message("NOTE: ABI = 12 is still in active development and has not been finalized, " - "define OPENVDB_USE_FUTURE_ABI_11 to suppress this message")) + #if OPENVDB_ABI_VERSION_NUMBER == 13 + #ifndef OPENVDB_USE_FUTURE_ABI_13 + PRAGMA(message("NOTE: ABI = 13 is still in active development and has not been finalized, " + "define OPENVDB_USE_FUTURE_ABI_13 to suppress this message")) #endif #else #error expected OPENVDB_ABI_VERSION_NUMBER <= OPENVDB_LIBRARY_MAJOR_VERSION_NUMBER @@ -189,18 +189,18 @@ // directive. This can be suppressed by defining OPENVDB_USE_DEPRECATED_ABI_. // Note that, whilst the VDB CMake does not allow this option to be hit, // it exists to propagate this message to downstream targets -#ifndef OPENVDB_USE_DEPRECATED_ABI_9 - #if OPENVDB_ABI_VERSION_NUMBER == 9 - PRAGMA(message("NOTE: ABI = 9 is deprecated, define OPENVDB_USE_DEPRECATED_ABI_9 " - "to suppress this message")) - #endif -#endif #ifndef OPENVDB_USE_DEPRECATED_ABI_10 #if OPENVDB_ABI_VERSION_NUMBER == 10 PRAGMA(message("NOTE: ABI = 10 is deprecated, define OPENVDB_USE_DEPRECATED_ABI_10 " "to suppress this message")) #endif #endif +#ifndef OPENVDB_USE_DEPRECATED_ABI_11 + #if OPENVDB_ABI_VERSION_NUMBER == 11 + PRAGMA(message("NOTE: ABI = 11 is deprecated, define OPENVDB_USE_DEPRECATED_ABI_11 " + "to suppress this message")) + #endif +#endif /// By default, the @b OPENVDB_REQUIRE_VERSION_NAME macro is undefined, and /// symbols from the version namespace are promoted to the top-level namespace diff --git a/openvdb_ax/openvdb_ax/CMakeLists.txt b/openvdb_ax/openvdb_ax/CMakeLists.txt index f2e718683b..e0d95caeb7 100644 --- a/openvdb_ax/openvdb_ax/CMakeLists.txt +++ b/openvdb_ax/openvdb_ax/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) # There is a bug introduced with LLVM 14 config files which causes CMake to # complain if the project is not init-ted with LANGUAGES C @@ -354,23 +354,23 @@ if(OPENVDB_AX_SHARED) endif() endif() -install(FILES ax.h Exceptions.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/) -install(FILES ${OPENVDB_AX_AST_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/ast) -install(FILES ${OPENVDB_AX_CODEGEN_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/codegen) -install(FILES ${OPENVDB_AX_COMPILER_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax/compiler) +install(FILES ax.h Exceptions.h DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb_ax/) +install(FILES ${OPENVDB_AX_AST_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb_ax/ast) +install(FILES ${OPENVDB_AX_CODEGEN_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb_ax/codegen) +install(FILES ${OPENVDB_AX_COMPILER_INCLUDE_FILES} DESTINATION ${OPENVDB_INSTALL_INCLUDEDIR}/openvdb_ax/compiler) if(OPENVDB_AX_STATIC) install(TARGETS openvdb_ax_static - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR} + LIBRARY DESTINATION ${OPENVDB_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${OPENVDB_INSTALL_LIBDIR} ) endif() if(OPENVDB_AX_SHARED) install(TARGETS openvdb_ax_shared - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR} + LIBRARY DESTINATION ${OPENVDB_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${OPENVDB_INSTALL_LIBDIR} ) endif() diff --git a/openvdb_ax/openvdb_ax/Exceptions.h b/openvdb_ax/openvdb_ax/Exceptions.h index 91a2e1d328..36f505f91e 100644 --- a/openvdb_ax/openvdb_ax/Exceptions.h +++ b/openvdb_ax/openvdb_ax/Exceptions.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file openvdb_ax/Exceptions.h /// diff --git a/openvdb_ax/openvdb_ax/ast/AST.h b/openvdb_ax/openvdb_ax/ast/AST.h index c27adba5d9..8b0fe3435e 100644 --- a/openvdb_ax/openvdb_ax/ast/AST.h +++ b/openvdb_ax/openvdb_ax/ast/AST.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ast/AST.h /// @@ -276,7 +276,7 @@ struct Node /// @param parent The parent to set inline void setParent(Node* parent) { #ifndef NDEBUG - bool hasChild = false; + [[maybe_unused]] bool hasChild = false; for (size_t i = 0; i < parent->children(); ++i) hasChild |= parent->child(i) == this; OPENVDB_ASSERT(hasChild); diff --git a/openvdb_ax/openvdb_ax/ast/Parse.cc b/openvdb_ax/openvdb_ax/ast/Parse.cc index 23ad6c27ff..f1afacf028 100644 --- a/openvdb_ax/openvdb_ax/ast/Parse.cc +++ b/openvdb_ax/openvdb_ax/ast/Parse.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "Parse.h" #include "../Exceptions.h" diff --git a/openvdb_ax/openvdb_ax/ast/Parse.h b/openvdb_ax/openvdb_ax/ast/Parse.h index c2c39fb527..dc2178480a 100644 --- a/openvdb_ax/openvdb_ax/ast/Parse.h +++ b/openvdb_ax/openvdb_ax/ast/Parse.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ast/Parse.h /// diff --git a/openvdb_ax/openvdb_ax/ast/PrintTree.cc b/openvdb_ax/openvdb_ax/ast/PrintTree.cc index 27a65dcac6..91d5586b29 100644 --- a/openvdb_ax/openvdb_ax/ast/PrintTree.cc +++ b/openvdb_ax/openvdb_ax/ast/PrintTree.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ast/PrintTree.cc diff --git a/openvdb_ax/openvdb_ax/ast/PrintTree.h b/openvdb_ax/openvdb_ax/ast/PrintTree.h index 1baa8f54f0..f6107d531b 100644 --- a/openvdb_ax/openvdb_ax/ast/PrintTree.h +++ b/openvdb_ax/openvdb_ax/ast/PrintTree.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ast/PrintTree.h /// diff --git a/openvdb_ax/openvdb_ax/ast/Scanners.cc b/openvdb_ax/openvdb_ax/ast/Scanners.cc index a99b729743..96c52bacfe 100644 --- a/openvdb_ax/openvdb_ax/ast/Scanners.cc +++ b/openvdb_ax/openvdb_ax/ast/Scanners.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ast/Scanners.cc diff --git a/openvdb_ax/openvdb_ax/ast/Scanners.h b/openvdb_ax/openvdb_ax/ast/Scanners.h index 962ba19edf..73b07ab07d 100644 --- a/openvdb_ax/openvdb_ax/ast/Scanners.h +++ b/openvdb_ax/openvdb_ax/ast/Scanners.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ast/Scanners.h /// diff --git a/openvdb_ax/openvdb_ax/ast/Tokens.h b/openvdb_ax/openvdb_ax/ast/Tokens.h index 7df86629bc..776ff4acb8 100644 --- a/openvdb_ax/openvdb_ax/ast/Tokens.h +++ b/openvdb_ax/openvdb_ax/ast/Tokens.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ast/Tokens.h /// diff --git a/openvdb_ax/openvdb_ax/ast/Visitor.h b/openvdb_ax/openvdb_ax/ast/Visitor.h index 165f1b2c73..ab8cbc22aa 100644 --- a/openvdb_ax/openvdb_ax/ast/Visitor.h +++ b/openvdb_ax/openvdb_ax/ast/Visitor.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ast/Visitor.h /// diff --git a/openvdb_ax/openvdb_ax/ax.cc b/openvdb_ax/openvdb_ax/ax.cc index a4a6705a4f..561f73f53f 100644 --- a/openvdb_ax/openvdb_ax/ax.cc +++ b/openvdb_ax/openvdb_ax/ax.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "ax.h" #include "ast/AST.h" diff --git a/openvdb_ax/openvdb_ax/ax.h b/openvdb_ax/openvdb_ax/ax.h index 143b03f76c..3d86d36796 100644 --- a/openvdb_ax/openvdb_ax/ax.h +++ b/openvdb_ax/openvdb_ax/ax.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ax.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/Codecs.cc b/openvdb_ax/openvdb_ax/codegen/Codecs.cc index 36f94c4b6c..b56a0dfeda 100644 --- a/openvdb_ax/openvdb_ax/codegen/Codecs.cc +++ b/openvdb_ax/openvdb_ax/codegen/Codecs.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include // for native codec types #include diff --git a/openvdb_ax/openvdb_ax/codegen/Codecs.h b/openvdb_ax/openvdb_ax/codegen/Codecs.h index e7ed6b5fc7..99b9dbed53 100644 --- a/openvdb_ax/openvdb_ax/codegen/Codecs.h +++ b/openvdb_ax/openvdb_ax/codegen/Codecs.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_AX_CODEGEN_CODECS_HAS_BEEN_INCLUDED #define OPENVDB_AX_CODEGEN_CODECS_HAS_BEEN_INCLUDED @@ -51,7 +51,7 @@ class OPENVDB_AX_API Codec OPENVDB_ASSERT(!mEncoder->list().empty()); OPENVDB_ASSERT(!mDecoder->list().empty()); OPENVDB_ASSERT(mEncoder->list().size() == mDecoder->list().size()); - for (const auto& F : mEncoder->list()) { + for ([[maybe_unused]] const auto& F : mEncoder->list()) { OPENVDB_ASSERT(F->size() == 1 || F->size() == 2); } #endif diff --git a/openvdb_ax/openvdb_ax/codegen/ComputeGenerator.cc b/openvdb_ax/openvdb_ax/codegen/ComputeGenerator.cc index 8088767586..fe6851213d 100644 --- a/openvdb_ax/openvdb_ax/codegen/ComputeGenerator.cc +++ b/openvdb_ax/openvdb_ax/codegen/ComputeGenerator.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/ComputeGenerator.cc diff --git a/openvdb_ax/openvdb_ax/codegen/ComputeGenerator.h b/openvdb_ax/openvdb_ax/codegen/ComputeGenerator.h index 2bf4e2ae44..33783e8fc6 100644 --- a/openvdb_ax/openvdb_ax/codegen/ComputeGenerator.h +++ b/openvdb_ax/openvdb_ax/codegen/ComputeGenerator.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/ComputeGenerator.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/ConstantFolding.h b/openvdb_ax/openvdb_ax/codegen/ConstantFolding.h index f5af7560da..7775c8e763 100644 --- a/openvdb_ax/openvdb_ax/codegen/ConstantFolding.h +++ b/openvdb_ax/openvdb_ax/codegen/ConstantFolding.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/ConstantFolding.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/FunctionRegistry.cc b/openvdb_ax/openvdb_ax/codegen/FunctionRegistry.cc index ac446bd9fe..18230d9cba 100644 --- a/openvdb_ax/openvdb_ax/codegen/FunctionRegistry.cc +++ b/openvdb_ax/openvdb_ax/codegen/FunctionRegistry.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/FunctionRegistry.cc diff --git a/openvdb_ax/openvdb_ax/codegen/FunctionRegistry.h b/openvdb_ax/openvdb_ax/codegen/FunctionRegistry.h index 9a5687c8ec..617f73f6f7 100644 --- a/openvdb_ax/openvdb_ax/codegen/FunctionRegistry.h +++ b/openvdb_ax/openvdb_ax/codegen/FunctionRegistry.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/FunctionRegistry.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/FunctionTypes.cc b/openvdb_ax/openvdb_ax/codegen/FunctionTypes.cc index 4ce9f27e4d..c7673ba8bf 100644 --- a/openvdb_ax/openvdb_ax/codegen/FunctionTypes.cc +++ b/openvdb_ax/openvdb_ax/codegen/FunctionTypes.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/FunctionTypes.cc @@ -426,7 +426,7 @@ FunctionGroup::execute(const std::vector& args, #ifndef NDEBUG std::vector unused; - llvm::Type* ret = target->types(unused, B.getContext()); + [[maybe_unused]] llvm::Type* ret = target->types(unused, B.getContext()); OPENVDB_ASSERT(result || ret->isVoidTy()); #endif return result; @@ -448,7 +448,7 @@ FunctionGroup::execute(const std::vector& args, #ifndef NDEBUG std::vector unused; - llvm::Type* ret = target->types(unused, B.getContext()); + [[maybe_unused]] llvm::Type* ret = target->types(unused, B.getContext()); OPENVDB_ASSERT(result || ret->isVoidTy()); #endif diff --git a/openvdb_ax/openvdb_ax/codegen/FunctionTypes.h b/openvdb_ax/openvdb_ax/codegen/FunctionTypes.h index aa8a5a7f61..4eaf8f1c44 100644 --- a/openvdb_ax/openvdb_ax/codegen/FunctionTypes.h +++ b/openvdb_ax/openvdb_ax/codegen/FunctionTypes.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/FunctionTypes.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/Functions.h b/openvdb_ax/openvdb_ax/codegen/Functions.h index 5b525235f4..cbcd754ffc 100644 --- a/openvdb_ax/openvdb_ax/codegen/Functions.h +++ b/openvdb_ax/openvdb_ax/codegen/Functions.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/Functions.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/PointComputeGenerator.cc b/openvdb_ax/openvdb_ax/codegen/PointComputeGenerator.cc index 87e07f983b..09f35c13ed 100644 --- a/openvdb_ax/openvdb_ax/codegen/PointComputeGenerator.cc +++ b/openvdb_ax/openvdb_ax/codegen/PointComputeGenerator.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/PointComputeGenerator.cc diff --git a/openvdb_ax/openvdb_ax/codegen/PointComputeGenerator.h b/openvdb_ax/openvdb_ax/codegen/PointComputeGenerator.h index 519c711ec0..8e742a83a3 100644 --- a/openvdb_ax/openvdb_ax/codegen/PointComputeGenerator.h +++ b/openvdb_ax/openvdb_ax/codegen/PointComputeGenerator.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/PointComputeGenerator.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/PointFunctions.cc b/openvdb_ax/openvdb_ax/codegen/PointFunctions.cc index a19af9d491..87840c2ee5 100644 --- a/openvdb_ax/openvdb_ax/codegen/PointFunctions.cc +++ b/openvdb_ax/openvdb_ax/codegen/PointFunctions.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/PointFunctions.cc /// diff --git a/openvdb_ax/openvdb_ax/codegen/PointLeafLocalData.h b/openvdb_ax/openvdb_ax/codegen/PointLeafLocalData.h index 573916805c..bd1a46854b 100644 --- a/openvdb_ax/openvdb_ax/codegen/PointLeafLocalData.h +++ b/openvdb_ax/openvdb_ax/codegen/PointLeafLocalData.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/PointLeafLocalData.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/StandardFunctions.cc b/openvdb_ax/openvdb_ax/codegen/StandardFunctions.cc index df9504a485..54bb07c49b 100644 --- a/openvdb_ax/openvdb_ax/codegen/StandardFunctions.cc +++ b/openvdb_ax/openvdb_ax/codegen/StandardFunctions.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/StandardFunctions.cc /// diff --git a/openvdb_ax/openvdb_ax/codegen/String.h b/openvdb_ax/openvdb_ax/codegen/String.h index 65546fd860..52553a04a7 100644 --- a/openvdb_ax/openvdb_ax/codegen/String.h +++ b/openvdb_ax/openvdb_ax/codegen/String.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/String.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/StringFunctions.cc b/openvdb_ax/openvdb_ax/codegen/StringFunctions.cc index afeceee0c3..ddf501c9d5 100644 --- a/openvdb_ax/openvdb_ax/codegen/StringFunctions.cc +++ b/openvdb_ax/openvdb_ax/codegen/StringFunctions.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/StringFunctions.cc /// diff --git a/openvdb_ax/openvdb_ax/codegen/SymbolTable.h b/openvdb_ax/openvdb_ax/codegen/SymbolTable.h index e03d885ef5..ca5e071b82 100644 --- a/openvdb_ax/openvdb_ax/codegen/SymbolTable.h +++ b/openvdb_ax/openvdb_ax/codegen/SymbolTable.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/SymbolTable.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/Types.cc b/openvdb_ax/openvdb_ax/codegen/Types.cc index a5ade76aaf..36c7edf4bd 100644 --- a/openvdb_ax/openvdb_ax/codegen/Types.cc +++ b/openvdb_ax/openvdb_ax/codegen/Types.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/Types.cc /// diff --git a/openvdb_ax/openvdb_ax/codegen/Types.h b/openvdb_ax/openvdb_ax/codegen/Types.h index fb07126234..11c06341b1 100644 --- a/openvdb_ax/openvdb_ax/codegen/Types.h +++ b/openvdb_ax/openvdb_ax/codegen/Types.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/Types.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/Utils.h b/openvdb_ax/openvdb_ax/codegen/Utils.h index 7f62d50eac..cfb7050008 100644 --- a/openvdb_ax/openvdb_ax/codegen/Utils.h +++ b/openvdb_ax/openvdb_ax/codegen/Utils.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/Utils.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/VolumeComputeGenerator.cc b/openvdb_ax/openvdb_ax/codegen/VolumeComputeGenerator.cc index 3579ac5e13..76909d5bc6 100644 --- a/openvdb_ax/openvdb_ax/codegen/VolumeComputeGenerator.cc +++ b/openvdb_ax/openvdb_ax/codegen/VolumeComputeGenerator.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/VolumeComputeGenerator.cc diff --git a/openvdb_ax/openvdb_ax/codegen/VolumeComputeGenerator.h b/openvdb_ax/openvdb_ax/codegen/VolumeComputeGenerator.h index 8c0db06e05..38e9060d70 100644 --- a/openvdb_ax/openvdb_ax/codegen/VolumeComputeGenerator.h +++ b/openvdb_ax/openvdb_ax/codegen/VolumeComputeGenerator.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/VolumeComputeGenerator.h /// diff --git a/openvdb_ax/openvdb_ax/codegen/VolumeFunctions.cc b/openvdb_ax/openvdb_ax/codegen/VolumeFunctions.cc index 26a7683be9..c73370b643 100644 --- a/openvdb_ax/openvdb_ax/codegen/VolumeFunctions.cc +++ b/openvdb_ax/openvdb_ax/codegen/VolumeFunctions.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file codegen/VolumeFunctions.cc /// diff --git a/openvdb_ax/openvdb_ax/compiler/AttributeBindings.h b/openvdb_ax/openvdb_ax/compiler/AttributeBindings.h index 45379b2114..ebd7bba23b 100644 --- a/openvdb_ax/openvdb_ax/compiler/AttributeBindings.h +++ b/openvdb_ax/openvdb_ax/compiler/AttributeBindings.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0/ +// SPDX-License-Identifier: Apache-2.0/ /// @file compiler/AttributeBindings.h /// diff --git a/openvdb_ax/openvdb_ax/compiler/AttributeRegistry.h b/openvdb_ax/openvdb_ax/compiler/AttributeRegistry.h index d5aab1f48b..6f40790d2d 100644 --- a/openvdb_ax/openvdb_ax/compiler/AttributeRegistry.h +++ b/openvdb_ax/openvdb_ax/compiler/AttributeRegistry.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0/ +// SPDX-License-Identifier: Apache-2.0/ /// @file compiler/AttributeRegistry.h /// diff --git a/openvdb_ax/openvdb_ax/compiler/Compiler.cc b/openvdb_ax/openvdb_ax/compiler/Compiler.cc index 2e171710ce..13ba59339f 100644 --- a/openvdb_ax/openvdb_ax/compiler/Compiler.cc +++ b/openvdb_ax/openvdb_ax/compiler/Compiler.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file compiler/Compiler.cc @@ -449,7 +449,7 @@ bool initializeGlobalFunctions(const codegen::FunctionRegistry& registry, if (!F.getName().startswith("ax.")) continue; const std::string mangled = getMangledName(llvm::cast(&F), engine); - const uint64_t address = + [[maybe_unused]] const uint64_t address = engine.getAddressToGlobalIfAvailable(mangled); OPENVDB_ASSERT(address != 0 && "Unbound function!"); } diff --git a/openvdb_ax/openvdb_ax/compiler/Compiler.h b/openvdb_ax/openvdb_ax/compiler/Compiler.h index 3f522278c8..3f450c0c92 100644 --- a/openvdb_ax/openvdb_ax/compiler/Compiler.h +++ b/openvdb_ax/openvdb_ax/compiler/Compiler.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file compiler/Compiler.h /// diff --git a/openvdb_ax/openvdb_ax/compiler/CompilerOptions.h b/openvdb_ax/openvdb_ax/compiler/CompilerOptions.h index 4501f9cf95..685d5e4e94 100644 --- a/openvdb_ax/openvdb_ax/compiler/CompilerOptions.h +++ b/openvdb_ax/openvdb_ax/compiler/CompilerOptions.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file compiler/CompilerOptions.h /// diff --git a/openvdb_ax/openvdb_ax/compiler/CustomData.h b/openvdb_ax/openvdb_ax/compiler/CustomData.h index d9e5fb7e2a..4c5f92de60 100644 --- a/openvdb_ax/openvdb_ax/compiler/CustomData.h +++ b/openvdb_ax/openvdb_ax/compiler/CustomData.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file compiler/CustomData.h /// diff --git a/openvdb_ax/openvdb_ax/compiler/Logger.cc b/openvdb_ax/openvdb_ax/compiler/Logger.cc index 7b4c448797..810db55b43 100644 --- a/openvdb_ax/openvdb_ax/compiler/Logger.cc +++ b/openvdb_ax/openvdb_ax/compiler/Logger.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file compiler/Logger.cc diff --git a/openvdb_ax/openvdb_ax/compiler/Logger.h b/openvdb_ax/openvdb_ax/compiler/Logger.h index 850d8b45e1..5e4d89224e 100644 --- a/openvdb_ax/openvdb_ax/compiler/Logger.h +++ b/openvdb_ax/openvdb_ax/compiler/Logger.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file compiler/Logger.h /// diff --git a/openvdb_ax/openvdb_ax/compiler/PointExecutable.cc b/openvdb_ax/openvdb_ax/compiler/PointExecutable.cc index b137f667a7..2f5722c135 100644 --- a/openvdb_ax/openvdb_ax/compiler/PointExecutable.cc +++ b/openvdb_ax/openvdb_ax/compiler/PointExecutable.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file compiler/PointExecutable.cc @@ -159,7 +159,7 @@ using KernelBufferRangeFunctionPtr = std::add_pointer #include diff --git a/openvdb_ax/openvdb_ax/test/ast/TestScanners.cc b/openvdb_ax/openvdb_ax/test/ast/TestScanners.cc index 5381af88fe..8b98f93b39 100644 --- a/openvdb_ax/openvdb_ax/test/ast/TestScanners.cc +++ b/openvdb_ax/openvdb_ax/test/ast/TestScanners.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "../util.h" diff --git a/openvdb_ax/openvdb_ax/test/backend/TestAttributeBindings.cc b/openvdb_ax/openvdb_ax/test/backend/TestAttributeBindings.cc index e0adf0a1ce..99906db669 100644 --- a/openvdb_ax/openvdb_ax/test/backend/TestAttributeBindings.cc +++ b/openvdb_ax/openvdb_ax/test/backend/TestAttributeBindings.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "util.h" diff --git a/openvdb_ax/openvdb_ax/test/backend/TestCodecs.cc b/openvdb_ax/openvdb_ax/test/backend/TestCodecs.cc index 6ee11452ad..d65593a453 100644 --- a/openvdb_ax/openvdb_ax/test/backend/TestCodecs.cc +++ b/openvdb_ax/openvdb_ax/test/backend/TestCodecs.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "util.h" diff --git a/openvdb_ax/openvdb_ax/test/backend/TestComputeGeneratorFailures.cc b/openvdb_ax/openvdb_ax/test/backend/TestComputeGeneratorFailures.cc index 55a01d066d..fb4c1ca2ee 100644 --- a/openvdb_ax/openvdb_ax/test/backend/TestComputeGeneratorFailures.cc +++ b/openvdb_ax/openvdb_ax/test/backend/TestComputeGeneratorFailures.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "util.h" #include "../util.h" diff --git a/openvdb_ax/openvdb_ax/test/backend/TestFunctionGroup.cc b/openvdb_ax/openvdb_ax/test/backend/TestFunctionGroup.cc index d76bc7f552..d8feb7a07c 100644 --- a/openvdb_ax/openvdb_ax/test/backend/TestFunctionGroup.cc +++ b/openvdb_ax/openvdb_ax/test/backend/TestFunctionGroup.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "util.h" diff --git a/openvdb_ax/openvdb_ax/test/backend/TestFunctionRegistry.cc b/openvdb_ax/openvdb_ax/test/backend/TestFunctionRegistry.cc index 3c1f64bcdd..8db4845cee 100644 --- a/openvdb_ax/openvdb_ax/test/backend/TestFunctionRegistry.cc +++ b/openvdb_ax/openvdb_ax/test/backend/TestFunctionRegistry.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include diff --git a/openvdb_ax/openvdb_ax/test/backend/TestFunctionTypes.cc b/openvdb_ax/openvdb_ax/test/backend/TestFunctionTypes.cc index 2b155af4be..4e3289ffbf 100644 --- a/openvdb_ax/openvdb_ax/test/backend/TestFunctionTypes.cc +++ b/openvdb_ax/openvdb_ax/test/backend/TestFunctionTypes.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "util.h" diff --git a/openvdb_ax/openvdb_ax/test/backend/TestLogger.cc b/openvdb_ax/openvdb_ax/test/backend/TestLogger.cc index c58a670c5f..12f0b4d37c 100644 --- a/openvdb_ax/openvdb_ax/test/backend/TestLogger.cc +++ b/openvdb_ax/openvdb_ax/test/backend/TestLogger.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "util.h" diff --git a/openvdb_ax/openvdb_ax/test/backend/TestStringIR.cc b/openvdb_ax/openvdb_ax/test/backend/TestStringIR.cc index 78f29628e3..fe5dde8726 100644 --- a/openvdb_ax/openvdb_ax/test/backend/TestStringIR.cc +++ b/openvdb_ax/openvdb_ax/test/backend/TestStringIR.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "util.h" @@ -289,10 +289,8 @@ TestStringIR::testStringStringIR() { static auto setInvalidString = [](String& S) { #if defined(__GNUC__) && !defined(__clang__) -#if OPENVDB_CHECK_GCC(8, 0) _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wclass-memaccess\"") -#endif #endif // zero out the data held by a String object (expected to not hold heap memory). // This is used to test the IR methods work as expected with the allocated, but @@ -300,9 +298,7 @@ TestStringIR::testStringStringIR() OPENVDB_ASSERT(S.isLocal()); std::memset(&S, 0, sizeof(String)); // uninit string, invalid class memory #if defined(__GNUC__) && !defined(__clang__) -#if OPENVDB_CHECK_GCC(8, 0) _Pragma("GCC diagnostic pop") -#endif #endif }; diff --git a/openvdb_ax/openvdb_ax/test/backend/TestSymbolTable.cc b/openvdb_ax/openvdb_ax/test/backend/TestSymbolTable.cc index 062fe89937..eb074c0b5f 100644 --- a/openvdb_ax/openvdb_ax/test/backend/TestSymbolTable.cc +++ b/openvdb_ax/openvdb_ax/test/backend/TestSymbolTable.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "util.h" diff --git a/openvdb_ax/openvdb_ax/test/backend/TestTypes.cc b/openvdb_ax/openvdb_ax/test/backend/TestTypes.cc index c37217d66d..9f7f7f2a7a 100644 --- a/openvdb_ax/openvdb_ax/test/backend/TestTypes.cc +++ b/openvdb_ax/openvdb_ax/test/backend/TestTypes.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "util.h" diff --git a/openvdb_ax/openvdb_ax/test/backend/util.h b/openvdb_ax/openvdb_ax/test/backend/util.h index da2225af17..040ea01c70 100644 --- a/openvdb_ax/openvdb_ax/test/backend/util.h +++ b/openvdb_ax/openvdb_ax/test/backend/util.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDB_AX_UNITTEST_BACKEND_UTIL_HAS_BEEN_INCLUDED #define OPENVDB_AX_UNITTEST_BACKEND_UTIL_HAS_BEEN_INCLUDED diff --git a/openvdb_ax/openvdb_ax/test/compiler/TestAXRun.cc b/openvdb_ax/openvdb_ax/test/compiler/TestAXRun.cc index 90c666e9e6..9ee04489ab 100644 --- a/openvdb_ax/openvdb_ax/test/compiler/TestAXRun.cc +++ b/openvdb_ax/openvdb_ax/test/compiler/TestAXRun.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/compiler/TestPointExecutable.cc b/openvdb_ax/openvdb_ax/test/compiler/TestPointExecutable.cc index 6ad0d932ba..a619856140 100644 --- a/openvdb_ax/openvdb_ax/test/compiler/TestPointExecutable.cc +++ b/openvdb_ax/openvdb_ax/test/compiler/TestPointExecutable.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -20,6 +20,12 @@ class TestPointExecutable : public CppUnit::TestCase { public: +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + using LeafIndexType = openvdb::Index64; +#else + using LeafIndexType = openvdb::Index32; +#endif + CPPUNIT_TEST_SUITE(TestPointExecutable); CPPUNIT_TEST(testConstructionDestruction); CPPUNIT_TEST(testCreateMissingAttributes); @@ -545,7 +551,7 @@ TestPointExecutable::testAttributeCodecs() points = points::createPointDataGrid (twoPoints, *defaultTransform); - CPPUNIT_ASSERT_EQUAL(points->tree().leafCount(), Index32(1)); + CPPUNIT_ASSERT_EQUAL(points->tree().leafCount(), LeafIndexType(1)); // collapsed uniform 0 attributes points::appendAttribute(points->tree(), "f"); @@ -641,7 +647,7 @@ TestPointExecutable::testAttributeCodecs() points = points::createPointDataGrid (twoPoints, *defaultTransform); - CPPUNIT_ASSERT_EQUAL(points->tree().leafCount(), Index32(1)); + CPPUNIT_ASSERT_EQUAL(points->tree().leafCount(), LeafIndexType(1)); // collapsed uniform 0 attributes points::appendAttribute>(points->tree(), "fpu8"); @@ -728,7 +734,7 @@ TestPointExecutable::testAttributeCodecs() points = points::createPointDataGrid , points::PointDataGrid> (twoPoints, *defaultTransform); - CPPUNIT_ASSERT_EQUAL(points->tree().leafCount(), Index32(1)); + CPPUNIT_ASSERT_EQUAL(points->tree().leafCount(), LeafIndexType(1)); points::appendAttribute(points->tree(), "t"); points::appendAttribute>(points->tree(), "f"); diff --git a/openvdb_ax/openvdb_ax/test/compiler/TestVolumeExecutable.cc b/openvdb_ax/openvdb_ax/test/compiler/TestVolumeExecutable.cc index 87faf11228..f0b9eeef8f 100644 --- a/openvdb_ax/openvdb_ax/test/compiler/TestVolumeExecutable.cc +++ b/openvdb_ax/openvdb_ax/test/compiler/TestVolumeExecutable.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -13,6 +13,12 @@ class TestVolumeExecutable : public CppUnit::TestCase { public: +#if OPENVDB_ABI_VERSION_NUMBER >= 12 + using LeafIndexType = openvdb::Index64; +#else + using LeafIndexType = openvdb::Index32; +#endif + CPPUNIT_TEST_SUITE(TestVolumeExecutable); CPPUNIT_TEST(testConstructionDestruction); CPPUNIT_TEST(testCreateMissingGrids); @@ -155,7 +161,7 @@ TestVolumeExecutable::testTreeExecutionLevel() const openvdb::FloatTree copy = tree; // check config auto CHECK_CONFIG = [&]() { - CPPUNIT_ASSERT_EQUAL(openvdb::Index32(1), tree.leafCount()); + CPPUNIT_ASSERT_EQUAL(LeafIndexType(1), tree.leafCount()); CPPUNIT_ASSERT_EQUAL(openvdb::Index64(3), tree.activeTileCount()); CPPUNIT_ASSERT_EQUAL(int(openvdb::FloatTree::DEPTH-4), tree.getValueDepth(openvdb::Coord(0))); CPPUNIT_ASSERT_EQUAL(int(openvdb::FloatTree::DEPTH-3), tree.getValueDepth(openvdb::Coord(NodeT2::DIM))); @@ -357,7 +363,7 @@ TestVolumeExecutable::testActiveTileStreaming() CPPUNIT_ASSERT_EQUAL(openvdb::Index(openvdb::FloatTree::DEPTH-1), max); executable->execute(grid); - CPPUNIT_ASSERT_EQUAL(openvdb::Index32(1), tree.leafCount()); + CPPUNIT_ASSERT_EQUAL(LeafIndexType(1), tree.leafCount()); CPPUNIT_ASSERT_EQUAL(openvdb::Index64(3), tree.activeTileCount()); CPPUNIT_ASSERT_EQUAL(int(openvdb::FloatTree::DEPTH-4), tree.getValueDepth(openvdb::Coord(0))); CPPUNIT_ASSERT_EQUAL(int(openvdb::FloatTree::DEPTH-3), tree.getValueDepth(openvdb::Coord(NodeT2::DIM))); @@ -404,7 +410,7 @@ TestVolumeExecutable::testActiveTileStreaming() openvdb::Index64(NodeT1::NUM_VOXELS) + openvdb::Index64(NodeT0::NUM_VOXELS); - CPPUNIT_ASSERT_EQUAL(openvdb::Index32(voxels / openvdb::FloatTree::LeafNodeType::NUM_VOXELS), tree.leafCount()); + CPPUNIT_ASSERT_EQUAL(LeafIndexType(voxels / openvdb::FloatTree::LeafNodeType::NUM_VOXELS), tree.leafCount()); CPPUNIT_ASSERT_EQUAL(openvdb::Index64(0), tree.activeTileCount()); CPPUNIT_ASSERT_EQUAL(int(openvdb::FloatTree::DEPTH-1), tree.getValueDepth(openvdb::Coord(0))); CPPUNIT_ASSERT_EQUAL(int(openvdb::FloatTree::DEPTH-1), tree.getValueDepth(openvdb::Coord(NodeT1::DIM))); @@ -463,7 +469,7 @@ TestVolumeExecutable::testActiveTileStreaming() ((n1ChildCount * (n2ChildAxisCount * n2ChildAxisCount)) - leafs) // NodeT1 face tiles (NodeT0) - leafs + 1 /*NodeT1*/ + 1 /*NodeT0*/; - CPPUNIT_ASSERT_EQUAL(openvdb::Index32(leafs), tree.leafCount()); + CPPUNIT_ASSERT_EQUAL(LeafIndexType(leafs), tree.leafCount()); CPPUNIT_ASSERT_EQUAL(openvdb::Index64(tiles), tree.activeTileCount()); CPPUNIT_ASSERT_EQUAL(int(openvdb::FloatTree::DEPTH-3), tree.getValueDepth(openvdb::Coord(NodeT2::DIM))); CPPUNIT_ASSERT_EQUAL(int(openvdb::FloatTree::DEPTH-2), tree.getValueDepth(openvdb::Coord(NodeT2::DIM+NodeT1::DIM))); @@ -512,7 +518,7 @@ TestVolumeExecutable::testActiveTileStreaming() executable->execute(grid); - CPPUNIT_ASSERT_EQUAL(openvdb::Index32(0), tree.leafCount()); + CPPUNIT_ASSERT_EQUAL(LeafIndexType(0), tree.leafCount()); CPPUNIT_ASSERT_EQUAL(openvdb::Index64(5), tree.activeTileCount()); CPPUNIT_ASSERT_EQUAL(int(openvdb::FloatTree::DEPTH-3), tree.getValueDepth(openvdb::Coord(NodeT1::DIM*0, 0, 0))); CPPUNIT_ASSERT_EQUAL(int(openvdb::FloatTree::DEPTH-3), tree.getValueDepth(openvdb::Coord(NodeT1::DIM*1, 0, 0))); @@ -567,7 +573,7 @@ TestVolumeExecutable::testActiveTileStreaming() (n1ChildCount - leafs) // NodeT1 face tiles (NodeT0) - leafs + 3 /*NodeT1*/ + 1 /*NodeT0*/; - CPPUNIT_ASSERT_EQUAL(openvdb::Index32(leafs), tree.leafCount()); + CPPUNIT_ASSERT_EQUAL(LeafIndexType(leafs), tree.leafCount()); CPPUNIT_ASSERT_EQUAL(openvdb::Index64(tiles), tree.activeTileCount()); CPPUNIT_ASSERT_EQUAL(int(openvdb::BoolTree::DEPTH-3), tree.getValueDepth(openvdb::Coord(NodeT1::DIM*1, 0, 0))); CPPUNIT_ASSERT_EQUAL(int(openvdb::BoolTree::DEPTH-3), tree.getValueDepth(openvdb::Coord(NodeT1::DIM*2, 0, 0))); @@ -624,7 +630,7 @@ TestVolumeExecutable::testActiveTileStreaming() (n1ChildCount - leafs) // NodeT1 face tiles (NodeT0) - leafs + 3 /*NodeT1*/ + 1 /*NodeT0*/; - CPPUNIT_ASSERT_EQUAL(openvdb::Index32(leafs), tree.leafCount()); + CPPUNIT_ASSERT_EQUAL(LeafIndexType(leafs), tree.leafCount()); CPPUNIT_ASSERT_EQUAL(openvdb::Index64(tiles), tree.activeTileCount()); CPPUNIT_ASSERT_EQUAL(int(StringTree::DEPTH-3), tree.getValueDepth(openvdb::Coord(NodeT1::DIM*1, 0, 0))); CPPUNIT_ASSERT_EQUAL(int(StringTree::DEPTH-3), tree.getValueDepth(openvdb::Coord(NodeT1::DIM*2, 0, 0))); @@ -668,7 +674,7 @@ TestVolumeExecutable::testActiveTileStreaming() executable->execute(grid); - CPPUNIT_ASSERT_EQUAL(openvdb::Index32(1), tree.leafCount()); + CPPUNIT_ASSERT_EQUAL(LeafIndexType(1), tree.leafCount()); CPPUNIT_ASSERT_EQUAL(openvdb::Index64(2), tree.activeTileCount()); CPPUNIT_ASSERT(tree.hasSameTopology(copy)); CPPUNIT_ASSERT_EQUAL(int(openvdb::FloatTree::DEPTH-3), tree.getValueDepth(openvdb::Coord(0))); @@ -715,7 +721,7 @@ TestVolumeExecutable::testActiveTileStreaming() openvdb::Index64(NodeT1::NUM_VOXELS) + openvdb::Index64(NodeT0::NUM_VOXELS); - CPPUNIT_ASSERT_EQUAL(openvdb::Index32(voxels / openvdb::FloatTree::LeafNodeType::NUM_VOXELS) + 1, tree.leafCount()); + CPPUNIT_ASSERT_EQUAL(LeafIndexType(voxels / openvdb::FloatTree::LeafNodeType::NUM_VOXELS) + 1, tree.leafCount()); CPPUNIT_ASSERT_EQUAL(openvdb::Index64(0), tree.activeTileCount()); CPPUNIT_ASSERT_EQUAL(voxels, tree.activeVoxelCount()); CPPUNIT_ASSERT_EQUAL(leaf, tree.probeLeaf(openvdb::Coord(NodeT1::DIM + NodeT0::DIM))); diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestArrayPack.cc b/openvdb_ax/openvdb_ax/test/frontend/TestArrayPack.cc index 51adcf113c..e04ce6fb8b 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestArrayPack.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestArrayPack.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestArrayUnpackNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestArrayUnpackNode.cc index dcc4a60661..6c0b60a3df 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestArrayUnpackNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestArrayUnpackNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestAssignExpressionNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestAssignExpressionNode.cc index b6ab887619..0fb4a69c3a 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestAssignExpressionNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestAssignExpressionNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestAttributeNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestAttributeNode.cc index 5e4e06b233..e9d8ea1529 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestAttributeNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestAttributeNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestBinaryOperatorNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestBinaryOperatorNode.cc index 15a904df83..4eba2c49b6 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestBinaryOperatorNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestBinaryOperatorNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestCastNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestCastNode.cc index 37b9438fbe..b350115486 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestCastNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestCastNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestCommaOperator.cc b/openvdb_ax/openvdb_ax/test/frontend/TestCommaOperator.cc index 6c56b59f17..3816285e98 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestCommaOperator.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestCommaOperator.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestConditionalStatementNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestConditionalStatementNode.cc index 7f0d4149cf..d7edbd100a 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestConditionalStatementNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestConditionalStatementNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestCrementNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestCrementNode.cc index 9c8903feef..86c8475095 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestCrementNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestCrementNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestDeclareLocalNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestDeclareLocalNode.cc index 73b91f732e..4af5bd053a 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestDeclareLocalNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestDeclareLocalNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestExternalVariableNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestExternalVariableNode.cc index 5776fa0094..f543f4f7a1 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestExternalVariableNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestExternalVariableNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestFunctionCallNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestFunctionCallNode.cc index 0a08083c29..3416bb4ccc 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestFunctionCallNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestFunctionCallNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestKeywordNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestKeywordNode.cc index 8834282233..3326918647 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestKeywordNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestKeywordNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestLocalNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestLocalNode.cc index 3cf6bd2a6e..3b6298858c 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestLocalNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestLocalNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestLoopNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestLoopNode.cc index 7a10818527..ee689ab55f 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestLoopNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestLoopNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestStatementListNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestStatementListNode.cc index ee8a47af31..1d5bfacd66 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestStatementListNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestStatementListNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestSyntaxFailures.cc b/openvdb_ax/openvdb_ax/test/frontend/TestSyntaxFailures.cc index 6179df57f1..3f639bf2a6 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestSyntaxFailures.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestSyntaxFailures.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestTernaryOperatorNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestTernaryOperatorNode.cc index 641c4f9549..ff7d1783a4 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestTernaryOperatorNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestTernaryOperatorNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestUnaryOperatorNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestUnaryOperatorNode.cc index 7c8999fbc6..1c0e1163f7 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestUnaryOperatorNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestUnaryOperatorNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/frontend/TestValueNode.cc b/openvdb_ax/openvdb_ax/test/frontend/TestValueNode.cc index 3c7597ea14..3df8d9e18b 100644 --- a/openvdb_ax/openvdb_ax/test/frontend/TestValueNode.cc +++ b/openvdb_ax/openvdb_ax/test/frontend/TestValueNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_ax/openvdb_ax/test/integration/CompareGrids.cc b/openvdb_ax/openvdb_ax/test/integration/CompareGrids.cc index 9333716df6..a3e1388587 100644 --- a/openvdb_ax/openvdb_ax/test/integration/CompareGrids.cc +++ b/openvdb_ax/openvdb_ax/test/integration/CompareGrids.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file test/integration/CompareGrids.cc diff --git a/openvdb_ax/openvdb_ax/test/integration/CompareGrids.h b/openvdb_ax/openvdb_ax/test/integration/CompareGrids.h index e9acdac426..d5a11436ba 100644 --- a/openvdb_ax/openvdb_ax/test/integration/CompareGrids.h +++ b/openvdb_ax/openvdb_ax/test/integration/CompareGrids.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file test/integration/CompareGrids.h /// diff --git a/openvdb_ax/openvdb_ax/test/integration/TestArrayUnpack.cc b/openvdb_ax/openvdb_ax/test/integration/TestArrayUnpack.cc index 71c1b00509..41e71ebfb1 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestArrayUnpack.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestArrayUnpack.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "CompareGrids.h" #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestAssign.cc b/openvdb_ax/openvdb_ax/test/integration/TestAssign.cc index 1f5aed6eda..a68c82aae3 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestAssign.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestAssign.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "CompareGrids.h" #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestBinary.cc b/openvdb_ax/openvdb_ax/test/integration/TestBinary.cc index 483af60e30..0b5359e840 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestBinary.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestBinary.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestCast.cc b/openvdb_ax/openvdb_ax/test/integration/TestCast.cc index 237a1102cf..843db3b779 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestCast.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestCast.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestConditional.cc b/openvdb_ax/openvdb_ax/test/integration/TestConditional.cc index c3f261ec7e..63d75d8d93 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestConditional.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestConditional.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestCrement.cc b/openvdb_ax/openvdb_ax/test/integration/TestCrement.cc index 273e580291..4ccfc164ec 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestCrement.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestCrement.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "CompareGrids.h" #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestDeclare.cc b/openvdb_ax/openvdb_ax/test/integration/TestDeclare.cc index 100d19c7f4..bfab389e70 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestDeclare.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestDeclare.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestEmpty.cc b/openvdb_ax/openvdb_ax/test/integration/TestEmpty.cc index 45db3bfb0c..fe71e55756 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestEmpty.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestEmpty.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestExternals.cc b/openvdb_ax/openvdb_ax/test/integration/TestExternals.cc index d97b9fc983..207884f1ad 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestExternals.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestExternals.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "CompareGrids.h" #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestHarness.cc b/openvdb_ax/openvdb_ax/test/integration/TestHarness.cc index acbc852da2..2114bbe071 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestHarness.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestHarness.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" #include "../util.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestHarness.h b/openvdb_ax/openvdb_ax/test/integration/TestHarness.h index ebdcf10a10..dc707b879e 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestHarness.h +++ b/openvdb_ax/openvdb_ax/test/integration/TestHarness.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file test/integration/TestHarness.h /// diff --git a/openvdb_ax/openvdb_ax/test/integration/TestKeyword.cc b/openvdb_ax/openvdb_ax/test/integration/TestKeyword.cc index 6eabe623b6..a323e0f0b1 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestKeyword.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestKeyword.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestLoop.cc b/openvdb_ax/openvdb_ax/test/integration/TestLoop.cc index 6b53b50f71..9a0bec8cc1 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestLoop.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestLoop.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestStandardFunctions.cc b/openvdb_ax/openvdb_ax/test/integration/TestStandardFunctions.cc index 65cf0dc93b..d11da8cab1 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestStandardFunctions.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestStandardFunctions.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestString.cc b/openvdb_ax/openvdb_ax/test/integration/TestString.cc index 3cb32509f2..b2cafdbea3 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestString.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestString.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestTernary.cc b/openvdb_ax/openvdb_ax/test/integration/TestTernary.cc index 334f755f91..1099f96272 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestTernary.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestTernary.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestUnary.cc b/openvdb_ax/openvdb_ax/test/integration/TestUnary.cc index aa34c1063f..462723aff3 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestUnary.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestUnary.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" #include "../util.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestVDBFunctions.cc b/openvdb_ax/openvdb_ax/test/integration/TestVDBFunctions.cc index 723bb837fb..bcd84106da 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestVDBFunctions.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestVDBFunctions.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" #include "../util.h" diff --git a/openvdb_ax/openvdb_ax/test/integration/TestWorldSpaceAccessors.cc b/openvdb_ax/openvdb_ax/test/integration/TestWorldSpaceAccessors.cc index 1565cc6e19..9341666083 100644 --- a/openvdb_ax/openvdb_ax/test/integration/TestWorldSpaceAccessors.cc +++ b/openvdb_ax/openvdb_ax/test/integration/TestWorldSpaceAccessors.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "TestHarness.h" diff --git a/openvdb_ax/openvdb_ax/test/main.cc b/openvdb_ax/openvdb_ax/test/main.cc index 12670ebbd6..d777907976 100644 --- a/openvdb_ax/openvdb_ax/test/main.cc +++ b/openvdb_ax/openvdb_ax/test/main.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include diff --git a/openvdb_ax/openvdb_ax/test/util.h b/openvdb_ax/openvdb_ax/test/util.h index 0494944460..6cb627be39 100644 --- a/openvdb_ax/openvdb_ax/test/util.h +++ b/openvdb_ax/openvdb_ax/test/util.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file test/util.h /// diff --git a/openvdb_ax/openvdb_ax/util/x86.cc b/openvdb_ax/openvdb_ax/util/x86.cc index 4a69ae62d3..b9bb3c4bda 100644 --- a/openvdb_ax/openvdb_ax/util/x86.cc +++ b/openvdb_ax/openvdb_ax/util/x86.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file util/x86.cc diff --git a/openvdb_ax/openvdb_ax/util/x86.h b/openvdb_ax/openvdb_ax/util/x86.h index ade4dbc876..6b39517fdc 100644 --- a/openvdb_ax/openvdb_ax/util/x86.h +++ b/openvdb_ax/openvdb_ax/util/x86.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file util/x86.h diff --git a/openvdb_cmd/CMakeLists.txt b/openvdb_cmd/CMakeLists.txt index c4351f49a0..edbb1a4e59 100644 --- a/openvdb_cmd/CMakeLists.txt +++ b/openvdb_cmd/CMakeLists.txt @@ -1,5 +1,5 @@ ## Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(OpenVDBBinaries LANGUAGES CXX) include(GNUInstallDirs) diff --git a/openvdb_cmd/vdb_ax/CMakeLists.txt b/openvdb_cmd/vdb_ax/CMakeLists.txt index 79d7293446..11562df353 100644 --- a/openvdb_cmd/vdb_ax/CMakeLists.txt +++ b/openvdb_cmd/vdb_ax/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(VDBAX LANGUAGES CXX) include(GNUInstallDirs) @@ -34,4 +34,4 @@ set(SOURCE_FILES main.cc) add_executable(vdb_ax ${SOURCE_FILES}) target_link_libraries(vdb_ax ${OPENVDB_BINARIES_DEPENDENT_LIBS}) -install(TARGETS vdb_ax RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS vdb_ax RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR}) diff --git a/openvdb_cmd/vdb_ax/cli.h b/openvdb_cmd/vdb_ax/cli.h index 1b80e5bfa0..12c666c6ae 100644 --- a/openvdb_cmd/vdb_ax/cli.h +++ b/openvdb_cmd/vdb_ax/cli.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file cmd/cli.h /// diff --git a/openvdb_cmd/vdb_ax/main.cc b/openvdb_cmd/vdb_ax/main.cc index f96b749486..9543d9fe6c 100644 --- a/openvdb_cmd/vdb_ax/main.cc +++ b/openvdb_cmd/vdb_ax/main.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file cmd/openvdb_ax.cc /// diff --git a/openvdb_cmd/vdb_lod/CMakeLists.txt b/openvdb_cmd/vdb_lod/CMakeLists.txt index 9f59829354..a67bdde2f4 100644 --- a/openvdb_cmd/vdb_lod/CMakeLists.txt +++ b/openvdb_cmd/vdb_lod/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(VDBLOD LANGUAGES CXX) include(GNUInstallDirs) @@ -16,4 +16,4 @@ set(SOURCE_FILES main.cc) add_executable(vdb_lod ${SOURCE_FILES}) target_link_libraries(vdb_lod ${OPENVDB_BINARIES_DEPENDENT_LIBS}) -install(TARGETS vdb_lod RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS vdb_lod RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR}) diff --git a/openvdb_cmd/vdb_lod/main.cc b/openvdb_cmd/vdb_lod/main.cc index d9085a54cb..e14e3b15b0 100644 --- a/openvdb_cmd/vdb_lod/main.cc +++ b/openvdb_cmd/vdb_lod/main.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_cmd/vdb_print/CMakeLists.txt b/openvdb_cmd/vdb_print/CMakeLists.txt index a8911a06d1..de58c90fba 100644 --- a/openvdb_cmd/vdb_print/CMakeLists.txt +++ b/openvdb_cmd/vdb_print/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(VDBPrint LANGUAGES CXX) include(GNUInstallDirs) @@ -16,4 +16,4 @@ set(SOURCE_FILES main.cc) add_executable(vdb_print ${SOURCE_FILES}) target_link_libraries(vdb_print ${OPENVDB_BINARIES_DEPENDENT_LIBS}) -install(TARGETS vdb_print RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS vdb_print RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR}) diff --git a/openvdb_cmd/vdb_print/main.cc b/openvdb_cmd/vdb_print/main.cc index de96ad4ed4..e093838768 100644 --- a/openvdb_cmd/vdb_print/main.cc +++ b/openvdb_cmd/vdb_print/main.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include @@ -210,31 +210,15 @@ printShortListing(const StringVec& filenames, bool metadata) // Print the grid's size, in bytes // no support for memUsageIfLoaded until ABI >= 10 for points::PointDataGrid types -#if OPENVDB_ABI_VERSION_NUMBER < 10 - using ListT = openvdb::GridTypes::Remove; -#else using ListT = openvdb::GridTypes; -#endif - const bool success = - grid->apply([&](const auto& typed){ - // @todo combine these methods to avoid iterating across the tree twice - const openvdb::Index64 incore = openvdb::tools::memUsage(typed.tree()); - const openvdb::Index64 total = openvdb::tools::memUsageIfLoaded(typed.tree()); - - std::cout << " " << std::right << std::setw(6) << bytesAsString(incore) << " (In Core)"; - std::cout << " " << std::right << std::setw(6) << bytesAsString(total) << " (Total)"; - }); - - (void)success; -#if OPENVDB_ABI_VERSION_NUMBER < 10 - if (!success) { - // could be a points grid, print in-core memory only - grid->apply([&](const auto& typed){ - const openvdb::Index64 incore = openvdb::tools::memUsage(typed.tree()); - std::cout << " " << std::right << std::setw(6) << bytesAsString(incore) << " (In Core)"; - }); - } -#endif + grid->apply([&](const auto& typed){ + // @todo combine these methods to avoid iterating across the tree twice + const openvdb::Index64 incore = openvdb::tools::memUsage(typed.tree()); + const openvdb::Index64 total = openvdb::tools::memUsageIfLoaded(typed.tree()); + + std::cout << " " << std::right << std::setw(6) << bytesAsString(incore) << " (In Core)"; + std::cout << " " << std::right << std::setw(6) << bytesAsString(total) << " (Total)"; + }); std::cout << std::endl; diff --git a/openvdb_cmd/vdb_render/CMakeLists.txt b/openvdb_cmd/vdb_render/CMakeLists.txt index 403aa8bd7f..032dfeeb66 100644 --- a/openvdb_cmd/vdb_render/CMakeLists.txt +++ b/openvdb_cmd/vdb_render/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(VDBRender LANGUAGES CXX) include(GNUInstallDirs) @@ -17,11 +17,11 @@ if(USE_PNG) endif() if(USE_IMATH_HALF) - find_package(Imath CONFIG REQUIRED) + find_package(Imath ${MINIMUM_IMATH_VERSION} CONFIG REQUIRED) endif() if(USE_EXR) - find_package(OpenEXR CONFIG REQUIRED) + find_package(OpenEXR ${MINIMUM_OPENEXR_VERSION} CONFIG REQUIRED) endif() set(SOURCE_FILES main.cc) @@ -51,4 +51,4 @@ target_link_libraries(vdb_render $ ) -install(TARGETS vdb_render RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS vdb_render RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR}) diff --git a/openvdb_cmd/vdb_render/main.cc b/openvdb_cmd/vdb_render/main.cc index 9a8d10288a..127d8720b7 100644 --- a/openvdb_cmd/vdb_render/main.cc +++ b/openvdb_cmd/vdb_render/main.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file main.cc /// diff --git a/openvdb_cmd/vdb_tool/CMakeLists.txt b/openvdb_cmd/vdb_tool/CMakeLists.txt index f9b846b8aa..c0a2d64277 100644 --- a/openvdb_cmd/vdb_tool/CMakeLists.txt +++ b/openvdb_cmd/vdb_tool/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) # CMP0091 allows for MSVC ABI targetting via CMAKE_MSVC_RUNTIME_LIBRARY # from CMake 3.15 and above. Must come before project(). @@ -26,7 +26,7 @@ list(APPEND CMAKE_MODULE_PATH ${OPENVDB_CMAKE_PATH}) add_library(vdb_tool_common INTERFACE) # Optional components -option(BUILD_TEST "Build unit tests" OFF) +option(OPENVDB_BUILD_VDB_TOOL_UNITTESTS "Build unit tests" OFF) option(OPENVDB_TOOL_USE_NANO "Compile with NanoVDB support" OFF) option(OPENVDB_TOOL_NANO_USE_ZIP "Compile NanoVDB with zip compression support. Requires OPENVDB_TOOL_USE_NANO=ON to have effect" ON) @@ -34,6 +34,7 @@ option(OPENVDB_TOOL_NANO_USE_BLOSC "Compile NanoVDB with Blosc compression suppo option(OPENVDB_TOOL_USE_PNG "Compile with PNG support" OFF) option(OPENVDB_TOOL_USE_EXR "Compile with EXR support" OFF) option(OPENVDB_TOOL_USE_JPG "Compile with JPG support" OFF) +option(OPENVDB_TOOL_USE_PDAL "Compile with extended points support" OFF) option(OPENVDB_TOOL_USE_ABC "Compile with Alembic support" OFF) option(OPENVDB_TOOL_USE_ALL "Compile with all optional components" OFF) if(OPENVDB_TOOL_USE_ALL) @@ -42,18 +43,20 @@ if(OPENVDB_TOOL_USE_ALL) set(OPENVDB_TOOL_USE_EXR ON) set(OPENVDB_TOOL_USE_JPG ON) set(OPENVDB_TOOL_USE_ABC ON) + set(OPENVDB_TOOL_USE_PDAL ON) + endif() if(OPENVDB_TOOL_USE_NANO) target_compile_definitions(vdb_tool_common INTERFACE "VDB_TOOL_USE_NANO") if(OPENVDB_TOOL_NANO_USE_ZIP) target_compile_definitions(vdb_tool_common INTERFACE "NANOVDB_USE_ZIP") - find_package(ZLIB REQUIRED) + find_package(ZLIB ${MINIMUM_ZLIB_VERSION} REQUIRED) target_link_libraries(vdb_tool_common INTERFACE ZLIB::ZLIB) endif() if(OPENVDB_TOOL_NANO_USE_BLOSC) target_compile_definitions(vdb_tool_common INTERFACE "NANOVDB_USE_BLOSC") - find_package(Blosc REQUIRED) + find_package(Blosc ${MINIMUM_BLOSC_VERSION} REQUIRED) target_link_libraries(vdb_tool_common INTERFACE blosc) endif() #target_include_directories(vdb_tool_common INTERFACE ${PROJECT_SOURCE_DIR}/../nanovdb/) @@ -83,6 +86,18 @@ if(OPENVDB_TOOL_USE_PNG) target_link_libraries(vdb_tool_common INTERFACE png) endif() +if(OPENVDB_TOOL_USE_PDAL) + target_compile_definitions(vdb_tool_common INTERFACE "VDB_TOOL_USE_PDAL") + if(WIN32) + find_package(libdpal CONFIG REQUIRED) + else() + find_package(PDAL REQUIRED) + endif() + message(STATUS "PDAL: ${PDAL_LIBRARIES} ${PDAL_INCLUDE_DIRS}") + target_link_libraries(vdb_tool_common INTERFACE ${PDAL_LIBRARIES}) + target_include_directories(vdb_tool_common INTERFACE ${PDAL_INCLUDE_DIRS}) +endif() + if(OPENVDB_TOOL_USE_JPG) target_compile_definitions(vdb_tool_common INTERFACE "VDB_TOOL_USE_JPG") find_package(JPEG REQUIRED) @@ -92,7 +107,7 @@ endif() if(OPENVDB_TOOL_USE_EXR) target_compile_definitions(vdb_tool_common INTERFACE "VDB_TOOL_USE_EXR") - find_package(OpenEXR REQUIRED) + find_package(OpenEXR ${MINIMUM_OPENEXR_VERSION} REQUIRED) target_link_libraries(vdb_tool_common INTERFACE OpenEXR::IlmImf) endif() @@ -166,14 +181,15 @@ target_include_directories(vdb_tool_common INTERFACE "${Boost_INCLUDE_DIRS}" "${ add_executable(vdb_tool src/main.cpp) target_include_directories(vdb_tool PRIVATE vdb_tool_common) target_link_libraries(vdb_tool PRIVATE vdb_tool_common) -install(TARGETS vdb_tool RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(TARGETS vdb_tool RUNTIME DESTINATION ${OPENVDB_INSTALL_BINDIR}) # unit test -if(BUILD_TEST) - find_package(GTest CONFIG REQUIRED) +if(OPENVDB_BUILD_VDB_TOOL_UNITTESTS) + find_package(GTest ${MINIMUM_GOOGLETEST_VERSION} CONFIG REQUIRED) add_executable(vdb_tool_test src/unittest.cpp) target_include_directories(vdb_tool_test PRIVATE vdb_tool_common) target_link_libraries(vdb_tool_test PRIVATE vdb_tool_common GTest::gmock GTest::gtest GTest::gmock_main GTest::gtest_main) + add_test(vdb_tool_unit_test vdb_tool_test) endif() diff --git a/openvdb_cmd/vdb_tool/README.md b/openvdb_cmd/vdb_tool/README.md index f64ebb6bea..23bb29066f 100644 --- a/openvdb_cmd/vdb_tool/README.md +++ b/openvdb_cmd/vdb_tool/README.md @@ -10,8 +10,8 @@ This command-line tool, dubbed vdb_tool, can combine any number of the of high-l | **eval** | Evaluate an expression written in our Reverse Polish Notation (see below) | | **config** | Load a configuration file and add the actions for processing | | **default** | Set default values used by all subsequent actions | -| **read** | Read mesh, points and level sets as obj, ply, abc, stl, pts, vdb or nvdb files | -| **write** | Write a polygon mesh, points or level set as a obj, ply, stl, abc or vdb file | +| **read** | Read mesh, points and level sets as obj, ply, abc, stl, off, pts, vdb or nvdb files | +| **write** | Write a polygon mesh, points or level set as a obj, ply, stl, off, abc or vdb file | | **vdb2points** | Extracts points from a VDB grid | | **mesh2ls** | Convert a polygon mesh to a narrow-band level set | | **points2ls** | Convert points into a narrow-band level set | @@ -59,9 +59,10 @@ For support, bug-reports or ideas for improvements please contact ken.museth@gma | Extension | Actions | Description | |-------|-------|-------| | vdb | read and write | OpenVDB sparse volume files with float, Vec3f and points | -| obj | read and write | ASCII OBJ mesh files with triangle, quad or points | -| ply | read and write | Binary and ASCII PLY mesh files with triangle, quad or points | +| obj | read and write | ASCII OBJ mesh files with triangles, quads or points | +| ply | read and write | Binary and ASCII PLY mesh files with triangles, quads or points | | stl | read and write | Binary STL mesh files with triangles | +| off | read and write | ASCI OFF mesh files with triangles, quads or points | | pts | read | ASCII PTS points files with one or more point clouds | | abc | optional read and write | Alembic binary mesh files | | nvdb| optional read and write | NanoVDB file with voxels or points | @@ -73,7 +74,7 @@ For support, bug-reports or ideas for improvements please contact ken.museth@gma # Terminology -We introduce terms: **actions**, **options**, **expressions**, and **instructions**. Actions are high-level openvdb tools, which each have unique options, e.g. -mesh2ls geo=1 voxel=0.1, where "-mesh2ls" is an action with two options "geo" and "voxel". Expressions are strings of code with one or more low-level instructions in our stack-based programming language (see below). These expressions start with "{" and ends with "}", and ":" is used to separate values and instructions. E.g. {1:2:+} is an expression with two values (1 and 2) and one instruction "+", and it reduces to the string value "3". See section on the "Stack-based string expressions" below for more details. +We introduce the following terms: **actions**, **options**, **expressions**, and **instructions**. Actions are high-level openvdb tools, which each have unique options, e.g. -mesh2ls geo=1 voxel=0.1, where "-mesh2ls" is an action with two options "geo" and "voxel". Expressions are strings of code with one or more low-level instructions in our stack-based programming language (see below). These expressions start with "{" and ends with "}", and ":" is used to separate values and instructions. E.g. {1:2:+} is an expression with two values (1 and 2) and one instruction "+", and it reduces to the string value "3". See section on the "Stack-based string expressions" below for more details. Note that **actions** always start with one or more "-" and (except for file names) its associated **options** always contain a "=" and an optional number of leading characters used for identification, e.g. "-erode r=2" is identical to "-erode radius=2.0", but "-erode rr=2" will produce an error since "rr" does not match the first two characters of any option associated with the action "erode". @@ -88,7 +89,7 @@ This tool supports its own light-weight stack-oriented programming language that This tool is using CMake for build on Linux and Windows. The only mandatory dependency of is [OpenVDB](http://www.openvdb.org). Optional dependencies include NanoVDB, libpng, libjpeg, OpenEXR, and Alembic. To enable them use the `-DUSE_=ON` flags. See the CMakeLists.txt for details. -The included unit test are using Gtest. Add `-DBUILD_TEST=ON` to the cmake command line to build it. +The included unit test are using Gtest. Add `-DOPENVDB_BUILD_VDB_TOOL_UNITTESTS=ON` to the cmake command line to build it. ## Building OpenVDB @@ -102,7 +103,7 @@ To generate the makefile, navigate to the cloned directory of vdb_tool, then fol ```bash mkdir build cd build -cmake -DOPENVDB_CMAKE_PATH=/usr/local/lib/cmake/OpenVDB -DUSE_ALL=ON -DBUILD_TEST=ON .. +cmake -DOPENVDB_CMAKE_PATH=/usr/local/lib/cmake/OpenVDB -DUSE_ALL=ON -DOPENVDB_BUILD_VDB_TOOL_UNITTESTS=ON .. ``` Update the OpenVDB cmake path above as needed. diff --git a/openvdb_cmd/vdb_tool/include/Geometry.h b/openvdb_cmd/vdb_tool/include/Geometry.h index 07c7f44743..ebd497b3bb 100644 --- a/openvdb_cmd/vdb_tool/include/Geometry.h +++ b/openvdb_cmd/vdb_tool/include/Geometry.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 //////////////////////////////////////////////////////////////////////////////// /// @@ -33,7 +33,7 @@ #ifdef VDB_TOOL_USE_NANO #include -#include +#include #endif #ifdef VDB_TOOL_USE_ABC @@ -45,6 +45,14 @@ #include #endif +#ifdef VDB_TOOL_USE_PDAL +#include "pdal/pdal.hpp" +#include "pdal/PipelineManager.hpp" +#include "pdal/PipelineReaderJSON.hpp" +#include "pdal/util/FileUtils.hpp" +#include +#endif + #if defined(_WIN32) #include #else @@ -58,6 +66,8 @@ OPENVDB_USE_VERSION_NAMESPACE namespace OPENVDB_VERSION_NAME { namespace vdb_tool { +#define MY_CLEAN_VERSION + /// @brief Class that encapsulates (explicit) geometry, i.e. vertices/points, /// triangles and quads. It is used to represent points and polygon meshes class Geometry @@ -82,9 +92,13 @@ class Geometry const std::vector& vtx() const { return mVtx; } const std::vector& tri() const { return mTri; } const std::vector& quad() const { return mQuad; } + const std::vector& rgb() const { return mRGB; } + std::vector& vtx() { return mVtx; } std::vector& tri() { return mTri; } std::vector& quad() { return mQuad; } + std::vector& rgb() { return mRGB; } + const BBoxT& bbox() const; void clear(); @@ -92,26 +106,31 @@ class Geometry // Reads all the vertices in the file and treats them as Geometry void write(const std::string &fileName) const; void writeOBJ(const std::string &fileName) const; - void writePLY(const std::string &fileName) const; + void writeOFF(const std::string &fileName) const; + void writePLY(const std::string &fileName, bool binary = true) const; void writeSTL(const std::string &fileName) const; void writeGEO(const std::string &fileName) const; void writeABC(const std::string &fileName) const; void writeOBJ(std::ostream &os) const; - void writePLY(std::ostream &os) const; + void writeOFF(std::ostream &os) const; + void writePLY(std::ostream &os, bool binary = true) const; void writeSTL(std::ostream &os) const; void read(const std::string &fileName); void readOBJ(const std::string &fileName); + void readOFF(const std::string &fileName); void readPLY(const std::string &fileName); void readSTL(const std::string &fileName); void readPTS(const std::string &fileName); void readGEO(const std::string &fileName); void readABC(const std::string &fileName); + void readPDAL(const std::string &fileName); void readVDB(const std::string &fileName); void readNVDB(const std::string &fileName); void readOBJ(std::istream &is); + void readOFF(std::istream &is); void readPLY(std::istream &is); size_t vtxCount() const { return mVtx.size(); } @@ -138,6 +157,7 @@ class Geometry std::vector mVtx; std::vector mTri; std::vector mQuad; + std::vector mRGB; mutable BBoxT mBBox; std::string mName; @@ -215,7 +235,7 @@ const math::BBox& Geometry::bbox() const void Geometry::write(const std::string &fileName) const { - switch (findFileExt(fileName, {"geo", "obj", "ply", "stl", "abc"})) { + switch (findFileExt(fileName, {"geo", "obj", "ply", "stl", "abc", "off"})) { case 1: this->writeGEO(fileName); break; @@ -231,30 +251,33 @@ void Geometry::write(const std::string &fileName) const case 5: this->writeABC(fileName); break; + case 6: + this->writeOFF(fileName); + break; default: throw std::invalid_argument("Geometry file \"" + fileName + "\" has an invalid extension"); } }// Geometry::write -void Geometry::writePLY(const std::string &fileName) const +void Geometry::writePLY(const std::string &fileName, bool binary) const { if (fileName == "stdout.ply") { //if (isatty(fileno(stdout))) throw std::invalid_argument("writePLY: stdout is not connected to the terminal!"); - this->writePLY(std::cout); + this->writePLY(std::cout, binary); } else { std::ofstream outfile(fileName, std::ios_base::binary); if (!outfile.is_open()) throw std::invalid_argument("Error writing to ply file \""+fileName+"\""); - this->writePLY(outfile);; + this->writePLY(outfile, binary); } }// Geometry::writePLY -void Geometry::writePLY(std::ostream &os) const +void Geometry::writePLY(std::ostream &os, bool binary) const { - os << "ply\n"; - if (isLittleEndian()) { - os << "format binary_little_endian 1.0\n"; + os << "ply\nformat "; + if (binary) { + os << "binary_" << (isLittleEndian() ? "little" : "big") << "_endian 1.0\n"; } else { - os << "format binary_big_endian 1.0\n"; + os << "ascii 1.0\n"; } os << "comment created by vdb_tool" << std::endl; os << "element vertex " << mVtx.size() << std::endl; @@ -265,32 +288,26 @@ void Geometry::writePLY(std::ostream &os) const os << "property list uchar int vertex_index\n"; os << "end_header\n"; static_assert(sizeof(Vec3s) == 3 * sizeof(float), "Unexpected sizeof(Vec3s)"); - os.write((const char *)mVtx.data(), mVtx.size() * 3 * sizeof(float)); - if (mTri.size()>0) { - const size_t size = sizeof(char) + 3*sizeof(uint32_t); - char *buffer = static_cast(std::malloc(mTri.size()*size)), *p = buffer;// uninitialized - if (buffer==nullptr) throw std::invalid_argument("Geometry::writePLY: failed to allocate buffer"); - static_assert(sizeof(Vec3I) == 3 * sizeof(uint32_t), "Unexpected sizeof(Vec3I)"); - for (const Vec3I *t = mTri.data(), *e = t + mTri.size(); t!=e; ++t) { - *p = 3; - std::memcpy(p + 1, t, 3*sizeof(uint32_t)); - p += size; - } - os.write(buffer, mTri.size()*size); - std::free(buffer); - } - if (mQuad.size()>0) { - const size_t size = sizeof(char) + 4*sizeof(uint32_t); - char *buffer = static_cast(std::malloc(mQuad.size()*size)), *p = buffer;// uninitialized - if (buffer==nullptr) throw std::invalid_argument("Geometry::writePLY: failed to allocate buffer"); - static_assert(sizeof(Vec4I) == 4 * sizeof(uint32_t), "Unexpected sizeof(Vec4I)"); - for (const Vec4I *q = mQuad.data(), *e = q + mQuad.size(); q!=e; ++q) { - *p = 4; - std::memcpy(p + 1, q, 4*sizeof(uint32_t)); - p += size; - } - os.write(buffer, mQuad.size()*size); - std::free(buffer); + if (binary) { + os.write((const char *)mVtx.data(), mVtx.size() * 3 * sizeof(float));// write x,y,z vertex coordinates + auto writeFaces = [](std::ostream &os, const uint32_t *faces, size_t count, uint8_t n) { + if (count==0) return; + const int size = 1 + 4*n; + char *buffer = (char*)std::malloc(count*size), *p = buffer;// uninitialized + if (buffer==nullptr) throw std::invalid_argument("Geometry::writePLY: failed to allocate buffer"); + for (const uint32_t *f = faces, *e = f + n*count; f!=e; f+=n, p += size) { + *p = (char)n; + std::memcpy(p + 1, f, 4*n); + } + os.write(buffer, count*size); + std::free(buffer); + }; + writeFaces(os, (const uint32_t*)mTri.data(), mTri.size(), 3); + writeFaces(os, (const uint32_t*)mQuad.data(), mQuad.size(), 4); + } else {// ascii + for (auto &v : mVtx) os << v[0] << " " << v[1] << " " << v[2] << "\n"; + for (auto &t : mTri) os << "3 " << t[0] << " " << t[1] << " " << t[2] << "\n"; + for (auto &q : mQuad) os << "4 " << q[0] << " " << q[1] << " " << q[2] << " " << q[3] << "\n"; } }// Geometry::writePLY @@ -302,24 +319,38 @@ void Geometry::writeOBJ(const std::string &fileName) const } else { std::ofstream outfile(fileName); if (!outfile.is_open()) throw std::invalid_argument("Error writing to obj file \""+fileName+"\""); - this->writeOBJ(outfile);; + this->writeOBJ(outfile); } }// Geometry::writeOBJ void Geometry::writeOBJ(std::ostream &os) const { - os << "# Created by vdb_tool\n"; - for (auto &v : mVtx) { - os << "v " << v[0] << " " << v[1] << " " << v[2] << "\n"; - } - for (auto &t : mTri) { - os << "f " << t[0]+1 << " " << t[1]+1 << " " << t[2]+1 << "\n";// obj is 1-based - } - for (auto &q : mQuad) { - os << "f " << q[0]+1 << " " << q[1]+1 << " " << q[2]+1 << " " << q[3]+1 << "\n";// obj is 1-based - } + os << "# obj file created by vdb_tool\n"; + for (auto &v : mVtx) os << "v " << v[0] << " " << v[1] << " " << v[2] << "\n"; + for (auto &t : mTri) os << "f " << t[0]+1 << " " << t[1]+1 << " " << t[2]+1 << "\n";// obj is 1-based + for (auto &q : mQuad) os << "f " << q[0]+1 << " " << q[1]+1 << " " << q[2]+1 << " " << q[3]+1 << "\n";// obj is 1-based }// Geometry::writeOBJ +void Geometry::writeOFF(const std::string &fileName) const +{ + if (fileName=="stdout.off") { + this->writeOFF(std::cout); + } else { + std::ofstream outfile(fileName); + if (!outfile.is_open()) throw std::invalid_argument("Error writing to off file \""+fileName+"\""); + this->writeOFF(outfile); + } +}// Geometry::writeOFF + +void Geometry::writeOFF(std::ostream &os) const +{ + os << "OFF\n# Created by vdb_tool\n"; + os << mVtx.size() << " " << (mTri.size() + mQuad.size()) << " " << 0 << "\n"; + for (auto &v : mVtx) os << v[0] << " " << v[1] << " " << v[2] << "\n"; + for (auto &t : mTri) os << "3 " << t[0] << " " << t[1] << " " << t[2] << "\n"; + for (auto &q : mQuad) os << "4 " << q[0] << " " << q[1] << " " << q[2] << " " << q[3] << "\n"; +}// Geometry::writeOFF + void Geometry::writeSTL(const std::string &fileName) const { if (fileName == "stdout.stl") { @@ -328,7 +359,7 @@ void Geometry::writeSTL(const std::string &fileName) const } else { std::ofstream outfile(fileName, std::ios::out | std::ios_base::binary); if (!outfile.is_open()) throw std::invalid_argument("Error writing to stl file \""+fileName+"\""); - this->writeSTL(outfile);; + this->writeSTL(outfile); } }// Geometry::writeSTL @@ -367,7 +398,7 @@ void Geometry::writeGEO(const std::string &fileName) const void Geometry::read(const std::string &fileName) { - switch (findFileExt(fileName, {"obj", "ply", "pts", "stl", "abc", "vdb", "nvdb", "geo"})) { + switch (findFileExt(fileName, {"obj", "ply", "pts", "stl", "abc", "vdb", "nvdb", "geo", "off"})) { case 1: this->readOBJ(fileName); break; @@ -392,9 +423,20 @@ void Geometry::read(const std::string &fileName) case 8: this->readGEO(fileName); break; + case 9: + this->readOFF(fileName); + break; default: - throw std::invalid_argument("Geometry::read: File \""+fileName+"\" has an invalid extension"); - break; +#if VDB_TOOL_USE_PDAL + pdal::StageFactory factory; + const std::string driver = factory.inferReaderDriver(fileName); + if (driver != "") { + this->readPDAL(fileName); + break; + } +#endif + throw std::invalid_argument("Geometry::read: File \""+fileName+"\" has an invalid extension"); + break; } }// Geometry::read @@ -442,6 +484,118 @@ void Geometry::readOBJ(std::istream &is) mBBox = BBoxT();//invalidate BBox }// Geometry::readOBJ +void Geometry::readPDAL(const std::string &fileName) +{ + #if VDB_TOOL_USE_PDAL + if (!pdal::FileUtils::fileExists(fileName)) throw std::invalid_argument("Error opening file \""+fileName+"\" - it doesn't exist!"); + + pdal::StageFactory factory; + std::string type = factory.inferReaderDriver(fileName); + std::string pipelineJson = R"({ + "pipeline" : [ + { + "type" : ")" + type + R"(", + "filename" : ")" + fileName + R"(" + } + ] + })"; + + Vec3f p; + Vec3s rgb; + try { + pdal::PipelineManager manager; + std::stringstream s(pipelineJson); + manager.readPipeline(s); + manager.execute(pdal::ExecMode::Standard); + + for (const std::shared_ptr& view : manager.views()) { + bool hasColor = false; + if (view->hasDim(pdal::Dimension::Id::Red) && view->hasDim(pdal::Dimension::Id::Green) && view->hasDim(pdal::Dimension::Id::Blue)) + hasColor = true; + for (const pdal::PointRef& point : *view) { + p[0] = point.getFieldAs(pdal::Dimension::Id::X); + p[1] = point.getFieldAs(pdal::Dimension::Id::Y); + p[2] = point.getFieldAs(pdal::Dimension::Id::Z); + mVtx.push_back(p); + if (hasColor) { + rgb[0] = point.getFieldAs(pdal::Dimension::Id::Red); + rgb[1] = point.getFieldAs(pdal::Dimension::Id::Green); + rgb[2] = point.getFieldAs(pdal::Dimension::Id::Blue); + mRGB.push_back(rgb); + } + } + } + + } + catch (const pdal::pdal_error& e) { + throw std::runtime_error("PDAL failed: " + std::string(e.what())); + } + catch (const std::exception& e) { + throw std::runtime_error("Reading file failed: " + std::string(e.what())); + } +#else + throw std::runtime_error("Cannot read file \"" + fileName + "\". PDAL support is not enabled in this build, please recompile with PDAL support"); +#endif + mBBox = BBoxT(); //invalidate BBox +}// Geometry::readPDAL + +void Geometry::readOFF(const std::string &fileName) +{ + if (fileName == "stdin.off") { + this->readOFF(std::cin); + } else { + std::ifstream infile(fileName); + if (!infile.is_open()) throw std::invalid_argument("Error opening Geometry file \""+fileName+"\""); + this->readOFF(infile); + } +}// Geometry::readOFF + +void Geometry::readOFF(std::istream &is) +{ + // read header + std::string line; + if (!std::getline(is, line) || line != "OFF") { + throw std::invalid_argument("Geometry::readOFF: expected header \"OFF\" but read \"" + line + "\""); + } + + // read vertex and face counts + size_t vtxCount=0, faceCount=0, edgeCount=0, nGon=0; + while (vtxCount == 0 && std::getline(is, line)) { + if (line.empty() || line[0] == '#') continue; + std::istringstream iss(line); + iss >> vtxCount >> faceCount >> edgeCount; + } + + // read vertices + Vec3f p; + vtxCount += mVtx.size(); + while (mVtx.size() < vtxCount && std::getline(is, line)) { + if (line.empty() || line[0] == '#') continue; + std::istringstream iss(line); + iss >> p[0] >> p[1] >> p[2]; + mVtx.push_back(p); + } + + // read faces + int f[4]; + faceCount += mTri.size() + mQuad.size(); + while (mTri.size() + mQuad.size() < faceCount && std::getline(is, line)) { + if (line.empty() || line[0] == '#') continue; + std::istringstream iss(line); + iss >> nGon; + if (nGon == 3) { + iss >> f[0] >> f[1] >> f[2]; + mTri.emplace_back(f[0],f[1],f[2]); + } else if (nGon == 4) { + iss >> f[0] >> f[1] >> f[2] >> f[3]; + mQuad.emplace_back(f[0],f[1],f[2],f[3]); + } else { + throw std::invalid_argument("Geometry::readOFF: " + std::to_string(nGon) + "-gons are not supported"); + } + } + mBBox = BBoxT();//invalidate BBox +}// Geometry::readOFF + void Geometry::readPLY(const std::string &fileName) { if (fileName == "stdin.ply") { @@ -468,9 +622,7 @@ void Geometry::readPLY(std::istream &is) auto tokens = tokenize_line(); auto test = [&tokens](int i, std::vector str) { if (i >= static_cast(tokens.size())) return false; - for (auto &s : str) { - if (tokens[i] == s) return true; - } + for (auto &s : str) if (tokens[i] == s) return true; return false; }; auto error = [&tokens](const std::string &msg){ @@ -479,8 +631,19 @@ void Geometry::readPLY(std::istream &is) std::cerr << "\"\n"; throw std::invalid_argument(msg); }; + auto sizeOf = [test, error](int i){ + if ( test(i, {"float", "float32", "int", "int32"}) ) return 4; + if ( test(i, {"double", "float64"}) ) return 8; + if ( test(i, {"int16", "uint16"}) ) return 2; + if ( test(i, {"uchar", "int8"}) ) return 1; + error("vdb_tool::readPLY: unsupported type"); + return 0; + }; + // check header if (!test(0, {"ply"})) error("vdb_tool::readPLY: not a ply file"); + + // check file format int format = -1;// 0 is ascii, 1 is little endian and 2 is big endian tokens = tokenize_line(); if (!(test(0, {"format"}) && test(2, {"1.0"})) ) { @@ -496,18 +659,20 @@ void Geometry::readPLY(std::istream &is) } const bool reverseBytes = format && format != (isLittleEndian() ? 1 : 2); // header: https://www.mathworks.com/help/vision/ug/the-ply-format.html - size_t vtxCount = 0, polyCount = 0; - struct Skip {int count, bytes;} vtx_skip[2]={{0,0},{0,0}}, ply_skip[2]={{0,0},{0,0}}; + size_t vtxCount = 0, faceCount = 0; + int vtxStride=0, vtxProps=0;// byte size of all vtx properties, number of vertex properties + struct Triplet {int offset, id, size;} xyz[3];// byte offset, id#, byte size + struct Skip {int count, bytes;} faceSkip[2]={{0,0},{0,0}};// head, {faces}, tail + + // parse header with vertex, face and property information tokens = tokenize_line(); bool run = true; while(run) { if ( test(0, {"element"}) ) { if ( test(1, {"vertex"}) ) { vtxCount = std::stoll(tokens[2]); - int n = 0; const std::string axis[3] = {"x", "y", "z"}; while(true) { - const int m = n>0 ? 1 : 0; tokens = tokenize_line(); if ( test(0, {"end_header"}) ) { run = false; @@ -515,35 +680,16 @@ void Geometry::readPLY(std::istream &is) } else if ( test(0, {"element"}) ) { break; } else if ( test(0, {"property"}) ) { - if ( test(1, {"float", "float32"}) ) { - if ( test(2, {"x", "y", "z"}) ) {// nx,ny.nz - if (n>2 || !test(2, {axis[n++]}) ) error("vdb_tool::readPLY: expected x or y or z"); - } else {// e.g. nx, ny, nz, intensity, s, t etc - if (n!=0 && n!=3) error("vdb_tool::readPLY: vertex float property interlaced with coordinates"); - vtx_skip[m].count += 1; - vtx_skip[m].bytes += static_cast(sizeof(float)); - } - } else if ( test(1, {"int16", "uint16"}) ) {// e.g. material_index etc - if (n!=0 && n!=3) error("vdb_tool::readPLY: vertex int16 property interlaced with coordinates is not supported"); - vtx_skip[m].count += 1; - vtx_skip[m].bytes += static_cast(sizeof(int16_t)); - } else if ( test(1, {"int", "int32"}) ) {// e.g. material_index etc - if (n!=0 && n!=3) error("vdb_tool::readPLY: vertex int32 property interlaced with coordinates is not supported"); - vtx_skip[m].count += 1; - vtx_skip[m].bytes += static_cast(sizeof(int32_t)); - } else if ( test(1, {"uchar", "int8"}) ) {// eg red, green, blue, alpha - if (n!=0 && n!=3) error("vdb_tool::readPLY: vertex int8 property interlaced with coordinates is not supported"); - vtx_skip[m].count += 1; - vtx_skip[m].bytes += static_cast(sizeof(unsigned char)); - } else { - error("vdb_tool::readPLY: invalid vertex property"); - } + Triplet t{vtxStride, vtxProps++, sizeOf(1)}; + for (int i=0; i<3; ++i) if (test(2, {axis[i]})) xyz[i] = t; + vtxStride += t.size; } } - if (n!=3) error("vdb_tool::readPLY: missing vertex coordinates"); + for (int i=0; i<3; ++i) if (xyz[i].size!=4 && xyz[i].size!=8) error("vdb_tool::readPLY: missing "+axis[i]+ + " vertex coordinates or unsupported size "+std::to_string(xyz[i].size)); } else if ( test(1, {"face"}) ) { - polyCount = std::stoll(tokens[2]); - int n = 0; + faceCount = std::stoll(tokens[2]); + int n = 0;// 0 is head and 1 is tail while (true) { tokens = tokenize_line(); if ( test(0, {"end_header"}) ) { @@ -551,15 +697,15 @@ void Geometry::readPLY(std::istream &is) break; } else if (test(0, {"element"}) ) { break; - } else if (test(0, {"property"}) ) { - if (test(1, {"list"}) && - test(2, {"uchar", "uint8"}) && - test(3, {"int", "uint", "int32"}) && + } else if (test(0, {"property"}) ) {// eg: "property list uchar int vertex_indices" + if (test(1, {"list"}) &&// list of vertex ID belonging to a polygon + test(2, {"uchar", "uint8"}) &&// size of polygon, e.g. 3 or 4 + test(3, {"int", "uint", "int32"}) &&// type of vertex id test(4, {"vertex_index", "vertex_indices"}) ) { - n = 1; - } else if ( test(1, {"uchar", "uint8"}) ) { - ply_skip[n].count += 1; - ply_skip[n].bytes += 1; + n = 1;// change from head to tail + } else if ( test(1, {"uchar", "uint8"}) ) {// eg: "property uchar intensity" + faceSkip[n].count += 1; + faceSkip[n].bytes += 1; } else { error("vdb_tool::readPLY: invalid face properties"); } @@ -578,7 +724,7 @@ void Geometry::readPLY(std::istream &is) } else { error("vdb_tool::readPLY: invalid element"); } - } else if ( test(0, {"comment", "obj_info"}) ) { + } else if ( test(0, {"comment", "obj_info"}) ) {// eq: "obj_info 3D colored patch boundaries" and "comment author: Paraform" tokens = tokenize_line(); } else { error("vdb_tool::readPLY: unexpected entry in header"); @@ -588,96 +734,69 @@ void Geometry::readPLY(std::istream &is) // read vertex coordinates mVtx.resize(vtxCount); if (format) {// binary - if (vtx_skip[0].count == 0 && vtx_skip[1].count == 0) {//faster + if (xyz[0].offset==0 && xyz[1].offset==4 && xyz[2].offset==8 && vtxStride==12) {// most common case is.read((char *)(mVtx.data()), vtxCount * 3 * sizeof(float)); + if (reverseBytes) for (Vec3f &v : mVtx) swapBytes(&v[0], 3); } else { - const size_t bSize = vtx_skip[0].bytes + 3*sizeof(float) + vtx_skip[1].bytes; - char *buffer = static_cast(std::malloc(vtxCount*bSize));// uninitialized + char *buffer = static_cast(std::malloc(vtxCount*vtxStride)), *p = buffer;// uninitialized if (buffer==nullptr) throw std::invalid_argument("Geometry::readPLY: failed to allocate buffer"); - is.read(buffer, vtxCount*bSize); - for (size_t i=0; i(buffer + i*bSize + vtx_skip[0].bytes); - mVtx[i] = Vec3f(p); + is.read(buffer, vtxCount*vtxStride); + for (Vec3f &vtx : mVtx) { + for (int i=0; i<3; ++i) { + if (xyz[i].size == 4) { + float v = *(float*)(p + xyz[i].offset); + vtx[i] = reverseBytes ? swapBytes(v) : v; + } else { + double v = *(double*)(p + xyz[i].offset); + vtx[i] = float(reverseBytes ? swapBytes(v) : v); + } + } + p += vtxStride; } std::free(buffer); } - if (reverseBytes) { - auto flipBytes = [](float v)->float{ - float tmp; - char *p = (char*)&v, *q = (char*)&tmp; - q[0] = p[3]; - q[1] = p[2]; - q[2] = p[1]; - q[3] = p[0]; - return tmp; - };// flipBytes in float - for (size_t i = 0; i < mVtx.size(); ++i) { - auto &p = mVtx[i]; - p[0] = flipBytes(p[0]); - p[1] = flipBytes(p[1]); - p[2] = flipBytes(p[2]); - } - } - } else {// ascii + + } else {// ascii vertices for (auto &v : mVtx) { tokens = tokenize_line(); - if (static_cast(tokens.size()) != vtx_skip[0].count + 3 + vtx_skip[1].count) { - error("vdb_tool::readPLY: error reading ascii vertex coordinates"); - } - for (int i = 0; i<3; ++i) { - v[i] = std::stof(tokens[i + vtx_skip[0].count]); - } + if (int(tokens.size()) != vtxProps) error("vdb_tool::readPLY: error reading ascii vertex coordinates"); + for (int i = 0; i<3; ++i) v[i] = std::stof(tokens[xyz[0].id]); }// loop over vertices } // read polygon vertex lists uint32_t vtx[4]; if (format) {// binary - auto flipBytes = [&](int n){ - uint32_t tmp; - char *q = (char*)&tmp; - for (int i=0; i(std::malloc(ply_skip[0].bytes + 1));// uninitialized + char *buffer = static_cast(std::malloc(faceSkip[0].bytes + 1));// uninitialized if (buffer==nullptr) throw std::invalid_argument("Geometry::readPLY: failed to allocate buffer"); - for (size_t i=0; i unsigned int switch (n) { case 3: - is.read((char *)(&vtx), 3*sizeof(uint32_t)); - if (reverseBytes) flipBytes(3); + is.read((char*)vtx, 3*sizeof(uint32_t)); + if (reverseBytes) swapBytes(vtx, 3); mTri.emplace_back(vtx); break; case 4: - is.read((char *)(&vtx), 4*sizeof(uint32_t)); - if (reverseBytes) flipBytes(4); + is.read((char*)vtx, 4*sizeof(uint32_t)); + if (reverseBytes) swapBytes(vtx, 4); mQuad.emplace_back(vtx); break; default: throw std::invalid_argument("Geometry::readPLY: binary " + std::to_string(n) + "-gons are not supported"); break; } - is.ignore(ply_skip[1].bytes); + is.ignore(faceSkip[1].bytes); }// loop over polygons std::free(buffer); - } else {// ascii format - for (size_t i=0; i(std::stoll(tokens[i + 1 + ply_skip[0].count])); - } + const std::string polySize = tokens[faceSkip[0].count]; + const int n = std::stoi(polySize); + if (n!=3 && n!=4) throw std::invalid_argument("Geometry::readPLY: ascii " + polySize + "-gons are not supported"); + for (int i = 0, j=1+faceSkip[0].count; i(std::stoll(tokens[j])); if (n==3) { mTri.emplace_back(vtx); } else { @@ -753,6 +872,8 @@ void Geometry::readPTS(const std::string &fileName) if (!infile.is_open()) throw std::runtime_error("Error opening particle file \""+fileName+"\""); std::string line; std::istringstream iss; + bool readColor = false; + Vec3s rgb; while(std::getline(infile, line)) { const size_t n = mVtx.size(), m = std::stoi(line); mVtx.resize(n + m); @@ -764,6 +885,18 @@ void Geometry::readPTS(const std::string &fileName) if (!(iss >> p[0] >> p[1] >> p[2])) {;//ignore intensity, r, g, b throw std::invalid_argument("Geometry::readPTS: error parsing line: \""+line+"\""); } + if (readColor) { + if (!(iss >> i) ) { // converting intensity to a multiplier on rgb might be appropriate, but i can't find a good spec for it + readColor = false; + continue; + } + if (!(iss >> rgb[0] >> rgb[1] >> rgb[2])) { + readColor = false; + continue; + } + mRGB.push_back(rgb/255.0); + } + }// loop over points }// loop over scans mBBox = BBoxT();//invalidate BBox diff --git a/openvdb_cmd/vdb_tool/include/Parser.h b/openvdb_cmd/vdb_tool/include/Parser.h index 80245e5db3..08b08599f5 100644 --- a/openvdb_cmd/vdb_tool/include/Parser.h +++ b/openvdb_cmd/vdb_tool/include/Parser.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 //////////////////////////////////////////////////////////////////////////////// /// diff --git a/openvdb_cmd/vdb_tool/include/Tool.h b/openvdb_cmd/vdb_tool/include/Tool.h index 4c27b32e32..b24e71696e 100644 --- a/openvdb_cmd/vdb_tool/include/Tool.h +++ b/openvdb_cmd/vdb_tool/include/Tool.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 //////////////////////////////////////////////////////////////////////////////// /// @@ -47,14 +47,15 @@ #include // for tools::interiorMask() #include #include +#include #include #include #ifdef VDB_TOOL_USE_NANO #include -#include -#include -#include +#include +#include +#include #endif #ifdef VDB_TOOL_USE_EXR @@ -69,6 +70,10 @@ #include #endif +#ifdef VDB_TOOL_USE_PDAL +#include +#endif + #ifdef VDB_TOOL_USE_JPG #include #endif @@ -364,14 +369,14 @@ void Tool::init() mParser.addAction( "read", "i", "Read one or more geometry or VDB files from disk or STDIN.", - {{"files", "", "{file|stdin}.{abc|obj|ply|stl|vdb}", "list of files or the input stream, e.g. file.vdb,stdin.vdb. Note that \"files=\" is optional since any argument without \"=\" is intrepreted as a file and appended to \"files\""}, + {{"files", "", "{file|stdin}.{abc|obj|ply|stl|off|vdb}", "list of files or the input stream, e.g. file.vdb,stdin.vdb. Note that \"files=\" is optional since any argument without \"=\" is intrepreted as a file and appended to \"files\""}, {"grids", "*", "*|grid_name,...", "list of VDB grids name to be imported (defaults to \"*\", i.e. import all available grids)"}, {"delayed", "true", "1|0|true|false", "toggle delayed loading of VDB grids (enabled by default). This option is ignored by other file types"}}, [](){}, [&](){this->read();}, 0);// anonymous options are treated as to the first option,i.e. "files" mParser.addAction( "write", "o", "Write list of geometry, VDB or config files to disk or STDOUT", - {{"files", "", "{file|stdout}.{obj|ply|stl|vdb|nvdb}", "list of files or the output stream, e.g. file.vdb or stdin.vdb. Note that \"files=\" is optional since any argument without the \"=\" character is intrepreted as a file and appended to \"files\"."}, + {{"files", "", "{file|stdout}.{obj|ply|stl|off|vdb|nvdb}", "list of files or the output stream, e.g. file.vdb or stdin.vdb. Note that \"files=\" is optional since any argument without the \"=\" character is intrepreted as a file and appended to \"files\"."}, {"geo", "0", "0|1...", "geometry to write (defaults to \"0\" which is the latest)."}, {"vdb", "*", "0,1,...", "list of VDB grids to write (defaults to \"*\", i.e. all available grids)."}, {"keep", "", "1|0|true|false", "toggle wether to preserved or deleted geometry and grids after they have been written."}, @@ -920,8 +925,8 @@ std::string Tool::examples() const { const int w = 16; std::stringstream ss; - ss << std::left << std::setw(w) << "Surface points:" << mCmdName << " -read points.[obj/ply/stl/pts] -points2ls d=256 r=2.0 w=3 -dilate r=2 -gauss i=1 w=1 -erode r=2 -ls2m a=0.25 -write output.[ply/obj/stl]\n"; - ss << std::left << std::setw(w) << "Convert mesh: " << mCmdName << " -read mesh.[ply/obj] -mesh2ls d=256 -write output.vdb config.txt\n"; + ss << std::left << std::setw(w) << "Surface points:" << mCmdName << " -read points.[obj/ply/stl/off/pts] -points2ls d=256 r=2.0 w=3 -dilate r=2 -gauss i=1 w=1 -erode r=2 -ls2m a=0.25 -write output.[ply/obj/stl]\n"; + ss << std::left << std::setw(w) << "Convert mesh: " << mCmdName << " -read mesh.[ply/obj/off] -mesh2ls d=256 -write output.vdb config.txt\n"; ss << std::left << std::setw(w) << "Config example:" << mCmdName << " -config config.txt\n"; return ss.str(); } @@ -958,7 +963,7 @@ void Tool::read() { OPENVDB_ASSERT(mParser.getAction().name == "read"); for (auto &fileName : mParser.getVec("files")) { - switch (findFileExt(fileName, {"geo,obj,ply,abc,pts,stl", "vdb", "nvdb"})) { + switch (findFileExt(fileName, {"geo,obj,ply,abc,pts,off,stl", "vdb", "nvdb"})) { case 1: this->readGeo(fileName); break; @@ -969,6 +974,14 @@ void Tool::read() this->readNVDB(fileName); break; default: +#if VDB_TOOL_USE_PDAL + pdal::StageFactory factory; + if (factory.inferReaderDriver(fileName) != "") + { + this->readGeo(fileName); + break; + } +#endif throw std::invalid_argument("File \""+fileName+"\" has an invalid extension"); break; } @@ -1049,7 +1062,7 @@ void Tool::readNVDB(const std::string &fileName) const size_t count = mGrid.size(); if (grids.size()) { for (const auto& gridHandle : grids) { - if (gridNames[0]=="*" || findMatch(gridHandle.gridMetaData()->shortGridName(), gridNames)) mGrid.push_back(nanovdb::nanoToOpenVDB(gridHandle)); + if (gridNames[0]=="*" || findMatch(gridHandle.gridMetaData()->shortGridName(), gridNames)) mGrid.push_back(nanovdb::tools::nanoToOpenVDB(gridHandle)); } } else if (mParser.verbose>0) { std::cerr << "readVDB: no vdb grids in \"" << fileName << "\""; @@ -1122,7 +1135,7 @@ void Tool::write() { OPENVDB_ASSERT(mParser.getAction().name == "write"); for (std::string &fileName : mParser.getVec("files")) { - switch (findFileExt(fileName, {"geo,obj,ply,stl,abc", "vdb", "nvdb", "txt"})) { + switch (findFileExt(fileName, {"geo,obj,ply,stl,off,abc", "vdb", "nvdb", "txt"})) { case 1: this->writeGeo(fileName); break; @@ -1249,26 +1262,26 @@ void Tool::writeNVDB(const std::string &fileName) throw std::invalid_argument("writeNVDB: unsupported bits \""+bits+"\""); } - nanovdb::StatsMode sMode = nanovdb::StatsMode::Default; + nanovdb::tools::StatsMode sMode = nanovdb::tools::StatsMode::Default; if (stats == "none") { - sMode = nanovdb::StatsMode::Disable; + sMode = nanovdb::tools::StatsMode::Disable; } else if (stats == "bbox") { - sMode = nanovdb::StatsMode::BBox; + sMode = nanovdb::tools::StatsMode::BBox; } else if (stats == "extrema") { - sMode = nanovdb::StatsMode::MinMax; + sMode = nanovdb::tools::StatsMode::MinMax; } else if (stats == "all") { - sMode = nanovdb::StatsMode::All; + sMode = nanovdb::tools::StatsMode::All; } else if (stats != "") { throw std::invalid_argument("writeNVDB: unsupported stats \""+stats+"\""); } - nanovdb::ChecksumMode cMode = nanovdb::ChecksumMode::Default; + nanovdb::CheckMode cMode = nanovdb::CheckMode::Default; if (checksum == "none") { - cMode = nanovdb::ChecksumMode::Disable; + cMode = nanovdb::CheckMode::Disable; } else if (checksum == "partial") { - cMode = nanovdb::ChecksumMode::Partial; + cMode = nanovdb::CheckMode::Partial; } else if (checksum == "full") { - cMode = nanovdb::ChecksumMode::Full; + cMode = nanovdb::CheckMode::Full; } else if (checksum != "") { throw std::invalid_argument("writeNVDB: unsupported checksum \""+checksum+"\""); } @@ -1289,21 +1302,21 @@ void Tool::writeNVDB(const std::string &fileName) using SrcGridT = openvdb::FloatGrid; switch (qMode){ case nanovdb::GridType::Fp4: - return nanovdb::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose); + return nanovdb::tools::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose); case nanovdb::GridType::Fp8: - return nanovdb::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose); + return nanovdb::tools::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose); case nanovdb::GridType::Fp16: - return nanovdb::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose); + return nanovdb::tools::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose); case nanovdb::GridType::FpN: if (absolute) { - return nanovdb::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose, nanovdb::AbsDiff(tolerance)); + return nanovdb::tools::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose, nanovdb::tools::AbsDiff(tolerance)); } else { - return nanovdb::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose, nanovdb::RelDiff(tolerance)); + return nanovdb::tools::createNanoGrid(*floatGrid, sMode, cMode, dither, verbose, nanovdb::tools::RelDiff(tolerance)); } default: break;// 32 bit float grids are handled below }// end of switch } - return nanovdb::openToNanoVDB(base, sMode, cMode, verbose);// float and other grids + return nanovdb::tools::openToNanoVDB(base, sMode, cMode, verbose);// float and other grids };// openToNano if (fileName=="stdout.nvdb") { @@ -1421,6 +1434,7 @@ void Tool::pointsToVdb() const int bits = mParser.get("bits"); std::string grid_name = mParser.get("name"); using GridT = points::PointDataGrid; + using IdGridT = tools::PointIndexGrid; if (mParser.verbose) mTimer.start("Points to VDB"); auto it = this->getGeom(age); Points points((*it)->vtx()); @@ -1428,19 +1442,48 @@ void Tool::pointsToVdb() auto xform = math::Transform::createLinearTransform(voxelSize); GridT::Ptr grid; + IdGridT::Ptr indexGrid; + + points::PointAttributeVector positionsWrapper((*it)->vtx()); + openvdb::NamePair rgbAttribute ; switch (bits) { case 8: - grid = points::createPointDataGrid, GridT>((*it)->vtx(), *xform); + indexGrid = tools::createPointIndexGrid(positionsWrapper, *xform); + grid = points::createPointDataGrid, GridT>(*indexGrid, positionsWrapper, *xform); + openvdb::points::TypedAttributeArray::registerType(); + rgbAttribute = + openvdb::points::TypedAttributeArray::attributeType(); + openvdb::points::appendAttribute(grid->tree(), "Cd", rgbAttribute); break; case 16: - grid = points::createPointDataGrid, GridT>((*it)->vtx(), *xform); + indexGrid = tools::createPointIndexGrid(positionsWrapper, *xform); + grid = points::createPointDataGrid, GridT>(*indexGrid, positionsWrapper, *xform); + openvdb::points::TypedAttributeArray::registerType(); + rgbAttribute = + openvdb::points::TypedAttributeArray::attributeType(); + openvdb::points::appendAttribute(grid->tree(), "Cd", rgbAttribute); break; case 32: - grid = points::createPointDataGrid((*it)->vtx(), *xform); + indexGrid = tools::createPointIndexGrid(positionsWrapper, *xform); + grid = points::createPointDataGrid(*indexGrid, positionsWrapper, *xform); + + openvdb::points::TypedAttributeArray::registerType(); + rgbAttribute = + openvdb::points::TypedAttributeArray::attributeType(); + openvdb::points::appendAttribute(grid->tree(), "Cd", rgbAttribute); break; default: throw std::invalid_argument("pointsToVdb: unsupported bit-width: "+std::to_string(bits)); } + + if ((*it)->rgb().size() == (*it)->vtx().size()) { + + points::PointAttributeVector rgbWrapper((*it)->rgb()); + points::populateAttribute>( + grid->tree(), indexGrid->tree(), "Cd", rgbWrapper); + + } if (grid_name.empty()) grid_name = "points2vdb_"+(*it)->getName(); grid->setName(grid_name); mGrid.push_back(grid); diff --git a/openvdb_cmd/vdb_tool/include/Util.h b/openvdb_cmd/vdb_tool/include/Util.h index 2a9df82dd6..9d084fb22e 100644 --- a/openvdb_cmd/vdb_tool/include/Util.h +++ b/openvdb_cmd/vdb_tool/include/Util.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 //////////////////////////////////////////////////////////////////////////////// /// @@ -377,6 +377,31 @@ inline bool isLittleEndian() return (*(char *)&tmp == 1); } +/// @brief invert endianess of a type +/// @tparam T Template type to be inverted +/// @param val value to be inverted +/// @return value with reverse bytes +template +inline T swapBytes(T val) +{ + T tmp; + for (char *src=(char*)&val, *dst=(char*)(&tmp)+sizeof(T)-1, *end=src+sizeof(T);src!=end; *dst-- = *src++); + return tmp; +} + +/// @brief invert endianess of an array of values of a specific type +/// @tparam T Template type to be inverted +/// @param val pointer to array with values to be inverted +/// @param n number of elements in the array +template +inline void swapBytes(T *val, int n) +{ + for (T tmp, *last = val + n; val < last; ++val) { + for (char *src=(char*)val, *dst=(char*)(&tmp)+sizeof(T)-1, *end=src+sizeof(T); src!=end; *dst-- = *src++); + *val = tmp; + } +} + /// @brief return a pseudo random uuid string. /// /// @details this function approximates a uuid version 4, variant 1 as detailed diff --git a/openvdb_cmd/vdb_tool/src/main.cpp b/openvdb_cmd/vdb_tool/src/main.cpp index 08be17d04b..ee5697ce9e 100644 --- a/openvdb_cmd/vdb_tool/src/main.cpp +++ b/openvdb_cmd/vdb_tool/src/main.cpp @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 //////////////////////////////////////////////////////////////////////////////// /// diff --git a/openvdb_cmd/vdb_tool/src/unittest.cpp b/openvdb_cmd/vdb_tool/src/unittest.cpp index 0600d643e1..0ddd6fb2cf 100644 --- a/openvdb_cmd/vdb_tool/src/unittest.cpp +++ b/openvdb_cmd/vdb_tool/src/unittest.cpp @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #define _USE_MATH_DEFINES @@ -301,6 +301,52 @@ TEST_F(Test_vdb_tool, Util) } EXPECT_EQ(size, tmp.size()); } + + {//swapBytes + const int i = 4, j = openvdb::vdb_tool::swapBytes(i); + EXPECT_NE(i, j); + EXPECT_EQ(i, openvdb::vdb_tool::swapBytes(j)); + + const float a = 4, b = openvdb::vdb_tool::swapBytes(a); + EXPECT_NE(a, b); + EXPECT_EQ(a, openvdb::vdb_tool::swapBytes(b)); + + const double x = 4, y = openvdb::vdb_tool::swapBytes(x); + EXPECT_NE(x, y); + EXPECT_EQ(x, openvdb::vdb_tool::swapBytes(y)); + + int vec_i[3]={3,4,5}, vec_j[3]; + for (int n=0; n<3; ++n) { + vec_j[n] = openvdb::vdb_tool::swapBytes(vec_i[n]); + EXPECT_NE(vec_i[n], vec_j[n]); + } + openvdb::vdb_tool::swapBytes(vec_j, 3); + for (int n=0; n<3; ++n) EXPECT_EQ(vec_i[n], vec_j[n]); + + float vec_a[3]={3,4,5}, vec_b[3]; + for (int n=0; n<3; ++n) { + vec_b[n] = openvdb::vdb_tool::swapBytes(vec_a[n]); + EXPECT_NE(vec_a[n], vec_b[n]); + } + openvdb::vdb_tool::swapBytes(vec_b, 3); + for (int n=0; n<3; ++n) EXPECT_EQ(vec_a[n], vec_b[n]); + + double vec_x[3]={3,4,5}, vec_y[3]; + for (int n=0; n<3; ++n) { + vec_y[n] = openvdb::vdb_tool::swapBytes(vec_x[n]); + EXPECT_NE(vec_x[n], vec_y[n]); + } + openvdb::vdb_tool::swapBytes(vec_y, 3); + for (int n=0; n<3; ++n) EXPECT_EQ(vec_x[n], vec_y[n]); + } + {// weird pointer behaviour + float vec[4], *p = vec; + EXPECT_EQ(vec, p);// of course + EXPECT_EQ((char*)(vec), (char*)p);// sure + EXPECT_EQ((char*)(&vec), (char*)p);// wait, what?! + EXPECT_NE((char*)(vec), (char*)(&p));// yep + EXPECT_NE((char*)(&p), (char*)p);// of course + } }// Util TEST_F(Test_vdb_tool, getArgs) @@ -371,18 +417,18 @@ TEST_F(Test_vdb_tool, Geometry) EXPECT_EQ(4, geo2.vtxCount()); EXPECT_EQ(2, geo2.triCount()); EXPECT_EQ(1, geo2.quadCount()); - EXPECT_EQ(openvdb::Vec3f(1,2,3), geo.bbox().min()); - EXPECT_EQ(openvdb::Vec3f(10,11,12), geo.bbox().max()); + EXPECT_EQ(openvdb::Vec3f(1,2,3), geo2.bbox().min()); + EXPECT_EQ(openvdb::Vec3f(10,11,12), geo2.bbox().max()); - EXPECT_EQ(openvdb::Vec3f(1,2,3), geo.vtx()[0]); - EXPECT_EQ(openvdb::Vec3f(4,5,6), geo.vtx()[1]); - EXPECT_EQ(openvdb::Vec3f(7,8,9), geo.vtx()[2]); - EXPECT_EQ(openvdb::Vec3f(10,11,12), geo.vtx()[3]); + EXPECT_EQ(openvdb::Vec3f(1,2,3), geo2.vtx()[0]); + EXPECT_EQ(openvdb::Vec3f(4,5,6), geo2.vtx()[1]); + EXPECT_EQ(openvdb::Vec3f(7,8,9), geo2.vtx()[2]); + EXPECT_EQ(openvdb::Vec3f(10,11,12), geo2.vtx()[3]); - EXPECT_EQ(openvdb::Vec3I(0,1,2), geo.tri()[0]); - EXPECT_EQ(openvdb::Vec3I(1,2,3), geo.tri()[1]); + EXPECT_EQ(openvdb::Vec3I(0,1,2), geo2.tri()[0]); + EXPECT_EQ(openvdb::Vec3I(1,2,3), geo2.tri()[1]); - EXPECT_EQ(openvdb::Vec4I(0,1,2,3), geo.quad()[0]); + EXPECT_EQ(openvdb::Vec4I(0,1,2,3), geo2.quad()[0]); } {// write to file std::ofstream os("data/test.geo", std::ios_base::binary); @@ -395,19 +441,62 @@ TEST_F(Test_vdb_tool, Geometry) EXPECT_EQ(4, geo2.vtxCount()); EXPECT_EQ(2, geo2.triCount()); EXPECT_EQ(1, geo2.quadCount()); - EXPECT_EQ(openvdb::Vec3f(1,2,3), geo.bbox().min()); - EXPECT_EQ(openvdb::Vec3f(10,11,12), geo.bbox().max()); + EXPECT_EQ(openvdb::Vec3f(1,2,3), geo2.bbox().min()); + EXPECT_EQ(openvdb::Vec3f(10,11,12), geo2.bbox().max()); - EXPECT_EQ(openvdb::Vec3f(1,2,3), geo.vtx()[0]); - EXPECT_EQ(openvdb::Vec3f(4,5,6), geo.vtx()[1]); - EXPECT_EQ(openvdb::Vec3f(7,8,9), geo.vtx()[2]); - EXPECT_EQ(openvdb::Vec3f(10,11,12), geo.vtx()[3]); + EXPECT_EQ(openvdb::Vec3f(1,2,3), geo2.vtx()[0]); + EXPECT_EQ(openvdb::Vec3f(4,5,6), geo2.vtx()[1]); + EXPECT_EQ(openvdb::Vec3f(7,8,9), geo2.vtx()[2]); + EXPECT_EQ(openvdb::Vec3f(10,11,12), geo2.vtx()[3]); - EXPECT_EQ(openvdb::Vec3I(0,1,2), geo.tri()[0]); - EXPECT_EQ(openvdb::Vec3I(1,2,3), geo.tri()[1]); + EXPECT_EQ(openvdb::Vec3I(0,1,2), geo2.tri()[0]); + EXPECT_EQ(openvdb::Vec3I(1,2,3), geo2.tri()[1]); - EXPECT_EQ(openvdb::Vec4I(0,1,2,3), geo.quad()[0]); + EXPECT_EQ(openvdb::Vec4I(0,1,2,3), geo2.quad()[0]); + } + {// test readOFF and writeOFF + geo.write("data/test.off"); + openvdb::vdb_tool::Geometry geo2; + geo2.read("data/test.off"); + EXPECT_EQ(4, geo2.vtxCount()); + EXPECT_EQ(2, geo2.triCount()); + EXPECT_EQ(1, geo2.quadCount()); + EXPECT_EQ(openvdb::Vec3f(1,2,3), geo2.bbox().min()); + EXPECT_EQ(openvdb::Vec3f(10,11,12), geo2.bbox().max()); + + EXPECT_EQ(openvdb::Vec3f(1,2,3), geo2.vtx()[0]); + EXPECT_EQ(openvdb::Vec3f(4,5,6), geo2.vtx()[1]); + EXPECT_EQ(openvdb::Vec3f(7,8,9), geo2.vtx()[2]); + EXPECT_EQ(openvdb::Vec3f(10,11,12), geo2.vtx()[3]); + + EXPECT_EQ(openvdb::Vec3I(0,1,2), geo2.tri()[0]); + EXPECT_EQ(openvdb::Vec3I(1,2,3), geo2.tri()[1]); + + EXPECT_EQ(openvdb::Vec4I(0,1,2,3), geo2.quad()[0]); + } + #ifdef VDB_TOOL_USE_PDAL + {// read from PDAL-supported ASCII format file + // (NOTE: PDAL also supports other formats e.g. LAS, LAZ, E57, Draco, FBX, NumPy, OBJ,…) + + // write a test file + std::ofstream os("data/test.txt"); + os << "X,Y,Z\n"; + for (size_t i=0; i #include diff --git a/openvdb_houdini/openvdb_houdini/AXUtils.h b/openvdb_houdini/openvdb_houdini/AXUtils.h index 22a37f7dbc..ebbff04088 100644 --- a/openvdb_houdini/openvdb_houdini/AXUtils.h +++ b/openvdb_houdini/openvdb_houdini/AXUtils.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file ax/HoudiniAXUtils.h /// diff --git a/openvdb_houdini/openvdb_houdini/AttributeTransferUtil.h b/openvdb_houdini/openvdb_houdini/AttributeTransferUtil.h index 01b372bb66..387b3b260d 100644 --- a/openvdb_houdini/openvdb_houdini/AttributeTransferUtil.h +++ b/openvdb_houdini/openvdb_houdini/AttributeTransferUtil.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file AttributeTransferUtil.h /// @author FX R&D Simulation team diff --git a/openvdb_houdini/openvdb_houdini/CMakeLists.txt b/openvdb_houdini/openvdb_houdini/CMakeLists.txt index 4a52446380..204a153f9c 100644 --- a/openvdb_houdini/openvdb_houdini/CMakeLists.txt +++ b/openvdb_houdini/openvdb_houdini/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -40,7 +40,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(OpenVDBHoudini LANGUAGES CXX) diff --git a/openvdb_houdini/openvdb_houdini/COPYRIGHT b/openvdb_houdini/openvdb_houdini/COPYRIGHT index 4f8f1897d1..7ebccaf678 100644 --- a/openvdb_houdini/openvdb_houdini/COPYRIGHT +++ b/openvdb_houdini/openvdb_houdini/COPYRIGHT @@ -1,2 +1,2 @@ Copyright Contributors to the OpenVDB Project -SPDX-License-Identifier: MPL-2.0 \ No newline at end of file +SPDX-License-Identifier: Apache-2.0 \ No newline at end of file diff --git a/openvdb_houdini/openvdb_houdini/GEO_VDBTranslator.cc b/openvdb_houdini/openvdb_houdini/GEO_VDBTranslator.cc index 3f860f7f14..2bc1b787f7 100644 --- a/openvdb_houdini/openvdb_houdini/GEO_VDBTranslator.cc +++ b/openvdb_houdini/openvdb_houdini/GEO_VDBTranslator.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (c) diff --git a/openvdb_houdini/openvdb_houdini/GR_PrimVDBPoints.cc b/openvdb_houdini/openvdb_houdini/GR_PrimVDBPoints.cc index 229c95b41f..9608005294 100644 --- a/openvdb_houdini/openvdb_houdini/GR_PrimVDBPoints.cc +++ b/openvdb_houdini/openvdb_houdini/GR_PrimVDBPoints.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file GR_PrimVDBPoints.cc /// diff --git a/openvdb_houdini/openvdb_houdini/GT_GEOPrimCollectVDB.cc b/openvdb_houdini/openvdb_houdini/GT_GEOPrimCollectVDB.cc index db4a006285..2ce990c8ed 100644 --- a/openvdb_houdini/openvdb_houdini/GT_GEOPrimCollectVDB.cc +++ b/openvdb_houdini/openvdb_houdini/GT_GEOPrimCollectVDB.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (c) Side Effects Software Inc. diff --git a/openvdb_houdini/openvdb_houdini/GT_GEOPrimCollectVDB.h b/openvdb_houdini/openvdb_houdini/GT_GEOPrimCollectVDB.h index b150523d06..8b84a543c0 100644 --- a/openvdb_houdini/openvdb_houdini/GT_GEOPrimCollectVDB.h +++ b/openvdb_houdini/openvdb_houdini/GT_GEOPrimCollectVDB.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (c) Side Effects Software Inc. diff --git a/openvdb_houdini/openvdb_houdini/GU_VDBPointTools.cc b/openvdb_houdini/openvdb_houdini/GU_VDBPointTools.cc index 89a09f9398..2c40084461 100644 --- a/openvdb_houdini/openvdb_houdini/GU_VDBPointTools.cc +++ b/openvdb_houdini/openvdb_houdini/GU_VDBPointTools.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include "GU_VDBPointTools.h" diff --git a/openvdb_houdini/openvdb_houdini/GU_VDBPointTools.h b/openvdb_houdini/openvdb_houdini/GU_VDBPointTools.h index 91c8d8b04e..88f7cbeb92 100644 --- a/openvdb_houdini/openvdb_houdini/GU_VDBPointTools.h +++ b/openvdb_houdini/openvdb_houdini/GU_VDBPointTools.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file GU_VDBPointTools.h /// @author FX R&D OpenVDB team diff --git a/openvdb_houdini/openvdb_houdini/GeometryUtil.cc b/openvdb_houdini/openvdb_houdini/GeometryUtil.cc index 7868b3550e..bb409cb369 100644 --- a/openvdb_houdini/openvdb_houdini/GeometryUtil.cc +++ b/openvdb_houdini/openvdb_houdini/GeometryUtil.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file GeometryUtil.cc /// @author FX R&D Simulation team diff --git a/openvdb_houdini/openvdb_houdini/GeometryUtil.h b/openvdb_houdini/openvdb_houdini/GeometryUtil.h index 49928e68b3..0d6df88f44 100644 --- a/openvdb_houdini/openvdb_houdini/GeometryUtil.h +++ b/openvdb_houdini/openvdb_houdini/GeometryUtil.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file GeometryUtil.h /// @author FX R&D Simulation team diff --git a/openvdb_houdini/openvdb_houdini/LICENSE b/openvdb_houdini/openvdb_houdini/LICENSE index a612ad9813..d9a10c0d8e 100644 --- a/openvdb_houdini/openvdb_houdini/LICENSE +++ b/openvdb_houdini/openvdb_houdini/LICENSE @@ -1,373 +1,176 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/openvdb_houdini/openvdb_houdini/ParmFactory.cc b/openvdb_houdini/openvdb_houdini/ParmFactory.cc index 05fb38b067..c1182d19d8 100644 --- a/openvdb_houdini/openvdb_houdini/ParmFactory.cc +++ b/openvdb_houdini/openvdb_houdini/ParmFactory.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file ParmFactory.cc /// @author FX R&D OpenVDB team diff --git a/openvdb_houdini/openvdb_houdini/ParmFactory.h b/openvdb_houdini/openvdb_houdini/ParmFactory.h index 77c0b33fe6..01abda8e2a 100644 --- a/openvdb_houdini/openvdb_houdini/ParmFactory.h +++ b/openvdb_houdini/openvdb_houdini/ParmFactory.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file ParmFactory.h /// @author FX R&D OpenVDB team diff --git a/openvdb_houdini/openvdb_houdini/PointUtils.cc b/openvdb_houdini/openvdb_houdini/PointUtils.cc index a61a31eb49..1bf6b2529c 100644 --- a/openvdb_houdini/openvdb_houdini/PointUtils.cc +++ b/openvdb_houdini/openvdb_houdini/PointUtils.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file PointUtils.cc /// @authors Dan Bailey, Nick Avramoussis, Richard Kwok diff --git a/openvdb_houdini/openvdb_houdini/PointUtils.h b/openvdb_houdini/openvdb_houdini/PointUtils.h index 0bf90fe23b..4e6b33f2ae 100644 --- a/openvdb_houdini/openvdb_houdini/PointUtils.h +++ b/openvdb_houdini/openvdb_houdini/PointUtils.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file PointUtils.h /// diff --git a/openvdb_houdini/openvdb_houdini/SHOP_OpenVDB_Points.cc b/openvdb_houdini/openvdb_houdini/SHOP_OpenVDB_Points.cc index 1dcc78db47..755e0b399c 100644 --- a/openvdb_houdini/openvdb_houdini/SHOP_OpenVDB_Points.cc +++ b/openvdb_houdini/openvdb_houdini/SHOP_OpenVDB_Points.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file SHOP_OpenVDB_Points.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_NodeVDB.cc b/openvdb_houdini/openvdb_houdini/SOP_NodeVDB.cc index 5385394764..7aaad72278 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_NodeVDB.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_NodeVDB.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_NodeVDB.cc /// @author FX R&D OpenVDB team diff --git a/openvdb_houdini/openvdb_houdini/SOP_NodeVDB.h b/openvdb_houdini/openvdb_houdini/SOP_NodeVDB.h index 88da9e7f4f..3ad09ade51 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_NodeVDB.h +++ b/openvdb_houdini/openvdb_houdini/SOP_NodeVDB.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_NodeVDB.h /// @author FX R&D OpenVDB team diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_AX.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_AX.cc index 92c147978e..f77803503a 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_AX.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_AX.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// /// @file SOP_OpenVDB_AX.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Activate.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Activate.cc index 6346648c29..c9ae6a40fe 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Activate.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Activate.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Activate.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Advect.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Advect.cc index 8b44e50059..e9e3ae94b5 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Advect.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Advect.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Advect.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Advect_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Advect_Points.cc index 23a4f680e3..7222754eb9 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Advect_Points.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Advect_Points.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Advect_Points.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Analysis.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Analysis.cc index 1f2a1a658b..719d48e61f 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Analysis.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Analysis.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Analysis.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Clip.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Clip.cc index 79e844b771..7a808110f7 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Clip.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Clip.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file SOP_OpenVDB_Clip.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Combine.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Combine.cc index 67a536ce37..f12991ea38 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Combine.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Combine.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Combine.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Convert.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Convert.cc index 888983a40d..4db5918210 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Convert.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Convert.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Convert.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Create.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Create.cc index de822accaa..173f1f7d7c 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Create.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Create.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Create.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Densify.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Densify.cc index 12749b86dc..867ac2bd79 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Densify.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Densify.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Densify.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Diagnostics.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Diagnostics.cc index 2219c840e3..d362adb438 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Diagnostics.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Diagnostics.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Diagnostics.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Extrapolate.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Extrapolate.cc index 0da59de659..c057dfdddb 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Extrapolate.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Extrapolate.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // // @file SOP_OpenVDB_Extrapolate.cc // diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Fill.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Fill.cc index 58f09c1d35..446889c3ce 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Fill.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Fill.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Fill.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Filter.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Filter.cc index a836e08a82..a4d7a07acf 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Filter.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Filter.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Filter.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Filter_Level_Set.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Filter_Level_Set.cc index aea85ebee9..79da2d1666 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Filter_Level_Set.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Filter_Level_Set.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file SOP_OpenVDB_Filter_Level_Set.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Fracture.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Fracture.cc index 6e922aff63..2402aa361f 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Fracture.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Fracture.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Fracture.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_From_Particles.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_From_Particles.cc index d1725d84c8..1718f65597 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_From_Particles.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_From_Particles.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_From_Particles.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_From_Polygons.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_From_Polygons.cc index e6d3b800f7..f1458cc7fa 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_From_Polygons.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_From_Polygons.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_From_Polygons.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_LOD.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_LOD.cc index aa3aa2d7fe..348524432f 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_LOD.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_LOD.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_LOD.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Merge.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Merge.cc index 6c2c88c0a1..673d673b10 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Merge.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Merge.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file SOP_OpenVDB_Merge.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Metadata.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Metadata.cc index c41ebd7e52..945139b2ab 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Metadata.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Metadata.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Metadata.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Morph_Level_Set.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Morph_Level_Set.cc index 84d6d224fc..3cdd95c4f1 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Morph_Level_Set.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Morph_Level_Set.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Morph_Level_Set.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Noise.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Noise.cc index 0fd36f705d..fbd99c6f20 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Noise.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Noise.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Noise.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Occlusion_Mask.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Occlusion_Mask.cc index 3dc1bbb22b..c094eebcfc 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Occlusion_Mask.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Occlusion_Mask.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Occlusion_Mask.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Platonic.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Platonic.cc index 103c443ec6..cef2eee31d 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Platonic.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Platonic.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Platonic.cc /// @author FX R&D OpenVDB team diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Points_Convert.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Points_Convert.cc index c4129cfa80..800ea0e636 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Points_Convert.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Points_Convert.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file SOP_OpenVDB_Points_Convert.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Points_Delete.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Points_Delete.cc index cbe541fd1b..3e585b4b3b 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Points_Delete.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Points_Delete.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file SOP_OpenVDB_Points_Delete.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Points_Group.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Points_Group.cc index 7e3780fb76..dd98495a53 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Points_Group.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Points_Group.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file SOP_OpenVDB_Points_Group.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Potential_Flow.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Potential_Flow.cc index b683a2310d..5fb25e046d 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Potential_Flow.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Potential_Flow.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file SOP_OpenVDB_Potential_Flow.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Prune.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Prune.cc index 86f93d407b..dbe2545e16 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Prune.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Prune.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Prune.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Frustum.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Frustum.cc index a220a00898..8458bab4e0 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Frustum.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Frustum.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file SOP_OpenVDB_Rasterize_Frustum.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc index fc54092992..9276832c5f 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rasterize_Points.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Rasterize_Points.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Ray.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Ray.cc index 61893f5eeb..93ff9ea647 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Ray.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Ray.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Ray.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Read.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Read.cc index 13cc41e2a5..2ed8508e82 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Read.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Read.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Read.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rebuild_Level_Set.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rebuild_Level_Set.cc index 0c6ca20b39..b1bf1d7c08 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rebuild_Level_Set.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Rebuild_Level_Set.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Rebuild_Level_Set.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Remap.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Remap.cc index 0ab99b752d..97aebf75bc 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Remap.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Remap.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Remap.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Remove_Divergence.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Remove_Divergence.cc index 3b880ed4a9..0add109604 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Remove_Divergence.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Remove_Divergence.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Remove_Divergence.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Resample.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Resample.cc index a6627b57d9..ceb346b5f7 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Resample.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Resample.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// /// @file SOP_OpenVDB_Resample.cc // diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc index 03990f9e63..d22eaced62 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sample_Points.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Sample_Points.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Scatter.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Scatter.cc index fc08051205..3598282725 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Scatter.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Scatter.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Scatter.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Segment.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Segment.cc index 7f685ce56e..3f6087d0e8 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Segment.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Segment.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Segment.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sort_Points.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sort_Points.cc index 8ea0a49a5a..6daa6dc249 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sort_Points.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Sort_Points.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Sort_Points.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_To_Polygons.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_To_Polygons.cc index cff8714837..742c47be21 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_To_Polygons.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_To_Polygons.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_To_Polygons.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_To_Spheres.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_To_Spheres.cc index bb921a305e..50e8597a06 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_To_Spheres.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_To_Spheres.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_To_Spheres.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Topology_To_Level_Set.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Topology_To_Level_Set.cc index 470eb1c29b..9003bd2f8e 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Topology_To_Level_Set.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Topology_To_Level_Set.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Topology_To_Level_Set.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Transform.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Transform.cc index d3823c2933..0c8e153a69 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Transform.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Transform.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Transform.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Vector_Merge.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Vector_Merge.cc index e5d68ddf7a..eaf893cb94 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Vector_Merge.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Vector_Merge.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Vector_Merge.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Vector_Split.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Vector_Split.cc index 3f9ee55d51..e26cf63666 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Vector_Split.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Vector_Split.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Vector_Split.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Visualize.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Visualize.cc index 20c71814e0..e7fbcc282b 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Visualize.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Visualize.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Visualize.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Write.cc b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Write.cc index 3d710a4b05..5c655116c2 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Write.cc +++ b/openvdb_houdini/openvdb_houdini/SOP_OpenVDB_Write.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file SOP_OpenVDB_Write.cc /// diff --git a/openvdb_houdini/openvdb_houdini/SOP_VDBVerbUtils.h b/openvdb_houdini/openvdb_houdini/SOP_VDBVerbUtils.h index 8b9dc51d56..3e63f3563e 100644 --- a/openvdb_houdini/openvdb_houdini/SOP_VDBVerbUtils.h +++ b/openvdb_houdini/openvdb_houdini/SOP_VDBVerbUtils.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (c) diff --git a/openvdb_houdini/openvdb_houdini/UT_VDBTools.h b/openvdb_houdini/openvdb_houdini/UT_VDBTools.h index df17226b0e..aa91601bc9 100644 --- a/openvdb_houdini/openvdb_houdini/UT_VDBTools.h +++ b/openvdb_houdini/openvdb_houdini/UT_VDBTools.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file UT_VDBTools.h /// @author FX R&D Simulation team diff --git a/openvdb_houdini/openvdb_houdini/UT_VDBUtils.cc b/openvdb_houdini/openvdb_houdini/UT_VDBUtils.cc index 568273ebc8..c962e300d1 100644 --- a/openvdb_houdini/openvdb_houdini/UT_VDBUtils.cc +++ b/openvdb_houdini/openvdb_houdini/UT_VDBUtils.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (c) Side Effects Software Inc. diff --git a/openvdb_houdini/openvdb_houdini/UT_VDBUtils.h b/openvdb_houdini/openvdb_houdini/UT_VDBUtils.h index 44bb14b8b6..641447436f 100644 --- a/openvdb_houdini/openvdb_houdini/UT_VDBUtils.h +++ b/openvdb_houdini/openvdb_houdini/UT_VDBUtils.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (c) Side Effects Software Inc. diff --git a/openvdb_houdini/openvdb_houdini/Utils.cc b/openvdb_houdini/openvdb_houdini/Utils.cc index 17a18e1890..cd791453ec 100644 --- a/openvdb_houdini/openvdb_houdini/Utils.cc +++ b/openvdb_houdini/openvdb_houdini/Utils.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file Utils.cc /// @author FX R&D Simulation team diff --git a/openvdb_houdini/openvdb_houdini/Utils.h b/openvdb_houdini/openvdb_houdini/Utils.h index 5f3ab0221d..8a0469c86e 100644 --- a/openvdb_houdini/openvdb_houdini/Utils.h +++ b/openvdb_houdini/openvdb_houdini/Utils.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file openvdb_houdini/Utils.h /// @author FX R&D Simulation team diff --git a/openvdb_houdini/openvdb_houdini/VRAY_OpenVDB_Points.cc b/openvdb_houdini/openvdb_houdini/VRAY_OpenVDB_Points.cc index f5b510c29e..89c808f406 100644 --- a/openvdb_houdini/openvdb_houdini/VRAY_OpenVDB_Points.cc +++ b/openvdb_houdini/openvdb_houdini/VRAY_OpenVDB_Points.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file VRAY_OpenVDB_Points.cc /// diff --git a/openvdb_houdini/openvdb_houdini/abitest/CMakeLists.txt b/openvdb_houdini/openvdb_houdini/abitest/CMakeLists.txt index 69da04e70c..62c476d43f 100644 --- a/openvdb_houdini/openvdb_houdini/abitest/CMakeLists.txt +++ b/openvdb_houdini/openvdb_houdini/abitest/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -12,7 +12,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(OpenVDBHoudiniABITest) diff --git a/openvdb_houdini/openvdb_houdini/abitest/TestABI.cc b/openvdb_houdini/openvdb_houdini/abitest/TestABI.cc index ccb1d8fcf7..0c5edada33 100644 --- a/openvdb_houdini/openvdb_houdini/abitest/TestABI.cc +++ b/openvdb_houdini/openvdb_houdini/abitest/TestABI.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include #include diff --git a/openvdb_houdini/openvdb_houdini/abitest/TestABI.h b/openvdb_houdini/openvdb_houdini/abitest/TestABI.h index 00e0dcdebf..d0ddb48439 100644 --- a/openvdb_houdini/openvdb_houdini/abitest/TestABI.h +++ b/openvdb_houdini/openvdb_houdini/abitest/TestABI.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 const char* getABI(); const char* getNamespace(); diff --git a/openvdb_houdini/openvdb_houdini/abitest/main.cc b/openvdb_houdini/openvdb_houdini/abitest/main.cc index 8ef872bd99..e1b805c705 100644 --- a/openvdb_houdini/openvdb_houdini/abitest/main.cc +++ b/openvdb_houdini/openvdb_houdini/abitest/main.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #include diff --git a/openvdb_houdini/openvdb_houdini/geometry.cc b/openvdb_houdini/openvdb_houdini/geometry.cc index c11ddde631..1d94c15053 100644 --- a/openvdb_houdini/openvdb_houdini/geometry.cc +++ b/openvdb_houdini/openvdb_houdini/geometry.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file geometry.cc /// @author FX R&D OpenVDB team diff --git a/openvdb_houdini/openvdb_houdini/geometry.h b/openvdb_houdini/openvdb_houdini/geometry.h index a9d7665813..6426ec4e10 100644 --- a/openvdb_houdini/openvdb_houdini/geometry.h +++ b/openvdb_houdini/openvdb_houdini/geometry.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 // /// @file geoemetry.h /// @author FX R&D OpenVDB team diff --git a/openvdb_houdini/openvdb_houdini/pythonrc.py b/openvdb_houdini/openvdb_houdini/pythonrc.py index 46b97c714b..458e723f9f 100644 --- a/openvdb_houdini/openvdb_houdini/pythonrc.py +++ b/openvdb_houdini/openvdb_houdini/pythonrc.py @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # Startup script to set the visibility of (and otherwise customize) # open-source (ASWF) OpenVDB nodes and their native Houdini equivalents diff --git a/openvdb_houdini/openvdb_houdini/reference/GEO_PrimVDB.cc b/openvdb_houdini/openvdb_houdini/reference/GEO_PrimVDB.cc index 33ad00fc2e..13df7c3fbf 100644 --- a/openvdb_houdini/openvdb_houdini/reference/GEO_PrimVDB.cc +++ b/openvdb_houdini/openvdb_houdini/reference/GEO_PrimVDB.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (c) Side Effects Software Inc. diff --git a/openvdb_houdini/openvdb_houdini/reference/GEO_PrimVDB.h b/openvdb_houdini/openvdb_houdini/reference/GEO_PrimVDB.h index 34fe700523..04b934b6f9 100644 --- a/openvdb_houdini/openvdb_houdini/reference/GEO_PrimVDB.h +++ b/openvdb_houdini/openvdb_houdini/reference/GEO_PrimVDB.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (c) Side Effects Software Inc. diff --git a/openvdb_houdini/openvdb_houdini/reference/GU_PrimVDB.cc b/openvdb_houdini/openvdb_houdini/reference/GU_PrimVDB.cc index 212a1ecb4b..78509a12d2 100644 --- a/openvdb_houdini/openvdb_houdini/reference/GU_PrimVDB.cc +++ b/openvdb_houdini/openvdb_houdini/reference/GU_PrimVDB.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (c) Side Effects Software Inc. diff --git a/openvdb_houdini/openvdb_houdini/reference/GU_PrimVDB.h b/openvdb_houdini/openvdb_houdini/reference/GU_PrimVDB.h index c0dfeb62e4..eb4a03820e 100644 --- a/openvdb_houdini/openvdb_houdini/reference/GU_PrimVDB.h +++ b/openvdb_houdini/openvdb_houdini/reference/GU_PrimVDB.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /* * Copyright (c) Side Effects Software Inc. diff --git a/openvdb_maya/openvdb_maya/CMakeLists.txt b/openvdb_maya/openvdb_maya/CMakeLists.txt index 855210174b..62b9bf6fb5 100644 --- a/openvdb_maya/openvdb_maya/CMakeLists.txt +++ b/openvdb_maya/openvdb_maya/CMakeLists.txt @@ -1,5 +1,5 @@ # Copyright Contributors to the OpenVDB Project -# SPDX-License-Identifier: MPL-2.0 +# SPDX-License-Identifier: Apache-2.0 # #[=======================================================================[ @@ -7,7 +7,7 @@ #]=======================================================================] -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.20) project(OpenVDBMaya LANGUAGES CXX) message(WARNING "The OpenVDB Maya plugin is currently unmaintained. The plugin " diff --git a/openvdb_maya/openvdb_maya/COPYRIGHT b/openvdb_maya/openvdb_maya/COPYRIGHT index 4f8f1897d1..7ebccaf678 100644 --- a/openvdb_maya/openvdb_maya/COPYRIGHT +++ b/openvdb_maya/openvdb_maya/COPYRIGHT @@ -1,2 +1,2 @@ Copyright Contributors to the OpenVDB Project -SPDX-License-Identifier: MPL-2.0 \ No newline at end of file +SPDX-License-Identifier: Apache-2.0 \ No newline at end of file diff --git a/openvdb_maya/openvdb_maya/LICENSE b/openvdb_maya/openvdb_maya/LICENSE index a612ad9813..d9a10c0d8e 100644 --- a/openvdb_maya/openvdb_maya/LICENSE +++ b/openvdb_maya/openvdb_maya/LICENSE @@ -1,373 +1,176 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS diff --git a/openvdb_maya/openvdb_maya/OpenVDBCopyNode.cc b/openvdb_maya/openvdb_maya/OpenVDBCopyNode.cc index 09fc45db7f..48198c614e 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBCopyNode.cc +++ b/openvdb_maya/openvdb_maya/OpenVDBCopyNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author FX R&D OpenVDB team diff --git a/openvdb_maya/openvdb_maya/OpenVDBData.cc b/openvdb_maya/openvdb_maya/OpenVDBData.cc index e8dd866de9..a3aa3e8bdb 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBData.cc +++ b/openvdb_maya/openvdb_maya/OpenVDBData.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file OpenVDBData.cc /// @author FX R&D OpenVDB team diff --git a/openvdb_maya/openvdb_maya/OpenVDBData.h b/openvdb_maya/openvdb_maya/OpenVDBData.h index 9612361375..0b2fba5799 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBData.h +++ b/openvdb_maya/openvdb_maya/OpenVDBData.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file OpenVDBData.h /// @author FX R&D OpenVDB team diff --git a/openvdb_maya/openvdb_maya/OpenVDBFilterNode.cc b/openvdb_maya/openvdb_maya/OpenVDBFilterNode.cc index 980c234ac4..bd137fe72b 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBFilterNode.cc +++ b/openvdb_maya/openvdb_maya/OpenVDBFilterNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author FX R&D OpenVDB team diff --git a/openvdb_maya/openvdb_maya/OpenVDBFromMayaFluidNode.cc b/openvdb_maya/openvdb_maya/OpenVDBFromMayaFluidNode.cc index eaf1a18ae5..66b8ef7219 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBFromMayaFluidNode.cc +++ b/openvdb_maya/openvdb_maya/OpenVDBFromMayaFluidNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author FX R&D OpenVDB team diff --git a/openvdb_maya/openvdb_maya/OpenVDBFromPolygonsNode.cc b/openvdb_maya/openvdb_maya/OpenVDBFromPolygonsNode.cc index f6b7c8495a..f40225c3d1 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBFromPolygonsNode.cc +++ b/openvdb_maya/openvdb_maya/OpenVDBFromPolygonsNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author FX R&D OpenVDB team diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc index d63ed1591e..5c31b5fd9d 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc +++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author FX R&D OpenVDB team diff --git a/openvdb_maya/openvdb_maya/OpenVDBPlugin.h b/openvdb_maya/openvdb_maya/OpenVDBPlugin.h index 5bb75dc211..76220d2779 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBPlugin.h +++ b/openvdb_maya/openvdb_maya/OpenVDBPlugin.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author FX R&D OpenVDB team diff --git a/openvdb_maya/openvdb_maya/OpenVDBReadNode.cc b/openvdb_maya/openvdb_maya/OpenVDBReadNode.cc index e8278c96fc..9cc8d1c69b 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBReadNode.cc +++ b/openvdb_maya/openvdb_maya/OpenVDBReadNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author FX R&D OpenVDB team diff --git a/openvdb_maya/openvdb_maya/OpenVDBToPolygonsNode.cc b/openvdb_maya/openvdb_maya/OpenVDBToPolygonsNode.cc index 3289372d0b..7ca0bf9b7a 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBToPolygonsNode.cc +++ b/openvdb_maya/openvdb_maya/OpenVDBToPolygonsNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file OpenVDBToPolygonsNode.cc /// diff --git a/openvdb_maya/openvdb_maya/OpenVDBTransformNode.cc b/openvdb_maya/openvdb_maya/OpenVDBTransformNode.cc index 5850b21079..683a2ca8e7 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBTransformNode.cc +++ b/openvdb_maya/openvdb_maya/OpenVDBTransformNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file OpenVDBTransformNode.cc /// @author FX R&D OpenVDB team diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.cc b/openvdb_maya/openvdb_maya/OpenVDBUtil.cc index 5b6c88a2d0..2db8c4131b 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBUtil.cc +++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file OpenVDBUtil.cc /// diff --git a/openvdb_maya/openvdb_maya/OpenVDBUtil.h b/openvdb_maya/openvdb_maya/OpenVDBUtil.h index 6a04b1eaf5..f1524344ec 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBUtil.h +++ b/openvdb_maya/openvdb_maya/OpenVDBUtil.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author FX R&D OpenVDB team diff --git a/openvdb_maya/openvdb_maya/OpenVDBVisualizeNode.cc b/openvdb_maya/openvdb_maya/OpenVDBVisualizeNode.cc index 74d4dea4b9..d76e3ecb7c 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBVisualizeNode.cc +++ b/openvdb_maya/openvdb_maya/OpenVDBVisualizeNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @file OpenVDBVisualizeNode.cc /// diff --git a/openvdb_maya/openvdb_maya/OpenVDBWriteNode.cc b/openvdb_maya/openvdb_maya/OpenVDBWriteNode.cc index 2dcff28c29..f4442bb558 100644 --- a/openvdb_maya/openvdb_maya/OpenVDBWriteNode.cc +++ b/openvdb_maya/openvdb_maya/OpenVDBWriteNode.cc @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 /// @author FX R&D OpenVDB team diff --git a/openvdb_wolfram/OpenVDBLink/AggregateData.m b/openvdb_wolfram/OpenVDBLink/AggregateData.m index 621fb49258..b9c0be479c 100755 --- a/openvdb_wolfram/OpenVDBLink/AggregateData.m +++ b/openvdb_wolfram/OpenVDBLink/AggregateData.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/BuildSettings.m b/openvdb_wolfram/OpenVDBLink/BuildSettings.m index a1bd056d5a..743bf4c036 100644 --- a/openvdb_wolfram/OpenVDBLink/BuildSettings.m +++ b/openvdb_wolfram/OpenVDBLink/BuildSettings.m @@ -2,7 +2,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) Switch[$OperatingSystem, diff --git a/openvdb_wolfram/OpenVDBLink/CSG.m b/openvdb_wolfram/OpenVDBLink/CSG.m index aeed2682e6..715f47408e 100755 --- a/openvdb_wolfram/OpenVDBLink/CSG.m +++ b/openvdb_wolfram/OpenVDBLink/CSG.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/DistanceMeasure.m b/openvdb_wolfram/OpenVDBLink/DistanceMeasure.m index 4b9764c867..5958fe8d66 100755 --- a/openvdb_wolfram/OpenVDBLink/DistanceMeasure.m +++ b/openvdb_wolfram/OpenVDBLink/DistanceMeasure.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/Filter.m b/openvdb_wolfram/OpenVDBLink/Filter.m index dbaafc7ade..bb6cee4749 100755 --- a/openvdb_wolfram/OpenVDBLink/Filter.m +++ b/openvdb_wolfram/OpenVDBLink/Filter.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/FogVolume.m b/openvdb_wolfram/OpenVDBLink/FogVolume.m index 33cfd4c571..7e18f9c28d 100755 --- a/openvdb_wolfram/OpenVDBLink/FogVolume.m +++ b/openvdb_wolfram/OpenVDBLink/FogVolume.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/Getters.m b/openvdb_wolfram/OpenVDBLink/Getters.m index d803fc622b..2172212e41 100755 --- a/openvdb_wolfram/OpenVDBLink/Getters.m +++ b/openvdb_wolfram/OpenVDBLink/Getters.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/Grids.m b/openvdb_wolfram/OpenVDBLink/Grids.m index caa12bceab..4db8e9925f 100755 --- a/openvdb_wolfram/OpenVDBLink/Grids.m +++ b/openvdb_wolfram/OpenVDBLink/Grids.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/IO.m b/openvdb_wolfram/OpenVDBLink/IO.m index c1fe5d531e..eabe25abbe 100755 --- a/openvdb_wolfram/OpenVDBLink/IO.m +++ b/openvdb_wolfram/OpenVDBLink/IO.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/Image.m b/openvdb_wolfram/OpenVDBLink/Image.m index 56be809d91..40bca419e6 100755 --- a/openvdb_wolfram/OpenVDBLink/Image.m +++ b/openvdb_wolfram/OpenVDBLink/Image.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/LTemplate.m b/openvdb_wolfram/OpenVDBLink/LTemplate.m index e64225658e..e63b47e670 100755 --- a/openvdb_wolfram/OpenVDBLink/LTemplate.m +++ b/openvdb_wolfram/OpenVDBLink/LTemplate.m @@ -2,7 +2,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Text:: *) diff --git a/openvdb_wolfram/OpenVDBLink/LevelSet.m b/openvdb_wolfram/OpenVDBLink/LevelSet.m index fd6aba76ca..c79ed106c5 100755 --- a/openvdb_wolfram/OpenVDBLink/LevelSet.m +++ b/openvdb_wolfram/OpenVDBLink/LevelSet.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/Measure.m b/openvdb_wolfram/OpenVDBLink/Measure.m index 66200fba5a..0827397515 100755 --- a/openvdb_wolfram/OpenVDBLink/Measure.m +++ b/openvdb_wolfram/OpenVDBLink/Measure.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/Mesh.m b/openvdb_wolfram/OpenVDBLink/Mesh.m index 31406b0c5f..f3bfeacfc9 100755 --- a/openvdb_wolfram/OpenVDBLink/Mesh.m +++ b/openvdb_wolfram/OpenVDBLink/Mesh.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/Messages.m b/openvdb_wolfram/OpenVDBLink/Messages.m index 9288206cf7..ae32998e96 100755 --- a/openvdb_wolfram/OpenVDBLink/Messages.m +++ b/openvdb_wolfram/OpenVDBLink/Messages.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/Morphology.m b/openvdb_wolfram/OpenVDBLink/Morphology.m index bc2d5ab5ed..a633c3be09 100755 --- a/openvdb_wolfram/OpenVDBLink/Morphology.m +++ b/openvdb_wolfram/OpenVDBLink/Morphology.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/OpenVDBLink.m b/openvdb_wolfram/OpenVDBLink/OpenVDBLink.m index 4c6180fd9a..b381800d39 100755 --- a/openvdb_wolfram/OpenVDBLink/OpenVDBLink.m +++ b/openvdb_wolfram/OpenVDBLink/OpenVDBLink.m @@ -18,7 +18,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/Render.m b/openvdb_wolfram/OpenVDBLink/Render.m index bef7fc09a5..9b93fb0465 100755 --- a/openvdb_wolfram/OpenVDBLink/Render.m +++ b/openvdb_wolfram/OpenVDBLink/Render.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/Setters.m b/openvdb_wolfram/OpenVDBLink/Setters.m index 2ade608b24..0f1686b5e6 100755 --- a/openvdb_wolfram/OpenVDBLink/Setters.m +++ b/openvdb_wolfram/OpenVDBLink/Setters.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBBoolGrid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBBoolGrid.h index c0e7fd4344..a3335c35ba 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBBoolGrid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBBoolGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBBOOLGRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBBOOLGRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBByteGrid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBByteGrid.h index c8bbe1e418..4499437e76 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBByteGrid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBByteGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBBYTEGRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBBYTEGRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBDoubleGrid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBDoubleGrid.h index 4e6fca87d6..9040ce415b 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBDoubleGrid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBDoubleGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBDOUBLEGRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBDOUBLEGRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBFloatGrid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBFloatGrid.h index 63b6b09e42..4e5e65bfe2 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBFloatGrid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBFloatGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBFLOATGRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBFLOATGRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBInt32Grid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBInt32Grid.h index 0a5cec331c..90265dc175 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBInt32Grid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBInt32Grid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBINT32GRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBINT32GRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBInt64Grid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBInt64Grid.h index dcfcc0d513..2808914bff 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBInt64Grid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBInt64Grid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBINT64GRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBINT64GRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBMaskGrid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBMaskGrid.h index 9b225abb8c..21b24f7262 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBMaskGrid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBMaskGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBMASKGRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBMASKGRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBUInt32Grid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBUInt32Grid.h index e84dce9e0e..5c3e839fce 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBUInt32Grid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBUInt32Grid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBUINT32GRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBUINT32GRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec2DGrid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec2DGrid.h index 4a3e82d436..f3ea25b689 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec2DGrid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec2DGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBVEC2DGRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBVEC2DGRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec2IGrid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec2IGrid.h index 3a55c6c727..1312709b18 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec2IGrid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec2IGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBVEC2IGRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBVEC2IGRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec2SGrid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec2SGrid.h index 8c0c8812a9..00dd795a88 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec2SGrid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec2SGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBVEC2SGRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBVEC2SGRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec3DGrid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec3DGrid.h index 84037028ae..7eb4a3b4e5 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec3DGrid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec3DGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBVEC3DGRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBVEC3DGRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec3IGrid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec3IGrid.h index a1371e38f5..59d3d2b6dc 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec3IGrid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec3IGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBVEC3IGRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBVEC3IGRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec3SGrid.h b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec3SGrid.h index 9318045813..aab5f062ad 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec3SGrid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/ExplicitGrids/OpenVDBVec3SGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_EXPLICITGRIDS_OPENVDBVEC3SGRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_EXPLICITGRIDS_OPENVDBVEC3SGRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/GlueTensors.h b/openvdb_wolfram/OpenVDBLink/Source/GlueTensors.h index a1b93e4e90..cb8b42e03a 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/GlueTensors.h +++ b/openvdb_wolfram/OpenVDBLink/Source/GlueTensors.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_GLUETENSORS_HAS_BEEN_INCLUDED #define OPENVDBLINK_GLUETENSORS_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBCommon.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBCommon.h index e8037a5788..2cea610554 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBCommon.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBCommon.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBCOMMON_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBCOMMON_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid.h index 36804f8ce7..cc67ee0260 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/AggregateData.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/AggregateData.h index bea5f4605c..2b23ab2c84 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/AggregateData.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/AggregateData.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_AGGREGATEDATA_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_AGGREGATEDATA_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/CSG.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/CSG.h index 62042d4b2e..1ae4279a01 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/CSG.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/CSG.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_CSG_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_CSG_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/DistanceMeasure.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/DistanceMeasure.h index 319ccb9ea1..5481f3bd2c 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/DistanceMeasure.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/DistanceMeasure.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_DISTANCEMEASURE_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_DISTANCEMEASURE_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Filter.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Filter.h index 5149b012fb..5b6891d38b 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Filter.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Filter.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_FILTER_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_FILTER_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/FogVolume.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/FogVolume.h index c2a6d66ea0..615526fcfe 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/FogVolume.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/FogVolume.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_FOGVOLUME_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_FOGVOLUME_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Getters.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Getters.h index 1bd5c07011..7212a72bc2 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Getters.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Getters.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_GETTERS_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_GETTERS_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/IO.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/IO.h index 93bd325448..b925447d2f 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/IO.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/IO.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_IO_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_IO_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Image.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Image.h index ddd7aea554..7213ca21ba 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Image.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Image.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_IMAGE_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_IMAGE_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/LevelSetCreation.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/LevelSetCreation.h index e72f75bf3a..cd1ffe23d7 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/LevelSetCreation.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/LevelSetCreation.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_LEVELSETCREATION_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_LEVELSETCREATION_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Measure.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Measure.h index 2c41791ca8..4de3ee8fec 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Measure.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Measure.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_MEASURE_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_MEASURE_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Mesh.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Mesh.h index 444c2bf1f4..0dde68c017 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Mesh.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Mesh.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_MESH_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_MESH_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Metadata.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Metadata.h index 9cb3d8ccf3..c8582802ee 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Metadata.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Metadata.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_METADATA_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_METADATA_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Morphology.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Morphology.h index bb19177424..3ea35cafa2 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Morphology.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Morphology.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_MORPHOLOGY_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_MORPHOLOGY_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Render.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Render.h index 7895b656f9..5038287a17 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Render.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Render.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_RENDER_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_RENDER_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Setters.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Setters.h index 6477cd2e0d..bc717705bb 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Setters.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Setters.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_SETTERS_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_SETTERS_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Transform.h b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Transform.h index af1d5421a0..d710707518 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Transform.h +++ b/openvdb_wolfram/OpenVDBLink/Source/OpenVDBGrid/Transform.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_OPENVDBGRID_TRANSFORM_HAS_BEEN_INCLUDED #define OPENVDBLINK_OPENVDBGRID_TRANSFORM_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Aggregate.h b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Aggregate.h index a7c003fccf..a8beec46d0 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Aggregate.h +++ b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Aggregate.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_UTILITIES_AGGREGATE_HAS_BEEN_INCLUDED #define OPENVDBLINK_UTILITIES_AGGREGATE_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Distance.h b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Distance.h index cd7729966c..4266294cf0 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Distance.h +++ b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Distance.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_UTILITIES_DISTANCE_HAS_BEEN_INCLUDED #define OPENVDBLINK_UTILITIES_DISTANCE_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Image.h b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Image.h index 3a8e82895c..e8038af1bf 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Image.h +++ b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Image.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_UTILITIES_IMAGE_HAS_BEEN_INCLUDED #define OPENVDBLINK_UTILITIES_IMAGE_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/Utilities/LevelSet.h b/openvdb_wolfram/OpenVDBLink/Source/Utilities/LevelSet.h index 9fa402fc18..930c21a7cb 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/Utilities/LevelSet.h +++ b/openvdb_wolfram/OpenVDBLink/Source/Utilities/LevelSet.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_UTILITIES_LEVELSET_HAS_BEEN_INCLUDED #define OPENVDBLINK_UTILITIES_LEVELSET_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Mesh.h b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Mesh.h index c2f84c34e8..bd00b6e5b1 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Mesh.h +++ b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Mesh.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_UTILITIES_MESH_HAS_BEEN_INCLUDED #define OPENVDBLINK_UTILITIES_MESH_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Metadata.h b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Metadata.h index c1d65780b5..49d99c4295 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Metadata.h +++ b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Metadata.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_UTILITIES_METADATA_HAS_BEEN_INCLUDED #define OPENVDBLINK_UTILITIES_METADATA_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Render.h b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Render.h index 6be0220a4d..78f49e6b9e 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Render.h +++ b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Render.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_UTILITIES_RENDER_HAS_BEEN_INCLUDED #define OPENVDBLINK_UTILITIES_RENDER_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Transform.h b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Transform.h index f6e286cf3f..cf5bb94c0a 100644 --- a/openvdb_wolfram/OpenVDBLink/Source/Utilities/Transform.h +++ b/openvdb_wolfram/OpenVDBLink/Source/Utilities/Transform.h @@ -1,5 +1,5 @@ // Copyright Contributors to the OpenVDB Project -// SPDX-License-Identifier: MPL-2.0 +// SPDX-License-Identifier: Apache-2.0 #ifndef OPENVDBLINK_UTILITIES_TRANSFORM_HAS_BEEN_INCLUDED #define OPENVDBLINK_UTILITIES_TRANSFORM_HAS_BEEN_INCLUDED diff --git a/openvdb_wolfram/OpenVDBLink/Transform.m b/openvdb_wolfram/OpenVDBLink/Transform.m index 4dde0fbadd..4971e1db1d 100755 --- a/openvdb_wolfram/OpenVDBLink/Transform.m +++ b/openvdb_wolfram/OpenVDBLink/Transform.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/openvdb_wolfram/OpenVDBLink/Values.m b/openvdb_wolfram/OpenVDBLink/Values.m index 3959c2c907..71dab04c51 100755 --- a/openvdb_wolfram/OpenVDBLink/Values.m +++ b/openvdb_wolfram/OpenVDBLink/Values.m @@ -10,7 +10,7 @@ (* ::Text:: *) (*Copyright Contributors to the OpenVDB Project*) -(*SPDX-License-Identifier: MPL-2.0*) +(*SPDX-License-Identifier: Apache-2.0*) (* ::Section:: *) diff --git a/pendingchanges/assert.txt b/pendingchanges/assert.txt deleted file mode 100644 index 76502ccd00..0000000000 --- a/pendingchanges/assert.txt +++ /dev/null @@ -1,6 +0,0 @@ -OpenVDB: - Improvements: - - Added openvdb::assertAbort to replace cassert and a OPENVDB_ENABLE_ASSERTS - cmake argument/compile define to toggle assertions in OpenVDB code, - independantly of NDEBUG. Asserts are no longer enabled by default in - when NDEBUG is absent (e.g. Debug builds). diff --git a/pendingchanges/ax_windows_cmake_fix.txt b/pendingchanges/ax_windows_cmake_fix.txt deleted file mode 100644 index d022feaa4e..0000000000 --- a/pendingchanges/ax_windows_cmake_fix.txt +++ /dev/null @@ -1,3 +0,0 @@ -Build: - - Fixed an issue with OpenVDB AX's CMake on Windows where the static and shared library targets would have the same name - [Reported by Nicholas Yue] diff --git a/pendingchanges/explicit_inst_win.txt b/pendingchanges/explicit_inst_win.txt deleted file mode 100644 index f86db01b8d..0000000000 --- a/pendingchanges/explicit_inst_win.txt +++ /dev/null @@ -1,3 +0,0 @@ -Build: - - USE_EXPLICIT_INSTANTIATION is now disabled on Windows by default due to - OOM linker issues. diff --git a/pendingchanges/houdinirpath.txt b/pendingchanges/houdinirpath.txt deleted file mode 100644 index 2165afe686..0000000000 --- a/pendingchanges/houdinirpath.txt +++ /dev/null @@ -1,3 +0,0 @@ -Houdini: - - When OPENVDB_ENABLE_RPATH is ON, the location of libopenvdb_houdini is now - added to the rpath of all Houdini dsos. diff --git a/pendingchanges/iofix.txt b/pendingchanges/iofix.txt deleted file mode 100644 index 6d095d7a02..0000000000 --- a/pendingchanges/iofix.txt +++ /dev/null @@ -1,3 +0,0 @@ -Bug Fixes: - - Fix potential crash reading corrupt .vdb files with invalid - blosc or zip chunks. [Fix thanks to Matthias Ueberheide] diff --git a/pendingchanges/jemalloc.txt b/pendingchanges/jemalloc.txt deleted file mode 100644 index 4db76f91b2..0000000000 --- a/pendingchanges/jemalloc.txt +++ /dev/null @@ -1,3 +0,0 @@ -Build: - - Jemalloc is now the preferred allocator of choice on all platforms when - CONCURRENT_MALLOC is set to Auto. diff --git a/pendingchanges/nanovdb_32.7.txt b/pendingchanges/nanovdb_32.7.txt deleted file mode 100644 index 78e2f71d01..0000000000 --- a/pendingchanges/nanovdb_32.7.txt +++ /dev/null @@ -1,85 +0,0 @@ -Bug fix: -nanovdb::readGrids works with raw grid buffer. - -Improvements: -Restructure files location and namespace to be more align with OpenVDB. The -namespaces touched by the restructuring are: io, cuda, util, tools, and math. -Add two scripts updateFiles.sh and updateFiles.py to update the files using -NanoVDB. The script updateFiles.py works on both Windows and Linux. -For a more complete list of changes, see API Changes (details). - -cuda::PointsToGrid supports target density. -Add support for NanoVDB Grid of type UInt8. -Add ability to use externally managed CUDA buffer. -Add create methods for CudaDeviceBuffer and exceptions. -Improve GridValidator logic, e.g. include check for grid count. -Add operator > and >= for class Coord according to lexicographical order. -Add toCodec to convert string to Codec enumeration type. -Add nanovdb::strlen(). -Add strncpy util. -Add NANOVDB_DISABLE_SYNC_CUDA_MALLOC that maps cudaMallocAsync and -cudaFreeAsync to cudaMalloc and cudaFree respectively. -Add guard to UINT64_C. -Remove use of cudaMallocAsync in PointsToGrid.cuh. -Align PNanoVDB blind metadata to NanoVDB. - -API Changes: -Change mapToGridType to toGridType. -Change mapToMagic to toMagic. -Change CpuTimer.h to Timer.h. - -API Changes (details): -These APIs are now under the math namespace: Ray, DDA, HDDA, Vec3, Vec4, BBox, -ZeroCrossing, TreeMarcher, PointTreeMarcher, BoxStencil, CurvatureStencil, -GradStencil, WenoStencil, AlignUp, Min, Max, Abs, Clamp, Sqrt, Sign, Maximum, -Delta, RoundDown, pi, isApproxZero, Round, createSampler, SampleFromVoxels. - -These APIs are now under the tools namespace: createNanoGrid, StatsMode, -createLevelSetSphere, createFogVolumeSphere, createFogVolumeSphere, -createFogVolumeSphere, createFogVolumeTorus, createLevelSetBox, CreateNanoGrid, -updateGridStats, evalChecksum, validateChecksum, checkGrid, Extrema. - -These APIs are now under the util namespace: is_floating_point, findLowestOn, -findHighestOn, Range, streq, strcpy, strcat, empty, Split, invoke, forEach, -reduce, prefixSum, is_same, is_specialization, PtrAdd, PtrDiff. - -Move nanovdb::build to nanovdb::tools::build. -Rename nanovdb::BBoxR to nanovdb::Vec3dBBox. -Rename nanovdb::BBox to nanovdb::Vec3dBbox. -Move nanovdb::cudaCreateNodeManager to nanovdb::cuda::createNodeManager. -Move and rename nanovdb::cudaVoxelsToGrid to nanovdb::cuda::voxelsToGrid. -Move and rename nanovdb::cudaPointsToGrid to nanovdb::cuda::pointsToGrid. -Move nanovdb::DitherLUT to nanovdb::math::DitherLUT. -Move and rename nanovdb::PackedRGBA8 to nanovdb::math::Rgba8. -Move nanovdb::Rgba8 to nanovdb::math::Rgba8. -Move and rename nanovdb::CpuTimer to nanovdb::util::Timer. -Move nanovdb::GpuTimer to nanovdb::util::cuda::Timer. -Move and rename nanovdb::CountOn to nanovdb::util::countOn. - -Move util/GridHandle.h to GridHandle.h. -Move util/BuildGrid.h to tools/GridBuilder.h. -Move util/GridBuilder.h to tools/GridBuilder.h. -Move util/IO.h to io/IO.h. -Move util/CSampleFromVoxels.h to math/CSampleFromVoxels.h. -Move util/DitherLUT.h to math/DitherLUT.h. -Move util/HDDA.h to math/HDDA.h. -Move util/Ray.h to math/Ray.h. -Move util/SampleFromVoxels.h to math/SampleFromVoxels.h. -Move util/Stencils.h to nanovdb/math/Stencils.h. -Move util/CreateNanoGrid.h to tools/CreateNanoGrid.h. -Move and rename util/Primitives.h to tools/CreatePrimitives.h. -Move util/GridChecksum.h to tools/GridChecksum.h. -Move util/GridStats.h to tools/GridStats.h. -Move util/GridChecksum.h to tools/GridChecksum.h. -Move util/GridValidator.h to tools/GridValidator.h. -Move util/NanoToOpenVDB.h to tools/NanoToOpenVDB.h. -Move util/cuda/CudaGridChecksum.cuh to tools/cuda/CudaGridChecksum.cuh. -Move util/cuda/CudaGridStats.cuh to tools/cuda/CudaGridStats.cuh. -Move util/cuda/CudaGridValidator.cuh to tools/cuda/CudaGridValidator.cuh. -Move util/cuda/CudaIndexToGrid.cuh to tools/cuda/CudaIndexToGrid.cuh. -Move and rename util/cuda/CudaPointsToGrid.cuh to tools/cuda/PointsToGrid.cuh. -Move util/cuda/CudaSignedFloodFill.cuh to tools/cuda/CudaSignedFloodFill.cuh. -Move and rename util/cuda/CudaDeviceBuffer.h to cuda/DeviceBuffer.h. -Move and rename util/cuda/CudaGridHandle.cuh to cuda/GridHandle.cuh. -Move and rename util/cuda/CudaUtils.h to util/cuda/Util.h. -Move and consolidate util/cuda/GpuTimer.h to util/cuda/Timer.h. diff --git a/pendingchanges/tsan_spheres.txt b/pendingchanges/tsan_spheres.txt deleted file mode 100644 index 150bdb7803..0000000000 --- a/pendingchanges/tsan_spheres.txt +++ /dev/null @@ -1,5 +0,0 @@ -OpenVDB: - Bug Fixes: - - Fixed a thread sanitizer issue which could cause undefined behaviour - in VolumeToSpheres::fillWithSpheres - [Reported by Jérémie Dumas] diff --git a/pendingchanges/ubsan.txt b/pendingchanges/ubsan.txt deleted file mode 100644 index f050fd29e0..0000000000 --- a/pendingchanges/ubsan.txt +++ /dev/null @@ -1,3 +0,0 @@ -OpenVDB: - - Bug Fixes:: - - Fixed an occurance of undefined behaviour in tools::activate (though this would typically not have manifested with any unintended behaviour) diff --git a/pendingchanges/vdb_tool.txt b/pendingchanges/vdb_tool.txt new file mode 100644 index 0000000000..c68dc25834 --- /dev/null +++ b/pendingchanges/vdb_tool.txt @@ -0,0 +1 @@ +added read and write support for OFF (Object File Format) files to vdb_tool \ No newline at end of file diff --git a/pendingchanges/windows_static_blosc.txt b/pendingchanges/windows_static_blosc.txt deleted file mode 100644 index 882dc1f3fa..0000000000 --- a/pendingchanges/windows_static_blosc.txt +++ /dev/null @@ -1,2 +0,0 @@ -Build: - - Fixed an issue with the Blosc CMake FindPackage for the OpenVDB Windows static library. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..b42bcd5c80 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,44 @@ +[build-system] +requires = ["scikit_build_core", "nanobind"] +build-backend = "scikit_build_core.build" + +[project] +name = "openvdb" +version = "12.0.1" +description= "Python bindings for OpenVDB: sparse volume data structure and tools." +dependencies = [ + "numpy", +] +authors = [ + { name = "OpenVDB Developer Team", email = "openvdb-dev@lists.aswf.io" }, +] +requires-python = ">=3.10" +classifiers = [ + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] + +[project.urls] +homepage = "https://www.openvdb.org/" +documentation = "https://www.openvdb.org/documentation" +forum = "https://github.com/AcademySoftwareFoundation/openvdb/discussions" +repository = "https://github.com/AcademySoftwareFoundation/openvdb" +slack = "https://slack.aswf.io/" + +[tool.scikit-build] +wheel.packages = [] + +[tool.scikit-build.cmake.define] +OPENVDB_CORE_STATIC="OFF" +USE_EXPLICIT_INSTANTIATION="OFF" +DISABLE_DEPENDENCY_VERSION_CHECKS="ON" +OPENVDB_USE_DELAYED_LOADING="OFF" +OPENVDB_BUILD_PYTHON_MODULE="ON" +USE_NUMPY="ON" + +USE_NANOVDB="ON" +NANOVDB_USE_CUDA="ON" +NANOVDB_BUILD_PYTHON_MODULE="ON" +NANOVDB_USE_OPENVDB="ON" + diff --git a/tsc/ccla.md b/tsc/ccla.md index 88d0d7f269..1e772e5e70 100644 --- a/tsc/ccla.md +++ b/tsc/ccla.md @@ -1,32 +1 @@ - - - -Corporate Contributor License Agreement ("Agreement") - -Thank you for your interest in the OpenVDB Project a Series of LF Projects, LLC (hereinafter "Project") which has selected the Mozilla Public License Version 2.0 (hereinafter "MPL-2.0") license for its inbound contributions. The terms You, Contributor and Contribution are used here as defined in the MPL-2.0 license. - -The Project is required to have a Contributor License Agreement (CLA) on file that binds each Contributor. - -You agree that all Contributions to the Project made by You or by Your designated employees shall be submitted pursuant to the Developer Certificate of Origin Version (DCO, current version available at https://developercertificate.org) accompanying the contribution and licensed to the project under the MPL-2.0. - -You agree that You shall be bound by the terms of the MPL-2.0 for all contributions made by You and Your employees. Your designated employees are those listed by Your CLA Manager(s) on the system of record for the Project. You agree to identify Your initial CLA Manager below and thereafter maintain current CLA Manager records in the Project's system of record. - -Initial CLA Manager (Name and Email): ______________________________________ - - -Corporate Signature: - - -Company Name: ____________________________________________ - - -Signature: _______________________________________________ - - -Name: _______________________________________________ - - -Title _______________________________________________ - - -Date: _______________________________________________ +The CCLA has been moved to https://cla-signature-files-prod.s3.amazonaws.com/contract-group/28a0d3d8-b869-44e0-a4f4-06b50c49822f/template/ccla-2024-09-04T09-58-59Z.pdf \ No newline at end of file diff --git a/tsc/icla.md b/tsc/icla.md index 4d39aebf11..450416e20c 100644 --- a/tsc/icla.md +++ b/tsc/icla.md @@ -1,20 +1 @@ - - - -Individual Contributor License Agreement ("Agreement") - -Thank you for your interest in the OpenVDB Project a Series of LF Projects, LLC (hereinafter "Project") which has selected the Mozilla Public License Version 2.0 (hereinafter "MPL-2.0") license for its inbound contributions. The terms You, Contributor and Contribution are used here as defined in the MPL-2.0 license. - -The Project is required to have a Contributor License Agreement (CLA) on file that binds each Contributor. - -You agree that all Contributions to the Project made by You shall be submitted pursuant to the Developer Certificate of Origin Version (DCO, current version available at https://developercertificate.org) accompanying the contribution and licensed to the project under the MPL-2.0, and that You agree to, and shall be bound by, the terms of the MPL-2.0. - - - -Signature: __________________________________________ - - -Name: _______________________________________________ - - -Date: _______________________________________________ +The ICLA has been moved to https://cla-signature-files-prod.s3.amazonaws.com/contract-group/28a0d3d8-b869-44e0-a4f4-06b50c49822f/template/icla-2024-09-04T09-58-58Z.pdf \ No newline at end of file diff --git a/tsc/meetings/2024-09-10.md b/tsc/meetings/2024-09-10.md new file mode 100644 index 0000000000..c350cdde01 --- /dev/null +++ b/tsc/meetings/2024-09-10.md @@ -0,0 +1,75 @@ +Minutes from OpenVDB TSC meeting, September 10th, 2024 + +Attendees: *Jeff* L., *Rich* J, *Ken* M., *Andre* P., *Dan* B. + +Regrets: *Nick* A., *Greg* H. + +Additional Attendees: +Dhruv Govil (Apple), Jonathan Swartz (NVIDIA), Francis Williams (NVIDIA), Barry Dempsey + +Agenda: + +1) Confirm quorum +2) Secretary +3) CCLA +4) Maintainer Change PR (#1883) +5) Approvals for all 5 PRs discussed last meeting +6) fVDB + NanoVDB +7) fVDB Test Files +8) CI Fixes Needed +9) Next Meeting + +------------ + +1) Confirm quorum + +Quorum is present. + +2) Secretary + +Secretary is Dan Bailey. + +3) CCLA + +See John Mertic email about pre-signing the CCLA. Jeff has done this for SideFX already, everyone +else needs to do this so we can switch to the new CCLA. + +4) Maintainer Change PR (#1883) + +Live review and approval of #1883 to rename "committer" to "maintainer". New TSC members require TSC +votes, all other responsibilities and permissions move to maintainer. Jonathan Swartz added to list +of maintainers and is now a member of ASWF organization. Dan to enable additional permissions for +Jonathan, Francis to go over process with Jonathan to also be made a maintainer. + +5) Approvals for all 5 PRs discussed last meeting + +a) 744 - remove boost any +b) 1893 - std::is_arithmetic for half +c) 1723 - boost conversion traits (1893 to be merged first) +d) 1789 - move value accessor methods to tree +e) 1775 - update tree adaptor to work with const inputs + +With all of these changes merged, boost can officially become an optional dependency of VDB. +Currently, it is a mandatory header-only dependency and requires boost libraries when +delayed-loading is enabled. + +6) fVDB + NanoVDB + +Currently fVDB is on a feature/fvdb branch. Requires significant improvements to NanoVDB to enable +mutable grids. After discussion, agreed that there should also be a feature/nanovdb branch which is +sporadically merged into feature/fvdb. Expectation that both branches are temporary and when new +functionality considered ready and stable, merged to master, nanovdb first, fvdb second. + +7) fVDB Test Files + +fVDB test files are currently living in a separate repo. fVDB is built and tested separately, for +improved security, test files are not accessed when built for distribution. + +8) CI Fixes Needed + +Lots of CI build fixes are needed before VDB12 release. Windows static library build still an +issue. + +9) Next Meeting + +Next meeting is on September 24th, 2024. 2pm-3pm EDT (GMT-4). diff --git a/tsc/meetings/2024-09-24.md b/tsc/meetings/2024-09-24.md new file mode 100644 index 0000000000..02a4e06d4b --- /dev/null +++ b/tsc/meetings/2024-09-24.md @@ -0,0 +1,109 @@ +Minutes from OpenVDB TSC meeting, September 9th, 2024 + +Attendees: *Ken* M., *Jeff* L., *Andre* P, *Dan* B., *Greg* H. + +Additional Attendees: John Mertic (Linux Foundation), Dhruv Govil (Apple), Mathew Cong (NVIDIA), Jonathan S, JT Nelson (Blender) + +Regrets: *Nick* A., *Richard* J. + +Agenda: + +1) Confirm quorum +2) Secretary +3) Various license changes +4) OpenVDB 12 +5) Broken build system +6) fVDB GPU testing +7) PIP install +8) Boost +9) Next Meeting + +------------ + +1) Confirm quorum + +Quorum is present. + +2) Secretary + +Secretary is Greg Hurst. + +3) Various license changes + +Need 2/3 majority approval for technical charter + +Ken, Jeff, Dan, Greg, Andre all approve -- 5/7 TSC approval + +SideFX and UT approve CCLA change, awaiting NVIDIA and other relevant players, Weta and ILM + +Links for reference and review: + +ICLA - https://cla-signature-files-prod.s3.amazonaws.com/contract-group/28a0d3d8-b869-44e0-a4f4-06b50c49822f/template/icla-2024-09-04T09-58-58Z.pdf +CCLA - https://cla-signature-files-prod.s3.amazonaws.com/contract-group/28a0d3d8-b869-44e0-a4f4-06b50c49822f/template/ccla-2024-09-04T09-58-59Z.pdf + +4) OpenVDB 12 + +fVDB not ready for version 12 + +* OpenVDB fillet filter PR 1793 +* OpenVDB Half Grid PR 1787 +* OpenVDB tube complex (TBD!) + +Access method on the root node. Currently can only access node via coordinate not index -- tease these things out +ABI could be a question mark here. +Iterate root table + random access + +nanoBind support for OpenVDB and NanoVDB (?) + +Beyond 12: +Volume advection is slow, which uses a slow grid iterator. Relatively straightforward to fix +Dilation more expensive than advection -- 6 nn can be sped up. + +5) Broken build system + +2 failures left on the weekly CI +1 is trivial and 1 is a little more complicated. + +ASWF says we used all of their budget this mont for their CI + +fVDB + license updates triggered runs + +6) fVDB GPU testing + +fVDB needs ampere or above GPU's to test 32 bit architecture. + +1. Azure can give us a 1/16th of an A10 -- not to build but run tests. Is it worth the cost? + +2. Could possibly run within internally at NVIDIA and push once verified + +3. Could push for other hardware to be donated to ASWF + +Can we connect the dots between ASWF and NVIDIA since NVIDIA can see this as a business need / priority + +FWIW OpenColorIO has GPU runners + +7) PIP install + +Helpful for distributing would be + +pip install openvdb and pip install nanovdb + +pip install nanovdb is working without openvdb dependency + +pip install openvdb is almost working -- Windows is still a headache + +fVDB currently uses pybind + +Historically we haven't supported package type management ourselves and left it to the users + +Just have ability to pip install and clone -- should be minimal support on our end. Still need to build on user's end. + +Go all in on nanoBind for OpenVDB and nanoVDB and then pybind for fVDB -- then transition when time is right in the future. + +8) Boost + +No longer require boost libraries -- optional requirement except for delayed loading + +9) Next Meeting + +Next Meeting 10-08-2024 diff --git a/tsc/meetings/2024-10-08.md b/tsc/meetings/2024-10-08.md new file mode 100644 index 0000000000..19a2582a38 --- /dev/null +++ b/tsc/meetings/2024-10-08.md @@ -0,0 +1,82 @@ +Minutes from OpenVDB TSC meeting, Octtober 8th, 2024 + +Attendees: *Ken* M., *Nick* A., *Jeff* L., *Andre* P, *Dan* B., *Greg* H. + +Regrets: *Rich* J. + +Additional Attendees: +John Mertic (Linux Foundation), Dhruv Govil (Apple), Mathew Cong (NVIDIA), +Jonathan Swartz (NVIDIA), JT Nelson (Blender), Victor Lu + +Agenda: + +1) Confirm quorum +2) Secretary +3) Re-licensing Progress +4) CI +5) Changing cpp test to gtest in AX +6) Deprecation Policy +7) PR-1916 - Nanobind PR +8) ABI and API Changes +9) Tube complex and thicken mesh +10) Next meeting + +------------ + +1) Confirm quorum + +Quorum is present. + +2) Secretary + +Secretary is Andre Pradhana. + +3) Re-licensing Progress + +NVIDIA has signed the CLA, but has not added their name to the list. ILM and +United Therapeutics have signed. + +The next step is to merge PR-1858 (which needs a second approval). Noted that +the PR probably needs to be updated to be more aligned with the master branch. +There was a suggestion to change the target of the PR to a feature branch to +bring everything up to date before merging to master. + +4) CI + +There are a few CI issues, e.g. with Houdini 20.5 and AX unit tests failing due +to LLVM version issues. + +5) Changing cpp test to gtest in AX + +Tim is looking at changing cpp test to unit test in +[PR-1919](https://github.com/AcademySoftwareFoundation/openvdb/pull/1919). + +6) Deprecation Policy + +Currently, we do not change the ABI until after the major release, i.e. we used +to add an extra minor release. + +We took a vote (six people agreed, one abstains) and agreed to drop ABI support +at the same time as a major release. Our deprecation policy is to support the +current and last two versions of the VFX reference platform. + +7) PR-1916 - Nanobind PR + +This PR is to switch from pybind11 to NanoBind. Andre agreed to take a look at +the PR. + +8) ABI and API Changes + +Dan went through a few suggestions: + - Root Node and Internal Nodes API changes: adding public methods to check if a + key exists in map and adding index-based iteration on internal nodes. + - Adding unsafe methods to bypass checks. It was suggested to add new methods + without unsafe labels. + +9) Tube complex and thicken mesh + +Greg will have a PR ready for creating tube complexes and thicken mesh. + +10) Next meeting + +Next meeting is on October 22nd, 2024. 2pm-3pm EDT (GMT-4). diff --git a/tsc/meetings/2024-10-22.md b/tsc/meetings/2024-10-22.md new file mode 100644 index 0000000000..c405ee6982 --- /dev/null +++ b/tsc/meetings/2024-10-22.md @@ -0,0 +1,151 @@ +Minutes from OpenVDB TSC meeting, October 22nd, 2024 + +Attendees: *Jeff* L., *Ken* M., *Andre* P., *Dan* B., *Nick* A., *Greg* H. + +Regrets: *Rich* J. + +Additional Attendees: +John Mertic (Linux Foundation), J. T. Nelson (Blender), Dhruv Govil (Apple), +Jonathan Swartz (NVIDIA), Matthew Cong (NVIDIA), Francis Williams (NVIDIA) + +Agenda: + +1) Confirm quorum +2) Secretary +3) Re-licensing to Apache and CLA/CCLA +4) CI +5) Drop ABI-9 support +6) PR-1916 +7) PR-1931 +8) PR-1936 +9) PR-1938 +10) PR-1939 +11) Half Grid Support PR +12) PR-1793 - Fillet in LevelSetFilter +13) PR-1794 +14) Pip Install OpenVDB +15) PR-1935 - Create Tubes and Thickened Mesh +16) Next Meeting + +------------ + +1) Confirm quorum + +Quorum is present. + +2) Secretary + +Secretary is Andre Pradhana. + +3) Re-licensing to Apache and CLA/CCLA + +The relicensing PR is merged. New contributions need to be licensed under +Apache, not SPDX. + +Today the following companies have signed for the new CLA: United Therapeutics, +Lucas Film, SideFX, and NVIDIA. Weta is in the process. Apple does individual +CLA. + +The process is that the old CLA will be taken out, documented for historic +purposes, and insert the new CLAs. New contributors need to sign the new CLA. +John Mertic needed approval from TSC members. + +We had concern regarding TSC members who cannot contribute code because they are +blocked by CLA approval. We voted if we needed to delay CLA update. Five people +agree to go through with updating the CLA and relicensing for VDB 12. John got +the approval. + +4) CI + +Dan fixed Windows CI. + +Weekly extra build has been upgraded to 2024 images now which uses LLVM 17. AX +was removed from this CI because of incompatibility. + +NanoVDB CI is updated to use 2024 OS Image. Andre looked at it and approved. + +5) Drop ABI-9 support + +We are dropping ABI-9 support for VDB-12. This means we are now dropping C++11 +and Python 3.7. + +Most notably, this also changes the old deprecation policy so that we do not +need to maintain an older version of the ABI for an extra minor release. + +6) [PR-1916](https://github.com/AcademySoftwareFoundation/openvdb/pull/1916) + +Nanobind support for OpenVDB and NanoVDB has the correct approvals. Dan merged +it. + +7) [PR-1931](https://github.com/AcademySoftwareFoundation/openvdb/pull/1931) + +A few methods were made to be public (e.g. haskey()). It’s suggested to make +some of the APIs to be aligned with what’s in the Tree API. + +Gave a motivation on the reason to add an API called deleteChildOrChild, which +gives one the ability to delete a child or coordinate that has a given +coordinate. A potential problem with the implementation detail of deleting an +element of a map is a case where one iterates through a map and deletes an entry +of the map, which invalidates the iterator itself. Needs good documentation, +e.g. calling this can invalidate child iterators. + +There is a bug in RooNode setOrigin. + +Ken will take a look. + +8) [PR-1936](https://github.com/AcademySoftwareFoundation/openvdb/pull/1936) + +Added const version of probeNode (for internal and root nodes) that didn’t exist +before. The API allows one to give the node type you want to probe and probe the +level below. + +The internal node can probe based on a child, but also overloads to probe with a +child, a value, and an activate state. + +The APIs have assert. + +Ken will take a look. + +9) [PR-1938](https://github.com/AcademySoftwareFoundation/openvdb/pull/1938) + +Discussion about adding unsafe methods, e.g. getValueUnsafe, getChildUnsafe. + +There was a concern: if a user deletes the word unsafe from the API call, will +the code still work? The answer is it depends on the implementation. + +Assert are added into these methods, so debug build should help with debugging +with a debug build. + +10) [PR-1939](https://github.com/AcademySoftwareFoundation/openvdb/pull/1939) + +Added a more efficient implementation in RootNode constructor by calling emplace +method in the table. + +Ken will take a look. + +11) Half Grid Support PR + +Andre and Greg will meet. We will create a feature/half_grid_branch and work +from there. + +12) [PR-1793](https://github.com/AcademySoftwareFoundation/openvdb/pull/1793) - Fillet in LevelSetFilter + +This PR is for VDB-12. + +13) [PR-1794](https://github.com/AcademySoftwareFoundation/openvdb/pull/1794) + +This PR is for VDB-12. + +14) Pip Install OpenVDB + +Matthew will try to get pip install for Python for VDB-12. + +15) [PR-1935](https://github.com/AcademySoftwareFoundation/openvdb/pull/1935) - Create Tubes and Thickened Mesh + +Discussed replacing the word thickened to dilate. Another suggestion along the +line of the term “alpha shape”. + +16) Next Meeting + +Next meeting is on October 29th, 2024. 2pm-3pm EDT (GMT-4). + diff --git a/tsc/meetings/2024-10-29.md b/tsc/meetings/2024-10-29.md new file mode 100644 index 0000000000..98a157f6f8 --- /dev/null +++ b/tsc/meetings/2024-10-29.md @@ -0,0 +1,140 @@ +Minutes from OpenVDB TSC meeting, October 29th, 2024 + +Attendees: *Ken* M., *Jeff* L., *Andre* P, *Dan* B., *Greg* H, *Nick* A. + +Additional Attendees: Dhruv Govil (Apple), Mathew Cong (NVIDIA), +Jonathan Swartz (NVIDIA) + +Regrets: *Richard* J. + +Agenda: + +1) Confirm quorum +2) Secretary +3) Meeting Times +4) OpenVDB 12 PRs +5) 12 Release +6) Next Meeting + +------------ + +1) Confirm quorum + +Quorum is present. + +2) Secretary + +Secretary is Jeff Lait. + +3) Meeting Times + +Do we alternate meeting times to get better universal times? + +We've lacked agenda so it is unclear if you need to show up or not. + +We need to be better at uploading meeting notes. + +In the winter, 8am works in NZ. We should figure out a better schedule for the summer. Either a new day or alternate days. + +We are able to sync and update the calendar now! + +We should start the call for agenda items again. + +Next weeks meeting we should each know what days don't work for this +time slot, so we can see if a non-Tuesday will work. + +4) OpenVDB 12 PRs + + +a) PR1936, 1938, 1939 + +Feedback addressed, ready to go. + +b) 1951 + +Awaiting on NVidia CLA. + +c) 1941 + +Awaiting on NVidia CLA. + +SKBuild is a bit of a mess. This is from the featurevdb vs nanovdb branches. Ideally only on SKBuild test? + +d) 1952 + +Need to sudo make install. Cleaned up old code. Now falls back +rather than uses complicated logic. + +Approved and ready. + +e) 1954 + +Newest container complains about undefined behaviour, we should fix +eventually, but turn off so it passes. We used to use a macro for +this, but it is believed __attribute__ is now supported by GCC. + +Nick will investigate, might be failing on Windows. + +f) 1794 + +Prevent integer overflow. + +This is an ABI change. Virtual functions now return different things. +Return type doesn't necessarily affect the mangle, but might affect the layout. + +We add a nodeCount(std::vector) rather than replace, and +deprecate the Index32 in new ABI. + +The version that returns std::vector needs both versions +switched according to the ABI type. + +We should also switch nonLeafCount at the same time rather than +waiting for next 2^32 overflow. + +g) 1935 + +Tube complex PR. + +Needs more unit tests. ConvexVoxelizer uses GridT, but things are +cast to float internally? Is this a float only setup? Should there be +static_asserts to early exit? This was originally float only and +tried to make generic. Passes shared pointer to grid, but holds +reference to a tree - should keep shared pointer to grid keep +lifetime guarantees. + +Should this all be put into one header? But these are separate functions. + +Should ConvexVoxelizer be a private namespace? Similar to Points api? +Ideally the user's entry ponit is a nicely documented header file. +Convex Voxelizer is meant to be a starting point for new types. An +example for a level set sphere test is provided. + +This should have its own unit test rather than adding to test tools. + +This can wait for VDB 12.1. + +h) Half grid feature branch + +Vec3h - Vec3h doesn't work.... Still failing unit tests. + +Not including means that .vdb files can't use this natively, as VDB12 +compliant DCC will not necessarily have this type registered. + +Requires too much for VDB12 release. + +We need a placeholder PR so we remember to finish this. + +i) 1821 + +PDAL support. Missing unit tests. Handles LIDAR style point formats. +Will be delayed until unit tests, can go in VDB12.1. + +5) Release + +Dan will do the release. PRs need to be merged by the 30th. + +6) Next Meeting + +Agenda: Dilation. New TSC meeting day + +Next Meeting 11-05-2024 at the same time. diff --git a/tsc/meetings/2024-11-05.md b/tsc/meetings/2024-11-05.md new file mode 100644 index 0000000000..3ad3b8c5e4 --- /dev/null +++ b/tsc/meetings/2024-11-05.md @@ -0,0 +1,100 @@ +Minutes from OpenVDB TSC meeting, November 5th, 2024 + +Attendees: *Ken* M., *Andre* P, *Dan* B., *Greg* H, *Nick* A. + +Additional Attendees: Jonathan Swartz (NVIDIA), Barry Dempsey + +Regrets: *Jeff* L., *Richard* J. + +Agenda: + +1) Confirm quorum +2) Secretary +3) V12 post mortem +4) 12.1 release +5) File format updates +6) Dilation +7) Next meeting + +------------ + +1) Confirm quorum + +Quorum is present. + +2) Secretary + +Secretary is Greg Hurst. + +3) V12 post mortem + +Release wasn't too bad -- getting CI in order was a bit of work but started a bit early. + +Having a X.1, X.2, etc. release there would be less of a squeeze for new features. + +Ken: perhaps 3 releases per year, including the major release. + +Nick: Would be nice if we could be in a place where patch releases are simple whenever there's a new feature. This means we can't put anything into master unless we're completely happy with it. We also need to make sure that the weekly tests are always in working order and when a failure happens, we need to address ASAP. + +CI could be more complicated once we start adding GPU's into the mix. + +Linux & Mac OS migrations have happenend and switching from bash to shell in Windows had made more stable. + +Chat groups can be much easier to manage the CI compared to emails, which we currently operate like. Perhaps Slack or Google chat? + +Ken: Could Nick add documentation or a presentation about the current CI? It's complex and a bit intimidating right now. + +Porting AX tests to GTest from CPPTest can help a bit with CI. + +4) 12.1 release + +March 1, 2025 release? + +* Tubes + Dilated Meshes +* HalfGrid +* Large Nano updates + +5) File format updates + +Migrate away from Blosc in favor from LZ4? + +Blosc brings a lot of compression codecs with it, so we could precondition ourselves and then just bring in LZ4. + +6) Dilation + +Dan presents on dilation -- noticed serial dilation was faster when making volume advection calls + +Active ideas of how we can speed up the multithreaded code. + +Vague description: + +Current: dilate into multiple grids then merge +Future: create 1 grid and dilate into it, parallelize over internal nodes directly above leaf nodes + +1. Partial Topology Copy, turn dense leaf nodes into active tiles +2. Node dilation, iterate over leafs and touch leaf neighbors +3. Mask dilation, scatter method but make sure you're not writing to the same leaf node at the same time. Split into center, face, edge, and corner passes, so 4 passes instead of 7. Still does scattering over a copy of the data since multiple passes are used. +4. Prune tree + +Tentatively a ~4-5x speedup for 'dense-like' grids and ~2x speedup for higher SA/V grids. + +TODOs +* Topology Copy + * Skip Topology Copy and Re-use Input Topology +* Node Dilation + * Apply Center, Face, Edge, Corner Scheme + * Avoid Naive Root Children Dilation +* Mask Dilation + * Cache Neighboring Internal Nodes + * Thread Corner Cases + * Simplify Edge Cases + * Extend to NN_FACE_EDGE/NN_FACE_EDGE_VERTEX modes +* Testing + * Build Worst Case and Poorly Balanced Trees + * Multiple Iterations + +7) Next meeting + +Tentativley we'd like to move meetings to Wednesdays at 11:00 PST if we get a buy in from Jeff and Rich. + +If this is the case, the next meeting is Wednesday Novermber 20, 2024 at 11:00 PST. diff --git a/tsc/process/deprecation.md b/tsc/process/deprecation.md index bf54ece78d..3ed9a307ca 100644 --- a/tsc/process/deprecation.md +++ b/tsc/process/deprecation.md @@ -5,7 +5,7 @@ OpenVDB is committed to supporting three years of Houdini and Maya based on those versions of the platform. The latest supported year is that in which the VDB version listed matches the major version. -For example, version 6.1.0 of OpenVDB supports VFX Reference Platform years +For example, all 6.x versions of OpenVDB support VFX Reference Platform years 2019, 2018 and 2017. This infers the following support: @@ -14,9 +14,5 @@ This infers the following support: * C++11 and C++14 * Houdini 16.5, 17.0 and 17.5 -When version 7.0.0 is released, OpenVDB will support VFX Reference Platform -years 2020, 2019 and 2018. Support for Houdini 16.5 and C++11 will be dropped. - -Support for obsolete ABIs will not be dropped until the first minor release -after the introduction of a new ABI. For example, the latest version to retain -support for ABI=4 will be the release prior to 7.1.0. +All 7.x versions of OpenVDB support VFX Reference Platform years 2020, 2019 and +2018. Support for Houdini 16.5, C++11 and ABI=4 is removed.