C PROGRAM 'LINDXF' TO CONVERT THE MODEL WIREFRAME GENERATED BY THE 'SEC'
C PROGRAM TO THE 'AUTOCAD' ASCII DRAWING INTERCHANGE (DXF) FILE FORMAT.
C
C MAIN INPUT DATA FILE READ FROM THE * EXTERNAL UNIT:
C (1) 'SEC','DXF',/
C     'SEC'...NAME OF THE INPUT DATA FILE CONTAINING A MODEL WIREFRAME
C             GENERATED BY THE 'SEC' PROGRAM.
C     'DXF'...NAME OF THE OUTPUT ASCII DRAWING INTERCHANGE (DXF) FILE
C             TO BE DISPLAYED BY 'AUTOCAD'.
C     /...    OBLIGATORY SLASH TO ENABLE FUTURE COMPATIBLE EXTENSIONS.
C
C INPUT FILE 'SEC' IS DESCRIBED WITHIN THE FORTRAN77 SOURCE CODE FILE
C     'MODSEC.FOR'.
C
C OUTPUT FILE 'DXF' SHOULD CONFORM THE AUTOCAD VERSION 10 AND HIGHER
C     SPECIFICATION.
C
C DATE: 1994, JANUARY 12
C CODED BY LUDEK KLIMES
C
C-----------------------------------------------------------------------
C
      CHARACTER*80 SEC,DXF,TEXT
      INTEGER LINE,LAYER,IPOINT
*     INTEGER IV
      REAL CART1,CART2,CART3
*     REAL VALUE
C
C     SEC,DXF... NAMES OF INPUT AND OUTPUT FILES.
C     TEXT...DUMMY TEXT STRING.
C     LINE...INDEX OF THE ISOSURFACE CORRESPONDING TO THE ISOLINE IN THE
C            MODEL WIREFRAME.
C     IV...  INDEX OF THE VELOCITY ISOSURFACE CORRESPONDING TO THE
C            ISOLINE.
C     LAYER..INDEX OF THE AUTOCAD LAYER CORRESPONDING TO THE ISOSURFACE.
C     IPOINT... LOOP VARIABLE.
C     CART1,CART2,CART3... CARTESIAN COORDINATES.
C     VALUE... VELOCITY ISOSURFACE VALUE.
C
C.......................................................................
C
C     INPUT AND OUTPUT FILES:
      WRITE(*,'(A)') ' ENTER NAMES OF INPUT AND OUTPUT FILES: '
      SEC='SEC.OUT'
      DXF='SEC.DXF'
      READ(*,*) SEC,DXF
      OPEN(1,FILE=SEC,STATUS='OLD')
      OPEN(2,FILE=DXF)
      WRITE(*,'(2A)')
     *          '+CREATING: ',DXF(1:MAX0(MIN0(INDEX(DXF,'    '),69),30))
C
      READ(1,*) (TEXT,I=1,20)
C
C     TABLES:
      WRITE(2,'(I2/A)')   0,'SECTION'
      WRITE(2,'(I2/A)')   2,'TABLES'
      WRITE(2,'(I2/A)')   0,'TABLE'
      WRITE(2,'(I2/A)')   2,'LTYPE'
      WRITE(2,'(I2/I4)') 70,1
      WRITE(2,'(I2/A)')   0,'LTYPE'
      WRITE(2,'(I2/A)')   2,'DASH'
      WRITE(2,'(I2/I4)') 70,0
      WRITE(2,'(I2/A)')   3,'Solid line'
      WRITE(2,'(I2/I4)') 72,65
      WRITE(2,'(I2/I4)') 73,2
      WRITE(2,'(I2/F8.3)') 40,1.000,49,0.500,49,0.500
      WRITE(2,'(I2/A)')   0,'ENDTAB'
      WRITE(2,'(I2/A)')   0,'TABLE'
      WRITE(2,'(I2/A)')   2,'LAYER'
      WRITE(2,'(I2/I4)') 70,10
      DO 10 LAYER=0,9
        WRITE(2,'(I2/A)')   0,'LAYER'
        WRITE(2,'(I2/I1)')  2,LAYER
        WRITE(2,'(I2/I4)') 70,0
        IF(LAYER.LE.0) THEN
          WRITE(2,'(I2/I4)') 62,7
          WRITE(2,'(I2/A)')   6,'DASH'
        ELSE
          WRITE(2,'(I2/I4)') 62,LAYER
          WRITE(2,'(I2/A)')   6,'CONTINUOUS'
        END IF
   10 CONTINUE
      WRITE(2,'(I2/A)')   0,'ENDTAB'
