Skip to content

Commit

Permalink
Merge topic 'data-array-update-lookup'
Browse files Browse the repository at this point in the history
c7ebe5b vtkDataArrayTemplate: Add a safe method to change an element with vtkVariant.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Brad King <brad.king@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Reviewed-by: Berk Geveci <berk.geveci@kitware.com>
Merge-request: !526
  • Loading branch information
tjcorona authored and kwrobot committed Aug 28, 2015
2 parents 98b27ba + c7ebe5b commit 84b126f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Common/Core/vtkDataArrayTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ class VTKCOMMONCORE_EXPORT vtkDataArrayTemplate:
// 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);
Expand Down
16 changes: 16 additions & 0 deletions Common/Core/vtkDataArrayTemplate.txx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 84b126f

Please sign in to comment.