Class StaticSpatialIndex

java.lang.Object
org.jhotdraw8.geom.contour.StaticSpatialIndex

public class StaticSpatialIndex extends Object
StaticSpatialIndex.

References:

This code has been derived from CavalierContours.

CavalierContours. Copyright (c) 2019 Jedidiah Buck McCready. MIT License.
github.com
  • Constructor Details

    • StaticSpatialIndex

      public StaticSpatialIndex(int numItems)
      Creates a new instance which can hold the specified number of items.
      Parameters:
      numItems - number of items in spatial index
    • StaticSpatialIndex

      public StaticSpatialIndex(int numItems, int nodeSize)
      Creates a new instance which can hold the specified number of items, and which uses the specified number of items per node.
      Parameters:
      numItems - number of items in spatial index
      nodeSize - number of items per node
  • Method Details

    • add

      public void add(double minX, double minY, double maxX, double maxY)
    • finish

      public void finish()
    • query

      public void query(double minX, double minY, double maxX, double maxY, IntArrayList results)
      Parameters:
      minX -
      minY -
      maxX -
      maxY -
      results -
    • query

      public void query(double minX, double minY, double maxX, double maxY, IntArrayList results, IntArrayDeque stack)
      Query the spatial index adding indexes to the results vector given. This overload accepts an existing vector to use as a stack and takes care of clearing the stack before use.
    • visitQuery

      public void visitQuery(double minX, double minY, double maxX, double maxY, IntPredicate visitor)
      Parameters:
      minX -
      minY -
      maxX -
      maxY -
      visitor -
    • visitQuery

      public void visitQuery(double minX, double minY, double maxX, double maxY, IntPredicate visitor, IntArrayDeque stack)
      Query the spatial index, invoking a visitor function for each index that overlaps the bounding box given. Visitor function has the signature boolean(int index), if visitor returns false the query stops early, otherwise the query continues. This overload accepts an existing vector to use as a stack and takes care of clearing the stack before use.