You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
dstoeckel edited this page Mar 16, 2015
·
2 revisions
How can I iterate over all atom pairs in an AtomContainer ?
Iterating over all atom pairs of an AtomContainer using the BALL_FOREACH_ATOM_PAIR-macro:
#include<BALL/KERNEL/forEach.h>usingnamespaceBALL;
...
AtomContainer ac;
AtomIterator ait1, ait2;
BALL_FOREACH_ATOM_PAIR(ac, ait1, ait2)
{
// Compute the distance of the current atom pairfloat dist = ait1->getPosition().getDistance(ait2->getPosition());
// Print the distance
std::cout << dist << "" << ait1->getFullName() << "" << ait2->getFullName() << std::endl;
}
Note: Using a simple nested AtomIterator-BondIterator-construction will consider each atom-pair twice!
Note: Never try to add or remove atoms from the AtomContainer while running over it! Your programm will crash!
Note: the BALL_FOREACH_ATOM_PAIR-macro gets an AtomContainer. BALL-objects, that can be runtime-cast to an AtomContainer are for example
a Chain, a Residue, a Molecule, a Protein, or a System.