org.osm2world.core.math.datastructures
Class IntersectionGrid<T extends IntersectionTestObject>

Object
  extended by IntersectionGrid<T>

public class IntersectionGrid<T extends IntersectionTestObject>
extends Object

a data structure that can be used to speed up intersection tests. An IntersectionTestObject is added to all grid cells that are at least partially covered by the object's axis-aligned bounding box. When testing for intersections or inclusions, only elements in the same cell need to be compared.


Constructor Summary
IntersectionGrid(AxisAlignedBoundingBoxXZ gridBounds, double approxCellSizeX, double approxCellSizeZ)
          alternative constructor that uses a target cell size to calculate the number of cells
IntersectionGrid(AxisAlignedBoundingBoxXZ gridBounds, int cellCountX, int cellCountZ)
           
 
Method Summary
 Collection<Collection<T>> cellsFor(IntersectionTestObject object)
          returns all non-empty cells that would contain the object.
 Collection<T>[][] getCellArray()
           
 Iterable<Collection<T>> getCells()
          returns the content object collections for all non-empty cells
 void insert(T object)
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntersectionGrid

public IntersectionGrid(AxisAlignedBoundingBoxXZ gridBounds,
                        int cellCountX,
                        int cellCountZ)

IntersectionGrid

public IntersectionGrid(AxisAlignedBoundingBoxXZ gridBounds,
                        double approxCellSizeX,
                        double approxCellSizeZ)
alternative constructor that uses a target cell size to calculate the number of cells

Method Detail

getCellArray

public Collection<T>[][] getCellArray()

getCells

public Iterable<Collection<T>> getCells()
returns the content object collections for all non-empty cells


cellsFor

public Collection<Collection<T>> cellsFor(IntersectionTestObject object)
returns all non-empty cells that would contain the object. Will not modify the intersection grid, and it doesn't matter whether the object has been inserted or not.


insert

public void insert(T object)