Class Ots2dSet

java.lang.Object
org.opentrafficsim.core.geometry.Ots2dSet
All Implemented Interfaces:
Iterable<Polygon2d>, Collection<Polygon2d>, Set<Polygon2d>

public class Ots2dSet extends Object implements Set<Polygon2d>
Set of Polygon2d objects and provides methods for fast selection of those objects that intersect a Polygon2d.
An Ots2dSet internally stores the Polygon2ds in a quad tree. At time of construction the minimum cell size is defined. Node expansion is never performed on nodes that are smaller than this limit.
Each node (even the non-leaf nodes) store a set of Polygon2d. Non-leaf nodes locally store those shapes that completely cover the rectangular area of the node. Such shapes are not also stored in leaf nodes below that node. Polygon2ds that partially cover a non-leaf node are stored in each of the leaf nodes below that node that those Polygon2ds (partially) cover. Leaf nodes that cannot be expanded (because they are too small) also store all Polygon2ds that partially cover the area of the node.
If removal of a Polygon2d objects results in a leaf becoming empty, that leaf is removed from its parent (which may then itself become empty and removed in turn).

Copyright (c) 2013-2024 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel