Graphite
Version 3
An experimental 3D geometry processing program
|
Managers a set of attributes attached to an object. More...
#include <geogram/basic/attributes.h>
Public Member Functions | |
AttributesManager () | |
Constructs a new empty AttributesManager. | |
~AttributesManager () | |
AttributesManager destructor. | |
index_t | nb () const |
Gets the number of attributes. More... | |
void | list_attribute_names (vector< std::string > &names) const |
Gets the names of all the attributes in this AttributeStore. More... | |
index_t | size () const |
Gets the size. More... | |
index_t | capacity () const |
Gets the capacity. More... | |
void | resize (index_t new_size) |
Resizes all the attributes managed by this AttributesManager. More... | |
void | reserve (index_t new_capacity) |
Pre-allocates memory for a number of items. More... | |
void | clear (bool keep_attributes, bool keep_memory=false) |
Clears this AttributesManager. More... | |
void | zero () |
Zeroes all the attributes. | |
void | bind_attribute_store (const std::string &name, AttributeStore *as) |
Binds an AttributeStore with the specified name. Ownership of this AttributeStore is transferred to the AttributesManager. More... | |
AttributeStore * | find_attribute_store (const std::string &name) |
Finds an AttributeStore by name. More... | |
const AttributeStore * | find_attribute_store (const std::string &name) const |
Finds an AttributeStore by name. More... | |
bool | is_defined (const std::string &name) const |
Tests whether an attribute is defined. More... | |
void | delete_attribute_store (const std::string &name) |
Deletes an AttributeStore by name. More... | |
void | delete_attribute_store (AttributeStore *as) |
Deletes an AttributeStore. More... | |
void | apply_permutation (const vector< index_t > &permutation) |
Applies a permutation to the stored attributes. More... | |
void | compress (const vector< index_t > &old2new) |
Compresses the stored attributes, by applying an index mapping that fills-in the gaps. More... | |
void | copy (const AttributesManager &rhs) |
Copies all the attributes from another AttributesManager. More... | |
void | copy_item (index_t to, index_t from) |
Copies all the attributes of an item into another one. More... | |
void | swap_items (index_t i, index_t j) |
Swaps all the attributes of two items. More... | |
void | zero_item (index_t to) |
Sets an item to zero. More... | |
void | scale_item (index_t to, double s) |
Scales an item. More... | |
void | madd_item (index_t to, double s, index_t from) |
Adds a scaled item to another item \detais item[to] += s * item[from]. More... | |
bool | copy_attribute (const std::string &name, const std::string &new_name) |
Copies an attribute. More... | |
bool | rename_attribute (const std::string &old_name, const std::string &new_name) |
Renames an attribute. More... | |
Managers a set of attributes attached to an object.
Definition at line 834 of file attributes.h.
Applies a permutation to the stored attributes.
Applying a permutation to the data is equivalent to:
But it is done in-place.
[in] | permutation | the permutation. It is temporarily changed during execution of the function, but identical to the input on exit. |
void GEO::AttributesManager::bind_attribute_store | ( | const std::string & | name, |
AttributeStore * | as | ||
) |
Binds an AttributeStore with the specified name. Ownership of this AttributeStore is transferred to the AttributesManager.
[in] | name | the name |
[in] | as | a pointer to the AttributeStore to be bound |
|
inline |
Gets the capacity.
Definition at line 878 of file attributes.h.
void GEO::AttributesManager::clear | ( | bool | keep_attributes, |
bool | keep_memory = false |
||
) |
Clears this AttributesManager.
[in] | keep_attributes | if true, then all attributes are resized to 0 but their names are kept. |
[in] | keep_memory | if true, allocated memory is kept reserved. |
Compresses the stored attributes, by applying an index mapping that fills-in the gaps.
This is equivalent to:
[in] | old2new | the index mapping to be applied. |
void GEO::AttributesManager::copy | ( | const AttributesManager & | rhs | ) |
Copies all the attributes from another AttributesManager.
Previous content of this AttributesManager is erased.
bool GEO::AttributesManager::copy_attribute | ( | const std::string & | name, |
const std::string & | new_name | ||
) |
Copies an attribute.
[in] | name | the attribute to copy |
[in] | new_name | new name of the attribute |
Copies all the attributes of an item into another one.
[in] | to | index of the destination item |
[in] | from | index of the source item |
void GEO::AttributesManager::delete_attribute_store | ( | AttributeStore * | as | ) |
Deletes an AttributeStore.
[in] | as | a pointer to the attribute store to be deleted. |
void GEO::AttributesManager::delete_attribute_store | ( | const std::string & | name | ) |
Deletes an AttributeStore by name.
[in] | name | the name of the attribute store to be deleted. |
AttributeStore* GEO::AttributesManager::find_attribute_store | ( | const std::string & | name | ) |
Finds an AttributeStore by name.
[in] | name | the name under which the AttributeStore was bound |
const AttributeStore* GEO::AttributesManager::find_attribute_store | ( | const std::string & | name | ) | const |
Finds an AttributeStore by name.
[in] | name | the name under which the AttributeStore was bound |
|
inline |
Tests whether an attribute is defined.
[in] | name | name of the attribute |
true | if an attribute with the specified name exists |
false | otherwise |
Definition at line 949 of file attributes.h.
void GEO::AttributesManager::list_attribute_names | ( | vector< std::string > & | names | ) | const |
Gets the names of all the attributes in this AttributeStore.
[out] | names | a vector of all attribute names |
Adds a scaled item to another item \detais item[to] += s * item[from].
[in] | to | the item |
[in] | s | the scaling factor |
[in] | from | the item to be scaled and added |
default implementation does nothing
|
inline |
Gets the number of attributes.
Definition at line 852 of file attributes.h.
bool GEO::AttributesManager::rename_attribute | ( | const std::string & | old_name, |
const std::string & | new_name | ||
) |
Renames an attribute.
[in] | old_name | current name of the attribute |
[in] | new_name | new name of the attribute |
void GEO::AttributesManager::reserve | ( | index_t | new_capacity | ) |
Pre-allocates memory for a number of items.
Has effect only if new_capacity is larger than current capacity.
[in] | new_capacity | the number of items. |
void GEO::AttributesManager::resize | ( | index_t | new_size | ) |
Resizes all the attributes managed by this AttributesManager.
[in] | new_size | the new number of items for all attributes. |
void GEO::AttributesManager::scale_item | ( | index_t | to, |
double | s | ||
) |
Scales an item.
item[to] *= s
[in] | to | the index of the item |
[in] | s | the scaling factor |
default implementation does nothing
|
inline |
Gets the size.
All attributes stored in an AttributesManager have the same number of items.
Definition at line 869 of file attributes.h.
Swaps all the attributes of two items.
[in] | i,j | the indices of the two items to be swapped |
void GEO::AttributesManager::zero_item | ( | index_t | to | ) |
Sets an item to zero.
[in] | to | index of the item |