checkpoint
[anneal.git] / src / edu / berkeley / qfat / Mesh.java
index 02f589e..68e9c23 100644 (file)
@@ -313,9 +313,9 @@ public class Mesh implements Iterable<Mesh.T> {
                 e.p2.bind(ebound.p1);
             }
         }
-        public void shatter(BindingGroup bg1, BindingGroup bg2) {
+        public void shatter(BindingGroup bg1, BindingGroup bg2, boolean triangles) {
             for(E e : set) {
-                e.shatter(e.midpoint(), bg1, bg2);
+                e.shatter(e.midpoint(), bg1, bg2, triangles);
             }
         }
     }
@@ -354,8 +354,9 @@ 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); }
-        public Point shatter(Point mid, BindingGroup bg1, BindingGroup bg2) {
+        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) {
             if (shattered || destroyed) return mid;
             shattered = true;
 
@@ -367,15 +368,21 @@ public class Mesh implements Iterable<Mesh.T> {
             if (bg1==null) bg1 = new BindingGroup();
             if (bg2==null) bg2 = new BindingGroup();
             BindingGroup old_bind_to = bind_to;
-            bind_peers.shatter(bg1, bg2);
-            old_bind_to.shatter(bg2.other(), bg1.other());
+            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();
 
-            newT(r.p, p1.p, mid, null, old_colorclass);
-            newT(r.p, mid, p2.p, null, old_colorclass);
-            bg1.add(p1.getE(mid));
-            bg2.add(p2.getE(mid).pair);
+            if (triangles) {
+                newT(r.p, p1.p, mid, null, old_colorclass);
+                newT(r.p, mid, p2.p, null, old_colorclass);
+                bg1.add(p1.getE(mid));
+                bg2.add(p2.getE(mid).pair);
+            }
             return mid;
         }