rtree.delete(rect, id);
}
- public V nearest(Point p) {
+ public V nearest(Point p) { return nearest(p, null); }
+ public V nearest(Point p, Visitor<V> ip) {
point.set(p.x, p.y, p.z);
+ this.visitor = ip;
rtree.nearest(point, myIntProcedure, Float.POSITIVE_INFINITY);
+ this.visitor = null;
V ret = found;
found = null;
return ret;
}
- public void range(HasBoundingBox v, Visitor vis) {
+ public void range(HasBoundingBox v, Visitor<V> vis) {
visitor = vis;
+ rect.set(v.getMinX(), v.getMinY(), v.getMinZ(), v.getMaxX(), v.getMaxY(), v.getMaxZ());
+ rtree.intersects(rect, myIntProcedure);
+ visitor = null;
+ }
+
+ public void range(Point p1, Point p2, Visitor<V> vis) {
+ visitor = vis;
+ rect.set(p1.x, p1.y, p1.z, p2.x, p2.y, p2.z);
rtree.intersects(rect, myIntProcedure);
visitor = null;
}
private class MyIntProcedure implements IntProcedure {
public boolean execute(int id) {
+ found = idToV.get(id);
if (visitor != null) {
- V v = idToV.get(id);
- visitor.visit(v);
- return true;
+ return visitor.visit(found);
} else {
- found = idToV.get(id);
return false;
}
}