Back to index

plt-scheme  4.2.1
Defines | Functions | Variables
plshade.c File Reference
#include "plplotP.h"
#include <float.h>

Go to the source code of this file.

Defines

#define MISSING_MIN_DEF   (PLFLT) 1.0
#define MISSING_MAX_DEF   (PLFLT) -1.0
#define NEG   1
#define POS   8
#define OK   0
#define UNDEF   64
#define linear(val1, val2, level)   ((level - val1) / (val2 - val1))
#define RATIO   3
#define COND(x, y)   cond_code[x*ny + y]
#define X(a, b)   (x[a*4+b])
#define POSITIVE_SLOPE   (PLINT) 1
#define NEGATIVE_SLOPE   (PLINT) 0
#define RATIO_SQ   6.0

Functions

static void set_cond (register int *cond, register PLFLT *a, register PLINT n)
static int find_interval (PLFLT a0, PLFLT a1, PLINT c0, PLINT c1, PLFLT *x)
static void poly (void(*fill)(PLINT, PLFLT *, PLFLT *), PLINT(*defined)(PLFLT, PLFLT), PLFLT *x, PLFLT *y, PLINT v1, PLINT v2, PLINT v3, PLINT v4)
static void exfill (void(*fill)(PLINT, PLFLT *, PLFLT *), PLINT(*defined)(PLFLT, PLFLT), int n, PLFLT *x, PLFLT *y)
static void big_recl (int *cond_code, register int ny, int dx, int dy, int *ix, int *iy)
static void draw_boundary (PLINT slope, PLFLT *x, PLFLT *y)
static PLINT plctest (PLFLT *x, PLFLT level)
static PLINT plctestez (PLFLT *a, PLINT nx, PLINT ny, PLINT ix, PLINT iy, PLFLT level)
static void plshade_int (PLFLT(*f2eval)(PLINT, PLINT, PLPointer), PLPointer f2eval_data, PLFLT(*c2eval)(PLINT, PLINT, PLPointer), PLPointer c2eval_data, PLINT(*defined)(PLFLT, PLFLT), PLFLT missing_min, PLFLT missing_max, PLINT nx, PLINT ny, PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT shade_min, PLFLT shade_max, PLINT sh_cmap, PLFLT sh_color, PLINT sh_width, PLINT min_color, PLINT min_width, PLINT max_color, PLINT max_width, void(*fill)(PLINT, PLFLT *, PLFLT *), PLINT rectangular, void(*pltr)(PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer), PLPointer pltr_data)
MZ_DLLEXPORT void c_plshades (PLFLT **a, PLINT nx, PLINT ny, PLINT(*defined)(PLFLT, PLFLT), PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT *clevel, PLINT nlevel, PLINT fill_width, PLINT cont_color, PLINT cont_width, void(*fill)(PLINT, PLFLT *, PLFLT *), PLINT rectangular, void(*pltr)(PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer), PLPointer pltr_data)
void c_plshade (PLFLT **a, PLINT nx, PLINT ny, PLINT(*defined)(PLFLT, PLFLT), PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT shade_min, PLFLT shade_max, PLINT sh_cmap, PLFLT sh_color, PLINT sh_width, PLINT min_color, PLINT min_width, PLINT max_color, PLINT max_width, void(*fill)(PLINT, PLFLT *, PLFLT *), PLINT rectangular, void(*pltr)(PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer), PLPointer pltr_data)
void c_plshade1 (PLFLT *a, PLINT nx, PLINT ny, PLINT(*defined)(PLFLT, PLFLT), PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT shade_min, PLFLT shade_max, PLINT sh_cmap, PLFLT sh_color, PLINT sh_width, PLINT min_color, PLINT min_width, PLINT max_color, PLINT max_width, void(*fill)(PLINT, PLFLT *, PLFLT *), PLINT rectangular, void(*pltr)(PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer), PLPointer pltr_data)
void plfshade (PLFLT(*f2eval)(PLINT, PLINT, PLPointer), PLPointer f2eval_data, PLFLT(*c2eval)(PLINT, PLINT, PLPointer), PLPointer c2eval_data, PLINT nx, PLINT ny, PLFLT xmin, PLFLT xmax, PLFLT ymin, PLFLT ymax, PLFLT shade_min, PLFLT shade_max, PLINT sh_cmap, PLFLT sh_color, PLINT sh_width, PLINT min_color, PLINT min_width, PLINT max_color, PLINT max_width, void(*fill)(PLINT, PLFLT *, PLFLT *), PLINT rectangular, void(*pltr)(PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer), PLPointer pltr_data)
static void bisect (PLINT(*defined)(PLFLT, PLFLT), PLINT niter, PLFLT x1, PLFLT y1, PLFLT x2, PLFLT y2, PLFLT *xb, PLFLT *yb)

