[157] | 1 | ;+ |
---|
[231] | 2 | ; |
---|
[157] | 3 | ; @file_comments |
---|
[114] | 4 | ; |
---|
[157] | 5 | ; @categories |
---|
| 6 | ; |
---|
| 7 | ; @param INDEX |
---|
| 8 | ; It is the tick mark index which starts at 0. |
---|
| 9 | ; |
---|
| 10 | ; @param NX {in}{required} |
---|
| 11 | ; The x dimension array |
---|
| 12 | ; |
---|
| 13 | ; @param NY {in}{required} |
---|
| 14 | ; The y dimension array |
---|
| 15 | ; |
---|
| 16 | ; @returns |
---|
| 17 | ; |
---|
[231] | 18 | ; @restrictions |
---|
[157] | 19 | ; |
---|
| 20 | ; @examples |
---|
[231] | 21 | ; |
---|
[157] | 22 | ; @history |
---|
| 23 | ; |
---|
| 24 | ; @version |
---|
| 25 | ; $Id$ |
---|
| 26 | ;- |
---|
| 27 | ; |
---|
[231] | 28 | FUNCTION numtri, index, nx, ny |
---|
| 29 | ; |
---|
[114] | 30 | compile_opt idl2, strictarrsubs |
---|
| 31 | ; |
---|
[2] | 32 | |
---|
| 33 | y=index/nx |
---|
| 34 | x=index-y*nx |
---|
| 35 | numtri = (y NE 0)*(nx-1)*(2*(y-1)+1) + (2-(y EQ (ny-1) OR y EQ (ny-1)))*x |
---|
| 36 | |
---|
| 37 | return, numtri |
---|
| 38 | end |
---|
[231] | 39 | ; |
---|
[2] | 40 | ;+ |
---|
| 41 | ; |
---|
[150] | 42 | ; @file_comments |
---|
[232] | 43 | ; Define a triangulation array like <proidl>TRIANGULATE</proidl> but for a |
---|
[2] | 44 | ; E-grid type |
---|
| 45 | ; |
---|
[150] | 46 | ; @categories |
---|
| 47 | ; Make contours with E-grid type |
---|
[231] | 48 | ; |
---|
[150] | 49 | ; @param NX {in}{required} |
---|
| 50 | ; The x dimension array |
---|
[2] | 51 | ; |
---|
[150] | 52 | ; @param NY {in}{required} |
---|
| 53 | ; The y dimension array |
---|
[2] | 54 | ; |
---|
[150] | 55 | ; @param SINGULAR {in}{optional} |
---|
[231] | 56 | ; When singular is undefined all rectangles are cut in using the vertical |
---|
| 57 | ; diagonal. |
---|
| 58 | ; Singular is a vector which contains the rectangles numbers which are cut in |
---|
[186] | 59 | ; using the horizontal diagonal. |
---|
[231] | 60 | ; The rectangle number is defined by the index (in a nx*ny vector) of the |
---|
[186] | 61 | ; lower-left corner of the rectangle. |
---|
[2] | 62 | ; |
---|
[150] | 63 | ; @keyword SHIFTED |
---|
[2] | 64 | ; |
---|
[150] | 65 | ; @returns |
---|
[186] | 66 | ; Triangles is a 2d array and is dimensions are 3 and (nx-1)*(ny-1). |
---|
[232] | 67 | ; Triangles is defined like in the <proidl>TRIANGULATE</proidl> procedure. |
---|
[231] | 68 | ; |
---|
[150] | 69 | ; @history |
---|
[157] | 70 | ; Sebastien Masson (smlod\@ipsl.jussieu.fr) |
---|
[150] | 71 | ; June 2001 |
---|
[2] | 72 | ; |
---|
[150] | 73 | ; @version |
---|
| 74 | ; $Id$ |
---|
[2] | 75 | ; |
---|
[231] | 76 | ; @todo |
---|
[150] | 77 | ; seb: documenter SHIFTED |
---|
[2] | 78 | ;- |
---|
| 79 | FUNCTION definetri_e, nx, ny, singular, SHIFTED = shifted |
---|
[114] | 80 | ; |
---|
| 81 | compile_opt idl2, strictarrsubs |
---|
| 82 | ; |
---|
[2] | 83 | nx = long(nx) |
---|
| 84 | ny = long(ny) |
---|
| 85 | triangles = lonarr(3, 2*(nx-1)*(ny-1)) |
---|
| 86 | ; |
---|
| 87 | ; build the base triangulation with the diamond cut in two triangles |
---|
| 88 | ; by the vertical diagonal |
---|
| 89 | ; |
---|
| 90 | ; first line |
---|
| 91 | index = lindgen(nx-1) |
---|
| 92 | trinumber = index |
---|
| 93 | triangles[0, trinumber] = index |
---|
| 94 | triangles[1, trinumber] = index+1 |
---|
| 95 | triangles[2, trinumber] = index+(nx+1-shifted) |
---|
| 96 | ; last line |
---|
| 97 | index = (ny-1)*nx+lindgen(nx-1) |
---|
| 98 | trinumber = numtri(index, nx, ny) |
---|
| 99 | triangles[0, trinumber] = index |
---|
| 100 | triangles[1, trinumber] = index+(-nx+((index/nx+1-shifted) MOD 2)) |
---|
| 101 | triangles[2, trinumber] = index+1 |
---|
| 102 | ; other lines |
---|
| 103 | if ny GT 2 then begin |
---|
| 104 | index = lindgen(nx, ny) |
---|
| 105 | index = index[0:nx-2, 1:ny-2] |
---|
| 106 | index = index[*] |
---|
| 107 | oddeven = (index/nx+1-shifted) MOD 2 |
---|
| 108 | trinumber = numtri(index, nx, ny) |
---|
| 109 | triangles[0, trinumber] = index |
---|
| 110 | triangles[1, trinumber] = index-nx+oddeven |
---|
| 111 | triangles[2, trinumber] = index+nx+oddeven |
---|
| 112 | triangles[0, trinumber+1] = index+nx+oddeven |
---|
| 113 | triangles[1, trinumber+1] = index-nx+oddeven |
---|
| 114 | triangles[2, trinumber+1] = index+1 |
---|
| 115 | endif |
---|
| 116 | ; |
---|
| 117 | ; cut the diamond specified by singular in two triangles |
---|
| 118 | ; by the horizontal diagonal |
---|
| 119 | ; |
---|
| 120 | IF keyword_set(singular) then BEGIN |
---|
| 121 | yindex = singular/nx |
---|
| 122 | otherline = where(yindex NE 0 AND yindex NE (ny-1)) |
---|
| 123 | if otherline[0] NE -1 then begin |
---|
| 124 | index = singular[otherline] |
---|
| 125 | oddeven = (index/nx+1-shifted) MOD 2 |
---|
| 126 | trinumber = numtri(index, nx, ny) |
---|
| 127 | triangles[0, trinumber] = index |
---|
| 128 | triangles[1, trinumber] = index-nx+oddeven |
---|
| 129 | triangles[2, trinumber] = index+1 |
---|
| 130 | triangles[0, trinumber+1] = index |
---|
| 131 | triangles[1, trinumber+1] = index+1 |
---|
| 132 | triangles[2, trinumber+1] = index+nx+oddeven |
---|
| 133 | endif |
---|
| 134 | |
---|
| 135 | endif |
---|
| 136 | return, triangles |
---|
| 137 | end |
---|
| 138 | |
---|