Changeset 226 for trunk/SRC/ToBeReviewed/TRIANGULATION/triangule_c.pro
- Timestamp:
- 03/16/07 10:22:26 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/ToBeReviewed/TRIANGULATION/triangule_c.pro
r163 r226 7 7 ; Construct the triangulation array. 8 8 ; 9 ; The idea is: construct a list of triangle which link points between them. 9 ; The idea is: construct a list of triangle which link points between them. 10 10 ; This is automatically done by the function TRIANGULATE 11 11 ; Here: 12 ; we consider the fact that points are disposed on a grid (regular or not, 13 ; but not unstructured, that is to say that points are written following a 14 ; rectangular matrix). A easy way to do triangles between all points is then: 12 ; we consider the fact that points are disposed on a grid (regular or not, 13 ; but not unstructured, that is to say that points are written following a 14 ; rectangular matrix). A easy way to do triangles between all points is then: 15 15 ; 16 16 ; for each point (i,j) of the matrix -except those of the last line and of … … 22 22 ; drawing to make sure!!), so there are two possible choice for each rectangle 23 23 ; we want to cut in 2 triangles... 24 ; 24 ; 25 25 ; It is thanks to this choice that we will be able to trace coast with right 26 26 ; angles. At each angle of coast remarkable by the existence of an unique land 27 27 ; point or of an unique ocean point on one of the four summit of a rectangle (i,j), 28 28 ; we have to cut the rectangle following the diagonal passing by this point. 29 ; 29 ; 30 30 ; @categories 31 31 ; Graphics 32 32 ; 33 33 ; @param MASKENTREE {in}{optional}{type=2d array} 34 ; It is a 2d array which will serve to mask the field we will trace after with CONTOUR, 34 ; It is a 2d array which will serve to mask the field we will trace after with CONTOUR, 35 35 ; ...TRIANGULATION=triangule(mask) 36 36 ; If this argument is not specified, the function use tmask … … 43 43 ; 44 44 ; @keyword COINMONTE {type=array} 45 ; To obtain the array of "ascending land corner" to be treated with 46 ; completecointerre.pro in the variable array instead of make it pass by the global 45 ; To obtain the array of "ascending land corner" to be treated with 46 ; completecointerre.pro in the variable array instead of make it pass by the global 47 47 ; variable twin_corners_up. 48 48 ; … … 52 52 ; @returns 53 53 ; res: tableau 2d (3,nbre de triangles). 54 ; Each line of res represent indexes of points constituting summits of a triangle. 54 ; Each line of res represent indexes of points constituting summits of a triangle. 55 55 ; See how we trace triangles in definetri.pro 56 56 ; … … 61 61 ; 62 62 ; @restrictions 63 ; Datas whose we want to do the contour must be disposed in a matrix. 64 ; On the other hand, in the matrix, the points's arrangement can not be 63 ; Datas whose we want to do the contour must be disposed in a matrix. 64 ; On the other hand, in the matrix, the points's arrangement can not be 65 65 ; irregular. If it is, use TRIANGULE. 66 66 ; … … 73 73 ; 74 74 ; @todo 75 ; seb L.267->268 je ne pense pas que ce soit ce que tu voulais dire mais 75 ; seb L.267->268 je ne pense pas que ce soit ce que tu voulais dire mais 76 76 ; c'est la traduction de ce qu'il y avait écrit. Correction si besoin. 77 77 ;- … … 101 101 ;------------------------------------------------------------ 102 102 if keyword_set(key_periodic)*(nx EQ jpi) $ 103 AND NOT keyword_set(basic) then BEGIN 103 AND NOT keyword_set(basic) then BEGIN 104 104 msk = [msk, msk[0, *]] 105 105 nx = nx+1 106 106 ENDIF 107 107 ;------------------------------------------------------------ 108 ; We will find the list of rectangles (i,j)(located by their left 109 ; bottom corner) we have to cut fol owing a descendant diagonal.108 ; We will find the list of rectangles (i,j)(located by their left 109 ; bottom corner) we have to cut following a descendant diagonal. 110 110 ; We will call this list : pts_downward 111 ; 111 ; 112 112 pts_downward = 0 113 113 … … 164 164 ENDIF 165 165 ; 166 if n_elements(pts_downward) EQ 1 then BEGIN 166 if n_elements(pts_downward) EQ 1 then BEGIN 167 167 tempdeux = systime(1) ; For key_performance =2 168 168 ; … … 173 173 coinmont = -1 174 174 coindesc = -1 175 ENDIF ELSE BEGIN 175 ENDIF ELSE BEGIN 176 176 tempdeux = systime(1) ; For key_performance =2 177 177 pts_downward = pts_downward[1:n_elements(pts_downward)-1] 178 178 pts_downward = pts_downward[uniq(pts_downward, sort(pts_downward))] 179 ; None rectangle can have an element of the last column or of the 179 ; None rectangle can have an element of the last column or of the 180 180 ; last line as left bottom corner. 181 181 ; so we have to remove these points if they has been selected in pts_downward. 182 derniere_colonne = (lindgen(ny)+1)*nx-1 183 derniere_ligne = lindgen(nx)+(ny-1)*nx 182 derniere_colonne = (lindgen(ny)+1)*nx-1 183 derniere_ligne = lindgen(nx)+(ny-1)*nx 184 184 pts_downward =different(pts_downward,derniere_colonne ) 185 185 pts_downward =different(pts_downward,derniere_ligne ) … … 193 193 coindesc =different(coindesc,derniere_ligne ) 194 194 endif 195 ENDIF ELSE BEGIN 195 ENDIF ELSE BEGIN 196 196 coinmont = -1 197 197 coindesc = -1 198 ENDELSE 198 ENDELSE 199 199 IF testvar(var = key_performance) EQ 2 THEN $ 200 200 print, 'temps triangule: menage ds pts_downward coinmont et coindesc', systime(1)-tempdeux … … 205 205 IF testvar(var = key_performance) EQ 2 THEN $ 206 206 print, 'temps triangule: definetri', systime(1)-tempdeux 207 ENDELSE 207 ENDELSE 208 208 ;------------------------------------------------------------ 209 209 ; We delete land points which only contain land points. 210 210 ;------------------------------------------------------------ 211 211 ; 212 ; 212 ; 213 213 if (NOT keyword_set(basic)) AND (NOT keyword_set(keep_cont)) then begin 214 214 tempdeux = systime(1) ; For key_performance =2 … … 224 224 trimask = intarr(nx, ny) 225 225 trimask[0:nx-2, 0:ny-2] = 1 226 IF recdsterre[0] NE -1 then BEGIN 226 IF recdsterre[0] NE -1 then BEGIN 227 227 tempdeux = systime(1) ; For key_performance =2 228 228 indice[recdsterre] = 1 … … 231 231 vire2 = 0 232 232 while (vire1[0] NE -1 OR vire2[0] NE -1) ne 0 do begin 233 ; Delete rectangles we have to remove from recsterre (in fact those we have 234 ; to keep although they ar eentirely in the land).233 ; Delete rectangles we have to remove from recsterre (in fact those we have 234 ; to keep although they are entirely in the land). 235 235 vire1 = where( (indice*shift(indice, -1, -1) $ 236 236 *(1-shift(indice, 0, -1))*(1-shift(indice, -1, 0))*trimask) EQ 1) 237 if vire1[0] NE -1 THEN BEGIN 237 if vire1[0] NE -1 THEN BEGIN 238 238 indice[vire1] = 0 239 239 ; indice[vire1+nx+1] = 0 240 240 endif 241 241 242 242 vire2 = where( ((1-indice)*(1-shift(indice, -1, -1)) $ 243 243 *shift(indice, 0, -1)*shift(indice, -1, 0)*trimask) EQ 1) 244 if vire2[0] NE -1 THEN BEGIN 244 if vire2[0] NE -1 THEN BEGIN 245 245 indice[vire2+1] = 0 246 246 ; indice[vire2+nx] = 0 … … 259 259 trigarde = transpose(temporary(trigarde)) 260 260 trigarde = [trigarde, trigarde+1] 261 ; 261 ; 262 262 triang = triang[*, temporary(trigarde[*])] 263 263 IF testvar(var = key_performance) EQ 2 THEN $ … … 265 265 endif 266 266 endif 267 ; print, 'temps tri triangles', systime(1)-t1 268 ;------------------------------------------------------------ 269 ; When key_periodic equal 1, triang is a list of indexes's array which 267 ; print, 'temps tri triangles', systime(1)-t1 268 ;------------------------------------------------------------ 269 ; When key_periodic equal 1, triang is a list of indexes's array which 270 270 ; have a surplus column. 271 ; We have to put it back to the initial matrix by putting indexes of 271 ; We have to put it back to the initial matrix by putting indexes of 272 272 ; the last column equal to these of the last column... 273 273 ;------------------------------------------------------------ 274 274 tempdeux = systime(1) ; For key_performance =2 275 275 if keyword_set(key_periodic)*(nx-1 EQ jpi) $ 276 AND NOT keyword_set(basic) then BEGIN 276 AND NOT keyword_set(basic) then BEGIN 277 277 indicey = triang/nx 278 278 indicex = triang-indicey*nx … … 310 310 IF NOT keyword_set(key_forgetold) THEN BEGIN 311 311 @updateold 312 ENDIF 313 314 IF keyword_set(key_performance) THEN print, 'temps triangule', systime(1)-tempsun 312 ENDIF 313 314 IF keyword_set(key_performance) THEN print, 'temps triangule', systime(1)-tempsun 315 315 316 316 return, triang 317 317 318 END 318 END
Note: See TracChangeset
for help on using the changeset viewer.