OpenVDB: PointAttribute.h Source File

OpenVDB 4.0.2

PointAttribute.h
Go to the documentation of this file.
1 //
3 // Copyright (c) 2012-2017 DreamWorks Animation LLC
4 //
5 // All rights reserved. This software is distributed under the
6 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
7 //
8 // Redistributions of source code must retain the above copyright
9 // and license notice and the following restrictions and disclaimer.
10 //
11 // * Neither the name of DreamWorks Animation nor the names of
12 // its contributors may be used to endorse or promote products derived
13 // from this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 // IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
27 // LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
28 //
30
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 inline ValueType defaultValue() { return zeroVal<ValueType>(); }
57
58 } // namespace point_attribute_internal
59
60
72 template <typename PointDataTree>
73 inline void appendAttribute(PointDataTree& tree,
74 const Name& name,
75 const NamePair& type,
76 const Index strideOrTotalSize = 1,
77 const bool constantStride = true,
78 Metadata::Ptr metaDefaultValue = Metadata::Ptr(),
79 const bool hidden = false,
80 const bool transient = false);
81
92 template <typename ValueType, typename CodecType, typename PointDataTree>
93 inline void appendAttribute(PointDataTree& tree,
94 const std::string& name,
95 const ValueType& uniformValue =
96 point_attribute_internal::defaultValue<ValueType>(),
97 const Index strideOrTotalSize = 1,
98 const bool constantStride = true,
99 Metadata::Ptr metaDefaultValue = Metadata::Ptr(),
100 const bool hidden = false,
101 const bool transient = false);
102
113 template <typename ValueType, typename PointDataTree>
114 inline void appendAttribute(PointDataTree& tree,
115 const std::string& name,
116 const ValueType& uniformValue =
117 point_attribute_internal::defaultValue<ValueType>(),
118 const Index strideOrTotalSize = 1,
119 const bool constantStride = true,
120 Metadata::Ptr metaDefaultValue = Metadata::Ptr(),
121 const bool hidden = false,
122 const bool transient = false);
123
129 template <typename ValueType, typename PointDataTree>
130 inline void collapseAttribute( PointDataTree& tree,
131 const Name& name,
132 const ValueType& uniformValue =
133 point_attribute_internal::defaultValue<ValueType>());
134
139 template <typename PointDataTree>
140 inline void dropAttributes( PointDataTree& tree,
141 const std::vector<size_t>& indices);
142
147 template <typename PointDataTree>
148 inline void dropAttributes( PointDataTree& tree,
149 const std::vector<Name>& names);
150
155 template <typename PointDataTree>
156 inline void dropAttribute( PointDataTree& tree,
157 const size_t& index);
158
163 template <typename PointDataTree>
164 inline void dropAttribute( PointDataTree& tree,
165 const Name& name);
166
176 template <typename PointDataTree>
177 inline void renameAttributes(PointDataTree& tree,
178 const std::vector<Name>& oldNames,
179 const std::vector<Name>& newNames);
180
188 template <typename PointDataTree>
189 inline void renameAttribute(PointDataTree& tree,
190 const Name& oldName,
191 const Name& newName);
192
196 template <typename PointDataTree>
197 inline void compactAttributes(PointDataTree& tree);
198
203 template <typename PointDataTree>
204 inline void bloscCompressAttribute( PointDataTree& tree,
205 const Name& name);
206
208
209
210 namespace point_attribute_internal {
211
212 template<typename PointDataTreeType>
213 struct AppendAttributeOp {
214
215 using LeafManagerT = typename tree::LeafManager<PointDataTreeType>;
216 using LeafRangeT = typename LeafManagerT::LeafRange;
217
218 AppendAttributeOp( AttributeSet::DescriptorPtr& descriptor,
219 const size_t pos,
220 const Index strideOrTotalSize = 1,
221 const bool constantStride = true,
222 const bool hidden = false,
223 const bool transient = false)
224 : mDescriptor(descriptor)
225 , mPos(pos)
226 , mStrideOrTotalSize(strideOrTotalSize)
227 , mConstantStride(constantStride)
228 , mHidden(hidden)
229 , mTransient(transient) { }
230
231 void operator()(const LeafRangeT& range) const {
232
233 for (auto leaf = range.begin(); leaf; ++leaf) {
234 const AttributeSet::Descriptor& expected = leaf->attributeSet().descriptor();
235
236 AttributeArray::Ptr attribute = leaf->appendAttribute(
237 expected, mDescriptor, mPos, mStrideOrTotalSize, mConstantStride);
238
239 if (mHidden) attribute->setHidden(true);
240 if (mTransient) attribute->setTransient(true);
241 }
242 }
243
245
246 AttributeSet::DescriptorPtr& mDescriptor;
247 const size_t mPos;
248 const Index mStrideOrTotalSize;
249 const bool mConstantStride;
250 const bool mHidden;
251 const bool mTransient;
252 }; // class AppendAttributeOp
253
254
256
257
258 template <typename ValueType, typename PointDataTreeType>
259 struct CollapseAttributeOp {
260
261 using LeafManagerT = typename tree::LeafManager<PointDataTreeType>;
262 using LeafRangeT = typename LeafManagerT::LeafRange;
263
264 CollapseAttributeOp(const size_t pos,
265 const ValueType& uniformValue)
266 : mPos(pos)
267 , mUniformValue(uniformValue) { }
268
269 void operator()(const LeafRangeT& range) const {
270
271 for (auto leaf = range.begin(); leaf; ++leaf) {
272 assert(leaf->hasAttribute(mPos));
273 AttributeArray& array = leaf->attributeArray(mPos);
274 AttributeWriteHandle<ValueType> handle(array);
275 handle.collapse(mUniformValue);
276 }
277 }
278
280
281 const size_t mPos;
282 const ValueType mUniformValue;
283 }; // class CollapseAttributeOp
284
285
287
288
289 template <typename PointDataTreeType>
290 struct CollapseAttributeOp<Name, PointDataTreeType> {
291
292 using LeafManagerT = typename tree::LeafManager<PointDataTreeType>;
293 using LeafRangeT = typename LeafManagerT::LeafRange;
294
295 CollapseAttributeOp(const size_t pos,
296 const Name& uniformValue)
297 : mPos(pos)
298 , mUniformValue(uniformValue) { }
299
300 void operator()(const LeafRangeT& range) const {
301
302 for (auto leaf = range.begin(); leaf; ++leaf) {
303 assert(leaf->hasAttribute(mPos));
304 AttributeArray& array = leaf->attributeArray(mPos);
305
306 const AttributeSet::Descriptor& descriptor = leaf->attributeSet().descriptor();
307 const MetaMap& metadata = descriptor.getMetadata();
308
309 StringAttributeWriteHandle handle(array, metadata);
310 handle.collapse(mUniformValue);
311 }
312 }
313
315
316 const size_t mPos;
317 const Name mUniformValue;
318 }; // class CollapseAttributeOp
319
320
322
323
324 template<typename PointDataTreeType>
325 struct DropAttributesOp {
326
327 using LeafManagerT = typename tree::LeafManager<PointDataTreeType>;
328 using LeafRangeT = typename LeafManagerT::LeafRange;
329 using Indices = std::vector<size_t>;
330
331 DropAttributesOp( const Indices& indices,
332 AttributeSet::DescriptorPtr& descriptor)
333 : mIndices(indices)
334 , mDescriptor(descriptor) { }
335
336 void operator()(const LeafRangeT& range) const {
337
338 for (auto leaf = range.begin(); leaf; ++leaf) {
339
340 const AttributeSet::Descriptor& expected = leaf->attributeSet().descriptor();
341
342 leaf->dropAttributes(mIndices, expected, mDescriptor);
343 }
344 }
345
347
348 const Indices& mIndices;
349 AttributeSet::DescriptorPtr& mDescriptor;
350 }; // class DropAttributesOp
351
352
354
355
356 template<typename PointDataTreeType>
357 struct CompactAttributesOp {
358
359 using LeafManagerT = typename tree::LeafManager<PointDataTreeType>;
360 using LeafRangeT = typename LeafManagerT::LeafRange;
361
362 void operator()(const LeafRangeT& range) const {
363 for (auto leaf = range.begin(); leaf; ++leaf) {
364 leaf->compactAttributes();
365 }
366 }
367 }; // class CompactAttributesOp
368
369
371
372
373 template<typename PointDataTreeType>
374 struct BloscCompressAttributesOp {
375
376 using LeafManagerT = typename tree::LeafManager<PointDataTreeType>;
377 using LeafRangeT = typename LeafManagerT::LeafRange;
378 using Indices = std::vector<size_t>;
379
380 BloscCompressAttributesOp(const Indices& indices)
381 : mIndices(indices) { }
382
383 void operator()(const LeafRangeT& range) const {
384
385 for (auto leaf = range.begin(); leaf; ++leaf) {
386
387 for (const size_t index : mIndices) {
388
389 AttributeArray& array = leaf->attributeArray(index);
390 array.compress();
391 }
392 }
393 }
394
396
397 const Indices& mIndices;
398 }; // class BloscCompressAttributesOp
399
400
402
403
404 template <typename ValueType, typename CodecType>
405 struct AttributeTypeConversion
406 {
407 static const NamePair& type() {
408 return TypedAttributeArray<ValueType, CodecType>::attributeType();
409 }
410 };
411
412
413 template <typename CodecType>
414 struct AttributeTypeConversion<Name, CodecType>
415 {
416 static const NamePair& type() { return StringAttributeArray::attributeType(); }
417 };
418
419
421
422
423 template <typename PointDataTree, typename ValueType>
424 struct MetadataStorage
425 {
426 static void add(PointDataTree&, const ValueType&) {}
427
428 template<typename AttributeListType>
429 static void add(PointDataTree&, const AttributeListType&) {}
430 };
431
432
433 template <typename PointDataTree>
434 struct MetadataStorage<PointDataTree, Name>
435 {
436 static void add(PointDataTree& tree, const Name& uniformValue) {
437 MetaMap& metadata = makeDescriptorUnique(tree)->getMetadata();
438 StringMetaInserter inserter(metadata);
439 inserter.insert(uniformValue);
440 }
441
442 template<typename AttributeListType>
443 static void add(PointDataTree& tree, const AttributeListType& data) {
444 MetaMap& metadata = makeDescriptorUnique(tree)->getMetadata();
445 StringMetaInserter inserter(metadata);
446 Name value;
447
448 for (size_t i = 0; i < data.size(); i++) {
449 data.get(value, i);
450 inserter.insert(value);
451 }
452 }
453 };
454
455
456 } // namespace point_attribute_internal
457
458
460
461
462 template <typename PointDataTree>
463 inline void appendAttribute(PointDataTree& tree,
464 const Name& name,
465 const NamePair& type,
466 const Index strideOrTotalSize,
467 const bool constantStride,
468 Metadata::Ptr metaDefaultValue,
469 const bool hidden,
470 const bool transient)
471 {
472 using Descriptor = AttributeSet::Descriptor;
473
474 using point_attribute_internal::AppendAttributeOp;
475
476 auto iter = tree.cbeginLeaf();
477
478 if (!iter) return;
479
480 // do not append a non-unique attribute
481
482 const Descriptor& descriptor = iter->attributeSet().descriptor();
483 const size_t index = descriptor.find(name);
484
485 if (index != AttributeSet::INVALID_POS) {
486 OPENVDB_THROW(KeyError,
487 "Cannot append an attribute with a non-unique name - " << name << ".");
488 }
489
490 // create a new attribute descriptor
491
492 Descriptor::Ptr newDescriptor = descriptor.duplicateAppend(name, type);
493
494 // store the attribute default value in the descriptor metadata
495
496 if (metaDefaultValue) {
497 newDescriptor->setDefaultValue(name, *metaDefaultValue);
498 }
499
500 // extract new pos
501
502 const size_t pos = newDescriptor->find(name);
503
504 // insert attributes using the new descriptor
505
506 tree::LeafManager<PointDataTree> leafManager(tree);
507 AppendAttributeOp<PointDataTree> append(newDescriptor, pos, strideOrTotalSize,
508 constantStride, hidden, transient);
509 tbb::parallel_for(leafManager.leafRange(), append);
510 }
511
512
514
515
516 template <typename ValueType, typename CodecType, typename PointDataTree>
517 inline void appendAttribute(PointDataTree& tree,
518 const std::string& name,
519 const ValueType& uniformValue,
520 const Index strideOrTotalSize,
521 const bool constantStride,
522 Metadata::Ptr metaDefaultValue,
523 const bool hidden,
524 const bool transient)
525 {
526 static_assert(!std::is_base_of<AttributeArray, ValueType>::value,
527 "ValueType must not be derived from AttributeArray");
528
529 using point_attribute_internal::AttributeTypeConversion;
530 using point_attribute_internal::defaultValue;
531 using point_attribute_internal::MetadataStorage;
532
533 appendAttribute(tree, name, AttributeTypeConversion<ValueType, CodecType>::type(),
534 strideOrTotalSize, constantStride, metaDefaultValue, hidden, transient);
535
536 if (!math::isExactlyEqual(uniformValue, defaultValue<ValueType>())) {
537 MetadataStorage<PointDataTree, ValueType>::add(tree, uniformValue);
538 collapseAttribute<ValueType>(tree, name, uniformValue);
539 }
540 }
541
542
544
545
546 template <typename ValueType, typename PointDataTree>
547 inline void appendAttribute(PointDataTree& tree,
548 const std::string& name,
549 const ValueType& uniformValue,
550 const Index strideOrTotalSize,
551 const bool constantStride,
552 Metadata::Ptr metaDefaultValue,
553 const bool hidden,
554 const bool transient)
555 {
556 static_assert(!std::is_base_of<AttributeArray, ValueType>::value,
557 "ValueType must not be derived from AttributeArray");
558
559 appendAttribute<ValueType, NullCodec>(tree, name, uniformValue, strideOrTotalSize,
560 constantStride, metaDefaultValue, hidden, transient);
561 }
562
563
565
566
567 template <typename ValueType, typename PointDataTree>
568 inline void collapseAttribute( PointDataTree& tree,
569 const Name& name,
570 const ValueType& uniformValue)
571 {
572 static_assert(!std::is_base_of<AttributeArray, ValueType>::value,
573 "ValueType must not be derived from AttributeArray");
574
575 using LeafManagerT = typename tree::LeafManager<PointDataTree>;
576 using Descriptor = AttributeSet::Descriptor;
577
578 using point_attribute_internal::CollapseAttributeOp;
579
580 auto iter = tree.cbeginLeaf();
581
582 if (!iter) return;
583
584
585 const Descriptor& descriptor = iter->attributeSet().descriptor();
586
587 // throw if attribute name does not exist
588
589 const size_t index = descriptor.find(name);
590 if (index == AttributeSet::INVALID_POS) {
591 OPENVDB_THROW(KeyError, "Cannot find attribute name in PointDataTree.");
592 }
593
594 LeafManagerT leafManager(tree);
595 tbb::parallel_for(leafManager.leafRange(),
596 CollapseAttributeOp<ValueType, PointDataTree>(index, uniformValue));
597 }
598
599
601
602
603 template <typename PointDataTree>
604 inline void dropAttributes( PointDataTree& tree,
605 const std::vector<size_t>& indices)
606 {
607 using LeafManagerT = typename tree::LeafManager<PointDataTree>;
608 using Descriptor = AttributeSet::Descriptor;
609
610 using point_attribute_internal::DropAttributesOp;
611
612 auto iter = tree.cbeginLeaf();
613
614 if (!iter) return;
615
616 const Descriptor& descriptor = iter->attributeSet().descriptor();
617
618 // throw if position index present in the indices as this attribute is mandatory
619
620 const size_t positionIndex = descriptor.find("P");
621 if (positionIndex!= AttributeSet::INVALID_POS &&
622 std::find(indices.begin(), indices.end(), positionIndex) != indices.end()) {
623 OPENVDB_THROW(KeyError, "Cannot drop mandatory position attribute.");
624 }
625
626 // insert attributes using the new descriptor
627
628 Descriptor::Ptr newDescriptor = descriptor.duplicateDrop(indices);
629 tbb::parallel_for(LeafManagerT(tree).leafRange(),
630 DropAttributesOp<PointDataTree>(indices, newDescriptor));
631 }
632
633
635
636
637 template <typename PointDataTree>
638 inline void dropAttributes( PointDataTree& tree,
639 const std::vector<Name>& names)
640 {
641 auto iter = tree.cbeginLeaf();
642
643 if (!iter) return;
644
645 const AttributeSet& attributeSet = iter->attributeSet();
646 const AttributeSet::Descriptor& descriptor = attributeSet.descriptor();
647
648 std::vector<size_t> indices;
649
650 for (const Name& name : names) {
651 const size_t index = descriptor.find(name);
652
653 // do not attempt to drop an attribute that does not exist
654 if (index == AttributeSet::INVALID_POS) {
655 OPENVDB_THROW(KeyError,
656 "Cannot drop an attribute that does not exist - " << name << ".");
657 }
658
659 indices.push_back(index);
660 }
661
662 dropAttributes(tree, indices);
663 }
664
665
667
668
669 template <typename PointDataTree>
670 inline void dropAttribute( PointDataTree& tree,
671 const size_t& index)
672 {
673 std::vector<size_t> indices{index};
674 dropAttributes(tree, indices);
675 }
676
677
678 template <typename PointDataTree>
679 inline void dropAttribute( PointDataTree& tree,
680 const Name& name)
681 {
682 std::vector<Name> names{name};
683 dropAttributes(tree, names);
684 }
685
686
688
689
690 template <typename PointDataTree>
691 inline void renameAttributes( PointDataTree& tree,
692 const std::vector<Name>& oldNames,
693 const std::vector<Name>& newNames)
694 {
695 if (oldNames.size() != newNames.size()) {
696 OPENVDB_THROW(ValueError, "Mis-matching sizes of name vectors, cannot rename attributes.");
697 }
698
699 using Descriptor = AttributeSet::Descriptor;
700
701 auto iter = tree.beginLeaf();
702
703 if (!iter) return;
704
705 const AttributeSet& attributeSet = iter->attributeSet();
706 const Descriptor& descriptor = attributeSet.descriptor();
707 auto newDescriptor = std::make_shared<Descriptor>(descriptor);
708
709 for (size_t i = 0; i < oldNames.size(); i++) {
710 const Name& oldName = oldNames[i];
711 if (descriptor.find(oldName) == AttributeSet::INVALID_POS) {
712 OPENVDB_THROW(KeyError, "Cannot find requested attribute - " << oldName << ".");
713 }
714
715 const Name& newName = newNames[i];
716 if (descriptor.find(newName) != AttributeSet::INVALID_POS) {
717 OPENVDB_THROW(KeyError,
718 "Cannot rename attribute as new name already exists - " << newName << ".");
719 }
720
721 const AttributeArray* array = attributeSet.getConst(oldName);
722 assert(array);
723
724 if (isGroup(*array)) {
725 OPENVDB_THROW(KeyError, "Cannot rename group attribute - " << oldName << ".");
726 }
727
728 newDescriptor->rename(oldName, newName);
729 }
730
731 for (; iter; ++iter) {
732 iter->renameAttributes(descriptor, newDescriptor);
733 }
734 }
735
736
737 template <typename PointDataTree>
738 inline void renameAttribute(PointDataTree& tree,
739 const Name& oldName,
740 const Name& newName)
741 {
742 renameAttributes(tree, {oldName}, {newName});
743 }
744
745
747
748
749 template <typename PointDataTree>
750 inline void compactAttributes(PointDataTree& tree)
751 {
752 using LeafManagerT = typename tree::LeafManager<PointDataTree>;
753
754 using point_attribute_internal::CompactAttributesOp;
755
756 auto iter = tree.beginLeaf();
757 if (!iter) return;
758
759 tbb::parallel_for(LeafManagerT(tree).leafRange(), CompactAttributesOp<PointDataTree>());
760 }
761
762
764
765
766 template <typename PointDataTree>
767 inline void bloscCompressAttribute( PointDataTree& tree,
768 const Name& name)
769 {
770 using point_attribute_internal::BloscCompressAttributesOp;
771
772 using LeafManagerT = typename tree::LeafManager<PointDataTree>;
773 using Descriptor = AttributeSet::Descriptor;
774
775 auto iter = tree.cbeginLeaf();
776
777 if (!iter) return;
778
779 const Descriptor& descriptor = iter->attributeSet().descriptor();
780
781 // throw if index cannot be found in descriptor
782
783 const size_t index = descriptor.find(name);
784 if (index == AttributeSet::INVALID_POS) {
785 OPENVDB_THROW(KeyError, "Cannot find requested attribute - " << name << ".");
786 }
787
788 // blosc compress attributes
789
790 std::vector<size_t> indices{index};
791
792 tbb::parallel_for(LeafManagerT(tree).leafRange(),
793 BloscCompressAttributesOp<PointDataTree>(indices));
794 }
795
797
798
799 } // namespace points
800 } // namespace OPENVDB_VERSION_NAME
801 } // namespace openvdb
802
803 #endif // OPENVDB_POINTS_POINT_ATTRIBUTE_HAS_BEEN_INCLUDED
804
805 // Copyright (c) 2012-2017 DreamWorks Animation LLC
806 // All rights reserved. This software is distributed under the
807 // Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
openvdb::v4_0_2::points::dropAttribute
void dropAttribute(PointDataTree &tree, const Name &name)
Drop one attribute from the VDB tree (convenience method).
Definition: PointAttribute.h:679
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp< Name, PointDataTreeType >::LeafManagerT
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:292
openvdb::v4_0_2::tree::Tree
Definition: Tree.h:205
openvdb::v4_0_2::points::point_attribute_internal::DropAttributesOp::mDescriptor
AttributeSet::DescriptorPtr & mDescriptor
Definition: PointAttribute.h:349
openvdb::v4_0_2::points::AttributeSet::descriptor
Descriptor & descriptor()
Return a reference to this attribute set&#39;s descriptor, which might be shared with other sets...
Definition: AttributeSet.h:121
AttributeGroup.h
Attribute Group access and filtering for iteration.
openvdb::v4_0_2::points::StringAttributeWriteHandle
Definition: AttributeArrayString.h:160
openvdb::v4_0_2::points::point_attribute_internal::MetadataStorage::add
static void add(PointDataTree &, const AttributeListType &)
Definition: PointAttribute.h:429
openvdb::v4_0_2::points::point_attribute_internal::DropAttributesOp::DropAttributesOp
DropAttributesOp(const Indices &indices, AttributeSet::DescriptorPtr &descriptor)
Definition: PointAttribute.h:331
openvdb::v4_0_2::KeyError
Definition: Exceptions.h:86
openvdb::v4_0_2::points::point_attribute_internal::AttributeTypeConversion::type
static const NamePair & type()
Definition: PointAttribute.h:407
openvdb::v4_0_2::points::isGroup
bool isGroup(const AttributeArray &array)
Definition: AttributeGroup.h:92
openvdb::v4_0_2::points::point_attribute_internal::DropAttributesOp::LeafRangeT
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:328
openvdb::v4_0_2::points::point_attribute_internal::BloscCompressAttributesOp::LeafRangeT
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:377
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp::CollapseAttributeOp
CollapseAttributeOp(const size_t pos, const ValueType &uniformValue)
Definition: PointAttribute.h:264
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp::LeafManagerT
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:261
openvdb::v4_0_2::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.h
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:101
openvdb::v4_0_2::math::isExactlyEqual
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:391
openvdb::v4_0_2::points::point_attribute_internal::CompactAttributesOp::LeafManagerT
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:359
openvdb::v4_0_2::points::point_attribute_internal::AppendAttributeOp
Definition: PointAttribute.h:213
i
tbb::atomic< Index32 > i
Definition: LeafBuffer.h:71
openvdb::v4_0_2::points::makeDescriptorUnique
AttributeSet::Descriptor::Ptr makeDescriptorUnique(PointDataTreeT &tree)
Deep copy the descriptor across all leaf nodes.
Definition: PointDataGrid.h:1586
openvdb::v4_0_2::points::compactAttributes
void compactAttributes(PointDataTree &tree)
Compact attributes in a VDB tree (if possible).
Definition: PointAttribute.h:750
data
T * data
Definition: LeafBuffer.h:71
openvdb::v4_0_2::points::point_attribute_internal::CompactAttributesOp::LeafRangeT
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:360
openvdb::v4_0_2::points::renameAttributes
void renameAttributes(PointDataTree &tree, const std::vector< Name > &oldNames, const std::vector< Name > &newNames)
Rename attributes in a VDB tree.
Definition: PointAttribute.h:691
openvdb::v4_0_2::Index
Index32 Index
Definition: Types.h:57
openvdb::v4_0_2::points::point_attribute_internal::AppendAttributeOp::operator()
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:231
openvdb::v4_0_2::points::point_attribute_internal::MetadataStorage::add
static void add(PointDataTree &, const ValueType &)
Definition: PointAttribute.h:426
openvdb::v4_0_2::points::point_attribute_internal::MetadataStorage< PointDataTree, Name >::add
static void add(PointDataTree &tree, const Name &uniformValue)
Definition: PointAttribute.h:436
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp< Name, PointDataTreeType >::mUniformValue
const Name mUniformValue
Definition: PointAttribute.h:317
openvdb::v4_0_2::points::AttributeSet::DescriptorPtr
std::shared_ptr< Descriptor > DescriptorPtr
Definition: AttributeSet.h:72
openvdb::v4_0_2::points::point_attribute_internal::DropAttributesOp
Definition: PointAttribute.h:325
openvdb::v4_0_2::points::point_attribute_internal::AppendAttributeOp::mPos
const size_t mPos
Definition: PointAttribute.h:247
openvdb::v4_0_2::points::point_attribute_internal::MetadataStorage
Definition: PointAttribute.h:424
openvdb::v4_0_2::points::point_attribute_internal::BloscCompressAttributesOp
Definition: PointAttribute.h:374
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp::operator()
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:269
openvdb::v4_0_2::Name
std::string Name
Definition: Name.h:44
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
Definition: version.h:43
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp< Name, PointDataTreeType >::CollapseAttributeOp
CollapseAttributeOp(const size_t pos, const Name &uniformValue)
Definition: PointAttribute.h:295
openvdb::v4_0_2::points::StringMetaInserter::insert
void insert(const Name &name)
Insert the string into the metadata.
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp::LeafRangeT
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:262
openvdb::v4_0_2::points::point_attribute_internal::AppendAttributeOp::mTransient
const bool mTransient
Definition: PointAttribute.h:251
openvdb::v4_0_2::points::point_attribute_internal::AttributeTypeConversion< Name, CodecType >::type
static const NamePair & type()
Definition: PointAttribute.h:416
openvdb::v4_0_2::points::point_attribute_internal::AppendAttributeOp::LeafManagerT
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:215
openvdb
Definition: Exceptions.h:39
openvdb::v4_0_2::points::point_attribute_internal::DropAttributesOp::Indices
std::vector< size_t > Indices
Definition: PointAttribute.h:329
openvdb::v4_0_2::tree::Tree::cbeginLeaf
LeafCIter cbeginLeaf() const
Return an iterator over all leaf nodes in this tree.
Definition: Tree.h:1182
openvdb::v4_0_2::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::v4_0_2::points::dropAttributes
void dropAttributes(PointDataTree &tree, const std::vector< Name > &names)
Drops attributes from the VDB tree.
Definition: PointAttribute.h:638
openvdb::v4_0_2::points::point_attribute_internal::CompactAttributesOp
Definition: PointAttribute.h:357
openvdb::v4_0_2::points::AttributeSet
Ordered collection of uniquely-named attribute arrays.
Definition: AttributeSet.h:62
openvdb::v4_0_2::points::collapseAttribute
void collapseAttribute(PointDataTree &tree, const Name &name, const ValueType &uniformValue=point_attribute_internal::defaultValue< ValueType >())
Collapse the attribute into a uniform value.
Definition: PointAttribute.h:568
openvdb::v4_0_2::points::StringAttributeWriteHandle::collapse
void collapse()
Set membership for the whole array and attempt to collapse.
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp< Name, PointDataTreeType >::operator()
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:300
openvdb::v4_0_2::points::TypedAttributeArray
Typed class for storing attribute data.
Definition: AttributeArray.h:437
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp::mPos
const size_t mPos
Definition: PointAttribute.h:281
openvdb::v4_0_2::points::appendAttribute
void appendAttribute(PointDataTree &tree, const std::string &name, const ValueType &uniformValue=point_attribute_internal::defaultValue< ValueType >(), 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:547
openvdb::v4_0_2::points::bloscCompressAttribute
void bloscCompressAttribute(PointDataTree &tree, const Name &name)
Apply Blosc compression to one attribute in the VDB tree.
Definition: PointAttribute.h:767
openvdb::v4_0_2::tree::LeafManager::leafRange
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:386
openvdb::v4_0_2::points::point_attribute_internal::CompactAttributesOp::operator()
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:362
openvdb::v4_0_2::points::point_attribute_internal::AppendAttributeOp::mHidden
const bool mHidden
Definition: PointAttribute.h:250
openvdb::v4_0_2::points::point_attribute_internal::AppendAttributeOp::LeafRangeT
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:216
openvdb::v4_0_2::points::point_attribute_internal::DropAttributesOp::operator()
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:336
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp
Definition: PointAttribute.h:259
openvdb::v4_0_2::ValueError
Definition: Exceptions.h:92
openvdb::v4_0_2::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::v4_0_2::points::AttributeWriteHandle::collapse
void collapse()
Replace the existing array with a uniform value (zero if none provided).
Definition: AttributeArray.h:2000
openvdb::v4_0_2::points::StringMetaInserter
Definition: AttributeArrayString.h:83
openvdb::v4_0_2::points::AttributeArray::Ptr
std::shared_ptr< AttributeArray > Ptr
Definition: AttributeArray.h:142
openvdb::v4_0_2::points::point_attribute_internal::BloscCompressAttributesOp::BloscCompressAttributesOp
BloscCompressAttributesOp(const Indices &indices)
Definition: PointAttribute.h:380
openvdb::v4_0_2::points::AttributeArray::compress
virtual bool compress()=0
Compress the attribute array.
openvdb::v4_0_2::points::point_attribute_internal::DropAttributesOp::LeafManagerT
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:327
openvdb::v4_0_2::points::point_attribute_internal::DropAttributesOp::mIndices
const Indices & mIndices
Definition: PointAttribute.h:348
PointDataGrid.h
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
openvdb::v4_0_2::tree::Tree::beginLeaf
LeafIter beginLeaf()
Return an iterator over all leaf nodes in this tree.
Definition: Tree.h:1180
openvdb::v4_0_2::points::AttributeArray
Base class for storing attribute data.
Definition: AttributeArray.h:118
AttributeArrayString.h
Attribute array storage for string data using Descriptor Metadata.
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp< Name, PointDataTreeType >::mPos
const size_t mPos
Definition: PointAttribute.h:316
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp::mUniformValue
const ValueType mUniformValue
Definition: PointAttribute.h:282
openvdb::v4_0_2::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:46
openvdb::v4_0_2::points::point_attribute_internal::AttributeTypeConversion
Definition: PointAttribute.h:405
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
openvdb::v4_0_2::NamePair
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:65
openvdb::v4_0_2::points::point_attribute_internal::AppendAttributeOp::mConstantStride
const bool mConstantStride
Definition: PointAttribute.h:249
openvdb::v4_0_2::points::point_attribute_internal::MetadataStorage< PointDataTree, Name >::add
static void add(PointDataTree &tree, const AttributeListType &data)
Definition: PointAttribute.h:443
openvdb::v4_0_2::points::point_attribute_internal::BloscCompressAttributesOp::mIndices
const Indices & mIndices
Definition: PointAttribute.h:397
openvdb::v4_0_2::points::point_attribute_internal::AppendAttributeOp::mDescriptor
AttributeSet::DescriptorPtr & mDescriptor
Definition: PointAttribute.h:246
openvdb::v4_0_2::points::point_attribute_internal::BloscCompressAttributesOp::operator()
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:383
openvdb::v4_0_2::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:207
AttributeSet.h
Set of Attribute Arrays which tracks metadata about each array.
openvdb::v4_0_2::points::point_attribute_internal::defaultValue
ValueType defaultValue()
Definition: PointAttribute.h:56
openvdb::v4_0_2::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:218
openvdb::v4_0_2::points::point_attribute_internal::CollapseAttributeOp< Name, PointDataTreeType >::LeafRangeT
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:293
openvdb::v4_0_2::points::renameAttribute
void renameAttribute(PointDataTree &tree, const Name &oldName, const Name &newName)
Rename an attribute in a VDB tree.
Definition: PointAttribute.h:738
openvdb::v4_0_2::points::point_attribute_internal::BloscCompressAttributesOp::Indices
std::vector< size_t > Indices
Definition: PointAttribute.h:378
openvdb::v4_0_2::points::point_attribute_internal::BloscCompressAttributesOp::LeafManagerT
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:376
openvdb::v4_0_2::points::AttributeWriteHandle
Write-able version of AttributeHandle.
Definition: AttributeArray.h:709
openvdb::v4_0_2::points::point_attribute_internal::AppendAttributeOp::mStrideOrTotalSize
const Index mStrideOrTotalSize
Definition: PointAttribute.h:248
openvdb::v4_0_2::Metadata::Ptr
SharedPtr< Metadata > Ptr
Definition: Metadata.h:51