Class LeftBalancedKdTreeImpl

java.lang.Object
cz.fidentis.analyst.data.kdtree.impl.LeftBalancedKdTreeImpl
All Implemented Interfaces:
KdTree, LeftBalancedKdTree, Serializable

public class LeftBalancedKdTreeImpl extends Object implements LeftBalancedKdTree
Implementation of a left-balanced Kd-tree. Resulting tree is stored in an array.
See Also:
  • Constructor Details

    • LeftBalancedKdTreeImpl

      public LeftBalancedKdTreeImpl(Collection<MeshFacet> facets)
      Constructor, loads facets and builds tree.
      Parameters:
      facets - MeshFacets from which the KdTree is built.
  • Method Details

    • getKdTreeArray

      public List<LeftBalancedKdNode> getKdTreeArray()
      Description copied from interface: LeftBalancedKdTree
      Gets the Kd-tree stored in an array.
      Specified by:
      getKdTreeArray in interface LeftBalancedKdTree
      Returns:
      Kd-tree array.
    • getMeshPointsArray

      public List<MeshPoint> getMeshPointsArray()
      Description copied from interface: LeftBalancedKdTree
      Gets the Kd-tree as an array of MeshPoint, instead of LeftBalancedKdNode.
      Specified by:
      getMeshPointsArray in interface LeftBalancedKdTree
      Returns:
      Kd-tree as an array of MeshPoint.
    • getLocationsArray

      public List<javax.vecmath.Point3d> getLocationsArray()
      Description copied from interface: LeftBalancedKdTree
      Gets the Kd-tree as an array of Point3d, instead of LeftBalancedKdNode.
      Specified by:
      getLocationsArray in interface LeftBalancedKdTree
      Returns:
      Kd-tree as an array of Point3d.
    • getRoot

      public LeftBalancedKdNode getRoot()
      Description copied from interface: KdTree
      Tree traversal - go to the "root" of the tree.
      Specified by:
      getRoot in interface KdTree
      Returns:
      root node of the tree
    • getNode

      public LeftBalancedKdNode getNode(int index)
      Description copied from interface: LeftBalancedKdTree
      Returns node of the tree at the specified index of the tree array.
      Specified by:
      getNode in interface LeftBalancedKdTree
      Parameters:
      index - - Index of node
    • hasLeftChild

      public boolean hasLeftChild(int index)
      Description copied from interface: LeftBalancedKdTree
      True if there exists a left child of node at index.
      Specified by:
      hasLeftChild in interface LeftBalancedKdTree
      Parameters:
      index - - index of parent in kdTree array
    • hasRightChild

      public boolean hasRightChild(int index)
      Description copied from interface: LeftBalancedKdTree
      True if there exists a right child of node at index.
      Specified by:
      hasRightChild in interface LeftBalancedKdTree
      Parameters:
      index - - index of parent in kdTree array
    • getLeftChild

      public LeftBalancedKdNode getLeftChild(int index)
      Description copied from interface: LeftBalancedKdTree
      Returns left child of node at index.
      Specified by:
      getLeftChild in interface LeftBalancedKdTree
      Parameters:
      index - - Index of node
    • getRightChild

      public LeftBalancedKdNode getRightChild(int index)
      Description copied from interface: LeftBalancedKdTree
      Returns right child of node at index.
      Specified by:
      getRightChild in interface LeftBalancedKdTree
      Parameters:
      index - - Index of node
    • addNode

      public void addNode(MeshPoint meshPoint)
      Description copied from interface: KdTree
      Method for adding independent point to existing tree. The balance of the tree is not guaranteed after adding elements, it depends on the distribution of the added points. It can create long linear branches. In Poisson disk sub-sampling, where this method is used, it isn't a problem.
      Specified by:
      addNode in interface KdTree
      Parameters:
      meshPoint - point to add
    • getNumNodes

      public int getNumNodes()
      Description copied from interface: KdTree
      Return number of nodes in the k-d tree.
      Specified by:
      getNumNodes in interface KdTree
      Returns:
      number of nodes in the k-d tree
    • getDepth

      public int getDepth()
      Description copied from interface: KdTree
      Return the length of the longest path.
      Specified by:
      getDepth in interface KdTree
      Returns:
      Return the length of the longest path.
    • accept

      public void accept(KdTreeVisitor visitor)
      Description copied from interface: KdTree
      Visits this tree.
      Specified by:
      accept in interface KdTree
      Parameters:
      visitor - Visitor