Changeset 3666


Ignore:
Timestamp:
05/06/10 10:23:52 (15 years ago)
Author:
Mathieu Morlighem
Message:

fixed tolerance

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/classes/public/processgeometry.m

    r3658 r3666  
    1414        x2=geom.Vertices(geom.Edges(i,2),1);
    1515        y2=geom.Vertices(geom.Edges(i,2),2);
     16        color1=geom.Edges(i,3);
    1617
    17         j=i+1; %test edges located AFTER i only
     18        j=i; %test edges located AFTER i only
    1819        while (j<size(geom.Edges,1)),
    1920
     
    3132                x4=geom.Vertices(geom.Edges(j,2),1);
    3233                y4=geom.Vertices(geom.Edges(j,2),2);
     34                color2=geom.Edges(j,3);
    3335
    3436                %Check if the two edges are crossing one another
     
    4042
    4143                        %Add vertex to the list of vertices
    42                         geom.Vertices(end+1,:)=[x y 1];
     44                        geom.Vertices(end+1,:)=[x y min(color1,color2)];
    4345                        id=size(geom.Vertices,1);
    4446
     
    5658        end
    5759
     60end
     61
     62%Check point outside
     63disp('Checking for points outside the domain...');
     64i=0;
     65num=0;
     66while (i<size(geom.Vertices,1)),
     67
     68        %vertex counter
     69        i=i+1;
     70
     71        %Get coordinates
     72        x=geom.Vertices(i,1);
     73        y=geom.Vertices(i,2);
     74        color=geom.Vertices(i,3);
     75
     76        %Check that the point is inside the domain
     77        if (color~=1 & ~ContourToNodes(x,y,outline(1),1)),
     78
     79                %Remove points from list of Vertices
     80                num=num+1;
     81                geom.Vertices(i,:)=[];
     82
     83                %update edges
     84                [posedges dummy]=find(geom.Edges==i);
     85                geom.Edges(posedges,:)=[];
     86                posedges=find(geom.Edges>i);
     87                geom.Edges(posedges)=geom.Edges(posedges)-1;
     88
     89                %update counter
     90                i=i-1;
     91        end
     92end
     93if num,
     94        disp(['WARNING: ' num2str(num) ' points outside the domain outline have been removed']);
    5895end
    5996
     
    102139%remove empty edges
    103140geom.Edges(find(geom.Edges(:,1)==geom.Edges(:,2)),:)=[];
    104 
    105 %Check point outside
    106 disp('Checking for points outside the domain...');
    107 i=0;
    108 num=0;
    109 while (i<size(geom.Vertices,1)),
    110 
    111         %vertex counter
    112         i=i+1;
    113 
    114         %Get coordinates
    115         x=geom.Vertices(i,1);
    116         y=geom.Vertices(i,2);
    117 
    118         %Check that the point is inside the domain
    119         if (~ContourToNodes(x,y,outline(1),1)),
    120 
    121                 %Remove points from list of Vertices
    122                 num=num+1;
    123                 geom.Vertices(i,:)=[];
    124 
    125                 %update edges
    126                 [posedges dummy]=find(geom.Edges==i);
    127                 geom.Edges(posedges,:)=[];
    128                 posedges=find(geom.Edges>i);
    129                 geom.Edges(posedges)=geom.Edges(posedges)-1;
    130 
    131                 %update counter
    132                 i=i-1;
    133         end
    134 end
    135 if num,
    136         disp(['WARNING: ' num2str(num) 'points outside the domain outline have been removed']);
    137 end
Note: See TracChangeset for help on using the changeset viewer.