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

Last change on this file since 231 was 231, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

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