8 #ifndef OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED 9 #define OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED 30 #if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER) 32 #elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__)) 33 return __builtin_popcount(v);
36 static const Byte numBits[256] = {
37 #define COUNTONB2(n) n, n+1, n+1, n+2 38 #define COUNTONB4(n) COUNTONB2(n), COUNTONB2(n+1), COUNTONB2(n+1), COUNTONB2(n+2) 39 #define COUNTONB6(n) COUNTONB4(n), COUNTONB4(n+1), COUNTONB4(n+1), COUNTONB4(n+2) 56 v = v - ((v >> 1) & 0x55555555U);
57 v = (v & 0x33333333U) + ((v >> 2) & 0x33333333U);
58 return (((v + (v >> 4)) & 0xF0F0F0FU) * 0x1010101U) >> 24;
68 #if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER) && defined(_M_X64) 70 #elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__)) 71 v = __builtin_popcountll(v);
74 v = v - ((v >> 1) & UINT64_C(0x5555555555555555));
75 v = (v & UINT64_C(0x3333333333333333)) + ((v >> 2) & UINT64_C(0x3333333333333333));
76 v = (((v + (v >> 4)) & UINT64_C(0xF0F0F0F0F0F0F0F)) * UINT64_C(0x101010101010101)) >> 56;
89 #if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER) 91 _BitScanForward(&index, static_cast<Index32>(v));
92 return static_cast<Index32>(index);
93 #elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__)) 94 return __builtin_ctz(v);
97 static const Byte DeBruijn[8] = {0, 1, 6, 2, 7, 5, 4, 3};
98 return DeBruijn[
Byte((v & -v) * 0x1DU) >> 5];
108 static const Byte DeBruijn[32] = {
109 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
110 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
112 return DeBruijn[
Index32((v & -v) * 0x077CB531U) >> 27];
120 #if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER) 122 _BitScanForward64(&index, v);
123 return static_cast<Index32>(index);
124 #elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__)) 125 return static_cast<Index32>(__builtin_ctzll(v));
128 static const Byte DeBruijn[64] = {
129 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
130 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
131 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
132 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12,
134 return DeBruijn[
Index64((v & -v) * UINT64_C(0x022FDD63CC95386D)) >> 58];
142 static const Byte DeBruijn[32] = {
143 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
144 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
151 return DeBruijn[
Index32(v * 0x07C4ACDDU) >> 27];
159 template<
typename NodeMask>
171 assert((parent ==
nullptr && pos == 0) || (parent !=
nullptr && pos <= NodeMask::SIZE));
178 mPos = iter.
mPos; mParent = iter.
mParent;
return *
this;
182 bool test()
const { assert(mPos <= NodeMask::SIZE);
return (mPos != NodeMask::SIZE); }
183 operator bool()
const {
return this->test(); }
188 template <
typename NodeMask>
193 using BaseType::mPos;
194 using BaseType::mParent;
200 assert(mParent !=
nullptr);
201 mPos = mParent->findNextOn(mPos+1);
202 assert(mPos <= NodeMask::SIZE);
219 template <
typename NodeMask>
224 using BaseType::mPos;
225 using BaseType::mParent;
231 assert(mParent !=
nullptr);
232 mPos=mParent->findNextOff(mPos+1);
233 assert(mPos <= NodeMask::SIZE);
250 template <
typename NodeMask>
255 using BaseType::mPos;
256 using BaseType::mParent;
263 assert(mParent !=
nullptr);
265 assert(mPos<= NodeMask::SIZE);
287 template<Index Log2Dim>
291 static_assert(Log2Dim > 2,
"expected NodeMask template specialization, got base template");
309 Word mWords[WORD_COUNT];
324 const Word* w2 = other.mWords;
325 for (
Word* w1 = mWords; n--; ++w1, ++w2) *w1 = *w2;
343 for (
const Word *w1=mWords, *w2=other.mWords; n-- && *w1++ == *w2++;) ;
359 template<
typename WordOp>
363 const Word *w2 = other.mWords;
364 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) op( *w1, *w2);
367 template<
typename WordOp>
371 const Word *w2 = other1.mWords, *w3 = other2.mWords;
372 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2, ++w3) op( *w1, *w2, *w3);
375 template<
typename WordOp>
380 const Word *w2 = other1.mWords, *w3 = other2.mWords, *w4 = other3.mWords;
381 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2, ++w3, ++w4) op( *w1, *w2, *w3, *w4);
388 const Word *w2 = other.mWords;
389 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= *w2;
396 const Word *w2 = other.mWords;
397 for (
Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 |= *w2;
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;
426 Index32 sum = 0, n = WORD_COUNT;
427 for (
const Word* w = mWords; n--; ++w) sum +=
CountOn(*w);
434 assert( (n >> 6) < WORD_COUNT );
435 mWords[n >> 6] |=
Word(1) << (n & 63);
439 assert( (n >> 6) < WORD_COUNT );
440 mWords[n >> 6] &= ~(
Word(1) << (n & 63));
443 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
449 for (
Word* w = mWords; n--; ++w) *w = state;
455 for (
Word* w = mWords; n--; ++w) *w = ~
Word(0);
461 for (
Word* w = mWords; n--; ++w) *w =
Word(0);
465 assert( (n >> 6) < WORD_COUNT );
466 mWords[n >> 6] ^=
Word(1) << (n & 63);
472 for (
Word* w = mWords; n--; ++w) *w = ~*w;
485 assert( (n >> 6) < WORD_COUNT );
486 return 0 != (mWords[n >> 6] & (
Word(1) << (n & 63)));
494 for (
const Word *w = mWords; n-- && *w++ == ~
Word(0);) ;
501 for (
const Word *w = mWords; n-- && *w++ ==
Word(0);) ;
509 isOn = (mWords[0] == ~
Word(0));
510 if ( !isOn && mWords[0] !=
Word(0))
return false;
511 const Word *w = mWords + 1, *n = mWords + WORD_COUNT;
512 while( w<n && *w == mWords[0] ) ++w;
518 const Word* w = mWords;
519 for (; n<WORD_COUNT && !*w; ++w, ++n) ;
520 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(*w);
525 const Word* w = mWords;
526 for (; n<WORD_COUNT && !~*w; ++w, ++n) ;
527 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(~*w);
531 template<
typename WordT>
535 assert(n*8*
sizeof(WordT) < SIZE);
536 return reinterpret_cast<const WordT*
>(mWords)[n];
538 template<
typename WordT>
541 assert(n*8*
sizeof(WordT) < SIZE);
542 return reinterpret_cast<WordT*
>(mWords)[n];
546 void save(std::ostream& os)
const 548 os.write(reinterpret_cast<const char*>(mWords), this->memUsage());
550 void load(std::istream& is) { is.read(reinterpret_cast<char*>(mWords), this->memUsage()); }
551 void seek(std::istream& is)
const { is.seekg(this->memUsage(), std::ios_base::cur); }
555 os <<
"NodeMask: Dim=" << DIM <<
" Log2Dim=" << Log2Dim
556 <<
" Bit count=" << SIZE <<
" word count=" << WORD_COUNT << std::endl;
560 const Index32 n=(SIZE>max_out ? max_out : SIZE);
561 for (
Index32 i=0; i < n; ++i) {
568 os <<
"|" << std::endl;
573 this->printBits(os, max_out);
579 if (n >= WORD_COUNT)
return SIZE;
582 if (b & (
Word(1) << m))
return start;
584 while(!b && ++n<WORD_COUNT) b = mWords[n];
591 if (n >= WORD_COUNT)
return SIZE;
594 if (b & (
Word(1) << m))
return start;
596 while(!b && ++n<WORD_COUNT) b = ~mWords[n];
628 void operator = (
const NodeMask &other) { mByte = other.mByte; }
655 template<
typename WordOp>
658 op(mByte, other.mByte);
661 template<
typename WordOp>
664 op(mByte, other1.mByte, other2.mByte);
667 template<
typename WordOp>
671 op(mByte, other1.mByte, other2.mByte, other3.mByte);
677 mByte &= other.mByte;
683 mByte |= other.mByte;
689 mByte &=
static_cast<Byte>(~other.mByte);
695 mByte ^= other.mByte;
711 mByte =
static_cast<Byte>(mByte | 0x01U << (n & 7));
716 mByte =
static_cast<Byte>(mByte & ~(0x01U << (n & 7)));
719 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
721 void set(
bool on) { mByte = on ? 0xFFU : 0x00U; }
729 mByte =
static_cast<Byte>(mByte ^ 0x01U << (n & 7));
745 return mByte & (0x01U << (n & 7));
750 bool isOn()
const {
return mByte == 0xFFU; }
752 bool isOff()
const {
return mByte == 0; }
759 return isOn || this->isOff();
764 const Byte b =
static_cast<Byte>(~mByte);
787 void save(std::ostream& os)
const { os.write(reinterpret_cast<const char*>(&mByte), 1); }
788 void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mByte), 1); }
789 void seek(std::istream& is)
const { is.seekg(1, std::ios_base::cur); }
793 os <<
"NodeMask: Dim=2, Log2Dim=1, Bit count=8, Word count=1"<<std::endl;
798 for (
Index32 i=0; i < 8; ++i) os << this->isOn(i);
799 os <<
"||" << std::endl;
809 if (start>=8)
return 8;
810 const Byte b =
static_cast<Byte>(mByte & (0xFFU << start));
816 if (start>=8)
return 8;
817 const Byte b =
static_cast<Byte>(~mByte & (0xFFU << start));
844 NodeMask(
bool on) : mWord(on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00)) {}
850 void operator = (
const NodeMask &other) { mWord = other.mWord; }
877 template<
typename WordOp>
880 op(mWord, other.mWord);
883 template<
typename WordOp>
886 op(mWord, other1.mWord, other2.mWord);
889 template<
typename WordOp>
893 op(mWord, other1.mWord, other2.mWord, other3.mWord);
899 mWord &= other.mWord;
905 mWord |= other.mWord;
911 mWord &= ~other.mWord;
917 mWord ^= other.mWord;
933 mWord |= UINT64_C(0x01) << (n & 63);
938 mWord &= ~(UINT64_C(0x01) << (n & 63));
941 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
943 void set(
bool on) { mWord = on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00); }
945 void setOn() { mWord = UINT64_C(0xFFFFFFFFFFFFFFFF); }
947 void setOff() { mWord = UINT64_C(0x00); }
951 mWord ^= UINT64_C(0x01) << (n & 63);
967 return 0 != (mWord & (UINT64_C(0x01) << (n & 63)));
972 bool isOn()
const {
return mWord == UINT64_C(0xFFFFFFFFFFFFFFFF); }
974 bool isOff()
const {
return mWord == 0; }
979 { isOn = this->isOn();
980 return isOn || this->isOff();
985 const Word w = ~mWord;
989 template<
typename WordT>
993 assert(n*8*
sizeof(WordT) < SIZE);
994 return reinterpret_cast<const WordT*
>(&mWord)[n];
996 template<
typename WordT>
999 assert(n*8*
sizeof(WordT) < SIZE);
1000 return reinterpret_cast<WordT*
>(mWord)[n];
1003 void save(std::ostream& os)
const { os.write(reinterpret_cast<const char*>(&mWord), 8); }
1004 void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mWord), 8); }
1005 void seek(std::istream& is)
const { is.seekg(8, std::ios_base::cur); }
1009 os <<
"NodeMask: Dim=4, Log2Dim=2, Bit count=64, Word count=1"<<std::endl;
1014 for (
Index32 i=0; i < 64; ++i) {
1015 if ( !(i%8) ) os <<
"|";
1016 os << this->isOn(i);
1018 os <<
"||" << std::endl;
1022 this->printInfo(os);
1023 this->printBits(os);
1028 if (start>=64)
return 64;
1029 const Word w = mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1035 if (start>=64)
return 64;
1036 const Word w = ~mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1056 mBitSize(bit_size), mIntSize(((bit_size-1)>>5)+1), mBits(new
Index32[mIntSize])
1058 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1061 mBitSize(B.mBitSize), mIntSize(B.mIntSize), mBits(new
Index32[mIntSize])
1063 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=B.
mBits[i];
1068 mBitSize = bit_size;
1069 mIntSize =((bit_size-1)>>5)+1;
1071 mBits =
new Index32[mIntSize];
1072 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1084 mBits =
new Index32[mIntSize];
1086 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=B.
mBits[i];
1100 mPos(pos), mBitSize(parent->getBitSize()), mParent(parent) { assert(pos <= mBitSize); }
1116 assert(mPos <= mBitSize);
1117 return (mPos != mBitSize);
1120 operator bool()
const {
return this->test();}
1127 using BaseIterator::mPos;
1128 using BaseIterator::mBitSize;
1129 using BaseIterator::mParent;
1134 assert(mParent !=
nullptr);
1135 mPos=mParent->findNextOn(mPos+1);
1136 assert(mPos <= mBitSize);
1139 for (
Index i=0; i<n && this->next(); ++i) {}
1143 return this->test();
1155 using BaseIterator::mPos;
1156 using BaseIterator::mBitSize;
1157 using BaseIterator::mParent;
1162 assert(mParent !=
nullptr);
1163 mPos=mParent->findNextOff(mPos+1);
1164 assert(mPos <= mBitSize);
1167 for (
Index i=0; i<n && this->next(); ++i) {}
1171 return this->test();
1183 using BaseIterator::mPos;
1184 using BaseIterator::mBitSize;
1185 using BaseIterator::mParent;
1190 assert(mParent !=
nullptr);
1192 assert(mPos<= mBitSize);
1195 for (
Index i=0; i<n && this->next(); ++i) {}
1199 return this->test();
1216 if (mBitSize != B.
mBitSize)
return false;
1217 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return false;
1222 if (mBitSize != B.
mBitSize)
return true;
1223 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return true;
1232 assert(mIntSize == other.
mIntSize);
1234 mBits[i] &= other.
mBits[i];
1236 for (
Index32 i = other.
mIntSize; i < mIntSize; ++i) mBits[i] = 0x00000000;
1240 assert(mIntSize == other.
mIntSize);
1242 mBits[i] |= other.
mBits[i];
1247 assert(mIntSize == other.
mIntSize);
1249 mBits[i] ^= other.
mBits[i];
1265 return static_cast<Index32>(mIntSize*
sizeof(
Index32) +
sizeof(*
this));
1279 assert( (i>>5) < mIntSize);
1280 mBits[i>>5] |= 1<<(i&31);
1285 assert( (i>>5) < mIntSize);
1286 mBits[i>>5] &= ~(1<<(i&31));
1289 void set(
Index32 i,
bool On) { On ? this->setOn(i) : this->setOff(i); }
1293 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0xFFFFFFFF;
1297 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1301 assert( (i>>5) < mIntSize);
1302 mBits[i>>5] ^= 1<<(i&31);
1306 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=~mBits[i];
1314 assert( (i>>5) < mIntSize);
1315 return ( mBits[i >> 5] & (1<<(i&31)) );
1319 assert( (i>>5) < mIntSize);
1320 return ( ~mBits[i >> 5] & (1<<(i&31)) );
1324 if (!mBits)
return false;
1325 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0xFFFFFFFF)
return false;
1330 if (!mBits)
return true;
1331 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0)
return false;
1338 while(!mBits[i])
if (++i == mIntSize)
return mBitSize;
1345 while(!(~mBits[i]))
if (++i == mIntSize)
return mBitSize;
1349 void save(std::ostream& os)
const {
1351 os.write(reinterpret_cast<const char*>(mBits), mIntSize *
sizeof(
Index32));
1355 is.read(reinterpret_cast<char*>(mBits), mIntSize *
sizeof(
Index32));
1357 void seek(std::istream& is)
const {
1359 is.seekg(mIntSize *
sizeof(
Index32), std::ios_base::cur);
1363 os <<
"RootNodeMask: Bit-size="<<mBitSize<<
" Int-size="<<mIntSize<<std::endl;
1367 const Index32 n=(mBitSize>max_out?max_out:mBitSize);
1368 for (
Index32 i=0; i < n; ++i) {
1373 os << this->isOn(i);
1375 os <<
"|" << std::endl;
1379 this->printInfo(os);
1380 this->printBits(os,max_out);
1385 Index32 n = start >> 5, m = start & 31;
1386 if (n>=mIntSize)
return mBitSize;
1388 if (b & (1<<m))
return start;
1389 b &= 0xFFFFFFFF << m;
1390 while(!b && ++n<mIntSize) b = mBits[n];
1396 Index32 n = start >> 5, m = start & 31;
1397 if (n>=mIntSize)
return mBitSize;
1399 if (b & (1<<m))
return start;
1401 while(!b && ++n<mIntSize) b = ~mBits[n];
1415 #endif // OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED void seek(std::istream &is) const
Definition: NodeMasks.h:1005
OnIterator endOn() const
Definition: NodeMasks.h:334
void increment(Index n)
Definition: NodeMasks.h:267
Definition: NodeMasks.h:1124
OnIterator beginOn() const
Definition: NodeMasks.h:333
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:991
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:477
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:936
bool next()
Definition: NodeMasks.h:268
DenseIterator beginDense() const
Definition: NodeMasks.h:638
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:315
bool operator==(const BaseIterator &iter) const
Definition: NodeMasks.h:1101
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:903
Index32 offset() const
Definition: NodeMasks.h:1111
RootNodeMask()
Definition: NodeMasks.h:1054
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:489
Index32 mBitSize
Definition: NodeMasks.h:1094
RootNodeMask operator|(const RootNodeMask &other) const
Definition: NodeMasks.h:1256
void setLastOff()
Definition: NodeMasks.h:1311
void load(std::istream &is)
Definition: NodeMasks.h:788
Byte Word
Definition: NodeMasks.h:612
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:929
OffIterator endOff() const
Definition: NodeMasks.h:859
OnIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1132
Index32 findFirstOn() const
Definition: NodeMasks.h:761
Index32 CountOff(Index64 v)
Return the number of off bits in the given 64-bit value.
Definition: NodeMasks.h:82
void setFirstOn()
Definition: NodeMasks.h:1308
RootNodeMask operator!() const
Definition: NodeMasks.h:1230
bool operator*() const
Definition: NodeMasks.h:1173
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:960
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:479
OnIterator beginOn() const
Definition: NodeMasks.h:856
~NodeMask()
Destructor.
Definition: NodeMasks.h:319
DenseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1188
bool next()
Definition: NodeMasks.h:205
OnMaskIterator()
Definition: NodeMasks.h:196
void increment()
Definition: NodeMasks.h:1161
uint32_t Index32
Definition: Types.h:29
Definition: NodeMasks.h:1180
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:553
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:469
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1007
OffMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:228
WordT & getWord(Index n)
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:539
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:703
DenseIterator beginDense() const
Definition: NodeMasks.h:860
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:479
void load(std::istream &is)
Definition: NodeMasks.h:1353
bool isOff() const
Definition: NodeMasks.h:1329
void setOn()
Definition: NodeMasks.h:1291
RootNodeMask(Index32 bit_size)
Definition: NodeMasks.h:1055
Definition: NodeMasks.h:251
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:687
RootNodeMask operator^(const RootNodeMask &other) const
Definition: NodeMasks.h:1259
void setOn()
Set all bits on.
Definition: NodeMasks.h:945
void increment(Index n)
Definition: NodeMasks.h:1166
Index32 mBitSize
Definition: NodeMasks.h:1050
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:475
bool operator*() const
Definition: NodeMasks.h:241
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:931
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1383
void setOn()
Set all bits on.
Definition: NodeMasks.h:452
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:801
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1362
Index32 mIntSize
Definition: NodeMasks.h:1050
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1033
Definition: NodeMasks.h:1152
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1394
Index32 countOff() const
Definition: NodeMasks.h:1275
const RootNodeMask & operator|=(const RootNodeMask &other)
Definition: NodeMasks.h:1239
void seek(std::istream &is) const
Definition: NodeMasks.h:1357
bool operator*() const
Definition: NodeMasks.h:1201
bool operator*() const
Definition: NodeMasks.h:1145
NodeMask operator!() const
Definition: NodeMasks.h:416
Index32 findFirstOn() const
Definition: NodeMasks.h:1335
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:954
NodeMask operator!() const
Definition: NodeMasks.h:698
DenseIterator beginDense() const
Definition: NodeMasks.h:337
Index32 findFirstOn() const
Definition: NodeMasks.h:982
BaseMaskIterator()
Definition: NodeMasks.h:167
OnIterator endOn() const
Definition: NodeMasks.h:857
Index getBitSize() const
Definition: NodeMasks.h:1075
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:418
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:923
DenseMaskIterator & operator++()
Definition: NodeMasks.h:274
OffIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1160
bool test() const
Definition: NodeMasks.h:182
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:681
OnIterator endOn() const
Definition: NodeMasks.h:1209
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:507
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:483
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:714
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:288
OnIterator endOn() const
Definition: NodeMasks.h:635
OffIterator endOff() const
Definition: NodeMasks.h:637
Index32 FindHighestOn(Index32 v)
Return the most significant on bit of the given 32-bit value.
Definition: NodeMasks.h:140
bool isOn(Index32 i) const
Definition: NodeMasks.h:1312
Index32 memUsage() const
Definition: NodeMasks.h:1405
OffIterator beginOff() const
Definition: NodeMasks.h:858
bool operator!=(const BaseIterator &iter) const
Definition: NodeMasks.h:1102
void setOff(Index32 i)
Definition: NodeMasks.h:1283
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:915
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:978
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:433
void increment()
Definition: NodeMasks.h:1189
void toggle(Index32 i)
Definition: NodeMasks.h:1299
void seek(std::istream &is) const
Definition: NodeMasks.h:789
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:438
bool isOn() const
Definition: NodeMasks.h:1323
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:707
Index32 CountOn(Index64 v)
Return the number of on bits in the given 64-bit value.
Definition: NodeMasks.h:66
Index32 FindLowestOn(Index64 v)
Return the least significant on bit of the given 64-bit value.
Definition: NodeMasks.h:117
DenseMaskIterator()
Definition: NodeMasks.h:259
OffIterator beginOff() const
Definition: NodeMasks.h:636
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1011
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:576
OffIterator & operator++()
Definition: NodeMasks.h:1174
bool isOff(Index32 i) const
Definition: NodeMasks.h:1317
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:422
OffIterator beginOff() const
Definition: NodeMasks.h:335
Index32 findFirstOff() const
Definition: NodeMasks.h:1342
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:927
void setOff()
Set all bits off.
Definition: NodeMasks.h:725
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:570
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1366
void setOn(Index32 i)
Definition: NodeMasks.h:1277
void increment(Index n)
Definition: NodeMasks.h:204
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:846
BaseMaskIterator & operator=(const BaseMaskIterator &iter)
Definition: NodeMasks.h:176
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:313
void increment(Index n)
Definition: NodeMasks.h:1138
WordT & getWord(Index n)
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:997
bool next()
Definition: NodeMasks.h:1169
void init(Index32 bit_size)
Definition: NodeMasks.h:1067
OnMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:197
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:795
bool operator*() const
Definition: NodeMasks.h:210
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:102
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:949
DenseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:260
void save(std::ostream &os) const
Definition: NodeMasks.h:1003
void save(std::ostream &os) const
Definition: NodeMasks.h:1349
void increment(Index n)
Definition: NodeMasks.h:235
void save(std::ostream &os) const
Definition: NodeMasks.h:787
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:409
BaseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:169
~RootNodeMask()
Definition: NodeMasks.h:1065
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:317
void increment()
Definition: NodeMasks.h:229
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1020
void seek(std::istream &is) const
Definition: NodeMasks.h:551
Index32 mPos
Definition: NodeMasks.h:1093
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:393
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:972
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1026
Index32 findFirstOff() const
Definition: NodeMasks.h:983
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:922
const RootNodeMask & operator^=(const RootNodeMask &other)
Definition: NodeMasks.h:1246
Index32 mPos
Definition: NodeMasks.h:163
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:734
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:956
Definition: Exceptions.h:13
Index32 countOn() const
Definition: NodeMasks.h:1268
OffIterator endOff() const
Definition: NodeMasks.h:1211
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:701
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:620
void setOff()
Set all bits off.
Definition: NodeMasks.h:458
void setLastOn()
Definition: NodeMasks.h:1309
DenseIterator endDense() const
Definition: NodeMasks.h:338
Index32 getMemUsage() const
Definition: NodeMasks.h:1264
Base class for the bit mask iterators.
Definition: NodeMasks.h:160
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:491
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:424
DenseIterator & operator++()
Definition: NodeMasks.h:1202
Definition: NodeMasks.h:220
~NodeMask()
Destructor.
Definition: NodeMasks.h:626
Definition: NodeMasks.h:1047
void save(std::ostream &os) const
Definition: NodeMasks.h:546
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:700
void setFirstOff()
Definition: NodeMasks.h:1310
BaseIterator & operator=(const BaseIterator &iter)
Definition: NodeMasks.h:1104
void increment()
Definition: NodeMasks.h:198
Index32 * mBits
Definition: NodeMasks.h:1051
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:791
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:431
bool next()
Definition: NodeMasks.h:1141
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:622
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:964
void increment()
Definition: NodeMasks.h:261
OffMaskIterator()
Definition: NodeMasks.h:227
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:750
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:732
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:705
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:498
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:401
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:693
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:471
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:752
Index32 findFirstOff() const
Definition: NodeMasks.h:762
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:736
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:742
bool next()
Definition: NodeMasks.h:236
OffIterator beginOff() const
Definition: NodeMasks.h:1210
Index32 Index
Definition: Types.h:31
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:738
OffMaskIterator & operator++()
Definition: NodeMasks.h:242
Index64 Word
Definition: NodeMasks.h:297
OnIterator beginOn() const
Definition: NodeMasks.h:1208
bool operator<(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:180
OffIterator()
Definition: NodeMasks.h:1159
~NodeMask()
Destructor.
Definition: NodeMasks.h:848
Index32 offset() const
Definition: NodeMasks.h:180
bool operator==(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:173
OnIterator & operator++()
Definition: NodeMasks.h:1146
OnIterator beginOn() const
Definition: NodeMasks.h:634
BaseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1099
BaseIterator()
Definition: NodeMasks.h:1097
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:814
bool operator!=(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:174
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:970
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:925
const NodeMask * mParent
Definition: NodeMasks.h:164
void setOn()
Set all bits on.
Definition: NodeMasks.h:723
void setOff()
Definition: NodeMasks.h:1295
DenseIterator endDense() const
Definition: NodeMasks.h:861
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:558
NodeMask operator!() const
Definition: NodeMasks.h:920
RootNodeMask & operator=(const RootNodeMask &B)
Definition: NodeMasks.h:1079
uint64_t Index64
Definition: Types.h:30
void increment(Index n)
Definition: NodeMasks.h:1194
void increment()
Definition: NodeMasks.h:1133
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:807
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:974
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:740
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:419
bool operator*() const
Definition: NodeMasks.h:273
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:958
NodeMask & operator=(const NodeMask &other)
Assignment operator.
Definition: NodeMasks.h:321
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
Definition: NodeMasks.h:1090
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:481
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:624
void load(std::istream &is)
Definition: NodeMasks.h:1004
DenseIterator endDense() const
Definition: NodeMasks.h:639
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:962
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:842
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:727
RootNodeMask(const RootNodeMask &B)
Definition: NodeMasks.h:1060
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:909
DenseIterator endDense() const
Definition: NodeMasks.h:1213
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1378
OnMaskIterator & operator++()
Definition: NodeMasks.h:211
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:588
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:844
Index32 findFirstOff() const
Definition: NodeMasks.h:522
void toggle()
Definition: NodeMasks.h:1304
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:748
void load(std::istream &is)
Definition: NodeMasks.h:550
OnIterator()
Definition: NodeMasks.h:1131
Index32 pos() const
Definition: NodeMasks.h:181
OffIterator endOff() const
Definition: NodeMasks.h:336
Index getIntSize() const
Definition: NodeMasks.h:1077
unsigned char Byte
Definition: Types.h:36
DenseIterator()
Definition: NodeMasks.h:1187
Definition: NodeMasks.h:189
Index32 pos() const
Definition: NodeMasks.h:1113
bool test() const
Definition: NodeMasks.h:1115
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:533
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:464
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:709
void setOff()
Set all bits off.
Definition: NodeMasks.h:947
const RootNodeMask * mParent
Definition: NodeMasks.h:1095
Index64 Word
Definition: NodeMasks.h:834
bool next()
Definition: NodeMasks.h:1197
DenseIterator beginDense() const
Definition: NodeMasks.h:1212
Index32 findFirstOn() const
Definition: NodeMasks.h:515
bool isConstant(bool &isOn) const
Definition: NodeMasks.h:756