19 #ifndef vtkLabelMapLookup_h
20 #define vtkLabelMapLookup_h
22 #include "vtkCommonDataModelModule.h"
24 #include <unordered_set>
27 VTK_ABI_NAMESPACE_BEGIN
43 this->CachedValue =
static_cast<T
>(values[0]);
44 this->CachedOutValue =
static_cast<T
>(values[0]);
45 this->CachedOutValueInitialized =
false;
51 if (label == this->CachedValue)
56 else if (this->CachedOutValueInitialized && label == this->CachedOutValue)
92 for (
int vidx = 0; vidx < numValues; vidx++)
94 Map.push_back(static_cast<T>(values[vidx]));
107 if (std::find(this->Map.begin(), this->Map.end(), label) != this->Map.end())
109 this->CachedValue = label;
114 this->CachedOutValue = label;
115 this->CachedOutValueInitialized =
true;
122 template <
typename T>
125 std::unordered_set<T>
Map;
130 for (
int vidx = 0; vidx < numValues; vidx++)
132 Map.insert(static_cast<T>(values[vidx]));
145 if (this->Map.find(label) != this->Map.end())
147 this->CachedValue = label;
152 this->CachedOutValue = label;
153 this->CachedOutValueInitialized =
true;
162 template <
typename T>
164 const double* values,
vtkIdType numLabels)
171 else if (numLabels < 20)
181 VTK_ABI_NAMESPACE_END
std::unordered_set< T > Map
bool IsLabelValueInCache(T label, bool &inLabelSet)
bool CachedOutValueInitialized
provide an efficient numeric label lookup
virtual bool IsLabelValue(T label)=0
bool IsLabelValue(T label) override
SingleLabelValue(const double *values)
LabelVector(const double *values, int numValues)
LabelSet(const double *values, int numValues)
vtkLabelMapLookup(const double *values, int vtkNotUsed(numValues))
static vtkLabelMapLookup< T > * CreateLabelLookup(const double *values, vtkIdType numLabels)
bool IsLabelValue(T label) override
bool IsLabelValue(T label) override
virtual ~vtkLabelMapLookup()=default