0001 function vb_headinfo_save(Headinfo, head_file)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 if ~exist('Headinfo', 'var'), Headinfo = []; end;
0023 if ~exist('head_file', 'var'), head_file = []; end;
0024 [Headinfo, head_file] = inner_check_arguments(Headinfo, head_file);
0025
0026
0027
0028
0029 Vhead = Headinfo.Vhead;
0030 Fhead = Headinfo.Fhead;
0031 XXhead = Headinfo.XXhead;
0032 Sigma = Headinfo.Sigma;
0033 LayerTag = Headinfo.LayerTag;
0034 Rmethod = Headinfo.Rmethod;
0035 R = Headinfo.R;
0036 Npatch = Headinfo.Npatch;
0037 Nvertex = Headinfo.Nvertex;
0038
0039
0040 if isempty(XXhead)
0041 if ~isempty(Vhead) && ~isempty(Fhead)
0042 if ~isempty(Nvertex) && ~isempty(Npatch)
0043 n_layer = size(Nvertex,1);
0044
0045 prev_point = 0;
0046 for i_layer = 1:n_layer
0047
0048 f_begin = Npatch(i_layer,1);
0049 f_end = Npatch(i_layer,2);
0050 v_begin = Nvertex(i_layer,1);
0051 v_end = Nvertex(i_layer,2);
0052
0053 cur_v = Vhead(v_begin:v_end,:);
0054 cur_f = Fhead(f_begin:f_end,:) - prev_point;
0055 [new_f, new_v, cur_XX] = vb_out_normal(cur_f, cur_v);
0056 XXhead = [XXhead; cur_XX];
0057 prev_point = prev_point + size(cur_v,1);
0058 end
0059 else
0060 [new_f, new_v, XXhead] = vb_out_normal(Fhead, Vhead);
0061 end
0062 else
0063 if isempty(Vhead), warning('Vhead is empty'); end
0064 if isempty(Fhead), warning('Fhead is empty'); end
0065 warning('XXhead is empty');
0066 end
0067 end
0068
0069
0070
0071
0072
0073 vb_save(head_file, 'Vhead','Fhead','XXhead','Npatch','Nvertex','LayerTag');
0074
0075
0076
0077
0078
0079
0080
0081 function [Headinfo, head_file] = inner_check_arguments(Headinfo, head_file)
0082 if isempty(Headinfo)
0083 error('Headinfo is a required parameter');
0084 end
0085
0086 if isempty(head_file)
0087 error('head_file is a required parameter');
0088 end
0089
0090 if ~isfield(Headinfo, 'Vhead') Headinfo.Vhead = []; end;
0091 if ~isfield(Headinfo, 'Fhead') Headinfo.Fhead = []; end;
0092 if ~isfield(Headinfo, 'XXhead') Headinfo.XXhead = []; end;
0093 if ~isfield(Headinfo, 'Sigma') Headinfo.Sigma = []; end;
0094 if ~isfield(Headinfo, 'LayerTag') Headinfo.LayerTag = []; end;
0095 if ~isfield(Headinfo, 'Rmethod') Headinfo.Rmethod = []; end;
0096 if ~isfield(Headinfo, 'R') Headinfo.R = []; end;
0097 if ~isfield(Headinfo, 'Npatch') Headinfo.Npatch = []; end;
0098 if ~isfield(Headinfo, 'Nvertex') Headinfo.Nvertex = []; end;
0099
0100
0101
0102