GRAPHIC DISPLAY SYSTEMS

Abstract: A method of determining the coincidence of a subject area and a clip area in a graphic display system, comprising creating three parts list, one for parts of the subject area that are outside the clip area, a second for parts of the clip area that are inside the subject area and a third for overlapping lines. The parts of the subject area which lie outside the clip area are defined by examining the parts lists. The output can then be used to control a pen plotter, in which different colours are used so that underlying areas do not have to be inked over with overlay colours.

Description: This invention relates to graphic display systems and in particular to such systems that include a pen plotter as an output device for pictures developed in the system. An interactive graphic display system such as the chart utility of the IBM Graphics Display Data Manager (GDDM) which is described in EU patent publication 26266 gives a user the ability to create graphic pictures on a display screen such as an IBM 3279. (IBM is a Registered Trade Mark). Once created it is often desirable to have a hardcopy of the picture and pen plotters connected to the system are commonly used for this purpose. Pen plotters provide a cheap, high quality graphics hard copy capability. However the technology differs from that of a cathode ray tube display in one significant way, once something is drawn, it cannot be erased or changed. This difference presents a problem where, say, a red square is drawn over a larger blue square. On a display, the underlying blue pels are simply changed to red pels, but on a plotter, the red will be drawn over the blue and a muddy brown colour will result. To provide quality output on plotters, it is therefor necessary to alter any underlying areas by clipping out any overlying areas. When the clipped underlying area is drawn and shaded, it will leave blank paper where the overlying areas will subsequently be drawn, resulting in a much more acceptable plot. Various methods for area clipping have been published. "Reentrant Polygon Clipping", Ivan E. Sutherland & Gary W Hodgman Comm. of ACM Jan 1974 V17 no. 1 p.32-42 describe a simple method for clipping a concave polygon to a convex area. This requires a concave clip area to be divided into convex polygons thus increasing the complexity of the calculations. "Hidden surface removal using polygon area sorting" Kevin Weiler & Peter Atherton Siggraph 77 proceedings Computer Graphics 11(2) Summer 77 p.214 describe another method for clipping concave polygons with holes, but this requires the polygons to be defined in a clockwise direction and holes in an anti-clockwise direction. The method of the present invention places no restrictions on the area definitions. Both the subject and clip areas may consist of multiple, overlapping, self-intersecting polgyons. The inside of an area is defined as all points that would cross the area boundary an odd number of times if moved along a straight line to infinity. It is an object of the invention to provide a method for one area definition to be clipped to another area definition. The method also finds use with regard to quality plotting in: Implementing 'background' lines by treating each background line as a thin area of width twice that of the pen. These can then be clipped out of any parts of the picture that they overlay. When plotting on foils, a common problem is ink run, for example where two areas abut and are coloured differently, because the ink takes a long time to dry, the two colours blend into each other along the boundary. This can be solved by shrinking the areas by one pen width. The easiest way to do this for an arbitrary area definition is to define a thin area of twice the pen width that goes around the boundary of the area, and clip this out of the original area. According to the present invention there is provided a method of determining the coincidence of a subject area and a clip area, each comprising one or more, possibly overlapping, self-intersecting, polygons in a graphic display system in which area definitions are stored in a display list store comprising the steps of: a) creating and storing a subject area parts list comprising separate entries for each part of one or more contiguous lines of the subject area that do not pass through the clip area b) creating and storing a clip area parts list comprising separate entries for each part of one or more contiguous lines of the clip area that pass through the subject area c) creating and storing an overlap parts list comprising separate entries for each part of one line of both the subject and clip areas in overlap d) for each entry in the subject area parts list scanning unprocessed entries first in the subject area parts list secondly in the clip area parts list thirdly in the overlap parts list for an entry having an end point definition the same as an end point definition of the part being processed, creating a new part by joining any part found to the part being processed storing the created part in a results part list and reiterating the process for the entry in the results part list until no further parts are found whereby the results part list includes the definition of the portion of the subject area which does not coincide with the clip area. According to a second aspect of the invention there is provided a graphic display system, in which area definitions are stored in a display list store, including control means adapted to control the operation of the system to perform the method of determining the coincidence of a subject area and a clip area each comprising one or more, possibly overlapping, self-intersecting, polygons, comprising the steps of: a) creating and storing a subject area parts list comprising separate entries for each part of one or more contiguous lines of the subject area that do not pass through the clip area b) creating and storing a clip area parts list comprising separate entries for each part of one or more contiguous lines of the clip area that pass through the subject area c) creating and storing an overlap parts list comprising separate entries for each part of one line of both the subject and clip areas in overlap d) for each entry in the subject area parts list scanning unprocessed entries first in the subject area parts list secondly in the clip area parts list thirdly in the overlap parts list for an entry having an end point definition the same as an end point definition of the part being processed, creating a new part by joining any part found to the part being processed storing the created part in a results part list and reiterating the process for the entry in the results part list until no further parts are found whereby the results part list includes the definition of the portion of the subject area which does not coincide with the clip area. In order that the invention may be fully understood it will now be described with reference to the accompanying drawings in which: Figs. 1-4 illustrate the operation of the method by way of example. Fig. 5 illustrates the component procedures of the method. Fig. 6 is a block schematic of a system in which the method can be implemented. The method embodying the invention will clip a 'subject area' to a 'clip area' producing a result that is an area defining all parts of the subject area that are outside the clip area. If necessary, the method is easily changed to clip the other way around, i.e. to produce a definition of the parts of the subject area that are inside the clip area. Each area definition is represented by a list of polygon definitions, each polygon definition is represented by a ring of vertices. The resultant area definition is in the same format so that it can be further clipped to other areas if required. The method involves building three lists. One (the subject parts list) contains the parts of the subject area boundary that are outside the clip area. The second (the clip parts list) contains the parts of the clip area boundary that are inside the subject area, and the third all clip area boundary lines that overlap subject area boundary lines (referred to as: 'overlapping' clip parts). Each list is built up by considering each line in the area and clipping it to the inside/outside of the other area. This requires a line clipping routine that can clip an arbitrary line to an arbitrary area definition. In particular it must cope with lines that (i) - may intersect the area at a vertex, (ii) may overlap one (or more) of the area boundary lines; and areas that may consist of multiple overlapping, self-intersecting polygons. Such a routine is described below. The resultant area definition is produced by joining the parts in the three lists together to form polygons. The joining process proceeds by taking a subject part and attempting to join it, 1st : to a non-overlapping clip part, 2nd : to another subject part, and 3rd : to an overlapping clip part. Thus the subject part is extended, and the total number of parts is reduced. When a polygon is formed, it is removed from the subject parts list and added to the resultant area definition. This process continues for each subject part until there are none left. Finally, any remaining clip parts are joined (where possible) in an attempt to form more polygons. These polygons are added to the resultant area definition unless they were formed only from overlapping clip parts. In this case, it is determined whether this polygon (which is common to both subject and clip areas) has the same sense (hole or solid) in both the subject and clip areas. The polygon is only added to the result if its sense is different in the subject and clip areas. In the rare situation of clipping to a self intersecting area with many boundary lines that are common or overlap the subject boundary, it is possible that after joining various parts, a dead end is reached, i.e. no part can be found that will join. This situation may occur when there are two or more overlapping clip parts that can be joined to the subject part, and the wrong one happens to be chosen. This occurs very infrequently and the simplest solution is to shift the subject area by a tiny amount in the x and y direction, then restart the clipping process. Figures 1 to 4 illustrate the method by way of example. A complex polygon such as shown in 1 (a) is displayed on a display screen. This may be part of a graph for example. A second area shown at 1 (b) is to be overlaid on the area of 1 (a) to give the result shown in Fig. 1 (c). It is then necessary to clip the shaded area of 1 (b) from the area of 1 (a). Figures 2a and 2b illustrate the contents of a subject parts list. Figures 3a and 3b illustrate the contents of a clip parts list. Figure 4a and 4b illustrate the contents of an overlap parts list. Of course all lines and parts are actually stored in the form of end point coordinates and the drawings are used for illustration only. In general terms the first step is for all lines of the subject area to be examined to determine whether or not they pass through the clip area. Starting at the top left corner line 10 has a portion 11 which overlaps the clip area. This is added to the overlap parts list (Fig. 4a). The second portion 12 is added to the subject parts list Fig. 2. The lines 13, 14, 15 and 16 are then examined and are added to the subject parts list. As each has a common coordinate with the previous line a complex part is developed. The line 18 has a portion 19 which passes through the clip area and portions 17 and 20 which do not. The portion 17 is added to the complex part 2 (a) in the subject parts list, the portion 19 is ignored and the portion 20 starts a new part in the subject parts list. The line 21 is added to the part 20 in the subject parts list and the line 22 is added to the overlap parts list (4 (b)). The clip area is then examined for lines that pass through or are contained in the subject area. The line 11 is already in the overlap parts list. Line 23 has two parts portion 24 is added to the clip parts list and portion 25 is ignored as is portion 27 of line 26. However portion 28 and portion 29 of line 30 are added to the clip parts list (3 (b)). Portion 22 of line 29 is already in the overlap parts list. In order to build the subject area minus the clip area, the first entry in the subject parts list is examined and then in the following order remaining entries in the clip parts list and then the overlap parts list are examined to determine the first that has a common end point coordinate with the first entry. This part found is then added to the subject part and the result placed in a result parts list. The process is reiterated using the entry in the results parts list until no parts having a common end point with the resultant part is found. In all cases the result shall be a closed polygon. The next entry in the subject parts list is then examined and the processes repeated until there are no further parts in the subject parts list. The result parts list will then contain a definition of the subject area minus the clip area. There now follows a detailed description of the method. The method has been divided into small procedures and Fig. 5 shows how they are related. Area Clip 50 (Fig. 5) This procedure controls the whole of the area clipping process. The 'subject area' is clipped to the 'clip area'. The result is a new subject area that defines all those parts of the original subject area that are outside of the clip area. Scan both parts lists and move any parts that are polygons to the result area. The subject list is now empty, try to construct more polygons from any remaining clip parts. Clipping is now complete Delete the original subject area and replace with the result area. Build Parts List (51) This procedure is passed two area definitions, the subject area is to be divided into parts that are either inside or outside of the clip area. Note that the terms 'subject area' & 'clip area' are with respect to the processing done by this procedure, and are independent of the same terms used in the AREA CLIP procedure. Add Line To Parts List 52 Add a single line to a parts list. Lines flagged as overlapping are held individually in the parts list. Other lines will be appended to the end of the current part if that is possible. Window 53 This procedure takes a line and an area, and sets a flag to indicate whether the line is completely outside the incidence rectangle of the area. This enables the line to be trivially rejected from clipping. Suitable techniques are well-known in the prior art. Join Two Parts 54 This procedure takes two parts (part1 and part2) and joins them together. It is assumed that the caller has determined that the last vertex in part1 is the same as one of the end vertices of part2, i.e. that part2 can be joined to the end of part1. Part2 is removed from its containing list and appended to part1, if part1 now defines a polygon, it is removed from its list and added to the Result area definition. Clip Line To Area 55 This procedure clips a single 'subject line' to the inside or the outside of an area. The result is a number of lines, represented by a list containing an even number of ordered points. Each odd-even pair of points define the two end points of a line. Get Intersection List 56 Find all intersections of a line extended to infinity with an area boundary. The intersection of the subject line with each boundary line is calculated, if the intersection is within the extent of the boundary line, it is added to the intersection list. Boundary lines that are colinear to the subject line are added to a list of colinear boundary lines, this list is used by 'IDENTIFY OVERLAPPING LINES' to flag any parts of the clipped line that overlap a boundary line. Once sorted, the intersection list defines each point where the extended subject line enters and leaves the area, thus when scanning through the list, lines from odd to even numbered intersections are within the area, and lines from even to odd numbered intersection are outside the area. It is important to ensure that the correct number of intersections is added to the list, when the subject line intersects a vertex or is colinear to a boundary line, see figure 4. This is handled by the routines 'PROCESS PARALLEL LINE' and 'ADD AN INTERSECTION'. Process Intersection List 57 The intersection list is sorted and scanned to determine which intersections are required to make up the resultant clipped line definition. Intersections outside the extent of the subject line are removed. Identify Overlapping Lines 58 Lines and gaps in the resultant clip line definition are compared with the boundary lines in the colinear boundary lines list. Any lines that overlap with a boundary line are flagged as overlapping. Also any gaps that overlap with a boundary line are added to the clipped line definition as overlapping lines. Add An Intersection 59 This procedure determines whether to add none, one or two intersections to the intersection list. If the intersection occurs at P1, it is not necessary to add it, because that particular intersection will have been processed as P2 for the previous line. If the line intersects at P2, we must determine if the subject line is tangential to the area, if it is, two intersections at P2 are added, otherwise one intersection at P2 is added. If the intersection is not at P1 or P2, the actual intersection is calculated and added to the intersection list. Process Parallel Line 60 This procedure processes a subject line that is parallel to the current boundary line P1 - P2. If the two lines are not colinear, no intersections are added. If they are colinear, similar processing to that in 'ADD AN INTERSECTION' is done to determine if the subject line is tangential to the area or not. Implementation Notes Line intersection calculation The following technique is used to calculate the intersection of two lines. Fixed point arithmetic can be used throughout, thus avoiding rounding errors. Also the position of the intersection, relative to either of the lines can be found by comparing the top and bottom of the fraction forming At or Bt without having to calculate the actual intersection. Assume two lines A and B defined by their end points Ax1,Ay1 Ax2,Ay2 and Bx1,By1 Bx2,By2 Aa = Ay1-Ay2 Ba = By1-By2 Ab = Ax2-Ax1 Bb = Bx2-Bx1 bot = (Ab*Ba) - (Aa*Bb) if bot=0, the two lines are parallel Atop = Bb*(By1-Ay1) + Ab (By1-Ay1) At = Atop / bot If 0<=At<=1 then intersection is within the extent of line A If At<0 int. is on the side of point Ax1,Ay1 If At>1 int. is on the side of point Ax2,Ay2 Btop = Aa*(Bx1-Ax1) Bt = Btop / bot If 0<=Bt<=1 then intersection is within the extent of line B If Bt<0 int. is on the side of point Bx1,By1 If Bt>1 int. is on the side of point Bx2,By2 The intersection point Ix,Iy can be calculated using Bt or At Ix = Ab*At + Ax1 = Bb*Bt + Bx1 Iy = -Aa*At + Ay1 = -Ba*Bt + By1 Data structures Area definitions, are represented by a simple data structure consisting of a list of polygons, each polygon is represented as a ring of points (vertices). Area attributes will include all information pertaining to the area, e.g. The areas incidence rectangle (min & max X & Y values) Colour Shading pattern Polygon attributes may include: The polygons incidence rectangle Vertex count. Point attributes include the co-ordinate of the point, and attributes pertaining to the line from this point to the next point. e.g.: X co-ordinate Y co-ordinate colour linetype overlapping flag. A line definition is simply two or more point definitions chained together, thus a single boundary line is passed to the clipping routine simply by passing the current polygon vertex. The result of the clipping is a list of point definitions, lines exist between each odd numbered point and its next point, gaps exist between each even numbered point and its next point. The method described above may be implemented on a system such as is illustrated schematically in Fig. 6. A host central processing unit 61 has a connection to a display control unit 62. The display control unit 62 controls the display and display screen 63 and receives input signals from a Keyboard 64 and an cursor control device 65 which may be a light pen, a tablet or an optical mouse. Hardcopy of the display pictures is provided by a plotter 66 also controlled by the display control unit. A graphic picture may be developed by a user interactively on the display screen and stored for later use in the host central processing unit. Alternatively a hardcopy may be produced by the plotter 66, it is then that the process described above is used. The control mechanism for controlling the operation of the system to perform the process may be a control routine stored in the central process unit or may be a control routine store on a diskette and loaded into the random access store of the display control unit. A further embodiment includes a programmable read only memory which is included in the display control unit and storing the routines to perform the process. All such possible mechanisms are contemplated to fall within the scope of the following claims.

