Post on 17-Aug-2020
transcript
USGS-OFR-85-233-B USGS-OFR-85-233-B
UNITED STATES DEPARTMENT OF THE INTERIOR
GEOLOGICAL SURVEY
POLYGON - Program Listing
by
Bruce A. Chuchel U.S. Geological Survey Menlo Park/ CA/ 94025
Open File Report 85-233-B
Prepared in cooperation with theNevada Operations Office
U. S. Department of Energy(Interagency Agreement DE-AI08-78ET44802)
This report is preliminary and has not been reviewed forconformity with U.S. Geological Survey editorial standards.
Use of brand names in this report is for the sake of descriptiononly, and does not constitute endorsement by the U. S.
Geological Survey. Although this program has been tested/the U.S. Geological Survey makes no guarantee of correct results.
Menlo Park/ California
1985
USGS-OFR-85-233-B USGS-OFR-85-233-B
UNITED STATESDEPARTMENT of INTERIOR
GEOLOGICAL SURVEY
POLYGON - Program Listing
BY
B. A. CHUCHEL 1
U.S. Geological Survey/ Menlo Park/ CA
INTRODUCTION
This report contains a listing of the FORTRAN program POLYGON. The Open- File Report #85-233-A [Chuchel, 1985] describes in detail how to use the POLYGON program. POLYGON features color-graphics, an interactive user dialogue, brief help messages, and "zooming" to selected portions of the terminal screen in order to edit and manipulate polygons using a graphics cursor or the Envision mouse. POLYGON has been developed in support of the U. S. Geological Survey's effort to characterize potential radioactive waste storage sites at the Nevada Test Site for the Nevada Waste Storage Investigations project.
POLYGON is a computer program for developing polygonal models on an Envision color-graphics terminal. The term "polygonal model" means (1) the coordinates of the corners of a set of polygonal shapes, (2) a set of parameters and parameter descriptions attached to each polygon, and (3) the topologic structure that links the polygons in a storage hierarchy. POLYGON uses a data structure called a quadruply linked tree [Knuth, 1969, p. 352] to store the topology of the collection of polygons composing the model.
These polygonal shapes may subsequently be used by independent modeling programs to represent three-dimensional shapes of gravitational or magnetic sources; for example, output from POLYGON is directly compatible with programs MAGPOLY or GRAVPOLY [Plouff, 1975a, 1975b; Godson 1983a, 1983b] and PFGRAV3D or PFMAG3D [Blakely, 1981].
A model may consist of up to 100 polygons; each with up to 100 vertices. Each polygon may be assigned up to ten numerical parameters, each with a descriptive label. A polygon's sides may not be self-crossing; perimeters of polygons are not allowed to cross, but any number of polygons can be completely contained within other polygons.
POLYGON is written in DEC (Digital Equipment Corporation) extended FORTRAN 77 and is presently operational on the USGS, Branch of Geophysics, VAX/VMS computer. The program is written to operate on the Envision 200 series of color-graphics terminals by Envision Technology Incorporated. The 200 series features a Tektronix 4014 compatible instruction set [Envision, 1983]. Modular construction of the program should make it relatively simple to convert to other color-graphics terminals.
REFERENCES
Blakely, R. J., 1981, A program for computing the magnetic anomaly overdigital topography: U.S. Geological Survey Open-File Report 81-298, 46 p.
Chuchel, B. A. , 1985, POLYGON - An interactive program for constructing and editing the geometries of polygons using a color graphics terminal: U.S. Geological Survey Open-File Report 85-233-A, 38 p.
Envision Technology, INC., 1983, Models 220 and 230 color graphics terminals reference manual #20640-1: San Jose, CA, 178 p.
Godson, R. H. , 1983a, MAGPOLY: A modification of DONALD PLOUFF's 3-D magnetic modelling program: U.S. Geological Survey Open-File Report 83-345, 48p.
Godson, R. H. , 1983b, GRAVPOLY: A modification of DONALD PLOUFF'S 3-D gravity modelling program: U.S. Geological Survey Open-File Report 83-346, 53p.
Knuth, D. E., 1969, The art of computer programming, Volume 1/Fundamental Algorithms: Menlo Park, CA, Addison-Wesley, 634p.
Plouff, Donald, 1975a, Derivation of formulas and FORTRAN programs to compute magnetic anomalies of prisms: U.S. Geological Survey Report, 112 p., available from National Technical Information Service, No. PB-243-525, U.S. Department of Commerce, Springfield, VA, 22161.
Plouff, Donald, 1975b, Derivation of formulas and FORTRAN programs to compute gravity anomalies of prisms: U.S. Geological Survey Report, 90 p., available from National Technical Information Service, No. PB-243-526, U.S. Department of Commerce, Springfield, VA 22161.
c+ccccccccccccccccccccc-c
Program POLYGON
Is designed to facilitate the construction
and editing of
th« geometries of
polygons Interactively
on an Envision color graphics terminal.
Various output files may be generated; for example, output
files compatible with the programs GRAVPOLY [Godson, 1983b]
and MAGPOLY [Godson, 1983a] may be created.
A standard
grid file may also be created which Is
compatible with the
programs PFGRAV3D and PFMAG3D [Blakely, 1981].
POLYGON can
take Input from the Envision mouse or
the cursor
control keys on
the numeric keypad.
For detailed Information
about using the program see the USGS Open-File report *85-Zrfc?r
"POLYGON -
An Interactive Program For
Constructing and Edit
ing the Geometries of
Polygons Using A Color Graphics Terminal
Author: Bruce A.
Chuchel ,
USGS, Menlo Park, CA.,
94025
Version 0.5
2/21/84
Version 1.0
12/09/84
CharacterMS label
Common /topology/ 1nfo( 100) , 1 u
pper ( 100) , 1down( 100) ,
AlleftC 100) , 1r1ght( 100)
Common /newtopo/ Inf new( 100) , 1upnew( 100) , 1dwnew( 100) ,
AllfnewC 100), Irtnewl 100)
Common /screenloc/ntotal ,numply( 100) ,xscr( 100, 100) ,yscr ( 100, 100)
Common /subscreen/xscrn( 2 ) , y
scrn(2),xgrd(2) ,ygrd< 2)
Common /box/xm1nbx( 100) , x
maxbx( 100) , y
mlnbx ( 100) ,ymaxbx( 100)
Common /1nout/x1n( 100, 100) , y 1 n( 100, 100) , xoutl 100, 100) ,
&yout(100, 100)
Common /parameter /parm( 100, 10)
/label s/ label/ Junk /ngb t
op , J
nktopC 100) , n
gbloc , J
nkloc( 100)
/gr 1d/grd( 250000)
/grid specs/ Id ,pgm, n
c,nr,nz,xo,dx,yo,dy,1proj,cm,bl
/scale/xsc,ysc,xstart,ystart,x1n1t,y1n1t
/subgrld/lcmln, Icmax, Irmln, 1
rmax,ncm1n,ncmax,nrm1n,nrmax
/scalefacts/ 1wc0, J
wc0,nxp 1 x , nyp 1 x ,p 1 xd 1m
/cal c/ncont , cml n , cdel
/screenbnd/x Ieft,xr1ght,ybot, ytop
/ names /grdnam,modnam , m
odgrd
/zoom/ Izoom, 1 zval ,
nzoom,ncm1nz( 5 ) , n
cmaxz (5),nrm1nz(5),
&nrmaxz(5)
Common
/ command s / n
ma x ,eps 1 1n, del In, del o
ut
/max/nptmax
/mlsc/ncol ,nrow,f Irst ,ntop, If Irst
/f lags/mcf lag , v
otf Ig
/model /mdfl jg/or Ig Inal / I
wcorg , J
wcorg ,nxorgp, n
yorgp
/colors /plyc 1 r ,black ,wh Ite
/f 1 1 1 /open , sol Id, f 1 1 typ
Common
Common
Common
Common
Common
Common
Common
Common
Common
Common
Common
Common
Common
Common
Common
Common
Common
Common
Character open*! , sol 1d*l ,f 1 I
typM ,pl ycl r*l ,
black*l ,wh1te*l
Character ans*l ,mcflag*2,f1rst*l , c
olor*!
Character vot fig*-, type*! , t
erm* 1 , 1d*56 ,
pgm*8
Character quest* 80, com* 2 ,
grdnam*80,modnam*80, modgrd* 80
- Print welcoming banner.....
4Call
wrtmsgC'**
Cal1 wrtmsg('
Welcome to
POLYGON version 1.0...12/09/84')
Cal1 wrtmsg( "
CC -
Get grid (grd).
CCall grdlndtest)
If (1test.EQ.-l)Go To 100
ncol»nc
nrow»nr
CC - Ask user If
verbose or
terse questioning Is
desired.
CCall askvotCvotfIg)
If (votfIg.EQ.'Q*>Go To 100
C *
C -
Initialize values used In
scaling and drawing grid on
C terminal
CCall Initial
CC - Scale grid to
screen.
CCall scaleg2sc(0)
xsc*f1oat(nxp1x)
ysc*float(nyp1x)
Iwcorg*1wc0
Jwco
rg»Jw
cJ0fnxorgp*nxp1x
nyorgp«nyp1x
Call setbnd
Call setf11(sol Id)
Cal1 clrply
CC - Ask for polygon command
CIf 1
rst»l
com* *h*
1test-0
Do 10
whlleC1test.EQ.0)
quest*8' Polygon command (p/o/r/w/z/h/q) *
1val*1aquest(quest,com,*(aZ)',2)
ff (com.EQ. *P» .
OR.com.EQ. 'pM Then
Call pdcom<1test2)
Else If
(com.EQ.'0'.OR.com.EQ.'o'> Then
If (mdflag.EQ.1) Then
Call outcom(ItestZ)
ElseCal1 errmod
End If
Else If
(com.EQ.*R*.OR.com.EQ.'r') Then
Call mod1n(1test2)
If (IfIrst.EQ.0.AND.ItestZ.EQ.1) Then
Call setclr(plyclr)
Call setf11(open)
Call drawwa1k
Call setfll(solld)
End If
If (ItestZ.EQ.1>mdflag-l
Else If
(com.EQ.'W.OR.com.EQ.'w') Then
Cal1 modout(ItestZ)
Else If
(com.EQ.'Z'.OR.com.EQ.'z'> Then
Call zomcom(IfIrst,ItestZ)
C else If
(com.eq.'S') then
C call comcom(ItestZ)
Else If
(com.EQ.'H'.OR.com.EQ.'h') Then
Cal1 hlpcom
Else If
(com.EO.'0'.OR.com.EQ.'q'.OR.Ival.EQ.-l) Then
Cal1 askend(ans)
If (ans.EO.'Y'.OR.ans.EQ.'y') Then
Call modout<ItestZ)
End If
ttest=l ElseCal1
errmsg
com= *h * End
IfIf
(com.NE.*h»)com='p*
10 End
Do C
100 Continue
Call closup
Stop * End
of Polygon'
End*********************************************************************
addply - Subroutine called
by plycom that
allows the
user to
enter a
new polygon and
positions this
polygon 1n
the
topology array.
********************************************************************
Subroutine addp1y(Itest)
Dimension xpoly(100),ypoly(100),xloc(100),yloc(100)
Common /box/xmtnbx(100),xmaxbx(100),ym1nbx(100),ymaxbxl100)
Common /commands/nmax,eps1In,del In,delout
Common /ca1c/ncont,cmln,cdel
Common /mlsc/ncol,nrow,f1rst,ntop, If Irst
Common /screenloc/ntota1,numply(100),xscr(100,100),yscr(100,100)
Common /temp/ntemp,xtemp(100),ytemp(100)
Common /flags/mcflag
Common /zoom/1 z
oom,1zva1,nzoom,ncm1nz(5),ncmaxz(5),nrm1nz(5),
&nrmaxz(5)
Common /colors/plyeIr,black,whIte
Common /f111/open,sol Id,f1Ityp
Character Intype*!,ans*2,ans2*2,mcflag*2,f1rst*l
Character open*!,sol1d*l,f1ltyp*l,p1ydr*l,black*!,wh1te*l
CItestM
Call setclr(plyclr)
lntype='0'Call
setl1n(Intype)
CC -
Ask If
user needs
help C
If (first.EG.'y') Then
Call hlpaddtItest)
End If
CC -
Find the
top (root)
node of
tree
CIf
(ntotal.GT.0) Then
Call fndtop(ntop)
If (ntop.LE.0)
Then 1test=-l Go
To 100
End If
End If
CC -
Set scaling variables for
drawing on
terminal (scalen)
CCal1
scalen
cC -
Find the
next available polygon npoly.
If one
exists. C
20 Continue
ans«'U'Call
fndnum(npoly)
If (npoly.LE.0)
Then If
(npoly.EQ.0) Then
Call wrtmsgC'
*** Polygon list
full ***'}
1test«0 ElseCall
wrtmsgC' Error
In fndnum routine')
1test=-l End
If Go To
100 End
If CC
- Print message about
entry Into
Polygon drawing mode
CCall
enhmsgC'*** Add
polygon mode
****) CC
- Initialize the
temporary array.
CCall
Inttmp 30
Continue
CC - Allow user
to enter
and draw the
polygon on
the terminal,
C find
the set
of x,y
points that
define the
polygon. C
Cal1 getply(xloc,yloc,nbrpts,mcflag,Itest)
If (mcflag.EQ.'Q')Go To
100 If
(Itest.LE.0) Then
Cal1 askstolans)
If (nbrpts.GE.2)
Then Call
setclr(black)
Call drwpln(xloc,yloc,nbrpts)
Call setclr(plyclr>
End If
Elseans='U* End
IfIf
(ans.EQ.'Y')Go To
30 If
(ans.EQ.'N'>Go To
100 CC
- Test polygon for
being self-reentrant.
CCal1
selftest(Iflag,nsIdel, ns1de2,xloc,yloc,nbrpts)
If (If1ag.LT.0) Then
Call wrtmsg<'
Error, polygon Is
self-cross 1ng...try
again.') Call
setclrtblack)
Call self 11(open)
Call drwply(xloc,yloc,nbrpts)
Call setclrtplyclr)
Call self I
Ksol Id)
Go To
30 End
If C
Cal1 Inttmp
ntemp=nbrpts
If (Izoom.EQ.1) Then
Do 50 1=1,nbrpts
Cal1 Inversf xt,yt,xloc(1),ylocM))
xpolyt1)=xt
ypoly(1)=yt
xtemp(1)*xt
ytemp(1)=yt
50
Continue
ElseDo
60 11*1,nbrpts
xpoly(11)-xloc(11)
ypoly(11)-y1oc(11)
xtemp(11)-xloc( 11)
ytemp(11)«yloc(11)
60
Continue
End If
Determine If
the polygon npoly crosses another polygon, and
If It
does not, place It
1n the tree (topology).
Call fndtpl(npoly,ntop,Itest)
If (Itest.EQ.l) Then
ntota1*ntota1+1
Cal1 stoply(xpoly,ypoly,nbrpts,npoly,Itest)
Ca11 fndbbxlxm1n,xmax,ym1n,ymax,xpoly,ypoly,nbrpts,delout)
xm1nbx(npoly)=xmin
xmaxbx(npoly)=xmax
ymlnbx(npoly)=ym1n
ymaxbx(npoly)=ymax
Cal
fndbpl(npoly,Itest)
Cal newold
ElseCalCalCalCal 1Cal 1
Call
End If
If (Itest.EQ.-l)Go To 100
setclr(black)
setf11(open)
drwply(xloc,yloc,nbrpts)
setclr(plyclr)
setf11(sol Id)
oldnew
- Test ntotal here, make sure It
doesn't go over.
f1rst='n'
- Find the root node (ntop) of
the tree
Call fndtop(ntop)
- Ask If
another polygon will be drawn on this grid
Call askply(ansZ)
If (ansZ.EQ.'Y')Go Tc 20
If (ansZ.EQ.*N«)1test=l
If (ansZ.EQ.'Q')1test=-2
100 Continue
f1rst='n'
Return
End
C +CCCC-C
addpnt - Allows the adding of
a string of points Into a
polygon
between positions ncorn,ncornZ.
**************
Subroutine addpnt(Itest)
Dimension x11ne(100),y11ne(100)
Common /topology/Info(100),1 upper(100),1down(100)
8
illeft(100),tr1ght(100)
Common /screenloc/ntotal,numply(100),xscr{100,100),yscr(100,100)
Common /parameter /parml100,10)
Common /polyloc/nptloc,xlocl100),yloc(100)
Common /temp/ntemp,xtemp(100),ytemp(100)
Common /commands/nmax,eps11n,delIn,del out
Common /max/npti..ax
Common /flags/mcflag,votfIg
Common /junk/ngbtop,jnktopl100).ngbloc,Jnkloc(100)
Common /zoom/1 z
oom,1zva1,nzoom,ncm1nz(5),ncmaxz(5),nrm1nz(5)»
&nrmaxz(5)
Common /screenbnd/xleft,xr1ght,ybot,ytop
Common /colors/plyclr,black,white
Common /f111/open,sol1d,f1Ityp
Character open*!,sol1d*l,f1ltyp*l,plyc1r*l,black*l,wh1te*l
Character votflg*2,Intype*!,mcflag*2,mcur*2,ans*2,ans2*2
CCall
enhmsg('*** Add
point mode ***')
C1test»0If
(ntotal.GT.0) Then
CC -
If cursor
type has
not been
selected prompt for
type. C
If (mcflag.EG.'N*) Then
Call askmocdncur )
If (incur .EG. 'Q' )
Then
1test=-l
Elsemcflag=mcur
End If
Elseincur "smcf 1 a
g
End If
CC - Print help
message. C
If (votfIg.EQ.'V)Call hlpapt
CC - Start looping
until polygon 1s
found (1test=l),
or user
C wants to
quit (1test=-l).
CDo 10
wh11e(ltest.EQ.0)
If lag»0
If 1ag2=0
If <mcur.EQ.*M'.OR.incur.EQ.'C* )
Then
CC -
Initialize the
temp array.
CCal1
Inttmp CC
- Let
user pick
the polygon and
return npoly,ncorn,x,y.
CCall
pckply(npoly,ncorn,x,y,ans,mcur,1err)
CC - Ask
1f corner
point of
polygon picked Is
to be
used. C
If (ans.EQ.'Y') Then
CC - Get corner to start adding string x!1ne,y!1ne at.
CCa11 msgspt
Cal1 retpnt(xtest,ytest,meur,1err2)
If (1err2.LE.-l) Then
1test«-l
Go To 20
End If
CIf
(Izoom.EQ.1)Cal1 1nvers(xtest,ytest,xtest,ytest)
CC -
Pick side where points to be added.
CCal1
msgsp2
Cal1 fnds1d(ncorn,ncorn2,dmln,xtest,ytest,npoly,1err3)
If ( 1err3.LE.JEf>
Then
1test=-l
Go To 20
End If
CC - Undraw the connecting lines between ncorn,ncornZ.
Cxl«xscr(npoly,ncorn)
yl-yscr(npoly,ncorn)
x2!»xscr(npoly.ncornZ)
y2=yscr(npoly,ncorn2)
CIf
(Izoom.EQ.1) Then
Call transCxone,yone,xl,yl)
Call trans(xtwo.ytwo,x2,y2)
Elsexone*xl
yone-yl
xtwo=x2
ytwo*y2
End If
CCall setclr(black)
Call drwl1n(xone,yone,xtwo,ytwo>
Call setclr(white)
CC -
Now pick which corner of
the side where additions start.
CCall
retpnt( xt,yt,incur , 1test)
If (1test.LE.-l>Go To 20
If (Izoom.EQ.1>Cal1 1nvers(xt,yt,xt,yt)
CC -
Determine orientation of
line by finding closest point to xt
tyt. C
d1stl-(xt-xl)**2+(yt-yl)**2
d1st2-(xt-x2)**2+(yt-y2)**2
If (dlstl.LT.d1st2.AND.d1stl.LT.del1n**2) Then
xf Irst-xl yf1rst«yl
xend»x2
yend-y2
1set-lElse If
(d1st2.LT.dlstl.AND.d1st2.LT.del1n**2) Then
xf 1rst*x2
yf1rst=y2
xend=x1
yend=yl
1Else 1
End If
If ( 1
set.EQ.-l )Go
To 20
C - Translate the coordinates xf1rst,yfIrst,xend,yend Into
zoomed
C coordinates If
1zoom«l
CIf
(Izoom.EQ.l )
Then
Call trans(xf1rst,yf1rst,xf1rst,yfIrst)
Call trans(xend,yend,xend,yend)
End If
CC -
User enters string of points (xl1ne,ylIne) to be added.
Cnbrpts«nuR.p1y{ n
poly)
nl1ne*0
1draw»0
lntype-'0*
Call set!In(lntype)
Cal1 getl1n(xl1ne,y11ne,n11ne,xf1rst,yf1rst,xend,yend,
& 1draw,nbrpts,nptmax,mcflag,1 test)
If (1test.LE.-l) Then
IfIag2«l
Go To 20
End If
CC - Convert line to unzoomed screen coordinate If
1zoom*l.
CIf
(Izoom.EQ.l) Then
Do 50
kk=l,nl1ne
Cal1 1nvers(xl1ne(kk),yl1ne(kk),xl1ne(kk),
&
yllne(kk))
50
Continue
End If
1strg=nbrpts-ncorn
CC - Construct the xtemp,ytemp arrays.
CDo 60 J«l,ncorn
xtemp{J)=xscr(npoly,J)
ytemp(J)=yscr(npoly,J)
60
Continue
CC -
Now bring xlIne,yline Into
xtemp,ytemp
CIf
(Iset.EQ.l) Then
ncon=0
1par=1 Elsencon«n11ne+1
1par=-l
End If
CDo
70 JJ«1,nlIne
xt0mp(ncorn +JJ)=xl1ne( neon*1par*JJ)
ytemp(ncorn*JJ>=yl1ne(ncon+1par*JJ)
70
Continue
CC -
Now add the points In
xscr,yscr from ncornZ to nbrpts onto
C xtemp,ytemp at
position ncorn+n11ne+1.
CIf
(1strg.GT.0) Then
Do 80 k=l,Istrg
xtemp(ncorn+nl1ne+k)=xscr(npo1y,ncorn+k)
ytemp(ncorn+nl1ne+k)*yscr(npoly,ncorn+k)
80
Continue
, .
. End If
If
ntemp=nbrpts+n1Ine
C
C - Test the new polygon for
self-crossing.
CCal 1
self test ( If Iag3 , n
sldel ,ns1de2 , x t
emp ,y t
emp , n t
emp)
If (If 1
ag3.EQ.-l) Then
Call wrtmsg( '
Error, polygon In
self -cross 1 ng ')
If 1ag2-l
Go To 20
End If
CC - Test the new polygon In
the xtemp.ytemp array and fit
C Into
the topology structure.
CCall
testopo( npoly , 1
test2 )
If ( 1
test2.GE.0)Then
1f lag«l elseIf I
ag2»l
end If
1test«l
C20
Continue
If ( If l
ag.EQ.0) Then
Call setclr(plyclr)
Call setfll(open)
Cal 1 drwclp( xloc,y1oc,nptloc,xleft,xr Ight ,
ybot , y
top )
If ( If 1
ag2.eq.l )
Then
If ( I
set.EQ.l )
Then
1 low*l 1 up*nl 1 ne
Else1 1 o
w«nl 1 ne
End If
Call setclr(black)
Call drwllnl xone,yone,xl 1 ne( 1 low) , yl 1 ne( 1 low) )
Call drwpl n( xl 1ne,yl Ine, nl Ine)
Call drwl Inlxl 1ne( 1up),yl 1ne( lup) ,
xtwo,ytwo)
Call setclr(plyclr )
End If
End If
Else If
(ans.EQ. 'N' )
Then
1test=0
Else1test»-l
End If
Call setf 11 (sol Id)
If ( lerr .EQ.-l ) 1
test»-l
Else If
(incur. EQ.'Q' >
Then
1test--l
End If
10 End Do
ElseCall
wrtmsg(' Sorry, no
polygons')
1test=-l
End If
CReturn
End
C +£ **************************************************************
C alphon
- Turns the alphanumeric cursor back on.
C"*************************************************************»
Subroutine alphon
cCal1 esccom('a2')
CReturn
End
C + CC
askall - Asks If
user would like to
view/change the parameters
C associated with the enhanced polygon.
C- C
Subroutine askall(ans)
Character quest*80,ans*2
Cans-'y'
quest"' View/change parameters of
enhanced (white) polygon'
Call askynq(quest,ans,-1 ,2 )
CReturn
End
C +wC
askans - Asks the user to confirm that a
previous action Is
C to be carried out.
C-Q ***************************
Subroutine askans(ans)
Character ans*2,quest*80
Cans«*n*
quest"' Do
you wish to proceed*
Call askynqtquest,ans,0,2>
CReturn
End C+ CC
askclr - Asks for Information used to draw a
Denver standard
C grid In
color on
the Envision terminal.
CC ncont
Number of
contour Intervals
C *
0 »
Sets up
terminal for
polygon drawing only
C «
1-12 =
Draws grid with the number of
contours
C Indicated
C -
// = Quit
CC cmln
* Minimum contour level
CC cdel
Contour Interval
C-V*
Subroutine askclr(ncont,cmln,cdel,Itest)
Character quest*80
Ccmln*0.0
cdel=0.0
CWrite (6,15)
15 Format (/,'
To draw the grid In
color
I first need
some',
&' parameters.',
&/,' Enter
the number of
contours',
&/,' 0 Sets up
terminal for
polygon drawing only',
^
. _
&/,' 1-12
- Draws grid with number of
contours Indicated*,
' I S
«,/, ' //
= Quit' ,/)
cC -
Get the number
of contours to
use for
coloring grid.
C1test-0
Do 10
wh11e(1test.EQ.0)
ncont»0
quest-' *Number
of contours (0-12,
// to
quit)' 1 val»1 1 q
uest(quest,neont,M12)*,0)
CIf
( 1va1.EQ.-l> Then
1test--l Else
If (ncont.GE.0.AND.ncont.LE.12) Then
1test»l ElseCall
errmsg
End If
10 End
DoIf
{1test.EQ.-l.OR.ncont.EQ.0)Go To
100 CC
- Get
minimum contour
level. C
quest-' *G1ve
minimum contour
level' cm1n*0.0
1 val*1rquest(quest,cm1n,Mel6.8)',0)
1test*1valIf
(1test.EQ.-l)Go To
100 CC
- Get
contour Interval.
Cquest"'
*G1ve contour
Interval' cdel=0.0
1val=1rquest<quest,cdel,'(el 6.8)',0)
1test«=1valIf
(1test.EQ.0)1test*l
C100
Continue
Return
End C +Q **********************************************************
C askdvl
- Asks
for the
dval to
use In
Initializing a
grid. C-£ **********************
Subroutine askdvl(dval,1 test)
Character quest*80
dval = 'ffff7fff'x C
1test«l 10
Continue
quest*' Dval
for grid'
1 val = IrquesU quest ,dva1 ,
Mel6.8)',16)
If ( 1
val.EQ.-l)1test»-l
CReturn
End C + CC
askend - ASK END - Asks the user before quitting If
the
C model should be written to an output file.
C-
£ *****************************
Subroutine askend(ans)
Character ans*2,quest*80
C
ans«'y'quest**
Save model*
Call askynq(quest,ans,1,1)
CReturn
End
C + CC
askenh -
Asks user
1f polygon drawn 1n
white 1s
correct.
C-\*
Subroutine askenh(ans)
Character ans*2,quest*B0
Cans-'V
quest"' Is
the polygon drawn In
white the
correct one'
Call askynq(quest,ans,-1,2)
CReturn
End C*\*C
askgvl
- Asks the user when generating a GRAVPOLY model file
C which parameters
In the parameter list
should be
C assigned to:
CC lone
Height of
top of
body
C Itwo
* Height of
bottom of
body
C Ithree =
Density contrast of
body
CC-X*
Subroutine askgvl(lone,Itwo,Ithree,1test)
Common /labels/label
Character ans*2,quest*80, label < 1
0)*15
Character usel* 15,use2*15,use3*15
C5 Continue
1one=0
1two=0
1three«0
usel='UNASSIGNED'
use2*'UNASSIGNED'
use3='UNASSIGNED'
CC - Message about parameters that program needs.
CCal1
msggvlCall
wait
CC -
Display the current labels.
CCal1
msglab
CC - Ask for position In
parameter list
of height of
top of
body.
C1test=0Do
10 wh1le(1test.EQ.0)
1one=0quest=' Top of
body (1-10,
0 or
// to quit)'
1 val = 11quest(quest,lone,'{12)',0)
^C
15
If done.GE. LAND. lone.LE. 10)
Then
' ^
usel3label
(lone)
I test-1
Else If
(lone.EQ.0.OR.1val.EQ.-l) Then
1test--l
ElseCal1 errmsg
End If
IB End Do
If (1test.EQ.-DGo To 50
CC -
Ask for position In
parameter 11st of height of bottom of body.
Cltest-0
Do 20 wh11e(1test.EQ.0)
1two-0
quest"* Bottom of oody (1-10, 0 or //
to quit)'
lval-1 1quest(quest,Itwo,'(12)*,0)
CIf
(Itwo.GE.LAND.Itwo.LE.10) Then
use2-label(Itwo)
I test-1
Else If
(Itwo.EQ.0.OR.Ival.EQ.-l) Then
1test--l
ElseCal1 errmsg
End If
20 End Do
If (1test.EQ.-l)Go To 50
CC - Ask for position In
parameter list of density contrast.
C1test-0
Do 30 wh11e(1test.EQ.0)
1three=0
quest-' Density contrast of body (1-10, 0 or //
to quit)'
1val«11 quest(quest,1 three,'(12)',0)
CIf
(Ithree.GE.l.AND.Ithree.LE.10) Then
use3*1abe1(Ithree)
1test*l
Else If
(Ithree.EQ.0.OR.Ival.EQ.-l) Then
1test=-l
ElseCall errmsg
End If
30 End Do
If (1test.EQ.-l)Go To 50
CC -
Display the labels that the user selected and prompt If
these
C are correct, allow changing
If wrong.
C1test-0
Do 40 wh11e(1test.EQ.0)
Print *,'
You made the following asstgnments»*
Print *,'
Height of top of
body 1s
labeled: ',usel
Print *,'
Height of
bottom of
body Is
labeled: ',use2
Print *,'
Density contrast of body Is
labeled: ',use3
ans='Y'
quest=' Are these assignments correct (y/n/q)'
1va1z1aquest(quest,ans,'(a2)',-2)
CIf
(ans.EQ.'Y') Then
ItestM
-V 1 A
Else If
(ans.EQ.'N') Then
! 1test=2
Else If
(ans.EQ.
1test=-l ElseC
al1 errmsg
End If
Q'.OR.Ival.EO.-l) Then
End Do
If (Itest
EQ.2)Go To 5
C+
CCCC-
C
Continue
If (Itest.EQ.-l) Then
1one*0
1two*0
1three»0
End If
Return
End
asklab - ASK LABel
- Asks the user for the label
associated with a
value array.
name to be
Subroutine ask1ab(label»Itest)
Character labnum*2,oldlab*15,label*15,quest*80
If( Itest. GE.IfIfIfIfIfIfIfIf
Itest.Itest.Itest.Itest.Itest.Itest.Itest.Itest.
If (Itest.
If (Itest.
LAND.
EQ.EQ.EQ.EQ.EQ.EQ.EQ.EQ.EQ.EQ.
1 )2)3)4)5)6)7)8)9)10)
Itest. LE1 abnum** 'labnum* '1 abnum* '
1 abnum* 'labnum= 'labnum* 'labnum= '1 abnum= '
labnum= 'labnum«
. 10)1'2'3'4'5'6'7'8'9'' 10'
Then
o!d1ab=1abe1
1test=0
Do 10
wh11e(Itest.EQ.0)
quest3
' Enter label * '//labnum
1 val = laquest(quest,label,'(a 15)
If
15)
10
Uabe1.EQ.*//*.OR.Ival.EQ.-l) Then
label*'UNASSIGNED'
1test»-l
Else If
(label.NE.'
') Then
1test»l
Elselabel-oldlab
Cal1 errmsg
End If
End Do
C +CC
ElseCall wrtmsg(
1test=-l
End If
Return
End
******************i askmdl
- ASK
MoDel
Error 1n
asklab, Itest out of range*)
- Asks for the name of
the user's model
17
c- c
Subroutine askmdT(modnam,1 test)
Character tempnm*80,modnam*80,quest*80
Ctempnm=modnam
1test=0
Do 10
while?1test.EQ.0)
quest"' Model name*
1val =laquest(quest,modnam,*(a80)',80)
CIf
( 1val.EQ.-l) Then
1test--l Else
If (modnam.NE.'
') Then
1test-lElse
If (modnam.EQ.'
') Then
modnam=tempnm
Call errmsg
End If
10 End
Do C
Return
End
C +
C askmoc - ASK Mouse Or Cursor
- Asks the user to select the
C Envision
mouse or
cursor keys
for entry of
locationsCC
mcur = Mouse/Cursor
C (note:
answer
1s returned
upshlfted)
C m
« Mouse (default)
C c
= Cursor keys
C q
- Quit
CC
\+
Subroutine askmoc(mcur)
Character mcur*2,quest*80
C1test=0
If (1test.EQ.0)
Then 10
Continue
mcur* *m*quest*'
Mouse or
cursor keys
(m/c/q)' 1va1=1aquest(quest,mcur,'(aZ)',-2)
CIf
( Ival.EQ.-l.OR.incur.EQ. *Q* )
Then
mcur«'Q'
1test"-l
Else If
(mcur.EQ.'M'.OR.mcur.EQ.'C') Then
1test=l
ElseCall
errmsg
End If
If (1test.EQ.0)
Go To
10 End
If C
Return
End C +
C askmpp
- Asks
the user
what method to
user when picking a
*< f v
C polygon.
C-
*************************************************************
Subroutine askmpp(ans)
Character ans*2 ,ques ,,*80
1test-0
ans-'h'
Do IF
whlleCltest.EQ.0)
quest*' Method for picking polygon (c/m/h/q)'
1 val- 1 a
quest(quest,ans,'(aZ)',-2)
If (ans.EQ.'C'.OR.ans.EQ.'M') Then
1test-l Else If
(ans.EQ.'Q*.OR.Ival.EQ.-l) Then
ans='CT
1test-l Else If
(ans.EQ.'H') Then
Cal1 hlpmpp
ElseCal1
errmsg
End If
IF End Do
Return
End
OC C C C C C C C C C C C C C C Cc- c
askmvl
- Asks the user
when generating a MAGPOLY model file
which parameters
In the parameter list should be assigned tot
lone *
Height of
top of
body
1 two
= Height of
bottom of
body
Ithree = Volume magnetic susceptibility (emuX100000)
Ifour = Remanent or
total volume magnetization
(emuX100000).
Iflve
= Declination of
remanent or
total magnetization
In degrees, measured positive clockwise from
the direction of
the y
axis.
Islx =
Inclination of
remanent or
total magnetization
In degrees, measured positive downward from
the horizontal plane.
SubroutIne askmvl(lone,1 two,Ithree,Ifour,If 1ve,Islx,1 test)
Common /labels/label
Character ansZ*2,ans*2.quest*80,label(10)*15
Character*15 usel,use2,use3,use4,use5,use6
5 Continue
1one=0
1two=0
1three=0
1four=0
If1ve=0
1s1x=0
usel='UNASSIGNED'
use2='UNASSIGNED'
use3='UNASSIGNED'
use4='UNASSIGNED*
use5='UNASSIGNED'
use6='UNASSIGNED'
- Message about what Information Is
to be provided.
Ca11 msgmvl
Call watt
CC - Display the current labels.
CCal1
msglab
CC - Ask
for position In
parameter 11st
of height
of top
of body.
C1test»0
Do 10
While (1test.EQ.0)
1one*0quest**
Top of
body (1-10,
0 or
// to
quit)' 1val» 1 1 q
uest(quest,lone,'(12)*,0)
CIf
(lone.GE.LAND.lone.LE.10) Then
usel*1abel(tone)
ltest-1 Else If
(1one.EQ.0.OR.1val.EQ.-l) Then
ltest*-l ElseCall
errmsg
End If
10 End
DoIf
(1test.EQ.-l)Go To
100 CC
- Ask
for position 1n
parameter 11st
of height
of bottom of
body. C
1test«0
Do 20
While (1test.EQ.0)
1two*0quest=* Bottom of
body (1-10, 0 or
// to quit)'
1 va1 = 1 1 quest(quest,Itwo,'(12)',0)
CIf
<Itwo.GE.LAND.Itwo.LE.10) Then
use2=label(Itwo)
1test«l
Else If
(1two.EQ.0.OR.Ival.EQ.-l) Then
1test=-l
ElseCal 1
errmsg
End If
20 End Do
If (1test.EQ.-l)Go To
100 CC
- Ask
for position In
parameter list
of Volume magnetic susceptibility.
C1test»0Do
30 While (1test.EQ.0)
1three-0quest*'
Volume magnetic susceptibility (1-10,
0 or
// to
quit)' 1val = 1 1 q
uest(quest,1 three,'( 12)',0)
CIf
(Ithree.GE.l.AND.Ithree.LE.10) Then
use3*1abel(Ithree)
1test=l
Else If
(Ithree.EQ.0.OR.Ival.EQ.-l) Then
1test=-l
ElseCal1 errmsg
End If
30 End Do
If ( I
test.EQ.-l )Go
To 100
C -
Ask for position 1n
parameter list of remanent or total volume
C magnetization.
C1test-0
Do 40 While (Itest.EQ.0)
1four»0
quest"' Remanent or total volume magnetization (1-10,
& 0 or //
to quit)'
1val«11quest(quest,Ifour,M12)',0)
CIf
(Ifour.GE.l.AND.Ifour.LE.10) Then
use4*label(1four )
Itesfl
Else If
<1four.EQ.0.0R.1val.EQ.-l) Then
1test--l
ElseCall errmsg
End If
40 End Do
If (Itest.EQ.-l)Go To 100
CC -
Ask for position 1n
parameter list of Declination of remanent or
C total magnetization.
C1test«0
Do 50 While (1test.EQ.0)
1f1ve-0
quest-' Declination of remanent or total magnetization
& (1-10, 0 or //
to quit)'
1val«11 quest(quest,1f1ve,'(12)',0)
CIf
(IfIve.GE.LAND.IfIve.LE.10) Then
useS-label(If1ve)
1test=l
Else If
(1f1ve.EQ.0.0R.Ival.EQ.-l) Then
1test=-l
ElseCal1 errmsg
End If
50 End Do
If (Itest.EQ.-l)Go To 100
CC - Ask for position In
parameter list of Inclination of remanent or
C total magnetization.
C1test»0
Do 60 While (Itest.EG.0)
1s1x«0
quest*' Inclination of remanent or total magnetization
& (1-10, 0 or //
to quit)'
1val-11quest(quest,1s1x,'(12)',0)
CIf
( Islx.GE.l.AND.1s1x.LE.10) Then
useG-label(Islx)
1test=l
Else If
( Islx.EQ.0.OR.Ival.EQ.-l) Then
1test=-l ElseC
al1 errmsg
End If
60 End Do
If (Itest.EQ.-l)Go To 100
C - Display the labels that the user selected and prompt If
these
c cC65
arc correct, allow changing If
wrong
68
cont1nu«
1test-0
Do 70 While
Write (6
Format (/,*
Print *,
Print *,
Print *,
Print *,
&1abe1ed:
Print *,
labeled:
(Itest.EQ.0)
,68)You have made
Height of
Height of
the following assignments:',/)
top of
body Is
labeled: *,usel
bottom of
body Is
labeled:
f,use2
Volume magnetic susceptibility 1s
labeled: ',use3
Remanent or
total volume magnetization
Is
&1s
&1s
,use4*,'
DeclInatIon
use5Incl1natIon
use6
Print *,
labeled:
ans2-'Y'
quest-' Are these assignments
1 va 1 » 1 aques t( q
uest, an s2, * (a2)
If (ans2.EQ. 'Y* )
Then
nlabel (2,1)* lone
n label (2,2)»1two
nla
be
l<2
,3)»
1t
ure
enlabel (2,4)-1four
nlabel <2,5) = 1f Ive
nlabel(2,6)'1s1x
lval-'M'
call setlbl(lval)
1test-l Else If
(ans2.EQ
ltest-2
Else If
(ans2.EQ
ltest=-l ElseCa 1 1
errmsg
End If
of remanent or
total magnetization
of remanent or
total magnetization
correct
, -2)(y/n/q)*
NM Then
Q*.OR.Ival.EQ.-l> Then
70End Do
If {Itest
EQ.2)Go To 5
100 Continue
If (Itest.EQ.-l) Then
1one=0
1two=0
1three=0
Ifour=0
If1ve=0
End If
Return
EndC +CCCC
asknam - ASK NAMe
- Asks the question In
string quest for
an 80
character string (name).
Formats the answer
using Saltus' laquest subroutine.
*************************************************************
Subroutine asknam(name,quest,Itest)
Character name*80,quest*80
1test=0
Do 10
wh11e(Itest.EG.0)
22
name** *
1 val -laquesKquest, name* '(a80)',0)
CIf
<Ival.EO.-l.OR.name.EQ.*//') Then
itest«-l Else If
Cname.NE.' ')
Thenitest-1
ElseCall
errmsg
End If
10 End
Do C
Return
End C +
C askok
- Asks users
if current state information
displayed at
C terminal
is OK.
C-CSubroutine askok(ans)
Character quest*80,ans*2
Cans»'Y'
quest-' *
OK'Call
askynq(quest,ans,-1,2)
CReturn
End C +£ *************************1
C askply - Asks
1f user
wants to
draw another
polygon. C-£ **************************************************************
Subroutine askply(ans)
Character ans*2,quest*80
Cans='y'
quest*' Draw another polygon'
Call askynq(quest,ans,-1 , 2 )
CRetur«nEnd
C + \*C
askpnt - Asks user
if corner of polygon selected
Is to be used.
C-V*
Subroutine askpnt(ans)
Character ans*2,quest*80
Cans='Y'quest='
Use the
corner where the
polygon was
selected'Call
askynqlquest,ans,-1,2)
CReturn
End C +L-C
askqst
- Asks the question in
the string quest.
V* ""
£ A*********************'
Subroutine askqst(ans.quest,itest)
Character ans*2,quest*80
1test«0Do
10 wh11e<ttest.EQ.0)
ans =' '
1 va 1«laquest(quest,ans,'(a2)',0)
CIf
(1val.EQ.-l.OR.ans.EQ.'//') Then
1test«-l Else If
Cans.NE.' M Then
1test=l ElseCal1
errmsg End
If 10
End Do
CReturn
End C +£ **************************************************************
C askrot
- Asks
the user
If the
corner of
the polygon picked
C should
be used
to rotate the
polygon about.
C-Q **************************************************************
Subroutine askrot(ans)
Character quest*80,ans*2
Cans='Y'quest*'
Rotate polygon about corner
picked'Call
askynq(quest,ans,- 1,2)
CReturn
End C +Q **************************************************************
C askrtZ
- Asks
the user
If another corner
of the
polygon should
C be used to rotate about Instead.
C-
Q **************************************************************
Subroutine askrtZ(ans)
Character quest*80,ans*2
Cans='Y'quest='
Rotate polygon about a
different corner
of this
polygon'Call
askynq(quest,ans,-1,2)
CReturn
End
C +Q **************************************************************
C ASKSTO - ASKS IF
UStK WANTS TO START OVER DRAWING POLYGON
C CALLED BY SUBROUTINE ADDPLY (ADD POLYGON).
C-
Q **************************************************************
Subroutine asksto(ans)
Character quest*80,ans*2
Cans='y'quest=' Start over entering polygon'
Call askynq(quest,ans,-1,1)
Return
«*«. ;
24
End
C +£ ****************************************1
C asksub - Asks the user for
the locations (ncmin,ncmax,nrmln,
C nrmax) of
the subgrld.
C-
Subroutlne asksub(1 test)
DlmensIon xgr1d(2),ygr1d(2),xscrn(2),yscrn(2)
Common /grIdspec»/1d,pgm,nc,nr,nz,xo,dx,yo,dy,IproJ,cm,bl
Common /subgrld/lcmln,Icmax,Irmln,1rmax,ncm1n,ncmax,nrm1n,nrmax
Character 1d*56,pgm*8,Intype*1
C1test-0
Do 15
wh11e(1test.EQ.0)
Write (6,20)
20 Format (/,'
Enter ncmin,ncmax,nrmln,nrmax (0**s to',
4' quit): ',$)
Read (5,25)ncm1n,ncmax,nrm1n,nrmax
25 Format (413)
CIf
((ncm1n.EQ.0.0).*ND.(ncmax.EQ.0.0).AND.(nrmln.EQ.0.0).
&AND.(nrmax.EG.0.0)) Then
1test=-l
Else If
((ncmin.LE.0).OR.(ncmax.LE.0).OR.
Alnrmln.LE.0).OR.(nrmax.LE.0)) Then
Write (6,30)
30 Format (/,'
Illegal value entered...try again')
Else If
((ncmin.GT.nc).OR.{ncmax.GT.nc).OR.(ncmin.GE.ncmax))
& Then
Write (6,35)
35 Format (/,*
Error
1n column boundar1es... try again')
CElse If
((nrmln.vT.nr).OR.(nrmax.GT.nr).OR.(nrmln.GE.nrmax))
& Then
Write (6,40)
40
Format (/,'
Error
In row boundarles... try again')
Else1test=l
Cxgr I
d(1)*ncm1n
xgr1d(2)=ncmax
ygr1d(1)=nrm1n
ygr 1d{2 ) = nrmax
CCal 1
fndscn(xscrn,yscrn,xgr1d,ygr1d,2)
Clntype='6'
Call setl1n(Intype)
Cal1 drwl1n(xscrnf1),yscrn(1),xscrn(1),yscrn(2))
Call drwl1n(xscrn(l),yscrn(2),xscrn(2),yscrn{2))
Call drw11n(xscrn(2),yscrn(2),xscrn(2),yscrn(l))
Call drwl1n{xscrn(2),yscrn(l),xscrn(l),yscrn(l))
CCall
zomstr(1test2)
CEnd
If 15
End Do
CReturn
End
C +£ **************************************************************
C asktwz
- Prints twilight zone message If
user wants to enter
C polygon with only two points.
Subroutine asktwz(ans)
Character quest*80,ans*2
CWrite (6,10)
10 Format (/,'
Are you In
the twilight zone???
You have only',
&' entered two points...')
C1test-0
If (1test.EQ.0> Then
20
Continue
ans='e'
quest
58' Do you wish to enter a
point or
quit (e/q)'
1 va1*1aquest(quest,ans,'(a2)',0)
CIf
(tval.EQ.-l) Then
ans«'CT
1test»l
Else If
(ans.EQ.'E'.OR.ans.EQ.'QM Then
ItestM
ElseCall errmsg
End If
If (1test.EQ.0)Go To 20
End If
CReturn
End
C +
C asktyp
- Asks for
the type boundary picking to be employed In
C the zoom command.
CC Itype =
Flag for
type of
boundaries
C "
1 = Cursor/Mouse entered screen boundaries
C "
2 * Subgrld boundaries given as
ncmln.ncmax,
C nrm1n,nrmax
C-\+
Subroutine asktyp(Itype,1 test)
Character quest*80
C1test-0
Ca11 msgsub
Do 10
wh11e(1test.EQ.0)
1type=l
quest=' Which method for
boundaries (1/2)'
1va1 = 11 quest(quest,Itype,'( 12) ' ,2)
CIf
(Ival.EQ.-l.OR.Itype.E0.0) Then
1test--l
Else If
(Itype.NE.1.AND.Itype.NE.2) Then
Cal1 errmsg
Else1test«l
End If
10 End Do
CReturn
End
C +
C askval
- ASK VALue - Asks for
which one of
the ten parameters In
C In
the parm* arrays to use when resetting the grid.
C-
Subroutine askval{Iset,ulabel,Itest)
Common /labels/label
Character ulabel* 15,label(IF)M5,quest*8F
CC -
Print message about selecting value (msgval).
CCall
msgval
CC -
Display the current labels.
CCall
msglab
CC - Ask question, test answer (Iset), and assign label
If C
answer
Is valId.
C1test«F
Do IF
whlleCItest.EQ.F)
quest"' Which parameter to use (1-1F,
F or
// to
quit)'
1val*11quest(quest,Iset,'(12)',F)
CIf
(Iset.GE.l.AND.Iset.LE.IF) Then
u1abe1
slabel(1 set)
1test-l Else If
(Iset.EQ.F.OR.Ival.EQ.-l) Then
1test--l
ElseCall
errmsg
End If
IF End Do
CReturn
End
C +V*C
askvot - Asks user
If verbose ("V")
or terse ("T")
prompts
C Is
desired.
C-V*
Subroutine askvot(ans)
Character ans*2,quest*8F
CItest'F
Do IF
wh11e(Itest.EQ.F)
ans ='t'
quest*' Do
you want verbose or
terse prompts (v/t/q)'
1va1=1aquest(quest,ans,'(a2)', -2)
CIf
( Ival.EQ.-l) Then
ans«'Q'
1test«l Else If
(ans.EQ.*W.OR.ans.EQ.'T*.OR.ans.EQ.*Q*) Then
1test-l ElseCall
errmsg
End If
IF End Do
CReturn
End C +\4
C askynq - Constructs a
yes/no/qult question from the text string
C passed to
1t under control of
the parameters IDEF,
and
IYNQ.
Answer
1s returned
1n character*?.
IDEF -
Flag for
If default answer
Is allowed.
» 1
- Default Is
allowed, answer returned as entered
0 -
no default
1s allowed, and upshift answer.
=-1 -
Upshift answer and allow default.
IYNQ -
Flag for type of Yes/No/Quit prompt
2
- (y/n/q)
Is added to text string, user supplied
default Is
tested and used.
1
- (y/n)
Is added to text string, user supplied
default Is
tested and used.
-1 -
(y/n)
Is added to text string, "n"
Is used
as the default answer.
= -2 -
(y/n/q)
Is added to text string, "q"
1s used
as the default answer.
i*« *********** **i
Subroutine askynq(quest,ans,1def,lynq)
Character prompt*88,quest*80,ans*2,defans*2
If lag-labs?lynq)
If (If l
ag.EG.1.OR.If lag.EQ.2) Then
lenqst*1tlen(quest)
If (Iflag.EQ.1) Then
prompt=quest(1:lenqst)//' (y/n)'
Elseprompt"quest(l:lenqst)//' (y/n/q)'
End If
If (Idef.NE.0) Then
If ( I
flag.EQ.2) Then
If (1ynq.EQ.-2) Then
ans='q'
ElseIf
((ans.NE.'y'.AND.ans.NE.'Y').AND
& (ans.NE.'n'.AND.ans.NE.'N').AND.
& (ans.NE.'q'.AND.ans.NE.'Q'))ans='q'
End If
ElseIf
(1ynq.EQ.-l) Then
ans='n'
ElseIf
((ans.NE.'y'.AND.ans.NE.'Y').AND
& (ans.NE.'n'.AND.ans.NE.'N'))ans='n'
End If
End If
End If
1set=2*ldef
If (Idef.GE.-l.AND.Idef.LE.1) Then
1test=0
defans=ans
10 Continue
1 va 1 = 1aquest(prompt,ans,'(a2)'.
If
Iset)
( Ival.EQ.-l) Then
If ( If l
ag.EQ.2)ans='Q'
If ( I
flag.EQ.1)ans='N'
1test=l
Else If
((ans.EQ.'Y'.OR.ans.EQ.'y').OR
(ans.EQ.'N'.OR.ans.EQ.'n').OR.
28
& Mans.EQ.'Q'.OR.ans.EQ.'q*).AND.Iflag.EQ.2)) Then
1test=l
Elseans«defans
Cal 1 errmsg
End If
If (1test.EQ.0)Go To 10
End If
End If
CReturn
End C +\«C
boundpoly -
Find an
Inner and out boudlng polygon around
C the polygon passed In
the arrays xpoly,ypoly.
C C->*
Subrout1ne boundpoly(1test,x1n,y1n,xout,yout,xpoly,ypoly,nbrpts,
& del I
n,delout)
DlmensIon xpoly(nbrpts),ypoly(nbrpts),x1n(nbrpts),y1n(nbrpts),
& xout(nbrpts),yout(nbrpts)
CIf
(nbrpts.LE.2) Then
1test=-l
Else
CDo
ISI 1*1 ,
nbrpts
If ( 1 .EQ.1)
Then
xlast=xpoly(nbrpts)
ylast=ypoly(nbrpts)
xnext^xpolyt 2)
ynext«ypoly(2)
Else If
{1.EQ.nbrpts) Then
xlast=xpoly(nbrpts-1 )
ylast=ypoly(nbrpts-1)
xnext=xpoly(1)
ynext=ypoly(1)
Elsexlast=xpoly(1-1)
ylast=ypoly(1-1)
xnext=xpoly(1+1)
ynext=ypoly(1+1)
End If
Cxavec=xlast-xpolv(i)
yavec«ylast-ypoly(1)
Cxbvec«xn*xt-xpoly(1)
ybvec«ynext-ypoly(
\)
CC -
Find the angle theta between vectors A and B
(xavec,yavec,
CC 1)
Find the vector Dot product of
A*B
C II)
Find the norm of
the vectors A,
B. C
dotprd=xavec*xbvec+yavec*ybvec
anorm=sqrt(xavec*xavec-»-yavec*yavec)
bnorm=sqrt(xbvec*xbvec-»-ybvec*ybvec)
If (anorm.It.1.0e-12) anorm=1.0e-12
If (bnorm. It. 1 .0e-12)
bnorm= 1 .
0e-12
theta=acos(dotprd/(anorm*bnorm))
angle»theta/2.0
Cxdvec=cos(angle)*xavec-s1n(angle)*yavec
ydvec*s1n(angle)*xavec+cos(angle)*yavec
Cdnorm»sqrt(xdvec*xdvec+ydvec*ydvec)
1f (dnorm.It.1.0e-12) dnorm=1.0e-12
Cxdun1t*xdvec/dnorm
ydun1t=ydvec/dnorm
Cxtest»xpoly(1)+xdun1t
ytest«ypoly(1)+ydun1t
CC -
Test the
two points (xtest,ytest) to
see If
they are within
C or
outside of
the polygon npoly.
This determines how
to C
find the
coordinates of
the polygon bounded on
the Inside
by C
del In and
outside by
delout. C
Cat 1 p1ytst(xpoly,ypoly,nbrpts,xtest,ytest,Inout)
CIf
(Inout.EQ.l) Then
par1tya +1
Elsepar1ty»-l
End If
Chyp1n«abs(de11n/s1n(angle))
hypout=abs(delout/sIn(angle))
CC -
Now construct the corner points for the Inner and outer boulndlng
C polygon.
Cx1n(1)»xpoly(1)+par1ty*hyp1n*xdun1t
y1n(1)=ypoly(1)+par1ty*hyp1n*ydunIt
xout(1)=xpoly(1)-par1ty*hypout*xdun1t
yout(1)=ypoly(1)-par1ty*hypout*ydun1t
10 Continue
1test=l
End If
CReturn
End
O
CC chgall
- Allows the changing of all values associated with
C every polygon
In the tree.
Starts at top (root)
C node of
tree, enhances polygon, prompts for change,
C allows setting of values and finds next node (poly-
C gon)
In tree.
C-
\*
Subroutine chgall
Dimension xpoly(1. 0),ypoly(100)
Common /screenloc/ntota1,numply(100) , x
scr U00, 100 ) ,
yscr ( 1
00,100)
Common /topology/1nfo<100),1 upper(100),1down(100),
&1left(100),1r1ght<100)
Common /screenbnd/xleft.xrlght,ybot,ytop
Common /zoom/1 zoom,1zval,nzoom.ncmlnz(5),ncmaxz(5),nrm1nz(5),
&nrmaxz(5 )
Common /colors/p1yc1r,black,whIte
Common /f111/open,sol Id,f11typ
Character ans*2,open*!,sol1d*l,f11typM,p1yc1r* 1,black*1,wh1te*l
Call fndtop(ntop)
If (ntop.GE.l) Then
CC -
Print message about assigning values to polygon In
white.
CCa11
msgal1
Call watt
Cngon=ntop
next=ntop
1test'0
Do 10
wh11e(1test.EQ.Jfr) npoly»lnfo(ngon)
CC -
Enhance polygon and prompt
CCall setclr(whlte)
Call setfll(open)
nbrpts=numply(npoly)
If (Izoom.EQ.1) Then
Do 20
1=1.nbrpts
Call trans(xpoly(1),ypoly(1),xscr(npoly,1),yscr(npoly,1))
20 Continue
ElseDo
25 J-l,nbrpts
xpoly(J)=xscr(npoly,J)
ypoly(J)=yscr(npoly,J)
25 Continue
End If
Call drwcIp(xpoly,ypoly,nbrpts,x1eft,xr1ght,ybot,ytop)
CC -
Ask
If user wants to
see/set values
CCa11
aska11(ans )
CIf
(ans.EQ.'V) Then
lset=0
Call valchg(npoly,Iset,lerror)
Else If
(ans.EQ.'Q*) Then
ltest=-l End
If CC
- Unenhance polygon
CCall
setclr(plyclr)
Call setfll(open)
Cal1 drwclp?xpoly,ypoly,nbrpts,xleft,xrIght.ybot,ytop)
Call setf IKsol Id)
CIf
(ltest.EQ.0) Then
Call wa1k(next,ngon,Ierr2)
If (1err2.EQ.1) Then
ngon«next
Else If
(1err2.EQ.J0) Then
1test«l Else If
(lerr2.LE.-l.OR.next.LT.0) Then
1test=-l
End If
End If
10 End
Do ElseCall
wrtmsg(*
Sorry, no
polygons')
End If
Return
End
O\*C chglab
- CHanGe LABel
- Allows changing the labels assocl-
C ated with the value* arrays.
C-
Subrouttne chglab( Itest )
Common
/ label s/ labelCharacter quest *80, label < 10)* 15 , u label * 15
CC -
Display the current settings for
the labels.
CCal 1
msglab
CC -
Ask which label
to change, test answer, and set label.
C1test-0
Do 10
wh11e( Itest. E
Q.0)
quest-' Label
to change (1-10,
-1 for
all, 0 or
// when done)'
IvalM 1 q
uest (quest, 1 lab , ' ( 12 ) ' , 2 )
CIf
(1va1.EQ.-l.OR.11ab.EQ.*) Then
ltest-1Else If
(11ab.EQ.-l) Then
1-1ltest-0
Do 25
wh11e( Itest. E
Q.0)
ulabel=1abel ( 1 )
1error= 1
Call ask lab< u
label , terror )
If ( l
error.EQ. 1 )
Then
label ( 1 )=u1abel
1 = 1 + 1 Else If
( lerror.EQ. -1 )
Then
1test=-l
End If
If ( 1 .GT. 10) 1test=l
25 End Do
Else If
( llab.GE. 1 .AND. llab.LE. 10)
Then
ulabel=1abe1 ( llab)
ler ror = 1 1 abCall
ask lab( ulabel , lerror )
If ( l
error.EQ. 1 >
Then
label ( 1 Iab)=u1abe1
Else If
( lerror. EQ.-l )
Then
1test«-l
End If
ElseCall
errmsg
End If
10 End
Do C
Return
End C +
C chgpar
- Allows the changing of
parameters associated with polygons
-J C. C-
Subroutlne chgpar { 1 t
est )
Character quest*80, ans*2
cCall
enhmsgC'*** Change parameters ***»)
C!test-0
ansa *h*
Do 10
wh11e(ftest.EQ.0)
quest*' Change parameter mode (a/p/h/q)'
1va1=1aquest(quest,ans,'(a2 )',-2)
CIf
(ans.EQ.'A') Then
Call chgall
Else If
(ans.EQ.'P') Then
Call chgpck
Else If
(ans.EQ.'H*) Then
Call hlppar
Else If
(ans.EQ.'Q'.OR.1val.EQ.-l> Then
1test«l ElseCal1
errmsg
End If
ans='q'
10 End Do
CReturn
End
chgpck - Allows the parameters for
individual polygons to
be
r** *****
Subroutine chgpck
Common /screenloc/ntotal,numplyt100), xscr(100,100),yscr(100,100)
Common /polyloc/nptloc,xloc(100),yloc(100)
Common /f1ags/mcflag,votfIg
&nrmaxz(5)
Common /screenbnd/xleft,xr1ght,ybot,ytop
Common /colors/piyclr,black,white
Common /f111/open,sol Id,f11typ
Character open*!,solIdM,f1ltyp*l,plyc1r*l,black*1,white*!
Character votflg*2,mcf1ag*2,mcur*2,ans*2,ans2*2
C1test=0
CC -
Test the number of
polygons ntotal, exit If
<=0. C
If (ntotal.GT.0) Then
CC -
If cursor type has not been selected prompt for
type. C
If (mcflag.EQ.'N') Then
Call askmoc(mcur)
If (mcur.EQ.'Q') Then
1test=-l
Elsemcf1ag=mcur
End If
Elsemcur=mcflag
End If
CC - Start looping until polygon Is
found (1test=l), or
user
C wants to quit (1test=-l).
C
Do 10
wh11e(Itest.EQ.0)
If (mcur.EQ.'M'.OR.mcur.EQ.'C') Then
CC -
Find polygon* enhance and return npoly,ncorn,x,y.
CCall
pckplylnpoly,ncorn,x,y,ans,mcur,lerr)
If (lerr.LE.-l) Then
1test--l
Go To 10
End If
CC - When correct polygon
Is found, prompt for
parameters.
C CIf
(ans.EQ.'YM Then
lset-0
Call valchg(npoly,Iset,ItestZ)
1test-l Else If
(ans.EQ.'NM Then
1test=0
Elseltest»-l
End If
CCall
setclr(plyclr)
Call setfll(open)
Cal1 drwclp< xloc,yloc.nptloc,xleft,xrIght,ybot,ytop)
Call setf 1 K
sol Id)
Else If
(mcur.EQ.'CT >
Then
1test=-l End
If10
End Oo
ElseCall
wrtmsgt* Sorry, no
polygons')
1test=-l End If
CReturn
End
C + \*C
chgply - CHanGe PoLYgon -
Driver for
Change polygon para-
C meter mode.
Options are:
CC 1
- Labels
C p
* Parameters associated with polygons
C h
- Help
C q
Quit and return to Polygon add/.../edit mode
C C-
Subroutlne chgp1y(Itest)
Character quest*80,ans*1
CCall
enhmsg('*** Change_parm mode ****)
C1test=0
ans='h'
Do 10
wh11e(Itest.EQ.0)
quest=' Change polygon parameters (1/p/h/q)*
1val = 1aquest(quest,ans,'(a2>' ,2)
CIf
(ans.EQ.'L'.OR.ans.EQ.'1') Then
Cal1 chglab(lerror)
Else If
(ans.EQ.'P'.OR.ans.EQ.'p') Then
Call chgpar ( lerror )
Else If
(ans.EO. *H' .OR.ans.EQ. 'h* ) Then
Call hlpchg
Else If
(ans. EQ. 'Q' . OR. Ival .EG. -1. OR.ans.EQ. 'q')
Then1test-l
ElseCal 1 errmsg
End If
anss 'q'
10 End
Do
Return
End
clipper -
Clips the
line segment
( xl ,yl ) , ( x2 ,y2 ) passed to
Itccccccccc-c **
cc
to fit
In the
window defined by
the x,y:
xleft<x<xr Ight
ybot<y<ytop
Clipper assumes that the line
segment passed to
It does
Indeed cross
the given window;
use tstend to
determine
whether a
line segment does
Indeed cross
window.
******************************************************
Subroutine cl 1
pper(x,y,xl,yl ,x2,y2,xleft,xr Ight ,ybot
delx=x2-xl
dely=y2-yl
*******
, ytop )
If (abs(dely).LT.l.e-16)dely=s1gnU.e-16,dely)
If (abs(delx).LT.1.e-16)delx=s1gn(1.e-16,delx)
Cslope*dely/delx
b=y2-slope*x2
CC -
Clip along
top or
bottom edges.
C
If (*yl .GT.ytop)
Then x = (ytop-b)/si ope y-ytop
Else If
(yl.LT.ybot) Then
x = (ybot-b >/siope y=ybot
End If
cc -
Clip along
left or
right edges.
cIf
(x.GT.xrIght) Then
x = xr Ighty=slope*xrIght+b
Else If
(x.LT.xleft) Then
x=xleft
y = s1 ope*x1eft+b
End If
CReturn
End »
35
c- cc cc+ccc-cc+ccccccccc-c
Subroutine closup
Call graphoff
Return
End
»**** clrply - Sets up the values used for coloring a polygon.
*************************************************************
Subroutine clrply
Common /colors/plyclr,black.white
Common /calc/ncont,cmin,cdel
Character plye 1r*1,black*1,white*!
black-'fl* white-'!'
If (ncont.GT.0) Then
p1yclr»char(ncont+3+1char{'0'))
Else If
(ncont.EQ.0) Then
piyclr=char(neont+4 + 1
chart'0'))
End If
Return
End
r*********************************************************************
clrsgd - Subroutine to color a
grid on
the Envision screen.
Author: Robert W.
Slmpson, USGS,
Menlo Park, CA.,
11/83.
Converted to a
subroutine by Bruce Chuchel, USGS,
Menlo Park,
CA., 2/84.
Subroutine clrsgdC If 1 r
st,1 test)
Common /gridspecs/Id,pgm,nco1,nrow,nz,xo,dx,yo,dy,IproJ,cm,bl
Common /scale/ xsc,ysc,xstart,ystart,x
\n1t,y1n1t
Common /subgrld/lcmln,Icmax,Irmln,1rmax,ncm1n,ncmax,nrm1n,nrmax
Common /cmdstrlng/ cmdstrlng
Common /cmd1ength/lengstr
Common /lodev1ce/loun1t
Common /gr1d/grd(250000)
Common /sealefacts/1wc0,Jwc0,nxp1x,nyp1x,p1xd1m
Common /calc/ncont,cm1n,cdel
Common /colors/piyc1r,black,whIte
Common /f111/open,sol Id,f11typ
Character plyclr*!,black*!,white*!,open*l,sol1d*l,f1ltyp*l
Character 1d*56,pgm*8,rect*13,wcbp*5,ans*2,esc*1
Character color*3,actw1nd*l,cmdstr1ng*200
Parameter (esc=char(27))
lengstr=0
Find range of
values
If ( If 1
rst.EQ.0)Go To 30
Call gmaxmln
20 Continue
Call askclr<neont,cm1n,cdel,1 test)
36
If Utest.EQ.-l)Go To 100
30 Continue
actw1nd='0*
loun1t=6
CC - Scale grid to screen
CIf
(Iftrst.EQ.l) Th*n
Cal1 sca1eg2sc(1)
ElseCall scaleg2sc(0)
End If
If (1fIrst.EQ.1.AND.ncont.GT.0) Then
Ca11 askok(ans)
End If
If Cans.EO.'N'.AND.1fIrst.EQ.1)Go To 20
If (ans.EQ.'Q') Then
1test--l
Go To 100
End If
CC - Set up color screen and spectrum
CCall blnsetupZt1oun1t,actw1nd)
ncolors
ancont+1
nsh1ft=0
If ( 1f I
rst.EQ.1) Then
Call envclr(1oun1t,ncolors,nsh1ft)
Call InkJet(1oun1t,ncolors)
End If
CC - Set full screen to lowest color
C1clr»0
Call sendcmd(lounlt,color(1cl r))
If (ncont.EQ.0)Go To 50
CC -
Go thru grid once for each color...
CDo 50 1c«l,ncolors
1clr=1c
Call sendcmd(1oun1t,color(1clr))
Do 50 J*nrm1n,nrmax
1left*ncmax+l
1rt=ncm1n-2
Do 50 1=ncm1n,ncmax
C -
Determine color from grid value...
If <grd< 1+(J-1 )*ncol ) .GE. 1 .
0e+38) Then
1clr«0
C this sets dvals to black
Else1clr-n1nt<(grd(1 + C J
-l>*ncol)-cm1n)/cdel+0.5)+ 1
1clr*max(1clr,1)
1clr»m1n(1clr,ncolors)
End If
C -
make rectangles from contiguous boxed of
the same color
C In
the present row...
If (1clr.GE.1c) Then
1 Ieft = m1n(1left,1)
1rt=max(Irt,1)
If (1rt.EQ.ncmax)Cal1 sendcmd(1oun1t,rect(lieft,J,1rt,J))
Else If
(Irt.EQ.1-1) Then
-* -, Call sendcmd(1oun1t.rect(lleft,J,1rt,J)>
*» J) /
1left=ncmax+1
End If
50 Continue
If (ncont.EQ.0) Then
xl-xlnlt
yb * y 1 n 11xr«xInlt+tncmax-ncmln+1>*nxp1x
ytsy1n1t+(nrmax-nrm1n+l)*nyp1x
Call setclr(whlte)
Call setfll(open)
Call drwbox(xl,yb,xr,yt)
End If
C -
FInlsh up. . .
Call sendcmd(lounlt,'end*)
100 Continue
CReturn
End
C+ CC
- Prints Maximum, Minimum, Average and Standard Deviation
C about the grid file.
C-Q ft*************************************************************
Subroutine gmaxmln
Common /gr1d/grd(250000)
Common /gr1dspecs/1d,pgm,nc,nr,nx,xo,dx,yo,dy
Character 1d*56,rgm*8
ngood=0
zmax=grd(1)
zm1n*grd(1 )
zsum»0.
zsqsum=0.
Do 45
J*l,nr
Do 45
1=1,nc
zval=grd(1+(J-l)*nc)
If (zval.LT.1.0e38) Then
ngood=ngood+1
zm1n-am1nl(zm1n,zva1)
zmax=amaxl(zmax,zva1)
zsum=zsum+zval
zsqsum=zsqsum+zval**2
End If
45 Continue
zave=zsum/ngood
zsdev*sqrt((zsqsum-zave**2)/ngood)
twosdev=2*zsdev
Pr IntPr Int
* Print *
PrInt *
Print *
Here are some facts about the grid values.'
i
MIN, MAX,
AVE=',zm1n,zmax,zave
PLUS/MIN 2 SD=',zave-twosdev,zave+twosdev
Return
End C +£ **********************************************************************
C b1nsetup2
- Sets up
the Envision terminal (window actwlnd)
C for
graphics.
C-£ **************************************************************
Subroutine b1nsetup2(loun1t.actwlnd)
Character esc* 1 ,actwl nd* 1
38
Parameter (esc=char(27))
^
C -
Erase screen...
Write <lounlt,1001)esc//'C20'
C - Move cursor home...
Write (lounlt,1001>esc//'th"
C -
Set scrolling to line
1 to 15...
C wr1te(lounlt,1001> esc//'t1;15r'
C -
Set binary number mode...
Write (lounlt,1001>esc//'OR0'
C - Set active window number...
Wr Ite (lounlt,1001>esc//'OA'//actwlnd
C -
Erase graphics screen to current background color
Write (lounlt,1001)esc//'F'
C -
Kill active window...
Write (lounlt,1001)esc//'OK*
C -
Set figure f 111 . . .(7)
Write (lounlt,1001)esc//'CF'
1001 Format (lh$,a)
CReturn
End***1
Character*13 Function box(x,y,dx,dy)
Draws a
box dx
wide a. d
dy high centered about
real world coordinate point x,y.
Character esc*l,wcbp*5
Parameter (esc=char(27))
Call rc2wc(x-dx/2,y-dy/2,111,J11)
Call rc2wc(x+dx/2,y+dy/2,lur,Jur>
ur=upper right;
11=lower left...
box«esc//'OX'//wcbp(111,Jl 1)//wcbp(1ur,Jur)
Return
End
r***iDraws a
rectangle which Includes the boxes about
grid points from 1gll,Jgll (lower left),
to
1gur,Jgur (upper right)...
Note that the two grid points can
be the same point,
or point In
the same col
or row...
*************************************************************
Character*13 Function rect(1g11,Jgl1,Igur,Jgur )
Character esc*l,wcbp*5,1d*56,pgm*8
Common /gr1dspecs/1d,pgm,ncol,nrow,nz,xo,dx,yo,dy,IproJ,cm,bl
Parameter (esc=char(27))
Call corners(Igl1,Jgl1,fwcl11,Jwc111,Iwclur,Jwc1ur)
Cal1 corners(Igur,Jgur,Iwc211,Jwc211,1wc2ur,Jwc2ur)
Box 1
Is the 11
box, box 2
1s the ur...
rect=esc//'OX'//wcbp(1we 111,Jwc111)//wcbp(1wc2ur,Jwc2ur)
Return
Endr***************************************************************
Subroutine rc2wc(x,y,1wc,Jwc)
Converts real
coordinates to world (pixel)
coords
Character 1d*56,pgm*8
Common /gr1dspecs/1d,pgm,nco1,nrow,nz,xo,dx,yo,dy
Common /scalefacts/1wc0,Jwc0,nxp1x,nypix,p1xd1m
Change real
world coordinates to
grid coords...
x1 = (x-xo)/dx
yj=(y-yo)/dy
Change grid coordinates to
world (pixel) coordinates...
1wc=1wc#+n1nt(real(nxp1x)*x1 )
Jwc=Jwc0+n1nt(rea1(nyp1x)*yj)
Return
Endr *** 1
Subroutine corners(1g,Jg,111,Jl1,lur,Jur)
C Finds
corners of
the box
which Is
centered at
grid point (1g,Jg).
C Coords
of the
corners are
returned In
world (pixel)
coordinates...
Common /scalefacts/lwcJ?,Jwc0,nxp1x,nyp1x,p1xd1m
Common /subgrId/lcmln,Icmax,Irmln,1rmax,ncm1n,ncmax,nrm1n,nrmax
1wc»1wcU+( 1g-ncm1n)*nxp1x
Jwc«Jwc0+( Jg-nrm1n)*nyp1x
11l»1wc-nxp1x/2
Jll«Jwc-nyp1x/2
1ur«111+nxp1x-1
Jur«Jll+nyp1x-l
Return
End\+
Subroutine sendcmd(lounlt,cmd)
Character crndM*).cmdstr1ng*200
Common /cmdlength/lengstr
Common /cmdstrIng/cmdstrIng
If (cmd(1:3).NE.'end*) Then
leng*len(cmd)
cmdstr1ng(1engstr+l:lengstr+1eng)*cmd(1:leng)
1engstr=lengstr+leng
End If
If (1engstr.GE.70.0R.cmd<1:3).EQ.'end*) TKen
WrIte (lounlt,'(lx,a )')cmdstr1 ng (
1:lengstr )
lengstr=0
End If
Return
End
C +
C Returns envision command string to set a
color.
C Positive Iclr
values refer to the color scale set by subroutine
C setcolors . . .
C Iclr
=0 Is
background color
« black
C Iclr
=1 thru
13 refers
to color
spectrum set
In sub
setclrsSC
for colors 3
thru 15.
C-£ *********************x****************************************
Character*3 Function colorHclr)
Character esc*l
Parameter (esc = char(27 ) )
CIf
( 1clr.EQ.J0f) Thrn
color»esc//'C
f//char<1char('0*))
Elsecolor»esc//'C*//char(1 char<'0*) + 1c1r + 2)
End If
CReturn
End C +
C clspnt
- Returns the
corner number
(NCORN) and
distance (DMIN)
C of
the corner
In array xpoly.ypoly closest to
theC
point (x,y).
A delta
radius around
each point can
C be
used for
selecting or
rejecting the
corner. ^
C ncorn
- Corner
number of
polygon.C
> 0
- Corner
number of
polygon was
found (within
C radtus used)
C * 0 - Corner number was not found (within radius
C used)
C *-l
- Error, the number of
points of
the polygon
C passed to clspnt was less
than
1.CC
Icon -
Flag controlling which radius criterion to use
C «
1 «
Use DELTA provided by call
to subroutine
C * 0 *
Use the maximum machine value VAXMAX available
CC-CSubroutine clspntlncorn,dmin,x,y,xpoly,ypoly,nbrpts.delta,Icon)
' Dimension xpoly(nbrpts),ypoly(nbrpts)
Parameter (vaxmin=-l.7e+38,vaxmax=l.7e+38)
CIf
(nbrpts.GE.l> Then
ncorn«0
If ( I
con.EG.1) Then
rad
1u
s«
de
lta**2
E
lseradlus-vaxmax
End If
dm1n=vaxmax
CDo
10 1«1,nbrpts
d«(x-xpoly(1>)**2+(y-ypoly(1))**2
If (d.LT.radius.AND.d.LT.dmIn) Then
ncorn*1
dm 1n=d
End If
10 Continue
Elsencorn«-l
End If
CReturn
End
C +V*C
copyspecs
- Copies the gridspecs to gr1dspecs2 common block.
C-
Subroutine copyspecs
Common /grIdspecs/1d,pgm,nc,nr,nz,xo.dx,yo,dy,IproJ,cm,b1
Common /gr1dspecs2/1d2,pgm2,nc2,nr2,nz2,xo2,dx2,yo2,dy2,
Alproj2,cm2,bl2
Character 1d*56,!d2*56,pgm*8,pgm2*8
Cnc2*nc
nr 2 = nrnz2*nz
xo2=xo
dx2=dx
yo2=yo
dy2=dy
iproJ2=1proJ
cmZ-cm
b!2=bl
CReturn
End
C + C
41
cpchars -
Draws a
string of character-prec 1 c 1
son characters (STRG)
at the world coordinates (X,Y).
Author t
Robert W.
Slmpson
Subroutine cpchars( x ,y , s
tr Ing )
Character wcbp*5,ncbp*3 , s
tr 1ng*( * ) , c
md* 90
1x«Jn1nt( x )
1y«Jn1nt(y)
Cal 1
r deb lank (str Ing, s
tr Ing, l
eng)
cmd«'OC' //wcbp( 1x, 1
y)//ncbp( leng ) /
/str Ing ( 1 t
leng)
Call esccom(cmd( 1 : 1
0+leng ) )
Return
End
i***icpcharset -
Sets up
the character-precision character parameters
for the Envision terminal.
See page 7-21
In Envision
reference manual for an explanation of the arguments.
Author: Robert W.
Slmpson
Subroutine cpcharset(1x,1y,zoom,rot,slant)
Character*! zoom,rot,slant
Character wcbp*5,cmd*11
cmd«'0r*//wcbp(1x,1y)//zoom//rot//si ant//*0'
Cal1 esccom(cmd)
Return
End
r***i
cpyply - Allows the copying of a
polygon from one position on
the screen to another position.
r************************************************************
Subroutine cpyply(1 test)
DImensIon vstore(10),xp1y(100),yply(100)
Common /topology/1nfo(100),1 upper(100),1down(100),
&11eft(100),1r1ght(100)
Common /screenloc/ntotal,numply(100),xscr(100,100),yscr(100,100)
Common /box/xmlnbx(103),xmaxbx(100),ym1nbx(100),ymaxbx(100)
Common /1nout/x1n(100,100),y1n(100,100),xout(100,100),
&yout(100,100)
Common /polyloc/nptloc,xloc(100),yloc(100)
Common /parameter /parm(100,10)
Common /temp/ntemp,xtemp(100),ytemp(100)
Common /flags/mcf ag,votflg
Common /Junk/ngbtop,jnktop?100),ngbloc,Jnk1oc(100)
Common /zoom/1 zoom,1zva1,nzoom,ncm1nz(5),ncmaxz(5),nrm1nz(5),
&nrmaxz(5)
Common /grldspecs/ Id,pgm,nc,nr,nz,xo,dx,yo,dy,IproJ,cm,bl
Common /scale/ xsc,ysc,xstart,ystart,xIn It,yIn It
Common /original/
'//corg , Jwcorg , n
xorgp , n
yorgp
Common /screenbnd/x1eft,xrIght,ybot,ytop
Common /commands/nmax,eps1 In,delIn.delout
Common /max/nptmax
Common /colors/plyclr.black,whIte
Common /f111/open,sol Id,f11typ
Character open*!, sol1d*l,f1ltyp*l,plyc1r*l,black*1,wh1te*l
Character 1d*56,pgm*8,votf1g*2,mcflag*2,mcur*2,ans*2,ans2*2
CCall enhmsg('*** Copy polygon mode *** )
C1test-0
CC -
Test the number of polygons ntotal, exit If
<=0.
CIf
(ntotal.GT.0) Then
CC -
If cursor type has not been selected prompt for type.
CIf
Imcflag.EQ.'N*) Then
Call askmoc(mcur)
If (mcur.EQ.*Q') Then
1test=-l
Elsemcflag=mcur
End If
Elsemcur»mcflag
End If
CC -
Print help
message
CIf
(votf Ig.EQ. 'VMCall hlpcpy
CC - Start looping until polygon Is
found (1test=l), or user
C wants to quit <1test=-l).
CDo 10
wh11e(1test.EQ.0)
If lag»0
If (mcur.EQ.'M'.OR.mcur.EQ.'C') Then
CC -
Initialize the temp arrays.
CCal 1
Inttmp
CC -
Let user pick polygon and return npoly,ncorn,x,y.
CCall pckply(npoly,ncorn,x,y,ans,mcur,lerr)
CC - Ask If
corner point of polygon picked should be used.
CIf
Cans.EG.'Y') Then
nbrpts^numply(npoly)
Cal1 pckpntlncorn.dlst,x,y,ans2.npoly,mcur)
If (ansZ.EO.*Q') Then
1test»-l
Go To 20
End If
CC - Message about repositioning cursor to new location
CCa11 h1pmv2
Call retpnt(xscnew,yscnew,mcur,lerr)
If (lerr.LE.-l> Then
1test=-l
Go To 20
End If
43
If Hzoom.EQ.l) Then
Call 1nvers(xnew,ynew,xscnew,yscnew)
Elsexnew*xscnew
ynew*yscnew
End If
CC -
Find the offset to add to the polygon coordinates (delx,dely)
Cdelx»xnew-x
dely»ynew-y
CC - Store new polygon
Cntemp*nbrpts
Do 30 1*1,ntemp
xtemp(1)=xscr(npoly,1)+de1x
ytempi 1)=yscr(npoly,1)+dely
30
Continue
CC - Test to see If
polygon will be off of
unzoomed grid.
Cxlfunz*xInlt
xrgunz*x1n1t+nc*nxorgp
ybtunz*yIn It
ytpunz
zy1n1t + n
r*nyorgp
Call testoff(xtemp,ytemp,ntemp.xlfunz,xrgunz,ybtunz,
& ytpunz,Intotal>
If (Intotal.LE.0) Then
If (Intotal.EG.0) Call
wrtmsgC' Error, polygon will
& be off of
unzoomed grid')
Go To 20
End If
CC -
Find available polygon position
CCall fndnum(npoly2>
CC - Test polygon In
xtemp,ytemp.
CCall
fndtop(ntop)
Call fndtpl(npoly2,ntop,1test3>
CIf
<1test3.EQ.l) Then
ntotal=ntota1+1
Cal1 stoply(xtemp,ytemp,ntemp,npolyZ,lerr)
Cal1 fndbbxC xml n
,xmax,ym1n,ymax,xtemp,ytemp,
& ntemp,delout)
xmlnbx(npo1y2)=xm1n
xmaxbx(npoly2)=xmax
ym1nbx(npoly2)=ym1n
ymaxbx(npoly2)=ymax
CC - Copy the Inner
and outer bounding polygons offset by the
C appropriate amount.
CDo
90 1»1,ntemp
x1n< npo\y2,1)=x1n(npoly,1)+delx
y1n(npo1y2,1)=y1n(npoly,1 )+de1y
xout(npoly2,l)=xout<npoly,1)+delx
yout(npoly2,1)=yout<npoly,1)+dely
90
Continue
** A A
C - Copy the parameter Information
Do 95 11-1,10
parm(npo1y2,11)*parm(npoly,11 )
95
Continue
If (Izoom.EQ.l) Then
Oo 80 11*1,ntemp
Call trans(xtemp(11),ytemp(11),
&
xtempC11),ytemp(11))
80
Continue
End If
Call setclr(plyc1r)
Call self 11(open)
Cal 1 drwclp(xtemp,ytemp,ntemp,xleft,xrIght,ybot,ytop )
Call setf 1 K
sol Id)
Ca11 newold
ElseCal1 oldnew
End If
1test«l
C20
Continue
If (If l
ag.EG.0) Then
Call setc1r(p1yc1r )
Call self 11(open)
Call drwclp(x1oc,y1oc,nptloc,xleft,xrIght,ybot,ytop)
End If
Else If
(ans.EQ.'NM Then
1test=0
Else1test=-l
End If
Call setf i
Ksol Id)
If (lerr.EQ.-l)1test»-l
Else If
(incur.EQ. 'Q* ) Then
1test=-l
End If
10 End Do
ElseCall wrtmsg('
Sorry, no polygons')
1test=-l
End If
CReturn
End C +\*C
crtgrd
- Prompts the user for Information to construct a
Denver
C standard grid.
(Note: nc*nr<=250000).
C-\«
Subroutine crtgrd(1 test)
Common /gr1dspecs/Id,pgm,nc,nr,nz,xo,dx,yo,dy,1proJ,cm,bl
Character quest*80,1d*56,pgm*8,ans*2
C1d=*
'pgm»'POLYGON
'nc=0
nr=0
nz = lxo=0.0
dx-0.0
yo=0.0
dy=0.0
1proJ=0
cm-0.0bl-0.0
tWrite (6,10)
10 Format (/,'
You will now be asked to enter the grid spec If l
eaf,
4'Ions. ',/,*
(Motet nco1*nrow less
than or
equal to 250,000)',/,
&' enter //
to quit.*,/)
C15
Continue
quest-'
Enter ID
for grid'
1 va1- 1aquest(quest,Id,'(a56)',0)
If (Id.EQ.' *)Go
To 15
If ( I
val.EQ.-l)Go To 100
CC -
Enter the number of
columns Incol)
C1test-0Do
20 whlleMtest.EQ.0. OR. (
nc*nr).GT. 250000)
12 Continue
quest*'
NCOL (//
to quit)'
1 val»11 quest(quest,nc,*(15)*,0)
If (nc.LE.0)Go To 12
If (Ival.GE.0) Then
18 Continue
quest-'
NROW
' 1val = 1
1quest(quest,nr,'(15)',0)
If (nr.LE.0)Go To 18
If (Ival.EQ.-l)1test=-l
If (nc*nr.GT.250000) Then
nc=0
nr=0
Print *,'
Error, grid dimensions too large nc*nr»<250000*
Else1test=l
End If
Else1test=-l
End If
20 End Do
If (Itest.EQ.-l)Go To 100
CC -
Enter lower
left corner x-coordlnate of
grid (xo).
Cquest*'
xo*1val =
Irquestlquest.xo,Mel6.8)',0)
If (1va1.EQ.-l)Go To 100
CC -
Enter Interval spacing In
x direction (dx).
Cquest*'
dx'1val»1rqu«st(quest,dx,*(el6.8)',0)
If (Ival.EQ.-l)Go To 100
CC -
Enter lower
left corner y-coordlnate of
grid lyo).
Cquest*'
yo'1val=1rquest(quest,yo,'(e!6.8)',0)
If <1val.EQ.-l)Go To 100
C C -
Enter Interval spacing
1n y
direction (dy).
quest»'
dy'1val = 1
rquest(quest,dy, Mel6.8)',0)
If (Ival.EQ.-l)Go To 100
cC - Ask for
dval to Initialize grid to
CC call
askdvlldval,Itest)
C If
(Itest.eq.-l) go to 100
CC -
Initialize grid to user's dval.
CC call
Intgrdldval)
C100
Continue
If ( I
val.EQ.-l)1test«-l
ReturnEnd
C* CC
Curoff - turns graphics cross-hair cursor
off C
1G0
1 -
command to
turn cursor
off. C- C
Subroutine curoff
CCall
esccom<*G0*)
CReturnEnd
C + C C
Curon - turns graphics cross-hair
cursor on.
- command
to turn
cursor on.
**************************
Subroutine curon
CCall
esccom('Gl')
CReturn
End C + CC
defclr - Allows the
changing of
a color
In the
Envision color
C *
table by
specifying the red,
green and
blue components.
CC color
= ASCII
character representing position of
C color
In color
table. See
COLOR.INF or
C DEFCLR.INF
or FNDCLR.INF.
C
'0'-'9', and
' : '-'?' . CC
Ired *
Integer value of
color gun
Intensity, C
Igreen range
Is from
0-15, 0=off,
15=full on.
C Iblue
CC- \*
Subroutine defclr(color,1red,Igreen,1b1ue)
Character color*!, c
redM,cgreen*l, cblue*l,com*5
CCall
fndclr(cred,Ired)
Call fndclr(cgreen,Igreen)
Call fndclr(cblue,Iblue)
Ccom*'Q
1//color//cred//egreen//cblue
Call esccom(com)
47
Return
End C + CC
delloc -
Deletes all
location Information associated with
C polygon npoly.
C-
Subroutlne delloc(npoly,Itest)
Common /parameter/parent 1
00,10)
Common /screenloc/ntotal,nump1y(100),xscr(100,100),yscr(100,100)
Common /box/xmlnbxl100),xmaxbx(100),ymlnbx(100),ymaxbx(100)
Common /1nout/vin(100,100),y1n(100,100),xout(100,100),
&yout(100,100)
Common /Junk/ngbtop,Jnktop(100),ngbloc,Jnkloc(100)
Common /commands/nmax,eps11n,del1n,del out
Common /max/nptmax
CItestM
CC -
Test the Input variables...
CIf
(npoly.GE.1.AND.npoly.LE.nmax) Then
CC - Zero out all!!! of
the coordlntate locations, parms and all
C Internal arrays...
CDo
10 1*1,nptmax
xscr(npoly,1)=0.0
yscr(npoly,1)=0.0
x1n(npoly,1)=0.0
xoutlnpoly,1)=0.0
y1n(npoly,1)=0.0
yout(npoly,1)=0.0
10 Continue
Cnumply(npoly)=0
Cxmlnbxlnpoly)»0.0
xmaxbx(npoly)=0.0
ym1nbx(npoly)=0.0
ymaxbx(npoly)=0.0
CDo 20 J-1,10
parm(npoly,J)*0.0
20
Continue
CJnkloc(ngbloc)*npoly
ElseCall
wrtmsg(' Error
In delloc, npoly out of
range')
1test--l
End If
Return
End C + CC
delply -
Deletes a
polygon from the model.
C-Q *******************************************
Subroutine delp1y(Itest)
Common /pol y 1 o
c/npt loc , x 1 oc ( 100) , y loc ( 100)
*. A Q
Common /screenloc/ntotal,numply(100),xscr(100,100),yscr(100,100)
" O
Common /Junk/ngbtop,Jnktop(100),ngbloc,Jnkloc(100)
Common /flags/mcflag,votfIg
Common /calc/ncont,cmin,cde1
Common /zoom/i z
oom,1zva1,nzoom,ncminz(5),ncmaxz(5),nrminz(5),
&nrmaxz(5)Common
/screenbnd/xleft,xr ight,ybot,ytop
Common /colors/piyclr,black,white
Common /f111/open,sol id,fi1typ
CCharacter open*!,sol1d*l,fiItypM,piyclr*l,black*!,white*!,color
&*!Character votflg*2,ans*2,mcflag*2,mcur*2
CIf
(ntotal.GT.0) Then
CC -
Print enhanced message.
CCall
enhmsgl'*** Delete
polygon mode
****) ltest-1 npoly
s0
CC -
Print help
message if
user wants verbose answers.
CIf
(votfIg.EQ.'V)Call hlpdel
CC -
Let user
pick polygon;
return npoly,ncorn,x,y.
C10
Continue
Call intply
Call pckplylnpoly,ncorn,x,y,ans,mcflag,ierr)
If (ans.EQ.'N')Go To
10 If
(ans.EQ.'Q')Go To
100 CC
- Now
that we are
certain about which polygon will
be C
deleted, decrement the
polygon counters and
Increment C
the garbage collection pointers (ngbtop,ngbloc).
Cntota1»ntota1 -1
If (ntotal.LT.0)ntotal=0
ngbtop=ngbtop+1
ngbloc=ngbloc+l
CC -
Physically delete (set
to zero)
all reference pointers from
C the topology array (deltpl)
and all
location coordinate
C arrays
(delloc). C
itest-1Call
deltpKnpoly, Itest)
If (Itest.EG.1)
Then Call
setclr(black)
Cal1 newold
Elsentotal-ntotal+1
ngbloc*ngbloc-l
ngbtop»ngbtop-1
Call setclrfplyclr)
Call o1d n ew
End If
CC -
Now either
undraw the
polygon (setclr(black))
if topology
C deletion was
succeeded, or
redraw the
polygon (setc1r(piyclr))
C if
deletion failed.
C » ^
Call setfll(open)
**' 49
Cal1 drwclplx1oc,yloc,nptloc,xleft,xright,ybot,ytop)
Call setclr(plyclr)
Call setf11(sol Id)
CC -
Delete the
location Info
for npoly 1f
topology deletion succeeded.
CIf
(npo1y.GT.0.AND.Itest.GE.1) Then
Call del1oc(npo1y,Itest)
If (ntotal.EQ.0)Cal1 wrtmsg(**** No
more polygons ***»)
End If
100 Continue
Elsentotal«0
Call wrtmsg( '
Polygon list
emtpy, (I.e.,
No polygons)')
End If
CReturn End
C +
C delpnt - Allows the deleting of
Individual point of
a polygon.
C-
Subroutlne delpnt*Itest)
Dimension xply(100),yp1y(100)
Common /topology/1nf o(100),1 u
pper(100),1down(100),
&11eft(100),1r1ght<100)
Common /screenloc/ntota1,numply(100),xscr(100,100),yscr(100,100)
Common /parameter /parm(100,10)
Common /polyloc/nptloc,xloc(100),yloc(100)
Common /temp/ntemp,xtemp(100),ytemp(100)
Common /flags/mcflag,votfIg
Common /Junk/ngbtop,Jnktop(100),ngbloc,Jnk1oc(100)
Common /zoom/Izoom,Izval,nzoom,ncm1nz(5),ncmaxz(5),nnrm1nz(5),
&nrmaxz(5)
Common /screenbnd/xleft,xrIght,ybot,ytop
Common /commands/nmax,eps1 In,del1n,del out
Common /colors/plyc1r,b1ack,wh1te
Common /f111/open,sol Id,f11typ
Character open*I,solIdM,f1ItypM,p1yclr*l,black*l,wh1te*l
Character votf1g*2,mcflag*2,mcur*2,ans*2,ans2*2
CCall
enhmsg('*** Delete point mode
***') C
1test«0If
(ntotal.GT.0) Then
CC -
If cursor
type has
not been
selected prompt for
type. C
If (mcflag.EQ.'N') Then
Call askmoc(mcur)
If (mcur.EQ.'Q'>
Then1test--l
Elsemcflag*mcur
End If
Elsemcur=mcf1ag
End If
If (votfIg.EQ.'V)Cal1 hlpdpt
CC -
Start looping
until polygon Is
found (1test=l),
or user
C wants
to quit
(1test*-l).C
«w C f\
Do 10
whl le( Itest.EQ.0) ;.
3 \J
1flag=0
If1ag2-0
If (mcur.EQ.'M*.OR.incur.EQ.'C') Then
CC -
Initialize the temp arrays.
CCall inttmp
CC -
Let user pick polygon, return npoly,ncorn,x,y.
CCal1 pckply(npoly,ncorn,x,y,ans,mcur,lerr)
CC - Ask If
corner of
polygon picked should be used.
CIf
(ans.EQ.'V) Then
nbrpts*numply(npoly)
If (nbrpts.EQ.3) Then
Call wrtmsgl' Sorry, can''t delete a
point, polygon
& only has three corners.')
ans2*'Q'
1test=-l
ElseCall askpnt(ans2)
If (am :.EQ. *N' )
Then
Cal1 msgspt
Call retpnt(x,y,mcur,1err2)
If (Izoom.EQ.1)Ca11 Inverslx,y,x,y)
End If
End If
CIf
(1err2.LE.-1.0R.ans2.EQ.'Q') Then
1test=-l
Go To 20
End If
CDo 35
' *! ,nbrpts
xplyl1)*xscr(npoly,1)
yply(1)*yscr(npoly,!)
35 Continue
1con=lCal1 clspnt(ncorn,d1st,x,y,xp!y,yply,nbrpts,delout,Icon)
If (ncorn.EQ.0.0R.1err2.LT.0) Then
1test=-l
Go To 20
End If
CC - Store new polygon
Cnpnt»«nbrpts-l
ntemp«npnts
If (ncorn.EQ.l) Then
Do 30
1*1,npnts
xtemp(1)=xscr(npoly,1 + 1 )
ytemp(1)*yscr{npoly,1 + 1 )
30 Continue
, Else If
(ncorn.EQ.nbrpts) Then
Do 40
J=l ,npnts
xtempiJ)=xscr(npoly,J)
ytemp(J)eyscr(npoly,J)
40
Continue
ElseDo
50 k=l,ncorn-l
xtemp(k)=xscr(npoly,k)
ytemp(k)*yscr(npoly,k)
50
Continue
Do 60 1-ncorn*1,nbrpts
xtemp(1-1)=xscr(npoly,1>
ytemp(1-1)=yscr(npo1y,1 )
60
Continue
End If
- Now
undraw the
connecting lines
to ncorn.
If (ncorn.EQ.l)
Thenxl*xscr(npoly.nbrpts)
yl«yscr(npoly,nbrpts)
x3*xscr(npoly,2)
y3=yscr(npo1y,2)
Else If
(ncorn.EQ.nbrpts) Then
xl*=xscr(npoly,nbrpts-l )
yl*yscr(npoly,nbrpts-1>
x3«xscr(npoly,1)
y3=yscr(npoly,1)
Elsexl«xscr(npoly,ncorn-1)
yl«yscr(npoly,ncorn-1)
x3*xscr(npo1y,ncorn+l )
y3ayscr(npoly,ncorn+1 )
End If
x2«xscr(npoly,ncorn)
y2=yscr(npoly,ncorn)
If (Izoom.EQ.1> Then
Call trans(xl,yl,xl,yl)
Call trans(x2,y2,x2,y2>
Call trans<x3,y3,x3,y3 )
End If
Call setclr(black)
Call drwl1n(xl,yl,x2,y2)
Call drwl1n(x2,y2,x3,y3>
Call setclr(white)
Call drw!1n(xl,yl,x3,y3)
- Test
the new
polygon
In the
xtemp,ytemp array to
see 1f
1t Is
self-cross 1ng.
Ca11 selftest?If1ag3,nsIdel,ns1de2,xtemp,ytemp,ntemp)
If (1f 1
ag3.EQ.-l> Then
Call wrtmsgt' Error, polygon
Is self-cross 1ng')
If1ag2=lGo
To 20
End If
- Test
the new
polygon 1n
the xtemp,ytemp array and
fit Into
the topology structure.
Call testopo(npoly,1test2>
If (1test2.GE.0> Then
If lag=l
ElseIf 1
ag2 = l
End If
1test=l
20
Cont1nue
If ( I
f1ag.EQ.0> Then
Call setclr(p1yc1r)
Call setflKopen)
52
Cal1 drwdp(xloc,yloc,nptloc,xleft,xr1ght, ybot,ytop)
If (IflagZ.eq.1) Then
Call setclr(black)
Call drwl1n(xl,yl,x3,y3)
Call setclr(plyclr)
Call setflKsolld)
End If
End If
Else If
(ans.EQ.'N') Then
1test=0
Else1test*-l
End If
Call setftl(solld)
If <terr.EQ.-l)1test»-l
Else If
(incur .EQ. *Q* ) Then
1test=-l
End If
10 End Do
ElseCall
wrtmsg(*
Sorry, no
polygons')
1test=-l
End If
CReturn
End
C +\*C
deltpl
- Deletes a
node (polygon npoly) from the topology
C structure 1n
the newtopo common blocks, and makes
C connecting links
for the remaining nodes.
C-\*
Subroutine deltpl(npoly,1 test)
Common /newtopo/1nfnewt 100),1upnew(100),1dwnew(100),
&11fnew(100),1rtnew(100)
Common /commands/nm^x,eps11n,delIn,del out
Common /Junk/ngbtop,Jnktop(100),ngbloc,Jnkloc(100)
CC -
Test to
make sure that npoly 1s
within range.
CIf
(npoly.GE.1.AND.npoly.LE.nmax) Then
1flag-0
If ( 1
test.EQ.2Hf lag=l
CC -
Find the position (ndpstn) of
the polygon (npoly)
In the
C tree (topology).
Abort and give user
message If
not
C found, this means something Is
screwed up
In the array
C Infnew (or
entire
t pology array).
CCall
fndply(ndpstn,npoly)
If (ndpstn.LE.0) Then
Print *,'
N^pstn =',ndpstn
1test*-l
Call wrtmsg(' You have big problems')
Go To 100
End If
1test=l CC
- Initialize the neighbor pointers of
polygon npoly.
Clup
851 upnewt ndpstn )
1dwn= 1dwnew( ndpstn)
* » S
)lft=1Ifnew(ndpstn)
*' ^
Irgt*51rtnew(ndpstn)
CC -
Determine If
the given polygon npoly 1s
a left
node of
the
C tree (lft=0).
If lft«0,
then test
to see
If there
Is a
C replacement polygon, first look
down (Idwn),
If this
Is zero,
C then
look to
the right (Irgt).
If Irgt
Is also
zero this
C means that
there Is
no replacement polygon Mrep)
CIf
(lft.EQ.0) Then
1rep=0If
(ldwn.GT.0)1rep»1dwn
CIf
(lrep.GT.0) Then
If (1up.GT.0)1dwnew(1up)=1rep
11fnew(Irep)»#
1 temp581 rep
20 Continue
1upnewl1 temp)»1 up 1 last*1 temp 1temp«1rtnew(Itemp)
If <Itemp.GT.0)Go To
20 1rtnew(1last)=1rgt
If ( 1rgt.GT.J0T) 11fnew( 1rgt)*1 last
1test*l C
Else If
(Irep.EQ.F) Then
If ( 1rgt.GT.0>
Then If
(1up.GT.0) Then
1dwnew(1up)*1rgt
1 Ifnew(1rgt)=0
1test=lElse
If (lup.EQ.0)
Then 1 Ifnewt1rgt)=0
1test=l Else1test=-l
Call wrtmsg('
Problem with
lup') End
IfElse If
(1rgt.EQ.0> Then
If ( 1
up.GT.0) Then
1dwnew(1 up)=0
1test=l
Else If
( 1up.EQ.0) Then
Ite.t=l
If (1flag.EQ.0)Cal1 wrtmsg(
4
*** No more Polygons ***')
Else1tesi=-l
Call wrtmsgC' Problem with lupM
End If
Else1test«-lCall
wrtmsg(' Problem with IrgtM
End If
Else1test« -1Call wrtmsg(' Problem with Irep')
End If
CC -
If the given polygon npoly Is
not a
left node (I.e. lft.ne.0)
C test for a
replacement polygon (Irep) by first looking down.
CElse If
(lft.GT.J0T) Then
1 rep=J0"
If I1dwn.GT.0)Irep-ldwn
If (1rep.GT.0) Then
llfnew(1rep)=lft
1rtnew(lft)«1rep
1temp«Irep
30
Continue
1upnew(Itemp)«1up
1last«1temp
1temp«1rtnew(Itemp)
If (Itemp.GT.0)Go To 30
1rtnew(1last)=1rgt
If (1rgt.GT.0>11fnew(1rgt)»1last
1test=lElse If
(Irep.EG.0) Then
1rtnew(lft)=1rgt
If (1rgt.GT.0)11fnew(1rgt)-lft
Itesfl
Else1test«-l
Call wrtmsg(' Problem with Irep')
End If
Else1test=-lCall
wrtmsg(' Problem with 1ft')
End If
CC - Zero out the deleted polygon's structure from the tree and
C add the deleted position (ndpstn) to
the garbage table at
C position Igarb.
CIf
(1test.GE.0) Then
1nfnew(ndpstn)-0
1upnew(ndpstn)=0
1dwnew(ndpstn )=0
1 Ifnew(ndpstn)=0
1rtnew(ndpstn)=0
CJnktop(ngbtop)=ndpstn
End IF
C100
Continue
ElseCall
wrtmsg(' Error
In DELTPL, npoly not
In range
& l=<npoly=<nmax')
1test=-l
End If
CReturn
End
C +£
**************************************************************
C dlspla -
Selects the drawing, erase, and
redraw modes
C (default-122).
For Envision model 230 only.
C-£ **************************************************************
Subroutine dlspla
CCall
esccom('OG122')
CReturn
End
C drawwalk
- Walks the topology structure (tree)
and clips and
C draws the polygon encountered
C-£ *****************************************
Subroutine drawwalk
Dimension xpoly(100),ypoly(100)
Common /screenloc/ntotal,numplyl100), xscrI 100,100),yscr(100,100)
Common /topology/Info(100),1 upper(100),1down(100),11eft(100),
&1r1ght<100)
Common /screenbnd/xleft,xr1ght, ybot,ytop
Common /zoom/1 zoom,1 zval,nzoom,ncm1nz(5),ncmaxz(5),nrm1nz(5),
&nrmaxz(5)
CCall fndtoplntop)
If (ntop.GE.l) Then
Cnext*ntop
ngon*ntop
1test=0
CDo 10
whllelltest.EQ.0)
npoly*Info(next)
If (npoly.GE.l) Then
nbrpts»numply(npoly)
If (nbrpts.GT.0) Then
If (Izoom.EQ.l) Then
Do 20 1=1,nbrpts
Call trans(xpolyH) ,ypol y( 1 ) ,
xscr(npoly, 1) ,
&
yscr(npoly,1))
20
Continue
ElseDo 25 j«l ,
nbrpts
xpolylj)=xscr(npoly,j)
ypoly(J)*yscr(npoly,J)
25
Continue
End If
Cal1 drwclplxpoly,ypoly,nbrpts,xleft,xrIght,ybot,ytop)
If (ltest2.GE.0) Then
Call walk(next,ngon,1test3)
If (next.GE.1) Then
ngon=next
Else If
<next.EQ.0.0R.1test3.EQ.0) Then
ltest=l Else If
<next.LT.0.0R.1test3.EQ.-l) Then
Print *,'
Error
1n walking tree at
pos11Ion *,ngon
1test=-l
End If
End If
Else1t«st»-l
End If
ElsePrint *,*
Error, npoly out of range'
1test»-l
End If
10 End
Do Else
Print *,'
Error ntop not found or
out of
range' End If
CReturn
. ^
*********************** *************************************
"" 56
C drwbox
- DRaW BoX
- Draw a
box with the boundaries determined
C by the world coordinate pair (x0,y0) and (xl,yl).
C-£ *************************************************************
Subroutine drwboxC xJ0, ySf , xl ,yl )
Character com*! 2 ,
wcbp*5
C
1xl*Jn1nt(xl
1yl»Jn1nt(yl )
com='OX* //wcbp( IxflT, 1
y0)//wcbp< 1x1 , lyl
Cal 1 esccom( com)
CReturn
End C +wC
drwclp -
DRaW Clipped Polygon
- Clips and draws the polygon
C xpoly,ypoly on
the Envision terminal.
C-CSubrout Ine
drwc lp( x
poly , ypol y , n
brpts , x left , xr Ight , y
bot , y
top)
D Imens Ion xpo1y(nbrpts),ypo1y(nbrpts)
CDo
18 1*1 , n
brpts
If ( 1 .EG. n
brpts) Then
xl=xpoly( 1 )
y 1 =ypol y ( 1 ) x2=xpoly( 1 )
y2=ypoly ( 1 )
Elsexl=xpoly ( 1 )
yl=ypoly( 1 )
x2=xpoly( 1+1 )
y2=ypoly( 1+1 )
End If
CCal 1
tstend( Inout , xl fyl ,
x2,y2,xleft,xr1ght , y
bot , y
top )
CIf
(1nout.EQ.3) Then
Call drwl 1n(xl ,yl ,x2,y2)
Else If
(Inout. EQ. 2) Then
Cal 1 cl 1p per ( x
one,yone,xl ,yl,x2,y2,xleft,xr1ght,
& ybot, y
top)
Call drwl 1n( xone, y
one,x2 ,y2 )
Else If
( Inout. EQ. 1 ) Then
Cal 1 cl Ipper { x
two, ytwo, x2 ,y2 ,xl ,yl ,
xleft,xr Ight,
& ybot, y
top)
Call drwl 1n(xl ,yl , xtwo, ytwo)
Else If
( Inout. EQ.0) Then
Cal 1 cl Ipper { xone, yone, x
l,yl,x2,y2,xleft,xr1ght,
& ybot, y
top)
Cal 1 cl Ipper ( xtwo, ytwo, x
2,y2,xl ,yl ,x left , xr Ight ,
& ybot, y
top)
Call drwl 1 n ( x
one , yone, x
two , y
two )
End If
IF Continue
CReturn
Endc+
* c 7
r *************************************************************
^J fC
drwl In -
Draw a
line connecting the world coordinates (x0,y0)
C and
( xl ,yl ) .
c-cSubroutine drwl1n{x0,y0,x1,y1)
Character com*12 ,wcbp*5
C1
xJe
r»Jn
1n
t(xF
)1y0=
Jn1nt(y
0)
1xi=Jn1nt(xl)
1yl=Jn1nt(yl)
Ccom«'OV'//wcbp(1x0,1y0)//wcbp(1x1,lyl)
Call esccom(com)
CReturn
End
C + CC
drwpln -
DRaW Poly LINe -
Draws a
polyline figure connecting
C world coordinates (xpts,ypts)
In the order passed to
C drwpln.
See the Envision reference manual or
drw-
C pln.lnf for details.
C-
Subroutine drwpln(xpts,ypts,nbrpts )
Dimension xpts(nbrpts),ypts<nbrpts)
Character esc*1,ncbp*3,wcbp*5
Cesc*char(27)
Print *,esc,'Om ',ncbp(nbrpts),(wcbp(Jn1nt(xpts(1)),
&Jn1nt(ypts(1 ) ) > , 1 = 1
.nbrpts)
CReturn
End
C + \*C
drwply -
Draws a polygon on the Envision terminal.
Connects
CC xpts.ypts
- Array containing the world coordinates
C of polygon vertices.
CC nbrpts
- Number of vertices In
xpts,ypts.
C-
\*
Subroutine drwply{xpts,ypts,nbrpts)
DImensIon xpts(nbrpts),ypts(nbrpts)
Character esc*1,ncbp*3,wcbp*5
Cesc=char(27)
Print *,esc, 'OM*,ncbpCnbrpts),(wcbp(Jn1nt(xpts( 1 ) ) ,
«,Jn1nt(ypts( 1))),1»1, nbrpts)
CReturn
End
C + CC
- drwpnt -
DRaW PoINT -
Draw a
point at world coordinates
C <x0,y0).
C-
£ *************************************************************
Subroutine drwpnt(x0,
Character com*7,wcbp*5
C1x0=
Jn1nt(x
0)
1yj0
f»jn
1nt(y
flf>
58
com-'OO'//wcbp(1x*.ty0>
Call esccom(com)
CReturn
End C + CC
edtply -
EDIT PoLY
- Driver
for Edit
polygon mode.
C Options are*
CC a
» Add
points
C d
» Delete a
point
C m
* Move a
point
C '
h »
HelpC
q » Quit
and return
to Polygon mode
C C-\*
Subroutine edtp1y(1 test)
Character quest*80,ans*2
CCall
enhmsgt'*** Edit
polygon mode
*** ) C
!test-0 ans*'h' Do
10 whlleCltest.EQ.0)
quest3
' Edit
polygon mode (a/d/m/h/q)'
1va1=1aquest(quest,ans,'(a2 )*,2)
CIf
(ans.EQ.'A*.OR.ans.EQ.'a*) Then
Call addpntllerror)
Else If
(ans.EQ.'M'.OR.ans.EQ.'m*) Then
Call movpnt(1 error)
Else If
(ans.EQ.*D'.OR.ans.EQ.'d*) Then
Call delpnt(lerror)
Else If
(ans.EQ.'H'.OR.ans.EQ.*h') Then
Call hlpedt
Else If
(ans.EQ.'Q'.OR.Ival.EQ.-l.OR.ans.EQ.'q') Then
1test=l
ElseCal1 errmsg
End If
C If
<lerror.eq.-l )
1test»-l
ans='q'
10 End Do
CReturn
End
C +
C enhmsg -
Displays enhanced message at user's terminal.
C-
Subroutlne enhmsg(text)
Character text*(*>,black*l,white*!
Cwh!te='1'black='0'Call
envbcl(whlte)
Call wrtmsg(text)
Call envbcl(black)
CReturn
End
o
cC entmou -
Enables the mouse, draws polygon as
user enters It,
C and returns polygon coordinates via
xscrn,yscrn.
C-CSubroutine entmou(xscrn,yscrn,nbrpts,Itest)
D linens Ion xscrn( If if) ,yscrnt 100)
Character ans*2
CCall curon
Call softkyt'l')
Cal1 setmou
Cal1 loadmou
nbrpts*0
1test»0
1-0If
(Itest.EG.0) Then
10 Continue
Call getmou(mode,1x,1y)
x-float(1x)
y-float(1y)
If (mode.EO.1.OR.mode,EG.2) Then
If (1.EQ.99.AND.mode.EO.l) Then
Print *,
& ' Last point, only button 2
or buttons 2&3
allowed*
Else1»1 + 1xscrn(1 )s
xyscrn(1 )=y
Call drwpnt(x,y)
If ( (1 .GT.l > .AND. ( 1 .IE. 1
00» Then
If {( 1 .
E0.2).AND.(mode.EQ.2» Then
Call asktwz(ans)
If (ans.EQ.'Q') Then
nbrpts=1
1test=-l
Elsemode=l
End If
End If
If (Itest.EQ.0) Then
Cal1 drwl1n(xscrn(1-1),yscrn(1-1),xscrn(1),yscrn(1
& ))If
(mode.EQ.2) Then
Call drwl1n{xscrnU),yscrnM),xscrn(l),yscrn(l)
& )nbrpts=1
1test=l End If
End If
End If
End If
CElse If
(mode.E0.3) Then
Call hlpmou
CElse If
lmode.EQ.23) Then
nbrpts*1
1test=-l C
ElseCall
errmsg
60
End If
If (1.EQ.99.AND.ltest.EQ.0) Then
Print *,*
99 coordinates entered, only one more allowed*
End If
If < 1 .GT. 100) 1tes,t--l
If (Itest.EG.0)Go To 10
End If
CCall
softkyC**)
Call curoff
Return
End
C +V*C
entply -
Enables cursor keys,
draws polygon as
user enters It,
C and returns coordinates via
xscrn,yscrn.
C-V*
Subroutine entply(xscrn,yscrn,nbrpts,itest)
Dimension xscrn( \418) ,yscrn( 100)
Character ans*l,ansl*l
CCal1
curon
nbrpts=0
1test=0
1=0If
( itest.EQ.0) Then
10 Continue
Call gtpnt(ans,x,y)
If (ans.EG.'e'.OR.ans.EG.'f«) Then
If ( 1 .
EG.99.AND.ans.EG.*e') Then
Print *,'
Last point, only (f/q)
allowed
1 Else1-1 + 1xscrn( 1 ) = x
yscrn( 1 )
=y
Ca11 drwpntt x,y)
If ((1.GT.1).AND.(1.LE.100)) Then
If ((1.EQ.2).AND.(ans.EQ.'f')) Then
Call asktwz(ansl)
ans=ans1
If (ans.EQ.'q') Then
nbrpts=1
1test=-l
End If
End If
If (Itest.EQ.0) Then
Call drwl1n(xscrn(1-l),yscrn{1-l),xscrn(1),yscrn(1
& ))If
(ans.EQ.'f') Then
Call drw11n(xscrnU),yscrn(i),xscrn(l),yscrn(l)
& )nbrpts=1
1test=l End
If End
If End
If End If
CElse If
{ans.EQ.'h') Then
Cal1 hlpent
CElse If
(ans.EQ.'q*) Then
nbrpts=1
1test=-l
CElseCal1 errmsg
CEnd If
If (1.EQ.99.AND.1test.EQ.0> Then
Print *,'
99 coordinates entered, only one more allowed*
End If
If (1.GT.10F)!test--l
If (1test.EQ.0)Go To 10
End If
CCall curoff
Return
End
C*
\*C envbcl -
Sets the alphanumeric display background color.
CC See ENVBCL.INF and/or the Envision reference manual.
C-£ ********** ***********: i
Subroutine envbcl(color)
Character com*2,color * 1
Ccom*'b
f//color
Cal1 esccom(com)
CReturn
End
C+
CC envclr
- Automatically loads In
the Envslon terminal and picks
C up
to 13
colors
1n a
spectral color sequence.
I=wh1te,
C 2*green, 3-ncolors=spectrurn, rest=black.
Color spectrum
C Is
left Justified at 1clr=3 If
nsh1t=0.
CC Author: Robert Slmpson
C-
£ **************************************************************
Subroutine envclrtloun1t,ncolors,nsh1ft)
Character color*1,v2c*1
Integer 1r(0:l5),1g(0:l5),1b<0:l5)
Parameter (nmax=14)
Integer 1rd(0:15),1gr<0:15),1bl<0:15)
Data 1rd/00,09,07,00,00,00,00,11,15,15,15,15,15,15,15,157
Data lgr/00.00,00,00,10,13,14,15,15,12,09,07,00,00,00,15/
Data 1b1/00,09,11,15,14,10,06,00,00,00,00,00,00,12,15,15/
Cncolors*max(2,ncolors)
ncolors=m1n(13,ncolors)
nsh1ft=max(0,nsh1ft)
nsh1ft=m1n(13-ncolors,nsh1ft)
CC Set al1
black...
CDo 20 1=0,15
1r(1)=0
1g(1 )=01b(1 )
=0
20 Continue
C C Set 1=
white
62
1g( 1 ) = 151b( 1 )«15
CC Set 2 =
cursor green...
C1r<2)»0
1g<2>=!5
1b(2)=0
CC Fill ncolors Into 3
thru ncolors+2 by Interpolating In
spectrum of 14...
CDo 40 1=1, n
colors
clr=Real H-l)*Real
( nmax- 1 ) /
Rea 1
( ncolors-1 )+ 1 .0
Do 40 J-l ,
nmax-l
If (clr.GE.Real
( J ) . AND . cl r .LE .
Rea 1
<J+1)> Then
1r(f + 2 + nsh1ft)-Jr!nt((lrd(J+l)-1rd(J) )*(clr-Real
< J) ) + 1rd( J) ) 1g(1 + 2 + n
sh1ft) = J
n1nt( ( 1gr( J + l )
-1gr( J) )
*(clr-Real
( J» + 1gr( J) )
1b(H-2 + n
sh1ft)*Jn1nt(<1bl(J-U)-1bl(J) )*(clr-Real {J))+1bl(J»
End If
40 Continue
CC Enhance yellow...
CDo 50
1 *3, ncolors+2
If Ub( 1 )
.EQ.0.AND. 1g(1 )
.GE.14.AND. 1r( 1 J
.GE.12) Then
1r( 1 )«15
1g( 1 ) = 15End If
50 Continue
CC Write color spec+.-um...
CDo 70 1clr=0,15
Call fndcl r { c
olor , I
clr )
Call defclrtcolor , 1
r(1clr),1g(1clr),1b(1clr))
70 Continue
CReturn
End
C +V*C
errmod
- Prints error message at user's terminal
1f output file
C 1s
requested before other conditions are satisfied.
C-
V*
Subroutine errmod
CWrite (6,10)
10 Format (/,'
Error output files can not be generated until',
&' model file Is
created',/)
CReturn
End
C + CC
errmsg -
Prints message at user's terminal
1f a wrong answer
C Is
entered.
C-
Subroutine errmsg
Write (6,10)
* _^
^
10 Format (/,'
Wrong answer...try again')
CReturn
End
C + CC
esccom - Sends the character string 'com'
to the Envision terminal.
C-\+
Subroutine esccom(com)
CharacterM*) com,esc*l
Parameter (esc=char(27))
C1leng=1en(com)
Write (6,20)esc//com
20 Format (x,a<1leng+1»
CReturn
End
C +V*C
fndbbx
- Finds the bounding box around the polygon passed
1n C
the arrays xpoly,ypoly.
Adds a boundary (delta)
C to
the boundary xmln,xmax,ym1n,ymax returned.
C-Q *********************** *************************************
Subroutine fndbbx(xmln ,xmax,ym1n,ymax,xpoly,ypo1y,nbrpts,delta)
D1mensIon xpoly(nbrpts),ypoly(nbrpts)
Cdelta*abs(delta)
CC -
Initialize the maximum and minimum values of
xmln,xmax,
C ymIn,ymax.
Cxm1n*xpoly(1)
xmaxsxpo1y(1)
ym1n*ypoly(1)
ymax=ypoly(1)
CC -
Go through the set of
points defining the polygon and
C find the smallest
?vxm1n,ym1n) and largest (ym1n,ymax).
CDo
10 1*1,nbrpts
xm1n=amlnl(xpo1y(1),xm1n)
xmaxsamaxl(xpoly(1),xmax)
ym1n=am1nl(ypo1y(1),ym1n)
ymax=amaxl(ypoly(1),ymax)
10 Continue
CC - Test the boundary limits for over/under flow when the
C epsllon (delta)
Is added/subtracted.
Cxm1n*xm1n-delta
xmax=xmax+delta
ym1n=ym1n-delta
ymax^ymax+delta
CReturn
End OC
fndbpl
- Finds an
Inner and outer bounding polygon around poly-
w» O4
C gon npoly.
C-
Subroutine fndbpl(npoly,1 test)
Common /screenloc/ntota1,numply(100),xscr(100,100),yscr{100,100)
Common /1nout/x1n(100,100),y1n<100,100),xout(100,100),
& yout(100,100)
Common /commands/nmax,eps11n,de11n,delout
Dlmens ion
xlntmpt100),y1ntmp(100),xoutmp(100),youtmp(100),
& xpoly(100),ypoly(100)
C1test-0
nbrpts-nump1y(npoly)
If (nbrpts.LE.2) Then
1test=-l
ElseDo 5
11*1 ,nbrpts
xpo!y(11)*xscr(npoly,11)
ypo!y(11)*yscr(npoly,11 )
5 Continue
CCall boundpoly(1 test,x1ntmp,y1ntmp,xoutmp,youtmp,xpoly,
& ypoly,nbrpts,del1n,delout)
If (Itest.EQ.l) Then
Do 10
1*1,nbrpts
x1n(npoly,1) = x
1ntmp(1 )
y1n(npoly,1)*y1ntmp(1 )
xout(npoly,1) = x
outmp( 1 )
yout(npoly,1) = y
outmp( 1 )
10 Continue
End If
End If
CReturn
End
C +l#C
fndcde -
FIND CoDE
- Returns the code for the region, ex-
C pressed as Iblt4,1b1t3,1b1t2,1b1tl, of the screen
C location (x,y).
See Figure 5-5, p.66, "Principles
C of Interactive Computer Graphics", by Newman and
C Sproull, 1979.
CC Ibltl
- 1,
If x
< xleft
C 1b1t2 =1,
If x
> xrlght
C 1b1t3 «
1, If
y <
ybot
C 1b1t4 =
1, If
y >
ytop
CC-£ ******************** .A**************************************
Subroutine fndcde(1b1t4,Ibl13,fbltZ,Ibltl,x,y,xleft,xrIght,
&ybot,ytop)
C1b1t4-0
1b1t3*0
1b1t2*0
1b1tl=0
CIf
(x.LT.xleft) Then
1b1tl=l
Else If
(x.GT.xrIght) Then
1b1t2-l
End If
C .
, _
If (y.LT.ybot) Then
6 J
1b1t3-l
Else If
(y.GT.ytop) Then
1b1t4-lEnd If
CReturn
End
C +£ **************************************************************
C fndclr
- Converts a
numeric code for
color In
the color table
C Into
the equivalent ASCII (hexadecimal) code for
the
C Envision terminal.
See also COLOR.INF, or
FNDCLR.INF.
CC ncolor -
Position number of
color
In color table 0-15.
C «
0 - usually black
C "
1-15 - Same as
color mapping I-'?*,
see
C Envision reference manual.
C color
- Ascll code (al)
for color
In color table
C *
'0'-'9',':'- ?'.
C »
'0', If
ncolor<0 or
ncolor>15, an
error
C message Is
printed.
C-£ **************************************************************
Subroutine fndcIr(color,ncolor)
Character color*!
CIf
(ncolor.GE.0.AND.ncolor.LE.15) Then
co1 or*char(ncolor+1 char('0'))
Elsecolor-'0'
Call wrtmsg(' Error, value past to FNDCLR out of
range.')
End If
CReturn
End
C +£ *************************************************************
C fndnod -
FIND NODe -
Finds the currently available node In
C the tree.
Starts with Jnktop arrays and then scans
C through the topology arrays.
If all
nodes have been
C used ndpstn=0.
CC ndpstn «
node position
C *
1 to
max
C »
0 no
more nodes
C »-l
error condition
CC-£ **************************************************************
Subroutine fndnod(ndpstn )
Common /topology/Info(100),1 upper(100),1down(100),
&1left(100),1 right?100)
Common /screenloc/ntota1,nump1y(100),xscr(100,100),yscr(100,100)
Common /commands/nmax,eps1 In,del1n,del out
Common /Junk/ngbtop,Jnktop(100).ngbloc,Jnkloc(100)
C1test-0
5 Continue
ndpstn-0
If (ntotal.GE.0.AND.ntotal.LE.nmax) Then
If (ntotal.EG.nmax) Then
Print *,'
Polygon list
full, only',nmax,'polygons allowed'
If (ngbtop.GT.0) Then
** DO
ndpstn
3Jnktop(ngbtop)
JnktopCngbtop >-0
ngbtop=ngbtop-1
Else If
(ngbtop.EQ.0) Then
1-1Do 10 whl1e(ndpstn.EQ.0)
If < 1
nfo(1J.LE.0) Then
ndpstn*1
Else1 = 1 + 1
End If
If ( 1 .
GT.nmax)ndpstn*-l
10
End Do
Elseltest-ltest+1
ngbtops0
Do 20 J«l,nmax
If (Jnktopt J).GT.0)ngbtop = n
gbtop+1
20
Continue
If (Itest.EQ.1> Then
Call wrtmsg(' Error In
ngbtop, recovery attempted')
Else If
(ltest.GE.2) Then
ndpstn=-1
Call wrtmsg(' Recovery attempt failed')
End If
End If
End If
Elsendpstn*-!
Call wrtmsg(' Error
In ntotal, out of range')
End If
If (Itest.EQ.1)Go To 5
CReturn
End
C +
C fndnum -
Finds the next available polygon position number.
C Starts with the Jnkloc arrays and then scans the
C numply (NUMBER points
In POLYGON) array for an open
C position (I.e. nump1y(npoly)
S0).
CC npoly =
Number of polygon position
C *
1 to nmax
C *
0 no more polygons spaces
C a-\
error condition
C-
Subroutlne fndnum(npoly)
Common /screenloc/ntota1,numply(100),xscr(100,100),yscr(100,100)
Common /commands/nmax,eps1 In,del In,delout
Common /junk/ngbtop
;Jnktop(100),ngbloc,Jnkloc(100)
C1test-0
5 Continue
npoly=0
If (ntotal.GE.0.AND.ntotal.LE.nmax) Then
If (ntotal.EQ.nmax) Then
Print *,' Polygon list full, on 1y',nmax,*polygons allowed*
ElseIf
(ngbloc.GT.0) Then
npoly*Jnklocingbloc)
Jnkloc(nqbloc)
S0
ngblocT.j-jbloc-1
Else If
(ngbloc.EG.0) Then
1 = 1Do 10
wh11e(npoly.EQ.0)
If <numply(1).LE.0) Then
npoly-1
Else1-1 + 1
End If
If (1.GT.nmax)npoly--1
10 End Do
Else1test«1test+l
ngbloc-0
Do 20 J-l,nmax
If (Jnkloc(J).GT.0)ngbloc»ngbloc+l
20
Continue
If (Itest.EQ.l) Then
Call wrtmsgl*
Error
In ngbloc, recovery attempted*)
Else If
(1test.GE.2) Then
npolya-l
Call wrtmsgC*
Recovery attempt failed*)
End If
End If
End If
Elsenpoly=-l
Call wrtmsgl*
Error
In ntotal')
End If
If (Itest.EQ.1)Go To 5
CReturn
End
C +WC
fndply -
Finds and returns the node position (ndpstn) of
C polygon npoly
In the tree.
CC ndpstn =
Node position of polygn npoly
C >
0, Node for npoly exists
C --It Node for npoly does not exist
CC-£ *************************************************************
Subroutine fndply(ndpstn,npoly)
Common /topology/1nfo(100),1 upper(100),I down(100),
«,11eft( 100),1r1ght( 100)
Common /commands/nmax,eps11n,del1n,delout
CIf
(npoly.GE.1.AND.npoly.LE.nmax) Then
1 = 1ndpstn-0
Do 20 wh11e(ndpstn.EQ.0)
If (1nfo(1).EQ.npoly) Then
ndpstn-1
Else1-1 + 1If
(1.GT.nmax)ndpstn=-l
End If
20
End Do
ElseCall wrtmsg('
Error, npoly passed to FNDPLY out of range.*)
ndpstn*-1
End If
** / Q
C OO
Return
End
O
CC fndscn - Converts the pair of grid locations xgrld.ygrld Into
C there corresponding screen locations xscrn,yscrn.
C-
CSubroutine fndscn(xscrn,yscrn,xgrld.ygrid,nbrpts)
Dimension xgr1d(2),ygr1d(2),xscrn(2),yscrn(2)
Common /sca!e/xsc,ysc,xstart,ystart,x1n1t,y1n1t
CDo 50 1*1,nbrpts
xscrn(1)*x1n1t+(xgr1d(1)-xstart)*xsc
yscrn(1)*y1n1t+(ygr1d(1)-ystart)*ysc
50 Continue
CReturn
End
C+
V*C fndsld -
Finds the corners (ncorn,ncorn2) of the side of the
C polygon npoly that Is
closest to the point xtest.ytest.
C-V»
Subroutine fnds1d(ncorn,ncorn2.drnln,xtest,ytest,npoly,Itest)
Common /screenloc/ntota1,nump1y(100),xscr(100,100),yscr(100,100)
Common /1nout/x1n(100,100),y1n(100,100),xout(100,100),
Ayout(100,100)
Common /commands/nmax,eps11n,de11n,delout
Common /max/nptmax
Parameter {vaxmln*-1.7e+38,vaxmax*!.7e+38 )
Dimension xpoly(6),ypoly(6)
Cncorn*0
ncorn2=0
1test«0
1set*0
dm1n*vaxmax
tota1d=vaxmax
CC - Test If
npoly Is
within range.
CIf
(npoly.GE.1.AND.npoly.LE.nmax) Then
nbrpts-nump1y(npoly)
If (nbrpts.GE.1.AND.nbrpts.LE.nptmax) Then
Do 10
1*1,nbrpts
1up*1+l
If (1.EG.nbrpts)1up=l
Cxpoly(1)*xscr(npoly,1)
xpo1y(2)*xout(npoly,1)
xpo1y(3)*xout(npoly,lup)
xpoly(4)*xscr(npoly,lup)
xpoly(5)*x1n(npoly,lup)
xpoly(6)*x1n(npoly,1)
Cypoly(1)*yscr(npoly,1)
ypoly(2)
zyout(npoly,1)
ypoly(3)
zyout(npoly,lup)
ypoly(4)
3yscr(npoly,lup)
ypoly{5)
zy1n{npoly,lup)
ypoly(6) = y
1n( npoly, 1 )
C -
Now test If
the point xtest.ytest Is
In the polygon bounded
C by xpoly,ypoly.
CCal1 plytst(xpoly,ypoly,6,xtest,ytcst,Inout)
CIf
(Inout.EG.1> Then
totald»(xscr(npoly,1)-xtest)**2 +(yscr(npoly,1) -
&
ytest)**2+<xscr(npoly,tup)-xtest )**2+(yscr(npoly,1up>-
&
ytest)**2
If (totald.LT.dmln) Then
ncorn«1
ncorn2z tup
dm1n«totald
lset-1
End If
End If
10 Continue
CIf
(Iset.EQ.l) Then
ltest-1
ElsePrint *,*
Error, could not find polygon''s aide'
1test«-l
End If
ElsePrint *,'
Error, nbrpts out of range'
1test«-l
End If
ElsePrint *,'
Error, npoly out of range'
1test»-l
End If
CReturn
End
C +£ *************************************************************
C fndtop -
FIND TOP
- Finds the top node or root (ntop) of the
C tree In
the topology arrays.
C-£
*************************************************************
Subroutine fndtop(ntop)
Common /topology/1nfo(100),1 upper(100),1down(100),
A11eft(100),1r1ght(100)
Common /commands/nmax,eps11n,del 1n,de1out
Cntop*0
1 = 1 C
Do 10
wh11«(ntop.EQ.0)
If (1nfo(1).GE.1.AND.1nfo(1).LE.nmax.AND.1 upper( 1>.EQ.0
A.AND.11eft(1).EQ.0) Then
ntop*1
Else1-1 + 1If
<1.GT.nmax)ntop=-l
End If
10 End Do
CReturn
End
C+
£ *************************************************************
~7 C\C
fndtopnew -
FIND TOP NEW- Finds the top node or
root (ntop) of the
**. / vJ
C tree In
the newtopo arrays.
c- c
Subroutine fndtopnew(ntop)
Common /newtopo/Infnew(100)
,1upnew(100)
,1dwnew(\00),
&1Ifnewl100)
,Irtnewl100)
Common /commands/nmax,eps1 In,del In,delout
Cntop«0
1*1 C
Do 10
wh11e(ntop.EQ.0)
If (1nfnew(1).GE.1.AND.1nfnew(1).LE.nmax.AND.1upnew(1).EQ.0
&.AND.llfnewl1).EQ.0) Then
ntop«1
Elsei-l + 1If
(1.GT.nmax)ntop=-l
End If
10 End Do
CReturn
End
C +v»C
fndtpl
- Finds the and sets the topology of the polygon npoly
C the corner locations are passed to the test routines
C In
the temp common block.
CC The topology Is
an Implementation of a
quadruply-11nked
C list [Knuth, "Fundamental Algorithms", p.
3521.
CC-
Subroutine fndtp1(npo1y,ntop,1 test)
Common /newtopo/Infnew(100),1upnew(100),1dwnew(100),
41 Ifnew(100),1rtnew(100)
Common /screenloc/ntota1,nump1y(100),xscr(100,100),
&yscr(100,100)
Common /neighbors/1cnt,1n(100),Jcnt,Joutl100)
Common /state/If last,Iftln,Iftout,ndpstn,lup
Common /commands/nmax,eps11n,del In,del out
C CC - Test to see If
this Is
the first polygon
CIf
(ntotal.EQ.0) Then
Call fndnodlndpstn)
If (ndpstn.GE.1 )
Then
Infnewlndpstn)=npoly
1upnew( ndpstn )**0
1dwnew(ndpstn)*0
11fnew(ndpstn)*0
1rtnew(ndpstn)=0
ntop«ndpstn
1test«l
ElseCall wrtmsgl' Failed on ntotal=0 test')
1test»-l
End If
CC -
Start at top of tree... ntop
CElse If
(ntotal .GT.0) Then
ngon=ntop
nh1t=0
1cnt=0
Jcnt*0
1up*0
n1eft»0
Iflast-0
Ift1n=0
lftout=0
Do 5
1*1,nmax
ln<1)-0
Jout(l>-0
5 Continue
CC -
Find the next available node position In
the topology arrays
CCall fndnod(ndpstn)
CC -
Clear the arrays associated with this node.
CIf
(ndpstn.GE.1) Then
Infnew(ndpstn)»0
1upnew(ndpstn >*0
1dwnew(ndpstn)*0
1 Ifnew(ndpstn)*0
1rtnew( ndpstn)=0
1test=0
Else1test«-l
End If
CC Test npoly to see
If It
Is within ngon
CDo 10
whlle(ltest.EQ.0)
n1oc«Infnew(ngon)
1con»0
Call tstpgn(1nout,n1oc,1con,terror)
If (1error.LE.-l) Go To 100
If (1nout.EQ.0) Then
Call tstxcr(ncross,n1oc)
If (ncross.EQ.1)1nout=-1
End If
CIf
(Inout.EQ.1) Then
nh1t«l
If (1cnt.EQ.0)Ift1n«ngon
1cnt«1cnt+l
1n(1cnt)»ngon
nleft«ngon
ngon*1rtnew(ngon)
If (ngon.EQ.0) Then
C print *,'
Test
1' Call settpl<npoly)
1test-l
End If
CElse If
(Inout.EQ.0) Then
If (nhlt.EQ.0) Then
1con*l
nloc»1nfnew(ngon)
Call tstpgnlInoutZ,nloc,1 con,lerrorZ)
If (1error2.LE.-l) Go To 100
If (1nout2.EQ.0) Then
If 1ast = n
gon
nleft=ngon
ngon = 1 r
tnew( ngon )
If (ngon.EQ.0) Then
C p
Int *,'
Test 2'
1rtnew(nleft)*ndpstn
Inf new( ndpstn )ssn
po1y
1upnew(ndpstn)«1up
fdwnew(ndpstn) =0
11fnew(ndpstn)*nleft
1rtnew(ndpstn)=0
ItestM
End If
Else If
(InoutZ.EQ.1) Then
1up«ngon
ngon*1dwnew(ngon)
If (ngon.EQ.0) Then
C print *,'
Test 3'
1dwnew(1up)=ndpstn
Infnew(ndpstn)*npoly
1upnew(ndpstn)* lup
1dwnew(ndpstn)*0
1 Ifnew(ndpstn)=0
\rtnew(ndpstn)
e0
1test=l End If
Else If
(InoutZ.EQ.-1) Then
1test»-l
Call wrtmsg(' Error, polygon crosses another')
Else1test*-l
Call wrtmsg(' Error with InoutZ value (not equal
& to 1,0,-1)')End If
CElse If
(nhlt.EQ.l) Then
If (Jcnt.EQ.0)lftout=ngon
Jcnt«Jcnt+l
Jout(Jcnt)*ngon
nleft«ngon
ngon*1rtnewlngon>
If (ngon.EQ.0) Then
C Print *,
Test 4'
C --
Procedure to
reset arrays.....
CCall
settpl(npoly)
ItestM
Else If
(ngon.GT.0) Then
1test=0
ElseCall
wrtmsg(' Problem with ngon (less
than zero)')
1test»-l
End If
End If
Else If
(1nout.EQ.-l) Then
Call wrtmsg(' Error, polygon crosses another*)
1test«-l
ElseCall
wrtmsg(' Error
In tstpgn (Inout was not 1,0,-!)')
1test--l
End If
10 End Do
End If
100
Continue
** 73
If (1error.LE.-l.OR.lerror2.LE.- 1)
1test«-l
c+cccc-cc+ccccccccccccccccccccccccccccc-c
Return
End
**************************************************************
getgrd - Asks the user for the name of
grid (grdnam), and
reads In
the grid.
Subroutine getgrd(Itest)
Common /names/grdnaiu,modnam,modgrd
Character quest*80,modgrd*80,modnam*80,grdnam*80
10 Continue
quest*' Grid name'
Call «sknam(grdnam,quest,Itest)
If < Itest. E
Q.-DGo To 100
Call redgrdtgrdnam,Itest)
If (Itest.EQ.-l)Go To 10
100 Continue
Return
End
*************************************************************************
getlIn - Returns the world coordinates (xl1ne,yl1ne) of
a line
entered on the Envision terminal.
The cross-hair cursor
keys or
the mouse may be used.
mcflag
Flag for
defaulting to
cross-hair cursor type
(mcur takes on
the same values as
mcflag)
* C
= Cross-hair cursor keys
* M
» Mouse
nllne
» Number of
points In
line xllne.yllne.
Iset *
Flag for
determining the connection of
end-
points (xl,yl,x2,y2) to the line.
« 2
* Connect (x2,y2) to
the end of
the line
xl 1ne(n1Ine),yl1ne(nlIne).
* 1
» Connect (xl.yl) to
the beginning of
the
1Ine xl1ne(1),yl1ne(1).
» 0 * Connect (xl,yl) and (x2,y2) as
In 1
and
2 above.
*-1 *
Do not connect endpolnts.
nptmax * The maximum number of
points that nbrpts*
nlIne can
equal.
nbrpts »
Number >=0 used for controlling the number
of points (nllne) that may be entered.
*************************************************************************
Subroutine getl1n(xl1ne,y11ne,n11ne,x1,y1,x2,y2,Iset,nbrpts,
&nptmax,mcflag,Itest)
Dimension x11 net 1
00),y11ne(100)
Character mcur*2,mcflag*2
1test*lmcur='N'
If (mcflag.EQ.'N') Then
Call askmoc(mcur)
If (mcur.EQ.'Q') Then
74
1test»-l
Elsemcf1ag»mcur
End If
Elsemcur "incf lag
End If
CIf
(mcur.EQ.»M') Then
Cal1 11nmou(xl1ne,yl1ne.nl1ne,xl,yl,x2,y2,1 set,nbrpts,
&
nptmax,Itest)
Else If
(mcur.EQ.'C') Then
Call 11ncur(xline,yl1ne,nl1ne,xl,yl,x2,y2,1 set.nbrpts,
&
nptmax,Itest)
End If
CReturn
End
C*
WC getmenu
- Prompts the user for screen menu Item and returns
C the Item number (NUMANS) and the first character of
C the string associated with the Item.
CC-
SubroutIne getmenu(ans,numans,mcur,xbox0,ybox0,xs1ze,ys1ze,
&xde1bx,ydelbx,nst-1ng,strIng)
Character*!*) str1ng(nstr1ng),ans*2
CIf
(nstrIng.GE.1) Then
CC - Prompt for cursor type,
If not already set.
CIf
(mcur.NE.'M'.AND.mcur.NE.'C') Then
Call askmoc(mcur)
If (mcur.EQ.'Q') Then
1test=-l
ans='
numans=-l
Else1test=0
End If
Else1test«0
End If
CC -
Prompt for screen location.
CDo 10
wh11e(Itest.EQ.0)
Call wrtmsg(' Select menu command')
1err=l
Call retpnt(x,y,mcur,lerr)
If (lerr.GE.0) Then
1test2»0
xlftbx«xbox0
xrgtbx*xbox0+xs1ze
ybotbx=
!ybox0
ytopbx = ybox0-«-ys 1 z
e
1*1CC
- Test user entered coordinates against the possible boxes.
CDo 20 whlle(1test2.EQ.0)
If ((x.GE.xlftbx.AND.x.LE.xrgtbx).AND.
& (y.GE.ybotbx.AND.y.LE.ytopbx)) Then
ans-str1ng<1>(1:1)//'
' numans*1
1test»l 1test2»l
Elsexlftbx-xlftbx+xdelbx
xrgtbx*xrgtbx+xdelbx
ybotbx-ybotbx+ydelbx
ytopbx*ytopbx+ydelbx
1-1 + 1If
( 1 .GT.nstMng) Then
Call wrtmsg(' Sorry, could not tell
which
& answer you wanted...try again.')
Itest2--l
End If
End If
20
End Do
CElse If
(lerr.LT.0) Then
1test»-l
ans='
* numans*-!
End If
10 End Do
CElseans='
' numans«-l
Call wrtmsgC NSTRING passed to GETMENU was <=0
f)
End If
CReturn
End
C +
C getmou - Returns the world coordinates of
the Envision graphics
C cross-hair cursor when using the mouse.
C-V*
Subroutine getmou(mode,1x,1y)
CCal1
moul1n
Cal1 mouexm(*0*)
C10
Continue
Read {5,20,err»90)mode,1x,1y
20 Format (13,2z4)
Ca11 mousop
Call alphon
Return
C90
Continue
Call alphon
Call wrtmsg(* Error,
1n reading mode and coordinates, try again*)
Go To 10
CEnd
C +
C getply - Returns the world coordinates (xscrn, yscrn) of
a polygon
**, -y s
C from the Envision terminal.
The cross-hair cursor keys
; / O
C or
the mouse may be used.
cC mcflag «
Flag for defaulting to cross-hair cursor type
C (mcur takes on the same values as mcflag)
C *
C « Cross-hair cursor keys
C »
M » Mouse
CC nbrpts *
Number of
points In
polygon xscrn,yscrn
C-r *************************************************************************
Subroutine getply(xscrn,yscrn,nbrpts,mcflag,Itest)
Dimension xscrn(100),yscrn(100)
Character mcur*2,mcflag*2
Cnbrpts=0
1test«l
mcur-'N'
If (mcflag.EG.'N') Then
Call askmoc(mcur)
If (mcur.EQ.'QM Then
mcflag-'N'
1test"-l
Elsemcflag«mcur
End If
Elsemcur=mcflag
End If
CIf
(mcur.EG.'M') Then
Cal1 entmou(xscrn,yscrn,nbrpts,Itest)
Else If
(mcur.EQ.*C*) Then
Cal1 entply(xscrn,yscrn,nbrpts,Itest)
End If
CC -
Test nbrpts against Itest...(did user crash out or what)
C also test nbrpts less than or equal to zero...
CReturn
End
C+
£ **************************************************************
C getsub
- Gets the subgrld locations entered using the cursor
C keys or
Envision mouse.
C-£ **************************************************************
Subroutine getsub(Itest)
Common /subscreen/xscrn(2 ),yscrn(2),xgr1d(2 ),ygr1d(2)
Character quest*80,mcflag*2,mcur*2,ans*l,1d*56,pgm*8,IntypeM
Character votf1g*2
Common /sca1e/xsc,ysc,xstart,ystart,x1n1t,y1ntt
Common /subgrtd/lcmln,fcmax,Irmln,1rmax,ncm1n,ncmax,nrmtn,nrmax
Common /sealefacts/1wc0,Jwc0,nxp1x,nyp1x,p1xd1m
Common /grIdspecs/1d,pgm,nc,nr,xo,dx,yo,dy,1proJ,cm,b1
Common /ortglna!/Iwcorg,Jwcorg,nxorgp,nyorgp
Common /flags/mcflag,votf1g
C1test«0
If (mcf lag.EG. 'N')
Then
Call askmoc(mcur)
If (mcur.EQ. *Q* )
Then
-7-,1test«-l
' / /
Else
mcflag«mcur
End If
If
Else
mcur=mcflag
End If
(1test.EQ.-l)Go To 100
CC -
Print help message
CIf
(votflg.EQ. W) Then
Ca 1 1
hlpmou
Call wait
End If
Citest2-0
1-0
Do 10
wh11e(1test2.EQ.0)
Call retpnt(x,y,mcur,1 ret)
If (Iret.GE.1) Then
1-1*1
If (1.EQ.l) Then
xscrn( 1 ) = x
yscrn(1 ) = y
Elsexscrn(2)=x
yscrn(2 )*y
1test2*l
End If
Else1test2»-l
1test=-l
End If
End Do
If (1test2.EQ.-l)Go To 100
10
lntypes'0'
Cal
Cal
Cal
Cal
Cal
setl1n(Intype)
drwl1n(xscrn(1)
drwl1n(xscrn( 1 )
yscrn( 1 )
yscrn(2)
xscrn(1 )
xscrn(2)
yscrn(2) )
yscrn(2))
drwl 1n(xscrn<2),yscrn(2),xscrn(2),yscrn( 1 ))
drwl 1n(xscrn(2),yscrn(1),xscrn(1),yscrn(1))
xsc«float(nxp1x)
ysc»float(nyp1x)
If (xscrn(1).GT.xscrn(2)) Then
xdum=xscrn(1)
xscrn(1)*xscrn(2)
xscrn(2)«xdum
End If
If (yscrn(1).GT.yscrn(2)) Then
ydum«yscrn(1)
yscrn(1)«yscrn(2)
yscrn(2)«ydum
End If
rscxsc=0.0
rscysc=0.0
If (abs(xsc).GT.1.0e-16)rscxsc-1.0/xsc
If (abs(ysc).GT.1.0e-16)rscysc=1.0/ysc
Do 20 J=l,2
xgr1d(J)=xstart+(xscrn(J)-1wcorg)*rscxsc
ygr1d(J)
ssystart + {
yscrn(J)-Jwcorg)*rscysc
20 Continue
78
ncm1n*1nt(xgr 1d< 1 ) )
ncmax«1nt(xgr1d(2)+0.5)
nrm1n=1nt(ygr1d(1 ) )
nrmax»1nt(ygr1d(2)+0.5)
CIf
(ncmln.LT.1)ncm1n-l
If (ncmax.GT.nc)ncmax=nc
If (nrmln.LT.1)nrm1n-l
If {nrmax.GT.nr)nrmax*nr
C1test*l
Call zomstr(Itest)
C100 Continue
Return
End
C +£ *************'
C graphoff -
Turns off the graphics character mode.
See page 5-8
C In
Envision Reference Manual, May 23,
1983.
C-£ *************
Subroutine graphoff
Character com*3
Ccom-'RG0*
Call esccom(com)
CReturn
End
C + CC
grdln
- Asks the user whether a
previous grid should be used
C or
If a
new grid should be created.
C-
\+
Subroutine grd1n(Itest)
Character quest*80,ans*2
C1test*0
Do 10
whllelItest.EG.0)
quest*' Read or
create a
grid (r/c/q)'
1val=laquest(quest,ans,'(a2)',0)
CIf
(ans.EG.'R') Then
Cal1 getgrd(Itest)
Else If
(ans.EG.'C'> Then
Call crtgrd(Itest)
Else If
(ans.EQ.'0'.OR.Ival.EG.-1) Then
1test--l
ElseCal1 errmsg
End If
If ((ans.EQ.'R'.OR.ans.EG.'C').AND.1 test.EQ.0)1 test-1
10 End Do
CReturn
End
C+
£ **************************************************************
C grvmod - Writes out a GRAVPOLY model using the POLYGON model
. '
' ,-n
C Information and user entered responses.
*!* is
C-
" ' '
\+
Subroutine grvmod(Itest>
Dimension xpoly(100),ypoly(100)
Common /topology/1nfo(100),1 upper(100),1down(100),1left(100),
&1r1ght(100)
Common /screenloc/ntota1,numply(100),xscr(100,100),yscr(100,100)
Common /parameter /parm(100,10)
Common /grIdspecs/1d,pgm,nc,nr,nz,xo,dx,yo,dy,IproJ,cm,bl
Common /orIglnal/Iwcorg,Jwcorg,nxorgp,nyorgp
Character 1dplot*40,If11e*50,If 11e2*50,quest*80,1fmt*80,
&1d*56,pgm*8,comf11*80,ans*2,ans2*2,name*8,un1x*4,un1z*4
namel1st/parms/Iplotr,Ibody,If lie,If 11e2,Isqs,datum,xseale,
&dc,un1x,un1z,name,height,ifmt,1dp lot,lobs,1calc,1res,naxco1
Ctplotr-9
naxcol-130
1body-0
1obs*0
1ca1c-0
1res*0
Idplot-'
* Iflle-'
* 1f11e2«'
* lsqs*0
datum*0.
xsca!e*0.
dc>0.
unlx-'kl1m'
unlz*'feet'
name*'grIdded'
helght-0.
CC - Ask for name of
file containing fleldpolnt Information.
C1test-l
quest** Name of
file containing fleldpolnt Information'
1val"1aquest(quest,If 1le,'(a50)',0)
If (Ival.EQ.-l)Go To 100
CC -
Name (type of data read In
from If l
ie).
C1test-0
Do 40 wh11e(ttest.EQ.0)
quest*' Type of data
In fleldpolnt file (enter H
for help)*
1val*1aquest(quest,name,'(a8)',-8)
CIf
(name(lsl).EQ.'G') Then
name*'grIdded'
helght-0.0
Write (6,45)
45 Format (2x,'Height of fleldpolnt grid above the same datume that')
quest*'
Is used to reference the body heights'
1val-1rquest(quest,height,*(el6.8)',16)
1test-l
If (Ival.EQ.-l)1test*-l
Else If
(name.EQ.'H'> Then
Call hlpg2
Else If
( Ival.EQ.-l) Then
1test«-l
Else
CC -
Ask for format type of data.
C1test2«0
Do 25
wh11e(1test2.EQ.0)
quest"' Enter format to use when reading In
your file*
1va1=laquest(quest,Ifmt,'(a80)',0)
If (Ival.EO.-l> Then
1test--l
1test2--l
Else If
(Ifmt.NE.'
') Then
1test2-l
1test»l
ElseCal1 errmsg
End If
25 End Do
End If
40 End Do
If ( 1
test.EQ.-DGo To 100
CC -
Ask for the name of standard grid containing the heights of
C fleldpolnts.
Cquest-' Name of standard grid containing heights of fleldpolnts'
Ival-laquest(quest,1f11e2,'(a50)',0)
If (Ival.EQ.-l)Go To 100
CC -
Ask for print out Identifier.
Cquest-' Identifier for printer output*
Ival-laquest(quest,1dp lot,'(a40>',0)
If (1val.EQ.-l)Go To 100
CC -
Ask If
constant should be added to calculated anomalies.
Cltest-0
Do 20 wh11e(ttest.EQ.0)
quest-' Add a
constant to the calculated anomalies (y/n/q)'
Ival-laquest(quest,ans,'(a2)',0)
CIf
(ans.EQ.«Y') Then
quest-' Constant to be added*
Ival-lrquest(quest,daturn,*(el6.8)',16)
1test-l
If (Ival.EQ.-l>1test=-l
Else If
(ans.EQ.'Q'.OR.Ival.EQ.-l) Then
1test--l
Else If
(ans.EQ.*N*) Then
ltest=l
datum-0.0
ElseCall errmsg
End If
20 End Do
If (Itest.EQ.-l)Go To 100
CC -
Ask Isqs determination.
C1test-0
Do 30 wh11e(Itest.EQ.0)
quest3
' Least-squares comparison/read observed values
& (y/n/h/q)'
1va1 = laquest(quest,ans2,'(a2 >',0)
CIf
(ans2.EQ.'Y') Then
Itest2
»0
*
f\ 1 D
o 35
wh
11
e( 1
tes
t2.E
Q.0
) t£
* O
f 1 s
qs**0
quest-* What value for
LSQS (0/1/7,
// to quit)*
1va1=11quest(quest,Isqs,*(12)*,-2)
CIf
(lsqs.EQ.0.0R.Isqs.EQ.1.OR.lsqs.EQ.7) Then
1test2-l
1test-l
Else If
( Ival.EQ.-l) Then
1test2--l
1test«-l
ElseCal1 errmsg
End If
35 End Do
Else If
(ans2.EQ.'N*) Then
lsqs-0
1test«l
Else If
(ans2.EQ.'H*) Then
Call hlpgl
Else If
(ans2.EQ.'Q*.OR.Ival.EQ.-l) Then
1test--l
ElseCall errmsg
End If
30 End Do
If (Itest.EQ.-l)Go To 100
CC - Ask for units In
x&y directions.
C1test-0
Do 50 wh11e(Itest.EQ.0)
unlx-'KILM*
quest-' Units In
x&y direction (FEET/KILF/MILE/METR/KILM/H/Q)'
1val*1aquest(quest,un1x,'(a4)',-4)
C1test-lIf
(unlx.EQ.'FEET'> Then
un 1x«'feet*
Else If
(unlx.EQ.'MILE*) Then
un1x«'mlle*
Else If
(unlx.EQ.'KILFM Then
unlx-'kllf'
Else If
(unlx.EQ.'METR') Then
un1x«'metr *
Else If
(unlx.EQ.'KILM' )
Then
un1x«'k11m*
Else If
(unlx.EQ.'H*) Then
Call h1pg3
1test-0
Else If
(unlx.EQ.'Q*.OR.Ival.EQ.-l) Then
1test--l
ElseCall errmsg
1test-0
End If
50 End Do
If (Itest.EQ.-l)Go To 100
CC - Ask for units In
z direction (height).
C1test«0
Do 60 wh11e(Itest.EQ.0)
un1z='FEET'
quest*' Units In
z direction (FEET/KILF/MILE/METR/KILM/H/Q)'
Ival = laquesKquest, un 1z , ' (a4 ) ',-4)
32
1test=lIf
(unlz.EQ.'FEET') Then
un 1 z
*'feet'
Else If
{unlz.EQ.'MILE') Then
un1z«'mlle'
Else If
(unlz.EQ.'KILF') Then
unlz-'kl If
Else If
(unlz.EQ.'METR') Then
unlz*'metr'
Else If
(untz.EQ.'KILM'> Then
unlz-'kt1m'
Else If
(unlz.EQ.'H') Then
Call hlpg3
1test»0
Else If
(untz.EQ.'Q'.OR.tval.EQ.-l) Then
1test--l ElseC
a11 errmsg
ttest-0
End If
60 End Do
If (Itest.EQ.-l)Go To 100
CC -
Ask for print switch to use.
C1test»0
Do 65
whtle(Itest.EQ.0)
Iflag=0
quest*' Print switch for body Information (1/0)'
1val«11 quest(quest,If lag,'(11)',1)
CIf
( Ival.EQ.-l) Then
1test=-l
Else If
(If lag.EQ.0.OR.If lag.EQ.1) Then
ttest=l ElseC
a11 errmsg
End If
65 End Do
If (Itest.LT.0)Go To 100
CC -
Ask which parm from the parm arrays to use when creating
C this model.
CCall askgvl(tone,ttwo,Ithree,ttest)
If (ttest.EQ.-l)Go To 100
CC -
Ask for the name to call this GRAVPOLY file (comfll)
C70 Continue
quest=' Name to call command file to run GRAVPOLY'
1val»1aquest(quest,comf11,'(a80)',0)
If (Ival.EQ.-l)Go To 100
If (comfll.EQ.' MGo To 70
CC -
Open the model file and write out the model.
COpen (11,f1le=comf11,status='new',carrtagecontrol = '1 1
st')
Write (11,nml-parms)
Call fndtop(ntop)
next = n
top
ttest«0
delxcn=dx/nxorgp
delycn*dy/nyorgp
Do 150 wh11eMtest.EQ.J0)
ngon=next
npoly* 1nfo(ngon )
nbrpts=numply( npoly)
If (nbrpts.GT.0> Then
Do 120 t» 1 ,
nbrpts
xpo1y( 1 )
»xo+(xscr( npol y , 1 > - I
wcorg )*delxcn
ypoly( 1 > »
yo+(yscr ( n
poly , 1 > -
Jwcorg )*delycn
120
Continue
CC -
Ffnd the handedness of the polygon (by right hand rule).
C gamma
> 0.0
* polygon ts
counter-clockwise
C gamma
< 0.0
» polygon 1s
clockwise
CCa 11
tota 1 t( g
amma , x
poly ,ypo1y , n
brpts )
CIf
(gamma. GT.0) Then
nstarfnbrpts
nend*l
1step«-l
Elsenstart* 1
nend»nbrpts
1step»l
End If
CC -
If the body has a
parent, we need to determine If
the parent-
C body/current-body overlap.
CI up =1 u
pper (ngon )
If ( 1
up.GT.0) Then
np1yup-info( 1 up )
Cpartop*parm(nplyup, lone)
parbot*parm( np l
yup , 1
two)
bodtop*parm(npoly , l
one)
bodbot«parm( npoly , I
two)
CC - We need only remove a
slab If
the parent body and current body
C overlap In
the z direction (height).
CIf
( ( (bodtop.LE.partop) .AND. (bodbot .GE .
parbot ) ) .OR.
& ( (
bodtop.GT.partop) .AND. (bodbot . LT. p
ar top > ) .OR.
&
( (bodtop.GT. parbot) .AND. (
bodbot. LT.parbot)) )
Then
CIf
(bodtop.LE.partop) Then
z top = ami n 1 ( b
od top , p
ar top )
Elseztop«partop
End If
CIf
(bodbot. GE. parbot) Then
zbot=amax 1 (
bodbot , p
arbot)
Elsezbot*parbot
End If
CC - Write out the slab parameters and coordinate Information.
CWrite
( 1 1 ,*)nbrpts, 1f lag , -
parm( nplyup , I
three) ,
Write
( 1 1 ,*)(xpoly( 1 ) ,
ypoly( 1 ) , 1 *
nstart ,nend , I
step)
End If
End If
CC - Write out the parameters and current body coordinate Info.
CWrIte (11, *
)nbrpts.If lag,parm(npoly,1 three),
& parm(npoly,lone),parm(npoly,Itwo)
WrIte (11,*)(xpoly(11>,ypoly< 1 1 ) , 11 = n
start,nend,Istep)
End If
CC -
Get next polygon
CCall
walk(next.ngon,ItestZ)
If (next.EQ.0.0R.1test2.LE.0)1test=l
150 End
OoClose (11)
C100
Continue
Return
End C + wC
gtpnt
- Returns the current world coordinates (x,y)
of the
C Envision cross-hair cursor.
CC ans = Character answer that user
entered [format(a 1)]
C *
e or
f, prompts the terminal for
screen coord.,
C and returns character answer.
C »
h *
returns ans-*h'
C s
q *
retL-ns ans='q'
C- w
Subroutine gtpnt(ans,x,y)
Character dum*3,ans*l
C1dx«0 1dy=0
Call setkam
Cal 1 loccur(tx,1y)
1test=0
If (1test.EQ.0) Then
10 Continue
dum-'
'Read (5,15,err=10)dum
15 Format (a3)
20
Continue
CIf
(dum.EQ.*E*.OR.dum.EG.«e') Then
Call loccur(1xloc,lyloc)
x=float(Ixloc)
y=float(lyloc)
ans»*e*
ItestM
CElse If
{dum.EQ.«F'.OR.dum.EG.'f*) Then
Call loccur(Ixloc,lyloc)
x=float(Ixloc)
y=float(lyloc)
ans='f*
1test»l C
Else If
(dum.EO.*H*.OR.dum.EQ.'h') Then
ans= * h'
1test=l
Else If
(dum.EQ. 'Q' .
OR.dum.EQ. 'q' )
Then
ans= 'q'
1test=l
CElse If
(dum.EQ. 'OS* )
Then
1dx=l 1dy=l
CElse If
(dum.EQ. 'Om* )
Then
1dx=-l
1dy«l C
Else If
(dum.EQ. '01 ')
Then
CElse If
(dum.EQ. 'Ox' >
Then
1dy=l C
Else If
(dum.EQ. 'Of >
Then
1dx=-l
CElse If
(dum.EQ. 'OrM Then
1dy=-l
CElse If
(dum.EQ. 'Ov' )
Then
tdx»l C
Else If
(dum.EQ. 'C\"' )
Then
1dy=10
CElse If
(dum.EQ. 't\$' )
Then
1dx»-10
CElse If
(dum.EQ- 'CM ')
Then
1dy=-10
CElse If
(dum.EQ. 'C\&') Then
CEnd If
CIf
( Itest. EQ.0) Then
1x= 1x+tdx
1y=fy+ 1 d
yCal 1
movcur ( 1x , 1y )
1dx=0
fdy»0
Go To 10
End If
End If
CReturn
End
subroutine hlpadd( Itest)
cftest=l
print *,'
Help for adding polygons not available'
creturn
end
C+
Q *************************************************************
C hlpapt -
Help message for subroutine addpnt (ADD POINT).
c- c
Subroutine hlpapt
Character ans*l
CWrite (6,10)
IB Format (/,'
Position the cross-hair cursor to a
corner of'
&' a
polygon, then choose:',/
c
&/,'
&/,'
&/,'
&/,'
Write
20 Format
(KEY)
(MOUSE)',
e or
f 1
or 2
B Selects the polygon'.
h 3
» Help message' ,
q 2&3
= Quit and return to Edit polygon mode',/)
(6,20)
(' When the polygon you selected Is
found.
It will*.
&' be drawn In
white on the',/,' screen and you will be asked*.
&' to select (using the cross-hair cursor):',/.
C
&/,'
&/,'
(1) The side of the polygon where points will be added*.
(2) An endpolnt of the selected side.',/)
Call wait
CC +CCCC-
C
Return
End
**********
hlpchg -
**********
***************************************************
HeLP CHanGe -
Displays the options available for
change labels/parameters associated with polygons.
***************************************************
Subroutine hlpchg
CCC +CCCC-
c
Write
10 Format
&/,'
&/, '&/, '
Return
End
**********
hlpcom -
**********
(6,10)
(/,' Change mode options:',/
1 » Change/assign labels on parameter list'.
p » Change/assign parameters to polygons'.
q »
Quit and return to Polygon add/... /edit mode*,/)
********* ****>« *
*************************************
Help module for Polygon command level, called by
the program POLYGON.
***************************************************
Subroutine hlpcom
CCCC +CCC
Write
10 Format
&*& '4*&*&
'& '4'Return
End
**********
hlpcpl
-
(6,10)
(/,' Polygon options available:',//.
p »
Polygon (add/change_parm/delete/ed1t_poly )
mode',/
o » Output P l
ouff /Godson file or
standard grid',/.
r *
Read model from file*,/.
w » Write model to output file',/,
S » Command parameter change mode',/.
z » Zoom to a
subgrld of grid',/,
Q *
quit' ,/)
****************************************************
Help message for subroutine pckpnt (PICK POINT)
for picking with the cross-hair cursor the corner of
87
V^
*
C a
polygon.
C-CSubroutine hlpcpl
CWrite (6,10)
10 Format (/,'
Position the cross-hair cursor to a
corner of,
A/,' this polygon and enter the screen location.',/)
CReturn
End
C +
C hlpcpy -
Prints help message about using the CPYPLY (COPY POLYGON)
C feature.
C-I*
Subroutine hlpcpy
CWrite (6,10)
10 Format (/,'
To copy a
polygon:',/,
&/,*
(1) Position graphics cursor to a
corner of polygon to',
&' copy',
&/,'
(11) Use the following keys to Identify the polygon',
&' or
screen location*,
&//,'
MOUSE
KEYBOARD
FUNCTION',
&/,
1 "e"
Sends cursor position to program',
&/, 2
"f" "
" "
" &/,
3 "h"
Help',
&/, 243
"q" Quit',/,
&/, (111)
Position the graphics cursor to the location to copy*,
&' the polygon at',
&/,'
(1v) Press appropriate key(s) as In
step (11).',
&//,'
NOTE:
The parameters for this polygon are also copied.',/)
CReturn
End
C +
C hlpcur -
Help message for entering a
single screen location
C using the cross-hair cursor keys and keyboard com-
C mand keys.
Called by subroutine retpnt (RETURN POINT)
C-
£ *************************************************************
Subroutine hlpcur
CWrite (6,10)
10 Format (/,'
To enter a
screen location, position the cross-hair',
&' cursor to the desired',/,' location and then type:',/,
&/,'
e or
f »
Enters the cross-hair cursor location',
&/,'
h Help',
&/,'
q Quit (no point Is
entered)',/)
CReturn
End
C +v»C
hlpdel
- Prints help message on using the delply (DELETE POLY-
C GON) mode.
C-V*
Subroutine hlpdei
CPrint *,*
Help for deleting polygon not available yet*
cReturn
End
O
CC hlpdpt -
Help message for subroutine delpnt (DELETE POINT).
C-
Subroutine hlpdpt
Character ansM
CWrite (6,10)
10 Format (/,*
Position the cross-hair cursor to a
corner of*,
&' a
polygon, then type:',/,
&/,'
(KEY)
(MOUSE)',
&/,'
e or
f 1
or 2
« Selects the polygon',
&/,'
h 3
Help message',
&/,'
q 2it3
=
Qu
it an
d
retu
rn
to
Ed
it p
oly
go
n',
&'
mo
de
',/) C
Write
(6
,20
)20 Format (*
When the polygon you selected Is
found,
1t will',
&* be drawn In
white on the screen',/,' and you will be asked',
&* to select (using cross-hair cursor), the corner of this',
&/,' polygon to delete.',/)
CCall wait
CReturn
End
C +V*C
hlpedt -
Help message for Edit polygon mode.
C-
**
Subroutine hlpedt
CWrite (6,10)
10 Format (/,'
Edit mode options:',/,
&/,*
a * Add points',
&/,'
d =
Delete a
point',
&/,'
m = Move a
point',
&/,'
q = Quit and return to Polygon mode',/)
CReturn
End
C +
C hlpent -
Asks If
help
Is need for entering a
polygon.
C-
Vx
Subroutine hlpent(Itest)
Character ans*1,answ*1,quest*80
C1test=0
If (Itest.EQ.0) Then
10 Continue
answ='y'
quest3
' Do you need Instructions (y/n)'
1va1 = 1aquest(quest,answ,'(a 1)',1)
CIf
(answ.EQ.'y*) Then
Call msgent
1test»l
89
Else If
(answ.EQ. 'n' )
1test-l
Then
C +CCCC-C +
WC C C-V*
Else If
(answ.EQ.'/*) Then
1test»-l
ElseCal 1
errmsg
End If
If ( 1
test.EQ.0)Go To 10
End If
Return
End
hlpgl
- Prints help message at user's terminal about least-
squares determination when generating a
GRAVPOLY file.
[***********!
Subroutine hlpgl
Write (6,10)
10 Format (/,'
LSQS
- A number that determines
If fleldpolnt',
&' (observed) values will be',/,' read or not or whether a',
&' least-squares comparison will be made between the',/,
&' calculated and observed values.',//,
&' 0 »
No fleldpolnt (observed) values will be used.',
&' It
must be kept In
mind',/,'
that It
Is always',
&' necessary to read fleldpolnt locations In
order to',
&/,'
define the grid points at which the model',
&' values will be calculated.',
&/,'
1
Fleldpolnt values will be read and used to*
&' calculate residual*,/,'
values (observed-',
&'ca1culated).',
&/,'
7 »
A least-squares comparison between the observed',
&' and calculated values',/,'
will be made to',
&* determine the best density contrast.',/)
Return
End
r***i
hlpgZ
- Prints help message at user's terminal about data type
of fleldpolnt f1le.
!***********{
Subroutine hlpgZ
Write (6,10)
10 Format (/,'
Enter the type of
data In
the fleldpolnt file.',
&' Default Is
"grldded" or
"g",',/,' which means that the',
&' fleldpolnt data will be read as a
standard USGS geophysics',
&' grldded file.',/,' Any other character (maximum of 8)
will',
&' be assusmed a
user formatted file.',/,'
If a
user formatted',
a standard USGS geophysics file of the same',/.
' file Is
read,
' data with the name "GRAVPOLY .OBS "
will be created.',/)
Return
End
subroutine hlpg3
return
end
Made It
to hlpg3'
c cSubroutine hlpmgl
CWrite (6,10)
10 Format (/,
&* LSQS Is
a number that determines what type of field-*,
A'polnt (observed) values*,/,* will be read or
what type or*,
&* least-squares comparison will be made between',/,* the*,
&* calculated and observed data.*,
&/,*
0 *
No fleldpolnt (observed) values will be used.*,
&* It
must be kept*,/,
&* In
mind that It
Is always necessary to read*,
4* field point*,/,
A* locations
In order to define the grid points',
&* at which the model*,/,
&* values will be calculated',/
&/,'
1
y component of magnetic anomaly*,
A/,*
2 »
x component of magnetic anomaly*,
&/,*
3 * Vertical component of magnetic anomaly (some*,
&* ground surveys)*,
&/,*
4 *
Total horizontal component of magnetic anomaly*,
&/,*
5 *
Total magnetic anomaly (the usual observed*,
&* aeromagnetlc anomaly)*,
A/,*
6 A best total magnetization vector (amplitude,*,
&* declination and*,/,
&* Inclination) will be determined by a
least-*,
&*square comparison*,
&/,*
between the observed and calculated values.*,
&/,*
7 *
A best susceptibility, assuming no remanent*,
&* magnetization, will',
&/,*
be determined by a
least-squares comparison*,
&* between the*,
&/,*
observed and calculated values.*,/)
CReturn
End
hlpmou -
Prints help messages on users terminal about using
C the Envision mouse or cross-hair cursor keys.
C-CSubroutine hlpmou
CCal1 msgmol
Call msgmoZ
Ca11 msgmo3
CReturn
End
O
CC hlpmov -
Prints help message about using the MOVPLY (MOVE POLYGON)
C feature.
C-
CSubroutine hlpmov
CWrite (6,10)
Return
91
End
O
CC hlpmvp -
Help message for moving a
single point, called
C by subroutine movpnt (MOVE POINT).
C-
V*
Subroutine hlpmvp
Character ans*l
CWrite (6,10)
1.0 Format (/,'
To move a
corner point, position the cross-hair',
&' cursor to a
corner of the*,/,' polygon, then type:',/,
&/,'
(KEY)
(MOUSE)',
&/,'
e or
f 1
or 2
B Enters the cross-hair cursor location*,
&/,'
h 3
Help',
&/,'
q 2&3
- Quit (no point Is
entered)',/)
CWrite (6,20)
20 Format ('
The polygon that you selected will be drawn In
white',
&* on the screen.
The point*,/,.' to be moved Is
entered',
&' by positioning the cross-hair cursor over the desired',
&/,' corner of the polygon (entering this corner location),',
, &*
and then positioning the',/,' cursor to the new location',
&' for this corner.',/)
CCall watt
CReturn
End
C+
\+C hlpout -
HeLP OUT -
Prints help message at user's terminal
C about Polygon output file types.
C-£ *************************************************************
Subroutine hlpout
CWrite (6,10)
10 Format (/,'
Output file options:',/
&/,'
p « Plouff/Godson format file (GRAVPOLY/MAGPOLY)',
&/,'
s » Standard grid file',
&/,'
q - Quit and return to POLYGON command',/)
CReturn
End
C +£
*************************************************************
C hlpval
- Prints help message about options available In
the
C chgpar (CHANGE PARAMETER) mode.
C-£ *************************************************************
Subroutine hlppar
CWrite (6,10)
10 Format (/,*
Options for changing polygon parameters:',/,
&/, '
a *
All polygons (via tree structure)',
&/,'
p «
Pick Individual polygons using cursor',
&/, '
q * Quit',/)
CReturn
End
_ ^c+
92£ **************************************************************
* *
hlpplf -
Help message for PLOUFF/GODSON GRAVPOLY/MAGPOLY out
put files.
***********
Subroutine hlpplf
Write (6,10)
10 Format (/,'
Enter "g"
for a
gravity model, or "m"
for a
magnetic*
&,&' model.',
A/,' NOTEi GRAVPOLY and MAGPOLY assume that the positive',
A' direction
Is upward.',/)
Return
End
t***ihipply -
Prints help message for plycom (POLYGON COMMAND) sub
routine.
Subroutine hipply
Write (6,10)
10 Format (/,'
POLYGON add/change/delete/edit options:',/
Add a
polygon *,
Change polygon parameters',
Delete a
polygon'.
Ed It a
polygon',
Special functions',
Cult and return to POLYGON command',/)
A/,
A/,
A/,
*/,
A/,
A/,
acdesqR
etu
rnE
nd
hlprot -
Prints help message about using the ROTPLY (ROTATE POLYGON)
feature.
Subroutine hlprot
Write (6,10)
10 Format (/,*
To rotate a
polygon:*,/,
A/,'
(1) Position the graphics cursor to a
corner of*,
A' the polygon to rotate',
A/,'
(11)
Use the following keys to Identify the polygon',
A' or screen location',
A//,'
MOUSE
KEYBOARD
FUNCTION',
"e" Sends cursor position to program*,
II X H
II M
II II
H ,
"h" Help',
"q" Quit',/,
Choose the location to use for the center of',
(corner picked In
steps (1)
and (11) may be used'.
Press appropriate key(s) as In
step (11).',
Enter rotation angle In
degrees.',/)
hlprtZ -
Help for subroutine rotply (ROTATE POLYGON), sends
A/,
A/,
A/,
A/,
A/,
A'
rA
/,A
/,A
/,
1232
A3
(11
1)
Cho
ota
t Ion
' ,(C
O( 1 v )
Pre
(v)
En
t
Retu
rnE
nd
93
C message to user on positioning cursor for origin to
C rotate polygon about.
C-
Subroutlne hlprtZ
CWrite (6,10)
10 Format (/,*
Move the cross-hairs to the location of the origin*,
&' to rotate this',/,* polygon about, and enter this point.',/)
CReturn
End
C+
C hlpspf -
Help Information for SPFCOM -
(SPECIAL FUNCTIONS MODE)
C-
Subroutlne hlpspf
CWrite (6,10)
10 Format (/,'
Special functions are:*,/,
&/,'
c * Copy a
polygon,*,
&/,*
m * Move a
polygon,*,
&/,*
r Rotate a
polygon,',
«,/, ' q
« Quit. ' ,/)
CReturn
End
C +£ **************************************************************
C hlpstk -
Help message for stack release mode.
Called by sub-
C routine zomstk (ZOOM STACK).
C-£ **************************************************************
Subroutine hlpstk
CWrite (6,10)
10 Format (/,'
Zoor stack release options:*,/,
&/,'
b * bottom of stack (oldest zoom values)*,
i/,'
c
clear zoom stack',
&/,'
t *
top of stack (youngest zoom values)',
&/,*
q * quit or //
return to zoom command level',/)
CReturn
End
C +WC
hlpzom -
Help message for zoom command mode.
C-£ **************************************************************
Subroutine hlpzom
CWrite (6,10)
10 Format (/,'
Zoom options available:',/,
i/,'
c »
Clear zoom stack',
&/,'
d =
Draw grid using a
selected zoom value',
&/,'
r *
Recall and draw grid using zoom values at top of',
«,' stack',
i/,'
s » Select a
subgrld (using mouse, cursor, or coords)*,
&/,'
u *
Unzoom and draw grid on screen (does nothing',
i/,*
to zoom values)',
&/,'
q * Quit and return to Polygon command',/)
' '
c **
94Return
'
i
c+cccccccccccccccccccccccc-c
End
IAQUEST -asks question with character answer
Ireturn *
IAQUEST (quest,ava1,form,mode)
Ireturn *
-1 1f
*//* was given as
response (user
wants out)
0 If
no response (user
took default)
1 If
user responded (returns response In
aval)
quest =
Character string containing question to be asked
(with no
? at the end,
It Is
added by function)
aval «
Character string to
receive answer
(used to pass default If
one Is
available)
form =
Character string containing fortran format to be
used to read the user
response
mode *
Integer control parameter:
mode
> 0,
default allowed
mode «
0, no
default allowed, upshift response
mode <
0, default allowed, upshift response
Integer Function 1aquest(quest,ava1,form,mode)
Character questM*) ,form*( *) ,aval*( *)
Character*100 str,form2*10,ans*80,astr*30
1aquest*0
Iqlen"1tlen(quest)
1rlen=1tlen(ava1)
If (mode.LT.0)Cal1 upshIft(ava1)
If (trlen.EQ.0)1rlen=l
If (mode.NE.0) Then
str=quest(1:Iqlen)//
1 s 1 en * 1 q 1 en + 1 r 1 en + 4C '
//aval(1:Irlen)//']?'
Else
str=quest(1:1qlen)//
f?' 1slen=Iqlen*1
End If
Write (formZ,105)1slen
105 Format
(f(x ,a', 1
3,',$)')
13 Write (6,form2)s' .-
Read (5,form)ans
1alen-31
1alen=1tlen(ans)
If ( 1
alen.NE.0) Then
If (ans.EQ.'//') Then
laquest--!
Else
iaquest=1
aval(1:1en(aval))=ans(l:len(aval))
If (mode.LE.0)Cal1 upshIft(ava1)
End If
Else
If (mode.EQ
End If
Return
End
0)Go To 13
C +CC
IDEBLANK- removes all
blanks and returns length
95
C Ireturn =
IDEBLANK (string)
CC Ireturn =
length of
the string without blanks
C string
* character string to
be de-blanked
CC-
Integer Function Ideblank(str1ng )
Character*256 str1ng*(*),temp
temp='
'1temp»len(strIng)
Do 10
1=1,Itemp
If (str1ng(1:1).EQ.' ')Go To 10
tempiJ:J)-str1ng( 1:1)
J-J + 1 10
Continue
str1ng=temp
1deblank=J-l
Return
End
C+C IIQUEST - Asks a
question with an
Integer answer
CC Ireturn »
IIQUEST (quest,Iva1,form,mode)
CC Ireturn
= -1
If '//'
was given as
response (user
wants out)
C 0 If
no response (user
took default)
C 1
If user responded (returns response In
aval)
CC quest »
Character string containing question to
be asked
C (with
no ?
at the end,
It Is
added by function)
CC Ival
* Integer variable to receive answer
C (used to pass default If
one Is
available)
CC form =
Character string containing fortran format to
be
C used to format the default contained In
Ival CC
mode *
Integer control parameter:
CC mode *
0, required response (no
default allowed)
C mode <>0,
default allowed
C-
Integer Function 1Iquest(quest,1va1,form,mode)
Character quest*(*),form*(*),rstr2*30
Character*100 str,form2*10,ans*30,astr*30
11quest«0
Iqlen*Itlcn(quest)
Write
(rs
trZ.fo
rmM
val
1rlen-1deblank(rstr2)
If (mode.NE.0) Then
str»
qu
est(1
:Iqle
n)//'
[V/r
str
2(l:1
r1 e
n)//'3
?'
1slen-1qlen+1rlen+4
Else
str=quest(1:Iqlen)//'?'
Islen*1qlen+l
End If
Write (form2,105)Islen
105 Format (Mx , a ', 1
3,',$)')
13 Write (6,form2)str
Read (5,110)ans
110 Format (a30)
* » O/
la Ten* Ideblank ( a
ns )
If ( 1alen.NE.jBf)
Then
If (ans.EQ. '//' )
Then
I Iquest--!
Else
1 1quest-l
Read (ans(lt1alen),120,err*25)1val
120
Format
( 1 10)End If
Else
If (mode.EQ.0)Go To 13
End If
Return
C couldn't decode
25 Continue
Write (6,130)
130 Format ('
Please answer again,
I expect a
number.')
Go To 13
End
C +I*C
Initial
- Initializes the variables used
In running POLYGON.
C-
£ **************************************************************
Subroutine Initial
Common /commands/nmax ,eps 1 1 n ,del 1 n , d
el out
Common /max/nptmax
Common /mlsc/ncol ,nrow,f1rst ,ntop, If I
rst
Common /zoom/ 1 z
oom, Izval , n
zoom, ncml nz ( 5
),ncmaxz(5),nrm1nz(5),
&nrmaxz( 5 )
Character 1d*56,pgm*8
CC -
Initialize the maximum number of polygons (nmax), the maximum
C number of
points
In each polygon (nptmax), and the starting
C number of polygons (ntotal).
Cnmax* 100
nptmax= 100
ntotal-0
CC -
Initialize variables used In
drawing the grid and polygons
C on the terminal screen.
CCall Intscr
CC -
Initialize the variables stored In
the original common block
CCall Intorg
CC -
Initializes the calc common block
CCall Intcal
CC -
Initialize flags used In
program
CCall Intflg
CC -
Initialize the zoom stack and pointers.
C1zoom=0
1zval=0
Cal 1
Intzom
C C -
Initialize the location arrays for the polygons.
Q7
? f
cCall Intloc
CC -
Initialized th« topology structure arrays.
CCall Inttpl
Ca11
i ntnew
CC -
Initialize the labels associated with the value list.
CCall tntlab
CC -
Initialize the parameters
In the parm list.
CCal 1
Intpar
CC -
Initialize the paramters used In
filling a
polygon
CCall Intfll
CReturn
End
C +£ **********************************************************************
C InkJet - Sets an optimal color map for dumping the screen to the
C InkJet plotter.
At present, only ncolors=12 properly map.
CC Author:
Robert W.
Simpson, USGS, Menlo Park, CA, 1984.
C-£ ***********************************************************************
Subroutine 1nkjet(loun1t,ncolors)
CCharacter*100 str(20)
If <ncolors.GE.l.AND.ncolors.LE.13) Then
Cstr(13)-'IJ0007,1000,3165,4110,5245,6006,7090,8218,9003,'//
& ':221,;107,<075,=077,>111,7053,,'
str(12)-'100007,1000,3165,4110,5245,6006,7090,8218,9003,'//
& ':221,;107,<075,=077,>053,,'
str{11)- * 1
00007,1000,3165,4110,5245,6006,7090,8218,9003,'//
& ':107,;075,<077,=053,,'
strt10)='100007,1000,3165,4110,5245,6006,7090,8003,9107,'//
& ':075,;077,<053,,'
str(9)-'100007,1000,3165,4110,5245,6006,7090,8003,9107,'//
& ':077,;053,,'
str < 8 ) =
I00007,1000,3165,4110,5006,6090,7003,8107,9077,'//
& ':053,,
str < 7 ) =
I00007,1000,3110,4006,5090,6003,7107,8077,9053,,'
str(6)« 100007,1000,3110,4006,5090,6003,7107,8077,,'
str(5)- 100007,1000,3006,4090,5003,6107,7077,,'
str(4)- 100007,1000,3006,4090,5003,6077,,'
str (3)- 100007,1000,3006,4003,5077,,'
str (2)- 100007,1000,3006,4077,,'
str(l)= 100007,1000,3006,,'
Call rdeblank(str(ncolor s),str(ncolors)
fleng)
Cal1 esccom(str(ncolors)(1:leng))
ElsePrint *,'
Subroutine INKOET cannot handle ncolors',ncolors
End If
CReturn
End
C + C
98
C intcal
- Initiallzse the calc common block.
C-r **************************************************************
Subroutine Intcal
Common /ca1c/ncont,cmin,cdel
Cncont=J0fcm1n-J0.J0cdel'0.0
CReturn
End
C +I*C
Intfll
- Initializes the parameters used in
pattern filling
C a
polygon.
i**********
Subroutine Intfll
Common /f11 I/open,solId,f11typ
Character open*!,sol1d*l,f1ltyp*l
Copen= *P'
sol1d='0»
f 11typ=»1'
CReturn
End
C + CC
Intflg -
Initializes flags used
In program POLYGON.
C-
Subroutlne Intflg
Common /flags/mcflag
Common /model/mdflag
Character mcflag*2
Cmcf1ag='N'
mdf1ag=0
CReturn
End
C +
C Intlab -
Initializes the labels associated with the value
C arrays.
******!
Su
bro
utin
e
intla
bC
omm
on /la
bels
/lab
el
Ch
ara
cte
r 1
ab
eK
10
)*15
C
nla
b=
lJ&
Oo
10
I=
l,n1ab
labeK 1 )
«'UNASSIGNED»
10 Continue
CReturn
End
C +
C Intloc -
INiTialize Location
- Initializes the location
** //
C and boundary arrays.
c-r *************************************************************
Subroutine Intloc
Common /commands/nmax,eps1 In,del1n,delout
Common /junk/ngbtop,jnktop(100),ngbloc,jnkloc(100)
CDo
10 npoly*l,nmax
Call delloc<npoly,Itest)
10 Continue
Cngbloc=0
Do 20
j= 1 ,nmaxjnkloc(j)»0
20 Continue
CReturn
End
C +wC
Intnew -
Initializes the working topology array
In the newtopo
C common block.
C-\*
Subroutine Intnew
Common /newtopo/1nfnewt 100),1upnew(100),<dwnew( 100),
&1Ifnew(100),<rtnew(100)
Common /commands/nmax,eps1 In,del 1
n,delout
CDo
10 1*1,nmax
1nfnew(1)=0
1upnew(1)=0
1dwnew(1)=0
1 Ifnewt 1)=01rtnew(1)=0
10 Continue
CReturn
End C +
C Intorg
- Initializes the variables stored
In the
C common block.
C-£ **************************************************************
Subroutine Intorg
Common /orlglnal/lwcorg,Jwcorg,nxorgp,nyorgp
C1wcorg=0
Jwcorg=0
nxorgp=0
nyorgp=0
CReturn
End C +
C Intpar
- Initializes the parameters
In the parm list.
C-£ **************************************************************
Subroutine Intpar
Common /Parameter/parm<100,10)
Common /commands/nmax,eps1 In,del 1n,delout
CDo 10 1=1,nmax
00
Do 10
J = l ,10 parml 1 , J )
=0.0
10 Continue
Return
End
*************************************************************
Intply -
Initializes the POLYLOC common block, used by most of
the editing and special function routines.
:********** ***************************************************
Subroutine Intply
Common /max/nptmax
Common Xpo1y1oc/npt1oc,xloc( 100) ,y1oc( 100)
nptloc»0
Do 10
1=1 ,nptmax
x1oc( 1 )
»0.0
yloc( 1 )
=0.0
10 Continue
Return
End
i* ** iIntscr
- Initializes the parameters used
In drawing the grid
and polygons on the screen.
t***********
Subroutine Intscr
Common /gr Id s
pecs/ Id , p
gm.nc ,nr,nz,xo,dx,yo,dy
Common /sca1e/xsc,ysc,xstart,ystart,x1n1t,y1n1t
Common /subgrld/lcmln.l cmax , I
rmln, 1 r
max , nctnl n , n
cmax ,nrm1n,nrmax
Common /sub screen/ xscrn( 2 ) ,
yscrn( 2 ) , x
grd ( 2 ) ,
ygrd( 2)
Common /commands/nmax , e
ps 1 In, d
el 1 n ,
de1out
Character 1d*56 ,pgm*8 , z
mf lag*!
x1n1t=100.0
ylnlt-100.0
XSC*
S0.0
ysc»0.0
xstart=l
ystart= 1
1cm1n=l
1cmax=nc
1 rml n= 1 1 rmax^nr
ncm 1 n= 1
ncmax=nc
nrm 1 n= 1
nrmax=nr
xscrn( 1 )a
0.0
yscrn< 1 )
*0.0
xscrn(2)=4000.0
yscrn<2>=3000.0
xgrd< 1 )
=0.0
ygrd(l>=0.0
xgrd(2)=0.0
101
ygrd(2)*0.0
Cepsl ln«»l .
0e-10
del1n=25.0
de1outM0.0
CReturn
End
C+
CC Inttmp
- Initializes the TEMP array, used by most of the editing
C and special function routines.
***********<
Subroutine Inttmp
Common /max/nptmax
Common /temp/ntemp ,xtemp(100),ytemp<100)
ntemp«0
Do 10
1-l,nptmax
xtemp(1)«0.0
ytemp(1)»0.0
10 Continue
Return
End
***
Inttpl
- INITIal ToPoLogy -
Initializes the topology arrays
and the garbage collector Jnktop.
***********
Subroutine Inttpl
Common /topology/1nfo(100),1 upper(100),1down(100),
&11eft(100),1r1ght(100)
Common /Junk/ngbtop,Jnktop(100),ngbloc,Jnk1oc(100)
Common /commands/nmax,eps1 In, d
elIn,del out
Cngbtop=0
Do 10
npoly*!,nmax
C1nfo(npoly)=0
1 upper(npoly)«0
1down(npoly)=0
11eft(npoly)«0
1r1ght(npoly)«0
CJnktop(npoly)«0
10 Continue
CReturn
End
C +£ ******************************************************
C Intwrk
- Initializes work grid (wrkgrd) to dval.
k***********************
Subroutine Intwrk(dval)
Common /work/wrkgrd(250000)
Do 10
1-1,250000
wrkgrd<1)=dval
10 Continue
occcccccccccccc-c
Return
End
Intzom -
Initializes the zoom stacks
nrmaxz for the zoom command.
********************
ncm 1 nz , n
cmaxz , n
rml nz ,
Izoom
nzoom
Izval
Flag for zoom state
1 «
Yes, program Is
0 «
No, program Is
of program
In zoomed state
not In
zoomed state
Pointer to top of zoom stack, range Is
from 0-5
Pointer used by subroutine unzcom (UNZOOM
COMMAND) to Identify zoom values to use In
recal1 mode.
ft**************************!
Subroutine Intzom
Common /zoom/Izoom,Izval,nzoom,ncm1nz(5),ncmaxz(5),nrminz(5)*
&nrmaxz(5)
Cnzoom«0
Do 20 1-1,5
ncm1nz(1)*0
ncmaxz(1 )»0
nrmlnz(1)»0
nrmaxz(1)*0
20 Continue
CReturn
End
C +£ **************************************************************
C Invers -
Transforms a
coordinate (xo1d,yo1d) from the zoomed
C screen to unzoomed screen coordinates (xnew,ynew).
C-
w
Subroutine 1nvers(xnew,ynew,xold,yold)
Common /subgrld/lcmln,icmax,Irmln,1rmax,ncm1n,ncmax,nrm1n,nrmax
Common /or1gInal/Iwcorg,Jwcorg,nxorgp.nyorgp
Common /scalefacts/1wc0,Jwc0,nxp1x,nyp1x,p1xd1m
Cxorg*1wcorg+(ncmln-1)*nxorgp
yorg*Jwcorg+(nrmln-1)*nyorgp
Cxnew*xorg+(xold-1wc0)*nxorgp/nxp1x
ynew*yorg+(yold-Jwc0)*nyorgp/nyp1x
CReturn
End
C +CCCCCCCCCCCC
IRQUEST
- asks question with real answer
Ireturn m
IRQUEST (quest,rva1,form,mode)
Ireturn *
-1 If
//* was given as response (user wants out)
0 If
no response (user took default)
1 if
user responded (returns response In
aval)
quest =
Character string containing question to be asked
(with no 7
at the end,
It Is
added by function)
rval
= Real variable to receive answer
103
C (used to pass default If
one Is
available)
CC form *
Character string containing fortran format to be
C used to format the default contained In
rval
CC mode *
Integer control parameter:
CC mode *
0, required response (no default allowed)
C mode <>0, default allowed
C-£
*********************************************
Integer Function 1rquest(quest,rval.form,mode)
Character quest*(*),form*(*>,rstr2*30
Character*100 str,form2*10,ans*30,astr*30
1rquest»0
Iqlen*Itlen(quest)
Write (rstr2,form)rwal
1rlen*1deb1ank(rstr2)
If (mode.NE.0) Then
str-quest(ltIqlen)//*
C *//rstr2(I:1r1en)//*]?*
1slen*1qlen+1rlen+4
Else
str-quest(1:Iqlen)//*?*
Islen*lqlen+1
End If
Write (form2,105)1slen
105 Format (*(x,a*,13,*,S)*)
13 Write (6,form2)str
Read (5.110)ans
110 Format (a30)
lalen*1deblank(ans )
If (1alen.NE.0) Then
If (ans.EQ.*//') Then
Irquest*-!
Else
1 rquest=1
Read (ans(1:lalen),120,err-25 )rval
120
Format (f20.0)
End If
Else
If (mode.EQ.0)Go To 13
End If
Return
C couldn't decode
25Continue
Write (6.130)
130
C +CCCCCCCC-c
**<
Format
( *Go To 13
End
ITLEN
Ireturn *
Ireturn
str Ing
***********
Please
Gives
ITLEN
- the
answer
length
(string)
length
aga 1 n ,
of
of«
string to have
*****************
I
str Ing
the
*m expecting
without
str Ingtral 1
***<»* *
Ing
****
tral
without
a number
. * )
1 Ing blanks
tra 1 1 1 ng
blanks
blanks removed from
*****iInteger Function 1tlen(strIng)
Character strlngM*)
1slen(strIng)
10 Continue
" 1 /)/
If (str 1ng( 1 t 1 ) .NE.
)Go To 15
! vn
1-1-1If
{ 1 .GT.0)Go To 10
15 Continue
ltlen-1
Return
End
c+cccccc-c
*****************************
1 Incur - Returns the world coordinates of a
line
( xl Ine, yl 1 ne) entered using the Envision cross-hair cursor keys.
The parameters are explained In
LINCUR.INF.
**************************************************************
Sub rout 1 n
e 11ncur(xi1ne,yl1ne,nl1ne,xl,yl,x2,y2,1 set, nbrpts ,
Anptmax , 1 t
est )
Dlinens Ion xl 1ne( n
ptmax ) ,yl 1ne( n
ptmax )
Character ans*l
Cal 1
curon
1=0
1test«0
nl 1ne=0
ntota 1 =
nbrpts
If Mtest.EQ.0) Then
10
Continue
Call gtpnt(ans, x ,y )
If {ans.EQ. »e» .
OR.ans.EO. 'f ' )
Then
If (ntotal .EG. (
nptmax-1 > .
AND. ans.EQ. »e')
Then
Print *,*
Last point, only (f/q) are allowed answers
Else1-1 + 1ntota 1 »
ntota 1+1
xl 1ne( 1 ) = x yl 1 ne( 1 )=y Call drwpnt(x,y)
If ( 1 .EQ. 1 .AND. ( 1
set.EQ.0.0R. Iset.EO. 1 ) )Cal 1
&
drwl 1n( x 1 , yl , x ,y >
If (I.GT.l)Call drwl 1n(xl 1ne( 1-1 ) ,yl 1ne< 1-1 ) ,
x,y)
If (ans.EQ. 'f .OR. n
tota 1 .EO. n
ptmax) Then
nl 1ne=1 1test=l
If ( I
set.EO. 0. OR. 1
set.EQ.2)Cal 1
drwl 1n( x , y , x2 ,y2 )
End If
End If
Else If
{ans.EQ. *h' )
Then
Call hlpent
Else If
(ans.EQ. 'q')
Then
nl 1ne«1
Itest--!
Else Call
errmsg
End If
If (ntota1.EQ.(nptmax-1).AND.1test.EQ.0)
Print *,!,' coordinates entered, only
End If
If (1.GT.nptmax)1test»-l
If (Itest.EQ.0)Go To 10
End If
Then
one more
allowed *
105
Cal1 curoff
Return
End
C+
£ ft*****!
C llnmou - Returns the world coordinates of a
line (x11ne,y11ne)
C entered using the Envision mouse.
CC The parameters are explained
In LINMOU.INF.
C-£ **************************************************************
Subroutine 11nmou(x1Ine,yl1ne,n11ne,x1,y1,x2,y2,Iset,nbrpts,
&nptmax,Itest)
DlmensIon xl1ne(nptmax),yl1ne(nptmax)
Character ans*l
CCall curon
Call softky('l')
Call setmou
Cal1 loadmou
C1test-0
1-0
nl1ne«0
ntotal»nbrpts
If (Itest.EQ.0) Then
10 Continue
Call getmoudnode,1x,1y)
x-floatt1x)
y»float(1y)
If (mode.EG.1.OR.mode.EQ.2) Then
If (mode.EQ.1.AND.ntotal.EQ.<nptmax-1» Then
Print *,'
Last point, only button 2
or buttons 243 are
& a 11 o
wed'
Else1-1 + 1ntota1«ntota1+1
xl1ne<1) = x
y11ne(1)=y
Call drwpnt(x,y)
If (1.EQ.1.AND.(Iset.EQ.0.OR.Iset.EQ.1))Call
&
drwl1n(xl,yl,x,y)
If (I.GT.l)Call drwl1n(xl1ne(1-1>,yl1ne(1-1),x,y)
If (mode.EQ.2.OR.ntotal.EQ.nptmax) Then
n11ne»1
1test=l
If {Iset.EQ.0.OR.Iset.EQ.2>Call drwl1n(x,y,x2,y2)
End If
End If
CElse If
(mode.EQ.3) Then
Call hlpmou
CElse If
(mode.EQ.23) Then
nl1ne»1
1test--l
CElseCal1 errmsg
CEnd If
If (ntotal .EQ. (
nptmax-1 ) .AND. I
test.EQ.0) Then
j t\
*. Print *,1,' coordinates entered, only one more allowed*
| UQ
End If
If (1.GT.nptmax)1test=-l
If (1test.EQ.0)Go To 10
End If
CCall softky('0'>
Cal1 curoff
Return
End
C +
CC loadmou
- Loads the mouse soft key button definitions within
C the terminals key translation table.
C-
£ **************************************************************
Subroutine loadmou
Character esc*l
Cesc*char(27 >
Cal1 esccomC'CA*//esc//*Ry0107\l\2\3\4\5\6\7')
CReturn
End
C +£ *************************************************************
C loccur -
LOCate CURsor - Return world coordinates (1x0,1y0)
C of Envision cross-hair cursor.
C-C
*********************** t*************************************
Subroutine loccur(1x0,1y0)
CCall esccom(*YC'>
Read (5,20)1x0,1y0
20 Format (2z4)
CReturn
End
C +
C magmod - Writes out a MAGPOLY model using the POLYGON model
C information and user entered responses.
C-C **************************************************************
Subroutine magmod(1test)
Dimension xpoly(100),ypoly(100)
Common /topology/1nfo<100),1upper(100),Idownl100),11eft(100),
&1r1ght(100)
Common /screenloc/ntota1,nump1y(100),xscr(100,100),yscr(100,100)
Common /parameter /parm(100,10)
Common /gr1dspecs/1d,pgm,nc,nr,nz,xo,dx,yo,dy,IproJ,cm,b1
Common /orIglnal/Iwcorg,Jwcorg.nxorgp,nyorgp
Character 1dplot*40,If 1le*50,If 11e2*50,quest*80,1fmt*80,
&1d*56,pgm*8,comf11*80,ans*2,ans2*2,name*8,un1x*4,un1z*4
namel1st/parms/Iplotr,Ibody,If 11e,If 11e2,Isqs,datum,xsca1e,
&dc,un1x,uniz,name,height,Ifmt,Idplot,lobs,Icalc,1 res,naxcol
C1plotr=9
naxcol=130
1body=0
1obs=0
1calc=0
1res»0
1dplot='
'1f11e=*
'1f11e2='
'107
1sqs»0
xscale*0.
dc-0.
unlx-'kllm'
un 1z*'f eet '
name*'gr fdded*
he1ght=0.
- Ask for
name of
file containing fteldpolnt Information.
1test»lquest"' Name of
file containing fleldpotnt Information'
1val»1aquest( quest, If lie, ' (a50) * ,0)
If ( Ival .EQ.-l )Go
To 100
- Name (type of
data re*d In
from If lie).
1test»0
Do 40 wh11e( 1test.EQ.0)
quest-' Type of
data
In fteldpotnt file (enter H
for help)'
Ival" taquest( quest, name, ' (a8 ) ' , -8 )
If (named tl).EQ. 'G' )
Then
name9 'gr t
dded '
helght-0.0
Write (6,45)
45 Format (2x, '
Height of
fteldpont grid above the same datum that')
quest*'
Is used to reference the body heights'
1va1»1r quest (quest .height, ' (
e!6.8) ' ,16)
ttest-1If
( Ival .EQ.-l ) 1test»-l
Else If
(name.EQ. 'H' )
Then
Call hlpg2
Else If
( Ival. EQ.-l) Then
Itest--! Else
- Ask for
format type of
data .
1test2-0
Do 25
wh11e( ltestZ.EQ.0)
quest*' Enter format to
use when reading In
your file*
1va1*1aquest( quest, tfmt, * (a 80) ' ,0)
If ( Ival .EQ.-l >
Then
1test«-l
1test2=-l
Else If
( Ifmt.NE. '
' ) Then
ttest-1 1test2-l
ElseCal 1
errmsg
End If
25 End Do
End If
40 End Do
If ( Itest. EQ.-l )Go
To 100
- Ask for
the name of
standard grid containing the heights of
f leldpolnts .
quest*' Name of
standard grid containing heights of
fleldpolnts*
4 A Q
1val»1aquest(quest, If 1 Ie2, ' (a50) ' ,0)
*~ tVO
If ( 1
val.EQ.-l)Go To 100
cC - Ask for print out Identifier.
Cquest"* Identifier for printer output'
1 val- laquesKquest, 1 d
p lot, ' (a 40) * ,0)
If (Ival.EQ.-l>Go To 100
CC - Ask
If constant should be added to calculated anomalies.
Cltest-0
Do 20 whllelltest.EQ.0)
quest-* Add a
constant to the calculated anomalies (y/n/q)'
1 val* 1aquest(quest,ans,*(a2)',0)
CIf
(ans.EQ.'V) Then
quest-' Constant to be added*
1val»1rquest(quest.datum,Mel6.8)',16)
ltest-1
If (Ival.EQ.-l)1test--l
Else If
(ans.EQ.*Q*.OR.Ival.EQ.-l) Then
1test»-l
Else If
(ans.EQ.'N*) Then
1test-l
datum=0.0
ElseCall errmsg
End If
20 End Do
If (Itest.EQ.-l)Go To 100
CC -
Ask Isqs determination.
C1test»0
Do 30 wh(le(Itest.EQ.0)
quest"' Least-squares comparison/read observed values
& (y/n/h/q)'
1 va1 = laquest(quest,ans2,'(a2 > *,0)
CIf
(ansZ.EQ.'Y'> Then
1testZ=0
Do 35
wh11e(ItestZ.EQ.0)
lsqs-0
quest-' What value for LSQS (0-7 Integer, //
to quit)'
1val=11quest(quest,Isqs,'(12)',-2>
CIf
(Isqs.GE.0.AND.lsqs.LE.7) Then
1test2«l
1test«l
Else If
(Ival.EQ.-l) Then
ltestZ«-l
1test--l
ElseCal1 errmsg
End If
35 End Do
Else If
(ansZ.EQ.'N'> Then
lsqs=0
ltest=l
Else If
(ansZ.EQ.'H'> Then
Cal1 hlpmgl
Else If
(ansZ.EQ.'Q'.OR. Ival .
EQ.-l )
Then
ltest=-l
ElseCa11 errmsg
KILFM Then
METR') Then
KILMM Then
Q'.OR.Ival.EQ.-l) Then
End If
30 End Do
If (Itest.EQ.-l)Go To 100
CC - Ask for units In
x&y directions.
C1test-0
Do 50 whlle(Itest.EG.0)
un1x«'KILM*
quest-' Units In
x&y direction <FEET/KILF/MILE/METR/KILM/H/Q)'
Ival=(aquest(quest,un1x,'(a4)',-4)
C1test-lIf
(unlx.EG.'FEET*) Then
un1x»'feet'
Else If
(unlx.EQ.'MILE*) Then
un1x«'mile*
Else If
(unlx.EQ
unlx-'kl If
Else If
(unlx.EQ
unlx-'metr *
Else If
(unlx.EQ
unlx-'kl1m*
Else If
(unlx.EQ.'H') Then
Call hlpg3
1test*0
Else If
(unlx.EQ
1test=-l
ElseCa11 errmsg
1test-0
End If
50 End Do
If ( I
test.EQ.-l)Go To 100
CC -
Ask for units In
z direction (height).
C1test=0
Do 60 whlle(Itest.EQ.0)
unlz-'FEET*
quest*' Units In
z direction (FEET/KILF/MILE/METR/KILM/H/Q)'
1va1=laquest(quest,un1z,'(a4)',-4)
C1test=l
If (unlz.EQ.'FEET') Then
unlz-'feet*
Else If
(unlz.EQ.'MILE') Then
unlz«'mlle*
Else If
(unlz.EQ.'KILF* )
Then
unlz-'kl If
Else If
(unlz.EQ.'METR') Then
un
1z*'m
etr'
Els
e If
(u
nlz
.EQ
.'KIL
M')
Th
en
un
1z=
'k11m
*E
lse If
(u
nlz
.EQ
Call
hlp
g3
1te
st=
0E
lse
If
(un
lz.E
Qit
es
f-1
E
lseCal1 errmsg
1test=0
End If
60 End Do
H*) Then
Q*.OR.Ival.EQ.-l) Then
no
If (1test.EQ.-l)Go To 100
CC - Ask for print switch Information.
C1test-0
Do 65 whlle(Itest.EQ.0)
If lag=0
quest*' Print switch for body Information (1/0)'
1va1~11quest(quest,If 1ag, (11)',1)
CIf
( Iwal.EQ.-l) Then
1test--l
Else If
( Iflag.EQ.0.0R.Iflag.EQ.1) Then
ltest-1
ElseCal1 errmsg
End If
65 End Do
If (1test.LT.0)Go To 100
CC - Ask which parm from the parm arrays to use when creating
C
this model.
CCall askmvlHone, Itwo, 1 t
hree, If o
ur , If 1 v
e, 1s1x, 1 t
est)
If (Itest.EQ.-l)Go To 100
CC -
Ask for the name to call this MAGPOLY file (comfll)
C70 Continue
quest*' Name to call command file to run MAGPOLY'
1val»1aquest(quest,comf11,'(a80)',0)
If ( I
wal.EQ.-l)Go To 100
If (coinf 1
1.EQ. '
')Go To 70
CC - Open the model file and write out the model.
COpen (11,f1le*comf11.status*'new',carr1agecontrol *'11st*)
Write (11,nml=parms)
Call fndtop(ntop)
next*ntop
1test*0
delxcn=dx/nxorgp
delycn=dy/nyorgp
Do 150 wh1le(Itest.EQ.0)
ngon«next
npo1y«Info{ngon)
nbrpts*numply(npoly)
If (nbrpts.GT.0) Then
Do 120 1-1,nbrpts
xpoly(1)°xo+(xscr(npoly,1)-1wcorg)*delxcn
ypoly(1)»yo+(yscr(npoly,1)-Jwcorg)*delycn
120
Continue
CC -
Find the handedness of the polygon
C gamma
> 0.0
* polygon
Is counter-clockwise
C gamma
< 0.0
= polygon Is
clockwise
CCa11 tota1t(gamma,xpo1y,ypo1y,nbrpts)
CIf
(gamma.GT.0) Then
nstart»nbrpts
441
nend=l
** 111
1step=-l
Else
nstart»l
nend^nbrpts
lstep-1 End
If CC
- If
the body has
a parent, need to determine If
the parent-body/
C current body over! p.
C1up»1 u
pper(ngon)
If ( 1up.GT.J0T)
Then
nplyup*1nfo(1 up)
Cpartop»parm(nplyup,lone)
parbot»parm(nplyup,Itwo)
bodtopaparm(npoly,lone)
bodbot*parm(npoly,Itwo)
CC - We need only remove a
slab If
the parent body and current body
C overlap
In the z direction (height).
CIf
(((bodtop.LE.partop).AND.(bodbot.GE.parbot)).OR.
& ((bodtop.GT.partop).AND.(bodbot.LT.partop)).OR.
& ((bodtop.GT.parbot).AND.(bodbot.LT.parbot))) Then
CIf
{bodtop.LE.partop) Then
ztop-amlnl{bodtop,partop)
Elseztop=partop
End If
CIf
{bodbot.GE.parbot) Then
zbot-amaxl(bodbot,parbot)
Elsezbot=parbot
End If
CC - Write out the slab to be
removed.
CWrite {ll,*)nbrpts,1flag,-parm(nplyup,1 three),
&parm(nplyup,Ifour),parm(nplyup,iflve),parm(nplyup,Is1x),ztop,zbot
Write {11,*){xpoly{1),ypoly{1>,1=nstart,nend,Istep)
End If
End If
Write {11,*)
nbrpts,If lag,parm(npoly,1 three>,
& parm(npoly,1four),parm(npoly,If 1ve),parm(npoly,Isix),
& parm(npoly,lone),parm(npoly,1 two)
WrIte {11,*){xpoly(11),ypoly{11),11=nstart,nend,Istep)
End If
CC - Get next polygon
CCall
walk(next,ngon,ItestZ)
If {next.EQ.0.0R.1 test2.LE.0)
1test=l 150
End Do
Close (11)
C100
Continue
Return
End C +
C mod In
- MODel INput - Asks for
the name of
the model, clears
C the model arrays and reads
In the model.
C-
Subroutine modln(lest)
Dimension xpoly(100),ypoly(100)
Common /topology/Info(100),1 upper(100),1down(100),
&11eft(100),1r1ght(100)
Common /screenloc/ntota1,nump1y(100),xscr(100,100),yscr(100,100)
Common /box/xmlnbx(100),xmaxbx(100),ym1nbx(100),ymaxbxf100)
Common /names/grdnam,modnam,modgrd
Common /mlsc/ncol,nrow,f1r st,ntop
Common /commands/nmax,eps1 In.del 1n,del out
Common /model/mdflag
Character f 1
rst*1,modgrd*80,grdnam*80,modnam*80
C10 Continue
CC - Ask for the name of the model
CCall askmd1(modnam,1 test)
If (1test.EQ.-l.OR.1test.EQ.0)Go To 100
CC - Clear model arrays for reading
CCall Intloc
Call Inttpl
Cal1 Intnew
CC - Read In
the model
CCall readmdtItest)
If (Itest.EQ.-l)Go To 10
Cal1 oldnew
mdflag= 1
CCall fndtop(ntop)
1test=0
1«1ncount=0
Do 50 whlle(Itest.EQ.0.AND.1.GE.1.AND.1.LE.nmax)
npoly
55 Inf o( 1 >
If (npoly.GT.0) Then
nbrpts*numply(npoly)
Do 40 J*l.nbrpts
xpoly(J)=xscr(npoly,J)
ypo1y(J)=yscr(npoly,J)
40
Continue
Call fndbbx(xm1n,xmax,ym1n,ymax,xpoly,ypoly,nbrpts,del out)
xm1nbx(npoly)=xm1n
xmaxbx(npoly)*xmax
ym1nbx(npo1y)=ym1n
ymaxbx(npoly)=ymax
Call fndbpl(npoly,Itest)
1test*0
ncount=ncount+l
If (ncount.EQ.ntotal)1test=l
End If
1*1 + 1 50 End Do
C100 Continue
Return
End
C+
\*C modout -
MODel OUTput
- Asks for the name of the model and
C writes 1t
out.
C-£
Subroutine modout<Itest)
Common /names/grdnam,modnam,modgrd
Character grdnam*80,modnam*80,modgrd*80
CC -
Ask for the name of the model
CCall askmd1(modnam Itest)
If <Itest.EQ.-l.OR.Itest.EQ.0)Go To 100
CC - Write out the model
CCal1 wrtmod<Itest)
100 Continue
Return
End
C +
C modpnt -
Determines the corner number of a
polygon picked.
C-
£ *************************************************************
Subroutine modpnt(ncorn,d1st,x,y,ans,npoly,mcur)
Dimension xply<100),yply(100)
Common /screenloc/ntota1,numply(100),xscr(100,100),yscr{100,100)
Common /zoom/Izoom,Izva1,nzoom,ncm1nz< 5),ncmaxz(5),nrm1nz(5),
inrmaxz(5)
Common /commands/nmax,eps1 In,del 1n,delout
Character mcur*2,ans*2
Cnbrpts=numply(npoly)
If (nbrpts.GT.0) Then
ans='N'
Do 40 whlle(ans.EQ.'N')
Call hlpcpl
Call retpnt(x,y,mcur,1err2)
If <1err2.GE.l) Then
If (1zoom.EQ.1)Cal1 1nvers(x,y,x,y)
Do 35
k = l,nbrpts
xply(k)=xscr<npoly,k)
yply(k)
syscr(npoly,k)
35 Continue
1con=l
Cal1 clspnt(ncorn,d1st,x,y,xply,yply,nbrpts,del out,Icon)
If (ncorn.EQ.0) Then
Call wrtmsg(* Could not find corner near your
& point...try again')
Elseans-'Y'
End If
Else If
(1err2.EQ.-l) Then
ans-'O'
End If
40
End Do
ElseCall wrtmsg(' Polygon number passed to MODPNT has no corners')
ans='Q'
End If
CReturn
End C + C
114
C mouexm - MOUse Execution Mode -
Selects Execution mode for
C Envision mouse, (0=Point mode,1=Mu1tIple mode).
C-
Subroutlne mouexm(mode)
Character mode*l,com*3
Ccom**IZ'//mode
Ca11 esccom(com)
CReturn
End
[***!
C moulln - MOUse LI N
ear -
Places Envision mouse In
linear res-
C ponse mode.
C-C
Subroutine moulln
CCall esccom('IY')
CReturn
End
C + CC
mousop
- MOUse Suspend OPerattons -
Suspends mouse operation
C until linear or
logarithmic response mode Is
re-
C selected.
C-V
Subroutine mousop
CCall esccom('IX')
CReturn
End
C movcur
- Moves the graphics cross-hair cursor to world coordinates
C ( 1
x,ly).
C-Q ***************************************************************
Subroutine movcur(1x,ly)
Character wcbp*5,com*6
Ccom='P'//wcbpl1x,ly)
Ca 11 esccomt com)
CReturn
End
C +
C movply - Allows the moving of a
polygon from one location to
C another part of the screen.
C-
Subroutine movply(1 test)
Dimension parstore(10)
Common /topology/1nfo(100),1 upper(100),1down(100),
&11eft(100),1r1ght(100)
Common /screenloc/ntota 1,numply(100),xscr(100,100),yscr(100,100)
Common /parameter /parm(100,10)
Common /poly1oc/nptloc,xloc(100),yloc(100)
Common /temp/ntemp,xtempC100),ytemp(100)
Common /f lags/mcflag,votfIg
Common /Junk/ngbtop,jnktop(100),ngbloc,Jnkloc(100)
Common /zoom/Izoom,Izva 1,nzoom,ncm1nz(5),ncmaxz(5),nrm1nz(5),
Anrmaxz(5)
Common /grldspecs/ Id,pgm,nc,nr,nz,xo,dx,yo,dy,1proj,cm,bl
Common /scale/ xsc,ysc,xstart
fystart,x1n1t,y1nIt
Common /original/ 1wcorg,Jwcorg,nxorgp,nyorgp
Common /screenbnd/xleft,xrIght,ybot,ytop
Common /commands/nmax, eps11n,delIn.delout
Common /max/nptmax
Common /state/lflast,IftIn,Iftout.ndpstn,lup
Common /colors/plyclr,black,white
Common /f 111/open,sol Id,f11typ
Ch
ara
cte
r o
pen
*l , so
l IdM
,f I ltyp
*l , p
i yclr
M , b
lack*! , w
hlte
*l C
hara
cte
r 1
d*5
6,p
gm
*8,v
otflg
*2,m
cfla
g*2
,mc
ur*2
,an
s*2
,an
s2
*2
CC
all
en
hm
sg
C'***
Mo
ve
p
oly
go
n
mo
de
*** )
C
1te
st-0
CC
- Test the number of polygons ntotal, exit If
<»0.
CIf
(ntotal.GT.0) Thjn
CC -
If cursor type has not been selected prompt for type.
CIf
(mcflag.EQ.*N') Then
Call askmoc(mcur)
If (mcur.EQ.'Q') Then
1test=-l
Elsemcflag=mcur
End If
Elsemcur^mcflay
End If
CC -
Print help message
CIf
(votf Ig.EQ. 'VMCall hlpmov
CC - Start looping until polygon Is
found (1test=l), or user
C wants to quit Mtest = -
l).
CDo 10 wh11e<1test.EQ.0)
If lag=0
If (mcur.EQ.'M*.OR.mcur.EQ.*C
f) Then
CC -
Initial the temp arrary.
Ccall 1nttmp
CC -
Let user pick polygon and return npoly,ncorn,x,y.
CCall pckply(npoly,ncorn,x,y,ans,mcur,1err)
CC - Ask If
corner point of polygon picked should be used.
CIf
(ans.EQ.'Y*) Then
nbrpts=numply(npoly)
Cal1 pckpnt{ncorn,d1st,x
fy,ans2,npoly,mcur)
If <ans2.EQ.'Q') Then
1test=-l
1J6
Go To 20
End If
CC - Message about repositioning cursor to new location
CCall hlpmvZ
Call retpnt(xscnew,yscnew,mcur,lerr)
If (terr.EQ.-l) Then
1test--l
Go To 20
End If
CIf
(fzoom.EQ.1> Then
Ca11 1nvers(xnew,ynew,xscnew,yscnew)
Elsexnew»xscnew
ynew*yscnew
End If
CC -
Find the amount that polygon should be moved by (delx.dely).
Cdelx*xnew-x
dely*ynew-y
CC - Store new polygon
Cntemp^nbrpts
Do 30 1*1,ntemp
xtemp(1>=xscr(npoly,1)+delx
ytempt1>*yscr(npoly,1)+dely
30
Continue
CC - Test If
polygon will be off of unzoomed grid.
Cxlfunz-xInlt
xrgunz=x1n1t+nc*nxorgp
ybtunz=yIn It
ytpunz*y1n1t+nr*nyorgp
Call testoff(xtemp,ytemp.ntemp,xlfunz,xrgunz,ybtunz,
& ytpunz,Intotal)
If ( I
ntotal.LE.0) Then
If (Intotal.EQ.0) Call wrtmsg(* Error, polygon will
& off of unzoomed grid*)
Go To 20
End If
CC - Store the parameter InformatlIon.
CDo 35
11 = 1, 10par store(11)=parm(npo1y,11)
35 Continue
CC -
Test the new polygon In
the xtemp,ytemp array and fit Into
C the topology structure.
CCall testopo(npoly,1test2 )
If MtestZ.GE.l) Then
npoly2*Info(ndpstn)
Do 40
1 1 1=1,10
parm(npoly2,111)=parstore( 111)
40
Continue
If1ag=l
End If
1test=l
117
20
Continue
If (If l
ag.EG.0) Then
Call setclr(plyclr)
Call self 11(open)
Cal1 drwclp(xloc,yloc,npt1oc,xleft,xrIght,ybot,ytop)
End If
Else If
(ans.EQ.»N') Then
1test»0
Else1test«-l
End If
Call self 11(sol Id)
If (ierr.EQ.-l)1test»-l
Else If
(mcur.EQ.*Q*) Then
1test«-l
End If
10 End Do
ElseCall wrtmsg(*
Sorry no polygons')
1test=-l
End If
CReturn
End
C +
C movpnt - Allows the moving of Individual points of
a polygon.
C-£ *************************************************************
Subroutine movpnt(itest)
Common /topology/1nfo(100),iupper(100),idown(100),
41 left(100),1r1ght(100)
Common /screenloc/ntota1,numply(100),xscr(100,100),yscr(100,100)
Common /parameter /parm(100,10)
Common /polyloc/nptloc,xloc(100),yloc(100)
Common /temp/ntemp,xtemp(100),ytemp(100)
Common /flags/mcflag,votfIg
Common /Junk/ngbtop,jnktop(100),ngbloc,jnkloc(100)
Common /zoom/1 zoom,1zva1,nzoom,ncm1nz(5),ncmaxz(5),nrminz(5),
&nrmaxz(5)
Common /screenbnd/xleft,xrIght,ybot,ytop
Common /commands/nmax,eps1 In,delIn,del out
Common /max/nptmax
Common /colors/plyclr,black,wh ite
Common /f111/open,sol Id,f11typ
Character open*!,solid*!,f1ItypM,plyclr*1,black*!,white*!
Character votflg*2,mcflag*2,mcur*2,ans*2,ans2*2
CCall enhmsgC*** Move point mode *** )
C1test*0
CC - Test the number of polygons ntotal, exit If
<=0.
CIf
(ntotal.GT.0) Then
CC -
If cursor type has not been selected prompt for type.
CIf
(mcflag.EQ.*N*) Then
Call askmoc(mcur)
If (mcur.EG.'Q') Then
1test=-l
Else
tie
mcflagamcur
End If
Elsemcur=mcflag
End If
CC -
Print help message If
user requested verbose answers.
CIf
(votfIg.EQ.'V) Call
hlpmvp
CC - Start looping until
polygon Is
found (1test=l), or
user
C wants to
quit (1test«-l).
CDo
10 whlle(1test.EQ.0)
Iflag«0
If Iag2=0
If <mcur.EQ.'M'.OR.mcur.EQ.'C') Then
CC -
Initialize the temp arrays.
CCall
Inttmp
CC -
Find polygon, enhance and return npoly,ncorn,x,y.
CCall
pckply(npoly,ncorn,x,y,ans,mcur,lerr)
CC -
Next ask
If corner picked In
pckply (ncorn =
x,y) should be
C used.
CIf
(ans.EQ.'YM Then
nbrpts=numply(npoly)
Call pckpnt(ncorn,d1st,x,y,ans2,npoly,meur)
If <ans2.EQ.'Q') Then
1test=-l
Go To 20
End If
CC -
Now undraw the connecting lines
to ncorn.
CIf
(ncorn.EQ.l) Then
x1=xscr(npoly,nbrpts)
yls=y
scr(npoly,nbrpts)
x3=xscr(npoly,2)
y3=yscr(npoly,2)
Else If
(r-orn.EQ.nbrpts) Then
xl = xscr(npoly,nbrpts-1 )
yl=yscr(npoly,nbrpts-l )
x3*xscr{npoly,1 )
y3»yscr(npoly,1)
Elsexl»xscr(npoly,ncorn-l )
yl«syscr(npoly,ncorn-l )
x3=xscr{npoly,ncorn+1)
y3*yscr(npoly,ncorn+1)
End If
x2=xscr(npoly,ncorn)
y2=yscr npoly,ncorn)
CIf
(Izoom.EQ.1) Then
Call trans( xl ,yl ,xl ,yl )
^. 4
4 s\
Call trans(x2,y2,x2,y2)
' I
I 7
Call trans(x3,y3,x3,y3)
End If
Call setclr(black)
Call drwl1n<xl,yl,x2,y2)
Call drwl1n(x2,y2,x3,y3)
CC - Message about repositioning cursor to new location
CCall hlpmvZ
Ca11 retpnt(xscnew,yscnew,meur,Ierr2)
If (1err2.LE.-l) Then
1tesf-l
Go To 20
End If
cc -
If program Is
In zoom state unzoom the screen location,
cIf
(Izoom.EQ.1) Then
Cal1 1nvers{xnew,ynew,xscnew,yscnew)
Elsexnew*xscnew
ynewyscnew
End If
CC -
Draw the connecting lines to the new corner
CCall setclr(whlte)
Call drwl1n(x1,yl,xscnew,yscnew)
Call drwl1n(xscnew,yscnew,x3,y3)
CC - Store new polygon
Cntemp=nbrpts
Do 30 1=1,ntemp
xtemp(1)=xscr(npoly,1)
ytemp(1)=yscr{npoly,1)
30
Continue
xtemp(ncorn > = x
new
ytemp(ncorn)=ynew
CC -
Test the new polygon
In xtemp,ytemp array to see If
It Is
C self-crossing.
CCal1 selftest(1flag3,ns1del,ns1de2,xtemp,ytemp,ntemp)
If (Iflag3.EQ.-l) Then
Call wrtmsg{' Error, polygon
Is self-cross 1ng.')
IfIag2=l
Go To 20
End If
CC -
Test the new polygon
In the xtemp,ytemp array and fit Into
C the topology structure.
CCall testopo(npoly,1test2)
If (1test2 GE.0) Then
Iflag=l
ElseIfIag2=l
End If
1test=l
C20
Continue
If (Iflag.EQ.0) Then
Call setclr(plyclr )
Call setfll(open)
Call drwclp(xloc,yloc,nptloc,xleft,xrIght,ybot,ytop)
If (1flagZ.EQ.1> Then
Call setclr(black)
Call drwlln(xl,yl,xscnew,yscnew)
Call drwl1n(xscnew,yscnew,x3,y3)
CaU setclrtplyclr)
End If
End If
Else If
(ans.EQ. *NM Then
ltest«0
Else1test«-l
End If
CaU self 11 (sol fd)
If (lerr.EQ.-l)1test=-l
Else If
(mcur.EQ.'Q*) Then
ltest»-l
End If
10 End Do
Elsecall wrtmsg(' Sorry, no polygons')
1test=-l
End If
Return
End
r ***i
msgall
- Message displayed at user's terminal giving Info about
assigning values to a
polygon.
**************************************************************
Subroutine msgall
Write (6,10)
10 Format (/,'
You will now be asked to assign parameters to the
& polygon drawn In
white.',/,'
Enter a
carriage return <CR> to
& use the default answer
In brackets [].',/)
Return
End
r***<
C msgclr
- Prints message at user's terminal on first time Into
C subroutine CLRSGD (Color Standard Grid).
C-Q **************************************************************
Subroutine msgclr
CWrite (6,10)
10 Format (/,'
To draw the grid 1n
color
I first need some',
&' facts about It' )
CReturn
End
C +
C msgent -
Prints message on user's terminal on how to use the
C a
screen coordinate.
C-Q *********************** Jr***«**********************************
Subroutine msgent
CWrite (6,30)
30 Format (/,'
To enter a
polygon use the cursor keys to position',
121
A/,' the
A//,' A/,* A/, * A/,*
Return
End
cross-hairs.
Then type:
e * enter
the current
f *
finish drawing the
h »
help, repeats this
q -
quit' )
cross-hair location*
polygon (and e)',
help message*,
C +CCCC-CC +CCCC-C
msggvl
- Message explaining Information that subroutine askgvl
asks user for.
***********
Subroutine msggvl
Write (6,10)
10 Format (/,*
You will now enter the numbers of the labels*
A* assigned to the following parameters:*,/,
A/,*
(1) Height of Top of body*,
A/,*
(2) Height of
Bottom of body*,
A/,*
(3) Density Contrast of body',/)
Return
End
[***!
msglab -
Displays on the user's terminal the labels currently
assigned to the parameter arrays parm*.
Subroutine msglab
Common /labels/label
Character Iabe1<10)*15
- Display the current labels.
Call wrtmsgC* The parameter labels are:*)
Do 8
1=1,10
Write (6,12)1,label( 1 )
12 Format (*
Label ',12,*: *,a!5)
8 Continue
Return
EndC +CCCC-C
msgmol
- MeSsaGe MOuse
1 -
First help message on using the
Envision mouse.
Subroutine msgmol
Write (6,10)
10 Format (//,
A* When
holding the
mouse In
the right
hand the
A* buttons
are numbered*,/,* from
left to
right.mouse'
Button
1 Is*
C + C C C
A* actuated by the Index finger',/,' and button 3
is actuated by*
A' the ring finger.',/)
ReturnEnd
!*************** *********************************************
msgmo2
- MeSsaGe MOuse 2
- Second help message on using the
Envision mouse.
122
c- c
Subroutine msgmoZ
CWrite (6,10)
10 Format (/,'
Use the mouse to position the cross-hair cursor*,
A/,' to the desired location on the screen, then type:')
CReturn
End
C +£ *************************************************************
C msgmo3 - MeSsaGe MOuse 3
- Third help message on using the
C Envision mouse.
C-
W
Subroutine msgmo3
CWrite (6,10)
10 Format (/,'
KEY-KEYBOARD, MOUSE-MOUSE BUTTON',
&/,'
(KEY)
(MOUSE)',
&/,'
e
1 =*
Enter cross-hair cursor screen',
&* location',
&/,'
f 2
* Enter screen location and finish',
&' drawing polygon',
&/,'
(In ADD polygon mode only)',
&/,*
h 3
= Help message',
&/,'
q 2
& 3
« Quit*,/)
CReturn
End
C +
C msgmvl
- Message explaining Information that subroutine askmvl
C asks user for.
C-
£ **************************************************************
Subroutine msgmvl
CWrite (6.10)
10 Format (/,'
You will now enter the numbers of the labels',
&' assigned to the following parameters:',/,
&//,'
(1) Height of
Top of body',
&/,'
(2) Height of Bottom of body',
&/,'
(3) Volume magnetic susceptibility (emuXl00000)',
&/,'
(4) Remanent or
total volume magnetization (emuX100000)'
&,&/,'
(5) Declination of remanent or
total magnetization',
&' In
degrees, measured',/,
&* positive clockwise from the direction of the y-axls*,
&/,'
(6) Inclination of remanent or total magnetization',
&' In
degrees, measured',/,
&' positive downward from the horizontal plane',/)
CReturn
End
C+
Q **************************************************************
C msgspZ -
Prints message at user's terminal about selecting the
C corner of the polygon to start adding points from.
C-
Q **************************************************************
Subroutine msgspZ
Write (6,10)
10 Format (/,'
Now enter one of the endpolnts of this side to start*
*,&' drawing from and then',/,' enter the locatlon(s) of the',
&' pofnt(s) to be added.',/)
Return
End
C rasgspm
- MeSsaGe Single Point Mode -
Displays enhanced mess-
C age at user's terminal on entry to single point mode
C using Envision terminal.
C-
CSubroutine msgspm
CCall envbcl('l')
Write (6,10)
10 Format (/,4x,**** Enter screen location ***
')Call envbcK '0' )
CReturn
End
C +
C msgspt -
Prints message at user's terminal about selecting
C the corner of polygon to use.
C-
w
Subroutine msgspt
CWrite (6,10)
10 Format (/,'
Position the cross-hair cursor to the side of the',
&* polygon where po1nt(s)',/,* will be added and enter this*,
&' side using the mouse or keyboard keys.',/)
CReturn
End
subroutine msgstd
cwr1te(6,10)
10 format(/,' You have the option to use a prexlstlng grid',
&
* when writing out*,/,' the standard grid.',/)
creturn
end
C +
C msgstk - Message for zoom stack release.
C-
£ **************************************************************
Subroutine msgstk
CWrite (6,10)
10 Format (/,*
The zoom stack
Is full, there are several ways*,
&* to release (free)',/,' a
space In
the stack.',/)
CReturn
End
124C
msgsub -
Prints message at user's terminal about methods for
C entering the subgrld boundaries In
zoom mode.
C Called by subroutine asktyp (ASK TYPE).
C-r- **************************************************************
Subroutine msg.sub
CWrite (6,10)
10 Format (/,'
The subgrld boundaries may be entered',
&' by one of two methodss',/,
&/,'
1 *
curs r/mouse entered subgrld locations',
&/,'
2 * prompt for locations of subgrld
', &'(ncm1n,ncmax,nrm1n,nrmax)*,
A/,'
0 or
// returns to zoom command level',/)
CReturn
End
C +£ *************************************************************
C msgval
- MeSsaGe paramter
- Prints a message at the user's term-
C
Inal about selecting the paramter to use when reset-
C ting the grid.
C-
£ *************************************************************
Subroutine msgval
CWrite (6,10)
10 Format (/,'
For outputtlng the Denver standard grid, select',
&' the label number of',/,'
a set of parameters to use when',
&' resetting the grid values.',/)
CReturn
End
subroutine msgwpg
cwrite (6,10)
10
form
att/,'
Lef's
tr
y
ag
ain
to
fin
d
yo
ur
po
lyg
on
') c
retu
rne
nd
C +\*C
ncbp -
Number coordinate byte packing.
Converts a
single
C Integer number to the Envision terminal code.
C Author: Robert Slmpson.
C-
£ **************************************************************
Character*3 Function ncbp(1)
Character blank*!
Parameter (lmax-16284)
Parameter (1m1n«0)
Parameter (blank-'
' ,1blank= Ichar( '
')) C C
- Force
1 Into bounds...
11n»m1n(1max,max(Imln,1))
C -
Get hi
and lo
bytes and offset with blank...
1lo=mod(11n,64)+1b1ank
1med=1tn/64+lblank
C -
Put bytes together...
ncbp=blank//char(Imed)//char(11o)
CReturn
End
C+**************************************************************
~
I 25
\* ^**
^^
C newold
- Copies the topology structure store In
the newtopo
occcccccc-c
common blocks onto the old topology stored In
the
topology common block.
If a polygon passes a
test
we do this to store the new structuring of the polygons
**************************************************************
Subroutine newold
Common /topology/1nfo(100),1 upper(100),1down(100),
&11eft(100),1r1ght(100)
Common /newtopo/1nfnew(100),lupnewf100),1dwnew(100),
&1Ifnew(100),1rtnew(100)
Common /commands/nmax,eps1In,del In,del out
Do 10
1*1,nmax
1nfo(1)-1nfnew(1)
1 upper(1) 1upnewC1)
IdownC1)-1dwnew(1)
1left(1)-11fnew<J)
1r1ght<1)-1rtnew<1)
10 Continue
Return
End
oldnew - Copies the old topology, stored In
the common block
topology, onto the new topology stored In
the common
block newtopo.
This
Is done to restore the original
topology of the polygons, to the working topology
arrays (newtopo),
If a
polygon crosses another during
testing.
**************************************************************
Subroutine oldnew
Common /topology/Info(100),1 upper(100),1down(100),
&11eft(100),1r1ght(100)
Common /newtopo/1nfnew(100),1upnew(100),1dwnew(100),
&11fnew(100),1rtnew(100)
Common /commands/nmax,eps1 In,del In,delout
Do 10
1=1,nmax
Inf new( lupnewl 1dwnew( 1 lfnew( 1rtnew(
10 Continue
Return
End
-1nfo( 1 ) * 1 u
pper ( 1
*1down( 1 )
-11eft( 1 )
»1r 1ght( 1
C +CCCCCCCCCCCC-C
************************************************************
outcom - OUTput COMmand mode -
Driver for controlling the
output files generated by POLYGON for use by other
modeling programs (PFMAG3D, PFGRAV3D, MAGPOLY, GRAV-
POLY).
Options are:
p * Plouff/Godson format for GRAVPOLY/MAGPOLY
s * Standard grid for pfmag3d, pfgravSd,
...h
- Help
q * Quit and return to Polygon command level
i*******Subroutine outcomf1 test)
126
Character quest*80,ans*2
Call enhmsg('*** Output file mode *** )
1test*0
ierror^F
Do 10
whlleC1t«st.EQ.0)
ans«'h*
quest*' Output file mode (p/s/h/q)'
1 val* 1 a
quest(quest,ans , M
a2 ) ' ,-2 )
If (ans.EQ.'P'
.O-.ans.EQ.»p») Then
Call plfoutilerror)
Else If
(ans.EQ.*S'.OR.ans.EQ.'s') Then
Call stdoutClerror)
Else If
<ans.EQ.'H'.OR.ans.EQ.'h») Then
Call hlpout
Else If
(ans.EQ.'Q».OR.Ival.EQ.-l.OR.ans.EQ.'q') Then
1test=l
ElseCa11 errmsg
End If
If (lerror.EQ.-l) Then
Call wrtmst,*'
Error encountered*)
1error
s0itest*-!
End If
10 End Do
Return
End
»***ipckply - Allows the user to position the cross-hair cursor to
locate a
polygon, enhances the polygon
If found, and
returns the polygon & corner number, and x,y screen
coordinates (unzoomed).
Subrout tne
pckply(npoly,ncorn,x,y,ans,mcur,ttest)
Common /polyloc/nptloc,xloc(100),yloc(100)
Common /screenloc/ntota1,numply(100),xscr(100,100),yscr(100,100)
Common /topology/Info(100),1 upper(100),Idown(100),
&1left(100),1 right<100)
Common /zoom/1 zoom,1zva1,nzoom,ncmlnz(S),ncmaxz(5),nrm1nz(5),
Anrmaxz(5)
Common /screenbnd/xleft,xrIght,ybot,ytop
Common /flags/mcflag,votfIg
Common /colors/plye 1r,black,whIte
Common /f111/open,sol Id,f11typ
Character op«n*l , sol 1d*l ,f 1 I
typM , pi y
clrM, black*! , w
hite*!
Character votflg*2,mcflag*2,mcur*2,ans*2
1test=0
npoly*0
ncorn=0
- If
cursor type has not been selected prompt for type.
If (mcflag.EQ.'N') Then
Call askmoc(mcur)
If (mcur.EG.'Q') Then
1test=-l
Else
127
mcflag-mcur
End If
Elsemcur*mcflag
End If
CCall fndtop(ntop)
If (ntop.GE.l) Then
Ipoly* 1nfo( n
top)
Else1test--l
End If
CC - Start looping until polygon Is
found (ItestM), or user
C wants to quit (1test»-l).
CDo 10
whlleCltest.EQ.Jfl)
Call Intply
Call retpnt( x ,y,. .cur , lerr )
If <lerr.GE.1) Then
If (Izoom.EQ.1)Cal1 1nvers(x,y,x,y)
Cal1 tester(npoly,ncorn,Ipoly,x,y,lerr)
If (npoly.LE.0) Then
Call wrtmsg(*
Could not find your polygon...try again.')
1err=0
End If
CIf
(lerr.GT.0) Then
CC -
Enhance polygon and prompt.
CCall setclr(whlte)
Call setfll(open)
nptloc=numply(npoly)
If (Izoom.EQ.1) Then
Do 20 1=1,nptloc
Call trans(xloc(1),yloc(1),xscr(npoly,1),
& yscr(npoly,1) )
20
Continue
ElseDo 25
J=l.nptloc
xloc(J)=xscr(npoly,J)
yloc(J)=yscr(npoly,J)
25
Continue
End If
Call drwclp(xloc,yloc,nptloc,xleft.xrIght.ybot,ytop)
CC - Ask If
enhanced polygon Is
correct one.
CCall askenh(ans)
If (ans.EQ.'Y* >
Then
1test=l
ElseCall setclr(plyclr>
Cal1 drwclp(xloc,yloc,nptloc,xleft,xrIght,ybot,ytop)
If (ans.EQ.*Q') Then
npoly«0
ncorn^tf x«0.0
y=0.0
1test»-l
*.' 1 Op
End If
f ^O
End If
Call setf 1 K
sol Id)
Else If
(lerr.LT.0) Then
1test=-l
End If
Elseitest»-l
End If
10 End Do
If {Itest.EQ.-l)ans-'Q'
CReturn
End
C +£ *************************************************************
C pckpnt -
Determines the corner number of a
polygon picked.
C-r *************************************************************
Subroutine pckpnt(ncorn,d1st,x,y, ans,npoly,mcur)
Dimension xp1y(100),yply(100)
Common /screenloc/ntotal,nump1y(100),xscr(100,100),yscr(100,100)
Common /zoom/1 zoom,1zva1,nzoom,ncm1nz(5),ncmaxz(5),nrminz(5),
&nrmaxz(5)
Common /commands/nmax,eps11n,del1n,de1out
Character mcur*2,ans*2
Cnbrpts=numply(npoly)
If Cnbrpts.GE.1) Then
Cal1 askpnt(ans)
Do 40 wh11e(ans.EQ.'N' )
Call hlpcpl
Call retpnt(x,y,mcur,1err2)
If (lerrZ.GE.l) Then
If (Izoom.EQ.1 )Cal1 1nvers(x,y,x,y)
Do 35
k=l,nbrpts
xp!y(k)»xscr(npoly,k)
yply( k )**yscr ( n
poly ,k )
35
Continue
1con=l
Call dspnt(ncorn,d1st,x,y,xp1y,yp1y,nbrpts,
& delout,Icon)
If (ncorn.EQ.0) Then
Call wrtmsg(' Could not find corner near you point...
&try agaIn')Elseans»'Y'
End If
Else If
(1errZ.EQ.-l) Then
ans»'Q'
End If
40
End Do
Else
Call wrtmsg(* Polygon number passed to PCKPNT has no corners')
ans»'Q'
End If
CReturn
End
C +£
**************************************************************
C pdcom
- Driver for drawing grid on terminal and polygon draw-
C ing
mode (PLYCOM).
C-£ **************************************************************
Subroutine pdcom(ltest)
"* 1 2 9
Common /misc/ncol,nrow.fIrst,ntop,IfIrst
Common /oMglnal/lwcorg, Jwcorg , n
xorgp , n
yorgp
Common /subgrld/lcmln,Icmax,Irmln,1rmax,ncm1n,ncmax,nrm1n,nrmax
Common /scale/xsc,ysc,xstart,ystart,xlnlt,yln1t
Common /sealefacts/twc0,Jwc0,nxp1x,nyp1x,p1xdfm
Common /model/mdflag
Common /colors/plyclr,black,wh1te
Common /f
\11/open,sol Id,fI 1typ
Ch
ara
cte
r p
lyc
lrM
,bla
ck
*l,w
h\te
*1
,op
en
*1
,so
l1d
*l,f1
ltyp
*l,f1
rs
t*l
1test»l
1t«st2»l
If ( If I
rst.EQ.1) Then
Cal1 Intscr
Call clrsgcH 1,ItestZ>
If (1test2.GE.0> Then
Cal 1
clrply
1wcorg*1wc0
Jwcorg»Jwc0
nxorgp*nxp1x
nyorgp*nyp
\x Ca11 setbnd
If (mdflag.EQ.1> Then
Call setclr(plyclr)
Call self 11(open)
Call drawwalk
Call set*!1(sol Id)
End If
End If
End If
If (1test2.GE.0) Then
xstart«ncm1n
ystart=nrmln
xsc = f
loat(nxp 1 x >
yscafloat(nyp1x)
Call setbnd
Cal1 plycom(ttest)
Else1test=-l
End If
If (ntop.GT.0)mdflag=l
If (1test.GE.0)Iftrst=0
Return
End
r***l
plfout - Constructs a
Plouff/Godson GRAVPOLY/MAGPOLY model
file from a
POLYGON model.
*******************
Subroutine plfout(1 test)
Character ans*1,quest*80
1test»0
Do 10
whlle(1test.EQ.0>
ans='G
fquest*' Gravity or
Magnetic model (g/m/h/q)
I val = laquest(quest,ans,*(a2 >',-2)
If (ans.EQ.'G» >
Then
Cal 1
Else If
Call magmod(1 test)
Else If
(ans.EQ.'H*) Then
tu. 'b' ) men
grvmod(Itest)
«
1 Xf)
(ans.EQ.'M'> Then
T ^ v
Call hlpplf
Else If
(ans.EQ.'Q'.OR.Ival.EQ.-l) Then
1test=-l
ElseCall errmsg
End If
10 End Do
CReturn
End
C +Q ******************************************************* ***1
C plycom -
PoLY COMmand -
Driver for Polygon mode.
Options
C are.
CC a
C c
C d
C e
C s
C h
C q
Add a
polygon
Change polygon parameters
Delete a
polygon
Edit a
polygon, (add/delete/move) points
Special functions (copy/move/rotate)
Help
Quit and return to Polygon Command level
C C-L*
Subroutine plycomC1 test)
Character string*?,quest*80,ans*2
str1ng*'ACDESHQ'
CCall enhmsg('*** POLYGON add/change_parm/delete/ed1t_poly mode
& mode ***')
CCall clrply
Cltest-0
ans-*h'
Do 10 wh1le(ltest.EQ.0)
If lag-'P*
If ( 1f l
ag.EQ.»M» >
Then
Call wrtmsg(* Polygon add/change_parm/delete/ed1t_poly mode
& (a/c/d/e/s/h/q)')
Call getmenu(str1ng,7,ans,1error)
Elsequest=' POLYGON add/change__parm/delete/ed 1 t__poly
mode
& (a/c/d/e/s/h/q)'
1va1 = 1aquest(quest,ans,Ma2)',2)
End If
CIf
(ana.EQ.'A'.OR.ans.EQ.'a') Then
Call addply(lerror)
Else If
(ans.EQ.'C'.OR.ans.EQ.'c') Then
Call chgply(lerror)
Else If
(ans.EQ.'D'.OR.ans.EQ.'d') Then
Cal1 delply(lerror)
Else If
{ans.EQ.'E'.OR.ans.EQ.'eM Then
Cal1 edtply(lerror)
Else If
(ans.EQ.'S'.OR.ans.EQ.'s') Then
Call spfcom(lerror)
Else If
(ans.EQ.'H*.OR.ans.EQ.'h') Then
Call hlpply
Else If
(ans.EQ.'Q'.OR.1val.EQ.-l.OR.ans.EQ.*q*) Then
ltest-1
ElseCall errmsg
End If
ans ='q'
10 End Do
CReturn
End
C+
CC plytst -
PoLY TeST -
Tests whether a
given location (x,y)
Is Inside (lnout-1) or outside (1nout*0) of the poly
gon given by the arrays xpoly and ypoly.
Author: Richard 0.
Blakely, USGS, Menlo Park, CA.
Modified by Bruce A.
Chuchel, USGS, Menlo Park, CA, 2/84.
Subroutine plytst(xpoly,ypoly,nbrpts,x,y,Inout)
DImenston xpoly(nbrpts),ypoly(nbrpts)
lcount=0
1nout»0
xm1n
ssxpoly( 1)
xmax^xpoly(1)
ym1n*ypoly(1)
ymax=ypoly(1)
Do 10
J = l,nbrpts
xmax=amax1(xpoly(J), max)
xm1n*am1nl(xpoly(J),xm1n)
ymax=amaxl(ypoly(J),ymax)
ym1n*am1nl(ypoly(J),ym1n)
10 Continue
If ((x.GE.xmln.AND.x.LE.xmax).AND.(y.GE.ymln.AND.y.LE.ymax>) Then
Do 20 1-1 ,
nbrpts
lup*1+1
If (1.EQ.nbrpts)1up=l
xlmax«amaxl(xpoly(fup),xpoly(1))
xlm1nsam1nl(xpoly( 1 u
p),xpoly(1))
If (x.GE.xlmln AND.x.LT.xImax) Then
a=(ypoly(1up)-ypoly(1))/(xpoly(1up)-xpoly(1))
b=ypoly( 1 )
-a*xpoly(1)
y0*a*x+b
If (y0.GE.y)1 count*1 count*1
End If
20
Continue
1nout*mod(1count,2)
End If
Return
End
**********************************************************************
rdeblank
- Eliminates blanks at right end of
strlngl, returns
as str1ng2 with new length 12.
Author: Robert W.
Simpson, USGS, Menlo Park, CA.
****************************************
Subroutine rdeblankt str1ngl,str1ng2,12)
Character***) strIngl,str1ng2
ll=len(str1ngl)
132
Find last
non-blank character on
right
Do 10
1=11,1,-!
10 If
(str IngH 1 : 1 ) .NE. '
' )Go To 20
20 12-1str1ng2*str1ngl
Return
End
t***irdhead
- Reads
1n the header block of
a standard grid (new and
old) versions.
If an
error
1s encountered on
reading
the header an
attempt 1s
made to
read 1t
as an
old
standard grId.
1test B
Flag for
type of
grid header read.
« 1
B New version of
standard (with proj,...)
» 0
* Old version of
standard (without proj,...)
- -1*
Error encountered, not a
recognizable header
Author: Robert Slmpson
»*******************!
Subroutine rdhead(unit,Id,pgm,ncol,nrow.nz,
&xo,dx,yo,dy,1proJ,cm,bl,1 test)
Character 1d*56,pgm*8
Integer unit
Read (unIt,err=20)Id,pgm,ncol,nrow,nz,xo,dx,yo,dy,1proJ,cm,b1
print '(Ih0,a,12,2(a,f10.4))',
& '
Proj-',IproJ,'
cm-',cm,*
bl=',bl
1test«l Return
20 Continue
Rewind unit
Read (unit,err=30)1d,pgm,ncol,nrow,nz,xo,dx,yo,dy
print '(Ih0,a)',
' Grid has
no projection specs
1n header...
1proJ=0
cm«0.0
bl=0.0
1test*0
Return
30 Continue
Write (6,35)
35 Format (/,'
Error encountered on
reading grid header',/)
1test=-l
Return
End
readmd
- READ MoDel
- Reads In
a Polygon model file.
*************************
Subroutine readmd(1 test)
Common /topology/1nfo(100),1 upper(100),1down(100),
&1left(100),1r1ght(100)
Common /screenloc/ntota1,numply(100),xscr(100,100),yscr(100,100)
Common /parameter /parm( 100, 10)
1 "2 "7
Common
/ label s/label
"~ { j j
Common /Junk/ngbtop,Jnktopt100),ngbloc,Jnkloc(100)
Common /names/grdnam,modnam,modgrd
Common /commands/nmax,eps11n,del 1n,del out
Common /grIdspecs/1d,pgm,nc,nr
tnz,xo,dx,yo,dy,1proj,cm,bl
Common /original/Iwcorg,Jwcorg,nxorgp,nyorgp
Character label(10)M5
Character 1d*56,pgm*8,grdnam*80,modnam*80,modgrd*80
Open <10,f1le»modnam,status='old',form=*formatted*,
&carr1agecontrol«*1 1st*,err = 1
00)
- Read
In the number of polygons In
the model
Read (10,10)ntotal
10 Format <x, 13)
Read <10,20)(label(kk),kk=1,5)
Read (10,20)(label(kk),kk=6,10)
20 Format (5(x,al5) )
- Read In
the polygon number, the number of points
In this
polygon, the screen locations and the polygon parms.
xcndel=nxorgp/dx
ycndel=nyorgp/dy
1count=
1Do 60 whlle«Icount.GE.1).AND.( 1 c
ount.LE.ntota1)
&.AND.(1 count.LE.nmax))
Read (10,33)npoly,nbrpts
33
Format (2(x,13»
Read (10,35)(parm(npoly,1),1=1,5)
Read (10,35)(parm(npoly,1),1=6,10)
35
Format (5<x,el5.8>>
numply(npoly)=nbrpts
Do 40
J = l,nbrpts
Read <10,45)xgrId,ygrId
45
Format (2(x,el6.8))
xscr(npoly,j)=1wcorg+((xgr1d-xo)*xcndel)
yscr(npoly,J)=Jwcorg+((ygrId-yo)*ycndel)
40
Continue
1 count*1count+1
60 Continue
- find garbage locations
kh1t=0
ngbloc=0
Do 50 1=nmax,1,-1
nloc=numply{1)
If (nloc.GT.0.AND.kh1t.EQ.0) Then
kh1t=l
Else If
(nloc.LE.0.AND.kh1t.EQ.1) Then
ngbloc*ngbloc+l
Jnkloc(ngbloc)-1
End If
50 Continue
- Now read In
the topology structure
ndpstn=1
Do 70
k=l,nmax
Read (10,65) 1nfo(k),lupper(k),1down(k),1left(k),1r1ght(k)
65 Format (5(x,13)>
**> "j
~< A
70 Continue
; -
Find the garbage topology locations.
nh1t«0
ngbtop^JfrDo 80 J=nmax,l,-l
1nf=1nfo(J)If
(Inf.GT.0.AND.nh1t.EQ.0) Then
nh1t»l
Else If
(Inf.LE.0.AND.nh1t.EQ.1) Then
ngbtop=ngbtop+1
Jnktop(ngbtop)«J
End If
80 Continue
n
Close (10)
1test»l
Return
100 Continue
Close (10)
1test«-l
Return
End
t***i:
REDGRD
- REaD GRId
- Reads In
a standard grid
r_
Subroutine redgrd(name,Itest)
Common /gr1d/grd(250000)
Common /grIdspecs/Id,pgm,nc,nr,nz,xo,dx,yo,dy,1proJ,cm,b1
Character name*80,1d*56,pgm*8
C1test«lOpen (10,f1le*name,status='old*,form='unformatted',err»100)
Ca 11
rdhead(10,1d,pgm,nc,nr,nz,xo,dx,yo,dy,IproJ,cm,b1,Itest)
If (Itest.GE.0) Then
Do 20 J=l,nr
Read (10,End »20)dummy,(grd(1+(J-l)*nc),1-1,nc)
20
Continue
End If
Close (10)
Return
C100 Continue
Close (10)
1test=-lReturn
End O£ *************************************************************
C redwrk
- Reads In
a standard
grid to
the work
array, called
C by
subroutine stdout
(STANDARD OUT).
C-L*
Subroutine redwrk(name,Itest)
Common /work/wrkgrd(250000)
Common /gr1dspecs2/1d2,pgm2,nc2,nr2,nz2,xo2,dx2,yo2,dy2,
&1proJ2,cm2,bl2
Character name*80,1d2*56,pgm2*8
C1test=l
135
Open (10,f1le*name,status*'old *,form*'unformatted *,err=100)
Cal1 rdhead(10,IdZ,pgm2,ncZ,nr2,nz2,xo2,dx2,yoZ,dy2,1proJZ,cm2,
Abl2,Itest)
If (Itest.GE.0) Then
Do 20 J=l,nr2
Read (10,End »20)dummy,(wrkgrd(1+(J-1)*nc2>,1=1,nc2)
20
Continue
End If
Close (10)
Return
C100 Continue
Close (10)
1test*-l
Return
End C+C
retpnt - RETurn PoINt -
Returns the current Envision cross-
C hair screen location (x,y),
depending on
whether the
C mouse of
cross-hair cursor keys were selected.
CC mcur
= 'm'
« Mouse Is
selected
C 'c'
= Cursor keys selected
CC-
Subrout1ne retpnt(x,y,mcur,Itest)
Character ans*l,mcur*2
CIf
(Itest.eq.3) Call
msgspm
CC -
If mouse was selected enable mouse and read In
point.
CIf
(mcur.EQ.'M') Then
Call softky('l')
If ( I
test.eq.3.or.Itest.eq.2) then
Call setmou
Call loadmou
End If
Cal1 curon
1test*0
If (Itest.EQ.0) Then
20
Continue
Call getmou(mode,1x,1y)
x=float(1x)
y=float(1y)
If (mode.EQ.l) Then
Call drwpnt(x.y)
ltest-1Else If
(mode.EQ.2) Then
Call drwpnt(x,y)
1test»2
Else If
(mode.EQ.23) Then
1test=-l
Else If
(mode.EQ.3) Then
Call hlpmpt
ElseCall wrtmsgl' Mouse button not def1ned...try again*)
End If
If (Itest.EQ.0)Go To
20 End If
Cal 1 curoff
Call softkyCff*)
- Else If
cursor was selected, enable the cross-hair cursors
and read In
point.
Else If
(incur .EG. *C* ) Then
Cal1 curon
1test=0
If (1test.EQ.0> Then
30 Continue
Call gtpnt(ans,x,y)
If tans.EG.*e') Then
Call drwpnt(x,y)
1test-l
Else If
(ans.EQ.'f) Then
Ca11 drwpnt(x,y)
1test=2
Else If
(ans.EQ.'h') Then
Call hlpcur
Else If
(ans.EQ.'q') Then
1test=-l
End If
If (1test.EQ.0)Go To
30
End If
Call curoff
End If
100 Continue
Return
End
**************************************************************
rotate
- Rotates the point xold.yold about the origin xorlgn,
yorlgn by the angle theta.
Subroutine rotated xnew,ynew,xold,yold,xor1gn,yorIgn,theta)
p1=3.14159265
delx=xold-xor1gn
de1y=yold-yorIgn
r1en=sqrt<delx**2+dely**2)
If (rlen.LT.1.0e-16)rlen=1.0e-16
?i1phacas1n{abs(delx/rlen) )
alpha-180.0*alpha/p1
If (dely.GE.0.0) Then
If <delx.LT.0.0)alpha=-alpha
ElseIf
(delx.GT.0.0) Then
a1pha-180.0-alpha
Elsea 1pha =a1p ha +
180.0
End If
End If
alpha=90.0-alpha
If (alpha.LT.0.0)alpha=360.0+amod{alpha,360.0)
xnew*r len*cos( (theta-t-a 1 p
ha )*p1/180.0)+xor1gn
ynew=rIen*s1n((theta+alpha)*p1/180.0)+yorIgn
Return
End137
*** *****!
I****************************
C rotply - Allows a polygon to be rotated about a
selected origin
C by the amount theta.
C-CSubroutine rotply(1 test)
Dimension parstore(10)
Common /topology/1nfo(100),1 upper(100),1down(100),
&11eft<100>,1r1ght<100)
Common /screenloc/ntota1,numply(100),xscr(100,100),yscr(100,100)
Common /parameter /parm(100,10)
Common /polyloc/nptloc,xloc(100),yloc(100)
Common /temp/ntemp,xtemp(100),ytemp(100)
Common /flags/mcflag,votfIg
Common /Junk/ngbtop,jnktop(100),ngbloc,Jnkloc(100)
Common /zoom/1 zoom,Izval,nzoom,ncm1nz(5),ncmaxz(5),nrmlnzl5),
&nrmaxz(5)
Common /grldspecs/ Id,pgm,nc,nr,nz,xo.dx,yo,dy,IproJ,cm,bl
Common /scale/ xsc,ysc,xstart,ystart,xIn It,yIn 11
Common /original/ Iwcorg,Jwcorg,nxorgp,nyorgp
Common /screenbnd/xleft,xrIght,ybot,ytop
Common /state/If last,Iftln,1 ftout,ndpstn,lup
Common /commands/nmax,eps1In,del In,delout.
Common /max/nptmax
Common /colors/plyclr,black,whIte
Common /f111/open,sol Id,f11typ
Character open*!,solIdM,f1ItypM,plycIr*1,black*1,wh1te*l
Character votflg*2,quest*80,mcflag*2,mcur*2,ans*2,ans2*2
Character Id*56,pgm*8,ans3*2,ans4*2,use*2
CCall enhmsg('*** Rotate polygon mode ***')
C1test-0
CC -
Test the number of polygons ntotal, exit If
<=0.
CIf
(ntotal.GT.0) Then
CC -
If cursor type has not been selected prompt for type.
CIf
(mcflag.EQ.'N') Then
Call askmoc(mcur)
If (mcur.EQ.'Q') Then
1test=-l
Elsemcflag*mcur
End If
Elsemcur=mcflag
End If
CC -
Print help message
CIf
(votfIg.EQ.*V*)Ca11 hlprot
CC - Start looping until polygon
Is found (1test=l), or
user
C wants to quit (1test=-l).
CDo 10
whlle(1test.EQ.0)
Iflag=0
If (mcur.EQ.'M'.OR.mcur.EQ.'C') Then
use='N'
C C -
Initialize the temp arrays.
138
Cal1 Inttmp
- Let user pick polygon, and return npoly,ncorn,x,y.
Cal1 pckply(npoly,ncorn,x,y,ans,mcur,1err)
- Ask If
corner of polygon picked should be used
:If
(ans.EQ.'Y'> Then
nbrpts»numply(npoly)
Call askrot(ansZ)
If (ansZ.EQ.'Y') Then
x0»xscr(npoly,ncorn)
y0*yscr(npoly,ncorn)
use-'Y'
Else If
(ansZ.EQ.'N*> Then
:E - Message about repositioning cursor to new location
^
Call askrt2(ans3)
If (ans3.EQ.'Y') Then
Cal1 modpnt(ncorn,d1st,x,y,ans4, npoly,meur)
If (ans4.EQ.'Y') Then
x0=xscr(npoly,ncorn)
y0=yscr(npoly,ncorn)
use*'Y'
Else1test=-2
End If
Else If
(ans3.EQ.*N*) Then
Call hlprtZ
Call retpnt(xscnew,yscnew,mcur,lerr)
If (lerr.GE.0) Then
If (Izoom.EQ.l) Then
Call 1nvers(xnew,ynew,xscnew,yscnew)
Elsexnew-xscnew
ynew=yscnew
End If
x0=xnew
y0»ynew
Else1test=-l
End If
Else If
(ans3.EQ.*Q*) Then
1test=-2
End If
Else If
(ansZ.EQ.'Q') Then
1test--2
End If
If (1test.LE.-l)Go To 20
:C -
User enters rotation angle In
degrees counter-clockwise.
:1test4>0
Do 45
wh11e<1test4.EQ.0)
Write (6,48)
48 Format (/,
4
' You will now enter the rotation angle for',
& * this polygon, measured',/,'
In degrees
', &
' counter-clockwise.',/)
theta=0.0
quest** Rotation angle'
1val=1rquest(quest,theta,'(e!6.8)',0)
If {Ival.EQ.-l) Then
1test4--2
1test*-2
Else1test4-l
End If
45 End
DoIf
(1test.LE.-l)Go To 20
- Rotate polygon and store.
ntemp*nbrpts
Do 30
1*1,ntemp
If (use.EQ.'Y'.AND.1.EQ.ncorn) Then
xtemp(I)*xscr{npoly,ncorn)
ytemp{1)*yscr{npoly,ncorn)
ElseCal1
rotate(xtemp(1),ytemp{1),xscr(npoly,1),
& yscr(npoly,1),x0,y0,theta)
End If
30
Continue
- Test the polygon to see If
It has
been rotated completely off
the unzoomed screen.
xlfunz*x1nIt
xrgunz*x1n1t+nc*nxorgp
ybtunzsy1n1t
ytpunz*y1n1t+nr*nyorgp
Call testoff(xtemp,ytemp,ntemp,xlfunz,xrgunz,ybtunz,
& ytpunz,1ntota1)
If (Intotal.LE.0) Then
If {Intotal.EQ.0) Call
wrtmsg{' Error, polygon will be
& rotated off of
unzoomed screen')
Go To 20
End If
- Store the polygon parameters.
Do 25
1 1 = 1 , 10parstore(11)=parm(npoly,11)
25 Continue
- Test the new polygon In
the xtemp,ytemp array and fit Into
the topology structure.
Call testopo(npoly,1test2)
If (ltest2.GE.l) Then
npoly2*1nfo(ndpstn)
Do 35
11 1 = 1 , 10parm(npoly2, 1 1 1 )**parstore( 1 1 1 )
35 Continue
Iflag-1 End
If 1test=l
20
Continue
If (Iflag.EQ.0) Then
Call setclr(plyclr)
Call self 1
1(open)
Call drwclp(xloc,yloc,nptloc,xleft,xr1ght,ybot,ytop)
-» 4
A r\ End
If f
*f U
Else If
(ans.EQ.'N') Then
1test=0
Else1test=-l
End If
Call setf11(sol1d)
If ( l
err.EQ.-l)1test»-l
Else If
(mcur.EQ.'Q*) Then
1test=-l
End If
10 End Do
ElseCall wrtmsgl'
Sorry, no polygons')
1test«-l
End If
CReturn
rstply - ReSeT PoLY - Resets grid locations In
wrkgrd under
control of irst.
If 1rst=l, resets grid points
within polygon xtmp,ytmp;
If 1rst=0, resets grid
points outside of polygon xpoly, ypoly.
i**************************************
Sub rout Ine
rstplyl xpoly , y
poly , n
brpts , n c
m In, n
cmax, nrmln, nr m
ax,
Anc ,nr,rstval , 1rst, 1 t
est )
D tmens Ion
xpoly ( n
brpts ) , y
poly ( n
brpts )
Common /work/wr kgrdl 250000)
If < (
nrmln.LE. nrmax) .AND. (
nrmln.GE. 1 .
AND . n
rmln . LE . nr ) .
AND .
&( nrmax .GE . l
.AND.nrmax.LE.nr) )
Then
1test«l
ElsePrint *,'
Error
In nrmln and nrmax'
Print *,'
nrm 1 n
= ' , n
rm 1 n , '
nrmax= ', n
rmax
1test=-l
End If
If ( (
ncmIn.LE. ncmax) .AND. (
ncmln.GE. 1 . A
ND . n
cmin . LE . nc ) .
AND.
&(ncmax.GE. 1 .
AND .ncmax.LE.nc ) )
Then
1test=l
ElsePrint *,'
Error
In ncmin and ncmax'
Print *,'
ncml n« ' , n
cm 1 n , '
ncmax= *, n
cmax
1test=-l
End If
If ( I
test. EQ.-l )Go To 50
1nout=l
Do 50 J=nrm1 n , n
rmax
Do 50
1 =ncm1n , n
cmax
Call plytstl xpoly , y
poly , n
brpts , x 1 ,y1 , I
nout)
If ( I
nout. EG. Irst)
Then
wrkgrd( 1+( J-l )
*nc )=rstval
End If
50 Continue
Return
End
141
- Scales grid to fill screen...
Screen 1s
(4151x3120)
In world coordinates we »
(1wc,Jwc).
A pixel here Is
a box around
1 we point =
smallest possible box.
A box Is
an (nxplx X
nyp1x) set of
pixels.
Define area of
screen for drawing...
**************************************************************
Subroutine seaIeg2sc(If lag)
Character esc*l,wcbp*5,1d*56,pgm*8
Parameter (esc»char(27))
Common /scale/ xsc,ysc,xstart.ystart,xInlt,yInlt
Common /subscreen/ xscrn(2),yscrn(2),xgrd(2),ygrd(2)
Common /grIdspecs/fd,pgm,ncol,nrow,nz,xo,dx,yo,dy
Common /scalefacts/1wc0,jwc0,nxp1x,nyp1x,p1xd1m
Common /subgrId/1cmIn,Icmax,Irmln,1rmax,ncm1n,ncmax,nrm1n,nrmax
1wcm1n*n1nt(x1n1t)
Jwcm1n»n1nt(yInlt)
Iwcmax^n1nt(xscrni2))
Jwcmax*n1nt(yscrn(2)>
ncd Iff*ncmax-ncm1n+1
nrd1ff
enrmax-nrm1n+l
: - Width and ht of grid
In grid units (usually km)...
If (ncdlff.EQ.0)ncd1ff=l
If (nrdlff.EQ.0)nrd1ff=1
Wldth=ncd1ff*dx
ht«nrd1ff*dy
C -
Dimension of
allowed screen area
In pixels...
1scr«Iwcmax-Iwcmln*1
Jscr=Jwcmax-Jwcmln*1
C - Get scale factors (km/pixel) for both x
and y directions...
C Choose that factor (the bigger) which will Just fit grid to screen
p1xd1msmax(width/real(1scr),ht/real(Jscr))
nxtotp1x*w1dth/p1xd1m
nytotp1x=ht/pIxdlm
1 -
Find pixel dimensions of a
box by roundlng...
nxp1x-n1nt((wldth/p1xd1m)/rea1(ncdIff))
nyp1x«n1nt<(ht/pIxd1m)/rea1<nrdIff))
; - Check result against screen size...If too big cut back by 1...
200 Continue
If <nxp1x*ncd1ff.GT.Iscr) Then
nxp 1 x = n
xp1x-1
Go To 200
End If
»
210 Continue
If <nyp1x*nrd1ff.GT.Jscr) Then
nyp1x=nyp1x-l
Go To 210
End If
Z - Check final scaling...
wbyh=real(nxp1x*ncd1ff)/real(nyp1x*nrd1ff)
wbyhtrue*w1dth/ht
fracerr=(wbyh-wbyhtrue)/wbyhtrue
: If
{ Iflag.EQ.1) Then
: Print *,'
I
Print *,'
x vs.
y scale distortion =',fracerr
* ,wbyh,wbyhtrue
*"* 4
A :
End If
/ 4P
If (abstfracerr.GT.0.05)) Then
c
Print *,'WARNING...grid ht vs.
width distorted by ',fracerr
Print *,'
Grid will probably scale better If
It Is
coarser...'
End If
CC -
Center of first box, and origin of grid coordinate system...
C (a
box 1s
centered on each grid point)
C1wc0«1wcm1n+nxp1x/2
Jwc0»Jwcm1n+nyp1x/2
C If
(1flag.EQ.l) Then
C Print *,'
' C
Print *,
C &
'ncol,nrow,nxtotp1x,nytotp1x,nxp1x,nyp1x'
C Print *,
C &
ncol,nrow,nxtotp1x,nytotp1x,nxp1x,nyp1x
C End If
CReturn
End
C +£ *********************************************************************
C scalen -
Determines the scaling factors XSC,YSC for a
(sub)grld.
C-£
*********************************************************************
Subroutine scalen
Common /scale/xsc,ysc,xstart,ystart,xIn It,yIn It
Common /subgrld/lcmln,Icmax,Irmln,1rmax,ncm1n,ncmax,nrm1n,nrmax
Common /sealefacts/1wc0,Jwc0,nxp1x,nyp1x,pIxdlm
CXSCB0.0
ysc«0.0
CIf
(( ncmax-ncmln ).GT.l )xsc=l.J0*nxp1x
If ((nrmax-nrmln),GT.1)ysc»1.0*nyp1x
CReturn
End
C +WC
selftest -
Tests whether a
polygon Is
self-cross Ing
(self-
C reentrant).
Test by comparing the sides
In pairs for
C crossing.
Subroutine exits Immediately on finding
C the first pair of sides (NSIDE1,NSIDE2 )
that do cross.
CC FORM.
CC CALL SELFTESTUFLAG,NSIDE1,NSIDE2,XPOLY,YPOLY,NBRPTS)
CC Iflag *
Flag Indicating whether a
polygon Is
self-
C crossing or not.
C *
1 -
polygon Is
NOT self-crossing
C »
0 - polygon passed has three corners or less.
C «-l
- polygon is
self-crossing.
CC nsldel,ns1de2 » Sides of polygon that cross; returned nonzero
C when 1flag--l.
NSIDE1
Is defined as the line
C segment joining the corner point xpo1y(nsIdel),
C ypoly(nsIdel) to xpoly(nsIdel+1),ypoly(nsIdel+1).
CC xpoly,ypoly » Array containing corner points of polygon
C nbrpts *
Number of corner points
In polygon xpoly,ypoly
*""" I 4 6
C ^
C Author: Bruce A.
Chuchel, USGS, Men 1o
Park, CA., 1/85.
Subroutine selftest{iflag.nsidel,ns ide2,xpoly,ypoly.nbrpts)
DImension xpoly(nbrpts),ypoly(nbrpts)
- Test to see if
the polygon passed to SELFTEST has
the minimum
number of
points (4).
If {nbrpts.GE.4) Then
- Loop through sides and test for
crossing.
1 lowl
Do 20
i«3,nbrpts
If {i.EQ.nbrpts) Then
xl*Bxpoly( nbrpts)
y 1 =ypoly{nbrpts)
x2»xpoly(1)
y2»ypo1y(1)
ilow«2 Elsex1*xpoly(i)
yl*ypoly{i)
x2=xpo1y(i + 1 )
*y2=ypoly(1 + 1 )
End If
- Inner
loop points to
only those sides in
the polygon that
are before side
i, and are not adjacent to it.
Do 20
J-ilow,i-2
If (J.EO.nbrpts) Then
xtl=xpoly{nbrpts)
ytl*ypo1y{nbrpts)
xt2=xpoly{1)
yt2=ypoly{1i
Elsextl»xpoly(J)
ytl=ypoly(J)
xt2=xpoly(3+1>
yt2=ypoly{J+l)
End If
- Test corner points of
individual line segments
i and
J for
crossing.
Call tstseg(ncross,xl,yl,x2,y2,xtl,ytl,xt2,yt2)
- If
line segments cross then, set
if lag, nslde*, and exit.
If (ncross.EQ.1) Then
if lag--lns idel*1nside2«J
Go To 100
End If
20
Continue
iflag=l ns1del=0
nside2=0
Elseiflag=0
ns1del=0
4 .
nside2=0
~
j 44
End If
Continue
Return
End
r***i
setbnd - Sets up
the screen boundary common block (xleft,xrIght,
ybot,ytop ).
t**********Subroutine setbnd
Common /sca1e/xsc,ysc,xstart,ystart,x1n1t,y1n1t
Common /screenbnd/xleft,xrIght,ybot,ytop
Common /orIglnal/Iwcorg,Jwcorg.nxorgp,nyorgp
Common /grIdspecs/1d,pgm,nc,nr,nz,xo,dx,yo,dy,iproJ,cm,b1
Common /zoom/tzoom,Izval,nzoom,ncminz(5),ncmaxz(5),nrm1nz(5),
&nrmaxz(5)
Common /sealefacts/1wc0,JwcJfl.nxp1x,nyp1x,p txdlm
Common /subgrld/tcmln,1cmax,trmln,1rmax,ncm1n,ncmax,nrm1n,nrmax
Character 1d*56,pgm*8
xleffxlnlt
ybotayIn It
If (Izoom.EQ.1) Then
xr1ght=(ncmax-ncm1n+l)*nxp1x+x1n1t
ytop*(nrmax-nrm1n-«-l )*nyp1x+y1n1t
Elsexr1ght*nc*nxorgp+x1n1t
ytop*nr*nyorgp + > 'nit
End If
Return
End
!***!
setclr -
Sets the graphics foreground color.
See setclr.lnf
or Envision reference manual for parameters.
t******************:
Subroutine setc1r(color>
Character com*2,
com*'C'//color
Ca11 esccom(com)
Return
End
!***)
setdlm -
Sets the drawing logic mode on
the Envision.
See the
Envision reference manual or
setdlm.Inf for
details.
t*****************Subroutine setdlm(mode)
Character mode*l,com*2
com='L'//mode
Call esccom(com)
Return
End
1 A r-
\ 45
£ *************************************************************
C -
setfll
- SET FIL1
- Select the fill pattern.
C-£ *************************************************************
Su
bro
utin
e setflK
flll)
Ch
ara
cte
r f1
11
*l,co
m*3
C
co
m**O
H'//f1
11
Call esccom(com)
CReturn
End
C +£ *************************************************************
C setgrd
- Walks the tree starting at the root node and sets
C the grid.
C-£ *************************************************************
Subroutine setgrdlIval,Itest)
Dimension xpoly<100),ypoly(100)
Common /subscreen/xscrn(2),yscrn(2),xgrd(2),ygrd(2)
Common /topology/1nfo(100),1 upper(100),1down(100),1left(100),
&1r1ght(100)
Common /screenloc/ntotal,numply(100),xscr(100,100),yscr(100,100)
Common /grldspecs/ld,pgm,nc,nr,nz,xo,dx,yo,dy,1proj,cm,bl
Common /box/xm1nbx(100),xmaxbx(100),ymlnbx(100),ymaxbx(100)
Common /max/nptmax
Common /parameter /parm(100,10)
Common /work/wrkgrd(250000)
Common /scale/xsc.ysc,xstart,ystart,xlnIt,yInlt
Common /scalefacts/1wc0,Jwc0,nxp1x,nyp1x,p1xd1m
Common /orIglnal/1weorg,Jwcorg,nxorgp,nyorgp
CCharacter 1d*56,pgm*8
CCall fndtop(ntop)
If (ntop.GE.l) Then
C 4?.
next*ntop
rstval=0.0
1test=0
CDo S
J=l,nptmax
xpoly(J)-0.0
ypoly(J)=0.0
5 Continue
Crscxsc«0.0
rscysc*0.0
If (abs(xsc).GT.l.e-16)rscxsc«1.0/xsc
If (abs(ysc).GT.1.e-16)rscysc=l.0/ysc
CDo 10
while!Itest.EQ.0.AND.next.GT.0)
ngon*next
npoly=1nfo(ngon)
nbrpts»numply(npoly)
If (nbrpts.GE.1) Then
Do 30
1 = 1 .nbrpts
xpoly(1)=xstart+(xscr(npoly,1)-1wcorg)*rscxsc
ypoly(1)«ystart+(yscr(npoly,1)-Jwcorg)*rscysc
30
Continue
Crstval =parm( npoly, Iva 1 )
>-» | A £
C -
Call up
the bounding box and translate these coordinates Into
C subgrld locations {ncmln,ncmax,nrmln,nrmax).
Cxgrd{l>=0.0
xgrd(2>=0.0
ygrd(1)-0.0
ygrd{2)-0.0
Cxscrn(1)=xm1nbx(npoly)
xscrn(2 )»xmaxbx{npoly)
yscrn(1)»ym1nbx{npoly)
yscrn(2)=ymaxbx{npoly)
CDo 35
J-l ,2xgrd(J)"xstart+{xscrn(J)-1wcorg)*rscxsc
ygrd(J)«ystart+{yscrn{J)-Jwcorg)*rscysc
35
Continue
Cncm1n=11nt(xgrdf 1 ) )
ncmax* t f
nt(xgrd(2 ) ) + l
nrm1n=11nt(ygrd(1 ) )
nrmax=11nt(ygrd{2))+l
If (ncmln.LT.1)ncm1n=1
If (ncmax.GT.nc)ncmax=nc
If (nrmln.LT.1)nrmln=1
If (nrmax.GT.nr)nrmax=nr
C C1rst»l
Call rstply(xpoly,ypoly.nbrpts,ncmln,ncmax,nrmln,nrmax,
&
nc,nr.rstval,1rst,If lag)
CEnd If
Call walk(next,ngon,1test2)
If (next.EQ.J0f.OR. 1
test2.EQ.0) ItestM
If (1test2.EQ.-l)1test=-l
10 End Do
End If
CReturn
End
c+r; *************************************************************
CC setkam - SET Key Application Mode - Sets the Envision term-
C fnal
up In
ke
pad application mode.
CC-£ *************************************************************
Subroutine setkam
CCall esccomC' ')
CReturn
End
C +£ *************************************************************
C -
setlln -
SET LINe -Select the line style.
C-
£ *************************************************************
Subroutine setlln(llne)
'.naracter 11ne*l,com*2
^. »
A -y
com='T'//1Ine
Call esccom(com)
C +CCCCC-C
Return
End
i*************************************************************
setmou -
Sets up the mouse soft key button definitions, called
by subroutine getmou (GET MOUSE).
Author: Robert W.
Slmpson
i*************************************************************
Subroutine setmou
Character esc*l,alphup*8, aIphoff*8,alphon*3
Parameter (esc«char(27 ) )
Parameter (aIphup*'\<'//esc//*[A *//'V
s?')Parameter (aIphoff«'\<'//esc//'a0'//'\~?')
Parameter (alphon»esc//'a2*)
'RDM*'//alphoff//alphup//'
3\_\*
'RD\2*'//alphoff//alphup//'
2\_\'
'RD\3*'//alphoff//alphup//' 23\_\'
'RD\4*'//alphoff//alphup//'
1\_V
'RD\5*'//alphoff//alphup//' 13\_V
RD\6*'//alphoff//alphup//' 12\_V
'RD\7*'//alphoff//alphup//'123\_\'
CalCalCalCalCalCal
esc com (
esc com (
esccom(
esccom(
esccom(
esccom(
Cal 1 esccom(
tA'//esc//
CA'//esc//
CA'//esc//
[A'//esc//
[A'//esc//
[A'//esc//
[A'//esc//
Return
End
*************************************************************
settpl
- Sets the pointers
In the newtopo arrays for the case
when there are multiple polygons, both Inside and
outside of
npoly, at the same level
In the tree.
In - Array containing node positions of all
the polygons
contained In
npoly.
Jout - Array of node positions of all
those polygons
not contained In
npoly, but at the same
level
In the tree as npoly; Jout
Is constructed
If an element
In the IN
array exists.
Iftln -
Node position of first polygon In
IN array that
polygon npoly contains.
Iftout -
The left most node
*************************************************************
Subroutine settpl(npoly)
Common /newtopo/Infnew(100),1upnew(100),1dwnew(100),
&1Ifnew(100)
,1rtnew(100)
Common /neighbors/lent,In(100),Jcnt,Jout(100)
Common /state/If last,Iftln,Iftout, ndpstn,lup
* Start by moving the left and right pointers of all
the
"neighbors" of npoly In
the tree.
If (Jcnt.GT.0) Then
If (If l
ast.eq.0.and.iup.gt.0)
Do 35
J=l ,Jcnt
If (J.EQ.l) Then
1lfnew(Iftout)*If last
Else1lfnew(Jout(J))»Jout(J-l )
1dwnew(1up)=lftout
148
End If
CIf
IJ.EQ.Jcnt) Then
1rtnew(Jout(Jcnt))*ndpstn
1 Ifnew(ndpstn) JoutlJcnt)
Else1rtnew(JoutlJ)>-JoutlJ+l )
End If
35 Continue
11fnew(ndpstn)«Jout(Jcnt)
If I I
flast.gt.0) Irtnewllflast) = l
ftout
Else If
ljcnt.eq.0) Then
1 Ifnew(ndpstn)*If last
If (Iflast.gt.0) IrtnewlIf last)-ndpstn
If (If l
ast.eq.0.and.1 up.gt.0) 1dwnew(lup)»ndpstn
End If
CInfnew(ndpstn)«npoly
1 upnew(ndpstn)*1 up
1dwnew(ndpstn)«IftIn
Irtnewl ndpstn )!E0
Cc
- Move the up,
left, and right pointers of
those objects now
c contained
In polygon npoly (I.e.
have ndpstn as
a parent).
CIf
(1cnt.gt.0) then
Do 40
1=1,lent
lupnewl1n(1))«ndpstn
If (1.EQ.1) Then
1lfnew(lft1n)-0
Else1Ifnewl1n(1))»1nl1-1 )
End If
CIf
I 1.EG.lent) Then
Irtnewl1n(1))=0
ElseIrtnewl1n(1)) = 1nl1 + 1 )
End If
40
Continue
End If
CReturn
End
C +
C softky -
SOFT KeY -
Sets the sending of
soft key definitions
C (*0'-d1sable,>1'^enable).
C-£ *************************************************************
Subroutine softky(comd)
Character com*3,comd*l
Ccom-'Rm'//comd
Ca11 esccom(com)
CReturn
End C +£ ************************************************************
C spfcom -
Driver for
special function mode.
Options are:
CC 1 49
C c
= Copy a
polygon (and
parameters)
« » '
m = Move a
polygon to a
new position)
r = Rotate a
polygon about a
specified origin and
by a
prescribed theta.
h =
Help
q - Quit and return to polygon ADD/CHANGE/DELETE/
EDIT mode.
r*********
Subroutine spfcorn?ttest)
Character quest*80,ans*2
CCall enhmsgl**** Special functions mode *** )
C Cans-'h'
1test«0
Do 10
whlleMtest.EQ.0)
quest**
Special function mode (c/m/r/h/q)'
1 va 1 = 1aquesttquest,ans, Ma2 ) ' ,2 )
CIf
(ans.EQ.*C'.OR.ans.EQ.'c* )
Then
Call cpyply(lerror)
Else If
(ans.EQ.'M*.OR.ans.EQ.'m') Then
Call movplyl lerror )
Else If
(ans.EQ.'R'.OR.ans.EQ.'r') Then
Call rotplyllerror)
Else If
(ans.EQ.'H*.OR.ans.EQ.'h' )
Then
Call hlpspf
Else If
(ans.EQ.'Q'.OR.Ival.EQ.-l.OR.ans.EQ.'q') Then
ltest*l
ElseCal1 errmsg
End If
ans='q'
10 End Do
CReturn
End
C +
C stdout - Creates a
Denver Standard grid output file.
C-
\*
Subroutine stdoutIItest)
Common /grIdspecsZ/1d2,pgm2,nc2,nr2,nz2,xo2,dx2,yo2,dy2,
&1proJ2,cm2,bl2
Common /gr1dspecs/1d,pgm,nc,nr,nz,xo,dx,yo,dy,IproJ,cm,bl
Common /names/grdnam,modnam,modgrd
Character ulabel*15,quest*80,grdnam*80,modnam*80,modgrd*80
Character 1d2*56,pgm2*8,ans*2,iddum*80,1d*56,pgin*8
CC -
Ask
If user want to use an already existing grid.
CIflag=l
Ca11 msgstd
quest=' Do you wish to use a
prexlsltlng grid (y/n/q)'
Call askqst(ans.quest,1 test)
If (1test.EQ.-l.OR.ans.EQ.*Q')Go To 100
If (ans.EQ.'Y') Iflag = 2
C C -
Ask for model grid's name
quest=' Model grid'
"150
Call asknamCmodgrd,quest,1 test)
If (Itest.EQ.-l)Go To 100
CC -
If a
prexlstlng grid Is
used read 1t
In and test Its
grid specs
CIf
( If lag.EQ.2) Then
Call redwrMmodgrd, Itest)
Call testspecs(Itest)
If (Itest.LE.-l)Go To 100
ElseCall copyspecs
End If
CC - ASK FOR GRID ID.
Cquest-'
Id*
Call asknam(Iddum,quest,Itest)
If (Itest.EQ.-l)Go To 100
ileng=1tlen(Iddum)
1d2=1ddum<1:56)
CC -
Ask for grid dval
CIf
(Iflag.EQ.1)Call askdv1<dval,Itest)
If (Itest.EQ.-l>Go To 100
CC -
Ask for which set of parameters (FARM* arrays) to use In
C setting the grid
CCall askval(Iset,ulabel,Itest)
If (Itest.EQ.-l)Go To 100
CC -
Initialize wrkgrd to dval
CIf
(Iflag.EQ.1)Call Intwrk(dval)
CC - Walk the tree and set the grid
CCall setgrdtIset,Itest)
CC - Write out the grid to the user specified file
CCall wrtgrddnodgrd,Itest)
C100 Continue
Return
End
C +
C stoply -
Stores the polygon xpoly,ypoly 1n
the screenloc array
C at position npoly.
C-w
Subroutine stoply(xpoly,ypoly,nbrpts,npoly,Itest)
DlmensIon xpoly(nbrpts),ypoly(nbrpts)
Common /screenloc/ntotal,numply(100),xscr(100,100),yscr(100,100)
Cnump1y( npoly )«= n
brpts
Do 10
1=1.nbrpts
xscr(npoly,1)=xpoly(1)
yscr(npoly,1)
Bypoly(1)
10 Continue
CReturn
151
End
r * **i
storeold - Stores all
the polygon Information associated with
npoly In
the oldcoord common block.
I*************************************************************
Subroutine storeold(npoly,1 test)
Common /oldcoord/noId,xold(100),yold(100),x1no1d(100),
&y1nold<100),xoutold(100),youtold(100),xm1nold,xmaxold,ym1nold,
&ymaxold,partmp(10)
Common /screenloc/ntotal,numply(100),xscr(100,100),yscr<100,100)
Common /box/xm1nbx(100),xmaxbx(100),ym1nbx<100),ymaxbx(100)
Common /1nout/x1n(100,100),y1n(100,100),xout(100,100),
&yout(100,100)
Common /parameter /parm<100,10)
Common /commands/nmax,eps1ln,delIn,delout
Common /max/nptmax
If (npoly.GE.1.AND.npoly.LE.nmax) Then
nold*numply(npoly)
If (nold.GE.1.AND.nold.LE.nptmax) Then
xm1nold
isxm1nbx( npoly)
xmaxo1d=xmaxbx{npoly)
ym1nold=ym1nbx(npoly)
ymaxold = y
maxbx< npoly)
Do 10
1=l,nold
xold(1)*xscr( npoly,1)
yold(1)*yscr(npoly,1)
x1nold(1)=x1n(npoly,1)
y1nold(1)=y1n(npoly,1)
xoutold(1)*xout(npoly,1)
youtold(1)=yout<npoly,1)
10 Continue
Do 20
J=l,10
partmp< J)*parm(npoly,J)
20
Continue
Itesfl
ElsePrint *,'
Error, number of
points for
polygon',npoly,
& ' out of
range*ltest«-l
End If
ElseCall
wrtmsg(' Polygon number out of
range')
1test--l
End If
Return
End
t ** *i tangle - Turning ANGLE
PURPOSE.
Determines the turning angle (relative heading change)
THETAD
In degrees when going from the line
segment
(xl,yl)-(x2,y2) to
the line
segment (x2,y2)-(x3,y3)
Using the equation:
c**2*a**2+b**2-2.0*a*b*cos(alpha)
where a,b are the distances from the corner (xl,yl)
(x2,y2) and (x2,y2),(x3,y3) respectively; and the
turning angle Is
defined as:
thetad-180.0-a1pha
FORM.
Cal1 tanglelthetad.xl,y1,x2,y2,x3,y3>
PARAMETERS.
THETAD
- Turning angle In
degrees.
(xl,yl),(x2,y2),(x3,y3)
- End points of line segments.
NOTEt
The THETAD returned Is
a positive number between 0.0
and 180.0 degrees; TANGLE does not make a
distinction
between a
left or
right turn.
************************************************************
Subroutine tangle(thetad,xl,yl,x2,y2,x3,y3)
Ca=sqrt((x2-xl)**2+(y2-yl)**2)
b=sqrt((x3-x2)**2+(y3-y2)**2)
c*sqrt((x3-xl)**2+(y3-yl)**2)
CIf
(a.LT.1.0e-18)a=l.0e-18
If (b.LT.1.0e-18)b=l.0e-18
Cthetad*acosd((c**2-<a**2+b**2 ))/(2.0*a*b))
CReturn
End
C +\*C
tester - Starting at polygon (LPOLY), tester walks the tree
structure and returns the polygon number (NPOLY) and
the corner of this polygon (NCORN) closest to the
point (x,y).
*************************************************************
Subroutine tester(npoly,ncorn,lpoly,x,y,1 test)
Dimension xpoly(100),ypoly(100)
Common /screenloc/ntota1,numply(100),xscr(100,100),yscr(100,100)
Common /topology/Info(100),1 upper(100),1down(100),
&11eft(100),1r1ght(100)
Common /commands/nmax,eps11n,del 1n,delout
Common /max/nptmax
Parameter (vaxmln*-!.7e+38,vaxmax=l.7e + 3
8 )
Character lowup*3
npoly=0
ncorn=0
If (Ipoly.GE.l.AND.Ipoly.LE.nmax) Then
1te
st=
01
po
ly=
Ipo
ly1 c
orn
= 01co
rn2=
01
se
t=0
1set2
=0
np
oly
l=0
nco
rn 1 =
0
... 1
C "Z
np
oly
2=
0
{ 0 J>
nc
orn
2=
0
dmln-vaxmax
dm 1n2 = v
axmax
CDo 10 whlle(1test.EQ.0)
Call tstbndC1n-ut,x,y,Ipoly)
If (Inout.EQ.1) Then
nbrpts
=enumply( Ipoly)
If (nbrpts.GE.1.AND.nbrpts.LE.nptmax) Then
Do 30 1«1,nbrpts
xpoly(1)«xscr(Ipoly,I)
ypoly(1) = y
scr(Ipoly, 1)
30
Continue
CC -
Test the polygon by using both the limited and unlimited
C versions of subroutine clspnt.
CIflag«0
Cal1 clspnt(Icorn,d1st,x,y,xpoly,ypoly,nbrpts,delout,
&
Iflag)
If Ug2-l
Cal1
c Ispnt(1corn2,d1st2,x,y,xpoly,ypoly,nbrpts,
&
delout,If lag?)
If < I
corn.GT.0.AND.dlst.LT.dmln) Then
npoly1«Ipoly
ncornl*Icorn
dm1n«d1st
1set«i
End If
If ( 1
corn2.GT.0.AND.d1st2.LT.dm1n2) Then
npoly2*Ipoly
ncornZ
581corn2
dm1n2*d1st2
1set2=l
End If
CC -
If the point (x,y) was not within the radius used for
C the limited version of clspnt, then test to see
If the point
C Is
Inside of the polygon currently under test.
CIf
(1corn2.EQ.0) Then
Call piytst(xpoly,ypo1y,nbrpts,x,y,1nout2)
Call fndply(ngon,Ipoly>
If (1nout2.EQ.1> Then
next=1down(ngon)
Elsenext-1r1ght(ngon)
End If
If (next.LE.0) Then
If {1set2.EQ.1) Then
npoly=npoly2
ncorn=ncorn2
1test=l
Else If
( Iset.EQ.1) Then
npoly=npoly1
ncorn=ncorn1
Itest'l
Else1test=-l
End If
Else1poly«1nfo(next)
End If
* t~
A Else If
{ Icorn.GT.0.OR. 1corn2.GT.JBT)
Then
I b 4
Call fndp1y(ngon,Ipoly)
If (ngon.GE.1) Then
Call walk(next,ngon,1test3)
If (next.EQ.0.0R.ftest3.EQ.0) Then
If ( I
setZ.EQ.1) Then
npo1y=npo!y2
ncorn=ncorn2
ttest*!
Else If
(Iset.EQ.1) Then
npoly^npolyl
ncorn=ncorn1
1test=l
ElsePMnt *, *
f 1test=-l
End If
Else1polyaInfo(next)
End If
ElsePrint *,'
Error, ngon not found*
1test=-l
End If
ElsePrint *,'
Error encountered
tn clspnt at polygon*,
&
tpoly,* and corner * *,1corn
1test=-l
End If
ElsePrint *,*
Error
In polygon *,tpoly*
&
* nbrpts out of range'
1test»-l
End If
Else If
(tnout.EQ.0> Then
Call fndp1y<ngon,Ipoly)
next«1r1ght(ngon)
If (next.LE.0) Then
If (IsetZ.EQ.l) Then
npoly=npoly2
ncorn=ncorn2
1test=l
Else If
(Iset.EQ.1) Then
npoly=npolyl
ncorn = n
corn 1
ltest=l
Else1test--l
Print *,'
Test bound routine*
Print *,*
*print *,*
Sorry, could not find your polygon*
End If
Elselpoly»lnfo(next)
End If
ElsePrint *,'
Error encountered 1n
tstbnd at polygon',Ipoly
1test»-l
End If
10
End Do
ElsePrint *,*
Error, lpolya*,Ipoly,' passed to tester out of range*
1test--l
End If
Return
155
End
r ** *i
testoff - Tests the polygon xpoly.ypoly to see if
at least one
corner point of the polygon
is Inside or
outside of a
given window.
Window Is
defined as x,y:
x1eft-<x«<xrIght
ybot*<y=<ytop
Intotal
« Flag giving result of test.
> 1,
at least one point Is
within window
* 0,
polygon Is
outside of
window
-!» error
In parameters passed to routine.
r****************************************
Subroutine testoff(xpoly,ypoly,nbrpts,xleft,xr1ght,ybot,
&ytop,f ntota1)
DImensIon xpoly(nLrpts),ypoly(nbrpts)
If ((nbrpts.GE.1).AND.(xleft.LE.xr1ght).AND.(ybot.LE.ytop)> Then
I ntota1=0
Do 10
1*1.nbrpts
If ((xpoly(1>.GE.xleft.AND.xpolyl1).LE.xrIght>.AND.
&
(ypoly(1>.GE.ybot.AND.ypoly(1>.LE.ytop))1ntota1=1ntota1+1
10 Continue
ElseCall wrtmsg(' Error
In TESTOFF, boundary conditions or
nbrpts
&
Illegal')
1 ntota1 = -1
End If
Return
End
***
testopo
- Test the polygon passed
In the xtemp,ytemp to see If
It will fit Into the topology arrays.
If not, restores
the old polygon Information stored
In the oldcoord
common block.
r*************
Subroutine testopo(npoly,1test)
Common /topology/1nfo(100),1 upper(100),1down(100),
&1left(100),1rIghtt100)
Common /oldcoord/noId,xoldf100),yoldt100),xInoldt100),
&y1no1d(100),xouto1d(100),youtold(100),xm1no1d,xmaxo1d,ym1no1d,
&ymaxo1d,partmp(10)
Common /temp/ntemp,xtemp(100),ytempC100)
Common /screen 1oc/ntota1,numply(100),xscr(100,100),yscr(100,100)
Common /box/xm1nbx(100),xmaxbx(100),ym1nbx(100),ymaxbx(100)
Common /1nout/x1n(100,100),y1n(100,100),xout(100,100),
&yout(100,100)
Common /parameter/parm(100,10)
Common /state/If 1ast,Iftln,Iftout,ndpstn,tup
Common /commands/nmax,eps11n,de11n,de1out
Common /max/nptmax
Common /screenbnd/xleft,xrIght,ybot,ytop
Common /Junk/ngbtop,Jnktopl100),ngbloc,Jnkloc{100)
Common /zoom/1 zoom,1zva1,nzoom,ncm1nz(5) ,ncmaxz(5),nrm1nz(5),
&nrmaxz(5)
Common /colors/plyclr,black,wh1te
Common /f111/open,sol Id,f1Ityp
156
Character open*! ,so1 1d*l ,f 1ltyp*l , pi y
clrM , b
lack*! ,white*!
Character 1ntype*1,ans*2,ans2*2
ltest-0
If (ntotal.GT.0.AND.npoly.GT.0) Then
Store the old polygon Information Into
the oldcoord common block.
Call storeold(npoly,1test3)
Delete the old polygon Information associated with npoly.
ntota1=ntota1 -1
If (ntotal.LT.0) ntotal=0
ngbloc=ngbloc+l
ngbtop=ngbtop+1
1err3=2
Call deltpl(npoly,1err3)
If (1err3.LE.-l) Then
Call wrtmsgC'
Error
In testopo routine*)
1test=-lGo To 100
End If
Call delloc(npoly,1err3)
- Find the available polygon position npo1y2.
Call fndnum(npoly2)
- Test polygon In
xtemp,ytemp.
Call fndtopnew(ntop)
Call fndtpl<npoly2,ntop,1test2)
If ( 1
test2.EQ.1) Then
ntota1=ntota1+1
Call stop 1
y(xtemp,ytemp,ntemp,npo1y2,1err3)
Ca11 fndbbx< xmln,xmax,ym1n,ymax,xtemp,ytemp,ntemp,
& delout)
xm1nbx(npoly2)=xm1n
xmaxbx(npo1y2)=xmax
ym1nbx(npoly2)=ym1n
ymaxbx(npoly2)=ymax
Call fndbpl(npoly2,1err3)
Do 95
1 1 = 1 , 10parm< n
poly2,11)=partmp(11)
95 Continue
Map the new topology structure onto the old topology arrays.
Call newold
- Undraw the old polygon and draw the new polygon.
If (Izoom.EQ.l) Then
Do 50 1=1,nold
Cal1 trans<xold<1),yold<1),xold<1),yold<1))
50
Continue
Do 55
J=l,ntemp
Call trans< xtemp(J),ytemp(J),xtempiJ),ytemptJ))
55 Continue
End If
- Cnp and
undraw the old polygon.
157
Call setclr(black)
Call setfll(open)
Cal1 drwclpC xold,yoId,nold,xleft,xr1ght,ybot,ytop)
- Clip and draw the new polygon.
Call setclr(plyclr)
Cal1 drwclp(xtemp,ytemp,ntemp,xleft,xrIght,ybot,ytop)
Call setfll(solld)
1test*l
Else If
(1test2.EQ.-l) Then
- Since new polygon failed test, restore the old polygon Inform-
matlon at the position of npoly2.
ntotal*n
total+1
Cal1 stoply(xold,yold,nold,npoly2,1err2)
xm1nbx(npo1y2)=xm1nold
xmaxbx(npoly2)=xmaxold
ymlnbxC npoly2 )«!ym1 n
old
ymaxbx(npoly2)-ymaxold
- Restore the Inner and outer bounding polygon Info.
Do 60 JJ = 1
,nold
Xln(npoly2,JJ)=x1nold(Jj)
y1n(npoly2,jj)=y1nold(Jj)
xout(npoly2,jj)=xoutold(jJ)
yout(npoly2,jj)=youtold(jj)
60
Continue
- Restore the paramter Info.
Do 65 J«l . 10
parm(npoly2,J)=partmp(j)
65 Continue
- Map the old topology structure back onto the new topology array
1nfo(ndpstn)=npoly2
Cal1 oldnew
1test=-l
End If
End If
00
Continue
Return
End
***testspecs -
Test the grid specifications In
the two common blocks
grldspecs and gr1dspecs2 for the matching of
essential
parameters.
************
Subroutine testspecs(1 test)
Common /grIdspecs/1d,pgm,nc,nr,nz,xo,dx,yo,dy,1proj,cm,bl
Common /gr1dspecs2/1d2,pgm2,nc2,nr2,nz2,xo2,dx2,yo2, dy2 ,
&1proj2,cm2,bl2
Character 1d*56,1d2*56,pgm*8,pgm2*8
If ((nc.EQ.nc2).AND.lnr.EQ.nr2)) Then
1test=l
158
ElseCall
wrtmsgt' Error TESTSPECS, grid specifications do
not
& match')
1test*-l
End If
CReturn
End C +wC
totalt
- Computes the total turning angle In
degrees of
the
C given polygon.
The ' t
ota 1
turning angle Is
the sum
C of
the Individual heading changes when moving from
C corner point to corner point around a
polygon.
C-W
Subroutine total t ( g
amma , x
poly,ypoly, nbrpts)
Dlmens ton
xpolyf nbrpts ) , y
poly( nbrpts )
theta=0.J&
Do 10
1 = 1 , nbrpts
If (1.EQ.1) Then
1back=nbrpts
1next=2
Else If
< 1 .EG. nbrpts) Then
1back=nbrpts-l
1next=l Else1back*1-l
1next-1+l
End If
xl^xpolyt Iback )
yl»ypoly( Iback)
x2=xpoly( 1 )
y2*ypoly( 1 )
x3=xpoly( Inext )
y3=ypoly( Inext )
Compute the next relative heading change when going from the line
segment
( xl ,yl ) , ( x2,y2 )
to ( x2 ,y2 ) , ( x3 ,y3 ) .
Cal 1 tang1e(theta ,xl,yl,x2,y2,x3,y3)
To determine If
the heading change was to the left
(counter-clockwise
or the right (clockwise), construct the components of
two
vectors A
and B,
and compute their cross-product.
Since the
vectors are In
a plane the k
(or z)
components of
the vectors
will be zero.
Ax=x2-xl
Ay=y2-yl
Bx=x3-x2
By=y3-y2
Now compute the cross-product; since the
k (or
z) components of
the vectors A and
B are zerro we need only compute the k
(or z)
component of
vector C.
Cz=Ax*By-Ay*Bx
We make the following definitions:
| J /
Cz > 0.0 - Relative heading change was to the left.
Cz < 0.0 - Relative heading change was to the right.
If (Cz.GT.0.0> Then
par1ty=-l.0
Else If
(Cz.LT.0.0) Then
par 1ty-1.0
Elsepar 1
ty«0.0
End If
gamma*gamma+par1ty*theta
10 Continue
Return
End
trans
- Transforms a
coordinate (xold.yold) from the normal
unzoomed screen to
a zoomed screen (xnew,ynew).
**************************************************************
Subroutine trans(xnew,ynew,xold,yold)
Common /subgrld/lcmln,Icmax,Irmin,1rmax,ncm1n,ncmax,nrm1n,nrmax
Common /original/Iwcorg,Jwcorg,nxorgp,nyorgp
Common /sealefacts/1wc0,Jwc0,nxp1x,nyp1x,p1xd1m
xorg*1wcorg+(ncmln-1)*nxorgp
yorg*Jwcorg*(nrmln-1)*nyorgp
xnew»1wc0+(xold-xorg)*nxp1x/nxorgp
ynew*Jwc0+(yold-yorg)*nyp1x/nyorgp
Return
End
f**************************************************************
tstbnd
- Test the location xtest,ytest to see If
It Is
within the
bounding box around polygon npoly.
Inout »
Flag for
point being Inside or
outside of
box.*
1 -
Point
Is Inside bounding box
* 0 -
Point
Is outside of
bounding box
«-l -
npoly passed to
tstbnd out of
range.
**************************************************************
Subroutine tstbnd(1nout,xtest,ytest,npoly)
Common /box/xmlnbx <. 100) , x
maxbx( 100) , ym 1 nbx ( 100) ,ymaxbx( 100)
Common /commands/nmax,eps1In,deli n.del o
ut
If (npoly.GE.1.AND.npoly.LE.nmax) Then
1nout=0
If ((xtest.LE.xmaxbx(npoly)).AND.(xtest.GE.xmlnbx(npoly)).AND
& (ytest.LE.ymaxbx(npoly)).AND.(ytest.GE.ymlnbx{npoly)))1nout=l
Else1nout=-1
:{nd If
Return
- -id
********************************************
«***M**««W1t«ll1tKIIII«ll««««ll«********M*********«*K**««««««««««1t«
~
f
-
tstend
- TeST END
- Tests the endpolnts of
the line
(xl.yl),
'60
(x2,y2) for mapping onto region 0000 (See "Principles
of Interactive Computer Graphics", by Newman and
Sproull, figure 5-5, page 66.)
Region 0000 Is
defined as any x,y:
xleft
< x
< xrlght
ybot
< y
< ytop
Inout
Value describing properties of pair
3 Both points
In region 0000
2 point (x2,y2) within region 0000
1 point (xl.yl) within region 0000
0
line segment crosses region 0000 (endpolnts
are outside)
-1 «
line segment
Is entirely off screen
Subroutine tstend(Inout,xl,yl,x2,y2,xleft,xrIght,ybot,ytop)
Cal1 fndcdel1one4,1one3,1one2,lonel,xl,yl,xleft,xrIght,ybot,ytop)
Call fndcde<1two4,1two3,ItwoZ,Itwol,x2,y2,xleft,xrIght,ybot,ytop)
nsuml* lone4+1one3+1one2+lonel
nsum2-1two4+1two3+1two2+Itwol
1nout«-1
If ((nsuml.EQ.0).AND.(nsumZ.EQ.0)) Then
1nout»3
Else If
(nsuml.EQ.0) Then
1nout*1
Else If
(nsum2.EQ.0) Then
1nout«Z
Else1count*0
If ((1one4.EQ.1).AND.(1two4.EQ.1)) Then
1 count*1 count*1
End If
If ((1one3.EQ.l).AND.(1two3.EQ.l)) Then
1count=1 count*1
End If
If ((loneZ.EQ.1).AND.(ItwoZ.EQ.1)) Then
1count=Icount*1
End If
If <(lonel.EQ.l).AND.(Itwol.EG.1)) Then
1 count"1 count*1
End If
If (lcount.EQ.0) Then
delx«x2-xl
dely*yZ-yl
If (abs(delx).LT.l.e-16) de1x=sign(1.e-16,delx)
If (abs(dely).LT.l.e-16) dely=s1gn(1.e-16,dely)
slope=dely/delx
b=y2-slope*x2
Do 10
1=1,2
If (1.EQ.1) Then
xtest*xleft
Else
161
xtest«xrIght
End If
ytest*slope*xtest+b
If (ytest.GE.ybot.AND.ytest.LE.ytop) 1nout»0
10 Continue
Do 20 J-1,2
If (J.EQ.l) Then
ytest«ybot
Elseytest*ytop
End If
xtest*(ytest-b)/s1 ope
If (xtest.GE.xleft.AND.xtest.LE.xrIght) 1nout-0
IB Continue
End If
End If
Return
End
tstpgn
- TeST PolyGoN -
Tests the two polygons npoly and
(xtemp,ytemp), under control of Icon, for whether
one polygon Is
inside, outside, or
if they cross.
Icon
* Input flag controlling how polygon comparlslons
are made.
* 1
« Tests
If polygon (xtemp,ytemp)
Is within
polygon npoly (xscr,yscr)
* 0 «
Tests
If polygon npoly (xscr,yscr)
is with
in polygon (xtemp,ytemp)
Inout
Flag describing whether a
polygon Is
Inside,
outside, or crosses another polygon.
* 1
* Inside
* 0 * outside
*-l *
cross
Subroutine tstpgn(Inout,npoly,icon,Itest)
Dimension xtest(100),ytest(100),xpoly(100),ypoly(100)
Common /commands/nmax,epsiIn,delin,delout
Common /temp/ntemp,xtemp(100),ytemp(100)
Common /screenloc/ntcta1,numply{100),xscr(100,100),yscr{100,100)
If (npoly.GE.1.AND.npoly.LE.nmax) Then
ItestM
nbrpts*numply(npoly)
If (Icon.EQ.1) Then
10
Do 10
xtest( ytest(
Cont Int
Do 20
xpolyl
ypoly(
88 1 , ntemp
)»xtemp( 1 ) )«y tempt 1 )
je1»1 ,nbrpts
1 ) sxscr ( npol y , 1 1 )
1 )»yscr ( npoly, 1 1 )
162
20
Continue
ncount-ntemp
npp*nbrpts
Else If
(lcon.EQ.0) Then
Do 30 J=l,nbrpts
xtest(J)»xscr(npoly,J)
ytest(J)*yscr(npoly,J)
30
Continue
Do 40 JJ-l,ntemp
xpoly(JJ)*xtemp(JJ )
ypoly(JJ)»ytemp(JJ)
40
Continue
ncount^nbrpts
nppsntemp
Else1test«-l
Call wrtmsg(* Error In
tstpgn. Icon was not
1 or 0')
Go To 100
End If
nout=0
n 1n=0
Do 50 k-1.ncount
Cal1 plytst(xpoly.ypoly,npp,xtest(k),ytest(k),Ireslt)
If (Ireslt.EQ.0) Then
nout=nout+l
Else If
(Ireslt.EQ.1) Then
n1n=n1n+l
End If
50
Continue
If (nout.EQ.ncount) Then
1nout»0
Else If
(nIn.EQ.ncount) Then
1nout*l
Else1nout=-1
End If
ElseCall wrtmsgl* Error, npoly not In
the range: l»<npoly»<nmax')
1test«-l
End If
100 Continue
Soturn
End
tstseg
- Tests two line segments [x1,y1],[x2,y2] and txtl.ytl],
Cxt2,yt2] to see If
they cross.
The test consists of:
(1) Comparing sides for overlap of their range
and doma 1.n.
(11) If
sides overlap from (1),
calculate the
Intersection point (xlnt.ylnt).
(111) Determine If
the Intersection point lies In
the overlap of the sides' ranges and domains
163
ncross
* Flag telling
if sides cross
= 1
* sides cross
» 0 *
sides do not cross
Author: Bruce A.
Chuchel, USGS, Menlo Park, CA. ,
1/85
-************************************************************
Subroutine tstseg(ncross,xl,yl,x2,y2,xt1,yt1,xt2,yt2)
ncross*0
- For the side Joining the points Cxl.yl] and Cx2,y2] construct
the domain and range Intervals [xlow,xup] and [ylow.yup]
x1ow*am1nl(xl,x2)
ylow*am1nl(yl,y2)
xup-amaxl(xl,x2)
yup*amaxl(yl,y2)
txlow-amlnl(xtl ,xt2)
tylow-amlnl(ytl,yt2)
txup«amaxl(xtl,xt2)
tyup^amaxl(ytl,yt2)
- Test (1)
If ((txlow.GE.xlow.OR.txup.GE.xlow).AND.
&{txlow.LE.xup.OR.txup.LE.xup).AND.
&(tylow.GE.ylow.OR.tyup.GE.ylow).AND.
&(tylow.LE.yup.OR.tyup.LE.yup)) Then
rr-- Determine the slope (dely/delx), and y-axls Intercept (b),
of the line segment between the points Cxl,yl] and [x2,y23.
delx«x2-xl
de1y«y2-yl
If (abs(delx).LT.1.0e-l6)delx=sIgn(1.0e-16,delx>
If (abs(dely).LT.1.0e-16)dely=s1gn(1.0e-IG.dely)
b-yl-xl*(de1y/delx)
- Test (11)
tdelx-(xt2-xtl)
tde1y-(yt2-ytl)
If (abs(tdelx).LT.1.0e-l6)tdelx-s1gn(1.0e-16,tdelx)
If (abs(tdely).LT.1.0e-16)tdely=s1gn(1.0e-16,tdely)
tb-ytl-xtl*(tde1y/tdelx)
d Iff-((dely/delx)-{tdely/tdelx))
If (abs(dIff).LT.l.0e-16)dIff=s1gn(1.0e-16,dIff)
x1nt-(tb-b)/d1ff
y1nt»x1nt*(de1y/de1x)+b
- Test (111)
Now test (x1nt,y1nt) for being In
the Intervals bounded
by Cxlow,xup],Cylow,yup] and Ctx1ow,txup],Ctylow,tyup]
If ((x1nt.GE.xlow.AND.x1nt.LE.xup).AND.
& (ylnt.GE.ylow.AND.ylnt.LE.yup).AND.
& (xlnt.GE.txlow.AND.xfnt.LE.txup).AND.
&
(ylnt.GE.tylow.AND.ylnt.LE.tyup)) Then
ncross=1
End If
End If
Return
End
r***i
tstxcr
- Tests whether the polygon given
In xtemp.ytemp array
overlaps on
the polygon npoly.
The test consists of:
(1) Comparing sides In
pairs for
overlap of
their
range and domain.
(11) If
sides overlap, calculate the Intersection
point (x1nt,y1nt).
(Ill) Determine If
the Intersection point lies
In the overlap of
the sides' ranges and domains
ncross
s Flag telling If
polygons overlap
s 1
= polygons overlap
* 0 * polygons do not
overlap
npoly
* Pointer to polygon In
xscr,yscr arrays
Subroutine tstxcr(ncross,npoly)
Common /screenloc/ntota1,nump1y(100),xscr(100,100),yscr(100,100)
Common /temp/ntemp,xtemp(100),ytemp(100)
1test«0
ncross=0
.tbrp
ts*n
um
ply
( np
oly
)
- Start the counter (1)
for the side of
the polygon npoly.
Do 10
wh11e(1t»st.EQ.0.AND.1.GE.l.AND.1.LE.nbrpts)
If (1.EQ.nbrpts) Then
xlsxscr(npoly,nbrpts)
yl^yscr(npoly.nbrpts)
x2ssx
scr(n
poly
, 1 )y2=yscr(npoly,1)
Elsexl^xscr(npoly,I)
yl^yscr(npoly,1)
x2S!xscr ( n
poly, 1 + 1 )
y2*yscr(npoly,1+1)
End If
- For
the side of
the polygon Joining the points (xl,yl) and
(x2,y2) construct the domain and range Intervals [xlow.xup],
Cy1ow,yup].
xlow=amInHxl ,x2)
ylow=am1nl(yl,y2)
xup=amax1(xl,x2)
yup=amaxl(y1,y2)
- Determine the slope (dely/delx), and y-axls Intercept (b),
of the line
segment between the points (xl,yl) and (x2,y2).
delx=x2-xl
165
dely=y2-y1
If (abs(delx).LT.1.0e-l2)delx=s1gn(1.0e-12,delx)
If (abs(dely).LT.1.0e-12)dely=sIgn(1.0e-12,dely)
b=yl-xl*(dely/delx)
CC - Now start searching through the xtemp,ytemp array and do the
C tests outlined above.
Start the counter (lent)
for the side
C of
polygon In
xtemp,ytemp.
CIcntM
Do 20 whlleCltest.EQ.0.AND.lent.GE.1.AND.lent.LE.ntemp)
If (Icnt.EQ.ntemp) Then
xt1=xtemp(ntemp)
y 11 = ytemp(ntemp)
xt2=xtemp(1)
yt2!=ytemp( 1 )
Elsextl=xtemp(lent)
ytl»ytemp(lent)
xt2=xtemp(1cnt+l)
yt2«ytemp(1cnt+l)
End If
Ctxlow=am1nl (xtl ,xt2)
tylow»am1nl(ytl,yt2)
txup'amaxl(xtl,xt2)
tyupaamaxl(ytl,yt2)
CC -
Test
( 1 ) C
If ((txlow.LT.xlow.AND.txup.LT.Xlow).OR.
A(txlow.GT.xup.AND.txup.GT.xup).OR.
4(tylow.LT.ylow.AND.tyup.LT.ylow).OR.
&(tylow.GT.yup.AND.tyup.GT.yup) )
Then
ltest-0
Else
CC -
Test (11 )
Ctdelx=(xt2-xtl)
tdely=(yt2-ytl)
If (abs(tdelx).LT.1,0e-12)tdelx=s1gn(1.0e-12,tdelx)
If (abs(tdely).LT.1.0e-12)tdely=s1gn(1.0e-12,tdely)
tb=ytl-xtl*(tdely/tdelx)
Cd1ff»((dely/delx)-(tdely/tdelx))
If (abstdlff).LT.1.0e-12)dIff-sIgn(1.0e-12,d1ff)
Xlnt»(tb-b)/d1ff
y1nt-x1nt*(dely/delx)+b
CC - Test (111)
C Now test (xlnt.ylnt) for
being In
the Intervals bounded
C by [xlow,xup],[ylow,yup] and [txlow,txup],Ctylow,tyup]
CIf
<(xlnt.GT.xlow.AND.xInt.LT.xup).AND.
& (ylnt.GT.ylow.AND.ylnt.LT.yup).AND.
& (xlnt.GT.txlow.AND.xInt.LT.txup).AND.
& (ylnt.GT.tylow.AND.ylnt.LT.tyup)) Then
ncross=1
1test=l End
If End If
If (ncross.EQ.0)lent*1cnt+l
20 End Do
If { Itest.EQ.JB) 1-1 + 1
10 End Do
Return
End
'**** unzcom -
Driver to redraw unzoomed grid on Envision terminal.
l**AA**A**AA*********A***i
Subroutine unzcom(1 test)
Common /mlsc/ncol,nrow,f1rst,ntop,If 1rst
Common /orIginal/Iwcorg,Jwcorg,nxorgp,nyorgp
Common /subgrld/lcmln,1cmax,Irmin,1rmax,ncm1n,ncmax,nrmln,nrmax
Common /scale/xsc,ysc,xstart,ystart,x1n1t,y1n1t
Common /sea lef a
cts/ 1wc0, Jwcfl, n
xp 1 x, n
yp 1 x ,p I
xdlm
Common /zoom/Izoom,Izval,nzoom,ncm1nz(5>,ncmaxz(5),nrm1nz(5),
&nrmaxz(5)
Common /colors/plyclr,black,white
Common /f111/open,sol Id,f11typ
Common /model/mdflag
Character piyclr*l,black*!,white*!,open*l,sol1d*l,f11typ*l
Character first*!
1test»l
ItestZ-l
If (IfIrst.EQ.l) Then
Call Intscr
Call clrsgdC1,ItestZ)
If
( 1te
st2
.GE
.JB
T)
Th
en
C
all
clr
ply
If 1rst=
J0f 1
wc
org
= 1w
cJ0f J
wc
org
= JwcJ0f
nxo
rgp
=n
xp
1x
nyo
rgp
=n
yp
1x
End If
ElseCall Intscr
Call clrsgd(J0f, I
testZ)
Call clrply
End If
If (ItestZ.GE.0) Then
1 zoom=0
xstart*ncm1n
ystart=nrm1n
xsc»floatlnxplx)
yscafloatlnyplx)
Call setbnd
End If
If ( I
testZ. GE.J0T. A
ND. mdf lag. EQ. 1 )
Then
Call setclr(plyclr)
Call selftl(open)
Call drawwalk
Call self 11(sol Id)
End If
If (ItestZ.LT.0)1test-1test2
Return
End
UPSHIFT - Converts lowercase to uppercase.
All non-lowercase characters unchanged.
1 / "7
CALL UPSHIFT(A)
A
A character string of any length
Author: Richard W. Saltus, USGS, Denver, CO.
SUBROUTINE UPSHIFTtA)
CHARACTERM*) A, UP* < 2
6 ) , D
OWNM 26 )
UP*'ABCDEFGHIOKLMNOPQRSTUVWXYZ'
DOWN*'abcdefghlJkImnopqrstuvwxyz'
ILEN=LEN(A>
DO 10 I-l.ILEN
INUM»INDEX(DOWN,A<1:1))
IF (INUM.NE.J0) A< I : I )
=UP( INUM: INUM)
10
CONTINUE
RETURN
END
C +£ *************************************************************
valchg - Allows the changing of the parameterss associated with
polygon npoly.
npoly *
Polygon number (1-nmax)
»
Iset *
Sets which arrays
In parm* arrays are to
be reset.
= 0 »
All parameters (1-10) will be prompted for
1
- 10 »
Prompts only for the one parameter
selected
*************************************************************
Subroutine valchg(npoly,Iset,Itest)
Common /commands/nmax,eps1 In,del1n,delout
Common /labels/label
Common /parameter /parm(100,10)
Character label(10)*15,ulabel * 1
5,quest*80
CIf
(npoly.GE.1.AND.npoly.LE.nmax) Then
1test=0
If {1set.EQ.0) Then
1event=0
1cnt=l
Else If
(Iset.GE.1.AND.Iset.LE. 10)
Then
1 event* 1
1cnt=1set
ElsePrint *,*
Error, Iset
out of
range'
1test»-l
End If
CC -
Print quit message
CCall
wrtmsg(* Enter //
when done asslglng parameters to
& thIspolygon')
CDo 10 while(Itest.EQ.0)
plyval=parm(npoly,lent)
ulabel*label(lent)
Cquest=ulabel//' parameter'
1val=1rquest{quest,plyval,'(el5.8)',15)
168
If (fval.EQ.l) Then
parm(npoly,lent >«plyval
Else If
Mval.EQ.-l) Then
1test«-l
End If
1cnt«1cnt+l
If (1 e
vent.EO.l.OR.Icnt.GT.10.AND.1test.NE.-l)1test«l
10 End Do
ElseCall wrtmsg(* Error, npoly out of range')
1test=-l
End If
Return
End
r**«n
watt
- Watts for user to enter a
carriage return before
contInuIng.
>**********!
Subroutine wait
Character ans*l
Write (6,10)
10 Format (/,'
Enter a
carriage return <CR> to contInue:',$)
Read (5,20)ans
20 Format (al)
Return
End
walk
- Starting at the position of polygon NGON
In the tree
(topology array), WALK returns the node position of the
next polygon 1n
the tree.
The walk proceeds as follows:
(1) Move down the (sub)tree on the 'left* side, by
looking at 1down of the current position.
If this
Is not zero return this as the next polygon.
(2) When a polygon
Is not found 'below' the current
position (Idown
Is zero), look to the right of
this position and test:
(a) If
a polygon
1s found on the right, return
this polygon.
(b) If
a polygon
1s not found on the right, move
up a
level and reapply test (a).
(3) When no more polygons are found to the right and
above the current position, the tree has been
completely searched.
Variables:
next
ngon
=
Next polygon
1n tree
>0 =
a polygon exists
0 =
«_ree has been exhausted
Position 1n
tree where walk
Is to start
(ngon must be greater than zero).
169
C Itest *
Error flag
C 1
st Next polygon was found
C 0 *
No more polygons
C -1
» A value In
tree Is
less than 0.
CC Note: ngon and next are pointers to positions In
the
C topology arrays.
CC-(*
Subroutine walk(next,ngon,Itest)
Common /topology/ 1nfo(100),1 upper(100),1down(100),
& 11eft< 100) , 1
Mght< 100)
Common /commands/ nmax,eps11n,del1n,delout
Cnext*0
If (ngon.ge.1.and.ngon.le.nmax) then
npnt=ngon
next=1down(ngon)
If (next.GT.0) then
1test=lElse If
(next.EG.0) Then
next*1r1ght(ngon)
If <next.GT.0) Then
1test=lElse If
(next.EG.0) Then
1test2=0
1 = 1Do 20 wh11e(1test2.EQ.0)
npnt^lupperCnpnt)
If (npnt.GT.0) Then
next=1r1ght(npnt)
If (next.GT.0) Then
1test=l
1test2*l
Else If
(next.EG.0) Then
1test2=0
Else1test2=-l
1test=-l
print *,'
Error, Irlght was out of range (1r1ght<«0)'
End If
Else If
(npnt.EQ.0) Then
next=0
1test=0
1test2=l
Else1test=-l
1test2=-l
print *,'
Error,
1 up of ',npnt,' less than zero'
End If
1-1 + 1 If
(I.GT.nmax) Then
print *,*
Error,
1 (counter) was >',nmax
ltea.--l
1test2--l
End If
20
End Do
Elseprint *,'
Error, Irlght of
f,npnt,' was less than zero'
1test=-l
End If
Elseprint *,'
Error, Idown of ',ngon,' was less than zero'
1test«-l
End If
Elseprint *,'
Error, NGON passed to WALK out of range*
1test*-l
End If
CReturn
End C +£ **************************************************************
C wcbp - World coordinate byte packing.
Converts a world co-
C ordlnate pair Into the (hexadecimal) code required for
C the Envision terminal.
See wcbp.lnf and Envision manual
CC Author: Robert Slmpson, USGS, Menlo Park, CA, 10/83.
C-£ **************************************************************
Character*5 Function wcbp(1,j)
Character blank*!
Parameter (1max=l6284,jmax*16284)
Parameter
( 1m1n=*0, Jm1n=J0)Parameter (blank** ',Iblank* 1 c
har( '
')) C C
- Force 1,J
Into bounds...
11n»m1n(1max,max(Imln,1))
j1n-m1n(jmax,max(Jmln,J))
C - Get hi
and lo
bytes and offset with blank...
11o-mod(11n,64)+1b1ank
1med*11n/64+1blank
Jlo=mod(J1n,64)+1blank
Jmed« Jln/64-Hblank
C -
Put bytes together...
wcbp-blank//chart1med)//char(1lo)//char(Jmed)//char(Jlo)
CReturn
End
C +£
**************************************************************
C wrhead - Writes the header for a
standard grid (new version).
CC Author: Robert W.
Slmpson, USGS, Menlo Park, CA.
CC-^
**************************************************************
Subroutine wrhead(un1t,1d,pgm,nco1,nrow,nz,
&xo,dx,yo,dy,IproJ,cm,b1,1 test >
Character 1d*56,pgm*8
Integer unit
C1test*lWrite (un1t)1d,pgm,nco1,nrow,nz,xo,dx,yo,dy,IproJ,cm,bl
CReturn
EndC +Q
**************************************************************
C wrtgrd - WRlTe GRID
- Writes out wrkgrd as
a Denver standard
C grId f1le to 'name'.
C-^ **************************************************************
Subroutine wrtgrdfname,1 test)
Common /work /wrkgrd '. 2
50000 )
Common /gr1dspecs2/1d2,pgm2,nc2,nr2,nz2,xo2,dx2,yo2,dy2,
171
&1proJ2,cm2,b12
Character name*80,1d2*56,pgm2*8
C1test-l
pgm2«'polygon
* dummy=0.0
Open (11,f1le«name,status*'new',form» * u
nformatted')
Cal1 wrhead(11,1d2,pgm2,nc2,nr2,nz2,xo2,dx2,yo2,dy2,1proj2,
&cm2,b12,Itest)
If (Itest.GE.0) Then
Do 20
J«l,nr2
WrIte (11)dummy,(wrkgrd(1+(J-l)*nc2),t=l,nc2)
20 Continue
End If
Close (11)
C100
Continue
Return
End
C +£
*************************************************************
C wrtmod - Writes out a
Polyogn model file.
CCC-\*
Subroutine wrtmod(Itest)
Common /topology/1nfo(100),1 upper(100),1down(100),
&11eft(100),1r1ght(100)
Common /screenloc/ntotal,numply(100),xscr(100,100),yscr(100,100)
Common /parameter /parm(100,10)
Common /labels/label
Common /commands/nmax,eps11n,delIn,del out
Common /Junk/ngbtop,Jnktop(100),ngbloc,Jnk1oc(100)
Common /names/grdnam,modnam,modgrd
Common /gr I
dspecs/1d,pgm,nc,nr,nz,xo,dx,yo,dy,1proJ,cm,bl
Common /original/Iwcorg,Jwcorg,nxorgp,nyorgp
CCharacter 1abe1<10)* 15
Character Id*56,pgm*8,grdnam*80,modnam*80,modgrd*80
COpen (10,f1le=modnam,status-* unknown',forma * f
ormatted *,
Acarrlagecontrol*'1 1st')
CC - Write out the current parms assigned to standard grid header
C Information.
CC write (10,5) Id,pgm,nc,nr,nz
C5 format(x,a56,x,a8,3(x,13))
C write (10,10) xo,dx,yo,dy
C10
format(4(x,«15.8))
C write (10,15) 1proJ,cm,bl
CIS
format(x,13,2(x,e!5.8))
CC - Write out the number of
polygons
In the model and the
C labels assigned to the parm arrays.
CWrite (10,20)ntotal
20 Format (x, 13)
Write (10,25)(label(k),k»l ,5)
Write (10,25)(label(k),k=6,10)
25 Format (5(x,al5))
C - Write out the polygon number, the number of
points
in this
1 /jC
C polygon, the grid locations and the polygon parms.
Cdelxcn=dx/nxorgp
delycn^dy/nyorgp
Do 60 1=1,nmax
npolye1nfo(1)
If (npoly.GT.0> Then
nbrpts=numply(npoly)
Write (10,33)npo1y,nbrpts
33 Format (2<x,l3>)
Write
( 10,35)(parm(npo1y,kk),kk=l,5)
Write (10,35) (parm(npoly,kk),kk = 6
,10)
35 Format (5(x,el5.8))
Do 40
J= 1 .nbrpts
xgr1d*xo+((xscr(npoly,J)-Iwcorg)*delxcn)
ygr1dsyo+((yscr(npoly,J)-Jwcorg)*delycn)
Write (10,45>xgrId,ygrId
45 Format (2(x,el6.8)>
40 Continue
End If
60 Continue
CC - Write out the topology structure
CDo
70 ndpstn«l,nmax
Write (10,65)1nfo(ndpstn),1 upper(ndpstn),1down(ndpstn),
&1left(ndpstn),1r1ght(ndpstn)
65 Format (5(x,l3))
70 Continue
CClose (10)
1test»l
Return
End C +£ **************************************************************
C wrtmsg - Writes out a
text string to the terminal.
C-£ **************************************************************
Subroutine wrtmsg(text)
Character textM*)
C1leng-ltlen(text)
Write (6,10)text
10 Format (x,a<11eng»
CReturn
EndC +£
**************************************************************
C zomcom -
Zoom command mode.
Controls the function of
zooming
C and unzoomlnlng In
the grid.
CC
Options:
CC c
= Clear zoom stack
C d
= Draw the grid using a
zoom value selected from the
C stack.
C r
* Recall and draw the grid using the zoom values
C
currently pointed to In
stack by nzoom.
C s
- Select a
subgrld (using mouse, cursor, grid
C coords.)
C u
- Unzoom grid, draw full
grid on
screen (does nothing
1 "7 7
C to zoom values)
I / .3
h *
Help message
q * Quit and return to Polygon command level
Subroutine zomcom(If 1rst,1 test)
Character ans*2,quest"80,zcom*2,fIrstM
Common /subgrld/lcmln,Icmax,1rmln,1rmax,ncm1n,ncmax,nrm1n,nrmax
Common /scale/xsc,ysc,xstart,ystart,xIn It,yIn It
Common /zoom/Izoom,Izval,nzoom,ncmlnz(5),ncmaxz(5),nrm1nz(5),
&nrmaxz(5)
Common /sealefacts/1wc0,Jwc0,nxp1x,nyp1x, p1xd1m
Common /orIglnal/Iwcorg,Jwcorg,nxorgp,nyorgp
Common /flags/mcflag,votfIg
Common /model/mdflag
Common /colors/plyclr,black,wh1te
Common /f111/open,sol Id,f11typ
Character plyclr*!,black*l,white*!,open*l,sol1d*l,f11typ*1
Character mcflag*2,votflg*2
Call enhmsg('*** Zoom mode ****)
- Testing of Input variables goes here
zcom-'H'
Iflag-0
Do 10
whlleCIflag.EQ.0)
quest"' Zoom command (c/d/r/s/u/h/q) '
Ival81aquest(quest,zcom,'(a2)',-2 )
If (zcom.EQ.'C') Then
Call askans(ans)
If (ans.EQ.*Y') Then
Cal1 Intzom
Call setbnd
Else If
(ans.EQ.'Q*) Then
If lag«-l
End If
Else If
{zcom.EQ.'D') Then
If (nzoom.GE.l) Then
Cal1 zompck(Itest)
If (Itest.GE.0) Then
Call dtspla
Call scaleg2sc(0)
Call clrsgd(0,Itest)
xstart^ncmln
ystart»nrm1n
Call setbnd
End If
If (mdflag.EQ.1.AND.Itest.GE.0) Then
Call setclr(plyclr)
Call setfll(open)
Call drawwalk
Call setf IKsol Id)
End If
ElseWrite (6,50)
50
Format (/,'
Sorry, zoom stack
Is empty...',/)
End If
Else If
(zcom.EQ.'S') Then
If (IfIrst.EQ.1) Then
Cal1 tntscr
Call c1rsgd(1,Itest)
Cal1 clrply
174
xscsfloat{nxp1x)
yscsfIoat(nyp1x)
1wcorg=1wc0
Jwcorg-Jwc0
nxorgp«nxp1x
nyorgp«nyp1x
Call setbnd
End If
If (mdflag.EQ.LAND.IfIrst.EQ.l) Then
Call setclr{plyclr>
Call setfll(open)
Call drawvtjlk
Call self 11(sol Id)
End If
If 1rst«0
20
Continue
Call asktyp(Itype,Itest)
If {Itest.EQ.-l)Go To 30
If (nzoom.EQ.5)Ca11 zomstk(Itest)
If {Itest.EQ.-l)Go To 30
If Mtype.EQ.l) Then
Call getsublItest)
Else If
<Itype.EG.2) Then
Cal 1
asksub(Itest)
End If
If (Itest.EQ.1)1zoom*l
If (Itest.EQ.-l)Go To 20
30
Continue
If {Itest.GE.0) Then
Call dlspla
Cal1 sca1eg2sc(0)
Call c1rsgd(0,Itest)
xstart«ncm1n
ystart=nrmfn
Call setbnd
End If
If (mdflag.EQ.LAND.Itest.GE.0) Then
Call setclr<plyclr)
Call setftl(open)
Call drawwalk
Call self 11(sol Id)
End If
Else If
{zcom.EQ.'R') Then
If (nzoom.GE.l) Then
Call zomrcl(Itest)
If (Itest.GE.0) Then
Call dlspla
Call sca1eg2sc(0)
Call clrsgd(0,Itest)
Call clrply
xstart«ncm1n
ystart^nrmln
Call setbnd
End If
If (mdflag.EQ.1.AND.Itest.GE.0) Then
Call setclr(plyclr)
Call self 11(open)
Call drawwalk
Call self 11(sol Id>
End If
ElseWrite (6,50)
End If
Else If
(zcom.EQ.'IT )
Then
Call unzcomlItest)
Else If
(zcom.EQ.*H*) Then
Ca 1 1
hIpzom
Else If
(zcom.EQ.'Q'.OR.Ival.EQ.-l) Then
If1ag=-l
ElseCall errmsg
End If
zcom»'Q'
10 End Do
CIf
( Iflag.EQ.-l)1test--l
Return
End
C+
f A**************************************************************
C zompck - Allows the picking of a
selected zoom value from the
C zoom stack (If
any exist).
C-
Subroutlne zompck(ttest)
Common /zoom/I zoom,Izva1,nzoom,ncm1nz(5),ncmaxz(5),nrm1nz(5),
4nrmaxz(5)
Common /subgrtd/lcmln,1cmax,trmln,1rmax,ncmln,ncmax,nrm1n,nrmax
Character quest*80
CC call hlpzpk
C1test«0
Do 10
whlleCItest.EQ.0)
quest"' Stack position of zoom value (1-5, 0 or
// to quit)'
1val«t1quest(quest,1zva1,'<12)',0)
CIf
(Izval.GE.LAND.Izval.LE. 5)
Then
If (ncm1nz(Izval).EQ.0.AND.ncmaxz(Izval).EQ.0.AND.
& nrm1nz(Izval).EQ.0.AND.nrmaxzlIzval).EQ.0) Then
Write (6,15)
11 Format (/,'
Error, zoom values for this position not set',/)
Elsencm1n»ncmInz(Izval)
ncmax=ncmaxz(tzval)
nrmln*nrmlnz(Izval)
nrmax*nrmaxz(Izval)
Itest*1
End If
Else If
(Izval.EQ.0.OR.Ival.EQ.-l) Then
1test«-l
ElseCall errmsg
End If
10 End Do
CReturn
End
C +
C zomrcl
- Recalls the subgrld values from position nzoom
C In
the zoom stack.
C-
Subroutlne zomrcl(Itest)
Common /grIdspecs/Id,pgm,nc,nr,nz,xo,dx,yo,dy,IproJ,cm,b1
Common /subgrId/Icmln,tcmax,Irmln,Irmax,ncmln.ncmax.nrmln.nrmax
Common /zoom/1 zoom,Izval,nzoom,ncm1nz(5),ncmaxz(5),nrmlnz(5),
176
Jrn
rmaxz(5
) C
ha
rac
ter
1d
*56
,pg
m*8
If {n
zo
om
.GE
.1.A
ND
.nzo
om
.LE
.5)
Th
enn
cm
1n
«n
cm
1n
a(n
zoo
m)
ncmax=ncmaxz(nzoom)
nrm1n»nrm1nz(nzoom)
nrmax*nrmaxz(nzoom)
1test«l
Else If
(nzoom.EQ.0) Then
1test»0
ElseItest--!
End If
Return
End
i***izomstk - Controls the release of the zoom stack.
Called by
subroutine zomcom (ZOOM COMMAND)
If nzoom equals five,
Bottom of stack (oldest zoom values)
Clear stack (zeroes out zoom stack)
Top of stack (youngest zoom values)
Help message
Quit t.id
return to ZOOM COMMAND level.
nzoom *
Pointer to current position In
zoom stack
* 0 *
If zoom stack
Is empty.
otherwise ranges between
1 and 5.
k*************************************************************
Subroutine zomstk(Itest)
Common /zoom/Izoom,1zval,nzoom,ncmInz(5),ncmaxz(5),nrm1nz(5),
&nrmaxz(5)
Character quest*80,ans*2
1test«0
Cal1 msgstk
Call hlpstk
ans-'H'
Do 10
whl!e(Itest.EQ.0)
quest"' What method of stack release (b/c/t/h/q)'
1val"Iaques11 quest,ans,*(a2)',0)
If (ans.EQ.'B») Then
1test-l
Do 20 1>1,4
ncm1nz(1)»ncm1nz(1 + 1 )
ncmaxz(1)»ncmaxz( 1 + 1 )
nrmlnz(1)*nrm1nz( 1 + 1 )
nrmaxz(1)*nrmaxz(1 + 1 )
20
Continue
ncmlnzC 5 )
»0
ncmaxz(5 ) *0
nrmlnz(5)=0
nrmaxz(5 )»0
nzoom»4
Else If
(ans.EQ.'TM Then
ftest»l
ncmlnz(5)»0
ncmaxz(5)«0
\ "77
nrm1nz(5)»0
I /
/
occcccccc-c
nrmaxz(5)*0
nzoomM
Else If
(ans.EQ.'C') Then
Cal1 Intzom
1test-l
Else If
(ans.EQ.'Q'.OR.Ival.EQ.-l) Then
1test--l
Else If
(ans.EQ.'h") Then
Call hlpstk
ElseCall errmsg
End If
10 End Do
Return
End
zorcntr - Stores the values of ncm1n,ncmax,nrm1n,nrmax, used for
zooming,
tn the zoom stack at position nzoom.
See Intzom.for for a
description of the variables In
the zoom common block.
Subroutine zomstr(Itest)
Common /zoom/Izoom,Izval,nzoom,ncminz(5),ncmaxz(5),nrm1nz(5),
&nrmaxz(5)
Common /subgrId/Icmin,Icmax,Irmln,1rmax,ncm1n,ncmax,nrm1n
tnrmax
If" (nzoom.6C.If,AN6.nzoom.Lf.§) then
1test-l
nzoomanzoom+1
ncminz(nzoom)
ancm In
ncmaxz(nzoom)«ncmax
nrm1nz(nzoom)=nrm1n
nrmaxz(nzoom) nrmax
Else If
(nzoom.GE.5) Then
Call wrtmsgC' Zoom stack
Is full')
1test»-l
End If
Return
End
178