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);) ;
523 const Word* w = mWords;
524 for (; n<WORD_COUNT && !*w; ++w, ++n) ;
525 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(*w);
530 const Word* w = mWords;
531 for (; n<WORD_COUNT && !~*w; ++w, ++n) ;
532 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(~*w);
536 template<
typename WordT>
540 assert(n*8*
sizeof(WordT) < SIZE);
541 return reinterpret_cast<const WordT*
>(mWords)[n];
543 template<
typename WordT>
546 assert(n*8*
sizeof(WordT) < SIZE);
547 return reinterpret_cast<WordT*
>(mWords)[n];
551 void save(std::ostream& os)
const 553 os.write(reinterpret_cast<const char*>(mWords), this->memUsage());
556 is.read(reinterpret_cast<char*>(mWords), this->memUsage());
561 os <<
"NodeMask: Dim=" << DIM <<
" Log2Dim=" << Log2Dim
562 <<
" Bit count=" << SIZE <<
" word count=" << WORD_COUNT << std::endl;
566 const Index32 n=(SIZE>max_out ? max_out : SIZE);
567 for (
Index32 i=0; i < n; ++i) {
574 os <<
"|" << std::endl;
579 this->printBits(os, max_out);
585 if (n >= WORD_COUNT)
return SIZE;
588 if (b & (Word(1) << m))
return start;
590 while(!b && ++n<WORD_COUNT) b = mWords[n];
597 if (n >= WORD_COUNT)
return SIZE;
600 if (b & (Word(1) << m))
return start;
602 while(!b && ++n<WORD_COUNT) b = ~mWords[n];
634 void operator = (
const NodeMask &other) { mByte = other.mByte; }
640 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
641 OnIterator
endOn()
const {
return OnIterator(SIZE,
this); }
642 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
643 OffIterator
endOff()
const {
return OffIterator(SIZE,
this); }
644 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
645 DenseIterator
endDense()
const {
return DenseIterator(SIZE,
this); }
661 template<
typename WordOp>
664 op(mByte, other.mByte);
667 template<
typename WordOp>
670 op(mByte, other1.mByte, other2.mByte);
673 template<
typename WordOp>
677 op(mByte, other1.mByte, other2.mByte, other3.mByte);
683 mByte &= other.mByte;
689 mByte |= other.mByte;
695 mByte &=
static_cast<Byte>(~other.mByte);
701 mByte ^= other.mByte;
717 mByte = mByte |
static_cast<Byte>(0x01U << (n & 7));
722 mByte = mByte &
static_cast<Byte>(~(0x01U << (n & 7)));
725 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
727 void set(
bool on) { mByte = on ? 0xFFU : 0x00U; }
735 mByte = mByte ^
static_cast<Byte>(0x01U << (n & 7));
751 return mByte & (0x01U << (n & 7));
756 bool isOn()
const {
return mByte == 0xFFU; }
758 bool isOff()
const {
return mByte == 0; }
762 const Byte b =
static_cast<Byte>(~mByte);
785 void save(std::ostream& os)
const 787 os.write(reinterpret_cast<const char*>(&mByte), 1);
789 void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mByte), 1); }
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; }
856 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
857 OnIterator
endOn()
const {
return OnIterator(SIZE,
this); }
858 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
859 OffIterator
endOff()
const {
return OffIterator(SIZE,
this); }
860 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
861 DenseIterator
endDense()
const {
return DenseIterator(SIZE,
this); }
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; }
978 const Word w = ~mWord;
982 template<
typename WordT>
986 assert(n*8*
sizeof(WordT) < SIZE);
987 return reinterpret_cast<const WordT*
>(&mWord)[n];
989 template<
typename WordT>
992 assert(n*8*
sizeof(WordT) < SIZE);
993 return reinterpret_cast<WordT*
>(mWord)[n];
996 void save(std::ostream& os)
const 998 os.write(reinterpret_cast<const char*>(&mWord), 8);
1000 void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mWord), 8); }
1004 os <<
"NodeMask: Dim=4, Log2Dim=2, Bit count=64, Word count=1"<<std::endl;
1009 for (
Index32 i=0; i < 64; ++i) {
1010 if ( !(i%8) ) os <<
"|";
1011 os << this->isOn(i);
1013 os <<
"||" << std::endl;
1017 this->printInfo(os);
1018 this->printBits(os);
1023 if (start>=64)
return 64;
1024 const Word w = mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1030 if (start>=64)
return 64;
1031 const Word w = ~mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1051 mBitSize(bit_size), mIntSize(((bit_size-1)>>5)+1), mBits(new
Index32[mIntSize])
1053 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1056 mBitSize(B.mBitSize), mIntSize(B.mIntSize), mBits(new
Index32[mIntSize])
1058 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=B.
mBits[i];
1063 mBitSize = bit_size;
1064 mIntSize =((bit_size-1)>>5)+1;
1066 mBits =
new Index32[mIntSize];
1067 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1079 mBits =
new Index32[mIntSize];
1081 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=B.
mBits[i];
1094 : mPos(pos), mBitSize(parent->getBitSize()), mParent(parent) {
1095 assert( pos<=mBitSize );
1112 assert(mPos <= mBitSize);
1113 return (mPos != mBitSize);
1116 operator bool()
const {
return this->test();}
1123 using BaseIterator::mPos;
1124 using BaseIterator::mBitSize;
1125 using BaseIterator::mParent;
1130 assert(mParent!=NULL);
1131 mPos=mParent->findNextOn(mPos+1);
1132 assert(mPos <= mBitSize);
1135 for (
Index i=0; i<n && this->next(); ++i) {}
1139 return this->test();
1151 using BaseIterator::mPos;
1152 using BaseIterator::mBitSize;
1153 using BaseIterator::mParent;
1158 assert(mParent!=NULL);
1159 mPos=mParent->findNextOff(mPos+1);
1160 assert(mPos <= mBitSize);
1163 for (
Index i=0; i<n && this->next(); ++i) {}
1167 return this->test();
1179 using BaseIterator::mPos;
1180 using BaseIterator::mBitSize;
1181 using BaseIterator::mParent;
1186 assert(mParent!=NULL);
1188 assert(mPos<= mBitSize);
1191 for (
Index i=0; i<n && this->next(); ++i) {}
1195 return this->test();
1204 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
1205 OnIterator
endOn()
const {
return OnIterator(mBitSize,
this); }
1206 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
1207 OffIterator
endOff()
const {
return OffIterator(mBitSize,
this); }
1208 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
1209 DenseIterator
endDense()
const {
return DenseIterator(mBitSize,
this); }
1212 if (mBitSize != B.
mBitSize)
return false;
1213 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return false;
1218 if (mBitSize != B.
mBitSize)
return true;
1219 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return true;
1228 assert(mIntSize == other.
mIntSize);
1230 mBits[i] &= other.
mBits[i];
1232 for (
Index32 i = other.
mIntSize; i < mIntSize; ++i) mBits[i] = 0x00000000;
1236 assert(mIntSize == other.
mIntSize);
1238 mBits[i] |= other.
mBits[i];
1243 assert(mIntSize == other.
mIntSize);
1245 mBits[i] ^= other.
mBits[i];
1261 return static_cast<Index32>(mIntSize*
sizeof(
Index32) +
sizeof(*
this));
1275 assert( (i>>5) < mIntSize);
1276 mBits[i>>5] |= 1<<(i&31);
1281 assert( (i>>5) < mIntSize);
1282 mBits[i>>5] &= ~(1<<(i&31));
1285 void set(
Index32 i,
bool On) { On ? this->setOn(i) : this->setOff(i); }
1289 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0xFFFFFFFF;
1293 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1297 assert( (i>>5) < mIntSize);
1298 mBits[i>>5] ^= 1<<(i&31);
1302 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=~mBits[i];
1310 assert( (i>>5) < mIntSize);
1311 return ( mBits[i >> 5] & (1<<(i&31)) );
1315 assert( (i>>5) < mIntSize);
1316 return ( ~mBits[i >> 5] & (1<<(i&31)) );
1320 if (!mBits)
return false;
1321 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0xFFFFFFFF)
return false;
1326 if (!mBits)
return true;
1327 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0)
return false;
1334 while(!mBits[i])
if (++i == mIntSize)
return mBitSize;
1341 while(!(~mBits[i]))
if (++i == mIntSize)
return mBitSize;
1345 void save(std::ostream& os)
const {
1347 os.write((
const char *)mBits,mIntSize*
sizeof(
Index32));
1351 is.read((
char *)mBits,mIntSize*
sizeof(
Index32));
1355 os <<
"RootNodeMask: Bit-size="<<mBitSize<<
" Int-size="<<mIntSize<<std::endl;
1359 const Index32 n=(mBitSize>max_out?max_out:mBitSize);
1360 for (
Index32 i=0; i < n; ++i) {
1365 os << this->isOn(i);
1367 os <<
"|" << std::endl;
1371 this->printInfo(os);
1372 this->printBits(os,max_out);
1377 Index32 n = start >> 5, m = start & 31;
1378 if (n>=mIntSize)
return mBitSize;
1380 if (b & (1<<m))
return start;
1381 b &= 0xFFFFFFFF << m;
1382 while(!b && ++n<mIntSize) b = mBits[n];
1388 Index32 n = start >> 5, m = start & 31;
1389 if (n>=mIntSize)
return mBitSize;
1391 if (b & (1<<m))
return start;
1393 while(!b && ++n<mIntSize) b = ~mBits[n];
1407 #endif // OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:507
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:915
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:626
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:756
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:447
DenseIterator endDense() const
Definition: NodeMasks.h:645
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:417
Definition: NodeMasks.h:1042
void load(std::istream &is)
Definition: NodeMasks.h:555
Index32 Index
Definition: Types.h:58
OnIterator & operator++()
Definition: NodeMasks.h:1142
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:923
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:699
DenseIterator endDense() const
Definition: NodeMasks.h:861
OffMaskIterator< NodeMask > OffIterator
Definition: NodeMasks.h:637
bool operator!=(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:186
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:707
void load(std::istream &is)
Definition: NodeMasks.h:1349
OffMaskIterator< NodeMask > OffIterator
Definition: NodeMasks.h:853
Index32 countOn() const
Definition: NodeMasks.h:1264
unsigned char Byte
Definition: Types.h:63
Index32 CountOff(Index64 v)
Return the number of off bits in the given 64-bit value.
Definition: NodeMasks.h:101
OnIterator endOn() const
Definition: NodeMasks.h:1205
void increment()
Definition: NodeMasks.h:1185
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:582
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:972
bool next()
Definition: NodeMasks.h:252
Index32 findFirstOff() const
Definition: NodeMasks.h:527
void increment()
Definition: NodeMasks.h:214
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:493
Index32 findFirstOn() const
Definition: NodeMasks.h:1331
OnMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:213
Index32 pos() const
Definition: NodeMasks.h:193
Index32 FindHighestOn(Index32 v)
Return the most significant on bit of the given 32-bit value.
Definition: NodeMasks.h:151
void increment(Index n)
Definition: NodeMasks.h:1190
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:846
OffIterator endOff() const
Definition: NodeMasks.h:352
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:450
bool operator*() const
Definition: NodeMasks.h:1141
void increment()
Definition: NodeMasks.h:1129
RootNodeMask operator^(const RootNodeMask &other) const
Definition: NodeMasks.h:1255
OffIterator & operator++()
Definition: NodeMasks.h:1170
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:630
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:709
void init(Index32 bit_size)
Definition: NodeMasks.h:1062
const RootNodeMask & operator&=(const RootNodeMask &other)
Definition: NodeMasks.h:1227
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:956
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:491
BaseMaskIterator & operator=(const BaseMaskIterator &iter)
Definition: NodeMasks.h:188
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:931
OffIterator()
Definition: NodeMasks.h:1155
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:740
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1370
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition: NodeMasks.h:425
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:715
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:304
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:929
Definition: NodeMasks.h:205
void save(std::ostream &os) const
Definition: NodeMasks.h:785
void increment(Index n)
Definition: NodeMasks.h:283
Definition: NodeMasks.h:236
Index64 Word
Definition: NodeMasks.h:834
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:401
void load(std::istream &is)
Definition: NodeMasks.h:789
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:954
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:681
uint32_t Index32
Definition: Types.h:56
bool next()
Definition: NodeMasks.h:221
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:925
OnMaskIterator< NodeMask > OnIterator
Definition: NodeMasks.h:345
RootNodeMask operator!() const
Definition: NodeMasks.h:1226
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:738
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:458
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition: NodeMasks.h:897
bool next()
Definition: NodeMasks.h:1165
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:480
DenseIterator()
Definition: NodeMasks.h:1183
void setOff(Index32 i)
Definition: NodeMasks.h:1279
Index32 countOff() const
Definition: NodeMasks.h:1271
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:713
DenseIterator beginDense() const
Definition: NodeMasks.h:353
void save(std::ostream &os) const
Definition: NodeMasks.h:996
void increment(Index n)
Definition: NodeMasks.h:220
Index32 offset() const
Definition: NodeMasks.h:1107
BaseMaskIterator()
Definition: NodeMasks.h:180
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:720
void load(std::istream &is)
Definition: NodeMasks.h:1000
void save(std::ostream &os) const
Definition: NodeMasks.h:1345
bool operator<(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:158
bool isOff() const
Definition: NodeMasks.h:1325
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:434
void setFirstOff()
Definition: NodeMasks.h:1306
NodeMask & operator=(const NodeMask &other)
Assignment operator.
Definition: NodeMasks.h:337
void setLastOff()
Definition: NodeMasks.h:1307
RootNodeMask(Index32 bit_size)
Definition: NodeMasks.h:1050
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:705
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:594
RootNodeMask & operator=(const RootNodeMask &B)
Definition: NodeMasks.h:1074
bool isOn(Index32 i) const
Definition: NodeMasks.h:1308
NodeMask operator!() const
Definition: NodeMasks.h:920
Index32 findFirstOn() const
Definition: NodeMasks.h:520
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:936
OnIterator endOn() const
Definition: NodeMasks.h:350
OnIterator endOn() const
Definition: NodeMasks.h:857
void setLastOn()
Definition: NodeMasks.h:1305
NodeMask operator!() const
Definition: NodeMasks.h:704
OnIterator beginOn() const
Definition: NodeMasks.h:856
NodeMask operator!() const
Definition: NodeMasks.h:432
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:499
const NodeMask * mParent
Definition: NodeMasks.h:178
OnIterator endOn() const
Definition: NodeMasks.h:641
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:958
DenseMaskIterator & operator++()
Definition: NodeMasks.h:290
Index32 findFirstOn() const
Definition: NodeMasks.h:975
void toggle(Index32 i)
Definition: NodeMasks.h:1295
OnIterator beginOn() const
Definition: NodeMasks.h:640
bool operator*() const
Definition: NodeMasks.h:226
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:921
Index32 offset() const
Definition: NodeMasks.h:192
Definition: NodeMasks.h:1085
Index32 CountOn(Index64 v)
Return the number of on bits in the given 64-bit value.
Definition: NodeMasks.h:92
Index32 findFirstOn() const
Definition: NodeMasks.h:759
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1358
void setOff()
Definition: NodeMasks.h:1291
~RootNodeMask()
Definition: NodeMasks.h:1060
OnIterator beginOn() const
Definition: NodeMasks.h:1204
OffMaskIterator< NodeMask > OffIterator
Definition: NodeMasks.h:346
#define OPENVDB_VERSION_NAME
Definition: version.h:43
bool operator*() const
Definition: NodeMasks.h:1169
OffIterator beginOff() const
Definition: NodeMasks.h:351
OnMaskIterator< NodeMask > OnIterator
Definition: NodeMasks.h:636
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1386
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1002
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:693
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:409
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:742
bool test() const
Definition: NodeMasks.h:1111
RootNodeMask()
Definition: NodeMasks.h:1049
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:497
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:628
const RootNodeMask * mParent
Definition: NodeMasks.h:1090
OnMaskIterator< NodeMask > OnIterator
Definition: NodeMasks.h:852
OffIterator endOff() const
Definition: NodeMasks.h:1207
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:974
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:791
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition: NodeMasks.h:909
bool next()
Definition: NodeMasks.h:1137
BaseIterator & operator=(const BaseIterator &iter)
Definition: NodeMasks.h:1100
Base class for the bit mask iterators.
Definition: NodeMasks.h:174
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:538
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:844
DenseIterator & operator++()
Definition: NodeMasks.h:1198
void increment(Index n)
Definition: NodeMasks.h:1134
bool test() const
Definition: NodeMasks.h:194
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:758
Index64 Word
Definition: NodeMasks.h:313
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1375
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:438
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:514
bool operator==(const BaseIterator &iter) const
Definition: NodeMasks.h:1097
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:746
DenseIterator endDense() const
Definition: NodeMasks.h:1209
void setOn(Index32 i)
Definition: NodeMasks.h:1273
Definition: Exceptions.h:39
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:564
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:505
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:962
void setOn()
Definition: NodeMasks.h:1287
Index32 mBitSize
Definition: NodeMasks.h:1045
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:440
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:495
OnMaskIterator()
Definition: NodeMasks.h:212
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:927
void setOn()
Set all bits on.
Definition: NodeMasks.h:945
OffMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:244
bool operator==(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:185
DenseMaskIterator< NodeMask > DenseIterator
Definition: NodeMasks.h:347
Index32 mBitSize
Definition: NodeMasks.h:1089
Byte Word
Definition: NodeMasks.h:618
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:711
void setOn()
Set all bits on.
Definition: NodeMasks.h:729
OffMaskIterator()
Definition: NodeMasks.h:243
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:922
void setOff()
Set all bits off.
Definition: NodeMasks.h:731
WordT & getWord(Index n)
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:990
void increment()
Definition: NodeMasks.h:277
Index32 pos() const
Definition: NodeMasks.h:1109
void toggle()
Definition: NodeMasks.h:1300
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:576
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:454
Index32 mPos
Definition: NodeMasks.h:1088
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1354
~NodeMask()
Destructor.
Definition: NodeMasks.h:632
Index32 findFirstOff() const
Definition: NodeMasks.h:760
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:795
void increment()
Definition: NodeMasks.h:1157
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:801
Definition: NodeMasks.h:267
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:331
bool operator*() const
Definition: NodeMasks.h:289
OffIterator endOff() const
Definition: NodeMasks.h:643
Index32 findFirstOff() const
Definition: NodeMasks.h:976
OffIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1156
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1015
const RootNodeMask & operator|=(const RootNodeMask &other)
Definition: NodeMasks.h:1235
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:984
WordT & getWord(Index n)
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:544
Index getBitSize() const
Definition: NodeMasks.h:1070
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:706
void setOff()
Set all bits off.
Definition: NodeMasks.h:947
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:333
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:687
DenseMaskIterator()
Definition: NodeMasks.h:275
DenseIterator endDense() const
Definition: NodeMasks.h:354
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:744
~NodeMask()
Destructor.
Definition: NodeMasks.h:848
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:1006
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1028
void setFirstOn()
Definition: NodeMasks.h:1304
Index32 * mBits
Definition: NodeMasks.h:1046
OffIterator endOff() const
Definition: NodeMasks.h:859
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:449
void setOn()
Set all bits on.
Definition: NodeMasks.h:468
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:949
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:814
BaseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1093
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:559
bool operator!=(const BaseIterator &iter) const
Definition: NodeMasks.h:1098
bool next()
Definition: NodeMasks.h:284
uint64_t Index64
Definition: Types.h:57
void increment(Index n)
Definition: NodeMasks.h:251
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:433
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition: NodeMasks.h:903
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:748
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:329
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:733
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:485
Index32 memUsage() const
Definition: NodeMasks.h:1397
~NodeMask()
Destructor.
Definition: NodeMasks.h:335
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:960
BaseIterator()
Definition: NodeMasks.h:1092
OnIterator()
Definition: NodeMasks.h:1127
OnIterator beginOn() const
Definition: NodeMasks.h:349
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:964
DenseIterator beginDense() const
Definition: NodeMasks.h:860
Index32 FindLowestOn(Index64 v)
Return the least significant on bit of the given 64-bit value.
Definition: NodeMasks.h:133
OnMaskIterator & operator++()
Definition: NodeMasks.h:227
DenseMaskIterator< NodeMask > DenseIterator
Definition: NodeMasks.h:638
RootNodeMask(const RootNodeMask &B)
Definition: NodeMasks.h:1055
OffIterator beginOff() const
Definition: NodeMasks.h:642
DenseIterator beginDense() const
Definition: NodeMasks.h:644
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:970
DenseMaskIterator< NodeMask > DenseIterator
Definition: NodeMasks.h:854
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:435
Index getIntSize() const
Definition: NodeMasks.h:1072
Index32 mIntSize
Definition: NodeMasks.h:1045
bool next()
Definition: NodeMasks.h:1193
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:807
OffIterator beginOff() const
Definition: NodeMasks.h:858
OffIterator beginOff() const
Definition: NodeMasks.h:1206
bool isOff(Index32 i) const
Definition: NodeMasks.h:1313
DenseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1184
RootNodeMask operator|(const RootNodeMask &other) const
Definition: NodeMasks.h:1252
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1021
void increment()
Definition: NodeMasks.h:245
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:754
Index32 mPos
Definition: NodeMasks.h:177
DenseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:276
bool operator*() const
Definition: NodeMasks.h:1197
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:842
OnIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1128
BaseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:181
OffMaskIterator & operator++()
Definition: NodeMasks.h:258
Index32 getMemUsage() const
Definition: NodeMasks.h:1260
Index32 findFirstOff() const
Definition: NodeMasks.h:1338
bool operator*() const
Definition: NodeMasks.h:257
void save(std::ostream &os) const
Definition: NodeMasks.h:551
RootNodeMask operator&(const RootNodeMask &other) const
Definition: NodeMasks.h:1249
void increment(Index n)
Definition: NodeMasks.h:1162
DenseIterator beginDense() const
Definition: NodeMasks.h:1208
const RootNodeMask & operator^=(const RootNodeMask &other)
Definition: NodeMasks.h:1242
bool isOn() const
Definition: NodeMasks.h:1319
void setOff()
Set all bits off.
Definition: NodeMasks.h:474