%N grpocl %F $MIR/src/grpocl.f
%D Polygon clip
%B
      SUBROUTINE GRPOCL (N,PX,PY, EDGE, VAL, MAXOUT, NOUT, QX, QY)
      INTEGER N, NOUT, EDGE, MAXOUT
      REAL    PX(*), PY(*), QX(*), QY(*)
      REAL    VAL

 Clip a polygon against a rectangle: Sutherland-Hodgman algorithm.
 this routine must be called four times to clip against each of the
 edges of the rectangle in turn.      

 Arguments:

 N (input, integer): the number of vertices of the polygon (at least
       3).
 PX, PY (input, real arrays, dimension at least N): world coordinates
       of the N vertices of the input polygon.
 EDGE (input, integer):
     1: clip against left edge,   X > XMIN=VAL
     2: clip against right edge,  X < XMAX=VAL
     3: clip against bottom edge, Y > YMIN=VAL
     4: clip against top edge,    Y < YMIN=VAL
 VAL  (input, real): coordinate value of current edge.
 MAXOUT (input, integer): maximum number of vertices allowed in
     output polygon (dimension of QX, QY).
 NOUT (output, integer): the number of vertices in the clipped polygon.
 QX, QY (output, real arrays, dimension at least MAXOUT): world
       coordinates of the NOUT vertices of the output polygon.
