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

Last change on this file since 276 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
RevLine 
[157]1;+
[231]2;
[157]3; @file_comments
[114]4;
[157]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;
[231]18; @restrictions
[157]19;
20; @examples
[231]21;
[157]22; @history
23;
24; @version
25; $Id$
26;-
27;
[231]28FUNCTION numtri, index, nx, ny
29;
[114]30  compile_opt idl2, strictarrsubs
31;
[2]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
[231]39;
[2]40;+
41;
[150]42; @file_comments
[232]43; Define a triangulation array like <proidl>TRIANGULATE</proidl> but for a
[2]44; E-grid type
45;
[150]46; @categories
47; Make contours with E-grid type
[231]48;
[150]49; @param NX {in}{required}
50; The x dimension array
[2]51;
[150]52; @param NY {in}{required}
53; The y dimension array
[2]54;
[150]55; @param SINGULAR {in}{optional}
[231]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
[186]59; using the horizontal diagonal.
[231]60; The rectangle number is defined by the index (in a nx*ny vector) of the
[186]61; lower-left corner of the rectangle.
[2]62;
[150]63; @keyword SHIFTED
[2]64;
[150]65; @returns
[186]66; Triangles is a 2d array and is dimensions are 3 and (nx-1)*(ny-1).
[232]67; Triangles is defined like in the <proidl>TRIANGULATE</proidl> procedure.
[231]68;
[150]69; @history
[157]70; Sebastien Masson (smlod\@ipsl.jussieu.fr)
[150]71;                       June 2001
[2]72;
[150]73; @version
74; $Id$
[2]75;
[231]76; @todo
[150]77; seb: documenter SHIFTED
[2]78;-
[262]79;
[2]80FUNCTION definetri_e, nx, ny, singular, SHIFTED = shifted
[114]81;
82  compile_opt idl2, strictarrsubs
83;
[2]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.