Go to the documentation of this file.
37 #ifndef OPENVDB_POINTS_ATTRIBUTE_SET_HAS_BEEN_INCLUDED
38 #define OPENVDB_POINTS_ATTRIBUTE_SET_HAS_BEEN_INCLUDED
49 class TestAttributeSet;
67 using Ptr = std::shared_ptr<AttributeSet>;
68 using ConstPtr = std::shared_ptr<const AttributeSet>;
82 : name(n), type(t), stride(s) {}
123 Descriptor& descriptor() {
return *mDescr; }
134 size_t size()
const {
return mAttrs.size(); }
137 size_t memUsage()
const;
141 size_t find(
const std::string& name)
const;
172 size_t groupOffset(
const Name& groupName)
const;
179 size_t groupOffset(
const Util::GroupIndex& index)
const;
183 Util::GroupIndex groupIndex(
const Name& groupName)
const;
186 Util::GroupIndex groupIndex(
const size_t offset)
const;
189 bool isShared(
size_t pos)
const;
193 void makeUnique(
size_t pos);
198 const Index strideOrTotalSize = 1,
199 const bool constantStride =
true,
207 const size_t pos,
const Index strideOrTotalSize = 1,
208 const bool constantStride =
true,
219 const Descriptor& expected, DescriptorPtr& replacement);
223 void renameAttributes(
const Descriptor& expected,
const DescriptorPtr& replacement);
227 void reorderAttributes(
const DescriptorPtr& replacement);
232 void resetDescriptor(
const DescriptorPtr& replacement,
const bool allowMismatchingDescriptors =
false);
235 void read(std::istream&);
238 void write(std::ostream&,
bool outputTransient =
false)
const;
241 void readDescriptor(std::istream&);
244 void writeDescriptor(std::ostream&,
bool outputTransient =
false)
const;
247 void readMetadata(std::istream&);
251 void writeMetadata(std::ostream&,
bool outputTransient =
false,
bool paged =
false)
const;
254 void readAttributes(std::istream&);
257 void writeAttributes(std::ostream&,
bool outputTransient =
false)
const;
265 using AttrArrayVec = std::vector<AttributeArray::Ptr>;
267 DescriptorPtr mDescr;
275 #if OPENVDB_ABI_VERSION_NUMBER >= 5
280 std::vector<std::shared_ptr<Element>> mElements;
296 using Ptr = std::shared_ptr<Descriptor>;
308 vec.push_back(nameAndType);
return *
this;
311 vec.emplace_back(name, type);
return *
this;
314 for (NameAndTypeVec::const_iterator it = other.begin(), itEnd = other.end(); it != itEnd; ++it) {
315 vec.emplace_back(it->name, it->type);
326 Descriptor(
const Descriptor&);
332 Ptr duplicateAppend(
const Name& name,
const NamePair& type)
const;
335 Ptr duplicateDrop(
const std::vector<size_t>& pos)
const;
338 size_t size()
const {
return mTypes.size(); }
341 size_t count(
const NamePair& type)
const;
344 size_t memUsage()
const;
348 size_t find(
const std::string& name)
const;
351 size_t rename(
const std::string& fromName,
const std::string& toName);
354 const Name& valueType(
size_t pos)
const;
356 const NamePair& type(
size_t pos)
const;
360 const MetaMap& getMetadata()
const;
363 bool hasDefaultValue(
const Name& name)
const;
365 template<
typename ValueType>
368 const size_t pos = find(name);
369 if (pos == INVALID_POS) {
373 std::stringstream ss;
374 ss <<
"default:" << name;
378 if (metadata)
return metadata->
value();
380 return zeroVal<ValueType>();
383 void setDefaultValue(
const Name& name,
const Metadata& defaultValue);
385 void removeDefaultValue(
const Name& name);
387 void pruneUnusedDefaultValues();
395 bool hasSameAttributes(
const Descriptor& rhs)
const;
403 bool hasGroup(
const Name& group)
const;
411 size_t renameGroup(
const std::string& fromName,
const std::string& toName);
413 const Name uniqueGroupName(
const Name& name)
const;
416 size_t groupOffset(
const Name& groupName)
const;
423 size_t groupOffset(
const GroupIndex& index)
const;
427 GroupIndex groupIndex(
const Name& groupName)
const;
430 GroupIndex groupIndex(
const size_t offset)
const;
433 const Name uniqueName(
const Name& name)
const;
436 static bool validName(
const Name& name);
444 static void parseNames( std::vector<std::string>& includeNames,
445 std::vector<std::string>& excludeNames,
447 const std::string& nameStr);
451 static void parseNames( std::vector<std::string>& includeNames,
452 std::vector<std::string>& excludeNames,
453 const std::string& nameStr);
456 void write(std::ostream&)
const;
458 void read(std::istream&);
462 void appendTo(NameAndTypeVec& attrs)
const;
466 static Ptr create(
const NameAndTypeVec&,
const NameToPosMap&,
const MetaMap&);
468 size_t insert(
const std::string& name,
const NamePair& typeName);
471 friend class ::TestAttributeSet;
474 std::vector<NamePair> mTypes;
477 #if OPENVDB_ABI_VERSION_NUMBER >= 5
482 int64_t mReserved[5];
484 int64_t mReserved[8];
492 #endif // OPENVDB_POINTS_ATTRIBUTE_ARRAY_HAS_BEEN_INCLUDED
bool operator!=(const AttributeSet &other) const
Definition: AttributeSet.h:262
Index stride
Definition: AttributeSet.h:85
std::string Name
Definition: Name.h:44
Definition: AttributeSet.h:77
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)
Definition: PointAttribute.h:269
Inserter & add(const Name &name, const NamePair &type)
Definition: AttributeSet.h:310
const Descriptor & descriptor() const
Definition: AttributeSet.h:126
std::shared_ptr< const Descriptor > DescriptorConstPtr
Definition: AttributeSet.h:73
Inserter & add(const NameAndType &nameAndType)
Definition: AttributeSet.h:307
Ordered collection of uniquely-named attribute arrays.
Definition: AttributeSet.h:62
ValueType getDefaultValue(const Name &name) const
Get a default value for an existing attribute.
Definition: AttributeSet.h:366
NameToPosMap::const_iterator ConstIterator
Definition: AttributeSet.h:302
Util::GroupIndex GroupIndex
Definition: AttributeSet.h:300
Library and file format version numbers.
Index32 Index
Definition: Types.h:61
Attribute Array storage templated on type and compression codec.
size_t size() const
Return the number of attributes in this set.
Definition: AttributeSet.h:134
void dropGroup(PointDataTree &tree, const Name &group, const bool compact=true)
Drops an existing group from the VDB tree.
Definition: PointGroup.h:546
NameAndTypeVec vec
Definition: AttributeSet.h:306
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:65
Definition: AttributeArray.h:145
Definition: Exceptions.h:87
std::vector< NameAndType > NameAndTypeVec
Definition: AttributeSet.h:88
const NameToPosMap & map() const
Return a reference to the name-to-position map.
Definition: AttributeSet.h:398
Name name
Definition: AttributeSet.h:83
NameAndType(const std::string &n, const NamePair &t, const Index s=1)
Definition: AttributeSet.h:81
void setGroup(PointDataTree &tree, const PointIndexTree &indexTree, const std::vector< short > &membership, const Name &group, const bool remove=false)
Sets group membership from a PointIndexTree-ordered vector.
Definition: PointGroup.h:692
std::shared_ptr< const AttributeSet > ConstPtr
Definition: AttributeSet.h:68
void renameAttributes(PointDataTreeT &tree, const std::vector< Name > &oldNames, const std::vector< Name > &newNames)
Rename attributes in a VDB tree.
Definition: PointAttribute.h:485
Attribute and type name pair.
Definition: AttributeSet.h:80
bool operator!=(const Descriptor &rhs) const
Return true if this descriptor is not equal to the given one.
Definition: AttributeSet.h:392
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:180
NamePair type
Definition: AttributeSet.h:84
Base class for storing attribute data.
Definition: AttributeArray.h:118
std::shared_ptr< Descriptor > DescriptorPtr
Definition: AttributeSet.h:72
Utility method to construct a NameAndType sequence.
Definition: AttributeSet.h:305
std::shared_ptr< AttributeSet > Ptr
Definition: AttributeSet.h:67
const NameToPosMap & groupMap() const
Return a reference to the name-to-position group map.
Definition: AttributeSet.h:400
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:128
std::map< std::string, size_t > NameToPosMap
Definition: AttributeSet.h:89
std::shared_ptr< AttributeArray > Ptr
Definition: AttributeArray.h:152
Util::NameAndTypeVec NameAndTypeVec
Definition: AttributeSet.h:299
Util::NameToPosMap NameToPosMap
Definition: AttributeSet.h:301
std::pair< size_t, uint8_t > GroupIndex
Definition: AttributeSet.h:90
Definition: AttributeSet.h:277
Definition: Exceptions.h:40
Inserter & add(const NameAndTypeVec &other)
Definition: AttributeSet.h:313
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:498
DescriptorPtr descriptorPtr() const
Return a pointer to this attribute set's descriptor, which might be shared with other sets.
Definition: AttributeSet.h:131
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:109
void dropAttributes(PointDataTreeT &tree, const std::vector< size_t > &indices)
Drops attributes from the VDB tree.
Definition: PointAttribute.h:397