Changeset 2607


Ignore:
Timestamp:
11/05/09 08:46:47 (15 years ago)
Author:
Mathieu Morlighem
Message:

Accelerated expread and removed old files not needed anymore

Location:
issm/trunk/src/m/utils/Exp
Files:
3 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/utils/Exp/expdoc.m

    r1 r2607  
    3333disp('     expselect: display all the profiles of oldfile, the user clicks on the contour he/she wants to remove. Results saved in newfile');
    3434disp('            usage: expselect(newfile,oldfile)');
    35 disp('     expwriteasvertices: writes an Argus file from a structure given in input???');
    36 disp('            usage: expwriteasvertices(structure,filename)');
    3735disp('     expwrite: writes an Argus file from a structure given in input???');
    3836disp('            usage: expwrite(structure,filename)');
  • issm/trunk/src/m/utils/Exp/readwrite/expread.m

    r1260 r2607  
    1 function struct=expread(name,whole);
    2 %EXPREAD - read a file exp and build a structure
     1function Struct=expread(filename,whole);
     2%EXPREAD - read a file exp and build a Structure
    33%
    4 %   This routine reads a file .exp and build a structure containing the
    5 %   fields x and y corresponding to the coordinates, one for the name of
     4%   This routine reads a file .exp and build a Structure containing the
     5%   fields x and y corresponding to the coordinates, one for the filename of
    66%   the exp file, for the density, for the nodes, and a field closed to
    77%   indicate if the domain is closed.
     
    1010%
    1111%   Usage:
    12 %      struct=expread(name,whole)
     12%      Struct=expread(filename,whole)
    1313
    1414%   Example:
    15 %      struct=expread('domainoutline.exp',1)
     15%      Struct=expread('domainoutline.exp',1)
    1616%
    1717%   See also EXPDOC, EXPWRITEASVERTICES
    1818
    1919%some checks
    20 if ~exist(name),
    21         error(['expread error message: file ' name ' not found!']);
     20if ~exist(filename),
     21        error(['expread error message: file ' filename ' not found!']);
     22end
     23if nargin~=2,
     24        help expread
     25        error('expread error message: second argument not provided'),
    2226end
    2327
    24 try,
    25 fid=fopen(name,'r');
    26 i=0;
     28%initialize number of profile
     29count=0;
     30
     31%open file
     32fid=fopen(filename,'r');
     33
     34%loop over the number of profiles
    2735while (~feof(fid)),
    28    i=i+1;
    29    %firt line contains the name
    30    A=readline(fid,2);
    31    if length(A)>8,
    32        struct(i).name=A(9:length(A));
     36
     37        %update number of profiles
     38   count=count+1;
     39
     40   %Get file name
     41        A=fscanf(fid,'%s %s',2);
     42        if ~strncmp(A,'##Name:',7), break; end
     43        if length(A)>7,
     44                Struct(count).name=A(8:end);
     45        else
     46                Struct(count).name='';
     47        end
     48
     49        %Get Icon
     50        A=fscanf(fid,'%s %s',2);
     51        if ~strncmp(A,'##Icon:',6), break; end
     52
     53        %Get Info
     54        A=fscanf(fid,'%s %s %s %s',4);
     55        if ~strncmp(A,'#Points',7), break; end
     56
     57        %Get number of nods and density
     58   A=fscanf(fid,'%f %f',[1 2]);
     59   if whole==1,
     60       Struct(count).nods=A(1);
     61   else
     62       Struct(count).nods=A(1)-1;
    3363   end
     64   Struct(count).density=A(2);
    3465
    35    A=readline(fid,2);
    36    A=readline(fid,4);
     66        %Get Info
     67        A=fscanf(fid,'%s %s %s %s',5);
     68        if ~strncmp(A,'#XposYpos',9), break; end
    3769
    38    [A,bytecount]=fscanf(fid,'%f %f',[1 2]);
    39    if whole==1,
    40        struct(i).nods=A(1);
    41    else
    42        struct(i).nods=A(1)-1;
    43    end
    44    struct(i).density=A(2);
    45    A=readline(fid,5);
     70        %Get Coordinates
     71        A=fscanf(fid,'%f %f',[2 Struct(count).nods]);
     72        Struct(count).x=A(1,:)';
     73        Struct(count).y=A(2,:)';
    4674
    47    struct(i).x=zeros(struct(i).nods,1);
    48    struct(i).y=zeros(struct(i).nods,1);
    49    struct(i).closed=0;
    50 
    51    for n=1:struct(i).nods,
    52        [A,bytecount]=fscanf(fid,'%f %f',[1 2]);
    53        struct(i).x(n)=A(1);
    54        struct(i).y(n)=A(2);
    55    end
    56    if whole==0,
    57        fscanf(fid,'%f %f',[1 2]);
    58    end
     75        %skip last coordinate if whole=0,
     76   if whole==0, fscanf(fid,'%f %f',[1 2]); end
    5977
    6078end
    61 catch,
    62 end
     79
     80%close file
    6381fclose(fid);
Note: See TracChangeset for help on using the changeset viewer.