checkpoint
[anneal.git] / src / edu / berkeley / qfat / Mesh.java
index fa6b80f..951f53a 100644 (file)
@@ -78,8 +78,6 @@ public class Mesh implements Iterable<Mesh.T> {
         public Point p, oldp, goodp;
         E e;                // some edge *leaving* this point
 
-        Matrix binding = Matrix.ONE;
-        Vertex bound_to = this;
         private boolean illegal = false;
 
         public Point getPoint() { return p; }
@@ -161,11 +159,14 @@ public class Mesh implements Iterable<Mesh.T> {
 
         public boolean move(Matrix m, boolean ignoreProblems) {
             boolean good = true;
-            for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
+
+            for(Vertex p : (Iterable<Vertex>)getBoundPeers())
                 good &= p.transform(m.times(p.p), ignoreProblems);
-            for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to)
+
+            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;
         }
 
@@ -260,24 +261,7 @@ public class Mesh implements Iterable<Mesh.T> {
             return norm.norm();
         }
 
-        public boolean isBoundTo(Vertex p) {
-            for(Vertex px = p; px!=null; px=(px.bound_to==p?null:px.bound_to))
-                if (px==this)
-                    return true;
-            return false;
-        }
-
-        public void unbind() { bound_to = this; binding = Matrix.ONE; }
-        public void bind(Vertex p) { bind(p, Matrix.ONE); }
-        public void bind(Vertex p, Matrix binding) {
-            if (isBoundTo(p)) return;
-            Vertex temp_bound_to = p.bound_to;
-            Matrix temp_binding = p.binding;
-            p.bound_to = this.bound_to;
-            p.binding = binding.times(this.binding); // FIXME: may have order wrong here
-            this.bound_to = temp_bound_to;
-            this.binding = temp_binding.times(temp_binding); // FIXME: may have order wrong here
-        }
+        public void bindTo(Vertex p) { bindTo(Matrix.ONE, p); }
     }
 
     public class BindingGroup {
@@ -309,8 +293,8 @@ public class Mesh implements Iterable<Mesh.T> {
         }
         public void dobind(E e) {
             for(E ebound : set) {
-                e.p1.bind(ebound.p2);
-                e.p2.bind(ebound.p1);
+                e.p1.bindTo(Matrix.ONE, ebound.p2);
+                e.p2.bindTo(Matrix.ONE, ebound.p1);
             }
         }
         public void shatter(BindingGroup bg1, BindingGroup bg2, boolean triangles) {
@@ -606,6 +590,9 @@ public class Mesh implements Iterable<Mesh.T> {
         public void reinsert() { triangles.remove(this); triangles.add(this); }
 
         public boolean shouldBeDrawn() {
+            if (e1().bind_to==null) return false;
+            if (e2().bind_to==null) return false;
+            if (e3().bind_to==null) return false;
             if (e1().bind_to.set.size() == 0) return false;
             if (e2().bind_to.set.size() == 0) return false;
             if (e3().bind_to.set.size() == 0) return false;