Claims: A method of determining the coincidence of a subject area (Fig. 1A) and a clip area (Fig. 1B) each comprising one or more possibly overlapping, self-intersecting, polygons, in a graphic display system (61,62,63,64,65,66) in which area definitions are stored in a display list store comprising the steps of: a) creating and storing (51) a subject area parts list comprising separate entries for each part of one or more contiguous lines (12-17,20-21) of the subject area that do not pass through the clip area b) creating and storing (51) a clip area parts list comprising separate entries for each part of one or more contiguous lines (24,28,30) of the clip area that pass through the subject area c) creating and storing (51) an overlap parts list comprising separate entries for each part of one line (11,22) of both the subject and clip areas in overlap d) for each entry in the subject area parts list scanning (50) unprocessed entries first in the subject area parts list secondly in the clip area parts list thirdly in the overlap parts list for an entry having an end point definition the same as an end point definition of the part being processed, creating a new part by joining (54) any part found to the part being processed storing the created part in a results part list and reiterating the process for the entry in the results part list until no further parts are found whereby the results part list includes the definition of the portion of the subject area which does not coincide with the clip area. A method as claimed in claim 1 in which the graphic display system includes an output pen plotter (66) and the result parts list is used to control the plotter when the subject area is drawn. A graphic display system (61,62,63,64,65,66), in which area definitions are stored in a display list store, including control means adapted to control the operation of the system to perform the method of determining the coincidence of a subject area (Fig. 1A) and a clip area (Fig. 1B), each comprising one or more possibly overlapping, self-intersecting, polygons comprising the steps of: a) creating and storing (51) a subject area parts list comprising separate entries for each part of one or more contiguous lines (12-17,20-21) of the subject area that do not pass through the clip area b) creating and storing (51) a clip area parts list comprising separate entries for each part of one or more contiguous lines (24,28,30) of the clip area that pass through the subject area c) creating and storing (51) an overlap parts list comprising separate entries for each part of one line (11,22) of both the subject and clip areas in overlap d) for each entry in the subject area parts list scanning (50) unprocessed entries first in the subject area parts list secondly in the clip area parts list thirdly in the overlap parts list for an entry having an end point definition the same as one end point definition of the part being processed, creating a new part by joining (54) any part found to the part being processed storing the created part in a results part list and reiterating the process for the entry in the results part list until no further parts are found whereby the results part list includes the definition of the portion of the subject area which does not coincide with the clip area. A graphic display system as claimed in claim 3 including an output pen plotter (66) and in which the results part list is used to control the plotter when the subject area is drawn.

Inventors: HOLDEN, IAN, MAILINGS, MICHAEL JON
Applicants: INTERNATIONAL BUSINESS MACHINES CORPORATION
Application year: 1985
Main classification: G06K15
IPC codes: G06F3, G06T11, G06K15, G09G5, G06T15