checkpoint
authoradam <adam@megacz.com>
Wed, 5 Dec 2007 05:34:03 +0000 (21:34 -0800)
committeradam <adam@megacz.com>
Wed, 5 Dec 2007 05:34:03 +0000 (21:34 -0800)
darcs-hash:20071205053403-5007d-ce2ab070a573fcde853cf0a776933fde9c4a81b7.gz

src/edu/berkeley/qfat/Mesh.java

index e530ad7..993f5e1 100644 (file)
@@ -78,6 +78,7 @@ public class Mesh implements Iterable<Mesh.T> {
                 done.add(p);
                 p.rescore();
             }
+        /*
         for(T t : this)
             for(Vert p : new Vert[] { t.v1(), t.v2(), t.v3() })
                 p.kdremove();
@@ -85,6 +86,7 @@ public class Mesh implements Iterable<Mesh.T> {
         for(T t : this)
             for(Vert p : new Vert[] { t.v1(), t.v2(), t.v3() })
                 p.kdinsert();
+        */
         return (float)(dist/num);
     }
 
@@ -172,6 +174,11 @@ public class Mesh implements Iterable<Mesh.T> {
             this.p = p;
             if (verts.get(p) != null) throw new Error();
             verts.put(this.p, this);
+            pointset.add(this);
+        }
+        public void reinsert() {
+            pointset.remove(this);
+            pointset.add(this);
         }
         public void kdremove() {
             if (!inserted) return;
@@ -213,7 +220,7 @@ public class Mesh implements Iterable<Mesh.T> {
                 watch = score_against.nearest(po.p);
 
                 // don't attract to vertices that face the other way
-                if (watch.norm().dot(norm()) < 0) {
+                if (watch.e == null || watch.norm().dot(norm()) < 0) {
                     watch = null;
                 } else {
                     watch.watch_x += po.p.x;
@@ -239,11 +246,13 @@ public class Mesh implements Iterable<Mesh.T> {
             try {
                 if (verts.get(this.p)==null) throw new Error();
                 verts.remove(this.p);
+                pointset.remove(this);
                 float newx = m.a*p.x + m.b*p.y + m.c*p.z + m.d;
                 float newy = m.e*p.x + m.f*p.y + m.g*p.z + m.h;
                 float newz = m.i*p.x + m.j*p.y + m.k*p.z + m.l;
                 this.p = new Point(newx, newy, newz);
                 // FIXME: what if we move onto exactly where another point is?
+                pointset.add(this);
                 verts.put(this.p,(Vert)this);
             } catch (Exception e) {
                 throw new RuntimeException(e);