0001 function vb_headinfo_join(info_list, joined_file, verbose_swt)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 try
0042
0043 if ~exist('info_list', 'var'), info_list = []; end;
0044 if ~exist('joined_file', 'var'), joined_file = []; end;
0045 if ~exist('verbose_swt', 'var'), verbose_swt = []; end;
0046
0047 [info_list, joined_file, VERBOSE] = ...
0048 inner_check_arguments(info_list, joined_file, verbose_swt);
0049
0050
0051 if size(info_list,2) <= 1
0052 vb_headinfo_save(info_list(1), joined_file);
0053 return;
0054 end
0055
0056
0057
0058
0059
0060
0061 Rmethod = vb_headinfo_get_rmethod(info_list(1));
0062
0063
0064 if isempty(Rmethod)
0065 calc_mode = 1;
0066 else
0067 calc_mode = vb_util_convert_rmethod2calcmode(Rmethod);
0068 end
0069
0070
0071 RR = [];
0072 N_info = size(info_list, 2);
0073
0074 XXhead = [];
0075 Vhead = [];
0076 Fhead = [];
0077 Nvertex = [];
0078 Npatch = [];
0079 R = [];
0080 Sigma = zeros(1, N_info);
0081 LayerTag = cell(1, N_info);
0082
0083 for ni = 1:N_info
0084 Vhead = vb_headinfo_get_vhead(info_list(ni));
0085 RR = [RR vb_util_distance_of_points(Vhead, calc_mode)];
0086 end
0087
0088 [R idx] = sort(RR);
0089
0090 InfoList = info_list(idx);
0091
0092
0093 Vhead = [];
0094
0095 begin_v = 1;
0096 begin_p = 1;
0097 Npoint = 0;
0098
0099 for ni = 1:N_info
0100 cur_info = InfoList(ni);
0101
0102 len_v = size(vb_headinfo_get_vhead(cur_info),1);
0103 len_p = size(vb_headinfo_get_fhead(cur_info),1);
0104
0105 end_v = begin_v + len_v -1;
0106 end_p = begin_p + len_p -1;
0107 Nvertex = [Nvertex; begin_v end_v];
0108 Npatch = [Npatch; begin_p end_p];
0109 begin_v = end_v + 1;
0110 begin_p = end_p + 1;
0111
0112 XXhead = [XXhead; vb_headinfo_get_xxhead(cur_info)];
0113 Vhead = [ Vhead; vb_headinfo_get_vhead(cur_info)];
0114 Fhead = [ Fhead; vb_headinfo_get_fhead(cur_info) + Npoint];
0115
0116
0117 sigma = vb_headinfo_get_sigma(cur_info);
0118 if isempty(sigma)
0119 sigma = NaN;
0120 end
0121 Sigma(ni) = sigma;
0122 LayerTag{ni} = vb_headinfo_get_layertag(cur_info);
0123
0124 Npoint = Npoint + len_v;
0125 end
0126
0127
0128 Headinfo = vb_headinfo_make([], Vhead, Fhead, XXhead, LayerTag, Sigma, ...
0129 Rmethod, R, Npatch, Nvertex);
0130
0131
0132 vb_headinfo_save(Headinfo, joined_file);
0133
0134 if VERBOSE
0135 fprintf('--- saved as current joined file : %s\n', joined_file);
0136 end
0137
0138 catch
0139 rethrow(lasterror);
0140 end
0141
0142
0143
0144
0145
0146 function [info_list, joined_file, VERBOSE] = ...
0147 inner_check_arguments(info_list, joined_file, verbose_swt)
0148
0149
0150 if isempty(info_list)
0151 error('info_list is a required parameter');
0152 end
0153
0154
0155 if isempty(joined_file)
0156 joined_file = ['.' filesep 'joined_head.head.mat'];
0157 end
0158
0159 if isempty(verbose_swt)
0160 VERBOSE = true;
0161 else
0162 VERBOSE = verbose_swt;
0163 end
0164
0165
0166 info_list = vb_util_arrange_list(info_list, 1);
0167
0168
0169
0170
0171
0172