Debian Codegraph @

packages/seacas/applications/blot/pick3d.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 PICK3D (PROMPT, CURSOR,
9 & NUMNPF, XN, YN, ZN, HIDENP, MIDDEF, IFLD, INTYP, RFIELD,
10 & XRES, YRES, ZRES, *)
11 C=======================================================================
12
13 C --*** PICK3D *** (MESH) Pick an object point
14 C -- Written by Amy Gilkey - revised 02/05/88
15 C --
16 C --PICK3D picks a user-selected object point. For cursor input, PICK3D
17 C --puts a cursor on the screen, waits until the user positions the cursor,
18 C --then translates the position into a 3D point by finding the nearest
19 C --node and returning its unrotated, deformed coordinates. For character
20 C --input, PICK3D gets an X,Y,Z set from the free-format fields (defaults
21 C --are not allowed).
22 C --
23 C --Parameters:
24 C -- PROMPT - IN - the point requested
25 C -- CURSOR - IN - true iff cursor input
26 C -- NUMNPF - IN - the number of nodes (cursor input only)
27 C -- XN, YN, ZN - IN - the displayed mesh nodal coordinates
28 C -- (cursor input only)
29 C -- HIDENP - IN - node i is defined iff HIDENP(i) is true
30 C -- (cursor input only)
31 C -- MIDDEF - IN - true if the middle of the displayed mesh is to be the
32 C -- starting position, else use the last selected position
33 C -- (cursor input only)
34 C -- IFLD - IN/OUT - the free-format field index (character input only)
35 C -- INTYP - IN - the free-format field types (character input only)
36 C -- RFIELD - IN - the free-format real fields (character input only)
37 C -- NPRES - OUT - the returned node
38 C -- XRES, YRES, ZRES - OUT - the returned point
39 C -- * - return statement if error picking point
40 C --
41 C --Common Variables:
42 C -- Sets DXLAST, DYLAST of /PICK/
43 C -- Uses /PICK/
44
45 PARAMETER (KLFT=1, KRGT=2, KBOT=3, KTOP=4, KNEA=5, KFAR=6)
46
47 include 'pick.blk'
48
49 CHARACTER*(*) PROMPT
50 LOGICAL CURSOR
51 REAL XN(*), YN(*), ZN(*)
52 LOGICAL HIDENP(*)
53 LOGICAL MIDDEF
54 INTEGER INTYP(*)
55 REAL RFIELD(*)
56
57 CHARACTER*80 XPRMPT
58 CHARACTER CH
59
60 IF (CURSOR) THEN
61 IF (.NOT. INITP) THEN
62 CALL PRTERR ('CMDERR', 'No mesh is displayed')
63 GOTO 110
64 END IF
65
66 C --Put up the cursor at the default location and wait for the user
67 C --to select a point
68
69 IF (PROMPT .NE. ' ') THEN
70 XPRMPT = 'Pick node nearest ' // PROMPT // '...'
71 ELSE
72 XPRMPT = ' '
73 END IF
74
75 IF (MIDDEF) THEN
76 DXRES = DXMID
77 DYRES = DYMID
78 ELSE
79 DXRES = DXLAST
80 DYRES = DYLAST
81 END IF
82 CALL GRIKEY (XPRMPT, DXRES, DYRES, CH, *110)
83
84 C --Save the selected position
85
86 DXLAST = DXRES
87 DYLAST = DYRES
88
89 C --Translate the point from device coordinates into object coordinates
90
91 XRES = PKMESH(KLFT) + (DXRES - DMESH(KLFT)) * DVRAT
92 YRES = PKMESH(KBOT) + (DYRES - DMESH(KBOT)) * DVRAT
93
94 C --Get the coordinates of the node nearest the point
95
96 DISMIN = 10E+30
97 DO 100 INP = 1, NUMNPF
98 IF (HIDENP(INP)) GOTO 100
99 X = XRES - XN(INP)
100 Y = YRES - YN(INP)
101 DIS = X*X + Y*Y
102 IF (DIS .LT. DISMIN) THEN
103 DISMIN = DIS
104 NPRES = INP
105 END IF
106 100 CONTINUE
107
108 CALL UNROT (1, 1, PKRMAT, PKRCEN,
109 & XN(NPRES), YN(NPRES), ZN(NPRES), XRES, YRES, ZRES)
110
111 ELSE
112
113 C --Get the X,Y,Z point from the free-format fields, no defaults
114
115 XPRMPT = PROMPT // ' X, Y, Z'
116 CALL FFNEED (IFLD, INTYP, 'R', 3,
117 & XPRMPT(:LENSTR(XPRMPT)), *110)
118 CALL FFREAL (IFLD, INTYP, RFIELD,
119 & 'X', 0.0, XRES, *110)
120 CALL FFREAL (IFLD, INTYP, RFIELD,
121 & 'Y', 0.0, YRES, *110)
122 CALL FFREAL (IFLD, INTYP, RFIELD,
123 & 'Z', 0.0, ZRES, *110)
124 END IF
125
126 RETURN
127
128 110 CONTINUE
129 RETURN 1
130 END