X-Git-Url: http://git.megacz.com/?p=anneal.git;a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2FMesh.java;h=951f53af85312dce770d989c6615d2355a48597d;hp=fa6b80f536b2a8b0a427a3b4329cf3a964582800;hb=de98420094a537a70140842ff185e6d113ad270e;hpb=bebc4007cb48fe93ca03f97047d3445a881afe9e diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index fa6b80f..951f53a 100644 --- a/src/edu/berkeley/qfat/Mesh.java +++ b/src/edu/berkeley/qfat/Mesh.java @@ -78,8 +78,6 @@ public class Mesh implements Iterable { public Point p, oldp, goodp; E e; // some edge *leaving* this point - Matrix binding = Matrix.ONE; - Vertex bound_to = this; private boolean illegal = false; public Point getPoint() { return p; } @@ -161,11 +159,14 @@ public class Mesh implements Iterable { public boolean move(Matrix m, boolean ignoreProblems) { boolean good = true; - for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to) + + for(Vertex p : (Iterable)getBoundPeers()) good &= p.transform(m.times(p.p), ignoreProblems); - for(Vertex p = this; p != null; p = (p.bound_to==this)?null:p.bound_to) + + for(Vertex p : (Iterable)getBoundPeers()) if (good || ignoreProblems) p.reComputeErrorAround(); - else p.transform(p.oldp, true); + else p.transform(p.oldp, true); + return good; } @@ -260,24 +261,7 @@ public class Mesh implements Iterable { return norm.norm(); } - public boolean isBoundTo(Vertex p) { - for(Vertex px = p; px!=null; px=(px.bound_to==p?null:px.bound_to)) - if (px==this) - return true; - return false; - } - - public void unbind() { bound_to = this; binding = Matrix.ONE; } - public void bind(Vertex p) { bind(p, Matrix.ONE); } - public void bind(Vertex p, Matrix binding) { - if (isBoundTo(p)) return; - Vertex temp_bound_to = p.bound_to; - Matrix temp_binding = p.binding; - p.bound_to = this.bound_to; - p.binding = binding.times(this.binding); // FIXME: may have order wrong here - this.bound_to = temp_bound_to; - this.binding = temp_binding.times(temp_binding); // FIXME: may have order wrong here - } + public void bindTo(Vertex p) { bindTo(Matrix.ONE, p); } } public class BindingGroup { @@ -309,8 +293,8 @@ public class Mesh implements Iterable { } public void dobind(E e) { for(E ebound : set) { - e.p1.bind(ebound.p2); - e.p2.bind(ebound.p1); + e.p1.bindTo(Matrix.ONE, ebound.p2); + e.p2.bindTo(Matrix.ONE, ebound.p1); } } public void shatter(BindingGroup bg1, BindingGroup bg2, boolean triangles) { @@ -606,6 +590,9 @@ public class Mesh implements Iterable { public void reinsert() { triangles.remove(this); triangles.add(this); } public boolean shouldBeDrawn() { + if (e1().bind_to==null) return false; + if (e2().bind_to==null) return false; + if (e3().bind_to==null) return false; if (e1().bind_to.set.size() == 0) return false; if (e2().bind_to.set.size() == 0) return false; if (e3().bind_to.set.size() == 0) return false;