Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: reading vertices from a file

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2012
    Posts
    18

    reading vertices from a file

    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;

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    Not an OpenGL problem - try a c++ forum.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    174
    Quote Originally Posted by Lee_Jennifer_82 View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •