Debian Codegraph @

packages/seacas/applications/blot/shdsph.f

raw
1 C Copyright(C) 1999-2020 National Technology & Engineering Solutions
2 C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 C NTESS, the U.S. Government retains certain rights in this software.
4 C
5 C See packages/seacas/LICENSE for details
6
7 C=======================================================================
8 SUBROUTINE SHDSPH (LENE, LINK, NUMLNK, NUMATR, XN, YN, ZN, ATRIB,
9 * BLKCOL, IDELB, ISPSOR, RAD,
10 * IELBST, ISPBLK, SHDCOL, ISHDCL, HIDENP, *)
11 C=======================================================================
12
13 C --*** SYMSPH *** (DETOUR) Plot element spheres
14 C -- Written by Lee Taylor, 07/12/88
15 C -- Amy Gilkey, 10/12/87
16 C -- D. P. Flanagan, 12/08/83
17 C -- Modified version 1.1a November 1990 - R.J. Meyers
18 C -- added color coded sphere capability
19 C --
20 C --SYMSPH drives the user symbol interface for element variables.
21 C --It processes each element by element block, computing scaling factors
22 C --and element information, then calling the user symbol routine.
23 C --Only elements of selected element blocks are drawn.
24 C --
25 C --Parameters:
26 C -- LENE - IN - the cumulative element counts by element block
27 C -- LINK - IN - the connectivity array
28 C -- NUMLNK - IN - the number of nodes per element by block
29 C -- NUMATR - IN - the number of attributes per element by block
30 C -- XN, YN, ZN - IN - the nodal coordinates
31 C -- ATRIB - IN - the element attributes array
32 C -- BLKCOL - IN/OUT - the user selected colors of the element blocks.
33 C -- BLKCOL(0) = 1 if the user defined material
34 C -- colors should be used in mesh plots.
35 C -- = -1 if program selected colors should
36 C -- be used.
37 C -- BLKCOL(i) = the user selected color of element
38 C -- block i:
39 C -- -2 - no color selected by user.
40 C -- -1 - black
41 C -- 0 - white
42 C -- 1 - red
43 C -- 2 - green
44 C -- 3 - yellow
45 C -- 4 - blue
46 C -- 5 - cyan
47 C -- 6 - magenta
48 C -- * - return statement if the cancel function is active
49 C --
50 C --Common Variables:
51 C -- Uses NELBLK of /DBNUMS/
52
53 PARAMETER (KLFT=1, KRGT=2, KBOT=3, KTOP=4, KNEA=5, KFAR=6)
54 include 'mshlim.blk'
55 include 'd3nums.blk'
56 include 'dbnums.blk'
57 include 'sphele.blk'
58
59 INTEGER LENE(0:NELBLK),LINK(*)
60 INTEGER NUMLNK(NELBLK),NUMATR(NELBLK)
61 REAL XN(*), YN(*), ZN(*), ATRIB(*)
62 INTEGER BLKCOL(0:NELBLK)
63 INTEGER IDELB(*)
64 INTEGER ISPSOR(NUMEL)
65 REAL RAD(NUMEL)
66 INTEGER IELBST(NELBLK), ISPBLK(NUMEL)
67 C ... SHDCOL(1, *) = Red Component
68 C SHDCOL(2, *) = Green Component
69 C SHDCOL(3, *) = Blue Component
70 C SHDCOL(4-7,*) - Future Use
71 REAL SHDCOL(7,NELBLK)
72 C ... ISHDCL(1, *) = -1 if color not set, >0 if color set
73 C ISHDCL(2, *) = Number of colors to use for this block (SET if 0)
74 C ISHDCL(3, *) = Starting location in color map (SET)
75 INTEGER ISHDCL(3,NELBLK)
76 LOGICAL HIDENP(*)
77
78 REAL XSI(4),YSI(4)
79 LOGICAL FIRST
80
81 include 'icrnbw.blk'
82 include 'light.blk'
83 include 'sphere.blk'
84 DATA FIRST /.TRUE./
85
86 XMIN = ZMMESH(KLFT)
87 XMAX = ZMMESH(KRGT)
88 YMIN = ZMMESH(KBOT)
89 YMAX = ZMMESH(KTOP)
90
91 if (.not. is3dim) return
92
93 IF ( FIRST ) THEN
94 FIRST = .FALSE.
95 END IF
96
97 C ... Calculate surface normals
98 C ... On a unit sphere, normals are simply x,y,z coords of point.
99 do 30 ip=1, npoly
100 i = icon(1,ip)
101 j = icon(2,ip)
102 k = icon(3,ip)
103 l = icon(4,ip)
104 XMAG = (xpts(i) + xpts(j) + xpts(k) + xpts(l)) / 4.0
105 YMAG = (ypts(i) + ypts(j) + ypts(k) + ypts(l)) / 4.0
106 ZMAG = 1.0 - SQRT(XMAG**2 + YMAG**2)
107
108 C ... Determine dot product of surface normal and light vector.
109 SMAG = 0.0
110 SHDMX = 0.0
111 DO 20 J = 1, NLIT
112 SMAG = SMAG + max(0.0, (XMAG * LITE(5,J) +
113 * YMAG * LITE(6,J) + ZMAG * LITE(7,J)) * LITE(8,J))
114 20 CONTINUE
115 SHADE(IP) = SMAG
116 SHDMX = MAX(SHDMX, SMAG)
117 30 CONTINUE
118 SHDMX = MIN(1.0, 1.0 / SHDMX)
119 DO 40 ip = 1, npoly
120 SHADE(IP) = SHADE(IP) * SHDMX
121 40 continue
122
123 iel = 0
124 IRAD = 1
125 ILNK = 1
126 do 104 ielb = 1, nelblk
127 nel = lene(ielb) - lene(ielb-1)
128 if (numlnk(ielb) .eq. 1 .AND. IELBST(IELB) .GT. 0) then
129 DO 102 ISPH = ILNK, ILNK+NEL-1
130 NODE = LINK(ISPH)
131 IF (IS3DIM) THEN
132 IF (HIDENP(NODE)) GOTO 102
133 END IF
134 if (numatr(ielb) .ge. 1) then
135 RAD(NODE) = DEFRAD * ATRIB(IRAD)
136 else
137 RAD(NODE) = DEFRAD
138 end if
139 X = XN(NODE)
140 Y = YN(NODE)
141 R = RAD(NODE)
142 C ... Determine if portion of sphere is in viewing window
143 if (x+r .ge. xmin .and. x-r .le. xmax .and.
144 * y+r .ge. ymin .and. y-r .le. ymax) then
145 iel = iel + 1
146 ISPSOR(IEL) = NODE
147 ISPBLK(NODE) = ielb
148 end if
149 IRAD = IRAD + NUMATR(IELB)
150 102 continue
151 ELSE
152 IRAD = IRAD + NEL * NUMATR(IELB)
153 END IF
154 ILNK = ILNK + NEL * NUMLNK(IELB)
155 104 continue
156 numsph = iel
157 C ... Sort elements from smallest Z coord to largest.
158 C Sort is based on element center.
159 call indexx (zn, ispsor, numsph, .FALSE.)
160
161 C ... Set colors for all blocks
162 call setcol (nelblk, shdcol, ishdcl, ielbst, blkcol, idelb)
163
164 C ... Plotting of spheres starts here.
165 do 130 iel = 1, numsph
166 node = ispsor(iel)
167 xc = xn(node)
168 yc = yn(node)
169 rd = rad(node)
170 ielb = ispblk(node)
171 mincol = ishdcl(3,ielb)
172 ncol = ishdcl(2,ielb)
173
174 do 120 ip = 1, npoly
175 do 118 in = 1, 4
176 xsi(in) = xc + rd * xpts(icon(in,ip))
177 ysi(in) = yc + rd * ypts(icon(in,ip))
178 118 continue
179 smag = shade(ip)
180 ICOL = MINCOL +
181 * min(NCOL-1, max(1, NINT(SHADE(IP) * DBLE(NCOL))))
182 CALL GRCOLR (ICOL)
183 CALL MPD2PG (4, XSI, YSI, 'S')
184 120 continue
185 130 continue
186 call pltflu
187
188 CALL GRCOLU('STANDARD')
189
190 RETURN
191 END