Code: Select all
wxString data = "1 2 3 4 5 6 7 8";
Thanks in advance for any help
Code: Select all
wxString data = "1 2 3 4 5 6 7 8";
Yes there is, but not sure if it will help you.....chocobo_ff wrote:Hi, this may sound like a stupid question, but is there a function for converting wxString to double,
.......
Hi yes I know that function already... thanks for the help anyway actually I just found there's a function called AfterFirst that finds the first whitespace (' ') and take a sub string from there, so problem now solvedsethjackson wrote:Yes there is, but not sure if it will help you.....
Cool.chocobo_ff wrote:Hi yes I know that function already... thanks for the help anyway actually I just found there's a function called AfterFirst that finds the first whitespace (' ') and take a sub string from there, so problem now solvedsethjackson wrote:Yes there is, but not sure if it will help you.....
Code: Select all
VARIABLES = "X","Y","Z" // < ------- well this I think understandable first column "x" second "y" third "z" this it is need to skip VARIABLES = "X","Y","Z"ZONE T="1",F=FEPOINT
ZONE T="1",F=FEPOINT,N= 2.00000 ,E= 2.00000 ,ET=BRICK // <---- N= 2.00000 this is how much lines "0.0000000D+00" like this numbers.
0.0000000D+00 0.0000000D+00 0.0000000D+00
0.1000000D+00 0.0000000D+00 0.0000000D+00
1 2 11 10 28 29 38 37 2 1 // < --------------E= 2.00000 this how much such lines
2 3 12 11 29 30 39 38 2 1
Code: Select all
#include <fstream>
#include <string>
#include <iostream>
#include <strstream>
using namespace std;
inline double parseDouble(ifstream &str)
{
string token;
strstream convertor;
double value;
str >> token;
convertor << token.replace(token.find('D'), 1, "E");
convertor >> value;
return value;
}
int main()
{
ifstream src("MESHGL.dat");
string token, line;
int numPoints = -1, numElements = -1;
int pos;
do {
src >> token;
if (token.find("N=") != string::npos) src >> numPoints;
if (token.find("E=") != string::npos) src >> numElements;
} while (!src.eof() && (numPoints == -1 || numElements == -1));
if (!src.eof())
cout << numPoints << ", " << numElements << '\n';
else
cout << "Invalid source file format!\n";
// skip end of line with "E="
getline(src, line);
double point[3];
int elements[10];
// start to read N-type lines
while (numPoints--)
{
point[0] = parseDouble(src);
point[1] = parseDouble(src);
point[2] = parseDouble(src);
cout << point[0] << "," << point[1] << "," << point[2] << "\n";
// skip end of line (just in case of comments)
getline(src, line);
}
// start to read E-type lines
while (numElements--)
{
cout << "E=";
for (int itemIndex=0; itemIndex<10; itemIndex ++)
{
src >> elements[itemIndex];
cout << elements[itemIndex] << " ";
}
cout << "\n";
// skip end of line (just in case of comments)
getline(src, line);
}
system("PAUSE");
return 0;
}
Code: Select all
7.3,0.6,10
7.4,0.6,10
E=1 2 11 10 28 29 38 37 2 1
E=2 3 12 11 29 30 39 38 2 1