Class TriangleKdTreeImpl
java.lang.Object
cz.fidentis.analyst.data.kdtree.impl.TriangleKdTreeImpl
- All Implemented Interfaces:
KdTree
,TriangleKdTree
,Serializable
!!!EXPERIMENTAL!!!
Class for building a kd-tree for storing
MeshTriangles
.
Triangles are only stored in leafs.
Triangles which intersect splitting plane are stored in both children.
Terminating condition for leafs is the maximum number of triangles stored in them (default 128).
leafSize
determines the size of work-group if using GPU for vertex-to-triangle NN search.
If not using GPU, disregard this message.
DEPENDS ON HARDWARE! Usually must be a multiple of 32. The higher the number, the better the performance
(But probably better to use bruteforce at that point).
On RTX 4060 TI - max 128 tested, on Intel UHD 620 - max 256 tested.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTriangleKdTreeImpl
(Collection<MeshFacet> facets) Constructor.TriangleKdTreeImpl
(List<MeshTriangle> triangles) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(KdTreeVisitor visitor) Visits this tree.void
Method for adding independent point to existing tree.getClosestLeaf
(javax.vecmath.Point3d point) Traverses tree from root to the leaf closest topoint
.int
getDepth()
Return the length of the longest path.getLeafFromNode
(javax.vecmath.Point3d point, TriangleKdNode rootNode) Traverses tree from specified node to the leaf closest topoint
.int
Getter for maximum leaf size.int
Return number of nodes in the k-d tree.getRoot()
Tree traversal - go to the "root" of the tree.
-
Constructor Details
-
TriangleKdTreeImpl
Constructor.- Parameters:
triangles
- List ofMeshTriangle
from which the tree is built.
-
TriangleKdTreeImpl
Constructor. Extracts triangles from all MeshFacets and builds tree from them.- Parameters:
facets
- Collection ofMeshFacet
-
-
Method Details
-
getRoot
Description copied from interface:KdTree
Tree traversal - go to the "root" of the tree. -
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. -
getLeafSize
public int getLeafSize()Description copied from interface:TriangleKdTree
Getter for maximum leaf size. Used for the size of work-group on GPU.- Specified by:
getLeafSize
in interfaceTriangleKdTree
- Returns:
- Maximum leaf size.
-
getClosestLeaf
Traverses tree from root to the leaf closest topoint
.- Specified by:
getClosestLeaf
in interfaceTriangleKdTree
- Parameters:
point
- Point to which to find the closest leaf.- Returns:
- Leaf node closest to
point
-
getLeafFromNode
Traverses tree from specified node to the leaf closest topoint
.- Specified by:
getLeafFromNode
in interfaceTriangleKdTree
- Parameters:
point
- Point to which to find the closest leaf.rootNode
- Node from which to start traversal.- Returns:
- Leaf node closest to
point
-