checkpoint
[anneal.git] / src / edu / berkeley / qfat / Mesh.java
index efeb89b..f96346d 100644 (file)
@@ -66,6 +66,24 @@ public class Mesh implements Iterable<Mesh.T> {
         }
     }
 
+    public void unscore() {
+        HashSet<Vert> done = new HashSet<Vert>();
+        for(T t : this)
+            for(Vert p : new Vert[] { t.v1(), t.v2(), t.v3() }) {
+                if (done.contains(p)) continue;
+                done.add(p);
+                p.unscore();
+            }
+    }
+    public void fundamental() {
+        HashSet<Vert> done = new HashSet<Vert>();
+        for(T t : this)
+            for(Vert p : new Vert[] { t.v1(), t.v2(), t.v3() }) {
+                if (done.contains(p)) continue;
+                done.add(p);
+                p.recomputeFundamentalQuadric();
+            }
+    }
     public float rescore() {
         int num = 0;
         double dist = 0;
@@ -75,6 +93,7 @@ public class Mesh implements Iterable<Mesh.T> {
                 if (done.contains(p)) continue;
                 done.add(p);
                 p.rescore();
+                
             }
         return (float)(dist/num);
     }
@@ -196,15 +215,7 @@ public class Mesh implements Iterable<Mesh.T> {
                 }
             }
 
-            /*
-            double s1, s2;
-            if (quadric_count==0) s1 = 0;
-            else                  s1 = p.distance(quadric_x/quadric_count, quadric_y/quadric_count, quadric_z/quadric_count);
-            s2 = quadric==null ? 0 : po.p.distance(quadric.p);
-            oldscore = (float)(s1 + s2);
-            */
-            oldscore = quadric.preAndPostMultiply(p);
-
+            oldscore = quadric_count == 0 ? 0 : (quadric.preAndPostMultiply(p) / quadric_count);
             score += oldscore;
         }
 
@@ -222,34 +233,11 @@ public class Mesh implements Iterable<Mesh.T> {
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }
-            fundamentalQuadric = fundamentalQuadric();
             rescore();
 
-            // recompute fundamental quadrics of all vertices sharing a face
-            E e = this.e;
-            do {
-                e.t.v1().recomputeFundamentalQuadric();
-                e.t.v2().recomputeFundamentalQuadric();
-                e.t.v3().recomputeFundamentalQuadric();
-                e = e.pair.next;
-            } while(e != this.e);
-            
-            boolean good = true;
-            /*
-            for(T t : this) {
-                for(E e = this.e; ;) {
-                    if (e.intersects(t)) { good = false; break; }
-                    e = e.pair.next;
-                    if (e == this.e) break;
-                }
-            }
-            */
-            /*
-                if (t==this.t) continue;
-                if (this.intersects(t)) good = false;
-            }
-            */
-            return good;
+            // should recompute fundamental quadrics of all vertices sharing a face, but we defer...
+            // FIXME: intersection test needed?
+            return true;
         }
         public boolean move(Vec v) {
             Matrix m = new Matrix(v);