Commit 6e08c7af authored by Andrew Bauer's avatar Andrew Bauer
Browse files

Reorder the point data arrays from Contour output to match input order

For image data, rectilinear grid and structured grids the point
data array order for the output arrays doesn't match the input
order if ComputeScalars is enabled. It did match for unstructured
grids and polydata. This was confusing when contouring multiblock
data sets with combinations of each since some orders were
kept consistent and others were not.
parent f365ba65
Pipeline #45615 failed with stage
......@@ -47,6 +47,27 @@
#include <cmath>
namespace
{
void ReorderPointDataArrays(vtkPointData* input, vtkPointData* output)
{
// reorder the output arrays to match the input
vtkNew<vtkPointData> tempPD;
for (int i = 0; i < input->GetNumberOfArrays(); i++)
{
tempPD->AddArray(
output->GetArray(input->GetArrayName(i)));
}
int indexArray[vtkDataSetAttributes::NUM_ATTRIBUTES];
input->GetAttributeIndices(indexArray);
output->ShallowCopy(tempPD.GetPointer());
for (int i = 0; i < vtkDataSetAttributes::NUM_ATTRIBUTES; i++)
{
output->SetActiveAttribute(indexArray[i], i);
}
}
}
vtkStandardNewMacro(vtkContourFilter);
vtkCxxSetObjectMacro(vtkContourFilter,ScalarTree,vtkScalarTree);
......@@ -287,7 +308,7 @@ int vtkContourFilter::RequestData(
int sType = inScalars->GetDataType();
// handle 2D images
// handle images but not uniform grids
if (vtkImageData::SafeDownCast(input) && sType != VTK_BIT &&
!vtkUniformGrid::SafeDownCast(input))
{
......@@ -332,7 +353,13 @@ int vtkContourFilter::RequestData(
this->SynchronizedTemplates3D->
SetInputArrayToProcess(0,this->GetInputArrayInformation(0));
return this->SynchronizedTemplates3D->ProcessRequest(request,inputVector,outputVector);
int retVal =
this->SynchronizedTemplates3D->ProcessRequest(request,inputVector,outputVector);
if ( retVal && this->ComputeScalars )
{
ReorderPointDataArrays(input->GetPointData(), this->GetOutput()->GetPointData());
}
return retVal;
}
} //if image data
......@@ -354,8 +381,13 @@ int vtkContourFilter::RequestData(
this->RectilinearSynchronizedTemplates->SetGenerateTriangles(this->GenerateTriangles);
this->RectilinearSynchronizedTemplates->
SetInputArrayToProcess(0,this->GetInputArrayInformation(0));
return this->RectilinearSynchronizedTemplates->
int retVal = this->RectilinearSynchronizedTemplates->
ProcessRequest(request,inputVector,outputVector);
if ( retVal && this->ComputeScalars )
{
ReorderPointDataArrays(input->GetPointData(), this->GetOutput()->GetPointData());
}
return retVal;
}
} // if 3D Rgrid
......@@ -378,8 +410,13 @@ int vtkContourFilter::RequestData(
this->GridSynchronizedTemplates->SetGenerateTriangles(this->GenerateTriangles);
this->GridSynchronizedTemplates->
SetInputArrayToProcess(0,this->GetInputArrayInformation(0));
return this->GridSynchronizedTemplates->
int retVal = this->GridSynchronizedTemplates->
ProcessRequest(request,inputVector,outputVector);
if ( retVal && this->ComputeScalars )
{
ReorderPointDataArrays(input->GetPointData(), this->GetOutput()->GetPointData());
}
return retVal;
}
} //if 3D SGrid
......
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