Class RegionBSPTree2D.LinecastVisitor
- java.lang.Object
-
- org.apache.commons.geometry.euclidean.twod.RegionBSPTree2D.LinecastVisitor
-
- All Implemented Interfaces:
BSPTreeVisitor<Vector2D,RegionBSPTree2D.RegionNode2D>
- Enclosing class:
- RegionBSPTree2D
private static final class RegionBSPTree2D.LinecastVisitor extends java.lang.Object implements BSPTreeVisitor<Vector2D,RegionBSPTree2D.RegionNode2D>
BSP tree visitor that performs a linecast operation against the boundaries of the visited tree.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.commons.geometry.core.partitioning.bsp.BSPTreeVisitor
BSPTreeVisitor.ClosestFirstVisitor<P extends Point<P>,N extends BSPTree.Node<P,N>>, BSPTreeVisitor.FarthestFirstVisitor<P extends Point<P>,N extends BSPTree.Node<P,N>>, BSPTreeVisitor.Order, BSPTreeVisitor.Result, BSPTreeVisitor.TargetPointVisitor<P extends Point<P>,N extends BSPTree.Node<P,N>>
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
firstOnly
If true, the visitor will stop visiting the tree once the first linecast point is determined.private LineConvexSubset
linecastSubset
The line subset to intersect with the boundaries of the BSP tree.private double
minAbscissa
The minimum abscissa found during the search.private java.util.List<LinecastPoint2D>
results
List of results from the linecast operation.
-
Constructor Summary
Constructors Constructor Description LinecastVisitor(LineConvexSubset linecastSubset, boolean firstOnly)
Create a new instance with the given intersecting line subset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private LinecastPoint2D
computeLinecastPoint(Vector2D pt, RegionBSPTree2D.RegionNode2D node)
Compute the linecast point for the given intersection point and tree node, returning null if the point does not actually lie on the region boundary.LinecastPoint2D
getFirstResult()
Get the firstLinecastPoint2D
resulting from the linecast operation.java.util.List<LinecastPoint2D>
getResults()
Get a list containing the results of the linecast operation.BSPTreeVisitor.Result
visit(RegionBSPTree2D.RegionNode2D node)
Visit a node in a BSP tree.BSPTreeVisitor.Order
visitOrder(RegionBSPTree2D.RegionNode2D internalNode)
Determine the visit order for the given internal node.
-
-
-
Field Detail
-
linecastSubset
private final LineConvexSubset linecastSubset
The line subset to intersect with the boundaries of the BSP tree.
-
firstOnly
private final boolean firstOnly
If true, the visitor will stop visiting the tree once the first linecast point is determined.
-
minAbscissa
private double minAbscissa
The minimum abscissa found during the search.
-
results
private final java.util.List<LinecastPoint2D> results
List of results from the linecast operation.
-
-
Constructor Detail
-
LinecastVisitor
LinecastVisitor(LineConvexSubset linecastSubset, boolean firstOnly)
Create a new instance with the given intersecting line subset.- Parameters:
linecastSubset
- line subset to intersect with the BSP tree region boundaryfirstOnly
- if true, the visitor will stop visiting the tree once the first linecast point is determined
-
-
Method Detail
-
getFirstResult
public LinecastPoint2D getFirstResult()
Get the firstLinecastPoint2D
resulting from the linecast operation.- Returns:
- the first linecast result point
-
getResults
public java.util.List<LinecastPoint2D> getResults()
Get a list containing the results of the linecast operation. The list is sorted and filtered.- Returns:
- list of sorted and filtered results from the linecast operation
-
visitOrder
public BSPTreeVisitor.Order visitOrder(RegionBSPTree2D.RegionNode2D internalNode)
Determine the visit order for the given internal node. This is called for each internal node beforeBSPTreeVisitor.visit(BSPTree.Node)
is called. Returning null orBSPTreeVisitor.Order.NONE
from this method skips the subtree rooted at the given node. This method is not called on leaf nodes.- Specified by:
visitOrder
in interfaceBSPTreeVisitor<Vector2D,RegionBSPTree2D.RegionNode2D>
- Parameters:
internalNode
- the internal node to determine the visit order for- Returns:
- the order that the subtree rooted at the given node should be visited
-
visit
public BSPTreeVisitor.Result visit(RegionBSPTree2D.RegionNode2D node)
Visit a node in a BSP tree. This method is called for both internal nodes and leaf nodes.- Specified by:
visit
in interfaceBSPTreeVisitor<Vector2D,RegionBSPTree2D.RegionNode2D>
- Parameters:
node
- the node being visited- Returns:
- the result of the visit operation
-
computeLinecastPoint
private LinecastPoint2D computeLinecastPoint(Vector2D pt, RegionBSPTree2D.RegionNode2D node)
Compute the linecast point for the given intersection point and tree node, returning null if the point does not actually lie on the region boundary.- Parameters:
pt
- intersection pointnode
- node containing the cut that the linecast line intersected with- Returns:
- a new linecast point instance or null if the intersection point does not lie on the region boundary
-
-