I have to extract vertices frm a file written as follows:
{(1.20, 3.0, -3.0); (1.10, -2.0, 4.0); (-5.0, 8.0, 7.0) …(-4.0, 7.0,-3.0)}
I need to store the values in vertex like this:
double v[3];
v[0] = 1.20;
v[1] = 3.0;
v[2] = -3.0;
Newlines may be encountered while reading;
How to separate bracket “{”, “(”, and comma’,’ and semicolon’;’
And store the numbers;
Not an OpenGL problem - try a c++ forum.
[QUOTE=Lee_Jennifer_82;1247673]I have to extract vertices frm a file written as follows:
{(1.20, 3.0, -3.0); (1.10, -2.0, 4.0); (-5.0, 8.0, 7.0) …(-4.0, 7.0,-3.0)}
[/QUOTE]
Years ago I would have written some C code to parse this file.
I’d suggest bringing the file into a text editor and simplifying it.
Do a global replace of all ‘{’, ‘(’, ‘)’, and ‘}’ with spaces.
Then replace all ‘;’ with ‘returns’. It will probably still need a
little tweaking after doing the above replaces. But you’d have
gone a long way towards your goal. Do you use Excel? It’s a
nice utility for reformatting data files. I use it a lot.