4#ifndef OPENVDB_TREE_LEAFBUFFER_HAS_BEEN_INCLUDED
5#define OPENVDB_TREE_LEAFBUFFER_HAS_BEEN_INCLUDED
11#if OPENVDB_ABI_VERSION_NUMBER < 14
12#include <tbb/spin_mutex.h>
32template<
typename T, Index Log2Dim>
58 bool empty()
const {
return !mData; }
116 ValueType* mData =
nullptr;
117#if OPENVDB_ABI_VERSION_NUMBER < 14
119 std::atomic<Index32> mDeprecatedAtomic{0};
120 tbb::spin_mutex mDeprecatedSpinMutex;
123 friend class ::TestLeaf;
132template<
typename T, Index Log2Dim>
141template<
typename T, Index Log2Dim>
149template<
typename T, Index Log2Dim>
154 if (other.mData !=
nullptr) {
156 ValueType* target = mData;
157 const ValueType* source = other.mData;
159 while (n--) *target++ = *source++;
164template<
typename T, Index Log2Dim>
169 if (mData) mData[i] = val;
173template<
typename T, Index Log2Dim>
177 if (&other !=
this) {
178 if (other.mData !=
nullptr) {
183 while (n--) *target++ = *source++;
190template<
typename T, Index Log2Dim>
194 if (mData !=
nullptr) {
197 while (n--) *target++ = val;
202template<
typename T, Index Log2Dim>
206 const ValueType *target = mData, *source = other.mData;
207 if (!target && !source)
return true;
208 if (!target || !source)
return false;
215template<
typename T, Index Log2Dim>
219 std::swap(mData, other.mData);
223template<
typename T, Index Log2Dim>
227 size_t n =
sizeof(*this);
229 return static_cast<Index>(n);
233template<
typename T, Index Log2Dim>
238 if (mData ==
nullptr) {
245template<
typename T, Index Log2Dim>
255template<
typename T, Index Log2Dim>
257LeafBuffer<T, Log2Dim>::at(
Index i)
const
263 if (mData)
return mData[i];
else return sZero;
267template<
typename T, Index Log2Dim>
269LeafBuffer<T, Log2Dim>::deallocate()
271 if (mData !=
nullptr) {
284template<Index Log2Dim>
296 static inline const bool sOn =
true;
297 static inline const bool sOff =
false;
304 void fill(
bool val) { mData.set(val); }
312 if (mData.isOn(i))
return sOn;
else return sOff;
321 void swap(
LeafBuffer& other) {
if (&other !=
this) std::swap(mData, other.mData); }
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
Tag dispatch class that distinguishes constructors during file input.
Definition Types.h:760
LeafBuffer(const NodeMaskType &other)
Definition LeafBuffer.h:301
~LeafBuffer()
Definition LeafBuffer.h:303
WordType StorageType
Definition LeafBuffer.h:291
util::NodeMask< Log2Dim > NodeMaskType
Definition LeafBuffer.h:288
bool operator!=(const LeafBuffer &other) const
Definition LeafBuffer.h:317
static const Index WORD_COUNT
Definition LeafBuffer.h:293
static const bool sOff
Definition LeafBuffer.h:297
typename NodeMaskType::Word WordType
Definition LeafBuffer.h:289
Index memUsage() const
Definition LeafBuffer.h:323
void swap(LeafBuffer &other)
Definition LeafBuffer.h:321
const WordType * data() const
Return a const pointer to the C-style array of words encoding the bits.
Definition LeafBuffer.h:331
LeafBuffer & operator=(const LeafBuffer &b)
Definition LeafBuffer.h:305
bool operator==(const LeafBuffer &other) const
Definition LeafBuffer.h:316
bool ValueType
Definition LeafBuffer.h:290
LeafBuffer(const LeafBuffer &other)
Definition LeafBuffer.h:302
LeafBuffer(bool on)
Definition LeafBuffer.h:300
const bool & operator[](Index i) const
Definition LeafBuffer.h:314
void fill(bool val)
Definition LeafBuffer.h:304
const bool & getValue(Index i) const
Definition LeafBuffer.h:307
const NodeMaskType & storage() const
Return raw LeafBuffer data.
Definition LeafBuffer.h:334
friend class LeafNode
Definition LeafBuffer.h:338
static Index size()
Definition LeafBuffer.h:324
static const Index SIZE
Definition LeafBuffer.h:294
static const bool sOn
Definition LeafBuffer.h:296
WordType * data()
Return a pointer to the C-style array of words encoding the bits.
Definition LeafBuffer.h:328
LeafBuffer()
Definition LeafBuffer.h:299
void setValue(Index i, bool val)
Definition LeafBuffer.h:319
Array of fixed size 23Log2Dim that stores the voxel values of a LeafNode.
Definition LeafBuffer.h:34
LeafBuffer & operator=(const LeafBuffer &)
Copy the other buffer's values into this buffer.
Definition LeafBuffer.h:175
~LeafBuffer()
Destructor.
Definition LeafBuffer.h:143
LeafBuffer(PartialCreate, const ValueType &)
Construct a buffer without allocating the value array. The buffer is left unallocated; call allocate(...
Definition LeafBuffer.h:53
ValueType StorageType
Definition LeafBuffer.h:37
LeafBuffer(const ValueType &)
Construct a buffer populated with the specified value.
Definition LeafBuffer.h:134
LeafBuffer(const LeafBuffer &)
Copy constructor.
Definition LeafBuffer.h:151
void fill(const ValueType &)
Populate this buffer with a constant value.
Definition LeafBuffer.h:192
util::NodeMask< Log2Dim > NodeMaskType
Definition LeafBuffer.h:38
bool operator!=(const LeafBuffer &other) const
Return true if the contents of the other buffer are not exactly equal to the contents of this buffer.
Definition LeafBuffer.h:80
void swap(LeafBuffer &)
Exchange this buffer's values with the other buffer's values.
Definition LeafBuffer.h:217
Index memUsage() const
Return the memory footprint of this buffer in bytes.
Definition LeafBuffer.h:225
bool empty() const
Return true if memory for this buffer has not yet been allocated.
Definition LeafBuffer.h:58
friend class LeafNode
Definition LeafBuffer.h:125
void setValue(Index i, const ValueType &)
Set the i'th value of this buffer to the specified value.
Definition LeafBuffer.h:166
static Index size()
Return the number of values contained in this buffer.
Definition LeafBuffer.h:88
const ValueType * data() const
Return a const pointer to the array of voxel values.
Definition LeafBuffer.h:235
static const Index SIZE
Definition LeafBuffer.h:39
ValueType * data()
Return a pointer to the array of voxel values.
Definition LeafBuffer.h:247
const ValueType & getValue(Index i) const
Return a const reference to the i'th element of this buffer.
Definition LeafBuffer.h:66
bool allocate()
Allocate memory for this buffer if it has not already been allocated.
Definition LeafBuffer.h:60
LeafBuffer()
Default constructor.
Definition LeafBuffer.h:42
T ValueType
Definition LeafBuffer.h:36
const ValueType & operator[](Index i) const
Return a const reference to the i'th element of this buffer.
Definition LeafBuffer.h:68
bool operator==(const LeafBuffer &) const
Return true if the contents of the other buffer exactly equal the contents of this buffer.
Definition LeafBuffer.h:204
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation.
Definition NodeMasks.h:309
Index64 Word
Definition NodeMasks.h:317
static const Index32 WORD_COUNT
Definition NodeMasks.h:316
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition Math.h:465
Index32 Index
Definition Types.h:34
constexpr T zeroVal()
Return the value of type T that corresponds to zero.
Definition Math.h:71
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:291