checkpoint
[anneal.git] / src / edu / berkeley / qfat / Main.java
index 9ba230d..b774066 100644 (file)
@@ -80,9 +80,9 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener
     public Main(StlFile stlf) {
 
         for(int i=0; i<stlf.coordArray.length; i+=3) {
-            Mesh.Vert p0 = goal.register(new Point(stlf.coordArray[i+0].x * MAG, stlf.coordArray[i+0].y * MAG, stlf.coordArray[i+0].z * MAG));
-            Mesh.Vert p1 = goal.register(new Point(stlf.coordArray[i+1].x * MAG, stlf.coordArray[i+1].y * MAG, stlf.coordArray[i+1].z * MAG));
-            Mesh.Vert p2 = goal.register(new Point(stlf.coordArray[i+2].x * MAG, stlf.coordArray[i+2].y * MAG, stlf.coordArray[i+2].z * MAG));
+            Point p0 = new Point(stlf.coordArray[i+0].x * MAG, stlf.coordArray[i+0].y * MAG, stlf.coordArray[i+0].z * MAG);
+            Point p1 = new Point(stlf.coordArray[i+1].x * MAG, stlf.coordArray[i+1].y * MAG, stlf.coordArray[i+1].z * MAG);
+            Point p2 = new Point(stlf.coordArray[i+2].x * MAG, stlf.coordArray[i+2].y * MAG, stlf.coordArray[i+2].z * MAG);
             Vec n  = new Vec(stlf.normArray[i/3].x * MAG, stlf.normArray[i/3].y  * MAG, stlf.normArray[i/3].z * MAG);
             Mesh.T t  = goal.newT(p0, p1, p2, n);
         }
@@ -118,20 +118,20 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener
         };
 
 
-        Mesh.Vert ltf = tile.register(new Point(-(width/2),  (height/2),  (depth/2)));
-        Mesh.Vert mtf = tile.register(new Point( 0.0,        (height/2),  (depth/2)));
-        Mesh.Vert rtf = tile.register(new Point( (width/2),  (height/2),  (depth/2)));
-        Mesh.Vert ltn = tile.register(new Point(-(width/2),  (height/2), -(depth/2)));
-        Mesh.Vert mtn = tile.register(new Point( 0.0,        (height/2), -(depth/2)));
-        Mesh.Vert rtn = tile.register(new Point( (width/2),  (height/2), -(depth/2)));
-        Mesh.Vert lbf = tile.register(new Point(-(width/2), -(height/2),  (depth/2)));
-        Mesh.Vert mbf = tile.register(new Point( 0.0,       -(height/2),  (depth/2)));
-        Mesh.Vert rbf = tile.register(new Point( (width/2), -(height/2),  (depth/2)));
-        Mesh.Vert lbn = tile.register(new Point(-(width/2), -(height/2), -(depth/2)));
-        Mesh.Vert mbn = tile.register(new Point( 0.0,       -(height/2), -(depth/2)));
-        Mesh.Vert rbn = tile.register(new Point( (width/2), -(height/2), -(depth/2)));
+        Point ltf = new Point(-(width/2),  (height/2),  (depth/2));
+        Point mtf = new Point( 0.0,        (height/2),  (depth/2));
+        Point rtf = new Point( (width/2),  (height/2),  (depth/2));
+        Point ltn = new Point(-(width/2),  (height/2), -(depth/2));
+        Point mtn = new Point( 0.0,        (height/2), -(depth/2));
+        Point rtn = new Point( (width/2),  (height/2), -(depth/2));
+        Point lbf = new Point(-(width/2), -(height/2),  (depth/2));
+        Point mbf = new Point( 0.0,       -(height/2),  (depth/2));
+        Point rbf = new Point( (width/2), -(height/2),  (depth/2));
+        Point lbn = new Point(-(width/2), -(height/2), -(depth/2));
+        Point mbn = new Point( 0.0,       -(height/2), -(depth/2));
+        Point rbn = new Point( (width/2), -(height/2), -(depth/2));
         
