c                          
c                          
c
      subroutine DrawFoot( side,inGCS,FileNum,PltSym,chsize,error )
      implicit none
        
      include 'tel_cons.inc'
      include 'tel_strc.inc'
      include 'tel_grph.inc'
      include 'tel_file.inc'
      include 'tel_name.inc'

      include 'vogle.fi'

      integer*4 FileNum,side,PltSym
      real*4    chsize(2)
      logical*4 inGCS,error           

      integer*4 i,j,SegNum,FtPntOrder(2,4),FtFrm
      real*4    VecLth,FtPosGCS(3,4),FtPntLoc(3,4)
      logical*4 OutLineOK
          
      data FtPntOrder / 1,2, 2,3, 3,4, 4,1 /                    
        
      error= .true.
      SegNum= rtft          
      if ( side .eq. lf ) SegNum= lfft      
      OutLineOK= .true.
      if ( FD(FileNum).SF.Param ) then
        do i= 1, 4
          do j= 1, 3
            FtPntLoc(j,i)= FD(FileNum).SP(SegNum).Shape(j,i)
          end do
        end do
        do i= 1, 4
          if ( VecLth(FtPntLoc(x,FtPntOrder(1,i)),FtPntLoc(x,FtPntOrder(2,i))) 
     &         .lt. 1.0e-5 ) OutLineOK= .false.
        end do
        if ( .not. OutLineOK ) goto 1000 ! error
      else       
        goto 1010 ! error                 
      end if
c
c     Read in frame of foot position/orientation data if foot outline is to
c     be displayed in GCS since the foot outline must be transformed from foot
c     LCS to GCS to be drawn correctly...
c                                                          
      if ( inGCS ) then
        if ( .not. FD(FileNum).SF.Pos ) goto 1020 ! error
        i= 1
        do while ( (.not. FtDataOK(i,side,FileNum)) .and.
     &             (i .lt. FD(FileNum).MP.num_frm)  ) 
          i= i + 1
        end do
        j= FD(FileNum).MP.num_frm
        do while ( (.not. FtDataOK(j,side,FileNum)) .and. (j .le. 1) ) 
          j= j - 1
        end do
        FtFrm= (i+j)/2
        do i= 1, 4         
          do j= 1, 3
            call ReadFileData( FileNum,SPN_DATA,SegNum,j,i,0,FtFrm,FtFrm+1,
     &                         PltData(1,1,MAX_PLT,MAX_GRAPH),
     &                         PltDataOK(1,MAX_PLT,MAX_GRAPH),error   )
            FtPosGCS(j,i)= PltData(1,1,MAX_PLT,MAX_GRAPH)
          end do ! j
        end do ! i                                                
        do i= 1, 4                            
          call PntChangeCS( FtPosGCS,FtPntLoc(x,i),FtPntLoc(x,i) )
        end do
      end if ! in GCS
c                                                                
c     Draw the outline on the graph...
c
      call dlstyl(0)
      do i= 1, 4
        call dmark( FtPntLoc(x,i),FtPntLoc(y,i),
     &              chsize(x)/2.0,chsize(y)/2.0,PltSym )
      end do                                               
      call dlstyl(PltSym-1)
      call color(PltSym)
      call move2(FtPntLoc(x,1),FtPntLoc(y,1))
      do i= 2, 4
        call draw2(FtPntLoc(x,i),FtPntLoc(y,i))
      end do
      call draw2(FtPntLoc(x,1),FtPntLoc(y,1))
      return

1000  write(6,1005) SegNames(SegNum)
1005  format(/' Error- Segment outline for ',a4,' contains bad data'/)
      return

1010  write(6,1015) SegNames(SegNum),FileNum
1015  format(/' Error- ',a4,' outline is not contained in file # ',i2/)
      return

1020  write(6,1025) SegNames(SegNum),FileNum
1025  format(/' Error- ',a4,' position is not contained in file # ',i2/)
      return
      end                            
