Loading...
Searching...
No Matches
CreateNanoGrid.h File Reference

Convert any grid to a nanovdb grid of the same type, e.g. float->float. More...

`#include "GridBuilder.h"`
`#include "NodeManager.h"`
`#include "GridHandle.h"`
`#include "GridStats.h"`
`#include "GridChecksum.h"`
`#include "Range.h"`
`#include "Invoke.h"`
`#include "ForEach.h"`
`#include "Reduce.h"`
`#include "PrefixSum.h"`
`#include "DitherLUT.h"`
`#include <limits>`
`#include <vector>`
`#include <set>`
`#include <cstring>`
`#include <type_traits>`

Go to the source code of this file.

## Classes

class | AbsDiff
| Compression oracle based on absolute difference. More...
class | RelDiff
| Compression oracle based on relative difference. More...
class | NodeAccessor< GridT >
| The NodeAccessor provides a uniform API for accessing nodes got NanoVDB, OpenVDB and build Grids. More...
class | NodeAccessor< NanoGrid< BuildT > >
| Template specialization for nanovdb::Grid which is special since its NodeManage uses a handle in order to support node access on the GPU! More...
struct | MapToNano< T >
| Trait that maps any type to the corresponding nanovdb type. More...
class | CreateNanoGrid< SrcGridT >
| Creates any nanovdb Grid from any source grid (certain combinations are obviously not allowed) More...
struct | CreateNanoGrid< SrcGridT >::BlindMetaData

## Namespaces

namespace | nanovdb

## Functions

template<typename SrcGridT, typename DstBuildT = typename MapToNano<typename SrcGridT::BuildType>::type, typename BufferT = HostBuffer>
disable_if< BuildTraits< DstBuildT >::is_index||BuildTraits< DstBuildT >::is_Fp, GridHandle< BufferT > >::type | createNanoGrid (const SrcGridT &srcGrid, StatsMode sMode=StatsMode::Default, ChecksumMode cMode=ChecksumMode::Default, int verbose=0, const BufferT &buffer=BufferT())
| Freestanding function that creates a NanoGrid<T> from any source grid.
template<typename SrcGridT, typename DstBuildT = typename MapToNano<typename SrcGridT::BuildType>::type, typename BufferT = HostBuffer>
enable_if< BuildTraits< DstBuildT >::is_index, GridHandle< BufferT > >::type | createNanoGrid (const SrcGridT &srcGrid, uint32_t channels=0u, bool includeStats=true, bool includeTiles=true, int verbose=0, const BufferT &buffer=BufferT())
| Freestanding function that creates a NanoGrid<ValueIndex> or NanoGrid<ValueOnIndex> from any source grid.
template<typename SrcGridT, typename DstBuildT = typename MapToNano<typename SrcGridT::BuildType>::type, typename OracleT = AbsDiff, typename BufferT = HostBuffer>
enable_if< is_same< FpN, DstBuildT >::value, GridHandle< BufferT > >::type | createNanoGrid (const SrcGridT &srcGrid, StatsMode sMode=StatsMode::Default, ChecksumMode cMode=ChecksumMode::Default, bool ditherOn=false, int verbose=0, const OracleT &oracle=OracleT(), const BufferT &buffer=BufferT())
| Freestanding function to create a NanoGrid<FpN> from any source grid.
template<typename SrcGridT, typename DstBuildT = typename MapToNano<typename SrcGridT::BuildType>::type, typename BufferT = HostBuffer>
enable_if< BuildTraits< DstBuildT >::is_FpX, GridHandle< BufferT > >::type | createNanoGrid (const SrcGridT &srcGrid, StatsMode sMode=StatsMode::Default, ChecksumMode cMode=ChecksumMode::Default, bool ditherOn=false, int verbose=0, const BufferT &buffer=BufferT())
| Freestanding function to create a NanoGrid<FpX> from any source grid, X=4,8,16.
std::ostream & | operator<< (std::ostream &os, const AbsDiff &diff)
std::ostream & | operator<< (std::ostream &os, const RelDiff &diff)

## Detailed Description

Convert any grid to a nanovdb grid of the same type, e.g. float->float.

Author
  Ken Museth

Date
  June 26, 2020

