Commit 467f62be authored by David C. Lonie's avatar David C. Lonie
Browse files

ScalarType->ValueType and ScalarReturnType->ReferenceType.

These names are more consistent with vtkTypedDataArray,
vtkDataArrayTemplate, and STL.

Also trimmed new class code to 80 characters wide because OCD.
parent dcd22bc2
......@@ -22,7 +22,8 @@ void Test()
array->SetNumberOfComponents(3);
array->SetNumberOfTuples(100);
vtkWriteableGenericDataArrayMacro(array,
for (vtkIdType tupleIdx=0, max=ARRAY->GetNumberOfTuples(); tupleIdx < max; ++tupleIdx)
for (vtkIdType tupleIdx=0, max=ARRAY->GetNumberOfTuples(); tupleIdx < max;
++tupleIdx)
{
ARRAY->SetComponentValue(tupleIdx, 0, 1);
ARRAY->SetComponentValue(tupleIdx, 1, 2);
......
......@@ -25,20 +25,20 @@
#include "vtkGenericDataArray.h"
#include "vtkBuffer.h"
template <class ScalarTypeT>
template <class ValueTypeT>
class vtkAoSDataArrayTemplate :
public vtkTypeTemplate<
vtkAoSDataArrayTemplate<ScalarTypeT>,
vtkGenericDataArray<vtkAoSDataArrayTemplate<ScalarTypeT>, ScalarTypeT>
vtkAoSDataArrayTemplate<ValueTypeT>,
vtkGenericDataArray<vtkAoSDataArrayTemplate<ValueTypeT>, ValueTypeT>
>
{
typedef vtkGenericDataArray<vtkAoSDataArrayTemplate<ValueTypeT>, ValueTypeT >
GenericDataArrayType;
public:
typedef vtkGenericDataArray<vtkAoSDataArrayTemplate<ScalarTypeT>, ScalarTypeT > GenericDataArrayType;
typedef GenericDataArrayType Superclass;
typedef vtkAoSDataArrayTemplate<ScalarTypeT> SelfType;
typedef typename Superclass::ScalarType ScalarType;
typedef typename Superclass::ScalarReturnType ScalarReturnType;
typedef typename Superclass::ScalarType ValueType; // to match vtkDataArrayTemplate.
typedef vtkAoSDataArrayTemplate<ValueTypeT> SelfType;
typedef typename Superclass::ValueType ValueType;
typedef typename Superclass::ReferenceType ReferenceType;
static vtkAoSDataArrayTemplate* New();
......@@ -46,34 +46,34 @@ public:
// Methods that are needed to be implemented by every vtkGenericDataArray
// subclass.
// **************************************************************************
inline ScalarReturnType GetValue(vtkIdType valueIdx) const
inline ReferenceType GetValue(vtkIdType valueIdx) const
{
return this->Buffer.GetBuffer()[valueIdx];
}
inline void GetTupleValue(vtkIdType tupleIdx, ScalarType* tuple) const
inline void GetTupleValue(vtkIdType tupleIdx, ValueType* tuple) const
{
const vtkIdType valueIdx = tupleIdx * this->NumberOfComponents;
std::copy(this->Buffer.GetBuffer() + valueIdx,
this->Buffer.GetBuffer() + valueIdx + this->NumberOfComponents,
tuple);
}
inline ScalarReturnType GetComponentValue(vtkIdType index, int comp) const
inline ReferenceType GetComponentValue(vtkIdType index, int comp) const
{
return this->Buffer.GetBuffer()[this->NumberOfComponents*index + comp];
}
inline void SetValue(vtkIdType valueIdx, ScalarType value)
inline void SetValue(vtkIdType valueIdx, ValueType value)
{
this->Buffer.GetBuffer()[valueIdx] = value;
this->DataChanged();
}
inline void SetTupleValue(vtkIdType tupleIdx, ScalarType* tuple)
inline void SetTupleValue(vtkIdType tupleIdx, ValueType* tuple)
{
const vtkIdType valueIdx = tupleIdx * this->NumberOfComponents;
std::copy(tuple, tuple + this->NumberOfComponents,
this->Buffer.GetBuffer() + valueIdx);
this->DataChanged();
}
inline void SetComponentValue(vtkIdType tupleIdx, int comp, ScalarType value)
inline void SetComponentValue(vtkIdType tupleIdx, int comp, ValueType value)
{
const vtkIdType valueIdx = tupleIdx * this->NumberOfComponents + comp;
this->SetValue(valueIdx, value);
......@@ -84,7 +84,7 @@ public:
// Get the address of a particular data index. Make sure data is allocated
// for the number of items requested. Set MaxId according to the number of
// data values requested.
ScalarType* WritePointer(vtkIdType id, vtkIdType number);
ValueType* WritePointer(vtkIdType id, vtkIdType number);
virtual void* WriteVoidPointer(vtkIdType id, vtkIdType number)
{ return this->WritePointer(id, number); }
......@@ -94,13 +94,13 @@ public:
// If the data is simply being iterated over, consider using
// vtkDataArrayIteratorMacro for safety and efficiency, rather than using this
// member directly.
ScalarType* GetPointer(vtkIdType id) { return this->Buffer.GetBuffer() + id; }
ValueType* GetPointer(vtkIdType id) { return this->Buffer.GetBuffer() + id; }
virtual void* GetVoidPointer(vtkIdType id) { return this->GetPointer(id); }
enum DeleteMethod
{
VTK_DATA_ARRAY_FREE=vtkBuffer<ScalarType>::VTK_DATA_ARRAY_FREE,
VTK_DATA_ARRAY_DELETE=vtkBuffer<ScalarType>::VTK_DATA_ARRAY_DELETE
VTK_DATA_ARRAY_FREE=vtkBuffer<ValueType>::VTK_DATA_ARRAY_FREE,
VTK_DATA_ARRAY_DELETE=vtkBuffer<ValueType>::VTK_DATA_ARRAY_DELETE
};
// Description:
......@@ -113,17 +113,17 @@ public:
// array will be deallocated. If the delete method is
// VTK_DATA_ARRAY_FREE, free() will be used. If the delete method is
// DELETE, delete[] will be used. The default is FREE.
void SetArray(ScalarType* array, vtkIdType size, int save, int deleteMethod);
void SetArray(ScalarType* array, vtkIdType size, int save)
void SetArray(ValueType* array, vtkIdType size, int save, int deleteMethod);
void SetArray(ValueType* array, vtkIdType size, int save)
{ this->SetArray(array, size, save, VTK_DATA_ARRAY_FREE); }
virtual void SetVoidArray(void* array, vtkIdType size, int save)
{ this->SetArray(static_cast<ScalarType*>(array), size, save); }
{ this->SetArray(static_cast<ValueType*>(array), size, save); }
virtual void SetVoidArray(void* array,
vtkIdType size,
int save,
int deleteMethod)
{
this->SetArray(static_cast<ScalarType*>(array), size, save, deleteMethod);
this->SetArray(static_cast<ValueType*>(array), size, save, deleteMethod);
}
//BTX
......@@ -140,15 +140,16 @@ protected:
bool ReallocateTuples(vtkIdType numTuples);
// **************************************************************************
vtkBuffer<ScalarType> Buffer;
ScalarType ValueRange[2]; // XXX
vtkBuffer<ValueType> Buffer;
ValueType ValueRange[2]; // XXX
bool SaveUserArray;
int DeleteMethod;
private:
vtkAoSDataArrayTemplate(const vtkAoSDataArrayTemplate&); // Not implemented.
void operator=(const vtkAoSDataArrayTemplate&); // Not implemented.
friend class vtkGenericDataArray<vtkAoSDataArrayTemplate<ScalarTypeT>, ScalarTypeT>;
friend class vtkGenericDataArray<vtkAoSDataArrayTemplate<ValueTypeT>,
ValueTypeT>;
//ETX
};
......
......@@ -14,26 +14,26 @@
=========================================================================*/
#define vtkAoSDataArrayTemplateT(returnType) \
template <class ScalarType> \
returnType vtkAoSDataArrayTemplate<ScalarType>
template <class ValueType> \
returnType vtkAoSDataArrayTemplate<ValueType>
//-----------------------------------------------------------------------------
vtkAoSDataArrayTemplateT(vtkAoSDataArrayTemplate<ScalarType>*)::New()
vtkAoSDataArrayTemplateT(vtkAoSDataArrayTemplate<ValueType>*)::New()
{
VTK_STANDARD_NEW_BODY(vtkAoSDataArrayTemplate<ScalarType>);
VTK_STANDARD_NEW_BODY(vtkAoSDataArrayTemplate<ValueType>);
}
//-----------------------------------------------------------------------------
template <class ScalarType>
vtkAoSDataArrayTemplate<ScalarType>::vtkAoSDataArrayTemplate()
template <class ValueType>
vtkAoSDataArrayTemplate<ValueType>::vtkAoSDataArrayTemplate()
{
this->SaveUserArray = false;
this->DeleteMethod = VTK_DATA_ARRAY_FREE;
}
//-----------------------------------------------------------------------------
template <class ScalarType>
vtkAoSDataArrayTemplate<ScalarType>::~vtkAoSDataArrayTemplate()
template <class ValueType>
vtkAoSDataArrayTemplate<ValueType>::~vtkAoSDataArrayTemplate()
{
this->SetArray(NULL, 0, 0);
this->Buffer.SetBuffer(NULL, 0);
......@@ -41,7 +41,7 @@ vtkAoSDataArrayTemplate<ScalarType>::~vtkAoSDataArrayTemplate()
//-----------------------------------------------------------------------------
vtkAoSDataArrayTemplateT(void)::SetArray(
ScalarType* array, vtkIdType size, int save, int deleteMethod)
ValueType* array, vtkIdType size, int save, int deleteMethod)
{
this->Buffer.SetBuffer(array, size, save, deleteMethod);
this->Size = size;
......@@ -50,9 +50,10 @@ vtkAoSDataArrayTemplateT(void)::SetArray(
}
//-----------------------------------------------------------------------------
template <class ScalarTypeT>
typename vtkAoSDataArrayTemplate<ScalarTypeT>::ScalarType*
vtkAoSDataArrayTemplate<ScalarTypeT>::WritePointer(vtkIdType id, vtkIdType number)
template <class ValueTypeT>
typename vtkAoSDataArrayTemplate<ValueTypeT>::ValueType*
vtkAoSDataArrayTemplate<ValueTypeT>::WritePointer(vtkIdType id,
vtkIdType number)
{
vtkIdType newSize = (id+number)+1;
if (newSize > this->Size)
......
......@@ -49,7 +49,8 @@ public:
inline ScalarType* GetBuffer() const
{ return this->Pointer; }
void SetBuffer(ScalarType* array, vtkIdType size, bool save=false, int deleteMethod=VTK_DATA_ARRAY_FREE)
void SetBuffer(ScalarType* array, vtkIdType size, bool save=false,
int deleteMethod=VTK_DATA_ARRAY_FREE)
{
if (this->Pointer != array)
{
......@@ -79,7 +80,8 @@ public:
this->SetBuffer(NULL, 0);
if (size > 0)
{
ScalarType* newArray = static_cast<ScalarType*>(malloc(size*sizeof(ScalarType)));
ScalarType* newArray =
static_cast<ScalarType*>(malloc(size * sizeof(ScalarType)));
if (newArray)
{
this->SetBuffer(newArray, size, false, VTK_DATA_ARRAY_FREE);
......@@ -102,14 +104,17 @@ public:
#endif
if (this->Pointer &&
(this->Save || this->DeleteMethod == VTK_DATA_ARRAY_DELETE || dontUseRealloc))
(this->Save || this->DeleteMethod == VTK_DATA_ARRAY_DELETE ||
dontUseRealloc))
{
ScalarType* newArray = static_cast<ScalarType*>(malloc(newsize*sizeof(ScalarType)));
ScalarType* newArray =
static_cast<ScalarType*>(malloc(newsize * sizeof(ScalarType)));
if (!newArray)
{
return false;
}
std::copy(this->Pointer, this->Pointer + std::min(this->Size, newsize), newArray);
std::copy(this->Pointer, this->Pointer + std::min(this->Size, newsize),
newArray);
// now save the new array and release the old one too.
this->SetBuffer(newArray, newsize, false, VTK_DATA_ARRAY_FREE);
}
......@@ -117,7 +122,8 @@ public:
{
// Try to reallocate with minimal memory usage and possibly avoid
// copying.
ScalarType* newArray = static_cast<ScalarType*>(realloc(this->Pointer, newsize*sizeof(ScalarType)));
ScalarType* newArray = static_cast<ScalarType*>(
realloc(this->Pointer, newsize * sizeof(ScalarType)));
if (!newArray)
{
return false;
......
......@@ -28,42 +28,43 @@
#include <cassert>
template<class DerivedT,
class ScalarTypeT,
class ScalarReturnTypeT=ScalarTypeT&>
class ValueTypeT,
class ReferenceTypeT=ValueTypeT&>
class vtkGenericDataArray : public vtkTypeTemplate<
vtkGenericDataArray<DerivedT, ScalarTypeT, ScalarReturnTypeT>,
vtkDataArray>
vtkGenericDataArray<DerivedT, ValueTypeT, ReferenceTypeT>,
vtkDataArray>
{
typedef
vtkGenericDataArray<DerivedT, ScalarTypeT, ScalarReturnTypeT> SelfType;
vtkGenericDataArray<DerivedT, ValueTypeT, ReferenceTypeT> SelfType;
public:
typedef ScalarTypeT ScalarType;
typedef ScalarReturnTypeT ScalarReturnType;
typedef ValueTypeT ValueType;
typedef ReferenceTypeT ReferenceType;
//----------------------------------------------------------------------------
// Methods that must be defined by the subclasses.
// Let's call these GenericDataArray concept methods.
inline ScalarReturnType GetValue(vtkIdType valueIdx) const
inline ReferenceType GetValue(vtkIdType valueIdx) const
{
return static_cast<const DerivedT*>(this)->GetValue(valueIdx);
}
inline void GetTupleValue(vtkIdType tupleIdx, ScalarType* tuple) const
inline void GetTupleValue(vtkIdType tupleIdx, ValueType* tuple) const
{
static_cast<const DerivedT*>(this)->GetTupleValue(tupleIdx, tuple);
}
inline ScalarReturnType GetComponentValue(vtkIdType tupleIdx, int comp) const
inline ReferenceType GetComponentValue(vtkIdType tupleIdx, int comp) const
{
return static_cast<const DerivedT*>(this)->GetComponentValue(tupleIdx, comp);
return static_cast<const DerivedT*>(this)->GetComponentValue(tupleIdx,
comp);
}
inline void SetValue(vtkIdType valueIdx, ScalarType value)
inline void SetValue(vtkIdType valueIdx, ValueType value)
{
static_cast<DerivedT*>(this)->SetValue(valueIdx, value);
}
inline void SetTupleValue(vtkIdType tupleIdx, ScalarType* tuple)
inline void SetTupleValue(vtkIdType tupleIdx, ValueType* tuple)
{
static_cast<DerivedT*>(this)->SetTupleValue(tupleIdx, tuple);
}
inline void SetComponentValue(vtkIdType tupleIdx, int comp, ScalarType value)
inline void SetComponentValue(vtkIdType tupleIdx, int comp, ValueType value)
{
static_cast<DerivedT*>(this)->SetComponentValue(tupleIdx, comp, value);
}
......@@ -74,11 +75,11 @@ public:
// Core methods.
virtual int GetDataType()
{
return vtkTypeTraits<ScalarType>::VTK_TYPE_ID;
return vtkTypeTraits<ValueType>::VTK_TYPE_ID;
}
virtual int GetDataTypeSize()
{
return static_cast<int>(sizeof(ScalarType));
return static_cast<int>(sizeof(ValueType));
}
//----------------------------------------------------------------------------
......@@ -119,14 +120,15 @@ public:
// let's keep the size an integral multiple of the number of components.
size = size < 0? 0 : size;
int numComps = this->GetNumberOfComponents() > 0? this->GetNumberOfComponents() : 1;
int numComps = this->GetNumberOfComponents() > 0
? this->GetNumberOfComponents() : 1;
vtkIdType numTuples = ceil(size/ static_cast<double>(numComps));
// NOTE: if numTuples is 0, AllocateTuples is expected to release the
// memory.
if (self->AllocateTuples(numTuples) == false)
{
vtkErrorMacro("Unable to allocate " << size
<< " elements of size " << sizeof(ScalarType)
<< " elements of size " << sizeof(ValueType)
<< " bytes. ");
#if !defined NDEBUG
// We're debugging, crash here preserving the stack
......@@ -172,7 +174,7 @@ public:
if (!self->ReallocateTuples(numTuples))
{
vtkErrorMacro("Unable to allocate " << numTuples * numComps
<< " elements of size " << sizeof(ScalarType)
<< " elements of size " << sizeof(ValueType)
<< " bytes. ");
#if !defined NDEBUG
// We're debugging, crash here preserving the stack
......@@ -252,8 +254,10 @@ public:
this->InsertTuple(nextTuple, source);
return nextTuple;
}
virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds, vtkAbstractArray *source);
virtual void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart, vtkAbstractArray* source);
virtual void InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
vtkAbstractArray *source);
virtual void InsertTuples(vtkIdType dstStart, vtkIdType n, vtkIdType srcStart,
vtkAbstractArray* source);
//----------------------------------------------------------------------------
// SetTuple methods.
......@@ -281,13 +285,13 @@ public:
virtual void SetVariantValue(vtkIdType idx, vtkVariant value);
//----------------------------------------------------------------------------
// All the lookup related methods We provide a default implementation that works
// using the iterator. Since these methods are virtual, a subclass can override
// these to provide faster alternatives.
// All the lookup related methods We provide a default implementation that
// works using the iterator. Since these methods are virtual, a subclass can
// override these to provide faster alternatives.
virtual vtkIdType LookupValue(vtkVariant value);
virtual vtkIdType LookupTypedValue(ScalarType value);
virtual vtkIdType LookupTypedValue(ValueType value);
virtual void LookupValue(vtkVariant value, vtkIdList* ids);
virtual void LookupTypedValue(ScalarType value, vtkIdList* ids);
virtual void LookupTypedValue(ValueType value, vtkIdList* ids);
virtual void ClearLookup()
{
this->Lookup.ClearLookup();
......@@ -312,14 +316,14 @@ public:
// Get a reference to the scalar value at a particular index.
// Index is value/component index assuming
// traditional VTK memory layout (array-of-structures).
ScalarReturnType GetValueReference(vtkIdType idx)
ReferenceType GetValueReference(vtkIdType idx)
{
return this->GetValue(idx);
}
// Description:
// Insert data at the end of the array. Return its location in the array.
vtkIdType InsertNextValue(ScalarType v)
vtkIdType InsertNextValue(ValueType v)
{
vtkIdType nextValueIdx = this->MaxId + 1;
if (nextValueIdx >= this->Size)
......@@ -336,7 +340,7 @@ public:
// Description:
// Insert data at a specified position in the array.
void InsertValue(vtkIdType idx, ScalarType v)
void InsertValue(vtkIdType idx, ValueType v)
{
vtkIdType tuple = idx / this->NumberOfComponents;
if (this->EnsureAccessToTuple(tuple))
......@@ -348,7 +352,7 @@ public:
// Description:
// Insert (memory allocation performed) the tuple into the ith location
// in the array.
void InsertTupleValue(vtkIdType idx, const ScalarType *t)
void InsertTupleValue(vtkIdType idx, const ValueType *t)
{
vtkIdType tuple = idx / this->NumberOfComponents;
if (this->EnsureAccessToTuple(tuple))
......@@ -359,7 +363,7 @@ public:
// Description:
// Insert (memory allocation performed) the tuple onto the end of the array.
vtkIdType InsertNextTupleValue(const ScalarType *t)
vtkIdType InsertNextTupleValue(const ValueType *t)
{
vtkIdType nextTuple = this->GetNumberOfTuples();
this->InsertTupleValue(nextTuple, t);
......@@ -388,7 +392,7 @@ protected:
bool EnsureAccessToTuple(vtkIdType tupleIdx)
{
if (tupleIdx < 0) { return false; }
vtkIdType expectedMaxId = (1 + tupleIdx) * this->GetNumberOfComponents() - 1;
vtkIdType expectedMaxId = (1 + tupleIdx) * this->NumberOfComponents - 1;
if (this->MaxId < expectedMaxId)
{
return this->Resize(tupleIdx + 1) != 0;
......
......@@ -66,7 +66,8 @@ vtkGenericDataArrayT(void)::InsertTuples(
for (vtkIdType cc=0; cc < numIds; ++cc)
{
vtkGenericDataArrayHelper::SetTuple(this, dstIds->GetId(cc), source, srcIds->GetId(cc));
vtkGenericDataArrayHelper::SetTuple(this, dstIds->GetId(cc), source,
srcIds->GetId(cc));
}
this->DataChanged();
}
......@@ -113,7 +114,8 @@ vtkGenericDataArrayT(void)::InsertTuples(vtkIdType dstStart, vtkIdType n,
for (vtkIdType cc=0; cc < n; ++cc)
{
vtkGenericDataArrayHelper::SetTuple(this, dstStart + cc, source, srcStart + cc);
vtkGenericDataArrayHelper::SetTuple(this, dstStart + cc, source,
srcStart + cc);
}
this->DataChanged();
}
......@@ -134,7 +136,8 @@ vtkGenericDataArrayT(void)::GetTuple(vtkIdType i, double * tuple)
}
//-----------------------------------------------------------------------------
vtkGenericDataArrayT(void)::SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray *source)
vtkGenericDataArrayT(void)::SetTuple(vtkIdType i, vtkIdType j,
vtkAbstractArray *source)
{
// XXX Should these be implemented in vtkDataArray?
vtkGenericDataArrayHelper::SetTuple(this, i, source, j);
......@@ -147,7 +150,7 @@ vtkGenericDataArrayT(void)::SetTuple(vtkIdType i, const float *source)
// XXX Should these be implemented in vtkDataArray?
for (int cc=0, max=this->GetNumberOfComponents(); cc < max; ++cc)
{
this->SetComponentValue(i, cc, static_cast<ScalarType>(source[cc]));
this->SetComponentValue(i, cc, static_cast<ValueType>(source[cc]));
}
this->DataChanged();
}
......@@ -158,7 +161,7 @@ vtkGenericDataArrayT(void)::SetTuple(vtkIdType i, const double *source)
// XXX Should these be implemented in vtkDataArray?
for (int cc=0, max=this->GetNumberOfComponents(); cc < max; ++cc)
{
this->SetComponentValue(i, cc, static_cast<ScalarType>(source[cc]));
this->SetComponentValue(i, cc, static_cast<ValueType>(source[cc]));
}
this->DataChanged();
}
......@@ -191,7 +194,8 @@ vtkGenericDataArrayT(void)::RemoveTuple(vtkIdType id)
{
for (int comp=0; comp < numComps; ++comp)
{
this->SetComponentValue(toTuple, comp, this->GetComponentValue(fromTuple, comp));
this->SetComponentValue(toTuple, comp,
this->GetComponentValue(fromTuple, comp));
}
}
this->SetNumberOfTuples(this->GetNumberOfTuples() - 1);
......@@ -222,7 +226,7 @@ vtkGenericDataArrayT(void*)::GetVoidPointer(vtkIdType)
vtkGenericDataArrayT(vtkIdType)::LookupValue(vtkVariant valueVariant)
{
bool valid = true;
ScalarType value = vtkVariantCast<ScalarType>(valueVariant, &valid);
ValueType value = vtkVariantCast<ValueType>(valueVariant, &valid);
if (valid)
{
return this->LookupTypedValue(value);
......@@ -231,7 +235,7 @@ vtkGenericDataArrayT(vtkIdType)::LookupValue(vtkVariant valueVariant)
}
//-----------------------------------------------------------------------------
vtkGenericDataArrayT(vtkIdType)::LookupTypedValue(ScalarType value)
vtkGenericDataArrayT(vtkIdType)::LookupTypedValue(ValueType value)
{
return this->Lookup.LookupValue(value);
}
......@@ -241,7 +245,7 @@ vtkGenericDataArrayT(void)::LookupValue(vtkVariant valueVariant, vtkIdList* ids)
{
ids->Reset();
bool valid = true;
ScalarType value = vtkVariantCast<ScalarType>(valueVariant, &valid);
ValueType value = vtkVariantCast<ValueType>(valueVariant, &valid);
if (valid)
{
this->LookupTypedValue(value, ids);
......@@ -249,17 +253,18 @@ vtkGenericDataArrayT(void)::LookupValue(vtkVariant valueVariant, vtkIdList* ids)
}
//-----------------------------------------------------------------------------
vtkGenericDataArrayT(void)::LookupTypedValue(ScalarType value, vtkIdList* ids)
vtkGenericDataArrayT(void)::LookupTypedValue(ValueType value, vtkIdList* ids)
{
ids->Reset();
this->Lookup.LookupValue(value, ids);
}
//-----------------------------------------------------------------------------
vtkGenericDataArrayT(void)::SetVariantValue(vtkIdType valueIdx, vtkVariant valueVariant)
vtkGenericDataArrayT(void)::SetVariantValue(vtkIdType valueIdx,
vtkVariant valueVariant)
{
bool valid = true;
ScalarType value = vtkVariantCast<ScalarType>(valueVariant, &valid);
ValueType value = vtkVariantCast<ValueType>(valueVariant, &valid);
if (valid)
{
this->SetValue(valueIdx, value);
......
......@@ -29,7 +29,8 @@ namespace
for (int cc=0, max=dest->GetNumberOfComponents(); cc < max; ++cc)
{
dest->SetComponentValue(destTuple, cc,
static_cast<typename ArrayDestType::ScalarType>(source->GetComponentValue(sourceTuple, cc)));
static_cast<typename ArrayDestType::ValueType>(
source->GetComponentValue(sourceTuple, cc)));
}
}
......@@ -77,7 +78,8 @@ void vtkGenericDataArrayHelper::SetTuple(
}
//----------------------------------------------------------------------------
void vtkGenericDataArrayHelper::GetTuple(vtkAbstractArray* source, vtkIdType tuple, double* buffer)
void vtkGenericDataArrayHelper::GetTuple(vtkAbstractArray* source,
vtkIdType tuple, double* buffer)
{
vtkConstGenericDataArrayMacro(source, vtkGetTuple(ARRAY, tuple, buffer));
}
......
......@@ -30,7 +30,8 @@ public:
static void SetTuple(vtkAbstractArray* dest, vtkIdType destTuple,
vtkAbstractArray* source, vtkIdType sourceTuple);
static void GetTuple(vtkAbstractArray* source, vtkIdType tuple, double* buffer);
static void GetTuple(vtkAbstractArray* source, vtkIdType tuple,
double* buffer);
//BTX
protected:
vtkGenericDataArrayHelper();
......
......@@ -34,7 +34,7 @@ class vtkGenericDataArrayLookupHelper
{
public:
typedef ArrayTypeT ArrayType;
typedef typename ArrayType::ScalarType ScalarType;
typedef typename ArrayType::ValueType ValueType;
// Constructor.
vtkGenericDataArrayLookupHelper(ArrayType& associatedArray)
......@@ -47,13 +47,14 @@ public:
this->ClearLookup();
}
vtkIdType LookupValue(ScalarType elem)
vtkIdType LookupValue(ValueType elem)
{
this->UpdateLookup();
ValueWithIndex temp;
temp.Value = elem;
ValueWithIndex* pos =
std::lower_bound(this->SortedArray, this->SortedArray + this->SortedArraySize, temp);
std::lower_bound(this->SortedArray,
this->SortedArray + this->SortedArraySize, temp);
if (pos == (this->SortedArray + this->SortedArraySize))
{
return -1;
......@@ -65,13 +66,14 @@ public:
return pos->Index;
}
void LookupValue(ScalarType elem, vtkIdList* ids)
void LookupValue(ValueType elem, vtkIdList* ids)
{
this->UpdateLookup();
ValueWithIndex temp;
temp.Value = elem;
std::pair<ValueWithIndex*, ValueWithIndex*> range =
std::equal_range(this->SortedArray, this->SortedArray + this->SortedArraySize, temp);
std::equal_range(this->SortedArray,
this->SortedArray + this->SortedArraySize, temp);
while (range.first != range.second)
{
// assert(range.first->Value == elem);
......@@ -95,7 +97,7 @@ private:
struct ValueWithIndex
{