Loading...
Searching...
No Matches
AttributeSet::Descriptor Class Reference

An immutable object that stores name, type and AttributeSet position for a constant collection of attribute arrays. More...

`#include <openvdb/points/AttributeSet.h>`

## Classes

struct | Inserter
| Utility method to construct a NameAndType sequence. More...

## Public Types

using | Ptr = std::shared_ptr<Descriptor>
using | NameAndType = Util::NameAndType
using | NameAndTypeVec = Util::NameAndTypeVec
using | GroupIndex = Util::GroupIndex
using | NameToPosMap = Util::NameToPosMap
using | ConstIterator = NameToPosMap::const_iterator

## Public Member Functions

| Descriptor ()
| Descriptor (const Descriptor &)
| Copy constructor.
Ptr | duplicateAppend (const Name &name, const NamePair &type) const
| Create a new descriptor as a duplicate with a new attribute appended.
Ptr | duplicateDrop (const std::vector< size_t > &pos) const
| Create a new descriptor as a duplicate with existing attributes dropped.
size_t | size () const
| Return the number of attributes in this descriptor.
size_t | count (const NamePair &type) const
| Return the number of attributes with this attribute type.
size_t | memUsage () const
| Return the number of bytes of memory used by this attribute set.
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 | rename (const std::string &fromName, const std::string &toName)
| Rename an attribute array.
const Name & | valueType (size_t pos) const
| Return the name of the attribute array's type.
const NamePair & | type (size_t pos) const
| Return the name of the attribute array's type.
MetaMap & | getMetadata ()
| Retrieve metadata map.
const MetaMap & | getMetadata () const
bool | hasDefaultValue (const Name &name) const
| Return true if the attribute has a default value.
template<typename ValueType>
ValueType | getDefaultValue (const Name &name) const
| Get a default value for an existing attribute.
void | setDefaultValue (const Name &name, const Metadata &defaultValue)
| Set a default value for an existing attribute.
void | removeDefaultValue (const Name &name)
void | pruneUnusedDefaultValues ()
bool | operator== (const Descriptor &) const
| Return true if this descriptor is equal to the given one.
bool | operator!= (const Descriptor &rhs) const
| Return true if this descriptor is not equal to the given one.
bool | hasSameAttributes (const Descriptor &rhs) const
const NameToPosMap & | map () const
| Return a reference to the name-to-position map.
const NameToPosMap & | groupMap () const
| Return a reference to the name-to-position group map.
bool | hasGroup (const Name &group) const
| Return `true` if group exists.
void | setGroup (const Name &group, const size_t offset, const bool checkValidOffset=false)
| Define a group name to offset mapping.
void | dropGroup (const Name &group)
| Drop any mapping keyed by group name.
void | clearGroups ()
| Clear all groups.
size_t | renameGroup (const std::string &fromName, const std::string &toName)
| Rename a group.
const Name | uniqueGroupName (const Name &name) const
| Return a unique name for a group based on given name.
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 GroupIndex &index) const
GroupIndex | groupIndex (const Name &groupName) const
| Return the group index from the name of the group.
GroupIndex | groupIndex (const size_t offset) const
size_t | availableGroups () const
size_t | unusedGroups () const
bool | canCompactGroups () const
| Return `true` if there are sufficient empty slots to allow compacting.
size_t | unusedGroupOffset (size_t hint=std::numeric_limits< size_t >::max()) const
| Return a group offset that is not in use.
bool | requiresGroupMove (Name &sourceName, size_t &sourceOffset, size_t &targetOffset) const
| Determine if a move is required to efficiently compact the data and store the source name, offset and the target offset in the input parameters.
bool | groupIndexCollision (const Descriptor &rhs) const
| Test if there are any group names shared by both descriptors which have a different index.
const Name | uniqueName (const Name &name) const
| Return a unique name for an attribute array based on given name.
void | write (std::ostream &) const
| Serialize this descriptor to the given stream.
void | read (std::istream &)
| Unserialize this transform from the given stream.

## Static Public Member Functions

static Ptr | create (const NamePair &)
| Create a new descriptor from a position attribute type and assumes "P" (for convenience).
static size_t | groupBits ()
| Return number of bits occupied by a group attribute array.
static bool | validName (const Name &name)
| Return true if the name is valid.
static void | parseNames (std::vector< std::string > &includeNames, std::vector< std::string > &excludeNames, bool &includeAll, const std::string &nameStr)
| Extract each name from nameStr into includeNames, or into excludeNames if the name is prefixed with a caret.
static void | parseNames (std::vector< std::string > &includeNames, std::vector< std::string > &excludeNames, const std::string &nameStr)
| Extract each name from nameStr into includeNames, or into excludeNames if the name is prefixed with a caret.

