From: adam Date: Wed, 5 Dec 2007 03:26:31 +0000 (-0800) Subject: checkpoint X-Git-Url: http://git.megacz.com/?p=anneal.git;a=commitdiff_plain;h=dab0605afd5ba7368ebea35eb9ef5e612ec19523 checkpoint darcs-hash:20071205032631-5007d-c425261bd24cc4e183fc92ea17f05bb4174d6a5e.gz --- diff --git a/src/Geom.java b/src/Geom.java index c7374f7..89acb70 100644 --- a/src/Geom.java +++ b/src/Geom.java @@ -13,7 +13,7 @@ public class Geom implements Iterable { public static float EPSILON = (float)0.0001; public static Random random = new Random(); - private HashMap ps = new HashMap(); + private HashMap ps = new HashMap(); public HashSet es = new HashSet(); public ArrayList ts = new ArrayList(); @@ -143,9 +143,15 @@ public class Geom implements Iterable { public M aspect = new M(); public M invaspect = new M(); - /** [UNIQUE] point in 3-space */ - public final class P { + public final class V extends P { + public V(P p) { + super(p.x, p.y, p.z); + if (ps.get(p) != null) throw new Error(); + ps.put(this, this); + } + } + public class P { float x, y, z; int watch_count; @@ -162,10 +168,10 @@ public class Geom implements Iterable { private boolean inserted = false; - public P register() { - P p2 = ps.get(this); - if (p2==null) { p2 = this; ps.put(this,this); } - return p2; + public V register() { + V v = ps.get(this); + if (v==null) v = new V(this); + return (V)v; } public void kdremove() { @@ -257,7 +263,7 @@ public class Geom implements Iterable { this.y = newy; this.z = newz; // FIXME: what if we move onto exactly where another point is? - ps.put(this,this); + ps.put((V)this,(V)this); } catch (Exception e) { throw new RuntimeException(e); }