コード例 #1
0
ファイル: RTree.java プロジェクト: pabloloyola/soot
 /**
  * Recursively searches the tree for all intersecting entries. Immediately calls execute() on the
  * passed IntProcedure when a matching entry is found.
  *
  * <p>[x] TODO rewrite this to be non-recursive? Make sure it doesn't slow it down.
  */
 private void intersects(Rectangle r, IntProcedure v, Node n) {
   for (int i = 0; i < n.entryCount; i++) {
     if (r.intersects(n.entries[i])) {
       if (n.isLeaf()) {
         v.execute(n.ids[i]);
       } else {
         Node childNode = getNode(n.ids[i]);
         intersects(r, v, childNode);
       }
     }
   }
 }
コード例 #2
0
ファイル: RTree.java プロジェクト: jianluhero/ISDM
 private void intersects(float x1, float y1, float x2, float y2, IntProcedure v, Node n) {
   for (int i = 0; i < n.entryCount; i++) {
     if (intersects(x1, y1, x2, y2, n.entries[i])) {
       if (n.isLeaf()) {
         v.execute(n.ids[i]);
       } else {
         Node childNode = getNode(n.ids[i]);
         intersects(x1, y1, x2, y2, v, childNode);
       }
     }
   }
 }
コード例 #3
0
ファイル: RTree.java プロジェクト: jianluhero/ISDM
  /** @see com.infomatiq.jsi.SpatialIndex#contains(Rectangle, IntProcedure) */
  public void contains(Rectangle r, IntProcedure v) {
    // find all rectangles in the tree that are contained by the passed
    // rectangle
    // written to be non-recursive (should model other searches on this?)

    parents.clear();
    parents.push(rootNodeId);

    parentsEntry.clear();
    parentsEntry.push(-1);

    // TODO: possible shortcut here - could test for intersection with the
    // MBR of the root node. If no intersection, return immediately.

    while (parents.size() > 0) {
      Node n = getNode(parents.peek());
      int startIndex = parentsEntry.peek() + 1;

      if (!n.isLeaf()) {
        // go through every entry in the index node to check
        // if it intersects the passed rectangle. If so, it
        // could contain entries that are contained.
        boolean intersects = false;
        for (int i = startIndex; i < n.entryCount; i++) {
          if (r.intersects(n.entries[i])) {
            parents.push(n.ids[i]);
            parentsEntry.pop();
            parentsEntry.push(i); // this becomes the start index
            // when the child has been
            // searched
            parentsEntry.push(-1);
            intersects = true;
            break; // ie go to next iteration of while()
          }
        }
        if (intersects) {
          continue;
        }
      } else {
        // go through every entry in the leaf to check if
        // it is contained by the passed rectangle
        for (int i = 0; i < n.entryCount; i++) {
          if (r.contains(n.entries[i])) {
            v.execute(n.ids[i]);
          }
        }
      }
      parents.pop();
      parentsEntry.pop();
    }
  }
コード例 #4
0
ファイル: RTree.java プロジェクト: pabloloyola/soot
 public boolean execute(int i) {
   m_intProcedure.execute(i);
   return true;
 }