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++;) ;
372 const Word* w2 = other.mWords;
373 for ( Word* w1 = mWords; n--; ++w1, ++w2) *w1 &= *w2;
379 const Word* w2 = other.mWords;
380 for ( Word* w1 = mWords; n--; ++w1, ++w2) *w1 |= *w2;
386 const Word* w2 = other.mWords;
387 for ( Word* w1 = mWords; n--; ++w1, ++w2) *w1 ^= *w2;
398 Index32 sum = 0, n = WORD_COUNT;
399 for (
const Word* w = mWords; n--; ++w) sum +=
CountOn(*w);
406 assert( (n >> 6) < WORD_COUNT );
407 mWords[n >> 6] |= Word(1) << (n & 63);
411 assert( (n >> 6) < WORD_COUNT );
412 mWords[n >> 6] &= ~(Word(1) << (n & 63));
415 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
419 const Word state = on ? ~Word(0) : Word(0);
421 for (Word* w = mWords; n--; ++w) *w = state;
427 for (Word* w = mWords; n--; ++w) *w = ~Word(0);
433 for (Word* w = mWords; n--; ++w) *w = Word(0);
437 assert( (n >> 6) < WORD_COUNT );
438 mWords[n >> 6] ^= Word(1) << (n & 63);
444 for (Word* w = mWords; n--; ++w) *w = ~*w;
457 assert( (n >> 6) < WORD_COUNT );
458 return 0 != (mWords[n >> 6] & (Word(1) << (n & 63)));
466 for (
const Word *w = mWords; n-- && *w++ == ~Word(0);) ;
473 for (
const Word *w = mWords; n-- && *w++ == Word(0);) ;
479 const Word* w = mWords;
480 for (; n<WORD_COUNT && !*w; ++w, ++n) ;
481 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(*w);
486 const Word* w = mWords;
487 for (; n<WORD_COUNT && !~*w; ++w, ++n) ;
488 return n==WORD_COUNT ? SIZE : (n << 6) +
FindLowestOn(~*w);
492 template<
typename WordT>
496 assert(n*8*
sizeof(WordT) < SIZE);
497 return reinterpret_cast<const WordT*
>(mWords)[n];
499 template<
typename WordT>
502 assert(n*8*
sizeof(WordT) < SIZE);
503 return reinterpret_cast<WordT*
>(mWords)[n];
507 void save(std::ostream& os)
const
509 os.write(reinterpret_cast<const char*>(mWords), this->memUsage());
512 is.read(reinterpret_cast<char*>(mWords), this->memUsage());
517 os <<
"NodeMask: Dim=" << DIM <<
" Log2Dim=" << Log2Dim
518 <<
" Bit count=" << SIZE <<
" word count=" << WORD_COUNT << std::endl;
522 const Index32 n=(SIZE>max_out ? max_out : SIZE);
523 for (
Index32 i=0; i < n; ++i) {
530 os <<
"|" << std::endl;
535 this->printBits(os, max_out);
541 if (n >= WORD_COUNT)
return SIZE;
544 if (b & (Word(1) << m))
return start;
546 while(!b && ++n<WORD_COUNT) b = mWords[n];
553 if (n >= WORD_COUNT)
return SIZE;
556 if (b & (Word(1) << m))
return start;
558 while(!b && ++n<WORD_COUNT) b = ~mWords[n];
590 void operator = (
const NodeMask &other) { mByte = other.mByte; }
596 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
597 OnIterator
endOn()
const {
return OnIterator(SIZE,
this); }
598 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
599 OffIterator
endOff()
const {
return OffIterator(SIZE,
this); }
600 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
601 DenseIterator
endDense()
const {
return DenseIterator(SIZE,
this); }
613 mByte &= other.mByte;
618 mByte |= other.mByte;
623 mByte ^= other.mByte;
638 mByte = mByte |
static_cast<Byte>(0x01U << (n & 7));
643 mByte = mByte &
static_cast<Byte>(~(0x01U << (n & 7)));
646 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
648 void set(
bool on) { mByte = on ? 0xFFU : 0x00U; }
656 mByte = mByte ^
static_cast<Byte>(0x01U << (n & 7));
672 return mByte & (0x01U << (n & 7));
677 bool isOn()
const {
return mByte == 0xFFU; }
679 bool isOff()
const {
return mByte == 0; }
683 const Byte b =
static_cast<Byte>(~mByte);
706 void save(std::ostream& os)
const
708 os.write(reinterpret_cast<const char*>(&mByte), 1);
710 void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mByte), 1); }
714 os <<
"NodeMask: Dim=2, Log2Dim=1, Bit count=8, Word count=1"<<std::endl;
719 for (
Index32 i=0; i < 8; ++i) os << this->isOn(i);
720 os <<
"||" << std::endl;
730 if (start>=8)
return 8;
731 const Byte b =
static_cast<Byte>(mByte & (0xFFU << start));
737 if (start>=8)
return 8;
738 const Byte b =
static_cast<Byte>(~mByte & (0xFFU << start));
765 NodeMask(
bool on) : mWord(on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00)) {}
771 void operator = (
const NodeMask &other) { mWord = other.mWord; }
777 OnIterator
beginOn()
const {
return OnIterator(this->findFirstOn(),
this); }
778 OnIterator
endOn()
const {
return OnIterator(SIZE,
this); }
779 OffIterator
beginOff()
const {
return OffIterator(this->findFirstOff(),
this); }
780 OffIterator
endOff()
const {
return OffIterator(SIZE,
this); }
781 DenseIterator
beginDense()
const {
return DenseIterator(0,
this); }
782 DenseIterator
endDense()
const {
return DenseIterator(SIZE,
this); }
794 mWord &= other.mWord;
799 mWord |= other.mWord;
804 mWord ^= other.mWord;
819 mWord |= UINT64_C(0x01) << (n & 63);
824 mWord &= ~(UINT64_C(0x01) << (n & 63));
827 void set(
Index32 n,
bool On) { On ? this->setOn(n) : this->setOff(n); }
829 void set(
bool on) { mWord = on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00); }
831 void setOn() { mWord = UINT64_C(0xFFFFFFFFFFFFFFFF); }
833 void setOff() { mWord = UINT64_C(0x00); }
837 mWord ^= UINT64_C(0x01) << (n & 63);
853 return 0 != (mWord & (UINT64_C(0x01) << (n & 63)));
858 bool isOn()
const {
return mWord == UINT64_C(0xFFFFFFFFFFFFFFFF); }
860 bool isOff()
const {
return mWord == 0; }
864 const Word w = ~mWord;
868 template<
typename WordT>
872 assert(n*8*
sizeof(WordT) < SIZE);
873 return reinterpret_cast<const WordT*
>(&mWord)[n];
875 template<
typename WordT>
878 assert(n*8*
sizeof(WordT) < SIZE);
879 return reinterpret_cast<WordT*
>(mWord)[n];
882 void save(std::ostream& os)
const
884 os.write(reinterpret_cast<const char*>(&mWord), 8);
886 void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mWord), 8); }
890 os <<
"NodeMask: Dim=4, Log2Dim=2, Bit count=64, Word count=1"<<std::endl;
895 for (
Index32 i=0; i < 64; ++i) {
896 if ( !(i%8) ) os <<
"|";
899 os <<
"||" << std::endl;
909 if (start>=64)
return 64;
910 const Word w = mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
916 if (start>=64)
return 64;
917 const Word w = ~mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
937 mBitSize(bit_size), mIntSize(((bit_size-1)>>5)+1), mBits(new
Index32[mIntSize])
939 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
942 mBitSize(B.mBitSize), mIntSize(B.mIntSize), mBits(new
Index32[mIntSize])
950 mIntSize =((bit_size-1)>>5)+1;
953 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
980 : mPos(pos), mBitSize(parent->getBitSize()), mParent(parent) {
981 assert( pos<=mBitSize );
998 assert(mPos <= mBitSize);
999 return (mPos != mBitSize);
1002 operator bool()
const {
return this->test();}
1009 using BaseIterator::mPos;
1010 using BaseIterator::mBitSize;
1011 using BaseIterator::mParent;
1016 assert(mParent!=NULL);
1017 mPos=mParent->findNextOn(mPos+1);
1018 assert(mPos <= mBitSize);
1021 for (
Index i=0; i<n && this->next(); ++i) {}
1025 return this->test();
1037 using BaseIterator::mPos;
1038 using BaseIterator::mBitSize;
1039 using BaseIterator::mParent;
1044 assert(mParent!=NULL);
1045 mPos=mParent->findNextOff(mPos+1);
1046 assert(mPos <= mBitSize);
1049 for (
Index i=0; i<n && this->next(); ++i) {}
1053 return this->test();
1065 using BaseIterator::mPos;
1066 using BaseIterator::mBitSize;
1067 using BaseIterator::mParent;
1072 assert(mParent!=NULL);
1074 assert(mPos<= mBitSize);
1077 for (
Index i=0; i<n && this->next(); ++i) {}
1081 return this->test();
1098 if (mBitSize != B.
mBitSize)
return false;
1099 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return false;
1104 if (mBitSize != B.
mBitSize)
return true;
1105 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != B.
mBits[i])
return true;
1114 assert(mIntSize == other.
mIntSize);
1116 mBits[i] &= other.
mBits[i];
1118 for (
Index32 i = other.
mIntSize; i < mIntSize; ++i) mBits[i] = 0x00000000;
1122 assert(mIntSize == other.
mIntSize);
1124 mBits[i] |= other.
mBits[i];
1129 assert(mIntSize == other.
mIntSize);
1131 mBits[i] ^= other.
mBits[i];
1147 return static_cast<Index32>(mIntSize*
sizeof(
Index32) +
sizeof(*
this));
1161 assert( (i>>5) < mIntSize);
1162 mBits[i>>5] |= 1<<(i&31);
1167 assert( (i>>5) < mIntSize);
1168 mBits[i>>5] &= ~(1<<(i&31));
1171 void set(
Index32 i,
bool On) { On ? this->setOn(i) : this->setOff(i); }
1175 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0xFFFFFFFF;
1179 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
1183 assert( (i>>5) < mIntSize);
1184 mBits[i>>5] ^= 1<<(i&31);
1188 for (
Index32 i=0; i<mIntSize; ++i) mBits[i]=~mBits[i];
1196 assert( (i>>5) < mIntSize);
1197 return ( mBits[i >> 5] & (1<<(i&31)) );
1201 assert( (i>>5) < mIntSize);
1202 return ( ~mBits[i >> 5] & (1<<(i&31)) );
1206 if (!mBits)
return false;
1207 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0xFFFFFFFF)
return false;
1212 if (!mBits)
return true;
1213 for (
Index32 i=0; i<mIntSize; ++i)
if (mBits[i] != 0)
return false;
1220 while(!mBits[i])
if (++i == mIntSize)
return mBitSize;
1227 while(!(~mBits[i]))
if (++i == mIntSize)
return mBitSize;
1231 void save(std::ostream& os)
const {
1233 os.write((
const char *)mBits,mIntSize*
sizeof(
Index32));
1237 is.read((
char *)mBits,mIntSize*
sizeof(
Index32));
1241 os <<
"RootNodeMask: Bit-size="<<mBitSize<<
" Int-size="<<mIntSize<<std::endl;
1245 const Index32 n=(mBitSize>max_out?max_out:mBitSize);
1246 for (
Index32 i=0; i < n; ++i) {
1251 os << this->isOn(i);
1253 os <<
"|" << std::endl;
1257 this->printInfo(os);
1258 this->printBits(os,max_out);
1263 Index32 n = start >> 5, m = start & 31;
1264 if (n>=mIntSize)
return mBitSize;
1266 if (b & (1<<m))
return start;
1267 b &= 0xFFFFFFFF << m;
1268 while(!b && ++n<mIntSize) b = mBits[n];
1274 Index32 n = start >> 5, m = start & 31;
1275 if (n>=mIntSize)
return mBitSize;
1277 if (b & (1<<m))
return start;
1279 while(!b && ++n<mIntSize) b = ~mBits[n];
1293 #endif // OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:1272
OnIterator & operator++()
Definition: NodeMasks.h:1028
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:677
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:646
const NodeMask & operator^=(const NodeMask &other)
Definition: NodeMasks.h:802
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:582
DenseIterator endDense() const
Definition: NodeMasks.h:601
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:449
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:809
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:827
const NodeMask & operator^=(const NodeMask &other)
Definition: NodeMasks.h:621
DenseIterator endDense() const
Definition: NodeMasks.h:782
OffMaskIterator< NodeMask > OffIterator
Definition: NodeMasks.h:593
void save(std::ostream &os) const
Definition: NodeMasks.h:507
bool test() const
Definition: NodeMasks.h:194
Index getBitSize() const
Definition: NodeMasks.h:956
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:628
void increment()
Definition: NodeMasks.h:214
void increment()
Definition: NodeMasks.h:1043
OffMaskIterator< NodeMask > OffIterator
Definition: NodeMasks.h:774
OnMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:213
void setOff()
Definition: NodeMasks.h:1177
void setOff()
Set all bits off.
Definition: NodeMasks.h:430
~RootNodeMask()
Definition: NodeMasks.h:946
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:463
bool isOn() const
Return true if all the bits are on.
Definition: NodeMasks.h:858
bool operator*() const
Definition: NodeMasks.h:1027
OffIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1042
void increment()
Definition: NodeMasks.h:1015
void load(std::istream &is)
Definition: NodeMasks.h:511
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:767
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:538
Index32 findFirstOff() const
Definition: NodeMasks.h:483
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:447
void increment()
Definition: NodeMasks.h:277
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:586
Base class for the bit mask iterators.
Definition: NodeMasks.h:174
uint64_t Index64
Definition: Types.h:58
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:842
Definition: NodeMasks.h:1006
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:630
const NodeMask & operator^=(const NodeMask &other)
Definition: NodeMasks.h:383
Index32 memUsage() const
Definition: NodeMasks.h:1283
bool operator==(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:185
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:817
void setFirstOn()
Set the first bit on.
Definition: NodeMasks.h:661
void increment(Index n)
Definition: NodeMasks.h:251
bool operator==(const BaseIterator &iter) const
Definition: NodeMasks.h:983
DenseMaskIterator()
Definition: NodeMasks.h:275
OffIterator endOff() const
Definition: NodeMasks.h:352
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:636
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:815
bool next()
Definition: NodeMasks.h:221
void toggle()
Definition: NodeMasks.h:1186
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:648
void setOn(Index32 i)
Definition: NodeMasks.h:1159
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:1240
void save(std::ostream &os) const
Definition: NodeMasks.h:706
void load(std::istream &is)
Definition: NodeMasks.h:710
Index32 * mBits
Definition: NodeMasks.h:932
const NodeMask & operator&=(const NodeMask &other)
Definition: NodeMasks.h:611
Index64 Word
Definition: NodeMasks.h:755
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:840
bool test() const
Definition: NodeMasks.h:997
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:811
Index32 mBitSize
Definition: NodeMasks.h:931
const RootNodeMask * mParent
Definition: NodeMasks.h:976
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:391
const NodeMask & operator&=(const NodeMask &other)
Definition: NodeMasks.h:369
const NodeMask & operator&=(const NodeMask &other)
Definition: NodeMasks.h:792
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:436
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:659
DenseIterator & operator++()
Definition: NodeMasks.h:1084
DenseIterator beginDense() const
Definition: NodeMasks.h:353
void increment(Index n)
Definition: NodeMasks.h:220
OnMaskIterator< NodeMask > OnIterator
Definition: NodeMasks.h:345
Index32 mBitSize
Definition: NodeMasks.h:975
bool operator!=(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Inequality operator, does exact floating point comparisons.
Definition: Vec3.h:458
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:634
OffMaskIterator()
Definition: NodeMasks.h:243
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:829
OffIterator beginOff() const
Definition: NodeMasks.h:1092
bool next()
Definition: NodeMasks.h:252
void save(std::ostream &os) const
Definition: NodeMasks.h:882
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:641
void load(std::istream &is)
Definition: NodeMasks.h:886
void setFirstOn()
Definition: NodeMasks.h:1190
Index32 mPos
Definition: NodeMasks.h:974
OffMaskIterator & operator++()
Definition: NodeMasks.h:258
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:550
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:626
Index32 FindHighestOn(Index32 v)
Return the most significant on bit of the given 32-bit value.
Definition: NodeMasks.h:151
Index32 findFirstOff() const
Definition: NodeMasks.h:1224
Index32 findFirstOn() const
Definition: NodeMasks.h:476
Index getIntSize() const
Definition: NodeMasks.h:958
OnIterator endOn() const
Definition: NodeMasks.h:350
Definition: NodeMasks.h:1034
const RootNodeMask & operator|=(const RootNodeMask &other)
Definition: NodeMasks.h:1121
DenseIterator beginDense() const
Definition: NodeMasks.h:1094
const RootNodeMask & operator^=(const RootNodeMask &other)
Definition: NodeMasks.h:1128
NodeMask operator!() const
Definition: NodeMasks.h:791
NodeMask operator!() const
Definition: NodeMasks.h:368
void set(bool on)
Set all bits to the specified state.
Definition: NodeMasks.h:417
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:822
OnIterator endOn() const
Definition: NodeMasks.h:778
RootNodeMask operator|(const RootNodeMask &other) const
Definition: NodeMasks.h:1138
bool operator*() const
Definition: NodeMasks.h:226
OnIterator beginOn() const
Definition: NodeMasks.h:777
NodeMask operator!() const
Definition: NodeMasks.h:610
Index32 mPos
Definition: NodeMasks.h:177
NodeMask & operator=(const NodeMask &other)
Assignment operator.
Definition: NodeMasks.h:337
RootNodeMask(const RootNodeMask &B)
Definition: NodeMasks.h:941
OnIterator endOn() const
Definition: NodeMasks.h:597
BaseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:181
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:844
Index32 findFirstOn() const
Definition: NodeMasks.h:861
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:807
void increment(Index n)
Definition: NodeMasks.h:1076
OnIterator beginOn() const
Definition: NodeMasks.h:596
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:455
DenseMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:276
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:494
Index32 findFirstOn() const
Definition: NodeMasks.h:680
bool operator!=(const BaseIterator &iter) const
Definition: NodeMasks.h:984
Index32 mIntSize
Definition: NodeMasks.h:931
#define OPENVDB_VERSION_NAME
Definition: version.h:43
OnMaskIterator< NodeMask > OnIterator
Definition: NodeMasks.h:592
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:888
bool next()
Definition: NodeMasks.h:1023
bool isOff(Index32 i) const
Definition: NodeMasks.h:1199
DenseMaskIterator & operator++()
Definition: NodeMasks.h:290
void setLastOn()
Set the last bit on.
Definition: NodeMasks.h:663
bool next()
Definition: NodeMasks.h:1051
OffMaskIterator< NodeMask > OffIterator
Definition: NodeMasks.h:346
OnMaskIterator< NodeMask > OnIterator
Definition: NodeMasks.h:773
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:584
void increment(Index n)
Definition: NodeMasks.h:1020
Index32 Index
Definition: Types.h:59
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:712
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:860
RootNodeMask operator^(const RootNodeMask &other) const
Definition: NodeMasks.h:1141
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:461
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:453
const RootNodeMask & operator&=(const RootNodeMask &other)
Definition: NodeMasks.h:1113
bool operator*() const
Definition: NodeMasks.h:289
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:470
bool operator!=(const BaseMaskIterator &iter) const
Definition: NodeMasks.h:186
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:765
bool isOff() const
Return true if all the bits are off.
Definition: NodeMasks.h:679
BaseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:979
OffIterator beginOff() const
Definition: NodeMasks.h:351
const NodeMask & operator|=(const NodeMask &other)
Definition: NodeMasks.h:376
bool isOn() const
Definition: NodeMasks.h:1205
Index64 Word
Definition: NodeMasks.h:313
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:667
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:396
OnMaskIterator()
Definition: NodeMasks.h:212
Definition: NodeMasks.h:236
Definition: Exceptions.h:39
BaseIterator()
Definition: NodeMasks.h:978
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:532
void setLastOff()
Set the last bit off.
Definition: NodeMasks.h:848
void increment()
Definition: NodeMasks.h:1071
void increment(Index n)
Definition: NodeMasks.h:1048
RootNodeMask operator!() const
Definition: NodeMasks.h:1112
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition: NodeMasks.h:415
OPENVDB_API Hermite min(const Hermite &, const Hermite &)
min and max operations done directly on the compressed data.
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:520
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:813
void init(Index32 bit_size)
Definition: NodeMasks.h:948
void setOn()
Set all bits on.
Definition: NodeMasks.h:831
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition: NodeMasks.h:394
Index32 getMemUsage() const
Definition: NodeMasks.h:1146
BaseMaskIterator & operator=(const BaseMaskIterator &iter)
Definition: NodeMasks.h:188
void load(std::istream &is)
Definition: NodeMasks.h:1235
Byte Word
Definition: NodeMasks.h:574
RootNodeMask operator&(const RootNodeMask &other) const
Definition: NodeMasks.h:1135
Index32 countOn() const
Return the total number of on bits.
Definition: NodeMasks.h:632
void setOn()
Set all bits on.
Definition: NodeMasks.h:650
void setOff()
Set all bits off.
Definition: NodeMasks.h:652
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:808
OnIterator endOn() const
Definition: NodeMasks.h:1091
WordT & getWord(Index n)
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:876
DenseMaskIterator< NodeMask > DenseIterator
Definition: NodeMasks.h:347
Index32 findFirstOn() const
Definition: NodeMasks.h:1217
Index32 pos() const
Definition: NodeMasks.h:193
Index32 findFirstOff() const
Definition: NodeMasks.h:681
Definition: NodeMasks.h:267
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:451
~NodeMask()
Destructor.
Definition: NodeMasks.h:588
bool operator<(const Tuple< SIZE, T0 > &t0, const Tuple< SIZE, T1 > &t1)
Definition: Tuple.h:158
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:716
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:722
OffIterator endOff() const
Definition: NodeMasks.h:599
WordT & getWord(Index n)
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:500
Index32 CountOn(Index64 v)
Return the number of on bits in the given 64-bit value.
Definition: NodeMasks.h:92
bool operator*() const
Definition: NodeMasks.h:1055
Index32 findFirstOff() const
Definition: NodeMasks.h:862
NodeMask(const NodeMask &other)
Copy constructor.
Definition: NodeMasks.h:333
void increment(Index n)
Definition: NodeMasks.h:283
void printAll(std::ostream &os=std::cout) const
Definition: NodeMasks.h:901
RootNodeMask & operator=(const RootNodeMask &B)
Definition: NodeMasks.h:960
NodeMask(bool on)
All bits are set to the specified state.
Definition: NodeMasks.h:331
void setOff()
Set all bits off.
Definition: NodeMasks.h:833
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition: NodeMasks.h:870
NodeMask operator|(const NodeMask &other) const
Definition: NodeMasks.h:627
const NodeMask & operator|=(const NodeMask &other)
Definition: NodeMasks.h:616
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:329
void setOff(Index32 i)
Definition: NodeMasks.h:1165
Index32 countOff() const
Definition: NodeMasks.h:1157
Index32 countOn() const
Definition: NodeMasks.h:1150
unsigned char Byte
Definition: Types.h:64
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:450
void setOff(Index32 n)
Set the nth bit off.
Definition: NodeMasks.h:410
OffIterator & operator++()
Definition: NodeMasks.h:1056
BaseMaskIterator()
Definition: NodeMasks.h:180
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:665
void setOn(Index32 n)
Set the nth bit on.
Definition: NodeMasks.h:405
~NodeMask()
Destructor.
Definition: NodeMasks.h:769
void setOn()
Set all bits on.
Definition: NodeMasks.h:424
void printBits(std::ostream &os=std::cout) const
Definition: NodeMasks.h:892
Definition: NodeMasks.h:205
void increment()
Definition: NodeMasks.h:245
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:914
DenseIterator endDense() const
Definition: NodeMasks.h:354
OffIterator endOff() const
Definition: NodeMasks.h:780
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition: NodeMasks.h:515
void toggle(Index32 i)
Definition: NodeMasks.h:1181
OffIterator()
Definition: NodeMasks.h:1041
bool operator*() const
Definition: NodeMasks.h:1083
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:835
void toggle()
Toggle the state of all bits in the mask.
Definition: NodeMasks.h:441
void setLastOff()
Definition: NodeMasks.h:1193
Index32 findNextOff(Index32 start) const
Definition: NodeMasks.h:735
bool operator*() const
Definition: NodeMasks.h:257
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:669
const NodeMask & operator|=(const NodeMask &other)
Definition: NodeMasks.h:797
OnIterator()
Definition: NodeMasks.h:1013
OnIterator beginOn() const
Definition: NodeMasks.h:349
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition: NodeMasks.h:654
void setFirstOff()
Set the first bit off.
Definition: NodeMasks.h:846
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition: NodeMasks.h:850
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1256
bool next()
Definition: NodeMasks.h:284
DenseIterator beginDense() const
Definition: NodeMasks.h:781
OffMaskIterator(Index32 pos, const NodeMask *parent)
Definition: NodeMasks.h:244
RootNodeMask()
Definition: NodeMasks.h:935
Index32 FindLowestOn(Index64 v)
Return the least significant on bit of the given 64-bit value.
Definition: NodeMasks.h:133
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation. ...
Definition: NodeMasks.h:304
OffIterator beginOff() const
Definition: NodeMasks.h:598
void save(std::ostream &os) const
Definition: NodeMasks.h:1231
const NodeMask * mParent
Definition: NodeMasks.h:178
OffIterator endOff() const
Definition: NodeMasks.h:1093
DenseMaskIterator< NodeMask > DenseIterator
Definition: NodeMasks.h:594
NodeMask operator^(const NodeMask &other) const
Definition: NodeMasks.h:392
DenseIterator beginDense() const
Definition: NodeMasks.h:600
BaseIterator & operator=(const BaseIterator &iter)
Definition: NodeMasks.h:986
DenseIterator()
Definition: NodeMasks.h:1069
void setFirstOff()
Definition: NodeMasks.h:1192
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:856
OnMaskIterator & operator++()
Definition: NodeMasks.h:227
uint32_t Index32
Definition: Types.h:57
DenseIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1070
Index32 offset() const
Definition: NodeMasks.h:192
Definition: NodeMasks.h:971
DenseMaskIterator< NodeMask > DenseIterator
Definition: NodeMasks.h:775
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
NodeMask operator&(const NodeMask &other) const
Definition: NodeMasks.h:390
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition: NodeMasks.h:1244
~NodeMask()
Destructor.
Definition: NodeMasks.h:335
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:728
OffIterator beginOff() const
Definition: NodeMasks.h:779
Definition: NodeMasks.h:1062
void set(Index32 i, bool On)
Definition: NodeMasks.h:1171
void setLastOn()
Definition: NodeMasks.h:1191
Index32 offset() const
Definition: NodeMasks.h:993
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:907
bool next()
Definition: NodeMasks.h:1079
void setOn()
Definition: NodeMasks.h:1173
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition: NodeMasks.h:675
Index32 countOff() const
Return the total number of on bits.
Definition: NodeMasks.h:403
bool isOff() const
Definition: NodeMasks.h:1211
NodeMask()
Default constructor sets all bits off.
Definition: NodeMasks.h:763
RootNodeMask(Index32 bit_size)
Definition: NodeMasks.h:936
OnIterator(Index32 pos, const RootNodeMask *parent)
Definition: NodeMasks.h:1014
Index32 findNextOn(Index32 start) const
Definition: NodeMasks.h:1261
Index32 CountOff(Index64 v)
Return the number of off bits in the given 64-bit value.
Definition: NodeMasks.h:101
Index32 pos() const
Definition: NodeMasks.h:995
bool isOn(Index32 i) const
Definition: NodeMasks.h:1194
OnIterator beginOn() const
Definition: NodeMasks.h:1090
Definition: NodeMasks.h:928
DenseIterator endDense() const
Definition: NodeMasks.h:1095