Graphite
Version 3
An experimental 3D geometry processing program
|
Access to an attribute as a double regardless its type. More...
#include <geogram/basic/attributes.h>
Classes | |
class | Accessor |
Accessor class used by ScalarAttributeAdapter to implement indexing operator. More... | |
class | ConstAccessor |
Accessor class used by ScalarAttributeAdapter to implement indexing operator (const version). More... | |
Public Types | |
enum | ElementType { ET_NONE =0 , ET_UINT8 =1 , ET_INT8 =2 , ET_UINT32 =3 , ET_INT32 =4 , ET_FLOAT32 =5 , ET_FLOAT64 =6 , ET_VEC2 =7 , ET_VEC3 =8 } |
Internal representation of the attribute. | |
Public Member Functions | |
ScalarAttributeAdapterBase () | |
ScalarAttributeAdapterBase constructor. | |
ScalarAttributeAdapterBase (const AttributesManager &manager, const std::string &name) | |
ScalarAttributeAdapterBase constructor. More... | |
bool | is_bound () const |
Tests whether an Attribute is bound. More... | |
void | unbind () |
Unbinds this Attribute. More... | |
void | bind_if_is_defined (const AttributesManager &manager, const std::string &name) |
Binds this Attribute to an AttributesManager if it already exists in the AttributesManager. More... | |
~ScalarAttributeAdapterBase () | |
ReadonlyScalarAttributeAdapterBase destructor. More... | |
index_t | size () const |
Gets the size. More... | |
ElementType | element_type () const |
Gets the internal representation of the elements. More... | |
index_t | element_index () const |
Gets the element index. More... | |
const AttributeStore * | attribute_store () const |
Gets the AttributeStore. More... | |
Public Member Functions inherited from GEO::AttributeStoreObserver | |
AttributeStoreObserver () | |
Creates a new uninitialied AttributeStore. | |
void | notify (Memory::pointer base_addr, index_t size, index_t dim) |
Callback function, called by the AttributeStore whenever it is modified. More... | |
index_t | size () const |
Gets the size. More... | |
index_t | dimension () const |
Gets the dimension. More... | |
index_t | nb_elements () const |
Gets the total number of elements. More... | |
void | register_me (AttributeStore *store) |
Registers this observer to an AttributeStore. More... | |
void | unregister_me (AttributeStore *store) |
Unregisters this observer from an AttributeStore. More... | |
void | disconnect () |
Disconnects this AttributeStoreObserver from its AttributeStore. More... | |
Static Public Member Functions | |
static bool | is_defined (const AttributesManager &manager, const std::string &name) |
Tests whether an attribute with the specified name and with a type that can be converted to double exists in an AttributesManager. More... | |
static bool | can_be_bound_to (const AttributeStore *store) |
Tests whether a ScalarAttributeAdapterBase can be bound to a given attribute store. More... | |
static index_t | nb_scalar_elements_per_item (const AttributeStore *store) |
Gets the number of scalar components per item in an AttributeStore. More... | |
Protected Member Functions | |
double | get_element_as_double (index_t i) const |
Gets an attribute value. More... | |
template<class T > | |
T | get_element (index_t i, index_t multiplier=1) const |
Gets an element. More... | |
double | set_element_as_double (index_t i, double value) |
Sets an attribute value. More... | |
template<class T > | |
void | set_element (T value, index_t i, index_t multiplier=1) const |
Sets an element. More... | |
Static Protected Member Functions | |
static std::string | attribute_base_name (const std::string &name) |
Gets the base attribute name from a compound name. More... | |
static index_t | attribute_element_index (const std::string &name) |
Gets the base attribute name from a compound name. More... | |
static ElementType | element_type (const AttributeStore *store) |
Gets the element type stored in an AttributeStore. More... | |
Protected Attributes | |
const AttributesManager * | manager_ |
const AttributeStore * | store_ |
ElementType | element_type_ |
index_t | element_index_ |
Protected Attributes inherited from GEO::AttributeStoreObserver | |
Memory::pointer | base_addr_ |
index_t | size_ |
index_t | dimension_ |
bool | disconnected_ |
Access to an attribute as a double regardless its type.
The attribute can be an element of a vector attribute.
Definition at line 1709 of file attributes.h.
|
inline |
ScalarAttributeAdapterBase constructor.
Retrieves a persistent attribute attached to a given AttributesManager.
[in] | manager | a reference to the AttributesManager |
[in] | name | name of the attribute with an optional index, for instance, "foobar[5]" refers to the 5th coordinate of the "foobar" vector attribute. |
Definition at line 1794 of file attributes.h.
|
inline |
ReadonlyScalarAttributeAdapterBase destructor.
The attribute is not destroyed, it can be retrieved later by binding with the same name. To destroy the attribute, use destroy() instead.
Definition at line 1844 of file attributes.h.
|
staticprotected |
Gets the base attribute name from a compound name.
[in] | name | the string with the attribute name and optional index. For instance, "foobar[5]" refers to the 5th coordinate of the "foobar" vector attribute. |
|
staticprotected |
Gets the base attribute name from a compound name.
[in] | name | the string with the attribute name and optional index. For instance, "foobar[5]" refers to the 5th coordinate of the "foobar" vector attribute. |
|
inline |
Gets the AttributeStore.
Definition at line 1896 of file attributes.h.
void GEO::ScalarAttributeAdapterBase::bind_if_is_defined | ( | const AttributesManager & | manager, |
const std::string & | name | ||
) |
Binds this Attribute to an AttributesManager if it already exists in the AttributesManager.
[in] | manager | a reference to the AttributesManager |
[in] | name | name of the attribute with an optional index, for instance, "foobar[5]" refers to the 5th coordinate of the "foobar" vector attribute. |
|
inlinestatic |
Tests whether a ScalarAttributeAdapterBase can be bound to a given attribute store.
[in] | store | a pointer to the attribute store. |
true | if it can be bound |
false | otherwise |
Definition at line 1908 of file attributes.h.
|
inline |
Gets the element index.
Definition at line 1888 of file attributes.h.
|
inline |
Gets the internal representation of the elements.
Definition at line 1878 of file attributes.h.
|
staticprotected |
Gets the element type stored in an AttributeStore.
[in] | store | a const pointer to the AttributeStore |
|
inlineprotected |
Gets an element.
Stored element type needs to match T, no verification is made
[in] | i | index of the element |
[in] | multiplier | multiplier applied to the index before fetching the raw pointer. |
Definition at line 1999 of file attributes.h.
|
inlineprotected |
Gets an attribute value.
[in] | i | the index of the item |
Definition at line 1958 of file attributes.h.
|
inline |
Tests whether an Attribute is bound.
true | if this Attribute is bound |
false | otherwise |
Definition at line 1807 of file attributes.h.
|
static |
Tests whether an attribute with the specified name and with a type that can be converted to double exists in an AttributesManager.
[in] | manager | a reference to the AttributesManager |
[in] | name | the name of the attribute with an optional index, for instance, "foobar[5]" refers to the 5th coordinate of the "foobar" vector attribute. |
|
static |
Gets the number of scalar components per item in an AttributeStore.
[in] | store | a pointer to the attribute store. |
|
inlineprotected |
Sets an element.
Stored element type needs to match T, no verification is made
[in] | value | the value of the element to be stored |
[in] | i | index of the element |
[in] | multiplier | multiplier applied to the index before fetching the raw pointer. |
Definition at line 2056 of file attributes.h.
|
inlineprotected |
Sets an attribute value.
[in] | i | the index of the element |
[in] | value | the new value of the element |
Definition at line 2014 of file attributes.h.
|
inline |
Gets the size.
Definition at line 1867 of file attributes.h.
|
inline |