Back to index

radiance  4R0+20100331
Defines | Functions | Variables
cgraph.c File Reference
#include <stdio.h>
#include "rterror.h"
#include "meta.h"
#include "mgvars.h"

Go to the source code of this file.

Defines

#define FHUGE   1e10
#define MAXSIZE   10000 /* Maximum size in characters of output */

Functions

static void climits (void)
static void cstretch (int c, double x, double y)
void cgraph (int width, int length)
void cplot (void)
void cpoint (int c, double x, double y)

Variables

static const char RCSid [] = "$Id: cgraph.c,v 1.2 2003/11/15 02:13:36 schorsch Exp $"
char * progname
static char outcarr [MAXSIZE]
static double xmin = XMAX
static double xmax = XMIN
static double ymin = YMAX
static double ymax = YMIN
static int dwidth
static int dlength
static int nplottable

Define Documentation

#define FHUGE   1e10

Definition at line 19 of file cgraph.c.

#define MAXSIZE   10000 /* Maximum size in characters of output */

Definition at line 21 of file cgraph.c.


Function Documentation

void cgraph ( int  width,
int  length 
)

Definition at line 39 of file cgraph.c.

{
       if (width * length > MAXSIZE) {
              fprintf(stderr, "%s: page too big\n", progname);
              quit(1);
       }
       dwidth = width;
       dlength = length;
       climits();                  /* get min & max values */
       cplot();                    /* do character plot */
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void climits ( void  ) [static]

Definition at line 56 of file cgraph.c.

{
       int  i;

       xmin = gparam[XMIN].flags & DEFINED ?
                     varvalue(gparam[XMIN].name) :
                     FHUGE ;
       xmax = gparam[XMAX].flags & DEFINED ?
                     varvalue(gparam[XMAX].name) :
                     -FHUGE ;
       ymin = gparam[YMIN].flags & DEFINED ?
                     varvalue(gparam[YMIN].name) :
                     FHUGE ;
       ymax = gparam[YMAX].flags & DEFINED ?
                     varvalue(gparam[YMAX].name) :
                     -FHUGE ;

       nplottable = 0;
       for (i = 0; i < MAXCUR; i++)
              mgcurve(i, cstretch);

       if (nplottable == 0) {
              fprintf(stderr, "%s: no plottable data\n", progname);
              quit(1);
       }
       printf("XMIN= %f  XMAX= %f  YMIN= %f  YMAX= %f\n",
                     xmin, xmax, ymin, ymax);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cplot ( void  )

Definition at line 120 of file cgraph.c.

{
       int  i, j;
       register char  *op;

       for (op = outcarr+dlength*dwidth; op > outcarr; )
              *--op = ' ';

       for (i = 0; i < MAXCUR; i++)
              mgcurve(i, cpoint);

       for (i = 0; i < dlength; i++) {
              for (j = 0; j < dwidth; j++)
                     putchar(*op++);
              putchar('\n');
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void cpoint ( int  c,
double  x,
double  y 
)

Definition at line 140 of file cgraph.c.

{
       register int  ndx;

       if (x < xmin || x > xmax || y < ymin || y > ymax)
              return;

       ndx = (dlength-1)*(1.0 - (y - ymin)/(ymax - ymin)) + 0.5;
       ndx = dwidth*ndx + (dwidth-1)*(x-xmin)/(xmax-xmin) + 0.5;

       if (outcarr[ndx] == ' ')
              outcarr[ndx] = c+'A';
       else if (outcarr[ndx] > '1' && outcarr[ndx] < '9')
              outcarr[ndx]++;
       else if (outcarr[ndx] == '9')
              outcarr[ndx] = '*';
       else if (outcarr[ndx] != '*')
              outcarr[ndx] = '2';
}

Here is the caller graph for this function:

void cstretch ( int  c,
double  x,
double  y 
) [static]

Definition at line 87 of file cgraph.c.

{
       if (gparam[XMIN].flags & DEFINED &&
                     x < xmin)
              return;
       if (gparam[XMAX].flags & DEFINED &&
                     x > xmax)
              return;
       if (gparam[YMIN].flags & DEFINED &&
                     y < ymin)
              return;
       if (gparam[YMAX].flags & DEFINED &&
                     y > ymax)
              return;

       if (x < xmin)
              xmin = x;
       if (x > xmax)
              xmax = x;
       if (y < ymin)
              ymin = y;
       if (y > ymax)
              ymax = y;
              
       nplottable++;
}

Here is the caller graph for this function:


Variable Documentation

int dlength [static]

Definition at line 30 of file cgraph.c.

int dwidth [static]

Definition at line 30 of file cgraph.c.

int nplottable [static]

Definition at line 32 of file cgraph.c.

char outcarr[MAXSIZE] [static]

Definition at line 25 of file cgraph.c.

char* progname

Definition at line 21 of file histo.c.

const char RCSid[] = "$Id: cgraph.c,v 1.2 2003/11/15 02:13:36 schorsch Exp $" [static]

Definition at line 2 of file cgraph.c.

double xmax = XMIN [static]

Definition at line 27 of file cgraph.c.

double xmin = XMAX [static]

Definition at line 27 of file cgraph.c.

double ymax = YMIN [static]

Definition at line 28 of file cgraph.c.

double ymin = YMAX [static]

Definition at line 28 of file cgraph.c.