Tải bản đầy đủ
APPENDIX E.4: 3-D OPEN MESH COMPUTER PROGRAM “GRAPH-E4”

APPENDIX E.4: 3-D OPEN MESH COMPUTER PROGRAM “GRAPH-E4”

Tải bản đầy đủ

174

APPENDICES

See the notes for section (b) of Appendix D.2.
(c) Digital ground model data

Line numbers 200–440

See the notes for section (c) of Appendix E.2.
(d) 3-D open mesh display

Line numbers 4000–4330

This is the main part of the program and will display an open mesh diagram. The mesh is drawn from back to front so that
any old plotting underneath a new mesh segment is removed using the PAINT command.
This program also requires the routines (l)–(u), with the exception of (m) and (p) as listed for Appendix E.1.
“GRAPH-E4”—BASIC program

10 REM Presentation Graphics Appendix E.4 - 3D Graphs
14 REM (C) Copyright P.H.Milne 1990 - Open Mesh
16 REM ALL RIGHTS RESERVED
20 REM VERSION PC-1.00, 23/05/90: **** Maximum 50,50 Data ****
30 CLEAR
40 ON ERROR GOTO 10000
50 PCF$ = "PGSCRDSK.PGD"
60 DIM Z(50, 50), CL%(15)
70 GX0 = 70: GY0 = 50: A$ = "*": DATBX = 0
80 GOSUB 8000: REM Check Screen & Disc
90 WINDOW (0, 0) - (639, 199)
100 PC$ = "3D Surfplot"
110 GOSUB 8200: REM Check ID File and DATA
120 LOCATE 15, 10: PRINT "Number of Rows = "; NROW
130 LOCATE 17, 10: PRINT "Number of Columns = "; NCOL
140 LOCATE 20, 10: PRINT "Do you wish to VIEW Graph (Y/N) ";
145 A$ = INPUT$(1)
150 IF INSTR("YNyn", A$) = 0 THEN 140
160 IF A$ = "N" OR A$ = "n" THEN 9600
170 SRX% = 2: SRY% = 1
180 IF SCR% = 2 THEN SRH% = 2 ELSE SRH% = 1
200 CLS: GOSUB 9000
210 LOCATE 6, 10: PRINT "Digital Ground Model - "; DFILEN$
220 LOCATE 10, 10: PRINT "X-AXIS : Min = "; XMIN
230 LOCATE 10, 40: PRINT ": Max = "; XMAX
240 LOCATE 12, 10: PRINT "Y-AXIS : Min = "; YMIN
250 LOCATE 12, 40: PRINT ": Max = "; YMAX
260 LOCATE 14, 10: PRINT "Z-AXIS : Min = "; ZMIN
270 LOCATE 14, 40: PRINT ": Max = "; ZMAX
400 LOCATE 20, 10: PRINT "Display Open Mesh (Y/N) ";
410 A$ = INPUT$(1)
420 IF INSTR("YNyn", A$) = 0 THEN 400
430 IF A$ = "N" OR A$ = "n" THEN 9600
440 GOSUB 8500: CLS

3-D CHARTS AND SURFACE MODELS

3995
4000
4001
4003
4005
4007
4010
4020
4030
4035
4040
4050
4060
4070
4090
4100
4110
4115
4120
4130
4135
4140
4150
4155
4160
4170
4175
4180
4190
4200
4210
4220
4230
4240
4250
4260
4270
4271
4275
4276
4277
4278
4280
4285
4286
4287
4288
4290
4295

REM ***** Screen Plotting Routine *****
DISP% = 1: YCEN = 0: XCEN = 0
SX = 160 * SRX%: SY = 100
IF SCR% <> 2 THEN RGB% = 2 ELSE RGB% = 12
IF SCR% <> 2 THEN 4010
SCREEN 9: COLOR 15, 0
VIEW SCREEN (5, 30) - (310 * SRX%, 150 * SRH%), 0, RGB%
WINDOW (XCEN − SX, YCEN − SY) - (XCEN + SX, YCEN + SY)
VEX = 50 / (ZMAX − ZMIN)
YSMIN = INT((ZMIN * VEX) / 10) * 10 + 5
X0 = −10 * SRX%: Y0 = (70 − YSMIN) * SRY%
CLS : YLAB$ = "V"
GOSUB 9000: GOSUB 7500
S = 2: B = 2.5 * SRX%
FOR GCOL = 1 TO NCOL − 1
FOR GROW = 1 TO NROW − 1
X1 = X0 + (GCOL − GROW) * B
GRC1 = (GROW + GCOL) * S
Y1 = Y0 + (Z(GROW, GCOL) * VEX − GRC1) * SRY%
X2 = X1 − B
GRC2 = (GROW + GCOL − 1) * S
Y2 = Y0 + (Z(GROW, GCOL − 1) * VEX − GRC2) * SRY%
X3 = X1 + B
GRC3 = (GROW − 1 + GCOL) * S
Y3 = Y0 + (Z(GROW − 1, GCOL) * VEX − GRC3) * SRY%
X4 = X1
GRC4 = (GROW − 1 + GCOL − 1) * S
Y4 = Y0 + (Z(GROW − GCOL − 1) * VEX − GRC4) * SRY%
LINE (X1, Y1) - (X2, Y2), 4
LINE − (X4, Y4), 4: LINE − (X3, Y3), 4
LINE − (X1, Y1), 4
Y = (Y1 + Y4) / 2
PAINT (X4, Y), 0, 4
LINE (X1, Y1) − (X2, Y2), 15
LINE − (X4, Y4), 15: LINE − (X3, Y3), 15
LINE − (X1, Y1), 15
NEXT GROW, GCOL
NROW = NROW − 1: NCOL = NCOL − 1
X1 = X0 + (−NROW) * B
Y1 = Y0 + ((−NROW) * S + Z(NROW, 0) * VEX) * SRY%
X2 = X0 + (−NROW) * B
Y2 = Y0 + ((−NROW) * S + YSMIN) * SRY%
LINE (X1, Y1) - (X2, Y2), 15
X1 = X0 + (NCOL − NROW) * B
Y1 = Y0 + (−(NCOL + NROW) * S + Z(NROW, NCOL) * VEX) * SRY%
X2 = X0 + (NCOL − NROW) * B
Y2 = Y0 + (−(NCOL + NROW) * S + YSMIN) * SRY%
LINE (X1, Y1) − (X2, Y2), 15
X1 = X0 + (NCOL) * B

