Commit c7ebe5bc authored by T.J. Corona's avatar T.J. Corona
Browse files

vtkDataArrayTemplate: Add a safe method to change an element with vtkVariant.

This fix is in reference to bug report 0013143.
parent 2e0acc8d
......@@ -212,6 +212,10 @@ public:
// Set a value in the array from a vtkVariant.
void SetVariantValue(vtkIdType id, vtkVariant value);
// Description:
// Insert a value in the array from a vtkVariant.
void InsertVariantValue(vtkIdType id, vtkVariant value);
// Description:
// Insert data at the end of the array. Return its location in the array.
vtkIdType InsertNextValue(T f);
......
......@@ -979,6 +979,22 @@ void vtkDataArrayTemplate<T>::SetVariantValue(vtkIdType id, vtkVariant value)
}
}
//----------------------------------------------------------------------------
template <class T>
void vtkDataArrayTemplate<T>::InsertVariantValue(vtkIdType id, vtkVariant value)
{
bool valid;
T toInsert = vtkVariantCast<T>(value, &valid);
if (valid)
{
this->InsertValue(id, toInsert);
}
else
{
vtkErrorMacro("unable to set value of type " << value.GetType());
}
}
//----------------------------------------------------------------------------
template <class T>
vtkIdType vtkDataArrayTemplate<T>::InsertNextValue(T f)
......
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