I work with a VTK data type for my outputs. Since my data is becoming larger and larger, it's taking considerable time to write it in ASCII and that's what I have been doing so far.
I need to change that into binary format but the problem is the file has some headers (see http://www.vtk.org/VTK/img/file-formats.pdf) that need to be written in ASCII even for binary files.
Now I don't have enough experience with binary formats and my first try was to open two streams via
ofstream asciiWriter(file_name.c_str());
ofstream binWriter(file_name.c_str(), ios::app | ios::binary);
problem is the output seems to be disorganized and asciiWriter
and binWriter
are not outputting in the correct order and so I cannot post-process my file in ParaView. One thing I tried was to use asciiWriter.flush()
and binWriter.flush()
whenever I'm done with header/data writing but that does not help either.
What should I do?
PS: I do not want to use the VTK package itself ... its HUGE and adds to my code dependency!