Class RegionBSPTree2S
java.lang.Object
org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree<Point2S,RegionBSPTree2S.RegionNode2S>
org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree<Point2S,RegionBSPTree2S.RegionNode2S>
org.apache.commons.geometry.spherical.twod.RegionBSPTree2S
- All Implemented Interfaces:
BoundarySource<GreatArc>
,BSPSubtree<Point2S,
,RegionBSPTree2S.RegionNode2S> BSPTree<Point2S,
,RegionBSPTree2S.RegionNode2S> HyperplaneBoundedRegion<Point2S>
,Splittable<Point2S,
,HyperplaneBoundedRegion<Point2S>> Region<Point2S>
,Sized
,BoundarySource2S
public class RegionBSPTree2S
extends AbstractRegionBSPTree<Point2S,RegionBSPTree2S.RegionNode2S>
implements BoundarySource2S
BSP tree representing regions in 2D spherical space.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class
Class used to project points onto the region boundary.static final class
BSP tree node for two dimensional spherical space.Nested classes/interfaces inherited from class org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree
AbstractRegionBSPTree.AbstractRegionNode<P extends Point<P>,
N extends AbstractRegionBSPTree.AbstractRegionNode<P, N>>, AbstractRegionBSPTree.BoundaryProjector<P extends Point<P>, N extends AbstractRegionBSPTree.AbstractRegionNode<P, N>>, AbstractRegionBSPTree.RegionSizeProperties<P extends Point<P>> Nested classes/interfaces inherited from class org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree
AbstractBSPTree.AbstractNode<P extends Point<P>,
N extends AbstractBSPTree.AbstractNode<P, N>>, AbstractBSPTree.SubtreeInitializer<N extends AbstractBSPTree.AbstractNode<?, ?>> Nested classes/interfaces inherited from interface org.apache.commons.geometry.core.partitioning.bsp.BSPTree
BSPTree.FindNodeCutRule, BSPTree.Node<P extends Point<P>,
N extends BSPTree.Node<P, N>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate List
<GreatArcPath> List of great arc path comprising the region boundary.private static final double
Constant containing the area of the full spherical space. -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new, empty instance.RegionBSPTree2S
(boolean full) Create a new region. -
Method Summary
Modifier and TypeMethodDescriptionReturn anIterable
for iterating over the boundaries of the region.Return a stream containing the boundaries for this instance.private List
<GreatArcPath> Compute the great arc paths comprising the region boundary.Compute the size-related properties of the region.copy()
Return a deep copy of this instance.protected RegionBSPTree2S.RegionNode2S
Create a new node for this tree.static RegionBSPTree2S
empty()
Return a new, empty BSP tree.static RegionBSPTree2S
Construct a new tree from the given boundaries.static RegionBSPTree2S
Construct a new tree from the given boundaries.static RegionBSPTree2S
full()
Return a new, full BSP tree.Return a list containing the boundaries of the region.Get the boundary of the region as a list of connected great arc paths.protected void
Invalidate any previously computed properties that rely on the internal structure of the tree.Project a point onto the boundary of the region.split
(Hyperplane<Point2S> splitter) Split this instance with the given hyperplane.toConvex()
Return a list ofConvexArea2S
s representing the same region as this instance.private void
toConvexRecursive
(RegionBSPTree2S.RegionNode2S node, ConvexArea2S nodeArea, List<? super ConvexArea2S> result) Recursive method to compute the convex areas of all inside leaf nodes in the subtree rooted at the given node.toTree()
Return the current instance.Methods inherited from class org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree
classify, complement, complement, condense, copyNodeProperties, createBoundaryIterable, createBoundaryList, difference, difference, getBoundarySize, getCentroid, getRegionSizeProperties, getSize, getSubtreeInitializer, insert, insert, insert, insert, insert, insert, insert, insert, intersection, intersection, isEmpty, isFull, setEmpty, setFull, split, union, union, xor, xor
Methods inherited from class org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree
accept, accept, copy, copyNode, copySubtree, count, cutNode, extract, extractParentPath, findNode, findNode, getRoot, getVersion, height, importSubtree, insert, nodes, removeNodeCut, setNodeCut, setRoot, splitIntoTrees, splitSubtree, swapsInsideOutside, toString, transform, treeString, treeString, trimToNode
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.commons.geometry.spherical.twod.BoundarySource2S
toList
Methods inherited from interface org.apache.commons.geometry.core.Sized
isFinite, isInfinite
-
Field Details
-
FULL_SIZE
private static final double FULL_SIZEConstant containing the area of the full spherical space.- See Also:
-
boundaryPaths
List of great arc path comprising the region boundary.
-
-
Constructor Details
-
RegionBSPTree2S
public RegionBSPTree2S()Create a new, empty instance. -
RegionBSPTree2S
public RegionBSPTree2S(boolean full) Create a new region. Iffull
is true, then the region will represent the entire 2-sphere. Otherwise, it will be empty.- Parameters:
full
- whether or not the region should contain the entire 2-sphere or be empty
-
-
Method Details
-
copy
Return a deep copy of this instance.- Returns:
- a deep copy of this instance.
- See Also:
-
boundaries
Return anIterable
for iterating over the boundaries of the region. Each boundary is oriented such that its plus side points to the outside of the region. The exact ordering of the boundaries is determined by the internal structure of the tree.- Overrides:
boundaries
in classAbstractRegionBSPTree<Point2S,
RegionBSPTree2S.RegionNode2S> - Returns:
- an
Iterable
for iterating over the boundaries of the region - See Also:
-
boundaryStream
Return a stream containing the boundaries for this instance.- Specified by:
boundaryStream
in interfaceBoundarySource<GreatArc>
- Returns:
- a stream containing the boundaries for this instance
-
getBoundaries
Return a list containing the boundaries of the region. Each boundary is oriented such that its plus side points to the outside of the region. The exact ordering of the boundaries is determined by the internal structure of the tree.- Overrides:
getBoundaries
in classAbstractRegionBSPTree<Point2S,
RegionBSPTree2S.RegionNode2S> - Returns:
- a list of the boundaries of the region
-
getBoundaryPaths
Get the boundary of the region as a list of connected great arc paths. The arcs are oriented such that their minus (left) side lies on the interior of the region.- Returns:
- great arc paths representing the region boundary
-
toConvex
Return a list ofConvexArea2S
s representing the same region as this instance. One convex area is returned for each interior leaf node in the tree.- Returns:
- a list of convex areas representing the same region as this instance
-
toConvexRecursive
private void toConvexRecursive(RegionBSPTree2S.RegionNode2S node, ConvexArea2S nodeArea, List<? super ConvexArea2S> result) Recursive method to compute the convex areas of all inside leaf nodes in the subtree rooted at the given node. The computed convex areas are added to the given list.- Parameters:
node
- root of the subtree to compute the convex areas fornodeArea
- the convex area for the current node; this will be split by the node's cut hyperplane to form the convex areas for any child nodesresult
- list containing the results of the computation
-
split
Split this instance with the given hyperplane.- Specified by:
split
in interfaceSplittable<Point2S,
HyperplaneBoundedRegion<Point2S>> - Parameters:
splitter
- the hyperplane to split this object with.- Returns:
- result of the split operation
-
project
Project a point onto the boundary of the region. Null is returned if the region contains no boundaries (ie, is eitherfull
orempty
).- Specified by:
project
in interfaceRegion<Point2S>
- Overrides:
project
in classAbstractRegionBSPTree<Point2S,
RegionBSPTree2S.RegionNode2S> - Parameters:
pt
- pt to project- Returns:
- projection of the point on the boundary of the region or null if the region does not contain any boundaries
-
toTree
Return the current instance.- Specified by:
toTree
in interfaceBoundarySource2S
- Returns:
- a BSP tree constructed from the boundaries in this instance
-
computeRegionSizeProperties
Compute the size-related properties of the region.- Specified by:
computeRegionSizeProperties
in classAbstractRegionBSPTree<Point2S,
RegionBSPTree2S.RegionNode2S> - Returns:
- object containing size properties for the region
-
createNode
Create a new node for this tree.- Specified by:
createNode
in classAbstractBSPTree<Point2S,
RegionBSPTree2S.RegionNode2S> - Returns:
- a new node for this tree
-
invalidate
protected void invalidate()Invalidate any previously computed properties that rely on the internal structure of the tree. This method must be called any time the tree's internal structure changes in order to force cacheable tree and node properties to be recomputed the next time they are requested.This method increments the tree's
AbstractBSPTree.version
property.- Overrides:
invalidate
in classAbstractRegionBSPTree<Point2S,
RegionBSPTree2S.RegionNode2S> - See Also:
-
computeBoundaryPaths
Compute the great arc paths comprising the region boundary.- Returns:
- the great arc paths comprising the region boundary
-
empty
Return a new, empty BSP tree.- Returns:
- a new, empty BSP tree.
-
full
Return a new, full BSP tree. The returned tree represents the full space.- Returns:
- a new, full BSP tree.
-
from
Construct a new tree from the given boundaries. If no boundaries are present, the returned tree is empty.- Parameters:
boundaries
- boundaries to construct the tree from- Returns:
- a new tree instance constructed from the given boundaries
- See Also:
-
from
Construct a new tree from the given boundaries. Iffull
is true, then the initial tree before boundary insertion contains the entire space. Otherwise, it is empty.- Parameters:
boundaries
- boundaries to construct the tree fromfull
- if true, the initial tree will contain the entire space- Returns:
- a new tree instance constructed from the given boundaries
-