## Protected Member Functions

void | appendTo (NameAndTypeVec &attrs) const
| Append to a vector of names and types from this Descriptor in position order.
size_t | insert (const std::string &name, const NamePair &typeName)

## Static Protected Member Functions

static Ptr | create (const NameAndTypeVec &, const NameToPosMap &, const MetaMap &)

## Friends

class | ::TestAttributeSet

## Detailed Description

An immutable object that stores name, type and AttributeSet position for a constant collection of attribute arrays.

Note
  The attribute name is actually mutable, but the attribute type and position can not be changed after creation.

## Member Typedef Documentation

## ConstIterator

using ConstIterator = NameToPosMap::const_iterator

## GroupIndex

using GroupIndex = Util::GroupIndex

## NameAndType

using NameAndType = Util::NameAndType

## NameAndTypeVec

using NameAndTypeVec = Util::NameAndTypeVec

## NameToPosMap

using NameToPosMap = Util::NameToPosMap

## Ptr

using Ptr = std::shared_ptr<Descriptor>

## Constructor & Destructor Documentation

## Descriptor() [1/2]

Descriptor | ( |  | ) |

## Descriptor() [2/2]

Descriptor | ( | const Descriptor & |  | ) |

Copy constructor.

## Member Function Documentation

## appendTo()

void appendTo | ( | NameAndTypeVec & | attrs | ) | const

protected

Append to a vector of names and types from this Descriptor in position order.

## availableGroups()

size_t availableGroups | ( |  | ) | const

Return the total number of available groups (group bits * number of group attributes)

## canCompactGroups()

bool canCompactGroups | ( |  | ) | const

Return `true` if there are sufficient empty slots to allow compacting.

## clearGroups()

void clearGroups | ( |  | ) |

Clear all groups.

## count()

size_t count | ( | const NamePair & | type | ) | const

Return the number of attributes with this attribute type.

## create() [1/2]

Ptr create | ( | const NameAndTypeVec & | ,
|  | const NameToPosMap & | ,
|  | const MetaMap & | )

static protected

Create a new descriptor from the given attribute and type name pairs and copy the group maps and metamap.

## create() [2/2]

Ptr create | ( | const NamePair & |  | ) |

static

Create a new descriptor from a position attribute type and assumes "P" (for convenience).

## dropGroup()

void dropGroup | ( | const Name & | group | ) |

Drop any mapping keyed by group name.

## duplicateAppend()

Ptr duplicateAppend | ( | const Name & | name,
|  | const NamePair & | type ) const

Create a new descriptor as a duplicate with a new attribute appended.

## duplicateDrop()

Ptr duplicateDrop | ( | const std::vector< size_t > & | pos | ) | const

Create a new descriptor as a duplicate with existing attributes dropped.

## find()

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.

## getDefaultValue()

template<typename ValueType>

ValueType getDefaultValue | ( | const Name & | name | ) | const

inline

Get a default value for an existing attribute.

## getMetadata() [1/2]

MetaMap & getMetadata | ( |  | ) |

Retrieve metadata map.

## getMetadata() [2/2]

const MetaMap & getMetadata | ( |  | ) | const

## groupBits()

size_t groupBits | ( |  | ) |

inline static

Return number of bits occupied by a group attribute array.

## groupIndex() [1/2]

GroupIndex groupIndex | ( | const Name & | groupName | ) | const

Return the group index from the name of the group.

## groupIndex() [2/2]

GroupIndex groupIndex | ( | const size_t | offset | ) | const

Return the group index from the offset of the group

Note
  see offset description for groupOffset()

## groupIndexCollision()

bool groupIndexCollision | ( | const Descriptor & | rhs | ) | const

Test if there are any group names shared by both descriptors which have a different index.

Parameters

  rhs | the descriptor to compare with

Returns
  `true` if an index collision exists

## groupMap()

const NameToPosMap & groupMap | ( |  | ) | const

inline

Return a reference to the name-to-position group map.

## groupOffset() [1/2]

size_t groupOffset | ( | const GroupIndex & | index | ) | const

## groupOffset() [2/2]

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.

## hasDefaultValue()

bool hasDefaultValue | ( | const Name & | name | ) | const

