Changeset 436 in PSPA for Interface_Web/trunk/pspaWT/sources/controler/src/sectorParameters.cc
- Timestamp:
- Nov 26, 2013, 5:36:11 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/sources/controler/src/sectorParameters.cc
r431 r436 1 2 //#include <cstdlib>3 1 4 2 #include "sectorParameters.h" 5 3 #include "mixedTools.h" 6 4 7 sectorParameters::sectorParameters() : parametersString_(NULL) 5 #define BAVARD 1 6 7 sectorParameters::sectorParameters() 8 8 { 9 9 geometry_= string("CIRCULAR"); 10 nCells_ = 0;11 lCell_ = 0.0;12 pc_ = 0.0;13 nbParam_ = 4;14 parametersString_ = new string[nbParam_+1];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 15 } 16 16 17 string* sectorParameters::getParametersString() const 18 {19 parametersString_[0] = mixedTools::intToString(nbParam_);20 parametersString_[1] = geometry_;21 parametersString_[2] = mixedTools::intToString(nCells_);22 parametersString_[3] = mixedTools::doubleToString(lCell_);23 parametersString_[4] = mixedTools::doubleToString(pc_);24 return parametersString_;25 }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 26 27 void sectorParameters::setParametersString(string* param) 28 { 29 geometry_ = param[1].c_str(); 30 nCells_ = atoi(param[2].c_str()); 31 lCell_ = atof(param[3].c_str()); 32 pc_ = atof(param[4].c_str()); 33 } 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 // } 34 44 35 45 void sectorParameters::raz() 36 46 { 37 geometry_= string("CIRCULAR"); 38 nCells_ = 0; 39 lCell_ = 0.0; 40 pc_ = 0.0; 47 if(!sectors_.empty()) sectors_.clear(); 41 48 } 42 49 … … 44 51 { 45 52 ostringstream sortie; 46 sortie<<" lattice "<<endl; 47 sortie<<geometry_<<" "<<nCells_<<" "<<lCell_<<" "<<pc_<<endl; 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 } 48 58 return sortie.str(); 49 59 } … … 51 61 void sectorParameters::FileInput(ifstream& ifs) 52 62 { 53 ifs >> geometry_ >> nCells_ >> lCell_ >> pc_; 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 } 54 74 } 55 75 56 76 void sectorParameters::InputRep(UAPNode* root) 57 77 { 58 UAPNode* node = root->addChild("lattice");59 node->addAttribute("name","global_lattice");60 node->addChild("geometry")->addAttribute("type",geometry_);61 string txt = "";62 txt = mixedTools::doubleToString(pc_);63 node->addChild("pc")->addAttribute("design",txt);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); 64 84 65 node = root->addChild("sector");66 node->addAttribute("name","sect");67 txt = mixedTools::doubleToString(lCell_);68 node->addAttribute("length",txt);69 txt = mixedTools::intToString(nCells_);70 node->addAttribute("repeat",txt);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); 71 91 } 72 92 73 int sectorParameters::getNumberOfCells() const { 74 return nCells_; 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 105 vector<statements> sectorParameters::getSectors() const { 106 return sectors_; 75 107 } 76 108 77 double sectorParameters::getCellLength() const { 78 return lCell_; 109 void 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 79 130 } 80 81 double sectorParameters::getParticleMomentum() const {82 return pc_;83 }84 85
Note: See TracChangeset
for help on using the changeset viewer.