[Paraview] Do anyone have examples of writing binary file with mesh and results data?

Paul McIntosh paul.mcintosh at internetscooter.com
Mon Jul 30 06:42:12 EDT 2012


I am new to this part of ParaView sorry - the approach I took was to use
read the data and use VTK for writing the files - you can start with the VTK
examples and then plug in your values. There could be bugs so start small
and grow the problem size. I also found that including the rendering from
the VTK examples made things quicker as you could write/read and test in the
same code.
 
Paul

  _____  

From: krysl.petr at gmail.com [mailto:krysl.petr at gmail.com] On Behalf Of Petr
Krysl
Sent: Monday, 30 July 2012 2:49 PM
To: Paul McIntosh
Cc: paraview at paraview.org
Subject: Re: [Paraview] Do anyone have examples of writing binary file with
mesh and results data?


Paul, 

This is a good guess. I have played with this already and Paraview would
read the points okay (for big ended write), but it would crash when reading
the cell data:

.
for k=1:length(Connectivity)
        f=Connectivity{k};
        ctype=zeros(size(f, 1),1)+Cell_types{k};
        fprintf(fid,'CELLS %d %d\n',size(f,1),(size(f,1)*(size(f,2)+1)));%
        if (~binary)
            for i= 1:size(f, 1)
                fprintf(fid,'%d ',size(f,2));
                for j= 1: size(f,2)
                    fprintf(fid,'%d ',f(i,j)-1);
                end
                fprintf(fid,'\n');
            end
        else
 
fwrite(fid,cast([zeros(size(f,1),1)+size(f,2),f-1],'int32'),'int32','b');
        end
        fprintf(fid,'\n');
        fprintf(fid,'\n');
        fprintf(fid,'CELL_TYPES %d\n',size(f,1));%
        if (~binary)
            for i= 1:size(f, 1)
                fprintf(fid,'%d\n',ctype(i));
            end
        else
            fwrite(fid,cast(ctype,'int32'),'int32','b');
        end
        fprintf(fid,'\n');
        fprintf(fid,'\n');
    end
.

There is something wrong in the code above (or there's a bug in paraview).
By the way my Matlab code that writes out binary *structured_grid* data
works just fine with paraview.
It is just the unstructured grid that's giving me headaches.

Petr

On Sun, Jul 29, 2012 at 8:29 PM, Paul McIntosh
<paul.mcintosh at internetscooter.com> wrote:



Maybe check the endianess - to read a binary file that was generated in
MATLAB I had to change the endianess. I think there is a VTK util on the
MATHWORKS site but I haven't tried that.
 
Paul

  _____  

From: paraview-bounces at paraview.org [mailto:paraview-bounces at paraview.org]
On Behalf Of Petr Krysl
Sent: Saturday, 28 July 2012 1:37 AM
To: paraview at paraview.org
Subject: Re: [Paraview] Do anyone have examples of writing binary file with
mesh and results data?


Hi, 

Did you ever get the Matlab writing of the binary VTK files to work?  I'm
having problems with them too: PV crashes when reading the binary files.


Thanks,
-- 
Petr Krysl 
University of California, San Diego
Skype: Petr.Krysl.UCSD.EDU
http://hogwarts.ucsd.edu/~pkrysl/





-- 
Petr Krysl 
University of California, San Diego
Skype: Petr.Krysl.UCSD.EDU
http://hogwarts.ucsd.edu/~pkrysl/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20120730/3d54b170/attachment.htm>


More information about the ParaView mailing list