[2] | 1 | ;+ |
---|
[231] | 2 | ; |
---|
[226] | 3 | ; @file_comments |
---|
[150] | 4 | ; Delete arrays which do not have to be drawn thanks to 2 tests: |
---|
| 5 | ; 1) Corners of the array must be in the window |
---|
[226] | 6 | ; 2) Lengthes of side of triangles expressed in normalized |
---|
| 7 | ; coordinates must not surpass a sill length. |
---|
[2] | 8 | ; |
---|
[150] | 9 | ; @categories |
---|
[2] | 10 | ; |
---|
[150] | 11 | ; @param TRIANG |
---|
[2] | 12 | ; |
---|
[226] | 13 | ; @param GLAM |
---|
| 14 | ; |
---|
| 15 | ; @param GPHI |
---|
| 16 | ; |
---|
[150] | 17 | ; @keyword _EXTRA |
---|
[231] | 18 | ; Used to pass keywords |
---|
[2] | 19 | ; |
---|
[150] | 20 | ; @uses |
---|
| 21 | ; common.pro |
---|
[2] | 22 | ; |
---|
[150] | 23 | ; @history |
---|
[157] | 24 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[150] | 25 | ; 20/2/99 |
---|
[2] | 26 | ; |
---|
[150] | 27 | ; @version |
---|
| 28 | ; $Id$ |
---|
[226] | 29 | ; |
---|
[2] | 30 | ;- |
---|
[231] | 31 | ; |
---|
[192] | 32 | FUNCTION ciseauxtri, triang, glam, gphi, _EXTRA = ex |
---|
[29] | 33 | ;--------------------------------------------------------- |
---|
[114] | 34 | ; |
---|
| 35 | compile_opt idl2, strictarrsubs |
---|
| 36 | ; |
---|
[29] | 37 | @cm_4mesh |
---|
| 38 | IF NOT keyword_set(key_forgetold) THEN BEGIN |
---|
| 39 | @updatenew |
---|
| 40 | ENDIF |
---|
| 41 | ;--------------------------------------------------------- |
---|
| 42 | IF NOT keyword_set(key_periodic) AND NOT keyword_set(key_irregular) $ |
---|
| 43 | AND NOT (!map.projection LE 7 AND !map.projection NE 0) $ |
---|
| 44 | AND NOT (!map.projection EQ 14 OR !map.projection EQ 15 $ |
---|
| 45 | OR !map.projection EQ 18) THEN return, triang |
---|
| 46 | ; |
---|
[150] | 47 | tempsun = systime(1) ; For key_performance |
---|
[29] | 48 | ; |
---|
[2] | 49 | taille = size(glam) |
---|
| 50 | nx = taille[1] |
---|
| 51 | ny = taille[2] |
---|
| 52 | |
---|
[150] | 53 | tempdeux = systime(1) ; For key_performance =2 |
---|
[226] | 54 | z = convert_coord(glam[*],gphi[*],/data,/to_normal) |
---|
[29] | 55 | x = z[0, *] |
---|
| 56 | y = z[1, *] |
---|
[2] | 57 | tempvar = SIZE(TEMPORARY(z)) ; delete z |
---|
| 58 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 59 | print, 'temps ciseauxtri: convert_coord data to_normal', systime(1)-tempdeux |
---|
| 60 | ; |
---|
[226] | 61 | ; Beware, following the projection, some points x or y can become NaN |
---|
| 62 | ; (see points behind the Earth in an orthographic projection). |
---|
[150] | 63 | ; In this case, we have to remove all triangle which contain one of these points. |
---|
[2] | 64 | ; |
---|
| 65 | if (!map.projection LE 7 AND !map.projection NE 0) $ |
---|
| 66 | OR !map.projection EQ 14 OR !map.projection EQ 15 OR !map.projection EQ 18 then begin |
---|
[150] | 67 | tempdeux = systime(1) ; For key_performance =2 |
---|
[29] | 68 | ; |
---|
| 69 | test = (x*y)[triang] |
---|
| 70 | test = finite(temporary(test), /nan) |
---|
| 71 | test = total(temporary(test), 1) |
---|
| 72 | ind = where(temporary(test) EQ 0) |
---|
| 73 | ; |
---|
| 74 | if ind[0] NE -1 then triang = triang[*, temporary(ind)] ELSE return, -1 |
---|
| 75 | trichanged = 1b |
---|
[2] | 76 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 77 | print, 'temps ciseauxtri: recherche points a NAN', systime(1)-tempdeux |
---|
| 78 | endif |
---|
| 79 | ; |
---|
[29] | 80 | seuil = 5 < (min([nx, ny])-2) |
---|
[2] | 81 | ; |
---|
[150] | 82 | ; Now we delete tringles whose one side has a size superior to 1/sill from the domain reserved for the drawing. |
---|
[2] | 83 | ; |
---|
| 84 | |
---|
[29] | 85 | if keyword_set(key_periodic) then begin |
---|
[150] | 86 | tempdeux = systime(1) ; For key_performance =2 |
---|
[2] | 87 | ; |
---|
[29] | 88 | xtri = x[triang] |
---|
| 89 | xtri = xtri-shift(xtri, 1, 0) |
---|
| 90 | testx = abs(temporary(xtri)) GT ((!p.position[2]-!p.position[0])/seuil) |
---|
| 91 | testx = total(temporary(testx), 1) |
---|
| 92 | ; |
---|
| 93 | ytri = y[triang] |
---|
| 94 | ytri = ytri-shift(ytri, 1, 0) |
---|
| 95 | testy = abs(temporary(ytri)) GT ((!p.position[3]-!p.position[1])/seuil) |
---|
| 96 | testy = total(temporary(testy), 1) |
---|
[226] | 97 | ; |
---|
[29] | 98 | test = temporary(testx)+temporary(testy) |
---|
[226] | 99 | ind=where(temporary(test) EQ 0) |
---|
[29] | 100 | ; |
---|
[2] | 101 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 102 | print, 'temps ciseauxtri: trouver les triangles trop grands', systime(1)-tempdeux |
---|
| 103 | ; |
---|
[150] | 104 | tempdeux = systime(1) ; For key_performance =2 |
---|
[29] | 105 | if ind[0] NE -1 then triang = triang[*, temporary(ind)] ELSE return, -1 |
---|
| 106 | trichanged = 1b |
---|
[2] | 107 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 108 | print, 'temps ciseauxtri: virer les triangles trop grands', systime(1)-tempdeux |
---|
| 109 | endif |
---|
| 110 | ; |
---|
[192] | 111 | ; We delete all triangle which are out of the valid frame |
---|
[2] | 112 | ; |
---|
[29] | 113 | if keyword_set(key_irregular) then begin |
---|
[2] | 114 | |
---|
[150] | 115 | tempdeux = systime(1) ; For key_performance =2 |
---|
[29] | 116 | xtri = x[triang] |
---|
| 117 | test1 = xtri GE !p.position[0] |
---|
| 118 | test2 = xtri LE !p.position[2] |
---|
| 119 | undefine, xtri |
---|
| 120 | testx = temporary(test1)*temporary(test2) |
---|
| 121 | testx = total(temporary(testx), 1) |
---|
[2] | 122 | ; |
---|
[29] | 123 | ytri = y[triang] |
---|
| 124 | test1 = ytri GE !p.position[1] |
---|
| 125 | test2 = ytri LE !p.position[3] |
---|
| 126 | undefine, ytri |
---|
| 127 | testy = temporary(test1)*temporary(test2) |
---|
| 128 | testy = total(temporary(testy), 1) |
---|
| 129 | ; |
---|
| 130 | test = temporary(testx)*temporary(testy); |
---|
| 131 | ; |
---|
| 132 | ind=where(temporary(test) NE 0) |
---|
| 133 | ; |
---|
| 134 | if ind[0] NE -1 then triang = triang[*, temporary(ind)] ELSE return, -1 |
---|
| 135 | trichanged = 1b |
---|
| 136 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 137 | print, 'temps ciseauxtri: virer les triangles hors du cadre', systime(1)-tempdeux |
---|
| 138 | ENDIF |
---|
| 139 | ; |
---|
[150] | 140 | ; Last sort. |
---|
[2] | 141 | ; |
---|
[29] | 142 | if keyword_set(trichanged) then BEGIN |
---|
[2] | 143 | ; |
---|
[226] | 144 | ; We have to check that triangles we keep do not form a triangulation |
---|
| 145 | ; in which 2 triangles have a common summit without have a common side. |
---|
[2] | 146 | ; |
---|
[226] | 147 | ; We constitute the list of rectangles we want to keep (we keep every |
---|
[150] | 148 | ; rectangle containing a triangle) |
---|
[2] | 149 | ; |
---|
[150] | 150 | ; In definetri, we have construct triangles just so the first and the |
---|
| 151 | ; last summit are those of the diagonale of the rectangle defined by |
---|
| 152 | ; the mesh size. To find from which rectangle a triangle comes, we look |
---|
[226] | 153 | ; for the min of the index following x and following y of each triangle. |
---|
[150] | 154 | ; Then we go by again this indexion following x and y in an indexion |
---|
| 155 | ; following nx*ny/ |
---|
[2] | 156 | ; |
---|
[150] | 157 | tempdeux = systime(1) ; For key_performance =2 |
---|
| 158 | ; y indexes of rectangles |
---|
[2] | 159 | indytriang = (triang[0, *]/nx) < (triang[2, *]/nx) |
---|
[150] | 160 | ; x indexes of rectangles |
---|
[2] | 161 | indxtriang0 = triang[0, *]-nx*(triang[0, *]/nx) |
---|
| 162 | indxtriang2 = triang[2, *]-nx*(triang[2, *]/nx) |
---|
| 163 | indxmin = indxtriang0 < indxtriang2 |
---|
[226] | 164 | ; Beware in the case where the grid is periodic and where we have all points |
---|
| 165 | ; following x, triangles which assure the periodicity in x have indexes |
---|
| 166 | ; following x which are 0 and nx-1. They belong to rectangles of the column |
---|
[150] | 167 | ; nx-1 and not to column 0. |
---|
[29] | 168 | if keyword_set(key_periodic) AND nx EQ jpi then BEGIN |
---|
[2] | 169 | indxmax = indxtriang0 > indxtriang2 |
---|
| 170 | indxtriang = indxmin + (nx-1)*(indxmin EQ 0 AND indxmax EQ (nx-1)) |
---|
[226] | 171 | ENDIF ELSE indxtriang = indxmin |
---|
[2] | 172 | listrect = nx*indytriang+indxtriang |
---|
| 173 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 174 | print, 'temps ciseauxtri: liste des rectangles', systime(1)-tempdeux |
---|
| 175 | ; |
---|
[226] | 176 | ; Now we have this list, we will make sure that we do not have triangles |
---|
[150] | 177 | ; with only a common summit. |
---|
[2] | 178 | ; |
---|
| 179 | test = bytarr(nx, ny) |
---|
| 180 | test[listrect] = 1 |
---|
| 181 | dejavire = 1b-test |
---|
| 182 | ; |
---|
[150] | 183 | tempdeux = systime(1) ; For key_performance =2 |
---|
[2] | 184 | vire1 = 0 |
---|
| 185 | vire2 = 0 |
---|
| 186 | while (vire1[0] NE -1 OR vire2[0] NE -1) ne 0 do begin |
---|
| 187 | vire1 = where( (test*shift(test, -1, -1) $ |
---|
| 188 | *(1-shift(test, 0, -1))*(1-shift(test, -1, 0))) EQ 1) |
---|
[150] | 189 | if vire1[0] NE -1 THEN test[vire1] = 0 ; We delete the rectangle |
---|
[2] | 190 | vire2 = where( ((1-test)*(1-shift(test, -1, -1)) $ |
---|
| 191 | *shift(test, 0, -1)*shift(test, -1, 0)) EQ 1) |
---|
[150] | 192 | ; We delete the top rectangle (same x index but equal to 1) |
---|
[226] | 193 | if vire2[0] NE -1 THEN test[vire2+nx] = 0 |
---|
[2] | 194 | ENDWHILE |
---|
| 195 | ;stop |
---|
| 196 | test = test+temporary(dejavire) |
---|
| 197 | ; |
---|
| 198 | avirer = where(temporary(test) EQ 0) |
---|
| 199 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
[226] | 200 | print, 'temps ciseauxtri: determination des rectangles a virer', systime(1)-tempdeux |
---|
[2] | 201 | ; |
---|
| 202 | if avirer[0] NE -1 then begin |
---|
[150] | 203 | tempdeux = systime(1) ; For key_performance =2 |
---|
[2] | 204 | indnx = n_elements(listrect) |
---|
| 205 | indny = n_elements(avirer) |
---|
[226] | 206 | ind = listrect[*]#replicate(1l, indny) |
---|
[2] | 207 | ind = ind EQ replicate(1, indnx)#avirer[*] |
---|
| 208 | if indny GT 1 then ind = total(ind, 2) |
---|
| 209 | ind = where(ind EQ 0) |
---|
| 210 | if ind[0] NE -1 then triang = triang[*, ind] ELSE return, -1 |
---|
| 211 | endif |
---|
| 212 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 213 | print, 'temps ciseauxtri: derniere retouche de la triangulation', systime(1)-tempdeux |
---|
| 214 | endif |
---|
| 215 | ; |
---|
[29] | 216 | ; |
---|
[226] | 217 | if keyword_set(key_performance) THEN print, 'temps ciseauxtri', systime(1)-tempsun |
---|
| 218 | ; |
---|
[2] | 219 | return, triang |
---|
| 220 | end |
---|