Go to the documentation of this file.
10 #ifndef OPENVDB_POINTS_ATTRIBUTE_ARRAY_STRING_HAS_BEEN_INCLUDED
11 #define OPENVDB_POINTS_ATTRIBUTE_ARRAY_STRING_HAS_BEEN_INCLUDED
15 #include <unordered_set>
16 #include <unordered_map>
31 namespace attribute_traits
38 template <
bool Truncate>
46 template<
typename StorageType>
static void decode(
const StorageType&,
ValueType&);
47 template<
typename StorageType>
static void encode(
const ValueType&, StorageType&);
48 static const char*
name() {
return Truncate ?
"str_trnc" :
"str"; }
71 std::vector<std::pair<Index, Index>> mIdBlocks;
72 std::unordered_set<Name> mValues;
79 template <
bool Truncate>
80 template<
typename StorageType>
88 template <
bool Truncate>
89 template<
typename StorageType>
112 using Ptr = std::shared_ptr<StringAttributeHandle>;
118 const bool preserveCompression =
true);
144 using Ptr = std::shared_ptr<StringAttributeWriteHandle>;
150 const bool expand =
true);
188 using ValueMap = std::unordered_map<std::string, Index>;
202 #endif // OPENVDB_POINTS_ATTRIBUTE_ARRAY_STRING_HAS_BEEN_INCLUDED
void set(Index n, const Name &name)
Set the value of the index to name.
AttributeHandle< StringIndexType, StringCodec< false > > mHandle
Definition: AttributeArrayString.h:133
void resetCache()
Reset the value cache from the metadata.
Index stride() const
Definition: AttributeArrayString.h:120
Definition: AttributeArrayString.h:110
Base class for storing attribute data.
Definition: AttributeArray.h:93
Definition: AttributeArrayString.h:40
void collapse()
Set membership for the whole array and attempt to collapse.
std::shared_ptr< StringAttributeHandle > Ptr
Definition: AttributeArrayString.h:112
AttributeArray & array()
Returns a reference to the array held in the Write Handle.
uint32_t StringIndexType
Definition: AttributeArrayString.h:28
uint16_t Type
Definition: AttributeArrayString.h:34
void collapse(const Name &name)
Set membership for the whole array and attempt to collapse.
typename attribute_traits::StringTypeTrait< Truncate >::Type Type
Definition: AttributeArrayString.h:44
Attribute Array storage templated on type and compression codec.
const AttributeArray & array() const
Returns a reference to the array held in the Handle.
StringIndexType Type
Definition: AttributeArrayString.h:33
void set(Index n, Index m, const Name &name)
Definition: AttributeArrayString.h:142
Write-able version of AttributeHandle.
Definition: AttributeArray.h:921
bool contains(const Name &name) const
Returns whether or not the metadata cache contains a given value.
bool isUniform() const
Definition: AttributeArrayString.h:123
Typed class for storing attribute data.
Definition: AttributeArray.h:570
Definition: AttributeArrayString.h:33
StringIndexType ValueType
Definition: AttributeArrayString.h:41
Index size() const
Definition: AttributeArrayString.h:121
bool hasConstantStride() const
Definition: AttributeArrayString.h:124
Definition: AttributeArray.h:850
StringAttributeHandle(const AttributeArray &array, const MetaMap &metadata, const bool preserveCompression=true)
bool isType() const
Return true if this attribute is of the same type as the template parameter.
Definition: AttributeArray.h:224
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:154
static const char * name()
Definition: AttributeArrayString.h:48
bool compact()
Compact the existing array to become uniform if all values are identical.
void expand(bool fill=true)
If this array is uniform, replace it with an array of length size().
static Ptr create(const AttributeArray &array, const MetaMap &metadata, const bool preserveCompression=true)
const MetaMap & mMetadata
Definition: AttributeArrayString.h:134
Name get(Index n, Index m=0) const
Index32 Index
Definition: Types.h:31
std::string Name
Definition: Name.h:17
Definition: AttributeArrayString.h:44
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:102
StringAttributeWriteHandle(AttributeArray &array, const MetaMap &metadata, const bool expand=true)
void fill(const Name &name)
Fill the existing array with the given value.
static Ptr create(AttributeArray &array, const MetaMap &metadata, const bool expand=true)
Definition: Exceptions.h:13
bool isString(const AttributeArray &array)
Definition: AttributeArrayString.h:100
Type Truncate(Type x, unsigned int digits)
Return x truncated to the given number of decimal digits.
Definition: Math.h:817
void get(Name &name, Index n, Index m=0) const