OBMolAngleIter Class Reference

Iterate over all angles in an OBMol. More...

#include <openbabel/obiter.h>

List of all members.

Public Member Functions

 OBMolAngleIter ()
 OBMolAngleIter (OBMol *mol)
 OBMolAngleIter (OBMol &mol)
 OBMolAngleIter (const OBMolAngleIter &ai)
 ~OBMolAngleIter ()
OBMolAngleIteroperator= (const OBMolAngleIter &ai)
 operator bool () const
OBMolAngleIteroperator++ ()
std::vector< unsigned int > operator* () const

Detailed Description

Iterate over all angles in an OBMol.

Since:
version 2.1

To facilitate iteration through all angles in a molecule, without resorting to atom indexes (which will change in the future), a variety of iterator methods are provided.

This has been made significantly easier by a series of macros in the obiter.h header file:

      \#define FOR_ANGLES_OF_MOL(a,m)     for( OBMolAngleIter     a(m); a; a++ )

Here is an example:

      #include <openbabel/obiter.h>
      #include <openbabel/mol.h>

      OBMol mol;
      OBAtom *a, *b, *c;
      double ang;

      FOR_ANGLES_OF_MOL(angle, mol)
      {
         // The variable a behaves like OBAngle* when used with -> and * but
         // but needs to be explicitly converted when appearing as a parameter
         // in a function call - use &*a

         b = _mol.GetAtom((*angle)[0] + 1);
         a = _mol.GetAtom((*angle)[1] + 1);
         c = _mol.GetAtom((*angle)[2] + 1);
         ang = a->GetAngle(b->GetIdx(), c->GetIdx());
      }

Constructor & Destructor Documentation

OBMolAngleIter (  ) [inline]
OBMolAngleIter ( OBMol mol )
OBMolAngleIter ( OBMol mol )
OBMolAngleIter ( const OBMolAngleIter ai )
~OBMolAngleIter (  ) [inline]

Member Function Documentation

OBMolAngleIter & operator= ( const OBMolAngleIter ai )
operator bool (  ) const [inline]
Returns:
Whether the iterator can still advance (i.e., visit more angles)
OBMolAngleIter & operator++ (  )

Preincrement -- advance to the next angle and return.

std::vector<unsigned int> operator* (  ) const [inline]
Returns:
A vector of three atom indexes specifying the angle
See also:
OBAtom::GetIdx()

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines