OpenVDB 11.0.0
|
Ordered collection of uniquely-named attribute arrays. More...
#include <openvdb/points/AttributeSet.h>
Classes | |
class | Descriptor |
An immutable object that stores name, type and AttributeSet position for a constant collection of attribute arrays. More... | |
struct | Util |
Public Types | |
enum | AttributePositionLabel : size_t { INVALID_POS = std::numeric_limits<size_t>::max() } |
using | Ptr = std::shared_ptr<AttributeSet> |
using | ConstPtr = std::shared_ptr<const AttributeSet> |
using | UniquePtr = std::unique_ptr<AttributeSet> |
using | DescriptorPtr = std::shared_ptr<Descriptor> |
using | DescriptorConstPtr = std::shared_ptr<const Descriptor> |
Public Member Functions | |
AttributeSet () | |
AttributeSet (const AttributeSet &attributeSet, Index arrayLength, const AttributeArray::ScopedRegistryLock *lock=nullptr) | |
AttributeSet (const DescriptorPtr &descriptor, Index arrayLength=1, const AttributeArray::ScopedRegistryLock *lock=nullptr) | |
AttributeSet (const AttributeSet &) | |
Shallow copy constructor, the descriptor and attribute arrays will be shared. | |
AttributeSet & | operator= (const AttributeSet &)=delete |
Disallow copy assignment, since it wouldn't be obvious whether the copy is deep or shallow. | |
Descriptor & | descriptor () |
Return a reference to this attribute set's descriptor, which might be shared with other sets. | |
const Descriptor & | descriptor () const |
DescriptorPtr | descriptorPtr () const |
Return a pointer to this attribute set's descriptor, which might be shared with other sets. | |
size_t | size () const |
Return the number of attributes in this set. | |
size_t | memUsage () const |
Return the number of bytes of memory used by this attribute set. | |
size_t | memUsageIfLoaded () const |
size_t | find (const std::string &name) const |
Return the position of the attribute array whose name is name, or INVALID_POS if no match is found. | |
size_t | replace (const std::string &name, const AttributeArray::Ptr &) |
Replace the attribute array whose name is name. | |
size_t | replace (size_t pos, const AttributeArray::Ptr &) |
Replace the attribute array stored at position pos in this container. | |
const AttributeArray * | getConst (const std::string &name) const |
Return a pointer to the attribute array whose name is name or a null pointer if no match is found. | |
const AttributeArray * | get (const std::string &name) const |
AttributeArray * | get (const std::string &name) |
const AttributeArray * | getConst (size_t pos) const |
Return a pointer to the attribute array stored at position pos in this set. | |
const AttributeArray * | get (size_t pos) const |
AttributeArray * | get (size_t pos) |
size_t | groupOffset (const Name &groupName) const |
Return the group offset from the name or index of the group A group attribute array is a single byte (8-bit), each bit of which can denote a group. The group offset is the position of the bit that denotes the requested group if all group attribute arrays in the set (and only attribute arrays marked as group) were to be laid out linearly according to their order in the set. | |
size_t | groupOffset (const Util::GroupIndex &index) const |
Util::GroupIndex | groupIndex (const Name &groupName) const |
Return the group index from the name of the group. | |
Util::GroupIndex | groupIndex (const size_t offset) const |
std::vector< size_t > | groupAttributeIndices () const |
Return the indices of the attribute arrays which are group attribute arrays. | |
bool | isShared (size_t pos) const |
Return true if the attribute array stored at position pos is shared. | |
void | makeUnique (size_t pos) |
If the attribute array stored at position pos is shared, replace the array with a deep copy of itself that is not shared with anyone else. | |
AttributeArray::Ptr | appendAttribute (const Name &name, const NamePair &type, const Index strideOrTotalSize=1, const bool constantStride=true, const Metadata *defaultValue=nullptr) |
Append attribute attribute (simple method) | |
AttributeArray::Ptr | appendAttribute (const Descriptor &expected, DescriptorPtr &replacement, const size_t pos, const Index strideOrTotalSize=1, const bool constantStride=true, const Metadata *defaultValue=nullptr, const AttributeArray::ScopedRegistryLock *lock=nullptr) |
AttributeArray::Ptr | removeAttribute (const Name &name) |
Remove and return an attribute array by name. | |
AttributeArray::Ptr | removeAttribute (const size_t pos) |
Remove and return an attribute array by index. | |
AttributeArray::Ptr | removeAttributeUnsafe (const size_t pos) |
Remove and return an attribute array by index (unsafe method) | |
void | dropAttributes (const std::vector< size_t > &pos) |
void | dropAttributes (const std::vector< size_t > &pos, const Descriptor &expected, DescriptorPtr &replacement) |
void | renameAttributes (const Descriptor &expected, const DescriptorPtr &replacement) |
void | reorderAttributes (const DescriptorPtr &replacement) |
void | resetDescriptor (const DescriptorPtr &replacement, const bool allowMismatchingDescriptors=false) |
void | read (std::istream &) |
Read the entire set from a stream. | |
void | write (std::ostream &, bool outputTransient=false) const |
void | readDescriptor (std::istream &) |
This will read the attribute descriptor from a stream. | |
void | writeDescriptor (std::ostream &, bool outputTransient=false) const |
void | readMetadata (std::istream &) |
This will read the attribute metadata from a stream. | |
void | writeMetadata (std::ostream &, bool outputTransient=false, bool paged=false) const |
void | readAttributes (std::istream &) |
This will read the attribute data from a stream. | |
void | writeAttributes (std::ostream &, bool outputTransient=false) const |
bool | operator== (const AttributeSet &other) const |
bool | operator!= (const AttributeSet &other) const |
Ordered collection of uniquely-named attribute arrays.
using ConstPtr = std::shared_ptr<const AttributeSet> |
using DescriptorConstPtr = std::shared_ptr<const Descriptor> |
using DescriptorPtr = std::shared_ptr<Descriptor> |
using Ptr = std::shared_ptr<AttributeSet> |
using UniquePtr = std::unique_ptr<AttributeSet> |
enum AttributePositionLabel : size_t |
AttributeSet | ( | ) |
AttributeSet | ( | const AttributeSet & | attributeSet, |
Index | arrayLength, | ||
const AttributeArray::ScopedRegistryLock * | lock = nullptr ) |
Construct a new AttributeSet from the given AttributeSet.
attributeSet | the old attribute set |
arrayLength | the desired length of the arrays in the new AttributeSet |
lock | an optional scoped registry lock to avoid contention |
AttributeSet | ( | const DescriptorPtr & | descriptor, |
Index | arrayLength = 1, | ||
const AttributeArray::ScopedRegistryLock * | lock = nullptr ) |
Construct a new AttributeSet from the given Descriptor.
descriptor | stored in the new AttributeSet and used in construction |
arrayLength | the desired length of the arrays in the new AttributeSet |
lock | an optional scoped registry lock to avoid contention |
AttributeSet | ( | const AttributeSet & | ) |
Shallow copy constructor, the descriptor and attribute arrays will be shared.
AttributeArray::Ptr appendAttribute | ( | const Descriptor & | expected, |
DescriptorPtr & | replacement, | ||
const size_t | pos, | ||
const Index | strideOrTotalSize = 1, | ||
const bool | constantStride = true, | ||
const Metadata * | defaultValue = nullptr, | ||
const AttributeArray::ScopedRegistryLock * | lock = nullptr ) |
Append attribute attribute (descriptor-sharing) Requires current descriptor to match expected On append, current descriptor is replaced with replacement Provide a lock object to avoid contention from appending in parallel
AttributeArray::Ptr appendAttribute | ( | const Name & | name, |
const NamePair & | type, | ||
const Index | strideOrTotalSize = 1, | ||
const bool | constantStride = true, | ||
const Metadata * | defaultValue = nullptr ) |
Append attribute attribute (simple method)
|
inline |
Return a reference to this attribute set's descriptor, which might be shared with other sets.
|
inline |
|
inline |
Return a pointer to this attribute set's descriptor, which might be shared with other sets.
void dropAttributes | ( | const std::vector< size_t > & | pos | ) |
Drop attributes with pos indices (simple method) Creates a new descriptor for this attribute set
void dropAttributes | ( | const std::vector< size_t > & | pos, |
const Descriptor & | expected, | ||
DescriptorPtr & | replacement ) |
Drop attributes with pos indices (descriptor-sharing method) Requires current descriptor to match expected On drop, current descriptor is replaced with replacement
size_t find | ( | const std::string & | name | ) | const |
Return the position of the attribute array whose name is name, or INVALID_POS
if no match is found.
AttributeArray * get | ( | const std::string & | name | ) |
const AttributeArray * get | ( | const std::string & | name | ) | const |
AttributeArray * get | ( | size_t | pos | ) |
const AttributeArray * get | ( | size_t | pos | ) | const |
const AttributeArray * getConst | ( | const std::string & | name | ) | const |
Return a pointer to the attribute array whose name is name or a null pointer if no match is found.
const AttributeArray * getConst | ( | size_t | pos | ) | const |
Return a pointer to the attribute array stored at position pos in this set.
std::vector< size_t > groupAttributeIndices | ( | ) | const |
Return the indices of the attribute arrays which are group attribute arrays.
Util::GroupIndex groupIndex | ( | const Name & | groupName | ) | const |
Return the group index from the name of the group.
Util::GroupIndex groupIndex | ( | const size_t | offset | ) | const |
Return the group index from the offset of the group
size_t groupOffset | ( | const Name & | groupName | ) | const |
Return the group offset from the name or index of the group A group attribute array is a single byte (8-bit), each bit of which can denote a group. The group offset is the position of the bit that denotes the requested group if all group attribute arrays in the set (and only attribute arrays marked as group) were to be laid out linearly according to their order in the set.
size_t groupOffset | ( | const Util::GroupIndex & | index | ) | const |
bool isShared | ( | size_t | pos | ) | const |
Return true if the attribute array stored at position pos is shared.
void makeUnique | ( | size_t | pos | ) |
If the attribute array stored at position pos is shared, replace the array with a deep copy of itself that is not shared with anyone else.
size_t memUsage | ( | ) | const |
Return the number of bytes of memory used by this attribute set.
size_t memUsageIfLoaded | ( | ) | const |
Return the number of bytes of memory used by this attribute set once it has been deserialized (this may be different to memUsage() if delay-loading is in use).
|
inline |
|
delete |
Disallow copy assignment, since it wouldn't be obvious whether the copy is deep or shallow.
bool operator== | ( | const AttributeSet & | other | ) | const |
Compare the descriptors and attribute arrays on the attribute sets Exit early if the descriptors do not match
void read | ( | std::istream & | ) |
Read the entire set from a stream.
void readAttributes | ( | std::istream & | ) |
This will read the attribute data from a stream.
void readDescriptor | ( | std::istream & | ) |
This will read the attribute descriptor from a stream.
void readMetadata | ( | std::istream & | ) |
This will read the attribute metadata from a stream.
AttributeArray::Ptr removeAttribute | ( | const Name & | name | ) |
Remove and return an attribute array by name.
name | the name of the attribute array to release |
Detaches the attribute array from this attribute set and returns it, if name is invalid, returns an empty shared pointer. This also updates the descriptor to remove the reference to the attribute array.
AttributeArray::Ptr removeAttribute | ( | const size_t | pos | ) |
Remove and return an attribute array by index.
pos | the position index of the attribute to release |
Detaches the attribute array from this attribute set and returns it, if pos is invalid, returns an empty shared pointer. This also updates the descriptor to remove the reference to the attribute array.
AttributeArray::Ptr removeAttributeUnsafe | ( | const size_t | pos | ) |
Remove and return an attribute array by index (unsafe method)
pos | the position index of the attribute to release |
Detaches the attribute array from this attribute set and returns it, if pos is invalid, returns an empty shared pointer. In cases where the AttributeSet is due to be destroyed, a small performance advantage can be gained by leaving the attribute array as a nullptr and not updating the descriptor. However, this leaves the AttributeSet in an invalid state making it unsafe to call any methods that implicitly derefence the attribute array.
void renameAttributes | ( | const Descriptor & | expected, |
const DescriptorPtr & | replacement ) |
Re-name attributes in set to match a provided descriptor Replaces own descriptor with replacement
void reorderAttributes | ( | const DescriptorPtr & | replacement | ) |
Re order attribute set to match a provided descriptor Replaces own descriptor with replacement
size_t replace | ( | const std::string & | name, |
const AttributeArray::Ptr & | ) |
Replace the attribute array whose name is name.
INVALID_POS
if the given name does not exist or if the replacement failed because the new array type does not comply with the descriptor. size_t replace | ( | size_t | pos, |
const AttributeArray::Ptr & | ) |
Replace the attribute array stored at position pos in this container.
INVALID_POS
if replacement failed because the new array type does not comply with the descriptor. void resetDescriptor | ( | const DescriptorPtr & | replacement, |
const bool | allowMismatchingDescriptors = false ) |
Replace the current descriptor with a replacement Note the provided Descriptor must be identical to the replacement unless allowMismatchingDescriptors is true (default is false)
|
inline |
Return the number of attributes in this set.
void write | ( | std::ostream & | , |
bool | outputTransient = false ) const |
Write the entire set to a stream.
outputTransient | if true, write out transient attributes |
void writeAttributes | ( | std::ostream & | , |
bool | outputTransient = false ) const |
This will write the attribute data to a stream.
outputTransient | if true, write out transient attributes |
void writeDescriptor | ( | std::ostream & | , |
bool | outputTransient = false ) const |
This will write the attribute descriptor to a stream.
outputTransient | if true, write out transient attributes |
void writeMetadata | ( | std::ostream & | , |
bool | outputTransient = false, | ||
bool | paged = false ) const |
This will write the attribute metadata to a stream.
outputTransient | if true, write out transient attributes |
paged | if true, data is written out in pages |