Changeset 24155


Ignore:
Timestamp:
09/23/19 15:57:55 (5 years ago)
Author:
Eric.Larour
Message:

CHG: diverse

Location:
issm/trunk-jpl/src/m/mesh
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/mesh/meshintersect3d.m

    r22938 r24155  
    99
    1010        %retrieve tolerance:
    11         tolerance=getfieldvalue(options,'tolerance',10);
     11        maxtol=getfieldvalue(options,'maxtol',100000); %100 km.
     12        tolincrement=getfieldvalue(options,'tolincrement',10);
     13        force=getfieldvalue(options,'force',0);
    1214
    1315        %go through lats,longs and find within tolerance, the index of the corresponding value in lat,long:
     
    1517       
    1618        for i=1:length(xs),
     19                tolerance=0;
    1720                distance=sqrt((x-xs(i)).^2+(y-ys(i)).^2+(z-zs(i)).^2);
    18                 s=find(distance<tolerance);
    19                 if length(s)>1,
    20                         for j=1:length(s),
    21                                 hold on;plot3(x(s(j)),y(s(j)),z(s(j)),'c.','MarkerSize',40)
     21
     22                s=find(distance==0);
     23                if ~isempty(s),
     24                        if length(s)>1,
     25
     26                                %we have two vertices that are coincident! Not good.
     27                                for j=1:length(s),
     28                                        hold on;plot3(x(s(j)),y(s(j)),z(s(j)),'c.','MarkerSize',40)
     29                                end
     30                                disp(['Vertex ' num2str(i) ' of input mesh coincides with vertices ' num2str(s) ' of output mesh']);
     31                                if force,
     32                                        indices(i)=s(1);
     33                                else
     34                                        error('');
     35                                end
     36                        else
     37                                indices(i)=s;
    2238                        end
    23                         distance(s)
    24                         error(sprintf('one or more vertices on the global mesh were duplicated (offset %i)',i));
    25                 elseif isempty(s),
    26                         plot(distance);
    27                         min(distance);
    28                         i
    29                         error('cannot find concurrent vertics!');
    30                 else
    31                         indices(i)=s;
    3239                end
     40
     41                %we could not find a 0 distance, find the lowest tolerance that generates a find:
     42                count=1;
     43                while isempty(s),
     44                        if count>1000,
     45                                disp(['could not find a vertex matching vertex ' num2str(i) ' of input mesh!']);
     46                                disp('Might think about changing tolerance increment');
     47                                error('');
     48                        end
     49                        tolerance=tolerance+tolincrement;
     50                        s=find(distance<tolerance);
     51                        count=count+1;
     52                end
     53                if tolerance>maxtol,
     54                        disp(['found matching vertices ' num2str(s) ' in output mesh for input mesh vertex ' num2str(i) ]);
     55                        disp(' however, these vertices are farther that the max tolerance allowed!');
     56                        error('');
     57                end
     58
     59                %recover minimum distance:
     60                sf=distance(s);
     61                pos=find(sf==min(sf));
     62                s=s(pos);
     63                indices(i)=s;
    3364        end
     65
     66
     67%               if length(s)>1,
     68%                       for j=1:length(s),
     69%                               hold on;plot3(x(s(j)),y(s(j)),z(s(j)),'c.','MarkerSize',40)
     70%                       end
     71%                       if force,
     72%                               indices(i)=s(1);
     73%                       else
     74%                               distance(s)
     75%                               error(sprintf('one or more vertices on the global mesh were duplicated (offset %i)',i));
     76%                       end
     77%               elseif isempty(s),
     78%                       plot(distance);
     79%                       min(distance);
     80%                       i
     81%                       error('cannot find concurrent vertics!');
     82%               else
     83%                       indices(i)=s;
     84%               end
     85
Note: See TracChangeset for help on using the changeset viewer.