1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; Build the triangulation for a E-grid type |
---|
5 | ; |
---|
6 | ; @categories |
---|
7 | ; Graphics |
---|
8 | ; |
---|
9 | ; @param MASKENTREE {in}{optional}{type=2d array} |
---|
10 | ; It is a 2d array which will serve to mask the field we will trace after with CONTOUR, |
---|
11 | ; ...TRIANGULATION=triangule(mask) |
---|
12 | ; If this argument is not specified, the function use tmask |
---|
13 | ; |
---|
14 | ; @keyword BASIC |
---|
15 | ; Specify that the mask is on a basic grid (use the triangulation for vertical cuts and hovmoellers) |
---|
16 | ; |
---|
17 | ; @keyword COINMONTE {type=array} |
---|
18 | ; To obtain the array of "ascending land corner" to be treated with |
---|
19 | ; <pro>completecointerre</pro> in the variable array instead of make it pass |
---|
20 | ; by the global variable twin_corners_up. |
---|
21 | ; |
---|
22 | ; @keyword COINDESCEND {type=array} |
---|
23 | ; See COINMONTE |
---|
24 | ; |
---|
25 | ; @keyword SHIFTED |
---|
26 | ; |
---|
27 | ; @uses |
---|
28 | ; common.pro |
---|
29 | ; |
---|
30 | ; @history |
---|
31 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
32 | ; june 2001 |
---|
33 | ; |
---|
34 | ; @version |
---|
35 | ; $Id$ |
---|
36 | ; |
---|
37 | ; @todo |
---|
38 | ; seb L.152->153 je ne pense pas que ce soit ce que tu voulais dire mais |
---|
39 | ; c'est la traduction de ce qu'il y avait écrit. Correction si besoin. |
---|
40 | ;- |
---|
41 | ; |
---|
42 | FUNCTION triangule_e, maskentree, COINMONTE = coinmonte, COINDESCEND = coindescend $ |
---|
43 | , SHIFTED = shifted, BASIC = basic |
---|
44 | ; |
---|
45 | compile_opt idl2, strictarrsubs |
---|
46 | ; |
---|
47 | @cm_4mesh |
---|
48 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
49 | @updatenew |
---|
50 | ENDIF |
---|
51 | ;--------------------------------------------------------- |
---|
52 | tempsun = systime(1) ; For key_performance |
---|
53 | ;------------------------------------------------------------ |
---|
54 | ; Is the mask given or do we have to take tmask? |
---|
55 | ;------------------------------------------------------------ |
---|
56 | ; |
---|
57 | msk = maskentree |
---|
58 | sizem = size(msk) |
---|
59 | nx = sizem[1] |
---|
60 | ny = sizem[2] |
---|
61 | ;------------------------------------------------------------ |
---|
62 | if keyword_set(key_periodic)*(nx EQ jpi) $ |
---|
63 | AND NOT keyword_set(basic) then BEGIN |
---|
64 | msk = [msk, msk[0, *]] |
---|
65 | nx = nx+1 |
---|
66 | ENDIF |
---|
67 | ; |
---|
68 | ; we will find the diamond that must be cut in two triangle using the |
---|
69 | ; horizontal diagonal. |
---|
70 | ; |
---|
71 | index = lindgen(nx, ny) |
---|
72 | index = index[0:nx-2, 1:ny-2] |
---|
73 | if n_elements(shifted) EQ 0 then shifted = 1 |
---|
74 | oddeven = (index/nx+1-shifted) MOD 2 |
---|
75 | msk1 = msk[index] |
---|
76 | msk2 = msk[index+1] |
---|
77 | sum = msk[index-nx+oddeven]+msk[index+nx+oddeven] |
---|
78 | sum1 = msk2+sum |
---|
79 | sum2 = msk1+sum |
---|
80 | ; |
---|
81 | ; horizontal |
---|
82 | ; |
---|
83 | singularpoint = where((msk1 EQ 0 AND sum1 EQ 3) OR (msk1 EQ 1 AND sum1 EQ 0) $ |
---|
84 | OR (msk2 EQ 0 AND sum2 EQ 3) OR (msk2 EQ 1 AND sum2 EQ 0) $ |
---|
85 | OR (sum EQ 0 AND (msk1+msk2) EQ 2) ) |
---|
86 | if singularpoint[0] NE -1 then begin |
---|
87 | horizontal = index[singularpoint] |
---|
88 | triang = definetri_e(nx, ny, horizontal, SHIFTED = shifted) |
---|
89 | ENDIF ELSE triang = definetri_e(nx, ny, SHIFTED = shifted) |
---|
90 | ; coinmont = index[where(sum EQ 2 AND (msk1+msk2) EQ 0)] |
---|
91 | ; coindesc = index[where(sum EQ 0 AND (msk1+msk2) EQ 2)] |
---|
92 | ; |
---|
93 | ; we keep only the triangles which are outside the land |
---|
94 | ; but for some reasons we will in fact delete the land diamond |
---|
95 | ; |
---|
96 | ; allrecinland = where(sum1+msk1 EQ 0) |
---|
97 | ; indexallinland = index[allrecinland] |
---|
98 | ; otherrec = (lindgen(nx, ny))[0:nx-2, 1:ny-2] |
---|
99 | ; otherrec = different(otherrec, indexallinland) |
---|
100 | ; ; |
---|
101 | ; index = lindgen(nx, ny) |
---|
102 | ; index = index[0:nx-3, 2:ny-3] |
---|
103 | ; out = inter(index, indexallinland) |
---|
104 | ; IF out[0] NE -1 THEN begin |
---|
105 | ; out = inter(out+1, indexallinland) |
---|
106 | ; IF out[0] NE -1 THEN begin |
---|
107 | ; out = out-1 |
---|
108 | ; oddeven = (out/nx+1-shifted) MOD 2 |
---|
109 | ; out = inter(out-nx+oddeven, otherrec) |
---|
110 | ; IF out[0] NE -1 THEN begin |
---|
111 | ; out = inter(out+2*nx, otherrec) |
---|
112 | ; IF out[0] NE -1 THEN begin |
---|
113 | ; out = out-(nx+((out/nx+shifted) MOD 2)) |
---|
114 | ; endif |
---|
115 | ; endif |
---|
116 | ; endif |
---|
117 | ; ENDIF |
---|
118 | ; help, out |
---|
119 | ; ; |
---|
120 | ; index = lindgen(nx, ny) |
---|
121 | ; index = index[0:nx-3, 2:ny-3] |
---|
122 | ; out = inter(index, otherrec) |
---|
123 | ; IF out[0] NE -1 THEN begin |
---|
124 | ; out = inter(out+1, otherrec) |
---|
125 | ; IF out[0] NE -1 THEN begin |
---|
126 | ; out = out-1 |
---|
127 | ; oddeven = (out/nx+1-shifted) MOD 2 |
---|
128 | ; out = inter(out-nx+oddeven, indexallinland) |
---|
129 | ; IF out[0] NE -1 THEN begin |
---|
130 | ; out = inter(out+2*nx, indexallinland) |
---|
131 | ; IF out[0] NE -1 THEN begin |
---|
132 | ; out = out-(nx+((out/nx+shifted) MOD 2)) |
---|
133 | ; endif |
---|
134 | ; endif |
---|
135 | ; endif |
---|
136 | ; endif |
---|
137 | ; help, out |
---|
138 | ; ; |
---|
139 | ; IF out[0] EQ -1 THEN out = different(indexallinland, out) ELSE out = indexallinland |
---|
140 | ; triout = numtri(out, nx, ny) |
---|
141 | ; triout = [triout, triout+1] |
---|
142 | ; goodtri = lindgen(2*(nx-1)*(ny-1)) |
---|
143 | ; goodtri = different(goodtri, triout) |
---|
144 | ; triang = triang[*, temporary(goodtri)] |
---|
145 | |
---|
146 | ; ; |
---|
147 | ;------------------------------------------------------------ |
---|
148 | ; When key_periodic equal 1, triang is a list of indexes's array which |
---|
149 | ; have a surplus column. |
---|
150 | ; We have to put it back to the initial matrix by putting indexes of |
---|
151 | ; the last column equal to these of the last column... |
---|
152 | ;------------------------------------------------------------ |
---|
153 | tempdeux = systime(1) ; For key_performance =2 |
---|
154 | if keyword_set(key_periodic)*(nx-1 EQ jpi) $ |
---|
155 | AND NOT keyword_set(basic) then BEGIN |
---|
156 | indicey = triang/nx |
---|
157 | indicex = triang-indicey*nx |
---|
158 | nx = nx-1 |
---|
159 | liste = where(indicex EQ nx) |
---|
160 | if liste[0] NE -1 then indicex[liste] = 0 |
---|
161 | triang = indicex+nx*indicey |
---|
162 | nx = nx+1 |
---|
163 | ; if coinmont[0] NE -1 then begin |
---|
164 | ; indicey = coinmont/nx |
---|
165 | ; indicex = coinmont-indicey*nx |
---|
166 | ; nx = nx-1 |
---|
167 | ; liste = where(indicex EQ nx) |
---|
168 | ; if liste[0] NE -1 THEN indicex[liste] = 0 |
---|
169 | ; coinmont = indicex+nx*indicey |
---|
170 | ; nx = nx+1 |
---|
171 | ; endif |
---|
172 | ; if coindesc[0] NE -1 then begin |
---|
173 | ; indicey = coindesc/nx |
---|
174 | ; indicex = coindesc-indicey*nx |
---|
175 | ; nx = nx-1 |
---|
176 | ; liste = where(indicex EQ nx) |
---|
177 | ; if liste[0] NE -1 THEN indicex[liste] = 0 |
---|
178 | ; coindesc = indicex+nx*indicey |
---|
179 | ; nx = nx+1 |
---|
180 | ; endif |
---|
181 | endif |
---|
182 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
183 | print, 'temps triangule: finitions', systime(1)-tempdeux |
---|
184 | |
---|
185 | ;------------------------------------------------------------ |
---|
186 | if arg_present(coinmonte) THEN coinmonte = coinmont ELSE twin_corners_up = coinmont |
---|
187 | if arg_present(coindescend) THEN coindescend = coindesc ELSE twin_corners_dn = coindesc |
---|
188 | |
---|
189 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
190 | @updateold |
---|
191 | ENDIF |
---|
192 | ;------------------------------------------------------------ |
---|
193 | |
---|
194 | |
---|
195 | IF keyword_set(key_performance) THEN print, 'temps triangule', systime(1)-tempsun |
---|
196 | |
---|
197 | return, triang |
---|
198 | |
---|
199 | END |
---|