//double min = (tile.avgedge/tile.numedges)*(1+(4/(double)verts));
//if (verts>0 && tile.es.peek().length() < min) return;
PriorityQueue<Mesh.E> es = new PriorityQueue<Mesh.E>();
- for(Mesh.E e : tile.es) es.add(e);
+ for(Mesh.E e : tile.edges()) es.add(e);
for(int i=0; i<10; i++) {
Mesh.E e = es.poll();
verts++;
public static Random random = new Random();
private HashMap<Point,Vert> ps = new HashMap<Point,Vert>();
- public HashSet<E> es = new HashSet<E>();
+ //public HashSet<E> es = new HashSet<E>();
+
+ public Iterable<E> edges() {
+ return
+ new Iterable<E>() {
+ public Iterator<E> iterator() {
+ // HACK
+ HashSet<E> hse = new HashSet<E>();
+ for(T t : Mesh.this) {
+ hse.add(t.e1());
+ hse.add(t.e2());
+ hse.add(t.e3());
+ hse.add(t.e1().pair);
+ hse.add(t.e2().pair);
+ hse.add(t.e3().pair);
+ }
+ return hse.iterator();
+ } };
+ }
public Iterator<T> iterator() {
- if (es.size() == 0) return new FaceIterator();
- return new FaceIterator(es.iterator().next().p1);
+ for(Vert v : ps.values()) {
+ if (v.e != null && v.e.t != null) return new FaceIterator(v);
+ }
+ return new FaceIterator();
}
public Point origin() { return new Point(0, 0, 0); }
pair.next = prev;
if (p1.e == this) p1.e = prev.next;
if (pair.p1.e == pair) pair.p1.e = pair.prev.next;
- es.remove(this);
- es.remove(pair);
avgedge -= this.length();
avgedge -= pair.length();
numedges--;
if (this.next.p1 != p2) throw new Error();
if (this.prev.p2 != p1) throw new Error();
if (this.p1.e == null) this.p1.e = this;
- es.add(this);
if (!added) {
added = true;
numedges++;