mesh_vertex_neighbours - find all immediate neighbours of a vertex [nI,nXYZ,nD] = mesh_vertex_neighbours(FV,index) FV is a struct with fields: FV.vertices - Nx3 matrix of Cartesian vertex coordindates (X,Y,Z) FV.faces - Mx3 matrix of triangulation of FV.vertices FV.edge - NxN sparse matrix of edge lengths (see mesh_edges) [nI,nXYZ,nD] - vertex neighbour Indices, XYZ coordinates and Distance from vertex
0001 function [nI,nXYZ,nD] = mesh_vertex_neighbours(FV,index), 0002 0003 % mesh_vertex_neighbours - find all immediate neighbours of a vertex 0004 % 0005 % [nI,nXYZ,nD] = mesh_vertex_neighbours(FV,index) 0006 % 0007 % FV is a struct with fields: 0008 % 0009 % FV.vertices - Nx3 matrix of Cartesian vertex coordindates (X,Y,Z) 0010 % FV.faces - Mx3 matrix of triangulation of FV.vertices 0011 % FV.edge - NxN sparse matrix of edge lengths (see mesh_edges) 0012 % 0013 % [nI,nXYZ,nD] - vertex neighbour Indices, XYZ coordinates and Distance 0014 % from vertex 0015 % 0016 0017 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:35 $ 0018 0019 % Licence: GNU GPL, no implied or express warranties 0020 % History: 04/2004, Darren.Weber_at_radiology.ucsf.edu 0021 % 0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0023 0024 0025 if ~exist('index','var'), 0026 fprintf('...no index specified, using vertex 1\n'); 0027 index = 1; 0028 end 0029 if isempty(index), 0030 fprintf('...no index specified, using vertex 1\n'); 0031 index = 1; 0032 end 0033 0034 if ~isfield(FV,'edge'), 0035 FV.edge = mesh_edges(FV); 0036 end 0037 0038 Nvert = size(FV.vertices,1); 0039 0040 fprintf('...finding vertex neighbours...'); tic; 0041 0042 % the indices of the neighbours 0043 nI = find(FV.edge(index,:))'; 0044 0045 % the coordinates of the neighbours 0046 nXYZ = FV.vertices(nI,:); 0047 0048 % only return unique vertex coordinates 0049 %[nXYZ, i, j] = unique(FV.vertices(nI,:),'rows'); 0050 0051 % extract neighbour edge lengths 0052 nD = full(FV.edge(index,nI))'; 0053 0054 0055 t = toc; fprintf('done (%5.2f sec).\n',t); 0056 0057 return