118#ifndef NANOVDB_NANOVDB_H_HAS_BEEN_INCLUDED
119#define NANOVDB_NANOVDB_H_HAS_BEEN_INCLUDED
126#define NANOVDB_MAGIC_NUMBER 0x304244566f6e614eUL
127#define NANOVDB_MAGIC_GRID 0x314244566f6e614eUL
128#define NANOVDB_MAGIC_FILE 0x324244566f6e614eUL
129#define NANOVDB_MAGIC_NODE 0x334244566f6e614eUL
130#define NANOVDB_MAGIC_MASK 0x00FFFFFFFFFFFFFFUL
133#define NANOVDB_MAJOR_VERSION_NUMBER 32
134#define NANOVDB_MINOR_VERSION_NUMBER 6
135#define NANOVDB_PATCH_VERSION_NUMBER 0
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)
162typedef signed char int8_t;
163typedef short int16_t;
165typedef long long int64_t;
166typedef unsigned char uint8_t;
167typedef unsigned int uint32_t;
168typedef unsigned short uint16_t;
169typedef unsigned long long uint64_t;
171#define NANOVDB_ASSERT(x)
173#define UINT64_C(x) (x ## ULL)
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)
205#if defined(__CUDACC__) || defined(__HIP__)
208#define __hostdev__ __host__ __device__
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)];
440template<
typename T0,
typename T1,
typename ...T>
446template<
typename T0,
typename T1>
449 static constexpr bool value =
false;
491template <
bool,
typename T =
void>
504template<
bool,
typename T =
void>
520 static constexpr bool value =
false;
536 static constexpr bool value =
false;
544 static constexpr bool value =
true;
552 static constexpr bool value =
true;
610template<
typename T,
typename ReferenceT>
621template<
typename T,
typename ReferenceT>
636template<
typename AnyType,
template<
typename...>
class TemplateType>
641template<
typename... Args,
template<
typename...>
class TemplateType>
768 return reinterpret_cast<const T*
>( (
const uint8_t*)p +
alignmentPadding(p) );
779template<
typename T1,
typename T2>
783 return reinterpret_cast<const char*
>(p) -
reinterpret_cast<const char*
>(q);
794template<
typename DstT,
typename SrcT>
798 return reinterpret_cast<DstT*
>(
reinterpret_cast<char*
>(p) + offset);
807template<
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);
997 return 3.141592653589793238462643383279502884e+00;
1002 return 3.141592653589793238462643383279502884e+00F;
1007 return 3.141592653589793238462643383279502884e+00;
1012 return 3.141592653589793238462643383279502884e+00L;
1052#if defined(__CUDA_ARCH__) || defined(__HIP__)
1059struct Maximum<uint32_t>
1064struct Maximum<float>
1069struct Maximum<double>
1077 static T
value() {
return std::numeric_limits<T>::max(); }
1082template<
typename Type>
1088template<
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)));
1109template<
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));
1187 return x < 0 ? -x : x;
1208template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
1211template<
typename CoordT,
template<
typename>
class Vec3T>
1214 return CoordT(int32_t(rintf(xyz[0])), int32_t(rintf(xyz[1])), int32_t(rintf(xyz[2])));
1219template<
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)));
1225template<
typename CoordT,
typename RealT,
template<
typename>
class Vec3T>
1247 return ((T(0) < x) ? T(1) : T(0)) - ((x < T(0)) ? T(1) : T(0));
1250template<
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])
1267template<
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])
1287template<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__)
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); }
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]);
1692template<
typename T1,
typename T2>
1695 return Vec3<T2>(scalar * vec[0], scalar * vec[1], scalar * vec[2]);
1697template<
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]));
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])
1839template<
typename T1,
typename T2>
1842 return Vec4<T2>(scalar * vec[0], scalar * vec[1], scalar * vec[2], scalar * vec[3]);
1844template<
typename T1,
typename T2>
1847 return Vec4<T2>(scalar / vec[0], scalar / vec[1], scalar / vec[2], scalar / vec[3]);
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));
1965template<
typename T,
int Rank = (is_specialization<T, Vec3>::value || is_specialization<T, Vec4>::value || is_same<T, Rgba8>::value) ? 1 : 0>
1971 static const int Rank = 0;
1972 static const bool IsScalar =
true;
1973 static const bool IsVector =
false;
1974 static const int Size = 1;
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;
1992template<
typename T,
int = sizeof(
typename TensorTraits<T>::ElementType)>
2049template<
typename BuildT>
2053 return GridType::Float;
2055 return GridType::Double;
2057 return GridType::Int16;
2059 return GridType::Int32;
2061 return GridType::Int64;
2063 return GridType::Vec3f;
2065 return GridType::Vec3d;
2067 return GridType::UInt32;
2069 return GridType::Mask;
2071 return GridType::Half;
2073 return GridType::Index;
2075 return GridType::OnIndex;
2077 return GridType::IndexMask;
2079 return GridType::OnIndexMask;
2081 return GridType::Boolean;
2083 return GridType::RGBA8;
2085 return GridType::Fp4;
2087 return GridType::Fp8;
2089 return GridType::Fp16;
2091 return GridType::FpN;
2093 return GridType::Vec4f;
2095 return GridType::Vec4d;
2097 return GridType::PointIndex;
2099 return GridType::Vec3u8;
2101 return GridType::Vec3u16;
2103 return GridType::Unknown;
2109template<
typename BuildT>
2113 return GridClass::Topology;
2115 return GridClass::IndexGrid;
2117 return GridClass::VoxelVolume;
2119 return GridClass::PointIndex;
2121 return defaultClass;
2132template<
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])));
2146template<
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])));
2161template<
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]))));
2176template<
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]))));
2190template<
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])));
2204template<
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])));
2212template<
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]))));
2220template<
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]))));
2231template<
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])
2294template<typename Vec3T, bool = is_floating_point<typename Vec3T::ValueType>::value>
2301template<
typename Vec3T>
2308 using BaseT::mCoord;
2326 return BBox(min, min.offsetBy(dim));
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]; }
2339 __hostdev__ Vec3T
dim()
const {
return *
this ? this->max() - this->min() : Vec3T(0); }
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];
2352template<
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;
2423 :
BaseT(CoordT::max(), CoordT::min())
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]);
2468 __hostdev__ bool isInside(
const CoordT& p)
const {
return !(CoordT::lessThan(p, this->min()) || CoordT::lessThan(this->max(), p)); }
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__)
2516 mCoord[0].minComponentAtomic(ijk);
2517 mCoord[1].maxComponentAtomic(ijk);
2520 __device__ inline BBox& expandAtomic(
const BBox& bbox)
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__)
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__)
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);
2654 return p[1] ? 32u + FindHighestOn(p[1]) : FindHighestOn(p[0]);
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);
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)))
2823template<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__)
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);
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];
3130 return b ? (n << 6) + FindLowestOn(b) : SIZE;
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];
3147 return b ? (n << 6) + FindHighestOn(b) : SIZE;
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>
3295template<
typename MatT,
typename Vec3T>
3296inline 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]);
3314template<
typename Vec3T>
3315inline 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{
3369 case GridType::Unknown:
return mValueSize==1u;
3370 case GridType::Float:
return mValueSize==4u;
3371 case GridType::Double:
return mValueSize==8u;
3372 case GridType::Int16:
return mValueSize==2u;
3373 case GridType::Int32:
return mValueSize==4u;
3374 case GridType::Int64:
return mValueSize==8u;
3375 case GridType::Vec3f:
return mValueSize==12u;
3376 case GridType::Vec3d:
return mValueSize==24u;
3377 case GridType::Half:
return mValueSize==2u;
3378 case GridType::RGBA8:
return mValueSize==4u;
3379 case GridType::Fp8:
return mValueSize==1u;
3380 case GridType::Fp16:
return mValueSize==2u;
3381 case GridType::Vec4f:
return mValueSize==16u;
3382 case GridType::Vec4d:
return mValueSize==32u;
3383 case GridType::Vec3u8:
return mValueSize==3u;
3384 case GridType::Vec3u16:
return mValueSize==6u;
3385 default:
return true;}
3395 return AlignUp<NANOVDB_DATA_ALIGNMENT>(mValueCount * mValueSize);
3403template<
typename Gr
idOrTreeOrRootT,
int LEVEL>
3407template<
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;
3414template<
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;
3422template<
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;
3429template<
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;
3436template<
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;
3443template<
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;
3450template<
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;
3458template<
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;
3468template<
typename BuildT>
3470template<
typename BuildT>
3472template<
typename BuildT>
3474template<
typename BuildT>
3476template<
typename BuildT>
3478template<
typename BuildT>
3480template<
typename BuildT>
3482template<
typename BuildT>
3513 static const int MaxNameSize = 256;
3521 char mGridName[MaxNameSize];
3534 static_assert(8 * 84 ==
sizeof(
GridData),
"GridData has unexpected size");
3538 __hostdev__ void init(std::initializer_list<GridFlags> list = {GridFlags::IsBreadthFirst},
3539 uint64_t gridSize = 0u,
3541 GridType gridType = GridType::Unknown,
3542 GridClass gridClass = GridClass::Unknown)
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;
3646 if (mFlags.
isMaskOn(GridFlags::HasLongGridName)) {
3648 for (uint32_t i = 0; i < mBlindMetadataCount; ++i) {
3649 const auto* metaData = this->blindMetaData(i);
3650 if (metaData->mDataClass == GridBlindDataClass::GridName) {
3652 return metaData->template getBlindData<const char>();
3671 if (
const uint8_t *root = this->nodePtr<3>()) {
3672 return *(
const uint32_t*)(root +
sizeof(
CoordBBox));
3687template<
typename BuildT,
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1>
3690template<
typename BuildT>
3697template<
typename TreeT>
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(); }
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>());
3909template<
typename TreeT>
3912 for (uint32_t i = 0, n = this->blindDataCount(); i < n; ++i) {
3913 if (this->blindMetaData(i).mSemantic == semantic)
3919template<
typename TreeT>
3922 auto test = [&](
int n) {
3923 const char* str = this->blindMetaData(n).mName;
3924 for (
int i = 0; i < GridBlindMetaData::MaxNameSize; ++i) {
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>
3972template<
typename Gr
idT>
3975 using Type =
typename GridT::TreeType;
3976 using type =
typename GridT::TreeType;
3978template<
typename Gr
idT>
3981 using Type =
const typename GridT::TreeType;
3982 using type =
const typename GridT::TreeType;
3988template<
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;
4028 RootT* ptr =
reinterpret_cast<RootT*
>(DataType::getRoot());
4035 const RootT* ptr =
reinterpret_cast<const RootT*
>(DataType::getRoot());
4059 __hostdev__ void extrema(ValueType& min, ValueType& max)
const;
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...);
4161template<
typename RootT>
4164 min = this->root().minimum();
4165 max = this->root().maximum();
4173template<
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);
4202 using KeyT = CoordT;
4203 __hostdev__ static KeyT CoordToKey(
const CoordT& ijk) {
return ijk & ~ChildT::MASK; }
4204 __hostdev__ static CoordT KeyToCoord(
const KeyT& key) {
return key; }
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;
4267 const auto key = CoordToKey(ijk);
4268 for (
Tile *p =
reinterpret_cast<Tile*
>(
this + 1), *q = p + mTableSize; p < q; ++p)
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);
4328template<
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
4641 __hostdev__ ValueType getValue(
const CoordType& ijk)
const
4643 if (
const Tile* tile = DataType::probeTile(ijk)) {
4644 return tile->isChild() ? this->getChild(tile)->getValue(ijk) : tile->value;
4646 return DataType::mBackground;
4648 __hostdev__ ValueType getValue(
int i,
int j,
int k)
const {
return this->getValue(CoordType(i, j, k)); }
4650 __hostdev__ bool isActive(
const CoordType& ijk)
const
4652 if (
const Tile* tile = DataType::probeTile(ijk)) {
4653 return tile->isChild() ? this->getChild(tile)->isActive(ijk) : tile->state;
4658 __hostdev__ bool probeValue(
const CoordType& ijk, ValueType& v)
const
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;
4672 __hostdev__ const LeafNodeType* probeLeaf(
const CoordType& ijk)
const
4674 const Tile* tile = DataType::probeTile(ijk);
4675 if (tile && tile->isChild()) {
4676 const auto* child = this->getChild(tile);
4677 return child->probeLeaf(ijk);
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...);
4722 static_assert(
sizeof(
typename DataType::Tile) %
NANOVDB_DATA_ALIGNMENT == 0,
"sizeof(RootData::Tile) is misaligned");
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>
4748 __hostdev__ ValueType getValueAndCache(
const CoordType& ijk,
const AccT& acc)
const
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>
4762 __hostdev__ bool isActiveAndCache(
const CoordType& ijk,
const AccT& acc)
const
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>
4774 __hostdev__ bool probeValueAndCache(
const CoordType& ijk, ValueType& v,
const AccT& acc)
const
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>
4790 __hostdev__ const LeafNodeType* probeLeafAndCache(
const CoordType& ijk,
const AccT& acc)
const
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);
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...);
4857template<
typename ChildT, u
int32_t LOG2DIM>
4864 using MaskT =
typename ChildT::template MaskType<LOG2DIM>;
4865 static constexpr bool FIXED_SIZE =
true;
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
4967template<
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
5222 __hostdev__ ValueType getValue(
const CoordType& ijk)
const
5224 const uint32_t n = CoordToOffset(ijk);
5225 return DataType::mChildMask.isOn(n) ? this->getChild(n)->getValue(ijk) : DataType::getValue(n);
5227 __hostdev__ bool isActive(
const CoordType& ijk)
const
5229 const uint32_t n = CoordToOffset(ijk);
5230 return DataType::mChildMask.isOn(n) ? this->getChild(n)->isActive(ijk) : DataType::isActive(n);
5232 __hostdev__ bool probeValue(
const CoordType& ijk, ValueType& v)
const
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);
5240 __hostdev__ const LeafNodeType* probeLeaf(
const CoordType& ijk)
const
5242 const uint32_t n = CoordToOffset(ijk);
5243 if (DataType::mChildMask.isOn(n))
5244 return this->getChild(n)->probeLeaf(ijk);
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();
5286 Coord ijk = InternalNode::OffsetToLocalCoord(n);
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>
5338 __hostdev__ bool isActiveAndCache(
const CoordType& ijk,
const AccT& acc)
const
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>
5348 __hostdev__ bool probeValueAndCache(
const CoordType& ijk, ValueType& v,
const AccT& acc)
const
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>
5360 __hostdev__ const LeafNodeType* probeLeafAndCache(
const CoordType& ijk,
const AccT& acc)
const
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);
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...);
5432template<
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)
5503template<
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>
5573template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5574struct 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;
5610template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5611struct 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;
5640template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5641struct 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;
5672template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5673struct 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
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;
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;
5737template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5738struct 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>
5787template<
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>
5836template<
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>
5871template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5897template<
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;
5932template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5934 :
public LeafData<ValueIndex, CoordT, MaskT, LOG2DIM>
5943template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5945 :
public LeafData<ValueOnIndex, CoordT, MaskT, LOG2DIM>
5956template<
typename CoordT,
template<u
int32_t>
class MaskT, uint32_t LOG2DIM>
5957struct 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>
6022template<
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>
6353 __hostdev__ typename AccT::NodeInfo getNodeInfoAndCache(
const CoordType& ,
const AccT& )
const
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...);
6399template<
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);
6424 update(FindLowestOn(word64) >> 3, FindHighestOn(word64) >> 3, 1);
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];
6429 update(FindLowestOn(
static_cast<uint32_t
>(
byte)), FindHighestOn(
static_cast<uint32_t
>(
byte)), 2);
6430 DataType::mFlags |= uint8_t(2);
6438template<
typename BuildT>
6440template<
typename BuildT>
6442template<
typename BuildT>
6444template<
typename BuildT>
6446template<
typename BuildT>
6448template<
typename BuildT>
6452template<
typename BuildT,
int LEVEL>
6456template<
typename BuildT>
6462template<
typename BuildT>
6468template<
typename BuildT>
6474template<
typename BuildT>
6545template<
typename BuildT>
6555 mutable const RootT* mRoot;
6561 static const int CacheLevels = 0;
6562#ifndef NANOVDB_NEW_ACCESSOR_METHODS
6603#ifdef NANOVDB_NEW_ACCESSOR_METHODS
6606 return this->
template get<GetValue<BuildT>>(ijk);
6616 __hostdev__ ValueType getValue(
const CoordType& ijk)
const
6618 return mRoot->getValueAndCache(ijk, *
this);
6620 __hostdev__ ValueType getValue(
int i,
int j,
int k)
const
6622 return this->getValue(CoordType(i, j, k));
6624 __hostdev__ ValueType operator()(
const CoordType& ijk)
const
6626 return this->getValue(ijk);
6628 __hostdev__ ValueType operator()(
int i,
int j,
int k)
const
6630 return this->getValue(CoordType(i, j, k));
6633 __hostdev__ NodeInfo getNodeInfo(
const CoordType& ijk)
const
6635 return mRoot->getNodeInfoAndCache(ijk, *
this);
6638 __hostdev__ bool isActive(
const CoordType& ijk)
const
6640 return mRoot->isActiveAndCache(ijk, *
this);
6643 __hostdev__ bool probeValue(
const CoordType& ijk, ValueType& v)
const
6645 return mRoot->probeValueAndCache(ijk, v, *
this);
6648 __hostdev__ const LeafT* probeLeaf(
const CoordType& ijk)
const
6650 return mRoot->probeLeafAndCache(ijk, *
this);
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>
6685template<
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;
6738 mKey = CoordType::max();
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);
6769 __hostdev__ ValueType getValue(
const CoordType& ijk)
const
6771 if (this->isCached(ijk))
6772 return mNode->getValueAndCache(ijk, *
this);
6773 return mRoot->getValueAndCache(ijk, *
this);
6775 __hostdev__ ValueType getValue(
int i,
int j,
int k)
const
6777 return this->getValue(CoordType(i, j, k));
6779 __hostdev__ ValueType operator()(
const CoordType& ijk)
const
6781 return this->getValue(ijk);
6783 __hostdev__ ValueType operator()(
int i,
int j,
int k)
const
6785 return this->getValue(CoordType(i, j, k));
6788 __hostdev__ NodeInfo getNodeInfo(
const CoordType& ijk)
const
6790 if (this->isCached(ijk))
6791 return mNode->getNodeInfoAndCache(ijk, *
this);
6792 return mRoot->getNodeInfoAndCache(ijk, *
this);
6795 __hostdev__ bool isActive(
const CoordType& ijk)
const
6797 if (this->isCached(ijk))
6798 return mNode->isActiveAndCache(ijk, *
this);
6799 return mRoot->isActiveAndCache(ijk, *
this);
6802 __hostdev__ bool probeValue(
const CoordType& ijk, ValueType& v)
const
6804 if (this->isCached(ijk))
6805 return mNode->probeValueAndCache(ijk, v, *
this);
6806 return mRoot->probeValueAndCache(ijk, v, *
this);
6809 __hostdev__ const LeafT* probeLeaf(
const CoordType& ijk)
const
6811 if (this->isCached(ijk))
6812 return mNode->probeLeafAndCache(ijk, *
this);
6813 return mRoot->probeLeafAndCache(ijk, *
this);
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>
6858 __hostdev__ void insert(
const CoordType&,
const OtherNodeT*)
const {}
6862template<
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
6881 mutable CoordT mKey;
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
6901 : mKey(CoordType::max())
6903 : mKeys{CoordType::max(), CoordType::max()}
6926#ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY
6927 mKey = CoordType::max();
6929 mKeys[0] = mKeys[1] = CoordType::max();
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)) {
6963 __hostdev__ CoordValueType computeDirty(
const CoordType& ijk)
const
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);
6996 __hostdev__ ValueType getValue(
const CoordType& ijk)
const
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);
7010 __hostdev__ ValueType operator()(
const CoordType& ijk)
const
7012 return this->getValue(ijk);
7014 __hostdev__ ValueType operator()(
int i,
int j,
int k)
const
7016 return this->getValue(CoordType(i, j, k));
7018 __hostdev__ ValueType getValue(
int i,
int j,
int k)
const
7020 return this->getValue(CoordType(i, j, k));
7022 __hostdev__ NodeInfo getNodeInfo(
const CoordType& ijk)
const
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);
7037 __hostdev__ bool isActive(
const CoordType& ijk)
const
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);
7052 __hostdev__ bool probeValue(
const CoordType& ijk, ValueType& v)
const
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);
7067 __hostdev__ const LeafT* probeLeaf(
const CoordType& ijk)
const
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);
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;
7150 __hostdev__ void insert(
const CoordType& ijk,
const Node2T* node)
const
7152#ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY
7155 mKeys[1] = ijk & ~Node2T::MASK;
7159 template<
typename OtherNodeT>
7160 __hostdev__ void insert(
const CoordType&,
const OtherNodeT*)
const {}
7164template<
typename BuildT>
7180#ifdef NANOVDB_USE_SINGLE_ACCESSOR_KEY
7181 mutable CoordT mKey;
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
7200 : mKey(CoordType::max())
7202 : mKeys{CoordType::max(), CoordType::max(), CoordType::max()}
7205 , mNode{
nullptr,
nullptr,
nullptr}
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
7251 mKey = CoordType::max();
7253 mKeys[0] = mKeys[1] = mKeys[2] = CoordType::max();
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;
7271 __hostdev__ CoordValueType computeDirty(
const CoordType& ijk)
const
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);
7299 __hostdev__ ValueType getValue(
const CoordType& ijk)
const
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);
7315 __hostdev__ ValueType operator()(
const CoordType& ijk)
const
7317 return this->getValue(ijk);
7319 __hostdev__ ValueType operator()(
int i,
int j,
int k)
const
7321 return this->getValue(CoordType(i, j, k));
7323 __hostdev__ ValueType getValue(
int i,
int j,
int k)
const
7325 return this->getValue(CoordType(i, j, k));
7328 __hostdev__ NodeInfo getNodeInfo(
const CoordType& ijk)
const
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);
7345 __hostdev__ bool isActive(
const CoordType& ijk)
const
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);
7362 __hostdev__ bool probeValue(
const CoordType& ijk, ValueType& v)
const
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);
7378 __hostdev__ const LeafT* probeLeaf(
const CoordType& ijk)
const
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);
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;
7486template<
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
7492template<
int LEVEL0 = -1,
int LEVEL1 = -1,
int LEVEL2 = -1,
typename ValueT =
float>
7498template<
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");
7529 if (GridMetaData::safeCast(gridData)) {
7532 mGridData = *gridData;
7551 template<
typename T>
7591template<
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);
7654template<
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;
7722template<
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>
7815struct 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)];
7920template<
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;
7940 Codec::NONE, 0u, gridData->
mVersion };
7941 os.write((
const char*)&head,
sizeof(
FileHeader));
7943 os.write(gridName, nameSize);
7945 os.write((
const char*)gridData, gridData->
mGridSize);
7950template<
typename GridHandleT,
template<
typename...>
class VecT>
7953#ifdef NANOVDB_USE_IOSTREAMS
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) {
7978template<
typename GridHandleT,
typename StreamT,
template<
typename...>
class VecT>
7979VecT<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);
7989 sum += data.mGridSize;
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());
8005 }
else if (head.
codec != Codec::NONE) {
8006 fprintf(stderr,
"nanovdb::readUncompressedGrids: invalid codec = \"%s\"\n",
toStr(head.
codec));
8010 for (uint16_t i = 0; i < head.
gridCount; ++i) {
8012 is.skip(meta.nameSize);
8013 auto buffer = GridHandleT::BufferType::create(meta.gridSize, &pool);
8014 is.read((
char*)buffer.data(), meta.gridSize);
8015 handles.emplace_back(std::move(buffer));
8023template<
typename GridHandleT,
template<
typename...>
class VecT>
8024VecT<GridHandleT>
readUncompressedGrids(
const char* fileName,
const typename GridHandleT::BufferType& buffer =
typename GridHandleT::BufferType())
8026#ifdef NANOVDB_USE_IOSTREAMS
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);
8061template<
typename BuildT>
8071template<
typename BuildT>
8083template<
typename BuildT>
8097template<
typename BuildT>
8109template<
typename BuildT>
8121template<
typename BuildT>
8133template<
typename BuildT>
8145template<
typename BuildT>
8157template<
typename BuildT>
8169 return tile.state > 0u;
8190template<
typename BuildT>
#define NANOVDB_MAGIC_FILE
Definition NanoVDB.h:128
#define NANOVDB_HOSTDEV_DISABLE_WARNING
Definition NanoVDB.h:234
#define NANOVDB_MAGIC_GRID
Definition NanoVDB.h:127
#define NANOVDB_MINOR_VERSION_NUMBER
Definition NanoVDB.h:134
#define NANOVDB_DATA_ALIGNMENT
Definition NanoVDB.h:154
#define __hostdev__
Definition NanoVDB.h:213
#define NANOVDB_MAJOR_VERSION_NUMBER
Definition NanoVDB.h:133
#define NANOVDB_ASSERT(x)
Definition NanoVDB.h:190
#define NANOVDB_MAGIC_NUMBER
Definition NanoVDB.h:126
#define NANOVDB_PATCH_VERSION_NUMBER
Definition NanoVDB.h:135
#define __device__
Definition NanoVDB.h:219
Iterator over the domain covered by a BBox.
Definition NanoVDB.h:2361
bool operator<(const Iterator &rhs) const
Definition NanoVDB.h:2406
const CoordT & operator*() const
Definition NanoVDB.h:2418
Iterator(const BBox &b, const Coord &p)
Definition NanoVDB.h:2371
bool operator<=(const Iterator &rhs) const
Definition NanoVDB.h:2411
bool operator==(const Iterator &rhs) const
Definition NanoVDB.h:2396
Iterator(const BBox &b)
Definition NanoVDB.h:2366
Iterator operator++(int)
Definition NanoVDB.h:2390
bool operator!=(const Iterator &rhs) const
Definition NanoVDB.h:2401
Iterator & operator++()
Definition NanoVDB.h:2376
Definition NanoVDB.h:2709
bool isBitOff(uint8_t bit) const
Definition NanoVDB.h:2788
BitFlags(std::initializer_list< uint8_t > list)
Definition NanoVDB.h:2716
Type data() const
Definition NanoVDB.h:2727
void setBitOn(std::initializer_list< uint8_t > list)
Definition NanoVDB.h:2752
void initMask(std::initializer_list< MaskT > list)
Definition NanoVDB.h:2736
void setBit(uint8_t bit, bool on)
Definition NanoVDB.h:2781
void setMaskOff(std::initializer_list< MaskT > list)
Definition NanoVDB.h:2775
void initBit(std::initializer_list< uint8_t > list)
Definition NanoVDB.h:2729
void setOn()
Definition NanoVDB.h:2746
BitFlags()
Definition NanoVDB.h:2715
void setMaskOff(MaskT mask)
Definition NanoVDB.h:2766
Type & data()
Definition NanoVDB.h:2728
void setBitOn(uint8_t bit)
Definition NanoVDB.h:2749
bool isMaskOff(std::initializer_list< MaskT > list) const
return true if any of the masks in the list are off
Definition NanoVDB.h:2804
bool isMaskOn(MaskT mask) const
Definition NanoVDB.h:2790
void setMaskOn(std::initializer_list< MaskT > list)
Definition NanoVDB.h:2769
bool isMaskOn(std::initializer_list< MaskT > list) const
return true if any of the masks in the list are on
Definition NanoVDB.h:2795
BitFlags(std::initializer_list< MaskT > list)
Definition NanoVDB.h:2722
void setBitOff(std::initializer_list< uint8_t > list)
Definition NanoVDB.h:2757
void setOff()
Definition NanoVDB.h:2747
void setMaskOn(MaskT mask)
Definition NanoVDB.h:2764
void setBitOff(uint8_t bit)
Definition NanoVDB.h:2750
BitFlags & operator=(Type n)
required for backwards compatibility
Definition NanoVDB.h:2812
bool isOff() const
Definition NanoVDB.h:2786
bool isBitOn(uint8_t bit) const
Definition NanoVDB.h:2787
void setMask(MaskT mask, bool on)
Definition NanoVDB.h:2783
Type getFlags() const
Definition NanoVDB.h:2744
decltype(mFlags) Type
Definition NanoVDB.h:2714
bool isMaskOff(MaskT mask) const
Definition NanoVDB.h:2792
bool isOn() const
Definition NanoVDB.h:2785
Class to access values in channels at a specific voxel location.
Definition NanoVDB.h:7724
const TreeType & tree() const
Return a const reference to the tree of the IndexGrid.
Definition NanoVDB.h:7765
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
uint64_t getIndex(const Coord &ijk) const
Return the linear offset into a channel that maps to the specified coordinate.
Definition NanoVDB.h:7787
ChannelT * setChannel(uint32_t channelID)
Change to an internal channel, assuming it exists as as blind data in the IndexGrid.
Definition NanoVDB.h:7781
const Vec3d & voxelSize() const
Return a vector of the axial voxel sizes.
Definition NanoVDB.h:7768
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
const NanoGrid< IndexT > & grid() const
Return a const reference to the IndexGrid.
Definition NanoVDB.h:7762
const uint64_t & valueCount() const
Return total number of values indexed by the IndexGrid.
Definition NanoVDB.h:7771
ChannelT & operator()(int i, int j, int k) const
Definition NanoVDB.h:7793
uint64_t idx(int i, int j, int k) const
Definition NanoVDB.h:7788
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
ChannelAccessor(const NanoGrid< IndexT > &grid, ChannelT *channelPtr)
Ctor from an IndexGrid and an external channel.
Definition NanoVDB.h:7749
ChannelT * setChannel(ChannelT *channelPtr)
Change to an external channel.
Definition NanoVDB.h:7775
ChannelT ValueType
Definition NanoVDB.h:7732
ChannelT & getValue(const Coord &ijk) const
Return the value from a cached channel that maps to the specified coordinate.
Definition NanoVDB.h:7791
ChannelT & operator()(const Coord &ijk) const
Definition NanoVDB.h:7792
Signed (i, j, k) 32-bit integer coordinate class, similar to openvdb::math::Coord.
Definition NanoVDB.h:1302
Coord & operator&=(int n)
Definition NanoVDB.h:1396
Coord round() const
Definition NanoVDB.h:1522
Coord operator-(const Coord &rhs) const
Definition NanoVDB.h:1425
Vec3< double > asVec3d() const
Return a double precision floating-point vector of this coordinate.
Definition NanoVDB.h:1718
Coord operator-() const
Definition NanoVDB.h:1426
uint32_t IndexType
Definition NanoVDB.h:1306
Coord operator<<(IndexType n) const
Definition NanoVDB.h:1368
static Coord Floor(const Vec3T &xyz)
Return the largest integer coordinates that are not greater than xyz (node centered conversion).
Definition NanoVDB.h:1499
Coord(ValueType n)
Initializes all coordinates to the given signed integer.
Definition NanoVDB.h:1315
Coord & operator-=(const Coord &rhs)
Definition NanoVDB.h:1434
Coord & operator>>=(uint32_t n)
Definition NanoVDB.h:1410
Coord & minComponent(const Coord &other)
Perform a component-wise minimum with the other Coord.
Definition NanoVDB.h:1443
Coord operator+(const Coord &rhs) const
Definition NanoVDB.h:1424
static size_t memUsage()
Definition NanoVDB.h:1343
bool operator<(const Coord &rhs) const
Return true if this Coord is lexicographically less than the given Coord.
Definition NanoVDB.h:1374
Coord & operator+=(const Coord &rhs)
Definition NanoVDB.h:1427
Coord & operator=(const CoordT &other)
Assignment operator that works with openvdb::Coord.
Definition NanoVDB.h:1355
int32_t y() const
Definition NanoVDB.h:1332
Coord & maxComponent(const Coord &other)
Perform a component-wise maximum with the other Coord.
Definition NanoVDB.h:1455
Coord operator&(IndexType n) const
Return a new instance with coordinates masked by the given unsigned integer.
Definition NanoVDB.h:1365
Coord()
Initialize all coordinates to zero.
Definition NanoVDB.h:1309
uint8_t octant() const
Return the octant of this Coord.
Definition NanoVDB.h:1511
const ValueType & operator[](IndexType i) const
Return a const reference to the given Coord component.
Definition NanoVDB.h:1347
int32_t z() const
Definition NanoVDB.h:1333
Coord & operator<<=(uint32_t n)
Definition NanoVDB.h:1403
int32_t x() const
Definition NanoVDB.h:1331
Coord(ValueType i, ValueType j, ValueType k)
Initializes coordinate to the given signed integers.
Definition NanoVDB.h:1321
int32_t & y()
Definition NanoVDB.h:1336
Coord offsetBy(ValueType n) const
Definition NanoVDB.h:1487
int32_t & x()
Definition NanoVDB.h:1335
Coord(ValueType *ptr)
Definition NanoVDB.h:1326
bool operator!=(const Coord &rhs) const
Definition NanoVDB.h:1395
static Coord min()
Definition NanoVDB.h:1341
ValueType & operator[](IndexType i)
Return a non-const reference to the given Coord component.
Definition NanoVDB.h:1351
bool operator==(const Coord &rhs) const
Definition NanoVDB.h:1394
Vec3< float > asVec3s() const
Return a single precision floating-point vector of this coordinate.
Definition NanoVDB.h:1712
bool operator<=(const Coord &rhs) const
Return true if this Coord is lexicographically less or equal to the given Coord.
Definition NanoVDB.h:1384
Coord offsetBy(ValueType dx, ValueType dy, ValueType dz) const
Definition NanoVDB.h:1482
static Coord max()
Definition NanoVDB.h:1339
int32_t & z()
Definition NanoVDB.h:1337
static bool lessThan(const Coord &a, const Coord &b)
Definition NanoVDB.h:1491
Coord operator>>(IndexType n) const
Definition NanoVDB.h:1371
uint32_t hash() const
Return a hash key derived from the existing coordinates.
Definition NanoVDB.h:1507
int32_t ValueType
Definition NanoVDB.h:1305
Coord & operator+=(int n)
Definition NanoVDB.h:1417
Dummy type for a 16bit quantization of float point values.
Definition NanoVDB.h:293
Dummy type for a 4bit quantization of float point values.
Definition NanoVDB.h:283
Dummy type for a 8bit quantization of float point values.
Definition NanoVDB.h:288
Dummy type for a variable bit quantization of floating point values.
Definition NanoVDB.h:298
Highest level of the data structure. Contains a tree and a world->index transform (that currently onl...
Definition NanoVDB.h:3699
Vec3T indexToWorld(const Vec3T &xyz) const
index to world space transformation
Definition NanoVDB.h:3773
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 Vec3d & voxelSize() const
Return a const reference to the size of a voxel in world units.
Definition NanoVDB.h:3762
BlindDataT * getBlindData(uint32_t n)
Definition NanoVDB.h:3897
Vec3T indexToWorldF(const Vec3T &xyz) const
index to world space transformation
Definition NanoVDB.h:3796
const GridType & gridType() const
Definition NanoVDB.h:3827
typename RootType::LeafNodeType LeafNodeType
Definition NanoVDB.h:3706
uint32_t blindDataCount() const
Return true if this grid is empty, i.e. contains no values or nodes.
Definition NanoVDB.h:3870
typename TreeT::ValueType ValueType
Definition NanoVDB.h:3708
int findBlindDataForSemantic(GridBlindDataSemantic semantic) const
Return the index of the first blind data with specified semantic if found, otherwise -1.
Definition NanoVDB.h:3910
typename TreeT::RootType RootType
Definition NanoVDB.h:3702
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
enable_if< BuildTraits< T >::is_index, constuint64_t & >::type valueCount() const
Return the total number of values indexed by this IndexGrid.
Definition NanoVDB.h:3743
bool isPointData() const
Definition NanoVDB.h:3834
uint32_t gridIndex() const
Return index of this grid in the buffer.
Definition NanoVDB.h:3733
const char * shortGridName() const
Return a c-string with the name of this grid, truncated to 255 characters.
Definition NanoVDB.h:3861
bool isBreadthFirst() const
Definition NanoVDB.h:3842
uint64_t activeVoxelCount() const
Computes a AABB of active values in world space.
Definition NanoVDB.h:3823
bool isSequential() const
return true if nodes at all levels can safely be accessed with simple linear offsets
Definition NanoVDB.h:3855
Vec3T indexToWorldDirF(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition NanoVDB.h:3801
typename TreeT::CoordType CoordType
Definition NanoVDB.h:3710
typename RootNodeType::ChildNodeType UpperNodeType
Definition NanoVDB.h:3704
Vec3T worldToIndexF(const Vec3T &xyz) const
world to index space transformation
Definition NanoVDB.h:3792
Vec3T worldToIndexDirF(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition NanoVDB.h:3806
bool isStaggered() const
Definition NanoVDB.h:3831
const GridClass & gridClass() const
Definition NanoVDB.h:3828
bool isValid() const
Methods related to the classification of this grid.
Definition NanoVDB.h:3826
DataType * data()
Definition NanoVDB.h:3722
bool hasAverage() const
Definition NanoVDB.h:3840
bool hasMinMax() const
Definition NanoVDB.h:3837
const BlindDataT * getBlindData(uint32_t n) const
Definition NanoVDB.h:3890
const char * gridName() const
Return a c-string with the name of this grid.
Definition NanoVDB.h:3858
AccessorType getAccessor() const
Return a new instance of a ReadAccessor used to access values in this grid.
Definition NanoVDB.h:3759
uint64_t gridSize() const
Return memory usage in bytes for this class only.
Definition NanoVDB.h:3730
const GridBlindMetaData & blindMetaData(uint32_t n) const
Definition NanoVDB.h:3903
Vec3T indexToWorldDir(const Vec3T &dir) const
transformation from index space direction to world space direction
Definition NanoVDB.h:3778
RootType RootNodeType
Definition NanoVDB.h:3703
Vec3T indexToWorldGradF(const Vec3T &grad) const
Transforms the gradient from index space to world space.
Definition NanoVDB.h:3811
uint64_t checksum() const
Return checksum of the grid buffer.
Definition NanoVDB.h:3864
bool isFogVolume() const
Definition NanoVDB.h:3830
const TreeT & tree() const
Return a const reference to the tree.
Definition NanoVDB.h:3753
bool isMask() const
Definition NanoVDB.h:3835
bool hasLongGridName() const
Definition NanoVDB.h:3839
const void * blindData(uint32_t n) const
Returns a const pointer to the blindData at the specified linear offset.
Definition NanoVDB.h:3882
TreeT & tree()
Return a non-const reference to the tree.
Definition NanoVDB.h:3756
Vec3T worldToIndex(const Vec3T &xyz) const
world to index space transformation
Definition NanoVDB.h:3769
uint32_t gridCount() const
Return total number of grids in the buffer.
Definition NanoVDB.h:3736
Vec3T worldToIndexDir(const Vec3T &dir) const
transformation from world space direction to index space direction
Definition NanoVDB.h:3783
Version version() const
Definition NanoVDB.h:3720
typename UpperNodeType::ChildNodeType LowerNodeType
Definition NanoVDB.h:3705
const Map & map() const
Return a const reference to the Map for this grid.
Definition NanoVDB.h:3765
bool hasStdDeviation() const
Definition NanoVDB.h:3841
bool hasBBox() const
Definition NanoVDB.h:3838
bool isLevelSet() const
Definition NanoVDB.h:3829
bool isGridIndex() const
Definition NanoVDB.h:3833
TreeT TreeType
Definition NanoVDB.h:3701
Grid(const Grid &)=delete
Disallow constructions, copy and assignment.
typename TreeT::BuildType BuildType
Definition NanoVDB.h:3709
enable_if< is_same< T, Point >::value, constuint64_t & >::type pointCount() const
Return the total number of points indexed by this PointGrid.
Definition NanoVDB.h:3750
Grid & operator=(const Grid &)=delete
Vec3T indexToWorldGrad(const Vec3T &grad) const
transform the gradient from index space to world space.
Definition NanoVDB.h:3788
const DataType * data() const
Definition NanoVDB.h:3724
bool isPointIndex() const
Definition NanoVDB.h:3832
bool isUnknown() const
Definition NanoVDB.h:3836
Dummy type for a 16 bit floating point values.
Definition NanoVDB.h:278
Visits child nodes of this node only.
Definition NanoVDB.h:4995
ChildIter & operator=(const ChildIter &)=default
NodeT & operator*() const
Definition NanoVDB.h:5013
CoordType getOrigin() const
Definition NanoVDB.h:5023
ChildIter()
Definition NanoVDB.h:5002
NodeT * operator->() const
Definition NanoVDB.h:5018
ChildIter(ParentT *parent)
Definition NanoVDB.h:5007
CoordType getCoord() const
Definition NanoVDB.h:5028
Visits all tile values and child nodes of this node.
Definition NanoVDB.h:5112
DenseIterator()
Definition NanoVDB.h:5117
bool isValueOn() const
Definition NanoVDB.h:5139
DenseIterator & operator=(const DenseIterator &)=default
const ChildT * probeChild(ValueType &value) const
Definition NanoVDB.h:5128
CoordType getOrigin() const
Definition NanoVDB.h:5144
DenseIterator(const InternalNode *parent)
Definition NanoVDB.h:5122
CoordType getCoord() const
Definition NanoVDB.h:5149
Visits all tile values in this node, i.e. both inactive and active tiles.
Definition NanoVDB.h:5039
ValueIterator & operator=(const ValueIterator &)=default
ValueIterator(const InternalNode *parent)
Definition NanoVDB.h:5049
bool isActive() const
Definition NanoVDB.h:5066
ValueIterator()
Definition NanoVDB.h:5044
CoordType getOrigin() const
Definition NanoVDB.h:5060
ValueType operator*() const
Definition NanoVDB.h:5055
CoordType getCoord() const
Definition NanoVDB.h:5065
Visits active tile values of this node only.
Definition NanoVDB.h:5078
ValueOnIterator(const InternalNode *parent)
Definition NanoVDB.h:5088
ValueOnIterator & operator=(const ValueOnIterator &)=default
CoordType getOrigin() const
Definition NanoVDB.h:5099
ValueType operator*() const
Definition NanoVDB.h:5094
ValueOnIterator()
Definition NanoVDB.h:5083
CoordType getCoord() const
Definition NanoVDB.h:5104
Internal nodes of a VDB treedim(),.
Definition NanoVDB.h:4969
auto get(const CoordType &ijk, ArgsT &&... args) const
Definition NanoVDB.h:5295
Coord offsetToGlobalCoord(uint32_t n) const
Definition NanoVDB.h:5284
ValueType getLastValue() const
If the last entry in this node's table is a tile, return the tile's value. Otherwise,...
Definition NanoVDB.h:5209
ChildNodeType * probeChild(const CoordType &ijk)
Definition NanoVDB.h:5250
const MaskType< LOG2DIM > & valueMask() const
Return a const reference to the bit mask of active voxels in this internal node.
Definition NanoVDB.h:5172
ValueIterator beginValue() const
Definition NanoVDB.h:5073
bool isActive() const
Return true if this node or any of its child nodes contain active values.
Definition NanoVDB.h:5292
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
static size_t memUsage()
Return memory usage in bytes for the class.
Definition NanoVDB.h:5169
DenseIterator beginDense() const
Definition NanoVDB.h:5152
CoordType origin() const
Return the origin in index space of this leaf node.
Definition NanoVDB.h:5180
typename ChildT::CoordType CoordType
Definition NanoVDB.h:4977
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
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
const MaskType< LOG2DIM > & childMask() const
Return a const reference to the bit mask of child nodes in this internal node.
Definition NanoVDB.h:5176
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
DataType * data()
Definition NanoVDB.h:5161
void localToGlobalCoord(Coord &ijk) const
modifies local coordinates to global coordinates of a tile or child node
Definition NanoVDB.h:5278
typename DataType::BuildT BuildType
Definition NanoVDB.h:4974
const MaskType< LOG2DIM > & getValueMask() const
Definition NanoVDB.h:5173
typename Mask< Log2Dim >::template Iterator< On > MaskIterT
Definition NanoVDB.h:4982
ChildT ChildNodeType
Definition NanoVDB.h:4976
const LeafNodeType * probeLeaf(const CoordType &ijk) const
Definition NanoVDB.h:5220
bool isActive(const CoordType &ijk) const
Definition NanoVDB.h:5217
typename DataType::ValueT ValueType
Definition NanoVDB.h:4972
static uint32_t CoordToOffset(const CoordType &ijk)
Return the linear offset corresponding to the given coordinate.
Definition NanoVDB.h:5262
typename DataType::StatsT FloatType
Definition NanoVDB.h:4973
ChildIterator beginChild()
Definition NanoVDB.h:5034
DenseIterator cbeginChildAll() const
Definition NanoVDB.h:5153
static Coord OffsetToLocalCoord(uint32_t n)
Definition NanoVDB.h:5270
bool probeValue(const CoordType &ijk, ValueType &v) const
return the state and updates the value of the specified voxel
Definition NanoVDB.h:5219
typename ChildT::LeafNodeType LeafNodeType
Definition NanoVDB.h:4975
ValueType getFirstValue() const
If the first entry in this node's table is a tile, return the tile's value. Otherwise,...
Definition NanoVDB.h:5202
const ChildNodeType * probeChild(const CoordType &ijk) const
Definition NanoVDB.h:5255
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
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
InternalNode()=delete
This class cannot be constructed or deleted.
ValueIterator cbeginValueAll() const
Definition NanoVDB.h:5074
ValueOnIterator cbeginValueOn() const
Definition NanoVDB.h:5108
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel.
Definition NanoVDB.h:5216
const MaskType< LOG2DIM > & getChildMask() const
Definition NanoVDB.h:5177
typename ChildT::template MaskType< LOG2 > MaskType
Definition NanoVDB.h:4980
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
const DataType * data() const
Definition NanoVDB.h:5163
InternalNode & operator=(const InternalNode &)=delete
decltype(OpT::set(std::declval< InternalNode & >(), std::declval< uint32_t >(), std::declval< ArgsT >()...)) set(const CoordType &ijk, ArgsT &&... args)
Definition NanoVDB.h:5306
ConstChildIterator cbeginChild() const
Definition NanoVDB.h:5035
InternalNode(const InternalNode &)=delete
ValueOnIterator beginValueOn() const
Definition NanoVDB.h:5107
Visits all values in a leaf node, i.e. both active and inactive values.
Definition NanoVDB.h:6115
ValueIterator & operator=(const ValueIterator &)=default
ValueIterator & operator++()
Definition NanoVDB.h:6148
ValueIterator operator++(int)
Definition NanoVDB.h:6153
ValueIterator(const LeafNode *parent)
Definition NanoVDB.h:6125
bool isActive() const
Definition NanoVDB.h:6142
CoordT getCoord() const
Definition NanoVDB.h:6137
ValueIterator()
Definition NanoVDB.h:6120
ValueType operator*() const
Definition NanoVDB.h:6132
Visits all inactive values in a leaf node.
Definition NanoVDB.h:6082
ValueOffIterator()
Definition NanoVDB.h:6087
CoordT getCoord() const
Definition NanoVDB.h:6103
ValueOffIterator & operator=(const ValueOffIterator &)=default
ValueType operator*() const
Definition NanoVDB.h:6098
ValueOffIterator(const LeafNode *parent)
Definition NanoVDB.h:6092
Visits all active values in a leaf node.
Definition NanoVDB.h:6049
CoordT getCoord() const
Definition NanoVDB.h:6070
ValueOnIterator(const LeafNode *parent)
Definition NanoVDB.h:6059
ValueOnIterator & operator=(const ValueOnIterator &)=default
ValueType operator*() const
Definition NanoVDB.h:6065
ValueOnIterator()
Definition NanoVDB.h:6054
Leaf nodes of the VDB tree. (defaults to 8x8x8 = 512 voxels)
Definition NanoVDB.h:6027
void setValue(const CoordT &ijk, const ValueType &v)
Sets the value at the specified location and activate its state.
Definition NanoVDB.h:6264
auto get(const CoordType &ijk, ArgsT &&... args) const
Definition NanoVDB.h:6312
void setValueOnly(uint32_t offset, const ValueType &v)
Sets the value at the specified location but leaves its state unchanged.
Definition NanoVDB.h:6269
bool isActive(const CoordT &ijk) const
Return true if the voxel value at the given coordinate is active.
Definition NanoVDB.h:6273
ValueType getLastValue() const
Return the last value in this leaf node.
Definition NanoVDB.h:6259
typename DataType::BuildType BuildType
Definition NanoVDB.h:6039
const MaskType< LOG2DIM > & valueMask() const
Return a const reference to the bit mask of active voxels in this leaf node.
Definition NanoVDB.h:6178
ValueIterator beginValue() const
Definition NanoVDB.h:6161
bool isActive() const
Return true if any of the voxel value are active in this leaf node.
Definition NanoVDB.h:6277
CoordT CoordType
Definition NanoVDB.h:6040
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
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
FloatType variance() const
Return the variance of all the active values encoded in this leaf node.
Definition NanoVDB.h:6191
ValueOffIterator cbeginValueOff() const
Definition NanoVDB.h:6111
LeafNode & operator=(const LeafNode &)=delete
auto set(const CoordType &ijk, ArgsT &&... args)
Definition NanoVDB.h:6324
bool isActive(uint32_t n) const
Definition NanoVDB.h:6274
DataType * data()
Definition NanoVDB.h:6173
uint8_t flags() const
Definition NanoVDB.h:6196
void localToGlobalCoord(Coord &ijk) const
Converts (in place) a local index coordinate to a global index coordinate.
Definition NanoVDB.h:6212
ValueType maximum() const
Return a const reference to the maximum active value encoded in this leaf node.
Definition NanoVDB.h:6185
const MaskType< LOG2DIM > & getValueMask() const
Definition NanoVDB.h:6179
typename DataType::FloatType FloatType
Definition NanoVDB.h:6038
CoordT origin() const
Return the origin in index space of this leaf node.
Definition NanoVDB.h:6199
typename Mask< Log2Dim >::template Iterator< ON > MaskIterT
Definition NanoVDB.h:6045
auto get(const uint32_t n, ArgsT &&... args) const
Definition NanoVDB.h:6318
static uint32_t CoordToOffset(const CoordT &ijk)
Return the linear offset corresponding to the given coordinate.
Definition NanoVDB.h:6297
CoordT offsetToGlobalCoord(uint32_t n) const
Definition NanoVDB.h:6214
void setValueOnly(const CoordT &ijk, const ValueType &v)
Definition NanoVDB.h:6270
ValueType getValue(uint32_t offset) const
Return the voxel value at the given offset.
Definition NanoVDB.h:6251
uint64_t memUsage() const
return memory usage in bytes for the leaf node
Definition NanoVDB.h:6242
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 LeafNode * probeLeaf(const CoordT &) const
Definition NanoVDB.h:6294
ValueType getFirstValue() const
Return the first value in this leaf node.
Definition NanoVDB.h:6257
ValueType getValue(const CoordT &ijk) const
Return the voxel value at the given coordinate.
Definition NanoVDB.h:6254
MaskT< LOG2 > MaskType
Definition NanoVDB.h:6043
static uint32_t voxelCount()
Return the total number of voxels (e.g. values) encoded in this leaf node.
Definition NanoVDB.h:6237
auto set(const uint32_t n, ArgsT &&... args)
Definition NanoVDB.h:6330
LeafNode(const LeafNode &)=delete
ValueOffIterator beginValueOff() const
Definition NanoVDB.h:6110
BBox< CoordT > bbox() const
Return the bounding box in index space of active values in this leaf node.
Definition NanoVDB.h:6223
LeafNode()=delete
This class cannot be constructed or deleted.
ValueIterator cbeginValueAll() const
Definition NanoVDB.h:6162
ValueOnIterator cbeginValueOn() const
Definition NanoVDB.h:6078
ValueType minimum() const
Return a const reference to the minimum active value encoded in this leaf node.
Definition NanoVDB.h:6182
typename DataType::ValueType ValueType
Definition NanoVDB.h:6037
static uint32_t padding()
Definition NanoVDB.h:6239
static CoordT OffsetToLocalCoord(uint32_t n)
Compute the local coordinates from a linear offset.
Definition NanoVDB.h:6204
bool hasBBox() const
Definition NanoVDB.h:6284
const DataType * data() const
Definition NanoVDB.h:6175
ValueOnIterator beginValueOn() const
Definition NanoVDB.h:6077
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
Definition NanoVDB.h:2893
DenseIterator & operator++()
Definition NanoVDB.h:2903
DenseIterator & operator=(const DenseIterator &)=default
DenseIterator(uint32_t pos=Mask::SIZE)
Definition NanoVDB.h:2895
uint32_t operator*() const
Definition NanoVDB.h:2900
DenseIterator operator++(int)
Definition NanoVDB.h:2908
uint32_t pos() const
Definition NanoVDB.h:2901
Definition NanoVDB.h:2859
Iterator()
Definition NanoVDB.h:2861
Iterator & operator=(const Iterator &)=default
uint32_t operator*() const
Definition NanoVDB.h:2872
Iterator operator++(int)
Definition NanoVDB.h:2880
uint32_t pos() const
Definition NanoVDB.h:2873
Iterator(uint32_t pos, const Mask *parent)
Definition NanoVDB.h:2866
Iterator & operator++()
Definition NanoVDB.h:2875
Bit-mask to encode active states and facilitate sequential iterators and a fast codec for I/O compres...
Definition NanoVDB.h:2825
uint32_t findPrev(uint32_t start) const
Definition NanoVDB.h:3135
DenseIterator beginAll() const
Definition NanoVDB.h:2926
OnIterator beginOn() const
Definition NanoVDB.h:2922
bool isOff(uint32_t n) const
Return true if the given bit is NOT set.
Definition NanoVDB.h:2986
bool operator==(const Mask &other) const
Definition NanoVDB.h:2971
uint32_t findFirst() const
Definition NanoVDB.h:3107
static size_t memUsage()
Return the memory footprint in bytes of this Mask.
Definition NanoVDB.h:2831
OffIterator beginOff() const
Definition NanoVDB.h:2924
void setOn()
Set all bits on.
Definition NanoVDB.h:3039
void toggle(uint32_t n)
Definition NanoVDB.h:3066
void set(uint32_t n, bool on)
Set the specified bit on or off.
Definition NanoVDB.h:3026
uint32_t countOn() const
Return the total number of set bits in this Mask.
Definition NanoVDB.h:2840
Mask & operator^=(const Mask &other)
Bitwise XOR.
Definition NanoVDB.h:3096
void setOff(uint32_t n)
Set the specified bit off.
Definition NanoVDB.h:3009
Mask(const Mask &other)
Copy constructor.
Definition NanoVDB.h:2942
Mask(bool on)
Definition NanoVDB.h:2934
bool isOn(uint32_t n) const
Return true if the given bit is set.
Definition NanoVDB.h:2983
void set(bool on)
Set all bits off.
Definition NanoVDB.h:3053
Mask & operator|=(const Mask &other)
Bitwise union.
Definition NanoVDB.h:3078
uint32_t findNext(uint32_t start) const
Definition NanoVDB.h:3118
const uint64_t * words() const
Definition NanoVDB.h:2950
uint64_t * words()
Return a pointer to the list of words of the bit mask.
Definition NanoVDB.h:2949
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
void setOff()
Set all bits off.
Definition NanoVDB.h:3046
Mask & operator&=(const Mask &other)
Bitwise intersection.
Definition NanoVDB.h:3069
static uint32_t bitCount()
Return the number of bits available in this Mask.
Definition NanoVDB.h:2834
bool isOff() const
Return true if none of the bits are set in this Mask.
Definition NanoVDB.h:2998
bool operator!=(const Mask &other) const
Definition NanoVDB.h:2980
Mask & operator=(const Mask &other)
Definition NanoVDB.h:2965
void toggle()
brief Toggle the state of all bits in the mask
Definition NanoVDB.h:3060
Mask & operator-=(const Mask &other)
Bitwise difference.
Definition NanoVDB.h:3087
static uint32_t wordCount()
Return the number of machine words used by this Mask.
Definition NanoVDB.h:2837
bool isOn() const
Return true if all the bits are set in this Mask.
Definition NanoVDB.h:2989
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
Mask()
Initialize all bits to zero.
Definition NanoVDB.h:2929
void setOn(uint32_t n)
Set the specified bit on.
Definition NanoVDB.h:3007
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
PointAccessor(const NanoGrid< Point > &grid)
Definition NanoVDB.h:7662
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
const NanoGrid< Point > & grid() const
Definition NanoVDB.h:7679
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
Class to access points at a specific voxel location.
Definition NanoVDB.h:7593
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
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
const NanoGrid< BuildT > & grid() const
Definition NanoVDB.h:7612
PointAccessor(const NanoGrid< BuildT > &grid)
Definition NanoVDB.h:7599
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
@dummy type for indexing points into voxels
Definition NanoVDB.h:303
ReadAccessor & operator=(const ReadAccessor &)=default
auto get(const CoordType &ijk, ArgsT &&... args) const
Definition NanoVDB.h:6659
ValueType getValue(int i, int j, int k) const
Definition NanoVDB.h:6608
ValueType operator()(int i, int j, int k) const
Definition NanoVDB.h:6610
ReadAccessor(const GridT &grid)
Constructor from a grid.
Definition NanoVDB.h:6582
ReadAccessor(const TreeT &tree)
Constructor from a tree.
Definition NanoVDB.h:6588
ValueType operator()(const CoordType &ijk) const
Definition NanoVDB.h:6609
bool isActive(const CoordType &ijk) const
Definition NanoVDB.h:6612
auto getNodeInfo(const CoordType &ijk) const
Definition NanoVDB.h:6611
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition NanoVDB.h:6613
typename RootT::CoordType CoordType
Definition NanoVDB.h:6559
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition NanoVDB.h:6597
void clear()
Reset this access to its initial state, i.e. with an empty cache @node Noop since this template speci...
Definition NanoVDB.h:6595
ValueType getValue(const CoordType &ijk) const
Definition NanoVDB.h:6604
typename RootT::ValueType ValueType
Definition NanoVDB.h:6558
const LeafT * probeLeaf(const CoordType &ijk) const
Definition NanoVDB.h:6614
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition NanoVDB.h:6654
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition NanoVDB.h:6576
BuildT BuildType
Definition NanoVDB.h:6557
auto set(const CoordType &ijk, ArgsT &&... args) const
Definition NanoVDB.h:6665
Node caching at all (three) tree levels.
Definition NanoVDB.h:7166
ReadAccessor & operator=(const ReadAccessor &)=default
auto get(const CoordType &ijk, ArgsT &&... args) const
Definition NanoVDB.h:7397
ValueType getValue(int i, int j, int k) const
Definition NanoVDB.h:7290
const NodeTrait< TreeT, LEVEL >::type * getNode() const
Definition NanoVDB.h:7240
CoordT CoordType
Definition NanoVDB.h:7191
ValueType operator()(int i, int j, int k) const
Definition NanoVDB.h:7292
ReadAccessor(const GridT &grid)
Constructor from a grid.
Definition NanoVDB.h:7210
ReadAccessor(const TreeT &tree)
Constructor from a tree.
Definition NanoVDB.h:7216
ValueType operator()(const CoordType &ijk) const
Definition NanoVDB.h:7291
ValueT ValueType
Definition NanoVDB.h:7190
bool isActive(const CoordType &ijk) const
Definition NanoVDB.h:7294
auto getNodeInfo(const CoordType &ijk) const
Definition NanoVDB.h:7293
const NodeT * getNode() const
Return a const point to the cached node of the specified type.
Definition NanoVDB.h:7232
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition NanoVDB.h:7295
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition NanoVDB.h:7221
void clear()
Reset this access to its initial state, i.e. with an empty cache.
Definition NanoVDB.h:7248
ValueType getValue(const CoordType &ijk) const
Definition NanoVDB.h:7286
bool isCached(const CoordType &ijk) const
Definition NanoVDB.h:7277
const LeafT * probeLeaf(const CoordType &ijk) const
Definition NanoVDB.h:7296
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition NanoVDB.h:7433
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition NanoVDB.h:7198
BuildT BuildType
Definition NanoVDB.h:7189
auto set(const CoordType &ijk, ArgsT &&... args) const
Definition NanoVDB.h:7415
ReadAccessor & operator=(const ReadAccessor &)=default
auto get(const CoordType &ijk, ArgsT &&... args) const
Definition NanoVDB.h:6825
ValueType getValue(int i, int j, int k) const
Definition NanoVDB.h:6761
CoordT CoordType
Definition NanoVDB.h:6709
ValueType operator()(int i, int j, int k) const
Definition NanoVDB.h:6763
ReadAccessor(const GridT &grid)
Constructor from a grid.
Definition NanoVDB.h:6724
bool isCached(const CoordType &ijk) const
Definition NanoVDB.h:6749
ReadAccessor(const TreeT &tree)
Constructor from a tree.
Definition NanoVDB.h:6730
ValueType operator()(const CoordType &ijk) const
Definition NanoVDB.h:6762
ValueT ValueType
Definition NanoVDB.h:6708
bool isActive(const CoordType &ijk) const
Definition NanoVDB.h:6765
auto getNodeInfo(const CoordType &ijk) const
Definition NanoVDB.h:6764
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition NanoVDB.h:6766
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition NanoVDB.h:6742
void clear()
Reset this access to its initial state, i.e. with an empty cache.
Definition NanoVDB.h:6736
ValueType getValue(const CoordType &ijk) const
Definition NanoVDB.h:6757
const LeafT * probeLeaf(const CoordType &ijk) const
Definition NanoVDB.h:6767
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition NanoVDB.h:6817
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition NanoVDB.h:6716
BuildT BuildType
Definition NanoVDB.h:6707
auto set(const CoordType &ijk, ArgsT &&... args) const
Definition NanoVDB.h:6833
ReadAccessor & operator=(const ReadAccessor &)=default
auto get(const CoordType &ijk, ArgsT &&... args) const
Definition NanoVDB.h:7100
ValueType getValue(int i, int j, int k) const
Definition NanoVDB.h:6987
CoordT CoordType
Definition NanoVDB.h:6892
ValueType operator()(int i, int j, int k) const
Definition NanoVDB.h:6989
ReadAccessor(const GridT &grid)
Constructor from a grid.
Definition NanoVDB.h:6912
ReadAccessor(const TreeT &tree)
Constructor from a tree.
Definition NanoVDB.h:6918
ValueType operator()(const CoordType &ijk) const
Definition NanoVDB.h:6988
ValueT ValueType
Definition NanoVDB.h:6891
bool isActive(const CoordType &ijk) const
Definition NanoVDB.h:6991
auto getNodeInfo(const CoordType &ijk) const
Definition NanoVDB.h:6990
bool probeValue(const CoordType &ijk, ValueType &v) const
Definition NanoVDB.h:6992
bool isCached1(const CoordType &ijk) const
Definition NanoVDB.h:6968
ReadAccessor(const ReadAccessor &)=default
Defaults constructors.
const RootT & root() const
Definition NanoVDB.h:6935
void clear()
Reset this access to its initial state, i.e. with an empty cache.
Definition NanoVDB.h:6924
ValueType getValue(const CoordType &ijk) const
Definition NanoVDB.h:6983
bool isCached2(const CoordType &ijk) const
Definition NanoVDB.h:6974
const LeafT * probeLeaf(const CoordType &ijk) const
Definition NanoVDB.h:6993
uint32_t getDim(const CoordType &ijk, const RayT &ray) const
Definition NanoVDB.h:7084
ReadAccessor(const RootT &root)
Constructor from a root node.
Definition NanoVDB.h:6899
BuildT BuildType
Definition NanoVDB.h:6890
auto set(const CoordType &ijk, ArgsT &&... args) const
Definition NanoVDB.h:7116
Definition NanoVDB.h:3688
8-bit red, green, blue, alpha packed into 32 bit unsigned int
Definition NanoVDB.h:1860
const uint32_t & packed() const
Definition NanoVDB.h:1943
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
Rgba8 & operator=(const Rgba8 &)=default
Default copy assignment operator.
const uint8_t & g() const
Definition NanoVDB.h:1946
uint8_t & g()
Definition NanoVDB.h:1950
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
uint32_t packed
Definition NanoVDB.h:1864
const uint8_t & a() const
Definition NanoVDB.h:1948
float asFloat(int n) const
return n'th color channel as a float in the range 0 to 1
Definition NanoVDB.h:1940
Rgba8(Rgba8 &&)=default
Default move constructor.
const uint8_t & r() const
Definition NanoVDB.h:1945
Rgba8()
Default ctor initializes all channels to zero.
Definition NanoVDB.h:1886
Rgba8(uint8_t v)
ctor where all channels are initialized to the same value
Definition NanoVDB.h:1901
Rgba8(const Vec3f &rgb)
Vec3f r,g,b ctor (alpha channel it set to 1)
Definition NanoVDB.h:1918
float lengthSqr() const
Definition NanoVDB.h:1932
Rgba8 & operator=(Rgba8 &&)=default
Default move assignment operator.
const uint8_t & b() const
Definition NanoVDB.h:1947
uint32_t & packed()
Definition NanoVDB.h:1944
uint8_t & r()
Definition NanoVDB.h:1949
uint8_t & operator[](int n)
Definition NanoVDB.h:1942
float length() const
Definition NanoVDB.h:1938
const uint8_t & operator[](int n) const
Definition NanoVDB.h:1941
bool operator==(const Rgba8 &rhs) const
Definition NanoVDB.h:1931
uint8_t ValueType
Definition NanoVDB.h:1869
Rgba8(const Rgba8 &)=default
Default copy constructor.
uint8_t & b()
Definition NanoVDB.h:1951
Rgba8(const Vec4f &rgba)
Vec4f r,g,b,a ctor.
Definition NanoVDB.h:1925
uint8_t c[4]
Definition NanoVDB.h:1863
uint8_t & a()
Definition NanoVDB.h:1952
static const int SIZE
Definition NanoVDB.h:1868
Definition NanoVDB.h:4353
void next()
Definition NanoVDB.h:4369
uint32_t mPos
Definition NanoVDB.h:4358
typename match_const< Tile, RootT >::type TileT
Definition NanoVDB.h:4356
BaseIter(DataT *data=nullptr, uint32_t n=0)
Definition NanoVDB.h:4359
TileT * tile() const
Definition NanoVDB.h:4370
typename match_const< DataType, RootT >::type DataT
Definition NanoVDB.h:4355
CoordType getOrigin() const
Definition NanoVDB.h:4371
DataT * mData
Definition NanoVDB.h:4357
uint32_t pos() const
Definition NanoVDB.h:4368
CoordType getCoord() const
Definition NanoVDB.h:4376
Definition NanoVDB.h:4385
ChildIter operator++(int)
Definition NanoVDB.h:4420
ChildIter & operator++()
Definition NanoVDB.h:4412
NodeT & operator*() const
Definition NanoVDB.h:4402
ChildIter()
Definition NanoVDB.h:4391
ChildIter(RootT *parent)
Definition NanoVDB.h:4395
NodeT * operator->() const
Definition NanoVDB.h:4407
Definition NanoVDB.h:4529
DenseIter(RootT *parent)
Definition NanoVDB.h:4538
bool isValueOn() const
Definition NanoVDB.h:4555
DenseIter & operator++()
Definition NanoVDB.h:4560
DenseIter operator++(int)
Definition NanoVDB.h:4566
DenseIter()
Definition NanoVDB.h:4534
NodeT * probeChild(ValueType &value) const
Definition NanoVDB.h:4543
Definition NanoVDB.h:4436
bool isActive() const
Definition NanoVDB.h:4456
ValueIter(RootT *parent)
Definition NanoVDB.h:4444
ValueIter operator++(int)
Definition NanoVDB.h:4469
ValueType operator*() const
Definition NanoVDB.h:4451
ValueIter()
Definition NanoVDB.h:4440
ValueIter & operator++()
Definition NanoVDB.h:4461
Definition NanoVDB.h:4485
ValueOnIter()
Definition NanoVDB.h:4489
ValueOnIter & operator++()
Definition NanoVDB.h:4505
ValueType operator*() const
Definition NanoVDB.h:4500
ValueOnIter operator++(int)
Definition NanoVDB.h:4513
ValueOnIter(RootT *parent)
Definition NanoVDB.h:4493
Top-most node of the VDB tree structure.
Definition NanoVDB.h:4330
const uint32_t & getTableSize() const
Definition NanoVDB.h:4604
const uint32_t & tileCount() const
Return the number of tiles encoded in this root node.
Definition NanoVDB.h:4603
auto get(const CoordType &ijk, ArgsT &&... args) const
Definition NanoVDB.h:4697
static uint64_t memUsage(uint32_t tableSize)
Return the expected memory footprint in bytes with the specified number of tiles.
Definition NanoVDB.h:4622
ChildNodeType * probeChild(const CoordType &ijk)
Definition NanoVDB.h:4690
ValueType getValue(int i, int j, int k) const
Definition NanoVDB.h:4633
ValueOnIterator beginValueOn()
Definition NanoVDB.h:4524
ChildT UpperNodeType
Definition NanoVDB.h:4336
typename ChildT::CoordType CoordType
Definition NanoVDB.h:4343
ConstValueIterator cbeginValueAll() const
Definition NanoVDB.h:4481
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
ConstValueOnIterator cbeginValueOn() const
Definition NanoVDB.h:4525
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
RootNode & operator=(const RootNode &)=delete
DataType * data()
Definition NanoVDB.h:4589
AccessorType getAccessor() const
Definition NanoVDB.h:4587
typename DataType::BuildT BuildType
Definition NanoVDB.h:4341
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
DenseIterator beginDense()
Definition NanoVDB.h:4577
RootNode(const RootNode &)=delete
ChildT ChildNodeType
Definition NanoVDB.h:4333
const LeafNodeType * probeLeaf(const CoordType &ijk) const
Definition NanoVDB.h:4637
bool isActive(const CoordType &ijk) const
Definition NanoVDB.h:4634
typename DataType::ValueT ValueType
Definition NanoVDB.h:4339
typename DataType::StatsT FloatType
Definition NanoVDB.h:4340
ValueIterator beginValue()
Definition NanoVDB.h:4480
ChildIterator beginChild()
Definition NanoVDB.h:4431
uint64_t memUsage() const
Return the actual memory footprint of this root node.
Definition NanoVDB.h:4625
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::LeafNodeType LeafNodeType
Definition NanoVDB.h:4338
ConstDenseIterator cbeginDense() const
Definition NanoVDB.h:4578
ConstDenseIterator cbeginChildAll() const
Definition NanoVDB.h:4579
const ChildNodeType * probeChild(const CoordType &ijk) const
Definition NanoVDB.h:4684
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
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
typename DataType::Tile Tile
Definition NanoVDB.h:4346
ValueType getValue(const CoordType &ijk) const
Return the value of the given voxel.
Definition NanoVDB.h:4632
const ValueType & background() const
Return the total number of active voxels in the root and all its child nodes.
Definition NanoVDB.h:4600
bool isEmpty() const
Return true if this RootNode is empty, i.e. contains no values or nodes.
Definition NanoVDB.h:4628
typename UpperNodeType::ChildNodeType LowerNodeType
Definition NanoVDB.h:4337
RootNode()=delete
This class cannot be constructed or deleted.
const ValueType & minimum() const
Return a const reference to the minimum active value encoded in this root node and any of its child n...
Definition NanoVDB.h:4607
const DataType * data() const
Definition NanoVDB.h:4591
decltype(OpT::set(std::declval< Tile & >(), std::declval< ArgsT >()...)) set(const CoordType &ijk, ArgsT &&... args)
Definition NanoVDB.h:4710
ConstChildIterator cbeginChild() const
Definition NanoVDB.h:4432
VDB Tree, which is a thin wrapper around a RootNode.
Definition NanoVDB.h:3990
typename RootT::ChildNodeType Node2
Definition NanoVDB.h:4009
auto get(const CoordType &ijk, ArgsT &&... args) const
Definition NanoVDB.h:4145
typename RootType::LeafNodeType LeafNodeType
Definition NanoVDB.h:4002
const NodeTrait< RootT, 1 >::type * getFirstLower() const
Definition NanoVDB.h:4140
RootT Node3
Definition NanoVDB.h:4008
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
ValueType getValue(int i, int j, int k) const
Definition NanoVDB.h:4044
const NodeT * getFirstNode() const
return a const pointer to the first node of the specified type
Definition NanoVDB.h:4110
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
typename RootNodeType::ChildNodeType UpperNodeType
Definition NanoVDB.h:4000
auto set(const CoordType &ijk, ArgsT &&... args)
Definition NanoVDB.h:4151
const NodeTrait< RootT, 2 >::type * getFirstUpper() const
Definition NanoVDB.h:4142
DataType * data()
Definition NanoVDB.h:4019
uint32_t nodeCount() const
Definition NanoVDB.h:4079
NodeTrait< RootT, 1 >::type * getFirstLower()
Definition NanoVDB.h:4139
Tree()=delete
This class cannot be constructed or deleted.
AccessorType getAccessor() const
Definition NanoVDB.h:4040
NodeTrait< RootT, 2 >::type * getFirstUpper()
Definition NanoVDB.h:4141
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
const LeafNodeType * getFirstLeaf() const
Definition NanoVDB.h:4138
NodeTrait< RootT, LEVEL >::type * getFirstNode()
return a pointer to the first node at the specified level
Definition NanoVDB.h:4121
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
RootT RootNodeType
Definition NanoVDB.h:3999
typename RootT::CoordType CoordType
Definition NanoVDB.h:4005
RootT & root()
Definition NanoVDB.h:4026
LeafNodeType * getFirstLeaf()
Template specializations of getFirstNode.
Definition NanoVDB.h:4137
Tree(const Tree &)=delete
static uint64_t memUsage()
return memory usage in bytes for the class
Definition NanoVDB.h:4024
LeafNodeType Node0
Definition NanoVDB.h:4011
NodeT * getFirstNode()
return a pointer to the first node of the specified type
Definition NanoVDB.h:4100
uint32_t nodeCount(int level) const
Definition NanoVDB.h:4085
typename Node2::ChildNodeType Node1
Definition NanoVDB.h:4010
const NodeTrait< RootT, LEVEL >::type * getFirstNode() const
return a const pointer to the first node of the specified level
Definition NanoVDB.h:4131
const RootT & root() const
Definition NanoVDB.h:4033
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
RootT RootType
Definition NanoVDB.h:3998
const ValueType & background() const
Return a const reference to the background value.
Definition NanoVDB.h:4056
Tree & operator=(const Tree &)=delete
typename UpperNodeType::ChildNodeType LowerNodeType
Definition NanoVDB.h:4001
typename RootT::ValueType ValueType
Definition NanoVDB.h:4003
uint32_t totalNodeCount() const
Definition NanoVDB.h:4091
const DataType * data() const
Definition NanoVDB.h:4021
typename RootT::BuildType BuildType
Definition NanoVDB.h:4004
Like ValueIndex but with a mutable mask.
Definition NanoVDB.h:263
Dummy type for a voxel whose value equals an offset into an external value array.
Definition NanoVDB.h:253
Dummy type for a voxel whose value equals its binary active state.
Definition NanoVDB.h:273
Like ValueOnIndex but with a mutable mask.
Definition NanoVDB.h:268
Dummy type for a voxel whose value equals an offset into an external value array of active values.
Definition NanoVDB.h:258
A simple vector class with three components, similar to openvdb::math::Vec3.
Definition NanoVDB.h:1530
Vec3(const Vec3< T2 > &v)
Definition NanoVDB.h:1553
Coord round() const
Round each component if this Vec<T> to its closest integer value.
Definition NanoVDB.h:1675
Vec3(T x)
Definition NanoVDB.h:1538
ValueType min() const
Return the smallest vector component.
Definition NanoVDB.h:1658
Vec3 operator-(const Coord &ijk) const
Definition NanoVDB.h:1594
Vec3 & minComponent(const Vec3 &other)
Perform a component-wise minimum with the other Coord.
Definition NanoVDB.h:1635
Vec3(const Coord &ijk)
Definition NanoVDB.h:1557
bool operator==(const Vec3 &rhs) const
Definition NanoVDB.h:1561
Vec3 operator-() const
Definition NanoVDB.h:1588
T length() const
Definition NanoVDB.h:1587
Vec3 operator*(const Vec3 &v) const
Definition NanoVDB.h:1589
Vec3 & maxComponent(const Vec3 &other)
Perform a component-wise maximum with the other Coord.
Definition NanoVDB.h:1647
Vec3 & operator-=(const Vec3 &v)
Definition NanoVDB.h:1611
Coord floor() const
Round each component if this Vec<T> up to its integer value.
Definition NanoVDB.h:1669
Vec3 & operator-=(const Coord &ijk)
Definition NanoVDB.h:1618
Vec3 operator+(const Coord &ijk) const
Definition NanoVDB.h:1593
Vec3 operator*(const T &s) const
Definition NanoVDB.h:1595
Vec3(T x, T y, T z)
Definition NanoVDB.h:1542
Vec3 operator/(const Vec3 &v) const
Definition NanoVDB.h:1590
T * asPointer()
return a non-const raw constant pointer to array of three vector components
Definition NanoVDB.h:1687
Vec3 & operator=(const Vec3T< T2 > &rhs)
Definition NanoVDB.h:1564
T dot(const Vec3T &v) const
Definition NanoVDB.h:1575
Vec3 & operator*=(const T &s)
Definition NanoVDB.h:1625
Vec3 & normalize()
Definition NanoVDB.h:1633
const T * asPointer() const
return a const raw constant pointer to array of three vector components
Definition NanoVDB.h:1689
T lengthSqr() const
Definition NanoVDB.h:1583
Vec3(const Vec3T< T2 > &v)
Definition NanoVDB.h:1547
Vec3 & operator+=(const Vec3 &v)
Definition NanoVDB.h:1597
Coord ceil() const
Round each component if this Vec<T> down to its integer value.
Definition NanoVDB.h:1672
static const int size
Definition NanoVDB.h:1535
const T & operator[](int i) const
Definition NanoVDB.h:1572
Vec3 cross(const Vec3T &v) const
Definition NanoVDB.h:1577
Vec3 operator/(const T &s) const
Definition NanoVDB.h:1596
Vec3 & operator+=(const Coord &ijk)
Definition NanoVDB.h:1604
bool operator!=(const Vec3 &rhs) const
Definition NanoVDB.h:1562
Vec3 operator+(const Vec3 &v) const
Definition NanoVDB.h:1591
T & operator[](int i)
Definition NanoVDB.h:1573
Vec3 operator-(const Vec3 &v) const
Definition NanoVDB.h:1592
ValueType max() const
Return the largest vector component.
Definition NanoVDB.h:1663
Vec3 & operator/=(const T &s)
Definition NanoVDB.h:1632
T ValueType
Definition NanoVDB.h:1536
static const int SIZE
Definition NanoVDB.h:1534
A simple vector class with four components, similar to openvdb::math::Vec4.
Definition NanoVDB.h:1728
Vec4 & normalize()
Definition NanoVDB.h:1809
Vec4 & operator/=(const T &s)
Definition NanoVDB.h:1808
Vec4 operator/(const Vec4 &v) const
Definition NanoVDB.h:1779
Vec4 & operator+=(const Vec4 &v)
Definition NanoVDB.h:1784
Vec4 operator*(const T &s) const
Definition NanoVDB.h:1782
T length() const
Definition NanoVDB.h:1776
Vec4 operator-(const Vec4 &v) const
Definition NanoVDB.h:1781
Vec4 & operator*=(const T &s)
Definition NanoVDB.h:1800
Vec4 operator*(const Vec4 &v) const
Definition NanoVDB.h:1778
Vec4(T x, T y, T z, T w)
Definition NanoVDB.h:1740
bool operator!=(const Vec4 &rhs) const
Definition NanoVDB.h:1756
Vec4 & maxComponent(const Vec4 &other)
Perform a component-wise maximum with the other Coord.
Definition NanoVDB.h:1825
Vec4(const Vec4< T2 > &v)
Definition NanoVDB.h:1745
T lengthSqr() const
Definition NanoVDB.h:1772
static const int size
Definition NanoVDB.h:1733
const T & operator[](int i) const
Definition NanoVDB.h:1768
Vec4 & operator-=(const Vec4 &v)
Definition NanoVDB.h:1792
bool operator==(const Vec4 &rhs) const
Definition NanoVDB.h:1755
Vec4 & minComponent(const Vec4 &other)
Perform a component-wise minimum with the other Coord.
Definition NanoVDB.h:1811
T & operator[](int i)
Definition NanoVDB.h:1769
Vec4 operator-() const
Definition NanoVDB.h:1777
Vec4 operator/(const T &s) const
Definition NanoVDB.h:1783
Vec4 & operator=(const Vec4T< T2 > &rhs)
Definition NanoVDB.h:1758
T dot(const Vec4T &v) const
Definition NanoVDB.h:1771
T ValueType
Definition NanoVDB.h:1734
Vec4(T x)
Definition NanoVDB.h:1736
static const int SIZE
Definition NanoVDB.h:1732
Vec4(const Vec4T< T2 > &v)
Definition NanoVDB.h:1750
Vec4 operator+(const Vec4 &v) const
Definition NanoVDB.h:1780
Bit-compacted representation of all three version numbers.
Definition NanoVDB.h:948
const char * c_str() const
Definition NanoVDB.h:981
bool operator<(const Version &rhs) const
Definition NanoVDB.h:966
uint32_t getPatch() const
Definition NanoVDB.h:973
bool operator<=(const Version &rhs) const
Definition NanoVDB.h:967
Version(uint32_t data)
Definition NanoVDB.h:957
Version()
Definition NanoVDB.h:951
bool operator==(const Version &rhs) const
Definition NanoVDB.h:965
Version(uint32_t major, uint32_t minor, uint32_t patch)
Definition NanoVDB.h:958
uint32_t getMajor() const
Definition NanoVDB.h:971
bool isCompatible() const
Definition NanoVDB.h:974
bool operator>=(const Version &rhs) const
Definition NanoVDB.h:969
int age() const
Check the major version of this instance relative to NANOVDB_MAJOR_VERSION_NUMBER.
Definition NanoVDB.h:978
uint32_t getMinor() const
Definition NanoVDB.h:972
uint32_t id() const
Definition NanoVDB.h:970
bool operator>(const Version &rhs) const
Definition NanoVDB.h:968
void writeUncompressedGrid(StreamT &os, const GridData *gridData, bool raw=false)
This is a standalone alternative to io::writeGrid(...,Codec::NONE) defined in util/IO....
Definition NanoVDB.h:7921
VecT< GridHandleT > readUncompressedGrids(StreamT &is, const typename GridHandleT::BufferType &pool=typename GridHandleT::BufferType())
read all uncompressed grids from a stream and return their handles.
Definition NanoVDB.h:7979
Codec
Define compression codecs.
Definition NanoVDB.h:7839
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
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
const char * toStr(GridType gridType)
Maps a GridType to a c-string.
Definition NanoVDB.h:349
float Fract(float x)
Definition NanoVDB.h:1140
int MinIndex(const Vec3T &v)
Definition NanoVDB.h:1251
static int64_t PtrDiff(const T1 *p, const T2 *q)
Compute the distance, in bytes, between two pointers.
Definition NanoVDB.h:780
T Abs(T x)
Definition NanoVDB.h:1185
bool isApproxZero(const Type &x)
Definition NanoVDB.h:1083
Type Min(Type a, Type b)
Definition NanoVDB.h:1089
T Sign(const T &x)
Return the sign of the given value as an integer (either -1, 0 or 1).
Definition NanoVDB.h:1245
T Pow4(T x)
Definition NanoVDB.h:1180
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
Vec3< float > Vec3f
Definition NanoVDB.h:1705
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
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
constexpr T pi()
Pi constant taken from Boost to match old behaviour.
Definition NanoVDB.h:995
bool isFloatingPointVector(GridType gridType)
return true if the GridType maps to a floating point vec3.
Definition NanoVDB.h:831
GridClass
Classes (superset of OpenVDB) that are currently supported by NanoVDB.
Definition NanoVDB.h:362
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
GridType
List of types that are currently supported by NanoVDB.
Definition NanoVDB.h:317
float Sqrt(float x)
Return the square root of a floating-point value.
Definition NanoVDB.h:1233
int MaxIndex(const Vec3T &v)
Definition NanoVDB.h:1268
Vec3< T2 > operator/(T1 scalar, const Vec3< T2 > &vec)
Definition NanoVDB.h:1698
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
static T * alignPtr(T *p)
offset the specified pointer so it is aligned.
Definition NanoVDB.h:757
GridFlags
Grid flags which indicate what extra information is present in the grid buffer.
Definition NanoVDB.h:387
Vec3< T2 > operator*(T1 scalar, const Vec3< T2 > &vec)
Definition NanoVDB.h:1693
int32_t Ceil(float x)
Definition NanoVDB.h:1158
int32_t Floor(float x)
Definition NanoVDB.h:1149
GridBlindDataClass
Blind-data Classes that are currently supported by NanoVDB.
Definition NanoVDB.h:416
Vec3< double > Vec3d
Definition NanoVDB.h:1704
GridType mapToGridType()
Maps from a templated build type to a GridType enum.
Definition NanoVDB.h:2050
CoordT Round(const Vec3T< RealT > &xyz)
T Pow3(T x)
Definition NanoVDB.h:1174
CoordT RoundDown(const Vec3T< RealT > &xyz)
Definition NanoVDB.h:1226
static void * memcpy64(void *dst, const void *src, size_t word_count)
copy 64 bit words from src to dst
Definition NanoVDB.h:871
static bool isAligned(const void *p)
return true if the specified pointer is aligned
Definition NanoVDB.h:737
bool isInteger(GridType gridType)
Return true if the GridType maps to a POD integer type.
Definition NanoVDB.h:843
GridBlindDataSemantic
Blind-data Semantics that are currently understood by NanoVDB.
Definition NanoVDB.h:424
bool isFloatingPoint(GridType gridType)
return true if the GridType maps to a floating point type
Definition NanoVDB.h:817
T Pow2(T x)
Definition NanoVDB.h:1168
float Clamp(float x, float a, float b)
Definition NanoVDB.h:1131
Type Max(Type a, Type b)
Definition NanoVDB.h:1110
bool isIndex(GridType gridType)
Return true if the GridType maps to a special index type (not a POD integer type).
Definition NanoVDB.h:855
GridClass mapToGridClass(GridClass defaultClass=GridClass::Unknown)
Maps from a templated build type to a GridClass enum.
Definition NanoVDB.h:2110
static bool isValid(const void *p)
return true if the specified pointer is aligned and not NULL
Definition NanoVDB.h:743
Iterator begin() const
Definition NanoVDB.h:2420
BBox< Vec3d > transform(const Map &map) const
transform this coordinate bounding box by the specified map
Definition NanoVDB.h:2499
BBox()
Definition NanoVDB.h:2422
bool is_divisible() const
Definition NanoVDB.h:2451
BBox(const CoordT &min, const CoordT &max)
Definition NanoVDB.h:2426
CoordT dim() const
Definition NanoVDB.h:2462
Iterator end() const
Definition NanoVDB.h:2421
bool empty() const
Return true if this bounding box is empty, e.g. uninitialized.
Definition NanoVDB.h:2455
BBox expandBy(typename CoordT::ValueType padding) const
Return a new instance that is expanded by the specified padding.
Definition NanoVDB.h:2490
bool isInside(const BBox &b) const
Return true if the given bounding box is inside this bounding box.
Definition NanoVDB.h:2470
bool hasOverlap(const BBox &b) const
Return true if the given bounding box overlaps with this bounding box.
Definition NanoVDB.h:2476
uint64_t volume() const
Definition NanoVDB.h:2463
static BBox createCube(const CoordT &min, typename CoordT::ValueType dim)
Definition NanoVDB.h:2441
BBox(BBox &other, const SplitT &)
Definition NanoVDB.h:2432
BBox< Vec3< RealT > > asReal() const
Definition NanoVDB.h:2483
bool isInside(const CoordT &p) const
Definition NanoVDB.h:2468
static BBox createCube(typename CoordT::ValueType min, typename CoordT::ValueType max)
Definition NanoVDB.h:2446
Vec3T dim() const
Definition NanoVDB.h:2339
bool isInside(const Vec3T &p) const
Definition NanoVDB.h:2340
BBox()
Default construction sets BBox to an empty bbox.
Definition NanoVDB.h:2310
BBox(const Coord &min, const Coord &max)
Definition NanoVDB.h:2319
bool empty() const
Definition NanoVDB.h:2333
BBox(const Vec3T &min, const Vec3T &max)
Definition NanoVDB.h:2315
Vec3T Vec3Type
Definition NanoVDB.h:2304
typename Vec3T::ValueType ValueType
Definition NanoVDB.h:2305
static BBox createCube(const Coord &min, typename Coord::ValueType dim)
Definition NanoVDB.h:2324
BBox(const BaseBBox< Coord > &bbox)
Definition NanoVDB.h:2329
Definition NanoVDB.h:2295
Definition NanoVDB.h:2233
Vec3T mCoord[2]
Definition NanoVDB.h:2234
BaseBBox()
Definition NanoVDB.h:2287
const Vec3T & max() const
Definition NanoVDB.h:2242
BaseBBox & expand(const Vec3T &xyz)
Expand this bounding box to enclose point xyz.
Definition NanoVDB.h:2250
bool operator!=(const BaseBBox &rhs) const
Definition NanoVDB.h:2236
BaseBBox & expand(const BaseBBox &bbox)
Expand this bounding box to enclose the given bounding box.
Definition NanoVDB.h:2258
const Vec3T & operator[](int i) const
Definition NanoVDB.h:2237
Vec3T & operator[](int i)
Definition NanoVDB.h:2238
bool isInside(const Vec3T &xyz)
Definition NanoVDB.h:2277
const Vec3T & min() const
Definition NanoVDB.h:2241
BaseBBox(const Vec3T &min, const Vec3T &max)
Definition NanoVDB.h:2288
Vec3T & min()
Definition NanoVDB.h:2239
bool operator==(const BaseBBox &rhs) const
Definition NanoVDB.h:2235
Vec3T & max()
Definition NanoVDB.h:2240
BaseBBox & translate(const Vec3T &xyz)
Definition NanoVDB.h:2243
BaseBBox & intersect(const BaseBBox &bbox)
Intersect this bounding box with the given bounding box.
Definition NanoVDB.h:2266
Definition NanoVDB.h:2685
float type
Definition NanoVDB.h:717
float Type
Definition NanoVDB.h:716
float type
Definition NanoVDB.h:703
float Type
Definition NanoVDB.h:702
float type
Definition NanoVDB.h:710
float Type
Definition NanoVDB.h:709
float type
Definition NanoVDB.h:724
float Type
Definition NanoVDB.h:723
float type
Definition NanoVDB.h:696
float Type
Definition NanoVDB.h:695
uint64_t Type
Definition NanoVDB.h:730
uint64_t type
Definition NanoVDB.h:731
uint64_t Type
Definition NanoVDB.h:674
uint64_t type
Definition NanoVDB.h:675
uint64_t Type
Definition NanoVDB.h:660
uint64_t type
Definition NanoVDB.h:661
bool Type
Definition NanoVDB.h:688
bool type
Definition NanoVDB.h:689
uint64_t Type
Definition NanoVDB.h:681
uint64_t type
Definition NanoVDB.h:682
uint64_t Type
Definition NanoVDB.h:667
uint64_t type
Definition NanoVDB.h:668
Maps one type (e.g. the build types above) to other (actual) types.
Definition NanoVDB.h:652
T Type
Definition NanoVDB.h:653
T type
Definition NanoVDB.h:654
Define static boolean tests for template build types.
Definition NanoVDB.h:472
static constexpr bool is_indexmask
Definition NanoVDB.h:477
static constexpr bool is_offindex
Definition NanoVDB.h:476
static constexpr bool is_onindex
Definition NanoVDB.h:475
static constexpr bool is_index
Definition NanoVDB.h:474
static constexpr bool is_Fp
Definition NanoVDB.h:481
static constexpr bool is_float
Definition NanoVDB.h:483
static constexpr bool is_special
Definition NanoVDB.h:485
static constexpr bool is_FpX
Definition NanoVDB.h:479
static double value()
Definition NanoVDB.h:1044
static float value()
Definition NanoVDB.h:1039
Delta for small floating-point offsets.
Definition NanoVDB.h:1035
double FloatType
Definition NanoVDB.h:2043
double FloatType
Definition NanoVDB.h:2001
uint64_t FloatType
Definition NanoVDB.h:2019
uint64_t FloatType
Definition NanoVDB.h:2013
bool FloatType
Definition NanoVDB.h:2037
uint64_t FloatType
Definition NanoVDB.h:2031
uint64_t FloatType
Definition NanoVDB.h:2025
bool FloatType
Definition NanoVDB.h:2007
Definition NanoVDB.h:1994
float FloatType
Definition NanoVDB.h:1995
Implements Tree::getDim(Coord)
Definition NanoVDB.h:8111
static uint32_t get(const NanoLower< BuildT > &, uint32_t)
Definition NanoVDB.h:8115
static uint32_t get(const NanoRoot< BuildT > &)
Definition NanoVDB.h:8112
static uint32_t get(const typename NanoRoot< BuildT >::Tile &)
Definition NanoVDB.h:8113
static uint32_t get(const NanoUpper< BuildT > &, uint32_t)
Definition NanoVDB.h:8114
static uint32_t get(const NanoLeaf< BuildT > &, uint32_t)
Definition NanoVDB.h:8116
Return the pointer to the leaf node that contains Coord. Implements Tree::probeLeaf(Coord)
Definition NanoVDB.h:8123
static const NanoLeaf< BuildT > * get(const typename NanoRoot< BuildT >::Tile &)
Definition NanoVDB.h:8125
static const NanoLeaf< BuildT > * get(const NanoRoot< BuildT > &)
Definition NanoVDB.h:8124
static const NanoLeaf< BuildT > * get(const NanoUpper< BuildT > &, uint32_t)
Definition NanoVDB.h:8126
static const NanoLeaf< BuildT > * get(const NanoLeaf< BuildT > &leaf, uint32_t)
Definition NanoVDB.h:8128
static const NanoLeaf< BuildT > * get(const NanoLower< BuildT > &, uint32_t)
Definition NanoVDB.h:8127
Return point to the lower internal node where Coord maps to one of its values, i.e....
Definition NanoVDB.h:8135
static const NanoLower< BuildT > * get(const NanoLower< BuildT > &node, uint32_t)
Definition NanoVDB.h:8139
static const NanoLower< BuildT > * get(const NanoLeaf< BuildT > &, uint32_t)
Definition NanoVDB.h:8140
static const NanoLower< BuildT > * get(const NanoUpper< BuildT > &, uint32_t)
Definition NanoVDB.h:8138
static const NanoLower< BuildT > * get(const typename NanoRoot< BuildT >::Tile &)
Definition NanoVDB.h:8137
static const NanoLower< BuildT > * get(const NanoRoot< BuildT > &)
Definition NanoVDB.h:8136
Definition NanoVDB.h:8196
FloatType average
Definition NanoVDB.h:8199
ValueType maximum
Definition NanoVDB.h:8198
CoordBBox bbox
Definition NanoVDB.h:8200
uint32_t dim
Definition NanoVDB.h:8197
Implements Tree::getNodeInfo(Coord)
Definition NanoVDB.h:8192
static NodeInfo get(const NanoLeaf< BuildT > &leaf, uint32_t n)
Definition NanoVDB.h:8218
static NodeInfo get(const NanoUpper< BuildT > &node, uint32_t n)
Definition NanoVDB.h:8210
static NodeInfo get(const NanoLower< BuildT > &node, uint32_t n)
Definition NanoVDB.h:8214
typename NanoLeaf< BuildT >::ValueType ValueType
Definition NanoVDB.h:8193
static NodeInfo get(const typename NanoRoot< BuildT >::Tile &tile)
Definition NanoVDB.h:8206
static NodeInfo get(const NanoRoot< BuildT > &root)
Definition NanoVDB.h:8202
typename NanoLeaf< BuildT >::FloatType FloatType
Definition NanoVDB.h:8194
Implements Tree::isActive(Coord)
Definition NanoVDB.h:8099
static auto get(const NanoUpper< BuildT > &node, uint32_t n)
Definition NanoVDB.h:8102
static auto get(const NanoRoot< BuildT > &)
Definition NanoVDB.h:8100
static auto get(const NanoLower< BuildT > &node, uint32_t n)
Definition NanoVDB.h:8103
static auto get(const NanoLeaf< BuildT > &leaf, uint32_t n)
Definition NanoVDB.h:8104
static auto get(const typename NanoRoot< BuildT >::Tile &tile)
Definition NanoVDB.h:8101
Return point to the upper internal node where Coord maps to one of its values, i.e....
Definition NanoVDB.h:8147
static const NanoUpper< BuildT > * get(const NanoUpper< BuildT > &node, uint32_t)
Definition NanoVDB.h:8150
static const NanoUpper< BuildT > * get(const NanoRoot< BuildT > &)
Definition NanoVDB.h:8148
static const NanoUpper< BuildT > * get(const NanoLeaf< BuildT > &, uint32_t)
Definition NanoVDB.h:8152
static const NanoUpper< BuildT > * get(const typename NanoRoot< BuildT >::Tile &)
Definition NanoVDB.h:8149
static const NanoUpper< BuildT > * get(const NanoLower< BuildT > &node, uint32_t)
Definition NanoVDB.h:8151
Implements Tree::getValue(Coord), i.e. return the value associated with a specific coordinate ijk.
Definition NanoVDB.h:8063
static auto get(const NanoUpper< BuildT > &node, uint32_t n)
Definition NanoVDB.h:8066
static auto get(const NanoRoot< BuildT > &root)
Definition NanoVDB.h:8064
static auto get(const NanoLower< BuildT > &node, uint32_t n)
Definition NanoVDB.h:8067
static auto get(const NanoLeaf< BuildT > &leaf, uint32_t n)
Definition NanoVDB.h:8068
static auto get(const typename NanoRoot< BuildT >::Tile &tile)
Definition NanoVDB.h:8065
Struct with all the member data of the Grid (useful during serialization of an openvdb grid)
Definition NanoVDB.h:3512
uint8_t * nodePtr()
Return a non-const uint8_t pointer to the first node at LEVEL.
Definition NanoVDB.h:3633
const CoordBBox & indexBBox() const
return AABB of active values in index space
Definition NanoVDB.h:3667
void setMinMaxOn(bool on=true)
Definition NanoVDB.h:3572
void setAverageOn(bool on=true)
Definition NanoVDB.h:3575
Vec3T applyInverseJacobianF(const Vec3T &xyz) const
Definition NanoVDB.h:3605
Vec3T applyIJTF(const Vec3T &xyz) const
Definition NanoVDB.h:3607
uint32_t mBlindMetadataCount
Definition NanoVDB.h:3528
Version mVersion
Definition NanoVDB.h:3516
uint32_t mData0
Definition NanoVDB.h:3529
GridType mGridType
Definition NanoVDB.h:3526
uint64_t mMagic
Definition NanoVDB.h:3514
GridData & operator=(const GridData &other)
Use this method to initiate most member dat.
Definition NanoVDB.h:3532
void setStdDeviationOn(bool on=true)
Definition NanoVDB.h:3576
bool isValid() const
return true if the magic number and the version are both valid
Definition NanoVDB.h:3568
const uint8_t * nodePtr() const
Return a non-const uint8_t pointer to the first node at LEVEL.
Definition NanoVDB.h:3621
Vec3T applyIJT(const Vec3T &xyz) const
Definition NanoVDB.h:3596
const uint8_t * treePtr() const
Definition NanoVDB.h:3614
GridClass mGridClass
Definition NanoVDB.h:3525
void setBBoxOn(bool on=true)
Definition NanoVDB.h:3573
const char * gridName() const
Definition NanoVDB.h:3644
void setLongGridNameOn(bool on=true)
Definition NanoVDB.h:3574
Vec3T applyJacobianF(const Vec3T &xyz) const
Definition NanoVDB.h:3603
bool setGridName(const char *src)
Definition NanoVDB.h:3577
uint64_t mGridSize
Definition NanoVDB.h:3520
Vec3T applyInverseJacobian(const Vec3T &xyz) const
Definition NanoVDB.h:3594
const GridBlindMetaData * blindMetaData(uint32_t n) const
Returns a const reference to the blindMetaData at the specified linear offset.
Definition NanoVDB.h:3638
uint8_t * treePtr()
Definition NanoVDB.h:3610
const BBox< Vec3d > & worldBBox() const
return AABB of active values in world space
Definition NanoVDB.h:3664
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
uint64_t mChecksum
Definition NanoVDB.h:3515
Vec3T applyMapF(const Vec3T &xyz) const
Definition NanoVDB.h:3599
uint64_t mData1
Definition NanoVDB.h:3530
uint32_t mGridCount
Definition NanoVDB.h:3519
Vec3T applyInverseMap(const Vec3T &xyz) const
Definition NanoVDB.h:3590
static uint64_t memUsage()
Return memory usage in bytes for this class only.
Definition NanoVDB.h:3661
Map mMap
Definition NanoVDB.h:3522
BBox< Vec3d > mWorldBBox
Definition NanoVDB.h:3523
bool isEmpty() const
test if the grid is empty, e.i the root table has size 0
Definition NanoVDB.h:3679
Vec3d mVoxelSize
Definition NanoVDB.h:3524
BitFlags< 32 > mFlags
Definition NanoVDB.h:3517
char mGridName[MaxNameSize]
Definition NanoVDB.h:3521
uint32_t rootTableSize() const
return the root table has size
Definition NanoVDB.h:3670
Vec3T applyJacobian(const Vec3T &xyz) const
Definition NanoVDB.h:3592
int64_t mBlindMetadataOffset
Definition NanoVDB.h:3527
uint32_t mGridIndex
Definition NanoVDB.h:3518
bool isRootConnected() const
return true if RootData follows TreeData in memory without any extra padding
Definition NanoVDB.h:3683
Vec3T applyMap(const Vec3T &xyz) const
Definition NanoVDB.h:3588
Vec3T applyInverseMapF(const Vec3T &xyz) const
Definition NanoVDB.h:3601
const typename GridT::TreeType Type
Definition NanoVDB.h:3981
const typename GridT::TreeType type
Definition NanoVDB.h:3982
defines a tree type from a grid type while preserving constness
Definition NanoVDB.h:3974
typename GridT::TreeType Type
Definition NanoVDB.h:3975
typename GridT::TreeType type
Definition NanoVDB.h:3976
Struct with all the member data of the InternalNode (useful during serialization of an openvdb Intern...
Definition NanoVDB.h:4859
void setOrigin(const T &ijk)
Definition NanoVDB.h:4940
StatsT mAverage
Definition NanoVDB.h:4885
typename ChildT::CoordType CoordT
Definition NanoVDB.h:4863
void setChild(uint32_t n, const void *ptr)
Definition NanoVDB.h:4900
MaskT mChildMask
Definition NanoVDB.h:4881
void setValue(uint32_t n, const ValueT &v)
Definition NanoVDB.h:4907
InternalData(const InternalData &)=delete
const ValueT & getMax() const
Definition NanoVDB.h:4943
void setDev(const StatsT &v)
Definition NanoVDB.h:4954
const ChildT * getChild(uint32_t n) const
Definition NanoVDB.h:4919
bool isActive(uint32_t n) const
Definition NanoVDB.h:4931
void setMin(const ValueT &v)
Definition NanoVDB.h:4951
typename ChildT::FloatType StatsT
Definition NanoVDB.h:4862
bool isChild(uint32_t n) const
Definition NanoVDB.h:4937
typename ChildT::BuildType BuildT
Definition NanoVDB.h:4861
ValueT getValue(uint32_t n) const
Definition NanoVDB.h:4925
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition NanoVDB.h:4892
const ValueT & getMin() const
Definition NanoVDB.h:4942
void setMax(const ValueT &v)
Definition NanoVDB.h:4952
StatsT mStdDevi
Definition NanoVDB.h:4886
Tile mTable[1u<<(3 *LOG2DIM)]
Definition NanoVDB.h:4896
BBox< CoordT > mBBox
Definition NanoVDB.h:4878
ChildT * getChild(uint32_t n)
Returns a pointer to the child node at the specifed linear offset.
Definition NanoVDB.h:4914
ValueT mMaximum
Definition NanoVDB.h:4884
const StatsT & stdDeviation() const
Definition NanoVDB.h:4945
static uint64_t memUsage()
Definition NanoVDB.h:4898
const StatsT & average() const
Definition NanoVDB.h:4944
MaskT mValueMask
Definition NanoVDB.h:4880
typename ChildT::template MaskType< LOG2DIM > MaskT
Definition NanoVDB.h:4864
InternalData & operator=(const InternalData &)=delete
void setAvg(const StatsT &v)
Definition NanoVDB.h:4953
typename ChildT::ValueType ValueT
Definition NanoVDB.h:4860
ValueT mMinimum
Definition NanoVDB.h:4883
InternalData()=delete
This class cannot be constructed or deleted.
uint64_t mFlags
Definition NanoVDB.h:4879
static constexpr uint8_t bitWidth()
Definition NanoVDB.h:5657
float getValue(uint32_t i) const
Definition NanoVDB.h:5658
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
static constexpr uint32_t padding()
Definition NanoVDB.h:5651
uint16_t ArrayType
Definition NanoVDB.h:5646
LeafData()=delete
This class cannot be constructed or deleted.
static constexpr uint64_t memUsage()
Definition NanoVDB.h:5650
static constexpr uint8_t bitWidth()
Definition NanoVDB.h:5590
float getValue(uint32_t i) const
Definition NanoVDB.h:5591
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
static constexpr uint32_t padding()
Definition NanoVDB.h:5584
LeafData()=delete
This class cannot be constructed or deleted.
uint8_t ArrayType
Definition NanoVDB.h:5579
static constexpr uint64_t memUsage()
Definition NanoVDB.h:5583
static constexpr uint8_t bitWidth()
Definition NanoVDB.h:5626
float getValue(uint32_t i) const
Definition NanoVDB.h:5627
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
static constexpr uint32_t padding()
Definition NanoVDB.h:5620
static constexpr int64_t memUsage()
Definition NanoVDB.h:5619
LeafData()=delete
This class cannot be constructed or deleted.
uint8_t ArrayType
Definition NanoVDB.h:5616
size_t memUsage() const
Definition NanoVDB.h:5687
float getValue(uint32_t i) const
Definition NanoVDB.h:5689
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
uint8_t bitWidth() const
Definition NanoVDB.h:5686
static constexpr uint32_t padding()
Definition NanoVDB.h:5680
LeafData()=delete
This class cannot be constructed or deleted.
static size_t memUsage(uint32_t bitWidth)
Definition NanoVDB.h:5688
void setOrigin(const T &ijk)
Definition NanoVDB.h:6010
FloatType getDev() const
Definition NanoVDB.h:6002
uint64_t mOffset
Definition NanoVDB.h:5972
uint64_t ValueType
Definition NanoVDB.h:5961
void setMax(const ValueType &)
Definition NanoVDB.h:6005
uint8_t mFlags
Definition NanoVDB.h:5969
void setOn(uint32_t offset)
Definition NanoVDB.h:5997
LeafData & operator=(const LeafData &)=delete
void setDev(const FloatType &)
Definition NanoVDB.h:6007
LeafData(const LeafData &)=delete
uint64_t offset() const
Definition NanoVDB.h:5986
void setValue(uint32_t offset, uint16_t value)
Definition NanoVDB.h:5992
ValueType getMin() const
Definition NanoVDB.h:5999
uint64_t getValue(uint32_t i) const
Definition NanoVDB.h:5990
MaskT< LOG2DIM > mValueMask
Definition NanoVDB.h:5970
void setValueOnly(uint32_t offset, uint16_t value)
Definition NanoVDB.h:5991
CoordT mBBoxMin
Definition NanoVDB.h:5967
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition NanoVDB.h:5980
uint64_t pointCount() const
Definition NanoVDB.h:5987
uint64_t first(uint32_t i) const
Definition NanoVDB.h:5988
uint16_t ArrayType
Definition NanoVDB.h:5964
ValueType getMax() const
Definition NanoVDB.h:6000
typename FloatTraits< ValueType >::FloatType FloatType
Definition NanoVDB.h:5963
LeafData()=delete
This class cannot be constructed or deleted.
FloatType getAvg() const
Definition NanoVDB.h:6001
void setAvg(const FloatType &)
Definition NanoVDB.h:6006
uint64_t last(uint32_t i) const
Definition NanoVDB.h:5989
static uint64_t memUsage()
Definition NanoVDB.h:5984
void setMin(const ValueType &)
Definition NanoVDB.h:6004
uint64_t mPointCount
Definition NanoVDB.h:5973
MaskT< LOG2DIM > mMask
Definition NanoVDB.h:5937
bool isMaskOn(uint32_t offset) const
Definition NanoVDB.h:5939
void setMask(uint32_t offset, bool v)
Definition NanoVDB.h:5940
static uint64_t memUsage()
Definition NanoVDB.h:5938
uint64_t lastOffset() const
Definition NanoVDB.h:5880
uint64_t getMax() const
Definition NanoVDB.h:5883
static uint32_t valueCount()
Definition NanoVDB.h:5878
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
uint64_t getValue(uint32_t i) const
Definition NanoVDB.h:5886
LeafData()=delete
This class cannot be constructed or deleted.
uint64_t getAvg() const
Definition NanoVDB.h:5884
uint64_t getDev() const
Definition NanoVDB.h:5885
uint64_t getMin() const
Definition NanoVDB.h:5882
void setOrigin(const T &ijk)
Definition NanoVDB.h:5824
bool getDev() const
Definition NanoVDB.h:5815
bool getMin() const
Definition NanoVDB.h:5812
static bool hasStats()
Definition NanoVDB.h:5805
void setMax(const ValueType &)
Definition NanoVDB.h:5819
bool getValue(uint32_t i) const
Definition NanoVDB.h:5811
uint8_t mFlags
Definition NanoVDB.h:5800
void setOn(uint32_t offset)
Definition NanoVDB.h:5817
LeafData & operator=(const LeafData &)=delete
bool getMax() const
Definition NanoVDB.h:5813
void setDev(const FloatType &)
Definition NanoVDB.h:5821
LeafData(const LeafData &)=delete
bool getAvg() const
Definition NanoVDB.h:5814
MaskT< LOG2DIM > mValueMask
Definition NanoVDB.h:5801
void setValue(uint32_t offset, bool)
Definition NanoVDB.h:5816
CoordT mBBoxMin
Definition NanoVDB.h:5798
static constexpr uint32_t padding()
Definition NanoVDB.h:5806
bool ValueType
Definition NanoVDB.h:5792
LeafData()=delete
This class cannot be constructed or deleted.
void setAvg(const FloatType &)
Definition NanoVDB.h:5820
static uint64_t memUsage()
Definition NanoVDB.h:5804
void setMin(const ValueType &)
Definition NanoVDB.h:5818
bool FloatType
Definition NanoVDB.h:5794
void ArrayType
Definition NanoVDB.h:5795
MaskT< LOG2DIM > mMask
Definition NanoVDB.h:5948
bool isMaskOn(uint32_t offset) const
Definition NanoVDB.h:5950
void setMask(uint32_t offset, bool v)
Definition NanoVDB.h:5951
static uint64_t memUsage()
Definition NanoVDB.h:5949
uint64_t lastOffset() const
Definition NanoVDB.h:5907
uint64_t getMax() const
Definition NanoVDB.h:5909
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
uint64_t getValue(uint32_t i) const
Definition NanoVDB.h:5912
uint32_t valueCount() const
Definition NanoVDB.h:5903
LeafData()=delete
This class cannot be constructed or deleted.
uint64_t getAvg() const
Definition NanoVDB.h:5910
uint64_t getDev() const
Definition NanoVDB.h:5911
uint64_t getMin() const
Definition NanoVDB.h:5908
void setOrigin(const T &ijk)
Definition NanoVDB.h:5775
bool getDev() const
Definition NanoVDB.h:5762
bool BuildType
Definition NanoVDB.h:5743
void setMin(const bool &)
Definition NanoVDB.h:5769
bool getMin() const
Definition NanoVDB.h:5759
void setMax(const bool &)
Definition NanoVDB.h:5770
void setValue(uint32_t offset, bool v)
Definition NanoVDB.h:5763
static bool hasStats()
Definition NanoVDB.h:5757
bool getValue(uint32_t i) const
Definition NanoVDB.h:5758
uint8_t mFlags
Definition NanoVDB.h:5750
void setOn(uint32_t offset)
Definition NanoVDB.h:5768
LeafData & operator=(const LeafData &)=delete
bool getMax() const
Definition NanoVDB.h:5760
LeafData(const LeafData &)=delete
MaskT< LOG2DIM > ArrayType
Definition NanoVDB.h:5745
bool getAvg() const
Definition NanoVDB.h:5761
MaskT< LOG2DIM > mValueMask
Definition NanoVDB.h:5751
MaskT< LOG2DIM > mValues
Definition NanoVDB.h:5752
CoordT mBBoxMin
Definition NanoVDB.h:5748
static constexpr uint32_t padding()
Definition NanoVDB.h:5755
bool ValueType
Definition NanoVDB.h:5742
void setDev(const bool &)
Definition NanoVDB.h:5772
LeafData()=delete
This class cannot be constructed or deleted.
static uint64_t memUsage()
Definition NanoVDB.h:5756
void setAvg(const bool &)
Definition NanoVDB.h:5771
bool FloatType
Definition NanoVDB.h:5744
Stuct with all the member data of the LeafNode (useful during serialization of an openvdb LeafNode)
Definition NanoVDB.h:5434
void setOrigin(const T &ijk)
Definition NanoVDB.h:5485
ValueType mMaximum
Definition NanoVDB.h:5449
FloatType getDev() const
Definition NanoVDB.h:5477
typename FloatTraits< ValueT >::FloatType FloatType
Definition NanoVDB.h:5439
void setMin(const ValueType &v)
Definition NanoVDB.h:5479
void setMax(const ValueType &v)
Definition NanoVDB.h:5480
static bool hasStats()
Definition NanoVDB.h:5463
FloatType mAverage
Definition NanoVDB.h:5450
void setDev(const FloatType &v)
Definition NanoVDB.h:5482
uint8_t mFlags
Definition NanoVDB.h:5445
void setOn(uint32_t offset)
Definition NanoVDB.h:5472
LeafData & operator=(const LeafData &)=delete
LeafData(const LeafData &)=delete
ValueType getMin() const
Definition NanoVDB.h:5474
void fill(const ValueType &v)
Definition NanoVDB.h:5487
ValueType getValue(uint32_t i) const
Definition NanoVDB.h:5465
void setValue(uint32_t offset, const ValueType &value)
Definition NanoVDB.h:5467
ValueT ValueType
Definition NanoVDB.h:5437
MaskT< LOG2DIM > mValueMask
Definition NanoVDB.h:5446
void setValueOnly(uint32_t offset, const ValueType &value)
Definition NanoVDB.h:5466
CoordT mBBoxMin
Definition NanoVDB.h:5443
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition NanoVDB.h:5457
ValueType getMax() const
Definition NanoVDB.h:5475
LeafData()=delete
This class cannot be constructed or deleted.
ValueT ArrayType
Definition NanoVDB.h:5440
FloatType getAvg() const
Definition NanoVDB.h:5476
static uint64_t memUsage()
Definition NanoVDB.h:5461
ValueType mMinimum
Definition NanoVDB.h:5448
void setAvg(const FloatType &v)
Definition NanoVDB.h:5481
ValueT BuildType
Definition NanoVDB.h:5438
ValueType mValues[1u<< 3 *LOG2DIM]
Definition NanoVDB.h:5452
FloatType mStdDevi
Definition NanoVDB.h:5451
Base-class for quantized float leaf nodes.
Definition NanoVDB.h:5505
void setOrigin(const T &ijk)
Definition NanoVDB.h:5565
float ValueType
Definition NanoVDB.h:5508
static bool hasStats()
Definition NanoVDB.h:5522
float getMin() const
return the quantized minimum of the active values in this node
Definition NanoVDB.h:5540
void setDev(float dev)
Definition NanoVDB.h:5562
void setMin(float min)
Definition NanoVDB.h:5553
float getAvg() const
return the quantized average of the active values in this node
Definition NanoVDB.h:5546
uint8_t mFlags
Definition NanoVDB.h:5513
void setOn(uint32_t offset)
Definition NanoVDB.h:5537
float mQuantum
Definition NanoVDB.h:5517
MaskT< LOG2DIM > mValueMask
Definition NanoVDB.h:5514
void init(float min, float max, uint8_t bitWidth)
Definition NanoVDB.h:5531
uint16_t mAvg
Definition NanoVDB.h:5518
CoordT mBBoxMin
Definition NanoVDB.h:5511
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition NanoVDB.h:5527
float mMinimum
Definition NanoVDB.h:5516
float FloatType
Definition NanoVDB.h:5509
void setMax(float max)
Definition NanoVDB.h:5556
void setAvg(float avg)
Definition NanoVDB.h:5559
static uint64_t memUsage()
Definition NanoVDB.h:5520
float getDev() const
return the quantized standard deviation of the active values in this node
Definition NanoVDB.h:5550
float getMax() const
return the quantized maximum of the active values in this node
Definition NanoVDB.h:5543
Definition NanoVDB.h:5838
void setOrigin(const T &ijk)
Definition NanoVDB.h:5865
uint64_t mOffset
Definition NanoVDB.h:5850
uint64_t ValueType
Definition NanoVDB.h:5841
uint64_t FloatType
Definition NanoVDB.h:5842
void setMax(const ValueType &)
Definition NanoVDB.h:5860
uint8_t mFlags
Definition NanoVDB.h:5848
void setOn(uint32_t offset)
Definition NanoVDB.h:5863
void setDev(const FloatType &)
Definition NanoVDB.h:5862
MaskT< LOG2DIM > mValueMask
Definition NanoVDB.h:5849
const uint64_t & firstOffset() const
Definition NanoVDB.h:5858
CoordT mBBoxMin
Definition NanoVDB.h:5846
static constexpr uint32_t padding()
Definition NanoVDB.h:5851
void setAvg(const FloatType &)
Definition NanoVDB.h:5861
static uint64_t memUsage()
Definition NanoVDB.h:5855
void setMin(const ValueType &)
Definition NanoVDB.h:5859
void ArrayType
Definition NanoVDB.h:5843
bool hasStats() const
Definition NanoVDB.h:5856
Definition NanoVDB.h:6030
static uint32_t dim()
Definition NanoVDB.h:6033
Defines an affine transform and its inverse represented as a 3x3 matrix and a vec3 translation.
Definition NanoVDB.h:3158
double mTaperD
Definition NanoVDB.h:3166
void set(const Mat4T &mat, const Mat4T &invMat, double taper=1.0)
Initialize the member data from 4x4 matrices.
Definition NanoVDB.h:3201
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
Vec3T applyIJTF(const Vec3T &xyz) const
Definition NanoVDB.h:3289
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
Map()
Default constructor for the identity map.
Definition NanoVDB.h:3169
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
Vec3d getVoxelSize() const
Return a voxels size in each coordinate direction, measured at the origin.
Definition NanoVDB.h:3292
Map(double s, const Vec3d &t=Vec3d(0.0, 0.0, 0.0))
Definition NanoVDB.h:3180
Vec3T applyMap(const Vec3T &ijk) const
Apply the forward affine transformation to a vector using 64bit floating point arithmetics.
Definition NanoVDB.h:3212
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
Vec3T applyMapF(const Vec3T &ijk) const
Apply the forward affine transformation to a vector using 32bit floating point arithmetics.
Definition NanoVDB.h:3220
Vec3T applyInverseMap(const Vec3T &xyz) const
Apply the inverse affine mapping to a vector using 64bit floating point arithmetics.
Definition NanoVDB.h:3246
Vec3T applyInverseMapF(const Vec3T &xyz) const
Apply the inverse affine mapping to a vector using 32bit floating point arithmetics.
Definition NanoVDB.h:3257
float mTaperF
Definition NanoVDB.h:3162
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
Maximum floating-point values.
Definition NanoVDB.h:1076
static T value()
Definition NanoVDB.h:1077
Trait to map from LEVEL to node type.
Definition NanoVDB.h:6453
typename GridOrTreeOrRootT::LeafNodeType type
Definition NanoVDB.h:3412
typename GridOrTreeOrRootT::LeafNodeType Type
Definition NanoVDB.h:3411
typename GridOrTreeOrRootT::RootNodeType::ChildNodeType::ChildNodeType Type
Definition NanoVDB.h:3426
typename GridOrTreeOrRootT::RootNodeType::ChildNodeType::ChildNodeType type
Definition NanoVDB.h:3427
typename GridOrTreeOrRootT::RootNodeType::ChildNodeType type
Definition NanoVDB.h:3441
typename GridOrTreeOrRootT::RootNodeType::ChildNodeType Type
Definition NanoVDB.h:3440
typename GridOrTreeOrRootT::RootNodeType type
Definition NanoVDB.h:3455
typename GridOrTreeOrRootT::RootNodeType Type
Definition NanoVDB.h:3454
const typename GridOrTreeOrRootT::LeafNodeType Type
Definition NanoVDB.h:3418
const typename GridOrTreeOrRootT::LeafNodeType type
Definition NanoVDB.h:3419
const typename GridOrTreeOrRootT::RootNodeType::ChildNodeType::ChildNodeType type
Definition NanoVDB.h:3434
const typename GridOrTreeOrRootT::RootNodeType::ChildNodeType::ChildNodeType Type
Definition NanoVDB.h:3433
const typename GridOrTreeOrRootT::RootNodeType::ChildNodeType Type
Definition NanoVDB.h:3447
const typename GridOrTreeOrRootT::RootNodeType::ChildNodeType type
Definition NanoVDB.h:3448
const typename GridOrTreeOrRootT::RootNodeType type
Definition NanoVDB.h:3463
const typename GridOrTreeOrRootT::RootNodeType Type
Definition NanoVDB.h:3462
Struct to derive node type from its level in a given grid, tree or root while preserving constness.
Definition NanoVDB.h:3404
Implements Tree::probeLeaf(Coord)
Definition NanoVDB.h:8159
static bool get(const typename NanoRoot< BuildT >::Tile &tile, ValueT &v)
Definition NanoVDB.h:8166
static bool get(const NanoLeaf< BuildT > &leaf, uint32_t n, ValueT &v)
Definition NanoVDB.h:8181
static bool get(const NanoUpper< BuildT > &node, uint32_t n, ValueT &v)
Definition NanoVDB.h:8171
static bool get(const NanoRoot< BuildT > &root, ValueT &v)
Definition NanoVDB.h:8161
typename BuildToValueMap< BuildT >::Type ValueT
Definition NanoVDB.h:8160
static bool get(const NanoLower< BuildT > &node, uint32_t n, ValueT &v)
Definition NanoVDB.h:8176
Definition NanoVDB.h:4224
ValueT value
Definition NanoVDB.h:4247
uint32_t state
Definition NanoVDB.h:4246
bool isActive() const
Definition NanoVDB.h:4242
KeyT key
Definition NanoVDB.h:4244
void setValue(const CoordType &k, bool s, const ValueType &v)
Definition NanoVDB.h:4233
CoordT origin() const
Definition NanoVDB.h:4243
bool isValue() const
Definition NanoVDB.h:4241
bool isChild() const
Definition NanoVDB.h:4240
void setChild(const CoordType &k, const void *ptr, const RootData *data)
Definition NanoVDB.h:4226
int64_t child
Definition NanoVDB.h:4245
Struct with all the member data of the RootNode (useful during serialization of an openvdb RootNode)
Definition NanoVDB.h:4175
StatsT mAverage
Definition NanoVDB.h:4212
typename ChildT::CoordType CoordT
Definition NanoVDB.h:4178
static CoordT KeyToCoord(const KeyT &key)
Definition NanoVDB.h:4194
const ChildT * getChild(const Tile *tile) const
Definition NanoVDB.h:4302
RootData()=delete
This class cannot be constructed or deleted.
ValueT mBackground
Definition NanoVDB.h:4209
Tile * tile(uint32_t n)
Definition NanoVDB.h:4258
const Tile * tile(uint32_t n) const
Returns a non-const reference to the tile at the specified linear offset.
Definition NanoVDB.h:4253
uint32_t mTableSize
Definition NanoVDB.h:4207
Tile * probeTile(const CoordT &ijk)
Definition NanoVDB.h:4264
const ValueT & getMax() const
Definition NanoVDB.h:4309
void setDev(const StatsT &v)
Definition NanoVDB.h:4316
uint64_t KeyT
Return a key based on the coordinates of a voxel.
Definition NanoVDB.h:4184
void setMin(const ValueT &v)
Definition NanoVDB.h:4313
typename ChildT::FloatType StatsT
Definition NanoVDB.h:4179
typename ChildT::BuildType BuildT
Definition NanoVDB.h:4177
ChildT * getChild(const Tile *tile)
Returns a const reference to the child node in the specified tile.
Definition NanoVDB.h:4297
static constexpr uint32_t padding()
Return padding of this class in bytes, due to aliasing and 32B alignment.
Definition NanoVDB.h:4218
const ValueT & getMin() const
Definition NanoVDB.h:4308
void setMax(const ValueT &v)
Definition NanoVDB.h:4314
StatsT mStdDevi
Definition NanoVDB.h:4213
RootData(const RootData &)=delete
static KeyT CoordToKey(const CoordType &ijk)
Definition NanoVDB.h:4186
RootData & operator=(const RootData &)=delete
BBox< CoordT > mBBox
Definition NanoVDB.h:4206
ValueT mMaximum
Definition NanoVDB.h:4211
const StatsT & stdDeviation() const
Definition NanoVDB.h:4311
const StatsT & average() const
Definition NanoVDB.h:4310
const Tile * probeTile(const CoordT &ijk) const
Definition NanoVDB.h:4289
void setAvg(const StatsT &v)
Definition NanoVDB.h:4315
typename ChildT::ValueType ValueT
Definition NanoVDB.h:4176
ValueT mMinimum
Definition NanoVDB.h:4210
Definition NanoVDB.h:8073
static auto set(NanoLower< BuildT > &node, uint32_t n, const ValueT &v)
Definition NanoVDB.h:8079
static auto set(NanoLeaf< BuildT > &leaf, uint32_t n, const ValueT &v)
Definition NanoVDB.h:8080
static auto set(NanoRoot< BuildT > &, const ValueT &)
Definition NanoVDB.h:8076
static auto set(NanoUpper< BuildT > &node, uint32_t n, const ValueT &v)
Definition NanoVDB.h:8078
typename NanoLeaf< BuildT >::ValueType ValueT
Definition NanoVDB.h:8075
static auto set(typename NanoRoot< BuildT >::Tile &tile, const ValueT &v)
Definition NanoVDB.h:8077
Definition NanoVDB.h:8085
static auto set(NanoLeaf< BuildT > &leaf, uint32_t n, const ValueT &v)
Definition NanoVDB.h:8092
static auto set(NanoRoot< BuildT > &, const ValueT &)
Definition NanoVDB.h:8088
static auto set(NanoUpper< BuildT > &, uint32_t, const ValueT &)
Definition NanoVDB.h:8090
static auto set(NanoLower< BuildT > &, uint32_t, const ValueT &)
Definition NanoVDB.h:8091
typename NanoLeaf< BuildT >::ValueType ValueT
Definition NanoVDB.h:8087
static auto set(typename NanoRoot< BuildT >::Tile &, const ValueT &)
Definition NanoVDB.h:8089
T ElementType
Definition NanoVDB.h:1975
static T scalar(const T &s)
Definition NanoVDB.h:1976
static ElementType scalar(const T &v)
Definition NanoVDB.h:1987
typename T::ValueType ElementType
Definition NanoVDB.h:1986
Definition NanoVDB.h:1966
static double value()
Definition NanoVDB.h:1028
static float value()
Definition NanoVDB.h:1023
Tolerance for floating-point comparison.
Definition NanoVDB.h:1019
Definition NanoVDB.h:3941
const uint8_t * getRoot() const
Definition NanoVDB.h:3955
bool isRootNext() const
return true if RootData is layout out immediately after TreeData in memory
Definition NanoVDB.h:3966
TreeData & operator=(const TreeData &other)
Definition NanoVDB.h:3947
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
void setFirstNode(const NodeT *node)
Definition NanoVDB.h:3958
void setRoot(const void *root)
Definition NanoVDB.h:3953
uint8_t * getRoot()
Definition NanoVDB.h:3954
uint32_t mNodeCount[3]
Definition NanoVDB.h:3943
bool isEmpty() const
Definition NanoVDB.h:3960
uint32_t mTileCount[3]
Definition NanoVDB.h:3944
uint64_t mVoxelCount
Definition NanoVDB.h:3945
T type
Definition NanoVDB.h:507
T type
Definition NanoVDB.h:499
C++11 implementation of std::enable_if.
Definition NanoVDB.h:493
static constexpr bool value
Definition NanoVDB.h:520
C++11 implementation of std::is_floating_point.
Definition NanoVDB.h:463
static constexpr bool value
Definition NanoVDB.h:464
Trait used to identify template parameter that are pointers.
Definition NanoVDB.h:535
static constexpr bool value
Definition NanoVDB.h:536
C++11 implementation of std::is_same.
Definition NanoVDB.h:442
static constexpr bool value
Definition NanoVDB.h:443
Metafunction used to determine if the first template parameter is a specialization of the class templ...
Definition NanoVDB.h:638
static const bool value
Definition NanoVDB.h:639
const typename remove_const< T >::type type
Definition NanoVDB.h:624
Trait used to transfer the const-ness of a reference type to another type.
Definition NanoVDB.h:612
typename remove_const< T >::type type
Definition NanoVDB.h:613
T type
Definition NanoVDB.h:572
Trait use to const from type. Default implementation is just a pass-through.
Definition NanoVDB.h:562
T type
Definition NanoVDB.h:563
T type
Definition NanoVDB.h:601
Trait use to remove pointer, i.e. "*", qualifier from a type. Default implementation is just a pass-t...
Definition NanoVDB.h:595
T type
Definition NanoVDB.h:595
T type
Definition NanoVDB.h:587
Trait use to remove reference, i.e. "&", qualifier from a type. Default implementation is just a pass...
Definition NanoVDB.h:581
T type
Definition NanoVDB.h:581
Definition NanoVDB.h:4868
ValueT value
Definition NanoVDB.h:4869
Tile(const Tile &)=delete
Tile & operator=(const Tile &)=delete
Tile()=delete
This class cannot be constructed or deleted.
int64_t child
Definition NanoVDB.h:4870