Interface for attribute maps. More...
#include <AttributeMap.hpp>
Public Types | |
typedef HandleT | HandleType |
The type of the handle used as key in this map. More... | |
typedef ValueT | ValueType |
The type of the value stored in this map. More... | |
Public Member Functions | |
virtual AttributeMapHandleIteratorPtr< HandleT > | begin () const =0 |
Returns an iterator over all keys of this map. The order of iteration is unspecified. More... | |
virtual void | clear ()=0 |
Removes all values from the map. More... | |
virtual bool | containsKey (HandleT key) const =0 |
Returns true iff the map contains a value associated with the given key. More... | |
virtual AttributeMapHandleIteratorPtr< HandleT > | end () const =0 |
Returns an iterator to the end of all keys. More... | |
virtual boost::optional< ValueT > | erase (HandleT key)=0 |
Removes the value associated with the given key. More... | |
virtual boost::optional< const ValueT & > | get (HandleT key) const =0 |
Returns the value associated with the given key or None if there is no associated value. More... | |
virtual boost::optional< ValueT & > | get (HandleT key)=0 |
Returns the value associated with the given key or None if there is no associated value. More... | |
virtual boost::optional< ValueT > | insert (HandleT key, const ValueT &value)=0 |
Inserts the given value at the given key position. More... | |
virtual size_t | numValues () const =0 |
Returns the number of values in this map. More... | |
ValueT & | operator[] (HandleT key) |
Returns the value associated with the given key or panics if there is no associated value. More... | |
const ValueT & | operator[] (HandleT key) const |
Returns the value associated with the given key or panics if there is no associated value. More... | |
Interface for attribute maps.
Attribute maps are associative containers which map from a handle to a value. A simple and obvious implementation of this interface is a hash map.
Attribute maps are used a lot in this library and are widely useful. A good example is an algorithm that needs to visit every face by traversing a mesh, but has to make sure to visit every face only once. In that algorithm, the best idea is to use an attribute map which maps from face to bool. This means that we associate a boolean value with each face. This boolean value can be used to store whether or not we already visited that face. Such a map would have the form AttributeMap<FaceHandle, bool>
.
Attribute maps are also used to store non-temporary data, like face-normals, vertex-colors, and much more. It's pretty simple, really: if you want to associate a value of type T
with a, say, vertex, simply create an AttributeMap<VertexHandle, T>
.
There are different implementations of this interface. The most important ones have a type alias in AttrMaps.hpp
. Please read the documentation in that file to learn more about different implementations.
HandleT | Key type of this map. Has to inherit from BaseHandle ! |
ValueT | The type to map to. |
Definition at line 75 of file AttributeMap.hpp.
typedef HandleT lvr2::AttributeMap< HandleT, ValueT >::HandleType |
The type of the handle used as key in this map.
Definition at line 80 of file AttributeMap.hpp.
typedef ValueT lvr2::AttributeMap< HandleT, ValueT >::ValueType |
The type of the value stored in this map.
Definition at line 87 of file AttributeMap.hpp.
|
pure virtual |
Returns an iterator over all keys of this map. The order of iteration is unspecified.
You can simply iterate over all keys of this map with a range-based for-loop:
Implemented in lvr2::ListMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, ValueT >, lvr2::VectorMap< lvr2::FaceHandle, lvr2::ClusterHandle >, lvr2::VectorMap< HandleT, lvr2::ClusterHandle >, lvr2::VectorMap< lvr2::Material >, lvr2::HashMap< HandleT, ValueT >, lvr2::HashMap< lvr2::FaceHandle, std::pair< float, float > >, and lvr2::HashMap< lvr2::VertexHandle, double >.
|
pure virtual |
Removes all values from the map.
Implemented in lvr2::ListMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, ValueT >, lvr2::VectorMap< lvr2::FaceHandle, lvr2::ClusterHandle >, lvr2::VectorMap< HandleT, lvr2::ClusterHandle >, lvr2::VectorMap< lvr2::Material >, lvr2::HashMap< HandleT, ValueT >, lvr2::HashMap< lvr2::FaceHandle, std::pair< float, float > >, and lvr2::HashMap< lvr2::VertexHandle, double >.
|
pure virtual |
Returns true iff the map contains a value associated with the given key.
Implemented in lvr2::HashMap< lvr2::VertexHandle, double >, lvr2::VectorMap< lvr2::Material >, lvr2::VectorMap< lvr2::FaceHandle, lvr2::ClusterHandle >, lvr2::HashMap< lvr2::FaceHandle, std::pair< float, float > >, lvr2::ListMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, lvr2::ClusterHandle >, and lvr2::HashMap< HandleT, ValueT >.
|
pure virtual |
Returns an iterator to the end of all keys.
Implemented in lvr2::ListMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, ValueT >, lvr2::VectorMap< lvr2::FaceHandle, lvr2::ClusterHandle >, lvr2::VectorMap< HandleT, lvr2::ClusterHandle >, lvr2::VectorMap< lvr2::Material >, lvr2::HashMap< HandleT, ValueT >, lvr2::HashMap< lvr2::FaceHandle, std::pair< float, float > >, and lvr2::HashMap< lvr2::VertexHandle, double >.
|
pure virtual |
Removes the value associated with the given key.
Implemented in lvr2::HashMap< lvr2::VertexHandle, double >, lvr2::VectorMap< lvr2::Material >, lvr2::VectorMap< lvr2::FaceHandle, lvr2::ClusterHandle >, lvr2::HashMap< lvr2::FaceHandle, std::pair< float, float > >, lvr2::ListMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, lvr2::ClusterHandle >, and lvr2::HashMap< HandleT, ValueT >.
|
pure virtual |
Returns the value associated with the given key or None if there is no associated value.
Note: this method can not be used to insert a new value. It only allows reading an already inserted value.
Implemented in lvr2::HashMap< lvr2::VertexHandle, double >, lvr2::VectorMap< lvr2::Material >, lvr2::VectorMap< lvr2::FaceHandle, lvr2::ClusterHandle >, lvr2::HashMap< lvr2::FaceHandle, std::pair< float, float > >, lvr2::ListMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, lvr2::ClusterHandle >, and lvr2::HashMap< HandleT, ValueT >.
|
pure virtual |
Returns the value associated with the given key or None if there is no associated value.
Note: this method can not be used to insert a new value. It only allows reading and modifying an already inserted value.
Implemented in lvr2::HashMap< lvr2::VertexHandle, double >, lvr2::VectorMap< lvr2::Material >, lvr2::VectorMap< lvr2::FaceHandle, lvr2::ClusterHandle >, lvr2::HashMap< lvr2::FaceHandle, std::pair< float, float > >, lvr2::ListMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, lvr2::ClusterHandle >, and lvr2::HashMap< HandleT, ValueT >.
|
pure virtual |
Inserts the given value at the given key position.
Implemented in lvr2::HashMap< lvr2::VertexHandle, double >, lvr2::VectorMap< lvr2::Material >, lvr2::HashMap< lvr2::FaceHandle, std::pair< float, float > >, lvr2::VectorMap< lvr2::FaceHandle, lvr2::ClusterHandle >, lvr2::ListMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, ValueT >, lvr2::HashMap< HandleT, ValueT >, and lvr2::VectorMap< HandleT, lvr2::ClusterHandle >.
|
pure virtual |
Returns the number of values in this map.
Implemented in lvr2::ListMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, ValueT >, lvr2::VectorMap< lvr2::FaceHandle, lvr2::ClusterHandle >, lvr2::VectorMap< HandleT, lvr2::ClusterHandle >, lvr2::VectorMap< lvr2::Material >, lvr2::HashMap< HandleT, ValueT >, lvr2::HashMap< lvr2::FaceHandle, std::pair< float, float > >, and lvr2::HashMap< lvr2::VertexHandle, double >.
ValueT& lvr2::AttributeMap< HandleT, ValueT >::operator[] | ( | HandleT | key | ) |
Returns the value associated with the given key or panics if there is no associated value.
Note: since this method panics, if there is no associated value, it cannot be used to insert new values. Use insert()
if you want to insert new values.
const ValueT& lvr2::AttributeMap< HandleT, ValueT >::operator[] | ( | HandleT | key | ) | const |
Returns the value associated with the given key or panics if there is no associated value.
Note: since this method panics, if there is no associated value, it cannot be used to insert new values. Use insert()
if you want to insert new values.