Commit 5c238b17 authored by Sean McBride's avatar Sean McBride

Converted the last remaining sprintf to snprintf

These changes are more invasive than my previous conversions.
a) Some private/protected method signatures now take a size parameter.
b) Deleted vtkMPEG2Writer entirely, because 1) it uses sprintf and I can’t find the size of the buffer, I think it’s been removed. 2) The class hasn’t been built in years.
c) some new defines introduced to avoid copy-pasting magic numbers.

The only remaining sprintf, I think, are in third party or C code.
parent 4305917c
......@@ -108,22 +108,25 @@ int main(int argc, char *argv[])
}
else if ( !strcmp( argv[count], "-DICOM" ) )
{
dirname = new char[strlen(argv[count+1])+1];
sprintf( dirname, "%s", argv[count+1] );
size_t size = strlen(argv[count+1])+1;
dirname = new char[size];
snprintf( dirname, size, "%s", argv[count+1] );
count += 2;
}
else if ( !strcmp( argv[count], "-VTI" ) )
{
fileName = new char[strlen(argv[count+1])+1];
size_t size = strlen(argv[count+1])+1;
fileName = new char[size];
fileType = VTI_FILETYPE;
sprintf( fileName, "%s", argv[count+1] );
snprintf( fileName, size, "%s", argv[count+1] );
count += 2;
}
else if ( !strcmp( argv[count], "-MHA" ) )
{
fileName = new char[strlen(argv[count+1])+1];
size_t size = strlen(argv[count+1])+1;
fileName = new char[size];
fileType = MHA_FILETYPE;
sprintf( fileName, "%s", argv[count+1] );
snprintf( fileName, size, "%s", argv[count+1] );
count += 2;
}
else if ( !strcmp( argv[count], "-Clip") )
......
......@@ -135,22 +135,25 @@ int main(int argc, char *argv[])
}
else if ( !strcmp( argv[count], "-DICOM" ) )
{
dirname = new char[strlen(argv[count+1])+1];
sprintf( dirname, "%s", argv[count+1] );
size_t size = strlen(argv[count+1])+1;
dirname = new char[size];
snprintf( dirname, size, "%s", argv[count+1] );
count += 2;
}
else if ( !strcmp( argv[count], "-VTI" ) )
{
fileName = new char[strlen(argv[count+1])+1];
size_t size = strlen(argv[count+1])+1;
fileName = new char[size];
fileType = VTI_FILETYPE;
sprintf( fileName, "%s", argv[count+1] );
snprintf( fileName, size, "%s", argv[count+1] );
count += 2;
}
else if ( !strcmp( argv[count], "-MHA" ) )
{
fileName = new char[strlen(argv[count+1])+1];
size_t size = strlen(argv[count+1])+1;
fileName = new char[size];
fileType = MHA_FILETYPE;
sprintf( fileName, "%s", argv[count+1] );
snprintf( fileName, size, "%s", argv[count+1] );
count += 2;
}
else if ( !strcmp( argv[count], "-Clip") )
......
......@@ -3438,7 +3438,7 @@ void vtkExodusIIReaderPrivate::RemoveBeginningAndTrailingSpaces( int len, char *
if (cend < cbegin)
{
sprintf(names[i], "null_%d", i);
snprintf(names[i], MAX_STR_LENGTH + 1, "null_%d", i);
continue;
}
......
......@@ -67,7 +67,7 @@ public:
{
this->Grow();
}
int nchars = sprintf(this->Top, "%s", newcontent);
int nchars = snprintf(this->Top, this->MaxBufferSize, "%s", newcontent);
this->Top+=nchars;
}
inline void append(const double newcontent)
......@@ -77,7 +77,7 @@ public:
{
this->Grow();
}
int nchars = sprintf(this->Top, "%s", this->NumBuffer);
int nchars = snprintf(this->Top, this->MaxBufferSize, "%s", this->NumBuffer);
this->Top+=nchars;
}
char *Buffer;
......
......@@ -123,13 +123,15 @@ void vtkImageReader2::ComputeInternalFileName(int slice)
if (this->FileNames)
{
const char *filename = this->FileNames->GetValue(slice);
this->InternalFileName = new char [strlen(filename) + 10];
sprintf(this->InternalFileName,"%s",filename);
size_t size = strlen(filename) + 10;
this->InternalFileName = new char [size];
snprintf(this->InternalFileName,size,"%s",filename);
}
else if (this->FileName)
{
this->InternalFileName = new char [strlen(this->FileName) + 10];
sprintf(this->InternalFileName,"%s",this->FileName);
size_t size = strlen(this->FileName) + 10;
this->InternalFileName = new char [size];
snprintf(this->InternalFileName,size,"%s",this->FileName);
}
else
{
......@@ -138,14 +140,15 @@ void vtkImageReader2::ComputeInternalFileName(int slice)
+ this->FileNameSliceOffset;
if (this->FilePrefix && this->FilePattern)
{
this->InternalFileName = new char [strlen(this->FilePrefix) +
strlen(this->FilePattern) + 10];
sprintf (this->InternalFileName, this->FilePattern,
this->FilePrefix, slicenum);
size_t size = strlen(this->FilePrefix) + strlen(this->FilePattern) + 10;
this->InternalFileName = new char [size];
snprintf (this->InternalFileName, size, this->FilePattern,
this->FilePrefix, slicenum);
}
else if (this->FilePattern)
{
this->InternalFileName = new char [strlen(this->FilePattern) + 10];
size_t size = strlen(this->FilePattern) + 10;
this->InternalFileName = new char [size];
int len = static_cast<int>(strlen(this->FilePattern));
int hasPercentS = 0;
for(int i =0; i < len-1; ++i)
......@@ -158,11 +161,11 @@ void vtkImageReader2::ComputeInternalFileName(int slice)
}
if(hasPercentS)
{
sprintf (this->InternalFileName, this->FilePattern, "", slicenum);
snprintf (this->InternalFileName, size, this->FilePattern, "", slicenum);
}
else
{
sprintf (this->InternalFileName, this->FilePattern, slicenum);
snprintf (this->InternalFileName, size, this->FilePattern, slicenum);
}
}
else
......
......@@ -91,7 +91,7 @@ public:
//@{
/**
* The sprintf-style format string used to build filename from
* The snprintf-style format string used to build filename from
* FilePrefix and slice number.
*/
virtual void SetFilePattern(const char *);
......
......@@ -35,6 +35,7 @@ vtkImageWriter::vtkImageWriter()
this->FilePattern = NULL;
this->FileName = NULL;
this->InternalFileName = NULL;
this->InternalFileNameSize = 0;
this->FileNumber = 0;
this->FileDimensionality = 2;
......@@ -119,10 +120,10 @@ int vtkImageWriter::RequestData(
}
// Make sure the file name is allocated
this->InternalFileName =
new char[(this->FileName ? strlen(this->FileName) : 1) +
(this->FilePrefix ? strlen(this->FilePrefix) : 1) +
(this->FilePattern ? strlen(this->FilePattern) : 1) + 10];
this->InternalFileNameSize = (this->FileName ? strlen(this->FileName) : 1) +
(this->FilePrefix ? strlen(this->FilePrefix) : 1) +
(this->FilePattern ? strlen(this->FilePattern) : 1) + 10;
this->InternalFileName = new char[this->InternalFileNameSize];
// Fill in image information.
int *wExt = inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT());
......@@ -148,6 +149,7 @@ int vtkImageWriter::RequestData(
delete [] this->InternalFileName;
this->InternalFileName = NULL;
this->InternalFileNameSize = 0;
return 1;
}
......@@ -177,18 +179,27 @@ void vtkImageWriter::RecursiveWrite(int axis,
// determine the name
if (this->FileName)
{
sprintf(this->InternalFileName,"%s",this->FileName);
snprintf(this->InternalFileName,
this->InternalFileNameSize,
"%s",
this->FileName);
}
else
{
if (this->FilePrefix)
{
sprintf(this->InternalFileName, this->FilePattern,
this->FilePrefix, this->FileNumber);
snprintf(this->InternalFileName,
this->InternalFileNameSize,
this->FilePattern,
this->FilePrefix,
this->FileNumber);
}
else
{
sprintf(this->InternalFileName, this->FilePattern,this->FileNumber);
snprintf(this->InternalFileName,
this->InternalFileNameSize,
this->FilePattern,
this->FileNumber);
}
if (this->FileNumber < this->MinimumFileNumber)
{
......@@ -298,18 +309,27 @@ void vtkImageWriter::RecursiveWrite(int axis,
// determine the name
if (this->FileName)
{
sprintf(this->InternalFileName,"%s",this->FileName);
snprintf(this->InternalFileName,
this->InternalFileNameSize,
"%s",
this->FileName);
}
else
{
if (this->FilePrefix)
{
sprintf(this->InternalFileName, this->FilePattern,
this->FilePrefix, this->FileNumber);
snprintf(this->InternalFileName,
this->InternalFileNameSize,
this->FilePattern,
this->FilePrefix,
this->FileNumber);
}
else
{
sprintf(this->InternalFileName, this->FilePattern,this->FileNumber);
snprintf(this->InternalFileName,
this->InternalFileNameSize,
this->FilePattern,
this->FileNumber);
}
if (this->FileNumber < this->MinimumFileNumber)
{
......
......@@ -58,7 +58,7 @@ public:
//@{
/**
* The sprintf format used to build filename from FilePrefix and number.
* The snprintf format used to build filename from FilePrefix and number.
*/
vtkSetStringMacro(FilePattern);
vtkGetStringMacro(FilePattern);
......@@ -97,6 +97,8 @@ protected:
int FileNumber;
int FileLowerLeft;
char *InternalFileName;
size_t InternalFileNameSize;
// Required for subclasses that need to prevent the writer
// from touching the file system. The getter/setter are only
// available in these subclasses.
......
......@@ -71,9 +71,9 @@ void vtkJPEGWriter::Write()
}
// Make sure the file name is allocated
size_t InternalFileNameSize = (this->FileName ? strlen(this->FileName) : 1) +
(this->FilePrefix ? strlen(this->FilePrefix) : 1) +
(this->FilePattern ? strlen(this->FilePattern) : 1) + 10;
this->InternalFileNameSize = (this->FileName ? strlen(this->FileName) : 1) +
(this->FilePrefix ? strlen(this->FilePrefix) : 1) +
(this->FilePattern ? strlen(this->FilePattern) : 1) + 10;
this->InternalFileName = new char[InternalFileNameSize];
// Fill in image information.
......@@ -97,19 +97,27 @@ void vtkJPEGWriter::Write()
// determine the name
if (this->FileName)
{
sprintf(this->InternalFileName,"%s",this->FileName);
snprintf(this->InternalFileName,
this->InternalFileNameSize,
"%s",
this->FileName);
}
else
{
if (this->FilePrefix)
{
sprintf(this->InternalFileName, this->FilePattern,
this->FilePrefix, this->FileNumber);
snprintf(this->InternalFileName,
this->InternalFileNameSize,
this->FilePattern,
this->FilePrefix,
this->FileNumber);
}
else
{
snprintf(this->InternalFileName, InternalFileNameSize,
this->FilePattern, this->FileNumber);
snprintf(this->InternalFileName,
this->InternalFileNameSize,
this->FilePattern,
this->FileNumber);
}
}
this->GetInputAlgorithm()->UpdateExtent(uExtent);
......
set(Module_SRCS
vtkGenericMovieWriter.cxx
#vtkMPEG2Writer.cxx # Do we want to continue supporting?
)
set_source_files_properties(
......
......@@ -10,7 +10,6 @@ endif()
vtk_add_test_cxx(${vtk-module}CxxTests tests
NO_VALID
# TestMovieWriter.cxx # fixme (deps not satisfied)
${TEST_SRC}
)
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestMovieWriter.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME Test of vtkMPEG2Writer
// .SECTION Description
//
#include "vtkImageCast.h"
#include "vtkImageData.h"
#include "vtkImageMandelbrotSource.h"
#include "vtkImageMapToColors.h"
#include "vtkLookupTable.h"
#include "vtkMPEG2Writer.h"
#include "vtksys/SystemTools.hxx"
int TestMovieWriter(int vtkNotUsed(argc), char* vtkNotUsed(argv)[])
{
int err = 0;
int cc = 0;
int exists = 0;
unsigned long length = 0;
vtkImageMandelbrotSource* Fractal0 = vtkImageMandelbrotSource::New();
Fractal0->SetWholeExtent( 0, 247, 0, 247, 0, 0 );
Fractal0->SetProjectionAxes( 0, 1, 2 );
Fractal0->SetOriginCX( -1.75, -1.25, 0, 0 );
Fractal0->SetSizeCX( 2.5, 2.5, 2, 1.5 );
Fractal0->SetMaximumNumberOfIterations( 100);
vtkImageCast* cast = vtkImageCast::New();
cast->SetInputConnection(Fractal0->GetOutputPort());
cast->SetOutputScalarTypeToUnsignedChar();
vtkLookupTable* table = vtkLookupTable::New();
table->SetTableRange(0, 100);
table->SetNumberOfColors(100);
table->Build();
table->SetTableValue(99, 0, 0, 0);
vtkImageMapToColors* colorize = vtkImageMapToColors::New();
colorize->SetOutputFormatToRGB();
colorize->SetLookupTable(table);
colorize->SetInputConnection(cast->GetOutputPort());
vtkMPEG2Writer *w = vtkMPEG2Writer::New();
w->SetInputConnection(colorize->GetOutputPort());
w->SetFileName("TestMovieWriter.mpg");
cout << "Writing file TestMovieWriter.mpg..." << endl;
w->Start();
for ( cc = 2; cc < 99; cc ++ )
{
cout << ".";
Fractal0->SetMaximumNumberOfIterations(cc);
table->SetTableRange(0, cc);
table->SetNumberOfColors(cc);
table->ForceBuild();
table->SetTableValue(cc-1, 0, 0, 0);
w->Write();
}
w->End();
cout << endl;
cout << "Done writing file TestMovieWriter.mpg..." << endl;
w->Delete();
exists = (int) vtksys::SystemTools::FileExists("TestMovieWriter.mpg");
length = vtksys::SystemTools::FileLength("TestMovieWriter.mpg");
cout << "TestMovieWriter.mpg file exists: " << exists << endl;
cout << "TestMovieWriter.mpg file length: " << length << endl;
if (!exists)
{
err = 1;
cerr << "ERROR: 1 - Test failing because TestMovieWriter.mpg file doesn't exist..." << endl;
}
if (0==length)
{
err = 2;
cerr << "ERROR: 2 - Test failing because TestMovieWriter.mpg file has zero length..." << endl;
}
colorize->Delete();
table->Delete();
cast->Delete();
Fractal0->Delete();
// err == 0 means test passes...
//
return err;
}
......@@ -20,7 +20,7 @@
* on the Microsoft Windows platform. The data type of the file is
* unsigned char regardless of the input type.
* @sa
* vtkGenericMovieWriter vtkMPEG2Writer
* vtkGenericMovieWriter
*/
#ifndef vtkAVIWriter_h
......
......@@ -22,7 +22,7 @@
* the file (i.e. the contents of the vtkImageData), End() will finalize
* and close the file.
* @sa
* vtkAVIWriter vtkMPEG2Writer
* vtkAVIWriter
*/
#ifndef vtkGenericMovieWriter_h
......
This diff is collapsed.
/*=========================================================================
Program: Visualization Toolkit
Module: vtkMPEG2Writer.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
/**
* @class vtkMPEG2Writer
* @brief Writes MPEG2 Movie files.
*
*
* vtkMPEG2Writer writes Movie files. The data type
* of the file is unsigned char regardless of the input type.
*
* This class is conditionally compiled into VTK only if VTK's CMake
* option VTK_USE_MPEG2_ENCODER is ON. It is OFF by default.
*
* Portions of the mpeg2 library are patented. VTK does not enable linking to
* this library by default so VTK can remain "patent free". Users who wish to
* link in mpeg2 functionality must build that library separately and then
* turn on VTK_USE_MPEG2_ENCODER when configuring VTK. After turning on
* VTK_USE_MPEG2_ENCODER, you must also set the CMake variables
* vtkMPEG2Encode_INCLUDE_PATH and vtkMPEG2Encode_LIBRARIES.
*
* You are solely responsible for any legal issues associated with using
* patented code in your software.
*
* You can download a "CMake-ified" source tree of the MPEG2 library by
* visiting the download page at http://www.vtk.org and scrolling down to
* the "Download Additional Components" section.
*
* @sa
* vtkGenericMovieWriter vtkAVIWriter vtkFFMPEGWriter
*/
#ifndef vtkMPEG2Writer_h
#define vtkMPEG2Writer_h
#include "vtkIOMovieModule.h" // For export macro
#include "vtkGenericMovieWriter.h"
class vtkMPEG2WriterInternal;
class vtkImageData;
struct MPEG2_structure;
class VTKIOMOVIE_EXPORT vtkMPEG2Writer : public vtkGenericMovieWriter
{
public:
static vtkMPEG2Writer *New();
vtkTypeMacro(vtkMPEG2Writer,vtkGenericMovieWriter);
void PrintSelf(ostream& os, vtkIndent indent);
//@{
/**
* These methods start writing an Movie file, write a frame to the file
* and then end the writing process.
*/
void Start();
void Write();
void End();
//@}
protected:
vtkMPEG2Writer();
~vtkMPEG2Writer();
vtkMPEG2WriterInternal *Internals;
long Time;
int ActualWrittenTime;
void Initialize();
int Initialized;
MPEG2_structure* MPEGStructure;
private:
vtkMPEG2Writer(const vtkMPEG2Writer&) VTK_DELETE_FUNCTION;
void operator=(const vtkMPEG2Writer&) VTK_DELETE_FUNCTION;
};
#endif
......@@ -607,7 +607,7 @@ void vtkPDataSetReader::ReadPVTKFileInformation(
// Copy filename (relative path?)
if (val[0] != '/' && val[1] != ':' && dirLength > 0)
{ // Must be a relative path.
sprintf(this->PieceFileNames[i], "%s%s", dir, val);
snprintf(this->PieceFileNames[i], 512, "%s%s", dir, val);
}
else
{
......
......@@ -239,7 +239,8 @@ int vtkPDataSetWriter::Write()
{
case VTK_POLY_DATA:
case VTK_UNSTRUCTURED_GRID:
if (!this->WriteUnstructuredMetaData(input, fileRoot, fileName, fptr))
if (!this->WriteUnstructuredMetaData(input, fileRoot,
fileName, fileNameSize, fptr))
{
this->CloseVTKFile(fptr);
remove(this->FileName);
......@@ -253,7 +254,7 @@ int vtkPDataSetWriter::Write()
case VTK_IMAGE_DATA:
case VTK_STRUCTURED_POINTS:
if (!this->WriteImageMetaData((vtkImageData*)input, fileRoot,
fileName, fptr))
fileName, fileNameSize, fptr))
{
this->CloseVTKFile(fptr);
remove(this->FileName);
......@@ -266,7 +267,8 @@ int vtkPDataSetWriter::Write()
break;
case VTK_RECTILINEAR_GRID:
if (!this->WriteRectilinearGridMetaData((vtkRectilinearGrid*)input,
fileRoot, fileName, fptr))
fileRoot, fileName,
fileNameSize, fptr))
{
this->CloseVTKFile(fptr);
remove(this->FileName);
......@@ -279,7 +281,8 @@ int vtkPDataSetWriter::Write()
break;
case VTK_STRUCTURED_GRID:
if (!this->WriteStructuredGridMetaData((vtkStructuredGrid*)input,
fileRoot, fileName, fptr))
fileRoot, fileName,
fileNameSize, fptr))
{
this->CloseVTKFile(fptr);
remove(this->FileName);
......@@ -304,7 +307,8 @@ int vtkPDataSetWriter::Write()
//----------------------------------------------------------------------------
int vtkPDataSetWriter::WriteUnstructuredMetaData(vtkDataSet *input,
char *root, char *str, ostream *fptr)
char *root, char *str,
size_t strSize, ostream *fptr)
{
int i;
......@@ -315,7 +319,7 @@ int vtkPDataSetWriter::WriteUnstructuredMetaData(vtkDataSet *input,
*fptr << " numberOfPieces=\"" << this->NumberOfPieces << "\" >" << endl;
for (i = 0; i < this->NumberOfPieces; ++i)
{
sprintf(str, this->FilePattern, root, i);
snprintf(str, strSize, this->FilePattern, root, i);
*fptr << " <Piece fileName=\"" << str << "\" />" << endl;
}
*fptr << "</File>" << endl;
......@@ -330,7 +334,8 @@ int vtkPDataSetWriter::WriteUnstructuredMetaData(vtkDataSet *input,
//----------------------------------------------------------------------------
int vtkPDataSetWriter::WriteImageMetaData(vtkImageData * input,
char *root, char *str, ostream *fptr)
char *root, char *str,
size_t strSize, ostream *fptr)
{
int *pi;
double *pf;
......@@ -434,7 +439,7 @@ int vtkPDataSetWriter::WriteImageMetaData(vtkImageData * input,
for (int i = 0; i < this->NumberOfPieces; ++i)
{
pi = &this->Extents[i][0];
sprintf(str, this->FilePattern, root, i);
snprintf(str, strSize, this->FilePattern, root, i);
*fptr << " <Piece fileName=\"" << str << "\"" << endl
<< " extent=\"" << pi[0] << " " << pi[1] << " " << pi[2] << " "
<< pi[3] << " " << pi[4] << " " << pi[5] << "\" />" << endl;
......@@ -450,7 +455,8 @@ int vtkPDataSetWriter::WriteImageMetaData(vtkImageData * input,
//----------------------------------------------------------------------------
int vtkPDataSetWriter::WriteRectilinearGridMetaData(vtkRectilinearGrid *input,
char *root, char *str, ostream *fptr)
char *root, char *str,
size_t strSize, ostream *fptr)
{
int i;
int *pi;
......@@ -470,7 +476,7 @@ int vtkPDataSetWriter::WriteRectilinearGridMetaData(vtkRectilinearGrid *input,
for (i = 0; i < this->NumberOfPieces; ++i)
{
pi = &this->Extents[i][0];
sprintf(str, this->FilePattern, root, i);
snprintf(str, strSize, this->FilePattern, root, i);
*fptr << " <Piece fileName=\"" << str << "\"" << endl
<< " extent=\"" << pi[0] << " " << pi[1] << " " << pi[2] << " "
<< pi[3] << " " << pi[4] << " " << pi[5] << "\" />" << endl;
......@@ -487,7 +493,8 @@ int vtkPDataSetWriter::WriteRectilinearGridMetaData(vtkRectilinearGrid *input,
//----------------------------------------------------------------------------
int vtkPDataSetWriter::WriteStructuredGridMetaData(vtkStructuredGrid *input,
char *root, char *str, ostream *fptr)
char *root, char *str,
size_t strSize, ostream *fptr)
{
int i;
int *pi;
......@@ -507,7 +514,7 @@ int vtkPDataSetWriter::WriteStructuredGridMetaData(vtkStructuredGrid *input,
for (i = 0; i < this->NumberOfPieces; ++i)
{
pi = &this->Extents[i][0];
sprintf(str, this->FilePattern, root, i);
snprintf(str, strSize, this->FilePattern, root, i);
*fptr << " <Piece fileName=\"" << str << "\"" << endl
<< " extent=\"" << pi[0] << " " << pi[1] << " " << pi[2] << " "
<< pi[3] << " " << pi[4] << " " << pi[5] << "\" />" << endl;
......
......@@ -113,13 +113,17 @@ protected:
ostream *OpenFile();
int WriteUnstructuredMetaData(vtkDataSet *input,
char *root, char *str, ostream *fptr);
char *root, char *str,
size_t strSize, ostream *fptr);
int WriteImageMetaData(vtkImageData *input,
char *root, char *str, ostream *fptr);
char *root, char *str,
size_t strSize, ostream *fptr);
int WriteRectilinearGridMetaData(vtkRectilinearGrid *input,
char *root, char *str, ostream *fptr);
char *root, char *str,
size_t strSize, ostream *fptr);
int WriteStructuredGridMetaData(vtkStructuredGrid *input,
char *root, char *str, ostream *fptr);
char *root, char *str,
size_t strSize, ostream *fptr);
int StartPiece;
int EndPiece;
......