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

  • Method Details

    • 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

      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

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

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