0001 function [Fnew, Vnew, xxn, Vmiss, Fmiss] = vb_out_normal(F,V,seedID)
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 if nargin<3, seedID=1; end;
0034
0035 Npoint = size(V,1);
0036 Npatch = size(F,1);
0037
0038 Plist = zeros(Npoint,2);
0039 Vlist = zeros(Npoint,2);
0040 Vflg = zeros(Npoint,1);
0041 Fflg = zeros(Npatch,1);
0042 FF = zeros(Npatch,3);
0043
0044
0045 xxF = vb_neighbor_index(V,F);
0046
0047
0048 Plist(1,:) = [seedID, xxF{seedID}(1,1)];
0049
0050 Nlist =1;
0051 Nroot =0;
0052
0053 while Nlist > 0,
0054
0055 Nedge = 0;
0056
0057
0058 for n=1:Nlist,
0059
0060 root = Plist(n,1);
0061 next = Plist(n,2);
0062
0063
0064 nextID = xxF{root};
0065
0066
0067 nlist1 = nextID(:,1);
0068 nlist2 = nextID(:,2);
0069 flist = nextID(:,3);
0070
0071
0072 nextix = find( Fflg(flist) == 0 );
0073
0074 if isempty(nextix),
0075 continue;
0076 end;
0077
0078
0079 nlist1 = nlist1(nextix);
0080 nlist2 = nlist2(nextix);
0081 flist = flist(nextix);
0082
0083 Nnext = length(nextix);
0084 Nnew = Nnext;
0085
0086
0087 for i=1:Nnext,
0088
0089 jx1 = find( nlist1==next );
0090 jx2 = find( nlist2==next );
0091
0092 if ~isempty(jx1),
0093 nold = next;
0094 jj = jx1(1);
0095 fid = flist(jj);
0096 next = nlist2(jj);
0097
0098
0099 Nedge = Nedge + 1;
0100 Vlist(Nedge,:) = [next nold];
0101
0102 FF(fid,:) = [root, nold, next];
0103
0104 Fflg(fid) = 1;
0105
0106 Vflg([root, nold, next]) = 1;
0107
0108
0109 inew = [1:(jj-1),(jj+1):Nnew];
0110 flist = flist(inew);
0111 nlist1 = nlist1(inew);
0112 nlist2 = nlist2(inew);
0113 Nnew = Nnew-1;
0114 elseif ~isempty(jx2),
0115 nold = next;
0116 jj = jx2(1);
0117 fid = flist(jj);
0118 next = nlist1(jj);
0119
0120
0121 Nedge = Nedge + 1;
0122 Vlist(Nedge,:) = [next nold];
0123
0124 FF(fid,:) = [root, nold, next];
0125
0126 Fflg(fid) = 1;
0127
0128 Vflg([root, nold, next]) = 1;
0129
0130
0131 inew = [1:(jj-1),(jj+1):Nnew];
0132 flist = flist(inew);
0133 nlist1 = nlist1(inew);
0134 nlist2 = nlist2(inew);
0135 Nnew = Nnew-1;
0136 end;
0137 end
0138
0139
0140 end;
0141
0142
0143
0144 Nlist = Nedge;
0145 Plist(1:Nedge,:) = Vlist(1:Nedge,:);
0146
0147 end
0148
0149
0150 indx = find(Vflg == 1);
0151 inxf = find(Fflg == 1);
0152 FF = FF(inxf,:);
0153
0154 [Vnew, Fnew] = vb_trans_index( V, FF, indx);
0155 [xxn , Fnew] = vb_out_normal_vect(Vnew,Fnew);
0156
0157
0158
0159 if nargout <= 3, return; end;
0160
0161
0162 vmiss = find(Vflg == 0);
0163
0164 [Vmiss, Fmiss] = vb_trans_index(V,F,vmiss);
0165
0166 return
0167