projects
/
anneal.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a3aad0b
)
checkpoint
author
adam
<adam@megacz.com>
Sun, 2 Dec 2007 03:03:01 +0000
(19:03 -0800)
committer
adam
<adam@megacz.com>
Sun, 2 Dec 2007 03:03:01 +0000
(19:03 -0800)
darcs-hash:
20071202030301
-5007d-
35faf934f46cc0b2a4a9a65f6402b959a51ee571
.gz
src/Geom.java
patch
|
blob
|
history
diff --git
a/src/Geom.java
b/src/Geom.java
index
316e334
..
445c896
100644
(file)
--- a/
src/Geom.java
+++ b/
src/Geom.java
@@
-188,6
+188,21
@@
public class Geom implements Iterable<Geom.T> {
public String toString() { return "<"+x+","+y+","+z+">"; }
}
public String toString() { return "<"+x+","+y+","+z+">"; }
}
+ public class BindingGroup {
+ public HashSet<E> es = new HashSet<E>();
+ public BindingGroup() { }
+ public merge(E e) {
+ if (e.bg != null) merge(e.bg);
+ else { es.add(e); e.bg = this; }
+ }
+ public merge(BindingGroup bg) {
+ for(E e : bg.es) {
+ e.bg = this;
+ this.bg.add(e);
+ }
+ }
+ }
+
/** [UNIQUE] an edge */
public final class E {
public final P p1, p2;
/** [UNIQUE] an edge */
public final class E {
public final P p1, p2;
@@
-197,17
+212,23
@@
public class Geom implements Iterable<Geom.T> {
E pair; // partner half-edge
E pair; // partner half-edge
- public E bound_to = this;
+ public BindingGroup bg = null;
public void bind(E e) { bind(e, new M()); }
public void bind(E e, M m) {
public void bind(E e) { bind(e, new M()); }
public void bind(E e, M m) {
- E old = this.bound_to;
- this.bound_to = e.bound_to;
- e.bound_to = old;
+ if (e.bg != null) e.bg.merge(this);
+ else if (bg != null) bg.merge(e);
+ else {
+ bg = new BindingGroup();
+ bg.merge(this);
+ bg.merge(e);
+ }
}
public void dobind() {
}
public void dobind() {
- for(E ex = bound_to; ex != this; ex = ex.bound_to) {
+ if (bg==null) return;
+ for(E ex : bg.es) {
+ if (ex==this) continue;
p1.bind(ex.p1);
p2.bind(ex.p2);
}
p1.bind(ex.p1);
p2.bind(ex.p2);
}