checkpoint
[anneal.git] / src / Geom.java
index 080690e..316e334 100644 (file)
@@ -196,10 +196,38 @@ public class Geom implements Iterable<Geom.T> {
         E next;  // next half-edge
         E pair;  // partner half-edge
 
+
+        public E bound_to = this;
+
         public void bind(E e) { bind(e, new M()); }
         public void bind(E e, M m) {
-            p1.bind(e.p2);
-            p2.bind(e.p1);
+            E old = this.bound_to;
+            this.bound_to = e.bound_to;
+            e.bound_to = old;
+        }
+
+        public void dobind() {
+            for(E ex = bound_to; ex != this; ex = ex.bound_to) {
+                p1.bind(ex.p1);
+                p2.bind(ex.p2);
+            }
+        }
+
+        public boolean destroyed = false;
+        public void shatter() {
+            if (destroyed) return;
+            /*
+            HashSet<E> eh = new HashSet<E>();
+            eh.add(this);
+            for(E ex = bound_to; ex != this; ex = ex.bound_to) eh.add(ex);
+            E[] es = (E[])eh.toArray(new E[0]);
+            */
+            destroy();
+            pair.shatter();
+            for(E ex = bound_to; ex != this; ex = ex.bound_to) ex.shatter();
+        }
+        public void destroy() {
+            this.destroyed = true;
         }
 
         private void sync() {