org.osm2world.core.math.datastructures
Class IntersectionGrid

Object
  extended by IntersectionGrid

public class IntersectionGrid
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<IntersectionTestObject>> cellsFor(IntersectionTestObject object)
          returns all non-empty cells that would contain the object.
 Collection<IntersectionTestObject>[][] getCellArray()
           
 Iterable<Collection<IntersectionTestObject>> getCells()
          returns the content object collections for all non-empty cells
 void insert(IntersectionTestObject 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<IntersectionTestObject>[][] getCellArray()

getCells

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


cellsFor

public Collection<Collection<IntersectionTestObject>> 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(IntersectionTestObject object)