-
Notifications
You must be signed in to change notification settings - Fork 0
/
reader.h
105 lines (99 loc) · 2.24 KB
/
reader.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#pragma once
#include "structures.h"
#include <iostream>
#include <fstream>
#include <string>
#include <cctype>
void reader (struct elements_of_orbit& _orb, struct satellite& _sat) {
std::string buffer;
std::string line;
std::ifstream file("initial_data.txt");
if (file.is_open()) {
while (!file.eof()) { // 0 - is not the end of file, 1 - is it.
file >> buffer;
line += buffer + " ";
if (line == "Parameters of orbit: " || line == "Parameters of satellite: ") {
line.clear();
}
else if (line == "inclination ") {
double tmp = 0;
file >> tmp;
_orb.inclination = tmp;
line.clear();
}
else if (line == "orbit eccentricity ") {
double tmp = 0;
file >> tmp;
_orb.orb_eccentricity = tmp;
line.clear();
}
else if (line == "apoapsis ") {
double tmp = 0;
file >> tmp;
_orb.apoapsis = tmp;
line.clear();
}
else if (line == "periapsis ") {
double tmp = 0;
file >> tmp;
_orb.periapsis = tmp;
line.clear();
}
else if (line == "argument of periapsis ") {
double tmp = 0;
file >> tmp;
_orb.periapsis_argument = tmp;
line.clear();
}
else if (line == "true anomaly ") {
double tmp = 0;
file >> tmp;
_orb.true_anomaly = tmp;
line.clear();
}
else if (line == "ascending long ") {
double tmp = 0;
file >> tmp;
_orb.ascending_long = tmp;
line.clear();
}
else if (line == "orbital major axis ") {
double tmp = 0;
file >> tmp;
_orb.orb_major_ax = tmp;
line.clear();
}
else if (line == "orbital minor axis ") {
double tmp = 0;
file >> tmp;
_orb.orb_minor_ax = tmp;
line.clear();
}
else if (line == "mass ") {
double tmp = 0;
file >> tmp;
_sat.mass = tmp;
line.clear();
}
else if (line == "area ") {
double tmp = 0;
file >> tmp;
_sat.S = tmp;
line.clear();
}
else if (line == "size ") {
double tmp = 0;
file >> tmp;
_sat.d = tmp;
line.clear();
}
else if (line == "Cx ") {
double tmp = 0;
file >> tmp;
_sat.Cx = tmp;
line.clear();
}
}
}
else std::cerr << "File of initial data is not opened" << std::endl;
}