Используя карту для хранения данных, которые уже были прочитаны? - PullRequest
0 голосов
/ 07 декабря 2018

Привет всем и спасибо, что нашли время, чтобы прочитать это.Поэтому в основном я пытаюсь взять данные, которые я прочитал, через текстовый файл и сохранить их в: std::map<double,pair<double,double>>storage Где первый дубль представляет идентификатор координаты, а пара представляет значения x и y, которые можно игнорироватьзначение z.

ID XYZ / n ID XYZ

Вершина класса

class vertex
   {
   public:

        map<double,pair<double,double>> keyTable;
        int count = 0; // just temporary to count the number of lines
        ifstream filestuff; //used later to initialize the reference

        double vert_id; //The ID of the Vertex will be stored here
        int num_vert,num_attrib,num_dimen; //First line of the .tri file
        //Declare class as a friend to take the ifstreamed file from main
        friend ifstream& operator >> (ifstream& input, vertex &vert){
            input>>vert.num_vert>>vert.num_dimen>>vert.num_attrib;
            return input;
        }
    vertex();
    virtual ~vertex();
    protected:
    private:
    double x,y,z; // Coordinate points
 };

В конструкторе

 vertex::vertex(){

    ifstream& input = filestuff; // text file passed as a reference

    while (getline(filestuff, line)) {
        count++

        while (count<num_vert) // for loop to stop at a
        {
        //add to the map and pray to god its okay
        keyTable.insert(?);
         // MAP STORED AS KEY = ID and pair of points is X and Y
        }      


      }

    return;
        //ctor
 }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...