How to work with MeshLab's mesh

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值