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

Last change on this file since 171 was 157, checked in by navarro, 18 years ago

header improvements + xxx doc

  • 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
63; in using the vertical diagonal. Singular is a vector which
64; contains the rectangles numbers which are cut in using the
65; horizontal diagonal.
66; The rectangle number is define by the index (in a nx*ny
67; vector) of the 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
74; (nx-1)*(ny-1)
75; Triangles is defined like in the TRIANGULATE procedure.
76;       
77; @history
78; Sebastien Masson (smlod\@ipsl.jussieu.fr)
79;                       June 2001
80;
81; @version
82; $Id$
83;
84; @todo
85; seb: documenter SHIFTED
86;-
87FUNCTION definetri_e, nx, ny, singular, SHIFTED = shifted
88;
89  compile_opt idl2, strictarrsubs
90;
91   nx = long(nx)
92   ny = long(ny)
93   triangles = lonarr(3, 2*(nx-1)*(ny-1))
94;
95; build the base triangulation with the diamond cut in two triangles
96; by the vertical diagonal
97;
98; first line
99   index = lindgen(nx-1)
100   trinumber = index
101   triangles[0, trinumber] = index
102   triangles[1, trinumber] = index+1
103   triangles[2, trinumber] = index+(nx+1-shifted)
104; last line
105   index = (ny-1)*nx+lindgen(nx-1)
106   trinumber = numtri(index, nx, ny)
107   triangles[0, trinumber] = index
108   triangles[1, trinumber] = index+(-nx+((index/nx+1-shifted) MOD 2))
109   triangles[2, trinumber] = index+1
110; other lines
111   if ny GT 2 then begin
112      index = lindgen(nx, ny)
113      index = index[0:nx-2, 1:ny-2]
114      index = index[*]
115      oddeven = (index/nx+1-shifted) MOD 2
116      trinumber = numtri(index, nx, ny)
117      triangles[0, trinumber] = index
118      triangles[1, trinumber] = index-nx+oddeven
119      triangles[2, trinumber] = index+nx+oddeven
120      triangles[0, trinumber+1] = index+nx+oddeven
121      triangles[1, trinumber+1] = index-nx+oddeven
122      triangles[2, trinumber+1] = index+1
123   endif
124;
125; cut the diamond specified by singular in two triangles
126; by the horizontal diagonal
127;
128   IF keyword_set(singular) then BEGIN
129      yindex = singular/nx
130      otherline = where(yindex NE 0 AND yindex NE (ny-1))
131      if otherline[0] NE -1 then begin
132         index = singular[otherline]
133         oddeven = (index/nx+1-shifted) MOD 2
134         trinumber = numtri(index, nx, ny)
135         triangles[0, trinumber] = index
136         triangles[1, trinumber] = index-nx+oddeven
137         triangles[2, trinumber] = index+1
138         triangles[0, trinumber+1] = index
139         triangles[1, trinumber+1] = index+1
140         triangles[2, trinumber+1] = index+nx+oddeven
141      endif
142
143   endif
144   return, triangles
145end
146
Note: See TracBrowser for help on using the repository browser.