OpenVDB 13.1.0
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 <nanovdb/NodeManager.h>
#include <nanovdb/GridHandle.h>
#include <nanovdb/tools/GridBuilder.h>
#include <nanovdb/tools/GridStats.h>
#include <nanovdb/tools/GridChecksum.h>
#include <nanovdb/util/Range.h>
#include <nanovdb/util/Invoke.h>
#include <nanovdb/util/ForEach.h>
#include <nanovdb/util/Reduce.h>
#include <nanovdb/util/PrefixSum.h>
#include <nanovdb/math/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 in 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...

Namespaces

namespace  nanovdb
 Defines a simple memory pool used to call cub functions that use dynamic temporary storage.
namespace  nanovdb::tools

Functions

template<typename SrcGridT, typename DstBuildT = typename MapToNano<typename SrcGridT::BuildType>::type, typename BufferT = HostBuffer>
util::disable_if< BuildTraits< DstBuildT >::is_index||BuildTraits< DstBuildT >::is_Fp, GridHandle< BufferT > >::type createNanoGrid (const SrcGridT &srcGrid, StatsMode sMode=StatsMode::Default, CheckMode cMode=CheckMode::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>
util::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>
util::enable_if< util::is_same< FpN, DstBuildT >::value, GridHandle< BufferT > >::type createNanoGrid (const SrcGridT &srcGrid, StatsMode sMode=StatsMode::Default, CheckMode cMode=CheckMode::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>
util::enable_if< BuildTraits< DstBuildT >::is_FpX, GridHandle< BufferT > >::type createNanoGrid (const SrcGridT &srcGrid, StatsMode sMode=StatsMode::Default, CheckMode cMode=CheckMode::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 nanovdb::tools::AbsDiff &diff)
std::ostream & operator<< (std::ostream &os, const nanovdb::tools::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::tools::build::FloatGrid.
auto handle = nanovdb::tools::createNanoGrid(srcGrid);
auto *dstGrid = handle.grid<float>();
util::disable_if< BuildTraits< DstBuildT >::is_index||BuildTraits< DstBuildT >::is_Fp, GridHandle< BufferT > >::type createNanoGrid(const SrcGridT &srcGrid, StatsMode sMode=StatsMode::Default, CheckMode cMode=CheckMode::Default, int verbose=0, const BufferT &buffer=BufferT())
Freestanding function that creates a NanoGrid<T> from any source grid.
Definition CreateNanoGrid.h:1938

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

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

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

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::tools::createNanoGridSrcGridT,DstBuildT>(srcGrid,0,false,false);//no blind data, tile values or stats
auto *dstGrid = handle.grid<DstBuildT>();
Dummy type for a voxel whose value equals an offset into an external value array.
Definition NanoVDB.h:177

Create a NanoVDB grid from scratch

#if defined(NANOVDB_USE_OPENVDB) && !defined(__CUDACC__)
using SrcGridT = openvdb::FloatGrid;
#else
#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::tools::createNanoGrid(srcGrid);// convert source grid to a grid handle
auto dstGrid = handle.grid<float>();// get a pointer to the destination grid
Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord.
Definition Math.h:346
Grid< float > FloatGrid
Definition GridBuilder.h:2032
Grid< FloatTree > FloatGrid
Definition openvdb.h:76

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::tools::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

Function Documentation

◆ operator<<() [1/2]

std::ostream & operator<< ( std::ostream & os,
const nanovdb::tools::AbsDiff & diff )
inline

◆ operator<<() [2/2]

std::ostream & operator<< ( std::ostream & os,
const nanovdb::tools::RelDiff & diff )
inline