ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-3.0/src/io/BendTypesSectionParser.cpp
(Generate patch)

Comparing branches/new_design/OOPSE-3.0/src/io/BendTypesSectionParser.cpp (file contents):
Revision 1784 by tim, Wed Nov 24 22:12:12 2004 UTC vs.
Revision 1856 by tim, Mon Dec 6 04:49:53 2004 UTC

# Line 27 | Line 27
27   #include "types/HarmonicBendType.hpp"
28   #include "types/UreyBradleyBendType.hpp"
29   #include "types/CubicBendType.hpp"
30 < #include "types/QuadraticBendType.hpp"
30 > #include "types/QuarticBendType.hpp"
31   #include "types/PolynomialBendType.hpp"
32 + #include "UseTheForce/ForceField.hpp"
33 + #include "utils/NumericConstant.hpp"
34   namespace oopse {
35  
36   BendTypesSectionParser::BendTypesSectionParser() {
37      setSectionName("BendTypes");
38 +
39 +    stringToEnumMap_["Harmonic"] =  btHarmonic;      
40 +    stringToEnumMap_["GhostBend"] =  btGhostBend;                
41 +    stringToEnumMap_["UreyBradley"] =  btUreyBradley;                    
42 +    stringToEnumMap_["Cubic"] = btCubic;
43 +    stringToEnumMap_["Quartic"] = btQuartic;
44 +    stringToEnumMap_["Polynomial"] = btPolynomial;    
45   }
46  
47   void BendTypesSectionParser::parseLine(ForceField& ff,const std::string& line, int lineNo){
48      StringTokenizer tokenizer(line);
40    std::string at1;
41    std::string at2;
42    std::string at3;
43    std::string bt;
44    double theta0;
49      BendType* bendType = NULL;
50  
51      int nTokens = tokenizer.countTokens();
# Line 51 | Line 55 | void BendTypesSectionParser::parseLine(ForceField& ff,
55          return;
56      }
57      
58 <    at1 = tokenizer.nextToken();
59 <    at2 = tokenizer.nextToken();
60 <    at3 = tokenizer.nextToken();
61 <    bt = tokenizer.nextToken();
62 <    theta0 = tokenizer.nextTokenAsDouble();
58 >    std::string at1 = tokenizer.nextToken();
59 >    std::string at2 = tokenizer.nextToken();
60 >    std::string at3 = tokenizer.nextToken();
61 >    BendTypeEnum bt = getBendTypeEnum(tokenizer.nextToken());
62 >    double theta0 = tokenizer.nextTokenAsDouble() / 180.0 * NumericConstant::PI; //convert to rad
63      nTokens -= 5;
64  
65      //switch is a maintain nightmare
66      switch(bt) {
67              
68 <        case "Harmonic" :
68 >        case btHarmonic :
69              
70              if (nTokens < 1) {
71  
# Line 71 | Line 75 | void BendTypesSectionParser::parseLine(ForceField& ff,
75                  bendType = new HarmonicBendType(theta0, ktheta);
76              }
77              break;
78 <        case "GhostBend" :
78 >        case btGhostBend :
79              if (nTokens < 1) {
80  
81              } else {
# Line 80 | Line 84 | void BendTypesSectionParser::parseLine(ForceField& ff,
84              }
85              break;            
86  
87 <        case "UreyBradley" :
87 >        case btUreyBradley :
88              if (nTokens < 3) {
89  
90              } else {
# Line 91 | Line 95 | void BendTypesSectionParser::parseLine(ForceField& ff,
95              }
96              break;
97              
98 <        case "Cubic" :
98 >        case btCubic :
99              if (nTokens < 4) {
100  
101              } else {
# Line 105 | Line 109 | void BendTypesSectionParser::parseLine(ForceField& ff,
109              }
110              break;
111              
112 <        case "Quartic" :
112 >        case btQuartic :
113              if (nTokens < 5) {
114  
115              } else {
# Line 117 | Line 121 | void BendTypesSectionParser::parseLine(ForceField& ff,
121                  double k1 = tokenizer.nextTokenAsDouble();
122                  double k0 = tokenizer.nextTokenAsDouble();
123                  
124 <                bendType = new QuadraticBendType(theta0, k4, k3, k2, k1, k0);
124 >                bendType = new QuarticBendType(theta0, k4, k3, k2, k1, k0);
125              }
126              break;
127  
128 <        case "Polynomial" :
128 >        case btPolynomial :
129              if (nTokens < 2 || nTokens % 2 != 0) {
130  
131              } else {
132                  int nPairs = nTokens / 2;
133                  int power;
134                  double coefficient;
135 <                PolynomialBendType* pbt = new PolynomialBendType();
135 >                PolynomialBendType* pbt = new PolynomialBendType(theta0);
136                  
137                  for (int i = 0; i < nPairs; ++i) {
138                      power = tokenizer.nextTokenAsInt();
# Line 139 | Line 143 | void BendTypesSectionParser::parseLine(ForceField& ff,
143              
144              break;
145  
146 +        case btUnknown :
147          default:
148 +            break;
149              
150      }
151  
# Line 148 | Line 154 | void BendTypesSectionParser::parseLine(ForceField& ff,
154      }
155   }
156  
157 + BendTypesSectionParser::BendTypeEnum BendTypesSectionParser::getBendTypeEnum(const std::string& str) {
158 +    std::map<std::string, BendTypeEnum>::iterator i;
159 +    i = stringToEnumMap_.find(str);
160 +
161 +    return i == stringToEnumMap_.end() ? btUnknown : i->second;
162 + }
163 +
164   } //end namespace oopse
165  
166  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines