OpenVDB: PointAttribute.h Source File

OpenVDB 5.1.0

PointAttribute.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
36
37 #ifndef OPENVDB_POINTS_POINT_ATTRIBUTE_HAS_BEEN_INCLUDED
38 #define OPENVDB_POINTS_POINT_ATTRIBUTE_HAS_BEEN_INCLUDED
39
40 #include <openvdb/openvdb.h>
41
42 #include "AttributeArrayString.h"
43 #include "AttributeSet.h"
44 #include "AttributeGroup.h"
45 #include "PointDataGrid.h"
46
47
48 namespace openvdb {
49 OPENVDB_USE_VERSION_NAMESPACE
50 namespace OPENVDB_VERSION_NAME {
51 namespace points {
52
53 namespace point_attribute_internal {
54
55 template <typename ValueType>
56 struct Default
57 {
58 static inline ValueType value() { return zeroVal<ValueType>(); }
59 };
60
61 } // namespace point_attribute_internal
62
63
75 template <typename PointDataTree>
76 inline void appendAttribute(PointDataTree& tree,
77 const Name& name,
78 const NamePair& type,
79 const Index strideOrTotalSize = 1,
80 const bool constantStride = true,
81 Metadata::Ptr metaDefaultValue = Metadata::Ptr(),
82 const bool hidden = false,
83 const bool transient = false);
84
95 template <typename ValueType, typename CodecType, typename PointDataTree>
96 inline void appendAttribute(PointDataTree& tree,
97 const std::string& name,
98 const ValueType& uniformValue =
99 point_attribute_internal::Default<ValueType>::value(),
100 const Index strideOrTotalSize = 1,
101 const bool constantStride = true,
102 Metadata::Ptr metaDefaultValue = Metadata::Ptr(),
103 const bool hidden = false,
104 const bool transient = false);
105
116 template <typename ValueType, typename PointDataTree>
117 inline void appendAttribute(PointDataTree& tree,
118 const std::string& name,
119 const ValueType& uniformValue =
120 point_attribute_internal::Default<ValueType>::value(),
121 const Index strideOrTotalSize = 1,
122 const bool constantStride = true,
123 Metadata::Ptr metaDefaultValue = Metadata::Ptr(),
124 const bool hidden = false,
125 const bool transient = false);
126
132 template <typename ValueType, typename PointDataTree>
133 inline void collapseAttribute( PointDataTree& tree,
134 const Name& name,
135 const ValueType& uniformValue =
136 point_attribute_internal::Default<ValueType>::value());
137
142 template <typename PointDataTree>
143 inline void dropAttributes( PointDataTree& tree,
144 const std::vector<size_t>& indices);
145
150 template <typename PointDataTree>
151 inline void dropAttributes( PointDataTree& tree,
152 const std::vector<Name>& names);
153
158 template <typename PointDataTree>
159 inline void dropAttribute( PointDataTree& tree,
160 const size_t& index);
161
166 template <typename PointDataTree>
167 inline void dropAttribute( PointDataTree& tree,
168 const Name& name);
169
179 template <typename PointDataTree>
180 inline void renameAttributes(PointDataTree& tree,
181 const std::vector<Name>& oldNames,
182 const std::vector<Name>& newNames);
183
191 template <typename PointDataTree>
192 inline void renameAttribute(PointDataTree& tree,
193 const Name& oldName,
194 const Name& newName);
195
199 template <typename PointDataTree>
200 inline void compactAttributes(PointDataTree& tree);
201
206 template <typename PointDataTree>
207 inline void bloscCompressAttribute( PointDataTree& tree,
208 const Name& name);
209
211
212
213 namespace point_attribute_internal {
214
215 template<typename PointDataTreeType>
216 struct AppendAttributeOp {
217
218 using LeafManagerT = typename tree::LeafManager<PointDataTreeType>;
219 using LeafRangeT = typename LeafManagerT::LeafRange;
220
221 AppendAttributeOp( AttributeSet::DescriptorPtr& descriptor,
222 const size_t pos,
223 const Index strideOrTotalSize = 1,
224 const bool constantStride = true,
225 const bool hidden = false,
226 const bool transient = false)
227 : mDescriptor(descriptor)
228 , mPos(pos)
229 , mStrideOrTotalSize(strideOrTotalSize)
230 , mConstantStride(constantStride)
231 , mHidden(hidden)
232 , mTransient(transient) { }
233
234 void operator()(const LeafRangeT& range) const {
235
236 for (auto leaf = range.begin(); leaf; ++leaf) {
237 const AttributeSet::Descriptor& expected = leaf->attributeSet().descriptor();
238
239 AttributeArray::Ptr attribute = leaf->appendAttribute(
240 expected, mDescriptor, mPos, mStrideOrTotalSize, mConstantStride);
241
242 if (mHidden) attribute->setHidden(true);
243 if (mTransient) attribute->setTransient(true);
244 }
245 }
246
248
249 AttributeSet::DescriptorPtr& mDescriptor;
250 const size_t mPos;
251 const Index mStrideOrTotalSize;
252 const bool mConstantStride;
253 const bool mHidden;
254 const bool mTransient;
255 }; // class AppendAttributeOp
256
257
259
260
261 template <typename ValueType, typename PointDataTreeType>
262 struct CollapseAttributeOp {
263
264 using LeafManagerT = typename tree::LeafManager<PointDataTreeType>;
265 using LeafRangeT = typename LeafManagerT::LeafRange;
266
267 CollapseAttributeOp(const size_t pos,
268 const ValueType& uniformValue)
269 : mPos(pos)
270 , mUniformValue(uniformValue) { }
271
272 void operator()(const LeafRangeT& range) const {
273
274 for (auto leaf = range.begin(); leaf; ++leaf) {
275 assert(leaf->hasAttribute(mPos));
276 AttributeArray& array = leaf->attributeArray(mPos);
277 AttributeWriteHandle<ValueType> handle(array);
278 handle.collapse(mUniformValue);
279 }
280 }
281
283
284 const size_t mPos;
285 const ValueType mUniformValue;
286 }; // class CollapseAttributeOp
287
288
290
291
292 template <typename PointDataTreeType>
293 struct CollapseAttributeOp<Name, PointDataTreeType> {
294
295 using LeafManagerT = typename tree::LeafManager<PointDataTreeType>;
296 using LeafRangeT = typename LeafManagerT::LeafRange;
297
298 CollapseAttributeOp(const size_t pos,
299 const Name& uniformValue)
300 : mPos(pos)
301 , mUniformValue(uniformValue) { }
302
303 void operator()(const LeafRangeT& range) const {
304
305 for (auto leaf = range.begin(); leaf; ++leaf) {
306 assert(leaf->hasAttribute(mPos));
307 AttributeArray& array = leaf->attributeArray(mPos);
308
309 const AttributeSet::Descriptor& descriptor = leaf->attributeSet().descriptor();
310 const MetaMap& metadata = descriptor.getMetadata();
311
312 StringAttributeWriteHandle handle(array, metadata);
313 handle.collapse(mUniformValue);
314 }
315 }
316
318
319 const size_t mPos;
320 const Name mUniformValue;
321 }; // class CollapseAttributeOp
322
323
325
326
327 template<typename PointDataTreeType>
328 struct DropAttributesOp {
329
330 using LeafManagerT = typename tree::LeafManager<PointDataTreeType>;
331 using LeafRangeT = typename LeafManagerT::LeafRange;
332 using Indices = std::vector<size_t>;
333
334 DropAttributesOp( const Indices& indices,
335 AttributeSet::DescriptorPtr& descriptor)
336 : mIndices(indices)
337 , mDescriptor(descriptor) { }
338
339 void operator()(const LeafRangeT& range) const {
340
341 for (auto leaf = range.begin(); leaf; ++leaf) {
342
343 const AttributeSet::Descriptor& expected = leaf->attributeSet().descriptor();
344
345 leaf->dropAttributes(mIndices, expected, mDescriptor);
346 }
347 }
348
350
351 const Indices& mIndices;
352 AttributeSet::DescriptorPtr& mDescriptor;
353 }; // class DropAttributesOp
354
355
357
358
359 template<typename PointDataTreeType>
360 struct CompactAttributesOp {
361
362 using LeafManagerT = typename tree::LeafManager<PointDataTreeType>;
363 using LeafRangeT = typename LeafManagerT::LeafRange;
364
365 void operator()(const LeafRangeT& range) const {
366 for (auto leaf = range.begin(); leaf; ++leaf) {
367 leaf->compactAttributes();
368 }
369 }
370 }; // class CompactAttributesOp
371
372
374
375
376 template<typename PointDataTreeType>
377 struct BloscCompressAttributesOp {
378
379 using LeafManagerT = typename tree::LeafManager<PointDataTreeType>;
380 using LeafRangeT = typename LeafManagerT::LeafRange;
381 using Indices = std::vector<size_t>;
382
383 BloscCompressAttributesOp(const Indices& indices)
384 : mIndices(indices) { }
385
386 void operator()(const LeafRangeT& range) const {
387
388 for (auto leaf = range.begin(); leaf; ++leaf) {
389
390 for (const size_t index : mIndices) {
391
392 AttributeArray& array = leaf->attributeArray(index);
393 array.compress();
394 }
395 }
396 }
397
399
400 const Indices& mIndices;
401 }; // class BloscCompressAttributesOp
402
403
405
406
407 template <typename ValueType, typename CodecType>
408 struct AttributeTypeConversion
409 {
410 static const NamePair& type() {
411 return TypedAttributeArray<ValueType, CodecType>::attributeType();
412 }
413 };
414
415
416 template <typename CodecType>
417 struct AttributeTypeConversion<Name, CodecType>
418 {
419 static const NamePair& type() { return StringAttributeArray::attributeType(); }
420 };
421
422
424
425
426 template <typename PointDataTree, typename ValueType>
427 struct MetadataStorage
428 {
429 static void add(PointDataTree&, const ValueType&) {}
430
431 template<typename AttributeListType>
432 static void add(PointDataTree&, const AttributeListType&) {}
433 };
434
435
436 template <typename PointDataTree>
437 struct MetadataStorage<PointDataTree, Name>
438 {
439 static void add(PointDataTree& tree, const Name& uniformValue) {
440 MetaMap& metadata = makeDescriptorUnique(tree)->getMetadata();
441 StringMetaInserter inserter(metadata);
442 inserter.insert(uniformValue);
443 }
444
445 template<typename AttributeListType>
446 static void add(PointDataTree& tree, const AttributeListType& data) {
447 MetaMap& metadata = makeDescriptorUnique(tree)->getMetadata();
448 StringMetaInserter inserter(metadata);
449 Name value;
450
451 for (size_t i = 0; i < data.size(); i++) {
452 data.get(value, i);
453 inserter.insert(value);
454 }
455 }
456 };
457
458
459 } // namespace point_attribute_internal
460
461
463
464
465 template <typename PointDataTree>
466 inline void appendAttribute(PointDataTree& tree,
467 const Name& name,
468 const NamePair& type,
469 const Index strideOrTotalSize,
470 const bool constantStride,
471 Metadata::Ptr metaDefaultValue,
472 const bool hidden,
473 const bool transient)
474 {
475 using Descriptor = AttributeSet::Descriptor;
476
477 using point_attribute_internal::AppendAttributeOp;
478
479 auto iter = tree.cbeginLeaf();
480
481 if (!iter) return;
482
483 // do not append a non-unique attribute
484
485 const Descriptor& descriptor = iter->attributeSet().descriptor();
486 const size_t index = descriptor.find(name);
487
488 if (index != AttributeSet::INVALID_POS) {
489 OPENVDB_THROW(KeyError,
490 "Cannot append an attribute with a non-unique name - " << name << ".");
491 }
492
493 // create a new attribute descriptor
494
495 Descriptor::Ptr newDescriptor = descriptor.duplicateAppend(name, type);
496
497 // store the attribute default value in the descriptor metadata
498
499 if (metaDefaultValue) {
500 newDescriptor->setDefaultValue(name, *metaDefaultValue);
501 }
502
503 // extract new pos
504
505 const size_t pos = newDescriptor->find(name);
506
507 // insert attributes using the new descriptor
508
509 tree::LeafManager<PointDataTree> leafManager(tree);
510 AppendAttributeOp<PointDataTree> append(newDescriptor, pos, strideOrTotalSize,
511 constantStride, hidden, transient);
512 tbb::parallel_for(leafManager.leafRange(), append);
513 }
514
515
517
518
519 template <typename ValueType, typename CodecType, typename PointDataTree>
520 inline void appendAttribute(PointDataTree& tree,
521 const std::string& name,
522 const ValueType& uniformValue,
523 const Index strideOrTotalSize,
524 const bool constantStride,
525 Metadata::Ptr metaDefaultValue,
526 const bool hidden,
527 const bool transient)
528 {
529 static_assert(!std::is_base_of<AttributeArray, ValueType>::value,
530 "ValueType must not be derived from AttributeArray");
531
532 using point_attribute_internal::AttributeTypeConversion;
533 using point_attribute_internal::Default;
534 using point_attribute_internal::MetadataStorage;
535
536 appendAttribute(tree, name, AttributeTypeConversion<ValueType, CodecType>::type(),
537 strideOrTotalSize, constantStride, metaDefaultValue, hidden, transient);
538
539 if (!math::isExactlyEqual(uniformValue, Default<ValueType>::value())) {
540 MetadataStorage<PointDataTree, ValueType>::add(tree, uniformValue);
541 collapseAttribute<ValueType>(tree, name, uniformValue);
542 }
543 }
544
545
547
548
549 template <typename ValueType, typename PointDataTree>
550 inline void appendAttribute(PointDataTree& tree,
551 const std::string& name,
552 const ValueType& uniformValue,
553 const Index strideOrTotalSize,
554 const bool constantStride,
555 Metadata::Ptr metaDefaultValue,
556 const bool hidden,
557 const bool transient)
558 {
559 static_assert(!std::is_base_of<AttributeArray, ValueType>::value,
560 "ValueType must not be derived from AttributeArray");
561
562 appendAttribute<ValueType, NullCodec>(tree, name, uniformValue, strideOrTotalSize,
563 constantStride, metaDefaultValue, hidden, transient);
564 }
565
566
568
569
570 template <typename ValueType, typename PointDataTree>
571 inline void collapseAttribute( PointDataTree& tree,
572 const Name& name,
573 const ValueType& uniformValue)
574 {
575 static_assert(!std::is_base_of<AttributeArray, ValueType>::value,
576 "ValueType must not be derived from AttributeArray");
577
578 using LeafManagerT = typename tree::LeafManager<PointDataTree>;
579 using Descriptor = AttributeSet::Descriptor;
580
581 using point_attribute_internal::CollapseAttributeOp;
582
583 auto iter = tree.cbeginLeaf();
584
585 if (!iter) return;
586
587
588 const Descriptor& descriptor = iter->attributeSet().descriptor();
589
590 // throw if attribute name does not exist
591
592 const size_t index = descriptor.find(name);
593 if (index == AttributeSet::INVALID_POS) {
594 OPENVDB_THROW(KeyError, "Cannot find attribute name in PointDataTree.");
595 }
596
597 LeafManagerT leafManager(tree);
598 tbb::parallel_for(leafManager.leafRange(),
599 CollapseAttributeOp<ValueType, PointDataTree>(index, uniformValue));
600 }
601
602
604
605
606 template <typename PointDataTree>
607 inline void dropAttributes( PointDataTree& tree,
608 const std::vector<size_t>& indices)
609 {
610 using LeafManagerT = typename tree::LeafManager<PointDataTree>;
611 using Descriptor = AttributeSet::Descriptor;
612
613 using point_attribute_internal::DropAttributesOp;
614
615 auto iter = tree.cbeginLeaf();
616
617 if (!iter) return;
618
619 const Descriptor& descriptor = iter->attributeSet().descriptor();
620
621 // throw if position index present in the indices as this attribute is mandatory
622
623 const size_t positionIndex = descriptor.find("P");
624 if (positionIndex!= AttributeSet::INVALID_POS &&
625 std::find(indices.begin(), indices.end(), positionIndex) != indices.end()) {
626 OPENVDB_THROW(KeyError, "Cannot drop mandatory position attribute.");
627 }
628
629 // insert attributes using the new descriptor
630
631 Descriptor::Ptr newDescriptor = descriptor.duplicateDrop(indices);
632 tbb::parallel_for(LeafManagerT(tree).leafRange(),
633 DropAttributesOp<PointDataTree>(indices, newDescriptor));
634 }
635
636
638
639
640 template <typename PointDataTree>
641 inline void dropAttributes( PointDataTree& tree,
642 const std::vector<Name>& names)
643 {
644 auto iter = tree.cbeginLeaf();
645
646 if (!iter) return;
647
648 const AttributeSet& attributeSet = iter->attributeSet();
649 const AttributeSet::Descriptor& descriptor = attributeSet.descriptor();
650
651 std::vector<size_t> indices;
652
653 for (const Name& name : names) {
654 const size_t index = descriptor.find(name);
655
656 // do not attempt to drop an attribute that does not exist
657 if (index == AttributeSet::INVALID_POS) {
658 OPENVDB_THROW(KeyError,
659 "Cannot drop an attribute that does not exist - " << name << ".");
660 }
661
662 indices.push_back(index);
663 }
664
665 dropAttributes(tree, indices);
666 }
667
668
670
671
672 template <typename PointDataTree>
673 inline void dropAttribute( PointDataTree& tree,
674 const size_t& index)
675 {
676 std::vector<size_t> indices{index};
677 dropAttributes(tree, indices);
678 }
679
680
681 template <typename PointDataTree>
682 inline void dropAttribute( PointDataTree& tree,
683 const Name& name)
684 {
685 std::vector<Name> names{name};
686 dropAttributes(tree, names);
687 }
688
689
691
692
693 template <typename PointDataTree>
694 inline void renameAttributes( PointDataTree& tree,
695 const std::vector<Name>& oldNames,
696 const std::vector<Name>& newNames)
697 {
698 if (oldNames.size() != newNames.size()) {
699 OPENVDB_THROW(ValueError, "Mis-matching sizes of name vectors, cannot rename attributes.");
700 }
701
702 using Descriptor = AttributeSet::Descriptor;
703
704 auto iter = tree.beginLeaf();
705
706 if (!iter) return;
707
708 const AttributeSet& attributeSet = iter->attributeSet();
709 const Descriptor& descriptor = attributeSet.descriptor();
710 auto newDescriptor = std::make_shared<Descriptor>(descriptor);
711
712 for (size_t i = 0; i < oldNames.size(); i++) {
713 const Name& oldName = oldNames[i];
714 if (descriptor.find(oldName) == AttributeSet::INVALID_POS) {
715 OPENVDB_THROW(KeyError, "Cannot find requested attribute - " << oldName << ".");
716 }
717
718 const Name& newName = newNames[i];
719 if (descriptor.find(newName) != AttributeSet::INVALID_POS) {
720 OPENVDB_THROW(KeyError,
721 "Cannot rename attribute as new name already exists - " << newName << ".");
722 }
723
724 const AttributeArray* array = attributeSet.getConst(oldName);
725 assert(array);
726
727 if (isGroup(*array)) {
728 OPENVDB_THROW(KeyError, "Cannot rename group attribute - " << oldName << ".");
729 }
730
731 newDescriptor->rename(oldName, newName);
732 }
733
734 for (; iter; ++iter) {
735 iter->renameAttributes(descriptor, newDescriptor);
736 }
737 }
738
739
740 template <typename PointDataTree>
741 inline void renameAttribute(PointDataTree& tree,
742 const Name& oldName,
743 const Name& newName)
744 {
745 renameAttributes(tree, {oldName}, {newName});
746 }
747
748
750
751
752 template <typename PointDataTree>
753 inline void compactAttributes(PointDataTree& tree)
754 {
755 using LeafManagerT = typename tree::LeafManager<PointDataTree>;
756
757 using point_attribute_internal::CompactAttributesOp;
758
759 auto iter = tree.beginLeaf();
760 if (!iter) return;
761
762 tbb::parallel_for(LeafManagerT(tree).leafRange(), CompactAttributesOp<PointDataTree>());
763 }
764
765
767
768
769 template <typename PointDataTree>
770 inline void bloscCompressAttribute( PointDataTree& tree,
771 const Name& name)
772 {
773 using point_attribute_internal::BloscCompressAttributesOp;
774
775 using LeafManagerT = typename tree::LeafManager<PointDataTree>;
776 using Descriptor = AttributeSet::Descriptor;
777
778 auto iter = tree.cbeginLeaf();
779
780 if (!iter) return;
781
782 const Descriptor& descriptor = iter->attributeSet().descriptor();
783
784 // throw if index cannot be found in descriptor
785
786 const size_t index = descriptor.find(name);
787 if (index == AttributeSet::INVALID_POS) {
788 OPENVDB_THROW(KeyError, "Cannot find requested attribute - " << name << ".");
789 }
790
791 // blosc compress attributes
792
793 std::vector<size_t> indices{index};
794
795 tbb::parallel_for(LeafManagerT(tree).leafRange(),
796 BloscCompressAttributesOp<PointDataTree>(indices));
797 }
798
800
801
802 } // namespace points
803 } // namespace OPENVDB_VERSION_NAME
804 } // namespace openvdb
805
806 #endif // OPENVDB_POINTS_POINT_ATTRIBUTE_HAS_BEEN_INCLUDED
807
808 // Copyright (c) 2012-2018 DreamWorks Animation LLC
809 // All rights reserved. This software is distributed under the
810 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v5_1::math::isExactlyEqual
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:395
openvdb::v5_1::points::point_attribute_internal::DropAttributesOp
Definition: PointAttribute.h:328
openvdb::v5_1::points::StringAttributeWriteHandle
Definition: AttributeArrayString.h:160
openvdb::v5_1::tree::Tree::beginLeaf
LeafIter beginLeaf()
Return an iterator over all leaf nodes in this tree.
Definition: Tree.h:1179
openvdb::v5_1::KeyError
Definition: Exceptions.h:86
openvdb::v5_1::points::TypedAttributeArray
Typed class for storing attribute data.
Definition: AttributeArray.h:441
openvdb::v5_1::points::StringMetaInserter
Definition: AttributeArrayString.h:83
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp< Name, PointDataTreeType >::LeafRangeT
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:296
openvdb::v5_1::points::point_attribute_internal::AppendAttributeOp::mConstantStride
const bool mConstantStride
Definition: PointAttribute.h:252
AttributeGroup.h
Attribute Group access and filtering for iteration.
openvdb::v5_1::points::AttributeArray
Base class for storing attribute data.
Definition: AttributeArray.h:118
openvdb::v5_1::Name
std::string Name
Definition: Name.h:44
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp::mPos
const size_t mPos
Definition: PointAttribute.h:284
openvdb::v5_1::points::StringAttributeWriteHandle::collapse
void collapse()
Set membership for the whole array and attempt to collapse.
openvdb::v5_1::points::point_attribute_internal::MetadataStorage::add
static void add(PointDataTree &, const ValueType &)
Definition: PointAttribute.h:429
openvdb::v5_1::points::appendAttribute
void appendAttribute(PointDataTree &tree, const std::string &name, const ValueType &uniformValue=point_attribute_internal::Default< ValueType >::value(), 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.
Definition: PointAttribute.h:550
openvdb::v5_1::points::point_attribute_internal::AttributeTypeConversion::type
static const NamePair & type()
Definition: PointAttribute.h:410
openvdb::v5_1::points::point_attribute_internal::CompactAttributesOp::operator()
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:365
openvdb::v5_1::points::point_attribute_internal::BloscCompressAttributesOp::Indices
std::vector< size_t > Indices
Definition: PointAttribute.h:381
openvdb::v5_1::points::AttributeWriteHandle::collapse
void collapse()
Replace the existing array with a uniform value (zero if none provided).
Definition: AttributeArray.h:2020
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.h
openvdb::v5_1::points::point_attribute_internal::MetadataStorage< PointDataTree, Name >::add
static void add(PointDataTree &tree, const Name &uniformValue)
Definition: PointAttribute.h:439
openvdb::v5_1::points::AttributeSet::DescriptorPtr
std::shared_ptr< Descriptor > DescriptorPtr
Definition: AttributeSet.h:72
openvdb::v5_1::points::bloscCompressAttribute
void bloscCompressAttribute(PointDataTree &tree, const Name &name)
Apply Blosc compression to one attribute in the VDB tree.
Definition: PointAttribute.h:770
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
openvdb::v5_1::points::point_attribute_internal::DropAttributesOp::operator()
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:339
openvdb::v5_1::points::point_attribute_internal::BloscCompressAttributesOp::operator()
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:386
openvdb::v5_1::points::point_attribute_internal::AppendAttributeOp::operator()
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:234
openvdb::v5_1::Metadata::Ptr
SharedPtr< Metadata > Ptr
Definition: Metadata.h:53
openvdb::v5_1::points::point_attribute_internal::AppendAttributeOp::mPos
const size_t mPos
Definition: PointAttribute.h:250
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::point_attribute_internal::AttributeTypeConversion< Name, CodecType >::type
static const NamePair & type()
Definition: PointAttribute.h:419
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp::LeafManagerT
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:264
openvdb::v5_1::points::point_attribute_internal::DropAttributesOp::Indices
std::vector< size_t > Indices
Definition: PointAttribute.h:332
openvdb::v5_1::points::point_attribute_internal::AppendAttributeOp::LeafRangeT
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:219
openvdb::v5_1::points::point_attribute_internal::MetadataStorage< PointDataTree, Name >::add
static void add(PointDataTree &tree, const AttributeListType &data)
Definition: PointAttribute.h:446
openvdb::v5_1::points::point_attribute_internal::DropAttributesOp::DropAttributesOp
DropAttributesOp(const Indices &indices, AttributeSet::DescriptorPtr &descriptor)
Definition: PointAttribute.h:334
openvdb::v5_1::points::point_attribute_internal::DropAttributesOp::mDescriptor
AttributeSet::DescriptorPtr & mDescriptor
Definition: PointAttribute.h:352
openvdb::v5_1::points::dropAttribute
void dropAttribute(PointDataTree &tree, const Name &name)
Drop one attribute from the VDB tree (convenience method).
Definition: PointAttribute.h:682
openvdb::v5_1::points::collapseAttribute
void collapseAttribute(PointDataTree &tree, const Name &name, const ValueType &uniformValue=point_attribute_internal::Default< ValueType >::value())
Collapse the attribute into a uniform value.
Definition: PointAttribute.h:571
openvdb::v5_1::tree::LeafManager
This class manages a linear array of pointers to a given tree&#39;s leaf nodes, as well as optional auxil...
Definition: LeafManager.h:110
openvdb::v5_1::NamePair
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:65
openvdb::v5_1::points::point_attribute_internal::AppendAttributeOp::mTransient
const bool mTransient
Definition: PointAttribute.h:254
openvdb::v5_1::points::AttributeSet::getConst
const AttributeArray * getConst(const std::string &name) const
Return a pointer to the attribute array whose name is name or a null pointer if no match is found...
openvdb::v5_1::points::AttributeArray::Ptr
std::shared_ptr< AttributeArray > Ptr
Definition: AttributeArray.h:142
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp< Name, PointDataTreeType >::LeafManagerT
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:295
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:136
openvdb::v5_1::ValueError
Definition: Exceptions.h:92
openvdb::v5_1::points::point_attribute_internal::MetadataStorage
Definition: PointAttribute.h:427
openvdb::v5_1::points::dropAttributes
void dropAttributes(PointDataTree &tree, const std::vector< Name > &names)
Drops attributes from the VDB tree.
Definition: PointAttribute.h:641
openvdb
Definition: Exceptions.h:40
openvdb::v5_1::tree::Tree::cbeginLeaf
LeafCIter cbeginLeaf() const
Return an iterator over all leaf nodes in this tree.
Definition: Tree.h:1181
openvdb::v5_1::points::isGroup
bool isGroup(const AttributeArray &array)
Definition: AttributeGroup.h:93
openvdb::v5_1::points::point_attribute_internal::BloscCompressAttributesOp
Definition: PointAttribute.h:377
openvdb::v5_1::points::point_attribute_internal::CompactAttributesOp::LeafManagerT
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:362
openvdb::v5_1::points::StringMetaInserter::insert
void insert(const Name &name)
Insert the string into the metadata.
openvdb::v5_1::points::point_attribute_internal::AttributeTypeConversion
Definition: PointAttribute.h:408
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp< Name, PointDataTreeType >::mUniformValue
const Name mUniformValue
Definition: PointAttribute.h:320
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp::mUniformValue
const ValueType mUniformValue
Definition: PointAttribute.h:285
openvdb::v5_1::points::point_attribute_internal::CompactAttributesOp::LeafRangeT
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:363
openvdb::v5_1::MetaMap::getMetadata
T::Ptr getMetadata(const Name &)
Return a pointer to a TypedMetadata object of type T and with the given name. If no such field exists...
Definition: MetaMap.h:165
openvdb::v5_1::points::point_attribute_internal::Default
Definition: PointAttribute.h:56
openvdb::v5_1::points::AttributeWriteHandle
Write-able version of AttributeHandle.
Definition: AttributeArray.h:713
openvdb::v5_1::points::point_attribute_internal::AppendAttributeOp::mHidden
const bool mHidden
Definition: PointAttribute.h:253
openvdb::v5_1::points::point_attribute_internal::BloscCompressAttributesOp::LeafManagerT
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:379
openvdb::v5_1::points::point_attribute_internal::DropAttributesOp::mIndices
const Indices & mIndices
Definition: PointAttribute.h:351
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp::CollapseAttributeOp
CollapseAttributeOp(const size_t pos, const ValueType &uniformValue)
Definition: PointAttribute.h:267
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp::operator()
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:272
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp< Name, PointDataTreeType >::mPos
const size_t mPos
Definition: PointAttribute.h:319
PointDataGrid.h
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
openvdb::v5_1::tree::LeafManager::leafRange
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:386
openvdb::v5_1::points::point_attribute_internal::AppendAttributeOp::LeafManagerT
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:218
openvdb::v5_1::points::point_attribute_internal::DropAttributesOp::LeafManagerT
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:330
openvdb::v5_1::points::point_attribute_internal::MetadataStorage::add
static void add(PointDataTree &, const AttributeListType &)
Definition: PointAttribute.h:432
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp::LeafRangeT
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:265
openvdb::v5_1::points::renameAttribute
void renameAttribute(PointDataTree &tree, const Name &oldName, const Name &newName)
Rename an attribute in a VDB tree.
Definition: PointAttribute.h:741
openvdb::v5_1::points::point_attribute_internal::DropAttributesOp::LeafRangeT
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:331
openvdb::v5_1::points::makeDescriptorUnique
AttributeSet::Descriptor::Ptr makeDescriptorUnique(PointDataTreeT &tree)
Deep copy the descriptor across all leaf nodes.
Definition: PointDataGrid.h:1616
AttributeArrayString.h
Attribute array storage for string data using Descriptor Metadata.
openvdb::v5_1::points::point_attribute_internal::Default::value
static ValueType value()
Definition: PointAttribute.h:58
openvdb::v5_1::points::point_attribute_internal::BloscCompressAttributesOp::LeafRangeT
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:380
openvdb::v5_1::points::point_attribute_internal::AppendAttributeOp::mDescriptor
AttributeSet::DescriptorPtr & mDescriptor
Definition: PointAttribute.h:249
openvdb::v5_1::points::point_attribute_internal::BloscCompressAttributesOp::BloscCompressAttributesOp
BloscCompressAttributesOp(const Indices &indices)
Definition: PointAttribute.h:383
openvdb::v5_1::Index
Index32 Index
Definition: Types.h:61
openvdb::v5_1::points::AttributeSet
Ordered collection of uniquely-named attribute arrays.
Definition: AttributeSet.h:62
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:188
openvdb::v5_1::points::point_attribute_internal::CompactAttributesOp
Definition: PointAttribute.h:360
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp< Name, PointDataTreeType >::operator()
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:303
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp
Definition: PointAttribute.h:262
openvdb::v5_1::points::point_attribute_internal::AppendAttributeOp::mStrideOrTotalSize
const Index mStrideOrTotalSize
Definition: PointAttribute.h:251
openvdb::v5_1::points::point_attribute_internal::AppendAttributeOp
Definition: PointAttribute.h:216
openvdb::v5_1::tree::Tree
Definition: Tree.h:203
openvdb::v5_1::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:46
openvdb::v5_1::points::point_attribute_internal::BloscCompressAttributesOp::mIndices
const Indices & mIndices
Definition: PointAttribute.h:400
AttributeSet.h
Set of Attribute Arrays which tracks metadata about each array.
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::AttributeArray::compress
virtual bool compress()=0
Compress the attribute array.
openvdb::v5_1::points::point_attribute_internal::AppendAttributeOp::AppendAttributeOp
AppendAttributeOp(AttributeSet::DescriptorPtr &descriptor, const size_t pos, const Index strideOrTotalSize=1, const bool constantStride=true, const bool hidden=false, const bool transient=false)
Definition: PointAttribute.h:221
openvdb::v5_1::points::point_attribute_internal::CollapseAttributeOp< Name, PointDataTreeType >::CollapseAttributeOp
CollapseAttributeOp(const size_t pos, const Name &uniformValue)
Definition: PointAttribute.h:298
openvdb::v5_1::points::PointDataTree
tree::Tree< tree::RootNode< tree::InternalNode< tree::InternalNode< PointDataLeafNode< PointDataIndex32, 3 >, 4 >, 5 > >> PointDataTree
Point index tree configured to match the default VDB configurations.
Definition: PointDataGrid.h:216