175

176

APPENDICES

4296
4297
4298
4300
4305
4306
4307
4308
4310
4317
4318
4320
4330

Y1 =
X2 =
Y2 =
LINE
X1 =
Y1 =
X2 =
Y2 =
LINE
X2 =
Y2 =
LINE
GOTO

Y0 + ((−NCOL) * S + Z(0, NCOL) * VEX) * SRY%
X0 + (NCOL) * B
Y0 + ((−NCOL) * S + YSMIN) * SRY%
(X1, Y1) − (X2, Y2), 15
X0 + (−NROW) * B
Y0 + ((−NROW) * S + YSMIN) * SRY%
X0 + (NCOL − NROW) * B
Y0 + (−(NCOL + NROW) * S + YSMIN) * SRY%
(X1, Y1) − (X2, Y2), 15
X0 + (NCOL) * B
Y0 + ((−NCOL) * S + YSMIN) * SRY%
− (X2, Y2), 15
9500
COMPUTER PROGRAM “GPLOT-E4”

To convert the program “GRAPH-E4” from screen graphics to an HPGL plotter take the previous plotter program
“GPLOT-E3” and make the following changes:
replace “E3” with “E4” on Lines 10 and 9580
replace “3D Profile” with “3D Surfplot” on Lines 14 and 100
replace “3D Profile” with “Open Mesh” on Line 400
add to segment (d) the code for Lines 4190–4272, which are given at the end of this section
“GPLOT-E4”—BASIC program—addition to segment (d) only
4190
4195
4200
4210
4220
4225
4230
4235
4240
4245
4250
4260
4270
4271
4272

FOR GROW − 0 TO NROW − 1: TSEC = 1: GOSUB 60000
PRINT #3, "PU;": GOSUB 60000: TSEC = 0
FOR GCOL = 0 TO NCOL − 2
X1 = X0 + (GCOL − GROW) * B
Y1 = Y0 + (Z(GROW, GCOL) * VEX − (GROW + GCOL) * S) * SRY%
Y1 = INT(Y1 * 10 + .5) / 10
X2 = X0 + (GCOL + 1 − GROW) * B
GRC2 = (GROW + GCOL + 1) * S
Y2 = Y0 + (Z(GROW, GCOL + 1) * VEX − GRC2) * SRY%
Y2 = INT(Y2 * 10 + .5) / 10
PRINT #3, "PA"; X1; ","; Y1; ";"
PRINT #3, "PD;PA"; X2; ","; Y2; ";"
NEXT GCOL
GOSUB 60000
NEXT GROW

3-D CHARTS AND SURFACE MODELS

177

APPENDIX E.5:
3-D SHADED MESH COMPUTER PROGRAM “GRAPH-E5”
This program was described in Section 5.3.4, and can be used to display either topographic (‘.CON’) or surface (‘.EQD’)
data files. This program is an extension of the 3-D open mesh program to colour shade each mesh segment depending
on its average height in the digital ground model.
3-D shaded mesh
See notes (a)–(d) for Appendix E.4. This program also requires routines (j)–(u), with the exception of (k), (m) and (p)
in Appendix E.1. An additional routine, listed in Appendix A.13 is also required at Line 7800.
“GRAPH-E5”—BASIC program

