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