/// <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 Âle;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]); } }
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; }
public RebondTool(double maxCovalentRadius, double minBondDistance, double bondTolerance) { this.maxCovalentRadius = maxCovalentRadius; this.bondTolerance = bondTolerance; this.minBondDistance = minBondDistance; this.bspt = null; }
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; }
/// <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 Âle;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]); } }
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; }
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; }
public bool addTuple(Bspt.Tuple tuple) { if (count == Bspt.leafCount) return false; tuples[count++] = tuple; return true; }
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; }
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; }
public EnumerateSphere enumHemiSphere(Bspt.Tuple center, double distance) { return new EnumerateSphere(this, center, distance, true); }
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; }
public IEnumerator enumNear(Bspt.Tuple center, double distance) { return new EnumerateNear(this, center, distance); }
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; }
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"); } }