[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
| 5 | ; NAME:dessinetri |
---|
| 6 | ; |
---|
| 7 | ; PURPOSE:dessine la triangulation |
---|
| 8 | ; |
---|
| 9 | ; CATEGORY:pour comprendre comment ca marche |
---|
| 10 | ; |
---|
| 11 | ; CALLING SEQUENCE:dessinetri [, tri, x, y] |
---|
| 12 | ; |
---|
| 13 | ; INPUTS:optionnels |
---|
| 14 | ; par defaut on choisit la triangulation qui est utilise pour |
---|
| 15 | ; les plots et on la trace aux points definites par vargrid |
---|
| 16 | ; |
---|
| 17 | ; sinon il faut fournir les tableaux |
---|
| 18 | ; tri definissant la triangulation (fournis par triangule.pro |
---|
| 19 | ; ou triangulate) |
---|
| 20 | ; x et y qui sont les positions de points a laquelle se raporte |
---|
| 21 | ; la triangulation (cf. les tableau x et y fournis ds |
---|
| 22 | ; triangulate) |
---|
| 23 | ; |
---|
[29] | 24 | ; KEYWORD PARAMETERS: |
---|
[2] | 25 | ; |
---|
[29] | 26 | ; All plots or polyfill keywords. |
---|
| 27 | ; |
---|
| 28 | ; WAIT=x. to call wait x second between each triangle draw. |
---|
| 29 | ; |
---|
| 30 | ; /ONEBYONE: to draw the triangles one by one |
---|
| 31 | ; |
---|
| 32 | ; /FILL: to fill the triangles (using polyfill) instead of plotting them |
---|
| 33 | ; |
---|
| 34 | ; CHANGECOLOR=n. to change the color of each traingle. n colors |
---|
| 35 | ; will be used and repeted if necessary. |
---|
| 36 | ; |
---|
| 37 | ; |
---|
[2] | 38 | ; OUTPUTS: |
---|
| 39 | ; |
---|
| 40 | ; COMMON BLOCKS:common.pro |
---|
| 41 | ; |
---|
| 42 | ; SIDE EFFECTS: |
---|
| 43 | ; |
---|
| 44 | ; RESTRICTIONS: |
---|
| 45 | ; |
---|
| 46 | ; EXAMPLE: |
---|
| 47 | ; |
---|
| 48 | ; MODIFICATION HISTORY:Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
| 49 | ; |
---|
| 50 | ;- |
---|
| 51 | ;------------------------------------------------------------ |
---|
| 52 | ;------------------------------------------------------------ |
---|
| 53 | ;------------------------------------------------------------ |
---|
| 54 | |
---|
[29] | 55 | PRO dessinetri, tri, x, y, WAIT = wait, ONEBYONE = onebyone, FILL = fill, CHANGECOLOR = changecolor, _extra = ex |
---|
[114] | 56 | ; |
---|
| 57 | compile_opt idl2, strictarrsubs |
---|
| 58 | ; |
---|
[2] | 59 | @common |
---|
| 60 | tempsun = systime(1) ; pour key_performance |
---|
[29] | 61 | a = '' |
---|
| 62 | if n_params() EQ 3 then BEGIN |
---|
| 63 | CASE size(x, /n_dimensions)+size(y, /n_dimensions) OF |
---|
| 64 | 2:BEGIN |
---|
| 65 | nx = n_elements(x) |
---|
| 66 | ny = n_elements(y) |
---|
| 67 | glam = x#replicate(1., ny) |
---|
| 68 | gphi = replicate(1., nx)#y |
---|
| 69 | END |
---|
| 70 | 4:BEGIN |
---|
| 71 | glam = x |
---|
| 72 | gphi = y |
---|
| 73 | END |
---|
| 74 | ELSE:BEGIN |
---|
| 75 | dummy = report('x and y inputs of dessinetri must have the same number of dimensions (1 or 2)') |
---|
| 76 | return |
---|
| 77 | END |
---|
| 78 | ENDCASE |
---|
[2] | 79 | ENDIF ELSE BEGIN |
---|
| 80 | grille,mask,glam,gphi, tri = tri |
---|
| 81 | undefine, mask |
---|
| 82 | tri = ciseauxtri(tri, glam, gphi) |
---|
| 83 | ENDELSE |
---|
[29] | 84 | ; |
---|
| 85 | IF keyword_set(changecolor) THEN BEGIN |
---|
| 86 | oldname = !d.name |
---|
| 87 | if !d.name EQ 'PS' OR !d.name EQ 'Z' then BEGIN |
---|
| 88 | thisos = strupcase(strmid(!version.os_family, 0, 3)) |
---|
| 89 | CASE thisOS of |
---|
| 90 | 'MAC': set_plot, thisOS |
---|
| 91 | 'WIN': set_plot, thisOS |
---|
| 92 | ELSE: set_plot, 'X' |
---|
| 93 | ENDCASE |
---|
| 94 | ncolors=(!d.n_colors-1) < 255 |
---|
| 95 | set_plot, oldname |
---|
| 96 | ENDIF ELSE ncolors=(!d.n_colors-1) < 255 |
---|
| 97 | color = 1+indgen(changecolor)*(ncolors/(changecolor-1)) |
---|
| 98 | ENDIF ELSE color = 0 |
---|
| 99 | color = color#replicate(1, n_elements(tri)/3/n_elements(color)+1) |
---|
| 100 | ; |
---|
[2] | 101 | tempdeux = systime(1) ; pour key_performance =2 |
---|
| 102 | for i = 0L, n_elements(tri)/3-1 do begin |
---|
| 103 | t = [tri[*, i], tri[0, i]] |
---|
[29] | 104 | IF keyword_set(fill) THEN $ |
---|
| 105 | polyfill, glam[t], gphi[t], color = color[i], _extra = ex $ |
---|
| 106 | ELSE plots, glam[t], gphi[t], color = color[i], _extra = ex |
---|
| 107 | IF keyword_set(wait) THEN wait, wait |
---|
| 108 | IF keyword_set(onebyone) THEN read, a, prompt = 'press a key' |
---|
[2] | 109 | ENDFOR |
---|
| 110 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
| 111 | print, 'temps dessinetri: trace des triangles', systime(1)-tempdeux |
---|
| 112 | ; |
---|
| 113 | if keyword_set(key_performance) THEN print, 'temps dessinetri', systime(1)-tempsun |
---|
| 114 | |
---|
| 115 | return |
---|
| 116 | end |
---|