PDA

View Full Version : reading vertices from a file



Lee_Jennifer_82
01-29-2013, 05:11 PM
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;

tonyo_au
01-29-2013, 05:29 PM
Not an OpenGL problem - try a c++ forum.

Carmine
01-30-2013, 10:58 AM
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)}


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.