Changeset 26540


Ignore:
Timestamp:
11/04/21 13:15:20 (3 years ago)
Author:
Cheng Gong
Message:

ADD: exp to levelset can handle multiple records

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/modules/ExpToLevelSet.m

    r25059 r26540  
    1414% Check usage
    1515if nargin~=3
    16         help ExpToLevelSet
    17         error('Wrong usage (see above)');
     16    help ExpToLevelSet
     17    error('Wrong usage (see above)');
    1818end
    1919
     20multipleShp = 0;
     21
    2022if ischar(contourname),
    21         [path,name,ext]=fileparts(contourname);
    22         if strcmpi(ext,'.shp'),
    23                 %read contour from shapefile
    24                 contourname=shpread(contourname);
    25         end
     23    [path,name,ext]=fileparts(contourname);
     24    if strcmpi(ext,'.shp'),
     25        %read contour from shapefile
     26        contourname=shpread(contourname);
     27        if isstruct(contourname)
     28            multipleShp = size(contourname, 2);
     29        end
     30    end
    2631end
    2732
    2833% Call mex module
    29 distance = ExpToLevelSet_matlab(x,y,contourname);
     34if multipleShp>0
     35    % shp file contains multiple contours
     36    distance = zeros(length(x)+1, multipleShp);
     37    for i = 1:multipleShp
     38        distance(1:end-1, i) = ExpToLevelSet_matlab(x,y,contourname(i));
     39        % append the NAME information at the end of the distance
     40        if isfield(contourname(i),'NAME')
     41            distance(end, i) = contourname(i).NAME;
     42        else
     43                        distance(end, i) = i;
     44        end       
     45    end
     46else
     47    % single shape or exp file
     48    distance = ExpToLevelSet_matlab(x,y,contourname);
     49end
Note: See TracChangeset for help on using the changeset viewer.