WorkAreaManager.cpp 1004 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include <iostream>
  2. #include <fstream>
  3. #include <sstream>
  4. #include <vector>
  5. #include "WorkAreaManager.h"
  6. #include "rapidcsv.h"
  7. CWorkAreaManager& CWorkAreaManager::GetInstance()
  8. {
  9. static CWorkAreaManager m;
  10. return m;
  11. }
  12. void CWorkAreaManager::LoadCSV(const char* file)
  13. {
  14. rapidcsv::Document doc("data.csv");
  15. int32_t count= doc.GetRowCount();
  16. std::vector < std::string > name= doc.GetColumn<std::string>(0);
  17. std::vector<float> x = doc.GetColumn<float>(1);
  18. std::vector<float> y = doc.GetColumn<float>(2);
  19. for (int32_t i = 0; i < count; i++)
  20. {
  21. std::cout << name[i] << "," << x[i] << "," << y[i] << std::endl;
  22. const char* str = name[i].c_str() + 1;
  23. int32_t index = std::stod(str)-1;
  24. _area[name[i].c_str()[0] - 'A'][index].x = x[i];
  25. _area[name[i].c_str()[0] - 'A'][index].y = y[i];
  26. }
  27. for (size_t i = 0; i < count; i++)
  28. {
  29. std::cout << _area[i]->x << "," << _area[i]->y << std::endl;
  30. }
  31. }
  32. Point& CWorkAreaManager::GetPoint(WorkArea area, int32_t no)
  33. {
  34. return _area[area][no];
  35. }