Commit eef22564 authored by Andrew Bauer's avatar Andrew Bauer Committed by Kitware Robot

Merge topic 'celliterator_datatype'

3148b3a8 Making DataSetCellIterators have proper point data type.
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1997
parents 820fdea1 3148b3a8
Pipeline #27580 running with stage
in 0 seconds
......@@ -15,13 +15,105 @@
#include "vtkDataSetCellIterator.h"
#include "vtkDataSet.h"
#include "vtkHyperTreeGrid.h"
#include "vtkIdList.h"
#include "vtkObjectFactory.h"
#include "vtkPoints.h"
#include "vtkIdList.h"
#include "vtkRectilinearGrid.h"
vtkStandardNewMacro(vtkDataSetCellIterator)
namespace
{
template<typename T>
void SetArrayType(T* grid, vtkPoints* points)
{
// check all directions to see if any of them are doubles and
// if they are we set the points data type to double. If the
// data types are all the same then we set it to the common
// data type. Otherwise we give up and just keep the default
// float data type.
int xType = -1, yType = -1, zType = -1;
if (vtkDataArray* x = grid->GetXCoordinates())
{
xType = x->GetDataType();
if (xType == VTK_DOUBLE)
{
points->SetDataType(VTK_DOUBLE);
return;
}
}
if (vtkDataArray* y = grid->GetYCoordinates())
{
yType = y->GetDataType();
if (yType == VTK_DOUBLE)
{
points->SetDataType(VTK_DOUBLE);
return;
}
}
if (vtkDataArray* z = grid->GetZCoordinates())
{
zType = z->GetDataType();
if (zType == VTK_DOUBLE)
{
points->SetDataType(VTK_DOUBLE);
return;
}
}
if (xType != -1 || yType != -1 || zType != -1)
{
if(xType == yType && xType == zType)
{
points->SetDataType(xType);
return;
}
if (xType == -1)
{
if (yType == -1)
{
points->SetDataType(zType);
return;
}
else if (zType == -1 || yType == zType)
{
points->SetDataType(yType);
return;
}
}
if (yType == -1)
{
if (xType == -1)
{
points->SetDataType(zType);
return;
}
else if (zType == -1 || xType == zType)
{
points->SetDataType(xType);
return;
}
}
if (zType == -1)
{
if (xType == -1)
{
points->SetDataType(yType);
return;
}
else if (yType == -1 || xType == yType)
{
points->SetDataType(xType);
return;
}
}
}
// Set it to the default since it may have gotten set to something else
points->SetDataType(VTK_FLOAT);
}
}
//------------------------------------------------------------------------------
void vtkDataSetCellIterator::PrintSelf(ostream &os, vtkIndent indent)
{
......@@ -35,6 +127,21 @@ void vtkDataSetCellIterator::SetDataSet(vtkDataSet *ds)
{
this->DataSet = ds;
this->CellId = 0;
cerr << "setting data set\n";
if (vtkRectilinearGrid* rg = vtkRectilinearGrid::SafeDownCast(ds))
{
SetArrayType(rg, this->Points);
}
else if (vtkHyperTreeGrid* htg = vtkHyperTreeGrid::SafeDownCast(ds))
{
SetArrayType(htg, this->Points);
}
else if (ds->IsA("vtkImageData") || ds->IsA("vtkHyperOctree"))
{
// ImageData and HyperOctree Origin and Spacing are doubles so
// the data type for this should also be double
this->Points->SetDataType(VTK_DOUBLE);
}
}
//------------------------------------------------------------------------------
......
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