checkpoint
[anneal.git] / src / edu / berkeley / qfat / Mesh.java
index edd82d6..fa6b80f 100644 (file)
@@ -354,8 +354,12 @@ public class Mesh implements Iterable<Mesh.T> {
         public void bindEdge(E e) { bind_to.add(e); }
         public void dobind() { bind_to.dobind(this); }
 
-        public Point shatter() { return shatter(midpoint(), null, null, true); }
+        public Point shatter() { return shatter(true); }
+        public Point shatter(boolean triangles) { return shatter(midpoint(), null, null, triangles); }
         public Point shatter(Point mid, BindingGroup bg1, BindingGroup bg2, boolean triangles) {
+            return shatter(mid, bg1, bg2, triangles, false);
+        }
+        public Point shatter(Point mid, BindingGroup bg1, BindingGroup bg2, boolean triangles, boolean leader) {
             if (shattered || destroyed) return mid;
             shattered = true;
 
@@ -369,6 +373,10 @@ public class Mesh implements Iterable<Mesh.T> {
             BindingGroup old_bind_to = bind_to;
             bind_peers.shatter(bg1, bg2, triangles);
             old_bind_to.shatter(bg2.other(), bg1.other(), triangles);
+            if (!triangles) {
+                next.shatter(false);
+                prev.shatter(false);
+            }
             pair.shatter();
             destroy();
 
@@ -377,6 +385,7 @@ public class Mesh implements Iterable<Mesh.T> {
                 newT(r.p, mid, p2.p, null, old_colorclass);
                 bg1.add(p1.getE(mid));
                 bg2.add(p2.getE(mid).pair);
+                if (leader) p1.getE(mid).shatter();
             }
             return mid;
         }