10 #ifndef OPENVDB_POINTS_ATTRIBUTE_SET_HAS_BEEN_INCLUDED 11 #define OPENVDB_POINTS_ATTRIBUTE_SET_HAS_BEEN_INCLUDED 14 #include <openvdb/version.h> 23 class TestAttributeSet;
44 using Ptr = std::shared_ptr<AttributeSet>;
45 using ConstPtr = std::shared_ptr<const AttributeSet>;
60 : name(n), type(t), stride(s) {}
112 size_t size()
const {
return mAttrs.size(); }
124 size_t find(
const std::string& name)
const;
161 size_t groupOffset(
const Name& groupName)
const;
172 std::vector<size_t> groupAttributeIndices()
const;
175 bool isShared(
size_t pos)
const;
179 void makeUnique(
size_t pos);
184 const Index strideOrTotalSize = 1,
185 const bool constantStride =
true,
186 const Metadata* defaultValue =
nullptr);
193 const size_t pos,
const Index strideOrTotalSize = 1,
194 const bool constantStride =
true,
195 const Metadata* defaultValue =
nullptr,
251 void resetDescriptor(
const DescriptorPtr& replacement,
const bool allowMismatchingDescriptors =
false);
254 void read(std::istream&);
257 void write(std::ostream&,
bool outputTransient =
false)
const;
260 void readDescriptor(std::istream&);
263 void writeDescriptor(std::ostream&,
bool outputTransient =
false)
const;
266 void readMetadata(std::istream&);
270 void writeMetadata(std::ostream&,
bool outputTransient =
false,
bool paged =
false)
const;
273 void readAttributes(std::istream&);
276 void writeAttributes(std::ostream&,
bool outputTransient =
false)
const;
284 using AttrArrayVec = std::vector<AttributeArray::Ptr>;
298 std::vector<std::shared_ptr<Element>> mElements;
313 using Ptr = std::shared_ptr<Descriptor>;
325 vec.push_back(nameAndType);
return *
this;
328 vec.emplace_back(name, type);
return *
this;
331 for (NameAndTypeVec::const_iterator it = other.begin(), itEnd = other.end(); it != itEnd; ++it) {
332 vec.emplace_back(it->name, it->type);
343 Descriptor(
const Descriptor&);
352 Ptr duplicateDrop(
const std::vector<size_t>& pos)
const;
355 size_t size()
const {
return mTypes.size(); }
358 size_t count(
const NamePair& type)
const;
365 size_t find(
const std::string& name)
const;
368 size_t rename(
const std::string& fromName,
const std::string& toName);
371 const Name& valueType(
size_t pos)
const;
373 const NamePair& type(
size_t pos)
const;
377 const MetaMap& getMetadata()
const;
380 bool hasDefaultValue(
const Name& name)
const;
382 template<
typename ValueType>
385 const size_t pos = find(name);
386 if (pos == INVALID_POS) {
390 std::stringstream ss;
391 ss <<
"default:" << name;
395 if (metadata)
return metadata->
value();
397 return zeroVal<ValueType>();
400 void setDefaultValue(
const Name& name,
const Metadata& defaultValue);
402 void removeDefaultValue(
const Name& name);
404 void pruneUnusedDefaultValues();
412 bool hasSameAttributes(
const Descriptor& rhs)
const;
420 bool hasGroup(
const Name& group)
const;
426 const bool checkValidOffset =
false);
432 size_t renameGroup(
const std::string& fromName,
const std::string& toName);
434 const Name uniqueGroupName(
const Name& name)
const;
443 size_t groupOffset(
const Name& groupName)
const;
444 size_t groupOffset(
const GroupIndex& index)
const;
451 GroupIndex groupIndex(
const size_t offset)
const;
458 size_t availableGroups()
const;
462 size_t unusedGroups()
const;
465 bool canCompactGroups()
const;
478 bool requiresGroupMove(
Name& sourceName,
size_t& sourceOffset,
size_t& targetOffset)
const;
484 bool groupIndexCollision(
const Descriptor& rhs)
const;
487 const Name uniqueName(
const Name& name)
const;
490 static bool validName(
const Name& name);
498 static void parseNames( std::vector<std::string>& includeNames,
499 std::vector<std::string>& excludeNames,
501 const std::string& nameStr);
505 static void parseNames( std::vector<std::string>& includeNames,
506 std::vector<std::string>& excludeNames,
507 const std::string& nameStr);
510 void write(std::ostream&)
const;
512 void read(std::istream&);
522 size_t insert(
const std::string& name,
const NamePair& typeName);
525 friend class ::TestAttributeSet;
528 std::vector<NamePair> mTypes;
535 int64_t mReserved[5];
542 #endif // OPENVDB_POINTS_ATTRIBUTE_ARRAY_HAS_BEEN_INCLUDED Util::GroupIndex GroupIndex
Definition: AttributeSet.h:317
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
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's descriptor, which might be shared with other sets...
Definition: AttributeSet.h:104
AttributePositionLabel
Definition: AttributeSet.h:42
Definition: AttributeSet.h:55
Index stride
Definition: AttributeSet.h:63
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
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
bool operator==(const Vec3< T0 > &v0, const Vec3< T1 > &v1)
Equality operator, does exact floating point comparisons.
Definition: Vec3.h:474
size_t size() const
Return the number of attributes in this set.
Definition: AttributeSet.h:112
std::shared_ptr< const Descriptor > DescriptorConstPtr
Definition: AttributeSet.h:51
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'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
Definition: AttributeArray.h:119
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'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
Name name
Definition: AttributeSet.h:61
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h.in:218
Base class for storing attribute data.
Definition: AttributeArray.h:93