3 using System.Collections.Generic;
19 split = 0.5f * (b0 + b1);
22 positions =
new List<Vector3>();
23 types =
new List<string>();
24 colors =
new List<Color>();
41 private Vector3
GetOffset(Vector3 b0, Vector3 b1,
int i) {
45 result = Vector3.zero;
48 result =
new Vector3(b1.x, 0, 0);
51 result =
new Vector3(0, b1.y, 0);
54 result =
new Vector3(b1.x, b1.y, 0);
57 result =
new Vector3(0, 0, b1.z);
60 result =
new Vector3(b1.x, 0, b1.z);
63 result =
new Vector3(0, b1.y, b1.z);
69 Debug.Log(
"VertexTree::Offset() > Something is very, very wrong here.");
70 result = Vector3.zero;
82 if(positions.Count >= MAX_ATOMS)
87 Vector3 oppositeBound = bound1 -
bound0;
91 for(
int i=0; i<8; i++) {
92 offset =
GetOffset(bound0, oppositeBound, i);
93 children[i] =
new AtomTree(bound0+offset, split+offset);
100 children[childIndex].
AddAtomToLeaf(positions[i], types[i], colors[i]);
112 private void AddAtom(Vector3 pos,
string type, Color col) {
119 if(positions.Count >= MAX_ATOMS)
127 children[childIndex].
AddAtom(pos, type, col);
131 return(isLeaf && positions.Count == 0);
136 float minDist =
float.MaxValue;
138 foreach(
AtomTree child
in children) {
140 dist = Vector3.SqrMagnitude(child.
split - pos);
154 float lowestDistance =
float.MaxValue;
156 for(
int i=0; i<positions.Count; i++) {
157 dist = Vector3.SqrMagnitude(pos - positions[i]);
159 if(dist < lowestDistance) {
160 lowestDistance = dist;
178 candidateCol = Color.magenta;
180 candidateDist =
float.MaxValue;
187 Debug.Log (
"isLeaf " + isLeaf);
188 Debug.Log (
"Taille colors " + colors.Count);
189 Debug.Log (
"Positions " + positions.Count);
192 for(
int i=0; i<positions.Count; i++) {
193 dist = Vector3.SqrMagnitude(pos - positions[i]);
194 if(dist < candidateDist) {
195 candidateDist = dist;
196 candidateCol = colors[i];
206 AtomTree optChild = children[childIndex];
208 foreach(
AtomTree child
in children) {
218 for(
int i=0; i<positions.Count; i++) {
219 Debug.Log(
"Type: " + types[i] +
" and position: " + positions[i].ToString());
226 foreach(
AtomTree atomTree
in children)
244 System.Diagnostics.Debug.Assert(atomModels.Count == atomLocations.Count);
246 for(
int i=0; i<atomModels.Count; i++) {
250 if(i > 0 && atomResname[i] != atomResname[i-1])
252 if(i>0 && atomChain[i] != atomChain[i-1])
256 type = atomChain[i] +
"L";
261 type = atomResname[i];
263 type = BfactorList[i].ToString();
265 type = atomsNumberList[i].ToString();
267 type = atomModels[i].type;
268 Vector3 pos =
new Vector3(atomLocations[i][0], atomLocations[i][1], atomLocations[i][2]);
272 atomTree.
AddAtom(pos, type, col);
void AddAtomToLeaf(Vector3 pos, string type, Color col)
static Color candidateCol
static List< string > atomsChainList
The chain of each atom.
static List< AtomModel > atomsTypelist
The type of each atom.
Vector3 GetOffset(Vector3 b0, Vector3 b1, int i)
static bool surfColHydroKD
void AddAtom(Vector3 pos, string type, Color col)
static float candidateDist
static List< float > BFactorList
Bfactor of each atom.
static bool surfColHydroEng
string GetClosestAtomType(Vector3 pos)
AtomTree GetOptimalChild(Vector3 pos)
List< Vector3 > positions
!WiP Includes FLAGS of GUI.
void SubGetClosestAtomColor(Vector3 pos)
static Vector3 MaxValue
The "biggest" corner of the bounding box that encloses the molecule.
static List< Color > atomsColorList
The color of each atom.
int GetChildIndex(Vector3 p)
static Vector3 MinValue
The "smallest" corner of the bounding box that encloses the molecule.
Color GetClosestAtomColor(Vector3 pos)
AtomTree(Vector3 b0, Vector3 b1)
static List< int > atomsNumberList
The number of each atoms (in the PDB file)
static List< string > atomsResnamelist
The name of the residue to which each atom belongs.
static bool surfColHydroWO
static bool surfColHydroEis
static List< float[]> atomsLocationlist
The coordinates of each atom.