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 {
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>
214 
216  using LeafRangeT = typename LeafManagerT::LeafRange;
217 
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 
247  const size_t mPos;
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>
260 
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 
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;
318 }; // class CollapseAttributeOp
319 
320 
322 
323 
324 template<typename PointDataTreeType>
326 
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 
350 }; // class DropAttributesOp
351 
352 
354 
355 
356 template<typename PointDataTreeType>
358 
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>
375 
377  using LeafRangeT = typename LeafManagerT::LeafRange;
378  using Indices = std::vector<size_t>;
379 
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 
398 }; // class BloscCompressAttributesOp
399 
400 
402 
403 
404 template <typename ValueType, typename CodecType>
406 {
407  static const NamePair& type() {
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>
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>
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 
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) {
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 
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 
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 
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) {
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) {
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>
751 {
752  using LeafManagerT = typename tree::LeafManager<PointDataTree>;
753 
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>
768  const Name& name)
769 {
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/ )
void dropAttribute(PointDataTree &tree, const Name &name)
Drop one attribute from the VDB tree (convenience method).
Definition: PointAttribute.h:679
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:292
Definition: Tree.h:205
AttributeSet::DescriptorPtr & mDescriptor
Definition: PointAttribute.h:349
Descriptor & descriptor()
Return a reference to this attribute set&#39;s descriptor, which might be shared with other sets...
Definition: AttributeSet.h:121
Attribute Group access and filtering for iteration.
Definition: AttributeArrayString.h:160
static void add(PointDataTree &, const AttributeListType &)
Definition: PointAttribute.h:429
DropAttributesOp(const Indices &indices, AttributeSet::DescriptorPtr &descriptor)
Definition: PointAttribute.h:331
Definition: Exceptions.h:86
static const NamePair & type()
Definition: PointAttribute.h:407
bool isGroup(const AttributeArray &array)
Definition: AttributeGroup.h:92
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:328
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:377
CollapseAttributeOp(const size_t pos, const ValueType &uniformValue)
Definition: PointAttribute.h:264
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:261
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...
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:101
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:391
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:359
tbb::atomic< Index32 > i
Definition: LeafBuffer.h:71
AttributeSet::Descriptor::Ptr makeDescriptorUnique(PointDataTreeT &tree)
Deep copy the descriptor across all leaf nodes.
Definition: PointDataGrid.h:1586
void compactAttributes(PointDataTree &tree)
Compact attributes in a VDB tree (if possible).
Definition: PointAttribute.h:750
T * data
Definition: LeafBuffer.h:71
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:360
void renameAttributes(PointDataTree &tree, const std::vector< Name > &oldNames, const std::vector< Name > &newNames)
Rename attributes in a VDB tree.
Definition: PointAttribute.h:691
Index32 Index
Definition: Types.h:57
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:231
static void add(PointDataTree &, const ValueType &)
Definition: PointAttribute.h:426
static void add(PointDataTree &tree, const Name &uniformValue)
Definition: PointAttribute.h:436
std::shared_ptr< Descriptor > DescriptorPtr
Definition: AttributeSet.h:72
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:269
std::string Name
Definition: Name.h:44
#define OPENVDB_VERSION_NAME
Definition: version.h:43
CollapseAttributeOp(const size_t pos, const Name &uniformValue)
Definition: PointAttribute.h:295
void insert(const Name &name)
Insert the string into the metadata.
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:262
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:215
Definition: Exceptions.h:39
std::vector< size_t > Indices
Definition: PointAttribute.h:329
LeafCIter cbeginLeaf() const
Return an iterator over all leaf nodes in this tree.
Definition: Tree.h:1182
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
void dropAttributes(PointDataTree &tree, const std::vector< Name > &names)
Drops attributes from the VDB tree.
Definition: PointAttribute.h:638
Ordered collection of uniquely-named attribute arrays.
Definition: AttributeSet.h:62
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
void collapse()
Set membership for the whole array and attempt to collapse.
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:300
Typed class for storing attribute data.
Definition: AttributeArray.h:437
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
void bloscCompressAttribute(PointDataTree &tree, const Name &name)
Apply Blosc compression to one attribute in the VDB tree.
Definition: PointAttribute.h:767
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:386
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:362
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:216
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:336
Definition: Exceptions.h:92
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
void collapse()
Replace the existing array with a uniform value (zero if none provided).
Definition: AttributeArray.h:2000
Definition: AttributeArrayString.h:83
std::shared_ptr< AttributeArray > Ptr
Definition: AttributeArray.h:142
BloscCompressAttributesOp(const Indices &indices)
Definition: PointAttribute.h:380
virtual bool compress()=0
Compress the attribute array.
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:327
const Indices & mIndices
Definition: PointAttribute.h:348
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
LeafIter beginLeaf()
Return an iterator over all leaf nodes in this tree.
Definition: Tree.h:1180
Base class for storing attribute data.
Definition: AttributeArray.h:118
Attribute array storage for string data using Descriptor Metadata.
const ValueType mUniformValue
Definition: PointAttribute.h:282
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:46
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:71
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:65
const bool mConstantStride
Definition: PointAttribute.h:249
static void add(PointDataTree &tree, const AttributeListType &data)
Definition: PointAttribute.h:443
AttributeSet::DescriptorPtr & mDescriptor
Definition: PointAttribute.h:246
void operator()(const LeafRangeT &range) const
Definition: PointAttribute.h:383
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
Set of Attribute Arrays which tracks metadata about each array.
ValueType defaultValue()
Definition: PointAttribute.h:56
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
typename LeafManagerT::LeafRange LeafRangeT
Definition: PointAttribute.h:293
void renameAttribute(PointDataTree &tree, const Name &oldName, const Name &newName)
Rename an attribute in a VDB tree.
Definition: PointAttribute.h:738
std::vector< size_t > Indices
Definition: PointAttribute.h:378
typename tree::LeafManager< PointDataTreeType > LeafManagerT
Definition: PointAttribute.h:376
Write-able version of AttributeHandle.
Definition: AttributeArray.h:709
const Index mStrideOrTotalSize
Definition: PointAttribute.h:248
SharedPtr< Metadata > Ptr
Definition: Metadata.h:51