checkpoint
[anneal.git] / src / edu / berkeley / qfat / Mesh.java
index 951f53a..d5e0db2 100644 (file)
@@ -6,6 +6,7 @@ import javax.swing.*;
 import javax.media.opengl.*;
 import javax.media.opengl.glu.*;
 import edu.berkeley.qfat.geom.*;
+import edu.berkeley.qfat.geom.HasBindingGroup;
 import edu.wlu.cs.levy.CG.KDTree;
 import edu.berkeley.qfat.geom.Point;
 import com.infomatiq.jsi.IntProcedure;
@@ -165,7 +166,7 @@ public class Mesh implements Iterable<Mesh.T> {
 
             for(Vertex p : (Iterable<Vertex>)getBoundPeers())
                 if (good || ignoreProblems)  p.reComputeErrorAround();
-                else                              p.transform(p.oldp, true);
+                else                         p.transform(p.oldp, true);
 
             return good;
         }
@@ -305,7 +306,7 @@ public class Mesh implements Iterable<Mesh.T> {
     }
 
     /** [UNIQUE] an edge */
-    public final class E implements Comparable<E> {
+    public final class E extends HasBindingGroup implements Comparable<E> {
 
         public final Vertex p1, p2;
         T t;     // triangle to our "left"
@@ -318,6 +319,16 @@ public class Mesh implements Iterable<Mesh.T> {
 
         public boolean intersects(T t) { return t.intersects(p1.p, p2.p); }
 
+        public void bindingGroupChanged(edu.berkeley.qfat.geom.BindingGroup newBindingGroup_) {
+            edu.berkeley.qfat.geom.BindingGroup<E> newBindingGroup = (edu.berkeley.qfat.geom.BindingGroup<E>)newBindingGroup_;
+            if (newBindingGroup==null) return;
+            if (this==newBindingGroup.getMaster()) return;
+            for(E eother : (Iterable<E>)newBindingGroup) {
+                this.next.bindTo(newBindingGroup.getMatrix(eother), eother.next);
+                this.prev.bindTo(newBindingGroup.getMatrix(eother), eother.prev);
+            }
+        }
+
         public float stretchRatio() {
             Vertex nearest = error_against.nearest(midpoint());
             float nearest_distance = midpoint().distance(nearest.p);
@@ -327,8 +338,6 @@ public class Mesh implements Iterable<Mesh.T> {
             return nearest_distance/other_distance;
         }
         public float comparator() {
-            
-
             return length();
             //return t==null?0:(1/t.aspect());
         }