.he 'SEEPICTURE''Page %'
.fo 'Steven Hardy'- % -'February 1978'
SEEPICTURE
This function analyses and repaints TURTLE pictures in terms of
lines and junctions.
Set up a TURTLE picture and then type:
 	: SEEPICTURE();
 	: DISPLAY();
.br
Each marked point of the picture has been 'coded' as either part of a line
or as a junction between lines;
furthermore the paint used indicates what type of line or junction, viz
 	!  VRT,	a vertical line
 	-  HRZ,	a horizontal line
 	/  RHT, a right diagonal line
 	\\  LFT, a left diagonal line
 	e  END,	a free end
 	l  ELL,	an ell junction
 	f  FRK, a fork junction
 	a  ARW, an arrow junction
 	t  TEE,	a tee junction
 	c  CRS, a crossover junction
 	k  KAY, a kay junction
 	p  PSI, a psi junction
 	j  JNn, an unclassifiable junction
.br
.sp
SEEPICTURE also uses the DATABASE package to record its
findings, as you can see by typing:
 	: DATABASE ==>
.bb
.sp
By typing:
 	: SHOWLIB SEEPICTURE;
.br
you will see that SEEPICTURE performs three operations in turn:
.in +4
.sp
.ti-4
(a)#The first phase, called FINDLINES, searches the TURTLE picture for
straight lines whose
lengths exceed MINLINELENGTH (initially three) and records details
of these lines in the DATABASE.
FINDLINES 'breaks' lines at junctions so that a single lines
may give rise to several line records in the DATABASE.
For example, the picture:
 	5    *
 	4    *
 	3    *
 	2    *
 	1*********
 	 123456789
.br
would yield three lines, [1#1] to [5#1], [5#1] to [5#5] and
[5#1] to [9#1].
The items actually added to the DATABASE would be:
 	[LINE HRZ [1 1] [5#1]]
 	[LINE HRZ [5#1] [9#1]]
 	[LINE VRT [5#1] [5 5]]
.br
You not expect the two points associated with a line to be
in any particular order, that is the last line above might
just as easily have been described as:
 	[LINE VRT [5 5] [5 1]]
.sp
You can prevent this breaking of lines by setting the variable
BREAKLINES to FALSE, thus typing:
 	: FALSE -> BREAKLINES;
 	: FINDLINES();
.br
would yield only two lines [1#1] to [9#1] and [5#1] to [5#5].
.ti-4
.sp
(b)#the second phase, called FINDJUNCS, uses the DATABASE records
to classify the junctions indicated by the line records
(ie FINDJUNCS doesn't use the TURTLE picture).
FINDJUNCS classifies the junctions between the ends of lines
as represented in the DATABASE. For the above picture it
would yield three ENDs and one TEE. (If BREAKLINES was FALSE it
would not detect the TEE and so produce four ENDs).
The output of FINDJUNCS is stored as a set of records in the DATABASE
like that of FINDLINES.
The items added here would be:
 	[JUNC ELL [1 1] [5#1]]
 	[JUNC ELL [5 5] [5#1]]
 	[JUNC ELL [9#1] [5#1]]
 	[JUNC TEE [5#1] [9#1] [5#1] [1 1]]
.br
The points at the other ends of lines radiating away from the junction
are given in clockwise order, starting with the point following the
largest angle, thus:
 	[JUNC TEE centre barb stem barb]
 	[JUNC ARW centre barb stem barb]
.sp
.ti-4
(c)#The final phase, PAINTPICTURE, merely repaints the TURTLE picture according to
to the information stored in the DATABASE.
.in-4
.sp
We can represent the whole process schematically:
 	A TURTLE picture
 		is processed by
 	FINDLINES
 		to yield
 	DATABASE items representing lines
 		which are processed by
 	FINDJUNCS
 		which yields
 	DATABASE items representing junctions
 		which, with the output of FINDLINES, is processed by
 	PAINTPICTURE
 		to give a TURTLE picture
