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