Filled Area Output


Discussed here is the fill area output primitive GFA and the functions that are used to set fill area attributes and retrieve current attribute settings.

Fill Area Primitive

The fill area output primitive takes a polygon as input and fills it with a solid color or cross hatching. The GKS standard sets hollow fill as the default. However, due to numerous complaints over many years, the default fill in the NCAR GKS implementation has been set to solid fill.
------------------------------------------------
          Argument | Type    |  Mode | Dimension
------------------------------------------------
CALL GFA  (N,      | Integer | Input |
           X,      | Real    | Input |   N
           Y)      | Real    | Input |   N
------------------------------------------------
N
The number of points in the polygon to be filled. (N > 2)
X
An array of dimension N containing the X world coordinates of the polygon.
Y
An array of dimension N containing the Y world coordinates of the polygon.
The area to be filled is delimited by a series of straight line segments connecting the successive points represented by (X(1), Y(1)), (X(2), Y(2)),..., (X(N), Y(N)). The last point in the polygon is connected to the first point with a straight line segment in the case that coordinate (X(N), Y(N)) is not equal to coordinate (X(l), Y(l)).
Defaults:
none
Errors:
5, 100
--------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void gfill_area(
                const Gpoint_list  *point_list  /*  list of points  */
);
--------------------------------------------------------------------------

Figure 15 - Filled areas

Given a polygon whose edges cross over each other, it becomes ambiguous as to what constitutes the "inside" of the polygon. The algorithm used in GKS is as follows: for a given point, create a straight line starting at that point and going to infinity in any direction. If the number of intersections between the straight line and the polygon is odd, the point is within the polygon; otherwise it is outside. If the straight line passes a polygon vertex tangentially, the intersection count is not affected. If a point is within the polygon, it is included in the area to be filled. Figure 16 illustrates the effects of this algorithm. The polygon on the left has ten distinct vertices as labeled, and the inside is as shown. The polygon on the right has five distinct vertices as labeled, and the edges cross one another. The inside is as shown.

Figure 16 - Fill area algorithm

Setting Fill Area Output Attributes


Set Fill Area Interior Style

---------------------------------------------------
             Argument | Type    |  Mode | Dimension
---------------------------------------------------
CALL GSFAIS  (INTS)   | Integer | Input |
---------------------------------------------------
INTS
Gives the style of fill to be used in subsequent calls to GFA. Options are:
0 - hollow fill
1 - solid fill
2 - pattern fill
3 - hatch fill
GKS subroutine GSFASI can then be used to set the particular workstation dependent hatch and pattern options which may be provided.
Default:
The default interior style in NCAR GKS is solid fill. This is in exception to the default specified in the GKS Standard (which is hollow fill).
Errors:
8, 2000
--------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void gset_fill_int_style(
             Gfill_int_style  fill_int_style  /*  fill interior style  */
);
--------------------------------------------------------------------------
Figure 17 below illustrates various fill area interior styles.

Set Fill Area Style Index

---------------------------------------------------
             Argument | Type    |  Mode | Dimension
---------------------------------------------------
CALL GSFASI  (STYLI)  | Integer | Input |
---------------------------------------------------
STYLI
Allows for the selection of workstation-dependent options for hatch or pattern fills. Pattern fill options are not supported in NCAR Graphics. Hatch fill options are:
1 - horizontal lines
2 - vertical lines
3 - lines of positive slope
4 - lines of negative slope
5 - horizontal and vertical lines
6 - lines of positive and negative slope
Default:
The default hatch fill is horizontal lines.
Errors:
8, 84

-----------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void gset_fill_style_ind(
                         Gint  fill_style_ind  /*  fill style index  */
);
-----------------------------------------------------------------------

Figure 17 - Fill area interior styles

Fill Area Inquiry Functions


Get the Fill Area Interior Style

----------------------------------------------------
             Argument | Type    | Mode   | Dimension
----------------------------------------------------
CALL GQFAIS  (ERRIND, | Integer | Output |
              INTS)   | Integer | Output |
----------------------------------------------------
ERRIND
Error flag. Gives an integer error number from the errors list in in Appendix D, or a 0 if no error occurred.
INTS
Gives the style of fill as set by GSFAIS.
Errors:
8
--------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void ginq_fill_int_style(
            Gint             *err_ind,        /*  error indicator      */
            Gfill_int_style  *fill_int_style  /*  fill interior style  */
);
--------------------------------------------------------------------------

Get the Fill Area Style Index

----------------------------------------------------
             Argument | Type    | Mode   | Dimension
----------------------------------------------------
CALL GQFASI  (ERRIND, | Integer | Output |
              STYLI)  | Integer | Output |
----------------------------------------------------
ERRIND
Error flag. Gives an integer error number from the errors list in in Appendix D, or a 0 if no error occurred.
STYLI
Gives the fill area style index as set by GSFASI.
Errors:
8
------------------------------------------------------------------------
C Synopsis

#include <ncarg/gks.h>

void ginq_fill_style_ind(
                    Gint  *err_ind,        /*  error indicator   */
                    Gint  *fill_style_ind  /*  fill style index  */
);
------------------------------------------------------------------------

Links: GKS Index, GKS Home