Go to the documentation of this file.
8 #ifndef OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
9 #define OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
30 #if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER)
32 #elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
33 return __builtin_popcount(v);
36 static const Byte numBits[256] = {
37 #define COUNTONB2(n) n, n+1, n+1, n+2
38 #define COUNTONB4(n) COUNTONB2(n), COUNTONB2(n+1), COUNTONB2(n+1), COUNTONB2(n+2)
39 #define COUNTONB6(n) COUNTONB4(n), COUNTONB4(n+1), COUNTONB4(n+1), COUNTONB4(n+2)
56 v = v - ((v >> 1) & 0x55555555U);
57 v = (v & 0x33333333U) + ((v >> 2) & 0x33333333U);
58 return (((v + (v >> 4)) & 0xF0F0F0FU) * 0x1010101U) >> 24;
68 #if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER) && defined(_M_X64)
70 #elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
71 v = __builtin_popcountll(v);
74 v = v - ((v >> 1) & UINT64_C(0x5555555555555555));
75 v = (v & UINT64_C(0x3333333333333333)) + ((v >> 2) & UINT64_C(0x3333333333333333));
76 v = (((v + (v >> 4)) & UINT64_C(0xF0F0F0F0F0F0F0F)) * UINT64_C(0x101010101010101)) >> 56;
89 #if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER)
91 _BitScanForward(&index,
static_cast<Index32>(v));
92 return static_cast<Index32>(index);
93 #elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
94 return __builtin_ctz(v);
97 static const Byte DeBruijn[8] = {0, 1, 6, 2, 7, 5, 4, 3};
98 return DeBruijn[
Byte((v & -v) * 0x1DU) >> 5];
108 static const Byte DeBruijn[32] = {
109 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
110 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
112 return DeBruijn[
Index32((v & -v) * 0x077CB531U) >> 27];
120 #if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER)
122 _BitScanForward64(&index, v);
123 return static_cast<Index32>(index);
124 #elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
125 return static_cast<Index32>(__builtin_ctzll(v));
128 static const Byte DeBruijn[64] = {
129 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
130 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
131 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
132 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12,
134 return DeBruijn[
Index64((v & -v) * UINT64_C(0x022FDD63CC95386D)) >> 58];
142 static const Byte DeBruijn[32] = {
143 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
144 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
151 return DeBruijn[
Index32(v * 0x07C4ACDDU) >> 27];
159 template<
typename NodeMask>
171 assert((parent ==
nullptr && pos == 0) || (parent !=
nullptr && pos <= NodeMask::SIZE));
178 mPos = iter.
mPos; mParent = iter.
mParent;
return *
this;
182 bool test()
const { assert(mPos <= NodeMask::SIZE);
return (mPos != NodeMask::SIZE); }
183 operator bool()
const {
return this->test(); }
188 template <
typename NodeMask>
193 using BaseType::mPos;
194 using BaseType::mParent;
200 assert(mParent !=
nullptr);
201 mPos = mParent->findNextOn(mPos+1);
202 assert(mPos <= NodeMask::SIZE);
219 template <
typename NodeMask>
224 using BaseType::mPos;
225 using BaseType::mParent;
231 assert(mParent !=
nullptr);
232 mPos=mParent->findNextOff(mPos+1);
233 assert(mPos <= NodeMask::SIZE);
250 template <
typename NodeMask>
255 using BaseType::mPos;
256 using BaseType::mParent;
263 assert(mParent !=
nullptr);
265 assert(mPos<= NodeMask::SIZE);
287 template<Index Log2Dim>
291 static_assert(Log2Dim > 2,
"expected NodeMask template specialization, got base template");
309 Word mWords[WORD_COUNT];
324 const Word* w2 = other.mWords;
325 for (
Word* w1 = mWords; n--; ++w1, ++w2) *w1 = *w2;
343 for (
const Word *w1=mWords, *w2=other.mWords; n-- && *w1++ == *w2++;) ;
359 template<
typename WordOp>
363 const Word *w2 = other.mWords;
364 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) op( *w1, *w2);
367 template<
typename WordOp>
371 const Word *w2 = other1.mWords, *w3 = other2.mWords;
372 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2, ++w3) op( *w1, *w2, *w3);
375 template<
typename WordOp>
380 const Word *w2 = other1.mWords, *w3 = other2.mWords, *w4 = other3.mWords;
381 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2, ++w3, ++w4) op( *w1, *w2, *w3, *w4);
388 const Word *w2 = other.mWords;
389 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= *w2;
396 const Word *w2 = other.mWords;
397 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 |= *w2;
404 const Word *w2 = other.mWords;
405 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= ~*w2;
412 const Word *w2 = other.mWords;
413 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 ^= *w2;
426 Index32 sum = 0, n = WORD_COUNT;
427 for (
const Word* w = mWords; n--; ++w) sum +=
CountOn(*w);
434 assert( (n >> 6) < WORD_COUNT );
435 mWords[n >> 6] |=
Word(1) << (n & 63);
439 assert( (n >> 6) < WORD_COUNT );
440 mWords[n >> 6] &= ~(
Word(1) << (n & 63));
443 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
449 for (
Word* w = mWords; n--; ++w) *w = state;
455 for (
Word* w = mWords; n--; ++w) *w = ~
Word(0);
461 for (
Word* w = mWords; n--; ++w) *w =
Word(0);
465 assert( (n >> 6) < WORD_COUNT );
466 mWords[n >> 6] ^=
Word(1) << (n & 63);
472 for (
Word* w = mWords; n--; ++w) *w = ~*w;
485 assert( (n >> 6) < WORD_COUNT );
486 return 0 != (mWords[n >> 6] & (
Word(1) << (n & 63)));
494 for (
const Word *w = mWords; n-- && *w++ == ~
Word(0);) ;
501 for (
const Word *w = mWords; n-- && *w++ ==
Word(0);) ;
509 isOn = (mWords[0] == ~
Word(0));
510 if ( !isOn && mWords[0] !=
Word(0))
return false;
511 const Word *w = mWords + 1, *n = mWords + WORD_COUNT;
512 while( w<n && *w == mWords[0] ) ++w;
518 const Word* w = mWords;
519 for (; n<WORD_COUNT && !*w; ++w, ++n) ;
520 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(*w);
525 const Word* w = mWords;
526 for (; n<WORD_COUNT && !~*w; ++w, ++n) ;
527 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(~*w);
531 template<
typename WordT>
535 assert(n*8*
sizeof(WordT) < SIZE);
536 return reinterpret_cast<const WordT*
>(mWords)[n];
538 template<
typename WordT>
541 assert(n*8*
sizeof(WordT) < SIZE);
542 return reinterpret_cast<WordT*
>(mWords)[n];
546 void save(std::ostream& os)
const
548 os.write(
reinterpret_cast<const char*
>(mWords), this->memUsage());
550 void load(std::istream& is) { is.read(
reinterpret_cast<char*
>(mWords), this->memUsage()); }
551 void seek(std::istream& is)
const { is.seekg(this->memUsage(), std::ios_base::cur); }
555 os <<
"NodeMask: Dim=" << DIM <<
" Log2Dim=" << Log2Dim
556 <<
" Bit count=" << SIZE <<
" word count=" << WORD_COUNT << std::endl;
560 const Index32 n=(SIZE>max_out ? max_out : SIZE);
561 for (
Index32 i=0; i < n; ++i) {
568 os <<
"|" << std::endl;
573 this->printBits(os, max_out);
579 if (n >= WORD_COUNT)
return SIZE;
582 if (b & (
Word(1) << m))
return start;
584 while(!b && ++n<WORD_COUNT) b = mWords[n];
591 if (n >= WORD_COUNT)
return SIZE;
594 if (b & (
Word(1) << m))
return start;
596 while(!b && ++n<WORD_COUNT) b = ~mWords[n];
628 void operator = (
const NodeMask &other) { mByte = other.mByte; }
655 template<
typename WordOp>
658 op(mByte, other.mByte);
661 template<
typename WordOp>
664 op(mByte, other1.mByte, other2.mByte);
667 template<
typename WordOp>
671 op(mByte, other1.mByte, other2.mByte, other3.mByte);
677 mByte &= other.mByte;
683 mByte |= other.mByte;
689 mByte &=
static_cast<Byte>(~other.mByte);
695 mByte ^= other.mByte;
711 mByte =
static_cast<Byte>(mByte | 0x01U << (n & 7));
716 mByte =
static_cast<Byte>(mByte & ~(0x01U << (n & 7)));
719 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
721 void set(
bool on) { mByte = on ? 0xFFU : 0x00U; }
729 mByte =
static_cast<Byte>(mByte ^ 0x01U << (n & 7));
745 return mByte & (0x01U << (n & 7));
750 bool isOn()
const {
return mByte == 0xFFU; }
752 bool isOff()
const {
return mByte == 0; }
759 return isOn || this->isOff();
764 const Byte b =
static_cast<Byte>(~mByte);
787 void save(std::ostream& os)
const { os.write(
reinterpret_cast<const char*
>(&mByte), 1); }
788 void load(std::istream& is) { is.read(
reinterpret_cast<char*
>(&mByte), 1); }
789 void seek(std::istream& is)
const { is.seekg(1, std::ios_base::cur); }
793 os <<
"NodeMask: Dim=2, Log2Dim=1, Bit count=8, Word count=1"<<std::endl;
798 for (
Index32 i=0; i < 8; ++i) os << this->isOn(i);
799 os <<
"||" << std::endl;
809 if (start>=8)
return 8;
810 const Byte b =
static_cast<Byte>(mByte & (0xFFU << start));
816 if (start>=8)
return 8;
817 const Byte b =
static_cast<Byte>(~mByte & (0xFFU << start));
844 NodeMask(
bool on) : mWord(on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00)) {}
850 void operator = (
const NodeMask &other) { mWord = other.mWord; }
877 template<
typename WordOp>
880 op(mWord, other.mWord);
883 template<
typename WordOp>
886 op(mWord, other1.mWord, other2.mWord);
889 template<
typename WordOp>
893 op(mWord, other1.mWord, other2.mWord, other3.mWord);
899 mWord &= other.mWord;
905 mWord |= other.mWord;
911 mWord &= ~other.mWord;
917 mWord ^= other.mWord;
933 mWord |= UINT64_C(0x01) << (n & 63);
938 mWord &= ~(UINT64_C(0x01) << (n & 63));
941 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
943 void set(
bool on) { mWord = on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00); }
945 void setOn() { mWord = UINT64_C(0xFFFFFFFFFFFFFFFF); }
947 void setOff() { mWord = UINT64_C(0x00); }
951 mWord ^= UINT64_C(0x01) << (n & 63);
967 return 0 != (mWord & (UINT64_C(0x01) << (n & 63)));
972 bool isOn()
const {
return mWord == UINT64_C(0xFFFFFFFFFFFFFFFF); }
974 bool isOff()
const {
return mWord == 0; }
979 { isOn = this->isOn();
980 return isOn || this->isOff();
985 const Word w = ~mWord;
989 template<
typename WordT>
993 assert(n*8*
sizeof(WordT) < SIZE);
994 return reinterpret_cast<const WordT*
>(&mWord)[n];
996 template<
typename WordT>
999 assert(n*8*
sizeof(WordT) < SIZE);
1000 return reinterpret_cast<WordT*
>(mWord)[n];
1003 void save(std::ostream& os)
const { os.write(
reinterpret_cast<const char*
>(&mWord), 8); }
1004 void load(std::istream& is) { is.read(
reinterpret_cast<char*
>(&mWord), 8); }
1005 void seek(std::istream& is)
const { is.seekg(8, std::ios_base::cur); }
1009 os <<
"NodeMask: Dim=4, Log2Dim=2, Bit count=64, Word count=1"<<std::endl;
1014 for (
Index32 i=0; i < 64; ++i) {
1015 if ( !(i%8) ) os <<
"|";
1016 os << this->isOn(i);
1018 os <<
"||" << std::endl;
1022 this->printInfo(os);
1023 this->printBits(os);
1028 if (start>=64)
return 64;
1029 const Word w = mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1035 if (start>=64)
return 64;
1036 const Word w = ~mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1056 mBitSize(bit_size), mIntSize(((bit_size-1)>>5)+1), mBits(new
Index32[mIntSize])
1058 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1061 mBitSize(B.mBitSize), mIntSize(B.mIntSize), mBits(new
Index32[mIntSize])
1063 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=B.
mBits[i];
1068 mBitSize = bit_size;
1069 mIntSize =((bit_size-1)>>5)+1;
1071 mBits =
new Index32[mIntSize];
1072 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1084 mBits =
new Index32[mIntSize];
1086 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=B.
mBits[i];
1100 mPos(pos), mBitSize(parent->getBitSize()), mParent(parent) { assert(pos <= mBitSize); }
1116 assert(mPos <= mBitSize);
1117 return (mPos != mBitSize);
1120 operator bool()
const {
return this->test();}
1127 using BaseIterator::mPos;
1128 using BaseIterator::mBitSize;
1129 using BaseIterator::mParent;
1134 assert(mParent !=
nullptr);
1135 mPos=mParent->findNextOn(mPos+1);
1136 assert(mPos <= mBitSize);
1139 for (
Index i=0; i<n && this->next(); ++i) {}
1143 return this->test();
1155 using BaseIterator::mPos;
1156 using BaseIterator::mBitSize;
1157 using BaseIterator::mParent;
1162 assert(mParent !=
nullptr);
1163 mPos=mParent->findNextOff(mPos+1);
1164 assert(mPos <= mBitSize);
1167 for (
Index i=0; i<n && this->next(); ++i) {}
1171 return this->test();
1183 using BaseIterator::mPos;
1184 using BaseIterator::mBitSize;
1185 using BaseIterator::mParent;
1190 assert(mParent !=
nullptr);
1192 assert(mPos<= mBitSize);
1195 for (
Index i=0; i<n && this->next(); ++i) {}
1199 return this->test();
1216 if (mBitSize != B.
mBitSize)
return false;
1217 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return false;
1222 if (mBitSize != B.
mBitSize)
return true;
1223 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return true;
1232 assert(mIntSize == other.
mIntSize);
1234 mBits[i] &= other.
mBits[i];
1236 for (
Index32 i = other.
mIntSize; i < mIntSize; ++i) mBits[i] = 0x00000000;
1240 assert(mIntSize == other.
mIntSize);
1242 mBits[i] |= other.
mBits[i];
1247 assert(mIntSize == other.
mIntSize);
1249 mBits[i] ^= other.
mBits[i];
1265 return static_cast<Index32>(mIntSize*
sizeof(
Index32) +
sizeof(*
this));
1279 assert( (i>>5) < mIntSize);
1280 mBits[i>>5] |= 1<<(i&31);
1285 assert( (i>>5) < mIntSize);
1286 mBits[i>>5] &= ~(1<<(i&31));
1289 void set(
Index32 i,
bool On) { On ? this->setOn(i) : this->setOff(i); }
1293 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0xFFFFFFFF;
1297 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1301 assert( (i>>5) < mIntSize);
1302 mBits[i>>5] ^= 1<<(i&31);
1306 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=~mBits[i];
1314 assert( (i>>5) < mIntSize);
1315 return ( mBits[i >> 5] & (1<<(i&31)) );
1319 assert( (i>>5) < mIntSize);
1320 return ( ~mBits[i >> 5] & (1<<(i&31)) );
1324 if (!mBits)
return false;
1325 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0xFFFFFFFF)
return false;
1330 if (!mBits)
return true;
1331 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0)
return false;
1338 while(!mBits[i])
if (++i == mIntSize)
return mBitSize;
1345 while(!(~mBits[i]))
if (++i == mIntSize)
return mBitSize;
1349 void save(std::ostream& os)
const {
1351 os.write(
reinterpret_cast<const char*
>(mBits), mIntSize *
sizeof(
Index32));
1355 is.read(
reinterpret_cast<char*
>(mBits), mIntSize *
sizeof(
Index32));
1357 void seek(std::istream& is)
const {
1359 is.seekg(mIntSize *
sizeof(
Index32), std::ios_base::cur);
1363 os <<
"RootNodeMask: Bit-size="<<mBitSize<<
" Int-size="<<mIntSize<<std::endl;
1367 const Index32 n=(mBitSize>max_out?max_out:mBitSize);
1368 for (
Index32 i=0; i < n; ++i) {
1373 os << this->isOn(i);
1375 os <<
"|" << std::endl;
1379 this->printInfo(os);
1380 this->printBits(os,max_out);
1385 Index32 n = start >> 5, m = start & 31;
1386 if (n>=mIntSize)
return mBitSize;
1388 if (b & (1<<m))
return start;
1389 b &= 0xFFFFFFFF << m;
1390 while(!b && ++n<mIntSize) b = mBits[n];
1396 Index32 n = start >> 5, m = start & 31;
1397 if (n>=mIntSize)
return mBitSize;
1399 if (b & (1<<m))
return start;
1401 while(!b && ++n<mIntSize) b = ~mBits[n];
1415 #endif // OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
bool operator*() const
Definition: NodeMasks.h:1201
OffIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1160
Index32 CountOn(Index64 v)
Return the number of on bits in the given 64-bit value.
Definition: NodeMasks.h:66
NodeMask operator!() const
Definition: NodeMasks.h:416
void increment()
Definition: NodeMasks.h:198
bool next()
Definition: NodeMasks.h:268
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:721
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:469
void setLastOn()
Definition: NodeMasks.h:1309
bool operator<(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:180
OffIterator endOff() const
Definition: NodeMasks.h:859
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:620
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:960
OnMaskIterator()
Definition: NodeMasks.h:196
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:393
void increment(Index n)
Definition: NodeMasks.h:267
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:576
void setOn()
Definition: NodeMasks.h:1291
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1033
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:443
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:943
void save(std::ostream &os) const
Definition: NodeMasks.h:1349
Index32 findFirstOn() const
Definition: NodeMasks.h:761
void increment(Index n)
Definition: NodeMasks.h:204
bool operator*() const
Definition: NodeMasks.h:273
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:701
void setOn()
Set all bits on.
Definition: NodeMasks.h:945
void increment(Index n)
Definition: NodeMasks.h:1138
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:419
BaseIterator(const BaseIterator &)=default
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:507
OnIterator endOn() const
Definition: NodeMasks.h:1209
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:422
OnIterator beginOn() const
Definition: NodeMasks.h:333
Index32 findFirstOn() const
Definition: NodeMasks.h:982
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:707
void setOn()
Set all bits on.
Definition: NodeMasks.h:723
Index32 CountOff(Index64 v)
Return the number of off bits in the given 64-bit value.
Definition: NodeMasks.h:82
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:570
Index32 findFirstOn() const
Definition: NodeMasks.h:1335
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:814
RootNodeMask operator|(const RootNodeMask &other) const
Definition: NodeMasks.h:1256
void setFirstOn()
Definition: NodeMasks.h:1308
BaseMaskIterator()
Definition: NodeMasks.h:167
void load(std::istream &is)
Definition: NodeMasks.h:550
Byte Word
Definition: NodeMasks.h:612
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:923
void setOn()
Set all bits on.
Definition: NodeMasks.h:452
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1366
OffIterator endOff() const
Definition: NodeMasks.h:336
OnIterator beginOn() const
Definition: NodeMasks.h:856
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:417
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:433
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:558
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:929
void increment()
Definition: NodeMasks.h:1133
DenseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1188
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:791
Index32 findFirstOff() const
Definition: NodeMasks.h:522
const RootNodeMask & operator|=(const RootNodeMask &other)
Definition: NodeMasks.h:1239
Index32 countOn() const
Definition: NodeMasks.h:1268
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:445
void load(std::istream &is)
Definition: NodeMasks.h:1353
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1394
RootNodeMask operator&(const RootNodeMask &other) const
Definition: NodeMasks.h:1253
DenseIterator beginDense() const
Definition: NodeMasks.h:860
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:481
OffIterator()
Definition: NodeMasks.h:1159
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:915
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:313
Index32 FindLowestOn(Index64 v)
Return the least significant on bit of the given 64-bit value.
Definition: NodeMasks.h:117
bool isOff() const
Definition: NodeMasks.h:1329
BaseIterator & operator=(const BaseIterator &iter)
Definition: NodeMasks.h:1104
bool test() const
Definition: NodeMasks.h:1115
void setOff(Index32 i)
Definition: NodeMasks.h:1283
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:315
BaseIterator()
Definition: NodeMasks.h:1097
Index32 mIntSize
Definition: NodeMasks.h:1050
OnIterator beginOn() const
Definition: NodeMasks.h:634
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:693
Index32 FindHighestOn(Index32 v)
Return the most significant on bit of the given 32-bit value.
Definition: NodeMasks.h:140
bool operator*() const
Definition: NodeMasks.h:241
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1007
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:719
bool operator*() const
Definition: NodeMasks.h:1173
Index32 findFirstOn() const
Definition: NodeMasks.h:515
Definition: NodeMasks.h:190
void set(Index32 i, bool On)
Definition: NodeMasks.h:1289
WordT & getWord(Index n)
Definition: NodeMasks.h:539
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:941
RootNodeMask operator!() const
Definition: NodeMasks.h:1230
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:931
const RootNodeMask & operator&=(const RootNodeMask &other)
Definition: NodeMasks.h:1231
OnIterator endOn() const
Definition: NodeMasks.h:635
DenseIterator beginDense() const
Definition: NodeMasks.h:638
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:491
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:801
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:709
OnIterator endOn() const
Definition: NodeMasks.h:857
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:846
WordT & getWord(Index n)
Definition: NodeMasks.h:997
Index32 pos() const
Definition: NodeMasks.h:1113
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:475
void toggle(Index32 i)
Definition: NodeMasks.h:1299
RootNodeMask operator^(const RootNodeMask &other) const
Definition: NodeMasks.h:1259
void save(std::ostream &os) const
Definition: NodeMasks.h:546
void increment(Index n)
Definition: NodeMasks.h:1166
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1020
bool operator*() const
Definition: NodeMasks.h:1145
DenseIterator endDense() const
Definition: NodeMasks.h:338
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:949
Definition: NodeMasks.h:1125
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:756
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:624
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:954
BaseMaskIterator & operator=(const BaseMaskIterator &iter)
Definition: NodeMasks.h:176
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:727
OffIterator beginOff() const
Definition: NodeMasks.h:858
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:978
void setOn(Index32 i)
Definition: NodeMasks.h:1277
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1026
Index32 findFirstOff() const
Definition: NodeMasks.h:983
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:732
void increment()
Definition: NodeMasks.h:229
const RootNodeMask & operator^=(const RootNodeMask &other)
Definition: NodeMasks.h:1246
Definition: NodeMasks.h:252
Definition: NodeMasks.h:221
Index32 mBitSize
Definition: NodeMasks.h:1094
const RootNodeMask * mParent
Definition: NodeMasks.h:1095
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:795
bool next()
Definition: NodeMasks.h:1169
Definition: NodeMasks.h:1153
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:705
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1383
bool next()
Definition: NodeMasks.h:205
~RootNodeMask()
Definition: NodeMasks.h:1065
DenseMaskIterator & operator++()
Definition: NodeMasks.h:274
OffIterator beginOff() const
Definition: NodeMasks.h:636
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:927
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:956
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:807
Index32 findFirstOff() const
Definition: NodeMasks.h:762
bool isOff(Index32 i) const
Definition: NodeMasks.h:1317
void setFirstOff()
Definition: NodeMasks.h:1310
void seek(std::istream &is) const
Definition: NodeMasks.h:551
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:734
bool next()
Definition: NodeMasks.h:1197
DenseIterator beginDense() const
Definition: NodeMasks.h:1212
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1011
DenseIterator beginDense() const
Definition: NodeMasks.h:337
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:431
void save(std::ostream &os) const
Definition: NodeMasks.h:1003
Index32 offset() const
Definition: NodeMasks.h:1111
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:409
Index32 mPos
Definition: NodeMasks.h:163
void increment(Index n)
Definition: NodeMasks.h:235
RootNodeMask(Index32 bit_size)
Definition: NodeMasks.h:1055
void increment()
Definition: NodeMasks.h:1189
bool isOn(Index32 i) const
Definition: NodeMasks.h:1312
OffMaskIterator & operator++()
Definition: NodeMasks.h:242
DenseMaskIterator()
Definition: NodeMasks.h:259
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation.
Definition: NodeMasks.h:289
BaseMaskIterator(const BaseMaskIterator &)=default
OffIterator endOff() const
Definition: NodeMasks.h:1211
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:471
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:498
OnMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:197
bool operator*() const
Definition: NodeMasks.h:210
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:699
Base class for the bit mask iterators.
Definition: NodeMasks.h:161
Index32 findFirstOff() const
Definition: NodeMasks.h:1342
void increment(Index n)
Definition: NodeMasks.h:1194
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:972
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:964
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:921
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:922
Index getBitSize() const
Definition: NodeMasks.h:1075
OnIterator()
Definition: NodeMasks.h:1131
void save(std::ostream &os) const
Definition: NodeMasks.h:787
void init(Index32 bit_size)
Definition: NodeMasks.h:1067
BaseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1099
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:438
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:742
void increment()
Definition: NodeMasks.h:261
OffMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:228
bool test() const
Definition: NodeMasks.h:182
NodeMask & operator=(const NodeMask &other)
Assignment operator.
Definition: NodeMasks.h:321
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:703
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:317
NodeMask operator!() const
Definition: NodeMasks.h:698
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:750
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:700
Index32 countOff() const
Definition: NodeMasks.h:1275
Index32 offset() const
Definition: NodeMasks.h:180
OffIterator beginOff() const
Definition: NodeMasks.h:335
NodeMask operator!() const
Definition: NodeMasks.h:920
DenseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:260
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:752
Index getIntSize() const
Definition: NodeMasks.h:1077
OnIterator & operator++()
Definition: NodeMasks.h:1146
DenseIterator & operator++()
Definition: NodeMasks.h:1202
RootNodeMask(const RootNodeMask &B)
Definition: NodeMasks.h:1060
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:483
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:424
OnIterator beginOn() const
Definition: NodeMasks.h:1208
void load(std::istream &is)
Definition: NodeMasks.h:788
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:958
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:401
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:925
Index32 pos() const
Definition: NodeMasks.h:181
bool operator==(const BaseIterator &iter) const
Definition: NodeMasks.h:1101
bool isOn() const
Definition: NodeMasks.h:1323
const NodeMask * mParent
Definition: NodeMasks.h:164
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:622
void setOff()
Set all bits off.
Definition: NodeMasks.h:458
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:687
DenseIterator endDense() const
Definition: NodeMasks.h:1213
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:588
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:464
OnMaskIterator & operator++()
Definition: NodeMasks.h:211
Index32 Index
Definition: Types.h:31
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1362
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:974
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:479
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:844
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:909
OffIterator beginOff() const
Definition: NodeMasks.h:1210
bool next()
Definition: NodeMasks.h:236
void load(std::istream &is)
Definition: NodeMasks.h:1004
Definition: NodeMasks.h:1091
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:736
void setOff()
Set all bits off.
Definition: NodeMasks.h:725
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:533
bool operator==(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:173
bool operator!=(const BaseIterator &iter) const
Definition: NodeMasks.h:1102
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:102
Index32 * mBits
Definition: NodeMasks.h:1051
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:385
OnIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1132
~NodeMask()
Destructor.
Definition: NodeMasks.h:626
Index32 getMemUsage() const
Definition: NodeMasks.h:1264
Index64 Word
Definition: NodeMasks.h:834
uint32_t Index32
Definition: Types.h:29
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1378
void seek(std::istream &is) const
Definition: NodeMasks.h:789
OffMaskIterator()
Definition: NodeMasks.h:227
OnIterator endOn() const
Definition: NodeMasks.h:334
Index32 memUsage() const
Definition: NodeMasks.h:1405
void seek(std::istream &is) const
Definition: NodeMasks.h:1357
void setLastOff()
Definition: NodeMasks.h:1311
RootNodeMask & operator=(const RootNodeMask &B)
Definition: NodeMasks.h:1079
DenseIterator endDense() const
Definition: NodeMasks.h:639
void setOff()
Set all bits off.
Definition: NodeMasks.h:947
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:681
bool operator!=(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:174
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:714
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:479
Definition: Exceptions.h:13
Definition: NodeMasks.h:1181
Index32 mPos
Definition: NodeMasks.h:1093
~NodeMask()
Destructor.
Definition: NodeMasks.h:848
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:418
uint64_t Index64
Definition: Types.h:30
~NodeMask()
Destructor.
Definition: NodeMasks.h:319
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:991
Index32 mBitSize
Definition: NodeMasks.h:1050
DenseIterator()
Definition: NodeMasks.h:1187
void seek(std::istream &is) const
Definition: NodeMasks.h:1005
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:489
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:553
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:740
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:970
OffIterator & operator++()
Definition: NodeMasks.h:1174
DenseIterator endDense() const
Definition: NodeMasks.h:861
RootNodeMask()
Definition: NodeMasks.h:1054
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:675
OffIterator endOff() const
Definition: NodeMasks.h:637
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:903
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:842
void setOff()
Definition: NodeMasks.h:1295
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:738
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:936
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:962
Index64 Word
Definition: NodeMasks.h:297
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:748
void increment()
Definition: NodeMasks.h:1161
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:477
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:897
bool next()
Definition: NodeMasks.h:1141
Definition: NodeMasks.h:1048
BaseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:169
unsigned char Byte
Definition: Types.h:36
void toggle()
Definition: NodeMasks.h:1304