[vtkusers] Find closest point
nuno.jf
nunofernandes7 at gmail.com
Sun Sep 18 09:42:06 EDT 2011
Dear Users,
I need to find the minimum distance between points from the same dataset.
So, considering one point P, I need to find the closest point to it (other
than P itself).
I began by using the following code in the examples:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/DataStructures/KdTreePointLocator/ClosestPoint
And I changed it to find the closest point to each point of my dataset:
int N = polydata -> GetNumberOfPoints();
double P[3];
for(double n = 0; n < N; n++)
{
polydata -> GetPoint( static_cast<vtkIdType>(n), P);
// Find the closest points to TestPoint
vtkIdType iD = kDTree->FindClosestPoint(P);
std::cout << "The closest point is point " << iD << std::endl;
//Get the coordinates of the closest point
double closestPoint[3];
kDTree->GetDataSet()->GetPoint(iD, closestPoint);
std::cout << "Coordinates: " << closestPoint[0] << " " << closestPoint[1]
<< " " << closestPoint[2] << std::endl;
}
The issue here is that the closest point I get corresponds to the point P (
that is, the point for which I want to calculate the distance).
How can I find the real closest point to a given point P without getting the
same point as a result?
Thank you in advance.
Nuno
--
View this message in context: http://vtk.1045678.n5.nabble.com/Find-closest-point-tp4816065p4816065.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list