Package org.opentrafficsim.core.geometry
Class Ots2dSet.QuadTreeNode
java.lang.Object
org.opentrafficsim.core.geometry.Ots2dSet.QuadTreeNode
- All Implemented Interfaces:
Serializable
- Enclosing class:
- Ots2dSet
Spatial-aware storage for a set of Polygon2d objects.
-
Constructor Summary
ConstructorDescriptionQuadTreeNode
(org.djutils.draw.bounds.Bounds2d boundingBox) Construct a new QuadTreeNode. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
add
(org.djutils.draw.line.Polygon2d shape) Add a Polygon2d to this QuadTreeNode.void
clear()
Remove all Polygon2ds from this QuadTreeNode and cut off all leaves.Set<org.djutils.draw.line.Polygon2d>
intersectingShapes
(org.djutils.draw.bounds.Bounds2d rectangle) Return a Set containing all Polygon2ds in this QuadTreeNode that intersect a rectangular area.boolean
intersects
(org.djutils.draw.line.Polygon2d shape) Test if the area of this QuadTree intersects a Polygon2d.boolean
remove
(org.djutils.draw.line.Polygon2d shape) Remove a Polygon2d from this QuadTreeNode.final String
toString()
(package private) final String
toString
(int recursionDepth) Recursively print this QuadTreeNode.final String
toStringGraphic
(int recursionDepth) Return a String depicting this QuadTreeNode.
-
Constructor Details
-
QuadTreeNode
QuadTreeNode(org.djutils.draw.bounds.Bounds2d boundingBox) Construct a new QuadTreeNode.- Parameters:
boundingBox
- Rectangle2D; the bounding box of the area of the new QuadTreeNode
-
-
Method Details
-
intersectingShapes
public Set<org.djutils.draw.line.Polygon2d> intersectingShapes(org.djutils.draw.bounds.Bounds2d rectangle) Return a Set containing all Polygon2ds in this QuadTreeNode that intersect a rectangular area.- Parameters:
rectangle
- Bounds2d; the area- Returns:
- Set<Polygon2d>; the set
-
clear
public void clear()Remove all Polygon2ds from this QuadTreeNode and cut off all leaves. -
remove
public boolean remove(org.djutils.draw.line.Polygon2d shape) Remove a Polygon2d from this QuadTreeNode.- Parameters:
shape
- Polygon2d; the shape that must be removed.- Returns:
- boolean; true if this node (or a sub-node) was altered; false otherwise
-
intersects
public boolean intersects(org.djutils.draw.line.Polygon2d shape) Test if the area of this QuadTree intersects a Polygon2d.- Parameters:
shape
- Polygon2d; the shape- Returns:
- boolean; true if the area of this QuadTree intersects the shape; false otherwise
-
add
public final boolean add(org.djutils.draw.line.Polygon2d shape) Add a Polygon2d to this QuadTreeNode.- Parameters:
shape
- Polygon2d; the shape- Returns:
- boolean; true if this QuadTreeNode changed as a result of this operation
-
toString
Recursively print this QuadTreeNode.- Parameters:
recursionDepth
- int; maximum depth to recurse- Returns:
- String
-
toString
-
toStringGraphic
Return a String depicting this QuadTreeNode.- Parameters:
recursionDepth
- int; levels to recurse- Returns:
- String
-