19#ifndef vtkLabelMapLookup_h
20#define vtkLabelMapLookup_h
22#include "vtkCommonDataModelModule.h"
25#include <unordered_set>
28VTK_ABI_NAMESPACE_BEGIN
44 this->CachedValue =
static_cast<T
>(values[0]);
45 this->CachedOutValue =
static_cast<T
>(values[0]);
46 this->CachedOutValueInitialized =
false;
52 if (label == this->CachedValue)
57 else if (this->CachedOutValueInitialized && label == this->CachedOutValue)
81 bool IsLabelValue(T label)
override {
return label == this->CachedValue; }
93 for (
int vidx = 0; vidx < numValues; vidx++)
95 Map.push_back(
static_cast<T
>(values[vidx]));
108 if (std::find(this->Map.begin(), this->Map.end(), label) != this->Map.end())
110 this->CachedValue = label;
115 this->CachedOutValue = label;
116 this->CachedOutValueInitialized =
true;
126 std::unordered_set<T>
Map;
131 for (
int vidx = 0; vidx < numValues; vidx++)
133 Map.insert(
static_cast<T
>(values[vidx]));
146 if (this->Map.find(label) != this->Map.end())
148 this->CachedValue = label;
153 this->CachedOutValue = label;
154 this->CachedOutValueInitialized =
true;
165 const double* values,
vtkIdType numLabels)
172 else if (numLabels < 20)
bool IsLabelValue(T label) override
std::unordered_set< T > Map
LabelSet(const double *values, int numValues)
LabelVector(const double *values, int numValues)
bool IsLabelValue(T label) override
bool IsLabelValue(T label) override
SingleLabelValue(const double *values)
provide an efficient numeric label lookup
virtual ~vtkLabelMapLookup()=default
vtkLabelMapLookup(const double *values, int numValues)
bool CachedOutValueInitialized
static vtkLabelMapLookup< T > * CreateLabelLookup(const double *values, vtkIdType numLabels)
bool IsLabelValueInCache(T label, bool &inLabelSet)
virtual bool IsLabelValue(T label)=0