10 #ifndef OPENVDB_POINTS_ATTRIBUTE_SET_HAS_BEEN_INCLUDED
11 #define OPENVDB_POINTS_ATTRIBUTE_SET_HAS_BEEN_INCLUDED
22 class TestAttributeSet;
43 using Ptr = std::shared_ptr<AttributeSet>;
44 using ConstPtr = std::shared_ptr<const AttributeSet>;
111 size_t size()
const {
return mAttrs.size(); }
114 size_t memUsage()
const;
116 #if OPENVDB_ABI_VERSION_NUMBER >= 10
162 size_t groupOffset(
const Name& groupName)
const;
163 size_t groupOffset(
const Util::GroupIndex&
index)
const;
167 Util::GroupIndex groupIndex(
const Name& groupName)
const;
170 Util::GroupIndex groupIndex(
const size_t offset)
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,
239 const Descriptor& expected, DescriptorPtr& replacement);
243 void renameAttributes(
const Descriptor& expected,
const DescriptorPtr& replacement);
247 void reorderAttributes(
const DescriptorPtr& replacement);
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>;
287 DescriptorPtr mDescr;
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(); }
362 size_t memUsage()
const;
372 const Name& valueType(
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) {
388 OPENVDB_THROW(LookupError,
"Cannot find attribute name to set default value.")
391 std::stringstream ss;
392 ss <<
"default:" << name;
396 if (metadata)
return metadata->
value();
398 return zeroVal<ValueType>();
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);
444 size_t groupOffset(
const Name& groupName)
const;
445 size_t groupOffset(
const GroupIndex&
index)
const;
449 GroupIndex groupIndex(
const Name& groupName)
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;
491 static bool validName(
const Name&
name);
499 static void parseNames( std::vector<std::string>& includeNames,
500 std::vector<std::string>& excludeNames,
506 static void parseNames( std::vector<std::string>& includeNames,
507 std::vector<std::string>& excludeNames,
511 void write(std::ostream&)
const;
513 void read(std::istream&);
517 void appendTo(NameAndTypeVec& attrs)
const;
521 static Ptr create(
const NameAndTypeVec&,
const NameToPosMap&,
const MetaMap&);
526 friend class ::TestAttributeSet;
529 std::vector<NamePair> mTypes;
536 int64_t mReserved[5];
543 #endif // OPENVDB_POINTS_ATTRIBUTE_ARRAY_HAS_BEEN_INCLUDED
Util::NameAndTypeVec NameAndTypeVec
ValueType getDefaultValue(const Name &name) const
Get a default value for an existing attribute.
Descriptor & descriptor()
Return a reference to this attribute set's descriptor, which might be shared with other sets...
std::shared_ptr< Descriptor > DescriptorPtr
Attribute and type name pair.
const Descriptor & descriptor() const
Return a reference to this attribute set's descriptor, which might be shared with other sets...
GLdouble GLdouble GLint GLint const GLdouble * points
Inserter & add(const NameAndTypeVec &other)
bool operator!=(const Descriptor &rhs) const
Return true if this descriptor is not equal to the given one.
GLsizei const GLchar *const * string
Util::NameToPosMap NameToPosMap
std::shared_ptr< AttributeSet > Ptr
#define OPENVDB_USE_VERSION_NAMESPACE
std::shared_ptr< const AttributeSet > ConstPtr
bool operator!=(const AttributeSet &other) const
OIIO_FORCEINLINE vbool4 insert(const vbool4 &a, bool val)
Helper: substitute val for a[i].
Utility method to construct a NameAndType sequence.
void renameAttributes(PointDataTreeT &tree, const std::vector< Name > &oldNames, const std::vector< Name > &newNames)
Rename attributes in a VDB tree.
void dropGroup(PointDataTreeT &tree, const Name &group, const bool compact)
Drops an existing group from the VDB tree.
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
void appendAttribute(PointDataTreeT &tree, const Name &name, const NamePair &type, const Index strideOrTotalSize, const bool constantStride, const Metadata *defaultValue, const bool hidden, const bool transient)
Appends a new attribute to the VDB tree (this method does not require a templated AttributeType) ...
Base class for storing attribute data.
std::string OIIO_UTIL_API replace(string_view str, string_view pattern, string_view replacement, bool global=false)
GLint GLenum GLboolean GLsizei stride
std::shared_ptr< const Descriptor > DescriptorConstPtr
std::shared_ptr< AttributeArray > Ptr
void dropAttributes(PointDataTreeT &tree, const std::vector< size_t > &indices)
Drops attributes from the VDB tree.
const NameToPosMap & groupMap() const
Return a reference to the name-to-position group map.
GLuint const GLchar * name
NameAndType(const std::string &n, const NamePair &t, const Index s=1)
std::pair< Name, Name > NamePair
std::map< std::string, size_t > NameToPosMap
Inserter & add(const NameAndType &nameAndType)
Element(ElementPtr parent, const string &category, const string &name)
void setGroup(PointDataTreeT &tree, const PointIndexTreeT &indexTree, const std::vector< short > &membership, const Name &group, const bool remove)
Sets group membership from a PointIndexTree-ordered vector.
std::unique_ptr< AttributeSet > UniquePtr
Library and file format version numbers.
OIIO_UTIL_API bool rename(string_view from, string_view to, std::string &err)
LeafData & operator=(const LeafData &)=delete
std::vector< NameAndType > NameAndTypeVec
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
size_t size() const
Return the number of attributes in this set.
Ordered collection of uniquely-named attribute arrays.
Inserter & add(const Name &name, const NamePair &type)
Util::GroupIndex GroupIndex
std::pair< size_t, uint8_t > GroupIndex
static size_t groupBits()
Return number of bits occupied by a group attribute array.
Attribute Array storage templated on type and compression codec.
NameToPosMap::const_iterator ConstIterator
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
DescriptorPtr descriptorPtr() const
Return a pointer to this attribute set's descriptor, which might be shared with other sets...
#define OPENVDB_THROW(exception, message)
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
const NameToPosMap & map() const
Return a reference to the name-to-position map.