public static void removeElectronContainer(IChemModel chemModel, IElectronContainer electrons)
        {
            ICrystal crystal = chemModel.Crystal;

            if (crystal != null)
            {
                if (crystal.contains(electrons))
                {
                    crystal.removeElectronContainer(electrons);
                }
                return;
            }
            ISetOfMolecules moleculeSet = chemModel.SetOfMolecules;

            if (moleculeSet != null)
            {
                SetOfMoleculesManipulator.removeElectronContainer(moleculeSet, electrons);
            }
            ISetOfReactions reactionSet = chemModel.SetOfReactions;

            if (reactionSet != null)
            {
                SetOfReactionsManipulator.removeElectronContainer(reactionSet, electrons);
            }
        }
        public static void removeAtomAndConnectedElectronContainers(IChemModel chemModel, IAtom atom)
        {
            ICrystal crystal = chemModel.Crystal;

            if (crystal != null)
            {
                if (crystal.contains(atom))
                {
                    crystal.removeAtomAndConnectedElectronContainers(atom);
                }
                return;
            }
            ISetOfMolecules moleculeSet = chemModel.SetOfMolecules;

            if (moleculeSet != null)
            {
                SetOfMoleculesManipulator.removeAtomAndConnectedElectronContainers(moleculeSet, atom);
            }
            ISetOfReactions reactionSet = chemModel.SetOfReactions;

            if (reactionSet != null)
            {
                SetOfReactionsManipulator.removeAtomAndConnectedElectronContainers(reactionSet, atom);
            }
        }
        public static IReaction getRelevantReaction(IChemModel chemModel, IAtom atom)
        {
            IReaction reaction = null;

            if (chemModel.SetOfReactions != null)
            {
                ISetOfReactions reactionSet = chemModel.SetOfReactions;
                reaction = SetOfReactionsManipulator.getRelevantReaction(reactionSet, atom);
            }
            return(reaction);
        }
        /// <summary> Returns all the AtomContainer's of a ChemModel.</summary>
        public static IAtomContainer[] getAllAtomContainers(IChemModel chemModel)
        {
            ISetOfMolecules moleculeSet = chemModel.Builder.newSetOfMolecules();

            if (chemModel.SetOfMolecules != null)
            {
                moleculeSet.add(chemModel.SetOfMolecules);
            }
            if (chemModel.SetOfReactions != null)
            {
                moleculeSet.add(SetOfReactionsManipulator.getAllMolecules(chemModel.SetOfReactions));
            }
            return(SetOfMoleculesManipulator.getAllAtomContainers(moleculeSet));
        }
 public static void setAtomProperties(IChemModel chemModel, System.Object propKey, System.Object propVal)
 {
     if (chemModel.SetOfMolecules != null)
     {
         SetOfMoleculesManipulator.setAtomProperties(chemModel.SetOfMolecules, propKey, propVal);
     }
     if (chemModel.SetOfReactions != null)
     {
         SetOfReactionsManipulator.setAtomProperties(chemModel.SetOfReactions, propKey, propVal);
     }
     if (chemModel.Crystal != null)
     {
         AtomContainerManipulator.setAtomProperties(chemModel.Crystal, propKey, propVal);
     }
 }
        public static IAtomContainer getRelevantAtomContainer(IChemModel chemModel, IBond bond)
        {
            IAtomContainer result = null;

            if (chemModel.SetOfMolecules != null)
            {
                ISetOfMolecules moleculeSet = chemModel.SetOfMolecules;
                result = SetOfMoleculesManipulator.getRelevantAtomContainer(moleculeSet, bond);
                if (result != null)
                {
                    return(result);
                }
            }
            if (chemModel.SetOfReactions != null)
            {
                ISetOfReactions reactionSet = chemModel.SetOfReactions;
                return(SetOfReactionsManipulator.getRelevantAtomContainer(reactionSet, bond));
            }
            // This should never happen.
            return(null);
        }
        public static int getBondCount(IChemModel chemModel)
        {
            int      count   = 0;
            ICrystal crystal = chemModel.Crystal;

            if (crystal != null)
            {
                count += crystal.getBondCount();
            }
            ISetOfMolecules moleculeSet = chemModel.SetOfMolecules;

            if (moleculeSet != null)
            {
                count += SetOfMoleculesManipulator.getBondCount(moleculeSet);
            }
            ISetOfReactions reactionSet = chemModel.SetOfReactions;

            if (reactionSet != null)
            {
                count += SetOfReactionsManipulator.getBondCount(reactionSet);
            }
            return(count);
        }
        /// <summary> Puts all the Molecules of this container together in one
        /// AtomContainer.
        ///
        /// </summary>
        /// <returns>  The AtomContainer with all the Molecules of this container
        ///
        /// </returns>
        /// <deprecated> This method has a serious performace impact. Try to use
        /// other methods.
        /// </deprecated>
        public static IAtomContainer getAllInOneContainer(IChemModel chemModel)
        {
            IAtomContainer container = chemModel.Builder.newAtomContainer();
            ICrystal       crystal   = chemModel.Crystal;

            if (crystal != null)
            {
                container.add(crystal);
            }
            ISetOfMolecules moleculeSet = chemModel.SetOfMolecules;

            if (moleculeSet != null)
            {
                container.add(SetOfMoleculesManipulator.getAllInOneContainer(moleculeSet));
            }
            ISetOfReactions reactionSet = chemModel.SetOfReactions;

            if (reactionSet != null)
            {
                container.add(SetOfReactionsManipulator.getAllInOneContainer(reactionSet));
            }
            return(container);
        }
        public static System.Collections.IList getAllChemObjects(IChemModel chemModel)
        {
            System.Collections.ArrayList list = new System.Collections.ArrayList();
            list.Add(chemModel);
            ICrystal crystal = chemModel.Crystal;

            if (crystal != null)
            {
                list.Add(crystal);
            }
            ISetOfMolecules moleculeSet = chemModel.SetOfMolecules;

            if (moleculeSet != null)
            {
                list.AddRange(SetOfMoleculesManipulator.getAllChemObjects(moleculeSet));
            }
            ISetOfReactions reactionSet = chemModel.SetOfReactions;

            if (reactionSet != null)
            {
                list.AddRange(SetOfReactionsManipulator.getAllChemObjects(reactionSet));
            }
            return(list);
        }