Template Class AttributeMap
Defined in File AttributeMap.hpp
Inheritance Relationships
Derived Types
public lvr2::HashMap< VertexHandle, double >(Template Class HashMap)public lvr2::HashMap< FaceHandle, std::pair< float, float > >(Template Class HashMap)public lvr2::VectorMap< HandleT, lvr2::ClusterHandle >(Template Class VectorMap)public lvr2::VectorMap< FaceHandle, lvr2::ClusterHandle >(Template Class VectorMap)public lvr2::VectorMap< lvr2::Material >(Template Class VectorMap)public lvr2::HashMap< HandleT, ValueT >(Template Class HashMap)public lvr2::ListMap< HandleT, ValueT >(Template Class ListMap)public lvr2::VectorMap< HandleT, ValueT >(Template Class VectorMap)
Class Documentation
-
template<typename HandleT, typename ValueT>
class AttributeMap 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
Twith a, say, vertex, simply create anAttributeMap<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:
HandleT – Key type of this map. Has to inherit from
BaseHandle!ValueT – The type to map to.
Subclassed by lvr2::HashMap< VertexHandle, double >, lvr2::HashMap< FaceHandle, std::pair< float, float > >, lvr2::VectorMap< HandleT, lvr2::ClusterHandle >, lvr2::VectorMap< FaceHandle, lvr2::ClusterHandle >, lvr2::VectorMap< lvr2::Material >, lvr2::HashMap< HandleT, ValueT >, lvr2::ListMap< HandleT, ValueT >, lvr2::VectorMap< HandleT, ValueT >
Public Types
Public Functions
-
virtual bool containsKey(HandleT key) const = 0
Returns true iff the map contains a value associated with the given key.
-
virtual boost::optional<ValueT> insert(HandleT key, const ValueT &value) = 0
Inserts the given value at the given key position.
- Returns:
If there was a value associated with the given key before inserting the new value, the old value is returned. None otherwise.
-
virtual boost::optional<ValueT> erase(HandleT key) = 0
Removes the value associated with the given key.
- Returns:
If there was a value associated with the key, it is returned. None otherwise.
-
virtual void clear() = 0
Removes all values from the map.
-
virtual boost::optional<ValueT&> get(HandleT key) = 0
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.
-
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.
Note: this method can not be used to insert a new value. It only allows reading an already inserted value.
-
virtual size_t numValues() const = 0
Returns the number of values in this map.
-
virtual AttributeMapHandleIteratorPtr<HandleT> begin() const = 0
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) { ... }
-
virtual AttributeMapHandleIteratorPtr<HandleT> end() const = 0
Returns an iterator to the end of all keys.