OpenVDB  12.0.0
AttributeSet.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: Apache-2.0
3 
4 /// @file points/AttributeSet.h
5 ///
6 /// @authors Dan Bailey, Mihai Alden
7 ///
8 /// @brief Set of Attribute Arrays which tracks metadata about each array.
9 
10 #ifndef OPENVDB_POINTS_ATTRIBUTE_SET_HAS_BEEN_INCLUDED
11 #define OPENVDB_POINTS_ATTRIBUTE_SET_HAS_BEEN_INCLUDED
12 
13 #include "AttributeArray.h"
14 #include <openvdb/version.h>
15 #include <openvdb/MetaMap.h>
16 
17 #include <limits>
18 #include <climits>
19 #include <memory>
20 #include <vector>
21 
22 
23 class TestAttributeSet;
24 
25 
26 namespace openvdb {
28 namespace OPENVDB_VERSION_NAME {
29 namespace points {
30 
31 
32 using GroupType = uint8_t;
33 
34 
35 ////////////////////////////////////////
36 
37 
38 /// Ordered collection of uniquely-named attribute arrays
40 {
41 public:
42  enum AttributePositionLabel : size_t { INVALID_POS = std::numeric_limits<size_t>::max() };
43 
44  using Ptr = std::shared_ptr<AttributeSet>;
45  using ConstPtr = std::shared_ptr<const AttributeSet>;
46  using UniquePtr = std::unique_ptr<AttributeSet>;
47 
48  class Descriptor;
49 
50  using DescriptorPtr = std::shared_ptr<Descriptor>;
51  using DescriptorConstPtr = std::shared_ptr<const Descriptor>;
52 
53  //////////
54 
55  struct Util
56  {
57  /// Attribute and type name pair.
58  struct NameAndType {
59  NameAndType(const std::string& n, const NamePair& t, const Index s = 1)
60  : name(n), type(t), stride(s) {}
64  };
65 
66  using NameAndTypeVec = std::vector<NameAndType>;
67  using NameToPosMap = std::map<std::string, size_t>;
68  using GroupIndex = std::pair<size_t, uint8_t>;
69  };
70 
71  //////////
72 
73  AttributeSet();
74 
75  /// Construct a new AttributeSet from the given AttributeSet.
76  /// @param attributeSet the old attribute set
77  /// @param arrayLength the desired length of the arrays in the new AttributeSet
78  /// @param lock an optional scoped registry lock to avoid contention
79  /// @note This constructor is typically used to resize an existing AttributeSet as
80  /// it transfers attribute metadata such as hidden and transient flags
81  AttributeSet(const AttributeSet& attributeSet, Index arrayLength,
82  const AttributeArray::ScopedRegistryLock* lock = nullptr);
83 
84  /// Construct a new AttributeSet from the given Descriptor.
85  /// @param descriptor stored in the new AttributeSet and used in construction
86  /// @param arrayLength the desired length of the arrays in the new AttributeSet
87  /// @param lock an optional scoped registry lock to avoid contention
88  /// @note Descriptors do not store attribute metadata such as hidden and transient flags
89  /// which live on the AttributeArrays, so for constructing from an existing AttributeSet
90  /// use the AttributeSet(const AttributeSet&, Index) constructor instead
91  AttributeSet(const DescriptorPtr& descriptor, Index arrayLength = 1,
92  const AttributeArray::ScopedRegistryLock* lock = nullptr);
93 
94  /// Shallow copy constructor, the descriptor and attribute arrays will be shared.
95  AttributeSet(const AttributeSet&);
96 
97  /// Disallow copy assignment, since it wouldn't be obvious whether the copy is deep or shallow.
98  AttributeSet& operator=(const AttributeSet&) = delete;
99 
100  //@{
101  /// @brief Return a reference to this attribute set's descriptor, which might
102  /// be shared with other sets.
103  Descriptor& descriptor() { return *mDescr; }
104  const Descriptor& descriptor() const { return *mDescr; }
105  //@}
106 
107  /// @brief Return a pointer to this attribute set's descriptor, which might be
108  /// shared with other sets
109  DescriptorPtr descriptorPtr() const { return mDescr; }
110 
111  /// Return the number of attributes in this set.
112  size_t size() const { return mAttrs.size(); }
113 
114  /// Return the number of bytes of memory used by this attribute set.
115  size_t memUsage() const;
116 
117  /// Return the number of bytes of memory used by this attribute set once it
118  /// has been deserialized (this may be different to memUsage() if delay-loading
119  /// is in use).
120  size_t memUsageIfLoaded() const;
121 
122  /// @brief Return the position of the attribute array whose name is @a name,
123  /// or @c INVALID_POS if no match is found.
124  size_t find(const std::string& name) const;
125 
126  /// @brief Replace the attribute array whose name is @a name.
127  /// @return The position of the updated attribute array or @c INVALID_POS
128  /// if the given name does not exist or if the replacement failed because
129  /// the new array type does not comply with the descriptor.
130  size_t replace(const std::string& name, const AttributeArray::Ptr&);
131 
132  /// @brief Replace the attribute array stored at position @a pos in this container.
133  /// @return The position of the updated attribute array or @c INVALID_POS
134  /// if replacement failed because the new array type does not comply with
135  /// the descriptor.
136  size_t replace(size_t pos, const AttributeArray::Ptr&);
137 
138  //@{
139  /// @brief Return a pointer to the attribute array whose name is @a name or
140  /// a null pointer if no match is found.
141  const AttributeArray* getConst(const std::string& name) const;
142  const AttributeArray* get(const std::string& name) const;
143  AttributeArray* get(const std::string& name);
144  //@}
145 
146  //@{
147  /// @brief Return a pointer to the attribute array stored at position @a pos
148  /// in this set.
149  const AttributeArray* getConst(size_t pos) const;
150  const AttributeArray* get(size_t pos) const;
151  AttributeArray* get(size_t pos);
152  //@}
153 
154  //@{
155  /// @brief Return the group offset from the name or index of the group
156  /// A group attribute array is a single byte (8-bit), each bit of which
157  /// can denote a group. The group offset is the position of the bit that
158  /// denotes the requested group if all group attribute arrays in the set
159  /// (and only attribute arrays marked as group) were to be laid out linearly
160  /// according to their order in the set.
161  size_t groupOffset(const Name& groupName) const;
162  size_t groupOffset(const Util::GroupIndex& index) const;
163  //@}
164 
165  /// Return the group index from the name of the group
166  Util::GroupIndex groupIndex(const Name& groupName) const;
167  /// Return the group index from the offset of the group
168  /// @note see offset description for groupOffset()
169  Util::GroupIndex groupIndex(const size_t offset) const;
170 
171  /// Return the indices of the attribute arrays which are group attribute arrays
172  std::vector<size_t> groupAttributeIndices() const;
173 
174  /// Return true if the attribute array stored at position @a pos is shared.
175  bool isShared(size_t pos) const;
176  /// @brief If the attribute array stored at position @a pos is shared,
177  /// replace the array with a deep copy of itself that is not
178  /// shared with anyone else.
179  void makeUnique(size_t pos);
180 
181  /// Append attribute @a attribute (simple method)
183  const NamePair& type,
184  const Index strideOrTotalSize = 1,
185  const bool constantStride = true,
186  const Metadata* defaultValue = nullptr);
187 
188  /// Append attribute @a attribute (descriptor-sharing)
189  /// Requires current descriptor to match @a expected
190  /// On append, current descriptor is replaced with @a replacement
191  /// Provide a @a lock object to avoid contention from appending in parallel
192  AttributeArray::Ptr appendAttribute(const Descriptor& expected, DescriptorPtr& replacement,
193  const size_t pos, const Index strideOrTotalSize = 1,
194  const bool constantStride = true,
195  const Metadata* defaultValue = nullptr,
196  const AttributeArray::ScopedRegistryLock* lock = nullptr);
197 
198  /// @brief Remove and return an attribute array by name
199  /// @param name the name of the attribute array to release
200  /// @details Detaches the attribute array from this attribute set and returns it, if
201  /// @a name is invalid, returns an empty shared pointer. This also updates the descriptor
202  /// to remove the reference to the attribute array.
203  /// @note AttributeArrays are stored as shared pointers, so they are not guaranteed
204  /// to be unique. Check the reference count before blindly re-using in a new AttributeSet.
205  AttributeArray::Ptr removeAttribute(const Name& name);
206 
207  /// @brief Remove and return an attribute array by index
208  /// @param pos the position index of the attribute to release
209  /// @details Detaches the attribute array from this attribute set and returns it, if
210  /// @a pos is invalid, returns an empty shared pointer. This also updates the descriptor
211  /// to remove the reference to the attribute array.
212  /// @note AttributeArrays are stored as shared pointers, so they are not guaranteed
213  /// to be unique. Check the reference count before blindly re-using in a new AttributeSet.
214  AttributeArray::Ptr removeAttribute(const size_t pos);
215 
216  /// @brief Remove and return an attribute array by index (unsafe method)
217  /// @param pos the position index of the attribute to release
218  /// @details Detaches the attribute array from this attribute set and returns it, if
219  /// @a pos is invalid, returns an empty shared pointer.
220  /// In cases where the AttributeSet is due to be destroyed, a small performance
221  /// advantage can be gained by leaving the attribute array as a nullptr and not
222  /// updating the descriptor. However, this leaves the AttributeSet in an invalid
223  /// state making it unsafe to call any methods that implicitly derefence the attribute array.
224  /// @note AttributeArrays are stored as shared pointers, so they are not guaranteed
225  /// to be unique. Check the reference count before blindly re-using in a new AttributeSet.
226  /// @warning Only use this method if you're an expert and know the risks of not
227  /// updating the array of attributes or the descriptor.
228  AttributeArray::Ptr removeAttributeUnsafe(const size_t pos);
229 
230  /// Drop attributes with @a pos indices (simple method)
231  /// Creates a new descriptor for this attribute set
232  void dropAttributes(const std::vector<size_t>& pos);
233 
234  /// Drop attributes with @a pos indices (descriptor-sharing method)
235  /// Requires current descriptor to match @a expected
236  /// On drop, current descriptor is replaced with @a replacement
237  void dropAttributes(const std::vector<size_t>& pos,
238  const Descriptor& expected, DescriptorPtr& replacement);
239 
240  /// Re-name attributes in set to match a provided descriptor
241  /// Replaces own descriptor with @a replacement
242  void renameAttributes(const Descriptor& expected, const DescriptorPtr& replacement);
243 
244  /// Re order attribute set to match a provided descriptor
245  /// Replaces own descriptor with @a replacement
246  void reorderAttributes(const DescriptorPtr& replacement);
247 
248  /// Replace the current descriptor with a @a replacement
249  /// Note the provided Descriptor must be identical to the replacement
250  /// unless @a allowMismatchingDescriptors is true (default is false)
251  void resetDescriptor(const DescriptorPtr& replacement, const bool allowMismatchingDescriptors = false);
252 
253  /// Read the entire set from a stream.
254  void read(std::istream&);
255  /// Write the entire set to a stream.
256  /// @param outputTransient if true, write out transient attributes
257  void write(std::ostream&, bool outputTransient = false) const;
258 
259  /// This will read the attribute descriptor from a stream.
260  void readDescriptor(std::istream&);
261  /// This will write the attribute descriptor to a stream.
262  /// @param outputTransient if true, write out transient attributes
263  void writeDescriptor(std::ostream&, bool outputTransient = false) const;
264 
265  /// This will read the attribute metadata from a stream.
266  void readMetadata(std::istream&);
267  /// This will write the attribute metadata to a stream.
268  /// @param outputTransient if true, write out transient attributes
269  /// @param paged if true, data is written out in pages
270  void writeMetadata(std::ostream&, bool outputTransient = false, bool paged = false) const;
271 
272  /// This will read the attribute data from a stream.
273  void readAttributes(std::istream&);
274  /// This will write the attribute data to a stream.
275  /// @param outputTransient if true, write out transient attributes
276  void writeAttributes(std::ostream&, bool outputTransient = false) const;
277 
278  /// Compare the descriptors and attribute arrays on the attribute sets
279  /// Exit early if the descriptors do not match
280  bool operator==(const AttributeSet& other) const;
281  bool operator!=(const AttributeSet& other) const { return !this->operator==(other); }
282 
283 private:
284  using AttrArrayVec = std::vector<AttributeArray::Ptr>;
285 
286  DescriptorPtr mDescr;
287  AttrArrayVec mAttrs;
288 }; // class AttributeSet
289 
290 ////////////////////////////////////////
291 
292 
293 /// A container for ABI=5 to help ease introduction of upcoming features
294 namespace future {
295  class Container
296  {
297  class Element { };
298  std::vector<std::shared_ptr<Element>> mElements;
299  };
300 }
301 
302 
303 ////////////////////////////////////////
304 
305 
306 /// @brief An immutable object that stores name, type and AttributeSet position
307 /// for a constant collection of attribute arrays.
308 /// @note The attribute name is actually mutable, but the attribute type
309 /// and position can not be changed after creation.
310 class OPENVDB_API AttributeSet::Descriptor
311 {
312 public:
313  using Ptr = std::shared_ptr<Descriptor>;
314 
319  using ConstIterator = NameToPosMap::const_iterator;
320 
321  /// Utility method to construct a NameAndType sequence.
322  struct Inserter {
324  Inserter& add(const NameAndType& nameAndType) {
325  vec.push_back(nameAndType); return *this;
326  }
327  Inserter& add(const Name& name, const NamePair& type) {
328  vec.emplace_back(name, type); return *this;
329  }
330  Inserter& add(const NameAndTypeVec& other) {
331  for (NameAndTypeVec::const_iterator it = other.begin(), itEnd = other.end(); it != itEnd; ++it) {
332  vec.emplace_back(it->name, it->type);
333  }
334  return *this;
335  }
336  };
337 
338  //////////
339 
340  Descriptor();
341 
342  /// Copy constructor
343  Descriptor(const Descriptor&);
344 
345  /// Create a new descriptor from a position attribute type and assumes "P" (for convenience).
346  static Ptr create(const NamePair&);
347 
348  /// Create a new descriptor as a duplicate with a new attribute appended
349  Ptr duplicateAppend(const Name& name, const NamePair& type) const;
350 
351  /// Create a new descriptor as a duplicate with existing attributes dropped
352  Ptr duplicateDrop(const std::vector<size_t>& pos) const;
353 
354  /// Return the number of attributes in this descriptor.
355  size_t size() const { return mTypes.size(); }
356 
357  /// Return the number of attributes with this attribute type
358  size_t count(const NamePair& type) const;
359 
360  /// Return the number of bytes of memory used by this attribute set.
361  size_t memUsage() const;
362 
363  /// @brief Return the position of the attribute array whose name is @a name,
364  /// or @c INVALID_POS if no match is found.
365  size_t find(const std::string& name) const;
366 
367  /// Rename an attribute array
368  size_t rename(const std::string& fromName, const std::string& toName);
369 
370  /// Return the name of the attribute array's type.
371  const Name& valueType(size_t pos) const;
372  /// Return the name of the attribute array's type.
373  const NamePair& type(size_t pos) const;
374 
375  /// Retrieve metadata map
376  MetaMap& getMetadata();
377  const MetaMap& getMetadata() const;
378 
379  /// Return true if the attribute has a default value
380  bool hasDefaultValue(const Name& name) const;
381  /// Get a default value for an existing attribute
382  template<typename ValueType>
383  ValueType getDefaultValue(const Name& name) const
384  {
385  const size_t pos = find(name);
386  if (pos == INVALID_POS) {
387  OPENVDB_THROW(LookupError, "Cannot find attribute name to set default value.")
388  }
389 
390  std::stringstream ss;
391  ss << "default:" << name;
392 
393  auto metadata = mMetadata.getMetadata<TypedMetadata<ValueType>>(ss.str());
394 
395  if (metadata) return metadata->value();
396 
397  return zeroVal<ValueType>();
398  }
399  /// Set a default value for an existing attribute
400  void setDefaultValue(const Name& name, const Metadata& defaultValue);
401  // Remove the default value if it exists
402  void removeDefaultValue(const Name& name);
403  // Prune any default values for which the key is no longer present
404  void pruneUnusedDefaultValues();
405 
406  /// Return true if this descriptor is equal to the given one.
407  bool operator==(const Descriptor&) const;
408  /// Return true if this descriptor is not equal to the given one.
409  bool operator!=(const Descriptor& rhs) const { return !this->operator==(rhs); }
410  /// Return true if this descriptor contains the same attributes
411  /// as the given descriptor, ignoring attribute order
412  bool hasSameAttributes(const Descriptor& rhs) const;
413 
414  /// Return a reference to the name-to-position map.
415  const NameToPosMap& map() const { return mNameMap; }
416  /// Return a reference to the name-to-position group map.
417  const NameToPosMap& groupMap() const { return mGroupMap; }
418 
419  /// Return @c true if group exists
420  bool hasGroup(const Name& group) const;
421  /// @brief Define a group name to offset mapping
422  /// @param group group name
423  /// @param offset group offset
424  /// @param checkValidOffset throws if offset out-of-range or in-use
425  void setGroup(const Name& group, const size_t offset,
426  const bool checkValidOffset = false);
427  /// Drop any mapping keyed by group name
428  void dropGroup(const Name& group);
429  /// Clear all groups
430  void clearGroups();
431  /// Rename a group
432  size_t renameGroup(const std::string& fromName, const std::string& toName);
433  /// Return a unique name for a group based on given name
434  const Name uniqueGroupName(const Name& name) const;
435 
436  //@{
437  /// @brief Return the group offset from the name or index of the group
438  /// A group attribute array is a single byte (8-bit), each bit of which
439  /// can denote a group. The group offset is the position of the bit that
440  /// denotes the requested group if all group attribute arrays in the set
441  /// (and only attribute arrays marked as group) were to be laid out linearly
442  /// according to their order in the set.
443  size_t groupOffset(const Name& groupName) const;
444  size_t groupOffset(const GroupIndex& index) const;
445  //@}
446 
447  /// Return the group index from the name of the group
448  GroupIndex groupIndex(const Name& groupName) const;
449  /// Return the group index from the offset of the group
450  /// @note see offset description for groupOffset()
451  GroupIndex groupIndex(const size_t offset) const;
452 
453  /// Return number of bits occupied by a group attribute array
454  static size_t groupBits() { return sizeof(GroupType) * CHAR_BIT; }
455 
456  /// Return the total number of available groups
457  /// (group bits * number of group attributes)
458  size_t availableGroups() const;
459 
460  /// Return the number of empty group slots which correlates to the number of groups
461  /// that can be stored without increasing the number of group attribute arrays
462  size_t unusedGroups() const;
463 
464  /// Return @c true if there are sufficient empty slots to allow compacting
465  bool canCompactGroups() const;
466 
467  /// @brief Return a group offset that is not in use
468  /// @param hint if provided, request a specific offset as a hint
469  /// @return index of an offset or size_t max if no available group offsets
470  size_t unusedGroupOffset(size_t hint = std::numeric_limits<size_t>::max()) const;
471 
472  /// @brief Determine if a move is required to efficiently compact the data and store the
473  /// source name, offset and the target offset in the input parameters
474  /// @param sourceName source name
475  /// @param sourceOffset source offset
476  /// @param targetOffset target offset
477  /// @return @c true if move is required to compact the data
478  bool requiresGroupMove(Name& sourceName, size_t& sourceOffset, size_t& targetOffset) const;
479 
480  /// @brief Test if there are any group names shared by both descriptors which
481  /// have a different index
482  /// @param rhs the descriptor to compare with
483  /// @return @c true if an index collision exists
484  bool groupIndexCollision(const Descriptor& rhs) const;
485 
486  /// Return a unique name for an attribute array based on given name
487  const Name uniqueName(const Name& name) const;
488 
489  /// Return true if the name is valid
490  static bool validName(const Name& name);
491 
492  /// @brief Extract each name from @a nameStr into @a includeNames, or into @a excludeNames
493  /// if the name is prefixed with a caret.
494  /// @param nameStr the input string of names
495  /// @param includeNames on exit, the list of names that are not prefixed with a caret
496  /// @param excludeNames on exit, the list of names that are prefixed with a caret
497  /// @param includeAll on exit, @c true if a "*" wildcard is present in the @a includeNames
498  static void parseNames( std::vector<std::string>& includeNames,
499  std::vector<std::string>& excludeNames,
500  bool& includeAll,
501  const std::string& nameStr);
502 
503  /// @brief Extract each name from @a nameStr into @a includeNames, or into @a excludeNames
504  /// if the name is prefixed with a caret.
505  static void parseNames( std::vector<std::string>& includeNames,
506  std::vector<std::string>& excludeNames,
507  const std::string& nameStr);
508 
509  /// Serialize this descriptor to the given stream.
510  void write(std::ostream&) const;
511  /// Unserialize this transform from the given stream.
512  void read(std::istream&);
513 
514 protected:
515  /// Append to a vector of names and types from this Descriptor in position order
516  void appendTo(NameAndTypeVec& attrs) const;
517 
518  /// Create a new descriptor from the given attribute and type name pairs
519  /// and copy the group maps and metamap.
520  static Ptr create(const NameAndTypeVec&, const NameToPosMap&, const MetaMap&);
521 
522  size_t insert(const std::string& name, const NamePair& typeName);
523 
524 private:
525  friend class ::TestAttributeSet;
526 
527  NameToPosMap mNameMap;
528  std::vector<NamePair> mTypes;
529  NameToPosMap mGroupMap;
530  MetaMap mMetadata;
531  // as this change is part of an ABI change, there's no good reason to reduce the reserved
532  // space aside from keeping the memory size of an AttributeSet the same for convenience
533  // (note that this assumes a typical three-pointer implementation for std::vector)
534  future::Container mFutureContainer; // occupies 3 reserved slots
535  int64_t mReserved[5]; // for future use
536 }; // class Descriptor
537 
538 } // namespace points
539 } // namespace OPENVDB_VERSION_NAME
540 } // namespace openvdb
541 
542 #endif // OPENVDB_POINTS_ATTRIBUTE_ARRAY_HAS_BEEN_INCLUDED
Util::GroupIndex GroupIndex
Definition: AttributeSet.h:317
#define OPENVDB_API
Definition: Platform.h:268
Definition: Exceptions.h:60
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
void renameAttributes(PointDataTreeT &tree, const std::vector< Name > &oldNames, const std::vector< Name > &newNames)
Rename attributes in a VDB tree.
Definition: PointAttributeImpl.h:326
uint8_t GroupType
Definition: AttributeSet.h:32
Inserter & add(const NameAndType &nameAndType)
Definition: AttributeSet.h:324
Index64 memUsageIfLoaded(const TreeT &tree, bool threaded=true)
Return the deserialized memory usage of this tree. This is not necessarily equal to the current memor...
Definition: Count.h:502
NameAndType(const std::string &n, const NamePair &t, const Index s=1)
Definition: AttributeSet.h:59
const Descriptor & descriptor() const
Return a reference to this attribute set&#39;s descriptor, which might be shared with other sets...
Definition: AttributeSet.h:104
AttributePositionLabel
Definition: AttributeSet.h:42
Definition: AttributeSet.h:55
Attribute Array storage templated on type and compression codec.
void dropAttributes(PointDataTreeT &tree, const std::vector< size_t > &indices)
Drops attributes from the VDB tree.
Definition: PointAttributeImpl.h:238
void appendAttribute(PointDataTreeT &tree, const Name &name, const NamePair &type, const Index strideOrTotalSize=1, const bool constantStride=true, const Metadata *defaultValue=nullptr, const bool hidden=false, const bool transient=false)
Appends a new attribute to the VDB tree (this method does not require a templated AttributeType) ...
Definition: PointAttributeImpl.h:103
bool operator!=(const AttributeSet &other) const
Definition: AttributeSet.h:281
Index32 Index
Definition: Types.h:54
const std::enable_if<!VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:110
ValueType getDefaultValue(const Name &name) const
Get a default value for an existing attribute.
Definition: AttributeSet.h:383
NameToPosMap::const_iterator ConstIterator
Definition: AttributeSet.h:319
Util::NameToPosMap NameToPosMap
Definition: AttributeSet.h:318
const NameToPosMap & map() const
Return a reference to the name-to-position map.
Definition: AttributeSet.h:415
Base class for storing metadata information in a grid.
Definition: Metadata.h:24
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:474
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:19
size_t size() const
Return the number of attributes in this set.
Definition: AttributeSet.h:112
Index64 memUsage(const TreeT &tree, bool threaded=true)
Return the total amount of memory in bytes occupied by this tree.
Definition: Count.h:493
std::shared_ptr< const Descriptor > DescriptorConstPtr
Definition: AttributeSet.h:51
Templated metadata class to hold specific types.
Definition: Metadata.h:122
std::map< std::string, size_t > NameToPosMap
Definition: AttributeSet.h:67
std::shared_ptr< const AttributeSet > ConstPtr
Definition: AttributeSet.h:45
DescriptorPtr descriptorPtr() const
Return a pointer to this attribute set&#39;s descriptor, which might be shared with other sets...
Definition: AttributeSet.h:109
Util::NameAndTypeVec NameAndTypeVec
Definition: AttributeSet.h:316
void replace(std::string &str, const std::string &oldStr, const std::string &newStr)
Definition: util.h:65
const NameToPosMap & groupMap() const
Return a reference to the name-to-position group map.
Definition: AttributeSet.h:417
Definition: Exceptions.h:13
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:40
std::unique_ptr< AttributeSet > UniquePtr
Definition: AttributeSet.h:46
NameAndTypeVec vec
Definition: AttributeSet.h:323
bool operator!=(const Descriptor &rhs) const
Return true if this descriptor is not equal to the given one.
Definition: AttributeSet.h:409
std::shared_ptr< AttributeSet > Ptr
Definition: AttributeSet.h:44
static size_t groupBits()
Return number of bits occupied by a group attribute array.
Definition: AttributeSet.h:454
Definition: AttributeSet.h:295
void setGroup(PointDataTreeT &tree, const PointIndexTreeT &indexTree, const std::vector< short > &membership, const Name &group, const bool remove=false)
Sets group membership from a PointIndexTree-ordered vector.
Definition: PointGroupImpl.h:438
Utility method to construct a NameAndType sequence.
Definition: AttributeSet.h:322
void dropGroup(PointDataTreeT &tree, const Name &group, const bool compact=true)
Drops an existing group from the VDB tree.
Definition: PointGroupImpl.h:296
Attribute and type name pair.
Definition: AttributeSet.h:58
std::pair< size_t, uint8_t > GroupIndex
Definition: AttributeSet.h:68
std::vector< NameAndType > NameAndTypeVec
Definition: AttributeSet.h:66
std::shared_ptr< Descriptor > DescriptorPtr
Definition: AttributeSet.h:50
Descriptor & descriptor()
Return a reference to this attribute set&#39;s descriptor, which might be shared with other sets...
Definition: AttributeSet.h:103
Inserter & add(const Name &name, const NamePair &type)
Definition: AttributeSet.h:327
Inserter & add(const NameAndTypeVec &other)
Definition: AttributeSet.h:330
std::shared_ptr< AttributeArray > Ptr
Definition: AttributeArray.h:126
NamePair type
Definition: AttributeSet.h:62
std::string Name
Definition: Name.h:19
Ordered collection of uniquely-named attribute arrays.
Definition: AttributeSet.h:39
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
T & value()
Return this metadata&#39;s value.
Definition: Metadata.h:250
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218
Base class for storing attribute data.
Definition: AttributeArray.h:93