Class AbstractRegionBSPTree.AbstractRegionNode<P extends Point<P>,N extends AbstractRegionBSPTree.AbstractRegionNode<P,N>>
java.lang.Object
org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree.AbstractNode<P,N>
org.apache.commons.geometry.core.partitioning.bsp.AbstractRegionBSPTree.AbstractRegionNode<P,N>
- Type Parameters:
P- Point implementation typeN- BSP tree node implementation type
- All Implemented Interfaces:
BSPSubtree<P,,N> BSPTree.Node<P,N>
- Direct Known Subclasses:
RegionBSPTree1D.RegionNode1D,RegionBSPTree1S.RegionNode1S,RegionBSPTree2D.RegionNode2D,RegionBSPTree2S.RegionNode2S,RegionBSPTree3D.RegionNode3D
- Enclosing class:
AbstractRegionBSPTree<P extends Point<P>,N extends AbstractRegionBSPTree.AbstractRegionNode<P, N>>
public abstract static class AbstractRegionBSPTree.AbstractRegionNode<P extends Point<P>,N extends AbstractRegionBSPTree.AbstractRegionNode<P,N>>
extends AbstractBSPTree.AbstractNode<P,N>
BSPTree.Node implementation for use with AbstractRegionBSPTrees.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate RegionCutBoundary<P> Object representing the part of the node cut hyperplane subset that lies on the region boundary.private RegionLocationThe location for the node. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRegionNode(AbstractBSPTree<P, N> tree) Simple constructor. -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcharacterizeHyperplaneSubset(HyperplaneConvexSubset<P> sub, AbstractRegionBSPTree.AbstractRegionNode<P, N> node, List<? super HyperplaneConvexSubset<P>> in, List<? super HyperplaneConvexSubset<P>> out) Recursive method to characterize a hyperplane convex subset with respect to the region's boundaries.booleanclearCut()Remove the cut from this node.private RegionCutBoundary<P> Compute the portion of the node's cut that lies on the boundary of the region.cut(Hyperplane<P> cutter) Cut this node with the given hyperplane.cut(Hyperplane<P> cutter, RegionCutRule cutRule) Cut this node with the given hyperplane, usingcutRuleto determine the region locations of any new child nodes.Get the portion of the node's cut that lies on the boundary of the region.Get the location property of the node.getTree()Get theBSPTreethat owns the node.booleaninsertCut(Hyperplane<P> cutter) Insert a cut into this node, using the default region cut rule ofRegionCutRule.MINUS_INSIDE.booleaninsertCut(Hyperplane<P> cutter, RegionCutRule cutRule) Insert a cut into this node.booleanisInside()True if the node is a leaf node and has a location ofRegionLocation.INSIDE.booleanTrue if the node is a leaf node and has a location ofRegionLocation.OUTSIDE.protected voidMethod called fromAbstractBSPTree.AbstractNode.checkValid()when updates are detected in the tree.voidsetLocation(RegionLocation location) Set the location property for the node.protected voidsetLocationValue(RegionLocation locationValue) Directly set the value of the location property for the node.toString()Methods inherited from class org.apache.commons.geometry.core.partitioning.bsp.AbstractBSPTree.AbstractNode
accept, checkValid, count, depth, getCut, getCutHyperplane, getMinus, getParent, getPlus, getSelf, height, isInternal, isLeaf, isMinus, isPlus, makeRoot, nodes, setSubtree, trim
-
Field Details
-
location
The location for the node. This will only be set on leaf nodes. -
cutBoundary
Object representing the part of the node cut hyperplane subset that lies on the region boundary. This is calculated lazily and is only present on internal nodes.
-
-
Constructor Details
-
AbstractRegionNode
Simple constructor.- Parameters:
tree- owning tree instance
-
-
Method Details
-
getTree
Get theBSPTreethat owns the node.- Specified by:
getTreein interfaceBSPTree.Node<P extends Point<P>,N extends AbstractRegionBSPTree.AbstractRegionNode<P, N>> - Overrides:
getTreein classAbstractBSPTree.AbstractNode<P extends Point<P>,N extends AbstractRegionBSPTree.AbstractRegionNode<P, N>> - Returns:
- the owning tree
-
getLocation
Get the location property of the node. Only the locations of leaf nodes are meaningful as they relate to the region represented by the BSP tree. For example, changing the location of an internal node will only affect the geometric properties of the region if the node later becomes a leaf node.- Returns:
- the location of the node
-
setLocation
Set the location property for the node. If the location is changed, the tree is invalidated.Only the locations of leaf nodes are meaningful as they relate to the region represented by the BSP tree. For example, changing the location of an internal node will only affect the geometric properties of the region if the node later becomes a leaf node.
- Parameters:
location- the location for the node- Throws:
IllegalArgumentException- iflocationis not one ofINSIDEorOUTSIDE
-
isInside
public boolean isInside()True if the node is a leaf node and has a location ofRegionLocation.INSIDE.- Returns:
- true if the node is a leaf node and has a location of
RegionLocation.INSIDE
-
isOutside
public boolean isOutside()True if the node is a leaf node and has a location ofRegionLocation.OUTSIDE.- Returns:
- true if the node is a leaf node and has a location of
RegionLocation.OUTSIDE
-
insertCut
Insert a cut into this node, using the default region cut rule ofRegionCutRule.MINUS_INSIDE.- Parameters:
cutter- the hyperplane to cut the node's region with- Returns:
- true if the cutting hyperplane intersected the node's region, resulting in the creation of new child nodes
- See Also:
-
insertCut
Insert a cut into this node. If the given hyperplane intersects this node's region, then the node's cut is set to theHyperplaneConvexSubsetrepresenting the intersection, new plus and minus child leaf nodes are assigned, and true is returned. If the hyperplane does not intersect the node's region, then the node's cut and plus and minus child references are all set to null (ie, it becomes a leaf node) and false is returned. In either case, any existing cut and/or child nodes are removed by this method.- Parameters:
cutter- the hyperplane to cut the node's region withcutRule- rule used to determine the region locations of newly created child nodes- Returns:
- true if the cutting hyperplane intersected the node's region, resulting in the creation of new child nodes
-
clearCut
public boolean clearCut()Remove the cut from this node. Returns true if the node previously had a cut.- Returns:
- true if the node had a cut before the call to this method
-
cut
Cut this node with the given hyperplane. The same node is returned, regardless of the outcome of the cut operation. If the operation succeeded, then the node will have plus and minus child nodes.- Parameters:
cutter- the hyperplane to cut the node's region with- Returns:
- this node
- See Also:
-
cut
Cut this node with the given hyperplane, usingcutRuleto determine the region locations of any new child nodes. The same node is returned, regardless of the outcome of the cut operation. If the operation succeeded, then the node will have plus and minus child nodes.- Parameters:
cutter- the hyperplane to cut the node's region withcutRule- rule used to determine the region locations of newly created child nodes- Returns:
- this node
- See Also:
-
getCutBoundary
Get the portion of the node's cut that lies on the boundary of the region.- Returns:
- the portion of the node's cut that lies on the boundary of the region
-
computeBoundary
Compute the portion of the node's cut that lies on the boundary of the region. This method must only be called on internal nodes.- Returns:
- object representing the portions of the node's cut that lie on the region's boundary
-
characterizeHyperplaneSubset
private void characterizeHyperplaneSubset(HyperplaneConvexSubset<P> sub, AbstractRegionBSPTree.AbstractRegionNode<P, N> node, List<? super HyperplaneConvexSubset<P>> in, List<? super HyperplaneConvexSubset<P>> out) Recursive method to characterize a hyperplane convex subset with respect to the region's boundaries.- Parameters:
sub- the hyperplane convex subset to characterizenode- the node to characterize the hyperplane convex subset againstin- list that will receive the portions of the subset that lie in the inside of the region; may be nullout- list that will receive the portions of the subset that lie on the outside of the region; may be null
-
toString
- Overrides:
toStringin classAbstractBSPTree.AbstractNode<P extends Point<P>,N extends AbstractRegionBSPTree.AbstractRegionNode<P, N>>
-
nodeInvalidated
protected void nodeInvalidated()Method called fromAbstractBSPTree.AbstractNode.checkValid()when updates are detected in the tree. This method should clear out any computed properties that rely on the structure of the tree and prepare them for recalculation.- Overrides:
nodeInvalidatedin classAbstractBSPTree.AbstractNode<P extends Point<P>,N extends AbstractRegionBSPTree.AbstractRegionNode<P, N>>
-
setLocationValue
Directly set the value of the location property for the node. No input validation is performed and the tree is not invalidated.- Parameters:
locationValue- the new location value for the node- See Also:
-