118#ifndef NANOVDB_NANOVDB_H_HAS_BEEN_INCLUDED
119#define NANOVDB_NANOVDB_H_HAS_BEEN_INCLUDED
121#define NANOVDB_MAGIC_NUMBER 0x304244566f6e614eUL
123#define NANOVDB_MAJOR_VERSION_NUMBER 32
124#define NANOVDB_MINOR_VERSION_NUMBER 4
125#define NANOVDB_PATCH_VERSION_NUMBER 2
128#define USE_SINGLE_ROOT_KEY
135#define NANOVDB_FPN_BRANCHLESS
137#define NANOVDB_DATA_ALIGNMENT 32
139#if !defined(NANOVDB_ALIGN)
140#define NANOVDB_ALIGN(n) alignas(n)
145typedef signed char int8_t;
146typedef short int16_t;
148typedef long long int64_t;
149typedef unsigned char uint8_t;
150typedef unsigned int uint32_t;
151typedef unsigned short uint16_t;
152typedef unsigned long long uint64_t;
154#define NANOVDB_ASSERT(x)
156#define UINT64_C(x) (x ## ULL)
168#ifdef NANOVDB_USE_IOSTREAMS
173#define NANOVDB_ASSERT(x) assert(x)
175#define NANOVDB_ASSERT(x)
178#if defined(NANOVDB_USE_INTRINSICS) && defined(_MSC_VER)
180#pragma intrinsic(_BitScanReverse)
181#pragma intrinsic(_BitScanForward)
182#pragma intrinsic(_BitScanReverse64)
183#pragma intrinsic(_BitScanForward64)
188#if defined(__CUDACC__) || defined(__HIP__)
190#define __hostdev__ __host__ __device__
197#if defined(_MSC_VER) && defined(__CUDACC__)
198#define NANOVDB_HOSTDEV_DISABLE_WARNING __pragma("hd_warning_disable")
199#elif defined(__GNUC__) && defined(__CUDACC__)
200#define NANOVDB_HOSTDEV_DISABLE_WARNING _Pragma("hd_warning_disable")
202#define NANOVDB_HOSTDEV_DISABLE_WARNING
206#define NANOVDB_OFFSETOF(CLASS, MEMBER) ((int)(size_t)((char*)&((CLASS*)0)->MEMBER - (char*)0))
265#ifndef __CUDACC_RTC__
269 static const char * LUT[] = {
"?",
"float",
"double" ,
"int16",
"int32",
270 "int64",
"Vec3f",
"Vec3d",
"Mask",
"Half",
271 "uint32",
"bool",
"RGBA8",
"Float4",
"Float8",
272 "Float16",
"FloatN",
"Vec4f",
"Vec4d",
"Index",
"End" };
273 static_assert(
sizeof(LUT)/
sizeof(
char*) - 1 == int(
GridType::End),
"Unexpected size of LUT" );
274 return LUT[
static_cast<int>(gridType)];
292#ifndef __CUDACC_RTC__
296 static const char * LUT[] = {
"?",
"SDF",
"FOG" ,
"MAC",
"PNTIDX",
297 "PNTDAT",
"TOPO",
"VOX",
"INDEX",
"END" };
298 static_assert(
sizeof(LUT)/
sizeof(
char*) - 1 == int(
GridClass::End),
"Unexpected size of LUT" );
299 return LUT[
static_cast<int>(gridClass)];
316#ifndef __CUDACC_RTC__
320 static const char * LUT[] = {
"has long grid name",
324 "has standard deviation",
327 static_assert( 1 << (
sizeof(LUT)/
sizeof(
char*) - 1) ==
int(
GridFlags::End),
"Unexpected size of LUT" );
328 return LUT[
static_cast<int>(gridFlags)];
355template<
typename T1,
typename T2>
358 static constexpr bool value =
false;
370template <
bool,
typename T =
void>
386 static constexpr bool value =
false;
425template<
typename AnyType,
template<
typename...>
class TemplateType>
430template<
typename... Args,
template<
typename...>
class TemplateType>
529 return reinterpret_cast<const T*
>( (
const uint8_t*)p +
alignmentPadding(p) );
534template <
typename T1,
typename T2>
538 return reinterpret_cast<const char*
>(p) -
reinterpret_cast<const char*
>(q);
541template <
typename DstT,
typename SrcT>
545 return reinterpret_cast<DstT*
>(
reinterpret_cast<char*
>(p) + offset);
548template <
typename DstT,
typename SrcT>
552 return reinterpret_cast<const DstT*
>(
reinterpret_cast<const char*
>(p) + offset);
576 : mData{(uint8_t(0.5f +
r * 255.0f)),
577 (uint8_t(0.5f +
g * 255.0f)),
578 (uint8_t(0.5f +
b * 255.0f)),
579 (uint8_t(0.5f +
a * 255.0f))}
586 return 0.0000153787005f*(float(mData.c[0])*mData.c[0] +
587 float(mData.c[1])*mData.c[1] +
588 float(mData.c[2])*mData.c[2]);
657 : mData( major << 21 | minor << 10 | patch )
673#ifndef __CUDACC_RTC__
676 char *buffer = (
char*)malloc(4 + 1 + 4 + 1 + 4 + 1);
721#if defined(__CUDA_ARCH__) || defined(__HIP__)
728struct Maximum<uint32_t>
738struct Maximum<double>
746 static T
value() {
return std::numeric_limits<T>::max(); }
751template<
typename Type>
757template<
typename Type>
760 return (a < b) ? a : b;
764 return int32_t(fminf(
float(a),
float(b)));
768 return uint32_t(fminf(
float(a),
float(b)));
778template<
typename Type>
781 return (a > b) ? a : b;
786 return int32_t(fmaxf(
float(a),
float(b)));
790 return uint32_t(fmaxf(
float(a),
float(b)));
811 return x - floorf(x);
820 return int32_t(floorf(x));
824 return int32_t(floor(x));
829 return int32_t(ceilf(x));
833 return int32_t(ceil(x));
856 return x < 0 ? -x : x;
877template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
880template<
typename CoordT,
template<
typename>
class Vec3T>
883 return CoordT(int32_t(rintf(xyz[0])), int32_t(rintf(xyz[1])), int32_t(rintf(xyz[2])));
888template<
typename CoordT,
template<
typename>
class Vec3T>
891 return CoordT(int32_t(floor(xyz[0] + 0.5)), int32_t(floor(xyz[1] + 0.5)), int32_t(floor(xyz[2] + 0.5)));
894template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
914__hostdev__ inline T
Sign(
const T &x) {
return ((T(0) < x)?T(1):T(0)) - ((x < T(0))?T(1):T(0)); }
916template<
typename Vec3T>
920 static const int hashTable[8] = {2, 1, 9, 1, 2, 9, 0, 0};
921 const int hashKey = ((v[0] < v[1]) << 2) + ((v[0] < v[2]) << 1) + (v[1] < v[2]);
922 return hashTable[hashKey];
924 if (v[0] < v[1] && v[0] < v[2])
933template<
typename Vec3T>
937 static const int hashTable[8] = {2, 1, 9, 1, 2, 9, 0, 0};
938 const int hashKey = ((v[0] > v[1]) << 2) + ((v[0] > v[2]) << 1) + (v[1] > v[2]);
939 return hashTable[hashKey];
941 if (v[0] > v[1] && v[0] > v[2])
953template<u
int64_t wordSize>
956 const uint64_t r = byteCount % wordSize;
957 return r ? byteCount - r + wordSize : byteCount;
963template<
typename>
class Vec3;
992 : mVec{ptr[0], ptr[1], ptr[2]}
1019 template <
typename CoordT>
1022 static_assert(
sizeof(
Coord) ==
sizeof(CoordT),
"Mis-matched sizeof");
1041 return mVec[0] < rhs[0] ? true : mVec[0] > rhs[0] ? false : mVec[1] < rhs[1] ? true : mVec[1] > rhs[1] ? false : mVec[2] < rhs[2] ? true :
false;
1095 if (other[0] < mVec[0])
1097 if (other[1] < mVec[1])
1099 if (other[2] < mVec[2])
1107 if (other[0] > mVec[0])
1109 if (other[1] > mVec[1])
1111 if (other[2] > mVec[2])
1118 return Coord(mVec[0] + dx, mVec[1] + dy, mVec[2] + dz);
1127 return (a[0] < b[0] || a[1] < b[1] || a[2] < b[2]);
1132 template<
typename Vec3T>
1137 template<
int Log2N = 3 + 4 + 5>
1138 __hostdev__ uint32_t
hash()
const {
return ((1 << Log2N) - 1) & (mVec[0] * 73856093 ^ mVec[1] * 19349663 ^ mVec[2] * 83492791); }
1143 (uint8_t(
bool(mVec[1] & (1u << 31))) << 1) |
1144 (uint8_t(
bool(mVec[2] & (1u << 31))) << 2)); }
1173 template<
typename T2>
1175 : mVec{T(v[0]), T(v[1]), T(v[2])}
1179 : mVec{T(ijk[0]), T(ijk[1]), T(ijk[2])}
1184 template<
typename Vec3T>
1194 template<
typename Vec3T>
1195 __hostdev__ T
dot(
const Vec3T& v)
const {
return mVec[0] * v[0] + mVec[1] * v[1] + mVec[2] * v[2]; }
1196 template<
typename Vec3T>
1199 return Vec3(mVec[1] * v[2] - mVec[2] * v[1],
1200 mVec[2] * v[0] - mVec[0] * v[2],
1201 mVec[0] * v[1] - mVec[1] * v[0]);
1205 return mVec[0] * mVec[0] + mVec[1] * mVec[1] + mVec[2] * mVec[2];
1241 if (other[0] < mVec[0])
1243 if (other[1] < mVec[1])
1245 if (other[2] < mVec[2])
1253 if (other[0] > mVec[0])
1255 if (other[1] > mVec[1])
1257 if (other[2] > mVec[2])
1264 return mVec[0] < mVec[1] ? (mVec[0] < mVec[2] ? mVec[0] : mVec[2]) : (mVec[1] < mVec[2] ? mVec[1] : mVec[2]);
1269 return mVec[0] > mVec[1] ? (mVec[0] > mVec[2] ? mVec[0] : mVec[2]) : (mVec[1] > mVec[2] ? mVec[1] : mVec[2]);
1276template<
typename T1,
typename T2>
1279 return Vec3<T2>(scalar * vec[0], scalar * vec[1], scalar * vec[2]);
1281template<
typename T1,
typename T2>
1284 return Vec3<T2>(scalar / vec[0], scalar / vec[1], scalar / vec[2]);
1318 template<
typename T2>
1320 : mVec{T(v[0]), T(v[1]), T(v[2]), T(v[3])}
1323 __hostdev__ bool operator==(
const Vec4& rhs)
const {
return mVec[0] == rhs[0] && mVec[1] == rhs[1] && mVec[2] == rhs[2] && mVec[3] == rhs[3]; }
1324 __hostdev__ bool operator!=(
const Vec4& rhs)
const {
return mVec[0] != rhs[0] || mVec[1] != rhs[1] || mVec[2] != rhs[2] || mVec[3] != rhs[3]; }
1325 template<
typename Vec4T>
1336 template<
typename Vec4T>
1337 __hostdev__ T
dot(
const Vec4T& v)
const {
return mVec[0] * v[0] + mVec[1] * v[1] + mVec[2] * v[2] + mVec[3] * v[3]; }
1340 return mVec[0] * mVec[0] + mVec[1] * mVec[1] + mVec[2] * mVec[2] + mVec[3] * mVec[3];
1379 if (other[0] < mVec[0])
1381 if (other[1] < mVec[1])
1383 if (other[2] < mVec[2])
1385 if (other[3] < mVec[3])
1393 if (other[0] > mVec[0])
1395 if (other[1] > mVec[1])
1397 if (other[2] > mVec[2])
1399 if (other[3] > mVec[3])
1405template<
typename T1,
typename T2>
1408 return Vec4<T2>(scalar * vec[0], scalar * vec[1], scalar * vec[2], scalar * vec[3]);
1410template<
typename T1,
typename T2>
1413 return Vec4<T2>(scalar / vec[0], scalar / vec[1], scalar / vec[2], scalar / vec[3]);
1423template<
typename T,
int Rank = (is_specialization<T, Vec3>::value ||
1424 is_specialization<T, Vec4>::value ||
1425 is_same<T, Rgba8>::value) ? 1 : 0>
1431 static const int Rank = 0;
1432 static const bool IsScalar =
true;
1433 static const bool IsVector =
false;
1434 static const int Size = 1;
1442 static const int Rank = 1;
1443 static const bool IsScalar =
false;
1444 static const bool IsVector =
true;
1445 static const int Size = T::SIZE;
1452template<
typename T,
int = sizeof(
typename TensorTraits<T>::ElementType)>
1485template<
typename BuildT>
1530template<
typename Vec3T>
1533 return Vec3T(fmaf(xyz[0], mat[0], fmaf(xyz[1], mat[1], xyz[2] * mat[2])),
1534 fmaf(xyz[0], mat[3], fmaf(xyz[1], mat[4], xyz[2] * mat[5])),
1535 fmaf(xyz[0], mat[6], fmaf(xyz[1], mat[7], xyz[2] * mat[8])));
1538template<
typename Vec3T>
1541 return Vec3T(fma(
static_cast<double>(xyz[0]), mat[0], fma(
static_cast<double>(xyz[1]), mat[1],
static_cast<double>(xyz[2]) * mat[2])),
1542 fma(
static_cast<double>(xyz[0]), mat[3], fma(
static_cast<double>(xyz[1]), mat[4],
static_cast<double>(xyz[2]) * mat[5])),
1543 fma(
static_cast<double>(xyz[0]), mat[6], fma(
static_cast<double>(xyz[1]), mat[7],
static_cast<double>(xyz[2]) * mat[8])));
1546template<
typename Vec3T>
1549 return Vec3T(fmaf(xyz[0], mat[0], fmaf(xyz[1], mat[1], fmaf(xyz[2], mat[2], vec[0]))),
1550 fmaf(xyz[0], mat[3], fmaf(xyz[1], mat[4], fmaf(xyz[2], mat[5], vec[1]))),
1551 fmaf(xyz[0], mat[6], fmaf(xyz[1], mat[7], fmaf(xyz[2], mat[8], vec[2]))));
1554template<
typename Vec3T>
1557 return Vec3T(fma(
static_cast<double>(xyz[0]), mat[0], fma(
static_cast<double>(xyz[1]), mat[1], fma(
static_cast<double>(xyz[2]), mat[2], vec[0]))),
1558 fma(
static_cast<double>(xyz[0]), mat[3], fma(
static_cast<double>(xyz[1]), mat[4], fma(
static_cast<double>(xyz[2]), mat[5], vec[1]))),
1559 fma(
static_cast<double>(xyz[0]), mat[6], fma(
static_cast<double>(xyz[1]), mat[7], fma(
static_cast<double>(xyz[2]), mat[8], vec[2]))));
1564template<
typename Vec3T>
1567 return Vec3T(fmaf(xyz[0], mat[0], fmaf(xyz[1], mat[3], xyz[2] * mat[6])),
1568 fmaf(xyz[0], mat[1], fmaf(xyz[1], mat[4], xyz[2] * mat[7])),
1569 fmaf(xyz[0], mat[2], fmaf(xyz[1], mat[5], xyz[2] * mat[8])));
1572template<
typename Vec3T>
1575 return Vec3T(fma(
static_cast<double>(xyz[0]), mat[0], fma(
static_cast<double>(xyz[1]), mat[3],
static_cast<double>(xyz[2]) * mat[6])),
1576 fma(
static_cast<double>(xyz[0]), mat[1], fma(
static_cast<double>(xyz[1]), mat[4],
static_cast<double>(xyz[2]) * mat[7])),
1577 fma(
static_cast<double>(xyz[0]), mat[2], fma(
static_cast<double>(xyz[1]), mat[5],
static_cast<double>(xyz[2]) * mat[8])));
1580template<
typename Vec3T>
1583 return Vec3T(fmaf(xyz[0], mat[0], fmaf(xyz[1], mat[3], fmaf(xyz[2], mat[6], vec[0]))),
1584 fmaf(xyz[0], mat[1], fmaf(xyz[1], mat[4], fmaf(xyz[2], mat[7], vec[1]))),
1585 fmaf(xyz[0], mat[2], fmaf(xyz[1], mat[5], fmaf(xyz[2], mat[8], vec[2]))));
1588template<
typename Vec3T>
1591 return Vec3T(fma(
static_cast<double>(xyz[0]), mat[0], fma(
static_cast<double>(xyz[1]), mat[3], fma(
static_cast<double>(xyz[2]), mat[6], vec[0]))),
1592 fma(
static_cast<double>(xyz[0]), mat[1], fma(
static_cast<double>(xyz[1]), mat[4], fma(
static_cast<double>(xyz[2]), mat[7], vec[1]))),
1593 fma(
static_cast<double>(xyz[0]), mat[2], fma(
static_cast<double>(xyz[1]), mat[5], fma(
static_cast<double>(xyz[2]), mat[8], vec[2]))));
1599template<
typename Vec3T>
1620 mCoord[0].minComponent(xyz);
1621 mCoord[1].maxComponent(xyz);
1654template<typename Vec3T, bool = is_floating_point<typename Vec3T::ValueType>::value>
1661template<
typename Vec3T>
1668 using BaseT::mCoord;
1685 return BBox(min, min.offsetBy(dim));
1690 mCoord[0][1] >= mCoord[1][1] ||
1691 mCoord[0][2] >= mCoord[1][2]; }
1692 __hostdev__ Vec3T
dim()
const {
return this->empty() ? Vec3T(0) : this->max() - this->min(); }
1695 return p[0] > mCoord[0][0] && p[1] > mCoord[0][1] && p[2] > mCoord[0][2] &&
1696 p[0] < mCoord[1][0] && p[1] < mCoord[1][1] && p[2] < mCoord[1][2];
1705template<
typename CoordT>
1710 using BaseT::mCoord;
1725 if (mPos[2] < mBBox[1][2]) {
1727 }
else if (mPos[1] < mBBox[1][1]) {
1728 mPos[2] = mBBox[0][2];
1730 }
else if (mPos[0] <= mBBox[1][0]) {
1731 mPos[2] = mBBox[0][2];
1732 mPos[1] = mBBox[0][1];
1749 :
BaseT(CoordT::max(), CoordT::min())
1757 template<
typename SplitT>
1759 :
BaseT(other.mCoord[0], other.mCoord[1])
1762 const int n =
MaxIndex(this->dim());
1763 mCoord[1][n] = (mCoord[0][n] + mCoord[1][n]) >> 1;
1764 other.mCoord[0][n] = mCoord[1][n] + 1;
1769 return BBox(min, min.offsetBy(dim - 1));
1773 mCoord[0][1] < mCoord[1][1] &&
1774 mCoord[0][2] < mCoord[1][2]; }
1777 mCoord[0][1] > mCoord[1][1] ||
1778 mCoord[0][2] > mCoord[1][2]; }
1780 __hostdev__ uint64_t
volume()
const {
auto d = this->dim();
return uint64_t(d[0])*uint64_t(d[1])*uint64_t(d[2]); }
1781 __hostdev__ bool isInside(
const CoordT& p)
const {
return !(CoordT::lessThan(p, this->min()) || CoordT::lessThan(this->max(), p)); }
1785 return !(CoordT::lessThan(b.min(), this->min()) || CoordT::lessThan(this->max(), b.max()));
1791 return !(CoordT::lessThan(this->max(), b.min()) || CoordT::lessThan(b.max(), this->min()));
1795 template<
typename RealT>
1800 Vec3<RealT>(RealT(mCoord[1][0] + 1), RealT(mCoord[1][1] + 1), RealT(mCoord[1][2] + 1)));
1805 return BBox(mCoord[0].offsetBy(-padding), mCoord[1].offsetBy(padding));
1821#if (defined(__CUDA_ARCH__) || defined(__HIP__)) && defined(NANOVDB_USE_INTRINSICS)
1823#elif defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS)
1824 unsigned long index;
1825 _BitScanForward(&index, v);
1826 return static_cast<uint32_t
>(index);
1827#elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS)
1828 return static_cast<uint32_t
>(__builtin_ctzl(v));
1831 static const unsigned char DeBruijn[32] = {
1832 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
1834#if defined(_MSC_VER) && !defined(__NVCC__)
1835#pragma warning(push)
1836#pragma warning(disable : 4146)
1838 return DeBruijn[uint32_t((v & -v) * 0x077CB531U) >> 27];
1839#if defined(_MSC_VER) && !defined(__NVCC__)
1853#if defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS)
1854 unsigned long index;
1855 _BitScanReverse(&index, v);
1856 return static_cast<uint32_t
>(index);
1857#elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS)
1858 return sizeof(
unsigned long) * 8 - 1 - __builtin_clzl(v);
1861 static const unsigned char DeBruijn[32] = {
1862 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30, 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31};
1868 return DeBruijn[uint32_t(v * 0x07C4ACDDU) >> 27];
1879#if (defined(__CUDA_ARCH__) || defined(__HIP__)) && defined(NANOVDB_USE_INTRINSICS)
1881#elif defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS)
1882 unsigned long index;
1883 _BitScanForward64(&index, v);
1884 return static_cast<uint32_t
>(index);
1885#elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS)
1886 return static_cast<uint32_t
>(__builtin_ctzll(v));
1889 static const unsigned char DeBruijn[64] = {
1890 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
1891 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
1892 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
1893 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12,
1896#if defined(_MSC_VER) && !defined(__NVCC__)
1897#pragma warning(push)
1898#pragma warning(disable : 4146)
1900 return DeBruijn[uint64_t((v & -v) * UINT64_C(0x022FDD63CC95386D)) >> 58];
1901#if defined(_MSC_VER) && !defined(__NVCC__)
1915#if defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS)
1916 unsigned long index;
1917 _BitScanReverse64(&index, v);
1918 return static_cast<uint32_t
>(index);
1919#elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS)
1920 return sizeof(
unsigned long) * 8 - 1 - __builtin_clzll(v);
1922 const uint32_t* p =
reinterpret_cast<const uint32_t*
>(&v);
1933#if (defined(__CUDA_ARCH__) || defined(__HIP__)) && defined(NANOVDB_USE_INTRINSICS)
1937#elif defined(_MSC_VER) && defined(_M_X64) && (_MSC_VER >= 1928) && defined(NANOVDB_USE_INTRINSICS)
1939 return __popcnt64(v);
1940#elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS)
1942 return __builtin_popcountll(v);
1945 v = v - ((v >> 1) & uint64_t(0x5555555555555555));
1946 v = (v & uint64_t(0x3333333333333333)) + ((v >> 2) & uint64_t(0x3333333333333333));
1947 return (((v + (v >> 4)) & uint64_t(0xF0F0F0F0F0F0F0F)) * uint64_t(0x101010101010101)) >> 56;
1955template<u
int32_t LOG2DIM>
1958 static constexpr uint32_t SIZE = 1U << (3 * LOG2DIM);
1959 static constexpr uint32_t WORD_COUNT = SIZE >> 6;
1960 uint64_t mWords[WORD_COUNT];
1975 uint32_t sum = 0, n = WORD_COUNT;
1976 for (
const uint64_t* w = mWords; n--; ++w)
1984 uint32_t n = i >> 6, sum =
CountOn( mWords[n] & ((uint64_t(1) << (i & 63u))-1u) );
1985 for (
const uint64_t* w = mWords; n--; ++w) sum +=
CountOn(*w);
2001 mPos = mParent->findNext<On>(mPos + 1);
2013 const Mask* mParent;
2026 for (uint32_t i = 0; i < WORD_COUNT; ++i)
2031 const uint64_t v = on ? ~uint64_t(0) : uint64_t(0);
2032 for (uint32_t i = 0; i < WORD_COUNT; ++i)
2039 for (uint32_t i = 0; i < WORD_COUNT; ++i)
2040 mWords[i] = other.mWords[i];
2044 template<
typename WordT>
2048 return reinterpret_cast<const WordT*
>(mWords)[n];
2052 template<
typename WordT>
2056 return reinterpret_cast<WordT*
>(mWords)[n];
2060 template<
typename MaskT>
2063 static_assert(
sizeof(
Mask) ==
sizeof(MaskT),
"Mismatching sizeof");
2064 static_assert(WORD_COUNT == MaskT::WORD_COUNT,
"Mismatching word count");
2065 static_assert(LOG2DIM == MaskT::LOG2DIM,
"Mismatching LOG2DIM");
2066 auto *src =
reinterpret_cast<const uint64_t*
>(&other);
2067 uint64_t *dst = mWords;
2068 for (uint32_t i = 0; i < WORD_COUNT; ++i) {
2076 for (uint32_t i = 0; i < WORD_COUNT; ++i) {
2077 if (mWords[i] != other.mWords[i])
return false;
2085 __hostdev__ bool isOn(uint32_t n)
const {
return 0 != (mWords[n >> 6] & (uint64_t(1) << (n & 63))); }
2088 __hostdev__ bool isOff(uint32_t n)
const {
return 0 == (mWords[n >> 6] & (uint64_t(1) << (n & 63))); }
2093 for (uint32_t i = 0; i < WORD_COUNT; ++i)
2094 if (mWords[i] != ~uint64_t(0))
2102 for (uint32_t i = 0; i < WORD_COUNT; ++i)
2103 if (mWords[i] != uint64_t(0))
2118 auto &word = mWords[n >> 6];
2120 word &= ~(uint64_t(1) << n);
2121 word |= uint64_t(On) << n;
2130 for (uint32_t i = 0; i < WORD_COUNT; ++i)
2131 mWords[i] = ~uint64_t(0);
2137 for (uint32_t i = 0; i < WORD_COUNT; ++i)
2138 mWords[i] = uint64_t(0);
2144 const uint64_t v = on ? ~uint64_t(0) : uint64_t(0);
2145 for (uint32_t i = 0; i < WORD_COUNT; ++i)
2151 uint32_t n = WORD_COUNT;
2152 for (
auto* w = mWords; n--; ++w)
2160 uint64_t *w1 = mWords;
2161 const uint64_t *w2 = other.mWords;
2162 for (uint32_t n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= *w2;
2168 uint64_t *w1 = mWords;
2169 const uint64_t *w2 = other.mWords;
2170 for (uint32_t n = WORD_COUNT; n--; ++w1, ++w2) *w1 |= *w2;
2176 uint64_t *w1 = mWords;
2177 const uint64_t *w2 = other.mWords;
2178 for (uint32_t n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= ~*w2;
2184 uint64_t *w1 = mWords;
2185 const uint64_t *w2 = other.mWords;
2186 for (uint32_t n = WORD_COUNT; n--; ++w1, ++w2) *w1 ^= *w2;
2197 const uint64_t* w = mWords;
2198 for (; n<WORD_COUNT && !(On ? *w : ~*w); ++w, ++n);
2199 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(On ? *w : ~*w);
2204 __hostdev__ uint32_t findNext(uint32_t start)
const
2206 uint32_t n = start >> 6;
2207 if (n >= WORD_COUNT)
2209 uint32_t m = start & 63;
2210 uint64_t b = On ? mWords[n] : ~mWords[n];
2211 if (b & (uint64_t(1) << m))
2213 b &= ~uint64_t(0) << m;
2214 while (!b && ++n < WORD_COUNT)
2215 b = On ? mWords[n] : ~mWords[n];
2235 template<
typename Mat3T,
typename Vec3T>
2236 __hostdev__ void set(
const Mat3T& mat,
const Mat3T& invMat,
const Vec3T& translate,
double taper);
2240 template<
typename Mat4T>
2241 __hostdev__ void set(
const Mat4T& mat,
const Mat4T& invMat,
double taper) {this->
set(mat, invMat, mat[3], taper);}
2243 template<
typename Vec3T>
2244 __hostdev__ void set(
double scale,
const Vec3T &translation,
double taper);
2246 template<
typename Vec3T>
2248 template<
typename Vec3T>
2251 template<
typename Vec3T>
2253 template<
typename Vec3T>
2256 template<
typename Vec3T>
2261 template<
typename Vec3T>
2267 template<
typename Vec3T>
2269 template<
typename Vec3T>
2272 template<
typename Vec3T>
2274 template<
typename Vec3T>
2278template<
typename Mat3T,
typename Vec3T>
2283 mTaperF =
static_cast<float>(taper);
2285 for (
int i = 0; i < 3; ++i) {
2286 *vd++ = translate[i];
2287 *vf++ =
static_cast<float>(translate[i]);
2288 for (
int j = 0; j < 3; ++j) {
2290 *mid++ = invMat[j][i];
2291 *mf++ =
static_cast<float>(mat[j][i]);
2292 *mif++ =
static_cast<float>(invMat[j][i]);
2297template<
typename Vec3T>
2300 const double mat[3][3] = {
2304 }, idx = 1.0/dx, invMat[3][3] = {
2309 this->
set(mat, invMat, trans, taper);
2316 static const int MaxNameSize = 256;
2323 char mName[MaxNameSize];
2333 template <
typename T>
2342template<
typename Gr
idOrTreeOrRootT,
int LEVEL>
2346template<
typename Gr
idOrTreeOrRootT>
2349 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2350 using Type =
typename GridOrTreeOrRootT::LeafNodeType;
2351 using type =
typename GridOrTreeOrRootT::LeafNodeType;
2353template<
typename Gr
idOrTreeOrRootT>
2356 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2357 using Type =
const typename GridOrTreeOrRootT::LeafNodeType;
2358 using type =
const typename GridOrTreeOrRootT::LeafNodeType;
2361template<
typename Gr
idOrTreeOrRootT>
2364 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2365 using Type =
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2366 using type =
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2368template<
typename Gr
idOrTreeOrRootT>
2371 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2372 using Type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2373 using type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2375template<
typename Gr
idOrTreeOrRootT>
2378 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2379 using Type =
typename GridOrTreeOrRootT::RootType::ChildNodeType;
2380 using type =
typename GridOrTreeOrRootT::RootType::ChildNodeType;
2382template<
typename Gr
idOrTreeOrRootT>
2385 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2386 using Type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType;
2387 using type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType;
2389template<
typename Gr
idOrTreeOrRootT>
2392 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2393 using Type =
typename GridOrTreeOrRootT::RootType;
2394 using type =
typename GridOrTreeOrRootT::RootType;
2397template<
typename Gr
idOrTreeOrRootT>
2400 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2401 using Type =
const typename GridOrTreeOrRootT::RootType;
2402 using type =
const typename GridOrTreeOrRootT::RootType;
2433 static const int MaxNameSize = 256;
2441 char mGridName[MaxNameSize];
2457 mFlags |=
static_cast<uint32_t
>(GridFlags::HasMinMax);
2459 mFlags &= ~static_cast<uint32_t>(GridFlags::HasMinMax);
2465 mFlags |=
static_cast<uint32_t
>(GridFlags::HasBBox);
2467 mFlags &= ~static_cast<uint32_t>(GridFlags::HasBBox);
2473 mFlags |=
static_cast<uint32_t
>(GridFlags::HasLongGridName);
2475 mFlags &= ~static_cast<uint32_t>(GridFlags::HasLongGridName);
2481 mFlags |=
static_cast<uint32_t
>(GridFlags::HasAverage);
2483 mFlags &= ~static_cast<uint32_t>(GridFlags::HasAverage);
2489 mFlags |=
static_cast<uint32_t
>(GridFlags::HasStdDeviation);
2491 mFlags &= ~static_cast<uint32_t>(GridFlags::HasStdDeviation);
2497 mFlags |=
static_cast<uint32_t
>(GridFlags::IsBreadthFirst);
2499 mFlags &= ~static_cast<uint32_t>(GridFlags::IsBreadthFirst);
2504 template<
typename Vec3T>
2506 template<
typename Vec3T>
2508 template<
typename Vec3T>
2510 template<
typename Vec3T>
2512 template<
typename Vec3T>
2515 template<
typename Vec3T>
2517 template<
typename Vec3T>
2519 template<
typename Vec3T>
2521 template<
typename Vec3T>
2523 template<
typename Vec3T>
2538 return PtrAdd<GridBlindMetaData>(
this, mBlindMetadataOffset) + n;
2544template <
typename BuildT,
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1>
2547template <
typename BuildT>
2554template<
typename TreeT>
2594 template <
typename T = BuildType>
2598 __hostdev__ const TreeT&
tree()
const {
return *
reinterpret_cast<const TreeT*
>(this->treePtr()); }
2613 template<
typename Vec3T>
2617 template<
typename Vec3T>
2622 template<
typename Vec3T>
2627 template<
typename Vec3T>
2632 template<
typename Vec3T>
2636 template<
typename Vec3T>
2640 template<
typename Vec3T>
2645 template<
typename Vec3T>
2650 template<
typename Vec3T>
2655 template<
typename Vec3T>
2683 __hostdev__ bool hasBBox()
const {
return DataType::mFlags &
static_cast<uint32_t
>(GridFlags::HasBBox); }
2691 template <
typename NodeT>
2696 template <
int LEVEL>
2702 if (this->hasLongGridName()) {
2704 const auto &metaData = this->blindMetaData(DataType::mBlindMetadataCount-1);
2705 NANOVDB_ASSERT(metaData.mDataClass == GridBlindDataClass::GridName);
2706 return metaData.template getBlindData<const char>();
2708 return DataType::mGridName;
2731 if (DataType::mBlindMetadataCount == 0u) {
2735 return this->blindMetaData(n).template getBlindData<void>();
2744template<
typename TreeT>
2747 for (uint32_t i = 0, n = this->blindDataCount(); i < n; ++i)
2748 if (this->blindMetaData(i).mSemantic == semantic)
2755template<
int ROOT_LEVEL = 3>
2758 static_assert(
ROOT_LEVEL == 3,
"Root level is assumed to be three");
2759 uint64_t mNodeOffset[4];
2760 uint32_t mNodeCount[3];
2761 uint32_t mTileCount[3];
2764 template <
typename RootT>
2766 template <
typename RootT>
2768 template <
typename RootT>
2771 template <
typename NodeT>
2774 mNodeOffset[NodeT::LEVEL] = node ?
PtrDiff(node,
this) : 0;
2781template<
typename Gr
idT>
2784 using Type =
typename GridT::TreeType;
2785 using type =
typename GridT::TreeType;
2787template<
typename Gr
idT>
2790 using Type =
const typename GridT::TreeType;
2791 using type =
const typename GridT::TreeType;
2797template<
typename RootT>
2800 static_assert(RootT::LEVEL == 3,
"Tree depth is not supported");
2801 static_assert(RootT::ChildNodeType::LOG2DIM == 5,
"Tree configuration is not supported");
2802 static_assert(RootT::ChildNodeType::ChildNodeType::LOG2DIM == 4,
"Tree configuration is not supported");
2803 static_assert(RootT::LeafNodeType::LOG2DIM == 3,
"Tree configuration is not supported");
2815 using Node2 =
typename RootT::ChildNodeType;
2816 using Node1 =
typename Node2::ChildNodeType;
2854 __hostdev__ void extrema(ValueType& min, ValueType& max)
const;
2870 return DataType::mTileCount[level - 1];
2873 template<
typename NodeT>
2876 static_assert(NodeT::LEVEL < 3,
"Invalid NodeT");
2877 return DataType::mNodeCount[NodeT::LEVEL];
2883 return DataType::mNodeCount[level];
2889 template <
typename NodeT>
2892 const uint64_t offset = DataType::mNodeOffset[NodeT::LEVEL];
2893 return offset>0 ? PtrAdd<NodeT>(
this, offset) :
nullptr;
2899 template <
typename NodeT>
2902 const uint64_t offset = DataType::mNodeOffset[NodeT::LEVEL];
2903 return offset>0 ? PtrAdd<NodeT>(
this, offset) :
nullptr;
2909 template <
int LEVEL>
2913 return this->
template getFirstNode<typename NodeTrait<RootT,LEVEL>::type>();
2919 template <
int LEVEL>
2923 return this->
template getFirstNode<typename NodeTrait<RootT,LEVEL>::type>();
2939template<
typename RootT>
2942 min = this->root().minimum();
2943 max = this->root().maximum();
2951template<
typename ChildT>
2958 static constexpr bool FIXED_SIZE =
false;
2961#ifdef USE_SINGLE_ROOT_KEY
2963 template <
typename CoordType>
2966 static_assert(
sizeof(
CoordT) ==
sizeof(CoordType),
"Mismatching sizeof");
2967 static_assert(32 - ChildT::TOTAL <= 21,
"Cannot use 64 bit root keys");
2968 return (
KeyT(uint32_t(ijk[2]) >> ChildT::TOTAL)) |
2969 (
KeyT(uint32_t(ijk[1]) >> ChildT::TOTAL) << 21) |
2970 (
KeyT(uint32_t(ijk[0]) >> ChildT::TOTAL) << 42);
2974 static constexpr uint64_t MASK = (1u << 21) - 1;
2975 return CoordT(((key >> 42) & MASK) << ChildT::TOTAL,
2976 ((key >> 21) & MASK) << ChildT::TOTAL,
2977 (key & MASK) << ChildT::TOTAL);
2980 using KeyT = CoordT;
2981 __hostdev__ static KeyT CoordToKey(
const CoordT& ijk) {
return ijk & ~ChildT::MASK; }
2982 __hostdev__ static CoordT KeyToCoord(
const KeyT& key) {
return key; }
3000 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
Tile
3002 template <
typename CoordType>
3005 key = CoordToKey(k);
3008 template <
typename CoordType,
typename ValueType>
3011 key = CoordToKey(k);
3032 return reinterpret_cast<const Tile*
>(
this + 1) + n;
3037 return reinterpret_cast<Tile*
>(
this + 1) + n;
3046 return PtrAdd<ChildT>(
this, tile->
child);
3051 return PtrAdd<ChildT>(
this, tile->
child);
3072template<
typename ChildT>
3089 static constexpr bool FIXED_SIZE = DataType::FIXED_SIZE;
3091 static constexpr uint32_t LEVEL = 1 + ChildT::LEVEL;
3096 uint32_t mPos, mSize;
3101 while (mPos<mSize && !mParent->tile(mPos)->isChild()) ++mPos;
3112 while (mPos < mSize && mParent->tile(mPos)->isValue()) ++mPos;
3127 uint32_t mPos, mSize;
3132 while (mPos < mSize && mParent->tile(mPos)->isChild()) ++mPos;
3143 while (mPos < mSize && mParent->tile(mPos)->isChild()) ++mPos;
3158 uint32_t mPos, mSize;
3163 while (mPos < mSize && !mParent->tile(mPos)->isActive()) ++mPos;
3173 while (mPos < mSize && !mParent->tile(mPos)->isActive()) ++mPos;
3233 if (
const Tile* tile = this->probeTile(ijk)) {
3234 return tile->isChild() ? this->getChild(tile)->getValue(ijk) : tile->value;
3236 return DataType::mBackground;
3241 if (
const Tile* tile = this->probeTile(ijk)) {
3242 return tile->isChild() ? this->getChild(tile)->isActive(ijk) : tile->state;
3252 if (
const Tile* tile = this->probeTile(ijk)) {
3253 if (tile->isChild()) {
3254 const auto *
child = this->getChild(tile);
3255 return child->probeValue(ijk, v);
3260 v = DataType::mBackground;
3266 const Tile* tile = this->probeTile(ijk);
3267 if (tile && tile->isChild()) {
3268 const auto *
child = this->getChild(tile);
3269 return child->probeLeaf(ijk);
3276 const Tile* tile = this->probeTile(ijk);
3277 if (tile && tile->isChild()) {
3278 return this->getChild(tile);
3286 const Tile* tiles =
reinterpret_cast<const Tile*
>(
this + 1);
3287 const auto key = DataType::CoordToKey(ijk);
3289 for (uint32_t i = 0; i < DataType::mTableSize; ++i) {
3290 if (tiles[i].key == key)
return &tiles[i];
3294 int32_t low = 0, high = DataType::mTableSize;
3295 while (low != high) {
3296 int mid = low + ((high - low) >> 1);
3297 const Tile* tile = &tiles[mid];
3298 if (tile->key == key) {
3300 }
else if (tile->key < key) {
3312 static_assert(
sizeof(
typename DataType::Tile) %
NANOVDB_DATA_ALIGNMENT == 0,
"sizeof(RootData::Tile) is misaligned");
3314 template<
typename,
int,
int,
int>
3321 template<
typename AccT>
3322 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ijk,
const AccT& acc)
const
3324 using NodeInfoT =
typename AccT::NodeInfo;
3325 if (
const Tile* tile = this->probeTile(ijk)) {
3326 if (tile->isChild()) {
3327 const auto *
child = this->getChild(tile);
3328 acc.insert(ijk,
child);
3329 return child->getNodeInfoAndCache(ijk, acc);
3331 return NodeInfoT{LEVEL, ChildT::dim(), tile->value, tile->value, tile->value,
3332 0, tile->origin(), tile->origin() + CoordType(ChildT::DIM)};
3334 return NodeInfoT{LEVEL, ChildT::dim(), this->minimum(), this->maximum(),
3335 this->average(), this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
3339 template<
typename AccT>
3340 __hostdev__ ValueType getValueAndCache(
const CoordType& ijk,
const AccT& acc)
const
3342 if (
const Tile* tile = this->probeTile(ijk)) {
3343 if (tile->isChild()) {
3344 const auto *
child = this->getChild(tile);
3345 acc.insert(ijk,
child);
3346 return child->getValueAndCache(ijk, acc);
3350 return DataType::mBackground;
3353 template<
typename AccT>
3354 __hostdev__ bool isActiveAndCache(
const CoordType& ijk,
const AccT& acc)
const
3356 const Tile* tile = this->probeTile(ijk);
3357 if (tile && tile->isChild()) {
3358 const auto *
child = this->getChild(tile);
3359 acc.insert(ijk,
child);
3360 return child->isActiveAndCache(ijk, acc);
3365 template<
typename AccT>
3366 __hostdev__ bool probeValueAndCache(
const CoordType& ijk, ValueType& v,
const AccT& acc)
const
3368 if (
const Tile* tile = this->probeTile(ijk)) {
3369 if (tile->isChild()) {
3370 const auto *
child = this->getChild(tile);
3371 acc.insert(ijk,
child);
3372 return child->probeValueAndCache(ijk, v, acc);
3377 v = DataType::mBackground;
3381 template<
typename AccT>
3382 __hostdev__ const LeafNodeType* probeLeafAndCache(
const CoordType& ijk,
const AccT& acc)
const
3384 const Tile* tile = this->probeTile(ijk);
3385 if (tile && tile->isChild()) {
3386 const auto *
child = this->getChild(tile);
3387 acc.insert(ijk,
child);
3388 return child->probeLeafAndCache(ijk, acc);
3393 template<
typename RayT,
typename AccT>
3394 __hostdev__ uint32_t getDimAndCache(
const CoordType& ijk,
const RayT& ray,
const AccT& acc)
const
3396 if (
const Tile* tile = this->probeTile(ijk)) {
3397 if (tile->isChild()) {
3398 const auto *
child = this->getChild(tile);
3399 acc.insert(ijk,
child);
3400 return child->getDimAndCache(ijk, ray, acc);
3402 return 1 << ChildT::TOTAL;
3404 return ChildNodeType::dim();
3416template<
typename ChildT, u
int32_t LOG2DIM>
3423 using MaskT =
typename ChildT::template MaskType<LOG2DIM>;
3424 static constexpr bool FIXED_SIZE =
true;
3453 + (1u << (3 * LOG2DIM))*(
sizeof(
ValueT) > 8u ?
sizeof(
ValueT) : 8u));
3455 alignas(32)
Tile mTable[1u << (3 * LOG2DIM)];
3462 mTable[n].child =
PtrDiff(ptr,
this);
3465 template <
typename ValueT>
3469 mTable[n].value = v;
3476 return PtrAdd<ChildT>(
this, mTable[n].
child);
3481 return PtrAdd<ChildT>(
this, mTable[n].
child);
3487 return mTable[n].value;
3493 return mValueMask.isOn(n);
3498 template <
typename T>
3519template<
typename ChildT, u
int32_t Log2Dim = ChildT::LOG2DIM + 1>
3530 static constexpr bool FIXED_SIZE = DataType::FIXED_SIZE;
3531 template<u
int32_t LOG2>
3536 static constexpr uint32_t LOG2DIM = Log2Dim;
3537 static constexpr uint32_t TOTAL = LOG2DIM + ChildT::TOTAL;
3538 static constexpr uint32_t DIM = 1u << TOTAL;
3539 static constexpr uint32_t SIZE = 1u << (3 * LOG2DIM);
3540 static constexpr uint32_t MASK = (1u << TOTAL) - 1u;
3541 static constexpr uint32_t LEVEL = 1 + ChildT::LEVEL;
3542 static constexpr uint64_t NUM_VALUES = uint64_t(1) << (3 * TOTAL);
3637 const uint32_t n = CoordToOffset(ijk);
3638 return DataType::mChildMask.isOn(n) ? this->getChild(n)->getValue(ijk) : DataType::getValue(n);
3643 const uint32_t n = CoordToOffset(ijk);
3644 return DataType::mChildMask.isOn(n) ? this->getChild(n)->isActive(ijk) : DataType::isActive(n);
3650 const uint32_t n = CoordToOffset(ijk);
3651 if (DataType::mChildMask.isOn(n))
3652 return this->getChild(n)->probeValue(ijk, v);
3653 v = DataType::getValue(n);
3654 return DataType::isActive(n);
3659 const uint32_t n = CoordToOffset(ijk);
3660 if (DataType::mChildMask.isOn(n))
3661 return this->getChild(n)->probeLeaf(ijk);
3667 const uint32_t n = CoordToOffset(ijk);
3668 return DataType::mChildMask.isOn(n) ? this->getChild(n) :
nullptr;
3675 return (((ijk[0] & MASK) >> ChildT::TOTAL) << (2 * LOG2DIM)) +
3676 (((ijk[1] & MASK) >> ChildT::TOTAL) << (LOG2DIM)) +
3677 ((ijk[2] & MASK) >> ChildT::TOTAL);
3679 return (((ijk[0] & MASK) >> ChildT::TOTAL) << (2 * LOG2DIM)) |
3680 (((ijk[1] & MASK) >> ChildT::TOTAL) << (LOG2DIM)) |
3681 ((ijk[2] & MASK) >> ChildT::TOTAL);
3689 const uint32_t m = n & ((1 << 2 * LOG2DIM) - 1);
3690 return Coord(n >> 2 * LOG2DIM, m >> LOG2DIM, m & ((1 << LOG2DIM) - 1));
3696 ijk <<= ChildT::TOTAL;
3697 ijk += this->origin();
3702 Coord ijk = InternalNode::OffsetToLocalCoord(n);
3703 this->localToGlobalCoord(ijk);
3710 return DataType::mFlags & uint32_t(2);
3717 template<
typename,
int,
int,
int>
3722 template<
typename, u
int32_t>
3726 template<
typename AccT>
3729 const uint32_t n = CoordToOffset(ijk);
3730 if (!DataType::mChildMask.isOn(n))
3731 return DataType::getValue(n);
3732 const ChildT*
child = this->getChild(n);
3733 acc.insert(ijk,
child);
3734 return child->getValueAndCache(ijk, acc);
3737 template<
typename AccT>
3738 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ijk,
const AccT& acc)
const
3740 using NodeInfoT =
typename AccT::NodeInfo;
3741 const uint32_t n = CoordToOffset(ijk);
3742 if (!DataType::mChildMask.isOn(n)) {
3743 return NodeInfoT{LEVEL, this->dim(), this->minimum(), this->maximum(), this->average(),
3744 this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
3746 const ChildT*
child = this->getChild(n);
3747 acc.insert(ijk,
child);
3748 return child->getNodeInfoAndCache(ijk, acc);
3751 template<
typename AccT>
3752 __hostdev__ bool isActiveAndCache(
const CoordType& ijk,
const AccT& acc)
const
3754 const uint32_t n = CoordToOffset(ijk);
3755 if (!DataType::mChildMask.isOn(n))
3756 return DataType::isActive(n);
3757 const ChildT*
child = this->getChild(n);
3758 acc.insert(ijk,
child);
3759 return child->isActiveAndCache(ijk, acc);
3762 template<
typename AccT>
3763 __hostdev__ bool probeValueAndCache(
const CoordType& ijk, ValueType& v,
const AccT& acc)
const
3765 const uint32_t n = CoordToOffset(ijk);
3766 if (!DataType::mChildMask.isOn(n)) {
3767 v = DataType::getValue(n);
3768 return DataType::isActive(n);
3770 const ChildT*
child = this->getChild(n);
3771 acc.insert(ijk,
child);
3772 return child->probeValueAndCache(ijk, v, acc);
3775 template<
typename AccT>
3776 __hostdev__ const LeafNodeType* probeLeafAndCache(
const CoordType& ijk,
const AccT& acc)
const
3778 const uint32_t n = CoordToOffset(ijk);
3779 if (!DataType::mChildMask.isOn(n))
3781 const ChildT*
child = this->getChild(n);
3782 acc.insert(ijk,
child);
3783 return child->probeLeafAndCache(ijk, acc);
3786 template<
typename RayT,
typename AccT>
3787 __hostdev__ uint32_t getDimAndCache(
const CoordType& ijk,
const RayT& ray,
const AccT& acc)
const
3789 if (DataType::mFlags & uint32_t(1u))
return this->dim();
3792 const uint32_t n = CoordToOffset(ijk);
3793 if (DataType::mChildMask.isOn(n)) {
3794 const ChildT*
child = this->getChild(n);
3795 acc.insert(ijk,
child);
3796 return child->getDimAndCache(ijk, ray, acc);
3798 return ChildNodeType::dim();
3808template<
typename ValueT,
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3811 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3812 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3817 static constexpr bool FIXED_SIZE =
true;
3820 uint8_t mBBoxDif[3];
3834 return sizeof(
LeafData) - (12 + 3 + 1 +
sizeof(MaskT<LOG2DIM>)
3835 + 2*(
sizeof(ValueT) +
sizeof(
FloatType))
3836 + (1u << (3 * LOG2DIM))*
sizeof(ValueT));
3845 mValueMask.setOn(offset);
3846 mValues[offset] =
value;
3859 template <
typename T>
3870template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3873 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3874 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3879 uint8_t mBBoxDif[3];
3893 return sizeof(
LeafFnBase) - (12 + 3 + 1 +
sizeof(MaskT<LOG2DIM>) + 2*4 + 4*2);
3898 mQuantum = (max - min)/
float((1 << bitWidth)-1);
3926 template <
typename T>
3933template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3934struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp4, CoordT, MaskT, LOG2DIM>
3940 static constexpr bool FIXED_SIZE =
true;
3941 alignas(32) uint8_t mCode[1u << (3 * LOG2DIM - 1)];
3945 static_assert(BaseT::padding()==0,
"expected no padding in LeafFnBase");
3946 return sizeof(
LeafData) -
sizeof(
BaseT) - (1u << (3 * LOG2DIM - 1));
3953 const uint8_t c = mCode[i>>1];
3954 return ( (i&1) ? c >> 4 : c & uint8_t(15) )*BaseT::mQuantum + BaseT::mMinimum;
3956 return ((mCode[i>>1] >> ((i&1)<<2)) & uint8_t(15))*BaseT::mQuantum + BaseT::mMinimum;
3967template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3968struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp8, CoordT, MaskT, LOG2DIM>
3974 static constexpr bool FIXED_SIZE =
true;
3975 alignas(32) uint8_t mCode[1u << 3 * LOG2DIM];
3978 static_assert(BaseT::padding()==0,
"expected no padding in LeafFnBase");
3979 return sizeof(
LeafData) -
sizeof(
BaseT) - (1u << 3 * LOG2DIM);
3985 return mCode[i]*BaseT::mQuantum + BaseT::mMinimum;
3994template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3995struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp16, CoordT, MaskT, LOG2DIM>
4001 static constexpr bool FIXED_SIZE =
true;
4002 alignas(32) uint16_t mCode[1u << 3 * LOG2DIM];
4006 static_assert(BaseT::padding()==0,
"expected no padding in LeafFnBase");
4007 return sizeof(
LeafData) -
sizeof(
BaseT) - 2*(1u << 3 * LOG2DIM);
4013 return mCode[i]*BaseT::mQuantum + BaseT::mMinimum;
4023template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
4024struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
FpN, CoordT, MaskT, LOG2DIM>
4030 static constexpr bool FIXED_SIZE =
false;
4032 static_assert(BaseT::padding()==0,
"expected no padding in LeafFnBase");
4041#ifdef NANOVDB_FPN_BRANCHLESS
4042 const int b = BaseT::mFlags >> 5;
4044 uint16_t code =
reinterpret_cast<const uint16_t*
>(
this + 1)[i >> (4 - b)];
4045 const static uint8_t shift[5] = {15, 7, 3, 1, 0};
4046 const static uint16_t mask[5] = {1, 3, 15, 255, 65535};
4047 code >>= (i & shift[b]) << b;
4050 uint32_t code =
reinterpret_cast<const uint32_t*
>(
this + 1)[i >> (5 - b)];
4052 code >>= (i & ((32 >> b) - 1)) << b;
4053 code &= (1 << (1 << b)) - 1;
4057 auto *values =
reinterpret_cast<const uint8_t*
>(
this+1);
4058 switch (BaseT::mFlags >> 5) {
4060 code = float((values[i>>3] >> (i&7) ) & uint8_t(1));
4063 code = float((values[i>>2] >> ((i&3)<<1)) & uint8_t(3));
4066 code = float((values[i>>1] >> ((i&1)<<2)) & uint8_t(15));
4069 code = float(values[i]);
4072 code = float(
reinterpret_cast<const uint16_t*
>(values)[i]);
4075 return float(code) * BaseT::mQuantum + BaseT::mMinimum;
4086template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
4087struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<bool, CoordT, MaskT, LOG2DIM>
4089 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
4090 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
4095 static constexpr bool FIXED_SIZE =
true;
4098 uint8_t mBBoxDif[3];
4102 uint64_t mPadding[2];
4115 mValueMask.setOn(offset);
4116 mValues.set(offset, v);
4124 template <
typename T>
4135template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
4138 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
4139 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
4144 static constexpr bool FIXED_SIZE =
true;
4147 uint8_t mBBoxDif[3];
4150 uint64_t mPadding[2];
4155 return sizeof(
LeafData) - (12u + 3u + 1u +
sizeof(MaskT<LOG2DIM>) + 2*8u);
4166 mValueMask.setOn(offset);
4174 template <
typename T>
4185template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
4188 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
4189 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
4194 static constexpr bool FIXED_SIZE =
true;
4197 uint8_t mBBoxDif[3];
4206 return sizeof(
LeafData) - (12u + 3u + 1u +
sizeof(MaskT<LOG2DIM>) + 2*8u);
4217 mValueMask.setOn(offset);
4222 if (mFlags & uint8_t(16u)) {
4223 return mValueMask.isOn(i) ? mValueOff + mValueMask.countOn(i) : 0;
4225 return mValueOff + i;
4228 template <
typename T>
4230 template <
typename T>
4232 template <
typename T>
4234 template <
typename T>
4236 template <
typename T>
4247template<
typename BuildT,
4248 typename CoordT =
Coord,
4249 template<u
int32_t>
class MaskT =
Mask,
4250 uint32_t Log2Dim = 3>
4256 static constexpr uint32_t TOTAL = 0;
4257 static constexpr uint32_t DIM = 1;
4266 static constexpr bool FIXED_SIZE = DataType::FIXED_SIZE;
4267 template<u
int32_t LOG2>
4314 __hostdev__ operator bool()
const {
return mPos < (1u << 3 * Log2Dim);}
4326 static constexpr uint32_t LOG2DIM = Log2Dim;
4327 static constexpr uint32_t TOTAL = LOG2DIM;
4328 static constexpr uint32_t DIM = 1u << TOTAL;
4329 static constexpr uint32_t SIZE = 1u << 3 * LOG2DIM;
4330 static constexpr uint32_t MASK = (1u << LOG2DIM) - 1u;
4331 static constexpr uint32_t LEVEL = 0;
4332 static constexpr uint64_t NUM_VALUES = uint64_t(1) << (3 * TOTAL);
4364 const uint32_t m = n & ((1 << 2 * LOG2DIM) - 1);
4365 return CoordT(n >> 2 * LOG2DIM, m >> LOG2DIM, m & MASK);
4373 return OffsetToLocalCoord(n) + this->origin();
4382 BBox<CoordT> bbox(DataType::mBBoxMin, DataType::mBBoxMin);
4383 if ( this->hasBBox() ) {
4384 bbox.max()[0] += DataType::mBBoxDif[0];
4385 bbox.max()[1] += DataType::mBBoxDif[1];
4386 bbox.max()[2] += DataType::mBBoxDif[2];
4433 return !DataType::mValueMask.isOff();
4441 const uint32_t n = CoordToOffset(ijk);
4442 v = DataType::getValue(n);
4443 return DataType::mValueMask.isOn(n);
4452 return ((ijk[0] & MASK) << (2 * LOG2DIM)) + ((ijk[1] & MASK) << LOG2DIM) + (ijk[2] & MASK);
4454 return ((ijk[0] & MASK) << (2 * LOG2DIM)) | ((ijk[1] & MASK) << LOG2DIM) | (ijk[2] & MASK);
4471 template<
typename,
int,
int,
int>
4476 template<
typename, u
int32_t>
4480 template<
typename AccT>
4481 __hostdev__ ValueType getValueAndCache(
const CoordT& ijk,
const AccT&)
const {
return this->getValue(ijk); }
4484 template<
typename AccT>
4485 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ,
const AccT& )
const {
4486 using NodeInfoT =
typename AccT::NodeInfo;
4487 return NodeInfoT{LEVEL, this->dim(), this->minimum(), this->maximum(),
4488 this->average(), this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
4491 template<
typename AccT>
4492 __hostdev__ bool isActiveAndCache(
const CoordT& ijk,
const AccT&)
const {
return this->isActive(ijk); }
4494 template<
typename AccT>
4495 __hostdev__ bool probeValueAndCache(
const CoordT& ijk, ValueType& v,
const AccT&)
const {
return this->probeValue(ijk, v); }
4497 template<
typename AccT>
4498 __hostdev__ const LeafNode* probeLeafAndCache(
const CoordT&,
const AccT&)
const {
return this; }
4500 template<
typename RayT,
typename AccT>
4501 __hostdev__ uint32_t getDimAndCache(
const CoordT&,
const RayT& ,
const AccT&)
const
4503 if (DataType::mFlags & uint8_t(1u))
return this->dim();
4506 return ChildNodeType::dim();
4511template<
typename ValueT,
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
4514 static_assert(LOG2DIM == 3,
"LeafNode::updateBBox: only supports LOGDIM = 3!");
4515 if (DataType::mValueMask.isOff()) {
4516 DataType::mFlags &= ~uint8_t(2);
4519 auto update = [&](uint32_t min, uint32_t max,
int axis) {
4521 DataType::mBBoxMin[axis] = (DataType::mBBoxMin[axis] & ~MASK) +
int(min);
4522 DataType::mBBoxDif[axis] = uint8_t(max - min);
4524 uint64_t word64 = DataType::mValueMask.template getWord<uint64_t>(0);
4525 uint32_t Xmin = word64 ? 0u : 8u;
4526 uint32_t Xmax = Xmin;
4527 for (
int i = 1; i < 8; ++i) {
4528 if (uint64_t w = DataType::mValueMask.
template getWord<uint64_t>(i)) {
4537 update(Xmin, Xmax, 0);
4538 update(FindLowestOn(word64) >> 3, FindHighestOn(word64) >> 3, 1);
4539 const uint32_t *p =
reinterpret_cast<const uint32_t*
>(&word64), word32 = p[0] | p[1];
4540 const uint16_t *q =
reinterpret_cast<const uint16_t*
>(&word32), word16 = q[0] | q[1];
4541 const uint8_t *b =
reinterpret_cast<const uint8_t*
>(&word16),
byte = b[0] | b[1];
4543 update(FindLowestOn(
static_cast<uint32_t
>(
byte)), FindHighestOn(
static_cast<uint32_t
>(
byte)), 2);
4544 DataType::mFlags |= uint8_t(2);
4552template<
typename BuildT>
4554template<
typename BuildT>
4556template<
typename BuildT>
4558template<
typename BuildT>
4560template<
typename BuildT>
4562template<
typename BuildT>
4566template<
typename BuildT,
int LEVEL>
4570template<
typename BuildT>
4576template<
typename BuildT>
4582template<
typename BuildT>
4588template<
typename BuildT>
4644template <
typename BuildT>
4654 mutable const RootT* mRoot;
4659 static const int CacheLevels = 0;
4694 return mRoot->getValueAndCache(ijk, *
this);
4698 return this->getValue(ijk);
4702 return this->getValue(
CoordType(i,j,k));
4707 return mRoot->getNodeInfoAndCache(ijk, *
this);
4712 return mRoot->isActiveAndCache(ijk, *
this);
4717 return mRoot->probeValueAndCache(ijk, v, *
this);
4722 return mRoot->probeLeafAndCache(ijk, *
this);
4725 template<
typename RayT>
4728 return mRoot->getDimAndCache(ijk, ray, *
this);
4735 template<
typename, u
int32_t>
4737 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4741 template<
typename NodeT>
4746template <
typename BuildT,
int LEVEL0>
4749 static_assert(LEVEL0 >= 0 && LEVEL0 <= 2,
"LEVEL0 should be 0, 1, or 2");
4763 mutable CoordT mKey;
4764 mutable const RootT* mRoot;
4765 mutable const NodeT* mNode;
4771 static const int CacheLevels = 1;
4792 mKey = CoordType::max();
4805 return (ijk[0] & int32_t(~NodeT::MASK)) == mKey[0] &&
4806 (ijk[1] & int32_t(~NodeT::MASK)) == mKey[1] &&
4807 (ijk[2] & int32_t(~NodeT::MASK)) == mKey[2];
4812 if (this->isCached(ijk)) {
4813 return mNode->getValueAndCache(ijk, *
this);
4815 return mRoot->getValueAndCache(ijk, *
this);
4819 return this->getValue(ijk);
4823 return this->getValue(
CoordType(i,j,k));
4828 if (this->isCached(ijk)) {
4829 return mNode->getNodeInfoAndCache(ijk, *
this);
4831 return mRoot->getNodeInfoAndCache(ijk, *
this);
4836 if (this->isCached(ijk)) {
4837 return mNode->isActiveAndCache(ijk, *
this);
4839 return mRoot->isActiveAndCache(ijk, *
this);
4844 if (this->isCached(ijk)) {
4845 return mNode->probeValueAndCache(ijk, v, *
this);
4847 return mRoot->probeValueAndCache(ijk, v, *
this);
4852 if (this->isCached(ijk)) {
4853 return mNode->probeLeafAndCache(ijk, *
this);
4855 return mRoot->probeLeafAndCache(ijk, *
this);
4858 template<
typename RayT>
4861 if (this->isCached(ijk)) {
4862 return mNode->getDimAndCache(ijk, ray, *
this);
4864 return mRoot->getDimAndCache(ijk, ray, *
this);
4871 template<
typename, u
int32_t>
4873 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4879 mKey = ijk & ~NodeT::MASK;
4884 template<
typename OtherNodeT>
4885 __hostdev__ void insert(
const CoordType&,
const OtherNodeT*)
const {}
4889template <
typename BuildT,
int LEVEL0,
int LEVEL1>
4892 static_assert(LEVEL0 >= 0 && LEVEL0 <= 2,
"LEVEL0 must be 0, 1, 2");
4893 static_assert(LEVEL1 >= 0 && LEVEL1 <= 2,
"LEVEL1 must be 0, 1, 2");
4894 static_assert(LEVEL0 < LEVEL1,
"Level 0 must be lower than level 1");
4907#ifdef USE_SINGLE_ACCESSOR_KEY
4908 mutable CoordT mKey;
4910 mutable CoordT mKeys[2];
4912 mutable const RootT* mRoot;
4913 mutable const Node1T* mNode1;
4914 mutable const Node2T* mNode2;
4920 static const int CacheLevels = 2;
4926#ifdef USE_SINGLE_ACCESSOR_KEY
4927 : mKey(CoordType::max())
4929 : mKeys{CoordType::max(), CoordType::max()}
4946#ifdef USE_SINGLE_ACCESSOR_KEY
4947 mKey = CoordType::max();
4949 mKeys[0] = mKeys[1] = CoordType::max();
4962#ifdef USE_SINGLE_ACCESSOR_KEY
4963 __hostdev__ bool isCached1(CoordValueType dirty)
const
4967 if (dirty & int32_t(~Node1T::MASK)) {
4973 __hostdev__ bool isCached2(CoordValueType dirty)
const
4977 if (dirty & int32_t(~Node2T::MASK)) {
4983 __hostdev__ CoordValueType computeDirty(
const CoordType& ijk)
const
4985 return (ijk[0] ^ mKey[0]) | (ijk[1] ^ mKey[1]) | (ijk[2] ^ mKey[2]);
4990 return (ijk[0] & int32_t(~Node1T::MASK)) == mKeys[0][0] &&
4991 (ijk[1] & int32_t(~Node1T::MASK)) == mKeys[0][1] &&
4992 (ijk[2] & int32_t(~Node1T::MASK)) == mKeys[0][2];
4996 return (ijk[0] & int32_t(~Node2T::MASK)) == mKeys[1][0] &&
4997 (ijk[1] & int32_t(~Node2T::MASK)) == mKeys[1][1] &&
4998 (ijk[2] & int32_t(~Node2T::MASK)) == mKeys[1][2];
5004#ifdef USE_SINGLE_ACCESSOR_KEY
5005 const CoordValueType dirty = this->computeDirty(ijk);
5009 if (this->isCached1(dirty)) {
5010 return mNode1->getValueAndCache(ijk, *
this);
5011 }
else if (this->isCached2(dirty)) {
5012 return mNode2->getValueAndCache(ijk, *
this);
5014 return mRoot->getValueAndCache(ijk, *
this);
5018 return this->getValue(ijk);
5022 return this->getValue(
CoordType(i,j,k));
5027#ifdef USE_SINGLE_ACCESSOR_KEY
5028 const CoordValueType dirty = this->computeDirty(ijk);
5032 if (this->isCached1(dirty)) {
5033 return mNode1->getNodeInfoAndCache(ijk, *
this);
5034 }
else if (this->isCached2(dirty)) {
5035 return mNode2->getNodeInfoAndCache(ijk, *
this);
5037 return mRoot->getNodeInfoAndCache(ijk, *
this);
5042#ifdef USE_SINGLE_ACCESSOR_KEY
5043 const CoordValueType dirty = this->computeDirty(ijk);
5047 if (this->isCached1(dirty)) {
5048 return mNode1->isActiveAndCache(ijk, *
this);
5049 }
else if (this->isCached2(dirty)) {
5050 return mNode2->isActiveAndCache(ijk, *
this);
5052 return mRoot->isActiveAndCache(ijk, *
this);
5057#ifdef USE_SINGLE_ACCESSOR_KEY
5058 const CoordValueType dirty = this->computeDirty(ijk);
5062 if (this->isCached1(dirty)) {
5063 return mNode1->probeValueAndCache(ijk, v, *
this);
5064 }
else if (this->isCached2(dirty)) {
5065 return mNode2->probeValueAndCache(ijk, v, *
this);
5067 return mRoot->probeValueAndCache(ijk, v, *
this);
5072#ifdef USE_SINGLE_ACCESSOR_KEY
5073 const CoordValueType dirty = this->computeDirty(ijk);
5077 if (this->isCached1(dirty)) {
5078 return mNode1->probeLeafAndCache(ijk, *
this);
5079 }
else if (this->isCached2(dirty)) {
5080 return mNode2->probeLeafAndCache(ijk, *
this);
5082 return mRoot->probeLeafAndCache(ijk, *
this);
5085 template<
typename RayT>
5088#ifdef USE_SINGLE_ACCESSOR_KEY
5089 const CoordValueType dirty = this->computeDirty(ijk);
5093 if (this->isCached1(dirty)) {
5094 return mNode1->getDimAndCache(ijk, ray, *
this);
5095 }
else if (this->isCached2(dirty)) {
5096 return mNode2->getDimAndCache(ijk, ray, *
this);
5098 return mRoot->getDimAndCache(ijk, ray, *
this);
5105 template<
typename, u
int32_t>
5107 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
5113#ifdef USE_SINGLE_ACCESSOR_KEY
5116 mKeys[0] = ijk & ~Node1T::MASK;
5120 __hostdev__ void insert(
const CoordType& ijk,
const Node2T* node)
const
5122#ifdef USE_SINGLE_ACCESSOR_KEY
5125 mKeys[1] = ijk & ~Node2T::MASK;
5129 template <
typename OtherNodeT>
5130 __hostdev__ void insert(
const CoordType&,
const OtherNodeT*)
const {}
5135template <
typename BuildT>
5151#ifdef USE_SINGLE_ACCESSOR_KEY
5152 mutable CoordT mKey;
5154 mutable CoordT mKeys[3];
5156 mutable const RootT* mRoot;
5157 mutable const void* mNode[3];
5163 static const int CacheLevels = 3;
5169#ifdef USE_SINGLE_ACCESSOR_KEY
5170 : mKey(CoordType::max())
5172 : mKeys{CoordType::max(), CoordType::max(), CoordType::max()}
5175 , mNode{
nullptr,
nullptr,
nullptr}
5195 template<
typename NodeT>
5200 return reinterpret_cast<const T*
>(mNode[NodeT::LEVEL]);
5203 template <
int LEVEL>
5207 static_assert(LEVEL>=0 && LEVEL<=2,
"ReadAccessor::getNode: Invalid node type");
5208 return reinterpret_cast<const T*
>(mNode[LEVEL]);
5215#ifdef USE_SINGLE_ACCESSOR_KEY
5216 mKey = CoordType::max();
5218 mKeys[0] = mKeys[1] = mKeys[2] = CoordType::max();
5220 mNode[0] = mNode[1] = mNode[2] =
nullptr;
5223#ifdef USE_SINGLE_ACCESSOR_KEY
5224 template<
typename NodeT>
5225 __hostdev__ bool isCached(CoordValueType dirty)
const
5227 if (!mNode[NodeT::LEVEL])
5229 if (dirty & int32_t(~NodeT::MASK)) {
5230 mNode[NodeT::LEVEL] =
nullptr;
5236 __hostdev__ CoordValueType computeDirty(
const CoordType& ijk)
const
5238 return (ijk[0] ^ mKey[0]) | (ijk[1] ^ mKey[1]) | (ijk[2] ^ mKey[2]);
5241 template<
typename NodeT>
5244 return (ijk[0] & int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL][0] && (ijk[1] & int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL][1] && (ijk[2] & int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL][2];
5250#ifdef USE_SINGLE_ACCESSOR_KEY
5251 const CoordValueType dirty = this->computeDirty(ijk);
5255 if (this->isCached<LeafT>(dirty)) {
5256 return ((
LeafT*)mNode[0])->getValue(ijk);
5257 }
else if (this->isCached<NodeT1>(dirty)) {
5258 return ((
NodeT1*)mNode[1])->getValueAndCache(ijk, *
this);
5259 }
else if (this->isCached<NodeT2>(dirty)) {
5260 return ((
NodeT2*)mNode[2])->getValueAndCache(ijk, *
this);
5262 return mRoot->getValueAndCache(ijk, *
this);
5266 return this->getValue(ijk);
5270 return this->getValue(
CoordType(i,j,k));
5275#ifdef USE_SINGLE_ACCESSOR_KEY
5276 const CoordValueType dirty = this->computeDirty(ijk);
5280 if (this->isCached<LeafT>(dirty)) {
5281 return ((
LeafT*)mNode[0])->getNodeInfoAndCache(ijk, *
this);
5282 }
else if (this->isCached<NodeT1>(dirty)) {
5283 return ((
NodeT1*)mNode[1])->getNodeInfoAndCache(ijk, *
this);
5284 }
else if (this->isCached<NodeT2>(dirty)) {
5285 return ((
NodeT2*)mNode[2])->getNodeInfoAndCache(ijk, *
this);
5287 return mRoot->getNodeInfoAndCache(ijk, *
this);
5292#ifdef USE_SINGLE_ACCESSOR_KEY
5293 const CoordValueType dirty = this->computeDirty(ijk);
5297 if (this->isCached<LeafT>(dirty)) {
5298 return ((
LeafT*)mNode[0])->isActive(ijk);
5299 }
else if (this->isCached<NodeT1>(dirty)) {
5300 return ((
NodeT1*)mNode[1])->isActiveAndCache(ijk, *
this);
5301 }
else if (this->isCached<NodeT2>(dirty)) {
5302 return ((
NodeT2*)mNode[2])->isActiveAndCache(ijk, *
this);
5304 return mRoot->isActiveAndCache(ijk, *
this);
5309#ifdef USE_SINGLE_ACCESSOR_KEY
5310 const CoordValueType dirty = this->computeDirty(ijk);
5314 if (this->isCached<LeafT>(dirty)) {
5315 return ((
LeafT*)mNode[0])->probeValue(ijk, v);
5316 }
else if (this->isCached<NodeT1>(dirty)) {
5317 return ((
NodeT1*)mNode[1])->probeValueAndCache(ijk, v, *
this);
5318 }
else if (this->isCached<NodeT2>(dirty)) {
5319 return ((
NodeT2*)mNode[2])->probeValueAndCache(ijk, v, *
this);
5321 return mRoot->probeValueAndCache(ijk, v, *
this);
5326#ifdef USE_SINGLE_ACCESSOR_KEY
5327 const CoordValueType dirty = this->computeDirty(ijk);
5331 if (this->isCached<LeafT>(dirty)) {
5332 return ((
LeafT*)mNode[0]);
5333 }
else if (this->isCached<NodeT1>(dirty)) {
5334 return ((
NodeT1*)mNode[1])->probeLeafAndCache(ijk, *
this);
5335 }
else if (this->isCached<NodeT2>(dirty)) {
5336 return ((
NodeT2*)mNode[2])->probeLeafAndCache(ijk, *
this);
5338 return mRoot->probeLeafAndCache(ijk, *
this);
5341 template<
typename RayT>
5344#ifdef USE_SINGLE_ACCESSOR_KEY
5345 const CoordValueType dirty = this->computeDirty(ijk);
5349 if (this->isCached<LeafT>(dirty)) {
5350 return ((
LeafT*)mNode[0])->getDimAndCache(ijk, ray, *
this);
5351 }
else if (this->isCached<NodeT1>(dirty)) {
5352 return ((
NodeT1*)mNode[1])->getDimAndCache(ijk, ray, *
this);
5353 }
else if (this->isCached<NodeT2>(dirty)) {
5354 return ((
NodeT2*)mNode[2])->getDimAndCache(ijk, ray, *
this);
5356 return mRoot->getDimAndCache(ijk, ray, *
this);
5363 template<
typename, u
int32_t>
5365 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
5369 template<
typename NodeT>
5372#ifdef USE_SINGLE_ACCESSOR_KEY
5375 mKeys[NodeT::LEVEL] = ijk & ~NodeT::MASK;
5377 mNode[NodeT::LEVEL] = node;
5395template <
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
5401template <
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
5407template <
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
5459template<
typename AttT>
5470 :
AccT(grid.tree().root())
5472 , mData(reinterpret_cast<const AttT*>(grid.blindData(0)))
5485 end = begin + count;
5493 auto* leaf = this->probeLeaf(ijk);
5494 if (leaf ==
nullptr) {
5497 begin = mData + leaf->minimum();
5498 end = begin + leaf->maximum();
5499 return leaf->maximum();
5505 auto* leaf = this->probeLeaf(ijk);
5506 if (leaf ==
nullptr)
5508 const uint32_t offset = LeafNodeType::CoordToOffset(ijk);
5509 if (leaf->isActive(offset)) {
5510 auto* p = mData + leaf->minimum();
5511 begin = p + (offset == 0 ? 0 : leaf->getValue(offset - 1));
5512 end = p + leaf->getValue(offset);
5522template<
typename ChannelT>
5537 :
BaseT(grid.tree().root())
5543 this->setChannel(channelID);
5548 :
BaseT(grid.tree().root())
5550 , mChannel(channelPtr)
5572 mChannel = channelPtr;
5580 this->setChannel(
reinterpret_cast<ChannelT*
>(
const_cast<void*
>(mGrid.
blindData(channelID))));
5596 const bool isActive = BaseT::probeValue(ijk, idx);
5603 template <
typename T>
5609#if !defined(__CUDA_ARCH__) && !defined(__HIP__)
5614struct MiniGridHandle {
5619 BufferType(BufferType &&other) : data(other.data), size(other.size) {other.data=
nullptr; other.size=0;}
5620 ~BufferType() {std::free(data);}
5621 BufferType& operator=(
const BufferType &other) =
delete;
5622 BufferType& operator=(BufferType &&other){data=other.data; size=other.size; other.data=
nullptr; other.size=0;
return *
this;}
5623 static BufferType create(
size_t n, BufferType* dummy =
nullptr) {
return BufferType(n);}
5625 MiniGridHandle(BufferType &&buf) : buffer(
std::move(buf)) {}
5626 const uint8_t* data()
const {
return buffer.data;}
5646template <
typename StreamT>
5649 char header[192] = {0}, *dst = header;
5650 const char *grid = (
const char*)buffer, *tree = grid + 672, *root = tree + *(
const uint64_t*)(tree + 24);
5651 auto cpy = [&](
const char *src,
int n){
for (
auto *end=src+n; src!=end; ++src) *dst++ = *src;};
5652 if (*(
const uint64_t*)(grid)!=0x304244566f6e614eUL) {
5653 fprintf(stderr,
"nanovdb::writeUncompressedGrid: invalid magic number\n"); exit(EXIT_FAILURE);
5654 }
else if (*(
const uint32_t*)(grid+16)>>21!=32) {
5655 fprintf(stderr,
"nanovdb::writeUncompressedGrid: invalid major version\n"); exit(EXIT_FAILURE);
5659 *(uint16_t*)(dst) = 1; dst += 4;
5666 cpy(grid + 560, 48);
5668 cpy(grid + 608, 24);
5669 const char *gridName = grid + 40;
5670 if (*(
const uint32_t*)(grid+20) & uint32_t(1)) {
5671 gridName = grid + *(
const int64_t*)(grid + 640) + 288*(*(
const uint32_t*)(grid + 648) - 1);
5672 gridName += *(
const uint64_t*)gridName;
5674 uint32_t nameSize = 1;
5675 for (
const char *p = gridName; *p!=
'\0'; ++p) ++nameSize;
5676 *(uint32_t*)(dst) = nameSize; dst += 4;
5678 *(uint32_t*)(dst) = 1; dst += 4;
5682 assert(dst - header == 192);
5683 os.write(header, 192);
5684 os.write(gridName, nameSize);
5686 const uint64_t gridSize = *(
const uint64_t*)(grid + 32);
5687 os.write(grid, gridSize);
5688 if (*(
const uint32_t*)(grid+24) >= *(
const uint32_t*)(grid+28) - 1)
break;
5694template<
typename GridHandleT,
template<
typename...>
class VecT>
5697#ifdef NANOVDB_USE_IOSTREAMS
5698 std::ofstream os(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
5702 StreamT(
const char *name) {fptr = fopen(name,
"wb");}
5703 ~StreamT() {fclose(fptr);}
5704 void write(
const char *data,
size_t n){fwrite(data, 1, n, fptr);}
5705 bool is_open()
const {
return fptr != NULL;}
5708 if (!os.is_open()) {
5709 fprintf(stderr,
"nanovdb::writeUncompressedGrids: Unable to open file \"%s\"for output\n",fileName); exit(EXIT_FAILURE);
5719template<
typename GridHandleT,
typename StreamT,
template<
typename...>
class VecT>
5720VecT<GridHandleT>
readUncompressedGrids(StreamT& is,
const typename GridHandleT::BufferType& buffer =
typename GridHandleT::BufferType())
5722 char header[16], metadata[176];
5723 VecT<GridHandleT> handles;
5724 while(is.read(header, 16)) {
5725 if (*(uint64_t*)(header)!=0x304244566f6e614eUL) {
5726 fprintf(stderr,
"nanovdb::readUncompressedGrids: invalid magic number\n"); exit(EXIT_FAILURE);
5727 }
else if (*(uint32_t*)(header+8)>>21!=32) {
5728 fprintf(stderr,
"nanovdb::readUncompressedGrids: invalid major version\n"); exit(EXIT_FAILURE);
5729 }
else if (*(uint16_t*)(header+14)!=0) {
5730 fprintf(stderr,
"nanovdb::readUncompressedGrids: invalid codec\n"); exit(EXIT_FAILURE);
5732 for (uint16_t i=0, e=*(uint16_t*)(header+12); i<e; ++i) {
5733 if (!is.read(metadata, 176)) {
5734 fprintf(stderr,
"nanovdb::readUncompressedGrids: error reading metadata\n"); exit(EXIT_FAILURE);
5736 const uint64_t gridSize = *(uint64_t*)(metadata);
5737 GridHandleT handle(GridHandleT::BufferType::create(gridSize, &buffer));
5738 is.skip(*(uint32_t*)(metadata + 136));
5739 is.read((
char*)handle.data(), gridSize);
5740 handles.emplace_back(std::move(handle));
5747template<
typename GridHandleT,
template<
typename...>
class VecT>
5748VecT<GridHandleT>
readUncompressedGrids(
const char *fileName,
const typename GridHandleT::BufferType& buffer =
typename GridHandleT::BufferType())
5750#ifdef NANOVDB_USE_IOSTREAMS
5751 struct StreamT :
public std::ifstream {
5752 StreamT(
const char *name) : std::ifstream(name, std::ios::in | std::ios::binary) {}
5753 void skip(uint32_t off) {this->seekg(off, std::ios_base::cur);}
5758 StreamT(
const char *name) {fptr = fopen(name,
"rb");}
5759 ~StreamT() {fclose(fptr);}
5760 bool read(
char *data,
size_t n){
size_t m=fread(data, 1, n, fptr);
return n==m;}
5761 void skip(uint32_t off){fseek(fptr, off, SEEK_CUR);}
5762 bool is_open()
const {
return fptr != NULL;}
5765 StreamT is(fileName);
5766 if (!is.is_open()) {
5767 fprintf(stderr,
"nanovdb::readUncompressedGrids: Unable to open file \"%s\"for input\n",fileName); exit(EXIT_FAILURE);
5769 return readUncompressedGrids<GridHandleT, StreamT, VecT>(is, buffer);
#define ROOT_LEVEL
Definition: CNanoVDB.h:53
ValueT value
Definition: GridBuilder.h:1290
ChildT * child
Definition: GridBuilder.h:1289
#define NANOVDB_HOSTDEV_DISABLE_WARNING
Definition: NanoVDB.h:202
#define NANOVDB_MINOR_VERSION_NUMBER
Definition: NanoVDB.h:124
#define NANOVDB_DATA_ALIGNMENT
Definition: NanoVDB.h:137
#define __hostdev__
Definition: NanoVDB.h:192
#define NANOVDB_MAJOR_VERSION_NUMBER
Definition: NanoVDB.h:123
#define NANOVDB_ASSERT(x)
Definition: NanoVDB.h:173
#define NANOVDB_MAGIC_NUMBER
Definition: NanoVDB.h:121
#define NANOVDB_PATCH_VERSION_NUMBER
Definition: NanoVDB.h:125
const CoordT & operator*() const
Definition: NanoVDB.h:1745
Iterator(const BBox &b)
Definition: NanoVDB.h:1718
Iterator operator++(int)
Definition: NanoVDB.h:1737
Iterator & operator++()
Definition: NanoVDB.h:1723
Class to access values in channels at a specific voxel location.
Definition: NanoVDB.h:5524
T & getValue(const Coord &ijk, T *channelPtr) const
Return the value from a specified channel that maps to the specified coordinate.
Definition: NanoVDB.h:5604
uint64_t getIndex(const Coord &ijk) const
Return the linear offset into a channel that maps to the specified coordinate.
Definition: NanoVDB.h:5584
const IndexGrid & grid() const
Return a const reference to the IndexGrid.
Definition: NanoVDB.h:5558
const uint64_t & valueCount() const
Return total number of values indexed by the IndexGrid.
Definition: NanoVDB.h:5567
const Vec3R & voxelSize() const
Return a vector of the axial voxel sizes.
Definition: NanoVDB.h:5564
ChannelT & operator()(int i, int j, int k) const
Definition: NanoVDB.h:5590
uint64_t idx(int i, int j, int k) const
Definition: NanoVDB.h:5585
void setChannel(uint32_t channelID)
Change to an internal channel, assuming it exists as as blind data in the IndexGrid.
Definition: NanoVDB.h:5578
ChannelAccessor(const IndexGrid &grid, uint32_t channelID=0u)
Ctor from an IndexGrid and an integer ID of an internal channel that is assumed to exist as blind dat...
Definition: NanoVDB.h:5536
ChannelAccessor(const IndexGrid &grid, ChannelT *channelPtr)
Ctor from an IndexGrid and an external channel.
Definition: NanoVDB.h:5547
const IndexTree & tree() const
Return a const reference to the tree of the IndexGrid.
Definition: NanoVDB.h:5561
bool probeValue(const CoordType &ijk, typename remove_const< ChannelT >::type &v) const
return the state and updates the value of the specified voxel
Definition: NanoVDB.h:5593
ChannelT ValueType
Definition: NanoVDB.h:5530
void setChannel(ChannelT *channelPtr)
Change to an external channel.
Definition: NanoVDB.h:5570
ChannelT & getValue(const Coord &ijk) const
Return the value from a cached channel that maps to the specified coordinate.
Definition: NanoVDB.h:5588
ChannelT & operator()(const Coord &ijk) const
Definition: NanoVDB.h:5589
Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord.
Definition: NanoVDB.h:967
Coord & operator&=(int n)
Definition: NanoVDB.h:1047
Coord operator-(const Coord &rhs) const
Definition: NanoVDB.h:1076
Vec3< double > asVec3d() const
Return a double precision floating-point vector of this coordinate.
Definition: NanoVDB.h:1296
uint32_t IndexType
Definition: NanoVDB.h:971
Coord operator<<(IndexType n) const
Definition: NanoVDB.h:1033
static Coord Floor(const Vec3T &xyz)
Return the largest integer coordinates that are not greater than xyz (node centered conversion).
Definition: NanoVDB.h:1133
Coord(ValueType n)
Initializes all coordinates to the given signed integer.
Definition: NanoVDB.h:980
Coord & operator-=(const Coord &rhs)
Definition: NanoVDB.h:1084
Coord & operator>>=(uint32_t n)
Definition: NanoVDB.h:1061
Coord & minComponent(const Coord &other)
Perform a component-wise minimum with the other Coord.
Definition: NanoVDB.h:1093
Coord operator+(const Coord &rhs) const
Definition: NanoVDB.h:1075
static size_t memUsage()
Definition: NanoVDB.h:1008
bool operator<(const Coord &rhs) const
Return true if this Coord is lexicographically less than the given Coord.
Definition: NanoVDB.h:1039
Coord & operator+=(const Coord &rhs)
Definition: NanoVDB.h:1077
Coord & operator=(const CoordT &other)
Assignment operator that works with openvdb::Coord.
Definition: NanoVDB.h:1020
int32_t y() const
Definition: NanoVDB.h:997
Coord & maxComponent(const Coord &other)
Perform a component-wise maximum with the other Coord.
Definition: NanoVDB.h:1105
Coord operator&(IndexType n) const
Return a new instance with coordinates masked by the given unsigned integer.
Definition: NanoVDB.h:1030
Coord()
Initialize all coordinates to zero.
Definition: NanoVDB.h:974
uint8_t octant() const
Return the octant of this Coord.
Definition: NanoVDB.h:1142
const ValueType & operator[](IndexType i) const
Return a const reference to the given Coord component.
Definition: NanoVDB.h:1012
int32_t z() const
Definition: NanoVDB.h:998
Coord & operator<<=(uint32_t n)
Definition: NanoVDB.h:1054
int32_t x() const
Definition: NanoVDB.h:996
Coord(ValueType i, ValueType j, ValueType k)
Initializes coordinate to the given signed integers.
Definition: NanoVDB.h:986
int32_t & y()
Definition: NanoVDB.h:1001
Coord offsetBy(ValueType n) const
Definition: NanoVDB.h:1121
int32_t & x()
Definition: NanoVDB.h:1000
Coord(ValueType *ptr)
Definition: NanoVDB.h:991
bool operator!=(const Coord &rhs) const
Definition: NanoVDB.h:1046
static Coord min()
Definition: NanoVDB.h:1006
ValueType & operator[](IndexType i)
Return a non-const reference to the given Coord component.
Definition: NanoVDB.h:1016
bool operator==(const Coord &rhs) const
Definition: NanoVDB.h:1045
Vec3< float > asVec3s() const
Return a single precision floating-point vector of this coordinate.
Definition: NanoVDB.h:1293
Coord offsetBy(ValueType dx, ValueType dy, ValueType dz) const
Definition: NanoVDB.h:1116
static Coord max()
Definition: NanoVDB.h:1004
int32_t & z()
Definition: NanoVDB.h:1002
static bool lessThan(const Coord &a, const Coord &b)
Definition: NanoVDB.h:1125
Coord operator>>(IndexType n) const
Definition: NanoVDB.h:1036
uint32_t hash() const
Return a hash key derived from the existing coordinates.
Definition: NanoVDB.h:1138
int32_t ValueType
Definition: NanoVDB.h:970
Coord & operator+=(int n)
Definition: NanoVDB.h:1068
Dummy type for a 16bit quantization of float point values.
Definition: NanoVDB.h:228
Dummy type for a 4bit quantization of float point values.
Definition: NanoVDB.h:222
Dummy type for a 8bit quantization of float point values.
Definition: NanoVDB.h:225
Dummy type for a variable bit quantization of floating point values.
Definition: NanoVDB.h:231
Highest level of the data structure. Contains a tree and a world->index transform (that currently onl...
Definition: NanoVDB.h:2556
Vec3T indexToWorld(const Vec3T &xyz) const
index to world space transformation
Definition: NanoVDB.h:2618
enable_if< is_same< T, ValueIndex >::value, uint64_t >::type valueCount() const
Return the total number of values indexed by this IndexGrid.
Definition: NanoVDB.h:2595
Vec3T indexToWorldF(const Vec3T &xyz) const
index to world space transformation
Definition: NanoVDB.h:2641
const GridType & gridType() const
Definition: NanoVDB.h:2672
uint32_t blindDataCount() const
Return the count of blind-data encoded in this grid.
Definition: NanoVDB.h:2721
typename TreeT::ValueType ValueType
Definition: NanoVDB.h:2561
typename TreeT::RootType RootType
Definition: NanoVDB.h:2559
bool isSequential() const
return true if the specified node type is layed out breadth-first in memory and has a fixed size....
Definition: NanoVDB.h:2692
bool isPointData() const
Definition: NanoVDB.h:2679
uint32_t gridIndex() const
Return index of this grid in the buffer.
Definition: NanoVDB.h:2586
const char * shortGridName() const
Return a c-string with the name of this grid, truncated to 255 characters.
Definition: NanoVDB.h:2712
bool isBreadthFirst() const
Definition: NanoVDB.h:2687
uint64_t activeVoxelCount() const
Return the total number of active voxels in this tree.
Definition: NanoVDB.h:2668
Vec3T indexToWorldDirF(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition: NanoVDB.h:2646
typename TreeT::CoordType CoordType
Definition: NanoVDB.h:2563
Vec3T worldToIndexF(const Vec3T &xyz) const
world to index space transformation
Definition: NanoVDB.h:2637
Vec3T worldToIndexDirF(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition: NanoVDB.h:2651
const Vec3R & voxelSize() const
Return a const reference to the size of a voxel in world units.
Definition: NanoVDB.h:2607
bool isStaggered() const
Definition: NanoVDB.h:2676
const GridClass & gridClass() const
Definition: NanoVDB.h:2673
bool isValid() const
Methods related to the classification of this grid.
Definition: NanoVDB.h:2671
DataType * data()
Definition: NanoVDB.h:2575
bool hasAverage() const
Definition: NanoVDB.h:2685
bool hasMinMax() const
Definition: NanoVDB.h:2682
const char * gridName() const
Return a c-string with the name of this grid.
Definition: NanoVDB.h:2700
const BBox< Vec3R > & worldBBox() const
Computes a AABB of active values in world space.
Definition: NanoVDB.h:2659
AccessorType getAccessor() const
Return a new instance of a ReadAccessor used to access values in this grid.
Definition: NanoVDB.h:2604
uint64_t gridSize() const
Return the memory footprint of the entire grid, i.e. including all nodes and blind data.
Definition: NanoVDB.h:2583
const GridBlindMetaData & blindMetaData(uint32_t n) const
Definition: NanoVDB.h:2738
Vec3T indexToWorldDir(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition: NanoVDB.h:2623
Vec3T indexToWorldGradF(const Vec3T &grad) const
Transforms the gradient from index space to world space.
Definition: NanoVDB.h:2656
uint64_t checksum() const
Return checksum of the grid buffer.
Definition: NanoVDB.h:2715
bool isFogVolume() const
Definition: NanoVDB.h:2675
const TreeT & tree() const
Return a const reference to the tree.
Definition: NanoVDB.h:2598
bool isMask() const
Definition: NanoVDB.h:2680
const BBox< CoordType > & indexBBox() const
Computes a AABB of active values in index space.
Definition: NanoVDB.h:2665
bool hasLongGridName() const
Definition: NanoVDB.h:2684
const void * blindData(uint32_t n) const
Returns a const pointer to the blindData at the specified linear offset.
Definition: NanoVDB.h:2729
static uint64_t memUsage()
Return memory usage in bytes for this class only.
Definition: NanoVDB.h:2580
TreeT & tree()
Return a non-const reference to the tree.
Definition: NanoVDB.h:2601
Vec3T worldToIndex(const Vec3T &xyz) const
world to index space transformation
Definition: NanoVDB.h:2614
uint32_t gridCount() const
Return total number of grids in the buffer.
Definition: NanoVDB.h:2589
Vec3T worldToIndexDir(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition: NanoVDB.h:2628
Version version() const
Definition: NanoVDB.h:2573
bool isEmpty() const
Return true if this grid is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:2718
const Map & map() const
Return a const reference to the Map for this grid.
Definition: NanoVDB.h:2610
bool hasStdDeviation() const
Definition: NanoVDB.h:2686
bool hasBBox() const
Definition: NanoVDB.h:2683
bool isLevelSet() const
Definition: NanoVDB.h:2674
bool isGridIndex() const
Definition: NanoVDB.h:2678
TreeT TreeType
Definition: NanoVDB.h:2558
Grid(const Grid &)=delete
Disallow constructions, copy and assignment.
typename TreeT::BuildType BuildType
Definition: NanoVDB.h:2562
Grid & operator=(const Grid &)=delete
Vec3T indexToWorldGrad(const Vec3T &grad) const
transform the gradient from index space to world space.
Definition: NanoVDB.h:2633
const DataType * data() const
Definition: NanoVDB.h:2577
bool isPointIndex() const
Definition: NanoVDB.h:2677
bool isUnknown() const
Definition: NanoVDB.h:2681
Dummy type for a 16 bit floating point values.
Definition: NanoVDB.h:219
Visits child nodes of this node only.
Definition: NanoVDB.h:3546
ChildIterator()
Definition: NanoVDB.h:3550
CoordType getOrigin() const
Definition: NanoVDB.h:3555
const ChildT * operator->() const
Definition: NanoVDB.h:3554
ChildIterator & operator=(const ChildIterator &)=default
ChildIterator(const InternalNode *parent)
Definition: NanoVDB.h:3551
const ChildT & operator*() const
Definition: NanoVDB.h:3553
Visits all tile values in this node, i.e. both inactive and active tiles.
Definition: NanoVDB.h:3562
ValueIterator & operator=(const ValueIterator &)=default
ValueIterator(const InternalNode *parent)
Definition: NanoVDB.h:3567
bool isActive() const
Definition: NanoVDB.h:3571
ValueIterator()
Definition: NanoVDB.h:3566
CoordType getOrigin() const
Definition: NanoVDB.h:3570
ValueType operator*() const
Definition: NanoVDB.h:3569
Visits active tile values of this node only.
Definition: NanoVDB.h:3578
ValueOnIterator(const InternalNode *parent)
Definition: NanoVDB.h:3583
ValueOnIterator & operator=(const ValueOnIterator &)=default
CoordType getOrigin() const
Definition: NanoVDB.h:3586
ValueType operator*() const
Definition: NanoVDB.h:3585
ValueOnIterator()
Definition: NanoVDB.h:3582
Internal nodes of a VDB treedim(),.
Definition: NanoVDB.h:3521
Coord offsetToGlobalCoord(uint32_t n) const
Definition: NanoVDB.h:3700
const MaskType< LOG2DIM > & valueMask() const
Return a const reference to the bit mask of active voxels in this internal node.
Definition: NanoVDB.h:3608
ValueIterator beginValue() const
Definition: NanoVDB.h:3574
bool isActive() const
Return true if this node or any of its child nodes contain active values.
Definition: NanoVDB.h:3708
static uint32_t dim()
Return the dimension, in voxel units, of this internal node (typically 8*16 or 8*16*32)
Definition: NanoVDB.h:3602
static size_t memUsage()
Return memory usage in bytes for the class.
Definition: NanoVDB.h:3605
CoordType origin() const
Return the origin in index space of this leaf node.
Definition: NanoVDB.h:3614
typename ChildT::CoordType CoordType
Definition: NanoVDB.h:3529
ChildIterator beginChild() const
Definition: NanoVDB.h:3558
const BBox< CoordType > & bbox() const
Return a const reference to the bounding box in index space of active values in this internal node an...
Definition: NanoVDB.h:3632
FloatType variance() const
Return the variance of all the active values encoded in this internal node and any of its child nodes...
Definition: NanoVDB.h:3626
const MaskType< LOG2DIM > & childMask() const
Return a const reference to the bit mask of child nodes in this internal node.
Definition: NanoVDB.h:3611
const FloatType & average() const
Return a const reference to the average of all the active values encoded in this internal node and an...
Definition: NanoVDB.h:3623
DataType * data()
Definition: NanoVDB.h:3597
void localToGlobalCoord(Coord &ijk) const
modifies local coordinates to global coordinates of a tile or child node
Definition: NanoVDB.h:3694
typename DataType::BuildT BuildType
Definition: NanoVDB.h:3526
typename Mask< Log2Dim >::template Iterator< On > MaskIterT
Definition: NanoVDB.h:3534
ChildT ChildNodeType
Definition: NanoVDB.h:3528
const LeafNodeType * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:3657
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:3641
typename DataType::ValueT ValueType
Definition: NanoVDB.h:3524
static uint32_t CoordToOffset(const CoordType &ijk)
Return the linear offset corresponding to the given coordinate.
Definition: NanoVDB.h:3672
typename DataType::StatsT FloatType
Definition: NanoVDB.h:3525
static Coord OffsetToLocalCoord(uint32_t n)
Definition: NanoVDB.h:3686
bool probeValue(const CoordType &ijk, ValueType &v) const
return the state and updates the value of the specified voxel
Definition: NanoVDB.h:3648
typename ChildT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:3527
const ChildNodeType * probeChild(const CoordType &ijk) const
Definition: NanoVDB.h:3665
const FloatType & stdDeviation() const
Return a const reference to the standard deviation of all the active values encoded in this internal ...
Definition: NanoVDB.h:3629
const ValueType & maximum() const
Return a const reference to the maximum active value encoded in this internal node and any of its chi...
Definition: NanoVDB.h:3620
InternalNode()=delete
This class cannot be constructed or deleted.
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel.
Definition: NanoVDB.h:3635
typename ChildT::template MaskType< LOG2 > MaskType
Definition: NanoVDB.h:3532
const ValueType & minimum() const
Return a const reference to the minimum active value encoded in this internal node and any of its chi...
Definition: NanoVDB.h:3617
const DataType * data() const
Definition: NanoVDB.h:3599
InternalNode & operator=(const InternalNode &)=delete
InternalNode(const InternalNode &)=delete
ValueOnIterator beginValueOn() const
Definition: NanoVDB.h:3589
Visits all values in a leaf node, i.e. both active and inactive values.
Definition: NanoVDB.h:4304
ValueIterator & operator=(const ValueIterator &)=default
ValueIterator & operator++()
Definition: NanoVDB.h:4315
ValueIterator operator++(int)
Definition: NanoVDB.h:4316
ValueIterator(const LeafNode *parent)
Definition: NanoVDB.h:4309
bool isActive() const
Definition: NanoVDB.h:4313
CoordT getCoord() const
Definition: NanoVDB.h:4312
ValueIterator()
Definition: NanoVDB.h:4308
ValueType operator*() const
Definition: NanoVDB.h:4311
Visits all inactive values in a leaf node.
Definition: NanoVDB.h:4289
ValueOffIterator()
Definition: NanoVDB.h:4293
CoordT getCoord() const
Definition: NanoVDB.h:4297
ValueOffIterator & operator=(const ValueOffIterator &)=default
ValueType operator*() const
Definition: NanoVDB.h:4296
ValueOffIterator(const LeafNode *parent)
Definition: NanoVDB.h:4294
Visits all active values in a leaf node.
Definition: NanoVDB.h:4274
CoordT getCoord() const
Definition: NanoVDB.h:4282
ValueOnIterator(const LeafNode *parent)
Definition: NanoVDB.h:4279
ValueOnIterator & operator=(const ValueOnIterator &)=default
ValueType operator*() const
Definition: NanoVDB.h:4281
ValueOnIterator()
Definition: NanoVDB.h:4278
Leaf nodes of the VDB tree. (defaults to 8x8x8 = 512 voxels)
Definition: NanoVDB.h:4252
void setValue(const CoordT &ijk, const ValueType &v)
Sets the value at the specified location and activate its state.
Definition: NanoVDB.h:4416
void setValueOnly(uint32_t offset, const ValueType &v)
Sets the value at the specified location but leaves its state unchanged.
Definition: NanoVDB.h:4421
bool isActive(const CoordT &ijk) const
Return true if the voxel value at the given coordinate is active.
Definition: NanoVDB.h:4425
typename DataType::BuildType BuildType
Definition: NanoVDB.h:4264
const MaskType< LOG2DIM > & valueMask() const
Return a const reference to the bit mask of active voxels in this leaf node.
Definition: NanoVDB.h:4339
ValueIterator beginValue() const
Definition: NanoVDB.h:4323
bool isActive() const
Return true if any of the voxel value are active in this leaf node.
Definition: NanoVDB.h:4429
CoordT CoordType
Definition: NanoVDB.h:4265
static uint32_t dim()
Return the dimension, in index space, of this leaf node (typically 8 as for openvdb leaf nodes!...
Definition: NanoVDB.h:4377
bool probeValue(const CoordT &ijk, ValueType &v) const
Return true if the voxel value at the given coordinate is active and updates v with the value.
Definition: NanoVDB.h:4439
FloatType variance() const
Return the variance of all the active values encoded in this leaf node.
Definition: NanoVDB.h:4351
LeafNode & operator=(const LeafNode &)=delete
bool isActive(uint32_t n) const
Definition: NanoVDB.h:4426
DataType * data()
Definition: NanoVDB.h:4334
uint8_t flags() const
Definition: NanoVDB.h:4356
void localToGlobalCoord(Coord &ijk) const
Converts (in place) a local index coordinate to a global index coordinate.
Definition: NanoVDB.h:4369
ValueType maximum() const
Return a const reference to the maximum active value encoded in this leaf node.
Definition: NanoVDB.h:4345
typename DataType::FloatType FloatType
Definition: NanoVDB.h:4263
CoordT origin() const
Return the origin in index space of this leaf node.
Definition: NanoVDB.h:4359
typename Mask< Log2Dim >::template Iterator< ON > MaskIterT
Definition: NanoVDB.h:4270
static uint32_t CoordToOffset(const CoordT &ijk)
Return the linear offset corresponding to the given coordinate.
Definition: NanoVDB.h:4449
CoordT offsetToGlobalCoord(uint32_t n) const
Definition: NanoVDB.h:4371
void setValueOnly(const CoordT &ijk, const ValueType &v)
Definition: NanoVDB.h:4422
ValueType getValue(uint32_t offset) const
Return the voxel value at the given offset.
Definition: NanoVDB.h:4408
FloatType average() const
Return a const reference to the average of all the active values encoded in this leaf node.
Definition: NanoVDB.h:4348
const LeafNode * probeLeaf(const CoordT &) const
Definition: NanoVDB.h:4446
ValueType getValue(const CoordT &ijk) const
Return the voxel value at the given coordinate.
Definition: NanoVDB.h:4411
MaskT< LOG2 > MaskType
Definition: NanoVDB.h:4268
static uint32_t voxelCount()
Return the total number of voxels (e.g. values) encoded in this leaf node.
Definition: NanoVDB.h:4394
LeafNode(const LeafNode &)=delete
ValueOffIterator beginValueOff() const
Definition: NanoVDB.h:4300
BBox< CoordT > bbox() const
Return the bounding box in index space of active values in this leaf node.
Definition: NanoVDB.h:4380
LeafNode()=delete
This class cannot be constructed or deleted.
ValueType minimum() const
Return a const reference to the minimum active value encoded in this leaf node.
Definition: NanoVDB.h:4342
typename DataType::ValueType ValueType
Definition: NanoVDB.h:4262
static uint32_t padding()
Definition: NanoVDB.h:4396
static CoordT OffsetToLocalCoord(uint32_t n)
Definition: NanoVDB.h:4361
bool hasBBox() const
Definition: NanoVDB.h:4436
uint64_t memUsage()
return memory usage in bytes for the class
Definition: NanoVDB.h:4399
const DataType * data() const
Definition: NanoVDB.h:4336
ValueOnIterator beginValueOn() const
Definition: NanoVDB.h:4285
FloatType stdDeviation() const
Return a const reference to the standard deviation of all the active values encoded in this leaf node...
Definition: NanoVDB.h:4354
Definition: NanoVDB.h:1991
Iterator()
Definition: NanoVDB.h:1993
Iterator & operator=(const Iterator &)=default
uint32_t operator*() const
Definition: NanoVDB.h:1996
Iterator operator++(int)
Definition: NanoVDB.h:2004
uint32_t pos() const
Definition: NanoVDB.h:1997
Iterator(uint32_t pos, const Mask *parent)
Definition: NanoVDB.h:1994
Iterator & operator++()
Definition: NanoVDB.h:1999
Bit-mask to encode active states and facilitate sequential iterators and a fast codec for I/O compres...
Definition: NanoVDB.h:1957
void set(uint32_t n, bool On)
Set the specified bit on or off.
Definition: NanoVDB.h:2115
OnIterator beginOn() const
Definition: NanoVDB.h:2019
bool isOff(uint32_t n) const
Return true if the given bit is NOT set.
Definition: NanoVDB.h:2088
const WordT & getWord(int n) const
Return a const reference to the nth word of the bit mask, for a word of arbitrary size.
Definition: NanoVDB.h:2045
bool operator==(const Mask &other) const
Definition: NanoVDB.h:2074
static size_t memUsage()
Return the memory footprint in bytes of this Mask.
Definition: NanoVDB.h:1964
OffIterator beginOff() const
Definition: NanoVDB.h:2021
void setOn()
Set all bits on.
Definition: NanoVDB.h:2128
void toggle(uint32_t n)
Definition: NanoVDB.h:2155
Iterator< false > OffIterator
Definition: NanoVDB.h:2017
uint32_t countOn() const
Return the total number of set bits in this Mask.
Definition: NanoVDB.h:1973
Mask & operator^=(const Mask &other)
Bitwise XOR.
Definition: NanoVDB.h:2182
void setOff(uint32_t n)
Set the specified bit off.
Definition: NanoVDB.h:2112
Mask(const Mask &other)
Copy constructor.
Definition: NanoVDB.h:2037
Iterator< true > OnIterator
Definition: NanoVDB.h:2016
WordT & getWord(int n)
Return a reference to the nth word of the bit mask, for a word of arbitrary size.
Definition: NanoVDB.h:2053
Mask(bool on)
Definition: NanoVDB.h:2029
Mask & operator=(const MaskT &other)
Assignment operator that works with openvdb::util::NodeMask.
Definition: NanoVDB.h:2061
bool isOn(uint32_t n) const
Return true if the given bit is set.
Definition: NanoVDB.h:2085
void set(bool on)
Set all bits off.
Definition: NanoVDB.h:2142
Mask & operator|=(const Mask &other)
Bitwise union.
Definition: NanoVDB.h:2166
void setOff()
Set all bits off.
Definition: NanoVDB.h:2135
Mask & operator&=(const Mask &other)
Bitwise intersection.
Definition: NanoVDB.h:2158
static uint32_t bitCount()
Return the number of bits available in this Mask.
Definition: NanoVDB.h:1967
bool isOff() const
Return true if none of the bits are set in this Mask.
Definition: NanoVDB.h:2100
bool operator!=(const Mask &other) const
Definition: NanoVDB.h:2082
void toggle()
brief Toggle the state of all bits in the mask
Definition: NanoVDB.h:2149
Mask & operator-=(const Mask &other)
Bitwise difference.
Definition: NanoVDB.h:2174
static uint32_t wordCount()
Return the number of machine words used by this Mask.
Definition: NanoVDB.h:1970
bool isOn() const
Return true if all the bits are set in this Mask.
Definition: NanoVDB.h:2091
uint32_t countOn(uint32_t i) const
Return the number of lower set bits in mask up to but excluding the i'th bit.
Definition: NanoVDB.h:1982
Mask()
Initialize all bits to zero.
Definition: NanoVDB.h:2024
void setOn(uint32_t n)
Set the specified bit on.
Definition: NanoVDB.h:2109
Class to access points at a specific voxel location.
Definition: NanoVDB.h:5461
uint64_t gridPoints(const AttT *&begin, const AttT *&end) const
Return the total number of point in the grid and set the iterators to the complete range of points.
Definition: NanoVDB.h:5481
typename NanoRoot< uint32_t >::LeafNodeType LeafNodeType
Definition: NanoVDB.h:5467
uint64_t leafPoints(const Coord &ijk, const AttT *&begin, const AttT *&end) const
Return the number of points in the leaf node containing the coordinate ijk. If this return value is l...
Definition: NanoVDB.h:5491
PointAccessor(const UInt32Grid &grid)
Definition: NanoVDB.h:5469
uint64_t voxelPoints(const Coord &ijk, const AttT *&begin, const AttT *&end) const
get iterators over offsets to points at a specific voxel location
Definition: NanoVDB.h:5503
ReadAccessor & operator=(const ReadAccessor &)=default
ValueType operator()(int i, int j, int k) const
Definition: NanoVDB.h:4700
ReadAccessor(const GridT &grid)
Constructor from a grid.
Definition: NanoVDB.h:4676
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4705
ReadAccessor(const TreeT &tree)
Constructor from a tree.
Definition: NanoVDB.h:4679
ValueType operator()(const CoordType &ijk) const
Definition: NanoVDB.h:4696
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4710
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4715
typename RootT::CoordType CoordType
Definition: NanoVDB.h:4657
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition: NanoVDB.h:4685
void clear()
Reset this access to its initial state, i.e. with an empty cache @node Noop since this template speci...
Definition: NanoVDB.h:4683
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4692
typename RootT::ValueType ValueType
Definition: NanoVDB.h:4656
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4720
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4726
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4673
Node caching at all (three) tree levels.
Definition: NanoVDB.h:5137
ReadAccessor & operator=(const ReadAccessor &)=default
typename ReadAccessor< ValueT, -1, -1, -1 >::NodeInfo NodeInfo
Definition: NanoVDB.h:5165
const NodeTrait< TreeT, LEVEL >::type * getNode() const
Definition: NanoVDB.h:5204
CoordT CoordType
Definition: NanoVDB.h:5161
ValueType operator()(int i, int j, int k) const
Definition: NanoVDB.h:5268
ReadAccessor(const GridT &grid)
Constructor from a grid.
Definition: NanoVDB.h:5180
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:5273
ReadAccessor(const TreeT &tree)
Constructor from a tree.
Definition: NanoVDB.h:5183
ValueType operator()(const CoordType &ijk) const
Definition: NanoVDB.h:5264
ValueT ValueType
Definition: NanoVDB.h:5160
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:5290
const NodeT * getNode() const
Return a const point to the cached node of the specified type.
Definition: NanoVDB.h:5196
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:5307
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition: NanoVDB.h:5185
void clear()
Reset this access to its initial state, i.e. with an empty cache.
Definition: NanoVDB.h:5213
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:5248
bool isCached(const CoordType &ijk) const
Definition: NanoVDB.h:5242
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:5324
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:5342
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:5168
ReadAccessor & operator=(const ReadAccessor &)=default
typename ReadAccessor< ValueT, -1, -1, -1 >::NodeInfo NodeInfo
Definition: NanoVDB.h:4773
CoordT CoordType
Definition: NanoVDB.h:4769
ValueType operator()(int i, int j, int k) const
Definition: NanoVDB.h:4821
ReadAccessor(const GridT &grid)
Constructor from a grid.
Definition: NanoVDB.h:4784
bool isCached(const CoordType &ijk) const
Definition: NanoVDB.h:4803
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4826
ReadAccessor(const TreeT &tree)
Constructor from a tree.
Definition: NanoVDB.h:4787
ValueType operator()(const CoordType &ijk) const
Definition: NanoVDB.h:4817
ValueT ValueType
Definition: NanoVDB.h:4768
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4834
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4842
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition: NanoVDB.h:4796
void clear()
Reset this access to its initial state, i.e. with an empty cache.
Definition: NanoVDB.h:4790
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4810
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4850
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4859
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4776
ReadAccessor & operator=(const ReadAccessor &)=default
CoordT CoordType
Definition: NanoVDB.h:4918
ValueType operator()(int i, int j, int k) const
Definition: NanoVDB.h:5020
ReadAccessor(const GridT &grid)
Constructor from a grid.
Definition: NanoVDB.h:4938
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:5025
ReadAccessor(const TreeT &tree)
Constructor from a tree.
Definition: NanoVDB.h:4941
ValueType operator()(const CoordType &ijk) const
Definition: NanoVDB.h:5016
ValueT ValueType
Definition: NanoVDB.h:4917
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:5040
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:5055
typename ReadAccessor< ValueT,-1,-1,-1 >::NodeInfo NodeInfo
Definition: NanoVDB.h:4922
bool isCached1(const CoordType &ijk) const
Definition: NanoVDB.h:4988
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition: NanoVDB.h:4955
void clear()
Reset this access to its initial state, i.e. with an empty cache.
Definition: NanoVDB.h:4944
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:5002
bool isCached2(const CoordType &ijk) const
Definition: NanoVDB.h:4994
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:5070
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:5086
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4925
Definition: NanoVDB.h:2545
8-bit red, green, blue, alpha packed into 32 bit unsigned int
Definition: NanoVDB.h:559
const uint32_t & packed() const
Definition: NanoVDB.h:593
Rgba8(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255u)
Definition: NanoVDB.h:573
Rgba8 & operator=(const Rgba8 &)=default
const uint8_t & g() const
Definition: NanoVDB.h:596
uint8_t & g()
Definition: NanoVDB.h:600
Rgba8(float r, float g, float b, float a=1.0f)
Definition: NanoVDB.h:575
uint32_t packed
Definition: NanoVDB.h:562
const uint8_t & a() const
Definition: NanoVDB.h:598
bool operator<(const Rgba8 &rhs) const
Definition: NanoVDB.h:582
const uint8_t & r() const
Definition: NanoVDB.h:595
Rgba8()
Definition: NanoVDB.h:572
Rgba8(uint8_t v)
Definition: NanoVDB.h:574
float lengthSqr() const
Definition: NanoVDB.h:584
Rgba8 & operator=(Rgba8 &&)=default
const uint8_t & b() const
Definition: NanoVDB.h:597
uint32_t & packed()
Definition: NanoVDB.h:594
uint8_t & r()
Definition: NanoVDB.h:599
uint8_t & operator[](int n)
Definition: NanoVDB.h:592
float length() const
Definition: NanoVDB.h:590
const uint8_t & operator[](int n) const
Definition: NanoVDB.h:591
bool operator==(const Rgba8 &rhs) const
Definition: NanoVDB.h:583
uint8_t ValueType
Definition: NanoVDB.h:566
Rgba8(const Rgba8 &)=default
uint8_t & b()
Definition: NanoVDB.h:601
uint8_t c[4]
Definition: NanoVDB.h:561
uint8_t & a()
Definition: NanoVDB.h:602
static const int SIZE
Definition: NanoVDB.h:565
Definition: NanoVDB.h:3094
ChildIterator()
Definition: NanoVDB.h:3098
ChildIterator & operator++()
Definition: NanoVDB.h:3109
ChildIterator operator++(int)
Definition: NanoVDB.h:3115
CoordType getOrigin() const
Definition: NanoVDB.h:3106
const ChildT * operator->() const
Definition: NanoVDB.h:3105
ChildIterator & operator=(const ChildIterator &)=default
uint32_t pos() const
Definition: NanoVDB.h:3108
const ChildT & operator*() const
Definition: NanoVDB.h:3104
ChildIterator(const RootNode *parent)
Definition: NanoVDB.h:3099
Definition: NanoVDB.h:3125
ValueIterator & operator=(const ValueIterator &)=default
ValueIterator & operator++()
Definition: NanoVDB.h:3140
ValueIterator operator++(int)
Definition: NanoVDB.h:3146
bool isActive() const
Definition: NanoVDB.h:3136
ValueIterator()
Definition: NanoVDB.h:3129
CoordType getOrigin() const
Definition: NanoVDB.h:3139
ValueType operator*() const
Definition: NanoVDB.h:3135
uint32_t pos() const
Definition: NanoVDB.h:3138
ValueIterator(const RootNode *parent)
Definition: NanoVDB.h:3130
Definition: NanoVDB.h:3156
ValueOnIterator operator++(int)
Definition: NanoVDB.h:3176
ValueOnIterator(const RootNode *parent)
Definition: NanoVDB.h:3161
ValueOnIterator & operator=(const ValueOnIterator &)=default
CoordType getOrigin() const
Definition: NanoVDB.h:3169
ValueOnIterator & operator++()
Definition: NanoVDB.h:3170
ValueType operator*() const
Definition: NanoVDB.h:3166
uint32_t pos() const
Definition: NanoVDB.h:3168
ValueOnIterator()
Definition: NanoVDB.h:3160
Top-most node of the VDB tree structure.
Definition: NanoVDB.h:3074
const uint32_t & tileCount() const
Return the number of tiles encoded in this root node.
Definition: NanoVDB.h:3207
static uint64_t memUsage(uint32_t tableSize)
Return the expected memory footprint in bytes with the specified number of tiles.
Definition: NanoVDB.h:3225
ValueIterator beginValue() const
Definition: NanoVDB.h:3153
typename ChildT::CoordType CoordType
Definition: NanoVDB.h:3085
ChildIterator beginChild() const
Definition: NanoVDB.h:3122
FloatType variance() const
Return the variance of all the active values encoded in this root node and any of its child nodes.
Definition: NanoVDB.h:3219
const FloatType & average() const
Return a const reference to the average of all the active values encoded in this root node and any of...
Definition: NanoVDB.h:3216
RootNode & operator=(const RootNode &)=delete
DataType * data()
Definition: NanoVDB.h:3193
AccessorType getAccessor() const
Definition: NanoVDB.h:3191
typename DataType::BuildT BuildType
Definition: NanoVDB.h:3083
const BBoxType & bbox() const
Return a const reference to the index bounding box of all the active values in this tree,...
Definition: NanoVDB.h:3198
RootNode(const RootNode &)=delete
ChildT ChildNodeType
Definition: NanoVDB.h:3078
const LeafNodeType * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:3264
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:3239
typename DataType::ValueT ValueType
Definition: NanoVDB.h:3081
typename DataType::StatsT FloatType
Definition: NanoVDB.h:3082
uint64_t memUsage() const
Return the actual memory footprint of this root node.
Definition: NanoVDB.h:3228
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:3250
typename ChildT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:3077
const ChildNodeType * probeChild(const CoordType &ijk) const
Definition: NanoVDB.h:3274
const FloatType & stdDeviation() const
Return a const reference to the standard deviation of all the active values encoded in this root node...
Definition: NanoVDB.h:3222
const Tile * probeTile(const CoordType &ijk) const
Find and return a Tile of this root node.
Definition: NanoVDB.h:3284
const ValueType & maximum() const
Return a const reference to the maximum active value encoded in this root node and any of its child n...
Definition: NanoVDB.h:3213
typename DataType::Tile Tile
Definition: NanoVDB.h:3088
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel.
Definition: NanoVDB.h:3231
const ValueType & background() const
Return the total number of active voxels in the root and all its child nodes.
Definition: NanoVDB.h:3204
bool isEmpty() const
Return true if this RootNode is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:3248
RootNode()=delete
This class cannot be constructed or deleted.
const ValueType & minimum() const
Return a const reference to the minimum active value encoded in this root node and any of its child n...
Definition: NanoVDB.h:3210
const DataType * data() const
Definition: NanoVDB.h:3195
ValueOnIterator beginValueOn() const
Definition: NanoVDB.h:3183
VDB Tree, which is a thin wrapper around a RootNode.
Definition: NanoVDB.h:2799
typename RootT::ChildNodeType Node2
Definition: NanoVDB.h:2815
const NodeTrait< RootT, 1 >::type * getFirstLower() const
Definition: NanoVDB.h:2930
RootT Node3
Definition: NanoVDB.h:2814
const uint32_t & activeTileCount(uint32_t level) const
Return the total number of active tiles at the specified level of the tree.
Definition: NanoVDB.h:2867
const NodeT * getFirstNode() const
return a const pointer to the first node of the specified type
Definition: NanoVDB.h:2900
uint64_t activeVoxelCount() const
Return the total number of active voxels in this tree.
Definition: NanoVDB.h:2860
typename RootT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:2808
const BBox< CoordType > & bbox() const
Return a const reference to the index bounding box of all the active values in this tree,...
Definition: NanoVDB.h:2857
const NodeTrait< RootT, 2 >::type * getFirstUpper() const
Definition: NanoVDB.h:2932
DataType * data()
Definition: NanoVDB.h:2825
uint32_t nodeCount() const
Definition: NanoVDB.h:2874
NodeTrait< RootT, 1 >::type * getFirstLower()
Definition: NanoVDB.h:2929
Tree()=delete
This class cannot be constructed or deleted.
AccessorType getAccessor() const
Definition: NanoVDB.h:2836
NodeTrait< RootT, 2 >::type * getFirstUpper()
Definition: NanoVDB.h:2931
bool isActive(const CoordType &ijk) const
Return the active state of the given voxel (regardless of state or location in the tree....
Definition: NanoVDB.h:2842
const LeafNodeType * getFirstLeaf() const
Definition: NanoVDB.h:2928
NodeTrait< RootT, LEVEL >::type * getFirstNode()
return a pointer to the first node at the specified level
Definition: NanoVDB.h:2911
bool probeValue(const CoordType &ijk, ValueType &v) const
Combines the previous two methods in a single call.
Definition: NanoVDB.h:2848
typename RootT::CoordType CoordType
Definition: NanoVDB.h:2811
RootT & root()
Definition: NanoVDB.h:2832
LeafNodeType * getFirstLeaf()
Template specializations of getFirstNode.
Definition: NanoVDB.h:2927
Tree(const Tree &)=delete
static uint64_t memUsage()
return memory usage in bytes for the class
Definition: NanoVDB.h:2830
LeafNodeType Node0
Definition: NanoVDB.h:2817
NodeT * getFirstNode()
return a pointer to the first node of the specified type
Definition: NanoVDB.h:2890
uint32_t nodeCount(int level) const
Definition: NanoVDB.h:2880
typename Node2::ChildNodeType Node1
Definition: NanoVDB.h:2816
const NodeTrait< RootT, LEVEL >::type * getFirstNode() const
return a const pointer to the first node of the specified level
Definition: NanoVDB.h:2921
const RootT & root() const
Definition: NanoVDB.h:2834
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel (regardless of state or location in the tree.)
Definition: NanoVDB.h:2839
RootT RootType
Definition: NanoVDB.h:2807
const ValueType & background() const
Return a const reference to the background value.
Definition: NanoVDB.h:2851
bool isEmpty() const
Return true if this tree is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:2845
Tree & operator=(const Tree &)=delete
typename RootT::ValueType ValueType
Definition: NanoVDB.h:2809
const DataType * data() const
Definition: NanoVDB.h:2827
typename RootT::BuildType BuildType
Definition: NanoVDB.h:2810
Dummy type for a voxel whose value equals an offset into an external value array.
Definition: NanoVDB.h:213
Dummy type for a voxel whose value equals its binary active state.
Definition: NanoVDB.h:216
Vec3(const Vec3< T2 > &v)
Definition: NanoVDB.h:1174
Coord round() const
Definition: NanoVDB.h:1273
Vec3(T x)
Definition: NanoVDB.h:1165
ValueType min() const
Return the smallest vector component.
Definition: NanoVDB.h:1262
Vec3 & minComponent(const Vec3 &other)
Perform a component-wise minimum with the other Coord.
Definition: NanoVDB.h:1239
Vec3(const Coord &ijk)
Definition: NanoVDB.h:1178
bool operator==(const Vec3 &rhs) const
Definition: NanoVDB.h:1182
Vec3 operator-() const
Definition: NanoVDB.h:1208
T length() const
Definition: NanoVDB.h:1207
Vec3 operator*(const Vec3 &v) const
Definition: NanoVDB.h:1209
Vec3 & maxComponent(const Vec3 &other)
Perform a component-wise maximum with the other Coord.
Definition: NanoVDB.h:1251
Vec3 & operator-=(const Vec3 &v)
Definition: NanoVDB.h:1222
Coord floor() const
Definition: NanoVDB.h:1271
Vec3 operator*(const T &s) const
Definition: NanoVDB.h:1213
Vec3(T x, T y, T z)
Definition: NanoVDB.h:1169
Vec3 operator/(const Vec3 &v) const
Definition: NanoVDB.h:1210
T dot(const Vec3T &v) const
Definition: NanoVDB.h:1195
Vec3 & operator=(const Vec3T &rhs)
Definition: NanoVDB.h:1185
Vec3 & operator*=(const T &s)
Definition: NanoVDB.h:1229
Vec3 & normalize()
Definition: NanoVDB.h:1237
T lengthSqr() const
Definition: NanoVDB.h:1203
Vec3 & operator+=(const Vec3 &v)
Definition: NanoVDB.h:1215
Coord ceil() const
Definition: NanoVDB.h:1272
const T & operator[](int i) const
Definition: NanoVDB.h:1192
Vec3 cross(const Vec3T &v) const
Definition: NanoVDB.h:1197
Vec3 operator/(const T &s) const
Definition: NanoVDB.h:1214
bool operator!=(const Vec3 &rhs) const
Definition: NanoVDB.h:1183
Vec3 operator+(const Vec3 &v) const
Definition: NanoVDB.h:1211
T & operator[](int i)
Definition: NanoVDB.h:1193
Vec3 operator-(const Vec3 &v) const
Definition: NanoVDB.h:1212
ValueType max() const
Return the largest vector component.
Definition: NanoVDB.h:1267
Vec3 & operator/=(const T &s)
Definition: NanoVDB.h:1236
T ValueType
Definition: NanoVDB.h:1163
static const int SIZE
Definition: NanoVDB.h:1162
A simple vector class with three double components, similar to openvdb::math::Vec4.
Definition: NanoVDB.h:1303
Vec4 & normalize()
Definition: NanoVDB.h:1375
Vec4 & operator/=(const T &s)
Definition: NanoVDB.h:1374
Vec4 operator/(const Vec4 &v) const
Definition: NanoVDB.h:1345
Vec4 & operator+=(const Vec4 &v)
Definition: NanoVDB.h:1350
Vec4 operator*(const T &s) const
Definition: NanoVDB.h:1348
T length() const
Definition: NanoVDB.h:1342
Vec4 operator-(const Vec4 &v) const
Definition: NanoVDB.h:1347
Vec4 & operator*=(const T &s)
Definition: NanoVDB.h:1366
Vec4 operator*(const Vec4 &v) const
Definition: NanoVDB.h:1344
Vec4(T x, T y, T z, T w)
Definition: NanoVDB.h:1314
bool operator!=(const Vec4 &rhs) const
Definition: NanoVDB.h:1324
Vec4 & maxComponent(const Vec4 &other)
Perform a component-wise maximum with the other Coord.
Definition: NanoVDB.h:1391
Vec4(const Vec4< T2 > &v)
Definition: NanoVDB.h:1319
T lengthSqr() const
Definition: NanoVDB.h:1338
const T & operator[](int i) const
Definition: NanoVDB.h:1334
Vec4 & operator=(const Vec4T &rhs)
Definition: NanoVDB.h:1326
Vec4 & operator-=(const Vec4 &v)
Definition: NanoVDB.h:1358
bool operator==(const Vec4 &rhs) const
Definition: NanoVDB.h:1323
Vec4 & minComponent(const Vec4 &other)
Perform a component-wise minimum with the other Coord.
Definition: NanoVDB.h:1377
T & operator[](int i)
Definition: NanoVDB.h:1335
Vec4 operator-() const
Definition: NanoVDB.h:1343
Vec4 operator/(const T &s) const
Definition: NanoVDB.h:1349
T dot(const Vec4T &v) const
Definition: NanoVDB.h:1337
T ValueType
Definition: NanoVDB.h:1308
Vec4(T x)
Definition: NanoVDB.h:1310
static const int SIZE
Definition: NanoVDB.h:1307
Vec4 operator+(const Vec4 &v) const
Definition: NanoVDB.h:1346
Bit-compacted representation of all three version numbers.
Definition: NanoVDB.h:648
const char * c_str() const
Definition: NanoVDB.h:674
bool operator<(const Version &rhs) const
Definition: NanoVDB.h:664
uint32_t getPatch() const
Definition: NanoVDB.h:671
bool operator<=(const Version &rhs) const
Definition: NanoVDB.h:665
Version()
Definition: NanoVDB.h:651
bool operator==(const Version &rhs) const
Definition: NanoVDB.h:663
Version(uint32_t major, uint32_t minor, uint32_t patch)
Definition: NanoVDB.h:656
uint32_t getMajor() const
Definition: NanoVDB.h:669
bool operator>=(const Version &rhs) const
Definition: NanoVDB.h:667
uint32_t getMinor() const
Definition: NanoVDB.h:670
uint32_t id() const
Definition: NanoVDB.h:668
bool operator>(const Version &rhs) const
Definition: NanoVDB.h:666
void writeUncompressedGrid(StreamT &os, const void *buffer)
This is a standalone alternative to io::writeGrid(...,Codec::NONE) defined in util/IO....
Definition: NanoVDB.h:5647
VecT< GridHandleT > readUncompressedGrids(StreamT &is, const typename GridHandleT::BufferType &buffer=typename GridHandleT::BufferType())
read all uncompressed grids from a stream and return their handles.
Definition: NanoVDB.h:5720
void writeUncompressedGrids(const char *fileName, const VecT< GridHandleT > &handles)
write multiple NanoVDB grids to a single file, without compression.
Definition: NanoVDB.h:5695
Definition: NanoVDB.h:208
uint64_t AlignUp(uint64_t byteCount)
round up byteSize to the nearest wordSize, e.g. to align to machine word: AlignUp<sizeof(size_t)(n)
Definition: NanoVDB.h:954
uint32_t CountOn(uint64_t v)
Definition: NanoVDB.h:1931
const char * toStr(GridType gridType)
Retuns a c-string used to describe a GridType.
Definition: NanoVDB.h:267
float Fract(float x)
Definition: NanoVDB.h:809
int MinIndex(const Vec3T &v)
Definition: NanoVDB.h:917
static int64_t PtrDiff(const T1 *p, const T2 *q)
Definition: NanoVDB.h:535
T Abs(T x)
Definition: NanoVDB.h:854
bool isApproxZero(const Type &x)
Definition: NanoVDB.h:752
Type Min(Type a, Type b)
Definition: NanoVDB.h:758
T Sign(const T &x)
Return the sign of the given value as an integer (either -1, 0 or 1).
Definition: NanoVDB.h:914
T Pow4(T x)
Definition: NanoVDB.h:849
static uint64_t alignmentPadding(const void *p)
return the smallest number of bytes that when added to the specified pointer results in an aligned po...
Definition: NanoVDB.h:510
Vec3< float > Vec3f
Definition: NanoVDB.h:1289
Vec3T matMult(const float *mat, const Vec3T &xyz)
Definition: NanoVDB.h:1531
static DstT * PtrAdd(SrcT *p, int64_t offset)
Definition: NanoVDB.h:542
GridClass
Classes (defined in OpenVDB) that are currently supported by NanoVDB.
Definition: NanoVDB.h:281
Vec3T matMultT(const float *mat, const Vec3T &xyz)
Definition: NanoVDB.h:1565
GridType
List of types that are currently supported by NanoVDB.
Definition: NanoVDB.h:243
float Sqrt(float x)
Return the square root of a floating-point value.
Definition: NanoVDB.h:902
int MaxIndex(const Vec3T &v)
Definition: NanoVDB.h:934
Vec3< T2 > operator/(T1 scalar, const Vec3< T2 > &vec)
Definition: NanoVDB.h:1282
ReadAccessor< ValueT, LEVEL0, LEVEL1, LEVEL2 > createAccessor(const NanoGrid< ValueT > &grid)
Free-standing function for convenient creation of a ReadAccessor with optional and customizable node ...
Definition: NanoVDB.h:5396
static T * alignPtr(T *p)
offset the specified pointer so it is aligned.
Definition: NanoVDB.h:518
GridFlags
Grid flags which indicate what extra information is present in the grid buffer.
Definition: NanoVDB.h:306
static uint32_t FindLowestOn(uint32_t v)
Returns the index of the lowest, i.e. least significant, on bit in the specified 32 bit word.
Definition: NanoVDB.h:1818
Vec3< T2 > operator*(T1 scalar, const Vec3< T2 > &vec)
Definition: NanoVDB.h:1277
int32_t Ceil(float x)
Definition: NanoVDB.h:827
static uint32_t FindHighestOn(uint32_t v)
Returns the index of the highest, i.e. most significant, on bit in the specified 32 bit word.
Definition: NanoVDB.h:1850
int32_t Floor(float x)
Definition: NanoVDB.h:818
GridBlindDataClass
Blind-data Classes that are currently supported by NanoVDB.
Definition: NanoVDB.h:335
Vec3< double > Vec3d
Definition: NanoVDB.h:1288
GridType mapToGridType()
Maps from a templated value type to a GridType enum.
Definition: NanoVDB.h:1486
CoordT Round(const Vec3T< RealT > &xyz)
T Pow3(T x)
Definition: NanoVDB.h:843
CoordT RoundDown(const Vec3T< RealT > &xyz)
Definition: NanoVDB.h:895
static bool isAligned(const void *p)
return true if the specified pointer is aligned
Definition: NanoVDB.h:498
GridBlindDataSemantic
Blind-data Semantics that are currently understood by NanoVDB.
Definition: NanoVDB.h:343
bool isFloatingPoint(GridType gridType)
return true if the GridType maps to a floating point value.
Definition: NanoVDB.h:610
T Pow2(T x)
Definition: NanoVDB.h:837
float Clamp(float x, float a, float b)
Definition: NanoVDB.h:800
Type Max(Type a, Type b)
Definition: NanoVDB.h:779
static bool isValid(const void *p)
return true if the specified pointer is aligned and not NULL
Definition: NanoVDB.h:504
Iterator begin() const
Definition: NanoVDB.h:1747
BBox()
Definition: NanoVDB.h:1748
bool is_divisible() const
Definition: NanoVDB.h:1772
BBox(const CoordT &min, const CoordT &max)
Definition: NanoVDB.h:1752
CoordT dim() const
Definition: NanoVDB.h:1779
bool empty() const
Return true if this bounding box is empty, i.e. uninitialized.
Definition: NanoVDB.h:1776
BBox expandBy(typename CoordT::ValueType padding) const
Return a new instance that is expanded by the specified padding.
Definition: NanoVDB.h:1803
bool isInside(const BBox &b) const
Return true if the given bounding box is inside this bounding box.
Definition: NanoVDB.h:1783
bool hasOverlap(const BBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: NanoVDB.h:1789
uint64_t volume() const
Definition: NanoVDB.h:1780
static BBox createCube(const CoordT &min, typename CoordT::ValueType dim)
Definition: NanoVDB.h:1767
BBox(BBox &other, const SplitT &)
Definition: NanoVDB.h:1758
BBox< Vec3< RealT > > asReal() const
Definition: NanoVDB.h:1796
bool isInside(const CoordT &p) const
Definition: NanoVDB.h:1781
Vec3T dim() const
Definition: NanoVDB.h:1692
bool isInside(const Vec3T &p) const
Definition: NanoVDB.h:1693
BBox()
Definition: NanoVDB.h:1669
BBox(const Coord &min, const Coord &max)
Definition: NanoVDB.h:1678
bool empty() const
Definition: NanoVDB.h:1689
BBox(const Vec3T &min, const Vec3T &max)
Definition: NanoVDB.h:1674
Vec3T Vec3Type
Definition: NanoVDB.h:1664
typename Vec3T::ValueType ValueType
Definition: NanoVDB.h:1665
static BBox createCube(const Coord &min, typename Coord::ValueType dim)
Definition: NanoVDB.h:1683
BBox(const BaseBBox< Coord > &bbox)
Definition: NanoVDB.h:1688
Definition: NanoVDB.h:1655
Definition: NanoVDB.h:1601
Vec3T mCoord[2]
Definition: NanoVDB.h:1602
BaseBBox()
Definition: NanoVDB.h:1647
const Vec3T & max() const
Definition: NanoVDB.h:1610
Coord & translate(const Vec3T &xyz)
Definition: NanoVDB.h:1611
BaseBBox & expand(const Vec3T &xyz)
Definition: NanoVDB.h:1618
bool operator!=(const BaseBBox &rhs) const
Definition: NanoVDB.h:1604
const Vec3T & operator[](int i) const
Definition: NanoVDB.h:1605
Vec3T & operator[](int i)
Definition: NanoVDB.h:1606
bool isInside(const Vec3T &xyz)
Definition: NanoVDB.h:1637
const Vec3T & min() const
Definition: NanoVDB.h:1609
BaseBBox(const Vec3T &min, const Vec3T &max)
Definition: NanoVDB.h:1648
Vec3T & min()
Definition: NanoVDB.h:1607
bool operator==(const BaseBBox &rhs) const
Definition: NanoVDB.h:1603
Vec3T & max()
Definition: NanoVDB.h:1608
BaseBBox & intersect(const BaseBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: NanoVDB.h:1626
float type
Definition: NanoVDB.h:485
float Type
Definition: NanoVDB.h:484
float type
Definition: NanoVDB.h:471
float Type
Definition: NanoVDB.h:470
float type
Definition: NanoVDB.h:478
float Type
Definition: NanoVDB.h:477
float type
Definition: NanoVDB.h:492
float Type
Definition: NanoVDB.h:491
float type
Definition: NanoVDB.h:464
float Type
Definition: NanoVDB.h:463
uint64_t Type
Definition: NanoVDB.h:449
uint64_t type
Definition: NanoVDB.h:450
bool Type
Definition: NanoVDB.h:456
bool type
Definition: NanoVDB.h:457
Maps one type (e.g. the build types above) to other (actual) types.
Definition: NanoVDB.h:441
T Type
Definition: NanoVDB.h:442
T type
Definition: NanoVDB.h:443
static double value()
Definition: NanoVDB.h:713
static float value()
Definition: NanoVDB.h:708
Delta for small floating-point offsets.
Definition: NanoVDB.h:704
double FloatType
Definition: NanoVDB.h:1461
uint64_t FloatType
Definition: NanoVDB.h:1473
bool FloatType
Definition: NanoVDB.h:1479
bool FloatType
Definition: NanoVDB.h:1467
Definition: NanoVDB.h:1454
float FloatType
Definition: NanoVDB.h:1455
Struct with all the member data of the Grid (useful during serialization of an openvdb grid)
Definition: NanoVDB.h:2432
uint32_t mFlags
Definition: NanoVDB.h:2437
const void * treePtr() const
Definition: NanoVDB.h:2530
void setMinMaxOn(bool on=true)
Definition: NanoVDB.h:2454
void setAverageOn(bool on=true)
Definition: NanoVDB.h:2478
Vec3T applyInverseJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2522
Vec3T applyIJTF(const Vec3T &xyz) const
Definition: NanoVDB.h:2524
uint32_t mBlindMetadataCount
Definition: NanoVDB.h:2448
Version mVersion
Definition: NanoVDB.h:2436
uint32_t mData0
Definition: NanoVDB.h:2449
GridType mGridType
Definition: NanoVDB.h:2446
uint64_t mMagic
Definition: NanoVDB.h:2434
void setStdDeviationOn(bool on=true)
Definition: NanoVDB.h:2486
Vec3T applyIJT(const Vec3T &xyz) const
Definition: NanoVDB.h:2513
GridClass mGridClass
Definition: NanoVDB.h:2445
void setBBoxOn(bool on=true)
Definition: NanoVDB.h:2462
void setLongGridNameOn(bool on=true)
Definition: NanoVDB.h:2470
Vec3T applyJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2520
uint64_t mGridSize
Definition: NanoVDB.h:2440
BBox< Vec3R > mWorldBBox
Definition: NanoVDB.h:2443
Vec3T applyInverseJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2511
void * treePtr()
Definition: NanoVDB.h:2527
const GridBlindMetaData * blindMetaData(uint32_t n) const
Returns a const reference to the blindMetaData at the specified linear offset.
Definition: NanoVDB.h:2535
void setBreadthFirstOn(bool on=true)
Definition: NanoVDB.h:2494
uint64_t mChecksum
Definition: NanoVDB.h:2435
Vec3T applyMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2516
uint64_t mData1
Definition: NanoVDB.h:2450
uint32_t mGridCount
Definition: NanoVDB.h:2439
Vec3R mVoxelSize
Definition: NanoVDB.h:2444
Vec3T applyInverseMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2507
Map mMap
Definition: NanoVDB.h:2442
Vec3T applyJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2509
void setFlagsOff()
Definition: NanoVDB.h:2453
int64_t mBlindMetadataOffset
Definition: NanoVDB.h:2447
uint32_t mGridIndex
Definition: NanoVDB.h:2438
Vec3T applyMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2505
Vec3T applyInverseMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2518
const typename GridT::TreeType Type
Definition: NanoVDB.h:2790
const typename GridT::TreeType type
Definition: NanoVDB.h:2791
defines a tree type from a grid type while preserving constness
Definition: NanoVDB.h:2783
typename GridT::TreeType Type
Definition: NanoVDB.h:2784
typename GridT::TreeType type
Definition: NanoVDB.h:2785
Struct with all the member data of the InternalNode (useful during serialization of an openvdb Intern...
Definition: NanoVDB.h:3418
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3499
StatsT mAverage
Definition: NanoVDB.h:3444
typename ChildT::CoordType CoordT
Definition: NanoVDB.h:3422
void setChild(uint32_t n, const void *ptr)
Definition: NanoVDB.h:3459
MaskT mChildMask
Definition: NanoVDB.h:3440
void setValue(uint32_t n, const ValueT &v)
Definition: NanoVDB.h:3466
InternalData(const InternalData &)=delete
const ValueT & getMax() const
Definition: NanoVDB.h:3502
void setDev(const StatsT &v)
Definition: NanoVDB.h:3509
const ChildT * getChild(uint32_t n) const
Definition: NanoVDB.h:3478
bool isActive(uint32_t n) const
Definition: NanoVDB.h:3490
void setMin(const ValueT &v)
Definition: NanoVDB.h:3506
typename ChildT::FloatType StatsT
Definition: NanoVDB.h:3421
bool isChild(uint32_t n) const
Definition: NanoVDB.h:3496
typename ChildT::BuildType BuildT
Definition: NanoVDB.h:3420
ValueT getValue(uint32_t n) const
Definition: NanoVDB.h:3484
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition: NanoVDB.h:3451
const ValueT & getMin() const
Definition: NanoVDB.h:3501
void setMax(const ValueT &v)
Definition: NanoVDB.h:3507
StatsT mStdDevi
Definition: NanoVDB.h:3445
BBox< CoordT > mBBox
Definition: NanoVDB.h:3437
ChildT * getChild(uint32_t n)
Returns a pointer to the child node at the specifed linear offset.
Definition: NanoVDB.h:3473
ValueT mMaximum
Definition: NanoVDB.h:3443
const StatsT & stdDeviation() const
Definition: NanoVDB.h:3504
static uint64_t memUsage()
Definition: NanoVDB.h:3457
const StatsT & average() const
Definition: NanoVDB.h:3503
MaskT mValueMask
Definition: NanoVDB.h:3439
typename ChildT::template MaskType< LOG2DIM > MaskT
Definition: NanoVDB.h:3423
InternalData & operator=(const InternalData &)=delete
void setAvg(const StatsT &v)
Definition: NanoVDB.h:3508
typename ChildT::ValueType ValueT
Definition: NanoVDB.h:3419
ValueT mMinimum
Definition: NanoVDB.h:3442
InternalData()=delete
This class cannot be constructed or deleted.
uint64_t mFlags
Definition: NanoVDB.h:3438
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:4010
float getValue(uint32_t i) const
Definition: NanoVDB.h:4011
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
static constexpr uint32_t padding()
Definition: NanoVDB.h:4005
uint16_t ArrayType
Definition: NanoVDB.h:4000
LeafData()=delete
This class cannot be constructed or deleted.
static constexpr uint64_t memUsage()
Definition: NanoVDB.h:4004
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:3949
float getValue(uint32_t i) const
Definition: NanoVDB.h:3950
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
static constexpr uint32_t padding()
Definition: NanoVDB.h:3944
LeafData()=delete
This class cannot be constructed or deleted.
uint8_t ArrayType
Definition: NanoVDB.h:3939
static constexpr uint64_t memUsage()
Definition: NanoVDB.h:3943
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:3982
float getValue(uint32_t i) const
Definition: NanoVDB.h:3983
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
static constexpr uint32_t padding()
Definition: NanoVDB.h:3977
static constexpr int64_t memUsage()
Definition: NanoVDB.h:3976
LeafData()=delete
This class cannot be constructed or deleted.
uint8_t ArrayType
Definition: NanoVDB.h:3973
size_t memUsage() const
Definition: NanoVDB.h:4037
float getValue(uint32_t i) const
Definition: NanoVDB.h:4039
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
uint8_t bitWidth() const
Definition: NanoVDB.h:4036
static constexpr uint32_t padding()
Definition: NanoVDB.h:4031
LeafData()=delete
This class cannot be constructed or deleted.
static size_t memUsage(uint32_t bitWidth)
Definition: NanoVDB.h:4038
void setOrigin(const T &ijk)
Definition: NanoVDB.h:4237
void setDev(const T &dev, T *p)
Definition: NanoVDB.h:4235
uint64_t getMax() const
Definition: NanoVDB.h:4212
uint64_t ValueType
Definition: NanoVDB.h:4190
uint64_t FloatType
Definition: NanoVDB.h:4192
uint64_t mValueOff
Definition: NanoVDB.h:4202
uint8_t mFlags
Definition: NanoVDB.h:4198
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
uint64_t getValue(uint32_t i) const
Definition: NanoVDB.h:4220
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:4200
CoordT mBBoxMin
Definition: NanoVDB.h:4196
static constexpr uint32_t padding()
Definition: NanoVDB.h:4205
void setValue(uint32_t offset, uint64_t)
Definition: NanoVDB.h:4215
LeafData()=delete
This class cannot be constructed or deleted.
void setMax(const T &max, T *p)
Definition: NanoVDB.h:4231
static uint64_t memUsage()
Definition: NanoVDB.h:4209
void setMin(const T &min, T *p)
Definition: NanoVDB.h:4229
uint64_t getAvg() const
Definition: NanoVDB.h:4213
uint64_t getDev() const
Definition: NanoVDB.h:4214
uint64_t mStatsOff
Definition: NanoVDB.h:4201
void ArrayType
Definition: NanoVDB.h:4193
void setAvg(const T &avg, T *p)
Definition: NanoVDB.h:4233
uint64_t getMin() const
Definition: NanoVDB.h:4211
void setOrigin(const T &ijk)
Definition: NanoVDB.h:4175
bool getDev() const
Definition: NanoVDB.h:4163
bool getMin() const
Definition: NanoVDB.h:4160
void setMax(const ValueType &)
Definition: NanoVDB.h:4170
bool getValue(uint32_t i) const
Definition: NanoVDB.h:4159
uint8_t mFlags
Definition: NanoVDB.h:4148
LeafData & operator=(const LeafData &)=delete
bool getMax() const
Definition: NanoVDB.h:4161
void setDev(const FloatType &)
Definition: NanoVDB.h:4172
LeafData(const LeafData &)=delete
bool getAvg() const
Definition: NanoVDB.h:4162
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:4149
void setValue(uint32_t offset, bool)
Definition: NanoVDB.h:4164
CoordT mBBoxMin
Definition: NanoVDB.h:4146
static constexpr uint32_t padding()
Definition: NanoVDB.h:4154
bool ValueType
Definition: NanoVDB.h:4140
LeafData()=delete
This class cannot be constructed or deleted.
void setAvg(const FloatType &)
Definition: NanoVDB.h:4171
static uint64_t memUsage()
Definition: NanoVDB.h:4152
void setMin(const ValueType &)
Definition: NanoVDB.h:4169
bool FloatType
Definition: NanoVDB.h:4142
void ArrayType
Definition: NanoVDB.h:4143
void setOrigin(const T &ijk)
Definition: NanoVDB.h:4125
bool getDev() const
Definition: NanoVDB.h:4112
bool BuildType
Definition: NanoVDB.h:4092
void setMin(const bool &)
Definition: NanoVDB.h:4119
bool getMin() const
Definition: NanoVDB.h:4109
void setMax(const bool &)
Definition: NanoVDB.h:4120
void setValue(uint32_t offset, bool v)
Definition: NanoVDB.h:4113
bool getValue(uint32_t i) const
Definition: NanoVDB.h:4108
uint8_t mFlags
Definition: NanoVDB.h:4099
LeafData & operator=(const LeafData &)=delete
bool getMax() const
Definition: NanoVDB.h:4110
LeafData(const LeafData &)=delete
MaskT< LOG2DIM > ArrayType
Definition: NanoVDB.h:4094
bool getAvg() const
Definition: NanoVDB.h:4111
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:4100
MaskT< LOG2DIM > mValues
Definition: NanoVDB.h:4101
CoordT mBBoxMin
Definition: NanoVDB.h:4097
static constexpr uint32_t padding()
Definition: NanoVDB.h:4104
bool ValueType
Definition: NanoVDB.h:4091
void setDev(const bool &)
Definition: NanoVDB.h:4122
LeafData()=delete
This class cannot be constructed or deleted.
static uint64_t memUsage()
Definition: NanoVDB.h:4105
void setAvg(const bool &)
Definition: NanoVDB.h:4121
bool FloatType
Definition: NanoVDB.h:4093
Stuct with all the member data of the LeafNode (useful during serialization of an openvdb LeafNode)
Definition: NanoVDB.h:3810
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3860
ValueType mMaximum
Definition: NanoVDB.h:3825
FloatType getDev() const
Definition: NanoVDB.h:3852
typename FloatTraits< ValueT >::FloatType FloatType
Definition: NanoVDB.h:3815
void setMin(const ValueType &v)
Definition: NanoVDB.h:3854
void setMax(const ValueType &v)
Definition: NanoVDB.h:3855
FloatType mAverage
Definition: NanoVDB.h:3826
void setDev(const FloatType &v)
Definition: NanoVDB.h:3857
uint8_t mFlags
Definition: NanoVDB.h:3821
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
ValueType getMin() const
Definition: NanoVDB.h:3849
ValueType getValue(uint32_t i) const
Definition: NanoVDB.h:3841
void setValue(uint32_t offset, const ValueType &value)
Definition: NanoVDB.h:3843
ValueT ValueType
Definition: NanoVDB.h:3813
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3822
void setValueOnly(uint32_t offset, const ValueType &value)
Definition: NanoVDB.h:3842
CoordT mBBoxMin
Definition: NanoVDB.h:3819
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition: NanoVDB.h:3833
ValueType getMax() const
Definition: NanoVDB.h:3850
LeafData()=delete
This class cannot be constructed or deleted.
ValueT ArrayType
Definition: NanoVDB.h:3816
FloatType getAvg() const
Definition: NanoVDB.h:3851
static uint64_t memUsage()
Definition: NanoVDB.h:3838
ValueType mMinimum
Definition: NanoVDB.h:3824
void setAvg(const FloatType &v)
Definition: NanoVDB.h:3856
ValueT BuildType
Definition: NanoVDB.h:3814
FloatType mStdDevi
Definition: NanoVDB.h:3827
Base-class for quantized float leaf nodes.
Definition: NanoVDB.h:3872
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3927
float ValueType
Definition: NanoVDB.h:3875
float getMin() const
return the quantized minimum of the active values in this node
Definition: NanoVDB.h:3902
void setDev(float dev)
Definition: NanoVDB.h:3924
void setMin(float min)
Definition: NanoVDB.h:3915
float getAvg() const
return the quantized average of the active values in this node
Definition: NanoVDB.h:3908
uint8_t mFlags
Definition: NanoVDB.h:3880
float mQuantum
Definition: NanoVDB.h:3884
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3881
void init(float min, float max, uint8_t bitWidth)
Definition: NanoVDB.h:3895
uint16_t mAvg
Definition: NanoVDB.h:3885
CoordT mBBoxMin
Definition: NanoVDB.h:3878
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition: NanoVDB.h:3892
float mMinimum
Definition: NanoVDB.h:3883
float FloatType
Definition: NanoVDB.h:3876
void setMax(float max)
Definition: NanoVDB.h:3918
void setAvg(float avg)
Definition: NanoVDB.h:3921
static uint64_t memUsage()
Definition: NanoVDB.h:3887
float getDev() const
return the quantized standard deviation of the active values in this node
Definition: NanoVDB.h:3912
float getMax() const
return the quantized maximum of the active values in this node
Definition: NanoVDB.h:3905
Definition: NanoVDB.h:4255
static uint32_t dim()
Definition: NanoVDB.h:4258
Defines an affine transform and its inverse represented as a 3x3 matrix and a vec3 translation.
Definition: NanoVDB.h:2224
double mTaperD
Definition: NanoVDB.h:2232
Vec3T applyInverseJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2270
Vec3T applyIJTF(const Vec3T &xyz) const
Definition: NanoVDB.h:2275
double mVecD[3]
Definition: NanoVDB.h:2231
void set(const Mat3T &mat, const Mat3T &invMat, const Vec3T &translate, double taper)
Initialize the member data.
Definition: NanoVDB.h:2279
float mInvMatF[9]
Definition: NanoVDB.h:2226
Vec3T applyIJT(const Vec3T &xyz) const
Definition: NanoVDB.h:2273
Vec3T applyJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2254
Vec3T applyInverseJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2268
void set(const Mat4T &mat, const Mat4T &invMat, double taper)
Initialize the member data.
Definition: NanoVDB.h:2241
double mInvMatD[9]
Definition: NanoVDB.h:2230
Vec3T applyMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2249
float mMatF[9]
Definition: NanoVDB.h:2225
Vec3T applyInverseMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2257
double mMatD[9]
Definition: NanoVDB.h:2229
Vec3T applyJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2252
Vec3T applyMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2247
Vec3T applyInverseMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2262
float mTaperF
Definition: NanoVDB.h:2228
float mVecF[3]
Definition: NanoVDB.h:2227
Maximum floating-point values.
Definition: NanoVDB.h:745
static T value()
Definition: NanoVDB.h:746
Trait to map from LEVEL to node type.
Definition: NanoVDB.h:4567
typename GridOrTreeOrRootT::LeafNodeType type
Definition: NanoVDB.h:2351
typename GridOrTreeOrRootT::LeafNodeType Type
Definition: NanoVDB.h:2350
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType Type
Definition: NanoVDB.h:2365
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType type
Definition: NanoVDB.h:2366
typename GridOrTreeOrRootT::RootType::ChildNodeType Type
Definition: NanoVDB.h:2379
typename GridOrTreeOrRootT::RootType::ChildNodeType type
Definition: NanoVDB.h:2380
typename GridOrTreeOrRootT::RootType type
Definition: NanoVDB.h:2394
typename GridOrTreeOrRootT::RootType Type
Definition: NanoVDB.h:2393
const typename GridOrTreeOrRootT::LeafNodeType Type
Definition: NanoVDB.h:2357
const typename GridOrTreeOrRootT::LeafNodeType type
Definition: NanoVDB.h:2358
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType Type
Definition: NanoVDB.h:2372
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType type
Definition: NanoVDB.h:2373
const typename GridOrTreeOrRootT::RootType::ChildNodeType type
Definition: NanoVDB.h:2387
const typename GridOrTreeOrRootT::RootType::ChildNodeType Type
Definition: NanoVDB.h:2386
const typename GridOrTreeOrRootT::RootType type
Definition: NanoVDB.h:2402
const typename GridOrTreeOrRootT::RootType Type
Definition: NanoVDB.h:2401
Struct to derive node type from its level in a given grid, tree or root while preserving constness.
Definition: NanoVDB.h:2343
uint32_t mLevel
Definition: NanoVDB.h:4662
ValueType mMaximum
Definition: NanoVDB.h:4665
uint32_t mDim
Definition: NanoVDB.h:4663
FloatType mAverage
Definition: NanoVDB.h:4666
CoordType mBBoxMax
Definition: NanoVDB.h:4669
ValueType mMinimum
Definition: NanoVDB.h:4664
CoordType mBBoxMin
Definition: NanoVDB.h:4668
FloatType mStdDevi
Definition: NanoVDB.h:4667
Definition: NanoVDB.h:3001
ValueT value
Definition: NanoVDB.h:3023
void setChild(const CoordType &k, const ChildT *ptr, const RootData *data)
Definition: NanoVDB.h:3003
uint32_t state
Definition: NanoVDB.h:3022
bool isActive() const
Definition: NanoVDB.h:3018
KeyT key
Definition: NanoVDB.h:3020
void setValue(const CoordType &k, bool s, const ValueType &v)
Definition: NanoVDB.h:3009
CoordT origin() const
Definition: NanoVDB.h:3019
bool isValue() const
Definition: NanoVDB.h:3017
bool isChild() const
Definition: NanoVDB.h:3016
int64_t child
Definition: NanoVDB.h:3021
Struct with all the member data of the RootNode (useful during serialization of an openvdb RootNode)
Definition: NanoVDB.h:2953
StatsT mAverage
Definition: NanoVDB.h:2990
typename ChildT::CoordType CoordT
Definition: NanoVDB.h:2956
static CoordT KeyToCoord(const KeyT &key)
Definition: NanoVDB.h:2972
const ChildT * getChild(const Tile *tile) const
Definition: NanoVDB.h:3048
RootData()=delete
This class cannot be constructed or deleted.
ValueT mBackground
Definition: NanoVDB.h:2987
Tile * tile(uint32_t n)
Definition: NanoVDB.h:3034
const Tile * tile(uint32_t n) const
Returns a non-const reference to the tile at the specified linear offset.
Definition: NanoVDB.h:3029
uint32_t mTableSize
Definition: NanoVDB.h:2985
const ValueT & getMax() const
Definition: NanoVDB.h:3055
void setDev(const StatsT &v)
Definition: NanoVDB.h:3062
uint64_t KeyT
Return a key based on the coordinates of a voxel.
Definition: NanoVDB.h:2962
void setMin(const ValueT &v)
Definition: NanoVDB.h:3059
typename ChildT::FloatType StatsT
Definition: NanoVDB.h:2957
typename ChildT::BuildType BuildT
Definition: NanoVDB.h:2955
ChildT * getChild(const Tile *tile)
Returns a const reference to the child node in the specified tile.
Definition: NanoVDB.h:3043
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition: NanoVDB.h:2996
const ValueT & getMin() const
Definition: NanoVDB.h:3054
void setMax(const ValueT &v)
Definition: NanoVDB.h:3060
StatsT mStdDevi
Definition: NanoVDB.h:2991
RootData(const RootData &)=delete
static KeyT CoordToKey(const CoordType &ijk)
Definition: NanoVDB.h:2964
RootData & operator=(const RootData &)=delete
BBox< CoordT > mBBox
Definition: NanoVDB.h:2984
ValueT mMaximum
Definition: NanoVDB.h:2989
const StatsT & stdDeviation() const
Definition: NanoVDB.h:3057
const StatsT & average() const
Definition: NanoVDB.h:3056
void setAvg(const StatsT &v)
Definition: NanoVDB.h:3061
typename ChildT::ValueType ValueT
Definition: NanoVDB.h:2954
ValueT mMinimum
Definition: NanoVDB.h:2988
T ElementType
Definition: NanoVDB.h:1435
static T scalar(const T &s)
Definition: NanoVDB.h:1436
static ElementType scalar(const T &v)
Definition: NanoVDB.h:1447
typename T::ValueType ElementType
Definition: NanoVDB.h:1446
Definition: NanoVDB.h:1426
static double value()
Definition: NanoVDB.h:697
static float value()
Definition: NanoVDB.h:692
Tolerance for floating-point comparison.
Definition: NanoVDB.h:688
Definition: NanoVDB.h:2757
const RootT * getRoot() const
Definition: NanoVDB.h:2769
void setFirstNode(const NodeT *node)
Definition: NanoVDB.h:2772
RootT * getRoot()
Definition: NanoVDB.h:2767
void setRoot(const RootT *root)
Definition: NanoVDB.h:2765
uint64_t mVoxelCount
Definition: NanoVDB.h:2762
T type
Definition: NanoVDB.h:378
C++11 implementation of std::enable_if.
Definition: NanoVDB.h:372
Definition: NanoVDB.h:385
static constexpr bool value
Definition: NanoVDB.h:386
C++11 implementation of std::is_floating_point.
Definition: NanoVDB.h:414
static const bool value
Definition: NanoVDB.h:415
C++11 implementation of std::is_same.
Definition: NanoVDB.h:357
static constexpr bool value
Definition: NanoVDB.h:358
Metafunction used to determine if the first template parameter is a specialization of the class templ...
Definition: NanoVDB.h:427
static const bool value
Definition: NanoVDB.h:428
T type
Definition: NanoVDB.h:406
Definition: NanoVDB.h:399
T type
Definition: NanoVDB.h:400
Definition: NanoVDB.h:3427
ValueT value
Definition: NanoVDB.h:3428
Tile(const Tile &)=delete
Tile & operator=(const Tile &)=delete
Tile()=delete
This class cannot be constructed or deleted.
int64_t child
Definition: NanoVDB.h:3429