Commit c54ae70e authored by Brad King's avatar Brad King 💬
Browse files

ENH: Added support for multiple outputs from vtkXMLReader. The standard data...

ENH: Added support for multiple outputs from vtkXMLReader.  The standard data set readers all still have only one output.
parent 17d11447
......@@ -25,7 +25,7 @@
#include "vtkXMLDataElement.h"
#include "vtkXMLDataParser.h"
vtkCxxRevisionMacro(vtkXMLDataReader, "1.5");
vtkCxxRevisionMacro(vtkXMLDataReader, "1.6");
//----------------------------------------------------------------------------
vtkXMLDataReader::vtkXMLDataReader()
......@@ -150,8 +150,8 @@ void vtkXMLDataReader::SetupOutputInformation()
// Use the configuration of the first piece since all are the same.
vtkXMLDataElement* ePointData = this->PointDataElements[0];
vtkXMLDataElement* eCellData = this->CellDataElements[0];
vtkPointData* pointData = this->GetOutputAsDataSet()->GetPointData();
vtkCellData* cellData = this->GetOutputAsDataSet()->GetCellData();
vtkPointData* pointData = this->GetOutputAsDataSet(0)->GetPointData();
vtkCellData* cellData = this->GetOutputAsDataSet(0)->GetCellData();
// Setup the point and cell data arrays without allocation.
this->NumberOfPointArrays = 0;
......@@ -211,7 +211,7 @@ void vtkXMLDataReader::SetupOutputData()
{
this->Superclass::SetupOutputData();
vtkDataSet* output = this->GetOutputAsDataSet();
vtkDataSet* output = this->GetOutputAsDataSet(0);
vtkPointData* pointData = output->GetPointData();
vtkCellData* cellData = output->GetCellData();
......@@ -287,8 +287,8 @@ int vtkXMLDataReader::ReadPieceData(int piece)
//----------------------------------------------------------------------------
int vtkXMLDataReader::ReadPieceData()
{
vtkPointData* pointData = this->GetOutputAsDataSet()->GetPointData();
vtkCellData* cellData = this->GetOutputAsDataSet()->GetCellData();
vtkPointData* pointData = this->GetOutputAsDataSet(0)->GetPointData();
vtkCellData* cellData = this->GetOutputAsDataSet(0)->GetCellData();
vtkXMLDataElement* ePointData = this->PointDataElements[this->Piece];
vtkXMLDataElement* eCellData = this->CellDataElements[this->Piece];
......
......@@ -26,7 +26,7 @@
#include "vtkXMLDataElement.h"
#include "vtkXMLDataReader.h"
vtkCxxRevisionMacro(vtkXMLPDataReader, "1.7");
vtkCxxRevisionMacro(vtkXMLPDataReader, "1.8");
//----------------------------------------------------------------------------
vtkXMLPDataReader::vtkXMLPDataReader()
......@@ -81,8 +81,8 @@ void vtkXMLPDataReader::SetupOutputInformation()
// Setup the output arrays.
vtkXMLDataElement* ePointData = this->PPointDataElement;
vtkXMLDataElement* eCellData = this->PCellDataElement;
vtkPointData* pointData = this->GetOutputAsDataSet()->GetPointData();
vtkCellData* cellData = this->GetOutputAsDataSet()->GetCellData();
vtkPointData* pointData = this->GetOutputAsDataSet(0)->GetPointData();
vtkCellData* cellData = this->GetOutputAsDataSet(0)->GetCellData();
// Setup the point and cell data arrays without allocation.
this->SetDataArraySelections(ePointData, this->PointDataArraySelection);
......@@ -138,7 +138,7 @@ void vtkXMLPDataReader::SetupOutputData()
{
this->Superclass::SetupOutputData();
vtkDataSet* output = this->GetOutputAsDataSet();
vtkDataSet* output = this->GetOutputAsDataSet(0);
vtkXMLDataElement* ePointData = this->PPointDataElement;
vtkXMLDataElement* eCellData = this->PCellDataElement;
vtkPointData* pointData = output->GetPointData();
......@@ -327,7 +327,7 @@ int vtkXMLPDataReader::ReadPieceData(int index)
int vtkXMLPDataReader::ReadPieceData()
{
vtkDataSet* input = this->GetPieceInputAsDataSet(this->Piece);
vtkDataSet* output = this->GetOutputAsDataSet();
vtkDataSet* output = this->GetOutputAsDataSet(0);
// Copy point data and cell data for this piece.
int i;
......
......@@ -23,7 +23,7 @@
#include "vtkXMLDataElement.h"
#include "vtkXMLStructuredDataReader.h"
vtkCxxRevisionMacro(vtkXMLPStructuredDataReader, "1.7");
vtkCxxRevisionMacro(vtkXMLPStructuredDataReader, "1.8");
//----------------------------------------------------------------------------
vtkXMLPStructuredDataReader::vtkXMLPStructuredDataReader()
......@@ -71,7 +71,7 @@ vtkIdType vtkXMLPStructuredDataReader::GetNumberOfCells()
void vtkXMLPStructuredDataReader::ReadXMLData()
{
// Get the requested Update Extent.
this->GetOutputAsDataSet()->GetUpdateExtent(this->UpdateExtent);
this->GetOutputAsDataSet(0)->GetUpdateExtent(this->UpdateExtent);
vtkDebugMacro("Updating extent "
<< this->UpdateExtent[0] << " " << this->UpdateExtent[1] << " "
......@@ -160,7 +160,7 @@ int
vtkXMLPStructuredDataReader::ReadPrimaryElement(vtkXMLDataElement* ePrimary)
{
if(!this->Superclass::ReadPrimaryElement(ePrimary)) { return 0; }
vtkDataSet* output = this->GetOutputAsDataSet();
vtkDataSet* output = this->GetOutputAsDataSet(0);
// Read information about the structured data.
int extent[6];
......@@ -182,14 +182,14 @@ void vtkXMLPStructuredDataReader::SetupOutputInformation()
// Tell the output to use the table extent translator to provide the
// correct piece breakdown for the file layout.
this->GetOutputAsDataSet()->SetExtentTranslator(this->ExtentTranslator);
this->GetOutputAsDataSet(0)->SetExtentTranslator(this->ExtentTranslator);
}
//----------------------------------------------------------------------------
void vtkXMLPStructuredDataReader::SetupEmptyOutput()
{
// Special extent to indicate no input.
this->GetOutputAsDataSet()->SetUpdateExtent(1, 0, 1, 0, 1, 0);
this->GetOutputAsDataSet(0)->SetUpdateExtent(1, 0, 1, 0, 1, 0);
}
//----------------------------------------------------------------------------
......
......@@ -21,7 +21,7 @@
#include "vtkPointSet.h"
#include "vtkCellArray.h"
vtkCxxRevisionMacro(vtkXMLPUnstructuredDataReader, "1.9");
vtkCxxRevisionMacro(vtkXMLPUnstructuredDataReader, "1.10");
//----------------------------------------------------------------------------
vtkXMLPUnstructuredDataReader::vtkXMLPUnstructuredDataReader()
......@@ -112,7 +112,7 @@ vtkIdType vtkXMLPUnstructuredDataReader::GetNumberOfCellsInPiece(int piece)
void vtkXMLPUnstructuredDataReader::SetupEmptyOutput()
{
// No pieces means no input.
this->GetOutputAsDataSet()->SetUpdateExtent(0, 0);
this->GetOutputAsDataSet(0)->SetUpdateExtent(0, 0);
}
//----------------------------------------------------------------------------
......
......@@ -32,7 +32,7 @@
#include <sys/stat.h>
vtkCxxRevisionMacro(vtkXMLReader, "1.13");
vtkCxxRevisionMacro(vtkXMLReader, "1.14");
//----------------------------------------------------------------------------
vtkXMLReader::vtkXMLReader()
......@@ -44,6 +44,7 @@ vtkXMLReader::vtkXMLReader()
this->CellDataArraySelection = vtkDataArraySelection::New();
this->InformationError = 0;
this->DataError = 0;
this->CurrentOutput = -1;
this->ProgressRange[0] = 0;
this->ProgressRange[1] = 1;
......@@ -88,8 +89,14 @@ void vtkXMLReader::PrintSelf(ostream& os, vtkIndent indent)
//----------------------------------------------------------------------------
vtkDataSet* vtkXMLReader::GetOutputAsDataSet()
{
if(this->NumberOfOutputs < 1) { return 0; }
return static_cast<vtkDataSet*>(this->Outputs[0]);
return this->GetOutputAsDataSet(0);
}
//----------------------------------------------------------------------------
vtkDataSet* vtkXMLReader::GetOutputAsDataSet(int index)
{
if(index < 0 || index >= this->NumberOfOutputs) { return 0; }
return static_cast<vtkDataSet*>(this->Outputs[index]);
}
//----------------------------------------------------------------------------
......@@ -248,8 +255,25 @@ void vtkXMLReader::ExecuteInformation()
}
//----------------------------------------------------------------------------
void vtkXMLReader::ExecuteData(vtkDataObject* vtkNotUsed(output))
void vtkXMLReader::ExecuteData(vtkDataObject* output)
{
// Set which output we are updating. If the given object is not one
// of our outputs, just initialize it to empty and return.
int i;
this->CurrentOutput = -1;
for(i=0; this->CurrentOutput < 0 && i < this->NumberOfOutputs; ++i)
{
if(output == this->Outputs[i])
{
this->CurrentOutput = i;
}
}
if(this->CurrentOutput < 0)
{
output->Initialize();
return;
}
// Re-open the input file. If it fails, the error was already
// reported by OpenVTKFile.
if(!this->OpenVTKFile())
......@@ -264,7 +288,7 @@ void vtkXMLReader::ExecuteData(vtkDataObject* vtkNotUsed(output))
// Give the vtkXMLParser instance its file back so that data section
// reads will work.
this->XMLParser->SetStream(this->FileStream);
// We are just starting to read. Do not call UpdateProgressDiscrete
// because we want a 0 progress callback the first time.
this->UpdateProgress(0);
......@@ -285,13 +309,13 @@ void vtkXMLReader::ExecuteData(vtkDataObject* vtkNotUsed(output))
// If we aborted or there was an error, provide empty output.
if(this->DataError || this->AbortExecute)
{
this->GetOutputAsDataSet()->Initialize();
this->GetOutputAsDataSet(this->CurrentOutput)->Initialize();
}
}
else
{
// There was an error reading the file. Provide empty output.
this->GetOutputAsDataSet()->Initialize();
this->GetOutputAsDataSet(this->CurrentOutput)->Initialize();
}
// We have finished reading.
......@@ -315,9 +339,14 @@ void vtkXMLReader::ReadXMLInformation()
}
else
{
int i;
// There was an error reading the file. Provide empty output.
this->InformationError = 1;
this->GetOutputAsDataSet()->Initialize();
for(i=0; i < this->NumberOfOutputs; ++i)
{
this->Outputs[i]->Initialize();
}
}
}
......@@ -369,7 +398,11 @@ int vtkXMLReader::ReadPrimaryElement(vtkXMLDataElement*)
void vtkXMLReader::SetupOutputInformation()
{
// Initialize the output.
this->GetOutputAsDataSet()->Initialize();
int i;
for(i=0; i < this->NumberOfOutputs; ++i)
{
this->Outputs[i]->Initialize();
}
}
//----------------------------------------------------------------------------
......
......@@ -53,6 +53,7 @@ public:
// Description:
// Get the output as a vtkDataSet pointer.
vtkDataSet* GetOutputAsDataSet();
vtkDataSet* GetOutputAsDataSet(int index);
// Description:
// Get the data array selection tables used to configure which data
......@@ -176,6 +177,10 @@ protected:
// Whether there was an error reading the file in ExecuteData.
int DataError;
// The index of the output on which ExecuteData is currently
// running.
int CurrentOutput;
// The current range over which progress is moving. This allows for
// incrementally fine-tuned progress updates.
virtual void GetProgressRange(float* range);
......
......@@ -22,7 +22,7 @@
#include "vtkXMLDataElement.h"
#include "vtkXMLDataParser.h"
vtkCxxRevisionMacro(vtkXMLStructuredDataReader, "1.8");
vtkCxxRevisionMacro(vtkXMLStructuredDataReader, "1.9");
//----------------------------------------------------------------------------
vtkXMLStructuredDataReader::vtkXMLStructuredDataReader()
......@@ -64,7 +64,7 @@ int vtkXMLStructuredDataReader::ReadPrimaryElement(vtkXMLDataElement* ePrimary)
int extent[6];
if(ePrimary->GetVectorAttribute("WholeExtent", 6, extent) == 6)
{
this->GetOutputAsDataSet()->SetWholeExtent(extent);
this->GetOutputAsDataSet(0)->SetWholeExtent(extent);
}
else
{
......@@ -79,7 +79,7 @@ int vtkXMLStructuredDataReader::ReadPrimaryElement(vtkXMLDataElement* ePrimary)
void vtkXMLStructuredDataReader::SetupEmptyOutput()
{
// Special extent to indicate no input.
this->GetOutputAsDataSet()->SetUpdateExtent(1, 0, 1, 0, 1, 0);
this->GetOutputAsDataSet(0)->SetUpdateExtent(1, 0, 1, 0, 1, 0);
}
//----------------------------------------------------------------------------
......@@ -174,7 +174,7 @@ int vtkXMLStructuredDataReader::ReadPiece(vtkXMLDataElement* ePiece)
void vtkXMLStructuredDataReader::ReadXMLData()
{
// Get the requested Update Extent.
this->GetOutputAsDataSet()->GetUpdateExtent(this->UpdateExtent);
this->GetOutputAsDataSet(0)->GetUpdateExtent(this->UpdateExtent);
vtkDebugMacro("Updating extent "
<< this->UpdateExtent[0] << " " << this->UpdateExtent[1] << " "
......
......@@ -24,7 +24,7 @@
#include "vtkCellArray.h"
#include "vtkPointSet.h"
vtkCxxRevisionMacro(vtkXMLUnstructuredDataReader, "1.9");
vtkCxxRevisionMacro(vtkXMLUnstructuredDataReader, "1.10");
//----------------------------------------------------------------------------
vtkXMLUnstructuredDataReader::vtkXMLUnstructuredDataReader()
......@@ -160,7 +160,7 @@ vtkXMLUnstructuredDataReader
void vtkXMLUnstructuredDataReader::SetupEmptyOutput()
{
// No pieces means no input.
this->GetOutputAsDataSet()->SetUpdateExtent(0, 0);
this->GetOutputAsDataSet(0)->SetUpdateExtent(0, 0);
}
//----------------------------------------------------------------------------
......
Supports Markdown
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