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 | ; |
---|
24 | ; KEYWORD PARAMETERS: |
---|
25 | ; |
---|
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 | ; |
---|
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 | |
---|
55 | PRO dessinetri, tri, x, y, WAIT = wait, ONEBYONE = onebyone, FILL = fill, CHANGECOLOR = changecolor, _extra = ex |
---|
56 | @common |
---|
57 | tempsun = systime(1) ; pour key_performance |
---|
58 | a = '' |
---|
59 | if n_params() EQ 3 then BEGIN |
---|
60 | CASE size(x, /n_dimensions)+size(y, /n_dimensions) OF |
---|
61 | 2:BEGIN |
---|
62 | nx = n_elements(x) |
---|
63 | ny = n_elements(y) |
---|
64 | glam = x#replicate(1., ny) |
---|
65 | gphi = replicate(1., nx)#y |
---|
66 | END |
---|
67 | 4:BEGIN |
---|
68 | glam = x |
---|
69 | gphi = y |
---|
70 | END |
---|
71 | ELSE:BEGIN |
---|
72 | dummy = report('x and y inputs of dessinetri must have the same number of dimensions (1 or 2)') |
---|
73 | return |
---|
74 | END |
---|
75 | ENDCASE |
---|
76 | ENDIF ELSE BEGIN |
---|
77 | grille,mask,glam,gphi, tri = tri |
---|
78 | undefine, mask |
---|
79 | tri = ciseauxtri(tri, glam, gphi) |
---|
80 | ENDELSE |
---|
81 | ; |
---|
82 | IF keyword_set(changecolor) THEN BEGIN |
---|
83 | oldname = !d.name |
---|
84 | if !d.name EQ 'PS' OR !d.name EQ 'Z' then BEGIN |
---|
85 | thisos = strupcase(strmid(!version.os_family, 0, 3)) |
---|
86 | CASE thisOS of |
---|
87 | 'MAC': set_plot, thisOS |
---|
88 | 'WIN': set_plot, thisOS |
---|
89 | ELSE: set_plot, 'X' |
---|
90 | ENDCASE |
---|
91 | ncolors=(!d.n_colors-1) < 255 |
---|
92 | set_plot, oldname |
---|
93 | ENDIF ELSE ncolors=(!d.n_colors-1) < 255 |
---|
94 | color = 1+indgen(changecolor)*(ncolors/(changecolor-1)) |
---|
95 | ENDIF ELSE color = 0 |
---|
96 | color = color#replicate(1, n_elements(tri)/3/n_elements(color)+1) |
---|
97 | ; |
---|
98 | tempdeux = systime(1) ; pour key_performance =2 |
---|
99 | for i = 0L, n_elements(tri)/3-1 do begin |
---|
100 | t = [tri[*, i], tri[0, i]] |
---|
101 | IF keyword_set(fill) THEN $ |
---|
102 | polyfill, glam[t], gphi[t], color = color[i], _extra = ex $ |
---|
103 | ELSE plots, glam[t], gphi[t], color = color[i], _extra = ex |
---|
104 | IF keyword_set(wait) THEN wait, wait |
---|
105 | IF keyword_set(onebyone) THEN read, a, prompt = 'press a key' |
---|
106 | ENDFOR |
---|
107 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
108 | print, 'temps dessinetri: trace des triangles', systime(1)-tempdeux |
---|
109 | ; |
---|
110 | if keyword_set(key_performance) THEN print, 'temps dessinetri', systime(1)-tempsun |
---|
111 | |
---|
112 | return |
---|
113 | end |
---|