OpenVDB: PointAttribute.h Source File

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