      SUBROUTINE TRAIT(V1,V2,V3,N1,N2,N3,X1,X2,X3,Y1,Y2,Y3,T1,T2,T3
     &                ,SENS,IOPT)
      DIMENSION T1(*),T2(*),T3(*)
      DIMENSION X(4),Y(4)
      INCLUDE 'com_ombreiso.f'
C
      IF (IOPT.GE.0) CALL GSCOL(IOPT)
      IF (N1.EQ.N2) THEN
        II = 0
        DO I=N1,N3-1
          II = II+1
          X(3) = T1(II)*(X2-X3) + X3
          Y(3) = T1(II)*(Y2-Y3) + Y3
          X(4) = T2(II)*(X1-X3) + X3
          Y(4) = T2(II)*(Y1-Y3) + Y3
          IF (IOPT.LT.0) CALL GSCOL(ISOMBRE+1+I)
          IF (SENS*V3.GE.SENS*V2) THEN
            CALL GSMOVE(X(4),Y(4))
            CALL GSLINE(X(3),Y(3))
          ELSE
            CALL GSMOVE(X(3),Y(3))
            CALL GSLINE(X(4),Y(4))
          ENDIF
          CALL MARVAL(I+1,X(3),X(4),Y(3),Y(4))
        ENDDO
      ELSE
        X(3) = T3(1)*(X1-X2) + X2
        Y(3) = T3(1)*(Y1-Y2) + Y2
        X(4) = T2(1)*(X1-X3) + X3
        Y(4) = T2(1)*(Y1-Y3) + Y3
        II = 1
        IF ((N1+2).LE.N2) THEN
          DO I=N1+1,N2-1
            II = II+1
            X(1) = X(4)
            Y(1) = Y(4)
            X(2) = X(3)
            Y(2) = Y(3)
            X(3) = T3(II)*(X1-X2) + X2
            Y(3) = T3(II)*(Y1-Y2) + Y2
            X(4) = T2(II)*(X1-X3) + X3
            Y(4) = T2(II)*(Y1-Y3) + Y3
            IF (IOPT.LT.0) CALL GSCOL(ISOMBRE+I)
            IF (SENS*V2.GE.SENS*V1) THEN
              CALL GSMOVE(X(1),Y(1))
              CALL GSLINE(X(2),Y(2))
            ELSE
              CALL GSMOVE(X(2),Y(2))
              CALL GSLINE(X(1),Y(1))
            ENDIF
            CALL MARVAL(I,X(1),X(2),Y(1),Y(2))
          ENDDO
        ENDIF
        X(1) = X(4)
        Y(1) = Y(4)
        X(2) = X(3)
        Y(2) = Y(3)
        IF (IOPT.LT.0) CALL GSCOL(ISOMBRE+N2)
        IF (SENS*V2.GE.SENS*V1) THEN
          CALL GSMOVE(X(1),Y(1))
          CALL GSLINE(X(2),Y(2))
        ELSE
          CALL GSMOVE(X(2),Y(2))
          CALL GSLINE(X(1),Y(1))
        ENDIF
        CALL MARVAL(N2,X(1),X(2),Y(1),Y(2))
        IF (N2.EQ.N3) THEN
          X(4) = X3
          Y(4) = Y3
        ELSE
          X(3) = T1(1)*(X2-X3) + X3
          Y(3) = T1(1)*(Y2-Y3) + Y3
          II = II+1
          X(4) = T2(II)*(X1-X3) + X3
          Y(4) = T2(II)*(Y1-Y3) + Y3
          II2 = 1
          IF ((N2+2).LE.N3) THEN
            DO I=N2+1,N3-1
              II = II+1
              II2 = II2+1
              X(1) = X(4)
              Y(1) = Y(4)
              X(2) = X(3)
              Y(2) = Y(3)
              X(3) = T1(II2)*(X2-X3) + X3
              Y(3) = T1(II2)*(Y2-Y3) + Y3
              X(4) = T2(II)*(X1-X3) + X3
              Y(4) = T2(II)*(Y1-Y3) + Y3
              IF (IOPT.LT.0) CALL GSCOL(ISOMBRE+I)
              IF (SENS*V3.GE.SENS*V2) THEN
                CALL GSMOVE(X(1),Y(1))
                CALL GSLINE(X(2),Y(2))
              ELSE
                CALL GSMOVE(X(2),Y(2))
                CALL GSLINE(X(1),Y(1))
              ENDIF
              CALL MARVAL(I,X(1),X(2),Y(1),Y(2))
            ENDDO
          ENDIF
          IF (IOPT.LT.0) CALL GSCOL(ISOMBRE+N3)
          IF (SENS*V3.GE.SENS*V2) THEN
            CALL GSMOVE(X(4),Y(4))
            CALL GSLINE(X(3),Y(3))
          ELSE
            CALL GSMOVE(X(3),Y(3))
            CALL GSLINE(X(4),Y(4))
          ENDIF
          CALL MARVAL(N3,X(3),X(4),Y(3),Y(4))
        ENDIF
      ENDIF
      END
C---------------------------------------------------------------------
      SUBROUTINE MARVAL(I,X1,X2,Y1,Y2)
      INCLUDE 'com_val.f'
      IF (X1.EQ.X2.AND.Y1.EQ.Y2) RETURN
      X = .5*(X1+X2)
      Y = .5*(Y1+Y2)
      IF (X.GT.XMMIN.AND.X.LT.XMMAX.AND.Y.GT.YMMIN.AND.Y.LT.YMMAX) THEN
        VALMAR(1,I-1) = X
        VALMAR(2,I-1) = Y
      ENDIF
      END
