-
Notifications
You must be signed in to change notification settings - Fork 0
/
getini.cpp
65 lines (56 loc) · 1.5 KB
/
getini.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
55
56
57
58
59
60
61
62
63
64
65
#include "getini.h"
GetIni::GetIni(const char* name){
filename = name;
ifstream in;
in.open(filename);
in>>root;
numbodies = root["numbodies"].asInt();
}
int GetIni::nOfBodies(){
return root["numbodies"].asInt();
}
int GetIni::getIteration(){
return root["iterations"].asInt();
}
double GetIni::getIterStepSize(){
return root["stepsize"].asDouble();
}
bool GetIni::getCMFlag(){
return root["cmflag"].asBool();
}
void GetIni::getPositions(Col<double> * &R){
R = new Col<double>[numbodies];
Value sub;
for(int i = 0; i < numbodies; i++){
sub = root["bodies"][i]["initialposition"];
R[i] << sub[0].asDouble()<<sub[1].asDouble()<<sub[2].asDouble();
}
}
void GetIni::getVelocities(Col<double> * &v){
v = new Col<double>[numbodies];
Value sub;
for(int i = 0; i < numbodies; i++){
sub = root["bodies"][i]["initialvelocity"];
v[i] << sub[0].asDouble()<<sub[1].asDouble()<<sub[2].asDouble();
}
}
string GetIni::getVideoFileName(){
return root["videofilename"].asString();
}
int GetIni::getVideoDuration(){
return root["videoduration"].asInt();
}
void GetIni::getXprojection(Col<double> &x){
Value sub = root["xprojection"];
x << sub[0].asDouble()<<sub[1].asDouble()<<sub[2].asDouble();
}
void GetIni::getYprojection(Col<double> &y){
Value sub = root["yprojection"];
y << sub[0].asDouble()<< sub[1].asDouble()<< sub[2].asDouble();
}
void GetIni::getMass(double * &mass){
mass = new double[numbodies];
for(int i = 0; i < numbodies; i++){
mass[i] = root["bodies"][i]["mass"].asDouble();
}
}