From 555cf60d0cae503832f60c26ddfae643945babaf Mon Sep 17 00:00:00 2001 From: John May Date: Thu, 21 Jul 2016 21:44:08 +0100 Subject: [PATCH] When moving around positional variation ensure all atoms are moved. --- .../cdk/layout/StructureDiagramGenerator.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tool/sdg/src/main/java/org/openscience/cdk/layout/StructureDiagramGenerator.java b/tool/sdg/src/main/java/org/openscience/cdk/layout/StructureDiagramGenerator.java index 44e9a15eb41..0c7c1a145c4 100644 --- a/tool/sdg/src/main/java/org/openscience/cdk/layout/StructureDiagramGenerator.java +++ b/tool/sdg/src/main/java/org/openscience/cdk/layout/StructureDiagramGenerator.java @@ -2128,6 +2128,25 @@ private void placePositionalVariation(IAtomContainer mol) { // get all atoms connected to the part we will move Set visited = new HashSet<>(); visit(visited, adjlist, atomIdx); + + // gather up other position group + Set newvisit = new HashSet<>(); + do { + newvisit.clear(); + for (Integer idx : visited) { + IAtom visitedAtom = mol.getAtom(idx); + for (Map.Entry, IAtom> e2 : mapping.entries()) { + if (e2.getKey().contains(visitedAtom)) { + int other = idxs.get(e2.getValue()); + if (!visited.contains(other) && newvisit.add(other)) { + visit(newvisit, adjlist, other); + } + } + } + } + visited.addAll(newvisit); + } while (!newvisit.isEmpty()); + IAtomContainer frag = mol.getBuilder().newInstance(IAtomContainer.class); for (Integer visit : visited) frag.addAtom(mol.getAtom(visit));