Commit 65f02758 authored by Brad King's avatar Brad King

ENH: Added progress reporting to XML writers.

parent d70fe4be
......@@ -17,6 +17,7 @@
=========================================================================*/
#include "vtkXMLDataSetWriter.h"
#include "vtkCallbackCommand.h"
#include "vtkDataSet.h"
#include "vtkImageData.h"
#include "vtkObjectFactory.h"
......@@ -30,17 +31,22 @@
#include "vtkXMLStructuredGridWriter.h"
#include "vtkXMLUnstructuredGridWriter.h"
vtkCxxRevisionMacro(vtkXMLDataSetWriter, "1.2");
vtkCxxRevisionMacro(vtkXMLDataSetWriter, "1.3");
vtkStandardNewMacro(vtkXMLDataSetWriter);
//----------------------------------------------------------------------------
vtkXMLDataSetWriter::vtkXMLDataSetWriter()
{
{
// Setup a callback for the internal writer to report progress.
this->ProgressObserver = vtkCallbackCommand::New();
this->ProgressObserver->SetCallback(&vtkXMLDataSetWriter::ProgressCallbackFunction);
this->ProgressObserver->SetClientData(this);
}
//----------------------------------------------------------------------------
vtkXMLDataSetWriter::~vtkXMLDataSetWriter()
{
this->ProgressObserver->Delete();
}
//----------------------------------------------------------------------------
......@@ -67,14 +73,8 @@ vtkDataSet* vtkXMLDataSetWriter::GetInput()
}
//----------------------------------------------------------------------------
int vtkXMLDataSetWriter::Write()
{
// Make sure there are enough settings to write (Input, FileName, etc).
if(!this->IsSafeToWrite())
{
return 0;
}
int vtkXMLDataSetWriter::WriteInternal()
{
vtkDataSet* input = this->GetInput();
vtkXMLWriter* writer = 0;
......@@ -130,11 +130,13 @@ int vtkXMLDataSetWriter::Write()
writer->SetBlockSize(this->GetBlockSize());
writer->SetDataMode(this->GetDataMode());
writer->SetEncodeAppendedData(this->GetEncodeAppendedData());
writer->AddObserver(vtkCommand::ProgressEvent, this->ProgressObserver);
// Try to write.
int result = writer->Write();
// Cleanup.
writer->RemoveObserver(this->ProgressObserver);
writer->Delete();
return result;
}
......@@ -156,3 +158,28 @@ const char* vtkXMLDataSetWriter::GetDefaultFileExtension()
{
return "vtk";
}
//----------------------------------------------------------------------------
void vtkXMLDataSetWriter::ProgressCallbackFunction(vtkObject* caller,
unsigned long,
void* clientdata, void*)
{
vtkProcessObject* w = vtkProcessObject::SafeDownCast(caller);
if(w)
{
reinterpret_cast<vtkXMLDataSetWriter*>(clientdata)->ProgressCallback(w);
}
}
//----------------------------------------------------------------------------
void vtkXMLDataSetWriter::ProgressCallback(vtkProcessObject* w)
{
float width = this->ProgressRange[1]-this->ProgressRange[0];
float internalProgress = w->GetProgress();
float progress = this->ProgressRange[0] + internalProgress*width;
this->UpdateProgressDiscrete(progress);
if(this->AbortExecute)
{
w->SetAbortExecute(1);
}
}
......@@ -31,6 +31,8 @@
#include "vtkXMLWriter.h"
class vtkCallbackCommand;
class VTK_IO_EXPORT vtkXMLDataSetWriter : public vtkXMLWriter
{
public:
......@@ -43,19 +45,27 @@ public:
void SetInput(vtkDataSet* input);
vtkDataSet* GetInput();
// Description:
// Invoke the writer. Returns 1 for success, 0 for failure.
virtual int Write();
protected:
vtkXMLDataSetWriter();
~vtkXMLDataSetWriter();
// Override writing method from superclass.
virtual int WriteInternal();
// Dummies to satisfy pure virtuals from superclass.
int WriteData();
const char* GetDataSetName();
const char* GetDefaultFileExtension();
// Callback registered with the ProgressObserver.
static void ProgressCallbackFunction(vtkObject*, unsigned long, void*,
void*);
// Progress callback from internal writer.
virtual void ProgressCallback(vtkProcessObject* w);
// The observer to report progress from the internal writer.
vtkCallbackCommand* ProgressObserver;
private:
vtkXMLDataSetWriter(const vtkXMLDataSetWriter&); // Not implemented.
void operator=(const vtkXMLDataSetWriter&); // Not implemented.
......
......@@ -17,6 +17,7 @@
=========================================================================*/
#include "vtkXMLPDataSetWriter.h"
#include "vtkCallbackCommand.h"
#include "vtkDataSet.h"
#include "vtkImageData.h"
#include "vtkObjectFactory.h"
......@@ -30,7 +31,7 @@
#include "vtkXMLPStructuredGridWriter.h"
#include "vtkXMLPUnstructuredGridWriter.h"
vtkCxxRevisionMacro(vtkXMLPDataSetWriter, "1.2");
vtkCxxRevisionMacro(vtkXMLPDataSetWriter, "1.3");
vtkStandardNewMacro(vtkXMLPDataSetWriter);
//----------------------------------------------------------------------------
......@@ -67,14 +68,8 @@ vtkDataSet* vtkXMLPDataSetWriter::GetInput()
}
//----------------------------------------------------------------------------
int vtkXMLPDataSetWriter::Write()
int vtkXMLPDataSetWriter::WriteInternal()
{
// Make sure there are enough settings to write (Input, FileName, etc).
if(!this->IsSafeToWrite())
{
return 0;
}
vtkDataSet* input = this->GetInput();
vtkXMLPDataWriter* writer = 0;
......@@ -134,6 +129,7 @@ int vtkXMLPDataSetWriter::Write()
writer->SetGhostLevel(this->GetGhostLevel());
writer->SetStartPiece(this->GetStartPiece());
writer->SetEndPiece(this->GetEndPiece());
writer->AddObserver(vtkCommand::ProgressEvent, this->ProgressObserver);
// Decide whether to write the summary file.
int writeSummary = 0;
......@@ -151,6 +147,7 @@ int vtkXMLPDataSetWriter::Write()
int result = writer->Write();
// Cleanup.
writer->RemoveObserver(this->ProgressObserver);
writer->Delete();
return result;
}
......
......@@ -43,18 +43,17 @@ public:
void SetInput(vtkDataSet* input);
vtkDataSet* GetInput();
// Description:
// Invoke the writer. Returns 1 for success, 0 for failure.
virtual int Write();
protected:
vtkXMLPDataSetWriter();
~vtkXMLPDataSetWriter();
// Override writing method from superclass.
virtual int WriteInternal();
// Dummies to satisfy pure virtuals from superclass.
const char* GetDataSetName();
const char* GetDefaultFileExtension();
vtkXMLWriter* CreatePieceWriter(int index);
vtkXMLWriter* CreatePieceWriter(int index);
private:
vtkXMLPDataSetWriter(const vtkXMLPDataSetWriter&); // Not implemented.
......
......@@ -16,9 +16,11 @@
=========================================================================*/
#include "vtkXMLPDataWriter.h"
#include "vtkCallbackCommand.h"
#include "vtkDataSet.h"
vtkCxxRevisionMacro(vtkXMLPDataWriter, "1.4");
vtkCxxRevisionMacro(vtkXMLPDataWriter, "1.5");
//----------------------------------------------------------------------------
vtkXMLPDataWriter::vtkXMLPDataWriter()
......@@ -34,6 +36,11 @@ vtkXMLPDataWriter::vtkXMLPDataWriter()
this->FileNameBase = 0;
this->FileNameExtension = 0;
this->PieceFileNameExtension = 0;
// Setup a callback for the internal writer to report progress.
this->ProgressObserver = vtkCallbackCommand::New();
this->ProgressObserver->SetCallback(&vtkXMLPDataWriter::ProgressCallbackFunction);
this->ProgressObserver->SetClientData(this);
}
//----------------------------------------------------------------------------
......@@ -43,6 +50,7 @@ vtkXMLPDataWriter::~vtkXMLPDataWriter()
if(this->FileNameBase) { delete [] this->FileNameBase; }
if(this->FileNameExtension) { delete [] this->FileNameExtension; }
if(this->PieceFileNameExtension) { delete [] this->PieceFileNameExtension; }
this->ProgressObserver->Delete();
}
//----------------------------------------------------------------------------
......@@ -70,14 +78,8 @@ void vtkXMLPDataWriter::SetWriteSummaryFile(int flag)
}
//----------------------------------------------------------------------------
int vtkXMLPDataWriter::Write()
int vtkXMLPDataWriter::WriteInternal()
{
// Make sure there are enough settings to write (Input, FileName, etc).
if(!this->IsSafeToWrite())
{
return 0;
}
// Prepare the file name.
this->SplitFileName();
......@@ -102,7 +104,7 @@ int vtkXMLPDataWriter::Write()
// Write the summary file if requested.
if(writeSummary)
{
if(!this->Superclass::Write()) { return 0; }
if(!this->Superclass::WriteInternal()) { return 0; }
}
return 1;
......@@ -237,10 +239,17 @@ char* vtkXMLPDataWriter::CreatePieceFileName(int index, const char* path)
//----------------------------------------------------------------------------
int vtkXMLPDataWriter::WritePieces()
{
// Split progress range by piece. Just assume all pieces are the
// same size.
float progressRange[2] = {0,0};
this->GetProgressRange(progressRange);
// Write each piece from StartPiece to EndPiece.
int i;
for(i=this->StartPiece; i <= this->EndPiece; ++i)
{
this->SetProgressRange(progressRange, i-this->StartPiece,
this->EndPiece-this->StartPiece+1);
if(!this->WritePiece(i))
{
return 0;
......@@ -255,6 +264,7 @@ int vtkXMLPDataWriter::WritePiece(int index)
// Create the writer for the piece. Its configuration should match
// our own writer.
vtkXMLWriter* pWriter = this->CreatePieceWriter(index);
pWriter->AddObserver(vtkCommand::ProgressEvent, this->ProgressObserver);
// Set the file name.
if(!this->PieceFileNameExtension)
......@@ -278,7 +288,33 @@ int vtkXMLPDataWriter::WritePiece(int index)
int result = pWriter->Write();
// Cleanup.
pWriter->RemoveObserver(this->ProgressObserver);
pWriter->Delete();
return result;
}
//----------------------------------------------------------------------------
void vtkXMLPDataWriter::ProgressCallbackFunction(vtkObject* caller,
unsigned long,
void* clientdata, void*)
{
vtkProcessObject* w = vtkProcessObject::SafeDownCast(caller);
if(w)
{
reinterpret_cast<vtkXMLPDataWriter*>(clientdata)->ProgressCallback(w);
}
}
//----------------------------------------------------------------------------
void vtkXMLPDataWriter::ProgressCallback(vtkProcessObject* w)
{
float width = this->ProgressRange[1]-this->ProgressRange[0];
float internalProgress = w->GetProgress();
float progress = this->ProgressRange[0] + internalProgress*width;
this->UpdateProgressDiscrete(progress);
if(this->AbortExecute)
{
w->SetAbortExecute(1);
}
}
......@@ -27,6 +27,7 @@
#include "vtkXMLWriter.h"
class vtkCallbackCommand;
class vtkDataSet;
class VTK_IO_EXPORT vtkXMLPDataWriter : public vtkXMLWriter
......@@ -60,13 +61,13 @@ public:
vtkGetMacro(WriteSummaryFile, int);
vtkBooleanMacro(WriteSummaryFile, int);
// Description:
// Invoke the writer. Returns 1 for success, 0 for failure.
int Write();
protected:
vtkXMLPDataWriter();
~vtkXMLPDataWriter();
// Override writing method from superclass.
virtual int WriteInternal();
virtual vtkXMLWriter* CreatePieceWriter(int index)=0;
virtual void WritePrimaryElementAttributes();
......@@ -79,6 +80,12 @@ protected:
int WritePieces();
int WritePiece(int index);
// Callback registered with the ProgressObserver.
static void ProgressCallbackFunction(vtkObject*, unsigned long, void*,
void*);
// Progress callback from internal writer.
virtual void ProgressCallback(vtkProcessObject* w);
int StartPiece;
int EndPiece;
int NumberOfPieces;
......@@ -91,6 +98,9 @@ protected:
char* FileNameExtension;
char* PieceFileNameExtension;
// The observer to report progress from the internal writer.
vtkCallbackCommand* ProgressObserver;
private:
vtkXMLPDataWriter(const vtkXMLPDataWriter&); // Not implemented.
void operator=(const vtkXMLPDataWriter&); // Not implemented.
......
......@@ -18,10 +18,12 @@
#include "vtkXMLPolyDataWriter.h"
#include "vtkCellArray.h"
#include "vtkCellData.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
vtkCxxRevisionMacro(vtkXMLPolyDataWriter, "1.2");
vtkCxxRevisionMacro(vtkXMLPolyDataWriter, "1.3");
vtkStandardNewMacro(vtkXMLPolyDataWriter);
//----------------------------------------------------------------------------
......@@ -93,12 +95,44 @@ void vtkXMLPolyDataWriter::WriteInlinePieceAttributes()
//----------------------------------------------------------------------------
void vtkXMLPolyDataWriter::WriteInlinePiece(vtkIndent indent)
{
{
// Split progress range by the approximate fraction of data written
// by each step in this method.
float progressRange[2] = {0,0};
this->GetProgressRange(progressRange);
float fractions[6];
this->CalculateSuperclassFraction(fractions);
// Set the range of progress for superclass.
this->SetProgressRange(progressRange, 0, fractions);
// Let the superclass write its data.
this->Superclass::WriteInlinePiece(indent);
vtkPolyData* input = this->GetInput();
// Set the range of progress for Verts.
this->SetProgressRange(progressRange, 1, fractions);
// Write the Verts.
this->WriteCellsInline("Verts", input->GetVerts(), 0, indent);
// Set the range of progress for Lines.
this->SetProgressRange(progressRange, 2, fractions);
// Write the Lines.
this->WriteCellsInline("Lines", input->GetLines(), 0, indent);
// Set the range of progress for Strips.
this->SetProgressRange(progressRange, 3, fractions);
// Write the Strips.
this->WriteCellsInline("Strips", input->GetStrips(), 0, indent);
// Set the range of progress for Polys.
this->SetProgressRange(progressRange, 4, fractions);
// Write the Polys.
this->WriteCellsInline("Polys", input->GetPolys(), 0, indent);
}
......@@ -180,14 +214,95 @@ void vtkXMLPolyDataWriter::WriteAppendedPieceData(int index)
input->GetPolys()->GetNumberOfCells());
os.seekp(returnPosition);
// Split progress range by the approximate fraction of data written
// by each step in this method.
float progressRange[2] = {0,0};
this->GetProgressRange(progressRange);
float fractions[6];
this->CalculateSuperclassFraction(fractions);
// Set the range of progress for superclass.
this->SetProgressRange(progressRange, 0, fractions);
// Let the superclass write its data.
this->Superclass::WriteAppendedPieceData(index);
// Set the range of progress for Verts.
this->SetProgressRange(progressRange, 1, fractions);
// Write the Verts.
this->WriteCellsAppendedData(input->GetVerts(), 0,
this->VertsPositions[index]);
// Set the range of progress for Lines.
this->SetProgressRange(progressRange, 2, fractions);
// Write the Lines.
this->WriteCellsAppendedData(input->GetLines(), 0,
this->LinesPositions[index]);
// Set the range of progress for Strips.
this->SetProgressRange(progressRange, 3, fractions);
// Write the Strips.
this->WriteCellsAppendedData(input->GetStrips(), 0,
this->StripsPositions[index]);
// Set the range of progress for Polys.
this->SetProgressRange(progressRange, 4, fractions);
// Write the Polys.
this->WriteCellsAppendedData(input->GetPolys(), 0,
this->PolysPositions[index]);
}
//----------------------------------------------------------------------------
vtkIdType vtkXMLPolyDataWriter::GetNumberOfInputCells()
{
vtkPolyData* input = this->GetInput();
return (input->GetVerts()->GetNumberOfCells()+
input->GetLines()->GetNumberOfCells()+
input->GetStrips()->GetNumberOfCells()+
input->GetPolys()->GetNumberOfCells());
}
//----------------------------------------------------------------------------
void vtkXMLPolyDataWriter::CalculateSuperclassFraction(float* fractions)
{
vtkPolyData* input = this->GetInput();
// The superclass will write point/cell data and point specifications.
int pdArrays = input->GetPointData()->GetNumberOfArrays();
int cdArrays = input->GetCellData()->GetNumberOfArrays();
vtkIdType pdSize = pdArrays*this->GetNumberOfInputPoints();
vtkIdType cdSize = cdArrays*this->GetNumberOfInputCells();
vtkIdType pointsSize = this->GetNumberOfInputPoints();
// This class will write cell specifications.
vtkIdType connectSizeV = (input->GetVerts()->GetData()->GetNumberOfTuples() -
input->GetVerts()->GetNumberOfCells());
vtkIdType connectSizeL = (input->GetLines()->GetData()->GetNumberOfTuples() -
input->GetLines()->GetNumberOfCells());
vtkIdType connectSizeS = (input->GetStrips()->GetData()->GetNumberOfTuples() -
input->GetStrips()->GetNumberOfCells());
vtkIdType connectSizeP = (input->GetPolys()->GetData()->GetNumberOfTuples() -
input->GetPolys()->GetNumberOfCells());
vtkIdType offsetSizeV = input->GetVerts()->GetNumberOfCells();
vtkIdType offsetSizeL = input->GetLines()->GetNumberOfCells();
vtkIdType offsetSizeS = input->GetStrips()->GetNumberOfCells();
vtkIdType offsetSizeP = input->GetPolys()->GetNumberOfCells();
fractions[0] = 0;
fractions[1] = fractions[0] + pdSize+cdSize+pointsSize;
fractions[2] = fractions[1] + connectSizeV+offsetSizeV;
fractions[3] = fractions[2] + connectSizeL+offsetSizeL;
fractions[4] = fractions[3] + connectSizeS+offsetSizeS;
fractions[5] = fractions[4] + connectSizeP+offsetSizeP;
if(fractions[5] == 0)
{
fractions[5] = 1;
}
for(int i=0; i < 5;++i)
{
fractions[i+1] = fractions[i+1] / fractions[5];
}
}
......@@ -65,6 +65,9 @@ protected:
void WriteAppendedPiece(int index, vtkIndent indent);
void WriteAppendedPieceData(int index);
virtual vtkIdType GetNumberOfInputCells();
void CalculateSuperclassFraction(float* fractions);
// Positions of attributes for each piece.
unsigned long* NumberOfVertsPositions;
unsigned long* NumberOfLinesPositions;
......
......@@ -16,12 +16,15 @@
=========================================================================*/
#include "vtkXMLRectilinearGridWriter.h"
#include "vtkObjectFactory.h"
#include "vtkRectilinearGrid.h"
#include "vtkCellData.h"
#include "vtkExtentTranslator.h"
#include "vtkFloatArray.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkRectilinearGrid.h"
vtkCxxRevisionMacro(vtkXMLRectilinearGridWriter, "1.2");
vtkCxxRevisionMacro(vtkXMLRectilinearGridWriter, "1.3");
vtkStandardNewMacro(vtkXMLRectilinearGridWriter);
//----------------------------------------------------------------------------
......@@ -149,7 +152,23 @@ void vtkXMLRectilinearGridWriter::WriteAppendedPiece(int index,
//----------------------------------------------------------------------------
void vtkXMLRectilinearGridWriter::WriteAppendedPieceData(int index)
{
// Split progress range by the approximate fractions of data written
// by each step in this method.
float progressRange[2] = {0,0};
this->GetProgressRange(progressRange);
float fractions[3];
this->CalculateSuperclassFraction(fractions);
// Set the range of progress for the superclass.
this->SetProgressRange(progressRange, 0, fractions);
// Let the superclass write its data.
this->Superclass::WriteAppendedPieceData(index);
// Set the range of progress for the coordinates arrays.
this->SetProgressRange(progressRange, 1, fractions);
// Write the coordinates arrays.
this->WriteCoordinatesAppendedData(this->GetInput()->GetXCoordinates(),
this->GetInput()->GetYCoordinates(),
this->GetInput()->GetZCoordinates(),
......@@ -160,9 +179,52 @@ void vtkXMLRectilinearGridWriter::WriteAppendedPieceData(int index)
//----------------------------------------------------------------------------
void vtkXMLRectilinearGridWriter::WriteInlinePiece(int index, vtkIndent indent)
{
// Split progress range by the approximate fractions of data written
// by each step in this method.
float progressRange[2] = {0,0};
this->GetProgressRange(progressRange);
float fractions[3];
this->CalculateSuperclassFraction(fractions);
// Set the range of progress for the superclass.
this->SetProgressRange(progressRange, 0, fractions);
// Let the superclass write its data.
this->Superclass::WriteInlinePiece(index, indent);
// Set the range of progress for the coordinates arrays.
this->SetProgressRange(progressRange, 1, fractions);
// Write the coordinates arrays.
this->WriteCoordinatesInline(this->GetInput()->GetXCoordinates(),
this->GetInput()->GetYCoordinates(),
this->GetInput()->GetZCoordinates(),
indent);
}
//----------------------------------------------------------------------------
void vtkXMLRectilinearGridWriter::CalculateSuperclassFraction(float* fractions)
{
int extent[6];
this->ExtentTranslator->GetExtent(extent);
int dims[3] = {extent[1]-extent[0]+1,
extent[3]-extent[2]+1,
extent[5]-extent[4]+1};
// The amount of data written by the superclass comes from the
// point/cell data arrays.
vtkIdType superclassPieceSize =
(this->GetInput()->GetPointData()->GetNumberOfArrays()*dims[0]*dims[1]*dims[2]+
this->GetInput()->GetCellData()->GetNumberOfArrays()*(dims[0]-1)*(dims[1]-1)*(dims[2]-1));
// The total data written includes the coordinate arrays.
vtkIdType totalPieceSize =
superclassPieceSize + dims[0] + dims[1] + dims[2];
if(totalPieceSize == 0)
{
totalPieceSize = 1;
}
fractions[0] = 0;
fractions[1] = fractions[0] + float(superclassPieceSize)/totalPieceSize;
fractions[2] = 1;
}
......@@ -60,6 +60,7 @@ protected:
void GetInputExtent(int* extent);
const char* GetDataSetName();
vtkDataArray* CreateExactCoordinates(vtkDataArray* a, int xyz);
void CalculateSuperclassFraction(float* fractions);
// Coordinate array appended data positions.
unsigned long** CoordinatePositions;
......
......@@ -16,12 +16,15 @@
=========================================================================*/
#include "vtkXMLStructuredDataWriter.h"
#include "vtkDataSet.h"
#include "vtkCellData.h"
#include "vtkDataArray.h"
#include "vtkDataCompressor.h"
#include "vtkDataSet.h"
#include "vtkExtentTranslator.h"
#include "vtkPointData.h"
vtkCxxRevisionMacro(vtkXMLStructuredDataWriter, "1.1");
vtkCxxRevisionMacro(vtkXMLStructuredDataWriter, "1.2");
vtkCxxSetObjectMacro(vtkXMLStructuredDataWriter, ExtentTranslator,
vtkExtentTranslator);
......@@ -70,7 +73,7 @@ int vtkXMLStructuredDataWriter::WriteData()
input->UpdateInformation();
// Prepare the extent translator to create the set of pieces.
this->SetupExtentTranslator();
this->SetupExtentTranslator();
// Write the file.
this->StartFile();
......@@ -98,12 +101,12 @@ void vtkXMLStructuredDataWriter::WriteAppendedMode(vtkIndent indent)
// Prepare storage for the point and cell data array appended data
// offsets for each piece.
this->PointDataOffsets = new unsigned long*[this->NumberOfPieces];
this->CellDataOffsets = new unsigned long*[this->NumberOfPieces];
this->CellDataOffsets = new unsigned long*[this->NumberOfPieces];
// Update the first piece to get form of data setup.
vtkDataSet* input = this->GetInputAsDataSet();
this->ExtentTranslator->SetPiece(0);
this->ExtentTranslator->PieceToExtent();
this->ExtentTranslator->PieceToExtent();
input->SetUpdateExtent(this->ExtentTranslator->GetExtent());
input->Update();
......@@ -130,25 +133,36 @@ void vtkXMLStructuredDataWriter::WriteAppendedMode(vtkIndent indent)
}
// Close the primary element.
os << indent << "</" << this->GetDataSetName() << ">\n";
os << indent << "</" << this->GetDataSetName() << ">\n";
// Split progress of the data write by the fraction contributed by
// each piece.
float progressRange[2] = {0,0};
this->GetProgressRange(progressRange);
float* fractions = new float[this->NumberOfPieces+1];
this->CalculatePieceFractions(fractions);
// Write each piece's data.
this->StartAppendedData();
for(i=0;i < this->NumberOfPieces;++i)
{
// Set the progress range for this piece.
this->SetProgressRange(progressRange, i, fractions);
// Update the piece's data.
this->ExtentTranslator->SetPiece(i);
this->ExtentTranslator->PieceToExtent();
this->ExtentTranslator->PieceToExtent();
input->SetUpdateExtent(this->ExtentTranslator->GetExtent());
input->Update();
this->WriteAppendedPieceData(i);
}
this->EndAppendedData();
this->EndAppendedData();
// Cleanup.
delete [] fractions;
delete [] this->PointDataOffsets;
delete [] this->CellDataOffsets;
}
......@@ -166,13 +180,23 @@ void vtkXMLStructuredDataWriter::WriteInlineMode(vtkIndent indent)
this->WritePrimaryElementAttributes();
os << ">\n";
// Split progress of the data write by the fraction contributed by
// each piece.
float progressRange[2] = {0,0};
this->GetProgressRange(progressRange);
float* fractions = new float[this->NumberOfPieces+1];
this->CalculatePieceFractions(fractions);
// Write each piece's XML and data.
for(i=0; i < this->NumberOfPieces; ++i)
{
// Set the progress range for this piece.
this->SetProgressRange(progressRange, i, fractions);
// Update the piece's extent and data.
this->ExtentTranslator->SetPiece(i);
this->ExtentTranslator->PieceToExtent();