123456789101112131415161718192021222324252627282930313233343536373839 |
- #include <iostream>
- #include <fstream>
- #include <sstream>
- #include <vector>
- #include "WorkAreaManager.h"
- #include "rapidcsv.h"
- CWorkAreaManager& CWorkAreaManager::GetInstance()
- {
- static CWorkAreaManager m;
- return m;
- }
- void CWorkAreaManager::LoadCSV(const char* file)
- {
- rapidcsv::Document doc("data.csv");
- int32_t count= doc.GetRowCount();
-
- std::vector < std::string > name= doc.GetColumn<std::string>(0);
- std::vector<float> x = doc.GetColumn<float>(1);
- std::vector<float> y = doc.GetColumn<float>(2);
-
- for (int32_t i = 0; i < count; i++)
- {
- std::cout << name[i] << "," << x[i] << "," << y[i] << std::endl;
- const char* str = name[i].c_str() + 1;
- int32_t index = std::stod(str)-1;
- _area[name[i].c_str()[0] - 'A'][index].x = x[i];
- _area[name[i].c_str()[0] - 'A'][index].y = y[i];
- }
- for (size_t i = 0; i < count; i++)
- {
- std::cout << _area[i]->x << "," << _area[i]->y << std::endl;
- }
-
- }
- Point& CWorkAreaManager::GetPoint(WorkArea area, int32_t no)
- {
- return _area[area][no];
- }
|