I often need to represent geometries by parsing STL as triangular meshes. Often plotting the geometry as a surf or trisurf plot does not do well to describe certain features, especially when in my applications, the geometries can become extremely large. Often the surfaces are very simple but have distinct holes/cuts/edges that I'd like to highlight. To do this I just detect all the edges and plot the eges that aren't shared with other triangles.
In the following example, I detect the edges of a peaks surface and plot as a 3D line:
N = 1e3;
[x,y] = meshgrid(1:N,1:N);
con = delaunay(x,y);
z = peaks(N);
M = [con(:,[1,2]) ; con(:,[2,3]); con(:,[3,1])];
[u,~,n] = unique(sort(M,2),'rows');
counts = accumarray(n(:), 1);
O = u(counts==1,:);
I = O(:,1:2)';
[x0,y0,z0] = deal(x(I),y(I),z(I));
Aside from potentially being able to improve performance, I'd like to be able to plot the edge as a single object such that it could be labeled in the legend, and automatically detected if a surface contained several boundaries or holes.