Return true if the attribute has a default value.

## hasGroup()

bool hasGroup | ( | const Name & | group | ) | const

Return `true` if group exists.

## hasSameAttributes()

bool hasSameAttributes | ( | const Descriptor & | rhs | ) | const

Return true if this descriptor contains the same attributes as the given descriptor, ignoring attribute order

## insert()

size_t insert | ( | const std::string & | name,
|  | const NamePair & | typeName )

protected

## map()

const NameToPosMap & map | ( |  | ) | const

inline

Return a reference to the name-to-position map.

## memUsage()

size_t memUsage | ( |  | ) | const

Return the number of bytes of memory used by this attribute set.

## operator!=()

bool operator!= | ( | const Descriptor & | rhs | ) | const

inline

Return true if this descriptor is not equal to the given one.

## operator==()

bool operator== | ( | const Descriptor & |  | ) | const

Return true if this descriptor is equal to the given one.

## parseNames() [1/2]

void parseNames | ( | std::vector< std::string > & | includeNames,
|  | std::vector< std::string > & | excludeNames,
|  | bool & | includeAll,
|  | const std::string & | nameStr )

static

Extract each name from nameStr into includeNames, or into excludeNames if the name is prefixed with a caret.

Parameters

  nameStr | the input string of names
  includeNames | on exit, the list of names that are not prefixed with a caret
  excludeNames | on exit, the list of names that are prefixed with a caret
  includeAll | on exit, `true` if a "*" wildcard is present in the includeNames

## parseNames() [2/2]

void parseNames | ( | std::vector< std::string > & | includeNames,
|  | std::vector< std::string > & | excludeNames,
|  | const std::string & | nameStr )

static

Extract each name from nameStr into includeNames, or into excludeNames if the name is prefixed with a caret.

## pruneUnusedDefaultValues()

void pruneUnusedDefaultValues | ( |  | ) |

## read()

void read | ( | std::istream & |  | ) |

Unserialize this transform from the given stream.

## removeDefaultValue()

void removeDefaultValue | ( | const Name & | name | ) |

## rename()

size_t rename | ( | const std::string & | fromName,
|  | const std::string & | toName )

Rename an attribute array.

## renameGroup()

size_t renameGroup | ( | const std::string & | fromName,
|  | const std::string & | toName )

Rename a group.

## requiresGroupMove()

bool requiresGroupMove | ( | Name & | sourceName,
|  | size_t & | sourceOffset,
|  | size_t & | targetOffset ) const

Determine if a move is required to efficiently compact the data and store the source name, offset and the target offset in the input parameters.

Parameters

  sourceName | source name
  sourceOffset | source offset
  targetOffset | target offset

Returns
  `true` if move is required to compact the data

## setDefaultValue()

void setDefaultValue | ( | const Name & | name,
|  | const Metadata & | defaultValue )

Set a default value for an existing attribute.

## setGroup()

void setGroup | ( | const Name & | group,
|  | const size_t | offset,
|  | const bool | checkValidOffset = false )

Define a group name to offset mapping.

Parameters

  group | group name
  offset | group offset
  checkValidOffset | throws if offset out-of-range or in-use

## size()

size_t size | ( |  | ) | const

inline

Return the number of attributes in this descriptor.

## type()

const NamePair & type | ( | size_t | pos | ) | const

Return the name of the attribute array's type.

## uniqueGroupName()

const Name uniqueGroupName | ( | const Name & | name | ) | const

Return a unique name for a group based on given name.

## uniqueName()

const Name uniqueName | ( | const Name & | name | ) | const

Return a unique name for an attribute array based on given name.

## unusedGroupOffset()

size_t unusedGroupOffset | ( | size_t | hint = std::numeric_limits< size_t >::max() | ) | const

Return a group offset that is not in use.

Parameters

  hint | if provided, request a specific offset as a hint

Returns
  index of an offset or size_t max if no available group offsets

## unusedGroups()

size_t unusedGroups | ( |  | ) | const

Return the number of empty group slots which correlates to the number of groups that can be stored without increasing the number of group attribute arrays

## validName()

bool validName | ( | const Name & | name | ) |

static

Return true if the name is valid.

## valueType()

const Name & valueType | ( | size_t | pos | ) | const

Return the name of the attribute array's type.

## write()

void write | ( | std::ostream & |  | ) | const

Serialize this descriptor to the given stream.

## Friends And Related Symbol Documentation

## ::TestAttributeSet

friend class ::TestAttributeSet

friend