I have two vtkPoints sets; both have an equal number of points. The point sets resulted from resampling two more or less similar-looking polydatas (triangular meshes). My goal is to re-order the vertex indices of one of the point sets to morphologically match the other point set (i.e. template point set). So far, I was able to achieve this goal by manually selecting some corresponding points in both point sets and eventually superimposing them to reorder the ids of the target point set.
My question is, is there any way to do it without using superimposition procedures?
I don’t understand why the point id’s are important to have the same shape on both point sets… it looks like I didn’t understand the problem. Is it possible to illustrate the problem and what you want to achieve with a figure?
Thanks for the reply. Sorry if the problem was vague; I’m going to provide an example. I have two laser-scanned human faces (triangular meshes), one of which I call the template, and the other one is the target. I resampled (blue noise resampling) both the template and target to get, for example, 200 uniformly distributed vertices. The result of such resampling is two point sets which both have 200 vertices, and they cover the face in a similar pattern.
Now, in the resampled template, the vertex’s index on the tip of the nose is 70, while in the resampled target, the vertex’s index on the nose’s tip is 25. I’m trying to find a way to re-order the target indices so the nose landmark gets the same index (70).
I’m going to treat these vertices as corresponding landmarks and perform Procrustes superimposition via an automated procedure. Hopefully, this example clarified my problem a little more. The tip of the nose was an example; most of the points on the resampled target has different index from the resampled template.
That’s clearer now. Well, I know no way to do that in VTK in a single shot. Hence, you have to break down that into simpler tasks:
let output_ps := blank pointset;
For each point in reference_ps:
let pr := current point in reference_ps;
let p2 := second_ps.find_closest( pr );
output_ps.addpoint( p2 );
endFor
let second_ps := output_ps;
That way, you’ll have the second point set with collocated points with the same index order of the first point set. Now it’s up to you to translate that pseudocode into VTK calls.
Thank you very much for the idea; I appreciate it. The problem is that the template and target meshes were digitised separately, so they have different coordinate systems (meshes are far apart). So the closest point approach (vtk point locator or cell locator) won’t be a proper procedure unless I manually superimpose my meshes. Since the coordinate systems are sometimes rotated, even the automated methods of superimposition (such as ICP) don’t work most of the time.
From ages ago, I remember that Maya used to have a tool that could re-order vertex ids (it’s not an open source, so that I couldn’t see the algorithm behind that tool). I was hoping for a similar thing in vtk. I guess the optimal solution is manually superimposing my data (there are hundreds and hundreds of them, that’s why I was thinking about an automated procedure).
In that case, you need to pre-process the target mesh so they closely match in space and, hence, satisfies the algorithm’s pre-condition. This is an operation called point set registration (Point-set registration - Wikipedia). Chose one that only uses rigid transformations so the points’ relative distances remain the same.