checkpoint
authoradam <adam@megacz.com>
Sun, 16 Dec 2007 01:14:04 +0000 (17:14 -0800)
committeradam <adam@megacz.com>
Sun, 16 Dec 2007 01:14:04 +0000 (17:14 -0800)
darcs-hash:20071216011404-5007d-4c3d6e98cd24634678b390907e32ea2f54a556fc.gz

src/edu/berkeley/qfat/MeshViewer.java
src/edu/berkeley/qfat/geom/HasPoint.java
src/edu/berkeley/qfat/geom/IntervalTree.java [deleted file]
src/edu/berkeley/qfat/geom/PointSet.java
src/edu/berkeley/qfat/geom/RTree.java

index 658beb1..f869aac 100644 (file)
@@ -18,10 +18,10 @@ public class MeshViewer implements GLEventListener, MouseListener, MouseMotionLi
     public Mesh.Vert[] points;
 
 
-    public boolean tileon = false;
+    public boolean tileon = true;
     public boolean tilemeshon = false;
-    public boolean goalon = true;
-    public boolean anneal = false;
+    public boolean goalon = false;
+    public boolean anneal = true;
 
     public int breaks = 0;
     boolean alt = false;
index f1914e3..e4e6d9e 100644 (file)
@@ -1,7 +1,7 @@
 package edu.berkeley.qfat.geom;
 import javax.media.opengl.*;
 
-/** point in 3-space; immutable */
+/** any object associated with a specific point in 3D space */
 public abstract class HasPoint implements HasBoundingBox {
     public abstract Point getPoint();
     public float getMaxX() { return getPoint().getMaxX(); }
diff --git a/src/edu/berkeley/qfat/geom/IntervalTree.java b/src/edu/berkeley/qfat/geom/IntervalTree.java
deleted file mode 100644 (file)
index 9d7ed75..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-package edu.berkeley.qfat.geom;
-import javax.media.opengl.*;
-
-public class IntervalTree<V extends HasBoundingBox> {
-
-
-    private static final int X_AXIS = 0;
-    private static final int Y_AXIS = 1;
-    private static final int Z_AXIS = 2;
-
-    private class Node {
-        int axis; /* 0, 1, 2 */
-        V vthis;
-        float maxmax, minmin;
-        Node small, large;
-        float bias = 0;
-
-        public Node(V vthis, int axis) {
-            this.vthis = vthis;
-            this.axis = axis;
-            maxmax = getMax(vthis);
-            minmin = getMin(vthis);
-        }
-
-        private float getMin(V v) {
-            switch(axis) {
-                case X_AXIS: return v.getMinX();
-                case Y_AXIS: return v.getMinY();
-                case Z_AXIS: return v.getMinZ();
-            }
-            throw new Error();
-        }
-        private float getMax(V v) {
-            switch(axis) {
-                case X_AXIS: return v.getMaxX();
-                case Y_AXIS: return v.getMaxY();
-                case Z_AXIS: return v.getMaxZ();
-            }
-            throw new Error();
-        }
-        public Node insert(V vnew) {
-            // FIXME bias
-            if (getMax(vnew) > maxmax && getMin(vnew) < minmin) {
-                float diff = Math.abs(maxmax - getMax(vnew)) - Math.abs(minmin - getMin(vnew));
-                if (diff < 0) {
-                    maxmax = getMax(vnew);
-                } else {
-                    minmin = getMin(vnew);
-                }
-            }
-            if (getMax(vnew) <= maxmax) {
-                right++;
-                small = small == null ? new Node(vnew, (axis+1)%3) : small.insert(vnew);
-                bias = (left - right) / (float)(left + right);
-                if (Math.abs(bias) > Math.abs(maxbias)) maxbias = bias;
-                return this;
-
-            } else if (getMin(vnew) >= minmin) {
-                left++;
-                large = large == null ? new Node(vnew, (axis+1)%3) : large.insert(vnew);
-                bias = (left - right) / (float)(left + right);
-                if (Math.abs(bias) > Math.abs(maxbias)) maxbias = bias;
-                return this;
-            }
-
-            throw new Error();
-        }
-        int left=0, right=0;
-
-    }
-
-    private Node root;
-
-    public void insert(V v) {
-        if (root==null) {
-            root = new Node(v, X_AXIS);
-        } else {
-            root.insert(v);
-        }
-        System.out.println(maxbias + " " + size);
-        size++;
-    }
-    int size = 0;
-    float maxbias = 0;
-
-    public V nearest(Point p) {
-        return null;
-    }
-
-}
index 2733daf..ccb0ca5 100644 (file)
@@ -51,7 +51,8 @@ public class PointSet<V extends HasPoint> implements Iterable<V> {
         float max_x = Float.MIN_VALUE;
         float max_y = Float.MIN_VALUE;
         float max_z = Float.MIN_VALUE;
-        for(Point p : exact.keySet()) {
+        for(V v : this) {
+            Point p = v.getPoint();
             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;
@@ -69,7 +70,8 @@ public class PointSet<V extends HasPoint> implements Iterable<V> {
         float max_x = Float.MIN_VALUE;
         float max_y = Float.MIN_VALUE;
         float max_z = Float.MIN_VALUE;
-        for(Point p : exact.keySet()) {
+        for(V v : this) {
+            Point p = v.getPoint();
             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;
index c2fd9b4..eaa9f69 100644 (file)
@@ -4,7 +4,7 @@ import java.util.*;
 import com.infomatiq.jsi.*;
 import com.infomatiq.jsi.rtree.*;
 
-public class RTree<V extends HasBoundingBox> {
+public class RTree<V extends HasBoundingBox> implements Iterable<V> {
 
     private com.infomatiq.jsi.rtree.RTree rtree =
         new com.infomatiq.jsi.rtree.RTree();
@@ -13,6 +13,8 @@ public class RTree<V extends HasBoundingBox> {
     HashMap<Integer, V> idToV = new HashMap<Integer, V>();
     HashMap<V, Integer> vToId = new HashMap<V, Integer>();
 
+    public Iterator<V> iterator() { return vToId.keySet().iterator(); }
+
     public RTree() {
         Properties props = new Properties();
         props.put("MinNodeEntries", "1");