Loading...
Searching...
No Matches
OBMolPairIter Class Reference

`#include <openbabel/obiter.h>`

## Public Member Functions

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

## Detailed Description

Iterate over all pairs of atoms (>1-4) in an OBMol.

Since
  version 2.1.

To facilitate iteration through all pairs of atoms in a molecule, without resorting to bond indexes (which may change in the future), a variety of iterators are provided. These pairs of atoms are separated by 4 atoms or more (i.e., these are non-bonded interactions).

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

\#define FOR_PAIRS_OF_MOL(p,m) for( OBMolPairIter p(m); p; p++ )
OpenBabel::OBMolPairIter::OBMolPairIter
OBMolPairIter()
Definition obiter.h:352
FOR_PAIRS_OF_MOL
#define FOR_PAIRS_OF_MOL(p, m)
Definition obiter.h:410

Here is an example:

#include <openbabel/obiter.h>
#include <openbabel/mol.h>
OpenBabel::OBMol mol;
OpenBabel::OBAtom *a, *b;
double rab;
FOR_PAIRS_OF_MOL(p, mol)
{
// The variable b behaves like OBBond* when used with -> and * but
// but needs to be explicitly converted when appearing as a parameter
// in a function call - use &*p
a = mol.GetAtom(p->first);
b = mol.GetAtom(p->second);
rab = a->GetDistance(b);
}
OpenBabel::OBAtom
Atom class.
Definition atom.h:72
OpenBabel::OBAtom::GetDistance
double GetDistance(int index)
Definition atom.cpp:1119
OpenBabel::OBMol
Molecule Class.
Definition mol.h:121
OpenBabel::OBMol::GetAtom
OBAtom * GetAtom(int idx) const
Definition mol.cpp:830
mol.h
Handle molecules. Declarations of OBMol, OBAtom, OBBond, OBResidue. (the main header for Open Babel).
obiter.h
STL-style iterators for Open Babel.

## Constructor & Destructor Documentation

## OBMolPairIter() [1/4]

OBMolPairIter | ( |  | ) |

inline

Referenced by OBMolPairIter(), operator++(), and operator=().

## OBMolPairIter() [2/4]

OBMolPairIter | ( | OBMol * | mol | ) |

## OBMolPairIter() [3/4]

OBMolPairIter | ( | OBMol & | mol | ) |

## OBMolPairIter() [4/4]

OBMolPairIter | ( | const OBMolPairIter & | ai | ) |

## ~OBMolPairIter()

~OBMolPairIter | ( |  | ) |

inline

## Member Function Documentation

## operator=()

OBMolPairIter & operator= | ( | const OBMolPairIter & | ai | ) |

## operator bool()

operator bool | ( |  | ) | const

inline

Returns
  Whether the iterator can still advance (i.e., visit more 1-4 atom pairs)

## operator++()

OBMolPairIter & operator++ | ( |  | ) |

Preincrement – advance to the next 1-4 atom pair and return.

## operator*()

std::vector< unsigned int > operator* | ( |  | ) | const

inline

Returns
  A vector of two atom indexes specifying the 1-4 atom pair

See also
  OBAtom::GetIdx()

The documentation for this class was generated from the following files:

- obiter.h
- obiter.cpp