[Paraview] VTK XML Binary Output

David Mulholland d.t.mulholland at googlemail.com
Tue Mar 31 09:06:54 EDT 2009


Hello,

I am currently trying to write my own quick output routine to generate a 
binary file using C++. I am currently trying to avoid having to use the vtk 
libraries because I only need a very basic output that doesn't change much. 
I so far have the ASCII output working no problem but I can't get the binary 
working.

I am using file.write() function to output the binary data and that seems to 
be working no problem and when used in a legacy format application it works 
perfectly except that the data is LittleEndian instead of BigEndian. That's 
why I have moved to BigEndian because I don't want to have to make the 
output routine for the data anymore complicated that file.write.

I started using the xml format and considering my output is raw binary and 
not base64 I changed it to be in the AppendedData section instead of 
DataArray. It still isn't working right, I get the following error when I 
try to load in ParaView:

ERROR: In ..\..\..\ParaView3\VTK\IO\vtkXMLStructuredDataReader.cxx, line 349
vtkXMLImageDataReader (0ADEC7F8): Error reading extent 0 422 0 242 0 1 from 
piece 0


ERROR: In ..\..\..\ParaView3\VTK\IO\vtkXMLDataReader.cxx, line 537
vtkXMLImageDataReader (0ADEC7F8): Cannot read cell data array "pressure" 
from PointData in piece 0.  The data array in the element may be too short.

The format of my output file is as follows:

<?xml version="1.0"?>
<VTKFile type="ImageData" version="0.1" byte_order="LittleEndian">
<ImageData WholeExtent="0 422 0 242 0 1" Origin="0 0 0" Spacing="1 1 1">
<Piece Extent="0 422 0 242 0 1">
<PointData>
</PointData>
<CellData Scalars="pressure">
<DataArray type="Float32" Name="pressure" format="appended" offset="0"/>
</CellData>
</Piece>
</ImageData>
<AppendedData encoding="raw">
_BINARYDATA
</AppendedData>
</VTKFile>

Note following an error message I have added an _ at the start of the binary 
data. Is this required?

One final thing, when using appended data, how do you calculate what the 
offset should be?

Thanks
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20090331/c9cfb591/attachment.htm>


More information about the ParaView mailing list