10 #ifndef OPENVDB_POINTS_ATTRIBUTE_SET_HAS_BEEN_INCLUDED 11 #define OPENVDB_POINTS_ATTRIBUTE_SET_HAS_BEEN_INCLUDED 14 #include <openvdb/version.h> 22 class TestAttributeSet;
43 using Ptr = std::shared_ptr<AttributeSet>;
44 using ConstPtr = std::shared_ptr<const AttributeSet>;
59 : name(n), type(t), stride(s) {}
111 size_t size()
const {
return mAttrs.size(); }
116 #if OPENVDB_ABI_VERSION_NUMBER >= 10 125 size_t find(
const std::string& name)
const;
162 size_t groupOffset(
const Name& groupName)
const;
173 std::vector<size_t> groupAttributeIndices()
const;
176 bool isShared(
size_t pos)
const;
180 void makeUnique(
size_t pos);
185 const Index strideOrTotalSize = 1,
186 const bool constantStride =
true,
187 const Metadata* defaultValue =
nullptr);
194 const size_t pos,
const Index strideOrTotalSize = 1,
195 const bool constantStride =
true,
196 const Metadata* defaultValue =
nullptr,
252 void resetDescriptor(
const DescriptorPtr& replacement,
const bool allowMismatchingDescriptors =
false);
255 void read(std::istream&);
258 void write(std::ostream&,
bool outputTransient =
false)
const;
261 void readDescriptor(std::istream&);
264 void writeDescriptor(std::ostream&,
bool outputTransient =
false)
const;
267 void readMetadata(std::istream&);
271 void writeMetadata(std::ostream&,
bool outputTransient =
false,
bool paged =
false)
const;
274 void readAttributes(std::istream&);
277 void writeAttributes(std::ostream&,
bool outputTransient =
false)
const;
285 using AttrArrayVec = std::vector<AttributeArray::Ptr>;
299 std::vector<std::shared_ptr<Element>> mElements;
314 using Ptr = std::shared_ptr<Descriptor>;
326 vec.push_back(nameAndType);
return *
this;
329 vec.emplace_back(name, type);
return *
this;
332 for (NameAndTypeVec::const_iterator it = other.begin(), itEnd = other.end(); it != itEnd; ++it) {
333 vec.emplace_back(it->name, it->type);
344 Descriptor(
const Descriptor&);
353 Ptr duplicateDrop(
const std::vector<size_t>& pos)
const;
356 size_t size()
const {
return mTypes.size(); }
359 size_t count(
const NamePair& type)
const;
366 size_t find(
const std::string& name)
const;
369 size_t rename(
const std::string& fromName,
const std::string& toName);
372 const Name& valueType(
size_t pos)
const;
374 const NamePair& type(
size_t pos)
const;
378 const MetaMap& getMetadata()
const;
381 bool hasDefaultValue(
const Name& name)
const;
383 template<
typename ValueType>
386 const size_t pos = find(name);
387 if (pos == INVALID_POS) {
391 std::stringstream ss;
392 ss <<
"default:" << name;
396 if (metadata)
return metadata->
value();
398 return zeroVal<ValueType>();
401 void setDefaultValue(
const Name& name,
const Metadata& defaultValue);
403 void removeDefaultValue(
const Name& name);
405 void pruneUnusedDefaultValues();
413 bool hasSameAttributes(
const Descriptor& rhs)
const;
421 bool hasGroup(
const Name& group)
const;
427 const bool checkValidOffset =
false);
433 size_t renameGroup(
const std::string& fromName,
const std::string& toName);
435 const Name uniqueGroupName(
const Name& name)
const;
444 size_t groupOffset(
const Name& groupName)
const;
445 size_t groupOffset(
const GroupIndex& index)
const;
452 GroupIndex groupIndex(
const size_t offset)
const;
459 size_t availableGroups()
const;
463 size_t unusedGroups()
const;
466 bool canCompactGroups()
const;
479 bool requiresGroupMove(
Name& sourceName,
size_t& sourceOffset,
size_t& targetOffset)
const;
485 bool groupIndexCollision(
const Descriptor& rhs)
const;
488 const Name uniqueName(
const Name& name)
const;
491 static bool validName(
const Name& name);
499 static void parseNames( std::vector<std::string>& includeNames,
500 std::vector<std::string>& excludeNames,
502 const std::string& nameStr);
506 static void parseNames( std::vector<std::string>& includeNames,
507 std::vector<std::string>& excludeNames,
508 const std::string& nameStr);
511 void write(std::ostream&)
const;
513 void read(std::istream&);
523 size_t insert(
const std::string& name,
const NamePair& typeName);
526 friend class ::TestAttributeSet;
529 std::vector<NamePair> mTypes;
536 int64_t mReserved[5];
543 #endif // OPENVDB_POINTS_ATTRIBUTE_ARRAY_HAS_BEEN_INCLUDED Index32 Index
Definition: Types.h:54
Inserter & add(const NameAndType &nameAndType)
Definition: AttributeSet.h:325
Util::GroupIndex GroupIndex
Definition: AttributeSet.h:318
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:74
NameAndType(const std::string &n, const NamePair &t, const Index s=1)
Definition: AttributeSet.h:58
ValueType getDefaultValue(const Name &name) const
Get a default value for an existing attribute.
Definition: AttributeSet.h:384
const Descriptor & descriptor() const
Return a reference to this attribute set's descriptor, which might be shared with other sets...
Definition: AttributeSet.h:103
Index stride
Definition: AttributeSet.h:62
Attribute Array storage templated on type and compression codec.
bool operator!=(const AttributeSet &other) const
Definition: AttributeSet.h:282
Attribute and type name pair.
Definition: AttributeSet.h:57
Definition: AttributeSet.h:54
size_t size() const
Return the number of attributes in this set.
Definition: AttributeSet.h:111
static fileSize_t write(std::ostream &os, const GridHandle< BufferT > &handle, Codec codec)
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:245
DescriptorPtr descriptorPtr() const
Return a pointer to this attribute set's descriptor, which might be shared with other sets...
Definition: AttributeSet.h:108
static void read(std::istream &is, GridHandle< BufferT > &handle, Codec codec)
void renameAttributes(PointDataTreeT &tree, const std::vector< Name > &oldNames, const std::vector< Name > &newNames)
Rename attributes in a VDB tree.
Definition: PointAttribute.h:468
const NameToPosMap & map() const
Return a reference to the name-to-position map.
Definition: AttributeSet.h:416
NameToPosMap::const_iterator ConstIterator
Definition: AttributeSet.h:320
std::shared_ptr< const Descriptor > DescriptorConstPtr
Definition: AttributeSet.h:50
Util::NameToPosMap NameToPosMap
Definition: AttributeSet.h:319
void replace(std::string &str, const std::string &oldStr, const std::string &newStr)
Definition: util.h:65
void dropAttributes(PointDataTreeT &tree, const std::vector< size_t > &indices)
Drops attributes from the VDB tree.
Definition: PointAttribute.h:380
std::shared_ptr< AttributeArray > Ptr
Definition: AttributeArray.h:125
Definition: Exceptions.h:13
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: PointGroup.h:548
NameAndTypeVec vec
Definition: AttributeSet.h:324
bool operator!=(const Descriptor &rhs) const
Return true if this descriptor is not equal to the given one.
Definition: AttributeSet.h:410
std::map< std::string, size_t > NameToPosMap
Definition: AttributeSet.h:66
Utility method to construct a NameAndType sequence.
Definition: AttributeSet.h:323
Definition: Exceptions.h:60
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:473
std::shared_ptr< const AttributeSet > ConstPtr
Definition: AttributeSet.h:44
std::unique_ptr< AttributeSet > UniquePtr
Definition: AttributeSet.h:45
std::shared_ptr< AttributeSet > Ptr
Definition: AttributeSet.h:43
Util::NameAndTypeVec NameAndTypeVec
Definition: AttributeSet.h:317
const NameToPosMap & groupMap() const
Return a reference to the name-to-position group map.
Definition: AttributeSet.h:418
static size_t groupBits()
Return number of bits occupied by a group attribute array.
Definition: AttributeSet.h:455
Base class for storing attribute data.
Definition: AttributeArray.h:92
std::pair< Name, Name > NamePair
Definition: AttributeArray.h:39
std::pair< size_t, uint8_t > GroupIndex
Definition: AttributeSet.h:67
std::vector< NameAndType > NameAndTypeVec
Definition: AttributeSet.h:65
Descriptor & descriptor()
Return a reference to this attribute set's descriptor, which might be shared with other sets...
Definition: AttributeSet.h:102
Inserter & add(const Name &name, const NamePair &type)
Definition: AttributeSet.h:328
Inserter & add(const NameAndTypeVec &other)
Definition: AttributeSet.h:331
void dropGroup(PointDataTreeT &tree, const Name &group, const bool compact=true)
Drops an existing group from the VDB tree.
Definition: PointGroup.h:406
Definition: AttributeArray.h:118
NamePair type
Definition: AttributeSet.h:61
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h.in:121
Definition: AttributeSet.h:296
Name name
Definition: AttributeSet.h:60
std::string Name
Definition: Name.h:17
Ordered collection of uniquely-named attribute arrays.
Definition: AttributeSet.h:38
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:212
std::shared_ptr< Descriptor > DescriptorPtr
Definition: AttributeSet.h:49
uint8_t GroupType
Definition: AttributeSet.h:31