Changeset 8270


Ignore:
Timestamp:
05/13/11 09:57:45 (14 years ago)
Author:
Mathieu Morlighem
Message:

updated outsidepoly and added folds

Location:
issm/trunk/src/c/shared/Exp
Files:
2 edited

Legend:

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

    r6965 r8270  
    1414#endif
    1515
    16 
    17 
    18 
     16/*IsInPoly {{{1*/
    1917int IsInPoly(Vec in,double* xc,double* yc,int numgrids,double* x,double* y,int i0,int i1, int edgevalue){
    2018
     
    5654        }
    5755         return 1;
    58 }
    59 
    60 int IsOutsidePoly(Vec out,double* xc,double* yc,int numgrids,double* x,double* y,int nods,int edgevalue){
     56}/*}}}*/
     57/*IsOutsidePoly {{{1*/
     58int IsOutsidePoly(Vec in,double* xc,double* yc,int numgrids,double* x,double* y,int i0,int i1, int edgevalue){
    6159
    6260        int i,j;
    6361        double x0,y0;
    6462        double value;
     63        double xmin=xc[0];
     64        double xmax=xc[0];
     65        double ymin=yc[0];
     66        double ymax=yc[0];
     67
     68        /*Get extrema*/
     69        for (i=1;i<numgrids;i++){
     70                if(xc[i]<xmin) xmin=xc[i];
     71                if(xc[i]>xmax) xmax=xc[i];
     72                if(yc[i]<ymin) ymin=yc[i];
     73                if(yc[i]>ymax) ymax=yc[i];
     74        }
    6575
    6676        /*Go through all grids of the mesh:*/
    67         for (i=MPI_Lowerrow(nods);i<MPI_Upperrow(nods);i++){
    68                 /*pick up grid: */
    69                 x0=x[i];
    70                 y0=y[i];
    71                 if (pnpoly(numgrids,xc,yc,x0,y0,edgevalue)){
    72                         value=0;
     77        for (i=i0;i<i1;i++){
     78
     79                //Get current value of value[i] -> do not change it if != 0
     80                VecGetValues(in,1,&i,&value);
     81                if (value){
     82                        /*this grid already is inside one of the contours, continue*/
     83                        continue;
     84                }
     85
     86                /*pick up grid (x[i],y[i]) and figure out if located inside contour (xc,yc)*/
     87                x0=x[i]; y0=y[i];
     88                if(x0<xmin || x0>xmax || y0<ymin || y0>ymax){
     89                        value=1;
    7390                }
    7491                else{
    75                         value=1;
     92                        value=1-pnpoly(numgrids,xc,yc,x0,y0,edgevalue);
    7693                }
    77                 VecSetValues(out,1,&i,&value,INSERT_VALUES);
     94                VecSetValues(in,1,&i,&value,INSERT_VALUES);
    7895        }
    79 
    8096        return 1;
    81 }
    82 
     97}/*}}}*/
     98/*pnpoly{{{1*/
    8399int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue) {
    84100        int i, j, c = 0;
     
    110126        }
    111127        return c;
    112 }
     128}/*}}}*/
  • issm/trunk/src/c/shared/Exp/exp.h

    r2587 r8270  
    1010
    1111int IsInPoly(Vec in,double* xc,double* yc,int numgrids,double* x,double* y,int i0,int i1, int edgevalue);
     12int IsOutsidePoly(Vec in,double* xc,double* yc,int numgrids,double* x,double* y,int i0,int i1, int edgevalue);
    1213int IsInPolySerial(double* in,double* xc,double* yc,int numgrids,double* x,double* y,int nods, int edgevalue);
    13 int IsOutsidePoly(Vec out,double* xc,double* yc,int numgrids,double* x,double* y,int nods,int edgevalue);
    1414int DomainOutlineRead(int* pnprof,int** pprofngrids,double*** ppprofx,double*** ppprofy,char* domainname);
    1515int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue);
Note: See TracChangeset for help on using the changeset viewer.