Variables

static PLFLT sh_max
static PLFLT sh_min
static int min_points
static int max_points
static int n_point
static int min_pts [4]
static int max_pts [4]
static PLINT pen_col_min
static PLINT pen_col_max
static PLINT pen_wd_min
static PLINT pen_wd_max
static PLFLT int_val

Define Documentation

#define COND (   x,
  y 
)    cond_code[x*ny + y]

Definition at line 889 of file plshade.c.

#define linear (   val1,
  val2,
  level 
)    ((level - val1) / (val2 - val1))

Definition at line 117 of file plshade.c.

#define MISSING_MAX_DEF   (PLFLT) -1.0

Definition at line 109 of file plshade.c.

#define MISSING_MIN_DEF   (PLFLT) 1.0

Definition at line 108 of file plshade.c.

#define NEG   1

Definition at line 112 of file plshade.c.

#define NEGATIVE_SLOPE   (PLINT) 0

Definition at line 1040 of file plshade.c.

#define OK   0

Definition at line 114 of file plshade.c.

#define POS   8

Definition at line 113 of file plshade.c.

#define POSITIVE_SLOPE   (PLINT) 1

Definition at line 1039 of file plshade.c.

#define RATIO   3

Definition at line 888 of file plshade.c.

#define RATIO_SQ   6.0

Definition at line 1041 of file plshade.c.

#define UNDEF   64

Definition at line 115 of file plshade.c.

#define X (   a,
  b 
)    (x[a*4+b])

Definition at line 1038 of file plshade.c.


Function Documentation

static void big_recl ( int cond_code,
register int  ny,
int  dx,
int  dy,
int ix,
int iy 
) [static]

Definition at line 892 of file plshade.c.

{

    int ok_x, ok_y, j;
    register int i, x, y;
    register int *cond;

    /* ok_x = ok to expand in x direction */
    /* x = current number of points in x direction */

    ok_x = ok_y = 1;
    x = y = 2;

    while (ok_x || ok_y) {
#ifdef RATIO
       if (RATIO * x <= y || RATIO * y <= x)
           break;
#endif
       if (ok_y) {
           /* expand in vertical */
           ok_y = 0;
           if (y == dy)
              continue;
           cond = &COND(0, y);
           for (i = 0; i < x; i++) {
              if (*cond != OK)
                  break;
              cond += ny;
           }
           if (i == x) {
              /* row is ok */
              y++;
              ok_y = 1;
           }
       }
       if (ok_x) {
           if (y == 2)
              break;
           /* expand in x direction */
           ok_x = 0;
           if (x == dx)
              continue;
           cond = &COND(x, 0);
           for (i = 0; i < y; i++) {
              if (*cond++ != OK)
                  break;
           }
           if (i == y) {
              /* column is OK */
              x++;
              ok_x = 1;
           }
       }
    }

    /* found the largest rectangle of 'ix' by 'iy' */
    *ix = --x;
    *iy = --y;

    /* set condition code to UNDEF in interior of rectangle */

    for (i = 1; i < x; i++) {
       cond = &COND(i, 1);
       for (j = 1; j < y; j++) {
           *cond++ = UNDEF;
       }
    }
}

Here is the caller graph for this function:

