Find member vertex near the root point & make member list [member_id] = vb_find_near_member(xxF, xxD, Vindx, Rmax, Ndisp) --- Input xxF{i} : Next-neighbor index that share the same triangle xxD{i} : Distance between next-neighbor and the vertex-i Vindx : Vertex index for root point Rmax : Max radius for neighbor search Ndisp : display process each Ndisp point --- Output member_id{n} : member vertex index which belog to the root point Vindx(n) [history] M. Sato 2006-7-15 2010-05-26 Taku Yoshioka Minor change (verbose level support) 2011-06-20 taku-y [minor] Progress message was added. Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [member_id] = vb_find_near_member(xxF, xxD, Vindx, Rmax, Ndisp) 0002 % Find member vertex near the root point & make member list 0003 % [member_id] = vb_find_near_member(xxF, xxD, Vindx, Rmax, Ndisp) 0004 % --- Input 0005 % xxF{i} : Next-neighbor index that share the same triangle 0006 % xxD{i} : Distance between next-neighbor and the vertex-i 0007 % Vindx : Vertex index for root point 0008 % Rmax : Max radius for neighbor search 0009 % Ndisp : display process each Ndisp point 0010 % --- Output 0011 % member_id{n} : member vertex index which belog to the root point Vindx(n) 0012 % 0013 % [history] 0014 % M. Sato 2006-7-15 0015 % 2010-05-26 Taku Yoshioka 0016 % Minor change (verbose level support) 0017 % 2011-06-20 taku-y 0018 % [minor] Progress message was added. 0019 % 0020 % Copyright (C) 2011, ATR All Rights Reserved. 0021 % License : New BSD License(see VBMEG_LICENSE.txt) 0022 0023 global vbmeg_inst; 0024 verbose_const = vb_define_verbose; 0025 if isempty(vbmeg_inst) | ~isfield(vbmeg_inst,'.verbose_level'), 0026 verbose_level = verbose_const.VERBOSE_LEVEL_NOTICE; 0027 else 0028 verbose_level = vbmeg_inst.verbose_level; 0029 end 0030 0031 if ~exist('Ndisp','var'), Ndisp = 200; end; 0032 0033 % Total Vertex point number 0034 Nall = size(xxF,1); 0035 % Number of root points 0036 Nroot = length(Vindx); 0037 % Neighbor member list for root points 0038 member_id = cell(Nroot,1); 0039 0040 % Add self index to member list 0041 for n=1:Nroot 0042 member_id{n} = Vindx(n); 0043 end 0044 0045 Mcount = zeros(Nall,1); % Number of root points near the vertex 0046 Iroot = cell(Nall,1); % Root index list for each vertex 0047 ddlist = cell(Nall,1); % Distance list 0048 0049 % progress 0050 prg = 0; 0051 prg_all = Nroot; 0052 h_prg = waitbar(prg/prg_all,'Neighbor search'); 0053 vb_disp_nonl(sprintf('%3d %% processed',ceil(100*(prg/prg_all)))); 0054 0055 % Make root index list for each vertex 0056 for n=1:Nroot 0057 % neighbor distance & index 0058 [id, dd] = vb_find_neighbor(Rmax, Vindx(n), xxF, xxD ); 0059 0060 % root index list 0061 for m = 1:length(id) 0062 % Vertex index 0063 i = id(m); 0064 Mcount(i) = Mcount(i) + 1; 0065 % Add root index 0066 Iroot{i} = [Iroot{i}, n]; 0067 ddlist{i} = [ddlist{i}, dd(m)]; 0068 end 0069 0070 if mod(n,Ndisp)==0, 0071 for ii=1:15; vb_disp_nonl(sprintf('\b')); end 0072 vb_disp_nonl(sprintf('%3d %% processed',ceil(100*(prg/prg_all)))); 0073 waitbar(prg/prg_all,h_prg); 0074 end 0075 prg = prg+1; 0076 end 0077 0078 vb_disp_nonl(' '); 0079 close(h_prg); 0080 0081 % Exclude root index from root index list 0082 Mcount(Vindx) = 0; 0083 0084 % one root point for one vertex 0085 Indx = find( Mcount == 1 ); 0086 0087 for m = 1:length(Indx) 0088 % Vertex index 0089 i = Indx(m); 0090 % Root index 0091 n = Iroot{i}; 0092 member_id{n} = [member_id{n}, i]; 0093 end 0094 0095 % many root points for one vertex 0096 Indx = find( Mcount > 1 ); 0097 0098 for m = 1:length(Indx) 0099 % Vertex index 0100 i = Indx(m); 0101 % Root index list 0102 ix = Iroot{i}; 0103 0104 % find nearest root 0105 [dmin, imin] = min(ddlist{i}); 0106 0107 % Root index 0108 n = ix(imin(1)); 0109 member_id{n} = [member_id{n}, i]; 0110 end 0111 0112 return;