1 /**********************************************************************
2 generic.h - Handle generic data classes. Custom data for atoms, bonds, etc.
3 
4 Copyright (C) 1998-2001 by OpenEye Scientific Software, Inc.
5 Some portions Copyright (C) 2001-2010 by Geoffrey R. Hutchison
6 
7 This file is part of the Open Babel project.
8 For more information, see <http://openbabel.org/>
9 
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation version 2 of the License.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18 ***********************************************************************/
19 
20 #ifndef OB_GENERIC_H
21 #define OB_GENERIC_H
22 
23 #include <openbabel/babelconfig.h>
24 
25 #include <string>
26 #include <vector>
27 #include <map>
28 
29 #include <openbabel/math/spacegroup.h>
30 #include <openbabel/obutil.h>
31 #include <openbabel/base.h>
32 
33 namespace OpenBabel
34 {
35 
36   // Forward declarations
37   class OBBase;
38   class OBAtom;
39   class OBBond;
40   class OBMol;
41   class OBRing;
42 
43   //! \class OBCommentData generic.h <openbabel/generic.h>
44   //! \brief Used to store a comment string (can be multiple lines long)
45  class OBAPI OBCommentData : public OBGenericData
46   {
47   protected:
48     std::string _data;
49   public:
50     OBCommentData();
51     OBCommentData(const OBCommentData&);
Clone(OBBase *)52     virtual OBGenericData* Clone(OBBase* /*parent*/) const{return new OBCommentData(*this);}
53 
54     OBCommentData& operator=(const OBCommentData &src);
55 
SetData(const std::string & data)56     void          SetData(const std::string &data)
57     { _data = data; Trim(_data); }
SetData(const char * d)58     void          SetData(const char *d)
59     {_data = d; Trim(_data);     }
GetData()60     const std::string &GetData()              const
61     {        return(_data);      }
GetValue()62     virtual const std::string &GetValue()              const
63     {        return(_data);      }
64   };
65 
66   //! \class OBExternalBond generic.h <openbabel/generic.h>
67   //! \brief Used to store information on an external bond
68   //! (e.g., SMILES fragments)
69   class OBAPI OBExternalBond
70   {
71     int     _idx;
72     OBAtom *_atom;
73     OBBond *_bond;
74   public:
OBExternalBond()75   OBExternalBond(): _idx(0), _atom(nullptr), _bond(nullptr) {}
76     OBExternalBond(OBAtom *,OBBond *,int);
77     OBExternalBond(const OBExternalBond &);
~OBExternalBond()78     ~OBExternalBond()   {}
79 
GetIdx()80     int     GetIdx()  const    {        return(_idx);    }
GetAtom()81     OBAtom *GetAtom() const    {        return(_atom);   }
GetBond()82     OBBond *GetBond() const    {        return(_bond);   }
SetIdx(int idx)83     void SetIdx(int idx)       {        _idx = idx;      }
SetAtom(OBAtom * atom)84     void SetAtom(OBAtom *atom) {        _atom = atom;    }
SetBond(OBBond * bond)85     void SetBond(OBBond *bond) {        _bond = bond;    }
86   };
87 
88   //! \class OBExternalBondData generic.h <openbabel/generic.h>
89   //! \brief Used to store information on external bonds (e.g., in SMILES fragments)
90  class OBAPI OBExternalBondData : public OBGenericData
91   {
92   protected:
93     std::vector<OBExternalBond> _vexbnd;
94   public:
95     OBExternalBondData();
96 
97     //Copying is not used and too much work to set up
Clone(OBBase *)98     virtual OBGenericData* Clone(OBBase* /*parent*/) const{return nullptr;}
99 
100     void SetData(OBAtom*,OBBond*,int);
GetData()101     std::vector<OBExternalBond> *GetData()
102       {
103         return(&_vexbnd);
104       }
105   };
106 
107   //! \class OBPairData generic.h <openbabel/generic.h>
108   //! \brief Used to store arbitrary text attribute/value relationships.
109   //!
110   //! Ideal for arbitrary text descriptors for molecules, atoms, bonds, residues,
111   //!  e.g. in QSAR.
112  class OBAPI OBPairData : public OBGenericData
113   {
114   protected:
115     std::string _value; //!< The data for this key/value pair
116   public:
117     OBPairData();
Clone(OBBase *)118     virtual OBGenericData* Clone(OBBase* /*parent*/) const
119       {return new OBPairData(*this);}
SetValue(const char * v)120     void    SetValue(const char *v)        {      _value = v;    }
SetValue(const std::string & v)121     void    SetValue(const std::string &v) {      _value = v;    }
GetValue()122     virtual const std::string &GetValue() const
123     {      return(_value);    }
124   };
125 
126   //! \class OBPairTemplate generic.h <openbabel/generic.h>
127   //! \brief Used to store arbitrary attribute/value relationsips of any type.
128   // More detailed description in generic.cpp
129   template <class ValueT>
130     class OBPairTemplate : public OBGenericData // Note: no OBAPI should be used
131   {
132   protected:
133     ValueT _value; //!< The data for this key/value pair
134   public:
OBPairTemplate()135   OBPairTemplate():
136     OBGenericData("PairData", OBGenericDataType::PairData) {};
Clone(OBBase *)137     virtual OBGenericData* Clone(OBBase* /*parent*/) const
138       {return new OBPairTemplate<ValueT>(*this);}
SetValue(const ValueT t)139     void SetValue(const ValueT t)             { _value = t;     }
GetGenericValue()140     virtual const ValueT &GetGenericValue() const    { return(_value); }
141   };
142 
143   //! Store arbitrary key/value integer data like OBPairData
144   typedef OBPairTemplate<int>     OBPairInteger;
145   //! Store arbitrary key/value floating point data like OBPairData
146   typedef OBPairTemplate<double>  OBPairFloatingPoint;
147   //! Store arbitrary key/value boolean data like OBPairData
148   typedef OBPairTemplate<bool>    OBPairBool;
149 
150   //! \class OBSetData generic.h <openbabel/generic.h>
151   //! \brief Used to store arbitrary attribute/set relationships.
152   //! Should be used to store a set of OBGenericData based on an attribute.
153  class OBAPI OBSetData : public OBGenericData
154   {
155   protected:
156     std::vector<OBGenericData *> _vdata;
157   public:
OBSetData()158   OBSetData() : OBGenericData("SetData", OBGenericDataType::SetData) {}
Clone(OBBase *)159     virtual OBGenericData* Clone(OBBase* /*parent*/) const{return new OBSetData(*this);}
160 
161     //! Add an OBGenericData element to the set.
AddData(OBGenericData * d)162     void AddData(OBGenericData *d)
163     {
164       if(d)
165         {
166           _vdata.push_back(d);
167         }
168     }
169 
170     //! Set the array of data to a new vector
SetData(std::vector<OBGenericData * > & vdata)171     void SetData(std::vector<OBGenericData *> &vdata)
172     {
173       _vdata = vdata;
174     }
175 
176     //! \return the OBGenericData associate with the attribute name parameter.
GetData(const char * s)177     OBGenericData *GetData(const char *s)
178     {
179       std::vector<OBGenericData*>::iterator i;
180 
181       for (i = _vdata.begin();i != _vdata.end();++i)
182         if ((*i)->GetAttribute() == s)
183           return(*i);
184 
185       return(nullptr);
186     }
187 
188     //! \return the OBGenericData associate with the attribute name parameter.
GetData(const std::string & s)189     OBGenericData *GetData(const std::string &s)
190     {
191       std::vector<OBGenericData*>::iterator i;
192 
193       for (i = _vdata.begin();i != _vdata.end();++i)
194         if ((*i)->GetAttribute() == s)
195           return(*i);
196 
197       return(nullptr);
198     }
199 
200     //! Gets the entire set.
GetData()201     virtual const std::vector<OBGenericData *> &GetData() const //now virtual and const
202     {
203       return(_vdata);
204     }
205 
206     //! Get the begin iterator.
GetBegin()207     std::vector<OBGenericData*>::iterator GetBegin()
208       {
209         return _vdata.begin();
210       }
211 
212     //! Get the end iterator.
GetEnd()213     std::vector<OBGenericData*>::iterator GetEnd()
214       {
215         return _vdata.end();
216       }
217 
218     //! Delete the matching OBGenericData element.
DeleteData(OBGenericData * gd)219     void DeleteData(OBGenericData *gd)
220     {
221       std::vector<OBGenericData*>::iterator i;
222       for (i = _vdata.begin();i != _vdata.end();++i)
223         if (*i == gd)
224           {
225             delete *i;
226             _vdata.erase(i);
227             break; // Done, don't do anything more, since iterator is invalid
228           }
229     }
230 
231   }; // OBSetData
232 
233   //! \class OBVirtualBond generic.h <openbabel/generic.h>
234   //! \brief Used to temporarily store bonds that reference
235   //! an atom that has not yet been added to a molecule
236  class OBAPI OBVirtualBond : public OBGenericData
237   {
238   protected:
239     unsigned int _bgn;
240     unsigned int _end;
241     unsigned int _ord;
242     int _stereo;
243   public:
244     OBVirtualBond();
Clone(OBBase *)245     virtual OBGenericData* Clone(OBBase* /*parent*/) const{return new OBVirtualBond(*this);}
246     OBVirtualBond(unsigned int, unsigned int, unsigned int,int stereo=0);
GetBgn()247     unsigned int GetBgn()    {      return(_bgn);    }
GetEnd()248     unsigned int GetEnd()    {      return(_end);    }
GetOrder()249     unsigned int GetOrder()  {      return(_ord);    }
GetStereo()250     int GetStereo() {      return(_stereo); }
251   };
252 
253   //! \class OBRingData generic.h <openbabel/generic.h>
254   //! \brief Used to store the SSSR set (filled in by OBMol::GetSSSR())
255  class OBAPI OBRingData : public OBGenericData
256   {
257   protected:
258     std::vector<OBRing*> _vr;
259   public:
260     OBRingData();
261     OBRingData(const OBRingData &);
262     // When copying a molecule, don't copy the RingData. Why not? Well,
263     // if you do, you'll end up with two RingDatas because one will already
264     // exist due to Kekulize() in EndModify() in operator= in OBMol. Having
265     // more than one RingData causes problems as one of them can become invalid
266     // and cause segfaults.
Clone(OBBase *)267     virtual OBGenericData* Clone(OBBase* /*parent*/) const{return nullptr;}
268     ~OBRingData();
269 
270     OBRingData &operator=(const OBRingData &);
271 
SetData(std::vector<OBRing * > & vr)272     void SetData(std::vector<OBRing*> &vr)
273     {
274       _vr = vr;
275     }
PushBack(OBRing * r)276     void PushBack(OBRing *r)
277     {
278       _vr.push_back(r);
279     }
GetData()280     std::vector<OBRing*> &GetData()
281       {
282         return(_vr);
283       }
284 
BeginRings()285     std::vector<OBRing*>::iterator BeginRings()
286       { return(_vr.begin()); }
EndRings()287     std::vector<OBRing*>::iterator EndRings()
288       { return(_vr.end()); }
289     OBRing *BeginRing(std::vector<OBRing*>::iterator &i);
290     OBRing *NextRing(std::vector<OBRing*>::iterator &i);
291   };
292 
293   //! \class OBUnitCell generic.h <openbabel/generic.h>
294   //! \brief Used for storing information about periodic boundary conditions
295   //!   with conversion to/from translation vectors and
296   //!  (a, b, c, alpha, beta, gamma)
297  class OBAPI OBUnitCell: public OBGenericData
298   {
299   public:
300     enum LatticeType { Undefined,
301                        Triclinic,
302                        Monoclinic,
303                        Orthorhombic,
304                        Tetragonal,
305                        Rhombohedral /**< also called trigonal*/,
306                        Hexagonal,
307                        Cubic};
308 
309 
310   protected:
311     matrix3x3 _mOrtho;// Orthogonal matrix of column vectors
312     matrix3x3 _mOrient;// Orientation matrix
313     vector3 _offset;
314     std::string _spaceGroupName;
315     const SpaceGroup* _spaceGroup;
316     LatticeType _lattice;
317   public:
318     //! public constructor
319     OBUnitCell();
320     OBUnitCell(const OBUnitCell &);
Clone(OBBase *)321     virtual OBGenericData* Clone(OBBase* /*parent*/) const
322     {return new OBUnitCell(*this);}
~OBUnitCell()323     ~OBUnitCell()    {}
324 
325     OBUnitCell &operator=(const OBUnitCell &);
326 
327     /*!
328     **\brief Constructs the cell matrix in lower triangular form from the values supplied
329     **\param a The length a
330     **\param b The length b
331     **\param c The length c
332     **\param alpha The angle alpha
333     **\param beta The angle beta
334     **\param gamma The angle gamma
335     */
336     void SetData(const double a, const double b, const double c,
337                  const double alpha, const double beta, const double gamma);
338     /*!
339     **\brief Constructs the cell matrix using the supplied row vectors
340     **\param v1 The x-vector
341     **\param v2 The y-vector
342     **\param v3 The z-vector
343     **\see OBUnitCell::GetCellVectors
344     */
345     void SetData(const vector3 v1, const vector3 v2, const vector3 v3);
346 
347     /*!
348     **\brief Sets the unit cell matrix
349     **\param m The unit cell matrix (row vectors)
350     **\see OBUnitCell::GetCellMatrix
351     */
352     void SetData(const matrix3x3 m);
353 
354     //! Set the offset to the origin to @p v1
355     void SetOffset(const vector3 v1);
356 
357     //! Set the space group for this unit cell.
358     //! Does not create an OBSymmetryData entry
SetSpaceGroup(const SpaceGroup * sg)359     void SetSpaceGroup(const SpaceGroup* sg) { _spaceGroup = sg; }
360 
361     //! Set the space group symbol for this unit cell.
362     //! Does not create an OBSymmetryData entry or attempt to convert
363     //!  between different symbol notations
SetSpaceGroup(const std::string sg)364     void SetSpaceGroup(const std::string sg) { _spaceGroup = SpaceGroup::GetSpaceGroup (sg);
365                                                _spaceGroupName = sg; }
366 
367     //! Set the space group for this unit cell. Each spacegroup-symbol
368     //! has a numeric equivalent which is easier to use to convert between
369     //! notations.
370     //! Does not create an OBSymmetryData entry or attempt to convert
371     //!  between different symbol notations
SetSpaceGroup(const int sg)372     void SetSpaceGroup(const int sg) { _spaceGroup = SpaceGroup::GetSpaceGroup (sg); }
373 
374     //! Set the Bravais lattice type for this unit cell
SetLatticeType(const LatticeType lt)375     void SetLatticeType(const LatticeType lt) { _lattice = lt; }
376 
377     //! Duplicate symmetry-unique atoms to fill out the unit cell
378     //! of the molecule, based on the known space group
379     void FillUnitCell(OBMol *);
380 
381     //! @todo Remove nonconst overloads in OBUnitCell on next version bump
382 
383     //! \return vector a
384     double GetA();
385     double GetA() const;
386     //! \return vector b
387     double GetB();
388     double GetB() const;
389     //! \return vector c
390     double GetC();
391     double GetC() const;
392     //! \return angle alpha
393     double GetAlpha();
394     double GetAlpha() const;
395     //! \return angle beta
396     double GetBeta();
397     double GetBeta() const;
398     //! \return angle gamma
399     double GetGamma();
400     double GetGamma() const;
401     //! \return any offset in the origin of the periodic boundaries
402     vector3 GetOffset();
403     vector3 GetOffset() const;
404 
405     //! \return the text representation of the space group for this unit cell
GetSpaceGroup()406     const SpaceGroup* GetSpaceGroup() { return(_spaceGroup); }
GetSpaceGroup()407     const SpaceGroup* GetSpaceGroup() const { return(_spaceGroup); }
408 
409     //! \return the text representation of the space group for this unit cell
GetSpaceGroupName()410     const std::string GetSpaceGroupName() { return(_spaceGroupName); }
GetSpaceGroupName()411     const std::string GetSpaceGroupName() const { return(_spaceGroupName); }
412 
413     //! \return lattice type (based on the @p spacegroup)
414     LatticeType GetLatticeType( int spacegroup );
415     LatticeType GetLatticeType( int spacegroup ) const;
416 
417     //! \return lattice type (based on angles and distances)
418     LatticeType GetLatticeType();
419     LatticeType GetLatticeType() const;
420 
421     //! \return v1, v2, v3 cell vectors
422     std::vector<vector3> GetCellVectors();
423     std::vector<vector3> GetCellVectors() const;
424     //! Access to the cell matrix as row vectors, useful for writing input files.
425     //! Equivalent to the transpose of GetOrientationMatrix() * GetOrthoMatrix()
426     //! \return The cell matrix with row vectors.
427     //! \see OBUnitCell::GetOrthoMatrix
428     //! \see OBUnitCell::GetFractionalMatrix
429     //! \see OBUnitCell::GetOrientationMatrix
430     //! \see OBUnitCell::FractionalToCartesian
431     //! \see OBUnitCell::CartesianToFractional
432     matrix3x3	GetCellMatrix();
433     matrix3x3	GetCellMatrix() const;
434     //! \return The orthogonalization matrix, used for converting from fractional to Cartesian coords.
435     //! \see OBUnitCell::GetCellMatrix
436     //! \see OBUnitCell::GetFractionalMatrix
437     //! \see OBUnitCell::GetOrientationMatrix
438     //! \see OBUnitCell::FractionalToCartesian
439     //! \see OBUnitCell::CartesianToFractional
440     matrix3x3 GetOrthoMatrix();
441     matrix3x3 GetOrthoMatrix() const;
442     //! Used to convert fractional and cartesian coordinates if the
443     //! cell is not oriented in standard form (a parallel to x axis,
444     //! b in xy plane)
445     //! \return The orientation matrix
446     //! \see OBUnitCell::GetOrthoMatrix
447     //! \see OBUnitCell::GetCellMatrix
448     //! \see OBUnitCell::GetFractionalMatrix
449     //! \see OBUnitCell::FractionalToCartesian
450     //! \see OBUnitCell::CartesianToFractional
451     matrix3x3 GetOrientationMatrix();
452     matrix3x3 GetOrientationMatrix() const;
453     //! \return The fractionalization matrix, used for converting from Cartesian to fractional coords.
454     //! \see OBUnitCell::GetOrthoMatrix
455     //! \see OBUnitCell::GetCellMatrix
456     //! \see OBUnitCell::GetOrientationMatrix
457     //! \see OBUnitCell::FractionalToCartesian
458     //! \see OBUnitCell::CartesianToFractional
459     matrix3x3 GetFractionalMatrix();
460     matrix3x3 GetFractionalMatrix() const;
461 
462     //! Convenience function to convert fractional coordinates to
463     //! cartesian coordinates. Returns
464     //!
465     //! GetOrientationMatrix() * GetOrthoMatrix() * frac + GetOffset()
466     //! \param frac Vector of fractional coordinates
467     //! \return Cartesian coordinates
468     vector3 FractionalToCartesian(vector3 frac);
469     vector3 FractionalToCartesian(vector3 frac) const;
470     //! Convenience function to convert cartesian coordinates to
471     //! fractional coordinates. Returns
472     //!
473     //! GetFractionalMatrix() * GetOrientationMatrix().inverse() * (cart - GetOffset())
474     //! \param cart Vector of cartesian coordinates
475     //! \return Fractional coordinates
476     vector3 CartesianToFractional(vector3 cart);
477     vector3 CartesianToFractional(vector3 cart) const;
478 
479     //! Wraps cartesian coordinate to fall within the unit cell.
480     //! \param cart Vector of cartesian coordinates
481     //! \return Cartesian coordinates within cell boundaries.
482     vector3 WrapCartesianCoordinate(vector3 cart);
483     vector3 WrapCartesianCoordinate(vector3 cart) const;
484     //! Wraps fractional coordinate to fall within the unit cell.
485     //! \param frac Vector of fractional coordinates
486     //! \return Fractional coordinates within cell boundaries (between 0 and 1).
487     //! \todo Make OBUnitCell::WrapFractionalCoordinate static in the next ABI break
488     vector3 WrapFractionalCoordinate(vector3 frac);
489     vector3 WrapFractionalCoordinate(vector3 frac) const;
490     //! Unwraps Cartesian coordinates near a reference location
491     //! \param new_loc Cartesian coordinates of target
492     //! \param ref_loc Cartesian coordinates of the reference location
493     //! \return Unwrapped coordinates of new_loc near ref_loc
494     vector3 UnwrapCartesianNear(vector3 new_loc, vector3 ref_loc);
495     vector3 UnwrapCartesianNear(vector3 new_loc, vector3 ref_loc) const;
496     //! Unwraps fractional coordinates near a reference location.
497     //! \param new_loc Fractional coordinates of target
498     //! \param ref_loc Fractional coordinates of the reference location
499     //! \return Unwrapped coordinates of new_loc near ref_loc
500     //! \todo Add a simple test case/example, like unwrapNear(<0.9, 0.2, 0.2>, <0.3, 0.9, 0.2>) -> <-0.1, 1.2, 0.2>
501     vector3 UnwrapFractionalNear(vector3 new_loc, vector3 ref_loc);
502     vector3 UnwrapFractionalNear(vector3 new_loc, vector3 ref_loc) const;
503     //! Applies the minimum image convention to a Cartesian displacement vector
504     //! \param cart Displacement vector between two atoms in Cartesian coordinates
505     //! \return Cartesian difference, wrapped within half the unit cell
506     vector3 MinimumImageCartesian(vector3 cart);
507     vector3 MinimumImageCartesian(vector3 cart) const;
508     //! Applies the minimum image convention to a fractional displacement vector
509     //! \param cart Displacement vector between two atoms in fractional coordinates
510     //! \return Fractional difference, wrapped within half the unit cell (-0.5 to 0.5)
511     vector3 MinimumImageFractional(vector3 frac);
512     vector3 MinimumImageFractional(vector3 frac) const;
513 
514     //! \return The numeric value of the given spacegroup
515     int GetSpaceGroupNumber( std::string name = "" );
516     int GetSpaceGroupNumber( std::string name = "" ) const;
517     //! \return The cell volume (in Angstroms^3)
518     double GetCellVolume();
519     double GetCellVolume() const;
520   };
521 
522   //! \class OBConformerData generic.h <openbabel/generic.h>
523   //! \brief Used to hold data on conformers or geometry optimization steps
524   //!
525   //! Supplements the support for multiple coordinate sets in OBMol, e.g.,
526   //! OBMol::GetConformer()
527  class OBAPI OBConformerData: public OBGenericData
528   {
529   protected:
530     //! Dimensionalities of conformers
531     std::vector<unsigned short>              _vDimension;
532     //! Relative energies of conformers (preferably in kJ/mol)
533     std::vector<double>                      _vEnergies;
534     //! Atomic forces for each conformer
535     std::vector< std::vector< vector3 > >    _vForces;
536     //! Atomic velocities for each conformer (e.g., trajectories)
537     std::vector< std::vector< vector3 > >    _vVelocity;
538     //! Atomic displacements for each conformer (e.g., RMS distances)
539     std::vector< std::vector< vector3 > >    _vDisplace;
540     //! Additional data (as strings)
541     std::vector<std::string>                 _vData;
542 
543   public:
544     OBConformerData();
545     OBConformerData(const OBConformerData &);
Clone(OBBase *)546     virtual OBGenericData* Clone(OBBase* /*parent*/) const{return new OBConformerData(*this);}
~OBConformerData()547     ~OBConformerData()    {}
548 
549     OBConformerData &operator=(const OBConformerData &);
550 
SetDimension(std::vector<unsigned short> vd)551     void SetDimension(std::vector<unsigned short> vd) { _vDimension = vd; }
SetEnergies(std::vector<double> ve)552     void SetEnergies(std::vector<double> ve) { _vEnergies = ve; }
SetForces(std::vector<std::vector<vector3>> vf)553     void SetForces(std::vector< std::vector< vector3 > > vf) {_vForces = vf;}
SetVelocities(std::vector<std::vector<vector3>> vv)554     void SetVelocities(std::vector< std::vector< vector3 > > vv)
555     { _vVelocity = vv; }
SetDisplacements(std::vector<std::vector<vector3>> vd)556     void SetDisplacements(std::vector< std::vector< vector3 > > vd)
557     { _vDisplace = vd; }
SetData(std::vector<std::string> vdat)558     void SetData(std::vector<std::string> vdat) { _vData = vdat; }
559 
GetDimension()560     std::vector<unsigned short> GetDimension() { return _vDimension; }
GetEnergies()561     std::vector<double>         GetEnergies()  { return _vEnergies; }
GetForces()562     std::vector< std::vector< vector3 > > GetForces() {return _vForces; }
GetVelocities()563     std::vector< std::vector< vector3 > > GetVelocities()
564       {return _vVelocity;}
GetDisplacements()565     std::vector< std::vector< vector3 > > GetDisplacements()
566       {return _vDisplace;}
GetData()567     std::vector<std::string>    GetData() { return _vData; }
568 
569   };
570 
571   //! \class OBSymmetryData generic.h <openbabel/generic.h>
572   //! \brief Used to hold the point-group and/or space-group symmetry
573   //! \todo Add support for translation between symbol notations.
574   //!        Add symmetry perception routines.
575  class OBAPI OBSymmetryData: public OBGenericData
576   {
577   protected:
578     std::string _spaceGroup;
579     std::string _pointGroup;
580   public:
581     OBSymmetryData();
582     OBSymmetryData(const OBSymmetryData &);
Clone(OBBase *)583     virtual OBGenericData* Clone(OBBase* /*parent*/) const{return new OBSymmetryData(*this);}
~OBSymmetryData()584     ~OBSymmetryData()    {}
585 
586     OBSymmetryData &operator=(const OBSymmetryData &);
587 
588     void SetData(std::string pg, std::string sg = "")
589     { _pointGroup = pg; _spaceGroup = sg; }
SetPointGroup(std::string pg)590     void SetPointGroup(std::string pg) { _pointGroup = pg; }
SetSpaceGroup(std::string sg)591     void SetSpaceGroup(std::string sg) { _spaceGroup = sg; }
592 
GetPointGroup()593     std::string GetPointGroup() { return _pointGroup; }
GetSpaceGroup()594     std::string GetSpaceGroup() { return _spaceGroup; }
595   };
596 
597   //! \class OBTorsion generic.h <openbabel/generic.h>
598   //! \brief Used to hold the torsion data for a single rotatable bond
599   //! and all four atoms around it
600   class OBAPI OBTorsion
601   {
602     friend class OBMol;
603     friend class OBTorsionData;
604 
605   protected:
606     std::pair<OBAtom*,OBAtom*> _bc;
607     //! double is angle in radians
608     std::vector<triple<OBAtom*,OBAtom*,double> > _ads;
609 
OBTorsion()610     OBTorsion(): _bc((OBAtom *)nullptr, (OBAtom *)nullptr)      {      }
611     //protected for use only by friend classes
612     OBTorsion(OBAtom *, OBAtom *, OBAtom *, OBAtom *);
613 
614     std::vector<quad<OBAtom*,OBAtom*,OBAtom*,OBAtom*> > GetTorsions();
615 
616   public:
617     OBTorsion(const OBTorsion &);
~OBTorsion()618     ~OBTorsion()      {}
619 
620     OBTorsion& operator=(const OBTorsion &);
621 
622     void Clear();
Empty()623     bool Empty()    {      return(_bc.first == 0 && _bc.second == 0);    }
624 
625     bool AddTorsion(OBAtom *a,OBAtom *b, OBAtom *c,OBAtom *d);
626     bool AddTorsion(quad<OBAtom*,OBAtom*,OBAtom*,OBAtom*> &atoms);
627 
628     bool SetAngle(double radians, unsigned int index = 0);
SetData(OBBond *)629     bool SetData(OBBond * /*bond*/) { return false; }
630 
631     bool GetAngle(double &radians, unsigned int index =0);
632     //! Gets the bond index of the central bond
633     //! \return int bond index
634     unsigned int GetBondIdx();
GetSize()635     size_t GetSize() const    {      return _ads.size();    }
636 
637     //! Gets the two central atoms of ABCD torsion
638     //!   \return pair<OBAtom*,OBAtom*>
GetBC()639     std::pair<OBAtom*,OBAtom*>                  GetBC()
640       {
641         return(_bc);
642       }
643     //! Gets the vector of distal atoms of ABCD torsion
644     //! \return vector of A,D atom pointers and a double
GetADs()645     std::vector<triple<OBAtom*,OBAtom*,double> > GetADs()
646     {
647       return(_ads) ;
648     }
649 
650     bool IsProtonRotor();
651   };
652 
653   //! \class OBTorsionData generic.h <openbabel/generic.h>
654   //! \brief Used to hold torsions as generic data for OBMol.
655   //!
656   //! Filled by OBMol::FindTorsions()
657  class OBAPI OBTorsionData : public OBGenericData
658   {
659     friend class OBMol;
660 
661   protected:
662     std::vector<OBTorsion> _torsions;
663 
664     OBTorsionData();
665     OBTorsionData(const OBTorsionData &);
666 
667   public:
668     OBTorsionData &operator=(const OBTorsionData &);
669 
670     //! \todo Needs to be updated to rebase atom pointers (or use indexes)
Clone(OBBase *)671     virtual OBGenericData* Clone(OBBase* /*parent*/) const
672     {return new OBTorsionData(*this);}
673 
674     void Clear();
675 
676     //! Gets a vector of the OBTorsion objects
677     //! \return the vector of torsions
GetData()678     std::vector<OBTorsion> GetData() const
679       {
680         return _torsions;
681       }
682 
683     //! Gets the number of torsion structs
684     //! \return integer count of the number of torsions
GetSize()685     size_t      GetSize() const
686     {
687       return _torsions.size();
688     }
689 
690     void SetData(OBTorsion &torsion);
691 
692     bool FillTorsionArray(std::vector<std::vector<unsigned int> > &torsions);
693   };
694 
695   //! \class OBAngle generic.h <openbabel/generic.h>
696   //! \brief Used to hold the 3 atoms in an angle and the angle itself
697   class OBAPI OBAngle
698   {
699     friend class OBMol;
700     friend class OBAngleData;
701 
702   protected:
703 
704     //member data
705 
706     OBAtom                *_vertex;
707     std::pair<OBAtom*,OBAtom*>  _termini;
708     double                  _radians;
709 
710     //protected member functions
711 
712     OBAngle();	//protect constructor for use only by friend classes
713     OBAngle(OBAtom *vertex,OBAtom *a,OBAtom *b);
714 
715     triple<OBAtom*,OBAtom*,OBAtom*> GetAtoms();
716     void SortByIndex();
717 
718   public:
719 
720     OBAngle(const OBAngle &);
~OBAngle()721     ~OBAngle()
722       {
723         _vertex = nullptr;
724       }
725 
726     OBAngle &operator = (const OBAngle &);
727     bool     operator ==(const OBAngle &);
728 
729     void  Clear();
730 
731     //! Gets the OBAngle angle value
732     //! \return angle in radians
GetAngle()733     double GetAngle() const
734     {
735       return(_radians);
736     }
737     //! Sets the OBAngle to @p radians
738     //! \param angle in radians
SetAngle(double angle)739     void  SetAngle(double angle)
740     {
741       _radians = angle;
742     }
743     void  SetAtoms(OBAtom *vertex,OBAtom *a,OBAtom *b);
744     void  SetAtoms(triple<OBAtom*,OBAtom*,OBAtom*> &atoms);
745 
746   };
747 
748   //! \class OBAngleData generic.h <openbabel/generic.h>
749   //! \brief Used to hold all angles in a molecule as generic data for OBMol
750  class OBAPI OBAngleData : public OBGenericData
751   {
752     friend class OBMol;
753 
754   protected:
755     std::vector<OBAngle> _angles;
756 
757     OBAngleData();
758     OBAngleData(const OBAngleData &);
759     //! Gets the angle vector data
760     /** \return a vector<OBAngle> **/
GetData()761     std::vector<OBAngle> GetData() const
762       {
763         return(_angles);
764       }
765 
766   public:
767     OBAngleData &operator =(const OBAngleData &);
Clone(OBBase *)768     virtual OBGenericData* Clone(OBBase* /*parent*/) const
769     {return new OBAngleData(*this);}
770 
771     void Clear();
772     unsigned int FillAngleArray(int **angles, unsigned int &size);
773     bool FillAngleArray(std::vector<std::vector<unsigned int> > &angles);
774 
775     void         SetData(OBAngle &);
776     //! Gets the number of angles stored
777     //! \return integer count of the number of angles
GetSize()778     size_t GetSize() const
779     {
780       return _angles.size();
781     }
782   };
783 
784 
785   //! \class OBSerialNums generic.h <openbabel/generic.h>
786   //! \brief Defines a map between serial numbers (e.g., in a PDB file) and OBAtom objects inside a molecule
787  class OBSerialNums : public OBGenericData
788   {
789   protected:
790     std::map<int, OBAtom*> _serialMap; //!< map between serial num
791 
792   public:
793 
OBSerialNums()794   OBSerialNums() :
795     OBGenericData("obSerialNums", OBGenericDataType::SerialNums)
796       {}
797 
OBSerialNums(const OBSerialNums & cp)798   OBSerialNums(const OBSerialNums &cp) : OBGenericData(cp)
799     {
800       _serialMap = cp._serialMap;
801     }
802     //! Member variables contain OBAtom pointers, so copying only valid within
803     //! same molecule, unless the code is modified, as in OBRotamerList
Clone(OBBase *)804     virtual OBGenericData* Clone(OBBase* /*parent*/) const
805     {return new OBSerialNums(*this);}
806 
GetData()807     std::map<int,OBAtom*> &GetData()    { return _serialMap;    }
SetData(std::map<int,OBAtom * > & sm)808     void SetData(std::map<int,OBAtom*> &sm) { _serialMap = sm;  }
809 
810   };
811 
812   //! \class OBVibrationData generic.h <openbabel/generic.h>
813   //! \brief Used to hold the normal modes of a molecule, etc.
814  class OBAPI OBVibrationData: public OBGenericData
815   {
816   protected:
817     //! Normal modes in 1/sqrt(a.u.)
818     std::vector< std::vector< vector3 > > _vLx;
819 
820     //! Harmonic frequencies in inverse centimeters
821     std::vector<double>  _vFrequencies;
822 
823     //! Infrared absorption intensities in KM/Mole
824     std::vector<double>  _vIntensities;
825 
826     //! Raman activities
827     std::vector<double>  _vRamanActivities;
828 
829   public:
OBVibrationData()830     OBVibrationData(): OBGenericData("VibrationData", OBGenericDataType::VibrationData){};
~OBVibrationData()831     virtual ~OBVibrationData() {}
Clone(OBBase *)832     virtual OBGenericData* Clone(OBBase*) const
833          {return new OBVibrationData(*this);}
834 
835     OBVibrationData & operator=(const OBVibrationData &);
836 
837     void SetData(const std::vector< std::vector< vector3 > > & lx,
838                  const std::vector<double> & frequencies,
839                  const std::vector<double> & intensities);
840     void SetData(const std::vector< std::vector< vector3 > > &,
841                  const std::vector<double> &,
842                  const std::vector<double> &,
843                  const std::vector<double> &);
844 
GetLx()845     std::vector< std::vector< vector3 > > GetLx() const
846       { return this->_vLx; }
GetFrequencies()847     std::vector<double> GetFrequencies() const
848       { return this->_vFrequencies; }
GetIntensities()849     std::vector<double> GetIntensities() const
850       { return this->_vIntensities; }
GetRamanActivities()851     std::vector<double> GetRamanActivities() const
852       { return this->_vRamanActivities; }
853 
854     unsigned int GetNumberOfFrequencies() const;
855 };
856 
857   //! \class OBDOSData generic.h <openbabel/generic.h>
858   //! \brief Used to hold density of states information
859  class OBAPI OBDOSData: public OBGenericData
860   {
861   protected:
862     //! Fermi energy (eV) as shown in _vEnergies
863     double _fermi;
864 
865     //! Energy levels (eV)
866     std::vector<double>  _vEnergies;
867 
868     //! Density of corresponding energy level (number of states / unit cell)
869     std::vector<double>  _vDensities;
870 
871     //! Integrated DOS vector
872     std::vector<double>  _vIntegration;
873 
874   public:
OBDOSData()875     OBDOSData(): OBGenericData("DOSData", OBGenericDataType::DOSData){};
~OBDOSData()876     virtual ~OBDOSData() {}
Clone(OBBase *)877     virtual OBGenericData* Clone(OBBase*) const
878          {return new OBDOSData(*this);}
879 
880     OBDOSData & operator=(const OBDOSData &);
881 
882     void SetData(double,
883                  const std::vector<double> &,
884                  const std::vector<double> &,
885                  const std::vector<double> &);
886 
GetFermiEnergy()887     double GetFermiEnergy() const
888       { return this->_fermi; }
GetEnergies()889     std::vector<double> GetEnergies() const
890       { return this->_vEnergies; }
GetDensities()891     std::vector<double> GetDensities() const
892       { return this->_vDensities; }
GetIntegration()893     std::vector<double> GetIntegration() const
894       { return this->_vIntegration; }
895   };
896 
897   //! \class OBOrbital generic.h <openbabel/generic.h>
898   //! \brief Used to store energy, occupation, and orbital symmetry of a particular orbital
899   //! \sa OBOrbitalData
900   class OBAPI OBOrbital
901   {
902     friend class OBOrbitalData;
903   protected:
904     double       _energy;         //!< in electron volts
905     double       _occupation;     //!< usually 0, 1, or 2, but can be fractional (e.g., solid-state calcs)
906     std::string  _mullikenSymbol; //!< symmetry designation
907   public:
908     void SetData(double energy, double occupation = 2.0, std::string symbol = "A")
909     { _energy = energy; _occupation = occupation; _mullikenSymbol = symbol; }
910 
GetEnergy()911     double GetEnergy() const        { return _energy; }
GetOccupation()912     double GetOccupation() const    { return _occupation; }
GetSymbol()913     std::string GetSymbol() const   { return _mullikenSymbol; }
914   };
915 
916   //! \class OBOrbitalData generic.h <openbabel/generic.h>
917   //! \brief Used to hold information about orbital energies
918   class OBAPI OBOrbitalData: public OBGenericData
919   {
920   public:
OBOrbitalData()921     OBOrbitalData(): OBGenericData("OrbitalData", OBGenericDataType::ElectronicData),
922       _alphaHOMO(0), _betaHOMO(0), _openShell(false) {};
~OBOrbitalData()923     virtual ~OBOrbitalData() {}
Clone(OBBase *)924     virtual OBGenericData* Clone(OBBase*) const
925          {return new OBOrbitalData(*this);}
926 
927     OBOrbitalData & operator=(const OBOrbitalData &);
928 
SetAlphaOrbitals(std::vector<OBOrbital> orbitalList)929     void SetAlphaOrbitals(std::vector<OBOrbital> orbitalList)
930     { _alphaOrbitals = orbitalList; }
SetBetaOrbitals(std::vector<OBOrbital> orbitalList)931     void SetBetaOrbitals(std::vector<OBOrbital> orbitalList)
932     { _betaOrbitals = orbitalList; }
933     void SetHOMO(int alpha, int beta = 0)
934     { _alphaHOMO = alpha; _betaHOMO = beta; }
SetOpenShell(bool openShell)935     void SetOpenShell(bool openShell)
936     { _openShell = openShell; }
937 
IsOpenShell()938     bool IsOpenShell() { return _openShell; }
939 
GetAlphaHOMO()940     unsigned int GetAlphaHOMO() { return _alphaHOMO; }
GetBetaHOMO()941     unsigned int GetBetaHOMO() { return _betaHOMO; }
GetAlphaOrbitals()942     std::vector<OBOrbital> GetAlphaOrbitals() { return _alphaOrbitals; }
GetBetaOrbitals()943     std::vector<OBOrbital> GetBetaOrbitals() { return _betaOrbitals; }
944 
945     //! \brief Convenience function for common cases of closed-shell calculations -- pass the energies and symmetries
946     //! This method will fill the OBOrbital objects for you
947     void LoadClosedShellOrbitals(std::vector<double> energies, std::vector<std::string> symmetries, unsigned int alphaHOMO);
948     //! \brief Convenience function to load alpha orbitals in an open-shell calculation
949     void LoadAlphaOrbitals(std::vector<double> energies, std::vector<std::string> symmetries, unsigned int alphaHOMO);
950     //! \brief Convenience function to load beta orbitals in an open-shell calculation
951     void LoadBetaOrbitals(std::vector<double> energies, std::vector<std::string> symmetries, unsigned int betaHOMO);
952 
953   protected:
954     std::vector<OBOrbital> _alphaOrbitals; //!< List of orbitals. In case of unrestricted calculations, this contains the alpha spin-orbitals
955     std::vector<OBOrbital> _betaOrbitals;  //!< Only used if needed (e.g., unrestricted calculations)
956     unsigned int _alphaHOMO;               //!< Highest occupied molecular orbital for _alphaOrbitals
957     unsigned int _betaHOMO;                //!< Highest occupied for _betaOrbitals (if needed)
958     bool _openShell;                       //!< Whether we store both alpha and beta spin-orbitals (i.e., a restricted open-shell or unrestricted calc.)
959   };
960 
961   //! \class OBElectronicTransitionData generic.h <openbabel/generic.h>
962   //! \brief Used to hold information about electronic transitions
963  class OBAPI OBElectronicTransitionData: public OBGenericData
964   {
965   protected:
966     //! Wavelengths (nm)
967     std::vector<double>  _vWavelengths;
968 
969     //! Oscillator strengths
970     std::vector<double>  _vForces;
971 
972     //! Electric dipole strengths
973     std::vector<double>  _vEDipole;
974 
975     //! Rotatory strengths (velocity)
976     std::vector<double>  _vRotatoryStrengthsVelocity;
977 
978     //! Rotatory strengths (length)
979     std::vector<double>  _vRotatoryStrengthsLength;
980 
981   public:
OBElectronicTransitionData()982     OBElectronicTransitionData(): OBGenericData("ElectronicTransitionData", OBGenericDataType::ElectronicTransitionData) {}
~OBElectronicTransitionData()983     virtual ~OBElectronicTransitionData() {}
Clone(OBBase *)984     virtual OBGenericData* Clone(OBBase*) const
985          {return new OBElectronicTransitionData(*this);}
986 
987     OBElectronicTransitionData & operator=(const OBElectronicTransitionData &);
988 
989     void SetData(const std::vector<double> & wavelengths,
990                  const std::vector<double> & forces);
991 
992     void SetEDipole(const std::vector<double> &);
993     void SetRotatoryStrengthsVelocity(const std::vector<double> &);
994     void SetRotatoryStrengthsLength(const std::vector<double> &);
995 
GetWavelengths()996     std::vector<double> GetWavelengths() const
997       { return this->_vWavelengths; }
GetForces()998     std::vector<double> GetForces() const
999       { return this->_vForces; }
GetEDipole()1000     std::vector<double> GetEDipole() const
1001       { return this->_vEDipole; }
GetRotatoryStrengthsVelocity()1002     std::vector<double> GetRotatoryStrengthsVelocity() const
1003       { return this->_vRotatoryStrengthsVelocity; }
GetRotatoryStrengthsLength()1004     std::vector<double> GetRotatoryStrengthsLength() const
1005       { return this->_vRotatoryStrengthsLength; }
1006 };
1007 
1008   //! \class OBRotationData generic.h <openbabel/generic.h>
1009   //! \brief Used to hold the rotational constants and symmetry numbers
1010  class OBAPI OBRotationData: public OBGenericData
1011  {
1012  public:
1013    enum RType{UNKNOWN, ASYMMETRIC, SYMMETRIC, LINEAR};
OBRotationData()1014    OBRotationData(): OBGenericData("RotationData", OBGenericDataType::RotationData){}
~OBRotationData()1015    virtual ~OBRotationData(){};
Clone(OBBase *)1016    virtual OBGenericData* Clone(OBBase*) const
1017          {return new OBRotationData(*this);}
SetData(RType RotorType,std::vector<double> RotationalConstants,int SymmetryNumber)1018    void SetData(RType RotorType, std::vector<double> RotationalConstants, int SymmetryNumber)
1019    {
1020      RotConsts = RotationalConstants;
1021      type = RotorType;
1022      SymNum = SymmetryNumber;
1023    }
1024 
1025    /// \return Rotational constants in GHz
GetRotConsts()1026    std::vector<double> GetRotConsts()const{ return RotConsts; }
1027 
GetSymmetryNumber()1028    int GetSymmetryNumber()const{ return SymNum; }
GetRotorType()1029    RType GetRotorType()const   { return type; }
1030 
1031  protected:
1032    std::vector<double> RotConsts;//!< Rotational constants in GHz
1033    int                 SymNum;   //!< Rotational Symmetry Number
1034    RType               type;     //!< linear, symmetric or asymmetric top
1035  };
1036 
1037   //! \class OBVectorData generic.h <openbabel/generic.h>
1038   //! \brief Used to hold a 3D vector item (e.g., a dipole moment)
1039   //! \since version 2.2
1040  class OBAPI OBVectorData: public OBGenericData
1041  {
1042  public:
OBVectorData()1043    OBVectorData(): OBGenericData("VectorData", OBGenericDataType::VectorData){}
~OBVectorData()1044    virtual ~OBVectorData(){};
Clone(OBBase *)1045    virtual OBGenericData* Clone(OBBase*) const
1046          {return new OBVectorData(*this);}
SetData(double x,double y,double z)1047    void SetData(double x, double y, double z)
1048      { _vec = vector3(x, y, z); }
SetData(vector3 data)1049    void SetData(vector3 data)
1050      { _vec = data; }
GetData()1051    vector3 GetData() const
1052      { return _vec; }
1053 
1054  protected:
1055    vector3            _vec; //!< 3D vector to be stored
1056  };
1057 
1058    //! \class OBMatrixData generic.h <openbabel/generic.h>
1059    //! \brief Used to hold a 3x3 matrix item (e.g., a quadrupole moment)
1060    //! \since version 2.2
1061   class OBAPI OBMatrixData: public OBGenericData
1062   {
1063   public:
OBMatrixData()1064     OBMatrixData(): OBGenericData("MatrixData", OBGenericDataType::MatrixData){}
~OBMatrixData()1065     virtual ~OBMatrixData(){};
Clone(OBBase *)1066     virtual OBGenericData* Clone(OBBase*) const
1067           {return new OBMatrixData(*this);}
SetData(matrix3x3 data)1068     void SetData(matrix3x3 data)
1069       { _matrix = data; }
GetData()1070     matrix3x3 GetData() const
1071       { return _matrix; }
1072 
1073   protected:
1074     matrix3x3            _matrix; //!< 3x3 matrix to be stored
1075   };
1076 
1077   //! \class OBFreeGridPoint generic.h <openbabel/generic.h>
1078   //! \brief Helper class for OBFreeGrid
1079   //! Can hold a random coordinate and associated value.
1080   class OBAPI OBFreeGridPoint
1081   {
1082   protected:
1083     double _x,_y,_z,_V;
1084 
1085   public:
OBFreeGridPoint()1086     OBFreeGridPoint() {};
OBFreeGridPoint(double x,double y,double z,double V)1087     OBFreeGridPoint(double x,double y,double z,double V) { _x = x; _y = y; _z = z; _V = V; }
~OBFreeGridPoint()1088     ~OBFreeGridPoint() {};
GetX()1089     double GetX() { return _x; }
GetY()1090     double GetY() { return _y; }
GetZ()1091     double GetZ() { return _z; }
GetV()1092     double GetV() { return _V; }
SetX(double x)1093     void SetX(double x) { _x = x; }
SetY(double y)1094     void SetY(double y) { _y = y; }
SetZ(double z)1095     void SetZ(double z) { _z = z; }
SetV(double V)1096     void SetV(double V) { _V = V; }
1097   };
1098 
1099   //! A standard iterator over a vector of FreeGridPoints
1100   typedef std::vector<OBFreeGridPoint*>::iterator OBFreeGridPointIterator;
1101 
1102   //! \class OBFreeGrid generic.h <openbabel/generic.h>
1103   //! \brief Handle double precision floating point data with coordinates not on a grid
1104   //! Can hold array of random coordinates and associated values.
1105   class OBAPI OBFreeGrid: public OBGenericData
1106   {
1107   protected:
1108     std::vector<OBFreeGridPoint*> _points;  //!< coordinates with accompanying float values
1109   public:
1110 
OBFreeGrid()1111     OBFreeGrid()
1112     {
1113     }
1114 
~OBFreeGrid()1115     ~OBFreeGrid()
1116     {
1117       //delete _points;
1118     }
1119 
NumPoints()1120     int NumPoints()
1121     {
1122       return (int)_points.size();
1123     }
1124 
AddPoint(double x,double y,double z,double V)1125     void AddPoint(double x,double y,double z, double V)
1126     {
1127       _points.push_back(new OpenBabel::OBFreeGridPoint(x,y,z,V));
1128     }
1129 
BeginPoints()1130     OBFreeGridPointIterator BeginPoints()
1131     {
1132       return _points.begin();
1133     }
1134 
EndPoints()1135     OBFreeGridPointIterator EndPoints()
1136     {
1137       return _points.begin() + NumPoints();
1138     }
1139 
BeginPoint(OBFreeGridPointIterator & i)1140     OBFreeGridPoint *BeginPoint(OBFreeGridPointIterator &i)
1141     {
1142       i = _points.begin();
1143       return((i == _points.end()) ? (OBFreeGridPoint*)nullptr : (OBFreeGridPoint*)*i);
1144     }
1145 
NextPoint(OBFreeGridPointIterator & i)1146     OBFreeGridPoint *NextPoint(OBFreeGridPointIterator &i)
1147     {
1148       ++i;
1149       return((i == _points.end()) ? (OBFreeGridPoint*)nullptr : (OBFreeGridPoint*)*i);
1150     }
1151 
1152     void Clear();
1153 
1154   };
1155 
1156   class OBAPI OBPcharge: public OBGenericData
1157   {
1158   protected:
1159     std::vector<double> _PartialCharge;
1160   public:
OBPcharge()1161     OBPcharge(){};
~OBPcharge()1162     ~OBPcharge(){};
1163 
NumPartialCharges()1164     int NumPartialCharges()
1165     {
1166       return (int)_PartialCharge.size();
1167     }
1168 
AddPartialCharge(std::vector<double> q)1169     void AddPartialCharge(std::vector<double> q)
1170     {
1171       _PartialCharge = q;
1172     }
1173 
GetPartialCharge()1174     std::vector<double> GetPartialCharge()
1175     {
1176         return _PartialCharge;
1177     }
1178   };
1179 
1180  //! A standard iterator over vectors of OBGenericData (e.g., inherited from OBBase)
1181   typedef std::vector<OBGenericData*>::iterator OBDataIterator;
1182 
1183 } //end namespace OpenBabel
1184 
1185 #endif // OB_GENERIC_H
1186 
1187 //! \file generic.h
1188 //! \brief Handle generic data classes. Custom data for atoms, bonds, etc.
1189