include
lvr2
attrmaps
AttrMaps.hpp
Go to the documentation of this file.
1
28
/*
29
* AttributeMap.hpp
30
*
31
* @date 26.07.2017
32
*/
33
34
#ifndef LVR2_ATTRMAPS_ATTRMAPS_H_
35
#define LVR2_ATTRMAPS_ATTRMAPS_H_
36
37
#include "
lvr2/attrmaps/AttributeMap.hpp
"
38
#include "
lvr2/attrmaps/HashMap.hpp
"
39
#include "
lvr2/attrmaps/ListMap.hpp
"
40
#include "
lvr2/attrmaps/VectorMap.hpp
"
41
#include "
lvr2/geometry/Handles.hpp
"
42
43
namespace
lvr2
44
{
45
46
/*
47
* This file defines many useful type aliases for implementors of the
48
* `AttributeMap` interface.
49
*
50
* Choosing the correct implementation can have a huge impact on performance
51
* of your algorithm. There are three main implementations, where each is
52
* useful in a specific situation -- it mainly depends on the number of values
53
* in the map.
54
*
55
* - DenseAttrMap: if there is a value associated with almost all handles
56
* - SparseAttrMap: if the number of values is significantly less than the
57
* number of handles
58
* - TinyAttrMap: if there is only a very small number of values (say... 7).
59
*
60
* In some algorithms you will associate a value with *every* handle, e.g. a
61
* `VertexMap<bool> visited`. In this situation, it's useful to use the
62
* DenseAttrMap: it will be faster than the other two implementations. In other
63
* situations, however, you won't associate a value with most handles. Here,
64
* a DenseAttrMap would be a bad idea, because it has a memory requirement of
65
* O(biggest_handle_idx). This means, a lot of space would be wasted. Thus,
66
* rather use SparseAttrMap in that case. Each lookup will be a bit slower, but
67
* we won't waste memory. Lastely, the `TinyAttrMap` is useful if you know you
68
* will have very few values.
69
*
70
* It's useful to look at HOW these implementations work under the hood to
71
* understand the runtime and memory overhead of each:
72
*
73
* - DenseAttrMap: uses an array (VectorMap/std::vector)
74
* - SparseAttrMap: uses a hash map (HashMap/std::unordered_map)
75
* - TinyAttrMap: uses an unsorted list of key-value pairs
76
*
77
*
78
* Additionally, there are specific type aliases for the most common uses,
79
* like `FaceMap = AttributeMap<FaceHandle, T>`. You should use those when you
80
* can.
81
*/
82
83
// ---------------------------------------------------------------------------
84
// Generic aliases
85
template
<
typename
HandleT,
typename
ValueT>
using
DenseAttrMap
=
VectorMap<HandleT, ValueT>
;
86
template
<
typename
HandleT,
typename
ValueT>
using
SparseAttrMap
=
HashMap<HandleT, ValueT>
;
87
template
<
typename
HandleT,
typename
ValueT>
using
TinyAttrMap
=
ListMap<HandleT, ValueT>
;
88
89
// ---------------------------------------------------------------------------
90
// Handle-specific aliases
91
template
<
typename
ValueT>
using
ClusterMap
=
AttributeMap<ClusterHandle, ValueT>
;
92
template
<
typename
ValueT>
using
EdgeMap
=
AttributeMap<EdgeHandle, ValueT>
;
93
template
<
typename
ValueT>
using
FaceMap
=
AttributeMap<FaceHandle, ValueT>
;
94
template
<
typename
ValueT>
using
VertexMap
=
AttributeMap<VertexHandle, ValueT>
;
95
96
// ---------------------------------------------------------------------------
97
// Handle- and implementation-specific aliases
98
template
<
typename
ValueT>
using
DenseClusterMap
=
DenseAttrMap<ClusterHandle, ValueT>
;
99
template
<
typename
ValueT>
using
DenseEdgeMap
=
DenseAttrMap<EdgeHandle, ValueT>
;
100
template
<
typename
ValueT>
using
DenseFaceMap
=
DenseAttrMap<FaceHandle, ValueT>
;
101
template
<
typename
ValueT>
using
DenseVertexMap
=
DenseAttrMap<VertexHandle, ValueT>
;
102
103
template
<
typename
ValueT>
using
SparseClusterMap
=
SparseAttrMap<ClusterHandle, ValueT>
;
104
template
<
typename
ValueT>
using
SparseEdgeMap
=
SparseAttrMap<EdgeHandle, ValueT>
;
105
template
<
typename
ValueT>
using
SparseFaceMap
=
SparseAttrMap<FaceHandle, ValueT>
;
106
template
<
typename
ValueT>
using
SparseVertexMap
=
SparseAttrMap<VertexHandle, ValueT>
;
107
108
template
<
typename
ValueT>
using
TinyClusterMap
=
TinyAttrMap<ClusterHandle, ValueT>
;
109
template
<
typename
ValueT>
using
TinyEdgeMap
=
TinyAttrMap<EdgeHandle, ValueT>
;
110
template
<
typename
ValueT>
using
TinyFaceMap
=
TinyAttrMap<FaceHandle, ValueT>
;
111
template
<
typename
ValueT>
using
TinyVertexMap
=
TinyAttrMap<VertexHandle, ValueT>
;
112
113
template
<
typename
ValueT>
using
DenseVertexMapOptional
= boost::optional<DenseVertexMap<ValueT>>;
114
}
// namespace lvr2
115
116
#endif
/* LVR2_ATTRMAPS_ATTRMAPS_H_ */
Handles.hpp
lvr2::HashMap
Definition:
HashMap.hpp:47
lvr2::AttributeMap
Interface for attribute maps.
Definition:
AttributeMap.hpp:75
lvr2::DenseVertexMapOptional
boost::optional< DenseVertexMap< ValueT > > DenseVertexMapOptional
Definition:
AttrMaps.hpp:113
VectorMap.hpp
ListMap.hpp
lvr2::ListMap
A simple implementation of AttributeMap for a small number of values.
Definition:
ListMap.hpp:65
lvr2::VectorMap
A map with constant lookup overhead using small-ish integer-keys.
Definition:
VectorMap.hpp:60
HashMap.hpp
AttributeMap.hpp
lvr2
Definition:
BaseBufferManipulators.hpp:39
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:22