[Gmsh] binary msh files and a programming question
Umut Tabak
u.tabak at tudelft.nl
Tue Dec 9 16:16:08 CET 2008
Dear developers(or people interested)
I wrote a C++ class to partition the binary msh file output of Gmsh for
my own FE based Ph.D. research.
It is still in the development phase I have to conduct some tests(until
now it seems to work) and I can send it to developers(if they are
interested) to include in the source code or someone else interested but
the point is that I used a rather strange condition to detect the ending
of the elements block. So my question is that
1.) after writing the binary mesh data, is a newline character('\n')
used, I can see this on the output from gbd or ddd. Since I do not know
the details of the code developed, I think I am right on this.
2.) Secondly I am using the below code to detect the end of elements
block in binary format but I could not understand \177 in the gmsh
output, the code below works and partitions the mesh into all the
elements in different binary data files(did not paste all, just the
related section)
.
.
. // at this point all the files are written correctly
memblockElements = NULL ; // defined before char*
memblockElements = new char[13]; // 13 if found by trial
file.read(memblockElements, 13);
string checkStr(memblockElements);
// reposition the
// file pointer for the next iteration loop 13 bytes back !!
file.seekg(-13,ios::cur);
if(strcmp (checkStr.c_str(),"\n$EndElements\177") == 0)
elemsFlag = false; // a boolean to check the end
}
while(elemsFlag);
Maybe I should review my string and char array knowledge in C.
If you could help me on this I would appreciate your help.
Thanks and best regards,
Umut