source: PSPA/Interface_Web/trunk/pspaWT/sources/controler/src/sectorParameters.cc @ 436

Last change on this file since 436 was 436, checked in by touze, 11 years ago

ajout de secteurs

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