Make closed surface [F,V,xx] = vb_close_surf(F,V) [F,V,xx,Vlist] = vb_close_surf(F,V) --- Input and Output V : surface vertex [Nvertex x 3] F : triangle patch index for surface [Npatch x 3] xx : outward normal vector [Nvertex x 3] --- Optional variable for check Vlist : boundary vertex list [cell array] Copyright (C) 2011, ATR All Rights Reserved. License : New BSD License(see VBMEG_LICENSE.txt)
0001 function [F,V,xx,Vlist] = vb_close_surf(F,V) 0002 % Make closed surface 0003 % [F,V,xx] = vb_close_surf(F,V) 0004 % [F,V,xx,Vlist] = vb_close_surf(F,V) 0005 % --- Input and Output 0006 % V : surface vertex [Nvertex x 3] 0007 % F : triangle patch index for surface [Npatch x 3] 0008 % xx : outward normal vector [Nvertex x 3] 0009 % --- Optional variable for check 0010 % Vlist : boundary vertex list [cell array] 0011 % 0012 % Copyright (C) 2011, ATR All Rights Reserved. 0013 % License : New BSD License(see VBMEG_LICENSE.txt) 0014 0015 DEBUG = 0; 0016 %Jedge = [9 2; 9 1; 1 10; 1 2 ; 2 9; 3 4; 2 1]; 0017 0018 fprintf('Make closed surface\n') 0019 0020 % Make vertex index list for boundary closed loop 0021 [Vlist] = vb_boundary_edge(F,V); 0022 0023 Flist = []; 0024 Nline = length(Vlist); 0025 0026 % Make triangle index to close surface 0027 % by using vertex index for boundary closed loop 0028 for n=1:Nline 0029 % make closed loop index list 0030 ID = Vlist{n}; 0031 NV = length(ID); 0032 0033 % Make triangle index to close surface 0034 Fadd = [ repmat(ID(1),[NV-2, 1]), ID(2:NV-1), ID(3:NV)]; 0035 Flist = [Flist ; Fadd]; 0036 end 0037 0038 % Add patch list to close surface 0039 F = [F ; Flist]; 0040 0041 fprintf('Surface is closed\n') 0042 fprintf('Make normal vector outward \n') 0043 0044 [F, V, xx] = vb_out_normal(F,V); 0045 0046 omega = vb_solid_angle_check(V,F); 0047 0048 fprintf('Closed surface index = %f\n',omega); 0049 0050 if DEBUG == 1 0051 for n=1:Nline 0052 ID = Vlist{n}; 0053 plot3(V(ID,1),V(ID,2),V(ID,3),'r-') 0054 hold on 0055 plot3(V([ID(1) ID(n)],1),V([ID(1) ID(n)],2),V([ID(1) ID(n)],3),'r-') 0056 end 0057 end 0058 0059 return 0060 0061 0062 return