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

void org::openscience::cdk::layout::RingPlacer::placeBridgedRing ( IRing  ring,
IAtomContainer  sharedAtoms,
Point2d  sharedAtomsCenter,
Vector2d  ringCenterVector,
double  bondLength 
) [inline, private]

Generated coordinates for a given ring, which is connected to another ring a bridged ring, i.e. it shares more than two atoms with another ring.

Parameters:
ringThe ring to be placed
sharedAtomsThe atoms of this ring, also members of another ring, which are already placed
sharedAtomsCenterThe geometric center of these atoms
ringCenterVectorA vector pointing the the center of the new ring
bondLengthThe standard bondlength

Definition at line 193 of file RingPlacer.java.

References org::openscience::cdk::interfaces::IAtomContainer::contains(), org::openscience::cdk::tools::LoggingTool::debug(), org::openscience::cdk::geometry::GeometryTools::getAngle(), org::openscience::cdk::interfaces::IAtomContainer::getAtomCount(), org::openscience::cdk::interfaces::IAtomContainer::getAtomNumber(), org::openscience::cdk::interfaces::IAtomContainer::getBond(), org::openscience::cdk::interfaces::IAtomContainer::getBondCount(), getBridgeAtoms(), org::openscience::cdk::interfaces::IBond::getConnectedAtom(), getNativeRingRadius(), org::openscience::cdk::interfaces::IRing::getNextBond(), org::openscience::cdk::interfaces::IAtom::getPoint2d(), org::openscience::cdk::interfaces::IRing::getRingSize(), org::openscience::cdk::layout::AtomPlacer::listNumbers(), and org::openscience::cdk::layout::AtomPlacer::populatePolygonCorners().

Referenced by placeRing().

      {
            double radius = getNativeRingRadius(ring, bondLength);
            Point2d ringCenter = new Point2d(sharedAtomsCenter);
            ringCenterVector.normalize();
            logger.debug("placeBridgedRing->: ringCenterVector.length()" + ringCenterVector.length());      
            ringCenterVector.scale(radius);
            ringCenter.add(ringCenterVector);


            IAtom[] bridgeAtoms = getBridgeAtoms(sharedAtoms);
            IAtom bondAtom1 = bridgeAtoms[0];
            IAtom bondAtom2 = bridgeAtoms[1];

            Vector2d bondAtom1Vector = new Vector2d(bondAtom1.getPoint2d());
            Vector2d bondAtom2Vector = new Vector2d(bondAtom2.getPoint2d());        
            Vector2d originRingCenterVector = new Vector2d(ringCenter);       

            bondAtom1Vector.sub(originRingCenterVector);
            bondAtom2Vector.sub(originRingCenterVector);          

            double occupiedAngle = bondAtom1Vector.angle(bondAtom2Vector);          
            
            double remainingAngle = (2 * Math.PI) - occupiedAngle;
            double addAngle = remainingAngle / (ring.getRingSize() - sharedAtoms.getAtomCount() + 1);

            logger.debug("placeBridgedRing->occupiedAngle: " + Math.toDegrees(occupiedAngle));
            logger.debug("placeBridgedRing->remainingAngle: " + Math.toDegrees(remainingAngle));

            logger.debug("placeBridgedRing->addAngle: " + Math.toDegrees(addAngle));                        


            IAtom startAtom;

            double centerX = ringCenter.x;
            double centerY = ringCenter.y;
            
            double xDiff = bondAtom1.getPoint2d().x - bondAtom2.getPoint2d().x;
            double yDiff = bondAtom1.getPoint2d().y - bondAtom2.getPoint2d().y;
            
            double startAngle;
            
            int direction = 1;
            // if bond is vertical
            if (xDiff == 0)
            {
                  logger.debug("placeBridgedRing->Bond is vertical");
                  //starts with the lower Atom
                  if (bondAtom1.getPoint2d().y > bondAtom2.getPoint2d().y)
                  {
                        startAtom = bondAtom1;
                  }
                  else
                  {
                        startAtom = bondAtom2;
                  }
                  
                  //changes the drawing direction
                  if (centerX < bondAtom1.getPoint2d().x)
                  {
                        direction = 1;
                  }
                  else
                  {
                        direction = -1;
                  }
            }

              // if bond is not vertical
            else
            {
                  //starts with the left Atom
                  if (bondAtom1.getPoint2d().x > bondAtom2.getPoint2d().x)
                  {
                        startAtom = bondAtom1;
                  }
                  else
                  {
                        startAtom = bondAtom2;
                  }
                  
                  //changes the drawing direction
                  if (centerY - bondAtom1.getPoint2d().y > (centerX - bondAtom1.getPoint2d().x) * yDiff / xDiff)
                  {
                        direction = 1;
                  }
                  else
                  {
                        direction = -1;
                  }
            }
            startAngle = GeometryTools.getAngle(startAtom.getPoint2d().x - ringCenter.x, startAtom.getPoint2d().y - ringCenter.y);

            IAtom currentAtom = startAtom;
        // determine first bond in Ring
        int k = 0;
//        for (k = 0; k < ring.getElectronContainerCount(); k++) {
//            if (ring.getElectronContainer(k) instanceof IBond) break;
//        }
        IBond currentBond = sharedAtoms.getBond(0);
            Vector atomsToDraw = new Vector();
            for (int i = 0; i < ring.getBondCount(); i++)
            {
                  currentBond = ring.getNextBond(currentBond, currentAtom);
                  currentAtom = currentBond.getConnectedAtom(currentAtom);
                  if (!sharedAtoms.contains(currentAtom))
                  {
                        atomsToDraw.addElement(currentAtom);
                  }
            }
                  try
                  {
                        logger.debug("placeBridgedRing->atomsToPlace: " + atomPlacer.listNumbers(molecule, atomsToDraw));
                        logger.debug("placeBridgedRing->startAtom is: " + (molecule.getAtomNumber(startAtom) + 1));
                        logger.debug("placeBridgedRing->startAngle: " + Math.toDegrees(startAngle));
                        logger.debug("placeBridgedRing->addAngle: " + Math.toDegrees(addAngle));            
                  }
                  catch(Exception exc)
                  {
                        logger.debug("Caught an exception while logging in RingPlacer");
                  }
            
            addAngle = addAngle * direction;
            atomPlacer.populatePolygonCorners(atomsToDraw, ringCenter, startAngle, addAngle, radius);
      }

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