From 5c853bc2480c011d948d31f45977a1e86035b4fe Mon Sep 17 00:00:00 2001 From: adam Date: Wed, 5 Dec 2007 00:54:37 -0800 Subject: [PATCH] checkpoint darcs-hash:20071205085437-5007d-422921ca6764ca82150f39a688233854a9aa047b.gz --- src/edu/berkeley/qfat/Mesh.java | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/edu/berkeley/qfat/Mesh.java b/src/edu/berkeley/qfat/Mesh.java index 0df0072..563e2f5 100644 --- a/src/edu/berkeley/qfat/Mesh.java +++ b/src/edu/berkeley/qfat/Mesh.java @@ -325,33 +325,37 @@ public class Mesh implements Iterable { public BindingGroup(E e) { left.add(e); } - public void add(E e) { + public void add(E e, boolean swap) { if (e.bg != null) { if (e.bg == this) return; - for(E ex : e.bg.left) { + for(E ex : (!swap ? e.bg.left : e.bg.right)) { ex.bg = this; left.add(ex); } - for(E ex : e.bg.right) { + for(E ex : (!swap ? e.bg.right : e.bg.left)) { ex.bg = this; right.add(ex); } } else { - left.add(e); + (!swap ? left : right).add(e); e.bg = this; } } public void dobind(E e) { // assumes e is part of the "left" set + Vert v1 = null; + Vert v2 = null; + if (left.contains(e)) { v1 = e.p1; v2 = e.p2; } + if (right.contains(e)) { v1 = e.p2; v2 = e.p1; } for(E ex : left) { if (ex==e) continue; - e.p1.bind(ex.p1); - e.p2.bind(ex.p2); + v1.bind(ex.p1); + v2.bind(ex.p2); } for(E ex : right) { if (ex==e) continue; - e.p1.bind(ex.pair.p1); - e.p2.bind(ex.pair.p2); + v1.bind(ex.p2); + v2.bind(ex.p1); } } public void shatter(BindingGroup bg1, BindingGroup bg2) { @@ -378,7 +382,7 @@ public class Mesh implements Iterable { public int compareTo(E e) { return e.length() > length() ? 1 : -1; } public void bindEdge(E e) { - e.pair.bg.add(this); + e.pair.bg.add(this, false); } public void dobind() { if (bg != null) bg.dobind(this); } @@ -399,8 +403,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), false); + bg2.add(p2.getE(mid).pair, false); return mid; } -- 1.7.10.4