source: trunk/SRC/ToBeReviewed/TRIANGULATION/definetri_e.pro @ 212

Last change on this file since 212 was 186, checked in by pinsard, 18 years ago

introducing hyperlinks in idldoc outputs (1/2)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1;+
2; @file_comments
3;
4;
5; @categories
6;
7;
8; @param INDEX
9; It is the tick mark index which starts at 0.
10;
11; @param NX {in}{required}
12; The x dimension array
13;
14; @param NY {in}{required}
15; The y dimension array
16;
17;
18; @returns
19;
20;
21; @restrictions
22;
23;
24; @examples
25;
26;
27; @history
28;
29;
30; @version
31; $Id$
32;-
33 function numtri, index, nx, ny
34;
35  compile_opt idl2, strictarrsubs
36;
37
38   y=index/nx
39   x=index-y*nx
40   numtri = (y NE 0)*(nx-1)*(2*(y-1)+1) + (2-(y EQ (ny-1) OR y EQ (ny-1)))*x
41
42   return, numtri
43end
44
45
46;+
47;
48; @file_comments
49; Define a triangulation array like TRIANGULATE but for a
50; E-grid type
51;
52; @categories
53; Make contours with E-grid type
54;
55; @param NX {in}{required}
56; The x dimension array
57;
58; @param NY {in}{required}
59; The y dimension array
60;
61; @param SINGULAR {in}{optional}
62; When singular is undefined all rectangles are cut in using the vertical
63; diagonal.
64; Singular is a vector which contains the rectangles numbers which are cut in
65; using the horizontal diagonal.
66; The rectangle number is defined by the index (in a nx*ny vector) of the
67; lower-left corner of the rectangle.
68;
69; @keyword SHIFTED
70;
71;
72; @returns
73; Triangles is a 2d array and is dimensions are 3 and (nx-1)*(ny-1).
74; Triangles is defined like in the TRIANGULATE procedure.
75;       
76; @history
77; Sebastien Masson (smlod\@ipsl.jussieu.fr)
78;                       June 2001
79;
80; @version
81; $Id$
82;
83; @todo
84; seb: documenter SHIFTED
85;-
86FUNCTION definetri_e, nx, ny, singular, SHIFTED = shifted
87;
88  compile_opt idl2, strictarrsubs
89;
90   nx = long(nx)
91   ny = long(ny)
92   triangles = lonarr(3, 2*(nx-1)*(ny-1))
93;
94; build the base triangulation with the diamond cut in two triangles
95; by the vertical diagonal
96;
97; first line
98   index = lindgen(nx-1)
99   trinumber = index
100   triangles[0, trinumber] = index
101   triangles[1, trinumber] = index+1
102   triangles[2, trinumber] = index+(nx+1-shifted)
103; last line
104   index = (ny-1)*nx+lindgen(nx-1)
105   trinumber = numtri(index, nx, ny)
106   triangles[0, trinumber] = index
107   triangles[1, trinumber] = index+(-nx+((index/nx+1-shifted) MOD 2))
108   triangles[2, trinumber] = index+1
109; other lines
110   if ny GT 2 then begin
111      index = lindgen(nx, ny)
112      index = index[0:nx-2, 1:ny-2]
113      index = index[*]
114      oddeven = (index/nx+1-shifted) MOD 2
115      trinumber = numtri(index, nx, ny)
116      triangles[0, trinumber] = index
117      triangles[1, trinumber] = index-nx+oddeven
118      triangles[2, trinumber] = index+nx+oddeven
119      triangles[0, trinumber+1] = index+nx+oddeven
120      triangles[1, trinumber+1] = index-nx+oddeven
121      triangles[2, trinumber+1] = index+1
122   endif
123;
124; cut the diamond specified by singular in two triangles
125; by the horizontal diagonal
126;
127   IF keyword_set(singular) then BEGIN
128      yindex = singular/nx
129      otherline = where(yindex NE 0 AND yindex NE (ny-1))
130      if otherline[0] NE -1 then begin
131         index = singular[otherline]
132         oddeven = (index/nx+1-shifted) MOD 2
133         trinumber = numtri(index, nx, ny)
134         triangles[0, trinumber] = index
135         triangles[1, trinumber] = index-nx+oddeven
136         triangles[2, trinumber] = index+1
137         triangles[0, trinumber+1] = index
138         triangles[1, trinumber+1] = index+1
139         triangles[2, trinumber+1] = index+nx+oddeven
140      endif
141
142   endif
143   return, triangles
144end
145
Note: See TracBrowser for help on using the repository browser.