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

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

corrections of some headers and parameters and keywords case. change of pro2href to replace proidl

  • 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 <proidl>TRIANGULATE</proidl> 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 <proidl>TRIANGULATE</proidl> 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;-
79;
80FUNCTION definetri_e, nx, ny, singular, SHIFTED = shifted
81;
82  compile_opt idl2, strictarrsubs
83;
84   nx = long(nx)
85   ny = long(ny)
86   triangles = lonarr(3, 2*(nx-1)*(ny-1))
87;
88; build the base triangulation with the diamond cut in two triangles
89; by the vertical diagonal
90;
91; first line
92   index = lindgen(nx-1)
93   trinumber = index
94   triangles[0, trinumber] = index
95   triangles[1, trinumber] = index+1
96   triangles[2, trinumber] = index+(nx+1-shifted)
97; last line
98   index = (ny-1)*nx+lindgen(nx-1)
99   trinumber = numtri(index, nx, ny)
100   triangles[0, trinumber] = index
101   triangles[1, trinumber] = index+(-nx+((index/nx+1-shifted) MOD 2))
102   triangles[2, trinumber] = index+1
103; other lines
104   if ny GT 2 then begin
105      index = lindgen(nx, ny)
106      index = index[0:nx-2, 1:ny-2]
107      index = index[*]
108      oddeven = (index/nx+1-shifted) MOD 2
109      trinumber = numtri(index, nx, ny)
110      triangles[0, trinumber] = index
111      triangles[1, trinumber] = index-nx+oddeven
112      triangles[2, trinumber] = index+nx+oddeven
113      triangles[0, trinumber+1] = index+nx+oddeven
114      triangles[1, trinumber+1] = index-nx+oddeven
115      triangles[2, trinumber+1] = index+1
116   endif
117;
118; cut the diamond specified by singular in two triangles
119; by the horizontal diagonal
120;
121   IF keyword_set(singular) then BEGIN
122      yindex = singular/nx
123      otherline = where(yindex NE 0 AND yindex NE (ny-1))
124      if otherline[0] NE -1 then begin
125         index = singular[otherline]
126         oddeven = (index/nx+1-shifted) MOD 2
127         trinumber = numtri(index, nx, ny)
128         triangles[0, trinumber] = index
129         triangles[1, trinumber] = index-nx+oddeven
130         triangles[2, trinumber] = index+1
131         triangles[0, trinumber+1] = index
132         triangles[1, trinumber+1] = index+1
133         triangles[2, trinumber+1] = index+nx+oddeven
134      endif
135
136   endif
137   return, triangles
138end
139
Note: See TracBrowser for help on using the repository browser.