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 withAbstractRegionBSPTree
s.
-
-
Field Summary
Fields Modifier and Type Field Description private RegionCutBoundary<P>
cutBoundary
Object representing the part of the node cut hyperplane subset that lies on the region boundary.private RegionLocation
location
The location for the node.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractRegionNode(AbstractBSPTree<P,N> tree)
Simple constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
characterizeHyperplaneSubset(HyperplaneConvexSubset<P> sub, AbstractRegionBSPTree.AbstractRegionNode<P,N> node, java.util.List<? super HyperplaneConvexSubset<P>> in, java.util.List<? super HyperplaneConvexSubset<P>> out)
Recursive method to characterize a hyperplane convex subset with respect to the region's boundaries.boolean
clearCut()
Remove the cut from this node.private RegionCutBoundary<P>
computeBoundary()
Compute the portion of the node's cut that lies on the boundary of the region.N
cut(Hyperplane<P> cutter)
Cut this node with the given hyperplane.N
cut(Hyperplane<P> cutter, RegionCutRule cutRule)
Cut this node with the given hyperplane, usingcutRule
to determine the region locations of any new child nodes.RegionCutBoundary<P>
getCutBoundary()
Get the portion of the node's cut that lies on the boundary of the region.RegionLocation
getLocation()
Get the location property of the node.AbstractRegionBSPTree<P,N>
getTree()
Get theBSPTree
that owns the node.boolean
insertCut(Hyperplane<P> cutter)
Insert a cut into this node, using the default region cut rule ofRegionCutRule.MINUS_INSIDE
.boolean
insertCut(Hyperplane<P> cutter, RegionCutRule cutRule)
Insert a cut into this node.boolean
isInside()
True if the node is a leaf node and has a location ofRegionLocation.INSIDE
.boolean
isOutside()
True if the node is a leaf node and has a location ofRegionLocation.OUTSIDE
.protected void
nodeInvalidated()
Method called fromAbstractBSPTree.AbstractNode.checkValid()
when updates are detected in the tree.void
setLocation(RegionLocation location)
Set the location property for the node.protected void
setLocationValue(RegionLocation locationValue)
Directly set the value of the location property for the node.java.lang.String
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 Detail
-
location
private RegionLocation location
The location for the node. This will only be set on leaf nodes.
-
cutBoundary
private RegionCutBoundary<P extends Point<P>> 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 Detail
-
AbstractRegionNode
protected AbstractRegionNode(AbstractBSPTree<P,N> tree)
Simple constructor.- Parameters:
tree
- owning tree instance
-
-
Method Detail
-
getTree
public AbstractRegionBSPTree<P,N> getTree()
Get theBSPTree
that owns the node.- Specified by:
getTree
in interfaceBSPTree.Node<P extends Point<P>,N extends AbstractRegionBSPTree.AbstractRegionNode<P,N>>
- Overrides:
getTree
in classAbstractBSPTree.AbstractNode<P extends Point<P>,N extends AbstractRegionBSPTree.AbstractRegionNode<P,N>>
- Returns:
- the owning tree
-
getLocation
public RegionLocation 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
public void setLocation(RegionLocation location)
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.
-
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
public boolean insertCut(Hyperplane<P> cutter)
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(Hyperplane, RegionCutRule)
-
insertCut
public boolean insertCut(Hyperplane<P> cutter, RegionCutRule cutRule)
Insert a cut into this node. If the given hyperplane intersects this node's region, then the node's cut is set to theHyperplaneConvexSubset
representing 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
public N cut(Hyperplane<P> cutter)
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:
insertCut(Hyperplane)
-
cut
public N cut(Hyperplane<P> cutter, RegionCutRule cutRule)
Cut this node with the given hyperplane, usingcutRule
to 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:
insertCut(Hyperplane, RegionCutRule)
-
getCutBoundary
public RegionCutBoundary<P> 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
private RegionCutBoundary<P> 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, java.util.List<? super HyperplaneConvexSubset<P>> in, java.util.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
public java.lang.String toString()
- Overrides:
toString
in 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:
nodeInvalidated
in classAbstractBSPTree.AbstractNode<P extends Point<P>,N extends AbstractRegionBSPTree.AbstractRegionNode<P,N>>
-
setLocationValue
protected void setLocationValue(RegionLocation locationValue)
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:
setLocation(RegionLocation)
-
-