Changeset 8157
- Timestamp:
- 05/06/11 08:16:05 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/modules/InterpFromMeshToGridx/InterpFromMeshToGridx.cpp
r8154 r8157 27 27 double x_grid_max,y_grid_max; 28 28 double data_value; 29 double cornersouth ,cornerwest;29 double cornersouth; 30 30 double* x_grid=NULL; 31 31 double* y_grid=NULL; … … 66 66 // EAST = ACTUAL WEST !!!!!!!!!!!!!!! 67 67 cornersouth=cornernorth-nlines*yposting; 68 cornerwest =cornereast +ncols *xposting;69 68 for(i=0;i<nlines;i++) y_grid[i]= cornersouth + yposting/2 + yposting*i; 70 69 for(i=0;i<ncols; i++) x_grid[i]= cornereast + xposting/2 + xposting*i; 71 for(i=0;i<=nlines;i++) y_m[i] 72 for(i=0;i<=ncols; i++) x_m[i] 70 for(i=0;i<=nlines;i++) y_m[i]= cornersouth + yposting*i; 71 for(i=0;i<=ncols; i++) x_m[i]= cornereast + xposting*i; 73 72 74 73 /*Initialize coordintes and griddata*/ … … 115 114 /*Get indices i and j that form a square around the currant triangle*/ 116 115 if (yflip){ 117 i1= (int)floor((y_tria_max-y_grid_max)/yposting)-1;118 i2= (int)ceil((y_tria_min-y_grid_max)/yposting);116 i1=max(0, (int)floor((y_tria_max-y_grid_max)/yposting)-1); 117 i2=min(nlines, (int)ceil((y_tria_min-y_grid_max)/yposting)); 119 118 } 120 119 else{ 121 i1= (int)floor((y_tria_min-y_grid_min)/yposting)-1;122 i2= (int)ceil((y_tria_max-y_grid_min)/yposting);120 i1=max(0, (int)floor((y_tria_min-y_grid_min)/yposting)-1); 121 i2=min(nlines, (int)ceil((y_tria_max-y_grid_min)/yposting)); 123 122 } 124 123 if (xflip){ 125 j1= (int)floor((x_tria_max-x_grid_max)/xposting)-1;126 j2= (int)ceil((x_tria_min-x_grid_max)/xposting);124 j1=max(0, (int)floor((x_tria_max-x_grid_max)/xposting)-1); 125 j2=min(ncols, (int)ceil((x_tria_min-x_grid_max)/xposting)); 127 126 } 128 127 else{ 129 j1= (int)floor((x_tria_min-x_grid_min)/xposting)-1;130 j2= (int)ceil((x_tria_max-x_grid_min)/xposting);128 j1=max(0, (int)floor((x_tria_min-x_grid_min)/xposting)-1); 129 j2=min(ncols, (int)ceil((x_tria_max-x_grid_min)/xposting)); 131 130 } 132 /*Check indices*/133 if(i1<0) _error_("first index is 0!");134 if(j1<0) _error_("first index is 0!");135 if(i2>=nlines)_error_("index exceeds matrix dimension! (%i >= nlines %i)",i2,nlines);136 if(j2>=ncols) _error_("index exceeds matrix dimension! (%i >= ncols %i)",j2,ncols);137 131 138 132 /*get area of the current element (Jacobian = 2 * area)*/
Note:
See TracChangeset
for help on using the changeset viewer.