Changeset 6965


Ignore:
Timestamp:
01/06/11 09:13:32 (14 years ago)
Author:
Mathieu Morlighem
Message:

Speeded up IsInPoly.cpp by checking extremas

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/shared/Exp/IsInPoly.cpp

    r5016 r6965  
    2222        double x0,y0;
    2323        double value;
     24        double xmin=xc[0];
     25        double xmax=xc[0];
     26        double ymin=yc[0];
     27        double ymax=yc[0];
     28
     29        /*Get extrema*/
     30        for (i=1;i<numgrids;i++){
     31                if(xc[i]<xmin) xmin=xc[i];
     32                if(xc[i]>xmax) xmax=xc[i];
     33                if(yc[i]<ymin) ymin=yc[i];
     34                if(yc[i]>ymax) ymax=yc[i];
     35        }
    2436
    2537        /*Go through all grids of the mesh:*/
     
    3547                /*pick up grid (x[i],y[i]) and figure out if located inside contour (xc,yc)*/
    3648                x0=x[i]; y0=y[i];
    37                 value=pnpoly(numgrids,xc,yc,x0,y0,edgevalue);
     49                if(x0<xmin || x0>xmax || y0<ymin || y0>ymax){
     50                        value=0;
     51                }
     52                else{
     53                        value=pnpoly(numgrids,xc,yc,x0,y0,edgevalue);
     54                }
    3855                VecSetValues(in,1,&i,&value,INSERT_VALUES);
    3956        }
Note: See TracChangeset for help on using the changeset viewer.