0001 function X = vb_read_vrml_patch(fname)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 key.start = 'IndexedFaceSet';
0015 key.start2 = 'coordIndex';
0016 key.end = ']';
0017 key.braket = '[';
0018
0019
0020 [Nskip, Nline, Mmax] = vb_read_vrml_line(fname,key,'%d,');
0021
0022
0023
0024
0025 Mmax = Mmax-1;
0026 X=zeros(Nline,Mmax);
0027
0028
0029 fprintf('Number of patch= %d\n', Nline)
0030 fprintf('Number of Max points in patch = %d\n', Mmax)
0031
0032 fid=fopen(fname);
0033
0034
0035 for n=1:Nskip
0036 next_line = fgetl(fid);
0037 end
0038
0039 nn = 0;
0040
0041
0042 for n=1:Nline
0043 next_line = fgetl(fid);
0044 x = sscanf(next_line,'%d,');
0045
0046
0047 Nx = length(x)-1;
0048
0049 if Nx > 0,
0050 nn = nn + 1;
0051 id = 1:Nx;
0052
0053
0054 X(n,id) = x(id)' + 1;
0055
0056
0057 if Nx < Mmax,
0058 X(n,(Nx+1):Mmax) = x(1) + 1;
0059 end;
0060 end
0061 end
0062
0063 fclose(fid);
0064
0065 X = X(1:nn,:);