home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Current Shareware 1994 January
/
SHAR194.ISO
/
graphuti
/
polyops.zip
/
POLYOPS.DOC
< prev
next >
Wrap
Text File
|
1993-08-06
|
4KB
|
71 lines
POLYOPS
This program calculates the intersection, union or difference of two
plane regions bounded by polygonal simple closed curves, using the
algorithms described by Margarit and Knott, Comput. & Graphics, v.13,
nunber 2, 1989. Data may be input graphically, from data files, or from
the keyboard, and the results may be displayed graphically or listed to
the screen or to a disk file. Source code is included; some of thee
supporting routines use special features of Turbo C, but the main
algorithm, polycalc.c, should be acceptable to any ANSI C compiler.
POLYOPS requires an IBM PC compatible computer with 640K RAM, and an
EGA/VGA graphics board with 256K memory.
Keyboard input is made in response to more or less self-explanatory
prompts; the numbers entered must be separated by spaces, commas, or
other non-numeric characters, but there is little restriction on format;
e.g., (x0,y0), (x1,y1),... or x0,y0; x1,y1;... or x0 y0 x1 y1... or
any combination of these is acceptable.
The demonstration program assumes that all input polygons lie in the
region [0,1]x[0,1], and any data files used should be normalized to
these limits. A data file should be an ASCII file containing the number
of vertices of the polygon A, all the x-coordinates of these vertices,
then all the y-coordinates, followed by the same information for B. The
file POLY.DAT contains 16 more or less random examples, which are named
"pdat1" ... "pdat16". These names may be used directly, since the demo
program automatically searches POLY.DAT if a file name starting 'pdat'
is given.
Input from the graphics screen is a little more complicated. The cursor
may be moved with the arrow keys or diagonally by PgUp, PgDn, End, Home.
The amount of movement is normally 10 screen pixels, but this may be
increased or decreased with the +/- keys. Increments of 1, 10, or 100
pixels are available. The current cursor position is marked as a vertex by
pressing Ins, which will also result in a line being drawn to this vertex
from the previous one, if any. Entry of a polygon is completed by pressing
Enter, which also closes up the figure, joining the final vertex to the
initial one (thus it is not necessary to move the cursor to the starting
point to finish the polygon). If the program detects an active mouse
driver, you may use the mouse for entry if desired, using the left button
to mark points and the right button to close up the polygon. (Mouse entry
is usually faster but not as accurate.) During the entry process, pressing
Del will delete the last vertex drawn (and erase the side to it), and Esc
will abort the whole entry process. The current cursor coordinates
(scaled to the range [0,1]) are displayed in the lower right of the screen.
These are only approximate values, so text or file entry should be used
if specific polygons are needed.
Output curves are of two types, 'island' and 'hole'. The names indicate
the function rather clearly. In the graphics display, islands are yellow,
holes are blue.
The output curve data files are text files which include the number of
curves and the type (island or hole) of each. Their vertices are in
floating point form (4 decimals in disk files, 1 decimal on the screen).
Little checking of input is done; all entry processes allow unacceptable
"polygons" to be input. The program will reject polygons which are not
simple (i.e., with repeated vertices or crossing sides), but most likely
will give erroneous results, or none at all, if the input polygons are
irregular in some other way.
The files listobjs and listlibs may be used in linking the necessary
modules and libraries.
Questions or comments should be sent to B. J. Ball, 3304 Glen Rose Drive,
Austin, Texas, 78731 (Compuserve 71141,2321).