import com.infomatiq.jsi.*;
import com.infomatiq.jsi.rtree.*;
+/** wrapper around the <tt>com.infomatiq.jsi.rtree.RTree</tt> class */
public class RTree<V extends HasBoundingBox> implements Iterable<V> {
private com.infomatiq.jsi.rtree.RTree rtree =
public Iterator<V> iterator() { return vToId.keySet().iterator(); }
- private final MyIntProcedure myIntProcedure = new MyIntProcedure();
+ private final MyIntProcedure myIntProcedure = new MyIntProcedure();
private final com.infomatiq.jsi.Rectangle rect = new com.infomatiq.jsi.Rectangle(0,0,0,0,0,0);
- private final com.infomatiq.jsi.Point point = new com.infomatiq.jsi.Point(0,0,0);
- private V found = null;
+ private final com.infomatiq.jsi.Point point = new com.infomatiq.jsi.Point(0,0,0);
+ private V found = null;
private Visitor<V> visitor = null;
private static final Properties props = new Properties();
rtree.delete(rect, id);
}
- private class MyIntProcedure implements IntProcedure {
- public boolean execute(int id) {
- if (visitor != null) {
- V v = idToV.get(id);
- visitor.visit(v);
- return true;
- } else {
- found = idToV.get(id);
- return false;
- }
- }
- }
-
public V nearest(Point p) {
point.set(p.x, p.y, p.z);
rtree.nearest(point, myIntProcedure, Float.POSITIVE_INFINITY);
public void range(HasBoundingBox v, Visitor 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 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) {
+ if (visitor != null) {
+ V v = idToV.get(id);
+ visitor.visit(v);
+ return true;
+ } else {
+ found = idToV.get(id);
+ return false;
+ }
+ }
+ }
}