spm_mesh_edges.m 757 B

12345678910111213141516171819202122232425
  1. function E = spm_mesh_edges(M)
  2. % Return edges of a surface mesh
  3. % FORMAT E = spm_mesh_edges(M)
  4. % M - a [nx3] faces array or a patch handle/structure
  5. %
  6. % E - a [mx2] edges array
  7. %__________________________________________________________________________
  8. % Copyright (C) 2010 Wellcome Trust Centre for Neuroimaging
  9. % Guillaume Flandin
  10. % $Id: spm_mesh_edges.m 4018 2010-07-27 18:22:42Z guillaume $
  11. %-Parse input arguments
  12. %--------------------------------------------------------------------------
  13. if ishandle(M)
  14. M = get(M,'Faces');
  15. elseif ~isnumeric(M)
  16. M = M.faces;
  17. end
  18. %-Compute edges
  19. %--------------------------------------------------------------------------
  20. M = sort(M,2);
  21. E = unique([M(:,[1 2]);M(:,[2 3]);M(:,[1 3])],'rows');