float myBondingRadius = atom.getBondingRadiusFloat();
if (myBondingRadius == 0)
continue;
float searchRadius = myBondingRadius + maxBondingRadius + bondTolerance;
initializeBspt(modelIndex);
CubeIterator iter = bspf.getCubeIterator(modelIndex);
iter.initialize(atom, searchRadius, true);
while (iter.hasMoreElements()) {
Atom atomNear = (Atom) iter.nextElement();
if (atomNear == atom || atomNear.isDeleted())
continue;
int atomIndexNear = atomNear.index;
boolean isNearInSetA = (bsA == null || bsA.get(atomIndexNear));
boolean isNearInSetB = (bsB == null || bsB.get(atomIndexNear));
if (!isNearInSetA && !isNearInSetB || bsExclude != null
&& bsExclude.get(atomIndexNear) && bsExclude.get(i) //this line forces BOTH to be excluded in order to ignore bonding
)
continue;
if (!(isAtomInSetA && isNearInSetB || isAtomInSetB && isNearInSetA))
continue;
short order = getBondOrder(myBondingRadius, atomNear
.getBondingRadiusFloat(), iter.foundDistance2(), minBondDistance2,
bondTolerance);
if (order > 0) {
if (checkValencesAndBond(atom, atomNear, order, mad, bsBonds))
nNew++;
}
}
iter.release();
}
if (showRebondTimes && Logger.debugging)
Logger.checkTimer("Time to autoBond");
return nNew;
}