Page 1 of 1

Code for searching neighborhood

Posted: Wed Jan 29, 2020 4:50 pm
by fblue
Hi,
I want to search the nearest point from a given point in a cloud. I've tried the code as following:
ccPointCloud* cloud = ccHObjectCaster::ToPointCloud(entity);
CCLib::ReferenceCloud* ref_cloud = new CCLib::ReferenceCloud(cloud);
CCVector3 point(200,100,100);
double distance_ = 0.01;
int test_index = cloud->getOctree()->findPointNeighbourhood(&point,ref_cloud,1,8,distance_);

Is that the correct way for searching the index of the nearest point ? I can't find out the document so I code it just by imagination. The code can be compiled but generates problem when running.
If it's wrong, so what's the method for searching nearest point index?
Thanks

Re: Code for searching neighborhood

Posted: Thu Jan 30, 2020 11:01 am
by fblue
I think I've figured it out.
In fact the return value is the number of nearest point and its index is stored in referenc Cloud.