public String toString() { return "<"+x+","+y+","+z+">"; }
}
+ public class BindingGroup {
+ public HashSet<E> es = new HashSet<E>();
+ public BindingGroup() { }
+ public merge(E e) {
+ if (e.bg != null) merge(e.bg);
+ else { es.add(e); e.bg = this; }
+ }
+ public merge(BindingGroup bg) {
+ for(E e : bg.es) {
+ e.bg = this;
+ this.bg.add(e);
+ }
+ }
+ }
+
/** [UNIQUE] an edge */
public final class E {
public final P p1, p2;
E next; // next half-edge
E pair; // partner half-edge
+
+ public BindingGroup bg = null;
+
+ public void bind(E e) { bind(e, new M()); }
+ public void bind(E e, M m) {
+ if (e.bg != null) e.bg.merge(this);
+ else if (bg != null) bg.merge(e);
+ else {
+ bg = new BindingGroup();
+ bg.merge(this);
+ bg.merge(e);
+ }
+ }
+
+ public void dobind() {
+ if (bg==null) return;
+ for(E ex : bg.es) {
+ if (ex==this) continue;
+ 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() {
this.prev.next = this;
this.next.prev = this;
public final E e1;
public final int color;
- public void bind(T t2, int rot) {
- // FIXME
- }
-
T(E e1) {
this.e1 = e1;
E e2 = e1.next;