示例#1
0
static int ffnd (ptr_level_f func, int i1, int i2, int i3, int i4, int jj1, int jj2, int jj3, int jj4, int ent, int qq, double Cont, int *zds)
{
    double phi1 = 0., phi2 = 0., phi3 = 0., phi4 = 0., xav = 0., yav = 0., phiav = 0.;
    int revflag = 0, i = 0;
    phi1 = phi_cont(i1, jj1) - Cont;
    phi2 = phi_cont(i2, jj2) - Cont;
    phi3 = phi_cont(i3, jj3) - Cont;
    phi4 = phi_cont(i4, jj4) - Cont;
    revflag = 0;
    *zds = 0;
    /* le point au centre du rectangle */
    xav = ( x_cont(i1) + x_cont(i3)) / 2.0 ;
    yav = ( y_cont(jj1) + y_cont(jj3)) / 2.0 ;
    phiav = ( phi1 + phi2 + phi3 + phi4) / 4.0;
    if (ISNAN(phiav) == 1)
    {
        return -1;
    }
    if (  not_same_sign( phiav, phi4))
    {
        int l1, k1;
        double phi;
        revflag = 1 ;
        l1 = i4;
        k1 = jj4;
        i4 = i1;
        jj4 = jj1;
        i1 = l1;
        jj1 = k1;
        l1 = i3;
        k1 = jj3;
        i3 = i2;
        jj3 = jj2;
        i2 = l1;
        jj2 = k1;
        phi = phi1;
        phi1 = phi4;
        phi4 = phi;
        phi = phi3;
        phi3 = phi2;
        phi2 = phi;
    }
    /* on stocke un nouveau point  */
    (*func)(1, Cont, f_intercept(0.0, phi1, x_cont(i1), phiav, xav),
            f_intercept(0.0, phi1, y_cont(jj1), phiav, yav));
    /*
     * on parcourt les segments du rectangle pour voir sur quelle face
     * on sort
     */
    for  ( i = 0 ;  ; i++)
    {
        int l1, k1;
        double phi;
        if ( not_same_sign ( phi1, phi2))   /** sortir du for **/
        {
            break ;
        }
        if  ( phiav != 0.0 )
        {
            (*func)(1, Cont, f_intercept(0.0, phi2, x_cont(i2), phiav, xav),
                    f_intercept(0.0, phi2, y_cont(jj2), phiav, yav));
        }
        /** on permutte les points du rectangle **/
        l1 = i1;
        k1 = jj1;
        i1 = i2;
        jj1 = jj2;
        i2 = i3;
        jj2 = jj3;
        i3 = i4;
        jj3 = jj4;
        i4 = l1;
        jj4 = k1;
        phi = phi1;
        phi1 = phi2;
        phi2 = phi3;
        phi3 = phi4;
        phi4 = phi;
    }
    (*func)(1, Cont, f_intercept(0.0, phi1, x_cont(i1), phi2, x_cont(i2)),
            f_intercept(0.0, phi1, y_cont(jj1), phi2, y_cont(jj2)));
    if ( qq == 1 && bdyp(i1, jj1) && bdyp(i2, jj2))
    {
        *zds = 1 ;
    }
    if ( revflag == 1  &&  ! oddp (i) )
    {
        i = i + 2;
    }
    return ( 1 + (  ( i + ent + 2) % 4));
}
示例#2
0
static void
markp(int not)
{
	oddp(not);
}
示例#3
0
static void look(ptr_level_f func, int i, int j, int ib, int jb, int qq, double Cont, int style)
{
    int ip = 0, jp = 0, im = 0, jm = 0, zds = 0, ent = 0, flag = 0, wflag = 0;
    jp = j + 1;
    ip = i + 1;
    jm = j - 1;
    im = i - 1;
    /*  on regarde comment est le segment de depart */
    if  ( jb == jm)
    {
        flag = 1;
    }
    else
    {
        if ( ib == im )
        {
            flag = 2 ;
        }
        else
        {
            if ( jb == jp )
            {
                flag = 3 ;
            }
            else  if ( ib == ip )
            {
                flag = 4;
            }
        }
    }
    switch  (  flag)
    {
        case  1 :
            if  (get_itg_cont(i, jm) > 1)
            {
                return;
            }
            ent = 1 ; /* le segment est vertical vers le bas */
            /* Storing intersection point */
            (*func)(0, Cont, x_cont(i),
                    f_intercept(Cont, phi_cont(i, jm),
                                y_cont(jm), phi_cont(i, j), y_cont(j)));
            break;
        case 2 :
            if  (get_itg_cont(im, j) == 1 || get_itg_cont(im, j) == 3 )
            {
                return;
            }
            ent = 2 ; /* le segment est horizontal gauche */
            /* Storing intersection point */
            (*func)( 0, Cont,
                     f_intercept(Cont, phi_cont(im, j),
                                 x_cont(im), phi_cont(i, j), x_cont(i)), y_cont(j));
            break ;
        case 3 :
            if  (get_itg_cont(i, j) > 1 )
            {
                return;
            }
            ent = 3 ; /* le segment est vertical haut */
            /* Storing intersection point */
            (*func)(0, Cont, x_cont(i), f_intercept(Cont, phi_cont(i, j),
                                                    y_cont(j), phi_cont(i, jp), y_cont(jp)));
            break ;
        case 4 :
            if  (get_itg_cont(i, j) == 1 || get_itg_cont(i, j) == 3 )
            {
                return;
            }
            ent = 4 ; /* le segment est horizontal droit */
            /* Storing intersection point */
            (*func)(0, Cont, f_intercept(Cont, phi_cont(i, j),
                                         x_cont(i), phi_cont(ip, j), x_cont(ip)),
                    y_cont(j));
            break;
        default :
            break;
    }
    wflag = 1;
    while ( wflag)
    {
        jp = j + 1;
        ip = i + 1;
        jm = j - 1;
        im = i - 1;
        switch  ( ent)
        {
            case 1 :
                inc_itg_cont(i, jm, 2L);
                ent = ffnd(func, i, ip, ip, i, j, j, jm, jm, ent, qq, Cont, &zds);
                /* on calcule le nouveau point, ent donne la
                direction du segment a explorer */
                switch ( ent)
                {
                    case -1:
                        wflag = 0;
                        break;
                    case 1 :
                        i = ip ;
                        break ;
                    case 2 :
                        i = ip;
                        j = jm;
                        break ;
                }
                break ;
            case 2  :
                inc_itg_cont(im, j, 1L);
                ent = ffnd(func, i, i, im, im, j, jm, jm, j, ent, qq, Cont, &zds);
                switch ( ent)
                {
                    case -1:
                        wflag = 0;
                        break;
                    case 2 :
                        j = jm ;
                        break ;
                    case  3  :
                        i = im;
                        j = jm;
                        break ;
                }
                break ;
            case 3 :
                inc_itg_cont(i, j, 2L);
                ent = ffnd(func, i, im, im, i, j, j, jp, jp, ent, qq, Cont, &zds);
                switch ( ent)
                {
                    case -1:
                        wflag = 0;
                        break;
                    case 3 :
                        i = im;
                        break ;
                    case 4 :
                        i = im;
                        j = jp;
                        break ;
                }
                break ;
            case 4 :
                inc_itg_cont(i, j, 1L);
                ent = ffnd(func, i, i, ip, ip, j, jp, jp, j, ent, qq, Cont, &zds);
                switch ( ent)
                {
                    case -1:
                        wflag = 0;
                        break;
                    case 4 :
                        j = jp;
                        break ;
                    case 1 :
                        i = ip;
                        j = jp;
                        break ;
                }
                break ;
        }

        /** new segment is on the boundary **/
        if ( zds == 1)
        {
            switch ( ent)
            {
                case 1 :
                    inc_itg_cont(i, (j - 1), 2L);
                    break ;
                case 2 :
                    inc_itg_cont(i - 1, j, 1L);
                    break ;
                case 3 :
                    inc_itg_cont(i, j, 2L);
                    break ;
                case 4 :
                    inc_itg_cont(i, j, 1L);
                    break ;
            }
            /** we must quit the while loop **/
            wflag = 0 ;
        }
        /**  init point was inside the domain */
        if ( qq == 2)
        {
            switch ( ent)
            {
                case 1 :
                    if  ( get_itg_cont (i, j - 1)  > 1)
                    {
                        wflag = 0 ;
                    }
                    break ;
                case 2 :
                    if  ( oddp(get_itg_cont(i - 1, j)))
                    {
                        wflag = 0 ;
                    }
                    break ;
                case 3 :
                    if  ( get_itg_cont(i, j) > 1)
                    {
                        wflag = 0 ;
                    }
                    break ;
                case 4 :
                    if  ( oddp(get_itg_cont(i, j)))
                    {
                        wflag = 0 ;
                    }
                    break ;
            }
        }
    }
    if ( func == GContStore2 )
    {
        GContStore2Last();
    }
    else
    {
        /* contour2di only computes level curves, not display them. */
        sciprint(_("%s is only made to compute level curves and not display them.\n"), "Contourdi");
    }
}