Struggling passing the face values of a .obj file to a vector.
f 5/1/1 1/2/1 4/3/1
f 5/1/1 4/3/1 8/4/1
f 3/5/2 7/6/2 8/7/2
That is what i need to store, but
f 5//1 1//1 4//1
f 5//1 4//1 8//1
f 3//2 7//2 8//2
It can sometimes be like that and i don't know how to get round the problem thanks.
Here's an example that uses
boost::tokenizerI usestdinto read input (all the values after the 'f'), and then I simply output the values to the terminal. I'm sure you can modify this to read from a file and place the values where you need them.Example 1
Sample output:
Example 2
Take note of the line
boost::char_separator<char> sep(" /");This is the specifier for all the tokens that will be counted as valid separators. It may be more convenient in your case to change this toboost::char_separator<char> sep("/");(no whitespace), and then simply read strings like so:Sample output:
In this second example I use a string stream to read individual strings from the entire input, and use a rudimentary check to see if the first character is 'f'. This example should also be adaptable for your needs.