99 #ifndef NANOVDB_NANOVDB_H_HAS_BEEN_INCLUDED 100 #define NANOVDB_NANOVDB_H_HAS_BEEN_INCLUDED 102 #define NANOVDB_MAGIC_NUMBER 0x304244566f6e614eUL // "NanoVDB0" in hex - little endian (uint64_t) 104 #define NANOVDB_MAJOR_VERSION_NUMBER 32 // reflects changes to the ABI and hence also the file format 105 #define NANOVDB_MINOR_VERSION_NUMBER 3 // reflects changes to the API but not ABI 106 #define NANOVDB_PATCH_VERSION_NUMBER 3 // reflects changes that does not affect the ABI or API 109 #define USE_SINGLE_ROOT_KEY 114 #define NANOVDB_FPN_BRANCHLESS 116 #define NANOVDB_DATA_ALIGNMENT 32 118 #if !defined(NANOVDB_ALIGN) 119 #define NANOVDB_ALIGN(n) alignas(n) 120 #endif // !defined(NANOVDB_ALIGN) 122 #ifdef __CUDACC_RTC__ 124 typedef signed char int8_t;
125 typedef short int16_t;
127 typedef long long int64_t;
128 typedef unsigned char uint8_t;
129 typedef unsigned int uint32_t;
130 typedef unsigned short uint16_t;
131 typedef unsigned long long uint64_t;
133 #define NANOVDB_ASSERT(x) 135 #define UINT64_C(x) (x ## ULL) 137 #else // __CUDACC_RTC__ 149 #define NANOVDB_ASSERT(x) assert(x) 151 #define NANOVDB_ASSERT(x) 154 #if defined(NANOVDB_USE_INTRINSICS) && defined(_MSC_VER) 156 #pragma intrinsic(_BitScanReverse) 157 #pragma intrinsic(_BitScanForward) 158 #pragma intrinsic(_BitScanReverse64) 159 #pragma intrinsic(_BitScanForward64) 162 #endif // __CUDACC_RTC__ 164 #if defined(__CUDACC__) || defined(__HIP__) 166 #define __hostdev__ __host__ __device__ 173 #if defined(_MSC_VER) && defined(__CUDACC__) 174 #define NANOVDB_HOSTDEV_DISABLE_WARNING __pragma("hd_warning_disable") 175 #elif defined(__GNUC__) && defined(__CUDACC__) 176 #define NANOVDB_HOSTDEV_DISABLE_WARNING _Pragma("hd_warning_disable") 178 #define NANOVDB_HOSTDEV_DISABLE_WARNING 182 #define NANOVDB_OFFSETOF(CLASS, MEMBER) ((int)(size_t)((char*)&((CLASS*)0)->MEMBER - (char*)0)) 237 #ifndef __CUDACC_RTC__ 241 static const char * LUT[] = {
"?",
"float",
"double" ,
"int16",
"int32",
242 "int64",
"Vec3f",
"Vec3d",
"Mask",
"Half",
243 "uint32",
"bool",
"RGBA8",
"Float4",
"Float8",
244 "Float16",
"FloatN",
"Vec4f",
"Vec4d",
"End" };
245 static_assert(
sizeof(LUT)/
sizeof(
char*) - 1 ==
int(
GridType::End),
"Unexpected size of LUT" );
246 return LUT[
static_cast<int>(gridType)];
263 #ifndef __CUDACC_RTC__ 267 static const char * LUT[] = {
"?",
"SDF",
"FOG" ,
"MAC",
"PNTIDX",
268 "PNTDAT",
"TOPO",
"VOX",
"END" };
269 static_assert(
sizeof(LUT)/
sizeof(
char*) - 1 ==
int(
GridClass::End),
"Unexpected size of LUT" );
270 return LUT[
static_cast<int>(gridClass)];
287 #ifndef __CUDACC_RTC__ 291 static const char * LUT[] = {
"has long grid name",
295 "has standard deviation",
298 static_assert( 1 << (
sizeof(LUT)/
sizeof(
char*) - 1) ==
int(
GridFlags::End),
"Unexpected size of LUT" );
299 return LUT[
static_cast<int>(gridFlags)];
325 template<
typename T1,
typename T2>
328 static constexpr
bool value =
false;
340 template <
bool,
typename T =
void>
345 template <
typename T>
367 template<
typename AnyType,
template<
typename...>
class TemplateType>
372 template<
typename... Args,
template<
typename...>
class TemplateType>
381 template <
typename T>
432 template <
typename T1,
typename T2>
436 return reinterpret_cast<const char*
>(p) - reinterpret_cast<const char*>(q);
439 template <
typename DstT,
typename SrcT>
443 return reinterpret_cast<DstT*
>(
reinterpret_cast<char*
>(p) + offset);
446 template <
typename DstT,
typename SrcT>
450 return reinterpret_cast<const DstT*
>(
reinterpret_cast<const char*
>(p) + offset);
462 static const int SIZE = 4;
470 __hostdev__ Rgba8(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255u) : mData{r, g, b, a} {}
473 : mData{(uint8_t(0.5f + r * 255.0f)),
474 (uint8_t(0.5f + g * 255.0f)),
475 (uint8_t(0.5f + b * 255.0f)),
476 (uint8_t(0.5f + a * 255.0f))}
483 return 0.0000153787005f*(float(mData.c[0])*mData.c[0] +
484 float(mData.c[1])*mData.c[1] +
485 float(mData.c[2])*mData.c[2]);
550 : mData( major << 21 | minor << 10 | patch )
566 #ifndef __CUDACC_RTC__ 569 char *buffer = (
char*)malloc(4 + 1 + 4 + 1 + 4 + 1);
570 sprintf(buffer,
"%d.%d.%d", this->getMajor(), this->getMinor(), this->getPatch());
614 #if defined(__CUDA_ARCH__) || defined(__HIP__) 644 template<
typename Type>
650 template<
typename Type>
653 return (a < b) ? a : b;
657 return int32_t(fminf(
float(a),
float(b)));
661 return uint32_t(fminf(
float(a),
float(b)));
671 template<
typename Type>
674 return (a > b) ? a : b;
679 return int32_t(fmaxf(
float(a),
float(b)));
683 return uint32_t(fmaxf(
float(a),
float(b)));
704 return x - floorf(x);
713 return int32_t(floorf(x));
717 return int32_t(floor(x));
722 return int32_t(ceilf(x));
726 return int32_t(ceil(x));
749 return x < 0 ? -x : x;
770 template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
773 template<
typename CoordT,
template<
typename>
class Vec3T>
776 return CoordT(int32_t(rintf(xyz[0])), int32_t(rintf(xyz[1])), int32_t(rintf(xyz[2])));
781 template<
typename CoordT,
template<
typename>
class Vec3T>
784 return CoordT(int32_t(floor(xyz[0] + 0.5)), int32_t(floor(xyz[1] + 0.5)), int32_t(floor(xyz[2] + 0.5)));
787 template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
806 template <
typename T>
807 __hostdev__ inline T
Sign(
const T &x) {
return ((T(0) < x)?T(1):T(0)) - ((x < T(0))?T(1):T(0)); }
809 template<
typename Vec3T>
813 static const int hashTable[8] = {2, 1, 9, 1, 2, 9, 0, 0};
814 const int hashKey = ((v[0] < v[1]) << 2) + ((v[0] < v[2]) << 1) + (v[1] < v[2]);
815 return hashTable[hashKey];
817 if (v[0] < v[1] && v[0] < v[2])
826 template<
typename Vec3T>
830 static const int hashTable[8] = {2, 1, 9, 1, 2, 9, 0, 0};
831 const int hashKey = ((v[0] > v[1]) << 2) + ((v[0] > v[2]) << 1) + (v[1] > v[2]);
832 return hashTable[hashKey];
834 if (v[0] > v[1] && v[0] > v[2])
846 template<u
int64_t wordSize>
849 const uint64_t r = byteCount % wordSize;
850 return r ? byteCount - r + wordSize : byteCount;
885 : mVec{ptr[0], ptr[1], ptr[2]}
912 template <
typename CoordT>
915 static_assert(
sizeof(
Coord) ==
sizeof(CoordT),
"Mis-matched sizeof");
934 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;
981 if (other[0] < mVec[0])
983 if (other[1] < mVec[1])
985 if (other[2] < mVec[2])
993 if (other[0] > mVec[0])
995 if (other[1] > mVec[1])
997 if (other[2] > mVec[2])
1004 return Coord(mVec[0] + dx, mVec[1] + dy, mVec[2] + dz);
1013 return (a[0] < b[0] || a[1] < b[1] || a[2] < b[2]);
1018 template<
typename Vec3T>
1023 template<
int Log2N = 3 + 4 + 5>
1024 __hostdev__ uint32_t
hash()
const {
return ((1 << Log2N) - 1) & (mVec[0] * 73856093 ^ mVec[1] * 19349663 ^ mVec[2] * 83492791); }
1029 (uint8_t(
bool(mVec[1] & (1u << 31))) << 1) |
1030 (uint8_t(
bool(mVec[2] & (1u << 31))) << 2); }
1042 template<
typename T>
1048 static const int SIZE = 3;
1059 template<
typename T2>
1061 : mVec{T(v[0]), T(v[1]), T(v[2])}
1065 : mVec{T(ijk[0]), T(ijk[1]), T(ijk[2])}
1070 template<
typename Vec3T>
1080 template<
typename Vec3T>
1081 __hostdev__ T
dot(
const Vec3T& v)
const {
return mVec[0] * v[0] + mVec[1] * v[1] + mVec[2] * v[2]; }
1082 template<
typename Vec3T>
1085 return Vec3(mVec[1] * v[2] - mVec[2] * v[1],
1086 mVec[2] * v[0] - mVec[0] * v[2],
1087 mVec[0] * v[1] - mVec[1] * v[0]);
1091 return mVec[0] * mVec[0] + mVec[1] * mVec[1] + mVec[2] * mVec[2];
1127 if (other[0] < mVec[0])
1129 if (other[1] < mVec[1])
1131 if (other[2] < mVec[2])
1139 if (other[0] > mVec[0])
1141 if (other[1] > mVec[1])
1143 if (other[2] > mVec[2])
1150 return mVec[0] < mVec[1] ? (mVec[0] < mVec[2] ? mVec[0] : mVec[2]) : (mVec[1] < mVec[2] ? mVec[1] : mVec[2]);
1155 return mVec[0] > mVec[1] ? (mVec[0] > mVec[2] ? mVec[0] : mVec[2]) : (mVec[1] > mVec[2] ? mVec[1] : mVec[2]);
1162 template<
typename T1,
typename T2>
1165 return Vec3<T2>(scalar * vec[0], scalar * vec[1], scalar * vec[2]);
1167 template<
typename T1,
typename T2>
1170 return Vec3<T2>(scalar / vec[0], scalar / vec[1], scalar / vec[2]);
1187 template<
typename T>
1193 static const int SIZE = 4;
1204 template<
typename T2>
1206 : mVec{T(v[0]), T(v[1]), T(v[2]), T(v[3])}
1209 __hostdev__ bool operator==(
const Vec4& rhs)
const {
return mVec[0] == rhs[0] && mVec[1] == rhs[1] && mVec[2] == rhs[2] && mVec[3] == rhs[3]; }
1210 __hostdev__ bool operator!=(
const Vec4& rhs)
const {
return mVec[0] != rhs[0] || mVec[1] != rhs[1] || mVec[2] != rhs[2] || mVec[3] != rhs[3]; }
1211 template<
typename Vec4T>
1222 template<
typename Vec4T>
1223 __hostdev__ T
dot(
const Vec4T& v)
const {
return mVec[0] * v[0] + mVec[1] * v[1] + mVec[2] * v[2] + mVec[3] * v[3]; }
1226 return mVec[0] * mVec[0] + mVec[1] * mVec[1] + mVec[2] * mVec[2] + mVec[3] * mVec[3];
1265 if (other[0] < mVec[0])
1267 if (other[1] < mVec[1])
1269 if (other[2] < mVec[2])
1271 if (other[3] < mVec[3])
1279 if (other[0] > mVec[0])
1281 if (other[1] > mVec[1])
1283 if (other[2] > mVec[2])
1285 if (other[3] > mVec[3])
1291 template<
typename T1,
typename T2>
1294 return Vec4<T2>(scalar * vec[0], scalar * vec[1], scalar * vec[2], scalar * vec[3]);
1296 template<
typename T1,
typename T2>
1299 return Vec4<T2>(scalar / vec[0], scalar / vec[1], scalar / vec[2], scalar / vec[3]);
1314 template<
typename T>
1317 static const int Rank = 0;
1318 static const bool IsScalar =
true;
1319 static const bool IsVector =
false;
1320 static const int Size = 1;
1325 template<
typename T>
1328 static const int Rank = 1;
1329 static const bool IsScalar =
false;
1330 static const bool IsVector =
true;
1331 static const int Size = T::SIZE;
1338 template<typename T, int = sizeof(typename TensorTraits<T>::ElementType)>
1344 template<
typename T>
1365 template<
typename BuildT>
1408 template<
typename Vec3T>
1411 return Vec3T(fmaf(xyz[0], mat[0], fmaf(xyz[1], mat[1], xyz[2] * mat[2])),
1412 fmaf(xyz[0], mat[3], fmaf(xyz[1], mat[4], xyz[2] * mat[5])),
1413 fmaf(xyz[0], mat[6], fmaf(xyz[1], mat[7], xyz[2] * mat[8])));
1416 template<
typename Vec3T>
1419 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])),
1420 fma(static_cast<double>(xyz[0]), mat[3], fma(static_cast<double>(xyz[1]), mat[4], static_cast<double>(xyz[2]) * mat[5])),
1421 fma(static_cast<double>(xyz[0]), mat[6], fma(static_cast<double>(xyz[1]), mat[7], static_cast<double>(xyz[2]) * mat[8])));
1424 template<
typename Vec3T>
1427 return Vec3T(fmaf(xyz[0], mat[0], fmaf(xyz[1], mat[1], fmaf(xyz[2], mat[2], vec[0]))),
1428 fmaf(xyz[0], mat[3], fmaf(xyz[1], mat[4], fmaf(xyz[2], mat[5], vec[1]))),
1429 fmaf(xyz[0], mat[6], fmaf(xyz[1], mat[7], fmaf(xyz[2], mat[8], vec[2]))));
1432 template<
typename Vec3T>
1435 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]))),
1436 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]))),
1437 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]))));
1442 template<
typename Vec3T>
1445 return Vec3T(fmaf(xyz[0], mat[0], fmaf(xyz[1], mat[3], xyz[2] * mat[6])),
1446 fmaf(xyz[0], mat[1], fmaf(xyz[1], mat[4], xyz[2] * mat[7])),
1447 fmaf(xyz[0], mat[2], fmaf(xyz[1], mat[5], xyz[2] * mat[8])));
1450 template<
typename Vec3T>
1453 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])),
1454 fma(static_cast<double>(xyz[0]), mat[1], fma(static_cast<double>(xyz[1]), mat[4], static_cast<double>(xyz[2]) * mat[7])),
1455 fma(static_cast<double>(xyz[0]), mat[2], fma(static_cast<double>(xyz[1]), mat[5], static_cast<double>(xyz[2]) * mat[8])));
1458 template<
typename Vec3T>
1461 return Vec3T(fmaf(xyz[0], mat[0], fmaf(xyz[1], mat[3], fmaf(xyz[2], mat[6], vec[0]))),
1462 fmaf(xyz[0], mat[1], fmaf(xyz[1], mat[4], fmaf(xyz[2], mat[7], vec[1]))),
1463 fmaf(xyz[0], mat[2], fmaf(xyz[1], mat[5], fmaf(xyz[2], mat[8], vec[2]))));
1466 template<
typename Vec3T>
1469 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]))),
1470 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]))),
1471 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]))));
1477 template<
typename Vec3T>
1498 mCoord[0].minComponent(xyz);
1499 mCoord[1].maxComponent(xyz);
1508 if (xyz[0] < mCoord[0][0] || xyz[1] < mCoord[0][1] || xyz[2] < mCoord[0][2])
1510 if (xyz[0] > mCoord[1][0] || xyz[1] > mCoord[1][1] || xyz[2] > mCoord[1][2])
1530 template<
typename Vec3T>
1537 using BaseT::mCoord;
1554 mCoord[0][1] >= mCoord[1][1] ||
1555 mCoord[0][2] >= mCoord[1][2]; }
1559 return p[0] > mCoord[0][0] && p[1] > mCoord[0][1] && p[2] > mCoord[0][2] &&
1560 p[0] < mCoord[1][0] && p[1] < mCoord[1][1] && p[2] < mCoord[1][2];
1568 template<
typename CoordT>
1573 using BaseT::mCoord;
1588 if (mPos[2] < mBBox[1][2]) {
1590 }
else if (mPos[1] < mBBox[1][1]) {
1591 mPos[2] = mBBox[0][2];
1593 }
else if (mPos[0] <= mBBox[1][0]) {
1594 mPos[2] = mBBox[0][2];
1595 mPos[1] = mBBox[0][1];
1619 template<
typename SplitT>
1621 :
BaseT(other.mCoord[0], other.mCoord[1])
1624 const int n =
MaxIndex(this->dim());
1625 mCoord[1][n] = (mCoord[0][n] + mCoord[1][n]) >> 1;
1626 other.mCoord[0][n] = mCoord[1][n] + 1;
1629 mCoord[0][1] < mCoord[1][1] &&
1630 mCoord[0][2] < mCoord[1][2]; }
1633 mCoord[0][1] > mCoord[1][1] ||
1634 mCoord[0][2] > mCoord[1][2]; }
1636 __hostdev__ uint64_t
volume()
const {
auto d = this->dim();
return uint64_t(d[0])*uint64_t(d[1])*uint64_t(d[2]); }
1640 return !(CoordT::lessThan(b.min(), this->
min()) || CoordT::lessThan(this->
max(), b.max()));
1644 template<
typename RealT>
1649 Vec3<RealT>(RealT(mCoord[1][0] + 1), RealT(mCoord[1][1] + 1), RealT(mCoord[1][2] + 1)));
1654 return BBox(mCoord[0].offsetBy(-padding), mCoord[1].offsetBy(padding));
1670 #if defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS) 1671 unsigned long index;
1672 _BitScanForward(&index, v);
1673 return static_cast<uint32_t
>(index);
1674 #elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS) 1675 return static_cast<uint32_t
>(__builtin_ctzl(v));
1677 static const unsigned char DeBruijn[32] = {
1678 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};
1680 #if defined(_MSC_VER) && !defined(__NVCC__) 1681 #pragma warning(push) 1682 #pragma warning(disable : 4146) 1684 return DeBruijn[uint32_t((v & -v) * 0x077CB531U) >> 27];
1685 #if defined(_MSC_VER) && !defined(__NVCC__) 1686 #pragma warning(pop) 1699 #if defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS) 1700 unsigned long index;
1701 _BitScanReverse(&index, v);
1702 return static_cast<uint32_t
>(index);
1703 #elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS) 1704 return sizeof(
unsigned long) * 8 - 1 - __builtin_clzl(v);
1707 static const unsigned char DeBruijn[32] = {
1708 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};
1714 return DeBruijn[uint32_t(v * 0x07C4ACDDU) >> 27];
1725 #if defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS) 1726 unsigned long index;
1727 _BitScanForward64(&index, v);
1728 return static_cast<uint32_t
>(index);
1729 #elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS) 1730 return static_cast<uint32_t
>(__builtin_ctzll(v));
1732 static const unsigned char DeBruijn[64] = {
1733 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
1734 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
1735 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
1736 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12,
1739 #if defined(_MSC_VER) && !defined(__NVCC__) 1740 #pragma warning(push) 1741 #pragma warning(disable : 4146) 1743 return DeBruijn[uint64_t((v & -v) * UINT64_C(0x022FDD63CC95386D)) >> 58];
1744 #if defined(_MSC_VER) && !defined(__NVCC__) 1745 #pragma warning(pop) 1758 #if defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS) 1759 unsigned long index;
1760 _BitScanReverse64(&index, v);
1761 return static_cast<uint32_t
>(index);
1762 #elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS) 1763 return sizeof(
unsigned long) * 8 - 1 - __builtin_clzll(v);
1765 const uint32_t* p =
reinterpret_cast<const uint32_t*
>(&v);
1776 #if defined(_MSC_VER) && defined(_M_X64) 1778 #elif (defined(__GNUC__) || defined(__clang__)) 1779 v = __builtin_popcountll(v);
1782 v = v - ((v >> 1) & uint64_t(0x5555555555555555));
1783 v = (v & uint64_t(0x3333333333333333)) + ((v >> 2) & uint64_t(0x3333333333333333));
1784 v = (((v + (v >> 4)) & uint64_t(0xF0F0F0F0F0F0F0F)) * uint64_t(0x101010101010101)) >> 56;
1786 return static_cast<uint32_t
>(v);
1793 template<u
int32_t LOG2DIM>
1796 static constexpr uint32_t SIZE = 1U << (3 * LOG2DIM);
1797 static constexpr uint32_t WORD_COUNT = SIZE >> 6;
1798 uint64_t mWords[WORD_COUNT];
1812 uint32_t sum = 0, n = WORD_COUNT;
1813 for (
const uint64_t* w = mWords; n--; ++w)
1836 mPos = mParent->findNextOn(mPos + 1);
1842 const Mask* mParent;
1848 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1853 const uint64_t v = on ? ~uint64_t(0) : uint64_t(0);
1854 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1861 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1862 mWords[i] = other.mWords[i];
1866 template<
typename WordT>
1870 return reinterpret_cast<const WordT*
>(mWords)[n];
1874 template<
typename MaskT>
1877 static_assert(
sizeof(
Mask) ==
sizeof(MaskT),
"Mismatching sizeof");
1878 static_assert(WORD_COUNT == MaskT::WORD_COUNT,
"Mismatching word count");
1879 static_assert(LOG2DIM == MaskT::LOG2DIM,
"Mismatching LOG2DIM");
1880 auto *src =
reinterpret_cast<const uint64_t*
>(&other);
1881 uint64_t *dst = mWords;
1882 for (uint32_t i = 0; i < WORD_COUNT; ++i) {
1890 for (uint32_t i = 0; i < WORD_COUNT; ++i) {
1891 if (mWords[i] != other.mWords[i])
return false;
1901 __hostdev__ bool isOn(uint32_t n)
const {
return 0 != (mWords[n >> 6] & (uint64_t(1) << (n & 63))); }
1905 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1906 if (mWords[i] != ~uint64_t(0))
1913 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1914 if (mWords[i] != uint64_t(0))
1925 #if 1 // switch between branchless 1926 auto &word = mWords[n >> 6];
1928 word &= ~(uint64_t(1) << n);
1929 word |= uint64_t(On) << n;
1931 On ? this->setOn(n) : this->setOff(n);
1938 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1939 mWords[i] = ~uint64_t(0);
1945 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1946 mWords[i] = uint64_t(0);
1952 const uint64_t v = on ? ~uint64_t(0) : uint64_t(0);
1953 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1959 uint32_t n = WORD_COUNT;
1960 for (
auto* w = mWords; n--; ++w)
1971 const uint64_t* w = mWords;
1972 for (; n < WORD_COUNT && !*w; ++w, ++n)
1974 return n == WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(*w);
1978 __hostdev__ uint32_t findNextOn(uint32_t start)
const 1980 uint32_t n = start >> 6;
1981 if (n >= WORD_COUNT)
1983 uint32_t m = start & 63;
1984 uint64_t b = mWords[n];
1985 if (b & (uint64_t(1) << m))
1987 b &= ~uint64_t(0) << m;
1988 while (!b && ++n < WORD_COUNT)
2009 template<
typename Mat4T>
2010 __hostdev__ void set(
const Mat4T& mat,
const Mat4T& invMat,
double taper);
2012 template<
typename Vec3T>
2014 template<
typename Vec3T>
2017 template<
typename Vec3T>
2019 template<
typename Vec3T>
2022 template<
typename Vec3T>
2025 return matMult(mInvMatD, Vec3T(xyz[0] - mVecD[0], xyz[1] - mVecD[1], xyz[2] - mVecD[2]));
2027 template<
typename Vec3T>
2030 return matMult(mInvMatF, Vec3T(xyz[0] - mVecF[0], xyz[1] - mVecF[1], xyz[2] - mVecF[2]));
2033 template<
typename Vec3T>
2035 template<
typename Vec3T>
2038 template<
typename Vec3T>
2040 template<
typename Vec3T>
2044 template<
typename Mat4T>
2047 float * mf = mMatF, *vf = mVecF;
2048 float* mif = mInvMatF;
2049 double *md = mMatD, *vd = mVecD;
2050 double* mid = mInvMatD;
2051 mTaperF =
static_cast<float>(taper);
2053 for (
int i = 0; i < 3; ++i) {
2055 *vf++ =
static_cast<float>(mat[3][i]);
2056 for (
int j = 0; j < 3; ++j) {
2058 *mid++ = invMat[j][i];
2059 *mf++ =
static_cast<float>(mat[j][i]);
2060 *mif++ =
static_cast<float>(invMat[j][i]);
2069 static const int MaxNameSize = 256;
2076 char mName[MaxNameSize];
2086 template <
typename T>
2095 template<
typename Gr
idOrTreeOrRootT,
int LEVEL>
2099 template<
typename Gr
idOrTreeOrRootT>
2102 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2103 using Type =
typename GridOrTreeOrRootT::LeafNodeType;
2104 using type =
typename GridOrTreeOrRootT::LeafNodeType;
2106 template<
typename Gr
idOrTreeOrRootT>
2109 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2110 using Type =
const typename GridOrTreeOrRootT::LeafNodeType;
2111 using type =
const typename GridOrTreeOrRootT::LeafNodeType;
2114 template<
typename Gr
idOrTreeOrRootT>
2117 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2118 using Type =
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2119 using type =
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2121 template<
typename Gr
idOrTreeOrRootT>
2124 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2125 using Type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2126 using type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2128 template<
typename Gr
idOrTreeOrRootT>
2131 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2132 using Type =
typename GridOrTreeOrRootT::RootType::ChildNodeType;
2133 using type =
typename GridOrTreeOrRootT::RootType::ChildNodeType;
2135 template<
typename Gr
idOrTreeOrRootT>
2138 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2139 using Type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType;
2140 using type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType;
2142 template<
typename Gr
idOrTreeOrRootT>
2145 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2146 using Type =
typename GridOrTreeOrRootT::RootType;
2147 using type =
typename GridOrTreeOrRootT::RootType;
2150 template<
typename Gr
idOrTreeOrRootT>
2153 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2154 using Type =
const typename GridOrTreeOrRootT::RootType;
2155 using type =
const typename GridOrTreeOrRootT::RootType;
2186 static const int MaxNameSize = 256;
2194 char mGridName[MaxNameSize];
2256 template<
typename Vec3T>
2258 template<
typename Vec3T>
2260 template<
typename Vec3T>
2262 template<
typename Vec3T>
2264 template<
typename Vec3T>
2267 template<
typename Vec3T>
2269 template<
typename Vec3T>
2271 template<
typename Vec3T>
2273 template<
typename Vec3T>
2275 template<
typename Vec3T>
2290 return PtrAdd<GridBlindMetaData>(
this, mBlindMetadataOffset) + n;
2296 template <
typename BuildT,
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1>
2299 template <
typename BuildT>
2306 template<
typename TreeT>
2322 Grid& operator=(
const Grid&) =
delete;
2344 __hostdev__ const TreeT&
tree()
const {
return *
reinterpret_cast<const TreeT*
>(this->treePtr()); }
2359 template<
typename Vec3T>
2363 template<
typename Vec3T>
2368 template<
typename Vec3T>
2373 template<
typename Vec3T>
2378 template<
typename Vec3T>
2382 template<
typename Vec3T>
2386 template<
typename Vec3T>
2391 template<
typename Vec3T>
2396 template<
typename Vec3T>
2401 template<
typename Vec3T>
2436 template <
typename NodeT>
2441 template <
int LEVEL>
2447 if (this->hasLongGridName()) {
2448 const auto &metaData = this->blindMetaData(DataType::mBlindMetadataCount-1);
2450 return metaData.template getBlindData<const char>();
2452 return DataType::mGridName;
2475 if (DataType::mBlindMetadataCount == 0) {
2479 return this->blindMetaData(n).template getBlindData<void>();
2488 template<
typename TreeT>
2491 for (uint32_t i = 0, n = this->blindDataCount(); i < n; ++i)
2492 if (this->blindMetaData(i).mSemantic == semantic)
2499 template<
int ROOT_LEVEL = 3>
2502 static_assert(
ROOT_LEVEL == 3,
"Root level is assumed to be three");
2503 uint64_t mNodeOffset[4];
2504 uint32_t mNodeCount[3];
2505 uint32_t mTileCount[3];
2508 template <
typename RootT>
2510 template <
typename RootT>
2512 template <
typename RootT>
2515 template <
typename NodeT>
2518 mNodeOffset[NodeT::LEVEL] = node ?
PtrDiff(node,
this) : 0;
2525 template<
typename Gr
idT>
2528 using Type =
typename GridT::TreeType;
2529 using type =
typename GridT::TreeType;
2531 template<
typename Gr
idT>
2534 using Type =
const typename GridT::TreeType;
2535 using type =
const typename GridT::TreeType;
2541 template<
typename RootT>
2544 static_assert(RootT::LEVEL == 3,
"Tree depth is not supported");
2545 static_assert(RootT::ChildNodeType::LOG2DIM == 5,
"Tree configuration is not supported");
2546 static_assert(RootT::ChildNodeType::ChildNodeType::LOG2DIM == 4,
"Tree configuration is not supported");
2547 static_assert(RootT::LeafNodeType::LOG2DIM == 3,
"Tree configuration is not supported");
2559 using Node2 =
typename RootT::ChildNodeType;
2560 using Node1 =
typename Node2::ChildNodeType;
2566 Tree& operator=(
const Tree&) =
delete;
2612 return DataType::mTileCount[n];
2615 template<
typename NodeT>
2618 static_assert(NodeT::LEVEL < 3,
"Invalid NodeT");
2619 return DataType::mNodeCount[NodeT::LEVEL];
2625 return DataType::mNodeCount[level];
2631 template <
typename NodeT>
2634 const uint64_t offset = DataType::mNodeOffset[NodeT::LEVEL];
2635 return offset>0 ? PtrAdd<NodeT>(
this, offset) :
nullptr;
2641 template <
typename NodeT>
2644 const uint64_t offset = DataType::mNodeOffset[NodeT::LEVEL];
2645 return offset>0 ? PtrAdd<NodeT>(
this, offset) :
nullptr;
2651 template <
int LEVEL>
2655 return this->
template getFirstNode<typename NodeTrait<RootT,LEVEL>::type>();
2661 template <
int LEVEL>
2665 return this->
template getFirstNode<typename NodeTrait<RootT,LEVEL>::type>();
2673 template<
typename RootT>
2676 min = this->root().minimum();
2677 max = this->root().maximum();
2685 template<
typename ChildT>
2692 static constexpr
bool FIXED_SIZE =
false;
2695 #ifdef USE_SINGLE_ROOT_KEY 2697 template <
typename CoordType>
2700 static_assert(
sizeof(
CoordT) ==
sizeof(CoordType),
"Mismatching sizeof");
2701 static_assert(32 - ChildT::TOTAL <= 21,
"Cannot use 64 bit root keys");
2702 return (
KeyT(uint32_t(ijk[2]) >> ChildT::TOTAL)) |
2703 (
KeyT(uint32_t(ijk[1]) >> ChildT::TOTAL) << 21) |
2704 (
KeyT(uint32_t(ijk[0]) >> ChildT::TOTAL) << 42);
2708 static constexpr uint64_t MASK = (1u << 21) - 1;
2709 return CoordT(((key >> 42) & MASK) << ChildT::TOTAL,
2710 ((key >> 21) & MASK) << ChildT::TOTAL,
2711 (key & MASK) << ChildT::TOTAL);
2727 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
Tile 2729 template <
typename CoordType>
2732 key = CoordToKey(k);
2735 template <
typename CoordType,
typename ValueType>
2738 key = CoordToKey(k);
2757 return reinterpret_cast<const Tile*
>(
this + 1) + n;
2762 return reinterpret_cast<Tile*
>(
this + 1) + n;
2771 return PtrAdd<ChildT>(
this, tile->
child);
2776 return PtrAdd<ChildT>(
this, tile->
child);
2797 template<
typename ChildT>
2813 static constexpr
bool FIXED_SIZE = DataType::FIXED_SIZE;
2815 static constexpr uint32_t LEVEL = 1 + ChildT::LEVEL;
2865 if (
const Tile* tile = this->findTile(ijk)) {
2866 return tile->isChild() ? this->getChild(tile)->getValue(ijk) : tile->value;
2868 return DataType::mBackground;
2873 if (
const Tile* tile = this->findTile(ijk)) {
2874 return tile->isChild() ? this->getChild(tile)->isActive(ijk) : tile->state;
2884 if (
const Tile* tile = this->findTile(ijk)) {
2885 if (tile->isChild()) {
2886 const auto *
child = this->getChild(tile);
2887 return child->probeValue(ijk, v);
2892 v = DataType::mBackground;
2898 const Tile* tile = this->findTile(ijk);
2899 if (tile && tile->isChild()) {
2900 const auto *
child = this->getChild(tile);
2901 return child->probeLeaf(ijk);
2910 template<
typename,
int,
int,
int>
2922 const Tile* tiles =
reinterpret_cast<const Tile*
>(
this + 1);
2923 const auto key = DataType::CoordToKey(ijk);
2924 #if 1 // switch between linear and binary seach 2925 for (uint32_t i = 0; i < DataType::mTableSize; ++i) {
2926 if (tiles[i].key == key)
return &tiles[i];
2928 #else// do not enable binary search if tiles are not guaranteed to be sorted!!!!!! 2930 int32_t low = 0, high = DataType::mTableSize;
2931 while (low != high) {
2932 int mid = low + ((high - low) >> 1);
2933 const Tile* tile = &tiles[mid];
2934 if (tile->key == key) {
2936 }
else if (tile->key < key) {
2947 template<
typename AccT>
2948 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ijk,
const AccT& acc)
const 2950 using NodeInfoT =
typename AccT::NodeInfo;
2951 if (
const Tile* tile = this->findTile(ijk)) {
2952 if (tile->isChild()) {
2953 const auto *
child = this->getChild(tile);
2954 acc.insert(ijk,
child);
2955 return child->getNodeInfoAndCache(ijk, acc);
2957 return NodeInfoT{LEVEL, ChildT::dim(), tile->value, tile->value, tile->value,
2958 0, tile->origin(), tile->origin() +
CoordType(ChildT::DIM)};
2960 return NodeInfoT{LEVEL, ChildT::dim(), this->minimum(), this->maximum(),
2961 this->average(), this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
2965 template<
typename AccT>
2968 if (
const Tile* tile = this->findTile(ijk)) {
2969 if (tile->isChild()) {
2970 const auto *
child = this->getChild(tile);
2971 acc.insert(ijk,
child);
2972 return child->getValueAndCache(ijk, acc);
2976 return DataType::mBackground;
2979 template<
typename AccT>
2982 const Tile* tile = this->findTile(ijk);
2983 if (tile && tile->isChild()) {
2984 const auto *
child = this->getChild(tile);
2985 acc.insert(ijk,
child);
2986 return child->isActiveAndCache(ijk, acc);
2991 template<
typename AccT>
2994 if (
const Tile* tile = this->findTile(ijk)) {
2995 if (tile->isChild()) {
2996 const auto *
child = this->getChild(tile);
2997 acc.insert(ijk,
child);
2998 return child->probeValueAndCache(ijk, v, acc);
3003 v = DataType::mBackground;
3007 template<
typename AccT>
3010 const Tile* tile = this->findTile(ijk);
3011 if (tile && tile->isChild()) {
3012 const auto *
child = this->getChild(tile);
3013 acc.insert(ijk,
child);
3014 return child->probeLeafAndCache(ijk, acc);
3019 template<
typename RayT,
typename AccT>
3020 __hostdev__ uint32_t getDimAndCache(
const CoordType& ijk,
const RayT& ray,
const AccT& acc)
const 3022 if (
const Tile* tile = this->findTile(ijk)) {
3023 if (tile->isChild()) {
3024 const auto *
child = this->getChild(tile);
3025 acc.insert(ijk,
child);
3026 return child->getDimAndCache(ijk, ray, acc);
3028 return 1 << ChildT::TOTAL;
3030 return ChildNodeType::dim();
3041 template<
typename ChildT, u
int32_t LOG2DIM>
3048 using MaskT =
typename ChildT::template MaskType<LOG2DIM>;
3049 static constexpr
bool FIXED_SIZE =
true;
3058 Tile& operator=(
const Tile&) =
delete;
3071 alignas(32) Tile mTable[1u << (3 * LOG2DIM)];
3076 mTable[n].child =
PtrDiff(ptr,
this);
3079 template <
typename ValueT>
3083 mTable[n].value = v;
3090 return PtrAdd<ChildT>(
this, mTable[n].child);
3095 return PtrAdd<ChildT>(
this, mTable[n].child);
3098 template <
typename T>
3119 template<
typename ChildT, u
int32_t Log2Dim = ChildT::LOG2DIM + 1>
3130 static constexpr
bool FIXED_SIZE = DataType::FIXED_SIZE;
3131 template<u
int32_t LOG2>
3134 static constexpr uint32_t LOG2DIM = Log2Dim;
3135 static constexpr uint32_t TOTAL = LOG2DIM + ChildT::TOTAL;
3136 static constexpr uint32_t DIM = 1u << TOTAL;
3137 static constexpr uint32_t SIZE = 1u << (3 * LOG2DIM);
3138 static constexpr uint32_t MASK = (1u << TOTAL) - 1u;
3139 static constexpr uint32_t LEVEL = 1 + ChildT::LEVEL;
3140 static constexpr uint64_t NUM_VALUES = uint64_t(1) << (3 * TOTAL);
3188 const uint32_t n = CoordToOffset(ijk);
3189 return DataType::mChildMask.isOn(n) ? this->getChild(n)->getValue(ijk) : DataType::mTable[n].value;
3194 const uint32_t n = CoordToOffset(ijk);
3195 return DataType::mChildMask.isOn(n) ? this->getChild(n)->isActive(ijk) : DataType::mValueMask.isOn(n);
3200 const uint32_t n = CoordToOffset(ijk);
3201 if (DataType::mChildMask.isOn(n))
3202 return this->getChild(n)->probeValue(ijk, v);
3203 v = DataType::mTable[n].value;
3204 return DataType::mValueMask.isOn(n);
3209 const uint32_t n = CoordToOffset(ijk);
3210 if (DataType::mChildMask.isOn(n))
3211 return this->getChild(n)->probeLeaf(ijk);
3219 return (((ijk[0] & MASK) >> ChildT::TOTAL) << (2 * LOG2DIM)) +
3220 (((ijk[1] & MASK) >> ChildT::TOTAL) << (LOG2DIM)) +
3221 ((ijk[2] & MASK) >> ChildT::TOTAL);
3223 return (((ijk[0] & MASK) >> ChildT::TOTAL) << (2 * LOG2DIM)) |
3224 (((ijk[1] & MASK) >> ChildT::TOTAL) << (LOG2DIM)) |
3225 ((ijk[2] & MASK) >> ChildT::TOTAL);
3233 const uint32_t m = n & ((1 << 2 * LOG2DIM) - 1);
3234 return Coord(n >> 2 * LOG2DIM, m >> LOG2DIM, m & ((1 << LOG2DIM) - 1));
3240 ijk <<= ChildT::TOTAL;
3241 ijk += this->origin();
3247 this->localToGlobalCoord(ijk);
3254 return DataType::mFlags & uint32_t(2);
3261 template<
typename,
int,
int,
int>
3266 template<
typename, u
int32_t>
3270 template<
typename AccT>
3273 const uint32_t n = CoordToOffset(ijk);
3274 if (!DataType::mChildMask.isOn(n))
3275 return DataType::mTable[n].value;
3276 const ChildT*
child = this->getChild(n);
3277 acc.insert(ijk, child);
3278 return child->getValueAndCache(ijk, acc);
3281 template<
typename AccT>
3282 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ijk,
const AccT& acc)
const 3284 using NodeInfoT =
typename AccT::NodeInfo;
3285 const uint32_t n = CoordToOffset(ijk);
3286 if (!DataType::mChildMask.isOn(n)) {
3287 return NodeInfoT{LEVEL, this->dim(), this->minimum(), this->maximum(), this->average(),
3288 this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
3290 const ChildT* child = this->getChild(n);
3291 acc.insert(ijk, child);
3292 return child->getNodeInfoAndCache(ijk, acc);
3295 template<
typename AccT>
3298 const uint32_t n = CoordToOffset(ijk);
3299 if (!DataType::mChildMask.isOn(n))
3300 return DataType::mValueMask.isOn(n);
3301 const ChildT* child = this->getChild(n);
3302 acc.insert(ijk, child);
3303 return child->isActiveAndCache(ijk, acc);
3306 template<
typename AccT>
3309 const uint32_t n = CoordToOffset(ijk);
3310 if (!DataType::mChildMask.isOn(n)) {
3311 v = DataType::mTable[n].value;
3312 return DataType::mValueMask.isOn(n);
3314 const ChildT* child = this->getChild(n);
3315 acc.insert(ijk, child);
3316 return child->probeValueAndCache(ijk, v, acc);
3319 template<
typename AccT>
3322 const uint32_t n = CoordToOffset(ijk);
3323 if (!DataType::mChildMask.isOn(n))
3325 const ChildT* child = this->getChild(n);
3326 acc.insert(ijk, child);
3327 return child->probeLeafAndCache(ijk, acc);
3330 template<
typename RayT,
typename AccT>
3331 __hostdev__ uint32_t getDimAndCache(
const CoordType& ijk,
const RayT& ray,
const AccT& acc)
const 3333 if (DataType::mFlags & uint32_t(1))
3337 const uint32_t n = CoordToOffset(ijk);
3338 if (DataType::mChildMask.isOn(n)) {
3339 const ChildT* child = this->getChild(n);
3340 acc.insert(ijk, child);
3341 return child->getDimAndCache(ijk, ray, acc);
3343 return ChildNodeType::dim();
3353 template<
typename ValueT,
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3356 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3357 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3362 static constexpr
bool FIXED_SIZE =
true;
3365 uint8_t mBBoxDif[3];
3380 mValueMask.setOn(offset);
3381 mValues[offset] =
value;
3394 template <
typename T>
3405 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3408 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3409 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3414 uint8_t mBBoxDif[3];
3425 mQuantum = (max -
min)/
float((1 << bitWidth)-1);
3453 template <
typename T>
3460 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3461 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp4, CoordT, MaskT, LOG2DIM>
3467 static constexpr
bool FIXED_SIZE =
true;
3468 alignas(32) uint8_t mCode[1u << (3 * LOG2DIM - 1)];
3474 const uint8_t c = mCode[i>>1];
3475 return ( (i&1) ? c >> 4 : c & uint8_t(15) )*BaseT::mQuantum + BaseT::mMinimum;
3477 return ((mCode[i>>1] >> ((i&1)<<2)) & uint8_t(15))*BaseT::mQuantum + BaseT::mMinimum;
3488 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3489 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp8, CoordT, MaskT, LOG2DIM>
3495 static constexpr
bool FIXED_SIZE =
true;
3496 alignas(32) uint8_t mCode[1u << 3 * LOG2DIM];
3501 return mCode[i]*BaseT::mQuantum + BaseT::mMinimum;
3510 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3511 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp16, CoordT, MaskT, LOG2DIM>
3517 static constexpr
bool FIXED_SIZE =
true;
3518 alignas(32) uint16_t mCode[1u << 3 * LOG2DIM];
3523 return mCode[i]*BaseT::mQuantum + BaseT::mMinimum;
3533 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3534 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
FpN, CoordT, MaskT, LOG2DIM>
3539 static constexpr
bool FIXED_SIZE =
false;
3546 #ifdef NANOVDB_FPN_BRANCHLESS// faster 3547 const int b = BaseT::mFlags >> 5;
3549 uint16_t code =
reinterpret_cast<const uint16_t*
>(
this + 1)[i >> (4 - b)];
3550 const static uint8_t shift[5] = {15, 7, 3, 1, 0};
3551 const static uint16_t mask[5] = {1, 3, 15, 255, 65535};
3552 code >>= (i & shift[b]) << b;
3555 uint32_t code =
reinterpret_cast<const uint32_t*
>(
this + 1)[i >> (5 - b)];
3557 code >>= (i & ((32 >> b) - 1)) << b;
3558 code &= (1 << (1 << b)) - 1;
3560 #else// use branched version (slow) 3562 auto *values =
reinterpret_cast<const uint8_t*
>(
this+1);
3563 switch (BaseT::mFlags >> 5) {
3565 code = float((values[i>>3] >> (i&7) ) & uint8_t(1));
3568 code = float((values[i>>2] >> ((i&3)<<1)) & uint8_t(3));
3571 code = float((values[i>>1] >> ((i&1)<<2)) & uint8_t(15));
3574 code = float(values[i]);
3577 code = float(reinterpret_cast<const uint16_t*>(values)[i]);
3580 return float(code) * BaseT::mQuantum + BaseT::mMinimum;
3591 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3592 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<bool, CoordT, MaskT, LOG2DIM>
3594 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3595 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3600 static constexpr
bool FIXED_SIZE =
true;
3603 uint8_t mBBoxDif[3];
3616 mValueMask.setOn(offset);
3617 mValues.set(offset, v);
3625 template <
typename T>
3636 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3639 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3640 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3645 static constexpr
bool FIXED_SIZE =
true;
3648 uint8_t mBBoxDif[3];
3660 mValueMask.setOn(offset);
3668 template <
typename T>
3679 template<
typename BuildT,
3680 typename CoordT =
Coord,
3681 template<u
int32_t>
class MaskT =
Mask,
3682 uint32_t Log2Dim = 3>
3696 static constexpr
bool FIXED_SIZE = DataType::FIXED_SIZE;
3697 template<u
int32_t LOG2>
3701 static constexpr uint32_t LOG2DIM = Log2Dim;
3702 static constexpr uint32_t TOTAL = LOG2DIM;
3703 static constexpr uint32_t DIM = 1u << TOTAL;
3704 static constexpr uint32_t SIZE = 1u << 3 * LOG2DIM;
3705 static constexpr uint32_t MASK = (1u << LOG2DIM) - 1u;
3706 static constexpr uint32_t LEVEL = 0;
3707 static constexpr uint64_t NUM_VALUES = uint64_t(1) << (3 * TOTAL);
3739 const uint32_t m = n & ((1 << 2 * LOG2DIM) - 1);
3740 return CoordT(n >> 2 * LOG2DIM, m >> LOG2DIM, m & MASK);
3748 return OffsetToLocalCoord(n) + this->origin();
3757 BBox<CoordT> bbox(DataType::mBBoxMin, DataType::mBBoxMin);
3758 if ( this->isActive() ) {
3759 bbox.max()[0] += DataType::mBBoxDif[0];
3760 bbox.max()[1] += DataType::mBBoxDif[1];
3761 bbox.max()[2] += DataType::mBBoxDif[2];
3804 NANOVDB_ASSERT(
bool(DataType::mFlags & uint8_t(2)) != DataType::mValueMask.isOff() );
3805 return DataType::mFlags & uint8_t(2);
3812 const uint32_t n = CoordToOffset(ijk);
3813 v = DataType::getValue(n);
3814 return DataType::mValueMask.isOn(n);
3823 return ((ijk[0] & MASK) << (2 * LOG2DIM)) + ((ijk[1] & MASK) << LOG2DIM) + (ijk[2] & MASK);
3825 return ((ijk[0] & MASK) << (2 * LOG2DIM)) | ((ijk[1] & MASK) << LOG2DIM) | (ijk[2] & MASK);
3842 template<
typename,
int,
int,
int>
3847 template<
typename, u
int32_t>
3851 template<
typename AccT>
3852 __hostdev__ ValueType getValueAndCache(
const CoordT& ijk,
const AccT&)
const {
return this->getValue(ijk); }
3855 template<
typename AccT>
3856 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ,
const AccT& )
const {
3857 using NodeInfoT =
typename AccT::NodeInfo;
3858 return NodeInfoT{LEVEL, this->dim(), this->minimum(), this->maximum(),
3859 this->average(), this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
3862 template<
typename AccT>
3863 __hostdev__ bool isActiveAndCache(
const CoordT& ijk,
const AccT&)
const {
return this->isActive(ijk); }
3865 template<
typename AccT>
3866 __hostdev__ bool probeValueAndCache(
const CoordT& ijk,
ValueType& v,
const AccT&)
const {
return this->probeValue(ijk, v); }
3868 template<
typename AccT>
3869 __hostdev__ const LeafNode* probeLeafAndCache(
const CoordT&,
const AccT&)
const {
return this; }
3871 template<
typename RayT,
typename AccT>
3872 __hostdev__ uint32_t getDimAndCache(
const CoordT&,
const RayT& ,
const AccT&)
const 3874 if (DataType::mFlags & uint8_t(1))
3877 return ChildNodeType::dim();
3882 template<
typename ValueT,
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3885 static_assert(LOG2DIM == 3,
"LeafNode::updateBBox: only supports LOGDIM = 3!");
3886 if (!this->isActive())
return;
3887 auto update = [&](uint32_t
min, uint32_t
max,
int axis) {
3889 DataType::mBBoxMin[axis] = (DataType::mBBoxMin[axis] & ~MASK) +
int(min);
3890 DataType::mBBoxDif[axis] = uint8_t(max - min);
3892 uint64_t word64 = DataType::mValueMask.template getWord<uint64_t>(0);
3893 uint32_t Xmin = word64 ? 0u : 8u;
3894 uint32_t Xmax = Xmin;
3895 for (
int i = 1; i < 8; ++i) {
3896 if (uint64_t w = DataType::mValueMask.
template getWord<uint64_t>(i)) {
3905 update(Xmin, Xmax, 0);
3907 const uint32_t *p =
reinterpret_cast<const uint32_t*
>(&word64), word32 = p[0] | p[1];
3908 const uint16_t *q =
reinterpret_cast<const uint16_t*
>(&word32), word16 = q[0] | q[1];
3909 const uint8_t *b =
reinterpret_cast<const uint8_t*
>(&word16), byte = b[0] | b[1];
3918 template<
typename BuildT>
3920 template<
typename BuildT>
3922 template<
typename BuildT>
3924 template<
typename BuildT>
3926 template<
typename BuildT>
3928 template<
typename BuildT>
3932 template<
typename BuildT,
int LEVEL>
3936 template<
typename BuildT>
3942 template<
typename BuildT>
3948 template<
typename BuildT>
3954 template<
typename BuildT>
4008 template <
typename BuildT>
4016 mutable const RootT* mRoot;
4021 static const int CacheLevels = 0;
4046 return mRoot->getValueAndCache(ijk, *
this);
4051 return mRoot->getNodeInfoAndCache(ijk, *
this);
4056 return mRoot->isActiveAndCache(ijk, *
this);
4061 return mRoot->probeValueAndCache(ijk, v, *
this);
4066 return mRoot->probeLeafAndCache(ijk, *
this);
4069 template<
typename RayT>
4072 return mRoot->getDimAndCache(ijk, ray, *
this);
4079 template<
typename, u
int32_t>
4081 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4085 template<
typename NodeT>
4090 template <
typename BuildT,
int LEVEL0>
4093 static_assert(LEVEL0 >= 0 && LEVEL0 <= 2,
"LEVEL0 should be 0, 1, or 2");
4106 mutable CoordT mKey;
4107 mutable const RootT* mRoot;
4108 mutable const NodeT* mNode;
4114 static const int CacheLevels = 1;
4135 return (ijk[0] & int32_t(~NodeT::MASK)) == mKey[0] &&
4136 (ijk[1] & int32_t(~NodeT::MASK)) == mKey[1] &&
4137 (ijk[2] & int32_t(~NodeT::MASK)) == mKey[2];
4142 if (this->isCached(ijk)) {
4143 return mNode->getValueAndCache(ijk, *
this);
4145 return mRoot->getValueAndCache(ijk, *
this);
4150 if (this->isCached(ijk)) {
4151 return mNode->getNodeInfoAndCache(ijk, *
this);
4153 return mRoot->getNodeInfoAndCache(ijk, *
this);
4158 if (this->isCached(ijk)) {
4159 return mNode->isActiveAndCache(ijk, *
this);
4161 return mRoot->isActiveAndCache(ijk, *
this);
4166 if (this->isCached(ijk)) {
4167 return mNode->probeValueAndCache(ijk, v, *
this);
4169 return mRoot->probeValueAndCache(ijk, v, *
this);
4174 if (this->isCached(ijk)) {
4175 return mNode->probeLeafAndCache(ijk, *
this);
4177 return mRoot->probeLeafAndCache(ijk, *
this);
4180 template<
typename RayT>
4183 if (this->isCached(ijk)) {
4184 return mNode->getDimAndCache(ijk, ray, *
this);
4186 return mRoot->getDimAndCache(ijk, ray, *
this);
4193 template<
typename, u
int32_t>
4195 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4201 mKey = ijk & ~NodeT::MASK;
4206 template<
typename OtherNodeT>
4211 template <
typename BuildT,
int LEVEL0,
int LEVEL1>
4214 static_assert(LEVEL0 >= 0 && LEVEL0 <= 2,
"LEVEL0 must be 0, 1, 2");
4215 static_assert(LEVEL1 >= 0 && LEVEL1 <= 2,
"LEVEL1 must be 0, 1, 2");
4216 static_assert(LEVEL0 < LEVEL1,
"Level 0 must be lower than level 1");
4228 #ifdef USE_SINGLE_ACCESSOR_KEY // 44 bytes total 4229 mutable CoordT mKey;
4230 #else // 68 bytes total 4231 mutable CoordT mKeys[2];
4233 mutable const RootT* mRoot;
4234 mutable const Node1T* mNode1;
4235 mutable const Node2T* mNode2;
4241 static const int CacheLevels = 2;
4247 #ifdef USE_SINGLE_ACCESSOR_KEY 4265 #ifdef USE_SINGLE_ACCESSOR_KEY 4266 __hostdev__ bool isCached1(CoordValueType dirty)
const 4270 if (dirty & int32_t(~Node1T::MASK)) {
4276 __hostdev__ bool isCached2(CoordValueType dirty)
const 4280 if (dirty & int32_t(~Node2T::MASK)) {
4288 return (ijk[0] ^ mKey[0]) | (ijk[1] ^ mKey[1]) | (ijk[2] ^ mKey[2]);
4293 return (ijk[0] & int32_t(~Node1T::MASK)) == mKeys[0][0] &&
4294 (ijk[1] & int32_t(~Node1T::MASK)) == mKeys[0][1] &&
4295 (ijk[2] & int32_t(~Node1T::MASK)) == mKeys[0][2];
4299 return (ijk[0] & int32_t(~Node2T::MASK)) == mKeys[1][0] &&
4300 (ijk[1] & int32_t(~Node2T::MASK)) == mKeys[1][1] &&
4301 (ijk[2] & int32_t(~Node2T::MASK)) == mKeys[1][2];
4307 #ifdef USE_SINGLE_ACCESSOR_KEY 4308 const CoordValueType dirty = this->computeDirty(ijk);
4312 if (this->isCached1(dirty)) {
4313 return mNode1->getValueAndCache(ijk, *
this);
4314 }
else if (this->isCached2(dirty)) {
4315 return mNode2->getValueAndCache(ijk, *
this);
4317 return mRoot->getValueAndCache(ijk, *
this);
4322 #ifdef USE_SINGLE_ACCESSOR_KEY 4323 const CoordValueType dirty = this->computeDirty(ijk);
4327 if (this->isCached1(dirty)) {
4328 return mNode1->getNodeInfoAndCache(ijk, *
this);
4329 }
else if (this->isCached2(dirty)) {
4330 return mNode2->getNodeInfoAndCache(ijk, *
this);
4332 return mRoot->getNodeInfoAndCache(ijk, *
this);
4337 #ifdef USE_SINGLE_ACCESSOR_KEY 4338 const CoordValueType dirty = this->computeDirty(ijk);
4342 if (this->isCached1(dirty)) {
4343 return mNode1->isActiveAndCache(ijk, *
this);
4344 }
else if (this->isCached2(dirty)) {
4345 return mNode2->isActiveAndCache(ijk, *
this);
4347 return mRoot->isActiveAndCache(ijk, *
this);
4352 #ifdef USE_SINGLE_ACCESSOR_KEY 4353 const CoordValueType dirty = this->computeDirty(ijk);
4357 if (this->isCached1(dirty)) {
4358 return mNode1->probeValueAndCache(ijk, v, *
this);
4359 }
else if (this->isCached2(dirty)) {
4360 return mNode2->probeValueAndCache(ijk, v, *
this);
4362 return mRoot->probeValueAndCache(ijk, v, *
this);
4367 #ifdef USE_SINGLE_ACCESSOR_KEY 4368 const CoordValueType dirty = this->computeDirty(ijk);
4372 if (this->isCached1(dirty)) {
4373 return mNode1->probeLeafAndCache(ijk, *
this);
4374 }
else if (this->isCached2(dirty)) {
4375 return mNode2->probeLeafAndCache(ijk, *
this);
4377 return mRoot->probeLeafAndCache(ijk, *
this);
4380 template<
typename RayT>
4383 #ifdef USE_SINGLE_ACCESSOR_KEY 4384 const CoordValueType dirty = this->computeDirty(ijk);
4388 if (this->isCached1(dirty)) {
4389 return mNode1->getDimAndCache(ijk, ray, *
this);
4390 }
else if (this->isCached2(dirty)) {
4391 return mNode2->getDimAndCache(ijk, ray, *
this);
4393 return mRoot->getDimAndCache(ijk, ray, *
this);
4400 template<
typename, u
int32_t>
4402 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4408 #ifdef USE_SINGLE_ACCESSOR_KEY 4411 mKeys[0] = ijk & ~Node1T::MASK;
4417 #ifdef USE_SINGLE_ACCESSOR_KEY 4420 mKeys[1] = ijk & ~Node2T::MASK;
4424 template <
typename OtherNodeT>
4430 template <
typename BuildT>
4445 #ifdef USE_SINGLE_ACCESSOR_KEY // 44 bytes total 4446 mutable CoordT mKey;
4447 #else // 68 bytes total 4448 mutable CoordT mKeys[3];
4450 mutable const RootT* mRoot;
4451 mutable const void* mNode[3];
4457 static const int CacheLevels = 3;
4463 #ifdef USE_SINGLE_ACCESSOR_KEY 4469 , mNode{
nullptr,
nullptr,
nullptr}
4483 template<
typename NodeT>
4488 return reinterpret_cast<const T*
>(mNode[NodeT::LEVEL]);
4491 #ifdef USE_SINGLE_ACCESSOR_KEY 4492 template<
typename NodeT>
4493 __hostdev__ bool isCached(CoordValueType dirty)
const 4495 if (!mNode[NodeT::LEVEL])
4497 if (dirty & int32_t(~NodeT::MASK)) {
4498 mNode[NodeT::LEVEL] =
nullptr;
4506 return (ijk[0] ^ mKey[0]) | (ijk[1] ^ mKey[1]) | (ijk[2] ^ mKey[2]);
4509 template<
typename NodeT>
4512 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];
4518 #ifdef USE_SINGLE_ACCESSOR_KEY 4519 const CoordValueType dirty = this->computeDirty(ijk);
4523 if (this->isCached<LeafT>(dirty)) {
4524 return ((
LeafT*)mNode[0])->getValue(ijk);
4525 }
else if (this->isCached<NodeT1>(dirty)) {
4526 return ((
NodeT1*)mNode[1])->getValueAndCache(ijk, *
this);
4527 }
else if (this->isCached<NodeT2>(dirty)) {
4528 return ((
NodeT2*)mNode[2])->getValueAndCache(ijk, *
this);
4530 return mRoot->getValueAndCache(ijk, *
this);
4535 #ifdef USE_SINGLE_ACCESSOR_KEY 4536 const CoordValueType dirty = this->computeDirty(ijk);
4540 if (this->isCached<LeafT>(dirty)) {
4541 return ((
LeafT*)mNode[0])->getNodeInfoAndCache(ijk, *
this);
4542 }
else if (this->isCached<NodeT1>(dirty)) {
4543 return ((
NodeT1*)mNode[1])->getNodeInfoAndCache(ijk, *
this);
4544 }
else if (this->isCached<NodeT2>(dirty)) {
4545 return ((
NodeT2*)mNode[2])->getNodeInfoAndCache(ijk, *
this);
4547 return mRoot->getNodeInfoAndCache(ijk, *
this);
4552 #ifdef USE_SINGLE_ACCESSOR_KEY 4553 const CoordValueType dirty = this->computeDirty(ijk);
4557 if (this->isCached<LeafT>(dirty)) {
4558 return ((
LeafT*)mNode[0])->isActive(ijk);
4559 }
else if (this->isCached<NodeT1>(dirty)) {
4560 return ((
NodeT1*)mNode[1])->isActiveAndCache(ijk, *
this);
4561 }
else if (this->isCached<NodeT2>(dirty)) {
4562 return ((
NodeT2*)mNode[2])->isActiveAndCache(ijk, *
this);
4564 return mRoot->isActiveAndCache(ijk, *
this);
4569 #ifdef USE_SINGLE_ACCESSOR_KEY 4570 const CoordValueType dirty = this->computeDirty(ijk);
4574 if (this->isCached<LeafT>(dirty)) {
4575 return ((
LeafT*)mNode[0])->probeValue(ijk, v);
4576 }
else if (this->isCached<NodeT1>(dirty)) {
4577 return ((
NodeT1*)mNode[1])->probeValueAndCache(ijk, v, *
this);
4578 }
else if (this->isCached<NodeT2>(dirty)) {
4579 return ((
NodeT2*)mNode[2])->probeValueAndCache(ijk, v, *
this);
4581 return mRoot->probeValueAndCache(ijk, v, *
this);
4586 #ifdef USE_SINGLE_ACCESSOR_KEY 4587 const CoordValueType dirty = this->computeDirty(ijk);
4591 if (this->isCached<LeafT>(dirty)) {
4592 return ((
LeafT*)mNode[0]);
4593 }
else if (this->isCached<NodeT1>(dirty)) {
4594 return ((
NodeT1*)mNode[1])->probeLeafAndCache(ijk, *
this);
4595 }
else if (this->isCached<NodeT2>(dirty)) {
4596 return ((
NodeT2*)mNode[2])->probeLeafAndCache(ijk, *
this);
4598 return mRoot->probeLeafAndCache(ijk, *
this);
4601 template<
typename RayT>
4604 #ifdef USE_SINGLE_ACCESSOR_KEY 4605 const CoordValueType dirty = this->computeDirty(ijk);
4609 if (this->isCached<LeafT>(dirty)) {
4610 return ((
LeafT*)mNode[0])->getDimAndCache(ijk, ray, *
this);
4611 }
else if (this->isCached<NodeT1>(dirty)) {
4612 return ((
NodeT1*)mNode[1])->getDimAndCache(ijk, ray, *
this);
4613 }
else if (this->isCached<NodeT2>(dirty)) {
4614 return ((
NodeT2*)mNode[2])->getDimAndCache(ijk, ray, *
this);
4616 return mRoot->getDimAndCache(ijk, ray, *
this);
4623 template<
typename, u
int32_t>
4625 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4629 template<
typename NodeT>
4632 #ifdef USE_SINGLE_ACCESSOR_KEY 4635 mKeys[NodeT::LEVEL] = ijk & ~NodeT::MASK;
4637 mNode[NodeT::LEVEL] = node;
4655 template <
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
4661 template <
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
4667 template <
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
4719 template<
typename AttT>
4730 :
AccT(grid.tree().root())
4732 , mData(reinterpret_cast<const AttT*>(grid.blindData(0)))
4745 end = begin + count;
4753 auto* leaf = this->probeLeaf(ijk);
4754 if (leaf ==
nullptr) {
4757 begin = mData + leaf->minimum();
4758 end = begin + leaf->maximum();
4759 return leaf->maximum();
4765 auto* leaf = this->probeLeaf(ijk);
4766 if (leaf ==
nullptr)
4768 const uint32_t offset = LeafNodeType::CoordToOffset(ijk);
4769 if (leaf->isActive(offset)) {
4770 auto* p = mData + leaf->minimum();
4771 begin = p + (offset == 0 ? 0 : leaf->getValue(offset - 1));
4772 end = p + leaf->getValue(offset);
4781 #endif // end of NANOVDB_NANOVDB_H_HAS_BEEN_INCLUDED typename FloatTraits< BuildT >::FloatType FloatType
Definition: NanoVDB.h:3360
bool operator==(const Vec3 &rhs) const
Definition: NanoVDB.h:1068
void setAvg(const FloatType &)
Definition: NanoVDB.h:3665
Vec3T applyInverseMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2270
typename TreeT::RootType RootType
Definition: NanoVDB.h:2311
int32_t ValueType
Definition: NanoVDB.h:863
ValueT ValueType
Definition: NanoVDB.h:4111
const BBox< Vec3R > & worldBBox() const
Computes a AABB of active values in world space.
Definition: NanoVDB.h:2405
static size_t memUsage(uint32_t bitWidth)
Definition: NanoVDB.h:3543
bool type
Definition: NanoVDB.h:392
T lengthSqr() const
Definition: NanoVDB.h:1224
const ValueT & getMin() const
Definition: NanoVDB.h:2779
bool operator==(const Coord &rhs) const
Definition: NanoVDB.h:938
static uint32_t CoordToOffset(const CoordT &ijk)
Return the linear offset corresponding to the given coordinate.
Definition: NanoVDB.h:3820
FloatType mStdDevi
Definition: NanoVDB.h:3372
bool empty() const
Definition: NanoVDB.h:1553
float type
Definition: NanoVDB.h:399
const RootT & root() const
Definition: NanoVDB.h:4473
ValueType minimum() const
Return a const reference to the minimum active value encoded in this leaf node.
Definition: NanoVDB.h:3717
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel.
Definition: NanoVDB.h:2863
ValueType maximum() const
Return a const reference to the maximum active value encoded in this leaf node.
Definition: NanoVDB.h:3720
StatsT mStdDevi
Definition: NanoVDB.h:3070
const RootT & root() const
Definition: NanoVDB.h:2578
const Vec3T & min() const
Definition: NanoVDB.h:1487
ChildT * child
Definition: GridBuilder.h:1286
Vec3(T x)
Definition: NanoVDB.h:1051
ValueType getValue(const CoordT &ijk) const
Return the voxel value at the given coordinate.
Definition: NanoVDB.h:3784
BBox(BBox &other, const SplitT &)
Definition: NanoVDB.h:1620
FloatType variance() const
Return the variance of all the active values encoded in this leaf node.
Definition: NanoVDB.h:3726
static float value()
Definition: NanoVDB.h:601
Vec3T applyJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2261
typename GridOrTreeOrRootT::RootType::ChildNodeType type
Definition: NanoVDB.h:2133
Tile * tile(uint32_t n)
Definition: NanoVDB.h:2759
void setDev(float dev)
Definition: NanoVDB.h:3451
Vec3T indexToWorldF(const Vec3T &xyz) const
index to world space transformation
Definition: NanoVDB.h:2387
const StatsT & average() const
Definition: NanoVDB.h:3103
void setRoot(const RootT *root)
Definition: NanoVDB.h:2509
Coord & operator+=(const Coord &rhs)
Definition: NanoVDB.h:963
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:3198
VDB Tree, which is a thin wrapper around a RootNode.
Definition: NanoVDB.h:2542
const MaskType< LOG2DIM > & valueMask() const
Return a const reference to the bit mask of active voxels in this internal node.
Definition: NanoVDB.h:3159
FloatType getDev() const
Definition: NanoVDB.h:3387
bool getMin() const
Definition: NanoVDB.h:3610
void setOn()
Set all bits on.
Definition: NanoVDB.h:1936
float Type
Definition: NanoVDB.h:419
float FloatType
Definition: NanoVDB.h:3411
Highest level of the data structure. Contains a tree and a world->index transform (that currently onl...
Definition: NanoVDB.h:2307
ValueType mMaximum
Definition: NanoVDB.h:4027
T lengthSqr() const
Definition: NanoVDB.h:1089
Vec3 & normalize()
Definition: NanoVDB.h:1123
DataType * data()
Definition: NanoVDB.h:2825
Vec4 & normalize()
Definition: NanoVDB.h:1261
Vec4(T x, T y, T z, T w)
Definition: NanoVDB.h:1200
void setFlagsOff()
Definition: NanoVDB.h:2205
Vec4 & operator-=(const Vec4 &v)
Definition: NanoVDB.h:1244
typename Vec3T::ValueType ValueType
Definition: NanoVDB.h:1534
bool isOff() const
Definition: NanoVDB.h:1911
const ValueType & operator[](IndexType i) const
Return a const reference to the given Coord component.
Definition: NanoVDB.h:905
void setDev(const StatsT &v)
Definition: NanoVDB.h:2787
#define NANOVDB_PATCH_VERSION_NUMBER
Definition: NanoVDB.h:106
const RootT & root() const
Definition: NanoVDB.h:4126
bool isBreadthFirst() const
Definition: NanoVDB.h:2432
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:2437
uint64_t activeVoxelCount() const
Return the total number of active voxels in this tree.
Definition: NanoVDB.h:2604
T Sign(const T &x)
Return the sign of the given value as an integer (either -1, 0 or 1).
Definition: NanoVDB.h:807
typename NanoRoot< uint32_t >::LeafNodeType LeafNodeType
Definition: NanoVDB.h:4727
const ValueType & background() const
Return the total number of active voxels in the root and all its child nodes.
Definition: NanoVDB.h:2836
Rgba8(uint8_t v)
Definition: NanoVDB.h:471
Metafunction used to determine if the first template parameter is a specialization of the class templ...
Definition: NanoVDB.h:368
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4164
uint32_t operator*() const
Definition: NanoVDB.h:1832
static uint32_t dim()
Definition: NanoVDB.h:3688
bool getDev() const
Definition: NanoVDB.h:3657
Vec3T worldToIndexDir(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition: NanoVDB.h:2374
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4320
static float value()
Definition: NanoVDB.h:585
const ValueT & getMax() const
Definition: NanoVDB.h:3102
Mask(bool on)
Definition: NanoVDB.h:1851
Vec4(const Vec4< T2 > &v)
Definition: NanoVDB.h:1205
bool isFogVolume() const
Definition: NanoVDB.h:2421
typename GridT::TreeType Type
Definition: NanoVDB.h:2528
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:3171
Coord operator+(const Coord &rhs) const
Definition: NanoVDB.h:961
static uint32_t CoordToOffset(const CoordType &ijk)
Return the linear offset corresponding to the given coordinate.
Definition: NanoVDB.h:3216
Version version() const
Definition: NanoVDB.h:2325
Vec3T indexToWorldGradF(const Vec3T &grad) const
Transforms the gradient from index space to world space.
Definition: NanoVDB.h:2402
typename ChildT::CoordType CoordType
Definition: NanoVDB.h:3129
GridClass
Classes (defined in OpenVDB) that are currently supported by NanoVDB.
Definition: NanoVDB.h:253
typename DataType::ValueT ValueType
Definition: NanoVDB.h:2806
Vec3 operator*(const Vec3 &v) const
Definition: NanoVDB.h:1095
static T scalar(const T &s)
Definition: NanoVDB.h:1322
Vec3T indexToWorldDirF(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition: NanoVDB.h:2392
uint32_t mDim
Definition: NanoVDB.h:4025
typename RootT::BuildType BuildType
Definition: NanoVDB.h:2554
const uint32_t & packed() const
Definition: NanoVDB.h:490
ValueType min() const
Return the smallest vector component.
Definition: NanoVDB.h:1148
uint32_t state
Definition: NanoVDB.h:2747
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType Type
Definition: NanoVDB.h:2125
BuildT BuildType
Definition: NanoVDB.h:3359
CoordT mBBoxMin
Definition: NanoVDB.h:3647
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:2586
Vec3 operator+(const Vec3 &v) const
Definition: NanoVDB.h:1097
bool isInside(const Vec3T &p) const
Definition: NanoVDB.h:1557
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:3168
const GridBlindMetaData * blindMetaData(uint32_t n) const
Returns a const reference to the blindMetaData at the specified linear offset.
Definition: NanoVDB.h:2287
uint8_t mFlags
Definition: NanoVDB.h:3366
static uint64_t memUsage(uint32_t tableSize)
Return the expected memory footprint in bytes with the specified number of tiles. ...
Definition: NanoVDB.h:2857
Vec3T applyInverseJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2263
Definition: NanoVDB.h:2297
LeafNodeType Node0
Definition: NanoVDB.h:2561
void setMin(const ValueT &v)
Definition: NanoVDB.h:2784
typename DataType::StatsT FloatType
Definition: NanoVDB.h:2807
Vec3 cross(const Vec3T &v) const
Definition: NanoVDB.h:1083
bool isLevelSet() const
Definition: NanoVDB.h:2420
ValueType & operator[](IndexType i)
Return a non-const reference to the given Coord component.
Definition: NanoVDB.h:909
const DataType * data() const
Definition: NanoVDB.h:3711
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType type
Definition: NanoVDB.h:2119
ChildT ChildNodeType
Definition: NanoVDB.h:2803
Vec4 operator*(const Vec4 &v) const
Definition: NanoVDB.h:1230
typename GridOrTreeOrRootT::RootType type
Definition: NanoVDB.h:2147
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4365
bool is_divisible() const
Definition: NanoVDB.h:1628
BaseBBox()
Definition: NanoVDB.h:1516
uint64_t memUsage() const
Return the actual memory footprint of this root node.
Definition: NanoVDB.h:2860
Vec4 & operator/=(const T &s)
Definition: NanoVDB.h:1260
MaskT< LOG2DIM > ArrayType
Definition: NanoVDB.h:3599
NanoBuildT Type
Definition: NanoVDB.h:384
uint64_t mMagic
Definition: NanoVDB.h:2187
void setBBoxOn(bool on=true)
Definition: NanoVDB.h:2214
uint64_t mGridSize
Definition: NanoVDB.h:2193
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3099
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4584
Vec3 operator/(const Vec3 &v) const
Definition: NanoVDB.h:1096
RootT Node3
Definition: NanoVDB.h:2558
Trait to map from LEVEL to node type.
Definition: NanoVDB.h:3933
Vec3T & min()
Definition: NanoVDB.h:1485
Rgba8(float r, float g, float b, float a=1.0f)
Definition: NanoVDB.h:472
void extrema(ValueType &min, ValueType &max) const
Sets the extrema values of all the active values in this tree, i.e. in all nodes of the tree...
Definition: NanoVDB.h:2674
const LeafNodeType * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:2896
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:2851
bool probeValue(const CoordType &ijk, ValueType &v) const
Combines the previous two methods in a single call.
Definition: NanoVDB.h:2592
#define NANOVDB_MINOR_VERSION_NUMBER
Definition: NanoVDB.h:105
bool operator<(const Coord &rhs) const
Return true if this Coord is lexicographically less than the given Coord.
Definition: NanoVDB.h:932
A simple vector class with three double components, similar to openvdb::math::Vec4.
Definition: NanoVDB.h:1188
CoordT RoundDown(const Vec3T< RealT > &xyz)
Definition: NanoVDB.h:788
uint64_t KeyT
Return a key based on the coordinates of a voxel.
Definition: NanoVDB.h:2696
void setValueOnly(const CoordT &ijk, const ValueType &v)
Definition: NanoVDB.h:3795
void setOn(uint32_t n)
Set the given bit on.
Definition: NanoVDB.h:1920
const NodeT * getFirstNode() const
return a const pointer to the first node of the specified type
Definition: NanoVDB.h:2642
const uint8_t & r() const
Definition: NanoVDB.h:492
BuildT ValueType
Definition: NanoVDB.h:3358
Coord & translate(const Vec3T &xyz)
Definition: NanoVDB.h:1489
uint64_t mFlags
Definition: NanoVDB.h:3063
bool isMask() const
Definition: NanoVDB.h:2425
const LeafNodeType * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:3207
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:1696
Rgba8()
Definition: NanoVDB.h:469
const CoordT & operator*() const
Definition: NanoVDB.h:1608
bool operator<(const Rgba8 &rhs) const
Definition: NanoVDB.h:479
bool operator>=(const Version &rhs) const
Definition: NanoVDB.h:560
int32_t z() const
Definition: NanoVDB.h:891
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4335
uint32_t mGridCount
Definition: NanoVDB.h:2192
CoordT mBBoxMin
Definition: NanoVDB.h:3364
BBox(const Coord &min, const Coord &max)
Definition: NanoVDB.h:1547
Vec3T applyIJTF(const Vec3T &xyz) const
Definition: NanoVDB.h:2041
uint8_t & r()
Definition: NanoVDB.h:496
const MaskType< LOG2DIM > & childMask() const
Return a const reference to the bit mask of child nodes in this internal node.
Definition: NanoVDB.h:3162
void setAverageOn(bool on=true)
Definition: NanoVDB.h:2230
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:3470
BBox expandBy(typename CoordT::ValueType padding) const
Return a new instance that is expanded by the specified padding.
Definition: NanoVDB.h:1652
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel (regardless of state or location in the tree.) ...
Definition: NanoVDB.h:2583
const TreeT & tree() const
Return a const reference to the tree.
Definition: NanoVDB.h:2344
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:2830
NodeT * getFirstNode()
return a pointer to the first node of the specified type
Definition: NanoVDB.h:2632
float mQuantum
Definition: NanoVDB.h:3419
const T & operator[](int i) const
Definition: NanoVDB.h:1220
Iterator & operator++()
Definition: NanoVDB.h:1834
ValueType mMinimum
Definition: NanoVDB.h:4026
bool isPointIndex() const
Definition: NanoVDB.h:2423
BBox(const Vec3T &min, const Vec3T &max)
Definition: NanoVDB.h:1543
MaskT< LOG2 > MaskType
Definition: NanoVDB.h:3698
Vec3(const Coord &ijk)
Definition: NanoVDB.h:1064
Map mMap
Definition: NanoVDB.h:2195
void setValue(uint32_t n, const ValueT &v)
Definition: NanoVDB.h:3080
float type
Definition: NanoVDB.h:413
TreeT & tree()
Return a non-const reference to the tree.
Definition: NanoVDB.h:2347
GridType mapToGridType()
Maps from a templated value type to a GridType enum.
Definition: NanoVDB.h:1366
typename ChildT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:2802
Bit-compacted representation of all three version numbers.
Definition: NanoVDB.h:540
int32_t x() const
Definition: NanoVDB.h:889
BBox< Vec3< RealT > > asReal() const
Definition: NanoVDB.h:1645
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType type
Definition: NanoVDB.h:2126
DataType * data()
Definition: NanoVDB.h:2569
bool isOn() const
Definition: NanoVDB.h:1903
Type Max(Type a, Type b)
Definition: NanoVDB.h:672
typename DataType::ValueT ValueType
Definition: NanoVDB.h:3124
const StatsT & stdDeviation() const
Definition: NanoVDB.h:3104
typename GridOrTreeOrRootT::LeafNodeType Type
Definition: NanoVDB.h:2103
Coord operator>>(IndexType n) const
Definition: NanoVDB.h:929
T ValueType
Definition: NanoVDB.h:1194
Definition: NanoVDB.h:3051
void setAvg(const bool &)
Definition: NanoVDB.h:3622
Vec3(const Vec3< T2 > &v)
Definition: NanoVDB.h:1060
bool isStaggered() const
Definition: NanoVDB.h:2422
static uint64_t memUsage()
return memory usage in bytes for the class
Definition: NanoVDB.h:2574
CoordT offsetToGlobalCoord(uint32_t n) const
Definition: NanoVDB.h:3746
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:847
Type Min(Type a, Type b)
Definition: NanoVDB.h:651
Vec3T applyMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2015
void setMin(float min)
Definition: NanoVDB.h:3442
ValueType mMaximum
Definition: NanoVDB.h:3370
Coord round() const
Definition: NanoVDB.h:1159
BaseBBox(const Vec3T &min, const Vec3T &max)
Definition: NanoVDB.h:1517
typename GridOrTreeOrRootT::LeafNodeType type
Definition: NanoVDB.h:2104
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3650
Vec3R mVoxelSize
Definition: NanoVDB.h:2197
Coord operator&(IndexType n) const
Return a new instance with coordinates masked by the given unsigned integer.
Definition: NanoVDB.h:923
void init(float min, float max, uint8_t bitWidth)
Definition: NanoVDB.h:3422
PointAccessor(const UInt32Grid &grid)
Definition: NanoVDB.h:4729
const T & operator[](int i) const
Definition: NanoVDB.h:1078
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel.
Definition: NanoVDB.h:3186
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:2601
bool isActive(const CoordT &ijk) const
Return true if the voxel value at the given coordinate is active.
Definition: NanoVDB.h:3798
const NodeT * getNode() const
Return a const point to the cached node of the specified type.
Definition: NanoVDB.h:4484
typename DataType::BuildT BuildType
Definition: NanoVDB.h:2808
bool isPointData() const
Definition: NanoVDB.h:2424
void setMin(const bool &)
Definition: NanoVDB.h:3620
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4602
FloatType mAverage
Definition: NanoVDB.h:4028
uint64_t activeVoxelCount() const
Return the total number of active voxels in this tree.
Definition: NanoVDB.h:2414
void setValue(uint32_t offset, const ValueType &value)
Definition: NanoVDB.h:3378
Vec3T worldToIndexF(const Vec3T &xyz) const
world to index space transformation
Definition: NanoVDB.h:2383
bool operator!=(const Mask &other) const
Definition: NanoVDB.h:1896
Vec3T matMult(const float *mat, const Vec3T &xyz)
Definition: NanoVDB.h:1409
int32_t Ceil(float x)
Definition: NanoVDB.h:720
void setMin(const ValueType &v)
Definition: NanoVDB.h:3389
bool FloatType
Definition: NanoVDB.h:1353
void setStdDeviationOn(bool on=true)
Definition: NanoVDB.h:2238
Definition: NanoVDB.h:1339
typename DataType::FloatType FloatType
Definition: NanoVDB.h:3693
#define NANOVDB_DATA_ALIGNMENT
Definition: NanoVDB.h:116
Vec3T applyInverseMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2259
typename DataType::Tile Tile
Definition: NanoVDB.h:2812
const RootT & root() const
Definition: NanoVDB.h:4258
CoordT CoordType
Definition: NanoVDB.h:3695
DataType * data()
Definition: NanoVDB.h:3148
bool getValue(uint32_t i) const
Definition: NanoVDB.h:3653
bool isEmpty() const
Return true if this grid is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:2462
bool isInside(const Vec3T &xyz)
Definition: NanoVDB.h:1506
Dummy type for a 16bit quantization of float point values.
Definition: NanoVDB.h:201
uint8_t ArrayType
Definition: NanoVDB.h:3494
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:2848
Coord & operator-=(const Coord &rhs)
Definition: NanoVDB.h:970
bool isActive() const
Return true if any of the voxel value are active in this leaf node.
Definition: NanoVDB.h:3802
BBox< CoordT > bbox() const
Return the bounding box in index space of active values in this leaf node.
Definition: NanoVDB.h:3755
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:3498
CoordT origin() const
Definition: NanoVDB.h:2744
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4246
const StatsT & stdDeviation() const
Definition: NanoVDB.h:2782
CoordType mBBoxMin
Definition: NanoVDB.h:4030
const GridBlindMetaData & blindMetaData(int n) const
Definition: NanoVDB.h:2482
WordT getWord(int n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NanoVDB.h:1867
Vec3< T2 > operator/(T1 scalar, const Vec3< T2 > &vec)
Definition: NanoVDB.h:1168
uint16_t ArrayType
Definition: NanoVDB.h:3516
uint32_t nodeCount() const
Definition: NanoVDB.h:2616
ValueT value
Definition: NanoVDB.h:2748
Node caching at all (three) tree levels.
Definition: NanoVDB.h:4431
BBox()
Definition: NanoVDB.h:1538
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4148
const DataType * data() const
Definition: NanoVDB.h:2329
Vec4 & operator=(const Vec4T &rhs)
Definition: NanoVDB.h:1212
Stuct with all the member data of the LeafNode (useful during serialization of an openvdb LeafNode) ...
Definition: NanoVDB.h:3354
GridBlindDataSemantic
Blind-data Semantics that are currently understood by NanoVDB.
Definition: NanoVDB.h:313
bool operator==(const BaseBBox &rhs) const
Definition: NanoVDB.h:1481
uint32_t packed
Definition: NanoVDB.h:459
Version mVersion
Definition: NanoVDB.h:2189
GridFlags
Grid flags which indicate what extra information is present in the grid buffer.
Definition: NanoVDB.h:277
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:1667
uint32_t mFlags
Definition: NanoVDB.h:2190
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:4656
RootT RootType
Definition: NanoVDB.h:2551
Definition: NanoVDB.h:184
float type
Definition: NanoVDB.h:406
float Type
Definition: NanoVDB.h:412
GridType mGridType
Definition: NanoVDB.h:2199
Vec3 & operator-=(const Vec3 &v)
Definition: NanoVDB.h:1108
uint64_t mChecksum
Definition: NanoVDB.h:2188
uint32_t nodeCount(int level) const
Definition: NanoVDB.h:2622
Definition: NanoVDB.h:1818
T dot(const Vec4T &v) const
Definition: NanoVDB.h:1223
uint32_t hash() const
Return a hash key derived from the existing coordinates.
Definition: NanoVDB.h:1024
Bit-mask to encode active states and facilitate sequential iterators and a fast codec for I/O compres...
Definition: NanoVDB.h:1794
int32_t & x()
Definition: NanoVDB.h:893
bool operator!=(const BaseBBox &rhs) const
Definition: NanoVDB.h:1482
static size_t memUsage()
Definition: NanoVDB.h:901
CoordT CoordType
Definition: NanoVDB.h:4112
void setOff()
Set all bits off.
Definition: NanoVDB.h:1943
static ElementType scalar(const T &v)
Definition: NanoVDB.h:1333
bool isChild() const
Definition: NanoVDB.h:2743
void localToGlobalCoord(Coord &ijk) const
modifies local coordinates to global coordinates of a tile or child node
Definition: NanoVDB.h:3238
void toggle()
brief Toggle the state of all bits in the mask
Definition: NanoVDB.h:1957
const Vec3T & max() const
Definition: NanoVDB.h:1488
Vec3T applyIJTF(const Vec3T &xyz) const
Definition: NanoVDB.h:2276
typename ChildT::ValueType ValueT
Definition: NanoVDB.h:2688
float mMinimum
Definition: NanoVDB.h:3418
Vec3T applyJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2272
uint8_t bitWidth() const
Definition: NanoVDB.h:3541
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:3520
void setMax(const ValueType &)
Definition: NanoVDB.h:3664
T Pow4(T x)
Definition: NanoVDB.h:742
ValueType getValue(uint32_t offset) const
Return the voxel value at the given offset.
Definition: NanoVDB.h:3781
KeyT key
Definition: NanoVDB.h:2745
bool isCached(const CoordType &ijk) const
Definition: NanoVDB.h:4510
typename DataType::StatsT FloatType
Definition: NanoVDB.h:3125
bool ValueType
Definition: NanoVDB.h:3596
A simple vector class with three double components, similar to openvdb::math::Vec3.
Definition: NanoVDB.h:856
bool isActive() const
Retrun true if this node or any of its child nodes contain active values.
Definition: NanoVDB.h:3252
Top-most node of the VDB tree structure.
Definition: NanoVDB.h:2798
void setValue(uint32_t offset, bool v)
Definition: NanoVDB.h:3614
typename ReadAccessor< ValueT,-1,-1,-1 >::NodeInfo NodeInfo
Definition: NanoVDB.h:4459
int64_t child
Definition: NanoVDB.h:3054
Vec3T applyJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2018
const typename GridOrTreeOrRootT::RootType Type
Definition: NanoVDB.h:2154
#define NANOVDB_MAJOR_VERSION_NUMBER
Definition: NanoVDB.h:104
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:3810
uint8_t ArrayType
Definition: NanoVDB.h:3466
Vec4 operator/(const T &s) const
Definition: NanoVDB.h:1235
Struct to derive node type from its level in a given grid, tree or root while perserving constness...
Definition: NanoVDB.h:2096
typename GridT::TreeType type
Definition: NanoVDB.h:2529
T length() const
Definition: NanoVDB.h:1093
static CoordT KeyToCoord(const KeyT &key)
Definition: NanoVDB.h:2706
Vec3< float > asVec3s() const
Return a single precision floating-point vector of this coordinate.
Definition: NanoVDB.h:1179
typename RootT::ChildNodeType Node2
Definition: NanoVDB.h:2559
Vec3 & minComponent(const Vec3 &other)
Perform a component-wise minimum with the other Coord.
Definition: NanoVDB.h:1125
ValueType mMinimum
Definition: NanoVDB.h:3369
typename GridOrTreeOrRootT::RootType::ChildNodeType Type
Definition: NanoVDB.h:2132
ValueT mMaximum
Definition: NanoVDB.h:3068
BBox(const CoordT &min, const CoordT &max)
Definition: NanoVDB.h:1615
void setValueOnly(uint32_t offset, const ValueType &value)
Definition: NanoVDB.h:3377
Vec3T applyInverseMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2023
Vec3T & max()
Definition: NanoVDB.h:1486
T ElementType
Definition: NanoVDB.h:1321
Vec4 & operator+=(const Vec4 &v)
Definition: NanoVDB.h:1236
Coord & maxComponent(const Coord &other)
Perform a component-wise maximum with the other Coord.
Definition: NanoVDB.h:991
float Type
Definition: NanoVDB.h:426
uint32_t getPatch() const
Definition: NanoVDB.h:564
bool hasStdDeviation() const
Definition: NanoVDB.h:2431
Struct with all the member data of the RootNode (useful during serialization of an openvdb RootNode) ...
Definition: NanoVDB.h:2686
openvdb::GridBase Grid
Definition: Utils.h:34
int32_t Floor(float x)
Definition: NanoVDB.h:711
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:2845
Mask()
Initialize all bits to zero.
Definition: NanoVDB.h:1846
double FloatType
Definition: NanoVDB.h:1347
float getValue(uint32_t i) const
Definition: NanoVDB.h:3544
static DstT * PtrAdd(SrcT *p, int64_t offset)
Definition: NanoVDB.h:440
Vec4 operator-() const
Definition: NanoVDB.h:1229
Delta for small floating-point offsets.
Definition: NanoVDB.h:597
GridClass mGridClass
Definition: NanoVDB.h:2198
Maps one type (e.g. the build types above) to other (actual) types.
Definition: NanoVDB.h:382
Coord()
Initialize all coordinates to zero.
Definition: NanoVDB.h:867
Vec3T applyInverseJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2274
Vec3T applyIJT(const Vec3T &xyz) const
Definition: NanoVDB.h:2039
DataType * data()
Definition: NanoVDB.h:3709
typename RootT::ValueType ValueType
Definition: NanoVDB.h:4018
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4140
bool operator<=(const Version &rhs) const
Definition: NanoVDB.h:558
void setMax(float max)
Definition: NanoVDB.h:3445
double ValueType
Definition: NanoVDB.h:1049
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:2854
typename ChildT::CoordType CoordType
Definition: NanoVDB.h:2810
const typename GridOrTreeOrRootT::RootType::ChildNodeType Type
Definition: NanoVDB.h:2139
void setChild(uint32_t n, const void *ptr)
Definition: NanoVDB.h:3073
Vec3 operator-(const Vec3 &v) const
Definition: NanoVDB.h:1098
void setMax(const ValueT &v)
Definition: NanoVDB.h:3107
Vec3T indexToWorldGrad(const Vec3T &grad) const
transform the gradient from index space to world space.
Definition: NanoVDB.h:2379
bool getAvg() const
Definition: NanoVDB.h:3656
const typename GridOrTreeOrRootT::LeafNodeType type
Definition: NanoVDB.h:2111
float length() const
Definition: NanoVDB.h:487
static size_t memUsage()
Return memory usage in bytes for the class.
Definition: NanoVDB.h:3156
static Coord Floor(const Vec3T &xyz)
Return the largest integer coordinates that are not greater than xyz (node centered conversion)...
Definition: NanoVDB.h:1019
bool isApproxZero(const Type &x)
Definition: NanoVDB.h:645
const NodeTrait< RootT, LEVEL >::type * getFirstNode() const
return a const pointer to the first node of the specified level
Definition: NanoVDB.h:2663
Coord operator-(const Coord &rhs) const
Definition: NanoVDB.h:962
const Map & map() const
Return a const reference to the Map for this grid.
Definition: NanoVDB.h:2356
static double value()
Definition: NanoVDB.h:590
Definition: NanoVDB.h:1524
bool getValue(uint32_t i) const
Definition: NanoVDB.h:3609
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4305
uint8_t octant() const
Return the octant of this Coord.
Definition: NanoVDB.h:1028
bool isValid() const
Methods related to the classification of this grid.
Definition: NanoVDB.h:2417
T Abs(T x)
Definition: NanoVDB.h:747
bool isOn(uint32_t n) const
Return true if the given bit is set.
Definition: NanoVDB.h:1901
uint64_t volume() const
Definition: NanoVDB.h:1636
bool operator!=(const Vec4 &rhs) const
Definition: NanoVDB.h:1210
typename Node2::ChildNodeType Node1
Definition: NanoVDB.h:2560
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4567
Dummy type for a 16 bit floating point values.
Definition: NanoVDB.h:192
uint32_t id() const
Definition: NanoVDB.h:561
const uint8_t & b() const
Definition: NanoVDB.h:494
#define NANOVDB_MAGIC_NUMBER
Definition: NanoVDB.h:102
const char * c_str() const
Definition: NanoVDB.h:567
bool getDev() const
Definition: NanoVDB.h:3613
float getValue(uint32_t i) const
Definition: NanoVDB.h:3521
bool isEmpty() const
Return true if this RootNode is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:2880
float Fract(float x)
Definition: NanoVDB.h:702
uint8_t & g()
Definition: NanoVDB.h:497
Vec4 operator*(const T &s) const
Definition: NanoVDB.h:1234
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4516
#define ROOT_LEVEL
Definition: CNanoVDB.h:53
int64_t child
Definition: NanoVDB.h:2746
bool empty() const
Return true if this bounding box is empty, i.e. uninitialized.
Definition: NanoVDB.h:1632
BuildT ArrayType
Definition: NanoVDB.h:3361
uint32_t mBlindMetadataCount
Definition: NanoVDB.h:2201
Vec3T indexToWorldDir(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition: NanoVDB.h:2369
Iterator beginOn() const
Definition: NanoVDB.h:1898
uint32_t CountOn(uint64_t v)
Definition: NanoVDB.h:1774
Vec3(T x, T y, T z)
Definition: NanoVDB.h:1055
bool BuildType
Definition: NanoVDB.h:3597
8-bit red, green, blue, alpha packed into 32 bit unsigned int
Definition: NanoVDB.h:455
const ValueT & getMin() const
Definition: NanoVDB.h:3101
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:2871
T length() const
Definition: NanoVDB.h:1228
Version(uint32_t major, uint32_t minor, uint32_t patch)
Definition: NanoVDB.h:549
AccessorType getAccessor() const
Return a new instance of a ReadAccessor used to access values in this grid.
Definition: NanoVDB.h:2350
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:3174
CoordT CoordType
Definition: NanoVDB.h:4239
Dummy type for a variable bit quantization of floating point values.
Definition: NanoVDB.h:204
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:3183
int MaxIndex(const Vec3T &v)
Definition: NanoVDB.h:827
void updateBBox()
Updates the local bounding box of active voxels in this node.
Definition: NanoVDB.h:3883
StatsT mAverage
Definition: NanoVDB.h:2724
Vec3T applyIJT(const Vec3T &xyz) const
Definition: NanoVDB.h:2265
Vec3 & operator/=(const T &s)
Definition: NanoVDB.h:1122
Rgba8(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255u)
Definition: NanoVDB.h:470
T type
Definition: NanoVDB.h:348
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3626
int32_t & z()
Definition: NanoVDB.h:895
const uint8_t & g() const
Definition: NanoVDB.h:493
uint8_t flags() const
Definition: NanoVDB.h:3731
bool isFloatingPoint(GridType gridType)
return true if the GridType maps to a floating point value.
Definition: NanoVDB.h:507
Coord & operator+=(int n)
Definition: NanoVDB.h:954
Vec4 operator/(const Vec4 &v) const
Definition: NanoVDB.h:1231
const GridType & gridType() const
Definition: NanoVDB.h:2418
typename RootT::ValueType ValueType
Definition: NanoVDB.h:2553
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:2842
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4049
float FloatType
Definition: NanoVDB.h:1341
Coord offsetToGlobalCoord(uint32_t n) const
Definition: NanoVDB.h:3244
void set(const Mat4T &mat, const Mat4T &invMat, double taper)
Definition: NanoVDB.h:2045
uint32_t IndexType
Definition: NanoVDB.h:864
Iterator()
Definition: NanoVDB.h:1821
bool getMax() const
Definition: NanoVDB.h:3655
typename ChildT::BuildType BuildT
Definition: NanoVDB.h:2689
ValueType getValue(uint32_t i) const
Definition: NanoVDB.h:3376
ValueType getMax() const
Definition: NanoVDB.h:3385
uint32_t mLevel
Definition: NanoVDB.h:4024
typename TreeT::ValueType ValueType
Definition: NanoVDB.h:2313
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:4763
ValueT value
Definition: GridBuilder.h:1287
float ValueType
Definition: NanoVDB.h:3410
CoordT Round(const Vec3T< RealT > &xyz)
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3395
typename ChildT::template MaskType< LOG2DIM > MaskT
Definition: NanoVDB.h:3048
static uint32_t wordCount()
Return the number of machine words used by this Mask.
Definition: NanoVDB.h:1808
BBox()
Definition: NanoVDB.h:1611
uint8_t mFlags
Definition: NanoVDB.h:3649
ValueType max() const
Return the largest vector component.
Definition: NanoVDB.h:1153
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType Type
Definition: NanoVDB.h:2118
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3416
int64_t mBlindMetadataOffset
Definition: NanoVDB.h:2200
ValueType getMin() const
Definition: NanoVDB.h:3384
Coord offsetBy(ValueType dx, ValueType dy, ValueType dz) const
Definition: NanoVDB.h:1002
float mTaperF
Definition: NanoVDB.h:2002
void setAvg(const FloatType &v)
Definition: NanoVDB.h:3391
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4462
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4181
Vec4 operator+(const Vec4 &v) const
Definition: NanoVDB.h:1232
void setAvg(const StatsT &v)
Definition: NanoVDB.h:3108
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4381
typename RootT::CoordType CoordType
Definition: NanoVDB.h:4019
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4035
BBox(const BaseBBox< Coord > &bbox)
Definition: NanoVDB.h:1552
Vec4 & minComponent(const Vec4 &other)
Perform a component-wise minimum with the other Coord.
Definition: NanoVDB.h:1263
typename RootT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:2552
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4550
CoordT mBBoxMin
Definition: NanoVDB.h:3602
static CoordT OffsetToLocalCoord(uint32_t n)
Definition: NanoVDB.h:3736
T & operator[](int i)
Definition: NanoVDB.h:1079
Vec3T applyMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2257
Vec3T & operator[](int i)
Definition: NanoVDB.h:1484
const void * blindData(uint32_t n) const
Returns a const pointer to the blindData at the specified linear offset.
Definition: NanoVDB.h:2473
void setValueOnly(uint32_t offset, const ValueType &v)
Sets the value at the specified location but leaves its state unchanged.
Definition: NanoVDB.h:3794
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:3177
int blindDataCount() const
Return the count of blind-data encoded in this grid.
Definition: NanoVDB.h:2465
bool isCached1(const CoordType &ijk) const
Definition: NanoVDB.h:4291
Vec3 operator/(const T &s) const
Definition: NanoVDB.h:1100
float lengthSqr() const
Definition: NanoVDB.h:481
void setMax(const bool &)
Definition: NanoVDB.h:3621
typename ChildT::BuildType BuildT
Definition: NanoVDB.h:3045
const DataType * data() const
Definition: NanoVDB.h:3150
const uint8_t & operator[](int n) const
Definition: NanoVDB.h:488
void setLongGridNameOn(bool on=true)
Definition: NanoVDB.h:2222
void setDev(const FloatType &v)
Definition: NanoVDB.h:3392
Iterator(uint32_t pos, const Mask *parent)
Definition: NanoVDB.h:1826
const ValueT & getMax() const
Definition: NanoVDB.h:2780
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4064
void setDev(const bool &)
Definition: NanoVDB.h:3623
DataType * data()
Definition: NanoVDB.h:2327
Vec3T mCoord[2]
Definition: NanoVDB.h:1480
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4172
ValueT mMinimum
Definition: NanoVDB.h:3067
RootT & root()
Definition: NanoVDB.h:2576
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3605
const StatsT & average() const
Definition: NanoVDB.h:2781
Dummy type for a 8bit quantization of float point values.
Definition: NanoVDB.h:198
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4054
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:4751
Maximum floating-point values.
Definition: NanoVDB.h:613
bool operator==(const Mask &other) const
Definition: NanoVDB.h:1888
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3454
bool hasMinMax() const
Definition: NanoVDB.h:2427
Dummy type for a voxel with a binary mask value, e.g. the active state.
Definition: NanoVDB.h:189
Version()
Definition: NanoVDB.h:544
bool operator<(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:189
int32_t & y()
Definition: NanoVDB.h:894
Vec3 & operator*=(const T &s)
Definition: NanoVDB.h:1115
uint32_t mGridIndex
Definition: NanoVDB.h:2191
int findBlindDataForSemantic(GridBlindDataSemantic semantic) const
Return the index of the blind data with specified semantic if found, otherwise -1.
Definition: NanoVDB.h:2489
uint64_t mVoxelCount
Definition: NanoVDB.h:2506
const char * gridName() const
Return a c-string with the name of this grid.
Definition: NanoVDB.h:2445
bool operator!=(const Vec3 &rhs) const
Definition: NanoVDB.h:1069
bool isEmpty() const
Return true if this tree is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:2589
static Coord OffsetToLocalCoord(uint32_t n)
Definition: NanoVDB.h:3230
const char * toStr(GridType gridType)
Retuns a c-string used to describe a GridType.
Definition: NanoVDB.h:239
BBox< Vec3R > mWorldBBox
Definition: NanoVDB.h:2196
CoordT CoordType
Definition: NanoVDB.h:4455
const RootT & root() const
Definition: NanoVDB.h:4037
float getMax() const
return the quantized maximum of the active values in this node
Definition: NanoVDB.h:3432
bool hasBBox() const
Definition: NanoVDB.h:2428
#define NANOVDB_ASSERT(x)
Definition: NanoVDB.h:149
T dot(const Vec3T &v) const
Definition: NanoVDB.h:1081
ValueT mBackground
Definition: NanoVDB.h:2721
BBox< CoordT > mBBox
Definition: NanoVDB.h:3062
const typename GridOrTreeOrRootT::RootType::ChildNodeType type
Definition: NanoVDB.h:2140
void ArrayType
Definition: NanoVDB.h:3644
float getMin() const
return the quantized minimum of the active values in this node
Definition: NanoVDB.h:3429
Defines an affine transform and its inverse represented as a 3x3 matrix and a vec3 translation...
Definition: NanoVDB.h:1997
float Type
Definition: NanoVDB.h:405
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4070
static double value()
Definition: NanoVDB.h:606
const FloatType & stdDeviation() const
Return a const reference to the standard deviation of all the active values encoded in this internal ...
Definition: NanoVDB.h:3180
Coord ceil() const
Definition: NanoVDB.h:1158
Coord(ValueType n)
Initializes all coordinates to the given signed integer.
Definition: NanoVDB.h:873
uint32_t gridIndex() const
Return index of this grid in the buffer.
Definition: NanoVDB.h:2338
GridType
List of types that are currently supported by NanoVDB.
Definition: NanoVDB.h:216
typename TreeT::CoordType CoordType
Definition: NanoVDB.h:2315
uint32_t getMajor() const
Definition: NanoVDB.h:562
void setValue(const CoordT &ijk, const ValueType &v)
Sets the value at the specified location and activate its state.
Definition: NanoVDB.h:3789
Coord & operator&=(int n)
Definition: NanoVDB.h:940
const Vec3R & voxelSize() const
Return a const reference to the size of a voxel in world units.
Definition: NanoVDB.h:2353
Class to access points at a specific voxel location.
Definition: NanoVDB.h:4720
void setChild(const CoordType &k, const ChildT *ptr, const RootData *data)
Definition: NanoVDB.h:2730
bool isUnknown() const
Definition: NanoVDB.h:2426
Vec4 & operator*=(const T &s)
Definition: NanoVDB.h:1252
Vec3 & operator=(const Vec3T &rhs)
Definition: NanoVDB.h:1071
ValueT mMaximum
Definition: NanoVDB.h:2723
bool isInside(const CoordT &p) const
Definition: NanoVDB.h:1637
const ChildT * getChild(const Tile *tile) const
Definition: NanoVDB.h:2773
bool getMin() const
Definition: NanoVDB.h:3654
ValueT mMinimum
Definition: NanoVDB.h:2722
NodeTrait< RootT, LEVEL >::type * getFirstNode()
return a pointer to the first node at the specified level
Definition: NanoVDB.h:2653
const GridClass & gridClass() const
Definition: NanoVDB.h:2419
bool FloatType
Definition: NanoVDB.h:1359
static KeyT CoordToKey(const CoordType &ijk)
Definition: NanoVDB.h:2698
const MaskType< LOG2DIM > & valueMask() const
Return a const reference to the bit mask of active voxels in this leaf node.
Definition: NanoVDB.h:3714
bool isValid(GridType gridType, GridClass gridClass)
return true if the combination of GridType and GridClass is valid.
Definition: NanoVDB.h:520
const RootT * getRoot() const
Definition: NanoVDB.h:2513
Vec3T applyInverseMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2028
const uint32_t & activeTileCount(uint32_t n) const
Return the total number of active tiles at the specified level of the tree.
Definition: NanoVDB.h:2609
typename ChildT::ValueType ValueT
Definition: NanoVDB.h:3044
BBox< CoordT > mBBox
Definition: NanoVDB.h:2718
float Sqrt(float x)
Return the square root of a floating-point value.
Definition: NanoVDB.h:795
AccessorType getAccessor() const
Definition: NanoVDB.h:2823
static Coord max()
Definition: NanoVDB.h:897
Vec3< T2 > operator*(T1 scalar, const Vec3< T2 > &vec)
Definition: NanoVDB.h:1163
int MinIndex(const Vec3T &v)
Definition: NanoVDB.h:810
uint8_t mFlags
Definition: NanoVDB.h:3415
Internal nodes of a VDB treedim(),.
Definition: NanoVDB.h:3120
const Tile * tile(uint32_t n) const
Returns a non-const reference to the tile at the specified linear offset.
Definition: NanoVDB.h:2754
CoordT dim() const
Definition: NanoVDB.h:1635
uint8_t & b()
Definition: NanoVDB.h:498
CoordType mBBoxMax
Definition: NanoVDB.h:4031
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:3192
#define NANOVDB_HOSTDEV_DISABLE_WARNING
Definition: NanoVDB.h:178
ValueT ValueType
Definition: NanoVDB.h:4454
TreeT TreeType
Definition: NanoVDB.h:2310
Base-class for quantized float leaf nodes.
Definition: NanoVDB.h:3406
FloatType average() const
Return a const reference to the average of all the active values encoded in this leaf node...
Definition: NanoVDB.h:3723
Coord operator<<(IndexType n) const
Definition: NanoVDB.h:926
Vec3T indexToWorld(const Vec3T &xyz) const
index to world space transformation
Definition: NanoVDB.h:2364
Vec4 & maxComponent(const Vec4 &other)
Perform a component-wise maximum with the other Coord.
Definition: NanoVDB.h:1277
Definition: NanoVDB.h:2500
bool hasAverage() const
Definition: NanoVDB.h:2430
bool isCached2(const CoordType &ijk) const
Definition: NanoVDB.h:4297
Struct with all the member data of the InternalNode (useful during serialization of an openvdb Intern...
Definition: NanoVDB.h:3042
Vec3T applyMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2268
const typename GridT::TreeType Type
Definition: NanoVDB.h:2534
uint8_t & a()
Definition: NanoVDB.h:499
float Clamp(float x, float a, float b)
Definition: NanoVDB.h:693
BaseBBox & expand(const Vec3T &xyz)
Definition: NanoVDB.h:1496
bool operator>(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:201
Dummy type for a 4bit quantization of float point values.
Definition: NanoVDB.h:195
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:2882
typename ChildT::CoordType CoordT
Definition: NanoVDB.h:3047
float getDev() const
return the quantized standard deviation of the active values in this node
Definition: NanoVDB.h:3439
Vec3T Vec3Type
Definition: NanoVDB.h:1533
static bool lessThan(const Coord &a, const Coord &b)
Definition: NanoVDB.h:1011
Vec3 & maxComponent(const Vec3 &other)
Perform a component-wise maximum with the other Coord.
Definition: NanoVDB.h:1137
const typename GridT::TreeType type
Definition: NanoVDB.h:2535
bool operator==(const Vec4 &rhs) const
Definition: NanoVDB.h:1209
RootT * getRoot()
Definition: NanoVDB.h:2511
Vec3T worldToIndexDirF(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition: NanoVDB.h:2397
Vec3< double > asVec3d() const
Return a double precision floating-point vector of this coordinate.
Definition: NanoVDB.h:1182
typename GridOrTreeOrRootT::RootType Type
Definition: NanoVDB.h:2146
uint8_t mFlags
Definition: NanoVDB.h:3604
NanoBuildT type
Definition: NanoVDB.h:385
void setValue(uint32_t offset, bool)
Definition: NanoVDB.h:3658
void toggle(uint32_t n)
Definition: NanoVDB.h:1963
bool getMax() const
Definition: NanoVDB.h:3611
const ChildT * getChild(uint32_t n) const
Definition: NanoVDB.h:3092
uint64_t checksum() const
Return checksum of the grid buffer.
Definition: NanoVDB.h:2459
static T value()
Definition: NanoVDB.h:639
Coord floor() const
Definition: NanoVDB.h:1157
Struct with all the member data of the Grid (useful during serialization of an openvdb grid) ...
Definition: NanoVDB.h:2184
bool ValueType
Definition: NanoVDB.h:3641
typename ChildT::template MaskType< LOG2 > MaskType
Definition: NanoVDB.h:3132
Coord & operator<<=(uint32_t n)
Definition: NanoVDB.h:947
Definition: NanoVDB.h:1312
Iterator begin() const
Definition: NanoVDB.h:1610
void setAvg(float avg)
Definition: NanoVDB.h:3448
FloatType stdDeviation() const
Return a const reference to the standard deviation of all the active values encoded in this leaf node...
Definition: NanoVDB.h:3729
typename DataType::BuildType BuildType
Definition: NanoVDB.h:3694
bool FloatType
Definition: NanoVDB.h:3643
static uint32_t bitCount()
Return the number of bits available in this Mask.
Definition: NanoVDB.h:1805
bool operator==(const Version &rhs) const
Definition: NanoVDB.h:556
void setMax(const ValueType &v)
Definition: NanoVDB.h:3390
uint8_t & operator[](int n)
Definition: NanoVDB.h:489
typename ChildT::FloatType StatsT
Definition: NanoVDB.h:3046
const Vec3T & operator[](int i) const
Definition: NanoVDB.h:1483
const uint8_t & a() const
Definition: NanoVDB.h:495
static uint64_t memUsage()
Return memory usage in bytes for this class only.
Definition: NanoVDB.h:2332
static int64_t PtrDiff(const T1 *p, const T2 *q)
Definition: NanoVDB.h:433
bool Type
Definition: NanoVDB.h:391
Vec3 operator*(const T &s) const
Definition: NanoVDB.h:1099
Mask & operator=(const MaskT &other)
Assignment operator that works with openvdb::util::NodeMask.
Definition: NanoVDB.h:1875
T & operator[](int i)
Definition: NanoVDB.h:1221
const typename GridOrTreeOrRootT::RootType type
Definition: NanoVDB.h:2155
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:4741
StatsT mAverage
Definition: NanoVDB.h:3069
Tolerance for floating-point comparison.
Definition: NanoVDB.h:581
void setFirstNode(const NodeT *node)
Definition: NanoVDB.h:2516
CoordT mBBoxMin
Definition: NanoVDB.h:3413
bool operator!=(const Coord &rhs) const
Definition: NanoVDB.h:939
typename ChildT::CoordType CoordT
Definition: NanoVDB.h:2690
T Pow2(T x)
Definition: NanoVDB.h:730
static uint32_t voxelCount()
Return the total number of voxels (e.g. values) encoded in this leaf node.
Definition: NanoVDB.h:3769
void setAvg(const StatsT &v)
Definition: NanoVDB.h:2786
static Coord min()
Definition: NanoVDB.h:899
MaskT mValueMask
Definition: NanoVDB.h:3064
Vec3T dim() const
Definition: NanoVDB.h:1556
uint16_t mMin
Definition: NanoVDB.h:3420
typename ChildT::FloatType StatsT
Definition: NanoVDB.h:2691
Coord offsetBy(ValueType n) const
Definition: NanoVDB.h:1007
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4350
Vec3T worldToIndex(const Vec3T &xyz) const
world to index space transformation
Definition: NanoVDB.h:2360
CoordType origin() const
Return the origin in index space of this leaf node.
Definition: NanoVDB.h:3165
size_t memUsage() const
Definition: NanoVDB.h:3542
Vec4 operator-(const Vec4 &v) const
Definition: NanoVDB.h:1233
const typename GridOrTreeOrRootT::LeafNodeType Type
Definition: NanoVDB.h:2110
const void * treePtr() const
Definition: NanoVDB.h:2282
void setMin(const ValueType &)
Definition: NanoVDB.h:3663
MaskT< LOG2DIM > mValues
Definition: NanoVDB.h:3606
float getValue(uint32_t i) const
Definition: NanoVDB.h:3499
uint32_t countOn() const
Definition: NanoVDB.h:1810
void setMinMaxOn(bool on=true)
Definition: NanoVDB.h:2206
void * treePtr()
Definition: NanoVDB.h:2279
void setValue(const CoordType &k, bool s, const ValueType &v)
Definition: NanoVDB.h:2736
uint32_t mTableSize
Definition: NanoVDB.h:2719
typename TreeT::BuildType BuildType
Definition: NanoVDB.h:2314
CoordT origin() const
Return the origin in index space of this leaf node.
Definition: NanoVDB.h:3734
typename T::ValueType ElementType
Definition: NanoVDB.h:1332
Iterator operator++(int)
Definition: NanoVDB.h:1600
Definition: NanoVDB.h:3686
typename RootT::CoordType CoordType
Definition: NanoVDB.h:2555
float type
Definition: NanoVDB.h:427
defines a tree type from a grid type while perserving constness
Definition: NanoVDB.h:2526
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4059
const BBox< CoordType > & indexBBox() const
Computes a AABB of active values in index space.
Definition: NanoVDB.h:2411
void setOff(uint32_t n)
Definition: NanoVDB.h:1921
uint32_t getMinor() const
Definition: NanoVDB.h:563
void localToGlobalCoord(Coord &ijk) const
Converts (in place) a local index coordinate to a global index coordinate.
Definition: NanoVDB.h:3744
bool isInside(const BBox &b) const
Definition: NanoVDB.h:1638
#define __hostdev__
Definition: NanoVDB.h:168
void setDev(const FloatType &)
Definition: NanoVDB.h:3666
typename ReadAccessor< ValueT,-1,-1,-1 >::NodeInfo NodeInfo
Definition: NanoVDB.h:4116
FloatType getAvg() const
Definition: NanoVDB.h:3386
Iterator & operator++()
Definition: NanoVDB.h:1586
uint8_t ValueType
Definition: NanoVDB.h:463
Leaf nodes of the VDB tree. (defaults to 8x8x8 = 512 voxels)
Definition: NanoVDB.h:3683
uint32_t & packed()
Definition: NanoVDB.h:491
static size_t memUsage()
Return the memory footprint in bytes of this Mask.
Definition: NanoVDB.h:1802
Vec3 operator-() const
Definition: NanoVDB.h:1094
void setDev(const StatsT &v)
Definition: NanoVDB.h:3109
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4533
Vec3T applyInverseJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2036
T Pow3(T x)
Definition: NanoVDB.h:736
Iterator(const BBox &b)
Definition: NanoVDB.h:1581
const char * shortGridName() const
Return a c-string with the name of this grid, truncated to 255 characters.
Definition: NanoVDB.h:2456
ChildT * getChild(uint32_t n)
Returns a pointer to the child node at the specifed linear offset.
Definition: NanoVDB.h:3087
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3669
bool FloatType
Definition: NanoVDB.h:3598
double mTaperD
Definition: NanoVDB.h:2006
const DataType * data() const
Definition: NanoVDB.h:2827
void setMax(const ValueT &v)
Definition: NanoVDB.h:2785
MaskT mChildMask
Definition: NanoVDB.h:3065
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4156
ChildT * getChild(const Tile *tile)
Returns a const reference to the child node in the specified tile.
Definition: NanoVDB.h:2768
bool isCached(const CoordType &ijk) const
Definition: NanoVDB.h:4133
Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord.
Definition: NanoVDB.h:859
Vec3T matMultT(const float *mat, const Vec3T &xyz)
Definition: NanoVDB.h:1443
const DataType * data() const
Definition: NanoVDB.h:2571
int32_t y() const
Definition: NanoVDB.h:890
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3367
C++11 implementation of std::is_floating_point.
Definition: NanoVDB.h:355
void setMin(const ValueT &v)
Definition: NanoVDB.h:3106
Definition: NanoVDB.h:2727
FloatType mAverage
Definition: NanoVDB.h:3371
Vec3T applyJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2020
Vec3T applyInverseJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2034
ValueT ValueType
Definition: NanoVDB.h:4238
Definition: NanoVDB.h:1478
AccessorType getAccessor() const
Definition: NanoVDB.h:2580
float Type
Definition: NanoVDB.h:398
StatsT mStdDevi
Definition: NanoVDB.h:2725
Vec3 & operator+=(const Vec3 &v)
Definition: NanoVDB.h:1101
FloatType mStdDevi
Definition: NanoVDB.h:4029
Coord(ValueType i, ValueType j, ValueType k)
Initializes coordinate to the given signed integers.
Definition: NanoVDB.h:879
bool hasLongGridName() const
Definition: NanoVDB.h:2429
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4119
const uint32_t & tileCount() const
Return the number of tiles encoded in this root node.
Definition: NanoVDB.h:2839
C++11 implementation of std::enable_if.
Definition: NanoVDB.h:341
ValueT value
Definition: NanoVDB.h:3053
uint64_t gridSize() const
Return the memory footprint of the entire grid, i.e. including all nodes and blind data...
Definition: NanoVDB.h:2335
const LeafNode * probeLeaf(const CoordT &) const
Definition: NanoVDB.h:3817
C++11 implementation of std::is_same.
Definition: NanoVDB.h:326
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4044
static uint32_t dim()
Return the dimension, in voxel units, of this internal node (typically 8*16 or 8*16*32) ...
Definition: NanoVDB.h:3153
uint32_t gridCount() const
Return total number of grids in the buffer.
Definition: NanoVDB.h:2341
bool getAvg() const
Definition: NanoVDB.h:3612
ChildT ChildNodeType
Definition: NanoVDB.h:3128
Coord & minComponent(const Coord &other)
Perform a component-wise minimum with the other Coord.
Definition: NanoVDB.h:979
typename DataType::BuildT BuildType
Definition: NanoVDB.h:3126
float getValue(uint32_t i) const
Definition: NanoVDB.h:3471
typename DataType::ValueType ValueType
Definition: NanoVDB.h:3692
float type
Definition: NanoVDB.h:420
bool operator==(const Rgba8 &rhs) const
Definition: NanoVDB.h:480
Coord(ValueType *ptr)
Definition: NanoVDB.h:884
typename ChildT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:3127
Mask(const Mask &other)
Copy constructor.
Definition: NanoVDB.h:1859
bool isActive(uint32_t n) const
Definition: NanoVDB.h:3799
const ValueType & background() const
Return a const reference to the background value.
Definition: NanoVDB.h:2595
static uint64_t memUsage()
return memory usage in bytes for the class
Definition: NanoVDB.h:3772
Coord & operator=(const CoordT &other)
Assignment operator that works with openvdb::Coord.
Definition: NanoVDB.h:913
typename ReadAccessor< ValueT,-1,-1,-1 >::NodeInfo NodeInfo
Definition: NanoVDB.h:4243
Vec3T applyMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2013
float getAvg() const
return the quantized average of the active values in this node
Definition: NanoVDB.h:3435
GridBlindDataClass
Blind-data Classes that are currently supported by NanoVDB.
Definition: NanoVDB.h:306
Vec4(T x)
Definition: NanoVDB.h:1196
void setBreadthFirstOn(bool on=true)
Definition: NanoVDB.h:2246
static uint32_t dim()
Return the dimension, in index space, of this leaf node (typically 8 as for openvdb leaf nodes!) ...
Definition: NanoVDB.h:3752