checkpoint
authoradam <adam@megacz.com>
Wed, 5 Dec 2007 05:08:27 +0000 (21:08 -0800)
committeradam <adam@megacz.com>
Wed, 5 Dec 2007 05:08:27 +0000 (21:08 -0800)
darcs-hash:20071205050827-5007d-b9d2da1a08a02358a261e435b94ec0558f09f0e7.gz

src/edu/berkeley/qfat/Mesh.java

index c570ede..f7ecb4d 100644 (file)
@@ -16,8 +16,7 @@ public class Mesh implements Iterable<Mesh.T> {
     public static float EPSILON = (float)0.0001;
     public static Random random = new Random();
 
-    private HashMap<Point,Vert>  ps = new HashMap<Point,Vert>();
-    //public  HashSet<E>           es = new HashSet<E>();
+    private HashMap<Point,Vert>  verts = new HashMap<Point,Vert>();
 
     public Iterable<E> edges() {
         return
@@ -38,9 +37,9 @@ public class Mesh implements Iterable<Mesh.T> {
     }
 
     public Iterator<T> iterator() {
-        for(Vert v : ps.values()) {
-            if (v.e != null && v.e.t != null) return new FaceIterator(v);
-        }
+        for(Vert v : verts.values())
+            if (v.e != null && v.e.t != null)
+                return new FaceIterator(v);
         return new FaceIterator();
     }
 
@@ -91,7 +90,7 @@ public class Mesh implements Iterable<Mesh.T> {
 
     public void transform(Matrix m) {
         ArrayList<Vert> set = new ArrayList<Vert>();
-        set.addAll(ps.values());
+        set.addAll(verts.values());
         for(Vert v : set) v.transform(m);
     }
 
@@ -102,7 +101,7 @@ public class Mesh implements Iterable<Mesh.T> {
         float max_x = Float.MIN_VALUE;
         float max_y = Float.MIN_VALUE;
         float max_z = Float.MIN_VALUE;
-        for(Point p : ps.keySet()) {
+        for(Point p : verts.keySet()) {
             if (p.x < min_x) min_x = p.x;
             if (p.y < min_y) min_y = p.y;
             if (p.z < min_z) min_z = p.z;
@@ -120,7 +119,7 @@ public class Mesh implements Iterable<Mesh.T> {
         float max_x = Float.MIN_VALUE;
         float max_y = Float.MIN_VALUE;
         float max_z = Float.MIN_VALUE;
-        for(Point p : ps.keySet()) {
+        for(Point p : verts.keySet()) {
             if (p.x < min_x) min_x = p.x;
             if (p.y < min_y) min_y = p.y;
             if (p.z < min_z) min_z = p.z;
@@ -170,13 +169,13 @@ public class Mesh implements Iterable<Mesh.T> {
         }
     }
 
-    public Vert register(Point p) { Vert v = ps.get(p); return v==null ? new Vert(p) : v; }
+    public Vert register(Point p) { Vert v = verts.get(p); return v==null ? new Vert(p) : v; }
     public final class Vert {
         public Point p;
         private Vert(Point p) {
             this.p = p;
-            if (ps.get(p) != null) throw new Error();
-            ps.put(this.p, this);
+            if (verts.get(p) != null) throw new Error();
+            verts.put(this.p, this);
         }
         public void kdremove() {
             if (!inserted) return;
@@ -242,14 +241,14 @@ public class Mesh implements Iterable<Mesh.T> {
             // FIXME: screws up hashmap
             unscore();
             try {
-                if (ps.get(this.p)==null) throw new Error();
-                ps.remove(this.p);
+                if (verts.get(this.p)==null) throw new Error();
+                verts.remove(this.p);
                 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?
-                ps.put(this.p,(Vert)this);
+                verts.put(this.p,(Vert)this);
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }
@@ -598,7 +597,7 @@ public class Mesh implements Iterable<Mesh.T> {
         if (norm != null) {
             Vec norm2 = p3.p.minus(p1.p).cross(p2.p.minus(p1.p));
             float dot = norm.dot(norm2);
-            //if (Math.abs(dot) < EPointSILON) throw new Error("dot products within epsilon of each other: "+norm+" "+norm2);
+            //if (Math.abs(dot) < EPointSILON) throw new Error("dot products within evertsilon of each other: "+norm+" "+norm2);
             if (dot < 0) { Vert p = p1; p1=p2; p2 = p; }
         }
         E e12 = p1.makeE(p2);