-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreadinput.cpp
56 lines (44 loc) · 1008 Bytes
/
readinput.cpp
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
47
48
49
50
51
52
53
54
#include <iostream>
#include <math.h>
#include <time.h>
#include <fstream>
#include <stdlib.h>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
#include <sstream>
#include "header.h"
using namespace std;
void readinput(vector<obstacle> &obs, string input)
{
int i;
std::ifstream inputFile(input.c_str());
if (inputFile.is_open())
{
i=0;
while(inputFile.good())
{
i++;
string line;
getline(inputFile,line);
std::stringstream stream(line);
// Get the obstacle coordinates from the line:
double x;
double y;
stream >> x;
stream >> y;
// std::cout << "Coordinate: x=" << x << " y=" << y << endl;
obstacle dummy;
dummy.x=x;
dummy.y=y;
obs.push_back(dummy);
}
inputFile.close();
// for(int j=1;j<i;j++)
// {
// std::cout << j << "x=" << obsX[j] << " y=" << obsY[j] << endl;
// }
}
else std::cout << "Unable to open the input file " << input.c_str() << endl;
}