add items to TODO list
[anneal.git] / src / edu / berkeley / qfat / geom / PointSet.java
index ccb0ca5..11e48a2 100644 (file)
@@ -1,6 +1,7 @@
 package edu.berkeley.qfat.geom;
 import java.util.*;
 
+/** a set of points, plus many useful methods operating over the set */
 public class PointSet<V extends HasPoint> implements Iterable<V> {
 
     private RTree<V> rtree = new RTree<V>();
@@ -9,11 +10,10 @@ public class PointSet<V extends HasPoint> implements Iterable<V> {
 
     public int size() { return exact.size(); }
 
-    public Iterator<V> iterator() {
-        return exact.values().iterator();
-    }
+    public Iterator<V> iterator() { return rtree.iterator(); }
+
     public void clear() {
-        exact = new HashMap<Point,V>();
+        exact.clear();
         rtree = new RTree<V>();
     }
 
@@ -21,9 +21,6 @@ public class PointSet<V extends HasPoint> implements Iterable<V> {
         return exact.get(p);
     }
 
-    public void rebuild() {
-    }
-
     public void add(V v) {
         V x = get(v.getPoint());
         if (x != null && x.equals(v)) return;
@@ -39,9 +36,10 @@ public class PointSet<V extends HasPoint> implements Iterable<V> {
         exact.remove(p);
     }
 
-    public V nearest(Point p) {
+    public V nearest(Point p) { return nearest(p, null); }
+    public V nearest(Point p, Visitor<V> vis) {
         if (exact.size()==0) return null;
-        return rtree.nearest(p);
+        return rtree.nearest(p, vis);
     }
 
     public Vec diagonal() {
@@ -63,6 +61,7 @@ public class PointSet<V extends HasPoint> implements Iterable<V> {
         return new Vec(max_x - min_x, max_y - min_y, max_z - min_z);
     }
 
+    // FEATURE: compute incrementally?
     public Point centroid() {
         float min_x = Float.MAX_VALUE;
         float min_y = Float.MAX_VALUE;