Commit 45ee2ce1 authored by Amy Squillacote's avatar Amy Squillacote
Browse files

ENH: converting subclasses of vtkWriter to use the new pipeline

parent 82e491f0
......@@ -28,7 +28,7 @@
#include <vtkstd/string>
vtkCxxRevisionMacro(vtkBYUWriter, "1.56");
vtkCxxRevisionMacro(vtkBYUWriter, "1.57");
vtkStandardNewMacro(vtkBYUWriter);
// Create object so that it writes displacement, scalar, and texture files
......@@ -69,7 +69,14 @@ vtkBYUWriter::~vtkBYUWriter()
void vtkBYUWriter::WriteData()
{
FILE *geomFp;
vtkPolyData *input= this->GetInput();
vtkPolyData *input= vtkPolyData::SafeDownCast(this->GetInput());
if (!input)
{
vtkErrorMacro("Input is not a vtkPolyData.");
return;
}
int numPts=input->GetNumberOfPoints();
if ( numPts < 1 )
......@@ -175,7 +182,7 @@ void vtkBYUWriter::WriteGeometryFile(FILE *geomFile, int numPts)
vtkIdType *pts = 0;
vtkPoints *inPts;
vtkCellArray *inPolys;
vtkPolyData *input= this->GetInput();
vtkPolyData *input= vtkPolyData::SafeDownCast(this->GetInput());
//
// Check input
//
......@@ -264,7 +271,7 @@ void vtkBYUWriter::WriteDisplacementFile(int numPts)
int i;
double *v;
vtkDataArray *inVectors;
vtkPolyData *input= this->GetInput();
vtkPolyData *input= vtkPolyData::SafeDownCast(this->GetInput());
if ( this->WriteDisplacement && this->DisplacementFileName &&
(inVectors = input->GetPointData()->GetVectors()) != NULL )
......@@ -313,7 +320,7 @@ void vtkBYUWriter::WriteScalarFile(int numPts)
int i;
float s;
vtkDataArray *inScalars;
vtkPolyData *input= this->GetInput();
vtkPolyData *input= vtkPolyData::SafeDownCast(this->GetInput());
if ( this->WriteScalar && this->ScalarFileName &&
(inScalars = input->GetPointData()->GetScalars()) != NULL )
......@@ -362,7 +369,7 @@ void vtkBYUWriter::WriteTextureFile(int numPts)
int i;
double *t;
vtkDataArray *inTCoords;
vtkPolyData *input= this->GetInput();
vtkPolyData *input= vtkPolyData::SafeDownCast(this->GetInput());
if ( this->WriteTexture && this->TextureFileName &&
(inTCoords = input->GetPointData()->GetTCoords()) != NULL )
......
......@@ -24,7 +24,7 @@
#include "vtkCellData.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkCGMWriter, "1.18");
vtkCxxRevisionMacro(vtkCGMWriter, "1.19");
vtkStandardNewMacro(vtkCGMWriter);
vtkCxxSetObjectMacro(vtkCGMWriter, Viewport, vtkViewport);
......@@ -528,7 +528,14 @@ int vtkCGMqsortCompare(const void *val1, const void *val2)
void vtkCGMWriter::WriteData()
{
FILE *outf;
vtkPolyData *input=this->GetInput();
vtkPolyData *input=vtkPolyData::SafeDownCast(this->GetInput());
if (!input)
{
vtkErrorMacro("Input is not a vtkPolyData.");
return;
}
vtkIdType numCells=input->GetNumberOfCells(), cellId;
vtkIdType numPts=input->GetNumberOfPoints();
......
......@@ -15,9 +15,10 @@
#include "vtkDataObjectWriter.h"
#include "vtkDataObject.h"
#include "vtkInformation.h"
#include "vtkObjectFactory.h"
vtkCxxRevisionMacro(vtkDataObjectWriter, "1.15");
vtkCxxRevisionMacro(vtkDataObjectWriter, "1.16");
vtkStandardNewMacro(vtkDataObjectWriter);
vtkDataObjectWriter::vtkDataObjectWriter()
......@@ -30,23 +31,6 @@ vtkDataObjectWriter::~vtkDataObjectWriter()
this->Writer->Delete();
}
//----------------------------------------------------------------------------
void vtkDataObjectWriter::SetInput(vtkDataObject *input)
{
this->vtkProcessObject::SetNthInput(0, input);
}
//----------------------------------------------------------------------------
vtkDataObject *vtkDataObjectWriter::GetInput()
{
if (this->NumberOfInputs < 1)
{
return NULL;
}
return (vtkDataObject *)(this->Inputs[0]);
}
// Write FieldData data to file
void vtkDataObjectWriter::WriteData()
{
......@@ -100,6 +84,10 @@ void vtkDataObjectWriter::PrintSelf(ostream& os, vtkIndent indent)
{
os << indent << "Field Data Name: (None)\n";
}
}
int vtkDataObjectWriter::FillInputPortInformation(int, vtkInformation *info)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataObject");
return 1;
}
......@@ -37,11 +37,6 @@ public:
vtkTypeRevisionMacro(vtkDataObjectWriter,vtkWriter);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set / get the input data or filter.
void SetInput(vtkDataObject *input);
vtkDataObject *GetInput();
// Description:
// Methods delegated to vtkDataWriter, see vtkDataWriter.
void SetFileName(const char *filename) {this->Writer->SetFileName(filename);};
......@@ -61,12 +56,12 @@ protected:
void WriteData();
vtkDataWriter *Writer;
virtual int FillInputPortInformation(int port, vtkInformation *info);
private:
vtkDataObjectWriter(const vtkDataObjectWriter&); // Not implemented.
void operator=(const vtkDataObjectWriter&); // Not implemented.
};
#endif
......@@ -17,6 +17,7 @@
#include "vtkDataSet.h"
#include "vtkErrorCode.h"
#include "vtkImageData.h"
#include "vtkInformation.h"
#include "vtkObjectFactory.h"
#include "vtkPolyData.h"
#include "vtkPolyDataWriter.h"
......@@ -28,32 +29,14 @@
#include "vtkUnstructuredGrid.h"
#include "vtkUnstructuredGridWriter.h"
vtkCxxRevisionMacro(vtkDataSetWriter, "1.38");
vtkCxxRevisionMacro(vtkDataSetWriter, "1.39");
vtkStandardNewMacro(vtkDataSetWriter);
//----------------------------------------------------------------------------
// Specify the input data or filter.
void vtkDataSetWriter::SetInput(vtkDataSet *input)
{
this->vtkProcessObject::SetNthInput(0, input);
}
//----------------------------------------------------------------------------
// Specify the input data or filter.
vtkDataSet *vtkDataSetWriter::GetInput()
{
if (this->NumberOfInputs < 1)
{
return NULL;
}
return static_cast<vtkDataSet*>(this->Inputs[0]);
}
void vtkDataSetWriter::WriteData()
{
int type;
vtkDataWriter *writer;
vtkDataSet *input = this->GetInput();
vtkDataSet *input = vtkDataSet::SafeDownCast(this->GetInput());
vtkDebugMacro(<<"Writing vtk dataset...");
......@@ -130,6 +113,12 @@ void vtkDataSetWriter::WriteData()
writer->Delete();
}
int vtkDataSetWriter::FillInputPortInformation(int, vtkInformation *info)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet");
return 1;
}
void vtkDataSetWriter::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
......
......@@ -30,17 +30,14 @@ public:
vtkTypeRevisionMacro(vtkDataSetWriter,vtkDataWriter);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set / get the input data or filter.
void SetInput(vtkDataSet *input);
vtkDataSet *GetInput();
protected:
vtkDataSetWriter() {};
~vtkDataSetWriter() {};
void WriteData();
virtual int FillInputPortInformation(int port, vtkInformation *info);
private:
vtkDataSetWriter(const vtkDataSetWriter&); // Not implemented.
void operator=(const vtkDataSetWriter&); // Not implemented.
......
......@@ -206,5 +206,3 @@ private:
};
#endif
......@@ -20,7 +20,7 @@
#include "vtkObjectFactory.h"
#include "vtkPolyData.h"
vtkCxxRevisionMacro(vtkIVWriter, "1.31");
vtkCxxRevisionMacro(vtkIVWriter, "1.32");
vtkStandardNewMacro(vtkIVWriter);
void vtkIVWriter::WriteData()
......@@ -48,7 +48,7 @@ void vtkIVWriter::WriteData()
vtkDebugMacro("Writing OpenInventor file");
fprintf(fp,"#Inventor V2.0 ascii\n");
fprintf(fp,"# OpenInventor file written by the visualization toolkit\n\n");
this->WritePolyData(this->GetInput(), fp);
this->WritePolyData(vtkPolyData::SafeDownCast(this->GetInput()), fp);
if (fclose(fp))
{
vtkErrorMacro(<< this->FileName
......
......@@ -20,7 +20,7 @@
#include "vtkPointData.h"
#include "vtkPolyData.h"
vtkCxxRevisionMacro(vtkMCubesWriter, "1.32");
vtkCxxRevisionMacro(vtkMCubesWriter, "1.33");
vtkStandardNewMacro(vtkMCubesWriter);
// Create object.
......@@ -46,7 +46,13 @@ void vtkMCubesWriter::WriteData()
vtkPoints *pts;
vtkDataArray *normals;
vtkCellArray *polys;
vtkPolyData *input=this->GetInput();
vtkPolyData *input=vtkPolyData::SafeDownCast(this->GetInput());
if (!input)
{
vtkErrorMacro("Input is not a vtkPolyData.");
return;
}
polys = input->GetPolys();
pts = input->GetPoints();
......
......@@ -24,7 +24,7 @@
#include <stddef.h>
vtkCxxRevisionMacro(vtkPLYWriter, "1.20");
vtkCxxRevisionMacro(vtkPLYWriter, "1.21");
vtkStandardNewMacro(vtkPLYWriter);
vtkCxxSetObjectMacro(vtkPLYWriter,LookupTable,vtkScalarsToColors);
......@@ -72,7 +72,14 @@ void vtkPLYWriter::WriteData()
vtkIdType i, j, idx;
vtkPoints *inPts;
vtkCellArray *polys;
vtkPolyData *input = this->GetInput();
vtkPolyData *input = vtkPolyData::SafeDownCast(this->GetInput());
if (!input)
{
vtkErrorMacro("Input is not a vtkPolyData.");
return;
}
unsigned char *cellColors, *pointColors;
PlyFile *ply;
float version;
......
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkPolyDataWriter.h"
#include "vtkInformation.h"
#include "vtkObjectFactory.h"
#include "vtkPolyData.h"
......@@ -23,32 +24,13 @@
# include <io.h> /* unlink */
#endif
vtkCxxRevisionMacro(vtkPolyDataWriter, "1.24");
vtkCxxRevisionMacro(vtkPolyDataWriter, "1.25");
vtkStandardNewMacro(vtkPolyDataWriter);
//----------------------------------------------------------------------------
// Specify the input data or filter.
void vtkPolyDataWriter::SetInput(vtkPolyData *input)
{
this->vtkProcessObject::SetNthInput(0, input);
}
//----------------------------------------------------------------------------
// Specify the input data or filter.
vtkPolyData *vtkPolyDataWriter::GetInput()
{
if (this->NumberOfInputs < 1)
{
return NULL;
}
return (vtkPolyData *)(this->Inputs[0]);
}
void vtkPolyDataWriter::WriteData()
{
ostream *fp;
vtkPolyData *input = this->GetInput();
vtkPolyData *input = vtkPolyData::SafeDownCast(this->GetInput());
vtkDebugMacro(<<"Writing vtk polygonal data...");
......@@ -144,6 +126,12 @@ void vtkPolyDataWriter::WriteData()
this->CloseVTKFile(fp);
}
int vtkPolyDataWriter::FillInputPortInformation(int, vtkInformation *info)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkPolyData");
return 1;
}
void vtkPolyDataWriter::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
......
......@@ -33,17 +33,14 @@ public:
vtkTypeRevisionMacro(vtkPolyDataWriter,vtkDataWriter);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set / get the input data or filter.
void SetInput(vtkPolyData *input);
vtkPolyData *GetInput();
protected:
vtkPolyDataWriter() {};
~vtkPolyDataWriter() {};
void WriteData();
virtual int FillInputPortInformation(int port, vtkInformation *info);
private:
vtkPolyDataWriter(const vtkPolyDataWriter&); // Not implemented.
void operator=(const vtkPolyDataWriter&); // Not implemented.
......
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkRectilinearGridWriter.h"
#include "vtkInformation.h"
#include "vtkObjectFactory.h"
#include "vtkRectilinearGrid.h"
......@@ -23,33 +24,14 @@
# include <io.h> /* unlink */
#endif
vtkCxxRevisionMacro(vtkRectilinearGridWriter, "1.24");
vtkCxxRevisionMacro(vtkRectilinearGridWriter, "1.25");
vtkStandardNewMacro(vtkRectilinearGridWriter);
//----------------------------------------------------------------------------
// Specify the input data or filter.
void vtkRectilinearGridWriter::SetInput(vtkRectilinearGrid *input)
{
this->vtkProcessObject::SetNthInput(0, input);
}
//----------------------------------------------------------------------------
// Specify the input data or filter.
vtkRectilinearGrid *vtkRectilinearGridWriter::GetInput()
{
if (this->NumberOfInputs < 1)
{
return NULL;
}
return (vtkRectilinearGrid *)(this->Inputs[0]);
}
void vtkRectilinearGridWriter::WriteData()
{
ostream *fp;
vtkRectilinearGrid *input = this->GetInput();
vtkRectilinearGrid *input = vtkRectilinearGrid::SafeDownCast(
this->GetInput());
int dim[3];
vtkDebugMacro(<<"Writing vtk rectilinear grid...");
......@@ -122,6 +104,13 @@ void vtkRectilinearGridWriter::WriteData()
this->CloseVTKFile(fp);
}
int vtkRectilinearGridWriter::FillInputPortInformation(int,
vtkInformation *info)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkRectilinearGrid");
return 1;
}
void vtkRectilinearGridWriter::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
......
......@@ -33,11 +33,6 @@ public:
static vtkRectilinearGridWriter *New();
vtkTypeRevisionMacro(vtkRectilinearGridWriter,vtkDataWriter);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set / get the input data or filter.
void SetInput(vtkRectilinearGrid *input);
vtkRectilinearGrid *GetInput();
protected:
vtkRectilinearGridWriter() {};
......@@ -45,11 +40,11 @@ protected:
void WriteData();
virtual int FillInputPortInformation(int port, vtkInformation *info);
private:
vtkRectilinearGridWriter(const vtkRectilinearGridWriter&); // Not implemented.
void operator=(const vtkRectilinearGridWriter&); // Not implemented.
};
#endif
......@@ -27,7 +27,7 @@
# include <io.h> /* unlink */
#endif
vtkCxxRevisionMacro(vtkSTLWriter, "1.55");
vtkCxxRevisionMacro(vtkSTLWriter, "1.56");
vtkStandardNewMacro(vtkSTLWriter);
vtkSTLWriter::vtkSTLWriter()
......@@ -39,7 +39,13 @@ void vtkSTLWriter::WriteData()
{
vtkPoints *pts;
vtkCellArray *polys;
vtkPolyData *input = this->GetInput();
vtkPolyData *input = vtkPolyData::SafeDownCast(this->GetInput());
if (!input)
{
vtkErrorMacro("Input is not a vtkPolyData.");
return;
}
polys = input->GetPolys();
pts = input->GetPoints();
......
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkStructuredGridWriter.h"
#include "vtkInformation.h"
#include "vtkObjectFactory.h"
#include "vtkStructuredGrid.h"
#include "vtkUnsignedCharArray.h"
......@@ -24,32 +25,13 @@
# include <io.h> /* unlink */
#endif
vtkCxxRevisionMacro(vtkStructuredGridWriter, "1.38");
vtkCxxRevisionMacro(vtkStructuredGridWriter, "1.39");
vtkStandardNewMacro(vtkStructuredGridWriter);
//----------------------------------------------------------------------------
// Specify the input data or filter.
void vtkStructuredGridWriter::SetInput(vtkStructuredGrid *input)
{
this->vtkProcessObject::SetNthInput(0, input);
}
//----------------------------------------------------------------------------
// Specify the input data or filter.
vtkStructuredGrid *vtkStructuredGridWriter::GetInput()
{
if (this->NumberOfInputs < 1)
{
return NULL;
}
return (vtkStructuredGrid *)(this->Inputs[0]);
}
void vtkStructuredGridWriter::WriteData()
{
ostream *fp;
vtkStructuredGrid *input= this->GetInput();
vtkStructuredGrid *input= vtkStructuredGrid::SafeDownCast(this->GetInput());
int dim[3];
vtkDebugMacro(<<"Writing vtk structured grid...");
......@@ -130,6 +112,12 @@ int vtkStructuredGridWriter::WriteBlanking(ostream *fp, vtkStructuredGrid *grid)
return this->WriteArray(fp, VTK_UNSIGNED_CHAR, blanking, " %s\n", numPts, 1);
}
int vtkStructuredGridWriter::FillInputPortInformation(int,
vtkInformation *info)
{
info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkStructuredGrid");
return 1;
}
void vtkStructuredGridWriter::PrintSelf(ostream& os, vtkIndent indent)
{
......
......@@ -34,11 +34,6 @@ public:
vtkTypeRevisionMacro(vtkStructuredGridWriter,vtkDataWriter);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Set / get the input data or filter.
void SetInput(vtkStructuredGrid *input);
vtkStructuredGrid *GetInput();
protected:
vtkStructuredGridWriter() {};
~vtkStructuredGridWriter() {};
......@@ -46,11 +41,11 @@ protected:
void WriteData();
int WriteBlanking(ostream *fp, vtkStructuredGrid *ds);
virtual int FillInputPortInformation(int port, vtkInformation *info);
private:
vtkStructuredGridWriter(const vtkStructuredGridWriter&); // Not implemented.
void operator=(const vtkStructuredGridWriter&); // Not implemented.
};
#endif
......@@ -14,6 +14,7 @@
=========================================================================*/
#include "vtkStructuredPointsWriter.h"
#include "vtkInformation.h"
#include "vtkObjectFactory.h"
#include "vtkStructuredPoints.h"
......@@ -24,33 +25,13 @@
#endif
vtkCxxRevisionMacro(vtkStructuredPointsWriter, "1.40");
vtkCxxRevisionMacro(vtkStructuredPointsWriter, "1.41");
vtkStandardNewMacro(vtkStructuredPointsWriter);
//----------------------------------------------------------------------------
// Specify the input data or filter.
void vtkStructuredPointsWriter::SetInput(vtkImageData *input)
{
this->vtkProcessObject::SetNthInput(0, input);
}
//----------------------------------------------------------------------------
// Specify the input data or filter.
vtkImageData *vtkStructuredPointsWriter::GetInput()
{
if (this->NumberOfInputs < 1)
{
return NULL;
}
return (vtkImageData *)(this->Inputs[0]);
}
void vtkStructuredPointsWriter::WriteData()
{
ostream *fp;
vtkImageData *input=this->GetInput();
vtkImageData *input= vtkImageData::SafeDownCast(this->GetInput());
int dim[3];
int *ext;
double spacing[3], origin[3];
......@@ -115,6 +96,13 @@ void vtkStructuredPointsWriter::WriteData()
this->CloseVTKFile(fp);
}
int vtkStructuredPointsWriter::FillInputPortInformation(int,
vtkInformation *info)
{