<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
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<const char*>(N), 4);<br>
<br>
Thorsten<br>
<br>
David Mulholland schrieb:
<blockquote cite="mid:18639349767042A49C3C19BBF7440A56@dm105"
type="cite">
<title></title>
<meta content="text/html;charset=iso-8859-1" http-equiv="Content-Type">
<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-family: Tahoma; font-style: normal; font-variant: normal; font-weight: normal; font-size: 10pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">
<div><br>
</div>
<div
style="background: rgb(245, 245, 245) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;">
<div style=""><b>From:</b> <a moz-do-not-send="true"
title="th@tp1.rub.de" href="mailto:th@tp1.rub.de">Thorsten Hater</a> </div>
<div><b>Sent:</b> Tuesday, March 31, 2009 2:23 PM</div>
<div><b>To:</b> <a moz-do-not-send="true"
title="d.t.mulholland@googlemail.com"
href="mailto:d.t.mulholland@googlemail.com">David Mulholland</a> </div>
<div><b>Cc:</b> <a moz-do-not-send="true"
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,<br>
<br>
the solution might be to append your data as<br>
<br>
< DataArray ... format="appended"><br>
</DataArray><br>
< AppendedData encoding="raw"><br>
_NNNNData <br>
</AppendedData><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>
Thorsten<br>
<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. The data array in the element may be too
short.<br>
<br>
The format of my output file is as follows:<br>
<br>
<?xml version="1.0"?><br>
<VTKFile type="ImageData" version="0.1" byte_order="LittleEndian"><br>
<ImageData WholeExtent="0 422 0 242 0 1" Origin="0 0 0" Spacing="1 1
1"><br>
<Piece Extent="0 422 0 242 0 1"><br>
<PointData><br>
</PointData><br>
<CellData Scalars="pressure"><br>
<DataArray type="Float32" Name="pressure" format="appended"
offset="0"/><br>
</CellData><br>
</Piece><br>
</ImageData><br>
<AppendedData encoding="raw"><br>
_BINARYDATA<br>
</AppendedData><br>
</VTKFile><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 moz-do-not-send="true" class="moz-txt-link-abbreviated"
href="http://www.kitware.com">www.kitware.com</a>
Visit other Kitware open-source projects at <a moz-do-not-send="true"
class="moz-txt-link-freetext"
href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a>
Please keep messages on-topic and check the ParaView Wiki at: <a
moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://paraview.org/Wiki/ParaView">http://paraview.org/Wiki/ParaView</a>
Follow this link to subscribe/unsubscribe:
<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://www.paraview.org/mailman/listinfo/paraview">http://www.paraview.org/mailman/listinfo/paraview</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>