HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
+ Include dependency graph for CreateNanoGrid.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  nanovdb::CreateNanoGrid< typename >
 Creates any nanovdb Grid from any source grid (certain combinations are obviously not allowed) More...
 
struct  nanovdb::MapToNano< typename >
 Trait that maps any type to the corresponding nanovdb type. More...
 
class  nanovdb::AbsDiff
 Compression oracle based on absolute difference. More...
 
class  nanovdb::RelDiff
 Compression oracle based on relative difference. More...
 
class  nanovdb::NodeAccessor< GridT >
 The NodeAccessor provides a uniform API for accessing nodes got NanoVDB, OpenVDB and build Grids. More...
 
class  nanovdb::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  nanovdb::MapToNano< typename >
 Trait that maps any type to the corresponding nanovdb type. More...
 
class  nanovdb::CreateNanoGrid< typename >
 Creates any nanovdb Grid from any source grid (certain combinations are obviously not allowed) More...
 
struct  nanovdb::CreateNanoGrid< typename >::BlindMetaData
 

Namespaces

 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 
nanovdb::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. More...
 
template<typename SrcGridT , typename DstBuildT = typename MapToNano<typename SrcGridT::BuildType>::type, typename BufferT = HostBuffer>
enable_if< BuildTraits
< DstBuildT >::is_index,
GridHandle< BufferT > >::type 
nanovdb::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. More...
 
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 
nanovdb::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. More...
 
template<typename SrcGridT , typename DstBuildT = typename MapToNano<typename SrcGridT::BuildType>::type, typename BufferT = HostBuffer>
enable_if< BuildTraits
< DstBuildT >::is_FpX,
GridHandle< BufferT > >::type 
nanovdb::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. More...
 
std::ostream & nanovdb::operator<< (std::ostream &os, const AbsDiff &diff)
 
std::ostream & nanovdb::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 *dstGrid = handle.grid<float>();

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>();

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>();

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

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

Definition in file CreateNanoGrid.h.