您的位置:首页 > 其它

How to work with MeshLab's mesh

2011-05-13 21:42 483 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