00001 /********************************************************************** 00002 bond.h - Handle OBBond class. 00003 00004 Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc. 00005 Some portions Copyright (C) 2001-2006 by Geoffrey R. Hutchison 00006 Some portions Copyright (C) 2003 by Michael Banck 00007 00008 This file is part of the Open Babel project. 00009 For more information, see <http://openbabel.sourceforge.net/> 00010 00011 This program is free software; you can redistribute it and/or modify 00012 it under the terms of the GNU General Public License as published by 00013 the Free Software Foundation version 2 of the License. 00014 00015 This program is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 GNU General Public License for more details. 00019 ***********************************************************************/ 00020 00021 #ifndef OB_BOND_H 00022 #define OB_BOND_H 00023 00024 #include <openbabel/babelconfig.h> 00025 00026 #ifndef EXTERN 00027 # define EXTERN extern 00028 #endif 00029 00030 #include <openbabel/base.h> 00031 #include <openbabel/atom.h> 00032 00033 namespace OpenBabel 00034 { 00035 00036 class OBAtom; 00037 00039 typedef OBBond OBEdgeBase; 00040 00041 //BOND Property Macros (flags) 00043 #define OB_AROMATIC_BOND (1<<1) 00045 #define OB_WEDGE_BOND (1<<2) 00047 #define OB_HASH_BOND (1<<3) 00049 #define OB_RING_BOND (1<<4) 00051 #define OB_TORUP_BOND (1<<5) 00053 #define OB_TORDOWN_BOND (1<<6) 00055 #define OB_KSINGLE_BOND (1<<7) 00057 #define OB_KDOUBLE_BOND (1<<8) 00059 #define OB_KTRIPLE_BOND (1<<9) 00061 #define OB_CLOSURE_BOND (1<<10) 00062 // 11-16 currently unused 00063 00064 // class introduction in bond.cpp 00065 class OBAPI OBBond: public OBBase 00066 { 00067 protected: 00068 unsigned int _idx; 00069 OBMol *_parent; 00070 OBAtom *_bgn; 00071 OBAtom *_end; 00072 00073 char _order; 00074 unsigned short int _flags; 00075 00076 bool HasFlag(int flag) { return((_flags & flag) != 0); } 00077 void SetFlag(int flag) { _flags |= flag; } 00078 void UnsetFlag(int flag) { _flags &= (~(flag)); } 00079 00080 public: 00082 00083 bool Visit; 00084 00086 OBBond(); 00088 virtual ~OBBond(); 00089 00091 00092 00093 00095 void SetIdx(int idx) { _idx = idx; } 00097 00098 void SetBO(int order); 00100 void SetBondOrder(int order); 00102 void SetBegin(OBAtom *begin){ _bgn = begin; } 00104 void SetEnd(OBAtom *end) { _end = end; } 00106 void SetParent(OBMol *ptr) { _parent= ptr; } 00108 void SetLength(OBAtom *fixed,double length); 00111 void SetLength(double length); 00113 void Set(int index, OBAtom* begin,OBAtom* end,int order,int flags); 00115 void SetKSingle(); 00117 void SetKDouble(); 00119 void SetKTriple(); 00121 void SetAromatic() { SetFlag(OB_AROMATIC_BOND); } 00123 void SetHash() { SetFlag(OB_HASH_BOND); } 00125 void SetWedge() { SetFlag(OB_WEDGE_BOND); } 00127 void SetUp() { SetFlag(OB_TORUP_BOND); UnsetFlag(OB_TORDOWN_BOND); } 00129 void SetDown() { SetFlag(OB_TORDOWN_BOND); UnsetFlag(OB_TORUP_BOND); } 00131 void SetInRing() { SetFlag(OB_RING_BOND); } 00133 00136 void SetClosure() { SetFlag(OB_CLOSURE_BOND); } 00138 void UnsetHash() { UnsetFlag(OB_HASH_BOND); } 00140 void UnsetWedge() { UnsetFlag(OB_WEDGE_BOND); } 00142 void UnsetUp() { UnsetFlag(OB_TORUP_BOND); } 00144 void UnsetDown() { UnsetFlag(OB_TORDOWN_BOND); } 00146 void UnsetAromatic() { UnsetFlag(OB_AROMATIC_BOND);} 00148 void UnsetKekule() 00149 { 00150 _flags &= (~(OB_KSINGLE_BOND|OB_KDOUBLE_BOND|OB_KTRIPLE_BOND)); 00151 } 00153 00155 00156 00157 unsigned int GetIdx() const { return(_idx); } 00159 00160 unsigned int GetBO() const { return(_order); } 00162 unsigned int GetBondOrder() const { return(_order); } 00164 unsigned int GetFlags() const { return(_flags); } 00166 unsigned int GetBeginAtomIdx() const 00167 { return (_bgn ? _bgn->GetIdx() : 0); } 00169 unsigned int GetEndAtomIdx() const 00170 { return (_end ? _end->GetIdx() : 0); } 00172 OBAtom *GetBeginAtom() { return(_bgn); } 00173 const OBAtom *GetBeginAtom() const 00174 { return(_bgn); } 00176 OBAtom *GetEndAtom() { return(_end); } 00177 const OBAtom *GetEndAtom() const 00178 { return(_end); } 00180 00182 OBAtom *GetNbrAtom(OBAtom *ptr) 00183 { 00184 return((ptr != _bgn)? _bgn : _end); 00185 } 00187 OBMol *GetParent() {return(_parent);} 00189 00190 double GetEquibLength() const; 00192 double GetLength() const; 00194 00196 unsigned int GetNbrAtomIdx(OBAtom *ptr) 00197 { 00198 if (ptr!=_bgn) 00199 return (_bgn ? _bgn->GetIdx() : 0); 00200 else 00201 return (_end ? _end->GetIdx() : 0); 00202 } 00204 00206 00207 00208 00209 00210 bool IsAromatic() const; 00212 bool IsInRing() const; 00214 00219 bool IsRotor(); 00221 bool IsAmide(); 00223 bool IsPrimaryAmide(); 00225 bool IsSecondaryAmide(); 00227 bool IsEster(); 00229 bool IsCarbonyl(); 00231 bool IsSingle(); 00233 bool IsDouble(); 00235 bool IsTriple(); 00237 bool IsKSingle(); 00239 bool IsKDouble(); 00241 bool IsKTriple(); 00243 bool IsClosure(); 00246 bool IsUp() { return(HasFlag(OB_TORUP_BOND)); } 00249 bool IsDown() { return(HasFlag(OB_TORDOWN_BOND)); } 00252 bool IsWedge() { return(HasFlag(OB_WEDGE_BOND)); } 00255 bool IsHash() { return(HasFlag(OB_HASH_BOND)); } 00257 bool IsDoubleBondGeometry(); 00259 00260 }; // class OBBond 00261 00263 typedef std::vector<OBBond*>::iterator OBBondIterator; 00264 00265 }// namespace OpenBabel 00266 00267 #endif // OB_BOND_H 00268
This file is part of the documentation for Open Babel, version 2.2.0.