X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fqfat%2FMesh.java;h=0df0072ef90ec58a1230f75e224a825e98d6dcb0;hb=3e0fc8c7a5658abf2c460fc4eae44d137748e4e7;hp=23ae1c8dac48dbd8fc502e5d42e06032b1d7af69;hpb=6e0085ca2aae0ae131abbd6d23fa5f3878834faa;p=anneal.git diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index 23ae1c8..0df0072 100644 --- a/src/edu/berkeley/qfat/Mesh.java +++ b/src/edu/berkeley/qfat/Mesh.java @@ -319,33 +319,48 @@ public class Mesh implements Iterable { } public class BindingGroup { - private HashSet ess = new HashSet(); + private HashSet left = new HashSet(); + private HashSet right = new HashSet(); public BindingGroup() { } public BindingGroup(E e) { - ess.add(e); + left.add(e); } public void add(E e) { - if (e.bg != null) { merge(e.bg); return; } - ess.add(e); - e.bg = this; - } - public void merge(BindingGroup bg) { - for(E e : bg.ess) { - e.bg = null; - add(e); + if (e.bg != null) { + if (e.bg == this) return; + for(E ex : e.bg.left) { + ex.bg = this; + left.add(ex); + } + for(E ex : e.bg.right) { + ex.bg = this; + right.add(ex); + } + } else { + left.add(e); + e.bg = this; } } public void dobind(E e) { - for(E ex : ess) { + // assumes e is part of the "left" set + for(E ex : left) { if (ex==e) continue; e.p1.bind(ex.p1); e.p2.bind(ex.p2); } + for(E ex : right) { + if (ex==e) continue; + e.p1.bind(ex.pair.p1); + e.p2.bind(ex.pair.p2); + } } public void shatter(BindingGroup bg1, BindingGroup bg2) { - for(E e : ess) { + for(E e : left) { e.shatter(e.midpoint(), bg1, bg2); } + for(E e : right) { + e.shatter(e.midpoint(), bg2, bg1); /* swap correct? */ + } } } @@ -384,8 +399,8 @@ public class Mesh implements Iterable { newT(r.p, p1.p, mid, null); newT(r.p, mid, p2.p, null); - //bg1.add(p1.getE(mid)); - //bg2.add(p2.getE(mid).pair); + bg1.add(p1.getE(mid)); + bg2.add(p2.getE(mid).pair); return mid; }