LiangliangNan / Easy3D

A lightweight, easy-to-use, and efficient C++ library for processing and rendering 3D data
GNU General Public License v3.0
1.35k stars 243 forks source link

[Question] Clarification on specifics of Easy3D's KdTree data structure and algorithms #150

Closed joeybinz closed 1 year ago

joeybinz commented 1 year ago

I am trying to use Easy3D's Kd-Tree and then in turn visualize the results with Easy3D, however after reading the documentation a few things are unclear to me.

The find_closest_k_points() function accepts arguments for an address of a vector where index of the k nearest neighbors will be stored. What should this index be used on? Would this index be the same as the index stored in the vertices used by the point cloud to create the KdTree? Or is this index only usable with the KdTree itself?

More or less my question comes down to is there any easy way to use the the indexes that come from the result of find_closest_k_points() to get the vertices they are referencing in the original point cloud?

Thanks for any clarification or help!

LiangliangNan commented 1 year ago

You're right. The returned indices are the same as in the point cloud used for building the kdtree. To get the Vertex of a PointCloud or SurfaceMesh from the returned index, you can use, auto v = PointCloud::Vertex(index) auto v = SurfaceMesh::Vertex(index)