1 | ;+ |
---|
2 | ; |
---|
3 | ; @file_comments |
---|
4 | ; Draw the triangulation |
---|
5 | ; |
---|
6 | ; @categories |
---|
7 | ; Utilities |
---|
8 | ; |
---|
9 | ; @param TRI {in}{optional} |
---|
10 | ; Array which define the triangulation (provided by <pro>triangule</pro> or |
---|
11 | ; <proidl>TRIANGULATE</proidl>) |
---|
12 | ; |
---|
13 | ; @param X {in}{optional} |
---|
14 | ; The x position of points to which the trangulation refer to |
---|
15 | ; (see the x array provided in triangulate) |
---|
16 | ; |
---|
17 | ; @param Y {in}{optional} |
---|
18 | ; The y position of points to which the trangulation refer to |
---|
19 | ; (see the y array provided in triangulate) |
---|
20 | ; |
---|
21 | ; @keyword WAIT |
---|
22 | ; =x. to call wait x second between each triangle draw. |
---|
23 | ; |
---|
24 | ; @keyword ONEBYONE |
---|
25 | ; To draw the triangles one by one |
---|
26 | ; |
---|
27 | ; @keyword FILL |
---|
28 | ; To fill the triangles (using polyfill) instead of plotting them |
---|
29 | ; |
---|
30 | ; @keyword CHANGECOLOR |
---|
31 | ; =n. To change the color of each triangle. n colors |
---|
32 | ; will be used and repeted if necessary. |
---|
33 | ; |
---|
34 | ; @uses |
---|
35 | ; <pro>common</pro> |
---|
36 | ; |
---|
37 | ; @history |
---|
38 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
39 | ; |
---|
40 | ; @version |
---|
41 | ; $Id$ |
---|
42 | ; |
---|
43 | ;- |
---|
44 | PRO dessinetri, tri, x, y, WAIT=wait, ONEBYONE=onebyone, FILL=fill $ |
---|
45 | , CHANGECOLOR=changecolor, _EXTRA=ex |
---|
46 | ; |
---|
47 | compile_opt idl2, strictarrsubs |
---|
48 | ; |
---|
49 | @common |
---|
50 | tempsun = systime(1) ; For key_performance |
---|
51 | a = '' |
---|
52 | if n_params() EQ 3 then BEGIN |
---|
53 | CASE size(x, /n_dimensions)+size(y, /n_dimensions) OF |
---|
54 | 2:BEGIN |
---|
55 | nx = n_elements(x) |
---|
56 | ny = n_elements(y) |
---|
57 | glam = x#replicate(1., ny) |
---|
58 | gphi = replicate(1., nx)#y |
---|
59 | END |
---|
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 |
---|
69 | ENDIF ELSE BEGIN |
---|
70 | grille,mask,glam,gphi, tri = tri |
---|
71 | undefine, mask |
---|
72 | tri = ciseauxtri(tri, glam, gphi) |
---|
73 | ENDELSE |
---|
74 | ; |
---|
75 | IF keyword_set(changecolor) THEN BEGIN |
---|
76 | oldname = !d.name |
---|
77 | if !d.name EQ 'PS' OR !d.name EQ 'Z' then BEGIN |
---|
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 |
---|
89 | color = color#replicate(1, n_elements(tri)/3/n_elements(color)+1) |
---|
90 | ; |
---|
91 | tempdeux = systime(1) ; For key_performance =2 |
---|
92 | for i = 0L, n_elements(tri)/3-1 do begin |
---|
93 | t = [tri[*, i], tri[0, i]] |
---|
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' |
---|
99 | ENDFOR |
---|
100 | IF testvar(var = key_performance) EQ 2 THEN $ |
---|
101 | print, 'temps dessinetri: trace des triangles', systime(1)-tempdeux |
---|
102 | ; |
---|
103 | if keyword_set(key_performance) THEN print, 'temps dessinetri', systime(1)-tempsun |
---|
104 | |
---|
105 | return |
---|
106 | end |
---|