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