Dear all,

I wrote two simple Matlab scripts to output data in a XML format (this is VTS - for structured grids). In the attached scripts the structured mesh is 2x2, the values to be visualized are all ones. The only difference is that one script outputs the data in ASCII format, another - in binary one. Using ParaView for visualization of the ASCII file is nice, while with binary data I get the following error:

ERROR: In /home/kitware/Dashboards/MyTests/NightlyMaster/ParaViewSuperbuild-Release/paraview/src/paraview/VTK/IO/XMLParser/vtkXMLParser.cxx, line 483 vtkXMLDataParser (0x54bcd40): Error parsing XML in stream at line 7, column 0, byte index 277: not well-formed (invalid token)

ERROR: In /home/kitware/Dashboards/MyTests/NightlyMaster/ParaViewSuperbuild-Release/paraview/src/paraview/VTK/IO/XML/vtkXMLReader.cxx, line 444 vtkXMLStructuredGridReader (0x54c2e60): Error parsing input file. ReadXMLInformation aborting.

ERROR: In /home/kitware/Dashboards/MyTests/NightlyMaster/ParaViewSuperbuild-Release/paraview/src/paraview/VTK/Common/ExecutionModel/vtkExecutive.cxx, line 783 vtkPVCompositeDataPipeline (0x54c82d0): Algorithm vtkXMLStructuredGridReader(0x54c2e60) returned failure for request: vtkInformation (0x54daea0)
  Debug: Off
  Modified Time: 154273
  Reference Count: 1
  Registered Events: (none)
  Request: REQUEST_INFORMATION
  FORWARD_DIRECTION: 0
  ALGORITHM_AFTER_FORWARD: 1


I can't figure out where the problem is. Searching in the Internet also didn't give me a clue. What am I doing wrong?

I use ParaView 4.2.0 64-bit on Linux Mint.

Thank you,
Mikhail

n = 2;
a = ones(n, n);
[x, y] = meshgrid(0 : 1/n : 1);

fname = 'test.vts';   
fid = fopen(fname, 'w');

fprintf(fid, '<?xml version="1.0"?>\n');
fprintf(fid, '<VTKFile type="StructuredGrid" version="0.1" byte_order="LittleEndian">\n');
fprintf(fid, '  <StructuredGrid WholeExtent="1 %d 1 %d 1 1">\n', n+1, n+1);
fprintf(fid, '    <Piece Extent="1 %d 1 %d 1 1">\n', n+1, n+1);
fprintf(fid, '      <CellData Scalars="scalars">\n');
fprintf(fid, '        <DataArray type="Float64" Name="coefficient" format="ascii">\n');

for i = 1 : n
    for j = 1 : n
        fprintf(fid, '%e\n', a(i, j));
    end
end

fprintf(fid, '        </DataArray>\n');
fprintf(fid, '      </CellData>\n');
fprintf(fid, '      <Points>\n');
fprintf(fid, '        <DataArray type="Float64" NumberOfComponents="3" format="ascii">\n');

for i = 1 : n+1
    for j = 1 : n+1
        fprintf(fid, '%f %f 0.0\n', x(i, j), y(i, j));
    end
end

fprintf(fid, '        </DataArray>\n');
fprintf(fid, '      </Points>\n');
fprintf(fid, '    </Piece>\n');
fprintf(fid, '  </StructuredGrid>\n');
fprintf(fid, '</VTKFile>\n');

fclose(fid);
n = 2;
a = ones(n, n);
[x, y] = meshgrid(0 : 1/n : 1);

fname = 'test_bin.vts';   
fid = fopen(fname, 'w');

fprintf(fid, '<?xml version="1.0"?>\n');
fprintf(fid, '<VTKFile type="StructuredGrid" version="0.1" byte_order="LittleEndian">\n');
fprintf(fid, '  <StructuredGrid WholeExtent="1 %d 1 %d 1 1">\n', n+1, n+1);
fprintf(fid, '    <Piece Extent="1 %d 1 %d 1 1">\n', n+1, n+1);
fprintf(fid, '      <CellData Scalars="scalars">\n');
fprintf(fid, '        <DataArray type="Float64" Name="coefficient" format="binary">\n');

fwrite(fid, a, 'double');

fprintf(fid, '        </DataArray>\n');
fprintf(fid, '      </CellData>\n');
fprintf(fid, '      <Points>\n');
fprintf(fid, '        <DataArray type="Float64" NumberOfComponents="3" format="binary">\n');

fwrite(fid, x, 'double');
fwrite(fid, y, 'double');
fwrite(fid, 0*x, 'double'); % z = 0

fprintf(fid, '        </DataArray>\n');
fprintf(fid, '      </Points>\n');
fprintf(fid, '    </Piece>\n');
fprintf(fid, '  </StructuredGrid>\n');
fprintf(fid, '</VTKFile>\n');

fclose(fid);
_______________________________________________
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

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to