OpenVDB 5.1.0

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