tetraplanar.h Source File

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

tetraplanar.h
Go to the documentation of this file.

    00001 /**********************************************************************
    00002   tetraplanar.h - OBTetraPlanarStereo
    00003
    00004   Copyright (C) 2009 by Tim Vandermeersch
    00005
    00006   This file is part of the Open Babel project.
    00007   For more information, see <http://openbabel.org/>
    00008
    00009   This program is free software; you can redistribute it and/or modify
    00010   it under the terms of the GNU General Public License as published by
    00011   the Free Software Foundation; either version 2 of the License, or
    00012   (at your option) any later version.
    00013
    00014   This program is distributed in the hope that it will be useful,
    00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00017   GNU General Public License for more details.
    00018
    00019   You should have received a copy of the GNU General Public License
    00020   along with this program; if not, write to the Free Software
    00021   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    00022   02110-1301, USA.
    00023  **********************************************************************/
    00024 #ifndef OB_TETRAPLANAR_H
    00025 #define OB_TETRAPLANAR_H
    00026
    00027 #include "stereo.h"
    00028 #include <algorithm> // std::rotate
    00029
    00030 namespace OpenBabel {
    00031
    00083   class OBAPI OBTetraPlanarStereo : public OBStereoBase
    00084   {
    00085     public:
    00086       OBTetraPlanarStereo(OBMol *mol);
    00087       virtual ~OBTetraPlanarStereo();
    00088
    00089       template <typename ConfigType>
    00090       static ConfigType ToConfig(const ConfigType &cfg, unsigned long start,
    00091           OBStereo::Shape shape = OBStereo::ShapeU)
    00092       {
    00093         ConfigType result = cfg;
    00094         result.shape = shape;
    00095
    00096         // convert from U/Z/4 to U shape
    00097         switch (cfg.shape) {
    00098           case OBStereo::ShapeU:
    00099             break;
    00100           case OBStereo::ShapeZ:
    00101             OBStereo::Permutate(result.refs, 2, 3); // convert to U shape
    00102             break;
    00103           case OBStereo::Shape4:
    00104             OBStereo::Permutate(result.refs, 1, 2); // convert to U shape
    00105             break;
    00106         }
    00107
    00108
    00109         // since refs are U shaped we can rotate the refs lexicographically
    00110         for (int i = 0; i < 4; ++i) {
    00111           std::rotate(result.refs.begin(), result.refs.begin() + 1, result.refs.end());
    00112           // start at refs[0]?
    00113           if (result.refs.at(0) == start)
    00114             break;
    00115         }
    00116
    00117         // convert from U to desired U/Z/4
    00118         // (don't change refs[0]!)
    00119         switch (shape) {
    00120           case OBStereo::ShapeU:
    00121             break;
    00122           case OBStereo::ShapeZ:
    00123             OBStereo::Permutate(result.refs, 2, 3); // convert to Z shape
    00124             break;
    00125           case OBStereo::Shape4:
    00126             OBStereo::Permutate(result.refs, 1, 2); // convert to 4 shape
    00127             break;
    00128         }
    00129
    00130         return result;
    00131       }
    00132
    00133   };
    00134
    00135 }
    00136
    00137 #endif
    00138

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines