home *** CD-ROM | disk | FTP | other *** search
-
-
- DOCUMENTATION FOR CONTOUR.C
-
-
- PURPOSE: To produce a plot of contour lines using ASCII characters for
- a series of specified contour levels. Input elevation data is specified
- as a series of grid points at specified grid line spacings.
-
- REFERENCE: BYTE magazine article titled "A Contouring Subroutine" by
- Paul D. Brourke in the June, 1987 issue. The main subroutine of this
- program is written in BASIC. It has been converted to C language and
- modified. The reader is referred to the BYTE magazine article for a
- detailed description of the algorithms operation.
-
- GENERAL PROGRAM DESCRIPTION: The user prepares an ASCII text file
- contaning the offsets of the x-direction grid lines, the offsets of y-
- direction grid lines, the contour lines desired, and the elevation level
- for each x-y grid line intersection. The grid line offsets must be in
- ascending order. Comments may be included in the textfile as long as
- they are enclosed in curly braces.
-
- Here is an example input file named <CONTOUR3.INP>
-
-
- 0.0 2.6 6.0 9.0 {X-Node Values }
- 0.0 1.0 2.0 3.0 4.0 5.0 {Y-Node Values }
- 5.0 8.9 {Contour Levels-1..nc }
-
- {
- Data array - Elevations at grid intersections - A few grid coordinates
- are shown to illustrate the grid layout.
- }
-
- 3 5 8 9 {9,5}
- 4 5 9 10
- 5 5 8 11
- 4 5 9 10
- 3 5{2.6,1} 10 11
- 3{0,0} 3 3 4
-
-
- This is the output directed to an ASCII file:
-
-
- *----------------------------------------------------------------------*
- | + |
- | +++++++ ++++++ |
- | ++++++ +++++ |
- | +++ +++++++ |
- | ++++ +++++++ |
- | + ++ |
- | + ++ |
- | + +++ |
- | + + |
- | +++ + |
- | +++ +++ |
- | + ++ |
- | +++ ++++ |
- | ++ +++ |
- | +++ + |
- | ++ ++ |
- | ++ + |
- | + +++++++++++ |
- | ++++++++++ +++++++++++++++++++|
- | +++ |
- | ++++++++++++++++++++++++++++++++++++|
- | |
- *----------------------------------------------------------------------*
-
-
-
- USER INTERFACE DESCRIPTION: The program is executed by entering
- "CONTOUR". The user is then prompted for the file name of the input data
- file. The file nane where the data is stored (i.e. INPUT.INP) is then
- entered. The program will execute and plot the specified contours on the
- terminal display. After the plot is complete, the user is queried to
- determine if a copy is desired. If the response is 'yes', the user is
- prompted for an output file name. After the name is provided the
- displayed contour plot is sent to the requested file. If no plot is
- desired the program exits to the operating system.
-
- A. INPUT FILE DESCRIPTION: The ASCII file to be read by CONTOUR.EXE can
- be typed up using a separate text editor. The file must be arranged as
- follows:
-
-
- Data
- Line No. Data description
- ------- -----------------------------------------------------------
-
- 1 A consecutive list of the offsets to each x-direction grid
- line from the origen separated by spaces or tabs. The origen is
- the lower left corner of the finished plot and the x-direction
- grid lines run from the bottom of the plot to the top. Positive
- offsets are to the right of the origen. The offsets must be in
- ascending order.
-
-
- 2 A consecutive list of y-grid line offsets. Positive grid
- offsets are above the origen. The offsets must be in ascending
- order and separated by spaces or tabs.
-
-
- 3 A consecutive list of contour levels to be plotted. They must
- be in ascending order and separated be spaces or tabs. The
- contour levels are interpolated from the grid intersection
- f(x,y) values provided starting with data line 4.
-
-
- 4 Grid intersection f(x,y) value matrix. The lower left value in
- the matrix is the f(x,y) value for the matrix. The number of
- ..to.. rows in the matrix (#rows) must be equal to the number of values
- provided in data line 2. The number of columns in the f(x,y)
- #rows matrix should be equal to the number of values provided in data
- line 1.
-
- NOTE: Lines containing only comments or which are blank
- are not counted.
-
-
- PROGRAM LIMITATIONS: This program is not universally applicable to all
- situations encountered. It's primary limitation is related to the
- plotting of contour lines which fall exactly on the established grid
- lines. If a calculated vector falls on the grid line, no vector is
- generated which leaves a gap in the contour line when plotted. In the
- real world this does not happen very often and does not present much of
- a problem. It can be generally be avoided by making sure the contour
- values input at grid points are not entered to coincide with any
- specified contour levels. At any rate the output file can easily be
- dressed up in a text editor if desired.
-
-
- VARIABLE DESCRIPTIONS:
-
- iub : Grid count in the x-direction
- jub : Grid count in the y-direction
- nc : No. of contours to be input
- prmerr : Error flag for checking input
- f(x,x_col,VCT) : Vector to store x-grid values (MAT_LIB array)
- f(y,y_row,VCT) : Vector to store y-grid values (MAT_LIB array)
- f(d,x_col,y_row) : Array to store grid pt. values(MAT_LIB array)
- f(z,contour_no,VCT) : Vector to store plot contours (MAT_LIB array)
- x1 : Start x-coordinate for pt.
- x2 : Start y-coordinate for pt.
- y1 : End x-coordinate for pt.
- y2 : End y-coordinate for pt.
- h [5] : Pt. values for a grid square
- xh [5] : X-coord. for a grid square
- yh[5] : Y-coord. for a grid square
- ish[5] : Above/below flags for a grid square
- caseval : Case which controls plot coordinate
- m1 : Pt. 1 for a triangular segment
- m2 : Pt. 2 for a triangular segment
- m3 : Pt. 3 for a triangular segment
- dmin : Highest f(x,y) value for a grid square
- dmax : Lowest f(x,y) value for a grid square
-