Interface KdTree

All Superinterfaces:
Serializable
All Known Implementing Classes:
KdTreeImpl

public interface KdTree extends Serializable
k-D tree for storing vertices (MeshPoints) of triangular (MeshFacets). Multiple mesh facets can be stored in a single kd-tree. In this case, vertices that are shared across multiple facets (have the same 3D location) are shared in the same node of the kd-tree.
  • Method Details

    • create

      static KdTree create(Set<MeshPoint> points)
      Creates a new k-D tree.
      Parameters:
      points - A set of individual mesh points. If no mesh points are provided, then an empty KD-tree is constructed (with the root node set to null).
      Returns:
      a new k-D tree
    • create

      static KdTree create(MeshModel mesh)
      Creates a new k-D tree. If no mesh points (vertices) are provided, then an empty k-D tree is constructed (with the root node set to null).
      Parameters:
      mesh - Mesh model
      Returns:
      a new k-D tree
    • create

      static KdTree create(MeshFacet facet)
      Creates a new k-D tree. If no mesh points (vertices) are provided, then an empty k-D tree is constructed (with the root node set to null).
      Parameters:
      facet - Mesh facet
      Returns:
      a new k-D tree
    • create

      static KdTree create(Collection<MeshFacet> facets)
      Creates a new k-D tree. If no mesh points (vertices) are provided, then an empty k-D tree is constructed (with the root node set to null). If multiple mesh facets share the same vertex, then they are stored efficiently in the same node of the k-D tree.
      Parameters:
      facets - The list of mesh facets to be stored. Facets can share vertices.
      Returns:
      a new k-D tree
    • getRoot

      KdNode getRoot()
      Tree traversal - go to the "root" of the tree.
      Returns:
      root node of the tree
    • addNode

      void addNode(MeshPoint meshPoint)
      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.
      Parameters:
      meshPoint - point to add
    • getNumNodes

      int getNumNodes()
      Return number of nodes in the k-d tree.
      Returns:
      number of nodes in the k-d tree
    • getDepth

      int getDepth()
      Return the length of the longest path.
      Returns:
      Return the length of the longest path.
    • accept

      void accept(KdTreeVisitor visitor)
      Visits this tree.
      Parameters:
      visitor - Visitor