Loading...
Searching...
No Matches
DenseGrid.h
Go to the documentation of this file.
// Copyright Contributors to the OpenVDB Project
// SPDX-License-Identifier: MPL-2.0
/// @file DenseGrid.h
///
/// @author Ken Museth
///
/// @brief Simple dense grid class.
#ifndef NANOVDB_DENSEGRID_H_HAS_BEEN_INCLUDED
#define NANOVDB_DENSEGRID_H_HAS_BEEN_INCLUDED
#include <stdint.h>// for uint64_t
#include <fstream> // for std::ifstream
#include <nanovdb/util/HostBuffer.h>// for default Buffer
#include <nanovdb/util/ForEach.h>
#include <nanovdb/NanoVDB.h>// for Map, GridClass, GridType and and Coord
// use 4x4x4 tiles for better cache coherence
// else it uses dense indexing which is slow!
// 0 means disable, 1 is 2x2x2, 2 is 4x4x4 and 3 is 8x8x8
#define LOG2_TILE_SIZE 2
namespace nanovdb {
// forward decleration
template<typename BufferT = HostBuffer>
class DenseGridHandle;
#define DENSE_MAGIC_NUMBER 0x42445665736e6544UL // "DenseVDB" in hex - little endian (uint64_t)
struct DenseData
{
Map mMap;// defined in NanoVDB.h
CoordBBox mIndexBBox;// min/max of bbox
BBox<Vec3R> mWorldBBox;// 48B. floating-point AABB of active values in WORLD SPACE (2 x 3 doubles)
Vec3R mVoxelSize;
GridClass mGridClass;// defined in NanoVDB.h
GridType mGridType; // defined in NanoVDB.h
uint64_t mY, mX;//strides in the y and x direction
uint64_t mSize;
__hostdev__ Coord dim() const { return mIndexBBox.dim(); }
// Affine transformations based on double precision
template<typename Vec3T>
__hostdev__ Vec3T applyMap(const Vec3T& xyz) const { return mMap.applyMap(xyz); } // Pos: index -> world
template<typename Vec3T>
__hostdev__ Vec3T applyInverseMap(const Vec3T& xyz) const { return mMap.applyInverseMap(xyz); } // Pos: world -> index
template<typename Vec3T>
__hostdev__ Vec3T applyJacobian(const Vec3T& xyz) const { return mMap.applyJacobian(xyz); } // Dir: index -> world
template<typename Vec3T>
__hostdev__ Vec3T applyInverseJacobian(const Vec3T& xyz) const { return mMap.applyInverseJacobian(xyz); } // Dir: world -> index
template<typename Vec3T>
__hostdev__ Vec3T applyIJT(const Vec3T& xyz) const { return mMap.applyIJT(xyz); }
// Affine transformations based on single precision
template<typename Vec3T>
__hostdev__ Vec3T applyMapF(const Vec3T& xyz) const { return mMap.applyMapF(xyz); } // Pos: index -> world
template<typename Vec3T>
__hostdev__ Vec3T applyInverseMapF(const Vec3T& xyz) const { return mMap.applyInverseMapF(xyz); } // Pos: world -> index
template<typename Vec3T>
__hostdev__ Vec3T applyJacobianF(const Vec3T& xyz) const { return mMap.applyJacobianF(xyz); } // Dir: index -> world
template<typename Vec3T>
__hostdev__ Vec3T applyInverseJacobianF(const Vec3T& xyz) const { return mMap.applyInverseJacobianF(xyz); } // Dir: world -> index
template<typename Vec3T>
__hostdev__ Vec3T applyIJTF(const Vec3T& xyz) const { return mMap.applyIJTF(xyz); }
};
/// @brief Simple dense grid class
/// @note ZYX is the memory-layout in VDB. It leads to nested
/// for-loops of the order x, y, z.
template<typename ValueT>
class DenseGrid : private DenseData
{
#if LOG2_TILE_SIZE > 0
static constexpr uint32_t TileLog2 = LOG2_TILE_SIZE, TileMask = (1 << TileLog2) - 1, TileDim = 1 << (3*TileLog2);
#endif
using DenseData = DenseData;
public:
using ValueType = ValueT;
template<typename BufferT = HostBuffer>
inline static DenseGridHandle<BufferT> create(Coord min, // min inclusive index coordinate
Coord max, // max inclusive index coordinate
double dx = 1.0, //voxel size
const Vec3d& p0 = Vec3d(0.0), // origin
GridClass gridClass = GridClass::Unknown,
const BufferT& allocator = BufferT());
__hostdev__ DenseGrid(const DenseGrid&) = delete;
__hostdev__ ~DenseGrid() = delete;
__hostdev__ DenseGrid& operator=(const DenseGrid&) = delete;
__hostdev__ uint64_t size() const { return mIndexBBox.volume(); }
__hostdev__ inline uint64_t coordToOffset(const Coord &ijk) const;
__hostdev__ inline bool test(const Coord &ijk) const;
__hostdev__ uint64_t memUsage() const {return mSize;}
__hostdev__ uint64_t gridSize() const {return this->memUsage();}
__hostdev__ const Coord& min() const { return mIndexBBox[0]; }
__hostdev__ const Coord& max() const { return mIndexBBox[1]; }
__hostdev__ inline bool isValidType() const;
/// @brief Return a const reference to the Map for this grid
__hostdev__ const Map& map() const { return DenseData::mMap; }
// @brief Return a const reference to the size of a voxel in world units
__hostdev__ const Vec3R& voxelSize() const { return DenseData::mVoxelSize; }
/// @brief world to index space transformation
template<typename Vec3T>
__hostdev__ Vec3T worldToIndex(const Vec3T& xyz) const { return this->applyInverseMap(xyz); }
/// @brief world to index space transformation
template<typename Vec3T>
__hostdev__ Vec3T indexToWorld(const Vec3T& xyz) const { return this->applyMap(xyz); }
/// @brief transformation from index space direction to world space direction
/// @warning assumes dir to be normalized
template<typename Vec3T>
__hostdev__ Vec3T indexToWorldDir(const Vec3T& dir) const { return this->applyJacobian(dir); }
/// @brief transformation from world space direction to index space direction
/// @warning assumes dir to be normalized
template<typename Vec3T>
__hostdev__ Vec3T worldToIndexDir(const Vec3T& dir) const { return this->applyInverseJacobian(dir); }
/// @brief transform the gradient from index space to world space.
/// @details Applies the inverse jacobian transform map.
template<typename Vec3T>
__hostdev__ Vec3T indexToWorldGrad(const Vec3T& grad) const { return this->applyIJT(grad); }
/// @brief world to index space transformation
template<typename Vec3T>
__hostdev__ Vec3T worldToIndexF(const Vec3T& xyz) const { return this->applyInverseMapF(xyz); }
/// @brief index to world space transformation
template<typename Vec3T>
__hostdev__ Vec3T indexToWorldF(const Vec3T& xyz) const { return this->applyMapF(xyz); }
/// @brief transformation from index space direction to world space direction
/// @warning assumes dir to be normalized
template<typename Vec3T>
__hostdev__ Vec3T indexToWorldDirF(const Vec3T& dir) const { return this->applyJacobianF(dir); }
/// @brief transformation from world space direction to index space direction
/// @warning assumes dir to be normalized
template<typename Vec3T>
__hostdev__ Vec3T worldToIndexDirF(const Vec3T& dir) const { return this->applyInverseJacobianF(dir); }
/// @brief Transforms the gradient from index space to world space.
/// @details Applies the inverse jacobian transform map.
template<typename Vec3T>
__hostdev__ Vec3T indexToWorldGradF(const Vec3T& grad) const { return DenseData::applyIJTF(grad); }
/// @brief Computes a AABB of active values in world space
__hostdev__ const BBox<Vec3R>& worldBBox() const { return DenseData::mWorldBBox; }
__hostdev__ bool isLevelSet() const { return DenseData::mGridClass == GridClass::LevelSet; }
__hostdev__ bool isFogVolume() const { return DenseData::mGridClass == GridClass::FogVolume; }
/// @brief Computes a AABB of active values in index space
///
/// @note This method is returning a floating point bounding box and not a CoordBBox. This makes
/// it more useful for clipping rays.
__hostdev__ const CoordBBox& indexBBox() const { return mIndexBBox; }
__hostdev__ const GridType& gridType() const { return DenseData::mGridType; }
__hostdev__ const GridClass& gridClass() const { return DenseData::mGridClass; }
__hostdev__ DenseData* data() { return reinterpret_cast<DenseData*>(this); }
__hostdev__ const DenseData* data() const { return reinterpret_cast<const DenseData*>(this); }
__hostdev__ ValueT* values() { return reinterpret_cast<ValueT*>(this+1);}
__hostdev__ const ValueT* values() const { return reinterpret_cast<const ValueT*>(this+1); }
__hostdev__ inline const ValueT& getValue(const Coord &ijk) const;
__hostdev__ inline void setValue(const Coord &ijk, const ValueT &v);
}; // Grid
template<typename ValueT>
template<typename BufferT>
DenseGridHandle<BufferT>
DenseGrid<ValueT>::create(Coord min,
Coord max,
double dx, //voxel size
const Vec3d& p0, // origin
GridClass gridClass,
const BufferT& allocator)
{
if (dx <= 0) {
throw std::runtime_error("GridBuilder: voxel size is zero or negative");
}
max += Coord(1,1,1);// now max is exclusive
#if LOG2_TILE_SIZE > 0
const uint64_t dim[3] = {(uint64_t(max[0] - min[0]) + TileMask) >> TileLog2,
(uint64_t(max[1] - min[1]) + TileMask) >> TileLog2,
(uint64_t(max[2] - min[2]) + TileMask) >> TileLog2};
const uint64_t size = sizeof(DenseGrid) + sizeof(ValueT)*TileDim*dim[0]*dim[1]*dim[2];
#else
const uint64_t dim[3] = {uint64_t(max[0] - min[0]),
uint64_t(max[1] - min[1]),
uint64_t(max[2] - min[2])};
const uint64_t size = sizeof(DenseGrid) + sizeof(ValueT)*dim[0]*dim[1]*dim[2];
#endif
DenseGridHandle<BufferT> handle(allocator.create(size));
DenseGrid* grid = reinterpret_cast<DenseGrid*>(handle.data());
grid->mSize = size;
const double Tx = p0[0], Ty = p0[1], Tz = p0[2];
const double mat[4][4] = {
{dx, 0.0, 0.0, 0.0}, // row 0
{0.0, dx, 0.0, 0.0}, // row 1
{0.0, 0.0, dx, 0.0}, // row 2
{Tx, Ty, Tz, 1.0}, // row 3
};
const double invMat[4][4] = {
{1 / dx, 0.0, 0.0, 0.0}, // row 0
{0.0, 1 / dx, 0.0, 0.0}, // row 1
{0.0, 0.0, 1 / dx, 0.0}, // row 2
{-Tx, -Ty, -Tz, 1.0}, // row 3
};
grid->mMap.set(mat, invMat, 1.0);
for (int i=0; i<3; ++i) {
grid->mIndexBBox[0][i] = min[i];
grid->mIndexBBox[1][i] = max[i] - 1;
}
grid->mWorldBBox[0] = grid->mWorldBBox[1] = grid->mMap.applyMap(Vec3d(min[0], min[1], min[2]));
grid->mWorldBBox.expand(grid->mMap.applyMap(Vec3d(min[0], min[1], max[2])));
grid->mWorldBBox.expand(grid->mMap.applyMap(Vec3d(min[0], max[1], min[2])));
grid->mWorldBBox.expand(grid->mMap.applyMap(Vec3d(max[0], min[1], min[2])));
grid->mWorldBBox.expand(grid->mMap.applyMap(Vec3d(max[0], max[1], min[2])));
grid->mWorldBBox.expand(grid->mMap.applyMap(Vec3d(max[0], min[1], max[2])));
grid->mWorldBBox.expand(grid->mMap.applyMap(Vec3d(min[0], max[1], max[2])));
grid->mWorldBBox.expand(grid->mMap.applyMap(Vec3d(max[0], max[1], max[2])));
grid->mVoxelSize = grid->mMap.applyMap(Vec3d(1)) - grid->mMap.applyMap(Vec3d(0));
if (gridClass == GridClass::LevelSet && !is_floating_point<ValueT>::value)
throw std::runtime_error("Level sets are expected to be floating point types");
if (gridClass == GridClass::FogVolume && !is_floating_point<ValueT>::value)
throw std::runtime_error("Fog volumes are expected to be floating point types");
grid->mGridClass = gridClass;
grid->mGridType = mapToGridType<ValueT>();
grid->mY = dim[2];
grid->mX = dim[2] * dim[1];
return handle;
}
template<typename ValueT>
bool DenseGrid<ValueT>::test(const Coord &ijk) const
{
return (ijk[0]>=mIndexBBox[0][0]) && (ijk[0]<=mIndexBBox[1][0]) &&
(ijk[1]>=mIndexBBox[0][1]) && (ijk[1]<=mIndexBBox[1][1]) &&
(ijk[2]>=mIndexBBox[0][2]) && (ijk[2]<=mIndexBBox[1][2]);
}
template<typename ValueT>
uint64_t DenseGrid<ValueT>::coordToOffset(const Coord &ijk) const
{
assert(this->test(ijk));
#if LOG2_TILE_SIZE > 0
const uint32_t x = ijk[0] - mIndexBBox[0][0];
const uint32_t y = ijk[1] - mIndexBBox[0][1];
const uint32_t z = ijk[2] - mIndexBBox[0][2];
return ((mX*(x>>TileLog2) + mY*(y>>TileLog2) + (z>>TileLog2))<<(3*TileLog2)) +
((x&TileMask)<<(2*TileLog2)) + ((y&TileMask)<<TileLog2) + (z&TileMask);
#else
return uint64_t(ijk[0]-mIndexBBox[0][0])*mX +
uint64_t(ijk[1]-mIndexBBox[0][1])*mY +
uint64_t(ijk[2]-mIndexBBox[0][2]);
#endif
}
template<typename ValueT>
const ValueT& DenseGrid<ValueT>::getValue(const Coord &ijk) const
{
return this->values()[this->coordToOffset(ijk)];
}
template<typename ValueT>
void DenseGrid<ValueT>::setValue(const Coord &ijk, const ValueT &value)
{
this->values()[this->coordToOffset(ijk)] = value;
}
template<typename ValueT>
bool DenseGrid<ValueT>::isValidType() const
{
return std::is_same<float, ValueT>::value ? mGridType == GridType::Float : false;
}
/////////////////////////////////////////////
namespace io{
template<typename ValueT>
void writeDense(const DenseGrid<ValueT> &grid, const char* fileName)
{
std::ofstream os(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
if (!os.is_open()) {
throw std::runtime_error("Unable to open file for output");
}
const uint64_t tmp[2] = {DENSE_MAGIC_NUMBER, grid.memUsage()};
os.write(reinterpret_cast<const char*>(tmp), 2*sizeof(uint64_t));
os.write(reinterpret_cast<const char*>(&grid), tmp[1]);
}
template<typename BufferT>
void writeDense(const DenseGridHandle<BufferT> &handle, const char* fileName)
{
std::ofstream os(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
if (!os.is_open()) {
throw std::runtime_error("Unable to open file for output");
}
const uint64_t tmp[2] = {DENSE_MAGIC_NUMBER, handle.size()};
os.write(reinterpret_cast<const char*>(tmp), 2*sizeof(uint64_t));
os.write(reinterpret_cast<const char*>(handle.data()), tmp[1]);
}
template<typename BufferT = HostBuffer>
DenseGridHandle<BufferT>
readDense(const char* fileName, const BufferT& allocator = BufferT())
{
std::ifstream is(fileName, std::ios::in | std::ios::binary);
if (!is.is_open()) {
throw std::runtime_error("Unable to open file for input");
}
uint64_t tmp[2];
is.read(reinterpret_cast<char*>(tmp), 2*sizeof(uint64_t));
if (tmp[0] != DENSE_MAGIC_NUMBER) {
throw std::runtime_error("This is not a dense NanoVDB file!");
}
DenseGridHandle<BufferT> handle(allocator.create(tmp[1]));
is.read(reinterpret_cast<char*>(handle.data()), tmp[1]);
return handle;
}
}// namespace io
/////////////////////////////////////////////
/// @brief Converts a NanoVDB grid to a DenseGrid
template<typename GridT, typename BufferT = HostBuffer>
DenseGridHandle<BufferT> convertToDense(const GridT &grid, const BufferT& allocator = BufferT())
{
using ValueT = typename GridT::ValueType;
using DenseT = DenseGrid<ValueT>;
const Coord min = grid.indexBBox().min(), max = grid.indexBBox().max() + Coord(1,1,1);// max is exclusive!
#if LOG2_TILE_SIZE > 0
static constexpr uint32_t TileLog2 = LOG2_TILE_SIZE, TileMask = (1 << TileLog2) - 1, TileDim = 1 << (3*TileLog2);
const uint64_t dim[3] = {(uint64_t(max[0] - min[0]) + TileMask) >> TileLog2,
(uint64_t(max[1] - min[1]) + TileMask) >> TileLog2,
(uint64_t(max[2] - min[2]) + TileMask) >> TileLog2};
const uint64_t size = sizeof(DenseT) + sizeof(ValueT)*TileDim*dim[0]*dim[1]*dim[2];
#else
const uint64_t dim[3] = {uint64_t(max[0] - min[0]),
uint64_t(max[1] - min[1]),
uint64_t(max[2] - min[2])};
const uint64_t size = sizeof(DenseT) + sizeof(ValueT)*dim[0]*dim[1]*dim[2];
#endif
DenseGridHandle<BufferT> handle( allocator.create(size) );
auto *dense = reinterpret_cast<DenseT*>(handle.data());
auto *data = dense->data();
// copy DenseData
data->mMap = grid.map();
data->mIndexBBox = grid.indexBBox();
data->mWorldBBox = grid.worldBBox();
data->mVoxelSize = grid.voxelSize();
data->mGridClass = grid.gridClass();
data->mGridType = grid.gridType();
data->mY = dim[2];
data->mX = dim[2] * dim[1];
data->mSize = size;
// copy values
auto kernel = [&](const Range<1,int> &r) {
auto acc = grid.getAccessor();
Coord ijk;
for (ijk[0] = r.begin(); ijk[0] < r.end(); ++ijk[0]) {
for (ijk[1] = min[1]; ijk[1] < max[1]; ++ijk[1]) {
for (ijk[2] = min[2]; ijk[2] < max[2]; ++ijk[2]) {
dense->setValue(ijk, acc.getValue(ijk));
}
}
}
};
Range<1,int> range(min[0], max[0]);
#if 1
forEach(range, kernel);
#else
kernel(range);
#endif
return handle;
}
/////////////////////////////////////////////
template<typename BufferT>
class DenseGridHandle
{
BufferT mBuffer;
public:
DenseGridHandle(BufferT&& resources) { mBuffer = std::move(resources); }
DenseGridHandle() = default;
/// @brief Disallow copy-construction
DenseGridHandle(const DenseGridHandle&) = delete;
/// @brief Disallow copy assignment operation
DenseGridHandle& operator=(const DenseGridHandle&) = delete;
/// @brief Move copy assignment operation
DenseGridHandle& operator=(DenseGridHandle&& other) noexcept
{
mBuffer = std::move(other.mBuffer);
return *this;
}
/// @brief Move copy-constructor
DenseGridHandle(DenseGridHandle&& other) noexcept { mBuffer = std::move(other.mBuffer); }
/// @brief Default destructor
~DenseGridHandle() { this->reset(); }
void reset() { mBuffer.clear(); }
BufferT& buffer() { return mBuffer; }
const BufferT& buffer() const { return mBuffer; }
/// @brief Returns a non-const pointer to the data.
///
/// @warning Note that the return pointer can be NULL if the DenseGridHandle was not initialized
uint8_t* data() {return mBuffer.data();}
/// @brief Returns a const pointer to the data.
///
/// @warning Note that the return pointer can be NULL if the DenseGridHandle was not initialized
const uint8_t* data() const {return mBuffer.data();}
/// @brief Returns the size in bytes of the raw memory buffer managed by this DenseGridHandle's allocator.
uint64_t size() const { return mBuffer.size();}
/// @brief Returns a const pointer to the NanoVDB grid encoded in the DenseGridHandle.
///
/// @warning Note that the return pointer can be NULL if the DenseGridHandle was not initialized or the template
/// parameter does not match!
template<typename ValueT>
const DenseGrid<ValueT>* grid() const
{
using GridT = const DenseGrid<ValueT>;
GridT* grid = reinterpret_cast<GridT*>(mBuffer.data());
return (grid && grid->isValidType()) ? grid : nullptr;
}
template<typename ValueT>
DenseGrid<ValueT>* grid()
{
using GridT = DenseGrid<ValueT>;
GridT* grid = reinterpret_cast<GridT*>(mBuffer.data());
return (grid && grid->isValidType()) ? grid : nullptr;
}
template<typename ValueT, typename U = BufferT>
typename std::enable_if<BufferTraits<U>::hasDeviceDual, const DenseGrid<ValueT>*>::type
deviceGrid() const
{
using GridT = const DenseGrid<ValueT>;
bool isValidType = reinterpret_cast<GridT*>(mBuffer.data())->isValidType();
GridT* grid = reinterpret_cast<GridT*>(mBuffer.deviceData());
return (grid && isValidType) ? grid : nullptr;
}
template<typename U = BufferT>
typename std::enable_if<BufferTraits<U>::hasDeviceDual, void>::type
deviceUpload(void* stream = nullptr, bool sync = true) {
mBuffer.deviceUpload(stream, sync);
}
template<typename U = BufferT>
typename std::enable_if<BufferTraits<U>::hasDeviceDual, void>::type
deviceDownload(void* stream = nullptr, bool sync = true) {
mBuffer.deviceDownload(stream, sync);
}
}; // DenseGridHandle
} // namespace nanovdb
#endif // NANOVDB_DENSEGRID_HAS_BEEN_INCLUDED
DENSE_MAGIC_NUMBER
#define DENSE_MAGIC_NUMBER
Definition DenseGrid.h:31
LOG2_TILE_SIZE
#define LOG2_TILE_SIZE
Definition DenseGrid.h:23
ForEach.h
A unified wrapper for tbb::parallel_for and a naive std::thread fallback.
value
ValueT value
Definition GridBuilder.h:1290
HostBuffer.h
HostBuffer - a buffer that contains a shared or private bump pool to either externally or internally ...
NanoVDB.h
Implements a light-weight self-contained VDB data-structure in a single file! In other words,...
__hostdev__
#define __hostdev__
Definition NanoVDB.h:192
nanovdb::Coord
Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord.
Definition NanoVDB.h:967
nanovdb::DenseGridHandle
Definition DenseGrid.h:402
nanovdb::DenseGridHandle::DenseGridHandle
DenseGridHandle(const DenseGridHandle &)=delete
Disallow copy-construction.
nanovdb::DenseGridHandle::DenseGridHandle
DenseGridHandle(DenseGridHandle &&other) noexcept
Move copy-constructor.
Definition DenseGrid.h:420
nanovdb::DenseGridHandle::deviceUpload
std::enable_if< BufferTraits< U >::hasDeviceDual, void >::type deviceUpload(void *stream=nullptr, bool sync=true)
Definition DenseGrid.h:474
nanovdb::DenseGridHandle::data
const uint8_t * data() const
Returns a const pointer to the data.
Definition DenseGrid.h:437
nanovdb::DenseGridHandle::DenseGridHandle
DenseGridHandle(BufferT &&resources)
Definition DenseGrid.h:406
nanovdb::DenseGridHandle::buffer
BufferT & buffer()
Definition DenseGrid.h:426
nanovdb::DenseGridHandle::deviceDownload
std::enable_if< BufferTraits< U >::hasDeviceDual, void >::type deviceDownload(void *stream=nullptr, bool sync=true)
Definition DenseGrid.h:480
nanovdb::DenseGridHandle::DenseGridHandle
DenseGridHandle()=default
nanovdb::DenseGridHandle::operator=
DenseGridHandle & operator=(DenseGridHandle &&other) noexcept
Move copy assignment operation.
Definition DenseGrid.h:414
nanovdb::DenseGridHandle::~DenseGridHandle
~DenseGridHandle()
Default destructor.
Definition DenseGrid.h:422
nanovdb::DenseGridHandle::deviceGrid
std::enable_if< BufferTraits< U >::hasDeviceDual, constDenseGrid< ValueT > * >::type deviceGrid() const
Definition DenseGrid.h:464
nanovdb::DenseGridHandle::size
uint64_t size() const
Returns the size in bytes of the raw memory buffer managed by this DenseGridHandle's allocator.
Definition DenseGrid.h:440
nanovdb::DenseGridHandle::buffer
const BufferT & buffer() const
Definition DenseGrid.h:427
nanovdb::DenseGridHandle::data
uint8_t * data()
Returns a non-const pointer to the data.
Definition DenseGrid.h:432
nanovdb::DenseGridHandle::grid
DenseGrid< ValueT > * grid()
Definition DenseGrid.h:455
nanovdb::DenseGridHandle::grid
const DenseGrid< ValueT > * grid() const
Returns a const pointer to the NanoVDB grid encoded in the DenseGridHandle.
Definition DenseGrid.h:447
nanovdb::DenseGridHandle::reset
void reset()
Definition DenseGrid.h:424
nanovdb::DenseGridHandle::operator=
DenseGridHandle & operator=(const DenseGridHandle &)=delete
Disallow copy assignment operation.
nanovdb::DenseGrid
Simple dense grid class.
Definition DenseGrid.h:75
nanovdb::DenseGrid::values
__hostdev__ ValueT * values()
Definition DenseGrid.h:175
nanovdb::DenseGrid::size
__hostdev__ uint64_t size() const
Definition DenseGrid.h:96
nanovdb::DenseGrid::gridClass
__hostdev__ const GridClass & gridClass() const
Definition DenseGrid.h:170
nanovdb::DenseGrid::worldBBox
__hostdev__ const BBox< Vec3R > & worldBBox() const
Computes a AABB of active values in world space.
Definition DenseGrid.h:158
nanovdb::DenseGrid::setValue
__hostdev__ void setValue(const Coord &ijk, const ValueT &v)
Definition DenseGrid.h:283
nanovdb::DenseGrid::worldToIndexF
__hostdev__ Vec3T worldToIndexF(const Vec3T &xyz) const
world to index space transformation
Definition DenseGrid.h:136
nanovdb::DenseGrid::map
__hostdev__ const Map & map() const
Return a const reference to the Map for this grid.
Definition DenseGrid.h:106
nanovdb::DenseGrid::values
__hostdev__ const ValueT * values() const
Definition DenseGrid.h:176
nanovdb::DenseGrid::data
__hostdev__ DenseData * data()
Definition DenseGrid.h:172
nanovdb::DenseGrid::getValue
__hostdev__ const ValueT & getValue(const Coord &ijk) const
Definition DenseGrid.h:277
nanovdb::DenseGrid::create
static DenseGridHandle< BufferT > create(Coord min, Coord max, double dx=1.0, const Vec3d &p0=Vec3d(0.0), GridClass gridClass=GridClass::Unknown, const BufferT &allocator=BufferT())
Definition DenseGrid.h:185
nanovdb::DenseGrid::data
__hostdev__ const DenseData * data() const
Definition DenseGrid.h:173
nanovdb::DenseGrid::worldToIndexDir
__hostdev__ Vec3T worldToIndexDir(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition DenseGrid.h:127
nanovdb::DenseGrid::ValueType
ValueT ValueType
Definition DenseGrid.h:82
nanovdb::DenseGrid::gridType
__hostdev__ const GridType & gridType() const
Definition DenseGrid.h:169
nanovdb::DenseGrid::gridSize
__hostdev__ uint64_t gridSize() const
Definition DenseGrid.h:100
nanovdb::DenseGrid::test
__hostdev__ bool test(const Coord &ijk) const
Definition DenseGrid.h:252
nanovdb::DenseGrid::indexToWorldGrad
__hostdev__ Vec3T indexToWorldGrad(const Vec3T &grad) const
transform the gradient from index space to world space.
Definition DenseGrid.h:132
nanovdb::DenseGrid::indexToWorldGradF
__hostdev__ Vec3T indexToWorldGradF(const Vec3T &grad) const
Transforms the gradient from index space to world space.
Definition DenseGrid.h:155
nanovdb::DenseGrid::coordToOffset
__hostdev__ uint64_t coordToOffset(const Coord &ijk) const
Definition DenseGrid.h:260
nanovdb::DenseGrid::indexToWorldDirF
__hostdev__ Vec3T indexToWorldDirF(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition DenseGrid.h:145
nanovdb::DenseGrid::indexBBox
__hostdev__ const CoordBBox & indexBBox() const
Computes a AABB of active values in index space.
Definition DenseGrid.h:167
nanovdb::DenseGrid::max
__hostdev__ const Coord & max() const
Definition DenseGrid.h:102
nanovdb::DenseGrid::indexToWorldDir
__hostdev__ Vec3T indexToWorldDir(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition DenseGrid.h:122
nanovdb::DenseGrid::indexToWorld
__hostdev__ Vec3T indexToWorld(const Vec3T &xyz) const
world to index space transformation
Definition DenseGrid.h:117
nanovdb::DenseGrid::operator=
__hostdev__ DenseGrid & operator=(const DenseGrid &)=delete
nanovdb::DenseGrid::voxelSize
__hostdev__ const Vec3R & voxelSize() const
Definition DenseGrid.h:109
nanovdb::DenseGrid::min
__hostdev__ const Coord & min() const
Definition DenseGrid.h:101
nanovdb::DenseGrid::isLevelSet
__hostdev__ bool isLevelSet() const
Definition DenseGrid.h:160
nanovdb::DenseGrid::DenseGrid
__hostdev__ DenseGrid(const DenseGrid &)=delete
nanovdb::DenseGrid::memUsage
__hostdev__ uint64_t memUsage() const
Definition DenseGrid.h:99
nanovdb::DenseGrid::isValidType
__hostdev__ bool isValidType() const
Definition DenseGrid.h:289
nanovdb::DenseGrid::worldToIndex
__hostdev__ Vec3T worldToIndex(const Vec3T &xyz) const
world to index space transformation
Definition DenseGrid.h:113
nanovdb::DenseGrid::worldToIndexDirF
__hostdev__ Vec3T worldToIndexDirF(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition DenseGrid.h:150
nanovdb::DenseGrid::indexToWorldF
__hostdev__ Vec3T indexToWorldF(const Vec3T &xyz) const
index to world space transformation
Definition DenseGrid.h:140
nanovdb::DenseGrid::~DenseGrid
__hostdev__ ~DenseGrid()=delete
nanovdb::DenseGrid::isFogVolume
__hostdev__ bool isFogVolume() const
Definition DenseGrid.h:161
nanovdb::Range
Definition Range.h:28
nanovdb::io
Definition NanoVDB.h:5629
nanovdb::io::writeDense
void writeDense(const DenseGrid< ValueT > &grid, const char *fileName)
Definition DenseGrid.h:299
nanovdb::io::readDense
DenseGridHandle< BufferT > readDense(const char *fileName, const BufferT &allocator=BufferT())
Definition DenseGrid.h:324
nanovdb
Definition NanoVDB.h:208
nanovdb::GridClass
GridClass
Classes (defined in OpenVDB) that are currently supported by NanoVDB.
Definition NanoVDB.h:281
nanovdb::GridClass::FogVolume
@ FogVolume
Definition NanoVDB.h:283
nanovdb::GridClass::Unknown
@ Unknown
Definition NanoVDB.h:281
nanovdb::GridClass::LevelSet
@ LevelSet
Definition NanoVDB.h:282
nanovdb::GridType
GridType
List of types that are currently supported by NanoVDB.
Definition NanoVDB.h:243
nanovdb::GridType::Float
@ Float
Definition NanoVDB.h:244
nanovdb::convertToDense
DenseGridHandle< BufferT > convertToDense(const GridT &grid, const BufferT &allocator=BufferT())
Converts a NanoVDB grid to a DenseGrid.
Definition DenseGrid.h:344
nanovdb::Vec3R
Vec3< double > Vec3R
Definition NanoVDB.h:1287
nanovdb::CoordBBox
BBox< Coord > CoordBBox
Definition NanoVDB.h:1809
nanovdb::Vec3d
Vec3< double > Vec3d
Definition NanoVDB.h:1288
nanovdb::mapToGridType
GridType mapToGridType()
Maps from a templated value type to a GridType enum.
Definition NanoVDB.h:1486
nanovdb::forEach
void forEach(RangeT range, const FuncT &func)
simple wrapper for tbb::parallel_for with a naive std fallback
Definition ForEach.h:40
nanovdb::BBox
Definition NanoVDB.h:1655
nanovdb::DenseData
Definition DenseGrid.h:35
nanovdb::DenseData::mIndexBBox
CoordBBox mIndexBBox
Definition DenseGrid.h:37
nanovdb::DenseData::applyInverseJacobian
__hostdev__ Vec3T applyInverseJacobian(const Vec3T &xyz) const
Definition DenseGrid.h:55
nanovdb::DenseData::mGridType
GridType mGridType
Definition DenseGrid.h:41
nanovdb::DenseData::mY
uint64_t mY
Definition DenseGrid.h:42
nanovdb::DenseData::mSize
uint64_t mSize
Definition DenseGrid.h:43
nanovdb::DenseData::applyIJTF
__hostdev__ Vec3T applyIJTF(const Vec3T &xyz) const
Definition DenseGrid.h:68
nanovdb::DenseData::mGridClass
GridClass mGridClass
Definition DenseGrid.h:40
nanovdb::DenseData::mWorldBBox
BBox< Vec3R > mWorldBBox
Definition DenseGrid.h:38
nanovdb::DenseData::applyInverseJacobianF
__hostdev__ Vec3T applyInverseJacobianF(const Vec3T &xyz) const
Definition DenseGrid.h:66
nanovdb::DenseData::applyInverseMapF
__hostdev__ Vec3T applyInverseMapF(const Vec3T &xyz) const
Definition DenseGrid.h:62
nanovdb::DenseData::mX
uint64_t mX
Definition DenseGrid.h:42
nanovdb::DenseData::applyIJT
__hostdev__ Vec3T applyIJT(const Vec3T &xyz) const
Definition DenseGrid.h:57
nanovdb::DenseData::mVoxelSize
Vec3R mVoxelSize
Definition DenseGrid.h:39
nanovdb::DenseData::applyMap
__hostdev__ Vec3T applyMap(const Vec3T &xyz) const
Definition DenseGrid.h:49
nanovdb::DenseData::applyJacobianF
__hostdev__ Vec3T applyJacobianF(const Vec3T &xyz) const
Definition DenseGrid.h:64
nanovdb::DenseData::applyInverseMap
__hostdev__ Vec3T applyInverseMap(const Vec3T &xyz) const
Definition DenseGrid.h:51
nanovdb::DenseData::mMap
Map mMap
Definition DenseGrid.h:36
nanovdb::DenseData::applyJacobian
__hostdev__ Vec3T applyJacobian(const Vec3T &xyz) const
Definition DenseGrid.h:53
nanovdb::DenseData::dim
__hostdev__ Coord dim() const
Definition DenseGrid.h:45
nanovdb::DenseData::applyMapF
__hostdev__ Vec3T applyMapF(const Vec3T &xyz) const
Definition DenseGrid.h:60
nanovdb::Map
Defines an affine transform and its inverse represented as a 3x3 matrix and a vec3 translation.
Definition NanoVDB.h:2224
nanovdb::is_floating_point::value
static const bool value
Definition NanoVDB.h:415