OpenVDB: openvdb/points/PointDataGrid.h Source File

OpenVDB 13.0.0

Loading...
Searching...
No Matches
PointDataGrid.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: Apache-2.0
3
4/// @author Dan Bailey
5///
6/// @file points/PointDataGrid.h
7///
8/// @brief Attribute-owned data structure for points. Point attributes are
9/// stored in leaf nodes and ordered by voxel for fast random and
10/// sequential access.
11
12#ifndef OPENVDB_POINTS_POINT_DATA_GRID_HAS_BEEN_INCLUDED
13#define OPENVDB_POINTS_POINT_DATA_GRID_HAS_BEEN_INCLUDED
14
15#include <openvdb/version.h>
16#include <openvdb/Grid.h>
17#include <openvdb/tree/Tree.h>
18#include <openvdb/tree/LeafNode.h>
19#include <openvdb/tools/PointIndexGrid.h>
20#include <openvdb/util/Assert.h>
21#include "AttributeArray.h"
22#include "AttributeArrayString.h"
23#include "AttributeGroup.h"
24#include "AttributeSet.h"
25#include "StreamCompression.h"
26#include <cstring> // std::memcpy
27#include <iostream>
28#include <limits>
29#include <memory>
30#include <type_traits> // std::is_same
31#include <utility> // std::pair, std::make_pair
32#include <vector>
33
34class TestPointDataLeaf;
35
36namespace openvdb {
37 OPENVDB_USE_VERSION_NAMESPACE
38namespace OPENVDB_VERSION_NAME {
39
40namespace io
41{
42
43/// @brief openvdb::io::readCompressedValues specialized on PointDataIndex32 arrays to
44/// ignore the value mask, use a larger block size and use 16-bit size instead of 64-bit
45template<>
46inline void
47 readCompressedValues( std::istream& is, PointDataIndex32* destBuf, Index destCount,
48 const util::NodeMask<3>& /*valueMask*/, bool /*fromHalf*/)
49{
50 using compression::bloscDecompress;
51
52 const bool seek = destBuf == nullptr;
53
54 const size_t destBytes = destCount*sizeof(PointDataIndex32);
55 const size_t maximumBytes = std::numeric_limits<uint16_t>::max();
56 if (destBytes >= maximumBytes) {
57 OPENVDB_THROW(openvdb::IoError, "Cannot read more than " <<
58 maximumBytes << " bytes in voxel values.")
59 }
60
61 uint16_t bytes16;
62
63 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(is);
64
65 if (seek && meta) {
66 // buffer size temporarily stored in the StreamMetadata pass
67 // to avoid having to perform an expensive disk read for 2-bytes
68 bytes16 = static_cast<uint16_t>(meta->pass());
69 // seek over size of the compressed buffer
70 is.seekg(sizeof(uint16_t), std::ios_base::cur);
71 }
72 else {
73 // otherwise read from disk
74 is.read(reinterpret_cast<char*>(&bytes16), sizeof(uint16_t));
75 }
76
77 if (bytes16 == std::numeric_limits<uint16_t>::max()) {
78 // read or seek uncompressed data
79 if (seek) {
80 is.seekg(destBytes, std::ios_base::cur);
81 }
82 else {
83 is.read(reinterpret_cast<char*>(destBuf), destBytes);
84 }
85 }
86 else {
87 // read or seek uncompressed data
88 if (seek) {
89 is.seekg(int(bytes16), std::ios_base::cur);
90 }
91 else {
92 // decompress into the destination buffer
93 std::unique_ptr<char[]> bloscBuffer(new char[int(bytes16)]);
94 is.read(bloscBuffer.get(), bytes16);
95 std::unique_ptr<char[]> buffer = bloscDecompress( bloscBuffer.get(),
96 destBytes,
97 /*resize=*/false);
98 std::memcpy(destBuf, buffer.get(), destBytes);
99 }
100 }
101}
102
103/// @brief openvdb::io::writeCompressedValues specialized on PointDataIndex32 arrays to
104/// ignore the value mask, use a larger block size and use 16-bit size instead of 64-bit
105template<>
106inline void
107 writeCompressedValues( std::ostream& os, const PointDataIndex32* srcBuf, Index srcCount,
108 const util::NodeMask<3>& /*valueMask*/,
109 const util::NodeMask<3>& /*childMask*/, bool /*toHalf*/)
110{
111 using compression::bloscCompress;
112
113 const size_t srcBytes = srcCount*sizeof(PointDataIndex32);
114 const size_t maximumBytes = std::numeric_limits<uint16_t>::max();
115 if (srcBytes >= maximumBytes) {
116 OPENVDB_THROW(openvdb::IoError, "Cannot write more than " <<
117 maximumBytes << " bytes in voxel values.")
118 }
119
120 const char* charBuffer = reinterpret_cast<const char*>(srcBuf);
121
122 size_t compressedBytes;
123 std::unique_ptr<char[]> buffer = bloscCompress( charBuffer, srcBytes,
124 compressedBytes, /*resize=*/false);
125
126 if (compressedBytes > 0) {
127 auto bytes16 = static_cast<uint16_t>(compressedBytes); // clamp to 16-bit unsigned integer
128 os.write(reinterpret_cast<const char*>(&bytes16), sizeof(uint16_t));
129 os.write(reinterpret_cast<const char*>(buffer.get()), compressedBytes);
130 }
131 else {
132 auto bytes16 = static_cast<uint16_t>(maximumBytes); // max value indicates uncompressed
133 os.write(reinterpret_cast<const char*>(&bytes16), sizeof(uint16_t));
134 os.write(reinterpret_cast<const char*>(srcBuf), srcBytes);
135 }
136}
137
138template <typename T>
139inline void
140 writeCompressedValuesSize(std::ostream& os, const T* srcBuf, Index srcCount)
141{
142 using compression::bloscCompressedSize;
143
144 const size_t srcBytes = srcCount*sizeof(T);
145 const size_t maximumBytes = std::numeric_limits<uint16_t>::max();
146 if (srcBytes >= maximumBytes) {
147 OPENVDB_THROW(openvdb::IoError, "Cannot write more than " <<
148 maximumBytes << " bytes in voxel values.")
149 }
150
151 const char* charBuffer = reinterpret_cast<const char*>(srcBuf);
152
153 // calculate voxel buffer size after compression
154 size_t compressedBytes = bloscCompressedSize(charBuffer, srcBytes);
155
156 if (compressedBytes > 0) {
157 auto bytes16 = static_cast<uint16_t>(compressedBytes); // clamp to 16-bit unsigned integer
158 os.write(reinterpret_cast<const char*>(&bytes16), sizeof(uint16_t));
159 }
160 else {
161 auto bytes16 = static_cast<uint16_t>(maximumBytes); // max value indicates uncompressed
162 os.write(reinterpret_cast<const char*>(&bytes16), sizeof(uint16_t));
163 }
164}
165
166} // namespace io
167
168
169// forward declaration
170 namespace tree {
171 template<Index, typename> struct SameLeafConfig;
172}
173
174
175////////////////////////////////////////
176
177
178namespace points {
179
180
181// forward declaration
182template<typename T, Index Log2Dim> class PointDataLeafNode;
183
184// these aliases are disabled in one of the unit tests to ensure that
185// they are not used by the Point headers
186
187#ifndef OPENVDB_DISABLE_POINT_DATA_TREE_ALIAS
188
189/// @brief Point index tree configured to match the default VDB configurations.
190 using PointDataTree = tree::Tree<tree::RootNode<tree::InternalNode<tree::InternalNode
191 <PointDataLeafNode<PointDataIndex32, 3>, 4>, 5>>>;
192
193
194/// @brief Point data grid.
195 using PointDataGrid = Grid<PointDataTree>;
196
197#endif
198
199/// @brief Deep copy the descriptor across all leaf nodes.
200///
201/// @param tree the PointDataTree.
202///
203/// @return the new descriptor.
204///
205/// @note This method will fail if the Descriptors in the tree are not all identical.
206template <typename PointDataTreeT>
207inline AttributeSet::Descriptor::Ptr
208 makeDescriptorUnique(PointDataTreeT& tree);
209
210
211/// @brief Toggle the streaming mode on all attributes in the tree to collapse the attributes
212/// after deconstructing a bound AttributeHandle to each array. This results in better
213/// memory efficiency when the data is streamed into another data structure
214/// (typically for rendering).
215///
216/// @param tree the PointDataTree.
217/// @param on @c true to enable streaming
218///
219/// @note Multiple threads cannot safely access the same AttributeArray when using streaming.
220template <typename PointDataTreeT>
221inline void
222 setStreamingMode(PointDataTreeT& tree, bool on = true);
223
224
225/// @brief Sequentially pre-fetch all delayed-load voxel and attribute data from disk in order
226/// to accelerate subsequent random access.
227///
228/// @param tree the PointDataTree.
229/// @param position if enabled, prefetch the position attribute (default is on)
230/// @param otherAttributes if enabled, prefetch all other attributes (default is on)
231template <typename PointDataTreeT>
232inline void
233 prefetch(PointDataTreeT& tree, bool position = true, bool otherAttributes = true);
234
235
236////////////////////////////////////////
237
238
239template <typename T, Index Log2Dim>
240 class PointDataLeafNode : public tree::LeafNode<T, Log2Dim>, io::MultiPass {
241
242public:
243 using LeafNodeType = PointDataLeafNode<T, Log2Dim>;
244 using Ptr = std::shared_ptr<PointDataLeafNode>;
245
246 using ValueType = T;
247 using ValueTypePair = std::pair<ValueType, ValueType>;
248 using IndexArray = std::vector<ValueType>;
249
250 using Descriptor = AttributeSet::Descriptor;
251
252 ////////////////////////////////////////
253
254 // The following methods had to be copied from the LeafNode class
255 // to make the derived PointDataLeafNode class compatible with the tree structure.
256
257 using BaseLeaf = tree::LeafNode<T, Log2Dim>;
258 using NodeMaskType = util::NodeMask<Log2Dim>;
259
260 using BaseLeaf::LOG2DIM;
261 using BaseLeaf::TOTAL;
262 using BaseLeaf::DIM;
263 using BaseLeaf::NUM_VALUES;
264 using BaseLeaf::NUM_VOXELS;
265 using BaseLeaf::SIZE;
266 using BaseLeaf::LEVEL;
267
268 /// Default constructor
269 PointDataLeafNode()
270 : mAttributeSet(new AttributeSet) { }
271
272 ~PointDataLeafNode() = default;
273
274 /// Construct using deep copy of other PointDataLeafNode
275 explicit PointDataLeafNode(const PointDataLeafNode& other)
276 : BaseLeaf(other)
277 , mAttributeSet(new AttributeSet(*other.mAttributeSet)) { }
278
279 /// Construct using supplied origin, value and active status
280 explicit
281 PointDataLeafNode(const Coord& coords, const T& value = zeroVal<T>(), bool active = false)
282 : BaseLeaf(coords, zeroVal<T>(), active)
283 , mAttributeSet(new AttributeSet) { assertNonModifiableUnlessZero(value); }
284
285 /// Construct using supplied origin, value and active status
286 /// use attribute map from another PointDataLeafNode
287 PointDataLeafNode(const PointDataLeafNode& other, const Coord& coords,
288 const T& value = zeroVal<T>(), bool active = false)
289 : BaseLeaf(coords, zeroVal<T>(), active)
290 , mAttributeSet(new AttributeSet(*other.mAttributeSet))
291 {
292 assertNonModifiableUnlessZero(value);
293 }
294
295 // Copy-construct from a PointIndexLeafNode with the same configuration but a different ValueType.
296 template<typename OtherValueType>
297 PointDataLeafNode(const tools::PointIndexLeafNode<OtherValueType, Log2Dim>& other)
298 : BaseLeaf(other)
299 , mAttributeSet(new AttributeSet) { }
300
301 // Copy-construct from a LeafNode with the same configuration but a different ValueType.
302 // Used for topology copies - explicitly sets the value (background) to zeroVal
303 template <typename ValueType>
304 PointDataLeafNode(const tree::LeafNode<ValueType, Log2Dim>& other, const T& value, TopologyCopy)
305 : BaseLeaf(other, zeroVal<T>(), TopologyCopy())
306 , mAttributeSet(new AttributeSet) { assertNonModifiableUnlessZero(value); }
307
308 // Copy-construct from a LeafNode with the same configuration but a different ValueType.
309 // Used for topology copies - explicitly sets the on and off value (background) to zeroVal
310 template <typename ValueType>
311 PointDataLeafNode(const tree::LeafNode<ValueType, Log2Dim>& other, const T& /*offValue*/, const T& /*onValue*/, TopologyCopy)
312 : BaseLeaf(other, zeroVal<T>(), zeroVal<T>(), TopologyCopy())
313 , mAttributeSet(new AttributeSet) { }
314
315 PointDataLeafNode(PartialCreate, const Coord& coords,
316 const T& value = zeroVal<T>(), bool active = false)
317 : BaseLeaf(PartialCreate(), coords, value, active)
318 , mAttributeSet(new AttributeSet) { assertNonModifiableUnlessZero(value); }
319
320public:
321
322 /// Retrieve the attribute set.
323 const AttributeSet& attributeSet() const { return *mAttributeSet; }
324
325 /// @brief Steal the attribute set, a new, empty attribute set is inserted in it's place.
326 AttributeSet::UniquePtr stealAttributeSet();
327
328 /// @brief Create a new attribute set. Existing attributes will be removed.
329 void initializeAttributes(const Descriptor::Ptr& descriptor, const Index arrayLength,
330 const AttributeArray::ScopedRegistryLock* lock = nullptr);
331 /// @brief Clear the attribute set.
332 void clearAttributes(const bool updateValueMask = true,
333 const AttributeArray::ScopedRegistryLock* lock = nullptr);
334
335 /// @brief Returns @c true if an attribute with this index exists.
336 /// @param pos Index of the attribute
337 bool hasAttribute(const size_t pos) const;
338 /// @brief Returns @c true if an attribute with this name exists.
339 /// @param attributeName Name of the attribute
340 bool hasAttribute(const Name& attributeName) const;
341
342 /// @brief Append an attribute to the leaf.
343 /// @param expected Existing descriptor is expected to match this parameter.
344 /// @param replacement New descriptor to replace the existing one.
345 /// @param pos Index of the new attribute in the descriptor replacement.
346 /// @param strideOrTotalSize Stride of the attribute array (if constantStride), total size otherwise
347 /// @param constantStride if @c false, stride is interpreted as total size of the array
348 /// @param metadata optional default value metadata
349 /// @param lock an optional scoped registry lock to avoid contention
350 AttributeArray::Ptr appendAttribute(const Descriptor& expected, Descriptor::Ptr& replacement,
351 const size_t pos, const Index strideOrTotalSize = 1,
352 const bool constantStride = true,
353 const Metadata* metadata = nullptr,
354 const AttributeArray::ScopedRegistryLock* lock = nullptr);
355
356 /// @brief Drop list of attributes.
357 /// @param pos vector of attribute indices to drop
358 /// @param expected Existing descriptor is expected to match this parameter.
359 /// @param replacement New descriptor to replace the existing one.
360 void dropAttributes(const std::vector<size_t>& pos,
361 const Descriptor& expected, Descriptor::Ptr& replacement);
362 /// @brief Reorder attribute set.
363 /// @param replacement New descriptor to replace the existing one.
364 void reorderAttributes(const Descriptor::Ptr& replacement);
365 /// @brief Rename attributes in attribute set (order must remain the same).
366 /// @param expected Existing descriptor is expected to match this parameter.
367 /// @param replacement New descriptor to replace the existing one.
368 void renameAttributes(const Descriptor& expected, Descriptor::Ptr& replacement);
369 /// @brief Compact all attributes in attribute set.
370 void compactAttributes();
371
372 /// @brief Replace the underlying attribute set with the given @a attributeSet.
373 /// @details This leaf will assume ownership of the given attribute set. The descriptors must
374 /// match and the voxel offsets values will need updating if the point order is different.
375 /// @throws ValueError if @a allowMismatchingDescriptors is @c false and the descriptors
376 /// do not match
377 void replaceAttributeSet(AttributeSet* attributeSet, bool allowMismatchingDescriptors = false);
378
379 /// @brief Replace the descriptor with a new one
380 /// The new Descriptor must exactly match the old one
381 void resetDescriptor(const Descriptor::Ptr& replacement);
382
383 /// @brief Sets all of the voxel offset values on this leaf, from the given vector
384 /// of @a offsets. If @a updateValueMask is true, then the active value mask will
385 /// be updated so voxels with points are active and empty voxels are inactive.
386 void setOffsets(const std::vector<ValueType>& offsets, const bool updateValueMask = true);
387
388 /// @brief Throws an error if the voxel values on this leaf are not monotonically
389 /// increasing or within the bounds of the attribute arrays
390 void validateOffsets() const;
391
392 /// @brief Read-write attribute array reference from index
393 /// @details Attribute arrays can be shared across leaf nodes, so non-const
394 /// access will deep-copy the array to make it unique. Always prefer
395 /// accessing const arrays where possible to eliminate this copying.
396 /// {
397 AttributeArray& attributeArray(const size_t pos);
398 const AttributeArray& attributeArray(const size_t pos) const;
399 const AttributeArray& constAttributeArray(const size_t pos) const;
400 /// }
401 /// @brief Read-write attribute array reference from name
402 /// @details Attribute arrays can be shared across leaf nodes, so non-const
403 /// access will deep-copy the array to make it unique. Always prefer
404 /// accessing const arrays where possible to eliminate this copying.
405 /// {
406 AttributeArray& attributeArray(const Name& attributeName);
407 const AttributeArray& attributeArray(const Name& attributeName) const;
408 const AttributeArray& constAttributeArray(const Name& attributeName) const;
409 /// }
410
411 /// @brief Read-only group handle from group index
412 GroupHandle groupHandle(const AttributeSet::Descriptor::GroupIndex& index) const;
413 /// @brief Read-only group handle from group name
414 GroupHandle groupHandle(const Name& group) const;
415 /// @brief Read-write group handle from group index
416 GroupWriteHandle groupWriteHandle(const AttributeSet::Descriptor::GroupIndex& index);
417 /// @brief Read-write group handle from group name
418 GroupWriteHandle groupWriteHandle(const Name& name);
419
420 /// @brief Compute the total point count for the leaf
421 Index64 pointCount() const;
422 /// @brief Compute the total active (on) point count for the leaf
423 Index64 onPointCount() const;
424 /// @brief Compute the total inactive (off) point count for the leaf
425 Index64 offPointCount() const;
426 /// @brief Compute the point count in a specific group for the leaf
427 Index64 groupPointCount(const Name& groupName) const;
428
429 /// @brief Activate voxels with non-zero points, deactivate voxels with zero points.
430 void updateValueMask();
431
432 ////////////////////////////////////////
433
434 void setOffsetOn(Index offset, const ValueType& val);
435 void setOffsetOnly(Index offset, const ValueType& val);
436
437 /// @brief Return @c true if the given node (which may have a different @c ValueType
438 /// than this node) has the same active value topology as this node.
439 template<typename OtherType, Index OtherLog2Dim>
440 bool hasSameTopology(const PointDataLeafNode<OtherType, OtherLog2Dim>* other) const {
441 return BaseLeaf::hasSameTopology(other);
442 }
443
444 /// Check for buffer, state and origin equivalence first.
445 /// If this returns true, do a deeper comparison on the attribute set to check
446 bool operator==(const PointDataLeafNode& other) const {
447 if(BaseLeaf::operator==(other) != true) return false;
448 return (*this->mAttributeSet == *other.mAttributeSet);
449 }
450
451 bool operator!=(const PointDataLeafNode& other) const { return !(other == *this); }
452
453 void addLeaf(PointDataLeafNode*) {}
454 template<typename AccessorT>
455 void addLeafAndCache(PointDataLeafNode*, AccessorT&) {}
456
457 //@{
458 /// @brief Return a pointer to this node.
459 PointDataLeafNode* touchLeaf(const Coord&) { return this; }
460 template<typename AccessorT>
461 PointDataLeafNode* touchLeafAndCache(const Coord&, AccessorT&) { return this; }
462
463 template<typename NodeT, typename AccessorT>
464 NodeT* probeNodeAndCache(const Coord&, AccessorT&)
465 {
466 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
467 if (!(std::is_same<NodeT,PointDataLeafNode>::value)) return nullptr;
468 return reinterpret_cast<NodeT*>(this);
469 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
470 }
471 PointDataLeafNode* probeLeaf(const Coord&) { return this; }
472 template<typename AccessorT>
473 PointDataLeafNode* probeLeafAndCache(const Coord&, AccessorT&) { return this; }
474 //@}
475
476 //@{
477 /// @brief Return a @const pointer to this node.
478 const PointDataLeafNode* probeConstLeaf(const Coord&) const { return this; }
479 template<typename AccessorT>
480 const PointDataLeafNode* probeConstLeafAndCache(const Coord&, AccessorT&) const { return this; }
481 template<typename AccessorT>
482 const PointDataLeafNode* probeLeafAndCache(const Coord&, AccessorT&) const { return this; }
483 const PointDataLeafNode* probeLeaf(const Coord&) const { return this; }
484 template<typename NodeT, typename AccessorT>
485 const NodeT* probeConstNodeAndCache(const Coord&, AccessorT&) const
486 {
487 OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
488 if (!(std::is_same<NodeT,PointDataLeafNode>::value)) return nullptr;
489 return reinterpret_cast<const NodeT*>(this);
490 OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
491 }
492 //@}
493
494 // I/O methods
495
496 void readTopology(std::istream& is, bool fromHalf = false);
497 void writeTopology(std::ostream& os, bool toHalf = false) const;
498
499 Index buffers() const;
500
501 void readBuffers(std::istream& is, bool fromHalf = false);
502 void readBuffers(std::istream& is, const CoordBBox&, bool fromHalf = false);
503 void writeBuffers(std::ostream& os, bool toHalf = false) const;
504
505
506 Index64 memUsage() const;
507 Index64 memUsageIfLoaded() const;
508
509 void evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels = true) const;
510
511 /// @brief Return the bounding box of this node, i.e., the full index space
512 /// spanned by this leaf node.
513 CoordBBox getNodeBoundingBox() const;
514
515 ////////////////////////////////////////
516
517 // Disable all write methods to avoid unintentional changes
518 // to the point-array offsets.
519
520 void assertNonmodifiable() {
521 OPENVDB_ASSERT(false && "Cannot modify voxel values in a PointDataTree.");
522 }
523
524 // some methods silently ignore attempts to modify the
525 // point-array offsets if a zero value is used
526
527 void assertNonModifiableUnlessZero(const ValueType& value) {
528 if (value != zeroVal<T>()) this->assertNonmodifiable();
529 }
530
531 void setActiveState(const Coord& xyz, bool on) { BaseLeaf::setActiveState(xyz, on); }
532 void setActiveState(Index offset, bool on) { BaseLeaf::setActiveState(offset, on); }
533
534 void setValueOnly(const Coord&, const ValueType&) { assertNonmodifiable(); }
535 void setValueOnly(Index, const ValueType&) { assertNonmodifiable(); }
536
537 void setValueOff(const Coord& xyz) { BaseLeaf::setValueOff(xyz); }
538 void setValueOff(Index offset) { BaseLeaf::setValueOff(offset); }
539
540 void setValueOff(const Coord&, const ValueType&) { assertNonmodifiable(); }
541 void setValueOff(Index, const ValueType&) { assertNonmodifiable(); }
542
543 void setValueOn(const Coord& xyz) { BaseLeaf::setValueOn(xyz); }
544 void setValueOn(Index offset) { BaseLeaf::setValueOn(offset); }
545
546 void setValueOn(const Coord&, const ValueType&) { assertNonmodifiable(); }
547 void setValueOn(Index, const ValueType&) { assertNonmodifiable(); }
548
549 void setValue(const Coord&, const ValueType&) { assertNonmodifiable(); }
550
551 void setValuesOn() { BaseLeaf::setValuesOn(); }
552 void setValuesOff() { BaseLeaf::setValuesOff(); }
553
554 template<typename ModifyOp>
555 void modifyValue(Index, const ModifyOp&) { assertNonmodifiable(); }
556
557 template<typename ModifyOp>
558 void modifyValue(const Coord&, const ModifyOp&) { assertNonmodifiable(); }
559
560 template<typename ModifyOp>
561 void modifyValueAndActiveState(const Coord&, const ModifyOp&) { assertNonmodifiable(); }
562
563 // clipping is not yet supported
564 void clip(const CoordBBox&, const ValueType& value) { assertNonModifiableUnlessZero(value); }
565
566 void fill(const CoordBBox&, const ValueType&, bool);
567 void fill(const ValueType& value) { assertNonModifiableUnlessZero(value); }
568 void fill(const ValueType&, bool);
569
570 template<typename AccessorT>
571 void setValueOnlyAndCache(const Coord&, const ValueType&, AccessorT&) {assertNonmodifiable();}
572
573 template<typename ModifyOp, typename AccessorT>
574 void modifyValueAndActiveStateAndCache(const Coord&, const ModifyOp&, AccessorT&) {
575 assertNonmodifiable();
576 }
577
578 template<typename AccessorT>
579 void setValueOffAndCache(const Coord&, const ValueType&, AccessorT&) { assertNonmodifiable(); }
580
581 template<typename AccessorT>
582 void setActiveStateAndCache(const Coord& xyz, bool on, AccessorT& parent) {
583 BaseLeaf::setActiveStateAndCache(xyz, on, parent);
584 }
585
586 void resetBackground(const ValueType&, const ValueType& newBackground) {
587 assertNonModifiableUnlessZero(newBackground);
588 }
589
590 void signedFloodFill(const ValueType&) { assertNonmodifiable(); }
591 void signedFloodFill(const ValueType&, const ValueType&) { assertNonmodifiable(); }
592
593 void negate() { assertNonmodifiable(); }
594
595 friend class ::TestPointDataLeaf;
596
597 using ValueOn = typename BaseLeaf::ValueOn;
598 using ValueOff = typename BaseLeaf::ValueOff;
599 using ValueAll = typename BaseLeaf::ValueAll;
600
601private:
602 AttributeSet::UniquePtr mAttributeSet;
603 uint16_t mVoxelBufferSize = 0;
604
605protected:
606 using ChildOn = typename BaseLeaf::ChildOn;
607 using ChildOff = typename BaseLeaf::ChildOff;
608 using ChildAll = typename BaseLeaf::ChildAll;
609
610 using MaskOnIterator = typename NodeMaskType::OnIterator;
611 using MaskOffIterator = typename NodeMaskType::OffIterator;
612 using MaskDenseIterator = typename NodeMaskType::DenseIterator;
613
614 // During topology-only construction, access is needed
615 // to protected/private members of other template instances.
616 template<typename, Index> friend class PointDataLeafNode;
617
618 friend class tree::IteratorBase<MaskOnIterator, PointDataLeafNode>;
619 friend class tree::IteratorBase<MaskOffIterator, PointDataLeafNode>;
620 friend class tree::IteratorBase<MaskDenseIterator, PointDataLeafNode>;
621
622public:
623 /// @brief Leaf value voxel iterator
624 ValueVoxelCIter beginValueVoxel(const Coord& ijk) const;
625
626public:
627
628 using ValueOnIter = typename BaseLeaf::template ValueIter<
629 MaskOnIterator, PointDataLeafNode, const ValueType, ValueOn>;
630 using ValueOnCIter = typename BaseLeaf::template ValueIter<
631 MaskOnIterator, const PointDataLeafNode, const ValueType, ValueOn>;
632 using ValueOffIter = typename BaseLeaf::template ValueIter<
633 MaskOffIterator, PointDataLeafNode, const ValueType, ValueOff>;
634 using ValueOffCIter = typename BaseLeaf::template ValueIter<
635 MaskOffIterator,const PointDataLeafNode,const ValueType,ValueOff>;
636 using ValueAllIter = typename BaseLeaf::template ValueIter<
637 MaskDenseIterator, PointDataLeafNode, const ValueType, ValueAll>;
638 using ValueAllCIter = typename BaseLeaf::template ValueIter<
639 MaskDenseIterator,const PointDataLeafNode,const ValueType,ValueAll>;
640 using ChildOnIter = typename BaseLeaf::template ChildIter<
641 MaskOnIterator, PointDataLeafNode, ChildOn>;
642 using ChildOnCIter = typename BaseLeaf::template ChildIter<
643 MaskOnIterator, const PointDataLeafNode, ChildOn>;
644 using ChildOffIter = typename BaseLeaf::template ChildIter<
645 MaskOffIterator, PointDataLeafNode, ChildOff>;
646 using ChildOffCIter = typename BaseLeaf::template ChildIter<
647 MaskOffIterator, const PointDataLeafNode, ChildOff>;
648 using ChildAllIter = typename BaseLeaf::template DenseIter<
649 PointDataLeafNode, ValueType, ChildAll>;
650 using ChildAllCIter = typename BaseLeaf::template DenseIter<
651 const PointDataLeafNode, const ValueType, ChildAll>;
652
653 using IndexVoxelIter = IndexIter<ValueVoxelCIter, NullFilter>;
654 using IndexAllIter = IndexIter<ValueAllCIter, NullFilter>;
655 using IndexOnIter = IndexIter<ValueOnCIter, NullFilter>;
656 using IndexOffIter = IndexIter<ValueOffCIter, NullFilter>;
657
658 /// @brief Leaf index iterator
659 IndexAllIter beginIndexAll() const
660 {
661 NullFilter filter;
662 return this->beginIndex<ValueAllCIter, NullFilter>(filter);
663 }
664 IndexOnIter beginIndexOn() const
665 {
666 NullFilter filter;
667 return this->beginIndex<ValueOnCIter, NullFilter>(filter);
668 }
669 IndexOffIter beginIndexOff() const
670 {
671 NullFilter filter;
672 return this->beginIndex<ValueOffCIter, NullFilter>(filter);
673 }
674
675 template<typename IterT, typename FilterT>
676 IndexIter<IterT, FilterT> beginIndex(const FilterT& filter) const;
677
678 /// @brief Filtered leaf index iterator
679 template<typename FilterT>
680 IndexIter<ValueAllCIter, FilterT> beginIndexAll(const FilterT& filter) const
681 {
682 return this->beginIndex<ValueAllCIter, FilterT>(filter);
683 }
684 template<typename FilterT>
685 IndexIter<ValueOnCIter, FilterT> beginIndexOn(const FilterT& filter) const
686 {
687 return this->beginIndex<ValueOnCIter, FilterT>(filter);
688 }
689 template<typename FilterT>
690 IndexIter<ValueOffCIter, FilterT> beginIndexOff(const FilterT& filter) const
691 {
692 return this->beginIndex<ValueOffCIter, FilterT>(filter);
693 }
694
695 /// @brief Leaf index iterator from voxel
696 IndexVoxelIter beginIndexVoxel(const Coord& ijk) const;
697
698 /// @brief Filtered leaf index iterator from voxel
699 template<typename FilterT>
700 IndexIter<ValueVoxelCIter, FilterT> beginIndexVoxel(const Coord& ijk, const FilterT& filter) const;
701
702#define VMASK_ this->getValueMask()
703 ValueOnCIter cbeginValueOn() const { return ValueOnCIter(VMASK_.beginOn(), this); }
704 ValueOnCIter beginValueOn() const { return ValueOnCIter(VMASK_.beginOn(), this); }
705 ValueOnIter beginValueOn() { return ValueOnIter(VMASK_.beginOn(), this); }
706 ValueOffCIter cbeginValueOff() const { return ValueOffCIter(VMASK_.beginOff(), this); }
707 ValueOffCIter beginValueOff() const { return ValueOffCIter(VMASK_.beginOff(), this); }
708 ValueOffIter beginValueOff() { return ValueOffIter(VMASK_.beginOff(), this); }
709 ValueAllCIter cbeginValueAll() const { return ValueAllCIter(VMASK_.beginDense(), this); }
710 ValueAllCIter beginValueAll() const { return ValueAllCIter(VMASK_.beginDense(), this); }
711 ValueAllIter beginValueAll() { return ValueAllIter(VMASK_.beginDense(), this); }
712
713 ValueOnCIter cendValueOn() const { return ValueOnCIter(VMASK_.endOn(), this); }
714 ValueOnCIter endValueOn() const { return ValueOnCIter(VMASK_.endOn(), this); }
715 ValueOnIter endValueOn() { return ValueOnIter(VMASK_.endOn(), this); }
716 ValueOffCIter cendValueOff() const { return ValueOffCIter(VMASK_.endOff(), this); }
717 ValueOffCIter endValueOff() const { return ValueOffCIter(VMASK_.endOff(), this); }
718 ValueOffIter endValueOff() { return ValueOffIter(VMASK_.endOff(), this); }
719 ValueAllCIter cendValueAll() const { return ValueAllCIter(VMASK_.endDense(), this); }
720 ValueAllCIter endValueAll() const { return ValueAllCIter(VMASK_.endDense(), this); }
721 ValueAllIter endValueAll() { return ValueAllIter(VMASK_.endDense(), this); }
722
723 ChildOnCIter cbeginChildOn() const { return ChildOnCIter(VMASK_.endOn(), this); }
724 ChildOnCIter beginChildOn() const { return ChildOnCIter(VMASK_.endOn(), this); }
725 ChildOnIter beginChildOn() { return ChildOnIter(VMASK_.endOn(), this); }
726 ChildOffCIter cbeginChildOff() const { return ChildOffCIter(VMASK_.endOff(), this); }
727 ChildOffCIter beginChildOff() const { return ChildOffCIter(VMASK_.endOff(), this); }
728 ChildOffIter beginChildOff() { return ChildOffIter(VMASK_.endOff(), this); }
729 ChildAllCIter cbeginChildAll() const { return ChildAllCIter(VMASK_.beginDense(), this); }
730 ChildAllCIter beginChildAll() const { return ChildAllCIter(VMASK_.beginDense(), this); }
731 ChildAllIter beginChildAll() { return ChildAllIter(VMASK_.beginDense(), this); }
732
733 ChildOnCIter cendChildOn() const { return ChildOnCIter(VMASK_.endOn(), this); }
734 ChildOnCIter endChildOn() const { return ChildOnCIter(VMASK_.endOn(), this); }
735 ChildOnIter endChildOn() { return ChildOnIter(VMASK_.endOn(), this); }
736 ChildOffCIter cendChildOff() const { return ChildOffCIter(VMASK_.endOff(), this); }
737 ChildOffCIter endChildOff() const { return ChildOffCIter(VMASK_.endOff(), this); }
738 ChildOffIter endChildOff() { return ChildOffIter(VMASK_.endOff(), this); }
739 ChildAllCIter cendChildAll() const { return ChildAllCIter(VMASK_.endDense(), this); }
740 ChildAllCIter endChildAll() const { return ChildAllCIter(VMASK_.endDense(), this); }
741 ChildAllIter endChildAll() { return ChildAllIter(VMASK_.endDense(), this); }
742#undef VMASK_
743}; // struct PointDataLeafNode
744
745////////////////////////////////////////
746
747// PointDataLeafNode implementation
748
749template<typename T, Index Log2Dim>
750inline AttributeSet::UniquePtr
751PointDataLeafNode<T, Log2Dim>::stealAttributeSet()
752{
753 AttributeSet::UniquePtr ptr = std::make_unique<AttributeSet>();
754 std::swap(ptr, mAttributeSet);
755 return ptr;
756}
757
758template<typename T, Index Log2Dim>
759inline void
760PointDataLeafNode<T, Log2Dim>::initializeAttributes(const Descriptor::Ptr& descriptor, const Index arrayLength,
761 const AttributeArray::ScopedRegistryLock* lock)
762{
763 if (descriptor->size() != 1 ||
764 descriptor->find("P") == AttributeSet::INVALID_POS ||
765 descriptor->valueType(0) != typeNameAsString<Vec3f>())
766 {
767 OPENVDB_THROW(IndexError, "Initializing attributes only allowed with one Vec3f position attribute.");
768 }
769
770 mAttributeSet.reset(new AttributeSet(descriptor, arrayLength, lock));
771}
772
773template<typename T, Index Log2Dim>
774inline void
775PointDataLeafNode<T, Log2Dim>::clearAttributes(const bool updateValueMask,
776 const AttributeArray::ScopedRegistryLock* lock)
777{
778 mAttributeSet.reset(new AttributeSet(*mAttributeSet, 0, lock));
779
780 // zero voxel values
781
782 this->buffer().fill(ValueType(0));
783
784 // if updateValueMask, also de-activate all voxels
785
786 if (updateValueMask) this->setValuesOff();
787}
788
789template<typename T, Index Log2Dim>
790inline bool
791PointDataLeafNode<T, Log2Dim>::hasAttribute(const size_t pos) const
792{
793 return pos < mAttributeSet->size();
794}
795
796template<typename T, Index Log2Dim>
797inline bool
798 PointDataLeafNode<T, Log2Dim>::hasAttribute(const Name& attributeName) const
799{
800 const size_t pos = mAttributeSet->find(attributeName);
801 return pos != AttributeSet::INVALID_POS;
802}
803
804template<typename T, Index Log2Dim>
805inline AttributeArray::Ptr
806PointDataLeafNode<T, Log2Dim>::appendAttribute( const Descriptor& expected, Descriptor::Ptr& replacement,
807 const size_t pos, const Index strideOrTotalSize,
808 const bool constantStride,
809 const Metadata* metadata,
810 const AttributeArray::ScopedRegistryLock* lock)
811{
812 return mAttributeSet->appendAttribute(
813 expected, replacement, pos, strideOrTotalSize, constantStride, metadata, lock);
814}
815
816template<typename T, Index Log2Dim>
817inline void
818PointDataLeafNode<T, Log2Dim>::dropAttributes(const std::vector<size_t>& pos,
819 const Descriptor& expected, Descriptor::Ptr& replacement)
820{
821 mAttributeSet->dropAttributes(pos, expected, replacement);
822}
823
824template<typename T, Index Log2Dim>
825inline void
826PointDataLeafNode<T, Log2Dim>::reorderAttributes(const Descriptor::Ptr& replacement)
827{
828 mAttributeSet->reorderAttributes(replacement);
829}
830
831template<typename T, Index Log2Dim>
832inline void
833PointDataLeafNode<T, Log2Dim>::renameAttributes(const Descriptor& expected, Descriptor::Ptr& replacement)
834{
835 mAttributeSet->renameAttributes(expected, replacement);
836}
837
838template<typename T, Index Log2Dim>
839inline void
840PointDataLeafNode<T, Log2Dim>::compactAttributes()
841{
842 for (size_t i = 0; i < mAttributeSet->size(); i++) {
843 AttributeArray* array = mAttributeSet->get(i);
844 array->compact();
845 }
846}
847
848template<typename T, Index Log2Dim>
849inline void
850PointDataLeafNode<T, Log2Dim>::replaceAttributeSet(AttributeSet* attributeSet, bool allowMismatchingDescriptors)
851{
852 if (!attributeSet) {
853 OPENVDB_THROW(ValueError, "Cannot replace with a null attribute set");
854 }
855
856 if (!allowMismatchingDescriptors && mAttributeSet->descriptor() != attributeSet->descriptor()) {
857 OPENVDB_THROW(ValueError, "Attribute set descriptors are not equal.");
858 }
859
860 mAttributeSet.reset(attributeSet);
861}
862
863template<typename T, Index Log2Dim>
864inline void
865PointDataLeafNode<T, Log2Dim>::resetDescriptor(const Descriptor::Ptr& replacement)
866{
867 mAttributeSet->resetDescriptor(replacement);
868}
869
870template<typename T, Index Log2Dim>
871inline void
872PointDataLeafNode<T, Log2Dim>::setOffsets(const std::vector<ValueType>& offsets, const bool updateValueMask)
873{
874 if (offsets.size() != LeafNodeType::NUM_VALUES) {
875 OPENVDB_THROW(ValueError, "Offset vector size doesn't match number of voxels.")
876 }
877
878 for (Index index = 0; index < offsets.size(); ++index) {
879 setOffsetOnly(index, offsets[index]);
880 }
881
882 if (updateValueMask) this->updateValueMask();
883}
884
885template<typename T, Index Log2Dim>
886inline void
887PointDataLeafNode<T, Log2Dim>::validateOffsets() const
888{
889 // Ensure all of the offset values are monotonically increasing
890 for (Index index = 1; index < BaseLeaf::SIZE; ++index) {
891 if (this->getValue(index-1) > this->getValue(index)) {
892 OPENVDB_THROW(ValueError, "Voxel offset values are not monotonically increasing");
893 }
894 }
895
896 // Ensure all attribute arrays are of equal length
897 for (size_t attributeIndex = 1; attributeIndex < mAttributeSet->size(); ++attributeIndex ) {
898 if (mAttributeSet->getConst(attributeIndex-1)->size() != mAttributeSet->getConst(attributeIndex)->size()) {
899 OPENVDB_THROW(ValueError, "Attribute arrays have inconsistent length");
900 }
901 }
902
903 // Ensure the last voxel's offset value matches the size of each attribute array
904 if (mAttributeSet->size() > 0 && this->getValue(BaseLeaf::SIZE-1) != mAttributeSet->getConst(0)->size()) {
905 OPENVDB_THROW(ValueError, "Last voxel offset value does not match attribute array length");
906 }
907}
908
909template<typename T, Index Log2Dim>
910inline AttributeArray&
911PointDataLeafNode<T, Log2Dim>::attributeArray(const size_t pos)
912{
913 if (pos >= mAttributeSet->size()) OPENVDB_THROW(LookupError, "Attribute Out Of Range - " << pos);
914 return *mAttributeSet->get(pos);
915}
916
917template<typename T, Index Log2Dim>
918inline const AttributeArray&
919 PointDataLeafNode<T, Log2Dim>::attributeArray(const size_t pos) const
920{
921 if (pos >= mAttributeSet->size()) OPENVDB_THROW(LookupError, "Attribute Out Of Range - " << pos);
922 return *mAttributeSet->getConst(pos);
923}
924
925template<typename T, Index Log2Dim>
926inline const AttributeArray&
927PointDataLeafNode<T, Log2Dim>::constAttributeArray(const size_t pos) const
928{
929 return this->attributeArray(pos);
930}
931
932template<typename T, Index Log2Dim>
933inline AttributeArray&
934 PointDataLeafNode<T, Log2Dim>::attributeArray(const Name& attributeName)
935{
936 const size_t pos = mAttributeSet->find(attributeName);
937 if (pos == AttributeSet::INVALID_POS) OPENVDB_THROW(LookupError, "Attribute Not Found - " << attributeName);
938 return *mAttributeSet->get(pos);
939}
940
941template<typename T, Index Log2Dim>
942inline const AttributeArray&
943 PointDataLeafNode<T, Log2Dim>::attributeArray(const Name& attributeName) const
944{
945 const size_t pos = mAttributeSet->find(attributeName);
946 if (pos == AttributeSet::INVALID_POS) OPENVDB_THROW(LookupError, "Attribute Not Found - " << attributeName);
947 return *mAttributeSet->getConst(pos);
948}
949
950template<typename T, Index Log2Dim>
951inline const AttributeArray&
952 PointDataLeafNode<T, Log2Dim>::constAttributeArray(const Name& attributeName) const
953{
954 return this->attributeArray(attributeName);
955}
956
957template<typename T, Index Log2Dim>
958inline GroupHandle
959PointDataLeafNode<T, Log2Dim>::groupHandle(const AttributeSet::Descriptor::GroupIndex& index) const
960{
961 const AttributeArray& array = this->attributeArray(index.first);
962 OPENVDB_ASSERT(isGroup(array));
963
964 const GroupAttributeArray& groupArray = GroupAttributeArray::cast(array);
965
966 return GroupHandle(groupArray, index.second);
967}
968
969template<typename T, Index Log2Dim>
970inline GroupHandle
971 PointDataLeafNode<T, Log2Dim>::groupHandle(const Name& name) const
972{
973 const AttributeSet::Descriptor::GroupIndex index = this->attributeSet().groupIndex(name);
974 return this->groupHandle(index);
975}
976
977template<typename T, Index Log2Dim>
978inline GroupWriteHandle
979PointDataLeafNode<T, Log2Dim>::groupWriteHandle(const AttributeSet::Descriptor::GroupIndex& index)
980{
981 AttributeArray& array = this->attributeArray(index.first);
982 OPENVDB_ASSERT(isGroup(array));
983
984 GroupAttributeArray& groupArray = GroupAttributeArray::cast(array);
985
986 return GroupWriteHandle(groupArray, index.second);
987}
988
989template<typename T, Index Log2Dim>
990inline GroupWriteHandle
991 PointDataLeafNode<T, Log2Dim>::groupWriteHandle(const Name& name)
992{
993 const AttributeSet::Descriptor::GroupIndex index = this->attributeSet().groupIndex(name);
994 return this->groupWriteHandle(index);
995}
996
997template<typename T, Index Log2Dim>
998template<typename ValueIterT, typename FilterT>
999inline IndexIter<ValueIterT, FilterT>
1000 PointDataLeafNode<T, Log2Dim>::beginIndex(const FilterT& filter) const
1001{
1002 // generate no-op iterator if filter evaluates no indices
1003
1004 if (filter.state() == index::NONE) {
1005 return IndexIter<ValueIterT, FilterT>(ValueIterT(), filter);
1006 }
1007
1008 // copy filter to ensure thread-safety
1009
1010 FilterT newFilter(filter);
1011 newFilter.reset(*this);
1012
1013 using IterTraitsT = tree::IterTraits<LeafNodeType, ValueIterT>;
1014
1015 // construct the value iterator and reset the filter to use this leaf
1016
1017 ValueIterT valueIter = IterTraitsT::begin(*this);
1018
1019 return IndexIter<ValueIterT, FilterT>(valueIter, newFilter);
1020}
1021
1022template<typename T, Index Log2Dim>
1023inline ValueVoxelCIter
1024PointDataLeafNode<T, Log2Dim>::beginValueVoxel(const Coord& ijk) const
1025{
1026 const Index index = LeafNodeType::coordToOffset(ijk);
1027 OPENVDB_ASSERT(index < BaseLeaf::SIZE);
1028 const ValueType end = this->getValue(index);
1029 const ValueType start = (index == 0) ? ValueType(0) : this->getValue(index - 1);
1030 return ValueVoxelCIter(start, end);
1031}
1032
1033template<typename T, Index Log2Dim>
1034inline typename PointDataLeafNode<T, Log2Dim>::IndexVoxelIter
1035PointDataLeafNode<T, Log2Dim>::beginIndexVoxel(const Coord& ijk) const
1036{
1037 ValueVoxelCIter iter = this->beginValueVoxel(ijk);
1038 return IndexVoxelIter(iter, NullFilter());
1039}
1040
1041template<typename T, Index Log2Dim>
1042template<typename FilterT>
1043inline IndexIter<ValueVoxelCIter, FilterT>
1044 PointDataLeafNode<T, Log2Dim>::beginIndexVoxel(const Coord& ijk, const FilterT& filter) const
1045{
1046 ValueVoxelCIter iter = this->beginValueVoxel(ijk);
1047 FilterT newFilter(filter);
1048 newFilter.reset(*this);
1049 return IndexIter<ValueVoxelCIter, FilterT>(iter, newFilter);
1050}
1051
1052template<typename T, Index Log2Dim>
1053inline Index64
1054PointDataLeafNode<T, Log2Dim>::pointCount() const
1055{
1056 return this->getLastValue();
1057}
1058
1059template<typename T, Index Log2Dim>
1060inline Index64
1061PointDataLeafNode<T, Log2Dim>::onPointCount() const
1062{
1063 if (this->isEmpty()) return 0;
1064 else if (this->isDense()) return this->pointCount();
1065 return iterCount(this->beginIndexOn());
1066}
1067
1068template<typename T, Index Log2Dim>
1069inline Index64
1070PointDataLeafNode<T, Log2Dim>::offPointCount() const
1071{
1072 if (this->isEmpty()) return this->pointCount();
1073 else if (this->isDense()) return 0;
1074 return iterCount(this->beginIndexOff());
1075}
1076
1077template<typename T, Index Log2Dim>
1078inline Index64
1079PointDataLeafNode<T, Log2Dim>::groupPointCount(const Name& groupName) const
1080{
1081 if (!this->attributeSet().descriptor().hasGroup(groupName)) {
1082 return Index64(0);
1083 }
1084 GroupFilter filter(groupName, this->attributeSet());
1085 if (filter.state() == index::ALL) {
1086 return this->pointCount();
1087 } else {
1088 return iterCount(this->beginIndexAll(filter));
1089 }
1090}
1091
1092template<typename T, Index Log2Dim>
1093inline void
1094PointDataLeafNode<T, Log2Dim>::updateValueMask()
1095{
1096 ValueType start = 0, end = 0;
1097 for (Index n = 0; n < LeafNodeType::NUM_VALUES; n++) {
1098 end = this->getValue(n);
1099 this->setValueMask(n, (end - start) > 0);
1100 start = end;
1101 }
1102}
1103
1104template<typename T, Index Log2Dim>
1105inline void
1106PointDataLeafNode<T, Log2Dim>::setOffsetOn(Index offset, const ValueType& val)
1107{
1108 this->buffer().setValue(offset, val);
1109 this->setValueMaskOn(offset);
1110}
1111
1112template<typename T, Index Log2Dim>
1113inline void
1114PointDataLeafNode<T, Log2Dim>::setOffsetOnly(Index offset, const ValueType& val)
1115{
1116 this->buffer().setValue(offset, val);
1117}
1118
1119template<typename T, Index Log2Dim>
1120inline void
1121PointDataLeafNode<T, Log2Dim>::readTopology(std::istream& is, bool fromHalf)
1122{
1123 BaseLeaf::readTopology(is, fromHalf);
1124}
1125
1126template<typename T, Index Log2Dim>
1127inline void
1128PointDataLeafNode<T, Log2Dim>::writeTopology(std::ostream& os, bool toHalf) const
1129{
1130 BaseLeaf::writeTopology(os, toHalf);
1131}
1132
1133template<typename T, Index Log2Dim>
1134inline Index
1135PointDataLeafNode<T, Log2Dim>::buffers() const
1136{
1137 return Index( /*voxel buffer sizes*/ 1 +
1138 /*voxel buffers*/ 1 +
1139 /*attribute metadata*/ 1 +
1140 /*attribute uniform values*/ mAttributeSet->size() +
1141 /*attribute buffers*/ mAttributeSet->size() +
1142 /*cleanup*/ 1);
1143}
1144
1145template<typename T, Index Log2Dim>
1146inline void
1147PointDataLeafNode<T, Log2Dim>::readBuffers(std::istream& is, bool fromHalf)
1148{
1149 this->readBuffers(is, CoordBBox::inf(), fromHalf);
1150}
1151
1152template<typename T, Index Log2Dim>
1153inline void
1154 PointDataLeafNode<T, Log2Dim>::readBuffers(std::istream& is, const CoordBBox& /*bbox*/, bool fromHalf)
1155{
1156 struct Local
1157 {
1158 static void destroyPagedStream(const io::StreamMetadata::AuxDataMap& auxData, const Index index)
1159 {
1160 // if paged stream exists, delete it
1161 std::string key("paged:" + std::to_string(index));
1162 auto it = auxData.find(key);
1163 if (it != auxData.end()) {
1164 (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(it);
1165 }
1166 }
1167
1168 static compression::PagedInputStream& getOrInsertPagedStream( const io::StreamMetadata::AuxDataMap& auxData,
1169 const Index index)
1170 {
1171 std::string key("paged:" + std::to_string(index));
1172 auto it = auxData.find(key);
1173 if (it != auxData.end()) {
1174 return *(std::any_cast<compression::PagedInputStream::Ptr>(it->second));
1175 }
1176 else {
1177 compression::PagedInputStream::Ptr pagedStream = std::make_shared<compression::PagedInputStream>();
1178 (const_cast<io::StreamMetadata::AuxDataMap&>(auxData))[key] = pagedStream;
1179 return *pagedStream;
1180 }
1181 }
1182
1183 static bool hasMatchingDescriptor(const io::StreamMetadata::AuxDataMap& auxData)
1184 {
1185 std::string matchingKey("hasMatchingDescriptor");
1186 auto itMatching = auxData.find(matchingKey);
1187 return itMatching != auxData.end();
1188 }
1189
1190 static void clearMatchingDescriptor(const io::StreamMetadata::AuxDataMap& auxData)
1191 {
1192 std::string matchingKey("hasMatchingDescriptor");
1193 std::string descriptorKey("descriptorPtr");
1194 auto itMatching = auxData.find(matchingKey);
1195 auto itDescriptor = auxData.find(descriptorKey);
1196 if (itMatching != auxData.end()) (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itMatching);
1197 if (itDescriptor != auxData.end()) (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itDescriptor);
1198 }
1199
1200 static void insertDescriptor( const io::StreamMetadata::AuxDataMap& auxData,
1201 const Descriptor::Ptr descriptor)
1202 {
1203 std::string descriptorKey("descriptorPtr");
1204 std::string matchingKey("hasMatchingDescriptor");
1205 auto itMatching = auxData.find(matchingKey);
1206 if (itMatching == auxData.end()) {
1207 // if matching bool is not found, insert "true" and the descriptor
1208 (const_cast<io::StreamMetadata::AuxDataMap&>(auxData))[matchingKey] = true;
1209 (const_cast<io::StreamMetadata::AuxDataMap&>(auxData))[descriptorKey] = descriptor;
1210 }
1211 }
1212
1213 static AttributeSet::Descriptor::Ptr retrieveMatchingDescriptor(const io::StreamMetadata::AuxDataMap& auxData)
1214 {
1215 std::string descriptorKey("descriptorPtr");
1216 auto itDescriptor = auxData.find(descriptorKey);
1217 OPENVDB_ASSERT(itDescriptor != auxData.end());
1218 const Descriptor::Ptr descriptor = std::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
1219 return descriptor;
1220 }
1221 };
1222
1223 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(is);
1224
1225 if (!meta) {
1226 OPENVDB_THROW(IoError, "Cannot read in a PointDataLeaf without StreamMetadata.");
1227 }
1228
1229 const Index pass(static_cast<uint16_t>(meta->pass()));
1230 const Index maximumPass(static_cast<uint16_t>(meta->pass() >> 16));
1231
1232 const Index attributes = (maximumPass - 4) / 2;
1233
1234 if (pass == 0) {
1235 // pass 0 - voxel data sizes
1236 is.read(reinterpret_cast<char*>(&mVoxelBufferSize), sizeof(uint16_t));
1237 Local::clearMatchingDescriptor(meta->auxData());
1238 }
1239 else if (pass == 1) {
1240 // pass 1 - descriptor and attribute metadata
1241 if (Local::hasMatchingDescriptor(meta->auxData())) {
1242 AttributeSet::Descriptor::Ptr descriptor = Local::retrieveMatchingDescriptor(meta->auxData());
1243 mAttributeSet->resetDescriptor(descriptor, /*allowMismatchingDescriptors=*/true);
1244 }
1245 else {
1246 uint8_t header;
1247 is.read(reinterpret_cast<char*>(&header), sizeof(uint8_t));
1248 mAttributeSet->readDescriptor(is);
1249 if (header & uint8_t(1)) {
1250 AttributeSet::DescriptorPtr descriptor = mAttributeSet->descriptorPtr();
1251 Local::insertDescriptor(meta->auxData(), descriptor);
1252 }
1253 // a forwards-compatibility mechanism for future use,
1254 // if a 0x2 bit is set, read and skip over a specific number of bytes
1255 if (header & uint8_t(2)) {
1256 uint64_t bytesToSkip;
1257 is.read(reinterpret_cast<char*>(&bytesToSkip), sizeof(uint64_t));
1258 if (bytesToSkip > uint64_t(0)) {
1259 auto metadata = io::getStreamMetadataPtr(is);
1260 if (metadata && metadata->seekable()) {
1261 is.seekg(bytesToSkip, std::ios_base::cur);
1262 }
1263 else {
1264 std::vector<uint8_t> tempData(bytesToSkip);
1265 is.read(reinterpret_cast<char*>(&tempData[0]), bytesToSkip);
1266 }
1267 }
1268 }
1269 // this reader is only able to read headers with 0x1 and 0x2 bits set
1270 if (header > uint8_t(3)) {
1271 OPENVDB_THROW(IoError, "Unrecognised header flags in PointDataLeafNode");
1272 }
1273 }
1274 mAttributeSet->readMetadata(is);
1275 }
1276 else if (pass < (attributes + 2)) {
1277 // pass 2...n+2 - attribute uniform values
1278 const size_t attributeIndex = pass - 2;
1279 AttributeArray* array = attributeIndex < mAttributeSet->size() ?
1280 mAttributeSet->get(attributeIndex) : nullptr;
1281 if (array) {
1282 compression::PagedInputStream& pagedStream =
1283 Local::getOrInsertPagedStream(meta->auxData(), static_cast<Index>(attributeIndex));
1284 pagedStream.setInputStream(is);
1285 pagedStream.setSizeOnly(true);
1286 array->readPagedBuffers(pagedStream);
1287 }
1288 }
1289 else if (pass == attributes + 2) {
1290 // pass n+2 - voxel data
1291
1292 const Index passValue(meta->pass());
1293
1294 // StreamMetadata pass variable used to temporarily store voxel buffer size
1295 io::StreamMetadata& nonConstMeta = const_cast<io::StreamMetadata&>(*meta);
1296 nonConstMeta.setPass(mVoxelBufferSize);
1297
1298 // readBuffers() calls readCompressedValues specialization above
1299 BaseLeaf::readBuffers(is, fromHalf);
1300
1301 // pass now reset to original value
1302 nonConstMeta.setPass(passValue);
1303 }
1304 else if (pass < (attributes*2 + 3)) {
1305 // pass n+2..2n+2 - attribute buffers
1306 const Index attributeIndex = pass - attributes - 3;
1307 AttributeArray* array = attributeIndex < mAttributeSet->size() ?
1308 mAttributeSet->get(attributeIndex) : nullptr;
1309 if (array) {
1310 compression::PagedInputStream& pagedStream =
1311 Local::getOrInsertPagedStream(meta->auxData(), attributeIndex);
1312 pagedStream.setInputStream(is);
1313 pagedStream.setSizeOnly(false);
1314 array->readPagedBuffers(pagedStream);
1315 }
1316 // cleanup paged stream reference in auxiliary metadata
1317 if (pass > attributes + 3) {
1318 Local::destroyPagedStream(meta->auxData(), attributeIndex-1);
1319 }
1320 }
1321 else if (pass < buffers()) {
1322 // pass 2n+3 - cleanup last paged stream
1323 const Index attributeIndex = pass - attributes - 4;
1324 Local::destroyPagedStream(meta->auxData(), attributeIndex);
1325 }
1326}
1327
1328template<typename T, Index Log2Dim>
1329inline void
1330PointDataLeafNode<T, Log2Dim>::writeBuffers(std::ostream& os, bool toHalf) const
1331{
1332 struct Local
1333 {
1334 static void destroyPagedStream(const io::StreamMetadata::AuxDataMap& auxData, const Index index)
1335 {
1336 // if paged stream exists, flush and delete it
1337 std::string key("paged:" + std::to_string(index));
1338 auto it = auxData.find(key);
1339 if (it != auxData.end()) {
1340 compression::PagedOutputStream& stream = *(std::any_cast<compression::PagedOutputStream::Ptr>(it->second));
1341 stream.flush();
1342 (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(it);
1343 }
1344 }
1345
1346 static compression::PagedOutputStream& getOrInsertPagedStream( const io::StreamMetadata::AuxDataMap& auxData,
1347 const Index index)
1348 {
1349 std::string key("paged:" + std::to_string(index));
1350 auto it = auxData.find(key);
1351 if (it != auxData.end()) {
1352 return *(std::any_cast<compression::PagedOutputStream::Ptr>(it->second));
1353 }
1354 else {
1355 compression::PagedOutputStream::Ptr pagedStream = std::make_shared<compression::PagedOutputStream>();
1356 (const_cast<io::StreamMetadata::AuxDataMap&>(auxData))[key] = pagedStream;
1357 return *pagedStream;
1358 }
1359 }
1360
1361 static void insertDescriptor( const io::StreamMetadata::AuxDataMap& auxData,
1362 const Descriptor::Ptr descriptor)
1363 {
1364 std::string descriptorKey("descriptorPtr");
1365 std::string matchingKey("hasMatchingDescriptor");
1366 auto itMatching = auxData.find(matchingKey);
1367 auto itDescriptor = auxData.find(descriptorKey);
1368 if (itMatching == auxData.end()) {
1369 // if matching bool is not found, insert "true" and the descriptor
1370 (const_cast<io::StreamMetadata::AuxDataMap&>(auxData))[matchingKey] = true;
1371 OPENVDB_ASSERT(itDescriptor == auxData.end());
1372 (const_cast<io::StreamMetadata::AuxDataMap&>(auxData))[descriptorKey] = descriptor;
1373 }
1374 else {
1375 // if matching bool is found and is false, early exit (a previous descriptor did not match)
1376 bool matching = std::any_cast<bool>(itMatching->second);
1377 if (!matching) return;
1378 OPENVDB_ASSERT(itDescriptor != auxData.end());
1379 // if matching bool is true, check whether the existing descriptor matches the current one and set
1380 // matching bool to false if not
1381 const Descriptor::Ptr existingDescriptor = std::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
1382 if (*existingDescriptor != *descriptor) {
1383 (const_cast<io::StreamMetadata::AuxDataMap&>(auxData))[matchingKey] = false;
1384 }
1385 }
1386 }
1387
1388 static bool hasMatchingDescriptor(const io::StreamMetadata::AuxDataMap& auxData)
1389 {
1390 std::string matchingKey("hasMatchingDescriptor");
1391 auto itMatching = auxData.find(matchingKey);
1392 // if matching key is not found, no matching descriptor
1393 if (itMatching == auxData.end()) return false;
1394 // if matching key is found and is false, no matching descriptor
1395 if (!std::any_cast<bool>(itMatching->second)) return false;
1396 return true;
1397 }
1398
1399 static AttributeSet::Descriptor::Ptr retrieveMatchingDescriptor(const io::StreamMetadata::AuxDataMap& auxData)
1400 {
1401 std::string descriptorKey("descriptorPtr");
1402 auto itDescriptor = auxData.find(descriptorKey);
1403 // if matching key is true, however descriptor is not found, it has already been retrieved
1404 if (itDescriptor == auxData.end()) return nullptr;
1405 // otherwise remove it and return it
1406 const Descriptor::Ptr descriptor = std::any_cast<AttributeSet::Descriptor::Ptr>(itDescriptor->second);
1407 (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itDescriptor);
1408 return descriptor;
1409 }
1410
1411 static void clearMatchingDescriptor(const io::StreamMetadata::AuxDataMap& auxData)
1412 {
1413 std::string matchingKey("hasMatchingDescriptor");
1414 std::string descriptorKey("descriptorPtr");
1415 auto itMatching = auxData.find(matchingKey);
1416 auto itDescriptor = auxData.find(descriptorKey);
1417 if (itMatching != auxData.end()) (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itMatching);
1418 if (itDescriptor != auxData.end()) (const_cast<io::StreamMetadata::AuxDataMap&>(auxData)).erase(itDescriptor);
1419 }
1420 };
1421
1422 const io::StreamMetadata::Ptr meta = io::getStreamMetadataPtr(os);
1423
1424 if (!meta) {
1425 OPENVDB_THROW(IoError, "Cannot write out a PointDataLeaf without StreamMetadata.");
1426 }
1427
1428 const Index pass(static_cast<uint16_t>(meta->pass()));
1429
1430 // leaf traversal analysis deduces the number of passes to perform for this leaf
1431 // then updates the leaf traversal value to ensure all passes will be written
1432
1433 if (meta->countingPasses()) {
1434 const Index requiredPasses = this->buffers();
1435 if (requiredPasses > pass) {
1436 meta->setPass(requiredPasses);
1437 }
1438 return;
1439 }
1440
1441 const Index maximumPass(static_cast<uint16_t>(meta->pass() >> 16));
1442 const Index attributes = (maximumPass - 4) / 2;
1443
1444 if (pass == 0) {
1445 // pass 0 - voxel data sizes
1446 io::writeCompressedValuesSize(os, this->buffer().data(), SIZE);
1447 // track if descriptor is shared or not
1448 Local::insertDescriptor(meta->auxData(), mAttributeSet->descriptorPtr());
1449 }
1450 else if (pass == 1) {
1451 // pass 1 - descriptor and attribute metadata
1452 bool matchingDescriptor = Local::hasMatchingDescriptor(meta->auxData());
1453 if (matchingDescriptor) {
1454 AttributeSet::Descriptor::Ptr descriptor = Local::retrieveMatchingDescriptor(meta->auxData());
1455 if (descriptor) {
1456 // write a header to indicate a shared descriptor
1457 uint8_t header(1);
1458 os.write(reinterpret_cast<const char*>(&header), sizeof(uint8_t));
1459 mAttributeSet->writeDescriptor(os, /*transient=*/false);
1460 }
1461 }
1462 else {
1463 // write a header to indicate a non-shared descriptor
1464 uint8_t header(0);
1465 os.write(reinterpret_cast<const char*>(&header), sizeof(uint8_t));
1466 mAttributeSet->writeDescriptor(os, /*transient=*/false);
1467 }
1468 mAttributeSet->writeMetadata(os, /*transient=*/false, /*paged=*/true);
1469 }
1470 else if (pass < attributes + 2) {
1471 // pass 2...n+2 - attribute buffer sizes
1472 const Index attributeIndex = pass - 2;
1473 // destroy previous paged stream
1474 if (pass > 2) {
1475 Local::destroyPagedStream(meta->auxData(), attributeIndex-1);
1476 }
1477 const AttributeArray* array = attributeIndex < mAttributeSet->size() ?
1478 mAttributeSet->getConst(attributeIndex) : nullptr;
1479 if (array) {
1480 compression::PagedOutputStream& pagedStream =
1481 Local::getOrInsertPagedStream(meta->auxData(), attributeIndex);
1482 pagedStream.setOutputStream(os);
1483 pagedStream.setSizeOnly(true);
1484 array->writePagedBuffers(pagedStream, /*outputTransient*/false);
1485 }
1486 }
1487 else if (pass == attributes + 2) {
1488 const Index attributeIndex = pass - 3;
1489 Local::destroyPagedStream(meta->auxData(), attributeIndex);
1490 // pass n+2 - voxel data
1491 BaseLeaf::writeBuffers(os, toHalf);
1492 }
1493 else if (pass < (attributes*2 + 3)) {
1494 // pass n+3...2n+3 - attribute buffers
1495 const Index attributeIndex = pass - attributes - 3;
1496 // destroy previous paged stream
1497 if (pass > attributes + 2) {
1498 Local::destroyPagedStream(meta->auxData(), attributeIndex-1);
1499 }
1500 const AttributeArray* array = attributeIndex < mAttributeSet->size() ?
1501 mAttributeSet->getConst(attributeIndex) : nullptr;
1502 if (array) {
1503 compression::PagedOutputStream& pagedStream =
1504 Local::getOrInsertPagedStream(meta->auxData(), attributeIndex);
1505 pagedStream.setOutputStream(os);
1506 pagedStream.setSizeOnly(false);
1507 array->writePagedBuffers(pagedStream, /*outputTransient*/false);
1508 }
1509 }
1510 else if (pass < buffers()) {
1511 Local::clearMatchingDescriptor(meta->auxData());
1512 // pass 2n+3 - cleanup last paged stream
1513 const Index attributeIndex = pass - attributes - 4;
1514 Local::destroyPagedStream(meta->auxData(), attributeIndex);
1515 }
1516}
1517
1518template<typename T, Index Log2Dim>
1519inline Index64
1520PointDataLeafNode<T, Log2Dim>::memUsage() const
1521{
1522 return BaseLeaf::memUsage() + mAttributeSet->memUsage();
1523}
1524
1525template<typename T, Index Log2Dim>
1526inline Index64
1527PointDataLeafNode<T, Log2Dim>::memUsageIfLoaded() const
1528{
1529 return BaseLeaf::memUsageIfLoaded() + mAttributeSet->memUsageIfLoaded();
1530}
1531
1532template<typename T, Index Log2Dim>
1533inline void
1534PointDataLeafNode<T, Log2Dim>::evalActiveBoundingBox(CoordBBox& bbox, bool visitVoxels) const
1535{
1536 BaseLeaf::evalActiveBoundingBox(bbox, visitVoxels);
1537}
1538
1539template<typename T, Index Log2Dim>
1540inline CoordBBox
1541PointDataLeafNode<T, Log2Dim>::getNodeBoundingBox() const
1542{
1543 return BaseLeaf::getNodeBoundingBox();
1544}
1545
1546template<typename T, Index Log2Dim>
1547inline void
1548PointDataLeafNode<T, Log2Dim>::fill(const CoordBBox& bbox, const ValueType& value, bool active)
1549{
1550 if (!this->allocate()) return;
1551
1552 this->assertNonModifiableUnlessZero(value);
1553
1554 // active state is permitted to be updated
1555
1556 for (Int32 x = bbox.min().x(); x <= bbox.max().x(); ++x) {
1557 const Index offsetX = (x & (DIM-1u)) << 2*Log2Dim;
1558 for (Int32 y = bbox.min().y(); y <= bbox.max().y(); ++y) {
1559 const Index offsetXY = offsetX + ((y & (DIM-1u)) << Log2Dim);
1560 for (Int32 z = bbox.min().z(); z <= bbox.max().z(); ++z) {
1561 const Index offset = offsetXY + (z & (DIM-1u));
1562 this->setValueMask(offset, active);
1563 }
1564 }
1565 }
1566}
1567
1568template<typename T, Index Log2Dim>
1569inline void
1570 PointDataLeafNode<T, Log2Dim>::fill(const ValueType& value, bool active)
1571{
1572 this->assertNonModifiableUnlessZero(value);
1573
1574 // active state is permitted to be updated
1575
1576 if (active) this->setValuesOn();
1577 else this->setValuesOff();
1578}
1579
1580
1581////////////////////////////////////////
1582
1583
1584template <typename PointDataTreeT>
1585inline AttributeSet::Descriptor::Ptr
1586makeDescriptorUnique(PointDataTreeT& tree)
1587{
1588 auto leafIter = tree.beginLeaf();
1589 if (!leafIter) return nullptr;
1590
1591 const AttributeSet::Descriptor& descriptor = leafIter->attributeSet().descriptor();
1592 auto newDescriptor = std::make_shared<AttributeSet::Descriptor>(descriptor);
1593 for (; leafIter; ++leafIter) {
1594 leafIter->resetDescriptor(newDescriptor);
1595 }
1596
1597 return newDescriptor;
1598}
1599
1600
1601template <typename PointDataTreeT>
1602inline void
1603setStreamingMode(PointDataTreeT& tree, bool on)
1604{
1605 auto leafIter = tree.beginLeaf();
1606 for (; leafIter; ++leafIter) {
1607 for (size_t i = 0; i < leafIter->attributeSet().size(); i++) {
1608 leafIter->attributeArray(i).setStreaming(on);
1609 }
1610 }
1611}
1612
1613
1614template <typename PointDataTreeT>
1615inline void
1616prefetch(PointDataTreeT& tree, bool position, bool otherAttributes)
1617{
1618 // NOTE: the following is intentionally not multi-threaded, as the I/O
1619 // is faster if done in the order in which it is stored in the file
1620
1621 auto leaf = tree.cbeginLeaf();
1622 if (!leaf) return;
1623
1624 const auto& attributeSet = leaf->attributeSet();
1625
1626 // pre-fetch leaf data
1627
1628 for ( ; leaf; ++leaf) {
1629 leaf->buffer().data();
1630 }
1631
1632 // pre-fetch position attribute data (position will typically have index 0)
1633
1634 size_t positionIndex = attributeSet.find("P");
1635
1636 if (position && positionIndex != AttributeSet::INVALID_POS) {
1637 for (leaf = tree.cbeginLeaf(); leaf; ++leaf) {
1638 OPENVDB_ASSERT(leaf->hasAttribute(positionIndex));
1639 leaf->constAttributeArray(positionIndex).loadData();
1640 }
1641 }
1642
1643 // pre-fetch other attribute data
1644
1645 if (otherAttributes) {
1646 const size_t attributes = attributeSet.size();
1647 for (size_t attributeIndex = 0; attributeIndex < attributes; attributeIndex++) {
1648 if (attributeIndex == positionIndex) continue;
1649 for (leaf = tree.cbeginLeaf(); leaf; ++leaf) {
1650 OPENVDB_ASSERT(leaf->hasAttribute(attributeIndex));
1651 leaf->constAttributeArray(attributeIndex).loadData();
1652 }
1653 }
1654 }
1655}
1656
1657
1658namespace internal {
1659
1660/// @brief Global registration of point data-related types
1661/// @note This is called from @c openvdb::initialize, so there is
1662/// no need to call it directly.
1663 void initialize();
1664
1665/// @brief Global deregistration of point data-related types
1666/// @note This is called from @c openvdb::uninitialize, so there is
1667/// no need to call it directly.
1668 void uninitialize();
1669
1670
1671/// @brief Recursive node chain which generates a openvdb::TypeList value
1672/// converted types of nodes to PointDataGrid nodes of the same configuration,
1673/// rooted at RootNodeType in reverse order, from LeafNode to RootNode.
1674/// See also TreeConverter<>.
1675template<typename HeadT, int HeadLevel>
1676 struct PointDataNodeChain
1677{
1678 using SubtreeT = typename PointDataNodeChain<typename HeadT::ChildNodeType, HeadLevel-1>::Type;
1679 using RootNodeT = tree::RootNode<typename SubtreeT::Back>;
1680 using Type = typename SubtreeT::template Append<RootNodeT>;
1681};
1682
1683// Specialization for internal nodes which require their embedded child type to
1684// be switched
1685template <typename ChildT, Index Log2Dim, int HeadLevel>
1686 struct PointDataNodeChain<tree::InternalNode<ChildT, Log2Dim>, HeadLevel>
1687{
1688 using SubtreeT = typename PointDataNodeChain<ChildT, HeadLevel-1>::Type;
1689 using InternalNodeT = tree::InternalNode<typename SubtreeT::Back, Log2Dim>;
1690 using Type = typename SubtreeT::template Append<InternalNodeT>;
1691};
1692
1693// Specialization for the last internal node of a node chain, expected
1694// to be templated on a leaf node
1695template <typename ChildT, Index Log2Dim>
1696 struct PointDataNodeChain<tree::InternalNode<ChildT, Log2Dim>, /*HeadLevel=*/1>
1697{
1698 using LeafNodeT = PointDataLeafNode<PointDataIndex32, ChildT::LOG2DIM>;
1699 using InternalNodeT = tree::InternalNode<LeafNodeT, Log2Dim>;
1700 using Type = TypeList<LeafNodeT, InternalNodeT>;
1701};
1702
1703} // namespace internal
1704
1705
1706/// @brief Similiar to ValueConverter, but allows for tree configuration conversion
1707/// to a PointDataTree. ValueConverter<PointDataIndex32> cannot be used as a
1708/// PointDataLeafNode is not a specialization of LeafNode
1709template <typename TreeType>
1710 struct TreeConverter {
1711 using RootNodeT = typename TreeType::RootNodeType;
1712 using NodeChainT = typename internal::PointDataNodeChain<RootNodeT, RootNodeT::LEVEL>::Type;
1713 using Type = tree::Tree<typename NodeChainT::Back>;
1714};
1715
1716
1717} // namespace points
1718
1719
1720////////////////////////////////////////
1721
1722
1723namespace tree
1724{
1725
1726/// Helper metafunction used to implement LeafNode::SameConfiguration
1727/// (which, as an inner class, can't be independently specialized)
1728template<Index Dim1, typename T2>
1729 struct SameLeafConfig<Dim1, points::PointDataLeafNode<T2, Dim1>> { static const bool value = true; };
1730
1731} // namespace tree
1732} // namespace OPENVDB_VERSION_NAME
1733} // namespace openvdb
1734
1735#endif // OPENVDB_POINTS_POINT_DATA_GRID_HAS_BEEN_INCLUDED
Assert.h
OPENVDB_ASSERT
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
AttributeArrayString.h
Attribute array storage for string data using Descriptor Metadata.
AttributeArray.h
Attribute Array storage templated on type and compression codec.
AttributeGroup.h
Attribute Group access and filtering for iteration.
AttributeSet.h
Set of Attribute Arrays which tracks metadata about each array.
Grid.h
LeafNode.h
OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_END
Definition Platform.h:164
OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
#define OPENVDB_NO_UNREACHABLE_CODE_WARNING_BEGIN
Definition Platform.h:163
VMASK_
#define VMASK_
Definition PointDataGrid.h:702
PointIndexGrid.h
Space-partitioning acceleration structure for points. Partitions the points into voxels to accelerate...
StreamCompression.h
Convenience wrappers to using Blosc and reading and writing of Paged data.
Tree.h
openvdb::v13_0::CoordBBox::inf
static CoordBBox inf()
Return an "infinite" bounding box, as defined by the Coord value range.
Definition Coord.h:322
openvdb::v13_0::Grid
Container class that associates a tree with a transform and metadata.
Definition Grid.h:571
openvdb::v13_0::IndexError
Definition Exceptions.h:57
openvdb::v13_0::IoError
Definition Exceptions.h:58
openvdb::v13_0::LookupError
Definition Exceptions.h:60
openvdb::v13_0::Metadata
Base class for storing metadata information in a grid.
Definition Metadata.h:25
openvdb::v13_0::PartialCreate
Tag dispatch class that distinguishes constructors during file input.
Definition Types.h:756
openvdb::v13_0::TopologyCopy
Tag dispatch class that distinguishes topology copy constructors from deep copy constructors.
Definition Types.h:750
openvdb::v13_0::ValueError
Definition Exceptions.h:65
openvdb::v13_0::compression::PagedInputStream
A Paging wrapper to std::istream that is responsible for reading from a given input stream and creati...
Definition StreamCompression.h:208
openvdb::v13_0::compression::PagedInputStream::setSizeOnly
void setSizeOnly(bool sizeOnly)
Size-only mode tags the stream as only reading size data.
Definition StreamCompression.h:217
openvdb::v13_0::compression::PagedInputStream::setInputStream
void setInputStream(std::istream &is)
Definition StreamCompression.h:222
openvdb::v13_0::compression::PagedInputStream::Ptr
std::shared_ptr< PagedInputStream > Ptr
Definition StreamCompression.h:210
openvdb::v13_0::compression::PagedOutputStream
A Paging wrapper to std::ostream that is responsible for writing from a given output stream at interv...
Definition StreamCompression.h:245
openvdb::v13_0::compression::PagedOutputStream::setSizeOnly
void setSizeOnly(bool sizeOnly)
Size-only mode tags the stream as only writing size data.
Definition StreamCompression.h:254
openvdb::v13_0::compression::PagedOutputStream::setOutputStream
void setOutputStream(std::ostream &os)
Definition StreamCompression.h:259
openvdb::v13_0::compression::PagedOutputStream::Ptr
std::shared_ptr< PagedOutputStream > Ptr
Definition StreamCompression.h:247
openvdb::v13_0::compression::PagedOutputStream::flush
void flush()
Manually flushes the current page to disk if non-zero.
openvdb::v13_0::io::StreamMetadata
Container for metadata describing how to unserialize grids from and/or serialize grids to a stream (w...
Definition io.h:31
openvdb::v13_0::io::StreamMetadata::AuxDataMap
std::map< std::string, std::any > AuxDataMap
Definition io.h:92
openvdb::v13_0::io::StreamMetadata::Ptr
SharedPtr< StreamMetadata > Ptr
Definition io.h:33
openvdb::v13_0::io::StreamMetadata::setPass
void setPass(uint32_t)
openvdb::v13_0::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition Coord.h:252
openvdb::v13_0::math::CoordBBox::min
const Coord & min() const
Definition Coord.h:324
openvdb::v13_0::math::CoordBBox::max
const Coord & max() const
Definition Coord.h:325
openvdb::v13_0::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition Coord.h:26
openvdb::v13_0::math::Coord::y
Int32 y() const
Definition Coord.h:132
openvdb::v13_0::math::Coord::x
Int32 x() const
Definition Coord.h:131
openvdb::v13_0::math::Coord::z
Int32 z() const
Definition Coord.h:133
openvdb::v13_0::points::AttributeArray::ScopedRegistryLock
Definition AttributeArray.h:120
openvdb::v13_0::points::AttributeArray
Base class for storing attribute data.
Definition AttributeArray.h:94
openvdb::v13_0::points::AttributeArray::Ptr
std::shared_ptr< AttributeArray > Ptr
Definition AttributeArray.h:126
openvdb::v13_0::points::AttributeArray::size
virtual Index size() const =0
openvdb::v13_0::points::AttributeArray::compact
virtual bool compact()=0
Compact the existing array to become uniform if all values are identical.
openvdb::v13_0::points::AttributeArray::readPagedBuffers
virtual void readPagedBuffers(compression::PagedInputStream &)=0
Read attribute buffers from a paged stream.
openvdb::v13_0::points::AttributeArray::writePagedBuffers
virtual void writePagedBuffers(compression::PagedOutputStream &, bool outputTransient) const =0
openvdb::v13_0::points::AttributeSet::Descriptor
An immutable object that stores name, type and AttributeSet position for a constant collection of att...
Definition AttributeSet.h:311
openvdb::v13_0::points::AttributeSet::Descriptor::GroupIndex
Util::GroupIndex GroupIndex
Definition AttributeSet.h:317
openvdb::v13_0::points::AttributeSet::Descriptor::Ptr
std::shared_ptr< Descriptor > Ptr
Definition AttributeSet.h:313
openvdb::v13_0::points::AttributeSet
Ordered collection of uniquely-named attribute arrays.
Definition AttributeSet.h:40
openvdb::v13_0::points::AttributeSet::descriptor
Descriptor & descriptor()
Return a reference to this attribute set's descriptor, which might be shared with other sets.
Definition AttributeSet.h:103
openvdb::v13_0::points::AttributeSet::INVALID_POS
@ INVALID_POS
Definition AttributeSet.h:42
openvdb::v13_0::points::AttributeSet::UniquePtr
std::unique_ptr< AttributeSet > UniquePtr
Definition AttributeSet.h:46
openvdb::v13_0::points::AttributeSet::DescriptorPtr
std::shared_ptr< Descriptor > DescriptorPtr
Definition AttributeSet.h:50
openvdb::v13_0::points::GroupFilter
Index filtering on group membership.
Definition AttributeGroup.h:136
openvdb::v13_0::points::GroupFilter::state
static index::State state()
Definition AttributeGroup.h:146
openvdb::v13_0::points::GroupHandle
Definition AttributeGroup.h:74
openvdb::v13_0::points::GroupWriteHandle
Definition AttributeGroup.h:103
openvdb::v13_0::points::IndexIter
A forward iterator over array indices with filtering IteratorT can be either IndexIter or ValueIndexI...
Definition IndexIterator.h:141
openvdb::v13_0::points::NullFilter
A no-op filter that can be used when iterating over all indices.
Definition IndexIterator.h:52
openvdb::v13_0::points::PointDataLeafNode
Definition PointDataGrid.h:240
openvdb::v13_0::points::PointDataLeafNode::ValueOffIter
typename BaseLeaf::template ValueIter< MaskOffIterator, PointDataLeafNode, const ValueType, ValueOff > ValueOffIter
Definition PointDataGrid.h:632
openvdb::v13_0::points::PointDataLeafNode::cbeginChildOn
ChildOnCIter cbeginChildOn() const
Definition PointDataGrid.h:723
openvdb::v13_0::points::PointDataLeafNode::ValueOffCIter
typename BaseLeaf::template ValueIter< MaskOffIterator, const PointDataLeafNode, const ValueType, ValueOff > ValueOffCIter
Definition PointDataGrid.h:634
openvdb::v13_0::points::PointDataLeafNode::getNodeBoundingBox
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node.
Definition PointDataGrid.h:1541
openvdb::v13_0::points::PointDataLeafNode::IndexAllIter
IndexIter< ValueAllCIter, NullFilter > IndexAllIter
Definition PointDataGrid.h:654
openvdb::v13_0::points::PointDataLeafNode::setValueOn
void setValueOn(Index offset)
Definition PointDataGrid.h:544
openvdb::v13_0::points::PointDataLeafNode::setValueOff
void setValueOff(const Coord &, const ValueType &)
Definition PointDataGrid.h:540
openvdb::v13_0::points::PointDataLeafNode::beginChildOn
ChildOnCIter beginChildOn() const
Definition PointDataGrid.h:724
openvdb::v13_0::points::PointDataLeafNode::beginChildOn
ChildOnIter beginChildOn()
Definition PointDataGrid.h:725
openvdb::v13_0::points::PointDataLeafNode::setActiveStateAndCache
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &parent)
Definition PointDataGrid.h:582
openvdb::v13_0::points::PointDataLeafNode::replaceAttributeSet
void replaceAttributeSet(AttributeSet *attributeSet, bool allowMismatchingDescriptors=false)
Replace the underlying attribute set with the given attributeSet.
Definition PointDataGrid.h:850
openvdb::v13_0::points::PointDataLeafNode::groupWriteHandle
GroupWriteHandle groupWriteHandle(const Name &name)
Read-write group handle from group name.
Definition PointDataGrid.h:991
openvdb::v13_0::points::PointDataLeafNode::constAttributeArray
const AttributeArray & constAttributeArray(const Name &attributeName) const
Definition PointDataGrid.h:952
openvdb::v13_0::points::PointDataLeafNode::IndexOffIter
IndexIter< ValueOffCIter, NullFilter > IndexOffIter
Definition PointDataGrid.h:656
openvdb::v13_0::points::PointDataLeafNode::endValueOn
ValueOnIter endValueOn()
Definition PointDataGrid.h:715
openvdb::v13_0::points::PointDataLeafNode::LeafNodeType
PointDataLeafNode< T, Log2Dim > LeafNodeType
Definition PointDataGrid.h:243
openvdb::v13_0::points::PointDataLeafNode::writeTopology
void writeTopology(std::ostream &os, bool toHalf=false) const
Definition PointDataGrid.h:1128
openvdb::v13_0::points::PointDataLeafNode::NodeMaskType
util::NodeMask< Log2Dim > NodeMaskType
Definition PointDataGrid.h:258
openvdb::v13_0::points::PointDataLeafNode::appendAttribute
AttributeArray::Ptr appendAttribute(const Descriptor &expected, Descriptor::Ptr &replacement, const size_t pos, const Index strideOrTotalSize=1, const bool constantStride=true, const Metadata *metadata=nullptr, const AttributeArray::ScopedRegistryLock *lock=nullptr)
Append an attribute to the leaf.
Definition PointDataGrid.h:806
openvdb::v13_0::points::PointDataLeafNode::touchLeaf
PointDataLeafNode * touchLeaf(const Coord &)
Return a pointer to this node.
Definition PointDataGrid.h:459
openvdb::v13_0::points::PointDataLeafNode::PointDataLeafNode
PointDataLeafNode(const tools::PointIndexLeafNode< OtherValueType, Log2Dim > &other)
Definition PointDataGrid.h:297
openvdb::v13_0::points::PointDataLeafNode::cbeginValueOff
ValueOffCIter cbeginValueOff() const
Definition PointDataGrid.h:706
openvdb::v13_0::points::PointDataLeafNode::touchLeafAndCache
PointDataLeafNode * touchLeafAndCache(const Coord &, AccessorT &)
Definition PointDataGrid.h:461
openvdb::v13_0::points::PointDataLeafNode::validateOffsets
void validateOffsets() const
Throws an error if the voxel values on this leaf are not monotonically increasing or within the bound...
Definition PointDataGrid.h:887
openvdb::v13_0::points::PointDataLeafNode::ChildAllIter
typename BaseLeaf::template DenseIter< PointDataLeafNode, ValueType, ChildAll > ChildAllIter
Definition PointDataGrid.h:648
openvdb::v13_0::points::PointDataLeafNode::PointDataLeafNode
PointDataLeafNode(const PointDataLeafNode &other, const Coord &coords, const T &value=zeroVal< T >(), bool active=false)
Definition PointDataGrid.h:287
openvdb::v13_0::points::PointDataLeafNode::operator==
bool operator==(const PointDataLeafNode &other) const
Definition PointDataGrid.h:446
openvdb::v13_0::points::PointDataLeafNode::ValueAllIter
typename BaseLeaf::template ValueIter< MaskDenseIterator, PointDataLeafNode, const ValueType, ValueAll > ValueAllIter
Definition PointDataGrid.h:636
openvdb::v13_0::points::PointDataLeafNode::attributeArray
const AttributeArray & attributeArray(const size_t pos) const
Definition PointDataGrid.h:919
openvdb::v13_0::points::PointDataLeafNode::hasSameTopology
bool hasSameTopology(const PointDataLeafNode< OtherType, OtherLog2Dim > *other) const
Return true if the given node (which may have a different ValueType than this node) has the same acti...
Definition PointDataGrid.h:440
openvdb::v13_0::points::PointDataLeafNode::endChildOn
ChildOnIter endChildOn()
Definition PointDataGrid.h:735
openvdb::v13_0::points::PointDataLeafNode::endValueAll
ValueAllIter endValueAll()
Definition PointDataGrid.h:721
openvdb::v13_0::points::PointDataLeafNode::groupWriteHandle
GroupWriteHandle groupWriteHandle(const AttributeSet::Descriptor::GroupIndex &index)
Read-write group handle from group index.
Definition PointDataGrid.h:979
openvdb::v13_0::points::PointDataLeafNode::modifyValue
void modifyValue(Index, const ModifyOp &)
Definition PointDataGrid.h:555
openvdb::v13_0::points::PointDataLeafNode::groupPointCount
Index64 groupPointCount(const Name &groupName) const
Compute the point count in a specific group for the leaf.
Definition PointDataGrid.h:1079
openvdb::v13_0::points::PointDataLeafNode::setValueOn
void setValueOn(Index, const ValueType &)
Definition PointDataGrid.h:547
openvdb::v13_0::points::PointDataLeafNode::setValuesOff
void setValuesOff()
Definition PointDataGrid.h:552
openvdb::v13_0::points::PointDataLeafNode::endValueAll
ValueAllCIter endValueAll() const
Definition PointDataGrid.h:720
openvdb::v13_0::points::PointDataLeafNode::probeLeaf
const PointDataLeafNode * probeLeaf(const Coord &) const
Definition PointDataGrid.h:483
openvdb::v13_0::points::PointDataLeafNode::endChildOff
ChildOffCIter endChildOff() const
Definition PointDataGrid.h:737
openvdb::v13_0::points::PointDataLeafNode::setValueOff
void setValueOff(Index, const ValueType &)
Definition PointDataGrid.h:541
openvdb::v13_0::points::PointDataLeafNode::ChildOffCIter
typename BaseLeaf::template ChildIter< MaskOffIterator, const PointDataLeafNode, ChildOff > ChildOffCIter
Definition PointDataGrid.h:646
openvdb::v13_0::points::PointDataLeafNode::PointDataLeafNode
PointDataLeafNode(PartialCreate, const Coord &coords, const T &value=zeroVal< T >(), bool active=false)
Definition PointDataGrid.h:315
openvdb::v13_0::points::PointDataLeafNode::cbeginValueAll
ValueAllCIter cbeginValueAll() const
Definition PointDataGrid.h:709
openvdb::v13_0::points::PointDataLeafNode::ChildOff
typename BaseLeaf::ChildOff ChildOff
Definition PointDataGrid.h:607
openvdb::v13_0::points::PointDataLeafNode::attributeArray
AttributeArray & attributeArray(const size_t pos)
Read-write attribute array reference from index.
Definition PointDataGrid.h:911
openvdb::v13_0::points::PointDataLeafNode::readTopology
void readTopology(std::istream &is, bool fromHalf=false)
Definition PointDataGrid.h:1121
openvdb::v13_0::points::PointDataLeafNode::probeConstLeaf
const PointDataLeafNode * probeConstLeaf(const Coord &) const
Return a const pointer to this node.
Definition PointDataGrid.h:478
openvdb::v13_0::points::PointDataLeafNode::setValueOnly
void setValueOnly(Index, const ValueType &)
Definition PointDataGrid.h:535
openvdb::v13_0::points::PointDataLeafNode::BaseLeaf
tree::LeafNode< T, Log2Dim > BaseLeaf
Definition PointDataGrid.h:257
openvdb::v13_0::points::PointDataLeafNode::groupHandle
GroupHandle groupHandle(const Name &group) const
Read-only group handle from group name.
Definition PointDataGrid.h:971
openvdb::v13_0::points::PointDataLeafNode::Ptr
std::shared_ptr< PointDataLeafNode > Ptr
Definition PointDataGrid.h:244
openvdb::v13_0::points::PointDataLeafNode::beginIndexAll
IndexAllIter beginIndexAll() const
Leaf index iterator.
Definition PointDataGrid.h:659
openvdb::v13_0::points::PointDataLeafNode::beginValueOn
ValueOnCIter beginValueOn() const
Definition PointDataGrid.h:704
openvdb::v13_0::points::PointDataLeafNode::clearAttributes
void clearAttributes(const bool updateValueMask=true, const AttributeArray::ScopedRegistryLock *lock=nullptr)
Clear the attribute set.
Definition PointDataGrid.h:775
openvdb::v13_0::points::PointDataLeafNode::hasAttribute
bool hasAttribute(const Name &attributeName) const
Returns true if an attribute with this name exists.
Definition PointDataGrid.h:798
openvdb::v13_0::points::PointDataLeafNode::ChildOn
typename BaseLeaf::ChildOn ChildOn
Definition PointDataGrid.h:606
openvdb::v13_0::points::PointDataLeafNode::signedFloodFill
void signedFloodFill(const ValueType &, const ValueType &)
Definition PointDataGrid.h:591
openvdb::v13_0::points::PointDataLeafNode::PointDataLeafNode
PointDataLeafNode(const PointDataLeafNode &other)
Construct using deep copy of other PointDataLeafNode.
Definition PointDataGrid.h:275
openvdb::v13_0::points::PointDataLeafNode< PointDataIndex32, ChildT::LOG2DIM >::updateValueMask
void updateValueMask()
openvdb::v13_0::points::PointDataLeafNode::modifyValueAndActiveState
void modifyValueAndActiveState(const Coord &, const ModifyOp &)
Definition PointDataGrid.h:561
openvdb::v13_0::points::PointDataLeafNode::ChildAll
typename BaseLeaf::ChildAll ChildAll
Definition PointDataGrid.h:608
openvdb::v13_0::points::PointDataLeafNode< PointDataIndex32, ChildT::LOG2DIM >::beginIndex
IndexIter< IterT, FilterT > beginIndex(const FilterT &filter) const
openvdb::v13_0::points::PointDataLeafNode::IndexVoxelIter
IndexIter< ValueVoxelCIter, NullFilter > IndexVoxelIter
Definition PointDataGrid.h:653
openvdb::v13_0::points::PointDataLeafNode::cendValueOn
ValueOnCIter cendValueOn() const
Definition PointDataGrid.h:713
openvdb::v13_0::points::PointDataLeafNode::setOffsetOnly
void setOffsetOnly(Index offset, const ValueType &val)
Definition PointDataGrid.h:1114
openvdb::v13_0::points::PointDataLeafNode::pointCount
Index64 pointCount() const
Compute the total point count for the leaf.
Definition PointDataGrid.h:1054
openvdb::v13_0::points::PointDataLeafNode::beginValueOff
ValueOffCIter beginValueOff() const
Definition PointDataGrid.h:707
openvdb::v13_0::points::PointDataLeafNode::resetDescriptor
void resetDescriptor(const Descriptor::Ptr &replacement)
Replace the descriptor with a new one The new Descriptor must exactly match the old one.
Definition PointDataGrid.h:865
openvdb::v13_0::points::PointDataLeafNode::beginIndexOff
IndexOffIter beginIndexOff() const
Definition PointDataGrid.h:669
openvdb::v13_0::points::PointDataLeafNode::cbeginChildAll
ChildAllCIter cbeginChildAll() const
Definition PointDataGrid.h:729
openvdb::v13_0::points::PointDataLeafNode::endChildOff
ChildOffIter endChildOff()
Definition PointDataGrid.h:738
openvdb::v13_0::points::PointDataLeafNode::modifyValueAndActiveStateAndCache
void modifyValueAndActiveStateAndCache(const Coord &, const ModifyOp &, AccessorT &)
Definition PointDataGrid.h:574
openvdb::v13_0::points::PointDataLeafNode::setValueOnly
void setValueOnly(const Coord &, const ValueType &)
Definition PointDataGrid.h:534
openvdb::v13_0::points::PointDataLeafNode::beginChildAll
ChildAllIter beginChildAll()
Definition PointDataGrid.h:731
openvdb::v13_0::points::PointDataLeafNode::renameAttributes
void renameAttributes(const Descriptor &expected, Descriptor::Ptr &replacement)
Rename attributes in attribute set (order must remain the same).
Definition PointDataGrid.h:833
openvdb::v13_0::points::PointDataLeafNode::ChildAllCIter
typename BaseLeaf::template DenseIter< const PointDataLeafNode, const ValueType, ChildAll > ChildAllCIter
Definition PointDataGrid.h:650
openvdb::v13_0::points::PointDataLeafNode::probeConstLeafAndCache
const PointDataLeafNode * probeConstLeafAndCache(const Coord &, AccessorT &) const
Definition PointDataGrid.h:480
openvdb::v13_0::points::PointDataLeafNode::DIM
static const Index DIM
Definition LeafNode.h:51
openvdb::v13_0::points::PointDataLeafNode::setActiveState
void setActiveState(const Coord &xyz, bool on)
Definition PointDataGrid.h:531
openvdb::v13_0::points::PointDataLeafNode::beginValueOn
ValueOnIter beginValueOn()
Definition PointDataGrid.h:705
openvdb::v13_0::points::PointDataLeafNode::initializeAttributes
void initializeAttributes(const Descriptor::Ptr &descriptor, const Index arrayLength, const AttributeArray::ScopedRegistryLock *lock=nullptr)
Create a new attribute set. Existing attributes will be removed.
Definition PointDataGrid.h:760
openvdb::v13_0::points::PointDataLeafNode::ValueOnIter
typename BaseLeaf::template ValueIter< MaskOnIterator, PointDataLeafNode, const ValueType, ValueOn > ValueOnIter
Definition PointDataGrid.h:628
openvdb::v13_0::points::PointDataLeafNode::beginValueVoxel
ValueVoxelCIter beginValueVoxel(const Coord &ijk) const
Leaf value voxel iterator.
Definition PointDataGrid.h:1024
openvdb::v13_0::points::PointDataLeafNode::probeNodeAndCache
NodeT * probeNodeAndCache(const Coord &, AccessorT &)
Definition PointDataGrid.h:464
openvdb::v13_0::points::PointDataLeafNode::beginIndexAll
IndexIter< ValueAllCIter, FilterT > beginIndexAll(const FilterT &filter) const
Filtered leaf index iterator.
Definition PointDataGrid.h:680
openvdb::v13_0::points::PointDataLeafNode< PointDataIndex32, ChildT::LOG2DIM >::assertNonModifiableUnlessZero
void assertNonModifiableUnlessZero(const ValueType &value)
Definition PointDataGrid.h:527
openvdb::v13_0::points::PointDataLeafNode::probeLeafAndCache
const PointDataLeafNode * probeLeafAndCache(const Coord &, AccessorT &) const
Definition PointDataGrid.h:482
openvdb::v13_0::points::PointDataLeafNode::cbeginChildOff
ChildOffCIter cbeginChildOff() const
Definition PointDataGrid.h:726
openvdb::v13_0::points::PointDataLeafNode::ChildOnCIter
typename BaseLeaf::template ChildIter< MaskOnIterator, const PointDataLeafNode, ChildOn > ChildOnCIter
Definition PointDataGrid.h:642
openvdb::v13_0::points::PointDataLeafNode::beginChildOff
ChildOffIter beginChildOff()
Definition PointDataGrid.h:728
openvdb::v13_0::points::PointDataLeafNode::beginChildOff
ChildOffCIter beginChildOff() const
Definition PointDataGrid.h:727
openvdb::v13_0::points::PointDataLeafNode::dropAttributes
void dropAttributes(const std::vector< size_t > &pos, const Descriptor &expected, Descriptor::Ptr &replacement)
Drop list of attributes.
Definition PointDataGrid.h:818
openvdb::v13_0::points::PointDataLeafNode::compactAttributes
void compactAttributes()
Compact all attributes in attribute set.
Definition PointDataGrid.h:840
openvdb::v13_0::points::PointDataLeafNode::setValueOff
void setValueOff(const Coord &xyz)
Definition PointDataGrid.h:537
openvdb::v13_0::points::PointDataLeafNode::operator!=
bool operator!=(const PointDataLeafNode &other) const
Definition PointDataGrid.h:451
openvdb::v13_0::points::PointDataLeafNode::buffers
Index buffers() const
Definition PointDataGrid.h:1135
openvdb::v13_0::points::PointDataLeafNode::endValueOff
ValueOffIter endValueOff()
Definition PointDataGrid.h:718
openvdb::v13_0::points::PointDataLeafNode::setValueOff
void setValueOff(Index offset)
Definition PointDataGrid.h:538
openvdb::v13_0::points::PointDataLeafNode::beginIndexOn
IndexIter< ValueOnCIter, FilterT > beginIndexOn(const FilterT &filter) const
Definition PointDataGrid.h:685
openvdb::v13_0::points::PointDataLeafNode::endChildAll
ChildAllCIter endChildAll() const
Definition PointDataGrid.h:740
openvdb::v13_0::points::PointDataLeafNode::setOffsets
void setOffsets(const std::vector< ValueType > &offsets, const bool updateValueMask=true)
Sets all of the voxel offset values on this leaf, from the given vector of offsets....
Definition PointDataGrid.h:872
openvdb::v13_0::points::PointDataLeafNode::probeConstNodeAndCache
const NodeT * probeConstNodeAndCache(const Coord &, AccessorT &) const
Definition PointDataGrid.h:485
openvdb::v13_0::points::PointDataLeafNode::setOffsetOn
void setOffsetOn(Index offset, const ValueType &val)
Definition PointDataGrid.h:1106
openvdb::v13_0::points::PointDataLeafNode::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Definition PointDataGrid.h:703
openvdb::v13_0::points::PointDataLeafNode::writeBuffers
void writeBuffers(std::ostream &os, bool toHalf=false) const
Definition PointDataGrid.h:1330
openvdb::v13_0::points::PointDataLeafNode::IndexOnIter
IndexIter< ValueOnCIter, NullFilter > IndexOnIter
Definition PointDataGrid.h:655
openvdb::v13_0::points::PointDataLeafNode::clip
void clip(const CoordBBox &, const ValueType &value)
Definition PointDataGrid.h:564
openvdb::v13_0::points::PointDataLeafNode::endChildOn
ChildOnCIter endChildOn() const
Definition PointDataGrid.h:734
openvdb::v13_0::points::PointDataLeafNode::reorderAttributes
void reorderAttributes(const Descriptor::Ptr &replacement)
Reorder attribute set.
Definition PointDataGrid.h:826
openvdb::v13_0::points::PointDataLeafNode::ChildOnIter
typename BaseLeaf::template ChildIter< MaskOnIterator, PointDataLeafNode, ChildOn > ChildOnIter
Definition PointDataGrid.h:640
openvdb::v13_0::points::PointDataLeafNode::cendChildOn
ChildOnCIter cendChildOn() const
Definition PointDataGrid.h:733
openvdb::v13_0::points::PointDataLeafNode::fill
void fill(const ValueType &, bool)
Definition PointDataGrid.h:1570
openvdb::v13_0::points::PointDataLeafNode::cendChildAll
ChildAllCIter cendChildAll() const
Definition PointDataGrid.h:739
openvdb::v13_0::points::PointDataLeafNode::PointDataLeafNode
PointDataLeafNode()
Default constructor.
Definition PointDataGrid.h:269
openvdb::v13_0::points::PointDataLeafNode::attributeSet
const AttributeSet & attributeSet() const
Retrieve the attribute set.
Definition PointDataGrid.h:323
openvdb::v13_0::points::PointDataLeafNode::assertNonmodifiable
void assertNonmodifiable()
Definition PointDataGrid.h:520
openvdb::v13_0::points::PointDataLeafNode::memUsageIfLoaded
Index64 memUsageIfLoaded() const
Definition PointDataGrid.h:1527
openvdb::v13_0::points::PointDataLeafNode::setValueOffAndCache
void setValueOffAndCache(const Coord &, const ValueType &, AccessorT &)
Definition PointDataGrid.h:579
openvdb::v13_0::points::PointDataLeafNode::endChildAll
ChildAllIter endChildAll()
Definition PointDataGrid.h:741
openvdb::v13_0::points::PointDataLeafNode::beginIndexOff
IndexIter< ValueOffCIter, FilterT > beginIndexOff(const FilterT &filter) const
Definition PointDataGrid.h:690
openvdb::v13_0::points::PointDataLeafNode::hasAttribute
bool hasAttribute(const size_t pos) const
Returns true if an attribute with this index exists.
Definition PointDataGrid.h:791
openvdb::v13_0::points::PointDataLeafNode::groupHandle
GroupHandle groupHandle(const AttributeSet::Descriptor::GroupIndex &index) const
}
Definition PointDataGrid.h:959
openvdb::v13_0::points::PointDataLeafNode::resetBackground
void resetBackground(const ValueType &, const ValueType &newBackground)
Definition PointDataGrid.h:586
openvdb::v13_0::points::PointDataLeafNode::MaskOffIterator
typename NodeMaskType::OffIterator MaskOffIterator
Definition PointDataGrid.h:611
openvdb::v13_0::points::PointDataLeafNode::PointDataLeafNode
PointDataLeafNode(const tree::LeafNode< ValueType, Log2Dim > &other, const T &value, TopologyCopy)
Definition PointDataGrid.h:304
openvdb::v13_0::points::PointDataLeafNode::stealAttributeSet
AttributeSet::UniquePtr stealAttributeSet()
Steal the attribute set, a new, empty attribute set is inserted in it's place.
Definition PointDataGrid.h:751
openvdb::v13_0::points::PointDataLeafNode::readBuffers
void readBuffers(std::istream &is, bool fromHalf=false)
Definition PointDataGrid.h:1147
openvdb::v13_0::points::PointDataLeafNode::setValue
void setValue(const Coord &, const ValueType &)
Definition PointDataGrid.h:549
openvdb::v13_0::points::PointDataLeafNode::cendValueAll
ValueAllCIter cendValueAll() const
Definition PointDataGrid.h:719
openvdb::v13_0::points::PointDataLeafNode::~PointDataLeafNode
~PointDataLeafNode()=default
openvdb::v13_0::points::PointDataLeafNode::NUM_VALUES
static const Index NUM_VALUES
Definition LeafNode.h:52
openvdb::v13_0::points::PointDataLeafNode::negate
void negate()
Definition PointDataGrid.h:593
openvdb::v13_0::points::PointDataLeafNode::beginChildAll
ChildAllCIter beginChildAll() const
Definition PointDataGrid.h:730
openvdb::v13_0::points::PointDataLeafNode::ValueAll
typename BaseLeaf::ValueAll ValueAll
Definition PointDataGrid.h:599
openvdb::v13_0::points::PointDataLeafNode::ValueTypePair
std::pair< ValueType, ValueType > ValueTypePair
Definition PointDataGrid.h:247
openvdb::v13_0::points::PointDataLeafNode::setValuesOn
void setValuesOn()
Definition PointDataGrid.h:551
openvdb::v13_0::points::PointDataLeafNode::Descriptor
AttributeSet::Descriptor Descriptor
Definition PointDataGrid.h:250
openvdb::v13_0::points::PointDataLeafNode::ValueOn
typename BaseLeaf::ValueOn ValueOn
Definition PointDataGrid.h:597
openvdb::v13_0::points::PointDataLeafNode::cendChildOff
ChildOffCIter cendChildOff() const
Definition PointDataGrid.h:736
openvdb::v13_0::points::PointDataLeafNode::addLeafAndCache
void addLeafAndCache(PointDataLeafNode *, AccessorT &)
Definition PointDataGrid.h:455
openvdb::v13_0::points::PointDataLeafNode::setValueOnlyAndCache
void setValueOnlyAndCache(const Coord &, const ValueType &, AccessorT &)
Definition PointDataGrid.h:571
openvdb::v13_0::points::PointDataLeafNode::beginIndexVoxel
IndexIter< ValueVoxelCIter, FilterT > beginIndexVoxel(const Coord &ijk, const FilterT &filter) const
Filtered leaf index iterator from voxel.
Definition PointDataGrid.h:1044
openvdb::v13_0::points::PointDataLeafNode::fill
void fill(const ValueType &value)
Definition PointDataGrid.h:567
openvdb::v13_0::points::PointDataLeafNode::MaskOnIterator
typename NodeMaskType::OnIterator MaskOnIterator
Definition PointDataGrid.h:610
openvdb::v13_0::points::PointDataLeafNode::ChildOffIter
typename BaseLeaf::template ChildIter< MaskOffIterator, PointDataLeafNode, ChildOff > ChildOffIter
Definition PointDataGrid.h:644
openvdb::v13_0::points::PointDataLeafNode::addLeaf
void addLeaf(PointDataLeafNode *)
Definition PointDataGrid.h:453
openvdb::v13_0::points::PointDataLeafNode::SIZE
static const Index SIZE
Definition LeafNode.h:54
openvdb::v13_0::points::PointDataLeafNode::evalActiveBoundingBox
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition PointDataGrid.h:1534
openvdb::v13_0::points::PointDataLeafNode::constAttributeArray
const AttributeArray & constAttributeArray(const size_t pos) const
Definition PointDataGrid.h:927
openvdb::v13_0::points::PointDataLeafNode::signedFloodFill
void signedFloodFill(const ValueType &)
Definition PointDataGrid.h:590
openvdb::v13_0::points::PointDataLeafNode::beginValueOff
ValueOffIter beginValueOff()
Definition PointDataGrid.h:708
openvdb::v13_0::points::PointDataLeafNode::setValueOn
void setValueOn(const Coord &xyz)
Definition PointDataGrid.h:543
openvdb::v13_0::points::PointDataLeafNode::setActiveState
void setActiveState(Index offset, bool on)
Definition PointDataGrid.h:532
openvdb::v13_0::points::PointDataLeafNode::ValueOnCIter
typename BaseLeaf::template ValueIter< MaskOnIterator, const PointDataLeafNode, const ValueType, ValueOn > ValueOnCIter
Definition PointDataGrid.h:630
openvdb::v13_0::points::PointDataLeafNode::attributeArray
AttributeArray & attributeArray(const Name &attributeName)
Read-write attribute array reference from name.
Definition PointDataGrid.h:934
openvdb::v13_0::points::PointDataLeafNode::beginIndexOn
IndexOnIter beginIndexOn() const
Definition PointDataGrid.h:664
openvdb::v13_0::points::PointDataLeafNode::ValueOff
typename BaseLeaf::ValueOff ValueOff
Definition PointDataGrid.h:598
openvdb::v13_0::points::PointDataLeafNode::beginIndexVoxel
IndexVoxelIter beginIndexVoxel(const Coord &ijk) const
Leaf index iterator from voxel.
Definition PointDataGrid.h:1035
openvdb::v13_0::points::PointDataLeafNode::offPointCount
Index64 offPointCount() const
Compute the total inactive (off) point count for the leaf.
Definition PointDataGrid.h:1070
openvdb::v13_0::points::PointDataLeafNode::modifyValue
void modifyValue(const Coord &, const ModifyOp &)
Definition PointDataGrid.h:558
openvdb::v13_0::points::PointDataLeafNode::cendValueOff
ValueOffCIter cendValueOff() const
Definition PointDataGrid.h:716
openvdb::v13_0::points::PointDataLeafNode::memUsage
Index64 memUsage() const
Definition PointDataGrid.h:1520
openvdb::v13_0::points::PointDataLeafNode::fill
void fill(const CoordBBox &, const ValueType &, bool)
Definition PointDataGrid.h:1548
openvdb::v13_0::points::PointDataLeafNode::onPointCount
Index64 onPointCount() const
Compute the total active (on) point count for the leaf.
Definition PointDataGrid.h:1061
openvdb::v13_0::points::PointDataLeafNode::endValueOff
ValueOffCIter endValueOff() const
Definition PointDataGrid.h:717
openvdb::v13_0::points::PointDataLeafNode::probeLeaf
PointDataLeafNode * probeLeaf(const Coord &)
Definition PointDataGrid.h:471
openvdb::v13_0::points::PointDataLeafNode::ValueType
T ValueType
Definition PointDataGrid.h:246
openvdb::v13_0::points::PointDataLeafNode::probeLeafAndCache
PointDataLeafNode * probeLeafAndCache(const Coord &, AccessorT &)
Definition PointDataGrid.h:473
openvdb::v13_0::points::PointDataLeafNode::endValueOn
ValueOnCIter endValueOn() const
Definition PointDataGrid.h:714
openvdb::v13_0::points::PointDataLeafNode::MaskDenseIterator
typename NodeMaskType::DenseIterator MaskDenseIterator
Definition PointDataGrid.h:612
openvdb::v13_0::points::PointDataLeafNode::ValueAllCIter
typename BaseLeaf::template ValueIter< MaskDenseIterator, const PointDataLeafNode, const ValueType, ValueAll > ValueAllCIter
Definition PointDataGrid.h:638
openvdb::v13_0::points::PointDataLeafNode::beginValueAll
ValueAllCIter beginValueAll() const
Definition PointDataGrid.h:710
openvdb::v13_0::points::PointDataLeafNode::PointDataLeafNode
PointDataLeafNode(const Coord &coords, const T &value=zeroVal< T >(), bool active=false)
Construct using supplied origin, value and active status.
Definition PointDataGrid.h:281
openvdb::v13_0::points::PointDataLeafNode::PointDataLeafNode
PointDataLeafNode(const tree::LeafNode< ValueType, Log2Dim > &other, const T &, const T &, TopologyCopy)
Definition PointDataGrid.h:311
openvdb::v13_0::points::PointDataLeafNode::readBuffers
void readBuffers(std::istream &is, const CoordBBox &, bool fromHalf=false)
Definition PointDataGrid.h:1154
openvdb::v13_0::points::PointDataLeafNode::attributeArray
const AttributeArray & attributeArray(const Name &attributeName) const
Definition PointDataGrid.h:943
openvdb::v13_0::points::PointDataLeafNode::PointDataLeafNode
friend class PointDataLeafNode
Definition PointDataGrid.h:616
openvdb::v13_0::points::PointDataLeafNode::setValueOn
void setValueOn(const Coord &, const ValueType &)
Definition PointDataGrid.h:546
openvdb::v13_0::points::PointDataLeafNode::beginValueAll
ValueAllIter beginValueAll()
Definition PointDataGrid.h:711
openvdb::v13_0::points::PointDataLeafNode::IndexArray
std::vector< ValueType > IndexArray
Definition PointDataGrid.h:248
openvdb::v13_0::points::TypedAttributeArray< GroupType, GroupCodec >::cast
static TypedAttributeArray & cast(AttributeArray &attributeArray)
openvdb::v13_0::points::ValueVoxelCIter
A forward iterator over array indices in a single voxel.
Definition IndexIterator.h:66
openvdb::v13_0::tree::InternalNode
Definition InternalNode.h:35
openvdb::v13_0::tree::IteratorBase
Base class for iterators over internal and leaf nodes.
Definition Iterator.h:30
openvdb::v13_0::tree::LeafNode
Templated block class to hold specific data types and a fixed number of values determined by Log2Dim....
Definition LeafNode.h:39
openvdb::v13_0::tree::LeafNode::getNodeBoundingBox
CoordBBox getNodeBoundingBox() const
Return the bounding box of this node, i.e., the full index space spanned by this leaf node.
Definition LeafNode.h:170
openvdb::v13_0::tree::LeafNode::writeTopology
void writeTopology(std::ostream &os, bool toHalf=false) const
Write out just the topology.
Definition LeafNode.h:1335
openvdb::v13_0::tree::LeafNode::getValue
const ValueType & getValue(const Coord &xyz) const
Return the value of the voxel at the given coordinates.
Definition LeafNode.h:1104
openvdb::v13_0::tree::LeafNode::setValueMask
void setValueMask(const NodeMaskType &mask)
Definition LeafNode.h:916
openvdb::v13_0::tree::LeafNode::setValuesOff
void setValuesOff()
Mark all voxels as inactive but don't change their values.
Definition LeafNode.h:504
openvdb::v13_0::tree::LeafNode::readTopology
void readTopology(std::istream &is, bool fromHalf=false)
Read in just the topology.
Definition LeafNode.h:1327
openvdb::v13_0::tree::LeafNode::buffer
const Buffer & buffer() const
Definition LeafNode.h:377
openvdb::v13_0::tree::LeafNode::setValueMaskOn
void setValueMaskOn(Index n)
Definition LeafNode.h:922
openvdb::v13_0::tree::LeafNode::NUM_VOXELS
static const Index NUM_VOXELS
Definition LeafNode.h:53
openvdb::v13_0::tree::LeafNode::DIM
static const Index DIM
Definition LeafNode.h:51
openvdb::v13_0::tree::LeafNode::setActiveState
void setActiveState(const Coord &xyz, bool on)
Set the active state of the voxel at the given coordinates but don't change its value.
Definition LeafNode.h:1154
openvdb::v13_0::tree::LeafNode::LEVEL
static const Index LEVEL
Definition LeafNode.h:55
openvdb::v13_0::tree::LeafNode::coordToOffset
static Index coordToOffset(const Coord &xyz)
Return the linear table offset of the given global or local coordinates.
Definition LeafNode.h:1069
openvdb::v13_0::tree::LeafNode::setValueOff
void setValueOff(const Coord &xyz)
Mark the voxel at the given coordinates as inactive but don't change its value.
Definition LeafNode.h:439
openvdb::v13_0::tree::LeafNode::hasSameTopology
bool hasSameTopology(const LeafNode< OtherType, OtherLog2Dim > *other) const
Return true if the given node (which may have a different ValueType than this node) has the same acti...
Definition LeafNode.h:1516
openvdb::v13_0::tree::LeafNode::writeBuffers
void writeBuffers(std::ostream &os, bool toHalf=false) const
Write buffers to a stream.
Definition LeafNode.h:1451
openvdb::v13_0::tree::LeafNode::memUsageIfLoaded
Index64 memUsageIfLoaded() const
Definition LeafNode.h:1488
openvdb::v13_0::tree::LeafNode::readBuffers
void readBuffers(std::istream &is, bool fromHalf=false)
Read buffers from a stream.
Definition LeafNode.h:1363
openvdb::v13_0::tree::LeafNode::NUM_VALUES
static const Index NUM_VALUES
Definition LeafNode.h:52
openvdb::v13_0::tree::LeafNode::setActiveStateAndCache
void setActiveStateAndCache(const Coord &xyz, bool on, AccessorT &)
Set the active state of the voxel at the given coordinates without changing its value.
Definition LeafNode.h:627
openvdb::v13_0::tree::LeafNode::setValuesOn
void setValuesOn()
Mark all voxels as active but don't change their values.
Definition LeafNode.h:502
openvdb::v13_0::tree::LeafNode::LOG2DIM
static const Index LOG2DIM
Definition LeafNode.h:49
openvdb::v13_0::tree::LeafNode::SIZE
static const Index SIZE
Definition LeafNode.h:54
openvdb::v13_0::tree::LeafNode::evalActiveBoundingBox
void evalActiveBoundingBox(CoordBBox &bbox, bool visitVoxels=true) const
Definition LeafNode.h:1498
openvdb::v13_0::tree::LeafNode::isEmpty
bool isEmpty() const
Return true if this node has no active voxels.
Definition LeafNode.h:151
openvdb::v13_0::tree::LeafNode::setValueOn
void setValueOn(const Coord &xyz)
Mark the voxel at the given coordinates as active but don't change its value.
Definition LeafNode.h:449
openvdb::v13_0::tree::LeafNode::allocate
bool allocate()
Allocate memory for this node's buffer if it has not already been allocated.
Definition LeafNode.h:157
openvdb::v13_0::tree::LeafNode::TOTAL
static const Index TOTAL
Definition LeafNode.h:50
openvdb::v13_0::tree::LeafNode::memUsage
Index64 memUsage() const
Return the memory in bytes occupied by this node.
Definition LeafNode.h:1478
openvdb::v13_0::tree::LeafNode::isDense
bool isDense() const
Return true if this node contains only active voxels.
Definition LeafNode.h:153
openvdb::v13_0::tree::LeafNode::getLastValue
const ValueType & getLastValue() const
Return a const reference to the last value in the buffer.
Definition LeafNode.h:663
openvdb::v13_0::tree::RootNode
Definition RootNode.h:40
openvdb::v13_0::tree::Tree
Definition Tree.h:195
openvdb::v13_0::util::NodeMask
Bit mask for the internal and leaf nodes of VDB. This is a 64-bit implementation.
Definition NodeMasks.h:308
openvdb::v13_0::util::NodeMask::DenseIterator
DenseMaskIterator< NodeMask > DenseIterator
Definition NodeMasks.h:350
openvdb::v13_0::util::NodeMask::OnIterator
OnMaskIterator< NodeMask > OnIterator
Definition NodeMasks.h:348
openvdb::v13_0::util::NodeMask::OffIterator
OffMaskIterator< NodeMask > OffIterator
Definition NodeMasks.h:349
openvdb::v13_0::compression::bloscDecompress
OPENVDB_API void bloscDecompress(char *uncompressedBuffer, const size_t expectedBytes, const size_t bufferBytes, const char *compressedBuffer)
Decompress into the supplied buffer. Will throw if decompression fails or uncompressed buffer has ins...
openvdb::v13_0::compression::bloscCompressedSize
OPENVDB_API size_t bloscCompressedSize(const char *buffer, const size_t uncompressedBytes)
Convenience wrapper to retrieve the compressed size of buffer when compressed.
openvdb::v13_0::compression::bloscCompress
OPENVDB_API void bloscCompress(char *compressedBuffer, size_t &compressedBytes, const size_t bufferBytes, const char *uncompressedBuffer, const size_t uncompressedBytes)
Compress into the supplied buffer.
openvdb::v13_0::internal
Definition openvdb.h:116
openvdb::v13_0::io::readCompressedValues
void readCompressedValues(std::istream &is, ValueT *destBuf, Index destCount, const MaskT &valueMask, bool fromHalf)
Definition Compression.h:466
openvdb::v13_0::io::getStreamMetadataPtr
OPENVDB_API SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme,...
openvdb::v13_0::io::writeCompressedValuesSize
size_t writeCompressedValuesSize(ValueT *srcBuf, Index srcCount, const MaskT &valueMask, uint8_t maskMetadata, bool toHalf, uint32_t compress)
Definition Compression.h:592
openvdb::v13_0::io::writeCompressedValues
void writeCompressedValues(std::ostream &os, const ValueT *srcBuf, Index srcCount, const MaskT &valueMask, const MaskT &childMask, bool toHalf)
Definition Compression.h:646
openvdb::v13_0::points::index
Definition IndexIterator.h:35
openvdb::v13_0::points::index::ALL
@ ALL
Definition IndexIterator.h:44
openvdb::v13_0::points::index::NONE
@ NONE
Definition IndexIterator.h:43
openvdb::v13_0::points::internal::initialize
void initialize()
Global registration of point data-related types.
openvdb::v13_0::points::internal::uninitialize
void uninitialize()
Global deregistration of point data-related types.
openvdb::v13_0::points
Definition AttributeArray.h:42
openvdb::v13_0::points::setStreamingMode
void setStreamingMode(PointDataTreeT &tree, bool on=true)
Toggle the streaming mode on all attributes in the tree to collapse the attributes after deconstructi...
Definition PointDataGrid.h:1603
openvdb::v13_0::points::prefetch
void prefetch(PointDataTreeT &tree, bool position=true, bool otherAttributes=true)
Sequentially pre-fetch all delayed-load voxel and attribute data from disk in order to accelerate sub...
Definition PointDataGrid.h:1616
openvdb::v13_0::points::isGroup
bool isGroup(const AttributeArray &array)
Definition AttributeGroup.h:64
openvdb::v13_0::points::GroupAttributeArray
TypedAttributeArray< GroupType, GroupCodec > GroupAttributeArray
Definition AttributeGroup.h:41
openvdb::v13_0::points::PointDataTree
tree::Tree< tree::RootNode< tree::InternalNode< tree::InternalNode< PointDataLeafNode< PointDataIndex32, 3 >, 4 >, 5 > > > PointDataTree
Point index tree configured to match the default VDB configurations.
Definition PointDataGrid.h:190
openvdb::v13_0::points::PointDataGrid
Grid< PointDataTree > PointDataGrid
Point data grid.
Definition PointDataGrid.h:195
openvdb::v13_0::points::iterCount
Index64 iterCount(const IterT &iter)
Count up the number of times the iterator can iterate.
Definition IndexIterator.h:315
openvdb::v13_0::points::makeDescriptorUnique
AttributeSet::Descriptor::Ptr makeDescriptorUnique(PointDataTreeT &tree)
Deep copy the descriptor across all leaf nodes.
Definition PointDataGrid.h:1586
openvdb::v13_0::tree
Definition PointDataGrid.h:170
openvdb::v13_0::Name
std::string Name
Definition Name.h:19
openvdb::v13_0::Index
Index32 Index
Definition Types.h:34
openvdb::v13_0::zeroVal
constexpr T zeroVal()
Return the value of type T that corresponds to zero.
Definition Math.h:71
openvdb::v13_0::Int32
int32_t Int32
Definition Types.h:36
openvdb::v13_0::Index64
uint64_t Index64
Definition Types.h:33
openvdb::v13_0::typeNameAsString
const char * typeNameAsString()
Definition Types.h:583
openvdb::v13_0::PointDataIndex32
PointIndex< Index32, 1 > PointDataIndex32
Definition Types.h:162
openvdb
Definition Exceptions.h:13
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition Exceptions.h:74
openvdb::v13_0::TypeList
A list of types (not necessarily unique).
Definition TypeList.h:578
openvdb::v13_0::io::MultiPass
Leaf nodes that require multi-pass I/O must inherit from this struct.
Definition io.h:124
openvdb::v13_0::points::TreeConverter
Similiar to ValueConverter, but allows for tree configuration conversion to a PointDataTree....
Definition PointDataGrid.h:1710
openvdb::v13_0::points::TreeConverter::Type
tree::Tree< typename NodeChainT::Back > Type
Definition PointDataGrid.h:1713
openvdb::v13_0::points::TreeConverter::RootNodeT
typename TreeType::RootNodeType RootNodeT
Definition PointDataGrid.h:1711
openvdb::v13_0::points::TreeConverter::NodeChainT
typename internal::PointDataNodeChain< RootNodeT, RootNodeT::LEVEL >::Type NodeChainT
Definition PointDataGrid.h:1712
openvdb::v13_0::points::internal::PointDataNodeChain< tree::InternalNode< ChildT, Log2Dim >, 1 >::InternalNodeT
tree::InternalNode< LeafNodeT, Log2Dim > InternalNodeT
Definition PointDataGrid.h:1699
openvdb::v13_0::points::internal::PointDataNodeChain< tree::InternalNode< ChildT, Log2Dim >, 1 >::Type
TypeList< LeafNodeT, InternalNodeT > Type
Definition PointDataGrid.h:1700
openvdb::v13_0::points::internal::PointDataNodeChain< tree::InternalNode< ChildT, Log2Dim >, 1 >::LeafNodeT
PointDataLeafNode< PointDataIndex32, ChildT::LOG2DIM > LeafNodeT
Definition PointDataGrid.h:1698
openvdb::v13_0::points::internal::PointDataNodeChain< tree::InternalNode< ChildT, Log2Dim >, HeadLevel >::SubtreeT
typename PointDataNodeChain< ChildT, HeadLevel-1 >::Type SubtreeT
Definition PointDataGrid.h:1688
openvdb::v13_0::points::internal::PointDataNodeChain< tree::InternalNode< ChildT, Log2Dim >, HeadLevel >::Type
typename SubtreeT::template Append< InternalNodeT > Type
Definition PointDataGrid.h:1690
openvdb::v13_0::points::internal::PointDataNodeChain< tree::InternalNode< ChildT, Log2Dim >, HeadLevel >::InternalNodeT
tree::InternalNode< typename SubtreeT::Back, Log2Dim > InternalNodeT
Definition PointDataGrid.h:1689
openvdb::v13_0::points::internal::PointDataNodeChain
Recursive node chain which generates a openvdb::TypeList value converted types of nodes to PointDataG...
Definition PointDataGrid.h:1677
openvdb::v13_0::points::internal::PointDataNodeChain::RootNodeT
tree::RootNode< typename SubtreeT::Back > RootNodeT
Definition PointDataGrid.h:1679
openvdb::v13_0::points::internal::PointDataNodeChain::SubtreeT
typename PointDataNodeChain< typename HeadT::ChildNodeType, HeadLevel-1 >::Type SubtreeT
Definition PointDataGrid.h:1678
openvdb::v13_0::points::internal::PointDataNodeChain::Type
typename SubtreeT::template Append< RootNodeT > Type
Definition PointDataGrid.h:1680
openvdb::v13_0::tools::PointIndexLeafNode
Definition PointIndexGrid.h:1359
openvdb::v13_0::tree::IterTraits
Definition TreeIterator.h:61
openvdb::v13_0::tree::LeafNode::ChildAll
Definition LeafNode.h:213
openvdb::v13_0::tree::LeafNode::ChildIter
Leaf nodes have no children, so their child iterators have no get/set accessors.
Definition LeafNode.h:282
openvdb::v13_0::tree::LeafNode::ChildOff
Definition LeafNode.h:213
openvdb::v13_0::tree::LeafNode::ChildOn
Definition LeafNode.h:213
openvdb::v13_0::tree::LeafNode::DenseIter
Definition LeafNode.h:291
openvdb::v13_0::tree::LeafNode::ValueAll
Definition LeafNode.h:212
openvdb::v13_0::tree::LeafNode::ValueIter
Definition LeafNode.h:221
openvdb::v13_0::tree::LeafNode::ValueOff
Definition LeafNode.h:212
openvdb::v13_0::tree::LeafNode::ValueOn
Definition LeafNode.h:212
openvdb::v13_0::tree::SameLeafConfig< Dim1, points::PointDataLeafNode< T2, Dim1 > >::value
static const bool value
Definition PointDataGrid.h:1729
openvdb::v13_0::tree::SameLeafConfig
Definition LeafNode.h:949
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:218