/** * Generated coordinates for a given ring. Multiplexes to special handlers * for the different possible situations (spiro-, fusion-, bridged attachement) * * @param ring The ring to be placed * @param sharedAtoms The atoms of this ring, also members of another ring, which are already placed * @param sharedAtomsCenter The geometric center of these atoms * @param ringCenterVector A vector pointing the the center of the new ring * @param bondLength The standard bondlength */ public void placeRing(IRing ring, IAtomContainer sharedAtoms, Point2d sharedAtomsCenter, Vector2d ringCenterVector, double bondLength) { int numSharedAtoms = sharedAtoms.getAtomCount(); int numSharedBonds = sharedAtoms.getBondCount(); logger.debug("placeRing -> sharedAtomCount: " + numSharedAtoms); if (numSharedAtoms > 2 && numSharedBonds > 1) { placeBridgedRing(ring, sharedAtoms, sharedAtomsCenter, ringCenterVector, bondLength); } else if (numSharedAtoms == 2 && numSharedBonds == 1) { placeFusedRing(ring, sharedAtoms, ringCenterVector, bondLength); } else if (numSharedAtoms == 1 && numSharedBonds == 0) { placeSpiroRing(ring, sharedAtoms, sharedAtomsCenter, ringCenterVector, bondLength); } }
/** * Place ring with default start angles, using {@link #defaultAngles}. * @param ring the ring to place. * @param ringCenter center coordinates of the ring. * @param bondLength given bond length. */ public void placeRing(IRing ring, Point2d ringCenter, double bondLength) { placeRing(ring, ringCenter, bondLength, defaultAngles); }
private static double det(Point2d a, Point2d b, Point2d c) { return det(a.x, a.y, b.x, b.y, c.x, c.y); }
ringPlacer.setMolecule(sourceContainer); ringPlacer.placeRing(newRing, ringCenter, bondLength, RingPlacer.jcpAngles); } else { return chemModel.getBuilder().newInstance(IRing.class); } else { ringPlacer.setMolecule(sourceContainer); ringPlacer.placeSpiroRing(newRing, sharedAtoms, sharedAtomsCenter, ringCenterVector, bondLength);
IAtom[] bridgeAtoms = getBridgeAtoms(sharedAtoms); IAtom bondAtom1 = bridgeAtoms[0]; IAtom bondAtom2 = bridgeAtoms[1]; boolean swap = snap ? det(bondAtom1.getPoint2d(), GeometryUtil.get2DCenter(otherAtoms), bondAtom2.getPoint2d()) < 0 : det(bondAtom1.getPoint2d(), GeometryUtil.get2DCenter(otherAtoms), bondAtom2.getPoint2d()) > 0; Vector2d bondAtom2Vector = new Vector2d(bondAtom2.getPoint2d()); Point2d midPoint = getMidPoint(bondAtom1Vector, bondAtom2Vector); Point2d ringCenter = null; double radius = getNativeRingRadius(ring, bondLength); double offset = 0; ringCenterVector = getPerpendicular(bondAtom1Vector, bondAtom2Vector, new Vector2d(midPoint.x - sharedAtomsCenter.x, midPoint.y - sharedAtomsCenter.y));
if (!macro || !macroPlacer.layout(first, rs)) { Vector2d ringCenterVector = ringPlacer.getRingCenterOfFirstRing(first, firstBondVector, bondLength); ringPlacer.placeRing(first, sharedAtoms, GeometryUtil.get2DCenter(sharedAtoms), ringCenterVector, bondLength); } else { result = 2; do { if (ring.getFlag(CDKConstants.ISPLACED)) { ringPlacer.placeConnectedRings(rs, ring, RingPlacer.FUSED, bondLength); ringPlacer.placeConnectedRings(rs, ring, RingPlacer.BRIDGED, bondLength); ringPlacer.placeConnectedRings(rs, ring, RingPlacer.SPIRO, bondLength);
newRingCenterVector.set(vec); rotate(vec, RAD_30); final Point2d tempPoint = new Point2d(sharedAtomsCenter); tempPoint.add(newRingCenterVector); placeRing(connectedRing, sharedAtoms, sharedAtomsCenter, newRingCenterVector, bondLength); connectedRing.setFlag(CDKConstants.ISPLACED, true); placeConnectedRings(rs, connectedRing, handleType, bondLength);
ringPlacer.setMolecule(sourceContainer); ringPlacer.placeFusedRing(newRing, sharedAtoms, ringCenterVector, bondLength);
for (IRingSet rset : ringSystems) { if (rset.getFlag(CDKConstants.ISPLACED)) { ringPlacer.placeRingSubstituents(rset, bondLength); } else { List<IRing> placed = new ArrayList<>(); if (ringPlacer.completePartiallyPlacedRing(rset, ring, bondLength)) placed.add(ring); ringPlacer.placeConnectedRings(rset, (IRing) ring, RingPlacer.FUSED, bondLength); ringPlacer.placeConnectedRings(rset, (IRing) ring, RingPlacer.BRIDGED, bondLength); ringPlacer.placeConnectedRings(rset, (IRing) ring, RingPlacer.SPIRO, bondLength); ringPlacer.placeRingSubstituents(rset, bondLength); RingPlacer.countHetero(ringSystems); Collections.sort(ringSystems, RingPlacer.RING_COMPARATOR); ringPlacer.placeRingSubstituents(ringSystems.get(0), bondLength); } else {
ringCenterVector = getPerpendicular(pBeg, pEnd, ringCenterVector); double radius = getNativeRingRadius(ring, bondLength); double newRingPerpendicular = Math.sqrt(Math.pow(radius, 2) - Math.pow(bondLength / 2, 2)); ringCenterVector.normalize(); logger.debug("placeFusedRing->: ringCenterVector.length()" + ringCenterVector.length()); ringCenterVector.scale(newRingPerpendicular); final Point2d ringCenter = getMidPoint(pBeg, pEnd); ringCenter.add(ringCenterVector); pEnd.sub(originRingCenterVector); final double occupiedAngle = angle(pBeg, pEnd);
ringPlacer.setMolecule(sourceContainer); ringPlacer.placeSpiroRing(newRing, sharedAtoms, sharedAtomsCenter, ringCenterVector, bondLength);
ringPlacer.setMolecule(this.molecule); ringPlacer.setAtomPlacer(this.atomPlacer); macroPlacer = new MacroCycleLayout(mol); selectOrientation = afix.isEmpty();
ringPlacer.setMolecule(this.molecule); macroPlacer = new MacroCycleLayout(this.molecule); return;
IAtomContainer placedRingSubstituents = ringPlacer.placeRingSubstituents(nextRingSystem, bondLength); ringSystem.add(placedRingSubstituents); AtomPlacer.markPlaced(placedAtoms); for (IRingSet ringset : ringSystems) { for (IAtomContainer ring : ringset.atomContainers()) ringPlacer.completePartiallyPlacedRing(ringset, (IRing) ring, bondLength); if (allPlaced(ringset)) ringPlacer.placeRingSubstituents(ringset, bondLength);
ringPlacer.checkAndMarkPlaced(sssr);
IAtom[] bridgeAtoms = getBridgeAtoms(sharedAtoms); IAtom bondAtom1 = bridgeAtoms[0]; IAtom bondAtom2 = bridgeAtoms[1]; boolean swap = snap ? det(bondAtom1.getPoint2d(), GeometryUtil.get2DCenter(otherAtoms), bondAtom2.getPoint2d()) < 0 : det(bondAtom1.getPoint2d(), GeometryUtil.get2DCenter(otherAtoms), bondAtom2.getPoint2d()) > 0; Vector2d bondAtom2Vector = new Vector2d(bondAtom2.getPoint2d()); Point2d midPoint = getMidPoint(bondAtom1Vector, bondAtom2Vector); Point2d ringCenter = null; double radius = getNativeRingRadius(ring, bondLength); double offset = 0; ringCenterVector = getPerpendicular(bondAtom1Vector, bondAtom2Vector, new Vector2d(midPoint.x - sharedAtomsCenter.x, midPoint.y - sharedAtomsCenter.y));
if (!macro || !macroPlacer.layout(first, rs)) { Vector2d ringCenterVector = ringPlacer.getRingCenterOfFirstRing(first, firstBondVector, bondLength); ringPlacer.placeRing(first, sharedAtoms, GeometryUtil.get2DCenter(sharedAtoms), ringCenterVector, bondLength); } else { result = 2; do { if (ring.getFlag(CDKConstants.ISPLACED)) { ringPlacer.placeConnectedRings(rs, ring, RingPlacer.FUSED, bondLength); ringPlacer.placeConnectedRings(rs, ring, RingPlacer.BRIDGED, bondLength); ringPlacer.placeConnectedRings(rs, ring, RingPlacer.SPIRO, bondLength);
newRingCenterVector.set(vec); rotate(vec, RAD_30); final Point2d tempPoint = new Point2d(sharedAtomsCenter); tempPoint.add(newRingCenterVector); placeRing(connectedRing, sharedAtoms, sharedAtomsCenter, newRingCenterVector, bondLength); connectedRing.setFlag(CDKConstants.ISPLACED, true); placeConnectedRings(rs, connectedRing, handleType, bondLength);
ringPlacer.setMolecule(sourceContainer); ringPlacer.placeFusedRing(newRing, sharedAtoms, ringCenterVector, bondLength); if (sourceContainer.getMaximumBondOrder(bond.getAtom(0)) == IBond.Order.SINGLE && sourceContainer.getMaximumBondOrder(bond.getAtom(1)) == IBond.Order.SINGLE) {
for (IRingSet rset : ringSystems) { if (rset.getFlag(CDKConstants.ISPLACED)) { ringPlacer.placeRingSubstituents(rset, bondLength); } else { List<IRing> placed = new ArrayList<>(); if (ringPlacer.completePartiallyPlacedRing(rset, ring, bondLength)) placed.add(ring); ringPlacer.placeConnectedRings(rset, (IRing) ring, RingPlacer.FUSED, bondLength); ringPlacer.placeConnectedRings(rset, (IRing) ring, RingPlacer.BRIDGED, bondLength); ringPlacer.placeConnectedRings(rset, (IRing) ring, RingPlacer.SPIRO, bondLength); ringPlacer.placeRingSubstituents(rset, bondLength); RingPlacer.countHetero(ringSystems); Collections.sort(ringSystems, RingPlacer.RING_COMPARATOR); ringPlacer.placeRingSubstituents(ringSystems.get(0), bondLength); } else {