    	SUBROUTINE IFFILL( IPT )
C
C  PROGRAMMER:  RONG-SHENG ZHOU
C		BOSTON COLLEGE, 8/1988
C
C	THIS ROUTINE IMPLEMENTS AREA/POLYGON FILL.
C
C	IPT >0< : START AREA/POLYGON FILL.
C	IPT = 0 : TERMINATE AREA FILL.
C	IPT > 0 : EDGE/OUTLINE THE FILLED AREA.
C	IPT < 0 : DO NOT EDGE/OUTLINE THE FILLED AREA.
C
    	INCLUDE 'TEKLIB.CBS'
C
C  QUIT ON CTRL_C...
C
     	IF( CTRL_C .OR. IPT.EQ.IFP ) RETURN
     	IF( IPT.NE.0 ) THEN
     	    IFP = IPT
     	ELSE
     	    CALL IFFILL_INIT(0)
     	    IFP = 0
     	ENDIF
     	IFF = 0

     	IF( IDW.NE.0 ) THEN
     	    IF( NPPS.GT.0 ) CALL IFPLOT_DUMP
     	    WRITE(IDF,1000) IPT
     	ENDIF
1000	FORMAT('FILL:',I3)

999	RETURN
    	END

     	SUBROUTINE IFFILL_INIT( ICOD )
C
C	THIS ROUTINE IMPLEMENTES POLYGON FILL.
C
     	INCLUDE 'TEKLIB.CBS'
     	SAVE INIT

    	IF( ITM.EQ.1 ) RETURN
     	IF( ICOD.EQ.0 ) GOTO 222	!END ALL PANELS
     	IF( INIT.EQ.999 ) GOTO 111	!BEGIN NEW PANEL
C
C  SELECT THE FILL PATTERN FOR ALL PANELS...
C
     	IF( ITM.EQ.2 ) THEN		!TEK-4100 GRAPHICS
    	    IF( IPL.GT.NBS-IPK-6 ) CALL IFINIT_DUMP
    	    IPB(IPL+1) = 27			!<ESC>MP color-index
    	    IPB(IPL+2) = 77
    	    IPB(IPL+3) = 80
    	    IPL = IPL + 3
    	    IF( IFP.EQ.1 ) THEN
     		CALL IFPACK_TEKINT( -ILP )		!SOLID COLOR
    	    ELSE
     		CALL IFPACK_TEKINT( IABS(IFP-1) )	!PREDEFINED PATTERN
    	    ENDIF
     	ENDIF
     	IF( ITM.EQ.3 ) THEN		!REGIS GRAPHICS
    	    IF( IPL.GT.NBS-IPK-3 ) CALL IFINIT_DUMP
     	    IPB(IPL+1) = '@'		!OPEN MACROGRAPH "P"
     	    IPB(IPL+2) = ':'
     	    IPB(IPL+3) = 'P'
     	    IPL = IPL + 3
     	ENDIF
     	INIT = 999
C
C  BEGIN NEW PANEL ...
C
  111	IF( ITM.EQ.2 ) THEN
     	    IF( IPL.GT.NBS-IPK-9 ) CALL IFINIT_DUMP
     	    IPB(IPL+1) = 27			!<ESC>LP last-pen-location
    	    IPB(IPL+2) = 76
    	    IPB(IPL+3) = 80
    	    IPL = IPL + 3
    	    CALL IFPACK_TEKXY( IXL, IYL )
    	    IPL = IPL + 1
    	    IPB(IPL) = 49
     	ENDIF
    	GOTO 999

  222	IF( INIT.NE.999 ) GOTO 999
C
C  END ALL PANELS ...
C
     	IF( ITM.EQ.2 ) THEN
     	    IF( IPL.GT.NBS-IPK-3 ) CALL IFINIT_DUMP
     	    IPB(IPL+1) = 27			!<ESC>LE
    	    IPB(IPL+2) = 76
    	    IPB(IPL+3) = 69
    	    IPL = IPL + 3
     	ENDIF
     	IF( ITM.EQ.3 ) THEN
     	    IF( IPL.GT.NBS-IPK-21 ) CALL IFINIT_DUMP
     	    IPB(IPL+1) = '@'		!CLOSE THE MACROGRAPH
     	    IPB(IPL+2) = ';'
     	    IPB(IPL+3) = 'F'		!FILL THE POLYGON
     	    IPB(IPL+4) = '('
     	    IPB(IPL+5) = 'W'
     	    IPB(IPL+6) = '('
     	    IPB(IPL+7) = 'I'
     	    IPL = IPL + 7
     	    CALL IFPACK_REGIS(IABS(IFP))
     	    IPB(IPL+1) = ')'
     	    IPB(IPL+2) = ','
     	    IPB(IPL+3) = '@'
     	    IPB(IPL+4) = 'P'
     	    IPB(IPL+5) = ')'
     	    IPL = IPL + 5
     	    IF( IFP.GT.0 ) THEN		!OUTLINE THE POLYGON
     		IPB(IPL+1) = '@'
     		IPB(IPL+2) = 'P'
     		IPL = IPL + 2
     	    ENDIF
     	    IPB(IPL+1) = '@'		!CLEAR MACROGRAPH "P"
     	    IPB(IPL+2) = ':'
     	    IPB(IPL+3) = 'P'
     	    IPB(IPL+4) = '@'
     	    IPB(IPL+5) = ';'
     	    IPL = IPL + 5
     	ENDIF
     	INIT = 0

 999	RETURN
    	END

     	SUBROUTINE IFFILL_PANEL( ICODE )
C
C	THIS ROUTINE ENABLES OR DISABLES NEW PANEL FOR POLYGON FILL.
C
     	INCLUDE 'TEKLIB.CBS'
     	NEW = ICODE
     	IF( NEW.NE.0 ) NEW = 1
     	IF( ITM.EQ.3 ) NEW = 0
     	RETURN
     	END

