OpenVDB  7.1.0
AttributeSet.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
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 <memory>
19 #include <vector>
20 
21 
22 class TestAttributeSet;
23 
24 
25 namespace openvdb {
27 namespace OPENVDB_VERSION_NAME {
28 namespace points {
29 
30 
31 using GroupType = uint8_t;
32 
33 
35 
36 
39 {
40 public:
41  enum { INVALID_POS = std::numeric_limits<size_t>::max() };
42 
43  using Ptr = std::shared_ptr<AttributeSet>;
44  using ConstPtr = std::shared_ptr<const AttributeSet>;
45  using UniquePtr = std::unique_ptr<AttributeSet>;
46 
47  class Descriptor;
48 
49  using DescriptorPtr = std::shared_ptr<Descriptor>;
50  using DescriptorConstPtr = std::shared_ptr<const Descriptor>;
51 
53 
54  struct Util
55  {
57  struct NameAndType {
58  NameAndType(const std::string& n, const NamePair& t, const Index s = 1)
59  : name(n), type(t), stride(s) {}
63  };
64 
65  using NameAndTypeVec = std::vector<NameAndType>;
66  using NameToPosMap = std::map<std::string, size_t>;
67  using GroupIndex = std::pair<size_t, uint8_t>;
68  };
69 
71 
73 
80  AttributeSet(const AttributeSet& attributeSet, Index arrayLength,
81  const AttributeArray::ScopedRegistryLock* lock = nullptr);
82 
90  AttributeSet(const DescriptorPtr& descriptor, Index arrayLength = 1,
91  const AttributeArray::ScopedRegistryLock* lock = nullptr);
92 
95 
97  AttributeSet& operator=(const AttributeSet&) = delete;
98 
100  Descriptor& descriptor() { return *mDescr; }
103  const Descriptor& descriptor() const { return *mDescr; }
105 
108  DescriptorPtr descriptorPtr() const { return mDescr; }
109 
111  size_t size() const { return mAttrs.size(); }
112 
114  size_t memUsage() const;
115 
118  size_t find(const std::string& name) const;
119 
124  size_t replace(const std::string& name, const AttributeArray::Ptr&);
125 
130  size_t replace(size_t pos, const AttributeArray::Ptr&);
131 
133  const AttributeArray* getConst(const std::string& name) const;
136  const AttributeArray* get(const std::string& name) const;
137  AttributeArray* get(const std::string& name);
139 
141  const AttributeArray* getConst(size_t pos) const;
144  const AttributeArray* get(size_t pos) const;
145  AttributeArray* get(size_t pos);
147 
149  size_t groupOffset(const Name& groupName) const;
156  size_t groupOffset(const Util::GroupIndex& index) const;
158 
160  Util::GroupIndex groupIndex(const Name& groupName) const;
163  Util::GroupIndex groupIndex(const size_t offset) const;
164 
166  std::vector<size_t> groupAttributeIndices() const;
167 
169  bool isShared(size_t pos) const;
173  void makeUnique(size_t pos);
174 
177  const NamePair& type,
178  const Index strideOrTotalSize = 1,
179  const bool constantStride = true,
180  const Metadata* defaultValue = nullptr);
181 
184  const NamePair& type,
185  const Index strideOrTotalSize,
186  const bool constantStride,
187  Metadata::Ptr defaultValue);
188 
193  AttributeArray::Ptr appendAttribute(const Descriptor& expected, DescriptorPtr& replacement,
194  const size_t pos, const Index strideOrTotalSize = 1,
195  const bool constantStride = true,
196  const Metadata* defaultValue = nullptr,
197  const AttributeArray::ScopedRegistryLock* lock = nullptr);
198 
200  AttributeArray::Ptr appendAttribute(const Descriptor& expected, DescriptorPtr& replacement,
201  const size_t pos, const Index strideOrTotalSize,
202  const bool constantStride,
204 
213 
222 
236 
239  void dropAttributes(const std::vector<size_t>& pos);
240 
244  void dropAttributes(const std::vector<size_t>& pos,
245  const Descriptor& expected, DescriptorPtr& replacement);
246 
249  void renameAttributes(const Descriptor& expected, const DescriptorPtr& replacement);
250 
253  void reorderAttributes(const DescriptorPtr& replacement);
254 
258  void resetDescriptor(const DescriptorPtr& replacement, const bool allowMismatchingDescriptors = false);
259 
261  void read(std::istream&);
264  void write(std::ostream&, bool outputTransient = false) const;
265 
267  void readDescriptor(std::istream&);
270  void writeDescriptor(std::ostream&, bool outputTransient = false) const;
271 
273  void readMetadata(std::istream&);
277  void writeMetadata(std::ostream&, bool outputTransient = false, bool paged = false) const;
278 
280  void readAttributes(std::istream&);
283  void writeAttributes(std::ostream&, bool outputTransient = false) const;
284 
287  bool operator==(const AttributeSet& other) const;
288  bool operator!=(const AttributeSet& other) const { return !this->operator==(other); }
289 
290 private:
291  using AttrArrayVec = std::vector<AttributeArray::Ptr>;
292 
293  DescriptorPtr mDescr;
294  AttrArrayVec mAttrs;
295 }; // class AttributeSet
296 
298 
299 
301 namespace future {
302  class Container
303  {
304  class Element { };
305  std::vector<std::shared_ptr<Element>> mElements;
306  };
307 }
308 
309 
311 
312 
317 class OPENVDB_API AttributeSet::Descriptor
318 {
319 public:
320  using Ptr = std::shared_ptr<Descriptor>;
321 
326  using ConstIterator = NameToPosMap::const_iterator;
327 
329  struct Inserter {
331  Inserter& add(const NameAndType& nameAndType) {
332  vec.push_back(nameAndType); return *this;
333  }
334  Inserter& add(const Name& name, const NamePair& type) {
335  vec.emplace_back(name, type); return *this;
336  }
337  Inserter& add(const NameAndTypeVec& other) {
338  for (NameAndTypeVec::const_iterator it = other.begin(), itEnd = other.end(); it != itEnd; ++it) {
339  vec.emplace_back(it->name, it->type);
340  }
341  return *this;
342  }
343  };
344 
346 
348 
350  Descriptor(const Descriptor&);
351 
353  static Ptr create(const NamePair&);
354 
356  Ptr duplicateAppend(const Name& name, const NamePair& type) const;
357 
359  Ptr duplicateDrop(const std::vector<size_t>& pos) const;
360 
362  size_t size() const { return mTypes.size(); }
363 
365  size_t count(const NamePair& type) const;
366 
368  size_t memUsage() const;
369 
372  size_t find(const std::string& name) const;
373 
375  size_t rename(const std::string& fromName, const std::string& toName);
376 
378  const Name& valueType(size_t pos) const;
380  const NamePair& type(size_t pos) const;
381 
384  const MetaMap& getMetadata() const;
385 
387  bool hasDefaultValue(const Name& name) const;
389  template<typename ValueType>
390  ValueType getDefaultValue(const Name& name) const
391  {
392  const size_t pos = find(name);
393  if (pos == INVALID_POS) {
394  OPENVDB_THROW(LookupError, "Cannot find attribute name to set default value.")
395  }
396 
397  std::stringstream ss;
398  ss << "default:" << name;
399 
400  auto metadata = mMetadata.getMetadata<TypedMetadata<ValueType>>(ss.str());
401 
402  if (metadata) return metadata->value();
403 
404  return zeroVal<ValueType>();
405  }
407  void setDefaultValue(const Name& name, const Metadata& defaultValue);
408  // Remove the default value if it exists
410  // Prune any default values for which the key is no longer present
412 
414  bool operator==(const Descriptor&) const;
416  bool operator!=(const Descriptor& rhs) const { return !this->operator==(rhs); }
419  bool hasSameAttributes(const Descriptor& rhs) const;
420 
422  const NameToPosMap& map() const { return mNameMap; }
424  const NameToPosMap& groupMap() const { return mGroupMap; }
425 
427  bool hasGroup(const Name& group) const;
432  void setGroup(const Name& group, const size_t offset,
433  const bool checkValidOffset = false);
435  void dropGroup(const Name& group);
437  void clearGroups();
439  size_t renameGroup(const std::string& fromName, const std::string& toName);
441  const Name uniqueGroupName(const Name& name) const;
442 
444  size_t groupOffset(const Name& groupName) const;
451  size_t groupOffset(const GroupIndex& index) const;
453 
455  GroupIndex groupIndex(const Name& groupName) const;
458  GroupIndex groupIndex(const size_t offset) const;
459 
461  static size_t groupBits() { return sizeof(GroupType) * CHAR_BIT; }
462 
465  size_t availableGroups() const;
466 
469  size_t unusedGroups() const;
470 
472  bool canCompactGroups() const;
473 
478 
480  size_t nextUnusedGroupOffset() const;
481 
488  bool requiresGroupMove(Name& sourceName, size_t& sourceOffset, size_t& targetOffset) const;
489 
494  bool groupIndexCollision(const Descriptor& rhs) const;
495 
497  const Name uniqueName(const Name& name) const;
498 
500  static bool validName(const Name& name);
501 
508  static void parseNames( std::vector<std::string>& includeNames,
509  std::vector<std::string>& excludeNames,
510  bool& includeAll,
511  const std::string& nameStr);
512 
515  static void parseNames( std::vector<std::string>& includeNames,
516  std::vector<std::string>& excludeNames,
517  const std::string& nameStr);
518 
520  void write(std::ostream&) const;
522  void read(std::istream&);
523 
524 protected:
526  void appendTo(NameAndTypeVec& attrs) const;
527 
530  static Ptr create(const NameAndTypeVec&, const NameToPosMap&, const MetaMap&);
531 
532  size_t insert(const std::string& name, const NamePair& typeName);
533 
534 private:
535  friend class ::TestAttributeSet;
536 
537  NameToPosMap mNameMap;
538  std::vector<NamePair> mTypes;
539  NameToPosMap mGroupMap;
540  MetaMap mMetadata;
541  // as this change is part of an ABI change, there's no good reason to reduce the reserved
542  // space aside from keeping the memory size of an AttributeSet the same for convenience
543  // (note that this assumes a typical three-pointer implementation for std::vector)
544  future::Container mFutureContainer; // occupies 3 reserved slots
545  int64_t mReserved[5]; // for future use
546 }; // class Descriptor
547 
548 } // namespace points
549 } // namespace OPENVDB_VERSION_NAME
550 } // namespace openvdb
551 
552 #endif // OPENVDB_POINTS_ATTRIBUTE_ARRAY_HAS_BEEN_INCLUDED
openvdb::v7_1::points::AttributeSet::DescriptorPtr
std::shared_ptr< Descriptor > DescriptorPtr
Definition: AttributeSet.h:49
openvdb::v7_1::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:20
openvdb::v7_1::points::AttributeSet::Inserter::add
Inserter & add(const NameAndType &nameAndType)
Definition: AttributeSet.h:331
openvdb::v7_1::points::AttributeSet::reorderAttributes
void reorderAttributes(const DescriptorPtr &replacement)
openvdb::v7_1::points::AttributeSet::Util
Definition: AttributeSet.h:55
openvdb::v7_1::points::AttributeSet::unusedGroupOffset
size_t unusedGroupOffset(size_t hint=std::numeric_limits< size_t >::max()) const
Return a group offset that is not in use.
openvdb::v7_1::points::AttributeSet::removeAttribute
__attribute__((deprecated)) AttributeArray AttributeArray::Ptr removeAttribute(const Name &name)
Remove and return an attribute array by name.
openvdb::v7_1::points::AttributeSet::operator==
bool operator==(const Descriptor &) const
Return true if this descriptor is equal to the given one.
openvdb::v7_1::points::AttributeSet::NameToPosMap
Util::NameToPosMap NameToPosMap
Definition: AttributeSet.h:325
openvdb::v7_1::points::AttributeSet::rename
size_t rename(const std::string &fromName, const std::string &toName)
Rename an attribute array.
openvdb::v7_1::points::AttributeSet::size
size_t size() const
Return the number of attributes in this set.
Definition: AttributeSet.h:111
openvdb::v7_1::points::AttributeSet::AttributeSet
AttributeSet(const DescriptorPtr &descriptor, Index arrayLength=1, const AttributeArray::ScopedRegistryLock *lock=nullptr)
openvdb::v7_1::TypedMetadata
Templated metadata class to hold specific types.
Definition: Metadata.h:122
openvdb::v7_1::points::AttributeSet::availableGroups
size_t availableGroups() const
openvdb::v7_1::points::AttributeSet::AttributeSet
AttributeSet()
openvdb::v7_1::points::AttributeSet::Inserter::add
Inserter & add(const NameAndTypeVec &other)
Definition: AttributeSet.h:337
openvdb::v7_1::points::AttributeSet::hasDefaultValue
bool hasDefaultValue(const Name &name) const
Return true if the attribute has a default value.
openvdb::v7_1::points::AttributeSet::canCompactGroups
bool canCompactGroups() const
Return true if there are sufficient empty slots to allow compacting.
openvdb::v7_1::TypedMetadata::value
T & value()
Return this metadata's value.
Definition: Metadata.h:249
openvdb::v7_1::points::AttributeSet::duplicateDrop
Ptr duplicateDrop(const std::vector< size_t > &pos) const
Create a new descriptor as a duplicate with existing attributes dropped.
openvdb::v7_1::points::AttributeSet::isShared
bool isShared(size_t pos) const
Return true if the attribute array stored at position pos is shared.
openvdb::v7_1::math::operator==
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:471
openvdb::v7_1::Index
Index32 Index
Definition: Types.h:31
openvdb::v7_1::points::future::Container
Definition: AttributeSet.h:303
openvdb::v7_1::points::AttributeSet::get
AttributeArray * get(const std::string &name)
openvdb::v7_1::points::AttributeSet::Util::NameAndType::NameAndType
NameAndType(const std::string &n, const NamePair &t, const Index s=1)
Definition: AttributeSet.h:58
openvdb::v7_1::points::AttributeSet::operator!=
bool operator!=(const AttributeSet &other) const
Definition: AttributeSet.h:288
openvdb::v7_1::Name
std::string Name
Definition: Name.h:17
openvdb::v7_1::points::AttributeSet::Descriptor
Descriptor(const Descriptor &)
Copy constructor.
openvdb::v7_1::points::AttributeSet::unusedGroups
size_t unusedGroups() const
openvdb::v7_1::points::AttributeSet::count
size_t count(const NamePair &type) const
Return the number of attributes with this attribute type.
openvdb::v7_1::points::AttributeSet::dropAttributes
void dropAttributes(const std::vector< size_t > &pos)
openvdb::v7_1::points::AttributeArray::Ptr
std::shared_ptr< AttributeArray > Ptr
Definition: AttributeArray.h:125
openvdb::v7_1::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:108
openvdb::v7_1::Metadata
Base class for storing metadata information in a grid.
Definition: Metadata.h:24
openvdb::v7_1::points::AttributeSet::Util::NameAndType
Attribute and type name pair.
Definition: AttributeSet.h:57
version.h
Library and file format version numbers.
openvdb::v7_1::points::appendAttribute
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: PointAttribute.h:242
openvdb::v7_1::points::AttributeSet::get
AttributeArray * get(size_t pos)
AttributeArray.h
Attribute Array storage templated on type and compression codec.
openvdb::v7_1::points::AttributeSet::duplicateAppend
Ptr duplicateAppend(const Name &name, const NamePair &type) const
Create a new descriptor as a duplicate with a new attribute appended.
openvdb::v7_1::points::AttributeSet::read
void read(std::istream &)
Read the entire set from a stream.
openvdb::v7_1::points::AttributeSet::clearGroups
void clearGroups()
Clear all groups.
openvdb::v7_1::points::AttributeSet::appendTo
void appendTo(NameAndTypeVec &attrs) const
Append to a vector of names and types from this Descriptor in position order.
openvdb::v7_1::points::AttributeSet::operator!=
bool operator!=(const Descriptor &rhs) const
Return true if this descriptor is not equal to the given one.
Definition: AttributeSet.h:416
openvdb::v7_1::points::AttributeSet::Inserter::vec
NameAndTypeVec vec
Definition: AttributeSet.h:330
openvdb::v7_1::points::AttributeSet::pruneUnusedDefaultValues
void pruneUnusedDefaultValues()
openvdb::v7_1::points::AttributeSet::Inserter::add
Inserter & add(const Name &name, const NamePair &type)
Definition: AttributeSet.h:334
openvdb::v7_1::points::AttributeSet::groupAttributeIndices
std::vector< size_t > groupAttributeIndices() const
Return the indices of the attribute arrays which are group attribute arrays.
openvdb::v7_1::points::strideOrTotalSize
const Name const NamePair const Index strideOrTotalSize
Definition: PointAttribute.h:546
openvdb::v7_1::points::AttributeSet::removeDefaultValue
void removeDefaultValue(const Name &name)
openvdb::v7_1::points::AttributeSet::get
const AttributeArray * get(size_t pos) const
openvdb::v7_1::points::AttributeSet::renameGroup
size_t renameGroup(const std::string &fromName, const std::string &toName)
Rename a group.
MetaMap.h
openvdb::v7_1::points::AttributeSet::Descriptor
Descriptor()
OPENVDB_API
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:230
openvdb::v7_1::points::AttributeSet::insert
size_t insert(const std::string &name, const NamePair &typeName)
openvdb::v7_1::points::type
const Name const NamePair & type
Definition: PointAttribute.h:545
openvdb::v7_1::points::AttributeSet::type
const NamePair & type(size_t pos) const
Return the name of the attribute array's type.
openvdb::v7_1::points::AttributeSet::find
size_t find(const std::string &name) const
Return the position of the attribute array whose name is name, or INVALID_POS if no match is found.
openvdb::v7_1::points::AttributeSet::DescriptorConstPtr
std::shared_ptr< const Descriptor > DescriptorConstPtr
Definition: AttributeSet.h:50
openvdb::v7_1::points::AttributeSet::write
void write(std::ostream &, bool outputTransient=false) const
OPENVDB_DEPRECATED
#define OPENVDB_DEPRECATED
Definition: Platform.h:42
openvdb::v7_1::points::AttributeSet::groupIndex
GroupIndex groupIndex(const size_t offset) const
openvdb::v7_1::points::AttributeSet::AttributeSet
AttributeSet(const AttributeSet &attributeSet, Index arrayLength, const AttributeArray::ScopedRegistryLock *lock=nullptr)
openvdb::v7_1::points::AttributeSet::setDefaultValue
void setDefaultValue(const Name &name, const Metadata &defaultValue)
Set a default value for an existing attribute.
openvdb::v7_1::points::AttributeSet::valueType
const Name & valueType(size_t pos) const
Return the name of the attribute array's type.
openvdb::v7_1::points::AttributeSet::operator=
AttributeSet & operator=(const AttributeSet &)=delete
Disallow copy assignment, since it wouldn't be obvious whether the copy is deep or shallow.
openvdb::v7_1::Metadata::Ptr
SharedPtr< Metadata > Ptr
Definition: Metadata.h:26
openvdb::v7_1::points::AttributeSet::parseNames
static void parseNames(std::vector< std::string > &includeNames, std::vector< std::string > &excludeNames, const std::string &nameStr)
Extract each name from nameStr into includeNames, or into excludeNames if the name is prefixed with a...
openvdb::v7_1::LookupError
Definition: Exceptions.h:60
openvdb::v7_1::points::AttributeSet::dropAttributes
void dropAttributes(const std::vector< size_t > &pos, const Descriptor &expected, DescriptorPtr &replacement)
openvdb::v7_1::points::AttributeSet::descriptor
const Descriptor & descriptor() const
Definition: AttributeSet.h:103
openvdb::v7_1::points::AttributeSet::dropGroup
void dropGroup(const Name &group)
Drop any mapping keyed by group name.
openvdb::v7_1::points::constantStride
const Name const NamePair const Index const bool constantStride
Definition: PointAttribute.h:547
openvdb::v7_1::points::AttributeSet::NameAndTypeVec
Util::NameAndTypeVec NameAndTypeVec
Definition: AttributeSet.h:323
openvdb::v7_1::points::AttributeSet::replace
size_t replace(const std::string &name, const AttributeArray::Ptr &)
Replace the attribute array whose name is name.
openvdb::v7_1::points::AttributeSet::groupMap
const NameToPosMap & groupMap() const
Return a reference to the name-to-position group map.
Definition: AttributeSet.h:424
openvdb::v7_1::points::AttributeSet::memUsage
size_t memUsage() const
Return the number of bytes of memory used by this attribute set.
openvdb::v7_1::points::AttributeSet::write
void write(std::ostream &) const
Serialize this descriptor to the given stream.
openvdb::v7_1::points::AttributeSet::operator==
bool operator==(const AttributeSet &other) const
openvdb::v7_1::points::AttributeSet::UniquePtr
std::unique_ptr< AttributeSet > UniquePtr
Definition: AttributeSet.h:45
openvdb::v7_1::points::AttributeSet::AttributeSet
AttributeSet(const AttributeSet &)
Shallow copy constructor, the descriptor and attribute arrays will be shared.
openvdb::v7_1::points::AttributeSet::get
const AttributeArray * get(const std::string &name) const
openvdb::v7_1::points::AttributeSet::Util::NameAndType::name
Name name
Definition: AttributeSet.h:60
openvdb::v7_1::points::AttributeSet::hasSameAttributes
bool hasSameAttributes(const Descriptor &rhs) const
openvdb::v7_1::points::AttributeSet::Util::NameAndTypeVec
std::vector< NameAndType > NameAndTypeVec
Definition: AttributeSet.h:65
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:146
openvdb::v7_1::points::AttributeSet::GroupIndex
Util::GroupIndex GroupIndex
Definition: AttributeSet.h:324
openvdb::v7_1::points::AttributeSet::uniqueGroupName
const Name uniqueGroupName(const Name &name) const
Return a unique name for a group based on given name.
openvdb::v7_1::points::AttributeSet::replace
size_t replace(size_t pos, const AttributeArray::Ptr &)
Replace the attribute array stored at position pos in this container.
openvdb::v7_1::points::AttributeSet::appendAttribute
__attribute__((deprecated)) AttributeArray AttributeArray::Ptr appendAttribute(const Descriptor &expected, DescriptorPtr &replacement, const size_t pos, const Index strideOrTotalSize=1, const bool constantStride=true, const Metadata *defaultValue=nullptr, const AttributeArray::ScopedRegistryLock *lock=nullptr)
openvdb::v7_1::points::AttributeSet::readMetadata
void readMetadata(std::istream &)
This will read the attribute metadata from a stream.
openvdb::v7_1::points::AttributeSet::setGroup
void setGroup(const Name &group, const size_t offset, const bool checkValidOffset=false)
Define a group name to offset mapping.
openvdb::v7_1::points::AttributeSet::Util::NameAndType::type
NamePair type
Definition: AttributeSet.h:61
openvdb::v7_1::points::AttributeArray
Base class for storing attribute data.
Definition: AttributeArray.h:93
openvdb::v7_1::points::AttributeSet
Ordered collection of uniquely-named attribute arrays.
Definition: AttributeSet.h:39
openvdb::v7_1::points::AttributeSet::writeMetadata
void writeMetadata(std::ostream &, bool outputTransient=false, bool paged=false) const
openvdb::v7_1::points::AttributeSet::renameAttributes
void renameAttributes(const Descriptor &expected, const DescriptorPtr &replacement)
openvdb::v7_1::points::AttributeSet::uniqueName
const Name uniqueName(const Name &name) const
Return a unique name for an attribute array based on given name.
openvdb::v7_1::points::AttributeSet::ConstPtr
std::shared_ptr< const AttributeSet > ConstPtr
Definition: AttributeSet.h:44
openvdb::v7_1::points::AttributeSet::readDescriptor
void readDescriptor(std::istream &)
This will read the attribute descriptor from a stream.
openvdb::v7_1::points::AttributeSet::groupOffset
size_t groupOffset(const Util::GroupIndex &index) const
openvdb::v7_1::points::AttributeSet::Inserter
Utility method to construct a NameAndType sequence.
Definition: AttributeSet.h:329
openvdb::v7_1::points::AttributeSet::Util::NameToPosMap
std::map< std::string, size_t > NameToPosMap
Definition: AttributeSet.h:66
openvdb::v7_1::points::AttributeSet::groupIndex
GroupIndex groupIndex(const Name &groupName) const
Return the group index from the name of the group.
openvdb::v7_1::points::AttributeSet::hasGroup
bool hasGroup(const Name &group) const
Return true if group exists.
openvdb::v7_1::points::name
const Name & name
Definition: PointAttribute.h:544
openvdb::v7_1::points::AttributeSet::appendAttribute
AttributeArray::Ptr appendAttribute(const Name &name, const NamePair &type, const Index strideOrTotalSize=1, const bool constantStride=true, const Metadata *defaultValue=nullptr)
Append attribute attribute (simple method)
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:94
openvdb::v7_1::points::AttributeSet::map
const NameToPosMap & map() const
Return a reference to the name-to-position map.
Definition: AttributeSet.h:422
openvdb::v7_1::points::AttributeSet::getMetadata
const MetaMap & getMetadata() const
openvdb::v7_1::points::AttributeSet::groupBits
static size_t groupBits()
Return number of bits occupied by a group attribute array.
Definition: AttributeSet.h:461
openvdb::v7_1::points::AttributeSet::writeDescriptor
void writeDescriptor(std::ostream &, bool outputTransient=false) const
openvdb::v7_1::points::AttributeSet::Util::GroupIndex
std::pair< size_t, uint8_t > GroupIndex
Definition: AttributeSet.h:67
openvdb::v7_1::points::AttributeArray::ScopedRegistryLock
Definition: AttributeArray.h:119
openvdb::v7_1::points::AttributeSet::groupIndex
Util::GroupIndex groupIndex(const Name &groupName) const
Return the group index from the name of the group.
openvdb::v7_1::points::AttributeSet::parseNames
static void parseNames(std::vector< std::string > &includeNames, std::vector< std::string > &excludeNames, bool &includeAll, const std::string &nameStr)
Extract each name from nameStr into includeNames, or into excludeNames if the name is prefixed with a...
openvdb::v7_1::points::AttributeSet::groupOffset
size_t groupOffset(const GroupIndex &index) const
openvdb::v7_1::points::AttributeSet::resetDescriptor
void resetDescriptor(const DescriptorPtr &replacement, const bool allowMismatchingDescriptors=false)
openvdb::v7_1::NamePair
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:39
openvdb::v7_1::points::AttributeSet::groupIndex
Util::GroupIndex groupIndex(const size_t offset) const
openvdb::v7_1::points::AttributeSet::groupIndexCollision
bool groupIndexCollision(const Descriptor &rhs) const
Test if there are any group names shared by both descriptors which have a different index.
openvdb::v7_1::points::AttributeSet::getMetadata
MetaMap & getMetadata()
Retrieve metadata map.
openvdb::v7_1::points::AttributeSet::create
static Ptr create(const NamePair &)
Create a new descriptor from a position attribute type and assumes "P" (for convenience).
openvdb
Definition: Exceptions.h:13
openvdb::v7_1::points::GroupType
uint8_t GroupType
Definition: AttributeSet.h:31
openvdb::v7_1::points::AttributeSet::create
static Ptr create(const NameAndTypeVec &, const NameToPosMap &, const MetaMap &)
openvdb::v7_1::points::AttributeSet::removeAttribute
AttributeArray::Ptr removeAttribute(const size_t pos)
Remove and return an attribute array by index.
openvdb::v7_1::points::AttributeSet::readAttributes
void readAttributes(std::istream &)
This will read the attribute data from a stream.
openvdb::v7_1::points::AttributeSet::requiresGroupMove
bool requiresGroupMove(Name &sourceName, size_t &sourceOffset, size_t &targetOffset) const
Determine if a move is required to efficiently compact the data and store the source name,...
openvdb::v7_1::points::AttributeSet::getDefaultValue
ValueType getDefaultValue(const Name &name) const
Get a default value for an existing attribute.
Definition: AttributeSet.h:390
openvdb::v7_1::points::AttributeSet::ConstIterator
NameToPosMap::const_iterator ConstIterator
Definition: AttributeSet.h:326
openvdb::v7_1::points::AttributeSet::validName
static bool validName(const Name &name)
Return true if the name is valid.
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:82
openvdb::v7_1::points::AttributeSet::writeAttributes
void writeAttributes(std::ostream &, bool outputTransient=false) const
openvdb::v7_1::points::AttributeSet::Ptr
std::shared_ptr< AttributeSet > Ptr
Definition: AttributeSet.h:43
openvdb::v7_1::points::AttributeSet::removeAttributeUnsafe
AttributeArray::Ptr removeAttributeUnsafe(const size_t pos)
Remove and return an attribute array by index (unsafe method)
openvdb::v7_1::tools::composite::max
const std::enable_if<!VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:106
openvdb::v7_1::points::AttributeSet::Util::NameAndType::stride
Index stride
Definition: AttributeSet.h:62
openvdb::v7_1::points::AttributeSet::makeUnique
void makeUnique(size_t pos)
If the attribute array stored at position pos is shared, replace the array with a deep copy of itself...