<html>
Dear vtk-ers,<br><br>
I wrote a program using vtk, which visualizes trajectories of particles
moved by a liquid during the filling of a mould. This program uses
ascii-data and works fine.<br>
Since the data sets are in the order of several megabytes, I would like
to transfer the ascii data to binary data, and this is where the problem
starts.<br><br>
To investigate the problem I wrote the test program below, using VC++
6.0, to create a rectilinear grid with some data. If I view the
vtkfile "pipo.vtk" using mayavi, data is shown, but all the
data is smaller than 8.04e-041. So it is likely that the binary float
data is read in a different way than it was written. <br><br>
Can somebody inform me how to write binary data from VC++ 6.0, in such a
way that it is read correctly by vtk ?<br><br>
Thank you in advance,<br><br>
ROB.<br><br>
//--------------------------------------------------------------------------------------<br>
<font face="Arial Rounded MT Bold, Helvetica">void main()<br>
{<br>
FILE *out ;<br>
float list[8];<br>
int coord[2];<br>
<x-tab> </x-tab><br>
out = fopen("pipo.vtk",
"w");<br><br>
fprintf(out,"# vtk DataFile Version
2.0\n");<br>
fprintf(out,"#My data in binary
format\n");<br>
fprintf(out,"BINARY\n ");<br>
fprintf(out,"DATASET
RECTILINEAR_GRID\n");<br>
fprintf(out,"DIMENSIONS 2 2 2\n");<br><br>
<x-tab> </x-tab>coord[0]=0;coord[1]=1;<br>
<x-tab> </x-tab>fprintf(out,"\nX_COORDINATES
2 int\n");<br>
<x-tab> </x-tab>fwrite(
coord, sizeof( int ), 2, out );<br>
<x-tab> </x-tab>fprintf(out,"\nY_COORDINATES
2 int\n");<br>
<x-tab> </x-tab>fwrite(
coord, sizeof( int ), 2, out );<br>
<x-tab> </x-tab>fprintf(out,"\nZ_COORDINATES
2 int\n");<br>
<x-tab> </x-tab>fwrite(
coord, sizeof( int ), 2, out );<br><br>
fprintf(out,"\nPOINT_DATA 8\n");<br>
fprintf(out,"SCALARS colors float\n");<br>
fprintf(out,"LOOKUP_TABLE
default\n");<br><br>
<x-tab> </x-tab>list[0]=0.0;list[1]=1.0;list[2]=2.0;list[3]=3.0;<br>
<x-tab> </x-tab>list[4]=4.0;list[5]=5.0;list[6]=6.0;list[7]=7.0;<br>
<x-tab> </x-tab>fwrite(
list, sizeof( float ), 8, out );<br>
}<br>
</font>//--------------------------------------------------------------------------------------<br><br>
<x-sigsep><p></x-sigsep>
<font color="#0000FF">dr. R. van Tol<br>
WTCM Gieterijcentrum<br>
Technologiepark 9<br>
B-9052 Zwijnaarde<br>
tel.:0032 (0)9 2645704<br>
fax:0032 (0)9 2645848<br>
</font><font color="#000080"><a href="mailto:rob.vantol@wtcm.be" eudora="autourl">mailto:</a></font><a href="mailto:rob.vantol@wtcm.be" eudora="autourl"><font color="#0000FF">rob.vantol@wtcm.be</a></font></html>