OpenVDB: PointAttribute.h Source File

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