Destroying Elements

Lazy deletion strategy.

Note that the two basic deletion strategies are very low level functions. They simply mark as deleted the corresponding entries without affecting the rest of the structures. So for example if you delete a vertex with these structures without checking that all the faces incident on it have been removed you create a non consistent situation…

Similarly, but less dangerously, when you delete a face its vertices are left around so at the end you can have unreferenced floating vertices.

In some situations, particularly when you have to loop many many times over the element of the mesh without deleting/creating anything, it can be practical and convenient to get rid of deleted elements by explicitly calling the two garbage collecting functions:

After calling these function it is safe to not check the IsD() state of every element and always holds that:

m.vert.size() == m.vn
m.face.size() == m.fn

Note that if there are no deleted elements in your mesh, the compactor functions returns immediately.

Adjacency relations

VCG meshes DO NOT store edges, only vertex and triangles. Even the basic adjacdncy relations has to be explicitly computed. We always try to do not store per-edge information and keep them only more or less implicitly. This is simply there are many algorithms that do not require it and the cost of updating/storing should be avoided when possible. In many cases algorithms that seems based on some kind

Counting border edges (without topology)

Typical example are border flags. Each face keep a bit for each of its sides saying if that face has a boundary on that side or not. This information can be accessed by mean of the IsB(i) function. To compute the border flags there are various algorithm according to the available topological informations.