Question

I want to select a region of the mesh and get the IDs of the selected vertices, so that I can use them in my custom c++ processing pipeline.

For example if there is a 3d hand mesh, one can choose the vertices that belong to every fingertip. Getting the IDs of these vertices is very useful for several applications, like tracking, annimating, etc.

Meshlab obviously uses the IDs of these vertices under the hood, but can this info be exposed to the user? There are plenty of tutorials online about how to choose (in various ways) some region of a mesh and apply some processing function, but I didn't find something that talks about getting raw information about the selected area.

Was it helpful?

Solution 3

The solution that I found is rather tedious.

It seems that, although Meshlab obviously uses these IDs under the hood, this information is not exposed to the user. So I following this heuristic:

  • Choose the vertex of interest with the standard MeshLab tool.
  • Invert the selection.
  • Delete all vertices, and get an 1-point pointcloud/mesh as result.
  • Export this as an .off file.
  • Open the exported file and read the coordinates of this unique point. One coordinate (e.g. X) is enough.
  • Search in your original .off file or in the original mesh/pointcloud structure to find the point/vertex with this coordinate.
  • There you have it, you have the ID of the chosen vertex in the original structure.
  • Then (this is application specific, according to my needs), using PCL, I created a Kd-Tree for my pointcloud, used the selected points (red) as "query" to get some nearest neighbors (green).

Result:

enter image description here

OTHER TIPS

There are two ways to display the vertex id in MeshLab:

  • Render => Show Label, this will display the vertex id on each vertex.
  • Click the yellow "Get Info" button and then click on a triangle. If your mesh is dense, it's not really readable though.

Be careful about 0-based and 1-based indexing, I'm not sure what they're based on in MeshLab.

Update in 2017: With the new MeshLab version (2016.12), the output can be made more readable. After clicking the "Get Info" button, one can press Space to switch from face-picking to vertex-picking. Then you can press p to log the vertex id and coordinates to the small log window.

On the other hand, Render => Show Label doesn't work anymore, it gives an error CANNOT START DECORATOR: the layer contains too many faces and vertices..

use the "Get Info" button and follow the instruction on the left to press the "t" and select the vertex and press p.to select one vertex

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top