Go to the documentation of this file.
8 #ifndef OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
9 #define OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
29 #if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER)
31 #elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
32 return __builtin_popcount(v);
35 static const Byte numBits[256] = {
36 #define COUNTONB2(n) n, n+1, n+1, n+2
37 #define COUNTONB4(n) COUNTONB2(n), COUNTONB2(n+1), COUNTONB2(n+1), COUNTONB2(n+2)
38 #define COUNTONB6(n) COUNTONB4(n), COUNTONB4(n+1), COUNTONB4(n+1), COUNTONB4(n+2)
55 v = v - ((v >> 1) & 0x55555555U);
56 v = (v & 0x33333333U) + ((v >> 2) & 0x33333333U);
57 return (((v + (v >> 4)) & 0xF0F0F0FU) * 0x1010101U) >> 24;
67 #if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER) && defined(_M_X64)
69 #elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
70 v = __builtin_popcountll(v);
73 v = v - ((v >> 1) & UINT64_C(0x5555555555555555));
74 v = (v & UINT64_C(0x3333333333333333)) + ((v >> 2) & UINT64_C(0x3333333333333333));
75 v = (((v + (v >> 4)) & UINT64_C(0xF0F0F0F0F0F0F0F)) * UINT64_C(0x101010101010101)) >> 56;
88 #if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER)
90 _BitScanForward(&index,
static_cast<Index32>(v));
91 return static_cast<Index32>(index);
92 #elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
93 return __builtin_ctz(v);
96 static const Byte DeBruijn[8] = {0, 1, 6, 2, 7, 5, 4, 3};
97 return DeBruijn[
Byte((v & -v) * 0x1DU) >> 5];
107 static const Byte DeBruijn[32] = {
108 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
109 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
113 #if defined(_MSC_VER)
114 #pragma warning(push)
115 #pragma warning(disable:4146)
117 return DeBruijn[
Index32((v & -v) * 0x077CB531U) >> 27];
118 #if defined(_MSC_VER)
128 #if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER)
130 _BitScanForward64(&index, v);
131 return static_cast<Index32>(index);
132 #elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
133 return static_cast<Index32>(__builtin_ctzll(v));
136 static const Byte DeBruijn[64] = {
137 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
138 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
139 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
140 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12,
145 #if defined(_MSC_VER)
146 #pragma warning(push)
147 #pragma warning(disable:4146)
149 return DeBruijn[
Index64((v & -v) * UINT64_C(0x022FDD63CC95386D)) >> 58];
150 #if defined(_MSC_VER)
161 static const Byte DeBruijn[32] = {
162 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
163 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
170 return DeBruijn[
Index32(v * 0x07C4ACDDU) >> 27];
178 template<
typename NodeMask>
190 assert((parent ==
nullptr && pos == 0) || (parent !=
nullptr && pos <= NodeMask::SIZE));
197 mPos = iter.
mPos; mParent = iter.
mParent;
return *
this;
201 bool test()
const { assert(mPos <= NodeMask::SIZE);
return (mPos != NodeMask::SIZE); }
202 operator bool()
const {
return this->test(); }
207 template <
typename NodeMask>
212 using BaseType::mPos;
213 using BaseType::mParent;
219 assert(mParent !=
nullptr);
220 mPos = mParent->findNextOn(mPos+1);
221 assert(mPos <= NodeMask::SIZE);
238 template <
typename NodeMask>
243 using BaseType::mPos;
244 using BaseType::mParent;
250 assert(mParent !=
nullptr);
251 mPos=mParent->findNextOff(mPos+1);
252 assert(mPos <= NodeMask::SIZE);
269 template <
typename NodeMask>
274 using BaseType::mPos;
275 using BaseType::mParent;
282 assert(mParent !=
nullptr);
284 assert(mPos<= NodeMask::SIZE);
306 template<Index Log2Dim>
310 static_assert(Log2Dim > 2,
"expected NodeMask template specialization, got base template");
328 Word mWords[WORD_COUNT];
343 const Word* w2 = other.mWords;
344 for (
Word* w1 = mWords; n--; ++w1, ++w2) *w1 = *w2;
362 for (
const Word *w1=mWords, *w2=other.mWords; n-- && *w1++ == *w2++;) ;
378 template<
typename WordOp>
382 const Word *w2 = other.mWords;
383 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) op( *w1, *w2);
386 template<
typename WordOp>
390 const Word *w2 = other1.mWords, *w3 = other2.mWords;
391 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2, ++w3) op( *w1, *w2, *w3);
394 template<
typename WordOp>
399 const Word *w2 = other1.mWords, *w3 = other2.mWords, *w4 = other3.mWords;
400 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2, ++w3, ++w4) op( *w1, *w2, *w3, *w4);
407 const Word *w2 = other.mWords;
408 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= *w2;
415 const Word *w2 = other.mWords;
416 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 |= *w2;
423 const Word *w2 = other.mWords;
424 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= ~*w2;
431 const Word *w2 = other.mWords;
432 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 ^= *w2;
445 Index32 sum = 0, n = WORD_COUNT;
446 for (
const Word* w = mWords; n--; ++w) sum +=
CountOn(*w);
453 assert( (n >> 6) < WORD_COUNT );
454 mWords[n >> 6] |=
Word(1) << (n & 63);
458 assert( (n >> 6) < WORD_COUNT );
459 mWords[n >> 6] &= ~(
Word(1) << (n & 63));
462 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
468 for (
Word* w = mWords; n--; ++w) *w = state;
474 for (
Word* w = mWords; n--; ++w) *w = ~
Word(0);
480 for (
Word* w = mWords; n--; ++w) *w =
Word(0);
484 assert( (n >> 6) < WORD_COUNT );
485 mWords[n >> 6] ^=
Word(1) << (n & 63);
491 for (
Word* w = mWords; n--; ++w) *w = ~*w;
504 assert( (n >> 6) < WORD_COUNT );
505 return 0 != (mWords[n >> 6] & (
Word(1) << (n & 63)));
513 for (
const Word *w = mWords; n-- && *w++ == ~
Word(0);) ;
520 for (
const Word *w = mWords; n-- && *w++ ==
Word(0);) ;
528 isOn = (mWords[0] == ~
Word(0));
529 if ( !isOn && mWords[0] !=
Word(0))
return false;
530 const Word *w = mWords + 1, *n = mWords + WORD_COUNT;
531 while( w<n && *w == mWords[0] ) ++w;
537 const Word* w = mWords;
538 for (; n<WORD_COUNT && !*w; ++w, ++n) ;
539 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(*w);
544 const Word* w = mWords;
545 for (; n<WORD_COUNT && !~*w; ++w, ++n) ;
546 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(~*w);
550 template<
typename WordT>
554 assert(n*8*
sizeof(WordT) < SIZE);
555 return reinterpret_cast<const WordT*
>(mWords)[n];
557 template<
typename WordT>
560 assert(n*8*
sizeof(WordT) < SIZE);
561 return reinterpret_cast<WordT*
>(mWords)[n];
565 void save(std::ostream& os)
const
567 os.write(
reinterpret_cast<const char*
>(mWords), this->memUsage());
569 void load(std::istream& is) { is.read(
reinterpret_cast<char*
>(mWords), this->memUsage()); }
570 void seek(std::istream& is)
const { is.seekg(this->memUsage(), std::ios_base::cur); }
574 os <<
"NodeMask: Dim=" << DIM <<
" Log2Dim=" << Log2Dim
575 <<
" Bit count=" << SIZE <<
" word count=" << WORD_COUNT << std::endl;
579 const Index32 n=(SIZE>max_out ? max_out : SIZE);
580 for (
Index32 i=0; i < n; ++i) {
587 os <<
"|" << std::endl;
592 this->printBits(os, max_out);
598 if (n >= WORD_COUNT)
return SIZE;
601 if (b & (
Word(1) << m))
return start;
603 while(!b && ++n<WORD_COUNT) b = mWords[n];
610 if (n >= WORD_COUNT)
return SIZE;
613 if (b & (
Word(1) << m))
return start;
615 while(!b && ++n<WORD_COUNT) b = ~mWords[n];
647 void operator = (
const NodeMask &other) { mByte = other.mByte; }
674 template<
typename WordOp>
677 op(mByte, other.mByte);
680 template<
typename WordOp>
683 op(mByte, other1.mByte, other2.mByte);
686 template<
typename WordOp>
690 op(mByte, other1.mByte, other2.mByte, other3.mByte);
696 mByte &= other.mByte;
702 mByte |= other.mByte;
708 mByte &=
static_cast<Byte>(~other.mByte);
714 mByte ^= other.mByte;
730 mByte =
static_cast<Byte>(mByte | 0x01U << (n & 7));
735 mByte =
static_cast<Byte>(mByte & ~(0x01U << (n & 7)));
738 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
740 void set(
bool on) { mByte = on ? 0xFFU : 0x00U; }
748 mByte =
static_cast<Byte>(mByte ^ 0x01U << (n & 7));
764 return mByte & (0x01U << (n & 7));
769 bool isOn()
const {
return mByte == 0xFFU; }
771 bool isOff()
const {
return mByte == 0; }
778 return isOn || this->isOff();
783 const Byte b =
static_cast<Byte>(~mByte);
806 void save(std::ostream& os)
const { os.write(
reinterpret_cast<const char*
>(&mByte), 1); }
807 void load(std::istream& is) { is.read(
reinterpret_cast<char*
>(&mByte), 1); }
808 void seek(std::istream& is)
const { is.seekg(1, std::ios_base::cur); }
812 os <<
"NodeMask: Dim=2, Log2Dim=1, Bit count=8, Word count=1"<<std::endl;
817 for (
Index32 i=0; i < 8; ++i) os << this->isOn(i);
818 os <<
"||" << std::endl;
828 if (start>=8)
return 8;
829 const Byte b =
static_cast<Byte>(mByte & (0xFFU << start));
835 if (start>=8)
return 8;
836 const Byte b =
static_cast<Byte>(~mByte & (0xFFU << start));
863 NodeMask(
bool on) : mWord(on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00)) {}
869 void operator = (
const NodeMask &other) { mWord = other.mWord; }
896 template<
typename WordOp>
899 op(mWord, other.mWord);
902 template<
typename WordOp>
905 op(mWord, other1.mWord, other2.mWord);
908 template<
typename WordOp>
912 op(mWord, other1.mWord, other2.mWord, other3.mWord);
918 mWord &= other.mWord;
924 mWord |= other.mWord;
930 mWord &= ~other.mWord;
936 mWord ^= other.mWord;
952 mWord |= UINT64_C(0x01) << (n & 63);
957 mWord &= ~(UINT64_C(0x01) << (n & 63));
960 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
962 void set(
bool on) { mWord = on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00); }
964 void setOn() { mWord = UINT64_C(0xFFFFFFFFFFFFFFFF); }
966 void setOff() { mWord = UINT64_C(0x00); }
970 mWord ^= UINT64_C(0x01) << (n & 63);
986 return 0 != (mWord & (UINT64_C(0x01) << (n & 63)));
991 bool isOn()
const {
return mWord == UINT64_C(0xFFFFFFFFFFFFFFFF); }
993 bool isOff()
const {
return mWord == 0; }
998 { isOn = this->isOn();
999 return isOn || this->isOff();
1004 const Word w = ~mWord;
1008 template<
typename WordT>
1012 assert(n*8*
sizeof(WordT) < SIZE);
1013 return reinterpret_cast<const WordT*
>(&mWord)[n];
1015 template<
typename WordT>
1018 assert(n*8*
sizeof(WordT) < SIZE);
1019 return reinterpret_cast<WordT*
>(mWord)[n];
1022 void save(std::ostream& os)
const { os.write(
reinterpret_cast<const char*
>(&mWord), 8); }
1023 void load(std::istream& is) { is.read(
reinterpret_cast<char*
>(&mWord), 8); }
1024 void seek(std::istream& is)
const { is.seekg(8, std::ios_base::cur); }
1028 os <<
"NodeMask: Dim=4, Log2Dim=2, Bit count=64, Word count=1"<<std::endl;
1033 for (
Index32 i=0; i < 64; ++i) {
1034 if ( !(i%8) ) os <<
"|";
1035 os << this->isOn(i);
1037 os <<
"||" << std::endl;
1041 this->printInfo(os);
1042 this->printBits(os);
1047 if (start>=64)
return 64;
1048 const Word w = mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1054 if (start>=64)
return 64;
1055 const Word w = ~mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1075 mBitSize(bit_size), mIntSize(((bit_size-1)>>5)+1), mBits(new
Index32[mIntSize])
1077 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1080 mBitSize(B.mBitSize), mIntSize(B.mIntSize), mBits(new
Index32[mIntSize])
1082 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=B.
mBits[i];
1087 mBitSize = bit_size;
1088 mIntSize =((bit_size-1)>>5)+1;
1090 mBits =
new Index32[mIntSize];
1091 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1103 mBits =
new Index32[mIntSize];
1105 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=B.
mBits[i];
1119 mPos(pos), mBitSize(parent->getBitSize()), mParent(parent) { assert(pos <= mBitSize); }
1135 assert(mPos <= mBitSize);
1136 return (mPos != mBitSize);
1139 operator bool()
const {
return this->test();}
1146 using BaseIterator::mPos;
1147 using BaseIterator::mBitSize;
1148 using BaseIterator::mParent;
1153 assert(mParent !=
nullptr);
1154 mPos=mParent->findNextOn(mPos+1);
1155 assert(mPos <= mBitSize);
1158 for (
Index i=0; i<n && this->next(); ++i) {}
1162 return this->test();
1174 using BaseIterator::mPos;
1175 using BaseIterator::mBitSize;
1176 using BaseIterator::mParent;
1181 assert(mParent !=
nullptr);
1182 mPos=mParent->findNextOff(mPos+1);
1183 assert(mPos <= mBitSize);
1186 for (
Index i=0; i<n && this->next(); ++i) {}
1190 return this->test();
1202 using BaseIterator::mPos;
1203 using BaseIterator::mBitSize;
1204 using BaseIterator::mParent;
1209 assert(mParent !=
nullptr);
1211 assert(mPos<= mBitSize);
1214 for (
Index i=0; i<n && this->next(); ++i) {}
1218 return this->test();
1235 if (mBitSize != B.
mBitSize)
return false;
1236 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return false;
1241 if (mBitSize != B.
mBitSize)
return true;
1242 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return true;
1251 assert(mIntSize == other.
mIntSize);
1253 mBits[i] &= other.
mBits[i];
1255 for (
Index32 i = other.
mIntSize; i < mIntSize; ++i) mBits[i] = 0x00000000;
1259 assert(mIntSize == other.
mIntSize);
1261 mBits[i] |= other.
mBits[i];
1266 assert(mIntSize == other.
mIntSize);
1268 mBits[i] ^= other.
mBits[i];
1284 return static_cast<Index32>(mIntSize*
sizeof(
Index32) +
sizeof(*
this));
1298 assert( (i>>5) < mIntSize);
1299 mBits[i>>5] |= 1<<(i&31);
1304 assert( (i>>5) < mIntSize);
1305 mBits[i>>5] &= ~(1<<(i&31));
1308 void set(
Index32 i,
bool On) { On ? this->setOn(i) : this->setOff(i); }
1312 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0xFFFFFFFF;
1316 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1320 assert( (i>>5) < mIntSize);
1321 mBits[i>>5] ^= 1<<(i&31);
1325 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=~mBits[i];
1333 assert( (i>>5) < mIntSize);
1334 return ( mBits[i >> 5] & (1<<(i&31)) );
1338 assert( (i>>5) < mIntSize);
1339 return ( ~mBits[i >> 5] & (1<<(i&31)) );
1343 if (!mBits)
return false;
1344 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0xFFFFFFFF)
return false;
1349 if (!mBits)
return true;
1350 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0)
return false;
1357 while(!mBits[i])
if (++i == mIntSize)
return mBitSize;
1364 while(!(~mBits[i]))
if (++i == mIntSize)
return mBitSize;
1368 void save(std::ostream& os)
const {
1370 os.write(
reinterpret_cast<const char*
>(mBits), mIntSize *
sizeof(
Index32));
1374 is.read(
reinterpret_cast<char*
>(mBits), mIntSize *
sizeof(
Index32));
1376 void seek(std::istream& is)
const {
1378 is.seekg(mIntSize *
sizeof(
Index32), std::ios_base::cur);
1382 os <<
"RootNodeMask: Bit-size="<<mBitSize<<
" Int-size="<<mIntSize<<std::endl;
1386 const Index32 n=(mBitSize>max_out?max_out:mBitSize);
1387 for (
Index32 i=0; i < n; ++i) {
1392 os << this->isOn(i);
1394 os <<
"|" << std::endl;
1398 this->printInfo(os);
1399 this->printBits(os,max_out);
1404 Index32 n = start >> 5, m = start & 31;
1405 if (n>=mIntSize)
return mBitSize;
1407 if (b & (1<<m))
return start;
1408 b &= 0xFFFFFFFF << m;
1409 while(!b && ++n<mIntSize) b = mBits[n];
1415 Index32 n = start >> 5, m = start & 31;
1416 if (n>=mIntSize)
return mBitSize;
1418 if (b & (1<<m))
return start;
1420 while(!b && ++n<mIntSize) b = ~mBits[n];
1434 #endif // OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
~NodeMask()
Destructor.
Definition: NodeMasks.h:867
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1385
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:517
void setOn()
Set all bits on.
Definition: NodeMasks.h:964
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1397
const RootNodeMask & operator|=(const RootNodeMask &other)
Definition: NodeMasks.h:1258
Index32 countOn() const
Definition: NodeMasks.h:1287
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:759
Index32 memUsage() const
Definition: NodeMasks.h:1424
void seek(std::istream &is) const
Definition: NodeMasks.h:1376
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:989
void setOn()
Set all bits on.
Definition: NodeMasks.h:742
bool operator*() const
Definition: NodeMasks.h:1220
void load(std::istream &is)
Definition: NodeMasks.h:1372
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:694
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:457
bool operator*() const
Definition: NodeMasks.h:292
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:922
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:981
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:767
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:916
NodeMask & operator=(const NodeMask &other)
Assignment operator.
Definition: NodeMasks.h:340
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:336
Byte Word
Definition: NodeMasks.h:631
Index32 FindHighestOn(Index32 v)
Return the most significant on bit of the given 32-bit value.
Definition: NodeMasks.h:159
DenseIterator beginDense() const
Definition: NodeMasks.h:356
Index32 mBitSize
Definition: NodeMasks.h:1069
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:450
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:810
void increment(Index n)
Definition: NodeMasks.h:286
BaseIterator(const BaseIterator &)=default
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:428
void set(Index32 i, bool On)
Definition: NodeMasks.h:1308
RootNodeMask()
Definition: NodeMasks.h:1073
RootNodeMask operator!() const
Definition: NodeMasks.h:1249
void setOff()
Definition: NodeMasks.h:1314
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:502
DenseIterator beginDense() const
Definition: NodeMasks.h:879
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:420
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:934
void toggle()
Definition: NodeMasks.h:1323
Index32 CountOff(Index64 v)
Return the number of off bits in the given 64-bit value.
Definition: NodeMasks.h:81
void toggle(Index32 i)
Definition: NodeMasks.h:1318
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1052
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:712
BaseMaskIterator()
Definition: NodeMasks.h:186
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1026
void setLastOn()
Definition: NodeMasks.h:1328
bool operator*() const
Definition: NodeMasks.h:1192
Index32 findFirstOn() const
Definition: NodeMasks.h:780
bool operator<(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:180
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:720
void setOn(Index32 i)
Definition: NodeMasks.h:1296
Index32 findFirstOn() const
Definition: NodeMasks.h:1001
OnIterator endOn() const
Definition: NodeMasks.h:654
DenseIterator beginDense() const
Definition: NodeMasks.h:657
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:726
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:552
const RootNodeMask & operator^=(const RootNodeMask &other)
Definition: NodeMasks.h:1265
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:820
OnIterator endOn() const
Definition: NodeMasks.h:876
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:865
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:404
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:833
OffIterator beginOff() const
Definition: NodeMasks.h:354
WordT & getWord(Index n)
Definition: NodeMasks.h:1016
BaseIterator & operator=(const BaseIterator &iter)
Definition: NodeMasks.h:1123
DenseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1207
bool test() const
Definition: NodeMasks.h:1134
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1039
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:968
BaseIterator()
Definition: NodeMasks.h:1116
void save(std::ostream &os) const
Definition: NodeMasks.h:1368
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:643
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:942
OnIterator endOn() const
Definition: NodeMasks.h:353
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:443
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:973
OnIterator beginOn() const
Definition: NodeMasks.h:875
void increment()
Definition: NodeMasks.h:217
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:746
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:479
OnIterator endOn() const
Definition: NodeMasks.h:1228
bool next()
Definition: NodeMasks.h:224
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:948
Definition: NodeMasks.h:209
Index32 findFirstOff() const
Definition: NodeMasks.h:1002
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:751
OnIterator()
Definition: NodeMasks.h:1150
void setOff()
Set all bits off.
Definition: NodeMasks.h:477
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:607
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:483
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:498
Definition: NodeMasks.h:271
DenseIterator beginDense() const
Definition: NodeMasks.h:1231
RootNodeMask operator|(const RootNodeMask &other) const
Definition: NodeMasks.h:1275
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:814
~NodeMask()
Destructor.
Definition: NodeMasks.h:338
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:724
Index32 pos() const
Definition: NodeMasks.h:1132
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:572
OnIterator beginOn() const
Definition: NodeMasks.h:653
RootNodeMask(Index32 bit_size)
Definition: NodeMasks.h:1074
Definition: NodeMasks.h:240
Definition: NodeMasks.h:1144
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:946
bool isOn(Index32 i) const
Definition: NodeMasks.h:1331
bool operator*() const
Definition: NodeMasks.h:260
Index32 findFirstOff() const
Definition: NodeMasks.h:781
OffIterator endOff() const
Definition: NodeMasks.h:1230
uint32_t Index32
Definition: openvdb/Types.h:30
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:738
BaseMaskIterator & operator=(const BaseMaskIterator &iter)
Definition: NodeMasks.h:195
void increment(Index n)
Definition: NodeMasks.h:223
Index32 findFirstOff() const
Definition: NodeMasks.h:1361
OnIterator & operator++()
Definition: NodeMasks.h:1165
bool next()
Definition: NodeMasks.h:1160
Definition: NodeMasks.h:1067
DenseMaskIterator & operator++()
Definition: NodeMasks.h:293
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:960
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1413
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:950
bool operator*() const
Definition: NodeMasks.h:229
RootNodeMask operator&(const RootNodeMask &other) const
Definition: NodeMasks.h:1272
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1030
Index32 mBitSize
Definition: NodeMasks.h:1113
void init(Index32 bit_size)
Definition: NodeMasks.h:1086
NodeMask operator!() const
Definition: NodeMasks.h:435
void save(std::ostream &os) const
Definition: NodeMasks.h:1022
const RootNodeMask * mParent
Definition: NodeMasks.h:1114
bool isOff() const
Definition: NodeMasks.h:1348
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:728
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:488
void setOff(Index32 i)
Definition: NodeMasks.h:1302
Index32 mIntSize
Definition: NodeMasks.h:1069
uint64_t Index64
Definition: openvdb/Types.h:31
void increment(Index n)
Definition: NodeMasks.h:254
OffMaskIterator & operator++()
Definition: NodeMasks.h:261
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:775
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:437
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:718
void increment()
Definition: NodeMasks.h:1180
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:991
OffIterator beginOff() const
Definition: NodeMasks.h:877
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:508
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:595
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:997
Definition: NodeMasks.h:1172
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:983
Index32 countOff() const
Definition: NodeMasks.h:1294
const RootNodeMask & operator&=(const RootNodeMask &other)
Definition: NodeMasks.h:1250
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1045
void increment()
Definition: NodeMasks.h:1208
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:940
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:941
void increment()
Definition: NodeMasks.h:248
void save(std::ostream &os) const
Definition: NodeMasks.h:806
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:462
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:761
RootNodeMask(const RootNodeMask &B)
Definition: NodeMasks.h:1079
OnIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1151
Index64 Word
Definition: NodeMasks.h:316
OffMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:247
OnIterator beginOn() const
Definition: NodeMasks.h:1227
RootNodeMask operator^(const RootNodeMask &other) const
Definition: NodeMasks.h:1278
void increment(Index n)
Definition: NodeMasks.h:1213
Index32 offset() const
Definition: NodeMasks.h:1130
Index32 mPos
Definition: NodeMasks.h:182
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:496
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:526
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:441
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation.
Definition: NodeMasks.h:308
bool next()
Definition: NodeMasks.h:1216
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:471
NodeMask operator!() const
Definition: NodeMasks.h:717
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:769
BaseMaskIterator(const BaseMaskIterator &)=default
OffIterator beginOff() const
Definition: NodeMasks.h:655
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:975
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:826
Index32 FindLowestOn(Index64 v)
Return the least significant on bit of the given 64-bit value.
Definition: NodeMasks.h:125
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:719
NodeMask operator!() const
Definition: NodeMasks.h:939
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:771
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:753
OffIterator beginOff() const
Definition: NodeMasks.h:1229
void load(std::istream &is)
Definition: NodeMasks.h:569
DenseMaskIterator()
Definition: NodeMasks.h:278
Definition: NodeMasks.h:1110
void setOn()
Set all bits on.
Definition: NodeMasks.h:471
BaseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1118
OffIterator endOff() const
Definition: NodeMasks.h:355
void load(std::istream &is)
Definition: NodeMasks.h:807
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:977
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:412
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:436
Index32 * mBits
Definition: NodeMasks.h:1070
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1402
DenseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:279
void increment()
Definition: NodeMasks.h:1152
bool test() const
Definition: NodeMasks.h:201
~RootNodeMask()
Definition: NodeMasks.h:1084
Index32 getMemUsage() const
Definition: NodeMasks.h:1283
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:706
DenseIterator & operator++()
Definition: NodeMasks.h:1221
OffIterator & operator++()
Definition: NodeMasks.h:1193
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:147
bool isOff(Index32 i) const
Definition: NodeMasks.h:1336
void setFirstOff()
Definition: NodeMasks.h:1329
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:993
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:928
void increment()
Definition: NodeMasks.h:280
void setLastOff()
Definition: NodeMasks.h:1330
Index32 offset() const
Definition: NodeMasks.h:199
RootNodeMask & operator=(const RootNodeMask &B)
Definition: NodeMasks.h:1098
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:438
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:332
void increment(Index n)
Definition: NodeMasks.h:1185
OnIterator beginOn() const
Definition: NodeMasks.h:352
void load(std::istream &is)
Definition: NodeMasks.h:1023
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:755
OffIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1179
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:589
Index32 findFirstOn() const
Definition: NodeMasks.h:534
bool operator==(const BaseIterator &iter) const
Definition: NodeMasks.h:1120
Index64 Word
Definition: NodeMasks.h:853
OffIterator()
Definition: NodeMasks.h:1178
const NodeMask * mParent
Definition: NodeMasks.h:183
Index32 pos() const
Definition: NodeMasks.h:200
bool next()
Definition: NodeMasks.h:1188
Index32 CountOn(Index64 v)
Return the number of on bits in the given 64-bit value.
Definition: NodeMasks.h:65
OnMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:216
WordT & getWord(Index n)
Definition: NodeMasks.h:558
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:722
void seek(std::istream &is) const
Definition: NodeMasks.h:808
OnMaskIterator()
Definition: NodeMasks.h:215
Base class for the bit mask iterators.
Definition: NodeMasks.h:180
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:510
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:452
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:577
DenseIterator endDense() const
Definition: NodeMasks.h:658
Index32 findFirstOff() const
Definition: NodeMasks.h:541
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:733
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:464
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:494
Index getBitSize() const
Definition: NodeMasks.h:1094
void save(std::ostream &os) const
Definition: NodeMasks.h:565
bool operator==(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:192
bool operator*() const
Definition: NodeMasks.h:1164
DenseIterator endDense() const
Definition: NodeMasks.h:357
bool operator!=(const BaseIterator &iter) const
Definition: NodeMasks.h:1121
unsigned char Byte
Definition: openvdb/Types.h:37
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:95
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:500
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:1010
void increment(Index n)
Definition: NodeMasks.h:1157
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:944
void seek(std::istream &is) const
Definition: NodeMasks.h:1024
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:334
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:641
DenseIterator endDense() const
Definition: NodeMasks.h:880
OffIterator endOff() const
Definition: NodeMasks.h:656
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:861
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:757
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:955
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:863
Index getIntSize() const
Definition: NodeMasks.h:1096
bool operator!=(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:193
void setOn()
Definition: NodeMasks.h:1310
bool next()
Definition: NodeMasks.h:255
Definition: openvdb/Exceptions.h:13
void setOff()
Set all bits off.
Definition: NodeMasks.h:744
Index32 mPos
Definition: NodeMasks.h:1112
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:740
bool isOn() const
Definition: NodeMasks.h:1342
OnMaskIterator & operator++()
Definition: NodeMasks.h:230
~NodeMask()
Destructor.
Definition: NodeMasks.h:645
DenseIterator endDense() const
Definition: NodeMasks.h:1232
void seek(std::istream &is) const
Definition: NodeMasks.h:570
OffIterator endOff() const
Definition: NodeMasks.h:878
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:639
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:979
Index32 Index
Definition: openvdb/Types.h:32
OffMaskIterator()
Definition: NodeMasks.h:246
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1381
bool next()
Definition: NodeMasks.h:287
DenseIterator()
Definition: NodeMasks.h:1206
Index32 findFirstOn() const
Definition: NodeMasks.h:1354
void setOff()
Set all bits off.
Definition: NodeMasks.h:966
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:700
BaseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:188
void setFirstOn()
Definition: NodeMasks.h:1327
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:962
Definition: NodeMasks.h:1200