I am trying to implement the ICP improvement that only uses points which have a closest point closer than some threshold in the landmark transform. It looked like it would be easy to do - here's what I came up with. (The commented lines are what I changed.)<br>
<br>The old version found the closest point to every point in 'a' and stored them in 'closestp'. Then it used 'a' and 'closestp' to create the landmark transform.<br>The new version finds the closest point to every point in 'a'. If the distance is less than the threshold, it adds a[i] to 'UsedPoints' and adds the closest point to 'closestp'. It then uses 'UsedPoints' and 'closestp' to create the lankmark transform. Nothing else is changed - with the idea being that 'a' will still be what is actually getting transformed.<br>
<br>---------------------------<br>vtkPoints *closestp = vtkPoints::New();<br>vtkPoints *UsedPoints = vtkPoints::New();<br><br>//clear the array used to create the landmark transform<br> closestp->SetNumberOfPoints(0);<br>
UsedPoints->SetNumberOfPoints(0);<br><br>
// Fill closestp and UsedPoints with the closest points to each vertex in input if they are sufficiently close<br> for(i = 0; i < nb_points; i++)<br> {<br> this->Locator->FindClosestPoint(a->GetPoint(i),<br>
outPoint,<br> cell_id,<br> sub_id,<br>
dist2);<br> //closestp->SetPoint(i, outPoint);<br> if(dist2 < Thresh_)<br> {<br> closestp->InsertNextPoint(outPoint);<br> UsedPoints->InsertNextPoint(a->GetPoint(i)); <br>
}<br>}<br> <br>// Build the landmark transform<br><br>// this->LandmarkTransform->SetSourceLandmarks(a);<br>// this->LandmarkTransform->SetTargetLandmarks(closestp);<br> this->LandmarkTransform->SetSourceLandmarks(UsedPoints);<br>
this->LandmarkTransform->SetTargetLandmarks(closestp);<br> this->LandmarkTransform->Update();<br><br>---------------------------<br>What happens is that in each iteration, the number of points used decreases until it eventually gets to zero. I am using two polydata's which are very close to each other and identical as the test source and target, so the number of points used should certainly not decrease. I have a feeling it is something to do with how the LandmarkTransform stores the vtkPoints data? Does anyone see the problem with this?<br>
<br clear="all">Thanks,<br><br>David<br>