1 package edu.berkeley.qfat.geom;
2 import javax.media.opengl.*;
4 import com.infomatiq.jsi.*;
5 import com.infomatiq.jsi.rtree.*;
7 public class RTree<V extends HasBoundingBox> {
9 private com.infomatiq.jsi.rtree.RTree rtree =
10 new com.infomatiq.jsi.rtree.RTree();
13 HashMap<Integer, V> idToV = new HashMap<Integer, V>();
14 HashMap<V, Integer> vToId = new HashMap<V, Integer>();
17 Properties props = new Properties();
18 props.put("MinNodeEntries", "1");
19 props.put("MaxNodeEntries", "5");
23 public void insert(V v) {
27 rtree.add(new com.infomatiq.jsi.Rectangle(v.getMinX(), v.getMinY(), v.getMinZ(),
28 v.getMaxX(), v.getMaxY(), v.getMaxZ()),
32 public void remove(V v) {
33 int id = vToId.get(v);
36 rtree.delete(new com.infomatiq.jsi.Rectangle(v.getMinX(), v.getMinY(), v.getMinZ(),
37 v.getMaxX(), v.getMaxY(), v.getMaxZ()),
44 private IntProcedure finder = new IntProcedure() {
45 public boolean execute(int id) {
46 found = idToV.get(id);
51 public V nearest(Point p) {
52 rtree.nearest(new com.infomatiq.jsi.Point(p.x, p.y, p.z), finder, Float.POSITIVE_INFINITY);