Easy. Assume that tess is an nx4 array, composed of references into the set of vertices.
Then surely is it true that:
facets = [tess(:,[1 2 3]);tess(:,[1 2 4]);tess(:,[1 3 4]);tess(:,[2 3 4])];
is a set of facets of those simplexes? So facets is the set of triangular facets as requested. But I think you asked for the outer boundary surface of the mesh.
The only problem is that some of those facets are replicated. That is, facets that are shared between a pair of touching simplexes will happen exactly twice. A facet that is on the surface will occur exactly once.
But in fact, these replicates are actually a good thing! If you are only looking for the surface triangulation, then you can discard those facets that occurred twice. It is important to sort them though. (Think! why?)
Now, how do we discard those duplicated?
facets = sortrows(facets);
duploc = find(all(diff(facets) == 0,2));
facets([duploc;duploc + 1],:) = [];
Best Answer