Commit 0d71a308 authored by David C. Lonie's avatar David C. Lonie

Replace SafeDownCast calls on arrays with vtkArrayDownCast.

SafeDownCast performs a series of virtual calls and string comparisons,
which is quite slow, especially when used in worker functions.

vtkArrayDownCast will switch between SafeDownCast and the more
efficient FastDownCast (only available for common vtkAbstractArray
subclasses) depending on whether or not FastDownCast is defined for
the specific array type.
parent d97bea99
......@@ -110,7 +110,7 @@ int vtkDataSetToPiston::RequestData(vtkInformation *vtkNotUsed(request),
return 1;
}
int association;
vtkFloatArray *inArray = vtkFloatArray::SafeDownCast(
vtkFloatArray *inArray = vtkArrayDownCast<vtkFloatArray>(
this->GetInputArrayToProcess(0,id, association));
//this filter expects that input has point associated float scalars
if (!inArray
......
......@@ -241,15 +241,15 @@ void vtkPistonMapper::RenderOnCPU()
int vertsPer = vtkpiston::QueryVertsPer(id);
vtkFloatArray *normals = vtkFloatArray::SafeDownCast(
vtkFloatArray *normals = vtkArrayDownCast<vtkFloatArray>(
od->GetPointData()->GetNormals());
if (!normals)
{
normals = vtkFloatArray::SafeDownCast(
normals = vtkArrayDownCast<vtkFloatArray>(
od->GetPointData()->GetArray("Normals"));
}
vtkFloatArray *scalars = vtkFloatArray::SafeDownCast(
vtkFloatArray *scalars = vtkArrayDownCast<vtkFloatArray>(
od->GetPointData()->GetScalars());
if (scalars)
{
......
......@@ -123,7 +123,7 @@ void vtkChartBox::Update()
for (int i = 0; i < nbCols; ++i)
{
vtkDataArray* array =
vtkDataArray::SafeDownCast(table->GetColumnByName(
vtkArrayDownCast<vtkDataArray>(table->GetColumnByName(
this->VisibleColumns->GetValue(i)));
if (array)
{
......@@ -172,7 +172,7 @@ bool vtkChartBox::Paint(vtkContext2D *painter)
this->AnnotationLink->GetMTime() > this->Storage->Plot->GetMTime())
{
vtkSelectionNode *node = selection->GetNode(0);
idArray = vtkIdTypeArray::SafeDownCast(node->GetSelectionList());
idArray = vtkArrayDownCast<vtkIdTypeArray>(node->GetSelectionList());
this->Storage->Plot->SetSelection(idArray);
}
}
......
......@@ -139,7 +139,8 @@ void vtkChartParallelCoordinates::Update()
{
double range[2];
vtkDataArray* array =
vtkDataArray::SafeDownCast(table->GetColumnByName(this->VisibleColumns->GetValue(i)));
vtkArrayDownCast<vtkDataArray>(table->GetColumnByName(
this->VisibleColumns->GetValue(i)));
if (array)
{
array->GetRange(range);
......@@ -181,7 +182,8 @@ bool vtkChartParallelCoordinates::Paint(vtkContext2D *painter)
{
vtkSelectionNode *node = selection->GetNumberOfNodes() > 0?
selection->GetNode(0) : NULL;
idArray = node? vtkIdTypeArray::SafeDownCast(node->GetSelectionList()) : NULL;
idArray = node? vtkArrayDownCast<vtkIdTypeArray>(node->GetSelectionList())
: NULL;
this->Storage->Plot->SetSelection(idArray);
}
}
......
......@@ -223,7 +223,7 @@ void vtkChartXY::Update()
vtkSelectionNode *node = selection->GetNumberOfNodes() > 0?
selection->GetNode(0) : NULL;
vtkIdTypeArray *idArray = node?
vtkIdTypeArray::SafeDownCast(node->GetSelectionList()) : NULL;
vtkArrayDownCast<vtkIdTypeArray>(node->GetSelectionList()) : NULL;
std::vector<vtkPlot*>::iterator it =
this->ChartPrivate->plots.begin();
for ( ; it != this->ChartPrivate->plots.end(); ++it)
......@@ -238,7 +238,7 @@ void vtkChartXY::Update()
{
vtkSelectionNode *node = selection->GetNode(i);
vtkIdTypeArray *idArray =
vtkIdTypeArray::SafeDownCast(node->GetSelectionList());
vtkArrayDownCast<vtkIdTypeArray>(node->GetSelectionList());
vtkPlot *selectionPlot =
vtkPlot::SafeDownCast(node->GetProperties()->Get(vtkSelectionNode::PROP()));
// Now iterate through the plots to update selection data
......@@ -261,7 +261,7 @@ void vtkChartXY::Update()
{
vtkSelectionNode *node = selection->GetNode(i);
vtkIdTypeArray *selectedColumns =
vtkIdTypeArray::SafeDownCast(node->GetSelectionList());
vtkArrayDownCast<vtkIdTypeArray>(node->GetSelectionList());
vtkIdType* ptr = reinterpret_cast<vtkIdType*>(selectedColumns->GetVoidPointer(0));
for (vtkIdType j = 0; j < selectedColumns->GetNumberOfTuples(); ++j)
{
......@@ -2062,7 +2062,7 @@ bool vtkChartXY::MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse)
selection->GetNode(0) : NULL;
if (node)
{
oldSelection->DeepCopy(vtkIdTypeArray::SafeDownCast(node->GetSelectionList()));
oldSelection->DeepCopy(vtkArrayDownCast<vtkIdTypeArray>(node->GetSelectionList()));
}
}
vtkNew<vtkIdTypeArray> plotSelection;
......
......@@ -219,7 +219,7 @@ void vtkChartXYZ::Update()
{
vtkSelectionNode *node = selection->GetNode(0);
vtkIdTypeArray *idArray =
vtkIdTypeArray::SafeDownCast(node->GetSelectionList());
vtkArrayDownCast<vtkIdTypeArray>(node->GetSelectionList());
for (size_t i = 0; i < this->Plots.size(); ++i)
{
this->Plots[i]->SetSelection(idArray);
......
......@@ -134,11 +134,11 @@ void vtkPlot3D::SetInputData(vtkTable *input, const vtkStdString &xName,
{
// Copy the points into our data structure for rendering - pack x, y, z...
vtkDataArray *xArr =
vtkDataArray::SafeDownCast(input->GetColumnByName(xName.c_str()));
vtkArrayDownCast<vtkDataArray>(input->GetColumnByName(xName.c_str()));
vtkDataArray *yArr =
vtkDataArray::SafeDownCast(input->GetColumnByName(yName.c_str()));
vtkArrayDownCast<vtkDataArray>(input->GetColumnByName(yName.c_str()));
vtkDataArray *zArr =
vtkDataArray::SafeDownCast(input->GetColumnByName(zName.c_str()));
vtkArrayDownCast<vtkDataArray>(input->GetColumnByName(zName.c_str()));
// Ensure that we have valid data arrays, and that they are of the same length.
assert(xArr);
......@@ -190,7 +190,7 @@ void vtkPlot3D::SetInputData(vtkTable *input, const vtkStdString &xName,
this->SetInputData(input, xName, yName, zName);
vtkDataArray *colorArr =
vtkDataArray::SafeDownCast(input->GetColumnByName(colorName.c_str()));
vtkArrayDownCast<vtkDataArray>(input->GetColumnByName(colorName.c_str()));
this->SetColors(colorArr);
}
......
......@@ -547,7 +547,7 @@ void vtkPlotArea::Update()
cache.Reset();
cache.ValidPointMask = (this->ValidPointMaskName.empty() == false)?
vtkCharArray::SafeDownCast(table->GetColumnByName(this->ValidPointMaskName)) : NULL;
vtkArrayDownCast<vtkCharArray>(table->GetColumnByName(this->ValidPointMaskName)) : NULL;
cache.SetPoints(
this->UseIndexForXSeries? NULL: this->Data->GetInputArrayToProcess(0, table),
this->Data->GetInputArrayToProcess(1, table),
......
......@@ -83,7 +83,7 @@ void vtkPlotBag::Update()
// Check if we have an input
vtkTable *table = this->Data->GetInput();
vtkDataArray *density = vtkDataArray::SafeDownCast(
vtkDataArray *density = vtkArrayDownCast<vtkDataArray>(
this->Data->GetInputAbstractArrayToProcess(2, this->GetInput()));
if (!table || !density)
{
......@@ -311,7 +311,7 @@ vtkStringArray* vtkPlotBag::GetLabels()
else if (this->Data->GetInput())
{
this->AutoLabels = vtkSmartPointer<vtkStringArray>::New();
vtkDataArray *density = vtkDataArray::SafeDownCast(
vtkDataArray *density = vtkArrayDownCast<vtkDataArray>(
this->Data->GetInputAbstractArrayToProcess(2, this->GetInput()));
if (density)
{
......@@ -332,7 +332,7 @@ vtkStdString vtkPlotBag::GetTooltipLabel(const vtkVector2d &plotPos,
this->TooltipDefaultLabelFormat : this->TooltipLabelFormat;
// Parse TooltipLabelFormat and build tooltipLabel
bool escapeNext = false;
vtkDataArray *density = vtkDataArray::SafeDownCast(
vtkDataArray *density = vtkArrayDownCast<vtkDataArray>(
this->Data->GetInputAbstractArrayToProcess(2, this->GetInput()));
for (size_t i = 0; i < format.length(); ++i)
{
......@@ -372,7 +372,7 @@ vtkStdString vtkPlotBag::GetTooltipLabel(const vtkVector2d &plotPos,
break;
case 'C':
{
vtkAbstractArray *colName = vtkAbstractArray::SafeDownCast(
vtkAbstractArray *colName = vtkArrayDownCast<vtkAbstractArray>(
this->GetInput()->GetColumnByName("ColName"));
std::stringstream ss;
if (colName)
......
......@@ -187,11 +187,11 @@ class vtkPlotBarSegment : public vtkObject {
painter->ApplyBrush(brush);
int n = this->Points->GetNumberOfPoints();
float *f =
vtkFloatArray::SafeDownCast(this->Points->GetData())->GetPointer(0);
vtkArrayDownCast<vtkFloatArray>(this->Points->GetData())->GetPointer(0);
float *p = NULL;
if (this->Previous)
{
p = vtkFloatArray::SafeDownCast(
p = vtkArrayDownCast<vtkFloatArray>(
this->Previous->Points->GetData())->GetPointer(0);
}
......@@ -689,7 +689,7 @@ void vtkPlotBar::GetBounds(double bounds[4], bool unscaled)
for ( it = this->Private->AdditionalSeries.begin(); it !=
this->Private->AdditionalSeries.end(); ++it )
{
y = vtkDataArray::SafeDownCast(table->GetColumnByName((*it).second.c_str()));
y = vtkArrayDownCast<vtkDataArray>(table->GetColumnByName((*it).second.c_str()));
y->GetRange(yRange);
bounds[valuesHigh] += yRange[1];
}
......@@ -870,7 +870,7 @@ bool vtkPlotBar::UpdateTableCache(vtkTable *table)
if (this->ScalarVisibility && !this->ColorArrayName.empty())
{
vtkDataArray* c =
vtkDataArray::SafeDownCast(table->GetColumnByName(this->ColorArrayName));
vtkArrayDownCast<vtkDataArray>(table->GetColumnByName(this->ColorArrayName));
// TODO: Should add support for categorical coloring & try enum lookup
if (c)
{
......@@ -896,7 +896,7 @@ bool vtkPlotBar::UpdateTableCache(vtkTable *table)
for ( it = this->Private->AdditionalSeries.begin();
it != this->Private->AdditionalSeries.end(); ++it )
{
y = vtkDataArray::SafeDownCast(table->GetColumnByName((*it).second.c_str()));
y = vtkArrayDownCast<vtkDataArray>(table->GetColumnByName((*it).second.c_str()));
prev = this->Private->AddSegment(x,y, this->GetXAxis(), this->GetYAxis(),prev);
}
......@@ -1025,7 +1025,7 @@ void vtkPlotBar::SelectColorArray(vtkIdType arrayNum)
vtkWarningMacro(<< "SelectColorArray called with no input table set.");
return;
}
vtkDataArray *col = vtkDataArray::SafeDownCast(table->GetColumn(arrayNum));
vtkDataArray *col = vtkArrayDownCast<vtkDataArray>(table->GetColumn(arrayNum));
// TODO: Should add support for categorical coloring & try enum lookup
if (!col)
{
......
......@@ -336,7 +336,7 @@ bool vtkPlotBox::UpdateTableCache(vtkTable *table)
std::vector<double>& col = this->Storage->at(i);
col.resize(rows);
vtkSmartPointer<vtkDataArray> data =
vtkDataArray::SafeDownCast(table->GetColumnByName(cols->GetValue(i)));
vtkArrayDownCast<vtkDataArray>(table->GetColumnByName(cols->GetValue(i)));
if (!data)
{
continue;
......
......@@ -133,7 +133,7 @@ bool vtkPlotFunctionalBag::UpdateTableCache(vtkTable *table)
{
// The input array has 2 components, this must be a bag
// with {miny,maxy} tuples
vtkDoubleArray* darr = vtkDoubleArray::SafeDownCast(array[1]);
vtkDoubleArray* darr = vtkArrayDownCast<vtkDoubleArray>(array[1]);
this->LogX = this->XAxis->GetLogScaleActive();
this->LogY = this->YAxis->GetLogScaleActive();
......
......@@ -324,7 +324,7 @@ bool vtkPlotParallelCoordinates::UpdateTableCache(vtkTable *table)
vtkAxis* axis = parent->GetAxis(i);
col.resize(rows);
vtkSmartPointer<vtkDataArray> data =
vtkDataArray::SafeDownCast(table->GetColumnByName(cols->GetValue(i)));
vtkArrayDownCast<vtkDataArray>(table->GetColumnByName(cols->GetValue(i)));
if (!data)
{
if (table->GetColumnByName(cols->GetValue(i))->IsA("vtkStringArray"))
......@@ -341,12 +341,12 @@ bool vtkPlotParallelCoordinates::UpdateTableCache(vtkTable *table)
vtkTable* stringTable = vtkTable::SafeDownCast(stoc->GetOutput(1));
if (table2)
{
data = vtkDataArray::SafeDownCast(table2->GetColumnByName("enumPC"));
data = vtkArrayDownCast<vtkDataArray>(table2->GetColumnByName("enumPC"));
}
if (stringTable && stringTable->GetColumnByName("Strings"))
{
vtkStringArray* strings =
vtkStringArray::SafeDownCast(stringTable->GetColumnByName("Strings"));
vtkArrayDownCast<vtkStringArray>(stringTable->GetColumnByName("Strings"));
vtkSmartPointer<vtkDoubleArray> arr =
vtkSmartPointer<vtkDoubleArray>::New();
for (vtkIdType j = 0; j < strings->GetNumberOfTuples(); ++j)
......@@ -389,7 +389,7 @@ bool vtkPlotParallelCoordinates::UpdateTableCache(vtkTable *table)
if (this->ScalarVisibility && !this->ColorArrayName.empty())
{
vtkDataArray* c =
vtkDataArray::SafeDownCast(table->GetColumnByName(this->ColorArrayName));
vtkArrayDownCast<vtkDataArray>(table->GetColumnByName(this->ColorArrayName));
// TODO: Should add support for categorical coloring & try enum lookup
if (c)
{
......@@ -497,7 +497,7 @@ void vtkPlotParallelCoordinates::SelectColorArray(vtkIdType arrayNum)
vtkDebugMacro(<< "SelectColorArray called with no input table set.");
return;
}
vtkDataArray *col = vtkDataArray::SafeDownCast(table->GetColumn(arrayNum));
vtkDataArray *col = vtkArrayDownCast<vtkDataArray>(table->GetColumn(arrayNum));
// TODO: Should add support for categorical coloring & try enum lookup
if (!col)
{
......
......@@ -121,7 +121,7 @@ void vtkPlotPoints::Update()
if (table && !this->ValidPointMaskName.empty() &&
table->GetColumnByName(this->ValidPointMaskName))
{
this->ValidPointMask = vtkCharArray::SafeDownCast(
this->ValidPointMask = vtkArrayDownCast<vtkCharArray>(
table->GetColumnByName(this->ValidPointMaskName));
}
else
......@@ -238,7 +238,7 @@ bool vtkPlotPoints::Paint(vtkContext2D *painter)
if (this->Selection->GetMTime() > this->SelectedPoints->GetMTime() ||
this->GetMTime() > this->SelectedPoints->GetMTime())
{
float *f = vtkFloatArray::SafeDownCast(
float *f = vtkArrayDownCast<vtkFloatArray>(
this->Points->GetData())->GetPointer(0);
int nSelected(static_cast<int>(this->Selection->GetNumberOfTuples()));
this->SelectedPoints->SetNumberOfComponents(2);
......@@ -731,7 +731,7 @@ bool vtkPlotPoints::UpdateTableCache(vtkTable *table)
if (this->ScalarVisibility && !this->ColorArrayName.empty())
{
vtkDataArray* c =
vtkDataArray::SafeDownCast(table->GetColumnByName(this->ColorArrayName));
vtkArrayDownCast<vtkDataArray>(table->GetColumnByName(this->ColorArrayName));
// TODO: Should add support for categorical coloring & try enum lookup
if (c)
{
......@@ -1008,7 +1008,7 @@ void vtkPlotPoints::SelectColorArray(vtkIdType arrayNum)
vtkDebugMacro(<< "SelectColorArray called with no input table set.");
return;
}
vtkDataArray *col = vtkDataArray::SafeDownCast(table->GetColumn(arrayNum));
vtkDataArray *col = vtkArrayDownCast<vtkDataArray>(table->GetColumn(arrayNum));
// TODO: Should add support for categorical coloring & try enum lookup
if (!col)
{
......
......@@ -338,10 +338,10 @@ class vtkPlotStackedSegment : public vtkObject {
painter->ApplyPen(pen);
painter->ApplyBrush(brush);
int n = this->Points->GetNumberOfPoints();
float *data_extent = vtkFloatArray::SafeDownCast(this->Points->GetData())->GetPointer(0);
float *data_extent = vtkArrayDownCast<vtkFloatArray>(this->Points->GetData())->GetPointer(0);
float *data_base = 0;
if (this->Previous)
data_base = vtkFloatArray::SafeDownCast(this->Previous->Points->GetData())->GetPointer(0);
data_base = vtkArrayDownCast<vtkFloatArray>(this->Previous->Points->GetData())->GetPointer(0);
if (n >= 2)
{
......@@ -796,7 +796,7 @@ bool vtkPlotStacked::UpdateTableCache(vtkTable *table)
for ( it = this->Private->AdditionalSeries.begin(); it != this->Private->AdditionalSeries.end(); ++it )
{
y = vtkDataArray::SafeDownCast(table->GetColumnByName((*it).second.c_str()));
y = vtkArrayDownCast<vtkDataArray>(table->GetColumnByName((*it).second.c_str()));
prev = this->Private->AddSegment(x,y,prev);
}
......
......@@ -219,7 +219,7 @@ bool PopulateHistograms(vtkTable *input, vtkTable *output, vtkStringArray *s,
double minmax[2] = { 0.0, 0.0 };
vtkStdString name(s->GetValue(i));
vtkDataArray *in =
vtkDataArray::SafeDownCast(input->GetColumnByName(name.c_str()));
vtkArrayDownCast<vtkDataArray>(input->GetColumnByName(name.c_str()));
if (in)
{
// The bin values are the centers, extending +/- half an inc either side
......@@ -231,7 +231,7 @@ bool PopulateHistograms(vtkTable *input, vtkTable *output, vtkStringArray *s,
double inc = (minmax[1] - minmax[0]) / (NumberOfBins) * 1.001;
double halfInc = inc / 2.0;
vtkSmartPointer<vtkFloatArray> extents =
vtkFloatArray::SafeDownCast(
vtkArrayDownCast<vtkFloatArray>(
output->GetColumnByName(vtkStdString(name + "_extents").c_str()));
if (!extents)
{
......@@ -246,7 +246,7 @@ bool PopulateHistograms(vtkTable *input, vtkTable *output, vtkStringArray *s,
extents->SetValue(j, min + j * inc);
}
vtkSmartPointer<vtkIntArray> populations =
vtkIntArray::SafeDownCast(
vtkArrayDownCast<vtkIntArray>(
output->GetColumnByName(vtkStdString(name + "_pops").c_str()));
if (!populations)
{
......@@ -829,7 +829,7 @@ void vtkScatterPlotMatrix::SetColumnVisibility(const vtkStdString &name,
}
// Add the column to the end of the list if it is a numeric column
if (this->Input && this->Input->GetColumnByName(name.c_str()) &&
vtkDataArray::SafeDownCast(this->Input->GetColumnByName(name.c_str())))
vtkArrayDownCast<vtkDataArray>(this->Input->GetColumnByName(name.c_str())))
{
this->VisibleColumns->InsertNextValue(name);
this->Private->VisibleColumnsModified = true;
......@@ -1300,7 +1300,7 @@ void vtkScatterPlotMatrix::UpdateAxes()
double range[2] = { 0, 0 };
std::string name(this->VisibleColumns->GetValue(i));
vtkDataArray *arr =
vtkDataArray::SafeDownCast(this->Input->GetColumnByName(name.c_str()));
vtkArrayDownCast<vtkDataArray>(this->Input->GetColumnByName(name.c_str()));
if (arr)
{
PIMPL::ColumnSetting settings;
......
......@@ -75,7 +75,7 @@ int TestDataArrayComponentNames(int,char *[])
//Test Down cast
vtkDoubleArray *downcast = vtkDoubleArray::SafeDownCast( farray );
vtkDoubleArray *downcast = vtkArrayDownCast<vtkDoubleArray>( farray );
if ( strcmp(downcast->GetComponentName(0),"a") != 0||
strcmp(downcast->GetComponentName(1),"b") != 0||
strcmp(downcast->GetComponentName(2),"c") != 0)
......
......@@ -341,7 +341,7 @@ void vtkBitArray::SetNumberOfTuples(vtkIdType number)
// performed; use in conjunction with SetNumberOfTuples() to allocate space.
void vtkBitArray::SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source)
{
vtkBitArray* ba = vtkBitArray::SafeDownCast(source);
vtkBitArray* ba = vtkArrayDownCast<vtkBitArray>(source);
if (!ba)
{
vtkWarningMacro("Input and output arrays types do not match.");
......@@ -364,7 +364,7 @@ void vtkBitArray::SetTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source)
// Note that memory allocation is performed as necessary to hold the data.
void vtkBitArray::InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source)
{
vtkBitArray* ba = vtkBitArray::SafeDownCast(source);
vtkBitArray* ba = vtkArrayDownCast<vtkBitArray>(source);
if (!ba)
{
vtkWarningMacro("Input and output arrays types do not match.");
......@@ -384,7 +384,7 @@ void vtkBitArray::InsertTuple(vtkIdType i, vtkIdType j, vtkAbstractArray* source
void vtkBitArray::InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
vtkAbstractArray *source)
{
vtkBitArray* ba = vtkBitArray::SafeDownCast(source);
vtkBitArray* ba = vtkArrayDownCast<vtkBitArray>(source);
if (!ba)
{
vtkWarningMacro("Input and output arrays types do not match.");
......@@ -421,7 +421,7 @@ void vtkBitArray::InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
void vtkBitArray::InsertTuples(vtkIdType dstStart, vtkIdType n,
vtkIdType srcStart, vtkAbstractArray *source)
{
vtkBitArray* sa = vtkBitArray::SafeDownCast(source);
vtkBitArray* sa = vtkArrayDownCast<vtkBitArray>(source);
if (!sa)
{
vtkWarningMacro("Input and outputs array data types do not match.");
......@@ -464,7 +464,7 @@ void vtkBitArray::InsertTuples(vtkIdType dstStart, vtkIdType n,
// Returns the location at which the data was inserted.
vtkIdType vtkBitArray::InsertNextTuple(vtkIdType j, vtkAbstractArray* source)
{
vtkBitArray* ba = vtkBitArray::SafeDownCast(source);
vtkBitArray* ba = vtkArrayDownCast<vtkBitArray>(source);
if (!ba)
{
vtkWarningMacro("Input and output arrays types do not match.");
......
......@@ -37,7 +37,7 @@ vtkBitArrayIterator::~vtkBitArrayIterator()
//-----------------------------------------------------------------------------
void vtkBitArrayIterator::Initialize(vtkAbstractArray* a)
{
vtkBitArray* b = vtkBitArray::SafeDownCast(a);
vtkBitArray* b = vtkArrayDownCast<vtkBitArray>(a);
if (!b && a)
{
vtkErrorMacro("vtkBitArrayIterator can iterate only over vtkBitArray.");
......
......@@ -234,11 +234,11 @@ vtkUnsignedCharArray *vtkScalarsToColors::MapScalars(vtkAbstractArray *scalars,
int numberOfComponents = scalars->GetNumberOfComponents();
vtkUnsignedCharArray *newColors;
vtkDataArray *dataArray = vtkDataArray::SafeDownCast(scalars);
vtkDataArray *dataArray = vtkArrayDownCast<vtkDataArray>(scalars);
// map scalars through lookup table only if needed
if ((colorMode == VTK_COLOR_MODE_DEFAULT &&
vtkUnsignedCharArray::SafeDownCast(dataArray) != NULL) ||
vtkArrayDownCast<vtkUnsignedCharArray>(dataArray) != NULL) ||
(colorMode == VTK_COLOR_MODE_DIRECT_SCALARS && dataArray))
{
newColors = this->
......@@ -1542,16 +1542,16 @@ void vtkScalarsToColors::MapScalarsThroughTable2(
vtkUnsignedCharArray *vtkScalarsToColors::ConvertToRGBA(
vtkDataArray *colors, int numComp, int numTuples)
{
if (vtkCharArray::SafeDownCast(colors) != NULL)
if (vtkArrayDownCast<vtkCharArray>(colors) != NULL)
{
vtkErrorMacro(<<"char type does not have enough values to hold a color");
return NULL;
}
if (numComp == 4 && this->Alpha >= 1.0 &&
vtkUnsignedCharArray::SafeDownCast(colors) != NULL)
vtkArrayDownCast<vtkUnsignedCharArray>(colors) != NULL)
{
vtkUnsignedCharArray* c = vtkUnsignedCharArray::SafeDownCast(colors);
vtkUnsignedCharArray* c = vtkArrayDownCast<vtkUnsignedCharArray>(colors);
c->Register(this);
return c;
}
......
......@@ -201,7 +201,7 @@ void vtkStringArray::DeepCopy(vtkAbstractArray* aa)
return;
}
vtkStringArray *fa = vtkStringArray::SafeDownCast( aa );
vtkStringArray *fa = vtkArrayDownCast<vtkStringArray>( aa );
if ( fa == NULL )
{
vtkErrorMacro(<< "Shouldn't Happen: Couldn't downcast array into a vtkStringArray." );
......@@ -518,7 +518,7 @@ vtkIdType vtkStringArray::GetDataSize()
void vtkStringArray::SetTuple(vtkIdType i, vtkIdType j,
vtkAbstractArray* source)
{
vtkStringArray* sa = vtkStringArray::SafeDownCast(source);
vtkStringArray* sa = vtkArrayDownCast<vtkStringArray>(source);
if (!sa)
{
vtkWarningMacro("Input and outputs array data types do not match.");
......@@ -540,7 +540,7 @@ void vtkStringArray::SetTuple(vtkIdType i, vtkIdType j,
void vtkStringArray::InsertTuple(vtkIdType i, vtkIdType j,
vtkAbstractArray* source)
{
vtkStringArray* sa = vtkStringArray::SafeDownCast(source);
vtkStringArray* sa = vtkArrayDownCast<vtkStringArray>(source);
if (!sa)
{
vtkWarningMacro("Input and outputs array data types do not match.");
......@@ -560,7 +560,7 @@ void vtkStringArray::InsertTuple(vtkIdType i, vtkIdType j,
void vtkStringArray::InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
vtkAbstractArray *source)
{
vtkStringArray* sa = vtkStringArray::SafeDownCast(source);
vtkStringArray* sa = vtkArrayDownCast<vtkStringArray>(source);
if (!sa)
{
vtkWarningMacro("Input and outputs array data types do not match.");
......@@ -598,7 +598,7 @@ void vtkStringArray::InsertTuples(vtkIdList *dstIds, vtkIdList *srcIds,
void vtkStringArray::InsertTuples(vtkIdType dstStart, vtkIdType n,
vtkIdType srcStart, vtkAbstractArray *source)
{
vtkStringArray* sa = vtkStringArray::SafeDownCast(source);
vtkStringArray* sa = vtkArrayDownCast<vtkStringArray>(source);
if (!sa)
{
vtkWarningMacro("Input and outputs array data types do not match.");
......@@ -641,7 +641,7 @@ void vtkStringArray::InsertTuples(vtkIdType dstStart, vtkIdType n,
vtkIdType vtkStringArray::InsertNextTuple(vtkIdType j,
vtkAbstractArray* source)
{
vtkStringArray* sa = vtkStringArray::SafeDownCast(source);
vtkStringArray* sa = vtkArrayDownCast<vtkStringArray>(source);
if (!sa)
{
vtkWarningMacro("Input and outputs array data types do not match.");
......@@ -672,7 +672,7 @@ void vtkStringArray::GetTuples(vtkIdList *indices, vtkAbstractArray *aa)
return;
}