<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META content=text/html;charset=iso-8859-1 http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.7000.0"></HEAD>
<BODY style="PADDING-LEFT: 10px; PADDING-RIGHT: 10px; PADDING-TOP: 15px" 
id=MailContainerBody leftMargin=0 topMargin=0 bgColor=#ffffff text=#000000 
CanvasTabStop="true" name="Compose message area">
<DIV><FONT face=Calibri>Hi Thorsten, </FONT></DIV>
<DIV><FONT face=Calibri></FONT>&nbsp;</DIV>
<DIV><FONT face=Calibri>I just tried that and it is now giving me a segmentation 
fault... I am using the following line: </FONT></DIV>
<DIV><FONT size=2>file.write(</FONT><FONT color=#40ffff size=2><FONT 
color=#40ffff size=2>reinterpret_cast</FONT></FONT><FONT size=2>&lt;</FONT><FONT 
color=#40ffff size=2><FONT color=#40ffff size=2>const</FONT></FONT><FONT size=2> 
</FONT><FONT color=#00bf00 size=2><FONT color=#00bf00 
size=2>char</FONT></FONT><FONT size=2>*&gt;(size), 4);</DIV></FONT>
<DIV style="FONT: 10pt Tahoma"><FONT size=3 face=Calibri></FONT>&nbsp;</DIV>
<DIV style="FONT: 10pt Tahoma">
<DIV><FONT size=3 face=Calibri>My size is calculated as - int size = 
idim*jdim*sizeof(float). idim is currently in the region of 400 and jdim 200. I 
am outputting big files and it is likely to get bigger.</FONT></DIV><FONT size=3 
face=Calibri></FONT></DIV>
<DIV style="FONT: 10pt Tahoma"><FONT size=3 face=Calibri></FONT><FONT size=3 
face=Calibri></FONT>&nbsp;</DIV>
<DIV style="FONT: 10pt Tahoma"><FONT size=3 face=Calibri>Also, I intend to 
include more data arrays each timestep, I just want to get it working with 
pressure first and then I will include then which is why I want to calculate the 
offset... I assuming it is just the number of bytes to the start of the next 
datafield...</FONT></DIV>
<DIV style="FONT: 10pt Tahoma"><FONT size=3 face=Calibri></FONT>&nbsp;</DIV>
<DIV style="FONT: 10pt Tahoma"><FONT size=3 face=Calibri>Thanks David</FONT> 
<DIV><BR></DIV>
<DIV style="BACKGROUND: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=th@tp1.rub.de 
href="mailto:th@tp1.rub.de">Thorsten Hater</A> </DIV>
<DIV><B>Sent:</B> Wednesday, April 01, 2009 10:55 AM</DIV>
<DIV><B>To:</B> <A title=d.t.mulholland@googlemail.com 
href="mailto:d.t.mulholland@googlemail.com">David Mulholland</A> </DIV>
<DIV><B>Cc:</B> <A title=paraview@paraview.org 
href="mailto:paraview@paraview.org">paraview@paraview.org</A> </DIV>
<DIV><B>Subject:</B> Re: [Paraview] VTK XML Binary Output</DIV></DIV></DIV>
<DIV><BR></DIV>Hello David,<BR><BR>the offset parameter is relevant if you 
append mulitple data sections into a single file.<BR>Every DataArray tag with 
append format specifies the offset as the position in the <BR>binary data in 
bytes.<BR>To write the integer I use the following:<BR><BR>std::ofstream os; // 
binary mode (for windows ...) ofstream to your file<BR>int N; // size in 
bytes<BR>os.write(reinterpret_cast&lt;const char*&gt;(N), 
4);<BR><BR>Thorsten<BR><BR>David Mulholland schrieb: 
<BLOCKQUOTE cite=mid:18639349767042A49C3C19BBF7440A56@dm105 type="cite">
  <META name=GENERATOR content="MSHTML 8.00.7000.0">
  <DIV>Hi Thorsten,<BR><BR>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. <BR><BR>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.<BR><BR>Thanks<BR>David</DIV>
  <DIV style="FONT: 10pt Tahoma; font-size-adjust: none; font-stretch: normal">
  <DIV><BR></DIV>
  <DIV 
  style="BACKGROUND: rgb(245,245,245) 0% 50%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial">
  <DIV><B>From:</B> <A title=th@tp1.rub.de href="mailto:th@tp1.rub.de" 
  moz-do-not-send="true">Thorsten Hater</A> </DIV>
  <DIV><B>Sent:</B> Tuesday, March 31, 2009 2:23 PM</DIV>
  <DIV><B>To:</B> <A title=d.t.mulholland@googlemail.com 
  href="mailto:d.t.mulholland@googlemail.com" moz-do-not-send="true">David 
  Mulholland</A> </DIV>
  <DIV><B>Cc:</B> <A title=paraview@paraview.org 
  href="mailto:paraview@paraview.org" 
  moz-do-not-send="true">paraview@paraview.org</A> </DIV>
  <DIV><B>Subject:</B> Re: [Paraview] VTK XML Binary Output</DIV></DIV></DIV>
  <DIV><BR></DIV>Hello,<BR><BR>the solution might be to append your data 
  as<BR><BR>&lt; DataArray ... 
  format="appended"&gt;<BR>&lt;/DataArray&gt;<BR>&lt; AppendedData 
  encoding="raw"&gt;<BR>_NNNNData <BR>&lt;/AppendedData&gt;<BR>where you should 
  replace NNNN with a four <BR>byte integer containing the number of bytes 
  <BR>in the data array as 4 chars.<BR>Setting the encoding to "raw" tells 
  ParaView, that<BR>the data is simply a stream of bytes rather than <BR>base64 
  encoded.<BR>If you want to write Image I can supply a small<BR>writer project 
  for 2D data.<BR><BR>&nbsp;&nbsp;&nbsp; Thorsten<BR>&nbsp;<BR>David Mulholland 
  schrieb: 
  <BLOCKQUOTE cite=mid:94F73CF1F23B43C096CCE910A36EC616@dm105 type="cite">
    <META name=GENERATOR content="MSHTML 8.00.7000.0">
    <DIV>Hello,<BR><BR>I am currently trying to write my own quick output 
    routine to generate a <BR>binary file using C++. I am currently trying to 
    avoid having to use the vtk <BR>libraries because I only need a very basic 
    output that doesn't change much. <BR>I so far have the ASCII output working 
    no problem but I can't get the binary <BR>working.<BR><BR>I am using 
    file.write() function to output the binary data and that seems to <BR>be 
    working no problem and when used in a legacy format application it works 
    <BR>perfectly except that the data is LittleEndian instead of BigEndian. 
    That's <BR>why I have moved to BigEndian because I don't want to have to 
    make the <BR>output routine for the data anymore complicated that 
    file.write.<BR><BR>I started using the xml format and considering my output 
    is raw binary and <BR>not base64 I changed it to be in the AppendedData 
    section instead of <BR>DataArray. It still isn't working right, I get the 
    following error when I <BR>try to load in ParaView:<BR><BR>ERROR: In 
    ..\..\..\ParaView3\VTK\IO\vtkXMLStructuredDataReader.cxx, line 
    349<BR>vtkXMLImageDataReader (0ADEC7F8): Error reading extent 0 422 0 242 0 
    1 from <BR>piece 0<BR><BR><BR>ERROR: In 
    ..\..\..\ParaView3\VTK\IO\vtkXMLDataReader.cxx, line 
    537<BR>vtkXMLImageDataReader (0ADEC7F8): Cannot read cell data array 
    "pressure" <BR>from PointData in piece 0.&nbsp; The data array in the 
    element may be too short.<BR><BR>The format of my output file is as 
    follows:<BR><BR>&lt;?xml version="1.0"?&gt;<BR>&lt;VTKFile type="ImageData" 
    version="0.1" byte_order="LittleEndian"&gt;<BR>&lt;ImageData WholeExtent="0 
    422 0 242 0 1" Origin="0 0 0" Spacing="1 1 1"&gt;<BR>&lt;Piece Extent="0 422 
    0 242 0 1"&gt;<BR>&lt;PointData&gt;<BR>&lt;/PointData&gt;<BR>&lt;CellData 
    Scalars="pressure"&gt;<BR>&lt;DataArray type="Float32" Name="pressure" 
    format="appended" 
    offset="0"/&gt;<BR>&lt;/CellData&gt;<BR>&lt;/Piece&gt;<BR>&lt;/ImageData&gt;<BR>&lt;AppendedData 
    encoding="raw"&gt;<BR>_BINARYDATA<BR>&lt;/AppendedData&gt;<BR>&lt;/VTKFile&gt;<BR><BR>Note 
    following an error message I have added an _ at the start of the binary 
    <BR>data. Is this required?<BR><BR>One final thing, when using appended 
    data, how do you calculate what the <BR>offset should 
    be?<BR><BR>Thanks<BR>David</DIV><PRE wrap=""><HR SIZE=4 width="90%">
_______________________________________________
Powered by <A class=moz-txt-link-abbreviated href="http://www.kitware.com" moz-do-not-send="true">www.kitware.com</A>

Visit other Kitware open-source projects at <A class=moz-txt-link-freetext href="http://www.kitware.com/opensource/opensource.html" moz-do-not-send="true">http://www.kitware.com/opensource/opensource.html</A>

Please keep messages on-topic and check the ParaView Wiki at: <A class=moz-txt-link-freetext href="http://paraview.org/Wiki/ParaView" moz-do-not-send="true">http://paraview.org/Wiki/ParaView</A>

Follow this link to subscribe/unsubscribe:
<A class=moz-txt-link-freetext href="http://www.paraview.org/mailman/listinfo/paraview" moz-do-not-send="true">http://www.paraview.org/mailman/listinfo/paraview</A>
  </PRE></BLOCKQUOTE><BR></BLOCKQUOTE><BR></BODY></HTML>