8#ifndef OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
9#define OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
14#include <openvdb/version.h>
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
116#pragma warning(disable:4146)
118 return DeBruijn[
Index32((v & -v) * 0x077CB531U) >> 27];
129#if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER)
131 _BitScanForward64(&index, v);
132 return static_cast<Index32>(index);
133#elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
134 return static_cast<Index32>(__builtin_ctzll(v));
137 static const Byte DeBruijn[64] = {
138 0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
139 62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
140 63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
141 51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12,
148#pragma warning(disable:4146)
150 return DeBruijn[
Index64((v & -v) * UINT64_C(0x022FDD63CC95386D)) >> 58];
162 static const Byte DeBruijn[32] = {
163 0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
164 8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
171 return DeBruijn[
Index32(v * 0x07C4ACDDU) >> 27];
179template<
typename NodeMask>
203 operator bool()
const {
return this->
test(); }
208template <
typename NodeMask>
221 mPos = mParent->findNextOn(mPos+1);
239template <
typename NodeMask>
252 mPos=mParent->findNextOff(mPos+1);
270template <
typename NodeMask>
307template<Index Log2Dim>
311 static_assert(Log2Dim > 2,
"expected NodeMask template specialization, got base template");
344 const Word* w2 = other.mWords;
345 for (
Word* w1 = mWords; n--; ++w1, ++w2) *w1 = *w2;
363 for (
const Word *w1=mWords, *w2=other.mWords; n-- && *w1++ == *w2++;) ;
367 bool operator != (
const NodeMask &other)
const {
return !(*
this == other); }
379 template<
typename WordOp>
383 const Word *w2 = other.mWords;
387 template<
typename WordOp>
391 const Word *w2 = other1.mWords, *w3 = other2.mWords;
395 template<
typename WordOp>
400 const Word *w2 = other1.mWords, *w3 = other2.mWords, *w4 = other3.mWords;
401 for (
Index32 n =
WORD_COUNT; n--; ++w1, ++w2, ++w3, ++w4) op( *w1, *w2, *w3, *w4);
408 const Word *w2 = other.mWords;
416 const Word *w2 = other.mWords;
424 const Word *w2 = other.mWords;
432 const Word *w2 = other.mWords;
447 for (
const Word* w = mWords; n--; ++w) sum +=
CountOn(*w);
455 mWords[n >> 6] |=
Word(1) << (n & 63);
460 mWords[n >> 6] &= ~(
Word(1) << (n & 63));
469 for (
Word* w = mWords; n--; ++w) *w = state;
475 for (
Word* w = mWords; n--; ++w) *w = ~
Word(0);
481 for (
Word* w = mWords; n--; ++w) *w =
Word(0);
486 mWords[n >> 6] ^=
Word(1) << (n & 63);
492 for (
Word* w = mWords; n--; ++w) *w = ~*w;
506 return 0 != (mWords[n >> 6] & (
Word(1) << (n & 63)));
514 for (
const Word *w = mWords; n-- && *w++ ==
~Word(0);) ;
521 for (
const Word *w = mWords; n-- && *w++ ==
Word(0);) ;
530 if ( !
isOn && mWords[0] !=
Word(0))
return false;
532 while( w<n && *w == mWords[0] ) ++w;
538 const Word* w = mWords;
545 const Word* w = mWords;
552 template<
typename WordT>
556 return reinterpret_cast<const WordT*
>(mWords)[n];
558 template<
typename WordT>
562 return reinterpret_cast<WordT*
>(mWords)[n];
566 void save(std::ostream& os)
const
568 os.write(
reinterpret_cast<const char*
>(mWords), this->
memUsage());
570 void load(std::istream& is) { is.read(
reinterpret_cast<char*
>(mWords), this->
memUsage()); }
571 void seek(std::istream& is)
const { is.seekg(this->
memUsage(), std::ios_base::cur); }
575 os <<
"NodeMask: Dim=" <<
DIM <<
" Log2Dim=" << Log2Dim
576 <<
" Bit count=" <<
SIZE <<
" word count=" <<
WORD_COUNT << std::endl;
581 for (
Index32 i=0; i < n; ++i) {
588 os <<
"|" << std::endl;
602 if (b & (
Word(1) << m))
return start;
614 if (b & (
Word(1) << m))
return start;
648 void operator = (
const NodeMask &other) { mByte = other.mByte; }
661 bool operator == (
const NodeMask &other)
const {
return mByte == other.mByte; }
663 bool operator != (
const NodeMask &other)
const {
return mByte != other.mByte; }
675 template<
typename WordOp>
678 op(mByte, other.mByte);
681 template<
typename WordOp>
684 op(mByte, other1.mByte, other2.mByte);
687 template<
typename WordOp>
691 op(mByte, other1.mByte, other2.mByte, other3.mByte);
697 mByte &= other.mByte;
703 mByte |= other.mByte;
709 mByte &=
static_cast<Byte>(~other.mByte);
715 mByte ^= other.mByte;
731 mByte =
static_cast<Byte>(mByte | 0x01U << (n & 7));
736 mByte =
static_cast<Byte>(mByte & ~(0x01U << (n & 7)));
741 void set(
bool on) { mByte = on ? 0xFFU : 0x00U; }
749 mByte =
static_cast<Byte>(mByte ^ 0x01U << (n & 7));
765 return mByte & (0x01U << (n & 7));
770 bool isOn()
const {
return mByte == 0xFFU; }
772 bool isOff()
const {
return mByte == 0; }
784 const Byte b =
static_cast<Byte>(~mByte);
791 template<typename WordT>
792 WordT getWord(Index n) const
794 static_assert(sizeof(WordT) == sizeof(Byte), "expected word size to be one byte");
795 OPENVDB_ASSERT(n == 0);
796 return reinterpret_cast<WordT>(mByte);
798 template<typename WordT>
799 WordT& getWord(Index n)
801 static_assert(sizeof(WordT) == sizeof(Byte), "expected word size to be one byte");
802 OPENVDB_ASSERT(n == 0);
803 return reinterpret_cast<WordT&>(mByte);
807 void save(std::ostream& os)
const { os.write(
reinterpret_cast<const char*
>(&mByte), 1); }
808 void load(std::istream& is) { is.read(
reinterpret_cast<char*
>(&mByte), 1); }
809 void seek(std::istream& is)
const { is.seekg(1, std::ios_base::cur); }
813 os <<
"NodeMask: Dim=2, Log2Dim=1, Bit count=8, Word count=1"<<std::endl;
819 os <<
"||" << std::endl;
829 if (start>=8)
return 8;
830 const Byte b =
static_cast<Byte>(mByte & (0xFFU << start));
836 if (start>=8)
return 8;
837 const Byte b =
static_cast<Byte>(~mByte & (0xFFU << start));
864 NodeMask(
bool on) : mWord(on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00)) {}
870 void operator = (
const NodeMask &other) { mWord = other.mWord; }
883 bool operator == (
const NodeMask &other)
const {
return mWord == other.mWord; }
885 bool operator != (
const NodeMask &other)
const {
return mWord != other.mWord; }
897 template<
typename WordOp>
900 op(mWord, other.mWord);
903 template<
typename WordOp>
906 op(mWord, other1.mWord, other2.mWord);
909 template<
typename WordOp>
913 op(mWord, other1.mWord, other2.mWord, other3.mWord);
919 mWord &= other.mWord;
925 mWord |= other.mWord;
931 mWord &= ~other.mWord;
937 mWord ^= other.mWord;
953 mWord |= UINT64_C(0x01) << (n & 63);
958 mWord &= ~(UINT64_C(0x01) << (n & 63));
963 void set(
bool on) { mWord = on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00); }
965 void setOn() { mWord = UINT64_C(0xFFFFFFFFFFFFFFFF); }
967 void setOff() { mWord = UINT64_C(0x00); }
971 mWord ^= UINT64_C(0x01) << (n & 63);
987 return 0 != (mWord & (UINT64_C(0x01) << (n & 63)));
992 bool isOn()
const {
return mWord == UINT64_C(0xFFFFFFFFFFFFFFFF); }
994 bool isOff()
const {
return mWord == 0; }
999 {
isOn = this->isOn();
1005 const Word w = ~mWord;
1010 template<
typename WordT>
1014 return reinterpret_cast<const WordT*
>(&mWord)[n];
1016 template<
typename WordT>
1020 return reinterpret_cast<WordT*
>(mWord)[n];
1023 void save(std::ostream& os)
const { os.write(
reinterpret_cast<const char*
>(&mWord), 8); }
1024 void load(std::istream& is) { is.read(
reinterpret_cast<char*
>(&mWord), 8); }
1025 void seek(std::istream& is)
const { is.seekg(8, std::ios_base::cur); }
1029 os <<
"NodeMask: Dim=4, Log2Dim=2, Bit count=64, Word count=1"<<std::endl;
1034 for (
Index32 i=0; i < 64; ++i) {
1035 if ( !(i%8) ) os <<
"|";
1036 os << this->
isOn(i);
1038 os <<
"||" << std::endl;
1048 if (start>=64)
return 64;
1049 const Word w = mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
1055 if (start>=64)
return 64;
1056 const Word w = ~mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
bool operator==(const BaseMaskIterator &iter) const
Definition NodeMasks.h:193
bool test() const
Definition NodeMasks.h:202
BaseMaskIterator(const BaseMaskIterator &)=default
bool operator!=(const BaseMaskIterator &iter) const
Definition NodeMasks.h:194
BaseMaskIterator()
Definition NodeMasks.h:187
Index32 mPos
Definition NodeMasks.h:183
Index32 pos() const
Definition NodeMasks.h:201
BaseMaskIterator(Index32 pos, const NodeMask *parent)
Definition NodeMasks.h:189
Index32 offset() const
Definition NodeMasks.h:200
const NodeMask * mParent
Definition NodeMasks.h:184
BaseMaskIterator & operator=(const BaseMaskIterator &iter)
Definition NodeMasks.h:196
Definition NodeMasks.h:272
DenseMaskIterator & operator++()
Definition NodeMasks.h:294
bool operator*() const
Definition NodeMasks.h:293
DenseMaskIterator()
Definition NodeMasks.h:279
DenseMaskIterator(Index32 pos, const NodeMask *parent)
Definition NodeMasks.h:280
bool next()
Definition NodeMasks.h:288
void increment(Index n)
Definition NodeMasks.h:287
void increment()
Definition NodeMasks.h:281
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition NodeMasks.h:713
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition NodeMasks.h:768
NodeMask operator|(const NodeMask &other) const
Definition NodeMasks.h:720
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition NodeMasks.h:695
Index32 countOn() const
Return the total number of on bits.
Definition NodeMasks.h:725
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition NodeMasks.h:707
void printAll(std::ostream &os=std::cout) const
Definition NodeMasks.h:821
OnIterator beginOn() const
Definition NodeMasks.h:654
NodeMask operator^(const NodeMask &other) const
Definition NodeMasks.h:721
DenseIterator endDense() const
Definition NodeMasks.h:659
DenseIterator beginDense() const
Definition NodeMasks.h:658
OffIterator beginOff() const
Definition NodeMasks.h:656
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition NodeMasks.h:739
void setOn()
Set all bits on.
Definition NodeMasks.h:743
DenseMaskIterator< NodeMask > DenseIterator
Definition NodeMasks.h:652
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition NodeMasks.h:762
void printBits(std::ostream &os=std::cout) const
Definition NodeMasks.h:815
bool isConstant(bool &isOn) const
Definition NodeMasks.h:776
static const Index32 WORD_COUNT
Definition NodeMasks.h:631
Index32 countOff() const
Return the total number of on bits.
Definition NodeMasks.h:727
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition NodeMasks.h:747
void setLastOff()
Set the last bit off.
Definition NodeMasks.h:760
NodeMask(bool on)
All bits are set to the specified state.
Definition NodeMasks.h:642
Index32 findNextOff(Index32 start) const
Definition NodeMasks.h:834
void seek(std::istream &is) const
Definition NodeMasks.h:809
void setFirstOff()
Set the first bit off.
Definition NodeMasks.h:758
OnMaskIterator< NodeMask > OnIterator
Definition NodeMasks.h:650
void set(bool on)
Set all bits to the specified state.
Definition NodeMasks.h:741
NodeMask operator!() const
Definition NodeMasks.h:718
static const Index32 SIZE
Definition NodeMasks.h:630
void setFirstOn()
Set the first bit on.
Definition NodeMasks.h:754
static const Index32 DIM
Definition NodeMasks.h:629
OnIterator endOn() const
Definition NodeMasks.h:655
void load(std::istream &is)
Definition NodeMasks.h:808
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition NodeMasks.h:701
void save(std::ostream &os) const
Definition NodeMasks.h:807
Index32 findFirstOff() const
Definition NodeMasks.h:782
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition NodeMasks.h:723
void setOff()
Set all bits off.
Definition NodeMasks.h:745
void setOff(Index32 n)
Set the nth bit off.
Definition NodeMasks.h:734
void setOn(Index32 n)
Set the nth bit on.
Definition NodeMasks.h:729
NodeMask operator&(const NodeMask &other) const
Definition NodeMasks.h:719
bool isOff() const
Return true if all the bits are off.
Definition NodeMasks.h:772
static const Index32 LOG2DIM
Definition NodeMasks.h:628
NodeMask()
Default constructor sets all bits off.
Definition NodeMasks.h:640
NodeMask(const NodeMask &other)
Copy constructor.
Definition NodeMasks.h:644
Byte Word
Definition NodeMasks.h:632
void toggle()
Toggle the state of all bits in the mask.
Definition NodeMasks.h:752
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition NodeMasks.h:811
OffMaskIterator< NodeMask > OffIterator
Definition NodeMasks.h:651
Index32 findNextOn(Index32 start) const
Definition NodeMasks.h:827
void setLastOn()
Set the last bit on.
Definition NodeMasks.h:756
~NodeMask()
Destructor.
Definition NodeMasks.h:646
OffIterator endOff() const
Definition NodeMasks.h:657
bool isOn() const
Return true if all the bits are on.
Definition NodeMasks.h:770
Index32 findFirstOn() const
Definition NodeMasks.h:781
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition NodeMasks.h:935
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition NodeMasks.h:990
NodeMask operator|(const NodeMask &other) const
Definition NodeMasks.h:942
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition NodeMasks.h:917
Index32 countOn() const
Return the total number of on bits.
Definition NodeMasks.h:947
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition NodeMasks.h:929
Index64 Word
Definition NodeMasks.h:854
void printAll(std::ostream &os=std::cout) const
Definition NodeMasks.h:1040
OnIterator beginOn() const
Definition NodeMasks.h:876
WordT & getWord(Index n)
Definition NodeMasks.h:1017
NodeMask operator^(const NodeMask &other) const
Definition NodeMasks.h:943
DenseIterator endDense() const
Definition NodeMasks.h:881
DenseIterator beginDense() const
Definition NodeMasks.h:880
OffIterator beginOff() const
Definition NodeMasks.h:878
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition NodeMasks.h:961
void setOn()
Set all bits on.
Definition NodeMasks.h:965
DenseMaskIterator< NodeMask > DenseIterator
Definition NodeMasks.h:874
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition NodeMasks.h:984
void printBits(std::ostream &os=std::cout) const
Definition NodeMasks.h:1031
bool isConstant(bool &isOn) const
Definition NodeMasks.h:998
static const Index32 WORD_COUNT
Definition NodeMasks.h:853
Index32 countOff() const
Return the total number of on bits.
Definition NodeMasks.h:949
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition NodeMasks.h:969
void setLastOff()
Set the last bit off.
Definition NodeMasks.h:982
NodeMask(bool on)
All bits are set to the specified state.
Definition NodeMasks.h:864
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition NodeMasks.h:1011
Index32 findNextOff(Index32 start) const
Definition NodeMasks.h:1053
void seek(std::istream &is) const
Definition NodeMasks.h:1025
void setFirstOff()
Set the first bit off.
Definition NodeMasks.h:980
OnMaskIterator< NodeMask > OnIterator
Definition NodeMasks.h:872
void set(bool on)
Set all bits to the specified state.
Definition NodeMasks.h:963
NodeMask operator!() const
Definition NodeMasks.h:940
static const Index32 SIZE
Definition NodeMasks.h:852
void setFirstOn()
Set the first bit on.
Definition NodeMasks.h:976
static const Index32 DIM
Definition NodeMasks.h:851
OnIterator endOn() const
Definition NodeMasks.h:877
void load(std::istream &is)
Definition NodeMasks.h:1024
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition NodeMasks.h:923
void save(std::ostream &os) const
Definition NodeMasks.h:1023
Index32 findFirstOff() const
Definition NodeMasks.h:1003
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition NodeMasks.h:945
void setOff()
Set all bits off.
Definition NodeMasks.h:967
void setOff(Index32 n)
Set the nth bit off.
Definition NodeMasks.h:956
void setOn(Index32 n)
Set the nth bit on.
Definition NodeMasks.h:951
NodeMask operator&(const NodeMask &other) const
Definition NodeMasks.h:941
bool isOff() const
Return true if all the bits are off.
Definition NodeMasks.h:994
static const Index32 LOG2DIM
Definition NodeMasks.h:850
NodeMask()
Default constructor sets all bits off.
Definition NodeMasks.h:862
NodeMask(const NodeMask &other)
Copy constructor.
Definition NodeMasks.h:866
void toggle()
Toggle the state of all bits in the mask.
Definition NodeMasks.h:974
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition NodeMasks.h:1027
OffMaskIterator< NodeMask > OffIterator
Definition NodeMasks.h:873
Index32 findNextOn(Index32 start) const
Definition NodeMasks.h:1046
void setLastOn()
Set the last bit on.
Definition NodeMasks.h:978
~NodeMask()
Destructor.
Definition NodeMasks.h:868
OffIterator endOff() const
Definition NodeMasks.h:879
bool isOn() const
Return true if all the bits are on.
Definition NodeMasks.h:992
Index32 findFirstOn() const
Definition NodeMasks.h:1002
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation.
Definition NodeMasks.h:309
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition NodeMasks.h:429
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition NodeMasks.h:509
NodeMask operator|(const NodeMask &other) const
Definition NodeMasks.h:438
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition NodeMasks.h:405
Index32 countOn() const
Return the total number of on bits.
Definition NodeMasks.h:444
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition NodeMasks.h:421
Index64 Word
Definition NodeMasks.h:317
OnIterator beginOn() const
Definition NodeMasks.h:353
WordT & getWord(Index n)
Definition NodeMasks.h:559
NodeMask operator^(const NodeMask &other) const
Definition NodeMasks.h:439
DenseIterator endDense() const
Definition NodeMasks.h:358
DenseIterator beginDense() const
Definition NodeMasks.h:357
OffIterator beginOff() const
Definition NodeMasks.h:355
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition NodeMasks.h:463
void setOn()
Set all bits on.
Definition NodeMasks.h:472
DenseMaskIterator< NodeMask > DenseIterator
Definition NodeMasks.h:351
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition NodeMasks.h:503
bool isConstant(bool &isOn) const
Definition NodeMasks.h:527
static const Index32 WORD_COUNT
Definition NodeMasks.h:316
Index32 countOff() const
Return the total number of on bits.
Definition NodeMasks.h:451
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition NodeMasks.h:484
void setLastOff()
Set the last bit off.
Definition NodeMasks.h:501
NodeMask(bool on)
All bits are set to the specified state.
Definition NodeMasks.h:335
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition NodeMasks.h:553
Index32 findNextOff(Index32 start) const
Definition NodeMasks.h:608
void seek(std::istream &is) const
Definition NodeMasks.h:571
void setFirstOff()
Set the first bit off.
Definition NodeMasks.h:499
OnMaskIterator< NodeMask > OnIterator
Definition NodeMasks.h:349
void set(bool on)
Set all bits to the specified state.
Definition NodeMasks.h:465
NodeMask operator!() const
Definition NodeMasks.h:436
static const Index32 SIZE
Definition NodeMasks.h:315
void setFirstOn()
Set the first bit on.
Definition NodeMasks.h:495
static const Index32 DIM
Definition NodeMasks.h:314
OnIterator endOn() const
Definition NodeMasks.h:354
void load(std::istream &is)
Definition NodeMasks.h:570
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition NodeMasks.h:413
void save(std::ostream &os) const
Definition NodeMasks.h:566
Index32 findFirstOff() const
Definition NodeMasks.h:542
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition NodeMasks.h:578
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition NodeMasks.h:442
void setOff()
Set all bits off.
Definition NodeMasks.h:478
void setOff(Index32 n)
Set the nth bit off.
Definition NodeMasks.h:458
void setOn(Index32 n)
Set the nth bit on.
Definition NodeMasks.h:453
NodeMask operator&(const NodeMask &other) const
Definition NodeMasks.h:437
bool isOff() const
Return true if all the bits are off.
Definition NodeMasks.h:518
NodeMask & operator=(const NodeMask &other)
Assignment operator.
Definition NodeMasks.h:341
static const Index32 LOG2DIM
Definition NodeMasks.h:313
NodeMask()
Default constructor sets all bits off.
Definition NodeMasks.h:333
NodeMask(const NodeMask &other)
Copy constructor.
Definition NodeMasks.h:337
void toggle()
Toggle the state of all bits in the mask.
Definition NodeMasks.h:489
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition NodeMasks.h:590
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition NodeMasks.h:573
OffMaskIterator< NodeMask > OffIterator
Definition NodeMasks.h:350
Index32 findNextOn(Index32 start) const
Definition NodeMasks.h:596
void setLastOn()
Set the last bit on.
Definition NodeMasks.h:497
~NodeMask()
Destructor.
Definition NodeMasks.h:339
OffIterator endOff() const
Definition NodeMasks.h:356
bool isOn() const
Return true if all the bits are on.
Definition NodeMasks.h:511
Index32 findFirstOn() const
Definition NodeMasks.h:535
Definition NodeMasks.h:241
bool operator*() const
Definition NodeMasks.h:261
OffMaskIterator()
Definition NodeMasks.h:247
OffMaskIterator(Index32 pos, const NodeMask *parent)
Definition NodeMasks.h:248
bool next()
Definition NodeMasks.h:256
OffMaskIterator & operator++()
Definition NodeMasks.h:262
void increment(Index n)
Definition NodeMasks.h:255
void increment()
Definition NodeMasks.h:249
Definition NodeMasks.h:210
bool operator*() const
Definition NodeMasks.h:230
OnMaskIterator & operator++()
Definition NodeMasks.h:231
bool next()
Definition NodeMasks.h:225
OnMaskIterator(Index32 pos, const NodeMask *parent)
Definition NodeMasks.h:217
OnMaskIterator()
Definition NodeMasks.h:216
void increment(Index n)
Definition NodeMasks.h:224
void increment()
Definition NodeMasks.h:218
Index32 CountOff(Byte v)
Return the number of off bits in the given 8-bit value.
Definition NodeMasks.h:50
Index32 FindHighestOn(Index32 v)
Return the most significant on bit of the given 32-bit value.
Definition NodeMasks.h:160
Index32 FindLowestOn(Byte v)
Return the least significant on bit of the given 8-bit value.
Definition NodeMasks.h:86
Index32 CountOn(Byte v)
Return the number of on bits in the given 8-bit value.
Definition NodeMasks.h:28
Index32 Index
Definition Types.h:34
unsigned char Byte
Definition Types.h:39
uint32_t Index32
Definition Types.h:32
uint64_t Index64
Definition Types.h:33
Definition Exceptions.h:13
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:284