-        points = new Mesh.Vert[] {
+        Point[] points = new Point[] {
             ltf,
             mtf,
             rtf,
@@ -184,23 +184,23 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener
                 for(Mesh.T t2 : tile) {
                     if (t1==t2) continue;
 
-                    if ((t1.p1().p.times(m).minus(t2.p1().p).mag() < Mesh.EPSILON) &&
-                        (t1.p2().p.times(m).minus(t2.p3().p).mag() < Mesh.EPSILON) &&
-                        (t1.p3().p.times(m).minus(t2.p2().p).mag() < Mesh.EPSILON)) {
+                    if ((t1.v1().p.times(m).minus(t2.v1().p).mag() < Mesh.EPSILON) &&
+                        (t1.v2().p.times(m).minus(t2.v3().p).mag() < Mesh.EPSILON) &&
+                        (t1.v3().p.times(m).minus(t2.v2().p).mag() < Mesh.EPSILON)) {
                         t1.e1().bind(t2.e3().pair);
                         t1.e2().bind(t2.e2().pair);
                         t1.e3().bind(t2.e1().pair);
                     }
-                    if ((t1.p2().p.times(m).minus(t2.p1().p).mag() < Mesh.EPSILON) &&
-                        (t1.p3().p.times(m).minus(t2.p3().p).mag() < Mesh.EPSILON) &&
-                        (t1.p1().p.times(m).minus(t2.p2().p).mag() < Mesh.EPSILON)) {
+                    if ((t1.v2().p.times(m).minus(t2.v1().p).mag() < Mesh.EPSILON) &&
+                        (t1.v3().p.times(m).minus(t2.v3().p).mag() < Mesh.EPSILON) &&
+                        (t1.v1().p.times(m).minus(t2.v2().p).mag() < Mesh.EPSILON)) {
                         t1.e2().bind(t2.e3().pair);
                         t1.e3().bind(t2.e2().pair);
                         t1.e1().bind(t2.e1().pair);
                     }
-                    if ((t1.p3().p.times(m).minus(t2.p1().p).mag() < Mesh.EPSILON) &&
-                        (t1.p1().p.times(m).minus(t2.p3().p).mag() < Mesh.EPSILON) &&
-                        (t1.p2().p.times(m).minus(t2.p2().p).mag() < Mesh.EPSILON)) {
+                    if ((t1.v3().p.times(m).minus(t2.v1().p).mag() < Mesh.EPSILON) &&
+                        (t1.v1().p.times(m).minus(t2.v3().p).mag() < Mesh.EPSILON) &&
+                        (t1.v2().p.times(m).minus(t2.v2().p).mag() < Mesh.EPSILON)) {
                         t1.e3().bind(t2.e3().pair);
                         t1.e1().bind(t2.e2().pair);
                         t1.e2().bind(t2.e1().pair);
@@ -243,7 +243,7 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener
         //double min = (tile.avgedge/tile.numedges)*(1+(4/(double)verts));
         //if (verts>0 && tile.es.peek().length() < min) return;
         PriorityQueue<Mesh.E> es = new PriorityQueue<Mesh.E>();
-        for(Mesh.E e : tile.es) es.add(e);
+        for(Mesh.E e : tile.edges()) es.add(e);
         for(int i=0; i<10; i++) {
             Mesh.E e = es.poll();
             verts++;
@@ -264,7 +264,8 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener
         r1 = r1 - (float)Math.floor(r1);
         r1 = r1 * (float)0.01;
         r1 = r1 - (float)0.005;
-        Vec v = p.watchback().p.minus(p.p).norm().times(r1);
+
+        Vec v = p.nearest_vert_in_other_mesh().minus(p.p).norm().times(r1);
 
         //v = p.norm().times(v.dot(p.norm()));
 
@@ -408,7 +409,7 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener
             */
 
             if (mesh==goal)
-                for(Mesh.Vert p : new Mesh.Vert[] { t.p1(), t.p2(), t.p3() }) {
+                for(Mesh.Vert p : new Mesh.Vert[] { t.v1(), t.v2(), t.v3() }) {
                     p.p.glVertex(gl);
                     //p.plus(p.norm().times(p.score()*10)).glVertex(gl);
                     p.partner().p.glVertex(gl);
@@ -450,7 +451,7 @@ public class Main implements GLEventListener, MouseListener, MouseMotionListener
                 glcanvas.repaint();
                 //tile.ts.get(Math.abs(random.nextInt()) % tile.ts.size()).e1().p1
                 for(Mesh.T t : tile)
-                    for(Mesh.Vert p : new Mesh.Vert[] { t.p1(), t.p2(), t.p3() }) {
+                    for(Mesh.Vert p : new Mesh.Vert[] { t.v1(), t.v2(), t.v3() }) {
                         rand(10,p);
                     }
                 goal.rescore();