(float)(0.25+(0.05*t.color)),
(float)(0.75+(0.05*t.color)),
(float)0.3);
+ /*
if (t.red) {
gl.glColor4f((float)(0.75+(0.05*t.color)),
(float)(0.25+(0.05*t.color)),
(float)(0.25+(0.05*t.color)),
(float)0.3);
}
+ */
t.glTriangle(gl, m);
}
if (option_errorNormals)
}
int i=0;
+
for(E e : flip) {
e.flip();
System.out.println("flip!");
i++;
//if (i>2) break;
}
+
System.out.println("count="+count);
+
+ /*
+ tris.clear();
+ for (T t : this) if (t.v1().edge && t.v2().edge && t.v3().edge) tris.add(t);
+ for (T t : tris)
+ t.shatter();
+ */
+
/*
- for (E e : flip) {
- if (e.p1.original && !e.p2.face && !e.p2.original) e.flip();
- else if (e.p2.original && !e.p1.face && !e.p1.original) e.flip();
- }
- HashSet<Vertex> verts = new HashSet<Vertex>();
- for(Vertex v : vertices()) verts.add(v);
for(Vertex v : verts) {
if (!v.face) continue;
- //v.move(v.recenter().minus(v.getPoint()), false);
+ v.move(v.recenter().minus(v.getPoint()), false);
}
*/
-
/*
Queue<T> q = new LinkedList<T>();
OUTER: while(true) {
break;
}
*/
- /*
- for (Vertex v : vertices())
- clearWish();
- for (Vertex v : vertices()) {
-
+
+ rebindPoints();
+ HashSet<Vertex> verts = new HashSet<Vertex>();
+ for(Vertex v : vertices()) verts.add(v);
+ for (Vertex v : verts)
+ v.clearWish();
+ for (Vertex v : verts) {
+ if (v.edge) {
+ for(E e = v.e; e!=null; e=e.pair.next==v.e?null:e.pair.next) {
+ if (e.p2.original) {
+ v.wish(e.p2);
+ v.wish(e.p2);
+ v.wish(e.p2);
+ v.wish(e.p2);
+ }
+ }
+ for(E e = v.e; e!=null; e=e.pair.next==v.e?null:e.pair.next) {
+ for(E e2 = e.p2.e; e2!=null; e2=e2.pair.next==e.p2.e?null:e2.pair.next) {
+ if (e2.p2.original) {
+ v.wish(e.p2);
+ }
+ }
+ }
+ }
}
- for (Vertex v : vertices())
- grantWish();
- */
+ for (Vertex v : verts)
+ v.grantWish();
+
}
// Vertexices //////////////////////////////////////////////////////////////////////////////
public boolean edge = false;
public boolean face = false;
+ private int wishes = 0;
+ private Point wish = Point.ZERO;
+ public void clearWish() { wishes = 0; wish = Point.ZERO; }
+ public void wish(HasPoint hp) {
+ Point p = hp.getPoint();
+ wishes++;
+ wish = new Point(wish.x+p.x, wish.y+p.y, wish.z+p.z);
+ }
+ public void grantWish() {
+ for(Vertex v : (Iterable<Vertex>)getBoundPeers()) {
+ if (v==this) continue;
+ Point p = this.getBindingMatrix(v).times(v.wish.minus(Point.ZERO).div(v.wishes).plus(Point.ZERO));
+ wish = p.minus(Point.ZERO).times(v.wishes).plus(wish);
+ wishes += v.wishes;
+ v.clearWish();
+ }
+ if (wishes==0) return;
+ Vec d = wish.minus(Point.ZERO).div(wishes).plus(Point.ZERO).minus(getPoint());
+ move(d, false);
+ clearWish();
+ }
+
private boolean illegal = false;
public boolean visible = false;
if (e.p1 == this && e.p2 == p2) return e;
i++;
e.sanity();
- if (e.destroyed) throw new RuntimeException();
+ if (e.destroyed) throw new RuntimeException("fark " + i + " " + e.prev + " " + (e.prev.next==e) + " " + e.prev.destroyed);
}
return null;
}
Vertex v2 = pair.t.getOtherVertex(pair);
destroy();
pair.destroy();
- newT(v1, v2, p2).red = true;
- newT(v2, v1, p1).red = true;
+ T t1 = newT(v1, v2, p2);
+ T t2 = newT(v2, v1, p1);
+ t1.e1().sanity();
+ t1.e2().sanity();
+ t1.e3().sanity();
+ t2.e1().sanity();
+ t2.e2().sanity();
+ t2.e3().sanity();
+
for (E e : (Iterable<E>)getBoundPeers()) {
+ if (e==this) continue;
if (e.destroyed) continue;
Vertex v1e = e.t.getOtherVertex(e);
Vertex v2e = e.pair.t.getOtherVertex(e.pair);
if (v1e.getE(v2e)!=null) throw new RuntimeException();
newT(v1e, v2e, e.p2).red = true;
newT(v2e, v1e, e.p1).red = true;
- makeE(v1.getPoint(),
- v2.getPoint()).bindTo(this.getBindingMatrix(e), makeE(v1e.getPoint(), v2e.getPoint()));
- makeE(v2.getPoint(),
- v1.getPoint()).bindTo(pair.getBindingMatrix(e.pair), makeE(v2e.getPoint(), v1e.getPoint()));
-
+ v2e.getE(v1e).bindTo(e.getBindingMatrix(this), v1.getE(v2));
+ v1e.getE(v2e).bindTo(e.pair.getBindingMatrix(this.pair), v2.getE(v1));
}
+
}
public void bindingGroupChanged(edu.berkeley.qfat.geom.BindingGroup newBindingGroup_) {
pair.next.t = null;
pair.prev.t = null;
- if (next.destroyed) throw new RuntimeException();
- if (prev.destroyed) throw new RuntimeException();
pair.prev.next = next;
next.prev = pair.prev;
prev.next = pair.next;
- pair.next = prev;
+ pair.next.prev = prev;
+
+ if (p1.e == this) p1.e = pair.next;
+ if (pair.p1.e == pair) pair.p1.e = next;
- if (p1.e == this) p1.e = prev.next;
- if (pair.p1.e == pair) pair.p1.e = pair.prev.next;
if (p2.e == this) throw new RuntimeException();
if (pair.p2.e == pair) throw new RuntimeException();
+ /*
+ next = pair;
+ prev = pair;
+ pair.next = this;
+ pair.prev = this;
+ */
+
+ /*
+ pair.prev = null;
+ pair.next = null;
+ next = null;
+ prev = null;
+ */
+
+ /*
sanity();
next.sanity();
prev.sanity();
pair.sanity();
+ */
}
private void sync() {