0001 function f=surfaceclean(f,v)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 pos=v;
0021 mi=min(pos);
0022 ma=max(pos);
0023
0024 idx0=find(abs(pos(:,1)-mi(1))<1e-6);
0025 idx1=find(abs(pos(:,1)-ma(1))<1e-6);
0026
0027 idy0=find(abs(pos(:,2)-mi(2))<1e-6);
0028 idy1=find(abs(pos(:,2)-ma(2))<1e-6);
0029
0030 idz0=find(abs(pos(:,3)-mi(3))<1e-6);
0031 idz1=find(abs(pos(:,3)-ma(3))<1e-6);
0032
0033 f=removeedgefaces(f,v,idx0);
0034 f=removeedgefaces(f,v,idx1);
0035 f=removeedgefaces(f,v,idy0);
0036 f=removeedgefaces(f,v,idy1);
0037 f=removeedgefaces(f,v,idz0);
0038 f=removeedgefaces(f,v,idz1);
0039
0040 function f=removeedgefaces(f,v,idx1)
0041 mask=zeros(length(v),1);
0042 mask(idx1)=1;
0043 f(find(sum(mask(f)')==3),:)=[];