35 #ifndef OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED 36 #define OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED 56 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics 59 const Byte numBits[256] = {
61 #define COUNTONB2(n) n, n+1, n+1, n+2 62 #define COUNTONB4(n) COUNTONB2(n), COUNTONB2(n+1), COUNTONB2(n+1), COUNTONB2(n+2) 63 #define COUNTONB6(n) COUNTONB4(n), COUNTONB4(n+1), COUNTONB4(n+1), COUNTONB4(n+2) 87 v = v - ((v >> 1) & 0x55555555U);
88 v = (v & 0x33333333U) + ((v >> 2) & 0x33333333U);
89 return (((v + (v >> 4)) & 0xF0F0F0FU) * 0x1010101U) >> 24;
99 v = v - ((v >> 1) & UINT64_C(0x5555555555555555));
100 v = (v & UINT64_C(0x3333333333333333)) + ((v >> 2) & UINT64_C(0x3333333333333333));
102 (((v + (v >> 4)) & UINT64_C(0xF0F0F0F0F0F0F0F)) * UINT64_C(0x101010101010101)) >> 56);
113 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics 116 const Byte DeBruijn[8] = {0, 1, 6, 2, 7, 5, 4, 3};
117 return DeBruijn[
Byte((v & -v) * 0x1DU) >> 5];
126 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics 129 const Byte DeBruijn[32] = {
130 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
131 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
133 return DeBruijn[
Index32((v & -v) * 0x077CB531U) >> 27];
142 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics 145 const Byte DeBruijn[64] = {
146 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
147 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
148 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
149 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12,
151 return DeBruijn[
Index64((v & -v) * UINT64_C(0x022FDD63CC95386D)) >> 58];
158 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics 161 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 BOOST_STATIC_ASSERT( Log2Dim>2 );
328 Word mWords[WORD_COUNT];
343 const Word* w2 = other.mWords;
344 for (Word* w1 = mWords; n--; ++w1, ++w2) *w1 = *w2;
352 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
353 OnIterator
endOn()
const {
return OnIterator(SIZE,
this); }
354 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
355 OffIterator
endOff()
const {
return OffIterator(SIZE,
this); }
356 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
357 DenseIterator
endDense()
const {
return DenseIterator(SIZE,
this); }
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); }
466 const Word state = on ? ~Word(0) : Word(0);
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());
570 is.read(reinterpret_cast<char*>(mWords), this->memUsage());
572 void seek(std::istream& is)
const {
573 is.seekg(this->memUsage(), std::ios_base::cur);
578 os <<
"NodeMask: Dim=" << DIM <<
" Log2Dim=" << Log2Dim
579 <<
" Bit count=" << SIZE <<
" word count=" << WORD_COUNT << std::endl;
583 const Index32 n=(SIZE>max_out ? max_out : SIZE);
584 for (
Index32 i=0; i < n; ++i) {
591 os <<
"|" << std::endl;
596 this->printBits(os, max_out);
602 if (n >= WORD_COUNT)
return SIZE;
605 if (b & (Word(1) << m))
return start;
607 while(!b && ++n<WORD_COUNT) b = mWords[n];
614 if (n >= WORD_COUNT)
return SIZE;
617 if (b & (Word(1) << m))
return start;
619 while(!b && ++n<WORD_COUNT) b = ~mWords[n];
651 void operator = (
const NodeMask &other) { mByte = other.mByte; }
657 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
658 OnIterator
endOn()
const {
return OnIterator(SIZE,
this); }
659 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
660 OffIterator
endOff()
const {
return OffIterator(SIZE,
this); }
661 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
662 DenseIterator
endDense()
const {
return DenseIterator(SIZE,
this); }
678 template<
typename WordOp>
681 op(mByte, other.mByte);
684 template<
typename WordOp>
687 op(mByte, other1.mByte, other2.mByte);
690 template<
typename WordOp>
694 op(mByte, other1.mByte, other2.mByte, other3.mByte);
700 mByte &= other.mByte;
706 mByte |= other.mByte;
712 mByte &=
static_cast<Byte>(~other.mByte);
718 mByte ^= other.mByte;
734 mByte = mByte |
static_cast<Byte>(0x01U << (n & 7));
739 mByte = mByte &
static_cast<Byte>(~(0x01U << (n & 7)));
742 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
744 void set(
bool on) { mByte = on ? 0xFFU : 0x00U; }
752 mByte = mByte ^
static_cast<Byte>(0x01U << (n & 7));
768 return mByte & (0x01U << (n & 7));
773 bool isOn()
const {
return mByte == 0xFFU; }
775 bool isOff()
const {
return mByte == 0; }
782 return isOn || this->isOff();
787 const Byte b =
static_cast<Byte>(~mByte);
810 void save(std::ostream& os)
const 812 os.write(reinterpret_cast<const char*>(&mByte), 1);
814 void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mByte), 1); }
815 void seek(std::istream& is)
const { is.seekg(1, std::ios_base::cur); }
819 os <<
"NodeMask: Dim=2, Log2Dim=1, Bit count=8, Word count=1"<<std::endl;
824 for (
Index32 i=0; i < 8; ++i) os << this->isOn(i);
825 os <<
"||" << std::endl;
835 if (start>=8)
return 8;
836 const Byte b =
static_cast<Byte>(mByte & (0xFFU << start));
842 if (start>=8)
return 8;
843 const Byte b =
static_cast<Byte>(~mByte & (0xFFU << start));
870 NodeMask(
bool on) : mWord(on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00)) {}
876 void operator = (
const NodeMask &other) { mWord = other.mWord; }
882 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
883 OnIterator
endOn()
const {
return OnIterator(SIZE,
this); }
884 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
885 OffIterator
endOff()
const {
return OffIterator(SIZE,
this); }
886 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
887 DenseIterator
endDense()
const {
return DenseIterator(SIZE,
this); }
903 template<
typename WordOp>
906 op(mWord, other.mWord);
909 template<
typename WordOp>
912 op(mWord, other1.mWord, other2.mWord);
915 template<
typename WordOp>
919 op(mWord, other1.mWord, other2.mWord, other3.mWord);
925 mWord &= other.mWord;
931 mWord |= other.mWord;
937 mWord &= ~other.mWord;
943 mWord ^= other.mWord;
959 mWord |= UINT64_C(0x01) << (n & 63);
964 mWord &= ~(UINT64_C(0x01) << (n & 63));
967 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
969 void set(
bool on) { mWord = on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00); }
971 void setOn() { mWord = UINT64_C(0xFFFFFFFFFFFFFFFF); }
973 void setOff() { mWord = UINT64_C(0x00); }
977 mWord ^= UINT64_C(0x01) << (n & 63);
993 return 0 != (mWord & (UINT64_C(0x01) << (n & 63)));
998 bool isOn()
const {
return mWord == UINT64_C(0xFFFFFFFFFFFFFFFF); }
1000 bool isOff()
const {
return mWord == 0; }
1005 { isOn = this->isOn();
1006 return isOn || this->isOff();
1011 const Word w = ~mWord;
1015 template<
typename WordT>
1019 assert(n*8*
sizeof(WordT) < SIZE);
1020 return reinterpret_cast<const WordT*
>(&mWord)[n];
1022 template<
typename WordT>
1025 assert(n*8*
sizeof(WordT) < SIZE);
1026 return reinterpret_cast<WordT*
>(mWord)[n];
1031 os.write(reinterpret_cast<const char*>(&mWord), 8);
1033 void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mWord), 8); }
1034 void seek(std::istream& is)
const { is.seekg(8, std::ios_base::cur); }
1038 os <<
"NodeMask: Dim=4, Log2Dim=2, Bit count=64, Word count=1"<<std::endl;
1043 for (
Index32 i=0; i < 64; ++i) {
1044 if ( !(i%8) ) os <<
"|";
1045 os << this->isOn(i);
1047 os <<
"||" << std::endl;
1051 this->printInfo(os);
1052 this->printBits(os);
1057 if (start>=64)
return 64;
1058 const Word w = mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1064 if (start>=64)
return 64;
1065 const Word w = ~mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1085 mBitSize(bit_size), mIntSize(((bit_size-1)>>5)+1), mBits(new
Index32[mIntSize])
1087 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1090 mBitSize(B.mBitSize), mIntSize(B.mIntSize), mBits(new
Index32[mIntSize])
1092 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=B.
mBits[i];
1097 mBitSize = bit_size;
1098 mIntSize =((bit_size-1)>>5)+1;
1100 mBits =
new Index32[mIntSize];
1101 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1113 mBits =
new Index32[mIntSize];
1115 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=B.
mBits[i];
1129 mPos(pos), mBitSize(parent->getBitSize()), mParent(parent) { assert(pos <= mBitSize); }
1145 assert(mPos <= mBitSize);
1146 return (mPos != mBitSize);
1149 operator bool()
const {
return this->test();}
1156 using BaseIterator::mPos;
1157 using BaseIterator::mBitSize;
1158 using BaseIterator::mParent;
1163 assert(mParent !=
nullptr);
1164 mPos=mParent->findNextOn(mPos+1);
1165 assert(mPos <= mBitSize);
1168 for (
Index i=0; i<n && this->next(); ++i) {}
1172 return this->test();
1184 using BaseIterator::mPos;
1185 using BaseIterator::mBitSize;
1186 using BaseIterator::mParent;
1191 assert(mParent !=
nullptr);
1192 mPos=mParent->findNextOff(mPos+1);
1193 assert(mPos <= mBitSize);
1196 for (
Index i=0; i<n && this->next(); ++i) {}
1200 return this->test();
1212 using BaseIterator::mPos;
1213 using BaseIterator::mBitSize;
1214 using BaseIterator::mParent;
1219 assert(mParent !=
nullptr);
1221 assert(mPos<= mBitSize);
1224 for (
Index i=0; i<n && this->next(); ++i) {}
1228 return this->test();
1237 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
1238 OnIterator
endOn()
const {
return OnIterator(mBitSize,
this); }
1239 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
1240 OffIterator
endOff()
const {
return OffIterator(mBitSize,
this); }
1241 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
1242 DenseIterator
endDense()
const {
return DenseIterator(mBitSize,
this); }
1245 if (mBitSize != B.
mBitSize)
return false;
1246 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return false;
1251 if (mBitSize != B.
mBitSize)
return true;
1252 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return true;
1261 assert(mIntSize == other.
mIntSize);
1263 mBits[i] &= other.
mBits[i];
1265 for (
Index32 i = other.
mIntSize; i < mIntSize; ++i) mBits[i] = 0x00000000;
1269 assert(mIntSize == other.
mIntSize);
1271 mBits[i] |= other.
mBits[i];
1276 assert(mIntSize == other.
mIntSize);
1278 mBits[i] ^= other.
mBits[i];
1294 return static_cast<Index32>(mIntSize*
sizeof(
Index32) +
sizeof(*
this));
1308 assert( (i>>5) < mIntSize);
1309 mBits[i>>5] |= 1<<(i&31);
1314 assert( (i>>5) < mIntSize);
1315 mBits[i>>5] &= ~(1<<(i&31));
1318 void set(
Index32 i,
bool On) { On ? this->setOn(i) : this->setOff(i); }
1322 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0xFFFFFFFF;
1326 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1330 assert( (i>>5) < mIntSize);
1331 mBits[i>>5] ^= 1<<(i&31);
1335 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=~mBits[i];
1343 assert( (i>>5) < mIntSize);
1344 return ( mBits[i >> 5] & (1<<(i&31)) );
1348 assert( (i>>5) < mIntSize);
1349 return ( ~mBits[i >> 5] & (1<<(i&31)) );
1353 if (!mBits)
return false;
1354 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0xFFFFFFFF)
return false;
1359 if (!mBits)
return true;
1360 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0)
return false;
1367 while(!mBits[i])
if (++i == mIntSize)
return mBitSize;
1374 while(!(~mBits[i]))
if (++i == mIntSize)
return mBitSize;
1378 void save(std::ostream& os)
const {
1380 os.write(reinterpret_cast<const char*>(mBits), mIntSize *
sizeof(
Index32));
1384 is.read(reinterpret_cast<char*>(mBits), mIntSize *
sizeof(
Index32));
1386 void seek(std::istream& is)
const {
1388 is.seekg(mIntSize *
sizeof(
Index32), std::ios_base::cur);
1392 os <<
"RootNodeMask: Bit-size="<<mBitSize<<
" Int-size="<<mIntSize<<std::endl;
1396 const Index32 n=(mBitSize>max_out?max_out:mBitSize);
1397 for (
Index32 i=0; i < n; ++i) {
1402 os << this->isOn(i);
1404 os <<
"|" << std::endl;
1408 this->printInfo(os);
1409 this->printBits(os,max_out);
1414 Index32 n = start >> 5, m = start & 31;
1415 if (n>=mIntSize)
return mBitSize;
1417 if (b & (1<<m))
return start;
1418 b &= 0xFFFFFFFF << m;
1419 while(!b && ++n<mIntSize) b = mBits[n];
1425 Index32 n = start >> 5, m = start & 31;
1426 if (n>=mIntSize)
return mBitSize;
1428 if (b & (1<<m))
return start;
1430 while(!b && ++n<mIntSize) b = ~mBits[n];
1444 #endif // OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1423
OnIterator & operator++()
Definition: NodeMasks.h:1175
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:773
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:941
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:643
DenseIterator endDense() const
Definition: NodeMasks.h:662
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:496
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:949
uint32_t Index32
Definition: Types.h:55
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:716
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:420
DenseIterator endDense() const
Definition: NodeMasks.h:887
OffMaskIterator< NodeMask > OffIterator
Definition: NodeMasks.h:654
void save(std::ostream &os) const
Definition: NodeMasks.h:565
bool test() const
Definition: NodeMasks.h:201
Index getBitSize() const
Definition: NodeMasks.h:1104
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:724
void increment()
Definition: NodeMasks.h:217
void increment()
Definition: NodeMasks.h:1190
OffMaskIterator< NodeMask > OffIterator
Definition: NodeMasks.h:879
OnMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:216
void setOff()
Definition: NodeMasks.h:1324
void setOff()
Set all bits off.
Definition: NodeMasks.h:477
~RootNodeMask()
Definition: NodeMasks.h:1094
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:510
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:998
bool operator*() const
Definition: NodeMasks.h:1174
OffIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1189
void increment()
Definition: NodeMasks.h:1162
void load(std::istream &is)
Definition: NodeMasks.h:569
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:872
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:599
Index32 findFirstOff() const
Definition: NodeMasks.h:541
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:494
void increment()
Definition: NodeMasks.h:280
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:647
Base class for the bit mask iterators.
Definition: NodeMasks.h:179
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:982
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:726
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:428
Index32 memUsage() const
Definition: NodeMasks.h:1434
bool operator==(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:192
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:957
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:757
void increment(Index n)
Definition: NodeMasks.h:254
bool operator==(const BaseIterator &iter) const
Definition: NodeMasks.h:1130
DenseMaskIterator()
Definition: NodeMasks.h:278
OffIterator endOff() const
Definition: NodeMasks.h:355
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:732
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:955
bool next()
Definition: NodeMasks.h:224
void toggle()
Definition: NodeMasks.h:1333
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:502
void setOn(Index32 i)
Definition: NodeMasks.h:1306
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1391
void save(std::ostream &os) const
Definition: NodeMasks.h:810
void load(std::istream &is)
Definition: NodeMasks.h:814
Index32 * mBits
Definition: NodeMasks.h:1080
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:698
Index64 Word
Definition: NodeMasks.h:860
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:980
bool test() const
Definition: NodeMasks.h:1144
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:951
Index32 mBitSize
Definition: NodeMasks.h:1079
const RootNodeMask * mParent
Definition: NodeMasks.h:1124
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:437
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:404
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:923
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:483
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:755
DenseIterator & operator++()
Definition: NodeMasks.h:1231
DenseIterator beginDense() const
Definition: NodeMasks.h:356
Index32 FindLowestOn(Index64 v)
Return the least significant on bit of the given 64-bit value.
Definition: NodeMasks.h:138
void increment(Index n)
Definition: NodeMasks.h:223
OnMaskIterator< NodeMask > OnIterator
Definition: NodeMasks.h:348
void seek(std::istream &is) const
Definition: NodeMasks.h:572
Index32 mBitSize
Definition: NodeMasks.h:1123
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:730
OffMaskIterator()
Definition: NodeMasks.h:246
OffIterator beginOff() const
Definition: NodeMasks.h:1239
bool next()
Definition: NodeMasks.h:255
void save(std::ostream &os) const
Definition: NodeMasks.h:1029
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:510
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:737
void load(std::istream &is)
Definition: NodeMasks.h:1033
void setFirstOn()
Definition: NodeMasks.h:1337
Index32 mPos
Definition: NodeMasks.h:1122
OffMaskIterator & operator++()
Definition: NodeMasks.h:261
Index32 FindHighestOn(Index32 v)
Return the most significant on bit of the given 32-bit value.
Definition: NodeMasks.h:156
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:611
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:722
Index32 findFirstOff() const
Definition: NodeMasks.h:1371
Index32 findFirstOn() const
Definition: NodeMasks.h:534
Index getIntSize() const
Definition: NodeMasks.h:1106
OnIterator endOn() const
Definition: NodeMasks.h:353
const RootNodeMask & operator|=(const RootNodeMask &other)
Definition: NodeMasks.h:1268
DenseIterator beginDense() const
Definition: NodeMasks.h:1241
const RootNodeMask & operator^=(const RootNodeMask &other)
Definition: NodeMasks.h:1275
NodeMask operator!() const
Definition: NodeMasks.h:946
NodeMask operator!() const
Definition: NodeMasks.h:435
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:962
OnIterator endOn() const
Definition: NodeMasks.h:883
RootNodeMask operator|(const RootNodeMask &other) const
Definition: NodeMasks.h:1285
bool operator*() const
Definition: NodeMasks.h:229
OnIterator beginOn() const
Definition: NodeMasks.h:882
NodeMask operator!() const
Definition: NodeMasks.h:721
Index32 mPos
Definition: NodeMasks.h:182
NodeMask & operator=(const NodeMask &other)
Assignment operator.
Definition: NodeMasks.h:340
RootNodeMask(const RootNodeMask &B)
Definition: NodeMasks.h:1089
OnIterator endOn() const
Definition: NodeMasks.h:658
BaseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:188
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:984
Index32 findFirstOn() const
Definition: NodeMasks.h:1008
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:947
void increment(Index n)
Definition: NodeMasks.h:1223
OnIterator beginOn() const
Definition: NodeMasks.h:657
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:502
DenseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:279
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:552
Index32 findFirstOn() const
Definition: NodeMasks.h:784
bool operator!=(const BaseIterator &iter) const
Definition: NodeMasks.h:1131
Index32 mIntSize
Definition: NodeMasks.h:1079
#define OPENVDB_VERSION_NAME
Definition: version.h:43
OnMaskIterator< NodeMask > OnIterator
Definition: NodeMasks.h:653
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1036
bool next()
Definition: NodeMasks.h:1170
bool isOff(Index32 i) const
Definition: NodeMasks.h:1346
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:710
DenseMaskIterator & operator++()
Definition: NodeMasks.h:293
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:759
bool next()
Definition: NodeMasks.h:1198
OffMaskIterator< NodeMask > OffIterator
Definition: NodeMasks.h:349
OnMaskIterator< NodeMask > OnIterator
Definition: NodeMasks.h:878
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:645
void increment(Index n)
Definition: NodeMasks.h:1167
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:817
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:1000
RootNodeMask operator^(const RootNodeMask &other) const
Definition: NodeMasks.h:1288
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:508
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:935
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:500
const RootNodeMask & operator&=(const RootNodeMask &other)
Definition: NodeMasks.h:1260
bool operator*() const
Definition: NodeMasks.h:292
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:517
bool operator!=(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:193
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:870
void seek(std::istream &is) const
Definition: NodeMasks.h:1386
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:775
BaseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1128
void seek(std::istream &is) const
Definition: NodeMasks.h:1034
OffIterator beginOff() const
Definition: NodeMasks.h:354
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:412
bool isOn() const
Definition: NodeMasks.h:1352
void seek(std::istream &is) const
Definition: NodeMasks.h:815
Index64 Word
Definition: NodeMasks.h:316
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:763
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:443
OnMaskIterator()
Definition: NodeMasks.h:215
Definition: NodeMasks.h:239
Definition: Exceptions.h:39
BaseIterator()
Definition: NodeMasks.h:1126
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:593
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:988
void increment()
Definition: NodeMasks.h:1218
void increment(Index n)
Definition: NodeMasks.h:1195
RootNodeMask operator!() const
Definition: NodeMasks.h:1259
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:581
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:953
void init(Index32 bit_size)
Definition: NodeMasks.h:1096
void setOn()
Set all bits on.
Definition: NodeMasks.h:971
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:1004
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:441
Index32 getMemUsage() const
Definition: NodeMasks.h:1293
BaseMaskIterator & operator=(const BaseMaskIterator &iter)
Definition: NodeMasks.h:195
void load(std::istream &is)
Definition: NodeMasks.h:1382
Byte Word
Definition: NodeMasks.h:635
RootNodeMask operator&(const RootNodeMask &other) const
Definition: NodeMasks.h:1282
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:728
void setOn()
Set all bits on.
Definition: NodeMasks.h:746
void setOff()
Set all bits off.
Definition: NodeMasks.h:748
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:948
OnIterator endOn() const
Definition: NodeMasks.h:1238
WordT & getWord(Index n)
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:1023
unsigned char Byte
Definition: Types.h:62
DenseMaskIterator< NodeMask > DenseIterator
Definition: NodeMasks.h:350
Index32 findFirstOn() const
Definition: NodeMasks.h:1364
Index32 pos() const
Definition: NodeMasks.h:200
Index32 findFirstOff() const
Definition: NodeMasks.h:785
Definition: NodeMasks.h:270
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:498
~NodeMask()
Destructor.
Definition: NodeMasks.h:649
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:821
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:827
OffIterator endOff() const
Definition: NodeMasks.h:660
WordT & getWord(Index n)
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:558
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:779
bool operator*() const
Definition: NodeMasks.h:1202
Index32 findFirstOff() const
Definition: NodeMasks.h:1009
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:336
void increment(Index n)
Definition: NodeMasks.h:286
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1049
Index32 CountOn(Index64 v)
Return the number of on bits in the given 64-bit value.
Definition: NodeMasks.h:97
RootNodeMask & operator=(const RootNodeMask &B)
Definition: NodeMasks.h:1108
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:334
void setOff()
Set all bits off.
Definition: NodeMasks.h:973
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:1017
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:723
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:704
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:332
void setOff(Index32 i)
Definition: NodeMasks.h:1312
Index32 countOff() const
Definition: NodeMasks.h:1304
Index32 countOn() const
Definition: NodeMasks.h:1297
uint64_t Index64
Definition: Types.h:56
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:457
OffIterator & operator++()
Definition: NodeMasks.h:1203
BaseMaskIterator()
Definition: NodeMasks.h:186
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:761
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:452
~NodeMask()
Destructor.
Definition: NodeMasks.h:874
void setOn()
Set all bits on.
Definition: NodeMasks.h:471
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1040
Definition: NodeMasks.h:208
void increment()
Definition: NodeMasks.h:248
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1062
DenseIterator endDense() const
Definition: NodeMasks.h:357
OffIterator endOff() const
Definition: NodeMasks.h:885
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:576
void toggle(Index32 i)
Definition: NodeMasks.h:1328
OffIterator()
Definition: NodeMasks.h:1188
bool operator*() const
Definition: NodeMasks.h:1230
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:975
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:488
void setLastOff()
Definition: NodeMasks.h:1340
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:840
bool operator*() const
Definition: NodeMasks.h:260
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:765
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:929
OnIterator()
Definition: NodeMasks.h:1160
OnIterator beginOn() const
Definition: NodeMasks.h:352
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:750
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:986
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:990
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1407
bool next()
Definition: NodeMasks.h:287
bool operator<(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:174
DenseIterator beginDense() const
Definition: NodeMasks.h:886
OffMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:247
RootNodeMask()
Definition: NodeMasks.h:1083
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:307
OffIterator beginOff() const
Definition: NodeMasks.h:659
void save(std::ostream &os) const
Definition: NodeMasks.h:1378
const NodeMask * mParent
Definition: NodeMasks.h:183
OffIterator endOff() const
Definition: NodeMasks.h:1240
DenseMaskIterator< NodeMask > DenseIterator
Definition: NodeMasks.h:655
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:438
DenseIterator beginDense() const
Definition: NodeMasks.h:661
BaseIterator & operator=(const BaseIterator &iter)
Definition: NodeMasks.h:1133
DenseIterator()
Definition: NodeMasks.h:1216
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:526
void setFirstOff()
Definition: NodeMasks.h:1339
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:996
OnMaskIterator & operator++()
Definition: NodeMasks.h:230
DenseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1217
Index32 offset() const
Definition: NodeMasks.h:199
Definition: NodeMasks.h:1119
DenseMaskIterator< NodeMask > DenseIterator
Definition: NodeMasks.h:880
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:436
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1395
~NodeMask()
Destructor.
Definition: NodeMasks.h:338
Index32 Index
Definition: Types.h:57
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:833
OffIterator beginOff() const
Definition: NodeMasks.h:884
void setLastOn()
Definition: NodeMasks.h:1338
Index32 offset() const
Definition: NodeMasks.h:1140
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1055
bool next()
Definition: NodeMasks.h:1226
void setOn()
Definition: NodeMasks.h:1320
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:771
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:450
bool isOff() const
Definition: NodeMasks.h:1358
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:868
RootNodeMask(Index32 bit_size)
Definition: NodeMasks.h:1084
OnIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1161
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1412
Index32 pos() const
Definition: NodeMasks.h:1142
Index32 CountOff(Index64 v)
Return the number of off bits in the given 64-bit value.
Definition: NodeMasks.h:106
bool isOn(Index32 i) const
Definition: NodeMasks.h:1341
OnIterator beginOn() const
Definition: NodeMasks.h:1237
Definition: NodeMasks.h:1076
DenseIterator endDense() const
Definition: NodeMasks.h:1242