10 REM Presentation Graphics Appendix E.5 - 3D Graphs
14 REM (C) Copyright P.H.Milne 1990 *** - Shaded Mesh ***
16 REM ALL RIGHTS RESERVED
20 REM VERSION PC-1.00, 1990: **** Maximum 50,50 Data ****
30 CLEAR
40 ON ERROR GOTO 10000
50 PCF$ = "PGSCRDSK.PGD"
60 DIM 2(50, 50), CL%(15)
70 GX0 = 70: GY0 = 50: A$ = "*": DATBX = 0: SR% = 2
80 GOSUB 8000: REM Check Screen & Disc
90 WINDOW (0, 0) - (639, 199)
100 PC$ = "3D Surface"
110 GOSUB 8200: REM Check ID File and DATA
120 LOCATE 15, 10: PRINT "Number of Rows = "; NROW
130 LOCATE 17, 10: PRINT "Number of Columns = "; NCOL
140 LOCATE 20, 10: PRINT "Do you wish to VIEW Model (Y/N)"
145 A$ = INPUT$(1)
150 IF INSTR("YNyn", A$) = 0 THEN 140
160 IF A$ = "N" OR A$ = "n" THEN 9600
200 CLS: GOSUB 9000
210 LOCATE 6, 10: PRINT "Digital Ground Model - "; DFILEN$
220 LOCATE 10, 10: PRINT "X-AXIS : Min = "; XMIN
230 LOCATE 10, 40: PRINT ": Max = "; XMAX
240 LOCATE 12, 10: PRINT "Y-AXIS : Min = "; YMIN
250 LOCATE 12, 40: PRINT ": Max = "; YMAX
260 LOCATE 14, 10: PRINT "Z-AXIS : Min = "; ZMIN
270 LOCATE 14, 40: PRINT ": Max = "; ZMAX
340 XTC = (XMAX − XMIN) / 10
350 TCC = XTC: GOSUB 7100
360 XTC = TCC: XM = 360
370 YTC = (ZMAX − ZMIN) / 5
380 TCC = YTC: GOSUB 7100
390 YTC = TCC: YM = 60
400 LOCATE 20, 10: PRINT "Display 3D Surface (Y/N) ";
410 A$ = INPUT$(1)

178

APPENDICES

420 IF INSTR("YNyn", A$) = 0 THEN 400
430 IF A$ = "N" OR A$ = "n" THEN 9600
440 GOSUB 8500: REM Read Text Title Data from Disc
3995 REM ***** Screen Plotting Routine *****
4000 GX = GX0: GY = GY0: YCEN = 0: XCEN = 0
4001 SX = 160 * SR%: SY = 100 * SR%
4005 SCREEN 9: COLOR 15, 0
4010 VIEW SCREEN (5, 30) - (310 * SR%, 150 * SR%), , 12
4050 CLS : GOSUB 9000: GOSUB 7500
4060 IF GSC = 1 THEN 4090
4063 NOCL = 13: RGB% = 15
4065 C$ = "1314051204101102030901060815"
4066 FOR I = 0 TO NOCL
4067 CL%(I) = VAL(MID$(C$, I * 2 + 1, 2))
4068 NEXT I
4070 TCC = (ZMAX − ZMIN) / 14
4075 GOSUB 7100
4078 HC = INT(ZMAX / TCC) * TCC: LC = INT(ZMIN / TCC) * TCC
4080 NOCL = (HC − LC) / TCC
4081 GOSUB 7800
4082 VIEW SCREEN (5, 30) - (258 * SR%, 150 * SR%), , 12
4083 WINDOW (XCEN − SX, YCEN − SY) - (XCEN + SX, YCEN + SY)
4084 VEX = 50 / (ZMAX − ZMIN)
4085 YSMIN = INT((ZMIN * VEX) / 10) * 10 + 5
4086 X0 = −30 * SR%: Y0 = (70 − YSMIN) * SR%
4088 GSC = 1
4090 S = 2: B = 2.5 * SR%
4095 FOR GCOL = 1 TO NCOL − 1
4100 FOR GROW = 1 TO NROW − 1
4110 X1 = X0 + (GCOL − GROW) * B
4115 GRC1 = (GROW + GCOL) * S
4120 Y1 = Y0 + (Z(GROW, GCOL) * VEX − GRC1) * SR%
4130 X2 = X1 − B
4135 GRC2 = (GROW + GCOL − 1) * S
4140 Y2 = Y0 + (Z(GROW, GCOL − 1) * VEX − GRC2) * SR%
4150 X3 = X1 + B
4155 GRC3 = (GROW − 1 + GCOL) * S
4160 Y3 = Y0 + (Z(GROW − 1, GCOL) * VEX − GRC3) * SR%
4170 X4 = X1
4175 GRC4 = (GROW − 1 + GCOL − 1) * S
4180 Y4 = Y0 + (Z(GROW − 1, GCOL − 1) * VEX − GRC4) * SR%
4181 ZAV = Z(GROW, GCOL) + Z(GROW, GCOL − 1) + Z(GROW − 1, GCOL)
4182 ZAV = (ZAV + Z(GROW − 1, GCOL − 1)) / 4
4183 CLOR = INT((HC − ZAV) / TCC) + 1
4190 LINE (X1, Y1) - (X2, Y2), CL%(CLOR)
4200 LINE − (X4, Y4), CL%(CLOR): LINE − (X3, Y3), CL%(CLOR)
4210 LINE − (X1, Y1), CL%(CLOR)
4220 Y = (Y1 + Y4) / 2
4230 PAINT (X4, Y), CL%(CLOR), CL%(CLOR)