Changeset 8270
- Timestamp:
- 05/13/11 09:57:45 (14 years ago)
- Location:
- issm/trunk/src/c/shared/Exp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/shared/Exp/IsInPoly.cpp
r6965 r8270 14 14 #endif 15 15 16 17 18 16 /*IsInPoly {{{1*/ 19 17 int IsInPoly(Vec in,double* xc,double* yc,int numgrids,double* x,double* y,int i0,int i1, int edgevalue){ 20 18 … … 56 54 } 57 55 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*/ 58 int IsOutsidePoly(Vec in,double* xc,double* yc,int numgrids,double* x,double* y,int i0,int i1, int edgevalue){ 61 59 62 60 int i,j; 63 61 double x0,y0; 64 62 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 } 65 75 66 76 /*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; 73 90 } 74 91 else{ 75 value=1 ;92 value=1-pnpoly(numgrids,xc,yc,x0,y0,edgevalue); 76 93 } 77 VecSetValues( out,1,&i,&value,INSERT_VALUES);94 VecSetValues(in,1,&i,&value,INSERT_VALUES); 78 95 } 79 80 96 return 1; 81 } 82 97 }/*}}}*/ 98 /*pnpoly{{{1*/ 83 99 int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue) { 84 100 int i, j, c = 0; … … 110 126 } 111 127 return c; 112 } 128 }/*}}}*/ -
issm/trunk/src/c/shared/Exp/exp.h
r2587 r8270 10 10 11 11 int IsInPoly(Vec in,double* xc,double* yc,int numgrids,double* x,double* y,int i0,int i1, int edgevalue); 12 int IsOutsidePoly(Vec in,double* xc,double* yc,int numgrids,double* x,double* y,int i0,int i1, int edgevalue); 12 13 int 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);14 14 int DomainOutlineRead(int* pnprof,int** pprofngrids,double*** ppprofx,double*** ppprofy,char* domainname); 15 15 int pnpoly(int npol, double *xp, double *yp, double x, double y, int edgevalue);
Note:
See TracChangeset
for help on using the changeset viewer.