X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Fedu%2Fberkeley%2Fqfat%2FMesh.java;h=951f53af85312dce770d989c6615d2355a48597d;hb=de98420094a537a70140842ff185e6d113ad270e;hp=68e9c23ec8cb73bcd467fa51f7ff74fd6375a5f5;hpb=64b959c2f7b32e81c510f5dabec573adcebda4b6;p=anneal.git diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index 68e9c23..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) { @@ -357,6 +341,9 @@ public class Mesh implements Iterable { public Point shatter() { return shatter(true); } public Point shatter(boolean triangles) { return shatter(midpoint(), null, null, triangles); } public Point shatter(Point mid, BindingGroup bg1, BindingGroup bg2, boolean triangles) { + return shatter(mid, bg1, bg2, triangles, false); + } + public Point shatter(Point mid, BindingGroup bg1, BindingGroup bg2, boolean triangles, boolean leader) { if (shattered || destroyed) return mid; shattered = true; @@ -382,6 +369,7 @@ public class Mesh implements Iterable { newT(r.p, mid, p2.p, null, old_colorclass); bg1.add(p1.getE(mid)); bg2.add(p2.getE(mid).pair); + if (leader) p1.getE(mid).shatter(); } return mid; } @@ -602,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;