Skip to content
Permalink
Browse files

only delete non-multibond H's; fixes JCP issue 8

Change-Id: Ibddcc47a411b087a08a2c184318b05e99650f79d
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
rwst authored and egonw committed Aug 8, 2012
1 parent 81d7be7 commit d0d785c54dad162cb5e3492c3f2c793707613dc2
Showing with 11 additions and 6 deletions.
  1. +11 −6 src/main/org/openscience/cdk/layout/StructureDiagramGenerator.java
@@ -260,14 +260,19 @@ public void generateExperimentalCoordinates(Vector2d firstBondVector) throws CDK
// first make a shallow copy: Atom/Bond references are kept
IMolecule original = molecule;
IMolecule shallowCopy = molecule.getBuilder().newInstance(IMolecule.class,molecule);
// ok, delete H's from
// delete single-bonded H's from
//IAtom[] atoms = shallowCopy.getAtoms();
for (int i = 0; i < shallowCopy.getAtomCount(); i++) {
IAtom curAtom = shallowCopy.getAtom(i);
if (curAtom.getSymbol().equals("H")) {
shallowCopy.removeAtomAndConnectedElectronContainers(curAtom);
curAtom.setPoint2d(null);
for (IAtom curAtom : shallowCopy.atoms()) {
if (curAtom.getSymbol().equals("H")) {
int bondsFromCurAtom=0;
for (IBond bond : shallowCopy.bonds())
if(bond.contains (curAtom))
++bondsFromCurAtom;
if (bondsFromCurAtom < 2) {
shallowCopy.removeAtomAndConnectedElectronContainers(curAtom);
curAtom.setPoint2d(null);
}
}
}
// do layout on the shallow copy
molecule = shallowCopy;

0 comments on commit d0d785c

Please sign in to comment.
You can’t perform that action at this time.