118 #ifndef NANOVDB_NANOVDB_H_HAS_BEEN_INCLUDED 119 #define NANOVDB_NANOVDB_H_HAS_BEEN_INCLUDED 126 #define NANOVDB_MAGIC_NUMBER 0x304244566f6e614eUL // "NanoVDB0" in hex - little endian (uint64_t) 127 #define NANOVDB_MAGIC_GRID 0x314244566f6e614eUL // "NanoVDB1" in hex - little endian (uint64_t) 128 #define NANOVDB_MAGIC_FILE 0x324244566f6e614eUL // "NanoVDB2" in hex - little endian (uint64_t) 129 #define NANOVDB_MAGIC_NODE 0x334244566f6e614eUL // "NanoVDB3" in hex - little endian (uint64_t) 130 #define NANOVDB_MAGIC_MASK 0x00FFFFFFFFFFFFFFUL // use this mask to remove the number 133 #define NANOVDB_MAJOR_VERSION_NUMBER 32 // reflects changes to the ABI and hence also the file format 134 #define NANOVDB_MINOR_VERSION_NUMBER 6 // reflects changes to the API but not ABI 135 #define NANOVDB_PATCH_VERSION_NUMBER 0 // reflects changes that does not affect the ABI or API 137 #define TBB_SUPPRESS_DEPRECATED_MESSAGES 1 140 #define NANOVDB_USE_SINGLE_ROOT_KEY 149 #define NANOVDB_NEW_ACCESSOR_METHODS 151 #define NANOVDB_FPN_BRANCHLESS 154 #define NANOVDB_DATA_ALIGNMENT 32 156 #if !defined(NANOVDB_ALIGN) 157 #define NANOVDB_ALIGN(n) alignas(n) 158 #endif // !defined(NANOVDB_ALIGN) 160 #ifdef __CUDACC_RTC__ 162 typedef signed char int8_t;
163 typedef short int16_t;
165 typedef long long int64_t;
166 typedef unsigned char uint8_t;
167 typedef unsigned int uint32_t;
168 typedef unsigned short uint16_t;
169 typedef unsigned long long uint64_t;
171 #define NANOVDB_ASSERT(x) 173 #define UINT64_C(x) (x ## ULL) 175 #else // !__CUDACC_RTC__ 185 #ifdef NANOVDB_USE_IOSTREAMS 190 #define NANOVDB_ASSERT(x) assert(x) 192 #define NANOVDB_ASSERT(x) 195 #if defined(NANOVDB_USE_INTRINSICS) && defined(_MSC_VER) 197 #pragma intrinsic(_BitScanReverse) 198 #pragma intrinsic(_BitScanForward) 199 #pragma intrinsic(_BitScanReverse64) 200 #pragma intrinsic(_BitScanForward64) 203 #endif // __CUDACC_RTC__ 205 #if defined(__CUDACC__) || defined(__HIP__) 208 #define __hostdev__ __host__ __device__ // Runs on the CPU and GPU, called from the CPU or the GPU 213 #define __hostdev__ // Runs on the CPU and GPU, called from the CPU or the GPU 216 #define __global__ // Runs on the GPU, called from the CPU or the GPU 219 #define __device__ // Runs on the GPU, called from the GPU 222 #define __host__ // Runs on the CPU, called from the CPU 225 #endif // if defined(__CUDACC__) || defined(__HIP__) 229 #if defined(_MSC_VER) && defined(__CUDACC__) 230 #define NANOVDB_HOSTDEV_DISABLE_WARNING __pragma("hd_warning_disable") 231 #elif defined(__GNUC__) && defined(__CUDACC__) 232 #define NANOVDB_HOSTDEV_DISABLE_WARNING _Pragma("hd_warning_disable") 234 #define NANOVDB_HOSTDEV_DISABLE_WARNING 245 #define NANOVDB_OFFSETOF(CLASS, MEMBER) ((int)(size_t)((char*)&((CLASS*)0)->MEMBER - (char*)0)) 345 #ifndef __CUDACC_RTC__ 351 static const char* LUT[] = {
"?",
"float",
"double",
"int16",
"int32",
"int64",
"Vec3f",
"Vec3d",
"Mask",
"Half",
352 "uint32",
"bool",
"RGBA8",
"Float4",
"Float8",
"Float16",
"FloatN",
"Vec4f",
"Vec4d",
353 "Index",
"OnIndex",
"IndexMask",
"OnIndexMask",
"PointIndex",
"Vec3u8",
"Vec3u16",
"End"};
354 static_assert(
sizeof(LUT) /
sizeof(
char*) - 1 ==
int(
GridType::End),
"Unexpected size of LUT");
355 return LUT[
static_cast<int>(gridType)];
374 #ifndef __CUDACC_RTC__ 378 static const char* LUT[] = {
"?",
"SDF",
"FOG",
"MAC",
"PNTIDX",
"PNTDAT",
"TOPO",
"VOX",
"INDEX",
"TENSOR",
"END"};
379 static_assert(
sizeof(LUT) /
sizeof(
char*) - 1 ==
int(
GridClass::End),
"Unexpected size of LUT");
380 return LUT[
static_cast<int>(gridClass)];
397 #ifndef __CUDACC_RTC__ 401 static const char* LUT[] = {
"has long grid name",
405 "has standard deviation",
408 static_assert(1 << (
sizeof(LUT) /
sizeof(
char*) - 1) ==
int(
GridFlags::End),
"Unexpected size of LUT");
409 return LUT[
static_cast<int>(gridFlags)];
440 template<
typename T0,
typename T1,
typename ...T>
446 template<
typename T0,
typename T1>
449 static constexpr
bool value =
false;
455 static constexpr
bool value =
true;
491 template <
bool,
typename T =
void>
496 template <
typename T>
504 template<
bool,
typename T =
void>
520 static constexpr
bool value =
false;
526 static constexpr
bool value =
true;
536 static constexpr
bool value =
false;
544 static constexpr
bool value =
true;
552 static constexpr
bool value =
true;
580 template <
typename T>
586 template <
typename T>
594 template <
typename T>
600 template <
typename T>
610 template<
typename T,
typename ReferenceT>
621 template<
typename T,
typename ReferenceT>
636 template<
typename AnyType,
template<
typename...>
class TemplateType>
639 static const bool value =
false;
641 template<
typename... Args,
template<
typename...>
class TemplateType>
644 static const bool value =
true;
756 template <
typename T>
764 template <
typename T>
768 return reinterpret_cast<const T*
>( (
const uint8_t*)p +
alignmentPadding(p) );
779 template<
typename T1,
typename T2>
783 return reinterpret_cast<const char*
>(p) - reinterpret_cast<const char*>(q);
794 template<
typename DstT,
typename SrcT>
798 return reinterpret_cast<DstT*
>(
reinterpret_cast<char*
>(p) + offset);
807 template<
typename DstT,
typename SrcT>
811 return reinterpret_cast<const DstT*
>(
reinterpret_cast<const char*
>(p) + offset);
874 auto *d =
reinterpret_cast<uint64_t*
>(dst), *e = d + word_count;
875 auto *s =
reinterpret_cast<const uint64_t*
>(src);
876 while (d != e) *d++ = *s++;
911 switch (blindClass) {
959 : mData(major << 21 | minor << 10 | patch)
980 #ifndef __CUDACC_RTC__ 983 char* buffer = (
char*)malloc(4 + 1 + 4 + 1 + 4 + 1);
984 snprintf(buffer, 4 + 1 + 4 + 1 + 4 + 1,
"%u.%u.%u", this->getMajor(), this->getMinor(), this->getPatch());
997 return 3.141592653589793238462643383279502884e+00;
1002 return 3.141592653589793238462643383279502884e+00F;
1007 return 3.141592653589793238462643383279502884e+00;
1012 return 3.141592653589793238462643383279502884e+00L;
1018 template<
typename T>
1034 template<
typename T>
1050 template<
typename T>
1052 #if defined(__CUDA_ARCH__) || defined(__HIP__) 1056 __hostdev__ static int value() {
return 2147483647; }
1061 __hostdev__ static uint32_t value() {
return 4294967295u; }
1066 __hostdev__ static float value() {
return 1e+38f; }
1071 __hostdev__ static double value() {
return 1e+308; }
1074 template<
typename T>
1082 template<
typename Type>
1088 template<
typename Type>
1091 return (a < b) ? a : b;
1095 return int32_t(fminf(
float(a),
float(b)));
1099 return uint32_t(fminf(
float(a),
float(b)));
1109 template<
typename Type>
1112 return (a > b) ? a : b;
1117 return int32_t(fmaxf(
float(a),
float(b)));
1121 return uint32_t(fmaxf(
float(a),
float(b)));
1133 return Max(
Min(x, b), a);
1137 return Max(
Min(x, b), a);
1142 return x - floorf(x);
1146 return x - floor(x);
1151 return int32_t(floorf(x));
1155 return int32_t(floor(x));
1160 return int32_t(ceilf(x));
1164 return int32_t(ceil(x));
1167 template<
typename T>
1173 template<
typename T>
1179 template<
typename T>
1184 template<
typename T>
1187 return x < 0 ? -x : x;
1208 template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
1211 template<
typename CoordT,
template<
typename>
class Vec3T>
1214 return CoordT(int32_t(rintf(xyz[0])), int32_t(rintf(xyz[1])), int32_t(rintf(xyz[2])));
1219 template<
typename CoordT,
template<
typename>
class Vec3T>
1222 return CoordT(int32_t(floor(xyz[0] + 0.5)), int32_t(floor(xyz[1] + 0.5)), int32_t(floor(xyz[2] + 0.5)));
1225 template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
1244 template<
typename T>
1247 return ((T(0) < x) ? T(1) : T(0)) - ((x < T(0)) ? T(1) : T(0));
1250 template<
typename Vec3T>
1254 static const int hashTable[8] = {2, 1, 9, 1, 2, 9, 0, 0};
1255 const int hashKey = ((v[0] < v[1]) << 2) + ((v[0] < v[2]) << 1) + (v[1] < v[2]);
1256 return hashTable[hashKey];
1258 if (v[0] < v[1] && v[0] < v[2])
1267 template<
typename Vec3T>
1271 static const int hashTable[8] = {2, 1, 9, 1, 2, 9, 0, 0};
1272 const int hashKey = ((v[0] > v[1]) << 2) + ((v[0] > v[2]) << 1) + (v[1] > v[2]);
1273 return hashTable[hashKey];
1275 if (v[0] > v[1] && v[0] > v[2])
1287 template<u
int64_t wordSize>
1290 const uint64_t r = byteCount % wordSize;
1291 return r ? byteCount - r + wordSize : byteCount;
1327 : mVec{ptr[0], ptr[1], ptr[2]}
1354 template<
typename CoordT>
1357 static_assert(
sizeof(
Coord) ==
sizeof(CoordT),
"Mis-matched sizeof");
1376 return mVec[0] < rhs[0] ?
true 1377 : mVec[0] > rhs[0] ?
false 1378 : mVec[1] < rhs[1] ?
true 1379 : mVec[1] > rhs[1] ?
false 1380 : mVec[2] < rhs[2] ?
true :
false;
1386 return mVec[0] < rhs[0] ?
true 1387 : mVec[0] > rhs[0] ?
false 1388 : mVec[1] < rhs[1] ?
true 1389 : mVec[1] > rhs[1] ?
false 1390 : mVec[2] <=rhs[2] ?
true :
false;
1445 if (other[0] < mVec[0])
1447 if (other[1] < mVec[1])
1449 if (other[2] < mVec[2])
1457 if (other[0] > mVec[0])
1459 if (other[1] > mVec[1])
1461 if (other[2] > mVec[2])
1465 #if defined(__CUDACC__) // the following functions only run on the GPU! 1468 atomicMin(&mVec[0], other[0]);
1469 atomicMin(&mVec[1], other[1]);
1470 atomicMin(&mVec[2], other[2]);
1475 atomicMax(&mVec[0], other[0]);
1476 atomicMax(&mVec[1], other[1]);
1477 atomicMax(&mVec[2], other[2]);
1484 return Coord(mVec[0] + dx, mVec[1] + dy, mVec[2] + dz);
1493 return (a[0] < b[0] || a[1] < b[1] || a[2] < b[2]);
1498 template<
typename Vec3T>
1506 template<
int Log2N = 3 + 4 + 5>
1507 __hostdev__ uint32_t
hash()
const {
return ((1 << Log2N) - 1) & (mVec[0] * 73856093 ^ mVec[1] * 19349669 ^ mVec[2] * 83492791); }
1512 (uint8_t(
bool(mVec[1] & (1u << 31))) << 1) |
1513 (uint8_t(
bool(mVec[2] & (1u << 31))) << 2); }
1528 template<
typename T>
1534 static const int SIZE = 3;
1535 static const int size = 3;
1546 template<
template<
class>
class Vec3T,
class T2>
1548 : mVec{T(v[0]), T(v[1]), T(v[2])}
1550 static_assert(Vec3T<T2>::size == size,
"expected Vec3T::size==3!");
1552 template<
typename T2>
1554 : mVec{T(v[0]), T(v[1]), T(v[2])}
1558 : mVec{T(ijk[0]), T(ijk[1]), T(ijk[2])}
1563 template<
template<
class>
class Vec3T,
class T2>
1566 static_assert(Vec3T<T2>::size == size,
"expected Vec3T::size==3!");
1574 template<
typename Vec3T>
1575 __hostdev__ T
dot(
const Vec3T& v)
const {
return mVec[0] * v[0] + mVec[1] * v[1] + mVec[2] * v[2]; }
1576 template<
typename Vec3T>
1579 return Vec3(mVec[1] * v[2] - mVec[2] * v[1],
1580 mVec[2] * v[0] - mVec[0] * v[2],
1581 mVec[0] * v[1] - mVec[1] * v[0]);
1585 return mVec[0] * mVec[0] + mVec[1] * mVec[1] + mVec[2] * mVec[2];
1606 mVec[0] += T(ijk[0]);
1607 mVec[1] += T(ijk[1]);
1608 mVec[2] += T(ijk[2]);
1620 mVec[0] -= T(ijk[0]);
1621 mVec[1] -= T(ijk[1]);
1622 mVec[2] -= T(ijk[2]);
1637 if (other[0] < mVec[0])
1639 if (other[1] < mVec[1])
1641 if (other[2] < mVec[2])
1649 if (other[0] > mVec[0])
1651 if (other[1] > mVec[1])
1653 if (other[2] > mVec[2])
1660 return mVec[0] < mVec[1] ? (mVec[0] < mVec[2] ? mVec[0] : mVec[2]) : (mVec[1] < mVec[2] ? mVec[1] : mVec[2]);
1665 return mVec[0] > mVec[1] ? (mVec[0] > mVec[2] ? mVec[0] : mVec[2]) : (mVec[1] > mVec[2] ? mVec[1] : mVec[2]);
1680 return Coord(mVec[0], mVec[1], mVec[2]);
1692 template<
typename T1,
typename T2>
1695 return Vec3<T2>(scalar * vec[0], scalar * vec[1], scalar * vec[2]);
1697 template<
typename T1,
typename T2>
1700 return Vec3<T2>(scalar / vec[0], scalar / vec[1], scalar / vec[2]);
1714 return Vec3f(
float(mVec[0]),
float(mVec[1]),
float(mVec[2]));
1720 return Vec3d(
double(mVec[0]),
double(mVec[1]),
double(mVec[2]));
1726 template<
typename T>
1732 static const int SIZE = 4;
1733 static const int size = 4;
1744 template<
typename T2>
1746 : mVec{T(v[0]), T(v[1]), T(v[2]), T(v[3])}
1749 template<
template<
class>
class Vec4T,
class T2>
1751 : mVec{T(v[0]), T(v[1]), T(v[2]), T(v[3])}
1753 static_assert(Vec4T<T2>::size == size,
"expected Vec4T::size==4!");
1755 __hostdev__ bool operator==(
const Vec4& rhs)
const {
return mVec[0] == rhs[0] && mVec[1] == rhs[1] && mVec[2] == rhs[2] && mVec[3] == rhs[3]; }
1756 __hostdev__ bool operator!=(
const Vec4& rhs)
const {
return mVec[0] != rhs[0] || mVec[1] != rhs[1] || mVec[2] != rhs[2] || mVec[3] != rhs[3]; }
1757 template<
template<
class>
class Vec4T,
class T2>
1760 static_assert(Vec4T<T2>::size == size,
"expected Vec4T::size==4!");
1770 template<
typename Vec4T>
1771 __hostdev__ T
dot(
const Vec4T& v)
const {
return mVec[0] * v[0] + mVec[1] * v[1] + mVec[2] * v[2] + mVec[3] * v[3]; }
1774 return mVec[0] * mVec[0] + mVec[1] * mVec[1] + mVec[2] * mVec[2] + mVec[3] * mVec[3];
1813 if (other[0] < mVec[0])
1815 if (other[1] < mVec[1])
1817 if (other[2] < mVec[2])
1819 if (other[3] < mVec[3])
1827 if (other[0] > mVec[0])
1829 if (other[1] > mVec[1])
1831 if (other[2] > mVec[2])
1833 if (other[3] > mVec[3])
1839 template<
typename T1,
typename T2>
1842 return Vec4<T2>(scalar * vec[0], scalar * vec[1], scalar * vec[2], scalar * vec[3]);
1844 template<
typename T1,
typename T2>
1847 return Vec4<T2>(scalar / vec[0], scalar / vec[1], scalar / vec[2], scalar / vec[3]);
1868 static const int SIZE = 4;
1887 : mData{{0, 0, 0, 0}}
1889 static_assert(
sizeof(uint32_t) ==
sizeof(
Rgba8),
"Unexpected sizeof");
1895 : mData{{r, g, b, a}}
1902 : mData{{v, v, v, v}}
1909 : mData{{
static_cast<uint8_t
>(0.5f + r * 255.0f),
1910 static_cast<uint8_t>(0.5f + g * 255.0f),
1911 static_cast<uint8_t
>(0.5f + b * 255.0f),
1912 static_cast<uint8_t>(0.5f + a * 255.0f)}}
1919 : Rgba8(rgb[0], rgb[1], rgb[2])
1926 : Rgba8(rgba[0], rgba[1], rgba[2], rgba[3])
1934 return 0.0000153787005f * (float(mData.c[0]) * mData.c[0] +
1935 float(mData.c[1]) * mData.c[1] +
1936 float(mData.c[2]) * mData.c[2]);
1954 return Vec3f(this->asFloat(0), this->asFloat(1), this->asFloat(2));
1957 return Vec4f(this->asFloat(0), this->asFloat(1), this->asFloat(2), this->asFloat(3));
1968 template<
typename T>
1971 static const int Rank = 0;
1972 static const bool IsScalar =
true;
1973 static const bool IsVector =
false;
1974 static const int Size = 1;
1979 template<
typename T>
1982 static const int Rank = 1;
1983 static const bool IsScalar =
false;
1984 static const bool IsVector =
true;
1985 static const int Size = T::SIZE;
1992 template<typename T, int = sizeof(typename TensorTraits<T>::ElementType)>
1998 template<
typename T>
2049 template<
typename BuildT>
2109 template<
typename BuildT>
2121 return defaultClass;
2132 template<
typename Vec3T>
2135 return Vec3T(fmaf(static_cast<float>(xyz[0]), mat[0], fmaf(static_cast<float>(xyz[1]), mat[1], static_cast<float>(xyz[2]) * mat[2])),
2136 fmaf(static_cast<float>(xyz[0]), mat[3], fmaf(static_cast<float>(xyz[1]), mat[4], static_cast<float>(xyz[2]) * mat[5])),
2137 fmaf(static_cast<float>(xyz[0]), mat[6], fmaf(static_cast<float>(xyz[1]), mat[7], static_cast<float>(xyz[2]) * mat[8])));
2146 template<
typename Vec3T>
2149 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])),
2150 fma(static_cast<double>(xyz[0]), mat[3], fma(static_cast<double>(xyz[1]), mat[4], static_cast<double>(xyz[2]) * mat[5])),
2151 fma(static_cast<double>(xyz[0]), mat[6], fma(static_cast<double>(xyz[1]), mat[7], static_cast<double>(xyz[2]) * mat[8])));
2161 template<
typename Vec3T>
2164 return Vec3T(fmaf(static_cast<float>(xyz[0]), mat[0], fmaf(static_cast<float>(xyz[1]), mat[1], fmaf(static_cast<float>(xyz[2]), mat[2], vec[0]))),
2165 fmaf(static_cast<float>(xyz[0]), mat[3], fmaf(static_cast<float>(xyz[1]), mat[4], fmaf(static_cast<float>(xyz[2]), mat[5], vec[1]))),
2166 fmaf(static_cast<float>(xyz[0]), mat[6], fmaf(static_cast<float>(xyz[1]), mat[7], fmaf(static_cast<float>(xyz[2]), mat[8], vec[2]))));
2176 template<
typename Vec3T>
2179 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]))),
2180 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]))),
2181 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]))));
2190 template<
typename Vec3T>
2193 return Vec3T(fmaf(static_cast<float>(xyz[0]), mat[0], fmaf(static_cast<float>(xyz[1]), mat[3], static_cast<float>(xyz[2]) * mat[6])),
2194 fmaf(static_cast<float>(xyz[0]), mat[1], fmaf(static_cast<float>(xyz[1]), mat[4], static_cast<float>(xyz[2]) * mat[7])),
2195 fmaf(static_cast<float>(xyz[0]), mat[2], fmaf(static_cast<float>(xyz[1]), mat[5], static_cast<float>(xyz[2]) * mat[8])));
2204 template<
typename Vec3T>
2207 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])),
2208 fma(static_cast<double>(xyz[0]), mat[1], fma(static_cast<double>(xyz[1]), mat[4], static_cast<double>(xyz[2]) * mat[7])),
2209 fma(static_cast<double>(xyz[0]), mat[2], fma(static_cast<double>(xyz[1]), mat[5], static_cast<double>(xyz[2]) * mat[8])));
2212 template<
typename Vec3T>
2215 return Vec3T(fmaf(static_cast<float>(xyz[0]), mat[0], fmaf(static_cast<float>(xyz[1]), mat[3], fmaf(static_cast<float>(xyz[2]), mat[6], vec[0]))),
2216 fmaf(static_cast<float>(xyz[0]), mat[1], fmaf(static_cast<float>(xyz[1]), mat[4], fmaf(static_cast<float>(xyz[2]), mat[7], vec[1]))),
2217 fmaf(static_cast<float>(xyz[0]), mat[2], fmaf(static_cast<float>(xyz[1]), mat[5], fmaf(static_cast<float>(xyz[2]), mat[8], vec[2]))));
2220 template<
typename Vec3T>
2223 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]))),
2224 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]))),
2225 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]))));
2231 template<
typename Vec3T>
2252 mCoord[0].minComponent(xyz);
2253 mCoord[1].maxComponent(xyz);
2260 mCoord[0].minComponent(bbox[0]);
2261 mCoord[1].maxComponent(bbox[1]);
2268 mCoord[0].maxComponent(bbox[0]);
2269 mCoord[1].minComponent(bbox[1]);
2279 if (xyz[0] < mCoord[0][0] || xyz[1] < mCoord[0][1] || xyz[2] < mCoord[0][2])
2281 if (xyz[0] > mCoord[1][0] || xyz[1] > mCoord[1][1] || xyz[2] > mCoord[1][2])
2294 template<typename Vec3T, bool = is_floating_point<typename Vec3T::ValueType>::value>
2301 template<
typename Vec3T>
2308 using BaseT::mCoord;
2330 : BBox(bbox[0], bbox[1])
2334 mCoord[0][1] >= mCoord[1][1] ||
2335 mCoord[0][2] >= mCoord[1][2]; }
2336 __hostdev__ operator bool()
const {
return mCoord[0][0] < mCoord[1][0] &&
2337 mCoord[0][1] < mCoord[1][1] &&
2338 mCoord[0][2] < mCoord[1][2]; }
2342 return p[0] > mCoord[0][0] && p[1] > mCoord[0][1] && p[2] > mCoord[0][2] &&
2343 p[0] < mCoord[1][0] && p[1] < mCoord[1][1] && p[2] < mCoord[1][2];
2352 template<
typename CoordT>
2357 using BaseT::mCoord;
2378 if (mPos[2] < mBBox[1][2]) {
2380 }
else if (mPos[1] < mBBox[1][1]) {
2381 mPos[2] = mBBox[0][2];
2383 }
else if (mPos[0] <= mBBox[1][0]) {
2384 mPos[2] = mBBox[0][2];
2385 mPos[1] = mBBox[0][1];
2399 return mPos == rhs.mPos;
2404 return mPos != rhs.mPos;
2409 return mPos < rhs.mPos;
2414 return mPos <= rhs.mPos;
2421 __hostdev__ Iterator
end()
const {
return Iterator{*
this, CoordT(mCoord[1][0]+1, mCoord[0][1], mCoord[0][2])}; }
2431 template<
typename SplitT>
2433 :
BaseT(other.mCoord[0], other.mCoord[1])
2436 const int n =
MaxIndex(this->dim());
2437 mCoord[1][n] = (mCoord[0][n] + mCoord[1][n]) >> 1;
2438 other.mCoord[0][n] = mCoord[1][n] + 1;
2443 return BBox(min, min.offsetBy(dim - 1));
2448 return BBox(CoordT(min), CoordT(max));
2452 mCoord[0][1] < mCoord[1][1] &&
2453 mCoord[0][2] < mCoord[1][2]; }
2456 mCoord[0][1] > mCoord[1][1] ||
2457 mCoord[0][2] > mCoord[1][2]; }
2459 __hostdev__ operator bool()
const {
return mCoord[0][0] <= mCoord[1][0] &&
2460 mCoord[0][1] <= mCoord[1][1] &&
2461 mCoord[0][2] <= mCoord[1][2]; }
2465 auto d = this->dim();
2466 return uint64_t(d[0]) * uint64_t(d[1]) * uint64_t(d[2]);
2472 return !(CoordT::lessThan(b.min(), this->
min()) || CoordT::lessThan(this->
max(), b.max()));
2478 return !(CoordT::lessThan(this->
max(), b.min()) || CoordT::lessThan(b.max(), this->
min()));
2482 template<
typename RealT =
double>
2487 Vec3<RealT>(RealT(mCoord[1][0] + 1), RealT(mCoord[1][1] + 1), RealT(mCoord[1][2] + 1)));
2492 return BBox(mCoord[0].offsetBy(-padding), mCoord[1].offsetBy(padding));
2498 template<
typename Map>
2503 bbox.expand(map.
applyMap(
Vec3d(mCoord[0][0], mCoord[0][1], mCoord[1][2])));
2504 bbox.expand(map.
applyMap(
Vec3d(mCoord[0][0], mCoord[1][1], mCoord[0][2])));
2505 bbox.expand(map.
applyMap(
Vec3d(mCoord[1][0], mCoord[0][1], mCoord[0][2])));
2506 bbox.expand(map.
applyMap(
Vec3d(mCoord[1][0], mCoord[1][1], mCoord[0][2])));
2507 bbox.expand(map.
applyMap(
Vec3d(mCoord[1][0], mCoord[0][1], mCoord[1][2])));
2508 bbox.expand(map.
applyMap(
Vec3d(mCoord[0][0], mCoord[1][1], mCoord[1][2])));
2509 bbox.expand(map.
applyMap(
Vec3d(mCoord[1][0], mCoord[1][1], mCoord[1][2])));
2513 #if defined(__CUDACC__) // the following functions only run on the GPU! 2516 mCoord[0].minComponentAtomic(ijk);
2517 mCoord[1].maxComponentAtomic(ijk);
2522 mCoord[0].minComponentAtomic(bbox[0]);
2523 mCoord[1].maxComponentAtomic(bbox[1]);
2528 mCoord[0].maxComponentAtomic(bbox[0]);
2529 mCoord[1].minComponentAtomic(bbox[1]);
2547 #if (defined(__CUDA_ARCH__) || defined(__HIP__)) && defined(NANOVDB_USE_INTRINSICS) 2548 return __ffs(v) - 1;
2549 #elif defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS) 2550 unsigned long index;
2551 _BitScanForward(&index, v);
2552 return static_cast<uint32_t
>(index);
2553 #elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS) 2554 return static_cast<uint32_t
>(__builtin_ctzl(v));
2557 static const unsigned char DeBruijn[32] = {
2558 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};
2560 #if defined(_MSC_VER) && !defined(__NVCC__) 2561 #pragma warning(push) 2562 #pragma warning(disable : 4146) 2564 return DeBruijn[uint32_t((v & -v) * 0x077CB531U) >> 27];
2565 #if defined(_MSC_VER) && !defined(__NVCC__) 2566 #pragma warning(pop) 2579 #if (defined(__CUDA_ARCH__) || defined(__HIP__)) && defined(NANOVDB_USE_INTRINSICS) 2580 return sizeof(uint32_t) * 8 - 1 - __clz(v);
2581 #elif defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS) 2582 unsigned long index;
2583 _BitScanReverse(&index, v);
2584 return static_cast<uint32_t
>(index);
2585 #elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS) 2586 return sizeof(
unsigned long) * 8 - 1 - __builtin_clzl(v);
2589 static const unsigned char DeBruijn[32] = {
2590 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
2591 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31};
2597 return DeBruijn[uint32_t(v * 0x07C4ACDDU) >> 27];
2608 #if (defined(__CUDA_ARCH__) || defined(__HIP__)) && defined(NANOVDB_USE_INTRINSICS) 2609 return __ffsll(static_cast<unsigned long long int>(v)) - 1;
2610 #elif defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS) 2611 unsigned long index;
2612 _BitScanForward64(&index, v);
2613 return static_cast<uint32_t
>(index);
2614 #elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS) 2615 return static_cast<uint32_t
>(__builtin_ctzll(v));
2618 static const unsigned char DeBruijn[64] = {
2619 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
2620 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
2621 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
2622 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12,
2625 #if defined(_MSC_VER) && !defined(__NVCC__) 2626 #pragma warning(push) 2627 #pragma warning(disable : 4146) 2629 return DeBruijn[uint64_t((v & -v) * UINT64_C(0x022FDD63CC95386D)) >> 58];
2630 #if defined(_MSC_VER) && !defined(__NVCC__) 2631 #pragma warning(pop) 2644 #if (defined(__CUDA_ARCH__) || defined(__HIP__)) && defined(NANOVDB_USE_INTRINSICS) 2645 return sizeof(
unsigned long) * 8 - 1 - __clzll(static_cast<unsigned long long int>(v));
2646 #elif defined(_MSC_VER) && defined(NANOVDB_USE_INTRINSICS) 2647 unsigned long index;
2648 _BitScanReverse64(&index, v);
2649 return static_cast<uint32_t
>(index);
2650 #elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS) 2651 return sizeof(
unsigned long) * 8 - 1 - __builtin_clzll(v);
2653 const uint32_t* p =
reinterpret_cast<const uint32_t*
>(&v);
2664 #if (defined(__CUDA_ARCH__) || defined(__HIP__)) && defined(NANOVDB_USE_INTRINSICS) 2668 #elif defined(_MSC_VER) && defined(_M_X64) && (_MSC_VER >= 1928) && defined(NANOVDB_USE_INTRINSICS) 2670 return uint32_t(__popcnt64(v));
2671 #elif (defined(__GNUC__) || defined(__clang__)) && defined(NANOVDB_USE_INTRINSICS) 2673 return __builtin_popcountll(v);
2674 #else // use software implementation 2676 v = v - ((v >> 1) & uint64_t(0x5555555555555555));
2677 v = (v & uint64_t(0x3333333333333333)) + ((v >> 2) & uint64_t(0x3333333333333333));
2678 return (((v + (v >> 4)) & uint64_t(0xF0F0F0F0F0F0F0F)) * uint64_t(0x101010101010101)) >> 56;
2718 for (
auto bit : list)
2719 mFlags |=
static_cast<Type>(1 << bit);
2721 template<
typename MaskT>
2724 for (
auto mask : list)
2725 mFlags |=
static_cast<Type>(mask);
2732 for (
auto bit : list)
2733 mFlags |=
static_cast<Type>(1 << bit);
2735 template<
typename MaskT>
2739 for (
auto mask : list)
2740 mFlags |=
static_cast<Type>(mask);
2754 for (
auto bit : list)
2755 mFlags |=
static_cast<Type>(1 << bit);
2759 for (
auto bit : list)
2760 mFlags &= ~static_cast<
Type>(1 << bit);
2763 template<
typename MaskT>
2765 template<
typename MaskT>
2768 template<
typename MaskT>
2771 for (
auto mask : list)
2772 mFlags |=
static_cast<Type>(mask);
2774 template<
typename MaskT>
2777 for (
auto mask : list)
2778 mFlags &= ~static_cast<
Type>(mask);
2782 template<
typename MaskT>
2789 template<
typename MaskT>
2791 template<
typename MaskT>
2794 template<
typename MaskT>
2797 for (
auto mask : list)
2798 if (0 != (mFlags & static_cast<Type>(mask)))
2803 template<
typename MaskT>
2806 for (
auto mask : list)
2807 if (0 == (mFlags & static_cast<Type>(mask)))
2823 template<u
int32_t LOG2DIM>
2827 static constexpr uint32_t SIZE = 1U << (3 * LOG2DIM);
2828 static constexpr uint32_t WORD_COUNT = SIZE >> 6;
2843 for (
const uint64_t *w = mWords, *q = w + WORD_COUNT; w != q; ++w)
2851 uint32_t n = i >> 6, sum =
CountOn(mWords[n] & ((uint64_t(1) << (i & 63u)) - 1u));
2852 for (
const uint64_t* w = mWords; n--; ++w)
2877 mPos = mParent->findNext<On>(mPos + 1);
2889 const Mask* mParent;
2931 for (uint32_t i = 0; i < WORD_COUNT; ++i)
2936 const uint64_t v = on ? ~uint64_t(0) : uint64_t(0);
2937 for (uint32_t i = 0; i < WORD_COUNT; ++i)
2944 for (uint32_t i = 0; i < WORD_COUNT; ++i)
2945 mWords[i] = other.mWords[i];
2953 template<
typename MaskT = Mask>
2956 static_assert(
sizeof(
Mask) ==
sizeof(MaskT),
"Mismatching sizeof");
2957 static_assert(WORD_COUNT == MaskT::WORD_COUNT,
"Mismatching word count");
2958 static_assert(LOG2DIM == MaskT::LOG2DIM,
"Mismatching LOG2DIM");
2959 auto* src =
reinterpret_cast<const uint64_t*
>(&other);
2960 for (uint64_t *dst = mWords, *end = dst + WORD_COUNT; dst != end; ++dst)
2967 memcpy64(mWords, other.mWords, WORD_COUNT);
2973 for (uint32_t i = 0; i < WORD_COUNT; ++i) {
2974 if (mWords[i] != other.mWords[i])
2983 __hostdev__ bool isOn(uint32_t n)
const {
return 0 != (mWords[n >> 6] & (uint64_t(1) << (n & 63))); }
2986 __hostdev__ bool isOff(uint32_t n)
const {
return 0 == (mWords[n >> 6] & (uint64_t(1) << (n & 63))); }
2991 for (uint32_t i = 0; i < WORD_COUNT; ++i)
2992 if (mWords[i] != ~uint64_t(0))
3000 for (uint32_t i = 0; i < WORD_COUNT; ++i)
3001 if (mWords[i] != uint64_t(0))
3011 #if defined(__CUDACC__) // the following functions only run on the GPU! 3012 __device__ inline void setOnAtomic(uint32_t n)
3014 atomicOr(reinterpret_cast<unsigned long long int*>(
this) + (n >> 6), 1ull << (n & 63));
3016 __device__ inline void setOffAtomic(uint32_t n)
3018 atomicAnd(reinterpret_cast<unsigned long long int*>(
this) + (n >> 6), ~(1ull << (n & 63)));
3020 __device__ inline void setAtomic(uint32_t n,
bool on)
3022 on ? this->setOnAtomic(n) : this->setOffAtomic(n);
3028 #if 1 // switch between branchless 3029 auto& word = mWords[n >> 6];
3031 word &= ~(uint64_t(1) << n);
3032 word |= uint64_t(on) << n;
3034 on ? this->setOn(n) : this->setOff(n);
3041 for (uint32_t i = 0; i < WORD_COUNT; ++i)
3042 mWords[i] = ~uint64_t(0);
3048 for (uint32_t i = 0; i < WORD_COUNT; ++i)
3049 mWords[i] = uint64_t(0);
3055 const uint64_t v = on ? ~uint64_t(0) : uint64_t(0);
3056 for (uint32_t i = 0; i < WORD_COUNT; ++i)
3062 uint32_t n = WORD_COUNT;
3063 for (
auto* w = mWords; n--; ++w)
3071 uint64_t* w1 = mWords;
3072 const uint64_t* w2 = other.mWords;
3073 for (uint32_t n = WORD_COUNT; n--; ++w1, ++w2)
3080 uint64_t* w1 = mWords;
3081 const uint64_t* w2 = other.mWords;
3082 for (uint32_t n = WORD_COUNT; n--; ++w1, ++w2)
3089 uint64_t* w1 = mWords;
3090 const uint64_t* w2 = other.mWords;
3091 for (uint32_t n = WORD_COUNT; n--; ++w1, ++w2)
3098 uint64_t* w1 = mWords;
3099 const uint64_t* w2 = other.mWords;
3100 for (uint32_t n = WORD_COUNT; n--; ++w1, ++w2)
3110 const uint64_t* w = mWords;
3111 for (; n < WORD_COUNT && !(ON ? *w : ~*w); ++w, ++n)
3113 return n < WORD_COUNT ? (n << 6) +
FindLowestOn(ON ? *w : ~*w) : SIZE;
3120 uint32_t n = start >> 6;
3121 if (n >= WORD_COUNT)
3123 uint32_t m = start & 63u;
3124 uint64_t b = ON ? mWords[n] : ~mWords[n];
3125 if (b & (uint64_t(1u) << m))
3127 b &= ~uint64_t(0u) << m;
3128 while (!b && ++n < WORD_COUNT)
3129 b = ON ? mWords[n] : ~mWords[n];
3137 uint32_t n = start >> 6;
3138 if (n >= WORD_COUNT)
3140 uint32_t m = start & 63u;
3141 uint64_t b = ON ? mWords[n] : ~mWords[n];
3142 if (b & (uint64_t(1u) << m))
3144 b &= (uint64_t(1u) << m) - 1u;
3146 b = ON ? mWords[--n] : ~mWords[--n];
3151 uint64_t mWords[WORD_COUNT];
3170 : mMatF{1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}
3171 , mInvMatF{1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}
3172 , mVecF{0.0f, 0.0f, 0.0f}
3174 , mMatD{1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}
3175 , mInvMatD{1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0}
3176 , mVecD{0.0, 0.0, 0.0}
3181 : mMatF{float(s), 0.0f, 0.0f, 0.0f, float(s), 0.0f, 0.0f, 0.0f, float(s)}
3182 , mInvMatF{1.0f / float(s), 0.0f, 0.0f, 0.0f, 1.0f / float(s), 0.0f, 0.0f, 0.0f, 1.0f / float(s)}
3183 , mVecF{float(t[0]), float(t[1]), float(t[2])}
3185 , mMatD{s, 0.0, 0.0, 0.0, s, 0.0, 0.0, 0.0, s}
3186 , mInvMatD{1.0 / s, 0.0, 0.0, 0.0, 1.0 / s, 0.0, 0.0, 0.0, 1.0 / s}
3187 , mVecD{t[0], t[1], t[2]}
3194 template<
typename MatT,
typename Vec3T>
3195 void set(
const MatT& mat,
const MatT& invMat,
const Vec3T& translate,
double taper = 1.0);
3200 template<
typename Mat4T>
3201 void set(
const Mat4T& mat,
const Mat4T& invMat,
double taper = 1.0) { this->
set(mat, invMat, mat[3], taper); }
3203 template<
typename Vec3T>
3204 void set(
double scale,
const Vec3T& translation,
double taper = 1.0);
3211 template<
typename Vec3T>
3219 template<
typename Vec3T>
3228 template<
typename Vec3T>
3237 template<
typename Vec3T>
3245 template<
typename Vec3T>
3248 return matMult(mInvMatD, Vec3T(xyz[0] - mVecD[0], xyz[1] - mVecD[1], xyz[2] - mVecD[2]));
3256 template<
typename Vec3T>
3259 return matMult(mInvMatF, Vec3T(xyz[0] - mVecF[0], xyz[1] - mVecF[1], xyz[2] - mVecF[2]));
3268 template<
typename Vec3T>
3277 template<
typename Vec3T>
3286 template<
typename Vec3T>
3288 template<
typename Vec3T>
3295 template<
typename MatT,
typename Vec3T>
3296 inline void Map::set(
const MatT& mat,
const MatT& invMat,
const Vec3T& translate,
double taper)
3298 float * mf = mMatF, *vf = mVecF, *mif = mInvMatF;
3299 double *md = mMatD, *vd = mVecD, *mid = mInvMatD;
3300 mTaperF =
static_cast<float>(taper);
3302 for (
int i = 0; i < 3; ++i) {
3303 *vd++ = translate[i];
3304 *vf++ =
static_cast<float>(translate[i]);
3305 for (
int j = 0; j < 3; ++j) {
3307 *mid++ = invMat[j][i];
3308 *mf++ =
static_cast<float>(mat[j][i]);
3309 *mif++ =
static_cast<float>(invMat[j][i]);
3314 template<
typename Vec3T>
3315 inline void Map::set(
double dx,
const Vec3T& trans,
double taper)
3318 const double mat[3][3] = { {dx, 0.0, 0.0},
3321 const double idx = 1.0 / dx;
3322 const double invMat[3][3] = { {idx, 0.0, 0.0},
3325 this->
set(mat, invMat, trans, taper);
3332 static const int MaxNameSize = 256;
3339 char mName[MaxNameSize];
3357 template<
typename BlindDataT>
3361 return mDataType == mapToGridType<BlindDataT>() ? PtrAdd<BlindDataT>(
this, mDataOffset) :
nullptr;
3367 auto check = [&]()->
bool{
3385 default:
return true;}
3395 return AlignUp<NANOVDB_DATA_ALIGNMENT>(mValueCount * mValueSize);
3403 template<
typename Gr
idOrTreeOrRootT,
int LEVEL>
3407 template<
typename Gr
idOrTreeOrRootT>
3410 static_assert(GridOrTreeOrRootT::RootNodeType::LEVEL == 3,
"Tree depth is not supported");
3411 using Type =
typename GridOrTreeOrRootT::LeafNodeType;
3412 using type =
typename GridOrTreeOrRootT::LeafNodeType;
3414 template<
typename Gr
idOrTreeOrRootT>
3417 static_assert(GridOrTreeOrRootT::RootNodeType::LEVEL == 3,
"Tree depth is not supported");
3418 using Type =
const typename GridOrTreeOrRootT::LeafNodeType;
3419 using type =
const typename GridOrTreeOrRootT::LeafNodeType;
3422 template<
typename Gr
idOrTreeOrRootT>
3425 static_assert(GridOrTreeOrRootT::RootNodeType::LEVEL == 3,
"Tree depth is not supported");
3426 using Type =
typename GridOrTreeOrRootT::RootNodeType::ChildNodeType::ChildNodeType;
3427 using type =
typename GridOrTreeOrRootT::RootNodeType::ChildNodeType::ChildNodeType;
3429 template<
typename Gr
idOrTreeOrRootT>
3432 static_assert(GridOrTreeOrRootT::RootNodeType::LEVEL == 3,
"Tree depth is not supported");
3433 using Type =
const typename GridOrTreeOrRootT::RootNodeType::ChildNodeType::ChildNodeType;
3434 using type =
const typename GridOrTreeOrRootT::RootNodeType::ChildNodeType::ChildNodeType;
3436 template<
typename Gr
idOrTreeOrRootT>
3439 static_assert(GridOrTreeOrRootT::RootNodeType::LEVEL == 3,
"Tree depth is not supported");
3440 using Type =
typename GridOrTreeOrRootT::RootNodeType::ChildNodeType;
3441 using type =
typename GridOrTreeOrRootT::RootNodeType::ChildNodeType;
3443 template<
typename Gr
idOrTreeOrRootT>
3446 static_assert(GridOrTreeOrRootT::RootNodeType::LEVEL == 3,
"Tree depth is not supported");
3447 using Type =
const typename GridOrTreeOrRootT::RootNodeType::ChildNodeType;
3448 using type =
const typename GridOrTreeOrRootT::RootNodeType::ChildNodeType;
3450 template<
typename Gr
idOrTreeOrRootT>
3453 static_assert(GridOrTreeOrRootT::RootNodeType::LEVEL == 3,
"Tree depth is not supported");
3454 using Type =
typename GridOrTreeOrRootT::RootNodeType;
3455 using type =
typename GridOrTreeOrRootT::RootNodeType;
3458 template<
typename Gr
idOrTreeOrRootT>
3461 static_assert(GridOrTreeOrRootT::RootNodeType::LEVEL == 3,
"Tree depth is not supported");
3462 using Type =
const typename GridOrTreeOrRootT::RootNodeType;
3463 using type =
const typename GridOrTreeOrRootT::RootNodeType;
3468 template<
typename BuildT>
3470 template<
typename BuildT>
3472 template<
typename BuildT>
3474 template<
typename BuildT>
3476 template<
typename BuildT>
3478 template<
typename BuildT>
3480 template<
typename BuildT>
3482 template<
typename BuildT>
3513 static const int MaxNameSize = 256;
3521 char mGridName[MaxNameSize];
3534 static_assert(8 * 84 ==
sizeof(
GridData),
"GridData has unexpected size");
3539 uint64_t gridSize = 0u,
3544 #ifdef NANOVDB_USE_NEW_MAGIC_NUMBERS 3549 mChecksum = ~uint64_t(0);
3554 mGridSize = gridSize;
3555 mGridName[0] =
'\0';
3558 mVoxelSize = map.getVoxelSize();
3559 mGridClass = gridClass;
3560 mGridType = gridType;
3561 mBlindMetadataOffset = mGridSize;
3562 mBlindMetadataCount = 0u;
3579 char *dst = mGridName, *end = dst + MaxNameSize;
3580 while (*src !=
'\0' && dst < end - 1)
3584 return *src ==
'\0';
3587 template<
typename Vec3T>
3589 template<
typename Vec3T>
3591 template<
typename Vec3T>
3593 template<
typename Vec3T>
3595 template<
typename Vec3T>
3598 template<
typename Vec3T>
3600 template<
typename Vec3T>
3602 template<
typename Vec3T>
3604 template<
typename Vec3T>
3606 template<
typename Vec3T>
3620 template <u
int32_t LEVEL>
3623 static_assert(LEVEL >= 0 && LEVEL <= 3,
"invalid LEVEL template parameter");
3624 auto *treeData = this->treePtr();
3625 auto nodeOffset = *
reinterpret_cast<const uint64_t*
>(treeData + 8*LEVEL);
3626 return nodeOffset ? PtrAdd<uint8_t>(treeData, nodeOffset) :
nullptr;
3632 template <u
int32_t LEVEL>
3641 return PtrAdd<GridBlindMetaData>(
this, mBlindMetadataOffset) + n;
3648 for (uint32_t i = 0; i < mBlindMetadataCount; ++i) {
3649 const auto* metaData = this->blindMetaData(i);
3652 return metaData->template getBlindData<const char>();
3671 if (
const uint8_t *root = this->nodePtr<3>()) {
3672 return *(
const uint32_t*)(root +
sizeof(
CoordBBox));
3687 template<
typename BuildT,
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1>
3690 template<
typename BuildT>
3697 template<
typename TreeT>
3717 Grid& operator=(
const Grid&) =
delete;
3741 template<
typename T = BuildType>
3748 template<
typename T = BuildType>
3753 __hostdev__ const TreeT&
tree()
const {
return *
reinterpret_cast<const TreeT*
>(this->treePtr()); }
3768 template<
typename Vec3T>
3772 template<
typename Vec3T>
3777 template<
typename Vec3T>
3782 template<
typename Vec3T>
3787 template<
typename Vec3T>
3791 template<
typename Vec3T>
3795 template<
typename Vec3T>
3800 template<
typename Vec3T>
3805 template<
typename Vec3T>
3810 template<
typename Vec3T>
3846 template<
typename NodeT>
3855 __hostdev__ bool isSequential()
const {
return UpperNodeType::FIXED_SIZE && LowerNodeType::FIXED_SIZE && LeafNodeType::FIXED_SIZE && this->isBreadthFirst(); }
3873 __hostdev__ int findBlindData(
const char* name)
const;
3884 printf(
"\nnanovdb::Grid::blindData is unsafe and hence deprecated! Please use nanovdb::Grid::getBlindData instead.\n\n");
3886 return this->blindMetaData(n).blindData();
3889 template <
typename BlindDataT>
3892 if (n >= DataType::mBlindMetadataCount)
return nullptr;
3893 return this->blindMetaData(n).template getBlindData<BlindDataT>();
3896 template <
typename BlindDataT>
3899 if (n >= DataType::mBlindMetadataCount)
return nullptr;
3900 return const_cast<BlindDataT*
>(this->blindMetaData(n).template getBlindData<BlindDataT>());
3909 template<
typename TreeT>
3912 for (uint32_t i = 0, n = this->blindDataCount(); i < n; ++i) {
3913 if (this->blindMetaData(i).mSemantic == semantic)
3919 template<
typename TreeT>
3922 auto test = [&](
int n) {
3923 const char* str = this->blindMetaData(n).mName;
3925 if (name[i] != str[i])
3927 if (name[i] ==
'\0' && str[i] ==
'\0')
3932 for (
int i = 0, n = this->blindDataCount(); i < n; ++i)
3942 int64_t mNodeOffset[4];
3943 uint32_t mNodeCount[3];
3944 uint32_t mTileCount[3];
3949 static_assert(8 * 8 ==
sizeof(
TreeData),
"TreeData has unexpected size");
3954 __hostdev__ uint8_t*
getRoot() {
return mNodeOffset[3] ? PtrAdd<uint8_t>(
this, mNodeOffset[3]) :
nullptr; }
3955 __hostdev__ const uint8_t*
getRoot()
const {
return mNodeOffset[3] ? PtrAdd<uint8_t>(
this, mNodeOffset[3]) :
nullptr; }
3957 template<
typename NodeT>
3972 template<
typename Gr
idT>
3975 using Type =
typename GridT::TreeType;
3976 using type =
typename GridT::TreeType;
3978 template<
typename Gr
idT>
3981 using Type =
const typename GridT::TreeType;
3982 using type =
const typename GridT::TreeType;
3988 template<
typename RootT>
3991 static_assert(RootT::LEVEL == 3,
"Tree depth is not supported");
3992 static_assert(RootT::ChildNodeType::LOG2DIM == 5,
"Tree configuration is not supported");
3993 static_assert(RootT::ChildNodeType::ChildNodeType::LOG2DIM == 4,
"Tree configuration is not supported");
3994 static_assert(RootT::LeafNodeType::LOG2DIM == 3,
"Tree configuration is not supported");
4009 using Node2 =
typename RootT::ChildNodeType;
4010 using Node1 =
typename Node2::ChildNodeType;
4016 Tree& operator=(
const Tree&) =
delete;
4028 RootT* ptr =
reinterpret_cast<RootT*
>(DataType::getRoot());
4035 const RootT* ptr =
reinterpret_cast<const RootT*
>(DataType::getRoot());
4075 return DataType::mTileCount[level - 1];
4078 template<
typename NodeT>
4081 static_assert(NodeT::LEVEL < 3,
"Invalid NodeT");
4082 return DataType::mNodeCount[NodeT::LEVEL];
4088 return DataType::mNodeCount[level];
4093 return DataType::mNodeCount[0] + DataType::mNodeCount[1] + DataType::mNodeCount[2];
4099 template<
typename NodeT>
4102 const int64_t offset = DataType::mNodeOffset[NodeT::LEVEL];
4103 return offset ? PtrAdd<NodeT>(
this, offset) :
nullptr;
4109 template<
typename NodeT>
4112 const int64_t offset = DataType::mNodeOffset[NodeT::LEVEL];
4113 return offset ? PtrAdd<NodeT>(
this, offset) :
nullptr;
4123 return this->
template getFirstNode<typename NodeTrait<RootT, LEVEL>::type>();
4133 return this->
template getFirstNode<typename NodeTrait<RootT, LEVEL>::type>();
4144 template<
typename OpT,
typename... ArgsT>
4147 return this->root().template get<OpT>(ijk, args...);
4150 template<
typename OpT,
typename... ArgsT>
4153 return this->root().template set<OpT>(ijk, args...);
4161 template<
typename RootT>
4164 min = this->root().minimum();
4165 max = this->root().maximum();
4173 template<
typename ChildT>
4180 static constexpr
bool FIXED_SIZE =
false;
4183 #ifdef NANOVDB_USE_SINGLE_ROOT_KEY 4185 template<
typename CoordType>
4188 static_assert(
sizeof(
CoordT) ==
sizeof(CoordType),
"Mismatching sizeof");
4189 static_assert(32 - ChildT::TOTAL <= 21,
"Cannot use 64 bit root keys");
4190 return (
KeyT(uint32_t(ijk[2]) >> ChildT::TOTAL)) |
4191 (
KeyT(uint32_t(ijk[1]) >> ChildT::TOTAL) << 21) |
4192 (
KeyT(uint32_t(ijk[0]) >> ChildT::TOTAL) << 42);
4196 static constexpr uint64_t MASK = (1u << 21) - 1;
4197 return CoordT(((key >> 42) & MASK) << ChildT::TOTAL,
4198 ((key >> 21) & MASK) << ChildT::TOTAL,
4199 (key & MASK) << ChildT::TOTAL);
4223 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
Tile 4225 template<
typename CoordType>
4228 key = CoordToKey(k);
4232 template<
typename CoordType,
typename ValueType>
4235 key = CoordToKey(k);
4256 return reinterpret_cast<const Tile*
>(
this + 1) + n;
4261 return reinterpret_cast<Tile*
>(
this + 1) + n;
4266 #if 1 // switch between linear and binary seach 4267 const auto key = CoordToKey(ijk);
4268 for (
Tile *p = reinterpret_cast<Tile*>(
this + 1), *q = p + mTableSize; p < q; ++p)
4272 #else // do not enable binary search if tiles are not guaranteed to be sorted!!!!!! 4273 int32_t low = 0, high = mTableSize;
4274 while (low != high) {
4275 int mid = low + ((high - low) >> 1);
4276 const Tile* tile = &tiles[mid];
4277 if (tile->
key == key) {
4279 }
else if (tile->
key < key) {
4291 return const_cast<RootData*
>(
this)->probeTile(ijk);
4300 return PtrAdd<ChildT>(
this, tile->
child);
4305 return PtrAdd<ChildT>(
this, tile->
child);
4328 template<
typename ChildT>
4347 static constexpr
bool FIXED_SIZE = DataType::FIXED_SIZE;
4349 static constexpr uint32_t LEVEL = 1 + ChildT::LEVEL;
4351 template<
typename RootT>
4374 return this->tile()->origin();
4379 return this->tile()->origin();
4383 template<
typename RootT>
4396 :
BaseT(parent->data(), parent->tileCount())
4399 while (*
this && !this->tile()->isChild())
4405 return *BaseT::mData->getChild(this->tile());
4410 return BaseT::mData->getChild(this->tile());
4416 while (*
this && this->tile()->isValue())
4434 template<
typename RootT>
4445 :
BaseT(parent->data(), parent->tileCount())
4448 while (*
this && this->tile()->isChild())
4454 return this->tile()->value;
4459 return this->tile()->state;
4465 while (*
this && this->tile()->isChild())
4483 template<
typename RootT>
4494 :
BaseT(parent->data(), parent->tileCount())
4497 while (*
this && !this->tile()->isActive())
4503 return this->tile()->value;
4509 while (*
this && !this->tile()->isActive())
4527 template<
typename RootT>
4539 :
BaseT(parent->data(), parent->tileCount())
4546 NodeT* child =
nullptr;
4547 auto* t = this->tile();
4549 child = BaseT::mData->getChild(t);
4558 return this->tile()->state;
4630 #ifdef NANOVDB_NEW_ACCESSOR_METHODS 4638 #else // NANOVDB_NEW_ACCESSOR_METHODS 4643 if (
const Tile* tile = DataType::probeTile(ijk)) {
4644 return tile->isChild() ? this->getChild(tile)->getValue(ijk) : tile->value;
4646 return DataType::mBackground;
4652 if (
const Tile* tile = DataType::probeTile(ijk)) {
4653 return tile->isChild() ? this->getChild(tile)->isActive(ijk) : tile->state;
4660 if (
const Tile* tile = DataType::probeTile(ijk)) {
4661 if (tile->isChild()) {
4662 const auto* child = this->getChild(tile);
4663 return child->probeValue(ijk, v);
4668 v = DataType::mBackground;
4674 const Tile* tile = DataType::probeTile(ijk);
4675 if (tile && tile->isChild()) {
4676 const auto* child = this->getChild(tile);
4677 return child->probeLeaf(ijk);
4682 #endif // NANOVDB_NEW_ACCESSOR_METHODS 4686 const Tile* tile = DataType::probeTile(ijk);
4687 return tile && tile->isChild() ? this->getChild(tile) :
nullptr;
4692 const Tile* tile = DataType::probeTile(ijk);
4693 return tile && tile->isChild() ? this->getChild(tile) :
nullptr;
4696 template<
typename OpT,
typename... ArgsT>
4699 if (
const Tile* tile = this->probeTile(ijk)) {
4700 if (tile->isChild())
4701 return this->getChild(tile)->template get<OpT>(ijk, args...);
4702 return OpT::get(*tile, args...);
4704 return OpT::get(*
this, args...);
4707 template<
typename OpT,
typename... ArgsT>
4709 __hostdev__ decltype(OpT::set(std::declval<Tile&>(), std::declval<ArgsT>()...))
4712 if (
Tile* tile = DataType::probeTile(ijk)) {
4713 if (tile->isChild())
4714 return this->getChild(tile)->template set<OpT>(ijk, args...);
4715 return OpT::set(*tile, args...);
4717 return OpT::set(*
this, args...);
4724 template<
typename,
int,
int,
int>
4729 #ifndef NANOVDB_NEW_ACCESSOR_METHODS 4731 template<
typename AccT>
4732 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ijk,
const AccT& acc)
const 4734 using NodeInfoT =
typename AccT::NodeInfo;
4735 if (
const Tile* tile = this->probeTile(ijk)) {
4736 if (tile->isChild()) {
4737 const auto* child = this->getChild(tile);
4738 acc.insert(ijk, child);
4739 return child->getNodeInfoAndCache(ijk, acc);
4741 return NodeInfoT{LEVEL, ChildT::dim(), tile->value, tile->value, tile->value, 0, tile->origin(), tile->origin() +
CoordType(ChildT::DIM)};
4743 return NodeInfoT{LEVEL, ChildT::dim(), this->minimum(), this->maximum(), this->average(), this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
4747 template<
typename AccT>
4750 if (
const Tile* tile = this->probeTile(ijk)) {
4751 if (tile->isChild()) {
4752 const auto* child = this->getChild(tile);
4753 acc.insert(ijk, child);
4754 return child->getValueAndCache(ijk, acc);
4758 return DataType::mBackground;
4761 template<
typename AccT>
4764 const Tile* tile = this->probeTile(ijk);
4765 if (tile && tile->isChild()) {
4766 const auto* child = this->getChild(tile);
4767 acc.insert(ijk, child);
4768 return child->isActiveAndCache(ijk, acc);
4773 template<
typename AccT>
4776 if (
const Tile* tile = this->probeTile(ijk)) {
4777 if (tile->isChild()) {
4778 const auto* child = this->getChild(tile);
4779 acc.insert(ijk, child);
4780 return child->probeValueAndCache(ijk, v, acc);
4785 v = DataType::mBackground;
4789 template<
typename AccT>
4792 const Tile* tile = this->probeTile(ijk);
4793 if (tile && tile->isChild()) {
4794 const auto* child = this->getChild(tile);
4795 acc.insert(ijk, child);
4796 return child->probeLeafAndCache(ijk, acc);
4800 #endif // NANOVDB_NEW_ACCESSOR_METHODS 4802 template<
typename RayT,
typename AccT>
4803 __hostdev__ uint32_t getDimAndCache(
const CoordType& ijk,
const RayT& ray,
const AccT& acc)
const 4805 if (
const Tile* tile = this->probeTile(ijk)) {
4806 if (tile->isChild()) {
4807 const auto* child = this->getChild(tile);
4808 acc.insert(ijk, child);
4809 return child->getDimAndCache(ijk, ray, acc);
4811 return 1 << ChildT::TOTAL;
4813 return ChildNodeType::dim();
4816 template<
typename OpT,
typename AccT,
typename... ArgsT>
4819 getAndCache(
const CoordType& ijk,
const AccT& acc, ArgsT&&... args)
const 4821 if (
const Tile* tile = this->probeTile(ijk)) {
4822 if (tile->isChild()) {
4823 const ChildT* child = this->getChild(tile);
4824 acc.insert(ijk, child);
4825 return child->template getAndCache<OpT>(ijk, acc, args...);
4827 return OpT::get(*tile, args...);
4829 return OpT::get(*
this, args...);
4832 template<
typename OpT,
typename AccT,
typename... ArgsT>
4834 __hostdev__ decltype(OpT::set(std::declval<Tile&>(), std::declval<ArgsT>()...))
4835 setAndCache(const
CoordType& ijk, const AccT& acc, ArgsT&&... args)
4837 if (
Tile* tile = DataType::probeTile(ijk)) {
4838 if (tile->isChild()) {
4839 ChildT* child = this->getChild(tile);
4840 acc.insert(ijk, child);
4841 return child->template setAndCache<OpT>(ijk, acc, args...);
4843 return OpT::set(*tile, args...);
4845 return OpT::set(*
this, args...);
4857 template<
typename ChildT, u
int32_t LOG2DIM>
4864 using MaskT =
typename ChildT::template MaskType<LOG2DIM>;
4865 static constexpr
bool FIXED_SIZE =
true;
4874 Tile& operator=(
const Tile&) =
delete;
4896 alignas(32) Tile mTable[1u << (3 * LOG2DIM)];
4903 mTable[n].child =
PtrDiff(ptr,
this);
4906 template<
typename ValueT>
4910 mTable[n].value = v;
4917 return PtrAdd<ChildT>(
this, mTable[n].child);
4922 return PtrAdd<ChildT>(
this, mTable[n].child);
4928 return mTable[n].value;
4934 return mValueMask.isOn(n);
4939 template<
typename T>
4947 #if defined(__GNUC__) && !defined(__APPLE__) && !defined(__llvm__) 4948 #pragma GCC diagnostic push 4949 #pragma GCC diagnostic ignored "-Wstringop-overflow" 4955 #if defined(__GNUC__) && !defined(__APPLE__) && !defined(__llvm__) 4956 #pragma GCC diagnostic pop 4967 template<
typename ChildT, u
int32_t Log2Dim = ChildT::LOG2DIM + 1>
4978 static constexpr
bool FIXED_SIZE = DataType::FIXED_SIZE;
4979 template<u
int32_t LOG2>
4984 static constexpr uint32_t LOG2DIM = Log2Dim;
4985 static constexpr uint32_t TOTAL = LOG2DIM + ChildT::TOTAL;
4986 static constexpr uint32_t DIM = 1u << TOTAL;
4987 static constexpr uint32_t SIZE = 1u << (3 * LOG2DIM);
4988 static constexpr uint32_t MASK = (1u << TOTAL) - 1u;
4989 static constexpr uint32_t LEVEL = 1 + ChildT::LEVEL;
4990 static constexpr uint64_t NUM_VALUES = uint64_t(1) << (3 * TOTAL);
4993 template <
typename ParentT>
5008 : BaseT(parent->mChildMask.beginOn())
5016 return *mParent->getChild(BaseT::pos());
5021 return mParent->getChild(BaseT::pos());
5026 return (*this)->origin();
5050 : BaseT(parent->data()->mChildMask.beginOff())
5089 : BaseT(parent->data()->mValueMask.beginOn())
5124 , mParent(parent->data())
5131 const ChildT* child =
nullptr;
5132 if (mParent->
mChildMask.isOn(BaseT::pos())) {
5133 child = mParent->
getChild(BaseT::pos());
5135 value = mParent->
getValue(BaseT::pos());
5142 return mParent->
isActive(BaseT::pos());
5147 return mParent->offsetToGlobalCoord(BaseT::pos());
5204 return DataType::mChildMask.isOn(0) ? this->getChild(0)->getFirstValue() : DataType::getValue(0);
5211 return DataType::mChildMask.isOn(SIZE - 1) ? this->getChild(SIZE - 1)->getLastValue() : DataType::getValue(SIZE - 1);
5214 #ifdef NANOVDB_NEW_ACCESSOR_METHODS 5221 #else // NANOVDB_NEW_ACCESSOR_METHODS 5224 const uint32_t n = CoordToOffset(ijk);
5225 return DataType::mChildMask.isOn(n) ? this->getChild(n)->getValue(ijk) : DataType::getValue(n);
5229 const uint32_t n = CoordToOffset(ijk);
5230 return DataType::mChildMask.isOn(n) ? this->getChild(n)->isActive(ijk) : DataType::isActive(n);
5234 const uint32_t n = CoordToOffset(ijk);
5235 if (DataType::mChildMask.isOn(n))
5236 return this->getChild(n)->probeValue(ijk, v);
5237 v = DataType::getValue(n);
5238 return DataType::isActive(n);
5242 const uint32_t n = CoordToOffset(ijk);
5243 if (DataType::mChildMask.isOn(n))
5244 return this->getChild(n)->probeLeaf(ijk);
5248 #endif // NANOVDB_NEW_ACCESSOR_METHODS 5252 const uint32_t n = CoordToOffset(ijk);
5253 return DataType::mChildMask.isOn(n) ? this->getChild(n) :
nullptr;
5257 const uint32_t n = CoordToOffset(ijk);
5258 return DataType::mChildMask.isOn(n) ? this->getChild(n) :
nullptr;
5264 return (((ijk[0] & MASK) >> ChildT::TOTAL) << (2 * LOG2DIM)) |
5265 (((ijk[1] & MASK) >> ChildT::TOTAL) << (LOG2DIM)) |
5266 ((ijk[2] & MASK) >> ChildT::TOTAL);
5273 const uint32_t m = n & ((1 << 2 * LOG2DIM) - 1);
5274 return Coord(n >> 2 * LOG2DIM, m >> LOG2DIM, m & ((1 << LOG2DIM) - 1));
5280 ijk <<= ChildT::TOTAL;
5281 ijk += this->origin();
5287 this->localToGlobalCoord(ijk);
5294 template<
typename OpT,
typename... ArgsT>
5297 const uint32_t n = CoordToOffset(ijk);
5298 if (this->isChild(n))
5299 return this->getChild(n)->template get<OpT>(ijk, args...);
5300 return OpT::get(*
this, n, args...);
5303 template<
typename OpT,
typename... ArgsT>
5305 __hostdev__ decltype(OpT::set(std::declval<InternalNode&>(), std::declval<uint32_t>(), std::declval<ArgsT>()...))
5308 const uint32_t n = CoordToOffset(ijk);
5309 if (this->isChild(n))
5310 return this->getChild(n)->template set<OpT>(ijk, args...);
5311 return OpT::set(*
this, n, args...);
5317 template<
typename,
int,
int,
int>
5322 template<
typename, u
int32_t>
5325 #ifndef NANOVDB_NEW_ACCESSOR_METHODS 5327 template<
typename AccT>
5330 const uint32_t n = CoordToOffset(ijk);
5331 if (DataType::mChildMask.isOff(n))
5332 return DataType::getValue(n);
5333 const ChildT* child = this->getChild(n);
5334 acc.insert(ijk, child);
5335 return child->getValueAndCache(ijk, acc);
5337 template<
typename AccT>
5340 const uint32_t n = CoordToOffset(ijk);
5341 if (DataType::mChildMask.isOff(n))
5342 return DataType::isActive(n);
5343 const ChildT* child = this->getChild(n);
5344 acc.insert(ijk, child);
5345 return child->isActiveAndCache(ijk, acc);
5347 template<
typename AccT>
5350 const uint32_t n = CoordToOffset(ijk);
5351 if (DataType::mChildMask.isOff(n)) {
5352 v = DataType::getValue(n);
5353 return DataType::isActive(n);
5355 const ChildT* child = this->getChild(n);
5356 acc.insert(ijk, child);
5357 return child->probeValueAndCache(ijk, v, acc);
5359 template<
typename AccT>
5362 const uint32_t n = CoordToOffset(ijk);
5363 if (DataType::mChildMask.isOff(n))
5365 const ChildT* child = this->getChild(n);
5366 acc.insert(ijk, child);
5367 return child->probeLeafAndCache(ijk, acc);
5369 template<
typename AccT>
5370 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ijk,
const AccT& acc)
const 5372 using NodeInfoT =
typename AccT::NodeInfo;
5373 const uint32_t n = CoordToOffset(ijk);
5374 if (DataType::mChildMask.isOff(n)) {
5375 return NodeInfoT{LEVEL, this->dim(), this->minimum(), this->maximum(), this->average(), this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
5377 const ChildT* child = this->getChild(n);
5378 acc.insert(ijk, child);
5379 return child->getNodeInfoAndCache(ijk, acc);
5381 #endif // NANOVDB_NEW_ACCESSOR_METHODS 5383 template<
typename RayT,
typename AccT>
5384 __hostdev__ uint32_t getDimAndCache(
const CoordType& ijk,
const RayT& ray,
const AccT& acc)
const 5386 if (DataType::mFlags & uint32_t(1u))
5390 const uint32_t n = CoordToOffset(ijk);
5391 if (DataType::mChildMask.isOn(n)) {
5392 const ChildT* child = this->getChild(n);
5393 acc.insert(ijk, child);
5394 return child->getDimAndCache(ijk, ray, acc);
5396 return ChildNodeType::dim();
5399 template<
typename OpT,
typename AccT,
typename... ArgsT>
5402 getAndCache(
const CoordType& ijk,
const AccT& acc, ArgsT&&... args)
const 5404 const uint32_t n = CoordToOffset(ijk);
5405 if (DataType::mChildMask.isOff(n))
5406 return OpT::get(*
this, n, args...);
5407 const ChildT* child = this->getChild(n);
5408 acc.insert(ijk, child);
5409 return child->template getAndCache<OpT>(ijk, acc, args...);
5412 template<
typename OpT,
typename AccT,
typename... ArgsT>
5414 __hostdev__ decltype(OpT::set(std::declval<InternalNode&>(), std::declval<uint32_t>(), std::declval<ArgsT>()...))
5415 setAndCache(const
CoordType& ijk, const AccT& acc, ArgsT&&... args)
5417 const uint32_t n = CoordToOffset(ijk);
5418 if (DataType::mChildMask.isOff(n))
5419 return OpT::set(*
this, n, args...);
5420 ChildT* child = this->getChild(n);
5421 acc.insert(ijk, child);
5422 return child->template setAndCache<OpT>(ijk, acc, args...);
5432 template<
typename ValueT,
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5435 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
5436 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
5441 static constexpr
bool FIXED_SIZE =
true;
5444 uint8_t mBBoxDif[3];
5459 return sizeof(
LeafData) - (12 + 3 + 1 +
sizeof(MaskT<LOG2DIM>) + 2 * (
sizeof(ValueT) +
sizeof(
FloatType)) + (1u << (3 * LOG2DIM)) *
sizeof(ValueT));
5469 mValueMask.setOn(offset);
5470 mValues[offset] = value;
5484 template<
typename T>
5489 for (
auto *p = mValues, *q = p + 512; p != q; ++p)
5503 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5506 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
5507 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
5512 uint8_t mBBoxDif[3];
5529 return sizeof(
LeafFnBase) - (12 + 3 + 1 +
sizeof(MaskT<LOG2DIM>) + 2 * 4 + 4 * 2);
5534 mQuantum = (max -
min) /
float((1 << bitWidth) - 1);
5564 template<
typename T>
5573 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5574 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp4, CoordT, MaskT, LOG2DIM>
5580 static constexpr
bool FIXED_SIZE =
true;
5581 alignas(32) uint8_t mCode[1u << (3 * LOG2DIM - 1)];
5586 static_assert(BaseT::padding() == 0,
"expected no padding in LeafFnBase");
5587 return sizeof(
LeafData) -
sizeof(
BaseT) - (1u << (3 * LOG2DIM - 1));
5594 const uint8_t c = mCode[i>>1];
5595 return ( (i&1) ? c >> 4 : c & uint8_t(15) )*BaseT::mQuantum + BaseT::mMinimum;
5597 return ((mCode[i >> 1] >> ((i & 1) << 2)) & uint8_t(15)) * BaseT::mQuantum + BaseT::mMinimum;
5610 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5611 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp8, CoordT, MaskT, LOG2DIM>
5617 static constexpr
bool FIXED_SIZE =
true;
5618 alignas(32) uint8_t mCode[1u << 3 * LOG2DIM];
5622 static_assert(BaseT::padding() == 0,
"expected no padding in LeafFnBase");
5623 return sizeof(
LeafData) -
sizeof(
BaseT) - (1u << 3 * LOG2DIM);
5629 return mCode[i] * BaseT::mQuantum + BaseT::mMinimum;
5640 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5641 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Fp16, CoordT, MaskT, LOG2DIM>
5647 static constexpr
bool FIXED_SIZE =
true;
5648 alignas(32) uint16_t mCode[1u << 3 * LOG2DIM];
5653 static_assert(BaseT::padding() == 0,
"expected no padding in LeafFnBase");
5654 return sizeof(
LeafData) -
sizeof(
BaseT) - 2 * (1u << 3 * LOG2DIM);
5660 return mCode[i] * BaseT::mQuantum + BaseT::mMinimum;
5672 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5673 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
FpN, CoordT, MaskT, LOG2DIM>
5679 static constexpr
bool FIXED_SIZE =
false;
5682 static_assert(BaseT::padding() == 0,
"expected no padding in LeafFnBase");
5691 #ifdef NANOVDB_FPN_BRANCHLESS // faster 5692 const int b = BaseT::mFlags >> 5;
5694 uint16_t code =
reinterpret_cast<const uint16_t*
>(
this + 1)[i >> (4 - b)];
5695 const static uint8_t shift[5] = {15, 7, 3, 1, 0};
5696 const static uint16_t mask[5] = {1, 3, 15, 255, 65535};
5697 code >>= (i & shift[b]) << b;
5700 uint32_t code =
reinterpret_cast<const uint32_t*
>(
this + 1)[i >> (5 - b)];
5701 code >>= (i & ((32 >> b) - 1)) << b;
5702 code &= (1 << (1 << b)) - 1;
5704 #else // use branched version (slow) 5706 auto* values =
reinterpret_cast<const uint8_t*
>(
this + 1);
5707 switch (BaseT::mFlags >> 5) {
5709 code = float((values[i >> 3] >> (i & 7)) & uint8_t(1));
5712 code = float((values[i >> 2] >> ((i & 3) << 1)) & uint8_t(3));
5715 code = float((values[i >> 1] >> ((i & 1) << 2)) & uint8_t(15));
5718 code = float(values[i]);
5721 code = float(reinterpret_cast<const uint16_t*>(values)[i]);
5724 return float(code) * BaseT::mQuantum + BaseT::mMinimum;
5737 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5738 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<bool, CoordT, MaskT, LOG2DIM>
5740 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
5741 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
5746 static constexpr
bool FIXED_SIZE =
true;
5749 uint8_t mBBoxDif[3];
5753 uint64_t mPadding[2];
5765 mValueMask.setOn(offset);
5766 mValues.set(offset, v);
5774 template<
typename T>
5787 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5790 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
5791 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
5796 static constexpr
bool FIXED_SIZE =
true;
5799 uint8_t mBBoxDif[3];
5802 uint64_t mPadding[2];
5808 return sizeof(
LeafData) - (12u + 3u + 1u +
sizeof(MaskT<LOG2DIM>) + 2 * 8u);
5823 template<
typename T>
5836 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5839 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
5840 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
5844 static constexpr
bool FIXED_SIZE =
true;
5847 uint8_t mBBoxDif[3];
5853 return sizeof(
LeafIndexBase) - (12u + 3u + 1u +
sizeof(MaskT<LOG2DIM>) + 2 * 8u);
5864 template<
typename T>
5871 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5897 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5905 return CountOn(BaseT::mValueMask.words()[7]) + (BaseT::mPrefixSum >> 54u & 511u);
5915 uint32_t n = i >> 6;
5916 const uint64_t w = BaseT::mValueMask.words()[n], mask = uint64_t(1) << (i & 63u);
5917 if (!(w & mask))
return uint64_t(0);
5918 uint64_t sum = BaseT::mOffset +
CountOn(w & (mask - 1u));
5919 if (n--) sum += BaseT::mPrefixSum >> (9u * n) & 511u;
5932 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5934 :
public LeafData<ValueIndex, CoordT, MaskT, LOG2DIM>
5943 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5945 :
public LeafData<ValueOnIndex, CoordT, MaskT, LOG2DIM>
5956 template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5957 struct NANOVDB_ALIGN(NANOVDB_DATA_ALIGNMENT)
LeafData<
Point, CoordT, MaskT, LOG2DIM>
5959 static_assert(
sizeof(CoordT) ==
sizeof(
Coord),
"Mismatching sizeof");
5960 static_assert(
sizeof(MaskT<LOG2DIM>) ==
sizeof(
Mask<LOG2DIM>),
"Mismatching sizeof");
5965 static constexpr
bool FIXED_SIZE =
true;
5968 uint8_t mBBoxDif[3];
5974 alignas(32) uint16_t mValues[1u << 3 * LOG2DIM];
5982 return sizeof(
LeafData) - (12u + 3u + 1u +
sizeof(MaskT<LOG2DIM>) + 2 * 8u + (1u << 3 * LOG2DIM) * 2u);
5988 __hostdev__ uint64_t
first(uint32_t i)
const {
return i ? uint64_t(mValues[i - 1u]) + mOffset : mOffset; }
5994 mValueMask.setOn(offset);
5995 mValues[offset] = value;
6009 template<
typename T>
6022 template<
typename BuildT,
6023 typename CoordT =
Coord,
6024 template<u
int32_t>
class MaskT =
Mask,
6025 uint32_t Log2Dim = 3>
6031 static constexpr uint32_t TOTAL = 0;
6032 static constexpr uint32_t DIM = 1;
6041 static constexpr
bool FIXED_SIZE = DataType::FIXED_SIZE;
6042 template<u
int32_t LOG2>
6060 : BaseT(parent->data()->mValueMask.beginOn())
6068 return mParent->
getValue(BaseT::pos());
6093 : BaseT(parent->data()->mValueMask.beginOff())
6101 return mParent->
getValue(BaseT::pos());
6122 , mPos(1u << 3 * Log2Dim)
6147 __hostdev__ operator bool()
const {
return mPos < (1u << 3 * Log2Dim); }
6165 static constexpr uint32_t LOG2DIM = Log2Dim;
6166 static constexpr uint32_t TOTAL = LOG2DIM;
6167 static constexpr uint32_t DIM = 1u << TOTAL;
6168 static constexpr uint32_t SIZE = 1u << 3 * LOG2DIM;
6169 static constexpr uint32_t MASK = (1u << LOG2DIM) - 1u;
6170 static constexpr uint32_t LEVEL = 0;
6171 static constexpr uint64_t NUM_VALUES = uint64_t(1) << (3 * TOTAL);
6207 const uint32_t m = n & ((1 << 2 * LOG2DIM) - 1);
6208 return CoordT(n >> 2 * LOG2DIM, m >> LOG2DIM, m & MASK);
6216 return OffsetToLocalCoord(n) + this->origin();
6225 BBox<CoordT> bbox(DataType::mBBoxMin, DataType::mBBoxMin);
6226 if (this->hasBBox()) {
6227 bbox.max()[0] += DataType::mBBoxDif[0];
6228 bbox.max()[1] += DataType::mBBoxDif[1];
6229 bbox.max()[2] += DataType::mBBoxDif[2];
6281 return !DataType::mValueMask.isOff();
6289 const uint32_t n = CoordToOffset(ijk);
6290 v = DataType::getValue(n);
6291 return DataType::mValueMask.isOn(n);
6299 return ((ijk[0] & MASK) << (2 * LOG2DIM)) | ((ijk[1] & MASK) << LOG2DIM) | (ijk[2] & MASK);
6311 template<
typename OpT,
typename... ArgsT>
6314 return OpT::get(*
this, CoordToOffset(ijk), args...);
6317 template<
typename OpT,
typename... ArgsT>
6320 return OpT::get(*
this, n, args...);
6323 template<
typename OpT,
typename... ArgsT>
6326 return OpT::set(*
this, CoordToOffset(ijk), args...);
6329 template<
typename OpT,
typename... ArgsT>
6332 return OpT::set(*
this, n, args...);
6338 template<
typename,
int,
int,
int>
6343 template<
typename, u
int32_t>
6346 #ifndef NANOVDB_NEW_ACCESSOR_METHODS 6348 template<
typename AccT>
6349 __hostdev__ ValueType getValueAndCache(
const CoordT& ijk,
const AccT&)
const {
return this->getValue(ijk); }
6352 template<
typename AccT>
6355 using NodeInfoT =
typename AccT::NodeInfo;
6356 return NodeInfoT{LEVEL, this->dim(), this->minimum(), this->maximum(), this->average(), this->stdDeviation(), this->bbox()[0], this->bbox()[1]};
6359 template<
typename AccT>
6360 __hostdev__ bool isActiveAndCache(
const CoordT& ijk,
const AccT&)
const {
return this->isActive(ijk); }
6362 template<
typename AccT>
6363 __hostdev__ bool probeValueAndCache(
const CoordT& ijk,
ValueType& v,
const AccT&)
const {
return this->probeValue(ijk, v); }
6365 template<
typename AccT>
6366 __hostdev__ const LeafNode* probeLeafAndCache(
const CoordT&,
const AccT&)
const {
return this; }
6369 template<
typename RayT,
typename AccT>
6370 __hostdev__ uint32_t getDimAndCache(
const CoordT&,
const RayT& ,
const AccT&)
const 6372 if (DataType::mFlags & uint8_t(1u))
6376 return ChildNodeType::dim();
6379 template<
typename OpT,
typename AccT,
typename... ArgsT>
6382 getAndCache(
const CoordType& ijk,
const AccT&, ArgsT&&... args)
const 6384 return OpT::get(*
this, CoordToOffset(ijk), args...);
6387 template<
typename OpT,
typename AccT,
typename... ArgsT>
6389 __hostdev__ decltype(OpT::set(std::declval<LeafNode&>(), std::declval<uint32_t>(), std::declval<ArgsT>()...))
6390 setAndCache(const
CoordType& ijk, const AccT&, ArgsT&&... args)
6392 return OpT::set(*
this, CoordToOffset(ijk), args...);
6399 template<
typename ValueT,
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
6402 static_assert(LOG2DIM == 3,
"LeafNode::updateBBox: only supports LOGDIM = 3!");
6403 if (DataType::mValueMask.isOff()) {
6404 DataType::mFlags &= ~uint8_t(2);
6407 auto update = [&](uint32_t
min, uint32_t
max,
int axis) {
6409 DataType::mBBoxMin[axis] = (DataType::mBBoxMin[axis] & ~MASK) +
int(min);
6410 DataType::mBBoxDif[axis] = uint8_t(max - min);
6412 uint64_t *w = DataType::mValueMask.words(), word64 = *w;
6413 uint32_t Xmin = word64 ? 0u : 8u, Xmax = Xmin;
6414 for (
int i = 1; i < 8; ++i) {
6423 update(Xmin, Xmax, 0);
6425 const uint32_t *p =
reinterpret_cast<const uint32_t*
>(&word64), word32 = p[0] | p[1];
6426 const uint16_t *q =
reinterpret_cast<const uint16_t*
>(&word32), word16 = q[0] | q[1];
6427 const uint8_t * b =
reinterpret_cast<const uint8_t*
>(&word16), byte = b[0] | b[1];
6430 DataType::mFlags |= uint8_t(2);
6438 template<
typename BuildT>
6440 template<
typename BuildT>
6442 template<
typename BuildT>
6444 template<
typename BuildT>
6446 template<
typename BuildT>
6448 template<
typename BuildT>
6452 template<
typename BuildT,
int LEVEL>
6456 template<
typename BuildT>
6462 template<
typename BuildT>
6468 template<
typename BuildT>
6474 template<
typename BuildT>
6545 template<
typename BuildT>
6555 mutable const RootT* mRoot;
6561 static const int CacheLevels = 0;
6562 #ifndef NANOVDB_NEW_ACCESSOR_METHODS 6583 : ReadAccessor(grid.tree().root())
6589 : ReadAccessor(tree.root())
6603 #ifdef NANOVDB_NEW_ACCESSOR_METHODS 6606 return this->
template get<GetValue<BuildT>>(ijk);
6615 #else // NANOVDB_NEW_ACCESSOR_METHODS 6618 return mRoot->getValueAndCache(ijk, *
this);
6622 return this->getValue(
CoordType(i, j, k));
6626 return this->getValue(ijk);
6630 return this->getValue(
CoordType(i, j, k));
6635 return mRoot->getNodeInfoAndCache(ijk, *
this);
6640 return mRoot->isActiveAndCache(ijk, *
this);
6645 return mRoot->probeValueAndCache(ijk, v, *
this);
6650 return mRoot->probeLeafAndCache(ijk, *
this);
6652 #endif // NANOVDB_NEW_ACCESSOR_METHODS 6653 template<
typename RayT>
6656 return mRoot->getDimAndCache(ijk, ray, *
this);
6658 template<
typename OpT,
typename... ArgsT>
6661 return mRoot->template get<OpT>(ijk, args...);
6664 template<
typename OpT,
typename... ArgsT>
6667 return const_cast<RootT*
>(mRoot)->
template set<OpT>(ijk, args...);
6674 template<
typename, u
int32_t>
6676 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
6680 template<
typename NodeT>
6685 template<
typename BuildT,
int LEVEL0>
6688 static_assert(LEVEL0 >= 0 && LEVEL0 <= 2,
"LEVEL0 should be 0, 1, or 2");
6702 mutable CoordT mKey;
6703 mutable const RootT* mRoot;
6704 mutable const NodeT* mNode;
6711 static const int CacheLevels = 1;
6712 #ifndef NANOVDB_NEW_ACCESSOR_METHODS 6713 using NodeInfo =
typename ReadAccessor<ValueT, -1, -1, -1>::NodeInfo;
6725 : ReadAccessor(grid.tree().root())
6731 : ReadAccessor(tree.root())
6751 return (ijk[0] & int32_t(~NodeT::MASK)) == mKey[0] &&
6752 (ijk[1] & int32_t(~NodeT::MASK)) == mKey[1] &&
6753 (ijk[2] & int32_t(~NodeT::MASK)) == mKey[2];
6756 #ifdef NANOVDB_NEW_ACCESSOR_METHODS 6759 return this->
template get<GetValue<BuildT>>(ijk);
6768 #else // NANOVDB_NEW_ACCESSOR_METHODS 6771 if (this->isCached(ijk))
6772 return mNode->getValueAndCache(ijk, *
this);
6773 return mRoot->getValueAndCache(ijk, *
this);
6777 return this->getValue(
CoordType(i, j, k));
6781 return this->getValue(ijk);
6785 return this->getValue(
CoordType(i, j, k));
6790 if (this->isCached(ijk))
6791 return mNode->getNodeInfoAndCache(ijk, *
this);
6792 return mRoot->getNodeInfoAndCache(ijk, *
this);
6797 if (this->isCached(ijk))
6798 return mNode->isActiveAndCache(ijk, *
this);
6799 return mRoot->isActiveAndCache(ijk, *
this);
6804 if (this->isCached(ijk))
6805 return mNode->probeValueAndCache(ijk, v, *
this);
6806 return mRoot->probeValueAndCache(ijk, v, *
this);
6811 if (this->isCached(ijk))
6812 return mNode->probeLeafAndCache(ijk, *
this);
6813 return mRoot->probeLeafAndCache(ijk, *
this);
6815 #endif // NANOVDB_NEW_ACCESSOR_METHODS 6816 template<
typename RayT>
6819 if (this->isCached(ijk))
6820 return mNode->getDimAndCache(ijk, ray, *
this);
6821 return mRoot->getDimAndCache(ijk, ray, *
this);
6824 template<
typename OpT,
typename... ArgsT>
6827 if (this->isCached(ijk))
6828 return mNode->template getAndCache<OpT>(ijk, *
this, args...);
6829 return mRoot->template getAndCache<OpT>(ijk, *
this, args...);
6832 template<
typename OpT,
typename... ArgsT>
6835 if (this->isCached(ijk))
6836 return const_cast<NodeT*>(mNode)->template setAndCache<OpT>(ijk, *
this, args...);
6837 return const_cast<RootT*
>(mRoot)->
template setAndCache<OpT>(ijk, *
this, args...);
6844 template<
typename, u
int32_t>
6846 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
6852 mKey = ijk & ~NodeT::MASK;
6857 template<
typename OtherNodeT>
6862 template<
typename BuildT,
int LEVEL0,
int LEVEL1>
6865 static_assert(LEVEL0 >= 0 && LEVEL0 <= 2,
"LEVEL0 must be 0, 1, 2");
6866 static_assert(LEVEL1 >= 0 && LEVEL1 <= 2,
"LEVEL1 must be 0, 1, 2");
6867 static_assert(LEVEL0 < LEVEL1,
"Level 0 must be lower than level 1");
6880 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY // 44 bytes total 6881 mutable CoordT mKey;
6882 #else // 68 bytes total 6883 mutable CoordT mKeys[2];
6885 mutable const RootT* mRoot;
6886 mutable const Node1T* mNode1;
6887 mutable const Node2T* mNode2;
6894 static const int CacheLevels = 2;
6895 #ifndef NANOVDB_NEW_ACCESSOR_METHODS 6896 using NodeInfo =
typename ReadAccessor<ValueT, -1, -1, -1>::NodeInfo;
6900 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 6913 : ReadAccessor(grid.tree().root())
6919 : ReadAccessor(tree.root())
6926 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 6942 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 6943 __hostdev__ bool isCached1(CoordValueType dirty)
const 6947 if (dirty & int32_t(~Node1T::MASK)) {
6953 __hostdev__ bool isCached2(CoordValueType dirty)
const 6957 if (dirty & int32_t(~Node2T::MASK)) {
6965 return (ijk[0] ^ mKey[0]) | (ijk[1] ^ mKey[1]) | (ijk[2] ^ mKey[2]);
6970 return (ijk[0] & int32_t(~Node1T::MASK)) == mKeys[0][0] &&
6971 (ijk[1] & int32_t(~Node1T::MASK)) == mKeys[0][1] &&
6972 (ijk[2] & int32_t(~Node1T::MASK)) == mKeys[0][2];
6976 return (ijk[0] & int32_t(~Node2T::MASK)) == mKeys[1][0] &&
6977 (ijk[1] & int32_t(~Node2T::MASK)) == mKeys[1][1] &&
6978 (ijk[2] & int32_t(~Node2T::MASK)) == mKeys[1][2];
6982 #ifdef NANOVDB_NEW_ACCESSOR_METHODS 6985 return this->
template get<GetValue<BuildT>>(ijk);
6994 #else // NANOVDB_NEW_ACCESSOR_METHODS 6998 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 6999 const CoordValueType dirty = this->computeDirty(ijk);
7003 if (this->isCached1(dirty)) {
7004 return mNode1->getValueAndCache(ijk, *
this);
7005 }
else if (this->isCached2(dirty)) {
7006 return mNode2->getValueAndCache(ijk, *
this);
7008 return mRoot->getValueAndCache(ijk, *
this);
7012 return this->getValue(ijk);
7016 return this->getValue(
CoordType(i, j, k));
7020 return this->getValue(
CoordType(i, j, k));
7024 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7025 const CoordValueType dirty = this->computeDirty(ijk);
7029 if (this->isCached1(dirty)) {
7030 return mNode1->getNodeInfoAndCache(ijk, *
this);
7031 }
else if (this->isCached2(dirty)) {
7032 return mNode2->getNodeInfoAndCache(ijk, *
this);
7034 return mRoot->getNodeInfoAndCache(ijk, *
this);
7039 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7040 const CoordValueType dirty = this->computeDirty(ijk);
7044 if (this->isCached1(dirty)) {
7045 return mNode1->isActiveAndCache(ijk, *
this);
7046 }
else if (this->isCached2(dirty)) {
7047 return mNode2->isActiveAndCache(ijk, *
this);
7049 return mRoot->isActiveAndCache(ijk, *
this);
7054 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7055 const CoordValueType dirty = this->computeDirty(ijk);
7059 if (this->isCached1(dirty)) {
7060 return mNode1->probeValueAndCache(ijk, v, *
this);
7061 }
else if (this->isCached2(dirty)) {
7062 return mNode2->probeValueAndCache(ijk, v, *
this);
7064 return mRoot->probeValueAndCache(ijk, v, *
this);
7069 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7070 const CoordValueType dirty = this->computeDirty(ijk);
7074 if (this->isCached1(dirty)) {
7075 return mNode1->probeLeafAndCache(ijk, *
this);
7076 }
else if (this->isCached2(dirty)) {
7077 return mNode2->probeLeafAndCache(ijk, *
this);
7079 return mRoot->probeLeafAndCache(ijk, *
this);
7081 #endif // NANOVDB_NEW_ACCESSOR_METHODS 7083 template<
typename RayT>
7086 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7087 const CoordValueType dirty = this->computeDirty(ijk);
7091 if (this->isCached1(dirty)) {
7092 return mNode1->getDimAndCache(ijk, ray, *
this);
7093 }
else if (this->isCached2(dirty)) {
7094 return mNode2->getDimAndCache(ijk, ray, *
this);
7096 return mRoot->getDimAndCache(ijk, ray, *
this);
7099 template<
typename OpT,
typename... ArgsT>
7102 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7103 const CoordValueType dirty = this->computeDirty(ijk);
7107 if (this->isCached1(dirty)) {
7108 return mNode1->template getAndCache<OpT>(ijk, *
this, args...);
7109 }
else if (this->isCached2(dirty)) {
7110 return mNode2->template getAndCache<OpT>(ijk, *
this, args...);
7112 return mRoot->template getAndCache<OpT>(ijk, *
this, args...);
7115 template<
typename OpT,
typename... ArgsT>
7118 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7119 const CoordValueType dirty = this->computeDirty(ijk);
7123 if (this->isCached1(dirty)) {
7124 return const_cast<Node1T*
>(mNode1)->
template setAndCache<OpT>(ijk, *
this, args...);
7125 }
else if (this->isCached2(dirty)) {
7126 return const_cast<Node2T*
>(mNode2)->
template setAndCache<OpT>(ijk, *
this, args...);
7128 return const_cast<RootT*
>(mRoot)->
template setAndCache<OpT>(ijk, *
this, args...);
7135 template<
typename, u
int32_t>
7137 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
7143 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7146 mKeys[0] = ijk & ~Node1T::MASK;
7152 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7155 mKeys[1] = ijk & ~Node2T::MASK;
7159 template<
typename OtherNodeT>
7164 template<
typename BuildT>
7180 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY // 44 bytes total 7181 mutable CoordT mKey;
7182 #else // 68 bytes total 7183 mutable CoordT mKeys[3];
7185 mutable const RootT* mRoot;
7186 mutable const void* mNode[3];
7193 static const int CacheLevels = 3;
7194 #ifndef NANOVDB_NEW_ACCESSOR_METHODS 7195 using NodeInfo =
typename ReadAccessor<ValueT, -1, -1, -1>::NodeInfo;
7199 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7205 , mNode{
nullptr,
nullptr,
nullptr}
7211 : ReadAccessor(grid.tree().root())
7217 : ReadAccessor(tree.root())
7231 template<
typename NodeT>
7236 return reinterpret_cast<const T*
>(mNode[NodeT::LEVEL]);
7243 static_assert(LEVEL >= 0 && LEVEL <= 2,
"ReadAccessor::getNode: Invalid node type");
7244 return reinterpret_cast<const T*
>(mNode[LEVEL]);
7250 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7255 mNode[0] = mNode[1] = mNode[2] =
nullptr;
7258 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7259 template<
typename NodeT>
7260 __hostdev__ bool isCached(CoordValueType dirty)
const 7262 if (!mNode[NodeT::LEVEL])
7264 if (dirty & int32_t(~NodeT::MASK)) {
7265 mNode[NodeT::LEVEL] =
nullptr;
7273 return (ijk[0] ^ mKey[0]) | (ijk[1] ^ mKey[1]) | (ijk[2] ^ mKey[2]);
7276 template<
typename NodeT>
7279 return (ijk[0] & int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL][0] &&
7280 (ijk[1] & int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL][1] &&
7281 (ijk[2] & int32_t(~NodeT::MASK)) == mKeys[NodeT::LEVEL][2];
7285 #ifdef NANOVDB_NEW_ACCESSOR_METHODS 7288 return this->
template get<GetValue<BuildT>>(ijk);
7297 #else // NANOVDB_NEW_ACCESSOR_METHODS 7301 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7302 const CoordValueType dirty = this->computeDirty(ijk);
7306 if (this->isCached<LeafT>(dirty)) {
7307 return ((
LeafT*)mNode[0])->getValue(ijk);
7308 }
else if (this->isCached<NodeT1>(dirty)) {
7309 return ((
NodeT1*)mNode[1])->getValueAndCache(ijk, *
this);
7310 }
else if (this->isCached<NodeT2>(dirty)) {
7311 return ((
NodeT2*)mNode[2])->getValueAndCache(ijk, *
this);
7313 return mRoot->getValueAndCache(ijk, *
this);
7317 return this->getValue(ijk);
7321 return this->getValue(
CoordType(i, j, k));
7325 return this->getValue(
CoordType(i, j, k));
7330 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7331 const CoordValueType dirty = this->computeDirty(ijk);
7335 if (this->isCached<LeafT>(dirty)) {
7336 return ((
LeafT*)mNode[0])->getNodeInfoAndCache(ijk, *
this);
7337 }
else if (this->isCached<NodeT1>(dirty)) {
7338 return ((
NodeT1*)mNode[1])->getNodeInfoAndCache(ijk, *
this);
7339 }
else if (this->isCached<NodeT2>(dirty)) {
7340 return ((
NodeT2*)mNode[2])->getNodeInfoAndCache(ijk, *
this);
7342 return mRoot->getNodeInfoAndCache(ijk, *
this);
7347 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7348 const CoordValueType dirty = this->computeDirty(ijk);
7352 if (this->isCached<LeafT>(dirty)) {
7353 return ((
LeafT*)mNode[0])->isActive(ijk);
7354 }
else if (this->isCached<NodeT1>(dirty)) {
7355 return ((
NodeT1*)mNode[1])->isActiveAndCache(ijk, *
this);
7356 }
else if (this->isCached<NodeT2>(dirty)) {
7357 return ((
NodeT2*)mNode[2])->isActiveAndCache(ijk, *
this);
7359 return mRoot->isActiveAndCache(ijk, *
this);
7364 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7365 const CoordValueType dirty = this->computeDirty(ijk);
7369 if (this->isCached<LeafT>(dirty)) {
7370 return ((
LeafT*)mNode[0])->probeValue(ijk, v);
7371 }
else if (this->isCached<NodeT1>(dirty)) {
7372 return ((
NodeT1*)mNode[1])->probeValueAndCache(ijk, v, *
this);
7373 }
else if (this->isCached<NodeT2>(dirty)) {
7374 return ((
NodeT2*)mNode[2])->probeValueAndCache(ijk, v, *
this);
7376 return mRoot->probeValueAndCache(ijk, v, *
this);
7380 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7381 const CoordValueType dirty = this->computeDirty(ijk);
7385 if (this->isCached<LeafT>(dirty)) {
7386 return ((
LeafT*)mNode[0]);
7387 }
else if (this->isCached<NodeT1>(dirty)) {
7388 return ((
NodeT1*)mNode[1])->probeLeafAndCache(ijk, *
this);
7389 }
else if (this->isCached<NodeT2>(dirty)) {
7390 return ((
NodeT2*)mNode[2])->probeLeafAndCache(ijk, *
this);
7392 return mRoot->probeLeafAndCache(ijk, *
this);
7394 #endif // NANOVDB_NEW_ACCESSOR_METHODS 7396 template<
typename OpT,
typename... ArgsT>
7399 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7400 const CoordValueType dirty = this->computeDirty(ijk);
7404 if (this->isCached<LeafT>(dirty)) {
7405 return ((
const LeafT*)mNode[0])->template getAndCache<OpT>(ijk, *
this, args...);
7406 }
else if (this->isCached<NodeT1>(dirty)) {
7407 return ((
const NodeT1*)mNode[1])->template getAndCache<OpT>(ijk, *
this, args...);
7408 }
else if (this->isCached<NodeT2>(dirty)) {
7409 return ((
const NodeT2*)mNode[2])->template getAndCache<OpT>(ijk, *
this, args...);
7411 return mRoot->template getAndCache<OpT>(ijk, *
this, args...);
7414 template<
typename OpT,
typename... ArgsT>
7417 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7418 const CoordValueType dirty = this->computeDirty(ijk);
7422 if (this->isCached<LeafT>(dirty)) {
7423 return ((
LeafT*)mNode[0])->template setAndCache<OpT>(ijk, *
this, args...);
7424 }
else if (this->isCached<NodeT1>(dirty)) {
7425 return ((
NodeT1*)mNode[1])->template setAndCache<OpT>(ijk, *
this, args...);
7426 }
else if (this->isCached<NodeT2>(dirty)) {
7427 return ((
NodeT2*)mNode[2])->template setAndCache<OpT>(ijk, *
this, args...);
7429 return ((
RootT*)mRoot)->template setAndCache<OpT>(ijk, *
this, args...);
7432 template<
typename RayT>
7435 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7436 const CoordValueType dirty = this->computeDirty(ijk);
7440 if (this->isCached<LeafT>(dirty)) {
7441 return ((
LeafT*)mNode[0])->getDimAndCache(ijk, ray, *
this);
7442 }
else if (this->isCached<NodeT1>(dirty)) {
7443 return ((
NodeT1*)mNode[1])->getDimAndCache(ijk, ray, *
this);
7444 }
else if (this->isCached<NodeT2>(dirty)) {
7445 return ((
NodeT2*)mNode[2])->getDimAndCache(ijk, ray, *
this);
7447 return mRoot->getDimAndCache(ijk, ray, *
this);
7454 template<
typename, u
int32_t>
7456 template<
typename,
typename,
template<u
int32_t>
class, uint32_t>
7460 template<
typename NodeT>
7463 #ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY 7466 mKeys[NodeT::LEVEL] = ijk & ~NodeT::MASK;
7468 mNode[NodeT::LEVEL] = node;
7486 template<
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
7492 template<
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
7498 template<
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
7515 uint32_t mRootTableSize, mPadding{0};
7518 template<
typename T>
7521 mGridData = *grid.
data();
7522 mTreeData = *grid.
tree().data();
7524 mRootTableSize = grid.
tree().root().getTableSize();
7528 static_assert(8 * 96 ==
sizeof(
GridMetaData),
"GridMetaData has unexpected size");
7532 mGridData = *gridData;
7551 template<
typename T>
7591 template<
typename AttT,
typename BuildT = u
int32_t>
7600 : AccT(grid.tree().root())
7602 , mData(grid.template getBlindData<AttT>(0))
7620 end = begin + count;
7628 auto* leaf = this->probeLeaf(ijk);
7629 if (leaf ==
nullptr) {
7632 begin = mData + leaf->minimum();
7633 end = begin + leaf->maximum();
7634 return leaf->maximum();
7640 begin = end =
nullptr;
7641 if (
auto* leaf = this->probeLeaf(ijk)) {
7643 if (leaf->isActive(offset)) {
7644 begin = mData + leaf->minimum();
7645 end = begin + leaf->getValue(offset);
7647 begin += leaf->getValue(offset - 1);
7654 template<
typename AttT>
7663 : AccT(grid.tree().root())
7665 , mData(grid.template getBlindData<AttT>(0))
7687 end = begin + count;
7695 auto* leaf = this->probeLeaf(ijk);
7696 if (leaf ==
nullptr)
7698 begin = mData + leaf->offset();
7699 end = begin + leaf->pointCount();
7700 return leaf->pointCount();
7706 if (
auto* leaf = this->probeLeaf(ijk)) {
7708 if (leaf->isActive(n)) {
7709 begin = mData + leaf->first(n);
7710 end = mData + leaf->last(n);
7714 begin = end =
nullptr;
7722 template<
typename ChannelT,
typename IndexT = ValueIndex>
7739 :
BaseT(grid.tree().root())
7745 this->setChannel(channelID);
7750 :
BaseT(grid.tree().root())
7752 , mChannel(channelPtr)
7783 return mChannel =
const_cast<ChannelT*
>(mGrid.template getBlindData<ChannelT>(channelID));
7799 const bool isActive = BaseT::probeValue(ijk, idx);
7806 template<
typename T>
7815 struct MiniGridHandle {
7820 BufferType(BufferType &&other) : data(other.data), size(other.size) {other.data=
nullptr; other.size=0;}
7821 ~BufferType() {std::free(data);}
7822 BufferType& operator=(
const BufferType &other) =
delete;
7823 BufferType& operator=(BufferType &&other){data=other.data; size=other.size; other.data=
nullptr; other.size=0;
return *
this;}
7824 static BufferType create(
size_t n, BufferType* dummy =
nullptr) {
return BufferType(n);}
7826 MiniGridHandle(BufferType &&buf) : buffer(std::move(buf)) {}
7827 const uint8_t* data()
const {
return buffer.data;}
7882 uint32_t nodeCount[4];
7883 uint32_t tileCount[3];
7890 #if !defined(__CUDA_ARCH__) && !defined(__HIP__) 7894 static const char * LUT[] = {
"NONE",
"ZIP",
"BLOSC" ,
"END" };
7895 static_assert(
sizeof(LUT) /
sizeof(
char*) - 1 ==
int(Codec::END),
"Unexpected size of LUT");
7896 return LUT[
static_cast<int>(codec)];
7920 template<
typename StreamT>
7926 #ifdef NANOVDB_USE_NEW_MAGIC_NUMBERS 7931 const char* gridName = gridData->
gridName();
7932 uint32_t nameSize = 1;
7933 for (
const char* p = gridName; *p !=
'\0'; ++p) ++nameSize;
7941 os.write((
const char*)&head,
sizeof(
FileHeader));
7943 os.write(gridName, nameSize);
7945 os.write((
const char*)gridData, gridData->
mGridSize);
7950 template<
typename GridHandleT,
template<
typename...>
class VecT>
7953 #ifdef NANOVDB_USE_IOSTREAMS // use this to switch between std::ofstream or FILE implementations 7954 std::ofstream os(fileName, std::ios::out | std::ios::binary | std::ios::trunc);
7958 StreamT(
const char* name) { fptr = fopen(name,
"wb"); }
7959 ~StreamT() { fclose(fptr); }
7960 void write(
const char* data,
size_t n) { fwrite(data, 1, n, fptr); }
7961 bool is_open()
const {
return fptr != NULL; }
7964 if (!os.is_open()) {
7965 fprintf(stderr,
"nanovdb::writeUncompressedGrids: Unable to open file \"%s\"for output\n", fileName);
7968 for (
auto& h : handles) {
7978 template<
typename GridHandleT,
typename StreamT,
template<
typename...>
class VecT>
7979 VecT<GridHandleT>
readUncompressedGrids(StreamT& is,
const typename GridHandleT::BufferType& pool =
typename GridHandleT::BufferType())
7981 VecT<GridHandleT> handles;
7983 is.read((
char*)&data, 40);
7985 uint64_t size = data.
mGridSize, sum = 0u;
7988 is.read((
char*)&data, 40);
7991 is.skip(-int64_t(sum + 40));
7992 auto buffer = GridHandleT::BufferType::create(size + sum, &pool);
7993 is.read((
char*)(buffer.data()), buffer.size());
7994 handles.emplace_back(std::move(buffer));
7998 while(is.read((
char*)&head,
sizeof(
FileHeader))) {
8000 fprintf(stderr,
"nanovdb::readUncompressedGrids: invalid magic number = \"%s\"\n", (
const char*)&(head.
magic));
8003 fprintf(stderr,
"nanovdb::readUncompressedGrids: invalid major version = \"%s\"\n", head.
version.
c_str());
8006 fprintf(stderr,
"nanovdb::readUncompressedGrids: invalid codec = \"%s\"\n",
toStr(head.
codec));
8010 for (uint16_t i = 0; i < head.
gridCount; ++i) {
8013 auto buffer = GridHandleT::BufferType::create(meta.
gridSize, &pool);
8014 is.read((
char*)buffer.data(), meta.
gridSize);
8015 handles.emplace_back(std::move(buffer));
8023 template<
typename GridHandleT,
template<
typename...>
class VecT>
8024 VecT<GridHandleT>
readUncompressedGrids(
const char* fileName,
const typename GridHandleT::BufferType& buffer =
typename GridHandleT::BufferType())
8026 #ifdef NANOVDB_USE_IOSTREAMS // use this to switch between std::ifstream or FILE implementations 8027 struct StreamT :
public std::ifstream {
8028 StreamT(
const char* name) : std::ifstream(name, std::ios::in | std::ios::binary){}
8029 void skip(int64_t off) { this->seekg(off, std::ios_base::cur); }
8034 StreamT(
const char* name) { fptr = fopen(name,
"rb"); }
8035 ~StreamT() { fclose(fptr); }
8036 bool read(
char* data,
size_t n) {
8037 size_t m = fread(data, 1, n, fptr);
8040 void skip(int64_t off) { fseek(fptr, (
long int)off, SEEK_CUR); }
8041 bool is_open()
const {
return fptr != NULL; }
8044 StreamT is(fileName);
8045 if (!is.is_open()) {
8046 fprintf(stderr,
"nanovdb::readUncompressedGrids: Unable to open file \"%s\"for input\n", fileName);
8049 return readUncompressedGrids<GridHandleT, StreamT, VecT>(is, buffer);
8052 #endif // if !defined(__CUDA_ARCH__) && !defined(__HIP__) 8061 template<
typename BuildT>
8071 template<
typename BuildT>
8083 template<
typename BuildT>
8097 template<
typename BuildT>
8109 template<
typename BuildT>
8121 template<
typename BuildT>
8133 template<
typename BuildT>
8145 template<
typename BuildT>
8157 template<
typename BuildT>
8163 v = root.mBackground;
8169 return tile.state > 0u;
8173 v = node.mTable[n].value;
8174 return node.mValueMask.isOn(n);
8178 v = node.mTable[n].value;
8179 return node.mValueMask.isOn(n);
8183 v = leaf.getValue(n);
8184 return leaf.mValueMask.isOn(n);
8190 template<
typename BuildT>
8212 return NodeInfo{2u, node.
dim(), node.minimum(), node.maximum(), node.average(), node.stdDeviation(), node.bbox()};
8216 return NodeInfo{1u, node.
dim(), node.minimum(), node.maximum(), node.average(), node.stdDeviation(), node.bbox()};
8220 return NodeInfo{0u, leaf.
dim(), leaf.minimum(), leaf.maximum(), leaf.average(), leaf.stdDeviation(), leaf.bbox()};
8226 #endif // end of NANOVDB_NANOVDB_H_HAS_BEEN_INCLUDED typename FloatTraits< BuildT >::FloatType FloatType
Definition: NanoVDB.h:5439
bool operator==(const Vec3 &rhs) const
Definition: NanoVDB.h:1561
void setAvg(const FloatType &)
Definition: NanoVDB.h:5820
ValueOffIterator beginValueOff() const
Definition: NanoVDB.h:6110
Map(double s, const Vec3d &t=Vec3d(0.0, 0.0, 0.0))
Definition: NanoVDB.h:3180
Vec3T applyInverseMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:3601
typename BuildT::RootType RootType
Definition: NanoVDB.h:3702
int32_t ValueType
Definition: NanoVDB.h:1305
ValueT ValueType
Definition: NanoVDB.h:6708
static size_t memUsage(uint32_t bitWidth)
Definition: NanoVDB.h:5688
bool type
Definition: NanoVDB.h:689
Visits all tile values in this node, i.e. both inactive and active tiles.
Definition: NanoVDB.h:5038
T lengthSqr() const
Definition: NanoVDB.h:1772
const ValueT & getMin() const
Definition: NanoVDB.h:4308
void setOrigin(const T &ijk)
Definition: NanoVDB.h:5865
CoordType getCoord() const
Definition: NanoVDB.h:4376
uint16_t ArrayType
Definition: NanoVDB.h:5964
bool operator==(const Coord &rhs) const
Definition: NanoVDB.h:1394
static uint32_t CoordToOffset(const CoordT &ijk)
Return the linear offset corresponding to the given coordinate.
Definition: NanoVDB.h:6297
FloatType mStdDevi
Definition: NanoVDB.h:5451
bool empty() const
Definition: NanoVDB.h:2333
float type
Definition: NanoVDB.h:696
Trait use to remove reference, i.e. "&", qualifier from a type. Default implementation is just a pass...
Definition: NanoVDB.h:581
void writeUncompressedGrids(const char *fileName, const VecT< GridHandleT > &handles, bool raw=false)
write multiple NanoVDB grids to a single file, without compression.
Definition: NanoVDB.h:7951
const RootT & root() const
Definition: NanoVDB.h:7221
bool isEmpty() const
test if the grid is empty, e.i the root table has size 0
Definition: NanoVDB.h:3679
ValueType minimum() const
Return a const reference to the minimum active value encoded in this leaf node.
Definition: NanoVDB.h:6182
typename RootType::LeafNodeType LeafNodeType
Definition: NanoVDB.h:4002
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel.
Definition: NanoVDB.h:4632
ValueType maximum() const
Return a const reference to the maximum active value encoded in this leaf node.
Definition: NanoVDB.h:6185
StatsT mStdDevi
Definition: NanoVDB.h:4886
const RootT & root() const
Definition: NanoVDB.h:4033
const Vec3T & min() const
Definition: NanoVDB.h:2241
static bool hasStats()
Definition: NanoVDB.h:5463
Vec3(T x)
Definition: NanoVDB.h:1538
ValueType getValue(const CoordT &ijk) const
Return the voxel value at the given coordinate.
Definition: NanoVDB.h:6254
static BBox createCube(const CoordT &min, typename CoordT::ValueType dim)
Definition: NanoVDB.h:2441
static bool isAligned(const void *p)
return true if the specified pointer is aligned
Definition: NanoVDB.h:737
GridClass mapToGridClass(GridClass defaultClass=GridClass::Unknown)
Maps from a templated build type to a GridClass enum.
Definition: NanoVDB.h:2110
Definition: IndexIterator.h:42
BBox(BBox &other, const SplitT &)
Definition: NanoVDB.h:2432
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition: NanoVDB.h:5527
bool operator!=(const Iterator &rhs) const
Definition: NanoVDB.h:2401
FloatType variance() const
Return the variance of all the active values encoded in this leaf node.
Definition: NanoVDB.h:6191
static float value()
Definition: NanoVDB.h:1039
ChildIter(RootT *parent)
Definition: NanoVDB.h:4395
uint32_t operator*() const
Definition: NanoVDB.h:2900
Vec3T applyJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:3592
void setBitOn(std::initializer_list< uint8_t > list)
Definition: NanoVDB.h:2752
uint32_t countOn(uint32_t i) const
Return the number of lower set bits in mask up to but excluding the i'th bit.
Definition: NanoVDB.h:2849
int age() const
Check the major version of this instance relative to NANOVDB_MAJOR_VERSION_NUMBER.
Definition: NanoVDB.h:978
Tile * tile(uint32_t n)
Definition: NanoVDB.h:4258
ValueType operator*() const
Definition: NanoVDB.h:6065
void setDev(float dev)
Definition: NanoVDB.h:5562
uint64_t lastOffset() const
Definition: NanoVDB.h:5880
Vec3T indexToWorldF(const Vec3T &xyz) const
index to world space transformation
Definition: NanoVDB.h:3796
const StatsT & average() const
Definition: NanoVDB.h:4944
Coord & operator+=(const Coord &rhs)
Definition: NanoVDB.h:1427
bool probeValue(const CoordType &ijk, ValueType &v) const
return the state and updates the value of the specified voxel
Definition: NanoVDB.h:5219
VDB Tree, which is a thin wrapper around a RootNode.
Definition: NanoVDB.h:3989
decltype(mFlags) Type
Definition: NanoVDB.h:2714
void setOrigin(const T &ijk)
Definition: NanoVDB.h:6010
uint8_t * getRoot()
Definition: NanoVDB.h:3954
const MaskType< LOG2DIM > & valueMask() const
Return a const reference to the bit mask of active voxels in this internal node.
Definition: NanoVDB.h:5172
ChildIter operator++(int)
Definition: NanoVDB.h:4420
static BBox createCube(typename CoordT::ValueType min, typename CoordT::ValueType max)
Definition: NanoVDB.h:2446
FloatType getDev() const
Definition: NanoVDB.h:5477
bool getMin() const
Definition: NanoVDB.h:5759
Vec3(const Vec3T< T2 > &v)
Definition: NanoVDB.h:1547
ValueT getValue(uint32_t n) const
Definition: NanoVDB.h:4925
void setOn()
Set all bits on.
Definition: NanoVDB.h:3039
CoordT getCoord() const
Definition: NanoVDB.h:6137
float Type
Definition: NanoVDB.h:716
static uint64_t alignmentPadding(const void *p)
return the smallest number of bytes that when added to the specified pointer results in an aligned po...
Definition: NanoVDB.h:749
float FloatType
Definition: NanoVDB.h:5509
Highest level of the data structure. Contains a tree and a world->index transform (that currently onl...
Definition: NanoVDB.h:3698
T lengthSqr() const
Definition: NanoVDB.h:1583
Vec3 & normalize()
Definition: NanoVDB.h:1633
auto getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:7293
DataType * data()
Definition: NanoVDB.h:4589
Vec4 & normalize()
Definition: NanoVDB.h:1809
Vec4(T x, T y, T z, T w)
Definition: NanoVDB.h:1740
Vec4 & operator-=(const Vec4 &v)
Definition: NanoVDB.h:1792
DenseIterator beginDense() const
Definition: NanoVDB.h:5152
Vec3T applyMapF(const Vec3T &ijk) const
Apply the forward affine transformation to a vector using 32bit floating point arithmetics.
Definition: NanoVDB.h:3220
uint32_t findFirst() const
Definition: NanoVDB.h:3107
ValueType operator()(const CoordType &ijk) const
Definition: NanoVDB.h:6609
void setOn(uint32_t offset)
Definition: NanoVDB.h:5817
FloatType stdDevi
Definition: NanoVDB.h:8199
typename Vec3T::ValueType ValueType
Definition: NanoVDB.h:2305
void setMaskOn(MaskT mask)
Definition: NanoVDB.h:2764
bool isOff() const
Return true if none of the bits are set in this Mask.
Definition: NanoVDB.h:2998
const ValueType & operator[](IndexType i) const
Return a const reference to the given Coord component.
Definition: NanoVDB.h:1347
void setDev(const StatsT &v)
Definition: NanoVDB.h:4316
const BBox< Vec3d > & worldBBox() const
return AABB of active values in world space
Definition: NanoVDB.h:3664
#define NANOVDB_PATCH_VERSION_NUMBER
Definition: NanoVDB.h:135
const RootT & root() const
Definition: NanoVDB.h:6742
bool isBreadthFirst() const
Definition: NanoVDB.h:3842
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:3847
static constexpr uint64_t memUsage()
Definition: NanoVDB.h:5583
uint64_t activeVoxelCount() const
Return a const reference to the index bounding box of all the active values in this tree...
Definition: NanoVDB.h:4065
T Sign(const T &x)
Return the sign of the given value as an integer (either -1, 0 or 1).
Definition: NanoVDB.h:1245
DenseIterator(const InternalNode *parent)
Definition: NanoVDB.h:5122
const ValueType & background() const
Return the total number of active voxels in the root and all its child nodes.
Definition: NanoVDB.h:4600
Rgba8(uint8_t v)
ctor where all channels are initialized to the same value
Definition: NanoVDB.h:1901
Metafunction used to determine if the first template parameter is a specialization of the class templ...
Definition: NanoVDB.h:637
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:6766
uint32_t operator*() const
Definition: NanoVDB.h:2872
Trait used to transfer the const-ness of a reference type to another type.
Definition: NanoVDB.h:611
static uint32_t dim()
Definition: NanoVDB.h:6033
bool getDev() const
Definition: NanoVDB.h:5815
Class to access values in channels at a specific voxel location.
Definition: NanoVDB.h:7723
Vec3T worldToIndexDir(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition: NanoVDB.h:3783
static float value()
Definition: NanoVDB.h:1023
const ValueT & getMax() const
Definition: NanoVDB.h:4943
Mask(bool on)
Definition: NanoVDB.h:2934
Vec4(const Vec4< T2 > &v)
Definition: NanoVDB.h:1745
bool isFogVolume() const
Definition: NanoVDB.h:3830
typename GridT::TreeType Type
Definition: NanoVDB.h:3975
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:5186
char mGridName[MaxNameSize]
Definition: NanoVDB.h:3521
Coord operator+(const Coord &rhs) const
Definition: NanoVDB.h:1424
const uint8_t * getRoot() const
Definition: NanoVDB.h:3955
Type getFlags() const
Definition: NanoVDB.h:2744
static uint32_t CoordToOffset(const CoordType &ijk)
Return the linear offset corresponding to the given coordinate.
Definition: NanoVDB.h:5262
Version version() const
Definition: NanoVDB.h:3720
bool isFloatingPointVector(GridType gridType)
return true if the GridType maps to a floating point vec3.
Definition: NanoVDB.h:831
PointAccessor(const NanoGrid< Point > &grid)
Definition: NanoVDB.h:7662
Vec3T indexToWorldGradF(const Vec3T &grad) const
Transforms the gradient from index space to world space.
Definition: NanoVDB.h:3811
typename ChildT::CoordType CoordType
Definition: NanoVDB.h:4977
MaskT< LOG2DIM > mMask
Definition: NanoVDB.h:5937
GridClass
Classes (superset of OpenVDB) that are currently supported by NanoVDB.
Definition: NanoVDB.h:362
typename DataType::ValueT ValueType
Definition: NanoVDB.h:4339
bool updateBBox()
Updates the local bounding box of active voxels in this node. Return true if bbox was updated...
Definition: NanoVDB.h:6400
Vec3 operator*(const Vec3 &v) const
Definition: NanoVDB.h:1589
static T scalar(const T &s)
Definition: NanoVDB.h:1976
Vec3T indexToWorldDirF(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition: NanoVDB.h:3801
Vec3T applyJacobianF(const Vec3T &ijk) const
Apply the linear forward 3x3 transformation to an input 3d vector using 32bit floating point arithmet...
Definition: NanoVDB.h:3238
typename RootT::BuildType BuildType
Definition: NanoVDB.h:4004
void setBitOff(uint8_t bit)
Definition: NanoVDB.h:2750
const uint32_t & packed() const
Definition: NanoVDB.h:1943
void setMask(uint32_t offset, bool v)
Definition: NanoVDB.h:5940
Definition: NanoVDB.h:4435
ValueType min() const
Return the smallest vector component.
Definition: NanoVDB.h:1658
ValueType operator*() const
Definition: NanoVDB.h:4500
uint32_t state
Definition: NanoVDB.h:4246
void setAvg(const FloatType &)
Definition: NanoVDB.h:6006
BuildT BuildType
Definition: NanoVDB.h:5438
CoordT mBBoxMin
Definition: NanoVDB.h:5798
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:4047
typename UpperNodeType::ChildNodeType LowerNodeType
Definition: NanoVDB.h:4001
Return the pointer to the leaf node that contains Coord. Implements Tree::probeLeaf(Coord) ...
Definition: NanoVDB.h:3479
Vec3 operator+(const Vec3 &v) const
Definition: NanoVDB.h:1591
const MaskType< LOG2DIM > & getChildMask() const
Definition: NanoVDB.h:5177
bool isInside(const Vec3T &p) const
Definition: NanoVDB.h:2340
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:5183
typename match_const< DataType, RootT >::type DataT
Definition: NanoVDB.h:4355
const GridBlindMetaData * blindMetaData(uint32_t n) const
Returns a const reference to the blindMetaData at the specified linear offset.
Definition: NanoVDB.h:3638
bool hasBBox() const
Definition: NanoVDB.h:6284
uint8_t mFlags
Definition: NanoVDB.h:5445
ChildIterator beginChild()
Definition: NanoVDB.h:5034
uint64_t mOffset
Definition: NanoVDB.h:5972
static uint64_t memUsage(uint32_t tableSize)
Return the expected memory footprint in bytes with the specified number of tiles. ...
Definition: NanoVDB.h:4622
Vec3T applyInverseJacobian(const Vec3T &xyz) const
Definition: NanoVDB.h:3594
static constexpr uint32_t padding()
Definition: NanoVDB.h:5851
Trait use to remove pointer, i.e. "*", qualifier from a type. Default implementation is just a pass-t...
Definition: NanoVDB.h:595
ValueType getFirstValue() const
Return the first value in this leaf node.
Definition: NanoVDB.h:6257
Definition: NanoVDB.h:3688
LeafNodeType Node0
Definition: NanoVDB.h:4011
static constexpr uint32_t padding()
Definition: NanoVDB.h:5584
ValueType operator()(const CoordType &ijk) const
Definition: NanoVDB.h:7291
uint64_t idx(int i, int j, int k) const
Definition: NanoVDB.h:7788
bool hasStats() const
Definition: NanoVDB.h:5856
void setMin(const ValueT &v)
Definition: NanoVDB.h:4313
Return point to the upper internal node where Coord maps to one of its values, i.e. terminates.
Definition: NanoVDB.h:8146
typename DataType::StatsT FloatType
Definition: NanoVDB.h:4340
Vec3 cross(const Vec3T &v) const
Definition: NanoVDB.h:1577
bool isLevelSet() const
Definition: NanoVDB.h:3829
Implements Tree::getValue(Coord), i.e. return the value associated with a specific coordinate ijk...
Definition: NanoVDB.h:3469
ValueType & operator[](IndexType i)
Return a non-const reference to the given Coord component.
Definition: NanoVDB.h:1351
const DataType * data() const
Definition: NanoVDB.h:6175
ValueType operator*() const
Definition: NanoVDB.h:5055
BitFlags()
Definition: NanoVDB.h:2715
ChildT ChildNodeType
Definition: NanoVDB.h:4333
static constexpr uint32_t padding()
Definition: NanoVDB.h:5806
#define NANOVDB_MAGIC_GRID
Definition: NanoVDB.h:127
void set(const MatT &mat, const MatT &invMat, const Vec3T &translate, double taper=1.0)
Initialize the member data from 3x3 or 4x4 matrices.
Definition: NanoVDB.h:3296
Vec4 operator*(const Vec4 &v) const
Definition: NanoVDB.h:1778
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:6993
ChildIter(ParentT *parent)
Definition: NanoVDB.h:5007
bool is_divisible() const
Definition: NanoVDB.h:2451
BaseBBox()
Definition: NanoVDB.h:2287
uint64_t memUsage() const
Return the actual memory footprint of this root node.
Definition: NanoVDB.h:4625
Vec4 & operator/=(const T &s)
Definition: NanoVDB.h:1808
MaskT< LOG2DIM > ArrayType
Definition: NanoVDB.h:5745
BitFlags(std::initializer_list< uint8_t > list)
Definition: NanoVDB.h:2716
T Type
Definition: NanoVDB.h:653
void setMin(const ValueType &)
Definition: NanoVDB.h:6004
uint64_t mMagic
Definition: NanoVDB.h:3514
void setBBoxOn(bool on=true)
Definition: NanoVDB.h:3573
uint64_t mGridSize
Definition: NanoVDB.h:3520
void setOrigin(const T &ijk)
Definition: NanoVDB.h:4940
Vec3 operator+(const Coord &ijk) const
Definition: NanoVDB.h:1593
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:7296
NodeT * probeChild(ValueType &value) const
Definition: NanoVDB.h:4543
Vec3 operator/(const Vec3 &v) const
Definition: NanoVDB.h:1590
RootT Node3
Definition: NanoVDB.h:4008
bool isCompatible() const
Definition: NanoVDB.h:974
Trait to map from LEVEL to node type.
Definition: NanoVDB.h:6453
CoordType getOrigin() const
Definition: NanoVDB.h:5060
Vec3T & min()
Definition: NanoVDB.h:2239
ValueType operator()(int i, int j, int k) const
Definition: NanoVDB.h:7292
Rgba8(float r, float g, float b, float a=1.0f)
floating-point r,g,b,a ctor where alpha channel defaults to opaque
Definition: NanoVDB.h:1908
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:4162
const LeafNodeType * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:4637
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:4616
bool probeValue(const CoordType &ijk, ValueType &v) const
Return true if this tree is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:4053
#define NANOVDB_MINOR_VERSION_NUMBER
Definition: NanoVDB.h:134
bool operator<(const Coord &rhs) const
Return true if this Coord is lexicographically less than the given Coord.
Definition: NanoVDB.h:1374
CoordType getOrigin() const
Definition: NanoVDB.h:5099
A simple vector class with four components, similar to openvdb::math::Vec4.
Definition: NanoVDB.h:1727
CoordT RoundDown(const Vec3T< RealT > &xyz)
Definition: NanoVDB.h:1226
ValueIter & operator++()
Definition: NanoVDB.h:4461
uint64_t KeyT
Return a key based on the coordinates of a voxel.
Definition: NanoVDB.h:4184
Vec3d mVoxelSize
Definition: NanoVDB.h:3524
void setValueOnly(const CoordT &ijk, const ValueType &v)
Definition: NanoVDB.h:6270
void setOn(uint32_t n)
Set the specified bit on.
Definition: NanoVDB.h:3007
const NodeT * getFirstNode() const
return a const pointer to the first node of the specified type
Definition: NanoVDB.h:4110
const uint8_t & r() const
Definition: NanoVDB.h:1945
bool isActive(uint32_t n) const
Definition: NanoVDB.h:4931
BuildT ValueType
Definition: NanoVDB.h:5437
uint64_t mFlags
Definition: NanoVDB.h:4879
bool isMask() const
Definition: NanoVDB.h:3835
int findBlindData(const char *name) const
Return the index of the first blind data with specified name if found, otherwise -1.
Definition: NanoVDB.h:3920
const LeafNodeType * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:5220
ReadAccessor(const GridT &grid)
Constructor from a grid.
Definition: NanoVDB.h:7210
MatType scale(const Vec3< typename MatType::value_type > &s)
Return a matrix that scales by s.
Definition: Mat.h:615
auto getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:6990
T type
Definition: NanoVDB.h:563
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition: NanoVDB.h:4218
Implements Tree::getNodeInfo(Coord)
Definition: NanoVDB.h:3483
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:2576
Rgba8()
Default ctor initializes all channels to zero.
Definition: NanoVDB.h:1886
const CoordT & operator*() const
Definition: NanoVDB.h:2418
Tile * probeTile(const CoordT &ijk)
Definition: NanoVDB.h:4264
static fileSize_t write(std::ostream &os, const GridHandle< BufferT > &handle, Codec codec, uint32_t n)
bool operator>=(const Version &rhs) const
Definition: NanoVDB.h:969
uint64_t getAvg() const
Definition: NanoVDB.h:5884
int32_t z() const
Definition: NanoVDB.h:1333
CoordT getCoord() const
Definition: NanoVDB.h:6070
ValueType minimum
Definition: NanoVDB.h:8198
ChildT UpperNodeType
Definition: NanoVDB.h:4336
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:6991
uint32_t mGridCount
Definition: NanoVDB.h:3519
uint64_t getAvg() const
Definition: NanoVDB.h:5910
CoordT mBBoxMin
Definition: NanoVDB.h:5443
const char * gridName() const
Definition: NanoVDB.h:3644
BBox(const Coord &min, const Coord &max)
Definition: NanoVDB.h:2319
Vec3T applyIJTF(const Vec3T &xyz) const
Definition: NanoVDB.h:3289
uint64_t FloatType
Definition: NanoVDB.h:2019
uint8_t & r()
Definition: NanoVDB.h:1949
const MaskType< LOG2DIM > & childMask() const
Return a const reference to the bit mask of child nodes in this internal node.
Definition: NanoVDB.h:5176
void setAverageOn(bool on=true)
Definition: NanoVDB.h:3575
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:5590
ValueIterator beginValue()
Definition: NanoVDB.h:4480
BBox expandBy(typename CoordT::ValueType padding) const
Return a new instance that is expanded by the specified padding.
Definition: NanoVDB.h:2490
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel (regardless of state or location in the tree.) ...
Definition: NanoVDB.h:4043
const TreeT & tree() const
Return a const reference to the tree.
Definition: NanoVDB.h:3753
ValueType operator*() const
Definition: NanoVDB.h:6098
Definition: NanoVDB.h:8195
typename GridOrTreeOrRootT::RootNodeType::ChildNodeType::ChildNodeType type
Definition: NanoVDB.h:3427
uint64_t FloatType
Definition: NanoVDB.h:2013
ValueIter(RootT *parent)
Definition: NanoVDB.h:4444
NodeT * getFirstNode()
return a pointer to the first node of the specified type
Definition: NanoVDB.h:4100
float mQuantum
Definition: NanoVDB.h:5517
double FloatType
Definition: NanoVDB.h:2043
const T & operator[](int i) const
Definition: NanoVDB.h:1768
Iterator & operator++()
Definition: NanoVDB.h:2875
bool isPointIndex() const
Definition: NanoVDB.h:3832
BBox(const Vec3T &min, const Vec3T &max)
Definition: NanoVDB.h:2315
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:7683
Vec3(const Coord &ijk)
Definition: NanoVDB.h:1557
Map mMap
Definition: NanoVDB.h:3522
void setValue(uint32_t n, const ValueT &v)
Definition: NanoVDB.h:4907
#define NANOVDB_MAGIC_FILE
Definition: NanoVDB.h:128
ValueIterator(const InternalNode *parent)
Definition: NanoVDB.h:5049
float type
Definition: NanoVDB.h:710
TreeT & tree()
Return a non-const reference to the tree.
Definition: NanoVDB.h:3756
GridType mapToGridType()
Maps from a templated build type to a GridType enum.
Definition: NanoVDB.h:2050
static uint64_t memUsage()
Definition: NanoVDB.h:5461
#define __device__
Definition: NanoVDB.h:219
typename ChildT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:4338
Bit-compacted representation of all three version numbers.
Definition: NanoVDB.h:947
int32_t x() const
Definition: NanoVDB.h:1331
ValueType getMax() const
Definition: NanoVDB.h:6000
ReadAccessor(const TreeT &tree)
Constructor from a tree.
Definition: NanoVDB.h:6730
BBox< Vec3< RealT > > asReal() const
Definition: NanoVDB.h:2483
DataType * data()
Definition: NanoVDB.h:4019
bool isOn() const
Return true if all the bits are set in this Mask.
Definition: NanoVDB.h:2989
bool isValueOn() const
Definition: NanoVDB.h:4555
Type Max(Type a, Type b)
Definition: NanoVDB.h:1110
typename DataType::ValueT ValueType
Definition: NanoVDB.h:4972
const StatsT & stdDeviation() const
Definition: NanoVDB.h:4945
typename GridOrTreeOrRootT::LeafNodeType Type
Definition: NanoVDB.h:3411
Coord operator>>(IndexType n) const
Definition: NanoVDB.h:1371
T ValueType
Definition: NanoVDB.h:1734
static constexpr uint32_t padding()
Definition: NanoVDB.h:5620
Definition: NanoVDB.h:4867
const Vec3d & voxelSize() const
Return a vector of the axial voxel sizes.
Definition: NanoVDB.h:7768
const MaskType< LOG2DIM > & getValueMask() const
Definition: NanoVDB.h:6179
void setAvg(const bool &)
Definition: NanoVDB.h:5771
Vec3(const Vec3< T2 > &v)
Definition: NanoVDB.h:1553
bool isStaggered() const
Definition: NanoVDB.h:3831
static uint64_t memUsage()
return memory usage in bytes for the class
Definition: NanoVDB.h:4024
CoordT offsetToGlobalCoord(uint32_t n) const
Definition: NanoVDB.h:6214
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:1288
void setMin(const ValueType &)
Definition: NanoVDB.h:5859
Type Min(Type a, Type b)
Definition: NanoVDB.h:1089
static constexpr uint32_t SIZE
Definition: NanoVDB.h:2827
uint32_t mNodeCount[3]
Definition: NanoVDB.h:3943
BaseBBox & intersect(const BaseBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition: NanoVDB.h:2266
ValueIterator cbeginValueAll() const
Definition: NanoVDB.h:6162
void setMin(float min)
Definition: NanoVDB.h:5553
ValueType mMaximum
Definition: NanoVDB.h:5449
Coord round() const
Round each component if this Vec<T> to its closest integer value.
Definition: NanoVDB.h:1675
BaseBBox(const Vec3T &min, const Vec3T &max)
Definition: NanoVDB.h:2288
typename GridOrTreeOrRootT::LeafNodeType type
Definition: NanoVDB.h:3412
uint64_t * words()
Return a pointer to the list of words of the bit mask.
Definition: NanoVDB.h:2949
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:5801
Trait use to const from type. Default implementation is just a pass-through.
Definition: NanoVDB.h:561
Coord operator&(IndexType n) const
Return a new instance with coordinates masked by the given unsigned integer.
Definition: NanoVDB.h:1365
void init(float min, float max, uint8_t bitWidth)
Definition: NanoVDB.h:5531
const T & operator[](int i) const
Definition: NanoVDB.h:1572
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel.
Definition: NanoVDB.h:5216
bool isActive(const CoordT &ijk) const
Return true if the voxel value at the given coordinate is active.
Definition: NanoVDB.h:6273
const NodeT * getNode() const
Return a const point to the cached node of the specified type.
Definition: NanoVDB.h:7232
typename DataType::BuildT BuildType
Definition: NanoVDB.h:4341
bool isPointData() const
Definition: NanoVDB.h:3834
void setMin(const bool &)
Definition: NanoVDB.h:5769
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:7433
uint64_t activeVoxelCount() const
Computes a AABB of active values in world space.
Definition: NanoVDB.h:3823
void setValue(uint32_t offset, const ValueType &value)
Definition: NanoVDB.h:5467
Vec3T worldToIndexF(const Vec3T &xyz) const
world to index space transformation
Definition: NanoVDB.h:3792
bool operator!=(const Mask &other) const
Definition: NanoVDB.h:2980
Vec3T matMult(const float *mat, const Vec3T &xyz)
Multiply a 3x3 matrix and a 3d vector using 32bit floating point arithmetics.
Definition: NanoVDB.h:2133
int32_t Ceil(float x)
Definition: NanoVDB.h:1158
ConstDenseIterator cbeginChildAll() const
Definition: NanoVDB.h:4579
void initBit(std::initializer_list< uint8_t > list)
Definition: NanoVDB.h:2729
uint64_t getMin() const
Definition: NanoVDB.h:5882
void setMin(const ValueType &v)
Definition: NanoVDB.h:5479
ReadAccessor(const TreeT &tree)
Constructor from a tree.
Definition: NanoVDB.h:7216
bool FloatType
Definition: NanoVDB.h:2007
bool isMaskOff(std::initializer_list< MaskT > list) const
return true if any of the masks in the list are off
Definition: NanoVDB.h:2804
void setStdDeviationOn(bool on=true)
Definition: NanoVDB.h:3576
Definition: NanoVDB.h:1993
typename DataType::FloatType FloatType
Definition: NanoVDB.h:6038
#define NANOVDB_DATA_ALIGNMENT
Definition: NanoVDB.h:154
Vec3T applyInverseMap(const Vec3T &xyz) const
Definition: NanoVDB.h:3590
typename DataType::Tile Tile
Definition: NanoVDB.h:4346
Map()
Default constructor for the identity map.
Definition: NanoVDB.h:3169
static uint64_t memUsage()
Return memory usage in bytes for this class only.
Definition: NanoVDB.h:3661
const RootT & root() const
Definition: NanoVDB.h:6935
Definition: NanoVDB.h:2708
const T * asPointer() const
return a const raw constant pointer to array of three vector components
Definition: NanoVDB.h:1689
ValueType operator()(int i, int j, int k) const
Definition: NanoVDB.h:6610
Trait used to identify template parameter that are pointers.
Definition: NanoVDB.h:534
DataType * data()
Definition: NanoVDB.h:5161
bool isBitOff(uint8_t bit) const
Definition: NanoVDB.h:2788
bool getValue(uint32_t i) const
Definition: NanoVDB.h:5811
bool isChild(uint32_t n) const
Definition: NanoVDB.h:4937
bool isInside(const Vec3T &xyz)
Definition: NanoVDB.h:2277
Dummy type for a 16bit quantization of float point values.
Definition: NanoVDB.h:292
CoordType getCoord() const
Definition: NanoVDB.h:5065
uint8_t ArrayType
Definition: NanoVDB.h:5616
float asFloat(int n) const
return n'th color channel as a float in the range 0 to 1
Definition: NanoVDB.h:1940
bool isSequential() const
return true if nodes at all levels can safely be accessed with simple linear offsets ...
Definition: NanoVDB.h:3855
typename Mask< Log2Dim >::template Iterator< On > MaskIterT
Definition: NanoVDB.h:4982
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:4613
ValueOnIterator()
Definition: NanoVDB.h:6054
CoordT mBBoxMin
Definition: NanoVDB.h:5967
const typename GridOrTreeOrRootT::RootNodeType::ChildNodeType Type
Definition: NanoVDB.h:3447
Coord & operator-=(const Coord &rhs)
Definition: NanoVDB.h:1434
bool isActive() const
Return true if any of the voxel value are active in this leaf node.
Definition: NanoVDB.h:6277
BBox< CoordT > bbox() const
Return the bounding box in index space of active values in this leaf node.
Definition: NanoVDB.h:6223
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:5626
NodeT & operator*() const
Definition: NanoVDB.h:5013
ValueIter operator++(int)
Definition: NanoVDB.h:4469
uint64_t memUsage() const
return memory usage in bytes for the leaf node
Definition: NanoVDB.h:6242
ConstDenseIterator cbeginDense() const
Definition: NanoVDB.h:4578
CoordT origin() const
Definition: NanoVDB.h:4243
FloatType getDev() const
Definition: NanoVDB.h:6002
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:6899
const StatsT & stdDeviation() const
Definition: NanoVDB.h:4311
T type
Definition: NanoVDB.h:507
Vec3 operator-(const Coord &ijk) const
Definition: NanoVDB.h:1594
Vec3< T2 > operator/(T1 scalar, const Vec3< T2 > &vec)
Definition: NanoVDB.h:1698
static uint64_t memUsage()
Definition: NanoVDB.h:5949
BBox< Vec3d > mWorldBBox
Definition: NanoVDB.h:3523
uint64_t ValueType
Definition: NanoVDB.h:5841
uint16_t ArrayType
Definition: NanoVDB.h:5646
uint32_t nodeCount() const
Definition: NanoVDB.h:4079
const uint64_t & valueCount() const
Return total number of values indexed by the IndexGrid.
Definition: NanoVDB.h:7771
ValueT value
Definition: NanoVDB.h:4247
Node caching at all (three) tree levels.
Definition: NanoVDB.h:7165
BBox()
Default construction sets BBox to an empty bbox.
Definition: NanoVDB.h:2310
Definition: NanoVDB.h:3471
const DataType * data() const
Definition: NanoVDB.h:3724
bool isActive() const
Definition: NanoVDB.h:5066
typename GridOrTreeOrRootT::RootNodeType::ChildNodeType::ChildNodeType Type
Definition: NanoVDB.h:3426
void setValueOnly(uint32_t offset, uint16_t value)
Definition: NanoVDB.h:5991
BuildT BuildType
Definition: NanoVDB.h:7189
Stuct with all the member data of the LeafNode (useful during serialization of an openvdb LeafNode) ...
Definition: NanoVDB.h:5433
GridBlindDataSemantic
Blind-data Semantics that are currently understood by NanoVDB.
Definition: NanoVDB.h:424
bool isRootNext() const
return true if RootData is layout out immediately after TreeData in memory
Definition: NanoVDB.h:3966
bool operator==(const BaseBBox &rhs) const
Definition: NanoVDB.h:2235
uint32_t packed
Definition: NanoVDB.h:1864
Version mVersion
Definition: NanoVDB.h:3516
void setOn(uint32_t offset)
Definition: NanoVDB.h:5863
void setBitOff(std::initializer_list< uint8_t > list)
Definition: NanoVDB.h:2757
ConstValueIterator cbeginValueAll() const
Definition: NanoVDB.h:4481
GridFlags
Grid flags which indicate what extra information is present in the grid buffer.
Definition: NanoVDB.h:387
const NodeTrait< TreeT, LEVEL >::type * getNode() const
Definition: NanoVDB.h:7240
static uint32_t valueCount()
Definition: NanoVDB.h:5878
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:2544
ValueType getValue(int i, int j, int k) const
Definition: NanoVDB.h:4044
CoordType getOrigin() const
Definition: NanoVDB.h:5144
ChildIter()
Definition: NanoVDB.h:5002
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:7487
RootT RootType
Definition: NanoVDB.h:3998
Definition: NanoVDB.h:247
float type
Definition: NanoVDB.h:703
CoordBBox bbox
Definition: NanoVDB.h:8200
bool isEmpty() const
Definition: NanoVDB.h:3960
float Type
Definition: NanoVDB.h:709
Visits all tile values and child nodes of this node.
Definition: NanoVDB.h:5111
GridType mGridType
Definition: NanoVDB.h:3526
Vec3 & operator-=(const Vec3 &v)
Definition: NanoVDB.h:1611
ChildNodeType * probeChild(const CoordType &ijk)
Definition: NanoVDB.h:5250
uint64_t mChecksum
Definition: NanoVDB.h:3515
uint32_t nodeCount(int level) const
Definition: NanoVDB.h:4085
ChannelAccessor(const NanoGrid< IndexT > &grid, ChannelT *channelPtr)
Ctor from an IndexGrid and an external channel.
Definition: NanoVDB.h:7749
Definition: NanoVDB.h:2858
Iterator end() const
Definition: NanoVDB.h:2421
NodeTrait< RootT, 1 >::type * getFirstLower()
Definition: NanoVDB.h:4139
Define static boolean tests for template build types.
Definition: NanoVDB.h:471
T dot(const Vec4T &v) const
Definition: NanoVDB.h:1771
uint32_t hash() const
Return a hash key derived from the existing coordinates.
Definition: NanoVDB.h:1507
Bit-mask to encode active states and facilitate sequential iterators and a fast codec for I/O compres...
Definition: NanoVDB.h:2824
int32_t & x()
Definition: NanoVDB.h:1335
uint64_t pointCount() const
Definition: NanoVDB.h:5987
uint64_t getValue(uint32_t i) const
Definition: NanoVDB.h:5990
T * asPointer()
return a non-const raw constant pointer to array of three vector components
Definition: NanoVDB.h:1687
bool operator!=(const BaseBBox &rhs) const
Definition: NanoVDB.h:2236
void clear()
Reset this access to its initial state, i.e. with an empty cache Noop since this template specializa...
Definition: NanoVDB.h:6595
static size_t memUsage()
Definition: NanoVDB.h:1343
CoordT CoordType
Definition: NanoVDB.h:6709
void setOff()
Set all bits off.
Definition: NanoVDB.h:3046
static ElementType scalar(const T &v)
Definition: NanoVDB.h:1987
bool isValid(const GridBlindDataClass &blindClass, const GridBlindDataSemantic &blindSemantics, const GridType &blindType)
return true if the combination of GridBlindDataClass, GridBlindDataSemantic and GridType is valid...
Definition: NanoVDB.h:906
bool isChild() const
Definition: NanoVDB.h:4240
ValueType getValue(int i, int j, int k) const
Definition: NanoVDB.h:7290
NodeT & operator*() const
Definition: NanoVDB.h:4402
void localToGlobalCoord(Coord &ijk) const
modifies local coordinates to global coordinates of a tile or child node
Definition: NanoVDB.h:5278
void toggle()
brief Toggle the state of all bits in the mask
Definition: NanoVDB.h:3060
uint64_t mData2
Definition: NanoVDB.h:3530
const Vec3T & max() const
Definition: NanoVDB.h:2242
ChannelT & operator()(int i, int j, int k) const
Definition: NanoVDB.h:7793
Vec3T applyIJTF(const Vec3T &xyz) const
Definition: NanoVDB.h:3607
const NanoGrid< BuildT > & grid() const
Definition: NanoVDB.h:7612
typename ChildT::ValueType ValueT
Definition: NanoVDB.h:4176
float mMinimum
Definition: NanoVDB.h:5516
BBox< Coord > CoordBBox
Definition: NanoVDB.h:2535
void clear()
Reset this access to its initial state, i.e. with an empty cache.
Definition: NanoVDB.h:6924
Vec3T applyJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:3603
uint8_t bitWidth() const
Definition: NanoVDB.h:5686
DenseIterator beginAll() const
Definition: NanoVDB.h:2926
Version(uint32_t data)
Definition: NanoVDB.h:957
static constexpr uint8_t bitWidth()
Definition: NanoVDB.h:5657
typename NanoLeaf< BuildT >::FloatType FloatType
Definition: NanoVDB.h:8194
bool isOff() const
Definition: NanoVDB.h:2786
void setMax(const ValueType &)
Definition: NanoVDB.h:5819
T Pow4(T x)
Definition: NanoVDB.h:1180
uint32_t totalNodeCount() const
Definition: NanoVDB.h:4091
Definition: NanoVDB.h:5837
ValueType getValue(uint32_t offset) const
Return the voxel value at the given offset.
Definition: NanoVDB.h:6251
KeyT key
Definition: NanoVDB.h:4244
uint64_t FloatType
Definition: NanoVDB.h:2025
bool isCached(const CoordType &ijk) const
Definition: NanoVDB.h:7277
typename DataType::StatsT FloatType
Definition: NanoVDB.h:4973
bool ValueType
Definition: NanoVDB.h:5742
A simple vector class with three components, similar to openvdb::math::Vec3.
Definition: NanoVDB.h:1298
Mask & operator^=(const Mask &other)
Bitwise XOR.
Definition: NanoVDB.h:3096
bool isActive() const
Return true if this node or any of its child nodes contain active values.
Definition: NanoVDB.h:5292
Dummy type for a voxel whose value equals an offset into an external value array of active values...
Definition: NanoVDB.h:257
Top-most node of the VDB tree structure.
Definition: NanoVDB.h:4329
void setValue(uint32_t offset, bool v)
Definition: NanoVDB.h:5763
int64_t child
Definition: NanoVDB.h:4870
bool operator<=(const Coord &rhs) const
Return true if this Coord is lexicographically less or equal to the given Coord.
Definition: NanoVDB.h:1384
#define NANOVDB_MAJOR_VERSION_NUMBER
Definition: NanoVDB.h:133
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:6287
uint8_t ArrayType
Definition: NanoVDB.h:5579
Vec4 operator/(const T &s) const
Definition: NanoVDB.h:1783
Struct to derive node type from its level in a given grid, tree or root while preserving constness...
Definition: NanoVDB.h:3404
ValueType operator*() const
Definition: NanoVDB.h:5094
typename GridT::TreeType type
Definition: NanoVDB.h:3976
T length() const
Definition: NanoVDB.h:1587
uint64_t getMax() const
Definition: NanoVDB.h:5909
Vec3T applyJacobian(const Vec3T &ijk) const
Apply the linear forward 3x3 transformation to an input 3d vector using 64bit floating point arithmet...
Definition: NanoVDB.h:3229
const ChildT * probeChild(ValueType &value) const
Definition: NanoVDB.h:5128
Definition: NanoVDB.h:4384
uint32_t level
Definition: NanoVDB.h:8197
static CoordT KeyToCoord(const KeyT &key)
Definition: NanoVDB.h:4194
Vec3< float > asVec3s() const
Return a single precision floating-point vector of this coordinate.
Definition: NanoVDB.h:1712
uint32_t mTileCount[3]
Definition: NanoVDB.h:3944
typename RootT::ChildNodeType Node2
Definition: NanoVDB.h:4009
Vec3 & minComponent(const Vec3 &other)
Perform a component-wise minimum with the other Coord.
Definition: NanoVDB.h:1635
ValueType mMinimum
Definition: NanoVDB.h:5448
DenseIterator(uint32_t pos=Mask::SIZE)
Definition: NanoVDB.h:2895
uint64_t Type
Definition: NanoVDB.h:660
uint64_t type
Definition: NanoVDB.h:668
T type
Definition: NanoVDB.h:601
ValueT mMaximum
Definition: NanoVDB.h:4884
BBox(const CoordT &min, const CoordT &max)
Definition: NanoVDB.h:2426
Mask & operator=(const Mask &other)
Definition: NanoVDB.h:2965
void setValueOnly(uint32_t offset, const ValueType &value)
Definition: NanoVDB.h:5466
const NanoGrid< Point > & grid() const
Definition: NanoVDB.h:7679
bool isActive() const
Definition: NanoVDB.h:6142
Vec3T applyInverseMap(const Vec3T &xyz) const
Apply the inverse affine mapping to a vector using 64bit floating point arithmetics.
Definition: NanoVDB.h:3246
const LeafNodeType * getFirstLeaf() const
Definition: NanoVDB.h:4138
Vec3T & max()
Definition: NanoVDB.h:2240
T ElementType
Definition: NanoVDB.h:1975
Vec4 & operator+=(const Vec4 &v)
Definition: NanoVDB.h:1784
Coord & maxComponent(const Coord &other)
Perform a component-wise maximum with the other Coord.
Definition: NanoVDB.h:1455
typename RootType::LeafNodeType LeafNodeType
Definition: NanoVDB.h:3706
float Type
Definition: NanoVDB.h:723
uint32_t getPatch() const
Definition: NanoVDB.h:973
bool hasStdDeviation() const
Definition: NanoVDB.h:3841
uint64_t Type
Definition: NanoVDB.h:667
Struct with all the member data of the RootNode (useful during serialization of an openvdb RootNode) ...
Definition: NanoVDB.h:4174
const GridBlindMetaData & blindMetaData(uint32_t n) const
Definition: NanoVDB.h:3903
openvdb::GridBase Grid
Definition: Utils.h:34
static BBox createCube(const Coord &min, typename Coord::ValueType dim)
Definition: NanoVDB.h:2324
uint8_t * treePtr()
Definition: NanoVDB.h:3610
static T * alignPtr(T *p)
offset the specified pointer so it is aligned.
Definition: NanoVDB.h:757
int32_t Floor(float x)
Definition: NanoVDB.h:1149
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:4610
Mask()
Initialize all bits to zero.
Definition: NanoVDB.h:2929
ReadAccessor(const TreeT &tree)
Constructor from a tree.
Definition: NanoVDB.h:6588
ValueIterator beginValue() const
Definition: NanoVDB.h:5073
bool isMaskOn(uint32_t offset) const
Definition: NanoVDB.h:5950
typename RootNodeType::ChildNodeType UpperNodeType
Definition: NanoVDB.h:4000
ConstValueOnIterator cbeginValueOn() const
Definition: NanoVDB.h:4525
double FloatType
Definition: NanoVDB.h:2001
float getValue(uint32_t i) const
Definition: NanoVDB.h:5689
void setMax(const ValueType &)
Definition: NanoVDB.h:6005
uint64_t type
Definition: NanoVDB.h:675
static DstT * PtrAdd(SrcT *p, int64_t offset)
Adds a byte offset of a non-const pointer to produce another non-const pointer.
Definition: NanoVDB.h:795
T type
Definition: NanoVDB.h:587
ValueIterator()
Definition: NanoVDB.h:5044
Vec4 operator-() const
Definition: NanoVDB.h:1777
Delta for small floating-point offsets.
Definition: NanoVDB.h:1035
GridClass mGridClass
Definition: NanoVDB.h:3525
Dummy type for a voxel whose value equals an offset into an external value array. ...
Definition: NanoVDB.h:252
Maps one type (e.g. the build types above) to other (actual) types.
Definition: NanoVDB.h:651
Coord()
Initialize all coordinates to zero.
Definition: NanoVDB.h:1309
Vec3T applyInverseJacobianF(const Vec3T &xyz) const
Definition: NanoVDB.h:3605
Vec3T applyIJT(const Vec3T &xyz) const
Apply the transposed inverse 3x3 transformation to an input 3d vector using 64bit floating point arit...
Definition: NanoVDB.h:3287
ValueType operator()(int i, int j, int k) const
Definition: NanoVDB.h:6989
DataType * data()
Definition: NanoVDB.h:6173
typename RootT::ValueType ValueType
Definition: NanoVDB.h:6558
Vec3d getVoxelSize() const
Return a voxels size in each coordinate direction, measured at the origin.
Definition: NanoVDB.h:3292
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:6757
bool operator<=(const Version &rhs) const
Definition: NanoVDB.h:967
ValueOnIter(RootT *parent)
Definition: NanoVDB.h:4493
Vec3 & operator+=(const Coord &ijk)
Definition: NanoVDB.h:1604
void setMax(float max)
Definition: NanoVDB.h:5556
double ValueType
Definition: NanoVDB.h:1536
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:4619
typename ChildT::CoordType CoordType
Definition: NanoVDB.h:4343
Definition: NanoVDB.h:4484
void setAvg(const FloatType &)
Definition: NanoVDB.h:5861
void setChild(uint32_t n, const void *ptr)
Definition: NanoVDB.h:4900
const uint8_t * nodePtr() const
Return a non-const uint8_t pointer to the first node at LEVEL.
Definition: NanoVDB.h:3621
ValueType getValue(int i, int j, int k) const
Definition: NanoVDB.h:6987
Vec3 operator-(const Vec3 &v) const
Definition: NanoVDB.h:1592
void setMax(const ValueT &v)
Definition: NanoVDB.h:4952
Vec3T indexToWorldGrad(const Vec3T &grad) const
transform the gradient from index space to world space.
Definition: NanoVDB.h:3788
static uint32_t padding()
Definition: NanoVDB.h:6239
bool getAvg() const
Definition: NanoVDB.h:5814
DenseIter operator++(int)
Definition: NanoVDB.h:4566
const typename GridOrTreeOrRootT::LeafNodeType type
Definition: NanoVDB.h:3419
float length() const
Definition: NanoVDB.h:1938
static size_t memUsage()
Return memory usage in bytes for the class.
Definition: NanoVDB.h:5169
static Coord Floor(const Vec3T &xyz)
Return the largest integer coordinates that are not greater than xyz (node centered conversion)...
Definition: NanoVDB.h:1499
bool isApproxZero(const Type &x)
Definition: NanoVDB.h:1083
void setOn(uint32_t offset)
Definition: NanoVDB.h:5997
const NodeTrait< RootT, LEVEL >::type * getFirstNode() const
return a const pointer to the first node of the specified level
Definition: NanoVDB.h:4131
Rgba8(const Vec4f &rgba)
Vec4f r,g,b,a ctor.
Definition: NanoVDB.h:1925
const BBoxType & bbox() const
Return a const reference to the index bounding box of all the active values in this tree...
Definition: NanoVDB.h:4594
Coord operator-(const Coord &rhs) const
Definition: NanoVDB.h:1425
const Map & map() const
Return a const reference to the Map for this grid.
Definition: NanoVDB.h:3765
static double value()
Definition: NanoVDB.h:1028
Definition: NanoVDB.h:2295
bool getValue(uint32_t i) const
Definition: NanoVDB.h:5758
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:6983
FloatType getAvg() const
Definition: NanoVDB.h:6001
uint8_t octant() const
Return the octant of this Coord.
Definition: NanoVDB.h:1511
ValueType operator*() const
Definition: NanoVDB.h:4451
bool isValid() const
Methods related to the classification of this grid.
Definition: NanoVDB.h:3826
CoordType getCoord() const
Definition: NanoVDB.h:5028
void setMax(const ValueType &)
Definition: NanoVDB.h:5860
DenseIter & operator++()
Definition: NanoVDB.h:4560
T Abs(T x)
Definition: NanoVDB.h:1185
bool isOn(uint32_t n) const
Return true if the given bit is set.
Definition: NanoVDB.h:2983
uint64_t volume() const
Definition: NanoVDB.h:2463
Vec3T applyMap(const Vec3T &ijk) const
Apply the forward affine transformation to a vector using 64bit floating point arithmetics.
Definition: NanoVDB.h:3212
bool operator!=(const Vec4 &rhs) const
Definition: NanoVDB.h:1756
typename Node2::ChildNodeType Node1
Definition: NanoVDB.h:4010
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:7295
Dummy type for a 16 bit floating point values.
Definition: NanoVDB.h:277
RootT RootNodeType
Definition: NanoVDB.h:3999
const uint8_t & b() const
Definition: NanoVDB.h:1947
uint32_t id() const
Definition: NanoVDB.h:970
#define NANOVDB_MAGIC_NUMBER
Definition: NanoVDB.h:126
const char * c_str() const
Definition: NanoVDB.h:981
bool getDev() const
Definition: NanoVDB.h:5762
Vec4 & operator=(const Vec4T< T2 > &rhs)
Definition: NanoVDB.h:1758
float getValue(uint32_t i) const
Definition: NanoVDB.h:5658
bool isEmpty() const
Return true if this RootNode is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:4628
float Fract(float x)
Definition: NanoVDB.h:1140
DenseIter()
Definition: NanoVDB.h:4534
NodeTrait< RootT, 2 >::type * getFirstUpper()
Definition: NanoVDB.h:4141
uint8_t & g()
Definition: NanoVDB.h:1950
void fill(const ValueType &v)
Definition: NanoVDB.h:5487
Vec4 operator*(const T &s) const
Definition: NanoVDB.h:1782
BitFlags & operator=(Type n)
required for backwards compatibility
Definition: NanoVDB.h:2812
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:7286
void ArrayType
Definition: NanoVDB.h:5843
const ChildNodeType * probeChild(const CoordType &ijk) const
Definition: NanoVDB.h:4684
Coord & operator>>=(uint32_t n)
Definition: NanoVDB.h:1410
static uint64_t memUsage()
Definition: NanoVDB.h:5855
int64_t child
Definition: NanoVDB.h:4245
bool empty() const
Return true if this bounding box is empty, e.g. uninitialized.
Definition: NanoVDB.h:2455
OnIterator beginOn() const
Definition: NanoVDB.h:2922
BuildT ArrayType
Definition: NanoVDB.h:5440
uint32_t mBlindMetadataCount
Definition: NanoVDB.h:3528
Vec3T indexToWorldDir(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition: NanoVDB.h:3778
BuildT BuildType
Definition: NanoVDB.h:6707
void setOn(uint32_t offset)
Definition: NanoVDB.h:5768
uint32_t CountOn(uint64_t v)
Definition: NanoVDB.h:2662
bool isMaskOn(uint32_t offset) const
Definition: NanoVDB.h:5939
Vec3(T x, T y, T z)
Definition: NanoVDB.h:1542
bool BuildType
Definition: NanoVDB.h:5743
8-bit red, green, blue, alpha packed into 32 bit unsigned int
Definition: NanoVDB.h:1859
const ValueT & getMin() const
Definition: NanoVDB.h:4942
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:4634
ValueOnIter()
Definition: NanoVDB.h:4489
typename UpperNodeType::ChildNodeType LowerNodeType
Definition: NanoVDB.h:3705
T length() const
Definition: NanoVDB.h:1776
Version(uint32_t major, uint32_t minor, uint32_t patch)
Definition: NanoVDB.h:958
TileT * tile() const
Definition: NanoVDB.h:4370
VecT< GridHandleT > readUncompressedGrids(const char *fileName, const typename GridHandleT::BufferType &buffer=typename GridHandleT::BufferType())
Read a multiple un-compressed NanoVDB grids from a file and return them as a vector.
Definition: NanoVDB.h:8024
uint64_t Type
Definition: NanoVDB.h:730
AccessorType getAccessor() const
Return a new instance of a ReadAccessor used to access values in this grid.
Definition: NanoVDB.h:3759
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition: NanoVDB.h:5457
CoordT mBBoxMin
Definition: NanoVDB.h:5846
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:5189
CoordT getCoord() const
Definition: NanoVDB.h:6103
CoordT CoordType
Definition: NanoVDB.h:6892
Dummy type for a variable bit quantization of floating point values.
Definition: NanoVDB.h:297
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:5198
ValueOnIterator(const InternalNode *parent)
Definition: NanoVDB.h:5088
bool operator<(const Version &rhs) const
Definition: NanoVDB.h:966
int MaxIndex(const Vec3T &v)
Definition: NanoVDB.h:1268
DenseIterator cbeginChildAll() const
Definition: NanoVDB.h:5153
uint32_t valueCount() const
Definition: NanoVDB.h:5903
const MaskType< LOG2DIM > & getValueMask() const
Definition: NanoVDB.h:5173
StatsT mAverage
Definition: NanoVDB.h:4212
ValueIterator & operator++()
Definition: NanoVDB.h:6148
const NanoGrid< IndexT > & grid() const
Return a const reference to the IndexGrid.
Definition: NanoVDB.h:7762
Visits all values in a leaf node, i.e. both active and inactive values.
Definition: NanoVDB.h:6114
Vec3T applyIJT(const Vec3T &xyz) const
Definition: NanoVDB.h:3596
Vec3 & operator/=(const T &s)
Definition: NanoVDB.h:1632
Rgba8(uint8_t r, uint8_t g, uint8_t b, uint8_t a=255u)
integer r,g,b,a ctor where alpha channel defaults to opaque
Definition: NanoVDB.h:1894
Type & data()
Definition: NanoVDB.h:2728
T type
Definition: NanoVDB.h:499
Visits active tile values of this node only.
Definition: NanoVDB.h:5077
void setOrigin(const T &ijk)
Definition: NanoVDB.h:5775
int32_t & z()
Definition: NanoVDB.h:1337
const uint8_t & g() const
Definition: NanoVDB.h:1946
Visits all inactive values in a leaf node.
Definition: NanoVDB.h:6081
uint8_t flags() const
Definition: NanoVDB.h:6196
bool isFloatingPoint(GridType gridType)
return true if the GridType maps to a floating point type
Definition: NanoVDB.h:817
Coord & operator+=(int n)
Definition: NanoVDB.h:1417
Vec4 operator/(const Vec4 &v) const
Definition: NanoVDB.h:1779
Like ValueIndex but with a mutable mask.
Definition: NanoVDB.h:262
const GridType & gridType() const
Definition: NanoVDB.h:3827
typename RootT::ValueType ValueType
Definition: NanoVDB.h:4003
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:4607
ValueOffIterator cbeginValueOff() const
Definition: NanoVDB.h:6111
GridData & operator=(const GridData &other)
Use this method to initiate most member dat.
Definition: NanoVDB.h:3532
Mask & operator-=(const Mask &other)
Bitwise difference.
Definition: NanoVDB.h:3087
Definition: NanoVDB.h:3473
NodeT * operator->() const
Definition: NanoVDB.h:4407
ChildIterator beginChild()
Definition: NanoVDB.h:4431
float FloatType
Definition: NanoVDB.h:1995
void setMask(MaskT mask, bool on)
Definition: NanoVDB.h:2783
ChannelT * setChannel(ChannelT *channelPtr)
Change to an external channel.
Definition: NanoVDB.h:7775
Coord offsetToGlobalCoord(uint32_t n) const
Definition: NanoVDB.h:5284
uint32_t IndexType
Definition: NanoVDB.h:1306
Iterator()
Definition: NanoVDB.h:2861
typename RootNodeType::ChildNodeType UpperNodeType
Definition: NanoVDB.h:3704
bool getMax() const
Definition: NanoVDB.h:5813
auto getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:6611
typename ChildT::BuildType BuildT
Definition: NanoVDB.h:4177
bool isGridIndex() const
Definition: NanoVDB.h:3833
ValueType getValue(uint32_t i) const
Definition: NanoVDB.h:5465
ValueType getMax() const
Definition: NanoVDB.h:5475
typename BuildT::ValueType ValueType
Definition: NanoVDB.h:3708
uint64_t voxelPoints(const Coord &ijk, const AttT *&begin, const AttT *&end) const
get iterators over attributes to points at a specific voxel location
Definition: NanoVDB.h:7638
Vec3 & operator-=(const Coord &ijk)
Definition: NanoVDB.h:1618
float ValueType
Definition: NanoVDB.h:5508
uint64_t lastOffset() const
Definition: NanoVDB.h:5907
CoordT Round(const Vec3T< RealT > &xyz)
const uint32_t & activeTileCount(uint32_t level) const
Return the total number of active tiles at the specified level of the tree.
Definition: NanoVDB.h:4072
uint64_t getValue(uint32_t i) const
Definition: NanoVDB.h:5912
void setOrigin(const T &ijk)
Definition: NanoVDB.h:5485
typename ChildT::template MaskType< LOG2DIM > MaskT
Definition: NanoVDB.h:4864
BitFlags< 32 > mFlags
Definition: NanoVDB.h:3517
CoordType getOrigin() const
Definition: NanoVDB.h:5023
uint32_t pos() const
Definition: NanoVDB.h:2901
uint8_t mFlags
Definition: NanoVDB.h:5969
void setMask(uint32_t offset, bool v)
Definition: NanoVDB.h:5951
static uint32_t wordCount()
Return the number of machine words used by this Mask.
Definition: NanoVDB.h:2837
BBox()
Definition: NanoVDB.h:2422
bool operator<(const Iterator &rhs) const
Definition: NanoVDB.h:2406
CoordType getCoord() const
Definition: NanoVDB.h:5149
uint8_t mFlags
Definition: NanoVDB.h:5800
void writeUncompressedGrid(StreamT &os, const GridData *gridData, bool raw=false)
This is a standalone alternative to io::writeGrid(...,Codec::NONE) defined in util/IO.h Unlike the latter this function has no dependencies at all, not even NanoVDB.h, so it also works if client code only includes PNanoVDB.h!
Definition: NanoVDB.h:7921
enable_if< BuildTraits< T >::is_index, const uint64_t & >::type valueCount() const
Return the total number of values indexed by this IndexGrid.
Definition: NanoVDB.h:3743
ValueType max() const
Return the largest vector component.
Definition: NanoVDB.h:1663
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:5514
bool isInteger(GridType gridType)
Return true if the GridType maps to a POD integer type.
Definition: NanoVDB.h:843
int64_t mBlindMetadataOffset
Definition: NanoVDB.h:3527
ValueType getMin() const
Definition: NanoVDB.h:5474
Coord offsetBy(ValueType dx, ValueType dy, ValueType dz) const
Definition: NanoVDB.h:1482
float mTaperF
Definition: NanoVDB.h:3162
Implements Tree::probeLeaf(Coord)
Definition: NanoVDB.h:3481
T type
Definition: NanoVDB.h:581
void setAvg(const FloatType &v)
Definition: NanoVDB.h:5481
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:7198
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:6817
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:5849
Vec4 operator+(const Vec4 &v) const
Definition: NanoVDB.h:1780
Type data() const
Definition: NanoVDB.h:2727
void setAvg(const StatsT &v)
Definition: NanoVDB.h:4953
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:7084
T type
Definition: NanoVDB.h:572
typename RootT::CoordType CoordType
Definition: NanoVDB.h:6559
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:6576
ChildIter()
Definition: NanoVDB.h:4391
void next()
Definition: NanoVDB.h:4369
BBox(const BaseBBox< Coord > &bbox)
Definition: NanoVDB.h:2329
RootType RootNodeType
Definition: NanoVDB.h:3703
Vec4 & minComponent(const Vec4 &other)
Perform a component-wise minimum with the other Coord.
Definition: NanoVDB.h:1811
BitFlags(std::initializer_list< MaskT > list)
Definition: NanoVDB.h:2722
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:7294
CoordT mBBoxMin
Definition: NanoVDB.h:5748
static CoordT OffsetToLocalCoord(uint32_t n)
Compute the local coordinates from a linear offset.
Definition: NanoVDB.h:6204
const typename remove_const< T >::type type
Definition: NanoVDB.h:624
T & operator[](int i)
Definition: NanoVDB.h:1573
uint64_t getDev() const
Definition: NanoVDB.h:5911
bool isOff(uint32_t n) const
Return true if the given bit is NOT set.
Definition: NanoVDB.h:2986
typename remove_const< T >::type type
Definition: NanoVDB.h:613
Vec3T applyMap(const Vec3T &xyz) const
Definition: NanoVDB.h:3588
Vec3T & operator[](int i)
Definition: NanoVDB.h:2238
uint32_t pos() const
Definition: NanoVDB.h:4368
const void * blindData(uint32_t n) const
Returns a const pointer to the blindData at the specified linear offset.
Definition: NanoVDB.h:3882
void setValueOnly(uint32_t offset, const ValueType &v)
Sets the value at the specified location but leaves its state unchanged.
Definition: NanoVDB.h:6269
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:5192
uint64_t voxelPoints(const Coord &ijk, const AttT *&begin, const AttT *&end) const
get iterators over attributes to points at a specific voxel location
Definition: NanoVDB.h:7704
bool isCached1(const CoordType &ijk) const
Definition: NanoVDB.h:6968
Vec3 operator/(const T &s) const
Definition: NanoVDB.h:1596
float lengthSqr() const
Definition: NanoVDB.h:1932
void setMax(const bool &)
Definition: NanoVDB.h:5770
typename ChildT::BuildType BuildT
Definition: NanoVDB.h:4861
const DataType * data() const
Definition: NanoVDB.h:5163
const uint8_t & operator[](int n) const
Definition: NanoVDB.h:1941
void setLongGridNameOn(bool on=true)
Definition: NanoVDB.h:3574
Coord round() const
Definition: NanoVDB.h:1522
static uint64_t memUsage()
Definition: NanoVDB.h:4898
ValueOnIter & operator++()
Definition: NanoVDB.h:4505
void setDev(const FloatType &v)
Definition: NanoVDB.h:5482
Iterator(uint32_t pos, const Mask *parent)
Definition: NanoVDB.h:2866
bool hasOverlap(const BBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition: NanoVDB.h:2476
uint64_t mPointCount
Definition: NanoVDB.h:5973
T type
Definition: NanoVDB.h:595
const ValueT & getMax() const
Definition: NanoVDB.h:4309
ReadAccessor(const GridT &grid)
Constructor from a grid.
Definition: NanoVDB.h:6912
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:6614
void setDev(const bool &)
Definition: NanoVDB.h:5772
MaskT< LOG2DIM > mMask
Definition: NanoVDB.h:5948
DataType * data()
Definition: NanoVDB.h:3722
ValueType operator()(const CoordType &ijk) const
Definition: NanoVDB.h:6762
PointAccessor(const NanoGrid< BuildT > &grid)
Definition: NanoVDB.h:7599
Vec3T mCoord[2]
Definition: NanoVDB.h:2234
const LeafT * probeLeaf(const CoordType &ijk) const
Definition: NanoVDB.h:6767
ValueT mMinimum
Definition: NanoVDB.h:4883
RootT & root()
Definition: NanoVDB.h:4026
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:5751
ValueOnIterator beginValueOn()
Definition: NanoVDB.h:4524
const StatsT & average() const
Definition: NanoVDB.h:4310
constexpr T pi()
Pi constant taken from Boost to match old behaviour.
Definition: NanoVDB.h:995
BaseBBox & expand(const BaseBBox &bbox)
Expand this bounding box to enclose the given bounding box.
Definition: NanoVDB.h:2258
ValueIterator(const LeafNode *parent)
Definition: NanoVDB.h:6125
uint64_t ValueType
Definition: NanoVDB.h:5961
void setMaskOn(std::initializer_list< MaskT > list)
Definition: NanoVDB.h:2769
ChannelAccessor(const NanoGrid< IndexT > &grid, uint32_t channelID=0u)
Ctor from an IndexGrid and an integer ID of an internal channel that is assumed to exist as blind dat...
Definition: NanoVDB.h:7738
Dummy type for a 8bit quantization of float point values.
Definition: NanoVDB.h:287
typename NanoLeaf< BuildT >::ValueType ValueType
Definition: NanoVDB.h:8193
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:6612
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:7626
uint32_t pos() const
Definition: NanoVDB.h:2873
Maximum floating-point values.
Definition: NanoVDB.h:1051
bool operator==(const Mask &other) const
Definition: NanoVDB.h:2971
void setOrigin(const T &ijk)
Definition: NanoVDB.h:5565
bool hasMinMax() const
Definition: NanoVDB.h:3837
bool operator==(const Iterator &rhs) const
Definition: NanoVDB.h:2396
Dummy type for a voxel whose value equals its binary active state.
Definition: NanoVDB.h:272
uint8_t mFlags
Definition: NanoVDB.h:5848
uint64_t mPrefixSum
Definition: NanoVDB.h:5850
bool operator<(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:174
DenseIterator()
Definition: NanoVDB.h:5117
uint64_t getMax() const
Definition: NanoVDB.h:5883
Version()
Definition: NanoVDB.h:951
static constexpr uint32_t padding()
Definition: NanoVDB.h:5680
Rgba8(const Vec3f &rgb)
Vec3f r,g,b ctor (alpha channel it set to 1)
Definition: NanoVDB.h:1918
bool setGridName(const char *src)
Definition: NanoVDB.h:3577
int32_t & y()
Definition: NanoVDB.h:1336
Vec3 & operator*=(const T &s)
Definition: NanoVDB.h:1625
uint32_t mGridIndex
Definition: NanoVDB.h:3518
static uint64_t memUsage()
Definition: NanoVDB.h:5984
int findBlindDataForSemantic(GridBlindDataSemantic semantic) const
Return the index of the first blind data with specified semantic if found, otherwise -1...
Definition: NanoVDB.h:3910
uint64_t mVoxelCount
Definition: NanoVDB.h:3945
const char * gridName() const
Return a c-string with the name of this grid.
Definition: NanoVDB.h:3858
bool operator!=(const Vec3 &rhs) const
Definition: NanoVDB.h:1562
Iterator(const BBox &b, const Coord &p)
Definition: NanoVDB.h:2371
uint64_t type
Definition: NanoVDB.h:661
void setBitOn(uint8_t bit)
Definition: NanoVDB.h:2749
static Coord OffsetToLocalCoord(uint32_t n)
Definition: NanoVDB.h:5270
static constexpr uint32_t padding()
Definition: NanoVDB.h:5651
uint64_t last(uint32_t i) const
Definition: NanoVDB.h:5989
bool isOn() const
Definition: NanoVDB.h:2785
const char * toStr(GridType gridType)
Maps a GridType to a c-string.
Definition: NanoVDB.h:349
ValueOnIterator()
Definition: NanoVDB.h:5083
bool isValid() const
return true if the magic number and the version are both valid
Definition: NanoVDB.h:3568
CoordT CoordType
Definition: NanoVDB.h:7191
const RootT & root() const
Definition: NanoVDB.h:6597
float getMax() const
return the quantized maximum of the active values in this node
Definition: NanoVDB.h:5543
bool hasBBox() const
Definition: NanoVDB.h:3838
BaseBBox & translate(const Vec3T &xyz)
Definition: NanoVDB.h:2243
#define NANOVDB_ASSERT(x)
Definition: NanoVDB.h:190
T dot(const Vec3T &v) const
Definition: NanoVDB.h:1575
ValueT mBackground
Definition: NanoVDB.h:4209
const typename GridOrTreeOrRootT::RootNodeType::ChildNodeType type
Definition: NanoVDB.h:3448
void clear()
Reset this access to its initial state, i.e. with an empty cache.
Definition: NanoVDB.h:6736
const NodeTrait< RootT, 2 >::type * getFirstUpper() const
Definition: NanoVDB.h:4142
BBox< CoordT > mBBox
Definition: NanoVDB.h:4878
const TreeType & tree() const
Return a const reference to the tree of the IndexGrid.
Definition: NanoVDB.h:7765
const typename GridOrTreeOrRootT::RootNodeType::ChildNodeType::ChildNodeType type
Definition: NanoVDB.h:3434
void ArrayType
Definition: NanoVDB.h:5795
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:7693
float getMin() const
return the quantized minimum of the active values in this node
Definition: NanoVDB.h:5540
Defines an affine transform and its inverse represented as a 3x3 matrix and a vec3 translation...
Definition: NanoVDB.h:3157
T & getValue(const Coord &ijk, T *channelPtr) const
Return the value from a specified channel that maps to the specified coordinate.
Definition: NanoVDB.h:7807
ValueIter()
Definition: NanoVDB.h:4440
uint64_t FloatType
Definition: NanoVDB.h:5842
float Type
Definition: NanoVDB.h:702
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition: NanoVDB.h:6654
static double value()
Definition: NanoVDB.h:1044
const FloatType & stdDeviation() const
Return a const reference to the standard deviation of all the active values encoded in this internal ...
Definition: NanoVDB.h:5195
void setBit(uint8_t bit, bool on)
Definition: NanoVDB.h:2781
Coord ceil() const
Round each component if this Vec<T> down to its integer value.
Definition: NanoVDB.h:1672
typename GridOrTreeOrRootT::RootNodeType::ChildNodeType type
Definition: NanoVDB.h:3441
Coord(ValueType n)
Initializes all coordinates to the given signed integer.
Definition: NanoVDB.h:1315
uint32_t gridIndex() const
Return index of this grid in the buffer.
Definition: NanoVDB.h:3733
GridType
List of types that are currently supported by NanoVDB.
Definition: NanoVDB.h:317
ValueType operator()(const CoordType &ijk) const
Definition: NanoVDB.h:6988
ValueType operator()(int i, int j, int k) const
Definition: NanoVDB.h:6763
void setMaskOff(std::initializer_list< MaskT > list)
Definition: NanoVDB.h:2775
typename BuildT::CoordType CoordType
Definition: NanoVDB.h:3710
uint32_t getMajor() const
Definition: NanoVDB.h:971
uint32_t findNext(uint32_t start) const
Definition: NanoVDB.h:3118
void setValue(const CoordT &ijk, const ValueType &v)
Sets the value at the specified location and activate its state.
Definition: NanoVDB.h:6264
Coord & operator&=(int n)
Definition: NanoVDB.h:1396
Class to access points at a specific voxel location.
Definition: NanoVDB.h:7592
bool isMaskOn(MaskT mask) const
Definition: NanoVDB.h:2790
ValueType getLastValue() const
If the last entry in this node's table is a tile, return the tile's value. Otherwise, return the result of calling getLastValue() on the child.
Definition: NanoVDB.h:5209
uint32_t blindDataCount() const
Return true if this grid is empty, i.e. contains no values or nodes.
Definition: NanoVDB.h:3870
void initMask(std::initializer_list< MaskT > list)
Definition: NanoVDB.h:2736
bool isUnknown() const
Definition: NanoVDB.h:3836
Vec4 & operator*=(const T &s)
Definition: NanoVDB.h:1800
ValueT mMaximum
Definition: NanoVDB.h:4211
bool isInside(const CoordT &p) const
Definition: NanoVDB.h:2468
const ChildT * getChild(const Tile *tile) const
Definition: NanoVDB.h:4302
bool getMin() const
Definition: NanoVDB.h:5812
const BlindDataT * getBlindData(uint32_t n) const
Definition: NanoVDB.h:3890
ValueT mMinimum
Definition: NanoVDB.h:4210
uint64_t offset() const
Definition: NanoVDB.h:5986
NodeTrait< RootT, LEVEL >::type * getFirstNode()
return a pointer to the first node at the specified level
Definition: NanoVDB.h:4121
const GridClass & gridClass() const
Definition: NanoVDB.h:3828
bool FloatType
Definition: NanoVDB.h:2037
uint32_t findPrev(uint32_t start) const
Definition: NanoVDB.h:3135
void setOn()
Definition: NanoVDB.h:2746
static KeyT CoordToKey(const CoordType &ijk)
Definition: NanoVDB.h:4186
static void read(std::istream &is, BufferT &buffer, Codec codec)
bool operator>(const Version &rhs) const
Definition: NanoVDB.h:968
const MaskType< LOG2DIM > & valueMask() const
Return a const reference to the bit mask of active voxels in this leaf node.
Definition: NanoVDB.h:6178
Vec3T applyInverseMapF(const Vec3T &xyz) const
Apply the inverse affine mapping to a vector using 32bit floating point arithmetics.
Definition: NanoVDB.h:3257
ValueType operator*() const
Definition: NanoVDB.h:6132
const typename GridOrTreeOrRootT::RootNodeType type
Definition: NanoVDB.h:3463
TreeData & operator=(const TreeData &other)
Definition: NanoVDB.h:3947
DenseIterator beginDense()
Definition: NanoVDB.h:4577
bool isValueOn() const
Definition: NanoVDB.h:5139
void clear()
Reset this access to its initial state, i.e. with an empty cache.
Definition: NanoVDB.h:7248
bool operator<=(const Iterator &rhs) const
Definition: NanoVDB.h:2411
bool isIndex(GridType gridType)
Return true if the GridType maps to a special index type (not a POD integer type).
Definition: NanoVDB.h:855
typename ChildT::ValueType ValueT
Definition: NanoVDB.h:4860
bool isRootConnected() const
return true if RootData follows TreeData in memory without any extra padding
Definition: NanoVDB.h:3683
BBox< CoordT > mBBox
Definition: NanoVDB.h:4206
float Sqrt(float x)
Return the square root of a floating-point value.
Definition: NanoVDB.h:1233
AccessorType getAccessor() const
Definition: NanoVDB.h:4587
static Coord max()
Definition: NanoVDB.h:1339
Implements Tree::getDim(Coord)
Definition: NanoVDB.h:3477
Definition: NanoVDB.h:4352
const NodeTrait< RootT, 1 >::type * getFirstLower() const
Definition: NanoVDB.h:4140
Codec
Define compression codecs.
Definition: NanoVDB.h:7839
Vec3< T2 > operator*(T1 scalar, const Vec3< T2 > &vec)
Definition: NanoVDB.h:1693
int MinIndex(const Vec3T &v)
Definition: NanoVDB.h:1251
uint8_t mFlags
Definition: NanoVDB.h:5513
void setOff()
Definition: NanoVDB.h:2747
Internal nodes of a VDB treedim(),.
Definition: NanoVDB.h:4968
const Tile * tile(uint32_t n) const
Returns a non-const reference to the tile at the specified linear offset.
Definition: NanoVDB.h:4253
CoordT dim() const
Definition: NanoVDB.h:2462
ValueType getValue(int i, int j, int k) const
Definition: NanoVDB.h:6761
uint8_t & b()
Definition: NanoVDB.h:1951
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:5217
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition: NanoVDB.h:4892
#define NANOVDB_HOSTDEV_DISABLE_WARNING
Definition: NanoVDB.h:234
DenseIter(RootT *parent)
Definition: NanoVDB.h:4538
ValueT ValueType
Definition: NanoVDB.h:7190
BuildT TreeType
Definition: NanoVDB.h:3701
void setChild(const CoordType &k, const void *ptr, const RootData *data)
Definition: NanoVDB.h:4226
Base-class for quantized float leaf nodes.
Definition: NanoVDB.h:5504
uint64_t FloatType
Definition: NanoVDB.h:2031
bool probeValue(const Coord &ijk, typename remove_const< ChannelT >::type &v) const
return the state and updates the value of the specified voxel
Definition: NanoVDB.h:7796
static constexpr uint32_t padding()
Definition: NanoVDB.h:5755
uint64_t getValue(uint32_t i) const
Definition: NanoVDB.h:5886
FloatType average() const
Return a const reference to the average of all the active values encoded in this leaf node...
Definition: NanoVDB.h:6188
const typename GridOrTreeOrRootT::RootNodeType::ChildNodeType::ChildNodeType Type
Definition: NanoVDB.h:3433
Coord operator<<(IndexType n) const
Definition: NanoVDB.h:1368
Vec3T indexToWorld(const Vec3T &xyz) const
index to world space transformation
Definition: NanoVDB.h:3773
Vec4 & maxComponent(const Vec4 &other)
Perform a component-wise maximum with the other Coord.
Definition: NanoVDB.h:1825
Definition: NanoVDB.h:3940
bool hasAverage() const
Definition: NanoVDB.h:3840
ValueOnIterator cbeginValueOn() const
Definition: NanoVDB.h:6078
static constexpr uint64_t memUsage()
Definition: NanoVDB.h:5650
bool isCached2(const CoordType &ijk) const
Definition: NanoVDB.h:6974
Struct with all the member data of the InternalNode (useful during serialization of an openvdb Intern...
Definition: NanoVDB.h:4858
Vec3T applyMapF(const Vec3T &xyz) const
Definition: NanoVDB.h:3599
Vec3 & operator=(const Vec3T< T2 > &rhs)
Definition: NanoVDB.h:1564
auto getNodeInfo(const CoordType &ijk) const
Definition: NanoVDB.h:6764
ValueOnIterator(const LeafNode *parent)
Definition: NanoVDB.h:6059
const typename GridT::TreeType Type
Definition: NanoVDB.h:3981
uint8_t & a()
Definition: NanoVDB.h:1952
float Clamp(float x, float a, float b)
Definition: NanoVDB.h:1131
bool isBitOn(uint8_t bit) const
Definition: NanoVDB.h:2787
BaseBBox & expand(const Vec3T &xyz)
Expand this bounding box to enclose point xyz.
Definition: NanoVDB.h:2250
CoordType getCoord() const
Definition: NanoVDB.h:5104
Dummy type for a 4bit quantization of float point values.
Definition: NanoVDB.h:282
ValueType getMin() const
Definition: NanoVDB.h:5999
bool probeValue(const CoordType &ijk, ValueType &v) const
return the state and updates the value of the specified voxel
Definition: NanoVDB.h:4636
typename ChildT::CoordType CoordT
Definition: NanoVDB.h:4863
float getDev() const
return the quantized standard deviation of the active values in this node
Definition: NanoVDB.h:5550
Return point to the lower internal node where Coord maps to one of its values, i.e. terminates.
Definition: NanoVDB.h:8134
Vec3T Vec3Type
Definition: NanoVDB.h:2304
void setRoot(const void *root)
Definition: NanoVDB.h:3953
uint64_t type
Definition: NanoVDB.h:682
static bool lessThan(const Coord &a, const Coord &b)
Definition: NanoVDB.h:1491
Vec3 & maxComponent(const Vec3 &other)
Perform a component-wise maximum with the other Coord.
Definition: NanoVDB.h:1647
const typename GridT::TreeType type
Definition: NanoVDB.h:3982
bool operator==(const Vec4 &rhs) const
Definition: NanoVDB.h:1755
Iterator operator++(int)
Definition: NanoVDB.h:2880
Vec3T worldToIndexDirF(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition: NanoVDB.h:3806
Vec3< double > asVec3d() const
Return a double precision floating-point vector of this coordinate.
Definition: NanoVDB.h:1718
uint64_t getIndex(const Coord &ijk) const
Return the linear offset into a channel that maps to the specified coordinate.
Definition: NanoVDB.h:7787
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition: NanoVDB.h:5980
Mask & operator&=(const Mask &other)
Bitwise intersection.
Definition: NanoVDB.h:3069
CoordType getOrigin() const
Definition: NanoVDB.h:4371
uint8_t mFlags
Definition: NanoVDB.h:5750
const Vec3d & voxelSize() const
Return a const reference to the size of a voxel in world units.
Definition: NanoVDB.h:3762
static uint64_t memUsage()
Definition: NanoVDB.h:5804
void setValue(uint32_t offset, bool)
Definition: NanoVDB.h:5816
void toggle(uint32_t n)
Definition: NanoVDB.h:3066
static bool hasStats()
Definition: NanoVDB.h:5805
bool getMax() const
Definition: NanoVDB.h:5760
OffIterator beginOff() const
Definition: NanoVDB.h:2924
const ChildT * getChild(uint32_t n) const
Definition: NanoVDB.h:4919
uint64_t checksum() const
Return checksum of the grid buffer.
Definition: NanoVDB.h:3864
static T value()
Definition: NanoVDB.h:1077
Definition: NanoVDB.h:505
static bool hasStats()
Definition: NanoVDB.h:5522
Coord floor() const
Round each component if this Vec<T> up to its integer value.
Definition: NanoVDB.h:1669
Struct with all the member data of the Grid (useful during serialization of an openvdb grid) ...
Definition: NanoVDB.h:3511
bool ValueType
Definition: NanoVDB.h:5792
typename ChildT::template MaskType< LOG2 > MaskType
Definition: NanoVDB.h:4980
Implements Tree::isActive(Coord)
Definition: NanoVDB.h:3475
Coord & operator<<=(uint32_t n)
Definition: NanoVDB.h:1403
ValueIterator cbeginValueAll() const
Definition: NanoVDB.h:5074
Definition: NanoVDB.h:1966
Iterator begin() const
Definition: NanoVDB.h:2420
void setAvg(float avg)
Definition: NanoVDB.h:5559
FloatType stdDeviation() const
Return a const reference to the standard deviation of all the active values encoded in this leaf node...
Definition: NanoVDB.h:6194
void setOn(uint32_t offset)
Definition: NanoVDB.h:5472
NodeT * operator->() const
Definition: NanoVDB.h:5018
void init(std::initializer_list< GridFlags > list={GridFlags::IsBreadthFirst}, uint64_t gridSize=0u, const Map &map=Map(), GridType gridType=GridType::Unknown, GridClass gridClass=GridClass::Unknown)
Definition: NanoVDB.h:3538
void setOn(uint32_t offset)
Definition: NanoVDB.h:5537
bool FloatType
Definition: NanoVDB.h:5794
const uint32_t & getTableSize() const
Definition: NanoVDB.h:4604
uint32_t mData0
Definition: NanoVDB.h:3529
static uint32_t bitCount()
Return the number of bits available in this Mask.
Definition: NanoVDB.h:2834
bool operator==(const Version &rhs) const
Definition: NanoVDB.h:965
type for indexing points into voxels
Definition: NanoVDB.h:302
void setMax(const ValueType &v)
Definition: NanoVDB.h:5480
uint8_t & operator[](int n)
Definition: NanoVDB.h:1942
ValueOnIterator cbeginValueOn() const
Definition: NanoVDB.h:5108
typename ChildT::FloatType StatsT
Definition: NanoVDB.h:4862
Definition: NanoVDB.h:2685
const Vec3T & operator[](int i) const
Definition: NanoVDB.h:2237
const uint8_t & a() const
Definition: NanoVDB.h:1948
DataT * mData
Definition: NanoVDB.h:4357
static int64_t PtrDiff(const T1 *p, const T2 *q)
Compute the distance, in bytes, between two pointers.
Definition: NanoVDB.h:780
bool Type
Definition: NanoVDB.h:688
Vec3 operator*(const T &s) const
Definition: NanoVDB.h:1595
bool isMaskOn(std::initializer_list< MaskT > list) const
return true if any of the masks in the list are on
Definition: NanoVDB.h:2795
void setDev(const FloatType &)
Definition: NanoVDB.h:6007
static uint64_t memUsage()
Definition: NanoVDB.h:5520
T & operator[](int i)
Definition: NanoVDB.h:1769
Definition: NanoVDB.h:2892
ValueOnIterator beginValueOn() const
Definition: NanoVDB.h:5107
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:7616
uint32_t rootTableSize() const
return the root table has size
Definition: NanoVDB.h:3670
StatsT mAverage
Definition: NanoVDB.h:4885
Tolerance for floating-point comparison.
Definition: NanoVDB.h:1019
Definition: NanoVDB.h:4528
void setFirstNode(const NodeT *node)
Definition: NanoVDB.h:3958
CoordT mBBoxMin
Definition: NanoVDB.h:5511
bool operator!=(const Coord &rhs) const
Definition: NanoVDB.h:1395
typename ChildT::CoordType CoordT
Definition: NanoVDB.h:4178
T Pow2(T x)
Definition: NanoVDB.h:1168
static uint32_t voxelCount()
Return the total number of voxels (e.g. values) encoded in this leaf node.
Definition: NanoVDB.h:6237
void setAvg(const StatsT &v)
Definition: NanoVDB.h:4315
static Coord min()
Definition: NanoVDB.h:1341
MaskT mValueMask
Definition: NanoVDB.h:4880
Vec3T dim() const
Definition: NanoVDB.h:2339
uint16_t mMin
Definition: NanoVDB.h:5518
typename ChildT::FloatType StatsT
Definition: NanoVDB.h:4179
typename GridOrTreeOrRootT::RootNodeType::ChildNodeType Type
Definition: NanoVDB.h:3440
static uint64_t memUsage()
Definition: NanoVDB.h:5938
LeafNodeType * getFirstLeaf()
Template specializations of getFirstNode.
Definition: NanoVDB.h:4137
typename FloatTraits< ValueType >::FloatType FloatType
Definition: NanoVDB.h:5963
Coord offsetBy(ValueType n) const
Definition: NanoVDB.h:1487
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:6992
Vec3T worldToIndex(const Vec3T &xyz) const
world to index space transformation
Definition: NanoVDB.h:3769
CoordType origin() const
Return the origin in index space of this leaf node.
Definition: NanoVDB.h:5180
ConstChildIterator cbeginChild() const
Definition: NanoVDB.h:4432
Like ValueOnIndex but with a mutable mask.
Definition: NanoVDB.h:267
size_t memUsage() const
Definition: NanoVDB.h:5687
Vec4 operator-(const Vec4 &v) const
Definition: NanoVDB.h:1781
ReadAccessor(const GridT &grid)
Constructor from a grid.
Definition: NanoVDB.h:6724
const typename GridOrTreeOrRootT::LeafNodeType Type
Definition: NanoVDB.h:3418
void setMin(const ValueType &)
Definition: NanoVDB.h:5818
MaskT< LOG2DIM > mValues
Definition: NanoVDB.h:5752
uint64_t getMin() const
Definition: NanoVDB.h:5908
float getValue(uint32_t i) const
Definition: NanoVDB.h:5627
static bool isValid(const void *p)
return true if the specified pointer is aligned and not NULL
Definition: NanoVDB.h:743
uint8_t * nodePtr()
Return a non-const uint8_t pointer to the first node at LEVEL.
Definition: NanoVDB.h:3633
ValueType getLastValue() const
Return the last value in this leaf node.
Definition: NanoVDB.h:6259
uint32_t countOn() const
Return the total number of set bits in this Mask.
Definition: NanoVDB.h:2840
const uint8_t * treePtr() const
Definition: NanoVDB.h:3614
void setMinMaxOn(bool on=true)
Definition: NanoVDB.h:3572
bool isMaskOff(MaskT mask) const
Definition: NanoVDB.h:2792
void setValue(const CoordType &k, bool s, const ValueType &v)
Definition: NanoVDB.h:4233
uint32_t mTableSize
Definition: NanoVDB.h:4207
typename BuildT::BuildType BuildType
Definition: NanoVDB.h:3709
CoordT origin() const
Return the origin in index space of this leaf node.
Definition: NanoVDB.h:6199
typename T::ValueType ElementType
Definition: NanoVDB.h:1986
Iterator operator++(int)
Definition: NanoVDB.h:2390
DenseIterator & operator++()
Definition: NanoVDB.h:2903
Definition: NanoVDB.h:6029
typename RootT::CoordType CoordType
Definition: NanoVDB.h:4005
float type
Definition: NanoVDB.h:724
defines a tree type from a grid type while preserving constness
Definition: NanoVDB.h:3973
ValueType getFirstValue() const
If the first entry in this node's table is a tile, return the tile's value. Otherwise, return the result of calling getFirstValue() on the child.
Definition: NanoVDB.h:5202
typename match_const< Tile, RootT >::type TileT
Definition: NanoVDB.h:4356
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition: NanoVDB.h:6613
void setOff(uint32_t n)
Set the specified bit off.
Definition: NanoVDB.h:3009
ReadAccessor(const TreeT &tree)
Constructor from a tree.
Definition: NanoVDB.h:6918
uint32_t getMinor() const
Definition: NanoVDB.h:972
ChannelT & operator()(const Coord &ijk) const
Definition: NanoVDB.h:7792
void localToGlobalCoord(Coord &ijk) const
Converts (in place) a local index coordinate to a global index coordinate.
Definition: NanoVDB.h:6212
bool isInside(const BBox &b) const
Return true if the given bounding box is inside this bounding box.
Definition: NanoVDB.h:2470
#define __hostdev__
Definition: NanoVDB.h:213
void setDev(const FloatType &)
Definition: NanoVDB.h:5821
const uint64_t * words() const
Definition: NanoVDB.h:2950
ValueIterator beginValue() const
Definition: NanoVDB.h:6161
Visits child nodes of this node only.
Definition: NanoVDB.h:4994
ChildIter & operator++()
Definition: NanoVDB.h:4412
ReadAccessor(const GridT &grid)
Constructor from a grid.
Definition: NanoVDB.h:6582
FloatType getAvg() const
Definition: NanoVDB.h:5476
const Tile * probeTile(const CoordT &ijk) const
Definition: NanoVDB.h:4289
enable_if< is_same< T, Point >::value, const uint64_t & >::type pointCount() const
Return the total number of points indexed by this PointGrid.
Definition: NanoVDB.h:3750
const ChildNodeType * probeChild(const CoordType &ijk) const
Definition: NanoVDB.h:5255
ValueType getValue(int i, int j, int k) const
Definition: NanoVDB.h:4633
void setValue(uint32_t offset, uint16_t value)
Definition: NanoVDB.h:5992
Iterator & operator++()
Definition: NanoVDB.h:2376
uint64_t Type
Definition: NanoVDB.h:681
uint8_t ValueType
Definition: NanoVDB.h:1869
ValueOffIterator(const LeafNode *parent)
Definition: NanoVDB.h:6092
typename Mask< 3 >::template Iterator< ON > MaskIterT
Definition: NanoVDB.h:6045
Leaf nodes of the VDB tree. (defaults to 8x8x8 = 512 voxels)
Definition: NanoVDB.h:6026
uint32_t & packed()
Definition: NanoVDB.h:1944
static size_t memUsage()
Return the memory footprint in bytes of this Mask.
Definition: NanoVDB.h:2831
Vec3 operator-() const
Definition: NanoVDB.h:1588
void setDev(const StatsT &v)
Definition: NanoVDB.h:4954
Vec3T applyInverseJacobianF(const Vec3T &xyz) const
Apply the linear inverse 3x3 transformation to an input 3d vector using 32bit floating point arithmet...
Definition: NanoVDB.h:3278
BBox< Vec3d > transform(const Map &map) const
transform this coordinate bounding box by the specified map
Definition: NanoVDB.h:2499
T Pow3(T x)
Definition: NanoVDB.h:1174
Iterator(const BBox &b)
Definition: NanoVDB.h:2366
const char * shortGridName() const
Return a c-string with the name of this grid, truncated to 255 characters.
Definition: NanoVDB.h:3861
ChildT * getChild(uint32_t n)
Returns a pointer to the child node at the specifed linear offset.
Definition: NanoVDB.h:4914
void setOrigin(const T &ijk)
Definition: NanoVDB.h:5824
BuildT BuildType
Definition: NanoVDB.h:6890
bool FloatType
Definition: NanoVDB.h:5744
static bool hasStats()
Definition: NanoVDB.h:5757
double mTaperD
Definition: NanoVDB.h:3166
void setDev(const FloatType &)
Definition: NanoVDB.h:5862
uint32_t dim
Definition: NanoVDB.h:8197
const DataType * data() const
Definition: NanoVDB.h:4591
void setMax(const ValueT &v)
Definition: NanoVDB.h:4314
uint64_t first(uint32_t i) const
Definition: NanoVDB.h:5988
MaskT mChildMask
Definition: NanoVDB.h:4881
bool isActive(const CoordType &ijk) const
Definition: NanoVDB.h:6765
ChildT * getChild(const Tile *tile)
Returns a const reference to the child node in the specified tile.
Definition: NanoVDB.h:4297
bool isCached(const CoordType &ijk) const
Definition: NanoVDB.h:6749
CoordBBox bbox() const
Return the index bounding box of all the active values in this tree, i.e. in all nodes of the tree...
Definition: NanoVDB.h:3963
ValueOnIterator beginValueOn() const
Definition: NanoVDB.h:6077
Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord.
Definition: NanoVDB.h:1301
Vec3T matMultT(const float *mat, const Vec3T &xyz)
Multiply the transposed of a 3x3 matrix and a 3d vector using 32bit floating point arithmetics...
Definition: NanoVDB.h:2191
const DataType * data() const
Definition: NanoVDB.h:4021
int32_t y() const
Definition: NanoVDB.h:1332
ValueIterator()
Definition: NanoVDB.h:6120
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:5446
ChildNodeType * probeChild(const CoordType &ijk)
Definition: NanoVDB.h:4690
BaseIter(DataT *data=nullptr, uint32_t n=0)
Definition: NanoVDB.h:4359
Definition: NanoVDB.h:518
C++11 implementation of std::is_floating_point.
Definition: NanoVDB.h:462
ValueOnIter operator++(int)
Definition: NanoVDB.h:4513
typename GridOrTreeOrRootT::RootNodeType Type
Definition: NanoVDB.h:3454
void setMin(const ValueT &v)
Definition: NanoVDB.h:4951
Definition: NanoVDB.h:4223
FloatType mAverage
Definition: NanoVDB.h:5450
bool isValue() const
Definition: NanoVDB.h:4241
BuildT BuildType
Definition: NanoVDB.h:6557
Vec3T applyInverseJacobian(const Vec3T &xyz) const
Apply the linear inverse 3x3 transformation to an input 3d vector using 64bit floating point arithmet...
Definition: NanoVDB.h:3269
ValueT ValueType
Definition: NanoVDB.h:6891
static constexpr int64_t memUsage()
Definition: NanoVDB.h:5619
Definition: NanoVDB.h:2232
BlindDataT * getBlindData(uint32_t n)
Definition: NanoVDB.h:3897
ChannelT & getValue(const Coord &ijk) const
Return the value from a cached channel that maps to the specified coordinate.
Definition: NanoVDB.h:7791
AccessorType getAccessor() const
Definition: NanoVDB.h:4040
bool isActive() const
Definition: NanoVDB.h:4242
float Type
Definition: NanoVDB.h:695
typename UpperNodeType::ChildNodeType LowerNodeType
Definition: NanoVDB.h:4337
StatsT mStdDevi
Definition: NanoVDB.h:4213
Vec3 & operator+=(const Vec3 &v)
Definition: NanoVDB.h:1597
void setMaskOff(MaskT mask)
Definition: NanoVDB.h:2766
Coord(ValueType i, ValueType j, ValueType k)
Initializes coordinate to the given signed integers.
Definition: NanoVDB.h:1321
bool hasLongGridName() const
Definition: NanoVDB.h:3839
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition: NanoVDB.h:6716
const uint32_t & tileCount() const
Return the number of tiles encoded in this root node.
Definition: NanoVDB.h:4603
C++11 implementation of std::enable_if.
Definition: NanoVDB.h:492
ValueT value
Definition: NanoVDB.h:4869
uint64_t gridSize() const
Return memory usage in bytes for this class only.
Definition: NanoVDB.h:3730
Vec4(const Vec4T< T2 > &v)
Definition: NanoVDB.h:1750
const LeafNode * probeLeaf(const CoordT &) const
Definition: NanoVDB.h:6294
ValueType getValue(int i, int j, int k) const
Definition: NanoVDB.h:6608
C++11 implementation of std::is_same.
Definition: NanoVDB.h:441
typename GridOrTreeOrRootT::RootNodeType type
Definition: NanoVDB.h:3455
static uint64_t memUsage()
Definition: NanoVDB.h:5756
Mask & operator|=(const Mask &other)
Bitwise union.
Definition: NanoVDB.h:3078
ValueType getValue(const CoordType &ijk) const
Definition: NanoVDB.h:6604
static uint32_t dim()
Return the dimension, in voxel units, of this internal node (typically 8*16 or 8*16*32) ...
Definition: NanoVDB.h:5166
uint32_t gridCount() const
Return total number of grids in the buffer.
Definition: NanoVDB.h:3736
enable_if<!is_same< MaskT, Mask >::value, Mask & >::type operator=(const MaskT &other)
Assignment operator that works with openvdb::util::NodeMask.
Definition: NanoVDB.h:2954
bool getAvg() const
Definition: NanoVDB.h:5761
uint64_t getDev() const
Definition: NanoVDB.h:5885
ConstChildIterator cbeginChild() const
Definition: NanoVDB.h:5035
ChildT ChildNodeType
Definition: NanoVDB.h:4976
Coord & minComponent(const Coord &other)
Perform a component-wise minimum with the other Coord.
Definition: NanoVDB.h:1443
typename DataType::BuildT BuildType
Definition: NanoVDB.h:4974
float getValue(uint32_t i) const
Definition: NanoVDB.h:5591
uint32_t mSize
Definition: NanoVDB.h:4358
ValueIterator operator++(int)
Definition: NanoVDB.h:6153
typename DataType::ValueType ValueType
Definition: NanoVDB.h:6037
float type
Definition: NanoVDB.h:717
const CoordBBox & indexBBox() const
return AABB of active values in index space
Definition: NanoVDB.h:3667
bool operator==(const Rgba8 &rhs) const
Definition: NanoVDB.h:1931
Coord(ValueType *ptr)
Definition: NanoVDB.h:1326
uint64_t type
Definition: NanoVDB.h:731
typename ChildT::LeafNodeType LeafNodeType
Definition: NanoVDB.h:4975
Mask(const Mask &other)
Copy constructor.
Definition: NanoVDB.h:2942
const uint64_t & firstOffset() const
Definition: NanoVDB.h:5858
bool isActive(uint32_t n) const
Definition: NanoVDB.h:6274
const ValueType & background() const
Return a const reference to the background value.
Definition: NanoVDB.h:4056
Coord & operator=(const CoordT &other)
Assignment operator that works with openvdb::Coord.
Definition: NanoVDB.h:1355
uint64_t Type
Definition: NanoVDB.h:674
float getAvg() const
return the quantized average of the active values in this node
Definition: NanoVDB.h:5546
static void * memcpy64(void *dst, const void *src, size_t word_count)
copy 64 bit words from src to dst
Definition: NanoVDB.h:871
ValueOffIterator()
Definition: NanoVDB.h:6087
bool isActive() const
Definition: NanoVDB.h:4456
GridBlindDataClass
Blind-data Classes that are currently supported by NanoVDB.
Definition: NanoVDB.h:416
MaskT< LOG2DIM > mValueMask
Definition: NanoVDB.h:5970
DenseIterator operator++(int)
Definition: NanoVDB.h:2908
Vec4(T x)
Definition: NanoVDB.h:1736
const typename GridOrTreeOrRootT::RootNodeType Type
Definition: NanoVDB.h:3462
Visits all active values in a leaf node.
Definition: NanoVDB.h:6048
static uint32_t dim()
Return the dimension, in index space, of this leaf node (typically 8 as for openvdb leaf nodes!) ...
Definition: NanoVDB.h:6220
ChannelT * setChannel(uint32_t channelID)
Change to an internal channel, assuming it exists as as blind data in the IndexGrid.
Definition: NanoVDB.h:7781
Coord operator-() const
Definition: NanoVDB.h:1426