-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathReadFromFile.h
46 lines (37 loc) · 925 Bytes
/
ReadFromFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#pragma once
#include <vector>
#include "Point_2D.h"
std::vector<Point_2D*> readPointsFromFile(int numOfPoints, std::string fileName) {
PROFILE_FUNCTION();
std::vector<Point_2D*> outVec;
std::ifstream inData(fileName);
char delim;
double x, y;
for (int i = 0; i < numOfPoints; ++i) {
inData >> delim
>> x
>> delim
>> y
>> delim >> delim;
//std::cout << x << "," << y << std::endl;
outVec.push_back(new Point_2D(x, y));
}
return outVec;
}
Point_2D* readPointsFromFileArray(int numOfPoints, std::string fileName) {
PROFILE_FUNCTION();
Point_2D* outVec = new Point_2D[numOfPoints];
std::ifstream inData(fileName);
char delim;
double x, y;
for (int i = 0; i < numOfPoints; ++i) {
inData >> delim
>> x
>> delim
>> y
>> delim >> delim;
//std::cout << x << "," << y << std::endl;
outVec[i] = Point_2D(x, y);
}
return outVec;
}