Public Types | Public Member Functions | List of all members
lvr2::AttributeMap< HandleT, ValueT > Class Template Referenceabstract

Interface for attribute maps. More...

#include <AttributeMap.hpp>

Inheritance diagram for lvr2::AttributeMap< HandleT, ValueT >:
Inheritance graph
[legend]

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...
 

Detailed Description

template<typename HandleT, typename ValueT>
class lvr2::AttributeMap< HandleT, ValueT >

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.

Template Parameters
HandleTKey type of this map. Has to inherit from BaseHandle!
ValueTThe type to map to.

Definition at line 75 of file AttributeMap.hpp.

Member Typedef Documentation

◆ HandleType

template<typename HandleT , typename ValueT >
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.

◆ ValueType

template<typename HandleT , typename ValueT >
typedef ValueT lvr2::AttributeMap< HandleT, ValueT >::ValueType

The type of the value stored in this map.

Definition at line 87 of file AttributeMap.hpp.

Member Function Documentation

◆ begin()

template<typename HandleT , typename ValueT >
virtual AttributeMapHandleIteratorPtr<HandleT> lvr2::AttributeMap< HandleT, ValueT >::begin ( ) const
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:

for (auto handle: attributeMap) { ... }

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 >.

◆ clear()

template<typename HandleT , typename ValueT >
virtual void lvr2::AttributeMap< HandleT, ValueT >::clear ( )
pure virtual

◆ containsKey()

template<typename HandleT , typename ValueT >
virtual bool lvr2::AttributeMap< HandleT, ValueT >::containsKey ( HandleT  key) const
pure virtual

◆ end()

template<typename HandleT , typename ValueT >
virtual AttributeMapHandleIteratorPtr<HandleT> lvr2::AttributeMap< HandleT, ValueT >::end ( ) const
pure virtual

◆ erase()

template<typename HandleT , typename ValueT >
virtual boost::optional<ValueT> lvr2::AttributeMap< HandleT, ValueT >::erase ( HandleT  key)
pure virtual

◆ get() [1/2]

template<typename HandleT , typename ValueT >
virtual boost::optional<const ValueT&> lvr2::AttributeMap< HandleT, ValueT >::get ( HandleT  key) const
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 >.

◆ get() [2/2]

template<typename HandleT , typename ValueT >
virtual boost::optional<ValueT&> lvr2::AttributeMap< HandleT, ValueT >::get ( HandleT  key)
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 >.

◆ insert()

template<typename HandleT , typename ValueT >
virtual boost::optional<ValueT> lvr2::AttributeMap< HandleT, ValueT >::insert ( HandleT  key,
const ValueT &  value 
)
pure virtual

◆ numValues()

template<typename HandleT , typename ValueT >
virtual size_t lvr2::AttributeMap< HandleT, ValueT >::numValues ( ) const
pure virtual

◆ operator[]() [1/2]

template<typename HandleT , typename ValueT >
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.

◆ operator[]() [2/2]

template<typename HandleT , typename ValueT >
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.


The documentation for this class was generated from the following file:


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:27