Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef OB_TETRANONPLANAR_H
00025 #define OB_TETRANONPLANAR_H
00026
00027 #include <openbabel/stereo/stereo.h>
00028 #include <openbabel/oberror.h>
00029
00030 namespace OpenBabel {
00031
00034
00091 class OBAPI OBTetraNonPlanarStereo : public OBStereoBase
00092 {
00093 public:
00098 OBTetraNonPlanarStereo(OBMol *mol);
00102 virtual ~OBTetraNonPlanarStereo();
00103
00144 template <typename ConfigType>
00145 static ConfigType ToConfig(const ConfigType &cfg, unsigned long from_or_towards,
00146 OBStereo::Winding winding = OBStereo::Clockwise,
00147 OBStereo::View view = OBStereo::ViewFrom)
00148 {
00149 if (cfg.from == OBStereo::NoRef) {
00150 obErrorLog.ThrowError(__FUNCTION__,
00151 "OBTetraNonPlanarStereo::ToConfig : Invalid from in ConfigType struct.", obError);
00152 return ConfigType();
00153 }
00154 if (cfg.refs.size() != 3) {
00155 obErrorLog.ThrowError(__FUNCTION__,
00156 "OBTetraNonPlanarStereo::ToConfig : Invalid refs size.", obError);
00157 return ConfigType();
00158 }
00159
00160
00161 ConfigType result = cfg;
00162 result.from = from_or_towards;
00163 result.winding = winding;
00164 result.view = view;
00165
00166
00167 bool odd = false;
00168
00169
00170 if (cfg.from != from_or_towards) {
00171
00172 for (int i = 0; i < 3; ++i) {
00173 if (cfg.refs.at(i) == from_or_towards) {
00174 result.refs[i] = cfg.from;
00175 break;
00176 }
00177 }
00178
00179 odd = true;
00180 }
00181
00182
00183 if (winding == cfg.winding)
00184 odd = !odd;
00185
00186 if (view == cfg.view)
00187 odd = !odd;
00188
00189
00190 if (result.refs.size() == 3) {
00191 if (odd)
00192 OBStereo::Permutate(result.refs, 1, 2);
00193 return result;
00194 }
00195
00196 obErrorLog.ThrowError(__FUNCTION__,
00197 "OBTetraNonPlanarStereo::ToConfig : Parameter id not found in internal refs.", obError);
00198 return result;
00199 }
00203 template <typename ConfigType>
00204 static void ChangeWinding(ConfigType &cfg)
00205 {
00206 cfg.winding = (cfg.winding == OBStereo::Clockwise) ? OBStereo::AntiClockwise : OBStereo::Clockwise;
00207 OBStereo::Permutate(cfg.refs, 1, 2);
00208 }
00212 template <typename ConfigType>
00213 static void ChangeView(ConfigType &cfg)
00214 {
00215 cfg.view = (cfg.view == OBStereo::ViewFrom) ? OBStereo::ViewTowards : OBStereo::ViewFrom;
00216 OBStereo::Permutate(cfg.refs, 1, 2);
00217 }
00221 template <typename ConfigType>
00222 static void Invert(ConfigType &cfg)
00223 {
00224 OBStereo::Permutate(cfg.refs, 1, 2);
00225 }
00226 };
00227
00229
00230 }
00231
00232 #endif
00233