Debian Codegraph @

packages/seacas/applications/blot/picknp.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 PICKNP (PROMPT, CURSOR, WINDOW,
9 & NDIM, NUMNPF, XN, YN, ZN, HIDENP, MIDDEF,
10 & IFLD, INTYP, RFIELD, NPRES, *)
11 C=======================================================================
12
13 C --*** PICKNP *** (MESH) Pick the nearest node
14 C -- Written by Amy Gilkey - revised 03/07/88
15 C --
16 C --PICKNP picks a user-selected node. For cursor input, PICKNP puts
17 C --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. For character input, PICKNP gets an X,Y,Z set from the
20 C --free-format fields (defaults are not allowed).
21 C --
22 C --Parameters:
23 C -- PROMPT - IN - the point requested
24 C -- CURSOR - IN - true iff cursor input
25 C -- WINDOW - IN - true iff the coordinates are window versus object
26 C -- coordinates
27 C -- NDIM - IN - the number of dimensions
28 C -- NUMNPF - IN - the number of nodes
29 C -- XN, YN, ZN - IN - the displayed mesh nodal coordinates
30 C -- HIDENP - IN - node i is defined iff HIDENP(i) is true
31 C -- (only if WINDOW)
32 C -- MIDDEF - IN - true if the middle of the displayed mesh is to be the
33 C -- starting position, else use the last selected position
34 C -- (cursor input only)
35 C -- IFLD - IN/OUT - the free-format field index (character input only)
36 C -- INTYP - IN - the free-format field types (character input only)
37 C -- RFIELD - IN - the free-format real fields (character input only)
38 C -- NPRES - OUT - the returned node
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 LOGICAL WINDOW
52 REAL XN(*), YN(*), ZN(*)
53 LOGICAL HIDENP(*)
54 LOGICAL MIDDEF
55 INTEGER INTYP(*)
56 REAL RFIELD(*)
57
58 CHARACTER*80 XPRMPT
59 CHARACTER CH
60
61 IF (CURSOR) THEN
62 IF (.NOT. INITP) THEN
63 CALL PRTERR ('CMDERR', 'No mesh is displayed')
64 GOTO 110
65 END IF
66
67 C --Put up the cursor at the default location and wait for the user
68 C --to select a point
69
70 IF (PROMPT .NE. ' ') THEN
71 XPRMPT = 'Pick node nearest ' // PROMPT // '...'
72 ELSE
73 XPRMPT = ' '
74 END IF
75
76 IF (MIDDEF) THEN
77 DXRES = DXMID
78 DYRES = DYMID
79 ELSE
80 DXRES = DXLAST
81 DYRES = DYLAST
82 END IF
83 CALL GRIKEY (XPRMPT, DXRES, DYRES, CH, *110)
84
85 C --Save the selected position
86
87 DXLAST = DXRES
88 DYLAST = DYRES
89
90 C --Translate the point from device coordinates into object coordinates
91
92 XRES = PKMESH(KLFT) + (DXRES - DMESH(KLFT)) * DVRAT
93 YRES = PKMESH(KBOT) + (DYRES - DMESH(KBOT)) * DVRAT
94
95 ELSE
96
97 C --Get the X,Y,Z point from the free-format fields, no defaults
98
99 IF (WINDOW .OR. (NDIM .NE. 3)) THEN
100 XPRMPT = PROMPT // ' X, Y'
101 ELSE
102 XPRMPT = PROMPT // ' X, Y, Z'
103 END IF
104 NEED = NDIM
105 IF (WINDOW) NEED = 2
106 CALL FFNEED (IFLD, INTYP, 'R', NEED,
107 & XPRMPT(:LENSTR(XPRMPT)), *110)
108 CALL FFREAL (IFLD, INTYP, RFIELD,
109 & 'X', 0.0, XRES, *110)
110 CALL FFREAL (IFLD, INTYP, RFIELD,
111 & 'Y', 0.0, YRES, *110)
112 IF (.NOT. (WINDOW .OR. (NDIM .NE. 3))) THEN
113 CALL FFREAL (IFLD, INTYP, RFIELD,
114 & 'Z', 0.0, ZRES, *110)
115 END IF
116 END IF
117
118 C --Get the coordinates of the node nearest the point
119
120 DISMIN = 10E+30
121 DO 100 INP = 1, NUMNPF
122 IF (WINDOW .AND. NDIM .EQ. 3) THEN
123 IF (HIDENP(INP)) GOTO 100
124 END IF
125 X = XRES - XN(INP)
126 Y = YRES - YN(INP)
127 IF (WINDOW .OR. (NDIM .NE. 3)) THEN
128 DIS = X*X + Y*Y
129 ELSE
130 Z = ZRES - ZN(INP)
131 DIS = X*X + Y*Y + Z*Z
132 END IF
133 IF (DIS .LT. DISMIN) THEN
134 DISMIN = DIS
135 NPRES = INP
136 END IF
137 100 CONTINUE
138
139 RETURN
140
141 110 CONTINUE
142 RETURN 1
143 END