static void bisect ( PLINT(*)(PLFLT, PLFLT defined,
PLINT  niter,
PLFLT  x1,
PLFLT  y1,
PLFLT  x2,
PLFLT  y2,
PLFLT xb,
PLFLT yb 
) [static]

Definition at line 783 of file plshade.c.

{
    PLFLT xm;
    PLFLT ym;

    if (niter == 0) {
        *xb = x1;
        *yb = y1;
        return;
    }

    xm = (x1 + x2) / 2;
    ym = (y1 + y2) / 2;

    if (defined (xm, ym))
      bisect (defined, niter - 1, xm, ym, x2, y2, xb, yb);
    else
      bisect (defined, niter - 1, x1, y1, xm, ym, xb, yb);      
}

Here is the caller graph for this function:

void c_plshade ( PLFLT **  a,
PLINT  nx,
PLINT  ny,
PLINT(*)(PLFLT, PLFLT defined,
PLFLT  xmin,
PLFLT  xmax,
PLFLT  ymin,
PLFLT  ymax,
PLFLT  shade_min,
PLFLT  shade_max,
PLINT  sh_cmap,
PLFLT  sh_color,
PLINT  sh_width,
PLINT  min_color,
PLINT  min_width,
PLINT  max_color,
PLINT  max_width,
void(*)(PLINT, PLFLT *, PLFLT *)  fill,
PLINT  rectangular,
void(*)(PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer pltr,
PLPointer  pltr_data 
)

Definition at line 238 of file plshade.c.

{
    PLfGrid2 grid;

    grid.f = a;
    grid.nx = nx;
    grid.ny = ny;

    plshade_int( plf2eval2, (PLPointer) &grid,
                 NULL, NULL,
/*          plc2eval, (PLPointer) &cgrid,*/
                 defined, MISSING_MIN_DEF, MISSING_MAX_DEF, nx, ny, xmin, 
                 xmax, ymin, ymax, shade_min, shade_max,
                 sh_cmap, sh_color, sh_width,
                 min_color, min_width, max_color, max_width,
                 fill, rectangular, pltr, pltr_data );
}

Here is the call graph for this function:

void c_plshade1 ( PLFLT a,
PLINT  nx,
PLINT  ny,
PLINT(*)(PLFLT, PLFLT defined,
PLFLT  xmin,
PLFLT  xmax,
PLFLT  ymin,
PLFLT  ymax,
PLFLT  shade_min,
PLFLT  shade_max,
PLINT  sh_cmap,
PLFLT  sh_color,
PLINT  sh_width,
PLINT  min_color,
PLINT  min_width,
PLINT  max_color,
PLINT  max_width,
void(*)(PLINT, PLFLT *, PLFLT *)  fill,
PLINT  rectangular,
void(*)(PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer pltr,
PLPointer  pltr_data 
)

Definition at line 272 of file plshade.c.

{
    PLfGrid grid;

    grid.f = a;
    grid.nx = nx;
    grid.ny = ny;

    plshade_int( plf2eval, (PLPointer) &grid,
                 NULL, NULL,
/*          plc2eval, (PLPointer) &cgrid,*/
                 defined, MISSING_MIN_DEF, MISSING_MAX_DEF, nx, ny, xmin, 
                 xmax, ymin, ymax, shade_min, shade_max,
                 sh_cmap, sh_color, sh_width,
                 min_color, min_width, max_color, max_width,
                 fill, rectangular, pltr, pltr_data );
}

Here is the call graph for this function:

MZ_DLLEXPORT void c_plshades ( PLFLT **  a,
PLINT  nx,
PLINT  ny,
PLINT(*)(PLFLT, PLFLT defined,
PLFLT  xmin,
PLFLT  xmax,
PLFLT  ymin,
PLFLT  ymax,
PLFLT clevel,
PLINT  nlevel,
PLINT  fill_width,
PLINT  cont_color,
PLINT  cont_width,
void(*)(PLINT, PLFLT *, PLFLT *)  fill,
PLINT  rectangular,
void(*)(PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer pltr,
PLPointer  pltr_data 
)

Definition at line 192 of file plshade.c.

{
   PLFLT shade_min, shade_max, shade_color;
   PLINT i, init_color, init_width;

   for (i = 0; i < nlevel-1; i++) {
      shade_min = clevel[i];
      shade_max = clevel[i+1];
      shade_color = i / (PLFLT) (nlevel-2);
      /* The constants in order mean 
       * (1) color map1,
       * (0, 0, 0, 0) all edge effects will be done with plcont rather
       * than the normal plshade drawing which gets partially blocked
       * when sequential shading is done as in the present case */
      
      plshade(a, nx, ny, defined, xmin, xmax, ymin, ymax,
             shade_min, shade_max,
             1, shade_color, fill_width,
             0, 0, 0, 0,
             fill, rectangular, pltr, pltr_data);
   }
   if(cont_color > 0 && cont_width > 0) {
      init_color = plsc->icol0;
      init_width = plsc->width;
      plcol0(cont_color);
      plwid(cont_width);
      plcont(a, nx, ny, 1, nx, 1, ny, clevel, nlevel, pltr, pltr_data);
      plcol0(init_color);
      plwid(init_width);
   }
}
static void draw_boundary ( PLINT  slope,
PLFLT x,
PLFLT y 
) [static]

Definition at line 969 of file plshade.c.

{
    int i;

    if (pen_col_min != 0 && pen_wd_min != 0 && min_points != 0) {
       plcol0(pen_col_min);
       plwid(pen_wd_min);
       if (min_points == 4 && slope == 0) {
           /* swap points 1 and 3 */
           i = min_pts[1];
           min_pts[1] = min_pts[3];
           min_pts[3] = i;
       }
       pljoin(x[min_pts[0]], y[min_pts[0]], x[min_pts[1]], y[min_pts[1]]);
       if (min_points == 4) {
           pljoin(x[min_pts[2]], y[min_pts[2]], x[min_pts[3]],
                 y[min_pts[3]]);
       }
    }
    if (pen_col_max != 0 && pen_wd_max != 0 && max_points != 0) {
       plcol0(pen_col_max);
       plwid(pen_wd_max);
       if (max_points == 4 && slope == 0) {
           /* swap points 1 and 3 */
           i = max_pts[1];
           max_pts[1] = max_pts[3];
           max_pts[3] = i;
       }
       pljoin(x[max_pts[0]], y[max_pts[0]], x[max_pts[1]], y[max_pts[1]]);
       if (max_points == 4) {
           pljoin(x[max_pts[2]], y[max_pts[2]], x[max_pts[3]],
                 y[max_pts[3]]);
       }
    }
}

Here is the caller graph for this function:

static void exfill ( void(*)(PLINT, PLFLT *, PLFLT *)  fill,
PLINT(*)(PLFLT, PLFLT defined,
int  n,
PLFLT x,
PLFLT y 
) [static]

Definition at line 812 of file plshade.c.

{
    if (defined == NULL)

        (*fill) (n, x, y);

    else {
        PLFLT xx[16];  
       PLFLT yy[16];
       PLFLT xb, yb;  
       PLINT count = 0;
       PLINT is_inside = defined (x[n-1], y[n-1]);
       PLINT i;

        for (i = 0; i < n; i++) {

           if (defined(x[i], y[i])) {
               if (!is_inside) {
                  if (i > 0)
                      bisect (defined, 10,
                            x[i], y[i], x[i-1], y[i-1], &xb, &yb);
                  else
                      bisect (defined, 10,
                            x[i], y[i], x[n-1], y[n-1], &xb, &yb);
                  xx[count] = xb;
                  yy[count++] = yb;
              }
              xx[count] = x[i];
              yy[count++] = y[i];
              is_inside = 1;
           }
           else {
               if (is_inside) {
                  if (i > 0)
                      bisect (defined, 10,
                            x[i-1], y[i-1], x[i], y[i], &xb, &yb);
                  else
                      bisect (defined, 10,
                            x[n-1], y[n-1], x[i], y[i], &xb, &yb);
                  xx[count] = xb;
                  yy[count++] = yb;
                  is_inside = 0;
              }
           }
       }
       
       if (count)
           (*fill) (count, xx, yy);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int find_interval ( PLFLT  a0,
PLFLT  a1,
PLINT  c0,
PLINT  c1,
PLFLT x 
) [static]

Definition at line 703 of file plshade.c.

{
    register int n;

    n = 0;
    if (c0 == OK) {
       x[n++] = 0.0;
       n_point++;
    }
    if (c0 == c1)
       return n;

    if (c0 == NEG || c1 == POS) {
       if (c0 == NEG) {
           x[n++] = linear(a0, a1, sh_min);
           min_pts[min_points++] = n_point++;
       }
       if (c1 == POS) {
           x[n++] = linear(a0, a1, sh_max);
           max_pts[max_points++] = n_point++;
       }
    }
    if (c0 == POS || c1 == NEG) {
       if (c0 == POS) {
           x[n++] = linear(a0, a1, sh_max);
           max_pts[max_points++] = n_point++;
       }
       if (c1 == NEG) {
           x[n++] = linear(a0, a1, sh_min);
           min_pts[min_points++] = n_point++;
       }
    }
    return n;
}

Here is the caller graph for this function:

static PLINT plctest ( PLFLT x,
PLFLT  level 
) [static]

Definition at line 1044 of file plshade.c.

{
    int i, j;
    double t[4], sorted[4], temp;

    sorted[0] = t[0] = X(1,1);
    sorted[1] = t[1] = X(2,2);
    sorted[2] = t[2] = X(1,2);
    sorted[3] = t[3] = X(2,1);

    for (j = 1; j < 4; j++) {
       temp = sorted[j];
       i = j - 1;
       while (i >= 0 && sorted[i] > temp) {
           sorted[i+1] = sorted[i];
           i--;
       }
       sorted[i+1] = temp;
    }
    /* sorted[0] == min */

    /* find min contour */
    temp = int_val * ceil(sorted[0]/int_val);
    if (temp < sorted[1]) {
       /* one contour line */
       for (i = 0; i < 4; i++) {
           if (t[i] < temp) return i/2;
       }
    }
       
    /* find max contour */
    temp = int_val * floor(sorted[3]/int_val);
    if (temp > sorted[2]) {
       /* one contour line */
       for (i = 0; i < 4; i++) {
           if (t[i] > temp) return i/2;
       }
    }
    /* nothing better to do - be consistant */
    return POSITIVE_SLOPE;
}

Here is the caller graph for this function:

static PLINT plctestez ( PLFLT a,
PLINT  nx,
PLINT  ny,
PLINT  ix,
PLINT  iy,
PLFLT  level 
) [static]

Definition at line 1096 of file plshade.c.

{

    PLFLT x[4][4];
    int i, j, ii, jj;

    for (i = 0; i < 4; i++) {
       ii = ix + i - 1;
       ii = MAX(0, ii);
       ii = MIN(ii, nx - 1);
       for (j = 0; j < 4; j++) {
           jj = iy + j - 1;
           jj = MAX(0, jj);
           jj = MIN(jj, ny - 1);
           x[i][j] = a[ii * ny + jj];
       }
    }
    return plctest(&(x[0][0]), level);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void plfshade ( PLFLT(*)(PLINT, PLINT, PLPointer f2eval,
PLPointer  f2eval_data,
PLFLT(*)(PLINT, PLINT, PLPointer c2eval,
PLPointer  c2eval_data,
PLINT  nx,
PLINT  ny,
PLFLT  xmin,
PLFLT  xmax,
PLFLT  ymin,
PLFLT  ymax,
PLFLT  shade_min,
PLFLT  shade_max,
PLINT  sh_cmap,
PLFLT  sh_color,
PLINT  sh_width,
PLINT  min_color,
PLINT  min_width,
PLINT  max_color,
PLINT  max_width,
void(*)(PLINT, PLFLT *, PLFLT *)  fill,
PLINT  rectangular,
void(*)(PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer pltr,
PLPointer  pltr_data 
)

Definition at line 306 of file plshade.c.

{
    plshade_int(f2eval,  f2eval_data, c2eval, c2eval_data, 
        NULL, MISSING_MIN_DEF, MISSING_MAX_DEF,
        nx, ny, xmin, xmax, ymin, ymax,
        shade_min, shade_max, sh_cmap, sh_color, sh_width,
        min_color, min_width, max_color, max_width,
        fill, rectangular, pltr, pltr_data);
}

Here is the call graph for this function:

static void plshade_int ( PLFLT(*)(PLINT, PLINT, PLPointer f2eval,
PLPointer  f2eval_data,
PLFLT(*)(PLINT, PLINT, PLPointer c2eval,
PLPointer  c2eval_data,
PLINT(*)(PLFLT, PLFLT defined,
PLFLT  missing_min,
PLFLT  missing_max,
PLINT  nx,
PLINT  ny,
PLFLT  xmin,
PLFLT  xmax,
PLFLT  ymin,
PLFLT  ymax,
PLFLT  shade_min,
PLFLT  shade_max,
PLINT  sh_cmap,
PLFLT  sh_color,
PLINT  sh_width,
PLINT  min_color,
PLINT  min_width,
PLINT  max_color,
PLINT  max_width,
void(*)(PLINT, PLFLT *, PLFLT *)  fill,
PLINT  rectangular,
void(*)(PLFLT, PLFLT, PLFLT *, PLFLT *, PLPointer pltr,
PLPointer  pltr_data 
) [static]

Definition at line 369 of file plshade.c.

{

    PLINT init_width, n, slope = 0, ix, iy;
    int count, i, j, nxny;
    PLFLT *a, *a0, *a1, dx, dy;
    PLFLT x[8], y[8], xp[2], tx, ty;
    int *c, *c0, *c1;

    if (plsc->level < 3) {
       plabort("plfshade: window must be set up first");
       return;
    }

    if (nx <= 0 || ny <= 0) {
       plabort("plfshade: nx and ny must be positive");
       return;
    }

    if (shade_min >= shade_max) {
       plabort("plfshade: shade_max must exceed shade_min");
       return;
    }

    if (pltr == NULL || pltr_data == NULL)
       rectangular = 1;

    int_val = shade_max - shade_min;
    init_width = plsc->width;

    pen_col_min = min_color;
    pen_col_max = max_color;

    pen_wd_min = min_width;
    pen_wd_max = max_width;

    plstyl((PLINT) 0, NULL, NULL);
    plwid(sh_width); 
    if (fill != NULL) {
        switch (sh_cmap) {
        case 0:
            plcol0((PLINT) sh_color);
           break;
        case 1:
           plcol1(sh_color);
           break;
        default:
           plabort("plfshade: invalid color map selection");
           return;
        }
    }
    /* alloc space for value array, and initialize */
    /* This is only a temporary kludge */
    nxny = nx * ny;
    if ((a = (PLFLT *) malloc(nxny * sizeof(PLFLT))) == NULL) {
       plabort("plfshade: unable to allocate memory for value array");
       return;
    }

    for (ix = 0; ix < nx; ix++) 
       for (iy = 0; iy < ny; iy++) 
           a[iy + ix*ny] = f2eval(ix, iy, f2eval_data);

    /* alloc space for condition codes */

    if ((c = (int *) malloc(nxny * sizeof(int))) == NULL) {
       plabort("plfshade: unable to allocate memory for condition codes");
       free(a);
       return;
    }

    sh_min = shade_min;
    sh_max = shade_max;

    set_cond(c, a, nxny);
    dx = (xmax - xmin) / (nx - 1);
    dy = (ymax - ymin) / (ny - 1);
    a0 = a;
    a1 = a + ny;
    c0 = c;
    c1 = c + ny;

    for (ix = 0; ix < nx - 1; ix++) {

       for (iy = 0; iy < ny - 1; iy++) {

           count = c0[iy] + c0[iy + 1] + c1[iy] + c1[iy + 1];

           /* No filling needs to be done for these cases */

           if (count >= UNDEF)
              continue;
           if (count == 4 * POS)
              continue;
           if (count == 4 * NEG)
              continue;

           /* Entire rectangle can be filled */

           if (count == 4 * OK) {
              /* find biggest rectangle that fits */
              if (rectangular) {
                  big_recl(c0 + iy, ny, nx - ix, ny - iy, &i, &j);
              }
              else {
                  i = j = 1;
              }
              x[0] = x[1] = ix;
              x[2] = x[3] = ix+i;
              y[0] = y[3] = iy;
              y[1] = y[2] = iy+j;

              if (pltr && pltr_data) {
                  for (i = 0; i < 4; i++) {
                     (*pltr) (x[i], y[i], &tx, &ty, pltr_data);
                     x[i] = tx;
                     y[i] = ty;
                  }
              }
              else {
                  for (i = 0; i < 4; i++) {
                     x[i] = xmin + x[i]*dx;
                     y[i] = ymin + y[i]*dy;
                  }
              }
              if (fill != NULL)
                  exfill (fill, defined, (PLINT) 4, x, y);
              iy += j - 1;
              continue;
           }

           /* Only part of rectangle can be filled */

           n_point = min_points = max_points = 0;
           n = find_interval(a0[iy], a0[iy + 1], c0[iy], c0[iy + 1], xp);
           for (j = 0; j < n; j++) {
              x[j] = ix;
              y[j] = iy + xp[j];
           }

           i = find_interval(a0[iy + 1], a1[iy + 1],
                           c0[iy + 1], c1[iy + 1], xp);

           for (j = 0; j < i; j++) {
              x[j + n] = ix + xp[j];
              y[j + n] = iy + 1;
           }
           n += i;

           i = find_interval(a1[iy + 1], a1[iy], c1[iy + 1], c1[iy], xp);
           for (j = 0; j < i; j++) {
              x[n + j] = ix + 1;
              y[n + j] = iy + 1 - xp[j];
           }
           n += i;

           i = find_interval(a1[iy], a0[iy], c1[iy], c0[iy], xp);
           for (j = 0; j < i; j++) {
              x[n + j] = ix + 1 - xp[j];
              y[n + j] = iy;
           }
           n += i;

           if (pltr && pltr_data) {
              for (i = 0; i < n; i++) {
                  (*pltr) (x[i], y[i], &tx, &ty, pltr_data);
                  x[i] = tx;
                  y[i] = ty;
              }
           }
           else {
              for (i = 0; i < n; i++) {
                  x[i] = xmin + x[i]*dx;
                  y[i] = ymin + y[i]*dy;
              }
           }

           if (min_points == 4)
              slope = plctestez(a, nx, ny, ix, iy, shade_min);
           if (max_points == 4)
              slope = plctestez(a, nx, ny, ix, iy, shade_max);

           /* n = number of end of line segments */
           /* min_points = number times shade_min meets edge */
           /* max_points = number times shade_max meets edge */

           /* special cases: check number of times a contour is in a box */

           switch ((min_points << 3) + max_points) {
             case 000:
             case 020:
             case 002:
             case 022:
              if (fill != NULL && n > 0)
                  exfill (fill, defined, n, x, y);
              break;
             case 040:      /* 2 contour lines in box */
             case 004:
              if (n != 6)
                  fprintf(stderr, "plfshade err n=%d !6", (int) n);
              if (slope == 1 && c0[iy] == OK) {
                  if (fill != NULL)
                     exfill (fill, defined, n, x, y);
              }
              else if (slope == 1) {
                  poly(fill, defined, x, y, 0, 1, 2, -1);
                  poly(fill, defined, x, y, 3, 4, 5, -1);
              }
              else if (c0[iy + 1] == OK) {
                  if (fill != NULL)
                     exfill (fill, defined, n, x, y);
              }
              else {
                  poly(fill, defined, x, y, 0, 1, 5, -1);
                  poly(fill, defined, x, y, 2, 3, 4, -1);
              }
              break;
             case 044:
              if (n != 8)
                  fprintf(stderr, "plfshade err n=%d !8", (int) n);
              if (slope == 1) {
                  poly(fill, defined, x, y, 0, 1, 2, 3);
                  poly(fill, defined, x, y, 4, 5, 6, 7);
              }
              else {
                  poly(fill, defined, x, y, 0, 1, 6, 7);
                  poly(fill, defined, x, y, 2, 3, 4, 5);
              }
              break;
             case 024:
             case 042:
              /* 3 contours */
              if (n != 7)
                  fprintf(stderr, "plfshade err n=%d !7", (int) n);

              if ((c0[iy] == OK || c1[iy+1] == OK) && slope == 1) {
                  if (fill != NULL)
                      exfill (fill, defined, n, x, y);
              }
              else if ((c0[iy+1] == OK || c1[iy] == OK) && slope == 0) {
                  if (fill !=NULL)
                      exfill (fill, defined, n, x, y);
              }

              else if (c0[iy] == OK) {
                  poly(fill, defined, x, y, 0, 1, 6, -1);
                  poly(fill, defined, x, y, 2, 3, 4, 5);
              }
              else if (c0[iy+1] == OK) {
                  poly(fill, defined, x, y, 0, 1, 2, -1);
                  poly(fill, defined, x, y, 3, 4, 5, 6);
              }
              else if (c1[iy+1] == OK) {
                  poly(fill, defined, x, y, 0, 1, 5, 6);
                  poly(fill, defined, x, y, 2, 3, 4, -1);
              }
              else if (c1[iy] == OK) {
                  poly(fill, defined, x, y, 0, 1, 2, 3);
                  poly(fill, defined, x, y, 4, 5, 6, -1);
              }
              else {
                  fprintf(stderr, "plfshade err logic case 024:042\n");
              }
              break;
             default:
              fprintf(stderr, "prog err switch\n");
              break;
           }
           draw_boundary(slope, x, y);

           if (fill != NULL) {
               plwid(sh_width);
              if (sh_cmap == 0) plcol0((PLINT) sh_color);
              else if (sh_cmap == 1) plcol1(sh_color);
           }
       }

       a0 = a1;
       c0 = c1;
       a1 += ny;
       c1 += ny;
    }

    free(c);
    free(a);
    plwid(init_width);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void poly ( void(*)(PLINT, PLFLT *, PLFLT *)  fill,
PLINT(*)(PLFLT, PLFLT defined,
PLFLT x,
PLFLT y,
PLINT  v1,
PLINT  v2,
PLINT  v3,
PLINT  v4 
) [static]

Definition at line 746 of file plshade.c.

{
    register PLINT n = 0;
    PLFLT xx[4], yy[4];

    if (fill == NULL)
       return;
    if (v1 >= 0) {
       xx[n] = x[v1];
       yy[n++] = y[v1];
    }
    if (v2 >= 0) {
       xx[n] = x[v2];
       yy[n++] = y[v2];
    }
    if (v3 >= 0) {
       xx[n] = x[v3];
       yy[n++] = y[v3];
    }
    if (v4 >= 0) {
       xx[n] = x[v4];
       yy[n++] = y[v4];
    }
    exfill (fill, defined, n, xx, yy);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void set_cond ( register int cond,
register PLFLT a,
register PLINT  n 
) [static]

Definition at line 678 of file plshade.c.

{
    while (n--) {
        if (*a < sh_min)
           *cond++ = NEG;
       else if (*a > sh_max)
           *cond++ = POS;
       else
           *cond++ = OK;
       a++;
    }
}

Here is the caller graph for this function:


Variable Documentation

PLFLT int_val [static]

Definition at line 126 of file plshade.c.

int max_points [static]

Definition at line 122 of file plshade.c.

int max_pts[4] [static]

Definition at line 123 of file plshade.c.

int min_points [static]

Definition at line 122 of file plshade.c.

int min_pts[4] [static]

Definition at line 123 of file plshade.c.

int n_point [static]

Definition at line 122 of file plshade.c.

PLINT pen_col_max [static]

Definition at line 124 of file plshade.c.

PLINT pen_col_min [static]

Definition at line 124 of file plshade.c.

PLINT pen_wd_max [static]

Definition at line 125 of file plshade.c.

PLINT pen_wd_min [static]

Definition at line 125 of file plshade.c.

PLFLT sh_max [static]

Definition at line 121 of file plshade.c.

PLFLT sh_min [static]

Definition at line 121 of file plshade.c.