[2] | 1 | ;+ |
---|
| 2 | ; |
---|
[150] | 3 | ; @file_comments |
---|
| 4 | ; Draw the triangulation |
---|
[2] | 5 | ; |
---|
[150] | 6 | ; @categories |
---|
[157] | 7 | ; Utilities |
---|
[231] | 8 | ; |
---|
[150] | 9 | ; @param TRI {in}{optional} |
---|
[231] | 10 | ; Array which define the triangulation (provided by <pro>triangule</pro> or |
---|
[232] | 11 | ; <proidl>triangulate</proidl>) |
---|
[231] | 12 | ; |
---|
[150] | 13 | ; @param X {in}{optional} |
---|
[231] | 14 | ; The x position of points to which the trangulation refer to |
---|
[150] | 15 | ; (see the x array provided in triangulate) |
---|
[2] | 16 | ; |
---|
[150] | 17 | ; @param Y {in}{optional} |
---|
[231] | 18 | ; The y position of points to which the trangulation refer to |
---|
[150] | 19 | ; (see the y array provided in triangulate) |
---|
[2] | 20 | ; |
---|
[150] | 21 | ; @keyword WAIT |
---|
| 22 | ; =x. to call wait x second between each triangle draw. |
---|
[2] | 23 | ; |
---|
[150] | 24 | ; @keyword ONEBYONE |
---|
| 25 | ; To draw the triangles one by one |
---|
[29] | 26 | ; |
---|
[150] | 27 | ; @keyword FILL |
---|
| 28 | ; To fill the triangles (using polyfill) instead of plotting them |
---|
[29] | 29 | ; |
---|
[150] | 30 | ; @keyword CHANGECOLOR |
---|
[163] | 31 | ; =n. To change the color of each triangle. n colors |
---|
[150] | 32 | ; will be used and repeted if necessary. |
---|
[29] | 33 | ; |
---|
[150] | 34 | ; @uses |
---|
| 35 | ; common.pro |
---|
[29] | 36 | ; |
---|
[150] | 37 | ; @history |
---|
[157] | 38 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
[29] | 39 | ; |
---|
[150] | 40 | ; @version |
---|
| 41 | ; $Id$ |
---|
[29] | 42 | ; |
---|
[2] | 43 | ;- |
---|
[231] | 44 | ; |
---|
[232] | 45 | PRO dessinetri, tri, x, y, WAIT = wait, ONEBYONE = onebyone, FILL = fill, CHANGECOLOR = changecolor, _EXTRA = ex |
---|
[114] | 46 | ; |
---|
| 47 | compile_opt idl2, strictarrsubs |
---|
| 48 | ; |
---|
[2] | 49 | @common |
---|
[150] | 50 | tempsun = systime(1) ; For key_performance |
---|
[29] | 51 | a = '' |
---|
| 52 | if n_params() EQ 3 then BEGIN |
---|
| 53 | CASE size(x, /n_dimensions)+size(y, /n_dimensions) OF |
---|
| 54 | 2:BEGIN |
---|
[231] | 55 | nx = n_elements(x) |
---|
| 56 | ny = n_elements(y) |
---|
[29] | 57 | glam = x#replicate(1., ny) |
---|
| 58 | gphi = replicate(1., nx)#y |
---|
[231] | 59 | END |
---|
[29] | 60 | 4:BEGIN |
---|
| 61 | glam = x |
---|
| 62 | gphi = y |
---|
| 63 | END |
---|
| 64 | ELSE:BEGIN |
---|
| 65 | dummy = report('x and y inputs of dessinetri must have the same number of dimensions (1 or 2)') |
---|
| 66 | return |
---|
| 67 | END |
---|
| 68 | ENDCASE |
---|
[231] | 69 | ENDIF ELSE BEGIN |
---|
[2] | 70 | grille,mask,glam,gphi, tri = tri |
---|
| 71 | undefine, mask |
---|
| 72 | tri = ciseauxtri(tri, glam, gphi) |
---|
[231] | 73 | ENDELSE |
---|
[29] | 74 | ; |
---|
| 75 | IF keyword_set(changecolor) THEN BEGIN |
---|
| 76 | oldname = !d.name |
---|
[231] | 77 | if !d.name EQ 'PS' OR !d.name EQ 'Z' then BEGIN |
---|
[29] | 78 | thisos = strupcase(strmid(!version.os_family, 0, 3)) |
---|
| 79 | CASE thisOS of |
---|
| 80 | 'MAC': set_plot, thisOS |
---|
| 81 | 'WIN': set_plot, thisOS |
---|
| 82 | ELSE: set_plot, 'X' |
---|
| 83 | ENDCASE |
---|
| 84 | ncolors=(!d.n_colors-1) < 255 |
---|
| 85 | set_plot, oldname |
---|
| 86 | ENDIF ELSE ncolors=(!d.n_colors-1) < 255 |
---|
| 87 | color = 1+indgen(changecolor)*(ncolors/(changecolor-1)) |
---|
| 88 | ENDIF ELSE color = 0 |
---|
[231] | 89 | color = color#replicate(1, n_elements(tri)/3/n_elements(color)+1) |
---|
[29] | 90 | ; |
---|
[150] | 91 | tempdeux = systime(1) ; For key_performance =2 |
---|
[2] | 92 | for i = 0L, n_elements(tri)/3-1 do begin |
---|
| 93 | t = [tri[*, i], tri[0, i]] |
---|
[29] | 94 | IF keyword_set(fill) THEN $ |
---|
| 95 | polyfill, glam[t], gphi[t], color = color[i], _extra = ex $ |
---|
| 96 | ELSE plots, glam[t], gphi[t], color = color[i], _extra = ex |
---|
| 97 | IF keyword_set(wait) THEN wait, wait |
---|
| 98 | IF keyword_set(onebyone) THEN read, a, prompt = 'press a key' |
---|
[2] | 99 | ENDFOR |
---|
| 100 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 101 | print, 'temps dessinetri: trace des triangles', systime(1)-tempdeux |
---|
| 102 | ; |
---|
[231] | 103 | if keyword_set(key_performance) THEN print, 'temps dessinetri', systime(1)-tempsun |
---|
[2] | 104 | |
---|
| 105 | return |
---|
| 106 | end |
---|