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