Exemplo n.º 1
0
 /// <summary> Rebonding using a Binary Space Partition Tree. Note, that any bonds
 /// defined will be deleted first. It assumes the unit of 3D space to
 /// be 1 &Acircle;ngstrom.
 /// </summary>
 public virtual void rebond(IAtomContainer container)
 {
     container.removeAllBonds();
     maxCovalentRadius = 0.0;
     // construct a new binary space partition tree
     bspt = new Bspt(3);
     IAtom[] atoms = container.Atoms;
     for (int i = atoms.Length; --i >= 0; )
     {
         IAtom atom = atoms[i];
         double myCovalentRadius = atom.CovalentRadius;
         if (myCovalentRadius == 0.0)
         {
             //throw new CDKException("Atom(s) does not have covalentRadius defined.");
         }
         else
         {
             if (myCovalentRadius > maxCovalentRadius)
                 maxCovalentRadius = myCovalentRadius;
             TupleAtom tupleAtom = new TupleAtom(atom);
             bspt.addTuple(tupleAtom);
         }
     }
     // rebond all atoms
     for (int i = atoms.Length; --i >= 0; )
     {
         bondAtom(container, atoms[i]);
     }
 }
Exemplo n.º 2
0
 public EnumerateSphere(Bspt bspt, Bspt.Tuple center, double distance, bool tHemisphere)
 {
     this.bspt        = bspt;
     this.distance    = distance;
     this.distance2   = distance * distance;
     this.center      = center;
     this.tHemisphere = tHemisphere;
     centerValues     = new double[bspt.dimMax];
     for (int dim = bspt.dimMax; --dim >= 0;)
     {
         centerValues[dim] = center.getDimValue(dim);
     }
     stack = new Node[Bspt.stackDepth];
     sp    = 0;
     Bspt.Element ele = bspt.eleRoot;
     while (ele is Node)
     {
         Node node = (Node)ele;
         if (center.getDimValue(node.dim) - distance <= node.splitValue)
         {
             if (sp == Bspt.stackDepth)
             {
                 System.Console.Out.WriteLine("Bspt.EnumerateSphere tree stack overflow");
             }
             stack[sp++] = node;
             ele         = node.eleLE;
         }
         else
         {
             ele = node.eleGE;
         }
     }
     leaf = (Leaf)ele;
     i    = 0;
 }
Exemplo n.º 3
0
 public RebondTool(double maxCovalentRadius, double minBondDistance, double bondTolerance)
 {
     this.maxCovalentRadius = maxCovalentRadius;
     this.bondTolerance = bondTolerance;
     this.minBondDistance = minBondDistance;
     this.bspt = null;
 }
Exemplo n.º 4
0
 public RebondTool(double maxCovalentRadius, double minBondDistance, double bondTolerance)
 {
     this.maxCovalentRadius = maxCovalentRadius;
     this.bondTolerance     = bondTolerance;
     this.minBondDistance   = minBondDistance;
     this.bspt = null;
 }
Exemplo n.º 5
0
            public EnumerateNear(Bspt bspt, Bspt.Tuple center, double distance)
            {
                this.distance = distance;
                this.center   = center;

                stack = new Node[Bspt.stackDepth];
                sp    = 0;
                Bspt.Element ele = bspt.eleRoot;
                while (ele is Node)
                {
                    Node node = (Node)ele;
                    if (center.getDimValue(node.dim) - distance <= node.splitValue)
                    {
                        if (sp == Bspt.stackDepth)
                        {
                            System.Console.Out.WriteLine("Bspt.EnumerateNear tree stack overflow");
                        }
                        stack[sp++] = node;
                        ele         = node.eleLE;
                    }
                    else
                    {
                        ele = node.eleGE;
                    }
                }
                leaf = (Leaf)ele;
                i    = 0;
            }
Exemplo n.º 6
0
 /// <summary> Rebonding using a Binary Space Partition Tree. Note, that any bonds
 /// defined will be deleted first. It assumes the unit of 3D space to
 /// be 1 &Acircle;ngstrom.
 /// </summary>
 public virtual void rebond(IAtomContainer container)
 {
     container.removeAllBonds();
     maxCovalentRadius = 0.0;
     // construct a new binary space partition tree
     bspt = new Bspt(3);
     IAtom[] atoms = container.Atoms;
     for (int i = atoms.Length; --i >= 0;)
     {
         IAtom  atom             = atoms[i];
         double myCovalentRadius = atom.CovalentRadius;
         if (myCovalentRadius == 0.0)
         {
             //throw new CDKException("Atom(s) does not have covalentRadius defined.");
         }
         else
         {
             if (myCovalentRadius > maxCovalentRadius)
             {
                 maxCovalentRadius = myCovalentRadius;
             }
             TupleAtom tupleAtom = new TupleAtom(atom);
             bspt.addTuple(tupleAtom);
         }
     }
     // rebond all atoms
     for (int i = atoms.Length; --i >= 0;)
     {
         bondAtom(container, atoms[i]);
     }
 }
Exemplo n.º 7
0
 public EnumerateAll(Bspt bspt)
 {
     stack = new Node[Bspt.stackDepth];
     sp    = 0;
     Bspt.Element ele = bspt.eleRoot;
     while (ele is Node)
     {
         Node node = (Node)ele;
         if (sp == Bspt.stackDepth)
         {
             System.Console.Out.WriteLine("Bspt.EnumerateAll tree stack overflow");
         }
         stack[sp++] = node;
         ele         = node.eleLE;
     }
     leaf = (Leaf)ele;
     i    = 0;
 }
