ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/owl/trunk/proteinstructure/Box.java
Revision: 282
Committed: Tue Aug 14 16:15:59 2007 UTC (17 years, 2 months ago) by duarte
File size: 2112 byte(s)
Log Message:
Made get_graph a bit less memory hungry, by using a float[][] instead of double[][]
Not printing warnings about missing atoms anymore
Line File contents
1 package proteinstructure;
2
3 import java.util.TreeMap;
4 import javax.vecmath.Point3d;
5 import javax.vecmath.Point3i;
6
7 public class Box {
8
9 Point3i floor;
10
11 private TreeMap<Integer,Point3d> i_pointsInBox;
12 private TreeMap<Integer,Point3d> j_pointsInBox;
13
14 public Box(Point3i floor){
15 this.floor=floor;
16 i_pointsInBox = new TreeMap<Integer, Point3d>();
17 j_pointsInBox = new TreeMap<Integer, Point3d>();
18 }
19
20 public void put_i_Point(int serial, Point3d point){
21 i_pointsInBox.put(serial, point);
22 }
23
24 public void put_j_Point(int serial, Point3d point){
25 j_pointsInBox.put(serial, point);
26 }
27
28 public void getDistancesWithinBox(float[][] distMatrix, boolean directed){ //we pass a reference to the distMatrix that we alter within this method
29 for (int i_serial:i_pointsInBox.keySet()) {
30 for (int j_serial:j_pointsInBox.keySet()) {
31 if (!directed) {
32 if (j_serial>i_serial) {
33 // this only works if previously we have made sure that atom serials are sequential from 0 to MAXATOMSERIAL
34 distMatrix[i_serial][j_serial] = (float)i_pointsInBox.get(i_serial).distance(j_pointsInBox.get(j_serial));
35 }
36 } else {
37 distMatrix[i_serial][j_serial] = (float)i_pointsInBox.get(i_serial).distance(j_pointsInBox.get(j_serial));
38 }
39 }
40 }
41
42 }
43
44 public void getDistancesToNeighborBox(Box nbBox ,float[][] distMatrix, boolean directed){
45 for (int i_serial:i_pointsInBox.keySet()){
46 for (int j_serial:nbBox.j_pointsInBox.keySet()){
47 if (!directed) {
48 if (j_serial>i_serial) {
49 // this only works if previously we have made sure that atom serials are sequential from 0 to MAXATOMSERIAL
50 if (distMatrix[i_serial][j_serial]==0.0f){ // i.e. if we haven't passed through this cell yet
51 distMatrix[i_serial][j_serial] = (float)i_pointsInBox.get(i_serial).distance(nbBox.j_pointsInBox.get(j_serial));
52 }
53 }
54 } else {
55 distMatrix[i_serial][j_serial] = (float)i_pointsInBox.get(i_serial).distance(nbBox.j_pointsInBox.get(j_serial));
56 }
57 }
58 }
59 }
60
61 // Beware, this returns only the size for i
62 public int size() {
63 return i_pointsInBox.size();
64 }
65
66 }