Open Babel  3.0
Public Member Functions | List of all members
OBMolPairIter Class Reference

#include <openbabel/obiter.h>

Public Member Functions

 OBMolPairIter ()
 
 OBMolPairIter (OBMol *mol)
 
 OBMolPairIter (OBMol &mol)
 
 OBMolPairIter (const OBMolPairIter &ai)
 
 ~OBMolPairIter ()
 
OBMolPairIteroperator= (const OBMolPairIter &ai)
 
 operator bool () const
 
OBMolPairIteroperator++ ()
 
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++ )

Here is an example:

#include <openbabel/mol.h>
double rab;
{
// 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);
}

Constructor & Destructor Documentation

◆ OBMolPairIter() [1/4]

OBMolPairIter ( )
inline

◆ 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: