[Gmsh] Binary files

Christophe Geuzaine cag32 at case.edu
Wed Mar 15 22:52:30 CET 2006


Jeremiah Hall wrote:
> Dear Mr. Geuzaine and Mr. Remacle,
> 
> I am using gmsh as a postprocessor for fluids problems, and I find it to be
> extremely useful.  I need to modify the data within each .pos file (1 view per
> file), and have been using the ASCII format thus far by first converting from
> binary to ASCII, then performing my operations.  However, to save time and
> space I would like to use the binary file.  I read about the file format in the
> manual, and looked directly at some of the files, and noticed that the binary
> format contains a mixture of ASCII and binary characters.  My question is: what
> is the best way to manipulate these files using C++?  I am relatively new to the
> language, and I know how to open file streams for either ASCII or binary, but
> not both.  

Open them in binary mode--even if on most operating systems it doesn't 
make any difference.

The format is described in the reference manual. Look at ReadView() in
Common/ViewIO.cpp for sample code. (You can probably simplify the 
routine quite a bit: this particular one also supports old versions of 
the format for backward compatibility.)

> Also, why is the header information in ASCII format?  Is there some
> benefit that I am unaware of?

It makes it easier for a human to see what's in the file?


> 
> Thanks in advance for your help.
> 
> Jermeiah Hall
> _______________________________________________
> gmsh mailing list
> gmsh at geuz.org
> http://www.geuz.org/mailman/listinfo/gmsh
> 


-- 
Christophe Geuzaine
Assistant Professor, Case Western Reserve University, Mathematics
http://www.case.edu/artsci/math/geuzaine