-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.cpp
More file actions
30 lines (26 loc) · 795 Bytes
/
parser.cpp
File metadata and controls
30 lines (26 loc) · 795 Bytes
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
#include "parser.hpp"
std::vector<PointData> parseFile(const std::string& filename) {
std::ifstream in(filename);
if (in) {
std::vector<PointData> vertices;
std::string line;
PointData vertex;
while (in.good()) {
in >> vertex.potential;
in >> vertex.position[0];
in >> vertex.position[1];
vertices.push_back(vertex);
}
return vertices;
}
throw errno;
}
float getBound(const std::vector<PointData> &vertices) {
/* Find the maximum absolute Potential */
float min = 0, max = 0;
for (const auto& vertex : vertices) {
min = std::min(min, vertex.potential);
max = std::max(max, vertex.potential);
}
return std::max(std::abs(min), std::abs(max));
}