0001 function [F, V, xx, Vmiss, Fmiss, Nmiss] = vb_surf_extract(B, step, Vorgin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 if ~exist('Vorgin','var'), Vorgin = [0, 0, 0]; end;
0025 if ~exist('step','var'), step = 1; end;
0026
0027
0028
0029
0030
0031
0032 tic
0033 fprintf('smoothing\n')
0034 B = smooth3(B,'gaussian',3);
0035 vb_ptime(toc);
0036
0037
0038 tic
0039 fprintf('surface extraction\n')
0040 Val = 0.5;
0041 [F,V] = isosurface(B,Val);
0042 vb_ptime(toc);
0043
0044
0045 x = V(:,1);
0046 V(:,1) = V(:,2);
0047 V(:,2) = x;
0048
0049
0050 NP = size(V,1);
0051 V = V*step - step/2;
0052 V = V + Vorgin(ones(NP,1),:);
0053
0054
0055
0056
0057
0058 tic
0059 fprintf('connected surface extraction\n')
0060 [Fall, Vall, Nall] = vb_separate_surf(F,V);
0061 F = Fall{1};
0062 V = Vall{1};
0063
0064
0065 [F, V, xx] = vb_out_normal(F,V);
0066 vb_ptime(toc)
0067
0068
0069 fprintf('# of connected vertex = %d\n', Nall(1))
0070
0071
0072 omega = vb_solid_angle_check(V,F);
0073 fprintf('Closed surface index (=1) : %f\n', omega)
0074 fprintf('# of disconnected vertex = %d\n', sum(Nall(2:end)))
0075
0076 if nargout < 4, return; end;
0077
0078 Nsurf = size(Vall,1)-1;
0079
0080 if Nsurf == 0,
0081 Fmiss = [];
0082 Vmiss = [];
0083 Nmiss = 0;
0084 return;
0085 end;
0086
0087 Fmiss = cell(Nsurf,1);
0088 Vmiss = cell(Nsurf,1);
0089 Nmiss = zeros(Nsurf,1);
0090
0091 for n=1:Nsurf
0092 Fmiss{n} = Fall{n+1};
0093 Vmiss{n} = Vall{n+1};
0094 Nmiss(n) = Nall(n+1);
0095 end
0096
0097