Package org.opentrafficsim.core.geometry
Class OTS2DSet.QuadTreeNode
- java.lang.Object
-
- org.opentrafficsim.core.geometry.OTS2DSet.QuadTreeNode
-
- All Implemented Interfaces:
Serializable
- Enclosing class:
- OTS2DSet
class OTS2DSet.QuadTreeNode extends Object implements Serializable
Spatial-aware storage for a set of OTSShape objects.
-
-
Constructor Summary
Constructors Constructor Description QuadTreeNode(Rectangle2D boundingBox)Construct a new QuadTreeNode.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(OTSShape shape)Add an OTSShape to this QuadTreeNode.voidclear()Remove all OTSShapes from this QuadTreeNode and cut off all leaves.Set<OTSShape>intersectingShapes(Rectangle2D rectangle)Return a Set containing all OTSShapes in this QuadTreeNode that intersect a rectangular area.booleanintersects(OTSShape shape)Test if the area of this QuadTree intersects an OTSShape.booleanremove(OTSShape shape)Remove an OTSShape from this QuadTreeNode.StringtoString()(package private) StringtoString(int recursionDepth)Recursively print this QuadTreeNode.StringtoStringGraphic(int recursionDepth)Return a String depicting this QuadTreeNode.
-
-
-
Constructor Detail
-
QuadTreeNode
QuadTreeNode(Rectangle2D boundingBox)
Construct a new QuadTreeNode.- Parameters:
boundingBox- Rectangle2D; the bounding box of the area of the new QuadTreeNode
-
-
Method Detail
-
intersectingShapes
public Set<OTSShape> intersectingShapes(Rectangle2D rectangle)
Return a Set containing all OTSShapes in this QuadTreeNode that intersect a rectangular area.- Parameters:
rectangle- Rectangle2D; the area- Returns:
- Set<OTSShape>; the set
-
clear
public void clear()
Remove all OTSShapes from this QuadTreeNode and cut off all leaves.
-
remove
public boolean remove(OTSShape shape)
Remove an OTSShape from this QuadTreeNode.- Parameters:
shape- OTSShape; the shape that must be removed.- Returns:
- boolean; true if this node (or a sub-node) was altered; false otherwise
-
intersects
public boolean intersects(OTSShape shape)
Test if the area of this QuadTree intersects an OTSShape.- Parameters:
shape- OTSShape; the shape- Returns:
- boolean; true if the area of this QuadTree intersects the shape; false otherwise
-
add
public final boolean add(OTSShape shape)
Add an OTSShape to this QuadTreeNode.- Parameters:
shape- OTSShape; the shape- Returns:
- boolean; true if this QuadTreeNode changed as a result of this operation
-
toString
final String toString(int recursionDepth)
Recursively print this QuadTreeNode.- Parameters:
recursionDepth- int; maximum depth to recurse- Returns:
- String
-
toStringGraphic
public final String toStringGraphic(int recursionDepth)
Return a String depicting this QuadTreeNode.- Parameters:
recursionDepth- int; levels to recurse- Returns:
- String
-
-