checkpoint
authoradam <adam@megacz.com>
Sun, 6 Jul 2008 21:53:19 +0000 (14:53 -0700)
committeradam <adam@megacz.com>
Sun, 6 Jul 2008 21:53:19 +0000 (14:53 -0700)
darcs-hash:20080706215319-5007d-0d67f3a5c45e022225525bb570b4671599ec3934.gz

src/edu/berkeley/qfat/Mesh.java

index 1998b4b..45ddf31 100644 (file)
@@ -158,34 +158,10 @@ public class Mesh implements Iterable<Mesh.T> {
             e.flip();
             System.out.println("flip!");
             i++;
-            //if (i>2) break;
         }
 
         System.out.println("count="+count);
 
-        /*
-        tris.clear();
-        for (T t : this) if (t.v1().edge && t.v2().edge && t.v3().edge) tris.add(t);
-        for (T t : tris)
-            t.shatter();
-        */
-
-        /*
-        for(Vertex v : verts) {
-            if (!v.face) continue;
-            v.move(v.recenter().minus(v.getPoint()), false);
-        }
-        */
-        /*
-        Queue<T> q = new LinkedList<T>();
-        OUTER: while(true) {
-            for (T t : this) {
-                if (t.old) { t.shatter(); continue OUTER; }
-            }
-            break;
-        }
-        */
-
         rebindPoints();
         HashSet<Vertex> verts = new HashSet<Vertex>();
         for(Vertex v : vertices()) verts.add(v);
@@ -212,7 +188,28 @@ public class Mesh implements Iterable<Mesh.T> {
         }
         for (Vertex v : verts)
             v.grantWish();
-
+        System.out.println("-------------------------------------------------------------------");
+        /*
+        for (Vertex v : verts) {
+            if (v.original) {
+                int n=0;
+                for(E e = v.e; e!=null; e=e.pair.next==v.e?null:e.pair.next) {
+                    n++;
+                    v.wish(e.midpoint());
+                    v.wish(e.midpoint());
+                    v.wish(e.next.pair.t.centroid());
+                }
+                v.avgWish();
+                v.wishes = 3;
+                for(int j=0; j<n-3; j++)
+                    v.wish(v.getPoint());
+            }
+        }
+        for (Vertex v : verts)
+            v.avgWish();
+        for (Vertex v : verts)
+            v.grantWish();
+        */
     }
 
     // Vertexices //////////////////////////////////////////////////////////////////////////////
@@ -238,6 +235,7 @@ public class Mesh implements Iterable<Mesh.T> {
         public void grantWish() {
             for(Vertex v : (Iterable<Vertex>)getBoundPeers()) {
                 if (v==this) continue;
+                if (v.wishes==0) continue;
                 Point p = this.getBindingMatrix(v).times(v.wish.minus(Point.ZERO).div(v.wishes).plus(Point.ZERO));
                 wish = p.minus(Point.ZERO).times(v.wishes).plus(wish);
                 wishes += v.wishes;
@@ -248,6 +246,11 @@ public class Mesh implements Iterable<Mesh.T> {
             move(d, false);
             clearWish();
         }
+        public void avgWish() {
+            if (wishes==0) return;
+            wish = wish.minus(Point.ZERO).div(wishes).plus(Point.ZERO);
+            wishes = 1;
+        }
 
         private boolean illegal = false;
 
@@ -406,8 +409,8 @@ public class Mesh implements Iterable<Mesh.T> {
             if (bindingGroup != null) {
                 /*
                 for(int i=0; i<20 ; i++) {
-                    Point p2 = getConstraint().times(pp);
-                    pp = pp.midpoint(p2);
+                    Point v2 = getConstraint().times(pp);
+                    pp = pp.midpoint(v2);
                     //System.out.println(m.minus(m2));
                 }
             */