1 package edu.berkeley.qfat.geom;
2 import edu.wlu.cs.levy.CG.KDTree;
5 public class PointSet<V extends HasPoint> implements Iterable<V> {
7 private /*final*/ KDTree kd = new KDTree(3);
8 private final double[] doubles = new double[3];
10 private HashMap<Point,V> exact = new HashMap<Point,V>();
12 public Iterator<V> iterator() {
13 return exact.values().iterator();
19 public V get(Point p) {
23 public void add(V v) {
24 V x = get(v.getPoint());
25 if (x != null && x.equals(v)) return;
26 Point p = v.getPoint();
31 kd.insert(doubles, v);
32 } catch (Exception e) {
38 public void remove(HasPoint v) { remove(v.getPoint()); }
39 public void remove(Point p) {
45 } catch (Exception e) { }
49 public V nearest(Point p) {
50 if (exact.size()==0) return null;
56 results = kd.nearest(doubles,1);
57 } catch (Exception e) {