99#ifndef NANOVDB_NANOVDB_H_HAS_BEEN_INCLUDED
100#define NANOVDB_NANOVDB_H_HAS_BEEN_INCLUDED
102#define NANOVDB_MAGIC_NUMBER 0x304244566f6e614eUL
104#define NANOVDB_MAJOR_VERSION_NUMBER 32
105#define NANOVDB_MINOR_VERSION_NUMBER 3
106#define NANOVDB_PATCH_VERSION_NUMBER 3
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)
124typedef signed char int8_t;
125typedef short int16_t;
127typedef long long int64_t;
128typedef unsigned char uint8_t;
129typedef unsigned int uint32_t;
130typedef unsigned short uint16_t;
131typedef unsigned long long uint64_t;
133#define NANOVDB_ASSERT(x)
135#define UINT64_C(x) (x ## ULL)
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)
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)];
325template<
typename T1,
typename T2>
328 static constexpr bool value =
false;
340template <
bool,
typename T =
void>
367template<
typename AnyType,
template<
typename...>
class TemplateType>
372template<
typename... Args,
template<
typename...>
class TemplateType>
432template <
typename T1,
typename T2>
436 return reinterpret_cast<const char*
>(p) -
reinterpret_cast<const char*
>(q);
439template <
typename DstT,
typename SrcT>
443 return reinterpret_cast<DstT*
>(
reinterpret_cast<char*
>(p) + offset);
446template <
typename DstT,
typename SrcT>
450 return reinterpret_cast<const DstT*
>(
reinterpret_cast<const char*
>(p) + offset);
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);
614#if defined(__CUDA_ARCH__) || defined(__HIP__)
621struct Maximum<uint32_t>
631struct Maximum<double>
644template<
typename Type>
650template<
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)));
671template<
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;
770template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
773template<
typename CoordT,
template<
typename>
class Vec3T>
776 return CoordT(int32_t(rintf(xyz[0])), int32_t(rintf(xyz[1])), int32_t(rintf(xyz[2])));
781template<
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)));
787template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
807__hostdev__ inline T
Sign(
const T &x) {
return ((T(0) < x)?T(1):T(0)) - ((x < T(0))?T(1):T(0)); }
809template<
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])
826template<
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])
846template<u
int64_t wordSize>
849 const uint64_t r = byteCount % wordSize;
850 return r ? byteCount - r + wordSize : byteCount;
856template<
typename>
class Vec3;
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); }
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]);
1162template<
typename T1,
typename T2>
1165 return Vec3<T2>(scalar * vec[0], scalar * vec[1], scalar * vec[2]);
1167template<
typename T1,
typename T2>
1170 return Vec3<T2>(scalar / vec[0], scalar / vec[1], scalar / vec[2]);
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])
1291template<
typename T1,
typename T2>
1294 return Vec4<T2>(scalar * vec[0], scalar * vec[1], scalar * vec[2], scalar * vec[3]);
1296template<
typename T1,
typename T2>
1299 return Vec4<T2>(scalar / vec[0], scalar / vec[1], scalar / vec[2], scalar / vec[3]);
1309template<
typename T,
int Rank = (is_specialization<T, Vec3>::value ||
1310 is_specialization<T, Vec4>::value ||
1311 is_same<T, Rgba8>::value) ? 1 : 0>
1317 static const int Rank = 0;
1318 static const bool IsScalar =
true;
1319 static const bool IsVector =
false;
1320 static const int Size = 1;
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;
1338template<
typename T,
int = sizeof(
typename TensorTraits<T>::ElementType)>
1365template<
typename BuildT>
1408template<
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])));
1416template<
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])));
1424template<
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]))));
1432template<
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]))));
1442template<
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])));
1450template<
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])));
1458template<
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]))));
1466template<
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]))));
1477template<
typename Vec3T>
1498 mCoord[0].minComponent(xyz);
1499 mCoord[1].maxComponent(xyz);
1530template<
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];
1568template<
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__)
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__)
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);
1777#if defined(_MSC_VER) && defined(_M_X64) && (_MSC_VER >= 1928)
1779#elif (defined(__GNUC__) || defined(__clang__))
1780 v = __builtin_popcountll(v);
1783 v = v - ((v >> 1) & uint64_t(0x5555555555555555));
1784 v = (v & uint64_t(0x3333333333333333)) + ((v >> 2) & uint64_t(0x3333333333333333));
1785 v = (((v + (v >> 4)) & uint64_t(0xF0F0F0F0F0F0F0F)) * uint64_t(0x101010101010101)) >> 56;
1787 return static_cast<uint32_t
>(v);
1794template<u
int32_t LOG2DIM>
1797 static constexpr uint32_t SIZE = 1U << (3 * LOG2DIM);
1798 static constexpr uint32_t WORD_COUNT = SIZE >> 6;
1799 uint64_t mWords[WORD_COUNT];
1813 uint32_t sum = 0, n = WORD_COUNT;
1814 for (
const uint64_t* w = mWords; n--; ++w)
1837 mPos = mParent->findNextOn(mPos + 1);
1843 const Mask* mParent;
1849 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1854 const uint64_t v = on ? ~uint64_t(0) : uint64_t(0);
1855 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1862 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1863 mWords[i] = other.mWords[i];
1867 template<
typename WordT>
1871 return reinterpret_cast<const WordT*
>(mWords)[n];
1875 template<
typename MaskT>
1878 static_assert(
sizeof(
Mask) ==
sizeof(MaskT),
"Mismatching sizeof");
1879 static_assert(WORD_COUNT == MaskT::WORD_COUNT,
"Mismatching word count");
1880 static_assert(LOG2DIM == MaskT::LOG2DIM,
"Mismatching LOG2DIM");
1881 auto *src =
reinterpret_cast<const uint64_t*
>(&other);
1882 uint64_t *dst = mWords;
1883 for (uint32_t i = 0; i < WORD_COUNT; ++i) {
1891 for (uint32_t i = 0; i < WORD_COUNT; ++i) {
1892 if (mWords[i] != other.mWords[i])
return false;
1902 __hostdev__ bool isOn(uint32_t n)
const {
return 0 != (mWords[n >> 6] & (uint64_t(1) << (n & 63))); }
1906 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1907 if (mWords[i] != ~uint64_t(0))
1914 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1915 if (mWords[i] != uint64_t(0))
1927 auto &word = mWords[n >> 6];
1929 word &= ~(uint64_t(1) << n);
1930 word |= uint64_t(On) << n;
1939 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1940 mWords[i] = ~uint64_t(0);
1946 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1947 mWords[i] = uint64_t(0);
1953 const uint64_t v = on ? ~uint64_t(0) : uint64_t(0);
1954 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1960 uint32_t n = WORD_COUNT;
1961 for (
auto* w = mWords; n--; ++w)
1972 const uint64_t* w = mWords;
1973 for (; n < WORD_COUNT && !*w; ++w, ++n)
1975 return n == WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(*w);
1979 __hostdev__ uint32_t findNextOn(uint32_t start)
const
1981 uint32_t n = start >> 6;
1982 if (n >= WORD_COUNT)
1984 uint32_t m = start & 63;
1985 uint64_t b = mWords[n];
1986 if (b & (uint64_t(1) << m))
1988 b &= ~uint64_t(0) << m;
1989 while (!b && ++n < WORD_COUNT)
2010 template<
typename Mat4T>
2011 __hostdev__ void set(
const Mat4T& mat,
const Mat4T& invMat,
double taper);
2013 template<
typename Vec3T>
2015 template<
typename Vec3T>
2018 template<
typename Vec3T>
2020 template<
typename Vec3T>
2023 template<
typename Vec3T>
2028 template<
typename Vec3T>
2034 template<
typename Vec3T>
2036 template<
typename Vec3T>
2039 template<
typename Vec3T>
2041 template<
typename Vec3T>
2045template<
typename Mat4T>
2052 mTaperF =
static_cast<float>(taper);
2054 for (
int i = 0; i < 3; ++i) {
2056 *vf++ =
static_cast<float>(mat[3][i]);
2057 for (
int j = 0; j < 3; ++j) {
2059 *mid++ = invMat[j][i];
2060 *mf++ =
static_cast<float>(mat[j][i]);
2061 *mif++ =
static_cast<float>(invMat[j][i]);
2070 static const int MaxNameSize = 256;
2077 char mName[MaxNameSize];
2087 template <
typename T>
2096template<
typename Gr
idOrTreeOrRootT,
int LEVEL>
2100template<
typename Gr
idOrTreeOrRootT>
2103 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2104 using Type =
typename GridOrTreeOrRootT::LeafNodeType;
2105 using type =
typename GridOrTreeOrRootT::LeafNodeType;
2107template<
typename Gr
idOrTreeOrRootT>
2110 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2111 using Type =
const typename GridOrTreeOrRootT::LeafNodeType;
2112 using type =
const typename GridOrTreeOrRootT::LeafNodeType;
2115template<
typename Gr
idOrTreeOrRootT>
2118 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2119 using Type =
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2120 using type =
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2122template<
typename Gr
idOrTreeOrRootT>
2125 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2126 using Type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2127 using type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2129template<
typename Gr
idOrTreeOrRootT>
2132 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2133 using Type =
typename GridOrTreeOrRootT::RootType::ChildNodeType;
2134 using type =
typename GridOrTreeOrRootT::RootType::ChildNodeType;
2136template<
typename Gr
idOrTreeOrRootT>
2139 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2140 using Type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType;
2141 using type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType;
2143template<
typename Gr
idOrTreeOrRootT>
2146 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2147 using Type =
typename GridOrTreeOrRootT::RootType;
2148 using type =
typename GridOrTreeOrRootT::RootType;
2151template<
typename Gr
idOrTreeOrRootT>
2154 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2155 using Type =
const typename GridOrTreeOrRootT::RootType;
2156 using type =
const typename GridOrTreeOrRootT::RootType;
2187 static const int MaxNameSize = 256;
2195 char mGridName[MaxNameSize];
2257 template<
typename Vec3T>
2259 template<
typename Vec3T>
2261 template<
typename Vec3T>
2263 template<
typename Vec3T>
2265 template<
typename Vec3T>
2268 template<
typename Vec3T>
2270 template<
typename Vec3T>
2272 template<
typename Vec3T>
2274 template<
typename Vec3T>
2276 template<
typename Vec3T>
2291 return PtrAdd<GridBlindMetaData>(
this, mBlindMetadataOffset) + n;
2297template <
typename BuildT,
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1>
2300template <
typename BuildT>
2307template<
typename TreeT>
2345 __hostdev__ const TreeT&
tree()
const {
return *
reinterpret_cast<const TreeT*
>(this->treePtr()); }
2360 template<
typename Vec3T>
2364 template<
typename Vec3T>
2369 template<
typename Vec3T>
2374 template<
typename Vec3T>
2379 template<
typename Vec3T>
2383 template<
typename Vec3T>
2387 template<
typename Vec3T>
2392 template<
typename Vec3T>
2397 template<
typename Vec3T>
2402 template<
typename Vec3T>
2437 template <
typename NodeT>
2442 template <
int LEVEL>
2448 if (this->hasLongGridName()) {
2449 const auto &metaData = this->blindMetaData(DataType::mBlindMetadataCount-1);
2451 return metaData.template getBlindData<const char>();
2453 return DataType::mGridName;
2476 if (DataType::mBlindMetadataCount == 0) {
2480 return this->blindMetaData(n).template getBlindData<void>();
2489template<
typename TreeT>
2492 for (uint32_t i = 0, n = this->blindDataCount(); i < n; ++i)
2493 if (this->blindMetaData(i).mSemantic == semantic)
2500template<
int ROOT_LEVEL = 3>
2503 static_assert(
ROOT_LEVEL == 3,
"Root level is assumed to be three");
2504 uint64_t mNodeOffset[4];
2505 uint32_t mNodeCount[3];
2506 uint32_t mTileCount[3];
2509 template <
typename RootT>
2511 template <
typename RootT>
2513 template <
typename RootT>
2516 template <
typename NodeT>
2519 mNodeOffset[NodeT::LEVEL] = node ?
PtrDiff(node,
this) : 0;
2526template<
typename Gr
idT>
2529 using Type =
typename GridT::TreeType;
2530 using type =
typename GridT::TreeType;
2532template<
typename Gr
idT>
2535 using Type =
const typename GridT::TreeType;
2536 using type =
const typename GridT::TreeType;
2542template<
typename RootT>
2545 static_assert(RootT::LEVEL == 3,
"Tree depth is not supported");
2546 static_assert(RootT::ChildNodeType::LOG2DIM == 5,
"Tree configuration is not supported");
2547 static_assert(RootT::ChildNodeType::ChildNodeType::LOG2DIM == 4,
"Tree configuration is not supported");
2548 static_assert(RootT::LeafNodeType::LOG2DIM == 3,
"Tree configuration is not supported");
2560 using Node2 =
typename RootT::ChildNodeType;
2561 using Node1 =
typename Node2::ChildNodeType;
2613 return DataType::mTileCount[n];
2616 template<
typename NodeT>
2619 static_assert(NodeT::LEVEL < 3,
"Invalid NodeT");
2620 return DataType::mNodeCount[NodeT::LEVEL];
2626 return DataType::mNodeCount[level];
2632 template <
typename NodeT>
2635 const uint64_t offset = DataType::mNodeOffset[NodeT::LEVEL];
2636 return offset>0 ? PtrAdd<NodeT>(
this, offset) :
nullptr;
2642 template <
typename NodeT>
2645 const uint64_t offset = DataType::mNodeOffset[NodeT::LEVEL];
2646 return offset>0 ? PtrAdd<NodeT>(
this, offset) :
nullptr;
2652 template <
int LEVEL>
2656 return this->
template getFirstNode<typename NodeTrait<RootT,LEVEL>::type>();
2662 template <
int LEVEL>
2666 return this->
template getFirstNode<typename NodeTrait<RootT,LEVEL>::type>();
2674template<
typename RootT>
2677 min = this->root().minimum();
2678 max = this->root().maximum();
2686template<
typename ChildT>
2693 static constexpr bool FIXED_SIZE =
false;
2696#ifdef USE_SINGLE_ROOT_KEY
2698 template <
typename CoordType>
2701 static_assert(
sizeof(
CoordT) ==
sizeof(CoordType),
"Mismatching sizeof");
2702 static_assert(32 - ChildT::TOTAL <= 21,
"Cannot use 64 bit root keys");
2703 return (
KeyT(uint32_t(ijk[2]) >> ChildT::TOTAL)) |
2704 (
KeyT(uint32_t(ijk[1]) >> ChildT::TOTAL) << 21) |
2705 (
KeyT(uint32_t(ijk[0]) >> ChildT::TOTAL) << 42);
2709 static constexpr uint64_t MASK = (1u << 21) - 1;
2710 return CoordT(((key >> 42) & MASK) << ChildT::TOTAL,
2711 ((key >> 21) & MASK) << ChildT::TOTAL,
2712 (key & MASK) << ChildT::TOTAL);
2715 using KeyT = CoordT;
2716 __hostdev__ static KeyT CoordToKey(
const CoordT& ijk) {
return ijk & ~ChildT::MASK; }
2717 __hostdev__ static CoordT KeyToCoord(
const KeyT& key) {
return key; }
2728 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
Tile
2730 template <
typename CoordType>
2733 key = CoordToKey(k);
2736 template <
typename CoordType,
typename ValueType>
2739 key = CoordToKey(k);
2758 return reinterpret_cast<const Tile*
>(
this + 1) + n;
2763 return reinterpret_cast<Tile*
>(
this + 1) + n;
2772 return PtrAdd<ChildT>(
this, tile->
child);
2777 return PtrAdd<ChildT>(
this, tile->
child);
2798template<
typename ChildT>
2814 static constexpr bool FIXED_SIZE = DataType::FIXED_SIZE;
2816 static constexpr uint32_t LEVEL = 1 + ChildT::LEVEL;
2866 if (
const Tile* tile = this->findTile(ijk)) {
2867 return tile->isChild() ? this->getChild(tile)->getValue(ijk) : tile->value;
2869 return DataType::mBackground;
2874 if (
const Tile* tile = this->findTile(ijk)) {
2875 return tile->isChild() ? this->getChild(tile)->isActive(ijk) : tile->state;
2885 if (
const Tile* tile = this->findTile(ijk)) {
2886 if (tile->isChild()) {
2887 const auto *
child = this->getChild(tile);
2888 return child->probeValue(ijk, v);
2893 v = DataType::mBackground;
2899 const Tile* tile = this->findTile(ijk);
2900 if (tile && tile->isChild()) {
2901 const auto *
child = this->getChild(tile);
2902 return child->probeLeaf(ijk);
2909 static_assert(
sizeof(
typename DataType::Tile) %
NANOVDB_DATA_ALIGNMENT == 0,
"sizeof(RootData::Tile) is misaligned");
2911 template<
typename,
int,
int,
int>
2923 const Tile* tiles =
reinterpret_cast<const Tile*
>(
this + 1);
2924 const auto key = DataType::CoordToKey(ijk);
2926 for (uint32_t i = 0; i < DataType::mTableSize; ++i) {
2927 if (tiles[i].key == key)
return &tiles[i];
2931 int32_t low = 0, high = DataType::mTableSize;
2932 while (low != high) {
2933 int mid = low + ((high - low) >> 1);
2934 const Tile* tile = &tiles[mid];
2935 if (tile->key == key) {
2937 }
else if (tile->key < key) {
2948 template<
typename AccT>
2949 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ijk,
const AccT& acc)
const
2951 using NodeInfoT =
typename AccT::NodeInfo;
2952 if (
const Tile* tile = this->findTile(ijk)) {
2953 if (tile->isChild()) {
2954 const auto *
child = this->getChild(tile);
2955 acc.insert(ijk,
child);
2956 return child->getNodeInfoAndCache(ijk, acc);
2958 return NodeInfoT{LEVEL, ChildT::dim(), tile->value, tile->value, tile->value,
2959 0, tile->origin(), tile->origin() + CoordType(ChildT::DIM)};
2961 return NodeInfoT{LEVEL, ChildT::dim(), this->minimum(), this->maximum(),
2962 this->average(), this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
2966 template<
typename AccT>
2967 __hostdev__ ValueType getValueAndCache(
const CoordType& ijk,
const AccT& acc)
const
2969 if (
const Tile* tile = this->findTile(ijk)) {
2970 if (tile->isChild()) {
2971 const auto *
child = this->getChild(tile);
2972 acc.insert(ijk,
child);
2973 return child->getValueAndCache(ijk, acc);
2977 return DataType::mBackground;
2980 template<
typename AccT>
2981 __hostdev__ bool isActiveAndCache(
const CoordType& ijk,
const AccT& acc)
const
2983 const Tile* tile = this->findTile(ijk);
2984 if (tile && tile->isChild()) {
2985 const auto *
child = this->getChild(tile);
2986 acc.insert(ijk,
child);
2987 return child->isActiveAndCache(ijk, acc);
2992 template<
typename AccT>
2993 __hostdev__ bool probeValueAndCache(
const CoordType& ijk, ValueType& v,
const AccT& acc)
const
2995 if (
const Tile* tile = this->findTile(ijk)) {
2996 if (tile->isChild()) {
2997 const auto *
child = this->getChild(tile);
2998 acc.insert(ijk,
child);
2999 return child->probeValueAndCache(ijk, v, acc);
3004 v = DataType::mBackground;
3008 template<
typename AccT>
3009 __hostdev__ const LeafNodeType* probeLeafAndCache(
const CoordType& ijk,
const AccT& acc)
const
3011 const Tile* tile = this->findTile(ijk);
3012 if (tile && tile->isChild()) {
3013 const auto *
child = this->getChild(tile);
3014 acc.insert(ijk,
child);
3015 return child->probeLeafAndCache(ijk, acc);
3020 template<
typename RayT,
typename AccT>
3021 __hostdev__ uint32_t getDimAndCache(
const CoordType& ijk,
const RayT& ray,
const AccT& acc)
const
3023 if (
const Tile* tile = this->findTile(ijk)) {
3024 if (tile->isChild()) {
3025 const auto *
child = this->getChild(tile);
3026 acc.insert(ijk,
child);
3027 return child->getDimAndCache(ijk, ray, acc);
3029 return 1 << ChildT::TOTAL;
3031 return ChildNodeType::dim();
3042template<
typename ChildT, u
int32_t LOG2DIM>
3049 using MaskT =
typename ChildT::template MaskType<LOG2DIM>;
3050 static constexpr bool FIXED_SIZE =
true;
3072 alignas(32)
Tile mTable[1u << (3 * LOG2DIM)];
3077 mTable[n].child =
PtrDiff(ptr,
this);
3080 template <
typename ValueT>
3084 mTable[n].value = v;
3091 return PtrAdd<ChildT>(
this, mTable[n].
child);
3096 return PtrAdd<ChildT>(
this, mTable[n].
child);
3099 template <
typename T>
3120template<
typename ChildT, u
int32_t Log2Dim = ChildT::LOG2DIM + 1>
3131 static constexpr bool FIXED_SIZE = DataType::FIXED_SIZE;
3132 template<u
int32_t LOG2>
3135 static constexpr uint32_t LOG2DIM = Log2Dim;
3136 static constexpr uint32_t TOTAL = LOG2DIM + ChildT::TOTAL;
3137 static constexpr uint32_t DIM = 1u << TOTAL;
3138 static constexpr uint32_t SIZE = 1u << (3 * LOG2DIM);
3139 static constexpr uint32_t MASK = (1u << TOTAL) - 1u;
3140 static constexpr uint32_t LEVEL = 1 + ChildT::LEVEL;
3141 static constexpr uint64_t NUM_VALUES = uint64_t(1) << (3 * TOTAL);
3189 const uint32_t n = CoordToOffset(ijk);
3190 return DataType::mChildMask.isOn(n) ? this->getChild(n)->getValue(ijk) : DataType::mTable[n].value;
3195 const uint32_t n = CoordToOffset(ijk);
3196 return DataType::mChildMask.isOn(n) ? this->getChild(n)->isActive(ijk) : DataType::mValueMask.isOn(n);
3201 const uint32_t n = CoordToOffset(ijk);
3202 if (DataType::mChildMask.isOn(n))
3203 return this->getChild(n)->probeValue(ijk, v);
3204 v = DataType::mTable[n].value;
3205 return DataType::mValueMask.isOn(n);
3210 const uint32_t n = CoordToOffset(ijk);
3211 if (DataType::mChildMask.isOn(n))
3212 return this->getChild(n)->probeLeaf(ijk);
3220 return (((ijk[0] & MASK) >> ChildT::TOTAL) << (2 * LOG2DIM)) +
3221 (((ijk[1] & MASK) >> ChildT::TOTAL) << (LOG2DIM)) +
3222 ((ijk[2] & MASK) >> ChildT::TOTAL);
3224 return (((ijk[0] & MASK) >> ChildT::TOTAL) << (2 * LOG2DIM)) |
3225 (((ijk[1] & MASK) >> ChildT::TOTAL) << (LOG2DIM)) |
3226 ((ijk[2] & MASK) >> ChildT::TOTAL);
3234 const uint32_t m = n & ((1 << 2 * LOG2DIM) - 1);
3235 return Coord(n >> 2 * LOG2DIM, m >> LOG2DIM, m & ((1 << LOG2DIM) - 1));
3241 ijk <<= ChildT::TOTAL;
3242 ijk += this->origin();
3248 this->localToGlobalCoord(ijk);
3255 return DataType::mFlags & uint32_t(2);
3262 template<
typename,
int,
int,
int>
3267 template<
typename, u
int32_t>
3271 template<
typename AccT>
3274 const uint32_t n = CoordToOffset(ijk);
3275 if (!DataType::mChildMask.isOn(n))
3276 return DataType::mTable[n].value;
3277 const ChildT*
child = this->getChild(n);
3278 acc.insert(ijk,
child);
3279 return child->getValueAndCache(ijk, acc);
3282 template<
typename AccT>
3283 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ijk,
const AccT& acc)
const
3285 using NodeInfoT =
typename AccT::NodeInfo;
3286 const uint32_t n = CoordToOffset(ijk);
3287 if (!DataType::mChildMask.isOn(n)) {
3288 return NodeInfoT{LEVEL, this->dim(), this->minimum(), this->maximum(), this->average(),
3289 this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
3291 const ChildT*
child = this->getChild(n);
3292 acc.insert(ijk,
child);
3293 return child->getNodeInfoAndCache(ijk, acc);
3296 template<
typename AccT>
3297 __hostdev__ bool isActiveAndCache(
const CoordType& ijk,
const AccT& acc)
const
3299 const uint32_t n = CoordToOffset(ijk);
3300 if (!DataType::mChildMask.isOn(n))
3301 return DataType::mValueMask.isOn(n);
3302 const ChildT*
child = this->getChild(n);
3303 acc.insert(ijk,
child);
3304 return child->isActiveAndCache(ijk, acc);
3307 template<
typename AccT>
3308 __hostdev__ bool probeValueAndCache(
const CoordType& ijk, ValueType& v,
const AccT& acc)
const
3310 const uint32_t n = CoordToOffset(ijk);
3311 if (!DataType::mChildMask.isOn(n)) {
3312 v = DataType::mTable[n].value;
3313 return DataType::mValueMask.isOn(n);
3315 const ChildT*
child = this->getChild(n);
3316 acc.insert(ijk,
child);
3317 return child->probeValueAndCache(ijk, v, acc);
3320 template<
typename AccT>
3321 __hostdev__ const LeafNodeType* probeLeafAndCache(
const CoordType& ijk,
const AccT& acc)
const
3323 const uint32_t n = CoordToOffset(ijk);
3324 if (!DataType::mChildMask.isOn(n))
3326 const ChildT*
child = this->getChild(n);
3327 acc.insert(ijk,
child);
3328 return child->probeLeafAndCache(ijk, acc);
3331 template<
typename RayT,
typename AccT>
3332 __hostdev__ uint32_t getDimAndCache(
const CoordType& ijk,
const RayT& ray,
const AccT& acc)
const
3334 if (DataType::mFlags & uint32_t(1))
3338 const uint32_t n = CoordToOffset(ijk);
3339 if (DataType::mChildMask.isOn(n)) {
3340 const ChildT*
child = this->getChild(n);
3341 acc.insert(ijk,
child);
3342 return child->getDimAndCache(ijk, ray, acc);
3344 return ChildNodeType::dim();
3354template<
typename ValueT,
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3357 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3358 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3363 static constexpr bool FIXED_SIZE =
true;
3366 uint8_t mBBoxDif[3];
3381 mValueMask.setOn(offset);
3382 mValues[offset] =
value;
3395 template <
typename T>
3406template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3409 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3410 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3415 uint8_t mBBoxDif[3];
3426 mQuantum = (
max -
min)/
float((1 << bitWidth)-1);
3454 template <
typename T>
3461template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3462struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp4, CoordT, MaskT, LOG2DIM>
3468 static constexpr bool FIXED_SIZE =
true;
3469 alignas(32) uint8_t mCode[1u << (3 * LOG2DIM - 1)];
3475 const uint8_t c = mCode[i>>1];
3476 return ( (i&1) ? c >> 4 : c & uint8_t(15) )*BaseT::mQuantum + BaseT::mMinimum;
3478 return ((mCode[i>>1] >> ((i&1)<<2)) & uint8_t(15))*BaseT::mQuantum + BaseT::mMinimum;
3489template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3490struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp8, CoordT, MaskT, LOG2DIM>
3496 static constexpr bool FIXED_SIZE =
true;
3497 alignas(32) uint8_t mCode[1u << 3 * LOG2DIM];
3502 return mCode[i]*BaseT::mQuantum + BaseT::mMinimum;
3511template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3512struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp16, CoordT, MaskT, LOG2DIM>
3518 static constexpr bool FIXED_SIZE =
true;
3519 alignas(32) uint16_t mCode[1u << 3 * LOG2DIM];
3524 return mCode[i]*BaseT::mQuantum + BaseT::mMinimum;
3534template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3535struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
FpN, CoordT, MaskT, LOG2DIM>
3540 static constexpr bool FIXED_SIZE =
false;
3547#ifdef NANOVDB_FPN_BRANCHLESS
3548 const int b = BaseT::mFlags >> 5;
3550 uint16_t code =
reinterpret_cast<const uint16_t*
>(
this + 1)[i >> (4 - b)];
3551 const static uint8_t shift[5] = {15, 7, 3, 1, 0};
3552 const static uint16_t mask[5] = {1, 3, 15, 255, 65535};
3553 code >>= (i & shift[b]) << b;
3556 uint32_t code =
reinterpret_cast<const uint32_t*
>(
this + 1)[i >> (5 - b)];
3558 code >>= (i & ((32 >> b) - 1)) << b;
3559 code &= (1 << (1 << b)) - 1;
3563 auto *values =
reinterpret_cast<const uint8_t*
>(
this+1);
3564 switch (BaseT::mFlags >> 5) {
3566 code = float((values[i>>3] >> (i&7) ) & uint8_t(1));
3569 code = float((values[i>>2] >> ((i&3)<<1)) & uint8_t(3));
3572 code = float((values[i>>1] >> ((i&1)<<2)) & uint8_t(15));
3575 code = float(values[i]);
3578 code = float(
reinterpret_cast<const uint16_t*
>(values)[i]);
3581 return float(code) * BaseT::mQuantum + BaseT::mMinimum;
3592template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3593struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<bool, CoordT, MaskT, LOG2DIM>
3595 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3596 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3601 static constexpr bool FIXED_SIZE =
true;
3604 uint8_t mBBoxDif[3];
3617 mValueMask.setOn(offset);
3618 mValues.set(offset, v);
3626 template <
typename T>
3637template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3640 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3641 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3646 static constexpr bool FIXED_SIZE =
true;
3649 uint8_t mBBoxDif[3];
3661 mValueMask.setOn(offset);
3669 template <
typename T>
3680template<
typename BuildT,
3681 typename CoordT =
Coord,
3682 template<u
int32_t>
class MaskT =
Mask,
3683 uint32_t Log2Dim = 3>
3697 static constexpr bool FIXED_SIZE = DataType::FIXED_SIZE;
3698 template<u
int32_t LOG2>
3702 static constexpr uint32_t LOG2DIM = Log2Dim;
3703 static constexpr uint32_t TOTAL = LOG2DIM;
3704 static constexpr uint32_t DIM = 1u << TOTAL;
3705 static constexpr uint32_t SIZE = 1u << 3 * LOG2DIM;
3706 static constexpr uint32_t MASK = (1u << LOG2DIM) - 1u;
3707 static constexpr uint32_t LEVEL = 0;
3708 static constexpr uint64_t NUM_VALUES = uint64_t(1) << (3 * TOTAL);
3740 const uint32_t m = n & ((1 << 2 * LOG2DIM) - 1);
3741 return CoordT(n >> 2 * LOG2DIM, m >> LOG2DIM, m & MASK);
3749 return OffsetToLocalCoord(n) + this->origin();
3758 BBox<CoordT> bbox(DataType::mBBoxMin, DataType::mBBoxMin);
3759 if ( this->isActive() ) {
3760 bbox.max()[0] += DataType::mBBoxDif[0];
3761 bbox.max()[1] += DataType::mBBoxDif[1];
3762 bbox.max()[2] += DataType::mBBoxDif[2];
3805 NANOVDB_ASSERT(
bool(DataType::mFlags & uint8_t(2)) != DataType::mValueMask.isOff() );
3806 return DataType::mFlags & uint8_t(2);
3813 const uint32_t n = CoordToOffset(ijk);
3814 v = DataType::getValue(n);
3815 return DataType::mValueMask.isOn(n);
3824 return ((ijk[0] & MASK) << (2 * LOG2DIM)) + ((ijk[1] & MASK) << LOG2DIM) + (ijk[2] & MASK);
3826 return ((ijk[0] & MASK) << (2 * LOG2DIM)) | ((ijk[1] & MASK) << LOG2DIM) | (ijk[2] & MASK);
3843 template<
typename,
int,
int,
int>
3848 template<
typename, u
int32_t>
3852 template<
typename AccT>
3853 __hostdev__ ValueType getValueAndCache(
const CoordT& ijk,
const AccT&)
const {
return this->getValue(ijk); }
3856 template<
typename AccT>
3857 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ,
const AccT& )
const {
3858 using NodeInfoT =
typename AccT::NodeInfo;
3859 return NodeInfoT{LEVEL, this->dim(), this->minimum(), this->maximum(),
3860 this->average(), this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
3863 template<
typename AccT>
3864 __hostdev__ bool isActiveAndCache(
const CoordT& ijk,
const AccT&)
const {
return this->isActive(ijk); }
3866 template<
typename AccT>
3867 __hostdev__ bool probeValueAndCache(
const CoordT& ijk, ValueType& v,
const AccT&)
const {
return this->probeValue(ijk, v); }
3869 template<
typename AccT>
3870 __hostdev__ const LeafNode* probeLeafAndCache(
const CoordT&,
const AccT&)
const {
return this; }
3872 template<
typename RayT,
typename AccT>
3873 __hostdev__ uint32_t getDimAndCache(
const CoordT&,
const RayT& ,
const AccT&)
const
3875 if (DataType::mFlags & uint8_t(1))
3878 return ChildNodeType::dim();
3883template<
typename ValueT,
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3886 static_assert(LOG2DIM == 3,
"LeafNode::updateBBox: only supports LOGDIM = 3!");
3887 if (!this->isActive())
return;
3888 auto update = [&](uint32_t
min, uint32_t
max,
int axis) {
3890 DataType::mBBoxMin[axis] = (DataType::mBBoxMin[axis] & ~MASK) +
int(
min);
3891 DataType::mBBoxDif[axis] = uint8_t(
max -
min);
3893 uint64_t word64 = DataType::mValueMask.template getWord<uint64_t>(0);
3894 uint32_t Xmin = word64 ? 0u : 8u;
3895 uint32_t Xmax = Xmin;
3896 for (
int i = 1; i < 8; ++i) {
3897 if (uint64_t w = DataType::mValueMask.
template getWord<uint64_t>(i)) {
3906 update(Xmin, Xmax, 0);
3908 const uint32_t *p =
reinterpret_cast<const uint32_t*
>(&word64), word32 = p[0] | p[1];
3909 const uint16_t *q =
reinterpret_cast<const uint16_t*
>(&word32), word16 = q[0] | q[1];
3910 const uint8_t *b =
reinterpret_cast<const uint8_t*
>(&word16),
byte = b[0] | b[1];
3919template<
typename BuildT>
3921template<
typename BuildT>
3923template<
typename BuildT>
3925template<
typename BuildT>
3927template<
typename BuildT>
3929template<
typename BuildT>
3933template<
typename BuildT,
int LEVEL>
3937template<
typename BuildT>
3943template<
typename BuildT>
3949template<
typename BuildT>
3955template<
typename BuildT>
4009template <
typename BuildT>
4017 mutable const RootT* mRoot;
4022 static const int CacheLevels = 0;
4047 return mRoot->getValueAndCache(ijk, *
this);
4052 return mRoot->getNodeInfoAndCache(ijk, *
this);
4057 return mRoot->isActiveAndCache(ijk, *
this);
4062 return mRoot->probeValueAndCache(ijk, v, *
this);
4067 return mRoot->probeLeafAndCache(ijk, *
this);
4070 template<
typename RayT>
4073 return mRoot->getDimAndCache(ijk, ray, *
this);
4080 template<
typename, u
int32_t>
4082 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4086 template<
typename NodeT>
4091template <
typename BuildT,
int LEVEL0>
4094 static_assert(LEVEL0 >= 0 && LEVEL0 <= 2,
"LEVEL0 should be 0, 1, or 2");
4107 mutable CoordT mKey;
4108 mutable const RootT* mRoot;
4109 mutable const NodeT* mNode;
4115 static const int CacheLevels = 1;
4136 return (ijk[0] & int32_t(~NodeT::MASK)) == mKey[0] &&
4137 (ijk[1] & int32_t(~NodeT::MASK)) == mKey[1] &&
4138 (ijk[2] & int32_t(~NodeT::MASK)) == mKey[2];
4143 if (this->isCached(ijk)) {
4144 return mNode->getValueAndCache(ijk, *
this);
4146 return mRoot->getValueAndCache(ijk, *
this);
4151 if (this->isCached(ijk)) {
4152 return mNode->getNodeInfoAndCache(ijk, *
this);
4154 return mRoot->getNodeInfoAndCache(ijk, *
this);
4159 if (this->isCached(ijk)) {
4160 return mNode->isActiveAndCache(ijk, *
this);
4162 return mRoot->isActiveAndCache(ijk, *
this);
4167 if (this->isCached(ijk)) {
4168 return mNode->probeValueAndCache(ijk, v, *
this);
4170 return mRoot->probeValueAndCache(ijk, v, *
this);
4175 if (this->isCached(ijk)) {
4176 return mNode->probeLeafAndCache(ijk, *
this);
4178 return mRoot->probeLeafAndCache(ijk, *
this);
4181 template<
typename RayT>
4184 if (this->isCached(ijk)) {
4185 return mNode->getDimAndCache(ijk, ray, *
this);
4187 return mRoot->getDimAndCache(ijk, ray, *
this);
4194 template<
typename, u
int32_t>
4196 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4202 mKey = ijk & ~NodeT::MASK;
4207 template<
typename OtherNodeT>
4208 __hostdev__ void insert(
const CoordType&,
const OtherNodeT*)
const {}
4212template <
typename BuildT,
int LEVEL0,
int LEVEL1>
4215 static_assert(LEVEL0 >= 0 && LEVEL0 <= 2,
"LEVEL0 must be 0, 1, 2");
4216 static_assert(LEVEL1 >= 0 && LEVEL1 <= 2,
"LEVEL1 must be 0, 1, 2");
4217 static_assert(LEVEL0 < LEVEL1,
"Level 0 must be lower than level 1");
4229#ifdef USE_SINGLE_ACCESSOR_KEY
4230 mutable CoordT mKey;
4232 mutable CoordT mKeys[2];
4234 mutable const RootT* mRoot;
4235 mutable const Node1T* mNode1;
4236 mutable const Node2T* mNode2;
4242 static const int CacheLevels = 2;
4248#ifdef USE_SINGLE_ACCESSOR_KEY
4266#ifdef USE_SINGLE_ACCESSOR_KEY
4267 __hostdev__ bool isCached1(CoordValueType dirty)
const
4271 if (dirty & int32_t(~Node1T::MASK)) {
4277 __hostdev__ bool isCached2(CoordValueType dirty)
const
4281 if (dirty & int32_t(~Node2T::MASK)) {
4287 __hostdev__ CoordValueType computeDirty(
const CoordType& ijk)
const
4289 return (ijk[0] ^ mKey[0]) | (ijk[1] ^ mKey[1]) | (ijk[2] ^ mKey[2]);
4294 return (ijk[0] & int32_t(~Node1T::MASK)) == mKeys[0][0] &&
4295 (ijk[1] & int32_t(~Node1T::MASK)) == mKeys[0][1] &&
4296 (ijk[2] & int32_t(~Node1T::MASK)) == mKeys[0][2];
4300 return (ijk[0] & int32_t(~Node2T::MASK)) == mKeys[1][0] &&
4301 (ijk[1] & int32_t(~Node2T::MASK)) == mKeys[1][1] &&
4302 (ijk[2] & int32_t(~Node2T::MASK)) == mKeys[1][2];
4308#ifdef USE_SINGLE_ACCESSOR_KEY
4309 const CoordValueType dirty = this->computeDirty(ijk);
4313 if (this->isCached1(dirty)) {
4314 return mNode1->getValueAndCache(ijk, *
this);
4315 }
else if (this->isCached2(dirty)) {
4316 return mNode2->getValueAndCache(ijk, *
this);
4318 return mRoot->getValueAndCache(ijk, *
this);
4323#ifdef USE_SINGLE_ACCESSOR_KEY
4324 const CoordValueType dirty = this->computeDirty(ijk);
4328 if (this->isCached1(dirty)) {
4329 return mNode1->getNodeInfoAndCache(ijk, *
this);
4330 }
else if (this->isCached2(dirty)) {
4331 return mNode2->getNodeInfoAndCache(ijk, *
this);
4333 return mRoot->getNodeInfoAndCache(ijk, *
this);
4338#ifdef USE_SINGLE_ACCESSOR_KEY
4339 const CoordValueType dirty = this->computeDirty(ijk);
4343 if (this->isCached1(dirty)) {
4344 return mNode1->isActiveAndCache(ijk, *
this);
4345 }
else if (this->isCached2(dirty)) {
4346 return mNode2->isActiveAndCache(ijk, *
this);
4348 return mRoot->isActiveAndCache(ijk, *
this);
4353#ifdef USE_SINGLE_ACCESSOR_KEY
4354 const CoordValueType dirty = this->computeDirty(ijk);
4358 if (this->isCached1(dirty)) {
4359 return mNode1->probeValueAndCache(ijk, v, *
this);
4360 }
else if (this->isCached2(dirty)) {
4361 return mNode2->probeValueAndCache(ijk, v, *
this);
4363 return mRoot->probeValueAndCache(ijk, v, *
this);
4368#ifdef USE_SINGLE_ACCESSOR_KEY
4369 const CoordValueType dirty = this->computeDirty(ijk);
4373 if (this->isCached1(dirty)) {
4374 return mNode1->probeLeafAndCache(ijk, *
this);
4375 }
else if (this->isCached2(dirty)) {
4376 return mNode2->probeLeafAndCache(ijk, *
this);
4378 return mRoot->probeLeafAndCache(ijk, *
this);
4381 template<
typename RayT>
4384#ifdef USE_SINGLE_ACCESSOR_KEY
4385 const CoordValueType dirty = this->computeDirty(ijk);
4389 if (this->isCached1(dirty)) {
4390 return mNode1->getDimAndCache(ijk, ray, *
this);
4391 }
else if (this->isCached2(dirty)) {
4392 return mNode2->getDimAndCache(ijk, ray, *
this);
4394 return mRoot->getDimAndCache(ijk, ray, *
this);
4401 template<
typename, u
int32_t>
4403 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4409#ifdef USE_SINGLE_ACCESSOR_KEY
4412 mKeys[0] = ijk & ~Node1T::MASK;
4416 __hostdev__ void insert(
const CoordType& ijk,
const Node2T* node)
const
4418#ifdef USE_SINGLE_ACCESSOR_KEY
4421 mKeys[1] = ijk & ~Node2T::MASK;
4425 template <
typename OtherNodeT>
4426 __hostdev__ void insert(
const CoordType&,
const OtherNodeT*)
const {}
4431template <
typename BuildT>
4446#ifdef USE_SINGLE_ACCESSOR_KEY
4447 mutable CoordT mKey;
4449 mutable CoordT mKeys[3];
4451 mutable const RootT* mRoot;
4452 mutable const void* mNode[3];
4458 static const int CacheLevels = 3;
4464#ifdef USE_SINGLE_ACCESSOR_KEY
4470 , mNode{
nullptr,
nullptr,
nullptr}
4484 template<
typename NodeT>
4489 return reinterpret_cast<const T*
>(mNode[NodeT::LEVEL]);
4492#ifdef USE_SINGLE_ACCESSOR_KEY
4493 template<
typename NodeT>
4494 __hostdev__ bool isCached(CoordValueType dirty)
const
4496 if (!mNode[NodeT::LEVEL])
4498 if (dirty & int32_t(~NodeT::MASK)) {
4499 mNode[NodeT::LEVEL] =
nullptr;
4505 __hostdev__ CoordValueType computeDirty(
const CoordType& ijk)
const
4507 return (ijk[0] ^ mKey[0]) | (ijk[1] ^ mKey[1]) | (ijk[2] ^ mKey[2]);
4510 template<
typename NodeT>
4513 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];
4519#ifdef USE_SINGLE_ACCESSOR_KEY
4520 const CoordValueType dirty = this->computeDirty(ijk);
4524 if (this->isCached<LeafT>(dirty)) {
4525 return ((
LeafT*)mNode[0])->getValue(ijk);
4526 }
else if (this->isCached<NodeT1>(dirty)) {
4527 return ((
NodeT1*)mNode[1])->getValueAndCache(ijk, *
this);
4528 }
else if (this->isCached<NodeT2>(dirty)) {
4529 return ((
NodeT2*)mNode[2])->getValueAndCache(ijk, *
this);
4531 return mRoot->getValueAndCache(ijk, *
this);
4536#ifdef USE_SINGLE_ACCESSOR_KEY
4537 const CoordValueType dirty = this->computeDirty(ijk);
4541 if (this->isCached<LeafT>(dirty)) {
4542 return ((
LeafT*)mNode[0])->getNodeInfoAndCache(ijk, *
this);
4543 }
else if (this->isCached<NodeT1>(dirty)) {
4544 return ((
NodeT1*)mNode[1])->getNodeInfoAndCache(ijk, *
this);
4545 }
else if (this->isCached<NodeT2>(dirty)) {
4546 return ((
NodeT2*)mNode[2])->getNodeInfoAndCache(ijk, *
this);
4548 return mRoot->getNodeInfoAndCache(ijk, *
this);
4553#ifdef USE_SINGLE_ACCESSOR_KEY
4554 const CoordValueType dirty = this->computeDirty(ijk);
4558 if (this->isCached<LeafT>(dirty)) {
4559 return ((
LeafT*)mNode[0])->isActive(ijk);
4560 }
else if (this->isCached<NodeT1>(dirty)) {
4561 return ((
NodeT1*)mNode[1])->isActiveAndCache(ijk, *
this);
4562 }
else if (this->isCached<NodeT2>(dirty)) {
4563 return ((
NodeT2*)mNode[2])->isActiveAndCache(ijk, *
this);
4565 return mRoot->isActiveAndCache(ijk, *
this);
4570#ifdef USE_SINGLE_ACCESSOR_KEY
4571 const CoordValueType dirty = this->computeDirty(ijk);
4575 if (this->isCached<LeafT>(dirty)) {
4576 return ((
LeafT*)mNode[0])->probeValue(ijk, v);
4577 }
else if (this->isCached<NodeT1>(dirty)) {
4578 return ((
NodeT1*)mNode[1])->probeValueAndCache(ijk, v, *
this);
4579 }
else if (this->isCached<NodeT2>(dirty)) {
4580 return ((
NodeT2*)mNode[2])->probeValueAndCache(ijk, v, *
this);
4582 return mRoot->probeValueAndCache(ijk, v, *
this);
4587#ifdef USE_SINGLE_ACCESSOR_KEY
4588 const CoordValueType dirty = this->computeDirty(ijk);
4592 if (this->isCached<LeafT>(dirty)) {
4593 return ((
LeafT*)mNode[0]);
4594 }
else if (this->isCached<NodeT1>(dirty)) {
4595 return ((
NodeT1*)mNode[1])->probeLeafAndCache(ijk, *
this);
4596 }
else if (this->isCached<NodeT2>(dirty)) {
4597 return ((
NodeT2*)mNode[2])->probeLeafAndCache(ijk, *
this);
4599 return mRoot->probeLeafAndCache(ijk, *
this);
4602 template<
typename RayT>
4605#ifdef USE_SINGLE_ACCESSOR_KEY
4606 const CoordValueType dirty = this->computeDirty(ijk);
4610 if (this->isCached<LeafT>(dirty)) {
4611 return ((
LeafT*)mNode[0])->getDimAndCache(ijk, ray, *
this);
4612 }
else if (this->isCached<NodeT1>(dirty)) {
4613 return ((
NodeT1*)mNode[1])->getDimAndCache(ijk, ray, *
this);
4614 }
else if (this->isCached<NodeT2>(dirty)) {
4615 return ((
NodeT2*)mNode[2])->getDimAndCache(ijk, ray, *
this);
4617 return mRoot->getDimAndCache(ijk, ray, *
this);
4624 template<
typename, u
int32_t>
4626 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4630 template<
typename NodeT>
4633#ifdef USE_SINGLE_ACCESSOR_KEY
4636 mKeys[NodeT::LEVEL] = ijk & ~NodeT::MASK;
4638 mNode[NodeT::LEVEL] = node;
4656template <
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
4662template <
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
4668template <
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
4720template<
typename AttT>
4731 :
AccT(grid.tree().root())
4733 , mData(reinterpret_cast<const AttT*>(grid.blindData(0)))
4746 end = begin + count;
4754 auto* leaf = this->probeLeaf(ijk);
4755 if (leaf ==
nullptr) {
4758 begin = mData + leaf->minimum();
4759 end = begin + leaf->maximum();
4760 return leaf->maximum();
4766 auto* leaf = this->probeLeaf(ijk);
4767 if (leaf ==
nullptr)
4769 const uint32_t offset = LeafNodeType::CoordToOffset(ijk);
4770 if (leaf->isActive(offset)) {
4771 auto* p = mData + leaf->minimum();
4772 begin = p + (offset == 0 ? 0 : leaf->getValue(offset - 1));
4773 end = p + leaf->getValue(offset);
#define ROOT_LEVEL
Definition: CNanoVDB.h:53
ValueT value
Definition: GridBuilder.h:1287
ChildT * child
Definition: GridBuilder.h:1286
#define NANOVDB_HOSTDEV_DISABLE_WARNING
Definition: NanoVDB.h:178
#define NANOVDB_MINOR_VERSION_NUMBER
Definition: NanoVDB.h:105
#define NANOVDB_DATA_ALIGNMENT
Definition: NanoVDB.h:116
#define __hostdev__
Definition: NanoVDB.h:168
#define NANOVDB_MAJOR_VERSION_NUMBER
Definition: NanoVDB.h:104
#define NANOVDB_ASSERT(x)
Definition: NanoVDB.h:149
#define NANOVDB_MAGIC_NUMBER
Definition: NanoVDB.h:102
#define NANOVDB_PATCH_VERSION_NUMBER
Definition: NanoVDB.h:106
const CoordT & operator*() const
Definition: NanoVDB.h:1608
Iterator(const BBox &b)
Definition: NanoVDB.h:1581
Iterator operator++(int)
Definition: NanoVDB.h:1600
Iterator & operator++()
Definition: NanoVDB.h:1586
Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord.
Definition: NanoVDB.h:860
Coord & operator&=(int n)
Definition: NanoVDB.h:940
Coord operator-(const Coord &rhs) const
Definition: NanoVDB.h:962
Vec3< double > asVec3d() const
Return a double precision floating-point vector of this coordinate.
Definition: NanoVDB.h:1182
uint32_t IndexType
Definition: NanoVDB.h:864
Coord operator<<(IndexType n) const
Definition: NanoVDB.h:926
static Coord Floor(const Vec3T &xyz)
Return the largest integer coordinates that are not greater than xyz (node centered conversion).
Definition: NanoVDB.h:1019
Coord(ValueType n)
Initializes all coordinates to the given signed integer.
Definition: NanoVDB.h:873
Coord & operator-=(const Coord &rhs)
Definition: NanoVDB.h:970
Coord & minComponent(const Coord &other)
Perform a component-wise minimum with the other Coord.
Definition: NanoVDB.h:979
Coord operator+(const Coord &rhs) const
Definition: NanoVDB.h:961
static size_t memUsage()
Definition: NanoVDB.h:901
bool operator<(const Coord &rhs) const
Return true if this Coord is lexicographically less than the given Coord.
Definition: NanoVDB.h:932
Coord & operator+=(const Coord &rhs)
Definition: NanoVDB.h:963
Coord & operator=(const CoordT &other)
Assignment operator that works with openvdb::Coord.
Definition: NanoVDB.h:913
int32_t y() const
Definition: NanoVDB.h:890
Coord & maxComponent(const Coord &other)
Perform a component-wise maximum with the other Coord.
Definition: NanoVDB.h:991
Coord operator&(IndexType n) const
Return a new instance with coordinates masked by the given unsigned integer.
Definition: NanoVDB.h:923
Coord()
Initialize all coordinates to zero.
Definition: NanoVDB.h:867
uint8_t octant() const
Return the octant of this Coord.
Definition: NanoVDB.h:1028
const ValueType & operator[](IndexType i) const
Return a const reference to the given Coord component.
Definition: NanoVDB.h:905
int32_t z() const
Definition: NanoVDB.h:891
Coord & operator<<=(uint32_t n)
Definition: NanoVDB.h:947
int32_t x() const
Definition: NanoVDB.h:889
Coord(ValueType i, ValueType j, ValueType k)
Initializes coordinate to the given signed integers.
Definition: NanoVDB.h:879
int32_t & y()
Definition: NanoVDB.h:894
Coord offsetBy(ValueType n) const
Definition: NanoVDB.h:1007
int32_t & x()
Definition: NanoVDB.h:893
Coord(ValueType *ptr)
Definition: NanoVDB.h:884
bool operator!=(const Coord &rhs) const
Definition: NanoVDB.h:939
static Coord min()
Definition: NanoVDB.h:899
ValueType & operator[](IndexType i)
Return a non-const reference to the given Coord component.
Definition: NanoVDB.h:909
bool operator==(const Coord &rhs) const
Definition: NanoVDB.h:938
Vec3< float > asVec3s() const
Return a single precision floating-point vector of this coordinate.
Definition: NanoVDB.h:1179
Coord offsetBy(ValueType dx, ValueType dy, ValueType dz) const
Definition: NanoVDB.h:1002
static Coord max()
Definition: NanoVDB.h:897
int32_t & z()
Definition: NanoVDB.h:895
static bool lessThan(const Coord &a, const Coord &b)
Definition: NanoVDB.h:1011
Coord operator>>(IndexType n) const
Definition: NanoVDB.h:929
uint32_t hash() const
Return a hash key derived from the existing coordinates.
Definition: NanoVDB.h:1024
int32_t ValueType
Definition: NanoVDB.h:863
Coord & operator+=(int n)
Definition: NanoVDB.h:954
Dummy type for a 16bit quantization of float point values.
Definition: NanoVDB.h:201
Dummy type for a 4bit quantization of float point values.
Definition: NanoVDB.h:195
Dummy type for a 8bit quantization of float point values.
Definition: NanoVDB.h:198
Dummy type for a variable bit quantization of floating point values.
Definition: NanoVDB.h:204
Highest level of the data structure. Contains a tree and a world->index transform (that currently onl...
Definition: NanoVDB.h:2309
Vec3T indexToWorld(const Vec3T &xyz) const
index to world space transformation
Definition: NanoVDB.h:2365
const GridBlindMetaData & blindMetaData(int n) const
Definition: NanoVDB.h:2483
Vec3T indexToWorldF(const Vec3T &xyz) const
index to world space transformation
Definition: NanoVDB.h:2388
const GridType & gridType() const
Definition: NanoVDB.h:2419
typename TreeT::ValueType ValueType
Definition: NanoVDB.h:2314
int findBlindDataForSemantic(GridBlindDataSemantic semantic) const
Return the index of the blind data with specified semantic if found, otherwise -1.
Definition: NanoVDB.h:2490
typename TreeT::RootType RootType
Definition: NanoVDB.h:2312
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:2438
bool isPointData() const
Definition: NanoVDB.h:2425
uint32_t gridIndex() const
Return index of this grid in the buffer.
Definition: NanoVDB.h:2339
const char * shortGridName() const
Return a c-string with the name of this grid, truncated to 255 characters.
Definition: NanoVDB.h:2457
bool isBreadthFirst() const
Definition: NanoVDB.h:2433
uint64_t activeVoxelCount() const
Return the total number of active voxels in this tree.
Definition: NanoVDB.h:2415
Vec3T indexToWorldDirF(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition: NanoVDB.h:2393
typename TreeT::CoordType CoordType
Definition: NanoVDB.h:2316
Vec3T worldToIndexF(const Vec3T &xyz) const
world to index space transformation
Definition: NanoVDB.h:2384
Vec3T worldToIndexDirF(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition: NanoVDB.h:2398
const Vec3R & voxelSize() const
Return a const reference to the size of a voxel in world units.
Definition: NanoVDB.h:2354
bool isStaggered() const
Definition: NanoVDB.h:2423
const GridClass & gridClass() const
Definition: NanoVDB.h:2420
bool isValid() const
Methods related to the classification of this grid.
Definition: NanoVDB.h:2418
DataType * data()
Definition: NanoVDB.h:2328
bool hasAverage() const
Definition: NanoVDB.h:2431
bool hasMinMax() const
Definition: NanoVDB.h:2428
const char * gridName() const
Return a c-string with the name of this grid.
Definition: NanoVDB.h:2446
const BBox< Vec3R > & worldBBox() const
Computes a AABB of active values in world space.
Definition: NanoVDB.h:2406
AccessorType getAccessor() const
Return a new instance of a ReadAccessor used to access values in this grid.
Definition: NanoVDB.h:2351
uint64_t gridSize() const
Return the memory footprint of the entire grid, i.e. including all nodes and blind data.
Definition: NanoVDB.h:2336
Vec3T indexToWorldDir(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition: NanoVDB.h:2370
int blindDataCount() const
Return the count of blind-data encoded in this grid.
Definition: NanoVDB.h:2466
Vec3T indexToWorldGradF(const Vec3T &grad) const
Transforms the gradient from index space to world space.
Definition: NanoVDB.h:2403
uint64_t checksum() const
Return checksum of the grid buffer.
Definition: NanoVDB.h:2460
bool isFogVolume() const
Definition: NanoVDB.h:2422
const TreeT & tree() const
Return a const reference to the tree.
Definition: NanoVDB.h:2345
bool isMask() const
Definition: NanoVDB.h:2426
const BBox< CoordType > & indexBBox() const
Computes a AABB of active values in index space.
Definition: NanoVDB.h:2412
bool hasLongGridName() const
Definition: NanoVDB.h:2430
const void * blindData(uint32_t n) const
Returns a const pointer to the blindData at the specified linear offset.
Definition: NanoVDB.h:2474
static uint64_t memUsage()
Return memory usage in bytes for this class only.
Definition: NanoVDB.h:2333
TreeT & tree()
Return a non-const reference to the tree.
Definition: NanoVDB.h:2348
Vec3T worldToIndex(const Vec3T &xyz) const
world to index space transformation
Definition: NanoVDB.h:2361
uint32_t gridCount() const
Return total number of grids in the buffer.
Definition: NanoVDB.h:2342
Vec3T worldToIndexDir(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition: NanoVDB.h:2375
Version version() const
Definition: NanoVDB.h:2326
bool isEmpty() const
Return true if this grid is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:2463
const Map & map() const
Return a const reference to the Map for this grid.
Definition: NanoVDB.h:2357
bool hasStdDeviation() const
Definition: NanoVDB.h:2432
bool hasBBox() const
Definition: NanoVDB.h:2429
bool isLevelSet() const
Definition: NanoVDB.h:2421
TreeT TreeType
Definition: NanoVDB.h:2311
Grid(const Grid &)=delete
Disallow constructions, copy and assignment.
typename TreeT::BuildType BuildType
Definition: NanoVDB.h:2315
Grid & operator=(const Grid &)=delete
Vec3T indexToWorldGrad(const Vec3T &grad) const
transform the gradient from index space to world space.
Definition: NanoVDB.h:2380
const DataType * data() const
Definition: NanoVDB.h:2330
bool isPointIndex() const
Definition: NanoVDB.h:2424
bool isUnknown() const
Definition: NanoVDB.h:2427
Dummy type for a 16 bit floating point values.
Definition: NanoVDB.h:192
Internal nodes of a VDB treedim(),.
Definition: NanoVDB.h:3122
Coord offsetToGlobalCoord(uint32_t n) const
Definition: NanoVDB.h:3245
const MaskType< LOG2DIM > & valueMask() const
Return a const reference to the bit mask of active voxels in this internal node.
Definition: NanoVDB.h:3160
bool isActive() const
Retrun true if this node or any of its child nodes contain active values.
Definition: NanoVDB.h:3253
static uint32_t dim()
Return the dimension, in voxel units, of this internal node (typically 8*16 or 8*16*32)
Definition: NanoVDB.h:3154
static size_t memUsage()
Return memory usage in bytes for the class.
Definition: NanoVDB.h:3157
CoordType origin() const
Return the origin in index space of this leaf node.
Definition: NanoVDB.h:3166
typename ChildT::CoordType CoordType
Definition: NanoVDB.h:3130
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:3184
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:3178
const MaskType< LOG2DIM > & childMask() const
Return a const reference to the bit mask of child nodes in this internal node.
Definition: NanoVDB.h:3163
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:3175
DataType * data()
Definition: NanoVDB.h:3149
void localToGlobalCoord(Coord &ijk) const
modifies local coordinates to global coordinates of a tile or child node
Definition: NanoVDB.h:3239
typename DataType::BuildT BuildType
Definition: NanoVDB.h:3127
ChildT ChildNodeType
Definition: NanoVDB.h:3129
const LeafNodeType * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:3208
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:3193
typename DataType::ValueT ValueType
Definition: NanoVDB.h:3125
static uint32_t CoordToOffset(const CoordType &ijk)
Return the linear offset corresponding to the given coordinate.
Definition: NanoVDB.h:3217
typename DataType::StatsT FloatType
Definition: NanoVDB.h:3126
static Coord OffsetToLocalCoord(uint32_t n)
Definition: NanoVDB.h:3231
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:3199
typename ChildT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:3128
const FloatType & stdDeviation() const
Return a const reference to the standard deviation of all the active values encoded in this internal ...
Definition: NanoVDB.h:3181
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:3172
InternalNode()=delete
This class cannot be constructed or deleted.
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel.
Definition: NanoVDB.h:3187
typename ChildT::template MaskType< LOG2 > MaskType
Definition: NanoVDB.h:3133
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:3169
const DataType * data() const
Definition: NanoVDB.h:3151
InternalNode & operator=(const InternalNode &)=delete
InternalNode(const InternalNode &)=delete
Leaf nodes of the VDB tree. (defaults to 8x8x8 = 512 voxels)
Definition: NanoVDB.h:3685
void setValue(const CoordT &ijk, const ValueType &v)
Sets the value at the specified location and activate its state.
Definition: NanoVDB.h:3790
void setValueOnly(uint32_t offset, const ValueType &v)
Sets the value at the specified location but leaves its state unchanged.
Definition: NanoVDB.h:3795
bool isActive(const CoordT &ijk) const
Return true if the voxel value at the given coordinate is active.
Definition: NanoVDB.h:3799
typename DataType::BuildType BuildType
Definition: NanoVDB.h:3695
const MaskType< LOG2DIM > & valueMask() const
Return a const reference to the bit mask of active voxels in this leaf node.
Definition: NanoVDB.h:3715
bool isActive() const
Return true if any of the voxel value are active in this leaf node.
Definition: NanoVDB.h:3803
CoordT CoordType
Definition: NanoVDB.h:3696
static uint32_t dim()
Return the dimension, in index space, of this leaf node (typically 8 as for openvdb leaf nodes!...
Definition: NanoVDB.h:3753
void updateBBox()
Updates the local bounding box of active voxels in this node.
Definition: NanoVDB.h:3884
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:3811
FloatType variance() const
Return the variance of all the active values encoded in this leaf node.
Definition: NanoVDB.h:3727
LeafNode & operator=(const LeafNode &)=delete
bool isActive(uint32_t n) const
Definition: NanoVDB.h:3800
DataType * data()
Definition: NanoVDB.h:3710
uint8_t flags() const
Definition: NanoVDB.h:3732
void localToGlobalCoord(Coord &ijk) const
Converts (in place) a local index coordinate to a global index coordinate.
Definition: NanoVDB.h:3745
ValueType maximum() const
Return a const reference to the maximum active value encoded in this leaf node.
Definition: NanoVDB.h:3721
typename DataType::FloatType FloatType
Definition: NanoVDB.h:3694
CoordT origin() const
Return the origin in index space of this leaf node.
Definition: NanoVDB.h:3735
static uint32_t CoordToOffset(const CoordT &ijk)
Return the linear offset corresponding to the given coordinate.
Definition: NanoVDB.h:3821
CoordT offsetToGlobalCoord(uint32_t n) const
Definition: NanoVDB.h:3747
void setValueOnly(const CoordT &ijk, const ValueType &v)
Definition: NanoVDB.h:3796
ValueType getValue(uint32_t offset) const
Return the voxel value at the given offset.
Definition: NanoVDB.h:3782
FloatType average() const
Return a const reference to the average of all the active values encoded in this leaf node.
Definition: NanoVDB.h:3724
const LeafNode * probeLeaf(const CoordT &) const
Definition: NanoVDB.h:3818
ValueType getValue(const CoordT &ijk) const
Return the voxel value at the given coordinate.
Definition: NanoVDB.h:3785
MaskT< LOG2 > MaskType
Definition: NanoVDB.h:3699
static uint32_t voxelCount()
Return the total number of voxels (e.g. values) encoded in this leaf node.
Definition: NanoVDB.h:3770
LeafNode(const LeafNode &)=delete
static uint64_t memUsage()
return memory usage in bytes for the class
Definition: NanoVDB.h:3773
BBox< CoordT > bbox() const
Return the bounding box in index space of active values in this leaf node.
Definition: NanoVDB.h:3756
LeafNode()=delete
This class cannot be constructed or deleted.
ValueType minimum() const
Return a const reference to the minimum active value encoded in this leaf node.
Definition: NanoVDB.h:3718
typename DataType::ValueType ValueType
Definition: NanoVDB.h:3693
static CoordT OffsetToLocalCoord(uint32_t n)
Definition: NanoVDB.h:3737
const DataType * data() const
Definition: NanoVDB.h:3712
FloatType stdDeviation() const
Return a const reference to the standard deviation of all the active values encoded in this leaf node...
Definition: NanoVDB.h:3730
Definition: NanoVDB.h:1820
Iterator()
Definition: NanoVDB.h:1822
Iterator & operator=(const Iterator &)=default
uint32_t operator*() const
Definition: NanoVDB.h:1833
Iterator(uint32_t pos, const Mask *parent)
Definition: NanoVDB.h:1827
Iterator & operator++()
Definition: NanoVDB.h:1835
Bit-mask to encode active states and facilitate sequential iterators and a fast codec for I/O compres...
Definition: NanoVDB.h:1796
Iterator beginOn() const
Definition: NanoVDB.h:1899
void set(uint32_t n, bool On)
Definition: NanoVDB.h:1924
bool operator==(const Mask &other) const
Definition: NanoVDB.h:1889
static size_t memUsage()
Return the memory footprint in bytes of this Mask.
Definition: NanoVDB.h:1803
void setOn()
Set all bits on.
Definition: NanoVDB.h:1937
void toggle(uint32_t n)
Definition: NanoVDB.h:1964
uint32_t countOn() const
Definition: NanoVDB.h:1811
void setOff(uint32_t n)
Definition: NanoVDB.h:1922
Mask(const Mask &other)
Copy constructor.
Definition: NanoVDB.h:1860
Mask(bool on)
Definition: NanoVDB.h:1852
Mask & operator=(const MaskT &other)
Assignment operator that works with openvdb::util::NodeMask.
Definition: NanoVDB.h:1876
bool isOn(uint32_t n) const
Return true if the given bit is set.
Definition: NanoVDB.h:1902
void set(bool on)
Set all bits off.
Definition: NanoVDB.h:1951
void setOff()
Set all bits off.
Definition: NanoVDB.h:1944
static uint32_t bitCount()
Return the number of bits available in this Mask.
Definition: NanoVDB.h:1806
bool isOff() const
Definition: NanoVDB.h:1912
bool operator!=(const Mask &other) const
Definition: NanoVDB.h:1897
void toggle()
brief Toggle the state of all bits in the mask
Definition: NanoVDB.h:1958
static uint32_t wordCount()
Return the number of machine words used by this Mask.
Definition: NanoVDB.h:1809
WordT getWord(int n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NanoVDB.h:1868
bool isOn() const
Definition: NanoVDB.h:1904
Mask()
Initialize all bits to zero.
Definition: NanoVDB.h:1847
void setOn(uint32_t n)
Set the given bit on.
Definition: NanoVDB.h:1921
Class to access points at a specific voxel location.
Definition: NanoVDB.h:4722
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:4742
typename NanoRoot< uint32_t >::LeafNodeType LeafNodeType
Definition: NanoVDB.h:4728
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:4752
PointAccessor(const UInt32Grid &grid)
Definition: NanoVDB.h:4730
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:4764
ReadAccessor & operator=(const ReadAccessor &)=default
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4050
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4055
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4060
typename RootT::CoordType CoordType
Definition: NanoVDB.h:4020
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition: NanoVDB.h:4038
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4045
typename RootT::ValueType ValueType
Definition: NanoVDB.h:4019
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4065
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4071
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4036
Node caching at all (three) tree levels.
Definition: NanoVDB.h:4433
ReadAccessor & operator=(const ReadAccessor &)=default
typename ReadAccessor< ValueT, -1, -1, -1 >::NodeInfo NodeInfo
Definition: NanoVDB.h:4460
CoordT CoordType
Definition: NanoVDB.h:4456
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4534
ValueT ValueType
Definition: NanoVDB.h:4455
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4551
const NodeT * getNode() const
Return a const point to the cached node of the specified type.
Definition: NanoVDB.h:4485
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4568
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition: NanoVDB.h:4474
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4517
bool isCached(const CoordType &ijk) const
Definition: NanoVDB.h:4511
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4585
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4603
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4463
ReadAccessor & operator=(const ReadAccessor &)=default
typename ReadAccessor< ValueT, -1, -1, -1 >::NodeInfo NodeInfo
Definition: NanoVDB.h:4117
CoordT CoordType
Definition: NanoVDB.h:4113
bool isCached(const CoordType &ijk) const
Definition: NanoVDB.h:4134
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4149
ValueT ValueType
Definition: NanoVDB.h:4112
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4157
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4165
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition: NanoVDB.h:4127
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4141
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4173
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4182
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4120
ReadAccessor & operator=(const ReadAccessor &)=default
CoordT CoordType
Definition: NanoVDB.h:4240
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4321
ValueT ValueType
Definition: NanoVDB.h:4239
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4336
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4351
typename ReadAccessor< ValueT,-1,-1,-1 >::NodeInfo NodeInfo
Definition: NanoVDB.h:4244
bool isCached1(const CoordType &ijk) const
Definition: NanoVDB.h:4292
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition: NanoVDB.h:4259
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4306
bool isCached2(const CoordType &ijk) const
Definition: NanoVDB.h:4298
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4366
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4382
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4247
Definition: NanoVDB.h:2298
8-bit red, green, blue, alpha packed into 32 bit unsigned int
Definition: NanoVDB.h:456
const uint32_t & packed() const
Definition: NanoVDB.h:490
Rgba8(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255u)
Definition: NanoVDB.h:470
Rgba8 & operator=(const Rgba8 &)=default
const uint8_t & g() const
Definition: NanoVDB.h:493
uint8_t & g()
Definition: NanoVDB.h:497
Rgba8(float r, float g, float b, float a=1.0f)
Definition: NanoVDB.h:472
uint32_t packed
Definition: NanoVDB.h:459
const uint8_t & a() const
Definition: NanoVDB.h:495
bool operator<(const Rgba8 &rhs) const
Definition: NanoVDB.h:479
const uint8_t & r() const
Definition: NanoVDB.h:492
Rgba8()
Definition: NanoVDB.h:469
Rgba8(uint8_t v)
Definition: NanoVDB.h:471
float lengthSqr() const
Definition: NanoVDB.h:481
Rgba8 & operator=(Rgba8 &&)=default
const uint8_t & b() const
Definition: NanoVDB.h:494
uint32_t & packed()
Definition: NanoVDB.h:491
uint8_t & r()
Definition: NanoVDB.h:496
uint8_t & operator[](int n)
Definition: NanoVDB.h:489
float length() const
Definition: NanoVDB.h:487
const uint8_t & operator[](int n) const
Definition: NanoVDB.h:488
bool operator==(const Rgba8 &rhs) const
Definition: NanoVDB.h:480
uint8_t ValueType
Definition: NanoVDB.h:463
Rgba8(const Rgba8 &)=default
uint8_t & b()
Definition: NanoVDB.h:498
uint8_t c[4]
Definition: NanoVDB.h:458
uint8_t & a()
Definition: NanoVDB.h:499
static const int SIZE
Definition: NanoVDB.h:462
Top-most node of the VDB tree structure.
Definition: NanoVDB.h:2800
const uint32_t & tileCount() const
Return the number of tiles encoded in this root node.
Definition: NanoVDB.h:2840
static uint64_t memUsage(uint32_t tableSize)
Return the expected memory footprint in bytes with the specified number of tiles.
Definition: NanoVDB.h:2858
typename ChildT::CoordType CoordType
Definition: NanoVDB.h:2811
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:2831
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:2852
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:2849
RootNode & operator=(const RootNode &)=delete
DataType * data()
Definition: NanoVDB.h:2826
AccessorType getAccessor() const
Definition: NanoVDB.h:2824
typename DataType::BuildT BuildType
Definition: NanoVDB.h:2809
RootNode(const RootNode &)=delete
ChildT ChildNodeType
Definition: NanoVDB.h:2804
const LeafNodeType * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:2897
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:2872
typename DataType::ValueT ValueType
Definition: NanoVDB.h:2807
typename DataType::StatsT FloatType
Definition: NanoVDB.h:2808
uint64_t memUsage() const
Return the actual memory footprint of this root node.
Definition: NanoVDB.h:2861
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:2883
typename ChildT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:2803
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:2855
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:2846
typename DataType::Tile Tile
Definition: NanoVDB.h:2813
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel.
Definition: NanoVDB.h:2864
const ValueType & background() const
Return the total number of active voxels in the root and all its child nodes.
Definition: NanoVDB.h:2837
bool isEmpty() const
Return true if this RootNode is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:2881
RootNode()=delete
This class cannot be constructed or deleted.
const ValueType & minimum() const
Return a const reference to the minimum active value encoded in this root node and any of its child n...
Definition: NanoVDB.h:2843
const DataType * data() const
Definition: NanoVDB.h:2828
VDB Tree, which is a thin wrapper around a RootNode.
Definition: NanoVDB.h:2544
typename RootT::ChildNodeType Node2
Definition: NanoVDB.h:2560
RootT Node3
Definition: NanoVDB.h:2559
const NodeT * getFirstNode() const
return a const pointer to the first node of the specified type
Definition: NanoVDB.h:2643
uint64_t activeVoxelCount() const
Return the total number of active voxels in this tree.
Definition: NanoVDB.h:2605
typename RootT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:2553
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:2602
DataType * data()
Definition: NanoVDB.h:2570
uint32_t nodeCount() const
Definition: NanoVDB.h:2617
Tree()=delete
This class cannot be constructed or deleted.
AccessorType getAccessor() const
Definition: NanoVDB.h:2581
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:2587
NodeTrait< RootT, LEVEL >::type * getFirstNode()
return a pointer to the first node at the specified level
Definition: NanoVDB.h:2654
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:2675
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:2610
bool probeValue(const CoordType &ijk, ValueType &v) const
Combines the previous two methods in a single call.
Definition: NanoVDB.h:2593
typename RootT::CoordType CoordType
Definition: NanoVDB.h:2556
RootT & root()
Definition: NanoVDB.h:2577
Tree(const Tree &)=delete
static uint64_t memUsage()
return memory usage in bytes for the class
Definition: NanoVDB.h:2575
LeafNodeType Node0
Definition: NanoVDB.h:2562
NodeT * getFirstNode()
return a pointer to the first node of the specified type
Definition: NanoVDB.h:2633
uint32_t nodeCount(int level) const
Definition: NanoVDB.h:2623
typename Node2::ChildNodeType Node1
Definition: NanoVDB.h:2561
const NodeTrait< RootT, LEVEL >::type * getFirstNode() const
return a const pointer to the first node of the specified level
Definition: NanoVDB.h:2664
const RootT & root() const
Definition: NanoVDB.h:2579
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel (regardless of state or location in the tree.)
Definition: NanoVDB.h:2584
RootT RootType
Definition: NanoVDB.h:2552
const ValueType & background() const
Return a const reference to the background value.
Definition: NanoVDB.h:2596
bool isEmpty() const
Return true if this tree is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:2590
Tree & operator=(const Tree &)=delete
typename RootT::ValueType ValueType
Definition: NanoVDB.h:2554
const DataType * data() const
Definition: NanoVDB.h:2572
typename RootT::BuildType BuildType
Definition: NanoVDB.h:2555
Dummy type for a voxel with a binary mask value, e.g. the active state.
Definition: NanoVDB.h:189
Vec3(const Vec3< T2 > &v)
Definition: NanoVDB.h:1060
Coord round() const
Definition: NanoVDB.h:1159
Vec3(T x)
Definition: NanoVDB.h:1051
ValueType min() const
Return the smallest vector component.
Definition: NanoVDB.h:1148
Vec3 & minComponent(const Vec3 &other)
Perform a component-wise minimum with the other Coord.
Definition: NanoVDB.h:1125
Vec3(const Coord &ijk)
Definition: NanoVDB.h:1064
bool operator==(const Vec3 &rhs) const
Definition: NanoVDB.h:1068
Vec3 operator-() const
Definition: NanoVDB.h:1094
T length() const
Definition: NanoVDB.h:1093
Vec3 operator*(const Vec3 &v) const
Definition: NanoVDB.h:1095
Vec3 & maxComponent(const Vec3 &other)
Perform a component-wise maximum with the other Coord.
Definition: NanoVDB.h:1137
Vec3 & operator-=(const Vec3 &v)
Definition: NanoVDB.h:1108
Coord floor() const
Definition: NanoVDB.h:1157
Vec3 operator*(const T &s) const
Definition: NanoVDB.h:1099
Vec3(T x, T y, T z)
Definition: NanoVDB.h:1055
Vec3 operator/(const Vec3 &v) const
Definition: NanoVDB.h:1096
T dot(const Vec3T &v) const
Definition: NanoVDB.h:1081
Vec3 & operator=(const Vec3T &rhs)
Definition: NanoVDB.h:1071
Vec3 & operator*=(const T &s)
Definition: NanoVDB.h:1115
Vec3 & normalize()
Definition: NanoVDB.h:1123
T lengthSqr() const
Definition: NanoVDB.h:1089
Vec3 & operator+=(const Vec3 &v)
Definition: NanoVDB.h:1101
Coord ceil() const
Definition: NanoVDB.h:1158
const T & operator[](int i) const
Definition: NanoVDB.h:1078
Vec3 cross(const Vec3T &v) const
Definition: NanoVDB.h:1083
Vec3 operator/(const T &s) const
Definition: NanoVDB.h:1100
bool operator!=(const Vec3 &rhs) const
Definition: NanoVDB.h:1069
Vec3 operator+(const Vec3 &v) const
Definition: NanoVDB.h:1097
T & operator[](int i)
Definition: NanoVDB.h:1079
Vec3 operator-(const Vec3 &v) const
Definition: NanoVDB.h:1098
ValueType max() const
Return the largest vector component.
Definition: NanoVDB.h:1153
Vec3 & operator/=(const T &s)
Definition: NanoVDB.h:1122
T ValueType
Definition: NanoVDB.h:1049
static const int SIZE
Definition: NanoVDB.h:1048
A simple vector class with three double components, similar to openvdb::math::Vec4.
Definition: NanoVDB.h:1189
Vec4 & normalize()
Definition: NanoVDB.h:1261
Vec4 & operator/=(const T &s)
Definition: NanoVDB.h:1260
Vec4 operator/(const Vec4 &v) const
Definition: NanoVDB.h:1231
Vec4 & operator+=(const Vec4 &v)
Definition: NanoVDB.h:1236
Vec4 operator*(const T &s) const
Definition: NanoVDB.h:1234
T length() const
Definition: NanoVDB.h:1228
Vec4 operator-(const Vec4 &v) const
Definition: NanoVDB.h:1233
Vec4 & operator*=(const T &s)
Definition: NanoVDB.h:1252
Vec4 operator*(const Vec4 &v) const
Definition: NanoVDB.h:1230
Vec4(T x, T y, T z, T w)
Definition: NanoVDB.h:1200
bool operator!=(const Vec4 &rhs) const
Definition: NanoVDB.h:1210
Vec4 & maxComponent(const Vec4 &other)
Perform a component-wise maximum with the other Coord.
Definition: NanoVDB.h:1277
Vec4(const Vec4< T2 > &v)
Definition: NanoVDB.h:1205
T lengthSqr() const
Definition: NanoVDB.h:1224
const T & operator[](int i) const
Definition: NanoVDB.h:1220
Vec4 & operator=(const Vec4T &rhs)
Definition: NanoVDB.h:1212
Vec4 & operator-=(const Vec4 &v)
Definition: NanoVDB.h:1244
bool operator==(const Vec4 &rhs) const
Definition: NanoVDB.h:1209
Vec4 & minComponent(const Vec4 &other)
Perform a component-wise minimum with the other Coord.
Definition: NanoVDB.h:1263
T & operator[](int i)
Definition: NanoVDB.h:1221
Vec4 operator-() const
Definition: NanoVDB.h:1229
Vec4 operator/(const T &s) const
Definition: NanoVDB.h:1235
T dot(const Vec4T &v) const
Definition: NanoVDB.h:1223
T ValueType
Definition: NanoVDB.h:1194
Vec4(T x)
Definition: NanoVDB.h:1196
static const int SIZE
Definition: NanoVDB.h:1193
Vec4 operator+(const Vec4 &v) const
Definition: NanoVDB.h:1232
Bit-compacted representation of all three version numbers.
Definition: NanoVDB.h:541
const char * c_str() const
Definition: NanoVDB.h:567
bool operator<(const Version &rhs) const
Definition: NanoVDB.h:557
uint32_t getPatch() const
Definition: NanoVDB.h:564
bool operator<=(const Version &rhs) const
Definition: NanoVDB.h:558
Version()
Definition: NanoVDB.h:544
bool operator==(const Version &rhs) const
Definition: NanoVDB.h:556
Version(uint32_t major, uint32_t minor, uint32_t patch)
Definition: NanoVDB.h:549
uint32_t getMajor() const
Definition: NanoVDB.h:562
bool operator>=(const Version &rhs) const
Definition: NanoVDB.h:560
uint32_t getMinor() const
Definition: NanoVDB.h:563
uint32_t id() const
Definition: NanoVDB.h:561
bool operator>(const Version &rhs) const
Definition: NanoVDB.h:559
Definition: NanoVDB.h:184
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
uint32_t CountOn(uint64_t v)
Definition: NanoVDB.h:1774
const char * toStr(GridType gridType)
Retuns a c-string used to describe a GridType.
Definition: NanoVDB.h:239
float Fract(float x)
Definition: NanoVDB.h:702
int MinIndex(const Vec3T &v)
Definition: NanoVDB.h:810
static int64_t PtrDiff(const T1 *p, const T2 *q)
Definition: NanoVDB.h:433
T Abs(T x)
Definition: NanoVDB.h:747
bool isApproxZero(const Type &x)
Definition: NanoVDB.h:645
Type Min(Type a, Type b)
Definition: NanoVDB.h:651
T Sign(const T &x)
Return the sign of the given value as an integer (either -1, 0 or 1).
Definition: NanoVDB.h:807
T Pow4(T x)
Definition: NanoVDB.h:742
Vec3< float > Vec3f
Definition: NanoVDB.h:1175
Vec3T matMult(const float *mat, const Vec3T &xyz)
Definition: NanoVDB.h:1409
static DstT * PtrAdd(SrcT *p, int64_t offset)
Definition: NanoVDB.h:440
GridClass
Classes (defined in OpenVDB) that are currently supported by NanoVDB.
Definition: NanoVDB.h:253
Vec3T matMultT(const float *mat, const Vec3T &xyz)
Definition: NanoVDB.h:1443
GridType
List of types that are currently supported by NanoVDB.
Definition: NanoVDB.h:216
float Sqrt(float x)
Return the square root of a floating-point value.
Definition: NanoVDB.h:795
int MaxIndex(const Vec3T &v)
Definition: NanoVDB.h:827
Vec3< T2 > operator/(T1 scalar, const Vec3< T2 > &vec)
Definition: NanoVDB.h:1168
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:4657
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
Vec3< T2 > operator*(T1 scalar, const Vec3< T2 > &vec)
Definition: NanoVDB.h:1163
int32_t Ceil(float x)
Definition: NanoVDB.h:720
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
int32_t Floor(float x)
Definition: NanoVDB.h:711
GridBlindDataClass
Blind-data Classes that are currently supported by NanoVDB.
Definition: NanoVDB.h:306
Vec3< double > Vec3d
Definition: NanoVDB.h:1174
GridType mapToGridType()
Maps from a templated value type to a GridType enum.
Definition: NanoVDB.h:1366
CoordT Round(const Vec3T< RealT > &xyz)
T Pow3(T x)
Definition: NanoVDB.h:736
CoordT RoundDown(const Vec3T< RealT > &xyz)
Definition: NanoVDB.h:788
GridBlindDataSemantic
Blind-data Semantics that are currently understood by NanoVDB.
Definition: NanoVDB.h:313
bool isFloatingPoint(GridType gridType)
return true if the GridType maps to a floating point value.
Definition: NanoVDB.h:507
T Pow2(T x)
Definition: NanoVDB.h:730
float Clamp(float x, float a, float b)
Definition: NanoVDB.h:693
Type Max(Type a, Type b)
Definition: NanoVDB.h:672
bool isValid(GridType gridType, GridClass gridClass)
return true if the combination of GridType and GridClass is valid.
Definition: NanoVDB.h:520
Iterator begin() const
Definition: NanoVDB.h:1610
BBox()
Definition: NanoVDB.h:1611
bool is_divisible() const
Definition: NanoVDB.h:1628
BBox(const CoordT &min, const CoordT &max)
Definition: NanoVDB.h:1615
CoordT dim() const
Definition: NanoVDB.h:1635
bool empty() const
Return true if this bounding box is empty, i.e. uninitialized.
Definition: NanoVDB.h:1632
BBox expandBy(typename CoordT::ValueType padding) const
Return a new instance that is expanded by the specified padding.
Definition: NanoVDB.h:1652
bool isInside(const BBox &b) const
Definition: NanoVDB.h:1638
uint64_t volume() const
Definition: NanoVDB.h:1636
BBox(BBox &other, const SplitT &)
Definition: NanoVDB.h:1620
BBox< Vec3< RealT > > asReal() const
Definition: NanoVDB.h:1645
bool isInside(const CoordT &p) const
Definition: NanoVDB.h:1637
Vec3T dim() const
Definition: NanoVDB.h:1556
bool isInside(const Vec3T &p) const
Definition: NanoVDB.h:1557
BBox()
Definition: NanoVDB.h:1538
BBox(const Coord &min, const Coord &max)
Definition: NanoVDB.h:1547
bool empty() const
Definition: NanoVDB.h:1553
BBox(const Vec3T &min, const Vec3T &max)
Definition: NanoVDB.h:1543
Vec3T Vec3Type
Definition: NanoVDB.h:1533
typename Vec3T::ValueType ValueType
Definition: NanoVDB.h:1534
BBox(const BaseBBox< Coord > &bbox)
Definition: NanoVDB.h:1552
Definition: NanoVDB.h:1524
Definition: NanoVDB.h:1479
Vec3T mCoord[2]
Definition: NanoVDB.h:1480
BaseBBox()
Definition: NanoVDB.h:1516
const Vec3T & max() const
Definition: NanoVDB.h:1488
Coord & translate(const Vec3T &xyz)
Definition: NanoVDB.h:1489
BaseBBox & expand(const Vec3T &xyz)
Definition: NanoVDB.h:1496
bool operator!=(const BaseBBox &rhs) const
Definition: NanoVDB.h:1482
const Vec3T & operator[](int i) const
Definition: NanoVDB.h:1483
Vec3T & operator[](int i)
Definition: NanoVDB.h:1484
bool isInside(const Vec3T &xyz)
Definition: NanoVDB.h:1506
const Vec3T & min() const
Definition: NanoVDB.h:1487
BaseBBox(const Vec3T &min, const Vec3T &max)
Definition: NanoVDB.h:1517
Vec3T & min()
Definition: NanoVDB.h:1485
bool operator==(const BaseBBox &rhs) const
Definition: NanoVDB.h:1481
Vec3T & max()
Definition: NanoVDB.h:1486
float type
Definition: NanoVDB.h:420
float Type
Definition: NanoVDB.h:419
float type
Definition: NanoVDB.h:406
float Type
Definition: NanoVDB.h:405
float type
Definition: NanoVDB.h:413
float Type
Definition: NanoVDB.h:412
float type
Definition: NanoVDB.h:427
float Type
Definition: NanoVDB.h:426
float type
Definition: NanoVDB.h:399
float Type
Definition: NanoVDB.h:398
bool Type
Definition: NanoVDB.h:391
bool type
Definition: NanoVDB.h:392
Maps one type (e.g. the build types above) to other (actual) types.
Definition: NanoVDB.h:383
T Type
Definition: NanoVDB.h:384
T type
Definition: NanoVDB.h:385
static double value()
Definition: NanoVDB.h:606
static float value()
Definition: NanoVDB.h:601
Delta for small floating-point offsets.
Definition: NanoVDB.h:597
double FloatType
Definition: NanoVDB.h:1347
bool FloatType
Definition: NanoVDB.h:1359
bool FloatType
Definition: NanoVDB.h:1353
Definition: NanoVDB.h:1340
float FloatType
Definition: NanoVDB.h:1341
Struct with all the member data of the Grid (useful during serialization of an openvdb grid)
Definition: NanoVDB.h:2186
uint32_t mFlags
Definition: NanoVDB.h:2191
const void * treePtr() const
Definition: NanoVDB.h:2283
void setMinMaxOn(bool on=true)
Definition: NanoVDB.h:2207
void setAverageOn(bool on=true)
Definition: NanoVDB.h:2231
Vec3T applyInverseJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2275
Vec3T applyIJTF(const Vec3T &xyz) const
Definition: NanoVDB.h:2277
uint32_t mBlindMetadataCount
Definition: NanoVDB.h:2202
Version mVersion
Definition: NanoVDB.h:2190
GridType mGridType
Definition: NanoVDB.h:2200
uint64_t mMagic
Definition: NanoVDB.h:2188
void setStdDeviationOn(bool on=true)
Definition: NanoVDB.h:2239
Vec3T applyIJT(const Vec3T &xyz) const
Definition: NanoVDB.h:2266
GridClass mGridClass
Definition: NanoVDB.h:2199
void setBBoxOn(bool on=true)
Definition: NanoVDB.h:2215
void setLongGridNameOn(bool on=true)
Definition: NanoVDB.h:2223
Vec3T applyJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2273
uint64_t mGridSize
Definition: NanoVDB.h:2194
BBox< Vec3R > mWorldBBox
Definition: NanoVDB.h:2197
Vec3T applyInverseJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2264
void * treePtr()
Definition: NanoVDB.h:2280
const GridBlindMetaData * blindMetaData(uint32_t n) const
Returns a const reference to the blindMetaData at the specified linear offset.
Definition: NanoVDB.h:2288
void setBreadthFirstOn(bool on=true)
Definition: NanoVDB.h:2247
uint64_t mChecksum
Definition: NanoVDB.h:2189
Vec3T applyMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2269
uint32_t mGridCount
Definition: NanoVDB.h:2193
Vec3R mVoxelSize
Definition: NanoVDB.h:2198
Vec3T applyInverseMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2260
Map mMap
Definition: NanoVDB.h:2196
Vec3T applyJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2262
void setFlagsOff()
Definition: NanoVDB.h:2206
int64_t mBlindMetadataOffset
Definition: NanoVDB.h:2201
uint32_t mGridIndex
Definition: NanoVDB.h:2192
Vec3T applyMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2258
Vec3T applyInverseMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2271
const typename GridT::TreeType Type
Definition: NanoVDB.h:2535
const typename GridT::TreeType type
Definition: NanoVDB.h:2536
defines a tree type from a grid type while perserving constness
Definition: NanoVDB.h:2528
typename GridT::TreeType Type
Definition: NanoVDB.h:2529
typename GridT::TreeType type
Definition: NanoVDB.h:2530
Struct with all the member data of the InternalNode (useful during serialization of an openvdb Intern...
Definition: NanoVDB.h:3044
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3100
StatsT mAverage
Definition: NanoVDB.h:3070
typename ChildT::CoordType CoordT
Definition: NanoVDB.h:3048
void setChild(uint32_t n, const void *ptr)
Definition: NanoVDB.h:3074
MaskT mChildMask
Definition: NanoVDB.h:3066
void setValue(uint32_t n, const ValueT &v)
Definition: NanoVDB.h:3081
InternalData(const InternalData &)=delete
const ValueT & getMax() const
Definition: NanoVDB.h:3103
void setDev(const StatsT &v)
Definition: NanoVDB.h:3110
const ChildT * getChild(uint32_t n) const
Definition: NanoVDB.h:3093
void setMin(const ValueT &v)
Definition: NanoVDB.h:3107
typename ChildT::FloatType StatsT
Definition: NanoVDB.h:3047
typename ChildT::BuildType BuildT
Definition: NanoVDB.h:3046
const ValueT & getMin() const
Definition: NanoVDB.h:3102
void setMax(const ValueT &v)
Definition: NanoVDB.h:3108
StatsT mStdDevi
Definition: NanoVDB.h:3071
BBox< CoordT > mBBox
Definition: NanoVDB.h:3063
ChildT * getChild(uint32_t n)
Returns a pointer to the child node at the specifed linear offset.
Definition: NanoVDB.h:3088
ValueT mMaximum
Definition: NanoVDB.h:3069
const StatsT & stdDeviation() const
Definition: NanoVDB.h:3105
const StatsT & average() const
Definition: NanoVDB.h:3104
MaskT mValueMask
Definition: NanoVDB.h:3065
typename ChildT::template MaskType< LOG2DIM > MaskT
Definition: NanoVDB.h:3049
InternalData & operator=(const InternalData &)=delete
void setAvg(const StatsT &v)
Definition: NanoVDB.h:3109
typename ChildT::ValueType ValueT
Definition: NanoVDB.h:3045
ValueT mMinimum
Definition: NanoVDB.h:3068
InternalData()=delete
This class cannot be constructed or deleted.
uint64_t mFlags
Definition: NanoVDB.h:3064
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:3521
float getValue(uint32_t i) const
Definition: NanoVDB.h:3522
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
uint16_t ArrayType
Definition: NanoVDB.h:3517
LeafData()=delete
This class cannot be constructed or deleted.
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:3471
float getValue(uint32_t i) const
Definition: NanoVDB.h:3472
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
LeafData()=delete
This class cannot be constructed or deleted.
uint8_t ArrayType
Definition: NanoVDB.h:3467
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:3499
float getValue(uint32_t i) const
Definition: NanoVDB.h:3500
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
LeafData()=delete
This class cannot be constructed or deleted.
uint8_t ArrayType
Definition: NanoVDB.h:3495
size_t memUsage() const
Definition: NanoVDB.h:3543
float getValue(uint32_t i) const
Definition: NanoVDB.h:3545
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
uint8_t bitWidth() const
Definition: NanoVDB.h:3542
LeafData()=delete
This class cannot be constructed or deleted.
static size_t memUsage(uint32_t bitWidth)
Definition: NanoVDB.h:3544
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3670
bool getDev() const
Definition: NanoVDB.h:3658
bool getMin() const
Definition: NanoVDB.h:3655
void setMax(const ValueType &)
Definition: NanoVDB.h:3665
bool getValue(uint32_t i) const
Definition: NanoVDB.h:3654
uint8_t mFlags
Definition: NanoVDB.h:3650
LeafData & operator=(const LeafData &)=delete
bool getMax() const
Definition: NanoVDB.h:3656
void setDev(const FloatType &)
Definition: NanoVDB.h:3667
LeafData(const LeafData &)=delete
bool getAvg() const
Definition: NanoVDB.h:3657
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3651
void setValue(uint32_t offset, bool)
Definition: NanoVDB.h:3659
CoordT mBBoxMin
Definition: NanoVDB.h:3648
bool ValueType
Definition: NanoVDB.h:3642
LeafData()=delete
This class cannot be constructed or deleted.
void setAvg(const FloatType &)
Definition: NanoVDB.h:3666
void setMin(const ValueType &)
Definition: NanoVDB.h:3664
bool FloatType
Definition: NanoVDB.h:3644
void ArrayType
Definition: NanoVDB.h:3645
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3627
bool getDev() const
Definition: NanoVDB.h:3614
bool BuildType
Definition: NanoVDB.h:3598
void setMin(const bool &)
Definition: NanoVDB.h:3621
bool getMin() const
Definition: NanoVDB.h:3611
void setMax(const bool &)
Definition: NanoVDB.h:3622
void setValue(uint32_t offset, bool v)
Definition: NanoVDB.h:3615
bool getValue(uint32_t i) const
Definition: NanoVDB.h:3610
uint8_t mFlags
Definition: NanoVDB.h:3605
LeafData & operator=(const LeafData &)=delete
bool getMax() const
Definition: NanoVDB.h:3612
LeafData(const LeafData &)=delete
MaskT< LOG2DIM > ArrayType
Definition: NanoVDB.h:3600
bool getAvg() const
Definition: NanoVDB.h:3613
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3606
MaskT< LOG2DIM > mValues
Definition: NanoVDB.h:3607
CoordT mBBoxMin
Definition: NanoVDB.h:3603
bool ValueType
Definition: NanoVDB.h:3597
void setDev(const bool &)
Definition: NanoVDB.h:3624
LeafData()=delete
This class cannot be constructed or deleted.
void setAvg(const bool &)
Definition: NanoVDB.h:3623
bool FloatType
Definition: NanoVDB.h:3599
Stuct with all the member data of the LeafNode (useful during serialization of an openvdb LeafNode)
Definition: NanoVDB.h:3356
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3396
ValueType mMaximum
Definition: NanoVDB.h:3371
FloatType getDev() const
Definition: NanoVDB.h:3388
typename FloatTraits< ValueT >::FloatType FloatType
Definition: NanoVDB.h:3361
void setMin(const ValueType &v)
Definition: NanoVDB.h:3390
void setMax(const ValueType &v)
Definition: NanoVDB.h:3391
FloatType mAverage
Definition: NanoVDB.h:3372
void setDev(const FloatType &v)
Definition: NanoVDB.h:3393
uint8_t mFlags
Definition: NanoVDB.h:3367
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
ValueType getMin() const
Definition: NanoVDB.h:3385
ValueType getValue(uint32_t i) const
Definition: NanoVDB.h:3377
void setValue(uint32_t offset, const ValueType &value)
Definition: NanoVDB.h:3379
ValueT ValueType
Definition: NanoVDB.h:3359
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3368
void setValueOnly(uint32_t offset, const ValueType &value)
Definition: NanoVDB.h:3378
CoordT mBBoxMin
Definition: NanoVDB.h:3365
ValueType getMax() const
Definition: NanoVDB.h:3386
LeafData()=delete
This class cannot be constructed or deleted.
ValueT ArrayType
Definition: NanoVDB.h:3362
FloatType getAvg() const
Definition: NanoVDB.h:3387
ValueType mMinimum
Definition: NanoVDB.h:3370
void setAvg(const FloatType &v)
Definition: NanoVDB.h:3392
ValueT BuildType
Definition: NanoVDB.h:3360
FloatType mStdDevi
Definition: NanoVDB.h:3373
Base-class for quantized float leaf nodes.
Definition: NanoVDB.h:3408
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3455
float ValueType
Definition: NanoVDB.h:3411
float getMin() const
return the quantized minimum of the active values in this node
Definition: NanoVDB.h:3430
void setDev(float dev)
Definition: NanoVDB.h:3452
void setMin(float min)
Definition: NanoVDB.h:3443
float getAvg() const
return the quantized average of the active values in this node
Definition: NanoVDB.h:3436
uint8_t mFlags
Definition: NanoVDB.h:3416
float mQuantum
Definition: NanoVDB.h:3420
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3417
void init(float min, float max, uint8_t bitWidth)
Definition: NanoVDB.h:3423
uint16_t mAvg
Definition: NanoVDB.h:3421
CoordT mBBoxMin
Definition: NanoVDB.h:3414
float mMinimum
Definition: NanoVDB.h:3419
float FloatType
Definition: NanoVDB.h:3412
void setMax(float max)
Definition: NanoVDB.h:3446
void setAvg(float avg)
Definition: NanoVDB.h:3449
float getDev() const
return the quantized standard deviation of the active values in this node
Definition: NanoVDB.h:3440
float getMax() const
return the quantized maximum of the active values in this node
Definition: NanoVDB.h:3433
Definition: NanoVDB.h:3688
static uint32_t dim()
Definition: NanoVDB.h:3689
Defines an affine transform and its inverse represented as a 3x3 matrix and a vec3 translation.
Definition: NanoVDB.h:1999
double mTaperD
Definition: NanoVDB.h:2007
Vec3T applyInverseJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2037
Vec3T applyIJTF(const Vec3T &xyz) const
Definition: NanoVDB.h:2042
double mVecD[3]
Definition: NanoVDB.h:2006
float mInvMatF[9]
Definition: NanoVDB.h:2001
Vec3T applyIJT(const Vec3T &xyz) const
Definition: NanoVDB.h:2040
Vec3T applyJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2021
Vec3T applyInverseJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2035
void set(const Mat4T &mat, const Mat4T &invMat, double taper)
Definition: NanoVDB.h:2046
double mInvMatD[9]
Definition: NanoVDB.h:2005
Vec3T applyMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2016
float mMatF[9]
Definition: NanoVDB.h:2000
Vec3T applyInverseMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2024
double mMatD[9]
Definition: NanoVDB.h:2004
Vec3T applyJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2019
Vec3T applyMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2014
Vec3T applyInverseMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2029
float mTaperF
Definition: NanoVDB.h:2003
float mVecF[3]
Definition: NanoVDB.h:2002
Maximum floating-point values.
Definition: NanoVDB.h:638
static T value()
Definition: NanoVDB.h:639
Trait to map from LEVEL to node type.
Definition: NanoVDB.h:3934
typename GridOrTreeOrRootT::LeafNodeType type
Definition: NanoVDB.h:2105
typename GridOrTreeOrRootT::LeafNodeType Type
Definition: NanoVDB.h:2104
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType Type
Definition: NanoVDB.h:2119
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType type
Definition: NanoVDB.h:2120
typename GridOrTreeOrRootT::RootType::ChildNodeType Type
Definition: NanoVDB.h:2133
typename GridOrTreeOrRootT::RootType::ChildNodeType type
Definition: NanoVDB.h:2134
typename GridOrTreeOrRootT::RootType type
Definition: NanoVDB.h:2148
typename GridOrTreeOrRootT::RootType Type
Definition: NanoVDB.h:2147
const typename GridOrTreeOrRootT::LeafNodeType Type
Definition: NanoVDB.h:2111
const typename GridOrTreeOrRootT::LeafNodeType type
Definition: NanoVDB.h:2112
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType Type
Definition: NanoVDB.h:2126
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType type
Definition: NanoVDB.h:2127
const typename GridOrTreeOrRootT::RootType::ChildNodeType type
Definition: NanoVDB.h:2141
const typename GridOrTreeOrRootT::RootType::ChildNodeType Type
Definition: NanoVDB.h:2140
const typename GridOrTreeOrRootT::RootType type
Definition: NanoVDB.h:2156
const typename GridOrTreeOrRootT::RootType Type
Definition: NanoVDB.h:2155
Struct to derive node type from its level in a given grid, tree or root while perserving constness.
Definition: NanoVDB.h:2097
uint32_t mLevel
Definition: NanoVDB.h:4025
ValueType mMaximum
Definition: NanoVDB.h:4028
uint32_t mDim
Definition: NanoVDB.h:4026
FloatType mAverage
Definition: NanoVDB.h:4029
CoordType mBBoxMax
Definition: NanoVDB.h:4032
ValueType mMinimum
Definition: NanoVDB.h:4027
CoordType mBBoxMin
Definition: NanoVDB.h:4031
FloatType mStdDevi
Definition: NanoVDB.h:4030
Definition: NanoVDB.h:2729
ValueT value
Definition: NanoVDB.h:2749
void setChild(const CoordType &k, const ChildT *ptr, const RootData *data)
Definition: NanoVDB.h:2731
uint32_t state
Definition: NanoVDB.h:2748
KeyT key
Definition: NanoVDB.h:2746
void setValue(const CoordType &k, bool s, const ValueType &v)
Definition: NanoVDB.h:2737
CoordT origin() const
Definition: NanoVDB.h:2745
bool isChild() const
Definition: NanoVDB.h:2744
int64_t child
Definition: NanoVDB.h:2747
Struct with all the member data of the RootNode (useful during serialization of an openvdb RootNode)
Definition: NanoVDB.h:2688
StatsT mAverage
Definition: NanoVDB.h:2725
typename ChildT::CoordType CoordT
Definition: NanoVDB.h:2691
static CoordT KeyToCoord(const KeyT &key)
Definition: NanoVDB.h:2707
const ChildT * getChild(const Tile *tile) const
Definition: NanoVDB.h:2774
RootData()=delete
This class cannot be constructed or deleted.
ValueT mBackground
Definition: NanoVDB.h:2722
Tile * tile(uint32_t n)
Definition: NanoVDB.h:2760
const Tile * tile(uint32_t n) const
Returns a non-const reference to the tile at the specified linear offset.
Definition: NanoVDB.h:2755
uint32_t mTableSize
Definition: NanoVDB.h:2720
const ValueT & getMax() const
Definition: NanoVDB.h:2781
void setDev(const StatsT &v)
Definition: NanoVDB.h:2788
uint64_t KeyT
Return a key based on the coordinates of a voxel.
Definition: NanoVDB.h:2697
void setMin(const ValueT &v)
Definition: NanoVDB.h:2785
typename ChildT::FloatType StatsT
Definition: NanoVDB.h:2692
typename ChildT::BuildType BuildT
Definition: NanoVDB.h:2690
ChildT * getChild(const Tile *tile)
Returns a const reference to the child node in the specified tile.
Definition: NanoVDB.h:2769
const ValueT & getMin() const
Definition: NanoVDB.h:2780
void setMax(const ValueT &v)
Definition: NanoVDB.h:2786
StatsT mStdDevi
Definition: NanoVDB.h:2726
RootData(const RootData &)=delete
static KeyT CoordToKey(const CoordType &ijk)
Definition: NanoVDB.h:2699
RootData & operator=(const RootData &)=delete
BBox< CoordT > mBBox
Definition: NanoVDB.h:2719
ValueT mMaximum
Definition: NanoVDB.h:2724
const StatsT & stdDeviation() const
Definition: NanoVDB.h:2783
const StatsT & average() const
Definition: NanoVDB.h:2782
void setAvg(const StatsT &v)
Definition: NanoVDB.h:2787
typename ChildT::ValueType ValueT
Definition: NanoVDB.h:2689
ValueT mMinimum
Definition: NanoVDB.h:2723
T ElementType
Definition: NanoVDB.h:1321
static T scalar(const T &s)
Definition: NanoVDB.h:1322
static ElementType scalar(const T &v)
Definition: NanoVDB.h:1333
typename T::ValueType ElementType
Definition: NanoVDB.h:1332
Definition: NanoVDB.h:1312
static double value()
Definition: NanoVDB.h:590
static float value()
Definition: NanoVDB.h:585
Tolerance for floating-point comparison.
Definition: NanoVDB.h:581
Definition: NanoVDB.h:2502
const RootT * getRoot() const
Definition: NanoVDB.h:2514
void setFirstNode(const NodeT *node)
Definition: NanoVDB.h:2517
RootT * getRoot()
Definition: NanoVDB.h:2512
void setRoot(const RootT *root)
Definition: NanoVDB.h:2510
uint64_t mVoxelCount
Definition: NanoVDB.h:2507
T type
Definition: NanoVDB.h:348
C++11 implementation of std::enable_if.
Definition: NanoVDB.h:342
C++11 implementation of std::is_floating_point.
Definition: NanoVDB.h:356
static const bool value
Definition: NanoVDB.h:357
C++11 implementation of std::is_same.
Definition: NanoVDB.h:327
static constexpr bool value
Definition: NanoVDB.h:328
Metafunction used to determine if the first template parameter is a specialization of the class templ...
Definition: NanoVDB.h:369
static const bool value
Definition: NanoVDB.h:370
Definition: NanoVDB.h:3053
ValueT value
Definition: NanoVDB.h:3054
Tile(const Tile &)=delete
Tile & operator=(const Tile &)=delete
Tile()=delete
This class cannot be constructed or deleted.
int64_t child
Definition: NanoVDB.h:3055