Logo Search packages:      
Sourcecode: cdk version File versions  Download package

void org::openscience::cdk::layout::StructureDiagramGenerator::layoutNextRingSystem (  ) throws Exception [inline, private]

Does the layout for the next RingSystem that is connected to those parts of the molecule that have already been laid out. Finds the next ring with an unplaced ring atom and lays out this ring. Then lays out the ring substituents of this ring. Then moves and rotates the laid out ring to match the position of its attachment bond to the rest of the molecule.

java.lang.Exceptionif an error occurs

Definition at line 668 of file StructureDiagramGenerator.java.

References org::openscience::cdk::interfaces::IAtomContainer::add(), org::openscience::cdk::tools::LoggingTool::debug(), org::openscience::cdk::tools::manipulator::RingSetManipulator::getAllAtomContainers(), org::openscience::cdk::geometry::GeometryTools::getAngle(), org::openscience::cdk::interfaces::IChemObject::getBuilder(), getNextBondWithUnplacedRingAtom(), getOtherBondAtom(), org::openscience::cdk::layout::AtomPlacer::getPlacedAtoms(), org::openscience::cdk::interfaces::IAtom::getPoint2d(), getRingAtom(), getRingSystemOfAtom(), layoutRingSet(), org::openscience::cdk::layout::AtomPlacer::markNotPlaced(), org::openscience::cdk::layout::AtomPlacer::markPlaced(), org::openscience::cdk::interfaces::IChemObjectBuilder::newAtomContainer(), org::openscience::cdk::layout::RingPlacer::placeRingSubstituents(), resetUnplacedRings(), org::openscience::cdk::geometry::GeometryTools::rotate(), and org::openscience::cdk::geometry::GeometryTools::translate2D().

Referenced by generateCoordinates().

            logger.debug("Start of layoutNextRingSystem()");

            IAtomContainer tempAc = atomPlacer.getPlacedAtoms(molecule);
            logger.debug("Finding attachment bond to already placed part...");
            IBond nextRingAttachmentBond = getNextBondWithUnplacedRingAtom();
            if (nextRingAttachmentBond != null)
                  logger.debug("...bond found.");

                   * Get the chain and the ring atom that are connected to where we are comming from.
                   * Both are connected by nextRingAttachmentBond.
                  IAtom ringAttachmentAtom = getRingAtom(nextRingAttachmentBond);
                  IAtom chainAttachmentAtom = getOtherBondAtom(ringAttachmentAtom, nextRingAttachmentBond);

                   * Get ring system which ringAttachmentAtom is part of
                  IRingSet nextRingSystem = getRingSystemOfAtom(ringSystems, ringAttachmentAtom);

                   * Get all rings of nextRingSytem as one IAtomContainer
                  IAtomContainer ringSystem = tempAc.getBuilder().newAtomContainer();
                  for (Iterator containers = RingSetManipulator.getAllAtomContainers(nextRingSystem).iterator(); containers.hasNext(); )
                        ringSystem.add((IAtomContainer) containers.next());

                   * Save coordinates of ringAttachmentAtom and chainAttachmentAtom
                  Point2d oldRingAttachmentAtomPoint = ringAttachmentAtom.getPoint2d();
                  Point2d oldChainAttachmentAtomPoint = chainAttachmentAtom.getPoint2d();

                   *  Do the layout of the next ring system
                  layoutRingSet(firstBondVector, nextRingSystem);

                   *  Place all the substituents of next ring system
                  IAtomContainer placedRingSubstituents = ringPlacer.placeRingSubstituents(nextRingSystem, bondLength);

                   * Move and rotate the laid out ring system to match the geometry of the
                   * attachment bond
                  logger.debug("Computing translation/rotation of new ringset to fit old attachment bond orientation...");

                  // old placed ring atom coordinate
                  Point2d oldPoint2 = oldRingAttachmentAtomPoint;
                  // old placed substituent atom coordinate
                  Point2d oldPoint1 = oldChainAttachmentAtomPoint;

                  // new placed ring atom coordinate
                  Point2d newPoint2 = ringAttachmentAtom.getPoint2d();
                  // new placed substituent atom coordinate
                  Point2d newPoint1 = chainAttachmentAtom.getPoint2d();

                  logger.debug("oldPoint1: " + oldPoint1);
                  logger.debug("oldPoint2: " + oldPoint2);
                  logger.debug("newPoint1: " + newPoint1);
                  logger.debug("newPoint2: " + newPoint2);

                  double oldAngle = GeometryTools.getAngle(oldPoint2.x - oldPoint1.x, oldPoint2.y - oldPoint1.y);
                  double newAngle = GeometryTools.getAngle(newPoint2.x - newPoint1.x, newPoint2.y - newPoint1.y);
                  double angleDiff = oldAngle - newAngle;

                  logger.debug("oldAngle: " + oldAngle + ", newAngle: " + newAngle + "; diff = " + angleDiff);

                  Vector2d translationVector = new Vector2d(oldPoint1);
                  translationVector.sub(new Vector2d(newPoint1));

                   * Move to fit old attachment bond orientation
                  GeometryTools.translate2D(ringSystem, translationVector);

                   * Rotate to fit old attachment bond orientation
                  GeometryTools.rotate(ringSystem, oldPoint1, angleDiff);

                  logger.debug("...done translating/rotating new ringset to fit old attachment bond orientation.");
                  logger.debug("...no bond found");

            logger.debug("End of layoutNextRingSystem()");

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index