OpenVDB 12.0.0
 
Loading...
Searching...
No Matches
Mask< LOG2DIM > Class Template Reference

Bit-mask to encode active states and facilitate sequential iterators and a fast codec for I/O compression. More...

#include <nanovdb/NanoVDB.h>

Classes

class  DenseIterator
 
class  Iterator
 

Public Types

using OnIterator = Iterator<true>
 
using OffIterator = Iterator<false>
 

Public Member Functions

__hostdev__ uint32_t countOn () const
 Return the total number of set bits in this Mask.
 
__hostdev__ uint32_t countOn (uint32_t i) const
 Return the number of lower set bits in mask up to but excluding the i'th bit.
 
__hostdev__ OnIterator beginOn () const
 
__hostdev__ OffIterator beginOff () const
 
__hostdev__ DenseIterator beginAll () const
 
__hostdev__ Mask ()
 Initialize all bits to zero.
 
__hostdev__ Mask (bool on)
 
__hostdev__ Mask (const Mask &other)
 Copy constructor.
 
__hostdev__ uint64_t * words ()
 Return a pointer to the list of words of the bit mask.
 
__hostdev__ const uint64_t * words () const
 
template<typename MaskT = Mask>
__hostdev__ util::enable_if<!util::is_same< MaskT, Mask >::value, Mask & >::type operator= (const MaskT &other)
 Assignment operator that works with openvdb::util::NodeMask.
 
Maskoperator= (const Mask &)=default
 
__hostdev__ bool operator== (const Mask &other) const
 
__hostdev__ bool operator!= (const Mask &other) const
 
__hostdev__ bool isOn (uint32_t n) const
 Return true if the given bit is set.
 
__hostdev__ bool isOff (uint32_t n) const
 Return true if the given bit is NOT set.
 
__hostdev__ bool isOn () const
 Return true if all the bits are set in this Mask.
 
__hostdev__ bool isOff () const
 Return true if none of the bits are set in this Mask.
 
__hostdev__ void setOn (uint32_t n)
 Set the specified bit on.
 
__hostdev__ void setOff (uint32_t n)
 Set the specified bit off.
 
__hostdev__ void set (uint32_t n, bool on)
 Set the specified bit on or off.
 
__hostdev__ void setOn ()
 Set all bits on.
 
__hostdev__ void setOff ()
 Set all bits off.
 
__hostdev__ void set (bool on)
 Set all bits off.
 
__hostdev__ void toggle ()
 brief Toggle the state of all bits in the mask
 
__hostdev__ void toggle (uint32_t n)
 
__hostdev__ Maskoperator&= (const Mask &other)
 Bitwise intersection.
 
__hostdev__ Maskoperator|= (const Mask &other)
 Bitwise union.
 
__hostdev__ Maskoperator-= (const Mask &other)
 Bitwise difference.
 
__hostdev__ Maskoperator^= (const Mask &other)
 Bitwise XOR.
 
template<bool ON>
NANOVDB_HOSTDEV_DISABLE_WARNING __hostdev__ uint32_t findFirst () const
 
template<bool ON>
NANOVDB_HOSTDEV_DISABLE_WARNING __hostdev__ uint32_t findNext (uint32_t start) const
 
template<bool ON>
NANOVDB_HOSTDEV_DISABLE_WARNING __hostdev__ uint32_t findPrev (uint32_t start) const
 

Static Public Member Functions

static __hostdev__ size_t memUsage ()
 Return the memory footprint in bytes of this Mask.
 
static __hostdev__ uint32_t bitCount ()
 Return the number of bits available in this Mask.
 
static __hostdev__ uint32_t wordCount ()
 Return the number of machine words used by this Mask.
 

Static Public Attributes

static constexpr uint32_t SIZE = 1U << (3 * LOG2DIM)
 
static constexpr uint32_t WORD_COUNT = SIZE >> 6
 

Detailed Description

template<uint32_t LOG2DIM>
class nanovdb::Mask< LOG2DIM >

Bit-mask to encode active states and facilitate sequential iterators and a fast codec for I/O compression.

Member Typedef Documentation

◆ OffIterator

template<uint32_t LOG2DIM>
using OffIterator = Iterator<false>

◆ OnIterator

template<uint32_t LOG2DIM>
using OnIterator = Iterator<true>

Constructor & Destructor Documentation

◆ Mask() [1/3]

template<uint32_t LOG2DIM>
__hostdev__ Mask ( )
inline

Initialize all bits to zero.

◆ Mask() [2/3]

template<uint32_t LOG2DIM>
__hostdev__ Mask ( bool on)
inline

◆ Mask() [3/3]

template<uint32_t LOG2DIM>
__hostdev__ Mask ( const Mask< LOG2DIM > & other)
inline

Copy constructor.

Member Function Documentation

◆ beginAll()

template<uint32_t LOG2DIM>
__hostdev__ DenseIterator beginAll ( ) const
inline

◆ beginOff()

template<uint32_t LOG2DIM>
__hostdev__ OffIterator beginOff ( ) const
inline

◆ beginOn()

template<uint32_t LOG2DIM>
__hostdev__ OnIterator beginOn ( ) const
inline

◆ bitCount()

template<uint32_t LOG2DIM>
static __hostdev__ uint32_t bitCount ( )
inlinestatic

Return the number of bits available in this Mask.

