35 #ifndef OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED 36 #define OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED 41 #include <openvdb/Platform.h> 42 #include <openvdb/Types.h> 56 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics 59 const Byte numBits[256] = {
60 # define B2(n) n, n+1, n+1, n+2 61 # define B4(n) B2(n), B2(n+1), B2(n+1), B2(n+2) 62 # define B6(n) B4(n), B4(n+1), B4(n+1), B4(n+2) 82 v = v - ((v >> 1) & 0x55555555U);
83 v = (v & 0x33333333U) + ((v >> 2) & 0x33333333U);
84 return (((v + (v >> 4)) & 0xF0F0F0FU) * 0x1010101U) >> 24;
94 v = v - ((v >> 1) & UINT64_C(0x5555555555555555));
95 v = (v & UINT64_C(0x3333333333333333)) + ((v >> 2) & UINT64_C(0x3333333333333333));
97 (((v + (v >> 4)) & UINT64_C(0xF0F0F0F0F0F0F0F)) * UINT64_C(0x101010101010101)) >> 56);
108 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics 111 const Byte DeBruijn[8] = {0, 1, 6, 2, 7, 5, 4, 3};
112 return DeBruijn[
Byte((v & -v) * 0x1DU) >> 5];
121 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics 124 const Byte DeBruijn[32] = {
125 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
126 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
128 return DeBruijn[
Index32((v & -v) * 0x077CB531U) >> 27];
137 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics 140 const Byte DeBruijn[64] = {
141 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
142 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
143 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
144 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12,
146 return DeBruijn[
Index64((v & -v) * UINT64_C(0x022FDD63CC95386D)) >> 58];
153 #ifndef _MSC_VER // Visual C++ doesn't guarantee thread-safe initialization of local statics 156 const Byte DeBruijn[32] = {
157 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
158 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
165 return DeBruijn[
Index32(v * 0x07C4ACDDU) >> 27];
173 template <
typename NodeMask>
183 assert( (parent==NULL && pos==0 ) || (parent!=NULL && pos<=NodeMask::SIZE) );
190 mPos = iter.
mPos; mParent = iter.
mParent;
return *
this;
196 assert(mPos <= NodeMask::SIZE);
197 return (mPos != NodeMask::SIZE);
199 operator bool()
const {
return this->test();}
204 template <
typename NodeMask>
209 using BaseType::mPos;
210 using BaseType::mParent;
216 assert(mParent != NULL);
217 mPos = mParent->findNextOn(mPos+1);
218 assert(mPos <= NodeMask::SIZE);
235 template <
typename NodeMask>
240 using BaseType::mPos;
241 using BaseType::mParent;
247 assert(mParent != NULL);
248 mPos=mParent->findNextOff(mPos+1);
249 assert(mPos <= NodeMask::SIZE);
266 template <
typename NodeMask>
271 using BaseType::mPos;
272 using BaseType::mParent;
279 assert(mParent != NULL);
281 assert(mPos<= NodeMask::SIZE);
303 template<Index Log2Dim>
307 BOOST_STATIC_ASSERT( Log2Dim>2 );
325 Word mWords[WORD_COUNT];
340 const Word* w2 = other.mWords;
341 for (Word* w1 = mWords; n--; ++w1, ++w2) *w1 = *w2;
349 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
350 OnIterator
endOn()
const {
return OnIterator(SIZE,
this); }
351 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
352 OffIterator
endOff()
const {
return OffIterator(SIZE,
this); }
353 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
354 DenseIterator
endDense()
const {
return DenseIterator(SIZE,
this); }
359 for (
const Word *w1=mWords, *w2=other.mWords; n-- && *w1++ == *w2++;) ;
375 template<
typename WordOp>
379 const Word *w2 = other.mWords;
380 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) op( *w1, *w2);
383 template<
typename WordOp>
387 const Word *w2 = other1.mWords, *w3 = other2.mWords;
388 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2, ++w3) op( *w1, *w2, *w3);
391 template<
typename WordOp>
396 const Word *w2 = other1.mWords, *w3 = other2.mWords, *w4 = other3.mWords;
397 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2, ++w3, ++w4) op( *w1, *w2, *w3, *w4);
404 const Word *w2 = other.mWords;
405 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= *w2;
412 const Word *w2 = other.mWords;
413 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 |= *w2;
420 const Word *w2 = other.mWords;
421 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= ~*w2;
428 const Word *w2 = other.mWords;
429 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 ^= *w2;
442 Index32 sum = 0, n = WORD_COUNT;
443 for (
const Word* w = mWords; n--; ++w) sum +=
CountOn(*w);
450 assert( (n >> 6) < WORD_COUNT );
451 mWords[n >> 6] |= Word(1) << (n & 63);
455 assert( (n >> 6) < WORD_COUNT );
456 mWords[n >> 6] &= ~(Word(1) << (n & 63));
459 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
463 const Word state = on ? ~Word(0) : Word(0);
465 for (Word* w = mWords; n--; ++w) *w = state;
471 for (Word* w = mWords; n--; ++w) *w = ~Word(0);
477 for (Word* w = mWords; n--; ++w) *w = Word(0);
481 assert( (n >> 6) < WORD_COUNT );
482 mWords[n >> 6] ^= Word(1) << (n & 63);
488 for (Word* w = mWords; n--; ++w) *w = ~*w;
501 assert( (n >> 6) < WORD_COUNT );
502 return 0 != (mWords[n >> 6] & (Word(1) << (n & 63)));
510 for (
const Word *w = mWords; n-- && *w++ == ~Word(0);) ;
517 for (
const Word *w = mWords; n-- && *w++ == Word(0);) ;
525 isOn = (mWords[0] == ~Word(0));
526 if ( !isOn && mWords[0] != Word(0))
return false;
527 const Word *w = mWords + 1, *n = mWords + WORD_COUNT;
528 while( w<n && *w == mWords[0] ) ++w;
534 const Word* w = mWords;
535 for (; n<WORD_COUNT && !*w; ++w, ++n) ;
536 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(*w);
541 const Word* w = mWords;
542 for (; n<WORD_COUNT && !~*w; ++w, ++n) ;
543 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(~*w);
547 template<
typename WordT>
551 assert(n*8*
sizeof(WordT) < SIZE);
552 return reinterpret_cast<const WordT*
>(mWords)[n];
554 template<
typename WordT>
557 assert(n*8*
sizeof(WordT) < SIZE);
558 return reinterpret_cast<WordT*
>(mWords)[n];
562 void save(std::ostream& os)
const 564 os.write(reinterpret_cast<const char*>(mWords), this->memUsage());
567 is.read(reinterpret_cast<char*>(mWords), this->memUsage());
572 os <<
"NodeMask: Dim=" << DIM <<
" Log2Dim=" << Log2Dim
573 <<
" Bit count=" << SIZE <<
" word count=" << WORD_COUNT << std::endl;
577 const Index32 n=(SIZE>max_out ? max_out : SIZE);
578 for (
Index32 i=0; i < n; ++i) {
585 os <<
"|" << std::endl;
590 this->printBits(os, max_out);
596 if (n >= WORD_COUNT)
return SIZE;
599 if (b & (Word(1) << m))
return start;
601 while(!b && ++n<WORD_COUNT) b = mWords[n];
608 if (n >= WORD_COUNT)
return SIZE;
611 if (b & (Word(1) << m))
return start;
613 while(!b && ++n<WORD_COUNT) b = ~mWords[n];
645 void operator = (
const NodeMask &other) { mByte = other.mByte; }
651 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
652 OnIterator
endOn()
const {
return OnIterator(SIZE,
this); }
653 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
654 OffIterator
endOff()
const {
return OffIterator(SIZE,
this); }
655 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
656 DenseIterator
endDense()
const {
return DenseIterator(SIZE,
this); }
672 template<
typename WordOp>
675 op(mByte, other.mByte);
678 template<
typename WordOp>
681 op(mByte, other1.mByte, other2.mByte);
684 template<
typename WordOp>
688 op(mByte, other1.mByte, other2.mByte, other3.mByte);
694 mByte &= other.mByte;
700 mByte |= other.mByte;
706 mByte &=
static_cast<Byte>(~other.mByte);
712 mByte ^= other.mByte;
728 mByte = mByte |
static_cast<Byte>(0x01U << (n & 7));
733 mByte = mByte &
static_cast<Byte>(~(0x01U << (n & 7)));
736 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
738 void set(
bool on) { mByte = on ? 0xFFU : 0x00U; }
746 mByte = mByte ^
static_cast<Byte>(0x01U << (n & 7));
762 return mByte & (0x01U << (n & 7));
767 bool isOn()
const {
return mByte == 0xFFU; }
769 bool isOff()
const {
return mByte == 0; }
776 return isOn || this->isOff();
781 const Byte b =
static_cast<Byte>(~mByte);
804 void save(std::ostream& os)
const 806 os.write(reinterpret_cast<const char*>(&mByte), 1);
808 void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mByte), 1); }
812 os <<
"NodeMask: Dim=2, Log2Dim=1, Bit count=8, Word count=1"<<std::endl;
817 for (
Index32 i=0; i < 8; ++i) os << this->isOn(i);
818 os <<
"||" << std::endl;
828 if (start>=8)
return 8;
829 const Byte b =
static_cast<Byte>(mByte & (0xFFU << start));
835 if (start>=8)
return 8;
836 const Byte b =
static_cast<Byte>(~mByte & (0xFFU << start));
863 NodeMask(
bool on) : mWord(on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00)) {}
869 void operator = (
const NodeMask &other) { mWord = other.mWord; }
875 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
876 OnIterator
endOn()
const {
return OnIterator(SIZE,
this); }
877 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
878 OffIterator
endOff()
const {
return OffIterator(SIZE,
this); }
879 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
880 DenseIterator
endDense()
const {
return DenseIterator(SIZE,
this); }
896 template<
typename WordOp>
899 op(mWord, other.mWord);
902 template<
typename WordOp>
905 op(mWord, other1.mWord, other2.mWord);
908 template<
typename WordOp>
912 op(mWord, other1.mWord, other2.mWord, other3.mWord);
918 mWord &= other.mWord;
924 mWord |= other.mWord;
930 mWord &= ~other.mWord;
936 mWord ^= other.mWord;
952 mWord |= UINT64_C(0x01) << (n & 63);
957 mWord &= ~(UINT64_C(0x01) << (n & 63));
960 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
962 void set(
bool on) { mWord = on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00); }
964 void setOn() { mWord = UINT64_C(0xFFFFFFFFFFFFFFFF); }
966 void setOff() { mWord = UINT64_C(0x00); }
970 mWord ^= UINT64_C(0x01) << (n & 63);
986 return 0 != (mWord & (UINT64_C(0x01) << (n & 63)));
991 bool isOn()
const {
return mWord == UINT64_C(0xFFFFFFFFFFFFFFFF); }
993 bool isOff()
const {
return mWord == 0; }
998 { isOn = this->isOn();
999 return isOn || this->isOff();
1004 const Word w = ~mWord;
1008 template<
typename WordT>
1012 assert(n*8*
sizeof(WordT) < SIZE);
1013 return reinterpret_cast<const WordT*
>(&mWord)[n];
1015 template<
typename WordT>
1018 assert(n*8*
sizeof(WordT) < SIZE);
1019 return reinterpret_cast<WordT*
>(mWord)[n];
1024 os.write(reinterpret_cast<const char*>(&mWord), 8);
1026 void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mWord), 8); }
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];
1120 : mPos(pos), mBitSize(parent->getBitSize()), mParent(parent) {
1121 assert( pos<=mBitSize );
1138 assert(mPos <= mBitSize);
1139 return (mPos != mBitSize);
1142 operator bool()
const {
return this->test();}
1149 using BaseIterator::mPos;
1150 using BaseIterator::mBitSize;
1151 using BaseIterator::mParent;
1156 assert(mParent!=NULL);
1157 mPos=mParent->findNextOn(mPos+1);
1158 assert(mPos <= mBitSize);
1161 for (
Index i=0; i<n && this->next(); ++i) {}
1165 return this->test();
1177 using BaseIterator::mPos;
1178 using BaseIterator::mBitSize;
1179 using BaseIterator::mParent;
1184 assert(mParent!=NULL);
1185 mPos=mParent->findNextOff(mPos+1);
1186 assert(mPos <= mBitSize);
1189 for (
Index i=0; i<n && this->next(); ++i) {}
1193 return this->test();
1205 using BaseIterator::mPos;
1206 using BaseIterator::mBitSize;
1207 using BaseIterator::mParent;
1212 assert(mParent!=NULL);
1214 assert(mPos<= mBitSize);
1217 for (
Index i=0; i<n && this->next(); ++i) {}
1221 return this->test();
1230 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
1231 OnIterator
endOn()
const {
return OnIterator(mBitSize,
this); }
1232 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
1233 OffIterator
endOff()
const {
return OffIterator(mBitSize,
this); }
1234 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
1235 DenseIterator
endDense()
const {
return DenseIterator(mBitSize,
this); }
1238 if (mBitSize != B.
mBitSize)
return false;
1239 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return false;
1244 if (mBitSize != B.
mBitSize)
return true;
1245 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return true;
1254 assert(mIntSize == other.
mIntSize);
1256 mBits[i] &= other.
mBits[i];
1258 for (
Index32 i = other.
mIntSize; i < mIntSize; ++i) mBits[i] = 0x00000000;
1262 assert(mIntSize == other.
mIntSize);
1264 mBits[i] |= other.
mBits[i];
1269 assert(mIntSize == other.
mIntSize);
1271 mBits[i] ^= other.
mBits[i];
1287 return static_cast<Index32>(mIntSize*
sizeof(
Index32) +
sizeof(*
this));
1301 assert( (i>>5) < mIntSize);
1302 mBits[i>>5] |= 1<<(i&31);
1307 assert( (i>>5) < mIntSize);
1308 mBits[i>>5] &= ~(1<<(i&31));
1311 void set(
Index32 i,
bool On) { On ? this->setOn(i) : this->setOff(i); }
1315 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0xFFFFFFFF;
1319 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1323 assert( (i>>5) < mIntSize);
1324 mBits[i>>5] ^= 1<<(i&31);
1328 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=~mBits[i];
1336 assert( (i>>5) < mIntSize);
1337 return ( mBits[i >> 5] & (1<<(i&31)) );
1341 assert( (i>>5) < mIntSize);
1342 return ( ~mBits[i >> 5] & (1<<(i&31)) );
1346 if (!mBits)
return false;
1347 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0xFFFFFFFF)
return false;
1352 if (!mBits)
return true;
1353 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0)
return false;
1360 while(!mBits[i])
if (++i == mIntSize)
return mBitSize;
1367 while(!(~mBits[i]))
if (++i == mIntSize)
return mBitSize;
1371 void save(std::ostream& os)
const {
1373 os.write((
const char *)mBits,mIntSize*
sizeof(
Index32));
1377 is.read((
char *)mBits,mIntSize*
sizeof(
Index32));
1381 os <<
"RootNodeMask: Bit-size="<<mBitSize<<
" Int-size="<<mIntSize<<std::endl;
1385 const Index32 n=(mBitSize>max_out?max_out:mBitSize);
1386 for (
Index32 i=0; i < n; ++i) {
1391 os << this->isOn(i);
1393 os <<
"|" << std::endl;
1397 this->printInfo(os);
1398 this->printBits(os,max_out);
1403 Index32 n = start >> 5, m = start & 31;
1404 if (n>=mIntSize)
return mBitSize;
1406 if (b & (1<<m))
return start;
1407 b &= 0xFFFFFFFF << m;
1408 while(!b && ++n<mIntSize) b = mBits[n];
1414 Index32 n = start >> 5, m = start & 31;
1415 if (n>=mIntSize)
return mBitSize;
1417 if (b & (1<<m))
return start;
1419 while(!b && ++n<mIntSize) b = ~mBits[n];
1433 #endif // OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:637
OffIterator beginOff() const
Definition: NodeMasks.h:351
void increment(Index n)
Definition: NodeMasks.h:251
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:934
bool next()
Definition: NodeMasks.h:1191
DenseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1210
void increment()
Definition: NodeMasks.h:214
OnIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1154
bool operator!=(const BaseIterator &iter) const
Definition: NodeMasks.h:1124
OnMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:213
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:717
void setOn()
Definition: NodeMasks.h:1313
OnIterator beginOn() const
Definition: NodeMasks.h:875
OffMaskIterator< NodeMask > OffIterator
Definition: NodeMasks.h:648
Index32 FindLowestOn(Index64 v)
Return the least significant on bit of the given 64-bit value.
Definition: NodeMasks.h:133
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:710
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:983
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:993
Definition: NodeMasks.h:1068
void increment()
Definition: NodeMasks.h:1155
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:549
NodeMask operator!() const
Definition: NodeMasks.h:715
OnIterator endOn() const
Definition: NodeMasks.h:1231
OffMaskIterator< NodeMask > OffIterator
Definition: NodeMasks.h:872
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:505
bool isOff(Index32 i) const
Definition: NodeMasks.h:1339
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:759
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1047
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:499
void save(std::ostream &os) const
Definition: NodeMasks.h:804
NodeMask operator!() const
Definition: NodeMasks.h:939
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:417
void toggle()
Definition: NodeMasks.h:1326
OnMaskIterator< NodeMask > OnIterator
Definition: NodeMasks.h:345
void setOn(Index32 i)
Definition: NodeMasks.h:1299
bool isOn(Index32 i) const
Definition: NodeMasks.h:1334
OnIterator beginOn() const
Definition: NodeMasks.h:651
void increment(Index n)
Definition: NodeMasks.h:1216
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:865
OffIterator beginOff() const
Definition: NodeMasks.h:1232
bool test() const
Definition: NodeMasks.h:194
DenseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:276
Index getIntSize() const
Definition: NodeMasks.h:1098
Index32 mBitSize
Definition: NodeMasks.h:1071
void setOff()
Set all bits off.
Definition: NodeMasks.h:474
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:720
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:641
OnIterator beginOn() const
Definition: NodeMasks.h:349
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:975
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:826
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:950
void load(std::istream &is)
Definition: NodeMasks.h:566
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:514
DenseIterator beginDense() const
Definition: NodeMasks.h:1234
Index32 FindHighestOn(Index32 v)
Return the most significant on bit of the given 32-bit value.
Definition: NodeMasks.h:151
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:493
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:751
OffIterator endOff() const
Definition: NodeMasks.h:352
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:726
OffIterator & operator++()
Definition: NodeMasks.h:1196
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1380
void increment(Index n)
Definition: NodeMasks.h:220
Index32 mPos
Definition: NodeMasks.h:1114
Index64 Word
Definition: NodeMasks.h:853
void setFirstOn()
Definition: NodeMasks.h:1330
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:440
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:944
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:973
void load(std::istream &is)
Definition: NodeMasks.h:808
bool test() const
Definition: NodeMasks.h:1137
NodeMask & operator=(const NodeMask &other)
Assignment operator.
Definition: NodeMasks.h:337
Base class for the bit mask iterators.
Definition: NodeMasks.h:174
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:749
bool next()
Definition: NodeMasks.h:221
const RootNodeMask & operator|=(const RootNodeMask &other)
Definition: NodeMasks.h:1261
bool next()
Definition: NodeMasks.h:284
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:731
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:491
RootNodeMask(const RootNodeMask &B)
Definition: NodeMasks.h:1081
void load(std::istream &is)
Definition: NodeMasks.h:1026
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:425
Index32 * mBits
Definition: NodeMasks.h:1072
Index32 countOff() const
Definition: NodeMasks.h:1297
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:587
const RootNodeMask * mParent
Definition: NodeMasks.h:1116
OffIterator endOff() const
Definition: NodeMasks.h:1233
Index32 mIntSize
Definition: NodeMasks.h:1071
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:447
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:497
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:955
bool next()
Definition: NodeMasks.h:1219
Index32 mBitSize
Definition: NodeMasks.h:1115
Index32 pos() const
Definition: NodeMasks.h:193
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:724
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1412
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:593
Index32 CountOff(Index64 v)
Return the number of off bits in the given 64-bit value.
Definition: NodeMasks.h:101
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:977
Index32 Index
Definition: Types.h:58
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:480
Index32 countOn() const
Definition: NodeMasks.h:1290
Index32 pos() const
Definition: NodeMasks.h:1135
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:523
void increment(Index n)
Definition: NodeMasks.h:283
bool operator==(const BaseIterator &iter) const
Definition: NodeMasks.h:1123
Index32 findFirstOn() const
Definition: NodeMasks.h:1357
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:575
uint64_t Index64
Definition: Types.h:57
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:991
void increment(Index n)
Definition: NodeMasks.h:1160
bool operator*() const
Definition: NodeMasks.h:1223
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:605
bool operator<(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:158
OffIterator endOff() const
Definition: NodeMasks.h:654
const RootNodeMask & operator^=(const RootNodeMask &other)
Definition: NodeMasks.h:1268
void save(std::ostream &os) const
Definition: NodeMasks.h:1371
#define OPENVDB_VERSION_NAME
Definition: version.h:43
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:948
OnMaskIterator< NodeMask > OnIterator
Definition: NodeMasks.h:647
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:753
OffMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:244
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:639
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:704
RootNodeMask operator!() const
Definition: NodeMasks.h:1252
Index32 mPos
Definition: NodeMasks.h:177
Index32 findFirstOn() const
Definition: NodeMasks.h:531
OnMaskIterator< NodeMask > OnIterator
Definition: NodeMasks.h:871
bool isOff() const
Definition: NodeMasks.h:1351
BaseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:181
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:718
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:863
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:928
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:767
bool next()
Definition: NodeMasks.h:1163
void load(std::istream &is)
Definition: NodeMasks.h:1375
OffIterator endOff() const
Definition: NodeMasks.h:878
OnIterator endOn() const
Definition: NodeMasks.h:350
Index32 getMemUsage() const
Definition: NodeMasks.h:1286
OffMaskIterator< NodeMask > OffIterator
Definition: NodeMasks.h:346
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:570
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:304
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:757
NodeMask operator!() const
Definition: NodeMasks.h:432
void increment()
Definition: NodeMasks.h:277
void increment()
Definition: NodeMasks.h:1211
Definition: Exceptions.h:39
Index32 offset() const
Definition: NodeMasks.h:192
uint32_t Index32
Definition: Types.h:56
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:942
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:981
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:409
bool operator!=(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:186
Index64 Word
Definition: NodeMasks.h:313
OnMaskIterator()
Definition: NodeMasks.h:212
void setOn()
Set all bits on.
Definition: NodeMasks.h:964
void increment()
Definition: NodeMasks.h:1183
Byte Word
Definition: NodeMasks.h:629
Index32 CountOn(Index64 v)
Return the number of on bits in the given 64-bit value.
Definition: NodeMasks.h:92
BaseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1119
void setOff()
Set all bits off.
Definition: NodeMasks.h:742
WordT & getWord(Index n)
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:1016
BaseMaskIterator()
Definition: NodeMasks.h:180
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:814
void setOn()
Set all bits on.
Definition: NodeMasks.h:740
OffIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1182
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:722
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:434
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:438
BaseIterator()
Definition: NodeMasks.h:1118
Definition: NodeMasks.h:267
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:329
~NodeMask()
Destructor.
Definition: NodeMasks.h:643
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:946
DenseIterator endDense() const
Definition: NodeMasks.h:1235
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:989
OffMaskIterator()
Definition: NodeMasks.h:243
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:1010
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:449
void init(Index32 bit_size)
Definition: NodeMasks.h:1088
DenseMaskIterator< NodeMask > DenseIterator
Definition: NodeMasks.h:347
bool isOn() const
Definition: NodeMasks.h:1345
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:765
void setOff()
Set all bits off.
Definition: NodeMasks.h:966
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1401
Index32 findFirstOff() const
Definition: NodeMasks.h:1364
BaseMaskIterator & operator=(const BaseMaskIterator &iter)
Definition: NodeMasks.h:188
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1032
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:495
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:698
DenseIterator endDense() const
Definition: NodeMasks.h:656
void save(std::ostream &os) const
Definition: NodeMasks.h:562
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:485
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:450
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:773
~NodeMask()
Destructor.
Definition: NodeMasks.h:335
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:755
DenseIterator beginDense() const
Definition: NodeMasks.h:353
OnIterator()
Definition: NodeMasks.h:1153
~NodeMask()
Destructor.
Definition: NodeMasks.h:867
OffIterator beginOff() const
Definition: NodeMasks.h:877
BaseIterator & operator=(const BaseIterator &iter)
Definition: NodeMasks.h:1126
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1054
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:997
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:331
void setFirstOff()
Definition: NodeMasks.h:1332
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:968
void increment(Index n)
Definition: NodeMasks.h:1188
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1396
DenseMaskIterator & operator++()
Definition: NodeMasks.h:290
Index32 findFirstOn() const
Definition: NodeMasks.h:778
Definition: NodeMasks.h:1111
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:454
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:744
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:922
DenseIterator endDense() const
Definition: NodeMasks.h:880
RootNodeMask & operator=(const RootNodeMask &B)
Definition: NodeMasks.h:1100
Index32 findFirstOn() const
Definition: NodeMasks.h:1001
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:458
bool operator*() const
Definition: NodeMasks.h:1167
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:979
OnMaskIterator & operator++()
Definition: NodeMasks.h:227
DenseIterator beginDense() const
Definition: NodeMasks.h:879
bool operator*() const
Definition: NodeMasks.h:226
void setOff(Index32 i)
Definition: NodeMasks.h:1305
unsigned char Byte
Definition: Types.h:63
OffIterator beginOff() const
Definition: NodeMasks.h:653
void setLastOn()
Definition: NodeMasks.h:1331
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:833
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:810
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1384
DenseIterator()
Definition: NodeMasks.h:1209
DenseMaskIterator< NodeMask > DenseIterator
Definition: NodeMasks.h:649
WordT & getWord(Index n)
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:555
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:333
Definition: NodeMasks.h:205
Definition: NodeMasks.h:236
void toggle(Index32 i)
Definition: NodeMasks.h:1321
DenseMaskIterator< NodeMask > DenseIterator
Definition: NodeMasks.h:873
Index32 findFirstOff() const
Definition: NodeMasks.h:1002
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
void setLastOff()
Definition: NodeMasks.h:1333
RootNodeMask(Index32 bit_size)
Definition: NodeMasks.h:1076
Index getBitSize() const
Definition: NodeMasks.h:1096
OnIterator endOn() const
Definition: NodeMasks.h:652
DenseIterator beginDense() const
Definition: NodeMasks.h:655
bool operator*() const
Definition: NodeMasks.h:257
void setOn()
Set all bits on.
Definition: NodeMasks.h:468
DenseMaskIterator()
Definition: NodeMasks.h:275
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:820
bool operator*() const
Definition: NodeMasks.h:289
Index32 offset() const
Definition: NodeMasks.h:1133
OffMaskIterator & operator++()
Definition: NodeMasks.h:258
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1028
OnIterator endOn() const
Definition: NodeMasks.h:876
bool operator==(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:185
OnIterator beginOn() const
Definition: NodeMasks.h:1230
Index32 findFirstOff() const
Definition: NodeMasks.h:538
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1041
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:507
RootNodeMask()
Definition: NodeMasks.h:1075
RootNodeMask operator^(const RootNodeMask &other) const
Definition: NodeMasks.h:1281
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:435
Index32 memUsage() const
Definition: NodeMasks.h:1423
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:861
const NodeMask * mParent
Definition: NodeMasks.h:178
Index32 findFirstOff() const
Definition: NodeMasks.h:779
OffIterator()
Definition: NodeMasks.h:1181
DenseIterator & operator++()
Definition: NodeMasks.h:1224
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:941
bool next()
Definition: NodeMasks.h:252
OnIterator & operator++()
Definition: NodeMasks.h:1168
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:769
DenseIterator endDense() const
Definition: NodeMasks.h:354
void increment()
Definition: NodeMasks.h:245
void setOff()
Definition: NodeMasks.h:1317
bool operator*() const
Definition: NodeMasks.h:1195
~RootNodeMask()
Definition: NodeMasks.h:1086
RootNodeMask operator|(const RootNodeMask &other) const
Definition: NodeMasks.h:1278
void save(std::ostream &os) const
Definition: NodeMasks.h:1022