Class LeftBalancedKdTreeImpl
java.lang.Object
cz.fidentis.analyst.data.kdtree.impl.LeftBalancedKdTreeImpl
- All Implemented Interfaces:
KdTree
,LeftBalancedKdTree
,Serializable
Implementation of a left-balanced Kd-tree.
Resulting tree is stored in an array.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLeftBalancedKdTreeImpl
(Collection<MeshFacet> facets) Constructor, loads facets and builds tree. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(KdTreeVisitor visitor) Visits this tree.void
Method for adding independent point to existing tree.int
getDepth()
Return the length of the longest path.Gets the Kd-tree stored in an array.getLeftChild
(int index) Returns left child of node at index.List
<javax.vecmath.Point3d> Gets the Kd-tree as an array ofPoint3d
, instead ofLeftBalancedKdNode
.Gets the Kd-tree as an array ofMeshPoint
, instead ofLeftBalancedKdNode
.getNode
(int index) Returns node of the tree at the specified index of the tree array.int
Return number of nodes in the k-d tree.getRightChild
(int index) Returns right child of node at index.getRoot()
Tree traversal - go to the "root" of the tree.boolean
hasLeftChild
(int index) True if there exists a left child of node at index.boolean
hasRightChild
(int index) True if there exists a right child of node at index.
-
Constructor Details
-
LeftBalancedKdTreeImpl
Constructor, loads facets and builds tree.- Parameters:
facets
- MeshFacets from which the KdTree is built.
-
-
Method Details
-
getKdTreeArray
Description copied from interface:LeftBalancedKdTree
Gets the Kd-tree stored in an array.- Specified by:
getKdTreeArray
in interfaceLeftBalancedKdTree
- Returns:
- Kd-tree array.
-
getMeshPointsArray
Description copied from interface:LeftBalancedKdTree
Gets the Kd-tree as an array ofMeshPoint
, instead ofLeftBalancedKdNode
.- Specified by:
getMeshPointsArray
in interfaceLeftBalancedKdTree
- Returns:
- Kd-tree as an array of
MeshPoint
.
-
getLocationsArray
Description copied from interface:LeftBalancedKdTree
Gets the Kd-tree as an array ofPoint3d
, instead ofLeftBalancedKdNode
.- Specified by:
getLocationsArray
in interfaceLeftBalancedKdTree
- Returns:
- Kd-tree as an array of
Point3d
.
-
getRoot
Description copied from interface:KdTree
Tree traversal - go to the "root" of the tree. -
getNode
Description copied from interface:LeftBalancedKdTree
Returns node of the tree at the specified index of the tree array.- Specified by:
getNode
in interfaceLeftBalancedKdTree
- 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 interfaceLeftBalancedKdTree
- 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 interfaceLeftBalancedKdTree
- Parameters:
index
- - index of parent in kdTree array
-
getLeftChild
Description copied from interface:LeftBalancedKdTree
Returns left child of node at index.- Specified by:
getLeftChild
in interfaceLeftBalancedKdTree
- Parameters:
index
- - Index of node
-
getRightChild
Description copied from interface:LeftBalancedKdTree
Returns right child of node at index.- Specified by:
getRightChild
in interfaceLeftBalancedKdTree
- Parameters:
index
- - Index of node
-
addNode
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. -
getNumNodes
public int getNumNodes()Description copied from interface:KdTree
Return number of nodes in the k-d tree.- Specified by:
getNumNodes
in interfaceKdTree
- 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. -
accept
Description copied from interface:KdTree
Visits this tree.
-