Go to the documentation of this file.
35 #ifndef OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
36 #define OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
58 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics
61 const Byte numBits[256] = {
63 #define COUNTONB2(n) n, n+1, n+1, n+2
64 #define COUNTONB4(n) COUNTONB2(n), COUNTONB2(n+1), COUNTONB2(n+1), COUNTONB2(n+2)
65 #define COUNTONB6(n) COUNTONB4(n), COUNTONB4(n+1), COUNTONB4(n+1), COUNTONB4(n+2)
89 v = v - ((v >> 1) & 0x55555555U);
90 v = (v & 0x33333333U) + ((v >> 2) & 0x33333333U);
91 return (((v + (v >> 4)) & 0xF0F0F0FU) * 0x1010101U) >> 24;
101 v = v - ((v >> 1) & UINT64_C(0x5555555555555555));
102 v = (v & UINT64_C(0x3333333333333333)) + ((v >> 2) & UINT64_C(0x3333333333333333));
103 return static_cast<Index32>(
104 (((v + (v >> 4)) & UINT64_C(0xF0F0F0F0F0F0F0F)) * UINT64_C(0x101010101010101)) >> 56);
115 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics
118 const Byte DeBruijn[8] = {0, 1, 6, 2, 7, 5, 4, 3};
119 return DeBruijn[
Byte((v & -v) * 0x1DU) >> 5];
128 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics
131 const Byte DeBruijn[32] = {
132 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
133 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
135 return DeBruijn[
Index32((v & -v) * 0x077CB531U) >> 27];
144 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics
147 const Byte DeBruijn[64] = {
148 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
149 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
150 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
151 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12,
153 return DeBruijn[
Index64((v & -v) * UINT64_C(0x022FDD63CC95386D)) >> 58];
160 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics
163 const Byte DeBruijn[32] = {
164 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
165 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
172 return DeBruijn[
Index32(v * 0x07C4ACDDU) >> 27];
180 template<
typename NodeMask>
192 assert((parent ==
nullptr && pos == 0) || (parent !=
nullptr && pos <= NodeMask::SIZE));
199 mPos = iter.
mPos; mParent = iter.
mParent;
return *
this;
203 bool test()
const { assert(mPos <= NodeMask::SIZE);
return (mPos != NodeMask::SIZE); }
204 operator bool()
const {
return this->test(); }
209 template <
typename NodeMask>
214 using BaseType::mPos;
215 using BaseType::mParent;
221 assert(mParent !=
nullptr);
222 mPos = mParent->findNextOn(mPos+1);
223 assert(mPos <= NodeMask::SIZE);
240 template <
typename NodeMask>
245 using BaseType::mPos;
246 using BaseType::mParent;
252 assert(mParent !=
nullptr);
253 mPos=mParent->findNextOff(mPos+1);
254 assert(mPos <= NodeMask::SIZE);
271 template <
typename NodeMask>
276 using BaseType::mPos;
277 using BaseType::mParent;
284 assert(mParent !=
nullptr);
286 assert(mPos<= NodeMask::SIZE);
308 template<Index Log2Dim>
312 static_assert(Log2Dim > 2,
"expected NodeMask template specialization, got base template");
330 Word mWords[WORD_COUNT];
345 const Word* w2 = other.mWords;
346 for (
Word* w1 = mWords; n--; ++w1, ++w2) *w1 = *w2;
364 for (
const Word *w1=mWords, *w2=other.mWords; n-- && *w1++ == *w2++;) ;
380 template<
typename WordOp>
384 const Word *w2 = other.mWords;
385 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) op( *w1, *w2);
388 template<
typename WordOp>
392 const Word *w2 = other1.mWords, *w3 = other2.mWords;
393 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2, ++w3) op( *w1, *w2, *w3);
396 template<
typename WordOp>
401 const Word *w2 = other1.mWords, *w3 = other2.mWords, *w4 = other3.mWords;
402 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2, ++w3, ++w4) op( *w1, *w2, *w3, *w4);
409 const Word *w2 = other.mWords;
410 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= *w2;
417 const Word *w2 = other.mWords;
418 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 |= *w2;
425 const Word *w2 = other.mWords;
426 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= ~*w2;
433 const Word *w2 = other.mWords;
434 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 ^= *w2;
447 Index32 sum = 0, n = WORD_COUNT;
448 for (
const Word* w = mWords; n--; ++w) sum +=
CountOn(*w);
455 assert( (n >> 6) < WORD_COUNT );
456 mWords[n >> 6] |=
Word(1) << (n & 63);
460 assert( (n >> 6) < WORD_COUNT );
461 mWords[n >> 6] &= ~(
Word(1) << (n & 63));
464 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
470 for (
Word* w = mWords; n--; ++w) *w = state;
476 for (
Word* w = mWords; n--; ++w) *w = ~
Word(0);
482 for (
Word* w = mWords; n--; ++w) *w =
Word(0);
486 assert( (n >> 6) < WORD_COUNT );
487 mWords[n >> 6] ^=
Word(1) << (n & 63);
493 for (
Word* w = mWords; n--; ++w) *w = ~*w;
506 assert( (n >> 6) < WORD_COUNT );
507 return 0 != (mWords[n >> 6] & (
Word(1) << (n & 63)));
515 for (
const Word *w = mWords; n-- && *w++ == ~
Word(0);) ;
522 for (
const Word *w = mWords; n-- && *w++ ==
Word(0);) ;
530 isOn = (mWords[0] == ~
Word(0));
531 if ( !isOn && mWords[0] !=
Word(0))
return false;
532 const Word *w = mWords + 1, *n = mWords + WORD_COUNT;
533 while( w<n && *w == mWords[0] ) ++w;
539 const Word* w = mWords;
540 for (; n<WORD_COUNT && !*w; ++w, ++n) ;
541 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(*w);
546 const Word* w = mWords;
547 for (; n<WORD_COUNT && !~*w; ++w, ++n) ;
548 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(~*w);
552 template<
typename WordT>
556 assert(n*8*
sizeof(WordT) < SIZE);
557 return reinterpret_cast<const WordT*>(mWords)[n];
559 template<
typename WordT>
562 assert(n*8*
sizeof(WordT) < SIZE);
563 return reinterpret_cast<WordT*>(mWords)[n];
567 void save(std::ostream& os)
const
569 os.write(reinterpret_cast<const char*>(mWords), this->memUsage());
571 void load(std::istream& is) { is.read(reinterpret_cast<char*>(mWords), this->memUsage()); }
572 void seek(std::istream& is)
const { is.seekg(this->memUsage(), std::ios_base::cur); }
576 os <<
"NodeMask: Dim=" << DIM <<
" Log2Dim=" << Log2Dim
577 <<
" Bit count=" << SIZE <<
" word count=" << WORD_COUNT << std::endl;
581 const Index32 n=(SIZE>max_out ? max_out : SIZE);
582 for (
Index32 i=0; i < n; ++i) {
589 os <<
"|" << std::endl;
594 this->printBits(os, max_out);
600 if (n >= WORD_COUNT)
return SIZE;
603 if (b & (
Word(1) << m))
return start;
605 while(!b && ++n<WORD_COUNT) b = mWords[n];
612 if (n >= WORD_COUNT)
return SIZE;
615 if (b & (
Word(1) << m))
return start;
617 while(!b && ++n<WORD_COUNT) b = ~mWords[n];
649 void operator = (
const NodeMask &other) { mByte = other.mByte; }
676 template<
typename WordOp>
679 op(mByte, other.mByte);
682 template<
typename WordOp>
685 op(mByte, other1.mByte, other2.mByte);
688 template<
typename WordOp>
692 op(mByte, other1.mByte, other2.mByte, other3.mByte);
698 mByte &= other.mByte;
704 mByte |= other.mByte;
710 mByte &= static_cast<Byte>(~other.mByte);
716 mByte ^= other.mByte;
732 mByte = static_cast<Byte>(mByte | 0x01U << (n & 7));
737 mByte = static_cast<Byte>(mByte & ~(0x01U << (n & 7)));
740 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
742 void set(
bool on) { mByte = on ? 0xFFU : 0x00U; }
750 mByte = static_cast<Byte>(mByte ^ 0x01U << (n & 7));
753 void toggle() { mByte = static_cast<Byte>(~mByte); }
766 return mByte & (0x01U << (n & 7));
771 bool isOn()
const {
return mByte == 0xFFU; }
773 bool isOff()
const {
return mByte == 0; }
780 return isOn || this->isOff();
785 const Byte b = static_cast<Byte>(~mByte);
808 void save(std::ostream& os)
const { os.write(reinterpret_cast<const char*>(&mByte), 1); }
809 void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mByte), 1); }
810 void seek(std::istream& is)
const { is.seekg(1, std::ios_base::cur); }
814 os <<
"NodeMask: Dim=2, Log2Dim=1, Bit count=8, Word count=1"<<std::endl;
819 for (
Index32 i=0; i < 8; ++i) os << this->isOn(i);
820 os <<
"||" << std::endl;
830 if (start>=8)
return 8;
831 const Byte b = static_cast<Byte>(mByte & (0xFFU << start));
837 if (start>=8)
return 8;
838 const Byte b = static_cast<Byte>(~mByte & (0xFFU << start));
865 NodeMask(
bool on) : mWord(on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00)) {}
871 void operator = (
const NodeMask &other) { mWord = other.mWord; }
898 template<
typename WordOp>
901 op(mWord, other.mWord);
904 template<
typename WordOp>
907 op(mWord, other1.mWord, other2.mWord);
910 template<
typename WordOp>
914 op(mWord, other1.mWord, other2.mWord, other3.mWord);
920 mWord &= other.mWord;
926 mWord |= other.mWord;
932 mWord &= ~other.mWord;
938 mWord ^= other.mWord;
954 mWord |= UINT64_C(0x01) << (n & 63);
959 mWord &= ~(UINT64_C(0x01) << (n & 63));
962 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
964 void set(
bool on) { mWord = on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00); }
966 void setOn() { mWord = UINT64_C(0xFFFFFFFFFFFFFFFF); }
968 void setOff() { mWord = UINT64_C(0x00); }
972 mWord ^= UINT64_C(0x01) << (n & 63);
988 return 0 != (mWord & (UINT64_C(0x01) << (n & 63)));
993 bool isOn()
const {
return mWord == UINT64_C(0xFFFFFFFFFFFFFFFF); }
995 bool isOff()
const {
return mWord == 0; }
1000 { isOn = this->isOn();
1001 return isOn || this->isOff();
1006 const Word w = ~mWord;
1010 template<
typename WordT>
1014 assert(n*8*
sizeof(WordT) < SIZE);
1015 return reinterpret_cast<const WordT*>(&mWord)[n];
1017 template<
typename WordT>
1020 assert(n*8*
sizeof(WordT) < SIZE);
1021 return reinterpret_cast<WordT*>(mWord)[n];
1024 void save(std::ostream& os)
const { os.write(reinterpret_cast<const char*>(&mWord), 8); }
1025 void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mWord), 8); }
1026 void seek(std::istream& is)
const { is.seekg(8, std::ios_base::cur); }
1030 os <<
"NodeMask: Dim=4, Log2Dim=2, Bit count=64, Word count=1"<<std::endl;
1035 for (
Index32 i=0; i < 64; ++i) {
1036 if ( !(i%8) ) os <<
"|";
1037 os << this->isOn(i);
1039 os <<
"||" << std::endl;
1043 this->printInfo(os);
1044 this->printBits(os);
1049 if (start>=64)
return 64;
1050 const Word w = mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1056 if (start>=64)
return 64;
1057 const Word w = ~mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1077 mBitSize(bit_size), mIntSize(((bit_size-1)>>5)+1), mBits(new
Index32[mIntSize])
1079 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1082 mBitSize(B.mBitSize), mIntSize(B.mIntSize), mBits(new
Index32[mIntSize])
1084 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=B.
mBits[i];
1089 mBitSize = bit_size;
1090 mIntSize =((bit_size-1)>>5)+1;
1092 mBits =
new Index32[mIntSize];
1093 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1105 mBits =
new Index32[mIntSize];
1107 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=B.
mBits[i];
1121 mPos(pos), mBitSize(parent->getBitSize()), mParent(parent) { assert(pos <= mBitSize); }
1137 assert(mPos <= mBitSize);
1138 return (mPos != mBitSize);
1141 operator bool()
const {
return this->test();}
1148 using BaseIterator::mPos;
1149 using BaseIterator::mBitSize;
1150 using BaseIterator::mParent;
1155 assert(mParent !=
nullptr);
1156 mPos=mParent->findNextOn(mPos+1);
1157 assert(mPos <= mBitSize);
1160 for (
Index i=0; i<n && this->next(); ++i) {}
1164 return this->test();
1176 using BaseIterator::mPos;
1177 using BaseIterator::mBitSize;
1178 using BaseIterator::mParent;
1183 assert(mParent !=
nullptr);
1184 mPos=mParent->findNextOff(mPos+1);
1185 assert(mPos <= mBitSize);
1188 for (
Index i=0; i<n && this->next(); ++i) {}
1192 return this->test();
1204 using BaseIterator::mPos;
1205 using BaseIterator::mBitSize;
1206 using BaseIterator::mParent;
1211 assert(mParent !=
nullptr);
1213 assert(mPos<= mBitSize);
1216 for (
Index i=0; i<n && this->next(); ++i) {}
1220 return this->test();
1237 if (mBitSize != B.
mBitSize)
return false;
1238 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return false;
1243 if (mBitSize != B.
mBitSize)
return true;
1244 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return true;
1253 assert(mIntSize == other.
mIntSize);
1255 mBits[i] &= other.
mBits[i];
1257 for (
Index32 i = other.
mIntSize; i < mIntSize; ++i) mBits[i] = 0x00000000;
1261 assert(mIntSize == other.
mIntSize);
1263 mBits[i] |= other.
mBits[i];
1268 assert(mIntSize == other.
mIntSize);
1270 mBits[i] ^= other.
mBits[i];
1286 return static_cast<Index32>(mIntSize*
sizeof(
Index32) +
sizeof(*
this));
1300 assert( (i>>5) < mIntSize);
1301 mBits[i>>5] |= 1<<(i&31);
1306 assert( (i>>5) < mIntSize);
1307 mBits[i>>5] &= ~(1<<(i&31));
1310 void set(
Index32 i,
bool On) { On ? this->setOn(i) : this->setOff(i); }
1314 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0xFFFFFFFF;
1318 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1322 assert( (i>>5) < mIntSize);
1323 mBits[i>>5] ^= 1<<(i&31);
1327 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=~mBits[i];
1335 assert( (i>>5) < mIntSize);
1336 return ( mBits[i >> 5] & (1<<(i&31)) );
1340 assert( (i>>5) < mIntSize);
1341 return ( ~mBits[i >> 5] & (1<<(i&31)) );
1345 if (!mBits)
return false;
1346 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0xFFFFFFFF)
return false;
1351 if (!mBits)
return true;
1352 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0)
return false;
1359 while(!mBits[i])
if (++i == mIntSize)
return mBitSize;
1366 while(!(~mBits[i]))
if (++i == mIntSize)
return mBitSize;
1370 void save(std::ostream& os)
const {
1372 os.write(reinterpret_cast<const char*>(mBits), mIntSize *
sizeof(
Index32));
1376 is.read(reinterpret_cast<char*>(mBits), mIntSize *
sizeof(
Index32));
1378 void seek(std::istream& is)
const {
1380 is.seekg(mIntSize *
sizeof(
Index32), std::ios_base::cur);
1384 os <<
"RootNodeMask: Bit-size="<<mBitSize<<
" Int-size="<<mIntSize<<std::endl;
1388 const Index32 n=(mBitSize>max_out?max_out:mBitSize);
1389 for (
Index32 i=0; i < n; ++i) {
1394 os << this->isOn(i);
1396 os <<
"|" << std::endl;
1400 this->printInfo(os);
1401 this->printBits(os,max_out);
1406 Index32 n = start >> 5, m = start & 31;
1407 if (n>=mIntSize)
return mBitSize;
1409 if (b & (1<<m))
return start;
1410 b &= 0xFFFFFFFF << m;
1411 while(!b && ++n<mIntSize) b = mBits[n];
1417 Index32 n = start >> 5, m = start & 31;
1418 if (n>=mIntSize)
return mBitSize;
1420 if (b & (1<<m))
return start;
1422 while(!b && ++n<mIntSize) b = ~mBits[n];
1428 return static_cast<Index32>(
sizeof(
Index32*)+(2+mIntSize)*
sizeof(
Index32));
1436 #endif // OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:643
Index32 mPos
Definition: NodeMasks.h:184
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:440
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:498
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:944
Index32 findFirstOn() const
Definition: NodeMasks.h:1003
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:865
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:936
const RootNodeMask & operator^=(const RootNodeMask &other)
Definition: NodeMasks.h:1267
DenseIterator endDense() const
Definition: NodeMasks.h:359
bool next()
Definition: NodeMasks.h:1162
OffIterator()
Definition: NodeMasks.h:1180
Index32 FindHighestOn(Index32 v)
Return the most significant on bit of the given 32-bit value.
Definition: NodeMasks.h:158
void setOn()
Set all bits on.
Definition: NodeMasks.h:966
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:757
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:439
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:338
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:714
DenseIterator beginDense() const
Definition: NodeMasks.h:659
Definition: NodeMasks.h:1201
void save(std::ostream &os) const
Definition: NodeMasks.h:1370
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:771
void load(std::istream &is)
Definition: NodeMasks.h:571
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:822
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1387
void setOn()
Set all bits on.
Definition: NodeMasks.h:744
RootNodeMask operator!() const
Definition: NodeMasks.h:1251
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:336
DenseIterator beginDense() const
Definition: NodeMasks.h:358
bool operator==(const BaseIterator &iter) const
Definition: NodeMasks.h:1122
RootNodeMask & operator=(const RootNodeMask &B)
Definition: NodeMasks.h:1100
bool test() const
Definition: NodeMasks.h:203
Index32 offset() const
Definition: NodeMasks.h:1132
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1041
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:609
Index getBitSize() const
Definition: NodeMasks.h:1096
void set(Index32 i, bool On)
Definition: NodeMasks.h:1310
Index32 memUsage() const
Definition: NodeMasks.h:1426
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:867
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:740
void setOff()
Set all bits off.
Definition: NodeMasks.h:746
void seek(std::istream &is) const
Definition: NodeMasks.h:810
bool operator*() const
Definition: NodeMasks.h:1222
RootNodeMask(const RootNodeMask &B)
Definition: NodeMasks.h:1081
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:645
void setOff(Index32 i)
Definition: NodeMasks.h:1304
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:962
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:726
void increment(Index n)
Definition: NodeMasks.h:256
void setOn()
Set all bits on.
Definition: NodeMasks.h:473
OffIterator beginOff() const
Definition: NodeMasks.h:879
Definition: NodeMasks.h:1173
Index32 FindLowestOn(Index64 v)
Return the least significant on bit of the given 64-bit value.
Definition: NodeMasks.h:140
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:948
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:735
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:708
const NodeMask * mParent
Definition: NodeMasks.h:185
void setOff()
Set all bits off.
Definition: NodeMasks.h:968
void seek(std::istream &is) const
Definition: NodeMasks.h:1026
bool next()
Definition: NodeMasks.h:289
Index64 Word
Definition: NodeMasks.h:855
OnIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1153
DenseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:281
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:724
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:930
void increment(Index n)
Definition: NodeMasks.h:1187
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:579
RootNodeMask operator^(const RootNodeMask &other) const
Definition: NodeMasks.h:1280
bool next()
Definition: NodeMasks.h:226
bool isOn() const
Definition: NodeMasks.h:1344
void save(std::ostream &os) const
Definition: NodeMasks.h:1024
OnIterator beginOn() const
Definition: NodeMasks.h:1229
OffIterator beginOff() const
Definition: NodeMasks.h:657
Index32 offset() const
Definition: NodeMasks.h:201
~RootNodeMask()
Definition: NodeMasks.h:1086
OnMaskIterator()
Definition: NodeMasks.h:217
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:957
bool operator==(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:194
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:702
void increment()
Definition: NodeMasks.h:1154
void increment(Index n)
Definition: NodeMasks.h:1215
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:502
OnIterator beginOn() const
Definition: NodeMasks.h:354
void increment()
Definition: NodeMasks.h:1210
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:504
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:777
Index32 pos() const
Definition: NodeMasks.h:202
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:946
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:773
Byte Word
Definition: NodeMasks.h:633
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:761
WordT & getWord(Index n)
Definition: NodeMasks.h:560
bool operator*() const
Definition: NodeMasks.h:294
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:999
void save(std::ostream &os) const
Definition: NodeMasks.h:808
void toggle(Index32 i)
Definition: NodeMasks.h:1320
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:975
Index32 * mBits
Definition: NodeMasks.h:1072
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:496
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:983
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:445
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:498
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:977
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:753
Index32 CountOn(Index64 v)
Return the number of on bits in the given 64-bit value.
Definition: NodeMasks.h:99
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:924
bool operator*() const
Definition: NodeMasks.h:231
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:755
bool operator!=(const BaseIterator &iter) const
Definition: NodeMasks.h:1123
DenseIterator()
Definition: NodeMasks.h:1208
void seek(std::istream &is) const
Definition: NodeMasks.h:572
void increment()
Definition: NodeMasks.h:282
bool operator<(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:207
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:995
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:454
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1054
Index32 findFirstOn() const
Definition: NodeMasks.h:1356
OffIterator beginOff() const
Definition: NodeMasks.h:1231
bool next()
Definition: NodeMasks.h:257
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:991
DenseIterator beginDense() const
Definition: NodeMasks.h:1233
void setOn()
Definition: NodeMasks.h:1312
NodeMask operator!() const
Definition: NodeMasks.h:437
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:728
void setLastOn()
Definition: NodeMasks.h:1330
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1047
~NodeMask()
Destructor.
Definition: NodeMasks.h:340
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:769
bool operator*() const
Definition: NodeMasks.h:1166
bool operator!=(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:195
BaseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:190
Index32 countOff() const
Definition: NodeMasks.h:1296
bool isOff(Index32 i) const
Definition: NodeMasks.h:1338
void increment(Index n)
Definition: NodeMasks.h:1159
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:835
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:512
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:519
Index32 CountOff(Index64 v)
Return the number of off bits in the given 64-bit value.
Definition: NodeMasks.h:108
const RootNodeMask & operator&=(const RootNodeMask &other)
Definition: NodeMasks.h:1252
Definition: NodeMasks.h:241
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:950
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:828
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:459
void setFirstOn()
Definition: NodeMasks.h:1329
void save(std::ostream &os) const
Definition: NodeMasks.h:567
OnIterator()
Definition: NodeMasks.h:1152
NodeMask operator!() const
Definition: NodeMasks.h:719
WordT & getWord(Index n)
Definition: NodeMasks.h:1018
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:430
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:414
bool operator*() const
Definition: NodeMasks.h:262
Index32 mBitSize
Definition: NodeMasks.h:1071
DenseIterator endDense() const
Definition: NodeMasks.h:1234
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1399
void increment(Index n)
Definition: NodeMasks.h:288
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:510
Index32 Index
Definition: Types.h:61
NodeMask operator!() const
Definition: NodeMasks.h:941
Index32 findFirstOn() const
Definition: NodeMasks.h:536
DenseIterator & operator++()
Definition: NodeMasks.h:1223
bool next()
Definition: NodeMasks.h:1218
Index32 mPos
Definition: NodeMasks.h:1114
OffIterator & operator++()
Definition: NodeMasks.h:1195
void load(std::istream &is)
Definition: NodeMasks.h:1374
DenseMaskIterator & operator++()
Definition: NodeMasks.h:295
OnMaskIterator & operator++()
Definition: NodeMasks.h:232
uint64_t Index64
Definition: Types.h:60
OffMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:249
OnIterator beginOn() const
Definition: NodeMasks.h:877
RootNodeMask(Index32 bit_size)
Definition: NodeMasks.h:1076
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:574
OnIterator & operator++()
Definition: NodeMasks.h:1167
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:452
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation.
Definition: NodeMasks.h:309
void setOff()
Set all bits off.
Definition: NodeMasks.h:479
BaseIterator()
Definition: NodeMasks.h:1118
OffMaskIterator()
Definition: NodeMasks.h:248
void setOff()
Definition: NodeMasks.h:1316
BaseMaskIterator()
Definition: NodeMasks.h:188
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:985
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:970
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:696
OnIterator endOn() const
Definition: NodeMasks.h:656
void setOn(Index32 i)
Definition: NodeMasks.h:1298
void increment()
Definition: NodeMasks.h:250
OffIterator endOff() const
Definition: NodeMasks.h:357
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:438
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:816
RootNodeMask operator|(const RootNodeMask &other) const
Definition: NodeMasks.h:1277
bool next()
Definition: NodeMasks.h:1190
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:763
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:748
OnIterator beginOn() const
Definition: NodeMasks.h:655
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:177
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:918
OnIterator endOn() const
Definition: NodeMasks.h:878
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:1012
uint32_t Index32
Definition: Types.h:59
OffIterator endOff() const
Definition: NodeMasks.h:1232
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:554
Index32 findFirstOff() const
Definition: NodeMasks.h:543
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:485
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:528
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1415
Index32 countOn() const
Definition: NodeMasks.h:1289
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1032
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:943
NodeMask & operator=(const NodeMask &other)
Assignment operator.
Definition: NodeMasks.h:342
Definition: NodeMasks.h:1068
void setLastOff()
Definition: NodeMasks.h:1332
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:759
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:500
void increment()
Definition: NodeMasks.h:219
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1404
OnMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:218
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:490
OffIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1181
~NodeMask()
Destructor.
Definition: NodeMasks.h:647
bool isOn(Index32 i) const
Definition: NodeMasks.h:1333
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:506
const RootNodeMask * mParent
Definition: NodeMasks.h:1116
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:334
OffIterator beginOff() const
Definition: NodeMasks.h:356
DenseIterator endDense() const
Definition: NodeMasks.h:660
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:721
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:125
BaseIterator & operator=(const BaseIterator &iter)
Definition: NodeMasks.h:1125
RootNodeMask operator&(const RootNodeMask &other) const
Definition: NodeMasks.h:1274
Base class for the bit mask iterators.
Definition: NodeMasks.h:181
void seek(std::istream &is) const
Definition: NodeMasks.h:1378
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:981
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1383
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:863
BaseMaskIterator & operator=(const BaseMaskIterator &iter)
Definition: NodeMasks.h:197
Definition: NodeMasks.h:1111
DenseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1209
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:742
Definition: NodeMasks.h:210
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:952
OffIterator endOff() const
Definition: NodeMasks.h:658
~NodeMask()
Destructor.
Definition: NodeMasks.h:869
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:406
Index32 getMemUsage() const
Definition: NodeMasks.h:1285
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:591
void increment(Index n)
Definition: NodeMasks.h:225
Index32 findFirstOff() const
Definition: NodeMasks.h:1004
OnIterator endOn() const
Definition: NodeMasks.h:355
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:730
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:466
Index64 Word
Definition: NodeMasks.h:318
DenseIterator endDense() const
Definition: NodeMasks.h:882
OffMaskIterator & operator++()
Definition: NodeMasks.h:263
Index32 mBitSize
Definition: NodeMasks.h:1115
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:464
Definition: Exceptions.h:40
OnIterator endOn() const
Definition: NodeMasks.h:1230
bool operator*() const
Definition: NodeMasks.h:1194
void load(std::istream &is)
Definition: NodeMasks.h:809
Index32 pos() const
Definition: NodeMasks.h:1134
const RootNodeMask & operator|=(const RootNodeMask &other)
Definition: NodeMasks.h:1260
Index32 findFirstOff() const
Definition: NodeMasks.h:1363
void increment()
Definition: NodeMasks.h:1182
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:720
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:641
DenseMaskIterator()
Definition: NodeMasks.h:280
bool test() const
Definition: NodeMasks.h:1136
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:812
RootNodeMask()
Definition: NodeMasks.h:1075
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:964
Definition: NodeMasks.h:1145
void init(Index32 bit_size)
Definition: NodeMasks.h:1088
OffIterator endOff() const
Definition: NodeMasks.h:880
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:942
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:722
bool isOff() const
Definition: NodeMasks.h:1350
Index32 findFirstOff() const
Definition: NodeMasks.h:783
Index getIntSize() const
Definition: NodeMasks.h:1098
unsigned char Byte
Definition: Types.h:66
void toggle()
Definition: NodeMasks.h:1325
Definition: NodeMasks.h:272
Index32 mIntSize
Definition: NodeMasks.h:1071
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:422
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:979
BaseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1120
DenseIterator beginDense() const
Definition: NodeMasks.h:881
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:597
void load(std::istream &is)
Definition: NodeMasks.h:1025
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:443
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:993
void setFirstOff()
Definition: NodeMasks.h:1331
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1028
Index32 findFirstOn() const
Definition: NodeMasks.h:782