1 | |
---|
2 | #include "sectorParameters.h" |
---|
3 | #include "mixedTools.h" |
---|
4 | |
---|
5 | #define BAVARD 1 |
---|
6 | |
---|
7 | sectorParameters::sectorParameters(sector* sect): |
---|
8 | sector_(sect) |
---|
9 | { |
---|
10 | geometry_= string("CIRCULAR"); |
---|
11 | sectorsStatements_.push_back(statements("vide",vector<string>())); |
---|
12 | sectorsStatements_.back().second.push_back("xxx"); |
---|
13 | sectorsStatements_.back().second.push_back("xxx"); |
---|
14 | sectorsStatements_.back().second.push_back("Unchecked"); |
---|
15 | sectorsStatements_.back().second.push_back("1"); |
---|
16 | } |
---|
17 | |
---|
18 | // sectorParameters::sectorParameters() : parametersString_(NULL) |
---|
19 | // { |
---|
20 | // geometry_= string("CIRCULAR"); |
---|
21 | // nCells_ = 0; |
---|
22 | // lCell_ = 0.0; |
---|
23 | // pc_ = 0.0; |
---|
24 | // nbParam_ = 4; |
---|
25 | // parametersString_ = new string[nbParam_+1]; |
---|
26 | // } |
---|
27 | |
---|
28 | // string* sectorParameters::getParametersString() const |
---|
29 | // { |
---|
30 | // parametersString_[0] = mixedTools::intToString(nbParam_); |
---|
31 | // parametersString_[1] = geometry_; |
---|
32 | // parametersString_[2] = mixedTools::intToString(nCells_); |
---|
33 | // parametersString_[3] = mixedTools::doubleToString(lCell_); |
---|
34 | // parametersString_[4] = mixedTools::doubleToString(pc_); |
---|
35 | // return parametersString_; |
---|
36 | // } |
---|
37 | |
---|
38 | // void sectorParameters::setParametersString(string* param) |
---|
39 | // { |
---|
40 | // geometry_ = param[1].c_str(); |
---|
41 | // nCells_ = atoi(param[2].c_str()); |
---|
42 | // lCell_ = atof(param[3].c_str()); |
---|
43 | // pc_ = atof(param[4].c_str()); |
---|
44 | // } |
---|
45 | |
---|
46 | void sectorParameters::raz() |
---|
47 | { |
---|
48 | if(!sectorsStatements_.empty()) sectorsStatements_.clear(); |
---|
49 | } |
---|
50 | |
---|
51 | string sectorParameters::FileOutputFlow() const |
---|
52 | { |
---|
53 | ostringstream sortie; |
---|
54 | sortie << " sectors " << endl; |
---|
55 | sortie << sectorsStatements_.size() << endl; |
---|
56 | for(int i = 0; i < sectorsStatements_.size(); i++) { |
---|
57 | sortie << sectorsStatements_.at(i).first << " " << sectorsStatements_.at(i).second.at(0) << " " << sectorsStatements_.at(i).second.at(1) << " " << sectorsStatements_.at(i).second.at(2) << " " << sectorsStatements_.at(i).second.at(3) << endl; |
---|
58 | } |
---|
59 | return sortie.str(); |
---|
60 | } |
---|
61 | |
---|
62 | void sectorParameters::FileInput(ifstream& ifs) |
---|
63 | { |
---|
64 | int n; |
---|
65 | ifs >> n; |
---|
66 | string txt = ""; |
---|
67 | for(int i = 0; i < n; i++) { |
---|
68 | ifs >> txt; |
---|
69 | sectorsStatements_.push_back(statements(txt,vector<string>())); |
---|
70 | for(int j = 0; j < 4; j++) { |
---|
71 | ifs >> txt; |
---|
72 | sectorsStatements_.back().second.push_back(txt); |
---|
73 | } |
---|
74 | } |
---|
75 | } |
---|
76 | |
---|
77 | void sectorParameters::InputRep(UAPNode* root) |
---|
78 | { |
---|
79 | // UAPNode* node = root->addChild("lattice"); |
---|
80 | // node->addAttribute("name","global_lattice"); |
---|
81 | // node->addChild("geometry")->addAttribute("type",geometry_); |
---|
82 | // string txt = ""; |
---|
83 | // txt = mixedTools::doubleToString(pc_); |
---|
84 | // node->addChild("pc")->addAttribute("design",txt); |
---|
85 | |
---|
86 | // node = root->addChild("sector"); |
---|
87 | // node->addAttribute("name","sect"); |
---|
88 | // txt = mixedTools::doubleToString(lCell_); |
---|
89 | // node->addAttribute("length",txt); |
---|
90 | // txt = mixedTools::intToString(nCells_); |
---|
91 | // node->addAttribute("repeat",txt); |
---|
92 | } |
---|
93 | |
---|
94 | // int sectorParameters::getNumberOfCells() const { |
---|
95 | // return nCells_; |
---|
96 | // } |
---|
97 | |
---|
98 | // double sectorParameters::getCellLength() const { |
---|
99 | // return lCell_; |
---|
100 | // } |
---|
101 | |
---|
102 | // double sectorParameters::getParticleMomentum() const { |
---|
103 | // return pc_; |
---|
104 | // } |
---|
105 | |
---|
106 | vector<statements> sectorParameters::getSectors() const { |
---|
107 | return sectorsStatements_; |
---|
108 | } |
---|
109 | |
---|
110 | void sectorParameters::setSectors(const vector<statements>& v) |
---|
111 | { |
---|
112 | #if BAVARD > 0 |
---|
113 | cout << "***********************************" << endl; |
---|
114 | cout << " sectorParameters::setSectors() " << endl << endl; |
---|
115 | #endif |
---|
116 | |
---|
117 | if(!sectorsStatements_.empty()) sectorsStatements_.clear(); |
---|
118 | |
---|
119 | for(int i = 0; i < v.size(); i++) { |
---|
120 | sectorsStatements_.push_back(statements(v.at(i).first,vector<string>())); |
---|
121 | for(int j = 0; j < 4; j++) |
---|
122 | sectorsStatements_.back().second.push_back(v.at(i).second.at(j)); |
---|
123 | } |
---|
124 | |
---|
125 | #if BAVARD > 0 |
---|
126 | cout << "sectorsStatements_.size()= " << sectorsStatements_.size() << endl; |
---|
127 | for(int i = 0; i < sectorsStatements_.size(); i++) { |
---|
128 | cout << "name= " << sectorsStatements_.at(i).first << ", de " << sectorsStatements_.at(i).second.at(0) << ", Ã " << sectorsStatements_.at(i).second.at(1) << ", reflection = " << sectorsStatements_.at(i).second.at(2) << ", repeat= " << sectorsStatements_.at(i).second.at(3) << endl << endl; |
---|
129 | } |
---|
130 | #endif |
---|
131 | } |
---|