;+ ; ; @file_comments ; Draw the triangulation ; ; @categories ; Utilities ; ; @param TRI {in}{optional} ; Array which define the triangulation (provided by triangule or ; TRIANGULATE) ; ; @param X {in}{optional} ; The x position of points to which the trangulation refer to ; (see the x array provided in triangulate) ; ; @param Y {in}{optional} ; The y position of points to which the trangulation refer to ; (see the y array provided in triangulate) ; ; @keyword WAIT ; =x. to call wait x second between each triangle draw. ; ; @keyword ONEBYONE ; To draw the triangles one by one ; ; @keyword FILL ; To fill the triangles (using polyfill) instead of plotting them ; ; @keyword CHANGECOLOR ; =n. To change the color of each triangle. n colors ; will be used and repeted if necessary. ; ; @uses ; common.pro ; ; @history ; Sebastien Masson (smasson\@lodyc.jussieu.fr) ; ; @version ; $Id$ ; ;- PRO dessinetri, tri, x, y, WAIT = wait, ONEBYONE = onebyone, FILL = fill, CHANGECOLOR = changecolor, _EXTRA = ex ; compile_opt idl2, strictarrsubs ; @common tempsun = systime(1) ; For key_performance a = '' if n_params() EQ 3 then BEGIN CASE size(x, /n_dimensions)+size(y, /n_dimensions) OF 2:BEGIN nx = n_elements(x) ny = n_elements(y) glam = x#replicate(1., ny) gphi = replicate(1., nx)#y END 4:BEGIN glam = x gphi = y END ELSE:BEGIN dummy = report('x and y inputs of dessinetri must have the same number of dimensions (1 or 2)') return END ENDCASE ENDIF ELSE BEGIN grille,mask,glam,gphi, tri = tri undefine, mask tri = ciseauxtri(tri, glam, gphi) ENDELSE ; IF keyword_set(changecolor) THEN BEGIN oldname = !d.name if !d.name EQ 'PS' OR !d.name EQ 'Z' then BEGIN thisos = strupcase(strmid(!version.os_family, 0, 3)) CASE thisOS of 'MAC': set_plot, thisOS 'WIN': set_plot, thisOS ELSE: set_plot, 'X' ENDCASE ncolors=(!d.n_colors-1) < 255 set_plot, oldname ENDIF ELSE ncolors=(!d.n_colors-1) < 255 color = 1+indgen(changecolor)*(ncolors/(changecolor-1)) ENDIF ELSE color = 0 color = color#replicate(1, n_elements(tri)/3/n_elements(color)+1) ; tempdeux = systime(1) ; For key_performance =2 for i = 0L, n_elements(tri)/3-1 do begin t = [tri[*, i], tri[0, i]] IF keyword_set(fill) THEN $ polyfill, glam[t], gphi[t], color = color[i], _extra = ex $ ELSE plots, glam[t], gphi[t], color = color[i], _extra = ex IF keyword_set(wait) THEN wait, wait IF keyword_set(onebyone) THEN read, a, prompt = 'press a key' ENDFOR IF testvar(var = key_performance) EQ 2 THEN $ print, 'temps dessinetri: trace des triangles', systime(1)-tempdeux ; if keyword_set(key_performance) THEN print, 'temps dessinetri', systime(1)-tempsun return end