Commit 8873e811 authored by David C. Lonie's avatar David C. Lonie
Browse files

Add vtkDataTypesCompare to compare data type tags.

This allows vtkIdType to be treated the same as its underlying
data type.
parent d1526635
......@@ -392,7 +392,7 @@ void vtkDataArray::GetData(vtkIdType tupleMin, vtkIdType tupleMax, int compMin,
void vtkDataArray::InterpolateTuple(vtkIdType i, vtkIdList *ptIndices,
vtkAbstractArray* source, double* weights)
{
if (this->GetDataType() != source->GetDataType())
if (!vtkDataTypesCompare(this->GetDataType(), source->GetDataType()))
{
vtkErrorMacro("Cannot InterpolateValue from array of type "
<< source->GetDataTypeAsString());
......@@ -456,7 +456,8 @@ void vtkDataArray::InterpolateTuple(vtkIdType i,
{
int type = this->GetDataType();
if (type != source1->GetDataType() || type != source2->GetDataType())
if (!vtkDataTypesCompare(type, source1->GetDataType()) ||
!vtkDataTypesCompare(type, source2->GetDataType()))
{
vtkErrorMacro("All arrays to InterpolateValue must be of same type.");
return;
......
......@@ -363,7 +363,7 @@ template <class T>
void vtkDataArrayTemplate<T>::SetTuple(vtkIdType i, vtkIdType j,
vtkAbstractArray* source)
{
if (source->GetDataType() != this->GetDataType())
if (!vtkDataTypesCompare(source->GetDataType(), this->GetDataType()))
{
vtkWarningMacro("Input and output array data types do not match.");
return;
......@@ -393,7 +393,7 @@ template<class T>
void vtkDataArrayTemplate<T>::InsertTuple(vtkIdType i, vtkIdType j,
vtkAbstractArray* source)
{
if (source->GetDataType() != this->GetDataType())
if (!vtkDataTypesCompare(source->GetDataType(), this->GetDataType()))
{
vtkWarningMacro("Input and output array data types do not match.");
return;
......@@ -446,7 +446,7 @@ template<class T>
void vtkDataArrayTemplate<T>::InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
vtkAbstractArray *source)
{
if (source->GetDataType() != this->GetDataType())
if (!vtkDataTypesCompare(source->GetDataType(), this->GetDataType()))
{
vtkWarningMacro("Input and output array data types do not match.");
return;
......@@ -528,7 +528,7 @@ void vtkDataArrayTemplate<T>::InsertTuples(vtkIdType dstStart, vtkIdType n,
return;
}
if (source->GetDataType() != this->GetDataType())
if (!vtkDataTypesCompare(source->GetDataType(), this->GetDataType()))
{
vtkWarningMacro("Input and output array data types do not match.");
return;
......@@ -551,7 +551,7 @@ template<class T>
vtkIdType vtkDataArrayTemplate<T>::InsertNextTuple(vtkIdType j,
vtkAbstractArray* source)
{
if (source->GetDataType() != this->GetDataType())
if (!vtkDataTypesCompare(source->GetDataType(), this->GetDataType()))
{
vtkWarningMacro("Input and output array data types do not match.");
return -1;
......
......@@ -255,16 +255,19 @@ typedef double vtkTypeFloat64;
#ifdef VTK_USE_64BIT_IDS
# if defined(VTK_TYPE_USE_LONG_LONG) && VTK_SIZEOF_LONG_LONG == 8
typedef long long vtkIdType;
# define VTK_ID_TYPE_IMPL VTK_LONG_LONG
# define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_LONG_LONG
# define VTK_ID_MIN VTK_LONG_LONG_MIN
# define VTK_ID_MAX VTK_LONG_LONG_MAX
# elif defined(VTK_SIZEOF_LONG) && VTK_SIZEOF_LONG == 8
typedef long vtkIdType;
# define VTK_ID_TYPE_IMPL VTK_LONG
# define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_LONG
# define VTK_ID_MIN VTK_LONG_MIN
# define VTK_ID_MAX VTK_LONG_MAX
# elif defined(VTK_TYPE_USE___INT64) && VTK_SIZEOF___INT64 == 8
typedef __int64 vtkIdType;
# define VTK_ID_TYPE_IMPL VTK___INT64
# define VTK_SIZEOF_ID_TYPE VTK_SIZEOF___INT64
# define VTK_ID_MIN VTK___INT64_MIN
# define VTK_ID_MAX VTK___INT64_MAX
......@@ -273,10 +276,25 @@ typedef __int64 vtkIdType;
# endif
#else
typedef int vtkIdType;
# define VTK_ID_TYPE_IMPL VTK_INT
# define VTK_SIZEOF_ID_TYPE VTK_SIZEOF_INT
# define VTK_ID_MIN VTK_INT_MIN
# define VTK_ID_MAX VTK_INT_MAX
#endif
#if defined(__cplusplus)
/* Description:
* Returns true if data type tags a and b point to the same data type. This
* is intended to handle vtkIdType, which does not have the same tag as its
* underlying data type.
* @note This method is only available when included from a C++ source file. */
inline int vtkDataTypesCompare(int a, int b)
{
return (a == b ||
((a == VTK_ID_TYPE || a == VTK_ID_TYPE_IMPL) &&
(b == VTK_ID_TYPE || b == VTK_ID_TYPE_IMPL)));
}
#endif
#endif
// VTK-HeaderTest-Exclude: vtkType.h
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment