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;
155 size_t groupOffset(
const Name& groupName)
const;
156 size_t groupOffset(
const Util::GroupIndex&
index)
const;
160 Util::GroupIndex groupIndex(
const Name& groupName)
const;
163 Util::GroupIndex groupIndex(
const size_t offset)
const;
166 std::vector<size_t> groupAttributeIndices()
const;
169 bool isShared(
size_t pos)
const;
173 void makeUnique(
size_t pos);
178 const Index strideOrTotalSize = 1,
179 const bool constantStride =
true,
180 const Metadata* defaultValue =
nullptr);
185 const Index strideOrTotalSize,
186 const bool constantStride,
194 const size_t pos,
const Index strideOrTotalSize = 1,
195 const bool constantStride =
true,
196 const Metadata* defaultValue =
nullptr,
201 const size_t pos,
const Index strideOrTotalSize,
202 const bool constantStride,
245 const Descriptor& expected, DescriptorPtr& replacement);
249 void renameAttributes(
const Descriptor& expected,
const DescriptorPtr& replacement);
253 void reorderAttributes(
const DescriptorPtr& replacement);
258 void resetDescriptor(
const DescriptorPtr& replacement,
const bool allowMismatchingDescriptors =
false);
261 void read(std::istream&);
264 void write(std::ostream&,
bool outputTransient =
false)
const;
267 void readDescriptor(std::istream&);
270 void writeDescriptor(std::ostream&,
bool outputTransient =
false)
const;
273 void readMetadata(std::istream&);
277 void writeMetadata(std::ostream&,
bool outputTransient =
false,
bool paged =
false)
const;
280 void readAttributes(std::istream&);
283 void writeAttributes(std::ostream&,
bool outputTransient =
false)
const;
291 using AttrArrayVec = std::vector<AttributeArray::Ptr>;
293 DescriptorPtr mDescr;
305 std::vector<std::shared_ptr<Element>> mElements;
320 using Ptr = std::shared_ptr<Descriptor>;
332 vec.push_back(nameAndType);
return *
this;
335 vec.emplace_back(name, type);
return *
this;
338 for (NameAndTypeVec::const_iterator it = other.begin(), itEnd = other.end(); it != itEnd; ++it) {
339 vec.emplace_back(it->name, it->type);
350 Descriptor(
const Descriptor&);
359 Ptr duplicateDrop(
const std::vector<size_t>& pos)
const;
362 size_t size()
const {
return mTypes.size(); }
368 size_t memUsage()
const;
378 const Name& valueType(
size_t pos)
const;
384 const MetaMap& getMetadata()
const;
387 bool hasDefaultValue(
const Name&
name)
const;
389 template<
typename ValueType>
392 const size_t pos =
find(name);
393 if (pos == INVALID_POS) {
394 OPENVDB_THROW(LookupError,
"Cannot find attribute name to set default value.")
397 std::stringstream ss;
398 ss <<
"default:" <<
name;
402 if (metadata)
return metadata->
value();
404 return zeroVal<ValueType>();
409 void removeDefaultValue(
const Name&
name);
411 void pruneUnusedDefaultValues();
419 bool hasSameAttributes(
const Descriptor& rhs)
const;
433 const bool checkValidOffset =
false);
450 size_t groupOffset(
const Name& groupName)
const;
451 size_t groupOffset(
const GroupIndex&
index)
const;
455 GroupIndex groupIndex(
const Name& groupName)
const;
458 GroupIndex groupIndex(
const size_t offset)
const;
465 size_t availableGroups()
const;
469 size_t unusedGroups()
const;
472 bool canCompactGroups()
const;
480 size_t nextUnusedGroupOffset()
const;
488 bool requiresGroupMove(
Name& sourceName,
size_t& sourceOffset,
size_t& targetOffset)
const;
494 bool groupIndexCollision(
const Descriptor& rhs)
const;
500 static bool validName(
const Name&
name);
508 static void parseNames( std::vector<std::string>& includeNames,
509 std::vector<std::string>& excludeNames,
515 static void parseNames( std::vector<std::string>& includeNames,
516 std::vector<std::string>& excludeNames,
520 void write(std::ostream&)
const;
522 void read(std::istream&);
526 void appendTo(NameAndTypeVec& attrs)
const;
530 static Ptr create(
const NameAndTypeVec&,
const NameToPosMap&,
const MetaMap&);
535 friend class ::TestAttributeSet;
538 std::vector<NamePair> mTypes;
545 int64_t mReserved[5];
552 #endif // OPENVDB_POINTS_ATTRIBUTE_ARRAY_HAS_BEEN_INCLUDED
vbool4 insert(const vbool4 &a, bool val)
Helper: substitute val for a[i].
Util::NameAndTypeVec NameAndTypeVec
vint4 max(const vint4 &a, const vint4 &b)
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...
Inserter & add(const NameAndTypeVec &other)
GLuint const GLchar * name
void dropGroup(PointDataTree &tree, const Name &group, const bool compact=true)
Drops an existing group from the VDB tree.
bool operator!=(const Descriptor &rhs) const
Return true if this descriptor is not equal to the given one.
OIIO_API bool rename(string_view from, string_view to, std::string &err)
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
void read(T &in, bool &v)
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.
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
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) ...
Base class for storing attribute data.
std::string OIIO_API replace(string_view str, string_view pattern, string_view replacement, bool global=false)
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.
NameAndType(const std::string &n, const NamePair &t, const Index s=1)
std::pair< Name, Name > NamePair
std::map< std::string, size_t > NameToPosMap
GLuint GLuint GLsizei GLenum type
Inserter & add(const NameAndType &nameAndType)
GLsizei const GLchar *const * string
std::unique_ptr< AttributeSet > UniquePtr
Library and file format version numbers.
FMT_CONSTEXPR bool find(Ptr first, Ptr last, T value, Ptr &out)
std::vector< NameAndType > NameAndTypeVec
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
GLuint GLuint GLsizei count
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.
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.
void write(T &out, bool v)
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)
const NameToPosMap & map() const
Return a reference to the name-to-position map.