HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointAttribute.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////
2 //
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 //
29 ///////////////////////////////////////////////////////////////////////////
30 
31 /// @author Dan Bailey, Khang Ngo
32 ///
33 /// @file points/PointAttribute.h
34 ///
35 /// @brief Point attribute manipulation in a VDB Point Grid.
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 
64 /// @brief Appends a new attribute to the VDB tree
65 /// (this method does not require a templated AttributeType)
66 ///
67 /// @param tree the PointDataTree to be appended to.
68 /// @param name name for the new attribute.
69 /// @param type the type of the attibute.
70 /// @param strideOrTotalSize the stride of the attribute
71 /// @param constantStride if @c false, stride is interpreted as total size of the array
72 /// @param metaDefaultValue metadata default attribute value
73 /// @param hidden mark attribute as hidden
74 /// @param transient mark attribute as transient
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 
85 /// @brief Appends a new attribute to the VDB tree.
86 ///
87 /// @param tree the PointDataTree to be appended to.
88 /// @param name name for the new attribute
89 /// @param uniformValue the initial value of the attribute
90 /// @param strideOrTotalSize the stride of the attribute
91 /// @param constantStride if @c false, stride is interpreted as total size of the array
92 /// @param metaDefaultValue metadata default attribute value
93 /// @param hidden mark attribute as hidden
94 /// @param transient mark attribute as transient
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 =
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 
108 /// @brief Collapse the attribute into a uniform value
109 ///
110 /// @param tree the PointDataTree in which to collapse the attribute.
111 /// @param name name for the attribute.
112 /// @param uniformValue value of the attribute
113 template <typename ValueType, typename PointDataTreeT>
114 inline void collapseAttribute( PointDataTreeT& tree,
115  const Name& name,
116  const ValueType& uniformValue =
118 
119 /// @brief Drops attributes from the VDB tree.
120 ///
121 /// @param tree the PointDataTree to be dropped from.
122 /// @param indices indices of the attributes to drop.
123 template <typename PointDataTreeT>
124 inline void dropAttributes( PointDataTreeT& tree,
125  const std::vector<size_t>& indices);
126 
127 /// @brief Drops attributes from the VDB tree.
128 ///
129 /// @param tree the PointDataTree to be dropped from.
130 /// @param names names of the attributes to drop.
131 template <typename PointDataTreeT>
132 inline void dropAttributes( PointDataTreeT& tree,
133  const std::vector<Name>& names);
134 
135 /// @brief Drop one attribute from the VDB tree (convenience method).
136 ///
137 /// @param tree the PointDataTree to be dropped from.
138 /// @param index index of the attribute to drop.
139 template <typename PointDataTreeT>
140 inline void dropAttribute( PointDataTreeT& tree,
141  const size_t& index);
142 
143 /// @brief Drop one attribute from the VDB tree (convenience method).
144 ///
145 /// @param tree the PointDataTree to be dropped from.
146 /// @param name name of the attribute to drop.
147 template <typename PointDataTreeT>
148 inline void dropAttribute( PointDataTreeT& tree,
149  const Name& name);
150 
151 /// @brief Rename attributes in a VDB tree.
152 ///
153 /// @param tree the PointDataTree.
154 /// @param oldNames a list of old attribute names to rename from.
155 /// @param newNames a list of new attribute names to rename to.
156 ///
157 /// @note Number of oldNames must match the number of newNames.
158 ///
159 /// @note Duplicate names and renaming group attributes are not allowed.
160 template <typename PointDataTreeT>
161 inline void renameAttributes(PointDataTreeT& tree,
162  const std::vector<Name>& oldNames,
163  const std::vector<Name>& newNames);
164 
165 /// @brief Rename an attribute in a VDB tree.
166 ///
167 /// @param tree the PointDataTree.
168 /// @param oldName the old attribute name to rename from.
169 /// @param newName the new attribute name to rename to.
170 ///
171 /// @note newName must not already exist and must not be a group attribute.
172 template <typename PointDataTreeT>
173 inline void renameAttribute(PointDataTreeT& tree,
174  const Name& oldName,
175  const Name& newName);
176 
177 /// @brief Compact attributes in a VDB tree (if possible).
178 ///
179 /// @param tree the PointDataTree.
180 template <typename PointDataTreeT>
181 inline void compactAttributes(PointDataTreeT& tree);
182 
183 /// @brief Apply Blosc compression to one attribute in the VDB tree.
184 ///
185 /// @param tree the PointDataTree.
186 /// @param name name of the attribute to compress.
187 template <typename PointDataTreeT>
188 inline void bloscCompressAttribute( PointDataTreeT& tree,
189  const Name& name);
190 
191 ////////////////////////////////////////
192 
193 
194 namespace point_attribute_internal {
195 
196 template<typename PointDataTreeT>
198 
200  using LeafRangeT = typename LeafManagerT::LeafRange;
201 
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(
222 
223  if (mHidden) attribute->setHidden(true);
224  if (mTransient) attribute->setTransient(true);
225  }
226  }
227 
228  //////////
229 
231  const size_t mPos;
233  const bool mConstantStride;
234  const bool mHidden;
235  const bool mTransient;
236 }; // class AppendAttributeOp
237 
238 
239 ////////////////////////////////////////
240 
241 
242 template <typename ValueType, typename PointDataTreeT>
244 
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 
263  //////////
264 
265  const size_t mPos;
266  const ValueType mUniformValue;
267 }; // class CollapseAttributeOp
268 
269 
270 ////////////////////////////////////////
271 
272 
273 template <typename PointDataTreeT>
274 struct CollapseAttributeOp<Name, PointDataTreeT> {
275 
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 
298  //////////
299 
300  const size_t mPos;
302 }; // class CollapseAttributeOp
303 
304 
305 ////////////////////////////////////////
306 
307 
308 template<typename PointDataTreeT>
310 
312  using LeafRangeT = typename LeafManagerT::LeafRange;
313  using Indices = std::vector<size_t>;
314 
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 
330  //////////
331 
334 }; // class DropAttributesOp
335 
336 
337 ////////////////////////////////////////
338 
339 
340 template<typename PointDataTreeT>
342 
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 
354 ////////////////////////////////////////
355 
356 
357 template<typename PointDataTreeT>
359 
361  using LeafRangeT = typename LeafManagerT::LeafRange;
362  using Indices = std::vector<size_t>;
363 
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 
379  //////////
380 
382 }; // class BloscCompressAttributesOp
383 
384 
385 ////////////////////////////////////////
386 
387 
388 template <typename ValueType, typename CodecType>
390 {
391  static const NamePair& type() {
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 
404 ////////////////////////////////////////
405 
406 
407 template <typename PointDataTreeT, typename ValueType>
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 
443 ////////////////////////////////////////
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 
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 
497 ////////////////////////////////////////
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 {
511  "ValueType must not be derived from AttributeArray");
512 
516 
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 
527 ////////////////////////////////////////
528 
529 
530 template <typename ValueType, typename PointDataTreeT>
531 inline void collapseAttribute( PointDataTreeT& tree,
532  const Name& name,
533  const ValueType& uniformValue)
534 {
536  "ValueType must not be derived from AttributeArray");
537 
538  using LeafManagerT = typename tree::LeafManager<PointDataTreeT>;
539  using Descriptor = AttributeSet::Descriptor;
540 
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 
563 ////////////////////////////////////////
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 
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 
599 ////////////////////////////////////////
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 
631 ////////////////////////////////////////
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 
652 ////////////////////////////////////////
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 
711 ////////////////////////////////////////
712 
713 
714 template <typename PointDataTreeT>
715 inline void compactAttributes(PointDataTreeT& tree)
716 {
717  using LeafManagerT = typename tree::LeafManager<PointDataTreeT>;
718 
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 
729 ////////////////////////////////////////
730 
731 
732 template <typename PointDataTreeT>
733 inline void bloscCompressAttribute( PointDataTreeT& tree,
734  const Name& name)
735 {
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 
763 ////////////////////////////////////////
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/ )
AttributeSet::Descriptor::Ptr makeDescriptorUnique(PointDataTreeT &tree)
Deep copy the descriptor across all leaf nodes.
Definition: ImfName.h:53
Descriptor & descriptor()
Return a reference to this attribute set's descriptor, which might be shared with other sets...
Definition: AttributeSet.h:121
GLsizei GLenum const void * indices
Definition: glcorearb.h:405
GLenum GLint * range
Definition: glcorearb.h:1924
LeafRange leafRange(size_t grainsize=1) const
Return a TBB-compatible LeafRange.
Definition: LeafManager.h:386
bool isExactlyEqual(const T0 &a, const T1 &b)
Return true if a is exactly equal to b.
Definition: Math.h:395
AppendAttributeOp(AttributeSet::DescriptorPtr &descriptor, const size_t pos, const Index strideOrTotalSize=1, const bool constantStride=true, const bool hidden=false, const bool transient=false)
GLsizei const GLchar *const * string
Definition: glcorearb.h:813
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:189
void compactAttributes(PointDataTreeT &tree)
Compact attributes in a VDB tree (if possible).
png_uint_32 i
Definition: png.h:2877
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:46
void collapse()
Replace the existing array with a uniform value (zero if none provided).
bool isGroup(const AttributeArray &array)
void renameAttributes(PointDataTreeT &tree, const std::vector< Name > &oldNames, const std::vector< Name > &newNames)
Rename attributes in a VDB tree.
Base class for storing attribute data.
virtual bool compress()=0
Compress the attribute array.
static const NamePair & attributeType()
Return the name of this attribute's type (includes codec)
Attribute array storage for string data using Descriptor Metadata.
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...
void collapse()
Set membership for the whole array and attempt to collapse.
This class manages a linear array of pointers to a given tree's leaf nodes, as well as optional auxil...
Definition: LeafManager.h:110
void dropAttributes(PointDataTreeT &tree, const std::vector< size_t > &indices)
Drops attributes from the VDB tree.
static void add(PointDataTreeT &, const AttributeListType &)
GLboolean * data
Definition: glcorearb.h:130
std::pair< Name, Name > NamePair
GLuint const GLchar * name
Definition: glcorearb.h:785
void bloscCompressAttribute(PointDataTreeT &tree, const Name &name)
Apply Blosc compression to one attribute in the VDB tree.
GLsizei const GLfloat * value
Definition: glcorearb.h:823
Set of Attribute Arrays which tracks metadata about each array.
void collapseAttribute(PointDataTreeT &tree, const Name &name, const ValueType &uniformValue=point_attribute_internal::Default< ValueType >::value())
Collapse the attribute into a uniform value.
Attribute Group access and filtering for iteration.
GLuint index
Definition: glcorearb.h:785
void dropAttribute(PointDataTreeT &tree, const size_t &index)
Drop one attribute from the VDB tree (convenience method).
Ordered collection of uniquely-named attribute arrays.
Definition: AttributeSet.h:62
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
tree::Tree< tree::RootNode< tree::InternalNode< tree::InternalNode< PointDataLeafNode< PointDataIndex32, 3 >, 4 >, 5 >>> PointDataTree
Point index tree configured to match the default VDB configurations.
void insert(const Name &name)
Insert the string into the metadata.
void appendAttribute(PointDataTreeT &tree, const Name &name, const NamePair &type, 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 (this method does not require a templated AttributeType) ...
void renameAttribute(PointDataTreeT &tree, const Name &oldName, const Name &newName)
Rename an attribute in a VDB tree.
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:135
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
DropAttributesOp(const Indices &indices, AttributeSet::DescriptorPtr &descriptor)
DescriptorPtr descriptorPtr() const
Return a pointer to this attribute set's descriptor, which might be shared with other sets...
Definition: AttributeSet.h:127
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
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