checkpoint
authoradam <adam@megacz.com>
Wed, 5 Dec 2007 08:51:34 +0000 (00:51 -0800)
committeradam <adam@megacz.com>
Wed, 5 Dec 2007 08:51:34 +0000 (00:51 -0800)
darcs-hash:20071205085134-5007d-aa1d0a1b2a16781177d4771df94f1091d9c7898d.gz

src/edu/berkeley/qfat/Mesh.java

index 5dd2aea..0df0072 100644 (file)
@@ -319,33 +319,48 @@ public class Mesh implements Iterable<Mesh.T> {
     }
 
     public class BindingGroup {
     }
 
     public class BindingGroup {
-        private HashSet<E> ess = new HashSet<E>();
+        private HashSet<E> left = new HashSet<E>();
+        private HashSet<E> right = new HashSet<E>();
         public BindingGroup() { }
         public BindingGroup(E e) {
         public BindingGroup() { }
         public BindingGroup(E e) {
-            ess.add(e);
+            left.add(e);
         }
         public void add(E e) {
             if (e.bg != null) {
         }
         public void add(E e) {
             if (e.bg != null) {
-                for(E ex : e.bg.ess) {
-                    ex.bg = null;
-                    add(ex);
+                if (e.bg == this) return;
+                for(E ex : e.bg.left) {
+                    ex.bg = this;
+                    left.add(ex);
+                }
+                for(E ex : e.bg.right) {
+                    ex.bg = this;
+                    right.add(ex);
                 }
             } else {
                 }
             } else {
-                ess.add(e);
+                left.add(e);
                 e.bg = this;
             }
         }
         public void dobind(E e) {
                 e.bg = this;
             }
         }
         public void dobind(E e) {
-            for(E ex : ess) {
+            // assumes e is part of the "left" set
+            for(E ex : left) {
                 if (ex==e) continue;
                 e.p1.bind(ex.p1);
                 e.p2.bind(ex.p2);
             }
                 if (ex==e) continue;
                 e.p1.bind(ex.p1);
                 e.p2.bind(ex.p2);
             }
+            for(E ex : right) {
+                if (ex==e) continue;
+                e.p1.bind(ex.pair.p1);
+                e.p2.bind(ex.pair.p2);
+            }
         }
         public void shatter(BindingGroup bg1, BindingGroup bg2) {
         }
         public void shatter(BindingGroup bg1, BindingGroup bg2) {
-            for(E e : ess) {
+            for(E e : left) {
                 e.shatter(e.midpoint(), bg1, bg2);
             }
                 e.shatter(e.midpoint(), bg1, bg2);
             }
+            for(E e : right) {
+                e.shatter(e.midpoint(), bg2, bg1);  /* swap correct? */
+            }
         }
     }
 
         }
     }