BALL
1.4.1
|
00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 00005 #ifndef BALL_MOLMEC_PARAMETER_COSINETORSION_H 00006 #define BALL_MOLMEC_PARAMETER_COSINETORSION_H 00007 00008 #ifndef BALL_FORMAT_PARAMETERSECTION_H 00009 # include <BALL/FORMAT/parameterSection.h> 00010 #endif 00011 00012 #ifndef BALL_MOLMEC_PARAMETER_ATOMTYPES_H 00013 # include <BALL/MOLMEC/PARAMETER/atomTypes.h> 00014 #endif 00015 00016 namespace BALL 00017 { 00025 class BALL_EXPORT CosineTorsion 00026 : public ParameterSection 00027 { 00028 public: 00029 00030 enum 00031 { 00032 UNKNOWN 00033 }; 00034 00035 struct SingleValues 00036 { 00037 float phase; 00038 float V; 00039 float f; 00040 float n; 00041 00042 SingleValues(const SingleValues& v) 00043 : phase(v.phase), 00044 V(v.V), 00045 f(v.f), 00046 n(v.n) 00047 { 00048 } 00049 00050 SingleValues() 00051 : phase(0), 00052 V(0), 00053 f(0), 00054 n(0) 00055 { 00056 } 00057 00058 bool operator == (const SingleValues& rhs) const 00059 { 00060 return ((phase == rhs.phase) && (V == rhs.V) 00061 && (f == rhs.f) && (n == rhs.n)); 00062 } 00063 }; 00064 00065 struct BALL_EXPORT Values 00066 { 00068 Size n; 00070 SingleValues* values; 00071 00072 Values() 00073 : n(0), 00074 values(0) 00075 { 00076 } 00077 00078 Values(Size number) 00079 : n((unsigned char)number), 00080 values(new SingleValues[number]) 00081 { 00082 } 00083 00084 Values(const Values& v) 00085 { 00086 n = v.n; 00087 values = new SingleValues[n]; 00088 for (Position i = 0; i < n; i++) 00089 { 00090 values[i].phase = v.values[i].phase; 00091 values[i].V = v.values[i].V; 00092 values[i].f = v.values[i].f; 00093 values[i].n = v.values[i].n; 00094 } 00095 } 00096 00097 void set(const Values& v) 00098 { 00099 delete [] values; 00100 00101 n = v.n; 00102 values = new SingleValues[n]; 00103 for (Position i = 0; i < n; i++) 00104 { 00105 values[i] = v.values[i]; 00106 } 00107 } 00108 00109 ~Values() 00110 { 00111 delete [] values; 00112 } 00113 00114 bool operator == (const Values& rhs) const 00115 { 00116 if (n != rhs.n) 00117 { 00118 return false; 00119 } 00120 for (Position i = 0; i < n; ++i) 00121 { 00122 if (!(values[i] == rhs.values[i])) 00123 { 00124 return false; 00125 } 00126 } 00127 return true; 00128 } 00129 00130 bool operator != (const Values& rhs) const 00131 { 00132 return ! operator == (rhs); 00133 } 00134 }; 00135 00136 struct BALL_EXPORT Data 00137 { 00138 Atom* atom1; 00139 Atom* atom2; 00140 Atom* atom3; 00141 Atom* atom4; 00142 00143 Values values; 00144 }; 00145 00146 struct BALL_EXPORT SingleData 00147 { 00148 Atom* atom1; 00149 Atom* atom2; 00150 Atom* atom3; 00151 Atom* atom4; 00152 00153 SingleValues values; 00154 }; 00155 00159 00162 CosineTorsion(); 00163 00166 CosineTorsion(const CosineTorsion& cosine_torsion); 00167 00170 virtual ~CosineTorsion() ; 00171 00174 virtual void clear() ; 00175 00177 00181 00188 virtual bool extractSection(ForceFieldParameters& parameters, const String& section_name); 00189 00191 virtual bool extractSection(Parameters& parameters, const String& section_name); 00192 00195 bool hasParameters(Atom::Type I, Atom::Type J, Atom::Type K, Atom::Type L) const; 00196 00199 CosineTorsion::Values getParameters(Atom::Type I, Atom::Type J, Atom::Type K, Atom::Type L) const; 00200 00205 bool assignParameters(CosineTorsion::Values& parameters, Atom::Type I, 00206 Atom::Type J, Atom::Type K, Atom::Type L) const; 00207 00209 00212 00215 CosineTorsion& operator = (const CosineTorsion& cosine_torsion); 00216 00218 00222 00225 bool operator == (const CosineTorsion& cosine_torsion) const; 00226 00228 00229 protected: 00230 00231 Size number_of_atom_types_; 00232 00233 vector<Values> torsions_; 00234 00235 HashMap<Size, Size> torsion_hash_map_; 00236 }; 00237 00238 } // namespace BALL 00239 00240 #endif // BALL_MOLMEC_PARAMETER_COSINETORSION_H