I am trying to figure out a way to read in coordinates from a text file. I know the basic file i/o, that isn't the problem. The problem is the fact that i have an insane number of coordinates to read from the file and I am looking for a good way to do it. There are about 872 lines, each line holds the X, Y, Z coordinates for a triangle so that means 9 floating point numbers. This will take up a lot of memory and I need the most efficient way to do it. Should I create a huge array of (872 * 9) floating point integers?
such as float* Verticies and then read in the coordinates with a for loop? should I try using a vector somehow?
Okay I have devised my first algorithm for this problem, I just need help implementing it
1) Make sure fstream is included in the project
2) Open the file for input
3) Declare an object of ifstream
4) while not at the end of the file read each line until 6 parenthesis have been encountered, when the 6th has been encountered skip to the next line and continue reading from there
This is what a line of the text file looks like:
( 192 -1024 59 ) ( 192 -1024 -763 ) ( 192 -256 -763 ) 64CRATE0 [ 0 1 0 0 ] [ 0 0 -1 0 ] 0 1 1
after the numbers there is some extra 'code' or whatever generated by the program that produces this text file. I need it to skip over that crap so it doesn't mess up my program.
I need all the suggestions I can possibly get.