OpenVDB: PointDataGrid.h Source File

OpenVDB 4.0.2

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