◆ countOn() [1/2]

template<uint32_t LOG2DIM>
__hostdev__ uint32_t countOn ( ) const
inline

Return the total number of set bits in this Mask.

◆ countOn() [2/2]

template<uint32_t LOG2DIM>
__hostdev__ uint32_t countOn ( uint32_t i) const
inline

Return the number of lower set bits in mask up to but excluding the i'th bit.

◆ findFirst()

template<uint32_t LOG2DIM>
template<bool ON>
NANOVDB_HOSTDEV_DISABLE_WARNING __hostdev__ uint32_t findFirst ( ) const
inline

◆ findNext()

template<uint32_t LOG2DIM>
template<bool ON>
NANOVDB_HOSTDEV_DISABLE_WARNING __hostdev__ uint32_t findNext ( uint32_t start) const
inline

◆ findPrev()

template<uint32_t LOG2DIM>
template<bool ON>
NANOVDB_HOSTDEV_DISABLE_WARNING __hostdev__ uint32_t findPrev ( uint32_t start) const
inline

◆ isOff() [1/2]

template<uint32_t LOG2DIM>
__hostdev__ bool isOff ( ) const
inline

Return true if none of the bits are set in this Mask.

◆ isOff() [2/2]

template<uint32_t LOG2DIM>
__hostdev__ bool isOff ( uint32_t n) const
inline

Return true if the given bit is NOT set.

◆ isOn() [1/2]

template<uint32_t LOG2DIM>
__hostdev__ bool isOn ( ) const
inline

Return true if all the bits are set in this Mask.

◆ isOn() [2/2]

template<uint32_t LOG2DIM>
__hostdev__ bool isOn ( uint32_t n) const
inline

Return true if the given bit is set.

◆ memUsage()

template<uint32_t LOG2DIM>
static __hostdev__ size_t memUsage ( )
inlinestatic

Return the memory footprint in bytes of this Mask.

◆ operator!=()

template<uint32_t LOG2DIM>
__hostdev__ bool operator!= ( const Mask< LOG2DIM > & other) const
inline

◆ operator&=()

template<uint32_t LOG2DIM>
__hostdev__ Mask & operator&= ( const Mask< LOG2DIM > & other)
inline

Bitwise intersection.

◆ operator-=()

template<uint32_t LOG2DIM>
__hostdev__ Mask & operator-= ( const Mask< LOG2DIM > & other)
inline

Bitwise difference.

◆ operator=() [1/2]

template<uint32_t LOG2DIM>
Mask & operator= ( const Mask< LOG2DIM > & )
default

◆ operator=() [2/2]

template<uint32_t LOG2DIM>
template<typename MaskT = Mask>
__hostdev__ util::enable_if<!util::is_same< MaskT, Mask >::value, Mask & >::type operator= ( const MaskT & other)
inline

Assignment operator that works with openvdb::util::NodeMask.

◆ operator==()

template<uint32_t LOG2DIM>
__hostdev__ bool operator== ( const Mask< LOG2DIM > & other) const
inline

◆ operator^=()

template<uint32_t LOG2DIM>
__hostdev__ Mask & operator^= ( const Mask< LOG2DIM > & other)
inline

Bitwise XOR.

◆ operator|=()

template<uint32_t LOG2DIM>
__hostdev__ Mask & operator|= ( const Mask< LOG2DIM > & other)
inline

Bitwise union.

◆ set() [1/2]

template<uint32_t LOG2DIM>
__hostdev__ void set ( bool on)
inline

Set all bits off.

◆ set() [2/2]

template<uint32_t LOG2DIM>
__hostdev__ void set ( uint32_t n,
bool on )
inline

Set the specified bit on or off.

◆ setOff() [1/2]

template<uint32_t LOG2DIM>
__hostdev__ void setOff ( )
inline

Set all bits off.

◆ setOff() [2/2]

template<uint32_t LOG2DIM>
__hostdev__ void setOff ( uint32_t n)
inline

Set the specified bit off.

◆ setOn() [1/2]

template<uint32_t LOG2DIM>
__hostdev__ void setOn ( )
inline

Set all bits on.

◆ setOn() [2/2]

template<uint32_t LOG2DIM>
__hostdev__ void setOn ( uint32_t n)
inline

Set the specified bit on.

◆ toggle() [1/2]

template<uint32_t LOG2DIM>
__hostdev__ void toggle ( )
inline

brief Toggle the state of all bits in the mask

◆ toggle() [2/2]

template<uint32_t LOG2DIM>
__hostdev__ void toggle ( uint32_t n)
inline

◆ wordCount()

template<uint32_t LOG2DIM>
static __hostdev__ uint32_t wordCount ( )
inlinestatic

Return the number of machine words used by this Mask.

◆ words() [1/2]

template<uint32_t LOG2DIM>
__hostdev__ uint64_t * words ( )
inline

Return a pointer to the list of words of the bit mask.

◆ words() [2/2]

template<uint32_t LOG2DIM>
__hostdev__ const uint64_t * words ( ) const
inline

Member Data Documentation

◆ SIZE

template<uint32_t LOG2DIM>
uint32_t SIZE = 1U << (3 * LOG2DIM)
staticconstexpr

◆ WORD_COUNT

template<uint32_t LOG2DIM>
uint32_t WORD_COUNT = SIZE >> 6
staticconstexpr