22 #ifndef vtkGenericDataArrayLookupHelper_h
23 #define vtkGenericDataArrayLookupHelper_h
35 template <
class ArrayTypeT>
44 : AssociatedArray(NULL),
55 if (this->AssociatedArray != array)
58 this->AssociatedArray = array;
68 std::lower_bound(this->SortedArray,
69 this->SortedArray + this->SortedArraySize, temp);
70 if (pos == (this->SortedArray + this->SortedArraySize))
74 if (pos->Value != elem)
86 std::pair<ValueWithIndex*, ValueWithIndex*>
range =
87 std::equal_range(this->SortedArray,
88 this->SortedArray + this->SortedArraySize, temp);
89 while (range.first != range.second)
103 free(this->SortedArray);
104 this->SortedArray = NULL;
105 this->SortedArraySize = 0;
113 struct ValueWithIndex
117 inline bool operator<(
const ValueWithIndex& other)
const
119 return this->Value < other.Value;
125 if (!this->AssociatedArray || this->SortedArray)
130 int numComps = this->AssociatedArray->GetNumberOfComponents();
131 this->SortedArraySize =
132 this->AssociatedArray->GetNumberOfTuples() * numComps;
134 if (this->SortedArraySize == 0)
139 this->SortedArray =
reinterpret_cast<ValueWithIndex*
>(
140 malloc(this->SortedArraySize *
sizeof(ValueWithIndex)));
141 for (
vtkIdType cc = 0,
max = this->AssociatedArray->GetNumberOfValues();
144 ValueWithIndex& item = this->SortedArray[cc];
145 item.Value = this->AssociatedArray->GetValue(cc);
148 std::sort(this->SortedArray, this->SortedArray + this->SortedArraySize);
151 ArrayTypeT *AssociatedArray;
152 ValueWithIndex* SortedArray;
void SetArray(ArrayTypeT *array)
void LookupValue(ValueType elem, vtkIdList *ids)
internal class used by vtkGenericDataArray to support LookupValue.
VTKCOMMONCORE_EXPORT bool operator<(const vtkUnicodeString &lhs, const vtkUnicodeString &rhs)
vtkIdType LookupValue(ValueType elem)
void ClearLookup()
Release any allocated memory for internal data-structures.
vtkGenericDataArrayLookupHelper()
list of point or cell ids
ArrayType::ValueType ValueType
~vtkGenericDataArrayLookupHelper()
vtkIdType InsertNextId(const vtkIdType vtkid)
Add the id specified to the end of the list.