Note
  In the examples below we assume that `srcGrid` is a exiting grid of type SrcGridT = `openvdb::FloatGrid`, `openvdb::FloatGrid` or `nanovdb::build::FloatGrid`.

auto handle = nanovdb::createNanoGrid(srcGrid);
auto *dstGrid = handle.grid<float>();
nanovdb::createNanoGrid
disable_if< BuildTraits< DstBuildT >::is_index||BuildTraits< DstBuildT >::is_Fp, GridHandle< BufferT > >::type createNanoGrid(const SrcGridT &srcGrid, StatsMode sMode=StatsMode::Default, ChecksumMode cMode=ChecksumMode::Default, int verbose=0, const BufferT &buffer=BufferT())
Freestanding function that creates a NanoGrid<T> from any source grid.
Definition CreateNanoGrid.h:1956

Convert a grid to a nanovdb grid of a different type, e.g. float->half

auto handle = nanovdb::createNanoGrid<SrcGridT,nanovdb::Fp16>(srcGrid);
auto *dstGrid = handle.grid<nanovdb::Fp16>();
nanovdb::Fp16
Dummy type for a 16bit quantization of float point values.
Definition NanoVDB.h:293

Convert a grid to a nanovdb grid of the same type but using a CUDA buffer

auto handle = nanovdb::createNanoGrid<SrcGridT, float, nanovdb::CudaDeviceBuffer>(srcGrid);
auto *dstGrid = handle.grid<float>();

Create a nanovdb grid that indices values in an existing source grid of any type. If DstBuildT = nanovdb::ValueIndex both active and in-active values are indexed and if DstBuildT = nanovdb::ValueOnIndex only active values are indexed.

using DstBuildT = nanovdb::ValueIndex;// index both active an inactive values
auto handle = nanovdb::createNanoGridSrcGridT,DstBuildT>(srcGrid,0,false,false);//no blind data, tile values or stats
auto *dstGrid = handle.grid<DstBuildT>();
nanovdb::ValueIndex
Dummy type for a voxel whose value equals an offset into an external value array.
Definition NanoVDB.h:253

Create a NanoVDB grid from scratch

#if defined(NANOVDB_USE_OPENVDB) && !defined(__CUDACC__)
using SrcGridT = openvdb::FloatGrid;
#else
using SrcGridT = nanovdb::build::FloatGrid;
#endif
SrcGridT srcGrid(0.0f);// create an empty source grid
auto srcAcc = srcGrid.getAccessor();// create an accessor
srcAcc.setValue(nanovdb::Coord(1,2,3), 1.0f);// set a voxel value
auto handle = nanovdb::createNanoGrid(srcGrid);// convert source grid to a grid handle
auto dstGrid = handle.grid<float>();// get a pointer to the destination grid
nanovdb::Coord
Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord.
Definition NanoVDB.h:1302
nanovdb::build::FloatGrid
Grid< float > FloatGrid
Definition GridBuilder.h:2032
openvdb::v11_0::FloatGrid
Grid< FloatTree > FloatGrid
Definition openvdb.h:75

Convert a base-pointer to an openvdb grid, denoted srcGrid, to a nanovdb grid of the same type, e.g. float -> float or openvdb::Vec3f -> nanovdb::Vec3f

auto handle = nanovdb::openToNanoVDB(*srcGrid);// convert source grid to a grid handle
auto dstGrid = handle.grid<float>();// get a pointer to the destination grid

Converts any existing grid to a NanoVDB grid, for example: nanovdb::build::Grid<SrcBuildT> -> nanovdb::Grid<DstBuildT> nanovdb::Grid<SrcBuildT> -> nanovdb::Grid<DstBuildT> nanovdb::Grid<SrcBuildT> -> nanovdb::Grid<ValueIndex or ValueOnIndex> openvdb::Grid<SrcBuildT> -> nanovdb::Grid<DstBuildT> openvdb::Grid<PointIndex> -> nanovdb::Grid<PointIndex> openvdb::Grid<PointData> -> nanovdb::Grid<PointData> openvdb::Grid<SrcBuildT> -> nanovdb::Grid<ValueIndex or ValueOnIndex>

Note
  This files replaces GridBuilder.h, IndexGridBuilder.h and OpenToNanoVDB.h