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)
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);
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);
1776#if defined(_MSC_VER) && defined(_M_X64)
1778#elif (defined(__GNUC__) || defined(__clang__))
1779 v = __builtin_popcountll(v);
1782 v = v - ((v >> 1) & uint64_t(0x5555555555555555));
1783 v = (v & uint64_t(0x3333333333333333)) + ((v >> 2) & uint64_t(0x3333333333333333));
1784 v = (((v + (v >> 4)) & uint64_t(0xF0F0F0F0F0F0F0F)) * uint64_t(0x101010101010101)) >> 56;
1786 return static_cast<uint32_t
>(v);
1793template<u
int32_t LOG2DIM>
1796 static constexpr uint32_t SIZE = 1U << (3 * LOG2DIM);
1797 static constexpr uint32_t WORD_COUNT = SIZE >> 6;
1798 uint64_t mWords[WORD_COUNT];
1812 uint32_t sum = 0, n = WORD_COUNT;
1813 for (
const uint64_t* w = mWords; n--; ++w)
1836 mPos = mParent->findNextOn(mPos + 1);
1842 const Mask* mParent;
1848 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1853 const uint64_t v = on ? ~uint64_t(0) : uint64_t(0);
1854 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1861 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1862 mWords[i] = other.mWords[i];
1866 template<
typename WordT>
1870 return reinterpret_cast<const WordT*
>(mWords)[n];
1874 template<
typename MaskT>
1877 static_assert(
sizeof(
Mask) ==
sizeof(MaskT),
"Mismatching sizeof");
1878 static_assert(WORD_COUNT == MaskT::WORD_COUNT,
"Mismatching word count");
1879 static_assert(LOG2DIM == MaskT::LOG2DIM,
"Mismatching LOG2DIM");
1880 auto *src =
reinterpret_cast<const uint64_t*
>(&other);
1881 uint64_t *dst = mWords;
1882 for (uint32_t i = 0; i < WORD_COUNT; ++i) {
1890 for (uint32_t i = 0; i < WORD_COUNT; ++i) {
1891 if (mWords[i] != other.mWords[i])
return false;
1901 __hostdev__ bool isOn(uint32_t n)
const {
return 0 != (mWords[n >> 6] & (uint64_t(1) << (n & 63))); }
1905 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1906 if (mWords[i] != ~uint64_t(0))
1913 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1914 if (mWords[i] != uint64_t(0))
1926 auto &word = mWords[n >> 6];
1928 word &= ~(uint64_t(1) << n);
1929 word |= uint64_t(On) << n;
1938 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1939 mWords[i] = ~uint64_t(0);
1945 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1946 mWords[i] = uint64_t(0);
1952 const uint64_t v = on ? ~uint64_t(0) : uint64_t(0);
1953 for (uint32_t i = 0; i < WORD_COUNT; ++i)
1959 uint32_t n = WORD_COUNT;
1960 for (
auto* w = mWords; n--; ++w)
1971 const uint64_t* w = mWords;
1972 for (; n < WORD_COUNT && !*w; ++w, ++n)
1974 return n == WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(*w);
1978 __hostdev__ uint32_t findNextOn(uint32_t start)
const
1980 uint32_t n = start >> 6;
1981 if (n >= WORD_COUNT)
1983 uint32_t m = start & 63;
1984 uint64_t b = mWords[n];
1985 if (b & (uint64_t(1) << m))
1987 b &= ~uint64_t(0) << m;
1988 while (!b && ++n < WORD_COUNT)
2009 template<
typename Mat4T>
2010 __hostdev__ void set(
const Mat4T& mat,
const Mat4T& invMat,
double taper);
2012 template<
typename Vec3T>
2014 template<
typename Vec3T>
2017 template<
typename Vec3T>
2019 template<
typename Vec3T>
2022 template<
typename Vec3T>
2027 template<
typename Vec3T>
2033 template<
typename Vec3T>
2035 template<
typename Vec3T>
2038 template<
typename Vec3T>
2040 template<
typename Vec3T>
2044template<
typename Mat4T>
2045void Map::set(
const Mat4T& mat,
const Mat4T& invMat,
double taper)
2051 mTaperF =
static_cast<float>(taper);
2053 for (
int i = 0; i < 3; ++i) {
2055 *vf++ =
static_cast<float>(mat[3][i]);
2056 for (
int j = 0; j < 3; ++j) {
2058 *mid++ = invMat[j][i];
2059 *mf++ =
static_cast<float>(mat[j][i]);
2060 *mif++ =
static_cast<float>(invMat[j][i]);
2069 static const int MaxNameSize = 256;
2076 char mName[MaxNameSize];
2086 template <
typename T>
2095template<
typename Gr
idOrTreeOrRootT,
int LEVEL>
2099template<
typename Gr
idOrTreeOrRootT>
2102 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2103 using Type =
typename GridOrTreeOrRootT::LeafNodeType;
2104 using type =
typename GridOrTreeOrRootT::LeafNodeType;
2106template<
typename Gr
idOrTreeOrRootT>
2109 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2110 using Type =
const typename GridOrTreeOrRootT::LeafNodeType;
2111 using type =
const typename GridOrTreeOrRootT::LeafNodeType;
2114template<
typename Gr
idOrTreeOrRootT>
2117 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2118 using Type =
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2119 using type =
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2121template<
typename Gr
idOrTreeOrRootT>
2124 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2125 using Type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2126 using type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType;
2128template<
typename Gr
idOrTreeOrRootT>
2131 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2132 using Type =
typename GridOrTreeOrRootT::RootType::ChildNodeType;
2133 using type =
typename GridOrTreeOrRootT::RootType::ChildNodeType;
2135template<
typename Gr
idOrTreeOrRootT>
2138 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2139 using Type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType;
2140 using type =
const typename GridOrTreeOrRootT::RootType::ChildNodeType;
2142template<
typename Gr
idOrTreeOrRootT>
2145 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2146 using Type =
typename GridOrTreeOrRootT::RootType;
2147 using type =
typename GridOrTreeOrRootT::RootType;
2150template<
typename Gr
idOrTreeOrRootT>
2153 static_assert(GridOrTreeOrRootT::RootType::LEVEL == 3,
"Tree depth is not supported");
2154 using Type =
const typename GridOrTreeOrRootT::RootType;
2155 using type =
const typename GridOrTreeOrRootT::RootType;
2186 static const int MaxNameSize = 256;
2194 char mGridName[MaxNameSize];
2256 template<
typename Vec3T>
2258 template<
typename Vec3T>
2260 template<
typename Vec3T>
2262 template<
typename Vec3T>
2264 template<
typename Vec3T>
2267 template<
typename Vec3T>
2269 template<
typename Vec3T>
2271 template<
typename Vec3T>
2273 template<
typename Vec3T>
2275 template<
typename Vec3T>
2290 return PtrAdd<GridBlindMetaData>(
this, mBlindMetadataOffset) + n;
2296template <
typename BuildT,
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1>
2299template <
typename BuildT>
2306template<
typename TreeT>
2344 __hostdev__ const TreeT&
tree()
const {
return *
reinterpret_cast<const TreeT*
>(this->treePtr()); }
2359 template<
typename Vec3T>
2363 template<
typename Vec3T>
2368 template<
typename Vec3T>
2373 template<
typename Vec3T>
2378 template<
typename Vec3T>
2382 template<
typename Vec3T>
2386 template<
typename Vec3T>
2391 template<
typename Vec3T>
2396 template<
typename Vec3T>
2401 template<
typename Vec3T>
2436 template <
typename NodeT>
2441 template <
int LEVEL>
2447 if (this->hasLongGridName()) {
2448 const auto &metaData = this->blindMetaData(DataType::mBlindMetadataCount-1);
2450 return metaData.template getBlindData<const char>();
2452 return DataType::mGridName;
2475 if (DataType::mBlindMetadataCount == 0) {
2479 return this->blindMetaData(n).template getBlindData<void>();
2488template<
typename TreeT>
2491 for (uint32_t i = 0, n = this->blindDataCount(); i < n; ++i)
2492 if (this->blindMetaData(i).mSemantic == semantic)
2499template<
int ROOT_LEVEL = 3>
2502 static_assert(
ROOT_LEVEL == 3,
"Root level is assumed to be three");
2503 uint64_t mNodeOffset[4];
2504 uint32_t mNodeCount[3];
2505 uint32_t mTileCount[3];
2508 template <
typename RootT>
2510 template <
typename RootT>
2512 template <
typename RootT>
2515 template <
typename NodeT>
2518 mNodeOffset[NodeT::LEVEL] = node ?
PtrDiff(node,
this) : 0;
2525template<
typename Gr
idT>
2528 using Type =
typename GridT::TreeType;
2529 using type =
typename GridT::TreeType;
2531template<
typename Gr
idT>
2534 using Type =
const typename GridT::TreeType;
2535 using type =
const typename GridT::TreeType;
2541template<
typename RootT>
2544 static_assert(RootT::LEVEL == 3,
"Tree depth is not supported");
2545 static_assert(RootT::ChildNodeType::LOG2DIM == 5,
"Tree configuration is not supported");
2546 static_assert(RootT::ChildNodeType::ChildNodeType::LOG2DIM == 4,
"Tree configuration is not supported");
2547 static_assert(RootT::LeafNodeType::LOG2DIM == 3,
"Tree configuration is not supported");
2559 using Node2 =
typename RootT::ChildNodeType;
2560 using Node1 =
typename Node2::ChildNodeType;
2612 return DataType::mTileCount[n];
2615 template<
typename NodeT>
2618 static_assert(NodeT::LEVEL < 3,
"Invalid NodeT");
2619 return DataType::mNodeCount[NodeT::LEVEL];
2625 return DataType::mNodeCount[level];
2631 template <
typename NodeT>
2634 const uint64_t offset = DataType::mNodeOffset[NodeT::LEVEL];
2635 return offset>0 ? PtrAdd<NodeT>(
this, offset) :
nullptr;
2641 template <
typename NodeT>
2644 const uint64_t offset = DataType::mNodeOffset[NodeT::LEVEL];
2645 return offset>0 ? PtrAdd<NodeT>(
this, offset) :
nullptr;
2651 template <
int LEVEL>
2655 return this->
template getFirstNode<typename NodeTrait<RootT,LEVEL>::type>();
2661 template <
int LEVEL>
2665 return this->
template getFirstNode<typename NodeTrait<RootT,LEVEL>::type>();
2673template<
typename RootT>
2676 min = this->root().minimum();
2677 max = this->root().maximum();
2685template<
typename ChildT>
2692 static constexpr bool FIXED_SIZE =
false;
2695#ifdef USE_SINGLE_ROOT_KEY
2697 template <
typename CoordType>
2700 static_assert(
sizeof(
CoordT) ==
sizeof(CoordType),
"Mismatching sizeof");
2701 static_assert(32 - ChildT::TOTAL <= 21,
"Cannot use 64 bit root keys");
2702 return (
KeyT(uint32_t(ijk[2]) >> ChildT::TOTAL)) |
2703 (
KeyT(uint32_t(ijk[1]) >> ChildT::TOTAL) << 21) |
2704 (
KeyT(uint32_t(ijk[0]) >> ChildT::TOTAL) << 42);
2708 static constexpr uint64_t MASK = (1u << 21) - 1;
2709 return CoordT(((key >> 42) & MASK) << ChildT::TOTAL,
2710 ((key >> 21) & MASK) << ChildT::TOTAL,
2711 (key & MASK) << ChildT::TOTAL);
2714 using KeyT = CoordT;
2715 __hostdev__ static KeyT CoordToKey(
const CoordT& ijk) {
return ijk & ~ChildT::MASK; }
2716 __hostdev__ static CoordT KeyToCoord(
const KeyT& key) {
return key; }
2727 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
Tile
2729 template <
typename CoordType>
2732 key = CoordToKey(k);
2735 template <
typename CoordType,
typename ValueType>
2738 key = CoordToKey(k);
2757 return reinterpret_cast<const Tile*
>(
this + 1) + n;
2762 return reinterpret_cast<Tile*
>(
this + 1) + n;
2771 return PtrAdd<ChildT>(
this, tile->
child);
2776 return PtrAdd<ChildT>(
this, tile->
child);
2797template<
typename ChildT>
2813 static constexpr bool FIXED_SIZE = DataType::FIXED_SIZE;
2815 static constexpr uint32_t LEVEL = 1 + ChildT::LEVEL;
2865 if (
const Tile* tile = this->findTile(ijk)) {
2866 return tile->isChild() ? this->getChild(tile)->getValue(ijk) : tile->value;
2868 return DataType::mBackground;
2873 if (
const Tile* tile = this->findTile(ijk)) {
2874 return tile->isChild() ? this->getChild(tile)->isActive(ijk) : tile->state;
2884 if (
const Tile* tile = this->findTile(ijk)) {
2885 if (tile->isChild()) {
2886 const auto *
child = this->getChild(tile);
2887 return child->probeValue(ijk, v);
2892 v = DataType::mBackground;
2898 const Tile* tile = this->findTile(ijk);
2899 if (tile && tile->isChild()) {
2900 const auto *
child = this->getChild(tile);
2901 return child->probeLeaf(ijk);
2908 static_assert(
sizeof(
typename DataType::Tile) %
NANOVDB_DATA_ALIGNMENT == 0,
"sizeof(RootData::Tile) is misaligned");
2910 template<
typename,
int,
int,
int>
2922 const Tile* tiles =
reinterpret_cast<const Tile*
>(
this + 1);
2923 const auto key = DataType::CoordToKey(ijk);
2925 for (uint32_t i = 0; i < DataType::mTableSize; ++i) {
2926 if (tiles[i].key == key)
return &tiles[i];
2930 int32_t low = 0, high = DataType::mTableSize;
2931 while (low != high) {
2932 int mid = low + ((high - low) >> 1);
2933 const Tile* tile = &tiles[mid];
2934 if (tile->key == key) {
2936 }
else if (tile->key < key) {
2947 template<
typename AccT>
2948 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ijk,
const AccT& acc)
const
2950 using NodeInfoT =
typename AccT::NodeInfo;
2951 if (
const Tile* tile = this->findTile(ijk)) {
2952 if (tile->isChild()) {
2953 const auto *
child = this->getChild(tile);
2954 acc.insert(ijk,
child);
2955 return child->getNodeInfoAndCache(ijk, acc);
2957 return NodeInfoT{LEVEL, ChildT::dim(), tile->value, tile->value, tile->value,
2958 0, tile->origin(), tile->origin() + CoordType(ChildT::DIM)};
2960 return NodeInfoT{LEVEL, ChildT::dim(), this->minimum(), this->maximum(),
2961 this->average(), this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
2965 template<
typename AccT>
2966 __hostdev__ ValueType getValueAndCache(
const CoordType& ijk,
const AccT& acc)
const
2968 if (
const Tile* tile = this->findTile(ijk)) {
2969 if (tile->isChild()) {
2970 const auto *
child = this->getChild(tile);
2971 acc.insert(ijk,
child);
2972 return child->getValueAndCache(ijk, acc);
2976 return DataType::mBackground;
2979 template<
typename AccT>
2980 __hostdev__ bool isActiveAndCache(
const CoordType& ijk,
const AccT& acc)
const
2982 const Tile* tile = this->findTile(ijk);
2983 if (tile && tile->isChild()) {
2984 const auto *
child = this->getChild(tile);
2985 acc.insert(ijk,
child);
2986 return child->isActiveAndCache(ijk, acc);
2991 template<
typename AccT>
2992 __hostdev__ bool probeValueAndCache(
const CoordType& ijk, ValueType& v,
const AccT& acc)
const
2994 if (
const Tile* tile = this->findTile(ijk)) {
2995 if (tile->isChild()) {
2996 const auto *
child = this->getChild(tile);
2997 acc.insert(ijk,
child);
2998 return child->probeValueAndCache(ijk, v, acc);
3003 v = DataType::mBackground;
3007 template<
typename AccT>
3008 __hostdev__ const LeafNodeType* probeLeafAndCache(
const CoordType& ijk,
const AccT& acc)
const
3010 const Tile* tile = this->findTile(ijk);
3011 if (tile && tile->isChild()) {
3012 const auto *
child = this->getChild(tile);
3013 acc.insert(ijk,
child);
3014 return child->probeLeafAndCache(ijk, acc);
3019 template<
typename RayT,
typename AccT>
3020 __hostdev__ uint32_t getDimAndCache(
const CoordType& ijk,
const RayT& ray,
const AccT& acc)
const
3022 if (
const Tile* tile = this->findTile(ijk)) {
3023 if (tile->isChild()) {
3024 const auto *
child = this->getChild(tile);
3025 acc.insert(ijk,
child);
3026 return child->getDimAndCache(ijk, ray, acc);
3028 return 1 << ChildT::TOTAL;
3030 return ChildNodeType::dim();
3041template<
typename ChildT, u
int32_t LOG2DIM>
3048 using MaskT =
typename ChildT::template MaskType<LOG2DIM>;
3049 static constexpr bool FIXED_SIZE =
true;
3071 alignas(32)
Tile mTable[1u << (3 * LOG2DIM)];
3076 mTable[n].child =
PtrDiff(ptr,
this);
3079 template <
typename ValueT>
3083 mTable[n].value = v;
3090 return PtrAdd<ChildT>(
this, mTable[n].
child);
3095 return PtrAdd<ChildT>(
this, mTable[n].
child);
3098 template <
typename T>
3119template<
typename ChildT, u
int32_t Log2Dim = ChildT::LOG2DIM + 1>
3130 static constexpr bool FIXED_SIZE = DataType::FIXED_SIZE;
3131 template<u
int32_t LOG2>
3134 static constexpr uint32_t LOG2DIM = Log2Dim;
3135 static constexpr uint32_t TOTAL = LOG2DIM + ChildT::TOTAL;
3136 static constexpr uint32_t DIM = 1u << TOTAL;
3137 static constexpr uint32_t SIZE = 1u << (3 * LOG2DIM);
3138 static constexpr uint32_t MASK = (1u << TOTAL) - 1u;
3139 static constexpr uint32_t LEVEL = 1 + ChildT::LEVEL;
3140 static constexpr uint64_t NUM_VALUES = uint64_t(1) << (3 * TOTAL);
3188 const uint32_t n = CoordToOffset(ijk);
3189 return DataType::mChildMask.isOn(n) ? this->getChild(n)->getValue(ijk) : DataType::mTable[n].value;
3194 const uint32_t n = CoordToOffset(ijk);
3195 return DataType::mChildMask.isOn(n) ? this->getChild(n)->isActive(ijk) : DataType::mValueMask.isOn(n);
3200 const uint32_t n = CoordToOffset(ijk);
3201 if (DataType::mChildMask.isOn(n))
3202 return this->getChild(n)->probeValue(ijk, v);
3203 v = DataType::mTable[n].value;
3204 return DataType::mValueMask.isOn(n);
3209 const uint32_t n = CoordToOffset(ijk);
3210 if (DataType::mChildMask.isOn(n))
3211 return this->getChild(n)->probeLeaf(ijk);
3219 return (((ijk[0] & MASK) >> ChildT::TOTAL) << (2 * LOG2DIM)) +
3220 (((ijk[1] & MASK) >> ChildT::TOTAL) << (LOG2DIM)) +
3221 ((ijk[2] & MASK) >> ChildT::TOTAL);
3223 return (((ijk[0] & MASK) >> ChildT::TOTAL) << (2 * LOG2DIM)) |
3224 (((ijk[1] & MASK) >> ChildT::TOTAL) << (LOG2DIM)) |
3225 ((ijk[2] & MASK) >> ChildT::TOTAL);
3233 const uint32_t m = n & ((1 << 2 * LOG2DIM) - 1);
3234 return Coord(n >> 2 * LOG2DIM, m >> LOG2DIM, m & ((1 << LOG2DIM) - 1));
3240 ijk <<= ChildT::TOTAL;
3241 ijk += this->origin();
3247 this->localToGlobalCoord(ijk);
3254 return DataType::mFlags & uint32_t(2);
3261 template<
typename,
int,
int,
int>
3266 template<
typename, u
int32_t>
3270 template<
typename AccT>
3273 const uint32_t n = CoordToOffset(ijk);
3274 if (!DataType::mChildMask.isOn(n))
3275 return DataType::mTable[n].value;
3276 const ChildT*
child = this->getChild(n);
3277 acc.insert(ijk,
child);
3278 return child->getValueAndCache(ijk, acc);
3281 template<
typename AccT>
3282 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ijk,
const AccT& acc)
const
3284 using NodeInfoT =
typename AccT::NodeInfo;
3285 const uint32_t n = CoordToOffset(ijk);
3286 if (!DataType::mChildMask.isOn(n)) {
3287 return NodeInfoT{LEVEL, this->dim(), this->minimum(), this->maximum(), this->average(),
3288 this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
3290 const ChildT*
child = this->getChild(n);
3291 acc.insert(ijk,
child);
3292 return child->getNodeInfoAndCache(ijk, acc);
3295 template<
typename AccT>
3296 __hostdev__ bool isActiveAndCache(
const CoordType& ijk,
const AccT& acc)
const
3298 const uint32_t n = CoordToOffset(ijk);
3299 if (!DataType::mChildMask.isOn(n))
3300 return DataType::mValueMask.isOn(n);
3301 const ChildT*
child = this->getChild(n);
3302 acc.insert(ijk,
child);
3303 return child->isActiveAndCache(ijk, acc);
3306 template<
typename AccT>
3307 __hostdev__ bool probeValueAndCache(
const CoordType& ijk, ValueType& v,
const AccT& acc)
const
3309 const uint32_t n = CoordToOffset(ijk);
3310 if (!DataType::mChildMask.isOn(n)) {
3311 v = DataType::mTable[n].value;
3312 return DataType::mValueMask.isOn(n);
3314 const ChildT*
child = this->getChild(n);
3315 acc.insert(ijk,
child);
3316 return child->probeValueAndCache(ijk, v, acc);
3319 template<
typename AccT>
3320 __hostdev__ const LeafNodeType* probeLeafAndCache(
const CoordType& ijk,
const AccT& acc)
const
3322 const uint32_t n = CoordToOffset(ijk);
3323 if (!DataType::mChildMask.isOn(n))
3325 const ChildT*
child = this->getChild(n);
3326 acc.insert(ijk,
child);
3327 return child->probeLeafAndCache(ijk, acc);
3330 template<
typename RayT,
typename AccT>
3331 __hostdev__ uint32_t getDimAndCache(
const CoordType& ijk,
const RayT& ray,
const AccT& acc)
const
3333 if (DataType::mFlags & uint32_t(1))
3337 const uint32_t n = CoordToOffset(ijk);
3338 if (DataType::mChildMask.isOn(n)) {
3339 const ChildT*
child = this->getChild(n);
3340 acc.insert(ijk,
child);
3341 return child->getDimAndCache(ijk, ray, acc);
3343 return ChildNodeType::dim();
3353template<
typename ValueT,
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3356 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3357 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3362 static constexpr bool FIXED_SIZE =
true;
3365 uint8_t mBBoxDif[3];
3380 mValueMask.setOn(offset);
3381 mValues[offset] =
value;
3394 template <
typename T>
3405template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3408 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3409 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3414 uint8_t mBBoxDif[3];
3425 mQuantum = (
max -
min)/
float((1 << bitWidth)-1);
3453 template <
typename T>
3460template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3461struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp4, CoordT, MaskT, LOG2DIM>
3467 static constexpr bool FIXED_SIZE =
true;
3468 alignas(32) uint8_t mCode[1u << (3 * LOG2DIM - 1)];
3474 const uint8_t c = mCode[i>>1];
3475 return ( (i&1) ? c >> 4 : c & uint8_t(15) )*BaseT::mQuantum + BaseT::mMinimum;
3477 return ((mCode[i>>1] >> ((i&1)<<2)) & uint8_t(15))*BaseT::mQuantum + BaseT::mMinimum;
3488template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3489struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp8, CoordT, MaskT, LOG2DIM>
3495 static constexpr bool FIXED_SIZE =
true;
3496 alignas(32) uint8_t mCode[1u << 3 * LOG2DIM];
3501 return mCode[i]*BaseT::mQuantum + BaseT::mMinimum;
3510template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3511struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp16, CoordT, MaskT, LOG2DIM>
3517 static constexpr bool FIXED_SIZE =
true;
3518 alignas(32) uint16_t mCode[1u << 3 * LOG2DIM];
3523 return mCode[i]*BaseT::mQuantum + BaseT::mMinimum;
3533template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3534struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
FpN, CoordT, MaskT, LOG2DIM>
3539 static constexpr bool FIXED_SIZE =
false;
3546#ifdef NANOVDB_FPN_BRANCHLESS
3547 const int b = BaseT::mFlags >> 5;
3549 uint16_t code =
reinterpret_cast<const uint16_t*
>(
this + 1)[i >> (4 - b)];
3550 const static uint8_t shift[5] = {15, 7, 3, 1, 0};
3551 const static uint16_t mask[5] = {1, 3, 15, 255, 65535};
3552 code >>= (i & shift[b]) << b;
3555 uint32_t code =
reinterpret_cast<const uint32_t*
>(
this + 1)[i >> (5 - b)];
3557 code >>= (i & ((32 >> b) - 1)) << b;
3558 code &= (1 << (1 << b)) - 1;
3562 auto *values =
reinterpret_cast<const uint8_t*
>(
this+1);
3563 switch (BaseT::mFlags >> 5) {
3565 code = float((values[i>>3] >> (i&7) ) & uint8_t(1));
3568 code = float((values[i>>2] >> ((i&3)<<1)) & uint8_t(3));
3571 code = float((values[i>>1] >> ((i&1)<<2)) & uint8_t(15));
3574 code = float(values[i]);
3577 code = float(
reinterpret_cast<const uint16_t*
>(values)[i]);
3580 return float(code) * BaseT::mQuantum + BaseT::mMinimum;
3591template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3592struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<bool, CoordT, MaskT, LOG2DIM>
3594 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3595 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3600 static constexpr bool FIXED_SIZE =
true;
3603 uint8_t mBBoxDif[3];
3616 mValueMask.setOn(offset);
3617 mValues.set(offset, v);
3625 template <
typename T>
3636template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3639 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
3640 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
3645 static constexpr bool FIXED_SIZE =
true;
3648 uint8_t mBBoxDif[3];
3660 mValueMask.setOn(offset);
3668 template <
typename T>
3679template<
typename BuildT,
3680 typename CoordT =
Coord,
3681 template<u
int32_t>
class MaskT =
Mask,
3682 uint32_t Log2Dim = 3>
3696 static constexpr bool FIXED_SIZE = DataType::FIXED_SIZE;
3697 template<u
int32_t LOG2>
3701 static constexpr uint32_t LOG2DIM = Log2Dim;
3702 static constexpr uint32_t TOTAL = LOG2DIM;
3703 static constexpr uint32_t DIM = 1u << TOTAL;
3704 static constexpr uint32_t SIZE = 1u << 3 * LOG2DIM;
3705 static constexpr uint32_t MASK = (1u << LOG2DIM) - 1u;
3706 static constexpr uint32_t LEVEL = 0;
3707 static constexpr uint64_t NUM_VALUES = uint64_t(1) << (3 * TOTAL);
3739 const uint32_t m = n & ((1 << 2 * LOG2DIM) - 1);
3740 return CoordT(n >> 2 * LOG2DIM, m >> LOG2DIM, m & MASK);
3748 return OffsetToLocalCoord(n) + this->origin();
3757 BBox<CoordT> bbox(DataType::mBBoxMin, DataType::mBBoxMin);
3758 if ( this->isActive() ) {
3759 bbox.max()[0] += DataType::mBBoxDif[0];
3760 bbox.max()[1] += DataType::mBBoxDif[1];
3761 bbox.max()[2] += DataType::mBBoxDif[2];
3804 NANOVDB_ASSERT(
bool(DataType::mFlags & uint8_t(2)) != DataType::mValueMask.isOff() );
3805 return DataType::mFlags & uint8_t(2);
3812 const uint32_t n = CoordToOffset(ijk);
3813 v = DataType::getValue(n);
3814 return DataType::mValueMask.isOn(n);
3823 return ((ijk[0] & MASK) << (2 * LOG2DIM)) + ((ijk[1] & MASK) << LOG2DIM) + (ijk[2] & MASK);
3825 return ((ijk[0] & MASK) << (2 * LOG2DIM)) | ((ijk[1] & MASK) << LOG2DIM) | (ijk[2] & MASK);
3842 template<
typename,
int,
int,
int>
3847 template<
typename, u
int32_t>
3851 template<
typename AccT>
3852 __hostdev__ ValueType getValueAndCache(
const CoordT& ijk,
const AccT&)
const {
return this->getValue(ijk); }
3855 template<
typename AccT>
3856 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ,
const AccT& )
const {
3857 using NodeInfoT =
typename AccT::NodeInfo;
3858 return NodeInfoT{LEVEL, this->dim(), this->minimum(), this->maximum(),
3859 this->average(), this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
3862 template<
typename AccT>
3863 __hostdev__ bool isActiveAndCache(
const CoordT& ijk,
const AccT&)
const {
return this->isActive(ijk); }
3865 template<
typename AccT>
3866 __hostdev__ bool probeValueAndCache(
const CoordT& ijk, ValueType& v,
const AccT&)
const {
return this->probeValue(ijk, v); }
3868 template<
typename AccT>
3869 __hostdev__ const LeafNode* probeLeafAndCache(
const CoordT&,
const AccT&)
const {
return this; }
3871 template<
typename RayT,
typename AccT>
3872 __hostdev__ uint32_t getDimAndCache(
const CoordT&,
const RayT& ,
const AccT&)
const
3874 if (DataType::mFlags & uint8_t(1))
3877 return ChildNodeType::dim();
3882template<
typename ValueT,
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
3885 static_assert(LOG2DIM == 3,
"LeafNode::updateBBox: only supports LOGDIM = 3!");
3886 if (!this->isActive())
return;
3887 auto update = [&](uint32_t
min, uint32_t
max,
int axis) {
3889 DataType::mBBoxMin[axis] = (DataType::mBBoxMin[axis] & ~MASK) +
int(
min);
3890 DataType::mBBoxDif[axis] = uint8_t(
max -
min);
3892 uint64_t word64 = DataType::mValueMask.template getWord<uint64_t>(0);
3893 uint32_t Xmin = word64 ? 0u : 8u;
3894 uint32_t Xmax = Xmin;
3895 for (
int i = 1; i < 8; ++i) {
3896 if (uint64_t w = DataType::mValueMask.
template getWord<uint64_t>(i)) {
3905 update(Xmin, Xmax, 0);
3907 const uint32_t *p =
reinterpret_cast<const uint32_t*
>(&word64), word32 = p[0] | p[1];
3908 const uint16_t *q =
reinterpret_cast<const uint16_t*
>(&word32), word16 = q[0] | q[1];
3909 const uint8_t *b =
reinterpret_cast<const uint8_t*
>(&word16),
byte = b[0] | b[1];
3918template<
typename BuildT>
3920template<
typename BuildT>
3922template<
typename BuildT>
3924template<
typename BuildT>
3926template<
typename BuildT>
3928template<
typename BuildT>
3932template<
typename BuildT,
int LEVEL>
3936template<
typename BuildT>
3942template<
typename BuildT>
3948template<
typename BuildT>
3954template<
typename BuildT>
4008template <
typename BuildT>
4016 mutable const RootT* mRoot;
4021 static const int CacheLevels = 0;
4046 return mRoot->getValueAndCache(ijk, *
this);
4051 return mRoot->getNodeInfoAndCache(ijk, *
this);
4056 return mRoot->isActiveAndCache(ijk, *
this);
4061 return mRoot->probeValueAndCache(ijk, v, *
this);
4066 return mRoot->probeLeafAndCache(ijk, *
this);
4069 template<
typename RayT>
4072 return mRoot->getDimAndCache(ijk, ray, *
this);
4079 template<
typename, u
int32_t>
4081 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4085 template<
typename NodeT>
4090template <
typename BuildT,
int LEVEL0>
4093 static_assert(LEVEL0 >= 0 && LEVEL0 <= 2,
"LEVEL0 should be 0, 1, or 2");
4106 mutable CoordT mKey;
4107 mutable const RootT* mRoot;
4108 mutable const NodeT* mNode;
4114 static const int CacheLevels = 1;
4135 return (ijk[0] & int32_t(~NodeT::MASK)) == mKey[0] &&
4136 (ijk[1] & int32_t(~NodeT::MASK)) == mKey[1] &&
4137 (ijk[2] & int32_t(~NodeT::MASK)) == mKey[2];
4142 if (this->isCached(ijk)) {
4143 return mNode->getValueAndCache(ijk, *
this);
4145 return mRoot->getValueAndCache(ijk, *
this);
4150 if (this->isCached(ijk)) {
4151 return mNode->getNodeInfoAndCache(ijk, *
this);
4153 return mRoot->getNodeInfoAndCache(ijk, *
this);
4158 if (this->isCached(ijk)) {
4159 return mNode->isActiveAndCache(ijk, *
this);
4161 return mRoot->isActiveAndCache(ijk, *
this);
4166 if (this->isCached(ijk)) {
4167 return mNode->probeValueAndCache(ijk, v, *
this);
4169 return mRoot->probeValueAndCache(ijk, v, *
this);
4174 if (this->isCached(ijk)) {
4175 return mNode->probeLeafAndCache(ijk, *
this);
4177 return mRoot->probeLeafAndCache(ijk, *
this);
4180 template<
typename RayT>
4183 if (this->isCached(ijk)) {
4184 return mNode->getDimAndCache(ijk, ray, *
this);
4186 return mRoot->getDimAndCache(ijk, ray, *
this);
4193 template<
typename, u
int32_t>
4195 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4201 mKey = ijk & ~NodeT::MASK;
4206 template<
typename OtherNodeT>
4207 __hostdev__ void insert(
const CoordType&,
const OtherNodeT*)
const {}
4211template <
typename BuildT,
int LEVEL0,
int LEVEL1>
4214 static_assert(LEVEL0 >= 0 && LEVEL0 <= 2,
"LEVEL0 must be 0, 1, 2");
4215 static_assert(LEVEL1 >= 0 && LEVEL1 <= 2,
"LEVEL1 must be 0, 1, 2");
4216 static_assert(LEVEL0 < LEVEL1,
"Level 0 must be lower than level 1");
4228#ifdef USE_SINGLE_ACCESSOR_KEY
4229 mutable CoordT mKey;
4231 mutable CoordT mKeys[2];
4233 mutable const RootT* mRoot;
4234 mutable const Node1T* mNode1;
4235 mutable const Node2T* mNode2;
4241 static const int CacheLevels = 2;
4247#ifdef USE_SINGLE_ACCESSOR_KEY
4265#ifdef USE_SINGLE_ACCESSOR_KEY
4266 __hostdev__ bool isCached1(CoordValueType dirty)
const
4270 if (dirty & int32_t(~Node1T::MASK)) {
4276 __hostdev__ bool isCached2(CoordValueType dirty)
const
4280 if (dirty & int32_t(~Node2T::MASK)) {
4286 __hostdev__ CoordValueType computeDirty(
const CoordType& ijk)
const
4288 return (ijk[0] ^ mKey[0]) | (ijk[1] ^ mKey[1]) | (ijk[2] ^ mKey[2]);
4293 return (ijk[0] & int32_t(~Node1T::MASK)) == mKeys[0][0] &&
4294 (ijk[1] & int32_t(~Node1T::MASK)) == mKeys[0][1] &&
4295 (ijk[2] & int32_t(~Node1T::MASK)) == mKeys[0][2];
4299 return (ijk[0] & int32_t(~Node2T::MASK)) == mKeys[1][0] &&
4300 (ijk[1] & int32_t(~Node2T::MASK)) == mKeys[1][1] &&
4301 (ijk[2] & int32_t(~Node2T::MASK)) == mKeys[1][2];
4307#ifdef USE_SINGLE_ACCESSOR_KEY
4308 const CoordValueType dirty = this->computeDirty(ijk);
4312 if (this->isCached1(dirty)) {
4313 return mNode1->getValueAndCache(ijk, *
this);
4314 }
else if (this->isCached2(dirty)) {
4315 return mNode2->getValueAndCache(ijk, *
this);
4317 return mRoot->getValueAndCache(ijk, *
this);
4322#ifdef USE_SINGLE_ACCESSOR_KEY
4323 const CoordValueType dirty = this->computeDirty(ijk);
4327 if (this->isCached1(dirty)) {
4328 return mNode1->getNodeInfoAndCache(ijk, *
this);
4329 }
else if (this->isCached2(dirty)) {
4330 return mNode2->getNodeInfoAndCache(ijk, *
this);
4332 return mRoot->getNodeInfoAndCache(ijk, *
this);
4337#ifdef USE_SINGLE_ACCESSOR_KEY
4338 const CoordValueType dirty = this->computeDirty(ijk);
4342 if (this->isCached1(dirty)) {
4343 return mNode1->isActiveAndCache(ijk, *
this);
4344 }
else if (this->isCached2(dirty)) {
4345 return mNode2->isActiveAndCache(ijk, *
this);
4347 return mRoot->isActiveAndCache(ijk, *
this);
4352#ifdef USE_SINGLE_ACCESSOR_KEY
4353 const CoordValueType dirty = this->computeDirty(ijk);
4357 if (this->isCached1(dirty)) {
4358 return mNode1->probeValueAndCache(ijk, v, *
this);
4359 }
else if (this->isCached2(dirty)) {
4360 return mNode2->probeValueAndCache(ijk, v, *
this);
4362 return mRoot->probeValueAndCache(ijk, v, *
this);
4367#ifdef USE_SINGLE_ACCESSOR_KEY
4368 const CoordValueType dirty = this->computeDirty(ijk);
4372 if (this->isCached1(dirty)) {
4373 return mNode1->probeLeafAndCache(ijk, *
this);
4374 }
else if (this->isCached2(dirty)) {
4375 return mNode2->probeLeafAndCache(ijk, *
this);
4377 return mRoot->probeLeafAndCache(ijk, *
this);
4380 template<
typename RayT>
4383#ifdef USE_SINGLE_ACCESSOR_KEY
4384 const CoordValueType dirty = this->computeDirty(ijk);
4388 if (this->isCached1(dirty)) {
4389 return mNode1->getDimAndCache(ijk, ray, *
this);
4390 }
else if (this->isCached2(dirty)) {
4391 return mNode2->getDimAndCache(ijk, ray, *
this);
4393 return mRoot->getDimAndCache(ijk, ray, *
this);
4400 template<
typename, u
int32_t>
4402 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4408#ifdef USE_SINGLE_ACCESSOR_KEY
4411 mKeys[0] = ijk & ~Node1T::MASK;
4415 __hostdev__ void insert(
const CoordType& ijk,
const Node2T* node)
const
4417#ifdef USE_SINGLE_ACCESSOR_KEY
4420 mKeys[1] = ijk & ~Node2T::MASK;
4424 template <
typename OtherNodeT>
4425 __hostdev__ void insert(
const CoordType&,
const OtherNodeT*)
const {}
4430template <
typename BuildT>
4445#ifdef USE_SINGLE_ACCESSOR_KEY
4446 mutable CoordT mKey;
4448 mutable CoordT mKeys[3];
4450 mutable const RootT* mRoot;
4451 mutable const void* mNode[3];
4457 static const int CacheLevels = 3;
4463#ifdef USE_SINGLE_ACCESSOR_KEY
4469 , mNode{
nullptr,
nullptr,
nullptr}
4483 template<
typename NodeT>
4488 return reinterpret_cast<const T*
>(mNode[NodeT::LEVEL]);
4491#ifdef USE_SINGLE_ACCESSOR_KEY
4492 template<
typename NodeT>
4493 __hostdev__ bool isCached(CoordValueType dirty)
const
4495 if (!mNode[NodeT::LEVEL])
4497 if (dirty & int32_t(~NodeT::MASK)) {
4498 mNode[NodeT::LEVEL] =
nullptr;
4504 __hostdev__ CoordValueType computeDirty(
const CoordType& ijk)
const
4506 return (ijk[0] ^ mKey[0]) | (ijk[1] ^ mKey[1]) | (ijk[2] ^ mKey[2]);
4509 template<
typename NodeT>
4512 return (ijk[0] & int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL][0] && (ijk[1] & int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL][1] && (ijk[2] & int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL][2];
4518#ifdef USE_SINGLE_ACCESSOR_KEY
4519 const CoordValueType dirty = this->computeDirty(ijk);
4523 if (this->isCached<LeafT>(dirty)) {
4524 return ((
LeafT*)mNode[0])->getValue(ijk);
4525 }
else if (this->isCached<NodeT1>(dirty)) {
4526 return ((
NodeT1*)mNode[1])->getValueAndCache(ijk, *
this);
4527 }
else if (this->isCached<NodeT2>(dirty)) {
4528 return ((
NodeT2*)mNode[2])->getValueAndCache(ijk, *
this);
4530 return mRoot->getValueAndCache(ijk, *
this);
4535#ifdef USE_SINGLE_ACCESSOR_KEY
4536 const CoordValueType dirty = this->computeDirty(ijk);
4540 if (this->isCached<LeafT>(dirty)) {
4541 return ((
LeafT*)mNode[0])->getNodeInfoAndCache(ijk, *
this);
4542 }
else if (this->isCached<NodeT1>(dirty)) {
4543 return ((
NodeT1*)mNode[1])->getNodeInfoAndCache(ijk, *
this);
4544 }
else if (this->isCached<NodeT2>(dirty)) {
4545 return ((
NodeT2*)mNode[2])->getNodeInfoAndCache(ijk, *
this);
4547 return mRoot->getNodeInfoAndCache(ijk, *
this);
4552#ifdef USE_SINGLE_ACCESSOR_KEY
4553 const CoordValueType dirty = this->computeDirty(ijk);
4557 if (this->isCached<LeafT>(dirty)) {
4558 return ((
LeafT*)mNode[0])->isActive(ijk);
4559 }
else if (this->isCached<NodeT1>(dirty)) {
4560 return ((
NodeT1*)mNode[1])->isActiveAndCache(ijk, *
this);
4561 }
else if (this->isCached<NodeT2>(dirty)) {
4562 return ((
NodeT2*)mNode[2])->isActiveAndCache(ijk, *
this);
4564 return mRoot->isActiveAndCache(ijk, *
this);
4569#ifdef USE_SINGLE_ACCESSOR_KEY
4570 const CoordValueType dirty = this->computeDirty(ijk);
4574 if (this->isCached<LeafT>(dirty)) {
4575 return ((
LeafT*)mNode[0])->probeValue(ijk, v);
4576 }
else if (this->isCached<NodeT1>(dirty)) {
4577 return ((
NodeT1*)mNode[1])->probeValueAndCache(ijk, v, *
this);
4578 }
else if (this->isCached<NodeT2>(dirty)) {
4579 return ((
NodeT2*)mNode[2])->probeValueAndCache(ijk, v, *
this);
4581 return mRoot->probeValueAndCache(ijk, v, *
this);
4586#ifdef USE_SINGLE_ACCESSOR_KEY
4587 const CoordValueType dirty = this->computeDirty(ijk);
4591 if (this->isCached<LeafT>(dirty)) {
4592 return ((
LeafT*)mNode[0]);
4593 }
else if (this->isCached<NodeT1>(dirty)) {
4594 return ((
NodeT1*)mNode[1])->probeLeafAndCache(ijk, *
this);
4595 }
else if (this->isCached<NodeT2>(dirty)) {
4596 return ((
NodeT2*)mNode[2])->probeLeafAndCache(ijk, *
this);
4598 return mRoot->probeLeafAndCache(ijk, *
this);
4601 template<
typename RayT>
4604#ifdef USE_SINGLE_ACCESSOR_KEY
4605 const CoordValueType dirty = this->computeDirty(ijk);
4609 if (this->isCached<LeafT>(dirty)) {
4610 return ((
LeafT*)mNode[0])->getDimAndCache(ijk, ray, *
this);
4611 }
else if (this->isCached<NodeT1>(dirty)) {
4612 return ((
NodeT1*)mNode[1])->getDimAndCache(ijk, ray, *
this);
4613 }
else if (this->isCached<NodeT2>(dirty)) {
4614 return ((
NodeT2*)mNode[2])->getDimAndCache(ijk, ray, *
this);
4616 return mRoot->getDimAndCache(ijk, ray, *
this);
4623 template<
typename, u
int32_t>
4625 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
4629 template<
typename NodeT>
4632#ifdef USE_SINGLE_ACCESSOR_KEY
4635 mKeys[NodeT::LEVEL] = ijk & ~NodeT::MASK;
4637 mNode[NodeT::LEVEL] = node;
4655template <
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
4661template <
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
4667template <
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
4719template<
typename AttT>
4730 :
AccT(grid.tree().root())
4732 , mData(reinterpret_cast<const AttT*>(grid.blindData(0)))
4745 end = begin + count;
4753 auto* leaf = this->probeLeaf(ijk);
4754 if (leaf ==
nullptr) {
4757 begin = mData + leaf->minimum();
4758 end = begin + leaf->maximum();
4759 return leaf->maximum();
4765 auto* leaf = this->probeLeaf(ijk);
4766 if (leaf ==
nullptr)
4768 const uint32_t offset = LeafNodeType::CoordToOffset(ijk);
4769 if (leaf->isActive(offset)) {
4770 auto* p = mData + leaf->minimum();
4771 begin = p + (offset == 0 ? 0 : leaf->getValue(offset - 1));
4772 end = p + leaf->getValue(offset);
#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:2308
Vec3T indexToWorld(const Vec3T &xyz) const
index to world space transformation
Definition: NanoVDB.h:2364
const GridBlindMetaData & blindMetaData(int n) const
Definition: NanoVDB.h:2482
Vec3T indexToWorldF(const Vec3T &xyz) const
index to world space transformation
Definition: NanoVDB.h:2387
const GridType & gridType() const
Definition: NanoVDB.h:2418
typename TreeT::ValueType ValueType
Definition: NanoVDB.h:2313
int findBlindDataForSemantic(GridBlindDataSemantic semantic) const
Return the index of the blind data with specified semantic if found, otherwise -1.
Definition: NanoVDB.h:2489
typename TreeT::RootType RootType
Definition: NanoVDB.h:2311
bool isSequential() const
return true if the specified node type is layed out breadth-first in memory and has a fixed size....
Definition: NanoVDB.h:2437
bool isPointData() const
Definition: NanoVDB.h:2424
uint32_t gridIndex() const
Return index of this grid in the buffer.
Definition: NanoVDB.h:2338
const char * shortGridName() const
Return a c-string with the name of this grid, truncated to 255 characters.
Definition: NanoVDB.h:2456
bool isBreadthFirst() const
Definition: NanoVDB.h:2432
uint64_t activeVoxelCount() const
Return the total number of active voxels in this tree.
Definition: NanoVDB.h:2414
Vec3T indexToWorldDirF(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition: NanoVDB.h:2392
typename TreeT::CoordType CoordType
Definition: NanoVDB.h:2315
Vec3T worldToIndexF(const Vec3T &xyz) const
world to index space transformation
Definition: NanoVDB.h:2383
Vec3T worldToIndexDirF(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition: NanoVDB.h:2397
const Vec3R & voxelSize() const
Return a const reference to the size of a voxel in world units.
Definition: NanoVDB.h:2353
bool isStaggered() const
Definition: NanoVDB.h:2422
const GridClass & gridClass() const
Definition: NanoVDB.h:2419
bool isValid() const
Methods related to the classification of this grid.
Definition: NanoVDB.h:2417
DataType * data()
Definition: NanoVDB.h:2327
bool hasAverage() const
Definition: NanoVDB.h:2430
bool hasMinMax() const
Definition: NanoVDB.h:2427
const char * gridName() const
Return a c-string with the name of this grid.
Definition: NanoVDB.h:2445
const BBox< Vec3R > & worldBBox() const
Computes a AABB of active values in world space.
Definition: NanoVDB.h:2405
AccessorType getAccessor() const
Return a new instance of a ReadAccessor used to access values in this grid.
Definition: NanoVDB.h:2350
uint64_t gridSize() const
Return the memory footprint of the entire grid, i.e. including all nodes and blind data.
Definition: NanoVDB.h:2335
Vec3T indexToWorldDir(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition: NanoVDB.h:2369
int blindDataCount() const
Return the count of blind-data encoded in this grid.
Definition: NanoVDB.h:2465
Vec3T indexToWorldGradF(const Vec3T &grad) const
Transforms the gradient from index space to world space.
Definition: NanoVDB.h:2402
uint64_t checksum() const
Return checksum of the grid buffer.
Definition: NanoVDB.h:2459
bool isFogVolume() const
Definition: NanoVDB.h:2421
const TreeT & tree() const
Return a const reference to the tree.
Definition: NanoVDB.h:2344
bool isMask() const
Definition: NanoVDB.h:2425
const BBox< CoordType > & indexBBox() const
Computes a AABB of active values in index space.
Definition: NanoVDB.h:2411
bool hasLongGridName() const
Definition: NanoVDB.h:2429
const void * blindData(uint32_t n) const
Returns a const pointer to the blindData at the specified linear offset.
Definition: NanoVDB.h:2473
static uint64_t memUsage()
Return memory usage in bytes for this class only.
Definition: NanoVDB.h:2332
TreeT & tree()
Return a non-const reference to the tree.
Definition: NanoVDB.h:2347
Vec3T worldToIndex(const Vec3T &xyz) const
world to index space transformation
Definition: NanoVDB.h:2360
uint32_t gridCount() const
Return total number of grids in the buffer.
Definition: NanoVDB.h:2341
Vec3T worldToIndexDir(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition: NanoVDB.h:2374
Version version() const
Definition: NanoVDB.h:2325
bool isEmpty() const
Return true if this grid is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:2462
const Map & map() const
Return a const reference to the Map for this grid.
Definition: NanoVDB.h:2356
bool hasStdDeviation() const
Definition: NanoVDB.h:2431
bool hasBBox() const
Definition: NanoVDB.h:2428
bool isLevelSet() const
Definition: NanoVDB.h:2420
TreeT TreeType
Definition: NanoVDB.h:2310
Grid(const Grid &)=delete
Disallow constructions, copy and assignment.
typename TreeT::BuildType BuildType
Definition: NanoVDB.h:2314
Grid & operator=(const Grid &)=delete
Vec3T indexToWorldGrad(const Vec3T &grad) const
transform the gradient from index space to world space.
Definition: NanoVDB.h:2379
const DataType * data() const
Definition: NanoVDB.h:2329
bool isPointIndex() const
Definition: NanoVDB.h:2423
bool isUnknown() const
Definition: NanoVDB.h:2426
Dummy type for a 16 bit floating point values.
Definition: NanoVDB.h:192
Internal nodes of a VDB treedim(),.
Definition: NanoVDB.h:3121
Coord offsetToGlobalCoord(uint32_t n) const
Definition: NanoVDB.h:3244
const MaskType< LOG2DIM > & valueMask() const
Return a const reference to the bit mask of active voxels in this internal node.
Definition: NanoVDB.h:3159
bool isActive() const
Retrun true if this node or any of its child nodes contain active values.
Definition: NanoVDB.h:3252
static uint32_t dim()
Return the dimension, in voxel units, of this internal node (typically 8*16 or 8*16*32)
Definition: NanoVDB.h:3153
static size_t memUsage()
Return memory usage in bytes for the class.
Definition: NanoVDB.h:3156
CoordType origin() const
Return the origin in index space of this leaf node.
Definition: NanoVDB.h:3165
typename ChildT::CoordType CoordType
Definition: NanoVDB.h:3129
const BBox< CoordType > & bbox() const
Return a const reference to the bounding box in index space of active values in this internal node an...
Definition: NanoVDB.h:3183
FloatType variance() const
Return the variance of all the active values encoded in this internal node and any of its child nodes...
Definition: NanoVDB.h:3177
const MaskType< LOG2DIM > & childMask() const
Return a const reference to the bit mask of child nodes in this internal node.
Definition: NanoVDB.h:3162
const FloatType & average() const
Return a const reference to the average of all the active values encoded in this internal node and an...
Definition: NanoVDB.h:3174
DataType * data()
Definition: NanoVDB.h:3148
void localToGlobalCoord(Coord &ijk) const
modifies local coordinates to global coordinates of a tile or child node
Definition: NanoVDB.h:3238
typename DataType::BuildT BuildType
Definition: NanoVDB.h:3126
ChildT ChildNodeType
Definition: NanoVDB.h:3128
const LeafNodeType * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:3207
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:3192
typename DataType::ValueT ValueType
Definition: NanoVDB.h:3124
static uint32_t CoordToOffset(const CoordType &ijk)
Return the linear offset corresponding to the given coordinate.
Definition: NanoVDB.h:3216
typename DataType::StatsT FloatType
Definition: NanoVDB.h:3125
static Coord OffsetToLocalCoord(uint32_t n)
Definition: NanoVDB.h:3230
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:3198
typename ChildT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:3127
const FloatType & stdDeviation() const
Return a const reference to the standard deviation of all the active values encoded in this internal ...
Definition: NanoVDB.h:3180
const ValueType & maximum() const
Return a const reference to the maximum active value encoded in this internal node and any of its chi...
Definition: NanoVDB.h:3171
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:3186
typename ChildT::template MaskType< LOG2 > MaskType
Definition: NanoVDB.h:3132
const ValueType & minimum() const
Return a const reference to the minimum active value encoded in this internal node and any of its chi...
Definition: NanoVDB.h:3168
const DataType * data() const
Definition: NanoVDB.h:3150
InternalNode & operator=(const InternalNode &)=delete
InternalNode(const InternalNode &)=delete
Leaf nodes of the VDB tree. (defaults to 8x8x8 = 512 voxels)
Definition: NanoVDB.h:3684
void setValue(const CoordT &ijk, const ValueType &v)
Sets the value at the specified location and activate its state.
Definition: NanoVDB.h:3789
void setValueOnly(uint32_t offset, const ValueType &v)
Sets the value at the specified location but leaves its state unchanged.
Definition: NanoVDB.h:3794
bool isActive(const CoordT &ijk) const
Return true if the voxel value at the given coordinate is active.
Definition: NanoVDB.h:3798
typename DataType::BuildType BuildType
Definition: NanoVDB.h:3694
const MaskType< LOG2DIM > & valueMask() const
Return a const reference to the bit mask of active voxels in this leaf node.
Definition: NanoVDB.h:3714
bool isActive() const
Return true if any of the voxel value are active in this leaf node.
Definition: NanoVDB.h:3802
CoordT CoordType
Definition: NanoVDB.h:3695
static uint32_t dim()
Return the dimension, in index space, of this leaf node (typically 8 as for openvdb leaf nodes!...
Definition: NanoVDB.h:3752
void updateBBox()
Updates the local bounding box of active voxels in this node.
Definition: NanoVDB.h:3883
bool probeValue(const CoordT &ijk, ValueType &v) const
Return true if the voxel value at the given coordinate is active and updates v with the value.
Definition: NanoVDB.h:3810
FloatType variance() const
Return the variance of all the active values encoded in this leaf node.
Definition: NanoVDB.h:3726
LeafNode & operator=(const LeafNode &)=delete
bool isActive(uint32_t n) const
Definition: NanoVDB.h:3799
DataType * data()
Definition: NanoVDB.h:3709
uint8_t flags() const
Definition: NanoVDB.h:3731
void localToGlobalCoord(Coord &ijk) const
Converts (in place) a local index coordinate to a global index coordinate.
Definition: NanoVDB.h:3744
ValueType maximum() const
Return a const reference to the maximum active value encoded in this leaf node.
Definition: NanoVDB.h:3720
typename DataType::FloatType FloatType
Definition: NanoVDB.h:3693
CoordT origin() const
Return the origin in index space of this leaf node.
Definition: NanoVDB.h:3734
static uint32_t CoordToOffset(const CoordT &ijk)
Return the linear offset corresponding to the given coordinate.
Definition: NanoVDB.h:3820
CoordT offsetToGlobalCoord(uint32_t n) const
Definition: NanoVDB.h:3746
void setValueOnly(const CoordT &ijk, const ValueType &v)
Definition: NanoVDB.h:3795
ValueType getValue(uint32_t offset) const
Return the voxel value at the given offset.
Definition: NanoVDB.h:3781
FloatType average() const
Return a const reference to the average of all the active values encoded in this leaf node.
Definition: NanoVDB.h:3723
const LeafNode * probeLeaf(const CoordT &) const
Definition: NanoVDB.h:3817
ValueType getValue(const CoordT &ijk) const
Return the voxel value at the given coordinate.
Definition: NanoVDB.h:3784
MaskT< LOG2 > MaskType
Definition: NanoVDB.h:3698
static uint32_t voxelCount()
Return the total number of voxels (e.g. values) encoded in this leaf node.
Definition: NanoVDB.h:3769
LeafNode(const LeafNode &)=delete
static uint64_t memUsage()
return memory usage in bytes for the class
Definition: NanoVDB.h:3772
BBox< CoordT > bbox() const
Return the bounding box in index space of active values in this leaf node.
Definition: NanoVDB.h:3755
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:3717
typename DataType::ValueType ValueType
Definition: NanoVDB.h:3692
static CoordT OffsetToLocalCoord(uint32_t n)
Definition: NanoVDB.h:3736
const DataType * data() const
Definition: NanoVDB.h:3711
FloatType stdDeviation() const
Return a const reference to the standard deviation of all the active values encoded in this leaf node...
Definition: NanoVDB.h:3729
Definition: NanoVDB.h:1819
Iterator()
Definition: NanoVDB.h:1821
Iterator & operator=(const Iterator &)=default
uint32_t operator*() const
Definition: NanoVDB.h:1832
Iterator(uint32_t pos, const Mask *parent)
Definition: NanoVDB.h:1826
Iterator & operator++()
Definition: NanoVDB.h:1834
Bit-mask to encode active states and facilitate sequential iterators and a fast codec for I/O compres...
Definition: NanoVDB.h:1795
Iterator beginOn() const
Definition: NanoVDB.h:1898
void set(uint32_t n, bool On)
Definition: NanoVDB.h:1923
bool operator==(const Mask &other) const
Definition: NanoVDB.h:1888
static size_t memUsage()
Return the memory footprint in bytes of this Mask.
Definition: NanoVDB.h:1802
void setOn()
Set all bits on.
Definition: NanoVDB.h:1936
void toggle(uint32_t n)
Definition: NanoVDB.h:1963
uint32_t countOn() const
Definition: NanoVDB.h:1810
void setOff(uint32_t n)
Definition: NanoVDB.h:1921
Mask(const Mask &other)
Copy constructor.
Definition: NanoVDB.h:1859
Mask(bool on)
Definition: NanoVDB.h:1851
Mask & operator=(const MaskT &other)
Assignment operator that works with openvdb::util::NodeMask.
Definition: NanoVDB.h:1875
bool isOn(uint32_t n) const
Return true if the given bit is set.
Definition: NanoVDB.h:1901
void set(bool on)
Set all bits off.
Definition: NanoVDB.h:1950
void setOff()
Set all bits off.
Definition: NanoVDB.h:1943
static uint32_t bitCount()
Return the number of bits available in this Mask.
Definition: NanoVDB.h:1805
bool isOff() const
Definition: NanoVDB.h:1911
bool operator!=(const Mask &other) const
Definition: NanoVDB.h:1896
void toggle()
brief Toggle the state of all bits in the mask
Definition: NanoVDB.h:1957
static uint32_t wordCount()
Return the number of machine words used by this Mask.
Definition: NanoVDB.h:1808
WordT getWord(int n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NanoVDB.h:1867
bool isOn() const
Definition: NanoVDB.h:1903
Mask()
Initialize all bits to zero.
Definition: NanoVDB.h:1846
void setOn(uint32_t n)
Set the given bit on.
Definition: NanoVDB.h:1920
Class to access points at a specific voxel location.
Definition: NanoVDB.h:4721
uint64_t gridPoints(const AttT *&begin, const AttT *&end) const
Return the total number of point in the grid and set the iterators to the complete range of points.
Definition: NanoVDB.h:4741
typename NanoRoot< uint32_t >::LeafNodeType LeafNodeType
Definition: NanoVDB.h:4727
uint64_t leafPoints(const Coord &ijk, const AttT *&begin, const AttT *&end) const
Return the number of points in the leaf node containing the coordinate ijk. If this return value is l...
Definition: NanoVDB.h:4751
PointAccessor(const UInt32Grid &grid)
Definition: NanoVDB.h:4729
uint64_t voxelPoints(const Coord &ijk, const AttT *&begin, const AttT *&end) const
get iterators over offsets to points at a specific voxel location
Definition: NanoVDB.h:4763
ReadAccessor & operator=(const ReadAccessor &)=default
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4049
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4054
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4059
typename RootT::CoordType CoordType
Definition: NanoVDB.h:4019
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition: NanoVDB.h:4037
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4044
typename RootT::ValueType ValueType
Definition: NanoVDB.h:4018
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4064
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4070
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4035
Node caching at all (three) tree levels.
Definition: NanoVDB.h:4432
ReadAccessor & operator=(const ReadAccessor &)=default
typename ReadAccessor< ValueT, -1, -1, -1 >::NodeInfo NodeInfo
Definition: NanoVDB.h:4459
CoordT CoordType
Definition: NanoVDB.h:4455
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4533
ValueT ValueType
Definition: NanoVDB.h:4454
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4550
const NodeT * getNode() const
Return a const point to the cached node of the specified type.
Definition: NanoVDB.h:4484
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4567
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition: NanoVDB.h:4473
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4516
bool isCached(const CoordType &ijk) const
Definition: NanoVDB.h:4510
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4584
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4602
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4462
ReadAccessor & operator=(const ReadAccessor &)=default
typename ReadAccessor< ValueT, -1, -1, -1 >::NodeInfo NodeInfo
Definition: NanoVDB.h:4116
CoordT CoordType
Definition: NanoVDB.h:4112
bool isCached(const CoordType &ijk) const
Definition: NanoVDB.h:4133
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4148
ValueT ValueType
Definition: NanoVDB.h:4111
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4156
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4164
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition: NanoVDB.h:4126
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4140
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4172
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4181
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4119
ReadAccessor & operator=(const ReadAccessor &)=default
CoordT CoordType
Definition: NanoVDB.h:4239
NodeInfo getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:4320
ValueT ValueType
Definition: NanoVDB.h:4238
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4335
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:4350
typename ReadAccessor< ValueT,-1,-1,-1 >::NodeInfo NodeInfo
Definition: NanoVDB.h:4243
bool isCached1(const CoordType &ijk) const
Definition: NanoVDB.h:4291
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition: NanoVDB.h:4258
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:4305
bool isCached2(const CoordType &ijk) const
Definition: NanoVDB.h:4297
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4365
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:4381
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:4246
Definition: NanoVDB.h:2297
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:2799
const uint32_t & tileCount() const
Return the number of tiles encoded in this root node.
Definition: NanoVDB.h:2839
static uint64_t memUsage(uint32_t tableSize)
Return the expected memory footprint in bytes with the specified number of tiles.
Definition: NanoVDB.h:2857
typename ChildT::CoordType CoordType
Definition: NanoVDB.h:2810
const BBox< CoordType > & bbox() const
Return a const reference to the index bounding box of all the active values in this tree,...
Definition: NanoVDB.h:2830
FloatType variance() const
Return the variance of all the active values encoded in this root node and any of its child nodes.
Definition: NanoVDB.h:2851
const FloatType & average() const
Return a const reference to the average of all the active values encoded in this root node and any of...
Definition: NanoVDB.h:2848
RootNode & operator=(const RootNode &)=delete
DataType * data()
Definition: NanoVDB.h:2825
AccessorType getAccessor() const
Definition: NanoVDB.h:2823
typename DataType::BuildT BuildType
Definition: NanoVDB.h:2808
RootNode(const RootNode &)=delete
ChildT ChildNodeType
Definition: NanoVDB.h:2803
const LeafNodeType * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:2896
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:2871
typename DataType::ValueT ValueType
Definition: NanoVDB.h:2806
typename DataType::StatsT FloatType
Definition: NanoVDB.h:2807
uint64_t memUsage() const
Return the actual memory footprint of this root node.
Definition: NanoVDB.h:2860
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:2882
typename ChildT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:2802
const FloatType & stdDeviation() const
Return a const reference to the standard deviation of all the active values encoded in this root node...
Definition: NanoVDB.h:2854
const ValueType & maximum() const
Return a const reference to the maximum active value encoded in this root node and any of its child n...
Definition: NanoVDB.h:2845
typename DataType::Tile Tile
Definition: NanoVDB.h:2812
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel.
Definition: NanoVDB.h:2863
const ValueType & background() const
Return the total number of active voxels in the root and all its child nodes.
Definition: NanoVDB.h:2836
bool isEmpty() const
Return true if this RootNode is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:2880
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:2842
const DataType * data() const
Definition: NanoVDB.h:2827
VDB Tree, which is a thin wrapper around a RootNode.
Definition: NanoVDB.h:2543
typename RootT::ChildNodeType Node2
Definition: NanoVDB.h:2559
RootT Node3
Definition: NanoVDB.h:2558
const NodeT * getFirstNode() const
return a const pointer to the first node of the specified type
Definition: NanoVDB.h:2642
uint64_t activeVoxelCount() const
Return the total number of active voxels in this tree.
Definition: NanoVDB.h:2604
typename RootT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:2552
const BBox< CoordType > & bbox() const
Return a const reference to the index bounding box of all the active values in this tree,...
Definition: NanoVDB.h:2601
DataType * data()
Definition: NanoVDB.h:2569
uint32_t nodeCount() const
Definition: NanoVDB.h:2616
Tree()=delete
This class cannot be constructed or deleted.
AccessorType getAccessor() const
Definition: NanoVDB.h:2580
bool isActive(const CoordType &ijk) const
Return the active state of the given voxel (regardless of state or location in the tree....
Definition: NanoVDB.h:2586
NodeTrait< RootT, LEVEL >::type * getFirstNode()
return a pointer to the first node at the specified level
Definition: NanoVDB.h:2653
void extrema(ValueType &min, ValueType &max) const
Sets the extrema values of all the active values in this tree, i.e. in all nodes of the tree.
Definition: NanoVDB.h:2674
const uint32_t & activeTileCount(uint32_t n) const
Return the total number of active tiles at the specified level of the tree.
Definition: NanoVDB.h:2609
bool probeValue(const CoordType &ijk, ValueType &v) const
Combines the previous two methods in a single call.
Definition: NanoVDB.h:2592
typename RootT::CoordType CoordType
Definition: NanoVDB.h:2555
RootT & root()
Definition: NanoVDB.h:2576
Tree(const Tree &)=delete
static uint64_t memUsage()
return memory usage in bytes for the class
Definition: NanoVDB.h:2574
LeafNodeType Node0
Definition: NanoVDB.h:2561
NodeT * getFirstNode()
return a pointer to the first node of the specified type
Definition: NanoVDB.h:2632
uint32_t nodeCount(int level) const
Definition: NanoVDB.h:2622
typename Node2::ChildNodeType Node1
Definition: NanoVDB.h:2560
const NodeTrait< RootT, LEVEL >::type * getFirstNode() const
return a const pointer to the first node of the specified level
Definition: NanoVDB.h:2663
const RootT & root() const
Definition: NanoVDB.h:2578
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel (regardless of state or location in the tree.)
Definition: NanoVDB.h:2583
RootT RootType
Definition: NanoVDB.h:2551
const ValueType & background() const
Return a const reference to the background value.
Definition: NanoVDB.h:2595
bool isEmpty() const
Return true if this tree is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:2589
Tree & operator=(const Tree &)=delete
typename RootT::ValueType ValueType
Definition: NanoVDB.h:2553
const DataType * data() const
Definition: NanoVDB.h:2571
typename RootT::BuildType BuildType
Definition: NanoVDB.h:2554
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
bool isValid(GridType gridType, GridClass gridClass)
return true if the combination of GridType and GridClass is valid.
Definition: NanoVDB.h:520
T Pow4(T x)
Definition: NanoVDB.h:742
GridType mapToGridType()
Maps from a templated value type to a GridType enum.
Definition: NanoVDB.h:1366
ReadAccessor< ValueT, LEVEL0, LEVEL1, LEVEL2 > createAccessor(const NanoGrid< ValueT > &grid)
Free-standing function for convenient creation of a ReadAccessor with optional and customizable node ...
Definition: NanoVDB.h:4656
static DstT * PtrAdd(SrcT *p, int64_t offset)
Definition: NanoVDB.h:440
float Clamp(float x, float a, float b)
Definition: NanoVDB.h:693
int32_t Floor(float x)
Definition: NanoVDB.h:711
int MinIndex(const Vec3T &v)
Definition: NanoVDB.h:810
Vec3< float > Vec3f
Definition: NanoVDB.h:1175
CoordT RoundDown(const Vec3T< RealT > &xyz)
Definition: NanoVDB.h:788
GridClass
Classes (defined in OpenVDB) that are currently supported by NanoVDB.
Definition: NanoVDB.h:253
GridType
List of types that are currently supported by NanoVDB.
Definition: NanoVDB.h:216
uint32_t CountOn(uint64_t v)
Definition: NanoVDB.h:1774
Vec3T matMult(const float *mat, const Vec3T &xyz)
Definition: NanoVDB.h:1409
Type Min(Type a, Type b)
Definition: NanoVDB.h:651
GridFlags
Grid flags which indicate what extra information is present in the grid buffer.
Definition: NanoVDB.h:277
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
float Sqrt(float x)
Return the square root of a floating-point value.
Definition: NanoVDB.h:795
Vec3< T2 > operator*(T1 scalar, const Vec3< T2 > &vec)
Definition: NanoVDB.h:1163
T Pow3(T x)
Definition: NanoVDB.h:736
GridBlindDataClass
Blind-data Classes that are currently supported by NanoVDB.
Definition: NanoVDB.h:306
float Fract(float x)
Definition: NanoVDB.h:702
Vec3T matMultT(const float *mat, const Vec3T &xyz)
Definition: NanoVDB.h:1443
Vec3< double > Vec3d
Definition: NanoVDB.h:1174
Vec3< T2 > operator/(T1 scalar, const Vec3< T2 > &vec)
Definition: NanoVDB.h:1168
const char * toStr(GridType gridType)
Retuns a c-string used to describe a GridType.
Definition: NanoVDB.h:239
static int64_t PtrDiff(const T1 *p, const T2 *q)
Definition: NanoVDB.h:433
T Sign(const T &x)
Return the sign of the given value as an integer (either -1, 0 or 1).
Definition: NanoVDB.h:807
Type Max(Type a, Type b)
Definition: NanoVDB.h:672
T Abs(T x)
Definition: NanoVDB.h:747
GridBlindDataSemantic
Blind-data Semantics that are currently understood by NanoVDB.
Definition: NanoVDB.h:313
CoordT Round(const Vec3T< RealT > &xyz)
bool isFloatingPoint(GridType gridType)
return true if the GridType maps to a floating point value.
Definition: NanoVDB.h:507
int32_t Ceil(float x)
Definition: NanoVDB.h:720
bool isApproxZero(const Type &x)
Definition: NanoVDB.h:645
int MaxIndex(const Vec3T &v)
Definition: NanoVDB.h:827
T Pow2(T x)
Definition: NanoVDB.h:730
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
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
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:2185
uint32_t mFlags
Definition: NanoVDB.h:2190
const void * treePtr() const
Definition: NanoVDB.h:2282
void setMinMaxOn(bool on=true)
Definition: NanoVDB.h:2206
void setAverageOn(bool on=true)
Definition: NanoVDB.h:2230
Vec3T applyInverseJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2274
Vec3T applyIJTF(const Vec3T &xyz) const
Definition: NanoVDB.h:2276
uint32_t mBlindMetadataCount
Definition: NanoVDB.h:2201
Version mVersion
Definition: NanoVDB.h:2189
GridType mGridType
Definition: NanoVDB.h:2199
uint64_t mMagic
Definition: NanoVDB.h:2187
void setStdDeviationOn(bool on=true)
Definition: NanoVDB.h:2238
Vec3T applyIJT(const Vec3T &xyz) const
Definition: NanoVDB.h:2265
GridClass mGridClass
Definition: NanoVDB.h:2198
void setBBoxOn(bool on=true)
Definition: NanoVDB.h:2214
void setLongGridNameOn(bool on=true)
Definition: NanoVDB.h:2222
Vec3T applyJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2272
uint64_t mGridSize
Definition: NanoVDB.h:2193
BBox< Vec3R > mWorldBBox
Definition: NanoVDB.h:2196
Vec3T applyInverseJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2263
void * treePtr()
Definition: NanoVDB.h:2279
const GridBlindMetaData * blindMetaData(uint32_t n) const
Returns a const reference to the blindMetaData at the specified linear offset.
Definition: NanoVDB.h:2287
void setBreadthFirstOn(bool on=true)
Definition: NanoVDB.h:2246
uint64_t mChecksum
Definition: NanoVDB.h:2188
Vec3T applyMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2268
uint32_t mGridCount
Definition: NanoVDB.h:2192
Vec3R mVoxelSize
Definition: NanoVDB.h:2197
Vec3T applyInverseMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2259
Map mMap
Definition: NanoVDB.h:2195
Vec3T applyJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2261
void setFlagsOff()
Definition: NanoVDB.h:2205
int64_t mBlindMetadataOffset
Definition: NanoVDB.h:2200
uint32_t mGridIndex
Definition: NanoVDB.h:2191
Vec3T applyMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2257
Vec3T applyInverseMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2270
const typename GridT::TreeType Type
Definition: NanoVDB.h:2534
const typename GridT::TreeType type
Definition: NanoVDB.h:2535
defines a tree type from a grid type while perserving constness
Definition: NanoVDB.h:2527
typename GridT::TreeType Type
Definition: NanoVDB.h:2528
typename GridT::TreeType type
Definition: NanoVDB.h:2529
Struct with all the member data of the InternalNode (useful during serialization of an openvdb Intern...
Definition: NanoVDB.h:3043
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3099
StatsT mAverage
Definition: NanoVDB.h:3069
typename ChildT::CoordType CoordT
Definition: NanoVDB.h:3047
void setChild(uint32_t n, const void *ptr)
Definition: NanoVDB.h:3073
MaskT mChildMask
Definition: NanoVDB.h:3065
void setValue(uint32_t n, const ValueT &v)
Definition: NanoVDB.h:3080
InternalData(const InternalData &)=delete
const ValueT & getMax() const
Definition: NanoVDB.h:3102
void setDev(const StatsT &v)
Definition: NanoVDB.h:3109
const ChildT * getChild(uint32_t n) const
Definition: NanoVDB.h:3092
void setMin(const ValueT &v)
Definition: NanoVDB.h:3106
typename ChildT::FloatType StatsT
Definition: NanoVDB.h:3046
typename ChildT::BuildType BuildT
Definition: NanoVDB.h:3045
const ValueT & getMin() const
Definition: NanoVDB.h:3101
void setMax(const ValueT &v)
Definition: NanoVDB.h:3107
StatsT mStdDevi
Definition: NanoVDB.h:3070
BBox< CoordT > mBBox
Definition: NanoVDB.h:3062
ChildT * getChild(uint32_t n)
Returns a pointer to the child node at the specifed linear offset.
Definition: NanoVDB.h:3087
ValueT mMaximum
Definition: NanoVDB.h:3068
const StatsT & stdDeviation() const
Definition: NanoVDB.h:3104
const StatsT & average() const
Definition: NanoVDB.h:3103
MaskT mValueMask
Definition: NanoVDB.h:3064
typename ChildT::template MaskType< LOG2DIM > MaskT
Definition: NanoVDB.h:3048
InternalData & operator=(const InternalData &)=delete
void setAvg(const StatsT &v)
Definition: NanoVDB.h:3108
typename ChildT::ValueType ValueT
Definition: NanoVDB.h:3044
ValueT mMinimum
Definition: NanoVDB.h:3067
InternalData()=delete
This class cannot be constructed or deleted.
uint64_t mFlags
Definition: NanoVDB.h:3063
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:3520
float getValue(uint32_t i) const
Definition: NanoVDB.h:3521
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
uint16_t ArrayType
Definition: NanoVDB.h:3516
LeafData()=delete
This class cannot be constructed or deleted.
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:3470
float getValue(uint32_t i) const
Definition: NanoVDB.h:3471
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
LeafData()=delete
This class cannot be constructed or deleted.
uint8_t ArrayType
Definition: NanoVDB.h:3466
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:3498
float getValue(uint32_t i) const
Definition: NanoVDB.h:3499
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
LeafData()=delete
This class cannot be constructed or deleted.
uint8_t ArrayType
Definition: NanoVDB.h:3494
size_t memUsage() const
Definition: NanoVDB.h:3542
float getValue(uint32_t i) const
Definition: NanoVDB.h:3544
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
uint8_t bitWidth() const
Definition: NanoVDB.h:3541
LeafData()=delete
This class cannot be constructed or deleted.
static size_t memUsage(uint32_t bitWidth)
Definition: NanoVDB.h:3543
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3669
bool getDev() const
Definition: NanoVDB.h:3657
bool getMin() const
Definition: NanoVDB.h:3654
void setMax(const ValueType &)
Definition: NanoVDB.h:3664
bool getValue(uint32_t i) const
Definition: NanoVDB.h:3653
uint8_t mFlags
Definition: NanoVDB.h:3649
LeafData & operator=(const LeafData &)=delete
bool getMax() const
Definition: NanoVDB.h:3655
void setDev(const FloatType &)
Definition: NanoVDB.h:3666
LeafData(const LeafData &)=delete
bool getAvg() const
Definition: NanoVDB.h:3656
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3650
void setValue(uint32_t offset, bool)
Definition: NanoVDB.h:3658
CoordT mBBoxMin
Definition: NanoVDB.h:3647
bool ValueType
Definition: NanoVDB.h:3641
LeafData()=delete
This class cannot be constructed or deleted.
void setAvg(const FloatType &)
Definition: NanoVDB.h:3665
void setMin(const ValueType &)
Definition: NanoVDB.h:3663
bool FloatType
Definition: NanoVDB.h:3643
void ArrayType
Definition: NanoVDB.h:3644
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3626
bool getDev() const
Definition: NanoVDB.h:3613
bool BuildType
Definition: NanoVDB.h:3597
void setMin(const bool &)
Definition: NanoVDB.h:3620
bool getMin() const
Definition: NanoVDB.h:3610
void setMax(const bool &)
Definition: NanoVDB.h:3621
void setValue(uint32_t offset, bool v)
Definition: NanoVDB.h:3614
bool getValue(uint32_t i) const
Definition: NanoVDB.h:3609
uint8_t mFlags
Definition: NanoVDB.h:3604
LeafData & operator=(const LeafData &)=delete
bool getMax() const
Definition: NanoVDB.h:3611
LeafData(const LeafData &)=delete
MaskT< LOG2DIM > ArrayType
Definition: NanoVDB.h:3599
bool getAvg() const
Definition: NanoVDB.h:3612
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3605
MaskT< LOG2DIM > mValues
Definition: NanoVDB.h:3606
CoordT mBBoxMin
Definition: NanoVDB.h:3602
bool ValueType
Definition: NanoVDB.h:3596
void setDev(const bool &)
Definition: NanoVDB.h:3623
LeafData()=delete
This class cannot be constructed or deleted.
void setAvg(const bool &)
Definition: NanoVDB.h:3622
bool FloatType
Definition: NanoVDB.h:3598
Stuct with all the member data of the LeafNode (useful during serialization of an openvdb LeafNode)
Definition: NanoVDB.h:3355
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3395
ValueType mMaximum
Definition: NanoVDB.h:3370
FloatType getDev() const
Definition: NanoVDB.h:3387
typename FloatTraits< ValueT >::FloatType FloatType
Definition: NanoVDB.h:3360
void setMin(const ValueType &v)
Definition: NanoVDB.h:3389
void setMax(const ValueType &v)
Definition: NanoVDB.h:3390
FloatType mAverage
Definition: NanoVDB.h:3371
void setDev(const FloatType &v)
Definition: NanoVDB.h:3392
uint8_t mFlags
Definition: NanoVDB.h:3366
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
ValueType getMin() const
Definition: NanoVDB.h:3384
ValueType getValue(uint32_t i) const
Definition: NanoVDB.h:3376
void setValue(uint32_t offset, const ValueType &value)
Definition: NanoVDB.h:3378
ValueT ValueType
Definition: NanoVDB.h:3358
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3367
void setValueOnly(uint32_t offset, const ValueType &value)
Definition: NanoVDB.h:3377
CoordT mBBoxMin
Definition: NanoVDB.h:3364
ValueType getMax() const
Definition: NanoVDB.h:3385
LeafData()=delete
This class cannot be constructed or deleted.
ValueT ArrayType
Definition: NanoVDB.h:3361
FloatType getAvg() const
Definition: NanoVDB.h:3386
ValueType mMinimum
Definition: NanoVDB.h:3369
void setAvg(const FloatType &v)
Definition: NanoVDB.h:3391
ValueT BuildType
Definition: NanoVDB.h:3359
FloatType mStdDevi
Definition: NanoVDB.h:3372
Base-class for quantized float leaf nodes.
Definition: NanoVDB.h:3407
void setOrigin(const T &ijk)
Definition: NanoVDB.h:3454
float ValueType
Definition: NanoVDB.h:3410
float getMin() const
return the quantized minimum of the active values in this node
Definition: NanoVDB.h:3429
void setDev(float dev)
Definition: NanoVDB.h:3451
void setMin(float min)
Definition: NanoVDB.h:3442
float getAvg() const
return the quantized average of the active values in this node
Definition: NanoVDB.h:3435
uint8_t mFlags
Definition: NanoVDB.h:3415
float mQuantum
Definition: NanoVDB.h:3419
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:3416
void init(float min, float max, uint8_t bitWidth)
Definition: NanoVDB.h:3422
uint16_t mAvg
Definition: NanoVDB.h:3420
CoordT mBBoxMin
Definition: NanoVDB.h:3413
float mMinimum
Definition: NanoVDB.h:3418
float FloatType
Definition: NanoVDB.h:3411
void setMax(float max)
Definition: NanoVDB.h:3445
void setAvg(float avg)
Definition: NanoVDB.h:3448
float getDev() const
return the quantized standard deviation of the active values in this node
Definition: NanoVDB.h:3439
float getMax() const
return the quantized maximum of the active values in this node
Definition: NanoVDB.h:3432
Definition: NanoVDB.h:3687
static uint32_t dim()
Definition: NanoVDB.h:3688
Defines an affine transform and its inverse represented as a 3x3 matrix and a vec3 translation.
Definition: NanoVDB.h:1998
double mTaperD
Definition: NanoVDB.h:2006
Vec3T applyInverseJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2036
Vec3T applyIJTF(const Vec3T &xyz) const
Definition: NanoVDB.h:2041
double mVecD[3]
Definition: NanoVDB.h:2005
float mInvMatF[9]
Definition: NanoVDB.h:2000
Vec3T applyIJT(const Vec3T &xyz) const
Definition: NanoVDB.h:2039
Vec3T applyJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:2020
Vec3T applyInverseJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2034
void set(const Mat4T &mat, const Mat4T &invMat, double taper)
Definition: NanoVDB.h:2045
double mInvMatD[9]
Definition: NanoVDB.h:2004
Vec3T applyMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2015
float mMatF[9]
Definition: NanoVDB.h:1999
Vec3T applyInverseMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2023
double mMatD[9]
Definition: NanoVDB.h:2003
Vec3T applyJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:2018
Vec3T applyMap(const Vec3T &xyz) const
Definition: NanoVDB.h:2013
Vec3T applyInverseMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:2028
float mTaperF
Definition: NanoVDB.h:2002
float mVecF[3]
Definition: NanoVDB.h:2001
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:3933
typename GridOrTreeOrRootT::LeafNodeType type
Definition: NanoVDB.h:2104
typename GridOrTreeOrRootT::LeafNodeType Type
Definition: NanoVDB.h:2103
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType Type
Definition: NanoVDB.h:2118
typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType type
Definition: NanoVDB.h:2119
typename GridOrTreeOrRootT::RootType::ChildNodeType Type
Definition: NanoVDB.h:2132
typename GridOrTreeOrRootT::RootType::ChildNodeType type
Definition: NanoVDB.h:2133
typename GridOrTreeOrRootT::RootType type
Definition: NanoVDB.h:2147
typename GridOrTreeOrRootT::RootType Type
Definition: NanoVDB.h:2146
const typename GridOrTreeOrRootT::LeafNodeType Type
Definition: NanoVDB.h:2110
const typename GridOrTreeOrRootT::LeafNodeType type
Definition: NanoVDB.h:2111
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType Type
Definition: NanoVDB.h:2125
const typename GridOrTreeOrRootT::RootType::ChildNodeType::ChildNodeType type
Definition: NanoVDB.h:2126
const typename GridOrTreeOrRootT::RootType::ChildNodeType type
Definition: NanoVDB.h:2140
const typename GridOrTreeOrRootT::RootType::ChildNodeType Type
Definition: NanoVDB.h:2139
const typename GridOrTreeOrRootT::RootType type
Definition: NanoVDB.h:2155
const typename GridOrTreeOrRootT::RootType Type
Definition: NanoVDB.h:2154
Struct to derive node type from its level in a given grid, tree or root while perserving constness.
Definition: NanoVDB.h:2096
uint32_t mLevel
Definition: NanoVDB.h:4024
ValueType mMaximum
Definition: NanoVDB.h:4027
uint32_t mDim
Definition: NanoVDB.h:4025
FloatType mAverage
Definition: NanoVDB.h:4028
CoordType mBBoxMax
Definition: NanoVDB.h:4031
ValueType mMinimum
Definition: NanoVDB.h:4026
CoordType mBBoxMin
Definition: NanoVDB.h:4030
FloatType mStdDevi
Definition: NanoVDB.h:4029
Definition: NanoVDB.h:2728
ValueT value
Definition: NanoVDB.h:2748
void setChild(const CoordType &k, const ChildT *ptr, const RootData *data)
Definition: NanoVDB.h:2730
uint32_t state
Definition: NanoVDB.h:2747
KeyT key
Definition: NanoVDB.h:2745
void setValue(const CoordType &k, bool s, const ValueType &v)
Definition: NanoVDB.h:2736
CoordT origin() const
Definition: NanoVDB.h:2744
bool isChild() const
Definition: NanoVDB.h:2743
int64_t child
Definition: NanoVDB.h:2746
Struct with all the member data of the RootNode (useful during serialization of an openvdb RootNode)
Definition: NanoVDB.h:2687
StatsT mAverage
Definition: NanoVDB.h:2724
typename ChildT::CoordType CoordT
Definition: NanoVDB.h:2690
static CoordT KeyToCoord(const KeyT &key)
Definition: NanoVDB.h:2706
const ChildT * getChild(const Tile *tile) const
Definition: NanoVDB.h:2773
RootData()=delete
This class cannot be constructed or deleted.
ValueT mBackground
Definition: NanoVDB.h:2721
Tile * tile(uint32_t n)
Definition: NanoVDB.h:2759
const Tile * tile(uint32_t n) const
Returns a non-const reference to the tile at the specified linear offset.
Definition: NanoVDB.h:2754
uint32_t mTableSize
Definition: NanoVDB.h:2719
const ValueT & getMax() const
Definition: NanoVDB.h:2780
void setDev(const StatsT &v)
Definition: NanoVDB.h:2787
uint64_t KeyT
Return a key based on the coordinates of a voxel.
Definition: NanoVDB.h:2696
void setMin(const ValueT &v)
Definition: NanoVDB.h:2784
typename ChildT::FloatType StatsT
Definition: NanoVDB.h:2691
typename ChildT::BuildType BuildT
Definition: NanoVDB.h:2689
ChildT * getChild(const Tile *tile)
Returns a const reference to the child node in the specified tile.
Definition: NanoVDB.h:2768
const ValueT & getMin() const
Definition: NanoVDB.h:2779
void setMax(const ValueT &v)
Definition: NanoVDB.h:2785
StatsT mStdDevi
Definition: NanoVDB.h:2725
RootData(const RootData &)=delete
static KeyT CoordToKey(const CoordType &ijk)
Definition: NanoVDB.h:2698
RootData & operator=(const RootData &)=delete
BBox< CoordT > mBBox
Definition: NanoVDB.h:2718
ValueT mMaximum
Definition: NanoVDB.h:2723
const StatsT & stdDeviation() const
Definition: NanoVDB.h:2782
const StatsT & average() const
Definition: NanoVDB.h:2781
void setAvg(const StatsT &v)
Definition: NanoVDB.h:2786
typename ChildT::ValueType ValueT
Definition: NanoVDB.h:2688
ValueT mMinimum
Definition: NanoVDB.h:2722
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:2501
const RootT * getRoot() const
Definition: NanoVDB.h:2513
void setFirstNode(const NodeT *node)
Definition: NanoVDB.h:2516
RootT * getRoot()
Definition: NanoVDB.h:2511
void setRoot(const RootT *root)
Definition: NanoVDB.h:2509
uint64_t mVoxelCount
Definition: NanoVDB.h:2506
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:3052
ValueT value
Definition: NanoVDB.h:3053
Tile(const Tile &)=delete
Tile & operator=(const Tile &)=delete
Tile()=delete
This class cannot be constructed or deleted.
int64_t child
Definition: NanoVDB.h:3054