Exemplo n.º 8
0
 public bool addTuple(Bspt.Tuple tuple)
 {
     if (tuple.getDimValue(dim) < splitValue)
     {
         if (eleLE.addTuple(tuple))
             return true;
         eleLE = new Node((dim + 1) % dimMax, dimMax, (Leaf)eleLE);
         return eleLE.addTuple(tuple);
     }
     if (tuple.getDimValue(dim) > splitValue)
     {
         if (eleGE.addTuple(tuple))
             return true;
         eleGE = new Node((dim + 1) % dimMax, dimMax, (Leaf)eleGE);
         return eleGE.addTuple(tuple);
     }
     if (eleLE.LeafWithSpace)
         eleLE.addTuple(tuple);
     else if (eleGE.LeafWithSpace)
         eleGE.addTuple(tuple);
     else if (eleLE is Node)
         eleLE.addTuple(tuple);
     else if (eleGE is Node)
         eleGE.addTuple(tuple);
     else
     {
         eleLE = new Node((dim + 1) % dimMax, dimMax, (Leaf)eleLE);
         return eleLE.addTuple(tuple);
     }
     return true;
 }
Exemplo n.º 9
0
 public bool addTuple(Bspt.Tuple tuple)
 {
     if (count == Bspt.leafCount)
         return false;
     tuples[count++] = tuple;
     return true;
 }
Exemplo n.º 10
0
 public EnumerateSphere(Bspt bspt, Bspt.Tuple center, double distance, bool tHemisphere)
 {
     this.bspt = bspt;
     this.distance = distance;
     this.distance2 = distance * distance;
     this.center = center;
     this.tHemisphere = tHemisphere;
     centerValues = new double[bspt.dimMax];
     for (int dim = bspt.dimMax; --dim >= 0; )
         centerValues[dim] = center.getDimValue(dim);
     stack = new Node[Bspt.stackDepth];
     sp = 0;
     Bspt.Element ele = bspt.eleRoot;
     while (ele is Node)
     {
         Node node = (Node)ele;
         if (center.getDimValue(node.dim) - distance <= node.splitValue)
         {
             if (sp == Bspt.stackDepth)
                 System.Console.Out.WriteLine("Bspt.EnumerateSphere tree stack overflow");
             stack[sp++] = node;
             ele = node.eleLE;
         }
         else
         {
             ele = node.eleGE;
         }
     }
     leaf = (Leaf)ele;
     i = 0;
 }
Exemplo n.º 11
0
 private bool isWithin(Bspt.Tuple t)
 {
     double dist2;
     double distT;
     distT = t.getDimValue(0) - centerValues[0];
     if (tHemisphere && distT < 0)
     {
         return false;
     }
     dist2 = distT * distT;
     if (dist2 > distance2)
     {
         return false;
     }
     for (int dim = bspt.dimMax; --dim > 0; )
     {
         distT = t.getDimValue(dim) - centerValues[dim];
         dist2 += distT * distT;
         if (dist2 > distance2)
         {
             return false;
         }
     }
     this.foundDistance2_Renamed_Field = dist2;
     return true;
 }
Exemplo n.º 12
0
 public EnumerateSphere enumHemiSphere(Bspt.Tuple center, double distance)
 {
     return new EnumerateSphere(this, center, distance, true);
 }
Exemplo n.º 13
0
            public EnumerateNear(Bspt bspt, Bspt.Tuple center, double distance)
            {
                this.distance = distance;
                this.center = center;

                stack = new Node[Bspt.stackDepth];
                sp = 0;
                Bspt.Element ele = bspt.eleRoot;
                while (ele is Node)
                {
                    Node node = (Node)ele;
                    if (center.getDimValue(node.dim) - distance <= node.splitValue)
                    {
                        if (sp == Bspt.stackDepth)
                            System.Console.Out.WriteLine("Bspt.EnumerateNear tree stack overflow");
                        stack[sp++] = node;
                        ele = node.eleLE;
                    }
                    else
                    {
                        ele = node.eleGE;
                    }
                }
                leaf = (Leaf)ele;
                i = 0;
            }
Exemplo n.º 14
0
 public IEnumerator enumNear(Bspt.Tuple center, double distance)
 {
     return new EnumerateNear(this, center, distance);
 }
Exemplo n.º 15
0
 public EnumerateAll(Bspt bspt)
 {
     stack = new Node[Bspt.stackDepth];
     sp = 0;
     Bspt.Element ele = bspt.eleRoot;
     while (ele is Node)
     {
         Node node = (Node)ele;
         if (sp == Bspt.stackDepth)
             System.Console.Out.WriteLine("Bspt.EnumerateAll tree stack overflow");
         stack[sp++] = node;
         ele = node.eleLE;
     }
     leaf = (Leaf)ele;
     i = 0;
 }
Exemplo n.º 16
0
 public void addTuple(Bspt.Tuple tuple)
 {
     if (!eleRoot.addTuple(tuple))
     {
         eleRoot = new Node(0, dimMax, (Leaf)eleRoot);
         if (!eleRoot.addTuple(tuple))
             System.Console.Out.WriteLine("Bspt.addTuple() failed");
     }
 }