C     AUTHOR'S NOTES
C     WRITE(2,'(I2/A)')   0,'TABLE'
C     WRITE(2,'(I2/A)')   2,'VIEW'
C     WRITE(2,'(I2/I4)') 70,1
C     WRITE(2,'(I2/A)')   0,'VIEW'
C     WRITE(2,'(I2/A)')   2,'111'
C     WRITE(2,'(I2/I4)') 70,0
C     WRITE(2,'(I2/I4)') 11,1,21,1,31,1
C     WRITE(2,'(I2/A)')  0,'ENDTAB'
C     END OF TABLES:
      WRITE(2,'(I2/A)')  0,'ENDSEC'
C
C     ENTITIES:
      WRITE(2,'(I2/A)')  0,'SECTION'
      WRITE(2,'(I2/A)')  2,'ENTITIES'
C
C     LOOP FOR LINES:
   20 CONTINUE
        LINE=0
        TEXT='$$$$'
        READ(1,*,END=90) TEXT,CART1,CART2,CART3
        IF(TEXT(01:04).EQ.'$$$$') THEN
          GO TO 90
        END IF
        IF(TEXT(11:14).EQ.'SURF') THEN
C         STRUCTURAL INTERFACE:
          READ(TEXT(15:18),'(I4)') LINE
          LAYER=IABS(LINE)
        ELSE IF(TEXT(21:24).EQ.'ISOL') THEN
C         VELOCITY ISOLINE:
*         READ(TEXT(15:18),'(I4)') LINE
*         READ(TEXT(25:28),'(I4)') IV
*         READ(TEXT(35:40),'(F6.3)') VALUE
          LAYER=0
        ELSE IF(TEXT(01:04).EQ.'WAVE'.AND.TEXT(11:13).EQ.'RAY') THEN
C         RAY:
          READ(TEXT(05:08),'(I4)') LINE
          LAYER=IABS(LINE)
        ELSE
C         NOT RECOGNISED:
          LAYER=0
        END IF
C       WRITING THE SECTION IN TERMS OF POLYLINES (PART 1/3):
        WRITE(2,'(I2/A)')   0,'POLYLINE'
        WRITE(2,'(I2/I1)')  8,LAYER
        WRITE(2,'(I2/I4)') 66,1
        WRITE(2,'(I2/I4)') 70,8
C       LOOP FOR POINTS OF THE LINE:
        DO 30 IPOINT=1,999999
C         WRITING THE SECTION IN TERMS OF LINES (PART 1/2):
C         IF(IPOINT.GT.1) THEN
C           WRITE(2,'(I2/A)')   0,'LINE'
C           WRITE(2,'(I2/I1)')  8,LAYER
C           WRITE(2,'(I2/F12.6)') 10,CART1,20,CART2,30,CART3
C         END IF
C         CARTESIAN COORDINATES:
          CART1=-999999.
          CART2=0.
          CART3=0.
          READ(1,*) CART1,CART2,CART3
          IF(CART1.EQ.-999999.) THEN
            GO TO 31
          END IF
C         WRITING THE SECTION IN TERMS OF POLYLINES (PART 2/3):
          WRITE(2,'(I2/A)')   0,'VERTEX'
          WRITE(2,'(I2/I1)')  8,LAYER
          WRITE(2,'(I2/I4)') 70,32
          WRITE(2,'(I2/F12.6)') 10,CART1,20,CART2,30,CART3
C         WRITING THE SECTION IN TERMS OF LINES (PART 2/2):
C         IF(IPOINT.GT.1) THEN
C           WRITE(2,'(I2/F12.6)') 11,CART1,21,CART2,31,CART3
C         END IF
   30   CONTINUE
        PAUSE 'ERROR: TOO MANY POINTS WITHIN A LINE SEGMENT'
        STOP
   31   CONTINUE
C       WRITING THE SECTION IN TERMS OF POLYLINES (PART 3/3):
        WRITE(2,'(I2/A)')   0,'SEQEND'
      GO TO 20
C
C     END OF ENTITIES:
   90 CONTINUE
      WRITE(2,'(I2/A)')  0,'ENDSEC'
      WRITE(2,'(I2/A)')  0,'EOF'
      WRITE(*,'(A)') '+CREATED: '
      STOP
      END
C
C=======================================================================
C
