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++;) ;
368 bool operator != (
const NodeMask &other)
const {
return !(*
this == other); }
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; }
664 bool operator != (
const NodeMask &other)
const {
return 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; }
886 bool operator != (
const NodeMask &other)
const {
return 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 Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1415
Index32 findFirstOff() const
Definition: NodeMasks.h:783
Definition: NodeMasks.h:1111
void save(std::ostream &os) const
Definition: NodeMasks.h:1024
Index32 FindHighestOn(Index32 v)
Return the most significant on bit of the given 32-bit value.
Definition: NodeMasks.h:158
void increment()
Definition: NodeMasks.h:1182
OffIterator endOff() const
Definition: NodeMasks.h:658
void setOn()
Definition: NodeMasks.h:1312
BaseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:190
void seek(std::istream &is) const
Definition: NodeMasks.h:572
void setFirstOff()
Definition: NodeMasks.h:1331
void increment(Index n)
Definition: NodeMasks.h:1187
void load(std::istream &is)
Definition: NodeMasks.h:809
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:574
void increment(Index n)
Definition: NodeMasks.h:256
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:459
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:943
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:726
OffIterator beginOff() const
Definition: NodeMasks.h:657
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:430
~NodeMask()
Destructor.
Definition: NodeMasks.h:869
BaseIterator & operator=(const BaseIterator &iter)
Definition: NodeMasks.h:1125
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:722
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:757
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:977
Index32 mPos
Definition: NodeMasks.h:184
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:944
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:863
OffMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:249
bool next()
Definition: NodeMasks.h:257
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:714
void setOn()
Set all bits on.
Definition: NodeMasks.h:744
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:993
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:962
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1028
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:334
DenseIterator beginDense() const
Definition: NodeMasks.h:358
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:490
RootNodeMask operator^(const RootNodeMask &other) const
Definition: NodeMasks.h:1280
Index32 findFirstOn() const
Definition: NodeMasks.h:782
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:643
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:975
void save(std::ostream &os) const
Definition: NodeMasks.h:808
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:995
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:936
DenseMaskIterator()
Definition: NodeMasks.h:280
Index32 findFirstOn() const
Definition: NodeMasks.h:536
void increment()
Definition: NodeMasks.h:250
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:645
OffMaskIterator()
Definition: NodeMasks.h:248
DenseIterator beginDense() const
Definition: NodeMasks.h:1233
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:753
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:981
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:865
NodeMask & operator=(const NodeMask &other)
Assignment operator.
Definition: NodeMasks.h:342
WordT & getWord(Index n)
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:1018
RootNodeMask(const RootNodeMask &B)
Definition: NodeMasks.h:1081
OffIterator beginOff() const
Definition: NodeMasks.h:1231
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:777
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:822
OnIterator beginOn() const
Definition: NodeMasks.h:877
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:948
OffIterator endOff() const
Definition: NodeMasks.h:357
void increment(Index n)
Definition: NodeMasks.h:225
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:979
Index getBitSize() const
Definition: NodeMasks.h:1096
Index32 * mBits
Definition: NodeMasks.h:1072
Index32 offset() const
Definition: NodeMasks.h:201
Byte Word
Definition: NodeMasks.h:633
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:528
bool operator<(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:207
Index64 Word
Definition: NodeMasks.h:855
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:985
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation.
Definition: NodeMasks.h:309
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:761
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:464
bool operator!=(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:195
void setOff()
Set all bits off.
Definition: NodeMasks.h:746
Index32 findFirstOff() const
Definition: NodeMasks.h:1004
bool isOff(Index32 i) const
Definition: NodeMasks.h:1338
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:740
void seek(std::istream &is) const
Definition: NodeMasks.h:810
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:769
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:591
void setOff(Index32 i)
Definition: NodeMasks.h:1304
void setOff()
Set all bits off.
Definition: NodeMasks.h:479
void setLastOff()
Definition: NodeMasks.h:1332
void setOn()
Set all bits on.
Definition: NodeMasks.h:966
Index32 FindLowestOn(Index64 v)
Return the least significant on bit of the given 64-bit value.
Definition: NodeMasks.h:140
Index32 getMemUsage() const
Definition: NodeMasks.h:1285
Definition: NodeMasks.h:1201
bool test() const
Definition: NodeMasks.h:1136
DenseMaskIterator & operator++()
Definition: NodeMasks.h:295
OnIterator beginOn() const
Definition: NodeMasks.h:354
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:983
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1054
OffMaskIterator & operator++()
Definition: NodeMasks.h:263
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:735
bool isOn() const
Definition: NodeMasks.h:1344
const RootNodeMask & operator&=(const RootNodeMask &other)
Definition: NodeMasks.h:1252
bool operator==(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:194
void setFirstOn()
Definition: NodeMasks.h:1329
RootNodeMask & operator=(const RootNodeMask &B)
Definition: NodeMasks.h:1100
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:867
DenseIterator endDense() const
Definition: NodeMasks.h:882
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:708
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:728
Definition: NodeMasks.h:1173
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:724
void setOn(Index32 i)
Definition: NodeMasks.h:1298
const NodeMask * mParent
Definition: NodeMasks.h:185
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:579
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:406
Index32 pos() const
Definition: NodeMasks.h:202
OnMaskIterator()
Definition: NodeMasks.h:217
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1047
OnIterator endOn() const
Definition: NodeMasks.h:355
Index32 pos() const
Definition: NodeMasks.h:1134
Definition: NodeMasks.h:210
void load(std::istream &is)
Definition: NodeMasks.h:1374
NodeMask operator!() const
Definition: NodeMasks.h:437
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:702
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:519
void increment(Index n)
Definition: NodeMasks.h:288
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:755
Index64 Word
Definition: NodeMasks.h:318
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:999
Definition: NodeMasks.h:241
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:952
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:502
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:970
Definition: NodeMasks.h:1068
OnIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1153
BaseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1120
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:125
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:773
void increment()
Definition: NodeMasks.h:219
BaseIterator()
Definition: NodeMasks.h:1118
OffIterator()
Definition: NodeMasks.h:1180
OffIterator & operator++()
Definition: NodeMasks.h:1195
Definition: NodeMasks.h:1145
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:504
RootNodeMask operator|(const RootNodeMask &other) const
Definition: NodeMasks.h:1277
DenseIterator beginDense() const
Definition: NodeMasks.h:881
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:991
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:835
Index32 Index
Definition: Types.h:61
DenseIterator endDense() const
Definition: NodeMasks.h:359
OnIterator beginOn() const
Definition: NodeMasks.h:655
uint64_t Index64
Definition: Types.h:60
Index getIntSize() const
Definition: NodeMasks.h:1098
Index32 offset() const
Definition: NodeMasks.h:1132
Index32 mBitSize
Definition: NodeMasks.h:1071
void load(std::istream &is)
Definition: NodeMasks.h:1025
void increment(Index n)
Definition: NodeMasks.h:1215
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:338
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:828
Base class for the bit mask iterators.
Definition: NodeMasks.h:181
RootNodeMask operator!() const
Definition: NodeMasks.h:1251
RootNodeMask()
Definition: NodeMasks.h:1075
Mat3< typename promote< T0, T1 >::type > operator *(const Mat3< T0 > &m0, const Mat3< T1 > &m1)
Multiply m0 by m1 and return the resulting matrix.
Definition: Mat3.h:645
Definition: Exceptions.h:40
Index32 findFirstOn() const
Definition: NodeMasks.h:1356
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:485
bool next()
Definition: NodeMasks.h:1218
DenseIterator endDense() const
Definition: NodeMasks.h:1234
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:696
void toggle(Index32 i)
Definition: NodeMasks.h:1320
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:440
Index32 CountOn(Index64 v)
Return the number of on bits in the given 64-bit value.
Definition: NodeMasks.h:99
Index32 countOn() const
Definition: NodeMasks.h:1289
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:816
OnIterator endOn() const
Definition: NodeMasks.h:656
DenseIterator & operator++()
Definition: NodeMasks.h:1223
Definition: NodeMasks.h:272
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1383
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:946
bool next()
Definition: NodeMasks.h:289
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:554
Index32 mBitSize
Definition: NodeMasks.h:1115
const RootNodeMask * mParent
Definition: NodeMasks.h:1116
void increment()
Definition: NodeMasks.h:1210
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:466
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1387
const RootNodeMask & operator|=(const RootNodeMask &other)
Definition: NodeMasks.h:1260
void setOn()
Set all bits on.
Definition: NodeMasks.h:473
Index32 findFirstOn() const
Definition: NodeMasks.h:1003
void setLastOn()
Definition: NodeMasks.h:1330
void load(std::istream &is)
Definition: NodeMasks.h:571
Index32 countOff() const
Definition: NodeMasks.h:1296
NodeMask operator!() const
Definition: NodeMasks.h:719
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:964
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:721
OnMaskIterator & operator++()
Definition: NodeMasks.h:232
const RootNodeMask & operator^=(const RootNodeMask &other)
Definition: NodeMasks.h:1267
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1041
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1399
OnMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:218
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:422
bool operator==(const BaseIterator &iter) const
Definition: NodeMasks.h:1122
RootNodeMask(Index32 bit_size)
Definition: NodeMasks.h:1076
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:500
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:748
Index32 CountOff(Index64 v)
Return the number of off bits in the given 64-bit value.
Definition: NodeMasks.h:108
void seek(std::istream &is) const
Definition: NodeMasks.h:1378
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:730
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:763
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:924
~NodeMask()
Destructor.
Definition: NodeMasks.h:647
OnIterator & operator++()
Definition: NodeMasks.h:1167
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:454
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:439
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:445
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:641
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:930
DenseIterator endDense() const
Definition: NodeMasks.h:660
OffIterator endOff() const
Definition: NodeMasks.h:880
bool isOff() const
Definition: NodeMasks.h:1350
bool next()
Definition: NodeMasks.h:1162
bool operator!=(const BaseIterator &iter) const
Definition: NodeMasks.h:1123
void toggle()
Definition: NodeMasks.h:1325
WordT & getWord(Index n)
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:560
OnIterator endOn() const
Definition: NodeMasks.h:878
void increment()
Definition: NodeMasks.h:282
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
Index32 mIntSize
Definition: NodeMasks.h:1071
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:496
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1404
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:336
NodeMask operator!() const
Definition: NodeMasks.h:941
void increment(Index n)
Definition: NodeMasks.h:1159
BaseMaskIterator()
Definition: NodeMasks.h:188
bool test() const
Definition: NodeMasks.h:203
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:414
bool isOn(Index32 i) const
Definition: NodeMasks.h:1333
Index32 findFirstOff() const
Definition: NodeMasks.h:1363
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:957
void init(Index32 bit_size)
Definition: NodeMasks.h:1088
OffIterator beginOff() const
Definition: NodeMasks.h:879
OffIterator beginOff() const
Definition: NodeMasks.h:356
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:177
Index32 mPos
Definition: NodeMasks.h:1114
OnIterator()
Definition: NodeMasks.h:1152
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:512
void setOff()
Set all bits off.
Definition: NodeMasks.h:968
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:597
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:498
OffIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1181
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:812
~NodeMask()
Destructor.
Definition: NodeMasks.h:340
void seek(std::istream &is) const
Definition: NodeMasks.h:1026
unsigned char Byte
Definition: Types.h:66
Index32 memUsage() const
Definition: NodeMasks.h:1426
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:759
DenseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:281
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:510
DenseIterator beginDense() const
Definition: NodeMasks.h:659
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:771
void save(std::ostream &os) const
Definition: NodeMasks.h:567
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:950
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:443
DenseIterator()
Definition: NodeMasks.h:1208
bool next()
Definition: NodeMasks.h:1190
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:498
void increment()
Definition: NodeMasks.h:1154
void save(std::ostream &os) const
Definition: NodeMasks.h:1370
bool next()
Definition: NodeMasks.h:226
OnIterator endOn() const
Definition: NodeMasks.h:1230
void setOff()
Definition: NodeMasks.h:1316
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1032
Index32 findFirstOff() const
Definition: NodeMasks.h:543
OffIterator endOff() const
Definition: NodeMasks.h:1232
~RootNodeMask()
Definition: NodeMasks.h:1086
BaseMaskIterator & operator=(const BaseMaskIterator &iter)
Definition: NodeMasks.h:197
OnIterator beginOn() const
Definition: NodeMasks.h:1229
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:452
void set(Index32 i, bool On)
Definition: NodeMasks.h:1310
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:609
uint32_t Index32
Definition: Types.h:59
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:918
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:1012