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

ENH: If the appended data section is encoded, the file format will be valid...

ENH: If the appended data section is encoded, the file format will be valid XML.  Writer now writes the <?xml version="1.0"?> XML header at the top in this case.  Also fixed crash on empty input.
parent 83177a65
......@@ -27,7 +27,7 @@
#include "vtkPoints.h"
#include "vtkUnsignedCharArray.h"
vtkCxxRevisionMacro(vtkXMLWriter, "1.3");
vtkCxxRevisionMacro(vtkXMLWriter, "1.4");
vtkCxxSetObjectMacro(vtkXMLWriter, Compressor, vtkDataCompressor);
//----------------------------------------------------------------------------
......@@ -181,6 +181,13 @@ void vtkXMLWriter::SetDataModeToAppended()
//----------------------------------------------------------------------------
int vtkXMLWriter::Write()
{
// Make sure we have input.
if(!this->Inputs || !this->Inputs[0])
{
vtkErrorMacro("No input provided!");
return 0;
}
// Make sure we have a file to write.
if(!this->FileName)
{
......@@ -237,6 +244,16 @@ vtkDataSet* vtkXMLWriter::GetInputAsDataSet()
void vtkXMLWriter::StartFile()
{
ostream& os = *(this->Stream);
// If this will really be a valid XML file, put the XML header at
// the top.
if(this->EncodeAppendedData)
{
os << "<?xml version=\"1.0\"?>\n";
}
// Open the document-level element. This will contain the rest of
// the elements.
os << "<VTKFile";
this->WriteFileAttributes();
os << ">\n";
......@@ -288,6 +305,8 @@ void vtkXMLWriter::WriteFileAttributes()
void vtkXMLWriter::EndFile()
{
ostream& os = *(this->Stream);
// Close the document-level element.
os << "</VTKFile>\n";
}
......
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