OpenVDB 7.0.0

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