[2] | 1 | function numtri, index, nx, ny |
---|
| 2 | |
---|
| 3 | y=index/nx |
---|
| 4 | x=index-y*nx |
---|
| 5 | numtri = (y NE 0)*(nx-1)*(2*(y-1)+1) + (2-(y EQ (ny-1) OR y EQ (ny-1)))*x |
---|
| 6 | |
---|
| 7 | return, numtri |
---|
| 8 | end |
---|
| 9 | |
---|
| 10 | |
---|
| 11 | ;+ |
---|
| 12 | ; NAME:definetri |
---|
| 13 | ; |
---|
| 14 | ; PURPOSE:Define a triangulation array like TRIANGULATE but for a |
---|
| 15 | ; E-grid type |
---|
| 16 | ; |
---|
| 17 | ; CATEGORY: make contours with E-grid type |
---|
| 18 | ; |
---|
| 19 | ; CALLING SEQUENCE:triangles=definetri(nx, ny [,vertical]) |
---|
| 20 | ; |
---|
| 21 | ; INPUTS: nx and ny are the array dimensions |
---|
| 22 | ; |
---|
| 23 | ; OPTIONAL INPUTS: |
---|
| 24 | ; |
---|
| 25 | ; vertical: When vertical is undefine all rectangles are cut |
---|
| 26 | ; in using the horizontal diagonal. Vertical is a vector which |
---|
| 27 | ; contains the rectangles numbers which are cut in using the |
---|
| 28 | ; vertical diagonal. |
---|
| 29 | ; The rectangle number is define by the index (in a nx*ny |
---|
| 30 | ; vector) of the lower-left corner of the rectangle. |
---|
| 31 | ; |
---|
| 32 | ; KEYWORD PARAMETERS: |
---|
| 33 | ; |
---|
| 34 | ; OUTPUTS: |
---|
| 35 | ; triangles is a 2d array and is dimensions are 3 and |
---|
| 36 | ; 2*(nx-1)*(ny-1) |
---|
| 37 | ; triangles is define like in the TRIANGULATE procedure. |
---|
| 38 | ; |
---|
| 39 | ; |
---|
| 40 | ; OPTIONAL OUTPUTS: |
---|
| 41 | ; |
---|
| 42 | ; COMMON BLOCKS: |
---|
| 43 | ; |
---|
| 44 | ; SIDE EFFECTS: |
---|
| 45 | ; |
---|
| 46 | ; RESTRICTIONS: |
---|
| 47 | ; |
---|
| 48 | ; PROCEDURE: |
---|
| 49 | ; |
---|
| 50 | ; EXAMPLE: |
---|
| 51 | ; |
---|
| 52 | ; |
---|
| 53 | ; MODIFICATION HISTORY: sebastien Masson (smlod@ipsl.jussieu.fr) |
---|
| 54 | ; June 2001 |
---|
| 55 | ; |
---|
| 56 | ;- |
---|
| 57 | FUNCTION definetri_e, nx, ny, singular, SHIFTED = shifted |
---|
| 58 | nx = long(nx) |
---|
| 59 | ny = long(ny) |
---|
| 60 | triangles = lonarr(3, 2*(nx-1)*(ny-1)) |
---|
| 61 | ; |
---|
| 62 | ; build the base triangulation with the diamond cut in two triangles |
---|
| 63 | ; by the vertical diagonal |
---|
| 64 | ; |
---|
| 65 | ; first line |
---|
| 66 | index = lindgen(nx-1) |
---|
| 67 | trinumber = index |
---|
| 68 | triangles[0, trinumber] = index |
---|
| 69 | triangles[1, trinumber] = index+1 |
---|
| 70 | triangles[2, trinumber] = index+(nx+1-shifted) |
---|
| 71 | ; last line |
---|
| 72 | index = (ny-1)*nx+lindgen(nx-1) |
---|
| 73 | trinumber = numtri(index, nx, ny) |
---|
| 74 | triangles[0, trinumber] = index |
---|
| 75 | triangles[1, trinumber] = index+(-nx+((index/nx+1-shifted) MOD 2)) |
---|
| 76 | triangles[2, trinumber] = index+1 |
---|
| 77 | ; other lines |
---|
| 78 | if ny GT 2 then begin |
---|
| 79 | index = lindgen(nx, ny) |
---|
| 80 | index = index[0:nx-2, 1:ny-2] |
---|
| 81 | index = index[*] |
---|
| 82 | oddeven = (index/nx+1-shifted) MOD 2 |
---|
| 83 | trinumber = numtri(index, nx, ny) |
---|
| 84 | triangles[0, trinumber] = index |
---|
| 85 | triangles[1, trinumber] = index-nx+oddeven |
---|
| 86 | triangles[2, trinumber] = index+nx+oddeven |
---|
| 87 | triangles[0, trinumber+1] = index+nx+oddeven |
---|
| 88 | triangles[1, trinumber+1] = index-nx+oddeven |
---|
| 89 | triangles[2, trinumber+1] = index+1 |
---|
| 90 | endif |
---|
| 91 | ; |
---|
| 92 | ; cut the diamond specified by singular in two triangles |
---|
| 93 | ; by the horizontal diagonal |
---|
| 94 | ; |
---|
| 95 | IF keyword_set(singular) then BEGIN |
---|
| 96 | yindex = singular/nx |
---|
| 97 | otherline = where(yindex NE 0 AND yindex NE (ny-1)) |
---|
| 98 | if otherline[0] NE -1 then begin |
---|
| 99 | index = singular[otherline] |
---|
| 100 | oddeven = (index/nx+1-shifted) MOD 2 |
---|
| 101 | trinumber = numtri(index, nx, ny) |
---|
| 102 | triangles[0, trinumber] = index |
---|
| 103 | triangles[1, trinumber] = index-nx+oddeven |
---|
| 104 | triangles[2, trinumber] = index+1 |
---|
| 105 | triangles[0, trinumber+1] = index |
---|
| 106 | triangles[1, trinumber+1] = index+1 |
---|
| 107 | triangles[2, trinumber+1] = index+nx+oddeven |
---|
| 108 | endif |
---|
| 109 | |
---|
| 110 | endif |
---|
| 111 | return, triangles |
---|
| 112 | end |
---|
| 113 | |
---|