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 type
N - 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 Details

    • 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 Details

    • AbstractRegionNode

      protected AbstractRegionNode(AbstractBSPTree<P,N> tree)
      Simple constructor.
      Parameters:
      tree - owning tree instance
  • Method Details

    • getTree

      public AbstractRegionBSPTree<P,N> getTree()
      Get the BSPTree that owns the node.
      Specified by:
      getTree in interface BSPTree.Node<P extends Point<P>,N extends AbstractRegionBSPTree.AbstractRegionNode<P,N>>
      Overrides:
      getTree in class AbstractBSPTree.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.

      Parameters:
      location - the location for the node
      Throws:
      IllegalArgumentException - if location is not one of INSIDE or OUTSIDE
    • isInside

      public boolean isInside()
      True if the node is a leaf node and has a location of RegionLocation.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 of RegionLocation.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 of RegionCutRule.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

      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 the HyperplaneConvexSubset 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 with
      cutRule - 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:
    • cut

      public N cut(Hyperplane<P> cutter, RegionCutRule cutRule)
      Cut this node with the given hyperplane, using cutRule 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 with
      cutRule - rule used to determine the region locations of newly created child nodes
      Returns:
      this node
      See Also:
    • 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, 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 characterize
      node - the node to characterize the hyperplane convex subset against
      in - list that will receive the portions of the subset that lie in the inside of the region; may be null
      out - list that will receive the portions of the subset that lie on the outside of the region; may be null
    • toString

      public String toString()
      Overrides:
      toString in class AbstractBSPTree.AbstractNode<P extends Point<P>,N extends AbstractRegionBSPTree.AbstractRegionNode<P,N>>
    • nodeInvalidated

      protected void nodeInvalidated()
      Method called from AbstractBSPTree.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 class AbstractBSPTree.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: