Commit 0b635e13 authored by Andrew Bauer's avatar Andrew Bauer

Properly reading in polyhedra in parallel XML unstructured grid reader.

The Faces and FaceLocations arrays weren't getting properly
populated when reading in a .pvtu file. These are needed for
reading in polyhedra.
parent bffa84d7
......@@ -160,7 +160,41 @@ int vtkXMLPUnstructuredGridReader::ReadPieceData()
outLocs[i] = inLocs[i] + startLoc;
}
// Copy the cooresponding cell types.
// Copy Faces and FaceLocations with offset adjustment if they exist
if(vtkIdTypeArray* inputFaces = input->GetFaces())
{
vtkIdTypeArray* inputFaceLocations = input->GetFaceLocations();
vtkIdTypeArray* outputFaces = output->GetFaces();
if(!outputFaces)
{
output->InitializeFacesRepresentation(0);
outputFaces = output->GetFaces();
}
vtkIdTypeArray* outputFaceLocations = output->GetFaceLocations();
for (vtkIdType i = 0;i < numCells; ++i)
{
outputFaceLocations->InsertNextValue(outputFaces->GetMaxId() + 1);
vtkIdType location = inputFaceLocations->GetValue(i);
vtkIdType numFaces = inputFaces->GetValue(location);
location++;
outputFaces->InsertNextValue(numFaces);
for (vtkIdType f = 0;f < numFaces; f++)
{
vtkIdType numPoints = inputFaces->GetValue(location);
outputFaces->InsertNextValue(numPoints);
location++;
for (vtkIdType p = 0;p < numPoints; p++)
{
// only the point ids get the offset
outputFaces->InsertNextValue(
inputFaces->GetValue(location)+this->StartPoint);
location++;
}
}
}
}
// Copy the corresponding cell types.
vtkUnsignedCharArray* inTypes = input->GetCellTypesArray();
vtkUnsignedCharArray* outTypes = output->GetCellTypesArray();
vtkIdType components = outTypes->GetNumberOfComponents();
......@@ -204,3 +238,17 @@ int vtkXMLPUnstructuredGridReader::FillOutputPortInformation(
info->Set(vtkDataObject::DATA_TYPE_NAME(), "vtkUnstructuredGrid");
return 1;
}
//----------------------------------------------------------------------------
void vtkXMLPUnstructuredGridReader::SqueezeOutputArrays(vtkDataObject* output)
{
vtkUnstructuredGrid* grid = vtkUnstructuredGrid::SafeDownCast(output);
if(vtkIdTypeArray* outputFaces = grid->GetFaces())
{
outputFaces->Squeeze();
}
if(vtkIdTypeArray* outputFaceLocations = grid->GetFaceLocations())
{
outputFaceLocations->Squeeze();
}
}
......@@ -59,6 +59,8 @@ protected:
vtkXMLDataReader* CreatePieceReader();
virtual int FillOutputPortInformation(int, vtkInformation*);
virtual void SqueezeOutputArrays(vtkDataObject*);
// The index of the cell in the output where the current piece
// begins.
vtkIdType StartCell;
......
......@@ -622,6 +622,8 @@ int vtkXMLReader::RequestData(vtkInformation *vtkNotUsed(request),
this->TimeStepWasReadOnce = 1;
}
this->SqueezeOutputArrays(output);
this->CurrentOutput = 0;
return 1;
}
......
......@@ -230,6 +230,10 @@ protected:
static void SelectionModifiedCallback(vtkObject* caller, unsigned long eid,
void* clientdata, void* calldata);
// Give concrete classes an option to squeeze any output arrays
// at the end of RequestData.
virtual void SqueezeOutputArrays(vtkDataObject*) {}
// The vtkXMLDataParser instance used to hide XML reading details.
vtkXMLDataParser* XMLParser;
......
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