Loading...
Searching...
No Matches
NodeMasks.h
Go to the documentation of this file.
// Copyright Contributors to the OpenVDB Project
// SPDX-License-Identifier: MPL-2.0
//
/// @author Ken Museth
///
/// @file NodeMasks.h
#ifndef OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
#define OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
#include <algorithm> // for std::min()
#include <cassert>
#include <cstring>
#include <iostream>// for cout
#include <openvdb/Platform.h>
#include <openvdb/Types.h>
//#include <strings.h> // for ffs
namespace openvdb {
OPENVDB_USE_VERSION_NAMESPACE
namespace OPENVDB_VERSION_NAME {
namespace util {
/// Return the number of on bits in the given 8-bit value.
inline Index32
CountOn(Byte v)
{
#if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER)
return __popcnt16(v);
#elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
return __builtin_popcount(v);
#else
// Software Implementation - Simple LUT
static const Byte numBits[256] = {
#define COUNTONB2(n) n, n+1, n+1, n+2
#define COUNTONB4(n) COUNTONB2(n), COUNTONB2(n+1), COUNTONB2(n+1), COUNTONB2(n+2)
#define COUNTONB6(n) COUNTONB4(n), COUNTONB4(n+1), COUNTONB4(n+1), COUNTONB4(n+2)
COUNTONB6(0), COUNTONB6(1), COUNTONB6(1), COUNTONB6(2)
};
return numBits[v];
#undef COUNTONB6
#undef COUNTONB4
#undef COUNTONB2
#endif
}
/// Return the number of off bits in the given 8-bit value.
inline Index32 CountOff(Byte v) { return CountOn(static_cast<Byte>(~v)); }
/// Return the number of on bits in the given 32-bit value.
inline Index32
CountOn(Index32 v)
{
v = v - ((v >> 1) & 0x55555555U);
v = (v & 0x33333333U) + ((v >> 2) & 0x33333333U);
return (((v + (v >> 4)) & 0xF0F0F0FU) * 0x1010101U) >> 24;
}
/// Return the number of off bits in the given 32-bit value.
inline Index32 CountOff(Index32 v) { return CountOn(~v); }
/// Return the number of on bits in the given 64-bit value.
inline Index32
CountOn(Index64 v)
{
#if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER) && defined(_M_X64)
v = __popcnt64(v);
#elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
v = __builtin_popcountll(v);
#else
// Software Implementation
v = v - ((v >> 1) & UINT64_C(0x5555555555555555));
v = (v & UINT64_C(0x3333333333333333)) + ((v >> 2) & UINT64_C(0x3333333333333333));
v = (((v + (v >> 4)) & UINT64_C(0xF0F0F0F0F0F0F0F)) * UINT64_C(0x101010101010101)) >> 56;
#endif
return static_cast<Index32>(v);
}
/// Return the number of off bits in the given 64-bit value.
inline Index32 CountOff(Index64 v) { return CountOn(~v); }
/// Return the least significant on bit of the given 8-bit value.
inline Index32
FindLowestOn(Byte v)
{
assert(v);
#if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER)
unsigned long index;
_BitScanForward(&index, static_cast<Index32>(v));
return static_cast<Index32>(index);
#elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
return __builtin_ctz(v);
#else
// Software Implementation
static const Byte DeBruijn[8] = {0, 1, 6, 2, 7, 5, 4, 3};
return DeBruijn[Byte((v & -v) * 0x1DU) >> 5];
#endif
}
/// Return the least significant on bit of the given 32-bit value.
inline Index32
FindLowestOn(Index32 v)
{
assert(v);
//return ffs(v);
static const Byte DeBruijn[32] = {
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
};
// disable unary minus on unsigned warning
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4146)
#endif
return DeBruijn[Index32((v & -v) * 0x077CB531U) >> 27];
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
}
/// Return the least significant on bit of the given 64-bit value.
inline Index32
FindLowestOn(Index64 v)
{
assert(v);
#if defined(OPENVDB_USE_SSE42) && defined(_MSC_VER)
unsigned long index;
_BitScanForward64(&index, v);
return static_cast<Index32>(index);
#elif defined(OPENVDB_USE_SSE42) && (defined(__GNUC__) || defined(__clang__))
return static_cast<Index32>(__builtin_ctzll(v));
#else
// Software Implementation
static const Byte DeBruijn[64] = {
0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12,
};
// disable unary minus on unsigned warning
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable:4146)
#endif
return DeBruijn[Index64((v & -v) * UINT64_C(0x022FDD63CC95386D)) >> 58];
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
#endif
}
/// Return the most significant on bit of the given 32-bit value.
inline Index32
FindHighestOn(Index32 v)
{
static const Byte DeBruijn[32] = {
0, 9, 1, 10, 13, 21, 2, 29, 11, 14, 16, 18, 22, 25, 3, 30,
8, 12, 20, 28, 15, 17, 24, 7, 19, 27, 23, 6, 26, 5, 4, 31
};
v |= v >> 1; // first round down to one less than a power of 2
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
return DeBruijn[Index32(v * 0x07C4ACDDU) >> 27];
}
////////////////////////////////////////
/// Base class for the bit mask iterators
template<typename NodeMask>
class BaseMaskIterator
{
protected:
Index32 mPos; // bit position
const NodeMask* mParent; // this iterator can't change the parent_mask!
public:
BaseMaskIterator(): mPos(NodeMask::SIZE), mParent(nullptr) {}
BaseMaskIterator(const BaseMaskIterator&) = default;
BaseMaskIterator(Index32 pos, const NodeMask* parent): mPos(pos), mParent(parent)
{
assert((parent == nullptr && pos == 0) || (parent != nullptr && pos <= NodeMask::SIZE));
}
bool operator==(const BaseMaskIterator &iter) const {return mPos == iter.mPos;}
bool operator!=(const BaseMaskIterator &iter) const {return mPos != iter.mPos;}
bool operator< (const BaseMaskIterator &iter) const {return mPos < iter.mPos;}
BaseMaskIterator& operator=(const BaseMaskIterator& iter)
{
mPos = iter.mPos; mParent = iter.mParent; return *this;
}
Index32 offset() const { return mPos; }
Index32 pos() const { return mPos; }
bool test() const { assert(mPos <= NodeMask::SIZE); return (mPos != NodeMask::SIZE); }
operator bool() const { return this->test(); }
}; // class BaseMaskIterator
/// @note This happens to be a const-iterator!
template <typename NodeMask>
class OnMaskIterator: public BaseMaskIterator<NodeMask>
{
private:
using BaseType = BaseMaskIterator<NodeMask>;
using BaseType::mPos;//bit position;
using BaseType::mParent;//this iterator can't change the parent_mask!
public:
OnMaskIterator() : BaseType() {}
OnMaskIterator(Index32 pos,const NodeMask *parent) : BaseType(pos,parent) {}
void increment()
{
assert(mParent != nullptr);
mPos = mParent->findNextOn(mPos+1);
assert(mPos <= NodeMask::SIZE);
}
void increment(Index n) { while(n-- && this->next()) ; }
bool next()
{
this->increment();
return this->test();
}
bool operator*() const {return true;}
OnMaskIterator& operator++()
{
this->increment();
return *this;
}
}; // class OnMaskIterator
template <typename NodeMask>
class OffMaskIterator: public BaseMaskIterator<NodeMask>
{
private:
using BaseType = BaseMaskIterator<NodeMask>;
using BaseType::mPos;//bit position;
using BaseType::mParent;//this iterator can't change the parent_mask!
public:
OffMaskIterator() : BaseType() {}
OffMaskIterator(Index32 pos,const NodeMask *parent) : BaseType(pos,parent) {}
void increment()
{
assert(mParent != nullptr);
mPos=mParent->findNextOff(mPos+1);
assert(mPos <= NodeMask::SIZE);
}
void increment(Index n) { while(n-- && this->next()) ; }
bool next()
{
this->increment();
return this->test();
}
bool operator*() const {return false;}
OffMaskIterator& operator++()
{
this->increment();
return *this;
}
}; // class OffMaskIterator
template <typename NodeMask>
class DenseMaskIterator: public BaseMaskIterator<NodeMask>
{
private:
using BaseType = BaseMaskIterator<NodeMask>;
using BaseType::mPos;//bit position;
using BaseType::mParent;//this iterator can't change the parent_mask!
public:
DenseMaskIterator() : BaseType() {}
DenseMaskIterator(Index32 pos,const NodeMask *parent) : BaseType(pos,parent) {}
void increment()
{
assert(mParent != nullptr);
mPos += 1;//careful - the increment might go beyond the end
assert(mPos<= NodeMask::SIZE);
}
void increment(Index n) { while(n-- && this->next()) ; }
bool next()
{
this->increment();
return this->test();
}
bool operator*() const {return mParent->isOn(mPos);}
DenseMaskIterator& operator++()
{
this->increment();
return *this;
}
}; // class DenseMaskIterator
/// @brief Bit mask for the internal and leaf nodes of VDB. This
/// is a 64-bit implementation.
///
/// @note A template specialization for Log2Dim=1 and Log2Dim=2 are
/// given below.
template<Index Log2Dim>
class NodeMask
{
public:
static_assert(Log2Dim > 2, "expected NodeMask template specialization, got base template");
static const Index32 LOG2DIM = Log2Dim;
static const Index32 DIM = 1<<Log2Dim;
static const Index32 SIZE = 1<<3*Log2Dim;
static const Index32 WORD_COUNT = SIZE >> 6;// 2^6=64
using Word = Index64;
private:
// The bits are represented as a linear array of Words, and the
// size of a Word is 32 or 64 bits depending on the platform.
// The BIT_MASK is defined as the number of bits in a Word - 1
//static const Index32 BIT_MASK = sizeof(void*) == 8 ? 63 : 31;
//static const Index32 LOG2WORD = BIT_MASK == 63 ? 6 : 5;
//static const Index32 WORD_COUNT = SIZE >> LOG2WORD;
//using Word = boost::mpl::if_c<BIT_MASK == 63, Index64, Index32>::type;
Word mWords[WORD_COUNT];//only member data!
public:
/// Default constructor sets all bits off
NodeMask() { this->setOff(); }
/// All bits are set to the specified state
NodeMask(bool on) { this->set(on); }
/// Copy constructor
NodeMask(const NodeMask &other) { *this = other; }
/// Destructor
~NodeMask() {}
/// Assignment operator
NodeMask& operator=(const NodeMask& other)
{
Index32 n = WORD_COUNT;
const Word* w2 = other.mWords;
for (Word* w1 = mWords; n--; ++w1, ++w2) *w1 = *w2;
return *this;
}
using OnIterator = OnMaskIterator<NodeMask>;
using OffIterator = OffMaskIterator<NodeMask>;
using DenseIterator = DenseMaskIterator<NodeMask>;
OnIterator beginOn() const { return OnIterator(this->findFirstOn(),this); }
OnIterator endOn() const { return OnIterator(SIZE,this); }
OffIterator beginOff() const { return OffIterator(this->findFirstOff(),this); }
OffIterator endOff() const { return OffIterator(SIZE,this); }
DenseIterator beginDense() const { return DenseIterator(0,this); }
DenseIterator endDense() const { return DenseIterator(SIZE,this); }
bool operator == (const NodeMask &other) const
{
int n = WORD_COUNT;
for (const Word *w1=mWords, *w2=other.mWords; n-- && *w1++ == *w2++;) ;
return n == -1;
}
bool operator != (const NodeMask &other) const { return !(*this == other); }
//
// Bitwise logical operations
//
/// @brief Apply a functor to the words of the this and the other mask.
///
/// @details An example that implements the "operator&=" method:
/// @code
/// struct Op { inline void operator()(W &w1, const W& w2) const { w1 &= w2; } };
/// @endcode
template<typename WordOp>
const NodeMask& foreach(const NodeMask& other, const WordOp& op)
{
Word *w1 = mWords;
const Word *w2 = other.mWords;
for (Index32 n = WORD_COUNT; n--; ++w1, ++w2) op( *w1, *w2);
return *this;
}
template<typename WordOp>
const NodeMask& foreach(const NodeMask& other1, const NodeMask& other2, const WordOp& op)
{
Word *w1 = mWords;
const Word *w2 = other1.mWords, *w3 = other2.mWords;
for (Index32 n = WORD_COUNT; n--; ++w1, ++w2, ++w3) op( *w1, *w2, *w3);
return *this;
}
template<typename WordOp>
const NodeMask& foreach(const NodeMask& other1, const NodeMask& other2, const NodeMask& other3,
const WordOp& op)
{
Word *w1 = mWords;
const Word *w2 = other1.mWords, *w3 = other2.mWords, *w4 = other3.mWords;
for (Index32 n = WORD_COUNT; n--; ++w1, ++w2, ++w3, ++w4) op( *w1, *w2, *w3, *w4);
return *this;
}
/// @brief Bitwise intersection
const NodeMask& operator&=(const NodeMask& other)
{
Word *w1 = mWords;
const Word *w2 = other.mWords;
for (Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= *w2;
return *this;
}
/// @brief Bitwise union
const NodeMask& operator|=(const NodeMask& other)
{
Word *w1 = mWords;
const Word *w2 = other.mWords;
for (Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 |= *w2;
return *this;
}
/// @brief Bitwise difference
const NodeMask& operator-=(const NodeMask& other)
{
Word *w1 = mWords;
const Word *w2 = other.mWords;
for (Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 &= ~*w2;
return *this;
}
/// @brief Bitwise XOR
const NodeMask& operator^=(const NodeMask& other)
{
Word *w1 = mWords;
const Word *w2 = other.mWords;
for (Index32 n = WORD_COUNT; n--; ++w1, ++w2) *w1 ^= *w2;
return *this;
}
NodeMask operator!() const { NodeMask m(*this); m.toggle(); return m; }
NodeMask operator&(const NodeMask& other) const { NodeMask m(*this); m &= other; return m; }
NodeMask operator|(const NodeMask& other) const { NodeMask m(*this); m |= other; return m; }
NodeMask operator^(const NodeMask& other) const { NodeMask m(*this); m ^= other; return m; }
/// Return the byte size of this NodeMask
static Index32 memUsage() { return static_cast<Index32>(WORD_COUNT*sizeof(Word)); }
/// Return the total number of on bits
Index32 countOn() const
{
Index32 sum = 0, n = WORD_COUNT;
for (const Word* w = mWords; n--; ++w) sum += CountOn(*w);
return sum;
}
/// Return the total number of on bits
Index32 countOff() const { return SIZE-this->countOn(); }
/// Set the <i>n</i>th bit on
void setOn(Index32 n) {
assert( (n >> 6) < WORD_COUNT );
mWords[n >> 6] |= Word(1) << (n & 63);
}
/// Set the <i>n</i>th bit off
void setOff(Index32 n) {
assert( (n >> 6) < WORD_COUNT );
mWords[n >> 6] &= ~(Word(1) << (n & 63));
}
/// Set the <i>n</i>th bit to the specified state
void set(Index32 n, bool On) { On ? this->setOn(n) : this->setOff(n); }
/// Set all bits to the specified state
void set(bool on)
{
const Word state = on ? ~Word(0) : Word(0);
Index32 n = WORD_COUNT;
for (Word* w = mWords; n--; ++w) *w = state;
}
/// Set all bits on
void setOn()
{
Index32 n = WORD_COUNT;
for (Word* w = mWords; n--; ++w) *w = ~Word(0);
}
/// Set all bits off
void setOff()
{
Index32 n = WORD_COUNT;
for (Word* w = mWords; n--; ++w) *w = Word(0);
}
/// Toggle the state of the <i>n</i>th bit
void toggle(Index32 n) {
assert( (n >> 6) < WORD_COUNT );
mWords[n >> 6] ^= Word(1) << (n & 63);
}
/// Toggle the state of all bits in the mask
void toggle()
{
Index32 n = WORD_COUNT;
for (Word* w = mWords; n--; ++w) *w = ~*w;
}
/// Set the first bit on
void setFirstOn() { this->setOn(0); }
/// Set the last bit on
void setLastOn() { this->setOn(SIZE-1); }
/// Set the first bit off
void setFirstOff() { this->setOff(0); }
/// Set the last bit off
void setLastOff() { this->setOff(SIZE-1); }
/// Return @c true if the <i>n</i>th bit is on
bool isOn(Index32 n) const
{
assert( (n >> 6) < WORD_COUNT );
return 0 != (mWords[n >> 6] & (Word(1) << (n & 63)));
}
/// Return @c true if the <i>n</i>th bit is off
bool isOff(Index32 n) const {return !this->isOn(n); }
/// Return @c true if all the bits are on
bool isOn() const
{
int n = WORD_COUNT;
for (const Word *w = mWords; n-- && *w++ == ~Word(0);) ;
return n == -1;
}
/// Return @c true if all the bits are off
bool isOff() const
{
int n = WORD_COUNT;
for (const Word *w = mWords; n-- && *w++ == Word(0);) ;
return n == -1;
}
/// Return @c true if bits are either all off OR all on.
/// @param isOn Takes on the values of all bits if the method
/// returns true - else it is undefined.
bool isConstant(bool &isOn) const
{
isOn = (mWords[0] == ~Word(0));//first word has all bits on
if ( !isOn && mWords[0] != Word(0)) return false;//early out
const Word *w = mWords + 1, *n = mWords + WORD_COUNT;
while( w<n && *w == mWords[0] ) ++w;
return w == n;
}
Index32 findFirstOn() const
{
Index32 n = 0;
const Word* w = mWords;
for (; n<WORD_COUNT && !*w; ++w, ++n) ;
return n==WORD_COUNT ? SIZE : (n << 6) + FindLowestOn(*w);
}
Index32 findFirstOff() const
{
Index32 n = 0;
const Word* w = mWords;
for (; n<WORD_COUNT && !~*w; ++w, ++n) ;
return n==WORD_COUNT ? SIZE : (n << 6) + FindLowestOn(~*w);
}
//@{
/// Return the <i>n</i>th word of the bit mask, for a word of arbitrary size.
template<typename WordT>
WordT getWord(Index n) const
{
assert(n*8*sizeof(WordT) < SIZE);
return reinterpret_cast<const WordT*>(mWords)[n];
}
template<typename WordT>
WordT& getWord(Index n)
{
assert(n*8*sizeof(WordT) < SIZE);
return reinterpret_cast<WordT*>(mWords)[n];
}
//@}
void save(std::ostream& os) const
{
os.write(reinterpret_cast<const char*>(mWords), this->memUsage());
}
void load(std::istream& is) { is.read(reinterpret_cast<char*>(mWords), this->memUsage()); }
void seek(std::istream& is) const { is.seekg(this->memUsage(), std::ios_base::cur); }
/// @brief simple print method for debugging
void printInfo(std::ostream& os=std::cout) const
{
os << "NodeMask: Dim=" << DIM << " Log2Dim=" << Log2Dim
<< " Bit count=" << SIZE << " word count=" << WORD_COUNT << std::endl;
}
void printBits(std::ostream& os=std::cout, Index32 max_out=80u) const
{
const Index32 n=(SIZE>max_out ? max_out : SIZE);
for (Index32 i=0; i < n; ++i) {
if ( !(i & 63) )
os << "||";
else if ( !(i%8) )
os << "|";
os << this->isOn(i);
}
os << "|" << std::endl;
}
void printAll(std::ostream& os=std::cout, Index32 max_out=80u) const
{
this->printInfo(os);
this->printBits(os, max_out);
}
Index32 findNextOn(Index32 start) const
{
Index32 n = start >> 6;//initiate
if (n >= WORD_COUNT) return SIZE; // check for out of bounds
Index32 m = start & 63;
Word b = mWords[n];
if (b & (Word(1) << m)) return start;//simpel case: start is on
b &= ~Word(0) << m;// mask out lower bits
while(!b && ++n<WORD_COUNT) b = mWords[n];// find next none-zero word
return (!b ? SIZE : (n << 6) + FindLowestOn(b));//catch last word=0
}
Index32 findNextOff(Index32 start) const
{
Index32 n = start >> 6;//initiate
if (n >= WORD_COUNT) return SIZE; // check for out of bounds
Index32 m = start & 63;
Word b = ~mWords[n];
if (b & (Word(1) << m)) return start;//simpel case: start is on
b &= ~Word(0) << m;// mask out lower bits
while(!b && ++n<WORD_COUNT) b = ~mWords[n];// find next none-zero word
return (!b ? SIZE : (n << 6) + FindLowestOn(b));//catch last word=0
}
};// NodeMask
/// @brief Template specialization of NodeMask for Log2Dim=1, i.e. 2^3 nodes
template<>
class NodeMask<1>
{
public:
static const Index32 LOG2DIM = 1;
static const Index32 DIM = 2;
static const Index32 SIZE = 8;
static const Index32 WORD_COUNT = 1;
using Word = Byte;
private:
Byte mByte;//only member data!
public:
/// Default constructor sets all bits off
NodeMask() : mByte(0x00U) {}
/// All bits are set to the specified state
NodeMask(bool on) : mByte(on ? 0xFFU : 0x00U) {}
/// Copy constructor
NodeMask(const NodeMask &other) : mByte(other.mByte) {}
/// Destructor
~NodeMask() {}
/// Assignment operator
void operator = (const NodeMask &other) { mByte = other.mByte; }
using OnIterator = OnMaskIterator<NodeMask>;
using OffIterator = OffMaskIterator<NodeMask>;
using DenseIterator = DenseMaskIterator<NodeMask>;
OnIterator beginOn() const { return OnIterator(this->findFirstOn(),this); }
OnIterator endOn() const { return OnIterator(SIZE,this); }
OffIterator beginOff() const { return OffIterator(this->findFirstOff(),this); }
OffIterator endOff() const { return OffIterator(SIZE,this); }
DenseIterator beginDense() const { return DenseIterator(0,this); }
DenseIterator endDense() const { return DenseIterator(SIZE,this); }
bool operator == (const NodeMask &other) const { return mByte == other.mByte; }
bool operator != (const NodeMask &other) const {return mByte != other.mByte; }
//
// Bitwise logical operations
//
/// @brief Apply a functor to the words of the this and the other mask.
///
/// @details An example that implements the "operator&=" method:
/// @code
/// struct Op { inline void operator()(Word &w1, const Word& w2) const { w1 &= w2; } };
/// @endcode
template<typename WordOp>
const NodeMask& foreach(const NodeMask& other, const WordOp& op)
{
op(mByte, other.mByte);
return *this;
}
template<typename WordOp>
const NodeMask& foreach(const NodeMask& other1, const NodeMask& other2, const WordOp& op)
{
op(mByte, other1.mByte, other2.mByte);
return *this;
}
template<typename WordOp>
const NodeMask& foreach(const NodeMask& other1, const NodeMask& other2, const NodeMask& other3,
const WordOp& op)
{
op(mByte, other1.mByte, other2.mByte, other3.mByte);
return *this;
}
/// @brief Bitwise intersection
const NodeMask& operator&=(const NodeMask& other)
{
mByte &= other.mByte;
return *this;
}
/// @brief Bitwise union
const NodeMask& operator|=(const NodeMask& other)
{
mByte |= other.mByte;
return *this;
}
/// @brief Bitwise difference
const NodeMask& operator-=(const NodeMask& other)
{
mByte &= static_cast<Byte>(~other.mByte);
return *this;
}
/// @brief Bitwise XOR
const NodeMask& operator^=(const NodeMask& other)
{
mByte ^= other.mByte;
return *this;
}
NodeMask operator!() const { NodeMask m(*this); m.toggle(); return m; }
NodeMask operator&(const NodeMask& other) const { NodeMask m(*this); m &= other; return m; }
NodeMask operator|(const NodeMask& other) const { NodeMask m(*this); m |= other; return m; }
NodeMask operator^(const NodeMask& other) const { NodeMask m(*this); m ^= other; return m; }
/// Return the byte size of this NodeMask
static Index32 memUsage() { return 1; }
/// Return the total number of on bits
Index32 countOn() const { return CountOn(mByte); }
/// Return the total number of on bits
Index32 countOff() const { return CountOff(mByte); }
/// Set the <i>n</i>th bit on
void setOn(Index32 n) {
assert( n < 8 );
mByte = static_cast<Byte>(mByte | 0x01U << (n & 7));
}
/// Set the <i>n</i>th bit off
void setOff(Index32 n) {
assert( n < 8 );
mByte = static_cast<Byte>(mByte & ~(0x01U << (n & 7)));
}
/// Set the <i>n</i>th bit to the specified state
void set(Index32 n, bool On) { On ? this->setOn(n) : this->setOff(n); }
/// Set all bits to the specified state
void set(bool on) { mByte = on ? 0xFFU : 0x00U; }
/// Set all bits on
void setOn() { mByte = 0xFFU; }
/// Set all bits off
void setOff() { mByte = 0x00U; }
/// Toggle the state of the <i>n</i>th bit
void toggle(Index32 n) {
assert( n < 8 );
mByte = static_cast<Byte>(mByte ^ 0x01U << (n & 7));
}
/// Toggle the state of all bits in the mask
void toggle() { mByte = static_cast<Byte>(~mByte); }
/// Set the first bit on
void setFirstOn() { this->setOn(0); }
/// Set the last bit on
void setLastOn() { this->setOn(7); }
/// Set the first bit off
void setFirstOff() { this->setOff(0); }
/// Set the last bit off
void setLastOff() { this->setOff(7); }
/// Return true if the <i>n</i>th bit is on
bool isOn(Index32 n) const
{
assert( n < 8 );
return mByte & (0x01U << (n & 7));
}
/// Return true if the <i>n</i>th bit is off
bool isOff(Index32 n) const {return !this->isOn(n); }
/// Return true if all the bits are on
bool isOn() const { return mByte == 0xFFU; }
/// Return true if all the bits are off
bool isOff() const { return mByte == 0; }
/// Return @c true if bits are either all off OR all on.
/// @param isOn Takes on the values of all bits if the method
/// returns true - else it is undefined.
bool isConstant(bool &isOn) const
{
isOn = this->isOn();
return isOn || this->isOff();
}
Index32 findFirstOn() const { return mByte ? FindLowestOn(mByte) : 8; }
Index32 findFirstOff() const
{
const Byte b = static_cast<Byte>(~mByte);
return b ? FindLowestOn(b) : 8;
}
/*
//@{
/// Return the <i>n</i>th word of the bit mask, for a word of arbitrary size.
/// @note This version assumes WordT=Byte and n=0!
template<typename WordT>
WordT getWord(Index n) const
{
static_assert(sizeof(WordT) == sizeof(Byte), "expected word size to be one byte");
assert(n == 0);
return reinterpret_cast<WordT>(mByte);
}
template<typename WordT>
WordT& getWord(Index n)
{
static_assert(sizeof(WordT) == sizeof(Byte), "expected word size to be one byte");
assert(n == 0);
return reinterpret_cast<WordT&>(mByte);
}
//@}
*/
void save(std::ostream& os) const { os.write(reinterpret_cast<const char*>(&mByte), 1); }
void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mByte), 1); }
void seek(std::istream& is) const { is.seekg(1, std::ios_base::cur); }
/// @brief simple print method for debugging
void printInfo(std::ostream& os=std::cout) const
{
os << "NodeMask: Dim=2, Log2Dim=1, Bit count=8, Word count=1"<<std::endl;
}
void printBits(std::ostream& os=std::cout) const
{
os << "||";
for (Index32 i=0; i < 8; ++i) os << this->isOn(i);
os << "||" << std::endl;
}
void printAll(std::ostream& os=std::cout) const
{
this->printInfo(os);
this->printBits(os);
}
Index32 findNextOn(Index32 start) const
{
if (start>=8) return 8;
const Byte b = static_cast<Byte>(mByte & (0xFFU << start));
return b ? FindLowestOn(b) : 8;
}
Index32 findNextOff(Index32 start) const
{
if (start>=8) return 8;
const Byte b = static_cast<Byte>(~mByte & (0xFFU << start));
return b ? FindLowestOn(b) : 8;
}
};// NodeMask<1>
/// @brief Template specialization of NodeMask for Log2Dim=2, i.e. 4^3 nodes
template<>
class NodeMask<2>
{
public:
static const Index32 LOG2DIM = 2;
static const Index32 DIM = 4;
static const Index32 SIZE = 64;
static const Index32 WORD_COUNT = 1;
using Word = Index64;
private:
Word mWord;//only member data!
public:
/// Default constructor sets all bits off
NodeMask() : mWord(UINT64_C(0x00)) {}
/// All bits are set to the specified state
NodeMask(bool on) : mWord(on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00)) {}
/// Copy constructor
NodeMask(const NodeMask &other) : mWord(other.mWord) {}
/// Destructor
~NodeMask() {}
/// Assignment operator
void operator = (const NodeMask &other) { mWord = other.mWord; }
using OnIterator = OnMaskIterator<NodeMask>;
using OffIterator = OffMaskIterator<NodeMask>;
using DenseIterator = DenseMaskIterator<NodeMask>;
OnIterator beginOn() const { return OnIterator(this->findFirstOn(),this); }
OnIterator endOn() const { return OnIterator(SIZE,this); }
OffIterator beginOff() const { return OffIterator(this->findFirstOff(),this); }
OffIterator endOff() const { return OffIterator(SIZE,this); }
DenseIterator beginDense() const { return DenseIterator(0,this); }
DenseIterator endDense() const { return DenseIterator(SIZE,this); }
bool operator == (const NodeMask &other) const { return mWord == other.mWord; }
bool operator != (const NodeMask &other) const {return mWord != other.mWord; }
//
// Bitwise logical operations
//
/// @brief Apply a functor to the words of the this and the other mask.
///
/// @details An example that implements the "operator&=" method:
/// @code
/// struct Op { inline void operator()(Word &w1, const Word& w2) const { w1 &= w2; } };
/// @endcode
template<typename WordOp>
const NodeMask& foreach(const NodeMask& other, const WordOp& op)
{
op(mWord, other.mWord);
return *this;
}
template<typename WordOp>
const NodeMask& foreach(const NodeMask& other1, const NodeMask& other2, const WordOp& op)
{
op(mWord, other1.mWord, other2.mWord);
return *this;
}
template<typename WordOp>
const NodeMask& foreach(const NodeMask& other1, const NodeMask& other2, const NodeMask& other3,
const WordOp& op)
{
op(mWord, other1.mWord, other2.mWord, other3.mWord);
return *this;
}
/// @brief Bitwise intersection
const NodeMask& operator&=(const NodeMask& other)
{
mWord &= other.mWord;
return *this;
}
/// @brief Bitwise union
const NodeMask& operator|=(const NodeMask& other)
{
mWord |= other.mWord;
return *this;
}
/// @brief Bitwise difference
const NodeMask& operator-=(const NodeMask& other)
{
mWord &= ~other.mWord;
return *this;
}
/// @brief Bitwise XOR
const NodeMask& operator^=(const NodeMask& other)
{
mWord ^= other.mWord;
return *this;
}
NodeMask operator!() const { NodeMask m(*this); m.toggle(); return m; }
NodeMask operator&(const NodeMask& other) const { NodeMask m(*this); m &= other; return m; }
NodeMask operator|(const NodeMask& other) const { NodeMask m(*this); m |= other; return m; }
NodeMask operator^(const NodeMask& other) const { NodeMask m(*this); m ^= other; return m; }
/// Return the byte size of this NodeMask
static Index32 memUsage() { return 8; }
/// Return the total number of on bits
Index32 countOn() const { return CountOn(mWord); }
/// Return the total number of on bits
Index32 countOff() const { return CountOff(mWord); }
/// Set the <i>n</i>th bit on
void setOn(Index32 n) {
assert( n < 64 );
mWord |= UINT64_C(0x01) << (n & 63);
}
/// Set the <i>n</i>th bit off
void setOff(Index32 n) {
assert( n < 64 );
mWord &= ~(UINT64_C(0x01) << (n & 63));
}
/// Set the <i>n</i>th bit to the specified state
void set(Index32 n, bool On) { On ? this->setOn(n) : this->setOff(n); }
/// Set all bits to the specified state
void set(bool on) { mWord = on ? UINT64_C(0xFFFFFFFFFFFFFFFF) : UINT64_C(0x00); }
/// Set all bits on
void setOn() { mWord = UINT64_C(0xFFFFFFFFFFFFFFFF); }
/// Set all bits off
void setOff() { mWord = UINT64_C(0x00); }
/// Toggle the state of the <i>n</i>th bit
void toggle(Index32 n) {
assert( n < 64 );
mWord ^= UINT64_C(0x01) << (n & 63);
}
/// Toggle the state of all bits in the mask
void toggle() { mWord = ~mWord; }
/// Set the first bit on
void setFirstOn() { this->setOn(0); }
/// Set the last bit on
void setLastOn() { this->setOn(63); }
/// Set the first bit off
void setFirstOff() { this->setOff(0); }
/// Set the last bit off
void setLastOff() { this->setOff(63); }
/// Return true if the <i>n</i>th bit is on
bool isOn(Index32 n) const
{
assert( n < 64 );
return 0 != (mWord & (UINT64_C(0x01) << (n & 63)));
}
/// Return true if the <i>n</i>th bit is off
bool isOff(Index32 n) const {return !this->isOn(n); }
/// Return true if all the bits are on
bool isOn() const { return mWord == UINT64_C(0xFFFFFFFFFFFFFFFF); }
/// Return true if all the bits are off
bool isOff() const { return mWord == 0; }
/// Return @c true if bits are either all off OR all on.
/// @param isOn Takes on the values of all bits if the method
/// returns true - else it is undefined.
bool isConstant(bool &isOn) const
{ isOn = this->isOn();
return isOn || this->isOff();
}
Index32 findFirstOn() const { return mWord ? FindLowestOn(mWord) : 64; }
Index32 findFirstOff() const
{
const Word w = ~mWord;
return w ? FindLowestOn(w) : 64;
}
//@{
/// Return the <i>n</i>th word of the bit mask, for a word of arbitrary size.
template<typename WordT>
WordT getWord(Index n) const
{
assert(n*8*sizeof(WordT) < SIZE);
return reinterpret_cast<const WordT*>(&mWord)[n];
}
template<typename WordT>
WordT& getWord(Index n)
{
assert(n*8*sizeof(WordT) < SIZE);
return reinterpret_cast<WordT*>(mWord)[n];
}
//@}
void save(std::ostream& os) const { os.write(reinterpret_cast<const char*>(&mWord), 8); }
void load(std::istream& is) { is.read(reinterpret_cast<char*>(&mWord), 8); }
void seek(std::istream& is) const { is.seekg(8, std::ios_base::cur); }
/// @brief simple print method for debugging
void printInfo(std::ostream& os=std::cout) const
{
os << "NodeMask: Dim=4, Log2Dim=2, Bit count=64, Word count=1"<<std::endl;
}
void printBits(std::ostream& os=std::cout) const
{
os << "|";
for (Index32 i=0; i < 64; ++i) {
if ( !(i%8) ) os << "|";
os << this->isOn(i);
}
os << "||" << std::endl;
}
void printAll(std::ostream& os=std::cout) const
{
this->printInfo(os);
this->printBits(os);
}
Index32 findNextOn(Index32 start) const
{
if (start>=64) return 64;
const Word w = mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
return w ? FindLowestOn(w) : 64;
}
Index32 findNextOff(Index32 start) const
{
if (start>=64) return 64;
const Word w = ~mWord & (UINT64_C(0xFFFFFFFFFFFFFFFF) << start);
return w ? FindLowestOn(w) : 64;
}
};// NodeMask<2>
// Unlike NodeMask above this RootNodeMask has a run-time defined size.
// It is only included for backward compatibility and will likely be
// deprecated in the future!
// This class is 32-bit specefic, hence the use if Index32 vs Index!
class RootNodeMask
{
protected:
Index32 mBitSize, mIntSize;
Index32 *mBits;
public:
RootNodeMask(): mBitSize(0), mIntSize(0), mBits(nullptr) {}
RootNodeMask(Index32 bit_size):
mBitSize(bit_size), mIntSize(((bit_size-1)>>5)+1), mBits(new Index32[mIntSize])
{
for (Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
}
RootNodeMask(const RootNodeMask& B):
mBitSize(B.mBitSize), mIntSize(B.mIntSize), mBits(new Index32[mIntSize])
{
for (Index32 i=0; i<mIntSize; ++i) mBits[i]=B.mBits[i];
}
~RootNodeMask() {delete [] mBits;}
void init(Index32 bit_size) {
mBitSize = bit_size;
mIntSize =((bit_size-1)>>5)+1;
delete [] mBits;
mBits = new Index32[mIntSize];
for (Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
}
Index getBitSize() const {return mBitSize;}
Index getIntSize() const {return mIntSize;}
RootNodeMask& operator=(const RootNodeMask& B) {
if (mBitSize!=B.mBitSize) {
mBitSize=B.mBitSize;
mIntSize=B.mIntSize;
delete [] mBits;
mBits = new Index32[mIntSize];
}
for (Index32 i=0; i<mIntSize; ++i) mBits[i]=B.mBits[i];
return *this;
}
class BaseIterator
{
protected:
Index32 mPos;//bit position
Index32 mBitSize;
const RootNodeMask* mParent;//this iterator can't change the parent_mask!
public:
BaseIterator() : mPos(0), mBitSize(0), mParent(nullptr) {}
BaseIterator(const BaseIterator&) = default;
BaseIterator(Index32 pos, const RootNodeMask* parent):
mPos(pos), mBitSize(parent->getBitSize()), mParent(parent) { assert(pos <= mBitSize); }
bool operator==(const BaseIterator &iter) const {return mPos == iter.mPos;}
bool operator!=(const BaseIterator &iter) const {return mPos != iter.mPos;}
bool operator< (const BaseIterator &iter) const {return mPos < iter.mPos;}
BaseIterator& operator=(const BaseIterator& iter) {
mPos = iter.mPos;
mBitSize = iter.mBitSize;
mParent = iter.mParent;
return *this;
}
Index32 offset() const {return mPos;}
Index32 pos() const {return mPos;}
bool test() const {
assert(mPos <= mBitSize);
return (mPos != mBitSize);
}
operator bool() const {return this->test();}
}; // class BaseIterator
/// @note This happens to be a const-iterator!
class OnIterator: public BaseIterator
{
protected:
using BaseIterator::mPos;//bit position;
using BaseIterator::mBitSize;//bit size;
using BaseIterator::mParent;//this iterator can't change the parent_mask!
public:
OnIterator() : BaseIterator() {}
OnIterator(Index32 pos,const RootNodeMask *parent) : BaseIterator(pos,parent) {}
void increment() {
assert(mParent != nullptr);
mPos=mParent->findNextOn(mPos+1);
assert(mPos <= mBitSize);
}
void increment(Index n) {
for (Index i=0; i<n && this->next(); ++i) {}
}
bool next() {
this->increment();
return this->test();
}
bool operator*() const {return true;}
OnIterator& operator++() {
this->increment();
return *this;
}
}; // class OnIterator
class OffIterator: public BaseIterator
{
protected:
using BaseIterator::mPos;//bit position;
using BaseIterator::mBitSize;//bit size;
using BaseIterator::mParent;//this iterator can't change the parent_mask!
public:
OffIterator() : BaseIterator() {}
OffIterator(Index32 pos,const RootNodeMask *parent) : BaseIterator(pos,parent) {}
void increment() {
assert(mParent != nullptr);
mPos=mParent->findNextOff(mPos+1);
assert(mPos <= mBitSize);
}
void increment(Index n) {
for (Index i=0; i<n && this->next(); ++i) {}
}
bool next() {
this->increment();
return this->test();
}
bool operator*() const {return true;}
OffIterator& operator++() {
this->increment();
return *this;
}
}; // class OffIterator
class DenseIterator: public BaseIterator
{
protected:
using BaseIterator::mPos;//bit position;
using BaseIterator::mBitSize;//bit size;
using BaseIterator::mParent;//this iterator can't change the parent_mask!
public:
DenseIterator() : BaseIterator() {}
DenseIterator(Index32 pos,const RootNodeMask *parent) : BaseIterator(pos,parent) {}
void increment() {
assert(mParent != nullptr);
mPos += 1;//carefull - the increament might go beyond the end
assert(mPos<= mBitSize);
}
void increment(Index n) {
for (Index i=0; i<n && this->next(); ++i) {}
}
bool next() {
this->increment();
return this->test();
}
bool operator*() const {return mParent->isOn(mPos);}
DenseIterator& operator++() {
this->increment();
return *this;
}
}; // class DenseIterator
OnIterator beginOn() const { return OnIterator(this->findFirstOn(),this); }
OnIterator endOn() const { return OnIterator(mBitSize,this); }
OffIterator beginOff() const { return OffIterator(this->findFirstOff(),this); }
OffIterator endOff() const { return OffIterator(mBitSize,this); }
DenseIterator beginDense() const { return DenseIterator(0,this); }
DenseIterator endDense() const { return DenseIterator(mBitSize,this); }
bool operator == (const RootNodeMask &B) const {
if (mBitSize != B.mBitSize) return false;
for (Index32 i=0; i<mIntSize; ++i) if (mBits[i] != B.mBits[i]) return false;
return true;
}
bool operator != (const RootNodeMask &B) const {
if (mBitSize != B.mBitSize) return true;
for (Index32 i=0; i<mIntSize; ++i) if (mBits[i] != B.mBits[i]) return true;
return false;
}
//
// Bitwise logical operations
//
RootNodeMask operator!() const { RootNodeMask m = *this; m.toggle(); return m; }
const RootNodeMask& operator&=(const RootNodeMask& other) {
assert(mIntSize == other.mIntSize);
for (Index32 i = 0, N = std::min(mIntSize, other.mIntSize); i < N; ++i) {
mBits[i] &= other.mBits[i];
}
for (Index32 i = other.mIntSize; i < mIntSize; ++i) mBits[i] = 0x00000000;
return *this;
}
const RootNodeMask& operator|=(const RootNodeMask& other) {
assert(mIntSize == other.mIntSize);
for (Index32 i = 0, N = std::min(mIntSize, other.mIntSize); i < N; ++i) {
mBits[i] |= other.mBits[i];
}
return *this;
}
const RootNodeMask& operator^=(const RootNodeMask& other) {
assert(mIntSize == other.mIntSize);
for (Index32 i = 0, N = std::min(mIntSize, other.mIntSize); i < N; ++i) {
mBits[i] ^= other.mBits[i];
}
return *this;
}
RootNodeMask operator&(const RootNodeMask& other) const {
RootNodeMask m(*this); m &= other; return m;
}
RootNodeMask operator|(const RootNodeMask& other) const {
RootNodeMask m(*this); m |= other; return m;
}
RootNodeMask operator^(const RootNodeMask& other) const {
RootNodeMask m(*this); m ^= other; return m;
}
Index32 getMemUsage() const {
return static_cast<Index32>(mIntSize*sizeof(Index32) + sizeof(*this));
}
Index32 countOn() const {
assert(mBits);
Index32 n=0;
for (Index32 i=0; i< mIntSize; ++i) n += CountOn(mBits[i]);
return n;
}
Index32 countOff() const { return mBitSize-this->countOn(); }
void setOn(Index32 i) {
assert(mBits);
assert( (i>>5) < mIntSize);
mBits[i>>5] |= 1<<(i&31);
}
void setOff(Index32 i) {
assert(mBits);
assert( (i>>5) < mIntSize);
mBits[i>>5] &= ~(1<<(i&31));
}
void set(Index32 i, bool On) { On ? this->setOn(i) : this->setOff(i); }
void setOn() {
assert(mBits);
for (Index32 i=0; i<mIntSize; ++i) mBits[i]=0xFFFFFFFF;
}
void setOff() {
assert(mBits);
for (Index32 i=0; i<mIntSize; ++i) mBits[i]=0x00000000;
}
void toggle(Index32 i) {
assert(mBits);
assert( (i>>5) < mIntSize);
mBits[i>>5] ^= 1<<(i&31);
}
void toggle() {
assert(mBits);
for (Index32 i=0; i<mIntSize; ++i) mBits[i]=~mBits[i];
}
void setFirstOn() { this->setOn(0); }
void setLastOn() { this->setOn(mBitSize-1); }
void setFirstOff() { this->setOff(0); }
void setLastOff() { this->setOff(mBitSize-1); }
bool isOn(Index32 i) const {
assert(mBits);
assert( (i>>5) < mIntSize);
return ( mBits[i >> 5] & (1<<(i&31)) );
}
bool isOff(Index32 i) const {
assert(mBits);
assert( (i>>5) < mIntSize);
return ( ~mBits[i >> 5] & (1<<(i&31)) );
}
bool isOn() const {
if (!mBits) return false;//undefined is off
for (Index32 i=0; i<mIntSize; ++i) if (mBits[i] != 0xFFFFFFFF) return false;
return true;
}
bool isOff() const {
if (!mBits) return true;//undefined is off
for (Index32 i=0; i<mIntSize; ++i) if (mBits[i] != 0) return false;
return true;
}
Index32 findFirstOn() const {
assert(mBits);
Index32 i=0;
while(!mBits[i]) if (++i == mIntSize) return mBitSize;//reached end
return 32*i + FindLowestOn(mBits[i]);
}
Index32 findFirstOff() const {
assert(mBits);
Index32 i=0;
while(!(~mBits[i])) if (++i == mIntSize) return mBitSize;//reached end
return 32*i + FindLowestOn(~mBits[i]);
}
void save(std::ostream& os) const {
assert(mBits);
os.write(reinterpret_cast<const char*>(mBits), mIntSize * sizeof(Index32));
}
void load(std::istream& is) {
assert(mBits);
is.read(reinterpret_cast<char*>(mBits), mIntSize * sizeof(Index32));
}
void seek(std::istream& is) const {
assert(mBits);
is.seekg(mIntSize * sizeof(Index32), std::ios_base::cur);
}
/// @brief simple print method for debugging
void printInfo(std::ostream& os=std::cout) const {
os << "RootNodeMask: Bit-size="<<mBitSize<<" Int-size="<<mIntSize<<std::endl;
}
void printBits(std::ostream& os=std::cout, Index32 max_out=80u) const {
const Index32 n=(mBitSize>max_out?max_out:mBitSize);
for (Index32 i=0; i < n; ++i) {
if ( !(i&31) )
os << "||";
else if ( !(i%8) )
os << "|";
os << this->isOn(i);
}
os << "|" << std::endl;
}
void printAll(std::ostream& os=std::cout, Index32 max_out=80u) const {
this->printInfo(os);
this->printBits(os,max_out);
}
Index32 findNextOn(Index32 start) const {
assert(mBits);
Index32 n = start >> 5, m = start & 31;//initiate
if (n>=mIntSize) return mBitSize; // check for out of bounds
Index32 b = mBits[n];
if (b & (1<<m)) return start;//simple case
b &= 0xFFFFFFFF << m;// mask lower bits
while(!b && ++n<mIntSize) b = mBits[n];// find next nonzero int
return (!b ? mBitSize : 32*n + FindLowestOn(b));//catch last-int=0
}
Index32 findNextOff(Index32 start) const {
assert(mBits);
Index32 n = start >> 5, m = start & 31;//initiate
if (n>=mIntSize) return mBitSize; // check for out of bounds
Index32 b = ~mBits[n];
if (b & (1<<m)) return start;//simple case
b &= 0xFFFFFFFF<<m;// mask lower bits
while(!b && ++n<mIntSize) b = ~mBits[n];// find next nonzero int
return (!b ? mBitSize : 32*n + FindLowestOn(b));//catch last-int=0
}
Index32 memUsage() const {
assert(mBits);
return static_cast<Index32>(sizeof(Index32*)+(2+mIntSize)*sizeof(Index32));//in bytes
}
}; // class RootNodeMask
} // namespace util
} // namespace OPENVDB_VERSION_NAME
} // namespace openvdb
#endif // OPENVDB_UTIL_NODEMASKS_HAS_BEEN_INCLUDED
COUNTONB6
#define COUNTONB6(n)
Platform.h
openvdb::v10_0::util::BaseMaskIterator::operator==
bool operator==(const BaseMaskIterator &iter) const
Definition NodeMasks.h:192
openvdb::v10_0::util::BaseMaskIterator::test
bool test() const
Definition NodeMasks.h:201
openvdb::v10_0::util::BaseMaskIterator::BaseMaskIterator
BaseMaskIterator(const BaseMaskIterator &)=default
openvdb::v10_0::util::BaseMaskIterator::operator!=
bool operator!=(const BaseMaskIterator &iter) const
Definition NodeMasks.h:193
openvdb::v10_0::util::BaseMaskIterator::BaseMaskIterator
BaseMaskIterator()
Definition NodeMasks.h:186
openvdb::v10_0::util::BaseMaskIterator::mPos
Index32 mPos
Definition NodeMasks.h:182
openvdb::v10_0::util::BaseMaskIterator::pos
Index32 pos() const
Definition NodeMasks.h:200
openvdb::v10_0::util::BaseMaskIterator::BaseMaskIterator
BaseMaskIterator(Index32 pos, const NodeMask *parent)
Definition NodeMasks.h:188
openvdb::v10_0::util::BaseMaskIterator::offset
Index32 offset() const
Definition NodeMasks.h:199
openvdb::v10_0::util::BaseMaskIterator::mParent
const NodeMask * mParent
Definition NodeMasks.h:183
openvdb::v10_0::util::BaseMaskIterator::operator=
BaseMaskIterator & operator=(const BaseMaskIterator &iter)
Definition NodeMasks.h:195
openvdb::v10_0::util::DenseMaskIterator
Definition NodeMasks.h:271
openvdb::v10_0::util::DenseMaskIterator::operator++
DenseMaskIterator & operator++()
Definition NodeMasks.h:293
openvdb::v10_0::util::DenseMaskIterator::operator*
bool operator*() const
Definition NodeMasks.h:292
openvdb::v10_0::util::DenseMaskIterator::DenseMaskIterator
DenseMaskIterator()
Definition NodeMasks.h:278
openvdb::v10_0::util::DenseMaskIterator::DenseMaskIterator
DenseMaskIterator(Index32 pos, const NodeMask *parent)
Definition NodeMasks.h:279
openvdb::v10_0::util::DenseMaskIterator::next
bool next()
Definition NodeMasks.h:287
openvdb::v10_0::util::DenseMaskIterator::increment
void increment(Index n)
Definition NodeMasks.h:286
openvdb::v10_0::util::DenseMaskIterator::increment
void increment()
Definition NodeMasks.h:280
openvdb::v10_0::util::NodeMask< 1 >::operator^=
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition NodeMasks.h:712
openvdb::v10_0::util::NodeMask< 1 >::isOff
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition NodeMasks.h:767
openvdb::v10_0::util::NodeMask< 1 >::operator|
NodeMask operator|(const NodeMask &other) const
Definition NodeMasks.h:719
openvdb::v10_0::util::NodeMask< 1 >::operator&=
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition NodeMasks.h:694
openvdb::v10_0::util::NodeMask< 1 >::countOn
Index32 countOn() const
Return the total number of on bits.
Definition NodeMasks.h:724
openvdb::v10_0::util::NodeMask< 1 >::operator-=
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition NodeMasks.h:706
openvdb::v10_0::util::NodeMask< 1 >::printAll
void printAll(std::ostream &os=std::cout) const
Definition NodeMasks.h:820
openvdb::v10_0::util::NodeMask< 1 >::beginOn
OnIterator beginOn() const
Definition NodeMasks.h:653
openvdb::v10_0::util::NodeMask< 1 >::operator^
NodeMask operator^(const NodeMask &other) const
Definition NodeMasks.h:720
openvdb::v10_0::util::NodeMask< 1 >::endDense
DenseIterator endDense() const
Definition NodeMasks.h:658
openvdb::v10_0::util::NodeMask< 1 >::beginDense
DenseIterator beginDense() const
Definition NodeMasks.h:657
openvdb::v10_0::util::NodeMask< 1 >::beginOff
OffIterator beginOff() const
Definition NodeMasks.h:655
openvdb::v10_0::util::NodeMask< 1 >::set
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition NodeMasks.h:738
openvdb::v10_0::util::NodeMask< 1 >::setOn
void setOn()
Set all bits on.
Definition NodeMasks.h:742
openvdb::v10_0::util::NodeMask< 1 >::DenseIterator
DenseMaskIterator< NodeMask > DenseIterator
Definition NodeMasks.h:651
openvdb::v10_0::util::NodeMask< 1 >::isOn
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition NodeMasks.h:761
openvdb::v10_0::util::NodeMask< 1 >::printBits
void printBits(std::ostream &os=std::cout) const
Definition NodeMasks.h:814
openvdb::v10_0::util::NodeMask< 1 >::isConstant
bool isConstant(bool &isOn) const
Definition NodeMasks.h:775
openvdb::v10_0::util::NodeMask< 1 >::WORD_COUNT
static const Index32 WORD_COUNT
Definition NodeMasks.h:630
openvdb::v10_0::util::NodeMask< 1 >::countOff
Index32 countOff() const
Return the total number of on bits.
Definition NodeMasks.h:726
openvdb::v10_0::util::NodeMask< 1 >::toggle
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition NodeMasks.h:746
openvdb::v10_0::util::NodeMask< 1 >::setLastOff
void setLastOff()
Set the last bit off.
Definition NodeMasks.h:759
openvdb::v10_0::util::NodeMask< 1 >::NodeMask
NodeMask(bool on)
All bits are set to the specified state.
Definition NodeMasks.h:641
openvdb::v10_0::util::NodeMask< 1 >::findNextOff
Index32 findNextOff(Index32 start) const
Definition NodeMasks.h:833
openvdb::v10_0::util::NodeMask< 1 >::seek
void seek(std::istream &is) const
Definition NodeMasks.h:808
openvdb::v10_0::util::NodeMask< 1 >::setFirstOff
void setFirstOff()
Set the first bit off.
Definition NodeMasks.h:757
openvdb::v10_0::util::NodeMask< 1 >::OnIterator
OnMaskIterator< NodeMask > OnIterator
Definition NodeMasks.h:649
openvdb::v10_0::util::NodeMask< 1 >::set
void set(bool on)
Set all bits to the specified state.
Definition NodeMasks.h:740
openvdb::v10_0::util::NodeMask< 1 >::operator!
NodeMask operator!() const
Definition NodeMasks.h:717
openvdb::v10_0::util::NodeMask< 1 >::SIZE
static const Index32 SIZE
Definition NodeMasks.h:629
openvdb::v10_0::util::NodeMask< 1 >::setFirstOn
void setFirstOn()
Set the first bit on.
Definition NodeMasks.h:753
openvdb::v10_0::util::NodeMask< 1 >::DIM
static const Index32 DIM
Definition NodeMasks.h:628
openvdb::v10_0::util::NodeMask< 1 >::endOn
OnIterator endOn() const
Definition NodeMasks.h:654
openvdb::v10_0::util::NodeMask< 1 >::load
void load(std::istream &is)
Definition NodeMasks.h:807
openvdb::v10_0::util::NodeMask< 1 >::operator|=
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition NodeMasks.h:700
openvdb::v10_0::util::NodeMask< 1 >::save
void save(std::ostream &os) const
Definition NodeMasks.h:806
openvdb::v10_0::util::NodeMask< 1 >::findFirstOff
Index32 findFirstOff() const
Definition NodeMasks.h:781
openvdb::v10_0::util::NodeMask< 1 >::memUsage
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition NodeMasks.h:722
openvdb::v10_0::util::NodeMask< 1 >::setOff
void setOff()
Set all bits off.
Definition NodeMasks.h:744
openvdb::v10_0::util::NodeMask< 1 >::setOff
void setOff(Index32 n)
Set the nth bit off.
Definition NodeMasks.h:733
openvdb::v10_0::util::NodeMask< 1 >::setOn
void setOn(Index32 n)
Set the nth bit on.
Definition NodeMasks.h:728
openvdb::v10_0::util::NodeMask< 1 >::operator&
NodeMask operator&(const NodeMask &other) const
Definition NodeMasks.h:718
openvdb::v10_0::util::NodeMask< 1 >::isOff
bool isOff() const
Return true if all the bits are off.
Definition NodeMasks.h:771
openvdb::v10_0::util::NodeMask< 1 >::LOG2DIM
static const Index32 LOG2DIM
Definition NodeMasks.h:627
openvdb::v10_0::util::NodeMask< 1 >::NodeMask
NodeMask()
Default constructor sets all bits off.
Definition NodeMasks.h:639
openvdb::v10_0::util::NodeMask< 1 >::NodeMask
NodeMask(const NodeMask &other)
Copy constructor.
Definition NodeMasks.h:643
openvdb::v10_0::util::NodeMask< 1 >::Word
Byte Word
Definition NodeMasks.h:631
openvdb::v10_0::util::NodeMask< 1 >::toggle
void toggle()
Toggle the state of all bits in the mask.
Definition NodeMasks.h:751
openvdb::v10_0::util::NodeMask< 1 >::printInfo
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition NodeMasks.h:810
openvdb::v10_0::util::NodeMask< 1 >::OffIterator
OffMaskIterator< NodeMask > OffIterator
Definition NodeMasks.h:650
openvdb::v10_0::util::NodeMask< 1 >::findNextOn
Index32 findNextOn(Index32 start) const
Definition NodeMasks.h:826
openvdb::v10_0::util::NodeMask< 1 >::setLastOn
void setLastOn()
Set the last bit on.
Definition NodeMasks.h:755
openvdb::v10_0::util::NodeMask< 1 >::~NodeMask
~NodeMask()
Destructor.
Definition NodeMasks.h:645
openvdb::v10_0::util::NodeMask< 1 >::endOff
OffIterator endOff() const
Definition NodeMasks.h:656
openvdb::v10_0::util::NodeMask< 1 >::isOn
bool isOn() const
Return true if all the bits are on.
Definition NodeMasks.h:769
openvdb::v10_0::util::NodeMask< 1 >::findFirstOn
Index32 findFirstOn() const
Definition NodeMasks.h:780
openvdb::v10_0::util::NodeMask< 2 >::operator^=
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition NodeMasks.h:934
openvdb::v10_0::util::NodeMask< 2 >::isOff
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition NodeMasks.h:989
openvdb::v10_0::util::NodeMask< 2 >::operator|
NodeMask operator|(const NodeMask &other) const
Definition NodeMasks.h:941
openvdb::v10_0::util::NodeMask< 2 >::operator&=
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition NodeMasks.h:916
openvdb::v10_0::util::NodeMask< 2 >::countOn
Index32 countOn() const
Return the total number of on bits.
Definition NodeMasks.h:946
openvdb::v10_0::util::NodeMask< 2 >::operator-=
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition NodeMasks.h:928
openvdb::v10_0::util::NodeMask< 2 >::Word
Index64 Word
Definition NodeMasks.h:853
openvdb::v10_0::util::NodeMask< 2 >::printAll
void printAll(std::ostream &os=std::cout) const
Definition NodeMasks.h:1039
openvdb::v10_0::util::NodeMask< 2 >::beginOn
OnIterator beginOn() const
Definition NodeMasks.h:875
openvdb::v10_0::util::NodeMask< 2 >::getWord
WordT & getWord(Index n)
Definition NodeMasks.h:1016
openvdb::v10_0::util::NodeMask< 2 >::operator^
NodeMask operator^(const NodeMask &other) const
Definition NodeMasks.h:942
openvdb::v10_0::util::NodeMask< 2 >::endDense
DenseIterator endDense() const
Definition NodeMasks.h:880
openvdb::v10_0::util::NodeMask< 2 >::beginDense
DenseIterator beginDense() const
Definition NodeMasks.h:879
openvdb::v10_0::util::NodeMask< 2 >::beginOff
OffIterator beginOff() const
Definition NodeMasks.h:877
openvdb::v10_0::util::NodeMask< 2 >::set
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition NodeMasks.h:960
openvdb::v10_0::util::NodeMask< 2 >::setOn
void setOn()
Set all bits on.
Definition NodeMasks.h:964
openvdb::v10_0::util::NodeMask< 2 >::DenseIterator
DenseMaskIterator< NodeMask > DenseIterator
Definition NodeMasks.h:873
openvdb::v10_0::util::NodeMask< 2 >::isOn
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition NodeMasks.h:983
openvdb::v10_0::util::NodeMask< 2 >::printBits
void printBits(std::ostream &os=std::cout) const
Definition NodeMasks.h:1030
openvdb::v10_0::util::NodeMask< 2 >::isConstant
bool isConstant(bool &isOn) const
Definition NodeMasks.h:997
openvdb::v10_0::util::NodeMask< 2 >::WORD_COUNT
static const Index32 WORD_COUNT
Definition NodeMasks.h:852
openvdb::v10_0::util::NodeMask< 2 >::countOff
Index32 countOff() const
Return the total number of on bits.
Definition NodeMasks.h:948
openvdb::v10_0::util::NodeMask< 2 >::toggle
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition NodeMasks.h:968
openvdb::v10_0::util::NodeMask< 2 >::setLastOff
void setLastOff()
Set the last bit off.
Definition NodeMasks.h:981
openvdb::v10_0::util::NodeMask< 2 >::NodeMask
NodeMask(bool on)
All bits are set to the specified state.
Definition NodeMasks.h:863
openvdb::v10_0::util::NodeMask< 2 >::getWord
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition NodeMasks.h:1010
openvdb::v10_0::util::NodeMask< 2 >::findNextOff
Index32 findNextOff(Index32 start) const
Definition NodeMasks.h:1052
openvdb::v10_0::util::NodeMask< 2 >::seek
void seek(std::istream &is) const
Definition NodeMasks.h:1024
openvdb::v10_0::util::NodeMask< 2 >::setFirstOff
void setFirstOff()
Set the first bit off.
Definition NodeMasks.h:979
openvdb::v10_0::util::NodeMask< 2 >::OnIterator
OnMaskIterator< NodeMask > OnIterator
Definition NodeMasks.h:871
openvdb::v10_0::util::NodeMask< 2 >::set
void set(bool on)
Set all bits to the specified state.
Definition NodeMasks.h:962
openvdb::v10_0::util::NodeMask< 2 >::operator!
NodeMask operator!() const
Definition NodeMasks.h:939
openvdb::v10_0::util::NodeMask< 2 >::SIZE
static const Index32 SIZE
Definition NodeMasks.h:851
openvdb::v10_0::util::NodeMask< 2 >::setFirstOn
void setFirstOn()
Set the first bit on.
Definition NodeMasks.h:975
openvdb::v10_0::util::NodeMask< 2 >::DIM
static const Index32 DIM
Definition NodeMasks.h:850
openvdb::v10_0::util::NodeMask< 2 >::endOn
OnIterator endOn() const
Definition NodeMasks.h:876
openvdb::v10_0::util::NodeMask< 2 >::load
void load(std::istream &is)
Definition NodeMasks.h:1023
openvdb::v10_0::util::NodeMask< 2 >::operator|=
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition NodeMasks.h:922
openvdb::v10_0::util::NodeMask< 2 >::save
void save(std::ostream &os) const
Definition NodeMasks.h:1022
openvdb::v10_0::util::NodeMask< 2 >::findFirstOff
Index32 findFirstOff() const
Definition NodeMasks.h:1002
openvdb::v10_0::util::NodeMask< 2 >::memUsage
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition NodeMasks.h:944
openvdb::v10_0::util::NodeMask< 2 >::setOff
void setOff()
Set all bits off.
Definition NodeMasks.h:966
openvdb::v10_0::util::NodeMask< 2 >::setOff
void setOff(Index32 n)
Set the nth bit off.
Definition NodeMasks.h:955
openvdb::v10_0::util::NodeMask< 2 >::setOn
void setOn(Index32 n)
Set the nth bit on.
Definition NodeMasks.h:950
openvdb::v10_0::util::NodeMask< 2 >::operator&
NodeMask operator&(const NodeMask &other) const
Definition NodeMasks.h:940
openvdb::v10_0::util::NodeMask< 2 >::isOff
bool isOff() const
Return true if all the bits are off.
Definition NodeMasks.h:993
openvdb::v10_0::util::NodeMask< 2 >::LOG2DIM
static const Index32 LOG2DIM
Definition NodeMasks.h:849
openvdb::v10_0::util::NodeMask< 2 >::NodeMask
NodeMask()
Default constructor sets all bits off.
Definition NodeMasks.h:861
openvdb::v10_0::util::NodeMask< 2 >::NodeMask
NodeMask(const NodeMask &other)
Copy constructor.
Definition NodeMasks.h:865
openvdb::v10_0::util::NodeMask< 2 >::toggle
void toggle()
Toggle the state of all bits in the mask.
Definition NodeMasks.h:973
openvdb::v10_0::util::NodeMask< 2 >::printInfo
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition NodeMasks.h:1026
openvdb::v10_0::util::NodeMask< 2 >::OffIterator
OffMaskIterator< NodeMask > OffIterator
Definition NodeMasks.h:872
openvdb::v10_0::util::NodeMask< 2 >::findNextOn
Index32 findNextOn(Index32 start) const
Definition NodeMasks.h:1045
openvdb::v10_0::util::NodeMask< 2 >::setLastOn
void setLastOn()
Set the last bit on.
Definition NodeMasks.h:977
openvdb::v10_0::util::NodeMask< 2 >::~NodeMask
~NodeMask()
Destructor.
Definition NodeMasks.h:867
openvdb::v10_0::util::NodeMask< 2 >::endOff
OffIterator endOff() const
Definition NodeMasks.h:878
openvdb::v10_0::util::NodeMask< 2 >::isOn
bool isOn() const
Return true if all the bits are on.
Definition NodeMasks.h:991
openvdb::v10_0::util::NodeMask< 2 >::findFirstOn
Index32 findFirstOn() const
Definition NodeMasks.h:1001
openvdb::v10_0::util::NodeMask
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation.
Definition NodeMasks.h:308
openvdb::v10_0::util::NodeMask::operator^=
const NodeMask & operator^=(const NodeMask &other)
Bitwise XOR.
Definition NodeMasks.h:428
openvdb::v10_0::util::NodeMask::isOff
bool isOff(Index32 n) const
Return true if the nth bit is off.
Definition NodeMasks.h:508
openvdb::v10_0::util::NodeMask::operator|
NodeMask operator|(const NodeMask &other) const
Definition NodeMasks.h:437
openvdb::v10_0::util::NodeMask::operator&=
const NodeMask & operator&=(const NodeMask &other)
Bitwise intersection.
Definition NodeMasks.h:404
openvdb::v10_0::util::NodeMask::countOn
Index32 countOn() const
Return the total number of on bits.
Definition NodeMasks.h:443
openvdb::v10_0::util::NodeMask::operator-=
const NodeMask & operator-=(const NodeMask &other)
Bitwise difference.
Definition NodeMasks.h:420
openvdb::v10_0::util::NodeMask::Word
Index64 Word
Definition NodeMasks.h:316
openvdb::v10_0::util::NodeMask::beginOn
OnIterator beginOn() const
Definition NodeMasks.h:352
openvdb::v10_0::util::NodeMask::getWord
WordT & getWord(Index n)
Definition NodeMasks.h:558
openvdb::v10_0::util::NodeMask::operator^
NodeMask operator^(const NodeMask &other) const
Definition NodeMasks.h:438
openvdb::v10_0::util::NodeMask::endDense
DenseIterator endDense() const
Definition NodeMasks.h:357
openvdb::v10_0::util::NodeMask::beginDense
DenseIterator beginDense() const
Definition NodeMasks.h:356
openvdb::v10_0::util::NodeMask::beginOff
OffIterator beginOff() const
Definition NodeMasks.h:354
openvdb::v10_0::util::NodeMask::set
void set(Index32 n, bool On)
Set the nth bit to the specified state.
Definition NodeMasks.h:462
openvdb::v10_0::util::NodeMask::setOn
void setOn()
Set all bits on.
Definition NodeMasks.h:471
openvdb::v10_0::util::NodeMask::DenseIterator
DenseMaskIterator< NodeMask > DenseIterator
Definition NodeMasks.h:350
openvdb::v10_0::util::NodeMask::isOn
bool isOn(Index32 n) const
Return true if the nth bit is on.
Definition NodeMasks.h:502
openvdb::v10_0::util::NodeMask::isConstant
bool isConstant(bool &isOn) const
Definition NodeMasks.h:526
openvdb::v10_0::util::NodeMask::WORD_COUNT
static const Index32 WORD_COUNT
Definition NodeMasks.h:315
openvdb::v10_0::util::NodeMask::countOff
Index32 countOff() const
Return the total number of on bits.
Definition NodeMasks.h:450
openvdb::v10_0::util::NodeMask::toggle
void toggle(Index32 n)
Toggle the state of the nth bit.
Definition NodeMasks.h:483
openvdb::v10_0::util::NodeMask::setLastOff
void setLastOff()
Set the last bit off.
Definition NodeMasks.h:500
openvdb::v10_0::util::NodeMask::NodeMask
NodeMask(bool on)
All bits are set to the specified state.
Definition NodeMasks.h:334
openvdb::v10_0::util::NodeMask::getWord
WordT getWord(Index n) const
Return the nth word of the bit mask, for a word of arbitrary size.
Definition NodeMasks.h:552
openvdb::v10_0::util::NodeMask::findNextOff
Index32 findNextOff(Index32 start) const
Definition NodeMasks.h:607
openvdb::v10_0::util::NodeMask::seek
void seek(std::istream &is) const
Definition NodeMasks.h:570
openvdb::v10_0::util::NodeMask::setFirstOff
void setFirstOff()
Set the first bit off.
Definition NodeMasks.h:498
openvdb::v10_0::util::NodeMask::OnIterator
OnMaskIterator< NodeMask > OnIterator
Definition NodeMasks.h:348
openvdb::v10_0::util::NodeMask::set
void set(bool on)
Set all bits to the specified state.
Definition NodeMasks.h:464
openvdb::v10_0::util::NodeMask::operator!
NodeMask operator!() const
Definition NodeMasks.h:435
openvdb::v10_0::util::NodeMask::SIZE
static const Index32 SIZE
Definition NodeMasks.h:314
openvdb::v10_0::util::NodeMask::setFirstOn
void setFirstOn()
Set the first bit on.
Definition NodeMasks.h:494
openvdb::v10_0::util::NodeMask::DIM
static const Index32 DIM
Definition NodeMasks.h:313
openvdb::v10_0::util::NodeMask::endOn
OnIterator endOn() const
Definition NodeMasks.h:353
openvdb::v10_0::util::NodeMask::load
void load(std::istream &is)
Definition NodeMasks.h:569
openvdb::v10_0::util::NodeMask::operator|=
const NodeMask & operator|=(const NodeMask &other)
Bitwise union.
Definition NodeMasks.h:412
openvdb::v10_0::util::NodeMask::save
void save(std::ostream &os) const
Definition NodeMasks.h:565
openvdb::v10_0::util::NodeMask::findFirstOff
Index32 findFirstOff() const
Definition NodeMasks.h:541
openvdb::v10_0::util::NodeMask::printBits
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition NodeMasks.h:577
openvdb::v10_0::util::NodeMask::memUsage
static Index32 memUsage()
Return the byte size of this NodeMask.
Definition NodeMasks.h:441
openvdb::v10_0::util::NodeMask::setOff
void setOff()
Set all bits off.
Definition NodeMasks.h:477
openvdb::v10_0::util::NodeMask::setOff
void setOff(Index32 n)
Set the nth bit off.
Definition NodeMasks.h:457
openvdb::v10_0::util::NodeMask::setOn
void setOn(Index32 n)
Set the nth bit on.
Definition NodeMasks.h:452
openvdb::v10_0::util::NodeMask::operator&
NodeMask operator&(const NodeMask &other) const
Definition NodeMasks.h:436
openvdb::v10_0::util::NodeMask::isOff
bool isOff() const
Return true if all the bits are off.
Definition NodeMasks.h:517
openvdb::v10_0::util::NodeMask::operator=
NodeMask & operator=(const NodeMask &other)
Assignment operator.
Definition NodeMasks.h:340
openvdb::v10_0::util::NodeMask::LOG2DIM
static const Index32 LOG2DIM
Definition NodeMasks.h:312
openvdb::v10_0::util::NodeMask::NodeMask
NodeMask()
Default constructor sets all bits off.
Definition NodeMasks.h:332
openvdb::v10_0::util::NodeMask::NodeMask
NodeMask(const NodeMask &other)
Copy constructor.
Definition NodeMasks.h:336
openvdb::v10_0::util::NodeMask::toggle
void toggle()
Toggle the state of all bits in the mask.
Definition NodeMasks.h:488
openvdb::v10_0::util::NodeMask::printAll
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition NodeMasks.h:589
openvdb::v10_0::util::NodeMask::printInfo
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition NodeMasks.h:572
openvdb::v10_0::util::NodeMask::OffIterator
OffMaskIterator< NodeMask > OffIterator
Definition NodeMasks.h:349
openvdb::v10_0::util::NodeMask::findNextOn
Index32 findNextOn(Index32 start) const
Definition NodeMasks.h:595
openvdb::v10_0::util::NodeMask::setLastOn
void setLastOn()
Set the last bit on.
Definition NodeMasks.h:496
openvdb::v10_0::util::NodeMask::~NodeMask
~NodeMask()
Destructor.
Definition NodeMasks.h:338
openvdb::v10_0::util::NodeMask::endOff
OffIterator endOff() const
Definition NodeMasks.h:355
openvdb::v10_0::util::NodeMask::isOn
bool isOn() const
Return true if all the bits are on.
Definition NodeMasks.h:510
openvdb::v10_0::util::NodeMask::findFirstOn
Index32 findFirstOn() const
Definition NodeMasks.h:534
openvdb::v10_0::util::OffMaskIterator
Definition NodeMasks.h:240
openvdb::v10_0::util::OffMaskIterator::operator*
bool operator*() const
Definition NodeMasks.h:260
openvdb::v10_0::util::OffMaskIterator::OffMaskIterator
OffMaskIterator()
Definition NodeMasks.h:246
openvdb::v10_0::util::OffMaskIterator::OffMaskIterator
OffMaskIterator(Index32 pos, const NodeMask *parent)
Definition NodeMasks.h:247
openvdb::v10_0::util::OffMaskIterator::next
bool next()
Definition NodeMasks.h:255
openvdb::v10_0::util::OffMaskIterator::operator++
OffMaskIterator & operator++()
Definition NodeMasks.h:261
openvdb::v10_0::util::OffMaskIterator::increment
void increment(Index n)
Definition NodeMasks.h:254
openvdb::v10_0::util::OffMaskIterator::increment
void increment()
Definition NodeMasks.h:248
openvdb::v10_0::util::OnMaskIterator
Definition NodeMasks.h:209
openvdb::v10_0::util::OnMaskIterator::operator*
bool operator*() const
Definition NodeMasks.h:229
openvdb::v10_0::util::OnMaskIterator::operator++
OnMaskIterator & operator++()
Definition NodeMasks.h:230
openvdb::v10_0::util::OnMaskIterator::next
bool next()
Definition NodeMasks.h:224
openvdb::v10_0::util::OnMaskIterator::OnMaskIterator
OnMaskIterator(Index32 pos, const NodeMask *parent)
Definition NodeMasks.h:216
openvdb::v10_0::util::OnMaskIterator::OnMaskIterator
OnMaskIterator()
Definition NodeMasks.h:215
openvdb::v10_0::util::OnMaskIterator::increment
void increment(Index n)
Definition NodeMasks.h:223
openvdb::v10_0::util::OnMaskIterator::increment
void increment()
Definition NodeMasks.h:217
openvdb::v10_0::util::RootNodeMask::BaseIterator::mParent
const RootNodeMask * mParent
Definition NodeMasks.h:1114
openvdb::v10_0::util::RootNodeMask::BaseIterator::test
bool test() const
Definition NodeMasks.h:1134
openvdb::v10_0::util::RootNodeMask::BaseIterator::mBitSize
Index32 mBitSize
Definition NodeMasks.h:1113
openvdb::v10_0::util::RootNodeMask::BaseIterator::operator==
bool operator==(const BaseIterator &iter) const
Definition NodeMasks.h:1120
openvdb::v10_0::util::RootNodeMask::BaseIterator::BaseIterator
BaseIterator(Index32 pos, const RootNodeMask *parent)
Definition NodeMasks.h:1118
openvdb::v10_0::util::RootNodeMask::BaseIterator::BaseIterator
BaseIterator()
Definition NodeMasks.h:1116
openvdb::v10_0::util::RootNodeMask::BaseIterator::mPos
Index32 mPos
Definition NodeMasks.h:1112
openvdb::v10_0::util::RootNodeMask::BaseIterator::pos
Index32 pos() const
Definition NodeMasks.h:1132
openvdb::v10_0::util::RootNodeMask::BaseIterator::operator=
BaseIterator & operator=(const BaseIterator &iter)
Definition NodeMasks.h:1123
openvdb::v10_0::util::RootNodeMask::BaseIterator::offset
Index32 offset() const
Definition NodeMasks.h:1130
openvdb::v10_0::util::RootNodeMask::BaseIterator::operator!=
bool operator!=(const BaseIterator &iter) const
Definition NodeMasks.h:1121
openvdb::v10_0::util::RootNodeMask::BaseIterator::BaseIterator
BaseIterator(const BaseIterator &)=default
openvdb::v10_0::util::RootNodeMask::DenseIterator
Definition NodeMasks.h:1200
openvdb::v10_0::util::RootNodeMask::DenseIterator::DenseIterator
DenseIterator()
Definition NodeMasks.h:1206
openvdb::v10_0::util::RootNodeMask::DenseIterator::operator++
DenseIterator & operator++()
Definition NodeMasks.h:1221
openvdb::v10_0::util::RootNodeMask::DenseIterator::DenseIterator
DenseIterator(Index32 pos, const RootNodeMask *parent)
Definition NodeMasks.h:1207
openvdb::v10_0::util::RootNodeMask::DenseIterator::operator*
bool operator*() const
Definition NodeMasks.h:1220
openvdb::v10_0::util::RootNodeMask::DenseIterator::mParent
const RootNodeMask * mParent
Definition NodeMasks.h:1114
openvdb::v10_0::util::RootNodeMask::DenseIterator::mBitSize
Index32 mBitSize
Definition NodeMasks.h:1113
openvdb::v10_0::util::RootNodeMask::DenseIterator::next
bool next()
Definition NodeMasks.h:1216
openvdb::v10_0::util::RootNodeMask::DenseIterator::mPos
Index32 mPos
Definition NodeMasks.h:1112
openvdb::v10_0::util::RootNodeMask::DenseIterator::increment
void increment(Index n)
Definition NodeMasks.h:1213
openvdb::v10_0::util::RootNodeMask::DenseIterator::increment
void increment()
Definition NodeMasks.h:1208
openvdb::v10_0::util::RootNodeMask::OffIterator
Definition NodeMasks.h:1172
openvdb::v10_0::util::RootNodeMask::OffIterator::operator*
bool operator*() const
Definition NodeMasks.h:1192
openvdb::v10_0::util::RootNodeMask::OffIterator::mParent
const RootNodeMask * mParent
Definition NodeMasks.h:1114
openvdb::v10_0::util::RootNodeMask::OffIterator::OffIterator
OffIterator()
Definition NodeMasks.h:1178
openvdb::v10_0::util::RootNodeMask::OffIterator::mBitSize
Index32 mBitSize
Definition NodeMasks.h:1113
openvdb::v10_0::util::RootNodeMask::OffIterator::OffIterator
OffIterator(Index32 pos, const RootNodeMask *parent)
Definition NodeMasks.h:1179
openvdb::v10_0::util::RootNodeMask::OffIterator::operator++
OffIterator & operator++()
Definition NodeMasks.h:1193
openvdb::v10_0::util::RootNodeMask::OffIterator::next
bool next()
Definition NodeMasks.h:1188
openvdb::v10_0::util::RootNodeMask::OffIterator::mPos
Index32 mPos
Definition NodeMasks.h:1112
openvdb::v10_0::util::RootNodeMask::OffIterator::increment
void increment(Index n)
Definition NodeMasks.h:1185
openvdb::v10_0::util::RootNodeMask::OffIterator::increment
void increment()
Definition NodeMasks.h:1180
openvdb::v10_0::util::RootNodeMask::OnIterator
Definition NodeMasks.h:1144
openvdb::v10_0::util::RootNodeMask::OnIterator::OnIterator
OnIterator()
Definition NodeMasks.h:1150
openvdb::v10_0::util::RootNodeMask::OnIterator::operator*
bool operator*() const
Definition NodeMasks.h:1164
openvdb::v10_0::util::RootNodeMask::OnIterator::mParent
const RootNodeMask * mParent
Definition NodeMasks.h:1114
openvdb::v10_0::util::RootNodeMask::OnIterator::mBitSize
Index32 mBitSize
Definition NodeMasks.h:1113
openvdb::v10_0::util::RootNodeMask::OnIterator::next
bool next()
Definition NodeMasks.h:1160
openvdb::v10_0::util::RootNodeMask::OnIterator::mPos
Index32 mPos
Definition NodeMasks.h:1112
openvdb::v10_0::util::RootNodeMask::OnIterator::OnIterator
OnIterator(Index32 pos, const RootNodeMask *parent)
Definition NodeMasks.h:1151
openvdb::v10_0::util::RootNodeMask::OnIterator::operator++
OnIterator & operator++()
Definition NodeMasks.h:1165
openvdb::v10_0::util::RootNodeMask::OnIterator::increment
void increment(Index n)
Definition NodeMasks.h:1157
openvdb::v10_0::util::RootNodeMask::OnIterator::increment
void increment()
Definition NodeMasks.h:1152
openvdb::v10_0::util::RootNodeMask::mBits
Index32 * mBits
Definition NodeMasks.h:1070
openvdb::v10_0::util::RootNodeMask::~RootNodeMask
~RootNodeMask()
Definition NodeMasks.h:1084
openvdb::v10_0::util::RootNodeMask::RootNodeMask
RootNodeMask()
Definition NodeMasks.h:1073
openvdb::v10_0::util::RootNodeMask::countOn
Index32 countOn() const
Definition NodeMasks.h:1287
openvdb::v10_0::util::RootNodeMask::getBitSize
Index getBitSize() const
Definition NodeMasks.h:1094
openvdb::v10_0::util::RootNodeMask::beginOn
OnIterator beginOn() const
Definition NodeMasks.h:1227
openvdb::v10_0::util::RootNodeMask::operator&=
const RootNodeMask & operator&=(const RootNodeMask &other)
Definition NodeMasks.h:1250
openvdb::v10_0::util::RootNodeMask::operator&
RootNodeMask operator&(const RootNodeMask &other) const
Definition NodeMasks.h:1272
openvdb::v10_0::util::RootNodeMask::set
void set(Index32 i, bool On)
Definition NodeMasks.h:1308
openvdb::v10_0::util::RootNodeMask::endDense
DenseIterator endDense() const
Definition NodeMasks.h:1232
openvdb::v10_0::util::RootNodeMask::operator|
RootNodeMask operator|(const RootNodeMask &other) const
Definition NodeMasks.h:1275
openvdb::v10_0::util::RootNodeMask::beginDense
DenseIterator beginDense() const
Definition NodeMasks.h:1231
openvdb::v10_0::util::RootNodeMask::beginOff
OffIterator beginOff() const
Definition NodeMasks.h:1229
openvdb::v10_0::util::RootNodeMask::setOn
void setOn()
Definition NodeMasks.h:1310
openvdb::v10_0::util::RootNodeMask::isOff
bool isOff(Index32 i) const
Definition NodeMasks.h:1336
openvdb::v10_0::util::RootNodeMask::countOff
Index32 countOff() const
Definition NodeMasks.h:1294
openvdb::v10_0::util::RootNodeMask::setLastOff
void setLastOff()
Definition NodeMasks.h:1330
openvdb::v10_0::util::RootNodeMask::RootNodeMask
RootNodeMask(const RootNodeMask &B)
Definition NodeMasks.h:1079
openvdb::v10_0::util::RootNodeMask::mBitSize
Index32 mBitSize
Definition NodeMasks.h:1069
openvdb::v10_0::util::RootNodeMask::findNextOff
Index32 findNextOff(Index32 start) const
Definition NodeMasks.h:1413
openvdb::v10_0::util::RootNodeMask::setOff
void setOff(Index32 i)
Definition NodeMasks.h:1302
openvdb::v10_0::util::RootNodeMask::seek
void seek(std::istream &is) const
Definition NodeMasks.h:1376
openvdb::v10_0::util::RootNodeMask::setOn
void setOn(Index32 i)
Definition NodeMasks.h:1296
openvdb::v10_0::util::RootNodeMask::mIntSize
Index32 mIntSize
Definition NodeMasks.h:1069
openvdb::v10_0::util::RootNodeMask::setFirstOff
void setFirstOff()
Definition NodeMasks.h:1329
openvdb::v10_0::util::RootNodeMask::isOn
bool isOn(Index32 i) const
Definition NodeMasks.h:1331
openvdb::v10_0::util::RootNodeMask::getIntSize
Index getIntSize() const
Definition NodeMasks.h:1096
openvdb::v10_0::util::RootNodeMask::setFirstOn
void setFirstOn()
Definition NodeMasks.h:1327
openvdb::v10_0::util::RootNodeMask::endOn
OnIterator endOn() const
Definition NodeMasks.h:1228
openvdb::v10_0::util::RootNodeMask::load
void load(std::istream &is)
Definition NodeMasks.h:1372
openvdb::v10_0::util::RootNodeMask::operator!
RootNodeMask operator!() const
Definition NodeMasks.h:1249
openvdb::v10_0::util::RootNodeMask::save
void save(std::ostream &os) const
Definition NodeMasks.h:1368
openvdb::v10_0::util::RootNodeMask::findFirstOff
Index32 findFirstOff() const
Definition NodeMasks.h:1361
openvdb::v10_0::util::RootNodeMask::operator^=
const RootNodeMask & operator^=(const RootNodeMask &other)
Definition NodeMasks.h:1265
openvdb::v10_0::util::RootNodeMask::printBits
void printBits(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition NodeMasks.h:1385
openvdb::v10_0::util::RootNodeMask::setOff
void setOff()
Definition NodeMasks.h:1314
openvdb::v10_0::util::RootNodeMask::init
void init(Index32 bit_size)
Definition NodeMasks.h:1086
openvdb::v10_0::util::RootNodeMask::memUsage
Index32 memUsage() const
Definition NodeMasks.h:1424
openvdb::v10_0::util::RootNodeMask::getMemUsage
Index32 getMemUsage() const
Definition NodeMasks.h:1283
openvdb::v10_0::util::RootNodeMask::isOff
bool isOff() const
Definition NodeMasks.h:1348
openvdb::v10_0::util::RootNodeMask::operator=
RootNodeMask & operator=(const RootNodeMask &B)
Definition NodeMasks.h:1098
openvdb::v10_0::util::RootNodeMask::toggle
void toggle(Index32 i)
Definition NodeMasks.h:1318
openvdb::v10_0::util::RootNodeMask::operator^
RootNodeMask operator^(const RootNodeMask &other) const
Definition NodeMasks.h:1278
openvdb::v10_0::util::RootNodeMask::toggle
void toggle()
Definition NodeMasks.h:1323
openvdb::v10_0::util::RootNodeMask::RootNodeMask
RootNodeMask(Index32 bit_size)
Definition NodeMasks.h:1074
openvdb::v10_0::util::RootNodeMask::printAll
void printAll(std::ostream &os=std::cout, Index32 max_out=80u) const
Definition NodeMasks.h:1397
openvdb::v10_0::util::RootNodeMask::printInfo
void printInfo(std::ostream &os=std::cout) const
simple print method for debugging
Definition NodeMasks.h:1381
openvdb::v10_0::util::RootNodeMask::operator|=
const RootNodeMask & operator|=(const RootNodeMask &other)
Definition NodeMasks.h:1258
openvdb::v10_0::util::RootNodeMask::findNextOn
Index32 findNextOn(Index32 start) const
Definition NodeMasks.h:1402
openvdb::v10_0::util::RootNodeMask::setLastOn
void setLastOn()
Definition NodeMasks.h:1328
openvdb::v10_0::util::RootNodeMask::endOff
OffIterator endOff() const
Definition NodeMasks.h:1230
openvdb::v10_0::util::RootNodeMask::isOn
bool isOn() const
Definition NodeMasks.h:1342
openvdb::v10_0::util::RootNodeMask::findFirstOn
Index32 findFirstOn() const
Definition NodeMasks.h:1354
openvdb::v10_0::util::CountOff
Index32 CountOff(Byte v)
Return the number of off bits in the given 8-bit value.
Definition NodeMasks.h:49
openvdb::v10_0::util::FindHighestOn
Index32 FindHighestOn(Index32 v)
Return the most significant on bit of the given 32-bit value.
Definition NodeMasks.h:159
openvdb::v10_0::util::FindLowestOn
Index32 FindLowestOn(Byte v)
Return the least significant on bit of the given 8-bit value.
Definition NodeMasks.h:85
openvdb::v10_0::util::CountOn
Index32 CountOn(Byte v)
Return the number of on bits in the given 8-bit value.
Definition NodeMasks.h:27
openvdb::v10_0::Index
Index32 Index
Definition Types.h:54
openvdb::v10_0::Byte
unsigned char Byte
Definition Types.h:59
openvdb::v10_0::Index32
uint32_t Index32
Definition Types.h:52
openvdb::v10_0::Index64
uint64_t Index64
Definition Types.h:53
openvdb
Definition Exceptions.h:13
Types.h
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:212