[Paraview] VTK XML Binary Output

David Mulholland d.t.mulholland at googlemail.com
Tue Mar 31 19:57:14 EDT 2009


Hi Thorsten,

That's really helpful. I don't quite know how to write out the number of bits as a char? If you could explain a way of how to do that it would be greatly appreciated. 

Also, how do I calculate what value goes in for the offset? I had a look at a couple of output files from paraview and it wasnt obvious how it was calculated.

Thanks
David


From: Thorsten Hater 
Sent: Tuesday, March 31, 2009 2:23 PM
To: David Mulholland 
Cc: paraview at paraview.org 
Subject: Re: [Paraview] VTK XML Binary Output


Hello,

the solution might be to append your data as

< DataArray ... format="appended">
</DataArray>
< AppendedData encoding="raw">
_NNNNData 
</AppendedData>
where you should replace NNNN with a four 
byte integer containing the number of bytes 
in the data array as 4 chars.
Setting the encoding to "raw" tells ParaView, that
the data is simply a stream of bytes rather than 
base64 encoded.
If you want to write Image I can supply a small
writer project for 2D data.

    Thorsten
 
David Mulholland schrieb: 
  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
------------------------------------------------------------------------------
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView

Follow this link to subscribe/unsubscribe:
http://www.paraview.org/mailman/listinfo/paraview
  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20090401/bce59b78/attachment.htm>


More information about the ParaView mailing list