I'm engineer switching from ancient Fortran to C++. My OOP skills are dim at best and would appreciate your help on storing the data structure I'm going to explain below.
I need to read a file that includes some engineering results data (namely ANSYS FE stress data for those familiar). To extract only the data I need, I have to read an input file first. Anyway, the input file includes the following data structure (just a simple analogy);
Name of triangle; --> Integer --> 1
Type of triangle; --> String --> 1
Min height and max height --> Float --> 2
Possible Colors --> String --> unknown number
The input file has an unknown number of triangles and each triangle has different unknown possible colors. In addition, each one has a type and min/max height.
I thought about creating an triangle object type, but the number of triangles are known at run-time. I don't know how to create a finite number of triangle objects with different names at runtime (as far as I know it's only possible in run-time compiled languages, Java).
Please, let me know how to read and store this type of data in the most efficient way. My only option at hand is now below and doesn't seem an efficient way to do it;
Read number of triangles first;
Loop for all triangles and read the data, store number of possible colors in a vector variable;
Open the engineering results data file;
Loop for every triangle and search for possible colors;
Create one, load it up with data, put it in the vector, repeat until all data is stored:
1 2 3 4 5 6 7 8 9 10
while ( thereIsStillDataLeftToRead)
// Now have a vector of triangles, containing all the triangle data read in