The next step is to understand how mesh works in MeshLab. MeshLab's defines a CMeshO class.
A CMeshO is a collection of vertices and triangular faces. A Face is (mainly) a three pointers structure to vertices that composed it. Every vertex could be referred by zero, one or more faces. A Vertex is (mainly) a class composed by a 3d point in space, a vertex- normal, a color and a 2d texture coordinates.
WARNING!!! to use vertex-texture coordinates you MUST first enable it, otherwise your plugin will crash!
You will find all the vertices in an c++ vector called vert, the edgess in a vector called edge and the faces in a vector called face.
Tipically a MeshLab plugin's function has a MeshModel parameter. A MeshModel contains a CMeshO you could refer to this instance via the cm MeshModel's member. In other words supposing you have a function with a MeshModel parameter called mymesh you could access to CMeshO vertices with:
mymesh.cm.vert[ii]; //ii is an unsigned int index to a particular vertex in the mesh
with:
mymesh.cm.face[ii]; //you can access to the ii face
and with:
mymesh.cm.face[ii].v(jj); //you will get the pointer to the jj vertex ( 0 <= jj < 3) in the ii face
vcglib also provides a way to simply and safely add and remove faces or vertices from a mesh.
vcg::tri::Allocator<CMeshO>::AddVertex(mymesh.cm,new vertex to be added); vcg::tri::Allocator<CMeshO>::AddFace(mymesh.cm,new face to be added);
The add functions are defined in the vcglib/vcg/complex/trimesh/allocate.h .
To enable texture coordinates per vertex (or for example quality for vertex) you MUST call the function:
mymesh.updateDataMask(MeshModel::MM_VERTTEXCOORD);
to test if the attribute is already enabled:
mymesh.hasDataMask(MeshModel::MM_VERTTEXCOORD);
Please note that you could use also a combination of attributes:
mymesh.updateDataMask(MeshModel::MM_VERTTEXCOORD | MeshModel::MM_FACEQUALITY);
If you need more detailed info about MeshLab/VCGLib mesh you could take a look to this link.