Home > functions > device > vivid > vb_read_vrml_coordinate.m

vb_read_vrml_coordinate

PURPOSE ^

Read Coordinate frpm XML-file

SYNOPSIS ^

function X = vb_read_vrml_coordinate(fname, Nskip, Nline, Mmax, key)

DESCRIPTION ^

 Read Coordinate frpm XML-file
 
 Coordinate3 {
    point [ 
        9.06 87.16 -851.32,
        10.02 87.13 -851.20,
            ...
    ]
    point [ 9.06 87.16 -851.32,
        10.02 87.13 -851.20,
            ...
       76.95 -72.55 23.16 ]

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function    X = vb_read_vrml_coordinate(fname, Nskip, Nline, Mmax, key)
0002 % Read Coordinate frpm XML-file
0003 %
0004 % Coordinate3 {
0005 %    point [
0006 %        9.06 87.16 -851.32,
0007 %        10.02 87.13 -851.20,
0008 %            ...
0009 %    ]
0010 %    point [ 9.06 87.16 -851.32,
0011 %        10.02 87.13 -851.20,
0012 %            ...
0013 %       76.95 -72.55 23.16 ]
0014 %
0015 % Copyright (C) 2011, ATR All Rights Reserved.
0016 % License : New BSD License(see VBMEG_LICENSE.txt)
0017 
0018 
0019 fid=fopen(fname);
0020 
0021 % Skip lines until data
0022 for n=1:Nskip
0023     next_line = fgetl(fid);
0024 end
0025 
0026 % Read data
0027 X  = zeros(Nline,Mmax);
0028 nn = 0;
0029 
0030 % Check case such as [ 12, 13,
0031 ix  = strfind(next_line,key);
0032 
0033 if ~isempty(ix)
0034     next_line = next_line(ix+1:end);
0035     
0036     if ~isempty(next_line)
0037         x  = sscanf(next_line,'%f');
0038         Nx = length(x);
0039         if Nx > 0,
0040             nn = nn + 1;
0041             X(nn, 1:Nx) = x';
0042         end
0043     end
0044 end
0045 
0046 for n=1:Nline
0047     next_line = fgetl(fid);
0048 
0049     x  = sscanf(next_line,'%f');
0050     Nx = length(x);
0051     if Nx > 0,
0052         nn = nn + 1;
0053         X(nn, 1:Nx) = x';
0054     end
0055 end
0056 
0057 fclose(fid);
0058 
0059 X = X(1:nn,:);

Generated on Tue 27-Aug-2013 11:46:04 by m2html © 2005