+ public final int serial = max_serial++;
+ public boolean occluded;
+
+ public Point shatter() {
+ if (destroyed) return null;
+ E e = e1();
+
+ HashSet<E> forward = new HashSet<E>();
+ HashSet<E> backward = new HashSet<E>();
+ HashSet<E> both = new HashSet<E>();
+
+ for(E eb : (Iterable<E>)e.getBoundPeers()) {
+ if (eb==e) continue;
+ if (eb.next.isBoundTo(e.next) && eb.prev.isBoundTo(e.prev)) {
+ forward.add(eb);
+ both.add(eb);
+ }
+ if (eb.pair.next.pair.isBoundTo(e.prev) && eb.pair.prev.pair.isBoundTo(e.next)) {
+ backward.add(eb.pair);
+ both.add(eb.pair);
+ }
+ }
+
+ Vertex v1 = e.t.v1();
+ Vertex v2 = e.t.v2();
+ Vertex v3 = e.t.v3();
+ Point c = e.t.centroid();
+ E e_next = e.next;
+ E e_prev = e.prev;
+ e.t.destroy();
+ newT(v1, v2, c);
+ newT(c, v2, v3);
+ newT(v3, v1, c);
+
+ // FIXME: forward too
+ for(E ex : backward) {
+ Vertex v1x = ex.t.v1();
+ Vertex v2x = ex.t.v2();
+ Vertex v3x = ex.t.v3();
+ Point cx = ex.t.centroid();
+ E ex_next = ex.next;
+ E ex_prev = ex.prev;
+ ex.t.destroy();
+ newT(v1x, v2x, cx);
+ newT(cx, v2x, v3x);
+ newT(v3x, v1x, cx);
+
+ // FIXME: i have no idea if this is right
+ e.next.bindTo(e.getBindingMatrix(ex.pair), ex.prev);
+ e.prev.bindTo(e.getBindingMatrix(ex.pair), ex.next);
+ e.next.pair.bindTo(e.getBindingMatrix(ex.pair), ex.prev.pair);
+ e.prev.pair.bindTo(e.getBindingMatrix(ex.pair), ex.next.pair);
+
+ e_next.next.bindTo(e_next.getBindingMatrix(ex_prev.pair), ex_prev.prev.pair);
+ e_next.prev.bindTo(e_next.getBindingMatrix(ex_prev.pair), ex_prev.next.pair);
+
+ e_prev.next.bindTo(e_prev.getBindingMatrix(ex_next.pair), ex_next.prev.pair);
+ e_prev.prev.bindTo(e_prev.getBindingMatrix(ex_next.pair), ex_next.next.pair);
+ }
+
+ /*
+
+ E first = null;
+ E firste = null;
+ E firstx = null;
+ E firstq = null;
+ for(E e : (Iterable<E>)getBoundPeers()) {
+ E enext = e.next;
+ E eprev = e.prev;
+ E pnext = e.pair.next;
+ E pprev = e.pair.prev;
+ Point mid = e.midpoint();
+ Vertex r = e.next.p2;
+ Vertex l = e.pair.next.p2;
+ if (!e.destroyed) {
+ e.destroy();
+ e.pair.destroy();
+ newT(r.p, e.p1.p, mid, null, 0);
+ newT(r.p, mid, e.p2.p, null, 0);
+ newT(l.p, mid, e.p1.p, null, 0);
+ newT(l.p, e.p2.p, mid, null, 0);
+ }
+ }
+ for(E e : (Iterable<E>)getBoundPeers()) {
+ Point mid = e.midpoint();
+ if (first==null) {
+ first = e.p1.getE(mid);
+ firste = e;
+ firstx = e.pair;
+ firstq = e.p2.getE(mid).pair;
+ continue;
+ }
+ e.p1.getE(mid). bindTo(e.getBindingMatrix(firste), first);
+ e.p1.getE(mid).pair. bindTo(e.getBindingMatrix(firste), first.pair);
+ e.p2.getE(mid).pair. bindTo(e.getBindingMatrix(firste), firstq);
+ e.p2.getE(mid).pair.pair.bindTo(e.getBindingMatrix(firste), firstq.pair);
+ }
+ */
+ /*
+ first.setConstraint(firste.getConstraint());
+ firstq.setConstraint(firste.getConstraint());
+ */
+ return null;